just-bash 2.5.0 → 2.5.1

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 (36) hide show
  1. package/dist/bin/chunks/chunk-CTLU5QUH.js +17 -0
  2. package/dist/bin/chunks/{grep-WDHYDUUD.js → grep-QCXXYC54.js} +1 -1
  3. package/dist/bin/chunks/rg-GVIT6FTE.js +33 -0
  4. package/dist/bin/just-bash.js +1 -1
  5. package/dist/bin/shell/chunks/chunk-CTLU5QUH.js +17 -0
  6. package/dist/bin/shell/chunks/{grep-WDHYDUUD.js → grep-QCXXYC54.js} +1 -1
  7. package/dist/bin/shell/chunks/rg-GVIT6FTE.js +33 -0
  8. package/dist/bin/shell/shell.js +1 -1
  9. package/dist/bundle/browser.js +379 -375
  10. package/dist/bundle/chunks/chunk-OHJS5H37.js +16 -0
  11. package/dist/bundle/chunks/{grep-QVR5G7SC.js → grep-TUWLGQC2.js} +1 -1
  12. package/dist/bundle/chunks/rg-KTCMPGU6.js +32 -0
  13. package/dist/bundle/index.js +1 -1
  14. package/dist/commands/rg/file-types.d.ts +33 -7
  15. package/dist/commands/rg/gitignore.d.ts +32 -3
  16. package/dist/commands/rg/rg-options.d.ts +14 -0
  17. package/dist/commands/search-engine/index.d.ts +1 -1
  18. package/dist/commands/search-engine/regex.d.ts +10 -0
  19. package/dist/fs/in-memory-fs/in-memory-fs.d.ts +51 -0
  20. package/dist/fs/in-memory-fs/index.d.ts +1 -0
  21. package/dist/fs/init.d.ts +12 -0
  22. package/dist/fs/interface.d.ts +203 -0
  23. package/dist/fs/mountable-fs/index.d.ts +1 -0
  24. package/dist/fs/mountable-fs/mountable-fs.d.ts +108 -0
  25. package/dist/fs/overlay-fs/index.d.ts +1 -0
  26. package/dist/fs/overlay-fs/overlay-fs.d.ts +107 -0
  27. package/dist/fs/read-write-fs/index.d.ts +1 -0
  28. package/dist/fs/read-write-fs/read-write-fs.d.ts +47 -0
  29. package/dist/fs/utils.d.ts +17 -0
  30. package/package.json +2 -3
  31. package/dist/bin/chunks/chunk-X4WRNADE.js +0 -17
  32. package/dist/bin/chunks/rg-ALK3CYAN.js +0 -29
  33. package/dist/bin/shell/chunks/chunk-X4WRNADE.js +0 -17
  34. package/dist/bin/shell/chunks/rg-ALK3CYAN.js +0 -29
  35. package/dist/bundle/chunks/chunk-7VH6U2UX.js +0 -16
  36. package/dist/bundle/chunks/rg-43HLKW4V.js +0 -28
@@ -1,6 +1,6 @@
1
- var Gd=Object.create;var os=Object.defineProperty;var qd=Object.getOwnPropertyDescriptor;var Vd=Object.getOwnPropertyNames;var Zd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty;var C=(t,e)=>()=>(t&&(e=t(t=0)),e);var qn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),L=(t,e)=>{for(var n in e)os(t,n,{get:e[n],enumerable:!0})},Qd=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Vd(e))!Kd.call(t,s)&&s!==n&&os(t,s,{get:()=>e[s],enumerable:!(r=qd(e,s))||r.enumerable});return t};var oo=(t,e,n)=>(n=t!=null?Gd(Zd(t)):{},Qd(e||!t||!t.__esModule?os(n,"default",{value:t,enumerable:!0}):n,t));var ao={};L(ao,{echoCommand:()=>Jd});function Xd(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"){if(n+1>=t.length){e+="\\";break}let r=t[n+1];switch(r){case"\\":e+="\\",n+=2;break;case"n":e+=`
2
- `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"e":case"E":e+="\x1B",n+=2;break;case"c":return{output:e,stop:!0};case"0":{let s="",i=n+2;for(;i<t.length&&i<n+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\0";else{let o=parseInt(s,8)%256;e+=String.fromCharCode(o)}n=i;break}case"x":{let s="",i=n+2;for(;i<t.length&&i<n+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\x",n+=2;else{let o=parseInt(s,16);e+=String.fromCharCode(o),n=i}break}case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\u",n+=2;else{let o=parseInt(s,16);e+=String.fromCodePoint(o),n=i}break}case"U":{let s="",i=n+2;for(;i<t.length&&i<n+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\U",n+=2;else{let o=parseInt(s,16);try{e+=String.fromCodePoint(o)}catch{e+=`\\U${s}`}n=i}break}default:e+=`\\${r}`,n+=2}}else e+=t[n],n++;return{output:e,stop:!1}}var Jd,lo=C(()=>{"use strict";Jd={name:"echo",async execute(t,e){let n=!1,r=!1,s=0;for(;s<t.length;){let o=t[s];if(o==="-n")n=!0,s++;else if(o==="-e")r=!0,s++;else if(o==="-E")r=!1,s++;else if(o==="-ne"||o==="-en")n=!0,r=!0,s++;else break}let i=t.slice(s).join(" ");if(r){let o=Xd(i);if(i=o.output,o.stop)return{stdout:i,stderr:"",exitCode:0}}return n||(i+=`
3
- `),{stdout:i,stderr:"",exitCode:0}}}});function N(t){let e=`${t.name} - ${t.summary}
1
+ var Kd=Object.create;var as=Object.defineProperty;var Qd=Object.getOwnPropertyDescriptor;var Xd=Object.getOwnPropertyNames;var Jd=Object.getPrototypeOf,Yd=Object.prototype.hasOwnProperty;var C=(t,e)=>()=>(t&&(e=t(t=0)),e);var Zn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),_=(t,e)=>{for(var n in e)as(t,n,{get:e[n],enumerable:!0})},ep=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Xd(e))!Yd.call(t,s)&&s!==n&&as(t,s,{get:()=>e[s],enumerable:!(r=Qd(e,s))||r.enumerable});return t};var lo=(t,e,n)=>(n=t!=null?Kd(Jd(t)):{},ep(e||!t||!t.__esModule?as(n,"default",{value:t,enumerable:!0}):n,t));var co={};_(co,{echoCommand:()=>np});function tp(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"){if(n+1>=t.length){e+="\\";break}let r=t[n+1];switch(r){case"\\":e+="\\",n+=2;break;case"n":e+=`
2
+ `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"e":case"E":e+="\x1B",n+=2;break;case"c":return{output:e,stop:!0};case"0":{let s="",i=n+2;for(;i<t.length&&i<n+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\0";else{let o=parseInt(s,8)%256;e+=String.fromCharCode(o)}n=i;break}case"x":{let s="",i=n+2;for(;i<t.length&&i<n+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\x",n+=2;else{let o=parseInt(s,16);e+=String.fromCharCode(o),n=i}break}case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\u",n+=2;else{let o=parseInt(s,16);e+=String.fromCodePoint(o),n=i}break}case"U":{let s="",i=n+2;for(;i<t.length&&i<n+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\U",n+=2;else{let o=parseInt(s,16);try{e+=String.fromCodePoint(o)}catch{e+=`\\U${s}`}n=i}break}default:e+=`\\${r}`,n+=2}}else e+=t[n],n++;return{output:e,stop:!1}}var np,uo=C(()=>{"use strict";np={name:"echo",async execute(t,e){let n=!1,r=!1,s=0;for(;s<t.length;){let o=t[s];if(o==="-n")n=!0,s++;else if(o==="-e")r=!0,s++;else if(o==="-E")r=!1,s++;else if(o==="-ne"||o==="-en")n=!0,r=!0,s++;else break}let i=t.slice(s).join(" ");if(r){let o=tp(i);if(i=o.output,o.stop)return{stdout:i,stderr:"",exitCode:0}}return n||(i+=`
3
+ `),{stdout:i,stderr:"",exitCode:0}}}});function k(t){let e=`${t.name} - ${t.summary}
4
4
 
5
5
  `;if(e+=`Usage: ${t.usage}
6
6
  `,t.description){if(e+=`
@@ -19,75 +19,75 @@ Examples:
19
19
  `}if(t.notes&&t.notes.length>0){e+=`
20
20
  Notes:
21
21
  `;for(let n of t.notes)e+=` ${n}
22
- `}return{stdout:e,stderr:"",exitCode:0}}function I(t){return t.includes("--help")}function D(t,e){return{stdout:"",stderr:e.startsWith("--")?`${t}: unrecognized option '${e}'
22
+ `}return{stdout:e,stderr:"",exitCode:0}}function N(t){return t.includes("--help")}function L(t,e){return{stdout:"",stderr:e.startsWith("--")?`${t}: unrecognized option '${e}'
23
23
  `:`${t}: invalid option -- '${e.replace(/^-/,"")}'
24
- `,exitCode:1}}var j=C(()=>{"use strict"});function K(t,e,n){let r=new Map,s=new Map;for(let[l,c]of Object.entries(n)){let u={name:l,type:c.type};c.short&&r.set(c.short,u),c.long&&s.set(c.long,u)}let i={};for(let[l,c]of Object.entries(n))c.default!==void 0?i[l]=c.default:c.type==="boolean"&&(i[l]=!1);let o=[],a=!1;for(let l=0;l<e.length;l++){let c=e[l];if(a||!c.startsWith("-")||c==="-"){o.push(c);continue}if(c==="--"){a=!0;continue}if(c.startsWith("--")){let u=c.indexOf("="),f,d;u!==-1?(f=c.slice(2,u),d=c.slice(u+1)):f=c.slice(2);let p=s.get(f);if(!p)return{ok:!1,error:D(t,c)};let{name:h,type:m}=p;if(m==="boolean")i[h]=!0;else{if(d===void 0){if(l+1>=e.length)return{ok:!1,error:{stdout:"",stderr:`${t}: option '--${f}' requires an argument
25
- `,exitCode:1}};d=e[++l]}i[h]=m==="number"?parseInt(d,10):d}}else{let u=c.slice(1);for(let f=0;f<u.length;f++){let d=u[f],p=r.get(d);if(!p)return{ok:!1,error:D(t,`-${d}`)};let{name:h,type:m}=p;if(m==="boolean")i[h]=!0;else{let g;if(f+1<u.length)g=u.slice(f+1);else if(l+1<e.length)g=e[++l];else return{ok:!1,error:{stdout:"",stderr:`${t}: option requires an argument -- '${d}'
26
- `,exitCode:1}};i[h]=m==="number"?parseInt(g,10):g;break}}}}return{ok:!0,result:{flags:i,positional:o}}}var Ae=C(()=>{"use strict";j()});var Ht=C(()=>{"use strict"});async function kt(t,e,n){let{cmdName:r,allowStdinMarker:s=!0,stopOnError:i=!1,batchSize:o=100}=n;if(e.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let a=[],l="",c=0;for(let u=0;u<e.length;u+=o){let f=e.slice(u,u+o),d=await Promise.all(f.map(async p=>{if(s&&p==="-")return{filename:"-",content:t.stdin,error:null};try{let h=t.fs.resolvePath(t.cwd,p),m=await t.fs.readFile(h,"binary");return{filename:p,content:m,error:null}}catch{return{filename:p,content:"",error:`${r}: ${p}: No such file or directory
27
- `}}}));for(let p of d)if(p.error){if(l+=p.error,c=1,i)return{files:a,stderr:l,exitCode:c}}else a.push({filename:p.filename,content:p.content})}return{files:a,stderr:l,exitCode:c}}async function Gt(t,e,n){let r=await kt(t,e,{...n,stopOnError:!0});return r.exitCode!==0?{ok:!1,error:{stdout:"",stderr:r.stderr,exitCode:r.exitCode}}:{ok:!0,content:r.files.map(i=>i.content).join("")}}var Nt=C(()=>{"use strict";Ht()});var co={};L(co,{catCommand:()=>tp});function np(t,e){let n=t.split(`
24
+ `,exitCode:1}}var j=C(()=>{"use strict"});function Q(t,e,n){let r=new Map,s=new Map;for(let[l,c]of Object.entries(n)){let u={name:l,type:c.type};c.short&&r.set(c.short,u),c.long&&s.set(c.long,u)}let i={};for(let[l,c]of Object.entries(n))c.default!==void 0?i[l]=c.default:c.type==="boolean"&&(i[l]=!1);let o=[],a=!1;for(let l=0;l<e.length;l++){let c=e[l];if(a||!c.startsWith("-")||c==="-"){o.push(c);continue}if(c==="--"){a=!0;continue}if(c.startsWith("--")){let u=c.indexOf("="),f,d;u!==-1?(f=c.slice(2,u),d=c.slice(u+1)):f=c.slice(2);let p=s.get(f);if(!p)return{ok:!1,error:L(t,c)};let{name:h,type:m}=p;if(m==="boolean")i[h]=!0;else{if(d===void 0){if(l+1>=e.length)return{ok:!1,error:{stdout:"",stderr:`${t}: option '--${f}' requires an argument
25
+ `,exitCode:1}};d=e[++l]}i[h]=m==="number"?parseInt(d,10):d}}else{let u=c.slice(1);for(let f=0;f<u.length;f++){let d=u[f],p=r.get(d);if(!p)return{ok:!1,error:L(t,`-${d}`)};let{name:h,type:m}=p;if(m==="boolean")i[h]=!0;else{let g;if(f+1<u.length)g=u.slice(f+1);else if(l+1<e.length)g=e[++l];else return{ok:!1,error:{stdout:"",stderr:`${t}: option requires an argument -- '${d}'
26
+ `,exitCode:1}};i[h]=m==="number"?parseInt(g,10):g;break}}}}return{ok:!0,result:{flags:i,positional:o}}}var Ae=C(()=>{"use strict";j()});var Gt=C(()=>{"use strict"});async function Nt(t,e,n){let{cmdName:r,allowStdinMarker:s=!0,stopOnError:i=!1,batchSize:o=100}=n;if(e.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let a=[],l="",c=0;for(let u=0;u<e.length;u+=o){let f=e.slice(u,u+o),d=await Promise.all(f.map(async p=>{if(s&&p==="-")return{filename:"-",content:t.stdin,error:null};try{let h=t.fs.resolvePath(t.cwd,p),m=await t.fs.readFile(h,"binary");return{filename:p,content:m,error:null}}catch{return{filename:p,content:"",error:`${r}: ${p}: No such file or directory
27
+ `}}}));for(let p of d)if(p.error){if(l+=p.error,c=1,i)return{files:a,stderr:l,exitCode:c}}else a.push({filename:p.filename,content:p.content})}return{files:a,stderr:l,exitCode:c}}async function qt(t,e,n){let r=await Nt(t,e,{...n,stopOnError:!0});return r.exitCode!==0?{ok:!1,error:{stdout:"",stderr:r.stderr,exitCode:r.exitCode}}:{ok:!0,content:r.files.map(i=>i.content).join("")}}var It=C(()=>{"use strict";Gt()});var fo={};_(fo,{catCommand:()=>ip});function op(t,e){let n=t.split(`
28
28
  `),r=t.endsWith(`
29
29
  `),s=r?n.slice(0,-1):n;return{content:s.map((o,a)=>`${String(e+a).padStart(6," ")} ${o}`).join(`
30
30
  `)+(r?`
31
- `:""),nextLineNumber:e+s.length}}var Yd,ep,tp,uo=C(()=>{"use strict";Ae();Nt();j();Yd={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},ep={number:{short:"n",long:"number",type:"boolean"}},tp={name:"cat",async execute(t,e){if(I(t))return N(Yd);let n=K("cat",t,ep);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await kt(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files)if(r){let c=np(l,a);o+=c.content,a=c.nextLineNumber}else o+=l;return{stdout:o,stderr:i.stderr,exitCode:i.exitCode}}}});function ye(t){return t instanceof Error?t.message:String(t)}var rt=C(()=>{"use strict"});function Vn(t,e,n){let r=t;n>=0&&r.length>n&&(r=r.slice(0,n));let s=Math.abs(e);return s>r.length&&(e<0?r=r.padEnd(s," "):r=r.padStart(s," ")),r}function fo(t,e){let n=e,r=0,s=-1,i=!1;for(n<t.length&&t[n]==="-"&&(i=!0,n++);n<t.length&&/\d/.test(t[n]);)r=r*10+parseInt(t[n],10),n++;if(n<t.length&&t[n]===".")for(n++,s=0;n<t.length&&/\d/.test(t[n]);)s=s*10+parseInt(t[n],10),n++;return i&&r>0&&(r=-r),[r,s,n-e]}function Zn(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)switch(t[n+1]){case"n":e+=`
32
- `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"\\":e+="\\",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"e":case"E":e+="\x1B",n+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<t.length&&i<n+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),n=i;break}case"x":n+3<t.length&&/[0-9a-fA-F]{2}/.test(t.slice(n+2,n+4))?(e+=String.fromCharCode(parseInt(t.slice(n+2,n+4),16)),n+=4):(e+=t[n],n++);break;case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\u",n+=2);break}case"U":{let s="",i=n+2;for(;i<t.length&&i<n+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\U",n+=2);break}default:e+=t[n],n++}else e+=t[n],n++;return e}var as=C(()=>{"use strict"});var ho={};L(ho,{printfCommand:()=>sp});import{sprintf as qt}from"sprintf-js";function ip(t,e,n){let r="",s=0,i=0,o=!1,a="";for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let l=s;if(s++,t[s]==="%"){r+="%",s++;continue}for(;s<t.length&&"+-0 #'".includes(t[s]);)s++;let c=!1;if(t[s]==="*")c=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;let u=!1;if(t[s]===".")if(s++,t[s]==="*")u=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;s<t.length&&"hlL".includes(t[s])&&s++;let f=t[s]||"";s++;let p=t.slice(l,s);if(c){let E=parseInt(e[n+i]||"0",10);i++,p=p.replace("*",String(E))}if(u){let E=parseInt(e[n+i]||"0",10);i++,p=p.replace(".*",`.${E}`)}let h=e[n+i]||"";i++;let{value:m,parseError:g,parseErrMsg:w,stopped:b}=op(p,f,h);if(r+=m,g&&(o=!0,w&&(a=w)),b)return{result:r,argsConsumed:i,error:o,errMsg:a,stopped:!0}}else r+=t[s],s++;return{result:r,argsConsumed:i,error:o,errMsg:a,stopped:!1}}function op(t,e,n){let r=!1,s="";switch(e){case"d":case"i":{let i=Kn(n);return r=st,r&&(s=`printf: ${n}: invalid number
33
- `),{value:po(t,i),parseError:r,parseErrMsg:s}}case"o":{let i=Kn(n);return r=st,r&&(s=`printf: ${n}: invalid number
34
- `),{value:ap(t,i),parseError:r,parseErrMsg:s}}case"u":{let i=Kn(n);r=st,r&&(s=`printf: ${n}: invalid number
35
- `);let o=i<0?i>>>0:i;return{value:po(t.replace("u","d"),o),parseError:r,parseErrMsg:s}}case"x":case"X":{let i=Kn(n);return r=st,r&&(s=`printf: ${n}: invalid number
36
- `),{value:lp(t,i),parseError:r,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let i=parseFloat(n)||0;return{value:dp(t,e,i),parseError:!1,parseErrMsg:""}}case"c":return{value:n.charAt(0)||"",parseError:!1,parseErrMsg:""};case"s":return{value:up(t,n),parseError:!1,parseErrMsg:""};case"q":return{value:fp(t,n),parseError:!1,parseErrMsg:""};case"b":{let i=pp(n);return{value:i.value,parseError:!1,parseErrMsg:"",stopped:i.stopped}}default:try{return{value:qt(t,n),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
37
- `}}}}function Kn(t){st=!1;let e=t.trimStart(),n=e!==e.trimEnd();if(t=e.trimEnd(),t.startsWith("'")&&t.length>=2||t.startsWith('"')&&t.length>=2)return t.charCodeAt(1);if(t.startsWith("\\'")&&t.length>=3||t.startsWith('\\"')&&t.length>=3)return t.charCodeAt(2);if(t.startsWith("+")&&(t=t.slice(1)),t.startsWith("0x")||t.startsWith("0X")){let r=parseInt(t,16);return Number.isNaN(r)?(st=!0,0):(n&&(st=!0),r)}if(t.startsWith("0")&&t.length>1&&/^-?0[0-7]+$/.test(t))return n&&(st=!0),parseInt(t,8)||0;if(/^\d+#/.test(t)){st=!0;let r=t.match(/^(\d+)#/);return r?parseInt(r[1],10):0}if(t!==""&&!/^-?\d+$/.test(t)){st=!0;let r=parseInt(t,10);return Number.isNaN(r)?0:r}return n&&(st=!0),parseInt(t,10)||0}function po(t,e){let n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return qt(t.replace(/\.\d*/,""),e);let r=n[1]||"",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=e<0,a=Math.abs(e),l=String(a);i>=0&&(l=l.padStart(i,"0"));let c="";o?c="-":r.includes("+")?c="+":r.includes(" ")&&(c=" ");let u=c+l;return s>u.length&&(r.includes("-")?u=u.padEnd(s," "):r.includes("0")&&i<0?u=c+l.padStart(s-c.length,"0"):u=u.padStart(s," ")),u}function ap(t,e){let n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return qt(t,e);let r=n[1]||"",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=Math.abs(e).toString(8);i>=0&&(o=o.padStart(i,"0")),r.includes("#")&&!o.startsWith("0")&&(o=`0${o}`);let a=o;return s>a.length&&(r.includes("-")?a=a.padEnd(s," "):r.includes("0")&&i<0?a=a.padStart(s,"0"):a=a.padStart(s," ")),a}function lp(t,e){let n=t.includes("X"),r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!r)return qt(t,e);let s=r[1]||"",i=r[2]?parseInt(r[2],10):0,o=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,a=Math.abs(e).toString(16);n&&(a=a.toUpperCase()),o>=0&&(a=a.padStart(o,"0"));let l="";s.includes("#")&&e!==0&&(l=n?"0X":"0x");let c=l+a;return i>c.length&&(s.includes("-")?c=c.padEnd(i," "):s.includes("0")&&o<0?c=l+a.padStart(i-l.length,"0"):c=c.padStart(i," ")),c}function cp(t){if(t==="")return"''";if(/^[a-zA-Z0-9_./-]+$/.test(t))return t;if(/[\x00-\x1f\x7f]/.test(t)){let r="$'";for(let s of t){let i=s.charCodeAt(0);s==="'"?r+="\\'":s==="\\"?r+="\\\\":s===`
38
- `?r+="\\n":s===" "?r+="\\t":s==="\r"?r+="\\r":s==="\x07"?r+="\\a":s==="\b"?r+="\\b":s==="\f"?r+="\\f":s==="\v"?r+="\\v":s==="\x1B"?r+="\\E":i<32||i>126?r+=`\\x${i.toString(16).padStart(2,"0")}`:s==='"'?r+='\\"':r+=s}return r+="'",r}let n="";for(let r of t)" |&;<>()$`\\\"'*?[#~=%!{}".includes(r)?n+=`\\${r}`:n+=r;return n}function up(t,e){let n=t.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!n)return qt(t.replace(/0+(?=\d)/,""),e);let r=n[1]==="-",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=r?-s:s;return Vn(e,o,i)}function fp(t,e){let n=cp(e),r=t.match(/^%(-?)(\d*)q$/);if(!r)return n;let s=r[1]==="-",i=r[2]?parseInt(r[2],10):0,o=n;return i>o.length&&(s?o=o.padEnd(i," "):o=o.padStart(i," ")),o}function dp(t,e,n){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!r)return qt(t,n);let s=r[1]||"",i=r[2]?parseInt(r[2],10):0,o=r[3]!==void 0?r[4]?parseInt(r[4],10):0:6,a,l=e.toLowerCase();if(l==="e"?(a=n.toExponential(o),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="E"&&(a=a.toUpperCase())):l==="f"?(a=n.toFixed(o),s.includes("#")&&o===0&&!a.includes(".")&&(a+=".")):l==="g"?(a=n.toPrecision(o||1),s.includes("#")||(a=a.replace(/\.?0+$/,""),a=a.replace(/\.?0+e/,"e")),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="G"&&(a=a.toUpperCase())):a=n.toString(),n>=0&&(s.includes("+")?a=`+${a}`:s.includes(" ")&&(a=` ${a}`)),i>a.length)if(s.includes("-"))a=a.padEnd(i," ");else if(s.includes("0")){let c=a.match(/^[+ -]/)?.[0]||"",u=c?a.slice(1):a;a=c+u.padStart(i-c.length,"0")}else a=a.padStart(i," ");return a}function pp(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)switch(t[n+1]){case"n":e+=`
39
- `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"\\":e+="\\",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"c":return{value:e,stopped:!0};case"x":{let s="",i=n+2;for(;i<t.length&&i<n+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCharCode(parseInt(s,16)),n=i):(e+="\\x",n+=2);break}case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\u",n+=2);break}case"0":{let s="",i=n+2;for(;i<t.length&&i<n+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;s?e+=String.fromCharCode(parseInt(s,8)):e+="\0",n=i;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<t.length&&i<n+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),n=i;break}default:e+=t[n],n++}else e+=t[n],n++;return{value:e,stopped:!1}}var rp,sp,st,mo=C(()=>{"use strict";rt();j();as();rp={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},sp={name:"printf",async execute(t,e){if(I(t))return N(rp);if(t.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
31
+ `:""),nextLineNumber:e+s.length}}var rp,sp,ip,po=C(()=>{"use strict";Ae();It();j();rp={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},sp={number:{short:"n",long:"number",type:"boolean"}},ip={name:"cat",async execute(t,e){if(N(t))return k(rp);let n=Q("cat",t,sp);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await Nt(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files)if(r){let c=op(l,a);o+=c.content,a=c.nextLineNumber}else o+=l;return{stdout:o,stderr:i.stderr,exitCode:i.exitCode}}}});function ye(t){return t instanceof Error?t.message:String(t)}var rt=C(()=>{"use strict"});function Kn(t,e,n){let r=t;n>=0&&r.length>n&&(r=r.slice(0,n));let s=Math.abs(e);return s>r.length&&(e<0?r=r.padEnd(s," "):r=r.padStart(s," ")),r}function ho(t,e){let n=e,r=0,s=-1,i=!1;for(n<t.length&&t[n]==="-"&&(i=!0,n++);n<t.length&&/\d/.test(t[n]);)r=r*10+parseInt(t[n],10),n++;if(n<t.length&&t[n]===".")for(n++,s=0;n<t.length&&/\d/.test(t[n]);)s=s*10+parseInt(t[n],10),n++;return i&&r>0&&(r=-r),[r,s,n-e]}function Qn(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)switch(t[n+1]){case"n":e+=`
32
+ `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"\\":e+="\\",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"e":case"E":e+="\x1B",n+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<t.length&&i<n+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),n=i;break}case"x":n+3<t.length&&/[0-9a-fA-F]{2}/.test(t.slice(n+2,n+4))?(e+=String.fromCharCode(parseInt(t.slice(n+2,n+4),16)),n+=4):(e+=t[n],n++);break;case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\u",n+=2);break}case"U":{let s="",i=n+2;for(;i<t.length&&i<n+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\U",n+=2);break}default:e+=t[n],n++}else e+=t[n],n++;return e}var ls=C(()=>{"use strict"});var go={};_(go,{printfCommand:()=>lp});import{sprintf as Vt}from"sprintf-js";function cp(t,e,n){let r="",s=0,i=0,o=!1,a="";for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let l=s;if(s++,t[s]==="%"){r+="%",s++;continue}for(;s<t.length&&"+-0 #'".includes(t[s]);)s++;let c=!1;if(t[s]==="*")c=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;let u=!1;if(t[s]===".")if(s++,t[s]==="*")u=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;s<t.length&&"hlL".includes(t[s])&&s++;let f=t[s]||"";s++;let p=t.slice(l,s);if(c){let E=parseInt(e[n+i]||"0",10);i++,p=p.replace("*",String(E))}if(u){let E=parseInt(e[n+i]||"0",10);i++,p=p.replace(".*",`.${E}`)}let h=e[n+i]||"";i++;let{value:m,parseError:g,parseErrMsg:b,stopped:w}=up(p,f,h);if(r+=m,g&&(o=!0,b&&(a=b)),w)return{result:r,argsConsumed:i,error:o,errMsg:a,stopped:!0}}else r+=t[s],s++;return{result:r,argsConsumed:i,error:o,errMsg:a,stopped:!1}}function up(t,e,n){let r=!1,s="";switch(e){case"d":case"i":{let i=Xn(n);return r=st,r&&(s=`printf: ${n}: invalid number
33
+ `),{value:mo(t,i),parseError:r,parseErrMsg:s}}case"o":{let i=Xn(n);return r=st,r&&(s=`printf: ${n}: invalid number
34
+ `),{value:fp(t,i),parseError:r,parseErrMsg:s}}case"u":{let i=Xn(n);r=st,r&&(s=`printf: ${n}: invalid number
35
+ `);let o=i<0?i>>>0:i;return{value:mo(t.replace("u","d"),o),parseError:r,parseErrMsg:s}}case"x":case"X":{let i=Xn(n);return r=st,r&&(s=`printf: ${n}: invalid number
36
+ `),{value:dp(t,i),parseError:r,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let i=parseFloat(n)||0;return{value:gp(t,e,i),parseError:!1,parseErrMsg:""}}case"c":return{value:n.charAt(0)||"",parseError:!1,parseErrMsg:""};case"s":return{value:hp(t,n),parseError:!1,parseErrMsg:""};case"q":return{value:mp(t,n),parseError:!1,parseErrMsg:""};case"b":{let i=yp(n);return{value:i.value,parseError:!1,parseErrMsg:"",stopped:i.stopped}}default:try{return{value:Vt(t,n),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
37
+ `}}}}function Xn(t){st=!1;let e=t.trimStart(),n=e!==e.trimEnd();if(t=e.trimEnd(),t.startsWith("'")&&t.length>=2||t.startsWith('"')&&t.length>=2)return t.charCodeAt(1);if(t.startsWith("\\'")&&t.length>=3||t.startsWith('\\"')&&t.length>=3)return t.charCodeAt(2);if(t.startsWith("+")&&(t=t.slice(1)),t.startsWith("0x")||t.startsWith("0X")){let r=parseInt(t,16);return Number.isNaN(r)?(st=!0,0):(n&&(st=!0),r)}if(t.startsWith("0")&&t.length>1&&/^-?0[0-7]+$/.test(t))return n&&(st=!0),parseInt(t,8)||0;if(/^\d+#/.test(t)){st=!0;let r=t.match(/^(\d+)#/);return r?parseInt(r[1],10):0}if(t!==""&&!/^-?\d+$/.test(t)){st=!0;let r=parseInt(t,10);return Number.isNaN(r)?0:r}return n&&(st=!0),parseInt(t,10)||0}function mo(t,e){let n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return Vt(t.replace(/\.\d*/,""),e);let r=n[1]||"",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=e<0,a=Math.abs(e),l=String(a);i>=0&&(l=l.padStart(i,"0"));let c="";o?c="-":r.includes("+")?c="+":r.includes(" ")&&(c=" ");let u=c+l;return s>u.length&&(r.includes("-")?u=u.padEnd(s," "):r.includes("0")&&i<0?u=c+l.padStart(s-c.length,"0"):u=u.padStart(s," ")),u}function fp(t,e){let n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return Vt(t,e);let r=n[1]||"",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=Math.abs(e).toString(8);i>=0&&(o=o.padStart(i,"0")),r.includes("#")&&!o.startsWith("0")&&(o=`0${o}`);let a=o;return s>a.length&&(r.includes("-")?a=a.padEnd(s," "):r.includes("0")&&i<0?a=a.padStart(s,"0"):a=a.padStart(s," ")),a}function dp(t,e){let n=t.includes("X"),r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!r)return Vt(t,e);let s=r[1]||"",i=r[2]?parseInt(r[2],10):0,o=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,a=Math.abs(e).toString(16);n&&(a=a.toUpperCase()),o>=0&&(a=a.padStart(o,"0"));let l="";s.includes("#")&&e!==0&&(l=n?"0X":"0x");let c=l+a;return i>c.length&&(s.includes("-")?c=c.padEnd(i," "):s.includes("0")&&o<0?c=l+a.padStart(i-l.length,"0"):c=c.padStart(i," ")),c}function pp(t){if(t==="")return"''";if(/^[a-zA-Z0-9_./-]+$/.test(t))return t;if(/[\x00-\x1f\x7f]/.test(t)){let r="$'";for(let s of t){let i=s.charCodeAt(0);s==="'"?r+="\\'":s==="\\"?r+="\\\\":s===`
38
+ `?r+="\\n":s===" "?r+="\\t":s==="\r"?r+="\\r":s==="\x07"?r+="\\a":s==="\b"?r+="\\b":s==="\f"?r+="\\f":s==="\v"?r+="\\v":s==="\x1B"?r+="\\E":i<32||i>126?r+=`\\x${i.toString(16).padStart(2,"0")}`:s==='"'?r+='\\"':r+=s}return r+="'",r}let n="";for(let r of t)" |&;<>()$`\\\"'*?[#~=%!{}".includes(r)?n+=`\\${r}`:n+=r;return n}function hp(t,e){let n=t.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!n)return Vt(t.replace(/0+(?=\d)/,""),e);let r=n[1]==="-",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=r?-s:s;return Kn(e,o,i)}function mp(t,e){let n=pp(e),r=t.match(/^%(-?)(\d*)q$/);if(!r)return n;let s=r[1]==="-",i=r[2]?parseInt(r[2],10):0,o=n;return i>o.length&&(s?o=o.padEnd(i," "):o=o.padStart(i," ")),o}function gp(t,e,n){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!r)return Vt(t,n);let s=r[1]||"",i=r[2]?parseInt(r[2],10):0,o=r[3]!==void 0?r[4]?parseInt(r[4],10):0:6,a,l=e.toLowerCase();if(l==="e"?(a=n.toExponential(o),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="E"&&(a=a.toUpperCase())):l==="f"?(a=n.toFixed(o),s.includes("#")&&o===0&&!a.includes(".")&&(a+=".")):l==="g"?(a=n.toPrecision(o||1),s.includes("#")||(a=a.replace(/\.?0+$/,""),a=a.replace(/\.?0+e/,"e")),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="G"&&(a=a.toUpperCase())):a=n.toString(),n>=0&&(s.includes("+")?a=`+${a}`:s.includes(" ")&&(a=` ${a}`)),i>a.length)if(s.includes("-"))a=a.padEnd(i," ");else if(s.includes("0")){let c=a.match(/^[+ -]/)?.[0]||"",u=c?a.slice(1):a;a=c+u.padStart(i-c.length,"0")}else a=a.padStart(i," ");return a}function yp(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)switch(t[n+1]){case"n":e+=`
39
+ `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"\\":e+="\\",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"c":return{value:e,stopped:!0};case"x":{let s="",i=n+2;for(;i<t.length&&i<n+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCharCode(parseInt(s,16)),n=i):(e+="\\x",n+=2);break}case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\u",n+=2);break}case"0":{let s="",i=n+2;for(;i<t.length&&i<n+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;s?e+=String.fromCharCode(parseInt(s,8)):e+="\0",n=i;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<t.length&&i<n+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),n=i;break}default:e+=t[n],n++}else e+=t[n],n++;return{value:e,stopped:!1}}var ap,lp,st,yo=C(()=>{"use strict";rt();j();ls();ap={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},lp={name:"printf",async execute(t,e){if(N(t))return k(ap);if(t.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
40
40
  `,exitCode:2};let n=null,r=0;for(;r<t.length;){let o=t[r];if(o==="--"){r++;break}if(o==="-v"){if(r+1>=t.length)return{stdout:"",stderr:`printf: -v: option requires an argument
41
41
  `,exitCode:1};if(n=t[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(\[[^\]]+\])?$/.test(n))return{stdout:"",stderr:`printf: \`${n}': not a valid identifier
42
42
  `,exitCode:2};r+=2}else{if(o.startsWith("-")&&o!=="-")break;break}}if(r>=t.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
43
- `,exitCode:1};let s=t[r],i=t.slice(r+1);try{let o=Zn(s),a="",l=0,c=!1,u="";do{let{result:f,argsConsumed:d,error:p,errMsg:h,stopped:m}=ip(o,i,l);if(a+=f,l+=d,p&&(c=!0,h&&(u=h)),m)break}while(l<i.length&&l>0);return l===0&&i.length>0,n?(e.env[n]=a,{stdout:"",stderr:u,exitCode:c?1:0}):{stdout:a,stderr:u,exitCode:c?1:0}}catch(o){return{stdout:"",stderr:`printf: ${ye(o)}
44
- `,exitCode:1}}}};st=!1});var xo={};L(xo,{lsCommand:()=>gp});import{minimatch as go}from"minimatch";function Qn(t){if(t<1024)return String(t);if(t<1024*1024){let n=t/1024;return n<10?`${n.toFixed(1)}K`:`${Math.round(n)}K`}if(t<1024*1024*1024){let n=t/1048576;return n<10?`${n.toFixed(1)}M`:`${Math.round(n)}M`}let e=t/(1024*1024*1024);return e<10?`${e.toFixed(1)}G`:`${Math.round(e)}G`}function Xn(t){let n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],r=String(t.getDate()).padStart(2," "),s=new Date,i=new Date(s.getTime()-4320*60*60*1e3);if(t>i){let a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${n} ${r} ${a}:${l}`}let o=t.getFullYear();return`${n} ${r} ${o}`}async function yp(t,e,n,r,s,i=!1,o=!1,a=!1){let l=n||r,c=e.fs.getAllPaths(),u=e.fs.resolvePath(e.cwd,"."),f=[];for(let d of c){let p=d.startsWith(u)&&d.slice(u.length+1)||d;if(go(p,t)||go(d,t)){let h=p.split("/").pop()||p;if(!l&&h.startsWith("."))continue;f.push(p||d)}}if(f.length===0)return{stdout:"",stderr:`ls: ${t}: No such file or directory
45
- `,exitCode:2};if(a){let d=[];for(let p of f){let h=e.fs.resolvePath(e.cwd,p);try{let m=await e.fs.stat(h);d.push({path:p,size:m.size??0})}catch{d.push({path:p,size:0})}}d.sort((p,h)=>h.size-p.size),f.length=0,f.push(...d.map(p=>p.path))}else f.sort();if(i&&f.reverse(),s){let d=[];for(let p of f){let h=e.fs.resolvePath(e.cwd,p);try{let m=await e.fs.stat(h),g=m.isDirectory?"drwxr-xr-x":"-rw-r--r--",w=m.isDirectory?"/":"",b=m.size??0,E=o?Qn(b).padStart(5):String(b).padStart(5),S=m.mtime??new Date(0),R=Xn(S);d.push(`${g} 1 user user ${E} ${R} ${p}${w}`)}catch{d.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${p}`)}}return{stdout:`${d.join(`
43
+ `,exitCode:1};let s=t[r],i=t.slice(r+1);try{let o=Qn(s),a="",l=0,c=!1,u="";do{let{result:f,argsConsumed:d,error:p,errMsg:h,stopped:m}=cp(o,i,l);if(a+=f,l+=d,p&&(c=!0,h&&(u=h)),m)break}while(l<i.length&&l>0);return l===0&&i.length>0,n?(e.env[n]=a,{stdout:"",stderr:u,exitCode:c?1:0}):{stdout:a,stderr:u,exitCode:c?1:0}}catch(o){return{stdout:"",stderr:`printf: ${ye(o)}
44
+ `,exitCode:1}}}};st=!1});var bo={};_(bo,{lsCommand:()=>bp});import{minimatch as xo}from"minimatch";function Jn(t){if(t<1024)return String(t);if(t<1024*1024){let n=t/1024;return n<10?`${n.toFixed(1)}K`:`${Math.round(n)}K`}if(t<1024*1024*1024){let n=t/1048576;return n<10?`${n.toFixed(1)}M`:`${Math.round(n)}M`}let e=t/(1024*1024*1024);return e<10?`${e.toFixed(1)}G`:`${Math.round(e)}G`}function Yn(t){let n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],r=String(t.getDate()).padStart(2," "),s=new Date,i=new Date(s.getTime()-4320*60*60*1e3);if(t>i){let a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${n} ${r} ${a}:${l}`}let o=t.getFullYear();return`${n} ${r} ${o}`}async function Ep(t,e,n,r,s,i=!1,o=!1,a=!1){let l=n||r,c=e.fs.getAllPaths(),u=e.fs.resolvePath(e.cwd,"."),f=[];for(let d of c){let p=d.startsWith(u)&&d.slice(u.length+1)||d;if(xo(p,t)||xo(d,t)){let h=p.split("/").pop()||p;if(!l&&h.startsWith("."))continue;f.push(p||d)}}if(f.length===0)return{stdout:"",stderr:`ls: ${t}: No such file or directory
45
+ `,exitCode:2};if(a){let d=[];for(let p of f){let h=e.fs.resolvePath(e.cwd,p);try{let m=await e.fs.stat(h);d.push({path:p,size:m.size??0})}catch{d.push({path:p,size:0})}}d.sort((p,h)=>h.size-p.size),f.length=0,f.push(...d.map(p=>p.path))}else f.sort();if(i&&f.reverse(),s){let d=[];for(let p of f){let h=e.fs.resolvePath(e.cwd,p);try{let m=await e.fs.stat(h),g=m.isDirectory?"drwxr-xr-x":"-rw-r--r--",b=m.isDirectory?"/":"",w=m.size??0,E=o?Jn(w).padStart(5):String(w).padStart(5),S=m.mtime??new Date(0),R=Yn(S);d.push(`${g} 1 user user ${E} ${R} ${p}${b}`)}catch{d.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${p}`)}}return{stdout:`${d.join(`
46
46
  `)}
47
47
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
48
48
  `)}
49
- `,stderr:"",exitCode:0}}async function yo(t,e,n,r,s,i,o,a=!1,l=!1,c=!1,u=!1){let f=n||r,d=e.fs.resolvePath(e.cwd,t);try{let p=await e.fs.stat(d);if(!p.isDirectory){if(s){let g=p.size??0,w=l?Qn(g).padStart(5):String(g).padStart(5),b=p.mtime??new Date(0),E=Xn(b);return{stdout:`-rw-r--r-- 1 user user ${w} ${E} ${t}
49
+ `,stderr:"",exitCode:0}}async function wo(t,e,n,r,s,i,o,a=!1,l=!1,c=!1,u=!1){let f=n||r,d=e.fs.resolvePath(e.cwd,t);try{let p=await e.fs.stat(d);if(!p.isDirectory){if(s){let g=p.size??0,b=l?Jn(g).padStart(5):String(g).padStart(5),w=p.mtime??new Date(0),E=Yn(w);return{stdout:`-rw-r--r-- 1 user user ${b} ${E} ${t}
50
50
  `,stderr:"",exitCode:0}}return{stdout:`${t}
51
- `,stderr:"",exitCode:0}}let h=await e.fs.readdir(d);if(f||(h=h.filter(g=>!g.startsWith("."))),c){let g=[];for(let w of h){let b=d==="/"?`/${w}`:`${d}/${w}`;try{let E=await e.fs.stat(b);g.push({name:w,size:E.size??0})}catch{g.push({name:w,size:0})}}g.sort((w,b)=>b.size-w.size),h=g.map(w=>w.name)}else h.sort();n&&(h=[".","..",...h]),a&&h.reverse();let m="";if((i||o)&&(m+=`${t}:
51
+ `,stderr:"",exitCode:0}}let h=await e.fs.readdir(d);if(f||(h=h.filter(g=>!g.startsWith("."))),c){let g=[];for(let b of h){let w=d==="/"?`/${b}`:`${d}/${b}`;try{let E=await e.fs.stat(w);g.push({name:b,size:E.size??0})}catch{g.push({name:b,size:0})}}g.sort((b,w)=>w.size-b.size),h=g.map(b=>b.name)}else h.sort();n&&(h=[".","..",...h]),a&&h.reverse();let m="";if((i||o)&&(m+=`${t}:
52
52
  `),s){m+=`total ${h.length}
53
- `;let g=h.filter(S=>S==="."||S===".."),w=h.filter(S=>S!=="."&&S!=="..");for(let S of g)m+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${S}
54
- `;let b=[];for(let S=0;S<w.length;S+=100){let R=w.slice(S,S+100),P=await Promise.all(R.map(async z=>{let W=d==="/"?`/${z}`:`${d}/${z}`;try{let X=await e.fs.stat(W),F=X.isDirectory?"drwxr-xr-x":"-rw-r--r--",T=X.isDirectory?"/":"",v=X.size??0,k=l?Qn(v).padStart(5):String(v).padStart(5),$=X.mtime??new Date(0),M=Xn($);return{name:z,line:`${F} 1 user user ${k} ${M} ${z}${T}
53
+ `;let g=h.filter(S=>S==="."||S===".."),b=h.filter(S=>S!=="."&&S!=="..");for(let S of g)m+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${S}
54
+ `;let w=[];for(let S=0;S<b.length;S+=100){let R=b.slice(S,S+100),F=await Promise.all(R.map(async z=>{let W=d==="/"?`/${z}`:`${d}/${z}`;try{let J=await e.fs.stat(W),P=J.isDirectory?"drwxr-xr-x":"-rw-r--r--",T=J.isDirectory?"/":"",$=J.size??0,I=l?Jn($).padStart(5):String($).padStart(5),v=J.mtime??new Date(0),D=Yn(v);return{name:z,line:`${P} 1 user user ${I} ${D} ${z}${T}
55
55
  `}}catch{return{name:z,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${z}
56
- `}}}));b.push(...P)}let E=new Map(w.map((S,R)=>[S,R]));b.sort((S,R)=>(E.get(S.name)??0)-(E.get(R.name)??0));for(let{line:S}of b)m+=S}else m+=h.join(`
56
+ `}}}));w.push(...F)}let E=new Map(b.map((S,R)=>[S,R]));w.sort((S,R)=>(E.get(S.name)??0)-(E.get(R.name)??0));for(let{line:S}of w)m+=S}else m+=h.join(`
57
57
  `)+(h.length?`
58
- `:"");if(i){let g=h.filter(E=>E!=="."&&E!==".."),w=[];if(e.fs.readdirWithFileTypes)w=(await e.fs.readdirWithFileTypes(d)).filter(S=>S.isDirectory&&g.includes(S.name)).map(S=>({name:S.name,isDirectory:!0}));else for(let E=0;E<g.length;E+=100){let S=g.slice(E,E+100),R=await Promise.all(S.map(async P=>{let z=d==="/"?`/${P}`:`${d}/${P}`;try{let W=await e.fs.stat(z);return{name:P,isDirectory:W.isDirectory}}catch{return{name:P,isDirectory:!1}}}));w.push(...R.filter(P=>P.isDirectory))}w.sort((E,S)=>E.name.localeCompare(S.name)),a&&w.reverse();let b=[];for(let E=0;E<w.length;E+=100){let S=w.slice(E,E+100),R=await Promise.all(S.map(async P=>{let z=t==="."?`./${P.name}`:`${t}/${P.name}`,W=await yo(z,e,n,r,s,i,!1,a,l,c,!0);return{name:P.name,result:W}}));b.push(...R)}b.sort((E,S)=>E.name.localeCompare(S.name)),a&&b.reverse();for(let{result:E}of b)m+=`
58
+ `:"");if(i){let g=h.filter(E=>E!=="."&&E!==".."),b=[];if(e.fs.readdirWithFileTypes)b=(await e.fs.readdirWithFileTypes(d)).filter(S=>S.isDirectory&&g.includes(S.name)).map(S=>({name:S.name,isDirectory:!0}));else for(let E=0;E<g.length;E+=100){let S=g.slice(E,E+100),R=await Promise.all(S.map(async F=>{let z=d==="/"?`/${F}`:`${d}/${F}`;try{let W=await e.fs.stat(z);return{name:F,isDirectory:W.isDirectory}}catch{return{name:F,isDirectory:!1}}}));b.push(...R.filter(F=>F.isDirectory))}b.sort((E,S)=>E.name.localeCompare(S.name)),a&&b.reverse();let w=[];for(let E=0;E<b.length;E+=100){let S=b.slice(E,E+100),R=await Promise.all(S.map(async F=>{let z=t==="."?`./${F.name}`:`${t}/${F.name}`,W=await wo(z,e,n,r,s,i,!1,a,l,c,!0);return{name:F.name,result:W}}));w.push(...R)}w.sort((E,S)=>E.name.localeCompare(S.name)),a&&w.reverse();for(let{result:E}of w)m+=`
59
59
  `,m+=E.stdout}return{stdout:m,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`ls: ${t}: No such file or directory
60
- `,exitCode:2}}}var hp,mp,gp,wo=C(()=>{"use strict";Ae();Ht();j();hp={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},mp={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},gp={name:"ls",async execute(t,e){if(I(t))return N(hp);let n=K("ls",t,mp);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.showAlmostAll,i=n.result.flags.longFormat,o=n.result.flags.humanReadable,a=n.result.flags.recursive,l=n.result.flags.reverse,c=n.result.flags.sortBySize,u=n.result.flags.directoryOnly,f=n.result.flags.sortByTime;n.result.flags.onePerLine;let d=n.result.positional;d.length===0&&d.push(".");let p="",h="",m=0;for(let g=0;g<d.length;g++){let w=d[g];if(g>0&&p&&!p.endsWith(`
60
+ `,exitCode:2}}}var xp,wp,bp,Eo=C(()=>{"use strict";Ae();Gt();j();xp={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},wp={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},bp={name:"ls",async execute(t,e){if(N(t))return k(xp);let n=Q("ls",t,wp);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.showAlmostAll,i=n.result.flags.longFormat,o=n.result.flags.humanReadable,a=n.result.flags.recursive,l=n.result.flags.reverse,c=n.result.flags.sortBySize,u=n.result.flags.directoryOnly,f=n.result.flags.sortByTime;n.result.flags.onePerLine;let d=n.result.positional;d.length===0&&d.push(".");let p="",h="",m=0;for(let g=0;g<d.length;g++){let b=d[g];if(g>0&&p&&!p.endsWith(`
61
61
 
62
62
  `)&&(p+=`
63
- `),u){let b=e.fs.resolvePath(e.cwd,w);try{let E=await e.fs.stat(b);if(i){let S=E.isDirectory?"drwxr-xr-x":"-rw-r--r--",R=E.isDirectory?"/":"",P=E.size??0,z=o?Qn(P).padStart(5):String(P).padStart(5),W=E.mtime??new Date(0),X=Xn(W);p+=`${S} 1 user user ${z} ${X} ${w}${R}
64
- `}else p+=`${w}
65
- `}catch{h+=`ls: cannot access '${w}': No such file or directory
66
- `,m=2}continue}if(w.includes("*")||w.includes("?")||w.includes("[")){let b=await yp(w,e,r,s,i,l,o,c);p+=b.stdout,h+=b.stderr,b.exitCode!==0&&(m=b.exitCode)}else{let b=await yo(w,e,r,s,i,a,d.length>1,l,o,c);p+=b.stdout,h+=b.stderr,b.exitCode!==0&&(m=b.exitCode)}}return{stdout:p,stderr:h,exitCode:m}}}});var bo={};L(bo,{mkdirCommand:()=>wp});var xp,wp,Eo=C(()=>{"use strict";rt();Ae();xp={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},wp={name:"mkdir",async execute(t,e){let n=K("mkdir",t,xp);if(!n.ok)return n.error;let r=n.result.flags.recursive,s=n.result.flags.verbose,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`mkdir: missing operand
63
+ `),u){let w=e.fs.resolvePath(e.cwd,b);try{let E=await e.fs.stat(w);if(i){let S=E.isDirectory?"drwxr-xr-x":"-rw-r--r--",R=E.isDirectory?"/":"",F=E.size??0,z=o?Jn(F).padStart(5):String(F).padStart(5),W=E.mtime??new Date(0),J=Yn(W);p+=`${S} 1 user user ${z} ${J} ${b}${R}
64
+ `}else p+=`${b}
65
+ `}catch{h+=`ls: cannot access '${b}': No such file or directory
66
+ `,m=2}continue}if(b.includes("*")||b.includes("?")||b.includes("[")){let w=await Ep(b,e,r,s,i,l,o,c);p+=w.stdout,h+=w.stderr,w.exitCode!==0&&(m=w.exitCode)}else{let w=await wo(b,e,r,s,i,a,d.length>1,l,o,c);p+=w.stdout,h+=w.stderr,w.exitCode!==0&&(m=w.exitCode)}}return{stdout:p,stderr:h,exitCode:m}}}});var So={};_(So,{mkdirCommand:()=>Cp});var Sp,Cp,Co=C(()=>{"use strict";rt();Ae();Sp={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Cp={name:"mkdir",async execute(t,e){let n=Q("mkdir",t,Sp);if(!n.ok)return n.error;let r=n.result.flags.recursive,s=n.result.flags.verbose,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`mkdir: missing operand
67
67
  `,exitCode:1};let o="",a="",l=0;for(let c of i)try{let u=e.fs.resolvePath(e.cwd,c);await e.fs.mkdir(u,{recursive:r}),s&&(o+=`mkdir: created directory '${c}'
68
68
  `)}catch(u){let f=ye(u);f.includes("ENOENT")||f.includes("no such file")?a+=`mkdir: cannot create directory '${c}': No such file or directory
69
69
  `:f.includes("EEXIST")||f.includes("already exists")?a+=`mkdir: cannot create directory '${c}': File exists
70
70
  `:a+=`mkdir: cannot create directory '${c}': ${f}
71
- `,l=1}return{stdout:o,stderr:a,exitCode:l}}}});var So={};L(So,{touchCommand:()=>bp});var bp,Co=C(()=>{"use strict";rt();j();bp={name:"touch",async execute(t,e){let n=[];for(let i of t){if(i.startsWith("--"))return D("touch",i);if(i.startsWith("-")&&i.length>1)return D("touch",i);n.push(i)}if(n.length===0)return{stdout:"",stderr:`touch: missing file operand
71
+ `,l=1}return{stdout:o,stderr:a,exitCode:l}}}});var Ao={};_(Ao,{touchCommand:()=>Ap});var Ap,ko=C(()=>{"use strict";rt();j();Ap={name:"touch",async execute(t,e){let n=[];for(let i of t){if(i.startsWith("--"))return L("touch",i);if(i.startsWith("-")&&i.length>1)return L("touch",i);n.push(i)}if(n.length===0)return{stdout:"",stderr:`touch: missing file operand
72
72
  `,exitCode:1};let r="",s=0;for(let i of n)try{let o=e.fs.resolvePath(e.cwd,i);await e.fs.exists(o)||await e.fs.writeFile(o,"")}catch(o){r+=`touch: cannot touch '${i}': ${ye(o)}
73
- `,s=1}return{stdout:"",stderr:r,exitCode:s}}}});var Ao={};L(Ao,{rmCommand:()=>Sp});var Ep,Sp,ko=C(()=>{"use strict";rt();Ae();Ep={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Sp={name:"rm",async execute(t,e){let n=K("rm",t,Ep);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,s=n.result.flags.force,i=n.result.flags.verbose,o=n.result.positional;if(o.length===0)return s?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand
73
+ `,s=1}return{stdout:"",stderr:r,exitCode:s}}}});var No={};_(No,{rmCommand:()=>Np});var kp,Np,Io=C(()=>{"use strict";rt();Ae();kp={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Np={name:"rm",async execute(t,e){let n=Q("rm",t,kp);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,s=n.result.flags.force,i=n.result.flags.verbose,o=n.result.positional;if(o.length===0)return s?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand
74
74
  `,exitCode:1};let a="",l="",c=0;for(let u of o)try{let f=e.fs.resolvePath(e.cwd,u);if((await e.fs.stat(f)).isDirectory&&!r){l+=`rm: cannot remove '${u}': Is a directory
75
75
  `,c=1;continue}await e.fs.rm(f,{recursive:r,force:s}),i&&(a+=`removed '${u}'
76
76
  `)}catch(f){if(!s){let d=ye(f);d.includes("ENOENT")||d.includes("no such file")?l+=`rm: cannot remove '${u}': No such file or directory
77
77
  `:d.includes("ENOTEMPTY")||d.includes("not empty")?l+=`rm: cannot remove '${u}': Directory not empty
78
78
  `:l+=`rm: cannot remove '${u}': ${d}
79
- `,c=1}}return{stdout:a,stderr:l,exitCode:c}}}});var No={};L(No,{cpCommand:()=>kp});var Cp,Ap,kp,Io=C(()=>{"use strict";rt();Ae();j();Cp={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},Ap={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},kp={name:"cp",async execute(t,e){if(I(t))return N(Cp);let n=K("cp",t,Ap);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,s=n.result.flags.noClobber,i=n.result.flags.preserve,o=n.result.flags.verbose,a=n.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
79
+ `,c=1}}return{stdout:a,stderr:l,exitCode:c}}}});var vo={};_(vo,{cpCommand:()=>$p});var Ip,vp,$p,$o=C(()=>{"use strict";rt();Ae();j();Ip={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},vp={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},$p={name:"cp",async execute(t,e){if(N(t))return k(Ip);let n=Q("cp",t,vp);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,s=n.result.flags.noClobber,i=n.result.flags.preserve,o=n.result.flags.verbose,a=n.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
80
80
  `,exitCode:1};let l=a.pop()??"",c=a,u=e.fs.resolvePath(e.cwd,l),f="",d="",p=0,h=!1;try{h=(await e.fs.stat(u)).isDirectory}catch{}if(c.length>1&&!h)return{stdout:"",stderr:`cp: target '${l}' is not a directory
81
- `,exitCode:1};for(let m of c)try{let g=e.fs.resolvePath(e.cwd,m),w=await e.fs.stat(g),b=u;if(h){let E=m.split("/").pop()||m;b=u==="/"?`/${E}`:`${u}/${E}`}if(w.isDirectory&&!r){d+=`cp: -r not specified; omitting directory '${m}'
82
- `,p=1;continue}if(s)try{await e.fs.stat(b);continue}catch{}await e.fs.cp(g,b,{recursive:r}),o&&(f+=`'${m}' -> '${b}'
83
- `)}catch(g){let w=ye(g);w.includes("ENOENT")||w.includes("no such file")?d+=`cp: cannot stat '${m}': No such file or directory
84
- `:d+=`cp: cannot copy '${m}': ${w}
85
- `,p=1}return{stdout:f,stderr:d,exitCode:p}}}});var vo={};L(vo,{mvCommand:()=>vp});var Np,Ip,vp,$o=C(()=>{"use strict";rt();Ae();j();Np={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},Ip={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},vp={name:"mv",async execute(t,e){if(I(t))return N(Np);let n=K("mv",t,Ip);if(!n.ok)return n.error;let r=n.result.flags.force,s=n.result.flags.noClobber,i=n.result.flags.verbose,o=n.result.positional;if(s&&(r=!1),o.length<2)return{stdout:"",stderr:`mv: missing destination file operand
81
+ `,exitCode:1};for(let m of c)try{let g=e.fs.resolvePath(e.cwd,m),b=await e.fs.stat(g),w=u;if(h){let E=m.split("/").pop()||m;w=u==="/"?`/${E}`:`${u}/${E}`}if(b.isDirectory&&!r){d+=`cp: -r not specified; omitting directory '${m}'
82
+ `,p=1;continue}if(s)try{await e.fs.stat(w);continue}catch{}await e.fs.cp(g,w,{recursive:r}),o&&(f+=`'${m}' -> '${w}'
83
+ `)}catch(g){let b=ye(g);b.includes("ENOENT")||b.includes("no such file")?d+=`cp: cannot stat '${m}': No such file or directory
84
+ `:d+=`cp: cannot copy '${m}': ${b}
85
+ `,p=1}return{stdout:f,stderr:d,exitCode:p}}}});var Ro={};_(Ro,{mvCommand:()=>Pp});var Rp,Fp,Pp,Fo=C(()=>{"use strict";rt();Ae();j();Rp={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},Fp={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Pp={name:"mv",async execute(t,e){if(N(t))return k(Rp);let n=Q("mv",t,Fp);if(!n.ok)return n.error;let r=n.result.flags.force,s=n.result.flags.noClobber,i=n.result.flags.verbose,o=n.result.positional;if(s&&(r=!1),o.length<2)return{stdout:"",stderr:`mv: missing destination file operand
86
86
  `,exitCode:1};let a=o.pop()??"",l=o,c=e.fs.resolvePath(e.cwd,a),u="",f="",d=0,p=!1;try{p=(await e.fs.stat(c)).isDirectory}catch{}if(l.length>1&&!p)return{stdout:"",stderr:`mv: target '${a}' is not a directory
87
- `,exitCode:1};for(let h of l)try{let m=e.fs.resolvePath(e.cwd,h),g=c;if(p){let w=h.split("/").pop()||h;g=c==="/"?`/${w}`:`${c}/${w}`}if(s)try{await e.fs.stat(g);continue}catch{}if(await e.fs.mv(m,g),i){let w=p?`${a}/${h.split("/").pop()||h}`:a;u+=`renamed '${h}' -> '${w}'
87
+ `,exitCode:1};for(let h of l)try{let m=e.fs.resolvePath(e.cwd,h),g=c;if(p){let b=h.split("/").pop()||h;g=c==="/"?`/${b}`:`${c}/${b}`}if(s)try{await e.fs.stat(g);continue}catch{}if(await e.fs.mv(m,g),i){let b=p?`${a}/${h.split("/").pop()||h}`:a;u+=`renamed '${h}' -> '${b}'
88
88
  `}}catch(m){let g=ye(m);g.includes("ENOENT")||g.includes("no such file")?f+=`mv: cannot stat '${h}': No such file or directory
89
89
  `:f+=`mv: cannot move '${h}': ${g}
90
- `,d=1}return{stdout:u,stderr:f,exitCode:d}}}});var Ro={};L(Ro,{lnCommand:()=>Rp});var $p,Rp,Po=C(()=>{"use strict";j();$p={name:"ln",summary:"make links between files",usage:"ln [OPTIONS] TARGET LINK_NAME",options:["-s create a symbolic link instead of a hard link","-f remove existing destination files","-n treat LINK_NAME as a normal file if it is a symbolic link to a directory","-v print name of each linked file"," --help display this help and exit"]},Rp={name:"ln",async execute(t,e){if(I(t))return N($p);let n=!1,r=!1,s=!1,i=0;for(;i<t.length&&t[i].startsWith("-");){let f=t[i];if(f==="-s"||f==="--symbolic")n=!0,i++;else if(f==="-f"||f==="--force")r=!0,i++;else if(f==="-v"||f==="--verbose")s=!0,i++;else if(f==="-n"||f==="--no-dereference")i++;else if(/^-[sfvn]+$/.test(f))f.includes("s")&&(n=!0),f.includes("f")&&(r=!0),f.includes("v")&&(s=!0),i++;else if(f==="--"){i++;break}else return{stdout:"",stderr:`ln: invalid option -- '${f.slice(1)}'
90
+ `,d=1}return{stdout:u,stderr:f,exitCode:d}}}});var Po={};_(Po,{lnCommand:()=>Op});var Tp,Op,To=C(()=>{"use strict";j();Tp={name:"ln",summary:"make links between files",usage:"ln [OPTIONS] TARGET LINK_NAME",options:["-s create a symbolic link instead of a hard link","-f remove existing destination files","-n treat LINK_NAME as a normal file if it is a symbolic link to a directory","-v print name of each linked file"," --help display this help and exit"]},Op={name:"ln",async execute(t,e){if(N(t))return k(Tp);let n=!1,r=!1,s=!1,i=0;for(;i<t.length&&t[i].startsWith("-");){let f=t[i];if(f==="-s"||f==="--symbolic")n=!0,i++;else if(f==="-f"||f==="--force")r=!0,i++;else if(f==="-v"||f==="--verbose")s=!0,i++;else if(f==="-n"||f==="--no-dereference")i++;else if(/^-[sfvn]+$/.test(f))f.includes("s")&&(n=!0),f.includes("f")&&(r=!0),f.includes("v")&&(s=!0),i++;else if(f==="--"){i++;break}else return{stdout:"",stderr:`ln: invalid option -- '${f.slice(1)}'
91
91
  `,exitCode:1}}let o=t.slice(i);if(o.length<2)return{stdout:"",stderr:`ln: missing file operand
92
92
  `,exitCode:1};let a=o[0],l=o[1],c=e.fs.resolvePath(e.cwd,l);if(await e.fs.exists(c))if(r)try{await e.fs.rm(c,{force:!0})}catch{return{stdout:"",stderr:`ln: cannot remove '${l}': Permission denied
93
93
  `,exitCode:1}}else return{stdout:"",stderr:`ln: failed to create ${n?"symbolic ":""}link '${l}': File exists
@@ -95,83 +95,87 @@ Notes:
95
95
  `,exitCode:1};await e.fs.link(f,c)}}catch(f){let d=f;return d.message.includes("EPERM")?{stdout:"",stderr:`ln: '${a}': hard link not allowed for directory
96
96
  `,exitCode:1}:{stdout:"",stderr:`ln: ${d.message}
97
97
  `,exitCode:1}}let u="";return s&&(u=`'${l}' -> '${a}'
98
- `),{stdout:u,stderr:"",exitCode:0}}}});var To={};L(To,{chmodCommand:()=>Fp});async function Fo(t,e,n,r){let s="",i=await t.fs.readdir(e);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;await t.fs.chmod(a,n),r&&(s+=`mode of '${a}' changed to ${n.toString(8).padStart(4,"0")}
99
- `),(await t.fs.stat(a)).isDirectory&&(s+=await Fo(t,a,n,r))}return s}function Tp(t){if(/^[0-7]+$/.test(t))return parseInt(t,8);let e=420,n=t.split(",");for(let r of n){let s=r.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!s)throw new Error(`Invalid mode: ${t}`);let i=s[1]||"a",o=s[2],a=s[3];(i==="a"||i==="")&&(i="ugo");let l=0;a.includes("r")&&(l|=4),a.includes("w")&&(l|=2),(a.includes("x")||a.includes("X"))&&(l|=1);for(let c of i){let u=0;c==="u"?u=6:c==="g"?u=3:c==="o"&&(u=0);let f=l<<u;o==="+"?e|=f:o==="-"?e&=~f:o==="="&&(e&=~(7<<u),e|=f)}}return e}var Pp,Fp,Oo=C(()=>{"use strict";j();Pp={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},Fp={name:"chmod",async execute(t,e){if(I(t))return N(Pp);if(t.length<2)return{stdout:"",stderr:`chmod: missing operand
98
+ `),{stdout:u,stderr:"",exitCode:0}}}});var Do={};_(Do,{chmodCommand:()=>Lp});async function Oo(t,e,n,r){let s="",i=await t.fs.readdir(e);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;await t.fs.chmod(a,n),r&&(s+=`mode of '${a}' changed to ${n.toString(8).padStart(4,"0")}
99
+ `),(await t.fs.stat(a)).isDirectory&&(s+=await Oo(t,a,n,r))}return s}function Mp(t){if(/^[0-7]+$/.test(t))return parseInt(t,8);let e=420,n=t.split(",");for(let r of n){let s=r.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!s)throw new Error(`Invalid mode: ${t}`);let i=s[1]||"a",o=s[2],a=s[3];(i==="a"||i==="")&&(i="ugo");let l=0;a.includes("r")&&(l|=4),a.includes("w")&&(l|=2),(a.includes("x")||a.includes("X"))&&(l|=1);for(let c of i){let u=0;c==="u"?u=6:c==="g"?u=3:c==="o"&&(u=0);let f=l<<u;o==="+"?e|=f:o==="-"?e&=~f:o==="="&&(e&=~(7<<u),e|=f)}}return e}var Dp,Lp,Lo=C(()=>{"use strict";j();Dp={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},Lp={name:"chmod",async execute(t,e){if(N(t))return k(Dp);if(t.length<2)return{stdout:"",stderr:`chmod: missing operand
100
100
  `,exitCode:1};let n=!1,r=!1,s=0;for(;s<t.length&&t[s].startsWith("-");){let f=t[s];if(f==="-R"||f==="--recursive")n=!0,s++;else if(f==="-v"||f==="--verbose")r=!0,s++;else if(f==="--"){s++;break}else{if(/^[+-]?[rwxugo]+/.test(f)||/^\d+$/.test(f))break;if(/^-[Rv]+$/.test(f)){f.includes("R")&&(n=!0),f.includes("v")&&(r=!0),s++;continue}return{stdout:"",stderr:`chmod: invalid option -- '${f.slice(1)}'
101
101
  `,exitCode:1}}}if(t.length-s<2)return{stdout:"",stderr:`chmod: missing operand
102
- `,exitCode:1};let i=t[s],o=t.slice(s+1),a;try{a=Tp(i)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${i}'
102
+ `,exitCode:1};let i=t[s],o=t.slice(s+1),a;try{a=Mp(i)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${i}'
103
103
  `,exitCode:1}}let l="",c="",u=!1;for(let f of o){let d=e.fs.resolvePath(e.cwd,f);try{if(await e.fs.chmod(d,a),r&&(l+=`mode of '${f}' changed to ${a.toString(8).padStart(4,"0")}
104
- `),n&&(await e.fs.stat(d)).isDirectory){let h=await Fo(e,d,a,r);l+=h}}catch{c+=`chmod: cannot access '${f}': No such file or directory
105
- `,u=!0}}return{stdout:l,stderr:c,exitCode:u?1:0}}}});var Do={};L(Do,{pwdCommand:()=>Op});var Op,Lo=C(()=>{"use strict";Op={name:"pwd",async execute(t,e){return{stdout:`${e.cwd}
106
- `,stderr:"",exitCode:0}}}});var Mo={};L(Mo,{readlinkCommand:()=>Lp});var Dp,Lp,_o=C(()=>{"use strict";j();Dp={name:"readlink",summary:"print resolved symbolic links or canonical file names",usage:"readlink [OPTIONS] FILE...",options:["-f canonicalize by following every symlink in every component of the given name recursively"," --help display this help and exit"]},Lp={name:"readlink",async execute(t,e){if(I(t))return N(Dp);let n=!1,r=0;for(;r<t.length&&t[r].startsWith("-");){let a=t[r];if(a==="-f"||a==="--canonicalize")n=!0,r++;else if(a==="--"){r++;break}else return{stdout:"",stderr:`readlink: invalid option -- '${a.slice(1)}'
104
+ `),n&&(await e.fs.stat(d)).isDirectory){let h=await Oo(e,d,a,r);l+=h}}catch{c+=`chmod: cannot access '${f}': No such file or directory
105
+ `,u=!0}}return{stdout:l,stderr:c,exitCode:u?1:0}}}});var Mo={};_(Mo,{pwdCommand:()=>_p});var _p,_o=C(()=>{"use strict";_p={name:"pwd",async execute(t,e){return{stdout:`${e.cwd}
106
+ `,stderr:"",exitCode:0}}}});var Bo={};_(Bo,{readlinkCommand:()=>Wp});var Bp,Wp,Wo=C(()=>{"use strict";j();Bp={name:"readlink",summary:"print resolved symbolic links or canonical file names",usage:"readlink [OPTIONS] FILE...",options:["-f canonicalize by following every symlink in every component of the given name recursively"," --help display this help and exit"]},Wp={name:"readlink",async execute(t,e){if(N(t))return k(Bp);let n=!1,r=0;for(;r<t.length&&t[r].startsWith("-");){let a=t[r];if(a==="-f"||a==="--canonicalize")n=!0,r++;else if(a==="--"){r++;break}else return{stdout:"",stderr:`readlink: invalid option -- '${a.slice(1)}'
107
107
  `,exitCode:1}}let s=t.slice(r);if(s.length===0)return{stdout:"",stderr:`readlink: missing operand
108
108
  `,exitCode:1};let i="",o=!1;for(let a of s){let l=e.fs.resolvePath(e.cwd,a);try{if(n){let c=l,u=new Set;for(;!u.has(c);){u.add(c);try{let f=await e.fs.readlink(c);if(f.startsWith("/"))c=f;else{let d=c.substring(0,c.lastIndexOf("/"))||"/";c=e.fs.resolvePath(d,f)}}catch{break}}i+=`${c}
109
109
  `}else{let c=await e.fs.readlink(l);i+=`${c}
110
110
  `}}catch{n?i+=`${l}
111
- `:o=!0}}return{stdout:i,stderr:"",exitCode:o?1:0}}}});function Jn(t,e){let n=10,r=null,s=!1,i=!1,o=!1,a=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-n"&&l+1<t.length){let u=t[++l];e==="tail"&&u.startsWith("+")?(o=!0,n=parseInt(u.slice(1),10)):n=parseInt(u,10)}else if(e==="tail"&&c.startsWith("-n+"))o=!0,n=parseInt(c.slice(3),10);else if(c.startsWith("-n"))n=parseInt(c.slice(2),10);else if(c==="-c"&&l+1<t.length)r=parseInt(t[++l],10);else if(c.startsWith("-c"))r=parseInt(c.slice(2),10);else if(c.startsWith("--bytes="))r=parseInt(c.slice(8),10);else if(c.startsWith("--lines="))n=parseInt(c.slice(8),10);else if(c==="-q"||c==="--quiet"||c==="--silent")s=!0;else if(c==="-v"||c==="--verbose")i=!0;else if(c.match(/^-\d+$/))n=parseInt(c.slice(1),10);else{if(c.startsWith("--"))return{ok:!1,error:D(e,c)};if(c.startsWith("-")&&c!=="-")return{ok:!1,error:D(e,c)};a.push(c)}}return r!==null&&(Number.isNaN(r)||r<0)?{ok:!1,error:{stdout:"",stderr:`${e}: invalid number of bytes
111
+ `:o=!0}}return{stdout:i,stderr:"",exitCode:o?1:0}}}});function er(t,e){let n=10,r=null,s=!1,i=!1,o=!1,a=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-n"&&l+1<t.length){let u=t[++l];e==="tail"&&u.startsWith("+")?(o=!0,n=parseInt(u.slice(1),10)):n=parseInt(u,10)}else if(e==="tail"&&c.startsWith("-n+"))o=!0,n=parseInt(c.slice(3),10);else if(c.startsWith("-n"))n=parseInt(c.slice(2),10);else if(c==="-c"&&l+1<t.length)r=parseInt(t[++l],10);else if(c.startsWith("-c"))r=parseInt(c.slice(2),10);else if(c.startsWith("--bytes="))r=parseInt(c.slice(8),10);else if(c.startsWith("--lines="))n=parseInt(c.slice(8),10);else if(c==="-q"||c==="--quiet"||c==="--silent")s=!0;else if(c==="-v"||c==="--verbose")i=!0;else if(c.match(/^-\d+$/))n=parseInt(c.slice(1),10);else{if(c.startsWith("--"))return{ok:!1,error:L(e,c)};if(c.startsWith("-")&&c!=="-")return{ok:!1,error:L(e,c)};a.push(c)}}return r!==null&&(Number.isNaN(r)||r<0)?{ok:!1,error:{stdout:"",stderr:`${e}: invalid number of bytes
112
112
  `,exitCode:1}}:Number.isNaN(n)||n<0?{ok:!1,error:{stdout:"",stderr:`${e}: invalid number of lines
113
- `,exitCode:1}}:{ok:!0,options:{lines:n,bytes:r,quiet:s,verbose:i,files:a,fromLine:o}}}async function Yn(t,e,n,r){let{quiet:s,verbose:i,files:o}=e;if(o.length===0)return{stdout:r(t.stdin),stderr:"",exitCode:0};let a="",l="",c=0,u=i||!s&&o.length>1;for(let f=0;f<o.length;f++){let d=o[f];u&&(f>0&&(a+=`
113
+ `,exitCode:1}}:{ok:!0,options:{lines:n,bytes:r,quiet:s,verbose:i,files:a,fromLine:o}}}async function tr(t,e,n,r){let{quiet:s,verbose:i,files:o}=e;if(o.length===0)return{stdout:r(t.stdin),stderr:"",exitCode:0};let a="",l="",c=0,u=i||!s&&o.length>1;for(let f=0;f<o.length;f++){let d=o[f];u&&(f>0&&(a+=`
114
114
  `),a+=`==> ${d} <==
115
115
  `);try{let p=t.fs.resolvePath(t.cwd,d),h=await t.fs.readFile(p);a+=r(h)}catch{l+=`${n}: ${d}: No such file or directory
116
- `,c=1}}return{stdout:a,stderr:l,exitCode:c}}function Bo(t,e,n){if(n!==null)return t.slice(0,n);if(e===0)return"";let r=0,s=0,i=t.length;for(;r<i&&s<e;){let o=t.indexOf(`
116
+ `,c=1}}return{stdout:a,stderr:l,exitCode:c}}function Uo(t,e,n){if(n!==null)return t.slice(0,n);if(e===0)return"";let r=0,s=0,i=t.length;for(;r<i&&s<e;){let o=t.indexOf(`
117
117
  `,r);if(o===-1)return`${t}
118
- `;s++,r=o+1}return r>0?t.slice(0,r):""}function Wo(t,e,n,r){if(n!==null)return t.slice(-n);let s=t.length;if(s===0)return"";if(r){let l=0,c=1;for(;l<s&&c<e;){let f=t.indexOf(`
118
+ `;s++,r=o+1}return r>0?t.slice(0,r):""}function jo(t,e,n,r){if(n!==null)return t.slice(-n);let s=t.length;if(s===0)return"";if(r){let l=0,c=1;for(;l<s&&c<e;){let f=t.indexOf(`
119
119
  `,l);if(f===-1)break;c++,l=f+1}let u=t.slice(l);return u.endsWith(`
120
120
  `)?u:`${u}
121
121
  `}if(e===0)return"";let i=s-1;t[i]===`
122
122
  `&&i--;let o=0;for(;i>=0&&o<e;){if(t[i]===`
123
123
  `&&(o++,o===e)){i++;break}i--}i<0&&(i=0);let a=t.slice(i);return t[s-1]===`
124
124
  `?a:`${a}
125
- `}var ls=C(()=>{"use strict";j()});var Uo={};L(Uo,{headCommand:()=>_p});var Mp,_p,jo=C(()=>{"use strict";j();ls();Mp={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},_p={name:"head",async execute(t,e){if(I(t))return N(Mp);let n=Jn(t,"head");if(!n.ok)return n.error;let{lines:r,bytes:s}=n.options;return Yn(e,n.options,"head",i=>Bo(i,r,s))}}});var zo={};L(zo,{tailCommand:()=>Wp});var Bp,Wp,Ho=C(()=>{"use strict";ls();j();Bp={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},Wp={name:"tail",async execute(t,e){if(I(t))return N(Bp);let n=Jn(t,"tail");if(!n.ok)return n.error;let{lines:r,bytes:s,fromLine:i}=n.options;return Yn(e,n.options,"tail",o=>Wo(o,r,s,i??!1))}}});var qo={};L(qo,{wcCommand:()=>zp});function Go(t){let e=t.length,n=0,r=0,s=!1;for(let i=0;i<e;i++){let o=t[i];o===`
126
- `?(n++,s&&(r++,s=!1)):o===" "||o===" "||o==="\r"?s&&(r++,s=!1):s=!0}return s&&r++,{lines:n,words:r,chars:e}}function cs(t,e,n,r,s){let i=[];e&&i.push(String(t.lines)),n&&i.push(String(t.words)),r&&i.push(String(t.chars));let o=i.join(" ");return s&&(o+=` ${s}`),o}var Up,jp,zp,Vo=C(()=>{"use strict";Ae();Nt();j();Up={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},jp={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},zp={name:"wc",async execute(t,e){if(I(t))return N(Up);let n=K("wc",t,jp);if(!n.ok)return n.error;let{lines:r,words:s}=n.result.flags,i=n.result.flags.bytes||n.result.flags.chars,o=n.result.positional;!r&&!s&&!i&&(r=s=i=!0);let a=await kt(e,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let d=Go(a.files[0].content);return{stdout:`${cs(d,r,s,i,"")}
127
- `,stderr:"",exitCode:0}}let l="",c=0,u=0,f=0;for(let{filename:d,content:p}of a.files){let h=Go(p);c+=h.lines,u+=h.words,f+=h.chars,l+=`${cs(h,r,s,i,d)}
128
- `}return o.length>1&&(l+=`${cs({lines:c,words:u,chars:f},r,s,i,"total")}
129
- `),{stdout:l,stderr:a.stderr,exitCode:a.exitCode}}}});var Ko={};L(Ko,{statCommand:()=>qp});function Zo(t,e){let n=e?"d":"-",r=[t&256?"r":"-",t&128?"w":"-",t&64?"x":"-",t&32?"r":"-",t&16?"w":"-",t&8?"x":"-",t&4?"r":"-",t&2?"w":"-",t&1?"x":"-"];return n+r.join("")}var Hp,Gp,qp,Qo=C(()=>{"use strict";Ae();j();Hp={name:"stat",summary:"display file or file system status",usage:"stat [OPTION]... FILE...",options:["-c FORMAT use the specified FORMAT instead of the default"," --help display this help and exit"]},Gp={format:{short:"c",type:"string"}},qp={name:"stat",async execute(t,e){if(I(t))return N(Hp);let n=K("stat",t,Gp);if(!n.ok)return n.error;let r=n.result.flags.format??null,s=n.result.positional;if(s.length===0)return{stdout:"",stderr:`stat: missing operand
130
- `,exitCode:1};let i="",o="",a=!1;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{let u=await e.fs.stat(c);if(r){let f=r,d=u.mode.toString(8),p=Zo(u.mode,u.isDirectory);f=f.replace(/%n/g,l),f=f.replace(/%N/g,`'${l}'`),f=f.replace(/%s/g,String(u.size)),f=f.replace(/%F/g,u.isDirectory?"directory":"regular file"),f=f.replace(/%a/g,d),f=f.replace(/%A/g,p),f=f.replace(/%u/g,"1000"),f=f.replace(/%U/g,"user"),f=f.replace(/%g/g,"1000"),f=f.replace(/%G/g,"group"),i+=`${f}
131
- `}else{let f=u.mode.toString(8).padStart(4,"0"),d=Zo(u.mode,u.isDirectory);i+=` File: ${l}
125
+ `}var cs=C(()=>{"use strict";j()});var zo={};_(zo,{headCommand:()=>jp});var Up,jp,Ho=C(()=>{"use strict";j();cs();Up={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},jp={name:"head",async execute(t,e){if(N(t))return k(Up);let n=er(t,"head");if(!n.ok)return n.error;let{lines:r,bytes:s}=n.options;return tr(e,n.options,"head",i=>Uo(i,r,s))}}});var Go={};_(Go,{tailCommand:()=>Hp});var zp,Hp,qo=C(()=>{"use strict";cs();j();zp={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},Hp={name:"tail",async execute(t,e){if(N(t))return k(zp);let n=er(t,"tail");if(!n.ok)return n.error;let{lines:r,bytes:s,fromLine:i}=n.options;return tr(e,n.options,"tail",o=>jo(o,r,s,i??!1))}}});var Zo={};_(Zo,{wcCommand:()=>Vp});function Vo(t){let e=t.length,n=0,r=0,s=!1;for(let i=0;i<e;i++){let o=t[i];o===`
126
+ `?(n++,s&&(r++,s=!1)):o===" "||o===" "||o==="\r"?s&&(r++,s=!1):s=!0}return s&&r++,{lines:n,words:r,chars:e}}function us(t,e,n,r,s){let i=[];e&&i.push(String(t.lines)),n&&i.push(String(t.words)),r&&i.push(String(t.chars));let o=i.join(" ");return s&&(o+=` ${s}`),o}var Gp,qp,Vp,Ko=C(()=>{"use strict";Ae();It();j();Gp={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},qp={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},Vp={name:"wc",async execute(t,e){if(N(t))return k(Gp);let n=Q("wc",t,qp);if(!n.ok)return n.error;let{lines:r,words:s}=n.result.flags,i=n.result.flags.bytes||n.result.flags.chars,o=n.result.positional;!r&&!s&&!i&&(r=s=i=!0);let a=await Nt(e,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let d=Vo(a.files[0].content);return{stdout:`${us(d,r,s,i,"")}
127
+ `,stderr:"",exitCode:0}}let l="",c=0,u=0,f=0;for(let{filename:d,content:p}of a.files){let h=Vo(p);c+=h.lines,u+=h.words,f+=h.chars,l+=`${us(h,r,s,i,d)}
128
+ `}return o.length>1&&(l+=`${us({lines:c,words:u,chars:f},r,s,i,"total")}
129
+ `),{stdout:l,stderr:a.stderr,exitCode:a.exitCode}}}});var Xo={};_(Xo,{statCommand:()=>Qp});function Qo(t,e){let n=e?"d":"-",r=[t&256?"r":"-",t&128?"w":"-",t&64?"x":"-",t&32?"r":"-",t&16?"w":"-",t&8?"x":"-",t&4?"r":"-",t&2?"w":"-",t&1?"x":"-"];return n+r.join("")}var Zp,Kp,Qp,Jo=C(()=>{"use strict";Ae();j();Zp={name:"stat",summary:"display file or file system status",usage:"stat [OPTION]... FILE...",options:["-c FORMAT use the specified FORMAT instead of the default"," --help display this help and exit"]},Kp={format:{short:"c",type:"string"}},Qp={name:"stat",async execute(t,e){if(N(t))return k(Zp);let n=Q("stat",t,Kp);if(!n.ok)return n.error;let r=n.result.flags.format??null,s=n.result.positional;if(s.length===0)return{stdout:"",stderr:`stat: missing operand
130
+ `,exitCode:1};let i="",o="",a=!1;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{let u=await e.fs.stat(c);if(r){let f=r,d=u.mode.toString(8),p=Qo(u.mode,u.isDirectory);f=f.replace(/%n/g,l),f=f.replace(/%N/g,`'${l}'`),f=f.replace(/%s/g,String(u.size)),f=f.replace(/%F/g,u.isDirectory?"directory":"regular file"),f=f.replace(/%a/g,d),f=f.replace(/%A/g,p),f=f.replace(/%u/g,"1000"),f=f.replace(/%U/g,"user"),f=f.replace(/%g/g,"1000"),f=f.replace(/%G/g,"group"),i+=`${f}
131
+ `}else{let f=u.mode.toString(8).padStart(4,"0"),d=Qo(u.mode,u.isDirectory);i+=` File: ${l}
132
132
  `,i+=` Size: ${u.size} Blocks: ${Math.ceil(u.size/512)}
133
133
  `,i+=`Access: (${f}/${d})
134
134
  `,i+=`Modify: ${u.mtime.toISOString()}
135
135
  `}}catch{o+=`stat: cannot stat '${l}': No such file or directory
136
- `,a=!0}}return{stdout:i,stderr:o,exitCode:a?1:0}}}});function Le(t,e,n){let r=typeof n=="boolean"?{ignoreCase:n}:n??{},s=e;r.stripQuotes&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1));let i=r.ignoreCase?`i:${s}`:s,o=Xo.get(i);return o||(o=Vp(s,r.ignoreCase),Xo.set(i,o)),o.test(t)}function Vp(t,e){let n="^";for(let r=0;r<t.length;r++){let s=t[r];if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=r+1;for(;i<t.length&&t[i]!=="]";)i++;n+=t.slice(r,i+1),r=i}else s==="."||s==="+"||s==="^"||s==="$"||s==="{"||s==="}"||s==="("||s===")"||s==="|"||s==="\\"?n+=`\\${s}`:n+=s}return n+="$",new RegExp(n,e?"i":"")}var Xo,us=C(()=>{"use strict";Xo=new Map});function Vt(t,e,n={}){let{invertMatch:r=!1,showLineNumbers:s=!1,countOnly:i=!1,countMatches:o=!1,filename:a="",onlyMatching:l=!1,beforeContext:c=0,afterContext:u=0,maxCount:f=0,contextSeparator:d="--",showColumn:p=!1,vimgrep:h=!1,showByteOffset:m=!1,replace:g=null,passthru:w=!1,multiline:b=!1}=n;if(b)return Zp(t,e,{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:d,showColumn:p,showByteOffset:m,replace:g});let E=t.split(`
137
- `),S=E.length,R=S>0&&E[S-1]===""?S-1:S;if(i||o){let T=0;for(let k=0;k<R;k++)if(e.lastIndex=0,o)for(let $=e.exec(E[k]);$!==null;$=e.exec(E[k]))r||T++,$[0].length===0&&e.lastIndex++;else e.test(E[k])!==r&&T++;return{output:`${a?`${a}:${T}`:String(T)}
138
- `,matched:T>0,matchCount:T}}if(c===0&&u===0&&!w){let T=[],v=!1,k=0,$=0;for(let M=0;M<R&&!(f>0&&k>=f);M++){let ee=E[M];if(e.lastIndex=0,e.test(ee)!==r)if(v=!0,k++,l){e.lastIndex=0;for(let oe=e.exec(ee);oe!==null;oe=e.exec(ee)){let Z=g!==null?g:oe[0],O=a?`${a}:`:"";m&&(O+=`${$+oe.index}:`),s&&(O+=`${M+1}:`),p&&(O+=`${oe.index+1}:`),T.push(O+Z),oe[0].length===0&&e.lastIndex++}}else if(h){e.lastIndex=0;for(let oe=e.exec(ee);oe!==null;oe=e.exec(ee)){let Z=a?`${a}:`:"";m&&(Z+=`${$+oe.index}:`),s&&(Z+=`${M+1}:`),p&&(Z+=`${oe.index+1}:`),T.push(Z+ee),oe[0].length===0&&e.lastIndex++}}else{e.lastIndex=0;let oe=e.exec(ee),Z=oe?oe.index+1:1,O=ee;g!==null&&(e.lastIndex=0,O=ee.replace(e,g));let ie=a?`${a}:`:"";m&&(ie+=`${$+(oe?oe.index:0)}:`),s&&(ie+=`${M+1}:`),p&&(ie+=`${Z}:`),T.push(ie+O)}$+=ee.length+1}return{output:T.length>0?`${T.join(`
136
+ `,a=!0}}return{stdout:i,stderr:o,exitCode:a?1:0}}}});function Le(t,e,n){let r=typeof n=="boolean"?{ignoreCase:n}:n??{},s=e;r.stripQuotes&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1));let i=r.ignoreCase?`i:${s}`:s,o=Yo.get(i);return o||(o=Xp(s,r.ignoreCase),Yo.set(i,o)),o.test(t)}function Xp(t,e){let n="^";for(let r=0;r<t.length;r++){let s=t[r];if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=r+1;for(;i<t.length&&t[i]!=="]";)i++;n+=t.slice(r,i+1),r=i}else s==="."||s==="+"||s==="^"||s==="$"||s==="{"||s==="}"||s==="("||s===")"||s==="|"||s==="\\"?n+=`\\${s}`:n+=s}return n+="$",new RegExp(n,e?"i":"")}var Yo,fs=C(()=>{"use strict";Yo=new Map});function ea(t,e){return t.replace(/\$(&|\d+|<([^>]+)>)/g,(n,r,s)=>{if(r==="&")return e[0];if(s!==void 0)return e.groups?.[s]??"";let i=parseInt(r,10);return e[i]??""})}function Zt(t,e,n={}){let{invertMatch:r=!1,showLineNumbers:s=!1,countOnly:i=!1,countMatches:o=!1,filename:a="",onlyMatching:l=!1,beforeContext:c=0,afterContext:u=0,maxCount:f=0,contextSeparator:d="--",showColumn:p=!1,vimgrep:h=!1,showByteOffset:m=!1,replace:g=null,passthru:b=!1,multiline:w=!1}=n;if(w)return Jp(t,e,{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:d,showColumn:p,showByteOffset:m,replace:g});let E=t.split(`
137
+ `),S=E.length,R=S>0&&E[S-1]===""?S-1:S;if(i||o){let T=0,$=(o||l)&&!r;for(let v=0;v<R;v++)if(e.lastIndex=0,$)for(let D=e.exec(E[v]);D!==null;D=e.exec(E[v]))T++,D[0].length===0&&e.lastIndex++;else e.test(E[v])!==r&&T++;return{output:`${a?`${a}:${T}`:String(T)}
138
+ `,matched:T>0,matchCount:T}}if(c===0&&u===0&&!b){let T=[],$=!1,I=0,v=0;for(let D=0;D<R&&!(f>0&&I>=f);D++){let ee=E[D];if(e.lastIndex=0,e.test(ee)!==r)if($=!0,I++,l){e.lastIndex=0;for(let ie=e.exec(ee);ie!==null;ie=e.exec(ee)){let K=g!==null?ea(g,ie):ie[0],M=a?`${a}:`:"";m&&(M+=`${v+ie.index}:`),s&&(M+=`${D+1}:`),p&&(M+=`${ie.index+1}:`),T.push(M+K),ie[0].length===0&&e.lastIndex++}}else if(h){e.lastIndex=0;for(let ie=e.exec(ee);ie!==null;ie=e.exec(ee)){let K=a?`${a}:`:"";m&&(K+=`${v+ie.index}:`),s&&(K+=`${D+1}:`),p&&(K+=`${ie.index+1}:`),T.push(K+ee),ie[0].length===0&&e.lastIndex++}}else{e.lastIndex=0;let ie=e.exec(ee),K=ie?ie.index+1:1,M=ee;g!==null&&(e.lastIndex=0,M=ee.replace(e,(...q)=>{if(q[0].length===0)return"";let O=q,ae=q[q.length-1];return typeof ae=="object"&&ae!==null?(O.groups=ae,O.input=q[q.length-2],O.index=q[q.length-3]):(O.input=q[q.length-1],O.index=q[q.length-2]),ea(g,O)}));let oe=a?`${a}:`:"";m&&(oe+=`${v+(ie?ie.index:0)}:`),s&&(oe+=`${D+1}:`),p&&(oe+=`${K}:`),T.push(oe+M)}v+=ee.length+1}return{output:T.length>0?`${T.join(`
139
139
  `)}
140
- `:"",matched:v,matchCount:k}}if(w){let T=[],v=!1,k=0;for(let $=0;$<R;$++){let M=E[$];e.lastIndex=0;let we=e.test(M)!==r;we&&(v=!0,k++);let oe=we?":":"-",Z=a?`${a}${oe}`:"";s&&(Z+=`${$+1}${oe}`),T.push(Z+M)}return{output:T.length>0?`${T.join(`
140
+ `:"",matched:$,matchCount:I}}if(b){let T=[],$=!1,I=0;for(let v=0;v<R;v++){let D=E[v];e.lastIndex=0;let we=e.test(D)!==r;we&&($=!0,I++);let ie=we?":":"-",K=a?`${a}${ie}`:"";s&&(K+=`${v+1}${ie}`),T.push(K+D)}return{output:T.length>0?`${T.join(`
141
141
  `)}
142
- `:"",matched:v,matchCount:k}}let P=[],z=0,W=new Set,X=-1,F=[];for(let T=0;T<R&&!(f>0&&z>=f);T++)e.lastIndex=0,e.test(E[T])!==r&&(F.push(T),z++);for(let T of F){let v=Math.max(0,T-c);X>=0&&v>X+1&&P.push(d);for(let $=v;$<T;$++)if(!W.has($)){W.add($),X=$;let M=E[$];s&&(M=`${$+1}-${M}`),a&&(M=`${a}-${M}`),P.push(M)}if(!W.has(T)){W.add(T),X=T;let $=E[T];if(l){e.lastIndex=0;for(let M=e.exec($);M!==null;M=e.exec($)){let ee=g!==null?g:M[0],we=a?`${a}:`:"";s&&(we+=`${T+1}:`),p&&(we+=`${M.index+1}:`),P.push(we+ee),M[0].length===0&&e.lastIndex++}}else{let M=$;s&&(M=`${T+1}:${M}`),a&&(M=`${a}:${M}`),P.push(M)}}let k=Math.min(R-1,T+u);for(let $=T+1;$<=k;$++)if(!W.has($)){W.add($),X=$;let M=E[$];s&&(M=`${$+1}-${M}`),a&&(M=`${a}-${M}`),P.push(M)}}return{output:P.length>0?`${P.join(`
142
+ `:"",matched:$,matchCount:I}}let F=[],z=0,W=new Set,J=-1,P=[];for(let T=0;T<R&&!(f>0&&z>=f);T++)e.lastIndex=0,e.test(E[T])!==r&&(P.push(T),z++);for(let T of P){let $=Math.max(0,T-c);J>=0&&$>J+1&&F.push(d);for(let v=$;v<T;v++)if(!W.has(v)){W.add(v),J=v;let D=E[v];s&&(D=`${v+1}-${D}`),a&&(D=`${a}-${D}`),F.push(D)}if(!W.has(T)){W.add(T),J=T;let v=E[T];if(l){e.lastIndex=0;for(let D=e.exec(v);D!==null;D=e.exec(v)){let ee=g!==null?g:D[0],we=a?`${a}:`:"";s&&(we+=`${T+1}:`),p&&(we+=`${D.index+1}:`),F.push(we+ee),D[0].length===0&&e.lastIndex++}}else{let D=v;s&&(D=`${T+1}:${D}`),a&&(D=`${a}:${D}`),F.push(D)}}let I=Math.min(R-1,T+u);for(let v=T+1;v<=I;v++)if(!W.has(v)){W.add(v),J=v;let D=E[v];s&&(D=`${v+1}-${D}`),a&&(D=`${a}-${D}`),F.push(D)}}return{output:F.length>0?`${F.join(`
143
143
  `)}
144
- `:"",matched:z>0,matchCount:z}}function Zp(t,e,n){let{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:d,showColumn:p,showByteOffset:h,replace:m}=n,g=t.split(`
145
- `),w=g.length,b=w>0&&g[w-1]===""?w-1:w,E=[0];for(let F=0;F<t.length;F++)t[F]===`
146
- `&&E.push(F+1);let S=F=>{let T=0;for(let v=0;v<E.length&&!(E[v]>F);v++)T=v;return T},R=F=>{let T=S(F);return F-E[T]+1},P=[];e.lastIndex=0;for(let F=e.exec(t);F!==null&&!(f>0&&P.length>=f);F=e.exec(t)){let T=S(F.index),v=S(F.index+Math.max(0,F[0].length-1));P.push({startLine:T,endLine:v,byteOffset:F.index,column:R(F.index),matchText:F[0]}),F[0].length===0&&e.lastIndex++}if(i||o){let F;if(o)F=r?0:P.length;else{let v=new Set;for(let k of P)for(let $=k.startLine;$<=k.endLine;$++)v.add($);F=r?b-v.size:v.size}return{output:`${a?`${a}:${F}`:String(F)}
147
- `,matched:F>0,matchCount:F}}if(r){let F=new Set;for(let v of P)for(let k=v.startLine;k<=v.endLine;k++)F.add(k);let T=[];for(let v=0;v<b;v++)if(!F.has(v)){let k=g[v];s&&(k=`${v+1}:${k}`),a&&(k=`${a}:${k}`),T.push(k)}return{output:T.length>0?`${T.join(`
144
+ `:"",matched:z>0,matchCount:z}}function Jp(t,e,n){let{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:d,showColumn:p,showByteOffset:h,replace:m}=n,g=t.split(`
145
+ `),b=g.length,w=b>0&&g[b-1]===""?b-1:b,E=[0];for(let P=0;P<t.length;P++)t[P]===`
146
+ `&&E.push(P+1);let S=P=>{let T=0;for(let $=0;$<E.length&&!(E[$]>P);$++)T=$;return T},R=P=>{let T=S(P);return P-E[T]+1},F=[];e.lastIndex=0;for(let P=e.exec(t);P!==null&&!(f>0&&F.length>=f);P=e.exec(t)){let T=S(P.index),$=S(P.index+Math.max(0,P[0].length-1));F.push({startLine:T,endLine:$,byteOffset:P.index,column:R(P.index),matchText:P[0]}),P[0].length===0&&e.lastIndex++}if(i||o){let P;if(o)P=r?0:F.length;else{let $=new Set;for(let I of F)for(let v=I.startLine;v<=I.endLine;v++)$.add(v);P=r?w-$.size:$.size}return{output:`${a?`${a}:${P}`:String(P)}
147
+ `,matched:P>0,matchCount:P}}if(r){let P=new Set;for(let $ of F)for(let I=$.startLine;I<=$.endLine;I++)P.add(I);let T=[];for(let $=0;$<w;$++)if(!P.has($)){let I=g[$];s&&(I=`${$+1}:${I}`),a&&(I=`${a}:${I}`),T.push(I)}return{output:T.length>0?`${T.join(`
148
148
  `)}
149
- `:"",matched:T.length>0,matchCount:T.length}}if(P.length===0)return{output:"",matched:!1,matchCount:0};let z=new Set,W=-1,X=[];for(let F of P){let T=Math.max(0,F.startLine-c),v=Math.min(b-1,F.endLine+u);W>=0&&T>W+1&&X.push(d);for(let k=T;k<F.startLine;k++)if(!z.has(k)){z.add(k),W=k;let $=g[k];s&&($=`${k+1}-${$}`),a&&($=`${a}-${$}`),X.push($)}if(l){let k=m!==null?m:F.matchText,$=a?`${a}:`:"";h&&($+=`${F.byteOffset}:`),s&&($+=`${F.startLine+1}:`),p&&($+=`${F.column}:`),X.push($+k);for(let M=F.startLine;M<=F.endLine;M++)z.add(M),W=M}else for(let k=F.startLine;k<=F.endLine&&k<b;k++)if(!z.has(k)){z.add(k),W=k;let $=g[k];m!==null&&k===F.startLine&&(e.lastIndex=0,$=$.replace(e,m));let M=a?`${a}:`:"";h&&k===F.startLine&&(M+=`${F.byteOffset}:`),s&&(M+=`${k+1}:`),p&&k===F.startLine&&(M+=`${F.column}:`),X.push(M+$)}for(let k=F.endLine+1;k<=v;k++)if(!z.has(k)){z.add(k),W=k;let $=g[k];s&&($=`${k+1}-${$}`),a&&($=`${a}-${$}`),X.push($)}}return{output:X.length>0?`${X.join(`
149
+ `:"",matched:T.length>0,matchCount:T.length}}if(F.length===0)return{output:"",matched:!1,matchCount:0};let z=new Set,W=-1,J=[];for(let P of F){let T=Math.max(0,P.startLine-c),$=Math.min(w-1,P.endLine+u);W>=0&&T>W+1&&J.push(d);for(let I=T;I<P.startLine;I++)if(!z.has(I)){z.add(I),W=I;let v=g[I];s&&(v=`${I+1}-${v}`),a&&(v=`${a}-${v}`),J.push(v)}if(l){let I=m!==null?m:P.matchText,v=a?`${a}:`:"";h&&(v+=`${P.byteOffset}:`),s&&(v+=`${P.startLine+1}:`),p&&(v+=`${P.column}:`),J.push(v+I);for(let D=P.startLine;D<=P.endLine;D++)z.add(D),W=D}else for(let I=P.startLine;I<=P.endLine&&I<w;I++)if(!z.has(I)){z.add(I),W=I;let v=g[I];m!==null&&I===P.startLine&&(e.lastIndex=0,v=v.replace(e,m));let D=a?`${a}:`:"";h&&I===P.startLine&&(D+=`${P.byteOffset}:`),s&&(D+=`${I+1}:`),p&&I===P.startLine&&(D+=`${P.column}:`),J.push(D+v)}for(let I=P.endLine+1;I<=$;I++)if(!z.has(I)){z.add(I),W=I;let v=g[I];s&&(v=`${I+1}-${v}`),a&&(v=`${a}-${v}`),J.push(v)}}return{output:J.length>0?`${J.join(`
150
150
  `)}
151
- `:"",matched:!0,matchCount:P.length}}var Jo=C(()=>{"use strict"});function wn(t,e){let n;switch(e.mode){case"fixed":n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":n=t;break;default:n=Kp(t);break}e.wholeWord&&(n=`(?<![\\w])(?:${n})(?![\\w])`),e.lineRegexp&&(n=`^${n}$`);let r=`g${e.ignoreCase?"i":""}${e.multilineDotall?"s":""}`;return new RegExp(n,r)}function Kp(t){let e="",n=0;for(;n<t.length;){let r=t[n];if(r==="\\"&&n+1<t.length){let s=t[n+1];if(s==="|"||s==="("||s===")"){e+=s,n+=2;continue}else if(s==="{"||s==="}"){e+=`\\${s}`,n+=2;continue}}r==="+"||r==="?"||r==="|"||r==="("||r===")"||r==="{"||r==="}"?e+=`\\${r}`:e+=r,n++}return e}var Yo=C(()=>{"use strict"});var fs=C(()=>{"use strict";Jo();Yo()});var tr={};L(tr,{egrepCommand:()=>Yp,fgrepCommand:()=>Jp,grepCommand:()=>ds});async function ea(t,e,n,r){let s=n.fs.resolvePath(n.cwd,t);try{if(!(await n.fs.stat(s)).isDirectory){let a=t.split("/").pop()||"";if(e){let l=e.replace(/^\//,"");Le(a,l,{stripQuotes:!0})&&r.push(t)}return}let o=await n.fs.readdir(s);for(let a of o){let l=t==="."?a:`${t}/${a}`,c=n.fs.resolvePath(n.cwd,l);if((await n.fs.stat(c)).isDirectory)await ea(l,e,n,r);else if(e){let f=e.replace(/^\//,"");Le(a,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function Xp(t,e){let n=[],r=t.lastIndexOf("/"),s,i;if(r===-1?(s=e.cwd,i=t):(s=t.slice(0,r)||"/",i=t.slice(r+1)),t.includes("**")){let a=[],l=t.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await ea(c,u,e,a),a.map(f=>({path:f}))}let o=e.fs.resolvePath(e.cwd,s);try{if(e.fs.readdirWithFileTypes){let a=await e.fs.readdirWithFileTypes(o);for(let l of a)if(Le(l.name,i,{stripQuotes:!0})){let c=r===-1?l.name:`${s}/${l.name}`;n.push({path:c,isFile:l.isFile})}}else{let a=await e.fs.readdir(o);for(let l of a)if(Le(l,i,{stripQuotes:!0})){let c=r===-1?l:`${s}/${l}`;n.push({path:c})}}}catch{}return n.sort((a,l)=>a.path.localeCompare(l.path))}async function er(t,e,n=[],r=[],s=[],i){let o=e.fs.resolvePath(e.cwd,t),a=[];try{let l,c;if(i!==void 0)l=i,c=!i;else{let f=await e.fs.stat(o);l=f.isFile,c=f.isDirectory}if(l){let f=t.split("/").pop()||t;return r.length>0&&r.some(d=>Le(f,d,{stripQuotes:!0}))?[]:n.length>0&&!n.some(d=>Le(f,d,{stripQuotes:!0}))?[]:[{path:t,isFile:!0}]}if(!c)return[];let u=t.split("/").pop()||t;if(s.length>0&&s.some(f=>Le(u,f,{stripQuotes:!0})))return[];if(e.fs.readdirWithFileTypes){let f=await e.fs.readdirWithFileTypes(o);for(let d of f){if(d.name.startsWith("."))continue;let p=t==="."?d.name:`${t}/${d.name}`,h=await er(p,e,n,r,s,d.isFile);a.push(...h)}}else{let f=await e.fs.readdir(o);for(let d of f){if(d.startsWith("."))continue;let p=t==="."?d:`${t}/${d}`,h=await er(p,e,n,r,s);a.push(...h)}}}catch{}return a}var Qp,ds,Jp,Yp,nr=C(()=>{"use strict";us();j();fs();Qp={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},ds={name:"grep",async execute(t,e){if(I(t))return N(Qp);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,d=!1,p=!1,h=!1,m=!1,g=!1,w=0,b=0,E=0,S=[],R=[],P=[],z=null,W=[];for(let Z=0;Z<t.length;Z++){let O=t[Z];if(O.startsWith("-")&&O!=="-"){if(O==="-e"&&Z+1<t.length){z=t[++Z];continue}if(O.startsWith("--include=")){S.push(O.slice(10));continue}if(O.startsWith("--exclude=")){R.push(O.slice(10));continue}if(O.startsWith("--exclude-dir=")){P.push(O.slice(14));continue}if(O.startsWith("--max-count=")){w=parseInt(O.slice(12),10);continue}let ie=O.match(/^-m(\d+)$/);if(ie){w=parseInt(ie[1],10);continue}if(O==="-m"&&Z+1<t.length){w=parseInt(t[++Z],10);continue}let J=O.match(/^-([ABC])(\d+)$/);if(J){let _=parseInt(J[2],10);J[1]==="A"?E=_:J[1]==="B"?b=_:J[1]==="C"&&(b=_,E=_);continue}if((O==="-A"||O==="-B"||O==="-C")&&Z+1<t.length){let _=parseInt(t[++Z],10);O==="-A"?E=_:O==="-B"?b=_:(b=_,E=_);continue}let ne=O.startsWith("--")?[O]:O.slice(1).split("");for(let _ of ne)if(_==="i"||_==="--ignore-case")n=!0;else if(_==="n"||_==="--line-number")r=!0;else if(_==="v"||_==="--invert-match")s=!0;else if(_==="c"||_==="--count")i=!0;else if(_==="l"||_==="--files-with-matches")o=!0;else if(_==="L"||_==="--files-without-match")a=!0;else if(_==="r"||_==="R"||_==="--recursive")l=!0;else if(_==="w"||_==="--word-regexp")c=!0;else if(_==="x"||_==="--line-regexp")u=!0;else if(_==="E"||_==="--extended-regexp")f=!0;else if(_==="P"||_==="--perl-regexp")d=!0;else if(_==="F"||_==="--fixed-strings")p=!0;else if(_==="o"||_==="--only-matching")h=!0;else if(_==="h"||_==="--no-filename")m=!0;else if(_==="q"||_==="--quiet"||_==="--silent")g=!0;else{if(_.startsWith("--"))return D("grep",_);if(_.length===1)return D("grep",`-${_}`)}}else z===null?z=O:W.push(O)}if(z===null)return{stdout:"",stderr:`grep: missing pattern
152
- `,exitCode:2};let X=p?"fixed":f?"extended":d?"perl":"basic",F;try{F=wn(z,{mode:X,ignoreCase:n,wholeWord:c,lineRegexp:u})}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${z}
153
- `,exitCode:2}}if(W.length===0&&e.stdin){let Z=Vt(e.stdin,F,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:"",onlyMatching:h,beforeContext:b,afterContext:E,maxCount:w});return g?{stdout:"",stderr:"",exitCode:Z.matched?0:1}:{stdout:Z.output,stderr:"",exitCode:Z.matched?0:1}}if(W.length===0)return{stdout:"",stderr:`grep: no input files
154
- `,exitCode:2};let T="",v="",k=!1,$=!1,M=[];for(let Z of W)if(Z.includes("*")||Z.includes("?")||Z.includes("[")){let O=await Xp(Z,e);if(l)for(let ie of O){let J=await er(ie.path,e,S,R,P,ie.isFile);M.push(...J)}else M.push(...O)}else if(l){let O=await er(Z,e,S,R,P);M.push(...O)}else M.push({path:Z});let ee=(M.length>1||l)&&!m,we=50;for(let Z=0;Z<M.length;Z+=we){let O=M.slice(Z,Z+we),ie=await Promise.all(O.map(async J=>{let ne=J.path,_=ne.split("/").pop()||ne;if(R.length>0&&!l&&R.some(he=>Le(_,he,{stripQuotes:!0}))||S.length>0&&!l&&!S.some(he=>Le(_,he,{stripQuotes:!0})))return null;try{let he=e.fs.resolvePath(e.cwd,ne),le=!1;if(J.isFile===void 0?le=(await e.fs.stat(he)).isDirectory:le=!J.isFile,le)return l?null:{error:`grep: ${ne}: Is a directory
155
- `};let ce=await e.fs.readFile(he),me=Vt(ce,F,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:ee?ne:"",onlyMatching:h,beforeContext:b,afterContext:E,maxCount:w});return{file:ne,result:me}}catch{return{error:`grep: ${ne}: No such file or directory
156
- `}}}));for(let J of ie){if(J===null)continue;if("error"in J&&J.error){v+=J.error,J.error.includes("Is a directory")||($=!0);continue}if(!("file"in J)||!J.result)continue;let{file:ne,result:_}=J;if(_.matched){if(k=!0,g)return{stdout:"",stderr:"",exitCode:0};o?T+=`${ne}
157
- `:a||(T+=_.output)}else a?T+=`${ne}
158
- `:i&&!o&&(T+=_.output)}}let oe;return $?oe=2:a?oe=T.length>0?0:1:oe=k?0:1,g?{stdout:"",stderr:"",exitCode:oe}:{stdout:T,stderr:v,exitCode:oe}}};Jp={name:"fgrep",async execute(t,e){return ds.execute(["-F",...t],e)}},Yp={name:"egrep",async execute(t,e){return ds.execute(["-E",...t],e)}}});function ps(t,e){let n=t.toLowerCase();for(let r of e){let s=rr[r];if(s){for(let i of s.extensions)if(n.endsWith(i))return!0;for(let i of s.globs)if(i.includes("*")){let o=i.replace(/\./g,"\\.").replace(/\*/g,".*");if(new RegExp(`^${o}$`,"i").test(t))return!0}else if(n===i.toLowerCase())return!0}}return!1}function ta(){let t=[];for(let[e,n]of Object.entries(rr).sort()){let r=[];for(let s of n.extensions)r.push(`*${s}`);for(let s of n.globs)r.push(s);t.push(`${e}: ${r.join(", ")}`)}return`${t.join(`
151
+ `:"",matched:!0,matchCount:F.length}}var ta=C(()=>{"use strict"});function bn(t,e){let n;switch(e.mode){case"fixed":n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":n=t.replace(/\(\?P<([^>]+)>/g,"(?<$1>");break;default:n=Yp(t);break}e.wholeWord&&(n=`(?<![\\w])(?:${n})(?![\\w])`),e.lineRegexp&&(n=`^${n}$`);let r="g"+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.multilineDotall?"s":"");return new RegExp(n,r)}function ds(t){let e=t.replace(/\$\{0\}|\$0(?![0-9])/g,"$$&");return e=e.replace(/\$\{([^0-9}][^}]*)\}/g,"$$<$1>"),e=e.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,"$$<$1>"),e}function Yp(t){let e="",n=0;for(;n<t.length;){let r=t[n];if(r==="\\"&&n+1<t.length){let s=t[n+1];if(s==="|"||s==="("||s===")"){e+=s,n+=2;continue}else if(s==="{"||s==="}"){e+=`\\${s}`,n+=2;continue}}r==="+"||r==="?"||r==="|"||r==="("||r===")"||r==="{"||r==="}"?e+=`\\${r}`:e+=r,n++}return e}var na=C(()=>{"use strict"});var ps=C(()=>{"use strict";ta();na()});var rr={};_(rr,{egrepCommand:()=>rh,fgrepCommand:()=>nh,grepCommand:()=>hs});async function ra(t,e,n,r){let s=n.fs.resolvePath(n.cwd,t);try{if(!(await n.fs.stat(s)).isDirectory){let a=t.split("/").pop()||"";if(e){let l=e.replace(/^\//,"");Le(a,l,{stripQuotes:!0})&&r.push(t)}return}let o=await n.fs.readdir(s);for(let a of o){let l=t==="."?a:`${t}/${a}`,c=n.fs.resolvePath(n.cwd,l);if((await n.fs.stat(c)).isDirectory)await ra(l,e,n,r);else if(e){let f=e.replace(/^\//,"");Le(a,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function th(t,e){let n=[],r=t.lastIndexOf("/"),s,i;if(r===-1?(s=e.cwd,i=t):(s=t.slice(0,r)||"/",i=t.slice(r+1)),t.includes("**")){let a=[],l=t.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await ra(c,u,e,a),a.map(f=>({path:f}))}let o=e.fs.resolvePath(e.cwd,s);try{if(e.fs.readdirWithFileTypes){let a=await e.fs.readdirWithFileTypes(o);for(let l of a)if(Le(l.name,i,{stripQuotes:!0})){let c=r===-1?l.name:`${s}/${l.name}`;n.push({path:c,isFile:l.isFile})}}else{let a=await e.fs.readdir(o);for(let l of a)if(Le(l,i,{stripQuotes:!0})){let c=r===-1?l:`${s}/${l}`;n.push({path:c})}}}catch{}return n.sort((a,l)=>a.path.localeCompare(l.path))}async function nr(t,e,n=[],r=[],s=[],i){let o=e.fs.resolvePath(e.cwd,t),a=[];try{let l,c;if(i!==void 0)l=i,c=!i;else{let f=await e.fs.stat(o);l=f.isFile,c=f.isDirectory}if(l){let f=t.split("/").pop()||t;return r.length>0&&r.some(d=>Le(f,d,{stripQuotes:!0}))?[]:n.length>0&&!n.some(d=>Le(f,d,{stripQuotes:!0}))?[]:[{path:t,isFile:!0}]}if(!c)return[];let u=t.split("/").pop()||t;if(s.length>0&&s.some(f=>Le(u,f,{stripQuotes:!0})))return[];if(e.fs.readdirWithFileTypes){let f=await e.fs.readdirWithFileTypes(o);for(let d of f){if(d.name.startsWith("."))continue;let p=t==="."?d.name:`${t}/${d.name}`,h=await nr(p,e,n,r,s,d.isFile);a.push(...h)}}else{let f=await e.fs.readdir(o);for(let d of f){if(d.startsWith("."))continue;let p=t==="."?d:`${t}/${d}`,h=await nr(p,e,n,r,s);a.push(...h)}}}catch{}return a}var eh,hs,nh,rh,sr=C(()=>{"use strict";fs();j();ps();eh={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},hs={name:"grep",async execute(t,e){if(N(t))return k(eh);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,d=!1,p=!1,h=!1,m=!1,g=!1,b=0,w=0,E=0,S=[],R=[],F=[],z=null,W=[];for(let K=0;K<t.length;K++){let M=t[K];if(M.startsWith("-")&&M!=="-"){if(M==="-e"&&K+1<t.length){z=t[++K];continue}if(M.startsWith("--include=")){S.push(M.slice(10));continue}if(M.startsWith("--exclude=")){R.push(M.slice(10));continue}if(M.startsWith("--exclude-dir=")){F.push(M.slice(14));continue}if(M.startsWith("--max-count=")){b=parseInt(M.slice(12),10);continue}let oe=M.match(/^-m(\d+)$/);if(oe){b=parseInt(oe[1],10);continue}if(M==="-m"&&K+1<t.length){b=parseInt(t[++K],10);continue}let q=M.match(/^-([ABC])(\d+)$/);if(q){let O=parseInt(q[2],10);q[1]==="A"?E=O:q[1]==="B"?w=O:q[1]==="C"&&(w=O,E=O);continue}if((M==="-A"||M==="-B"||M==="-C")&&K+1<t.length){let O=parseInt(t[++K],10);M==="-A"?E=O:M==="-B"?w=O:(w=O,E=O);continue}let ne=M.startsWith("--")?[M]:M.slice(1).split("");for(let O of ne)if(O==="i"||O==="--ignore-case")n=!0;else if(O==="n"||O==="--line-number")r=!0;else if(O==="v"||O==="--invert-match")s=!0;else if(O==="c"||O==="--count")i=!0;else if(O==="l"||O==="--files-with-matches")o=!0;else if(O==="L"||O==="--files-without-match")a=!0;else if(O==="r"||O==="R"||O==="--recursive")l=!0;else if(O==="w"||O==="--word-regexp")c=!0;else if(O==="x"||O==="--line-regexp")u=!0;else if(O==="E"||O==="--extended-regexp")f=!0;else if(O==="P"||O==="--perl-regexp")d=!0;else if(O==="F"||O==="--fixed-strings")p=!0;else if(O==="o"||O==="--only-matching")h=!0;else if(O==="h"||O==="--no-filename")m=!0;else if(O==="q"||O==="--quiet"||O==="--silent")g=!0;else{if(O.startsWith("--"))return L("grep",O);if(O.length===1)return L("grep",`-${O}`)}}else z===null?z=M:W.push(M)}if(z===null)return{stdout:"",stderr:`grep: missing pattern
152
+ `,exitCode:2};let J=p?"fixed":f?"extended":d?"perl":"basic",P;try{P=bn(z,{mode:J,ignoreCase:n,wholeWord:c,lineRegexp:u})}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${z}
153
+ `,exitCode:2}}if(W.length===0&&e.stdin){let K=Zt(e.stdin,P,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:"",onlyMatching:h,beforeContext:w,afterContext:E,maxCount:b});return g?{stdout:"",stderr:"",exitCode:K.matched?0:1}:{stdout:K.output,stderr:"",exitCode:K.matched?0:1}}if(W.length===0)return{stdout:"",stderr:`grep: no input files
154
+ `,exitCode:2};let T="",$="",I=!1,v=!1,D=[];for(let K of W)if(K.includes("*")||K.includes("?")||K.includes("[")){let M=await th(K,e);if(l)for(let oe of M){let q=await nr(oe.path,e,S,R,F,oe.isFile);D.push(...q)}else D.push(...M)}else if(l){let M=await nr(K,e,S,R,F);D.push(...M)}else D.push({path:K});let ee=(D.length>1||l)&&!m,we=50;for(let K=0;K<D.length;K+=we){let M=D.slice(K,K+we),oe=await Promise.all(M.map(async q=>{let ne=q.path,O=ne.split("/").pop()||ne;if(R.length>0&&!l&&R.some(ae=>Le(O,ae,{stripQuotes:!0}))||S.length>0&&!l&&!S.some(ae=>Le(O,ae,{stripQuotes:!0})))return null;try{let ae=e.fs.resolvePath(e.cwd,ne),ce=!1;if(q.isFile===void 0?ce=(await e.fs.stat(ae)).isDirectory:ce=!q.isFile,ce)return l?null:{error:`grep: ${ne}: Is a directory
155
+ `};let ue=await e.fs.readFile(ae),me=Zt(ue,P,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:ee?ne:"",onlyMatching:h,beforeContext:w,afterContext:E,maxCount:b});return{file:ne,result:me}}catch{return{error:`grep: ${ne}: No such file or directory
156
+ `}}}));for(let q of oe){if(q===null)continue;if("error"in q&&q.error){$+=q.error,q.error.includes("Is a directory")||(v=!0);continue}if(!("file"in q)||!q.result)continue;let{file:ne,result:O}=q;if(O.matched){if(I=!0,g)return{stdout:"",stderr:"",exitCode:0};o?T+=`${ne}
157
+ `:a||(T+=O.output)}else a?T+=`${ne}
158
+ `:i&&!o&&(T+=O.output)}}let ie;return v?ie=2:a?ie=T.length>0?0:1:ie=I?0:1,g?{stdout:"",stderr:"",exitCode:ie}:{stdout:T,stderr:$,exitCode:ie}}};nh={name:"fgrep",async execute(t,e){return hs.execute(["-F",...t],e)}},rh={name:"egrep",async execute(t,e){return hs.execute(["-E",...t],e)}}});function ia(){let t=[];for(let[e,n]of Object.entries(sa).sort()){let r=[];for(let s of n.extensions)r.push(`*${s}`);for(let s of n.globs)r.push(s);t.push(`${e}: ${r.join(", ")}`)}return`${t.join(`
159
159
  `)}
160
- `}var rr,sr=C(()=>{"use strict";rr={js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}}});function na(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,filesWithMatches:!1,filesWithoutMatch:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],types:[],typesNot:[],hidden:!1,noIgnore:!1,maxDepth:1/0,followSymlinks:!1,searchZip:!1,searchBinary:!1}}var ra=C(()=>{"use strict"});function sa(t){return rr[t]?null:{stdout:"",stderr:`rg: unknown type: ${t}
161
- Use --type-list to see available types.
162
- `,exitCode:1}}function rh(t){t.hidden?t.searchBinary=!0:t.noIgnore?t.hidden=!0:t.noIgnore=!0}function sh(t,e,n){let r=t[e];for(let s of eh){if(r.startsWith(`--${s.long}=`)){let i=r.slice(`--${s.long}=`.length),o=ia(n,s,i);return o?{newIndex:e,error:o}:{newIndex:e}}if(s.short&&r===`-${s.short}`||r===`--${s.long}`){if(e+1>=t.length)return null;let i=t[e+1],o=ia(n,s,i);return o?{newIndex:e+1,error:o}:{newIndex:e+1}}}return null}function ia(t,e,n){if(e.validate){let s=e.validate(n);if(s)return s}let r=e.parse?e.parse(n):n;e.multi?t[e.target].push(r):t[e.target]=r}function ih(t,e){let n=t[e];if(n==="--sort"&&e+1<t.length){let r=t[e+1];if(r==="path"||r==="none")return{value:r,newIndex:e+1}}if(n.startsWith("--sort=")){let r=n.slice(7);if(r==="path"||r==="none")return{value:r,newIndex:e}}return null}function oh(t,e){let n=t[e],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:e}:(n==="-A"||n==="-B"||n==="-C")&&e+1<t.length?{flag:n[1],value:parseInt(t[e+1],10),newIndex:e+1}:null}function ah(t){let e=t.match(/^-m(\d+)$/);return e?parseInt(e[1],10):null}function oa(t){let e=na(),n=null,r=[],s=-1,i=-1,o=-1,a=!1;for(let l=0;l<t.length;l++){let c=t[l];if(c.startsWith("-")&&c!=="-"){let u=oh(t,l);if(u){let{flag:m,value:g,newIndex:w}=u;m==="A"?s=Math.max(s,g):m==="B"?i=Math.max(i,g):o=g,l=w;continue}let f=ah(c);if(f!==null){e.maxCount=f;continue}let d=sh(t,l,e);if(d){if(d.error)return{success:!1,error:d.error};l=d.newIndex;continue}let p=ih(t,l);if(p){e.sort=p.value,l=p.newIndex;continue}let h=c.startsWith("--")?[c]:c.slice(1).split("");for(let m of h){if(nh.has(m)){e.lineNumber=!0,a=!0;continue}if(m==="u"||m==="--unrestricted"){rh(e);continue}let g=th[m];if(g){g(e);continue}if(m.startsWith("--"))return{success:!1,error:D("rg",m)};if(m.length===1)return{success:!1,error:D("rg",`-${m}`)}}}else n===null?n=c:r.push(c)}return(s>=0||o>=0)&&(e.afterContext=Math.max(s>=0?s:0,o>=0?o:0)),(i>=0||o>=0)&&(e.beforeContext=Math.max(i>=0?i:0,o>=0?o:0)),n!==null&&e.patterns.push(n),(e.column||e.vimgrep)&&(a=!0),{success:!0,options:e,paths:r,explicitLineNumbers:a}}var eh,th,nh,aa=C(()=>{"use strict";j();sr();ra();eh=[{short:"g",long:"glob",target:"globs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:sa},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:sa},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{long:"max-depth",target:"maxDepth",parse:parseInt},{long:"context-separator",target:"contextSeparator"}],th={i:t=>{t.ignoreCase=!0,t.caseSensitive=!1,t.smartCase=!1},"--ignore-case":t=>{t.ignoreCase=!0,t.caseSensitive=!1,t.smartCase=!1},s:t=>{t.caseSensitive=!0,t.ignoreCase=!1,t.smartCase=!1},"--case-sensitive":t=>{t.caseSensitive=!0,t.ignoreCase=!1,t.smartCase=!1},S:t=>{t.smartCase=!0,t.ignoreCase=!1,t.caseSensitive=!1},"--smart-case":t=>{t.smartCase=!0,t.ignoreCase=!1,t.caseSensitive=!1},F:t=>{t.fixedStrings=!0},"--fixed-strings":t=>{t.fixedStrings=!0},w:t=>{t.wordRegexp=!0},"--word-regexp":t=>{t.wordRegexp=!0},x:t=>{t.lineRegexp=!0},"--line-regexp":t=>{t.lineRegexp=!0},v:t=>{t.invertMatch=!0},"--invert-match":t=>{t.invertMatch=!0},U:t=>{t.multiline=!0},"--multiline":t=>{t.multiline=!0},c:t=>{t.count=!0},"--count":t=>{t.count=!0},"--count-matches":t=>{t.countMatches=!0},l:t=>{t.filesWithMatches=!0},"--files-with-matches":t=>{t.filesWithMatches=!0},"--files-without-match":t=>{t.filesWithoutMatch=!0},o:t=>{t.onlyMatching=!0},"--only-matching":t=>{t.onlyMatching=!0},q:t=>{t.quiet=!0},"--quiet":t=>{t.quiet=!0},N:t=>{t.lineNumber=!1},"--no-line-number":t=>{t.lineNumber=!1},I:t=>{t.noFilename=!0},"--no-filename":t=>{t.noFilename=!0},0:t=>{t.nullSeparator=!0},"--null":t=>{t.nullSeparator=!0},b:t=>{t.byteOffset=!0},"--byte-offset":t=>{t.byteOffset=!0},"--column":t=>{t.column=!0,t.lineNumber=!0},"--vimgrep":t=>{t.vimgrep=!0,t.column=!0,t.lineNumber=!0},"--json":t=>{t.json=!0},"--hidden":t=>{t.hidden=!0},"--no-ignore":t=>{t.noIgnore=!0},L:t=>{t.followSymlinks=!0},"--follow":t=>{t.followSymlinks=!0},z:t=>{t.searchZip=!0},"--search-zip":t=>{t.searchZip=!0},a:t=>{t.searchBinary=!0},"--text":t=>{t.searchBinary=!0},"--heading":t=>{t.heading=!0},"--passthru":t=>{t.passthru=!0},"--include-zero":t=>{t.includeZero=!0}},nh=new Set(["n","--line-number"])});async function la(t,e){let n=new bn(t,e);return await n.load(e),n}var hs,bn,ca=C(()=>{"use strict";hs=class{patterns=[];basePath;constructor(e="/"){this.basePath=e}parse(e){let n=e.split(`
163
- `);for(let r of n){let s=r.replace(/\s+$/,"");if(!s||s.startsWith("#"))continue;let i=!1;s.startsWith("!")&&(i=!0,s=s.slice(1));let o=!1;s.endsWith("/")&&(o=!0,s=s.slice(0,-1));let a=!1;s.startsWith("/")?(a=!0,s=s.slice(1)):s.includes("/")&&!s.startsWith("**/")&&(a=!0);let l=this.patternToRegex(s,a);this.patterns.push({pattern:r,regex:l,negated:i,directoryOnly:o,rooted:a})}}patternToRegex(e,n){let r="";n?r="^":r="(?:^|/)";let s=0;for(;s<e.length;){let i=e[s];if(i==="*")e[s+1]==="*"?e[s+2]==="/"?(r+="(?:.*/)?",s+=3):(s+2>=e.length,r+=".*",s+=2):(r+="[^/]*",s++);else if(i==="?")r+="[^/]",s++;else if(i==="["){let o=s+1;for(o<e.length&&e[o]==="!"&&o++,o<e.length&&e[o]==="]"&&o++;o<e.length&&e[o]!=="]";)o++;if(o<e.length){let a=e.slice(s,o+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),r+=a,s=o+1}else r+="\\[",s++}else i==="/"?(r+="/",s++):(r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s++)}return r+="(?:/.*)?$",new RegExp(r)}matches(e,n){let r=e.replace(/^\.\//,"");r=r.replace(/^\//,"");let s=!1;for(let i of this.patterns)i.directoryOnly&&!n||i.regex.test(r)&&(s=!i.negated);return s}getBasePath(){return this.basePath}},bn=class{parsers=[];fs;rootPath;constructor(e,n){this.fs=e,this.rootPath=n}async load(e){let n=[],r=e;for(;r.startsWith(this.rootPath)||r===this.rootPath;){n.unshift(r);let s=this.fs.resolvePath(r,"..");if(s===r)break;r=s}for(let s of n)for(let i of[".gitignore",".ignore"]){let o=this.fs.resolvePath(s,i);try{let a=await this.fs.readFile(o),l=new hs(s);l.parse(a),this.parsers.push(l)}catch{}}}matches(e,n){for(let r of this.parsers){let s=r.getBasePath();if(!e.startsWith(s))continue;let i=e.slice(s.length).replace(/^\//,"");if(r.matches(i,n))return!0}return!1}static isCommonIgnored(e){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv","dist","build",".next",".nuxt","target",".cargo"]).has(e)}}});import{gunzipSync as lh}from"node:zlib";function ch(t){return t.length>=2&&t[0]===31&&t[1]===139}async function ua(t){let{ctx:e,options:n,paths:r,explicitLineNumbers:s}=t,i=[...n.patterns];for(let h of n.patternFiles)try{let m=e.fs.resolvePath(e.cwd,h),w=(await e.fs.readFile(m)).split(`
164
- `).filter(b=>b.length>0);i.push(...w)}catch{return{stdout:"",stderr:`rg: ${h}: No such file or directory
165
- `,exitCode:2}}if(i.length===0)return{stdout:"",stderr:`rg: no pattern given
166
- `,exitCode:2};let o=r.length===0?["."]:r,a=uh(n,i),l;try{l=fh(i,n,a)}catch{return{stdout:"",stderr:`rg: invalid regex: ${i.join(", ")}
167
- `,exitCode:2}}let c=null;n.noIgnore||(c=await la(e.fs,e.cwd));let{files:u,singleExplicitFile:f}=await dh(e,o,n,c);if(u.length===0)return{stdout:"",stderr:"",exitCode:1};let d=!n.noFilename&&(!f||u.length>1),p=n.lineNumber;return s||(f&&u.length===1&&(p=!1),n.onlyMatching&&(p=!1)),hh(e,u,l,n,d,p)}function uh(t,e){return t.caseSensitive?!1:t.ignoreCase?!0:t.smartCase?!e.some(n=>/[A-Z]/.test(n)):!1}function fh(t,e,n){let r;return t.length===1?r=t[0]:r=t.map(s=>e.fixedStrings?s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${s})`).join("|"),wn(r,{mode:e.fixedStrings&&t.length===1?"fixed":"perl",ignoreCase:n,wholeWord:e.wordRegexp,lineRegexp:e.lineRegexp,multiline:e.multiline})}async function dh(t,e,n,r){let s=[],i=0,o=0;for(let l of e){let c=t.fs.resolvePath(t.cwd,l);try{let u=await t.fs.stat(c);u.isFile?(i++,da(l,n,r,c)&&s.push(l)):u.isDirectory&&(o++,await fa(t,l,c,0,n,r,s))}catch{}}return{files:n.sort==="path"?s.sort():s,singleExplicitFile:i===1&&o===0}}async function fa(t,e,n,r,s,i,o){if(!(r>=s.maxDepth))try{let a=t.fs.readdirWithFileTypes?await t.fs.readdirWithFileTypes(n):(await t.fs.readdir(n)).map(l=>({name:l,isFile:void 0}));for(let l of a){let c=l.name;if(!s.hidden&&c.startsWith(".")||!s.noIgnore&&bn.isCommonIgnored(c))continue;let u=e==="."?c:`${e}/${c}`,f=t.fs.resolvePath(n,c),d,p,h=!1;if(l.isFile!==void 0&&"isDirectory"in l){let g=l;if(h=g.isSymbolicLink===!0,h&&!s.followSymlinks)continue;if(h&&s.followSymlinks)try{let w=await t.fs.stat(f);d=w.isFile,p=w.isDirectory}catch{continue}else d=g.isFile,p=g.isDirectory}else try{let g=t.fs.lstat?await t.fs.lstat(f):await t.fs.stat(f);if(h=g.isSymbolicLink===!0,h&&!s.followSymlinks)continue;let w=h&&s.followSymlinks?await t.fs.stat(f):g;d=w.isFile,p=w.isDirectory}catch{continue}i?.matches(f,p)||(p?await fa(t,u,f,r+1,s,i,o):d&&da(u,s,i,f)&&o.push(u))}}catch{}}function da(t,e,n,r){let s=t.split("/").pop()||t;if(n?.matches(r,!1)||e.types.length>0&&!ps(s,e.types)||e.typesNot.length>0&&ps(s,e.typesNot))return!1;if(e.globs.length>0){let i=e.globs.filter(a=>!a.startsWith("!")),o=e.globs.filter(a=>a.startsWith("!")).map(a=>a.slice(1));if(i.length>0){let a=!1;for(let l of i)if(En(s,l)||En(t,l)){a=!0;break}if(!a)return!1}for(let a of o)if(a.startsWith("/")){let l=a.slice(1);if(En(t,l))return!1}else if(En(s,a)||En(t,a))return!1}return!0}function En(t,e){let n="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="*")e[r+1]==="*"?(n+=".*",r++):n+="[^/]*";else if(s==="?")n+="[^/]";else if(s==="["){let i=r+1;for(i<e.length&&e[i]==="!"&&i++,i<e.length&&e[i]==="]"&&i++;i<e.length&&e[i]!=="]";)i++;if(i<e.length){let o=e.slice(r,i+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),n+=o,r=i}else n+="\\["}else n+=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return n+="$",new RegExp(n).test(t)}async function ph(t,e,n,r){try{if(r.searchZip&&n.endsWith(".gz")){let o=await t.fs.readFileBuffer(e);if(ch(o))try{let a=lh(o),l=new TextDecoder().decode(a),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await t.fs.readFile(e),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function hh(t,e,n,r,s,i){let o="",a=!1,l=[],c=0,u=0,f=0,d=50;e:for(let m=0;m<e.length;m+=d){let g=e.slice(m,m+d),w=await Promise.all(g.map(async b=>{let E=t.fs.resolvePath(t.cwd,b),S=await ph(t,E,b,r);if(!S)return null;let{content:R,isBinary:P}=S;if(f+=R.length,P&&!r.searchBinary)return null;let z=s&&!r.heading?b:"",W=Vt(R,n,{invertMatch:r.invertMatch,showLineNumbers:i,countOnly:r.count,countMatches:r.countMatches,filename:z,onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace,passthru:r.passthru,multiline:r.multiline});return r.json&&W.matched?{file:b,result:W,content:R,isBinary:!1}:{file:b,result:W}}));for(let b of w){if(!b)continue;let{file:E,result:S}=b;if(S.matched){if(a=!0,u++,c+=S.matchCount,r.quiet&&!r.json)break e;if(r.json&&!r.quiet){let R=b.content||"";l.push(JSON.stringify({type:"begin",data:{path:{text:E}}}));let P=R.split(`
168
- `);n.lastIndex=0;let z=0;for(let W=0;W<P.length;W++){let X=P[W];n.lastIndex=0;let F=[];for(let T=n.exec(X);T!==null;T=n.exec(X)){let v={match:{text:T[0]},start:T.index,end:T.index+T[0].length};r.replace!==null&&(v.replacement={text:r.replace}),F.push(v),T[0].length===0&&n.lastIndex++}if(F.length>0){let T={type:"match",data:{path:{text:E},lines:{text:`${X}
169
- `},line_number:W+1,absolute_offset:z,submatches:F}};l.push(JSON.stringify(T))}z+=X.length+1}l.push(JSON.stringify({type:"end",data:{path:{text:E},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:R.length,bytes_printed:0,matched_lines:S.matchCount,matches:S.matchCount}}}))}else if(r.filesWithMatches){let R=r.nullSeparator?"\0":`
170
- `;o+=`${E}${R}`}else r.filesWithoutMatch||(r.heading&&s&&(o+=`${E}
160
+ `}var sa,En,ms=C(()=>{"use strict";sa={js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}},En=class{types;constructor(){this.types=new Map(Object.entries(sa).map(([e,n])=>[e,{extensions:[...n.extensions],globs:[...n.globs]}]))}addType(e){let n=e.indexOf(":");if(n===-1)return;let r=e.slice(0,n),s=e.slice(n+1);if(s.startsWith("include:")){let i=s.slice(8),o=this.types.get(i);if(o){let a=this.types.get(r)||{extensions:[],globs:[]};a.extensions.push(...o.extensions),a.globs.push(...o.globs),this.types.set(r,a)}}else{let i=this.types.get(r)||{extensions:[],globs:[]};if(s.startsWith("*.")&&!s.slice(2).includes("*")){let o=s.slice(1);i.extensions.includes(o)||i.extensions.push(o)}else i.globs.includes(s)||i.globs.push(s);this.types.set(r,i)}}clearType(e){let n=this.types.get(e);n&&(n.extensions=[],n.globs=[])}getType(e){return this.types.get(e)}getAllTypes(){return this.types}matchesType(e,n){let r=e.toLowerCase();for(let s of n){if(s==="all"){if(this.matchesAnyType(e))return!0;continue}let i=this.types.get(s);if(i){for(let o of i.extensions)if(r.endsWith(o))return!0;for(let o of i.globs)if(o.includes("*")){let a=o.replace(/\./g,"\\.").replace(/\*/g,".*");if(new RegExp(`^${a}$`,"i").test(e))return!0}else if(r===o.toLowerCase())return!0}}return!1}matchesAnyType(e){let n=e.toLowerCase();for(let r of this.types.values()){for(let s of r.extensions)if(n.endsWith(s))return!0;for(let s of r.globs)if(s.includes("*")){let i=s.replace(/\./g,"\\.").replace(/\*/g,".*");if(new RegExp(`^${i}$`,"i").test(e))return!0}else if(n===s.toLowerCase())return!0}return!1}}});function oa(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:1/0,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var aa=C(()=>{"use strict"});function sh(t){let e=t.match(/^(\d+)([KMG])?$/i);if(!e)return 0;let n=parseInt(e[1],10);switch((e[2]||"").toUpperCase()){case"K":return n*1024;case"M":return n*1024*1024;case"G":return n*1024*1024*1024;default:return n}}function ih(t){return/^\d+[KMG]?$/i.test(t)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${t}
161
+ `,exitCode:1}}function la(t){return null}function lh(t){t.hidden?t.searchBinary=!0:t.noIgnore?t.hidden=!0:t.noIgnore=!0}function ch(t,e,n){let r=t[e];for(let s of ca){if(r.startsWith(`--${s.long}=`)){let i=r.slice(`--${s.long}=`.length),o=ir(n,s,i);return o?{newIndex:e,error:o}:{newIndex:e}}if(s.short&&r.startsWith(`-${s.short}`)&&r.length>2){let i=r.slice(2),o=ir(n,s,i);return o?{newIndex:e,error:o}:{newIndex:e}}if(s.short&&r===`-${s.short}`||r===`--${s.long}`){if(e+1>=t.length)return null;let i=t[e+1],o=ir(n,s,i);return o?{newIndex:e+1,error:o}:{newIndex:e+1}}}return null}function uh(t){return ca.find(e=>e.short===t)}function ir(t,e,n){if(e.validate){let s=e.validate(n);if(s)return s}let r=e.parse?e.parse(n):n;e.multi?t[e.target].push(r):t[e.target]=r}function fh(t,e){let n=t[e];if(n==="--sort"&&e+1<t.length){let r=t[e+1];if(r==="path"||r==="none")return{value:r,newIndex:e+1}}if(n.startsWith("--sort=")){let r=n.slice(7);if(r==="path"||r==="none")return{value:r,newIndex:e}}return null}function dh(t,e){let n=t[e],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:e}:(n==="-A"||n==="-B"||n==="-C")&&e+1<t.length?{flag:n[1],value:parseInt(t[e+1],10),newIndex:e+1}:null}function ph(t){let e=t.match(/^-m(\d+)$/);return e?parseInt(e[1],10):null}function ua(t){let e=oa(),n=null,r=[],s=-1,i=-1,o=-1,a=!1;for(let l=0;l<t.length;l++){let c=t[l];if(c.startsWith("-")&&c!=="-"){let u=dh(t,l);if(u){let{flag:g,value:b,newIndex:w}=u;g==="A"?s=Math.max(s,b):g==="B"?i=Math.max(i,b):o=b,l=w;continue}let f=ph(c);if(f!==null){e.maxCount=f;continue}let d=ch(t,l,e);if(d){if(d.error)return{success:!1,error:d.error};l=d.newIndex;continue}let p=fh(t,l);if(p){e.sort=p.value,l=p.newIndex;continue}let h=c.startsWith("--")?[c]:c.slice(1).split(""),m=!1;for(let g of h){if(ah.has(g)){e.lineNumber=!0,a=!0;continue}if(g==="u"||g==="--unrestricted"){lh(e);continue}if(g==="P"||g==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
162
+ `,exitCode:1}};if(g.length===1){let w=uh(g);if(w){if(l+1>=t.length)return{success:!1,error:L("rg",`-${g}`)};let E=ir(e,w,t[l+1]);if(E)return{success:!1,error:E};l++,m=!0;continue}}let b=oh[g];if(b){b(e);continue}if(g.startsWith("--"))return{success:!1,error:L("rg",g)};if(g.length===1)return{success:!1,error:L("rg",`-${g}`)}}}else n===null&&e.patterns.length===0&&e.patternFiles.length===0?n=c:r.push(c)}return(s>=0||o>=0)&&(e.afterContext=Math.max(s>=0?s:0,o>=0?o:0)),(i>=0||o>=0)&&(e.beforeContext=Math.max(i>=0?i:0,o>=0?o:0)),n!==null&&e.patterns.push(n),(e.column||e.vimgrep)&&(a=!0),{success:!0,options:e,paths:r,explicitLineNumbers:a}}var ca,oh,ah,fa=C(()=>{"use strict";j();aa();ca=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:la},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:la},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:parseInt},{long:"max-filesize",target:"maxFilesize",parse:sh,validate:ih},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",target:"maxDepth",parse:()=>1/0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],oh={i:t=>{t.ignoreCase=!0,t.caseSensitive=!1,t.smartCase=!1},"--ignore-case":t=>{t.ignoreCase=!0,t.caseSensitive=!1,t.smartCase=!1},s:t=>{t.caseSensitive=!0,t.ignoreCase=!1,t.smartCase=!1},"--case-sensitive":t=>{t.caseSensitive=!0,t.ignoreCase=!1,t.smartCase=!1},S:t=>{t.smartCase=!0,t.ignoreCase=!1,t.caseSensitive=!1},"--smart-case":t=>{t.smartCase=!0,t.ignoreCase=!1,t.caseSensitive=!1},F:t=>{t.fixedStrings=!0},"--fixed-strings":t=>{t.fixedStrings=!0},w:t=>{t.wordRegexp=!0},"--word-regexp":t=>{t.wordRegexp=!0},x:t=>{t.lineRegexp=!0},"--line-regexp":t=>{t.lineRegexp=!0},v:t=>{t.invertMatch=!0},"--invert-match":t=>{t.invertMatch=!0},U:t=>{t.multiline=!0},"--multiline":t=>{t.multiline=!0},"--multiline-dotall":t=>{t.multilineDotall=!0,t.multiline=!0},c:t=>{t.count=!0},"--count":t=>{t.count=!0},"--count-matches":t=>{t.countMatches=!0},l:t=>{t.filesWithMatches=!0},"--files":t=>{t.files=!0},"--files-with-matches":t=>{t.filesWithMatches=!0},"--files-without-match":t=>{t.filesWithoutMatch=!0},"--stats":t=>{t.stats=!0},o:t=>{t.onlyMatching=!0},"--only-matching":t=>{t.onlyMatching=!0},q:t=>{t.quiet=!0},"--quiet":t=>{t.quiet=!0},N:t=>{t.lineNumber=!1},"--no-line-number":t=>{t.lineNumber=!1},H:t=>{t.withFilename=!0},"--with-filename":t=>{t.withFilename=!0},I:t=>{t.noFilename=!0},"--no-filename":t=>{t.noFilename=!0},0:t=>{t.nullSeparator=!0},"--null":t=>{t.nullSeparator=!0},b:t=>{t.byteOffset=!0},"--byte-offset":t=>{t.byteOffset=!0},"--column":t=>{t.column=!0,t.lineNumber=!0},"--no-column":t=>{t.column=!1},"--vimgrep":t=>{t.vimgrep=!0,t.column=!0,t.lineNumber=!0},"--json":t=>{t.json=!0},"--hidden":t=>{t.hidden=!0},"--no-ignore":t=>{t.noIgnore=!0},"--no-ignore-dot":t=>{t.noIgnoreDot=!0},"--no-ignore-vcs":t=>{t.noIgnoreVcs=!0},L:t=>{t.followSymlinks=!0},"--follow":t=>{t.followSymlinks=!0},z:t=>{t.searchZip=!0},"--search-zip":t=>{t.searchZip=!0},a:t=>{t.searchBinary=!0},"--text":t=>{t.searchBinary=!0},"--heading":t=>{t.heading=!0},"--passthru":t=>{t.passthru=!0},"--include-zero":t=>{t.includeZero=!0},"--glob-case-insensitive":t=>{t.globCaseInsensitive=!0}},ah=new Set(["n","--line-number"])});async function gs(t,e,n=!1,r=!1,s=[]){let i=new Cn(t,e,n,r);await i.load(e);for(let o of s)try{let a=t.resolvePath(e,o),l=await t.readFile(a);i.addPatternsFromContent(l,e)}catch{}return i}var Sn,Cn,da=C(()=>{"use strict";Sn=class{patterns=[];basePath;constructor(e="/"){this.basePath=e}parse(e){let n=e.split(`
163
+ `);for(let r of n){let s=r.replace(/\s+$/,"");if(!s||s.startsWith("#"))continue;let i=!1;s.startsWith("!")&&(i=!0,s=s.slice(1));let o=!1;s.endsWith("/")&&(o=!0,s=s.slice(0,-1));let a=!1;s.startsWith("/")?(a=!0,s=s.slice(1)):s.includes("/")&&!s.startsWith("**/")&&(a=!0);let l=this.patternToRegex(s,a);this.patterns.push({pattern:r,regex:l,negated:i,directoryOnly:o,rooted:a})}}patternToRegex(e,n){let r="";n?r="^":r="(?:^|/)";let s=0;for(;s<e.length;){let i=e[s];if(i==="*")e[s+1]==="*"?e[s+2]==="/"?(r+="(?:.*/)?",s+=3):(s+2>=e.length,r+=".*",s+=2):(r+="[^/]*",s++);else if(i==="?")r+="[^/]",s++;else if(i==="["){let o=s+1;for(o<e.length&&e[o]==="!"&&o++,o<e.length&&e[o]==="]"&&o++;o<e.length&&e[o]!=="]";)o++;if(o<e.length){let a=e.slice(s,o+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),r+=a,s=o+1}else r+="\\[",s++}else i==="/"?(r+="/",s++):(r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s++)}return r+="(?:/.*)?$",new RegExp(r)}matches(e,n){let r=e.replace(/^\.\//,"");r=r.replace(/^\//,"");let s=!1;for(let i of this.patterns)i.directoryOnly&&!n||i.regex.test(r)&&(s=!i.negated);return s}isWhitelisted(e,n){let r=e.replace(/^\.\//,"");r=r.replace(/^\//,"");for(let s of this.patterns)if(!(s.directoryOnly&&!n)&&s.negated&&s.regex.test(r))return!0;return!1}getBasePath(){return this.basePath}},Cn=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(e,n,r=!1,s=!1){this.fs=e,this.skipDotIgnore=r,this.skipVcsIgnore=s}async load(e){let n=[],r=e;for(;;){n.unshift(r);let i=this.fs.resolvePath(r,"..");if(i===r)break;r=i}let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let i of n){this.loadedDirs.add(i);for(let o of s){let a=this.fs.resolvePath(i,o);try{let l=await this.fs.readFile(a),c=new Sn(i);c.parse(l),this.parsers.push(c)}catch{}}}}async loadForDirectory(e){if(this.loadedDirs.has(e))return;this.loadedDirs.add(e);let n=[];this.skipVcsIgnore||n.push(".gitignore"),this.skipDotIgnore||n.push(".rgignore",".ignore");for(let r of n){let s=this.fs.resolvePath(e,r);try{let i=await this.fs.readFile(s),o=new Sn(e);o.parse(i),this.parsers.push(o)}catch{}}}addPatternsFromContent(e,n){let r=new Sn(n);r.parse(e),this.parsers.push(r)}matches(e,n){for(let r of this.parsers){let s=r.getBasePath();if(!e.startsWith(s))continue;let i=e.slice(s.length).replace(/^\//,"");if(r.matches(i,n))return!0}return!1}isWhitelisted(e,n){for(let r of this.parsers){let s=r.getBasePath();if(!e.startsWith(s))continue;let i=e.slice(s.length).replace(/^\//,"");if(r.isWhitelisted(i,n))return!0}return!1}static isCommonIgnored(e){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(e)}}});import{gunzipSync as hh}from"node:zlib";function mh(t){return t.length>=2&&t[0]===31&&t[1]===139}function gh(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];r==="["&&!e?e=!0:r==="]"&&e&&(e=!1)}return e?`rg: glob '${t}' has an unclosed character class`:null}async function pa(t){let{ctx:e,options:n,paths:r,explicitLineNumbers:s}=t;for(let m of n.globs){let g=m.startsWith("!")?m.slice(1):m,b=gh(g);if(b)return{stdout:"",stderr:`${b}
164
+ `,exitCode:1}}if(n.files){let m=[...n.patterns,...r];return wh(e,m,n)}let i=[...n.patterns];for(let m of n.patternFiles)try{let g;if(m==="-")g=e.stdin;else{let w=e.fs.resolvePath(e.cwd,m);g=await e.fs.readFile(w)}let b=g.split(`
165
+ `).filter(w=>w.length>0);i.push(...b)}catch{return{stdout:"",stderr:`rg: ${m}: No such file or directory
166
+ `,exitCode:2}}if(i.length===0)return n.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
167
+ `,exitCode:2};let o=r.length===0?["."]:r,a=yh(n,i),l;try{l=xh(i,n,a)}catch{return{stdout:"",stderr:`rg: invalid regex: ${i.join(", ")}
168
+ `,exitCode:2}}let c=null;n.noIgnore||(c=await gs(e.fs,e.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let u=new En;for(let m of n.typeClear)u.clearType(m);for(let m of n.typeAdd)u.addType(m);let{files:f,singleExplicitFile:d}=await ha(e,o,n,c,u);if(f.length===0)return{stdout:"",stderr:"",exitCode:1};let p=!n.noFilename&&(n.withFilename||!d||f.length>1),h=n.lineNumber;return s||(d&&f.length===1&&(h=!1),n.onlyMatching&&(h=!1)),Sh(e,f,l,n,p,h)}function yh(t,e){return t.caseSensitive?!1:t.ignoreCase?!0:t.smartCase?!e.some(n=>/[A-Z]/.test(n)):!1}function xh(t,e,n){let r;return t.length===1?r=t[0]:r=t.map(s=>e.fixedStrings?s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${s})`).join("|"),bn(r,{mode:e.fixedStrings&&t.length===1?"fixed":"perl",ignoreCase:n,wholeWord:e.wordRegexp,lineRegexp:e.lineRegexp,multiline:e.multiline,multilineDotall:e.multilineDotall})}async function ha(t,e,n,r,s){let i=[],o=0,a=0;for(let c of e){let u=t.fs.resolvePath(t.cwd,c);try{let f=await t.fs.stat(u);if(f.isFile){if(o++,n.maxFilesize>0&&f.size>n.maxFilesize)continue;ga(c,n,r,u,s)&&i.push(c)}else f.isDirectory&&(a++,await ma(t,c,u,0,n,r,s,i))}catch{}}return{files:n.sort==="path"?i.sort():i,singleExplicitFile:o===1&&a===0}}async function ma(t,e,n,r,s,i,o,a){if(!(r>=s.maxDepth)){i&&await i.loadForDirectory(n);try{let l=t.fs.readdirWithFileTypes?await t.fs.readdirWithFileTypes(n):(await t.fs.readdir(n)).map(c=>({name:c,isFile:void 0}));for(let c of l){let u=c.name;if(!s.noIgnore&&Cn.isCommonIgnored(u))continue;let f=u.startsWith("."),d=e==="."?u:e==="./"?`./${u}`:e.endsWith("/")?`${e}${u}`:`${e}/${u}`,p=t.fs.resolvePath(n,u),h,m,g=!1;if(c.isFile!==void 0&&"isDirectory"in c){let E=c;if(g=E.isSymbolicLink===!0,g&&!s.followSymlinks)continue;if(g&&s.followSymlinks)try{let S=await t.fs.stat(p);h=S.isFile,m=S.isDirectory}catch{continue}else h=E.isFile,m=E.isDirectory}else try{let E=t.fs.lstat?await t.fs.lstat(p):await t.fs.stat(p);if(g=E.isSymbolicLink===!0,g&&!s.followSymlinks)continue;let S=g&&s.followSymlinks?await t.fs.stat(p):E;h=S.isFile,m=S.isDirectory}catch{continue}if(!i?.matches(p,m)&&!(f&&!s.hidden&&!i?.isWhitelisted(p,m))){if(m)await ma(t,d,p,r+1,s,i,o,a);else if(h){if(s.maxFilesize>0)try{if((await t.fs.stat(p)).size>s.maxFilesize)continue}catch{continue}ga(d,s,i,p,o)&&a.push(d)}}}}catch{}}}function ga(t,e,n,r,s){let i=t.split("/").pop()||t;if(n?.matches(r,!1)||e.types.length>0&&!s.matchesType(i,e.types)||e.typesNot.length>0&&s.matchesType(i,e.typesNot))return!1;if(e.globs.length>0){let o=e.globCaseInsensitive,a=e.globs.filter(c=>!c.startsWith("!")),l=e.globs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(a.length>0){let c=!1;for(let u of a)if(it(i,u,o)||it(t,u,o)){c=!0;break}if(!c)return!1}for(let c of l)if(c.startsWith("/")){let u=c.slice(1);if(it(t,u,o))return!1}else if(it(i,c,o)||it(t,c,o))return!1}if(e.iglobs.length>0){let o=e.iglobs.filter(l=>!l.startsWith("!")),a=e.iglobs.filter(l=>l.startsWith("!")).map(l=>l.slice(1));if(o.length>0){let l=!1;for(let c of o)if(it(i,c,!0)||it(t,c,!0)){l=!0;break}if(!l)return!1}for(let l of a)if(l.startsWith("/")){let c=l.slice(1);if(it(t,c,!0))return!1}else if(it(i,l,!0)||it(t,l,!0))return!1}return!0}function it(t,e,n=!1){let r="^";for(let s=0;s<e.length;s++){let i=e[s];if(i==="*")e[s+1]==="*"?(r+=".*",s++):r+="[^/]*";else if(i==="?")r+="[^/]";else if(i==="["){let o=s+1;for(o<e.length&&e[o]==="!"&&o++,o<e.length&&e[o]==="]"&&o++;o<e.length&&e[o]!=="]";)o++;if(o<e.length){let a=e.slice(s,o+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),r+=a,s=o}else r+="\\["}else r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return r+="$",new RegExp(r,n?"i":"").test(t)}async function wh(t,e,n){let r=null;n.noIgnore||(r=await gs(t.fs,t.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let s=new En;for(let c of n.typeClear)s.clearType(c);for(let c of n.typeAdd)s.addType(c);let i=e.length===0?["."]:e,{files:o}=await ha(t,i,n,r,s);if(o.length===0)return{stdout:"",stderr:"",exitCode:1};if(n.quiet)return{stdout:"",stderr:"",exitCode:0};let a=n.nullSeparator?"\0":`
169
+ `;return{stdout:o.map(c=>c+a).join(""),stderr:"",exitCode:0}}function bh(t,e){if(e.length===0)return!0;for(let n of e)if(it(t,n,!1))return!0;return!1}async function Eh(t,e,n,r){try{if(r.preprocessor&&t.exec){let o=n.split("/").pop()||n;if(bh(o,r.preprocessorGlobs)){let a=await t.exec(`${r.preprocessor} "${e}"`,{cwd:t.cwd});if(a.exitCode===0&&a.stdout){let l=a.stdout.slice(0,8192);return{content:a.stdout,isBinary:l.includes("\0")}}}}if(r.searchZip&&n.endsWith(".gz")){let o=await t.fs.readFileBuffer(e);if(mh(o))try{let a=hh(o),l=new TextDecoder().decode(a),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await t.fs.readFile(e),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function Sh(t,e,n,r,s,i){let o="",a=!1,l=[],c=0,u=0,f=0,d=50;e:for(let m=0;m<e.length;m+=d){let g=e.slice(m,m+d),b=await Promise.all(g.map(async w=>{let E=t.fs.resolvePath(t.cwd,w),S=await Eh(t,E,w,r);if(!S)return null;let{content:R,isBinary:F}=S;if(f+=R.length,F&&!r.searchBinary)return null;let z=s&&!r.heading?w:"",W=Zt(R,n,{invertMatch:r.invertMatch,showLineNumbers:i,countOnly:r.count,countMatches:r.countMatches,filename:z,onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace!==null?ds(r.replace):null,passthru:r.passthru,multiline:r.multiline});return r.json&&W.matched?{file:w,result:W,content:R,isBinary:!1}:{file:w,result:W}}));for(let w of b){if(!w)continue;let{file:E,result:S}=w;if(S.matched){if(a=!0,u++,c+=S.matchCount,r.quiet&&!r.json)break e;if(r.json&&!r.quiet){let R=w.content||"";l.push(JSON.stringify({type:"begin",data:{path:{text:E}}}));let F=R.split(`
170
+ `);n.lastIndex=0;let z=0;for(let W=0;W<F.length;W++){let J=F[W];n.lastIndex=0;let P=[];for(let T=n.exec(J);T!==null;T=n.exec(J)){let $={match:{text:T[0]},start:T.index,end:T.index+T[0].length};r.replace!==null&&($.replacement={text:r.replace}),P.push($),T[0].length===0&&n.lastIndex++}if(P.length>0){let T={type:"match",data:{path:{text:E},lines:{text:`${J}
171
+ `},line_number:W+1,absolute_offset:z,submatches:P}};l.push(JSON.stringify(T))}z+=J.length+1}l.push(JSON.stringify({type:"end",data:{path:{text:E},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:R.length,bytes_printed:0,matched_lines:S.matchCount,matches:S.matchCount}}}))}else if(r.filesWithMatches){let R=r.nullSeparator?"\0":`
172
+ `;o+=`${E}${R}`}else r.filesWithoutMatch||(r.heading&&!r.noFilename&&(o+=`${E}
171
173
  `),o+=S.output)}else if(r.filesWithoutMatch){let R=r.nullSeparator?"\0":`
172
174
  `;o+=`${E}${R}`}else r.includeZero&&(r.count||r.countMatches)&&(o+=S.output)}}r.json&&(l.push(JSON.stringify({type:"summary",data:{elapsed_total:{secs:0,nanos:0,human:"0s"},stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:e.length,searches_with_match:u,bytes_searched:f,bytes_printed:0,matched_lines:c,matches:c}}})),o=`${l.join(`
173
175
  `)}
174
- `);let p=r.quiet&&!r.json?"":o,h;return r.filesWithoutMatch?h=o.length>0?0:1:h=a?0:1,{stdout:p,stderr:"",exitCode:h}}var pa=C(()=>{"use strict";fs();sr();ca()});var ha={};L(ha,{rgCommand:()=>gh});var mh,gh,ma=C(()=>{"use strict";j();sr();aa();pa();mh={name:"rg",summary:"recursively search for a pattern",usage:"rg [OPTIONS] PATTERN [PATH ...]",description:`rg (ripgrep) recursively searches directories for a regex pattern.
176
+ `);let p=r.quiet&&!r.json?"":o;if(r.stats&&!r.json){let m=["",`${c} matches`,`${c} matched lines`,`${u} files contained matches`,`${e.length} files searched`,`${f} bytes searched`].join(`
177
+ `);p+=`${m}
178
+ `}let h;return r.filesWithoutMatch?h=o.length>0?0:1:h=a?0:1,{stdout:p,stderr:"",exitCode:h}}var ya=C(()=>{"use strict";ps();ms();da()});var xa={};_(xa,{rgCommand:()=>Ah});var Ch,Ah,wa=C(()=>{"use strict";j();ms();fa();ya();Ch={name:"rg",summary:"recursively search for a pattern",usage:"rg [OPTIONS] PATTERN [PATH ...]",description:`rg (ripgrep) recursively searches directories for a regex pattern.
175
179
  Unlike grep, rg is recursive by default and respects .gitignore files.
176
180
 
177
181
  EXAMPLES:
@@ -182,22 +186,22 @@ EXAMPLES:
182
186
  rg -t js foo Search only JavaScript files
183
187
  rg -g '*.ts' foo Search files matching glob
184
188
  rg --hidden foo Include hidden files
185
- rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files"," --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},gh={name:"rg",async execute(t,e){if(I(t))return N(mh);if(t.includes("--type-list"))return{stdout:ta(),stderr:"",exitCode:0};let n=oa(t);return n.success?ua({ctx:e,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}}});function ir(t){return t instanceof Fe||t instanceof Be||t instanceof Te}var Qe,Fe,Be,Te,it,Xe,ue,ke,ct,V,ot,fe=C(()=>{"use strict";Qe=class extends Error{stdout;stderr;constructor(e,n="",r=""){super(e),this.stdout=n,this.stderr=r}prependOutput(e,n){this.stdout=e+this.stdout,this.stderr=n+this.stderr}},Fe=class extends Qe{levels;name="BreakError";constructor(e=1,n="",r=""){super("break",n,r),this.levels=e}},Be=class extends Qe{levels;name="ContinueError";constructor(e=1,n="",r=""){super("continue",n,r),this.levels=e}},Te=class extends Qe{exitCode;name="ReturnError";constructor(e=0,n="",r=""){super("return",n,r),this.exitCode=e}},it=class extends Qe{exitCode;name="ErrexitError";constructor(e,n="",r=""){super(`errexit: command exited with status ${e}`,n,r),this.exitCode=e}},Xe=class extends Qe{varName;name="NounsetError";constructor(e,n=""){super(`${e}: unbound variable`,n,`bash: ${e}: unbound variable
186
- `),this.varName=e}},ue=class extends Qe{exitCode;name="ExitError";constructor(e,n="",r=""){super("exit",n,r),this.exitCode=e}},ke=class extends Qe{name="ArithmeticError";constructor(e,n="",r=""){super(e,n,r),this.stderr=r||`bash: ${e}
187
- `}},ct=class extends Qe{name="BadSubstitutionError";constructor(e,n="",r=""){super(e,n,r),this.stderr=r||`bash: ${e}: bad substitution
188
- `}},V=class extends Qe{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,n,r="",s=""){super(e,r,s),this.limitType=n,this.stderr=s||`bash: ${e}
189
- `}},ot=class extends Qe{name="SubshellExitError";constructor(e="",n=""){super("subshell exit",e,n)}}});function ya(t,e,n){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:t,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],restartCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],pendingExecute:void 0,rangeStates:n||new Map}}function xh(t){return typeof t=="object"&&"first"in t&&"step"in t}function Sn(t,e,n,r){if(t==="$")return e===n;if(typeof t=="number")return e===t;if(xh(t)){let{first:s,step:i}=t;return i===0?e===s:(e-s)%i===0&&e>=s}if(typeof t=="object"&&"pattern"in t)try{return new RegExp(t.pattern).test(r)}catch{return!1}return!1}function wh(t){let e=n=>n===void 0?"undefined":n==="$"?"$":typeof n=="number"?String(n):"pattern"in n?`/${n.pattern}/`:"first"in n?`${n.first}~${n.step}`:"unknown";return`${e(t.start)},${e(t.end)}`}function Zt(t,e,n,r,s){if(!t||!t.start&&!t.end)return!0;let i=t.start,o=t.end;if(i!==void 0&&o===void 0)return Sn(i,e,n,r);if(i!==void 0&&o!==void 0){let a=typeof i=="object"&&"pattern"in i,l=typeof o=="object"&&"pattern"in o;if(!a&&!l){let u=typeof i=="number"?i:i==="$"?n:1,f=typeof o=="number"?o:n;return e>=u&&e<=f}if(s){let u=wh(t),f=s.get(u);return f||(f={active:!1},s.set(u,f)),f.active?(Sn(o,e,n,r)&&(f.active=!1,s.set(u,f)),!0):Sn(i,e,n,r)?(f.active=!0,f.startLine=e,s.set(u,f),Sn(o,e,n,r)&&(f.active=!1,s.set(u,f)),!0):!1}return Sn(i,e,n,r)}return!0}function bh(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){let r=t[n+1];if(r==="+"||r==="?"||r==="|"){e+=r,n+=2;continue}if(r==="("||r===")"){e+=r,n+=2;continue}if(r==="{"||r==="}"){e+=r,n+=2;continue}e+=t[n]+r,n+=2;continue}if(t[n]==="+"||t[n]==="?"||t[n]==="|"||t[n]==="("||t[n]===")"){e+=`\\${t[n]}`,n++;continue}e+=t[n],n++}return e}function Eh(t){let e="";for(let n=0;n<t.length;n++){let r=t[n],s=r.charCodeAt(0);r==="\\"?e+="\\\\":r===" "?e+="\\t":r===`
189
+ rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},Ah={name:"rg",async execute(t,e){if(N(t))return k(Ch);if(t.includes("--type-list"))return{stdout:ia(),stderr:"",exitCode:0};let n=ua(t);return n.success?pa({ctx:e,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}}});function or(t){return t instanceof Pe||t instanceof Be||t instanceof Te}var Qe,Pe,Be,Te,ot,Xe,fe,ke,ut,Z,at,de=C(()=>{"use strict";Qe=class extends Error{stdout;stderr;constructor(e,n="",r=""){super(e),this.stdout=n,this.stderr=r}prependOutput(e,n){this.stdout=e+this.stdout,this.stderr=n+this.stderr}},Pe=class extends Qe{levels;name="BreakError";constructor(e=1,n="",r=""){super("break",n,r),this.levels=e}},Be=class extends Qe{levels;name="ContinueError";constructor(e=1,n="",r=""){super("continue",n,r),this.levels=e}},Te=class extends Qe{exitCode;name="ReturnError";constructor(e=0,n="",r=""){super("return",n,r),this.exitCode=e}},ot=class extends Qe{exitCode;name="ErrexitError";constructor(e,n="",r=""){super(`errexit: command exited with status ${e}`,n,r),this.exitCode=e}},Xe=class extends Qe{varName;name="NounsetError";constructor(e,n=""){super(`${e}: unbound variable`,n,`bash: ${e}: unbound variable
190
+ `),this.varName=e}},fe=class extends Qe{exitCode;name="ExitError";constructor(e,n="",r=""){super("exit",n,r),this.exitCode=e}},ke=class extends Qe{name="ArithmeticError";constructor(e,n="",r=""){super(e,n,r),this.stderr=r||`bash: ${e}
191
+ `}},ut=class extends Qe{name="BadSubstitutionError";constructor(e,n="",r=""){super(e,n,r),this.stderr=r||`bash: ${e}: bad substitution
192
+ `}},Z=class extends Qe{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,n,r="",s=""){super(e,r,s),this.limitType=n,this.stderr=s||`bash: ${e}
193
+ `}},at=class extends Qe{name="SubshellExitError";constructor(e="",n=""){super("subshell exit",e,n)}}});function Ea(t,e,n){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:t,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],restartCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],pendingExecute:void 0,rangeStates:n||new Map}}function Nh(t){return typeof t=="object"&&"first"in t&&"step"in t}function An(t,e,n,r){if(t==="$")return e===n;if(typeof t=="number")return e===t;if(Nh(t)){let{first:s,step:i}=t;return i===0?e===s:(e-s)%i===0&&e>=s}if(typeof t=="object"&&"pattern"in t)try{return new RegExp(t.pattern).test(r)}catch{return!1}return!1}function Ih(t){let e=n=>n===void 0?"undefined":n==="$"?"$":typeof n=="number"?String(n):"pattern"in n?`/${n.pattern}/`:"first"in n?`${n.first}~${n.step}`:"unknown";return`${e(t.start)},${e(t.end)}`}function Kt(t,e,n,r,s){if(!t||!t.start&&!t.end)return!0;let i=t.start,o=t.end;if(i!==void 0&&o===void 0)return An(i,e,n,r);if(i!==void 0&&o!==void 0){let a=typeof i=="object"&&"pattern"in i,l=typeof o=="object"&&"pattern"in o;if(!a&&!l){let u=typeof i=="number"?i:i==="$"?n:1,f=typeof o=="number"?o:n;return e>=u&&e<=f}if(s){let u=Ih(t),f=s.get(u);return f||(f={active:!1},s.set(u,f)),f.active?(An(o,e,n,r)&&(f.active=!1,s.set(u,f)),!0):An(i,e,n,r)?(f.active=!0,f.startLine=e,s.set(u,f),An(o,e,n,r)&&(f.active=!1,s.set(u,f)),!0):!1}return An(i,e,n,r)}return!0}function vh(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){let r=t[n+1];if(r==="+"||r==="?"||r==="|"){e+=r,n+=2;continue}if(r==="("||r===")"){e+=r,n+=2;continue}if(r==="{"||r==="}"){e+=r,n+=2;continue}e+=t[n]+r,n+=2;continue}if(t[n]==="+"||t[n]==="?"||t[n]==="|"||t[n]==="("||t[n]===")"){e+=`\\${t[n]}`,n++;continue}e+=t[n],n++}return e}function $h(t){let e="";for(let n=0;n<t.length;n++){let r=t[n],s=r.charCodeAt(0);r==="\\"?e+="\\\\":r===" "?e+="\\t":r===`
190
194
  `?e+=`$
191
- `:r==="\r"?e+="\\r":r==="\x07"?e+="\\a":r==="\b"?e+="\\b":r==="\f"?e+="\\f":r==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=r}return`${e}$`}function ga(t,e,n){let r="",s=0;for(;s<t.length;){if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&"){r+="&",s+=2;continue}if(i==="n"){r+=`
192
- `,s+=2;continue}if(i==="t"){r+=" ",s+=2;continue}let o=parseInt(i,10);if(o>=1&&o<=9){r+=n[o-1]||"",s+=2;continue}r+=i,s+=2;continue}if(t[s]==="&"){r+=e,s++;continue}r+=t[s],s++}return r}function Sh(t,e){let{lineNumber:n,totalLines:r,patternSpace:s}=e;if(t.type!=="label"&&Zt(t.address,n,r,s,e.rangeStates))switch(t.type){case"substitute":{let i=t,o="";i.global&&(o+="g"),i.ignoreCase&&(o+="i");let a=i.extendedRegex?i.pattern:bh(i.pattern);try{let l=new RegExp(a,o),c=l.test(e.patternSpace);if(l.lastIndex=0,c){if(e.substitutionMade=!0,i.nthOccurrence&&i.nthOccurrence>0&&!i.global){let u=0,f=i.nthOccurrence;e.patternSpace=e.patternSpace.replace(new RegExp(a,`g${i.ignoreCase?"i":""}`),(d,...p)=>{if(u++,u===f){let h=p.slice(0,-2);return ga(i.replacement,d,h)}return d})}else e.patternSpace=e.patternSpace.replace(l,(u,...f)=>{let d=f.slice(0,-2);return ga(i.replacement,u,d)});i.printOnMatch&&(e.printed=!0)}}catch{}break}case"print":e.printed=!0;break;case"printFirstLine":{let i=e.patternSpace.indexOf(`
195
+ `:r==="\r"?e+="\\r":r==="\x07"?e+="\\a":r==="\b"?e+="\\b":r==="\f"?e+="\\f":r==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=r}return`${e}$`}function ba(t,e,n){let r="",s=0;for(;s<t.length;){if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&"){r+="&",s+=2;continue}if(i==="n"){r+=`
196
+ `,s+=2;continue}if(i==="t"){r+=" ",s+=2;continue}let o=parseInt(i,10);if(o>=1&&o<=9){r+=n[o-1]||"",s+=2;continue}r+=i,s+=2;continue}if(t[s]==="&"){r+=e,s++;continue}r+=t[s],s++}return r}function Rh(t,e){let{lineNumber:n,totalLines:r,patternSpace:s}=e;if(t.type!=="label"&&Kt(t.address,n,r,s,e.rangeStates))switch(t.type){case"substitute":{let i=t,o="";i.global&&(o+="g"),i.ignoreCase&&(o+="i");let a=i.extendedRegex?i.pattern:vh(i.pattern);try{let l=new RegExp(a,o),c=l.test(e.patternSpace);if(l.lastIndex=0,c){if(e.substitutionMade=!0,i.nthOccurrence&&i.nthOccurrence>0&&!i.global){let u=0,f=i.nthOccurrence;e.patternSpace=e.patternSpace.replace(new RegExp(a,`g${i.ignoreCase?"i":""}`),(d,...p)=>{if(u++,u===f){let h=p.slice(0,-2);return ba(i.replacement,d,h)}return d})}else e.patternSpace=e.patternSpace.replace(l,(u,...f)=>{let d=f.slice(0,-2);return ba(i.replacement,u,d)});i.printOnMatch&&(e.printed=!0)}}catch{}break}case"print":e.printed=!0;break;case"printFirstLine":{let i=e.patternSpace.indexOf(`
193
197
  `);i!==-1?e.lineNumberOutput.push(e.patternSpace.slice(0,i)):e.lineNumberOutput.push(e.patternSpace);break}case"delete":e.deleted=!0;break;case"deleteFirstLine":{let i=e.patternSpace.indexOf(`
194
198
  `);i!==-1?(e.patternSpace=e.patternSpace.slice(i+1),e.restartCycle=!0):e.deleted=!0;break}case"zap":e.patternSpace="";break;case"append":e.appendBuffer.push(t.text);break;case"insert":e.appendBuffer.unshift(`__INSERT__${t.text}`);break;case"change":e.patternSpace=t.text,e.deleted=!0,e.appendBuffer.push(t.text);break;case"hold":e.holdSpace=e.patternSpace;break;case"holdAppend":e.holdSpace?e.holdSpace+=`
195
199
  ${e.patternSpace}`:e.holdSpace=e.patternSpace;break;case"get":e.patternSpace=e.holdSpace;break;case"getAppend":e.patternSpace+=`
196
- ${e.holdSpace}`;break;case"exchange":{let i=e.patternSpace;e.patternSpace=e.holdSpace,e.holdSpace=i;break}case"next":e.printed=!0;break;case"quit":e.quit=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"quitSilent":e.quit=!0,e.quitSilent=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"list":{let i=Eh(e.patternSpace);e.lineNumberOutput.push(i);break}case"printFilename":e.currentFilename&&e.lineNumberOutput.push(e.currentFilename);break;case"version":break;case"readFile":e.pendingFileReads.push({filename:t.filename,wholeFile:!0});break;case"readFileLine":e.pendingFileReads.push({filename:t.filename,wholeFile:!1});break;case"writeFile":e.pendingFileWrites.push({filename:t.filename,content:`${e.patternSpace}
200
+ ${e.holdSpace}`;break;case"exchange":{let i=e.patternSpace;e.patternSpace=e.holdSpace,e.holdSpace=i;break}case"next":e.printed=!0;break;case"quit":e.quit=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"quitSilent":e.quit=!0,e.quitSilent=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"list":{let i=$h(e.patternSpace);e.lineNumberOutput.push(i);break}case"printFilename":e.currentFilename&&e.lineNumberOutput.push(e.currentFilename);break;case"version":break;case"readFile":e.pendingFileReads.push({filename:t.filename,wholeFile:!0});break;case"readFileLine":e.pendingFileReads.push({filename:t.filename,wholeFile:!1});break;case"writeFile":e.pendingFileWrites.push({filename:t.filename,content:`${e.patternSpace}
197
201
  `});break;case"writeFirstLine":{let i=e.patternSpace.indexOf(`
198
202
  `),o=i!==-1?e.patternSpace.slice(0,i):e.patternSpace;e.pendingFileWrites.push({filename:t.filename,content:`${o}
199
- `});break}case"execute":t.command?e.pendingExecute={command:t.command,replacePattern:!1}:e.pendingExecute={command:e.patternSpace,replacePattern:!0};break;case"transliterate":e.patternSpace=Ch(e.patternSpace,t);break;case"lineNumber":e.lineNumberOutput.push(String(e.lineNumber));break;case"branch":break;case"branchOnSubst":break;case"branchOnNoSubst":break;case"group":break}}function Ch(t,e){let n="";for(let r of t){let s=e.source.indexOf(r);s!==-1?n+=e.dest[s]:n+=r}return n}function ms(t,e,n,r){let s=new Map;for(let c=0;c<t.length;c++){let u=t[c];u.type==="label"&&s.set(u.name,c)}let i=r?.maxIterations??yh,o=0,a=0,l=0;for(;l<t.length;){if(o++,o>i)throw new V(`sed: command execution exceeded maximum iterations (${i})`,"iterations");if(e.deleted||e.quit||e.quitSilent||e.restartCycle)break;let c=t[l];if(c.type==="nextAppend"){if(Zt(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates))if(n&&n.currentLineIndex+a+1<n.lines.length){a++;let u=n.lines[n.currentLineIndex+a];e.patternSpace+=`
200
- ${u}`,e.lineNumber=n.currentLineIndex+a+1}else{e.quit=!0,e.deleted=!0;break}l++;continue}if(c.type==="branch"){let u=c;if(Zt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnSubst"){let u=c;if(Zt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&e.substitutionMade){if(e.substitutionMade=!1,u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnNoSubst"){let u=c;if(Zt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&!e.substitutionMade){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="group"){let u=c;Zt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&ms(u.commands,e,n,r),l++;continue}Sh(c,e),l++}return a}var yh,xa=C(()=>{"use strict";fe();yh=1e4});var U,or,wa=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.DOLLAR="DOLLAR",t.PATTERN="PATTERN",t.STEP="STEP",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.COMMA="COMMA",t.COMMAND="COMMAND",t.SUBSTITUTE="SUBSTITUTE",t.TRANSLITERATE="TRANSLITERATE",t.LABEL_DEF="LABEL_DEF",t.BRANCH="BRANCH",t.BRANCH_ON_SUBST="BRANCH_ON_SUBST",t.BRANCH_ON_NO_SUBST="BRANCH_ON_NO_SUBST",t.TEXT_CMD="TEXT_CMD",t.FILE_READ="FILE_READ",t.FILE_READ_LINE="FILE_READ_LINE",t.FILE_WRITE="FILE_WRITE",t.FILE_WRITE_LINE="FILE_WRITE_LINE",t.EXECUTE="EXECUTE",t.EOF="EOF",t.ERROR="ERROR"})(U||(U={}));or=class{input;pos=0;line=1;column=1;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&e.push(n)}return e.push(this.makeToken(U.EOF,"")),e}makeToken(e,n,r){return{type:e,value:n,line:this.line,column:this.column,...r}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
203
+ `});break}case"execute":t.command?e.pendingExecute={command:t.command,replacePattern:!1}:e.pendingExecute={command:e.patternSpace,replacePattern:!0};break;case"transliterate":e.patternSpace=Fh(e.patternSpace,t);break;case"lineNumber":e.lineNumberOutput.push(String(e.lineNumber));break;case"branch":break;case"branchOnSubst":break;case"branchOnNoSubst":break;case"group":break}}function Fh(t,e){let n="";for(let r of t){let s=e.source.indexOf(r);s!==-1?n+=e.dest[s]:n+=r}return n}function ys(t,e,n,r){let s=new Map;for(let c=0;c<t.length;c++){let u=t[c];u.type==="label"&&s.set(u.name,c)}let i=r?.maxIterations??kh,o=0,a=0,l=0;for(;l<t.length;){if(o++,o>i)throw new Z(`sed: command execution exceeded maximum iterations (${i})`,"iterations");if(e.deleted||e.quit||e.quitSilent||e.restartCycle)break;let c=t[l];if(c.type==="nextAppend"){if(Kt(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates))if(n&&n.currentLineIndex+a+1<n.lines.length){a++;let u=n.lines[n.currentLineIndex+a];e.patternSpace+=`
204
+ ${u}`,e.lineNumber=n.currentLineIndex+a+1}else{e.quit=!0,e.deleted=!0;break}l++;continue}if(c.type==="branch"){let u=c;if(Kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnSubst"){let u=c;if(Kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&e.substitutionMade){if(e.substitutionMade=!1,u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnNoSubst"){let u=c;if(Kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&!e.substitutionMade){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="group"){let u=c;Kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&ys(u.commands,e,n,r),l++;continue}Rh(c,e),l++}return a}var kh,Sa=C(()=>{"use strict";de();kh=1e4});var U,ar,Ca=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.DOLLAR="DOLLAR",t.PATTERN="PATTERN",t.STEP="STEP",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.COMMA="COMMA",t.COMMAND="COMMAND",t.SUBSTITUTE="SUBSTITUTE",t.TRANSLITERATE="TRANSLITERATE",t.LABEL_DEF="LABEL_DEF",t.BRANCH="BRANCH",t.BRANCH_ON_SUBST="BRANCH_ON_SUBST",t.BRANCH_ON_NO_SUBST="BRANCH_ON_NO_SUBST",t.TEXT_CMD="TEXT_CMD",t.FILE_READ="FILE_READ",t.FILE_READ_LINE="FILE_READ_LINE",t.FILE_WRITE="FILE_WRITE",t.FILE_WRITE_LINE="FILE_WRITE_LINE",t.EXECUTE="EXECUTE",t.EOF="EOF",t.ERROR="ERROR"})(U||(U={}));ar=class{input;pos=0;line=1;column=1;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&e.push(n)}return e.push(this.makeToken(U.EOF,"")),e}makeToken(e,n,r){return{type:e,value:n,line:this.line,column:this.column,...r}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
201
205
  `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===" "||e===" "||e==="\r")this.advance();else if(e==="#")for(;this.pos<this.input.length&&this.peek()!==`
202
206
  `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,n=this.column,r=this.peek();return r===`
203
207
  `?(this.advance(),{type:U.NEWLINE,value:`
@@ -217,14 +221,14 @@ ${u}`,e.lineNumber=n.currentLineIndex+a+1}else{e.quit=!0,e.deleted=!0;break}l++;
217
221
  `;)s+=this.advance();return{type:U.TEXT_CMD,value:e,text:s.trim(),line:n,column:r}}readBranch(e,n,r,s){for(;this.peek()===" "||this.peek()===" ";)this.advance();let i="";for(;this.pos<this.input.length;){let o=this.peek();if(o===" "||o===" "||o===`
218
222
  `||o===";"||o==="}"||o==="{")break;i+=this.advance()}return{type:e,value:n,label:i||void 0,line:r,column:s}}readFileCommand(e,n,r,s){for(;this.peek()===" "||this.peek()===" ";)this.advance();let i="";for(;this.pos<this.input.length;){let o=this.peek();if(o===`
219
223
  `||o===";")break;i+=this.advance()}return{type:e,value:n,filename:i.trim(),line:r,column:s}}readExecute(e,n){for(;this.peek()===" "||this.peek()===" ";)this.advance();let r="";for(;this.pos<this.input.length;){let s=this.peek();if(s===`
220
- `||s===";")break;r+=this.advance()}return{type:U.EXECUTE,value:"e",command:r.trim()||void 0,line:e,column:n}}isDigit(e){return e>="0"&&e<="9"}}});function ba(t,e=!1){return new gs(t,e).parse()}var gs,Ea=C(()=>{"use strict";wa();gs=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(e,n=!1){this.scripts=e,this.extendedRegex=n}parse(){let e=[];for(let n of this.scripts){let r=new or(n);for(this.tokens=r.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(U.NEWLINE)||this.check(U.SEMICOLON)){this.advance();continue}let s=this.parseCommand();if(s.error)return{commands:[],error:s.error};s.command&&e.push(s.command)}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();for(;this.check(U.NEWLINE)||this.check(U.SEMICOLON);)this.advance();if(this.isAtEnd())return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null};let n=this.peek();switch(n.type){case U.COMMAND:return this.parseSimpleCommand(n,e);case U.SUBSTITUTE:return this.parseSubstituteFromToken(n,e);case U.TRANSLITERATE:return this.parseTransliterateFromToken(n,e);case U.LABEL_DEF:return this.advance(),{command:{type:"label",name:n.label||""}};case U.BRANCH:return this.advance(),{command:{type:"branch",address:e,label:n.label}};case U.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:e,label:n.label}};case U.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:e,label:n.label}};case U.TEXT_CMD:return this.advance(),this.parseTextCommand(n,e);case U.FILE_READ:return this.advance(),{command:{type:"readFile",address:e,filename:n.filename||""}};case U.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:e,filename:n.filename||""}};case U.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:e,filename:n.filename||""}};case U.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:e,filename:n.filename||""}};case U.EXECUTE:return this.advance(),{command:{type:"execute",address:e,command:n.command}};case U.LBRACE:return this.parseGroup(e);case U.RBRACE:return{command:null};case U.ERROR:return{command:null,error:`invalid command: ${n.value}`};default:return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null}}}parseSimpleCommand(e,n){this.advance();let r=e.value;switch(r){case"p":return{command:{type:"print",address:n}};case"P":return{command:{type:"printFirstLine",address:n}};case"d":return{command:{type:"delete",address:n}};case"D":return{command:{type:"deleteFirstLine",address:n}};case"h":return{command:{type:"hold",address:n}};case"H":return{command:{type:"holdAppend",address:n}};case"g":return{command:{type:"get",address:n}};case"G":return{command:{type:"getAppend",address:n}};case"x":return{command:{type:"exchange",address:n}};case"n":return{command:{type:"next",address:n}};case"N":return{command:{type:"nextAppend",address:n}};case"q":return{command:{type:"quit",address:n}};case"Q":return{command:{type:"quitSilent",address:n}};case"z":return{command:{type:"zap",address:n}};case"=":return{command:{type:"lineNumber",address:n}};case"l":return{command:{type:"list",address:n}};case"F":return{command:{type:"printFilename",address:n}};case"v":return{command:{type:"version",address:n}};default:return{command:null,error:`unknown command: ${r}`}}}parseSubstituteFromToken(e,n){this.advance();let r=e.flags||"",s,i=r.match(/(\d+)/);return i&&(s=parseInt(i[1],10)),{command:{type:"substitute",address:n,pattern:e.pattern||"",replacement:e.replacement||"",global:r.includes("g"),ignoreCase:r.includes("i")||r.includes("I"),printOnMatch:r.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,n){this.advance();let r=e.source||"",s=e.dest||"";return r.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:n,source:r,dest:s}}}parseTextCommand(e,n){let r=e.value,s=e.text||"";switch(r){case"a":return{command:{type:"append",address:n,text:s}};case"i":return{command:{type:"insert",address:n,text:s}};case"c":return{command:{type:"change",address:n,text:s}};default:return{command:null,error:`unknown text command: ${r}`}}}parseGroup(e){this.advance();let n=[];for(;!this.isAtEnd()&&!this.check(U.RBRACE);){if(this.check(U.NEWLINE)||this.check(U.SEMICOLON)){this.advance();continue}let r=this.parseCommand();if(r.error)return{command:null,error:r.error};r.command&&n.push(r.command)}return this.check(U.RBRACE)?(this.advance(),{command:{type:"group",address:e,commands:n}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){let e=this.parseAddress();if(e===void 0)return;let n;return this.check(U.COMMA)&&(this.advance(),n=this.parseAddress()),{start:e,end:n}}parseAddress(){let e=this.peek();switch(e.type){case U.NUMBER:return this.advance(),e.value;case U.DOLLAR:return this.advance(),"$";case U.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case U.STEP:return this.advance(),{first:e.first||0,step:e.step||0};default:return}}peek(){return this.tokens[this.pos]||{type:U.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===U.EOF}}});var Sa={};L(Sa,{sedCommand:()=>kh});async function ys(t,e,n,r={}){let{limits:s,filename:i,fs:o,cwd:a}=r,l=t.split(`
221
- `);l.length>0&&l[l.length-1]===""&&l.pop();let c=l.length,u="",f,d="",p=new Map,h=new Map,m=new Map,g=new Map,w=s?{maxIterations:s.maxSedIterations}:void 0;for(let b=0;b<l.length;b++){let E={...ya(c,i,p),patternSpace:l[b],holdSpace:d,lineNumber:b+1,totalLines:c,substitutionMade:!1},S={lines:l,currentLineIndex:b},R=0,P=1e4,z=0;do{if(R++,R>P)break;E.restartCycle=!1,E.pendingFileReads=[],E.pendingFileWrites=[];let F=ms(e,E,S,w);if(z+=F,o&&a){for(let T of E.pendingFileReads){let v=o.resolvePath(a,T.filename);try{if(T.wholeFile){let k=await o.readFile(v);E.appendBuffer.push(k.replace(/\n$/,""))}else{if(!h.has(v)){let M=await o.readFile(v);h.set(v,M.split(`
222
- `)),m.set(v,0)}let k=h.get(v),$=m.get(v);k&&$!==void 0&&$<k.length&&(E.appendBuffer.push(k[$]),m.set(v,$+1))}}catch{}}for(let T of E.pendingFileWrites){let v=o.resolvePath(a,T.filename),k=g.get(v)||"";g.set(v,k+T.content)}}S.currentLineIndex+=F}while(E.restartCycle&&!E.deleted&&!E.quit&&!E.quitSilent);b+=z,d=E.holdSpace;for(let F of E.lineNumberOutput)u+=`${F}
223
- `;let W=[],X=[];for(let F of E.appendBuffer)F.startsWith("__INSERT__")?W.push(F.slice(10)):X.push(F);for(let F of W)u+=`${F}
224
+ `||s===";")break;r+=this.advance()}return{type:U.EXECUTE,value:"e",command:r.trim()||void 0,line:e,column:n}}isDigit(e){return e>="0"&&e<="9"}}});function Aa(t,e=!1){return new xs(t,e).parse()}var xs,ka=C(()=>{"use strict";Ca();xs=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(e,n=!1){this.scripts=e,this.extendedRegex=n}parse(){let e=[];for(let n of this.scripts){let r=new ar(n);for(this.tokens=r.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(U.NEWLINE)||this.check(U.SEMICOLON)){this.advance();continue}let s=this.parseCommand();if(s.error)return{commands:[],error:s.error};s.command&&e.push(s.command)}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();for(;this.check(U.NEWLINE)||this.check(U.SEMICOLON);)this.advance();if(this.isAtEnd())return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null};let n=this.peek();switch(n.type){case U.COMMAND:return this.parseSimpleCommand(n,e);case U.SUBSTITUTE:return this.parseSubstituteFromToken(n,e);case U.TRANSLITERATE:return this.parseTransliterateFromToken(n,e);case U.LABEL_DEF:return this.advance(),{command:{type:"label",name:n.label||""}};case U.BRANCH:return this.advance(),{command:{type:"branch",address:e,label:n.label}};case U.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:e,label:n.label}};case U.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:e,label:n.label}};case U.TEXT_CMD:return this.advance(),this.parseTextCommand(n,e);case U.FILE_READ:return this.advance(),{command:{type:"readFile",address:e,filename:n.filename||""}};case U.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:e,filename:n.filename||""}};case U.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:e,filename:n.filename||""}};case U.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:e,filename:n.filename||""}};case U.EXECUTE:return this.advance(),{command:{type:"execute",address:e,command:n.command}};case U.LBRACE:return this.parseGroup(e);case U.RBRACE:return{command:null};case U.ERROR:return{command:null,error:`invalid command: ${n.value}`};default:return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null}}}parseSimpleCommand(e,n){this.advance();let r=e.value;switch(r){case"p":return{command:{type:"print",address:n}};case"P":return{command:{type:"printFirstLine",address:n}};case"d":return{command:{type:"delete",address:n}};case"D":return{command:{type:"deleteFirstLine",address:n}};case"h":return{command:{type:"hold",address:n}};case"H":return{command:{type:"holdAppend",address:n}};case"g":return{command:{type:"get",address:n}};case"G":return{command:{type:"getAppend",address:n}};case"x":return{command:{type:"exchange",address:n}};case"n":return{command:{type:"next",address:n}};case"N":return{command:{type:"nextAppend",address:n}};case"q":return{command:{type:"quit",address:n}};case"Q":return{command:{type:"quitSilent",address:n}};case"z":return{command:{type:"zap",address:n}};case"=":return{command:{type:"lineNumber",address:n}};case"l":return{command:{type:"list",address:n}};case"F":return{command:{type:"printFilename",address:n}};case"v":return{command:{type:"version",address:n}};default:return{command:null,error:`unknown command: ${r}`}}}parseSubstituteFromToken(e,n){this.advance();let r=e.flags||"",s,i=r.match(/(\d+)/);return i&&(s=parseInt(i[1],10)),{command:{type:"substitute",address:n,pattern:e.pattern||"",replacement:e.replacement||"",global:r.includes("g"),ignoreCase:r.includes("i")||r.includes("I"),printOnMatch:r.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,n){this.advance();let r=e.source||"",s=e.dest||"";return r.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:n,source:r,dest:s}}}parseTextCommand(e,n){let r=e.value,s=e.text||"";switch(r){case"a":return{command:{type:"append",address:n,text:s}};case"i":return{command:{type:"insert",address:n,text:s}};case"c":return{command:{type:"change",address:n,text:s}};default:return{command:null,error:`unknown text command: ${r}`}}}parseGroup(e){this.advance();let n=[];for(;!this.isAtEnd()&&!this.check(U.RBRACE);){if(this.check(U.NEWLINE)||this.check(U.SEMICOLON)){this.advance();continue}let r=this.parseCommand();if(r.error)return{command:null,error:r.error};r.command&&n.push(r.command)}return this.check(U.RBRACE)?(this.advance(),{command:{type:"group",address:e,commands:n}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){let e=this.parseAddress();if(e===void 0)return;let n;return this.check(U.COMMA)&&(this.advance(),n=this.parseAddress()),{start:e,end:n}}parseAddress(){let e=this.peek();switch(e.type){case U.NUMBER:return this.advance(),e.value;case U.DOLLAR:return this.advance(),"$";case U.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case U.STEP:return this.advance(),{first:e.first||0,step:e.step||0};default:return}}peek(){return this.tokens[this.pos]||{type:U.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===U.EOF}}});var Na={};_(Na,{sedCommand:()=>Th});async function ws(t,e,n,r={}){let{limits:s,filename:i,fs:o,cwd:a}=r,l=t.split(`
225
+ `);l.length>0&&l[l.length-1]===""&&l.pop();let c=l.length,u="",f,d="",p=new Map,h=new Map,m=new Map,g=new Map,b=s?{maxIterations:s.maxSedIterations}:void 0;for(let w=0;w<l.length;w++){let E={...Ea(c,i,p),patternSpace:l[w],holdSpace:d,lineNumber:w+1,totalLines:c,substitutionMade:!1},S={lines:l,currentLineIndex:w},R=0,F=1e4,z=0;do{if(R++,R>F)break;E.restartCycle=!1,E.pendingFileReads=[],E.pendingFileWrites=[];let P=ys(e,E,S,b);if(z+=P,o&&a){for(let T of E.pendingFileReads){let $=o.resolvePath(a,T.filename);try{if(T.wholeFile){let I=await o.readFile($);E.appendBuffer.push(I.replace(/\n$/,""))}else{if(!h.has($)){let D=await o.readFile($);h.set($,D.split(`
226
+ `)),m.set($,0)}let I=h.get($),v=m.get($);I&&v!==void 0&&v<I.length&&(E.appendBuffer.push(I[v]),m.set($,v+1))}}catch{}}for(let T of E.pendingFileWrites){let $=o.resolvePath(a,T.filename),I=g.get($)||"";g.set($,I+T.content)}}S.currentLineIndex+=P}while(E.restartCycle&&!E.deleted&&!E.quit&&!E.quitSilent);w+=z,d=E.holdSpace;for(let P of E.lineNumberOutput)u+=`${P}
227
+ `;let W=[],J=[];for(let P of E.appendBuffer)P.startsWith("__INSERT__")?W.push(P.slice(10)):J.push(P);for(let P of W)u+=`${P}
224
228
  `;!E.deleted&&!E.quitSilent&&(n?E.printed&&(u+=`${E.patternSpace}
225
229
  `):u+=`${E.patternSpace}
226
- `);for(let F of X)u+=`${F}
227
- `;if(E.quit||E.quitSilent){E.exitCode!==void 0&&(f=E.exitCode);break}}if(o&&a)for(let[b,E]of g)try{await o.writeFile(b,E)}catch{}return{output:u,exitCode:f}}var Ah,kh,Ca=C(()=>{"use strict";fe();j();xa();Ea();Ah={name:"sed",summary:"stream editor for filtering and transforming text",usage:"sed [OPTION]... {script} [input-file]...",options:["-n, --quiet, --silent suppress automatic printing of pattern space","-e script add the script to commands to be executed","-f script-file read script from file","-i, --in-place edit files in place","-E, -r, --regexp-extended use extended regular expressions"," --help display this help and exit"],description:`Commands:
230
+ `);for(let P of J)u+=`${P}
231
+ `;if(E.quit||E.quitSilent){E.exitCode!==void 0&&(f=E.exitCode);break}}if(o&&a)for(let[w,E]of g)try{await o.writeFile(w,E)}catch{}return{output:u,exitCode:f}}var Ph,Th,Ia=C(()=>{"use strict";de();j();Sa();ka();Ph={name:"sed",summary:"stream editor for filtering and transforming text",usage:"sed [OPTION]... {script} [input-file]...",options:["-n, --quiet, --silent suppress automatic printing of pattern space","-e script add the script to commands to be executed","-f script-file read script from file","-i, --in-place edit files in place","-E, -r, --regexp-extended use extended regular expressions"," --help display this help and exit"],description:`Commands:
228
232
  s/regexp/replacement/[flags] substitute
229
233
  d delete pattern space
230
234
  p print pattern space
@@ -253,36 +257,36 @@ Addresses:
253
257
  $ last line
254
258
  /regexp/ lines matching regexp
255
259
  N,M range from line N to M
256
- first~step every step-th line starting at first`};kh={name:"sed",async execute(t,e){if(I(t))return N(Ah);let n=[],r=[],s=!1,i=!1,o=!1,a=[];for(let f=0;f<t.length;f++){let d=t[f];if(d==="-n"||d==="--quiet"||d==="--silent")s=!0;else if(d==="-i"||d==="--in-place")i=!0;else if(d.startsWith("-i"))i=!0;else if(d==="-E"||d==="-r"||d==="--regexp-extended")o=!0;else if(d==="-e")f+1<t.length&&n.push(t[++f]);else if(d==="-f")f+1<t.length&&r.push(t[++f]);else{if(d.startsWith("--"))return D("sed",d);if(d.startsWith("-")&&d.length>1){for(let p of d.slice(1))if(p!=="n"&&p!=="e"&&p!=="f"&&p!=="i"&&p!=="E"&&p!=="r")return D("sed",`-${p}`);d.includes("n")&&(s=!0),d.includes("i")&&(i=!0),(d.includes("E")||d.includes("r"))&&(o=!0),d.includes("e")&&!d.includes("n")&&!d.includes("i")&&f+1<t.length&&n.push(t[++f]),d.includes("f")&&!d.includes("e")&&f+1<t.length&&r.push(t[++f])}else!d.startsWith("-")&&n.length===0&&r.length===0?n.push(d):d.startsWith("-")||a.push(d)}}for(let f of r){let d=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readFile(d);for(let h of p.split(`
260
+ first~step every step-th line starting at first`};Th={name:"sed",async execute(t,e){if(N(t))return k(Ph);let n=[],r=[],s=!1,i=!1,o=!1,a=[];for(let f=0;f<t.length;f++){let d=t[f];if(d==="-n"||d==="--quiet"||d==="--silent")s=!0;else if(d==="-i"||d==="--in-place")i=!0;else if(d.startsWith("-i"))i=!0;else if(d==="-E"||d==="-r"||d==="--regexp-extended")o=!0;else if(d==="-e")f+1<t.length&&n.push(t[++f]);else if(d==="-f")f+1<t.length&&r.push(t[++f]);else{if(d.startsWith("--"))return L("sed",d);if(d.startsWith("-")&&d.length>1){for(let p of d.slice(1))if(p!=="n"&&p!=="e"&&p!=="f"&&p!=="i"&&p!=="E"&&p!=="r")return L("sed",`-${p}`);d.includes("n")&&(s=!0),d.includes("i")&&(i=!0),(d.includes("E")||d.includes("r"))&&(o=!0),d.includes("e")&&!d.includes("n")&&!d.includes("i")&&f+1<t.length&&n.push(t[++f]),d.includes("f")&&!d.includes("e")&&f+1<t.length&&r.push(t[++f])}else!d.startsWith("-")&&n.length===0&&r.length===0?n.push(d):d.startsWith("-")||a.push(d)}}for(let f of r){let d=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readFile(d);for(let h of p.split(`
257
261
  `)){let m=h.trim();m&&!m.startsWith("#")&&n.push(m)}}catch{return{stdout:"",stderr:`sed: couldn't open file ${f}: No such file or directory
258
262
  `,exitCode:1}}}if(n.length===0)return{stdout:"",stderr:`sed: no script specified
259
- `,exitCode:1};let{commands:l,error:c}=ba(n,o);if(c)return{stdout:"",stderr:`sed: ${c}
263
+ `,exitCode:1};let{commands:l,error:c}=Aa(n,o);if(c)return{stdout:"",stderr:`sed: ${c}
260
264
  `,exitCode:1};if(l.length===0)return{stdout:"",stderr:`sed: no valid commands
261
- `,exitCode:1};let u="";if(a.length===0){u=e.stdin;try{let f=await ys(u,l,s,{limits:e.limits,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof V)return{stdout:"",stderr:`sed: ${f.message}
262
- `,exitCode:V.EXIT_CODE};throw f}}if(i){for(let f of a){let d=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readFile(d),h=await ys(p,l,s,{limits:e.limits,filename:f,fs:e.fs,cwd:e.cwd});await e.fs.writeFile(d,h.output)}catch(p){return p instanceof V?{stdout:"",stderr:`sed: ${p.message}
263
- `,exitCode:V.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
264
- `,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}for(let f of a){let d=e.fs.resolvePath(e.cwd,f);try{u+=await e.fs.readFile(d)}catch(p){return p instanceof V?{stdout:"",stderr:`sed: ${p.message}
265
- `,exitCode:V.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
266
- `,exitCode:1}}}try{let f=await ys(u,l,s,{limits:e.limits,filename:a.length===1?a[0]:void 0,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof V)return{stdout:"",stderr:`sed: ${f.message}
267
- `,exitCode:V.EXIT_CODE};throw f}}}});function xs(t={}){let{fieldSep:e=/\s+/,maxIterations:n=1e4,maxRecursionDepth:r=100,fs:s,cwd:i}=t;return{FS:" ",OFS:" ",ORS:`
268
- `,NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:{},arrays:{},ARGC:0,ARGV:{},functions:new Map,fieldSep:e,maxIterations:n,maxRecursionDepth:r,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,output:"",openedFiles:new Set,fs:s,cwd:i}}var Aa=C(()=>{"use strict"});function ka(t,e,n){switch(n){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?t/e:0;case"%":return e!==0?t%e:0;case"^":case"**":return t**e;default:return 0}}var Na=C(()=>{"use strict"});function Ge(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function be(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}async function Nh(t,e,n){return t.length===0?e.line.length:be(await n.evalExpr(t[0])).length}async function Ih(t,e,n){if(t.length<2)return"";let r=be(await n.evalExpr(t[0])),s=Math.floor(Ge(await n.evalExpr(t[1])))-1;if(t.length>=3){let i=Math.floor(Ge(await n.evalExpr(t[2])));return r.substr(Math.max(0,s),i)}return r.substr(Math.max(0,s))}async function vh(t,e,n){if(t.length<2)return 0;let r=be(await n.evalExpr(t[0])),s=be(await n.evalExpr(t[1])),i=r.indexOf(s);return i===-1?0:i+1}async function $h(t,e,n){if(t.length<2)return 0;let r=be(await n.evalExpr(t[0])),s=t[1];if(s.type!=="variable")return 0;let i=s.name,o=e.FS;if(t.length>=3){let l=be(await n.evalExpr(t[2]));o=l===" "?/\s+/:l}else e.FS===" "&&(o=/\s+/);let a=r.split(o);e.arrays[i]={};for(let l=0;l<a.length;l++)e.arrays[i][String(l+1)]=a[l];return a.length}async function Rh(t,e,n){if(t.length<2)return 0;let r;t[0].type==="regex"?r=t[0].pattern:(r=be(await n.evalExpr(t[0])),r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)));let s=be(await n.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(Ge(await n.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=be(e.vars[i]??"");try{let a=new RegExp(r),l=o.replace(a,va(s)),c=l!==o?1:0;if(i==="$0")e.line=l,e.fields=e.FS===" "?l.trim().split(/\s+/).filter(Boolean):l.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let u=parseInt(i.slice(1),10)-1;for(;e.fields.length<=u;)e.fields.push("");e.fields[u]=l,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=l;return c}catch{return 0}}async function Ph(t,e,n){if(t.length<2)return 0;let r;t[0].type==="regex"?r=t[0].pattern:(r=be(await n.evalExpr(t[0])),r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)));let s=be(await n.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(Ge(await n.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=be(e.vars[i]??"");try{let a=new RegExp(r,"g"),l=o.match(a),c=l?l.length:0,u=o.replace(a,va(s));if(i==="$0")e.line=u,e.fields=e.FS===" "?u.trim().split(/\s+/).filter(Boolean):u.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let f=parseInt(i.slice(1),10)-1;for(;e.fields.length<=f;)e.fields.push("");e.fields[f]=u,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=u;return c}catch{return 0}}function va(t){return e=>{let n="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length){let s=t[r+1];s==="&"?(n+="&",r+=2):s==="\\"?(n+="\\",r+=2):(n+=t[r+1],r+=2)}else t[r]==="&"?(n+=e,r++):(n+=t[r],r++);return n}}async function Fh(t,e,n){if(t.length<2)return e.RSTART=0,e.RLENGTH=-1,0;let r=be(await n.evalExpr(t[0])),s;t[1].type==="regex"?s=t[1].pattern:(s=be(await n.evalExpr(t[1])),s.startsWith("/")&&s.endsWith("/")&&(s=s.slice(1,-1)));try{let o=new RegExp(s).exec(r);if(o)return e.RSTART=o.index+1,e.RLENGTH=o[0].length,e.RSTART}catch{}return e.RSTART=0,e.RLENGTH=-1,0}async function Th(t,e,n){if(t.length<3)return"";let r;t[0].type==="regex"?r=t[0].pattern:(r=be(await n.evalExpr(t[0])),r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)));let s=be(await n.evalExpr(t[1])),i=be(await n.evalExpr(t[2])),o=t.length>=4?be(await n.evalExpr(t[3])):e.line;try{let a=i.toLowerCase()==="g",l=a?0:parseInt(i,10)||1;if(a){let c=new RegExp(r,"g");return o.replace(c,(u,...f)=>Ia(s,u,f.slice(0,-2)))}else{let c=0,u=new RegExp(r,"g");return o.replace(u,(f,...d)=>(c++,c===l?Ia(s,f,d.slice(0,-2)):f))}}catch{return o}}function Ia(t,e,n){let r="",s=0;for(;s<t.length;)if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&")r+="&",s+=2;else if(i==="0")r+=e,s+=2;else if(i>="1"&&i<="9"){let o=parseInt(i,10)-1;r+=n[o]||"",s+=2}else i==="n"?(r+=`
269
- `,s+=2):i==="t"?(r+=" ",s+=2):(r+=i,s+=2)}else t[s]==="&"?(r+=e,s++):(r+=t[s],s++);return r}async function Oh(t,e,n){return t.length===0?"":be(await n.evalExpr(t[0])).toLowerCase()}async function Dh(t,e,n){return t.length===0?"":be(await n.evalExpr(t[0])).toUpperCase()}async function Lh(t,e,n){if(t.length===0)return"";let r=be(await n.evalExpr(t[0])),s=[];for(let i=1;i<t.length;i++)s.push(await n.evalExpr(t[i]));return Es(r,s)}async function Mh(t,e,n){return t.length===0?0:Math.floor(Ge(await n.evalExpr(t[0])))}async function _h(t,e,n){return t.length===0?0:Math.sqrt(Ge(await n.evalExpr(t[0])))}async function Bh(t,e,n){return t.length===0?0:Math.sin(Ge(await n.evalExpr(t[0])))}async function Wh(t,e,n){return t.length===0?0:Math.cos(Ge(await n.evalExpr(t[0])))}async function Uh(t,e,n){let r=t.length>0?Ge(await n.evalExpr(t[0])):0,s=t.length>1?Ge(await n.evalExpr(t[1])):0;return Math.atan2(r,s)}async function jh(t,e,n){return t.length===0?0:Math.log(Ge(await n.evalExpr(t[0])))}async function zh(t,e,n){return t.length===0?1:Math.exp(Ge(await n.evalExpr(t[0])))}function Hh(t,e,n){return e.random?e.random():Math.random()}async function Gh(t,e,n){let r=t.length>0?Ge(await n.evalExpr(t[0])):Date.now();return e.vars._srand_seed=r,r}function ws(t,e){return()=>{throw new Error(`${t}() is not supported - ${e}`)}}function bs(t){return()=>{throw new Error(`function '${t}()' is not implemented`)}}function Es(t,e){let n=0,r="",s=0;for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let i=s+1,o="",a="",l="";for(;i<t.length&&/[-+ #0]/.test(t[i]);)o+=t[i++];for(;i<t.length&&/\d/.test(t[i]);)a+=t[i++];if(t[i]===".")for(i++;i<t.length&&/\d/.test(t[i]);)l+=t[i++];let c=t[i],u=e[n];switch(c){case"s":{let f=u!==void 0?String(u):"";if(l&&(f=f.substring(0,parseInt(l,10))),a){let d=parseInt(a,10);o.includes("-")?f=f.padEnd(d):f=f.padStart(d)}r+=f,n++;break}case"d":case"i":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=String(f);if(a){let p=parseInt(a,10);if(o.includes("-"))d=d.padEnd(p);else if(o.includes("0")&&!o.includes("-")){let h=f<0?"-":"";d=h+Math.abs(f).toString().padStart(p-h.length,"0")}else d=d.padStart(p)}r+=d,n++;break}case"f":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f.toFixed(d);if(a){let h=parseInt(a,10);o.includes("-")?p=p.padEnd(h):p=p.padStart(h)}r+=p,n++;break}case"e":case"E":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f.toExponential(d);if(c==="E"&&(p=p.toUpperCase()),a){let h=parseInt(a,10);o.includes("-")?p=p.padEnd(h):p=p.padStart(h)}r+=p,n++;break}case"g":case"G":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f!==0?Math.floor(Math.log10(Math.abs(f))):0,h;if(f===0?h="0":p<-4||p>=d?(h=f.toExponential(d-1),c==="G"&&(h=h.toUpperCase())):h=f.toPrecision(d),h=h.replace(/\.?0+$/,"").replace(/\.?0+e/,"e"),a){let m=parseInt(a,10);o.includes("-")?h=h.padEnd(m):h=h.padStart(m)}r+=h,n++;break}case"x":case"X":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=Math.abs(f).toString(16);if(c==="X"&&(d=d.toUpperCase()),a){let p=parseInt(a,10);o.includes("0")?d=d.padStart(p,"0"):o.includes("-")?d=d.padEnd(p):d=d.padStart(p)}r+=f<0?`-${d}`:d,n++;break}case"o":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=Math.abs(f).toString(8);if(a){let p=parseInt(a,10);o.includes("0")?d=d.padStart(p,"0"):o.includes("-")?d=d.padEnd(p):d=d.padStart(p)}r+=f<0?`-${d}`:d,n++;break}case"c":{typeof u=="number"?r+=String.fromCharCode(u):r+=String(u??"").charAt(0)||"",n++;break}case"%":r+="%";break;default:r+=t.substring(s,i+1)}s=i+1}else if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];switch(i){case"n":r+=`
270
- `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;default:r+=i}s+=2}else r+=t[s++];return r}var $a,Ss=C(()=>{"use strict";$a={length:Nh,substr:Ih,index:vh,split:$h,sub:Rh,gsub:Ph,match:Fh,gensub:Th,tolower:Oh,toupper:Dh,sprintf:Lh,int:Mh,sqrt:_h,sin:Bh,cos:Wh,atan2:Uh,log:jh,exp:zh,rand:Hh,srand:Gh,system:ws("system","shell execution not allowed in sandboxed environment"),close:ws("close","file operations not allowed"),fflush:ws("fflush","file operations not allowed"),systime:bs("systime"),mktime:bs("mktime"),strftime:bs("strftime")}});function Me(t){return typeof t=="number"?t!==0:t!==""}function Q(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function Y(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}function Cs(t){if(typeof t=="number")return!0;let e=String(t).trim();return e===""?!1:!Number.isNaN(Number(e))}function Cn(t,e){try{return new RegExp(t).test(e)}catch{return!1}}var Kt=C(()=>{"use strict"});function Ra(t,e){return t.FS===" "?e.trim().split(/\s+/).filter(Boolean):e.split(t.fieldSep)}function It(t,e){return e===0?t.line:e<0||e>t.fields.length?"":t.fields[e-1]??""}function Qt(t,e,n){if(e===0)t.line=Y(n),t.fields=Ra(t,t.line),t.NF=t.fields.length;else if(e>0){for(;t.fields.length<e;)t.fields.push("");t.fields[e-1]=Y(n),t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}}function An(t,e){t.line=e,t.fields=Ra(t,e),t.NF=t.fields.length}function Pa(t,e){if(t.FS=e,e===" ")t.fieldSep=/\s+/;else try{t.fieldSep=new RegExp(e)}catch{t.fieldSep=new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var ar=C(()=>{"use strict";Kt()});function vt(t,e){switch(e){case"FS":return t.FS;case"OFS":return t.OFS;case"ORS":return t.ORS;case"NR":return t.NR;case"NF":return t.NF;case"FNR":return t.FNR;case"FILENAME":return t.FILENAME;case"RSTART":return t.RSTART;case"RLENGTH":return t.RLENGTH;case"SUBSEP":return t.SUBSEP;case"ARGC":return t.ARGC}return t.vars[e]??""}function gt(t,e,n){switch(e){case"FS":Pa(t,Y(n));return;case"OFS":t.OFS=Y(n);return;case"ORS":t.ORS=Y(n);return;case"NR":t.NR=Math.floor(Q(n));return;case"NF":{let r=Math.floor(Q(n));if(r<t.NF)t.fields=t.fields.slice(0,r),t.line=t.fields.join(t.OFS);else if(r>t.NF){for(;t.fields.length<r;)t.fields.push("");t.line=t.fields.join(t.OFS)}t.NF=r;return}case"FNR":t.FNR=Math.floor(Q(n));return;case"FILENAME":t.FILENAME=Y(n);return;case"RSTART":t.RSTART=Math.floor(Q(n));return;case"RLENGTH":t.RLENGTH=Math.floor(Q(n));return;case"SUBSEP":t.SUBSEP=Y(n);return}t.vars[e]=n}function $t(t,e,n){return e==="ARGV"?t.ARGV[n]??"":t.arrays[e]?.[n]??""}function Xt(t,e,n,r){t.arrays[e]||(t.arrays[e]={}),t.arrays[e][n]=r}function Fa(t,e,n){return e==="ARGV"?t.ARGV[n]!==void 0:t.arrays[e]?.[n]!==void 0}function Ta(t,e,n){t.arrays[e]&&delete t.arrays[e][n]}function Oa(t,e){delete t.arrays[e]}var As=C(()=>{"use strict";ar();Kt()});function Da(t){ks=t}async function G(t,e){switch(e.type){case"number":return e.value;case"string":return e.value;case"regex":return Cn(e.pattern,t.line)?1:0;case"field":return qh(t,e);case"variable":return vt(t,e.name);case"array_access":return Vh(t,e);case"binary":return Zh(t,e);case"unary":return Xh(t,e);case"ternary":return Me(await G(t,e.condition))?G(t,e.consequent):G(t,e.alternate);case"call":return Jh(t,e.name,e.args);case"assignment":return em(t,e);case"pre_increment":return tm(t,e.operand);case"pre_decrement":return nm(t,e.operand);case"post_increment":return rm(t,e.operand);case"post_decrement":return sm(t,e.operand);case"in":return im(t,e.key,e.array);case"getline":return om(t,e.variable,e.file);case"tuple":return lm(t,e.elements);default:return""}}async function qh(t,e){let n=Math.floor(Q(await G(t,e.index)));return It(t,n)}async function Vh(t,e){let n=Y(await G(t,e.key));return $t(t,e.array,n)}async function Zh(t,e){let n=e.operator;if(n==="||")return Me(await G(t,e.left))||Me(await G(t,e.right))?1:0;if(n==="&&")return Me(await G(t,e.left))&&Me(await G(t,e.right))?1:0;if(n==="~"){let a=await G(t,e.left),l=e.right.type==="regex"?e.right.pattern:Y(await G(t,e.right));try{return new RegExp(l).test(Y(a))?1:0}catch{return 0}}if(n==="!~"){let a=await G(t,e.left),l=e.right.type==="regex"?e.right.pattern:Y(await G(t,e.right));try{return new RegExp(l).test(Y(a))?0:1}catch{return 1}}let r=await G(t,e.left),s=await G(t,e.right);if(n===" ")return Y(r)+Y(s);if(Kh(n))return Qh(r,s,n);let i=Q(r),o=Q(s);return ka(i,o,n)}function Kh(t){return["<","<=",">",">=","==","!="].includes(t)}function Qh(t,e,n){let r=Cs(t),s=Cs(e);if(r&&s){let a=Q(t),l=Q(e);switch(n){case"<":return a<l?1:0;case"<=":return a<=l?1:0;case">":return a>l?1:0;case">=":return a>=l?1:0;case"==":return a===l?1:0;case"!=":return a!==l?1:0}}let i=Y(t),o=Y(e);switch(n){case"<":return i<o?1:0;case"<=":return i<=o?1:0;case">":return i>o?1:0;case">=":return i>=o?1:0;case"==":return i===o?1:0;case"!=":return i!==o?1:0}return 0}async function Xh(t,e){let n=await G(t,e.operand);switch(e.operator){case"!":return Me(n)?0:1;case"-":return-Q(n);case"+":return+Q(n);default:return n}}async function Jh(t,e,n){let r=$a[e];if(r)return r(n,t,{evalExpr:i=>G(t,i)});let s=t.functions.get(e);return s?Yh(t,s,n):""}async function Yh(t,e,n){if(t.currentRecursionDepth++,t.currentRecursionDepth>t.maxRecursionDepth)throw t.currentRecursionDepth--,new V(`awk: recursion depth exceeded maximum (${t.maxRecursionDepth})`,"recursion",t.output);let r={};for(let i of e.params)r[i]=t.vars[i];for(let i=0;i<e.params.length;i++){let o=e.params[i],a=i<n.length?await G(t,n[i]):"";t.vars[o]=a}t.hasReturn=!1,t.returnValue=void 0,ks&&await ks(t,e.body.statements);let s=t.returnValue??"";for(let i of e.params)r[i]!==void 0?t.vars[i]=r[i]:delete t.vars[i];return t.hasReturn=!1,t.returnValue=void 0,t.currentRecursionDepth--,s}async function em(t,e){let n=await G(t,e.value),r=e.target,s=e.operator,i;if(s==="=")i=n;else{let o;if(r.type==="field"){let c=Math.floor(Q(await G(t,r.index)));o=It(t,c)}else if(r.type==="variable")o=vt(t,r.name);else{let c=Y(await G(t,r.key));o=$t(t,r.array,c)}let a=Q(o),l=Q(n);switch(s){case"+=":i=a+l;break;case"-=":i=a-l;break;case"*=":i=a*l;break;case"/=":i=l!==0?a/l:0;break;case"%=":i=l!==0?a%l:0;break;case"^=":i=a**l;break;default:i=n}}if(r.type==="field"){let o=Math.floor(Q(await G(t,r.index)));Qt(t,o,i)}else if(r.type==="variable")gt(t,r.name,i);else{let o=Y(await G(t,r.key));Xt(t,r.array,o,i)}return i}async function tm(t,e){let n;if(e.type==="field"){let r=Math.floor(Q(await G(t,e.index)));n=Q(It(t,r))+1,Qt(t,r,n)}else if(e.type==="variable")n=Q(vt(t,e.name))+1,gt(t,e.name,n);else{let r=Y(await G(t,e.key));n=Q($t(t,e.array,r))+1,Xt(t,e.array,r,n)}return n}async function nm(t,e){let n;if(e.type==="field"){let r=Math.floor(Q(await G(t,e.index)));n=Q(It(t,r))-1,Qt(t,r,n)}else if(e.type==="variable")n=Q(vt(t,e.name))-1,gt(t,e.name,n);else{let r=Y(await G(t,e.key));n=Q($t(t,e.array,r))-1,Xt(t,e.array,r,n)}return n}async function rm(t,e){let n;if(e.type==="field"){let r=Math.floor(Q(await G(t,e.index)));n=Q(It(t,r)),Qt(t,r,n+1)}else if(e.type==="variable")n=Q(vt(t,e.name)),gt(t,e.name,n+1);else{let r=Y(await G(t,e.key));n=Q($t(t,e.array,r)),Xt(t,e.array,r,n+1)}return n}async function sm(t,e){let n;if(e.type==="field"){let r=Math.floor(Q(await G(t,e.index)));n=Q(It(t,r)),Qt(t,r,n-1)}else if(e.type==="variable")n=Q(vt(t,e.name)),gt(t,e.name,n-1);else{let r=Y(await G(t,e.key));n=Q($t(t,e.array,r)),Xt(t,e.array,r,n-1)}return n}async function im(t,e,n){let r;if(e.type==="tuple"){let s=[];for(let i of e.elements)s.push(Y(await G(t,i)));r=s.join(t.SUBSEP)}else r=Y(await G(t,e));return Fa(t,n,r)?1:0}async function om(t,e,n){if(n)return am(t,e,n);if(!t.lines||t.lineIndex===void 0)return-1;let r=t.lineIndex+1;if(r>=t.lines.length)return 0;let s=t.lines[r];return e?gt(t,e,s):An(t,s),t.NR++,t.lineIndex=r,1}async function am(t,e,n){if(!t.fs||!t.cwd)return-1;let r=Y(await G(t,n)),s=t.fs.resolvePath(t.cwd,r),i=`__fc_${s}`,o=`__fi_${s}`,a,l;if(t.vars[i]===void 0)try{a=(await t.fs.readFile(s)).split(`
271
- `),a.length>0&&a[a.length-1]===""&&a.pop(),t.vars[i]=JSON.stringify(a),t.vars[o]=-1,l=-1}catch{return-1}else a=JSON.parse(t.vars[i]),l=t.vars[o];let c=l+1;if(c>=a.length)return 0;let u=a[c];return t.vars[o]=c,e?gt(t,e,u):An(t,u),1}async function lm(t,e){if(e.length===0)return"";for(let n=0;n<e.length-1;n++)await G(t,e[n]);return G(t,e[e.length-1])}var ks,Ns=C(()=>{"use strict";fe();Na();Ss();ar();Kt();As();ks=null});async function Jt(t,e){for(let n of e)if(await Rt(t,n),cm(t))break}function cm(t){return t.shouldExit||t.shouldNext||t.shouldNextFile||t.loopBreak||t.loopContinue||t.hasReturn}async function Rt(t,e){switch(e.type){case"block":await Jt(t,e.statements);break;case"expr_stmt":await G(t,e.expression);break;case"print":await um(t,e.args,e.output);break;case"printf":await fm(t,e.format,e.args,e.output);break;case"if":await dm(t,e);break;case"while":await pm(t,e);break;case"do_while":await hm(t,e);break;case"for":await mm(t,e);break;case"for_in":await gm(t,e);break;case"break":t.loopBreak=!0;break;case"continue":t.loopContinue=!0;break;case"next":t.shouldNext=!0;break;case"nextfile":t.shouldNextFile=!0;break;case"exit":t.shouldExit=!0,t.exitCode=e.code?Math.floor(Q(await G(t,e.code))):0;break;case"return":t.hasReturn=!0,t.returnValue=e.value?await G(t,e.value):"";break;case"delete":await ym(t,e.target);break}}async function um(t,e,n){let r=[];for(let i of e)r.push(Y(await G(t,i)));let s=r.join(t.OFS)+t.ORS;n?await La(t,n.redirect,n.file,s):t.output+=s}async function fm(t,e,n,r){let s=Y(await G(t,e)),i=[];for(let a of n)i.push(await G(t,a));let o=Es(s,i);r?await La(t,r.redirect,r.file,o):t.output+=o}async function La(t,e,n,r){if(!t.fs||!t.cwd){t.output+=r;return}let s=Y(await G(t,n)),i=t.fs.resolvePath(t.cwd,s);e===">"?t.openedFiles.has(i)?await t.fs.appendFile(i,r):(await t.fs.writeFile(i,r),t.openedFiles.add(i)):(t.openedFiles.has(i)||t.openedFiles.add(i),await t.fs.appendFile(i,r))}async function dm(t,e){Me(await G(t,e.condition))?await Rt(t,e.consequent):e.alternate&&await Rt(t,e.alternate)}async function pm(t,e){let n=0;for(;Me(await G(t,e.condition));){if(n++,n>t.maxIterations)throw new V(`awk: while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await Rt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function hm(t,e){let n=0;do{if(n++,n>t.maxIterations)throw new V(`awk: do-while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await Rt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}while(Me(await G(t,e.condition)))}async function mm(t,e){e.init&&await G(t,e.init);let n=0;for(;!e.condition||Me(await G(t,e.condition));){if(n++,n>t.maxIterations)throw new V(`awk: for loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await Rt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break;e.update&&await G(t,e.update)}}async function gm(t,e){let n=t.arrays[e.array];if(n)for(let r of Object.keys(n)){if(t.vars[e.variable]=r,t.loopContinue=!1,await Rt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function ym(t,e){if(e.type==="array_access"){let n=Y(await G(t,e.key));Ta(t,e.array,n)}else e.type==="variable"&&Oa(t,e.name)}var Ma=C(()=>{"use strict";fe();Ss();Ns();Kt();As();Da(Jt)});var kn,_a=C(()=>{"use strict";Ns();ar();Kt();Ma();kn=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}execute(e){this.program=e,this.ctx.output="";for(let n of e.functions)this.ctx.functions.set(n.name,n);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let e of this.program.rules)if(e.pattern?.type==="begin"&&(await Jt(this.ctx,e.action.statements),this.ctx.shouldExit))break}}async executeLine(e){if(!(!this.program||this.ctx.shouldExit)){An(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let n=0;n<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);n++){let r=this.program.rules[n];r.pattern?.type==="begin"||r.pattern?.type==="end"||await this.matchesRule(r,n)&&await Jt(this.ctx,r.action.statements)}}}async executeEnd(){if(!(!this.program||this.ctx.shouldExit)){for(let e of this.program.rules)if(e.pattern?.type==="end"&&(await Jt(this.ctx,e.action.statements),this.ctx.shouldExit))break}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,n){let r=e.pattern;if(!r)return!0;switch(r.type){case"begin":case"end":return!1;case"regex_pattern":return Cn(r.pattern,this.ctx.line);case"expr_pattern":return Me(await G(this.ctx,r.expression));case"range":{let s=await this.matchPattern(r.start),i=await this.matchPattern(r.end);return this.rangeStates[n]?(i&&(this.rangeStates[n]=!1),!0):s?(this.rangeStates[n]=!0,i&&(this.rangeStates[n]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(e.type){case"regex_pattern":return Cn(e.pattern,this.ctx.line);case"expr_pattern":return Me(await G(this.ctx,e.expression));default:return!1}}}});var Ba=C(()=>{"use strict";Aa();_a()});function wm(t){return t.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var x,xm,lr,Wa=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.STRING="STRING",t.REGEX="REGEX",t.IDENT="IDENT",t.BEGIN="BEGIN",t.END="END",t.IF="IF",t.ELSE="ELSE",t.WHILE="WHILE",t.DO="DO",t.FOR="FOR",t.IN="IN",t.BREAK="BREAK",t.CONTINUE="CONTINUE",t.NEXT="NEXT",t.NEXTFILE="NEXTFILE",t.EXIT="EXIT",t.RETURN="RETURN",t.DELETE="DELETE",t.FUNCTION="FUNCTION",t.PRINT="PRINT",t.PRINTF="PRINTF",t.GETLINE="GETLINE",t.PLUS="PLUS",t.MINUS="MINUS",t.STAR="STAR",t.SLASH="SLASH",t.PERCENT="PERCENT",t.CARET="CARET",t.EQ="EQ",t.NE="NE",t.LT="LT",t.GT="GT",t.LE="LE",t.GE="GE",t.MATCH="MATCH",t.NOT_MATCH="NOT_MATCH",t.AND="AND",t.OR="OR",t.NOT="NOT",t.ASSIGN="ASSIGN",t.PLUS_ASSIGN="PLUS_ASSIGN",t.MINUS_ASSIGN="MINUS_ASSIGN",t.STAR_ASSIGN="STAR_ASSIGN",t.SLASH_ASSIGN="SLASH_ASSIGN",t.PERCENT_ASSIGN="PERCENT_ASSIGN",t.CARET_ASSIGN="CARET_ASSIGN",t.INCREMENT="INCREMENT",t.DECREMENT="DECREMENT",t.QUESTION="QUESTION",t.COLON="COLON",t.COMMA="COMMA",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.LBRACKET="LBRACKET",t.RBRACKET="RBRACKET",t.DOLLAR="DOLLAR",t.APPEND="APPEND",t.PIPE="PIPE",t.EOF="EOF"})(x||(x={}));xm={BEGIN:x.BEGIN,END:x.END,if:x.IF,else:x.ELSE,while:x.WHILE,do:x.DO,for:x.FOR,in:x.IN,break:x.BREAK,continue:x.CONTINUE,next:x.NEXT,nextfile:x.NEXTFILE,exit:x.EXIT,return:x.RETURN,delete:x.DELETE,function:x.FUNCTION,print:x.PRINT,printf:x.PRINTF,getline:x.GETLINE};lr=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&(e.push(n),this.lastTokenType=n.type)}return e.push(this.makeToken(x.EOF,"")),e}makeToken(e,n){return{type:e,value:n,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
265
+ `,exitCode:1};let u="";if(a.length===0){u=e.stdin;try{let f=await ws(u,l,s,{limits:e.limits,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof Z)return{stdout:"",stderr:`sed: ${f.message}
266
+ `,exitCode:Z.EXIT_CODE};throw f}}if(i){for(let f of a){let d=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readFile(d),h=await ws(p,l,s,{limits:e.limits,filename:f,fs:e.fs,cwd:e.cwd});await e.fs.writeFile(d,h.output)}catch(p){return p instanceof Z?{stdout:"",stderr:`sed: ${p.message}
267
+ `,exitCode:Z.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
268
+ `,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}for(let f of a){let d=e.fs.resolvePath(e.cwd,f);try{u+=await e.fs.readFile(d)}catch(p){return p instanceof Z?{stdout:"",stderr:`sed: ${p.message}
269
+ `,exitCode:Z.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
270
+ `,exitCode:1}}}try{let f=await ws(u,l,s,{limits:e.limits,filename:a.length===1?a[0]:void 0,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof Z)return{stdout:"",stderr:`sed: ${f.message}
271
+ `,exitCode:Z.EXIT_CODE};throw f}}}});function bs(t={}){let{fieldSep:e=/\s+/,maxIterations:n=1e4,maxRecursionDepth:r=100,fs:s,cwd:i}=t;return{FS:" ",OFS:" ",ORS:`
272
+ `,NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:{},arrays:{},ARGC:0,ARGV:{},functions:new Map,fieldSep:e,maxIterations:n,maxRecursionDepth:r,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,output:"",openedFiles:new Set,fs:s,cwd:i}}var va=C(()=>{"use strict"});function $a(t,e,n){switch(n){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?t/e:0;case"%":return e!==0?t%e:0;case"^":case"**":return t**e;default:return 0}}var Ra=C(()=>{"use strict"});function Ge(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function be(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}async function Oh(t,e,n){return t.length===0?e.line.length:be(await n.evalExpr(t[0])).length}async function Dh(t,e,n){if(t.length<2)return"";let r=be(await n.evalExpr(t[0])),s=Math.floor(Ge(await n.evalExpr(t[1])))-1;if(t.length>=3){let i=Math.floor(Ge(await n.evalExpr(t[2])));return r.substr(Math.max(0,s),i)}return r.substr(Math.max(0,s))}async function Lh(t,e,n){if(t.length<2)return 0;let r=be(await n.evalExpr(t[0])),s=be(await n.evalExpr(t[1])),i=r.indexOf(s);return i===-1?0:i+1}async function Mh(t,e,n){if(t.length<2)return 0;let r=be(await n.evalExpr(t[0])),s=t[1];if(s.type!=="variable")return 0;let i=s.name,o=e.FS;if(t.length>=3){let l=be(await n.evalExpr(t[2]));o=l===" "?/\s+/:l}else e.FS===" "&&(o=/\s+/);let a=r.split(o);e.arrays[i]={};for(let l=0;l<a.length;l++)e.arrays[i][String(l+1)]=a[l];return a.length}async function _h(t,e,n){if(t.length<2)return 0;let r;t[0].type==="regex"?r=t[0].pattern:(r=be(await n.evalExpr(t[0])),r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)));let s=be(await n.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(Ge(await n.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=be(e.vars[i]??"");try{let a=new RegExp(r),l=o.replace(a,Pa(s)),c=l!==o?1:0;if(i==="$0")e.line=l,e.fields=e.FS===" "?l.trim().split(/\s+/).filter(Boolean):l.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let u=parseInt(i.slice(1),10)-1;for(;e.fields.length<=u;)e.fields.push("");e.fields[u]=l,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=l;return c}catch{return 0}}async function Bh(t,e,n){if(t.length<2)return 0;let r;t[0].type==="regex"?r=t[0].pattern:(r=be(await n.evalExpr(t[0])),r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)));let s=be(await n.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(Ge(await n.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=be(e.vars[i]??"");try{let a=new RegExp(r,"g"),l=o.match(a),c=l?l.length:0,u=o.replace(a,Pa(s));if(i==="$0")e.line=u,e.fields=e.FS===" "?u.trim().split(/\s+/).filter(Boolean):u.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let f=parseInt(i.slice(1),10)-1;for(;e.fields.length<=f;)e.fields.push("");e.fields[f]=u,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=u;return c}catch{return 0}}function Pa(t){return e=>{let n="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length){let s=t[r+1];s==="&"?(n+="&",r+=2):s==="\\"?(n+="\\",r+=2):(n+=t[r+1],r+=2)}else t[r]==="&"?(n+=e,r++):(n+=t[r],r++);return n}}async function Wh(t,e,n){if(t.length<2)return e.RSTART=0,e.RLENGTH=-1,0;let r=be(await n.evalExpr(t[0])),s;t[1].type==="regex"?s=t[1].pattern:(s=be(await n.evalExpr(t[1])),s.startsWith("/")&&s.endsWith("/")&&(s=s.slice(1,-1)));try{let o=new RegExp(s).exec(r);if(o)return e.RSTART=o.index+1,e.RLENGTH=o[0].length,e.RSTART}catch{}return e.RSTART=0,e.RLENGTH=-1,0}async function Uh(t,e,n){if(t.length<3)return"";let r;t[0].type==="regex"?r=t[0].pattern:(r=be(await n.evalExpr(t[0])),r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)));let s=be(await n.evalExpr(t[1])),i=be(await n.evalExpr(t[2])),o=t.length>=4?be(await n.evalExpr(t[3])):e.line;try{let a=i.toLowerCase()==="g",l=a?0:parseInt(i,10)||1;if(a){let c=new RegExp(r,"g");return o.replace(c,(u,...f)=>Fa(s,u,f.slice(0,-2)))}else{let c=0,u=new RegExp(r,"g");return o.replace(u,(f,...d)=>(c++,c===l?Fa(s,f,d.slice(0,-2)):f))}}catch{return o}}function Fa(t,e,n){let r="",s=0;for(;s<t.length;)if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&")r+="&",s+=2;else if(i==="0")r+=e,s+=2;else if(i>="1"&&i<="9"){let o=parseInt(i,10)-1;r+=n[o]||"",s+=2}else i==="n"?(r+=`
273
+ `,s+=2):i==="t"?(r+=" ",s+=2):(r+=i,s+=2)}else t[s]==="&"?(r+=e,s++):(r+=t[s],s++);return r}async function jh(t,e,n){return t.length===0?"":be(await n.evalExpr(t[0])).toLowerCase()}async function zh(t,e,n){return t.length===0?"":be(await n.evalExpr(t[0])).toUpperCase()}async function Hh(t,e,n){if(t.length===0)return"";let r=be(await n.evalExpr(t[0])),s=[];for(let i=1;i<t.length;i++)s.push(await n.evalExpr(t[i]));return Cs(r,s)}async function Gh(t,e,n){return t.length===0?0:Math.floor(Ge(await n.evalExpr(t[0])))}async function qh(t,e,n){return t.length===0?0:Math.sqrt(Ge(await n.evalExpr(t[0])))}async function Vh(t,e,n){return t.length===0?0:Math.sin(Ge(await n.evalExpr(t[0])))}async function Zh(t,e,n){return t.length===0?0:Math.cos(Ge(await n.evalExpr(t[0])))}async function Kh(t,e,n){let r=t.length>0?Ge(await n.evalExpr(t[0])):0,s=t.length>1?Ge(await n.evalExpr(t[1])):0;return Math.atan2(r,s)}async function Qh(t,e,n){return t.length===0?0:Math.log(Ge(await n.evalExpr(t[0])))}async function Xh(t,e,n){return t.length===0?1:Math.exp(Ge(await n.evalExpr(t[0])))}function Jh(t,e,n){return e.random?e.random():Math.random()}async function Yh(t,e,n){let r=t.length>0?Ge(await n.evalExpr(t[0])):Date.now();return e.vars._srand_seed=r,r}function Es(t,e){return()=>{throw new Error(`${t}() is not supported - ${e}`)}}function Ss(t){return()=>{throw new Error(`function '${t}()' is not implemented`)}}function Cs(t,e){let n=0,r="",s=0;for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let i=s+1,o="",a="",l="";for(;i<t.length&&/[-+ #0]/.test(t[i]);)o+=t[i++];for(;i<t.length&&/\d/.test(t[i]);)a+=t[i++];if(t[i]===".")for(i++;i<t.length&&/\d/.test(t[i]);)l+=t[i++];let c=t[i],u=e[n];switch(c){case"s":{let f=u!==void 0?String(u):"";if(l&&(f=f.substring(0,parseInt(l,10))),a){let d=parseInt(a,10);o.includes("-")?f=f.padEnd(d):f=f.padStart(d)}r+=f,n++;break}case"d":case"i":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=String(f);if(a){let p=parseInt(a,10);if(o.includes("-"))d=d.padEnd(p);else if(o.includes("0")&&!o.includes("-")){let h=f<0?"-":"";d=h+Math.abs(f).toString().padStart(p-h.length,"0")}else d=d.padStart(p)}r+=d,n++;break}case"f":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f.toFixed(d);if(a){let h=parseInt(a,10);o.includes("-")?p=p.padEnd(h):p=p.padStart(h)}r+=p,n++;break}case"e":case"E":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f.toExponential(d);if(c==="E"&&(p=p.toUpperCase()),a){let h=parseInt(a,10);o.includes("-")?p=p.padEnd(h):p=p.padStart(h)}r+=p,n++;break}case"g":case"G":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f!==0?Math.floor(Math.log10(Math.abs(f))):0,h;if(f===0?h="0":p<-4||p>=d?(h=f.toExponential(d-1),c==="G"&&(h=h.toUpperCase())):h=f.toPrecision(d),h=h.replace(/\.?0+$/,"").replace(/\.?0+e/,"e"),a){let m=parseInt(a,10);o.includes("-")?h=h.padEnd(m):h=h.padStart(m)}r+=h,n++;break}case"x":case"X":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=Math.abs(f).toString(16);if(c==="X"&&(d=d.toUpperCase()),a){let p=parseInt(a,10);o.includes("0")?d=d.padStart(p,"0"):o.includes("-")?d=d.padEnd(p):d=d.padStart(p)}r+=f<0?`-${d}`:d,n++;break}case"o":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=Math.abs(f).toString(8);if(a){let p=parseInt(a,10);o.includes("0")?d=d.padStart(p,"0"):o.includes("-")?d=d.padEnd(p):d=d.padStart(p)}r+=f<0?`-${d}`:d,n++;break}case"c":{typeof u=="number"?r+=String.fromCharCode(u):r+=String(u??"").charAt(0)||"",n++;break}case"%":r+="%";break;default:r+=t.substring(s,i+1)}s=i+1}else if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];switch(i){case"n":r+=`
274
+ `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;default:r+=i}s+=2}else r+=t[s++];return r}var Ta,As=C(()=>{"use strict";Ta={length:Oh,substr:Dh,index:Lh,split:Mh,sub:_h,gsub:Bh,match:Wh,gensub:Uh,tolower:jh,toupper:zh,sprintf:Hh,int:Gh,sqrt:qh,sin:Vh,cos:Zh,atan2:Kh,log:Qh,exp:Xh,rand:Jh,srand:Yh,system:Es("system","shell execution not allowed in sandboxed environment"),close:Es("close","file operations not allowed"),fflush:Es("fflush","file operations not allowed"),systime:Ss("systime"),mktime:Ss("mktime"),strftime:Ss("strftime")}});function Me(t){return typeof t=="number"?t!==0:t!==""}function X(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function Y(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}function ks(t){if(typeof t=="number")return!0;let e=String(t).trim();return e===""?!1:!Number.isNaN(Number(e))}function kn(t,e){try{return new RegExp(t).test(e)}catch{return!1}}var Qt=C(()=>{"use strict"});function Oa(t,e){return t.FS===" "?e.trim().split(/\s+/).filter(Boolean):e.split(t.fieldSep)}function vt(t,e){return e===0?t.line:e<0||e>t.fields.length?"":t.fields[e-1]??""}function Xt(t,e,n){if(e===0)t.line=Y(n),t.fields=Oa(t,t.line),t.NF=t.fields.length;else if(e>0){for(;t.fields.length<e;)t.fields.push("");t.fields[e-1]=Y(n),t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}}function Nn(t,e){t.line=e,t.fields=Oa(t,e),t.NF=t.fields.length}function Da(t,e){if(t.FS=e,e===" ")t.fieldSep=/\s+/;else try{t.fieldSep=new RegExp(e)}catch{t.fieldSep=new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var lr=C(()=>{"use strict";Qt()});function $t(t,e){switch(e){case"FS":return t.FS;case"OFS":return t.OFS;case"ORS":return t.ORS;case"NR":return t.NR;case"NF":return t.NF;case"FNR":return t.FNR;case"FILENAME":return t.FILENAME;case"RSTART":return t.RSTART;case"RLENGTH":return t.RLENGTH;case"SUBSEP":return t.SUBSEP;case"ARGC":return t.ARGC}return t.vars[e]??""}function yt(t,e,n){switch(e){case"FS":Da(t,Y(n));return;case"OFS":t.OFS=Y(n);return;case"ORS":t.ORS=Y(n);return;case"NR":t.NR=Math.floor(X(n));return;case"NF":{let r=Math.floor(X(n));if(r<t.NF)t.fields=t.fields.slice(0,r),t.line=t.fields.join(t.OFS);else if(r>t.NF){for(;t.fields.length<r;)t.fields.push("");t.line=t.fields.join(t.OFS)}t.NF=r;return}case"FNR":t.FNR=Math.floor(X(n));return;case"FILENAME":t.FILENAME=Y(n);return;case"RSTART":t.RSTART=Math.floor(X(n));return;case"RLENGTH":t.RLENGTH=Math.floor(X(n));return;case"SUBSEP":t.SUBSEP=Y(n);return}t.vars[e]=n}function Rt(t,e,n){return e==="ARGV"?t.ARGV[n]??"":t.arrays[e]?.[n]??""}function Jt(t,e,n,r){t.arrays[e]||(t.arrays[e]={}),t.arrays[e][n]=r}function La(t,e,n){return e==="ARGV"?t.ARGV[n]!==void 0:t.arrays[e]?.[n]!==void 0}function Ma(t,e,n){t.arrays[e]&&delete t.arrays[e][n]}function _a(t,e){delete t.arrays[e]}var Ns=C(()=>{"use strict";lr();Qt()});function Ba(t){Is=t}async function G(t,e){switch(e.type){case"number":return e.value;case"string":return e.value;case"regex":return kn(e.pattern,t.line)?1:0;case"field":return em(t,e);case"variable":return $t(t,e.name);case"array_access":return tm(t,e);case"binary":return nm(t,e);case"unary":return im(t,e);case"ternary":return Me(await G(t,e.condition))?G(t,e.consequent):G(t,e.alternate);case"call":return om(t,e.name,e.args);case"assignment":return lm(t,e);case"pre_increment":return cm(t,e.operand);case"pre_decrement":return um(t,e.operand);case"post_increment":return fm(t,e.operand);case"post_decrement":return dm(t,e.operand);case"in":return pm(t,e.key,e.array);case"getline":return hm(t,e.variable,e.file);case"tuple":return gm(t,e.elements);default:return""}}async function em(t,e){let n=Math.floor(X(await G(t,e.index)));return vt(t,n)}async function tm(t,e){let n=Y(await G(t,e.key));return Rt(t,e.array,n)}async function nm(t,e){let n=e.operator;if(n==="||")return Me(await G(t,e.left))||Me(await G(t,e.right))?1:0;if(n==="&&")return Me(await G(t,e.left))&&Me(await G(t,e.right))?1:0;if(n==="~"){let a=await G(t,e.left),l=e.right.type==="regex"?e.right.pattern:Y(await G(t,e.right));try{return new RegExp(l).test(Y(a))?1:0}catch{return 0}}if(n==="!~"){let a=await G(t,e.left),l=e.right.type==="regex"?e.right.pattern:Y(await G(t,e.right));try{return new RegExp(l).test(Y(a))?0:1}catch{return 1}}let r=await G(t,e.left),s=await G(t,e.right);if(n===" ")return Y(r)+Y(s);if(rm(n))return sm(r,s,n);let i=X(r),o=X(s);return $a(i,o,n)}function rm(t){return["<","<=",">",">=","==","!="].includes(t)}function sm(t,e,n){let r=ks(t),s=ks(e);if(r&&s){let a=X(t),l=X(e);switch(n){case"<":return a<l?1:0;case"<=":return a<=l?1:0;case">":return a>l?1:0;case">=":return a>=l?1:0;case"==":return a===l?1:0;case"!=":return a!==l?1:0}}let i=Y(t),o=Y(e);switch(n){case"<":return i<o?1:0;case"<=":return i<=o?1:0;case">":return i>o?1:0;case">=":return i>=o?1:0;case"==":return i===o?1:0;case"!=":return i!==o?1:0}return 0}async function im(t,e){let n=await G(t,e.operand);switch(e.operator){case"!":return Me(n)?0:1;case"-":return-X(n);case"+":return+X(n);default:return n}}async function om(t,e,n){let r=Ta[e];if(r)return r(n,t,{evalExpr:i=>G(t,i)});let s=t.functions.get(e);return s?am(t,s,n):""}async function am(t,e,n){if(t.currentRecursionDepth++,t.currentRecursionDepth>t.maxRecursionDepth)throw t.currentRecursionDepth--,new Z(`awk: recursion depth exceeded maximum (${t.maxRecursionDepth})`,"recursion",t.output);let r={};for(let i of e.params)r[i]=t.vars[i];for(let i=0;i<e.params.length;i++){let o=e.params[i],a=i<n.length?await G(t,n[i]):"";t.vars[o]=a}t.hasReturn=!1,t.returnValue=void 0,Is&&await Is(t,e.body.statements);let s=t.returnValue??"";for(let i of e.params)r[i]!==void 0?t.vars[i]=r[i]:delete t.vars[i];return t.hasReturn=!1,t.returnValue=void 0,t.currentRecursionDepth--,s}async function lm(t,e){let n=await G(t,e.value),r=e.target,s=e.operator,i;if(s==="=")i=n;else{let o;if(r.type==="field"){let c=Math.floor(X(await G(t,r.index)));o=vt(t,c)}else if(r.type==="variable")o=$t(t,r.name);else{let c=Y(await G(t,r.key));o=Rt(t,r.array,c)}let a=X(o),l=X(n);switch(s){case"+=":i=a+l;break;case"-=":i=a-l;break;case"*=":i=a*l;break;case"/=":i=l!==0?a/l:0;break;case"%=":i=l!==0?a%l:0;break;case"^=":i=a**l;break;default:i=n}}if(r.type==="field"){let o=Math.floor(X(await G(t,r.index)));Xt(t,o,i)}else if(r.type==="variable")yt(t,r.name,i);else{let o=Y(await G(t,r.key));Jt(t,r.array,o,i)}return i}async function cm(t,e){let n;if(e.type==="field"){let r=Math.floor(X(await G(t,e.index)));n=X(vt(t,r))+1,Xt(t,r,n)}else if(e.type==="variable")n=X($t(t,e.name))+1,yt(t,e.name,n);else{let r=Y(await G(t,e.key));n=X(Rt(t,e.array,r))+1,Jt(t,e.array,r,n)}return n}async function um(t,e){let n;if(e.type==="field"){let r=Math.floor(X(await G(t,e.index)));n=X(vt(t,r))-1,Xt(t,r,n)}else if(e.type==="variable")n=X($t(t,e.name))-1,yt(t,e.name,n);else{let r=Y(await G(t,e.key));n=X(Rt(t,e.array,r))-1,Jt(t,e.array,r,n)}return n}async function fm(t,e){let n;if(e.type==="field"){let r=Math.floor(X(await G(t,e.index)));n=X(vt(t,r)),Xt(t,r,n+1)}else if(e.type==="variable")n=X($t(t,e.name)),yt(t,e.name,n+1);else{let r=Y(await G(t,e.key));n=X(Rt(t,e.array,r)),Jt(t,e.array,r,n+1)}return n}async function dm(t,e){let n;if(e.type==="field"){let r=Math.floor(X(await G(t,e.index)));n=X(vt(t,r)),Xt(t,r,n-1)}else if(e.type==="variable")n=X($t(t,e.name)),yt(t,e.name,n-1);else{let r=Y(await G(t,e.key));n=X(Rt(t,e.array,r)),Jt(t,e.array,r,n-1)}return n}async function pm(t,e,n){let r;if(e.type==="tuple"){let s=[];for(let i of e.elements)s.push(Y(await G(t,i)));r=s.join(t.SUBSEP)}else r=Y(await G(t,e));return La(t,n,r)?1:0}async function hm(t,e,n){if(n)return mm(t,e,n);if(!t.lines||t.lineIndex===void 0)return-1;let r=t.lineIndex+1;if(r>=t.lines.length)return 0;let s=t.lines[r];return e?yt(t,e,s):Nn(t,s),t.NR++,t.lineIndex=r,1}async function mm(t,e,n){if(!t.fs||!t.cwd)return-1;let r=Y(await G(t,n)),s=t.fs.resolvePath(t.cwd,r),i=`__fc_${s}`,o=`__fi_${s}`,a,l;if(t.vars[i]===void 0)try{a=(await t.fs.readFile(s)).split(`
275
+ `),a.length>0&&a[a.length-1]===""&&a.pop(),t.vars[i]=JSON.stringify(a),t.vars[o]=-1,l=-1}catch{return-1}else a=JSON.parse(t.vars[i]),l=t.vars[o];let c=l+1;if(c>=a.length)return 0;let u=a[c];return t.vars[o]=c,e?yt(t,e,u):Nn(t,u),1}async function gm(t,e){if(e.length===0)return"";for(let n=0;n<e.length-1;n++)await G(t,e[n]);return G(t,e[e.length-1])}var Is,vs=C(()=>{"use strict";de();Ra();As();lr();Qt();Ns();Is=null});async function Yt(t,e){for(let n of e)if(await Ft(t,n),ym(t))break}function ym(t){return t.shouldExit||t.shouldNext||t.shouldNextFile||t.loopBreak||t.loopContinue||t.hasReturn}async function Ft(t,e){switch(e.type){case"block":await Yt(t,e.statements);break;case"expr_stmt":await G(t,e.expression);break;case"print":await xm(t,e.args,e.output);break;case"printf":await wm(t,e.format,e.args,e.output);break;case"if":await bm(t,e);break;case"while":await Em(t,e);break;case"do_while":await Sm(t,e);break;case"for":await Cm(t,e);break;case"for_in":await Am(t,e);break;case"break":t.loopBreak=!0;break;case"continue":t.loopContinue=!0;break;case"next":t.shouldNext=!0;break;case"nextfile":t.shouldNextFile=!0;break;case"exit":t.shouldExit=!0,t.exitCode=e.code?Math.floor(X(await G(t,e.code))):0;break;case"return":t.hasReturn=!0,t.returnValue=e.value?await G(t,e.value):"";break;case"delete":await km(t,e.target);break}}async function xm(t,e,n){let r=[];for(let i of e)r.push(Y(await G(t,i)));let s=r.join(t.OFS)+t.ORS;n?await Wa(t,n.redirect,n.file,s):t.output+=s}async function wm(t,e,n,r){let s=Y(await G(t,e)),i=[];for(let a of n)i.push(await G(t,a));let o=Cs(s,i);r?await Wa(t,r.redirect,r.file,o):t.output+=o}async function Wa(t,e,n,r){if(!t.fs||!t.cwd){t.output+=r;return}let s=Y(await G(t,n)),i=t.fs.resolvePath(t.cwd,s);e===">"?t.openedFiles.has(i)?await t.fs.appendFile(i,r):(await t.fs.writeFile(i,r),t.openedFiles.add(i)):(t.openedFiles.has(i)||t.openedFiles.add(i),await t.fs.appendFile(i,r))}async function bm(t,e){Me(await G(t,e.condition))?await Ft(t,e.consequent):e.alternate&&await Ft(t,e.alternate)}async function Em(t,e){let n=0;for(;Me(await G(t,e.condition));){if(n++,n>t.maxIterations)throw new Z(`awk: while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await Ft(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function Sm(t,e){let n=0;do{if(n++,n>t.maxIterations)throw new Z(`awk: do-while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await Ft(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}while(Me(await G(t,e.condition)))}async function Cm(t,e){e.init&&await G(t,e.init);let n=0;for(;!e.condition||Me(await G(t,e.condition));){if(n++,n>t.maxIterations)throw new Z(`awk: for loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await Ft(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break;e.update&&await G(t,e.update)}}async function Am(t,e){let n=t.arrays[e.array];if(n)for(let r of Object.keys(n)){if(t.vars[e.variable]=r,t.loopContinue=!1,await Ft(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function km(t,e){if(e.type==="array_access"){let n=Y(await G(t,e.key));Ma(t,e.array,n)}else e.type==="variable"&&_a(t,e.name)}var Ua=C(()=>{"use strict";de();As();vs();Qt();Ns();Ba(Yt)});var In,ja=C(()=>{"use strict";vs();lr();Qt();Ua();In=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}execute(e){this.program=e,this.ctx.output="";for(let n of e.functions)this.ctx.functions.set(n.name,n);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let e of this.program.rules)if(e.pattern?.type==="begin"&&(await Yt(this.ctx,e.action.statements),this.ctx.shouldExit))break}}async executeLine(e){if(!(!this.program||this.ctx.shouldExit)){Nn(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let n=0;n<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);n++){let r=this.program.rules[n];r.pattern?.type==="begin"||r.pattern?.type==="end"||await this.matchesRule(r,n)&&await Yt(this.ctx,r.action.statements)}}}async executeEnd(){if(!(!this.program||this.ctx.shouldExit)){for(let e of this.program.rules)if(e.pattern?.type==="end"&&(await Yt(this.ctx,e.action.statements),this.ctx.shouldExit))break}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,n){let r=e.pattern;if(!r)return!0;switch(r.type){case"begin":case"end":return!1;case"regex_pattern":return kn(r.pattern,this.ctx.line);case"expr_pattern":return Me(await G(this.ctx,r.expression));case"range":{let s=await this.matchPattern(r.start),i=await this.matchPattern(r.end);return this.rangeStates[n]?(i&&(this.rangeStates[n]=!1),!0):s?(this.rangeStates[n]=!0,i&&(this.rangeStates[n]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(e.type){case"regex_pattern":return kn(e.pattern,this.ctx.line);case"expr_pattern":return Me(await G(this.ctx,e.expression));default:return!1}}}});var za=C(()=>{"use strict";va();ja()});function Im(t){return t.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var x,Nm,cr,Ha=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.STRING="STRING",t.REGEX="REGEX",t.IDENT="IDENT",t.BEGIN="BEGIN",t.END="END",t.IF="IF",t.ELSE="ELSE",t.WHILE="WHILE",t.DO="DO",t.FOR="FOR",t.IN="IN",t.BREAK="BREAK",t.CONTINUE="CONTINUE",t.NEXT="NEXT",t.NEXTFILE="NEXTFILE",t.EXIT="EXIT",t.RETURN="RETURN",t.DELETE="DELETE",t.FUNCTION="FUNCTION",t.PRINT="PRINT",t.PRINTF="PRINTF",t.GETLINE="GETLINE",t.PLUS="PLUS",t.MINUS="MINUS",t.STAR="STAR",t.SLASH="SLASH",t.PERCENT="PERCENT",t.CARET="CARET",t.EQ="EQ",t.NE="NE",t.LT="LT",t.GT="GT",t.LE="LE",t.GE="GE",t.MATCH="MATCH",t.NOT_MATCH="NOT_MATCH",t.AND="AND",t.OR="OR",t.NOT="NOT",t.ASSIGN="ASSIGN",t.PLUS_ASSIGN="PLUS_ASSIGN",t.MINUS_ASSIGN="MINUS_ASSIGN",t.STAR_ASSIGN="STAR_ASSIGN",t.SLASH_ASSIGN="SLASH_ASSIGN",t.PERCENT_ASSIGN="PERCENT_ASSIGN",t.CARET_ASSIGN="CARET_ASSIGN",t.INCREMENT="INCREMENT",t.DECREMENT="DECREMENT",t.QUESTION="QUESTION",t.COLON="COLON",t.COMMA="COMMA",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.LBRACKET="LBRACKET",t.RBRACKET="RBRACKET",t.DOLLAR="DOLLAR",t.APPEND="APPEND",t.PIPE="PIPE",t.EOF="EOF"})(x||(x={}));Nm={BEGIN:x.BEGIN,END:x.END,if:x.IF,else:x.ELSE,while:x.WHILE,do:x.DO,for:x.FOR,in:x.IN,break:x.BREAK,continue:x.CONTINUE,next:x.NEXT,nextfile:x.NEXTFILE,exit:x.EXIT,return:x.RETURN,delete:x.DELETE,function:x.FUNCTION,print:x.PRINT,printf:x.PRINTF,getline:x.GETLINE};cr=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&(e.push(n),this.lastTokenType=n.type)}return e.push(this.makeToken(x.EOF,"")),e}makeToken(e,n){return{type:e,value:n,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
272
276
  `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===" "||e===" "||e==="\r")this.advance();else if(e==="\\")if(this.peek(1)===`
273
277
  `)this.advance(),this.advance();else break;else if(e==="#")for(;this.pos<this.input.length&&this.peek()!==`
274
278
  `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,n=this.column,r=this.peek();return r===`
275
279
  `?(this.advance(),{type:x.NEWLINE,value:`
276
280
  `,line:e,column:n}):r==='"'?this.readString():r==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(r)||r==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(r)||r==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,x.NEWLINE,x.SEMICOLON,x.LBRACE,x.RBRACE,x.LPAREN,x.LBRACKET,x.COMMA,x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN,x.AND,x.OR,x.NOT,x.MATCH,x.NOT_MATCH,x.QUESTION,x.COLON,x.LT,x.GT,x.LE,x.GE,x.EQ,x.NE,x.PLUS,x.MINUS,x.STAR,x.PERCENT,x.CARET,x.PRINT,x.PRINTF,x.IF,x.WHILE,x.DO,x.FOR,x.RETURN]).has(this.lastTokenType)}readString(){let e=this.line,n=this.column;this.advance();let r="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let s=this.advance();switch(s){case"n":r+=`
277
281
  `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case'"':r+='"';break;case"/":r+="/";break;default:r+=s}}else r+=this.advance();return this.peek()==='"'&&this.advance(),{type:x.STRING,value:r,line:e,column:n}}readRegex(){let e=this.line,n=this.column;this.advance();let r="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")r+=this.advance(),this.pos<this.input.length&&(r+=this.advance());else{if(this.peek()===`
278
- `)break;r+=this.advance()}return this.peek()==="/"&&this.advance(),r=wm(r),{type:x.REGEX,value:r,line:e,column:n}}readNumber(){let e=this.line,n=this.column,r="";for(;this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(r+=this.advance();this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(r+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(r+=this.advance());this.isDigit(this.peek());)r+=this.advance();return{type:x.NUMBER,value:parseFloat(r),line:e,column:n}}readIdentifier(){let e=this.line,n=this.column,r="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)r+=this.advance();let s=xm[r];return s?{type:s,value:r,line:e,column:n}:{type:x.IDENT,value:r,line:e,column:n}}readOperator(){let e=this.line,n=this.column,r=this.advance(),s=this.peek();switch(r){case"+":return s==="+"?(this.advance(),{type:x.INCREMENT,value:"++",line:e,column:n}):s==="="?(this.advance(),{type:x.PLUS_ASSIGN,value:"+=",line:e,column:n}):{type:x.PLUS,value:"+",line:e,column:n};case"-":return s==="-"?(this.advance(),{type:x.DECREMENT,value:"--",line:e,column:n}):s==="="?(this.advance(),{type:x.MINUS_ASSIGN,value:"-=",line:e,column:n}):{type:x.MINUS,value:"-",line:e,column:n};case"*":return s==="*"?(this.advance(),{type:x.CARET,value:"**",line:e,column:n}):s==="="?(this.advance(),{type:x.STAR_ASSIGN,value:"*=",line:e,column:n}):{type:x.STAR,value:"*",line:e,column:n};case"/":return s==="="?(this.advance(),{type:x.SLASH_ASSIGN,value:"/=",line:e,column:n}):{type:x.SLASH,value:"/",line:e,column:n};case"%":return s==="="?(this.advance(),{type:x.PERCENT_ASSIGN,value:"%=",line:e,column:n}):{type:x.PERCENT,value:"%",line:e,column:n};case"^":return s==="="?(this.advance(),{type:x.CARET_ASSIGN,value:"^=",line:e,column:n}):{type:x.CARET,value:"^",line:e,column:n};case"=":return s==="="?(this.advance(),{type:x.EQ,value:"==",line:e,column:n}):{type:x.ASSIGN,value:"=",line:e,column:n};case"!":return s==="="?(this.advance(),{type:x.NE,value:"!=",line:e,column:n}):s==="~"?(this.advance(),{type:x.NOT_MATCH,value:"!~",line:e,column:n}):{type:x.NOT,value:"!",line:e,column:n};case"<":return s==="="?(this.advance(),{type:x.LE,value:"<=",line:e,column:n}):{type:x.LT,value:"<",line:e,column:n};case">":return s==="="?(this.advance(),{type:x.GE,value:">=",line:e,column:n}):s===">"?(this.advance(),{type:x.APPEND,value:">>",line:e,column:n}):{type:x.GT,value:">",line:e,column:n};case"&":return s==="&"?(this.advance(),{type:x.AND,value:"&&",line:e,column:n}):{type:x.IDENT,value:"&",line:e,column:n};case"|":return s==="|"?(this.advance(),{type:x.OR,value:"||",line:e,column:n}):{type:x.PIPE,value:"|",line:e,column:n};case"~":return{type:x.MATCH,value:"~",line:e,column:n};case"?":return{type:x.QUESTION,value:"?",line:e,column:n};case":":return{type:x.COLON,value:":",line:e,column:n};case",":return{type:x.COMMA,value:",",line:e,column:n};case";":return{type:x.SEMICOLON,value:";",line:e,column:n};case"(":return{type:x.LPAREN,value:"(",line:e,column:n};case")":return{type:x.RPAREN,value:")",line:e,column:n};case"{":return{type:x.LBRACE,value:"{",line:e,column:n};case"}":return{type:x.RBRACE,value:"}",line:e,column:n};case"[":return{type:x.LBRACKET,value:"[",line:e,column:n};case"]":return{type:x.RBRACKET,value:"]",line:e,column:n};case"$":return{type:x.DOLLAR,value:"$",line:e,column:n};default:return{type:x.IDENT,value:r,line:e,column:n}}}isDigit(e){return e>="0"&&e<="9"}isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}}});var cr,Ua=C(()=>{"use strict";Wa();cr=class{tokens=[];pos=0;parse(e){let n=new lr(e);return this.tokens=n.tokenize(),this.pos=0,this.parseProgram()}current(){return this.tokens[this.pos]||{type:x.EOF,value:"",line:0,column:0}}advance(){let e=this.current();return this.pos<this.tokens.length&&this.pos++,e}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,n){if(!this.check(e)){let r=this.current();throw new Error(n||`Expected ${e}, got ${r.type} at line ${r.line}:${r.column}`)}return this.advance()}skipNewlines(){for(;this.check(x.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(x.NEWLINE)||this.check(x.SEMICOLON);)this.advance()}parseProgram(){let e=[],n=[];for(this.skipNewlines();!this.check(x.EOF)&&(this.skipNewlines(),!this.check(x.EOF));)this.check(x.FUNCTION)?e.push(this.parseFunction()):n.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:n}}parseFunction(){this.expect(x.FUNCTION);let e=this.expect(x.IDENT).value;this.expect(x.LPAREN);let n=[];if(!this.check(x.RPAREN))for(n.push(this.expect(x.IDENT).value);this.check(x.COMMA);)this.advance(),n.push(this.expect(x.IDENT).value);this.expect(x.RPAREN),this.skipNewlines();let r=this.parseBlock();return{name:e,params:n,body:r}}parseRule(){let e;if(this.check(x.BEGIN))this.advance(),e={type:"begin"};else if(this.check(x.END))this.advance(),e={type:"end"};else if(this.check(x.LBRACE))e=void 0;else if(this.check(x.REGEX)){let r=this.advance();if(this.check(x.AND)||this.check(x.OR)){let s={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:r.value}};e={type:"expr_pattern",expression:this.parseLogicalOrRest(s)}}else{let s={type:"regex_pattern",pattern:r.value};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}}else{let s={type:"expr_pattern",expression:this.parseExpression()};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}this.skipNewlines();let n;return this.check(x.LBRACE)?n=this.parseBlock():n={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:e,action:n}}parseBlock(){this.expect(x.LBRACE),this.skipNewlines();let e=[];for(;!this.check(x.RBRACE)&&!this.check(x.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(x.RBRACE),{type:"block",statements:e}}parseStatement(){if(this.check(x.LBRACE))return this.parseBlock();if(this.check(x.IF))return this.parseIf();if(this.check(x.WHILE))return this.parseWhile();if(this.check(x.DO))return this.parseDoWhile();if(this.check(x.FOR))return this.parseFor();if(this.check(x.BREAK))return this.advance(),{type:"break"};if(this.check(x.CONTINUE))return this.advance(),{type:"continue"};if(this.check(x.NEXT))return this.advance(),{type:"next"};if(this.check(x.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(x.EXIT)){this.advance();let n;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(n=this.parseExpression()),{type:"exit",code:n}}if(this.check(x.RETURN)){this.advance();let n;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(n=this.parseExpression()),{type:"return",value:n}}if(this.check(x.DELETE)){this.advance();let n=this.parsePrimary();if(n.type!=="array_access"&&n.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:n}}return this.check(x.PRINT)?this.parsePrint():this.check(x.PRINTF)?this.parsePrintf():{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(x.IF),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let n=this.parseStatement();this.skipTerminators();let r;return this.check(x.ELSE)&&(this.advance(),this.skipNewlines(),r=this.parseStatement()),{type:"if",condition:e,consequent:n,alternate:r}}parseWhile(){this.expect(x.WHILE),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:"while",condition:e,body:n}}parseDoWhile(){this.expect(x.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(x.WHILE),this.expect(x.LPAREN);let n=this.parseExpression();return this.expect(x.RPAREN),{type:"do_while",body:e,condition:n}}parseFor(){if(this.expect(x.FOR),this.expect(x.LPAREN),this.check(x.IDENT)){let i=this.advance();if(this.check(x.IN)){this.advance();let o=this.expect(x.IDENT).value;this.expect(x.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for_in",variable:i.value,array:o,body:a}}this.pos--}let e;this.check(x.SEMICOLON)||(e=this.parseExpression()),this.expect(x.SEMICOLON);let n;this.check(x.SEMICOLON)||(n=this.parseExpression()),this.expect(x.SEMICOLON);let r;this.check(x.RPAREN)||(r=this.parseExpression()),this.expect(x.RPAREN),this.skipNewlines();let s=this.parseStatement();return{type:"for",init:e,condition:n,update:r,body:s}}parsePrint(){this.expect(x.PRINT);let e=[];if(this.check(x.NEWLINE)||this.check(x.SEMICOLON)||this.check(x.RBRACE)||this.check(x.PIPE)||this.check(x.GT)||this.check(x.APPEND))e.push({type:"field",index:{type:"number",value:0}});else for(e.push(this.parsePrintArg());this.check(x.COMMA);)this.advance(),e.push(this.parsePrintArg());let n;return this.check(x.GT)?(this.advance(),n={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),n={redirect:">>",file:this.parsePrimary()}),{type:"print",args:e,output:n}}parsePrintArg(){return this.lookAheadForTernary()?this.parseTernary():this.parsePrintOr()}lookAheadForTernary(){let e=0,n=this.pos;for(;n<this.tokens.length;){let r=this.tokens[n];if(r.type===x.LPAREN&&e++,r.type===x.RPAREN&&e--,r.type===x.QUESTION&&e===0)return!0;if(r.type===x.NEWLINE||r.type===x.SEMICOLON||r.type===x.RBRACE||r.type===x.COMMA||r.type===x.PIPE)return!1;n++}return!1}parsePrintOr(){let e=this.parsePrintAnd();for(;this.check(x.OR);){this.advance();let n=this.parsePrintAnd();e={type:"binary",operator:"||",left:e,right:n}}return e}parsePrintAnd(){let e=this.parsePrintIn();for(;this.check(x.AND);){this.advance();let n=this.parsePrintIn();e={type:"binary",operator:"&&",left:e,right:n}}return e}parsePrintIn(){let e=this.parsePrintMatch();if(this.check(x.IN)){this.advance();let n=String(this.expect(x.IDENT).value);return{type:"in",key:e,array:n}}return e}parsePrintMatch(){let e=this.parsePrintComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let n=this.advance().type===x.MATCH?"~":"!~",r=this.parsePrintComparison();e={type:"binary",operator:n,left:e,right:r}}return e}parsePrintComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GE,x.EQ,x.NE);){let n=this.advance(),r=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">=":">=","==":"==","!=":"!="}[n.value],left:e,right:r}}return e}parsePrintf(){this.expect(x.PRINTF);let e=this.parsePrintArg(),n=[];for(;this.check(x.COMMA);)this.advance(),n.push(this.parsePrintArg());let r;return this.check(x.GT)?(this.advance(),r={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),r={redirect:">>",file:this.parsePrimary()}),{type:"printf",format:e,args:n,output:r}}parseExpression(){return this.parseAssignment()}parseAssignment(){let e=this.parseTernary();if(this.match(x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN)){let n=this.advance(),r=this.parseAssignment();if(e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[n.value],target:e,value:r}}return e}parseTernary(){let e=this.parseOr();if(this.check(x.QUESTION)){this.advance();let n=this.parseExpression();this.expect(x.COLON);let r=this.parseExpression();e={type:"ternary",condition:e,consequent:n,alternate:r}}return e}parseOr(){let e=this.parseAnd();for(;this.check(x.OR);){this.advance();let n=this.parseAnd();e={type:"binary",operator:"||",left:e,right:n}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(x.OR);){this.advance();let n=this.parseAnd();e={type:"binary",operator:"||",left:e,right:n}}return e}parseLogicalAndRest(e){for(;this.check(x.AND);){this.advance();let n=this.parseIn();e={type:"binary",operator:"&&",left:e,right:n}}return e}parseAnd(){let e=this.parseIn();for(;this.check(x.AND);){this.advance();let n=this.parseIn();e={type:"binary",operator:"&&",left:e,right:n}}return e}parseIn(){let e=this.parseMatch();if(this.check(x.IN)){this.advance();let n=this.expect(x.IDENT).value;return{type:"in",key:e,array:n}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let n=this.advance().type===x.MATCH?"~":"!~",r=this.parseComparison();e={type:"binary",operator:n,left:e,right:r}}return e}parseComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE);){let n=this.advance(),r=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">":">",">=":">=","==":"==","!=":"!="}[n.value],left:e,right:r}}return e}parseConcatenation(){let e=this.parseAddSub();for(;this.canStartExpression()&&!this.isComparisonOrHigherOp();){let n=this.parseAddSub();e={type:"binary",operator:" ",left:e,right:n}}return e}canStartExpression(){return this.match(x.NUMBER,x.STRING,x.IDENT,x.DOLLAR,x.LPAREN,x.NOT,x.MINUS,x.PLUS,x.INCREMENT,x.DECREMENT)}isComparisonOrHigherOp(){return this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE,x.AND,x.OR,x.QUESTION,x.MATCH,x.NOT_MATCH,x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN,x.COMMA,x.SEMICOLON,x.NEWLINE,x.RBRACE,x.RPAREN,x.RBRACKET,x.COLON,x.PIPE,x.APPEND,x.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(x.PLUS,x.MINUS);){let n=this.advance().value,r=this.parseMulDiv();e={type:"binary",operator:n,left:e,right:r}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(x.STAR,x.SLASH,x.PERCENT);){let n=this.advance(),r=this.parseUnary();e={type:"binary",operator:{"*":"*","/":"/","%":"%"}[n.value],left:e,right:r}}return e}parseUnary(){if(this.check(x.INCREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:e}}:{type:"pre_increment",operand:e}}if(this.check(x.DECREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:e}}:{type:"pre_decrement",operand:e}}if(this.match(x.NOT,x.MINUS,x.PLUS)){let e=this.advance().value,n=this.parseUnary();return{type:"unary",operator:e,operand:n}}return this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(x.CARET)){this.advance();let n=this.parsePower();e={type:"binary",operator:"^",left:e,right:n}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(x.INCREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:e}}if(this.check(x.DECREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:e}}return e}parsePrimary(){if(this.check(x.NUMBER))return{type:"number",value:this.advance().value};if(this.check(x.STRING))return{type:"string",value:this.advance().value};if(this.check(x.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(x.DOLLAR))return this.advance(),{type:"field",index:this.parsePrimary()};if(this.check(x.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(x.COMMA)){let n=[e];for(;this.check(x.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(x.RPAREN),{type:"tuple",elements:n}}return this.expect(x.RPAREN),e}if(this.check(x.GETLINE)){this.advance();let e,n;return this.check(x.IDENT)&&(e=this.advance().value),this.check(x.LT)&&(this.advance(),n=this.parsePrimary()),{type:"getline",variable:e,file:n}}if(this.check(x.IDENT)){let e=this.advance().value;if(this.check(x.LPAREN)){this.advance();let n=[];if(!this.check(x.RPAREN))for(n.push(this.parseExpression());this.check(x.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(x.RPAREN),{type:"call",name:e,args:n}}if(this.check(x.LBRACKET)){this.advance();let n=[this.parseExpression()];for(;this.check(x.COMMA);)this.advance(),n.push(this.parseExpression());this.expect(x.RBRACKET);let r;if(n.length===1)r=n[0];else{r=n[0];for(let s=1;s<n.length;s++)r={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:r,right:{type:"variable",name:"SUBSEP"}},right:n[s]}}return{type:"array_access",array:e,key:r}}return{type:"variable",name:e}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}}});var Ga={};L(Ga,{awkCommand2:()=>Em});function ja(t){return t.replace(/\\t/g," ").replace(/\\n/g,`
279
- `).replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function za(t){if(t===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(t))try{return new RegExp(t)}catch{return new RegExp(Ha(t))}return new RegExp(Ha(t))}function Ha(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var bm,Em,qa=C(()=>{"use strict";fe();j();Ba();Ua();bm={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},Em={name:"awk",async execute(t,e){if(I(t))return N(bm);let n=/\s+/,r=" ",s={},i=0;for(let p=0;p<t.length;p++){let h=t[p];if(h==="-F"&&p+1<t.length)r=ja(t[++p]),n=za(r),i=p+1;else if(h.startsWith("-F"))r=ja(h.slice(2)),n=za(r),i=p+1;else if(h==="-v"&&p+1<t.length){let m=t[++p],g=m.indexOf("=");if(g>0){let w=m.slice(0,g),b=m.slice(g+1);s[w]=b}i=p+1}else{if(h.startsWith("--"))return D("awk",h);if(h.startsWith("-")&&h.length>1){let m=h[1];if(m!=="F"&&m!=="v")return D("awk",`-${m}`);i=p+1}else if(!h.startsWith("-")){i=p;break}}}if(i>=t.length)return{stdout:"",stderr:`awk: missing program
280
- `,exitCode:1};let o=t[i],a=t.slice(i+1),l=new cr,c;try{c=l.parse(o)}catch(p){return{stdout:"",stderr:`awk: ${p instanceof Error?p.message:String(p)}
281
- `,exitCode:1}}let u={readFile:e.fs.readFile.bind(e.fs),writeFile:e.fs.writeFile.bind(e.fs),appendFile:async(p,h)=>{try{let m=await e.fs.readFile(p);await e.fs.writeFile(p,m+h)}catch{await e.fs.writeFile(p,h)}},resolvePath:e.fs.resolvePath.bind(e.fs)},f=xs({fieldSep:n,maxIterations:e.limits?.maxAwkIterations,fs:u,cwd:e.cwd});f.FS=r,f.vars={...s},f.ARGC=a.length+1,f.ARGV={0:"awk"};for(let p=0;p<a.length;p++)f.ARGV[String(p+1)]=a[p];let d=new kn(f);d.execute(c);try{if(await d.executeBegin(),f.shouldExit)return{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()};let p=[];if(a.length>0)for(let h of a)try{let m=e.fs.resolvePath(e.cwd,h),w=(await e.fs.readFile(m)).split(`
282
- `);w.length>0&&w[w.length-1]===""&&w.pop(),p.push({filename:h,lines:w})}catch{return{stdout:"",stderr:`awk: ${h}: No such file or directory
282
+ `)break;r+=this.advance()}return this.peek()==="/"&&this.advance(),r=Im(r),{type:x.REGEX,value:r,line:e,column:n}}readNumber(){let e=this.line,n=this.column,r="";for(;this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(r+=this.advance();this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(r+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(r+=this.advance());this.isDigit(this.peek());)r+=this.advance();return{type:x.NUMBER,value:parseFloat(r),line:e,column:n}}readIdentifier(){let e=this.line,n=this.column,r="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)r+=this.advance();let s=Nm[r];return s?{type:s,value:r,line:e,column:n}:{type:x.IDENT,value:r,line:e,column:n}}readOperator(){let e=this.line,n=this.column,r=this.advance(),s=this.peek();switch(r){case"+":return s==="+"?(this.advance(),{type:x.INCREMENT,value:"++",line:e,column:n}):s==="="?(this.advance(),{type:x.PLUS_ASSIGN,value:"+=",line:e,column:n}):{type:x.PLUS,value:"+",line:e,column:n};case"-":return s==="-"?(this.advance(),{type:x.DECREMENT,value:"--",line:e,column:n}):s==="="?(this.advance(),{type:x.MINUS_ASSIGN,value:"-=",line:e,column:n}):{type:x.MINUS,value:"-",line:e,column:n};case"*":return s==="*"?(this.advance(),{type:x.CARET,value:"**",line:e,column:n}):s==="="?(this.advance(),{type:x.STAR_ASSIGN,value:"*=",line:e,column:n}):{type:x.STAR,value:"*",line:e,column:n};case"/":return s==="="?(this.advance(),{type:x.SLASH_ASSIGN,value:"/=",line:e,column:n}):{type:x.SLASH,value:"/",line:e,column:n};case"%":return s==="="?(this.advance(),{type:x.PERCENT_ASSIGN,value:"%=",line:e,column:n}):{type:x.PERCENT,value:"%",line:e,column:n};case"^":return s==="="?(this.advance(),{type:x.CARET_ASSIGN,value:"^=",line:e,column:n}):{type:x.CARET,value:"^",line:e,column:n};case"=":return s==="="?(this.advance(),{type:x.EQ,value:"==",line:e,column:n}):{type:x.ASSIGN,value:"=",line:e,column:n};case"!":return s==="="?(this.advance(),{type:x.NE,value:"!=",line:e,column:n}):s==="~"?(this.advance(),{type:x.NOT_MATCH,value:"!~",line:e,column:n}):{type:x.NOT,value:"!",line:e,column:n};case"<":return s==="="?(this.advance(),{type:x.LE,value:"<=",line:e,column:n}):{type:x.LT,value:"<",line:e,column:n};case">":return s==="="?(this.advance(),{type:x.GE,value:">=",line:e,column:n}):s===">"?(this.advance(),{type:x.APPEND,value:">>",line:e,column:n}):{type:x.GT,value:">",line:e,column:n};case"&":return s==="&"?(this.advance(),{type:x.AND,value:"&&",line:e,column:n}):{type:x.IDENT,value:"&",line:e,column:n};case"|":return s==="|"?(this.advance(),{type:x.OR,value:"||",line:e,column:n}):{type:x.PIPE,value:"|",line:e,column:n};case"~":return{type:x.MATCH,value:"~",line:e,column:n};case"?":return{type:x.QUESTION,value:"?",line:e,column:n};case":":return{type:x.COLON,value:":",line:e,column:n};case",":return{type:x.COMMA,value:",",line:e,column:n};case";":return{type:x.SEMICOLON,value:";",line:e,column:n};case"(":return{type:x.LPAREN,value:"(",line:e,column:n};case")":return{type:x.RPAREN,value:")",line:e,column:n};case"{":return{type:x.LBRACE,value:"{",line:e,column:n};case"}":return{type:x.RBRACE,value:"}",line:e,column:n};case"[":return{type:x.LBRACKET,value:"[",line:e,column:n};case"]":return{type:x.RBRACKET,value:"]",line:e,column:n};case"$":return{type:x.DOLLAR,value:"$",line:e,column:n};default:return{type:x.IDENT,value:r,line:e,column:n}}}isDigit(e){return e>="0"&&e<="9"}isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}}});var ur,Ga=C(()=>{"use strict";Ha();ur=class{tokens=[];pos=0;parse(e){let n=new cr(e);return this.tokens=n.tokenize(),this.pos=0,this.parseProgram()}current(){return this.tokens[this.pos]||{type:x.EOF,value:"",line:0,column:0}}advance(){let e=this.current();return this.pos<this.tokens.length&&this.pos++,e}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,n){if(!this.check(e)){let r=this.current();throw new Error(n||`Expected ${e}, got ${r.type} at line ${r.line}:${r.column}`)}return this.advance()}skipNewlines(){for(;this.check(x.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(x.NEWLINE)||this.check(x.SEMICOLON);)this.advance()}parseProgram(){let e=[],n=[];for(this.skipNewlines();!this.check(x.EOF)&&(this.skipNewlines(),!this.check(x.EOF));)this.check(x.FUNCTION)?e.push(this.parseFunction()):n.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:n}}parseFunction(){this.expect(x.FUNCTION);let e=this.expect(x.IDENT).value;this.expect(x.LPAREN);let n=[];if(!this.check(x.RPAREN))for(n.push(this.expect(x.IDENT).value);this.check(x.COMMA);)this.advance(),n.push(this.expect(x.IDENT).value);this.expect(x.RPAREN),this.skipNewlines();let r=this.parseBlock();return{name:e,params:n,body:r}}parseRule(){let e;if(this.check(x.BEGIN))this.advance(),e={type:"begin"};else if(this.check(x.END))this.advance(),e={type:"end"};else if(this.check(x.LBRACE))e=void 0;else if(this.check(x.REGEX)){let r=this.advance();if(this.check(x.AND)||this.check(x.OR)){let s={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:r.value}};e={type:"expr_pattern",expression:this.parseLogicalOrRest(s)}}else{let s={type:"regex_pattern",pattern:r.value};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}}else{let s={type:"expr_pattern",expression:this.parseExpression()};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}this.skipNewlines();let n;return this.check(x.LBRACE)?n=this.parseBlock():n={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:e,action:n}}parseBlock(){this.expect(x.LBRACE),this.skipNewlines();let e=[];for(;!this.check(x.RBRACE)&&!this.check(x.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(x.RBRACE),{type:"block",statements:e}}parseStatement(){if(this.check(x.LBRACE))return this.parseBlock();if(this.check(x.IF))return this.parseIf();if(this.check(x.WHILE))return this.parseWhile();if(this.check(x.DO))return this.parseDoWhile();if(this.check(x.FOR))return this.parseFor();if(this.check(x.BREAK))return this.advance(),{type:"break"};if(this.check(x.CONTINUE))return this.advance(),{type:"continue"};if(this.check(x.NEXT))return this.advance(),{type:"next"};if(this.check(x.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(x.EXIT)){this.advance();let n;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(n=this.parseExpression()),{type:"exit",code:n}}if(this.check(x.RETURN)){this.advance();let n;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(n=this.parseExpression()),{type:"return",value:n}}if(this.check(x.DELETE)){this.advance();let n=this.parsePrimary();if(n.type!=="array_access"&&n.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:n}}return this.check(x.PRINT)?this.parsePrint():this.check(x.PRINTF)?this.parsePrintf():{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(x.IF),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let n=this.parseStatement();this.skipTerminators();let r;return this.check(x.ELSE)&&(this.advance(),this.skipNewlines(),r=this.parseStatement()),{type:"if",condition:e,consequent:n,alternate:r}}parseWhile(){this.expect(x.WHILE),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:"while",condition:e,body:n}}parseDoWhile(){this.expect(x.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(x.WHILE),this.expect(x.LPAREN);let n=this.parseExpression();return this.expect(x.RPAREN),{type:"do_while",body:e,condition:n}}parseFor(){if(this.expect(x.FOR),this.expect(x.LPAREN),this.check(x.IDENT)){let i=this.advance();if(this.check(x.IN)){this.advance();let o=this.expect(x.IDENT).value;this.expect(x.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for_in",variable:i.value,array:o,body:a}}this.pos--}let e;this.check(x.SEMICOLON)||(e=this.parseExpression()),this.expect(x.SEMICOLON);let n;this.check(x.SEMICOLON)||(n=this.parseExpression()),this.expect(x.SEMICOLON);let r;this.check(x.RPAREN)||(r=this.parseExpression()),this.expect(x.RPAREN),this.skipNewlines();let s=this.parseStatement();return{type:"for",init:e,condition:n,update:r,body:s}}parsePrint(){this.expect(x.PRINT);let e=[];if(this.check(x.NEWLINE)||this.check(x.SEMICOLON)||this.check(x.RBRACE)||this.check(x.PIPE)||this.check(x.GT)||this.check(x.APPEND))e.push({type:"field",index:{type:"number",value:0}});else for(e.push(this.parsePrintArg());this.check(x.COMMA);)this.advance(),e.push(this.parsePrintArg());let n;return this.check(x.GT)?(this.advance(),n={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),n={redirect:">>",file:this.parsePrimary()}),{type:"print",args:e,output:n}}parsePrintArg(){return this.lookAheadForTernary()?this.parseTernary():this.parsePrintOr()}lookAheadForTernary(){let e=0,n=this.pos;for(;n<this.tokens.length;){let r=this.tokens[n];if(r.type===x.LPAREN&&e++,r.type===x.RPAREN&&e--,r.type===x.QUESTION&&e===0)return!0;if(r.type===x.NEWLINE||r.type===x.SEMICOLON||r.type===x.RBRACE||r.type===x.COMMA||r.type===x.PIPE)return!1;n++}return!1}parsePrintOr(){let e=this.parsePrintAnd();for(;this.check(x.OR);){this.advance();let n=this.parsePrintAnd();e={type:"binary",operator:"||",left:e,right:n}}return e}parsePrintAnd(){let e=this.parsePrintIn();for(;this.check(x.AND);){this.advance();let n=this.parsePrintIn();e={type:"binary",operator:"&&",left:e,right:n}}return e}parsePrintIn(){let e=this.parsePrintMatch();if(this.check(x.IN)){this.advance();let n=String(this.expect(x.IDENT).value);return{type:"in",key:e,array:n}}return e}parsePrintMatch(){let e=this.parsePrintComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let n=this.advance().type===x.MATCH?"~":"!~",r=this.parsePrintComparison();e={type:"binary",operator:n,left:e,right:r}}return e}parsePrintComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GE,x.EQ,x.NE);){let n=this.advance(),r=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">=":">=","==":"==","!=":"!="}[n.value],left:e,right:r}}return e}parsePrintf(){this.expect(x.PRINTF);let e=this.parsePrintArg(),n=[];for(;this.check(x.COMMA);)this.advance(),n.push(this.parsePrintArg());let r;return this.check(x.GT)?(this.advance(),r={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),r={redirect:">>",file:this.parsePrimary()}),{type:"printf",format:e,args:n,output:r}}parseExpression(){return this.parseAssignment()}parseAssignment(){let e=this.parseTernary();if(this.match(x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN)){let n=this.advance(),r=this.parseAssignment();if(e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[n.value],target:e,value:r}}return e}parseTernary(){let e=this.parseOr();if(this.check(x.QUESTION)){this.advance();let n=this.parseExpression();this.expect(x.COLON);let r=this.parseExpression();e={type:"ternary",condition:e,consequent:n,alternate:r}}return e}parseOr(){let e=this.parseAnd();for(;this.check(x.OR);){this.advance();let n=this.parseAnd();e={type:"binary",operator:"||",left:e,right:n}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(x.OR);){this.advance();let n=this.parseAnd();e={type:"binary",operator:"||",left:e,right:n}}return e}parseLogicalAndRest(e){for(;this.check(x.AND);){this.advance();let n=this.parseIn();e={type:"binary",operator:"&&",left:e,right:n}}return e}parseAnd(){let e=this.parseIn();for(;this.check(x.AND);){this.advance();let n=this.parseIn();e={type:"binary",operator:"&&",left:e,right:n}}return e}parseIn(){let e=this.parseMatch();if(this.check(x.IN)){this.advance();let n=this.expect(x.IDENT).value;return{type:"in",key:e,array:n}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let n=this.advance().type===x.MATCH?"~":"!~",r=this.parseComparison();e={type:"binary",operator:n,left:e,right:r}}return e}parseComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE);){let n=this.advance(),r=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">":">",">=":">=","==":"==","!=":"!="}[n.value],left:e,right:r}}return e}parseConcatenation(){let e=this.parseAddSub();for(;this.canStartExpression()&&!this.isComparisonOrHigherOp();){let n=this.parseAddSub();e={type:"binary",operator:" ",left:e,right:n}}return e}canStartExpression(){return this.match(x.NUMBER,x.STRING,x.IDENT,x.DOLLAR,x.LPAREN,x.NOT,x.MINUS,x.PLUS,x.INCREMENT,x.DECREMENT)}isComparisonOrHigherOp(){return this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE,x.AND,x.OR,x.QUESTION,x.MATCH,x.NOT_MATCH,x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN,x.COMMA,x.SEMICOLON,x.NEWLINE,x.RBRACE,x.RPAREN,x.RBRACKET,x.COLON,x.PIPE,x.APPEND,x.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(x.PLUS,x.MINUS);){let n=this.advance().value,r=this.parseMulDiv();e={type:"binary",operator:n,left:e,right:r}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(x.STAR,x.SLASH,x.PERCENT);){let n=this.advance(),r=this.parseUnary();e={type:"binary",operator:{"*":"*","/":"/","%":"%"}[n.value],left:e,right:r}}return e}parseUnary(){if(this.check(x.INCREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:e}}:{type:"pre_increment",operand:e}}if(this.check(x.DECREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:e}}:{type:"pre_decrement",operand:e}}if(this.match(x.NOT,x.MINUS,x.PLUS)){let e=this.advance().value,n=this.parseUnary();return{type:"unary",operator:e,operand:n}}return this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(x.CARET)){this.advance();let n=this.parsePower();e={type:"binary",operator:"^",left:e,right:n}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(x.INCREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:e}}if(this.check(x.DECREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:e}}return e}parsePrimary(){if(this.check(x.NUMBER))return{type:"number",value:this.advance().value};if(this.check(x.STRING))return{type:"string",value:this.advance().value};if(this.check(x.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(x.DOLLAR))return this.advance(),{type:"field",index:this.parsePrimary()};if(this.check(x.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(x.COMMA)){let n=[e];for(;this.check(x.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(x.RPAREN),{type:"tuple",elements:n}}return this.expect(x.RPAREN),e}if(this.check(x.GETLINE)){this.advance();let e,n;return this.check(x.IDENT)&&(e=this.advance().value),this.check(x.LT)&&(this.advance(),n=this.parsePrimary()),{type:"getline",variable:e,file:n}}if(this.check(x.IDENT)){let e=this.advance().value;if(this.check(x.LPAREN)){this.advance();let n=[];if(!this.check(x.RPAREN))for(n.push(this.parseExpression());this.check(x.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(x.RPAREN),{type:"call",name:e,args:n}}if(this.check(x.LBRACKET)){this.advance();let n=[this.parseExpression()];for(;this.check(x.COMMA);)this.advance(),n.push(this.parseExpression());this.expect(x.RBRACKET);let r;if(n.length===1)r=n[0];else{r=n[0];for(let s=1;s<n.length;s++)r={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:r,right:{type:"variable",name:"SUBSEP"}},right:n[s]}}return{type:"array_access",array:e,key:r}}return{type:"variable",name:e}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}}});var Ka={};_(Ka,{awkCommand2:()=>$m});function qa(t){return t.replace(/\\t/g," ").replace(/\\n/g,`
283
+ `).replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function Va(t){if(t===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(t))try{return new RegExp(t)}catch{return new RegExp(Za(t))}return new RegExp(Za(t))}function Za(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var vm,$m,Qa=C(()=>{"use strict";de();j();za();Ga();vm={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},$m={name:"awk",async execute(t,e){if(N(t))return k(vm);let n=/\s+/,r=" ",s={},i=0;for(let p=0;p<t.length;p++){let h=t[p];if(h==="-F"&&p+1<t.length)r=qa(t[++p]),n=Va(r),i=p+1;else if(h.startsWith("-F"))r=qa(h.slice(2)),n=Va(r),i=p+1;else if(h==="-v"&&p+1<t.length){let m=t[++p],g=m.indexOf("=");if(g>0){let b=m.slice(0,g),w=m.slice(g+1);s[b]=w}i=p+1}else{if(h.startsWith("--"))return L("awk",h);if(h.startsWith("-")&&h.length>1){let m=h[1];if(m!=="F"&&m!=="v")return L("awk",`-${m}`);i=p+1}else if(!h.startsWith("-")){i=p;break}}}if(i>=t.length)return{stdout:"",stderr:`awk: missing program
284
+ `,exitCode:1};let o=t[i],a=t.slice(i+1),l=new ur,c;try{c=l.parse(o)}catch(p){return{stdout:"",stderr:`awk: ${p instanceof Error?p.message:String(p)}
285
+ `,exitCode:1}}let u={readFile:e.fs.readFile.bind(e.fs),writeFile:e.fs.writeFile.bind(e.fs),appendFile:async(p,h)=>{try{let m=await e.fs.readFile(p);await e.fs.writeFile(p,m+h)}catch{await e.fs.writeFile(p,h)}},resolvePath:e.fs.resolvePath.bind(e.fs)},f=bs({fieldSep:n,maxIterations:e.limits?.maxAwkIterations,fs:u,cwd:e.cwd});f.FS=r,f.vars={...s},f.ARGC=a.length+1,f.ARGV={0:"awk"};for(let p=0;p<a.length;p++)f.ARGV[String(p+1)]=a[p];let d=new In(f);d.execute(c);try{if(await d.executeBegin(),f.shouldExit)return{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()};let p=[];if(a.length>0)for(let h of a)try{let m=e.fs.resolvePath(e.cwd,h),b=(await e.fs.readFile(m)).split(`
286
+ `);b.length>0&&b[b.length-1]===""&&b.pop(),p.push({filename:h,lines:b})}catch{return{stdout:"",stderr:`awk: ${h}: No such file or directory
283
287
  `,exitCode:1}}else{let h=e.stdin.split(`
284
- `);h.length>0&&h[h.length-1]===""&&h.pop(),p.push({filename:"",lines:h})}for(let h of p){for(f.FILENAME=h.filename,f.FNR=0,f.lines=h.lines,f.lineIndex=-1,f.shouldNextFile=!1;f.lineIndex<h.lines.length-1&&(f.lineIndex++,await d.executeLine(h.lines[f.lineIndex]),!(f.shouldExit||f.shouldNextFile)););if(f.shouldExit)break}return f.shouldExit||await d.executeEnd(),{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()}}catch(p){let h=p instanceof Error?p.message:String(p),m=p instanceof V?V.EXIT_CODE:2;return{stdout:d.getOutput(),stderr:`awk: ${h}
285
- `,exitCode:m}}}}});function Va(t){let e=t.trim(),n=e.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!n){let o=parseFloat(e);return Number.isNaN(o)?0:o}let r=parseFloat(n[1]),s=(n[2]||"").toLowerCase(),i=Sm[s]||1;return r*i}function Za(t){let e=t.trim().toLowerCase().slice(0,3);return Cm[e]||0}function Am(t,e){let n=t.split(/(\d+)/),r=e.split(/(\d+)/),s=Math.max(n.length,r.length);for(let i=0;i<s;i++){let o=n[i]||"",a=r[i]||"",l=/^\d+$/.test(o)?parseInt(o,10):null,c=/^\d+$/.test(a)?parseInt(a,10):null;if(l!==null&&c!==null){if(l!==c)return l-c}else if(o!==a)return o.localeCompare(a)}return 0}function Ka(t){return t.replace(/[^a-zA-Z0-9\s]/g,"")}function Is(t,e,n){let r=n!==null?n:/\s+/,s=t.split(r),i=e.startField-1;if(i>=s.length)return"";if(e.endField===void 0){let l=s[i]||"";return e.startChar!==void 0&&(l=l.slice(e.startChar-1)),e.ignoreLeading&&(l=l.trimStart()),l}let o=Math.min(e.endField-1,s.length-1),a="";for(let l=i;l<=o&&l<s.length;l++){let c=s[l]||"";if(l===i&&e.startChar!==void 0&&(c=c.slice(e.startChar-1)),l===o&&e.endChar!==void 0){let u=l===i&&e.startChar!==void 0?e.endChar-e.startChar+1:e.endChar;c=c.slice(0,u)}l>i&&(a+=n||" "),a+=c}return e.ignoreLeading&&(a=a.trimStart()),a}function Qa(t,e,n){let r=t,s=e;if(n.dictionaryOrder&&(r=Ka(r),s=Ka(s)),n.ignoreCase&&(r=r.toLowerCase(),s=s.toLowerCase()),n.monthSort){let i=Za(r),o=Za(s);return i-o}if(n.humanNumeric){let i=Va(r),o=Va(s);return i-o}if(n.versionSort)return Am(r,s);if(n.numeric){let i=parseFloat(r)||0,o=parseFloat(s)||0;return i-o}return r.localeCompare(s)}function Xa(t){let{keys:e,fieldDelimiter:n,numeric:r,ignoreCase:s,reverse:i,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c,ignoreLeadingBlanks:u,stable:f}=t;return(d,p)=>{let h=d,m=p;if(u&&(h=h.trimStart(),m=m.trimStart()),e.length===0){let w=Qa(h,m,{numeric:r,ignoreCase:s,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c});if(w!==0)return i?-w:w;if(!f){let b=d.localeCompare(p);return i?-b:b}return 0}for(let g of e){let w=Is(h,g,n),b=Is(m,g,n);g.ignoreLeading&&(w=w.trimStart(),b=b.trimStart());let E={numeric:g.numeric??r,ignoreCase:g.ignoreCase??s,humanNumeric:g.humanNumeric??o,versionSort:g.versionSort??a,dictionaryOrder:g.dictionaryOrder??l,monthSort:g.monthSort??c},S=g.reverse??i,R=Qa(w,b,E);if(R!==0)return S?-R:R}if(!f){let g=d.localeCompare(p);return i?-g:g}return 0}}function Ja(t,e){if(e.keys.length===0){if(e.ignoreCase){let s=new Set;return t.filter(i=>{let o=i.toLowerCase();return s.has(o)?!1:(s.add(o),!0)})}return[...new Set(t)]}let n=e.keys[0],r=new Set;return t.filter(s=>{let i=Is(s,n,e.fieldDelimiter);return(n.ignoreCase??e.ignoreCase)&&(i=i.toLowerCase()),r.has(i)?!1:(r.add(i),!0)})}var Sm,Cm,Ya=C(()=>{"use strict";Sm={"":1,k:1024,m:1048576,g:1073741824,t:1099511627776,p:0x4000000000000,e:1152921504606847e3},Cm={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}});function ur(t){let e={startField:1},n="",r=t,s=r.match(/([bdfhMnrV]+)$/);s&&(n=s[1],r=r.slice(0,-n.length)),n.includes("n")&&(e.numeric=!0),n.includes("r")&&(e.reverse=!0),n.includes("f")&&(e.ignoreCase=!0),n.includes("b")&&(e.ignoreLeading=!0),n.includes("h")&&(e.humanNumeric=!0),n.includes("V")&&(e.versionSort=!0),n.includes("d")&&(e.dictionaryOrder=!0),n.includes("M")&&(e.monthSort=!0);let i=r.split(",");if(i.length===0||i[0]==="")return null;let o=i[0].split("."),a=parseInt(o[0],10);if(Number.isNaN(a)||a<1)return null;if(e.startField=a,o.length>1&&o[1]){let l=parseInt(o[1],10);!Number.isNaN(l)&&l>=1&&(e.startChar=l)}if(i.length>1&&i[1]){let l=i[1],c=l.match(/([bdfhMnrV]+)$/);if(c){let f=c[1];f.includes("n")&&(e.numeric=!0),f.includes("r")&&(e.reverse=!0),f.includes("f")&&(e.ignoreCase=!0),f.includes("b")&&(e.ignoreLeading=!0),f.includes("h")&&(e.humanNumeric=!0),f.includes("V")&&(e.versionSort=!0),f.includes("d")&&(e.dictionaryOrder=!0),f.includes("M")&&(e.monthSort=!0),l=l.slice(0,-f.length)}let u=l.split(".");if(u[0]){let f=parseInt(u[0],10);if(!Number.isNaN(f)&&f>=1&&(e.endField=f),u.length>1&&u[1]){let d=parseInt(u[1],10);!Number.isNaN(d)&&d>=1&&(e.endChar=d)}}}return e}var el=C(()=>{"use strict"});var tl={};L(tl,{sortCommand:()=>Nm});var km,Nm,nl=C(()=>{"use strict";Nt();j();Ya();el();km={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
288
+ `);h.length>0&&h[h.length-1]===""&&h.pop(),p.push({filename:"",lines:h})}for(let h of p){for(f.FILENAME=h.filename,f.FNR=0,f.lines=h.lines,f.lineIndex=-1,f.shouldNextFile=!1;f.lineIndex<h.lines.length-1&&(f.lineIndex++,await d.executeLine(h.lines[f.lineIndex]),!(f.shouldExit||f.shouldNextFile)););if(f.shouldExit)break}return f.shouldExit||await d.executeEnd(),{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()}}catch(p){let h=p instanceof Error?p.message:String(p),m=p instanceof Z?Z.EXIT_CODE:2;return{stdout:d.getOutput(),stderr:`awk: ${h}
289
+ `,exitCode:m}}}}});function Xa(t){let e=t.trim(),n=e.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!n){let o=parseFloat(e);return Number.isNaN(o)?0:o}let r=parseFloat(n[1]),s=(n[2]||"").toLowerCase(),i=Rm[s]||1;return r*i}function Ja(t){let e=t.trim().toLowerCase().slice(0,3);return Fm[e]||0}function Pm(t,e){let n=t.split(/(\d+)/),r=e.split(/(\d+)/),s=Math.max(n.length,r.length);for(let i=0;i<s;i++){let o=n[i]||"",a=r[i]||"",l=/^\d+$/.test(o)?parseInt(o,10):null,c=/^\d+$/.test(a)?parseInt(a,10):null;if(l!==null&&c!==null){if(l!==c)return l-c}else if(o!==a)return o.localeCompare(a)}return 0}function Ya(t){return t.replace(/[^a-zA-Z0-9\s]/g,"")}function $s(t,e,n){let r=n!==null?n:/\s+/,s=t.split(r),i=e.startField-1;if(i>=s.length)return"";if(e.endField===void 0){let l=s[i]||"";return e.startChar!==void 0&&(l=l.slice(e.startChar-1)),e.ignoreLeading&&(l=l.trimStart()),l}let o=Math.min(e.endField-1,s.length-1),a="";for(let l=i;l<=o&&l<s.length;l++){let c=s[l]||"";if(l===i&&e.startChar!==void 0&&(c=c.slice(e.startChar-1)),l===o&&e.endChar!==void 0){let u=l===i&&e.startChar!==void 0?e.endChar-e.startChar+1:e.endChar;c=c.slice(0,u)}l>i&&(a+=n||" "),a+=c}return e.ignoreLeading&&(a=a.trimStart()),a}function el(t,e,n){let r=t,s=e;if(n.dictionaryOrder&&(r=Ya(r),s=Ya(s)),n.ignoreCase&&(r=r.toLowerCase(),s=s.toLowerCase()),n.monthSort){let i=Ja(r),o=Ja(s);return i-o}if(n.humanNumeric){let i=Xa(r),o=Xa(s);return i-o}if(n.versionSort)return Pm(r,s);if(n.numeric){let i=parseFloat(r)||0,o=parseFloat(s)||0;return i-o}return r.localeCompare(s)}function tl(t){let{keys:e,fieldDelimiter:n,numeric:r,ignoreCase:s,reverse:i,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c,ignoreLeadingBlanks:u,stable:f}=t;return(d,p)=>{let h=d,m=p;if(u&&(h=h.trimStart(),m=m.trimStart()),e.length===0){let b=el(h,m,{numeric:r,ignoreCase:s,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c});if(b!==0)return i?-b:b;if(!f){let w=d.localeCompare(p);return i?-w:w}return 0}for(let g of e){let b=$s(h,g,n),w=$s(m,g,n);g.ignoreLeading&&(b=b.trimStart(),w=w.trimStart());let E={numeric:g.numeric??r,ignoreCase:g.ignoreCase??s,humanNumeric:g.humanNumeric??o,versionSort:g.versionSort??a,dictionaryOrder:g.dictionaryOrder??l,monthSort:g.monthSort??c},S=g.reverse??i,R=el(b,w,E);if(R!==0)return S?-R:R}if(!f){let g=d.localeCompare(p);return i?-g:g}return 0}}function nl(t,e){if(e.keys.length===0){if(e.ignoreCase){let s=new Set;return t.filter(i=>{let o=i.toLowerCase();return s.has(o)?!1:(s.add(o),!0)})}return[...new Set(t)]}let n=e.keys[0],r=new Set;return t.filter(s=>{let i=$s(s,n,e.fieldDelimiter);return(n.ignoreCase??e.ignoreCase)&&(i=i.toLowerCase()),r.has(i)?!1:(r.add(i),!0)})}var Rm,Fm,rl=C(()=>{"use strict";Rm={"":1,k:1024,m:1048576,g:1073741824,t:1099511627776,p:0x4000000000000,e:1152921504606847e3},Fm={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}});function fr(t){let e={startField:1},n="",r=t,s=r.match(/([bdfhMnrV]+)$/);s&&(n=s[1],r=r.slice(0,-n.length)),n.includes("n")&&(e.numeric=!0),n.includes("r")&&(e.reverse=!0),n.includes("f")&&(e.ignoreCase=!0),n.includes("b")&&(e.ignoreLeading=!0),n.includes("h")&&(e.humanNumeric=!0),n.includes("V")&&(e.versionSort=!0),n.includes("d")&&(e.dictionaryOrder=!0),n.includes("M")&&(e.monthSort=!0);let i=r.split(",");if(i.length===0||i[0]==="")return null;let o=i[0].split("."),a=parseInt(o[0],10);if(Number.isNaN(a)||a<1)return null;if(e.startField=a,o.length>1&&o[1]){let l=parseInt(o[1],10);!Number.isNaN(l)&&l>=1&&(e.startChar=l)}if(i.length>1&&i[1]){let l=i[1],c=l.match(/([bdfhMnrV]+)$/);if(c){let f=c[1];f.includes("n")&&(e.numeric=!0),f.includes("r")&&(e.reverse=!0),f.includes("f")&&(e.ignoreCase=!0),f.includes("b")&&(e.ignoreLeading=!0),f.includes("h")&&(e.humanNumeric=!0),f.includes("V")&&(e.versionSort=!0),f.includes("d")&&(e.dictionaryOrder=!0),f.includes("M")&&(e.monthSort=!0),l=l.slice(0,-f.length)}let u=l.split(".");if(u[0]){let f=parseInt(u[0],10);if(!Number.isNaN(f)&&f>=1&&(e.endField=f),u.length>1&&u[1]){let d=parseInt(u[1],10);!Number.isNaN(d)&&d>=1&&(e.endChar=d)}}}return e}var sl=C(()=>{"use strict"});var il={};_(il,{sortCommand:()=>Om});var Tm,Om,ol=C(()=>{"use strict";It();j();rl();sl();Tm={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
286
290
  F is a field number (1-indexed)
287
291
  C is a character position within the field (1-indexed)
288
292
  OPTS can be: b d f h M n r V (per-key modifiers)
@@ -292,16 +296,16 @@ Examples:
292
296
  -k2,2 sort by second field only
293
297
  -k1.3 sort by first field starting at 3rd character
294
298
  -k1,2n sort by fields 1-2 numerically
295
- -k2 -k1 sort by field 2, then by field 1`},Nm={name:"sort",async execute(t,e){if(I(t))return N(km);let n={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},r=[];for(let c=0;c<t.length;c++){let u=t[c];if(u==="-r"||u==="--reverse")n.reverse=!0;else if(u==="-n"||u==="--numeric-sort")n.numeric=!0;else if(u==="-u"||u==="--unique")n.unique=!0;else if(u==="-f"||u==="--ignore-case")n.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")n.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")n.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")n.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")n.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")n.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")n.stable=!0;else if(u==="-c"||u==="--check")n.checkOnly=!0;else if(u==="-o"||u==="--output")n.outputFile=t[++c]||null;else if(u.startsWith("-o"))n.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))n.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")n.fieldDelimiter=t[++c]||null;else if(u.startsWith("-t"))n.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))n.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=t[++c];if(f){let d=ur(f);d&&n.keys.push(d)}}else if(u.startsWith("-k")){let f=ur(u.slice(2));f&&n.keys.push(f)}else if(u.startsWith("--key=")){let f=ur(u.slice(6));f&&n.keys.push(f)}else{if(u.startsWith("--"))return D("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let d of u.slice(1))if(d==="r")n.reverse=!0;else if(d==="n")n.numeric=!0;else if(d==="u")n.unique=!0;else if(d==="f")n.ignoreCase=!0;else if(d==="h")n.humanNumeric=!0;else if(d==="V")n.versionSort=!0;else if(d==="d")n.dictionaryOrder=!0;else if(d==="M")n.monthSort=!0;else if(d==="b")n.ignoreLeadingBlanks=!0;else if(d==="s")n.stable=!0;else if(d==="c")n.checkOnly=!0;else{f=!0;break}if(f)return D("sort",u)}else r.push(u)}}let s=await Gt(e,r,{cmdName:"sort"});if(!s.ok)return s.error;let o=s.content.split(`
296
- `);o.length>0&&o[o.length-1]===""&&o.pop();let a=Xa(n);if(n.checkOnly){let c=r.length>0?r[0]:"-";for(let u=1;u<o.length;u++)if(a(o[u-1],o[u])>0)return{stdout:"",stderr:`sort: ${c}:${u+1}: disorder: ${o[u]}
297
- `,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}o.sort(a),n.unique&&(o=Ja(o,n));let l=o.length>0?`${o.join(`
299
+ -k2 -k1 sort by field 2, then by field 1`},Om={name:"sort",async execute(t,e){if(N(t))return k(Tm);let n={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},r=[];for(let c=0;c<t.length;c++){let u=t[c];if(u==="-r"||u==="--reverse")n.reverse=!0;else if(u==="-n"||u==="--numeric-sort")n.numeric=!0;else if(u==="-u"||u==="--unique")n.unique=!0;else if(u==="-f"||u==="--ignore-case")n.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")n.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")n.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")n.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")n.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")n.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")n.stable=!0;else if(u==="-c"||u==="--check")n.checkOnly=!0;else if(u==="-o"||u==="--output")n.outputFile=t[++c]||null;else if(u.startsWith("-o"))n.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))n.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")n.fieldDelimiter=t[++c]||null;else if(u.startsWith("-t"))n.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))n.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=t[++c];if(f){let d=fr(f);d&&n.keys.push(d)}}else if(u.startsWith("-k")){let f=fr(u.slice(2));f&&n.keys.push(f)}else if(u.startsWith("--key=")){let f=fr(u.slice(6));f&&n.keys.push(f)}else{if(u.startsWith("--"))return L("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let d of u.slice(1))if(d==="r")n.reverse=!0;else if(d==="n")n.numeric=!0;else if(d==="u")n.unique=!0;else if(d==="f")n.ignoreCase=!0;else if(d==="h")n.humanNumeric=!0;else if(d==="V")n.versionSort=!0;else if(d==="d")n.dictionaryOrder=!0;else if(d==="M")n.monthSort=!0;else if(d==="b")n.ignoreLeadingBlanks=!0;else if(d==="s")n.stable=!0;else if(d==="c")n.checkOnly=!0;else{f=!0;break}if(f)return L("sort",u)}else r.push(u)}}let s=await qt(e,r,{cmdName:"sort"});if(!s.ok)return s.error;let o=s.content.split(`
300
+ `);o.length>0&&o[o.length-1]===""&&o.pop();let a=tl(n);if(n.checkOnly){let c=r.length>0?r[0]:"-";for(let u=1;u<o.length;u++)if(a(o[u-1],o[u])>0)return{stdout:"",stderr:`sort: ${c}:${u+1}: disorder: ${o[u]}
301
+ `,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}o.sort(a),n.unique&&(o=nl(o,n));let l=o.length>0?`${o.join(`
298
302
  `)}
299
- `:"";if(n.outputFile){let c=e.fs.resolvePath(e.cwd,n.outputFile);return await e.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}}});var rl={};L(rl,{uniqCommand:()=>$m});var Im,vm,$m,sl=C(()=>{"use strict";Ae();Nt();j();Im={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},vm={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},$m={name:"uniq",async execute(t,e){if(I(t))return N(Im);let n=K("uniq",t,vm);if(!n.ok)return n.error;let{count:r,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=n.result.flags,a=n.result.positional,l=await Gt(e,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=l.content.split(`
300
- `);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],d=u[0],p=1,h=(w,b)=>o?w.toLowerCase()===b.toLowerCase():w===b;for(let w=1;w<u.length;w++)h(u[w],d)?p++:(f.push({line:d,count:p}),d=u[w],p=1);f.push({line:d,count:p});let m=f;s?m=f.filter(w=>w.count>1):i&&(m=f.filter(w=>w.count===1));let g="";for(let{line:w,count:b}of m)r?g+=`${String(b).padStart(4)} ${w}
301
- `:g+=`${w}
302
- `;return{stdout:g,stderr:"",exitCode:0}}}});var il={};L(il,{commCommand:()=>Pm});var Rm,Pm,ol=C(()=>{"use strict";j();Rm={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},Pm={name:"comm",async execute(t,e){if(I(t))return N(Rm);let n=!1,r=!1,s=!1,i=[];for(let g of t)if(g==="-1")n=!0;else if(g==="-2")r=!0;else if(g==="-3")s=!0;else if(g==="-12"||g==="-21")n=!0,r=!0;else if(g==="-13"||g==="-31")n=!0,s=!0;else if(g==="-23"||g==="-32")r=!0,s=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")n=!0,r=!0,s=!0;else{if(g.startsWith("-")&&g!=="-")return D("comm",g);i.push(g)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
303
+ `:"";if(n.outputFile){let c=e.fs.resolvePath(e.cwd,n.outputFile);return await e.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}}});var al={};_(al,{uniqCommand:()=>Mm});var Dm,Lm,Mm,ll=C(()=>{"use strict";Ae();It();j();Dm={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},Lm={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},Mm={name:"uniq",async execute(t,e){if(N(t))return k(Dm);let n=Q("uniq",t,Lm);if(!n.ok)return n.error;let{count:r,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=n.result.flags,a=n.result.positional,l=await qt(e,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=l.content.split(`
304
+ `);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],d=u[0],p=1,h=(b,w)=>o?b.toLowerCase()===w.toLowerCase():b===w;for(let b=1;b<u.length;b++)h(u[b],d)?p++:(f.push({line:d,count:p}),d=u[b],p=1);f.push({line:d,count:p});let m=f;s?m=f.filter(b=>b.count>1):i&&(m=f.filter(b=>b.count===1));let g="";for(let{line:b,count:w}of m)r?g+=`${String(w).padStart(4)} ${b}
305
+ `:g+=`${b}
306
+ `;return{stdout:g,stderr:"",exitCode:0}}}});var cl={};_(cl,{commCommand:()=>Bm});var _m,Bm,ul=C(()=>{"use strict";j();_m={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},Bm={name:"comm",async execute(t,e){if(N(t))return k(_m);let n=!1,r=!1,s=!1,i=[];for(let g of t)if(g==="-1")n=!0;else if(g==="-2")r=!0;else if(g==="-3")s=!0;else if(g==="-12"||g==="-21")n=!0,r=!0;else if(g==="-13"||g==="-31")n=!0,s=!0;else if(g==="-23"||g==="-32")r=!0,s=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")n=!0,r=!0,s=!0;else{if(g.startsWith("-")&&g!=="-")return L("comm",g);i.push(g)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
303
307
  Try 'comm --help' for more information.
304
- `,exitCode:1};let o=async g=>{if(g==="-")return e.stdin;try{let w=e.fs.resolvePath(e.cwd,g);return await e.fs.readFile(w)}catch{return null}},a=await o(i[0]);if(a===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
308
+ `,exitCode:1};let o=async g=>{if(g==="-")return e.stdin;try{let b=e.fs.resolvePath(e.cwd,g);return await e.fs.readFile(b)}catch{return null}},a=await o(i[0]);if(a===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
305
309
  `,exitCode:1};let l=await o(i[1]);if(l===null)return{stdout:"",stderr:`comm: ${i[1]}: No such file or directory
306
310
  `,exitCode:1};let c=a.split(`
307
311
  `),u=l.split(`
@@ -310,18 +314,18 @@ Try 'comm --help' for more information.
310
314
  `),f++):c[f]<u[d]?(n||(p+=`${c[f]}
311
315
  `),f++):c[f]>u[d]?(r||(p+=`${h}${u[d]}
312
316
  `),d++):(s||(p+=`${m}${c[f]}
313
- `),f++,d++);return{stdout:p,stderr:"",exitCode:0}}}});var al={};L(al,{cutCommand:()=>Dm});function Tm(t){let e=[],n=t.split(",");for(let r of n)if(r.includes("-")){let[s,i]=r.split("-");e.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(r,10);e.push({start:s,end:s})}return e}function Om(t,e){let n=[];for(let r of e){let s=r.start-1,i=r.end===null?t.length:r.end;for(let o=s;o<i&&o<t.length;o++)o>=0&&!n.includes(t[o])&&n.push(t[o])}return n}var Fm,Dm,ll=C(()=>{"use strict";Nt();j();Fm={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};Dm={name:"cut",async execute(t,e){if(I(t))return N(Fm);let n=" ",r=null,s=null,i=!1,o=[];for(let d=0;d<t.length;d++){let p=t[d];if(p==="-d")n=t[++d]||" ";else if(p.startsWith("-d"))n=p.slice(2);else if(p==="-f")r=t[++d];else if(p.startsWith("-f"))r=p.slice(2);else if(p==="-c")s=t[++d];else if(p.startsWith("-c"))s=p.slice(2);else if(p==="-s"||p==="--only-delimited")i=!0;else{if(p.startsWith("--"))return D("cut",p);if(p.startsWith("-")){let h=!1;for(let m of p.slice(1))if(m==="s")i=!0;else if(!"dfc".includes(m)){h=!0;break}if(h)return D("cut",p)}else o.push(p)}}if(!r&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
314
- `,exitCode:1};let a=await Gt(e,o,{cmdName:"cut"});if(!a.ok)return a.error;let c=a.content.split(`
315
- `);c.length>0&&c[c.length-1]===""&&c.pop();let u=Tm(r||s||"1"),f="";for(let d of c)if(s){let p=d.split(""),h=[];for(let m of u){let g=m.start-1,w=m.end===null?p.length:m.end;for(let b=g;b<w&&b<p.length;b++)b>=0&&h.push(p[b])}f+=`${h.join("")}
316
- `}else{if(i&&!d.includes(n))continue;let p=d.split(n),h=Om(p,u);f+=`${h.join(n)}
317
- `}return{stdout:f,stderr:"",exitCode:0}}}});var ul={};L(ul,{pasteCommand:()=>_m});function cl(t,e){if(t.length===0)return"";if(t.length===1)return t[0];let n=t[0];for(let r=1;r<t.length;r++){let s=(r-1)%e.length;n+=e[s]+t[r]}return n}var Lm,Mm,_m,fl=C(()=>{"use strict";Ae();j();Lm={name:"paste",summary:"merge lines of files",usage:"paste [OPTION]... [FILE]...",description:["Write lines consisting of the sequentially corresponding lines from","each FILE, separated by TABs, to standard output.","","With no FILE, or when FILE is -, read standard input."],options:["-d, --delimiters=LIST reuse characters from LIST instead of TABs","-s, --serial paste one file at a time instead of in parallel"," --help display this help and exit"],examples:["paste file1 file2 Merge file1 and file2 side by side","paste -d, file1 file2 Use comma as delimiter","paste -s file1 Paste all lines of file1 on one line","paste - - < file Paste pairs of lines from file"]},Mm={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},_m={name:"paste",async execute(t,e){if(I(t))return N(Lm);let n=K("paste",t,Mm);if(!n.ok)return n.error;let r=n.result.flags.delimiter,s=n.result.flags.serial,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
317
+ `),f++,d++);return{stdout:p,stderr:"",exitCode:0}}}});var fl={};_(fl,{cutCommand:()=>zm});function Um(t){let e=[],n=t.split(",");for(let r of n)if(r.includes("-")){let[s,i]=r.split("-");e.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(r,10);e.push({start:s,end:s})}return e}function jm(t,e){let n=[];for(let r of e){let s=r.start-1,i=r.end===null?t.length:r.end;for(let o=s;o<i&&o<t.length;o++)o>=0&&!n.includes(t[o])&&n.push(t[o])}return n}var Wm,zm,dl=C(()=>{"use strict";It();j();Wm={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};zm={name:"cut",async execute(t,e){if(N(t))return k(Wm);let n=" ",r=null,s=null,i=!1,o=[];for(let d=0;d<t.length;d++){let p=t[d];if(p==="-d")n=t[++d]||" ";else if(p.startsWith("-d"))n=p.slice(2);else if(p==="-f")r=t[++d];else if(p.startsWith("-f"))r=p.slice(2);else if(p==="-c")s=t[++d];else if(p.startsWith("-c"))s=p.slice(2);else if(p==="-s"||p==="--only-delimited")i=!0;else{if(p.startsWith("--"))return L("cut",p);if(p.startsWith("-")){let h=!1;for(let m of p.slice(1))if(m==="s")i=!0;else if(!"dfc".includes(m)){h=!0;break}if(h)return L("cut",p)}else o.push(p)}}if(!r&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
318
+ `,exitCode:1};let a=await qt(e,o,{cmdName:"cut"});if(!a.ok)return a.error;let c=a.content.split(`
319
+ `);c.length>0&&c[c.length-1]===""&&c.pop();let u=Um(r||s||"1"),f="";for(let d of c)if(s){let p=d.split(""),h=[];for(let m of u){let g=m.start-1,b=m.end===null?p.length:m.end;for(let w=g;w<b&&w<p.length;w++)w>=0&&h.push(p[w])}f+=`${h.join("")}
320
+ `}else{if(i&&!d.includes(n))continue;let p=d.split(n),h=jm(p,u);f+=`${h.join(n)}
321
+ `}return{stdout:f,stderr:"",exitCode:0}}}});var hl={};_(hl,{pasteCommand:()=>qm});function pl(t,e){if(t.length===0)return"";if(t.length===1)return t[0];let n=t[0];for(let r=1;r<t.length;r++){let s=(r-1)%e.length;n+=e[s]+t[r]}return n}var Hm,Gm,qm,ml=C(()=>{"use strict";Ae();j();Hm={name:"paste",summary:"merge lines of files",usage:"paste [OPTION]... [FILE]...",description:["Write lines consisting of the sequentially corresponding lines from","each FILE, separated by TABs, to standard output.","","With no FILE, or when FILE is -, read standard input."],options:["-d, --delimiters=LIST reuse characters from LIST instead of TABs","-s, --serial paste one file at a time instead of in parallel"," --help display this help and exit"],examples:["paste file1 file2 Merge file1 and file2 side by side","paste -d, file1 file2 Use comma as delimiter","paste -s file1 Paste all lines of file1 on one line","paste - - < file Paste pairs of lines from file"]},Gm={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},qm={name:"paste",async execute(t,e){if(N(t))return k(Hm);let n=Q("paste",t,Gm);if(!n.ok)return n.error;let r=n.result.flags.delimiter,s=n.result.flags.serial,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
318
322
  `,exitCode:1};let o=e.stdin?e.stdin.split(`
319
323
  `):[""];o.length>0&&o[o.length-1]===""&&o.pop();let a=i.filter(f=>f==="-").length,l=[],c=0;for(let f of i)if(f==="-"){let d=[];for(let p=c;p<o.length;p+=a)d.push(o[p]);l.push(d),c++}else{let d=e.fs.resolvePath(e.cwd,f);try{let h=(await e.fs.readFile(d)).split(`
320
324
  `);h.length>0&&h[h.length-1]===""&&h.pop(),l.push(h)}catch{return{stdout:"",stderr:`paste: ${f}: No such file or directory
321
- `,exitCode:1}}}let u="";if(s)for(let f of l)f&&(u+=`${cl(f,r)}
322
- `);else{let f=Math.max(...l.map(d=>d?.length??0));for(let d=0;d<f;d++){let p=[];for(let h of l)p.push(h?.[d]??"");u+=`${cl(p,r)}
323
- `}}return{stdout:u,stderr:"",exitCode:0}}}});var pl={};L(pl,{trCommand:()=>jm});function dl(t){let e="",n=0;for(;n<t.length;){if(t[n]==="["&&t[n+1]===":"){let r=!1;for(let[s,i]of Object.entries(Wm))if(t.slice(n).startsWith(s)){e+=i,n+=s.length,r=!0;break}if(r)continue}if(t[n]==="\\"&&n+1<t.length){let r=t[n+1];r==="n"?e+=`
324
- `:r==="t"?e+=" ":r==="r"?e+="\r":e+=r,n+=2;continue}if(n+2<t.length&&t[n+1]==="-"){let r=t.charCodeAt(n),s=t.charCodeAt(n+2);for(let i=r;i<=s;i++)e+=String.fromCharCode(i);n+=3;continue}e+=t[n],n++}return e}var Bm,Wm,Um,jm,hl=C(()=>{"use strict";Ae();j();Bm={name:"tr",summary:"translate or delete characters",usage:"tr [OPTION]... SET1 [SET2]",options:["-c, -C, --complement use the complement of SET1","-d, --delete delete characters in SET1","-s, --squeeze-repeats squeeze repeated characters"," --help display this help and exit"],description:`SET syntax:
325
+ `,exitCode:1}}}let u="";if(s)for(let f of l)f&&(u+=`${pl(f,r)}
326
+ `);else{let f=Math.max(...l.map(d=>d?.length??0));for(let d=0;d<f;d++){let p=[];for(let h of l)p.push(h?.[d]??"");u+=`${pl(p,r)}
327
+ `}}return{stdout:u,stderr:"",exitCode:0}}}});var yl={};_(yl,{trCommand:()=>Qm});function gl(t){let e="",n=0;for(;n<t.length;){if(t[n]==="["&&t[n+1]===":"){let r=!1;for(let[s,i]of Object.entries(Zm))if(t.slice(n).startsWith(s)){e+=i,n+=s.length,r=!0;break}if(r)continue}if(t[n]==="\\"&&n+1<t.length){let r=t[n+1];r==="n"?e+=`
328
+ `:r==="t"?e+=" ":r==="r"?e+="\r":e+=r,n+=2;continue}if(n+2<t.length&&t[n+1]==="-"){let r=t.charCodeAt(n),s=t.charCodeAt(n+2);for(let i=r;i<=s;i++)e+=String.fromCharCode(i);n+=3;continue}e+=t[n],n++}return e}var Vm,Zm,Km,Qm,xl=C(()=>{"use strict";Ae();j();Vm={name:"tr",summary:"translate or delete characters",usage:"tr [OPTION]... SET1 [SET2]",options:["-c, -C, --complement use the complement of SET1","-d, --delete delete characters in SET1","-s, --squeeze-repeats squeeze repeated characters"," --help display this help and exit"],description:`SET syntax:
325
329
  a-z character range
326
330
  [:alnum:] all letters and digits
327
331
  [:alpha:] all letters
@@ -335,19 +339,19 @@ Try 'comm --help' for more information.
335
339
  [:graph:] all printable characters except space
336
340
  [:cntrl:] all control characters
337
341
  [:xdigit:] all hexadecimal digits
338
- \\n, \\t, \\r escape sequences`},Wm={"[:alnum:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789","[:alpha:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","[:blank:]":" ","[:cntrl:]":Array.from({length:32},(t,e)=>String.fromCharCode(e)).join("").concat("\x7F"),"[:digit:]":"0123456789","[:graph:]":Array.from({length:94},(t,e)=>String.fromCharCode(33+e)).join(""),"[:lower:]":"abcdefghijklmnopqrstuvwxyz","[:print:]":Array.from({length:95},(t,e)=>String.fromCharCode(32+e)).join(""),"[:punct:]":"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~","[:space:]":`
339
- \r\f\v`,"[:upper:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZ","[:xdigit:]":"0123456789ABCDEFabcdef"};Um={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},jm={name:"tr",async execute(t,e){if(I(t))return N(Bm);let n=K("tr",t,Um);if(!n.ok)return n.error;let r=n.result.flags.complement||n.result.flags.complementUpper,s=n.result.flags.delete,i=n.result.flags.squeeze,o=n.result.positional;if(o.length<1)return{stdout:"",stderr:`tr: missing operand
342
+ \\n, \\t, \\r escape sequences`},Zm={"[:alnum:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789","[:alpha:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","[:blank:]":" ","[:cntrl:]":Array.from({length:32},(t,e)=>String.fromCharCode(e)).join("").concat("\x7F"),"[:digit:]":"0123456789","[:graph:]":Array.from({length:94},(t,e)=>String.fromCharCode(33+e)).join(""),"[:lower:]":"abcdefghijklmnopqrstuvwxyz","[:print:]":Array.from({length:95},(t,e)=>String.fromCharCode(32+e)).join(""),"[:punct:]":"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~","[:space:]":`
343
+ \r\f\v`,"[:upper:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZ","[:xdigit:]":"0123456789ABCDEFabcdef"};Km={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},Qm={name:"tr",async execute(t,e){if(N(t))return k(Vm);let n=Q("tr",t,Km);if(!n.ok)return n.error;let r=n.result.flags.complement||n.result.flags.complementUpper,s=n.result.flags.delete,i=n.result.flags.squeeze,o=n.result.positional;if(o.length<1)return{stdout:"",stderr:`tr: missing operand
340
344
  `,exitCode:1};if(!s&&!i&&o.length<2)return{stdout:"",stderr:`tr: missing operand after SET1
341
- `,exitCode:1};let a=dl(o[0]),l=o.length>1?dl(o[1]):"",c=e.stdin,u=d=>{let p=a.includes(d);return r?!p:p},f="";if(s)for(let d of c)u(d)||(f+=d);else if(i&&o.length===1){let d="";for(let p of c)u(p)&&p===d||(f+=p,d=p)}else{if(r){let d=l.length>0?l[l.length-1]:"";for(let p of c)a.includes(p)?f+=p:f+=d}else{let d=new Map;for(let p=0;p<a.length;p++){let h=p<l.length?l[p]:l[l.length-1];d.set(a[p],h)}for(let p of c)f+=d.get(p)??p}if(i){let d="",p="";for(let h of f)l.includes(h)&&h===p||(d+=h,p=h);f=d}}return{stdout:f,stderr:"",exitCode:0}}}});var ml={};L(ml,{rev:()=>Gm});function Hm(t){return Array.from(t).reverse().join("")}var zm,Gm,gl=C(()=>{"use strict";j();zm={name:"rev",summary:"reverse lines characterwise",usage:"rev [file ...]",description:"Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.",examples:["echo 'hello' | rev # Output: olleh","rev file.txt # Reverse each line in file"]};Gm={name:"rev",execute:async(t,e)=>{if(I(t))return N(zm);let n=[];for(let i of t)if(i==="--"){let o=t.indexOf(i);n.push(...t.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return D("rev",i);n.push(i)}let r="",s=i=>{let o=i.split(`
345
+ `,exitCode:1};let a=gl(o[0]),l=o.length>1?gl(o[1]):"",c=e.stdin,u=d=>{let p=a.includes(d);return r?!p:p},f="";if(s)for(let d of c)u(d)||(f+=d);else if(i&&o.length===1){let d="";for(let p of c)u(p)&&p===d||(f+=p,d=p)}else{if(r){let d=l.length>0?l[l.length-1]:"";for(let p of c)a.includes(p)?f+=p:f+=d}else{let d=new Map;for(let p=0;p<a.length;p++){let h=p<l.length?l[p]:l[l.length-1];d.set(a[p],h)}for(let p of c)f+=d.get(p)??p}if(i){let d="",p="";for(let h of f)l.includes(h)&&h===p||(d+=h,p=h);f=d}}return{stdout:f,stderr:"",exitCode:0}}}});var wl={};_(wl,{rev:()=>Ym});function Jm(t){return Array.from(t).reverse().join("")}var Xm,Ym,bl=C(()=>{"use strict";j();Xm={name:"rev",summary:"reverse lines characterwise",usage:"rev [file ...]",description:"Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.",examples:["echo 'hello' | rev # Output: olleh","rev file.txt # Reverse each line in file"]};Ym={name:"rev",execute:async(t,e)=>{if(N(t))return k(Xm);let n=[];for(let i of t)if(i==="--"){let o=t.indexOf(i);n.push(...t.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return L("rev",i);n.push(i)}let r="",s=i=>{let o=i.split(`
342
346
  `),a=i.endsWith(`
343
- `)&&o[o.length-1]==="";return a&&o.pop(),o.map(Hm).join(`
347
+ `)&&o[o.length-1]==="";return a&&o.pop(),o.map(Jm).join(`
344
348
  `)+(a?`
345
349
  `:"")};if(n.length===0){let i=e.stdin??"";r=s(i)}else for(let i of n)if(i==="-"){let o=e.stdin??"";r+=s(o)}else{let o=e.fs.resolvePath(e.cwd,i),a=await e.fs.readFile(o);if(a===null)return{exitCode:1,stdout:r,stderr:`rev: ${i}: No such file or directory
346
- `};r+=s(a)}return{exitCode:0,stdout:r,stderr:""}}}});var xl={};L(xl,{nl:()=>Km});function Vm(t,e,n){let r=String(t);switch(e){case"ln":return r.padEnd(n);case"rn":return r.padStart(n);case"rz":return r.padStart(n,"0");default:return e}}function Zm(t,e){switch(e){case"a":return!0;case"t":return t.trim().length>0;case"n":return!1;default:return e}}function yl(t,e,n){if(t==="")return{output:"",nextNumber:n};let r=t.split(`
350
+ `};r+=s(a)}return{exitCode:0,stdout:r,stderr:""}}}});var Sl={};_(Sl,{nl:()=>r0});function t0(t,e,n){let r=String(t);switch(e){case"ln":return r.padEnd(n);case"rn":return r.padStart(n);case"rz":return r.padStart(n,"0");default:return e}}function n0(t,e){switch(e){case"a":return!0;case"t":return t.trim().length>0;case"n":return!1;default:return e}}function El(t,e,n){if(t==="")return{output:"",nextNumber:n};let r=t.split(`
347
351
  `),s=[],i=n,o=t.endsWith(`
348
- `)&&r[r.length-1]==="";o&&r.pop();for(let a of r)if(Zm(a,e.bodyStyle)){let l=Vm(i,e.numberFormat,e.width);s.push(`${l}${e.separator}${a}`),i+=e.increment}else{let l=" ".repeat(e.width);s.push(`${l}${e.separator}${a}`)}return{output:s.join(`
352
+ `)&&r[r.length-1]==="";o&&r.pop();for(let a of r)if(n0(a,e.bodyStyle)){let l=t0(i,e.numberFormat,e.width);s.push(`${l}${e.separator}${a}`),i+=e.increment}else{let l=" ".repeat(e.width);s.push(`${l}${e.separator}${a}`)}return{output:s.join(`
349
353
  `)+(o?`
350
- `:""),nextNumber:i}}var qm,Km,wl=C(()=>{"use strict";j();qm={name:"nl",summary:"number lines of files",usage:"nl [OPTION]... [FILE]...",description:"Write each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.",options:["-b STYLE Body numbering style: a (all), t (non-empty), n (none)","-n FORMAT Number format: ln (left), rn (right), rz (right zeros)","-w WIDTH Number width (default: 6)","-s SEP Separator after number (default: TAB)","-v START Starting line number (default: 1)","-i INCR Line number increment (default: 1)"],examples:["nl file.txt # Number non-empty lines","nl -ba file.txt # Number all lines","nl -n rz -w 3 file.txt # Right-justified with zeros","nl -s ': ' file.txt # Use ': ' as separator"]};Km={name:"nl",execute:async(t,e)=>{if(I(t))return N(qm);let n={bodyStyle:"t",numberFormat:"rn",width:6,separator:" ",startNumber:1,increment:1},r=[],s=0;for(;s<t.length;){let a=t[s];if(a==="-b"&&s+1<t.length){let l=t[s+1];if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
354
+ `:""),nextNumber:i}}var e0,r0,Cl=C(()=>{"use strict";j();e0={name:"nl",summary:"number lines of files",usage:"nl [OPTION]... [FILE]...",description:"Write each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.",options:["-b STYLE Body numbering style: a (all), t (non-empty), n (none)","-n FORMAT Number format: ln (left), rn (right), rz (right zeros)","-w WIDTH Number width (default: 6)","-s SEP Separator after number (default: TAB)","-v START Starting line number (default: 1)","-i INCR Line number increment (default: 1)"],examples:["nl file.txt # Number non-empty lines","nl -ba file.txt # Number all lines","nl -n rz -w 3 file.txt # Right-justified with zeros","nl -s ': ' file.txt # Use ': ' as separator"]};r0={name:"nl",execute:async(t,e)=>{if(N(t))return k(e0);let n={bodyStyle:"t",numberFormat:"rn",width:6,separator:" ",startNumber:1,increment:1},r=[],s=0;for(;s<t.length;){let a=t[s];if(a==="-b"&&s+1<t.length){let l=t[s+1];if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
351
355
  `};n.bodyStyle=l,s+=2}else if(a.startsWith("-b")){let l=a.slice(2);if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
352
356
  `};n.bodyStyle=l,s++}else if(a==="-n"&&s+1<t.length){let l=t[s+1];if(l!=="ln"&&l!=="rn"&&l!=="rz")return{exitCode:1,stdout:"",stderr:`nl: invalid line numbering format: '${l}'
353
357
  `};n.numberFormat=l,s+=2}else if(a.startsWith("-n")){let l=a.slice(2);if(l!=="ln"&&l!=="rn"&&l!=="rz")return{exitCode:1,stdout:"",stderr:`nl: invalid line numbering format: '${l}'
@@ -357,214 +361,214 @@ Try 'comm --help' for more information.
357
361
  `};n.startNumber=l,s+=2}else if(a.startsWith("-v")){let l=parseInt(a.slice(2),10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid starting line number: '${a.slice(2)}'
358
362
  `};n.startNumber=l,s++}else if(a==="-i"&&s+1<t.length){let l=parseInt(t[s+1],10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid line number increment: '${t[s+1]}'
359
363
  `};n.increment=l,s+=2}else if(a.startsWith("-i")){let l=parseInt(a.slice(2),10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid line number increment: '${a.slice(2)}'
360
- `};n.increment=l,s++}else if(a==="--"){r.push(...t.slice(s+1));break}else{if(a.startsWith("-")&&a!=="-")return D("nl",a);r.push(a),s++}}let i="",o=n.startNumber;if(r.length===0){let a=e.stdin??"";i=yl(a,n,o).output}else for(let a of r){let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFile(l);if(c===null)return{exitCode:1,stdout:i,stderr:`nl: ${a}: No such file or directory
361
- `};let u=yl(c,n,o);i+=u.output,o=u.nextNumber}return{exitCode:0,stdout:i,stderr:""}}}});var El={};L(El,{fold:()=>Ym});function Xm(t,e,n){return n?new TextEncoder().encode(t).length:t===" "?8-e%8:t==="\b"?-1:1}function Jm(t,e){if(t.length===0)return t;let{width:n,breakAtSpaces:r,countBytes:s}=e,i=[],o="",a=0,l=-1,c=0;for(let u=0;u<t.length;u++){let f=t[u],d=Xm(f,a,s);a+d>n&&o.length>0?r&&l>=0?(i.push(o.slice(0,l+1)),o=o.slice(l+1)+f,a=a-c-1+d,l=-1,c=0):(i.push(o),o=f,a=d,l=-1,c=0):(o+=f,a+=d,(f===" "||f===" ")&&(l=o.length-1,c=a-d))}return o.length>0&&i.push(o),i.join(`
362
- `)}function bl(t,e){if(t==="")return"";let n=t.split(`
364
+ `};n.increment=l,s++}else if(a==="--"){r.push(...t.slice(s+1));break}else{if(a.startsWith("-")&&a!=="-")return L("nl",a);r.push(a),s++}}let i="",o=n.startNumber;if(r.length===0){let a=e.stdin??"";i=El(a,n,o).output}else for(let a of r){let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFile(l);if(c===null)return{exitCode:1,stdout:i,stderr:`nl: ${a}: No such file or directory
365
+ `};let u=El(c,n,o);i+=u.output,o=u.nextNumber}return{exitCode:0,stdout:i,stderr:""}}}});var kl={};_(kl,{fold:()=>a0});function i0(t,e,n){return n?new TextEncoder().encode(t).length:t===" "?8-e%8:t==="\b"?-1:1}function o0(t,e){if(t.length===0)return t;let{width:n,breakAtSpaces:r,countBytes:s}=e,i=[],o="",a=0,l=-1,c=0;for(let u=0;u<t.length;u++){let f=t[u],d=i0(f,a,s);a+d>n&&o.length>0?r&&l>=0?(i.push(o.slice(0,l+1)),o=o.slice(l+1)+f,a=a-c-1+d,l=-1,c=0):(i.push(o),o=f,a=d,l=-1,c=0):(o+=f,a+=d,(f===" "||f===" ")&&(l=o.length-1,c=a-d))}return o.length>0&&i.push(o),i.join(`
366
+ `)}function Al(t,e){if(t==="")return"";let n=t.split(`
363
367
  `),r=t.endsWith(`
364
- `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>Jm(i,e)).join(`
368
+ `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>o0(i,e)).join(`
365
369
  `)+(r?`
366
- `:"")}var Qm,Ym,Sl=C(()=>{"use strict";j();Qm={name:"fold",summary:"wrap each input line to fit in specified width",usage:"fold [OPTION]... [FILE]...",description:"Wrap input lines in each FILE, writing to standard output. If no FILE is specified, standard input is read.",options:["-w WIDTH Use WIDTH columns instead of 80","-s Break at spaces","-b Count bytes rather than columns"],examples:["fold -w 40 file.txt # Wrap at 40 columns","fold -sw 40 file.txt # Word wrap at 40 columns","echo 'long line' | fold -w 5 # Force wrap at 5"]};Ym={name:"fold",execute:async(t,e)=>{if(I(t))return N(Qm);let n={width:80,breakAtSpaces:!1,countBytes:!1},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-w"&&s+1<t.length){let a=parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${t[s+1]}'
370
+ `:"")}var s0,a0,Nl=C(()=>{"use strict";j();s0={name:"fold",summary:"wrap each input line to fit in specified width",usage:"fold [OPTION]... [FILE]...",description:"Wrap input lines in each FILE, writing to standard output. If no FILE is specified, standard input is read.",options:["-w WIDTH Use WIDTH columns instead of 80","-s Break at spaces","-b Count bytes rather than columns"],examples:["fold -w 40 file.txt # Wrap at 40 columns","fold -sw 40 file.txt # Word wrap at 40 columns","echo 'long line' | fold -w 5 # Force wrap at 5"]};a0={name:"fold",execute:async(t,e)=>{if(N(t))return k(s0);let n={width:80,breakAtSpaces:!1,countBytes:!1},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-w"&&s+1<t.length){let a=parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${t[s+1]}'
367
371
  `};n.width=a,s+=2}else if(o.startsWith("-w")&&o.length>2){let a=parseInt(o.slice(2),10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${o.slice(2)}'
368
372
  `};n.width=a,s++}else if(o==="-s")n.breakAtSpaces=!0,s++;else if(o==="-b")n.countBytes=!0,s++;else if(o==="-bs"||o==="-sb")n.breakAtSpaces=!0,n.countBytes=!0,s++;else if(o.match(/^-[sb]+w\d+$/)){o.includes("s")&&(n.breakAtSpaces=!0),o.includes("b")&&(n.countBytes=!0);let a=o.replace(/^-[sb]+w/,""),l=parseInt(a,10);if(Number.isNaN(l)||l<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${a}'
369
373
  `};n.width=l,s++}else if(o.match(/^-[sb]+w$/)&&s+1<t.length){o.includes("s")&&(n.breakAtSpaces=!0),o.includes("b")&&(n.countBytes=!0);let a=parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${t[s+1]}'
370
- `};n.width=a,s+=2}else if(o==="--"){r.push(...t.slice(s+1));break}else if(o.startsWith("-")&&o!=="-"){let a=o.slice(1),l=!1;for(let c of a)if(c==="s")n.breakAtSpaces=!0;else if(c==="b")n.countBytes=!0;else{l=!0;break}if(l)return D("fold",o);s++}else r.push(o),s++}let i="";if(r.length===0){let o=e.stdin??"";i=bl(o,n)}else for(let o of r){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`fold: ${o}: No such file or directory
371
- `};i+=bl(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var Al={};L(Al,{expand:()=>r0});function fr(t){let e=t.split(",").map(r=>r.trim()),n=[];for(let r of e){let s=parseInt(r,10);if(Number.isNaN(s)||s<1)return null;n.push(s)}for(let r=1;r<n.length;r++)if(n[r]<=n[r-1])return null;return n}function t0(t,e){if(e.length===1){let n=e[0];return n-t%n}for(let n of e)if(n>t)return n-t;if(e.length>=2){let n=e[e.length-1]-e[e.length-2],r=e[e.length-1],s=Math.floor((t-r)/n)+1;return r+s*n-t}return 1}function n0(t,e){let{tabStops:n,leadingOnly:r}=e,s="",i=0,o=!0;for(let a of t)if(a===" ")if(r&&!o)s+=a,i++;else{let l=t0(i,n);s+=" ".repeat(l),i+=l}else a!==" "&&a!==" "&&(o=!1),s+=a,i++;return s}function Cl(t,e){if(t==="")return"";let n=t.split(`
374
+ `};n.width=a,s+=2}else if(o==="--"){r.push(...t.slice(s+1));break}else if(o.startsWith("-")&&o!=="-"){let a=o.slice(1),l=!1;for(let c of a)if(c==="s")n.breakAtSpaces=!0;else if(c==="b")n.countBytes=!0;else{l=!0;break}if(l)return L("fold",o);s++}else r.push(o),s++}let i="";if(r.length===0){let o=e.stdin??"";i=Al(o,n)}else for(let o of r){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`fold: ${o}: No such file or directory
375
+ `};i+=Al(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var vl={};_(vl,{expand:()=>f0});function dr(t){let e=t.split(",").map(r=>r.trim()),n=[];for(let r of e){let s=parseInt(r,10);if(Number.isNaN(s)||s<1)return null;n.push(s)}for(let r=1;r<n.length;r++)if(n[r]<=n[r-1])return null;return n}function c0(t,e){if(e.length===1){let n=e[0];return n-t%n}for(let n of e)if(n>t)return n-t;if(e.length>=2){let n=e[e.length-1]-e[e.length-2],r=e[e.length-1],s=Math.floor((t-r)/n)+1;return r+s*n-t}return 1}function u0(t,e){let{tabStops:n,leadingOnly:r}=e,s="",i=0,o=!0;for(let a of t)if(a===" ")if(r&&!o)s+=a,i++;else{let l=c0(i,n);s+=" ".repeat(l),i+=l}else a!==" "&&a!==" "&&(o=!1),s+=a,i++;return s}function Il(t,e){if(t==="")return"";let n=t.split(`
372
376
  `),r=t.endsWith(`
373
- `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>n0(i,e)).join(`
377
+ `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>u0(i,e)).join(`
374
378
  `)+(r?`
375
- `:"")}var e0,r0,kl=C(()=>{"use strict";j();e0={name:"expand",summary:"convert tabs to spaces",usage:"expand [OPTION]... [FILE]...",description:"Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-i Only convert leading tabs on each line"],examples:["expand file.txt # Convert all tabs to 8 spaces","expand -t 4 file.txt # Use 4-space tabs","expand -t 4,8,12 file.txt # Custom tab stops"]};r0={name:"expand",execute:async(t,e)=>{if(I(t))return N(e0);let n={tabStops:[8],leadingOnly:!1},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=fr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
376
- `};n.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=fr(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(2)}'
377
- `};n.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=fr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
378
- `};n.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=fr(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(7)}'
379
- `};n.tabStops=a,s++}else if(o==="-i"||o==="--initial")n.leadingOnly=!0,s++;else if(o==="--"){r.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return D("expand",o);r.push(o),s++}}let i="";if(r.length===0){let o=e.stdin??"";i=Cl(o,n)}else for(let o of r){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`expand: ${o}: No such file or directory
380
- `};i+=Cl(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var vl={};L(vl,{unexpand:()=>o0});function dr(t){let e=t.split(",").map(r=>r.trim()),n=[];for(let r of e){let s=parseInt(r,10);if(Number.isNaN(s)||s<1)return null;n.push(s)}for(let r=1;r<n.length;r++)if(n[r]<=n[r-1])return null;return n}function Nl(t,e){if(e.length===1){let n=e[0];return t+(n-t%n)}for(let n of e)if(n>t)return n;if(e.length>=2){let n=e[e.length-1]-e[e.length-2],r=e[e.length-1],s=Math.floor((t-r)/n)+1;return r+s*n}return-1}function i0(t,e){let{tabStops:n,allBlanks:r}=e,s="",i=0,o="",a=0,l=!0,c=()=>{if(o.length===0)return;let u=a+o.length;if(!r&&!l){s+=o,o="";return}let f=a,d="";for(;f<u;){let h=Nl(f,n);if(h<=u&&h>f)d+=" ",f=h;else break}let p=u-f;p>0&&(d+=" ".repeat(p)),s+=d,o=""};for(let u of t)u===" "?(o.length===0&&(a=i),o+=u,i++):u===" "?(c(),s+=u,i=Nl(i,n)):(c(),s+=u,i++,l=!1);return c(),s}function Il(t,e){if(t==="")return"";let n=t.split(`
379
+ `:"")}var l0,f0,$l=C(()=>{"use strict";j();l0={name:"expand",summary:"convert tabs to spaces",usage:"expand [OPTION]... [FILE]...",description:"Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-i Only convert leading tabs on each line"],examples:["expand file.txt # Convert all tabs to 8 spaces","expand -t 4 file.txt # Use 4-space tabs","expand -t 4,8,12 file.txt # Custom tab stops"]};f0={name:"expand",execute:async(t,e)=>{if(N(t))return k(l0);let n={tabStops:[8],leadingOnly:!1},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=dr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
380
+ `};n.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=dr(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(2)}'
381
+ `};n.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=dr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
382
+ `};n.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=dr(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(7)}'
383
+ `};n.tabStops=a,s++}else if(o==="-i"||o==="--initial")n.leadingOnly=!0,s++;else if(o==="--"){r.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return L("expand",o);r.push(o),s++}}let i="";if(r.length===0){let o=e.stdin??"";i=Il(o,n)}else for(let o of r){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`expand: ${o}: No such file or directory
384
+ `};i+=Il(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var Pl={};_(Pl,{unexpand:()=>h0});function pr(t){let e=t.split(",").map(r=>r.trim()),n=[];for(let r of e){let s=parseInt(r,10);if(Number.isNaN(s)||s<1)return null;n.push(s)}for(let r=1;r<n.length;r++)if(n[r]<=n[r-1])return null;return n}function Rl(t,e){if(e.length===1){let n=e[0];return t+(n-t%n)}for(let n of e)if(n>t)return n;if(e.length>=2){let n=e[e.length-1]-e[e.length-2],r=e[e.length-1],s=Math.floor((t-r)/n)+1;return r+s*n}return-1}function p0(t,e){let{tabStops:n,allBlanks:r}=e,s="",i=0,o="",a=0,l=!0,c=()=>{if(o.length===0)return;let u=a+o.length;if(!r&&!l){s+=o,o="";return}let f=a,d="";for(;f<u;){let h=Rl(f,n);if(h<=u&&h>f)d+=" ",f=h;else break}let p=u-f;p>0&&(d+=" ".repeat(p)),s+=d,o=""};for(let u of t)u===" "?(o.length===0&&(a=i),o+=u,i++):u===" "?(c(),s+=u,i=Rl(i,n)):(c(),s+=u,i++,l=!1);return c(),s}function Fl(t,e){if(t==="")return"";let n=t.split(`
381
385
  `),r=t.endsWith(`
382
- `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>i0(i,e)).join(`
386
+ `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>p0(i,e)).join(`
383
387
  `)+(r?`
384
- `:"")}var s0,o0,$l=C(()=>{"use strict";j();s0={name:"unexpand",summary:"convert spaces to tabs",usage:"unexpand [OPTION]... [FILE]...",description:"Convert blanks in each FILE to TABs, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-a Convert all sequences of blanks (not just leading)"],examples:["unexpand file.txt # Convert leading spaces to tabs","unexpand -a file.txt # Convert all space sequences","unexpand -t 4 file.txt # Use 4-space tabs"]};o0={name:"unexpand",execute:async(t,e)=>{if(I(t))return N(s0);let n={tabStops:[8],allBlanks:!1},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=dr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
385
- `};n.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=dr(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(2)}'
386
- `};n.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=dr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
387
- `};n.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=dr(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(7)}'
388
- `};n.tabStops=a,s++}else if(o==="-a"||o==="--all")n.allBlanks=!0,s++;else if(o==="--"){r.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return D("unexpand",o);r.push(o),s++}}let i="";if(r.length===0){let o=e.stdin??"";i=Il(o,n)}else for(let o of r){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`unexpand: ${o}: No such file or directory
389
- `};i+=Il(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var Fl={};L(Fl,{strings:()=>c0});function l0(t){return t>=32&&t<=126||t===9}function Rl(t,e){if(e===null)return"";switch(e){case"o":return`${t.toString(8).padStart(7," ")} `;case"x":return`${t.toString(16).padStart(7," ")} `;case"d":return`${t.toString(10).padStart(7," ")} `;default:return e}}function Pl(t,e){let n=[],r="",s=0,i=typeof t=="string"?new TextEncoder().encode(t):t;for(let o=0;o<i.length;o++){let a=i[o];if(l0(a))r.length===0&&(s=o),r+=String.fromCharCode(a);else{if(r.length>=e.minLength){let l=Rl(s,e.offsetFormat);n.push(`${l}${r}`)}r=""}}if(r.length>=e.minLength){let o=Rl(s,e.offsetFormat);n.push(`${o}${r}`)}return n}var a0,c0,Tl=C(()=>{"use strict";j();a0={name:"strings",summary:"print the sequences of printable characters in files",usage:"strings [OPTION]... [FILE]...",description:"For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.",options:["-n MIN Print sequences of at least MIN characters (default: 4)","-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)","-a Scan the entire file (default behavior)","-e ENCODING Select character encoding (s=7-bit, S=8-bit)"],examples:["strings file.bin # Extract strings (min 4 chars)","strings -n 8 file.bin # Extract strings (min 8 chars)","strings -t x file.bin # Show hex offset","echo 'hello' | strings # Read from stdin"]};c0={name:"strings",execute:async(t,e)=>{if(I(t))return N(a0);let n={minLength:4,offsetFormat:null},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-n"&&s+1<t.length){let a=Number.parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${t[s+1]}'
388
+ `:"")}var d0,h0,Tl=C(()=>{"use strict";j();d0={name:"unexpand",summary:"convert spaces to tabs",usage:"unexpand [OPTION]... [FILE]...",description:"Convert blanks in each FILE to TABs, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-a Convert all sequences of blanks (not just leading)"],examples:["unexpand file.txt # Convert leading spaces to tabs","unexpand -a file.txt # Convert all space sequences","unexpand -t 4 file.txt # Use 4-space tabs"]};h0={name:"unexpand",execute:async(t,e)=>{if(N(t))return k(d0);let n={tabStops:[8],allBlanks:!1},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=pr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
389
+ `};n.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=pr(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(2)}'
390
+ `};n.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=pr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
391
+ `};n.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=pr(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(7)}'
392
+ `};n.tabStops=a,s++}else if(o==="-a"||o==="--all")n.allBlanks=!0,s++;else if(o==="--"){r.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return L("unexpand",o);r.push(o),s++}}let i="";if(r.length===0){let o=e.stdin??"";i=Fl(o,n)}else for(let o of r){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`unexpand: ${o}: No such file or directory
393
+ `};i+=Fl(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var Ll={};_(Ll,{strings:()=>y0});function g0(t){return t>=32&&t<=126||t===9}function Ol(t,e){if(e===null)return"";switch(e){case"o":return`${t.toString(8).padStart(7," ")} `;case"x":return`${t.toString(16).padStart(7," ")} `;case"d":return`${t.toString(10).padStart(7," ")} `;default:return e}}function Dl(t,e){let n=[],r="",s=0,i=typeof t=="string"?new TextEncoder().encode(t):t;for(let o=0;o<i.length;o++){let a=i[o];if(g0(a))r.length===0&&(s=o),r+=String.fromCharCode(a);else{if(r.length>=e.minLength){let l=Ol(s,e.offsetFormat);n.push(`${l}${r}`)}r=""}}if(r.length>=e.minLength){let o=Ol(s,e.offsetFormat);n.push(`${o}${r}`)}return n}var m0,y0,Ml=C(()=>{"use strict";j();m0={name:"strings",summary:"print the sequences of printable characters in files",usage:"strings [OPTION]... [FILE]...",description:"For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.",options:["-n MIN Print sequences of at least MIN characters (default: 4)","-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)","-a Scan the entire file (default behavior)","-e ENCODING Select character encoding (s=7-bit, S=8-bit)"],examples:["strings file.bin # Extract strings (min 4 chars)","strings -n 8 file.bin # Extract strings (min 8 chars)","strings -t x file.bin # Show hex offset","echo 'hello' | strings # Read from stdin"]};y0={name:"strings",execute:async(t,e)=>{if(N(t))return k(m0);let n={minLength:4,offsetFormat:null},r=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-n"&&s+1<t.length){let a=Number.parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${t[s+1]}'
390
394
  `};n.minLength=a,s+=2}else if(o.match(/^-n\d+$/)){let a=Number.parseInt(o.slice(2),10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${o.slice(2)}'
391
395
  `};n.minLength=a,s++}else if(o.match(/^-\d+$/)){let a=Number.parseInt(o.slice(1),10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${o.slice(1)}'
392
396
  `};n.minLength=a,s++}else if(o==="-t"&&s+1<t.length){let a=t[s+1];if(a!=="o"&&a!=="x"&&a!=="d")return{exitCode:1,stdout:"",stderr:`strings: invalid radix: '${a}'
393
397
  `};n.offsetFormat=a,s+=2}else if(o.startsWith("-t")&&o.length===3){let a=o[2];if(a!=="o"&&a!=="x"&&a!=="d")return{exitCode:1,stdout:"",stderr:`strings: invalid radix: '${a}'
394
398
  `};n.offsetFormat=a,s++}else if(o==="-a"||o==="--all"||o==="-")o==="-"&&r.push(o),s++;else if(o==="-e"&&s+1<t.length){let a=t[s+1];if(a!=="s"&&a!=="S")return{exitCode:1,stdout:"",stderr:`strings: invalid encoding: '${a}'
395
399
  `};s+=2}else if(o.startsWith("-e")&&o.length===3){let a=o[2];if(a!=="s"&&a!=="S")return{exitCode:1,stdout:"",stderr:`strings: invalid encoding: '${a}'
396
- `};s++}else if(o==="--"){r.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return D("strings",o);r.push(o),s++}}let i="";if(r.length===0){let o=e.stdin??"",a=Pl(o,n);i=a.length>0?`${a.join(`
400
+ `};s++}else if(o==="--"){r.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return L("strings",o);r.push(o),s++}}let i="";if(r.length===0){let o=e.stdin??"",a=Dl(o,n);i=a.length>0?`${a.join(`
397
401
  `)}
398
402
  `:""}else for(let o of r){let a;if(o==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,o);if(a=await e.fs.readFile(c),a===null)return{exitCode:1,stdout:i,stderr:`strings: ${o}: No such file or directory
399
- `}}let l=Pl(a,n);l.length>0&&(i+=`${l.join(`
403
+ `}}let l=Dl(a,n);l.length>0&&(i+=`${l.join(`
400
404
  `)}
401
- `)}return{exitCode:0,stdout:i,stderr:""}}}});var Dl={};L(Dl,{split:()=>m0});function Ol(t){let e=t.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!e)return null;let n=Number.parseInt(e[1],10);if(Number.isNaN(n)||n<1)return null;let r=(e[2]||"").toUpperCase(),i={"":1,K:1024,M:1024*1024,G:1024*1024*1024,T:1024*1024*1024*1024,P:1024*1024*1024*1024*1024}[r];return i===void 0?null:n*i}function f0(t,e,n){if(e)return t.toString().padStart(n,"0");let r="abcdefghijklmnopqrstuvwxyz",s="",i=t;for(let o=0;o<n;o++)s=r[i%26]+s,i=Math.floor(i/26);return s}function d0(t,e){let n=t.split(`
405
+ `)}return{exitCode:0,stdout:i,stderr:""}}}});var Bl={};_(Bl,{split:()=>C0});function _l(t){let e=t.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!e)return null;let n=Number.parseInt(e[1],10);if(Number.isNaN(n)||n<1)return null;let r=(e[2]||"").toUpperCase(),i={"":1,K:1024,M:1024*1024,G:1024*1024*1024,T:1024*1024*1024*1024,P:1024*1024*1024*1024*1024}[r];return i===void 0?null:n*i}function w0(t,e,n){if(e)return t.toString().padStart(n,"0");let r="abcdefghijklmnopqrstuvwxyz",s="",i=t;for(let o=0;o<n;o++)s=r[i%26]+s,i=Math.floor(i/26);return s}function b0(t,e){let n=t.split(`
402
406
  `),r=t.endsWith(`
403
407
  `)&&n[n.length-1]==="";r&&n.pop();let s=[];for(let i=0;i<n.length;i+=e){let o=n.slice(i,i+e),l=i+e>=n.length&&!r?o.join(`
404
408
  `):`${o.join(`
405
409
  `)}
406
- `;s.push({content:l,hasContent:!0})}return s}function p0(t,e){let r=new TextEncoder().encode(t),s=new TextDecoder,i=[];for(let o=0;o<r.length;o+=e){let a=r.slice(o,o+e);i.push({content:s.decode(a),hasContent:a.length>0})}return i}function h0(t,e){let r=new TextEncoder().encode(t),s=new TextDecoder,i=[],o=Math.ceil(r.length/e);for(let a=0;a<e;a++){let l=a*o,c=Math.min(l+o,r.length),u=r.slice(l,c);i.push({content:s.decode(u),hasContent:u.length>0})}return i}var u0,m0,Ll=C(()=>{"use strict";j();u0={name:"split",summary:"split a file into pieces",usage:"split [OPTION]... [FILE [PREFIX]]",description:"Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.",options:["-l N Put N lines per output file","-b SIZE Put SIZE bytes per output file (K, M, G suffixes)","-n CHUNKS Split into CHUNKS equal-sized files","-d Use numeric suffixes (00, 01, ...) instead of alphabetic","-a LENGTH Use suffixes of length LENGTH (default: 2)","--additional-suffix=SUFFIX Append SUFFIX to file names"],examples:["split -l 100 file.txt # Split into 100-line chunks","split -b 1M file.bin # Split into 1MB chunks","split -n 5 file.txt # Split into 5 equal parts","split -d file.txt part_ # part_00, part_01, ...","split -a 3 -d file.txt x # x000, x001, ..."]};m0={name:"split",execute:async(t,e)=>{if(I(t))return N(u0);let n={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},r=[],s=0;for(;s<t.length;){let c=t[s];if(c==="-l"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${t[s+1]}'
410
+ `;s.push({content:l,hasContent:!0})}return s}function E0(t,e){let r=new TextEncoder().encode(t),s=new TextDecoder,i=[];for(let o=0;o<r.length;o+=e){let a=r.slice(o,o+e);i.push({content:s.decode(a),hasContent:a.length>0})}return i}function S0(t,e){let r=new TextEncoder().encode(t),s=new TextDecoder,i=[],o=Math.ceil(r.length/e);for(let a=0;a<e;a++){let l=a*o,c=Math.min(l+o,r.length),u=r.slice(l,c);i.push({content:s.decode(u),hasContent:u.length>0})}return i}var x0,C0,Wl=C(()=>{"use strict";j();x0={name:"split",summary:"split a file into pieces",usage:"split [OPTION]... [FILE [PREFIX]]",description:"Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.",options:["-l N Put N lines per output file","-b SIZE Put SIZE bytes per output file (K, M, G suffixes)","-n CHUNKS Split into CHUNKS equal-sized files","-d Use numeric suffixes (00, 01, ...) instead of alphabetic","-a LENGTH Use suffixes of length LENGTH (default: 2)","--additional-suffix=SUFFIX Append SUFFIX to file names"],examples:["split -l 100 file.txt # Split into 100-line chunks","split -b 1M file.bin # Split into 1MB chunks","split -n 5 file.txt # Split into 5 equal parts","split -d file.txt part_ # part_00, part_01, ...","split -a 3 -d file.txt x # x000, x001, ..."]};C0={name:"split",execute:async(t,e)=>{if(N(t))return k(x0);let n={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},r=[],s=0;for(;s<t.length;){let c=t[s];if(c==="-l"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${t[s+1]}'
407
411
  `};n.mode="lines",n.lines=u,s+=2}else if(c.match(/^-l\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${c.slice(2)}'
408
- `};n.mode="lines",n.lines=u,s++}else if(c==="-b"&&s+1<t.length){let u=Ol(t[s+1]);if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${t[s+1]}'
409
- `};n.mode="bytes",n.bytes=u,s+=2}else if(c.match(/^-b.+$/)){let u=Ol(c.slice(2));if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${c.slice(2)}'
412
+ `};n.mode="lines",n.lines=u,s++}else if(c==="-b"&&s+1<t.length){let u=_l(t[s+1]);if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${t[s+1]}'
413
+ `};n.mode="bytes",n.bytes=u,s+=2}else if(c.match(/^-b.+$/)){let u=_l(c.slice(2));if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${c.slice(2)}'
410
414
  `};n.mode="bytes",n.bytes=u,s++}else if(c==="-n"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of chunks: '${t[s+1]}'
411
415
  `};n.mode="chunks",n.chunks=u,s+=2}else if(c.match(/^-n\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of chunks: '${c.slice(2)}'
412
416
  `};n.mode="chunks",n.chunks=u,s++}else if(c==="-a"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${t[s+1]}'
413
417
  `};n.suffixLength=u,s+=2}else if(c.match(/^-a\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${c.slice(2)}'
414
- `};n.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")n.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))n.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<t.length)n.additionalSuffix=t[s+1],s+=2;else if(c==="--"){r.push(...t.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return D("split",c);r.push(c),s++}}let i="-",o="x";r.length>=1&&(i=r[0]),r.length>=2&&(o=r[1]);let a;if(i==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,i),u=await e.fs.readFile(c);if(u===null)return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
415
- `};a=u}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(n.mode){case"lines":l=d0(a,n.lines);break;case"bytes":l=p0(a,n.bytes);break;case"chunks":l=h0(a,n.chunks);break;default:return n.mode}for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=f0(c,n.useNumericSuffix,n.suffixLength),d=`${o}${f}${n.additionalSuffix}`,p=e.fs.resolvePath(e.cwd,d);await e.fs.writeFile(p,u.content)}return{exitCode:0,stdout:"",stderr:""}}}});var _l={};L(_l,{column:()=>E0});function Ml(t,e,n){return e?n?t.split(e):t.split(e).filter(r=>r.length>0):n?t.split(/[ \t]/):t.split(/[ \t]+/).filter(r=>r.length>0)}function x0(t){let e=[];for(let n of t)for(let r=0;r<n.length;r++){let s=n[r].length;(e[r]===void 0||s>e[r])&&(e[r]=s)}return e}function w0(t,e){if(t.length===0)return"";let n=x0(t),r=[];for(let s of t){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(n[o]));r.push(i.join(e))}return r.join(`
416
- `)}function b0(t,e,n){if(t.length===0)return"";let r=Math.max(...t.map(c=>c.length)),s=n.length,i=r+s,o=Math.max(1,Math.floor((e+s)/i)),a=Math.ceil(t.length/o),l=[];for(let c=0;c<a;c++){let u=[];for(let f=0;f<o;f++){let d=f*a+c;d<t.length&&(f===o-1||(f+1)*a+c>=t.length?u.push(t[d]):u.push(t[d].padEnd(r)))}l.push(u.join(n))}return l.join(`
417
- `)}var g0,y0,E0,Bl=C(()=>{"use strict";Ae();j();g0={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},y0={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};E0={name:"column",execute:async(t,e)=>{if(I(t))return N(g0);let n=K("column",t,y0);if(!n.ok)return n.error;let{table:r,separator:s,outputSep:i,width:o,noMerge:a}=n.result.flags,l=n.result.positional,c=i??" ",u;if(l.length===0)u=e.stdin??"";else{let m=[];for(let g of l)if(g==="-")m.push(e.stdin??"");else{let w=e.fs.resolvePath(e.cwd,g),b=await e.fs.readFile(w);if(b===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
418
- `};m.push(b)}u=m.join("")}if(u===""||u.trim()==="")return{exitCode:0,stdout:"",stderr:""};let f=u.split(`
418
+ `};n.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")n.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))n.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<t.length)n.additionalSuffix=t[s+1],s+=2;else if(c==="--"){r.push(...t.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return L("split",c);r.push(c),s++}}let i="-",o="x";r.length>=1&&(i=r[0]),r.length>=2&&(o=r[1]);let a;if(i==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,i),u=await e.fs.readFile(c);if(u===null)return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
419
+ `};a=u}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(n.mode){case"lines":l=b0(a,n.lines);break;case"bytes":l=E0(a,n.bytes);break;case"chunks":l=S0(a,n.chunks);break;default:return n.mode}for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=w0(c,n.useNumericSuffix,n.suffixLength),d=`${o}${f}${n.additionalSuffix}`,p=e.fs.resolvePath(e.cwd,d);await e.fs.writeFile(p,u.content)}return{exitCode:0,stdout:"",stderr:""}}}});var jl={};_(jl,{column:()=>$0});function Ul(t,e,n){return e?n?t.split(e):t.split(e).filter(r=>r.length>0):n?t.split(/[ \t]/):t.split(/[ \t]+/).filter(r=>r.length>0)}function N0(t){let e=[];for(let n of t)for(let r=0;r<n.length;r++){let s=n[r].length;(e[r]===void 0||s>e[r])&&(e[r]=s)}return e}function I0(t,e){if(t.length===0)return"";let n=N0(t),r=[];for(let s of t){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(n[o]));r.push(i.join(e))}return r.join(`
420
+ `)}function v0(t,e,n){if(t.length===0)return"";let r=Math.max(...t.map(c=>c.length)),s=n.length,i=r+s,o=Math.max(1,Math.floor((e+s)/i)),a=Math.ceil(t.length/o),l=[];for(let c=0;c<a;c++){let u=[];for(let f=0;f<o;f++){let d=f*a+c;d<t.length&&(f===o-1||(f+1)*a+c>=t.length?u.push(t[d]):u.push(t[d].padEnd(r)))}l.push(u.join(n))}return l.join(`
421
+ `)}var A0,k0,$0,zl=C(()=>{"use strict";Ae();j();A0={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},k0={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};$0={name:"column",execute:async(t,e)=>{if(N(t))return k(A0);let n=Q("column",t,k0);if(!n.ok)return n.error;let{table:r,separator:s,outputSep:i,width:o,noMerge:a}=n.result.flags,l=n.result.positional,c=i??" ",u;if(l.length===0)u=e.stdin??"";else{let m=[];for(let g of l)if(g==="-")m.push(e.stdin??"");else{let b=e.fs.resolvePath(e.cwd,g),w=await e.fs.readFile(b);if(w===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
422
+ `};m.push(w)}u=m.join("")}if(u===""||u.trim()==="")return{exitCode:0,stdout:"",stderr:""};let f=u.split(`
419
423
  `);u.endsWith(`
420
- `)&&f[f.length-1]===""&&f.pop();let p=f.filter(m=>m.trim().length>0),h;if(r){let m=p.map(g=>Ml(g,s,a));h=w0(m,c)}else{let m=[];for(let g of p){let w=Ml(g,s,a);m.push(...w)}h=b0(m,o,c)}return h.length>0&&(h+=`
421
- `),{exitCode:0,stdout:h,stderr:""}}}});var Wl={};L(Wl,{join:()=>N0});function C0(t,e){return e?t.split(e):t.split(/[ \t]+/).filter(n=>n.length>0)}function A0(t,e,n,r){let s=C0(t,e),i=s[n-1]??"";return r&&(i=i.toLowerCase()),{fields:s,joinKey:i,original:t}}function vs(t,e,n){let r=n.separator??" ";if(n.outputFormat){let o=[];for(let{file:a,field:l}of n.outputFormat){let c=a===1?t:e;c&&l===0?o.push(c.joinKey):c&&c.fields[l-1]!==void 0?o.push(c.fields[l-1]):o.push(n.emptyString)}return o.join(r)}let s=[],i=t?.joinKey??e?.joinKey??"";if(s.push(i),t)for(let o=0;o<t.fields.length;o++)o!==n.field1-1&&s.push(t.fields[o]);if(e)for(let o=0;o<e.fields.length;o++)o!==n.field2-1&&s.push(e.fields[o]);return s.join(r)}function k0(t){let e=t.split(","),n=[];for(let r of e){let s=r.trim().match(/^(\d+)\.(\d+)$/);if(!s)return null;let i=Number.parseInt(s[1],10),o=Number.parseInt(s[2],10);if(i!==1&&i!==2)return null;n.push({file:i,field:o})}return n}var S0,N0,Ul=C(()=>{"use strict";j();S0={name:"join",summary:"join lines of two files on a common field",usage:"join [OPTION]... FILE1 FILE2",description:"For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.",options:["-1 FIELD Join on this FIELD of file 1 (default: 1)","-2 FIELD Join on this FIELD of file 2 (default: 1)","-t CHAR Use CHAR as input and output field separator","-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)","-v FILENUM Like -a but only output unpairable lines","-e STRING Replace missing fields with STRING","-o FORMAT Output format (comma-separated list of FILENUM.FIELD)","-i Ignore case when comparing fields"],examples:["join file1 file2 # Join on first field","join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1","join -t ',' file1.csv file2.csv # Join CSV files","join -a 1 file1 file2 # Left outer join"]};N0={name:"join",execute:async(t,e)=>{if(I(t))return N(S0);let n={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},r=[],s=0;for(;s<t.length;){let d=t[s];if(d==="-1"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${t[s+1]}'
424
+ `)&&f[f.length-1]===""&&f.pop();let p=f.filter(m=>m.trim().length>0),h;if(r){let m=p.map(g=>Ul(g,s,a));h=I0(m,c)}else{let m=[];for(let g of p){let b=Ul(g,s,a);m.push(...b)}h=v0(m,o,c)}return h.length>0&&(h+=`
425
+ `),{exitCode:0,stdout:h,stderr:""}}}});var Hl={};_(Hl,{join:()=>O0});function F0(t,e){return e?t.split(e):t.split(/[ \t]+/).filter(n=>n.length>0)}function P0(t,e,n,r){let s=F0(t,e),i=s[n-1]??"";return r&&(i=i.toLowerCase()),{fields:s,joinKey:i,original:t}}function Rs(t,e,n){let r=n.separator??" ";if(n.outputFormat){let o=[];for(let{file:a,field:l}of n.outputFormat){let c=a===1?t:e;c&&l===0?o.push(c.joinKey):c&&c.fields[l-1]!==void 0?o.push(c.fields[l-1]):o.push(n.emptyString)}return o.join(r)}let s=[],i=t?.joinKey??e?.joinKey??"";if(s.push(i),t)for(let o=0;o<t.fields.length;o++)o!==n.field1-1&&s.push(t.fields[o]);if(e)for(let o=0;o<e.fields.length;o++)o!==n.field2-1&&s.push(e.fields[o]);return s.join(r)}function T0(t){let e=t.split(","),n=[];for(let r of e){let s=r.trim().match(/^(\d+)\.(\d+)$/);if(!s)return null;let i=Number.parseInt(s[1],10),o=Number.parseInt(s[2],10);if(i!==1&&i!==2)return null;n.push({file:i,field:o})}return n}var R0,O0,Gl=C(()=>{"use strict";j();R0={name:"join",summary:"join lines of two files on a common field",usage:"join [OPTION]... FILE1 FILE2",description:"For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.",options:["-1 FIELD Join on this FIELD of file 1 (default: 1)","-2 FIELD Join on this FIELD of file 2 (default: 1)","-t CHAR Use CHAR as input and output field separator","-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)","-v FILENUM Like -a but only output unpairable lines","-e STRING Replace missing fields with STRING","-o FORMAT Output format (comma-separated list of FILENUM.FIELD)","-i Ignore case when comparing fields"],examples:["join file1 file2 # Join on first field","join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1","join -t ',' file1.csv file2.csv # Join CSV files","join -a 1 file1 file2 # Left outer join"]};O0={name:"join",execute:async(t,e)=>{if(N(t))return k(R0);let n={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},r=[],s=0;for(;s<t.length;){let d=t[s];if(d==="-1"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${t[s+1]}'
422
426
  `};n.field1=p,s+=2}else if(d==="-2"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${t[s+1]}'
423
427
  `};n.field2=p,s+=2}else if((d==="-t"||d==="--field-separator")&&s+1<t.length)n.separator=t[s+1],s+=2;else if(d.startsWith("-t")&&d.length>2)n.separator=d.slice(2),s++;else if(d==="-a"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(p!==1&&p!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${t[s+1]}'
424
428
  `};n.printUnpairable.add(p),s+=2}else if(d.match(/^-a[12]$/))n.printUnpairable.add(Number.parseInt(d[2],10)),s++;else if(d==="-v"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(p!==1&&p!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${t[s+1]}'
425
- `};n.onlyUnpairable.add(p),s+=2}else if(d.match(/^-v[12]$/))n.onlyUnpairable.add(Number.parseInt(d[2],10)),s++;else if(d==="-e"&&s+1<t.length)n.emptyString=t[s+1],s+=2;else if(d==="-o"&&s+1<t.length){let p=k0(t[s+1]);if(!p)return{exitCode:1,stdout:"",stderr:`join: invalid field spec: '${t[s+1]}'
426
- `};n.outputFormat=p,s+=2}else if(d==="-i"||d==="--ignore-case")n.ignoreCase=!0,s++;else if(d==="--"){r.push(...t.slice(s+1));break}else{if(d.startsWith("-")&&d!=="-")return D("join",d);r.push(d),s++}}if(r.length!==2)return{exitCode:1,stdout:"",stderr:r.length<2?`join: missing file operand
429
+ `};n.onlyUnpairable.add(p),s+=2}else if(d.match(/^-v[12]$/))n.onlyUnpairable.add(Number.parseInt(d[2],10)),s++;else if(d==="-e"&&s+1<t.length)n.emptyString=t[s+1],s+=2;else if(d==="-o"&&s+1<t.length){let p=T0(t[s+1]);if(!p)return{exitCode:1,stdout:"",stderr:`join: invalid field spec: '${t[s+1]}'
430
+ `};n.outputFormat=p,s+=2}else if(d==="-i"||d==="--ignore-case")n.ignoreCase=!0,s++;else if(d==="--"){r.push(...t.slice(s+1));break}else{if(d.startsWith("-")&&d!=="-")return L("join",d);r.push(d),s++}}if(r.length!==2)return{exitCode:1,stdout:"",stderr:r.length<2?`join: missing file operand
427
431
  `:`join: extra operand
428
432
  `};let i=[];for(let d of r)if(d==="-")i.push(e.stdin??"");else{let p=e.fs.resolvePath(e.cwd,d),h=await e.fs.readFile(p);if(h===null)return{exitCode:1,stdout:"",stderr:`join: ${d}: No such file or directory
429
433
  `};i.push(h)}let o=(d,p)=>{let h=d.split(`
430
434
  `);return d.endsWith(`
431
- `)&&h[h.length-1]===""&&h.pop(),h.filter(m=>m.length>0).map(m=>A0(m,n.separator,p,n.ignoreCase))},a=o(i[0],n.field1),l=o(i[1],n.field2),c=new Map;for(let d of l){let p=c.get(d.joinKey);p?p.push(d):c.set(d.joinKey,[d])}let u=[],f=new Set;for(let d of a){let p=c.get(d.joinKey);if(p&&p.length>0){if(f.add(d.joinKey),n.onlyUnpairable.size===0)for(let h of p)u.push(vs(d,h,n))}else(n.printUnpairable.has(1)||n.onlyUnpairable.has(1))&&u.push(vs(d,null,n))}if(n.printUnpairable.has(2)||n.onlyUnpairable.has(2))for(let d of l)f.has(d.joinKey)||u.push(vs(null,d,n));return{exitCode:0,stdout:u.length>0?`${u.join(`
435
+ `)&&h[h.length-1]===""&&h.pop(),h.filter(m=>m.length>0).map(m=>P0(m,n.separator,p,n.ignoreCase))},a=o(i[0],n.field1),l=o(i[1],n.field2),c=new Map;for(let d of l){let p=c.get(d.joinKey);p?p.push(d):c.set(d.joinKey,[d])}let u=[],f=new Set;for(let d of a){let p=c.get(d.joinKey);if(p&&p.length>0){if(f.add(d.joinKey),n.onlyUnpairable.size===0)for(let h of p)u.push(Rs(d,h,n))}else(n.printUnpairable.has(1)||n.onlyUnpairable.has(1))&&u.push(Rs(d,null,n))}if(n.printUnpairable.has(2)||n.onlyUnpairable.has(2))for(let d of l)f.has(d.joinKey)||u.push(Rs(null,d,n));return{exitCode:0,stdout:u.length>0?`${u.join(`
432
436
  `)}
433
- `:"",stderr:""}}}});var jl={};L(jl,{teeCommand:()=>$0});var I0,v0,$0,zl=C(()=>{"use strict";Ae();j();I0={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append append to the given FILEs, do not overwrite"," --help display this help and exit"]},v0={append:{short:"a",long:"append",type:"boolean"}},$0={name:"tee",async execute(t,e){if(I(t))return N(I0);let n=K("tee",t,v0);if(!n.ok)return n.error;let{append:r}=n.result.flags,s=n.result.positional,i=e.stdin,o="",a=0;for(let l of s)try{let c=e.fs.resolvePath(e.cwd,l);r?await e.fs.appendFile(c,i):await e.fs.writeFile(c,i)}catch{o+=`tee: ${l}: No such file or directory
434
- `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function Je(t,e){switch(t.type){case"name":{let n=t.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],i=e.name;if(t.ignoreCase){if(!i.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Le(e.name,n,t.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=t.pattern,r=e.relativePath,s=n.split("/");for(let o=0;o<s.length-1;o++){let a=s[o];if(a&&a!=="."&&a!==".."&&!a.includes("*")&&!a.includes("?")&&!a.includes("[")){let l=`/${a}/`;if(t.ignoreCase){if(!r.toLowerCase().includes(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(l))return{matches:!1,pruned:!1,printed:!1}}}let i=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let o=i[1];if(t.ignoreCase){if(!r.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(o))return{matches:!1,pruned:!1,printed:!1}}return{matches:Le(r,n,t.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=t.ignoreCase?"i":"";return{matches:new RegExp(t.pattern,n).test(e.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return t.fileType==="f"?{matches:e.isFile,pruned:!1,printed:!1}:t.fileType==="d"?{matches:e.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:e.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-e.mtime)/(1e3*60*60*24),s;return t.comparison==="more"?s=r>t.days:t.comparison==="less"?s=r<t.days:s=Math.floor(r)===t.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=e.newerRefTimes.get(t.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:e.mtime>n,pruned:!1,printed:!1}}case"size":{let n=t.value;switch(t.unit){case"c":n=t.value;break;case"k":n=t.value*1024;break;case"M":n=t.value*1024*1024;break;case"G":n=t.value*1024*1024*1024;break;case"b":n=t.value*512;break}let r;return t.comparison==="more"?r=e.size>n:t.comparison==="less"?r=e.size<n:t.unit==="b"?r=Math.ceil(e.size/512)===t.value:r=e.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=e.mode&511,r=t.mode&511,s;return t.matchType==="exact"?s=n===r:t.matchType==="all"?s=(n&r)===r:s=(n&r)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=Je(t.expr,e);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=Je(t.left,e);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=Je(t.right,e);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=Je(t.left,e);if(n.matches)return n;let r=Je(t.right,e);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function Nn(t){if(!t)return!1;switch(t.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return Nn(t.expr);case"and":case"or":return Nn(t.left)||Nn(t.right)}}function In(t){if(!t)return!1;switch(t.type){case"empty":return!0;case"not":return In(t.expr);case"and":case"or":return In(t.left)||In(t.right);default:return!1}}function Hl(t){let e={terminalDirName:null,requiredExtension:null};if(!t)return e;let n=R0(t);if(P0(t)&&n.length===1){let i=n[0].split("/").filter(o=>o.length>0);if(i.length>=2)for(let o=i.length-2;o>=0;o--){let a=i[o];if(!a.includes("*")&&!a.includes("?")&&!a.includes("[")&&a!=="."&&a!==".."){let l=i[o+1];if(l&&(l.includes("*")||l.includes("?"))){e.terminalDirName=a;let c=l.match(/^\*(\.[a-zA-Z0-9]+)$/);c&&(e.requiredExtension=c[1])}break}}}return e}function R0(t){let e=[],n=r=>{r.type==="path"?e.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(t),e}function P0(t){let e=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?e(n.expr):n.type==="and"||n.type==="or"?e(n.left)||e(n.right):!1;return e(t)}function Gl(t){let e=[],n=r=>{r&&(r.type==="newer"?e.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(t),e}function vn(t){if(!t)return!0;switch(t.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return vn(t.expr);case"and":case"or":return vn(t.left)&&vn(t.right)}}function Pt(t,e,n,r,s){switch(t.type){case"name":{let i=t.pattern,o=i.match(/^\*(\.[a-zA-Z0-9]+)$/);if(o){let a=o[1];if(t.ignoreCase){if(!e.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!e.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Le(e,i,t.ignoreCase),pruned:!1,printed:!1}}case"path":{let i=t.pattern,o=i.split("/");for(let l=0;l<o.length-1;l++){let c=o[l];if(c&&c!=="."&&c!==".."&&!c.includes("*")&&!c.includes("?")&&!c.includes("[")){let u=`/${c}/`;if(t.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let a=i.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let l=a[1];if(t.ignoreCase){if(!n.toLowerCase().endsWith(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(l))return{matches:!1,pruned:!1,printed:!1}}return{matches:Le(n,i,t.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let i=t.ignoreCase?"i":"";return{matches:new RegExp(t.pattern,i).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return t.fileType==="f"?{matches:r,pruned:!1,printed:!1}:t.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let i=Pt(t.expr,e,n,r,s);return{matches:!i.matches,pruned:i.pruned,printed:!1}}case"and":{let i=Pt(t.left,e,n,r,s);if(!i.matches)return{matches:!1,pruned:i.pruned,printed:!1};let o=Pt(t.right,e,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:i.printed||o.printed}}case"or":{let i=Pt(t.left,e,n,r,s);if(i.matches)return i;let o=Pt(t.right,e,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:o.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function $n(t){if(!t)return!1;switch(t.type){case"prune":return!0;case"not":return $n(t.expr);case"and":case"or":return $n(t.left)||$n(t.right);default:return!1}}function yt(t){switch(t.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return yt(t.expr);case"and":case"or":return yt(t.left)&&yt(t.right)}}function ql(t,e){if(!t||!e.isDirectory)return{shouldPrune:!1};if(!yt(t))return $s(t,e);let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Je(t,n).pruned}}function $s(t,e){switch(t.type){case"or":{if(yt(t.left)){let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(Je(t.left,n).pruned)return{shouldPrune:!0}}return $s(t.right,e)}case"and":{if(yt(t.left)&&yt(t.right)){let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Je(t,n).pruned}}if(yt(t.left)){let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return Je(t.left,n).matches?$s(t.right,e):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Vl=C(()=>{"use strict";us()});function Zl(t,e){let n=[],r=[],s=e;for(;s<t.length;){let o=t[s];if(o==="("||o==="\\("){n.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){n.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<t.length)n.push({type:"expr",expr:{type:"name",pattern:t[++s]}});else if(o==="-iname"&&s+1<t.length)n.push({type:"expr",expr:{type:"name",pattern:t[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<t.length)n.push({type:"expr",expr:{type:"path",pattern:t[++s]}});else if(o==="-ipath"&&s+1<t.length)n.push({type:"expr",expr:{type:"path",pattern:t[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<t.length)n.push({type:"expr",expr:{type:"regex",pattern:t[++s]}});else if(o==="-iregex"&&s+1<t.length)n.push({type:"expr",expr:{type:"regex",pattern:t[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<t.length){let a=t[++s];if(a==="f"||a==="d")n.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
437
+ `:"",stderr:""}}}});var ql={};_(ql,{teeCommand:()=>M0});var D0,L0,M0,Vl=C(()=>{"use strict";Ae();j();D0={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append append to the given FILEs, do not overwrite"," --help display this help and exit"]},L0={append:{short:"a",long:"append",type:"boolean"}},M0={name:"tee",async execute(t,e){if(N(t))return k(D0);let n=Q("tee",t,L0);if(!n.ok)return n.error;let{append:r}=n.result.flags,s=n.result.positional,i=e.stdin,o="",a=0;for(let l of s)try{let c=e.fs.resolvePath(e.cwd,l);r?await e.fs.appendFile(c,i):await e.fs.writeFile(c,i)}catch{o+=`tee: ${l}: No such file or directory
438
+ `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function Je(t,e){switch(t.type){case"name":{let n=t.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],i=e.name;if(t.ignoreCase){if(!i.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Le(e.name,n,t.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=t.pattern,r=e.relativePath,s=n.split("/");for(let o=0;o<s.length-1;o++){let a=s[o];if(a&&a!=="."&&a!==".."&&!a.includes("*")&&!a.includes("?")&&!a.includes("[")){let l=`/${a}/`;if(t.ignoreCase){if(!r.toLowerCase().includes(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(l))return{matches:!1,pruned:!1,printed:!1}}}let i=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let o=i[1];if(t.ignoreCase){if(!r.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(o))return{matches:!1,pruned:!1,printed:!1}}return{matches:Le(r,n,t.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=t.ignoreCase?"i":"";return{matches:new RegExp(t.pattern,n).test(e.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return t.fileType==="f"?{matches:e.isFile,pruned:!1,printed:!1}:t.fileType==="d"?{matches:e.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:e.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-e.mtime)/(1e3*60*60*24),s;return t.comparison==="more"?s=r>t.days:t.comparison==="less"?s=r<t.days:s=Math.floor(r)===t.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=e.newerRefTimes.get(t.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:e.mtime>n,pruned:!1,printed:!1}}case"size":{let n=t.value;switch(t.unit){case"c":n=t.value;break;case"k":n=t.value*1024;break;case"M":n=t.value*1024*1024;break;case"G":n=t.value*1024*1024*1024;break;case"b":n=t.value*512;break}let r;return t.comparison==="more"?r=e.size>n:t.comparison==="less"?r=e.size<n:t.unit==="b"?r=Math.ceil(e.size/512)===t.value:r=e.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=e.mode&511,r=t.mode&511,s;return t.matchType==="exact"?s=n===r:t.matchType==="all"?s=(n&r)===r:s=(n&r)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=Je(t.expr,e);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=Je(t.left,e);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=Je(t.right,e);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=Je(t.left,e);if(n.matches)return n;let r=Je(t.right,e);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function vn(t){if(!t)return!1;switch(t.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return vn(t.expr);case"and":case"or":return vn(t.left)||vn(t.right)}}function $n(t){if(!t)return!1;switch(t.type){case"empty":return!0;case"not":return $n(t.expr);case"and":case"or":return $n(t.left)||$n(t.right);default:return!1}}function Zl(t){let e={terminalDirName:null,requiredExtension:null};if(!t)return e;let n=_0(t);if(B0(t)&&n.length===1){let i=n[0].split("/").filter(o=>o.length>0);if(i.length>=2)for(let o=i.length-2;o>=0;o--){let a=i[o];if(!a.includes("*")&&!a.includes("?")&&!a.includes("[")&&a!=="."&&a!==".."){let l=i[o+1];if(l&&(l.includes("*")||l.includes("?"))){e.terminalDirName=a;let c=l.match(/^\*(\.[a-zA-Z0-9]+)$/);c&&(e.requiredExtension=c[1])}break}}}return e}function _0(t){let e=[],n=r=>{r.type==="path"?e.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(t),e}function B0(t){let e=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?e(n.expr):n.type==="and"||n.type==="or"?e(n.left)||e(n.right):!1;return e(t)}function Kl(t){let e=[],n=r=>{r&&(r.type==="newer"?e.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(t),e}function Rn(t){if(!t)return!0;switch(t.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return Rn(t.expr);case"and":case"or":return Rn(t.left)&&Rn(t.right)}}function Pt(t,e,n,r,s){switch(t.type){case"name":{let i=t.pattern,o=i.match(/^\*(\.[a-zA-Z0-9]+)$/);if(o){let a=o[1];if(t.ignoreCase){if(!e.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!e.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Le(e,i,t.ignoreCase),pruned:!1,printed:!1}}case"path":{let i=t.pattern,o=i.split("/");for(let l=0;l<o.length-1;l++){let c=o[l];if(c&&c!=="."&&c!==".."&&!c.includes("*")&&!c.includes("?")&&!c.includes("[")){let u=`/${c}/`;if(t.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let a=i.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let l=a[1];if(t.ignoreCase){if(!n.toLowerCase().endsWith(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(l))return{matches:!1,pruned:!1,printed:!1}}return{matches:Le(n,i,t.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let i=t.ignoreCase?"i":"";return{matches:new RegExp(t.pattern,i).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return t.fileType==="f"?{matches:r,pruned:!1,printed:!1}:t.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let i=Pt(t.expr,e,n,r,s);return{matches:!i.matches,pruned:i.pruned,printed:!1}}case"and":{let i=Pt(t.left,e,n,r,s);if(!i.matches)return{matches:!1,pruned:i.pruned,printed:!1};let o=Pt(t.right,e,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:i.printed||o.printed}}case"or":{let i=Pt(t.left,e,n,r,s);if(i.matches)return i;let o=Pt(t.right,e,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:o.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function Fn(t){if(!t)return!1;switch(t.type){case"prune":return!0;case"not":return Fn(t.expr);case"and":case"or":return Fn(t.left)||Fn(t.right);default:return!1}}function xt(t){switch(t.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return xt(t.expr);case"and":case"or":return xt(t.left)&&xt(t.right)}}function Ql(t,e){if(!t||!e.isDirectory)return{shouldPrune:!1};if(!xt(t))return Fs(t,e);let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Je(t,n).pruned}}function Fs(t,e){switch(t.type){case"or":{if(xt(t.left)){let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(Je(t.left,n).pruned)return{shouldPrune:!0}}return Fs(t.right,e)}case"and":{if(xt(t.left)&&xt(t.right)){let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Je(t,n).pruned}}if(xt(t.left)){let n={name:e.name,relativePath:e.relativePath,isFile:e.isFile,isDirectory:e.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return Je(t.left,n).matches?Fs(t.right,e):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Xl=C(()=>{"use strict";fs()});function Jl(t,e){let n=[],r=[],s=e;for(;s<t.length;){let o=t[s];if(o==="("||o==="\\("){n.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){n.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<t.length)n.push({type:"expr",expr:{type:"name",pattern:t[++s]}});else if(o==="-iname"&&s+1<t.length)n.push({type:"expr",expr:{type:"name",pattern:t[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<t.length)n.push({type:"expr",expr:{type:"path",pattern:t[++s]}});else if(o==="-ipath"&&s+1<t.length)n.push({type:"expr",expr:{type:"path",pattern:t[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<t.length)n.push({type:"expr",expr:{type:"regex",pattern:t[++s]}});else if(o==="-iregex"&&s+1<t.length)n.push({type:"expr",expr:{type:"regex",pattern:t[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<t.length){let a=t[++s];if(a==="f"||a==="d")n.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
435
439
  `,actions:[]}}else if(o==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(o==="-mtime"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=parseInt(c,10);Number.isNaN(u)||n.push({type:"expr",expr:{type:"mtime",days:u,comparison:l}})}else if(o==="-newer"&&s+1<t.length){let a=t[++s];n.push({type:"expr",expr:{type:"newer",refPath:a}})}else if(o==="-size"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=c.match(/^(\d+)([ckMGb])?$/);if(u){let f=parseInt(u[1],10),d=u[2]||"b";n.push({type:"expr",expr:{type:"size",value:f,unit:d,comparison:l}})}}else if(o==="-perm"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("-")?(l="all",c=a.slice(1)):a.startsWith("/")&&(l="any",c=a.slice(1));let u=parseInt(c,8);Number.isNaN(u)||n.push({type:"expr",expr:{type:"perm",mode:u,matchType:l}})}else if(o==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(o==="-not"||o==="!")n.push({type:"not"});else if(o==="-o"||o==="-or")n.push({type:"op",op:"or"});else if(o==="-a"||o==="-and")n.push({type:"op",op:"and"});else if(o==="-maxdepth"||o==="-mindepth")s++;else if(o!=="-depth")if(o==="-exec"){let a=[];for(s++;s<t.length&&t[s]!==";"&&t[s]!=="+";)a.push(t[s]),s++;if(s>=t.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let l=t[s]==="+";r.push({type:"exec",command:a,batchMode:l})}else if(o==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(o==="-print0")r.push({type:"print0"});else if(o==="-printf"&&s+1<t.length){let a=t[++s];r.push({type:"printf",format:a})}else if(o==="-delete")r.push({type:"delete"});else{if(o.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${o}'
436
- `,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let i=F0(n);return i.error?{expr:null,pathIndex:s,error:i.error,actions:r}:{expr:i.expr,pathIndex:s,actions:r}}function F0(t){let e=0;function n(){let a=r();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="or"){e++;let c=r();if(!c)return a;a={type:"or",left:a,right:c}}else break}return a}function r(){let a=s();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="and"){e++;let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else if(l.type==="expr"||l.type==="not"||l.type==="lparen"){let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else break}return a}function s(){if(e<t.length&&t[e].type==="not"){e++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(e>=t.length)return null;let a=t[e];if(a.type==="lparen"){e++;let l=n();return e<t.length&&t[e].type==="rparen"&&e++,l}return a.type==="expr"?(e++,a.expr):(a.type==="rparen",null)}return{expr:n()}}var Kl=C(()=>{"use strict"});var Xl={};L(Xl,{findCommand:()=>M0});function T0(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function O0(t,e,n){t({category:"find",name:"summary",durationMs:n,details:{readdirCalls:e.readdirCalls,readdirTimeMs:e.readdirTime,statCalls:e.statCalls,statTimeMs:e.statTime,evalCalls:e.evalCalls,evalTimeMs:e.evalTime,nodeCount:e.nodeCount,batchCount:e.batchCount,batchTimeMs:e.batchTime,earlyPrunes:e.earlyPrunes,otherTimeMs:n-e.readdirTime-e.statTime-e.evalTime-e.batchTime}})}function _0(t,e){let n=Zn(t),r="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){r+="%",s++;continue}let[i,o,a]=fo(n,s);if(s+=a,s>=n.length){r+="%";break}let l=n[s],c;switch(l){case"f":c=e.name,s++;break;case"h":{let u=e.path.lastIndexOf("/");c=u>0?e.path.slice(0,u):".",s++;break}case"p":c=e.path,s++;break;case"P":{let u=e.startingPoint;e.path===u?c="":e.path.startsWith(`${u}/`)?c=e.path.slice(u.length+1):u==="."&&e.path.startsWith("./")?c=e.path.slice(2):c=e.path,s++;break}case"s":c=String(e.size),s++;break;case"d":c=String(e.depth),s++;break;case"m":c=(e.mode&511).toString(8),s++;break;case"M":c=B0(e.mode,e.isDirectory),s++;break;case"t":{let u=new Date(e.mtime);c=W0(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(e.mtime);c=U0(f,u),s+=2}else c="%T",s++;break}default:r+=`%${i!==0||o!==-1?`${i}.${o}`:""}${l}`,s++;continue}r+=Vn(c,i,o)}else r+=n[s],s++;return r}function B0(t,e){let n=t&511,r=e?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function W0(t){let e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=e[t.getDay()],s=n[t.getMonth()],i=String(t.getDate()).padStart(2," "),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=String(t.getSeconds()).padStart(2,"0"),c=t.getFullYear();return`${r} ${s} ${i} ${o}:${a}:${l} ${c}`}function U0(t,e){switch(e){case"@":return String(t.getTime()/1e3);case"Y":return String(t.getFullYear());case"m":return String(t.getMonth()+1).padStart(2,"0");case"d":return String(t.getDate()).padStart(2,"0");case"H":return String(t.getHours()).padStart(2,"0");case"M":return String(t.getMinutes()).padStart(2,"0");case"S":return String(t.getSeconds()).padStart(2,"0");case"T":return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`;case"F":return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;default:return`%T${e}`}}var Ql,D0,L0,M0,Jl=C(()=>{"use strict";j();as();Vl();Kl();Ql=500;D0={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},L0=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),M0={name:"find",async execute(t,e){if(I(t))return N(D0);let n=[],r=null,s=null,i=!1,o=!1;for(let v=0;v<t.length;v++){let k=t[v];if(k==="-maxdepth"&&v+1<t.length)o=!0,r=parseInt(t[++v],10);else if(k==="-mindepth"&&v+1<t.length)o=!0,s=parseInt(t[++v],10);else if(k==="-depth")o=!0,i=!0;else if(k==="-exec")for(o=!0,v++;v<t.length&&t[v]!==";"&&t[v]!=="+";)v++;else!k.startsWith("-")&&k!==";"&&k!=="+"&&k!=="("&&k!==")"&&k!=="\\("&&k!=="\\)"&&k!=="!"?o||n.push(k):L0.has(k)?(o=!0,v++):(k.startsWith("-")||k==="("||k==="\\("||k==="!")&&(o=!0)}n.length===0&&n.push(".");let{expr:a,error:l,actions:c}=Zl(t,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some(v=>v.type==="print"),f=c.length===0,d=[],p=c.some(v=>v.type==="printf"),h=[],m="",g=0,w=Gl(a),b=new Map;for(let v of w){let k=e.fs.resolvePath(e.cwd,v);try{let $=await e.fs.stat(k);b.set(v,$.mtime?.getTime()??Date.now())}catch{}}let E=c.some(v=>{if(v.type!=="printf")return!1;let k=v.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(k)}),S=Nn(a)||E,R=In(a),P=Hl(a),z=$n(a),W=vn(a),X=typeof e.fs.readdirWithFileTypes=="function";for(let v of n){let we=function(O){let J=s===null||O.depth>=s,ne=!1;if(J&&a!==null){let he=Date.now(),le;if(W)le=Pt(a,O.name,O.relativePath,O.isFile,O.isDirectory);else{let ce={name:O.name,relativePath:O.relativePath,isFile:O.isFile,isDirectory:O.isDirectory,isEmpty:O.isEmpty,mtime:O.stat?.mtime?.getTime()??Date.now(),size:O.stat?.size??0,mode:O.stat?.mode??420,newerRefTimes:b};le=Je(a,ce)}J=le.matches,ne=u?le.printed:J,$.evalCalls++,$.evalTime+=Date.now()-he}else J&&(ne=!0);return ne?{print:!0,printfData:p?{path:O.relativePath,name:O.name,size:O.stat?.size??0,mtime:O.stat?.mtime?.getTime()??Date.now(),mode:O.stat?.mode??420,isDirectory:O.isDirectory,depth:O.depth,startingPoint:v}:null}:{print:!1,printfData:null}};var T=we;v.length>1&&v.endsWith("/")&&(v=v.slice(0,-1));let k=e.fs.resolvePath(e.cwd,v);try{await e.fs.stat(k)}catch{m+=`find: ${v}: No such file or directory
437
- `,g=1;continue}let $=T0(),M=Date.now();async function ee(O){let{path:ie,depth:J,typeInfo:ne}=O;if($.nodeCount++,r!==null&&J>r)return null;let _,he,le;if(ne&&!S)_=ne.isFile,he=ne.isDirectory;else{try{let At=Date.now();le=await e.fs.stat(ie),$.statCalls++,$.statTime+=Date.now()-At}catch{return null}if(!le)return null;_=le.isFile,he=le.isDirectory}let ce;ie===k?ce=v.split("/").pop()||v:ce=ie.split("/").pop()||"";let me=ie===k?v:v==="."?`./${ie.slice(k==="/"?k.length:k.length+1)}`:v+ie.slice(k.length),Ie=[],Re=null,Se=null,Ce=!1;he&&z&&!i&&(Ce=ql(a,{name:ce,relativePath:me,isFile:_,isDirectory:he}).shouldPrune,Ce&&$.earlyPrunes++);let ze=r!==null&&J>=r,He=P.terminalDirName!==null&&ce===P.terminalDirName,xn=!ze&&!He&&!Ce;if(he&&((xn||R||He)&&!Ce)){let At=Date.now();if(X&&e.fs.readdirWithFileTypes){if(Re=await e.fs.readdirWithFileTypes(ie),Se=Re.map(_e=>_e.name),$.readdirCalls++,$.readdirTime+=Date.now()-At,xn)Ie=Re.map((_e,Ke)=>({path:ie==="/"?`/${_e.name}`:`${ie}/${_e.name}`,depth:J+1,typeInfo:{isFile:_e.isFile,isDirectory:_e.isDirectory},resultIndex:Ke}));else if(He){let _e=P.requiredExtension;Ie=Re.filter(Ke=>Ke.isFile&&(!_e||Ke.name.endsWith(_e))).map((Ke,Hd)=>({path:ie==="/"?`/${Ke.name}`:`${ie}/${Ke.name}`,depth:J+1,typeInfo:{isFile:Ke.isFile,isDirectory:Ke.isDirectory},resultIndex:Hd}))}}else Se=await e.fs.readdir(ie),$.readdirCalls++,$.readdirTime+=Date.now()-At,xn&&(Ie=Se.map((_e,Ke)=>({path:ie==="/"?`/${_e}`:`${ie}/${_e}`,depth:J+1,resultIndex:Ke})))}let Gn=_?(le?.size??0)===0:Se!==null&&Se.length===0,zt=Ce;if(!i&&a!==null&&!Ce&&z){let At=Date.now(),_e={name:ce,relativePath:me,isFile:_,isDirectory:he,isEmpty:Gn,mtime:le?.mtime?.getTime()??Date.now(),size:le?.size??0,mode:le?.mode??420,newerRefTimes:b};zt=Je(a,_e).pruned,$.evalCalls++,$.evalTime+=Date.now()-At}return{relativePath:me,name:ce,isFile:_,isDirectory:he,isEmpty:Gn,stat:le,depth:J,children:zt?[]:Ie,pruned:zt}}async function oe(){let O={paths:[],printfData:[]};if(i){let le=function(ce){let me={paths:[],printfData:[]},Ie=ne[ce];if(!Ie)return me;for(let Ce of Ie.childIndices){let ze=le(Ce);me.paths.push(...ze.paths),me.printfData.push(...ze.printfData)}let{print:Re,printfData:Se}=we(Ie.node);return Re&&(me.paths.push(Ie.node.relativePath),Se&&me.printfData.push(Se)),me};var ie=le;let ne=[],_=[{item:{path:k,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],he=new Map;for(;_.length>0;){let ce=Date.now(),me=_.splice(0,Ql),Ie=await Promise.all(me.map(Re=>ee(Re.item)));$.batchCount++,$.batchTime+=Date.now()-ce;for(let Re=0;Re<me.length;Re++){let Se=Ie[Re],Ce=me[Re];if(!Se)continue;let ze=ne.length;if(Ce.parentIndex>=0){let He=he.get(Ce.parentIndex)||[];He.push(ze),he.set(Ce.parentIndex,He)}ne.push({node:Se,parentIndex:Ce.parentIndex,childIndices:[]});for(let He=0;He<Se.children.length;He++)_.push({item:Se.children[He],parentIndex:ze,childOrderInParent:He})}}for(let[ce,me]of he)ce>=0&&ce<ne.length&&(ne[ce].childIndices=me);if(ne.length>0){let ce=le(0);O.paths.push(...ce.paths),O.printfData.push(...ce.printfData)}}else{let ce=function(me){let Ie=ne.get(me);Ie&&(O.paths.push(Ie.path),Ie.printfData&&O.printfData.push(Ie.printfData));let Re=le.get(me);if(Re)for(let Se of Re)ce(Se)};var J=ce;let ne=new Map,_=0,he=[{item:{path:k,depth:0,resultIndex:0},orderIndex:_++}],le=new Map;for(;he.length>0;){let me=Date.now(),Ie=he.splice(0,Ql),Re=await Promise.all(Ie.map(async({item:Se,orderIndex:Ce})=>{let ze=await ee(Se);return ze?{node:ze,orderIndex:Ce}:null}));$.batchCount++,$.batchTime+=Date.now()-me;for(let Se of Re){if(!Se)continue;let{node:Ce,orderIndex:ze}=Se,{print:He,printfData:xn}=we(Ce);if(He&&ne.set(ze,{path:Ce.relativePath,printfData:xn}),Ce.children.length>0){let is=[];for(let Gn of Ce.children){let zt=_++;is.push(zt),he.push({item:Gn,orderIndex:zt})}le.set(ze,is)}}}ce(0)}return O}let Z=await oe();if(d.push(...Z.paths),h.push(...Z.printfData),e.trace){let O=Date.now()-M;O0(e.trace,$,O),e.trace({category:"find",name:"searchPath",durationMs:O,details:{path:v,resultsFound:Z.paths.length}})}}let F="";if(c.length>0)for(let v of c)switch(v.type){case"print":F+=d.length>0?`${d.join(`
440
+ `,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let i=W0(n);return i.error?{expr:null,pathIndex:s,error:i.error,actions:r}:{expr:i.expr,pathIndex:s,actions:r}}function W0(t){let e=0;function n(){let a=r();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="or"){e++;let c=r();if(!c)return a;a={type:"or",left:a,right:c}}else break}return a}function r(){let a=s();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="and"){e++;let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else if(l.type==="expr"||l.type==="not"||l.type==="lparen"){let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else break}return a}function s(){if(e<t.length&&t[e].type==="not"){e++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(e>=t.length)return null;let a=t[e];if(a.type==="lparen"){e++;let l=n();return e<t.length&&t[e].type==="rparen"&&e++,l}return a.type==="expr"?(e++,a.expr):(a.type==="rparen",null)}return{expr:n()}}var Yl=C(()=>{"use strict"});var tc={};_(tc,{findCommand:()=>G0});function U0(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function j0(t,e,n){t({category:"find",name:"summary",durationMs:n,details:{readdirCalls:e.readdirCalls,readdirTimeMs:e.readdirTime,statCalls:e.statCalls,statTimeMs:e.statTime,evalCalls:e.evalCalls,evalTimeMs:e.evalTime,nodeCount:e.nodeCount,batchCount:e.batchCount,batchTimeMs:e.batchTime,earlyPrunes:e.earlyPrunes,otherTimeMs:n-e.readdirTime-e.statTime-e.evalTime-e.batchTime}})}function q0(t,e){let n=Qn(t),r="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){r+="%",s++;continue}let[i,o,a]=ho(n,s);if(s+=a,s>=n.length){r+="%";break}let l=n[s],c;switch(l){case"f":c=e.name,s++;break;case"h":{let u=e.path.lastIndexOf("/");c=u>0?e.path.slice(0,u):".",s++;break}case"p":c=e.path,s++;break;case"P":{let u=e.startingPoint;e.path===u?c="":e.path.startsWith(`${u}/`)?c=e.path.slice(u.length+1):u==="."&&e.path.startsWith("./")?c=e.path.slice(2):c=e.path,s++;break}case"s":c=String(e.size),s++;break;case"d":c=String(e.depth),s++;break;case"m":c=(e.mode&511).toString(8),s++;break;case"M":c=V0(e.mode,e.isDirectory),s++;break;case"t":{let u=new Date(e.mtime);c=Z0(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(e.mtime);c=K0(f,u),s+=2}else c="%T",s++;break}default:r+=`%${i!==0||o!==-1?`${i}.${o}`:""}${l}`,s++;continue}r+=Kn(c,i,o)}else r+=n[s],s++;return r}function V0(t,e){let n=t&511,r=e?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function Z0(t){let e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=e[t.getDay()],s=n[t.getMonth()],i=String(t.getDate()).padStart(2," "),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=String(t.getSeconds()).padStart(2,"0"),c=t.getFullYear();return`${r} ${s} ${i} ${o}:${a}:${l} ${c}`}function K0(t,e){switch(e){case"@":return String(t.getTime()/1e3);case"Y":return String(t.getFullYear());case"m":return String(t.getMonth()+1).padStart(2,"0");case"d":return String(t.getDate()).padStart(2,"0");case"H":return String(t.getHours()).padStart(2,"0");case"M":return String(t.getMinutes()).padStart(2,"0");case"S":return String(t.getSeconds()).padStart(2,"0");case"T":return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`;case"F":return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;default:return`%T${e}`}}var ec,z0,H0,G0,nc=C(()=>{"use strict";j();ls();Xl();Yl();ec=500;z0={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},H0=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),G0={name:"find",async execute(t,e){if(N(t))return k(z0);let n=[],r=null,s=null,i=!1,o=!1;for(let $=0;$<t.length;$++){let I=t[$];if(I==="-maxdepth"&&$+1<t.length)o=!0,r=parseInt(t[++$],10);else if(I==="-mindepth"&&$+1<t.length)o=!0,s=parseInt(t[++$],10);else if(I==="-depth")o=!0,i=!0;else if(I==="-exec")for(o=!0,$++;$<t.length&&t[$]!==";"&&t[$]!=="+";)$++;else!I.startsWith("-")&&I!==";"&&I!=="+"&&I!=="("&&I!==")"&&I!=="\\("&&I!=="\\)"&&I!=="!"?o||n.push(I):H0.has(I)?(o=!0,$++):(I.startsWith("-")||I==="("||I==="\\("||I==="!")&&(o=!0)}n.length===0&&n.push(".");let{expr:a,error:l,actions:c}=Jl(t,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some($=>$.type==="print"),f=c.length===0,d=[],p=c.some($=>$.type==="printf"),h=[],m="",g=0,b=Kl(a),w=new Map;for(let $ of b){let I=e.fs.resolvePath(e.cwd,$);try{let v=await e.fs.stat(I);w.set($,v.mtime?.getTime()??Date.now())}catch{}}let E=c.some($=>{if($.type!=="printf")return!1;let I=$.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(I)}),S=vn(a)||E,R=$n(a),F=Zl(a),z=Fn(a),W=Rn(a),J=typeof e.fs.readdirWithFileTypes=="function";for(let $ of n){let we=function(M){let q=s===null||M.depth>=s,ne=!1;if(q&&a!==null){let ae=Date.now(),ce;if(W)ce=Pt(a,M.name,M.relativePath,M.isFile,M.isDirectory);else{let ue={name:M.name,relativePath:M.relativePath,isFile:M.isFile,isDirectory:M.isDirectory,isEmpty:M.isEmpty,mtime:M.stat?.mtime?.getTime()??Date.now(),size:M.stat?.size??0,mode:M.stat?.mode??420,newerRefTimes:w};ce=Je(a,ue)}q=ce.matches,ne=u?ce.printed:q,v.evalCalls++,v.evalTime+=Date.now()-ae}else q&&(ne=!0);return ne?{print:!0,printfData:p?{path:M.relativePath,name:M.name,size:M.stat?.size??0,mtime:M.stat?.mtime?.getTime()??Date.now(),mode:M.stat?.mode??420,isDirectory:M.isDirectory,depth:M.depth,startingPoint:$}:null}:{print:!1,printfData:null}};var T=we;$.length>1&&$.endsWith("/")&&($=$.slice(0,-1));let I=e.fs.resolvePath(e.cwd,$);try{await e.fs.stat(I)}catch{m+=`find: ${$}: No such file or directory
441
+ `,g=1;continue}let v=U0(),D=Date.now();async function ee(M){let{path:oe,depth:q,typeInfo:ne}=M;if(v.nodeCount++,r!==null&&q>r)return null;let O,ae,ce;if(ne&&!S)O=ne.isFile,ae=ne.isDirectory;else{try{let kt=Date.now();ce=await e.fs.stat(oe),v.statCalls++,v.statTime+=Date.now()-kt}catch{return null}if(!ce)return null;O=ce.isFile,ae=ce.isDirectory}let ue;oe===I?ue=$.split("/").pop()||$:ue=oe.split("/").pop()||"";let me=oe===I?$:$==="."?`./${oe.slice(I==="/"?I.length:I.length+1)}`:$+oe.slice(I.length),Ie=[],Re=null,Se=null,Ce=!1;ae&&z&&!i&&(Ce=Ql(a,{name:ue,relativePath:me,isFile:O,isDirectory:ae}).shouldPrune,Ce&&v.earlyPrunes++);let ze=r!==null&&q>=r,He=F.terminalDirName!==null&&ue===F.terminalDirName,wn=!ze&&!He&&!Ce;if(ae&&((wn||R||He)&&!Ce)){let kt=Date.now();if(J&&e.fs.readdirWithFileTypes){if(Re=await e.fs.readdirWithFileTypes(oe),Se=Re.map(_e=>_e.name),v.readdirCalls++,v.readdirTime+=Date.now()-kt,wn)Ie=Re.map((_e,Ke)=>({path:oe==="/"?`/${_e.name}`:`${oe}/${_e.name}`,depth:q+1,typeInfo:{isFile:_e.isFile,isDirectory:_e.isDirectory},resultIndex:Ke}));else if(He){let _e=F.requiredExtension;Ie=Re.filter(Ke=>Ke.isFile&&(!_e||Ke.name.endsWith(_e))).map((Ke,Zd)=>({path:oe==="/"?`/${Ke.name}`:`${oe}/${Ke.name}`,depth:q+1,typeInfo:{isFile:Ke.isFile,isDirectory:Ke.isDirectory},resultIndex:Zd}))}}else Se=await e.fs.readdir(oe),v.readdirCalls++,v.readdirTime+=Date.now()-kt,wn&&(Ie=Se.map((_e,Ke)=>({path:oe==="/"?`/${_e}`:`${oe}/${_e}`,depth:q+1,resultIndex:Ke})))}let Vn=O?(ce?.size??0)===0:Se!==null&&Se.length===0,Ht=Ce;if(!i&&a!==null&&!Ce&&z){let kt=Date.now(),_e={name:ue,relativePath:me,isFile:O,isDirectory:ae,isEmpty:Vn,mtime:ce?.mtime?.getTime()??Date.now(),size:ce?.size??0,mode:ce?.mode??420,newerRefTimes:w};Ht=Je(a,_e).pruned,v.evalCalls++,v.evalTime+=Date.now()-kt}return{relativePath:me,name:ue,isFile:O,isDirectory:ae,isEmpty:Vn,stat:ce,depth:q,children:Ht?[]:Ie,pruned:Ht}}async function ie(){let M={paths:[],printfData:[]};if(i){let ce=function(ue){let me={paths:[],printfData:[]},Ie=ne[ue];if(!Ie)return me;for(let Ce of Ie.childIndices){let ze=ce(Ce);me.paths.push(...ze.paths),me.printfData.push(...ze.printfData)}let{print:Re,printfData:Se}=we(Ie.node);return Re&&(me.paths.push(Ie.node.relativePath),Se&&me.printfData.push(Se)),me};var oe=ce;let ne=[],O=[{item:{path:I,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],ae=new Map;for(;O.length>0;){let ue=Date.now(),me=O.splice(0,ec),Ie=await Promise.all(me.map(Re=>ee(Re.item)));v.batchCount++,v.batchTime+=Date.now()-ue;for(let Re=0;Re<me.length;Re++){let Se=Ie[Re],Ce=me[Re];if(!Se)continue;let ze=ne.length;if(Ce.parentIndex>=0){let He=ae.get(Ce.parentIndex)||[];He.push(ze),ae.set(Ce.parentIndex,He)}ne.push({node:Se,parentIndex:Ce.parentIndex,childIndices:[]});for(let He=0;He<Se.children.length;He++)O.push({item:Se.children[He],parentIndex:ze,childOrderInParent:He})}}for(let[ue,me]of ae)ue>=0&&ue<ne.length&&(ne[ue].childIndices=me);if(ne.length>0){let ue=ce(0);M.paths.push(...ue.paths),M.printfData.push(...ue.printfData)}}else{let ue=function(me){let Ie=ne.get(me);Ie&&(M.paths.push(Ie.path),Ie.printfData&&M.printfData.push(Ie.printfData));let Re=ce.get(me);if(Re)for(let Se of Re)ue(Se)};var q=ue;let ne=new Map,O=0,ae=[{item:{path:I,depth:0,resultIndex:0},orderIndex:O++}],ce=new Map;for(;ae.length>0;){let me=Date.now(),Ie=ae.splice(0,ec),Re=await Promise.all(Ie.map(async({item:Se,orderIndex:Ce})=>{let ze=await ee(Se);return ze?{node:ze,orderIndex:Ce}:null}));v.batchCount++,v.batchTime+=Date.now()-me;for(let Se of Re){if(!Se)continue;let{node:Ce,orderIndex:ze}=Se,{print:He,printfData:wn}=we(Ce);if(He&&ne.set(ze,{path:Ce.relativePath,printfData:wn}),Ce.children.length>0){let os=[];for(let Vn of Ce.children){let Ht=O++;os.push(Ht),ae.push({item:Vn,orderIndex:Ht})}ce.set(ze,os)}}}ue(0)}return M}let K=await ie();if(d.push(...K.paths),h.push(...K.printfData),e.trace){let M=Date.now()-D;j0(e.trace,v,M),e.trace({category:"find",name:"searchPath",durationMs:M,details:{path:$,resultsFound:K.paths.length}})}}let P="";if(c.length>0)for(let $ of c)switch($.type){case"print":P+=d.length>0?`${d.join(`
438
442
  `)}
439
- `:"";break;case"print0":F+=d.length>0?`${d.join("\0")}\0`:"";break;case"delete":{let k=[...d].sort(($,M)=>M.length-$.length);for(let $ of k){let M=e.fs.resolvePath(e.cwd,$);try{await e.fs.rm(M,{recursive:!1})}catch(ee){let we=ee instanceof Error?ee.message:String(ee);m+=`find: cannot delete '${$}': ${we}
440
- `,g=1}}break}case"printf":for(let k of h)F+=_0(v.format,k);break;case"exec":if(!e.exec)return{stdout:"",stderr:`find: -exec not supported in this context
441
- `,exitCode:1};if(v.batchMode){let k=[];for(let ee of v.command)ee==="{}"?k.push(...d):k.push(ee);let $=k.map(ee=>`"${ee}"`).join(" "),M=await e.exec($,{cwd:e.cwd});F+=M.stdout,m+=M.stderr,M.exitCode!==0&&(g=M.exitCode)}else for(let k of d){let M=v.command.map(we=>we==="{}"?k:we).map(we=>`"${we}"`).join(" "),ee=await e.exec(M,{cwd:e.cwd});F+=ee.stdout,m+=ee.stderr,ee.exitCode!==0&&(g=ee.exitCode)}break}else f&&(F=d.length>0?`${d.join(`
443
+ `:"";break;case"print0":P+=d.length>0?`${d.join("\0")}\0`:"";break;case"delete":{let I=[...d].sort((v,D)=>D.length-v.length);for(let v of I){let D=e.fs.resolvePath(e.cwd,v);try{await e.fs.rm(D,{recursive:!1})}catch(ee){let we=ee instanceof Error?ee.message:String(ee);m+=`find: cannot delete '${v}': ${we}
444
+ `,g=1}}break}case"printf":for(let I of h)P+=q0($.format,I);break;case"exec":if(!e.exec)return{stdout:"",stderr:`find: -exec not supported in this context
445
+ `,exitCode:1};if($.batchMode){let I=[];for(let ee of $.command)ee==="{}"?I.push(...d):I.push(ee);let v=I.map(ee=>`"${ee}"`).join(" "),D=await e.exec(v,{cwd:e.cwd});P+=D.stdout,m+=D.stderr,D.exitCode!==0&&(g=D.exitCode)}else for(let I of d){let D=$.command.map(we=>we==="{}"?I:we).map(we=>`"${we}"`).join(" "),ee=await e.exec(D,{cwd:e.cwd});P+=ee.stdout,m+=ee.stderr,ee.exitCode!==0&&(g=ee.exitCode)}break}else f&&(P=d.length>0?`${d.join(`
442
446
  `)}
443
- `:"");return{stdout:F,stderr:m,exitCode:g}}}});var Yl={};L(Yl,{basenameCommand:()=>z0});var j0,z0,ec=C(()=>{"use strict";j();j0={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX]
444
- basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},z0={name:"basename",async execute(t,e){if(I(t))return N(j0);let n=!1,r="",s=[];for(let o=0;o<t.length;o++){let a=t[o];a==="-a"||a==="--multiple"?n=!0:a==="-s"&&o+1<t.length?(r=t[++o],n=!0):a.startsWith("--suffix=")?(r=a.slice(9),n=!0):a.startsWith("-")||s.push(a)}if(s.length===0)return{stdout:"",stderr:`basename: missing operand
447
+ `:"");return{stdout:P,stderr:m,exitCode:g}}}});var rc={};_(rc,{basenameCommand:()=>X0});var Q0,X0,sc=C(()=>{"use strict";j();Q0={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX]
448
+ basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},X0={name:"basename",async execute(t,e){if(N(t))return k(Q0);let n=!1,r="",s=[];for(let o=0;o<t.length;o++){let a=t[o];a==="-a"||a==="--multiple"?n=!0:a==="-s"&&o+1<t.length?(r=t[++o],n=!0):a.startsWith("--suffix=")?(r=a.slice(9),n=!0):a.startsWith("-")||s.push(a)}if(s.length===0)return{stdout:"",stderr:`basename: missing operand
445
449
  `,exitCode:1};!n&&s.length>=2&&(r=s.pop()??"");let i=[];for(let o of s){let a=o.replace(/\/+$/,""),l=a.split("/").pop()||a;r&&l.endsWith(r)&&(l=l.slice(0,-r.length)),i.push(l)}return{stdout:`${i.join(`
446
450
  `)}
447
- `,stderr:"",exitCode:0}}}});var tc={};L(tc,{dirnameCommand:()=>G0});var H0,G0,nc=C(()=>{"use strict";j();H0={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},G0={name:"dirname",async execute(t,e){if(I(t))return N(H0);let n=t.filter(s=>!s.startsWith("-"));if(n.length===0)return{stdout:"",stderr:`dirname: missing operand
451
+ `,stderr:"",exitCode:0}}}});var ic={};_(ic,{dirnameCommand:()=>Y0});var J0,Y0,oc=C(()=>{"use strict";j();J0={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},Y0={name:"dirname",async execute(t,e){if(N(t))return k(J0);let n=t.filter(s=>!s.startsWith("-"));if(n.length===0)return{stdout:"",stderr:`dirname: missing operand
448
452
  `,exitCode:1};let r=[];for(let s of n){let i=s.replace(/\/+$/,""),o=i.lastIndexOf("/");o===-1?r.push("."):o===0?r.push("/"):r.push(i.slice(0,o))}return{stdout:`${r.join(`
449
453
  `)}
450
- `,stderr:"",exitCode:0}}}});var sc={};L(sc,{treeCommand:()=>Z0});async function K0(t,e,n,r,s){let i={output:"",stderr:"",dirCount:0,fileCount:0},o=t.fs.resolvePath(t.cwd,e);try{if(!(await t.fs.stat(o)).isDirectory)return i.output=`${e}
454
+ `,stderr:"",exitCode:0}}}});var lc={};_(lc,{treeCommand:()=>ng});async function rg(t,e,n,r,s){let i={output:"",stderr:"",dirCount:0,fileCount:0},o=t.fs.resolvePath(t.cwd,e);try{if(!(await t.fs.stat(o)).isDirectory)return i.output=`${e}
451
455
  `,i.fileCount=1,i}catch{return i.stderr=`tree: ${e}: No such file or directory
452
456
  `,i}if(i.output=`${e}
453
457
  `,n.maxDepth!==null&&s>=n.maxDepth)return i;try{let a=[];if(t.fs.readdirWithFileTypes)a=(await t.fs.readdirWithFileTypes(o)).map(u=>({name:u.name,isDirectory:u.isDirectory}));else{let c=await t.fs.readdir(o);for(let u=0;u<c.length;u+=100){let f=c.slice(u,u+100),d=await Promise.all(f.map(async p=>{let h=o==="/"?`/${p}`:`${o}/${p}`;try{let m=await t.fs.stat(h);return{name:p,isDirectory:m.isDirectory}}catch{return null}}));a.push(...d.filter(p=>p!==null))}}let l=a.filter(c=>!(!n.showHidden&&c.name.startsWith(".")||n.directoriesOnly&&!c.isDirectory));l.sort((c,u)=>c.name.localeCompare(u.name));for(let c=0;c<l.length;c++){let u=l[c],f=o==="/"?`/${u.name}`:`${o}/${u.name}`,d=c===l.length-1,p=d?"`-- ":"|-- ",h=r+(d?" ":"| ");if(u.isDirectory){i.dirCount++;let m=n.fullPath?f:u.name;if(i.output+=`${r+p+m}
454
- `,n.maxDepth===null||s+1<n.maxDepth){let g=await rc(t,f,n,h,s+1);i.output+=g.output,i.dirCount+=g.dirCount,i.fileCount+=g.fileCount}}else{i.fileCount++;let m=n.fullPath?f:u.name;i.output+=`${r+p+m}
458
+ `,n.maxDepth===null||s+1<n.maxDepth){let g=await ac(t,f,n,h,s+1);i.output+=g.output,i.dirCount+=g.dirCount,i.fileCount+=g.fileCount}}else{i.fileCount++;let m=n.fullPath?f:u.name;i.output+=`${r+p+m}
455
459
  `}}}catch{i.stderr=`tree: ${e}: Permission denied
456
- `}return i}async function rc(t,e,n,r,s){let i={output:"",stderr:"",dirCount:0,fileCount:0};if(n.maxDepth!==null&&s>=n.maxDepth)return i;try{let o=[];if(t.fs.readdirWithFileTypes)o=(await t.fs.readdirWithFileTypes(e)).map(c=>({name:c.name,isDirectory:c.isDirectory}));else{let l=await t.fs.readdir(e);for(let c=0;c<l.length;c+=100){let u=l.slice(c,c+100),f=await Promise.all(u.map(async d=>{let p=e==="/"?`/${d}`:`${e}/${d}`;try{let h=await t.fs.stat(p);return{name:d,isDirectory:h.isDirectory}}catch{return null}}));o.push(...f.filter(d=>d!==null))}}let a=o.filter(l=>!(!n.showHidden&&l.name.startsWith(".")||n.directoriesOnly&&!l.isDirectory));a.sort((l,c)=>l.name.localeCompare(c.name));for(let l=0;l<a.length;l++){let c=a[l],u=e==="/"?`/${c.name}`:`${e}/${c.name}`,f=l===a.length-1,d=f?"`-- ":"|-- ",p=r+(f?" ":"| ");if(c.isDirectory){i.dirCount++;let h=n.fullPath?u:c.name;i.output+=`${r+d+h}
457
- `;let m=await rc(t,u,n,p,s+1);i.output+=m.output,i.dirCount+=m.dirCount,i.fileCount+=m.fileCount}else{i.fileCount++;let h=n.fullPath?u:c.name;i.output+=`${r+d+h}
458
- `}}}catch{}return i}var q0,V0,Z0,ic=C(()=>{"use strict";Ae();Ht();j();q0={name:"tree",summary:"list contents of directories in a tree-like format",usage:"tree [OPTION]... [DIRECTORY]...",options:["-a include hidden files","-d list directories only","-L LEVEL limit depth of directory tree","-f print full path prefix for each file"," --help display this help and exit"]},V0={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},Z0={name:"tree",async execute(t,e){if(I(t))return N(q0);let n=K("tree",t,V0);if(!n.ok)return n.error;let r={showHidden:n.result.flags.showHidden,directoriesOnly:n.result.flags.directoriesOnly,maxDepth:n.result.flags.maxDepth??null,fullPath:n.result.flags.fullPath},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0,l=0;for(let c of s){let u=await K0(e,c,r,"",0);i+=u.output,o+=u.stderr,a+=u.dirCount,l+=u.fileCount}return i+=`
460
+ `}return i}async function ac(t,e,n,r,s){let i={output:"",stderr:"",dirCount:0,fileCount:0};if(n.maxDepth!==null&&s>=n.maxDepth)return i;try{let o=[];if(t.fs.readdirWithFileTypes)o=(await t.fs.readdirWithFileTypes(e)).map(c=>({name:c.name,isDirectory:c.isDirectory}));else{let l=await t.fs.readdir(e);for(let c=0;c<l.length;c+=100){let u=l.slice(c,c+100),f=await Promise.all(u.map(async d=>{let p=e==="/"?`/${d}`:`${e}/${d}`;try{let h=await t.fs.stat(p);return{name:d,isDirectory:h.isDirectory}}catch{return null}}));o.push(...f.filter(d=>d!==null))}}let a=o.filter(l=>!(!n.showHidden&&l.name.startsWith(".")||n.directoriesOnly&&!l.isDirectory));a.sort((l,c)=>l.name.localeCompare(c.name));for(let l=0;l<a.length;l++){let c=a[l],u=e==="/"?`/${c.name}`:`${e}/${c.name}`,f=l===a.length-1,d=f?"`-- ":"|-- ",p=r+(f?" ":"| ");if(c.isDirectory){i.dirCount++;let h=n.fullPath?u:c.name;i.output+=`${r+d+h}
461
+ `;let m=await ac(t,u,n,p,s+1);i.output+=m.output,i.dirCount+=m.dirCount,i.fileCount+=m.fileCount}else{i.fileCount++;let h=n.fullPath?u:c.name;i.output+=`${r+d+h}
462
+ `}}}catch{}return i}var eg,tg,ng,cc=C(()=>{"use strict";Ae();Gt();j();eg={name:"tree",summary:"list contents of directories in a tree-like format",usage:"tree [OPTION]... [DIRECTORY]...",options:["-a include hidden files","-d list directories only","-L LEVEL limit depth of directory tree","-f print full path prefix for each file"," --help display this help and exit"]},tg={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},ng={name:"tree",async execute(t,e){if(N(t))return k(eg);let n=Q("tree",t,tg);if(!n.ok)return n.error;let r={showHidden:n.result.flags.showHidden,directoriesOnly:n.result.flags.directoriesOnly,maxDepth:n.result.flags.maxDepth??null,fullPath:n.result.flags.fullPath},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0,l=0;for(let c of s){let u=await rg(e,c,r,"",0);i+=u.output,o+=u.stderr,a+=u.dirCount,l+=u.fileCount}return i+=`
459
463
  ${a} director${a===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"s"}`),i+=`
460
- `,{stdout:i,stderr:o,exitCode:o?1:0}}}});var ac={};L(ac,{duCommand:()=>J0});async function oc(t,e,n,r,s){let i={output:"",totalSize:0,stderr:""};try{let o=await t.fs.stat(e);if(!o.isDirectory)return i.totalSize=o.size,(r.allFiles||s===0)&&(i.output=pr(o.size,r.humanReadable)+" "+n+`
461
- `),i;let a=0,l=[];if(t.fs.readdirWithFileTypes){let f=await t.fs.readdirWithFileTypes(e),d=f.filter(h=>h.isFile),p=f.filter(h=>h.isDirectory);for(let h=0;h<d.length;h+=100){let m=d.slice(h,h+100),g=await Promise.all(m.map(async w=>{let b=e==="/"?`/${w.name}`:`${e}/${w.name}`;try{let E=await t.fs.stat(b);return{name:w.name,isDirectory:!1,size:E.size}}catch{return{name:w.name,isDirectory:!1,size:0}}}));l.push(...g)}l.push(...p.map(h=>({name:h.name,isDirectory:!0})))}else{let f=await t.fs.readdir(e);for(let d=0;d<f.length;d+=100){let p=f.slice(d,d+100),h=await Promise.all(p.map(async m=>{let g=e==="/"?`/${m}`:`${e}/${m}`;try{let w=await t.fs.stat(g);return{name:m,isDirectory:w.isDirectory,size:w.isDirectory?void 0:w.size}}catch{return{name:m,isDirectory:!1,size:0}}}));l.push(...h)}}l.sort((f,d)=>f.name.localeCompare(d.name));let c=l.filter(f=>!f.isDirectory);for(let f of c){let d=f.size??0;if(a+=d,r.allFiles&&!r.summarize){let p=n==="."?f.name:`${n}/${f.name}`;i.output+=pr(d,r.humanReadable)+" "+p+`
462
- `}}let u=l.filter(f=>f.isDirectory);for(let f=0;f<u.length;f+=100){let d=u.slice(f,f+100),p=await Promise.all(d.map(async h=>{let m=e==="/"?`/${h.name}`:`${e}/${h.name}`,g=n==="."?h.name:`${n}/${h.name}`;return{name:h.name,result:await oc(t,m,g,r,s+1)}}));p.sort((h,m)=>h.name.localeCompare(m.name));for(let{result:h}of p)a+=h.totalSize,r.summarize||(r.maxDepth===null||s+1<=r.maxDepth)&&(i.output+=h.output)}i.totalSize=a,(r.summarize||r.maxDepth===null||s<=r.maxDepth)&&(i.output+=`${pr(a,r.humanReadable)} ${n}
464
+ `,{stdout:i,stderr:o,exitCode:o?1:0}}}});var fc={};_(fc,{duCommand:()=>og});async function uc(t,e,n,r,s){let i={output:"",totalSize:0,stderr:""};try{let o=await t.fs.stat(e);if(!o.isDirectory)return i.totalSize=o.size,(r.allFiles||s===0)&&(i.output=hr(o.size,r.humanReadable)+" "+n+`
465
+ `),i;let a=0,l=[];if(t.fs.readdirWithFileTypes){let f=await t.fs.readdirWithFileTypes(e),d=f.filter(h=>h.isFile),p=f.filter(h=>h.isDirectory);for(let h=0;h<d.length;h+=100){let m=d.slice(h,h+100),g=await Promise.all(m.map(async b=>{let w=e==="/"?`/${b.name}`:`${e}/${b.name}`;try{let E=await t.fs.stat(w);return{name:b.name,isDirectory:!1,size:E.size}}catch{return{name:b.name,isDirectory:!1,size:0}}}));l.push(...g)}l.push(...p.map(h=>({name:h.name,isDirectory:!0})))}else{let f=await t.fs.readdir(e);for(let d=0;d<f.length;d+=100){let p=f.slice(d,d+100),h=await Promise.all(p.map(async m=>{let g=e==="/"?`/${m}`:`${e}/${m}`;try{let b=await t.fs.stat(g);return{name:m,isDirectory:b.isDirectory,size:b.isDirectory?void 0:b.size}}catch{return{name:m,isDirectory:!1,size:0}}}));l.push(...h)}}l.sort((f,d)=>f.name.localeCompare(d.name));let c=l.filter(f=>!f.isDirectory);for(let f of c){let d=f.size??0;if(a+=d,r.allFiles&&!r.summarize){let p=n==="."?f.name:`${n}/${f.name}`;i.output+=hr(d,r.humanReadable)+" "+p+`
466
+ `}}let u=l.filter(f=>f.isDirectory);for(let f=0;f<u.length;f+=100){let d=u.slice(f,f+100),p=await Promise.all(d.map(async h=>{let m=e==="/"?`/${h.name}`:`${e}/${h.name}`,g=n==="."?h.name:`${n}/${h.name}`;return{name:h.name,result:await uc(t,m,g,r,s+1)}}));p.sort((h,m)=>h.name.localeCompare(m.name));for(let{result:h}of p)a+=h.totalSize,r.summarize||(r.maxDepth===null||s+1<=r.maxDepth)&&(i.output+=h.output)}i.totalSize=a,(r.summarize||r.maxDepth===null||s<=r.maxDepth)&&(i.output+=`${hr(a,r.humanReadable)} ${n}
463
467
  `)}catch{i.stderr=`du: cannot read directory '${n}': Permission denied
464
- `}return i}function pr(t,e){return e?t<1024?`${t}`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)}M`:`${(t/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(t/1024)||1)}var Q0,X0,J0,lc=C(()=>{"use strict";Ae();Ht();j();Q0={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},X0={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},J0={name:"du",async execute(t,e){if(I(t))return N(Q0);let n=K("du",t,X0);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{await e.fs.stat(c);let u=await oc(e,c,l,r,0);i+=u.output,a+=u.totalSize,o+=u.stderr}catch{o+=`du: cannot access '${l}': No such file or directory
465
- `}}return r.grandTotal&&s.length>0&&(i+=`${pr(a,r.humanReadable)} total
466
- `),{stdout:i,stderr:o,exitCode:o?1:0}}}});var Rs={};L(Rs,{envCommand:()=>eg,printenvCommand:()=>ng});var Y0,eg,tg,ng,Ps=C(()=>{"use strict";j();Y0={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},eg={name:"env",async execute(t,e){if(I(t))return N(Y0);let n=!1,r=[],s={},i=-1;for(let u=0;u<t.length;u++){let f=t[u];if(f==="-i"||f==="--ignore-environment")n=!0;else if(f==="-u"&&u+1<t.length)r.push(t[++u]);else if(f.startsWith("-u"))r.push(f.slice(2));else if(f.startsWith("--unset="))r.push(f.slice(8));else{if(f.startsWith("--")&&f!=="--")return D("env",f);if(f.startsWith("-")&&f!=="-"){for(let d of f.slice(1))if(d!=="i"&&d!=="u")return D("env",`-${d}`);f.includes("i")&&(n=!0)}else if(f.includes("=")&&i===-1){let d=f.indexOf("="),p=f.slice(0,d),h=f.slice(d+1);s[p]=h}else{i=u;break}}}let o;if(n)o={...s};else{o={...e.env};for(let u of r)delete o[u];Object.assign(o,s)}if(i===-1){let u=[];for(let[f,d]of Object.entries(o))u.push(`${f}=${d}`);return{stdout:u.join(`
468
+ `}return i}function hr(t,e){return e?t<1024?`${t}`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)}M`:`${(t/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(t/1024)||1)}var sg,ig,og,dc=C(()=>{"use strict";Ae();Gt();j();sg={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},ig={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},og={name:"du",async execute(t,e){if(N(t))return k(sg);let n=Q("du",t,ig);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{await e.fs.stat(c);let u=await uc(e,c,l,r,0);i+=u.output,a+=u.totalSize,o+=u.stderr}catch{o+=`du: cannot access '${l}': No such file or directory
469
+ `}}return r.grandTotal&&s.length>0&&(i+=`${hr(a,r.humanReadable)} total
470
+ `),{stdout:i,stderr:o,exitCode:o?1:0}}}});var Ps={};_(Ps,{envCommand:()=>lg,printenvCommand:()=>ug});var ag,lg,cg,ug,Ts=C(()=>{"use strict";j();ag={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},lg={name:"env",async execute(t,e){if(N(t))return k(ag);let n=!1,r=[],s={},i=-1;for(let u=0;u<t.length;u++){let f=t[u];if(f==="-i"||f==="--ignore-environment")n=!0;else if(f==="-u"&&u+1<t.length)r.push(t[++u]);else if(f.startsWith("-u"))r.push(f.slice(2));else if(f.startsWith("--unset="))r.push(f.slice(8));else{if(f.startsWith("--")&&f!=="--")return L("env",f);if(f.startsWith("-")&&f!=="-"){for(let d of f.slice(1))if(d!=="i"&&d!=="u")return L("env",`-${d}`);f.includes("i")&&(n=!0)}else if(f.includes("=")&&i===-1){let d=f.indexOf("="),p=f.slice(0,d),h=f.slice(d+1);s[p]=h}else{i=u;break}}}let o;if(n)o={...s};else{o={...e.env};for(let u of r)delete o[u];Object.assign(o,s)}if(i===-1){let u=[];for(let[f,d]of Object.entries(o))u.push(`${f}=${d}`);return{stdout:u.join(`
467
471
  `)+(u.length>0?`
468
472
  `:""),stderr:"",exitCode:0}}if(!e.exec)return{stdout:"",stderr:`env: command execution not supported in this context
469
- `,exitCode:1};let a=t.slice(i).join(" "),l=Object.entries(s).map(([u,f])=>`${u}="${f}"`).join(" "),c=l?`${l} ${a}`:a;return e.exec(c,{cwd:e.cwd})}},tg={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},ng={name:"printenv",async execute(t,e){if(I(t))return N(tg);let n=t.filter(i=>!i.startsWith("-"));if(n.length===0){let i=[];for(let[o,a]of Object.entries(e.env))i.push(`${o}=${a}`);return{stdout:i.join(`
473
+ `,exitCode:1};let a=t.slice(i).join(" "),l=Object.entries(s).map(([u,f])=>`${u}="${f}"`).join(" "),c=l?`${l} ${a}`:a;return e.exec(c,{cwd:e.cwd})}},cg={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},ug={name:"printenv",async execute(t,e){if(N(t))return k(cg);let n=t.filter(i=>!i.startsWith("-"));if(n.length===0){let i=[];for(let[o,a]of Object.entries(e.env))i.push(`${o}=${a}`);return{stdout:i.join(`
470
474
  `)+(i.length>0?`
471
475
  `:""),stderr:"",exitCode:0}}let r=[],s=0;for(let i of n)i in e.env?r.push(e.env[i]):s=1;return{stdout:r.join(`
472
476
  `)+(r.length>0?`
473
- `:""),stderr:"",exitCode:s}}}});var Fs={};L(Fs,{aliasCommand:()=>sg,unaliasCommand:()=>ig});var rg,Yt,sg,ig,Ts=C(()=>{"use strict";j();rg={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},Yt="BASH_ALIAS_",sg={name:"alias",async execute(t,e){if(I(t))return N(rg);if(t.length===0){let n="";for(let[r,s]of Object.entries(e.env))if(r.startsWith(Yt)){let i=r.slice(Yt.length);n+=`alias ${i}='${s}'
474
- `}return{stdout:n,stderr:"",exitCode:0}}for(let n of t){let r=n.indexOf("=");if(r===-1){let s=Yt+n;return e.env[s]?{stdout:`alias ${n}='${e.env[s]}'
477
+ `:""),stderr:"",exitCode:s}}}});var Os={};_(Os,{aliasCommand:()=>dg,unaliasCommand:()=>pg});var fg,en,dg,pg,Ds=C(()=>{"use strict";j();fg={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},en="BASH_ALIAS_",dg={name:"alias",async execute(t,e){if(N(t))return k(fg);if(t.length===0){let n="";for(let[r,s]of Object.entries(e.env))if(r.startsWith(en)){let i=r.slice(en.length);n+=`alias ${i}='${s}'
478
+ `}return{stdout:n,stderr:"",exitCode:0}}for(let n of t){let r=n.indexOf("=");if(r===-1){let s=en+n;return e.env[s]?{stdout:`alias ${n}='${e.env[s]}'
475
479
  `,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${n}: not found
476
- `,exitCode:1}}else{let s=n.slice(0,r),i=n.slice(r+1);(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1)),e.env[Yt+s]=i}}return{stdout:"",stderr:"",exitCode:0}}},ig={name:"unalias",async execute(t,e){if(I(t))return N({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(t.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
477
- `,exitCode:1};if(t[0]==="-a"){for(let s of Object.keys(e.env))s.startsWith(Yt)&&delete e.env[s];return{stdout:"",stderr:"",exitCode:0}}let n=!1,r="";for(let s of t){let i=Yt+s;e.env[i]?delete e.env[i]:(r+=`unalias: ${s}: not found
478
- `,n=!0)}return{stdout:"",stderr:r,exitCode:n?1:0}}}});var uc={};L(uc,{historyCommand:()=>ag});var og,cc,ag,fc=C(()=>{"use strict";j();og={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},cc="BASH_HISTORY",ag={name:"history",async execute(t,e){if(I(t))return N(og);let n=e.env[cc]||"[]",r;try{r=JSON.parse(n)}catch{r=[]}if(t[0]==="-c")return e.env[cc]="[]",{stdout:"",stderr:"",exitCode:0};let s=r.length;t[0]&&/^\d+$/.test(t[0])&&(s=Math.min(parseInt(t[0],10),r.length));let i=r.length-s,o="";for(let a=i;a<r.length;a++){let l=(a+1).toString().padStart(5," ");o+=`${l} ${r[a]}
479
- `}return{stdout:o,stderr:"",exitCode:0}}}});var dc={};L(dc,{xargsCommand:()=>cg});var lg,cg,pc=C(()=>{"use strict";j();lg={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},cg={name:"xargs",async execute(t,e){if(I(t))return N(lg);let n=null,r=null,s=null,i=null,o=!1,a=!1,l=!1,c=0;for(let b=0;b<t.length;b++){let E=t[b];if(E==="-I"&&b+1<t.length)n=t[++b],c=b+1;else if(E==="-d"&&b+1<t.length)r=t[++b].replace(/\\n/g,`
480
- `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=b+1;else if(E==="-n"&&b+1<t.length)s=parseInt(t[++b],10),c=b+1;else if(E==="-P"&&b+1<t.length)i=parseInt(t[++b],10),c=b+1;else if(E==="-0"||E==="--null")o=!0,c=b+1;else if(E==="-t"||E==="--verbose")a=!0,c=b+1;else if(E==="-r"||E==="--no-run-if-empty")l=!0,c=b+1;else{if(E.startsWith("--"))return D("xargs",E);if(E.startsWith("-")&&E.length>1){for(let S of E.slice(1))if(!"0tr".includes(S))return D("xargs",`-${S}`);E.includes("0")&&(o=!0),E.includes("t")&&(a=!0),E.includes("r")&&(l=!0),c=b+1}else if(!E.startsWith("-")){c=b;break}}}let u=t.slice(c);u.length===0&&u.push("echo");let f;if(o?f=e.stdin.split("\0").filter(b=>b.length>0):r!==null?f=e.stdin.replace(/\n$/,"").split(r).filter(E=>E.length>0):f=e.stdin.split(/\s+/).map(b=>b.trim()).filter(b=>b.length>0),f.length===0)return l?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",p="",h=0,m=b=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(b)?`"${b.replace(/([\\"`$])/g,"\\$1")}"`:b,g=async b=>{let E=b.map(m).join(" ");return a&&(p+=`${E}
480
+ `,exitCode:1}}else{let s=n.slice(0,r),i=n.slice(r+1);(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1)),e.env[en+s]=i}}return{stdout:"",stderr:"",exitCode:0}}},pg={name:"unalias",async execute(t,e){if(N(t))return k({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(t.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
481
+ `,exitCode:1};if(t[0]==="-a"){for(let s of Object.keys(e.env))s.startsWith(en)&&delete e.env[s];return{stdout:"",stderr:"",exitCode:0}}let n=!1,r="";for(let s of t){let i=en+s;e.env[i]?delete e.env[i]:(r+=`unalias: ${s}: not found
482
+ `,n=!0)}return{stdout:"",stderr:r,exitCode:n?1:0}}}});var hc={};_(hc,{historyCommand:()=>mg});var hg,pc,mg,mc=C(()=>{"use strict";j();hg={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},pc="BASH_HISTORY",mg={name:"history",async execute(t,e){if(N(t))return k(hg);let n=e.env[pc]||"[]",r;try{r=JSON.parse(n)}catch{r=[]}if(t[0]==="-c")return e.env[pc]="[]",{stdout:"",stderr:"",exitCode:0};let s=r.length;t[0]&&/^\d+$/.test(t[0])&&(s=Math.min(parseInt(t[0],10),r.length));let i=r.length-s,o="";for(let a=i;a<r.length;a++){let l=(a+1).toString().padStart(5," ");o+=`${l} ${r[a]}
483
+ `}return{stdout:o,stderr:"",exitCode:0}}}});var gc={};_(gc,{xargsCommand:()=>yg});var gg,yg,yc=C(()=>{"use strict";j();gg={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},yg={name:"xargs",async execute(t,e){if(N(t))return k(gg);let n=null,r=null,s=null,i=null,o=!1,a=!1,l=!1,c=0;for(let w=0;w<t.length;w++){let E=t[w];if(E==="-I"&&w+1<t.length)n=t[++w],c=w+1;else if(E==="-d"&&w+1<t.length)r=t[++w].replace(/\\n/g,`
484
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=w+1;else if(E==="-n"&&w+1<t.length)s=parseInt(t[++w],10),c=w+1;else if(E==="-P"&&w+1<t.length)i=parseInt(t[++w],10),c=w+1;else if(E==="-0"||E==="--null")o=!0,c=w+1;else if(E==="-t"||E==="--verbose")a=!0,c=w+1;else if(E==="-r"||E==="--no-run-if-empty")l=!0,c=w+1;else{if(E.startsWith("--"))return L("xargs",E);if(E.startsWith("-")&&E.length>1){for(let S of E.slice(1))if(!"0tr".includes(S))return L("xargs",`-${S}`);E.includes("0")&&(o=!0),E.includes("t")&&(a=!0),E.includes("r")&&(l=!0),c=w+1}else if(!E.startsWith("-")){c=w;break}}}let u=t.slice(c);u.length===0&&u.push("echo");let f;if(o?f=e.stdin.split("\0").filter(w=>w.length>0):r!==null?f=e.stdin.replace(/\n$/,"").split(r).filter(E=>E.length>0):f=e.stdin.split(/\s+/).map(w=>w.trim()).filter(w=>w.length>0),f.length===0)return l?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",p="",h=0,m=w=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(w)?`"${w.replace(/([\\"`$])/g,"\\$1")}"`:w,g=async w=>{let E=w.map(m).join(" ");return a&&(p+=`${E}
481
485
  `),e.exec?e.exec(E,{cwd:e.cwd}):{stdout:`${E}
482
- `,stderr:"",exitCode:0}},w=async b=>{if(i!==null&&i>1)for(let E=0;E<b.length;E+=i){let S=b.slice(E,E+i),R=await Promise.all(S.map(g));for(let P of R)d+=P.stdout,p+=P.stderr,P.exitCode!==0&&(h=P.exitCode)}else for(let E of b){let S=await g(E);d+=S.stdout,p+=S.stderr,S.exitCode!==0&&(h=S.exitCode)}};if(n!==null){let b=f.map(E=>u.map(S=>S.replaceAll(n,E)));await w(b)}else if(s!==null){let b=[];for(let E=0;E<f.length;E+=s){let S=f.slice(E,E+s);b.push([...u,...S])}await w(b)}else{let b=[...u,...f],E=await g(b);d+=E.stdout,p+=E.stderr,h=E.exitCode}return{stdout:d,stderr:p,exitCode:h}}}});var Os={};L(Os,{falseCommand:()=>fg,trueCommand:()=>ug});var ug,fg,Ds=C(()=>{"use strict";ug={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},fg={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}}});var hc={};L(hc,{clearCommand:()=>pg});var dg,pg,mc=C(()=>{"use strict";j();dg={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},pg={name:"clear",async execute(t,e){return I(t)?N(dg):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}}});var Ls={};L(Ls,{bashCommand:()=>hg,shCommand:()=>mg});async function hr(t,e,n,r){if(!r.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
486
+ `,stderr:"",exitCode:0}},b=async w=>{if(i!==null&&i>1)for(let E=0;E<w.length;E+=i){let S=w.slice(E,E+i),R=await Promise.all(S.map(g));for(let F of R)d+=F.stdout,p+=F.stderr,F.exitCode!==0&&(h=F.exitCode)}else for(let E of w){let S=await g(E);d+=S.stdout,p+=S.stderr,S.exitCode!==0&&(h=S.exitCode)}};if(n!==null){let w=f.map(E=>u.map(S=>S.replaceAll(n,E)));await b(w)}else if(s!==null){let w=[];for(let E=0;E<f.length;E+=s){let S=f.slice(E,E+s);w.push([...u,...S])}await b(w)}else{let w=[...u,...f],E=await g(w);d+=E.stdout,p+=E.stderr,h=E.exitCode}return{stdout:d,stderr:p,exitCode:h}}}});var Ls={};_(Ls,{falseCommand:()=>wg,trueCommand:()=>xg});var xg,wg,Ms=C(()=>{"use strict";xg={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},wg={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}}});var xc={};_(xc,{clearCommand:()=>Eg});var bg,Eg,wc=C(()=>{"use strict";j();bg={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},Eg={name:"clear",async execute(t,e){return N(t)?k(bg):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}}});var _s={};_(_s,{bashCommand:()=>Sg,shCommand:()=>Cg});async function mr(t,e,n,r){if(!r.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
483
487
  `,exitCode:1};let s={0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")};n.forEach((u,f)=>{s[String(f+1)]=u});let i=t;if(i.startsWith("#!")){let u=i.indexOf(`
484
488
  `);u!==-1&&(i=i.slice(u+1))}let o=i.split(`
485
- `),a=[];for(let u of o){let f=u.trim();f&&!f.startsWith("#")&&a.push(f)}let l=a.join("; ");return await r.exec(l,{env:s,cwd:r.cwd})}var gc,hg,mg,Ms=C(()=>{"use strict";j();gc={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},hg={name:"bash",async execute(t,e){if(I(t))return N(gc);if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"bash",o=t.slice(3);return hr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],r=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,n),i=await e.fs.readFile(s);return hr(i,n,r,e)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
486
- `,exitCode:127}}}},mg={name:"sh",async execute(t,e){if(I(t))return N({...gc,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"sh",o=t.slice(3);return hr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],r=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,n),i=await e.fs.readFile(s);return hr(i,n,r,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
487
- `,exitCode:127}}}}});function yg(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??gg},env:t?.env}}function _s(t,e,n){let r=new Map(t.vars);return r.set(e,n),{vars:r,limits:t.limits,env:t.env,root:t.root,currentPath:t.currentPath}}function Bs(t,e){let n=t;for(let r of e)if(n&&typeof n=="object")n=n[r];else return;return n}function en(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?en(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?en(t.base):[];if(e===null)return null;let n=t.index.value;return typeof n=="number"||typeof n=="string"?[...e,n]:null}if(t.type==="Pipe"){let e=en(t.left);return e===null?null:Ws(e,t.right)}return t.type==="Call"&&(t.name==="parent"||t.name==="root"),null}function Ws(t,e){if(e.type==="Call"){if(e.name==="parent"){let n=1;if(e.args.length>0&&e.args[0].type==="Literal"){let r=e.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return t.slice(0,Math.max(0,t.length-n));{let r=-n-1;return t.slice(0,Math.min(r,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let n=en(e);if(n!==null)return[...t,...n]}if(e.type==="Index"&&e.index.type==="Literal"){let n=en(e);if(n!==null)return[...t,...n]}if(e.type==="Pipe"){let n=Ws(t,e.left);return n===null?null:Ws(n,e.right)}return e.type==="Identity"?t:null}function A(t,e,n){let r=n&&"vars"in n?n:yg(n);switch(r.root===void 0&&(r={...r,root:t,currentPath:[]}),e.type){case"Identity":return[t];case"Field":return(e.base?A(t,e.base,r):[t]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let o=i[e.name];return[o===void 0?null:o]}return[null]});case"Index":return(e.base?A(t,e.base,r):[t]).flatMap(i=>A(i,e.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){let l=a<0?i.length+a:a;return l>=0&&l<i.length?[i[l]]:[null]}return typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[a]]:[null]}));case"Slice":return(e.base?A(t,e.base,r):[t]).flatMap(i=>{if(!Array.isArray(i)&&typeof i!="string")return[null];let o=i.length,a=e.start?A(t,e.start,r):[0],l=e.end?A(t,e.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=yc(c,o),d=yc(u,o);return Array.isArray(i),i.slice(f,d)}))});case"Iterate":return(e.base?A(t,e.base,r):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=A(t,e.left,r),i=en(e.left);return s.flatMap(o=>{if(i!==null){let a={...r,currentPath:[...r.currentPath??[],...i]};return A(o,e.right,a)}return A(o,e.right,r)})}case"Comma":{let s=A(t,e.left,r),i=A(t,e.right,r);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[A(t,e.elements,r)]:[[]];case"Object":{let s=[{}];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:A(t,i.key,r),a=A(t,i.value,r),l=[];for(let c of s)for(let u of o)for(let f of a)l.push({...c,[String(u)]:f});s.length=0,s.push(...l)}return s}case"Paren":return A(t,e.expr,r);case"BinaryOp":return bg(t,e.op,e.left,e.right,r);case"UnaryOp":return A(t,e.operand,r).map(i=>e.op==="-"?typeof i=="number"?-i:null:e.op==="not"?!Oe(i):null);case"Cond":return A(t,e.cond,r).flatMap(i=>{if(Oe(i))return A(t,e.then,r);for(let o of e.elifs)if(A(t,o.cond,r).some(Oe))return A(t,o.then,r);return e.else?A(t,e.else,r):[null]});case"Try":try{return A(t,e.body,r)}catch{return e.catch?A(t,e.catch,r):[]}case"Call":return wc(t,e.name,e.args,r);case"VarBind":return A(t,e.value,r).flatMap(i=>{let o=_s(r,e.name,i);return A(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[r.env??{}];let s=r.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return A(t,e.expr,r)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:A(t,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[xg(t,e.path,e.op,e.value,r)];case"Reduce":{let s=A(t,e.expr,r),i=A(t,e.init,r)[0];for(let o of s){let a=_s(r,e.varName,o);i=A(i,e.update,a)[0]}return[i]}case"Foreach":{let s=A(t,e.expr,r),i=A(t,e.init,r)[0],o=[];for(let a of s){let l=_s(r,e.varName,a);if(i=A(i,e.update,l)[0],e.extract){let c=A(i,e.extract,l);o.push(...c)}else o.push(i)}return o}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function yc(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function xg(t,e,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return A(l,r,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?{...l,...c}:c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let d={...f};return d[c.name]=u(d[c.name]),d}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l};return f[c.name]=u(f[c.name]),f}return l}case"Index":{let d=A(t,c.index,s)[0];if(c.base)return o(l,c.base,p=>{if(typeof d=="number"&&Array.isArray(p)){let h=[...p],m=d<0?h.length+d:d;return m>=0&&m<h.length&&(h[m]=u(h[m])),h}if(typeof d=="string"&&p&&typeof p=="object"&&!Array.isArray(p)){let h={...p};return h[d]=u(h[d]),h}return p});if(typeof d=="number"&&Array.isArray(l)){let p=[...l],h=d<0?p.length+d:d;return h>=0&&h<p.length&&(p[h]=u(p[h])),p}if(typeof d=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){let p={...l};return p[d]=u(p[d]),p}return l}case"Iterate":{let f=d=>{if(Array.isArray(d))return d.map(p=>u(p));if(d&&typeof d=="object"){let p={};for(let[h,m]of Object.entries(d))p[h]=u(m);return p}return d};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,d=>d);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(n==="|=")return i(l,l);let c=A(t,r,s);return i(l,c[0]??null)})}function wg(t,e,n){function r(s,i){switch(i.type){case"Identity":return null;case"Field":{if(s&&typeof s=="object"&&!Array.isArray(s)){let o={...s};return delete o[i.name],o}return s}case"Index":{let a=A(t,i.index,n)[0];if(typeof a=="number"&&Array.isArray(s)){let l=[...s],c=a<0?l.length+a:a;return c>=0&&c<l.length&&l.splice(c,1),l}if(typeof a=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){let l={...s};return delete l[a],l}return s}case"Iterate":return Array.isArray(s)?[]:s&&typeof s=="object"?{}:s;default:return s}}return r(t,e)}function Oe(t){return t!==null&&t!==!1}function bg(t,e,n,r,s){if(e==="and")return A(t,n,s).flatMap(l=>Oe(l)?A(t,r,s).map(u=>Oe(u)):[!1]);if(e==="or")return A(t,n,s).flatMap(l=>Oe(l)?[!0]:A(t,r,s).map(u=>Oe(u)));if(e==="//"){let l=A(t,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:A(t,r,s)}let i=A(t,n,s),o=A(t,r,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?{...a,...l}:null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}return null;case"*":return typeof a=="number"&&typeof l=="number"?a*l:typeof a=="string"&&typeof l=="number"?a.repeat(l):a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?xc(a,l):null;case"/":return typeof a=="number"&&typeof l=="number"?a/l:typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":return typeof a=="number"&&typeof l=="number"?a%l:null;case"==":return tn(a,l);case"!=":return!tn(a,l);case"<":return mr(a,l)<0;case"<=":return mr(a,l)<=0;case">":return mr(a,l)>0;case">=":return mr(a,l)>=0;default:return null}}))}function tn(t,e){return JSON.stringify(t)===JSON.stringify(e)}function mr(t,e){return typeof t=="number"&&typeof e=="number"?t-e:typeof t=="string"&&typeof e=="string"?t.localeCompare(e):0}function xc(t,e){let n={...t};for(let r of Object.keys(e))r in n&&n[r]&&typeof n[r]=="object"&&!Array.isArray(n[r])&&e[r]&&typeof e[r]=="object"&&!Array.isArray(e[r])?n[r]=xc(n[r],e[r]):n[r]=e[r];return n}function wc(t,e,n,r){switch(e){case"keys":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"values":return Array.isArray(t)?[t]:t&&typeof t=="object"?[Object.values(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:[null];case"utf8bytelength":return typeof t=="string"?[new TextEncoder().encode(t).length]:[null];case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"empty":return[];case"error":{let s=n.length>0?A(t,n[0],r)[0]:t;throw new Error(String(s))}case"not":return[!Oe(t)];case"null":return[null];case"true":return[!0];case"false":return[!1];case"first":if(n.length>0){let s=A(t,n[0],r);return s.length>0?[s[0]]:[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(n.length>0){let s=A(t,n[0],r);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(n.length<1)return[null];let i=A(t,n[0],r)[0];if(n.length>1){let o=A(t,n[1],r);return i>=0&&i<o.length?[o[i]]:[]}return Array.isArray(t)?i>=0&&i<t.length?[t[i]]:[null]:[null]}case"range":{if(n.length===0)return[];let s=A(t,n[0],r);if(n.length===1){let c=s[0];return Array.from({length:c},(u,f)=>f)}let i=A(t,n[1],r),o=s[0],a=i[0],l=[];for(let c=o;c<a;c++)l.push(c);return l}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"sort":return Array.isArray(t)?[[...t].sort(Ft)]:[null];case"sort_by":return!Array.isArray(t)||n.length===0?[null]:[[...t].sort((i,o)=>{let a=A(i,n[0],r)[0],l=A(o,n[0],r)[0];return Ft(a,l)})];case"unique":if(Array.isArray(t)){let s=new Set,i=[];for(let o of t){let a=JSON.stringify(o);s.has(a)||(s.add(a),i.push(o))}return[i]}return[null];case"unique_by":{if(!Array.isArray(t)||n.length===0)return[null];let s=new Set,i=[];for(let o of t){let a=JSON.stringify(A(o,n[0],r)[0]);s.has(a)||(s.add(a),i.push(o))}return[i]}case"group_by":{if(!Array.isArray(t)||n.length===0)return[null];let s=new Map;for(let i of t){let o=JSON.stringify(A(i,n[0],r)[0]);s.has(o)||s.set(o,[]),s.get(o)?.push(i)}return[[...s.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>Ft(s,i)>0?s:i)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((s,i)=>{let o=A(s,n[0],r)[0],a=A(i,n[0],r)[0];return Ft(o,a)>0?s:i})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>Ft(s,i)<0?s:i)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((s,i)=>{let o=A(s,n[0],r)[0],a=A(i,n[0],r)[0];return Ft(o,a)<0?s:i})];case"flatten":{if(!Array.isArray(t))return[null];let s=n.length>0?A(t,n[0],r)[0]:Number.POSITIVE_INFINITY;return[t.flat(s)]}case"add":if(Array.isArray(t)){if(t.length===0)return[null];if(t.every(s=>typeof s=="number"))return[t.reduce((s,i)=>s+i,0)];if(t.every(s=>typeof s=="string"))return[t.join("")];if(t.every(s=>Array.isArray(s)))return[t.flat()];if(t.every(s=>s&&typeof s=="object"&&!Array.isArray(s)))return[Object.assign({},...t)]}return[null];case"any":return n.length>0?Array.isArray(t)?[t.some(s=>Oe(A(s,n[0],r)[0]))]:[!1]:Array.isArray(t)?[t.some(Oe)]:[!1];case"all":return n.length>0?Array.isArray(t)?[t.every(s=>Oe(A(s,n[0],r)[0]))]:[!0]:Array.isArray(t)?[t.every(Oe)]:[!0];case"select":return n.length===0?[t]:A(t,n[0],r).some(Oe)?[t]:[];case"map":return n.length===0||!Array.isArray(t)?[null]:[t.flatMap(i=>A(i,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(t))return[t.flatMap(s=>A(s,n[0],r))];if(t&&typeof t=="object"){let s={};for(let[i,o]of Object.entries(t)){let a=A(o,n[0],r);a.length>0&&(s[i]=a[0])}return[s]}return[null]}case"has":{if(n.length===0)return[!1];let i=A(t,n[0],r)[0];return Array.isArray(t)&&typeof i=="number"?[i>=0&&i<t.length]:t&&typeof t=="object"&&typeof i=="string"?[i in t]:[!1]}case"in":{if(n.length===0)return[!1];let i=A(t,n[0],r)[0];return Array.isArray(i)&&typeof t=="number"?[t>=0&&t<i.length]:i&&typeof i=="object"&&typeof t=="string"?[t in i]:[!1]}case"contains":{if(n.length===0)return[!1];let s=A(t,n[0],r);return[gr(t,s[0])]}case"inside":{if(n.length===0)return[!1];let s=A(t,n[0],r);return[gr(s[0],t)]}case"getpath":{if(n.length===0)return[null];let i=A(t,n[0],r)[0],o=t;for(let a of i){if(o==null)return[null];if(Array.isArray(o)&&typeof a=="number")o=o[a];else if(typeof o=="object"&&typeof a=="string")o=o[a];else return[null]}return[o]}case"setpath":{if(n.length<2)return[null];let i=A(t,n[0],r)[0],a=A(t,n[1],r)[0];return[Us(t,i,a)]}case"delpaths":{if(n.length===0)return[t];let i=A(t,n[0],r)[0],o=t;for(let a of i.sort((l,c)=>c.length-l.length))o=js(o,a);return[o]}case"path":{if(n.length===0)return[[]];let s=[];return Eg(t,n[0],r,[],s),s}case"del":return n.length===0?[t]:[wg(t,n[0],r)];case"paths":{let s=[],i=(o,a)=>{if(o&&typeof o=="object")if(Array.isArray(o))for(let l=0;l<o.length;l++)s.push([...a,l]),i(o[l],[...a,l]);else for(let l of Object.keys(o))s.push([...a,l]),i(o[l],[...a,l])};return i(t,[]),n.length>0?s.filter(o=>{let a=t;for(let c of o)if(Array.isArray(a)&&typeof c=="number")a=a[c];else if(a&&typeof a=="object"&&typeof c=="string")a=a[c];else return!1;return A(a,n[0],r).some(Oe)}):s}case"leaf_paths":{let s=[],i=(o,a)=>{if(o===null||typeof o!="object")s.push(a);else if(Array.isArray(o))for(let l=0;l<o.length;l++)i(o[l],[...a,l]);else for(let l of Object.keys(o))i(o[l],[...a,l])};return i(t,[]),[s]}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([s,i])=>({key:s,value:i}))]:[null];case"from_entries":if(Array.isArray(t)){let s={};for(let i of t)if(i&&typeof i=="object"){let o=i,a=o.key??o.name??o.k,l=o.value??o.v;a!==void 0&&(s[String(a)]=l)}return[s]}return[null];case"with_entries":{if(n.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let i=Object.entries(t).map(([a,l])=>({key:a,value:l})).flatMap(a=>A(a,n[0],r)),o={};for(let a of i)if(a&&typeof a=="object"){let l=a,c=l.key??l.name??l.k,u=l.value??l.v;c!==void 0&&(o[String(c)]=u)}return[o]}return[null]}case"join":{if(!Array.isArray(t))return[null];let s=n.length>0?A(t,n[0],r):[""],i=String(s[0]);return[t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(i)]}case"split":{if(typeof t!="string"||n.length===0)return[null];let s=A(t,n[0],r),i=String(s[0]);return[t.split(i)]}case"test":{if(typeof t!="string"||n.length===0)return[!1];let s=A(t,n[0],r),i=String(s[0]);try{let o=n.length>1?String(A(t,n[1],r)[0]):"";return[new RegExp(i,o).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||n.length===0)return[null];let s=A(t,n[0],r),i=String(s[0]);try{let o=n.length>1?String(A(t,n[1],r)[0]):"",l=new RegExp(i,`${o}d`).exec(t);if(!l)return[];let c=l.indices;return[{offset:l.index,length:l[0].length,string:l[0],captures:l.slice(1).map((u,f)=>({offset:c?.[f+1]?.[0]??null,length:u?.length??0,string:u??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||n.length===0)return[null];let s=A(t,n[0],r),i=String(s[0]);try{let o=n.length>1?String(A(t,n[1],r)[0]):"",a=new RegExp(i,o),l=t.match(a);return!l||!l.groups?[{}]:[l.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||n.length<2)return[null];let s=A(t,n[0],r),i=A(t,n[1],r),o=String(s[0]),a=String(i[0]);try{let l=n.length>2?String(A(t,n[2],r)[0]):"";return[t.replace(new RegExp(o,l),a)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||n.length<2)return[null];let s=A(t,n[0],r),i=A(t,n[1],r),o=String(s[0]),a=String(i[0]);try{let l=n.length>2?String(A(t,n[2],r)[0]):"g",c=l.includes("g")?l:`${l}g`;return[t.replace(new RegExp(o,c),a)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.toLowerCase()]:[null];case"ascii_upcase":return typeof t=="string"?[t.toUpperCase()]:[null];case"ltrimstr":{if(typeof t!="string"||n.length===0)return[t];let s=A(t,n[0],r),i=String(s[0]);return[t.startsWith(i)?t.slice(i.length):t]}case"rtrimstr":{if(typeof t!="string"||n.length===0)return[t];let s=A(t,n[0],r),i=String(s[0]);return[t.endsWith(i)?t.slice(0,-i.length):t]}case"trim":return typeof t=="string"?[t.trim()]:[t];case"startswith":{if(typeof t!="string"||n.length===0)return[!1];let s=A(t,n[0],r);return[t.startsWith(String(s[0]))]}case"endswith":{if(typeof t!="string"||n.length===0)return[!1];let s=A(t,n[0],r);return[t.endsWith(String(s[0]))]}case"index":{if(n.length===0)return[null];let i=A(t,n[0],r)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.indexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){let o=t.findIndex(a=>tn(a,i));return[o>=0?o:null]}return[null]}case"rindex":{if(n.length===0)return[null];let i=A(t,n[0],r)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.lastIndexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){for(let o=t.length-1;o>=0;o--)if(tn(t[o],i))return[o];return[null]}return[null]}case"indices":{if(n.length===0)return[[]];let i=A(t,n[0],r)[0],o=[];if(typeof t=="string"&&typeof i=="string"){let a=t.indexOf(i);for(;a!==-1;)o.push(a),a=t.indexOf(i,a+1)}else if(Array.isArray(t))for(let a=0;a<t.length;a++)tn(t[a],i)&&o.push(a);return[o]}case"floor":return typeof t=="number"?[Math.floor(t)]:[null];case"ceil":return typeof t=="number"?[Math.ceil(t)]:[null];case"round":return typeof t=="number"?[Math.round(t)]:[null];case"sqrt":return typeof t=="number"?[Math.sqrt(t)]:[null];case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:[null];case"log":return typeof t=="number"?[Math.log(t)]:[null];case"log10":return typeof t=="number"?[Math.log10(t)]:[null];case"log2":return typeof t=="number"?[Math.log2(t)]:[null];case"exp":return typeof t=="number"?[Math.exp(t)]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(typeof t!="number"||n.length===0)return[null];let i=A(t,n[0],r)[0];return[t**i]}case"sin":return typeof t=="number"?[Math.sin(t)]:[null];case"cos":return typeof t=="number"?[Math.cos(t)]:[null];case"tan":return typeof t=="number"?[Math.tan(t)]:[null];case"asin":return typeof t=="number"?[Math.asin(t)]:[null];case"acos":return typeof t=="number"?[Math.acos(t)]:[null];case"atan":return typeof t=="number"?[Math.atan(t)]:[null];case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let s=Number(t);return[Number.isNaN(s)?null:s]}return[null];case"infinite":return[!Number.isFinite(t)];case"nan":return[Number.isNaN(t)];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"now":return[Date.now()/1e3];case"env":return[r.env??{}];case"recurse":{if(n.length===0){let a=[],l=c=>{if(a.push(c),Array.isArray(c))for(let u of c)l(u);else if(c&&typeof c=="object")for(let u of Object.keys(c))l(c[u])};return l(t),a}let s=[],i=new Set,o=a=>{let l=JSON.stringify(a);if(i.has(l))return;i.add(l),s.push(a);let c=A(a,n[0],r);for(let u of c)u!=null&&o(u)};return o(t),s}case"recurse_down":return wc(t,"recurse",n,r);case"walk":{if(n.length===0)return[t];let s=new WeakSet,i=o=>{if(o&&typeof o=="object"){if(s.has(o))return o;s.add(o)}let a;if(Array.isArray(o))a=o.map(i);else if(o&&typeof o=="object"){let c={};for(let[u,f]of Object.entries(o))c[u]=i(f);a=c}else a=o;return A(a,n[0],r)[0]};return[i(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),i=[];for(let o=0;o<s;o++)i.push(t.map(a=>Array.isArray(a)?a[o]:null));return[i]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(s=>s.codePointAt(0))]:[null];case"implode":return Array.isArray(t)?[String.fromCodePoint(...t)]:[null];case"tojson":case"tojsonstream":return[JSON.stringify(t)];case"fromjson":{if(typeof t=="string")try{return[JSON.parse(t)]}catch{return[null]}return[null]}case"limit":{if(n.length<2)return[];let i=A(t,n[0],r)[0];return A(t,n[1],r).slice(0,i)}case"until":{if(n.length<2)return[t];let s=t,i=r.limits.maxIterations;for(let o=0;o<i;o++){if(A(s,n[0],r).some(Oe))return[s];let l=A(s,n[1],r);if(l.length===0)return[s];s=l[0]}throw new V(`jq until: too many iterations (${i}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[t];let s=[],i=t,o=r.limits.maxIterations;for(let a=0;a<o&&A(i,n[0],r).some(Oe);a++){s.push(i);let c=A(i,n[1],r);if(c.length===0)break;i=c[0]}if(s.length>=o)throw new V(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(n.length===0)return[t];let s=[],i=t,o=r.limits.maxIterations;for(let a=0;a<o;a++){s.push(i);let l=A(i,n[0],r);if(l.length===0)break;i=l[0]}if(s.length>=o)throw new V(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"debug":return[t];case"input_line_number":return[1];case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(i=>{let o=String(i??"");return o.includes(",")||o.includes('"')||o.includes(`
488
- `)?`"${o.replace(/"/g,'""')}"`:o}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(s=>String(s??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":return[JSON.stringify(t)];case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let s=r.currentPath;if(s.length===0)return[];let i=n.length>0?A(t,n[0],r)[0]:1;if(i>=0){if(i>s.length)return[];let o=s.slice(0,s.length-i);return[Bs(r.root,o)]}else{let o=-i-1;if(o>=s.length)return[t];let a=s.slice(0,o);return[Bs(r.root,a)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let s=r.currentPath,i=[];for(let o=s.length-1;o>=0;o--)i.push(Bs(r.root,s.slice(0,o)));return[i]}case"root":return r.root!==void 0?[r.root]:[];default:throw new Error(`Unknown function: ${e}`)}}function Ft(t,e){let n=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,r=n(t),s=n(e);if(r!==s)return r-s;if(typeof t=="number"&&typeof e=="number")return t-e;if(typeof t=="string"&&typeof e=="string")return t.localeCompare(e);if(typeof t=="boolean"&&typeof e=="boolean")return(t?1:0)-(e?1:0);if(Array.isArray(t)&&Array.isArray(e)){for(let i=0;i<Math.min(t.length,e.length);i++){let o=Ft(t[i],e[i]);if(o!==0)return o}return t.length-e.length}return 0}function gr(t,e){if(tn(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return e.every(n=>t.some(r=>gr(r,n)));if(t&&e&&typeof t=="object"&&typeof e=="object"&&!Array.isArray(t)&&!Array.isArray(e)){let n=t,r=e;return Object.keys(r).every(s=>s in n&&gr(n[s],r[s]))}return!1}function Us(t,e,n){if(e.length===0)return n;let[r,...s]=e;if(typeof r=="number"){let o=Array.isArray(t)?[...t]:[];for(;o.length<=r;)o.push(null);return o[r]=Us(o[r],s,n),o}let i=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};return i[r]=Us(i[r],s,n),i}function js(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i={...t};return delete i[String(s)],i}return t}let[n,...r]=e;if(Array.isArray(t)&&typeof n=="number"){let s=[...t];return s[n]=js(s[n],r),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s={...t};return s[String(n)]=js(s[String(n)],r),s}return t}function Eg(t,e,n,r,s){A(t,e,n).length>0&&s.push(r)}var gg,bc=C(()=>{"use strict";fe();gg=1e4});function Ec(t){let e=[],n=0,r=(c=0)=>t[n+c],s=()=>t[n++],i=()=>n>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
489
+ `),a=[];for(let u of o){let f=u.trim();f&&!f.startsWith("#")&&a.push(f)}let l=a.join("; ");return await r.exec(l,{env:s,cwd:r.cwd})}var bc,Sg,Cg,Bs=C(()=>{"use strict";j();bc={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},Sg={name:"bash",async execute(t,e){if(N(t))return k(bc);if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"bash",o=t.slice(3);return mr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],r=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,n),i=await e.fs.readFile(s);return mr(i,n,r,e)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
490
+ `,exitCode:127}}}},Cg={name:"sh",async execute(t,e){if(N(t))return k({...bc,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"sh",o=t.slice(3);return mr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],r=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,n),i=await e.fs.readFile(s);return mr(i,n,r,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
491
+ `,exitCode:127}}}}});function kg(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??Ag},env:t?.env}}function Ws(t,e,n){let r=new Map(t.vars);return r.set(e,n),{vars:r,limits:t.limits,env:t.env,root:t.root,currentPath:t.currentPath}}function Us(t,e){let n=t;for(let r of e)if(n&&typeof n=="object")n=n[r];else return;return n}function tn(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?tn(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?tn(t.base):[];if(e===null)return null;let n=t.index.value;return typeof n=="number"||typeof n=="string"?[...e,n]:null}if(t.type==="Pipe"){let e=tn(t.left);return e===null?null:js(e,t.right)}return t.type==="Call"&&(t.name==="parent"||t.name==="root"),null}function js(t,e){if(e.type==="Call"){if(e.name==="parent"){let n=1;if(e.args.length>0&&e.args[0].type==="Literal"){let r=e.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return t.slice(0,Math.max(0,t.length-n));{let r=-n-1;return t.slice(0,Math.min(r,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let n=tn(e);if(n!==null)return[...t,...n]}if(e.type==="Index"&&e.index.type==="Literal"){let n=tn(e);if(n!==null)return[...t,...n]}if(e.type==="Pipe"){let n=js(t,e.left);return n===null?null:js(n,e.right)}return e.type==="Identity"?t:null}function A(t,e,n){let r=n&&"vars"in n?n:kg(n);switch(r.root===void 0&&(r={...r,root:t,currentPath:[]}),e.type){case"Identity":return[t];case"Field":return(e.base?A(t,e.base,r):[t]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let o=i[e.name];return[o===void 0?null:o]}return[null]});case"Index":return(e.base?A(t,e.base,r):[t]).flatMap(i=>A(i,e.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){let l=a<0?i.length+a:a;return l>=0&&l<i.length?[i[l]]:[null]}return typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[a]]:[null]}));case"Slice":return(e.base?A(t,e.base,r):[t]).flatMap(i=>{if(!Array.isArray(i)&&typeof i!="string")return[null];let o=i.length,a=e.start?A(t,e.start,r):[0],l=e.end?A(t,e.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=Ec(c,o),d=Ec(u,o);return Array.isArray(i),i.slice(f,d)}))});case"Iterate":return(e.base?A(t,e.base,r):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=A(t,e.left,r),i=tn(e.left);return s.flatMap(o=>{if(i!==null){let a={...r,currentPath:[...r.currentPath??[],...i]};return A(o,e.right,a)}return A(o,e.right,r)})}case"Comma":{let s=A(t,e.left,r),i=A(t,e.right,r);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[A(t,e.elements,r)]:[[]];case"Object":{let s=[{}];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:A(t,i.key,r),a=A(t,i.value,r),l=[];for(let c of s)for(let u of o)for(let f of a)l.push({...c,[String(u)]:f});s.length=0,s.push(...l)}return s}case"Paren":return A(t,e.expr,r);case"BinaryOp":return vg(t,e.op,e.left,e.right,r);case"UnaryOp":return A(t,e.operand,r).map(i=>e.op==="-"?typeof i=="number"?-i:null:e.op==="not"?!Oe(i):null);case"Cond":return A(t,e.cond,r).flatMap(i=>{if(Oe(i))return A(t,e.then,r);for(let o of e.elifs)if(A(t,o.cond,r).some(Oe))return A(t,o.then,r);return e.else?A(t,e.else,r):[null]});case"Try":try{return A(t,e.body,r)}catch{return e.catch?A(t,e.catch,r):[]}case"Call":return Cc(t,e.name,e.args,r);case"VarBind":return A(t,e.value,r).flatMap(i=>{let o=Ws(r,e.name,i);return A(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[r.env??{}];let s=r.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return A(t,e.expr,r)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:A(t,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[Ng(t,e.path,e.op,e.value,r)];case"Reduce":{let s=A(t,e.expr,r),i=A(t,e.init,r)[0];for(let o of s){let a=Ws(r,e.varName,o);i=A(i,e.update,a)[0]}return[i]}case"Foreach":{let s=A(t,e.expr,r),i=A(t,e.init,r)[0],o=[];for(let a of s){let l=Ws(r,e.varName,a);if(i=A(i,e.update,l)[0],e.extract){let c=A(i,e.extract,l);o.push(...c)}else o.push(i)}return o}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function Ec(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function Ng(t,e,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return A(l,r,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?{...l,...c}:c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let d={...f};return d[c.name]=u(d[c.name]),d}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l};return f[c.name]=u(f[c.name]),f}return l}case"Index":{let d=A(t,c.index,s)[0];if(c.base)return o(l,c.base,p=>{if(typeof d=="number"&&Array.isArray(p)){let h=[...p],m=d<0?h.length+d:d;return m>=0&&m<h.length&&(h[m]=u(h[m])),h}if(typeof d=="string"&&p&&typeof p=="object"&&!Array.isArray(p)){let h={...p};return h[d]=u(h[d]),h}return p});if(typeof d=="number"&&Array.isArray(l)){let p=[...l],h=d<0?p.length+d:d;return h>=0&&h<p.length&&(p[h]=u(p[h])),p}if(typeof d=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){let p={...l};return p[d]=u(p[d]),p}return l}case"Iterate":{let f=d=>{if(Array.isArray(d))return d.map(p=>u(p));if(d&&typeof d=="object"){let p={};for(let[h,m]of Object.entries(d))p[h]=u(m);return p}return d};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,d=>d);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(n==="|=")return i(l,l);let c=A(t,r,s);return i(l,c[0]??null)})}function Ig(t,e,n){function r(s,i){switch(i.type){case"Identity":return null;case"Field":{if(s&&typeof s=="object"&&!Array.isArray(s)){let o={...s};return delete o[i.name],o}return s}case"Index":{let a=A(t,i.index,n)[0];if(typeof a=="number"&&Array.isArray(s)){let l=[...s],c=a<0?l.length+a:a;return c>=0&&c<l.length&&l.splice(c,1),l}if(typeof a=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){let l={...s};return delete l[a],l}return s}case"Iterate":return Array.isArray(s)?[]:s&&typeof s=="object"?{}:s;default:return s}}return r(t,e)}function Oe(t){return t!==null&&t!==!1}function vg(t,e,n,r,s){if(e==="and")return A(t,n,s).flatMap(l=>Oe(l)?A(t,r,s).map(u=>Oe(u)):[!1]);if(e==="or")return A(t,n,s).flatMap(l=>Oe(l)?[!0]:A(t,r,s).map(u=>Oe(u)));if(e==="//"){let l=A(t,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:A(t,r,s)}let i=A(t,n,s),o=A(t,r,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?{...a,...l}:null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}return null;case"*":return typeof a=="number"&&typeof l=="number"?a*l:typeof a=="string"&&typeof l=="number"?a.repeat(l):a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?Sc(a,l):null;case"/":return typeof a=="number"&&typeof l=="number"?a/l:typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":return typeof a=="number"&&typeof l=="number"?a%l:null;case"==":return nn(a,l);case"!=":return!nn(a,l);case"<":return gr(a,l)<0;case"<=":return gr(a,l)<=0;case">":return gr(a,l)>0;case">=":return gr(a,l)>=0;default:return null}}))}function nn(t,e){return JSON.stringify(t)===JSON.stringify(e)}function gr(t,e){return typeof t=="number"&&typeof e=="number"?t-e:typeof t=="string"&&typeof e=="string"?t.localeCompare(e):0}function Sc(t,e){let n={...t};for(let r of Object.keys(e))r in n&&n[r]&&typeof n[r]=="object"&&!Array.isArray(n[r])&&e[r]&&typeof e[r]=="object"&&!Array.isArray(e[r])?n[r]=Sc(n[r],e[r]):n[r]=e[r];return n}function Cc(t,e,n,r){switch(e){case"keys":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"values":return Array.isArray(t)?[t]:t&&typeof t=="object"?[Object.values(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:[null];case"utf8bytelength":return typeof t=="string"?[new TextEncoder().encode(t).length]:[null];case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"empty":return[];case"error":{let s=n.length>0?A(t,n[0],r)[0]:t;throw new Error(String(s))}case"not":return[!Oe(t)];case"null":return[null];case"true":return[!0];case"false":return[!1];case"first":if(n.length>0){let s=A(t,n[0],r);return s.length>0?[s[0]]:[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(n.length>0){let s=A(t,n[0],r);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(n.length<1)return[null];let i=A(t,n[0],r)[0];if(n.length>1){let o=A(t,n[1],r);return i>=0&&i<o.length?[o[i]]:[]}return Array.isArray(t)?i>=0&&i<t.length?[t[i]]:[null]:[null]}case"range":{if(n.length===0)return[];let s=A(t,n[0],r);if(n.length===1){let c=s[0];return Array.from({length:c},(u,f)=>f)}let i=A(t,n[1],r),o=s[0],a=i[0],l=[];for(let c=o;c<a;c++)l.push(c);return l}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"sort":return Array.isArray(t)?[[...t].sort(Tt)]:[null];case"sort_by":return!Array.isArray(t)||n.length===0?[null]:[[...t].sort((i,o)=>{let a=A(i,n[0],r)[0],l=A(o,n[0],r)[0];return Tt(a,l)})];case"unique":if(Array.isArray(t)){let s=new Set,i=[];for(let o of t){let a=JSON.stringify(o);s.has(a)||(s.add(a),i.push(o))}return[i]}return[null];case"unique_by":{if(!Array.isArray(t)||n.length===0)return[null];let s=new Set,i=[];for(let o of t){let a=JSON.stringify(A(o,n[0],r)[0]);s.has(a)||(s.add(a),i.push(o))}return[i]}case"group_by":{if(!Array.isArray(t)||n.length===0)return[null];let s=new Map;for(let i of t){let o=JSON.stringify(A(i,n[0],r)[0]);s.has(o)||s.set(o,[]),s.get(o)?.push(i)}return[[...s.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>Tt(s,i)>0?s:i)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((s,i)=>{let o=A(s,n[0],r)[0],a=A(i,n[0],r)[0];return Tt(o,a)>0?s:i})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>Tt(s,i)<0?s:i)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((s,i)=>{let o=A(s,n[0],r)[0],a=A(i,n[0],r)[0];return Tt(o,a)<0?s:i})];case"flatten":{if(!Array.isArray(t))return[null];let s=n.length>0?A(t,n[0],r)[0]:Number.POSITIVE_INFINITY;return[t.flat(s)]}case"add":if(Array.isArray(t)){if(t.length===0)return[null];if(t.every(s=>typeof s=="number"))return[t.reduce((s,i)=>s+i,0)];if(t.every(s=>typeof s=="string"))return[t.join("")];if(t.every(s=>Array.isArray(s)))return[t.flat()];if(t.every(s=>s&&typeof s=="object"&&!Array.isArray(s)))return[Object.assign({},...t)]}return[null];case"any":return n.length>0?Array.isArray(t)?[t.some(s=>Oe(A(s,n[0],r)[0]))]:[!1]:Array.isArray(t)?[t.some(Oe)]:[!1];case"all":return n.length>0?Array.isArray(t)?[t.every(s=>Oe(A(s,n[0],r)[0]))]:[!0]:Array.isArray(t)?[t.every(Oe)]:[!0];case"select":return n.length===0?[t]:A(t,n[0],r).some(Oe)?[t]:[];case"map":return n.length===0||!Array.isArray(t)?[null]:[t.flatMap(i=>A(i,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(t))return[t.flatMap(s=>A(s,n[0],r))];if(t&&typeof t=="object"){let s={};for(let[i,o]of Object.entries(t)){let a=A(o,n[0],r);a.length>0&&(s[i]=a[0])}return[s]}return[null]}case"has":{if(n.length===0)return[!1];let i=A(t,n[0],r)[0];return Array.isArray(t)&&typeof i=="number"?[i>=0&&i<t.length]:t&&typeof t=="object"&&typeof i=="string"?[i in t]:[!1]}case"in":{if(n.length===0)return[!1];let i=A(t,n[0],r)[0];return Array.isArray(i)&&typeof t=="number"?[t>=0&&t<i.length]:i&&typeof i=="object"&&typeof t=="string"?[t in i]:[!1]}case"contains":{if(n.length===0)return[!1];let s=A(t,n[0],r);return[yr(t,s[0])]}case"inside":{if(n.length===0)return[!1];let s=A(t,n[0],r);return[yr(s[0],t)]}case"getpath":{if(n.length===0)return[null];let i=A(t,n[0],r)[0],o=t;for(let a of i){if(o==null)return[null];if(Array.isArray(o)&&typeof a=="number")o=o[a];else if(typeof o=="object"&&typeof a=="string")o=o[a];else return[null]}return[o]}case"setpath":{if(n.length<2)return[null];let i=A(t,n[0],r)[0],a=A(t,n[1],r)[0];return[zs(t,i,a)]}case"delpaths":{if(n.length===0)return[t];let i=A(t,n[0],r)[0],o=t;for(let a of i.sort((l,c)=>c.length-l.length))o=Hs(o,a);return[o]}case"path":{if(n.length===0)return[[]];let s=[];return $g(t,n[0],r,[],s),s}case"del":return n.length===0?[t]:[Ig(t,n[0],r)];case"paths":{let s=[],i=(o,a)=>{if(o&&typeof o=="object")if(Array.isArray(o))for(let l=0;l<o.length;l++)s.push([...a,l]),i(o[l],[...a,l]);else for(let l of Object.keys(o))s.push([...a,l]),i(o[l],[...a,l])};return i(t,[]),n.length>0?s.filter(o=>{let a=t;for(let c of o)if(Array.isArray(a)&&typeof c=="number")a=a[c];else if(a&&typeof a=="object"&&typeof c=="string")a=a[c];else return!1;return A(a,n[0],r).some(Oe)}):s}case"leaf_paths":{let s=[],i=(o,a)=>{if(o===null||typeof o!="object")s.push(a);else if(Array.isArray(o))for(let l=0;l<o.length;l++)i(o[l],[...a,l]);else for(let l of Object.keys(o))i(o[l],[...a,l])};return i(t,[]),[s]}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([s,i])=>({key:s,value:i}))]:[null];case"from_entries":if(Array.isArray(t)){let s={};for(let i of t)if(i&&typeof i=="object"){let o=i,a=o.key??o.name??o.k,l=o.value??o.v;a!==void 0&&(s[String(a)]=l)}return[s]}return[null];case"with_entries":{if(n.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let i=Object.entries(t).map(([a,l])=>({key:a,value:l})).flatMap(a=>A(a,n[0],r)),o={};for(let a of i)if(a&&typeof a=="object"){let l=a,c=l.key??l.name??l.k,u=l.value??l.v;c!==void 0&&(o[String(c)]=u)}return[o]}return[null]}case"join":{if(!Array.isArray(t))return[null];let s=n.length>0?A(t,n[0],r):[""],i=String(s[0]);return[t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(i)]}case"split":{if(typeof t!="string"||n.length===0)return[null];let s=A(t,n[0],r),i=String(s[0]);return[t.split(i)]}case"test":{if(typeof t!="string"||n.length===0)return[!1];let s=A(t,n[0],r),i=String(s[0]);try{let o=n.length>1?String(A(t,n[1],r)[0]):"";return[new RegExp(i,o).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||n.length===0)return[null];let s=A(t,n[0],r),i=String(s[0]);try{let o=n.length>1?String(A(t,n[1],r)[0]):"",l=new RegExp(i,`${o}d`).exec(t);if(!l)return[];let c=l.indices;return[{offset:l.index,length:l[0].length,string:l[0],captures:l.slice(1).map((u,f)=>({offset:c?.[f+1]?.[0]??null,length:u?.length??0,string:u??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||n.length===0)return[null];let s=A(t,n[0],r),i=String(s[0]);try{let o=n.length>1?String(A(t,n[1],r)[0]):"",a=new RegExp(i,o),l=t.match(a);return!l||!l.groups?[{}]:[l.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||n.length<2)return[null];let s=A(t,n[0],r),i=A(t,n[1],r),o=String(s[0]),a=String(i[0]);try{let l=n.length>2?String(A(t,n[2],r)[0]):"";return[t.replace(new RegExp(o,l),a)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||n.length<2)return[null];let s=A(t,n[0],r),i=A(t,n[1],r),o=String(s[0]),a=String(i[0]);try{let l=n.length>2?String(A(t,n[2],r)[0]):"g",c=l.includes("g")?l:`${l}g`;return[t.replace(new RegExp(o,c),a)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.toLowerCase()]:[null];case"ascii_upcase":return typeof t=="string"?[t.toUpperCase()]:[null];case"ltrimstr":{if(typeof t!="string"||n.length===0)return[t];let s=A(t,n[0],r),i=String(s[0]);return[t.startsWith(i)?t.slice(i.length):t]}case"rtrimstr":{if(typeof t!="string"||n.length===0)return[t];let s=A(t,n[0],r),i=String(s[0]);return[t.endsWith(i)?t.slice(0,-i.length):t]}case"trim":return typeof t=="string"?[t.trim()]:[t];case"startswith":{if(typeof t!="string"||n.length===0)return[!1];let s=A(t,n[0],r);return[t.startsWith(String(s[0]))]}case"endswith":{if(typeof t!="string"||n.length===0)return[!1];let s=A(t,n[0],r);return[t.endsWith(String(s[0]))]}case"index":{if(n.length===0)return[null];let i=A(t,n[0],r)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.indexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){let o=t.findIndex(a=>nn(a,i));return[o>=0?o:null]}return[null]}case"rindex":{if(n.length===0)return[null];let i=A(t,n[0],r)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.lastIndexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){for(let o=t.length-1;o>=0;o--)if(nn(t[o],i))return[o];return[null]}return[null]}case"indices":{if(n.length===0)return[[]];let i=A(t,n[0],r)[0],o=[];if(typeof t=="string"&&typeof i=="string"){let a=t.indexOf(i);for(;a!==-1;)o.push(a),a=t.indexOf(i,a+1)}else if(Array.isArray(t))for(let a=0;a<t.length;a++)nn(t[a],i)&&o.push(a);return[o]}case"floor":return typeof t=="number"?[Math.floor(t)]:[null];case"ceil":return typeof t=="number"?[Math.ceil(t)]:[null];case"round":return typeof t=="number"?[Math.round(t)]:[null];case"sqrt":return typeof t=="number"?[Math.sqrt(t)]:[null];case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:[null];case"log":return typeof t=="number"?[Math.log(t)]:[null];case"log10":return typeof t=="number"?[Math.log10(t)]:[null];case"log2":return typeof t=="number"?[Math.log2(t)]:[null];case"exp":return typeof t=="number"?[Math.exp(t)]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(typeof t!="number"||n.length===0)return[null];let i=A(t,n[0],r)[0];return[t**i]}case"sin":return typeof t=="number"?[Math.sin(t)]:[null];case"cos":return typeof t=="number"?[Math.cos(t)]:[null];case"tan":return typeof t=="number"?[Math.tan(t)]:[null];case"asin":return typeof t=="number"?[Math.asin(t)]:[null];case"acos":return typeof t=="number"?[Math.acos(t)]:[null];case"atan":return typeof t=="number"?[Math.atan(t)]:[null];case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let s=Number(t);return[Number.isNaN(s)?null:s]}return[null];case"infinite":return[!Number.isFinite(t)];case"nan":return[Number.isNaN(t)];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"now":return[Date.now()/1e3];case"env":return[r.env??{}];case"recurse":{if(n.length===0){let a=[],l=c=>{if(a.push(c),Array.isArray(c))for(let u of c)l(u);else if(c&&typeof c=="object")for(let u of Object.keys(c))l(c[u])};return l(t),a}let s=[],i=new Set,o=a=>{let l=JSON.stringify(a);if(i.has(l))return;i.add(l),s.push(a);let c=A(a,n[0],r);for(let u of c)u!=null&&o(u)};return o(t),s}case"recurse_down":return Cc(t,"recurse",n,r);case"walk":{if(n.length===0)return[t];let s=new WeakSet,i=o=>{if(o&&typeof o=="object"){if(s.has(o))return o;s.add(o)}let a;if(Array.isArray(o))a=o.map(i);else if(o&&typeof o=="object"){let c={};for(let[u,f]of Object.entries(o))c[u]=i(f);a=c}else a=o;return A(a,n[0],r)[0]};return[i(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),i=[];for(let o=0;o<s;o++)i.push(t.map(a=>Array.isArray(a)?a[o]:null));return[i]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(s=>s.codePointAt(0))]:[null];case"implode":return Array.isArray(t)?[String.fromCodePoint(...t)]:[null];case"tojson":case"tojsonstream":return[JSON.stringify(t)];case"fromjson":{if(typeof t=="string")try{return[JSON.parse(t)]}catch{return[null]}return[null]}case"limit":{if(n.length<2)return[];let i=A(t,n[0],r)[0];return A(t,n[1],r).slice(0,i)}case"until":{if(n.length<2)return[t];let s=t,i=r.limits.maxIterations;for(let o=0;o<i;o++){if(A(s,n[0],r).some(Oe))return[s];let l=A(s,n[1],r);if(l.length===0)return[s];s=l[0]}throw new Z(`jq until: too many iterations (${i}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[t];let s=[],i=t,o=r.limits.maxIterations;for(let a=0;a<o&&A(i,n[0],r).some(Oe);a++){s.push(i);let c=A(i,n[1],r);if(c.length===0)break;i=c[0]}if(s.length>=o)throw new Z(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(n.length===0)return[t];let s=[],i=t,o=r.limits.maxIterations;for(let a=0;a<o;a++){s.push(i);let l=A(i,n[0],r);if(l.length===0)break;i=l[0]}if(s.length>=o)throw new Z(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"debug":return[t];case"input_line_number":return[1];case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(i=>{let o=String(i??"");return o.includes(",")||o.includes('"')||o.includes(`
492
+ `)?`"${o.replace(/"/g,'""')}"`:o}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(s=>String(s??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":return[JSON.stringify(t)];case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let s=r.currentPath;if(s.length===0)return[];let i=n.length>0?A(t,n[0],r)[0]:1;if(i>=0){if(i>s.length)return[];let o=s.slice(0,s.length-i);return[Us(r.root,o)]}else{let o=-i-1;if(o>=s.length)return[t];let a=s.slice(0,o);return[Us(r.root,a)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let s=r.currentPath,i=[];for(let o=s.length-1;o>=0;o--)i.push(Us(r.root,s.slice(0,o)));return[i]}case"root":return r.root!==void 0?[r.root]:[];default:throw new Error(`Unknown function: ${e}`)}}function Tt(t,e){let n=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,r=n(t),s=n(e);if(r!==s)return r-s;if(typeof t=="number"&&typeof e=="number")return t-e;if(typeof t=="string"&&typeof e=="string")return t.localeCompare(e);if(typeof t=="boolean"&&typeof e=="boolean")return(t?1:0)-(e?1:0);if(Array.isArray(t)&&Array.isArray(e)){for(let i=0;i<Math.min(t.length,e.length);i++){let o=Tt(t[i],e[i]);if(o!==0)return o}return t.length-e.length}return 0}function yr(t,e){if(nn(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return e.every(n=>t.some(r=>yr(r,n)));if(t&&e&&typeof t=="object"&&typeof e=="object"&&!Array.isArray(t)&&!Array.isArray(e)){let n=t,r=e;return Object.keys(r).every(s=>s in n&&yr(n[s],r[s]))}return!1}function zs(t,e,n){if(e.length===0)return n;let[r,...s]=e;if(typeof r=="number"){let o=Array.isArray(t)?[...t]:[];for(;o.length<=r;)o.push(null);return o[r]=zs(o[r],s,n),o}let i=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};return i[r]=zs(i[r],s,n),i}function Hs(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i={...t};return delete i[String(s)],i}return t}let[n,...r]=e;if(Array.isArray(t)&&typeof n=="number"){let s=[...t];return s[n]=Hs(s[n],r),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s={...t};return s[String(n)]=Hs(s[String(n)],r),s}return t}function $g(t,e,n,r,s){A(t,e,n).length>0&&s.push(r)}var Ag,Ac=C(()=>{"use strict";de();Ag=1e4});function kc(t){let e=[],n=0,r=(c=0)=>t[n+c],s=()=>t[n++],i=()=>n>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
489
493
  `||u==="\r")){if(u==="#"){for(;!i()&&r()!==`
490
494
  `;)s();continue}if(u==="."&&r()==="."){s(),e.push({type:"DOTDOT",pos:c});continue}if(u==="="&&r()==="="){s(),e.push({type:"EQ",pos:c});continue}if(u==="!"&&r()==="="){s(),e.push({type:"NE",pos:c});continue}if(u==="<"&&r()==="="){s(),e.push({type:"LE",pos:c});continue}if(u===">"&&r()==="="){s(),e.push({type:"GE",pos:c});continue}if(u==="/"&&r()==="/"){s(),r()==="="?(s(),e.push({type:"UPDATE_ALT",pos:c})):e.push({type:"ALT",pos:c});continue}if(u==="+"&&r()==="="){s(),e.push({type:"UPDATE_ADD",pos:c});continue}if(u==="-"&&r()==="="){s(),e.push({type:"UPDATE_SUB",pos:c});continue}if(u==="*"&&r()==="="){s(),e.push({type:"UPDATE_MUL",pos:c});continue}if(u==="/"&&r()==="="){s(),e.push({type:"UPDATE_DIV",pos:c});continue}if(u==="%"&&r()==="="){s(),e.push({type:"UPDATE_MOD",pos:c});continue}if(u==="="&&r()!=="="){e.push({type:"ASSIGN",pos:c});continue}if(u==="."){e.push({type:"DOT",pos:c});continue}if(u==="|"){r()==="="?(s(),e.push({type:"UPDATE_PIPE",pos:c})):e.push({type:"PIPE",pos:c});continue}if(u===","){e.push({type:"COMMA",pos:c});continue}if(u===":"){e.push({type:"COLON",pos:c});continue}if(u===";"){e.push({type:"SEMICOLON",pos:c});continue}if(u==="("){e.push({type:"LPAREN",pos:c});continue}if(u===")"){e.push({type:"RPAREN",pos:c});continue}if(u==="["){e.push({type:"LBRACKET",pos:c});continue}if(u==="]"){e.push({type:"RBRACKET",pos:c});continue}if(u==="{"){e.push({type:"LBRACE",pos:c});continue}if(u==="}"){e.push({type:"RBRACE",pos:c});continue}if(u==="?"){e.push({type:"QUESTION",pos:c});continue}if(u==="+"){e.push({type:"PLUS",pos:c});continue}if(u==="-"){if(o(r())){let f=u;for(;!i()&&(o(r())||r()===".");)f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}e.push({type:"MINUS",pos:c});continue}if(u==="*"){e.push({type:"STAR",pos:c});continue}if(u==="/"){e.push({type:"SLASH",pos:c});continue}if(u==="%"){e.push({type:"PERCENT",pos:c});continue}if(u==="<"){e.push({type:"LT",pos:c});continue}if(u===">"){e.push({type:"GT",pos:c});continue}if(o(u)){let f=u;for(;!i()&&(o(r())||r()==="."||r()==="e"||r()==="E");)(r()==="e"||r()==="E")&&(t[n+1]==="+"||t[n+1]==="-")&&(f+=s()),f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}if(u==='"'){let f="";for(;!i()&&r()!=='"';)if(r()==="\\"){if(s(),i())break;let d=s();switch(d){case"n":f+=`
491
- `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=d}}else f+=s();i()||s(),e.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(r());)f+=s();let d=Sg[f];d?e.push({type:d,pos:c}):e.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return e.push({type:"EOF",pos:n}),e}function Sc(t){let e=Ec(t);return new zs(e).parse()}var Sg,zs,Cc=C(()=>{"use strict";Sg={and:"AND",or:"OR",not:"NOT",if:"IF",then:"THEN",elif:"ELIF",else:"ELSE",end:"END",as:"AS",try:"TRY",catch:"CATCH",true:"TRUE",false:"FALSE",null:"NULL",reduce:"REDUCE",foreach:"FOREACH"};zs=class t{tokens;pos=0;constructor(e){this.tokens=e}peek(e=0){return this.tokens[this.pos+e]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let n of e)if(this.check(n))return this.advance();return null}expect(e,n){if(!this.check(e))throw new Error(`${n} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let e=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){return this.parsePipe()}parsePipe(){let e=this.parseComma();for(;this.match("PIPE");){let n=this.parseComma();e={type:"Pipe",left:e,right:n}}return e}parseComma(){let e=this.parseVarBind();for(;this.match("COMMA");){let n=this.parseVarBind();e={type:"Comma",left:e,right:n}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match("AS")){let n=this.expect("IDENT","Expected variable name after 'as'"),r=n.value;if(!r.startsWith("$"))throw new Error(`Variable name must start with $ at position ${n.pos}`);this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return{type:"VarBind",name:r,value:e,body:s}}return e}parseUpdate(){let e=this.parseAlt(),n={ASSIGN:"=",UPDATE_ADD:"+=",UPDATE_SUB:"-=",UPDATE_MUL:"*=",UPDATE_DIV:"/=",UPDATE_MOD:"%=",UPDATE_ALT:"//=",UPDATE_PIPE:"|="},r=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(r){let s=this.parseVarBind();return{type:"UpdateOp",op:n[r.type],path:e,value:s}}return e}parseAlt(){let e=this.parseOr();for(;this.match("ALT");){let n=this.parseOr();e={type:"BinaryOp",op:"//",left:e,right:n}}return e}parseOr(){let e=this.parseAnd();for(;this.match("OR");){let n=this.parseAnd();e={type:"BinaryOp",op:"or",left:e,right:n}}return e}parseAnd(){let e=this.parseNot();for(;this.match("AND");){let n=this.parseNot();e={type:"BinaryOp",op:"and",left:e,right:n}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),n={EQ:"==",NE:"!=",LT:"<",LE:"<=",GT:">",GE:">="},r=this.match("EQ","NE","LT","LE","GT","GE");if(r){let s=this.parseAddSub();e={type:"BinaryOp",op:n[r.type],left:e,right:s}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match("PLUS")){let n=this.parseMulDiv();e={type:"BinaryOp",op:"+",left:e,right:n}}else if(this.match("MINUS")){let n=this.parseMulDiv();e={type:"BinaryOp",op:"-",left:e,right:n}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match("STAR")){let n=this.parseUnary();e={type:"BinaryOp",op:"*",left:e,right:n}}else if(this.match("SLASH")){let n=this.parseUnary();e={type:"BinaryOp",op:"/",left:e,right:n}}else if(this.match("PERCENT")){let n=this.parseUnary();e={type:"BinaryOp",op:"%",left:e,right:n}}else break;return e}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("QUESTION"))e={type:"Optional",expr:e};else if(this.check("DOT")&&this.peek(1).type==="IDENT")this.advance(),e={type:"Field",name:this.expect("IDENT","Expected field name").value,base:e};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))e={type:"Iterate",base:e};else if(this.check("COLON")){this.advance();let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",end:n,base:e}}else{let n=this.parseExpr();if(this.match("COLON")){let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",start:n,end:r,base:e}}else this.expect("RBRACKET","Expected ']'"),e={type:"Index",index:n,base:e}}else break;return e}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.match("DOT")){if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:n}}let e=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:e,end:n}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:e}}return this.check("IDENT")?{type:"Field",name:this.advance().value}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let n=this.advance().value;return n.includes("\\(")?this.parseStringInterpolation(n):{type:"Literal",value:n}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let e=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:e}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let e=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:e}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let e=this.parsePostfix(),n;return this.match("CATCH")&&(n=this.parsePostfix()),{type:"Try",body:e,catch:n}}if(this.match("REDUCE")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after reduce expression");let n=this.expect("IDENT","Expected variable name"),r=n.value;if(!r.startsWith("$"))throw new Error(`Variable name must start with $ at position ${n.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr();return this.expect("RPAREN","Expected ')' after update expression"),{type:"Reduce",expr:e,varName:r,init:s,update:i}}if(this.match("FOREACH")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after foreach expression");let n=this.expect("IDENT","Expected variable name"),r=n.value;if(!r.startsWith("$"))throw new Error(`Variable name must start with $ at position ${n.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr(),o;return this.match("SEMICOLON")&&(o=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions"),{type:"Foreach",expr:e,varName:r,init:s,update:i,extract:o}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let n=this.advance().value;if(n.startsWith("$"))return{type:"VarRef",name:n};if(this.match("LPAREN")){let r=[];if(!this.check("RPAREN"))for(r.push(this.parseExpr());this.match("SEMICOLON");)r.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:n,args:r}}return{type:"Call",name:n,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let e=[];if(!this.check("RBRACE"))do{let n,r;if(this.match("LPAREN"))n=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else if(this.check("IDENT")){let s=this.advance().value;this.match("COLON")?(n=s,r=this.parseObjectValue()):(n=s,r={type:"Field",name:s})}else if(this.check("STRING"))n=this.advance().value,this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);e.push({key:n,value:r})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match("PIPE");){let n=this.parseVarBind();e={type:"Pipe",left:e,right:n}}return e}parseIf(){let e=this.parseExpr();this.expect("THEN","Expected 'then'");let n=this.parseExpr(),r=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();r.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:e,then:n,elifs:r,else:s}}parseStringInterpolation(e){let n=[],r="",s=0;for(;s<e.length;)if(e[s]==="\\"&&e[s+1]==="("){r&&(n.push(r),r=""),s+=2;let i=1,o="";for(;s<e.length&&i>0;)e[s]==="("?i++:e[s]===")"&&i--,i>0&&(o+=e[s]),s++;let a=Ec(o),l=new t(a);n.push(l.parse())}else r+=e[s],s++;return r&&n.push(r),{type:"StringInterp",parts:n}}}});var Ac=C(()=>{"use strict";bc();Cc()});var Nc={};L(Nc,{jqCommand:()=>Ag});function kc(t){let e=[],n=0,r=t.length;for(;n<r;){for(;n<r&&/\s/.test(t[n]);)n++;if(n>=r)break;let s=n,i=t[n];if(i==="{"||i==="["){let o=i,a=i==="{"?"}":"]",l=1,c=!1,u=!1;for(n++;n<r&&l>0;){let f=t[n];u?u=!1:f==="\\"?u=!0:f==='"'?c=!c:c||(f===o?l++:f===a&&l--),n++}if(l!==0)throw new Error(`Unexpected end of JSON input at position ${n} (unclosed ${o})`);e.push(JSON.parse(t.slice(s,n)))}else if(i==='"'){let o=!1;for(n++;n<r;){let a=t[n];if(o)o=!1;else if(a==="\\")o=!0;else if(a==='"'){n++;break}n++}e.push(JSON.parse(t.slice(s,n)))}else if(i==="-"||i>="0"&&i<="9"){for(;n<r&&/[\d.eE+-]/.test(t[n]);)n++;e.push(JSON.parse(t.slice(s,n)))}else if(t.slice(n,n+4)==="true")e.push(!0),n+=4;else if(t.slice(n,n+5)==="false")e.push(!1),n+=5;else if(t.slice(n,n+4)==="null")e.push(null),n+=4;else{let o=t.slice(n,n+10);throw new Error(`Invalid JSON at position ${s}: unexpected '${o.split(/\s/)[0]}'`)}}return e}function Rn(t,e,n,r,s,i=0){if(t===null||t===void 0)return"null";if(typeof t=="boolean")return String(t);if(typeof t=="number")return Number.isFinite(t)?String(t):"null";if(typeof t=="string")return n?t:JSON.stringify(t);let o=s?" ":" ";if(Array.isArray(t))return t.length===0?"[]":e?`[${t.map(l=>Rn(l,!0,!1,r,s)).join(",")}]`:`[
492
- ${t.map(l=>o.repeat(i+1)+Rn(l,!1,!1,r,s,i+1)).join(`,
495
+ `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=d}}else f+=s();i()||s(),e.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(r());)f+=s();let d=Rg[f];d?e.push({type:d,pos:c}):e.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return e.push({type:"EOF",pos:n}),e}function Nc(t){let e=kc(t);return new Gs(e).parse()}var Rg,Gs,Ic=C(()=>{"use strict";Rg={and:"AND",or:"OR",not:"NOT",if:"IF",then:"THEN",elif:"ELIF",else:"ELSE",end:"END",as:"AS",try:"TRY",catch:"CATCH",true:"TRUE",false:"FALSE",null:"NULL",reduce:"REDUCE",foreach:"FOREACH"};Gs=class t{tokens;pos=0;constructor(e){this.tokens=e}peek(e=0){return this.tokens[this.pos+e]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let n of e)if(this.check(n))return this.advance();return null}expect(e,n){if(!this.check(e))throw new Error(`${n} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let e=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){return this.parsePipe()}parsePipe(){let e=this.parseComma();for(;this.match("PIPE");){let n=this.parseComma();e={type:"Pipe",left:e,right:n}}return e}parseComma(){let e=this.parseVarBind();for(;this.match("COMMA");){let n=this.parseVarBind();e={type:"Comma",left:e,right:n}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match("AS")){let n=this.expect("IDENT","Expected variable name after 'as'"),r=n.value;if(!r.startsWith("$"))throw new Error(`Variable name must start with $ at position ${n.pos}`);this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return{type:"VarBind",name:r,value:e,body:s}}return e}parseUpdate(){let e=this.parseAlt(),n={ASSIGN:"=",UPDATE_ADD:"+=",UPDATE_SUB:"-=",UPDATE_MUL:"*=",UPDATE_DIV:"/=",UPDATE_MOD:"%=",UPDATE_ALT:"//=",UPDATE_PIPE:"|="},r=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(r){let s=this.parseVarBind();return{type:"UpdateOp",op:n[r.type],path:e,value:s}}return e}parseAlt(){let e=this.parseOr();for(;this.match("ALT");){let n=this.parseOr();e={type:"BinaryOp",op:"//",left:e,right:n}}return e}parseOr(){let e=this.parseAnd();for(;this.match("OR");){let n=this.parseAnd();e={type:"BinaryOp",op:"or",left:e,right:n}}return e}parseAnd(){let e=this.parseNot();for(;this.match("AND");){let n=this.parseNot();e={type:"BinaryOp",op:"and",left:e,right:n}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),n={EQ:"==",NE:"!=",LT:"<",LE:"<=",GT:">",GE:">="},r=this.match("EQ","NE","LT","LE","GT","GE");if(r){let s=this.parseAddSub();e={type:"BinaryOp",op:n[r.type],left:e,right:s}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match("PLUS")){let n=this.parseMulDiv();e={type:"BinaryOp",op:"+",left:e,right:n}}else if(this.match("MINUS")){let n=this.parseMulDiv();e={type:"BinaryOp",op:"-",left:e,right:n}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match("STAR")){let n=this.parseUnary();e={type:"BinaryOp",op:"*",left:e,right:n}}else if(this.match("SLASH")){let n=this.parseUnary();e={type:"BinaryOp",op:"/",left:e,right:n}}else if(this.match("PERCENT")){let n=this.parseUnary();e={type:"BinaryOp",op:"%",left:e,right:n}}else break;return e}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("QUESTION"))e={type:"Optional",expr:e};else if(this.check("DOT")&&this.peek(1).type==="IDENT")this.advance(),e={type:"Field",name:this.expect("IDENT","Expected field name").value,base:e};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))e={type:"Iterate",base:e};else if(this.check("COLON")){this.advance();let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",end:n,base:e}}else{let n=this.parseExpr();if(this.match("COLON")){let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",start:n,end:r,base:e}}else this.expect("RBRACKET","Expected ']'"),e={type:"Index",index:n,base:e}}else break;return e}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.match("DOT")){if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:n}}let e=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:e,end:n}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:e}}return this.check("IDENT")?{type:"Field",name:this.advance().value}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let n=this.advance().value;return n.includes("\\(")?this.parseStringInterpolation(n):{type:"Literal",value:n}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let e=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:e}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let e=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:e}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let e=this.parsePostfix(),n;return this.match("CATCH")&&(n=this.parsePostfix()),{type:"Try",body:e,catch:n}}if(this.match("REDUCE")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after reduce expression");let n=this.expect("IDENT","Expected variable name"),r=n.value;if(!r.startsWith("$"))throw new Error(`Variable name must start with $ at position ${n.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr();return this.expect("RPAREN","Expected ')' after update expression"),{type:"Reduce",expr:e,varName:r,init:s,update:i}}if(this.match("FOREACH")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after foreach expression");let n=this.expect("IDENT","Expected variable name"),r=n.value;if(!r.startsWith("$"))throw new Error(`Variable name must start with $ at position ${n.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr(),o;return this.match("SEMICOLON")&&(o=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions"),{type:"Foreach",expr:e,varName:r,init:s,update:i,extract:o}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let n=this.advance().value;if(n.startsWith("$"))return{type:"VarRef",name:n};if(this.match("LPAREN")){let r=[];if(!this.check("RPAREN"))for(r.push(this.parseExpr());this.match("SEMICOLON");)r.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:n,args:r}}return{type:"Call",name:n,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let e=[];if(!this.check("RBRACE"))do{let n,r;if(this.match("LPAREN"))n=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else if(this.check("IDENT")){let s=this.advance().value;this.match("COLON")?(n=s,r=this.parseObjectValue()):(n=s,r={type:"Field",name:s})}else if(this.check("STRING"))n=this.advance().value,this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);e.push({key:n,value:r})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match("PIPE");){let n=this.parseVarBind();e={type:"Pipe",left:e,right:n}}return e}parseIf(){let e=this.parseExpr();this.expect("THEN","Expected 'then'");let n=this.parseExpr(),r=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();r.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:e,then:n,elifs:r,else:s}}parseStringInterpolation(e){let n=[],r="",s=0;for(;s<e.length;)if(e[s]==="\\"&&e[s+1]==="("){r&&(n.push(r),r=""),s+=2;let i=1,o="";for(;s<e.length&&i>0;)e[s]==="("?i++:e[s]===")"&&i--,i>0&&(o+=e[s]),s++;let a=kc(o),l=new t(a);n.push(l.parse())}else r+=e[s],s++;return r&&n.push(r),{type:"StringInterp",parts:n}}}});var vc=C(()=>{"use strict";Ac();Ic()});var Rc={};_(Rc,{jqCommand:()=>Pg});function $c(t){let e=[],n=0,r=t.length;for(;n<r;){for(;n<r&&/\s/.test(t[n]);)n++;if(n>=r)break;let s=n,i=t[n];if(i==="{"||i==="["){let o=i,a=i==="{"?"}":"]",l=1,c=!1,u=!1;for(n++;n<r&&l>0;){let f=t[n];u?u=!1:f==="\\"?u=!0:f==='"'?c=!c:c||(f===o?l++:f===a&&l--),n++}if(l!==0)throw new Error(`Unexpected end of JSON input at position ${n} (unclosed ${o})`);e.push(JSON.parse(t.slice(s,n)))}else if(i==='"'){let o=!1;for(n++;n<r;){let a=t[n];if(o)o=!1;else if(a==="\\")o=!0;else if(a==='"'){n++;break}n++}e.push(JSON.parse(t.slice(s,n)))}else if(i==="-"||i>="0"&&i<="9"){for(;n<r&&/[\d.eE+-]/.test(t[n]);)n++;e.push(JSON.parse(t.slice(s,n)))}else if(t.slice(n,n+4)==="true")e.push(!0),n+=4;else if(t.slice(n,n+5)==="false")e.push(!1),n+=5;else if(t.slice(n,n+4)==="null")e.push(null),n+=4;else{let o=t.slice(n,n+10);throw new Error(`Invalid JSON at position ${s}: unexpected '${o.split(/\s/)[0]}'`)}}return e}function Pn(t,e,n,r,s,i=0){if(t===null||t===void 0)return"null";if(typeof t=="boolean")return String(t);if(typeof t=="number")return Number.isFinite(t)?String(t):"null";if(typeof t=="string")return n?t:JSON.stringify(t);let o=s?" ":" ";if(Array.isArray(t))return t.length===0?"[]":e?`[${t.map(l=>Pn(l,!0,!1,r,s)).join(",")}]`:`[
496
+ ${t.map(l=>o.repeat(i+1)+Pn(l,!1,!1,r,s,i+1)).join(`,
493
497
  `)}
494
- ${o.repeat(i)}]`;if(typeof t=="object"){let a=Object.keys(t);return r&&(a=a.sort()),a.length===0?"{}":e?`{${a.map(c=>`${JSON.stringify(c)}:${Rn(t[c],!0,!1,r,s)}`).join(",")}}`:`{
495
- ${a.map(c=>{let u=Rn(t[c],!1,!1,r,s,i+1);return`${o.repeat(i+1)}${JSON.stringify(c)}: ${u}`}).join(`,
498
+ ${o.repeat(i)}]`;if(typeof t=="object"){let a=Object.keys(t);return r&&(a=a.sort()),a.length===0?"{}":e?`{${a.map(c=>`${JSON.stringify(c)}:${Pn(t[c],!0,!1,r,s)}`).join(",")}}`:`{
499
+ ${a.map(c=>{let u=Pn(t[c],!1,!1,r,s,i+1);return`${o.repeat(i+1)}${JSON.stringify(c)}: ${u}`}).join(`,
496
500
  `)}
497
- ${o.repeat(i)}}`}return String(t)}var Cg,Ag,Ic=C(()=>{"use strict";fe();Nt();j();Ac();Cg={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};Ag={name:"jq",async execute(t,e){if(I(t))return N(Cg);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=".",f=!1,d=[];for(let h=0;h<t.length;h++){let m=t[h];if(m==="-r"||m==="--raw-output")n=!0;else if(m==="-c"||m==="--compact-output")r=!0;else if(m==="-e"||m==="--exit-status")s=!0;else if(m==="-s"||m==="--slurp")i=!0;else if(m==="-n"||m==="--null-input")o=!0;else if(m==="-j"||m==="--join-output")a=!0;else if(!(m==="-a"||m==="--ascii")){if(m==="-S"||m==="--sort-keys")l=!0;else if(!(m==="-C"||m==="--color")){if(!(m==="-M"||m==="--monochrome"))if(m==="--tab")c=!0;else if(m==="-")d.push("-");else{if(m.startsWith("--"))return D("jq",m);if(m.startsWith("-")){for(let g of m.slice(1))if(g==="r")n=!0;else if(g==="c")r=!0;else if(g==="e")s=!0;else if(g==="s")i=!0;else if(g==="n")o=!0;else if(g==="j")a=!0;else if(g!=="a"){if(g==="S")l=!0;else if(g!=="C"){if(g!=="M")return D("jq",`-${g}`)}}}else f?d.push(m):(u=m,f=!0)}}}}let p=[];if(!o)if(d.length===0||d.length===1&&d[0]==="-")p.push({source:"stdin",content:e.stdin});else{let h=await kt(e,d,{cmdName:"jq",stopOnError:!0});if(h.exitCode!==0)return{stdout:"",stderr:h.stderr,exitCode:2};p=h.files.map(m=>({source:m.filename||"stdin",content:m.content}))}try{let h=Sc(u),m=[],g={limits:e.limits?{maxIterations:e.limits.maxJqIterations}:void 0,env:e.env};if(o)m=A(null,h,g);else if(i){let R=[];for(let{content:P}of p){let z=P.trim();z&&R.push(...kc(z))}m=A(R,h,g)}else for(let{content:R}of p){let P=R.trim();if(!P)continue;let z=kc(P);for(let W of z)m.push(...A(W,h,g))}let w=m.map(R=>Rn(R,r,n,l,c)),b=a?"":`
498
- `,E=w.join(b),S=s&&(m.length===0||m.every(R=>R==null||R===!1))?1:0;return{stdout:E?a?E:`${E}
499
- `:"",stderr:"",exitCode:S}}catch(h){if(h instanceof V)return{stdout:"",stderr:`jq: ${h.message}
500
- `,exitCode:V.EXIT_CODE};let m=h.message;return m.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${m}
501
+ ${o.repeat(i)}}`}return String(t)}var Fg,Pg,Fc=C(()=>{"use strict";de();It();j();vc();Fg={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};Pg={name:"jq",async execute(t,e){if(N(t))return k(Fg);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=".",f=!1,d=[];for(let h=0;h<t.length;h++){let m=t[h];if(m==="-r"||m==="--raw-output")n=!0;else if(m==="-c"||m==="--compact-output")r=!0;else if(m==="-e"||m==="--exit-status")s=!0;else if(m==="-s"||m==="--slurp")i=!0;else if(m==="-n"||m==="--null-input")o=!0;else if(m==="-j"||m==="--join-output")a=!0;else if(!(m==="-a"||m==="--ascii")){if(m==="-S"||m==="--sort-keys")l=!0;else if(!(m==="-C"||m==="--color")){if(!(m==="-M"||m==="--monochrome"))if(m==="--tab")c=!0;else if(m==="-")d.push("-");else{if(m.startsWith("--"))return L("jq",m);if(m.startsWith("-")){for(let g of m.slice(1))if(g==="r")n=!0;else if(g==="c")r=!0;else if(g==="e")s=!0;else if(g==="s")i=!0;else if(g==="n")o=!0;else if(g==="j")a=!0;else if(g!=="a"){if(g==="S")l=!0;else if(g!=="C"){if(g!=="M")return L("jq",`-${g}`)}}}else f?d.push(m):(u=m,f=!0)}}}}let p=[];if(!o)if(d.length===0||d.length===1&&d[0]==="-")p.push({source:"stdin",content:e.stdin});else{let h=await Nt(e,d,{cmdName:"jq",stopOnError:!0});if(h.exitCode!==0)return{stdout:"",stderr:h.stderr,exitCode:2};p=h.files.map(m=>({source:m.filename||"stdin",content:m.content}))}try{let h=Nc(u),m=[],g={limits:e.limits?{maxIterations:e.limits.maxJqIterations}:void 0,env:e.env};if(o)m=A(null,h,g);else if(i){let R=[];for(let{content:F}of p){let z=F.trim();z&&R.push(...$c(z))}m=A(R,h,g)}else for(let{content:R}of p){let F=R.trim();if(!F)continue;let z=$c(F);for(let W of z)m.push(...A(W,h,g))}let b=m.map(R=>Pn(R,r,n,l,c)),w=a?"":`
502
+ `,E=b.join(w),S=s&&(m.length===0||m.every(R=>R==null||R===!1))?1:0;return{stdout:E?a?E:`${E}
503
+ `:"",stderr:"",exitCode:S}}catch(h){if(h instanceof Z)return{stdout:"",stderr:`jq: ${h.message}
504
+ `,exitCode:Z.EXIT_CODE};let m=h.message;return m.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${m}
501
505
  `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${m}
502
- `,exitCode:5}}}}});var $c={};L($c,{base64Command:()=>Ig});async function vc(t,e,n){if(e.length===0||e.length===1&&e[0]==="-")return{ok:!0,data:Uint8Array.from(t.stdin,a=>a.charCodeAt(0))};let r=[];for(let a of e){if(a==="-"){r.push(Uint8Array.from(t.stdin,l=>l.charCodeAt(0)));continue}try{let l=t.fs.resolvePath(t.cwd,a),c=await t.fs.readFileBuffer(l);r.push(c)}catch{return{ok:!1,error:{stdout:"",stderr:`${n}: ${a}: No such file or directory
503
- `,exitCode:1}}}}let s=r.reduce((a,l)=>a+l.length,0),i=new Uint8Array(s),o=0;for(let a of r)i.set(a,o),o+=a.length;return{ok:!0,data:i}}var kg,Ng,Ig,Rc=C(()=>{"use strict";Ae();j();kg={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},Ng={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};Ig={name:"base64",async execute(t,e){if(I(t))return N(kg);let n=K("base64",t,Ng);if(!n.ok)return n.error;let r=n.result.flags.decode,s=n.result.flags.wrap,i=n.result.positional;try{if(r){let l=await vc(e,i,"base64");if(!l.ok)return l.error;let u=String.fromCharCode(...l.data).replace(/\s/g,"");return{stdout:atob(u),stderr:"",exitCode:0}}let o=await vc(e,i,"base64");if(!o.ok)return o.error;let a=btoa(String.fromCharCode(...o.data));if(s>0){let l=[];for(let c=0;c<a.length;c+=s)l.push(a.slice(c,c+s));a=l.join(`
506
+ `,exitCode:5}}}}});var Tc={};_(Tc,{base64Command:()=>Dg});async function Pc(t,e,n){if(e.length===0||e.length===1&&e[0]==="-")return{ok:!0,data:Uint8Array.from(t.stdin,a=>a.charCodeAt(0))};let r=[];for(let a of e){if(a==="-"){r.push(Uint8Array.from(t.stdin,l=>l.charCodeAt(0)));continue}try{let l=t.fs.resolvePath(t.cwd,a),c=await t.fs.readFileBuffer(l);r.push(c)}catch{return{ok:!1,error:{stdout:"",stderr:`${n}: ${a}: No such file or directory
507
+ `,exitCode:1}}}}let s=r.reduce((a,l)=>a+l.length,0),i=new Uint8Array(s),o=0;for(let a of r)i.set(a,o),o+=a.length;return{ok:!0,data:i}}var Tg,Og,Dg,Oc=C(()=>{"use strict";Ae();j();Tg={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},Og={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};Dg={name:"base64",async execute(t,e){if(N(t))return k(Tg);let n=Q("base64",t,Og);if(!n.ok)return n.error;let r=n.result.flags.decode,s=n.result.flags.wrap,i=n.result.positional;try{if(r){let l=await Pc(e,i,"base64");if(!l.ok)return l.error;let u=String.fromCharCode(...l.data).replace(/\s/g,"");return{stdout:atob(u),stderr:"",exitCode:0}}let o=await Pc(e,i,"base64");if(!o.ok)return o.error;let a=btoa(String.fromCharCode(...o.data));if(s>0){let l=[];for(let c=0;c<a.length;c+=s)l.push(a.slice(c,c+s));a=l.join(`
504
508
  `)+(a.length>0?`
505
509
  `:"")}return{stdout:a,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`base64: invalid input
506
- `,exitCode:1}}}}});var Fc={};L(Fc,{diffCommand:()=>Rg});import*as Pc from"diff";var vg,$g,Rg,Tc=C(()=>{"use strict";Ae();j();vg={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},$g={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},Rg={name:"diff",async execute(t,e){if(I(t))return N(vg);let n=K("diff",t,$g);if(!n.ok)return n.error;let r=n.result.flags.brief,s=n.result.flags.reportSame,i=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
510
+ `,exitCode:1}}}}});var Lc={};_(Lc,{diffCommand:()=>_g});import*as Dc from"diff";var Lg,Mg,_g,Mc=C(()=>{"use strict";Ae();j();Lg={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},Mg={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},_g={name:"diff",async execute(t,e){if(N(t))return k(Lg);let n=Q("diff",t,Mg);if(!n.ok)return n.error;let r=n.result.flags.brief,s=n.result.flags.reportSame,i=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
507
511
  `,exitCode:2};let a,l,[c,u]=o;try{a=c==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory
508
512
  `,exitCode:2}}try{l=u==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
509
513
  `,exitCode:2}}let f=a,d=l;return i&&(f=f.toLowerCase(),d=d.toLowerCase()),f===d?s?{stdout:`Files ${c} and ${u} are identical
510
514
  `,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:r?{stdout:`Files ${c} and ${u} differ
511
- `,stderr:"",exitCode:1}:{stdout:Pc.createTwoFilesPatch(c,u,a,l,"","",{context:3}),stderr:"",exitCode:1}}}});var Oc={};L(Oc,{dateCommand:()=>Lg});function De(t,e=2){return String(t).padStart(e,"0")}function Og(t){let e=-t.getTimezoneOffset();return`${e>=0?"+":"-"}${De(Math.floor(Math.abs(e)/60))}${De(Math.abs(e)%60)}`}function yr(t,e,n){let r=n?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},s="",i=0;for(;i<e.length;){if(e[i]==="%"&&i+1<e.length){let o=e[++i];switch(o){case"%":s+="%";break;case"a":s+=Fg[r.w];break;case"b":case"h":s+=Tg[r.m];break;case"d":s+=De(r.D);break;case"e":s+=String(r.D).padStart(2," ");break;case"F":s+=`${r.Y}-${De(r.m+1)}-${De(r.D)}`;break;case"H":s+=De(r.H);break;case"I":s+=De(r.H%12||12);break;case"m":s+=De(r.m+1);break;case"M":s+=De(r.M);break;case"n":s+=`
512
- `;break;case"p":s+=r.H<12?"AM":"PM";break;case"P":s+=r.H<12?"am":"pm";break;case"R":s+=`${De(r.H)}:${De(r.M)}`;break;case"s":s+=Math.floor(t.getTime()/1e3);break;case"S":s+=De(r.S);break;case"t":s+=" ";break;case"T":s+=`${De(r.H)}:${De(r.M)}:${De(r.S)}`;break;case"u":s+=r.w||7;break;case"w":s+=r.w;break;case"y":s+=De(r.Y%100);break;case"Y":s+=r.Y;break;case"z":s+=n?"+0000":Og(t);break;case"Z":s+=n?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:s+=`%${o}`}}else s+=e[i];i++}return s}function Dg(t){let e=new Date(t);if(!Number.isNaN(e.getTime()))return e;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let n=t.toLowerCase();return n==="now"||n==="today"?new Date:n==="yesterday"?new Date(Date.now()-864e5):n==="tomorrow"?new Date(Date.now()+864e5):null}var Pg,Fg,Tg,Lg,Dc=C(()=>{"use strict";j();Pg={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},Fg=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Tg=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];Lg={name:"date",async execute(t,e){if(I(t))return N(Pg);let n=!1,r=null,s=null,i=!1,o=!1;for(let c=0;c<t.length;c++){let u=t[c];if(u==="-u"||u==="--utc")n=!0;else if(u==="-d"||u==="--date")r=t[++c]??"";else if(u.startsWith("--date="))r=u.slice(7);else if(u==="-I"||u==="--iso-8601")i=!0;else if(u==="-R"||u==="--rfc-email")o=!0;else if(u.startsWith("+"))s=u.slice(1);else{if(u.startsWith("--"))return D("date",u);if(u.startsWith("-"))for(let f of u.slice(1))if(f==="u")n=!0;else if(f==="I")i=!0;else if(f==="R")o=!0;else return D("date",`-${f}`)}}let a=r!==null?Dg(r):new Date;if(!a)return{stdout:"",stderr:`date: invalid date '${r}'
513
- `,exitCode:1};let l;return s?l=yr(a,s,n):i?l=yr(a,"%Y-%m-%dT%H:%M:%S%z",n):o?l=yr(a,"%a, %d %b %Y %H:%M:%S %z",n):l=yr(a,"%a %b %e %H:%M:%S %Z %Y",n),{stdout:`${l}
514
- `,stderr:"",exitCode:0}}}});var Lc={};L(Lc,{sleepCommand:()=>Bg});function _g(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let n=parseFloat(e[1]);switch(e[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var Mg,Bg,Mc=C(()=>{"use strict";j();Mg={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
515
+ `,stderr:"",exitCode:1}:{stdout:Dc.createTwoFilesPatch(c,u,a,l,"","",{context:3}),stderr:"",exitCode:1}}}});var _c={};_(_c,{dateCommand:()=>Hg});function De(t,e=2){return String(t).padStart(e,"0")}function jg(t){let e=-t.getTimezoneOffset();return`${e>=0?"+":"-"}${De(Math.floor(Math.abs(e)/60))}${De(Math.abs(e)%60)}`}function xr(t,e,n){let r=n?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},s="",i=0;for(;i<e.length;){if(e[i]==="%"&&i+1<e.length){let o=e[++i];switch(o){case"%":s+="%";break;case"a":s+=Wg[r.w];break;case"b":case"h":s+=Ug[r.m];break;case"d":s+=De(r.D);break;case"e":s+=String(r.D).padStart(2," ");break;case"F":s+=`${r.Y}-${De(r.m+1)}-${De(r.D)}`;break;case"H":s+=De(r.H);break;case"I":s+=De(r.H%12||12);break;case"m":s+=De(r.m+1);break;case"M":s+=De(r.M);break;case"n":s+=`
516
+ `;break;case"p":s+=r.H<12?"AM":"PM";break;case"P":s+=r.H<12?"am":"pm";break;case"R":s+=`${De(r.H)}:${De(r.M)}`;break;case"s":s+=Math.floor(t.getTime()/1e3);break;case"S":s+=De(r.S);break;case"t":s+=" ";break;case"T":s+=`${De(r.H)}:${De(r.M)}:${De(r.S)}`;break;case"u":s+=r.w||7;break;case"w":s+=r.w;break;case"y":s+=De(r.Y%100);break;case"Y":s+=r.Y;break;case"z":s+=n?"+0000":jg(t);break;case"Z":s+=n?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:s+=`%${o}`}}else s+=e[i];i++}return s}function zg(t){let e=new Date(t);if(!Number.isNaN(e.getTime()))return e;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let n=t.toLowerCase();return n==="now"||n==="today"?new Date:n==="yesterday"?new Date(Date.now()-864e5):n==="tomorrow"?new Date(Date.now()+864e5):null}var Bg,Wg,Ug,Hg,Bc=C(()=>{"use strict";j();Bg={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},Wg=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ug=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];Hg={name:"date",async execute(t,e){if(N(t))return k(Bg);let n=!1,r=null,s=null,i=!1,o=!1;for(let c=0;c<t.length;c++){let u=t[c];if(u==="-u"||u==="--utc")n=!0;else if(u==="-d"||u==="--date")r=t[++c]??"";else if(u.startsWith("--date="))r=u.slice(7);else if(u==="-I"||u==="--iso-8601")i=!0;else if(u==="-R"||u==="--rfc-email")o=!0;else if(u.startsWith("+"))s=u.slice(1);else{if(u.startsWith("--"))return L("date",u);if(u.startsWith("-"))for(let f of u.slice(1))if(f==="u")n=!0;else if(f==="I")i=!0;else if(f==="R")o=!0;else return L("date",`-${f}`)}}let a=r!==null?zg(r):new Date;if(!a)return{stdout:"",stderr:`date: invalid date '${r}'
517
+ `,exitCode:1};let l;return s?l=xr(a,s,n):i?l=xr(a,"%Y-%m-%dT%H:%M:%S%z",n):o?l=xr(a,"%a, %d %b %Y %H:%M:%S %z",n):l=xr(a,"%a %b %e %H:%M:%S %Z %Y",n),{stdout:`${l}
518
+ `,stderr:"",exitCode:0}}}});var Wc={};_(Wc,{sleepCommand:()=>Vg});function qg(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let n=parseFloat(e[1]);switch(e[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var Gg,Vg,Uc=C(()=>{"use strict";j();Gg={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
515
519
  s - seconds (default)
516
520
  m - minutes
517
521
  h - hours
518
522
  d - days
519
523
 
520
- NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};Bg={name:"sleep",async execute(t,e){if(I(t))return N(Mg);if(t.length===0)return{stdout:"",stderr:`sleep: missing operand
521
- `,exitCode:1};let n=0;for(let r of t){let s=_g(r);if(s===null)return{stdout:"",stderr:`sleep: invalid time interval '${r}'
522
- `,exitCode:1};n+=s}return e.sleep?await e.sleep(n):await new Promise(r=>setTimeout(r,n)),{stdout:"",stderr:"",exitCode:0}}}});var _c={};L(_c,{timeoutCommand:()=>jg});function Ug(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let n=parseFloat(e[1]);switch(e[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var Wg,jg,Bc=C(()=>{"use strict";j();Wg={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
524
+ NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};Vg={name:"sleep",async execute(t,e){if(N(t))return k(Gg);if(t.length===0)return{stdout:"",stderr:`sleep: missing operand
525
+ `,exitCode:1};let n=0;for(let r of t){let s=qg(r);if(s===null)return{stdout:"",stderr:`sleep: invalid time interval '${r}'
526
+ `,exitCode:1};n+=s}return e.sleep?await e.sleep(n):await new Promise(r=>setTimeout(r,n)),{stdout:"",stderr:"",exitCode:0}}}});var jc={};_(jc,{timeoutCommand:()=>Qg});function Kg(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let n=parseFloat(e[1]);switch(e[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var Zg,Qg,zc=C(()=>{"use strict";j();Zg={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
523
527
 
524
528
  DURATION is a number with optional suffix:
525
529
  s - seconds (default)
526
530
  m - minutes
527
531
  h - hours
528
- d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]};jg={name:"timeout",async execute(t,e){if(I(t))return N(Wg);let n=!1,r=0;for(let d=0;d<t.length;d++){let p=t[d];if(p==="--preserve-status")n=!0,r=d+1;else if(p==="--foreground")r=d+1;else if(p==="-k"||p==="--kill-after")d++,r=d+1;else if(p.startsWith("--kill-after="))r=d+1;else if(p==="-s"||p==="--signal")d++,r=d+1;else if(p.startsWith("--signal="))r=d+1;else{if(p.startsWith("--")&&p!=="--")return D("timeout",p);if(p.startsWith("-")&&p.length>1&&p!=="--")if(p.startsWith("-k"))r=d+1;else if(p.startsWith("-s"))r=d+1;else return D("timeout",p);else{r=d;break}}}let s=t.slice(r);if(s.length===0)return{stdout:"",stderr:`timeout: missing operand
529
- `,exitCode:1};let i=s[0],o=Ug(i);if(o===null)return{stdout:"",stderr:`timeout: invalid time interval '${i}'
532
+ d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]};Qg={name:"timeout",async execute(t,e){if(N(t))return k(Zg);let n=!1,r=0;for(let d=0;d<t.length;d++){let p=t[d];if(p==="--preserve-status")n=!0,r=d+1;else if(p==="--foreground")r=d+1;else if(p==="-k"||p==="--kill-after")d++,r=d+1;else if(p.startsWith("--kill-after="))r=d+1;else if(p==="-s"||p==="--signal")d++,r=d+1;else if(p.startsWith("--signal="))r=d+1;else{if(p.startsWith("--")&&p!=="--")return L("timeout",p);if(p.startsWith("-")&&p.length>1&&p!=="--")if(p.startsWith("-k"))r=d+1;else if(p.startsWith("-s"))r=d+1;else return L("timeout",p);else{r=d;break}}}let s=t.slice(r);if(s.length===0)return{stdout:"",stderr:`timeout: missing operand
533
+ `,exitCode:1};let i=s[0],o=Kg(i);if(o===null)return{stdout:"",stderr:`timeout: invalid time interval '${i}'
530
534
  `,exitCode:1};let a=s.slice(1);if(a.length===0)return{stdout:"",stderr:`timeout: missing operand
531
535
  `,exitCode:1};if(!e.exec)return{stdout:"",stderr:`timeout: exec not available
532
- `,exitCode:1};let l=a.map(d=>d.includes(" ")||d.includes(" ")?`'${d.replace(/'/g,"'\\''")}'`:d).join(" "),c=new Promise(d=>{setTimeout(()=>d({timedOut:!0}),o)}),u=e.exec(l,{cwd:e.cwd}).then(d=>({timedOut:!1,result:d})),f=await Promise.race([c,u]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}}});var Wc={};L(Wc,{seqCommand:()=>zg});var zg,Uc=C(()=>{"use strict";zg={name:"seq",async execute(t){let e=`
536
+ `,exitCode:1};let l=a.map(d=>d.includes(" ")||d.includes(" ")?`'${d.replace(/'/g,"'\\''")}'`:d).join(" "),c=new Promise(d=>{setTimeout(()=>d({timedOut:!0}),o)}),u=e.exec(l,{cwd:e.cwd}).then(d=>({timedOut:!1,result:d})),f=await Promise.race([c,u]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}}});var Hc={};_(Hc,{seqCommand:()=>Xg});var Xg,Gc=C(()=>{"use strict";Xg={name:"seq",async execute(t){let e=`
533
537
  `,n=!1,r=[],s=0;for(;s<t.length;){let h=t[s];if(h==="-s"&&s+1<t.length){e=t[s+1],s+=2;continue}if(h==="-w"){n=!0,s++;continue}if(h==="--"){s++;break}if(h.startsWith("-")&&h!=="-"){if(h.startsWith("-s")&&h.length>2){e=h.slice(2),s++;continue}if((h==="-ws"||h==="-sw")&&(n=!0,s+1<t.length)){e=t[s+1],s+=2;continue}}r.push(h),s++}for(;s<t.length;)r.push(t[s]),s++;if(r.length===0)return{stdout:"",stderr:`seq: missing operand
534
538
  `,exitCode:1};let i=1,o=1,a;if(r.length===1?a=parseFloat(r[0]):r.length===2?(i=parseFloat(r[0]),a=parseFloat(r[1])):(i=parseFloat(r[0]),o=parseFloat(r[1]),a=parseFloat(r[2])),Number.isNaN(i)||Number.isNaN(o)||Number.isNaN(a))return{stdout:"",stderr:`seq: invalid floating point argument: '${r.find(m=>Number.isNaN(parseFloat(m)))}'
535
539
  `,exitCode:1};if(o===0)return{stdout:"",stderr:`seq: invalid Zero increment value: '0'
536
- `,exitCode:1};let l=[],c=h=>{let m=String(h),g=m.indexOf(".");return g===-1?0:m.length-g-1},u=Math.max(c(i),c(o),c(a)),f=1e5,d=0;if(o>0)for(let h=i;h<=a+1e-10&&!(d++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));else for(let h=i;h>=a-1e-10&&!(d++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));if(n&&l.length>0){let h=Math.max(...l.map(m=>m.replace("-","").length));for(let m=0;m<l.length;m++){let g=l[m].startsWith("-"),b=(g?l[m].slice(1):l[m]).padStart(h,"0");l[m]=g?`-${b}`:b}}let p=l.join(e);return{stdout:p?`${p}
537
- `:"",stderr:"",exitCode:0}}}});var jc={};L(jc,{exprCommand:()=>Hg});function Gg(t){if(t.length===1)return t[0];let e=0;function n(){let c=r();for(;e<t.length&&t[e]==="|";){e++;let u=r();if(c!=="0"&&c!=="")return c;c=u}return c}function r(){let c=s();for(;e<t.length&&t[e]==="&";){e++;let u=s();(c==="0"||c===""||u==="0"||u==="")&&(c="0")}return c}function s(){let c=i();for(;e<t.length;){let u=t[e];if(["=","!=","<",">","<=",">="].includes(u)){e++;let f=i(),d=parseInt(c,10),p=parseInt(f,10),h=!Number.isNaN(d)&&!Number.isNaN(p),m;u==="="?m=h?d===p:c===f:u==="!="?m=h?d!==p:c!==f:u==="<"?m=h?d<p:c<f:u===">"?m=h?d>p:c>f:u==="<="?m=h?d<=p:c<=f:m=h?d>=p:c>=f,c=m?"1":"0"}else break}return c}function i(){let c=o();for(;e<t.length;){let u=t[e];if(u==="+"||u==="-"){e++;let f=o(),d=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(d)||Number.isNaN(p))throw new Error("non-integer argument");c=String(u==="+"?d+p:d-p)}else break}return c}function o(){let c=a();for(;e<t.length;){let u=t[e];if(u==="*"||u==="/"||u==="%"){e++;let f=a(),d=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(d)||Number.isNaN(p))throw new Error("non-integer argument");if((u==="/"||u==="%")&&p===0)throw new Error("division by zero");u==="*"?c=String(d*p):u==="/"?c=String(Math.trunc(d/p)):c=String(d%p)}else break}return c}function a(){let c=l();for(;e<t.length&&t[e]===":";){e++;let u=l(),f=new RegExp(`^${u}`),d=c.match(f);d?c=d[1]!==void 0?d[1]:String(d[0].length):c="0"}return c}function l(){if(e>=t.length)throw new Error("syntax error");let c=t[e];if(c==="match"){e++;let u=l(),f=l(),d=new RegExp(f),p=u.match(d);return p?p[1]!==void 0?p[1]:String(p[0].length):"0"}if(c==="substr"){e++;let u=l(),f=parseInt(l(),10),d=parseInt(l(),10);if(Number.isNaN(f)||Number.isNaN(d))throw new Error("non-integer argument");return u.substring(f-1,f-1+d)}if(c==="index"){e++;let u=l(),f=l();for(let d=0;d<u.length;d++)if(f.includes(u[d]))return String(d+1);return"0"}if(c==="length"){e++;let u=l();return String(u.length)}if(c==="("){e++;let u=n();if(e>=t.length||t[e]!==")")throw new Error("syntax error");return e++,u}return e++,c}return n()}var Hg,zc=C(()=>{"use strict";Hg={name:"expr",async execute(t,e){if(t.length===0)return{stdout:"",stderr:`expr: missing operand
538
- `,exitCode:2};try{let n=Gg(t),r=n==="0"||n===""?1:0;return{stdout:`${n}
540
+ `,exitCode:1};let l=[],c=h=>{let m=String(h),g=m.indexOf(".");return g===-1?0:m.length-g-1},u=Math.max(c(i),c(o),c(a)),f=1e5,d=0;if(o>0)for(let h=i;h<=a+1e-10&&!(d++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));else for(let h=i;h>=a-1e-10&&!(d++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));if(n&&l.length>0){let h=Math.max(...l.map(m=>m.replace("-","").length));for(let m=0;m<l.length;m++){let g=l[m].startsWith("-"),w=(g?l[m].slice(1):l[m]).padStart(h,"0");l[m]=g?`-${w}`:w}}let p=l.join(e);return{stdout:p?`${p}
541
+ `:"",stderr:"",exitCode:0}}}});var qc={};_(qc,{exprCommand:()=>Jg});function Yg(t){if(t.length===1)return t[0];let e=0;function n(){let c=r();for(;e<t.length&&t[e]==="|";){e++;let u=r();if(c!=="0"&&c!=="")return c;c=u}return c}function r(){let c=s();for(;e<t.length&&t[e]==="&";){e++;let u=s();(c==="0"||c===""||u==="0"||u==="")&&(c="0")}return c}function s(){let c=i();for(;e<t.length;){let u=t[e];if(["=","!=","<",">","<=",">="].includes(u)){e++;let f=i(),d=parseInt(c,10),p=parseInt(f,10),h=!Number.isNaN(d)&&!Number.isNaN(p),m;u==="="?m=h?d===p:c===f:u==="!="?m=h?d!==p:c!==f:u==="<"?m=h?d<p:c<f:u===">"?m=h?d>p:c>f:u==="<="?m=h?d<=p:c<=f:m=h?d>=p:c>=f,c=m?"1":"0"}else break}return c}function i(){let c=o();for(;e<t.length;){let u=t[e];if(u==="+"||u==="-"){e++;let f=o(),d=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(d)||Number.isNaN(p))throw new Error("non-integer argument");c=String(u==="+"?d+p:d-p)}else break}return c}function o(){let c=a();for(;e<t.length;){let u=t[e];if(u==="*"||u==="/"||u==="%"){e++;let f=a(),d=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(d)||Number.isNaN(p))throw new Error("non-integer argument");if((u==="/"||u==="%")&&p===0)throw new Error("division by zero");u==="*"?c=String(d*p):u==="/"?c=String(Math.trunc(d/p)):c=String(d%p)}else break}return c}function a(){let c=l();for(;e<t.length&&t[e]===":";){e++;let u=l(),f=new RegExp(`^${u}`),d=c.match(f);d?c=d[1]!==void 0?d[1]:String(d[0].length):c="0"}return c}function l(){if(e>=t.length)throw new Error("syntax error");let c=t[e];if(c==="match"){e++;let u=l(),f=l(),d=new RegExp(f),p=u.match(d);return p?p[1]!==void 0?p[1]:String(p[0].length):"0"}if(c==="substr"){e++;let u=l(),f=parseInt(l(),10),d=parseInt(l(),10);if(Number.isNaN(f)||Number.isNaN(d))throw new Error("non-integer argument");return u.substring(f-1,f-1+d)}if(c==="index"){e++;let u=l(),f=l();for(let d=0;d<u.length;d++)if(f.includes(u[d]))return String(d+1);return"0"}if(c==="length"){e++;let u=l();return String(u.length)}if(c==="("){e++;let u=n();if(e>=t.length||t[e]!==")")throw new Error("syntax error");return e++,u}return e++,c}return n()}var Jg,Vc=C(()=>{"use strict";Jg={name:"expr",async execute(t,e){if(t.length===0)return{stdout:"",stderr:`expr: missing operand
542
+ `,exitCode:2};try{let n=Yg(t),r=n==="0"||n===""?1:0;return{stdout:`${n}
539
543
  `,stderr:"",exitCode:r}}catch(n){return{stdout:"",stderr:`expr: ${n.message}
540
- `,exitCode:2}}}}});function Vg(t){function e(p,h){return p<<h|p>>>32-h}let n=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),r=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=t.length*8,i=(t.length%64<56?56:120)-t.length%64,o=new Uint8Array(t.length+i+8);o.set(t),o[t.length]=128;let a=new DataView(o.buffer);a.setUint32(o.length-8,s>>>0,!0),a.setUint32(o.length-4,Math.floor(s/4294967296),!0);let l=1732584193,c=4023233417,u=2562383102,f=271733878;for(let p=0;p<o.length;p+=64){let h=new Uint32Array(16);for(let E=0;E<16;E++)h[E]=a.getUint32(p+E*4,!0);let m=l,g=c,w=u,b=f;for(let E=0;E<64;E++){let S,R;E<16?(S=g&w|~g&b,R=E):E<32?(S=b&g|~b&w,R=(5*E+1)%16):E<48?(S=g^w^b,R=(3*E+5)%16):(S=w^(g|~b),R=7*E%16),S=S+m+n[E]+h[R]>>>0,m=b,b=w,w=g,g=g+e(S,r[E])>>>0}l=l+m>>>0,c=c+g>>>0,u=u+w>>>0,f=f+b>>>0}let d=new Uint8Array(16);return new DataView(d.buffer).setUint32(0,l,!0),new DataView(d.buffer).setUint32(4,c,!0),new DataView(d.buffer).setUint32(8,u,!0),new DataView(d.buffer).setUint32(12,f,!0),Array.from(d).map(p=>p.toString(16).padStart(2,"0")).join("")}async function Hc(t,e){if(t==="md5")return Vg(e);let n=await globalThis.crypto.subtle.digest(qg[t],new Uint8Array(e).buffer);return Array.from(new Uint8Array(n)).map(r=>r.toString(16).padStart(2,"0")).join("")}function nn(t,e,n){let r={name:t,summary:n,usage:`${t} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:t,async execute(s,i){if(I(s))return N(r);let o=!1,a=[];for(let f of s)if(f==="-c"||f==="--check")o=!0;else if(!(f==="-b"||f==="-t"||f==="--binary"||f==="--text")){if(f.startsWith("-")&&f!=="-")return D(t,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return Uint8Array.from(i.stdin,d=>d.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,d="";for(let p of a){let h=p==="-"?i.stdin:await i.fs.readFile(i.fs.resolvePath(i.cwd,p)).catch(()=>null);if(h===null)return{stdout:"",stderr:`${t}: ${p}: No such file or directory
544
+ `,exitCode:2}}}}});function ty(t){function e(p,h){return p<<h|p>>>32-h}let n=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),r=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=t.length*8,i=(t.length%64<56?56:120)-t.length%64,o=new Uint8Array(t.length+i+8);o.set(t),o[t.length]=128;let a=new DataView(o.buffer);a.setUint32(o.length-8,s>>>0,!0),a.setUint32(o.length-4,Math.floor(s/4294967296),!0);let l=1732584193,c=4023233417,u=2562383102,f=271733878;for(let p=0;p<o.length;p+=64){let h=new Uint32Array(16);for(let E=0;E<16;E++)h[E]=a.getUint32(p+E*4,!0);let m=l,g=c,b=u,w=f;for(let E=0;E<64;E++){let S,R;E<16?(S=g&b|~g&w,R=E):E<32?(S=w&g|~w&b,R=(5*E+1)%16):E<48?(S=g^b^w,R=(3*E+5)%16):(S=b^(g|~w),R=7*E%16),S=S+m+n[E]+h[R]>>>0,m=w,w=b,b=g,g=g+e(S,r[E])>>>0}l=l+m>>>0,c=c+g>>>0,u=u+b>>>0,f=f+w>>>0}let d=new Uint8Array(16);return new DataView(d.buffer).setUint32(0,l,!0),new DataView(d.buffer).setUint32(4,c,!0),new DataView(d.buffer).setUint32(8,u,!0),new DataView(d.buffer).setUint32(12,f,!0),Array.from(d).map(p=>p.toString(16).padStart(2,"0")).join("")}async function Zc(t,e){if(t==="md5")return ty(e);let n=await globalThis.crypto.subtle.digest(ey[t],new Uint8Array(e).buffer);return Array.from(new Uint8Array(n)).map(r=>r.toString(16).padStart(2,"0")).join("")}function rn(t,e,n){let r={name:t,summary:n,usage:`${t} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:t,async execute(s,i){if(N(s))return k(r);let o=!1,a=[];for(let f of s)if(f==="-c"||f==="--check")o=!0;else if(!(f==="-b"||f==="-t"||f==="--binary"||f==="--text")){if(f.startsWith("-")&&f!=="-")return L(t,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return Uint8Array.from(i.stdin,d=>d.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,d="";for(let p of a){let h=p==="-"?i.stdin:await i.fs.readFile(i.fs.resolvePath(i.cwd,p)).catch(()=>null);if(h===null)return{stdout:"",stderr:`${t}: ${p}: No such file or directory
541
545
  `,exitCode:1};for(let m of h.split(`
542
- `)){let g=m.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!g)continue;let[,w,b]=g,E=await l(b);if(E===null){d+=`${b}: FAILED open or read
543
- `,f++;continue}let S=await Hc(e,E)===w.toLowerCase();d+=`${b}: ${S?"OK":"FAILED"}
546
+ `)){let g=m.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!g)continue;let[,b,w]=g,E=await l(w);if(E===null){d+=`${w}: FAILED open or read
547
+ `,f++;continue}let S=await Zc(e,E)===b.toLowerCase();d+=`${w}: ${S?"OK":"FAILED"}
544
548
  `,S||f++}}return f>0&&(d+=`${t}: WARNING: ${f} computed checksum${f>1?"s":""} did NOT match
545
549
  `),{stdout:d,stderr:"",exitCode:f>0?1:0}}let c="",u=0;for(let f of a){let d=await l(f);if(d===null){c+=`${t}: ${f}: No such file or directory
546
- `,u=1;continue}c+=`${await Hc(e,d)} ${f}
547
- `}return{stdout:c,stderr:"",exitCode:u}}}}var qg,xr=C(()=>{"use strict";j();qg={sha1:"SHA-1",sha256:"SHA-256"}});var Gc={};L(Gc,{md5sumCommand:()=>Zg});var Zg,qc=C(()=>{"use strict";xr();Zg=nn("md5sum","md5","compute MD5 message digest")});var Vc={};L(Vc,{sha1sumCommand:()=>Kg});var Kg,Zc=C(()=>{"use strict";xr();Kg=nn("sha1sum","sha1","compute SHA1 message digest")});var Kc={};L(Kc,{sha256sumCommand:()=>Qg});var Qg,Qc=C(()=>{"use strict";xr();Qg=nn("sha256sum","sha256","compute SHA256 message digest")});var Xc=qn(Hs=>{Hs.read=function(t,e,n,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,c=l>>1,u=-7,f=n?s-1:0,d=n?-1:1,p=t[e+f];for(f+=d,i=p&(1<<-u)-1,p>>=-u,u+=a;u>0;i=i*256+t[e+f],f+=d,u-=8);for(o=i&(1<<-u)-1,i>>=-u,u+=r;u>0;o=o*256+t[e+f],f+=d,u-=8);if(i===0)i=1-c;else{if(i===l)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-c}return(p?-1:1)*o*Math.pow(2,i-r)};Hs.write=function(t,e,n,r,s,i){var o,a,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,d=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,h=r?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?e+=d/l:e+=d*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(e*l-1)*Math.pow(2,s),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;t[n+p]=a&255,p+=h,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;t[n+p]=o&255,p+=h,o/=256,c-=8);t[n+p-h]|=m*128}});function Jc(t,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(t):Jg(t);case"utf-16le":return Yg(t);case"ascii":return ey(t);case"latin1":case"iso-8859-1":return ty(t);case"windows-1252":return ny(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function Jg(t){let e="",n=0;for(;n<t.length;){let r=t[n++];if(r<128)e+=String.fromCharCode(r);else if(r<224){let s=t[n++]&63;e+=String.fromCharCode((r&31)<<6|s)}else if(r<240){let s=t[n++]&63,i=t[n++]&63;e+=String.fromCharCode((r&15)<<12|s<<6|i)}else{let s=t[n++]&63,i=t[n++]&63,o=t[n++]&63,a=(r&7)<<18|s<<12|i<<6|o;a-=65536,e+=String.fromCharCode(55296+(a>>10&1023),56320+(a&1023))}}return e}function Yg(t){let e="";for(let n=0;n<t.length;n+=2)e+=String.fromCharCode(t[n]|t[n+1]<<8);return e}function ey(t){return String.fromCharCode(...t.map(e=>e&127))}function ty(t){return String.fromCharCode(...t)}function ny(t){let e="";for(let n of t)n>=128&&n<=159&&Gs[n]?e+=Gs[n]:e+=String.fromCharCode(n);return e}var Gs,Xg,Yc=C(()=>{Gs={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},Xg={};for(let[t,e]of Object.entries(Gs))Xg[e]=Number.parseInt(t)});function We(t){return new DataView(t.buffer,t.byteOffset)}var eu,tu,ge,rn,Ee,nu,ru,su,Ue,Pn=C(()=>{eu=oo(Xc(),1);Yc();tu={len:1,get(t,e){return We(t).getUint8(e)},put(t,e,n){return We(t).setUint8(e,n),e+1}},ge={len:2,get(t,e){return We(t).getUint16(e,!0)},put(t,e,n){return We(t).setUint16(e,n,!0),e+2}},rn={len:2,get(t,e){return We(t).getUint16(e)},put(t,e,n){return We(t).setUint16(e,n),e+2}},Ee={len:4,get(t,e){return We(t).getUint32(e,!0)},put(t,e,n){return We(t).setUint32(e,n,!0),e+4}},nu={len:4,get(t,e){return We(t).getUint32(e)},put(t,e,n){return We(t).setUint32(e,n),e+4}},ru={len:4,get(t,e){return We(t).getInt32(e)},put(t,e,n){return We(t).setInt32(e,n),e+4}},su={len:8,get(t,e){return We(t).getBigUint64(e,!0)},put(t,e,n){return We(t).setBigUint64(e,n,!0),e+8}},Ue=class{constructor(e,n){this.len=e,this.encoding=n}get(e,n=0){let r=e.subarray(n,n+this.len);return Jc(r,this.encoding)}}});var sy,de,Tt,Fn=C(()=>{sy="End-Of-Stream",de=class extends Error{constructor(){super(sy),this.name="EndOfStreamError"}},Tt=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}});var iu=C(()=>{});var Ot,wr=C(()=>{Fn();Ot=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,n=!1){let r=await this.read(e,n);return this.peekQueue.push(e.subarray(0,r)),r}async read(e,n=!1){if(e.length===0)return 0;let r=this.readFromPeekBuffer(e);if(this.endOfStream||(r+=await this.readRemainderFromStream(e.subarray(r),n)),r===0&&!n)throw new de;return r}readFromPeekBuffer(e){let n=e.length,r=0;for(;this.peekQueue.length>0&&n>0;){let s=this.peekQueue.pop();if(!s)throw new Error("peekData should be defined");let i=Math.min(s.length,n);e.set(s.subarray(0,i),r),r+=i,n-=i,i<s.length&&this.peekQueue.push(s.subarray(i))}return r}async readRemainderFromStream(e,n){let r=0;for(;r<e.length&&!this.endOfStream;){if(this.interrupted)throw new Tt;let s=await this.readFromStream(e.subarray(r),n);if(s===0)break;r+=s}if(!n&&r<e.length)throw new de;return r}}});var ou=C(()=>{Fn();iu();wr()});var br,au=C(()=>{wr();br=class extends Ot{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var Tn,qs=C(()=>{au();Tn=class extends br{async readFromStream(e,n){if(e.length===0)return 0;let r=await this.reader.read(new Uint8Array(e.length),{min:n?void 0:e.length});return r.done&&(this.endOfStream=r.done),r.value?(e.set(r.value),r.value.length):0}}});var sn,Vs=C(()=>{Fn();wr();sn=class extends Ot{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,n){let r=Math.min(n.length,e.length);return e.set(n.subarray(0,r)),r<n.length?this.buffer=n.subarray(r):this.buffer=null,r}async readFromStream(e,n){if(e.length===0)return 0;let r=0;for(this.buffer&&(r+=this.writeChunk(e,this.buffer));r<e.length&&!this.endOfStream;){let s=await this.reader.read();if(s.done){this.endOfStream=!0;break}s.value&&(r+=this.writeChunk(e.subarray(r),s.value))}if(!n&&r===0&&this.endOfStream)throw new de;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function Zs(t){try{let e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new sn(e):new Tn(e)}catch(e){if(e instanceof TypeError)return new sn(t.getReader());throw e}}var lu=C(()=>{qs();Vs()});var Dt=C(()=>{Fn();ou();qs();Vs();lu()});var ut,On=C(()=>{Dt();ut=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,n=this.position){let r=new Uint8Array(e.len);if(await this.readBuffer(r,{position:n})<e.len)throw new de;return e.get(r,0)}async peekToken(e,n=this.position){let r=new Uint8Array(e.len);if(await this.peekBuffer(r,{position:n})<e.len)throw new de;return e.get(r,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new de;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new de;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let n=this.fileInfo.size-this.position;if(e>n)return this.position+=n,n}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,n){if(!this.supportsRandomAccess()&&n&&n.position!==void 0&&n.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...n}}abort(){return Promise.resolve()}}});var oy,Er,cu=C(()=>{On();Dt();oy=256e3,Er=class extends ut{constructor(e,n){super(n),this.streamReader=e,this.fileInfo=n?.fileInfo??{}}async readBuffer(e,n){let r=this.normalizeOptions(e,n),s=r.position-this.position;if(s>0)return await this.ignore(s),this.readBuffer(e,n);if(s<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(r.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,r.length),r.mayBeLess);if(this.position+=i,(!n||!n.mayBeLess)&&i<r.length)throw new de;return i}async peekBuffer(e,n){let r=this.normalizeOptions(e,n),s=0;if(r.position){let i=r.position-this.position;if(i>0){let o=new Uint8Array(r.length+i);return s=await this.peekBuffer(o,{mayBeLess:r.mayBeLess}),e.set(o.subarray(i)),s-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(r.length>0){try{s=await this.streamReader.peek(e.subarray(0,r.length),r.mayBeLess)}catch(i){if(n?.mayBeLess&&i instanceof de)return 0;throw i}if(!r.mayBeLess&&s<r.length)throw new de}return s}async ignore(e){let n=Math.min(oy,e),r=new Uint8Array(n),s=0;for(;s<e;){let i=e-s,o=await this.readBuffer(r,{length:Math.min(n,i)});if(o<0)return o;s+=o}return s}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}});var Sr,uu=C(()=>{Dt();On();Sr=class extends ut{constructor(e,n){super(n),this.uint8Array=e,this.fileInfo={...n?.fileInfo??{},size:e.length}}async readBuffer(e,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(e,n);return this.position+=r,r}async peekBuffer(e,n){let r=this.normalizeOptions(e,n),s=Math.min(this.uint8Array.length-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new de;return e.set(this.uint8Array.subarray(r.position,r.position+s)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});var Cr,fu=C(()=>{Dt();On();Cr=class extends ut{constructor(e,n){super(n),this.blob=e,this.fileInfo={...n?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(e,n);return this.position+=r,r}async peekBuffer(e,n){let r=this.normalizeOptions(e,n),s=Math.min(this.blob.size-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new de;let i=await this.blob.slice(r.position,r.position+s).arrayBuffer();return e.set(new Uint8Array(i)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});function du(t,e){let n=Zs(t),r=e??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new Er(n,r)}function pu(t,e){return new Sr(t,e)}function hu(t,e){return new Cr(t,e)}var mu=C(()=>{Dt();cu();uu();fu();Dt();On()});var yu=qn((US,gu)=>{var on=1e3,an=on*60,ln=an*60,Lt=ln*24,ly=Lt*7,cy=Lt*365.25;gu.exports=function(t,e){e=e||{};var n=typeof t;if(n==="string"&&t.length>0)return uy(t);if(n==="number"&&isFinite(t))return e.long?dy(t):fy(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function uy(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var n=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*cy;case"weeks":case"week":case"w":return n*ly;case"days":case"day":case"d":return n*Lt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ln;case"minutes":case"minute":case"mins":case"min":case"m":return n*an;case"seconds":case"second":case"secs":case"sec":case"s":return n*on;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function fy(t){var e=Math.abs(t);return e>=Lt?Math.round(t/Lt)+"d":e>=ln?Math.round(t/ln)+"h":e>=an?Math.round(t/an)+"m":e>=on?Math.round(t/on)+"s":t+"ms"}function dy(t){var e=Math.abs(t);return e>=Lt?Ar(t,e,Lt,"day"):e>=ln?Ar(t,e,ln,"hour"):e>=an?Ar(t,e,an,"minute"):e>=on?Ar(t,e,on,"second"):t+" ms"}function Ar(t,e,n,r){var s=e>=n*1.5;return Math.round(t/n)+" "+r+(s?"s":"")}});var wu=qn((jS,xu)=>{function py(t){n.debug=n,n.default=n,n.coerce=l,n.disable=o,n.enable=s,n.enabled=a,n.humanize=yu(),n.destroy=c,Object.keys(t).forEach(u=>{n[u]=t[u]}),n.names=[],n.skips=[],n.formatters={};function e(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=e;function n(u){let f,d=null,p,h;function m(...g){if(!m.enabled)return;let w=m,b=Number(new Date),E=b-(f||b);w.diff=E,w.prev=f,w.curr=b,f=b,g[0]=n.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let S=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(P,z)=>{if(P==="%%")return"%";S++;let W=n.formatters[z];if(typeof W=="function"){let X=g[S];P=W.call(w,X),g.splice(S,1),S--}return P}),n.formatArgs.call(w,g),(w.log||n.log).apply(w,g)}return m.namespace=u,m.useColors=n.useColors(),m.color=n.selectColor(u),m.extend=r,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==n.namespaces&&(p=n.namespaces,h=n.enabled(u)),h),set:g=>{d=g}}),typeof n.init=="function"&&n.init(m),m}function r(u,f){let d=n(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function s(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];let f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of f)d[0]==="-"?n.skips.push(d.slice(1)):n.names.push(d)}function i(u,f){let d=0,p=0,h=-1,m=0;for(;d<u.length;)if(p<f.length&&(f[p]===u[d]||f[p]==="*"))f[p]==="*"?(h=p,m=d,p++):(d++,p++);else if(h!==-1)p=h+1,m++,d=m;else return!1;for(;p<f.length&&f[p]==="*";)p++;return p===f.length}function o(){let u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function a(u){for(let f of n.skips)if(i(u,f))return!1;for(let f of n.names)if(i(u,f))return!0;return!1}function l(u){return u instanceof Error?u.stack||u.message:u}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}xu.exports=py});var bu=qn((je,kr)=>{je.formatArgs=my;je.save=gy;je.load=yy;je.useColors=hy;je.storage=xy();je.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();je.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function hy(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function my(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+kr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(n++,s==="%c"&&(r=n))}),t.splice(r,0,e)}je.log=console.debug||console.log||(()=>{});function gy(t){try{t?je.storage.setItem("debug",t):je.storage.removeItem("debug")}catch{}}function yy(){let t;try{t=je.storage.getItem("debug")||je.storage.getItem("DEBUG")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function xy(){try{return localStorage}catch{}}kr.exports=wu()(je);var{formatters:wy}=kr.exports;wy.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Mt,Ks,Eu,Su,Cu,Au=C(()=>{Pn();Mt={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Ks={get(t){return{signature:Ee.get(t,0),compressedSize:Ee.get(t,8),uncompressedSize:Ee.get(t,12)}},len:16},Eu={get(t){let e=ge.get(t,6);return{signature:Ee.get(t,0),minVersion:ge.get(t,4),dataDescriptor:!!(e&8),compressedMethod:ge.get(t,8),compressedSize:Ee.get(t,18),uncompressedSize:Ee.get(t,22),filenameLength:ge.get(t,26),extraFieldLength:ge.get(t,28),filename:null}},len:30},Su={get(t){return{signature:Ee.get(t,0),nrOfThisDisk:ge.get(t,4),nrOfThisDiskWithTheStart:ge.get(t,6),nrOfEntriesOnThisDisk:ge.get(t,8),nrOfEntriesOfSize:ge.get(t,10),sizeOfCd:Ee.get(t,12),offsetOfStartOfCd:Ee.get(t,16),zipFileCommentLength:ge.get(t,20)}},len:22},Cu={get(t){let e=ge.get(t,8);return{signature:Ee.get(t,0),minVersion:ge.get(t,6),dataDescriptor:!!(e&8),compressedMethod:ge.get(t,10),compressedSize:Ee.get(t,20),uncompressedSize:Ee.get(t,24),filenameLength:ge.get(t,28),extraFieldLength:ge.get(t,30),fileCommentLength:ge.get(t,32),relativeOffsetOfLocalHeader:Ee.get(t,42),filename:null}},len:46}});function Nu(t){let e=new Uint8Array(Ee.len);return Ee.put(e,0,t),e}function Ey(t,e){let n=t.length,r=e.length;if(r>n)return-1;for(let s=0;s<=n-r;s++){let i=!0;for(let o=0;o<r;o++)if(t[s+o]!==e[o]){i=!1;break}if(i)return s}return-1}function Sy(t){let e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}var ku,at,Qs,by,Nr,Dn,Iu=C(()=>{Pn();ku=oo(bu(),1);Au();at=(0,ku.default)("tokenizer:inflate"),Qs=256*1024,by=Nu(Mt.DataDescriptor),Nr=Nu(Mt.EndOfCentralDirectory),Dn=class t{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Qs)}async isZip(){return await this.peekSignature()===Mt.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Ee)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,n=Math.min(16*1024,e.fileInfo.size),r=this.syncBuffer.subarray(0,n);await this.tokenizer.readBuffer(r,{position:e.fileInfo.size-n});for(let s=r.length-4;s>=0;s--)if(r[s]===Nr[0]&&r[s+1]===Nr[1]&&r[s+2]===Nr[2]&&r[s+3]===Nr[3])return e.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){at("Cannot reading central-directory without random-read support");return}at("Reading central-directory...");let e=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){at("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(Su,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken(Cu);if(o.signature!==Mt.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Ue(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),at(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(e),s}this.tokenizer.setPosition(e)}async unzip(e){let n=await this.readCentralDirectory();if(n)return this.iterateOverCentralDirectory(n,e);let r=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=e(s);r=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=Qs;at("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===Qs;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=Ey(this.syncBuffer.subarray(0,l),by);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),a.push(f)}else await this.tokenizer.ignore(u)}at(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,Sy(a),i.handler)}else i.handler?(at(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(at(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(at(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(Ks)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Ks.len}`)}while(!r)}async iterateOverCentralDirectory(e,n){for(let r of e){let s=n(r);if(s.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(e,n,r){if(e.compressedMethod===0)return r(n);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);at(`Decompress filename=${e.filename}, compressed-size=${n.length}`);let s=await t.decompressDeflateRaw(n);return r(s)}static async decompressDeflateRaw(e){let n=new ReadableStream({start(i){i.enqueue(e),i.close()}}),r=new DecompressionStream("deflate-raw"),s=n.pipeThrough(r);try{let o=await new Response(s).arrayBuffer();return new Uint8Array(o)}catch(i){let o=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(Ee);if(e===Mt.LocalFileHeader){let n=await this.tokenizer.readToken(Eu);return n.filename=await this.tokenizer.readToken(new Ue(n.filenameLength,"utf-8")),n}if(e===Mt.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var Ln,vu=C(()=>{Ln=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(n){let r=new Uint8Array(1024),s=await e.readBuffer(r,{mayBeLess:!0});if(s===0){n.close();return}n.enqueue(r.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var $u=C(()=>{Iu();vu()});function Xs(t){let{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}var JS,YS,eC,Ru=C(()=>{JS={utf8:new globalThis.TextDecoder("utf8")},YS=new globalThis.TextEncoder,eC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"))});function Pu(t,e){if(e==="utf-16le"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s&255,s>>8&255)}return n}if(e==="utf-16be"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s>>8&255,s&255)}return n}return[...t].map(n=>n.charCodeAt(0))}function Fu(t,e=0){let n=Number.parseInt(new Ue(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let s=e;s<e+148;s++)r+=t[s];for(let s=e+156;s<e+512;s++)r+=t[s];return n===r}var Tu,Ou=C(()=>{Pn();Tu={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4}});var Du,Lu,Mu=C(()=>{Du=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],Lu=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"]});async function _u(t,e){return new ei(e).fromBuffer(t)}function Ys(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function lt(t,e,n){n={offset:0,...n};for(let[r,s]of e.entries())if(n.mask){if(s!==(n.mask[r]&t[r+n.offset]))return!1}else if(s!==t[r+n.offset])return!1;return!0}var Js,ei,cC,uC,Bu=C(()=>{Pn();mu();$u();Ru();Ou();Mu();Js=4100;ei=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let n=e.position;for(let r of this.detectors){let s=await r.detect(e);if(s)return s;if(n!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let n=e instanceof Uint8Array?e:new Uint8Array(e);if(n?.length>1)return this.fromTokenizer(pu(n,this.tokenizerOptions))}async fromBlob(e){let n=hu(e,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(e){let n=du(e,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(e,n){let{sampleSize:r=Js}=n,s,i,o=e.getReader({mode:"byob"});try{let{value:c,done:u}=await o.read(new Uint8Array(r));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof de))throw f;s=void 0}i=c}finally{o.releaseLock()}let a=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=e.pipeThrough(a);return l.fileType=s,l}check(e,n){return lt(this.buffer,e,n)}checkString(e,n){return this.check(Pu(e,n?.encoding),n)}detectConfident=async e=>{if(this.buffer=new Uint8Array(Js),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8])){let r=new Ln(e).inflate(),s=!0;try{let i;try{i=await this.fromStream(r)}catch{s=!1}if(i&&i.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{s&&await r.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);let n=await e.readToken(Tu);return e.position+n>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(n),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let n;return await new Dn(e).unzip(r=>{switch(r.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(s){let i=new TextDecoder("utf-8").decode(s).trim();n=Ys(i)},stop:!0};case"[Content_Types].xml":return{async handler(s){let i=new TextDecoder("utf-8").decode(s),o=i.indexOf('.main+xml"');if(o===-1){let a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";i.includes(`ContentType="${a}"`)&&(n=Ys(a))}else{i=i.slice(0,Math.max(0,o));let a=i.lastIndexOf('"'),l=i.slice(Math.max(0,a+1));n=Ys(l)}},stop:!0};default:return/classes\d*\.dex/.test(r.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(r=>{if(!(r instanceof de))throw r}),n??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let n=new Uint8Array(8);return await e.readBuffer(n),lt(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:lt(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:lt(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:lt(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:lt(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:lt(n,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let n=await this.readTiffHeader(!1);if(n)return n}if(this.check([77,77])){let n=await this.readTiffHeader(!0);if(n)return n}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function n(){let a=await e.peekNumber(tu),l=128,c=0;for(;(a&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await e.readBuffer(u),u}async function r(){let a=await n(),l=await n();l[0]^=128>>l.length-1;let c=Math.min(6,l.length),u=new DataView(a.buffer),f=new DataView(l.buffer,l.length-c,c);return{id:Xs(u),len:Xs(f)}}async function s(a){for(;a>0;){let l=await r();if(l.id===17026)return(await e.readToken(new Ue(l.len))).replaceAll(/\00.*$/g,"");await e.ignore(l.len),--a}}let i=await r();switch(await s(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let n=new Ue(4,"latin1").get(this.buffer,2);if(n.match("^d*")&&n>=1e3&&n<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new Ue(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
548
- `,"\r"," "," ","\0"].some(n=>this.checkString(n,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function n(){return{length:await e.readToken(ru),type:await e.readToken(new Ue(4,"latin1"))}}do{let r=await n();if(r.length<0)return;switch(r.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(r.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let n=new Ue(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(n){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return n.startsWith("3g")?n.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
549
- `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function n(){let r=new Uint8Array(16);return await e.readBuffer(r),{id:r,size:Number(await e.readToken(su))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let r=await n(),s=r.size-24;if(lt(r.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let i=new Uint8Array(16);if(s-=await e.readBuffer(i),lt(i,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(lt(i,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(s)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Ue(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let n=new DataView(this.buffer.buffer).getUint32(12,!0);if(n>12&&this.buffer.length>=n+16)try{let r=new TextDecoder().decode(this.buffer.subarray(16,n+16));if(JSON.parse(r).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Fu(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let n="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:n})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:n})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
550
- `,{offset:2,encoding:n})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(Js),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let n=0;n<=this.options.mpegOffsetTolerance;++n){let r=this.scanMpeg(n);if(r)return r}};async readTiffTag(e){let n=await this.tokenizer.readToken(e?rn:ge);switch(this.tokenizer.ignore(10),n){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let n=await this.tokenizer.readToken(e?rn:ge);for(let r=0;r<n;++r){let s=await this.readTiffTag(e);if(s)return s}}async readTiffHeader(e){let n=(e?rn:ge).get(this.buffer,2),r=(e?nu:Ee).get(this.buffer,4);if(n===42){if(r>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(r>=8){let i=(e?rn:ge).get(this.buffer,8),o=(e?rn:ge).get(this.buffer,10);if(i===28&&o===254||i===31&&o===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(r),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(n===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},cC=new Set(Du),uC=new Set(Lu)});var ju={};L(ju,{fileCommand:()=>vy});function Ay(t,e){if(Uu[t])return Uu[t];let[n,r]=e.split("/"),s=r?.split("+")[0]?.replace(/-/g," ")||t;switch(n){case"image":return`${s.toUpperCase()} image data`;case"audio":return`${s.toUpperCase()} audio`;case"video":return`${s.toUpperCase()} video`;case"font":return`${s} font`;case"model":return`${s} 3D model`;case"application":return r?.includes("zip")||r?.includes("compressed")?`${s} archive data`:r?.includes("executable")?`${s} executable`:`${t.toUpperCase()} data`;default:return`${t.toUpperCase()} data`}}function ky(t){let e=t.split("/").pop()||t;if(e.startsWith(".")&&!e.includes(".",1))return e;let n=e.lastIndexOf(".");return n===-1||n===0?"":e.slice(n).toLowerCase()}function Ny(t,e){if(t.startsWith("#!")){let l=t.split(`
550
+ `,u=1;continue}c+=`${await Zc(e,d)} ${f}
551
+ `}return{stdout:c,stderr:"",exitCode:u}}}}var ey,wr=C(()=>{"use strict";j();ey={sha1:"SHA-1",sha256:"SHA-256"}});var Kc={};_(Kc,{md5sumCommand:()=>ny});var ny,Qc=C(()=>{"use strict";wr();ny=rn("md5sum","md5","compute MD5 message digest")});var Xc={};_(Xc,{sha1sumCommand:()=>ry});var ry,Jc=C(()=>{"use strict";wr();ry=rn("sha1sum","sha1","compute SHA1 message digest")});var Yc={};_(Yc,{sha256sumCommand:()=>sy});var sy,eu=C(()=>{"use strict";wr();sy=rn("sha256sum","sha256","compute SHA256 message digest")});var tu=Zn(qs=>{qs.read=function(t,e,n,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,c=l>>1,u=-7,f=n?s-1:0,d=n?-1:1,p=t[e+f];for(f+=d,i=p&(1<<-u)-1,p>>=-u,u+=a;u>0;i=i*256+t[e+f],f+=d,u-=8);for(o=i&(1<<-u)-1,i>>=-u,u+=r;u>0;o=o*256+t[e+f],f+=d,u-=8);if(i===0)i=1-c;else{if(i===l)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-c}return(p?-1:1)*o*Math.pow(2,i-r)};qs.write=function(t,e,n,r,s,i){var o,a,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,d=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,h=r?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?e+=d/l:e+=d*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(e*l-1)*Math.pow(2,s),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;t[n+p]=a&255,p+=h,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;t[n+p]=o&255,p+=h,o/=256,c-=8);t[n+p-h]|=m*128}});function nu(t,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(t):oy(t);case"utf-16le":return ay(t);case"ascii":return ly(t);case"latin1":case"iso-8859-1":return cy(t);case"windows-1252":return uy(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function oy(t){let e="",n=0;for(;n<t.length;){let r=t[n++];if(r<128)e+=String.fromCharCode(r);else if(r<224){let s=t[n++]&63;e+=String.fromCharCode((r&31)<<6|s)}else if(r<240){let s=t[n++]&63,i=t[n++]&63;e+=String.fromCharCode((r&15)<<12|s<<6|i)}else{let s=t[n++]&63,i=t[n++]&63,o=t[n++]&63,a=(r&7)<<18|s<<12|i<<6|o;a-=65536,e+=String.fromCharCode(55296+(a>>10&1023),56320+(a&1023))}}return e}function ay(t){let e="";for(let n=0;n<t.length;n+=2)e+=String.fromCharCode(t[n]|t[n+1]<<8);return e}function ly(t){return String.fromCharCode(...t.map(e=>e&127))}function cy(t){return String.fromCharCode(...t)}function uy(t){let e="";for(let n of t)n>=128&&n<=159&&Vs[n]?e+=Vs[n]:e+=String.fromCharCode(n);return e}var Vs,iy,ru=C(()=>{Vs={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},iy={};for(let[t,e]of Object.entries(Vs))iy[e]=Number.parseInt(t)});function We(t){return new DataView(t.buffer,t.byteOffset)}var su,iu,ge,sn,Ee,ou,au,lu,Ue,Tn=C(()=>{su=lo(tu(),1);ru();iu={len:1,get(t,e){return We(t).getUint8(e)},put(t,e,n){return We(t).setUint8(e,n),e+1}},ge={len:2,get(t,e){return We(t).getUint16(e,!0)},put(t,e,n){return We(t).setUint16(e,n,!0),e+2}},sn={len:2,get(t,e){return We(t).getUint16(e)},put(t,e,n){return We(t).setUint16(e,n),e+2}},Ee={len:4,get(t,e){return We(t).getUint32(e,!0)},put(t,e,n){return We(t).setUint32(e,n,!0),e+4}},ou={len:4,get(t,e){return We(t).getUint32(e)},put(t,e,n){return We(t).setUint32(e,n),e+4}},au={len:4,get(t,e){return We(t).getInt32(e)},put(t,e,n){return We(t).setInt32(e,n),e+4}},lu={len:8,get(t,e){return We(t).getBigUint64(e,!0)},put(t,e,n){return We(t).setBigUint64(e,n,!0),e+8}},Ue=class{constructor(e,n){this.len=e,this.encoding=n}get(e,n=0){let r=e.subarray(n,n+this.len);return nu(r,this.encoding)}}});var dy,pe,Ot,On=C(()=>{dy="End-Of-Stream",pe=class extends Error{constructor(){super(dy),this.name="EndOfStreamError"}},Ot=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}});var cu=C(()=>{});var Dt,br=C(()=>{On();Dt=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,n=!1){let r=await this.read(e,n);return this.peekQueue.push(e.subarray(0,r)),r}async read(e,n=!1){if(e.length===0)return 0;let r=this.readFromPeekBuffer(e);if(this.endOfStream||(r+=await this.readRemainderFromStream(e.subarray(r),n)),r===0&&!n)throw new pe;return r}readFromPeekBuffer(e){let n=e.length,r=0;for(;this.peekQueue.length>0&&n>0;){let s=this.peekQueue.pop();if(!s)throw new Error("peekData should be defined");let i=Math.min(s.length,n);e.set(s.subarray(0,i),r),r+=i,n-=i,i<s.length&&this.peekQueue.push(s.subarray(i))}return r}async readRemainderFromStream(e,n){let r=0;for(;r<e.length&&!this.endOfStream;){if(this.interrupted)throw new Ot;let s=await this.readFromStream(e.subarray(r),n);if(s===0)break;r+=s}if(!n&&r<e.length)throw new pe;return r}}});var uu=C(()=>{On();cu();br()});var Er,fu=C(()=>{br();Er=class extends Dt{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var Dn,Zs=C(()=>{fu();Dn=class extends Er{async readFromStream(e,n){if(e.length===0)return 0;let r=await this.reader.read(new Uint8Array(e.length),{min:n?void 0:e.length});return r.done&&(this.endOfStream=r.done),r.value?(e.set(r.value),r.value.length):0}}});var on,Ks=C(()=>{On();br();on=class extends Dt{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,n){let r=Math.min(n.length,e.length);return e.set(n.subarray(0,r)),r<n.length?this.buffer=n.subarray(r):this.buffer=null,r}async readFromStream(e,n){if(e.length===0)return 0;let r=0;for(this.buffer&&(r+=this.writeChunk(e,this.buffer));r<e.length&&!this.endOfStream;){let s=await this.reader.read();if(s.done){this.endOfStream=!0;break}s.value&&(r+=this.writeChunk(e.subarray(r),s.value))}if(!n&&r===0&&this.endOfStream)throw new pe;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function Qs(t){try{let e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new on(e):new Dn(e)}catch(e){if(e instanceof TypeError)return new on(t.getReader());throw e}}var du=C(()=>{Zs();Ks()});var Lt=C(()=>{On();uu();Zs();Ks();du()});var ft,Ln=C(()=>{Lt();ft=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,n=this.position){let r=new Uint8Array(e.len);if(await this.readBuffer(r,{position:n})<e.len)throw new pe;return e.get(r,0)}async peekToken(e,n=this.position){let r=new Uint8Array(e.len);if(await this.peekBuffer(r,{position:n})<e.len)throw new pe;return e.get(r,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new pe;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new pe;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let n=this.fileInfo.size-this.position;if(e>n)return this.position+=n,n}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,n){if(!this.supportsRandomAccess()&&n&&n.position!==void 0&&n.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...n}}abort(){return Promise.resolve()}}});var hy,Sr,pu=C(()=>{Ln();Lt();hy=256e3,Sr=class extends ft{constructor(e,n){super(n),this.streamReader=e,this.fileInfo=n?.fileInfo??{}}async readBuffer(e,n){let r=this.normalizeOptions(e,n),s=r.position-this.position;if(s>0)return await this.ignore(s),this.readBuffer(e,n);if(s<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(r.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,r.length),r.mayBeLess);if(this.position+=i,(!n||!n.mayBeLess)&&i<r.length)throw new pe;return i}async peekBuffer(e,n){let r=this.normalizeOptions(e,n),s=0;if(r.position){let i=r.position-this.position;if(i>0){let o=new Uint8Array(r.length+i);return s=await this.peekBuffer(o,{mayBeLess:r.mayBeLess}),e.set(o.subarray(i)),s-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(r.length>0){try{s=await this.streamReader.peek(e.subarray(0,r.length),r.mayBeLess)}catch(i){if(n?.mayBeLess&&i instanceof pe)return 0;throw i}if(!r.mayBeLess&&s<r.length)throw new pe}return s}async ignore(e){let n=Math.min(hy,e),r=new Uint8Array(n),s=0;for(;s<e;){let i=e-s,o=await this.readBuffer(r,{length:Math.min(n,i)});if(o<0)return o;s+=o}return s}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}});var Cr,hu=C(()=>{Lt();Ln();Cr=class extends ft{constructor(e,n){super(n),this.uint8Array=e,this.fileInfo={...n?.fileInfo??{},size:e.length}}async readBuffer(e,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(e,n);return this.position+=r,r}async peekBuffer(e,n){let r=this.normalizeOptions(e,n),s=Math.min(this.uint8Array.length-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new pe;return e.set(this.uint8Array.subarray(r.position,r.position+s)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});var Ar,mu=C(()=>{Lt();Ln();Ar=class extends ft{constructor(e,n){super(n),this.blob=e,this.fileInfo={...n?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(e,n);return this.position+=r,r}async peekBuffer(e,n){let r=this.normalizeOptions(e,n),s=Math.min(this.blob.size-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new pe;let i=await this.blob.slice(r.position,r.position+s).arrayBuffer();return e.set(new Uint8Array(i)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});function gu(t,e){let n=Qs(t),r=e??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new Sr(n,r)}function yu(t,e){return new Cr(t,e)}function xu(t,e){return new Ar(t,e)}var wu=C(()=>{Lt();pu();hu();mu();Lt();Ln()});var Eu=Zn((ZS,bu)=>{var an=1e3,ln=an*60,cn=ln*60,Mt=cn*24,gy=Mt*7,yy=Mt*365.25;bu.exports=function(t,e){e=e||{};var n=typeof t;if(n==="string"&&t.length>0)return xy(t);if(n==="number"&&isFinite(t))return e.long?by(t):wy(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function xy(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var n=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*yy;case"weeks":case"week":case"w":return n*gy;case"days":case"day":case"d":return n*Mt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*cn;case"minutes":case"minute":case"mins":case"min":case"m":return n*ln;case"seconds":case"second":case"secs":case"sec":case"s":return n*an;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function wy(t){var e=Math.abs(t);return e>=Mt?Math.round(t/Mt)+"d":e>=cn?Math.round(t/cn)+"h":e>=ln?Math.round(t/ln)+"m":e>=an?Math.round(t/an)+"s":t+"ms"}function by(t){var e=Math.abs(t);return e>=Mt?kr(t,e,Mt,"day"):e>=cn?kr(t,e,cn,"hour"):e>=ln?kr(t,e,ln,"minute"):e>=an?kr(t,e,an,"second"):t+" ms"}function kr(t,e,n,r){var s=e>=n*1.5;return Math.round(t/n)+" "+r+(s?"s":"")}});var Cu=Zn((KS,Su)=>{function Ey(t){n.debug=n,n.default=n,n.coerce=l,n.disable=o,n.enable=s,n.enabled=a,n.humanize=Eu(),n.destroy=c,Object.keys(t).forEach(u=>{n[u]=t[u]}),n.names=[],n.skips=[],n.formatters={};function e(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=e;function n(u){let f,d=null,p,h;function m(...g){if(!m.enabled)return;let b=m,w=Number(new Date),E=w-(f||w);b.diff=E,b.prev=f,b.curr=w,f=w,g[0]=n.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let S=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(F,z)=>{if(F==="%%")return"%";S++;let W=n.formatters[z];if(typeof W=="function"){let J=g[S];F=W.call(b,J),g.splice(S,1),S--}return F}),n.formatArgs.call(b,g),(b.log||n.log).apply(b,g)}return m.namespace=u,m.useColors=n.useColors(),m.color=n.selectColor(u),m.extend=r,m.destroy=n.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==n.namespaces&&(p=n.namespaces,h=n.enabled(u)),h),set:g=>{d=g}}),typeof n.init=="function"&&n.init(m),m}function r(u,f){let d=n(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function s(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];let f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of f)d[0]==="-"?n.skips.push(d.slice(1)):n.names.push(d)}function i(u,f){let d=0,p=0,h=-1,m=0;for(;d<u.length;)if(p<f.length&&(f[p]===u[d]||f[p]==="*"))f[p]==="*"?(h=p,m=d,p++):(d++,p++);else if(h!==-1)p=h+1,m++,d=m;else return!1;for(;p<f.length&&f[p]==="*";)p++;return p===f.length}function o(){let u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function a(u){for(let f of n.skips)if(i(u,f))return!1;for(let f of n.names)if(i(u,f))return!0;return!1}function l(u){return u instanceof Error?u.stack||u.message:u}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}Su.exports=Ey});var Au=Zn((je,Nr)=>{je.formatArgs=Cy;je.save=Ay;je.load=ky;je.useColors=Sy;je.storage=Ny();je.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();je.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Sy(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Cy(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Nr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(n++,s==="%c"&&(r=n))}),t.splice(r,0,e)}je.log=console.debug||console.log||(()=>{});function Ay(t){try{t?je.storage.setItem("debug",t):je.storage.removeItem("debug")}catch{}}function ky(){let t;try{t=je.storage.getItem("debug")||je.storage.getItem("DEBUG")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Ny(){try{return localStorage}catch{}}Nr.exports=Cu()(je);var{formatters:Iy}=Nr.exports;Iy.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var _t,Xs,ku,Nu,Iu,vu=C(()=>{Tn();_t={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Xs={get(t){return{signature:Ee.get(t,0),compressedSize:Ee.get(t,8),uncompressedSize:Ee.get(t,12)}},len:16},ku={get(t){let e=ge.get(t,6);return{signature:Ee.get(t,0),minVersion:ge.get(t,4),dataDescriptor:!!(e&8),compressedMethod:ge.get(t,8),compressedSize:Ee.get(t,18),uncompressedSize:Ee.get(t,22),filenameLength:ge.get(t,26),extraFieldLength:ge.get(t,28),filename:null}},len:30},Nu={get(t){return{signature:Ee.get(t,0),nrOfThisDisk:ge.get(t,4),nrOfThisDiskWithTheStart:ge.get(t,6),nrOfEntriesOnThisDisk:ge.get(t,8),nrOfEntriesOfSize:ge.get(t,10),sizeOfCd:Ee.get(t,12),offsetOfStartOfCd:Ee.get(t,16),zipFileCommentLength:ge.get(t,20)}},len:22},Iu={get(t){let e=ge.get(t,8);return{signature:Ee.get(t,0),minVersion:ge.get(t,6),dataDescriptor:!!(e&8),compressedMethod:ge.get(t,10),compressedSize:Ee.get(t,20),uncompressedSize:Ee.get(t,24),filenameLength:ge.get(t,28),extraFieldLength:ge.get(t,30),fileCommentLength:ge.get(t,32),relativeOffsetOfLocalHeader:Ee.get(t,42),filename:null}},len:46}});function Ru(t){let e=new Uint8Array(Ee.len);return Ee.put(e,0,t),e}function $y(t,e){let n=t.length,r=e.length;if(r>n)return-1;for(let s=0;s<=n-r;s++){let i=!0;for(let o=0;o<r;o++)if(t[s+o]!==e[o]){i=!1;break}if(i)return s}return-1}function Ry(t){let e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}var $u,lt,Js,vy,Ir,Mn,Fu=C(()=>{Tn();$u=lo(Au(),1);vu();lt=(0,$u.default)("tokenizer:inflate"),Js=256*1024,vy=Ru(_t.DataDescriptor),Ir=Ru(_t.EndOfCentralDirectory),Mn=class t{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Js)}async isZip(){return await this.peekSignature()===_t.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Ee)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,n=Math.min(16*1024,e.fileInfo.size),r=this.syncBuffer.subarray(0,n);await this.tokenizer.readBuffer(r,{position:e.fileInfo.size-n});for(let s=r.length-4;s>=0;s--)if(r[s]===Ir[0]&&r[s+1]===Ir[1]&&r[s+2]===Ir[2]&&r[s+3]===Ir[3])return e.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){lt("Cannot reading central-directory without random-read support");return}lt("Reading central-directory...");let e=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){lt("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(Nu,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken(Iu);if(o.signature!==_t.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Ue(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),lt(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(e),s}this.tokenizer.setPosition(e)}async unzip(e){let n=await this.readCentralDirectory();if(n)return this.iterateOverCentralDirectory(n,e);let r=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=e(s);r=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=Js;lt("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===Js;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=$y(this.syncBuffer.subarray(0,l),vy);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),a.push(f)}else await this.tokenizer.ignore(u)}lt(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,Ry(a),i.handler)}else i.handler?(lt(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(lt(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(lt(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(Xs)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Xs.len}`)}while(!r)}async iterateOverCentralDirectory(e,n){for(let r of e){let s=n(r);if(s.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(e,n,r){if(e.compressedMethod===0)return r(n);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);lt(`Decompress filename=${e.filename}, compressed-size=${n.length}`);let s=await t.decompressDeflateRaw(n);return r(s)}static async decompressDeflateRaw(e){let n=new ReadableStream({start(i){i.enqueue(e),i.close()}}),r=new DecompressionStream("deflate-raw"),s=n.pipeThrough(r);try{let o=await new Response(s).arrayBuffer();return new Uint8Array(o)}catch(i){let o=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(Ee);if(e===_t.LocalFileHeader){let n=await this.tokenizer.readToken(ku);return n.filename=await this.tokenizer.readToken(new Ue(n.filenameLength,"utf-8")),n}if(e===_t.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var _n,Pu=C(()=>{_n=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(n){let r=new Uint8Array(1024),s=await e.readBuffer(r,{mayBeLess:!0});if(s===0){n.close();return}n.enqueue(r.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var Tu=C(()=>{Fu();Pu()});function Ys(t){let{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}var iC,oC,aC,Ou=C(()=>{iC={utf8:new globalThis.TextDecoder("utf8")},oC=new globalThis.TextEncoder,aC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"))});function Du(t,e){if(e==="utf-16le"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s&255,s>>8&255)}return n}if(e==="utf-16be"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s>>8&255,s&255)}return n}return[...t].map(n=>n.charCodeAt(0))}function Lu(t,e=0){let n=Number.parseInt(new Ue(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let s=e;s<e+148;s++)r+=t[s];for(let s=e+156;s<e+512;s++)r+=t[s];return n===r}var Mu,_u=C(()=>{Tn();Mu={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4}});var Bu,Wu,Uu=C(()=>{Bu=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],Wu=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"]});async function ju(t,e){return new ni(e).fromBuffer(t)}function ti(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function ct(t,e,n){n={offset:0,...n};for(let[r,s]of e.entries())if(n.mask){if(s!==(n.mask[r]&t[r+n.offset]))return!1}else if(s!==t[r+n.offset])return!1;return!0}var ei,ni,gC,yC,zu=C(()=>{Tn();wu();Tu();Ou();_u();Uu();ei=4100;ni=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let n=e.position;for(let r of this.detectors){let s=await r.detect(e);if(s)return s;if(n!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let n=e instanceof Uint8Array?e:new Uint8Array(e);if(n?.length>1)return this.fromTokenizer(yu(n,this.tokenizerOptions))}async fromBlob(e){let n=xu(e,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(e){let n=gu(e,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(e,n){let{sampleSize:r=ei}=n,s,i,o=e.getReader({mode:"byob"});try{let{value:c,done:u}=await o.read(new Uint8Array(r));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof pe))throw f;s=void 0}i=c}finally{o.releaseLock()}let a=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=e.pipeThrough(a);return l.fileType=s,l}check(e,n){return ct(this.buffer,e,n)}checkString(e,n){return this.check(Du(e,n?.encoding),n)}detectConfident=async e=>{if(this.buffer=new Uint8Array(ei),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8])){let r=new _n(e).inflate(),s=!0;try{let i;try{i=await this.fromStream(r)}catch{s=!1}if(i&&i.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{s&&await r.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);let n=await e.readToken(Mu);return e.position+n>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(n),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let n;return await new Mn(e).unzip(r=>{switch(r.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(s){let i=new TextDecoder("utf-8").decode(s).trim();n=ti(i)},stop:!0};case"[Content_Types].xml":return{async handler(s){let i=new TextDecoder("utf-8").decode(s),o=i.indexOf('.main+xml"');if(o===-1){let a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";i.includes(`ContentType="${a}"`)&&(n=ti(a))}else{i=i.slice(0,Math.max(0,o));let a=i.lastIndexOf('"'),l=i.slice(Math.max(0,a+1));n=ti(l)}},stop:!0};default:return/classes\d*\.dex/.test(r.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(r=>{if(!(r instanceof pe))throw r}),n??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let n=new Uint8Array(8);return await e.readBuffer(n),ct(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ct(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ct(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ct(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ct(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ct(n,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let n=await this.readTiffHeader(!1);if(n)return n}if(this.check([77,77])){let n=await this.readTiffHeader(!0);if(n)return n}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function n(){let a=await e.peekNumber(iu),l=128,c=0;for(;(a&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await e.readBuffer(u),u}async function r(){let a=await n(),l=await n();l[0]^=128>>l.length-1;let c=Math.min(6,l.length),u=new DataView(a.buffer),f=new DataView(l.buffer,l.length-c,c);return{id:Ys(u),len:Ys(f)}}async function s(a){for(;a>0;){let l=await r();if(l.id===17026)return(await e.readToken(new Ue(l.len))).replaceAll(/\00.*$/g,"");await e.ignore(l.len),--a}}let i=await r();switch(await s(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let n=new Ue(4,"latin1").get(this.buffer,2);if(n.match("^d*")&&n>=1e3&&n<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new Ue(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
552
+ `,"\r"," "," ","\0"].some(n=>this.checkString(n,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function n(){return{length:await e.readToken(au),type:await e.readToken(new Ue(4,"latin1"))}}do{let r=await n();if(r.length<0)return;switch(r.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(r.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let n=new Ue(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(n){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return n.startsWith("3g")?n.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
553
+ `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function n(){let r=new Uint8Array(16);return await e.readBuffer(r),{id:r,size:Number(await e.readToken(lu))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let r=await n(),s=r.size-24;if(ct(r.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let i=new Uint8Array(16);if(s-=await e.readBuffer(i),ct(i,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(ct(i,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(s)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Ue(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let n=new DataView(this.buffer.buffer).getUint32(12,!0);if(n>12&&this.buffer.length>=n+16)try{let r=new TextDecoder().decode(this.buffer.subarray(16,n+16));if(JSON.parse(r).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Lu(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let n="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:n})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:n})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
554
+ `,{offset:2,encoding:n})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(ei),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let n=0;n<=this.options.mpegOffsetTolerance;++n){let r=this.scanMpeg(n);if(r)return r}};async readTiffTag(e){let n=await this.tokenizer.readToken(e?sn:ge);switch(this.tokenizer.ignore(10),n){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let n=await this.tokenizer.readToken(e?sn:ge);for(let r=0;r<n;++r){let s=await this.readTiffTag(e);if(s)return s}}async readTiffHeader(e){let n=(e?sn:ge).get(this.buffer,2),r=(e?ou:Ee).get(this.buffer,4);if(n===42){if(r>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(r>=8){let i=(e?sn:ge).get(this.buffer,8),o=(e?sn:ge).get(this.buffer,10);if(i===28&&o===254||i===31&&o===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(r),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(n===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},gC=new Set(Bu),yC=new Set(Wu)});var qu={};_(qu,{fileCommand:()=>Ly});function Py(t,e){if(Gu[t])return Gu[t];let[n,r]=e.split("/"),s=r?.split("+")[0]?.replace(/-/g," ")||t;switch(n){case"image":return`${s.toUpperCase()} image data`;case"audio":return`${s.toUpperCase()} audio`;case"video":return`${s.toUpperCase()} video`;case"font":return`${s} font`;case"model":return`${s} 3D model`;case"application":return r?.includes("zip")||r?.includes("compressed")?`${s} archive data`:r?.includes("executable")?`${s} executable`:`${t.toUpperCase()} data`;default:return`${t.toUpperCase()} data`}}function Ty(t){let e=t.split("/").pop()||t;if(e.startsWith(".")&&!e.includes(".",1))return e;let n=e.lastIndexOf(".");return n===-1||n===0?"":e.slice(n).toLowerCase()}function Oy(t,e){if(t.startsWith("#!")){let l=t.split(`
551
555
  `)[0];return l.includes("python")?{description:"Python script, ASCII text executable",mime:"text/x-python"}:l.includes("node")||l.includes("bun")||l.includes("deno")?{description:"JavaScript script, ASCII text executable",mime:"text/javascript"}:l.includes("bash")?{description:"Bourne-Again shell script, ASCII text executable",mime:"text/x-shellscript"}:l.includes("sh")?{description:"POSIX shell script, ASCII text executable",mime:"text/x-shellscript"}:l.includes("ruby")?{description:"Ruby script, ASCII text executable",mime:"text/x-ruby"}:l.includes("perl")?{description:"Perl script, ASCII text executable",mime:"text/x-perl"}:{description:"script, ASCII text executable",mime:"text/plain"}}let n=t.trimStart();if(n.startsWith("<?xml"))return{description:"XML document",mime:"application/xml"};if(n.startsWith("<!DOCTYPE html")||n.toLowerCase().startsWith("<html"))return{description:"HTML document",mime:"text/html"};let r=t.includes(`\r
552
- `),s=t.includes("\r")&&!r,i="";r?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let o=ky(e);if(o&&Wu[o]){let l=Wu[o];return l.mime.startsWith("text/")&&i?{description:`${l.description}${i}`,mime:l.mime}:l}let a=!1;for(let l=0;l<Math.min(t.length,8192);l++)if(t.charCodeAt(l)>127){a=!0;break}return a?{description:`UTF-8 Unicode text${i}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${i}`,mime:"text/plain"}}async function Iy(t,e){if(e.length===0)return{description:"empty",mime:"inode/x-empty"};let n=await _u(e);if(n)return{description:Ay(n.ext,n.mime),mime:n.mime};let r=new TextDecoder("utf-8",{fatal:!1}).decode(e);return Ny(r,t)}var Cy,Wu,Uu,vy,zu=C(()=>{"use strict";Bu();j();Cy={name:"file",summary:"determine file type",usage:"file [OPTION]... FILE...",options:["-b, --brief do not prepend filenames to output","-i, --mime output MIME type strings","-L, --dereference follow symlinks"," --help display this help and exit"]},Wu={".js":{description:"JavaScript source",mime:"text/javascript"},".mjs":{description:"JavaScript module",mime:"text/javascript"},".cjs":{description:"CommonJS module",mime:"text/javascript"},".ts":{description:"TypeScript source",mime:"text/typescript"},".tsx":{description:"TypeScript JSX source",mime:"text/typescript"},".jsx":{description:"JavaScript JSX source",mime:"text/javascript"},".py":{description:"Python script",mime:"text/x-python"},".rb":{description:"Ruby script",mime:"text/x-ruby"},".go":{description:"Go source",mime:"text/x-go"},".rs":{description:"Rust source",mime:"text/x-rust"},".c":{description:"C source",mime:"text/x-c"},".h":{description:"C header",mime:"text/x-c"},".cpp":{description:"C++ source",mime:"text/x-c++"},".hpp":{description:"C++ header",mime:"text/x-c++"},".java":{description:"Java source",mime:"text/x-java"},".sh":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".bash":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".zsh":{description:"Zsh shell script",mime:"text/x-shellscript"},".json":{description:"JSON data",mime:"application/json"},".yaml":{description:"YAML data",mime:"text/yaml"},".yml":{description:"YAML data",mime:"text/yaml"},".xml":{description:"XML document",mime:"application/xml"},".csv":{description:"CSV text",mime:"text/csv"},".toml":{description:"TOML data",mime:"text/toml"},".html":{description:"HTML document",mime:"text/html"},".htm":{description:"HTML document",mime:"text/html"},".css":{description:"CSS stylesheet",mime:"text/css"},".svg":{description:"SVG image",mime:"image/svg+xml"},".md":{description:"Markdown document",mime:"text/markdown"},".markdown":{description:"Markdown document",mime:"text/markdown"},".txt":{description:"ASCII text",mime:"text/plain"},".rst":{description:"reStructuredText",mime:"text/x-rst"},".env":{description:"ASCII text",mime:"text/plain"},".gitignore":{description:"ASCII text",mime:"text/plain"},".dockerignore":{description:"ASCII text",mime:"text/plain"}},Uu={jpg:"JPEG image data",jpeg:"JPEG image data",png:"PNG image data",gif:"GIF image data",webp:"WebP image data",bmp:"PC bitmap",ico:"MS Windows icon resource",tif:"TIFF image data",tiff:"TIFF image data",psd:"Adobe Photoshop Document",avif:"AVIF image",heic:"HEIC image",heif:"HEIF image",jxl:"JPEG XL image",icns:"Mac OS X icon",svg:"SVG Scalable Vector Graphics image",pdf:"PDF document",epub:"EPUB document",mobi:"Mobipocket E-book",djvu:"DjVu document",zip:"Zip archive data",gz:"gzip compressed data",gzip:"gzip compressed data",bz2:"bzip2 compressed data",xz:"XZ compressed data",tar:"POSIX tar archive",rar:"RAR archive data","7z":"7-zip archive data",lz:"lzip compressed data",lzma:"LZMA compressed data",zst:"Zstandard compressed data",cab:"Microsoft Cabinet archive",ar:"Unix ar archive",rpm:"RPM package",deb:"Debian binary package",apk:"Android Package",dmg:"Apple disk image",iso:"ISO 9660 CD-ROM filesystem data",vhd:"Microsoft Virtual Hard Disk",vhdx:"Microsoft Virtual Hard Disk (new format)",qcow2:"QEMU QCOW Image",mp3:"Audio file with ID3",m4a:"MPEG-4 audio",aac:"AAC audio",wav:"RIFF (little-endian) data, WAVE audio",flac:"FLAC audio bitstream data",ogg:"Ogg data",oga:"Ogg audio",opus:"Ogg Opus audio",aiff:"AIFF audio",wma:"Windows Media Audio",amr:"AMR audio",mid:"MIDI audio",midi:"MIDI audio",ape:"Monkey's Audio",mp4:"ISO Media, MPEG-4",m4v:"MPEG-4 video",webm:"WebM",avi:"RIFF (little-endian) data, AVI",mov:"ISO Media, Apple QuickTime movie",mkv:"Matroska data",wmv:"Windows Media Video",flv:"Flash Video","3gp":"3GPP multimedia","3g2":"3GPP2 multimedia",ogv:"Ogg video",mts:"MPEG transport stream",m2ts:"MPEG transport stream",ts:"MPEG transport stream",mpg:"MPEG video",mpeg:"MPEG video",exe:"PE32 executable",dll:"PE32 DLL",elf:"ELF executable",mach:"Mach-O executable",wasm:"WebAssembly (wasm) binary module",dex:"Android Dalvik executable",class:"Java class file",swf:"Adobe Flash",doc:"Microsoft Word Document",docx:"Microsoft Word 2007+ Document",xls:"Microsoft Excel Spreadsheet",xlsx:"Microsoft Excel 2007+ Spreadsheet",ppt:"Microsoft PowerPoint Presentation",pptx:"Microsoft PowerPoint 2007+ Presentation",odt:"OpenDocument Text",ods:"OpenDocument Spreadsheet",odp:"OpenDocument Presentation",ttf:"TrueType Font",otf:"OpenType Font",woff:"Web Open Font Format",woff2:"Web Open Font Format 2",eot:"Embedded OpenType font",stl:"Stereolithography CAD",obj:"Wavefront 3D Object",gltf:"GL Transmission Format",glb:"GL Transmission Format (binary)",sqlite:"SQLite 3.x database",mdb:"Microsoft Access Database",xml:"XML document",json:"JSON data",macho:"Mach-O binary",ics:"iCalendar data",vcf:"vCard data",msi:"Microsoft Installer",ps:"PostScript",ai:"Adobe Illustrator",indd:"Adobe InDesign",sketch:"Sketch design file",fig:"Figma design file",xd:"Adobe XD",blend:"Blender",fbx:"Autodesk FBX",lnk:"MS Windows shortcut",alias:"Mac OS alias",torrent:"BitTorrent file",pcap:"pcap capture file",arrow:"Apache Arrow",parquet:"Apache Parquet"};vy={name:"file",async execute(t,e){if(I(t))return N(Cy);let n=!1,r=!1,s=[];for(let a of t)if(a.startsWith("--")){if(a==="--brief")n=!0;else if(a==="--mime"||a==="--mime-type")r=!0;else if(a!=="--dereference")return D("file",a)}else if(a.startsWith("-")&&a!=="-"){for(let l of a.slice(1))if(l==="b")n=!0;else if(l==="i")r=!0;else if(l!=="L")return D("file",`-${l}`)}else s.push(a);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
556
+ `),s=t.includes("\r")&&!r,i="";r?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let o=Ty(e);if(o&&Hu[o]){let l=Hu[o];return l.mime.startsWith("text/")&&i?{description:`${l.description}${i}`,mime:l.mime}:l}let a=!1;for(let l=0;l<Math.min(t.length,8192);l++)if(t.charCodeAt(l)>127){a=!0;break}return a?{description:`UTF-8 Unicode text${i}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${i}`,mime:"text/plain"}}async function Dy(t,e){if(e.length===0)return{description:"empty",mime:"inode/x-empty"};let n=await ju(e);if(n)return{description:Py(n.ext,n.mime),mime:n.mime};let r=new TextDecoder("utf-8",{fatal:!1}).decode(e);return Oy(r,t)}var Fy,Hu,Gu,Ly,Vu=C(()=>{"use strict";zu();j();Fy={name:"file",summary:"determine file type",usage:"file [OPTION]... FILE...",options:["-b, --brief do not prepend filenames to output","-i, --mime output MIME type strings","-L, --dereference follow symlinks"," --help display this help and exit"]},Hu={".js":{description:"JavaScript source",mime:"text/javascript"},".mjs":{description:"JavaScript module",mime:"text/javascript"},".cjs":{description:"CommonJS module",mime:"text/javascript"},".ts":{description:"TypeScript source",mime:"text/typescript"},".tsx":{description:"TypeScript JSX source",mime:"text/typescript"},".jsx":{description:"JavaScript JSX source",mime:"text/javascript"},".py":{description:"Python script",mime:"text/x-python"},".rb":{description:"Ruby script",mime:"text/x-ruby"},".go":{description:"Go source",mime:"text/x-go"},".rs":{description:"Rust source",mime:"text/x-rust"},".c":{description:"C source",mime:"text/x-c"},".h":{description:"C header",mime:"text/x-c"},".cpp":{description:"C++ source",mime:"text/x-c++"},".hpp":{description:"C++ header",mime:"text/x-c++"},".java":{description:"Java source",mime:"text/x-java"},".sh":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".bash":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".zsh":{description:"Zsh shell script",mime:"text/x-shellscript"},".json":{description:"JSON data",mime:"application/json"},".yaml":{description:"YAML data",mime:"text/yaml"},".yml":{description:"YAML data",mime:"text/yaml"},".xml":{description:"XML document",mime:"application/xml"},".csv":{description:"CSV text",mime:"text/csv"},".toml":{description:"TOML data",mime:"text/toml"},".html":{description:"HTML document",mime:"text/html"},".htm":{description:"HTML document",mime:"text/html"},".css":{description:"CSS stylesheet",mime:"text/css"},".svg":{description:"SVG image",mime:"image/svg+xml"},".md":{description:"Markdown document",mime:"text/markdown"},".markdown":{description:"Markdown document",mime:"text/markdown"},".txt":{description:"ASCII text",mime:"text/plain"},".rst":{description:"reStructuredText",mime:"text/x-rst"},".env":{description:"ASCII text",mime:"text/plain"},".gitignore":{description:"ASCII text",mime:"text/plain"},".dockerignore":{description:"ASCII text",mime:"text/plain"}},Gu={jpg:"JPEG image data",jpeg:"JPEG image data",png:"PNG image data",gif:"GIF image data",webp:"WebP image data",bmp:"PC bitmap",ico:"MS Windows icon resource",tif:"TIFF image data",tiff:"TIFF image data",psd:"Adobe Photoshop Document",avif:"AVIF image",heic:"HEIC image",heif:"HEIF image",jxl:"JPEG XL image",icns:"Mac OS X icon",svg:"SVG Scalable Vector Graphics image",pdf:"PDF document",epub:"EPUB document",mobi:"Mobipocket E-book",djvu:"DjVu document",zip:"Zip archive data",gz:"gzip compressed data",gzip:"gzip compressed data",bz2:"bzip2 compressed data",xz:"XZ compressed data",tar:"POSIX tar archive",rar:"RAR archive data","7z":"7-zip archive data",lz:"lzip compressed data",lzma:"LZMA compressed data",zst:"Zstandard compressed data",cab:"Microsoft Cabinet archive",ar:"Unix ar archive",rpm:"RPM package",deb:"Debian binary package",apk:"Android Package",dmg:"Apple disk image",iso:"ISO 9660 CD-ROM filesystem data",vhd:"Microsoft Virtual Hard Disk",vhdx:"Microsoft Virtual Hard Disk (new format)",qcow2:"QEMU QCOW Image",mp3:"Audio file with ID3",m4a:"MPEG-4 audio",aac:"AAC audio",wav:"RIFF (little-endian) data, WAVE audio",flac:"FLAC audio bitstream data",ogg:"Ogg data",oga:"Ogg audio",opus:"Ogg Opus audio",aiff:"AIFF audio",wma:"Windows Media Audio",amr:"AMR audio",mid:"MIDI audio",midi:"MIDI audio",ape:"Monkey's Audio",mp4:"ISO Media, MPEG-4",m4v:"MPEG-4 video",webm:"WebM",avi:"RIFF (little-endian) data, AVI",mov:"ISO Media, Apple QuickTime movie",mkv:"Matroska data",wmv:"Windows Media Video",flv:"Flash Video","3gp":"3GPP multimedia","3g2":"3GPP2 multimedia",ogv:"Ogg video",mts:"MPEG transport stream",m2ts:"MPEG transport stream",ts:"MPEG transport stream",mpg:"MPEG video",mpeg:"MPEG video",exe:"PE32 executable",dll:"PE32 DLL",elf:"ELF executable",mach:"Mach-O executable",wasm:"WebAssembly (wasm) binary module",dex:"Android Dalvik executable",class:"Java class file",swf:"Adobe Flash",doc:"Microsoft Word Document",docx:"Microsoft Word 2007+ Document",xls:"Microsoft Excel Spreadsheet",xlsx:"Microsoft Excel 2007+ Spreadsheet",ppt:"Microsoft PowerPoint Presentation",pptx:"Microsoft PowerPoint 2007+ Presentation",odt:"OpenDocument Text",ods:"OpenDocument Spreadsheet",odp:"OpenDocument Presentation",ttf:"TrueType Font",otf:"OpenType Font",woff:"Web Open Font Format",woff2:"Web Open Font Format 2",eot:"Embedded OpenType font",stl:"Stereolithography CAD",obj:"Wavefront 3D Object",gltf:"GL Transmission Format",glb:"GL Transmission Format (binary)",sqlite:"SQLite 3.x database",mdb:"Microsoft Access Database",xml:"XML document",json:"JSON data",macho:"Mach-O binary",ics:"iCalendar data",vcf:"vCard data",msi:"Microsoft Installer",ps:"PostScript",ai:"Adobe Illustrator",indd:"Adobe InDesign",sketch:"Sketch design file",fig:"Figma design file",xd:"Adobe XD",blend:"Blender",fbx:"Autodesk FBX",lnk:"MS Windows shortcut",alias:"Mac OS alias",torrent:"BitTorrent file",pcap:"pcap capture file",arrow:"Apache Arrow",parquet:"Apache Parquet"};Ly={name:"file",async execute(t,e){if(N(t))return k(Fy);let n=!1,r=!1,s=[];for(let a of t)if(a.startsWith("--")){if(a==="--brief")n=!0;else if(a==="--mime"||a==="--mime-type")r=!0;else if(a!=="--dereference")return L("file",a)}else if(a.startsWith("-")&&a!=="-"){for(let l of a.slice(1))if(l==="b")n=!0;else if(l==="i")r=!0;else if(l!=="L")return L("file",`-${l}`)}else s.push(a);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
553
557
  `,exitCode:1};let i="",o=0;for(let a of s)try{let l=e.fs.resolvePath(e.cwd,a);if((await e.fs.stat(l)).isDirectory){let p=r?"inode/directory":"directory";i+=n?`${p}
554
558
  `:`${a}: ${p}
555
- `;continue}let u=await e.fs.readFileBuffer(l),f=await Iy(a,u),d=r?f.mime:f.description;i+=n?`${d}
559
+ `;continue}let u=await e.fs.readFileBuffer(l),f=await Dy(a,u),d=r?f.mime:f.description;i+=n?`${d}
556
560
  `:`${a}: ${d}
557
561
  `}catch{i+=n?`cannot open
558
562
  `:`${a}: cannot open (No such file or directory)
559
- `,o=1}return{stdout:i,stderr:"",exitCode:o}}}});var Hu={};L(Hu,{htmlToMarkdownCommand:()=>Py});import $y from"turndown";var Ry,Py,Gu=C(()=>{"use strict";j();Ry={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 ![alt](src)"," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '<h1>Hello</h1><p>World</p>' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},Py={name:"html-to-markdown",async execute(t,e){if(I(t))return N(Ry);let n="-",r="```",s="---",i="atx",o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-b"||c==="--bullet")n=t[++l]??"-";else if(c.startsWith("--bullet="))n=c.slice(9);else if(c==="-c"||c==="--code")r=t[++l]??"```";else if(c.startsWith("--code="))r=c.slice(7);else if(c==="-r"||c==="--hr")s=t[++l]??"---";else if(c.startsWith("--hr="))s=c.slice(5);else if(c.startsWith("--heading-style=")){let u=c.slice(16);(u==="setext"||u==="atx")&&(i=u)}else if(c==="-")o.push("-");else{if(c.startsWith("--"))return D("html-to-markdown",c);if(c.startsWith("-"))return D("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=e.stdin;else try{let l=e.fs.resolvePath(e.cwd,o[0]);a=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
560
- `,exitCode:1}}if(!a.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new $y({bulletListMarker:n,codeBlockStyle:"fenced",fence:r,hr:s,headingStyle:i});return l.remove(["script","style","footer"]),{stdout:`${l.turndown(a).trim()}
563
+ `,o=1}return{stdout:i,stderr:"",exitCode:o}}}});var Zu={};_(Zu,{htmlToMarkdownCommand:()=>By});import My from"turndown";var _y,By,Ku=C(()=>{"use strict";j();_y={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 ![alt](src)"," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '<h1>Hello</h1><p>World</p>' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},By={name:"html-to-markdown",async execute(t,e){if(N(t))return k(_y);let n="-",r="```",s="---",i="atx",o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-b"||c==="--bullet")n=t[++l]??"-";else if(c.startsWith("--bullet="))n=c.slice(9);else if(c==="-c"||c==="--code")r=t[++l]??"```";else if(c.startsWith("--code="))r=c.slice(7);else if(c==="-r"||c==="--hr")s=t[++l]??"---";else if(c.startsWith("--hr="))s=c.slice(5);else if(c.startsWith("--heading-style=")){let u=c.slice(16);(u==="setext"||u==="atx")&&(i=u)}else if(c==="-")o.push("-");else{if(c.startsWith("--"))return L("html-to-markdown",c);if(c.startsWith("-"))return L("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=e.stdin;else try{let l=e.fs.resolvePath(e.cwd,o[0]);a=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
564
+ `,exitCode:1}}if(!a.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new My({bulletListMarker:n,codeBlockStyle:"fenced",fence:r,hr:s,headingStyle:i});return l.remove(["script","style","footer"]),{stdout:`${l.turndown(a).trim()}
561
565
  `,stderr:"",exitCode:0}}catch(l){return{stdout:"",stderr:`html-to-markdown: conversion error: ${l.message}
562
- `,exitCode:1}}}}});var qu={};L(qu,{helpCommand:()=>Oy});function Ty(t){let e=[],n=new Set(t);e.push(`Available commands:
563
- `);let r=[];for(let[s,i]of Object.entries(Fy)){let o=i.filter(a=>n.has(a));if(o.length>0){e.push(` ${s}:`),e.push(` ${o.join(", ")}
566
+ `,exitCode:1}}}}});var Qu={};_(Qu,{helpCommand:()=>jy});function Uy(t){let e=[],n=new Set(t);e.push(`Available commands:
567
+ `);let r=[];for(let[s,i]of Object.entries(Wy)){let o=i.filter(a=>n.has(a));if(o.length>0){e.push(` ${s}:`),e.push(` ${o.join(", ")}
564
568
  `);for(let a of o)n.delete(a)}}for(let s of n)r.push(s);return r.length>0&&(e.push(" Other:"),e.push(` ${r.sort().join(", ")}
565
569
  `)),e.push("Use '<command> --help' for details on a specific command."),`${e.join(`
566
570
  `)}
567
- `}var Fy,Oy,Vu=C(()=>{"use strict";Fy={"File operations":["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"],"Text processing":["grep","sed","awk","sort","uniq","cut","tr","tee","diff"],Search:["find"],"Navigation & paths":["pwd","basename","dirname","tree","du"],"Environment & shell":["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"],"Data processing":["xargs","jq","base64","date"],Network:["curl","html-to-markdown"]};Oy={name:"help",async execute(t,e){if(t.includes("--help")||t.includes("-h"))return{stdout:`help - display available commands
571
+ `}var Wy,jy,Xu=C(()=>{"use strict";Wy={"File operations":["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"],"Text processing":["grep","sed","awk","sort","uniq","cut","tr","tee","diff"],Search:["find"],"Navigation & paths":["pwd","basename","dirname","tree","du"],"Environment & shell":["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"],"Data processing":["xargs","jq","base64","date"],Network:["curl","html-to-markdown"]};jy={name:"help",async execute(t,e){if(t.includes("--help")||t.includes("-h"))return{stdout:`help - display available commands
568
572
 
569
573
  Usage: help [command]
570
574
 
@@ -573,100 +577,100 @@ Options:
573
577
 
574
578
  If a command name is provided, shows help for that command.
575
579
  Otherwise, lists all available commands.
576
- `,stderr:"",exitCode:0};if(t.length>0&&e.exec){let r=t[0];return e.exec(`${r} --help`,{cwd:e.cwd})}let n=e.getRegisteredCommands?.()??[];return{stdout:Ty(n),stderr:"",exitCode:0}}}});var Zu={};L(Zu,{whichCommand:()=>My});var Dy,Ly,My,Ku=C(()=>{"use strict";Ae();j();Dy={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},Ly={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},My={name:"which",async execute(t,e){if(I(t))return N(Dy);let n=K("which",t,Ly);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.silent,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:"",exitCode:1};let a=(e.env.PATH||"/bin:/usr/bin").split(":"),l="",c=!0;for(let u of i){let f=!1;for(let d of a){if(!d)continue;let p=`${d}/${u}`;if(await e.fs.exists(p)&&(f=!0,s||(l+=`${p}
577
- `),!r))break}f||(c=!1)}return{stdout:l,stderr:"",exitCode:c?0:1}}}});var Qu={};L(Qu,{tac:()=>By});async function _y(t,e){if(t.length>0&&t[0]!=="-"){let s=t[0].startsWith("/")?t[0]:`${e.cwd}/${t[0]}`;try{let o=(await e.fs.readFile(s)).split(`
580
+ `,stderr:"",exitCode:0};if(t.length>0&&e.exec){let r=t[0];return e.exec(`${r} --help`,{cwd:e.cwd})}let n=e.getRegisteredCommands?.()??[];return{stdout:Uy(n),stderr:"",exitCode:0}}}});var Ju={};_(Ju,{whichCommand:()=>Gy});var zy,Hy,Gy,Yu=C(()=>{"use strict";Ae();j();zy={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},Hy={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},Gy={name:"which",async execute(t,e){if(N(t))return k(zy);let n=Q("which",t,Hy);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.silent,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:"",exitCode:1};let a=(e.env.PATH||"/bin:/usr/bin").split(":"),l="",c=!0;for(let u of i){let f=!1;for(let d of a){if(!d)continue;let p=`${d}/${u}`;if(await e.fs.exists(p)&&(f=!0,s||(l+=`${p}
581
+ `),!r))break}f||(c=!1)}return{stdout:l,stderr:"",exitCode:c?0:1}}}});var ef={};_(ef,{tac:()=>Vy});async function qy(t,e){if(t.length>0&&t[0]!=="-"){let s=t[0].startsWith("/")?t[0]:`${e.cwd}/${t[0]}`;try{let o=(await e.fs.readFile(s)).split(`
578
582
  `);o[o.length-1]===""&&o.pop();let a=o.reverse();return{stdout:a.length>0?`${a.join(`
579
583
  `)}
580
584
  `:"",stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`tac: ${t[0]}: No such file or directory
581
585
  `,exitCode:1}}}let n=e.stdin.split(`
582
586
  `);n[n.length-1]===""&&n.pop();let r=n.reverse();return{stdout:r.length>0?`${r.join(`
583
587
  `)}
584
- `:"",stderr:"",exitCode:0}}var By,Xu=C(()=>{"use strict";By={name:"tac",execute:_y}});var Ju={};L(Ju,{hostname:()=>Uy});async function Wy(t,e){return{stdout:`localhost
585
- `,stderr:"",exitCode:0}}var Uy,Yu=C(()=>{"use strict";Uy={name:"hostname",execute:Wy}});var ef={};L(ef,{od:()=>zy});async function jy(t,e){let n=t.includes("-c"),r=t.includes("-An")?"none":"octal",s=e.stdin,i=t.filter(l=>!l.startsWith("-")&&l!=="-");if(i.length>0){let l=i[0].startsWith("/")?i[0]:`${e.cwd}/${i[0]}`;try{s=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`od: ${i[0]}: No such file or directory
588
+ `:"",stderr:"",exitCode:0}}var Vy,tf=C(()=>{"use strict";Vy={name:"tac",execute:qy}});var nf={};_(nf,{hostname:()=>Ky});async function Zy(t,e){return{stdout:`localhost
589
+ `,stderr:"",exitCode:0}}var Ky,rf=C(()=>{"use strict";Ky={name:"hostname",execute:Zy}});var sf={};_(sf,{od:()=>Xy});async function Qy(t,e){let n=t.includes("-c"),r=t.includes("-An")?"none":"octal",s=e.stdin,i=t.filter(l=>!l.startsWith("-")&&l!=="-");if(i.length>0){let l=i[0].startsWith("/")?i[0]:`${e.cwd}/${i[0]}`;try{s=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`od: ${i[0]}: No such file or directory
586
590
  `,exitCode:1}}}if(n){let l=[];for(let u of s){let f=u.charCodeAt(0);f===0?l.push("\\0"):f===9?l.push("\\t"):f===10?l.push("\\n"):f===13?l.push("\\r"):f===32?l.push(" "):f>=32&&f<127?l.push(` ${u}`):l.push(`\\${f.toString(8).padStart(3,"0")}`)}let c=[];for(let u=0;u<l.length;u+=16){let f=l.slice(u,u+16),d=r==="none"?"":`${u.toString(8).padStart(7,"0")} `;c.push(d+f.join(" "))}return r!=="none"&&c.push(s.length.toString(8).padStart(7,"0")),{stdout:`${c.join(`
587
591
  `)}
588
592
  `,stderr:"",exitCode:0}}let o=[];for(let l of s)o.push(l.charCodeAt(0).toString(8).padStart(3,"0"));let a=[];for(let l=0;l<o.length;l+=8){let c=o.slice(l,l+8),u=r==="none"?"":`${l.toString(8).padStart(7,"0")} `;a.push(u+c.join(" "))}return r!=="none"&&o.length>0&&a.push(s.length.toString(8).padStart(7,"0")),{stdout:a.length>0?`${a.join(`
589
593
  `)}
590
- `:"",stderr:"",exitCode:0}}var zy,tf=C(()=>{"use strict";zy={name:"od",execute:jy}});var vr={};L(vr,{gunzipCommand:()=>Jy,gzipCommand:()=>Xy,zcatCommand:()=>Yy});import{constants as ti,gunzipSync as ni,gzipSync as nf}from"node:zlib";function rf(t){return t.best?ti.Z_BEST_COMPRESSION:t.level8?8:t.level7?7:t.level6?6:t.level5?5:t.level4?4:t.level3?3:t.level2?2:t.fast?ti.Z_BEST_SPEED:ti.Z_DEFAULT_COMPRESSION}function sf(t){if(t.length<10)return{originalName:null,mtime:null,headerSize:0};if(t[0]!==31||t[1]!==139)return{originalName:null,mtime:null,headerSize:0};let e=t[3],n=t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r=10;if(e&4){if(r+2>t.length)return{originalName:null,mtime:null,headerSize:0};let i=t[r]|t[r+1]<<8;r+=2+i}let s=null;if(e&8){let i=r;for(;r<t.length&&t[r]!==0;)r++;r<t.length&&(s=new TextDecoder().decode(t.slice(i,r)),r++)}if(e&16){for(;r<t.length&&t[r]!==0;)r++;r++}return e&2&&(r+=2),{originalName:s,mtime:n>0?new Date(n*1e3):null,headerSize:r}}function Zy(t){if(t.length<4)return 0;let e=t.length;return t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24}function Ir(t){return t.length>=2&&t[0]===31&&t[1]===139}async function of(t,e,n,r,s,i){let o=n.suffix,a,l,c;if(e==="-"||e==="")if(c=Uint8Array.from(t.stdin,u=>u.charCodeAt(0)),s){if(!Ir(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
591
- `,exitCode:1};try{let u=ni(c);return{stdout:String.fromCharCode(...u),stderr:"",exitCode:0}}catch(u){let f=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`${r}: stdin: ${f}
592
- `,exitCode:1}}}else{let u=rf(n),f=nf(c,{level:u});return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0}}a=t.fs.resolvePath(t.cwd,e);try{if((await t.fs.stat(a)).isDirectory)return n.recursive?await af(t,a,n,r,s,i):n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: is a directory -- ignored
594
+ `:"",stderr:"",exitCode:0}}var Xy,of=C(()=>{"use strict";Xy={name:"od",execute:Qy}});var $r={};_($r,{gunzipCommand:()=>ox,gzipCommand:()=>ix,zcatCommand:()=>ax});import{constants as ri,gunzipSync as si,gzipSync as af}from"node:zlib";function lf(t){return t.best?ri.Z_BEST_COMPRESSION:t.level8?8:t.level7?7:t.level6?6:t.level5?5:t.level4?4:t.level3?3:t.level2?2:t.fast?ri.Z_BEST_SPEED:ri.Z_DEFAULT_COMPRESSION}function cf(t){if(t.length<10)return{originalName:null,mtime:null,headerSize:0};if(t[0]!==31||t[1]!==139)return{originalName:null,mtime:null,headerSize:0};let e=t[3],n=t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r=10;if(e&4){if(r+2>t.length)return{originalName:null,mtime:null,headerSize:0};let i=t[r]|t[r+1]<<8;r+=2+i}let s=null;if(e&8){let i=r;for(;r<t.length&&t[r]!==0;)r++;r<t.length&&(s=new TextDecoder().decode(t.slice(i,r)),r++)}if(e&16){for(;r<t.length&&t[r]!==0;)r++;r++}return e&2&&(r+=2),{originalName:s,mtime:n>0?new Date(n*1e3):null,headerSize:r}}function nx(t){if(t.length<4)return 0;let e=t.length;return t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24}function vr(t){return t.length>=2&&t[0]===31&&t[1]===139}async function uf(t,e,n,r,s,i){let o=n.suffix,a,l,c;if(e==="-"||e==="")if(c=Uint8Array.from(t.stdin,u=>u.charCodeAt(0)),s){if(!vr(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
595
+ `,exitCode:1};try{let u=si(c);return{stdout:String.fromCharCode(...u),stderr:"",exitCode:0}}catch(u){let f=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`${r}: stdin: ${f}
596
+ `,exitCode:1}}}else{let u=lf(n),f=af(c,{level:u});return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0}}a=t.fs.resolvePath(t.cwd,e);try{if((await t.fs.stat(a)).isDirectory)return n.recursive?await ff(t,a,n,r,s,i):n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: is a directory -- ignored
593
597
  `,exitCode:1}}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
594
598
  `,exitCode:1}}try{c=await t.fs.readFileBuffer(a)}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
595
599
  `,exitCode:1}}if(s){if(!e.endsWith(o))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: unknown suffix -- ignored
596
- `,exitCode:1};if(!Ir(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: not in gzip format
597
- `,exitCode:1};let u;try{u=ni(c)}catch(f){let d=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`${r}: ${e}: ${d}
598
- `,exitCode:1}}if(i)return{stdout:String.fromCharCode(...u),stderr:"",exitCode:0};if(n.name){let f=sf(c);f.originalName?l=t.fs.resolvePath(t.cwd,f.originalName):l=a.slice(0,-o.length)}else l=a.slice(0,-o.length);if(!n.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${r}: ${l} already exists; not overwritten
600
+ `,exitCode:1};if(!vr(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: not in gzip format
601
+ `,exitCode:1};let u;try{u=si(c)}catch(f){let d=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`${r}: ${e}: ${d}
602
+ `,exitCode:1}}if(i)return{stdout:String.fromCharCode(...u),stderr:"",exitCode:0};if(n.name){let f=cf(c);f.originalName?l=t.fs.resolvePath(t.cwd,f.originalName):l=a.slice(0,-o.length)}else l=a.slice(0,-o.length);if(!n.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${r}: ${l} already exists; not overwritten
599
603
  `,exitCode:1}}catch{}if(await t.fs.writeFile(l,u),!n.keep&&!i&&await t.fs.rm(a),n.verbose){let f=c.length>0?((1-c.length/u.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${e}: ${f}% -- replaced with ${l.split("/").pop()}
600
604
  `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}else{if(e.endsWith(o))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e} already has ${o} suffix -- unchanged
601
- `,exitCode:1};let u=rf(n),f;try{f=nf(c,{level:u})}catch(d){let p=d instanceof Error?d.message:"unknown error";return{stdout:"",stderr:`${r}: ${e}: ${p}
605
+ `,exitCode:1};let u=lf(n),f;try{f=af(c,{level:u})}catch(d){let p=d instanceof Error?d.message:"unknown error";return{stdout:"",stderr:`${r}: ${e}: ${p}
602
606
  `,exitCode:1}}if(i)return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0};if(l=a+o,!n.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${r}: ${l} already exists; not overwritten
603
607
  `,exitCode:1}}catch{}if(await t.fs.writeFile(l,f),!n.keep&&!i&&await t.fs.rm(a),n.verbose){let d=c.length>0?((1-f.length/c.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${e}: ${d}% -- replaced with ${l.split("/").pop()}
604
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function af(t,e,n,r,s,i){let o=await t.fs.readdir(e),a="",l="",c=0;for(let u of o){let f=t.fs.resolvePath(e,u),d=await t.fs.stat(f);if(d.isDirectory){let p=await af(t,f,n,r,s,i);a+=p.stdout,l+=p.stderr,p.exitCode!==0&&(c=p.exitCode)}else if(d.isFile){let p=n.suffix;if(s&&!u.endsWith(p)||!s&&u.endsWith(p))continue;let h=f.startsWith(`${t.cwd}/`)?f.slice(t.cwd.length+1):f,m=await of(t,h,n,r,s,i);a+=m.stdout,l+=m.stderr,m.exitCode!==0&&(c=m.exitCode)}}return{stdout:a,stderr:l,exitCode:c}}async function Ky(t,e,n,r){let s;if(e==="-"||e==="")s=Uint8Array.from(t.stdin,f=>f.charCodeAt(0));else{let f=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
605
- `,exitCode:1}}}if(!Ir(s))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: not in gzip format
606
- `,exitCode:1};let i=s.length,o=Zy(s),a=o>0?((1-i/o)*100).toFixed(1):"0.0",c=sf(s).originalName||(e==="-"?"":e.replace(/\.gz$/,""));return{stdout:`${i.toString().padStart(10)} ${o.toString().padStart(10)} ${a.padStart(5)}% ${c}
607
- `,stderr:"",exitCode:0}}async function Qy(t,e,n,r){let s;if(e==="-"||e==="")s=Uint8Array.from(t.stdin,i=>i.charCodeAt(0));else{let i=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
608
- `,exitCode:1}}}if(!Ir(s))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: not in gzip format
609
- `,exitCode:1};try{return ni(s),n.verbose?{stdout:"",stderr:`${e}: OK
608
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function ff(t,e,n,r,s,i){let o=await t.fs.readdir(e),a="",l="",c=0;for(let u of o){let f=t.fs.resolvePath(e,u),d=await t.fs.stat(f);if(d.isDirectory){let p=await ff(t,f,n,r,s,i);a+=p.stdout,l+=p.stderr,p.exitCode!==0&&(c=p.exitCode)}else if(d.isFile){let p=n.suffix;if(s&&!u.endsWith(p)||!s&&u.endsWith(p))continue;let h=f.startsWith(`${t.cwd}/`)?f.slice(t.cwd.length+1):f,m=await uf(t,h,n,r,s,i);a+=m.stdout,l+=m.stderr,m.exitCode!==0&&(c=m.exitCode)}}return{stdout:a,stderr:l,exitCode:c}}async function rx(t,e,n,r){let s;if(e==="-"||e==="")s=Uint8Array.from(t.stdin,f=>f.charCodeAt(0));else{let f=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
609
+ `,exitCode:1}}}if(!vr(s))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: not in gzip format
610
+ `,exitCode:1};let i=s.length,o=nx(s),a=o>0?((1-i/o)*100).toFixed(1):"0.0",c=cf(s).originalName||(e==="-"?"":e.replace(/\.gz$/,""));return{stdout:`${i.toString().padStart(10)} ${o.toString().padStart(10)} ${a.padStart(5)}% ${c}
611
+ `,stderr:"",exitCode:0}}async function sx(t,e,n,r){let s;if(e==="-"||e==="")s=Uint8Array.from(t.stdin,i=>i.charCodeAt(0));else{let i=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
612
+ `,exitCode:1}}}if(!vr(s))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: not in gzip format
613
+ `,exitCode:1};try{return si(s),n.verbose?{stdout:"",stderr:`${e}: OK
610
614
  `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(i){let o=i instanceof Error?i.message:"invalid";return{stdout:"",stderr:`${r}: ${e}: ${o}
611
- `,exitCode:1}}}async function ri(t,e,n){let r=n==="zcat"?qy:n==="gunzip"?Gy:Hy;if(I(t))return N(r);let s=K(n,t,Vy);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,o=s.result.positional,a=n==="gunzip"||n==="zcat"||i.decompress||i.uncompress,l=n==="zcat"||i.stdout||i.toStdout;if(i.list){o.length===0&&(o=["-"]);let d=` compressed uncompressed ratio uncompressed_name
612
- `,p="",h=0;for(let m of o){let g=await Ky(e,m,i,n);d+=g.stdout,p+=g.stderr,g.exitCode!==0&&(h=g.exitCode)}return{stdout:d,stderr:p,exitCode:h}}if(i.test){o.length===0&&(o=["-"]);let d="",p="",h=0;for(let m of o){let g=await Qy(e,m,i,n);d+=g.stdout,p+=g.stderr,g.exitCode!==0&&(h=g.exitCode)}return{stdout:d,stderr:p,exitCode:h}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let d of o){let p=await of(e,d,i,n,a,l);c+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var Hy,Gy,qy,Vy,Xy,Jy,Yy,$r=C(()=>{"use strict";Ae();j();Hy={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
615
+ `,exitCode:1}}}async function ii(t,e,n){let r=n==="zcat"?ex:n==="gunzip"?Yy:Jy;if(N(t))return k(r);let s=Q(n,t,tx);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,o=s.result.positional,a=n==="gunzip"||n==="zcat"||i.decompress||i.uncompress,l=n==="zcat"||i.stdout||i.toStdout;if(i.list){o.length===0&&(o=["-"]);let d=` compressed uncompressed ratio uncompressed_name
616
+ `,p="",h=0;for(let m of o){let g=await rx(e,m,i,n);d+=g.stdout,p+=g.stderr,g.exitCode!==0&&(h=g.exitCode)}return{stdout:d,stderr:p,exitCode:h}}if(i.test){o.length===0&&(o=["-"]);let d="",p="",h=0;for(let m of o){let g=await sx(e,m,i,n);d+=g.stdout,p+=g.stderr,g.exitCode!==0&&(h=g.exitCode)}return{stdout:d,stderr:p,exitCode:h}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let d of o){let p=await uf(e,d,i,n,a,l);c+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var Jy,Yy,ex,tx,ix,ox,ax,Rr=C(()=>{"use strict";Ae();j();Jy={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
613
617
 
614
618
  When no FILE is given, or when FILE is -, read from standard input.
615
619
 
616
- With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},Gy={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place).
620
+ With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},Yy={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place).
617
621
 
618
- When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},qy={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
622
+ When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},ex={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
619
623
 
620
- When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},Vy={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};Xy={name:"gzip",async execute(t,e){return ri(t,e,"gzip")}},Jy={name:"gunzip",async execute(t,e){return ri(t,e,"gunzip")}},Yy={name:"zcat",async execute(t,e){return ri(t,e,"zcat")}}});function si(t){let e=t.indexOf("=");if(e>=0){let n=t.slice(0,e),r=t.slice(e+1);return n?`${encodeURIComponent(n)}=${encodeURIComponent(r)}`:encodeURIComponent(r)}return encodeURIComponent(t)}function ii(t){let e=t.indexOf("=");if(e<0)return null;let n=t.slice(0,e),r=t.slice(e+1),s,i,o=r.match(/;type=([^;]+)$/);o&&(i=o[1],r=r.slice(0,-o[0].length));let a=r.match(/;filename=([^;]+)/);return a&&(s=a[1],r=r.replace(a[0],"")),(r.startsWith("@")||r.startsWith("<"))&&(s=s??r.slice(1).split("/").pop()),{name:n,value:r,filename:s,contentType:i}}function lf(t,e){let n=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let s of t){let i=s.value;if(i.startsWith("@")||i.startsWith("<")){let a=i.slice(1);i=e.get(a)??""}let o=`--${n}\r
624
+ When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},tx={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};ix={name:"gzip",async execute(t,e){return ii(t,e,"gzip")}},ox={name:"gunzip",async execute(t,e){return ii(t,e,"gunzip")}},ax={name:"zcat",async execute(t,e){return ii(t,e,"zcat")}}});function oi(t){let e=t.indexOf("=");if(e>=0){let n=t.slice(0,e),r=t.slice(e+1);return n?`${encodeURIComponent(n)}=${encodeURIComponent(r)}`:encodeURIComponent(r)}return encodeURIComponent(t)}function ai(t){let e=t.indexOf("=");if(e<0)return null;let n=t.slice(0,e),r=t.slice(e+1),s,i,o=r.match(/;type=([^;]+)$/);o&&(i=o[1],r=r.slice(0,-o[0].length));let a=r.match(/;filename=([^;]+)/);return a&&(s=a[1],r=r.replace(a[0],"")),(r.startsWith("@")||r.startsWith("<"))&&(s=s??r.slice(1).split("/").pop()),{name:n,value:r,filename:s,contentType:i}}function df(t,e){let n=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let s of t){let i=s.value;if(i.startsWith("@")||i.startsWith("<")){let a=i.slice(1);i=e.get(a)??""}let o=`--${n}\r
621
625
  `;s.filename?(o+=`Content-Disposition: form-data; name="${s.name}"; filename="${s.filename}"\r
622
626
  `,s.contentType&&(o+=`Content-Type: ${s.contentType}\r
623
627
  `)):o+=`Content-Disposition: form-data; name="${s.name}"\r
624
628
  `,o+=`\r
625
629
  ${i}\r
626
630
  `,r.push(o)}return r.push(`--${n}--\r
627
- `),{body:r.join(""),boundary:n}}var oi=C(()=>{"use strict"});var cf,uf=C(()=>{"use strict";cf={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]}});function ff(t){let e={method:"GET",headers:{},dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let n=0;n<t.length;n++){let r=t[n];if(r==="-X"||r==="--request")e.method=t[++n]??"GET";else if(r.startsWith("-X"))e.method=r.slice(2);else if(r.startsWith("--request="))e.method=r.slice(10);else if(r==="-H"||r==="--header"){let s=t[++n];if(s){let i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}}else if(r.startsWith("--header=")){let s=r.slice(9),i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}else if(r==="-d"||r==="--data"||r==="--data-raw")e.data=t[++n]??"",e.method==="GET"&&(e.method="POST");else if(r.startsWith("-d"))e.data=r.slice(2),e.method==="GET"&&(e.method="POST");else if(r.startsWith("--data="))e.data=r.slice(7),e.method==="GET"&&(e.method="POST");else if(r.startsWith("--data-raw="))e.data=r.slice(11),e.method==="GET"&&(e.method="POST");else if(r==="--data-binary")e.data=t[++n]??"",e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(r.startsWith("--data-binary="))e.data=r.slice(14),e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(r==="--data-urlencode"){let s=t[++n]??"";e.data=(e.data?`${e.data}&`:"")+si(s),e.method==="GET"&&(e.method="POST")}else if(r.startsWith("--data-urlencode=")){let s=r.slice(17);e.data=(e.data?`${e.data}&`:"")+si(s),e.method==="GET"&&(e.method="POST")}else if(r==="-F"||r==="--form"){let s=t[++n]??"",i=ii(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(r.startsWith("--form=")){let s=r.slice(7),i=ii(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(r==="-u"||r==="--user")e.user=t[++n];else if(r.startsWith("-u"))e.user=r.slice(2);else if(r.startsWith("--user="))e.user=r.slice(7);else if(r==="-A"||r==="--user-agent")e.headers["User-Agent"]=t[++n]??"";else if(r.startsWith("-A"))e.headers["User-Agent"]=r.slice(2);else if(r.startsWith("--user-agent="))e.headers["User-Agent"]=r.slice(13);else if(r==="-e"||r==="--referer")e.headers.Referer=t[++n]??"";else if(r.startsWith("-e"))e.headers.Referer=r.slice(2);else if(r.startsWith("--referer="))e.headers.Referer=r.slice(10);else if(r==="-b"||r==="--cookie")e.headers.Cookie=t[++n]??"";else if(r.startsWith("-b"))e.headers.Cookie=r.slice(2);else if(r.startsWith("--cookie="))e.headers.Cookie=r.slice(9);else if(r==="-c"||r==="--cookie-jar")e.cookieJar=t[++n];else if(r.startsWith("--cookie-jar="))e.cookieJar=r.slice(13);else if(r==="-T"||r==="--upload-file")e.uploadFile=t[++n],e.method==="GET"&&(e.method="PUT");else if(r.startsWith("--upload-file="))e.uploadFile=r.slice(14),e.method==="GET"&&(e.method="PUT");else if(r==="-m"||r==="--max-time"){let s=parseFloat(t[++n]??"0");!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(r.startsWith("--max-time=")){let s=parseFloat(r.slice(11));!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(r==="--connect-timeout"){let s=parseFloat(t[++n]??"0");!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(r.startsWith("--connect-timeout=")){let s=parseFloat(r.slice(18));!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(r==="-o"||r==="--output")e.outputFile=t[++n];else if(r.startsWith("--output="))e.outputFile=r.slice(9);else if(r==="-O"||r==="--remote-name")e.useRemoteName=!0;else if(r==="-I"||r==="--head")e.headOnly=!0,e.method="HEAD";else if(r==="-i"||r==="--include")e.includeHeaders=!0;else if(r==="-s"||r==="--silent")e.silent=!0;else if(r==="-S"||r==="--show-error")e.showError=!0;else if(r==="-f"||r==="--fail")e.failSilently=!0;else if(r==="-L"||r==="--location")e.followRedirects=!0;else if(r==="--max-redirs")n++;else if(!r.startsWith("--max-redirs="))if(r==="-w"||r==="--write-out")e.writeOut=t[++n];else if(r.startsWith("--write-out="))e.writeOut=r.slice(12);else if(r==="-v"||r==="--verbose")e.verbose=!0;else{if(r.startsWith("--")&&r!=="--")return D("curl",r);if(r.startsWith("-")&&r!=="-")for(let s of r.slice(1))switch(s){case"s":e.silent=!0;break;case"S":e.showError=!0;break;case"f":e.failSilently=!0;break;case"L":e.followRedirects=!0;break;case"I":e.headOnly=!0,e.method="HEAD";break;case"i":e.includeHeaders=!0;break;case"O":e.useRemoteName=!0;break;case"v":e.verbose=!0;break;default:return D("curl",`-${s}`)}else r.startsWith("-")||(e.url=r)}}return e}var df=C(()=>{"use strict";j();oi()});function ai(t){return Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(`\r
628
- `)}function pf(t){try{return new URL(t).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function li(t,e){let n=t;return n=n.replace(/%\{http_code\}/g,String(e.status)),n=n.replace(/%\{content_type\}/g,e.headers["content-type"]||""),n=n.replace(/%\{url_effective\}/g,e.url),n=n.replace(/%\{size_download\}/g,String(e.bodyLength)),n=n.replace(/\\n/g,`
629
- `),n}var hf=C(()=>{"use strict"});var mf={};L(mf,{curlCommand:()=>sx});async function ex(t,e){if(t.uploadFile){let n=e.fs.resolvePath(e.cwd,t.uploadFile);return{body:await e.fs.readFile(n)}}if(t.formFields.length>0){let n=new Map;for(let i of t.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let o=e.fs.resolvePath(e.cwd,i.value.slice(1));try{let a=await e.fs.readFile(o);n.set(i.value.slice(1),a)}catch{n.set(i.value.slice(1),"")}}let{body:r,boundary:s}=lf(t.formFields,n);return{body:r,contentType:`multipart/form-data; boundary=${s}`}}return t.data!==void 0?{body:t.data}:{}}function tx(t,e){let n={...t.headers};if(t.user){let r=Buffer.from(t.user).toString("base64");n.Authorization=`Basic ${r}`}return e&&!n["Content-Type"]&&(n["Content-Type"]=e),n}async function nx(t,e,n){if(!t.cookieJar)return;let r=e["set-cookie"];if(!r)return;let s=n.fs.resolvePath(n.cwd,t.cookieJar);await n.fs.writeFile(s,r)}function rx(t,e,n){let r="";if(t.verbose){r+=`> ${t.method} ${n}
631
+ `),{body:r.join(""),boundary:n}}var li=C(()=>{"use strict"});var pf,hf=C(()=>{"use strict";pf={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]}});function mf(t){let e={method:"GET",headers:{},dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let n=0;n<t.length;n++){let r=t[n];if(r==="-X"||r==="--request")e.method=t[++n]??"GET";else if(r.startsWith("-X"))e.method=r.slice(2);else if(r.startsWith("--request="))e.method=r.slice(10);else if(r==="-H"||r==="--header"){let s=t[++n];if(s){let i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}}else if(r.startsWith("--header=")){let s=r.slice(9),i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}else if(r==="-d"||r==="--data"||r==="--data-raw")e.data=t[++n]??"",e.method==="GET"&&(e.method="POST");else if(r.startsWith("-d"))e.data=r.slice(2),e.method==="GET"&&(e.method="POST");else if(r.startsWith("--data="))e.data=r.slice(7),e.method==="GET"&&(e.method="POST");else if(r.startsWith("--data-raw="))e.data=r.slice(11),e.method==="GET"&&(e.method="POST");else if(r==="--data-binary")e.data=t[++n]??"",e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(r.startsWith("--data-binary="))e.data=r.slice(14),e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(r==="--data-urlencode"){let s=t[++n]??"";e.data=(e.data?`${e.data}&`:"")+oi(s),e.method==="GET"&&(e.method="POST")}else if(r.startsWith("--data-urlencode=")){let s=r.slice(17);e.data=(e.data?`${e.data}&`:"")+oi(s),e.method==="GET"&&(e.method="POST")}else if(r==="-F"||r==="--form"){let s=t[++n]??"",i=ai(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(r.startsWith("--form=")){let s=r.slice(7),i=ai(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(r==="-u"||r==="--user")e.user=t[++n];else if(r.startsWith("-u"))e.user=r.slice(2);else if(r.startsWith("--user="))e.user=r.slice(7);else if(r==="-A"||r==="--user-agent")e.headers["User-Agent"]=t[++n]??"";else if(r.startsWith("-A"))e.headers["User-Agent"]=r.slice(2);else if(r.startsWith("--user-agent="))e.headers["User-Agent"]=r.slice(13);else if(r==="-e"||r==="--referer")e.headers.Referer=t[++n]??"";else if(r.startsWith("-e"))e.headers.Referer=r.slice(2);else if(r.startsWith("--referer="))e.headers.Referer=r.slice(10);else if(r==="-b"||r==="--cookie")e.headers.Cookie=t[++n]??"";else if(r.startsWith("-b"))e.headers.Cookie=r.slice(2);else if(r.startsWith("--cookie="))e.headers.Cookie=r.slice(9);else if(r==="-c"||r==="--cookie-jar")e.cookieJar=t[++n];else if(r.startsWith("--cookie-jar="))e.cookieJar=r.slice(13);else if(r==="-T"||r==="--upload-file")e.uploadFile=t[++n],e.method==="GET"&&(e.method="PUT");else if(r.startsWith("--upload-file="))e.uploadFile=r.slice(14),e.method==="GET"&&(e.method="PUT");else if(r==="-m"||r==="--max-time"){let s=parseFloat(t[++n]??"0");!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(r.startsWith("--max-time=")){let s=parseFloat(r.slice(11));!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(r==="--connect-timeout"){let s=parseFloat(t[++n]??"0");!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(r.startsWith("--connect-timeout=")){let s=parseFloat(r.slice(18));!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(r==="-o"||r==="--output")e.outputFile=t[++n];else if(r.startsWith("--output="))e.outputFile=r.slice(9);else if(r==="-O"||r==="--remote-name")e.useRemoteName=!0;else if(r==="-I"||r==="--head")e.headOnly=!0,e.method="HEAD";else if(r==="-i"||r==="--include")e.includeHeaders=!0;else if(r==="-s"||r==="--silent")e.silent=!0;else if(r==="-S"||r==="--show-error")e.showError=!0;else if(r==="-f"||r==="--fail")e.failSilently=!0;else if(r==="-L"||r==="--location")e.followRedirects=!0;else if(r==="--max-redirs")n++;else if(!r.startsWith("--max-redirs="))if(r==="-w"||r==="--write-out")e.writeOut=t[++n];else if(r.startsWith("--write-out="))e.writeOut=r.slice(12);else if(r==="-v"||r==="--verbose")e.verbose=!0;else{if(r.startsWith("--")&&r!=="--")return L("curl",r);if(r.startsWith("-")&&r!=="-")for(let s of r.slice(1))switch(s){case"s":e.silent=!0;break;case"S":e.showError=!0;break;case"f":e.failSilently=!0;break;case"L":e.followRedirects=!0;break;case"I":e.headOnly=!0,e.method="HEAD";break;case"i":e.includeHeaders=!0;break;case"O":e.useRemoteName=!0;break;case"v":e.verbose=!0;break;default:return L("curl",`-${s}`)}else r.startsWith("-")||(e.url=r)}}return e}var gf=C(()=>{"use strict";j();li()});function ci(t){return Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(`\r
632
+ `)}function yf(t){try{return new URL(t).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function ui(t,e){let n=t;return n=n.replace(/%\{http_code\}/g,String(e.status)),n=n.replace(/%\{content_type\}/g,e.headers["content-type"]||""),n=n.replace(/%\{url_effective\}/g,e.url),n=n.replace(/%\{size_download\}/g,String(e.bodyLength)),n=n.replace(/\\n/g,`
633
+ `),n}var xf=C(()=>{"use strict"});var wf={};_(wf,{curlCommand:()=>dx});async function lx(t,e){if(t.uploadFile){let n=e.fs.resolvePath(e.cwd,t.uploadFile);return{body:await e.fs.readFile(n)}}if(t.formFields.length>0){let n=new Map;for(let i of t.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let o=e.fs.resolvePath(e.cwd,i.value.slice(1));try{let a=await e.fs.readFile(o);n.set(i.value.slice(1),a)}catch{n.set(i.value.slice(1),"")}}let{body:r,boundary:s}=df(t.formFields,n);return{body:r,contentType:`multipart/form-data; boundary=${s}`}}return t.data!==void 0?{body:t.data}:{}}function cx(t,e){let n={...t.headers};if(t.user){let r=Buffer.from(t.user).toString("base64");n.Authorization=`Basic ${r}`}return e&&!n["Content-Type"]&&(n["Content-Type"]=e),n}async function ux(t,e,n){if(!t.cookieJar)return;let r=e["set-cookie"];if(!r)return;let s=n.fs.resolvePath(n.cwd,t.cookieJar);await n.fs.writeFile(s,r)}function fx(t,e,n){let r="";if(t.verbose){r+=`> ${t.method} ${n}
630
634
  `;for(let[s,i]of Object.entries(t.headers))r+=`> ${s}: ${i}
631
635
  `;r+=`>
632
636
  `,r+=`< HTTP/1.1 ${e.status} ${e.statusText}
633
637
  `;for(let[s,i]of Object.entries(e.headers))r+=`< ${s}: ${i}
634
638
  `;r+=`<
635
639
  `}return t.includeHeaders&&!t.verbose&&(r+=`HTTP/1.1 ${e.status} ${e.statusText}\r
636
- `,r+=ai(e.headers),r+=`\r
640
+ `,r+=ci(e.headers),r+=`\r
637
641
  \r
638
642
  `),t.headOnly?t.includeHeaders||t.verbose||(r+=`HTTP/1.1 ${e.status} ${e.statusText}\r
639
- `,r+=ai(e.headers),r+=`\r
640
- `):r+=e.body,t.writeOut&&(r+=li(t.writeOut,{status:e.status,headers:e.headers,url:e.url,bodyLength:e.body.length})),r}var sx,gf=C(()=>{"use strict";rt();j();oi();uf();df();hf();sx={name:"curl",async execute(t,e){if(I(t))return N(cf);let n=ff(t);if("exitCode"in n)return n;let r=n;if(!r.url)return{stdout:"",stderr:`curl: no URL specified
643
+ `,r+=ci(e.headers),r+=`\r
644
+ `):r+=e.body,t.writeOut&&(r+=ui(t.writeOut,{status:e.status,headers:e.headers,url:e.url,bodyLength:e.body.length})),r}var dx,bf=C(()=>{"use strict";rt();j();li();hf();gf();xf();dx={name:"curl",async execute(t,e){if(N(t))return k(pf);let n=mf(t);if("exitCode"in n)return n;let r=n;if(!r.url)return{stdout:"",stderr:`curl: no URL specified
641
645
  `,exitCode:2};if(!e.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
642
- `,exitCode:1};let s=r.url;s.match(/^https?:\/\//)||(s=`https://${s}`);try{let{body:i,contentType:o}=await ex(r,e),a=tx(r,o),l=await e.fetch(s,{method:r.method,headers:Object.keys(a).length>0?a:void 0,body:i,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs});if(await nx(r,l.headers,e),r.failSilently&&l.status>=400)return{stdout:"",stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${l.status}
643
- `:"",exitCode:22};let c=rx(r,l,s);if(r.outputFile||r.useRemoteName){let u=r.outputFile||pf(s),f=e.fs.resolvePath(e.cwd,u);await e.fs.writeFile(f,r.headOnly?"":l.body),r.verbose||(c=""),r.writeOut&&(c=li(r.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:c,stderr:"",exitCode:0}}catch(i){let o=ye(i),a=1;return o.includes("Network access denied")?a=7:o.includes("HTTP method")&&o.includes("not allowed")?a=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?a=47:o.includes("aborted")&&(a=28),{stdout:"",stderr:!r.silent||r.showError?`curl: (${a}) ${o}
644
- `:"",exitCode:a}}}}});var ci=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(lo(),ao))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(uo(),co))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(mo(),ho))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(wo(),xo))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(Eo(),bo))).mkdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Co(),So))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(ko(),Ao))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Io(),No))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>($o(),vo))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Po(),Ro))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(Oo(),To))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(Lo(),Do))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(_o(),Mo))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(jo(),Uo))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(Ho(),zo))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(Vo(),qo))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(Qo(),Ko))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(nr(),tr))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(nr(),tr))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(nr(),tr))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(ma(),ha))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(Ca(),Sa))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(qa(),Ga))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(nl(),tl))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(sl(),rl))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(ol(),il))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(ll(),al))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(fl(),ul))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(hl(),pl))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(gl(),ml))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(wl(),xl))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Sl(),El))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(kl(),Al))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>($l(),vl))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(Tl(),Fl))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Ll(),Dl))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Bl(),_l))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(Ul(),Wl))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(zl(),jl))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(Jl(),Xl))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(ec(),Yl))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(nc(),tc))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(ic(),sc))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(lc(),ac))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Ps(),Rs))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Ps(),Rs))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Ts(),Fs))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Ts(),Fs))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(fc(),uc))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(pc(),dc))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Ds(),Os))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Ds(),Os))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(mc(),hc))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(Ms(),Ls))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(Ms(),Ls))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Ic(),Nc))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Rc(),$c))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Tc(),Fc))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Dc(),Oc))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(Mc(),Lc))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(Bc(),_c))).timeoutCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Uc(),Wc))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(zc(),jc))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(qc(),Gc))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(Zc(),Vc))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(Qc(),Kc))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(zu(),ju))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(Gu(),Hu))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(Vu(),qu))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(Ku(),Zu))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(Xu(),Qu))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(Yu(),Ju))).hostname},{name:"od",load:async()=>(await Promise.resolve().then(()=>(tf(),ef))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>($r(),vr))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>($r(),vr))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>($r(),vr))).zcatCommand}],xf=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(gf(),mf))).curlCommand}],yf=new Map;function wf(t){return{name:t.name,async execute(e,n){let r=yf.get(t.name);return r||(r=await t.load(),yf.set(t.name,r)),r.execute(e,n)}}}function ix(){return ci.map(t=>t.name)}function ox(){return xf.map(t=>t.name)}function bf(t){return(t?ci.filter(n=>t.includes(n.name)):ci).map(wf)}function Ef(){return xf.map(wf)}function Sf(t){return"load"in t&&typeof t.load=="function"}function ax(t,e){return{name:t,execute:e}}function Cf(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var lx=new TextEncoder,cx=new TextDecoder;function ui(t,e){if(t instanceof Uint8Array)return t;if(e==="base64")return Uint8Array.from(atob(t),n=>n.charCodeAt(0));if(e==="hex"){let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}return e==="binary"||e==="latin1"?Uint8Array.from(t,n=>n.charCodeAt(0)):lx.encode(t)}function Af(t,e){return e==="base64"?btoa(String.fromCharCode(...t)):e==="hex"?Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join(""):e==="binary"||e==="latin1"?String.fromCharCode(...t):cx.decode(t)}function Rr(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Pr=new TextEncoder;function ux(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var _t=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))ux(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(i=>i&&i!=="."),s=[];for(let i of r)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let i=this.normalizePath(e);this.ensureParentDirs(i);let o=Rr(r),a=ui(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=Rr(n);return Af(r,s)}async readFileBuffer(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Pr.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=Rr(r),a=ui(n,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:Pr.encode(i.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:i.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){try{let n=this.resolvePathWithSymlinks(e);return this.data.has(n)}catch{return!1}}async stat(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Pr.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.resolveIntermediateSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Pr.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}resolveIntermediateSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=this.resolveSymlink(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=this.resolveSymlink(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),n=this.resolveSymlink(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),i=this.normalizePath(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var kf="5.1.0(1)-release",Nf="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Mn(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function If(){let{pid:t,ppid:e,uid:n,gid:r}=Mn();return`Name: bash
646
+ `,exitCode:1};let s=r.url;s.match(/^https?:\/\//)||(s=`https://${s}`);try{let{body:i,contentType:o}=await lx(r,e),a=cx(r,o),l=await e.fetch(s,{method:r.method,headers:Object.keys(a).length>0?a:void 0,body:i,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs});if(await ux(r,l.headers,e),r.failSilently&&l.status>=400)return{stdout:"",stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${l.status}
647
+ `:"",exitCode:22};let c=fx(r,l,s);if(r.outputFile||r.useRemoteName){let u=r.outputFile||yf(s),f=e.fs.resolvePath(e.cwd,u);await e.fs.writeFile(f,r.headOnly?"":l.body),r.verbose||(c=""),r.writeOut&&(c=ui(r.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:c,stderr:"",exitCode:0}}catch(i){let o=ye(i),a=1;return o.includes("Network access denied")?a=7:o.includes("HTTP method")&&o.includes("not allowed")?a=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?a=47:o.includes("aborted")&&(a=28),{stdout:"",stderr:!r.silent||r.showError?`curl: (${a}) ${o}
648
+ `:"",exitCode:a}}}}});var fi=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(uo(),co))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(po(),fo))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(yo(),go))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(Eo(),bo))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(Co(),So))).mkdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(ko(),Ao))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(Io(),No))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>($o(),vo))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(Fo(),Ro))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(To(),Po))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(Lo(),Do))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(_o(),Mo))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(Wo(),Bo))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(Ho(),zo))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(qo(),Go))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(Ko(),Zo))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(Jo(),Xo))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(sr(),rr))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(sr(),rr))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(sr(),rr))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(wa(),xa))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(Ia(),Na))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(Qa(),Ka))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(ol(),il))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(ll(),al))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(ul(),cl))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(dl(),fl))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(ml(),hl))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(xl(),yl))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(bl(),wl))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(Cl(),Sl))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Nl(),kl))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>($l(),vl))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(Tl(),Pl))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(Ml(),Ll))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Wl(),Bl))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(zl(),jl))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(Gl(),Hl))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Vl(),ql))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(nc(),tc))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(sc(),rc))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(oc(),ic))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(cc(),lc))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(dc(),fc))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Ts(),Ps))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Ts(),Ps))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Ds(),Os))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Ds(),Os))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(mc(),hc))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(yc(),gc))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Ms(),Ls))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Ms(),Ls))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(wc(),xc))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(Bs(),_s))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(Bs(),_s))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Fc(),Rc))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Oc(),Tc))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Mc(),Lc))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Bc(),_c))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(Uc(),Wc))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(zc(),jc))).timeoutCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Gc(),Hc))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(Vc(),qc))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(Qc(),Kc))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(Jc(),Xc))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(eu(),Yc))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(Vu(),qu))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(Ku(),Zu))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(Xu(),Qu))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(Yu(),Ju))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(tf(),ef))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(rf(),nf))).hostname},{name:"od",load:async()=>(await Promise.resolve().then(()=>(of(),sf))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Rr(),$r))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Rr(),$r))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Rr(),$r))).zcatCommand}],Sf=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(bf(),wf))).curlCommand}],Ef=new Map;function Cf(t){return{name:t.name,async execute(e,n){let r=Ef.get(t.name);return r||(r=await t.load(),Ef.set(t.name,r)),r.execute(e,n)}}}function px(){return fi.map(t=>t.name)}function hx(){return Sf.map(t=>t.name)}function Af(t){return(t?fi.filter(n=>t.includes(n.name)):fi).map(Cf)}function kf(){return Sf.map(Cf)}function Nf(t){return"load"in t&&typeof t.load=="function"}function mx(t,e){return{name:t,execute:e}}function If(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var gx=new TextEncoder,yx=new TextDecoder;function di(t,e){if(t instanceof Uint8Array)return t;if(e==="base64")return Uint8Array.from(atob(t),n=>n.charCodeAt(0));if(e==="hex"){let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}return e==="binary"||e==="latin1"?Uint8Array.from(t,n=>n.charCodeAt(0)):gx.encode(t)}function vf(t,e){return e==="base64"?btoa(String.fromCharCode(...t)):e==="hex"?Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join(""):e==="binary"||e==="latin1"?String.fromCharCode(...t):yx.decode(t)}function Fr(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Pr=new TextEncoder;function xx(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Bt=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))xx(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(i=>i&&i!=="."),s=[];for(let i of r)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let i=this.normalizePath(e);this.ensureParentDirs(i);let o=Fr(r),a=di(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=Fr(n);return vf(r,s)}async readFileBuffer(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Pr.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=Fr(r),a=di(n,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:Pr.encode(i.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:i.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){try{let n=this.resolvePathWithSymlinks(e);return this.data.has(n)}catch{return!1}}async stat(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Pr.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.resolveIntermediateSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Pr.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}resolveIntermediateSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=this.resolveSymlink(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=this.resolveSymlink(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),n=this.resolveSymlink(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),i=this.normalizePath(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var $f="5.1.0(1)-release",Rf="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function Bn(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function Ff(){let{pid:t,ppid:e,uid:n,gid:r}=Bn();return`Name: bash
645
649
  State: R (running)
646
650
  Pid: ${t}
647
651
  PPid: ${e}
648
652
  Uid: ${n} ${n} ${n} ${n}
649
653
  Gid: ${r} ${r} ${r} ${r}
650
- `}function fx(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function dx(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function px(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function hx(t){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${Nf}
654
+ `}function wx(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function bx(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function Ex(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function Sx(t){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${Rf}
651
655
  `),t.writeFileSync("/proc/self/exe","/bin/bash"),t.writeFileSync("/proc/self/cmdline","bash\0"),t.writeFileSync("/proc/self/comm",`bash
652
- `),t.writeFileSync("/proc/self/status",If()),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function vf(t,e){fx(t)&&(dx(t,e),px(t),hx(t))}fe();var mx=["tar","yq","xan","sqlite3"];function $f(t){return mx.includes(t)}fe();function ve(t,e){return{type:"ArithmeticExpression",expression:ft(t,e,0).expr}}function ft(t,e,n){return gx(t,e,n)}function gx(t,e,n){let{expr:r,pos:s}=Tr(t,e,n);for(s=xe(e,s);e[s]===",";){s++;let{expr:i,pos:o}=Tr(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:i},s=xe(e,o)}return{expr:r,pos:s}}function Tr(t,e,n){let{expr:r,pos:s}=yx(t,e,n);if(s=xe(e,s),e[s]==="?"){s++;let{expr:i,pos:o}=ft(t,e,s);if(s=xe(e,o),e[s]===":"){s++;let{expr:a,pos:l}=ft(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:a},pos:l}}}return{expr:r,pos:s}}function yx(t,e,n){let{expr:r,pos:s}=Rf(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:i,pos:o}=Rf(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:i},s=o}return{expr:r,pos:s}}function Rf(t,e,n){let{expr:r,pos:s}=Pf(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:i,pos:o}=Pf(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:i},s=o}return{expr:r,pos:s}}function Pf(t,e,n){let{expr:r,pos:s}=Ff(t,e,n);for(;s=xe(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:i,pos:o}=Ff(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:i},s=o}return{expr:r,pos:s}}function Ff(t,e,n){let{expr:r,pos:s}=Tf(t,e,n);for(;s=xe(e,s),e[s]==="^";){s++;let{expr:i,pos:o}=Tf(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:i},s=o}return{expr:r,pos:s}}function Tf(t,e,n){let{expr:r,pos:s}=Of(t,e,n);for(;s=xe(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:i,pos:o}=Of(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:i},s=o}return{expr:r,pos:s}}function Of(t,e,n){let{expr:r,pos:s}=Df(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Df(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Df(t,e,n){let{expr:r,pos:s}=fi(t,e,n);for(;;)if(s=xe(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=fi(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else if(e[s]==="<"||e[s]===">"){let i=e[s];s++;let{expr:o,pos:a}=fi(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function fi(t,e,n){let{expr:r,pos:s}=Lf(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Lf(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Lf(t,e,n){let{expr:r,pos:s}=Mf(t,e,n);for(;s=xe(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let i=e[s];s++;let{expr:o,pos:a}=Mf(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Mf(t,e,n){let{expr:r,pos:s}=Fr(t,e,n);for(;;)if(s=xe(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:i,pos:o}=Fr(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:i},s=o}else if(e[s]==="/"||e[s]==="%"){let i=e[s];s++;let{expr:o,pos:a}=Fr(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function Fr(t,e,n){let{expr:r,pos:s}=di(t,e,n),i=xe(e,s);if(e.slice(i,i+2)==="**"){i+=2;let{expr:o,pos:a}=Fr(t,e,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:o},pos:a}}return{expr:r,pos:s}}function di(t,e,n){let r=xe(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:i,pos:o}=di(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:i,pos:o}=di(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return wx(t,e,r)}function xx(t,e){let n=t[e];return n==="$"||n==="`"}function wx(t,e,n){let{expr:r,pos:s}=_f(t,e,n),i=[r];for(;xx(e,s);){let{expr:o,pos:a}=_f(t,e,s);i.push(o),s=a}if(i.length>1&&(r={type:"ArithConcat",parts:i}),s=xe(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let o=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:o,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function _f(t,e,n){let r=xe(e,n);if(e.slice(r,r+3)==="$(("){r+=3;let s=1,i=r;for(;r<e.length-1&&s>0;)e[r]==="("&&e[r+1]==="("?(s++,r+=2):e[r]===")"&&e[r+1]===")"?(s--,s>0&&(r+=2)):r++;let o=e.slice(i,r),{expr:a}=ft(t,o,0);return r+=2,{expr:{type:"ArithNested",expression:a},pos:r}}if(e.slice(r,r+2)==="$("&&e[r+2]!=="("){r+=2;let s=1,i=r;for(;r<e.length&&s>0;)e[r]==="("?s++:e[r]===")"&&s--,s>0&&r++;let o=e.slice(i,r);return r++,{expr:{type:"ArithCommandSubst",command:o},pos:r}}if(e[r]==="`"){r++;let s=r;for(;r<e.length&&e[r]!=="`";)r++;let i=e.slice(s,r);return e[r]==="`"&&r++,{expr:{type:"ArithCommandSubst",command:i},pos:r}}if(e[r]==="("){r++;let{expr:s,pos:i}=ft(t,e,r);return r=xe(e,i),e[r]===")"&&r++,{expr:{type:"ArithGroup",expression:s},pos:r}}if(/[0-9]/.test(e[r])){let s="",i=!1;for(;r<e.length;){let a=e[r];if(i)if(/[0-9a-zA-Z@_]/.test(a))s+=a,r++;else break;else if(a==="#")i=!0,s+=a,r++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,r++;else break}if(e[r]==="."&&/[0-9]/.test(e[r+1]))throw new ke(`${s}.${e[r+1]}...: syntax error: invalid arithmetic operator`);if(e[r]==="["){let a=e.slice(r).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:cn(s)},pos:r}}if(e[r]==="$"&&e[r+1]==="{"){let s=r+2,i=1,o=s;for(;o<e.length&&i>0;)e[o]==="{"?i++:e[o]==="}"&&i--,i>0&&o++;let a=e.slice(s,o),l=o+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let u=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:u},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let u=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:u},pos:c}}return r=l,{expr:{type:"ArithBracedExpansion",content:a},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[0-9]/.test(e[r+1])){r++;let s="";for(;r<e.length&&/[0-9]/.test(e[r]);)s+=e[r],r++;return{expr:{type:"ArithVariable",name:s},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[a-zA-Z_]/.test(e[r+1])&&r++,/[a-zA-Z_]/.test(e[r])){let s="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)s+=e[r],r++;if(e[r]==="["){r++;let o;if(e[r]==="'"||e[r]==='"'){let c=e[r];for(r++,o="";r<e.length&&e[r]!==c;)o+=e[r],r++;e[r]===c&&r++,r=xe(e,r),e[r]==="]"&&r++}let a;if(o===void 0){let{expr:c,pos:u}=ft(t,e,r);a=c,r=u,e[r]==="]"&&r++}if(r=xe(e,r),e[r]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:r};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(r,r+c.length)===c&&e.slice(r,r+c.length+1)!=="=="){r+=c.length;let{expr:u,pos:f}=Tr(t,e,r);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:o,value:u},pos:f}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:o},pos:r}}r=xe(e,r);let i=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let o of i)if(e.slice(r,r+o.length)===o&&e.slice(r,r+o.length+1)!=="=="){r+=o.length;let{expr:a,pos:l}=Tr(t,e,r);return{expr:{type:"ArithAssignment",operator:o,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:r}}return{expr:{type:"ArithNumber",value:0},pos:r}}function cn(t){if(t.includes("#")){let[e,n]=t.split("#"),r=Number.parseInt(e,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let i of n){let o;if(i>="0"&&i<="9")o=i.charCodeAt(0)-48;else if(i>="a"&&i<="z")o=i.charCodeAt(0)-97+10;else if(i>="A"&&i<="Z")o=i.charCodeAt(0)-65+36;else if(i==="@")o=62;else if(i==="_")o=63;else return Number.NaN;if(o>=r)return Number.NaN;s=s*r+o}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function xe(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
653
- `){e+=2;continue}if(/\s/.test(t[e])){e++;continue}break}return e}var B={script(t){return{type:"Script",statements:t}},statement(t,e=[],n=!1){return{type:"Statement",pipelines:t,operators:e,background:n}},pipeline(t,e=!1){return{type:"Pipeline",commands:t,negated:e}},simpleCommand(t,e=[],n=[],r=[]){return{type:"SimpleCommand",name:t,args:e,assignments:n,redirections:r}},word(t){return{type:"Word",parts:t}},literal(t){return{type:"Literal",value:t}},singleQuoted(t){return{type:"SingleQuoted",value:t}},doubleQuoted(t){return{type:"DoubleQuoted",parts:t}},escaped(t){return{type:"Escaped",value:t}},parameterExpansion(t,e=null){return{type:"ParameterExpansion",parameter:t,operation:e}},commandSubstitution(t,e=!1){return{type:"CommandSubstitution",body:t,legacy:e}},arithmeticExpansion(t){return{type:"ArithmeticExpansion",expression:t}},assignment(t,e,n=!1,r=null){return{type:"Assignment",name:t,value:e,append:n,array:r}},redirection(t,e,n=null){return{type:"Redirection",fd:n,operator:t,target:e}},hereDoc(t,e,n=!1,r=!1){return{type:"HereDoc",delimiter:t,content:e,stripTabs:n,quoted:r}},ifNode(t,e=null,n=[]){return{type:"If",clauses:t,elseBody:e,redirections:n}},forNode(t,e,n,r=[]){return{type:"For",variable:t,words:e,body:n,redirections:r}},whileNode(t,e,n=[]){return{type:"While",condition:t,body:e,redirections:n}},untilNode(t,e,n=[]){return{type:"Until",condition:t,body:e,redirections:n}},caseNode(t,e,n=[]){return{type:"Case",word:t,items:e,redirections:n}},caseItem(t,e,n=";;"){return{type:"CaseItem",patterns:t,body:e,terminator:n}},subshell(t,e=[]){return{type:"Subshell",body:t,redirections:e}},group(t,e=[]){return{type:"Group",body:t,redirections:e}},functionDef(t,e,n=[]){return{type:"FunctionDef",name:t,body:e,redirections:n}},conditionalCommand(t,e=[]){return{type:"ConditionalCommand",expression:t,redirections:e}},arithmeticCommand(t,e=[]){return{type:"ArithmeticCommand",expression:t,redirections:e}}};var y;(function(t){t.EOF="EOF",t.NEWLINE="NEWLINE",t.SEMICOLON="SEMICOLON",t.AMP="AMP",t.PIPE="PIPE",t.PIPE_AMP="PIPE_AMP",t.AND_AND="AND_AND",t.OR_OR="OR_OR",t.BANG="BANG",t.LESS="LESS",t.GREAT="GREAT",t.DLESS="DLESS",t.DGREAT="DGREAT",t.LESSAND="LESSAND",t.GREATAND="GREATAND",t.LESSGREAT="LESSGREAT",t.DLESSDASH="DLESSDASH",t.CLOBBER="CLOBBER",t.TLESS="TLESS",t.AND_GREAT="AND_GREAT",t.AND_DGREAT="AND_DGREAT",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.DSEMI="DSEMI",t.SEMI_AND="SEMI_AND",t.SEMI_SEMI_AND="SEMI_SEMI_AND",t.DBRACK_START="DBRACK_START",t.DBRACK_END="DBRACK_END",t.DPAREN_START="DPAREN_START",t.DPAREN_END="DPAREN_END",t.IF="IF",t.THEN="THEN",t.ELSE="ELSE",t.ELIF="ELIF",t.FI="FI",t.FOR="FOR",t.WHILE="WHILE",t.UNTIL="UNTIL",t.DO="DO",t.DONE="DONE",t.CASE="CASE",t.ESAC="ESAC",t.IN="IN",t.FUNCTION="FUNCTION",t.SELECT="SELECT",t.TIME="TIME",t.COPROC="COPROC",t.WORD="WORD",t.NAME="NAME",t.NUMBER="NUMBER",t.ASSIGNMENT_WORD="ASSIGNMENT_WORD",t.COMMENT="COMMENT",t.HEREDOC_CONTENT="HEREDOC_CONTENT"})(y||(y={}));var Or={if:y.IF,then:y.THEN,else:y.ELSE,elif:y.ELIF,fi:y.FI,for:y.FOR,while:y.WHILE,until:y.UNTIL,do:y.DO,done:y.DONE,case:y.CASE,esac:y.ESAC,in:y.IN,function:y.FUNCTION,select:y.SELECT,time:y.TIME,coproc:y.COPROC};function Wf(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return!1;let n=t.slice(e[0].length);if(n===""||n==="+")return!0;if(n[0]==="["){let r=0,s=0;for(;s<n.length;s++)if(n[s]==="[")r++;else if(n[s]==="]"&&(r--,r===0))break;if(r!==0||s>=n.length)return!1;let i=n.slice(s+1);return i===""||i==="+"}return!1}var bx=[[";",";","&",y.SEMI_SEMI_AND],["<","<","<",y.TLESS],["&",">",">",y.AND_DGREAT]],Ex=[["[","[",y.DBRACK_START],["]","]",y.DBRACK_END],["(","(",y.DPAREN_START],[")",")",y.DPAREN_END],["&","&",y.AND_AND],["|","|",y.OR_OR],[";",";",y.DSEMI],[";","&",y.SEMI_AND],["|","&",y.PIPE_AMP],[">",">",y.DGREAT],["<","&",y.LESSAND],[">","&",y.GREATAND],["<",">",y.LESSGREAT],[">","|",y.CLOBBER],["&",">",y.AND_GREAT]],Sx={"|":y.PIPE,"&":y.AMP,";":y.SEMICOLON,"(":y.LPAREN,")":y.RPAREN,"<":y.LESS,">":y.GREAT};function Cx(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}var Dr=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];constructor(e){this.input=e}tokenize(){let n=this.input.length,r=this.tokens,s=this.pendingHeredocs;for(;this.pos<n&&(this.skipWhitespace(),!(this.pos>=n));){if(s.length>0&&r.length>0&&r[r.length-1].type===y.NEWLINE){this.readHeredocContent();continue}let i=this.nextToken();i&&r.push(i)}return r.push({type:y.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),r}skipWhitespace(){let e=this.input,n=e.length,r=this.pos,s=this.column,i=this.line;for(;r<n;){let o=e[r];if(o===" "||o===" ")r++,s++;else if(o==="\\"&&e[r+1]===`
656
+ `),t.writeFileSync("/proc/self/status",Ff()),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function Pf(t,e){wx(t)&&(bx(t,e),Ex(t),Sx(t))}de();var Cx=["tar","yq","xan","sqlite3"];function Tf(t){return Cx.includes(t)}de();function ve(t,e){return{type:"ArithmeticExpression",expression:dt(t,e,0).expr}}function dt(t,e,n){return Ax(t,e,n)}function Ax(t,e,n){let{expr:r,pos:s}=Or(t,e,n);for(s=xe(e,s);e[s]===",";){s++;let{expr:i,pos:o}=Or(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:i},s=xe(e,o)}return{expr:r,pos:s}}function Or(t,e,n){let{expr:r,pos:s}=kx(t,e,n);if(s=xe(e,s),e[s]==="?"){s++;let{expr:i,pos:o}=dt(t,e,s);if(s=xe(e,o),e[s]===":"){s++;let{expr:a,pos:l}=dt(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:a},pos:l}}}return{expr:r,pos:s}}function kx(t,e,n){let{expr:r,pos:s}=Of(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:i,pos:o}=Of(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:i},s=o}return{expr:r,pos:s}}function Of(t,e,n){let{expr:r,pos:s}=Df(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:i,pos:o}=Df(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:i},s=o}return{expr:r,pos:s}}function Df(t,e,n){let{expr:r,pos:s}=Lf(t,e,n);for(;s=xe(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:i,pos:o}=Lf(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:i},s=o}return{expr:r,pos:s}}function Lf(t,e,n){let{expr:r,pos:s}=Mf(t,e,n);for(;s=xe(e,s),e[s]==="^";){s++;let{expr:i,pos:o}=Mf(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:i},s=o}return{expr:r,pos:s}}function Mf(t,e,n){let{expr:r,pos:s}=_f(t,e,n);for(;s=xe(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:i,pos:o}=_f(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:i},s=o}return{expr:r,pos:s}}function _f(t,e,n){let{expr:r,pos:s}=Bf(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Bf(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Bf(t,e,n){let{expr:r,pos:s}=pi(t,e,n);for(;;)if(s=xe(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=pi(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else if(e[s]==="<"||e[s]===">"){let i=e[s];s++;let{expr:o,pos:a}=pi(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function pi(t,e,n){let{expr:r,pos:s}=Wf(t,e,n);for(;s=xe(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Wf(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Wf(t,e,n){let{expr:r,pos:s}=Uf(t,e,n);for(;s=xe(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let i=e[s];s++;let{expr:o,pos:a}=Uf(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Uf(t,e,n){let{expr:r,pos:s}=Tr(t,e,n);for(;;)if(s=xe(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:i,pos:o}=Tr(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:i},s=o}else if(e[s]==="/"||e[s]==="%"){let i=e[s];s++;let{expr:o,pos:a}=Tr(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function Tr(t,e,n){let{expr:r,pos:s}=hi(t,e,n),i=xe(e,s);if(e.slice(i,i+2)==="**"){i+=2;let{expr:o,pos:a}=Tr(t,e,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:o},pos:a}}return{expr:r,pos:s}}function hi(t,e,n){let r=xe(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:i,pos:o}=hi(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:i,pos:o}=hi(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return Ix(t,e,r)}function Nx(t,e){let n=t[e];return n==="$"||n==="`"}function Ix(t,e,n){let{expr:r,pos:s}=jf(t,e,n),i=[r];for(;Nx(e,s);){let{expr:o,pos:a}=jf(t,e,s);i.push(o),s=a}if(i.length>1&&(r={type:"ArithConcat",parts:i}),s=xe(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let o=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:o,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function jf(t,e,n){let r=xe(e,n);if(e.slice(r,r+3)==="$(("){r+=3;let s=1,i=r;for(;r<e.length-1&&s>0;)e[r]==="("&&e[r+1]==="("?(s++,r+=2):e[r]===")"&&e[r+1]===")"?(s--,s>0&&(r+=2)):r++;let o=e.slice(i,r),{expr:a}=dt(t,o,0);return r+=2,{expr:{type:"ArithNested",expression:a},pos:r}}if(e.slice(r,r+2)==="$("&&e[r+2]!=="("){r+=2;let s=1,i=r;for(;r<e.length&&s>0;)e[r]==="("?s++:e[r]===")"&&s--,s>0&&r++;let o=e.slice(i,r);return r++,{expr:{type:"ArithCommandSubst",command:o},pos:r}}if(e[r]==="`"){r++;let s=r;for(;r<e.length&&e[r]!=="`";)r++;let i=e.slice(s,r);return e[r]==="`"&&r++,{expr:{type:"ArithCommandSubst",command:i},pos:r}}if(e[r]==="("){r++;let{expr:s,pos:i}=dt(t,e,r);return r=xe(e,i),e[r]===")"&&r++,{expr:{type:"ArithGroup",expression:s},pos:r}}if(/[0-9]/.test(e[r])){let s="",i=!1;for(;r<e.length;){let a=e[r];if(i)if(/[0-9a-zA-Z@_]/.test(a))s+=a,r++;else break;else if(a==="#")i=!0,s+=a,r++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,r++;else break}if(e[r]==="."&&/[0-9]/.test(e[r+1]))throw new ke(`${s}.${e[r+1]}...: syntax error: invalid arithmetic operator`);if(e[r]==="["){let a=e.slice(r).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:un(s)},pos:r}}if(e[r]==="$"&&e[r+1]==="{"){let s=r+2,i=1,o=s;for(;o<e.length&&i>0;)e[o]==="{"?i++:e[o]==="}"&&i--,i>0&&o++;let a=e.slice(s,o),l=o+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let u=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:u},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let u=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:u},pos:c}}return r=l,{expr:{type:"ArithBracedExpansion",content:a},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[0-9]/.test(e[r+1])){r++;let s="";for(;r<e.length&&/[0-9]/.test(e[r]);)s+=e[r],r++;return{expr:{type:"ArithVariable",name:s},pos:r}}if(e[r]==="$"&&r+1<e.length&&/[a-zA-Z_]/.test(e[r+1])&&r++,/[a-zA-Z_]/.test(e[r])){let s="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)s+=e[r],r++;if(e[r]==="["){r++;let o;if(e[r]==="'"||e[r]==='"'){let c=e[r];for(r++,o="";r<e.length&&e[r]!==c;)o+=e[r],r++;e[r]===c&&r++,r=xe(e,r),e[r]==="]"&&r++}let a;if(o===void 0){let{expr:c,pos:u}=dt(t,e,r);a=c,r=u,e[r]==="]"&&r++}if(r=xe(e,r),e[r]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:r};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(r,r+c.length)===c&&e.slice(r,r+c.length+1)!=="=="){r+=c.length;let{expr:u,pos:f}=Or(t,e,r);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:o,value:u},pos:f}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:o},pos:r}}r=xe(e,r);let i=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let o of i)if(e.slice(r,r+o.length)===o&&e.slice(r,r+o.length+1)!=="=="){r+=o.length;let{expr:a,pos:l}=Or(t,e,r);return{expr:{type:"ArithAssignment",operator:o,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:r}}return{expr:{type:"ArithNumber",value:0},pos:r}}function un(t){if(t.includes("#")){let[e,n]=t.split("#"),r=Number.parseInt(e,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let i of n){let o;if(i>="0"&&i<="9")o=i.charCodeAt(0)-48;else if(i>="a"&&i<="z")o=i.charCodeAt(0)-97+10;else if(i>="A"&&i<="Z")o=i.charCodeAt(0)-65+36;else if(i==="@")o=62;else if(i==="_")o=63;else return Number.NaN;if(o>=r)return Number.NaN;s=s*r+o}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function xe(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
657
+ `){e+=2;continue}if(/\s/.test(t[e])){e++;continue}break}return e}var B={script(t){return{type:"Script",statements:t}},statement(t,e=[],n=!1){return{type:"Statement",pipelines:t,operators:e,background:n}},pipeline(t,e=!1){return{type:"Pipeline",commands:t,negated:e}},simpleCommand(t,e=[],n=[],r=[]){return{type:"SimpleCommand",name:t,args:e,assignments:n,redirections:r}},word(t){return{type:"Word",parts:t}},literal(t){return{type:"Literal",value:t}},singleQuoted(t){return{type:"SingleQuoted",value:t}},doubleQuoted(t){return{type:"DoubleQuoted",parts:t}},escaped(t){return{type:"Escaped",value:t}},parameterExpansion(t,e=null){return{type:"ParameterExpansion",parameter:t,operation:e}},commandSubstitution(t,e=!1){return{type:"CommandSubstitution",body:t,legacy:e}},arithmeticExpansion(t){return{type:"ArithmeticExpansion",expression:t}},assignment(t,e,n=!1,r=null){return{type:"Assignment",name:t,value:e,append:n,array:r}},redirection(t,e,n=null){return{type:"Redirection",fd:n,operator:t,target:e}},hereDoc(t,e,n=!1,r=!1){return{type:"HereDoc",delimiter:t,content:e,stripTabs:n,quoted:r}},ifNode(t,e=null,n=[]){return{type:"If",clauses:t,elseBody:e,redirections:n}},forNode(t,e,n,r=[]){return{type:"For",variable:t,words:e,body:n,redirections:r}},whileNode(t,e,n=[]){return{type:"While",condition:t,body:e,redirections:n}},untilNode(t,e,n=[]){return{type:"Until",condition:t,body:e,redirections:n}},caseNode(t,e,n=[]){return{type:"Case",word:t,items:e,redirections:n}},caseItem(t,e,n=";;"){return{type:"CaseItem",patterns:t,body:e,terminator:n}},subshell(t,e=[]){return{type:"Subshell",body:t,redirections:e}},group(t,e=[]){return{type:"Group",body:t,redirections:e}},functionDef(t,e,n=[]){return{type:"FunctionDef",name:t,body:e,redirections:n}},conditionalCommand(t,e=[]){return{type:"ConditionalCommand",expression:t,redirections:e}},arithmeticCommand(t,e=[]){return{type:"ArithmeticCommand",expression:t,redirections:e}}};var y;(function(t){t.EOF="EOF",t.NEWLINE="NEWLINE",t.SEMICOLON="SEMICOLON",t.AMP="AMP",t.PIPE="PIPE",t.PIPE_AMP="PIPE_AMP",t.AND_AND="AND_AND",t.OR_OR="OR_OR",t.BANG="BANG",t.LESS="LESS",t.GREAT="GREAT",t.DLESS="DLESS",t.DGREAT="DGREAT",t.LESSAND="LESSAND",t.GREATAND="GREATAND",t.LESSGREAT="LESSGREAT",t.DLESSDASH="DLESSDASH",t.CLOBBER="CLOBBER",t.TLESS="TLESS",t.AND_GREAT="AND_GREAT",t.AND_DGREAT="AND_DGREAT",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.DSEMI="DSEMI",t.SEMI_AND="SEMI_AND",t.SEMI_SEMI_AND="SEMI_SEMI_AND",t.DBRACK_START="DBRACK_START",t.DBRACK_END="DBRACK_END",t.DPAREN_START="DPAREN_START",t.DPAREN_END="DPAREN_END",t.IF="IF",t.THEN="THEN",t.ELSE="ELSE",t.ELIF="ELIF",t.FI="FI",t.FOR="FOR",t.WHILE="WHILE",t.UNTIL="UNTIL",t.DO="DO",t.DONE="DONE",t.CASE="CASE",t.ESAC="ESAC",t.IN="IN",t.FUNCTION="FUNCTION",t.SELECT="SELECT",t.TIME="TIME",t.COPROC="COPROC",t.WORD="WORD",t.NAME="NAME",t.NUMBER="NUMBER",t.ASSIGNMENT_WORD="ASSIGNMENT_WORD",t.COMMENT="COMMENT",t.HEREDOC_CONTENT="HEREDOC_CONTENT"})(y||(y={}));var Dr={if:y.IF,then:y.THEN,else:y.ELSE,elif:y.ELIF,fi:y.FI,for:y.FOR,while:y.WHILE,until:y.UNTIL,do:y.DO,done:y.DONE,case:y.CASE,esac:y.ESAC,in:y.IN,function:y.FUNCTION,select:y.SELECT,time:y.TIME,coproc:y.COPROC};function Hf(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return!1;let n=t.slice(e[0].length);if(n===""||n==="+")return!0;if(n[0]==="["){let r=0,s=0;for(;s<n.length;s++)if(n[s]==="[")r++;else if(n[s]==="]"&&(r--,r===0))break;if(r!==0||s>=n.length)return!1;let i=n.slice(s+1);return i===""||i==="+"}return!1}var vx=[[";",";","&",y.SEMI_SEMI_AND],["<","<","<",y.TLESS],["&",">",">",y.AND_DGREAT]],$x=[["[","[",y.DBRACK_START],["]","]",y.DBRACK_END],["(","(",y.DPAREN_START],[")",")",y.DPAREN_END],["&","&",y.AND_AND],["|","|",y.OR_OR],[";",";",y.DSEMI],[";","&",y.SEMI_AND],["|","&",y.PIPE_AMP],[">",">",y.DGREAT],["<","&",y.LESSAND],[">","&",y.GREATAND],["<",">",y.LESSGREAT],[">","|",y.CLOBBER],["&",">",y.AND_GREAT]],Rx={"|":y.PIPE,"&":y.AMP,";":y.SEMICOLON,"(":y.LPAREN,")":y.RPAREN,"<":y.LESS,">":y.GREAT};function Fx(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}var Lr=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];constructor(e){this.input=e}tokenize(){let n=this.input.length,r=this.tokens,s=this.pendingHeredocs;for(;this.pos<n&&(this.skipWhitespace(),!(this.pos>=n));){if(s.length>0&&r.length>0&&r[r.length-1].type===y.NEWLINE){this.readHeredocContent();continue}let i=this.nextToken();i&&r.push(i)}return r.push({type:y.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),r}skipWhitespace(){let e=this.input,n=e.length,r=this.pos,s=this.column,i=this.line;for(;r<n;){let o=e[r];if(o===" "||o===" ")r++,s++;else if(o==="\\"&&e[r+1]===`
654
658
  `)r+=2,i++,s=1;else break}this.pos=r,this.column=s,this.line=i}nextToken(){let e=this.input,n=this.pos,r=this.line,s=this.column,i=e[n],o=e[n+1],a=e[n+2];if(i==="#")return this.readComment(n,r,s);if(i===`
655
659
  `)return this.pos=n+1,this.line++,this.column=1,{type:y.NEWLINE,value:`
656
- `,start:n,end:n+1,line:r,column:s};if(i==="<"&&o==="<"&&a==="-")return this.pos=n+3,this.column=s+3,this.registerHeredocFromLookahead(!0),this.makeToken(y.DLESSDASH,"<<-",n,r,s);for(let[c,u,f,d]of bx)if(i===c&&o===u&&a===f)return this.pos=n+3,this.column=s+3,this.makeToken(d,c+u+f,n,r,s);if(i==="<"&&o==="<")return this.pos=n+2,this.column=s+2,this.registerHeredocFromLookahead(!1),this.makeToken(y.DLESS,"<<",n,r,s);for(let[c,u,f]of Ex)if(i===c&&o===u)return this.pos=n+2,this.column=s+2,this.makeToken(f,c+u,n,r,s);let l=Sx[i];return l?(this.pos=n+1,this.column=s+1,this.makeToken(l,i,n,r,s)):i==="{"?o==="}"?(this.pos=n+2,this.column=s+2,{type:y.WORD,value:"{}",start:n,end:n+2,line:r,column:s,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(n)!==null?this.readWordWithBraceExpansion(n,r,s):this.scanLiteralBraceWord(n)!==null?this.readWordWithBraceExpansion(n,r,s):o!==void 0&&o!==" "&&o!==" "&&o!==`
660
+ `,start:n,end:n+1,line:r,column:s};if(i==="<"&&o==="<"&&a==="-")return this.pos=n+3,this.column=s+3,this.registerHeredocFromLookahead(!0),this.makeToken(y.DLESSDASH,"<<-",n,r,s);for(let[c,u,f,d]of vx)if(i===c&&o===u&&a===f)return this.pos=n+3,this.column=s+3,this.makeToken(d,c+u+f,n,r,s);if(i==="<"&&o==="<")return this.pos=n+2,this.column=s+2,this.registerHeredocFromLookahead(!1),this.makeToken(y.DLESS,"<<",n,r,s);for(let[c,u,f]of $x)if(i===c&&o===u)return this.pos=n+2,this.column=s+2,this.makeToken(f,c+u,n,r,s);let l=Rx[i];return l?(this.pos=n+1,this.column=s+1,this.makeToken(l,i,n,r,s)):i==="{"?o==="}"?(this.pos=n+2,this.column=s+2,{type:y.WORD,value:"{}",start:n,end:n+2,line:r,column:s,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(n)!==null?this.readWordWithBraceExpansion(n,r,s):this.scanLiteralBraceWord(n)!==null?this.readWordWithBraceExpansion(n,r,s):o!==void 0&&o!==" "&&o!==" "&&o!==`
657
661
  `?this.readWord(n,r,s):(this.pos=n+1,this.column=s+1,this.makeToken(y.LBRACE,"{",n,r,s)):i==="}"?this.isWordCharFollowing(n+1)?this.readWord(n,r,s):(this.pos=n+1,this.column=s+1,this.makeToken(y.RBRACE,"}",n,r,s)):i==="!"?o==="="?(this.pos=n+2,this.column=s+2,this.makeToken(y.WORD,"!=",n,r,s)):(this.pos=n+1,this.column=s+1,this.makeToken(y.BANG,"!",n,r,s)):this.readWord(n,r,s)}makeToken(e,n,r,s,i){return{type:e,value:n,start:r,end:this.pos,line:s,column:i}}readComment(e,n,r){let s=this.input,i=s.length,o=this.pos;for(;o<i&&s[o]!==`
658
662
  `;)o++;let a=s.slice(e,o);return this.pos=o,this.column=r+(o-e),{type:y.COMMENT,value:a,start:e,end:o,line:n,column:r}}readWord(e,n,r){let s=this.input,i=s.length,o=this.pos,a=o;for(;o<i;){let g=s[o];if(g===" "||g===" "||g===`
659
663
  `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"||g==="'"||g==='"'||g==="\\"||g==="$"||g==="`"||g==="{"||g==="}"||g==="~"||g==="*"||g==="?"||g==="[")break;o++}if(o>a){let g=s[o];if(o>=i||g===" "||g===" "||g===`
660
- `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"){let w=s.slice(a,o);if(this.pos=o,this.column=r+(o-a),Or[w])return{type:Or[w],value:w,start:e,end:o,line:n,column:r};let b=w.indexOf("=");return b>0&&Wf(w.slice(0,b))?{type:y.ASSIGNMENT_WORD,value:w,start:e,end:o,line:n,column:r}:/^[0-9]+$/.test(w)?{type:y.NUMBER,value:w,start:e,end:o,line:n,column:r}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)?{type:y.NAME,value:w,start:e,end:o,line:n,column:r,quoted:!1,singleQuoted:!1}:{type:y.WORD,value:w,start:e,end:o,line:n,column:r,quoted:!1,singleQuoted:!1}}}o=this.pos;let l=this.column,c=this.line,u="",f=!1,d=!1,p=!1,h=!1,m=s[o]==='"'||s[o]==="'";for(;o<i;){let g=s[o];if(!p&&!h&&(g===" "||g===" "||g===`
661
- `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"))break;if(g==="$"&&o+1<i&&s[o+1]==="'"&&!p&&!h){for(u+="$'",o+=2,l+=2;o<i&&s[o]!=="'";)s[o]==="\\"&&o+1<i?(u+=s[o]+s[o+1],o+=2,l+=2):(u+=s[o],o++,l++);o<i&&(u+="'",o++,l++);continue}if(g==="$"&&o+1<i&&s[o+1]==='"'&&!p&&!h){o++,l++,h=!0,f=!0,u===""&&(m=!0),o++,l++;continue}if(g==="'"&&!h){p?(p=!1,m||(u+=g)):(p=!0,m?(d=!0,f=!0):u+=g),o++,l++;continue}if(g==='"'&&!p){h?(h=!1,m||(u+=g)):(h=!0,m?f=!0:u+=g),o++,l++;continue}if(g==="\\"&&!p&&o+1<i){let w=s[o+1];if(w===`
662
- `){o+=2,c++,l=1;continue}if(h){if(w==='"'||w==="\\"||w==="$"||w==="`"||w===`
663
- `){w==="$"||w==="`"?u+=g+w:u+=w,o+=2,l+=2;continue}}else{w==='"'||w==="'"?u+=g+w:u+=w,o+=2,l+=2;continue}}if(g==="$"&&o+1<i&&s[o+1]==="("){u+=g,o++,l++,u+=s[o],o++,l++;let w=1,b=!1,E=!1,S=0,R=!1,P="",z=s[o]==="(";for(;w>0&&o<i;){let W=s[o];if(u+=W,b)W==="'"&&(b=!1);else if(E)W==="\\"&&o+1<i?(u+=s[o+1],o++,l++):W==='"'&&(E=!1);else if(W==="'")b=!0,P="";else if(W==='"')E=!0,P="";else if(W==="\\"&&o+1<i)u+=s[o+1],o++,l++,P="";else if(W==="#"&&!z&&(P===""||/\s/.test(s[o-1]||""))){for(;o+1<i&&s[o+1]!==`
664
- `;)o++,l++,u+=s[o];P=""}else/[a-zA-Z_]/.test(W)?P+=W:(P==="case"?(S++,R=!1):P==="in"&&S>0?R=!0:P==="esac"&&S>0&&(S--,R=!1),P="",W==="("?o>0&&s[o-1]==="$"?w++:R||w++:W===")"?R?R=!1:w--:W===";"&&S>0&&o+1<i&&s[o+1]===";"&&(R=!0));W===`
665
- `&&(c++,l=0,P=""),o++,l++}continue}if(g==="$"&&o+1<i&&s[o+1]==="["){u+=g,o++,l++,u+=s[o],o++,l++;let w=1;for(;w>0&&o<i;){let b=s[o];u+=b,b==="["?w++:b==="]"?w--:b===`
666
- `&&(c++,l=0),o++,l++}continue}if(g==="$"&&o+1<i&&s[o+1]==="{"){u+=g,o++,l++,u+=s[o],o++,l++;let w=1;for(;w>0&&o<i;){let b=s[o];u+=b,b==="{"?w++:b==="}"?w--:b===`
667
- `&&(c++,l=0),o++,l++}continue}if(g==="$"&&o+1<i){let w=s[o+1];if(w==="#"||w==="?"||w==="$"||w==="!"||w==="@"||w==="*"||w==="-"||w>="0"&&w<="9"){u+=g+w,o+=2,l+=2;continue}}if(g==="`"){for(u+=g,o++,l++;o<i&&s[o]!=="`";){let w=s[o];u+=w,w==="\\"&&o+1<i&&(u+=s[o+1],o++,l++),w===`
664
+ `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"){let b=s.slice(a,o);if(this.pos=o,this.column=r+(o-a),Dr[b])return{type:Dr[b],value:b,start:e,end:o,line:n,column:r};let w=b.indexOf("=");return w>0&&Hf(b.slice(0,w))?{type:y.ASSIGNMENT_WORD,value:b,start:e,end:o,line:n,column:r}:/^[0-9]+$/.test(b)?{type:y.NUMBER,value:b,start:e,end:o,line:n,column:r}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)?{type:y.NAME,value:b,start:e,end:o,line:n,column:r,quoted:!1,singleQuoted:!1}:{type:y.WORD,value:b,start:e,end:o,line:n,column:r,quoted:!1,singleQuoted:!1}}}o=this.pos;let l=this.column,c=this.line,u="",f=!1,d=!1,p=!1,h=!1,m=s[o]==='"'||s[o]==="'";for(;o<i;){let g=s[o];if(!p&&!h&&(g===" "||g===" "||g===`
665
+ `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"))break;if(g==="$"&&o+1<i&&s[o+1]==="'"&&!p&&!h){for(u+="$'",o+=2,l+=2;o<i&&s[o]!=="'";)s[o]==="\\"&&o+1<i?(u+=s[o]+s[o+1],o+=2,l+=2):(u+=s[o],o++,l++);o<i&&(u+="'",o++,l++);continue}if(g==="$"&&o+1<i&&s[o+1]==='"'&&!p&&!h){o++,l++,h=!0,f=!0,u===""&&(m=!0),o++,l++;continue}if(g==="'"&&!h){p?(p=!1,m||(u+=g)):(p=!0,m?(d=!0,f=!0):u+=g),o++,l++;continue}if(g==='"'&&!p){h?(h=!1,m||(u+=g)):(h=!0,m?f=!0:u+=g),o++,l++;continue}if(g==="\\"&&!p&&o+1<i){let b=s[o+1];if(b===`
666
+ `){o+=2,c++,l=1;continue}if(h){if(b==='"'||b==="\\"||b==="$"||b==="`"||b===`
667
+ `){b==="$"||b==="`"?u+=g+b:u+=b,o+=2,l+=2;continue}}else{b==='"'||b==="'"?u+=g+b:u+=b,o+=2,l+=2;continue}}if(g==="$"&&o+1<i&&s[o+1]==="("){u+=g,o++,l++,u+=s[o],o++,l++;let b=1,w=!1,E=!1,S=0,R=!1,F="",z=s[o]==="(";for(;b>0&&o<i;){let W=s[o];if(u+=W,w)W==="'"&&(w=!1);else if(E)W==="\\"&&o+1<i?(u+=s[o+1],o++,l++):W==='"'&&(E=!1);else if(W==="'")w=!0,F="";else if(W==='"')E=!0,F="";else if(W==="\\"&&o+1<i)u+=s[o+1],o++,l++,F="";else if(W==="#"&&!z&&(F===""||/\s/.test(s[o-1]||""))){for(;o+1<i&&s[o+1]!==`
668
+ `;)o++,l++,u+=s[o];F=""}else/[a-zA-Z_]/.test(W)?F+=W:(F==="case"?(S++,R=!1):F==="in"&&S>0?R=!0:F==="esac"&&S>0&&(S--,R=!1),F="",W==="("?o>0&&s[o-1]==="$"?b++:R||b++:W===")"?R?R=!1:b--:W===";"&&S>0&&o+1<i&&s[o+1]===";"&&(R=!0));W===`
669
+ `&&(c++,l=0,F=""),o++,l++}continue}if(g==="$"&&o+1<i&&s[o+1]==="["){u+=g,o++,l++,u+=s[o],o++,l++;let b=1;for(;b>0&&o<i;){let w=s[o];u+=w,w==="["?b++:w==="]"?b--:w===`
670
+ `&&(c++,l=0),o++,l++}continue}if(g==="$"&&o+1<i&&s[o+1]==="{"){u+=g,o++,l++,u+=s[o],o++,l++;let b=1;for(;b>0&&o<i;){let w=s[o];u+=w,w==="{"?b++:w==="}"?b--:w===`
671
+ `&&(c++,l=0),o++,l++}continue}if(g==="$"&&o+1<i){let b=s[o+1];if(b==="#"||b==="?"||b==="$"||b==="!"||b==="@"||b==="*"||b==="-"||b>="0"&&b<="9"){u+=g+b,o+=2,l+=2;continue}}if(g==="`"){for(u+=g,o++,l++;o<i&&s[o]!=="`";){let b=s[o];u+=b,b==="\\"&&o+1<i&&(u+=s[o+1],o++,l++),b===`
668
672
  `&&(c++,l=0),o++,l++}o<i&&(u+=s[o],o++,l++);continue}u+=g,o++,g===`
669
- `?(c++,l=1):l++}if(this.pos=o,this.column=l,this.line=c,u==="")return{type:y.WORD,value:"",start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d};if(!f&&Or[u])return{type:Or[u],value:u,start:e,end:o,line:n,column:r};if(!m){let g=u.indexOf("=");if(g>0&&Wf(u.slice(0,g)))return{type:y.ASSIGNMENT_WORD,value:u,start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d}}return/^[0-9]+$/.test(u)?{type:y.NUMBER,value:u,start:e,end:o,line:n,column:r}:Cx(u)?{type:y.NAME,value:u,start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d}:{type:y.WORD,value:u,start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let n=this.pos,r=this.line,s=this.column,i="";for(;this.pos<this.input.length;){let o=this.pos,a="";for(;this.pos<this.input.length&&this.input[this.pos]!==`
673
+ `?(c++,l=1):l++}if(this.pos=o,this.column=l,this.line=c,u==="")return{type:y.WORD,value:"",start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d};if(!f&&Dr[u])return{type:Dr[u],value:u,start:e,end:o,line:n,column:r};if(!m){let g=u.indexOf("=");if(g>0&&Hf(u.slice(0,g)))return{type:y.ASSIGNMENT_WORD,value:u,start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d}}return/^[0-9]+$/.test(u)?{type:y.NUMBER,value:u,start:e,end:o,line:n,column:r}:Fx(u)?{type:y.NAME,value:u,start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d}:{type:y.WORD,value:u,start:e,end:o,line:n,column:r,quoted:f,singleQuoted:d}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let n=this.pos,r=this.line,s=this.column,i="";for(;this.pos<this.input.length;){let o=this.pos,a="";for(;this.pos<this.input.length&&this.input[this.pos]!==`
670
674
  `;)a+=this.input[this.pos],this.pos++,this.column++;if((e.stripTabs?a.replace(/^\t+/,""):a)===e.delimiter){this.pos<this.input.length&&this.input[this.pos]===`
671
675
  `&&(this.pos++,this.line++,this.column=1);break}i+=a,this.pos<this.input.length&&this.input[this.pos]===`
672
676
  `&&(i+=`
@@ -674,48 +678,48 @@ Gid: ${r} ${r} ${r} ${r}
674
678
  `||n===";"||n==="&"||n==="|"||n==="("||n===")"||n==="<"||n===">")}readWordWithBraceExpansion(e,n,r){let s=this.input,i=s.length,o=e,a=r;for(;o<i;){let c=s[o];if(c===" "||c===" "||c===`
675
679
  `||c===";"||c==="&"||c==="|"||c==="("||c===")"||c==="<"||c===">")break;if(c==="{"){if(this.scanBraceExpansion(o)!==null){let f=1;for(o++,a++;o<i&&f>0;)s[o]==="{"?f++:s[o]==="}"&&f--,o++,a++;continue}o++,a++;continue}if(c==="}"){o++,a++;continue}if(c==="$"&&o+1<i&&s[o+1]==="("){o++,a++,o++,a++;let u=1;for(;u>0&&o<i;)s[o]==="("?u++:s[o]===")"&&u--,o++,a++;continue}if(c==="$"&&o+1<i&&s[o+1]==="{"){o++,a++,o++,a++;let u=1;for(;u>0&&o<i;)s[o]==="{"?u++:s[o]==="}"&&u--,o++,a++;continue}if(c==="`"){for(o++,a++;o<i&&s[o]!=="`";)s[o]==="\\"&&o+1<i?(o+=2,a+=2):(o++,a++);o<i&&(o++,a++);continue}o++,a++}let l=s.slice(e,o);return this.pos=o,this.column=a,{type:y.WORD,value:l,start:e,end:o,line:n,column:r,quoted:!1,singleQuoted:!1}}scanBraceExpansion(e){let n=this.input,r=n.length,s=e+1,i=1,o=!1,a=!1;for(;s<r&&i>0;){let l=n[s];if(l==="{")i++,s++;else if(l==="}")i--,s++;else if(l===","&&i===1)o=!0,s++;else if(l==="."&&s+1<r&&n[s+1]===".")a=!0,s+=2;else{if(l===" "||l===" "||l===`
676
680
  `||l===";"||l==="&"||l==="|")return null;s++}}return i===0&&(o||a)?n.slice(e,s):null}scanLiteralBraceWord(e){let n=this.input,r=n.length,s=e+1,i=1;for(;s<r&&i>0;){let o=n[s];if(o==="{")i++,s++;else if(o==="}"){if(i--,i===0)return n.slice(e,s+1);s++}else{if(o===" "||o===" "||o===`
677
- `||o===";"||o==="&"||o==="|")return null;s++}}return null}};var pi=1e6,hi=1e5,Uf=1e6,jf=new Set([y.LESS,y.GREAT,y.DLESS,y.DGREAT,y.LESSAND,y.GREATAND,y.LESSGREAT,y.DLESSDASH,y.CLOBBER,y.TLESS,y.AND_GREAT,y.AND_DGREAT]),zf=new Set([y.LESS,y.GREAT,y.DLESS,y.DGREAT,y.LESSAND,y.GREATAND,y.LESSGREAT,y.DLESSDASH,y.CLOBBER,y.TLESS]),dt=class extends Error{line;column;token;constructor(e,n,r,s=void 0){super(`Parse error at ${n}:${r}: ${e}`),this.line=n,this.column=r,this.token=s,this.name="ParseException"}};function Gf(t,e,n){let r=n+1;for(;r<e.length&&/[a-zA-Z0-9_-]/.test(e[r]);)r++;return r}function mi(t,e,n,r,s){let i=1,o=n+1;for(;o<e.length&&i>0;)e[o]===r?i++:e[o]===s&&i--,i>0&&o++;return i===0?o:-1}function Bt(t,e,n){let r=n,s=1;for(;r<e.length&&s>0;){let i=e[r];if(i==="\\"&&r+1<e.length){r+=2;continue}if(i==="'"){let o=e.indexOf("'",r+1);if(o!==-1){r=o+1;continue}}if(i==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}i==="{"?s++:i==="}"&&s--,s>0&&r++}return r}function qf(t,e,n){let r=n,s=!1;for(;r<e.length;){let i=e[r];if(i==="/"&&s||i==="}")break;if(i==="'"){let o=e.indexOf("'",r+1);if(o!==-1){r=o+1,s=!0;continue}}if(i==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++,s=!0;continue}i==="\\"?(r+=2,s=!0):(r++,s=!0)}return r}function Vf(t,e,n){let r=n,s="";for(;r<e.length;){let i=e[r];if(i==="*"||i==="?")s+=i,r++;else if(i==="["){let o=Ax(e,r);o===-1?(s+=i,r++):(s+=e.slice(r,o+1),r=o+1)}else break}return{pattern:s,endIndex:r}}function Ax(t,e){let n=e+1;for(n<t.length&&t[n]==="^"&&n++,n<t.length&&t[n]==="]"&&n++;n<t.length;){let r=t[n];if(r==="\\"&&n+1<t.length){n+=2;continue}if(r==="]")return n;if(r==='"'||r==="$"||r==="`")return-1;if(r==="'"){let s=t.indexOf("'",n+1);if(s!==-1){n=s+1;continue}}if(r==="["&&n+1<t.length&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){n=s+2;continue}}if(r==="["&&n+1<t.length&&(t[n+1]==="."||t[n+1]==="=")){let i=`${t[n+1]}]`,o=t.indexOf(i,n+2);if(o!==-1){n=o+2;continue}}n++}return-1}function Zf(t,e,n){let r="",s=n;for(;s<e.length&&e[s]!=="'";){let i=e[s];if(i==="\\"&&s+1<e.length)switch(e[s+1]){case"n":r+=`
678
- `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=e.slice(s+2,s+4),l=parseInt(a,16);Number.isNaN(l)?(r+="\\x",s+=2):(r+=String.fromCharCode(l),s+=4);break}case"u":{let a=e.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<e.length&&l<s+4&&/[0-7]/.test(e[l]);)a+=e[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<e.length&&e[s]==="'"&&s++,{part:B.literal(r),endIndex:s}}function gi(t,e){let n=e.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:ve(t,n)}function Hf(t){let e=[],n="",r=0;for(let s=0;s<t.length;s++){let i=t[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(e.push(n),n=""):n+=i}return e.push(n),e}function Kf(t,e,n,r){let s=mi(t,e,n,"{","}");if(s===-1)return null;let i=e.slice(n+1,s),o=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:Hf(i).map(u=>({type:"Word",word:B.word(r(t,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:Hf(i).map(u=>({type:"Word",word:B.word([B.literal(u)])}))},endIndex:s+1}:null}function Qf(t,e){let n="";for(let r of e.parts)switch(r.type){case"Literal":case"SingleQuoted":case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;default:n+=r.type}return n}function Xf(t,e){return{[y.LESS]:"<",[y.GREAT]:">",[y.DGREAT]:">>",[y.LESSAND]:"<&",[y.GREATAND]:">&",[y.LESSGREAT]:"<>",[y.CLOBBER]:">|",[y.TLESS]:"<<<",[y.AND_GREAT]:"&>",[y.AND_DGREAT]:"&>>",[y.DLESS]:"<",[y.DLESSDASH]:"<"}[e]||">"}function Lr(t){let e=t.current(),n=e.type;if(n===y.NUMBER){let r=t.peek(1);return e.end!==r.start?!1:zf.has(r.type)}return jf.has(n)}function Mr(t){let e=null;t.check(y.NUMBER)&&(e=Number.parseInt(t.advance().value,10));let n=t.advance(),r=Xf(t,n.type);if(n.type===y.DLESS||n.type===y.DLESSDASH)return kx(t,r,e,n.type===y.DLESSDASH);t.isWord()||t.error("Expected redirection target");let s=t.parseWord();return B.redirection(r,s,e)}function kx(t,e,n,r){t.isWord()||t.error("Expected here-document delimiter");let s=t.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=B.redirection(r?"<<-":"<<",B.hereDoc(i,B.word([]),r,o),n);return t.addPendingHeredoc(a,i,r,o),a}function Yf(t){let e=t.current().line,n=[],r=null,s=[],i=[];for(;t.check(y.ASSIGNMENT_WORD);)t.checkIterationLimit(),n.push(Nx(t));for(;Lr(t);)t.checkIterationLimit(),i.push(Mr(t));for(t.isWord()&&(r=t.parseWord());(!t.isStatementEnd()||t.check(y.RBRACE))&&!t.check(y.PIPE,y.PIPE_AMP);)if(t.checkIterationLimit(),Lr(t))i.push(Mr(t));else if(t.check(y.RBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.isWord())s.push(t.parseWord());else if(t.check(y.ASSIGNMENT_WORD)){let a=t.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||t.check(y.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||t.expect(y.LPAREN);let d=yi(t);t.expect(y.RPAREN);let p=d.map(m=>Qf(t,m)),h=`${f}=(${p.join(" ")})`;s.push(t.parseWordFromString(h,!1,!1))}else s.push(t.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(t.check(y.LPAREN))t.error("syntax error near unexpected token `('");else break;let o=B.simpleCommand(r,s,n,i);return o.line=e,o}function Nx(t){let e=t.expect(y.ASSIGNMENT_WORD),n=e.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||t.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,d=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&t.error(`Invalid assignment: ${n}`),i=n.slice(d,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&t.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=yi(t);t.expect(y.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return B.assignment(d,null,a,f)}if(l===""&&t.check(y.LPAREN)){let f=t.current();if(e.end===f.start){t.advance();let d=yi(t);t.expect(y.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return B.assignment(p,null,a,d)}}let c=l?t.parseWordFromString(l,e.quoted,e.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return B.assignment(u,c,a,null)}function yi(t){let e=[];for(t.skipNewlines();!t.check(y.RPAREN,y.EOF);)t.checkIterationLimit(),t.isWord()?e.push(t.parseWord()):t.advance(),t.skipNewlines();return e}function xi(t){t.expect(y.IF);let e=[],n=t.parseCompoundList();t.expect(y.THEN);let r=t.parseCompoundList();if(r.length===0){let o=t.check(y.FI)?"fi":t.check(y.ELSE)?"else":t.check(y.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${o}'`)}for(e.push({condition:n,body:r});t.check(y.ELIF);){t.advance();let o=t.parseCompoundList();t.expect(y.THEN);let a=t.parseCompoundList();if(a.length===0){let l=t.check(y.FI)?"fi":t.check(y.ELSE)?"else":t.check(y.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${l}'`)}e.push({condition:o,body:a})}let s=null;t.check(y.ELSE)&&(t.advance(),s=t.parseCompoundList(),s.length===0&&t.error("syntax error near unexpected token `fi'")),t.expect(y.FI);let i=t.parseOptionalRedirections();return B.ifNode(e,s,i)}function wi(t){if(t.expect(y.FOR),t.check(y.DPAREN_START))return vx(t);t.isWord()||t.error("Expected variable name in for loop");let n=t.advance().value,r=null;if(t.skipNewlines(),t.check(y.IN))for(t.advance(),r=[];!t.check(y.SEMICOLON,y.NEWLINE,y.DO,y.EOF)&&t.isWord();)r.push(t.parseWord());t.check(y.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(y.DO);let s=t.parseCompoundList();t.expect(y.DONE);let i=t.parseOptionalRedirections();return B.forNode(n,r,s,i)}function vx(t){t.expect(y.DPAREN_START);let e=null,n=null,r=null,s=["","",""],i=0,o=0;for(;!t.check(y.DPAREN_END,y.EOF);){let c=t.advance();if(c.type===y.SEMICOLON&&o===0){if(i++,i>2)break}else c.value==="("&&o++,c.value===")"&&o--,s[i]+=c.value}t.expect(y.DPAREN_END),s[0].trim()&&(e=ve(t,s[0].trim())),s[1].trim()&&(n=ve(t,s[1].trim())),s[2].trim()&&(r=ve(t,s[2].trim())),t.skipNewlines(),t.check(y.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(y.DO);let a=t.parseCompoundList();t.expect(y.DONE);let l=t.parseOptionalRedirections();return{type:"CStyleFor",init:e,condition:n,update:r,body:a,redirections:l}}function bi(t){t.expect(y.WHILE);let e=t.parseCompoundList();t.expect(y.DO);let n=t.parseCompoundList();n.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(y.DONE);let r=t.parseOptionalRedirections();return B.whileNode(e,n,r)}function Ei(t){t.expect(y.UNTIL);let e=t.parseCompoundList();t.expect(y.DO);let n=t.parseCompoundList();n.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(y.DONE);let r=t.parseOptionalRedirections();return B.untilNode(e,n,r)}function Si(t){t.expect(y.CASE),t.isWord()||t.error("Expected word after 'case'");let e=t.parseWord();t.skipNewlines(),t.expect(y.IN),t.skipNewlines();let n=[];for(;!t.check(y.ESAC,y.EOF);){t.checkIterationLimit();let s=t.getPos(),i=$x(t);if(i&&n.push(i),t.skipNewlines(),t.getPos()===s&&!i)break}t.expect(y.ESAC);let r=t.parseOptionalRedirections();return B.caseNode(e,n,r)}function $x(t){t.check(y.LPAREN)&&t.advance();let e=[];for(;t.isWord()&&(e.push(t.parseWord()),t.check(y.PIPE));)t.advance();if(e.length===0)return null;t.expect(y.RPAREN),t.skipNewlines();let n=[];for(;!t.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND,y.ESAC,y.EOF);){t.checkIterationLimit(),t.isWord()&&t.peek(1).type===y.RPAREN&&t.error("syntax error near unexpected token `)'"),t.check(y.LPAREN)&&t.peek(1).type===y.WORD&&t.error(`syntax error near unexpected token \`${t.peek(1).value}'`);let s=t.getPos(),i=t.parseStatement();if(i&&n.push(i),t.skipSeparators(!1),t.getPos()===s&&!i)break}let r=";;";return t.check(y.DSEMI)?(t.advance(),r=";;"):t.check(y.SEMI_AND)?(t.advance(),r=";&"):t.check(y.SEMI_SEMI_AND)&&(t.advance(),r=";;&"),B.caseItem(e,n,r)}function Ci(t){t.peek(1).type,y.LPAREN,t.expect(y.LPAREN),t.check(y.LPAREN)&&t.advance();let e=t.parseCompoundList();t.expect(y.RPAREN);let n=t.parseOptionalRedirections();return B.subshell(e,n)}function Ai(t){t.expect(y.LBRACE);let e=t.parseCompoundList();t.expect(y.RBRACE);let n=t.parseOptionalRedirections();return B.group(e,n)}var Px=["-a","-b","-c","-d","-e","-f","-g","-h","-k","-p","-r","-s","-t","-u","-w","-x","-G","-L","-N","-O","-S","-z","-n","-o","-v","-R"],Fx=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"];function Ni(t){return t.skipNewlines(),Tx(t)}function Tx(t){let e=ed(t);for(t.skipNewlines();t.check(y.OR_OR);){t.advance(),t.skipNewlines();let n=ed(t);e={type:"CondOr",left:e,right:n},t.skipNewlines()}return e}function ed(t){let e=ki(t);for(t.skipNewlines();t.check(y.AND_AND);){t.advance(),t.skipNewlines();let n=ki(t);e={type:"CondAnd",left:e,right:n},t.skipNewlines()}return e}function ki(t){return t.skipNewlines(),t.check(y.BANG)?(t.advance(),t.skipNewlines(),{type:"CondNot",operand:ki(t)}):Ox(t)}function Ox(t){if(t.check(y.LPAREN)){t.advance();let e=Ni(t);return t.expect(y.RPAREN),{type:"CondGroup",expression:e}}if(t.isWord()){let e=t.current(),n=e.value;if(Px.includes(n)&&!e.quoted&&(t.advance(),t.check(y.DBRACK_END)&&t.error(`Expected operand after ${n}`),t.isWord())){let s=t.parseWord();return{type:"CondUnary",operator:n,operand:s}}let r=t.parseWord();if(t.isWord()&&Fx.includes(t.current().value)){let s=t.advance().value,i=t.parseWord();return{type:"CondBinary",operator:s,left:r,right:i}}if(t.check(y.LESS)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"<",left:r,right:s}}if(t.check(y.GREAT)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:">",left:r,right:s}}if(t.isWord()&&t.current().value==="="){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}t.error("Expected conditional expression")}function Lx(t,e,n){let r=n+1,s=e[r];if("@*#?$!-0123456789".includes(s))return{part:B.parameterExpansion(s),endIndex:r+1};let i="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)i+=e[r],r++;return{part:B.parameterExpansion(i),endIndex:r}}function Mx(t,e,n,r=!1){let s=n+2,i=!1;e[s]==="!"&&(i=!0,s++);let o=!1;e[s]==="#"&&!/[}:#%/^,]/.test(e[s+1]||"}")&&(o=!0,s++);let a="",l=e[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(e[s+1]||""))a=l,s++;else for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)a+=e[s],s++;if(e[s]==="["){let u=mi(t,e,s,"[","]");a+=e.slice(s,u+1),s=u+1}a===""&&!i&&!o&&e[s]!=="}"&&t.error(`\${${e[s]}}: bad substitution`);let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(e[s]==="*"||e[s]==="@"){let f=e[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else c={type:"Indirection"}}else if(o)if(e[s]===":")for(c={type:"LengthSliceError"};s<e.length&&e[s]!=="}";)s++;else e[s]!=="}"&&/[-+=?]/.test(e[s])?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<e.length&&e[s]!=="}"){let u=_x(t,e,s,a,r);c=u.operation,s=u.endIndex}if(s<e.length&&e[s]!=="}"){let u=e[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<e.length&&e[f]!=="}";)f++;let d=e.slice(n,f+1);t.error(`\${${d.slice(2,-1)}}: bad substitution`)}}for(;s<e.length&&e[s]!=="}";)s++;return{part:B.parameterExpansion(a,c),endIndex:s+1}}function _x(t,e,n,r,s=!1){let i=n,o=e[i],a=e[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let w=Bt(t,e,i),b=e.slice(i,w),E=xt(t,b,!1,!1,!0,!1,s),S=B.word(E.length>0?E:[B.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:S,checkEmpty:!0},endIndex:w};if(l==="=")return{operation:{type:"AssignDefault",word:S,checkEmpty:!0},endIndex:w};if(l==="?")return{operation:{type:"ErrorIfUnset",word:S,checkEmpty:!0},endIndex:w};if(l==="+")return{operation:{type:"UseAlternative",word:S,checkEmpty:!0},endIndex:w}}i++;let c=Bt(t,e,i),u=e.slice(i,c),f=-1,d=0,p=0;for(let g=0;g<u.length;g++){let w=u[g];if(w==="("||w==="[")d++;else if(w===")"||w==="]")d--;else if(w==="?"&&d===0)p++;else if(w===":"&&d===0)if(p>0)p--;else{f=g;break}}let h=f>=0?u.slice(0,f):u,m=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:gi(t,h),length:m?gi(t,m):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=Bt(t,e,i),c=e.slice(i,l),u=xt(t,c,!1,!1,!0,!1,s),f=B.word(u.length>0?u:[B.literal("")]);if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=Bt(t,e,i),f=e.slice(i,u),d=xt(t,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:B.word(d.length>0?d:[B.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;e[i]==="#"?(c="start",i++):e[i]==="%"&&(c="end",i++);let u=qf(t,e,i),f=e.slice(i,u),d=xt(t,f,!1,!1,!1),p=B.word(d.length>0?d:[B.literal("")]),h=null,m=u;if(e[u]==="/"){let g=u+1,w=Bt(t,e,g),b=e.slice(g,w),E=xt(t,b,!1,!1,!1);h=B.word(E.length>0?E:[B.literal("")]),m=w}return{operation:{type:"PatternReplacement",pattern:p,replacement:h,all:l,anchor:c},endIndex:m}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=Bt(t,e,i),f=e.slice(i,u),d=f?B.word([B.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:d},endIndex:u}}return o==="@"&&/[QPaAEK]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function Ii(t,e,n,r=!1){let s=n+1;if(s>=e.length)return{part:B.literal("$"),endIndex:s};let i=e[s];if(i==="("&&e[s+1]==="(")return t.parseArithmeticExpansion(e,n);if(i==="["){let o=1,a=s+1;for(;a<e.length&&o>0;)e[a]==="["?o++:e[a]==="]"&&o--,o>0&&a++;if(o===0){let l=e.slice(s+1,a),c=ve(t,l);return{part:B.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?t.parseCommandSubstitution(e,n):i==="{"?Mx(t,e,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?Lx(t,e,n):{part:B.literal("$"),endIndex:s}}function Bx(t,e){let n=[],r=0,s="",i=()=>{s&&(n.push(B.literal(s)),s="")};for(;r<e.length;){let o=e[r];if(o==="\\"&&r+1<e.length){let a=e[r+1];if(a==="$"||a==="`"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=Ii(t,e,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=t.parseBacktickSubstitution(e,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function Wx(t,e,n){let r=[],s=n,i="",o=()=>{i&&(r.push(B.literal(i)),i="")};for(;s<e.length&&e[s]!=='"';){let a=e[s];if(a==="\\"&&s+1<e.length){let l=e[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=Ii(t,e,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=t.parseBacktickSubstitution(e,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:B.doubleQuoted(r),endIndex:s}}function xt(t,e,n=!1,r=!1,s=!1,i=!1,o=!1){if(r)return[B.singleQuoted(e)];if(n){let f=Bx(t,e);return[B.doubleQuoted(f)]}let a=[],l=0,c="",u=()=>{c&&(a.push(B.literal(c)),c="")};for(;l<e.length;){let f=e[l];if(f==="\\"&&l+1<e.length){let d=e[l+1];(i?d==="$"||d==="`"||d==="\\"||d===`
681
+ `||o===";"||o==="&"||o==="|")return null;s++}}return null}};var mi=1e6,gi=1e5,Gf=1e6,qf=new Set([y.LESS,y.GREAT,y.DLESS,y.DGREAT,y.LESSAND,y.GREATAND,y.LESSGREAT,y.DLESSDASH,y.CLOBBER,y.TLESS,y.AND_GREAT,y.AND_DGREAT]),Vf=new Set([y.LESS,y.GREAT,y.DLESS,y.DGREAT,y.LESSAND,y.GREATAND,y.LESSGREAT,y.DLESSDASH,y.CLOBBER,y.TLESS]),pt=class extends Error{line;column;token;constructor(e,n,r,s=void 0){super(`Parse error at ${n}:${r}: ${e}`),this.line=n,this.column=r,this.token=s,this.name="ParseException"}};function Kf(t,e,n){let r=n+1;for(;r<e.length&&/[a-zA-Z0-9_-]/.test(e[r]);)r++;return r}function yi(t,e,n,r,s){let i=1,o=n+1;for(;o<e.length&&i>0;)e[o]===r?i++:e[o]===s&&i--,i>0&&o++;return i===0?o:-1}function Wt(t,e,n){let r=n,s=1;for(;r<e.length&&s>0;){let i=e[r];if(i==="\\"&&r+1<e.length){r+=2;continue}if(i==="'"){let o=e.indexOf("'",r+1);if(o!==-1){r=o+1;continue}}if(i==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}i==="{"?s++:i==="}"&&s--,s>0&&r++}return r}function Qf(t,e,n){let r=n,s=!1;for(;r<e.length;){let i=e[r];if(i==="/"&&s||i==="}")break;if(i==="'"){let o=e.indexOf("'",r+1);if(o!==-1){r=o+1,s=!0;continue}}if(i==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++,s=!0;continue}i==="\\"?(r+=2,s=!0):(r++,s=!0)}return r}function Xf(t,e,n){let r=n,s="";for(;r<e.length;){let i=e[r];if(i==="*"||i==="?")s+=i,r++;else if(i==="["){let o=Px(e,r);o===-1?(s+=i,r++):(s+=e.slice(r,o+1),r=o+1)}else break}return{pattern:s,endIndex:r}}function Px(t,e){let n=e+1;for(n<t.length&&t[n]==="^"&&n++,n<t.length&&t[n]==="]"&&n++;n<t.length;){let r=t[n];if(r==="\\"&&n+1<t.length){n+=2;continue}if(r==="]")return n;if(r==='"'||r==="$"||r==="`")return-1;if(r==="'"){let s=t.indexOf("'",n+1);if(s!==-1){n=s+1;continue}}if(r==="["&&n+1<t.length&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){n=s+2;continue}}if(r==="["&&n+1<t.length&&(t[n+1]==="."||t[n+1]==="=")){let i=`${t[n+1]}]`,o=t.indexOf(i,n+2);if(o!==-1){n=o+2;continue}}n++}return-1}function Jf(t,e,n){let r="",s=n;for(;s<e.length&&e[s]!=="'";){let i=e[s];if(i==="\\"&&s+1<e.length)switch(e[s+1]){case"n":r+=`
682
+ `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=e.slice(s+2,s+4),l=parseInt(a,16);Number.isNaN(l)?(r+="\\x",s+=2):(r+=String.fromCharCode(l),s+=4);break}case"u":{let a=e.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<e.length&&l<s+4&&/[0-7]/.test(e[l]);)a+=e[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<e.length&&e[s]==="'"&&s++,{part:B.literal(r),endIndex:s}}function xi(t,e){let n=e.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:ve(t,n)}function Zf(t){let e=[],n="",r=0;for(let s=0;s<t.length;s++){let i=t[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(e.push(n),n=""):n+=i}return e.push(n),e}function Yf(t,e,n,r){let s=yi(t,e,n,"{","}");if(s===-1)return null;let i=e.slice(n+1,s),o=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:Zf(i).map(u=>({type:"Word",word:B.word(r(t,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:Zf(i).map(u=>({type:"Word",word:B.word([B.literal(u)])}))},endIndex:s+1}:null}function ed(t,e){let n="";for(let r of e.parts)switch(r.type){case"Literal":case"SingleQuoted":case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;default:n+=r.type}return n}function td(t,e){return{[y.LESS]:"<",[y.GREAT]:">",[y.DGREAT]:">>",[y.LESSAND]:"<&",[y.GREATAND]:">&",[y.LESSGREAT]:"<>",[y.CLOBBER]:">|",[y.TLESS]:"<<<",[y.AND_GREAT]:"&>",[y.AND_DGREAT]:"&>>",[y.DLESS]:"<",[y.DLESSDASH]:"<"}[e]||">"}function Mr(t){let e=t.current(),n=e.type;if(n===y.NUMBER){let r=t.peek(1);return e.end!==r.start?!1:Vf.has(r.type)}return qf.has(n)}function _r(t){let e=null;t.check(y.NUMBER)&&(e=Number.parseInt(t.advance().value,10));let n=t.advance(),r=td(t,n.type);if(n.type===y.DLESS||n.type===y.DLESSDASH)return Tx(t,r,e,n.type===y.DLESSDASH);t.isWord()||t.error("Expected redirection target");let s=t.parseWord();return B.redirection(r,s,e)}function Tx(t,e,n,r){t.isWord()||t.error("Expected here-document delimiter");let s=t.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=B.redirection(r?"<<-":"<<",B.hereDoc(i,B.word([]),r,o),n);return t.addPendingHeredoc(a,i,r,o),a}function rd(t){let e=t.current().line,n=[],r=null,s=[],i=[];for(;t.check(y.ASSIGNMENT_WORD);)t.checkIterationLimit(),n.push(Ox(t));for(;Mr(t);)t.checkIterationLimit(),i.push(_r(t));for(t.isWord()&&(r=t.parseWord());(!t.isStatementEnd()||t.check(y.RBRACE))&&!t.check(y.PIPE,y.PIPE_AMP);)if(t.checkIterationLimit(),Mr(t))i.push(_r(t));else if(t.check(y.RBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.isWord())s.push(t.parseWord());else if(t.check(y.ASSIGNMENT_WORD)){let a=t.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||t.check(y.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||t.expect(y.LPAREN);let d=wi(t);t.expect(y.RPAREN);let p=d.map(m=>ed(t,m)),h=`${f}=(${p.join(" ")})`;s.push(t.parseWordFromString(h,!1,!1))}else s.push(t.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(t.check(y.LPAREN))t.error("syntax error near unexpected token `('");else break;let o=B.simpleCommand(r,s,n,i);return o.line=e,o}function Ox(t){let e=t.expect(y.ASSIGNMENT_WORD),n=e.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||t.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,d=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&t.error(`Invalid assignment: ${n}`),i=n.slice(d,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&t.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=wi(t);t.expect(y.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return B.assignment(d,null,a,f)}if(l===""&&t.check(y.LPAREN)){let f=t.current();if(e.end===f.start){t.advance();let d=wi(t);t.expect(y.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return B.assignment(p,null,a,d)}}let c=l?t.parseWordFromString(l,e.quoted,e.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return B.assignment(u,c,a,null)}function wi(t){let e=[];for(t.skipNewlines();!t.check(y.RPAREN,y.EOF);)t.checkIterationLimit(),t.isWord()?e.push(t.parseWord()):t.advance(),t.skipNewlines();return e}function bi(t){t.expect(y.IF);let e=[],n=t.parseCompoundList();t.expect(y.THEN);let r=t.parseCompoundList();if(r.length===0){let o=t.check(y.FI)?"fi":t.check(y.ELSE)?"else":t.check(y.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${o}'`)}for(e.push({condition:n,body:r});t.check(y.ELIF);){t.advance();let o=t.parseCompoundList();t.expect(y.THEN);let a=t.parseCompoundList();if(a.length===0){let l=t.check(y.FI)?"fi":t.check(y.ELSE)?"else":t.check(y.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${l}'`)}e.push({condition:o,body:a})}let s=null;t.check(y.ELSE)&&(t.advance(),s=t.parseCompoundList(),s.length===0&&t.error("syntax error near unexpected token `fi'")),t.expect(y.FI);let i=t.parseOptionalRedirections();return B.ifNode(e,s,i)}function Ei(t){if(t.expect(y.FOR),t.check(y.DPAREN_START))return Lx(t);t.isWord()||t.error("Expected variable name in for loop");let n=t.advance().value,r=null;if(t.skipNewlines(),t.check(y.IN))for(t.advance(),r=[];!t.check(y.SEMICOLON,y.NEWLINE,y.DO,y.EOF)&&t.isWord();)r.push(t.parseWord());t.check(y.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(y.DO);let s=t.parseCompoundList();t.expect(y.DONE);let i=t.parseOptionalRedirections();return B.forNode(n,r,s,i)}function Lx(t){t.expect(y.DPAREN_START);let e=null,n=null,r=null,s=["","",""],i=0,o=0;for(;!t.check(y.DPAREN_END,y.EOF);){let c=t.advance();if(c.type===y.SEMICOLON&&o===0){if(i++,i>2)break}else c.value==="("&&o++,c.value===")"&&o--,s[i]+=c.value}t.expect(y.DPAREN_END),s[0].trim()&&(e=ve(t,s[0].trim())),s[1].trim()&&(n=ve(t,s[1].trim())),s[2].trim()&&(r=ve(t,s[2].trim())),t.skipNewlines(),t.check(y.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(y.DO);let a=t.parseCompoundList();t.expect(y.DONE);let l=t.parseOptionalRedirections();return{type:"CStyleFor",init:e,condition:n,update:r,body:a,redirections:l}}function Si(t){t.expect(y.WHILE);let e=t.parseCompoundList();t.expect(y.DO);let n=t.parseCompoundList();n.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(y.DONE);let r=t.parseOptionalRedirections();return B.whileNode(e,n,r)}function Ci(t){t.expect(y.UNTIL);let e=t.parseCompoundList();t.expect(y.DO);let n=t.parseCompoundList();n.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(y.DONE);let r=t.parseOptionalRedirections();return B.untilNode(e,n,r)}function Ai(t){t.expect(y.CASE),t.isWord()||t.error("Expected word after 'case'");let e=t.parseWord();t.skipNewlines(),t.expect(y.IN),t.skipNewlines();let n=[];for(;!t.check(y.ESAC,y.EOF);){t.checkIterationLimit();let s=t.getPos(),i=Mx(t);if(i&&n.push(i),t.skipNewlines(),t.getPos()===s&&!i)break}t.expect(y.ESAC);let r=t.parseOptionalRedirections();return B.caseNode(e,n,r)}function Mx(t){t.check(y.LPAREN)&&t.advance();let e=[];for(;t.isWord()&&(e.push(t.parseWord()),t.check(y.PIPE));)t.advance();if(e.length===0)return null;t.expect(y.RPAREN),t.skipNewlines();let n=[];for(;!t.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND,y.ESAC,y.EOF);){t.checkIterationLimit(),t.isWord()&&t.peek(1).type===y.RPAREN&&t.error("syntax error near unexpected token `)'"),t.check(y.LPAREN)&&t.peek(1).type===y.WORD&&t.error(`syntax error near unexpected token \`${t.peek(1).value}'`);let s=t.getPos(),i=t.parseStatement();if(i&&n.push(i),t.skipSeparators(!1),t.getPos()===s&&!i)break}let r=";;";return t.check(y.DSEMI)?(t.advance(),r=";;"):t.check(y.SEMI_AND)?(t.advance(),r=";&"):t.check(y.SEMI_SEMI_AND)&&(t.advance(),r=";;&"),B.caseItem(e,n,r)}function ki(t){t.peek(1).type,y.LPAREN,t.expect(y.LPAREN),t.check(y.LPAREN)&&t.advance();let e=t.parseCompoundList();t.expect(y.RPAREN);let n=t.parseOptionalRedirections();return B.subshell(e,n)}function Ni(t){t.expect(y.LBRACE);let e=t.parseCompoundList();t.expect(y.RBRACE);let n=t.parseOptionalRedirections();return B.group(e,n)}var Bx=["-a","-b","-c","-d","-e","-f","-g","-h","-k","-p","-r","-s","-t","-u","-w","-x","-G","-L","-N","-O","-S","-z","-n","-o","-v","-R"],Wx=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"];function vi(t){return t.skipNewlines(),Ux(t)}function Ux(t){let e=sd(t);for(t.skipNewlines();t.check(y.OR_OR);){t.advance(),t.skipNewlines();let n=sd(t);e={type:"CondOr",left:e,right:n},t.skipNewlines()}return e}function sd(t){let e=Ii(t);for(t.skipNewlines();t.check(y.AND_AND);){t.advance(),t.skipNewlines();let n=Ii(t);e={type:"CondAnd",left:e,right:n},t.skipNewlines()}return e}function Ii(t){return t.skipNewlines(),t.check(y.BANG)?(t.advance(),t.skipNewlines(),{type:"CondNot",operand:Ii(t)}):jx(t)}function jx(t){if(t.check(y.LPAREN)){t.advance();let e=vi(t);return t.expect(y.RPAREN),{type:"CondGroup",expression:e}}if(t.isWord()){let e=t.current(),n=e.value;if(Bx.includes(n)&&!e.quoted&&(t.advance(),t.check(y.DBRACK_END)&&t.error(`Expected operand after ${n}`),t.isWord())){let s=t.parseWord();return{type:"CondUnary",operator:n,operand:s}}let r=t.parseWord();if(t.isWord()&&Wx.includes(t.current().value)){let s=t.advance().value,i=t.parseWord();return{type:"CondBinary",operator:s,left:r,right:i}}if(t.check(y.LESS)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"<",left:r,right:s}}if(t.check(y.GREAT)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:">",left:r,right:s}}if(t.isWord()&&t.current().value==="="){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}t.error("Expected conditional expression")}function Hx(t,e,n){let r=n+1,s=e[r];if("@*#?$!-0123456789".includes(s))return{part:B.parameterExpansion(s),endIndex:r+1};let i="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)i+=e[r],r++;return{part:B.parameterExpansion(i),endIndex:r}}function Gx(t,e,n,r=!1){let s=n+2,i=!1;e[s]==="!"&&(i=!0,s++);let o=!1;e[s]==="#"&&!/[}:#%/^,]/.test(e[s+1]||"}")&&(o=!0,s++);let a="",l=e[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(e[s+1]||""))a=l,s++;else for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)a+=e[s],s++;if(e[s]==="["){let u=yi(t,e,s,"[","]");a+=e.slice(s,u+1),s=u+1}a===""&&!i&&!o&&e[s]!=="}"&&t.error(`\${${e[s]}}: bad substitution`);let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(e[s]==="*"||e[s]==="@"){let f=e[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else c={type:"Indirection"}}else if(o)if(e[s]===":")for(c={type:"LengthSliceError"};s<e.length&&e[s]!=="}";)s++;else e[s]!=="}"&&/[-+=?]/.test(e[s])?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<e.length&&e[s]!=="}"){let u=qx(t,e,s,a,r);c=u.operation,s=u.endIndex}if(s<e.length&&e[s]!=="}"){let u=e[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<e.length&&e[f]!=="}";)f++;let d=e.slice(n,f+1);t.error(`\${${d.slice(2,-1)}}: bad substitution`)}}for(;s<e.length&&e[s]!=="}";)s++;return{part:B.parameterExpansion(a,c),endIndex:s+1}}function qx(t,e,n,r,s=!1){let i=n,o=e[i],a=e[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let b=Wt(t,e,i),w=e.slice(i,b),E=wt(t,w,!1,!1,!0,!1,s),S=B.word(E.length>0?E:[B.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:S,checkEmpty:!0},endIndex:b};if(l==="=")return{operation:{type:"AssignDefault",word:S,checkEmpty:!0},endIndex:b};if(l==="?")return{operation:{type:"ErrorIfUnset",word:S,checkEmpty:!0},endIndex:b};if(l==="+")return{operation:{type:"UseAlternative",word:S,checkEmpty:!0},endIndex:b}}i++;let c=Wt(t,e,i),u=e.slice(i,c),f=-1,d=0,p=0;for(let g=0;g<u.length;g++){let b=u[g];if(b==="("||b==="[")d++;else if(b===")"||b==="]")d--;else if(b==="?"&&d===0)p++;else if(b===":"&&d===0)if(p>0)p--;else{f=g;break}}let h=f>=0?u.slice(0,f):u,m=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:xi(t,h),length:m?xi(t,m):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=Wt(t,e,i),c=e.slice(i,l),u=wt(t,c,!1,!1,!0,!1,s),f=B.word(u.length>0?u:[B.literal("")]);if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=Wt(t,e,i),f=e.slice(i,u),d=wt(t,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:B.word(d.length>0?d:[B.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;e[i]==="#"?(c="start",i++):e[i]==="%"&&(c="end",i++);let u=Qf(t,e,i),f=e.slice(i,u),d=wt(t,f,!1,!1,!1),p=B.word(d.length>0?d:[B.literal("")]),h=null,m=u;if(e[u]==="/"){let g=u+1,b=Wt(t,e,g),w=e.slice(g,b),E=wt(t,w,!1,!1,!1);h=B.word(E.length>0?E:[B.literal("")]),m=b}return{operation:{type:"PatternReplacement",pattern:p,replacement:h,all:l,anchor:c},endIndex:m}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=Wt(t,e,i),f=e.slice(i,u),d=f?B.word([B.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:d},endIndex:u}}return o==="@"&&/[QPaAEK]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function $i(t,e,n,r=!1){let s=n+1;if(s>=e.length)return{part:B.literal("$"),endIndex:s};let i=e[s];if(i==="("&&e[s+1]==="(")return t.parseArithmeticExpansion(e,n);if(i==="["){let o=1,a=s+1;for(;a<e.length&&o>0;)e[a]==="["?o++:e[a]==="]"&&o--,o>0&&a++;if(o===0){let l=e.slice(s+1,a),c=ve(t,l);return{part:B.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?t.parseCommandSubstitution(e,n):i==="{"?Gx(t,e,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?Hx(t,e,n):{part:B.literal("$"),endIndex:s}}function Vx(t,e){let n=[],r=0,s="",i=()=>{s&&(n.push(B.literal(s)),s="")};for(;r<e.length;){let o=e[r];if(o==="\\"&&r+1<e.length){let a=e[r+1];if(a==="$"||a==="`"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=$i(t,e,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=t.parseBacktickSubstitution(e,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function Zx(t,e,n){let r=[],s=n,i="",o=()=>{i&&(r.push(B.literal(i)),i="")};for(;s<e.length&&e[s]!=='"';){let a=e[s];if(a==="\\"&&s+1<e.length){let l=e[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=$i(t,e,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=t.parseBacktickSubstitution(e,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:B.doubleQuoted(r),endIndex:s}}function wt(t,e,n=!1,r=!1,s=!1,i=!1,o=!1){if(r)return[B.singleQuoted(e)];if(n){let f=Vx(t,e);return[B.doubleQuoted(f)]}let a=[],l=0,c="",u=()=>{c&&(a.push(B.literal(c)),c="")};for(;l<e.length;){let f=e[l];if(f==="\\"&&l+1<e.length){let d=e[l+1];(i?d==="$"||d==="`"||d==="\\"||d===`
679
683
  `:d==="$"||d==="`"||d==="\\"||d==='"'||d===`
680
- `)?c+=d:c+=`\\${d}`,l+=2;continue}if(f==="'"&&!o&&!i){u();let d=e.indexOf("'",l+1);if(d===-1){c+=e.slice(l);break}a.push(B.singleQuoted(e.slice(l+1,d))),l=d+1;continue}if(f==='"'&&!i){u();let{part:d,endIndex:p}=Wx(t,e,l+1);a.push(d),l=p+1;continue}if(f==="$"&&e[l+1]==="'"){u();let{part:d,endIndex:p}=Zf(t,e,l+2);a.push(d),l=p;continue}if(f==="$"){u();let{part:d,endIndex:p}=Ii(t,e,l);d&&a.push(d),l=p;continue}if(f==="`"){u();let{part:d,endIndex:p}=t.parseBacktickSubstitution(e,l);a.push(d),l=p;continue}if(f==="~"){let d=l>0?e[l-1]:"";if(l===0||d==="="||s&&d===":"){let h=Gf(t,e,l),m=e[h];if(m===void 0||m==="/"||m===":"){u();let g=e.slice(l+1,h)||null;a.push({type:"TildeExpansion",user:g}),l=h;continue}}}if(f==="*"||f==="?"||f==="["){u();let{pattern:d,endIndex:p}=Vf(t,e,l);a.push({type:"Glob",pattern:d}),l=p;continue}if(f==="{"&&!s){let d=Kf(t,e,l,xt);if(d){u(),a.push(d.part),l=d.endIndex;continue}}c+=f,l++}return u(),a}var Pe=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Uf)throw new dt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(e){if(e.length>pi)throw new dt(`Input too large: ${e.length} bytes exceeds limit of ${pi}`,1,1);let n=new Dr(e);if(this.tokens=n.tokenize(),this.tokens.length>hi)throw new dt(`Too many tokens: ${this.tokens.length} exceeds limit of ${hi}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===e||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,n){if(this.check(e))return this.advance();let r=this.current();throw new dt(n||`Expected ${e}, got ${r.type}`,r.line,r.column,r)}error(e){let n=this.current();throw new dt(e,n.line,n.column,n)}skipNewlines(){for(;this.check(y.NEWLINE,y.COMMENT);)this.check(y.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(y.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(y.SEMICOLON,y.COMMENT)){this.advance();continue}if(e&&this.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,n,r,s){this.pendingHeredocs.push({redirect:e,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(y.HEREDOC_CONTENT)){let n=this.advance(),r;e.quoted?r=B.word([B.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),e.redirect.target=B.hereDoc(e.delimiter,r,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(y.EOF,y.NEWLINE,y.SEMICOLON,y.AMP,y.AND_AND,y.OR_OR,y.RPAREN,y.RBRACE,y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===y.WORD||e===y.NAME||e===y.NUMBER||e===y.ASSIGNMENT_WORD||e===y.IF||e===y.FOR||e===y.WHILE||e===y.UNTIL||e===y.CASE||e===y.LPAREN||e===y.LBRACE||e===y.DPAREN_START||e===y.DBRACK_START||e===y.FUNCTION||e===y.BANG||e===y.IN||e===y.LESS||e===y.GREAT||e===y.DLESS||e===y.DGREAT||e===y.LESSAND||e===y.GREATAND||e===y.LESSGREAT||e===y.DLESSDASH||e===y.CLOBBER||e===y.TLESS||e===y.AND_GREAT||e===y.AND_DGREAT}parseScript(){let e=[],r=0;for(this.skipNewlines();!this.check(y.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)"),this.checkUnexpectedToken();let s=this.pos,i=this.parseStatement();i&&e.push(i),this.skipSeparators(!1),this.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===s&&!this.check(y.EOF)&&this.advance()}return B.script(e)}checkUnexpectedToken(){let e=this.current().type,n=this.current().value;(e===y.DO||e===y.DONE||e===y.THEN||e===y.ELSE||e===y.ELIF||e===y.FI||e===y.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),(e===y.RBRACE||e===y.RPAREN)&&this.error(`syntax error near unexpected token \`${n}'`),(e===y.DSEMI||e===y.SEMI_AND||e===y.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),e===y.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`)}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=[],n=[],r=!1,s=this.parsePipeline();for(e.push(s);this.check(y.AND_AND,y.OR_OR);){let i=this.advance();n.push(i.type===y.AND_AND?"&&":"||"),this.skipNewlines();let o=this.parsePipeline();e.push(o)}return this.check(y.AMP)&&(this.advance(),r=!0),B.statement(e,n,r)}parsePipeline(){let e=0;for(;this.check(y.BANG);)this.advance(),e++;let n=e%2===1,r=[],s=this.parseCommand();for(r.push(s);this.check(y.PIPE,y.PIPE_AMP);){let i=this.advance();this.skipNewlines();let o=this.parseCommand();i.type===y.PIPE_AMP&&o.type==="SimpleCommand"&&o.redirections.unshift(B.redirection(">&",B.word([B.literal("1")]),2)),r.push(o)}return B.pipeline(r,n)}parseCommand(){return this.check(y.IF)?xi(this):this.check(y.FOR)?wi(this):this.check(y.WHILE)?bi(this):this.check(y.UNTIL)?Ei(this):this.check(y.CASE)?Si(this):this.check(y.LPAREN)?Ci(this):this.check(y.LBRACE)?Ai(this):this.check(y.DPAREN_START)?this.parseArithmeticCommand():this.check(y.DBRACK_START)?this.parseConditionalCommand():this.check(y.FUNCTION)?this.parseFunctionDef():this.check(y.NAME,y.WORD)&&this.peek(1).type===y.LPAREN&&this.peek(2).type===y.RPAREN?this.parseFunctionDef():Yf(this)}isWord(){let e=this.current().type;return e===y.WORD||e===y.NAME||e===y.NUMBER||e===y.IF||e===y.FOR||e===y.WHILE||e===y.UNTIL||e===y.CASE||e===y.FUNCTION||e===y.ELSE||e===y.ELIF||e===y.FI||e===y.THEN||e===y.DO||e===y.DONE||e===y.ESAC||e===y.IN||e===y.SELECT||e===y.TIME||e===y.COPROC||e===y.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordFromString(e,n=!1,r=!1,s=!1,i=!1){let o=xt(this,e,n,r,s,i);return B.word(o)}parseCommandSubstitution(e,n){let r=n+2,s=1,i=r,o=!1,a=!1,l=0,c=!1,u="";for(;i<e.length&&s>0;){let h=e[i];o?h==="'"&&(o=!1):a?h==="\\"&&i+1<e.length?i++:h==='"'&&(a=!1):h==="'"?(o=!0,u=""):h==='"'?(a=!0,u=""):h==="\\"&&i+1<e.length?(i++,u=""):/[a-zA-Z_]/.test(h)?u+=h:(u==="case"?(l++,c=!1):u==="in"&&l>0?c=!0:u==="esac"&&l>0&&(l--,c=!1),u="",h==="("?i>0&&e[i-1]==="$"?s++:c||s++:h===")"?c?c=!1:s--:h===";"&&l>0&&i+1<e.length&&e[i+1]===";"&&(c=!0)),s>0&&i++}s>0&&this.error("unexpected EOF while looking for matching `)'");let f=e.slice(r,i),p=new t().parse(f);return{part:B.commandSubstitution(p,!1),endIndex:i+1}}parseBacktickSubstitution(e,n,r=!1){let i=n+1,o="";for(;i<e.length&&e[i]!=="`";)if(e[i]==="\\"){let c=e[i+1];c==="$"||c==="`"||c==="\\"||c===`
684
+ `)?c+=d:c+=`\\${d}`,l+=2;continue}if(f==="'"&&!o&&!i){u();let d=e.indexOf("'",l+1);if(d===-1){c+=e.slice(l);break}a.push(B.singleQuoted(e.slice(l+1,d))),l=d+1;continue}if(f==='"'&&!i){u();let{part:d,endIndex:p}=Zx(t,e,l+1);a.push(d),l=p+1;continue}if(f==="$"&&e[l+1]==="'"){u();let{part:d,endIndex:p}=Jf(t,e,l+2);a.push(d),l=p;continue}if(f==="$"){u();let{part:d,endIndex:p}=$i(t,e,l);d&&a.push(d),l=p;continue}if(f==="`"){u();let{part:d,endIndex:p}=t.parseBacktickSubstitution(e,l);a.push(d),l=p;continue}if(f==="~"){let d=l>0?e[l-1]:"";if(l===0||d==="="||s&&d===":"){let h=Kf(t,e,l),m=e[h];if(m===void 0||m==="/"||m===":"){u();let g=e.slice(l+1,h)||null;a.push({type:"TildeExpansion",user:g}),l=h;continue}}}if(f==="*"||f==="?"||f==="["){u();let{pattern:d,endIndex:p}=Xf(t,e,l);a.push({type:"Glob",pattern:d}),l=p;continue}if(f==="{"&&!s){let d=Yf(t,e,l,wt);if(d){u(),a.push(d.part),l=d.endIndex;continue}}c+=f,l++}return u(),a}var Fe=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Gf)throw new pt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(e){if(e.length>mi)throw new pt(`Input too large: ${e.length} bytes exceeds limit of ${mi}`,1,1);let n=new Lr(e);if(this.tokens=n.tokenize(),this.tokens.length>gi)throw new pt(`Too many tokens: ${this.tokens.length} exceeds limit of ${gi}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===e||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,n){if(this.check(e))return this.advance();let r=this.current();throw new pt(n||`Expected ${e}, got ${r.type}`,r.line,r.column,r)}error(e){let n=this.current();throw new pt(e,n.line,n.column,n)}skipNewlines(){for(;this.check(y.NEWLINE,y.COMMENT);)this.check(y.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(y.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(y.SEMICOLON,y.COMMENT)){this.advance();continue}if(e&&this.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,n,r,s){this.pendingHeredocs.push({redirect:e,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(y.HEREDOC_CONTENT)){let n=this.advance(),r;e.quoted?r=B.word([B.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),e.redirect.target=B.hereDoc(e.delimiter,r,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(y.EOF,y.NEWLINE,y.SEMICOLON,y.AMP,y.AND_AND,y.OR_OR,y.RPAREN,y.RBRACE,y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===y.WORD||e===y.NAME||e===y.NUMBER||e===y.ASSIGNMENT_WORD||e===y.IF||e===y.FOR||e===y.WHILE||e===y.UNTIL||e===y.CASE||e===y.LPAREN||e===y.LBRACE||e===y.DPAREN_START||e===y.DBRACK_START||e===y.FUNCTION||e===y.BANG||e===y.IN||e===y.LESS||e===y.GREAT||e===y.DLESS||e===y.DGREAT||e===y.LESSAND||e===y.GREATAND||e===y.LESSGREAT||e===y.DLESSDASH||e===y.CLOBBER||e===y.TLESS||e===y.AND_GREAT||e===y.AND_DGREAT}parseScript(){let e=[],r=0;for(this.skipNewlines();!this.check(y.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)"),this.checkUnexpectedToken();let s=this.pos,i=this.parseStatement();i&&e.push(i),this.skipSeparators(!1),this.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===s&&!this.check(y.EOF)&&this.advance()}return B.script(e)}checkUnexpectedToken(){let e=this.current().type,n=this.current().value;(e===y.DO||e===y.DONE||e===y.THEN||e===y.ELSE||e===y.ELIF||e===y.FI||e===y.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),(e===y.RBRACE||e===y.RPAREN)&&this.error(`syntax error near unexpected token \`${n}'`),(e===y.DSEMI||e===y.SEMI_AND||e===y.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),e===y.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`)}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=[],n=[],r=!1,s=this.parsePipeline();for(e.push(s);this.check(y.AND_AND,y.OR_OR);){let i=this.advance();n.push(i.type===y.AND_AND?"&&":"||"),this.skipNewlines();let o=this.parsePipeline();e.push(o)}return this.check(y.AMP)&&(this.advance(),r=!0),B.statement(e,n,r)}parsePipeline(){let e=0;for(;this.check(y.BANG);)this.advance(),e++;let n=e%2===1,r=[],s=this.parseCommand();for(r.push(s);this.check(y.PIPE,y.PIPE_AMP);){let i=this.advance();this.skipNewlines();let o=this.parseCommand();i.type===y.PIPE_AMP&&o.type==="SimpleCommand"&&o.redirections.unshift(B.redirection(">&",B.word([B.literal("1")]),2)),r.push(o)}return B.pipeline(r,n)}parseCommand(){return this.check(y.IF)?bi(this):this.check(y.FOR)?Ei(this):this.check(y.WHILE)?Si(this):this.check(y.UNTIL)?Ci(this):this.check(y.CASE)?Ai(this):this.check(y.LPAREN)?ki(this):this.check(y.LBRACE)?Ni(this):this.check(y.DPAREN_START)?this.parseArithmeticCommand():this.check(y.DBRACK_START)?this.parseConditionalCommand():this.check(y.FUNCTION)?this.parseFunctionDef():this.check(y.NAME,y.WORD)&&this.peek(1).type===y.LPAREN&&this.peek(2).type===y.RPAREN?this.parseFunctionDef():rd(this)}isWord(){let e=this.current().type;return e===y.WORD||e===y.NAME||e===y.NUMBER||e===y.IF||e===y.FOR||e===y.WHILE||e===y.UNTIL||e===y.CASE||e===y.FUNCTION||e===y.ELSE||e===y.ELIF||e===y.FI||e===y.THEN||e===y.DO||e===y.DONE||e===y.ESAC||e===y.IN||e===y.SELECT||e===y.TIME||e===y.COPROC||e===y.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordFromString(e,n=!1,r=!1,s=!1,i=!1){let o=wt(this,e,n,r,s,i);return B.word(o)}parseCommandSubstitution(e,n){let r=n+2,s=1,i=r,o=!1,a=!1,l=0,c=!1,u="";for(;i<e.length&&s>0;){let h=e[i];o?h==="'"&&(o=!1):a?h==="\\"&&i+1<e.length?i++:h==='"'&&(a=!1):h==="'"?(o=!0,u=""):h==='"'?(a=!0,u=""):h==="\\"&&i+1<e.length?(i++,u=""):/[a-zA-Z_]/.test(h)?u+=h:(u==="case"?(l++,c=!1):u==="in"&&l>0?c=!0:u==="esac"&&l>0&&(l--,c=!1),u="",h==="("?i>0&&e[i-1]==="$"?s++:c||s++:h===")"?c?c=!1:s--:h===";"&&l>0&&i+1<e.length&&e[i+1]===";"&&(c=!0)),s>0&&i++}s>0&&this.error("unexpected EOF while looking for matching `)'");let f=e.slice(r,i),p=new t().parse(f);return{part:B.commandSubstitution(p,!1),endIndex:i+1}}parseBacktickSubstitution(e,n,r=!1){let i=n+1,o="";for(;i<e.length&&e[i]!=="`";)if(e[i]==="\\"){let c=e[i+1];c==="$"||c==="`"||c==="\\"||c===`
681
685
  `||r&&c==='"'?(c!==`
682
- `&&(o+=c),i+=2):(o+=e[i],i++)}else o+=e[i],i++;i>=e.length&&this.error("unexpected EOF while looking for matching ``'");let l=new t().parse(o);return{part:B.commandSubstitution(l,!0),endIndex:i+1}}parseArithmeticExpansion(e,n){let r=n+3,s=1,i=0,o=r;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(r,o),l=this.parseArithmeticExpression(a);return{part:B.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){this.expect(y.DPAREN_START);let e="",n=1,r=0,s=!1,i=!1;for(;n>0&&!this.check(y.EOF);){if(s){if(s=!1,r>0){r--,e+=")";continue}if(this.check(y.RPAREN)){n--,i=!0,this.advance();continue}if(this.check(y.DPAREN_END)){n--,i=!0;continue}e+=")";continue}this.check(y.DPAREN_START)?(n++,e+="((",this.advance()):this.check(y.DPAREN_END)?r>=2?(r-=2,e+="))",this.advance()):r===1?(r--,e+=")",s=!0,this.advance()):(n--,i=!0,n>0&&(e+="))"),this.advance()):this.check(y.LPAREN)?(r++,e+="(",this.advance()):this.check(y.RPAREN)?(r>0&&r--,e+=")",this.advance()):(e+=this.current().value,this.advance())}i||this.expect(y.DPAREN_END);let o=this.parseArithmeticExpression(e.trim()),a=this.parseOptionalRedirections();return B.arithmeticCommand(o,a)}parseConditionalCommand(){this.expect(y.DBRACK_START);let e=Ni(this);this.expect(y.DBRACK_END);let n=this.parseOptionalRedirections();return B.conditionalCommand(e,n)}parseFunctionDef(){let e;this.check(y.FUNCTION)?(this.advance(),e=this.expect(y.NAME,"Expected function name").value,this.check(y.LPAREN)&&(this.advance(),this.expect(y.RPAREN))):(e=this.advance().value,this.expect(y.LPAREN),this.expect(y.RPAREN)),this.skipNewlines();let n=this.parseCompoundCommandBody(),r=this.parseOptionalRedirections();return B.functionDef(e,n,r)}parseCompoundCommandBody(){if(this.check(y.LBRACE))return Ai(this);if(this.check(y.LPAREN))return Ci(this);if(this.check(y.IF))return xi(this);if(this.check(y.FOR))return wi(this);if(this.check(y.WHILE))return bi(this);if(this.check(y.UNTIL))return Ei(this);if(this.check(y.CASE))return Si(this);this.error("Expected compound command for function body")}parseCompoundList(){let e=[];for(this.skipNewlines();!this.check(y.EOF,y.FI,y.ELSE,y.ELIF,y.THEN,y.DO,y.DONE,y.ESAC,y.RPAREN,y.RBRACE,y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,r=this.parseStatement();if(r&&e.push(r),this.skipSeparators(),this.pos===n&&!r)break}return e}parseOptionalRedirections(){let e=[];for(;Lr(this);){this.checkIterationLimit();let n=this.pos;if(e.push(Mr(this)),this.pos===n)break}return e}parseArithmeticExpression(e){return ve(this,e)}};function wt(t){return new Pe().parse(t)}fe();Ht();var un=class{fs;cwd;constructor(e,n){this.fs=e,this.cwd=n}isGlobPattern(e){return e.includes("*")||e.includes("?")||/\[.*\]/.test(e)}async expandArgs(e,n){let r=e.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<e.length;o++){let a=s[o];a===null?i.push(e[o]):a.length>0?i.push(...a):i.push(e[o])}return i}async expand(e){return e.includes("**")?this.expandRecursive(e):this.expandSimple(e)}async expandSimple(e){let n=[],r=e.lastIndexOf("/"),s,i;r===-1?(s=this.cwd,i=e):(s=e.slice(0,r)||"/",i=e.slice(r+1));let o=this.fs.resolvePath(this.cwd,s);try{let a=await this.fs.readdir(o);for(let l of a)if(this.matchPattern(l,i)){let c=r===-1?l:`${s}/${l}`;n.push(c)}}catch{}return n.sort()}async expandRecursive(e){let n=[],r=e.indexOf("**"),s=e.slice(0,r).replace(/\/$/,"")||".",o=e.slice(r+2).replace(/^\//,"");return await this.walkDirectory(s,o,n),n.sort()}async walkDirectory(e,n,r){let s=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=e==="."?l.name:`${e}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,n,r)))}}else{let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let d=e==="."?f:`${e}/${f}`,p=this.fs.resolvePath(this.cwd,d);try{let h=await this.fs.stat(p);return{name:f,path:d,isDirectory:h.isDirectory}}catch{return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch{}}matchPattern(e,n){return this.patternToRegex(n).test(e)}patternToRegex(e){let n="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=r+1,o="[";for(i<e.length&&(e[i]==="^"||e[i]==="!")&&(o+="^",i++),i<e.length&&e[i]==="]"&&(o+="\\]",i++);i<e.length&&e[i]!=="]";){if(e[i]==="["&&i+1<e.length&&e[i+1]===":"){let a=e.indexOf(":]",i+2);if(a!==-1){let l=e.slice(i+2,a),c=this.posixClassToRegex(l);o+=c,i=a+2;continue}}if(e[i]==="\\"&&i+1<e.length){o+=`\\${e[i+1]}`,i+=2;continue}e[i]==="-"?o+="\\-":o+=e[i],i++}o+="]",n+=o,r=i}else if(s==="\\"&&r+1<e.length){let i=e[r+1];/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i,r++}else/[.+^${}()|]/.test(s)?n+=`\\${s}`:n+=s}return n+="$",new RegExp(n)}posixClassToRegex(e){return{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"!-~",lower:"a-z",print:" -~",punct:"!-/:-@\\[-`{-~",space:" \\t\\n\\r\\f\\v",upper:"A-Z",word:"a-zA-Z0-9_",xdigit:"0-9a-fA-F"}[e]||""}};fe();function Ye(t){switch(t.type){case"ArithCommandSubst":return!0;case"ArithNested":return Ye(t.expression);case"ArithBinary":return Ye(t.left)||Ye(t.right);case"ArithUnary":return Ye(t.operand);case"ArithTernary":return Ye(t.condition)||Ye(t.consequent)||Ye(t.alternate);case"ArithAssignment":return Ye(t.value);case"ArithGroup":return Ye(t.expression);case"ArithArrayElement":return t.index?Ye(t.index):!1;case"ArithConcat":return t.parts.some(Ye);default:return!1}}function vi(t){let e=t.operation;return e?!!("word"in e&&e.word&&pt(e.word)||e.type==="PatternReplacement"&&(e.pattern&&pt(e.pattern)||e.replacement&&pt(e.replacement))||e.type==="PatternRemoval"&&e.pattern&&pt(e.pattern)):!1}function _r(t){switch(t.type){case"CommandSubstitution":return!0;case"ArithmeticExpansion":return Ye(t.expression.expression);case"DoubleQuoted":return t.parts.some(_r);case"BraceExpansion":return t.items.some(e=>e.type==="Word"&&pt(e.word));case"ParameterExpansion":return vi(t);default:return!1}}function pt(t){return t.parts.some(_r)}function $i(t){if(!t.operation)return!1;let e=t.operation,n;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(n=e.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function td(t){let e=!1,n=!1,r=!1,s=!1,i=!1;for(let o of t){if((o.type==="SingleQuoted"||o.type==="DoubleQuoted")&&(e=!0,o.type==="DoubleQuoted"))for(let a of o.parts)a.type==="ParameterExpansion"&&a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&!a.operation&&(s=!0);o.type==="CommandSubstitution"&&(n=!0),o.type==="ParameterExpansion"&&(i=!0,(o.parameter==="@"||o.parameter==="*")&&(r=!0),$i(o)&&(e=!0))}return{hasQuoted:e,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i}}function jx(t,e,n,r,s){let i=n??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,d=String(Math.abs(u)).padStart(l,"0");return f?`-${d}`:d}return String(u)};if(t<=e)for(let u=t,f=0;u<=e&&f<1e4;u+=o,f++)a.push(c(u));else for(let u=t,f=0;u>=e&&f<1e4;u-=o,f++)a.push(c(u));return a}function zx(t,e,n){let r=n??1;r===0&&(r=1);let s=t.charCodeAt(0),i=e.charCodeAt(0),o=Math.abs(r),a=t>="A"&&t<="Z",l=t>="a"&&t<="z",c=e>="A"&&e<="Z",u=e>="a"&&e<="z";if(a&&u||l&&c)return null;let f=[];if(s<=i)for(let d=s,p=0;d<=i&&p<1e4;d+=o,p++)f.push(String.fromCharCode(d));else for(let d=s,p=0;d>=i&&p<1e4;d-=o,p++)f.push(String.fromCharCode(d));return f}function _n(t,e,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof t=="number"&&typeof e=="number"?{expanded:jx(t,e,n,r,s),literal:`{${t}..${e}${i}}`}:typeof t=="string"&&typeof e=="string"?{expanded:zx(t,e,n),literal:`{${t}..${e}${i}}`}:{expanded:null,literal:`{${t}..${e}${i}}`}}function qe(t,e){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\")if(r+1<t.length){let i=t[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r+=2}else n+="\\\\",r++;else if(s==="*")n+=e?".*":".*?",r++;else if(s==="?")n+=".",r++;else if(s==="["){let i=Hx(t,r);if(i===-1)n+="\\[",r++;else{let o=t.slice(r+1,i);n+=Gx(o),r=i+1}}else/[\^$.|+(){}]/.test(s)?(n+=`\\${s}`,r++):(n+=s,r++)}return n}function Hx(t,e){let n=e+1;for(n<t.length&&t[n]==="^"&&n++,n<t.length&&t[n]==="]"&&n++;n<t.length;){if(t[n]==="\\"&&n+1<t.length){n+=2;continue}if(t[n]==="]")return n;if(t[n]==="'"){let r=t.indexOf("'",n+1);if(r!==-1){n=r+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let r=t.indexOf(":]",n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function Gx(t){let e="[",n=0;for((t[0]==="^"||t[0]==="!")&&(e+="^",n++);n<t.length;){if(t[n]==="'"){let s=t.indexOf("'",n+1);if(s!==-1){let i=t.slice(n+1,s);for(let o of i)o==="\\"?e+="\\\\":o==="]"?e+="\\]":o==="^"&&e==="["?e+="\\^":e+=o;n=s+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){let i=t.slice(n+2,s);e+=Vx(i),n=s+2;continue}}let r=t[n];r==="\\"?n+1<t.length?(e+=`\\${t[n+1]}`,n+=2):(e+="\\\\",n++):r==="-"&&n>0&&n<t.length-1?(e+="-",n++):r==="^"&&n===0?(e+="^",n++):(r==="]"&&n===0?e+="\\]":e+=r,n++)}return e+="]",e}var qx={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"!-~",lower:"a-z",print:" -~",punct:"!-/:-@\\[-`{-~",space:" \\t\\n\\r\\f\\v",upper:"A-Z",word:"a-zA-Z0-9_",xdigit:"0-9A-Fa-f"};function Vx(t){return qx[t]??""}fe();function Bn(t,e){let n=`${e}_`,r=[];for(let s of Object.keys(t.state.env))if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function Wn(t,e){let n=`${e}_`;for(let r of Object.keys(t.state.env))r.startsWith(n)&&delete t.state.env[r]}function Ri(t,e){let n=`${e}_`,r=[];for(let s of Object.keys(t.state.env))if(s.startsWith(n)&&!s.includes("__")){let i=s.slice(n.length);r.push(i)}return r.sort()}function nd(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function Br(t){return t.IFS??`
683
- `}function rd(t){return t.IFS===""}function Un(t){return t.split("").map(e=>/[\\^$.*+?()[\]{}|-]/.test(e)?`\\${e}`:e===" "?"\\t":e===`
684
- `?"\\n":e).join("")}function Zx(t,e){let n=Un(t);return new RegExp(`[${n}]+`,e)}function Kx(t){let e=Un(t);return new RegExp(`^[${e}]+`)}function Qx(t){let e=Un(t);return new RegExp(`[${e}]+$`)}function fn(t){let e=t.IFS;return e===void 0?" ":e[0]||""}function sd(t,e){if(e==="")return{words:[t],wordStarts:[0]};let n=[],r=[],s=Zx(e,"g"),i=0,o=t.match(Kx(e));o&&(i=o[0].length),s.lastIndex=i;let a=s.exec(t);for(;a!==null;)a.index>i&&(r.push(i),n.push(t.substring(i,a.index))),i=s.lastIndex,a=s.exec(t);return i<t.length&&(r.push(i),n.push(t.substring(i))),{words:n,wordStarts:r}}function id(t,e){return e===""?t:t.replace(Qx(e),"")}function $e(t,e){return t.state.associativeArrays?.has(e)?Ri(t,e).map(i=>[i,t.state.env[`${e}_${i}`]]):Bn(t,e).map(s=>[s,t.state.env[`${e}_${s}`]])}function od(t,e){return t.state.associativeArrays?.has(e)?Ri(t,e).length>0:Bn(t,e).length>0}function et(t,e,n=!0,r=!1){switch(e){case"?":return String(t.state.lastExitCode);case"$":return String(process.pid);case"#":return t.state.env["#"]||"0";case"@":return t.state.env["@"]||"";case"_":return t.state.lastArg;case"-":{let o="";return t.state.options.errexit&&(o+="e"),t.state.options.nounset&&(o+="u"),t.state.options.verbose&&(o+="v"),t.state.options.xtrace&&(o+="x"),t.state.options.pipefail&&(o+="p"),o}case"*":{let o=Number.parseInt(t.state.env["#"]||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(t.state.env[String(l)]||"");return a.join(fn(t.state.env))}case"0":return t.state.env[0]||"bash";case"PWD":return t.state.env.PWD!==void 0?t.state.env.PWD:"";case"OLDPWD":return t.state.env.OLDPWD!==void 0?t.state.env.OLDPWD:"";case"PPID":{let{ppid:o}=Mn();return String(o)}case"UID":{let{uid:o}=Mn();return String(o)}case"EUID":return String(process.geteuid?.()??Mn().uid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-t.state.startTime)/1e3));case"BASH_VERSION":return kf;case"!":return String(t.state.lastBackgroundPid);case"LINENO":return String(t.state.currentLine)}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(e))throw new ct(`\${${e}}`);let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(a==="@"||a==="*"){let f=$e(t,o);if(f.length>0)return f.map(([,p])=>p).join(" ");let d=t.state.env[o];return d!==void 0?d:""}if(t.state.associativeArrays?.has(o)){let f=nd(a),d=t.state.env[`${o}_${f}`];if(d===void 0&&n&&t.state.options.nounset)throw new Xe(`${o}[${a}]`);return d||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new Pe,d=ve(f,a);c=re(t,d.expression)}catch{let f=t.state.env[a];c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=$e(t,o);if(f.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${o}: bad array subscript
686
+ `&&(o+=c),i+=2):(o+=e[i],i++)}else o+=e[i],i++;i>=e.length&&this.error("unexpected EOF while looking for matching ``'");let l=new t().parse(o);return{part:B.commandSubstitution(l,!0),endIndex:i+1}}parseArithmeticExpansion(e,n){let r=n+3,s=1,i=0,o=r;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(r,o),l=this.parseArithmeticExpression(a);return{part:B.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){this.expect(y.DPAREN_START);let e="",n=1,r=0,s=!1,i=!1;for(;n>0&&!this.check(y.EOF);){if(s){if(s=!1,r>0){r--,e+=")";continue}if(this.check(y.RPAREN)){n--,i=!0,this.advance();continue}if(this.check(y.DPAREN_END)){n--,i=!0;continue}e+=")";continue}this.check(y.DPAREN_START)?(n++,e+="((",this.advance()):this.check(y.DPAREN_END)?r>=2?(r-=2,e+="))",this.advance()):r===1?(r--,e+=")",s=!0,this.advance()):(n--,i=!0,n>0&&(e+="))"),this.advance()):this.check(y.LPAREN)?(r++,e+="(",this.advance()):this.check(y.RPAREN)?(r>0&&r--,e+=")",this.advance()):(e+=this.current().value,this.advance())}i||this.expect(y.DPAREN_END);let o=this.parseArithmeticExpression(e.trim()),a=this.parseOptionalRedirections();return B.arithmeticCommand(o,a)}parseConditionalCommand(){this.expect(y.DBRACK_START);let e=vi(this);this.expect(y.DBRACK_END);let n=this.parseOptionalRedirections();return B.conditionalCommand(e,n)}parseFunctionDef(){let e;this.check(y.FUNCTION)?(this.advance(),e=this.expect(y.NAME,"Expected function name").value,this.check(y.LPAREN)&&(this.advance(),this.expect(y.RPAREN))):(e=this.advance().value,this.expect(y.LPAREN),this.expect(y.RPAREN)),this.skipNewlines();let n=this.parseCompoundCommandBody(),r=this.parseOptionalRedirections();return B.functionDef(e,n,r)}parseCompoundCommandBody(){if(this.check(y.LBRACE))return Ni(this);if(this.check(y.LPAREN))return ki(this);if(this.check(y.IF))return bi(this);if(this.check(y.FOR))return Ei(this);if(this.check(y.WHILE))return Si(this);if(this.check(y.UNTIL))return Ci(this);if(this.check(y.CASE))return Ai(this);this.error("Expected compound command for function body")}parseCompoundList(){let e=[];for(this.skipNewlines();!this.check(y.EOF,y.FI,y.ELSE,y.ELIF,y.THEN,y.DO,y.DONE,y.ESAC,y.RPAREN,y.RBRACE,y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,r=this.parseStatement();if(r&&e.push(r),this.skipSeparators(),this.pos===n&&!r)break}return e}parseOptionalRedirections(){let e=[];for(;Mr(this);){this.checkIterationLimit();let n=this.pos;if(e.push(_r(this)),this.pos===n)break}return e}parseArithmeticExpression(e){return ve(this,e)}};function bt(t){return new Fe().parse(t)}de();Gt();var fn=class{fs;cwd;constructor(e,n){this.fs=e,this.cwd=n}isGlobPattern(e){return e.includes("*")||e.includes("?")||/\[.*\]/.test(e)}async expandArgs(e,n){let r=e.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<e.length;o++){let a=s[o];a===null?i.push(e[o]):a.length>0?i.push(...a):i.push(e[o])}return i}async expand(e){return e.includes("**")?this.expandRecursive(e):this.expandSimple(e)}async expandSimple(e){let n=[],r=e.lastIndexOf("/"),s,i;r===-1?(s=this.cwd,i=e):(s=e.slice(0,r)||"/",i=e.slice(r+1));let o=this.fs.resolvePath(this.cwd,s);try{let a=await this.fs.readdir(o);for(let l of a)if(this.matchPattern(l,i)){let c=r===-1?l:`${s}/${l}`;n.push(c)}}catch{}return n.sort()}async expandRecursive(e){let n=[],r=e.indexOf("**"),s=e.slice(0,r).replace(/\/$/,"")||".",o=e.slice(r+2).replace(/^\//,"");return await this.walkDirectory(s,o,n),n.sort()}async walkDirectory(e,n,r){let s=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=e==="."?l.name:`${e}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,n,r)))}}else{let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let d=e==="."?f:`${e}/${f}`,p=this.fs.resolvePath(this.cwd,d);try{let h=await this.fs.stat(p);return{name:f,path:d,isDirectory:h.isDirectory}}catch{return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch{}}matchPattern(e,n){return this.patternToRegex(n).test(e)}patternToRegex(e){let n="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=r+1,o="[";for(i<e.length&&(e[i]==="^"||e[i]==="!")&&(o+="^",i++),i<e.length&&e[i]==="]"&&(o+="\\]",i++);i<e.length&&e[i]!=="]";){if(e[i]==="["&&i+1<e.length&&e[i+1]===":"){let a=e.indexOf(":]",i+2);if(a!==-1){let l=e.slice(i+2,a),c=this.posixClassToRegex(l);o+=c,i=a+2;continue}}if(e[i]==="\\"&&i+1<e.length){o+=`\\${e[i+1]}`,i+=2;continue}e[i]==="-"?o+="\\-":o+=e[i],i++}o+="]",n+=o,r=i}else if(s==="\\"&&r+1<e.length){let i=e[r+1];/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i,r++}else/[.+^${}()|]/.test(s)?n+=`\\${s}`:n+=s}return n+="$",new RegExp(n)}posixClassToRegex(e){return{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"!-~",lower:"a-z",print:" -~",punct:"!-/:-@\\[-`{-~",space:" \\t\\n\\r\\f\\v",upper:"A-Z",word:"a-zA-Z0-9_",xdigit:"0-9a-fA-F"}[e]||""}};de();function Ye(t){switch(t.type){case"ArithCommandSubst":return!0;case"ArithNested":return Ye(t.expression);case"ArithBinary":return Ye(t.left)||Ye(t.right);case"ArithUnary":return Ye(t.operand);case"ArithTernary":return Ye(t.condition)||Ye(t.consequent)||Ye(t.alternate);case"ArithAssignment":return Ye(t.value);case"ArithGroup":return Ye(t.expression);case"ArithArrayElement":return t.index?Ye(t.index):!1;case"ArithConcat":return t.parts.some(Ye);default:return!1}}function Ri(t){let e=t.operation;return e?!!("word"in e&&e.word&&ht(e.word)||e.type==="PatternReplacement"&&(e.pattern&&ht(e.pattern)||e.replacement&&ht(e.replacement))||e.type==="PatternRemoval"&&e.pattern&&ht(e.pattern)):!1}function Br(t){switch(t.type){case"CommandSubstitution":return!0;case"ArithmeticExpansion":return Ye(t.expression.expression);case"DoubleQuoted":return t.parts.some(Br);case"BraceExpansion":return t.items.some(e=>e.type==="Word"&&ht(e.word));case"ParameterExpansion":return Ri(t);default:return!1}}function ht(t){return t.parts.some(Br)}function Fi(t){if(!t.operation)return!1;let e=t.operation,n;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(n=e.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function id(t){let e=!1,n=!1,r=!1,s=!1,i=!1;for(let o of t){if((o.type==="SingleQuoted"||o.type==="DoubleQuoted")&&(e=!0,o.type==="DoubleQuoted"))for(let a of o.parts)a.type==="ParameterExpansion"&&a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&!a.operation&&(s=!0);o.type==="CommandSubstitution"&&(n=!0),o.type==="ParameterExpansion"&&(i=!0,(o.parameter==="@"||o.parameter==="*")&&(r=!0),Fi(o)&&(e=!0))}return{hasQuoted:e,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i}}function Qx(t,e,n,r,s){let i=n??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,d=String(Math.abs(u)).padStart(l,"0");return f?`-${d}`:d}return String(u)};if(t<=e)for(let u=t,f=0;u<=e&&f<1e4;u+=o,f++)a.push(c(u));else for(let u=t,f=0;u>=e&&f<1e4;u-=o,f++)a.push(c(u));return a}function Xx(t,e,n){let r=n??1;r===0&&(r=1);let s=t.charCodeAt(0),i=e.charCodeAt(0),o=Math.abs(r),a=t>="A"&&t<="Z",l=t>="a"&&t<="z",c=e>="A"&&e<="Z",u=e>="a"&&e<="z";if(a&&u||l&&c)return null;let f=[];if(s<=i)for(let d=s,p=0;d<=i&&p<1e4;d+=o,p++)f.push(String.fromCharCode(d));else for(let d=s,p=0;d>=i&&p<1e4;d-=o,p++)f.push(String.fromCharCode(d));return f}function Wn(t,e,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof t=="number"&&typeof e=="number"?{expanded:Qx(t,e,n,r,s),literal:`{${t}..${e}${i}}`}:typeof t=="string"&&typeof e=="string"?{expanded:Xx(t,e,n),literal:`{${t}..${e}${i}}`}:{expanded:null,literal:`{${t}..${e}${i}}`}}function qe(t,e){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\")if(r+1<t.length){let i=t[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r+=2}else n+="\\\\",r++;else if(s==="*")n+=e?".*":".*?",r++;else if(s==="?")n+=".",r++;else if(s==="["){let i=Jx(t,r);if(i===-1)n+="\\[",r++;else{let o=t.slice(r+1,i);n+=Yx(o),r=i+1}}else/[\^$.|+(){}]/.test(s)?(n+=`\\${s}`,r++):(n+=s,r++)}return n}function Jx(t,e){let n=e+1;for(n<t.length&&t[n]==="^"&&n++,n<t.length&&t[n]==="]"&&n++;n<t.length;){if(t[n]==="\\"&&n+1<t.length){n+=2;continue}if(t[n]==="]")return n;if(t[n]==="'"){let r=t.indexOf("'",n+1);if(r!==-1){n=r+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let r=t.indexOf(":]",n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function Yx(t){let e="[",n=0;for((t[0]==="^"||t[0]==="!")&&(e+="^",n++);n<t.length;){if(t[n]==="'"){let s=t.indexOf("'",n+1);if(s!==-1){let i=t.slice(n+1,s);for(let o of i)o==="\\"?e+="\\\\":o==="]"?e+="\\]":o==="^"&&e==="["?e+="\\^":e+=o;n=s+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){let i=t.slice(n+2,s);e+=tw(i),n=s+2;continue}}let r=t[n];r==="\\"?n+1<t.length?(e+=`\\${t[n+1]}`,n+=2):(e+="\\\\",n++):r==="-"&&n>0&&n<t.length-1?(e+="-",n++):r==="^"&&n===0?(e+="^",n++):(r==="]"&&n===0?e+="\\]":e+=r,n++)}return e+="]",e}var ew={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"!-~",lower:"a-z",print:" -~",punct:"!-/:-@\\[-`{-~",space:" \\t\\n\\r\\f\\v",upper:"A-Z",word:"a-zA-Z0-9_",xdigit:"0-9A-Fa-f"};function tw(t){return ew[t]??""}de();function Un(t,e){let n=`${e}_`,r=[];for(let s of Object.keys(t.state.env))if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function jn(t,e){let n=`${e}_`;for(let r of Object.keys(t.state.env))r.startsWith(n)&&delete t.state.env[r]}function Pi(t,e){let n=`${e}_`,r=[];for(let s of Object.keys(t.state.env))if(s.startsWith(n)&&!s.includes("__")){let i=s.slice(n.length);r.push(i)}return r.sort()}function od(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function Wr(t){return t.IFS??`
687
+ `}function ad(t){return t.IFS===""}function zn(t){return t.split("").map(e=>/[\\^$.*+?()[\]{}|-]/.test(e)?`\\${e}`:e===" "?"\\t":e===`
688
+ `?"\\n":e).join("")}function nw(t,e){let n=zn(t);return new RegExp(`[${n}]+`,e)}function rw(t){let e=zn(t);return new RegExp(`^[${e}]+`)}function sw(t){let e=zn(t);return new RegExp(`[${e}]+$`)}function dn(t){let e=t.IFS;return e===void 0?" ":e[0]||""}function ld(t,e){if(e==="")return{words:[t],wordStarts:[0]};let n=[],r=[],s=nw(e,"g"),i=0,o=t.match(rw(e));o&&(i=o[0].length),s.lastIndex=i;let a=s.exec(t);for(;a!==null;)a.index>i&&(r.push(i),n.push(t.substring(i,a.index))),i=s.lastIndex,a=s.exec(t);return i<t.length&&(r.push(i),n.push(t.substring(i))),{words:n,wordStarts:r}}function cd(t,e){return e===""?t:t.replace(sw(e),"")}function $e(t,e){return t.state.associativeArrays?.has(e)?Pi(t,e).map(i=>[i,t.state.env[`${e}_${i}`]]):Un(t,e).map(s=>[s,t.state.env[`${e}_${s}`]])}function ud(t,e){return t.state.associativeArrays?.has(e)?Pi(t,e).length>0:Un(t,e).length>0}function et(t,e,n=!0,r=!1){switch(e){case"?":return String(t.state.lastExitCode);case"$":return String(process.pid);case"#":return t.state.env["#"]||"0";case"@":return t.state.env["@"]||"";case"_":return t.state.lastArg;case"-":{let o="";return t.state.options.errexit&&(o+="e"),t.state.options.nounset&&(o+="u"),t.state.options.verbose&&(o+="v"),t.state.options.xtrace&&(o+="x"),t.state.options.pipefail&&(o+="p"),o}case"*":{let o=Number.parseInt(t.state.env["#"]||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(t.state.env[String(l)]||"");return a.join(dn(t.state.env))}case"0":return t.state.env[0]||"bash";case"PWD":return t.state.env.PWD!==void 0?t.state.env.PWD:"";case"OLDPWD":return t.state.env.OLDPWD!==void 0?t.state.env.OLDPWD:"";case"PPID":{let{ppid:o}=Bn();return String(o)}case"UID":{let{uid:o}=Bn();return String(o)}case"EUID":return String(process.geteuid?.()??Bn().uid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-t.state.startTime)/1e3));case"BASH_VERSION":return $f;case"!":return String(t.state.lastBackgroundPid);case"LINENO":return String(t.state.currentLine)}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(e))throw new ut(`\${${e}}`);let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(a==="@"||a==="*"){let f=$e(t,o);if(f.length>0)return f.map(([,p])=>p).join(" ");let d=t.state.env[o];return d!==void 0?d:""}if(t.state.associativeArrays?.has(o)){let f=od(a),d=t.state.env[`${o}_${f}`];if(d===void 0&&n&&t.state.options.nounset)throw new Xe(`${o}[${a}]`);return d||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new Fe,d=ve(f,a);c=re(t,d.expression)}catch{let f=t.state.env[a];c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=$e(t,o);if(f.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${o}: bad array subscript
685
689
  `,"";let p=Math.max(...f.map(([m])=>typeof m=="number"?m:0))+1+c;return p<0?(t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${o}: bad array subscript
686
- `,""):t.state.env[`${o}_${p}`]||""}let u=t.state.env[`${o}_${c}`];if(u===void 0&&n&&t.state.options.nounset)throw new Xe(`${o}[${c}]`);return u||""}if(/^[1-9][0-9]*$/.test(e)){let o=t.state.env[e];if(o===void 0&&n&&t.state.options.nounset)throw new Xe(e);return o||""}let i=t.state.env[e];if(i===void 0&&n&&t.state.options.nounset)throw new Xe(e);return i||""}async function ad(t,e,n,r,s){let i=[];for(let u of e){let f=u.type==="ParameterExpansion"||u.type==="CommandSubstitution"||u.type==="ArithmeticExpansion";if(u.type==="ParameterExpansion"&&$i(u)){let d=await s(t,u);i.push({value:d,splittable:!1})}else{let d=await s(t,u);i.push({value:d,splittable:f})}}if(!i.some(u=>u.splittable&&new RegExp(`[${r}]`).test(u.value))){let u=i.map(f=>f.value).join("");return u?[u]:[]}let a=new RegExp(`[${r}]+`),l=[],c="";for(let u=0;u<i.length;u++){let f=i[u];if(!f.splittable)c+=f.value;else{let d=f.value.split(a);for(let p=0;p<d.length;p++)p===0?c+=d[p]:(c!==""&&l.push(c),c=d[p])}}return c!==""&&l.push(c),l}function Ve(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ld(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function cd(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}function Pi(t){if(t==="")return"''";if(!/['\\\n\r\t\x00-\x1f\x7f]/.test(t))return`'${t}'`;let e="$'";for(let n of t)switch(n){case"'":e+="\\'";break;case"\\":e+="\\\\";break;case`
687
- `:e+="\\n";break;case"\r":e+="\\r";break;case" ":e+="\\t";break;default:{let r=n.charCodeAt(0);r<32||r===127?e+=`\\x${r.toString(16).padStart(2,"0")}`:e+=n}}return`${e}'`}function Wt(t,e,n=!1){return e.map(r=>ht(t,r,n)).join("")}async function Ut(t,e,n=!1){let r=[];for(let s of e)r.push(await tt(t,s));return r.join("")}function Xx(t){return cd(t)}function ud(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!Xx(e))return!1;return!0}function fd(t){return t.replace(/([*?[\]\\])/g,"\\$1")}function dd(t,e,n=!1){let r=ld(e);if(r!==null)return r;switch(e.type){case"ParameterExpansion":return yd(t,e,n);case"TildeExpansion":return n?e.user===null?"~":`~${e.user}`:e.user===null?t.state.env.HOME||"/home/user":e.user==="root"?"/root":`~${e.user}`;case"Glob":return e.pattern;default:return null}}function ht(t,e,n=!1){let r=dd(t,e,n);if(r!==null)return r;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(ht(t,i,!0));return s.join("")}case"ArithmeticExpansion":return String(re(t,e.expression.expression));case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=_n(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(Wr(t,i.word));return s.join(" ")}default:return""}}function Wr(t,e){let n=e.parts,r=n.length;if(r===1)return ht(t,n[0]);let s=[];for(let i=0;i<r;i++)s.push(ht(t,n[i]));return s.join("")}async function pe(t,e){return pt(e)?gd(t,e):Wr(t,e)}function Ur(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&Ur(e.parts))return!0;return!1}function Jx(t){for(let e of t){if(e.type==="BraceExpansion"){for(let n of e.items)if(n.type==="Word"&&pt(n.word))return!0}if(_r(e))return!0}return!1}var pd=1e4,dn=1e5;function hd(t,e,n={count:0}){if(n.count>dn)return[[]];let r=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=_n(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let d of f.expanded)n.count++,i.push(d);else{o=!0,a=f.literal;break}}else{let f=hd(t,u.word.parts,n);for(let d of f)n.count++,i.push(d.join(""))}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>pd||n.count>dn)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>dn)return c.length>0?c:r;c.push([...u,f])}r=c}else{let i=ht(t,s);for(let o of r)n.count++,o.push(i)}return r}function Yx(t,e){let n=e.parts;return Ur(n)?hd(t,n).map(s=>s.join("")):[Wr(t,e)]}async function md(t,e,n={count:0}){if(n.count>dn)return[[]];let r=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=_n(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let d of f.expanded)n.count++,i.push(d);else{o=!0,a=f.literal;break}}else{let f=await md(t,u.word.parts,n);for(let d of f)n.count++,i.push(d.join(""))}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>pd||n.count>dn)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>dn)return c.length>0?c:r;c.push([...u,f])}r=c}else{let i=await tt(t,s);for(let o of r)n.count++,o.push(i)}return r}async function ew(t,e){let n=e.parts;return Ur(n)?(await md(t,n)).map(s=>s.join("")):[await pe(t,e)]}async function jn(t,e){let n=e.parts,{hasQuoted:r,hasCommandSub:s,hasArrayVar:i,hasArrayAtExpansion:o,hasParamExpansion:a}=td(n),c=Ur(n)?Jx(n)?await ew(t,e):Yx(t,e):null;if(c&&c.length>1){let d=[];for(let p of c)if(!r&&/[*?[]/.test(p)){let m=await new un(t.fs,t.state.cwd).expand(p);m.length>0?d.push(...m):d.push(p)}else d.push(p);return{values:d,quoted:!1}}if(o&&n.length===1&&n[0].type==="DoubleQuoted"){let d=n[0];if(d.parts.length===1&&d.parts[0].type==="ParameterExpansion"){let h=d.parts[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@]\]$/);if(h){let m=h[1],g=$e(t,m);if(g.length>0)return{values:g.map(([,b])=>b),quoted:!0};let w=t.state.env[m];return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}}}if(n.length===1&&n[0].type==="DoubleQuoted"){let d=n[0],p=-1,h=!1;for(let m=0;m<d.parts.length;m++){let g=d.parts[m];if(g.type==="ParameterExpansion"&&(g.parameter==="@"||g.parameter==="*")){p=m,h=g.parameter==="*";break}}if(p!==-1){let m=d.parts[p];m.type==="ParameterExpansion"&&m.operation&&(p=-1)}if(p!==-1){let m=Number.parseInt(t.state.env["#"]||"0",10),g="";for(let S=0;S<p;S++)g+=await tt(t,d.parts[S]);let w="";for(let S=p+1;S<d.parts.length;S++)w+=await tt(t,d.parts[S]);if(m===0){if(h)return{values:[g+w],quoted:!0};let S=g+w;return{values:S?[S]:[],quoted:!0}}let b=[];for(let S=1;S<=m;S++)b.push(t.state.env[String(S)]||"");if(h){let S=fn(t.state.env);return{values:[g+b.join(S)+w],quoted:!0}}return b.length===1?{values:[g+b[0]+w],quoted:!0}:{values:[g+b[0],...b.slice(1,-1),b[b.length-1]+w],quoted:!0}}}if((s||i||a)&&!rd(t.state.env)){let d=Br(t.state.env),p=Un(d),h=await ad(t,n,d,p,tt),m=[],g=new un(t.fs,t.state.cwd);for(let w of h)if(/[*?[]/.test(w)){let b=await g.expand(w);b.length>0?m.push(...b):m.push(w)}else m.push(w);return{values:m,quoted:!1}}let f=pt(e)?await gd(t,e):Wr(t,e);if(!r&&/[*?[]/.test(f)){let p=await new un(t.fs,t.state.cwd).expand(f);if(p.length>0)return{values:p,quoted:!1}}return f===""&&!r?{values:[],quoted:!1}:{values:[f],quoted:r}}async function gd(t,e){let n=e.parts,r=n.length;if(r===1)return tt(t,n[0]);let s=[];for(let i=0;i<r;i++)s.push(await tt(t,n[i]));return s.join("")}async function tt(t,e){if(e.type==="ParameterExpansion"&&vi(e))return tw(t,e);let n=dd(t,e);if(n!==null)return n;switch(e.type){case"DoubleQuoted":{let r=[];for(let s of e.parts)r.push(await tt(t,s));return r.join("")}case"CommandSubstitution":try{let r=await t.executeScript(e.body);return t.state.lastExitCode=r.exitCode,t.state.env["?"]=String(r.exitCode),r.stdout.replace(/\n+$/,"")}catch(r){if(r instanceof V)throw r;if(r instanceof ue)return t.state.lastExitCode=r.exitCode,t.state.env["?"]=String(r.exitCode),r.stdout.replace(/\n+$/,"");throw r}case"ArithmeticExpansion":return String(await se(t,e.expression.expression));case"BraceExpansion":{let r=[];for(let s of e.items)if(s.type==="Range"){let i=_n(s.start,s.end,s.step,s.startStr,s.endStr);if(i.expanded)r.push(...i.expanded);else return i.literal}else r.push(await pe(t,s.word));return r.join(" ")}default:return""}}function yd(t,e,n=!1){let{parameter:r,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=et(t,r,!i);if(!s)return o;let a=!(r in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?Wt(t,s.word.parts,n):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=Wt(t,s.word.parts,n),f=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,d,p]=f,h;if(/^\d+$/.test(p))h=Number.parseInt(p,10);else{try{let g=new Pe,w=ve(g,p);h=re(t,w.expression)}catch{let g=t.state.env[p];h=g?Number.parseInt(g,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${d}_${h}`]=u;let m=Number.parseInt(t.state.env[`${d}__length`]||"0",10);h>=m&&(t.state.env[`${d}__length`]=String(h+1))}else t.state.env[r]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?Wt(t,s.word.parts,n):`${r}: parameter null or not set`;throw new ue(1,"",`bash: ${u}
688
- `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?Wt(t,s.word.parts,n):"";case"Length":{let c=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c){let u=$e(t,c[1]);return String(u.length)}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&od(t,r)){let u=t.state.env[`${r}_0`]||"";return String(u.length)}return String(o.length)}case"LengthSliceError":throw new ct(r);case"Substring":{let c=s.offset?re(t,s.offset.expression):0,u=s.length?re(t,s.length.expression):void 0;if(r==="@"||r==="*"){let h=(t.state.env["@"]||"").split(" ").filter(b=>b),m=t.state.env[0]||"bash",g=c===0?[m,...h]:h,w=c===0?0:c-1;if(w<0||w>=g.length)return"";if(u!==void 0){let b=u<0?g.length+u:w+u;return g.slice(w,Math.max(w,b)).join(" ")}return g.slice(w).join(" ")}let f=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(f){let m=$e(t,f[1]).map(([,w])=>w),g=c;if(g<0&&(g=m.length+g,g<0))return"";if(u!==void 0){if(u<0){let w=m.length+u;return m.slice(g,Math.max(g,w)).join(" ")}return m.slice(g,g+u).join(" ")}return m.slice(g).join(" ")}let d=[...o],p=c;if(p<0&&(p=Math.max(0,d.length+p)),u!==void 0){if(u<0){let h=d.length+u;return d.slice(p,Math.max(p,h)).join("")}return d.slice(p,p+u).join("")}return d.slice(p).join("")}case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=qe(f.pattern,s.greedy);else if(f.type==="Literal")c+=qe(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=Ve(f.value);else if(f.type==="DoubleQuoted"){let d=Wt(t,f.parts);c+=Ve(d)}else if(f.type==="ParameterExpansion"){let d=ht(t,f);c+=qe(d,s.greedy)}else{let d=ht(t,f);c+=Ve(d)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let d=o.slice(f);if(u.test(d))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let d of s.pattern.parts)if(d.type==="Glob")c+=qe(d.pattern,!0);else if(d.type==="Literal")c+=qe(d.value,!0);else if(d.type==="SingleQuoted"||d.type==="Escaped")c+=Ve(d.value);else if(d.type==="DoubleQuoted"){let p=Wt(t,d.parts);c+=Ve(p)}else if(d.type==="ParameterExpansion"){let p=ht(t,d);c+=qe(p,!0)}else{let p=ht(t,d);c+=Ve(p)}let u=s.replacement?Wt(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let d=new RegExp(c,f);if(s.all){let p="",h=0,m=d.exec(o);for(;m!==null&&!(m[0].length===0&&m.index===o.length);)p+=o.slice(h,m.index)+u,h=m.index+m[0].length,m[0].length===0&&h++,m=d.exec(o);return p+=o.slice(h),p}return o.replace(d,u)}catch{return o}}case"CaseModification":return s.direction==="upper"?s.all?o.toUpperCase():o.charAt(0).toUpperCase()+o.slice(1):s.all?o.toLowerCase():o.charAt(0).toLowerCase()+o.slice(1);case"Transform":{let c=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c&&s.operator==="Q")return $e(t,c[1]).map(([,d])=>Pi(d)).join(" ");switch(s.operator){case"Q":return Pi(o);case"P":return o;case"a":return"";case"A":return`${r}=${Pi(o)}`;case"E":return o.replace(/\\([\\abefnrtv'"?])/g,(u,f)=>{switch(f){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
689
- `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return f}});case"K":return"";default:return o}}case"Indirection":return et(t,o);case"ArrayKeys":{let u=$e(t,s.array).map(([f])=>String(f));return s.star?u.join(fn(t.state.env)):u.join(" ")}case"VarNamePrefix":{let c=Object.keys(t.state.env).filter(u=>u.startsWith(s.prefix)&&!u.includes("__")).sort();return s.star?c.join(fn(t.state.env)):c.join(" ")}default:return o}}async function tw(t,e,n=!1){let{parameter:r,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=et(t,r,!i);if(!s)return o;let a=!(r in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?Ut(t,s.word.parts,n):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=await Ut(t,s.word.parts,n),f=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,d,p]=f,h;if(/^\d+$/.test(p))h=Number.parseInt(p,10);else{try{let g=new Pe,w=ve(g,p);h=await se(t,w.expression)}catch{let g=t.state.env[p];h=g?Number.parseInt(g,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${d}_${h}`]=u;let m=Number.parseInt(t.state.env[`${d}__length`]||"0",10);h>=m&&(t.state.env[`${d}__length`]=String(h+1))}else t.state.env[r]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?await Ut(t,s.word.parts,n):`${r}: parameter null or not set`;throw new ue(1,"",`bash: ${u}
690
- `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?Ut(t,s.word.parts,n):"";case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=qe(f.pattern,s.greedy);else if(f.type==="Literal")c+=qe(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=Ve(f.value);else if(f.type==="DoubleQuoted"){let d=await Ut(t,f.parts);c+=Ve(d)}else if(f.type==="ParameterExpansion"){let d=await tt(t,f);c+=qe(d,s.greedy)}else{let d=await tt(t,f);c+=Ve(d)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let d=o.slice(f);if(u.test(d))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let d of s.pattern.parts)if(d.type==="Glob")c+=qe(d.pattern,!0);else if(d.type==="Literal")c+=qe(d.value,!0);else if(d.type==="SingleQuoted"||d.type==="Escaped")c+=Ve(d.value);else if(d.type==="DoubleQuoted"){let p=await Ut(t,d.parts);c+=Ve(p)}else if(d.type==="ParameterExpansion"){let p=await tt(t,d);c+=qe(p,!0)}else{let p=await tt(t,d);c+=Ve(p)}let u=s.replacement?await Ut(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let d=new RegExp(c,f);if(s.all){let p="",h=0,m=d.exec(o);for(;m!==null&&!(m[0].length===0&&m.index===o.length);)p+=o.slice(h,m.index)+u,h=m.index+m[0].length,m[0].length===0&&h++,m=d.exec(o);return p+=o.slice(h),p}return o.replace(d,u)}catch{return o}}default:return yd(t,e,n)}}function Fi(t,e,n){switch(n){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?Math.trunc(t/e):0;case"%":return e!==0?t%e:0;case"**":if(e<0)throw new ke("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function xd(t,e,n){switch(n){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function Ti(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}function nw(t,e){let n=t.state.env[e];if(n!==void 0)return n;let r=t.state.env[`${e}_0`];return r!==void 0?r:et(t,e)}function pn(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let n=t.trim();if(!n)return 0;try{let r=new Pe,{expr:s,pos:i}=ft(r,n,0);if(i<n.length){let o=n.slice(i).trim().split(/\s+/)[0];throw new ke(`${n}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(r){if(r instanceof ke)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new ke(`${n}: syntax error in expression (error token is "${s}")`)}}function jr(t,e,n=new Set){if(n.has(e))return 0;n.add(e);let r=nw(t,e);if(!r)return 0;let s=Number.parseInt(r,10);if(!Number.isNaN(s)&&/^-?\d+$/.test(r.trim()))return s;let i=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return jr(t,i,n);try{let o=new Pe,{expr:a}=ft(o,i,0);return nt(t,a,n)}catch{return 0}}function nt(t,e,n){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new ke("value too great for base");return e.value;case"ArithVariable":return jr(t,e.name,n);case"ArithBinary":{if(e.operator==="||")return nt(t,e.left,n)||nt(t,e.right,n)?1:0;if(e.operator==="&&")return nt(t,e.left,n)&&nt(t,e.right,n)?1:0;let r=nt(t,e.left,n),s=nt(t,e.right,n);return Fi(r,s,e.operator)}case"ArithUnary":{let r=nt(t,e.operand,n);return Ti(r,e.operator)}case"ArithTernary":return nt(t,e.condition,n)?nt(t,e.consequent,n):nt(t,e.alternate,n);case"ArithGroup":return nt(t,e.expression,n);default:return re(t,e)}}function bt(t,e){if(e.startsWith("#")){let f=e.slice(1),d=t.state.env[f]||"";return String(d.length)}if(e.startsWith("!")){let f=e.slice(1),d=t.state.env[f]||"";return t.state.env[d]||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let d=e.indexOf(f);d>0&&(r===-1||d<r)&&(r=d,s=f)}if(r===-1)return et(t,e);let i=e.slice(0,r),o=e.slice(r+s.length),a=t.state.env[i],l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env[i]=o,o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}function re(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new ke("value too great for base");return e.value;case"ArithVariable":return jr(t,e.name);case"ArithNested":return re(t,e.expression);case"ArithCommandSubst":return 0;case"ArithBracedExpansion":{let n=bt(t,e.content);return Number.parseInt(n,10)||0}case"ArithDynamicBase":{let n=bt(t,e.baseExpr),r=Number.parseInt(n,10);if(r<2||r>64)return 0;let s=`${r}#${e.value}`;return cn(s)}case"ArithDynamicNumber":{let r=bt(t,e.prefix)+e.suffix;return cn(r)}case"ArithArrayElement":{let n=t.state.associativeArrays?.has(e.array),r;if(e.stringKey!==void 0)r=`${e.array}_${e.stringKey}`;else if(n&&e.index?.type==="ArithVariable")r=`${e.array}_${e.index.name}`;else if(e.index){let i=re(t,e.index);if(i<0){let a=$e(t,e.array);if(a.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${e.array}: bad array subscript
690
+ `,""):t.state.env[`${o}_${p}`]||""}let u=t.state.env[`${o}_${c}`];if(u===void 0&&n&&t.state.options.nounset)throw new Xe(`${o}[${c}]`);return u||""}if(/^[1-9][0-9]*$/.test(e)){let o=t.state.env[e];if(o===void 0&&n&&t.state.options.nounset)throw new Xe(e);return o||""}let i=t.state.env[e];if(i===void 0&&n&&t.state.options.nounset)throw new Xe(e);return i||""}async function fd(t,e,n,r,s){let i=[];for(let u of e){let f=u.type==="ParameterExpansion"||u.type==="CommandSubstitution"||u.type==="ArithmeticExpansion";if(u.type==="ParameterExpansion"&&Fi(u)){let d=await s(t,u);i.push({value:d,splittable:!1})}else{let d=await s(t,u);i.push({value:d,splittable:f})}}if(!i.some(u=>u.splittable&&new RegExp(`[${r}]`).test(u.value))){let u=i.map(f=>f.value).join("");return u?[u]:[]}let a=new RegExp(`[${r}]+`),l=[],c="";for(let u=0;u<i.length;u++){let f=i[u];if(!f.splittable)c+=f.value;else{let d=f.value.split(a);for(let p=0;p<d.length;p++)p===0?c+=d[p]:(c!==""&&l.push(c),c=d[p])}}return c!==""&&l.push(c),l}function Ve(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dd(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function pd(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}function Ti(t){if(t==="")return"''";if(!/['\\\n\r\t\x00-\x1f\x7f]/.test(t))return`'${t}'`;let e="$'";for(let n of t)switch(n){case"'":e+="\\'";break;case"\\":e+="\\\\";break;case`
691
+ `:e+="\\n";break;case"\r":e+="\\r";break;case" ":e+="\\t";break;default:{let r=n.charCodeAt(0);r<32||r===127?e+=`\\x${r.toString(16).padStart(2,"0")}`:e+=n}}return`${e}'`}function Ut(t,e,n=!1){return e.map(r=>mt(t,r,n)).join("")}async function jt(t,e,n=!1){let r=[];for(let s of e)r.push(await tt(t,s));return r.join("")}function iw(t){return pd(t)}function hd(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!iw(e))return!1;return!0}function md(t){return t.replace(/([*?[\]\\])/g,"\\$1")}function gd(t,e,n=!1){let r=dd(e);if(r!==null)return r;switch(e.type){case"ParameterExpansion":return Ed(t,e,n);case"TildeExpansion":return n?e.user===null?"~":`~${e.user}`:e.user===null?t.state.env.HOME||"/home/user":e.user==="root"?"/root":`~${e.user}`;case"Glob":return e.pattern;default:return null}}function mt(t,e,n=!1){let r=gd(t,e,n);if(r!==null)return r;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(mt(t,i,!0));return s.join("")}case"ArithmeticExpansion":return String(re(t,e.expression.expression));case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=Wn(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(Ur(t,i.word));return s.join(" ")}default:return""}}function Ur(t,e){let n=e.parts,r=n.length;if(r===1)return mt(t,n[0]);let s=[];for(let i=0;i<r;i++)s.push(mt(t,n[i]));return s.join("")}async function he(t,e){return ht(e)?bd(t,e):Ur(t,e)}function jr(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&jr(e.parts))return!0;return!1}function ow(t){for(let e of t){if(e.type==="BraceExpansion"){for(let n of e.items)if(n.type==="Word"&&ht(n.word))return!0}if(Br(e))return!0}return!1}var yd=1e4,pn=1e5;function xd(t,e,n={count:0}){if(n.count>pn)return[[]];let r=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=Wn(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let d of f.expanded)n.count++,i.push(d);else{o=!0,a=f.literal;break}}else{let f=xd(t,u.word.parts,n);for(let d of f)n.count++,i.push(d.join(""))}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>yd||n.count>pn)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>pn)return c.length>0?c:r;c.push([...u,f])}r=c}else{let i=mt(t,s);for(let o of r)n.count++,o.push(i)}return r}function aw(t,e){let n=e.parts;return jr(n)?xd(t,n).map(s=>s.join("")):[Ur(t,e)]}async function wd(t,e,n={count:0}){if(n.count>pn)return[[]];let r=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=Wn(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let d of f.expanded)n.count++,i.push(d);else{o=!0,a=f.literal;break}}else{let f=await wd(t,u.word.parts,n);for(let d of f)n.count++,i.push(d.join(""))}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>yd||n.count>pn)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>pn)return c.length>0?c:r;c.push([...u,f])}r=c}else{let i=await tt(t,s);for(let o of r)n.count++,o.push(i)}return r}async function lw(t,e){let n=e.parts;return jr(n)?(await wd(t,n)).map(s=>s.join("")):[await he(t,e)]}async function Hn(t,e){let n=e.parts,{hasQuoted:r,hasCommandSub:s,hasArrayVar:i,hasArrayAtExpansion:o,hasParamExpansion:a}=id(n),c=jr(n)?ow(n)?await lw(t,e):aw(t,e):null;if(c&&c.length>1){let d=[];for(let p of c)if(!r&&/[*?[]/.test(p)){let m=await new fn(t.fs,t.state.cwd).expand(p);m.length>0?d.push(...m):d.push(p)}else d.push(p);return{values:d,quoted:!1}}if(o&&n.length===1&&n[0].type==="DoubleQuoted"){let d=n[0];if(d.parts.length===1&&d.parts[0].type==="ParameterExpansion"){let h=d.parts[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@]\]$/);if(h){let m=h[1],g=$e(t,m);if(g.length>0)return{values:g.map(([,w])=>w),quoted:!0};let b=t.state.env[m];return b!==void 0?{values:[b],quoted:!0}:{values:[],quoted:!0}}}}if(n.length===1&&n[0].type==="DoubleQuoted"){let d=n[0],p=-1,h=!1;for(let m=0;m<d.parts.length;m++){let g=d.parts[m];if(g.type==="ParameterExpansion"&&(g.parameter==="@"||g.parameter==="*")){p=m,h=g.parameter==="*";break}}if(p!==-1){let m=d.parts[p];m.type==="ParameterExpansion"&&m.operation&&(p=-1)}if(p!==-1){let m=Number.parseInt(t.state.env["#"]||"0",10),g="";for(let S=0;S<p;S++)g+=await tt(t,d.parts[S]);let b="";for(let S=p+1;S<d.parts.length;S++)b+=await tt(t,d.parts[S]);if(m===0){if(h)return{values:[g+b],quoted:!0};let S=g+b;return{values:S?[S]:[],quoted:!0}}let w=[];for(let S=1;S<=m;S++)w.push(t.state.env[String(S)]||"");if(h){let S=dn(t.state.env);return{values:[g+w.join(S)+b],quoted:!0}}return w.length===1?{values:[g+w[0]+b],quoted:!0}:{values:[g+w[0],...w.slice(1,-1),w[w.length-1]+b],quoted:!0}}}if((s||i||a)&&!ad(t.state.env)){let d=Wr(t.state.env),p=zn(d),h=await fd(t,n,d,p,tt),m=[],g=new fn(t.fs,t.state.cwd);for(let b of h)if(/[*?[]/.test(b)){let w=await g.expand(b);w.length>0?m.push(...w):m.push(b)}else m.push(b);return{values:m,quoted:!1}}let f=ht(e)?await bd(t,e):Ur(t,e);if(!r&&/[*?[]/.test(f)){let p=await new fn(t.fs,t.state.cwd).expand(f);if(p.length>0)return{values:p,quoted:!1}}return f===""&&!r?{values:[],quoted:!1}:{values:[f],quoted:r}}async function bd(t,e){let n=e.parts,r=n.length;if(r===1)return tt(t,n[0]);let s=[];for(let i=0;i<r;i++)s.push(await tt(t,n[i]));return s.join("")}async function tt(t,e){if(e.type==="ParameterExpansion"&&Ri(e))return cw(t,e);let n=gd(t,e);if(n!==null)return n;switch(e.type){case"DoubleQuoted":{let r=[];for(let s of e.parts)r.push(await tt(t,s));return r.join("")}case"CommandSubstitution":try{let r=await t.executeScript(e.body);return t.state.lastExitCode=r.exitCode,t.state.env["?"]=String(r.exitCode),r.stdout.replace(/\n+$/,"")}catch(r){if(r instanceof Z)throw r;if(r instanceof fe)return t.state.lastExitCode=r.exitCode,t.state.env["?"]=String(r.exitCode),r.stdout.replace(/\n+$/,"");throw r}case"ArithmeticExpansion":return String(await se(t,e.expression.expression));case"BraceExpansion":{let r=[];for(let s of e.items)if(s.type==="Range"){let i=Wn(s.start,s.end,s.step,s.startStr,s.endStr);if(i.expanded)r.push(...i.expanded);else return i.literal}else r.push(await he(t,s.word));return r.join(" ")}default:return""}}function Ed(t,e,n=!1){let{parameter:r,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=et(t,r,!i);if(!s)return o;let a=!(r in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?Ut(t,s.word.parts,n):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=Ut(t,s.word.parts,n),f=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,d,p]=f,h;if(/^\d+$/.test(p))h=Number.parseInt(p,10);else{try{let g=new Fe,b=ve(g,p);h=re(t,b.expression)}catch{let g=t.state.env[p];h=g?Number.parseInt(g,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${d}_${h}`]=u;let m=Number.parseInt(t.state.env[`${d}__length`]||"0",10);h>=m&&(t.state.env[`${d}__length`]=String(h+1))}else t.state.env[r]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?Ut(t,s.word.parts,n):`${r}: parameter null or not set`;throw new fe(1,"",`bash: ${u}
692
+ `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?Ut(t,s.word.parts,n):"";case"Length":{let c=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c){let u=$e(t,c[1]);return String(u.length)}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&ud(t,r)){let u=t.state.env[`${r}_0`]||"";return String(u.length)}return String(o.length)}case"LengthSliceError":throw new ut(r);case"Substring":{let c=s.offset?re(t,s.offset.expression):0,u=s.length?re(t,s.length.expression):void 0;if(r==="@"||r==="*"){let h=(t.state.env["@"]||"").split(" ").filter(w=>w),m=t.state.env[0]||"bash",g=c===0?[m,...h]:h,b=c===0?0:c-1;if(b<0||b>=g.length)return"";if(u!==void 0){let w=u<0?g.length+u:b+u;return g.slice(b,Math.max(b,w)).join(" ")}return g.slice(b).join(" ")}let f=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(f){let m=$e(t,f[1]).map(([,b])=>b),g=c;if(g<0&&(g=m.length+g,g<0))return"";if(u!==void 0){if(u<0){let b=m.length+u;return m.slice(g,Math.max(g,b)).join(" ")}return m.slice(g,g+u).join(" ")}return m.slice(g).join(" ")}let d=[...o],p=c;if(p<0&&(p=Math.max(0,d.length+p)),u!==void 0){if(u<0){let h=d.length+u;return d.slice(p,Math.max(p,h)).join("")}return d.slice(p,p+u).join("")}return d.slice(p).join("")}case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=qe(f.pattern,s.greedy);else if(f.type==="Literal")c+=qe(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=Ve(f.value);else if(f.type==="DoubleQuoted"){let d=Ut(t,f.parts);c+=Ve(d)}else if(f.type==="ParameterExpansion"){let d=mt(t,f);c+=qe(d,s.greedy)}else{let d=mt(t,f);c+=Ve(d)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let d=o.slice(f);if(u.test(d))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let d of s.pattern.parts)if(d.type==="Glob")c+=qe(d.pattern,!0);else if(d.type==="Literal")c+=qe(d.value,!0);else if(d.type==="SingleQuoted"||d.type==="Escaped")c+=Ve(d.value);else if(d.type==="DoubleQuoted"){let p=Ut(t,d.parts);c+=Ve(p)}else if(d.type==="ParameterExpansion"){let p=mt(t,d);c+=qe(p,!0)}else{let p=mt(t,d);c+=Ve(p)}let u=s.replacement?Ut(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let d=new RegExp(c,f);if(s.all){let p="",h=0,m=d.exec(o);for(;m!==null&&!(m[0].length===0&&m.index===o.length);)p+=o.slice(h,m.index)+u,h=m.index+m[0].length,m[0].length===0&&h++,m=d.exec(o);return p+=o.slice(h),p}return o.replace(d,u)}catch{return o}}case"CaseModification":return s.direction==="upper"?s.all?o.toUpperCase():o.charAt(0).toUpperCase()+o.slice(1):s.all?o.toLowerCase():o.charAt(0).toLowerCase()+o.slice(1);case"Transform":{let c=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c&&s.operator==="Q")return $e(t,c[1]).map(([,d])=>Ti(d)).join(" ");switch(s.operator){case"Q":return Ti(o);case"P":return o;case"a":return"";case"A":return`${r}=${Ti(o)}`;case"E":return o.replace(/\\([\\abefnrtv'"?])/g,(u,f)=>{switch(f){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
693
+ `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return f}});case"K":return"";default:return o}}case"Indirection":return et(t,o);case"ArrayKeys":{let u=$e(t,s.array).map(([f])=>String(f));return s.star?u.join(dn(t.state.env)):u.join(" ")}case"VarNamePrefix":{let c=Object.keys(t.state.env).filter(u=>u.startsWith(s.prefix)&&!u.includes("__")).sort();return s.star?c.join(dn(t.state.env)):c.join(" ")}default:return o}}async function cw(t,e,n=!1){let{parameter:r,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=et(t,r,!i);if(!s)return o;let a=!(r in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?jt(t,s.word.parts,n):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=await jt(t,s.word.parts,n),f=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,d,p]=f,h;if(/^\d+$/.test(p))h=Number.parseInt(p,10);else{try{let g=new Fe,b=ve(g,p);h=await se(t,b.expression)}catch{let g=t.state.env[p];h=g?Number.parseInt(g,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${d}_${h}`]=u;let m=Number.parseInt(t.state.env[`${d}__length`]||"0",10);h>=m&&(t.state.env[`${d}__length`]=String(h+1))}else t.state.env[r]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?await jt(t,s.word.parts,n):`${r}: parameter null or not set`;throw new fe(1,"",`bash: ${u}
694
+ `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?jt(t,s.word.parts,n):"";case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=qe(f.pattern,s.greedy);else if(f.type==="Literal")c+=qe(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=Ve(f.value);else if(f.type==="DoubleQuoted"){let d=await jt(t,f.parts);c+=Ve(d)}else if(f.type==="ParameterExpansion"){let d=await tt(t,f);c+=qe(d,s.greedy)}else{let d=await tt(t,f);c+=Ve(d)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let d=o.slice(f);if(u.test(d))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let d of s.pattern.parts)if(d.type==="Glob")c+=qe(d.pattern,!0);else if(d.type==="Literal")c+=qe(d.value,!0);else if(d.type==="SingleQuoted"||d.type==="Escaped")c+=Ve(d.value);else if(d.type==="DoubleQuoted"){let p=await jt(t,d.parts);c+=Ve(p)}else if(d.type==="ParameterExpansion"){let p=await tt(t,d);c+=qe(p,!0)}else{let p=await tt(t,d);c+=Ve(p)}let u=s.replacement?await jt(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let d=new RegExp(c,f);if(s.all){let p="",h=0,m=d.exec(o);for(;m!==null&&!(m[0].length===0&&m.index===o.length);)p+=o.slice(h,m.index)+u,h=m.index+m[0].length,m[0].length===0&&h++,m=d.exec(o);return p+=o.slice(h),p}return o.replace(d,u)}catch{return o}}default:return Ed(t,e,n)}}function Oi(t,e,n){switch(n){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?Math.trunc(t/e):0;case"%":return e!==0?t%e:0;case"**":if(e<0)throw new ke("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function Sd(t,e,n){switch(n){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function Di(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}function uw(t,e){let n=t.state.env[e];if(n!==void 0)return n;let r=t.state.env[`${e}_0`];return r!==void 0?r:et(t,e)}function hn(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let n=t.trim();if(!n)return 0;try{let r=new Fe,{expr:s,pos:i}=dt(r,n,0);if(i<n.length){let o=n.slice(i).trim().split(/\s+/)[0];throw new ke(`${n}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(r){if(r instanceof ke)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new ke(`${n}: syntax error in expression (error token is "${s}")`)}}function zr(t,e,n=new Set){if(n.has(e))return 0;n.add(e);let r=uw(t,e);if(!r)return 0;let s=Number.parseInt(r,10);if(!Number.isNaN(s)&&/^-?\d+$/.test(r.trim()))return s;let i=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return zr(t,i,n);try{let o=new Fe,{expr:a}=dt(o,i,0);return nt(t,a,n)}catch{return 0}}function nt(t,e,n){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new ke("value too great for base");return e.value;case"ArithVariable":return zr(t,e.name,n);case"ArithBinary":{if(e.operator==="||")return nt(t,e.left,n)||nt(t,e.right,n)?1:0;if(e.operator==="&&")return nt(t,e.left,n)&&nt(t,e.right,n)?1:0;let r=nt(t,e.left,n),s=nt(t,e.right,n);return Oi(r,s,e.operator)}case"ArithUnary":{let r=nt(t,e.operand,n);return Di(r,e.operator)}case"ArithTernary":return nt(t,e.condition,n)?nt(t,e.consequent,n):nt(t,e.alternate,n);case"ArithGroup":return nt(t,e.expression,n);default:return re(t,e)}}function Et(t,e){if(e.startsWith("#")){let f=e.slice(1),d=t.state.env[f]||"";return String(d.length)}if(e.startsWith("!")){let f=e.slice(1),d=t.state.env[f]||"";return t.state.env[d]||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let d=e.indexOf(f);d>0&&(r===-1||d<r)&&(r=d,s=f)}if(r===-1)return et(t,e);let i=e.slice(0,r),o=e.slice(r+s.length),a=t.state.env[i],l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env[i]=o,o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}function re(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new ke("value too great for base");return e.value;case"ArithVariable":return zr(t,e.name);case"ArithNested":return re(t,e.expression);case"ArithCommandSubst":return 0;case"ArithBracedExpansion":{let n=Et(t,e.content);return Number.parseInt(n,10)||0}case"ArithDynamicBase":{let n=Et(t,e.baseExpr),r=Number.parseInt(n,10);if(r<2||r>64)return 0;let s=`${r}#${e.value}`;return un(s)}case"ArithDynamicNumber":{let r=Et(t,e.prefix)+e.suffix;return un(r)}case"ArithArrayElement":{let n=t.state.associativeArrays?.has(e.array),r;if(e.stringKey!==void 0)r=`${e.array}_${e.stringKey}`;else if(n&&e.index?.type==="ArithVariable")r=`${e.array}_${e.index.name}`;else if(e.index){let i=re(t,e.index);if(i<0){let a=$e(t,e.array);if(a.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${e.array}: bad array subscript
691
695
  `,0;let c=Math.max(...a.map(([u])=>typeof u=="number"?u:0))+1+i;if(c<0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${e.array}: bad array subscript
692
- `,0;i=c}r=`${e.array}_${i}`;let o=t.state.env[r];if(o!==void 0)return pn(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return pn(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Xe(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[r];return s!==void 0?pn(s):0}case"ArithDoubleSubscript":throw new ke("double subscript","","");case"ArithNumberSubscript":throw new ke(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return re(t,e.left)||re(t,e.right)?1:0;if(e.operator==="&&")return re(t,e.left)&&re(t,e.right)?1:0;let n=re(t,e.left),r=re(t,e.right);return Fi(n,r,e.operator)}case"ArithUnary":{let n=re(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let r=e.operand.name,s=Number.parseInt(et(t,r),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[r]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let r=e.operand.array,s=t.state.associativeArrays?.has(r),i;if(e.operand.stringKey!==void 0)i=`${r}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${r}_${e.operand.index.name}`;else if(e.operand.index){let l=re(t,e.operand.index);i=`${r}_${l}`}else return n;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return n}return Ti(n,e.operator)}case"ArithTernary":return re(t,e.condition)?re(t,e.consequent):re(t,e.alternate);case"ArithAssignment":{let n=e.variable,r=n;if(e.stringKey!==void 0)r=`${n}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(n);if(a&&e.subscript.type==="ArithVariable")r=`${n}_${e.subscript.name}`;else if(a){let l=re(t,e.subscript);r=`${n}_${l}`}else{let l=re(t,e.subscript);if(l<0){let c=$e(t,n);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}r=`${n}_${l}`}}let s=Number.parseInt(t.state.env[r]||"0",10)||0,i=re(t,e.value),o=xd(s,i,e.operator);return t.state.env[r]=String(o),o}case"ArithGroup":return re(t,e.expression);case"ArithConcat":{let n="";for(let r of e.parts)n+=wd(t,r);return Number.parseInt(n,10)||0}default:return 0}}function wd(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return et(t,e.name);case"ArithBracedExpansion":return bt(t,e.content);case"ArithCommandSubst":return"0";case"ArithConcat":{let n="";for(let r of e.parts)n+=wd(t,r);return n}default:return String(re(t,e))}}async function se(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new ke("value too great for base");return e.value;case"ArithVariable":return jr(t,e.name);case"ArithNested":return se(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let r=(await t.execFn(e.command)).stdout.trim();return Number.parseInt(r,10)||0}return 0}case"ArithBracedExpansion":{let n=bt(t,e.content);return Number.parseInt(n,10)||0}case"ArithDynamicBase":{let n=bt(t,e.baseExpr),r=Number.parseInt(n,10);if(r<2||r>64)return 0;let s=`${r}#${e.value}`;return cn(s)}case"ArithDynamicNumber":{let r=bt(t,e.prefix)+e.suffix;return cn(r)}case"ArithArrayElement":{let n=t.state.associativeArrays?.has(e.array),r;if(e.stringKey!==void 0)r=`${e.array}_${e.stringKey}`;else if(n&&e.index?.type==="ArithVariable")r=`${e.array}_${e.index.name}`;else if(e.index){let i=await se(t,e.index);r=`${e.array}_${i}`;let o=t.state.env[r];if(o!==void 0)return pn(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return pn(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Xe(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[r];return s!==void 0?pn(s):0}case"ArithDoubleSubscript":throw new ke("double subscript","","");case"ArithNumberSubscript":throw new ke(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return await se(t,e.left)||await se(t,e.right)?1:0;if(e.operator==="&&")return await se(t,e.left)&&await se(t,e.right)?1:0;let n=await se(t,e.left),r=await se(t,e.right);return Fi(n,r,e.operator)}case"ArithUnary":{let n=await se(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let r=e.operand.name,s=Number.parseInt(et(t,r),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[r]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let r=e.operand.array,s=t.state.associativeArrays?.has(r),i;if(e.operand.stringKey!==void 0)i=`${r}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${r}_${e.operand.index.name}`;else if(e.operand.index){let l=await se(t,e.operand.index);i=`${r}_${l}`}else return n;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return n}return Ti(n,e.operator)}case"ArithTernary":return await se(t,e.condition)?await se(t,e.consequent):await se(t,e.alternate);case"ArithAssignment":{let n=e.variable,r=n;if(e.stringKey!==void 0)r=`${n}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(n);if(a&&e.subscript.type==="ArithVariable")r=`${n}_${e.subscript.name}`;else if(a){let l=await se(t,e.subscript);r=`${n}_${l}`}else{let l=await se(t,e.subscript);if(l<0){let c=$e(t,n);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}r=`${n}_${l}`}}let s=Number.parseInt(t.state.env[r]||"0",10)||0,i=await se(t,e.value),o=xd(s,i,e.operator);return t.state.env[r]=String(o),o}case"ArithGroup":return await se(t,e.expression);case"ArithConcat":{let n="";for(let r of e.parts)n+=await bd(t,r);return Number.parseInt(n,10)||0}default:return 0}}async function bd(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return et(t,e.name);case"ArithBracedExpansion":return bt(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command)).stdout.trim():"0";case"ArithConcat":{let n="";for(let r of e.parts)n+=await bd(t,r);return n}default:return String(await se(t,e))}}fe();fe();var te=Object.freeze({stdout:"",stderr:"",exitCode:0});function Ze(t=""){return{stdout:t,stderr:"",exitCode:0}}function q(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function H(t,e,n){return{stdout:t,stderr:e,exitCode:n}}function Ne(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function mt(t,e,n="",r=""){throw new V(t,e,n,r)}function Oi(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new ot;return te}let n=1;if(e.length>0){let r=Number.parseInt(e[0],10);if(Number.isNaN(r)||r<1)throw new ue(128,"",`bash: break: ${e[0]}: numeric argument required
693
- `);n=r}throw new Fe(n)}async function Di(t,e){let n,r=!1,s=!1,i=0;for(;i<e.length;)if(e[i]==="--"){i++;break}else if(e[i]==="-L")s=!1,i++;else if(e[i]==="-P")s=!0,i++;else if(e[i].startsWith("-")&&e[i]!=="-")i++;else break;let o=e.slice(i);if(o.length===0||o[0]==="~"?n=t.state.env.HOME||"/":o[0]==="-"?(n=t.state.previousDir,r=!0):n=o[0],!n.startsWith("/")&&!n.startsWith("./")&&!n.startsWith("../")&&n!=="."&&n!==".."){let f=t.state.env.CDPATH;if(f){let d=f.split(":").filter(p=>p);for(let p of d){let h=p.startsWith("/")?`${p}/${n}`:`${t.state.cwd}/${p}/${n}`;try{if((await t.fs.stat(h)).isDirectory){n=h,r=!0;break}}catch{}}}}let l=(n.startsWith("/")?n:`${t.state.cwd}/${n}`).split("/").filter(f=>f&&f!=="."),c="";for(let f of l)if(f==="..")c=c.split("/").slice(0,-1).join("/")||"/";else{c=c?`${c}/${f}`:`/${f}`;try{if(!(await t.fs.stat(c)).isDirectory)return q(`bash: cd: ${n}: Not a directory
694
- `)}catch{return q(`bash: cd: ${n}: No such file or directory
696
+ `,0;i=c}r=`${e.array}_${i}`;let o=t.state.env[r];if(o!==void 0)return hn(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return hn(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Xe(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[r];return s!==void 0?hn(s):0}case"ArithDoubleSubscript":throw new ke("double subscript","","");case"ArithNumberSubscript":throw new ke(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return re(t,e.left)||re(t,e.right)?1:0;if(e.operator==="&&")return re(t,e.left)&&re(t,e.right)?1:0;let n=re(t,e.left),r=re(t,e.right);return Oi(n,r,e.operator)}case"ArithUnary":{let n=re(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let r=e.operand.name,s=Number.parseInt(et(t,r),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[r]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let r=e.operand.array,s=t.state.associativeArrays?.has(r),i;if(e.operand.stringKey!==void 0)i=`${r}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${r}_${e.operand.index.name}`;else if(e.operand.index){let l=re(t,e.operand.index);i=`${r}_${l}`}else return n;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return n}return Di(n,e.operator)}case"ArithTernary":return re(t,e.condition)?re(t,e.consequent):re(t,e.alternate);case"ArithAssignment":{let n=e.variable,r=n;if(e.stringKey!==void 0)r=`${n}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(n);if(a&&e.subscript.type==="ArithVariable")r=`${n}_${e.subscript.name}`;else if(a){let l=re(t,e.subscript);r=`${n}_${l}`}else{let l=re(t,e.subscript);if(l<0){let c=$e(t,n);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}r=`${n}_${l}`}}let s=Number.parseInt(t.state.env[r]||"0",10)||0,i=re(t,e.value),o=Sd(s,i,e.operator);return t.state.env[r]=String(o),o}case"ArithGroup":return re(t,e.expression);case"ArithConcat":{let n="";for(let r of e.parts)n+=Cd(t,r);return Number.parseInt(n,10)||0}default:return 0}}function Cd(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return et(t,e.name);case"ArithBracedExpansion":return Et(t,e.content);case"ArithCommandSubst":return"0";case"ArithConcat":{let n="";for(let r of e.parts)n+=Cd(t,r);return n}default:return String(re(t,e))}}async function se(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new ke("value too great for base");return e.value;case"ArithVariable":return zr(t,e.name);case"ArithNested":return se(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let r=(await t.execFn(e.command)).stdout.trim();return Number.parseInt(r,10)||0}return 0}case"ArithBracedExpansion":{let n=Et(t,e.content);return Number.parseInt(n,10)||0}case"ArithDynamicBase":{let n=Et(t,e.baseExpr),r=Number.parseInt(n,10);if(r<2||r>64)return 0;let s=`${r}#${e.value}`;return un(s)}case"ArithDynamicNumber":{let r=Et(t,e.prefix)+e.suffix;return un(r)}case"ArithArrayElement":{let n=t.state.associativeArrays?.has(e.array),r;if(e.stringKey!==void 0)r=`${e.array}_${e.stringKey}`;else if(n&&e.index?.type==="ArithVariable")r=`${e.array}_${e.index.name}`;else if(e.index){let i=await se(t,e.index);r=`${e.array}_${i}`;let o=t.state.env[r];if(o!==void 0)return hn(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return hn(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Xe(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[r];return s!==void 0?hn(s):0}case"ArithDoubleSubscript":throw new ke("double subscript","","");case"ArithNumberSubscript":throw new ke(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return await se(t,e.left)||await se(t,e.right)?1:0;if(e.operator==="&&")return await se(t,e.left)&&await se(t,e.right)?1:0;let n=await se(t,e.left),r=await se(t,e.right);return Oi(n,r,e.operator)}case"ArithUnary":{let n=await se(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let r=e.operand.name,s=Number.parseInt(et(t,r),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[r]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let r=e.operand.array,s=t.state.associativeArrays?.has(r),i;if(e.operand.stringKey!==void 0)i=`${r}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${r}_${e.operand.index.name}`;else if(e.operand.index){let l=await se(t,e.operand.index);i=`${r}_${l}`}else return n;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return n}return Di(n,e.operator)}case"ArithTernary":return await se(t,e.condition)?await se(t,e.consequent):await se(t,e.alternate);case"ArithAssignment":{let n=e.variable,r=n;if(e.stringKey!==void 0)r=`${n}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(n);if(a&&e.subscript.type==="ArithVariable")r=`${n}_${e.subscript.name}`;else if(a){let l=await se(t,e.subscript);r=`${n}_${l}`}else{let l=await se(t,e.subscript);if(l<0){let c=$e(t,n);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}r=`${n}_${l}`}}let s=Number.parseInt(t.state.env[r]||"0",10)||0,i=await se(t,e.value),o=Sd(s,i,e.operator);return t.state.env[r]=String(o),o}case"ArithGroup":return await se(t,e.expression);case"ArithConcat":{let n="";for(let r of e.parts)n+=await Ad(t,r);return Number.parseInt(n,10)||0}default:return 0}}async function Ad(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return et(t,e.name);case"ArithBracedExpansion":return Et(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command)).stdout.trim():"0";case"ArithConcat":{let n="";for(let r of e.parts)n+=await Ad(t,r);return n}default:return String(await se(t,e))}}de();de();var te=Object.freeze({stdout:"",stderr:"",exitCode:0});function Ze(t=""){return{stdout:t,stderr:"",exitCode:0}}function V(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function H(t,e,n){return{stdout:t,stderr:e,exitCode:n}}function Ne(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function gt(t,e,n="",r=""){throw new Z(t,e,n,r)}function Li(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new at;return te}let n=1;if(e.length>0){let r=Number.parseInt(e[0],10);if(Number.isNaN(r)||r<1)throw new fe(128,"",`bash: break: ${e[0]}: numeric argument required
697
+ `);n=r}throw new Pe(n)}async function Mi(t,e){let n,r=!1,s=!1,i=0;for(;i<e.length;)if(e[i]==="--"){i++;break}else if(e[i]==="-L")s=!1,i++;else if(e[i]==="-P")s=!0,i++;else if(e[i].startsWith("-")&&e[i]!=="-")i++;else break;let o=e.slice(i);if(o.length===0||o[0]==="~"?n=t.state.env.HOME||"/":o[0]==="-"?(n=t.state.previousDir,r=!0):n=o[0],!n.startsWith("/")&&!n.startsWith("./")&&!n.startsWith("../")&&n!=="."&&n!==".."){let f=t.state.env.CDPATH;if(f){let d=f.split(":").filter(p=>p);for(let p of d){let h=p.startsWith("/")?`${p}/${n}`:`${t.state.cwd}/${p}/${n}`;try{if((await t.fs.stat(h)).isDirectory){n=h,r=!0;break}}catch{}}}}let l=(n.startsWith("/")?n:`${t.state.cwd}/${n}`).split("/").filter(f=>f&&f!=="."),c="";for(let f of l)if(f==="..")c=c.split("/").slice(0,-1).join("/")||"/";else{c=c?`${c}/${f}`:`/${f}`;try{if(!(await t.fs.stat(c)).isDirectory)return V(`bash: cd: ${n}: Not a directory
698
+ `)}catch{return V(`bash: cd: ${n}: No such file or directory
695
699
  `)}}let u=c||"/";return t.state.previousDir=t.state.cwd,t.state.cwd=u,t.state.env.PWD=t.state.cwd,t.state.env.OLDPWD=t.state.previousDir,Ze(r?`${u}
696
- `:"")}fe();function Li(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new ot;return te}if(e.length>1)throw new Fe(1);let n=1;if(e.length>0){let r=Number.parseInt(e[0],10);if(Number.isNaN(r)||r<1)return q(`bash: continue: ${e[0]}: numeric argument required
697
- `);n=r}throw new Be(n)}function jt(t,e){t.state.readonlyVars=t.state.readonlyVars||new Set,t.state.readonlyVars.add(e)}function rw(t,e){return t.state.readonlyVars?.has(e)??!1}function Et(t,e,n="bash"){return rw(t,e)?q(`${n}: ${e}: readonly variable
698
- `):null}function Ed(t){let e=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(e)return{name:e[1],isArray:!0,arrayElements:Mi(e[2])};if(t.includes("=")){let n=t.indexOf("=");return{name:t.slice(0,n),isArray:!1,value:t.slice(n+1)}}return{name:t,isArray:!1}}function Sd(t,e,n={}){let{name:r,isArray:s,arrayElements:i,value:o}=e,{makeReadonly:a=!1,checkReadonly:l=!0}=n;if(l){let c=Et(t,r);if(c)return c}if(s&&i){for(let c=0;c<i.length;c++)t.state.env[`${r}_${c}`]=i[c];t.state.env[`${r}__length`]=String(i.length)}else o!==void 0&&(t.state.env[r]=o);return a&&jt(t,r),null}function _i(t,e){let n=!1,r=!1,s=!1,i=!1,o=!1,a=[];for(let l=0;l<e.length;l++){let c=e[l];if(c==="-a")n=!0;else if(c==="-A")r=!0;else if(c==="-r")s=!0;else if(c==="-x")i=!0;else if(c==="-p")o=!0;else if(c==="--"){a.push(...e.slice(l+1));break}else if(c.startsWith("-"))for(let u of c.slice(1))u==="a"?n=!0:u==="A"?r=!0:u==="r"?s=!0:u==="x"?i=!0:u==="p"&&(o=!0);else a.push(c)}if(o&&a.length>0){let l="";for(let c of a){let u=t.state.env[c];if(u!==void 0){let f=u.replace(/\\/g,"\\\\").replace(/"/g,'\\"');l+=`declare -- ${c}="${f}"
700
+ `:"")}de();function _i(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new at;return te}if(e.length>1)throw new Pe(1);let n=1;if(e.length>0){let r=Number.parseInt(e[0],10);if(Number.isNaN(r)||r<1)return V(`bash: continue: ${e[0]}: numeric argument required
701
+ `);n=r}throw new Be(n)}function zt(t,e){t.state.readonlyVars=t.state.readonlyVars||new Set,t.state.readonlyVars.add(e)}function fw(t,e){return t.state.readonlyVars?.has(e)??!1}function St(t,e,n="bash"){return fw(t,e)?V(`${n}: ${e}: readonly variable
702
+ `):null}function kd(t){let e=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(e)return{name:e[1],isArray:!0,arrayElements:Bi(e[2])};if(t.includes("=")){let n=t.indexOf("=");return{name:t.slice(0,n),isArray:!1,value:t.slice(n+1)}}return{name:t,isArray:!1}}function Nd(t,e,n={}){let{name:r,isArray:s,arrayElements:i,value:o}=e,{makeReadonly:a=!1,checkReadonly:l=!0}=n;if(l){let c=St(t,r);if(c)return c}if(s&&i){for(let c=0;c<i.length;c++)t.state.env[`${r}_${c}`]=i[c];t.state.env[`${r}__length`]=String(i.length)}else o!==void 0&&(t.state.env[r]=o);return a&&zt(t,r),null}function Wi(t,e){let n=!1,r=!1,s=!1,i=!1,o=!1,a=[];for(let l=0;l<e.length;l++){let c=e[l];if(c==="-a")n=!0;else if(c==="-A")r=!0;else if(c==="-r")s=!0;else if(c==="-x")i=!0;else if(c==="-p")o=!0;else if(c==="--"){a.push(...e.slice(l+1));break}else if(c.startsWith("-"))for(let u of c.slice(1))u==="a"?n=!0:u==="A"?r=!0:u==="r"?s=!0:u==="x"?i=!0:u==="p"&&(o=!0);else a.push(c)}if(o&&a.length>0){let l="";for(let c of a){let u=t.state.env[c];if(u!==void 0){let f=u.replace(/\\/g,"\\\\").replace(/"/g,'\\"');l+=`declare -- ${c}="${f}"
699
703
  `}}return Ze(l)}if(a.length===0&&!o){let l="",c=Object.entries(t.state.env).filter(([u])=>!u.startsWith("BASH_")).sort(([u],[f])=>u.localeCompare(f));for(let[u,f]of c){let d=f.replace(/'/g,"'\\''");l+=`declare -- ${u}='${d}'
700
- `}return Ze(l)}for(let l of a){let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(c){let u=c[1],f=c[2];if(r&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u)),r&&f.includes("[")){let d=sw(f);for(let[p,h]of d)t.state.env[`${u}_${p}`]=h}else{let d=Mi(f);for(let p=0;p<d.length;p++)t.state.env[`${u}_${p}`]=d[p];t.state.env[`${u}__length`]=String(d.length)}s&&jt(t,u);continue}if(l.includes("=")){let u=l.indexOf("="),f=l.slice(0,u),d=l.slice(u+1),p=Et(t,f);if(p)return p;t.state.env[f]=d,s&&jt(t,f)}else{let u=l;r&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u));let f=Object.keys(t.state.env).some(d=>d.startsWith(`${u}_`)&&!d.startsWith(`${u}__length`));!(u in t.state.env)&&!f&&(n||r?t.state.env[`${u}__length`]="0":t.state.env[u]=""),s&&jt(t,u)}}return te}function Mi(t){let e=[],n="",r=!1,s=!1,i=!1;for(let o of t){if(i){n+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(o==="'"&&!s){r=!r;continue}if(o==='"'&&!r){s=!s;continue}if((o===" "||o===" "||o===`
701
- `)&&!r&&!s){n&&(e.push(n),n="");continue}n+=o}return n&&e.push(n),e}function sw(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&/\s/.test(t[n]);)n++;if(n>=t.length)break;if(t[n]!=="["){n++;continue}n++;let r="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)r+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&t[n]!=="]"&&t[n]!=="=";)r+=t[n],n++;for(;n<t.length&&t[n]!=="]";)n++;if(t[n]==="]"&&n++,t[n]!=="=")continue;n++;let s="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)t[n]==="\\"&&n+1<t.length&&n++,s+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&!/\s/.test(t[n]);)s+=t[n],n++;e.push([r,s])}return e}function Bi(t,e){let n=!1,r=!1,s=[];for(let i=0;i<e.length;i++){let o=e[i];if(o==="-a")n=!0;else if(o==="-A")r=!0;else if(o==="-p"){if(e.length===1){let a="";for(let l of t.state.readonlyVars||[]){let c=t.state.env[l];c!==void 0&&(a+=`declare -r ${l}="${c}"
702
- `)}return Ze(a)}}else if(o==="--"){s.push(...e.slice(i+1));break}else o.startsWith("-")||s.push(o)}for(let i of s){let o=Ed(i);if(o.value===void 0&&!o.isArray){jt(t,o.name);continue}let a=Sd(t,o,{makeReadonly:!0});if(a)return a}return te}fe();async function Wi(t,e){let n=e;if(n.length>0){let s=n[0];if(s==="--")n=n.slice(1);else if(s.startsWith("-")&&s!=="-"&&s.length>1)return q(`bash: eval: ${s}: invalid option
704
+ `}return Ze(l)}for(let l of a){let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(c){let u=c[1],f=c[2];if(r&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u)),r&&f.includes("[")){let d=dw(f);for(let[p,h]of d)t.state.env[`${u}_${p}`]=h}else{let d=Bi(f);for(let p=0;p<d.length;p++)t.state.env[`${u}_${p}`]=d[p];t.state.env[`${u}__length`]=String(d.length)}s&&zt(t,u);continue}if(l.includes("=")){let u=l.indexOf("="),f=l.slice(0,u),d=l.slice(u+1),p=St(t,f);if(p)return p;t.state.env[f]=d,s&&zt(t,f)}else{let u=l;r&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u));let f=Object.keys(t.state.env).some(d=>d.startsWith(`${u}_`)&&!d.startsWith(`${u}__length`));!(u in t.state.env)&&!f&&(n||r?t.state.env[`${u}__length`]="0":t.state.env[u]=""),s&&zt(t,u)}}return te}function Bi(t){let e=[],n="",r=!1,s=!1,i=!1;for(let o of t){if(i){n+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(o==="'"&&!s){r=!r;continue}if(o==='"'&&!r){s=!s;continue}if((o===" "||o===" "||o===`
705
+ `)&&!r&&!s){n&&(e.push(n),n="");continue}n+=o}return n&&e.push(n),e}function dw(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&/\s/.test(t[n]);)n++;if(n>=t.length)break;if(t[n]!=="["){n++;continue}n++;let r="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)r+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&t[n]!=="]"&&t[n]!=="=";)r+=t[n],n++;for(;n<t.length&&t[n]!=="]";)n++;if(t[n]==="]"&&n++,t[n]!=="=")continue;n++;let s="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)t[n]==="\\"&&n+1<t.length&&n++,s+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&!/\s/.test(t[n]);)s+=t[n],n++;e.push([r,s])}return e}function Ui(t,e){let n=!1,r=!1,s=[];for(let i=0;i<e.length;i++){let o=e[i];if(o==="-a")n=!0;else if(o==="-A")r=!0;else if(o==="-p"){if(e.length===1){let a="";for(let l of t.state.readonlyVars||[]){let c=t.state.env[l];c!==void 0&&(a+=`declare -r ${l}="${c}"
706
+ `)}return Ze(a)}}else if(o==="--"){s.push(...e.slice(i+1));break}else o.startsWith("-")||s.push(o)}for(let i of s){let o=kd(i);if(o.value===void 0&&!o.isArray){zt(t,o.name);continue}let a=Nd(t,o,{makeReadonly:!0});if(a)return a}return te}de();async function ji(t,e){let n=e;if(n.length>0){let s=n[0];if(s==="--")n=n.slice(1);else if(s.startsWith("-")&&s!=="-"&&s.length>1)return V(`bash: eval: ${s}: invalid option
703
707
  eval: usage: eval [arg ...]
704
- `,2)}if(n.length===0)return te;let r=n.join(" ");if(r.trim()==="")return te;try{let s=wt(r);return t.executeScript(s)}catch(s){if(s instanceof Fe||s instanceof Be||s instanceof Te||s instanceof ue)throw s;if(s.name==="ParseException")return q(`bash: eval: ${s.message}
705
- `);throw s}}fe();function Ui(t,e){let n,r="";if(e.length===0)n=t.state.lastExitCode;else{let s=e[0],i=Number.parseInt(s,10);s===""||Number.isNaN(i)||!/^-?\d+$/.test(s)?(r=`bash: exit: ${s}: numeric argument required
706
- `,n=2):n=(i%256+256)%256}throw new ue(n,"",r)}function ji(t,e){let n=!1,r=[];for(let o of e)o==="-n"?n=!0:o==="-p"||o==="--"||r.push(o);if(r.length===0&&!n){let o="",a=Object.entries(t.state.env).filter(([l])=>!l.startsWith("BASH_ALIAS_")).sort(([l],[c])=>l.localeCompare(c));for(let[l,c]of a){let u=c.replace(/'/g,"'\\''");o+=`declare -x ${l}='${u}'
708
+ `,2)}if(n.length===0)return te;let r=n.join(" ");if(r.trim()==="")return te;try{let s=bt(r);return t.executeScript(s)}catch(s){if(s instanceof Pe||s instanceof Be||s instanceof Te||s instanceof fe)throw s;if(s.name==="ParseException")return V(`bash: eval: ${s.message}
709
+ `);throw s}}de();function zi(t,e){let n,r="";if(e.length===0)n=t.state.lastExitCode;else{let s=e[0],i=Number.parseInt(s,10);s===""||Number.isNaN(i)||!/^-?\d+$/.test(s)?(r=`bash: exit: ${s}: numeric argument required
710
+ `,n=2):n=(i%256+256)%256}throw new fe(n,"",r)}function Hi(t,e){let n=!1,r=[];for(let o of e)o==="-n"?n=!0:o==="-p"||o==="--"||r.push(o);if(r.length===0&&!n){let o="",a=Object.entries(t.state.env).filter(([l])=>!l.startsWith("BASH_ALIAS_")).sort(([l],[c])=>l.localeCompare(c));for(let[l,c]of a){let u=c.replace(/'/g,"'\\''");o+=`declare -x ${l}='${u}'
707
711
  `}return Ze(o)}if(n){for(let o of r){let a=o.split("=")[0];delete t.state.env[a]}return te}let s="",i=0;for(let o of r){let a,l;if(o.includes("=")){let c=o.indexOf("=");a=o.slice(0,c),l=o.slice(c+1)}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){s+=`bash: export: \`${o}': not a valid identifier
708
- `,i=1;continue}l!==void 0?t.state.env[a]=l:a in t.state.env||(t.state.env[a]="")}return H("",s,i)}function iw(t){let e=[],n="",r=0;for(let s of t){for(let i of s)i==="("?r++:i===")"&&r--;n?n+=` ${s}`:n=s,r===0&&(e.push(n),n="")}return n&&e.push(n),e}async function zi(t,e){if(e.length===0)return q(`bash: let: expression expected
709
- `);let n=iw(e),r=0;for(let s of n)try{let o=wt(`(( ${s} ))`).statements[0];if(o&&o.pipelines.length>0&&o.pipelines[0].commands.length>0){let a=o.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(r=await se(t,a.expression.expression))}}catch(i){return q(`bash: let: ${s}: ${i.message}
710
- `)}return H("","",r===0?1:0)}function ow(t,e){let n=t.state.env.HOME||"/home/user";return e.split(":").map(i=>i==="~"?n:i==="~root"?"/root":i.startsWith("~/")?n+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function Hi(t,e){if(t.state.localScopes.length===0)return q(`bash: local: can only be used in a function
711
- `);let n=t.state.localScopes[t.state.localScopes.length-1],r="",s=0;for(let i of e){let o,a;if(i.includes("=")){let l=i.indexOf("=");o=i.slice(0,l),a=ow(t,i.slice(l+1))}else o=i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){r+=`bash: local: \`${i}': not a valid identifier
712
- `,s=1;continue}n.has(o)||n.set(o,t.state.env[o]),a!==void 0&&(t.state.env[o]=a)}return H("",r,s)}function Gi(t,e,n){let r=`
712
+ `,i=1;continue}l!==void 0?t.state.env[a]=l:a in t.state.env||(t.state.env[a]="")}return H("",s,i)}function pw(t){let e=[],n="",r=0;for(let s of t){for(let i of s)i==="("?r++:i===")"&&r--;n?n+=` ${s}`:n=s,r===0&&(e.push(n),n="")}return n&&e.push(n),e}async function Gi(t,e){if(e.length===0)return V(`bash: let: expression expected
713
+ `);let n=pw(e),r=0;for(let s of n)try{let o=bt(`(( ${s} ))`).statements[0];if(o&&o.pipelines.length>0&&o.pipelines[0].commands.length>0){let a=o.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(r=await se(t,a.expression.expression))}}catch(i){return V(`bash: let: ${s}: ${i.message}
714
+ `)}return H("","",r===0?1:0)}function hw(t,e){let n=t.state.env.HOME||"/home/user";return e.split(":").map(i=>i==="~"?n:i==="~root"?"/root":i.startsWith("~/")?n+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function qi(t,e){if(t.state.localScopes.length===0)return V(`bash: local: can only be used in a function
715
+ `);let n=t.state.localScopes[t.state.localScopes.length-1],r="",s=0;for(let i of e){let o,a;if(i.includes("=")){let l=i.indexOf("=");o=i.slice(0,l),a=hw(t,i.slice(l+1))}else o=i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){r+=`bash: local: \`${i}': not a valid identifier
716
+ `,s=1;continue}n.has(o)||n.set(o,t.state.env[o]),a!==void 0&&(t.state.env[o]=a)}return H("",r,s)}function Vi(t,e,n){let r=`
713
717
  `,s=0,i=0,o=0,a=!1,l="MAPFILE",c=0;for(;c<e.length;){let m=e[c];m==="-d"&&c+1<e.length?(r=e[c+1]||`
714
- `,c+=2):m==="-n"&&c+1<e.length?(s=Number.parseInt(e[c+1],10)||0,c+=2):m==="-O"&&c+1<e.length?(i=Number.parseInt(e[c+1],10)||0,c+=2):m==="-s"&&c+1<e.length?(o=Number.parseInt(e[c+1],10)||0,c+=2):m==="-t"?(a=!0,c++):m==="-u"||m==="-C"||m==="-c"?c+=2:(m.startsWith("-")||(l=m),c++)}let u=n;!u&&t.state.groupStdin!==void 0&&(u=t.state.groupStdin);let f=[],d=u,p=0,h=0;for(;d.length>0;){let m=d.indexOf(r);if(m===-1){d.length>0&&(h<o?h++:(s===0||p<s)&&(f.push(d),p++));break}let g=d.substring(0,m);if(a||(g+=r),d=d.substring(m+r.length),h<o){h++;continue}if(s>0&&p>=s)break;f.push(g),p++}Wn(t,l);for(let m=0;m<f.length;m++)t.state.env[`${l}_${i+m}`]=f[m];return f.length>0&&(t.state.env[`${l}__length`]=String(i+f.length)),t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=""),H("","",0)}function qi(t,e,n){let r=!1,s=`
715
- `,i="",o=-1,a=null,l=[],c=0,u=!1;for(;c<e.length;){let b=e[c];b==="-r"?r=!0:b==="-d"&&c+1<e.length?(s=e[c+1],c++):b==="-p"&&c+1<e.length?(i=e[c+1],c++):b==="-n"&&c+1<e.length?(o=Number.parseInt(e[c+1],10),(Number.isNaN(o)||o<0)&&(u=!0,o=0),c++):b==="-a"&&c+1<e.length?(a=e[c+1],c++):b==="-t"?c+1<e.length&&!e[c+1].startsWith("-")&&c++:b==="-s"||b.startsWith("-")||l.push(b),c++}if(u)return H("","",1);l.length===0&&a===null&&l.push("REPLY");let f=n;!f&&t.state.groupStdin!==void 0&&(f=t.state.groupStdin);let d="",p=0,h=!0;if(o>=0){for(let b=0;b<f.length&&b<o;b++){let E=f[b];if(E===s){p=b+1;break}d+=E,p=b+1}t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=f.substring(p))}else{let b=f;for(p=0;;){let E=b.indexOf(s);if(E!==-1){let S=b.substring(0,E);if(p+=E+s.length,b=b.substring(E+s.length),!r&&S.endsWith("\\")){d+=S.slice(0,-1);continue}d+=S,h=!0;break}else if(b.length>0){d+=b,p+=b.length,h=!1,b="";break}else{if(d.length===0){for(let S of l)t.state.env[S]="";return a&&Wn(t,a),H("","",1)}h=!1;break}}t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=f.substring(p))}if(s===`
718
+ `,c+=2):m==="-n"&&c+1<e.length?(s=Number.parseInt(e[c+1],10)||0,c+=2):m==="-O"&&c+1<e.length?(i=Number.parseInt(e[c+1],10)||0,c+=2):m==="-s"&&c+1<e.length?(o=Number.parseInt(e[c+1],10)||0,c+=2):m==="-t"?(a=!0,c++):m==="-u"||m==="-C"||m==="-c"?c+=2:(m.startsWith("-")||(l=m),c++)}let u=n;!u&&t.state.groupStdin!==void 0&&(u=t.state.groupStdin);let f=[],d=u,p=0,h=0;for(;d.length>0;){let m=d.indexOf(r);if(m===-1){d.length>0&&(h<o?h++:(s===0||p<s)&&(f.push(d),p++));break}let g=d.substring(0,m);if(a||(g+=r),d=d.substring(m+r.length),h<o){h++;continue}if(s>0&&p>=s)break;f.push(g),p++}jn(t,l);for(let m=0;m<f.length;m++)t.state.env[`${l}_${i+m}`]=f[m];return f.length>0&&(t.state.env[`${l}__length`]=String(i+f.length)),t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=""),H("","",0)}function Zi(t,e,n){let r=!1,s=`
719
+ `,i="",o=-1,a=null,l=[],c=0,u=!1;for(;c<e.length;){let w=e[c];w==="-r"?r=!0:w==="-d"&&c+1<e.length?(s=e[c+1],c++):w==="-p"&&c+1<e.length?(i=e[c+1],c++):w==="-n"&&c+1<e.length?(o=Number.parseInt(e[c+1],10),(Number.isNaN(o)||o<0)&&(u=!0,o=0),c++):w==="-a"&&c+1<e.length?(a=e[c+1],c++):w==="-t"?c+1<e.length&&!e[c+1].startsWith("-")&&c++:w==="-s"||w.startsWith("-")||l.push(w),c++}if(u)return H("","",1);l.length===0&&a===null&&l.push("REPLY");let f=n;!f&&t.state.groupStdin!==void 0&&(f=t.state.groupStdin);let d="",p=0,h=!0;if(o>=0){for(let w=0;w<f.length&&w<o;w++){let E=f[w];if(E===s){p=w+1;break}d+=E,p=w+1}t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=f.substring(p))}else{let w=f;for(p=0;;){let E=w.indexOf(s);if(E!==-1){let S=w.substring(0,E);if(p+=E+s.length,w=w.substring(E+s.length),!r&&S.endsWith("\\")){d+=S.slice(0,-1);continue}d+=S,h=!0;break}else if(w.length>0){d+=w,p+=w.length,h=!1,w="";break}else{if(d.length===0){for(let S of l)t.state.env[S]="";return a&&jn(t,a),H("","",1)}h=!1;break}}t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=f.substring(p))}if(s===`
716
720
  `&&d.endsWith(`
717
- `)&&(d=d.slice(0,-1)),r||(d=d.replace(/\\(.)/g,"$1")),l.length===1&&l[0]==="REPLY")return t.state.env.REPLY=d,H("","",h?0:1);let m=Br(t.state.env),{words:g,wordStarts:w}=sd(d,m);if(a){Wn(t,a);for(let b=0;b<g.length;b++)t.state.env[`${a}_${b}`]=g[b];return H("","",h?0:1)}for(let b=0;b<l.length;b++){let E=l[b];if(b<l.length-1)t.state.env[E]=g[b]??"";else if(b<w.length){let S=id(d.substring(w[b]),m);t.state.env[E]=S}else t.state.env[E]=""}return H("","",h?0:1)}fe();function Vi(t,e){if(t.state.callDepth===0&&t.state.sourceDepth===0)return q("bash: return: can only `return' from a function or sourced script\n");let n=t.state.lastExitCode;if(e.length>0){let r=e[0],s=Number.parseInt(r,10);if(r===""||Number.isNaN(s)||!/^-?\d+$/.test(r))return q(`bash: return: ${r}: numeric argument required
718
- `,2);n=(s%256+256)%256}throw new Te(n)}function aw(t){return/^[a-zA-Z0-9_/.:-]*$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}var zr=`set: usage: set [-eux] [+eux] [-o option] [+o option]
721
+ `)&&(d=d.slice(0,-1)),r||(d=d.replace(/\\(.)/g,"$1")),l.length===1&&l[0]==="REPLY")return t.state.env.REPLY=d,H("","",h?0:1);let m=Wr(t.state.env),{words:g,wordStarts:b}=ld(d,m);if(a){jn(t,a);for(let w=0;w<g.length;w++)t.state.env[`${a}_${w}`]=g[w];return H("","",h?0:1)}for(let w=0;w<l.length;w++){let E=l[w];if(w<l.length-1)t.state.env[E]=g[w]??"";else if(w<b.length){let S=cd(d.substring(b[w]),m);t.state.env[E]=S}else t.state.env[E]=""}return H("","",h?0:1)}de();function Ki(t,e){if(t.state.callDepth===0&&t.state.sourceDepth===0)return V("bash: return: can only `return' from a function or sourced script\n");let n=t.state.lastExitCode;if(e.length>0){let r=e[0],s=Number.parseInt(r,10);if(r===""||Number.isNaN(s)||!/^-?\d+$/.test(r))return V(`bash: return: ${r}: numeric argument required
722
+ `,2);n=(s%256+256)%256}throw new Te(n)}function mw(t){return/^[a-zA-Z0-9_/.:-]*$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}var Hr=`set: usage: set [-eux] [+eux] [-o option] [+o option]
719
723
  Options:
720
724
  -e Exit immediately if a command exits with non-zero status
721
725
  +e Disable -e
@@ -731,68 +735,68 @@ Options:
731
735
  +o pipefail Disable pipefail
732
736
  -o xtrace Same as -x
733
737
  +o xtrace Disable xtrace
734
- `,Cd={e:"errexit",u:"nounset",x:"xtrace",v:"verbose",f:null,h:null,C:null,n:null,a:null,b:null,m:null,B:null,H:null,P:null,T:null,E:null,p:null},Ad={errexit:"errexit",pipefail:"pipefail",nounset:"nounset",xtrace:"xtrace",verbose:"verbose",noclobber:null,noglob:null,noexec:null,allexport:null,notify:null,monitor:null,braceexpand:null,histexpand:null,physical:null,functrace:null,errtrace:null,privileged:null,hashall:null,posix:null,vi:null,emacs:null,ignoreeof:null,"interactive-comments":null,keyword:null,onecmd:null},kd=["errexit","nounset","pipefail","verbose","xtrace"],Nd=["allexport","braceexpand","emacs","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","noclobber","noexec","noglob","nolog","notify","onecmd","physical","posix","privileged","vi"];function Id(t,e,n){e!==null&&(t.state.options[e]=n)}function lw(t,e){return e+1<t.length&&!t[e+1].startsWith("-")&&!t[e+1].startsWith("+")}function Ki(t,e){if(e.includes("--help"))return Ze(zr);if(e.length===0){let r=Object.entries(t.state.env).filter(([s])=>/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)).sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>`${s}=${aw(i)}`).join(`
738
+ `,Id={e:"errexit",u:"nounset",x:"xtrace",v:"verbose",f:null,h:null,C:null,n:null,a:null,b:null,m:null,B:null,H:null,P:null,T:null,E:null,p:null},vd={errexit:"errexit",pipefail:"pipefail",nounset:"nounset",xtrace:"xtrace",verbose:"verbose",noclobber:null,noglob:null,noexec:null,allexport:null,notify:null,monitor:null,braceexpand:null,histexpand:null,physical:null,functrace:null,errtrace:null,privileged:null,hashall:null,posix:null,vi:null,emacs:null,ignoreeof:null,"interactive-comments":null,keyword:null,onecmd:null},$d=["errexit","nounset","pipefail","verbose","xtrace"],Rd=["allexport","braceexpand","emacs","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","noclobber","noexec","noglob","nolog","notify","onecmd","physical","posix","privileged","vi"];function Fd(t,e,n){e!==null&&(t.state.options[e]=n)}function gw(t,e){return e+1<t.length&&!t[e+1].startsWith("-")&&!t[e+1].startsWith("+")}function Xi(t,e){if(e.includes("--help"))return Ze(Hr);if(e.length===0){let r=Object.entries(t.state.env).filter(([s])=>/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)).sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>`${s}=${mw(i)}`).join(`
735
739
  `);return Ze(r?`${r}
736
- `:"")}let n=0;for(;n<e.length;){let r=e[n];if((r==="-o"||r==="+o")&&lw(e,n)){let s=e[n+1];if(!(s in Ad))return q(`bash: set: ${s}: invalid option name
737
- ${zr}`);Id(t,Ad[s],r==="-o"),n+=2;continue}if(r==="-o"){let s=kd.map(a=>`${a.padEnd(16)}${t.state.options[a]?"on":"off"}`),i=Nd.map(a=>`${a.padEnd(16)}off`),o=[...s,...i].sort();return Ze(`${o.join(`
740
+ `:"")}let n=0;for(;n<e.length;){let r=e[n];if((r==="-o"||r==="+o")&&gw(e,n)){let s=e[n+1];if(!(s in vd))return V(`bash: set: ${s}: invalid option name
741
+ ${Hr}`);Fd(t,vd[s],r==="-o"),n+=2;continue}if(r==="-o"){let s=$d.map(a=>`${a.padEnd(16)}${t.state.options[a]?"on":"off"}`),i=Rd.map(a=>`${a.padEnd(16)}off`),o=[...s,...i].sort();return Ze(`${o.join(`
738
742
  `)}
739
- `)}if(r==="+o"){let s=kd.map(a=>`set ${t.state.options[a]?"-o":"+o"} ${a}`),i=Nd.map(a=>`set +o ${a}`),o=[...s,...i].sort();return Ze(`${o.join(`
743
+ `)}if(r==="+o"){let s=$d.map(a=>`set ${t.state.options[a]?"-o":"+o"} ${a}`),i=Rd.map(a=>`set +o ${a}`),o=[...s,...i].sort();return Ze(`${o.join(`
740
744
  `)}
741
- `)}if(r.length>1&&(r[0]==="-"||r[0]==="+")&&r[1]!=="-"){let s=r[0]==="-";for(let i=1;i<r.length;i++){let o=r[i];if(!(o in Cd))return q(`bash: set: ${r[0]}${o}: invalid option
742
- ${zr}`);Id(t,Cd[o],s)}n++;continue}if(r==="--")return Zi(t,e.slice(n+1)),te;if(r==="-"){if(t.state.options.xtrace=!1,t.state.options.verbose=!1,n+1<e.length)return Zi(t,e.slice(n+1)),te;n++;continue}if(r==="+"){n++;continue}return r.startsWith("-")||r.startsWith("+")?q(`bash: set: ${r}: invalid option
743
- ${zr}`):(Zi(t,e.slice(n)),te)}return te}function Zi(t,e){let n=1;for(;t.state.env[String(n)]!==void 0;)delete t.state.env[String(n)],n++;for(let r=0;r<e.length;r++)t.state.env[String(r+1)]=e[r];t.state.env["#"]=String(e.length),t.state.env["@"]=e.join(" "),t.state.env["*"]=e.join(" ")}function Qi(t,e){let n=1;if(e.length>0){let o=Number.parseInt(e[0],10);if(Number.isNaN(o)||o<0)return q(`bash: shift: ${e[0]}: numeric argument required
744
- `);n=o}let r=Number.parseInt(t.state.env["#"]||"0",10);if(n>r)return q(`bash: shift: shift count out of range
745
- `);if(n===0)return te;let s=[];for(let o=1;o<=r;o++)s.push(t.state.env[String(o)]||"");let i=s.slice(n);for(let o=1;o<=r;o++)delete t.state.env[String(o)];for(let o=0;o<i.length;o++)t.state.env[String(o+1)]=i[o];return t.state.env["#"]=String(i.length),t.state.env["@"]=i.join(" "),te}fe();async function Xi(t,e){let n=e;if(n.length>0&&n[0]==="--"&&(n=n.slice(1)),n.length===0)return H("",`bash: source: filename argument required
746
- `,2);let r=n[0],s=null,i=null;if(r.includes("/")){let l=t.fs.resolvePath(t.state.cwd,r);try{i=await t.fs.readFile(l),s=l}catch{}}else{let c=(t.state.env.PATH||"").split(":").filter(u=>u);for(let u of c){let f=t.fs.resolvePath(t.state.cwd,`${u}/${r}`);try{if((await t.fs.stat(f)).isDirectory)continue;i=await t.fs.readFile(f),s=f;break}catch{}}if(i===null){let u=t.fs.resolvePath(t.state.cwd,r);try{i=await t.fs.readFile(u),s=u}catch{}}}if(i===null)return q(`bash: ${r}: No such file or directory
747
- `);let o={};if(n.length>1){for(let c=1;c<=9;c++)o[String(c)]=t.state.env[String(c)];o["#"]=t.state.env["#"],o["@"]=t.state.env["@"];let l=n.slice(1);t.state.env["#"]=String(l.length),t.state.env["@"]=l.join(" ");for(let c=0;c<l.length&&c<9;c++)t.state.env[String(c+1)]=l[c];for(let c=l.length+1;c<=9;c++)delete t.state.env[String(c)]}let a=()=>{if(t.state.sourceDepth--,n.length>1)for(let[l,c]of Object.entries(o))c===void 0?delete t.state.env[l]:t.state.env[l]=c};t.state.sourceDepth++;try{let l=wt(i),c=await t.executeScript(l);return a(),c}catch(l){if(a(),l instanceof ue)throw l;if(l instanceof Te)return H(l.stdout,l.stderr,l.exitCode);if(l.name==="ParseException")return q(`bash: ${r}: ${l.message}
748
- `);throw l}}function Ji(t,e){let n="variable",r="",s=0;for(let i of e){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){t.state.functions.delete(i);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let a=o[1],l=o[2];if(l==="@"||l==="*"){let u=$e(t,a);for(let[f]of u)delete t.state.env[`${a}_${f}`];delete t.state.env[a];continue}let c;if(/^-?\d+$/.test(l))c=Number.parseInt(l,10);else{let u=t.state.env[l];c=u?Number.parseInt(u,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let u=$e(t,a),f=u.length;if(f===0){r+=`bash: unset: [${c}]: bad array subscript
745
+ `)}if(r.length>1&&(r[0]==="-"||r[0]==="+")&&r[1]!=="-"){let s=r[0]==="-";for(let i=1;i<r.length;i++){let o=r[i];if(!(o in Id))return V(`bash: set: ${r[0]}${o}: invalid option
746
+ ${Hr}`);Fd(t,Id[o],s)}n++;continue}if(r==="--")return Qi(t,e.slice(n+1)),te;if(r==="-"){if(t.state.options.xtrace=!1,t.state.options.verbose=!1,n+1<e.length)return Qi(t,e.slice(n+1)),te;n++;continue}if(r==="+"){n++;continue}return r.startsWith("-")||r.startsWith("+")?V(`bash: set: ${r}: invalid option
747
+ ${Hr}`):(Qi(t,e.slice(n)),te)}return te}function Qi(t,e){let n=1;for(;t.state.env[String(n)]!==void 0;)delete t.state.env[String(n)],n++;for(let r=0;r<e.length;r++)t.state.env[String(r+1)]=e[r];t.state.env["#"]=String(e.length),t.state.env["@"]=e.join(" "),t.state.env["*"]=e.join(" ")}function Ji(t,e){let n=1;if(e.length>0){let o=Number.parseInt(e[0],10);if(Number.isNaN(o)||o<0)return V(`bash: shift: ${e[0]}: numeric argument required
748
+ `);n=o}let r=Number.parseInt(t.state.env["#"]||"0",10);if(n>r)return V(`bash: shift: shift count out of range
749
+ `);if(n===0)return te;let s=[];for(let o=1;o<=r;o++)s.push(t.state.env[String(o)]||"");let i=s.slice(n);for(let o=1;o<=r;o++)delete t.state.env[String(o)];for(let o=0;o<i.length;o++)t.state.env[String(o+1)]=i[o];return t.state.env["#"]=String(i.length),t.state.env["@"]=i.join(" "),te}de();async function Yi(t,e){let n=e;if(n.length>0&&n[0]==="--"&&(n=n.slice(1)),n.length===0)return H("",`bash: source: filename argument required
750
+ `,2);let r=n[0],s=null,i=null;if(r.includes("/")){let l=t.fs.resolvePath(t.state.cwd,r);try{i=await t.fs.readFile(l),s=l}catch{}}else{let c=(t.state.env.PATH||"").split(":").filter(u=>u);for(let u of c){let f=t.fs.resolvePath(t.state.cwd,`${u}/${r}`);try{if((await t.fs.stat(f)).isDirectory)continue;i=await t.fs.readFile(f),s=f;break}catch{}}if(i===null){let u=t.fs.resolvePath(t.state.cwd,r);try{i=await t.fs.readFile(u),s=u}catch{}}}if(i===null)return V(`bash: ${r}: No such file or directory
751
+ `);let o={};if(n.length>1){for(let c=1;c<=9;c++)o[String(c)]=t.state.env[String(c)];o["#"]=t.state.env["#"],o["@"]=t.state.env["@"];let l=n.slice(1);t.state.env["#"]=String(l.length),t.state.env["@"]=l.join(" ");for(let c=0;c<l.length&&c<9;c++)t.state.env[String(c+1)]=l[c];for(let c=l.length+1;c<=9;c++)delete t.state.env[String(c)]}let a=()=>{if(t.state.sourceDepth--,n.length>1)for(let[l,c]of Object.entries(o))c===void 0?delete t.state.env[l]:t.state.env[l]=c};t.state.sourceDepth++;try{let l=bt(i),c=await t.executeScript(l);return a(),c}catch(l){if(a(),l instanceof fe)throw l;if(l instanceof Te)return H(l.stdout,l.stderr,l.exitCode);if(l.name==="ParseException")return V(`bash: ${r}: ${l.message}
752
+ `);throw l}}function eo(t,e){let n="variable",r="",s=0;for(let i of e){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){t.state.functions.delete(i);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let a=o[1],l=o[2];if(l==="@"||l==="*"){let u=$e(t,a);for(let[f]of u)delete t.state.env[`${a}_${f}`];delete t.state.env[a];continue}let c;if(/^-?\d+$/.test(l))c=Number.parseInt(l,10);else{let u=t.state.env[l];c=u?Number.parseInt(u,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let u=$e(t,a),f=u.length;if(f===0){r+=`bash: unset: [${c}]: bad array subscript
749
753
  `,s=1;continue}let d=f+c;if(d<0){r+=`bash: unset: [${c}]: bad array subscript
750
- `,s=1;continue}let p=u[d][0];delete t.state.env[`${a}_${p}`];continue}delete t.state.env[`${a}_${c}`];continue}delete t.state.env[i],t.state.functions.delete(i)}return H("",r,s)}function Yi(t,e){return t.fs.resolvePath(t.state.cwd,e)}var cw=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function Hr(t){return cw.includes(t)}async function Gr(t,e,n){let r=Yi(t,n);switch(e){case"-e":case"-a":return t.fs.exists(r);case"-f":return await t.fs.exists(r)?(await t.fs.stat(r)).isFile:!1;case"-d":return await t.fs.exists(r)?(await t.fs.stat(r)).isDirectory:!1;case"-r":case"-w":case"-x":return t.fs.exists(r);case"-s":return await t.fs.exists(r)?(await t.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await t.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&512)!==0:!1;case"-g":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return t.fs.exists(r);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>r===i||r.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return t.fs.exists(r);default:return!1}}var uw=["-nt","-ot","-ef"];function qr(t){return uw.includes(t)}async function Vr(t,e,n,r){let s=Yi(t,n),i=Yi(t,r);switch(e){case"-nt":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await t.fs.exists(s)||!await t.fs.exists(i))return!1;let o=t.fs.resolvePath(t.state.cwd,s),a=t.fs.resolvePath(t.state.cwd,i);return o===a}catch{return!1}default:return!1}}var fw=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function Zr(t){return fw.has(t)}function Kr(t,e,n){switch(t){case"-eq":return e===n;case"-ne":return e!==n;case"-lt":return e<n;case"-le":return e<=n;case"-gt":return e>n;case"-ge":return e>=n}}function Qr(t){return t==="="||t==="=="||t==="!="}function Xr(t,e,n,r=!1){let s=r?Jr(e,n):e===n;return t==="!="?!s:s}var dw=new Set(["-z","-n"]);function Yr(t){return dw.has(t)}function es(t,e){switch(t){case"-z":return e==="";case"-n":return e!==""}}function ts(t,e){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let r=n[1],s=n[2];s=s.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(o,a)=>t.state.env[a]||"");let i;if(/^-?\d+$/.test(s))i=Number.parseInt(s,10);else try{let o=Function(`"use strict"; return (${s})`)();i=typeof o=="number"?Math.floor(o):0}catch{let o=t.state.env[s];i=o?Number.parseInt(o,10):0}if(i<0){let o=Bn(t,r);if(o.length===0||(i=Math.max(...o)+1+i,i<0))return!1}return`${r}_${i}`in t.state.env}return e in t.state.env}async function St(t,e){switch(e.type){case"CondBinary":{let n=await pe(t,e.left),r=await pe(t,e.right),s=e.right.parts.length>0&&e.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped");if(Qr(e.operator))return Xr(e.operator,n,r,!s);if(Zr(e.operator))return Kr(e.operator,$d(t,n),$d(t,r));if(qr(e.operator))return Vr(t,e.operator,n,r);switch(e.operator){case"=~":try{let i=new RegExp(r),o=n.match(i);if(o){t.state.env.BASH_REMATCH=o[0];for(let a=1;a<o.length;a++)t.state.env[`BASH_REMATCH_${a}`]=o[a]||""}return o!==null}catch{throw new Error("syntax error in regular expression")}case"<":return n<r;case">":return n>r;default:return!1}}case"CondUnary":{let n=await pe(t,e.operand);return Hr(e.operator)?Gr(t,e.operator,n):Yr(e.operator)?es(e.operator,n):e.operator==="-v"?ts(t,n):e.operator==="-o"?to(t,n):!1}case"CondNot":return!await St(t,e.operand);case"CondAnd":return await St(t,e.left)?await St(t,e.right):!1;case"CondOr":return await St(t,e.left)?!0:await St(t,e.right);case"CondGroup":return await St(t,e.expression);case"CondWord":return await pe(t,e.word)!=="";default:return!1}}async function hn(t,e){if(e.length===0)return H("","",1);if(e.length===1)return Ne(!!e[0]);if(e.length===2){let r=e[0],s=e[1];return r==="("?q(`test: '(' without matching ')'
751
- `,2):Hr(r)?Ne(await Gr(t,r,s)):Yr(r)?Ne(es(r,s)):r==="!"?Ne(!s):r==="-v"?Ne(ts(t,s)):r==="-o"?Ne(to(t,s)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?q(`test: ${r}: unary operator expected
752
- `,2):H("","",1)}if(e.length===3){let r=e[0],s=e[1],i=e[2];if(Qr(s))return Ne(Xr(s,r,i));if(Zr(s)){let o=ns(r),a=ns(i);return!o.valid||!a.valid?H("","",2):Ne(Kr(s,o.value,a.value))}if(qr(s))return Ne(await Vr(t,s,r,i));switch(s){case"-a":return Ne(r!==""&&i!=="");case"-o":return Ne(r!==""||i!=="");case">":return Ne(r>i);case"<":return Ne(r<i)}if(r==="!"){let o=await hn(t,[s,i]);return H("",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r==="("&&i===")")return Ne(s!=="")}if(e.length===4){if(e[0]==="!"){let r=await hn(t,e.slice(1));return H("",r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(e[0]==="("&&e[3]===")")return hn(t,[e[1],e[2]])}let n=await Pd(t,e,0);return n.pos<e.length?q(`test: too many arguments
753
- `,2):Ne(n.value)}async function Pd(t,e,n){return pw(t,e,n)}async function pw(t,e,n){let{value:r,pos:s}=await vd(t,e,n);for(;e[s]==="-o";){let i=await vd(t,e,s+1);r=r||i.value,s=i.pos}return{value:r,pos:s}}async function vd(t,e,n){let{value:r,pos:s}=await eo(t,e,n);for(;e[s]==="-a";){let i=await eo(t,e,s+1);r=r&&i.value,s=i.pos}return{value:r,pos:s}}async function eo(t,e,n){if(e[n]==="!"){let{value:r,pos:s}=await eo(t,e,n+1);return{value:!r,pos:s}}return hw(t,e,n)}async function hw(t,e,n){let r=e[n];if(r==="("){let{value:i,pos:o}=await Pd(t,e,n+1);return{value:i,pos:e[o]===")"?o+1:o}}if(Hr(r)){let i=e[n+1]??"";return{value:await Gr(t,r,i),pos:n+2}}if(Yr(r)){let i=e[n+1]??"";return{value:es(r,i),pos:n+2}}if(r==="-v"){let i=e[n+1]??"";return{value:ts(t,i),pos:n+2}}if(r==="-o"){let i=e[n+1]??"";return{value:to(t,i),pos:n+2}}let s=e[n+1];if(Qr(s)){let i=r,o=e[n+2]??"";return{value:Xr(s,i,o),pos:n+3}}if(Zr(s)){let i=ns(r),o=ns(e[n+2]??"0");return!i.valid||!o.valid?{value:!1,pos:n+3}:{value:Kr(s,i.value,o.value),pos:n+3}}if(qr(s)){let i=r,o=e[n+2]??"";return{value:await Vr(t,s,i,o),pos:n+3}}return{value:r!==void 0&&r!=="",pos:n+1}}function Jr(t,e){let n="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r++}else n+="\\\\";else if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=e.indexOf("]",r+1);i!==-1?(n+=e.slice(r,i+1),r=i):n+="\\["}else/[\\^$.|+(){}]/.test(s)?n+=`\\${s}`:n+=s}return n+="$",new RegExp(n).test(t)}function to(t,e){let r={errexit:()=>t.state.options.errexit===!0,nounset:()=>t.state.options.nounset===!0,pipefail:()=>t.state.options.pipefail===!0,xtrace:()=>t.state.options.xtrace===!0,e:()=>t.state.options.errexit===!0,u:()=>t.state.options.nounset===!0,x:()=>t.state.options.xtrace===!0}[e];return r?r():!1}function $d(t,e){if(e=e.trim(),e==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(e))return Rd(e);try{let n=new Pe,r=ve(n,e);return re(t,r.expression)}catch{return Rd(e)}}function mw(t,e){let n=0;for(let r of t){let s;if(r>="0"&&r<="9")s=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")s=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")s=r.charCodeAt(0)-65+36;else if(r==="@")s=62;else if(r==="_")s=63;else return Number.NaN;if(s>=e)return Number.NaN;n=n*e+s}return n}function Rd(t){if(t=t.trim(),t==="")return 0;let e=!1;t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1));let n,r=t.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let s=Number.parseInt(r[1],10);s>=2&&s<=64?n=mw(r[2],s):n=0}else/^0[xX][0-9a-fA-F]+$/.test(t)?n=Number.parseInt(t,16):/^0[0-7]+$/.test(t)?n=Number.parseInt(t,8):n=Number.parseInt(t,10);return Number.isNaN(n)&&(n=0),e?-n:n}function ns(t){if(t=t.trim(),t==="")return{value:0,valid:!0};let e=!1;if(t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1)),!/^\d+$/.test(t))return{value:0,valid:!1};let n=Number.parseInt(t,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:e?-n:n,valid:!0}}fe();async function no(t,e){let n=t.state.inCondition;t.state.inCondition=!0;let r="",s="",i=0;try{for(let o of e){let a=await t.executeStatement(o);r+=a.stdout,s+=a.stderr,i=a.exitCode}}finally{t.state.inCondition=n}return{stdout:r,stderr:s,exitCode:i}}fe();rt();function zn(t,e,n,r){if(t instanceof Fe)return e+=t.stdout,n+=t.stderr,t.levels>1&&r>1?(t.levels--,t.stdout=e,t.stderr=n,{action:"rethrow",stdout:e,stderr:n,error:t}):{action:"break",stdout:e,stderr:n};if(t instanceof Be)return e+=t.stdout,n+=t.stderr,t.levels>1&&r>1?(t.levels--,t.stdout=e,t.stderr=n,{action:"rethrow",stdout:e,stderr:n,error:t}):{action:"continue",stdout:e,stderr:n};if(t instanceof Te||t instanceof it||t instanceof ue||t instanceof V)return t.prependOutput(e,n),{action:"rethrow",stdout:e,stderr:n,error:t};let s=ye(t);return{action:"error",stdout:e,stderr:`${n}${s}
754
- `,exitCode:1}}fe();rt();async function rs(t,e,n="",r=""){let s=n,i=r,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(ir(a)||a instanceof it||a instanceof ue||a instanceof V||a instanceof ot)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${ye(a)}
755
- `,exitCode:1}}return{stdout:s,stderr:i,exitCode:o}}async function Fd(t,e){let n="",r="";for(let s of e.clauses){let i=await no(t,s.condition);if(n+=i.stdout,r+=i.stderr,i.exitCode===0)return rs(t,s.body,n,r)}return e.elseBody?rs(t,e.elseBody,n,r):H(n,r,0)}async function Td(t,e){let n="",r="",s=0,i=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.variable))return q(`bash: \`${e.variable}': not a valid identifier
756
- `);let o=[];if(e.words===null)o=(t.state.env["@"]||"").split(" ").filter(Boolean);else if(e.words.length===0)o=[];else for(let a of e.words){let l=await jn(t,a);o.push(...l.values)}t.state.loopDepth++;try{for(let a of o){i++,i>t.limits.maxLoopIterations&&mt(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r),t.state.env[e.variable]=a;try{for(let l of e.body){let c=await t.executeStatement(l);n+=c.stdout,r+=c.stderr,s=c.exitCode}}catch(l){let c=zn(l,n,r,t.state.loopDepth);if(n=c.stdout,r=c.stderr,c.action==="break")break;if(c.action==="continue")continue;if(c.action==="error")return H(n,r,c.exitCode??1);throw c.error}}}finally{t.state.loopDepth--}return H(n,r,s)}async function Od(t,e){let n="",r="",s=0,i=0;e.init&&await se(t,e.init.expression),t.state.loopDepth++;try{for(;i++,i>t.limits.maxLoopIterations&&mt(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r),!(e.condition&&await se(t,e.condition.expression)===0);){try{for(let o of e.body){let a=await t.executeStatement(o);n+=a.stdout,r+=a.stderr,s=a.exitCode}}catch(o){let a=zn(o,n,r,t.state.loopDepth);if(n=a.stdout,r=a.stderr,a.action==="break")break;if(a.action==="continue"){e.update&&await se(t,e.update.expression);continue}if(a.action==="error")return H(n,r,a.exitCode??1);throw a.error}e.update&&await se(t,e.update.expression)}}finally{t.state.loopDepth--}return H(n,r,s)}async function Dd(t,e,n=""){let r="",s="",i=0,o=0,a=n;for(let c of e.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await pe(t,u.content);u.stripTabs&&(f=f.split(`
754
+ `,s=1;continue}let p=u[d][0];delete t.state.env[`${a}_${p}`];continue}delete t.state.env[`${a}_${c}`];continue}delete t.state.env[i],t.state.functions.delete(i)}return H("",r,s)}function to(t,e){return t.fs.resolvePath(t.state.cwd,e)}var yw=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function Gr(t){return yw.includes(t)}async function qr(t,e,n){let r=to(t,n);switch(e){case"-e":case"-a":return t.fs.exists(r);case"-f":return await t.fs.exists(r)?(await t.fs.stat(r)).isFile:!1;case"-d":return await t.fs.exists(r)?(await t.fs.stat(r)).isDirectory:!1;case"-r":case"-w":case"-x":return t.fs.exists(r);case"-s":return await t.fs.exists(r)?(await t.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await t.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&512)!==0:!1;case"-g":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return t.fs.exists(r);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>r===i||r.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return t.fs.exists(r);default:return!1}}var xw=["-nt","-ot","-ef"];function Vr(t){return xw.includes(t)}async function Zr(t,e,n,r){let s=to(t,n),i=to(t,r);switch(e){case"-nt":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await t.fs.exists(s)||!await t.fs.exists(i))return!1;let o=t.fs.resolvePath(t.state.cwd,s),a=t.fs.resolvePath(t.state.cwd,i);return o===a}catch{return!1}default:return!1}}var ww=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function Kr(t){return ww.has(t)}function Qr(t,e,n){switch(t){case"-eq":return e===n;case"-ne":return e!==n;case"-lt":return e<n;case"-le":return e<=n;case"-gt":return e>n;case"-ge":return e>=n}}function Xr(t){return t==="="||t==="=="||t==="!="}function Jr(t,e,n,r=!1){let s=r?Yr(e,n):e===n;return t==="!="?!s:s}var bw=new Set(["-z","-n"]);function es(t){return bw.has(t)}function ts(t,e){switch(t){case"-z":return e==="";case"-n":return e!==""}}function ns(t,e){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let r=n[1],s=n[2];s=s.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(o,a)=>t.state.env[a]||"");let i;if(/^-?\d+$/.test(s))i=Number.parseInt(s,10);else try{let o=Function(`"use strict"; return (${s})`)();i=typeof o=="number"?Math.floor(o):0}catch{let o=t.state.env[s];i=o?Number.parseInt(o,10):0}if(i<0){let o=Un(t,r);if(o.length===0||(i=Math.max(...o)+1+i,i<0))return!1}return`${r}_${i}`in t.state.env}return e in t.state.env}async function Ct(t,e){switch(e.type){case"CondBinary":{let n=await he(t,e.left),r=await he(t,e.right),s=e.right.parts.length>0&&e.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped");if(Xr(e.operator))return Jr(e.operator,n,r,!s);if(Kr(e.operator))return Qr(e.operator,Td(t,n),Td(t,r));if(Vr(e.operator))return Zr(t,e.operator,n,r);switch(e.operator){case"=~":try{let i=new RegExp(r),o=n.match(i);if(o){t.state.env.BASH_REMATCH=o[0];for(let a=1;a<o.length;a++)t.state.env[`BASH_REMATCH_${a}`]=o[a]||""}return o!==null}catch{throw new Error("syntax error in regular expression")}case"<":return n<r;case">":return n>r;default:return!1}}case"CondUnary":{let n=await he(t,e.operand);return Gr(e.operator)?qr(t,e.operator,n):es(e.operator)?ts(e.operator,n):e.operator==="-v"?ns(t,n):e.operator==="-o"?ro(t,n):!1}case"CondNot":return!await Ct(t,e.operand);case"CondAnd":return await Ct(t,e.left)?await Ct(t,e.right):!1;case"CondOr":return await Ct(t,e.left)?!0:await Ct(t,e.right);case"CondGroup":return await Ct(t,e.expression);case"CondWord":return await he(t,e.word)!=="";default:return!1}}async function mn(t,e){if(e.length===0)return H("","",1);if(e.length===1)return Ne(!!e[0]);if(e.length===2){let r=e[0],s=e[1];return r==="("?V(`test: '(' without matching ')'
755
+ `,2):Gr(r)?Ne(await qr(t,r,s)):es(r)?Ne(ts(r,s)):r==="!"?Ne(!s):r==="-v"?Ne(ns(t,s)):r==="-o"?Ne(ro(t,s)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?V(`test: ${r}: unary operator expected
756
+ `,2):H("","",1)}if(e.length===3){let r=e[0],s=e[1],i=e[2];if(Xr(s))return Ne(Jr(s,r,i));if(Kr(s)){let o=rs(r),a=rs(i);return!o.valid||!a.valid?H("","",2):Ne(Qr(s,o.value,a.value))}if(Vr(s))return Ne(await Zr(t,s,r,i));switch(s){case"-a":return Ne(r!==""&&i!=="");case"-o":return Ne(r!==""||i!=="");case">":return Ne(r>i);case"<":return Ne(r<i)}if(r==="!"){let o=await mn(t,[s,i]);return H("",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r==="("&&i===")")return Ne(s!=="")}if(e.length===4){if(e[0]==="!"){let r=await mn(t,e.slice(1));return H("",r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(e[0]==="("&&e[3]===")")return mn(t,[e[1],e[2]])}let n=await Dd(t,e,0);return n.pos<e.length?V(`test: too many arguments
757
+ `,2):Ne(n.value)}async function Dd(t,e,n){return Ew(t,e,n)}async function Ew(t,e,n){let{value:r,pos:s}=await Pd(t,e,n);for(;e[s]==="-o";){let i=await Pd(t,e,s+1);r=r||i.value,s=i.pos}return{value:r,pos:s}}async function Pd(t,e,n){let{value:r,pos:s}=await no(t,e,n);for(;e[s]==="-a";){let i=await no(t,e,s+1);r=r&&i.value,s=i.pos}return{value:r,pos:s}}async function no(t,e,n){if(e[n]==="!"){let{value:r,pos:s}=await no(t,e,n+1);return{value:!r,pos:s}}return Sw(t,e,n)}async function Sw(t,e,n){let r=e[n];if(r==="("){let{value:i,pos:o}=await Dd(t,e,n+1);return{value:i,pos:e[o]===")"?o+1:o}}if(Gr(r)){let i=e[n+1]??"";return{value:await qr(t,r,i),pos:n+2}}if(es(r)){let i=e[n+1]??"";return{value:ts(r,i),pos:n+2}}if(r==="-v"){let i=e[n+1]??"";return{value:ns(t,i),pos:n+2}}if(r==="-o"){let i=e[n+1]??"";return{value:ro(t,i),pos:n+2}}let s=e[n+1];if(Xr(s)){let i=r,o=e[n+2]??"";return{value:Jr(s,i,o),pos:n+3}}if(Kr(s)){let i=rs(r),o=rs(e[n+2]??"0");return!i.valid||!o.valid?{value:!1,pos:n+3}:{value:Qr(s,i.value,o.value),pos:n+3}}if(Vr(s)){let i=r,o=e[n+2]??"";return{value:await Zr(t,s,i,o),pos:n+3}}return{value:r!==void 0&&r!=="",pos:n+1}}function Yr(t,e){let n="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r++}else n+="\\\\";else if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=e.indexOf("]",r+1);i!==-1?(n+=e.slice(r,i+1),r=i):n+="\\["}else/[\\^$.|+(){}]/.test(s)?n+=`\\${s}`:n+=s}return n+="$",new RegExp(n).test(t)}function ro(t,e){let r={errexit:()=>t.state.options.errexit===!0,nounset:()=>t.state.options.nounset===!0,pipefail:()=>t.state.options.pipefail===!0,xtrace:()=>t.state.options.xtrace===!0,e:()=>t.state.options.errexit===!0,u:()=>t.state.options.nounset===!0,x:()=>t.state.options.xtrace===!0}[e];return r?r():!1}function Td(t,e){if(e=e.trim(),e==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(e))return Od(e);try{let n=new Fe,r=ve(n,e);return re(t,r.expression)}catch{return Od(e)}}function Cw(t,e){let n=0;for(let r of t){let s;if(r>="0"&&r<="9")s=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")s=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")s=r.charCodeAt(0)-65+36;else if(r==="@")s=62;else if(r==="_")s=63;else return Number.NaN;if(s>=e)return Number.NaN;n=n*e+s}return n}function Od(t){if(t=t.trim(),t==="")return 0;let e=!1;t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1));let n,r=t.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let s=Number.parseInt(r[1],10);s>=2&&s<=64?n=Cw(r[2],s):n=0}else/^0[xX][0-9a-fA-F]+$/.test(t)?n=Number.parseInt(t,16):/^0[0-7]+$/.test(t)?n=Number.parseInt(t,8):n=Number.parseInt(t,10);return Number.isNaN(n)&&(n=0),e?-n:n}function rs(t){if(t=t.trim(),t==="")return{value:0,valid:!0};let e=!1;if(t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1)),!/^\d+$/.test(t))return{value:0,valid:!1};let n=Number.parseInt(t,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:e?-n:n,valid:!0}}de();async function so(t,e){let n=t.state.inCondition;t.state.inCondition=!0;let r="",s="",i=0;try{for(let o of e){let a=await t.executeStatement(o);r+=a.stdout,s+=a.stderr,i=a.exitCode}}finally{t.state.inCondition=n}return{stdout:r,stderr:s,exitCode:i}}de();rt();function Gn(t,e,n,r){if(t instanceof Pe)return e+=t.stdout,n+=t.stderr,t.levels>1&&r>1?(t.levels--,t.stdout=e,t.stderr=n,{action:"rethrow",stdout:e,stderr:n,error:t}):{action:"break",stdout:e,stderr:n};if(t instanceof Be)return e+=t.stdout,n+=t.stderr,t.levels>1&&r>1?(t.levels--,t.stdout=e,t.stderr=n,{action:"rethrow",stdout:e,stderr:n,error:t}):{action:"continue",stdout:e,stderr:n};if(t instanceof Te||t instanceof ot||t instanceof fe||t instanceof Z)return t.prependOutput(e,n),{action:"rethrow",stdout:e,stderr:n,error:t};let s=ye(t);return{action:"error",stdout:e,stderr:`${n}${s}
758
+ `,exitCode:1}}de();rt();async function ss(t,e,n="",r=""){let s=n,i=r,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(or(a)||a instanceof ot||a instanceof fe||a instanceof Z||a instanceof at)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${ye(a)}
759
+ `,exitCode:1}}return{stdout:s,stderr:i,exitCode:o}}async function Ld(t,e){let n="",r="";for(let s of e.clauses){let i=await so(t,s.condition);if(n+=i.stdout,r+=i.stderr,i.exitCode===0)return ss(t,s.body,n,r)}return e.elseBody?ss(t,e.elseBody,n,r):H(n,r,0)}async function Md(t,e){let n="",r="",s=0,i=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.variable))return V(`bash: \`${e.variable}': not a valid identifier
760
+ `);let o=[];if(e.words===null)o=(t.state.env["@"]||"").split(" ").filter(Boolean);else if(e.words.length===0)o=[];else for(let a of e.words){let l=await Hn(t,a);o.push(...l.values)}t.state.loopDepth++;try{for(let a of o){i++,i>t.limits.maxLoopIterations&&gt(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r),t.state.env[e.variable]=a;try{for(let l of e.body){let c=await t.executeStatement(l);n+=c.stdout,r+=c.stderr,s=c.exitCode}}catch(l){let c=Gn(l,n,r,t.state.loopDepth);if(n=c.stdout,r=c.stderr,c.action==="break")break;if(c.action==="continue")continue;if(c.action==="error")return H(n,r,c.exitCode??1);throw c.error}}}finally{t.state.loopDepth--}return H(n,r,s)}async function _d(t,e){let n="",r="",s=0,i=0;e.init&&await se(t,e.init.expression),t.state.loopDepth++;try{for(;i++,i>t.limits.maxLoopIterations&&gt(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r),!(e.condition&&await se(t,e.condition.expression)===0);){try{for(let o of e.body){let a=await t.executeStatement(o);n+=a.stdout,r+=a.stderr,s=a.exitCode}}catch(o){let a=Gn(o,n,r,t.state.loopDepth);if(n=a.stdout,r=a.stderr,a.action==="break")break;if(a.action==="continue"){e.update&&await se(t,e.update.expression);continue}if(a.action==="error")return H(n,r,a.exitCode??1);throw a.error}e.update&&await se(t,e.update.expression)}}finally{t.state.loopDepth--}return H(n,r,s)}async function Bd(t,e,n=""){let r="",s="",i=0,o=0,a=n;for(let c of e.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await he(t,u.content);u.stripTabs&&(f=f.split(`
757
761
  `).map(d=>d.replace(/^\t+/,"")).join(`
758
- `)),a=f}else if(c.operator==="<<<"&&c.target.type==="Word")a=`${await pe(t,c.target)}
759
- `;else if(c.operator==="<"&&c.target.type==="Word")try{let u=await pe(t,c.target),f=t.fs.resolvePath(t.state.cwd,u);a=await t.fs.readFile(f)}catch{let u=await pe(t,c.target);return q(`bash: ${u}: No such file or directory
760
- `)}let l=t.state.groupStdin;a&&(t.state.groupStdin=a),t.state.loopDepth++;try{for(;;){o++,o>t.limits.maxLoopIterations&&mt(`while loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,s);let c=0,u=!1,f=!1,d=t.state.inCondition;t.state.inCondition=!0;try{for(let p of e.condition){let h=await t.executeStatement(p);r+=h.stdout,s+=h.stderr,c=h.exitCode}}catch(p){if(p instanceof Fe){if(r+=p.stdout,s+=p.stderr,p.levels>1&&t.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=s,t.state.inCondition=d,p;u=!0}else if(p instanceof Be){if(r+=p.stdout,s+=p.stderr,p.levels>1&&t.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=s,t.state.inCondition=d,p;f=!0}else throw t.state.inCondition=d,p}finally{t.state.inCondition=d}if(u)break;if(!f){if(c!==0)break;try{for(let p of e.body){let h=await t.executeStatement(p);r+=h.stdout,s+=h.stderr,i=h.exitCode}}catch(p){let h=zn(p,r,s,t.state.loopDepth);if(r=h.stdout,s=h.stderr,h.action==="break")break;if(h.action==="continue")continue;if(h.action==="error")return H(r,s,h.exitCode??1);throw h.error}}}}finally{t.state.loopDepth--,t.state.groupStdin=l}return H(r,s,i)}async function Ld(t,e){let n="",r="",s=0,i=0;t.state.loopDepth++;try{for(;;){i++,i>t.limits.maxLoopIterations&&mt(`until loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r);let o=await no(t,e.condition);if(n+=o.stdout,r+=o.stderr,o.exitCode===0)break;try{for(let a of e.body){let l=await t.executeStatement(a);n+=l.stdout,r+=l.stderr,s=l.exitCode}}catch(a){let l=zn(a,n,r,t.state.loopDepth);if(n=l.stdout,r=l.stderr,l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return H(n,r,l.exitCode??1);throw l.error}}}finally{t.state.loopDepth--}return H(n,r,s)}async function Md(t,e){let n="",r="",s=0,i=await pe(t,e.word),o=!1;for(let a=0;a<e.items.length;a++){let l=e.items[a],c=o;if(!o)for(let u of l.patterns){let f=await pe(t,u);if(ud(u)&&(f=fd(f)),Jr(i,f)){c=!0;break}}if(c){let u=await rs(t,l.body,n,r);if(n=u.stdout,r=u.stderr,s=u.exitCode,l.terminator===";;")break;l.terminator===";&"?o=!0:o=!1}else o=!1}return H(n,r,s)}fe();fe();function _d(t,e){return t.state.functions.set(e.name,e),te}async function Bd(t,e,n){t.state.callDepth++,t.state.callDepth>t.limits.maxCallDepth&&(t.state.callDepth--,mt(`${e.name}: maximum recursion depth (${t.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),t.state.localScopes.push(new Map);let r={};for(let i=0;i<n.length;i++)r[String(i+1)]=t.state.env[String(i+1)],t.state.env[String(i+1)]=n[i];r["@"]=t.state.env["@"],r["#"]=t.state.env["#"],t.state.env["@"]=n.join(" "),t.state.env["#"]=String(n.length);let s=()=>{let i=t.state.localScopes.pop();if(i)for(let[o,a]of i)a===void 0?delete t.state.env[o]:t.state.env[o]=a;for(let[o,a]of Object.entries(r))a===void 0?delete t.state.env[o]:t.state.env[o]=a;t.state.callDepth--};try{let i=await t.executeCommand(e.body,"");return s(),i}catch(i){if(s(),i instanceof Te)return H(i.stdout,i.stderr,i.exitCode);throw i}}rt();async function Wd(t,e,n){let{stdout:r,stderr:s,exitCode:i}=e;for(let o of n){if(o.target.type==="HereDoc")continue;let a=await pe(t,o.target);switch(o.operator){case">":{let l=o.fd??1;if(l===1){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
762
+ `)),a=f}else if(c.operator==="<<<"&&c.target.type==="Word")a=`${await he(t,c.target)}
763
+ `;else if(c.operator==="<"&&c.target.type==="Word")try{let u=await he(t,c.target),f=t.fs.resolvePath(t.state.cwd,u);a=await t.fs.readFile(f)}catch{let u=await he(t,c.target);return V(`bash: ${u}: No such file or directory
764
+ `)}let l=t.state.groupStdin;a&&(t.state.groupStdin=a),t.state.loopDepth++;try{for(;;){o++,o>t.limits.maxLoopIterations&&gt(`while loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,s);let c=0,u=!1,f=!1,d=t.state.inCondition;t.state.inCondition=!0;try{for(let p of e.condition){let h=await t.executeStatement(p);r+=h.stdout,s+=h.stderr,c=h.exitCode}}catch(p){if(p instanceof Pe){if(r+=p.stdout,s+=p.stderr,p.levels>1&&t.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=s,t.state.inCondition=d,p;u=!0}else if(p instanceof Be){if(r+=p.stdout,s+=p.stderr,p.levels>1&&t.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=s,t.state.inCondition=d,p;f=!0}else throw t.state.inCondition=d,p}finally{t.state.inCondition=d}if(u)break;if(!f){if(c!==0)break;try{for(let p of e.body){let h=await t.executeStatement(p);r+=h.stdout,s+=h.stderr,i=h.exitCode}}catch(p){let h=Gn(p,r,s,t.state.loopDepth);if(r=h.stdout,s=h.stderr,h.action==="break")break;if(h.action==="continue")continue;if(h.action==="error")return H(r,s,h.exitCode??1);throw h.error}}}}finally{t.state.loopDepth--,t.state.groupStdin=l}return H(r,s,i)}async function Wd(t,e){let n="",r="",s=0,i=0;t.state.loopDepth++;try{for(;;){i++,i>t.limits.maxLoopIterations&&gt(`until loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r);let o=await so(t,e.condition);if(n+=o.stdout,r+=o.stderr,o.exitCode===0)break;try{for(let a of e.body){let l=await t.executeStatement(a);n+=l.stdout,r+=l.stderr,s=l.exitCode}}catch(a){let l=Gn(a,n,r,t.state.loopDepth);if(n=l.stdout,r=l.stderr,l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return H(n,r,l.exitCode??1);throw l.error}}}finally{t.state.loopDepth--}return H(n,r,s)}async function Ud(t,e){let n="",r="",s=0,i=await he(t,e.word),o=!1;for(let a=0;a<e.items.length;a++){let l=e.items[a],c=o;if(!o)for(let u of l.patterns){let f=await he(t,u);if(hd(u)&&(f=md(f)),Yr(i,f)){c=!0;break}}if(c){let u=await ss(t,l.body,n,r);if(n=u.stdout,r=u.stderr,s=u.exitCode,l.terminator===";;")break;l.terminator===";&"?o=!0:o=!1}else o=!1}return H(n,r,s)}de();de();function jd(t,e){return t.state.functions.set(e.name,e),te}async function zd(t,e,n){t.state.callDepth++,t.state.callDepth>t.limits.maxCallDepth&&(t.state.callDepth--,gt(`${e.name}: maximum recursion depth (${t.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),t.state.localScopes.push(new Map);let r={};for(let i=0;i<n.length;i++)r[String(i+1)]=t.state.env[String(i+1)],t.state.env[String(i+1)]=n[i];r["@"]=t.state.env["@"],r["#"]=t.state.env["#"],t.state.env["@"]=n.join(" "),t.state.env["#"]=String(n.length);let s=()=>{let i=t.state.localScopes.pop();if(i)for(let[o,a]of i)a===void 0?delete t.state.env[o]:t.state.env[o]=a;for(let[o,a]of Object.entries(r))a===void 0?delete t.state.env[o]:t.state.env[o]=a;t.state.callDepth--};try{let i=await t.executeCommand(e.body,"");return s(),i}catch(i){if(s(),i instanceof Te)return H(i.stdout,i.stderr,i.exitCode);throw i}}rt();async function Hd(t,e,n){let{stdout:r,stderr:s,exitCode:i}=e;for(let o of n){if(o.target.type==="HereDoc")continue;let a=await he(t,o.target);switch(o.operator){case">":{let l=o.fd??1;if(l===1){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
761
765
  `,i=1,r="";break}}catch{}await t.fs.writeFile(c,r,"binary"),r=""}else if(l===2)if(a==="/dev/null")s="";else{let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
762
766
  `,i=1;break}}catch{}await t.fs.writeFile(c,s,"binary"),s=""}break}case">>":{let l=o.fd??1;if(l===1){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
763
767
  `,i=1,r="";break}}catch{}await t.fs.appendFile(c,r,"binary"),r=""}else if(l===2){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
764
768
  `,i=1;break}}catch{}await t.fs.appendFile(c,s,"binary"),s=""}break}case">&":{let l=o.fd??1;a==="2"||a==="&2"?l===1&&(s+=r,r=""):(a==="1"||a==="&1")&&(r+=s,s="");break}case"&>":{let l=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(l)).isDirectory){s=`bash: ${a}: Is a directory
765
769
  `,i=1,r="";break}}catch{}await t.fs.writeFile(l,r+s,"binary"),r="",s="";break}case"&>>":{let l=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(l)).isDirectory){s=`bash: ${a}: Is a directory
766
- `,i=1,r="";break}}catch{}await t.fs.appendFile(l,r+s,"binary"),r="",s="";break}}}return H(r,s,i)}var Hn=class{ctx;constructor(e,n){this.ctx={state:n,fs:e.fs,commands:e.commands,limits:e.limits,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep,trace:e.trace}}async executeScript(e){let n="",r="",s=0;for(let i of e.statements)try{let o=await this.executeStatement(i);n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}catch(o){if(o instanceof ue)throw o.prependOutput(n,r),o;if(o instanceof V)throw o;if(o instanceof it)return n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Xe)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof ct)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Fe||o instanceof Be){if(this.ctx.state.loopDepth>0)throw o.prependOutput(n,r),o;n+=o.stdout,r+=o.stderr;continue}throw o instanceof Te&&o.prependOutput(n,r),o}return{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}}}async executeStatement(e){this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&mt(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands");let n="",r="",s=0,i=-1,o=!1;for(let a=0;a<e.pipelines.length;a++){let l=e.pipelines[a],c=a>0?e.operators[a-1]:null;if(c==="&&"&&s!==0||c==="||"&&s===0)continue;let u=await this.executePipeline(l);n+=u.stdout,r+=u.stderr,s=u.exitCode,i=a,o=l.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}if(this.ctx.state.options.errexit&&s!==0&&i===e.pipelines.length-1&&!o&&!this.ctx.state.inCondition)throw new it(s,n,r);return H(n,r,s)}async executePipeline(e){let n="",r=te,s=0,i=[];for(let o=0;o<e.commands.length;o++){let a=e.commands[o],l=o===e.commands.length-1,c;try{c=await this.executeCommand(a,n)}catch(u){if(u instanceof ct)c={stdout:u.stdout,stderr:u.stderr,exitCode:1};else if(u instanceof ue&&e.commands.length>1)c={stdout:u.stdout,stderr:u.stderr,exitCode:u.exitCode};else throw u}i.push(c.exitCode),c.exitCode!==0&&(s=c.exitCode),l?r=c:(n=c.stdout,r={stdout:"",stderr:c.stderr,exitCode:c.exitCode})}for(let o of Object.keys(this.ctx.state.env))o.startsWith("PIPESTATUS_")&&delete this.ctx.state.env[o];for(let o=0;o<i.length;o++)this.ctx.state.env[`PIPESTATUS_${o}`]=String(i[o]);return this.ctx.state.env.PIPESTATUS__length=String(i.length),this.ctx.state.options.pipefail&&s!==0&&(r={...r,exitCode:s}),e.negated&&(r={...r,exitCode:r.exitCode===0?1:0}),r}async executeCommand(e,n){switch(e.type){case"SimpleCommand":return this.executeSimpleCommand(e,n);case"If":return Fd(this.ctx,e);case"For":return Td(this.ctx,e);case"CStyleFor":return Od(this.ctx,e);case"While":return Dd(this.ctx,e,n);case"Until":return Ld(this.ctx,e);case"Case":return Md(this.ctx,e);case"Subshell":return this.executeSubshell(e,n);case"Group":return this.executeGroup(e,n);case"FunctionDef":return _d(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return te}}async executeSimpleCommand(e,n){try{return await this.executeSimpleCommandInner(e,n)}catch(r){if(r instanceof ke)return q(r.stderr);throw r}}async executeSimpleCommandInner(e,n){e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.expansionStderr="";let r={};for(let l of e.assignments){let c=l.name;if(l.array){if(/\[.+\]$/.test(c))return H("",`bash: ${c}: cannot assign list to array member
767
- `,1);let m=Et(this.ctx,c);if(m)return m;let g=[];for(let b of l.array){let E=await jn(this.ctx,b);g.push(...E.values)}let w=0;if(l.append){let b=$e(this.ctx,c);b.length>0&&(w=Math.max(...b.map(([S])=>typeof S=="number"?S:0))+1)}else{let b=`${c}_`;for(let E of Object.keys(this.ctx.state.env))E.startsWith(b)&&!E.includes("__")&&delete this.ctx.state.env[E]}for(let b=0;b<g.length;b++)this.ctx.state.env[`${c}_${w+b}`]=g[b];l.append||(this.ctx.state.env[`${c}__length`]=String(g.length));continue}let u=l.value?await pe(this.ctx,l.value):"";if(c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return H("",`bash: ${c}: bad array subscript
768
- `,1);let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let m=d[1],g=d[2],w=Et(this.ctx,m);if(w)return w;let b=this.ctx.state.associativeArrays?.has(m),E;if(b){let R;if(g.startsWith("'")&&g.endsWith("'"))R=g.slice(1,-1);else if(g.startsWith('"')&&g.endsWith('"')){let P=g.slice(1,-1),W=new Pe().parseWordFromString(P,!0,!1);R=await pe(this.ctx,W)}else if(g.includes("$")){let z=new Pe().parseWordFromString(g,!1,!1);R=await pe(this.ctx,z)}else R=g;E=`${m}_${R}`}else{let R;if(/^-?\d+$/.test(g))R=Number.parseInt(g,10);else{try{let P=new Pe,z=ve(P,g);R=re(this.ctx,z.expression)}catch{let P=this.ctx.state.env[g];R=P?Number.parseInt(P,10):0}Number.isNaN(R)&&(R=0)}if(R<0){let P=$e(this.ctx,m);if(P.length===0)return H("",`bash: ${m}[${g}]: bad array subscript
769
- `,1);if(R=Math.max(...P.map(([W])=>typeof W=="number"?W:0))+1+R,R<0)return H("",`bash: ${m}[${g}]: bad array subscript
770
- `,1)}E=`${m}_${R}`}let S=l.append?(this.ctx.state.env[E]||"")+u:u;e.name?(r[E]=this.ctx.state.env[E],this.ctx.state.env[E]=S):this.ctx.state.env[E]=S;continue}let p=Et(this.ctx,c);if(p)return p;let h=l.append?(this.ctx.state.env[c]||"")+u:u;e.name?(r[c]=this.ctx.state.env[c],this.ctx.state.env[c]=h):this.ctx.state.env[c]=h}if(!e.name)return H("","",this.ctx.state.lastExitCode);for(let l of e.redirections){if((l.operator==="<<"||l.operator==="<<-")&&l.target.type==="HereDoc"){let c=l.target,u=await pe(this.ctx,c.content);c.stripTabs&&(u=u.split(`
770
+ `,i=1,r="";break}}catch{}await t.fs.appendFile(l,r+s,"binary"),r="",s="";break}}}return H(r,s,i)}var qn=class{ctx;constructor(e,n){this.ctx={state:n,fs:e.fs,commands:e.commands,limits:e.limits,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep,trace:e.trace}}async executeScript(e){let n="",r="",s=0;for(let i of e.statements)try{let o=await this.executeStatement(i);n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}catch(o){if(o instanceof fe)throw o.prependOutput(n,r),o;if(o instanceof Z)throw o;if(o instanceof ot)return n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Xe)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof ut)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Pe||o instanceof Be){if(this.ctx.state.loopDepth>0)throw o.prependOutput(n,r),o;n+=o.stdout,r+=o.stderr;continue}throw o instanceof Te&&o.prependOutput(n,r),o}return{stdout:n,stderr:r,exitCode:s,env:{...this.ctx.state.env}}}async executeStatement(e){this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&gt(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands");let n="",r="",s=0,i=-1,o=!1;for(let a=0;a<e.pipelines.length;a++){let l=e.pipelines[a],c=a>0?e.operators[a-1]:null;if(c==="&&"&&s!==0||c==="||"&&s===0)continue;let u=await this.executePipeline(l);n+=u.stdout,r+=u.stderr,s=u.exitCode,i=a,o=l.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}if(this.ctx.state.options.errexit&&s!==0&&i===e.pipelines.length-1&&!o&&!this.ctx.state.inCondition)throw new ot(s,n,r);return H(n,r,s)}async executePipeline(e){let n="",r=te,s=0,i=[];for(let o=0;o<e.commands.length;o++){let a=e.commands[o],l=o===e.commands.length-1,c;try{c=await this.executeCommand(a,n)}catch(u){if(u instanceof ut)c={stdout:u.stdout,stderr:u.stderr,exitCode:1};else if(u instanceof fe&&e.commands.length>1)c={stdout:u.stdout,stderr:u.stderr,exitCode:u.exitCode};else throw u}i.push(c.exitCode),c.exitCode!==0&&(s=c.exitCode),l?r=c:(n=c.stdout,r={stdout:"",stderr:c.stderr,exitCode:c.exitCode})}for(let o of Object.keys(this.ctx.state.env))o.startsWith("PIPESTATUS_")&&delete this.ctx.state.env[o];for(let o=0;o<i.length;o++)this.ctx.state.env[`PIPESTATUS_${o}`]=String(i[o]);return this.ctx.state.env.PIPESTATUS__length=String(i.length),this.ctx.state.options.pipefail&&s!==0&&(r={...r,exitCode:s}),e.negated&&(r={...r,exitCode:r.exitCode===0?1:0}),r}async executeCommand(e,n){switch(e.type){case"SimpleCommand":return this.executeSimpleCommand(e,n);case"If":return Ld(this.ctx,e);case"For":return Md(this.ctx,e);case"CStyleFor":return _d(this.ctx,e);case"While":return Bd(this.ctx,e,n);case"Until":return Wd(this.ctx,e);case"Case":return Ud(this.ctx,e);case"Subshell":return this.executeSubshell(e,n);case"Group":return this.executeGroup(e,n);case"FunctionDef":return jd(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return te}}async executeSimpleCommand(e,n){try{return await this.executeSimpleCommandInner(e,n)}catch(r){if(r instanceof ke)return V(r.stderr);throw r}}async executeSimpleCommandInner(e,n){e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.expansionStderr="";let r={};for(let l of e.assignments){let c=l.name;if(l.array){if(/\[.+\]$/.test(c))return H("",`bash: ${c}: cannot assign list to array member
771
+ `,1);let m=St(this.ctx,c);if(m)return m;let g=[];for(let w of l.array){let E=await Hn(this.ctx,w);g.push(...E.values)}let b=0;if(l.append){let w=$e(this.ctx,c);w.length>0&&(b=Math.max(...w.map(([S])=>typeof S=="number"?S:0))+1)}else{let w=`${c}_`;for(let E of Object.keys(this.ctx.state.env))E.startsWith(w)&&!E.includes("__")&&delete this.ctx.state.env[E]}for(let w=0;w<g.length;w++)this.ctx.state.env[`${c}_${b+w}`]=g[w];l.append||(this.ctx.state.env[`${c}__length`]=String(g.length));continue}let u=l.value?await he(this.ctx,l.value):"";if(c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return H("",`bash: ${c}: bad array subscript
772
+ `,1);let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let m=d[1],g=d[2],b=St(this.ctx,m);if(b)return b;let w=this.ctx.state.associativeArrays?.has(m),E;if(w){let R;if(g.startsWith("'")&&g.endsWith("'"))R=g.slice(1,-1);else if(g.startsWith('"')&&g.endsWith('"')){let F=g.slice(1,-1),W=new Fe().parseWordFromString(F,!0,!1);R=await he(this.ctx,W)}else if(g.includes("$")){let z=new Fe().parseWordFromString(g,!1,!1);R=await he(this.ctx,z)}else R=g;E=`${m}_${R}`}else{let R;if(/^-?\d+$/.test(g))R=Number.parseInt(g,10);else{try{let F=new Fe,z=ve(F,g);R=re(this.ctx,z.expression)}catch{let F=this.ctx.state.env[g];R=F?Number.parseInt(F,10):0}Number.isNaN(R)&&(R=0)}if(R<0){let F=$e(this.ctx,m);if(F.length===0)return H("",`bash: ${m}[${g}]: bad array subscript
773
+ `,1);if(R=Math.max(...F.map(([W])=>typeof W=="number"?W:0))+1+R,R<0)return H("",`bash: ${m}[${g}]: bad array subscript
774
+ `,1)}E=`${m}_${R}`}let S=l.append?(this.ctx.state.env[E]||"")+u:u;e.name?(r[E]=this.ctx.state.env[E],this.ctx.state.env[E]=S):this.ctx.state.env[E]=S;continue}let p=St(this.ctx,c);if(p)return p;let h=l.append?(this.ctx.state.env[c]||"")+u:u;e.name?(r[c]=this.ctx.state.env[c],this.ctx.state.env[c]=h):this.ctx.state.env[c]=h}if(!e.name)return H("","",this.ctx.state.lastExitCode);for(let l of e.redirections){if((l.operator==="<<"||l.operator==="<<-")&&l.target.type==="HereDoc"){let c=l.target,u=await he(this.ctx,c.content);c.stripTabs&&(u=u.split(`
771
775
  `).map(f=>f.replace(/^\t+/,"")).join(`
772
- `)),n=u;continue}if(l.operator==="<<<"&&l.target.type==="Word"){n=`${await pe(this.ctx,l.target)}
773
- `;continue}if(l.operator==="<"&&l.target.type==="Word")try{let c=await pe(this.ctx,l.target),u=this.ctx.fs.resolvePath(this.ctx.state.cwd,c);n=await this.ctx.fs.readFile(u)}catch{let c=await pe(this.ctx,l.target);for(let[u,f]of Object.entries(r))f===void 0?delete this.ctx.state.env[u]:this.ctx.state.env[u]=f;return q(`bash: ${c}: No such file or directory
774
- `)}}let s=await pe(this.ctx,e.name),i=[],o=[];for(let l of e.args){let c=await jn(this.ctx,l);for(let u of c.values)i.push(u),o.push(c.quoted)}if(!s){if(e.name.parts.every(c=>c.type==="CommandSubstitution"||c.type==="ParameterExpansion"||c.type==="ArithmeticExpansion")){if(i.length>0){let c=i.shift();return o.shift(),await this.runCommand(c,i,o,n)}return H("","",this.ctx.state.lastExitCode)}return q(`bash: : command not found
775
- `,127)}let a=await this.runCommand(s,i,o,n);a=await Wd(this.ctx,a,e.redirections),this.ctx.state.lastArg=i.length>0?i[i.length-1]:s;for(let[l,c]of Object.entries(r))c===void 0?delete this.ctx.state.env[l]:this.ctx.state.env[l]=c;return this.ctx.state.expansionStderr&&(a={...a,stderr:this.ctx.state.expansionStderr+a.stderr},this.ctx.state.expansionStderr=""),a}async runCommand(e,n,r,s,i=!1){if(e==="cd")return await Di(this.ctx,n);if(e==="export")return ji(this.ctx,n);if(e==="unset")return Ji(this.ctx,n);if(e==="exit")return Ui(this.ctx,n);if(e==="local")return Hi(this.ctx,n);if(e==="set")return Ki(this.ctx,n);if(e==="break")return Oi(this.ctx,n);if(e==="continue")return Li(this.ctx,n);if(e==="return")return Vi(this.ctx,n);if(e==="eval")return Wi(this.ctx,n);if(e==="shift")return Qi(this.ctx,n);if(e==="source"||e===".")return Xi(this.ctx,n);if(e==="read")return qi(this.ctx,n,s);if(e==="mapfile"||e==="readarray")return Gi(this.ctx,n,s);if(e==="declare"||e==="typeset")return _i(this.ctx,n);if(e==="readonly")return Bi(this.ctx,n);if(!i){let u=this.ctx.state.functions.get(e);if(u)return Bd(this.ctx,u,n)}if(e===":"||e==="true")return te;if(e==="false")return Ne(!1);if(e==="let")return zi(this.ctx,n);if(e==="command"){if(n.length===0)return te;let u=n;for(;u.length>0&&u[0].startsWith("-");)u=u.slice(1);if(u.length===0)return te;let[f,...d]=u;return this.runCommand(f,d,[],s,!0)}if(e==="builtin"){if(n.length===0)return te;let[u,...f]=n;return this.runCommand(u,f,[],s)}if(e==="shopt")return te;if(e==="exec"){if(n.length===0)return te;let[u,...f]=n;return this.runCommand(u,f,[],s)}if(e==="wait")return te;if(e==="type")return this.handleType(n);if(e==="[["){let u=n.lastIndexOf("]]");if(u!==-1){let f=n.slice(0,u);return hn(this.ctx,f)}return q("bash: [[: missing `]]'\n",2)}if(e==="["||e==="test"){let u=n;if(e==="["){if(n[n.length-1]!=="]")return q("[: missing `]'\n",2);u=n.slice(0,-1)}return hn(this.ctx,u)}let o=await this.resolveCommand(e);if(!o)return $f(e)?q(`bash: ${e}: command not available in browser environments. Exclude '${e}' from your commands or use the Node.js bundle.
776
- `,127):q(`bash: ${e}: command not found
777
- `,127);let{cmd:a,path:l}=o,c={fs:this.ctx.fs,cwd:this.ctx.state.cwd,env:this.ctx.state.env,stdin:s,limits:this.ctx.limits,exec:this.ctx.execFn,fetch:this.ctx.fetch,getRegisteredCommands:()=>Array.from(this.ctx.commands.keys()),sleep:this.ctx.sleep,trace:this.ctx.trace};try{return await a.execute(n,c)}catch(u){return q(`${e}: ${ye(u)}
776
+ `)),n=u;continue}if(l.operator==="<<<"&&l.target.type==="Word"){n=`${await he(this.ctx,l.target)}
777
+ `;continue}if(l.operator==="<"&&l.target.type==="Word")try{let c=await he(this.ctx,l.target),u=this.ctx.fs.resolvePath(this.ctx.state.cwd,c);n=await this.ctx.fs.readFile(u)}catch{let c=await he(this.ctx,l.target);for(let[u,f]of Object.entries(r))f===void 0?delete this.ctx.state.env[u]:this.ctx.state.env[u]=f;return V(`bash: ${c}: No such file or directory
778
+ `)}}let s=await he(this.ctx,e.name),i=[],o=[];for(let l of e.args){let c=await Hn(this.ctx,l);for(let u of c.values)i.push(u),o.push(c.quoted)}if(!s){if(e.name.parts.every(c=>c.type==="CommandSubstitution"||c.type==="ParameterExpansion"||c.type==="ArithmeticExpansion")){if(i.length>0){let c=i.shift();return o.shift(),await this.runCommand(c,i,o,n)}return H("","",this.ctx.state.lastExitCode)}return V(`bash: : command not found
779
+ `,127)}let a=await this.runCommand(s,i,o,n);a=await Hd(this.ctx,a,e.redirections),this.ctx.state.lastArg=i.length>0?i[i.length-1]:s;for(let[l,c]of Object.entries(r))c===void 0?delete this.ctx.state.env[l]:this.ctx.state.env[l]=c;return this.ctx.state.expansionStderr&&(a={...a,stderr:this.ctx.state.expansionStderr+a.stderr},this.ctx.state.expansionStderr=""),a}async runCommand(e,n,r,s,i=!1){if(e==="cd")return await Mi(this.ctx,n);if(e==="export")return Hi(this.ctx,n);if(e==="unset")return eo(this.ctx,n);if(e==="exit")return zi(this.ctx,n);if(e==="local")return qi(this.ctx,n);if(e==="set")return Xi(this.ctx,n);if(e==="break")return Li(this.ctx,n);if(e==="continue")return _i(this.ctx,n);if(e==="return")return Ki(this.ctx,n);if(e==="eval")return ji(this.ctx,n);if(e==="shift")return Ji(this.ctx,n);if(e==="source"||e===".")return Yi(this.ctx,n);if(e==="read")return Zi(this.ctx,n,s);if(e==="mapfile"||e==="readarray")return Vi(this.ctx,n,s);if(e==="declare"||e==="typeset")return Wi(this.ctx,n);if(e==="readonly")return Ui(this.ctx,n);if(!i){let u=this.ctx.state.functions.get(e);if(u)return zd(this.ctx,u,n)}if(e===":"||e==="true")return te;if(e==="false")return Ne(!1);if(e==="let")return Gi(this.ctx,n);if(e==="command"){if(n.length===0)return te;let u=n;for(;u.length>0&&u[0].startsWith("-");)u=u.slice(1);if(u.length===0)return te;let[f,...d]=u;return this.runCommand(f,d,[],s,!0)}if(e==="builtin"){if(n.length===0)return te;let[u,...f]=n;return this.runCommand(u,f,[],s)}if(e==="shopt")return te;if(e==="exec"){if(n.length===0)return te;let[u,...f]=n;return this.runCommand(u,f,[],s)}if(e==="wait")return te;if(e==="type")return this.handleType(n);if(e==="[["){let u=n.lastIndexOf("]]");if(u!==-1){let f=n.slice(0,u);return mn(this.ctx,f)}return V("bash: [[: missing `]]'\n",2)}if(e==="["||e==="test"){let u=n;if(e==="["){if(n[n.length-1]!=="]")return V("[: missing `]'\n",2);u=n.slice(0,-1)}return mn(this.ctx,u)}let o=await this.resolveCommand(e);if(!o)return Tf(e)?V(`bash: ${e}: command not available in browser environments. Exclude '${e}' from your commands or use the Node.js bundle.
780
+ `,127):V(`bash: ${e}: command not found
781
+ `,127);let{cmd:a,path:l}=o,c={fs:this.ctx.fs,cwd:this.ctx.state.cwd,env:this.ctx.state.env,stdin:s,limits:this.ctx.limits,exec:this.ctx.execFn,fetch:this.ctx.fetch,getRegisteredCommands:()=>Array.from(this.ctx.commands.keys()),sleep:this.ctx.sleep,trace:this.ctx.trace};try{return await a.execute(n,c)}catch(u){return V(`${e}: ${ye(u)}
778
782
  `)}}async resolveCommand(e){if(e.includes("/")){let i=this.ctx.fs.resolvePath(this.ctx.state.cwd,e);if(!await this.ctx.fs.exists(i))return null;let o=i.split("/").pop()||e,a=this.ctx.commands.get(o);return a?{cmd:a,path:i}:null}let r=(this.ctx.state.env.PATH||"/bin:/usr/bin").split(":");for(let i of r){if(!i)continue;let o=`${i}/${e}`;if(await this.ctx.fs.exists(o)){let a=this.ctx.commands.get(e);if(a)return{cmd:a,path:o}}}if(!await this.ctx.fs.exists("/bin")){let i=this.ctx.commands.get(e);if(i)return{cmd:i,path:`/bin/${e}`}}return null}async findCommandInPath(e){let n=[],s=(this.ctx.state.env.PATH||"/bin:/usr/bin").split(":");for(let i of s){if(!i)continue;let o=`${i}/${e}`;await this.ctx.fs.exists(o)&&n.push(o)}return n}handleType(e){let n=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),r=new Set(["cd","export","unset","exit","local","set","break","continue","return","eval","shift","source",".","read","declare","typeset","readonly",":","true","false","let","command","builtin","shopt","exec","wait","type","[","test"]),s="",i="",o=0;for(let a of e)n.has(a)?s+=`${a} is a shell keyword
779
783
  `:r.has(a)?s+=`${a} is a shell builtin
780
784
  `:this.ctx.state.functions.has(a)?s+=`${a} is a function
781
785
  `:this.ctx.commands.has(a)?s+=`${a} is /bin/${a}
782
786
  `:(i+=`bash: type: ${a}: not found
783
- `,o=1);return H(s,i,o)}async executeSubshell(e,n=""){let r={...this.ctx.state.env},s=this.ctx.state.cwd,i=this.ctx.state.loopDepth,o=this.ctx.state.parentHasLoopContext;this.ctx.state.parentHasLoopContext=i>0,this.ctx.state.loopDepth=0;let a=this.ctx.state.groupStdin;n&&(this.ctx.state.groupStdin=n);let l="",c="",u=0;try{for(let f of e.body){let d=await this.executeStatement(f);l+=d.stdout,c+=d.stderr,u=d.exitCode}}catch(f){if(this.ctx.state.env=r,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,f instanceof V)throw f;if(f instanceof ot)return l+=f.stdout,c+=f.stderr,H(l,c,0);if(f instanceof Fe||f instanceof Be)return l+=f.stdout,c+=f.stderr,H(l,c,0);if(f instanceof ue)return l+=f.stdout,c+=f.stderr,H(l,c,f.exitCode);if(f instanceof Te)return l+=f.stdout,c+=f.stderr,H(l,c,f.exitCode);if(f instanceof it)throw f.stdout=l+f.stdout,f.stderr=c+f.stderr,f;return H(l,`${c}${ye(f)}
784
- `,1)}return this.ctx.state.env=r,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,H(l,c,u)}async executeGroup(e,n=""){let r="",s="",i=0,o=this.ctx.state.groupStdin;n&&(this.ctx.state.groupStdin=n);try{for(let a of e.body){let l=await this.executeStatement(a);r+=l.stdout,s+=l.stderr,i=l.exitCode}}catch(a){if(this.ctx.state.groupStdin=o,a instanceof V)throw a;if(ir(a)||a instanceof it||a instanceof ue)throw a.prependOutput(r,s),a;return H(r,`${s}${ye(a)}
785
- `,1)}return this.ctx.state.groupStdin=o,H(r,s,i)}async executeArithmeticCommand(e){try{let n=await se(this.ctx,e.expression.expression);return Ne(n!==0)}catch(n){return q(`bash: arithmetic expression: ${n.message}
786
- `)}}async executeConditionalCommand(e){try{let n=await St(this.ctx,e.expression);return Ne(n)}catch(n){return q(`bash: conditional expression: ${n.message}
787
- `,2)}}};var Ct={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3};function Ud(t){return t?{maxCallDepth:t.maxCallDepth??Ct.maxCallDepth,maxCommandCount:t.maxCommandCount??Ct.maxCommandCount,maxLoopIterations:t.maxLoopIterations??Ct.maxLoopIterations,maxAwkIterations:t.maxAwkIterations??Ct.maxAwkIterations,maxSedIterations:t.maxSedIterations??Ct.maxSedIterations,maxJqIterations:t.maxJqIterations??Ct.maxJqIterations,maxSqliteTimeoutMs:t.maxSqliteTimeoutMs??Ct.maxSqliteTimeoutMs}:{...Ct}}function jd(t){try{let e=new URL(t);return{origin:e.origin,pathname:e.pathname,href:e.href}}catch{return null}}function gw(t){let e=jd(t);return e?{origin:e.origin,pathPrefix:e.pathname}:null}function yw(t,e){let n=jd(t);if(!n)return!1;let r=gw(e);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function ro(t,e){return!e||e.length===0?!1:e.some(n=>yw(t,n))}var mn=class extends Error{constructor(e){super(`Network access denied: URL not in allow-list: ${e}`),this.name="NetworkAccessDeniedError"}},gn=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name="TooManyRedirectsError"}},yn=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name="RedirectNotAllowedError"}},ss=class extends Error{constructor(e,n){super(`HTTP method '${e}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}};var xw=20,ww=3e4,bw=["GET","HEAD"],Ew=new Set(["GET","HEAD","OPTIONS"]),Sw=new Set([301,302,303,307,308]);function so(t){let e=t.maxRedirects??xw,n=t.timeoutMs??ww,r=t.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:t.allowedMethods??bw;function s(a){if(!t.dangerouslyAllowFullInternetAccess&&!ro(a,t.allowedUrlPrefixes??[]))throw new mn(a)}function i(a){if(t.dangerouslyAllowFullInternetAccess)return;let l=a.toUpperCase();if(!r.includes(l))throw new ss(l,r)}async function o(a,l={}){let c=l.method?.toUpperCase()??"GET";s(a),i(c);let u=a,f=0,d=l.followRedirects??!0,p=l.timeoutMs!==void 0?Math.min(l.timeoutMs,n):n;for(;;){let h=new AbortController,m=setTimeout(()=>h.abort(),p);try{let g={method:c,headers:l.headers,signal:h.signal,redirect:"manual"};l.body&&!Ew.has(c)&&(g.body=l.body);let w=await fetch(u,g);if(Sw.has(w.status)&&d){let b=w.headers.get("location");if(!b)return await zd(w,u);let E=new URL(b,u).href;if(!t.dangerouslyAllowFullInternetAccess&&!ro(E,t.allowedUrlPrefixes??[]))throw new yn(E);if(f++,f>e)throw new gn(e);u=E;continue}return await zd(w,u)}finally{clearTimeout(m)}}}return o}async function zd(t,e){let n={};return t.headers.forEach((r,s)=>{n[s.toLowerCase()]=r}),{status:t.status,statusText:t.statusText,headers:n,body:await t.text(),url:e}}var io=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;state;constructor(e={}){let n=e.fs??new _t(e.files);this.fs=n,this.useDefaultLayout=!e.cwd&&!e.files;let r=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s={HOME:this.useDefaultLayout?"/home/user":"/",PATH:"/bin:/usr/bin",IFS:`
788
- `,OSTYPE:"linux-gnu",MACHTYPE:"x86_64-pc-linux-gnu",HOSTTYPE:"x86_64",PWD:r,OLDPWD:r,...e.env};if(this.limits=Ud({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.network&&(this.secureFetch=so(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1},inCondition:!1,loopDepth:0},vf(n,this.useDefaultLayout),r!=="/"&&n instanceof _t)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let i of bf(e.commands))this.registerCommand(i);if(e.network)for(let i of Ef())this.registerCommand(i);if(e.customCommands)for(let i of e.customCommands)Sf(i)?this.registerCommand(Cf(i)):this.registerCommand(i)}registerCommand(e){this.commands.set(e.name,e);let n=this.fs;if(typeof n.writeFileSync=="function")try{n.writeFileSync(`/bin/${e.name}`,`#!/bin/bash
787
+ `,o=1);return H(s,i,o)}async executeSubshell(e,n=""){let r={...this.ctx.state.env},s=this.ctx.state.cwd,i=this.ctx.state.loopDepth,o=this.ctx.state.parentHasLoopContext;this.ctx.state.parentHasLoopContext=i>0,this.ctx.state.loopDepth=0;let a=this.ctx.state.groupStdin;n&&(this.ctx.state.groupStdin=n);let l="",c="",u=0;try{for(let f of e.body){let d=await this.executeStatement(f);l+=d.stdout,c+=d.stderr,u=d.exitCode}}catch(f){if(this.ctx.state.env=r,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,f instanceof Z)throw f;if(f instanceof at)return l+=f.stdout,c+=f.stderr,H(l,c,0);if(f instanceof Pe||f instanceof Be)return l+=f.stdout,c+=f.stderr,H(l,c,0);if(f instanceof fe)return l+=f.stdout,c+=f.stderr,H(l,c,f.exitCode);if(f instanceof Te)return l+=f.stdout,c+=f.stderr,H(l,c,f.exitCode);if(f instanceof ot)throw f.stdout=l+f.stdout,f.stderr=c+f.stderr,f;return H(l,`${c}${ye(f)}
788
+ `,1)}return this.ctx.state.env=r,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,H(l,c,u)}async executeGroup(e,n=""){let r="",s="",i=0,o=this.ctx.state.groupStdin;n&&(this.ctx.state.groupStdin=n);try{for(let a of e.body){let l=await this.executeStatement(a);r+=l.stdout,s+=l.stderr,i=l.exitCode}}catch(a){if(this.ctx.state.groupStdin=o,a instanceof Z)throw a;if(or(a)||a instanceof ot||a instanceof fe)throw a.prependOutput(r,s),a;return H(r,`${s}${ye(a)}
789
+ `,1)}return this.ctx.state.groupStdin=o,H(r,s,i)}async executeArithmeticCommand(e){try{let n=await se(this.ctx,e.expression.expression);return Ne(n!==0)}catch(n){return V(`bash: arithmetic expression: ${n.message}
790
+ `)}}async executeConditionalCommand(e){try{let n=await Ct(this.ctx,e.expression);return Ne(n)}catch(n){return V(`bash: conditional expression: ${n.message}
791
+ `,2)}}};var At={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3};function Gd(t){return t?{maxCallDepth:t.maxCallDepth??At.maxCallDepth,maxCommandCount:t.maxCommandCount??At.maxCommandCount,maxLoopIterations:t.maxLoopIterations??At.maxLoopIterations,maxAwkIterations:t.maxAwkIterations??At.maxAwkIterations,maxSedIterations:t.maxSedIterations??At.maxSedIterations,maxJqIterations:t.maxJqIterations??At.maxJqIterations,maxSqliteTimeoutMs:t.maxSqliteTimeoutMs??At.maxSqliteTimeoutMs}:{...At}}function qd(t){try{let e=new URL(t);return{origin:e.origin,pathname:e.pathname,href:e.href}}catch{return null}}function Aw(t){let e=qd(t);return e?{origin:e.origin,pathPrefix:e.pathname}:null}function kw(t,e){let n=qd(t);if(!n)return!1;let r=Aw(e);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function io(t,e){return!e||e.length===0?!1:e.some(n=>kw(t,n))}var gn=class extends Error{constructor(e){super(`Network access denied: URL not in allow-list: ${e}`),this.name="NetworkAccessDeniedError"}},yn=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name="TooManyRedirectsError"}},xn=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name="RedirectNotAllowedError"}},is=class extends Error{constructor(e,n){super(`HTTP method '${e}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}};var Nw=20,Iw=3e4,vw=["GET","HEAD"],$w=new Set(["GET","HEAD","OPTIONS"]),Rw=new Set([301,302,303,307,308]);function oo(t){let e=t.maxRedirects??Nw,n=t.timeoutMs??Iw,r=t.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:t.allowedMethods??vw;function s(a){if(!t.dangerouslyAllowFullInternetAccess&&!io(a,t.allowedUrlPrefixes??[]))throw new gn(a)}function i(a){if(t.dangerouslyAllowFullInternetAccess)return;let l=a.toUpperCase();if(!r.includes(l))throw new is(l,r)}async function o(a,l={}){let c=l.method?.toUpperCase()??"GET";s(a),i(c);let u=a,f=0,d=l.followRedirects??!0,p=l.timeoutMs!==void 0?Math.min(l.timeoutMs,n):n;for(;;){let h=new AbortController,m=setTimeout(()=>h.abort(),p);try{let g={method:c,headers:l.headers,signal:h.signal,redirect:"manual"};l.body&&!$w.has(c)&&(g.body=l.body);let b=await fetch(u,g);if(Rw.has(b.status)&&d){let w=b.headers.get("location");if(!w)return await Vd(b,u);let E=new URL(w,u).href;if(!t.dangerouslyAllowFullInternetAccess&&!io(E,t.allowedUrlPrefixes??[]))throw new xn(E);if(f++,f>e)throw new yn(e);u=E;continue}return await Vd(b,u)}finally{clearTimeout(m)}}}return o}async function Vd(t,e){let n={};return t.headers.forEach((r,s)=>{n[s.toLowerCase()]=r}),{status:t.status,statusText:t.statusText,headers:n,body:await t.text(),url:e}}var ao=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;state;constructor(e={}){let n=e.fs??new Bt(e.files);this.fs=n,this.useDefaultLayout=!e.cwd&&!e.files;let r=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s={HOME:this.useDefaultLayout?"/home/user":"/",PATH:"/bin:/usr/bin",IFS:`
792
+ `,OSTYPE:"linux-gnu",MACHTYPE:"x86_64-pc-linux-gnu",HOSTTYPE:"x86_64",PWD:r,OLDPWD:r,...e.env};if(this.limits=Gd({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.network&&(this.secureFetch=oo(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1},inCondition:!1,loopDepth:0},Pf(n,this.useDefaultLayout),r!=="/"&&n instanceof Bt)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let i of Af(e.commands))this.registerCommand(i);if(e.network)for(let i of kf())this.registerCommand(i);if(e.customCommands)for(let i of e.customCommands)Nf(i)?this.registerCommand(If(i)):this.registerCommand(i)}registerCommand(e){this.commands.set(e.name,e);let n=this.fs;if(typeof n.writeFileSync=="function")try{n.writeFileSync(`/bin/${e.name}`,`#!/bin/bash
789
793
  # Built-in command: ${e.name}
790
794
  `)}catch{}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug("stdout",{output:e.stdout}),e.stderr&&this.logger.info("stderr",{output:e.stderr}),this.logger.info("exit",{exitCode:e.exitCode})),e}async exec(e,n){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
791
795
  `,exitCode:1,env:{...this.state.env,...n?.env}};if(!e.trim())return{stdout:"",stderr:"",exitCode:0,env:{...this.state.env,...n?.env}};this.logger?.info("exec",{command:e});let r=n?.cwd??this.state.cwd,s={...this.state,env:{...this.state.env,...n?.env,...n?.cwd?{PWD:n.cwd}:{}},cwd:r,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options}},i=e;n?.rawScript||(i=e.split(`
792
796
  `).map(a=>a.trimStart()).join(`
793
- `));try{let o=wt(i),a={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn},c=await new Hn(a,s).executeScript(o);return this.logResult(c)}catch(o){if(o instanceof ue)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode,env:{...this.state.env,...n?.env}});if(o instanceof ke)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:1,env:{...this.state.env,...n?.env}});if(o instanceof V)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:V.EXIT_CODE,env:{...this.state.env,...n?.env}});if(o.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${o.message}
797
+ `));try{let o=bt(i),a={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn},c=await new qn(a,s).executeScript(o);return this.logResult(c)}catch(o){if(o instanceof fe)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode,env:{...this.state.env,...n?.env}});if(o instanceof ke)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:1,env:{...this.state.env,...n?.env}});if(o instanceof Z)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:Z.EXIT_CODE,env:{...this.state.env,...n?.env}});if(o.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${o.message}
794
798
  `,exitCode:2,env:{...this.state.env,...n?.env}});if(o instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${o.message}
795
- `,exitCode:1,env:{...this.state.env,...n?.env}});throw o}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,n){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),n)}getCwd(){return this.state.cwd}getEnv(){return{...this.state.env}}};export{io as Bash,_t as InMemoryFs,mn as NetworkAccessDeniedError,yn as RedirectNotAllowedError,gn as TooManyRedirectsError,ax as defineCommand,ix as getCommandNames,ox as getNetworkCommandNames};
799
+ `,exitCode:1,env:{...this.state.env,...n?.env}});throw o}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,n){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),n)}getCwd(){return this.state.cwd}getEnv(){return{...this.state.env}}};export{ao as Bash,Bt as InMemoryFs,gn as NetworkAccessDeniedError,xn as RedirectNotAllowedError,yn as TooManyRedirectsError,mx as defineCommand,px as getCommandNames,hx as getNetworkCommandNames};
796
800
  /*! Bundled license information:
797
801
 
798
802
  ieee754/index.js: