just-bash 2.4.3 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +42 -4
  2. package/dist/AGENTS.md +2 -2
  3. package/dist/bin/chunks/base64-O7TCK5TL.js +6 -0
  4. package/dist/bin/{shell/chunks/cat-ZEMMQGY5.js → chunks/cat-AJXZOSPN.js} +1 -1
  5. package/dist/bin/chunks/{chunk-45SNFRCY.js → chunk-5WFYIUU2.js} +2 -2
  6. package/dist/bin/chunks/chunk-X4WRNADE.js +17 -0
  7. package/dist/bin/{shell/chunks/chunk-GX4MPCG6.js → chunks/chunk-Y5QKO4KO.js} +5 -5
  8. package/dist/bin/chunks/{cut-WWPJ2PYT.js → cut-IHF6BEOO.js} +1 -1
  9. package/dist/bin/chunks/grep-WDHYDUUD.js +9 -0
  10. package/dist/bin/{shell/chunks/gzip-MNCJB6OR.js → chunks/gzip-YXK3WZQL.js} +22 -22
  11. package/dist/bin/{shell/chunks/jq-XH2PXRWE.js → chunks/jq-XXZPU5CA.js} +1 -1
  12. package/dist/bin/chunks/{md5sum-VGXAOUBA.js → md5sum-2VAAFCTS.js} +1 -1
  13. package/dist/bin/chunks/rg-ALK3CYAN.js +29 -0
  14. package/dist/bin/chunks/{sha1sum-BIUH233Z.js → sha1sum-67P4ME4N.js} +1 -1
  15. package/dist/bin/{shell/chunks/sha256sum-SUIK2MT2.js → chunks/sha256sum-MV3WQ4QF.js} +1 -1
  16. package/dist/bin/{shell/chunks/sort-C3F6LCNY.js → chunks/sort-KUHOCH5S.js} +1 -1
  17. package/dist/bin/chunks/sqlite3-THMDBIGF.js +36 -0
  18. package/dist/bin/chunks/tar-C27YYUAS.js +63 -0
  19. package/dist/bin/{shell/chunks/uniq-DKS7RIAE.js → chunks/uniq-IXHB2FVS.js} +1 -1
  20. package/dist/bin/chunks/{wc-4LMTC3QD.js → wc-QSBRKIF5.js} +1 -1
  21. package/dist/bin/chunks/{xan-WNN2ZOAX.js → xan-6K2NGTHM.js} +1 -1
  22. package/dist/bin/just-bash.js +78 -78
  23. package/dist/bin/shell/chunks/base64-O7TCK5TL.js +6 -0
  24. package/dist/bin/{chunks/cat-ZEMMQGY5.js → shell/chunks/cat-AJXZOSPN.js} +1 -1
  25. package/dist/bin/shell/chunks/{chunk-45SNFRCY.js → chunk-5WFYIUU2.js} +2 -2
  26. package/dist/bin/shell/chunks/chunk-X4WRNADE.js +17 -0
  27. package/dist/bin/{chunks/chunk-GX4MPCG6.js → shell/chunks/chunk-Y5QKO4KO.js} +5 -5
  28. package/dist/bin/shell/chunks/{cut-WWPJ2PYT.js → cut-IHF6BEOO.js} +1 -1
  29. package/dist/bin/shell/chunks/grep-WDHYDUUD.js +9 -0
  30. package/dist/bin/{chunks/gzip-MNCJB6OR.js → shell/chunks/gzip-YXK3WZQL.js} +22 -22
  31. package/dist/bin/{chunks/jq-XH2PXRWE.js → shell/chunks/jq-XXZPU5CA.js} +1 -1
  32. package/dist/bin/shell/chunks/{md5sum-VGXAOUBA.js → md5sum-2VAAFCTS.js} +1 -1
  33. package/dist/bin/shell/chunks/rg-ALK3CYAN.js +29 -0
  34. package/dist/bin/shell/chunks/{sha1sum-BIUH233Z.js → sha1sum-67P4ME4N.js} +1 -1
  35. package/dist/bin/{chunks/sha256sum-SUIK2MT2.js → shell/chunks/sha256sum-MV3WQ4QF.js} +1 -1
  36. package/dist/bin/{chunks/sort-C3F6LCNY.js → shell/chunks/sort-KUHOCH5S.js} +1 -1
  37. package/dist/bin/shell/chunks/sqlite3-THMDBIGF.js +36 -0
  38. package/dist/bin/shell/chunks/tar-C27YYUAS.js +63 -0
  39. package/dist/bin/{chunks/uniq-DKS7RIAE.js → shell/chunks/uniq-IXHB2FVS.js} +1 -1
  40. package/dist/bin/shell/chunks/{wc-4LMTC3QD.js → wc-QSBRKIF5.js} +1 -1
  41. package/dist/bin/shell/chunks/{xan-WNN2ZOAX.js → xan-6K2NGTHM.js} +1 -1
  42. package/dist/bin/shell/shell.js +100 -100
  43. package/dist/bundle/browser.js +542 -506
  44. package/dist/bundle/chunks/base64-3BME25ON.js +5 -0
  45. package/dist/bundle/chunks/{cat-W5XITXDC.js → cat-MV4K6AUA.js} +1 -1
  46. package/dist/bundle/chunks/{chunk-4ACWXGKW.js → chunk-7L36YK2X.js} +2 -2
  47. package/dist/bundle/chunks/chunk-7VH6U2UX.js +16 -0
  48. package/dist/bundle/chunks/{chunk-46TSKXFW.js → chunk-GFLIVSUW.js} +5 -5
  49. package/dist/bundle/chunks/{cut-KKAAQJVD.js → cut-NVKWEAZF.js} +1 -1
  50. package/dist/bundle/chunks/grep-QVR5G7SC.js +8 -0
  51. package/dist/bundle/chunks/{gzip-7QAS5P2Y.js → gzip-L3NDJG3F.js} +22 -22
  52. package/dist/bundle/chunks/{jq-AAWVUTC4.js → jq-3YU5HRKE.js} +1 -1
  53. package/dist/bundle/chunks/{md5sum-LJHKXLVT.js → md5sum-KLHZSRUA.js} +1 -1
  54. package/dist/bundle/chunks/rg-43HLKW4V.js +28 -0
  55. package/dist/bundle/chunks/{sha1sum-NRUZZ4Q6.js → sha1sum-WKWTIZGQ.js} +1 -1
  56. package/dist/bundle/chunks/{sha256sum-5ZGJ4NJL.js → sha256sum-IUVNMBTA.js} +1 -1
  57. package/dist/bundle/chunks/{sort-JHO22QVO.js → sort-EJUT5LXD.js} +1 -1
  58. package/dist/bundle/chunks/sqlite3-5QVZOGER.js +35 -0
  59. package/dist/bundle/chunks/tar-QWBXMF7K.js +62 -0
  60. package/dist/bundle/chunks/{uniq-SEKCFR7B.js → uniq-47QVBRNC.js} +1 -1
  61. package/dist/bundle/chunks/{wc-52FZ4QGS.js → wc-DFQKWSIZ.js} +1 -1
  62. package/dist/bundle/chunks/{xan-ZHXYF6B4.js → xan-2R2APJJ4.js} +1 -1
  63. package/dist/bundle/index.js +119 -119
  64. package/dist/commands/registry.d.ts +1 -1
  65. package/dist/commands/rg/file-types.d.ts +23 -0
  66. package/dist/commands/rg/gitignore.d.ts +69 -0
  67. package/dist/commands/rg/rg-options.d.ts +47 -0
  68. package/dist/commands/rg/rg-parser.d.ts +20 -0
  69. package/dist/commands/rg/rg-search.d.ts +15 -0
  70. package/dist/commands/rg/rg.d.ts +12 -0
  71. package/dist/commands/search-engine/index.d.ts +10 -0
  72. package/dist/commands/search-engine/matcher.d.ts +57 -0
  73. package/dist/commands/search-engine/regex.d.ts +17 -0
  74. package/dist/commands/tar/archive.d.ts +107 -0
  75. package/dist/commands/tar/tar.d.ts +8 -0
  76. package/dist/index.d.ts +1 -0
  77. package/package.json +11 -5
  78. package/dist/bin/chunks/base64-RJX7MYGG.js +0 -6
  79. package/dist/bin/chunks/grep-U2RCKOEG.js +0 -15
  80. package/dist/bin/chunks/sqlite3-PZRKN3TT.js +0 -37
  81. package/dist/bin/shell/chunks/base64-RJX7MYGG.js +0 -6
  82. package/dist/bin/shell/chunks/grep-U2RCKOEG.js +0 -15
  83. package/dist/bin/shell/chunks/sqlite3-PZRKN3TT.js +0 -37
  84. package/dist/bundle/chunks/base64-F5R4G5EG.js +0 -5
  85. package/dist/bundle/chunks/grep-CTJRP2G3.js +0 -14
  86. package/dist/bundle/chunks/sqlite3-CX5D36A5.js +0 -36
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ import{a as te,b as re,c as N}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import*as Z from"@mongodb-js/zstd";import Ae from"compressjs";var P="file",se="link",ae="symlink",b="directory",Re={file:"0",link:"1",symlink:"2","character-device":"3","block-device":"4",directory:"5",fifo:"6","pax-header":"x","pax-global-header":"g","gnu-long-name":"L","gnu-long-link-name":"K"},ve={0:P,1:se,2:ae,3:"character-device",4:"block-device",5:b,6:"fifo",x:"pax-header",g:"pax-global-header",L:"gnu-long-name",K:"gnu-long-link-name"},ze=new Uint8Array(512),O=new Uint8Array(0),x=new TextEncoder,oe=new TextDecoder;function T(e,t,i,r){r&&x.encodeInto(r,e.subarray(t,t+i))}function I(e,t,i,r){if(r===void 0)return;let n=r.toString(8).padStart(i-1,"0");x.encodeInto(n,e.subarray(t,t+i-1))}function A(e,t,i){let r=e.indexOf(0,t),n=r===-1||r>t+i?t+i:r;return oe.decode(e.subarray(t,n))}function G(e,t,i){let r=0,n=t+i;for(let s=t;s<n;s++){let o=e[s];if(o===0)break;o!==32&&(r=r*8+(o-48))}return r}function R(e,t,i){if(e[t]&128){let r=0;r=e[t]&127;for(let n=1;n<i;n++)r=r*256+e[t+n];if(!Number.isSafeInteger(r))throw new Error("TAR number too large");return r}return G(e,t,i)}var k=e=>e.type===b||e.type===ae||e.type===se;async function ce(e){if(e==null)return O;if(e instanceof Uint8Array)return e;if(typeof e=="string")return x.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Blob)return new Uint8Array(await e.arrayBuffer());throw new TypeError("Unsupported content type for entry body.")}function le(e,t){let{strip:i,filter:r,map:n}=t;if(!i&&!r&&!n)return e;let s={...e};if(i&&i>0){let a=s.name.split("/").filter(Boolean);if(i>=a.length)return null;let c=a.slice(i).join("/");if(s.name=s.type===b&&!c.endsWith("/")?`${c}/`:c,s.linkname?.startsWith("/")){let l=s.linkname.split("/").filter(Boolean);s.linkname=i>=l.length?"/":`/${l.slice(i).join("/")}`}}if(r?.(s)===!1)return null;let o=n?n(s):s;return o&&(!o.name||!o.name.trim()||o.name==="."||o.name==="/")?null:o}var K=32,Oe=48;function be(e){let t=G(e,148,8),i=0;for(let r=0;r<e.length;r++)r>=148&&r<156?i+=K:i+=e[r];return t===i}function Me(e){e.fill(K,148,156);let t=0;for(let i of e)t+=i;for(let i=153;i>=148;i--)e[i]=(t&7)+Oe,t>>=3;e[154]=0,e[155]=K}function $e(e){let t={};e.name.length>100&&ue(e.name)===null&&(t.path=e.name),e.linkname&&e.linkname.length>100&&(t.linkpath=e.linkname),e.uname&&e.uname.length>32&&(t.uname=e.uname),e.gname&&e.gname.length>32&&(t.gname=e.gname),e.uid!=null&&e.uid>2097151&&(t.uid=String(e.uid)),e.gid!=null&&e.gid>2097151&&(t.gid=String(e.gid)),e.size!=null&&e.size>8589934591&&(t.size=String(e.size)),e.pax&&Object.assign(t,e.pax);let i=Object.entries(t);if(i.length===0)return null;let r=x.encode(i.map(([n,s])=>{let o=`${n}=${s}
3
+ `,a=x.encode(o).length+1,c=a+String(a).length;return c=a+String(c).length,`${c} ${o}`}).join(""));return{paxHeader:fe({name:oe.decode(x.encode(`PaxHeader/${e.name}`).slice(0,100)),size:r.length,type:"pax-header",mode:420,mtime:e.mtime,uname:e.uname,gname:e.gname,uid:e.uid,gid:e.gid}),paxBody:r}}function ue(e){if(e.length<=100)return null;let t=e.length-100-1,i=e.lastIndexOf("/",155);return i>0&&i>=t?{prefix:e.slice(0,i),name:e.slice(i+1)}:null}function fe(e){let t=new Uint8Array(512),i=k(e)?0:e.size??0,r=e.name,n="";if(!e.pax?.path){let s=ue(r);s&&(r=s.name,n=s.prefix)}return T(t,0,100,r),I(t,100,8,e.mode??(e.type===b?493:420)),I(t,108,8,e.uid??0),I(t,116,8,e.gid??0),I(t,124,12,i),I(t,136,12,Math.floor((e.mtime?.getTime()??Date.now())/1e3)),T(t,156,1,Re[e.type??P]),T(t,157,100,e.linkname),T(t,257,6,"ustar\0"),T(t,263,2,"00"),T(t,265,32,e.uname),T(t,297,32,e.gname),T(t,345,155,n),Me(t),t}function Ze(e,t){if(t&&!be(e))throw new Error("Invalid tar header checksum.");let i=A(e,156,1),r={name:A(e,0,100),mode:G(e,100,8),uid:R(e,108,8),gid:R(e,116,8),size:R(e,124,12),mtime:new Date(R(e,136,12)*1e3),type:ve[i]||P,linkname:A(e,157,100)},n=A(e,257,6);return n.trim()==="ustar"&&(r.uname=A(e,265,32),r.gname=A(e,297,32)),n==="ustar"&&(r.prefix=A(e,345,155)),r}var Be={path:["name",e=>e],linkpath:["linkname",e=>e],size:["size",e=>parseInt(e,10)],mtime:["mtime",parseFloat],uid:["uid",e=>parseInt(e,10)],gid:["gid",e=>parseInt(e,10)],uname:["uname",e=>e],gname:["gname",e=>e]};function De(e){let t=new TextDecoder("utf-8"),i={},r={},n=0;for(;n<e.length;){let s=e.indexOf(32,n);if(s===-1)break;let o=parseInt(t.decode(e.subarray(n,s)),10);if(Number.isNaN(o)||o===0)break;let a=n+o,[c,l]=t.decode(e.subarray(s+1,a-1)).split("=",2);if(c&&l!==void 0){r[c]=l;let d=Be[c];if(d){let[u,g]=d,p=g(l);(typeof p=="string"||!Number.isNaN(p))&&(i[u]=p)}}n=a}return Object.keys(r).length>0&&(i.pax=r),i}function ne(e,t){t.name!==void 0&&(e.name=t.name),t.linkname!==void 0&&(e.linkname=t.linkname),t.size!==void 0&&(e.size=t.size),t.mtime!==void 0&&(e.mtime=new Date(t.mtime*1e3)),t.uid!==void 0&&(e.uid=t.uid),t.gid!==void 0&&(e.gid=t.gid),t.uname!==void 0&&(e.uname=t.uname),t.gname!==void 0&&(e.gname=t.gname),t.pax&&(e.pax=Object.assign({},e.pax??{},t.pax))}function Ne(e){switch(e){case"pax-global-header":case"pax-header":return De;case"gnu-long-name":return t=>({name:A(t,0,t.length)});case"gnu-long-link-name":return t=>({linkname:A(t,0,t.length)});default:return}}function Le(e){let t=fe(e),i=$e(e);if(!i)return[t];let r=-i.paxBody.length&511,n=r>0?[ze.subarray(0,r)]:[];return[i.paxHeader,i.paxBody,...n,t]}var Ke=new Uint8Array(512*2);function de(e,t,i){let r=null,n=0,s=!1;return{add(o){if(s){let a=new Error("No new tar entries after finalize.");throw t(a),a}if(r!==null){let a=new Error("Previous entry must be completed before adding a new one");throw t(a),a}try{let a=k(o)?0:o.size??0,c=Le({...o,size:a});for(let l of c)e(l);r={...o,size:a},n=0}catch(a){t(a)}},write(o){if(!r){let c=new Error("No active tar entry.");throw t(c),c}if(s){let c=new Error("Cannot write data after finalize.");throw t(c),c}let a=n+o.length;if(a>r.size){let c=new Error(`"${r.name}" exceeds given size of ${r.size} bytes.`);throw t(c),c}try{n=a,e(o)}catch(c){t(c)}},endEntry(){if(!r){let o=new Error("No active entry to end.");throw t(o),o}if(s){let o=new Error("Cannot end entry after finalize.");throw t(o),o}try{if(n!==r.size){let a=new Error(`Size mismatch for "${r.name}".`);throw t(a),a}let o=-r.size&511;o>0&&e(new Uint8Array(o)),r=null,n=0}catch(o){throw t(o),o}},finalize(){if(s){let o=new Error("Archive has already been finalized");throw t(o),o}if(r!==null){let o=new Error("Cannot finalize while an entry is still active");throw t(o),o}try{e(Ke),s=!0,i&&i()}catch(o){t(o)}}}}var v=256;function Pe(){let e=new Array(v),t=e.length-1,i=0,r=0,n=0,s=a=>{let c=e[i];a===c.length?(e[i]=O,i=i+1&t):e[i]=c.subarray(a),n-=a,n===0&&e.length>v&&(e=new Array(v),t=v-1,i=0,r=0)};function o(a,c){if(c){let p=0,f=Math.min(a,n);for(;f>0;){let h=e[i],m=Math.min(f,h.length),S=m===h.length?h:h.subarray(0,m);if(s(m),f-=m,p+=m,!c(S))break}return p}if(n<a)return null;if(a===0)return O;let l=e[i];if(l.length>=a){let p=l.length===a?l:l.subarray(0,a);return s(a),p}let d=new Uint8Array(a),u=0,g=a;for(;g>0;){let p=e[i],f=Math.min(g,p.length);d.set(f===p.length?p:p.subarray(0,f),u),u+=f,g-=f,s(f)}return d}return{push:a=>{if(a.length===0)return;let c=r+1&t;if(c===i){let l=e.length,d=l*2,u=new Array(d),g=r-i+l&l-1;if(i<r)for(let p=0;p<g;p++)u[p]=e[i+p];else if(g>0){let p=l-i;for(let f=0;f<p;f++)u[f]=e[i+f];for(let f=0;f<r;f++)u[p+f]=e[f]}e=u,t=d-1,i=0,r=g,c=r+1&t}e[r]=a,r=c,n+=a.length},available:()=>n,peek:a=>{if(n<a)return null;if(a===0)return O;let c=e[i];if(c.length>=a)return c.length===a?c:c.subarray(0,a);let l=new Uint8Array(a),d=0,u=i;for(;d<a;){let g=e[u],p=Math.min(a-d,g.length);p===g.length?l.set(g,d):l.set(g.subarray(0,p),d),d+=p,u=u+1&t}return l},discard:a=>{if(a>n)throw new Error("Too many bytes consumed");if(a===0)return;let c=a;for(;c>0;){let l=e[i],d=Math.min(c,l.length);s(d),c-=d}},pull:o}}var L=0,F=1,z=new Error("Tar archive is truncated.");function me(e={}){let t=e.strict??!1,{available:i,peek:r,push:n,discard:s,pull:o}=Pe(),a=L,c=!1,l=!1,d=!1,u=null,g={},p={},f={isEntryActive:()=>a===F,isBodyComplete:()=>!u||u.remaining===0,write(h){if(c)throw new Error("Archive already ended.");n(h)},end(){c=!0},readHeader(){if(a!==L)throw new Error("Cannot read header while an entry is active");if(!l)for(;!l;){if(i()<512){if(c){if(i()>0&&t)throw z;l=!0;return}return null}let h=r(512);if(ie(h)){if(i()<512*2){if(c){if(t)throw z;l=!0;return}return null}if(ie(r(512*2).subarray(512))){s(512*2),l=!0,d=!0;return}if(t)throw new Error("Invalid tar header.");s(512);continue}let m;try{m=Ze(h,t)}catch(w){if(t)throw w;s(512);continue}let S=Ne(m.type);if(S){let w=m.size+511&-512;if(i()<512+w){if(c&&t)throw z;return null}s(512);let U=S(o(w).subarray(0,m.size)),ke=m.type==="pax-global-header"?g:p;for(let ee in U)ke[ee]=U[ee];continue}s(512);let E=m;return m.prefix&&(E.name=`${m.prefix}/${E.name}`),ne(E,g),ne(E,p),p={},u={header:E,remaining:E.size,padding:-E.size&511},a=F,E}},streamBody(h){if(a!==F||!u||u.remaining===0)return 0;let m=Math.min(u.remaining,i());if(m===0)return 0;let S=o(m,h);return u.remaining-=S,S},skipPadding(){if(a!==F||!u)return!0;if(u.remaining>0)throw new Error("Body not fully consumed");return i()<u.padding?!1:(s(u.padding),u=null,a=L,!0)},skipEntry(){if(a!==F||!u)return!0;let h=Math.min(u.remaining,i());return h>0&&(s(h),u.remaining-=h),u.remaining>0?!1:f.skipPadding()},validateEOF(){if(t){if(!d)throw z;if(i()>0&&o(i()).some(h=>h!==0))throw new Error("Invalid EOF.")}}};return f}function ie(e){if(e.byteOffset%8===0){let t=new BigUint64Array(e.buffer,e.byteOffset,e.length/8);for(let i=0;i<t.length;i++)if(t[i]!==0n)return!1;return!0}for(let t=0;t<e.length;t++)if(e[t]!==0)return!1;return!0}function he(){return new CompressionStream("gzip")}function ge(){return new DecompressionStream("gzip")}function Ge(){let e,t;return{readable:new ReadableStream({start(i){e=i,t=de(i.enqueue.bind(i),i.error.bind(i),i.close.bind(i))}}),controller:{add(i){let r=k(i),n={...i};return r&&(n.size=0),t.add(n),r&&t.endEntry(),new WritableStream({write(s){t.write(s)},close(){r||t.endEntry()},abort(s){e.error(s)}})},finalize(){t.finalize()},error(i){e.error(i)}}}}async function Se(e){let t=[],i=e.getReader(),r=0;try{for(;;){let{done:o,value:a}=await i.read();if(o)break;t.push(a),r+=a.length}let n=new Uint8Array(r),s=0;for(let o of t)n.set(o,s),s+=o.length;return n}finally{i.releaseLock()}}var pe=e=>e.pipeTo(new WritableStream);function He(e={}){let t=me(e),i=null,r=!1,n=s=>{if(!r){r=!0;try{for(;;)if(t.isEntryActive()){if(i){if(t.streamBody(o=>(i.enqueue(o),!0))===0&&!t.isBodyComplete())break}else if(!t.skipEntry())break;if(t.isBodyComplete()){try{i?.close()}catch{}if(i=null,!t.skipPadding())break}}else{let o=t.readHeader();if(o==null)break;s.enqueue({header:o,body:new ReadableStream({start(a){o.size===0?a.close():i=a},pull:()=>n(s),cancel(){i=null,n(s)}})})}}catch(o){try{i?.error(o)}catch{}throw i=null,o}finally{r=!1}}};return new TransformStream({transform(s,o){try{t.write(s),n(o)}catch(a){try{i?.error(a)}catch{}throw a}},flush(s){try{if(t.end(),n(s),t.validateEOF(),t.isEntryActive()&&!t.isBodyComplete())try{i?.close()}catch{}}catch(o){try{i?.error(o)}catch{}throw o}}},void 0,{highWaterMark:1})}async function Ee(e){let{readable:t,controller:i}=Ge();return await(async()=>{for(let r of e){let n=i.add(r.header),s="body"in r?r.body:r.data;if(!s){await n.close();continue}if(s instanceof ReadableStream)await s.pipeTo(n);else if(s instanceof Blob)await s.stream().pipeTo(n);else try{let o=await ce(s);if(o.length>0){let a=n.getWriter();await a.write(o),await a.close()}else await n.close()}catch{throw new TypeError(`Unsupported content type for entry "${r.header.name}".`)}}})().then(()=>i.finalize()).catch(r=>i.error(r)),new Uint8Array(await Se(t))}async function we(e,t={}){let i=e instanceof ReadableStream?e:new ReadableStream({start(s){s.enqueue(e instanceof Uint8Array?e:new Uint8Array(e)),s.close()}}),r=[],n=i.pipeThrough(He(t));for await(let s of n){let o;try{o=le(s.header,t)}catch(a){throw await s.body.cancel(),a}if(o===null){await pe(s.body);continue}k(o)?(await pe(s.body),r.push({header:o})):r.push({header:o,data:await Se(s.body)})}return r}var M=null,$=null;async function _e(){if(M)return M;if($)throw $;try{return M=await import("node-liblzma"),M}catch{throw $=new Error("xz compression requires node-liblzma which failed to load. Install liblzma-dev (apt) or xz (brew) and reinstall dependencies."),$}}var y=100*1024*1024,ye=1e4;function We(e){let t="file";e.isDirectory?t="directory":e.isSymlink&&(t="symlink");let i=e.name;e.isDirectory&&!i.endsWith("/")&&(i+="/");let r;e.content!==void 0&&(typeof e.content=="string"?r=new TextEncoder().encode(e.content):r=e.content);let n=e.isDirectory||e.isSymlink?0:r?.length??0;return{header:{name:i,mode:e.mode??(e.isDirectory?493:420),uid:e.uid??0,gid:e.gid??0,size:n,mtime:e.mtime??new Date,type:t,linkname:e.linkTarget??"",uname:"user",gname:"user"},body:r}}async function C(e){let t=e.map(We);return Ee(t)}async function Te(e){let t=await C(e),n=new ReadableStream({start(l){l.enqueue(t),l.close()}}).pipeThrough(he()).getReader(),s=[];for(;;){let{done:l,value:d}=await n.read();if(l)break;s.push(d)}let o=s.reduce((l,d)=>l+d.length,0),a=new Uint8Array(o),c=0;for(let l of s)a.set(l,c),c+=l.length;return a}async function _(e){if(e.length>y)return{entries:[],error:`Archive too large (max ${y} bytes)`};try{let t=await we(e),i=[];for(let r of t){if(i.length>=ye)return{entries:i,error:`Too many entries (max ${ye})`};let n="file";switch(r.header.type){case"directory":n="directory";break;case"symlink":n="symlink";break;case"link":n="hardlink";break;case"file":n="file";break;default:n="other"}i.push({name:r.header.name,mode:r.header.mode??420,uid:r.header.uid??0,gid:r.header.gid??0,size:r.header.size,mtime:r.header.mtime??new Date,type:n,linkTarget:r.header.linkname||void 0,content:r.data??new Uint8Array(0)})}return{entries:i}}catch(t){let i=t instanceof Error?t.message:"Unknown error";return{entries:[],error:i}}}async function H(e){if(e.length>y)return{entries:[],error:`Archive too large (max ${y} bytes)`};try{let r=new ReadableStream({start(c){c.enqueue(e),c.close()}}).pipeThrough(ge()).getReader(),n=[];for(;;){let{done:c,value:l}=await r.read();if(c)break;n.push(l)}let s=n.reduce((c,l)=>c+l.length,0),o=new Uint8Array(s),a=0;for(let c of n)o.set(c,a),a+=c.length;return _(o)}catch(t){let i=t instanceof Error?t.message:"Unknown error";return{entries:[],error:`Decompression failed: ${i}`}}}function W(e){return e.length>=2&&e[0]===31&&e[1]===139}function X(e){return e.length>=3&&e[0]===66&&e[1]===90&&e[2]===104}function j(e){return e.length>=6&&e[0]===253&&e[1]===55&&e[2]===122&&e[3]===88&&e[4]===90&&e[5]===0}async function Xe(e){let i=Ae.Bzip2.decompressFile(Array.from(e));return new Uint8Array(i)}async function je(e){let t=Ae.Bzip2,i=[];return t.compressFile(Array.from(e),i,9),new Uint8Array(i)}async function qe(e){let i=(await _e()).unxzSync(Buffer.from(e));return new Uint8Array(i)}async function Ye(e){let i=(await _e()).xzSync(Buffer.from(e));return new Uint8Array(i)}async function Ce(e){let t=await C(e);return je(t)}async function xe(e){let t=await C(e);return Ye(t)}async function q(e){if(e.length>y)return{entries:[],error:`Archive too large (max ${y} bytes)`};try{let t=await Xe(e);return _(t)}catch(t){let i=t instanceof Error?t.message:"Unknown error";return{entries:[],error:i}}}async function Y(e){if(e.length>y)return{entries:[],error:`Archive too large (max ${y} bytes)`};try{let t=await qe(e);return _(t)}catch(t){let i=t instanceof Error?t.message:"Unknown error";return{entries:[],error:i}}}function V(e){return e.length>=4&&e[0]===40&&e[1]===181&&e[2]===47&&e[3]===253}async function Ve(e){let t=await Z.compress(Buffer.from(e),3);return new Uint8Array(t)}async function Je(e){let t=await Z.decompress(Buffer.from(e));return new Uint8Array(t)}async function Ue(e){let t=await C(e);return Ve(t)}async function J(e){if(e.length>y)return{entries:[],error:`Archive too large (max ${y} bytes)`};try{let t=await Je(e);return _(t)}catch(t){let i=t instanceof Error?t.message:"Unknown error";return{entries:[],error:i}}}var Ie=100,Qe={name:"tar",summary:"manipulate tape archives",usage:"tar [options] [file...]",description:["Create, extract, or list contents of tar archives.","","One of -c, -r, -u, -x, or -t is required to specify the operation."],options:["-c, --create create a new archive","-r, --append append files to the end of an archive","-u, --update only append files newer than copy in archive","-x, --extract extract files from an archive","-t, --list list contents of an archive","-f, --file=ARCHIVE use archive file ARCHIVE","-a, --auto-compress use archive suffix to determine compression","-z, --gzip filter archive through gzip","-j, --bzip2 filter archive through bzip2","-J, --xz filter archive through xz","--zstd filter archive through zstd","-v, --verbose verbosely list files processed","-O, --to-stdout extract files to standard output","-k, --keep-old-files don't replace existing files when extracting","-m, --touch don't extract file modified time","-C, --directory=DIR change to directory DIR before performing operations","-p, --preserve preserve permissions","-T, --files-from=FILE read files to extract/create from FILE","-X, --exclude-from=FILE read exclude patterns from FILE","--strip=N strip N leading path components on extraction","--exclude=PATTERN exclude files matching PATTERN","--wildcards use wildcards for pattern matching"," --help display this help and exit"],examples:["tar -cvf archive.tar file1 file2 Create archive from files","tar -czvf archive.tar.gz dir/ Create gzip-compressed archive","tar -cjvf archive.tar.bz2 dir/ Create bzip2-compressed archive","tar -rf archive.tar newfile.txt Append file to archive","tar -uf archive.tar dir/ Update archive with newer files","tar -xvf archive.tar Extract archive","tar -xvf archive.tar -C /tmp Extract to /tmp","tar -tvf archive.tar List archive contents","tar -xzf archive.tar.gz Extract gzip archive","tar -xf archive.tar file1.txt Extract specific file","tar -xOf archive.tar file.txt Extract file to stdout","tar -xf archive.tar --wildcards '*.txt' Extract matching files"]};function et(e){let t={create:!1,append:!1,update:!1,extract:!1,list:!1,file:"",autoCompress:!1,gzip:!1,bzip2:!1,xz:!1,zstd:!1,verbose:!1,toStdout:!1,keepOldFiles:!1,touch:!1,directory:"",preserve:!1,strip:0,exclude:[],filesFrom:"",excludeFrom:"",wildcards:!1},i=[],r=0;for(;r<e.length;){let n=e[r];if(n.startsWith("-")&&!n.startsWith("--")&&n.length>2){if(/^-\d+$/.test(n)){i.push(n),r++;continue}for(let s=1;s<n.length;s++){let o=n[s];switch(o){case"c":t.create=!0;break;case"r":t.append=!0;break;case"u":t.update=!0;break;case"x":t.extract=!0;break;case"t":t.list=!0;break;case"a":t.autoCompress=!0;break;case"z":t.gzip=!0;break;case"j":t.bzip2=!0;break;case"J":t.xz=!0;break;case"v":t.verbose=!0;break;case"O":t.toStdout=!0;break;case"k":t.keepOldFiles=!0;break;case"m":t.touch=!0;break;case"p":t.preserve=!0;break;case"f":if(s<n.length-1)t.file=n.substring(s+1),s=n.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'f'
4
+ `,exitCode:2}};t.file=e[r]}break;case"C":if(s<n.length-1)t.directory=n.substring(s+1),s=n.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'C'
5
+ `,exitCode:2}};t.directory=e[r]}break;case"T":if(s<n.length-1)t.filesFrom=n.substring(s+1),s=n.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'T'
6
+ `,exitCode:2}};t.filesFrom=e[r]}break;case"X":if(s<n.length-1)t.excludeFrom=n.substring(s+1),s=n.length;else{if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'X'
7
+ `,exitCode:2}};t.excludeFrom=e[r]}break;default:return{ok:!1,error:N("tar",`-${o}`)}}}r++;continue}if(n==="-c"||n==="--create")t.create=!0;else if(n==="-r"||n==="--append")t.append=!0;else if(n==="-u"||n==="--update")t.update=!0;else if(n==="-x"||n==="--extract"||n==="--get")t.extract=!0;else if(n==="-t"||n==="--list")t.list=!0;else if(n==="-a"||n==="--auto-compress")t.autoCompress=!0;else if(n==="-z"||n==="--gzip"||n==="--gunzip")t.gzip=!0;else if(n==="-j"||n==="--bzip2")t.bzip2=!0;else if(n==="-J"||n==="--xz")t.xz=!0;else if(n==="--zstd")t.zstd=!0;else if(n==="-v"||n==="--verbose")t.verbose=!0;else if(n==="-O"||n==="--to-stdout")t.toStdout=!0;else if(n==="-k"||n==="--keep-old-files")t.keepOldFiles=!0;else if(n==="-m"||n==="--touch")t.touch=!0;else if(n==="--wildcards")t.wildcards=!0;else if(n==="-p"||n==="--preserve"||n==="--preserve-permissions")t.preserve=!0;else if(n==="-f"||n==="--file"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'f'
8
+ `,exitCode:2}};t.file=e[r]}else if(n.startsWith("--file="))t.file=n.substring(7);else if(n==="-C"||n==="--directory"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'C'
9
+ `,exitCode:2}};t.directory=e[r]}else if(n.startsWith("--directory="))t.directory=n.substring(12);else if(n.startsWith("--strip-components=")||n.startsWith("--strip=")){let s=n.includes("--strip-components=")?n.substring(19):n.substring(8),o=parseInt(s,10);if(Number.isNaN(o)||o<0)return{ok:!1,error:{stdout:"",stderr:`tar: invalid number for --strip: '${s}'
10
+ `,exitCode:2}};t.strip=o}else if(n.startsWith("--exclude="))t.exclude.push(n.substring(10));else if(n==="--exclude"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option '--exclude' requires an argument
11
+ `,exitCode:2}};t.exclude.push(e[r])}else if(n==="-T"||n==="--files-from"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'T'
12
+ `,exitCode:2}};t.filesFrom=e[r]}else if(n.startsWith("--files-from="))t.filesFrom=n.substring(13);else if(n==="-X"||n==="--exclude-from"){if(r++,r>=e.length)return{ok:!1,error:{stdout:"",stderr:`tar: option requires an argument -- 'X'
13
+ `,exitCode:2}};t.excludeFrom=e[r]}else if(n.startsWith("--exclude-from="))t.excludeFrom=n.substring(15);else if(n==="--"){i.push(...e.slice(r+1));break}else{if(n.startsWith("-"))return{ok:!1,error:N("tar",n)};i.push(n)}r++}return{ok:!0,options:t,files:i}}function Q(e,t){let i=e.includes("/")?e.substring(e.lastIndexOf("/")+1):e;for(let r of t){let n=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"<<<GLOBSTAR>>>").replace(/\*/g,"[^/]*").replace(/<<<GLOBSTAR>>>/g,".*").replace(/\?/g,".");if(new RegExp(`^${n}$`).test(e)||new RegExp(`^${n}/`).test(e)||!r.includes("/")&&new RegExp(`^${n}$`).test(i))return!0}return!1}function B(e,t){let i=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"<<<GLOBSTAR>>>").replace(/\*/g,"[^/]*").replace(/<<<GLOBSTAR>>>/g,".*").replace(/\?/g,"."),r=e.includes("/")?e.substring(e.lastIndexOf("/")+1):e;return new RegExp(`^${i}$`).test(e)||new RegExp(`^${i}$`).test(r)}function Fe(e,t){if(t<=0)return e;let i=e.split("/").filter(r=>r!=="");return i.length<=t?"":i.slice(t).join("/")}function tt(e,t){let i=t?"d":"-",r=[e&256?"r":"-",e&128?"w":"-",e&64?"x":"-",e&32?"r":"-",e&16?"w":"-",e&8?"x":"-",e&4?"r":"-",e&2?"w":"-",e&1?"x":"-"].join("");return i+r}function rt(e){let i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],r=e.getDate().toString().padStart(2," "),n=e.getHours().toString().padStart(2,"0"),s=e.getMinutes().toString().padStart(2,"0");return`${i} ${r} ${n}:${s}`}async function D(e,t,i,r){let n=[],s=[],o=e.fs.resolvePath(t,i);try{let a=await e.fs.stat(o);if(Q(i,r))return{entries:n,errors:s};if(a.isDirectory){n.push({name:i,isDirectory:!0,mode:a.mode,mtime:a.mtime});let c=await e.fs.readdir(o);for(let l=0;l<c.length;l+=Ie){let d=c.slice(l,l+Ie),u=await Promise.all(d.map(g=>D(e,t,i?`${i}/${g}`:g,r)));for(let g of u)n.push(...g.entries),s.push(...g.errors)}}else if(a.isFile){let c=await e.fs.readFileBuffer(o);n.push({name:i,content:c,mode:a.mode,mtime:a.mtime})}else if(a.isSymbolicLink){let c=await e.fs.readlink(o);n.push({name:i,isSymlink:!0,linkTarget:c,mode:a.mode,mtime:a.mtime})}}catch(a){let c=a instanceof Error?a.message:"unknown error";s.push(`tar: ${i}: ${c}`)}return{entries:n,errors:s}}async function nt(e,t,i){if(i.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to create an empty archive
14
+ `,exitCode:2};let r=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,n=[],s=[],o="";for(let d of i){let{entries:u,errors:g}=await D(e,r,d,t.exclude);if(n.push(...u),s.push(...g),t.verbose)for(let p of u)o+=`${p.name}${p.isDirectory?"/":""}
15
+ `}if(n.length===0&&s.length>0)return{stdout:"",stderr:`${s.join(`
16
+ `)}
17
+ `,exitCode:2};let a;try{t.gzip?a=await Te(n):t.bzip2?a=await Ce(n):t.xz?a=await xe(n):t.zstd?a=await Ue(n):a=await C(n)}catch(d){return{stdout:"",stderr:`tar: error creating archive: ${d instanceof Error?d.message:"unknown error"}
18
+ `,exitCode:2}}let c="";if(t.file&&t.file!=="-"){let d=e.fs.resolvePath(e.cwd,t.file);try{await e.fs.writeFile(d,a)}catch(u){let g=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`tar: ${t.file}: ${g}
19
+ `,exitCode:2}}}else c=String.fromCharCode(...a);let l=o;return s.length>0&&(l+=`${s.join(`
20
+ `)}
21
+ `),{stdout:c,stderr:l,exitCode:s.length>0?2:0}}async function it(e,t,i){if(!t.file||t.file==="-")return{stdout:"",stderr:`tar: Cannot append to stdin/stdout
22
+ `,exitCode:2};if(i.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to append nothing to archive
23
+ `,exitCode:2};let r=e.fs.resolvePath(e.cwd,t.file),n;try{n=await e.fs.readFileBuffer(r)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
24
+ `,exitCode:2}}let s=await _(n);if(s.error)return{stdout:"",stderr:`tar: ${s.error}
25
+ `,exitCode:2};let o=s.entries.map(f=>({name:f.name,content:f.content,mode:f.mode,mtime:f.mtime,isDirectory:f.type==="directory",isSymlink:f.type==="symlink",linkTarget:f.linkTarget,uid:f.uid,gid:f.gid})),a=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,c=[],l=[],d="";for(let f of i){let{entries:h,errors:m}=await D(e,a,f,t.exclude);if(c.push(...h),l.push(...m),t.verbose)for(let S of h)d+=`${S.name}${S.isDirectory?"/":""}
26
+ `}let u=[...o,...c],g;try{g=await C(u)}catch(f){return{stdout:"",stderr:`tar: error creating archive: ${f instanceof Error?f.message:"unknown error"}
27
+ `,exitCode:2}}try{await e.fs.writeFile(r,g)}catch(f){let h=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`tar: ${t.file}: ${h}
28
+ `,exitCode:2}}let p=d;return l.length>0&&(p+=`${l.join(`
29
+ `)}
30
+ `),{stdout:"",stderr:p,exitCode:l.length>0?2:0}}async function st(e,t,i){if(!t.file||t.file==="-")return{stdout:"",stderr:`tar: Cannot update stdin/stdout
31
+ `,exitCode:2};if(i.length===0)return{stdout:"",stderr:`tar: Cowardly refusing to update with nothing
32
+ `,exitCode:2};let r=e.fs.resolvePath(e.cwd,t.file),n;try{n=await e.fs.readFileBuffer(r)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
33
+ `,exitCode:2}}let s=await _(n);if(s.error)return{stdout:"",stderr:`tar: ${s.error}
34
+ `,exitCode:2};let o=new Map;for(let m of s.entries)o.set(m.name,m.mtime);let a=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,c=[],l=[],d="";for(let m of i){let{entries:S,errors:E}=await D(e,a,m,t.exclude);l.push(...E);for(let w of S){let U=o.get(w.name);(!U||w.mtime&&w.mtime.getTime()>U.getTime())&&(c.push(w),t.verbose&&(d+=`${w.name}${w.isDirectory?"/":""}
35
+ `))}}if(c.length===0){let m="";return l.length>0&&(m=`${l.join(`
36
+ `)}
37
+ `),{stdout:"",stderr:m,exitCode:l.length>0?2:0}}let u=new Set(c.map(m=>m.name)),p=[...s.entries.filter(m=>!u.has(m.name)).map(m=>({name:m.name,content:m.content,mode:m.mode,mtime:m.mtime,isDirectory:m.type==="directory",isSymlink:m.type==="symlink",linkTarget:m.linkTarget,uid:m.uid,gid:m.gid})),...c],f;try{f=await C(p)}catch(m){return{stdout:"",stderr:`tar: error creating archive: ${m instanceof Error?m.message:"unknown error"}
38
+ `,exitCode:2}}try{await e.fs.writeFile(r,f)}catch(m){let S=m instanceof Error?m.message:"unknown error";return{stdout:"",stderr:`tar: ${t.file}: ${S}
39
+ `,exitCode:2}}let h=d;return l.length>0&&(h+=`${l.join(`
40
+ `)}
41
+ `),{stdout:"",stderr:h,exitCode:l.length>0?2:0}}async function at(e,t,i){let r;if(t.file&&t.file!=="-"){let f=e.fs.resolvePath(e.cwd,t.file);try{r=await e.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
42
+ `,exitCode:2}}}else r=Uint8Array.from(e.stdin,f=>f.charCodeAt(0));let n,s=t.gzip||W(r),o=t.bzip2||X(r),a=t.xz||j(r),c=t.zstd||V(r);if(s?n=await H(r):o?n=await q(r):a?n=await Y(r):c?n=await J(r):n=await _(r),n.error)return{stdout:"",stderr:`tar: ${n.error}
43
+ `,exitCode:2};let l=t.directory?e.fs.resolvePath(e.cwd,t.directory):e.cwd,d="",u="",g=[];if(t.directory&&!t.toStdout)try{await e.fs.mkdir(l,{recursive:!0})}catch{}for(let f of n.entries){let h=Fe(f.name,t.strip);if(!h)continue;let m=h.endsWith("/")?h.slice(0,-1):h;if(i.length>0){let E;if(t.wildcards?E=i.some(w=>B(h,w)||B(m,w)||h.startsWith(`${w}/`)):E=i.some(w=>h===w||h.startsWith(`${w}/`)||m===w),!E)continue}if(Q(h,t.exclude))continue;let S=e.fs.resolvePath(l,h);try{if(f.type==="directory"){if(t.toStdout)continue;await e.fs.mkdir(S,{recursive:!0}),t.verbose&&(d+=`${h}
44
+ `)}else if(f.type==="file"){if(t.toStdout){u+=new TextDecoder().decode(f.content),t.verbose&&(d+=`${h}
45
+ `);continue}if(t.keepOldFiles)try{await e.fs.stat(S),t.verbose&&(d+=`${h}: not overwritten, file exists
46
+ `);continue}catch{}let E=S.substring(0,S.lastIndexOf("/"));if(E)try{await e.fs.mkdir(E,{recursive:!0})}catch{}if(await e.fs.writeFile(S,f.content),t.preserve&&f.mode)try{await e.fs.chmod(S,f.mode)}catch{}t.verbose&&(d+=`${h}
47
+ `)}else if(f.type==="symlink"&&f.linkTarget){if(t.toStdout)continue;if(t.keepOldFiles)try{await e.fs.stat(S),t.verbose&&(d+=`${h}: not overwritten, file exists
48
+ `);continue}catch{}let E=S.substring(0,S.lastIndexOf("/"));if(E)try{await e.fs.mkdir(E,{recursive:!0})}catch{}try{await e.fs.symlink(f.linkTarget,S)}catch{}t.verbose&&(d+=`${h}
49
+ `)}}catch(E){let w=E instanceof Error?E.message:"unknown error";g.push(`tar: ${h}: ${w}`)}}let p=d;return g.length>0&&(p+=`${g.join(`
50
+ `)}
51
+ `),{stdout:u,stderr:p,exitCode:g.length>0?2:0}}async function ot(e,t,i){let r;if(t.file&&t.file!=="-"){let d=e.fs.resolvePath(e.cwd,t.file);try{r=await e.fs.readFileBuffer(d)}catch{return{stdout:"",stderr:`tar: ${t.file}: Cannot open: No such file or directory
52
+ `,exitCode:2}}}else r=Uint8Array.from(e.stdin,d=>d.charCodeAt(0));let n,s=t.gzip||W(r),o=t.bzip2||X(r),a=t.xz||j(r),c=t.zstd||V(r);if(s?n=await H(r):o?n=await q(r):a?n=await Y(r):c?n=await J(r):n=await _(r),n.error)return{stdout:"",stderr:`tar: ${n.error}
53
+ `,exitCode:2};let l="";for(let d of n.entries){let u=Fe(d.name,t.strip);if(!u)continue;let g=u.endsWith("/")?u.slice(0,-1):u;if(i.length>0){let p;if(t.wildcards?p=i.some(f=>B(u,f)||B(g,f)||u.startsWith(`${f}/`)):p=i.some(f=>u===f||u.startsWith(`${f}/`)||g===f),!p)continue}if(!Q(u,t.exclude))if(t.verbose){let p=d.type==="directory",f=tt(d.mode,p),h=`${d.uid}/${d.gid}`,m=d.size.toString().padStart(8," "),S=rt(d.mtime),E=`${f} ${h.padEnd(10)} ${m} ${S} ${u}`;d.type==="symlink"&&d.linkTarget&&(E+=` -> ${d.linkTarget}`),l+=`${E}
54
+ `}else l+=`${u}
55
+ `}return{stdout:l,stderr:"",exitCode:0}}var gt={name:"tar",async execute(e,t){if(re(e))return te(Qe);let i=et(e);if(!i.ok)return i.error;let{options:r,files:n}=i,s=[r.create,r.append,r.update,r.extract,r.list].filter(Boolean).length;if(s===0)return{stdout:"",stderr:`tar: You must specify one of -c, -r, -u, -x, or -t
56
+ `,exitCode:2};if(s>1)return{stdout:"",stderr:`tar: You may not specify more than one of -c, -r, -u, -x, or -t
57
+ `,exitCode:2};if(r.autoCompress&&r.file&&r.create){let c=r.file.toLowerCase();c.endsWith(".tar.gz")||c.endsWith(".tgz")?r.gzip=!0:c.endsWith(".tar.bz2")||c.endsWith(".tbz2")?r.bzip2=!0:c.endsWith(".tar.xz")||c.endsWith(".txz")?r.xz=!0:(c.endsWith(".tar.zst")||c.endsWith(".tzst"))&&(r.zstd=!0)}let o=[r.gzip,r.bzip2,r.xz,r.zstd].filter(Boolean).length;if(o>1)return{stdout:"",stderr:`tar: You may not specify more than one compression option
58
+ `,exitCode:2};if((r.append||r.update)&&o>0)return{stdout:"",stderr:`tar: Cannot append/update compressed archives - decompress first
59
+ `,exitCode:2};let a=n;if(r.filesFrom){let c=t.fs.resolvePath(t.cwd,r.filesFrom);try{let d=(await t.fs.readFile(c)).split(`
60
+ `).map(u=>u.trim()).filter(u=>u.length>0&&!u.startsWith("#"));a=[...n,...d]}catch{return{stdout:"",stderr:`tar: ${r.filesFrom}: Cannot open: No such file or directory
61
+ `,exitCode:2}}}if(r.excludeFrom){let c=t.fs.resolvePath(t.cwd,r.excludeFrom);try{let d=(await t.fs.readFile(c)).split(`
62
+ `).map(u=>u.trim()).filter(u=>u.length>0&&!u.startsWith("#"));r.exclude.push(...d)}catch{return{stdout:"",stderr:`tar: ${r.excludeFrom}: Cannot open: No such file or directory
63
+ `,exitCode:2}}}return r.create?nt(t,r,a):r.append?it(t,r,a):r.update?st(t,r,a):r.extract?at(t,r,a):ot(t,r,a)}};export{gt as tarCommand};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{b as g}from"./chunk-45SNFRCY.js";import"./chunk-OBH7XN5N.js";import{a as f}from"./chunk-TA7RUHGQ.js";import{a as p,b as d}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var b={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"]},w={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"}},P={name:"uniq",async execute(a,m){if(d(a))return p(b);let o=f("uniq",a,w);if(!o.ok)return o.error;let{count:h,duplicatesOnly:y,uniqueOnly:q,ignoreCase:C}=o.result.flags,O=o.result.positional,u=await g(m,O,{cmdName:"uniq"});if(!u.ok)return u.error;let n=u.content.split(`
2
+ import{b as g}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as f}from"./chunk-TA7RUHGQ.js";import{a as p,b as d}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var b={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"]},w={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"}},P={name:"uniq",async execute(a,m){if(d(a))return p(b);let o=f("uniq",a,w);if(!o.ok)return o.error;let{count:h,duplicatesOnly:y,uniqueOnly:q,ignoreCase:C}=o.result.flags,O=o.result.positional,u=await g(m,O,{cmdName:"uniq"});if(!u.ok)return u.error;let n=u.content.split(`
3
3
  `);if(n.length>0&&n[n.length-1]===""&&n.pop(),n.length===0)return{stdout:"",stderr:"",exitCode:0};let t=[],r=n[0],i=1,x=(e,s)=>C?e.toLowerCase()===s.toLowerCase():e===s;for(let e=1;e<n.length;e++)x(n[e],r)?i++:(t.push({line:r,count:i}),r=n[e],i=1);t.push({line:r,count:i});let l=t;y?l=t.filter(e=>e.count>1):q&&(l=t.filter(e=>e.count===1));let c="";for(let{line:e,count:s}of l)h?c+=`${String(s).padStart(4)} ${e}
4
4
  `:c+=`${e}
5
5
  `;return{stdout:c,stderr:"",exitCode:0}}};export{P as uniqCommand};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as y}from"./chunk-45SNFRCY.js";import"./chunk-OBH7XN5N.js";import{a as g}from"./chunk-TA7RUHGQ.js";import{a as w,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var C={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"]},S={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"}},L={name:"wc",async execute(n,l){if(m(n))return w(C);let r=g("wc",n,S);if(!r.ok)return r.error;let{lines:s,words:t}=r.result.flags,e=r.result.flags.bytes||r.result.flags.chars,o=r.result.positional;!s&&!t&&!e&&(s=t=e=!0);let i=await y(l,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let f=b(i.files[0].content);return{stdout:`${h(f,s,t,e,"")}
2
+ import{a as y}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as g}from"./chunk-TA7RUHGQ.js";import{a as w,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var C={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"]},S={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"}},L={name:"wc",async execute(n,l){if(m(n))return w(C);let r=g("wc",n,S);if(!r.ok)return r.error;let{lines:s,words:t}=r.result.flags,e=r.result.flags.bytes||r.result.flags.chars,o=r.result.positional;!s&&!t&&!e&&(s=t=e=!0);let i=await y(l,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let f=b(i.files[0].content);return{stdout:`${h(f,s,t,e,"")}
3
3
  `,stderr:"",exitCode:0}}let c="",u=0,d=0,p=0;for(let{filename:f,content:x}of i.files){let a=b(x);u+=a.lines,d+=a.words,p+=a.chars,c+=`${h(a,s,t,e,f)}
4
4
  `}return o.length>1&&(c+=`${h({lines:u,words:d,chars:p},s,t,e,"total")}
5
5
  `),{stdout:c,stderr:i.stderr,exitCode:i.exitCode}}};function b(n){let l=n.length,r=0,s=0,t=!1;for(let e=0;e<l;e++){let o=n[e];o===`
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{a as $e,b as w,c as v,d as H,e as J}from"./chunk-UUQYHLBO.js";import{a as Ge}from"./chunk-QSDVMMYI.js";import{a as P}from"./chunk-ACRTDIBO.js";import"./chunk-NWWB2XRE.js";import{a as Re}from"./chunk-45SNFRCY.js";import"./chunk-OBH7XN5N.js";import{a as $,b as _}from"./chunk-GTNBSMZR.js";import{b as He,d as Je,e as ze,f as Ke}from"./chunk-KGOUQS5A.js";var Te={};Je(Te,{parseMoonblade:()=>V,parseNamedExpressions:()=>T});function T(e){let n=[],s=new W(e).tokenize(),r=0,o=()=>s[r]||{type:"eof",value:"",pos:0},a=()=>s[r++];for(;o().type!=="eof";){if(o().type===","&&n.length>0){a();continue}let d=[],u=0,p=r;for(;o().type!=="eof";){let i=o();if((i.type===","||i.type==="as")&&u===0)break;(i.type==="("||i.type==="["||i.type==="{")&&u++,(i.type===")"||i.type==="]"||i.type==="}")&&u--,d.push(a())}d.push({type:"eof",value:"",pos:0});let h=new U(d).parse(),c;if(o().type==="as")if(a(),o().type==="("){a();let i=[];for(;o().type!==")"&&o().type!=="eof";)(o().type==="ident"||o().type==="string")&&(i.push(o().value),a()),o().type===","&&a();o().type===")"&&a(),c=i}else if(o().type==="ident"||o().type==="string")c=o().value,a();else throw new Error(`Expected name after 'as', got ${o().type}`);else c=e.slice(s[p].pos,s[r-1]?.pos||e.length).trim(),h.type==="identifier"&&(c=h.name);n.push({expr:h,name:c})}return n}function V(e){let t=new W(e).tokenize();return new U(t).parse()}var W,O,U,j=He(()=>{"use strict";W=class{input;pos=0;tokens=[];constructor(n){this.input=n}tokenize(){for(;this.pos<this.input.length&&(this.skipWhitespace(),!(this.pos>=this.input.length));){let n=this.nextToken();n&&this.tokens.push(n)}return this.tokens.push({type:"eof",value:"",pos:this.pos}),this.tokens}skipWhitespace(){for(;this.pos<this.input.length;){let n=this.input[this.pos];if(n===" "||n===" "||n===`
2
+ import{a as $e,b as w,c as v,d as H,e as J}from"./chunk-UUQYHLBO.js";import{a as Ge}from"./chunk-QSDVMMYI.js";import{a as P}from"./chunk-ACRTDIBO.js";import"./chunk-NWWB2XRE.js";import{a as Re}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as $,b as _}from"./chunk-GTNBSMZR.js";import{b as He,d as Je,e as ze,f as Ke}from"./chunk-KGOUQS5A.js";var Te={};Je(Te,{parseMoonblade:()=>V,parseNamedExpressions:()=>T});function T(e){let n=[],s=new W(e).tokenize(),r=0,o=()=>s[r]||{type:"eof",value:"",pos:0},a=()=>s[r++];for(;o().type!=="eof";){if(o().type===","&&n.length>0){a();continue}let d=[],u=0,p=r;for(;o().type!=="eof";){let i=o();if((i.type===","||i.type==="as")&&u===0)break;(i.type==="("||i.type==="["||i.type==="{")&&u++,(i.type===")"||i.type==="]"||i.type==="}")&&u--,d.push(a())}d.push({type:"eof",value:"",pos:0});let h=new U(d).parse(),c;if(o().type==="as")if(a(),o().type==="("){a();let i=[];for(;o().type!==")"&&o().type!=="eof";)(o().type==="ident"||o().type==="string")&&(i.push(o().value),a()),o().type===","&&a();o().type===")"&&a(),c=i}else if(o().type==="ident"||o().type==="string")c=o().value,a();else throw new Error(`Expected name after 'as', got ${o().type}`);else c=e.slice(s[p].pos,s[r-1]?.pos||e.length).trim(),h.type==="identifier"&&(c=h.name);n.push({expr:h,name:c})}return n}function V(e){let t=new W(e).tokenize();return new U(t).parse()}var W,O,U,j=He(()=>{"use strict";W=class{input;pos=0;tokens=[];constructor(n){this.input=n}tokenize(){for(;this.pos<this.input.length&&(this.skipWhitespace(),!(this.pos>=this.input.length));){let n=this.nextToken();n&&this.tokens.push(n)}return this.tokens.push({type:"eof",value:"",pos:this.pos}),this.tokens}skipWhitespace(){for(;this.pos<this.input.length;){let n=this.input[this.pos];if(n===" "||n===" "||n===`
3
3
  `||n==="\r")this.pos++;else if(n==="#")for(;this.pos<this.input.length&&this.input[this.pos]!==`
4
4
  `;)this.pos++;else break}}nextToken(){let n=this.pos,t=this.input[this.pos];if(t>="0"&&t<="9")return this.readNumber();if(t==='"'||t==="'"||t==="`")return this.readString(t);if(t==="b"&&this.pos+1<this.input.length){let r=this.input[this.pos+1];if(r==='"'||r==="'"||r==="`")return this.pos++,this.readString(r)}if(t==="/"){let r=this.tokens[this.tokens.length-1];return r&&(r.type==="int"||r.type==="float"||r.type==="string"||r.type==="ident"||r.type===")"||r.type==="]")?this.input[this.pos+1]==="/"?(this.pos+=2,{type:"//",value:"//",pos:n}):(this.pos++,{type:"/",value:"/",pos:n}):this.readRegex()}if(this.match("not in"))return{type:"not in",value:"not in",pos:n};if(this.match("=>"))return{type:"=>",value:"=>",pos:n};if(this.match("**"))return{type:"**",value:"**",pos:n};if(this.match("++"))return{type:"++",value:"++",pos:n};if(this.match("//"))return{type:"//",value:"//",pos:n};if(this.match("=="))return{type:"==",value:"==",pos:n};if(this.match("!="))return{type:"!=",value:"!=",pos:n};if(this.match("<="))return{type:"<=",value:"<=",pos:n};if(this.match(">="))return{type:">=",value:">=",pos:n};if(this.match("&&"))return{type:"&&",value:"&&",pos:n};if(this.match("||"))return{type:"||",value:"||",pos:n};let s={"(":"(",")":")","[":"[","]":"]","{":"{","}":"}",",":",",":":":",";":";","+":"+","-":"-","*":"*","%":"%","<":"<",">":">","!":"!",".":".","|":"|","=":"="};if(t in s)return this.pos++,{type:s[t],value:t,pos:n};if(this.isIdentStart(t))return this.readIdentifier();throw new Error(`Unexpected character '${t}' at position ${this.pos}`)}match(n){if(this.input.slice(this.pos,this.pos+n.length)===n){if(/^[a-zA-Z]/.test(n)){let t=this.input[this.pos+n.length];if(t&&this.isIdentChar(t))return!1}return this.pos+=n.length,!0}return!1}isIdentStart(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"||n==="_"}isIdentChar(n){return this.isIdentStart(n)||n>="0"&&n<="9"}readNumber(){let n=this.pos,t=!1,s=!1;for(;this.pos<this.input.length;){let o=this.input[this.pos];if(o>="0"&&o<="9")this.pos++;else if(o==="_")this.pos++;else if(o==="."&&!t&&!s)t=!0,this.pos++;else if((o==="e"||o==="E")&&!s)s=!0,t=!0,this.pos++,this.pos<this.input.length&&(this.input[this.pos]==="+"||this.input[this.pos]==="-")&&this.pos++;else break}let r=this.input.slice(n,this.pos).replace(/_/g,"");return{type:t?"float":"int",value:r,pos:n}}readString(n){let t=this.pos;this.pos++;let s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r===n)return this.pos++,{type:"string",value:s,pos:t};if(r==="\\"){if(this.pos++,this.pos<this.input.length){let o=this.input[this.pos];switch(o){case"n":s+=`
5
5
  `;break;case"r":s+="\r";break;case"t":s+=" ";break;case"\\":s+="\\";break;case'"':s+='"';break;case"'":s+="'";break;case"`":s+="`";break;case"0":s+="\0";break;default:s+=o}this.pos++}}else s+=r,this.pos++}throw new Error(`Unterminated string starting at position ${t}`)}readRegex(){let n=this.pos;this.pos++;let t="",s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r==="/"){for(this.pos++;this.pos<this.input.length&&this.input[this.pos]==="i";)s+=this.input[this.pos],this.pos++;return{type:"regex",value:t+(s?`/${s}`:""),pos:n}}r==="\\"?(t+=r,this.pos++,this.pos<this.input.length&&(t+=this.input[this.pos],this.pos++)):(t+=r,this.pos++)}throw new Error(`Unterminated regex starting at position ${n}`)}readIdentifier(){let n=this.pos;for(;this.pos<this.input.length&&this.isIdentChar(this.input[this.pos]);)this.pos++;let t=!1;this.pos<this.input.length&&this.input[this.pos]==="?"&&(t=!0,this.pos++);let s=this.input.slice(n,t?this.pos-1:this.pos);t&&(s+="?");let r={true:"true",false:"false",null:"null",and:"and",or:"or",eq:"eq",ne:"ne",lt:"lt",le:"le",gt:"gt",ge:"ge",in:"in",as:"as",_:"_"},o=s.replace(/\?$/,"");return o in r&&!t?{type:r[o],value:o,pos:n}:{type:"ident",value:s,pos:n}}},O={PIPE:1,OR:2,AND:3,EQUALITY:4,COMPARISON:5,ADDITIVE:6,MULTIPLICATIVE:7,POWER:8,UNARY:9,POSTFIX:10},U=class{pos=0;tokens;constructor(n){this.tokens=n}parse(){let n=this.parseExpr(0);if(this.peek().type!=="eof")throw new Error(`Unexpected token: ${this.peek().value}`);return n}parseExpr(n){let t=this.parsePrefix();for(;;){let s=this.peek(),r=this.getInfixPrec(s.type);if(r<n)break;t=this.parseInfix(t,r)}return t}parsePrefix(){let n=this.peek();switch(n.type){case"int":return this.advance(),{type:"int",value:Number.parseInt(n.value,10)};case"float":return this.advance(),{type:"float",value:Number.parseFloat(n.value)};case"string":return this.advance(),{type:"string",value:n.value};case"regex":{this.advance();let t=n.value.split("/"),s=t.length>1?t[t.length-1]:"";return{type:"regex",pattern:t.slice(0,-1).join("/")||n.value,caseInsensitive:s.includes("i")}}case"true":return this.advance(),{type:"bool",value:!0};case"false":return this.advance(),{type:"bool",value:!1};case"null":return this.advance(),{type:"null"};case"_":return this.advance(),{type:"underscore"};case"ident":{let t=n.value,s=t.endsWith("?"),r=s?t.slice(0,-1):t;if(this.advance(),this.peek().type==="(")return this.parseFunctionCall(r);if(this.peek().type==="=>"){this.advance();let o=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:[r],body:o},[r])}return{type:"identifier",name:r,unsure:s}}case"(":{this.advance();let t=[];if(this.peek().type===")"){if(this.advance(),this.peek().type==="=>"){this.advance();let r=this.parseExpr(0);return{type:"lambda",params:[],body:r}}throw new Error("Empty parentheses not allowed")}if(this.peek().type==="ident"){let r=this.peek().value;if(this.advance(),this.peek().type===","||this.peek().type===")"){for(t.push(r);this.peek().type===","&&(this.advance(),this.peek().type==="ident");)t.push(this.peek().value),this.advance();if(this.peek().type===")"&&(this.advance(),this.peek().type==="=>")){this.advance();let o=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:t,body:o},t)}this.pos-=t.length*2,t.length>1&&(this.pos=this.pos)}this.pos--}let s=this.parseExpr(0);return this.expect(")"),this.peek().type,s}case"[":return this.parseList();case"{":return this.parseMap();case"-":{this.advance();let t=this.parseExpr(O.UNARY);return t.type==="int"?{type:"int",value:-t.value}:t.type==="float"?{type:"float",value:-t.value}:{type:"func",name:"neg",args:[{expr:t}]}}case"!":return this.advance(),{type:"func",name:"not",args:[{expr:this.parseExpr(O.UNARY)}]};default:throw new Error(`Unexpected token: ${n.type} (${n.value})`)}}parseFunctionCall(n){this.expect("(");let t=[];if(this.peek().type!==")")do{t.length>0&&this.peek().type===","&&this.advance();let s;if(this.peek().type==="ident"){let o=this.peek().value,a=this.pos+1;a<this.tokens.length&&this.tokens[a].type==="="&&(s=o,this.advance(),this.advance())}let r=this.parseExpr(0);t.push({name:s,expr:r})}while(this.peek().type===",");return this.expect(")"),{type:"func",name:n.toLowerCase(),args:t}}parseList(){this.expect("[");let n=[];if(this.peek().type!=="]")do n.length>0&&this.peek().type===","&&this.advance(),n.push(this.parseExpr(0));while(this.peek().type===",");return this.expect("]"),{type:"list",elements:n}}parseMap(){this.expect("{");let n=[];if(this.peek().type!=="}")do{n.length>0&&this.peek().type===","&&this.advance();let t;if(this.peek().type==="ident")t=this.peek().value,this.advance();else if(this.peek().type==="string")t=this.peek().value,this.advance();else throw new Error(`Expected map key, got ${this.peek().type}`);this.expect(":");let s=this.parseExpr(0);n.push({key:t,value:s})}while(this.peek().type===",");return this.expect("}"),{type:"map",entries:n}}parseInfix(n,t){let s=this.peek(),r={"+":"add","-":"sub","*":"mul","/":"div","//":"idiv","%":"mod","**":"pow","++":"concat","==":"==","!=":"!=","<":"<","<=":"<=",">":">",">=":">=",eq:"eq",ne:"ne",lt:"lt",le:"le",gt:"gt",ge:"ge","&&":"and",and:"and","||":"or",or:"or"};if(s.type in r){this.advance();let o=this.parseExpr(t+(this.isRightAssoc(s.type)?0:1));return{type:"func",name:r[s.type],args:[{expr:n},{expr:o}]}}if(s.type==="|"){this.advance();let o=this.parseExpr(t);return this.handlePipe(n,o)}if(s.type===".")return this.advance(),this.handleDot(n);if(s.type==="[")return this.advance(),this.handleIndexing(n);if(s.type==="in")return this.advance(),{type:"func",name:"contains",args:[{expr:this.parseExpr(t+1)},{expr:n}]};if(s.type==="not in")return this.advance(),{type:"func",name:"not",args:[{expr:{type:"func",name:"contains",args:[{expr:this.parseExpr(t+1)},{expr:n}]}}]};throw new Error(`Unexpected infix token: ${s.type}`)}handlePipe(n,t){if(t.type==="identifier")return{type:"func",name:t.name,args:[{expr:n}]};if(t.type==="func"){let s=this.countUnderscores(t);return s===0?t:s===1?this.fillUnderscore(t,n):{type:"pipeline",exprs:[n,t]}}return this.countUnderscores(t)===1?this.fillUnderscore(t,n):t}handleDot(n){let t=this.peek();if(t.type==="ident"){let s=t.value;if(this.advance(),this.peek().type==="("){let r=this.parseFunctionCall(s);return r.type==="func"&&r.args.unshift({expr:n}),r}return{type:"func",name:"get",args:[{expr:n},{expr:{type:"string",value:s}}]}}if(t.type==="int"){let s=Number.parseInt(t.value,10);return this.advance(),{type:"func",name:"get",args:[{expr:n},{expr:{type:"int",value:s}}]}}if(t.type==="string"){let s=t.value;return this.advance(),{type:"func",name:"get",args:[{expr:n},{expr:{type:"string",value:s}}]}}throw new Error(`Expected identifier, number, or string after dot, got ${t.type}`)}handleIndexing(n){if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:n}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:n},{expr:{type:"int",value:0}},{expr:s}]}}let t=this.parseExpr(0);if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:n},{expr:t}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:n},{expr:t},{expr:s}]}}return this.expect("]"),{type:"func",name:"get",args:[{expr:n},{expr:t}]}}countUnderscores(n){return n.type==="underscore"?1:n.type==="func"?n.args.reduce((t,s)=>t+this.countUnderscores(s.expr),0):n.type==="list"?n.elements.reduce((t,s)=>t+this.countUnderscores(s),0):n.type==="map"?n.entries.reduce((t,s)=>t+this.countUnderscores(s.value),0):0}fillUnderscore(n,t){return n.type==="underscore"?t:n.type==="func"?{...n,args:n.args.map(s=>({...s,expr:this.fillUnderscore(s.expr,t)}))}:n.type==="list"?{...n,elements:n.elements.map(s=>this.fillUnderscore(s,t))}:n.type==="map"?{...n,entries:n.entries.map(s=>({...s,value:this.fillUnderscore(s.value,t)}))}:n}bindLambdaArgs(n,t){return{...n,body:this.bindLambdaArgsInExpr(n.body,t)}}bindLambdaArgsInExpr(n,t){return n.type==="identifier"&&t.includes(n.name)?{type:"lambdaBinding",name:n.name}:n.type==="func"?{...n,args:n.args.map(s=>({...s,expr:this.bindLambdaArgsInExpr(s.expr,t)}))}:n.type==="list"?{...n,elements:n.elements.map(s=>this.bindLambdaArgsInExpr(s,t))}:n.type==="map"?{...n,entries:n.entries.map(s=>({...s,value:this.bindLambdaArgsInExpr(s.value,t)}))}:n}getInfixPrec(n){switch(n){case"|":return O.PIPE;case"||":case"or":return O.OR;case"&&":case"and":return O.AND;case"==":case"!=":case"eq":case"ne":return O.EQUALITY;case"<":case"<=":case">":case">=":case"lt":case"le":case"gt":case"ge":case"in":case"not in":return O.COMPARISON;case"+":case"-":case"++":return O.ADDITIVE;case"*":case"/":case"//":case"%":return O.MULTIPLICATIVE;case"**":return O.POWER;case".":case"[":return O.POSTFIX;default:return-1}}isRightAssoc(n){return n==="**"}peek(){return this.tokens[this.pos]||{type:"eof",value:"",pos:0}}advance(){return this.tokens[this.pos++]}expect(n){let t=this.peek();if(t.type!==n)throw new Error(`Expected ${n}, got ${t.type}`);return this.advance()}}});j();function N(e,n){return n.length===0?I(e,[]):n.length===1?{type:"Pipe",left:n[0],right:I(e,[])}:{type:"Pipe",left:n[0],right:I(e,n.slice(1))}}var De={add:e=>b("+",e[0],e[1]),sub:e=>b("-",e[0],e[1]),mul:e=>b("*",e[0],e[1]),div:e=>b("/",e[0],e[1]),mod:e=>b("%",e[0],e[1]),idiv:e=>I("floor",[b("/",e[0],e[1])]),pow:e=>N("pow",e),neg:e=>({type:"UnaryOp",op:"-",operand:e[0]}),"==":e=>b("==",e[0],e[1]),"!=":e=>b("!=",e[0],e[1]),"<":e=>b("<",e[0],e[1]),"<=":e=>b("<=",e[0],e[1]),">":e=>b(">",e[0],e[1]),">=":e=>b(">=",e[0],e[1]),eq:e=>b("==",L(e[0]),L(e[1])),ne:e=>b("!=",L(e[0]),L(e[1])),lt:e=>b("<",L(e[0]),L(e[1])),le:e=>b("<=",L(e[0]),L(e[1])),gt:e=>b(">",L(e[0]),L(e[1])),ge:e=>b(">=",L(e[0]),L(e[1])),and:e=>b("and",e[0],e[1]),or:e=>b("or",e[0],e[1]),not:e=>({type:"UnaryOp",op:"not",operand:e[0]}),len:e=>N("length",e),length:e=>N("length",e),upper:e=>N("ascii_upcase",e),lower:e=>N("ascii_downcase",e),trim:e=>N("trim",e),ltrim:e=>e.length===0?I("ltrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:I("ltrimstr",[{type:"Literal",value:" "}])},rtrim:e=>e.length===0?I("rtrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:I("rtrimstr",[{type:"Literal",value:" "}])},split:e=>N("split",e),join:e=>e.length===1?I("join",[{type:"Literal",value:""}]):N("join",e),concat:e=>b("+",e[0],e[1]),startswith:e=>N("startswith",e),endswith:e=>N("endswith",e),contains:e=>N("contains",e),replace:e=>N("gsub",e),substr:e=>e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:b("+",e[1],e[2])},abs:e=>N("fabs",e),floor:e=>N("floor",e),ceil:e=>N("ceil",e),round:e=>N("round",e),sqrt:e=>N("sqrt",e),log:e=>N("log",e),log10:e=>N("log10",e),log2:e=>N("log2",e),exp:e=>N("exp",e),sin:e=>N("sin",e),cos:e=>N("cos",e),tan:e=>N("tan",e),asin:e=>N("asin",e),acos:e=>N("acos",e),atan:e=>N("atan",e),min:e=>N("min",e),max:e=>N("max",e),first:e=>e.length===0?{type:"Index",index:{type:"Literal",value:0}}:{type:"Index",index:{type:"Literal",value:0},base:e[0]},last:e=>e.length===0?{type:"Index",index:{type:"Literal",value:-1}}:{type:"Index",index:{type:"Literal",value:-1},base:e[0]},get:e=>e.length===1?{type:"Index",index:e[0]}:{type:"Index",index:e[1],base:e[0]},slice:e=>e.length===1?{type:"Slice",base:e[0]}:e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:e[2]},keys:"keys",values:"values",entries:e=>I("to_entries",e),from_entries:"from_entries",reverse:"reverse",sort:"sort",sort_by:"sort_by",group_by:"group_by",unique:"unique",unique_by:"unique_by",flatten:"flatten",map:e=>({type:"Pipe",left:e[0],right:{type:"Array",elements:e[1]}}),select:e=>I("select",e),empty:()=>I("empty",[]),count:()=>I("length",[]),sum:e=>e.length===0?I("add",[]):{type:"Pipe",left:{type:"Array",elements:e[0]},right:I("add",[])},mean:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:b("/",I("add",[]),I("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:b("/",I("add",[]),I("length",[]))},avg:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:b("/",I("add",[]),I("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:b("/",I("add",[]),I("length",[]))},type:"type",isnull:e=>e.length===0?b("==",{type:"Identity"},{type:"Literal",value:null}):b("==",e[0],{type:"Literal",value:null}),isempty:e=>e.length===0?b("==",{type:"Identity"},{type:"Literal",value:""}):b("==",e[0],{type:"Literal",value:""}),tonumber:e=>e.length===0?I("tonumber",[]):I("tonumber",e),tostring:e=>e.length===0?I("tostring",[]):I("tostring",e),if:e=>je(e[0],e[1],e[2]),coalesce:e=>{if(e.length===0)return{type:"Literal",value:null};if(e.length===1)return e[0];let[n,...t]=e,s=b("and",b("!=",n,{type:"Literal",value:null}),b("!=",n,{type:"Literal",value:""}));return je(s,n,t.length===1?t[0]:De.coalesce(t))},index:()=>({type:"Field",name:"_row_index"}),now:()=>I("now",[]),fmt:e=>I("tostring",e),format:e=>I("tostring",e)};function b(e,n,t){return{type:"BinaryOp",op:e,left:n,right:t}}function I(e,n){return{type:"Call",name:e,args:n}}var Xe="then";function je(e,n,t){let s={type:"Cond",cond:e,elifs:[],else:t||{type:"Literal",value:null}};return s[Xe]=n,s}function L(e){return{type:"Pipe",left:e,right:{type:"Call",name:"tostring",args:[]}}}function A(e,n=!0){switch(e.type){case"int":case"float":return{type:"Literal",value:e.value};case"string":return{type:"Literal",value:e.value};case"bool":return{type:"Literal",value:e.value};case"null":return{type:"Literal",value:null};case"underscore":return{type:"Index",base:{type:"Identity"},index:{type:"Literal",value:"_"}};case"identifier":return n?{type:"Field",name:e.name}:{type:"VarRef",name:e.name};case"lambdaBinding":return{type:"VarRef",name:e.name};case"func":{let t=e.args.map(r=>A(r.expr,n)),s=De[e.name];return typeof s=="function"?s(t):I(typeof s=="string"?s:e.name,t)}case"list":return e.elements.length===0?{type:"Array"}:{type:"Array",elements:e.elements.reduce((t,s,r)=>{let o=A(s,n);return r===0?o:{type:"Comma",left:t,right:o}},null)};case"map":return{type:"Object",entries:e.entries.map(t=>({key:t.key,value:A(t.value,n)}))};case"regex":return{type:"Literal",value:e.pattern};case"slice":return{type:"Slice",start:e.start?A(e.start,n):void 0,end:e.end?A(e.end,n):void 0};case"lambda":return A(e.body,n);case"pipeline":return{type:"Identity"};default:throw new Error(`Unknown moonblade expression type: ${e.type}`)}}function K(e){let n=[],t=0;for(;t<e.length;){for(;t<e.length&&(e[t]===" "||e[t]===",");)t++;if(t>=e.length)break;let s=t;for(;t<e.length&&/\w/.test(e[t]);)t++;let r=e.slice(s,t);for(;t<e.length&&e[t]===" ";)t++;if(e[t]!=="(")break;t++;let o=1,a=t;for(;t<e.length&&o>0;)e[t]==="("?o++:e[t]===")"&&o--,o>0&&t++;let d=e.slice(a,t).trim();for(t++;t<e.length&&e[t]===" ";)t++;let u="";if(e.slice(t,t+3).toLowerCase()==="as "){for(t+=3;t<e.length&&e[t]===" ";)t++;let p=t;for(;t<e.length&&/\w/.test(e[t]);)t++;u=e.slice(p,t)}u||(u=d?`${r}(${d})`:`${r}()`),n.push({func:r,expr:d,alias:u})}return n}function Ve(e){return/^\w+$/.test(e)}function z(e,n,t){let s=A(V(n)),r=P(e,s,t);return r.length>0?r[0]:null}function G(e,n,t={}){let{func:s,expr:r}=n;if(s==="count"&&!r)return e.length;let o;switch(Ve(r)?o=e.map(a=>a[r]).filter(a=>a!=null):o=e.map(a=>z(a,r,t)).filter(a=>a!=null),s){case"count":return Ve(r)?o.length:o.filter(a=>!!a).length;case"sum":return o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d))).reduce((d,u)=>d+u,0);case"mean":case"avg":{let a=o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d)));return a.length>0?a.reduce((d,u)=>d+u,0)/a.length:0}case"min":{let a=o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d)));return a.length>0?Math.min(...a):null}case"max":{let a=o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d)));return a.length>0?Math.max(...a):null}case"first":return o.length>0?o[0]:null;case"last":return o.length>0?o[o.length-1]:null;case"median":{let a=o.map(u=>typeof u=="number"?u:Number.parseFloat(String(u))).filter(u=>!Number.isNaN(u)).sort((u,p)=>u-p);if(a.length===0)return null;let d=Math.floor(a.length/2);return a.length%2===0?(a[d-1]+a[d])/2:a[d]}case"mode":{let a=new Map;for(let p of o){let l=String(p);a.set(l,(a.get(l)||0)+1)}let d=0,u=null;for(let[p,l]of a)l>d&&(d=l,u=p);return u}case"cardinality":return new Set(o.map(d=>String(d))).size;case"values":return o.map(a=>String(a)).join("|");case"distinct_values":return[...new Set(o.map(d=>String(d)))].sort().join("|");case"all":{if(e.length===0)return!0;for(let a of e)if(!z(a,r,t))return!1;return!0}case"any":{for(let a of e)if(z(a,r,t))return!0;return!1}default:return null}}function We(e,n,t={}){let s={};for(let r of n)s[r.alias]=G(e,r,t);return s}async function X(e,n){let t="",s=[];for(let l of e)l.startsWith("-")||(t?s.push(l):t=l);if(!t)return{stdout:"",stderr:`xan agg: no aggregation expression