@preventive/triage 1.0.0-alpha.16 → 1.0.0-alpha.18
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.
- package/common/server-info.ts +4 -4
- package/out/client-managed.js +55 -39
- package/out/client-sync.js +14 -14
- package/out/graph.js +10 -10
- package/out/index.html +1 -0
- package/out/terminal.js +227 -220
- package/out/view.css +1 -1
- package/out/view.js +160 -130
- package/package.json +6 -6
- package/server-e2e/index.ts +8 -1
- package/server-e2e/static.ts +11 -17
- package/out/provider-icons/claude.svg +0 -1
- package/out/provider-icons/deepseek.svg +0 -1
- package/out/provider-icons/google.svg +0 -1
- package/out/provider-icons/grok.svg +0 -1
- package/out/provider-icons/moonshot.svg +0 -1
- package/out/provider-icons/nvidia.svg +0 -1
- package/out/provider-icons/openai.svg +0 -1
- package/out/provider-icons/openrouter.svg +0 -1
- package/out/provider-icons/qwen.svg +0 -1
- package/out/provider-icons/zai.svg +0 -1
package/out/terminal.js
CHANGED
|
@@ -1,147 +1,154 @@
|
|
|
1
|
-
var
|
|
1
|
+
var wm=Object.defineProperty;var ym=(e,t)=>{for(var n in t)wm(e,n,{get:t[n],enumerable:!0})};var na=globalThis[Symbol.for("@rray/frontend")];if(!na)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:ra,html:De,nothing:Qo,unsafeCSS:oa,render:VE,StateElement:KE,classMap:JE,repeat:ia,styleMap:QE}=na;var F=(e="")=>({stdout:e,stderr:"",exitCode:0}),x=(e,t=1)=>({stdout:"",stderr:e.endsWith(`
|
|
2
2
|
`)?e:e+`
|
|
3
|
-
`,exitCode:t}),de=(e,t=1)=>y(`usage: ${e}`,t);var Gu=Symbol("unsupported");function O(e){if(e==null)return null;try{return e[Gu]??null}catch{return null}}function k(e,t,n,r,i=1){return re(y(r,i),e,t,n,r)}function re(e,t,n,r,i){return Object.defineProperty(e,Gu,{value:{kind:t,command:n,detail:r,message:i},enumerable:!1,configurable:!0}),e}function Y(e,t,n,r){let i=O(e);return i?k(i.kind,t,i.detail,n,r):y(n,r)}var w=class extends Error{constructor(t,n,r){super(r),this.name="UnsupportedError",re(this,t,null,n,r)}};function zi(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let i=JSON.stringify([n.kind,r,n.detail]);e.has(i)||(e.add(i),t.push(Object.freeze(n)))}}}var{Buffer:Xu}=globalThis,Yu=Xu&&!Xu.TYPED_ARRAY_SUPPORT;var Zu=e=>e&&(Yu||`${e}`.includes("[native code]"));!Yu&&Zu(()=>{})&&(Zu=()=>!1);function Hi(e,t){let n=e.length;for(let r=0;r<n;r++)t[r]=e.charCodeAt(r);return t}var gn=null,wn=!1,Vu=!1,qe=new TextEncoder,We=new TextDecoder("utf-8",{ignoreBOM:!0}),Gi=new TextDecoder("latin1",{ignoreBOM:!0});var Xi=globalThis.Buffer;function kr(e){if(!(e&&e instanceof Uint8Array))throw new TypeError("Expected an Uint8Array")}var vr="Input is not a string",Zi="Input is not well-formed Unicode";function Nt(e,t){switch(t){case"uint8":if(e.constructor!==Uint8Array)throw new Error("Unexpected");return e;case"arraybuffer":if(e.byteLength!==e.buffer.byteLength)throw new Error("Unexpected");return e.buffer;case"buffer":return e.length<=64?Xi.from(e):Xi.from(e.buffer,e.byteOffset,e.byteLength)}throw new TypeError("Unexpected format")}function Ku(e,t){switch(t){case"uint8":return e.length<=64||e.byteOffset!==0||e.byteLength!==e.buffer.byteLength?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case"arraybuffer":return e.buffer.byteLength===e.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);case"buffer":if(e.constructor!==Xi)throw new Error("Unexpected");return e}throw new TypeError("Unexpected format")}var jh=We,zh=We?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):null,{isWellFormed:Qu}=String.prototype;function Hh(e,t,n){if(t||e.length===n.length)return n;if(Qu){if(Qu.call(e))return n;throw new TypeError(Zi)}let r=0,i=n.length-3;for(;r<=i;){let o=n.indexOf(239,r);if(o===-1||o>i)break;if(r=o+1,n[o+1]===191&&n[o+2]===189){if(null)try{if(encodeURI(e)!==null)return n}catch{}else if(e===Yi(n))return n;throw new TypeError(Zi)}}return n}function ea(e,t=!1){if(typeof e!="string")throw new TypeError(vr);return e.length===0?new Uint8Array:qe||!null?Hh(e,t,qe.encode(e)):null(e,t)}function Yi(e,t=!1){return kr(e),e.byteLength===0?"":We||!null?t?jh.decode(e):zh.decode(e):null(e,t)}var ta=(e,t="uint8")=>Nt(ea(e,!1),t),A=(e,t="uint8")=>Nt(ea(e,!0),t),Vi=e=>Yi(e,!1),na=e=>Yi(e,!0);function q(e){try{return ta(e)}catch(t){throw t instanceof TypeError?new w("feature","unpaired surrogate","unpaired UTF-16 surrogates cannot be encoded as UTF-8"):t}}var Gh=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Sr(e){for(let t=0;t<e.length;){let n=Gh(e[t]),r=n===1?e[t]:n===0?-1:Zh(e,t,n);yield r,t+=r<0?1:n}}var Xh=[0,0,128,2048,65536];function Zh(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let i=1;i<n;i++){if((e[t+i]&192)!==128)return-1;r=r<<6|e[t+i]&63}return r<Xh[n]||r>1114111||r>=55296&&r<=57343?-1:r}var Ki=e=>na(e);function pt(e){let t;try{t=Vi(e)}catch{}return t}function P(e){try{return Vi(e)}catch{throw new w("feature","partial UTF-8 byte sequence","byte output that is not valid UTF-8 cannot be represented by this string-based terminal")}}function ra(e){if(Object.keys(e).length>0)throw new TypeError("Unexpected extra options")}var h$=Object.getPrototypeOf(Uint8Array);var oa=globalThis.atob,sa=Uint8Array.prototype.toBase64,ia=8192,Yh=sa&&oa;function Ji(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return"";if(Yh&&r>=256&&r<1e8&&e.toBase64===sa&&e.BYTES_PER_ELEMENT===1){let o=t===0&&n===e.length?e:e.subarray(t,n);return oa(o.toBase64())}if(r>ia){let o="";for(let s=t;s<n;){let u=Math.min(n,s+ia);o+=String.fromCharCode.apply(String,e.subarray(s,u)),s=u}return o}let i=t===0&&n===e.length?e:e.subarray(t,n);return String.fromCharCode.apply(String,i)}var ua=gn?e=>e.byteLength>=768&&!Vu?gn.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):We.decode(e):Gi?e=>Gi.decode(e):e=>Ji(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var aa=e=>Hi(e,new Uint8Array(e.length)),Vh=wn&&qe?.encodeInto,la=Vh?(e,t)=>{let n=new Uint8Array(e.length+4),r=qe.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw new SyntaxError(t);return n.subarray(0,e.length)}:gn?(e,t)=>{let n=gn.from(e,"utf8");if(n.length!==e.length)throw new SyntaxError(t);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}:(e,t)=>{let n=qe.encode(e);if(n.length!==e.length)throw new SyntaxError(t);return n};var no={};Bh(no,{E_CHAR:()=>Ht,E_LAST:()=>Qi,E_LENGTH:()=>ma,E_PADDING:()=>ha,fromBase64:()=>to,toBase64:()=>eo});var fa=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],ca=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],da={},pa={},Ht="Invalid character in base64 input",ha="Invalid base64 padding",ma="Invalid base64 length",Qi="Invalid last chunk";function eo(e,t,n){let r=e.length/3|0,i=r*3,o="",s=0,u=t?ca:fa,a=t?pa:da;if(!a.pairs)if(a.pairs=[],We){a.codepairs=new Uint16Array(4096);let h=a.codepairs,m=new Uint8Array(h.buffer,h.byteOffset,h.byteLength);for(let g=0;g<64;g++){let b=u[g].charCodeAt(0);for(let x=0;x<64;x++)m[g<<7|x<<1]=m[x<<7|(g<<1)+1]=b}}else{let h=a.pairs;for(let m=0;m<64;m++)for(let g=0;g<64;g++)h.push(`${u[m]}${u[g]}`)}let{pairs:l,codepairs:f}=a;if(We){let h=new Uint16Array(r*2),m=0;for(let g=e.length-11;s<g;s+=12,m+=8){let b=e[s],x=e[s+1],S=e[s+2],E=e[s+3],M=e[s+4],D=e[s+5],T=e[s+6],ne=e[s+7],Le=e[s+8],z=e[s+9],ce=e[s+10],zt=e[s+11];h[m]=f[b<<4|x>>4],h[m+1]=f[(x&15)<<8|S],h[m+2]=f[E<<4|M>>4],h[m+3]=f[(M&15)<<8|D],h[m+4]=f[T<<4|ne>>4],h[m+5]=f[(ne&15)<<8|Le],h[m+6]=f[z<<4|ce>>4],h[m+7]=f[(ce&15)<<8|zt]}for(let g=e.length-2;s<g;s+=3,m+=2){let b=e[s],x=e[s+1],S=e[s+2];h[m]=f[b<<4|x>>4],h[m+1]=f[(x&15)<<8|S]}o=ua(h)}else for(;s<i;s+=3){let h=e[s],m=e[s+1],g=e[s+2];o+=l[h<<4|m>>4],o+=l[(m&15)<<8|g]}let c=0,d=2,p=e.length;for(;s<p;s++){let h=e[s];o+=u[c|h>>d],d===6&&(d=0,o+=u[h&63]),c=h<<6-d&63,d+=2}return d!==2&&(o+=u[c]),n&&(o+=["","==","="][p-i]),o}var Kh=qe?128:65536;function to(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,i=n%4,o=n-i;if(i===1)throw new SyntaxError(ma);if(r>3||r!==0&&e.length%4!==0)throw new SyntaxError(ha);let s=t?ca:fa,u=t?pa:da;u.fromMap||(u.fromMap=new Int8Array(Kh).fill(-1),s.forEach((h,m)=>u.fromMap[h.charCodeAt(0)]=m));let a=u.fromMap,l=new Uint8Array(Math.floor(n*3/4)),f=0,c=0;if(qe){let h=la(e,Ht);for(;c<o;c+=4){let m=h[c],g=h[c+1],b=h[c+2],x=h[c+3],S=a[m]<<18|a[g]<<12|a[b]<<6|a[x];if(S<0)throw new SyntaxError(Ht);l[f]=S>>16,l[f+1]=S>>8&255,l[f+2]=S&255,f+=3}}else for(;c<o;c+=4){let h=e.charCodeAt(c),m=e.charCodeAt(c+1),g=e.charCodeAt(c+2),b=e.charCodeAt(c+3),x=a[h]<<18|a[m]<<12|a[g]<<6|a[b];if(x<0)throw new SyntaxError(Ht);l[f]=x>>16,l[f+1]=x>>8&255,l[f+2]=x&255,f+=3}if(i<2)return l;let d=a[e.charCodeAt(c++)]<<6|a[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(Ht);if(l[f++]=d>>4,i<3){if(d&15)throw new SyntaxError(Qi);return l}let p=a[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(Ht);if(l[f++]=d<<4&255|p>>2,p&3)throw new SyntaxError(Qi);return l}var{Buffer:At,atob:ya,btoa:xa}=globalThis,ka=At&&!At.TYPED_ARRAY_SUPPORT,{toBase64:ga}=Uint8Array.prototype,{E_CHAR:bn,E_PADDING:$r,E_LENGTH:Jh,E_LAST:Qh}=no,em=xa&&wn,tm=ya&&wn,nm=e=>e.constructor===At&&At.isBuffer(e),rm=e=>nm(e)?e:At.from(e.buffer,e.byteOffset,e.byteLength);function ro(e,t){if(t)return e;let n=e.indexOf("=",e.length-3);return n===-1?e:e.slice(0,n)}function im(e,t){return t&&e.length%4!==0?e+"=".repeat(4-e.length%4):e}var om=e=>ga&&e.toBase64===ga;function io(e,{padding:t=!0}={}){return kr(e),om(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):ka?ro(rm(e).base64Slice(0,e.byteLength),t):em?ro(xa(Ji(e)),t):eo(e,!1,t)}function xn(e,t){if(typeof t=="string"&&(t={format:t}),!t)return wa(e,!1,"both","uint8",null);let{format:n="uint8",padding:r="both",...i}=t;return wa(e,!1,r,n,i)}function wa(e,t,n,r,i){if(typeof e!="string")throw new TypeError(vr);i!==null&&ra(i);let o=n==="both"?e.endsWith("="):void 0;if(n===!0||o===!0){if(e.length%4!==0)throw new SyntaxError($r);if(e[e.length-3]==="=")throw new SyntaxError($r)}else if(n===!1||o===!1){if(e.length%4===1)throw new SyntaxError(Jh);if(n===!1&&e.endsWith("="))throw new SyntaxError("Did not expect padding in base64 input")}else throw new TypeError("Invalid padding option");return yn(e,t,n,r)}var sm=/[\t\n\f\r ]/;function ba(e,t){let n=e.indexOf("=",e.length-3),r=n>=0?e.length-n:0,i=e.length-r,o=i%4,s=t.length-(i-o)/4*3;return o===0&&s===0||o===2&&s===1||o===3&&s===2}var yn;Uint8Array.fromBase64?yn=(e,t,n,r)=>{let i=t?"base64url":"base64",o;if(n===!0)o=Uint8Array.fromBase64(e,{alphabet:i,lastChunkHandling:"strict"});else try{let s=e.length%4>0?`${e}${"=".repeat(4-e.length%4)}`:e;o=Uint8Array.fromBase64(s,{alphabet:i,lastChunkHandling:"strict"})}catch(s){throw sm.test(e)?new SyntaxError(bn):s}if(!ba(e,o))throw new SyntaxError(bn);return Nt(o,r)}:ka?yn=(e,t,n,r)=>{let i=At.byteLength(e,"base64"),o=At.allocUnsafeSlow(i);if(o.base64Write(e)!==i)throw new SyntaxError($r);let s=t?ro(e,n===!1):im(e,n!==!0),u=t?o.base64urlSlice(0,o.length):o.base64Slice(0,o.length);if(s!==u)throw new SyntaxError($r);return Ku(o,r)}:tm?yn=(e,t,n,r)=>{let i;if(t){if(/[\t\n\f\r +/]/.test(e))throw new SyntaxError(bn);e=e.replaceAll("-","+").replaceAll("_","/")}try{i=aa(ya(e))}catch{throw new SyntaxError(bn)}if(!t&&!ba(e,i))throw new SyntaxError(bn);if(i.length%3!==0){let o=io(i.subarray(-(i.length%3))),s=e.length%4===0?e.slice(-4):e.slice(-(e.length%4)).padEnd(4,"=");if(o!==s)throw new SyntaxError(Qh)}return Nt(i,r)}:yn=(e,t,n,r)=>Nt(to(e,t),r);function kn(e){let t=e.startsWith("/"),n=e.split("/").filter(Boolean),r=[];for(let i of n)if(i!=="."){if(i===".."){r.length>0&&r.at(-1)!==".."?r.pop():t||r.push("..");continue}r.push(i)}return t?"/"+r.join("/"):r.length===0?".":r.join("/")}function G(e,t){return t.startsWith("/")?kn(t):kn(e+"/"+t)}var um=40,Er=(e,t)=>e.isLink?.(t)===!0;function v(e,t,n,{follow:r=!0}={}){let i=je(e,t,n,{follow:r});return i.error?{path:null,error:i.error}:t.endsWith("/")&&!n.isDir(i.path)?{path:null,error:"Not a directory"}:{path:i.path,error:null}}function je(e,t,n,{follow:r=!0,lenient:i=!1}={}){if(t===""||t.includes("\0"))return{path:"/",error:"No such file or directory",rest:[]};let o=(t.startsWith("/")?t:e+"/"+t).split("/").filter(Boolean),s=r||t.endsWith("/"),u=um,a="/";for(;o.length>0;){let f=o.shift();if(!n.isDir(a)){if(!i){let d=n.isFile(a)||Er(n,a)?"Not a directory":"No such file or directory";return{path:a,error:d,rest:[f,...o]}}f===".."?a=ge(a):f!=="."&&(a=Ae(a,f));continue}if(f===".."){a=ge(a);continue}if(f!=="."&&(a=Ae(a,f)),!Er(n,a)||n.isDir(a)||o.length===0&&!s)continue;if(u--===0)return{path:a,error:"Too many levels of symbolic links",rest:[...o]};let c=n.readLink(a);a=c.startsWith("/")?"/":ge(a),o.unshift(...c.split("/").filter(Boolean),...c.endsWith("/")?["."]:[])}let l=!n.isDir(a)&&!n.isFile(a)&&!Er(n,a);return{path:a,error:l?"No such file or directory":null,rest:[]}}var ie=(e,t,n,r=!0)=>n===""||n.includes("\0")?G(t,n):je(t,n,e,{follow:r,lenient:!0}).path;function Qe(e,t,n,r=v(e,t,n)){if(r.path!==null)return null;if(t===""||t.includes("\0")||t.endsWith("/")||r.error!=="No such file or directory")return r.error;let i=je(e,t,n);return i.rest.length>0?i.error:n.isDir(ge(i.path))?null:"Not a directory"}function ge(e){let t=kn(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return n<0?".":n===0?"/":t.slice(0,n)}function et(e){let t=kn(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return t.slice(n+1)}function B(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e.codePointAt(n)-t.codePointAt(n);return e.length-t.length}function Ae(e,t){return e==="/"?"/"+t:e+"/"+t}function ze(e,t){return e==="/"?t.slice(1):t.slice(e.length+1)}function Sa(e,t="/"){let n=new Map,r=new Map;for(let[u,a]of fm(e)){let l=String(u),f=cm(a,l);if(f===null)continue;if(l.includes("\0"))throw new TypeError("createTerminal: source paths must not contain NUL characters");let c=kn("/"+l),d=t==="/"?c:c==="/"?t:t+c;f.link===void 0?(n.set(d,f.content),r.delete(d)):(r.set(d,f.link),n.delete(d))}let i=new Map([["/",{dirs:[],files:[],links:[]}]]);va(i,t);for(let[u,a]of[["files",n],["links",r]])for(let l of a.keys()){let f=l.lastIndexOf("/"),c=l.slice(0,f)||"/";va(i,c),i.get(c)[u].push(l==="/"?"/":l.slice(f+1))}for(let u of i.values())u.dirs.sort(B),u.files.sort(B),u.links.sort(B);let o=(u,a=!1)=>{let l=n.get(u);if(!(l instanceof Nr))return l;let f;try{f=l.decode()}catch(c){if(!(c instanceof SyntaxError))throw c;if(a)return;throw new w("feature","base64 source",`${JSON.stringify(u)} declares base64 that does not decode, so its bytes cannot be read`)}return n.set(u,f),f},s={isFile:u=>n.has(u),isDir:u=>i.has(u),isLink:u=>r.has(u),readLink:u=>r.get(u),readFile:u=>{let a=o(u);return a===void 0||typeof a=="string"?a:Gt(a,JSON.stringify(u))},readBytes:(u,a=!1)=>{let l=o(u);return typeof l!="string"?l:a?A(l):q(l)},fileSize:u=>i.has(u)?void 0:r.has(u)?q(r.get(u)).length:n.has(u)?am(n.get(u)):void 0,sameFileContents:(u,a)=>lm(o(u,!0),o(a,!0)),exactBytes:u=>oo(o(u,!0)),isBytes:u=>typeof n.get(u)=="object",isEmptyFile:u=>{let a=n.get(u);return typeof a=="string"?a==="":a?.length===0},listDir:u=>{let a=i.get(u);if(!a)throw new Error(`not a directory: ${u}`);return a},walkFiles:u=>hm(s,u)};return s}var am=e=>typeof e=="string"?q(e).length:e.length,oo=e=>typeof e=="string"?e.isWellFormed()?q(e):void 0:e;function Gt(e,t,n="reading them as text"){let r=pt(e);if(r===void 0)throw new w("feature","binary file",`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var vn=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r]);function lm(e,t){return e===void 0||t===void 0?!1:typeof e=="string"&&typeof t=="string"?e===t:vn(oo(e),oo(t))}function fm(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}function cm(e,t){if(typeof e=="string")return{content:e};if(ArrayBuffer.isView(e))return{content:pm(e,t)};if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e instanceof ArrayBuffer)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(e.format!==void 0||e.data!==void 0)return{content:dm(e,t)};if(e.type===void 0&&e.target===void 0)return null;let n=JSON.stringify(t);if(e.type!=="link")throw new TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(e.type??null)}; the only declaration is { type: 'link', target }`);let{target:r}=e;if(typeof r!="string"||r===""||r.includes("\0"))throw new TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{link:r}}function dm(e,t){let n=JSON.stringify(t);if(e.format!=="base64")throw new TypeError(`createTerminal: source ${n} declares format ${JSON.stringify(e.format??null)}; the only format is { format: 'base64', data }`);if(typeof e.data!="string")throw new TypeError(`createTerminal: source ${n} must declare its base64 as a string in \`data\``);return new Nr(e.data)}var Nr=class{constructor(t){this.text=t;let n=t.endsWith("==")?2:t.endsWith("=")?1:0;this.length=Math.floor((t.length-n)*3/4)}decode(){return xn(this.text)}};function pm(e,t){if(e.BYTES_PER_ELEMENT!==1)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is a ${e[Symbol.toStringTag]??"view"}; declare a file's bytes as a Uint8Array`);return new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice()}function*Oe(e,t,n=Number.POSITIVE_INFINITY,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:"file",depth:0};return}if(!e.isDir(t)){Er(e,t)&&(yield{path:t,kind:"link",depth:0});return}let i=[{path:t,kind:"dir",depth:0}];for(;i.length;){let o=i.pop();if(yield o,o.kind!=="dir"||o.depth>=n||!r(o.path))continue;let{dirs:s,files:u,links:a=[]}=e.listDir(o.path),l=s.length-1,f=u.length-1,c=a.length-1;for(;l>=0||f>=0||c>=0;){let d=l>=0?"dir":null,p=l>=0?s[l]:null;f>=0&&(p===null||B(u[f],p)>=0)&&(d="file",p=u[f]),c>=0&&(p===null||B(a[c],p)>=0)&&(d="link",p=a[c]),d==="dir"?l--:d==="file"?f--:c--,i.push({path:Ae(o.path,p),kind:d,depth:o.depth+1})}}}function*hm(e,t){for(let n of Oe(e,t))n.kind==="file"&&(yield n.path)}function va(e,t){let n=[],r=t;for(;r!=="/"&&!e.has(r);)n.push(r),r=r.slice(0,r.lastIndexOf("/"))||"/";for(let i=n.length-1;i>=0;i--){let o=n[i];e.set(o,{dirs:[],files:[],links:[]});let s=o.lastIndexOf("/");e.get(o.slice(0,s)||"/").dirs.push(o.slice(s+1))}}var Ot={__proto__:null,alpha:"A-Za-z",digit:"0-9",alnum:"0-9A-Za-z",upper:"A-Z",lower:"a-z",space:" \\t\\n\\v\\f\\r",blank:" \\t",punct:"!-\\/:-@\\[-`{-~",xdigit:"0-9A-Fa-f",cntrl:"\\x00-\\x1F\\x7F",print:"\\x20-\\x7E",graph:"\\x21-\\x7E",word:"0-9A-Za-z_"},so={__proto__:null};for(let[e,t]of Object.entries(Ot)){let n=new RegExp(`[${t}]`,"u"),r=[];for(let i=0;i<128;i++){if(!n.test(String.fromCodePoint(i)))continue;let o=r.at(-1);o&&o[1]===i-1?o[1]=i:r.push([i,i])}so[e]=r}var Ar=32767;function $a(e,t){if(e>Ar||t!==void 0&&t>Ar)throw new Error("Regular expression too big")}function Ea(e,t,n=!1){let r=t+1;e[r]==="^"&&r++;let i=!0,o=!1;for(;r<e.length;){let s=e[r];if(s==="]"&&!i)return r;if(i=!1,s==="["&&":.=".includes(e[r+1]??"")){let l=e[r+1],f=e.indexOf(l+"]",r+2);if(f===-1)throw new Error("Unmatched [, [^, [:, [., or [=");if(l===":"&&!(e.slice(r+2,f)in Ot))throw new Error("Invalid character class name");if(l!==":"&&n&&/\P{ASCII}/u.test(e.slice(r+2,f)))throw new Error("Invalid collation character");r=f+2,o=l!==".";continue}if(s==="-"&&o&&r+1<e.length&&e[r+1]!=="]")throw new Error("Invalid range end");let u=s==="\\"&&r+1<e.length?2:1;if(e[r+u]==="-"&&e[r+u+1]!==void 0&&e[r+u+1]!=="]"){let l=r+u+1,f=e[l]==="["?e[l+1]:void 0;if(f===":"||f==="=")throw new Error("Invalid range end");let c=f==="."?e.indexOf(".]",l+2):-1;if(f==="."&&c===-1)throw new Error("Unmatched [, [^, [:, [., or [=");let d=f==="."?l+2:l+(e[l]==="\\"?1:0);if(n&&(e.codePointAt(r+u-1)>127||e.codePointAt(d)>127))throw new Error("Invalid collation character");r=c===-1?l+(e[l]==="\\"?2:1):c+2,o=!0;continue}r+=u,o=!1}throw new Error("Unmatched [, [^, [:, [., or [=")}function Xt(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let i=n.classes?n.classes.body(r[1]):Ot[r[1]];if(i===void 0){if(n?.unknown!=="empty")throw new Error(`invalid character class \`[:${r[1]}:]\``);return{body:"",end:t+r[0].length}}return{body:i,end:t+r[0].length}}var Or={alpha:"1t:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,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:-wnf:1,x4d:1:-wn5:1,x4e:1:-wn8:1,x4g:1:-wlu:1,x4h:1:-wmi:1,x4i:1:-wlx:1,x4j:1:ps:1,x4k:8:1:2,x50:1:-1c:1,x51:1:-wn7:1,x52:1:-raw:1,x53:2:1:2,x5c:1:1:1,x5i:2:1:2,x6d:1:1:1,1ee9:q:w:1,1fcw:14:14:1,1fhs:10:14:1,1fn4:b:13:1,1fng:f:13:1,1fnw:7:13:1,1fo4:2:13:1,1h1c:1f:1s:1,1jfk:w:w:1,20cg:w:w:1,2olc:y:y:1";var J="C.UTF-8",Ir="only the C.UTF-8 locale is supported",ao=e=>typeof e=="string"&&/^C\.UTF-?8$/iu.test(e),mm=new Set(["LANG","LC_ALL","LC_CTYPE"]);function Ca(e){if(e.locale===void 0||ao(e.locale))return J;throw new TypeError(`createTerminal: ${Ir} (got ${JSON.stringify(e.locale)})`)}function Fa(e,t){if(!(mm.has(e)?ao(t)||e!=="LANG"&&t==="":ao(t)||t==="C"||t==="POSIX"||t===""))throw new w("feature",e,`${e}: ${Ir}`)}var Cr=e=>e==="C"||e==="POSIX",ae=e=>Cr(e.locale);function Oa(e){let t=[],n=-1;for(let r of e.split(",")){let[i,o]=r.split(":").map(u=>parseInt(u,36)),s=n+1+i;t.push([s,s+o]),n=s+o}return t}function gm(e){let t=e.findIndex(([n])=>n>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function uo(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):e<128?"\\x"+e.toString(16).padStart(2,"0"):String.fromCodePoint(e)}var wm=e=>e.map(([t,n])=>t===n?uo(t):`${uo(t)}-${uo(n)}`).join("");function bm(e,t){let n=e.length-1,r=0;for(;r<=n;){let i=r+n>>1;if(t<e[i][0])n=i-1;else if(t>e[i][1])r=i+1;else return!0}return!1}var Fr=e=>e==="upper"||e==="lower"?"alpha":e,ym=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],It=/[\u1C80-\u1C88]/u;function Ia(e){let t=new Map;for(let n of e.split(",")){let[r,i,o,s]=n.split(":").map(u=>parseInt(u,36));for(let u=0;u<i;u++)t.set(r+u*s,r+u*s+o)}return t}var Ta=(e,t)=>({up:e,low:t,folds:new Map});function xm(){let e=new Map,t=new Map;for(let n=97;n<=122;n++)e.set(n,n-32),t.set(n-32,n);return Ta(e,t)}function km(e){let t=[];for(let[n,r]of e.sort((i,o)=>i[0]-o[0])){let i=t.at(-1);i&&n<=i[1]+1?i[1]=Math.max(i[1],r):t.push([n,r])}return t}function _a(e,t,n,r,i){let o=new Map,s=new Map,u=null,a=c=>(s.has(c)||s.set(c,n(c)),s.get(c)),l=()=>u??=i(),f={name:e,multibyte:t,ranges:a,body(c){return o.has(c)||o.set(c,r(c,a(c))),o.get(c)},has(c,d){let p=a(c);return p!==void 0&&bm(p,d)},assertions(){if(f.js)return f.js;let c=f.body("space"),d=`[${f.body("word")}]`;return f.js={__proto__:null,"<":`(?<!${d})(?=${d})`,">":`(?<=${d})(?!${d})`,boundary:`(?:(?<!${d})(?=${d})|(?<=${d})(?!${d}))`,inside:`(?:(?<=${d})(?=${d})|(?<!${d})(?!${d}))`,word:d,nonWord:`[^${f.body("word")}]`,space:`[${c}]`,nonSpace:`[^${c}]`},f.js},up:c=>l().up.get(c)??c,low:c=>l().low.get(c)??c,fold(c){let{folds:d}=l(),p=d.get(c);if(p===void 0){let h=f.up(c),m=f.low(h),g=new Set([c,h]);m!==h&&f.up(m)===h&&g.add(m);for(let b of ym)f.up(b)===h&&g.add(b);p=[...g].sort((b,x)=>b-x),d.set(c,p)}return p},foldRange(c,d){let{up:p}=l(),h=p.get(c)??c,m=p.get(d)??d;if(h>m)return null;let g=[],b=[];for(let[E,M]of p){let D=E>=h&&E<=m;D!==(M>=h&&M<=m)&&(D?g:b).push(E)}let x=[],S=h;for(let E of g.sort((M,D)=>M-D))E>S&&x.push([S,E-1]),S=E+1;return S<=m&&x.push([S,m]),km([...x,...b.map(E=>[E,E])])}};return f}var vm=_a("C",!1,e=>so[e],e=>Ot[e],xm),Sm=_a(J,!0,e=>e==="word"?gm(Oa(Or.alnum)):Object.hasOwn(Or,e)?Oa(Or[e]):void 0,(e,t)=>t===void 0?void 0:wm(t),()=>Ta(Ia(Na),Ia(Aa)));function Q(e){if(e===J)return Sm;if(Cr(e))return vm;throw new w("feature","locale",`matching in the ${e} locale is not supported`)}var oe=(1n<<63n)-1n,tt=-oe-1n,nt=(1n<<64n)-1n;function R(e,t,n,r){let i=v(e.cwd,n,e.fs,r);return L(e,t,n,i.error),i}function L(e,t,n,r){if(r!=="No such file or directory"||typeof n!="string")return;let i=n.startsWith("/"),o=i?"/":e.cwd,s=n.replace(/^\/+/u,""),u=new Set;for(let f of new Set(["/",e.mount??"/",e.home??"/"])){if(f===o)continue;let c=v(f,s,e.fs);c.error||u.add(c.path)}if(!u.size)return;let a=i?"":` from cwd ${JSON.stringify(e.cwd)}`,l=`${i?"absolute":"relative"} path ${JSON.stringify(n)} was not found${a}`;e.notes?.add(`${t}: ${l}. ${$m(e,u)}`)}function $m(e,t){let n=[...t].sort(B),r=n.map(u=>JSON.stringify(u));if(n.length===1)return`A ${e.fs.isDir(n[0])?"dir":"file"} exists at ${r[0]}.`;let o=n.every(u=>!e.fs.isDir(u)&&e.fs.isFile(u))&&n.some(u=>!e.fs.sameFileContents(n[0],u)),s=`${r.slice(0,-1).join(", ")} and ${r.at(-1)}`;return`${n.length===2?"Both":"All"} of ${s} exist${o?", and they differ in contents":""}.`}function Zt(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(".")&&e.add(G(t,r))},emit(t,n,r,i=""){ht(t,{command:n,action:"omitted",noun:["hidden entry","hidden entries"],explanation:r,context:i,paths:e})}}}var La=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function Ra(e,t){for(let n of t.split(`
|
|
4
|
-
`))
|
|
5
|
-
`){if(e==="")return[];let n=e.split(t);return n.at(-1)===""&&n.pop(),n}var
|
|
6
|
-
`)=>e.length===0?"":e.join(t)+t;function
|
|
7
|
-
`){let n=[];for(let r=0;r<e.length;){let
|
|
8
|
-
`}function Me(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let i=e.readFile(t);if(i!==void 0)return n?A(i):q(i)}function mt(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:pt(n),bytes:n}}function se(e,t,n,r,i){if(t.length===0){X(r);let o=i?.read,a=[{name:null,kind:"file",...o==="bytes"||o==="loose-bytes"?{bytes:o==="loose-bytes"?A(n):q(n)}:{content:n}}];return{inputs:a,entries:a,stderr:"",failed:!1}}return rt(e,t,r,n,i)}function Da(e,t){return e===null||e==="-"||e==="/dev/stdin"?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):"standard input":JSON.stringify(v(t.cwd,e,t.fs).path??e)}function Sn(e,t,n,r){let i=se(e,t,n,r);return{content:i.inputs.map(o=>o.content).join(""),stderr:i.stderr,failed:i.failed}}var ee=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:t.failed?1:0});function we(e,t,n=e,{max:r=1/0,digitsOnly:i=!1}={}){if(typeof e!="string"||!(i?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:y(`${t}: invalid count: ${n}`)};let o=Number(e);return o>r?{error:y(`${t}: out of range: ${n}`)}:{value:Math.min(o,Number.MAX_SAFE_INTEGER)}}function Ua(e,t){if(typeof e!="string")return{error:y(`${t}: invalid count: ${e}`)};let n=e[0]==="+"||e[0]==="-"?e[0]:"",r=n==="-"?e.slice(1):e,i=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),o=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!i&&!o)return{error:y(`${t}: invalid count: ${e}`)};let s=i?.[2]??(o?r:""),u=co(BigInt(i?.[1]??"1"),s,t,e);return u.error?u:{...u,sign:n}}function co(e,t,n,r){let i=1n;t==="b"?i=512n:t&&(i=(t.length===2?1000n:1024n)**BigInt("KMGTPEZYRQ".indexOf(t[0].toUpperCase())+1));let o=e*i;return o>nt?{error:y(`${n}: count out of range: ${r}`)}:{value:Number(o>BigInt(Number.MAX_SAFE_INTEGER)?BigInt(Number.MAX_SAFE_INTEGER):o)}}function Z(e){try{let t=e?.message;return typeof t=="string"&&t!==""?t:String(e)}catch{return"threw a value with no message"}}var it=e=>e==="/tmp"||e.startsWith("/tmp/");function Ba(e){let t=new Map,n=new Map,r=new Set(["/tmp"]),i,o=e.listDir("/"),s={dirs:[...o.dirs,"tmp"].sort(B),files:o.files,links:o.links??[]},u=Tm(r,t,n),a=u.reshaped,l=(c,d)=>{if(!c.startsWith("/tmp/"))throw new Error("writable overlay paths must start with /tmp/");t.has(c)||a(),n.delete(c),t.set(c,d)},f={observeIo:c=>{i=c},fileIdentity:c=>t.get(c),fileSize:c=>t.get(c)?.bytes.length??(n.has(c)?q(n.get(c)).length:e.fileSize(c)),readIdentity:c=>(i?.read(c),P(c.bytes)),isFile:c=>t.has(c)||e.isFile(c),isDir:c=>r.has(c)||e.isDir(c),isLink:c=>n.has(c)||e.isLink?.(c)===!0,readLink:c=>n.get(c)??e.readLink?.(c),...Am(e,t,c=>i?.read(c)),sameFileContents:(c,d)=>_m(e,t,c,d),listDir:c=>c==="/"?s:r.has(c)?u.of(c):e.listDir(c),*walkFiles(c){for(let d of Oe(f,c))d.kind==="file"&&(yield d.path)},openWritable(c,d,p=!1){let h=ie(f,c,d);if(h!=="/tmp"&&!h.startsWith("/tmp/"))return null;$n(f,c,d);let m=t.get(h);return m?p||(i?.write(m),m.bytes=new Uint8Array):(m={bytes:new Uint8Array},l(h,m)),Rm(h,m,p,()=>i?.write(m))},makeWritableDir:(c,d)=>Om(f,{dirs:r,files:t,links:n,reshaped:a},c,d),makeWritableLink:(c,d,p)=>Im(f,{links:n,reshaped:a},c,d,p),removeWritableDir:(c,d)=>Fm(f,{dirs:r,reshaped:a},c,d),copyWritable(c,d,p){let h=ie(f,c,p);if(!h.startsWith("/tmp/"))return!1;$n(f,c,p);let m=t.get(d);if(d===h||m&&m===t.get(h))throw new Error("source and destination are the same file");i?.read(m??d);let g=m?m.bytes:Me(e,d);return f.openWritable(c,p).writeBytes(g),!0},replaceWritable:(c,d,p,h)=>Cm(f,{files:t,links:n,put:l},c,d,p,h),removeWritable(c,d){let p=ie(f,c,d,!1);if(p!=="/tmp"&&!p.startsWith("/tmp/"))return!1;let h=v(c,d,f,{follow:!1});if(h.error)throw Ge(d,h.error);if(f.isDir(h.path))throw new Error(`${d}: Is a directory`);return n.delete(h.path)||t.delete(h.path),a(),!0}};return f}function Am(e,t,n){return{readFile:r=>{let i=t.get(r);return n(i??r),i?Gt(i.bytes,JSON.stringify(r)):e.readFile(r)},readBytes:(r,i=!1)=>{let o=t.get(r);return n(o??r),o?o.bytes:Me(e,r,i)},exactBytes:r=>t.get(r)?.bytes??e.exactBytes(r),isEmptyFile:r=>{let i=t.get(r);return i?i.bytes.length===0:e.isEmptyFile(r)},isBytes:r=>t.has(r)||e.isBytes?.(r)===!0}}function Om(e,t,n,r){let i=ie(e,n,r,!1);if(i!=="/tmp"&&!i.startsWith("/tmp/"))return!1;if(t.dirs.has(i))return!0;if($n(e,n,r),t.files.has(i)||t.links.has(i))throw new Error(`${r}: File exists`);return t.dirs.add(i),t.reshaped(),!0}function Im(e,t,n,r,i){let o=ie(e,n,r,!1);return o.startsWith("/tmp/")?(Lm(e,n,r),t.links.set(o,i),t.reshaped(),!0):!1}function Cm(e,t,n,r,i,o){let s=ie(e,n,r,!1),u=o===void 0?null:ie(e,n,o,!1);if(!s.startsWith("/tmp/")||u!==null&&!u.startsWith("/tmp/"))return!1;$n(e,n,r);let a=t.files.get(s),l=t.links.get(s);if(!a&&l===void 0)throw Ge(r,"No such file or directory");u!==null&&$n(e,n,o);let f={bytes:q(i)};return l===void 0?u!==null&&t.put(u,a):(t.links.delete(s),u!==null&&(t.links.set(u,l),t.files.delete(u))),t.put(s,f),!0}function Fm(e,t,n,r){let i=ie(e,n,r,!1);if(i!=="/tmp"&&!i.startsWith("/tmp/"))return!1;let o=v(n,r,e);if(o.error)throw Ge(r,o.error);if(!t.dirs.has(o.path))throw new Error(`${r}: Not a directory`);if(o.path==="/tmp")throw new Error(`${r}: Device or resource busy`);let{dirs:s,files:u,links:a}=e.listDir(o.path);if(s.length||u.length||a.length)throw new Error(`${r}: Directory not empty`);return t.dirs.delete(o.path),t.reshaped(),!0}function Tm(e,t,n){let r=new Map,i=(o,s)=>[...o].filter(u=>u.startsWith(s)&&!u.slice(s.length).includes("/")).map(u=>u.slice(s.length)).sort(B);return{reshaped:()=>{r=new Map},of(o){let s=r.get(o);if(s)return s;let u={dirs:i(e,o+"/"),files:i(t.keys(),o+"/"),links:i(n.keys(),o+"/")};return r.set(o,u),u}}}function _m(e,t,n,r){let i=t.get(n),o=t.get(r);if(!i&&!o)return e.sameFileContents(n,r);let s=(u,a)=>a?a.bytes:e.exactBytes(u);return vn(s(n,i),s(r,o))}function $n(e,t,n){let r=je(t,n,e);if(r.error===null){if(e.isDir(r.path))throw new Error(`${n}: Is a directory`);if(n.endsWith("/"))throw Ge(n,"Not a directory");return}if(r.rest.length>0||n.endsWith("/")||n.includes("\0"))throw Ge(n,r.error);if(!e.isDir(ge(r.path)))throw Ge(n,"No such file or directory")}function Lm(e,t,n){if(n===""||n.includes("\0"))throw Ge(n,"No such file or directory");let r=je(t,n,e,{follow:!1});if(r.error===null)throw Ge(n,"File exists");if(r.rest.length>0||n.endsWith("/"))throw Ge(n,r.error);if(!e.isDir(ge(r.path)))throw Ge(n,"Not a directory")}function Ge(e,t){return Object.assign(new Error(`${e}: ${t}`),{path:e,fsError:t})}function Rm(e,t,n,r){let i=0,o=s=>{let u=t.bytes,a=n?u.length:i,l=Math.max(u.length,a+s.length),f=u.buffer;f.byteLength<l&&(f=new ArrayBuffer(Math.max(l,f.byteLength*2)),new Uint8Array(f).set(u));let c=new Uint8Array(f,0,l);c.set(s,a),t.bytes=c,i=a+s.length};return{path:e,identity:t,get position(){return n?t.bytes.length:i},write(s){s!==""&&(r(),o(q(s)))},writeBytes(s){s.length!==0&&(r(),o(s))}}}var qa=["cwd","home","user","inherit"];function Wa(e,t){let n=En(t,"mount","/"),r=En(t,"home",n),i=En(t,"cwd",n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!=="/tmp/")throw new TypeError("createTerminal: writable must be '/tmp/', false, or undefined");let o=t.writable==="/tmp/";if(o&&(n==="/"||n==="/tmp"||n.startsWith("/tmp/")))throw new Error("createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'");let s=Sa(e,n);return{fs:o?Ba(s):s,cwd:i,home:r,mount:n,writable:o,locale:Ca(t)}}function ja(e,t){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`fork: options must be an object (got ${t===null?"null":Array.isArray(t)?"an array":typeof t})`);for(let n of Object.keys(t))if(!qa.includes(n))throw new Error(`fork: unknown option \`${n}\` (known: ${qa.join(", ")}; the sources, the mount, the /tmp/ overlay and the commands come from the parent)`);if(t.inherit!==void 0&&typeof t.inherit!="boolean")throw new TypeError(`fork: inherit must be true or false (got ${t.inherit===null?"null":typeof t.inherit})`);return{cwd:En(t,"cwd",e.cwd,"fork",e.cwd),home:En(t,"home",e.home,"fork",e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function En(e,t,n,r="createTerminal",i="/"){let o=e[t]===void 0?n:e[t];if(typeof o!="string"||o.includes("\0"))throw new TypeError(`${r}: ${t} must be a string without NUL characters`);return G(i,o)}function be(e,t=0,n=e.value.length){return{value:e.value.slice(t,n),mask:e.mask===null?null:e.mask.slice(t,n),...e.empty?{empty:e.empty.filter(r=>r>=t&&r<=n).map(r=>r-t)}:{}}}function Nn(e){let t=/^([A-Za-z_][A-Za-z0-9_]*)=/u.exec(e.value);return!t||e.mask!==null&&/[12]/u.test(e.mask.slice(0,t[0].length))||e.empty?.some(n=>n<t[0].length)?null:{name:t[1],end:t[0].length}}var za=(e,t)=>e.mask===null?"0":e.mask[t];function Ha(e,t=!1){let n=new Set;if(!e.value.includes("~"))return n;let r=e.value,i=u=>za(e,u)==="0",o=t?null:Nn(e)?.end??null,s=u=>t===!0||o!==null&&u>=o;for(let u=0;u<r.length;u++){let a=u===0||u===o||s(u)&&r[u-1]===":"&&i(u-1),l=s(u)||t==="parameterAssign";if(!a||r[u]!=="~"||!i(u)||!Mm(e,u,l))continue;let f=r[u+1];if(f&&f!=="/"&&f!==":"&&i(u+1))throw new w("feature","tilde prefix","named-user and directory-stack tilde prefixes are not supported");(f===void 0||i(u+1)&&(f==="/"||f===":"&&l))&&n.add(u)}return n}function Mm(e,t,n){for(let r=t;r<=e.value.length;r++){if(e.empty?.includes(r))return!1;if(r===e.value.length)return!0;if(za(e,r)!=="0")return!1;if(e.value[r]==="/"||n&&e.value[r]===":")return!0}return!0}function Ga(...e){let t="",n="",r=[];for(let i of e){for(let o of i.empty??[])r.push(t.length+o);t+=i.value,n+=i.mask??"0".repeat(i.value.length)}return{value:t,mask:e.every(i=>i.mask===null)?null:n,...r.length?{empty:r}:{}}}var Yt=64;function ot(e,t){let n="";for(let r=t+1;r<e.length;r++){let i=e[r];if(i==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(i!=="\\"){n+=i;continue}let o=e[r+1];if(o==="`")throw new w("feature","\\`","nested backtick command substitution is not supported; use `$( )` instead");if(o==="$"||o==="\\"){n+=o,r++;continue}if(o===`
|
|
9
|
-
`){r++;continue}n+=
|
|
10
|
-
`,n);return e.i=s===-1?t.length:s,!1}if(
|
|
11
|
-
`)return
|
|
12
|
-
`){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(
|
|
13
|
-
`,"");if(t.startsWith("#")&&t.length>1&&
|
|
14
|
-
`?n+=2:(t--,n++);return n}var
|
|
15
|
-
`;)f+=2;if(e[f]==="'"&&!u){let d=
|
|
16
|
-
`;)a+=2;if(e[a]!==")")throw
|
|
17
|
-
`){e.i+=2;continue}if(t==="#"){let
|
|
18
|
-
`,e.i);e.i=
|
|
19
|
-
`)return e.i++,{kind:"newline"};let n=e.line.slice(e.i,e.i+2);if(n==="<("||n===">(")throw new
|
|
20
|
-
`){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(
|
|
21
|
-
`;)e.line=e.line.slice(0,e.i+1)+e.line.slice(e.i+3),e.removed+=2}function
|
|
22
|
-
`;)t+=2;return t}function
|
|
23
|
-
`,r:"\r",t:" ",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function
|
|
24
|
-
`,r);let l=u===-1?e.length:u;if(a+=e.slice(r,l),r=l+1,
|
|
3
|
+
`,exitCode:t}),pe=(e,t=1)=>x(`usage: ${e}`,t);var sa=Symbol("unsupported");function O(e){if(e==null)return null;try{return e[sa]??null}catch{return null}}function v(e,t,n,r,o=1){return ie(x(r,o),e,t,n,r)}function ie(e,t,n,r,o){return Object.defineProperty(e,sa,{value:{kind:t,command:n,detail:r,message:o},enumerable:!1,configurable:!0}),e}function K(e,t,n,r){let o=O(e);return o?v(o.kind,t,o.detail,n,r):x(n,r)}var b=class extends Error{constructor(t,n,r){super(r),this.name="UnsupportedError",ie(this,t,null,n,r)}};function ei(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let o=JSON.stringify([n.kind,r,n.detail]);e.has(o)||(e.add(o),t.push(Object.freeze(n)))}}}var{Buffer:ua}=globalThis,la=ua&&!ua.TYPED_ARRAY_SUPPORT;var aa=e=>e&&(la||`${e}`.includes("[native code]"));!la&&aa(()=>{})&&(aa=()=>!1);function ti(e,t){let n=e.length;for(let r=0;r<n;r++)t[r]=e.charCodeAt(r);return t}var kn=null,Ot=!1,fa=!1,Ae=new TextEncoder,Oe=new TextDecoder("utf-8",{ignoreBOM:!0}),ni=new TextDecoder("latin1",{ignoreBOM:!0});var ri=globalThis.Buffer;function Zt(e){if(!(e&&e instanceof Uint8Array))throw new TypeError("Expected an Uint8Array")}var Yt="Input is not a string",oi="Input is not well-formed Unicode";function et(e,t){switch(t){case"uint8":if(e.constructor!==Uint8Array)throw new Error("Unexpected");return e;case"arraybuffer":if(e.byteLength!==e.buffer.byteLength)throw new Error("Unexpected");return e.buffer;case"buffer":return e.length<=64?ri.from(e):ri.from(e.buffer,e.byteOffset,e.byteLength)}throw new TypeError("Unexpected format")}function ca(e,t){switch(t){case"uint8":return e.length<=64||e.byteOffset!==0||e.byteLength!==e.buffer.byteLength?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case"arraybuffer":return e.buffer.byteLength===e.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);case"buffer":if(e.constructor!==ri)throw new Error("Unexpected");return e}throw new TypeError("Unexpected format")}var km=Oe,vm=Oe?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):null,{isWellFormed:pa}=String.prototype;function Sm(e,t,n){if(t||e.length===n.length)return n;if(pa){if(pa.call(e))return n;throw new TypeError(oi)}let r=0,o=n.length-3;for(;r<=o;){let i=n.indexOf(239,r);if(i===-1||i>o)break;if(r=i+1,n[i+1]===191&&n[i+2]===189){if(null)try{if(encodeURI(e)!==null)return n}catch{}else if(e===ii(n))return n;throw new TypeError(oi)}}return n}function ha(e,t=!1){if(typeof e!="string")throw new TypeError(Yt);return e.length===0?new Uint8Array:Ae||!null?Sm(e,t,Ae.encode(e)):null(e,t)}function ii(e,t=!1){return Zt(e),e.byteLength===0?"":Oe||!null?t?km.decode(e):vm.decode(e):null(e,t)}var ma=(e,t="uint8")=>et(ha(e,!1),t),A=(e,t="uint8")=>et(ha(e,!0),t),si=e=>ii(e,!1),ga=e=>ii(e,!0);function B(e){try{return ma(e)}catch(t){throw t instanceof TypeError?new b("feature","unpaired surrogate","unpaired UTF-16 surrogates cannot be encoded as UTF-8"):t}}var Em=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Nr(e){for(let t=0;t<e.length;){let n=Em(e[t]),r=n===1?e[t]:n===0?-1:Nm(e,t,n);yield r,t+=r<0?1:n}}var $m=[0,0,128,2048,65536];function Nm(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let o=1;o<n;o++){if((e[t+o]&192)!==128)return-1;r=r<<6|e[t+o]&63}return r<$m[n]||r>1114111||r>=55296&&r<=57343?-1:r}var ui=e=>ga(e);function me(e){let t;try{t=si(e)}catch{}return t}function vn(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((r,o)=>r+o.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function W(e){try{return si(e)}catch{throw new b("feature","partial UTF-8 byte sequence","byte output that is not valid UTF-8 cannot be represented by this string-based terminal")}}function Ar(e){if(Object.keys(e).length>0)throw new TypeError("Unexpected extra options")}var g$=Object.getPrototypeOf(Uint8Array);var ya=globalThis.atob,ba=Uint8Array.prototype.toBase64,wa=8192,Am=ba&&ya;function ai(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return"";if(Am&&r>=256&&r<1e8&&e.toBase64===ba&&e.BYTES_PER_ELEMENT===1){let i=t===0&&n===e.length?e:e.subarray(t,n);return ya(i.toBase64())}if(r>wa){let i="";for(let s=t;s<n;){let u=Math.min(n,s+wa);i+=String.fromCharCode.apply(String,e.subarray(s,u)),s=u}return i}let o=t===0&&n===e.length?e:e.subarray(t,n);return String.fromCharCode.apply(String,o)}var Or=kn?e=>e.byteLength>=768&&!fa?kn.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):Oe.decode(e):ni?e=>ni.decode(e):e=>ai(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var xa=e=>ti(e,new Uint8Array(e.length)),Om=Ot&&Ae?.encodeInto,Cr=Om?(e,t)=>{let n=new Uint8Array(e.length+4),r=Ae.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw new SyntaxError(t);return n.subarray(0,e.length)}:kn?(e,t)=>{let n=kn.from(e,"utf8");if(n.length!==e.length)throw new SyntaxError(t);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}:(e,t)=>{let n=Ae.encode(e);if(n.length!==e.length)throw new SyntaxError(t);return n};var di={};ym(di,{E_CHAR:()=>Vt,E_LAST:()=>li,E_LENGTH:()=>Na,E_PADDING:()=>$a,fromBase64:()=>ci,toBase64:()=>fi});var ka=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],va=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],Sa={},Ea={},Vt="Invalid character in base64 input",$a="Invalid base64 padding",Na="Invalid base64 length",li="Invalid last chunk";function fi(e,t,n){let r=e.length/3|0,o=r*3,i="",s=0,u=t?va:ka,a=t?Ea:Sa;if(!a.pairs)if(a.pairs=[],Oe){a.codepairs=new Uint16Array(4096);let h=a.codepairs,m=new Uint8Array(h.buffer,h.byteOffset,h.byteLength);for(let g=0;g<64;g++){let w=u[g].charCodeAt(0);for(let y=0;y<64;y++)m[g<<7|y<<1]=m[y<<7|(g<<1)+1]=w}}else{let h=a.pairs;for(let m=0;m<64;m++)for(let g=0;g<64;g++)h.push(`${u[m]}${u[g]}`)}let{pairs:l,codepairs:f}=a;if(Oe){let h=new Uint16Array(r*2),m=0;for(let g=e.length-11;s<g;s+=12,m+=8){let w=e[s],y=e[s+1],k=e[s+2],S=e[s+3],I=e[s+4],M=e[s+5],C=e[s+6],H=e[s+7],Y=e[s+8],D=e[s+9],de=e[s+10],Xt=e[s+11];h[m]=f[w<<4|y>>4],h[m+1]=f[(y&15)<<8|k],h[m+2]=f[S<<4|I>>4],h[m+3]=f[(I&15)<<8|M],h[m+4]=f[C<<4|H>>4],h[m+5]=f[(H&15)<<8|Y],h[m+6]=f[D<<4|de>>4],h[m+7]=f[(de&15)<<8|Xt]}for(let g=e.length-2;s<g;s+=3,m+=2){let w=e[s],y=e[s+1],k=e[s+2];h[m]=f[w<<4|y>>4],h[m+1]=f[(y&15)<<8|k]}i=Or(h)}else for(;s<o;s+=3){let h=e[s],m=e[s+1],g=e[s+2];i+=l[h<<4|m>>4],i+=l[(m&15)<<8|g]}let c=0,d=2,p=e.length;for(;s<p;s++){let h=e[s];i+=u[c|h>>d],d===6&&(d=0,i+=u[h&63]),c=h<<6-d&63,d+=2}return d!==2&&(i+=u[c]),n&&(i+=["","==","="][p-o]),i}var Cm=Ae?128:65536;function ci(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,o=n%4,i=n-o;if(o===1)throw new SyntaxError(Na);if(r>3||r!==0&&e.length%4!==0)throw new SyntaxError($a);let s=t?va:ka,u=t?Ea:Sa;u.fromMap||(u.fromMap=new Int8Array(Cm).fill(-1),s.forEach((h,m)=>u.fromMap[h.charCodeAt(0)]=m));let a=u.fromMap,l=new Uint8Array(Math.floor(n*3/4)),f=0,c=0;if(Ae){let h=Cr(e,Vt);for(;c<i;c+=4){let m=h[c],g=h[c+1],w=h[c+2],y=h[c+3],k=a[m]<<18|a[g]<<12|a[w]<<6|a[y];if(k<0)throw new SyntaxError(Vt);l[f]=k>>16,l[f+1]=k>>8&255,l[f+2]=k&255,f+=3}}else for(;c<i;c+=4){let h=e.charCodeAt(c),m=e.charCodeAt(c+1),g=e.charCodeAt(c+2),w=e.charCodeAt(c+3),y=a[h]<<18|a[m]<<12|a[g]<<6|a[w];if(y<0)throw new SyntaxError(Vt);l[f]=y>>16,l[f+1]=y>>8&255,l[f+2]=y&255,f+=3}if(o<2)return l;let d=a[e.charCodeAt(c++)]<<6|a[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(Vt);if(l[f++]=d>>4,o<3){if(d&15)throw new SyntaxError(li);return l}let p=a[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(Vt);if(l[f++]=d<<4&255|p>>2,p&3)throw new SyntaxError(li);return l}var{Buffer:Ct,atob:Ia,btoa:Ta}=globalThis,Fa=Ct&&!Ct.TYPED_ARRAY_SUPPORT,{toBase64:Aa}=Uint8Array.prototype,{E_CHAR:Sn,E_PADDING:Ir,E_LENGTH:Im,E_LAST:Tm}=di,Fm=Ta&&Ot,Lm=Ia&&Ot,_m=e=>e.constructor===Ct&&Ct.isBuffer(e),Rm=e=>_m(e)?e:Ct.from(e.buffer,e.byteOffset,e.byteLength);function pi(e,t){if(t)return e;let n=e.indexOf("=",e.length-3);return n===-1?e:e.slice(0,n)}function Mm(e,t){return t&&e.length%4!==0?e+"=".repeat(4-e.length%4):e}var Pm=e=>Aa&&e.toBase64===Aa;function hi(e,{padding:t=!0}={}){return Zt(e),Pm(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):Fa?pi(Rm(e).base64Slice(0,e.byteLength),t):Fm?pi(Ta(ai(e)),t):fi(e,!1,t)}function $n(e,t){if(typeof t=="string"&&(t={format:t}),!t)return Oa(e,!1,"both","uint8",null);let{format:n="uint8",padding:r="both",...o}=t;return Oa(e,!1,r,n,o)}function Oa(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Yt);o!==null&&Ar(o);let i=n==="both"?e.endsWith("="):void 0;if(n===!0||i===!0){if(e.length%4!==0)throw new SyntaxError(Ir);if(e[e.length-3]==="=")throw new SyntaxError(Ir)}else if(n===!1||i===!1){if(e.length%4===1)throw new SyntaxError(Im);if(n===!1&&e.endsWith("="))throw new SyntaxError("Did not expect padding in base64 input")}else throw new TypeError("Invalid padding option");return En(e,t,n,r)}var Dm=/[\t\n\f\r ]/;function Ca(e,t){let n=e.indexOf("=",e.length-3),r=n>=0?e.length-n:0,o=e.length-r,i=o%4,s=t.length-(o-i)/4*3;return i===0&&s===0||i===2&&s===1||i===3&&s===2}var En;Uint8Array.fromBase64?En=(e,t,n,r)=>{let o=t?"base64url":"base64",i;if(n===!0)i=Uint8Array.fromBase64(e,{alphabet:o,lastChunkHandling:"strict"});else try{let s=e.length%4>0?`${e}${"=".repeat(4-e.length%4)}`:e;i=Uint8Array.fromBase64(s,{alphabet:o,lastChunkHandling:"strict"})}catch(s){throw Dm.test(e)?new SyntaxError(Sn):s}if(!Ca(e,i))throw new SyntaxError(Sn);return et(i,r)}:Fa?En=(e,t,n,r)=>{let o=Ct.byteLength(e,"base64"),i=Ct.allocUnsafeSlow(o);if(i.base64Write(e)!==o)throw new SyntaxError(Ir);let s=t?pi(e,n===!1):Mm(e,n!==!0),u=t?i.base64urlSlice(0,i.length):i.base64Slice(0,i.length);if(s!==u)throw new SyntaxError(Ir);return ca(i,r)}:Lm?En=(e,t,n,r)=>{let o;if(t){if(/[\t\n\f\r +/]/.test(e))throw new SyntaxError(Sn);e=e.replaceAll("-","+").replaceAll("_","/")}try{o=xa(Ia(e))}catch{throw new SyntaxError(Sn)}if(!t&&!Ca(e,o))throw new SyntaxError(Sn);if(o.length%3!==0){let i=hi(o.subarray(-(o.length%3))),s=e.length%4===0?e.slice(-4):e.slice(-(e.length%4)).padEnd(4,"=");if(i!==s)throw new SyntaxError(Tm)}return et(o,r)}:En=(e,t,n,r)=>et(ci(e,t),r);function Nn(e){let t=e.startsWith("/"),n=e.split("/").filter(Boolean),r=[];for(let o of n)if(o!=="."){if(o===".."){r.length>0&&r.at(-1)!==".."?r.pop():t||r.push("..");continue}r.push(o)}return t?"/"+r.join("/"):r.length===0?".":r.join("/")}function Z(e,t){return t.startsWith("/")?Nn(t):Nn(e+"/"+t)}var Bm=40,Tr=(e,t)=>e.isLink?.(t)===!0;function E(e,t,n,{follow:r=!0}={}){let o=ze(e,t,n,{follow:r});return o.error?{path:null,error:o.error}:t.endsWith("/")&&!n.isDir(o.path)?{path:null,error:"Not a directory"}:{path:o.path,error:null}}function ze(e,t,n,{follow:r=!0,lenient:o=!1}={}){if(t===""||t.includes("\0"))return{path:"/",error:"No such file or directory",rest:[]};let i=(t.startsWith("/")?t:e+"/"+t).split("/").filter(Boolean),s=r||t.endsWith("/"),u=Bm,a="/";for(;i.length>0;){let f=i.shift();if(!n.isDir(a)){if(!o){let d=n.isFile(a)||Tr(n,a)?"Not a directory":"No such file or directory";return{path:a,error:d,rest:[f,...i]}}f===".."?a=ye(a):f!=="."&&(a=Te(a,f));continue}if(f===".."){a=ye(a);continue}if(f!=="."&&(a=Te(a,f)),!Tr(n,a)||n.isDir(a)||i.length===0&&!s)continue;if(u--===0)return{path:a,error:"Too many levels of symbolic links",rest:[...i]};let c=n.readLink(a);a=c.startsWith("/")?"/":ye(a),i.unshift(...c.split("/").filter(Boolean),...c.endsWith("/")?["."]:[])}let l=!n.isDir(a)&&!n.isFile(a)&&!Tr(n,a);return{path:a,error:l?"No such file or directory":null,rest:[]}}var se=(e,t,n,r=!0)=>n===""||n.includes("\0")?Z(t,n):ze(t,n,e,{follow:r,lenient:!0}).path;function tt(e,t,n,r=E(e,t,n)){if(r.path!==null)return null;if(t===""||t.includes("\0")||t.endsWith("/")||r.error!=="No such file or directory")return r.error;let o=ze(e,t,n);return o.rest.length>0?o.error:n.isDir(ye(o.path))?null:"Not a directory"}function ye(e){let t=Nn(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return n<0?".":n===0?"/":t.slice(0,n)}function nt(e){let t=Nn(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return t.slice(n+1)}function j(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e.codePointAt(n)-t.codePointAt(n);return e.length-t.length}function Te(e,t){return e==="/"?"/"+t:e+"/"+t}function He(e,t){return e==="/"?t.slice(1):t.slice(e.length+1)}function _a(e,t="/"){let n=new Map,r=new Map;for(let[u,a]of Wm(e)){let l=String(u),f=qm(a,l);if(f===null)continue;if(l.includes("\0"))throw new TypeError("createTerminal: source paths must not contain NUL characters");let c=Nn("/"+l),d=t==="/"?c:c==="/"?t:t+c;f.link===void 0?(n.set(d,f.content),r.delete(d)):(r.set(d,f.link),n.delete(d))}let o=new Map([["/",{dirs:[],files:[],links:[]}]]);La(o,t);for(let[u,a]of[["files",n],["links",r]])for(let l of a.keys()){let f=l.lastIndexOf("/"),c=l.slice(0,f)||"/";La(o,c),o.get(c)[u].push(l==="/"?"/":l.slice(f+1))}for(let u of o.values())u.dirs.sort(j),u.files.sort(j),u.links.sort(j);let i=(u,a=!1)=>{let l=n.get(u);if(!(l instanceof Fr))return l;let f;try{f=l.decode()}catch(c){if(!(c instanceof SyntaxError))throw c;if(a)return;throw new b("feature","base64 source",`${JSON.stringify(u)} declares base64 that does not decode, so its bytes cannot be read`)}return n.set(u,f),f},s={isFile:u=>n.has(u),isDir:u=>o.has(u),isLink:u=>r.has(u),readLink:u=>r.get(u),readFile:u=>{let a=i(u);return a===void 0||typeof a=="string"?a:rt(a,JSON.stringify(u))},readBytes:(u,a=!1)=>{let l=i(u);return typeof l!="string"?l:a?A(l):B(l)},fileSize:u=>o.has(u)?void 0:r.has(u)?B(r.get(u)).length:n.has(u)?Um(n.get(u)):void 0,sameFileContents:(u,a)=>jm(i(u,!0),i(a,!0)),exactBytes:u=>mi(i(u,!0)),isBytes:u=>typeof n.get(u)=="object",isEmptyFile:u=>{let a=n.get(u);return typeof a=="string"?a==="":a?.length===0},listDir:u=>{let a=o.get(u);if(!a)throw new Error(`not a directory: ${u}`);return a},walkFiles:u=>Gm(s,u)};return s}var Um=e=>typeof e=="string"?B(e).length:e.length,mi=e=>typeof e=="string"?e.isWellFormed()?B(e):void 0:e;function rt(e,t,n="reading them as text"){let r=me(e);if(r===void 0)throw new b("feature","binary file",`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var An=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r]);function jm(e,t){return e===void 0||t===void 0?!1:typeof e=="string"&&typeof t=="string"?e===t:An(mi(e),mi(t))}function Wm(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}function qm(e,t){if(typeof e=="string")return{content:e};if(ArrayBuffer.isView(e))return{content:Hm(e,t)};if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e instanceof ArrayBuffer)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(e.format!==void 0||e.data!==void 0)return{content:zm(e,t)};if(e.type===void 0&&e.target===void 0)return null;let n=JSON.stringify(t);if(e.type!=="link")throw new TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(e.type??null)}; the only declaration is { type: 'link', target }`);let{target:r}=e;if(typeof r!="string"||r===""||r.includes("\0"))throw new TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{link:r}}function zm(e,t){let n=JSON.stringify(t);if(e.format!=="base64")throw new TypeError(`createTerminal: source ${n} declares format ${JSON.stringify(e.format??null)}; the only format is { format: 'base64', data }`);if(typeof e.data!="string")throw new TypeError(`createTerminal: source ${n} must declare its base64 as a string in \`data\``);return new Fr(e.data)}var Fr=class{constructor(t){this.text=t;let n=t.endsWith("==")?2:t.endsWith("=")?1:0;this.length=Math.floor((t.length-n)*3/4)}decode(){return $n(this.text)}};function Hm(e,t){if(e.BYTES_PER_ELEMENT!==1)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is a ${e[Symbol.toStringTag]??"view"}; declare a file's bytes as a Uint8Array`);return new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice()}function*Fe(e,t,n=Number.POSITIVE_INFINITY,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:"file",depth:0};return}if(!e.isDir(t)){Tr(e,t)&&(yield{path:t,kind:"link",depth:0});return}let o=[{path:t,kind:"dir",depth:0}];for(;o.length;){let i=o.pop();if(yield i,i.kind!=="dir"||i.depth>=n||!r(i.path))continue;let{dirs:s,files:u,links:a=[]}=e.listDir(i.path),l=s.length-1,f=u.length-1,c=a.length-1;for(;l>=0||f>=0||c>=0;){let d=l>=0?"dir":null,p=l>=0?s[l]:null;f>=0&&(p===null||j(u[f],p)>=0)&&(d="file",p=u[f]),c>=0&&(p===null||j(a[c],p)>=0)&&(d="link",p=a[c]),d==="dir"?l--:d==="file"?f--:c--,o.push({path:Te(i.path,p),kind:d,depth:i.depth+1})}}}function*Gm(e,t){for(let n of Fe(e,t))n.kind==="file"&&(yield n.path)}function La(e,t){let n=[],r=t;for(;r!=="/"&&!e.has(r);)n.push(r),r=r.slice(0,r.lastIndexOf("/"))||"/";for(let o=n.length-1;o>=0;o--){let i=n[o];e.set(i,{dirs:[],files:[],links:[]});let s=i.lastIndexOf("/");e.get(i.slice(0,s)||"/").dirs.push(i.slice(s+1))}}var It={__proto__:null,alpha:"A-Za-z",digit:"0-9",alnum:"0-9A-Za-z",upper:"A-Z",lower:"a-z",space:" \\t\\n\\v\\f\\r",blank:" \\t",punct:"!-\\/:-@\\[-`{-~",xdigit:"0-9A-Fa-f",cntrl:"\\x00-\\x1F\\x7F",print:"\\x20-\\x7E",graph:"\\x21-\\x7E",word:"0-9A-Za-z_"},gi={__proto__:null};for(let[e,t]of Object.entries(It)){let n=new RegExp(`[${t}]`,"u"),r=[];for(let o=0;o<128;o++){if(!n.test(String.fromCodePoint(o)))continue;let i=r.at(-1);i&&i[1]===o-1?i[1]=o:r.push([o,o])}gi[e]=r}var Lr=32767;function Ra(e,t){if(e>Lr||t!==void 0&&t>Lr)throw new Error("Regular expression too big")}function Ma(e,t,n=!1){let r=t+1;e[r]==="^"&&r++;let o=!0,i=!1;for(;r<e.length;){let s=e[r];if(s==="]"&&!o)return r;if(o=!1,s==="["&&":.=".includes(e[r+1]??"")){let l=e[r+1],f=e.indexOf(l+"]",r+2);if(f===-1)throw new Error("Unmatched [, [^, [:, [., or [=");if(l===":"&&!(e.slice(r+2,f)in It))throw new Error("Invalid character class name");if(l!==":"&&n&&/\P{ASCII}/u.test(e.slice(r+2,f)))throw new Error("Invalid collation character");r=f+2,i=l!==".";continue}if(s==="-"&&i&&r+1<e.length&&e[r+1]!=="]")throw new Error("Invalid range end");let u=s==="\\"&&r+1<e.length?2:1;if(e[r+u]==="-"&&e[r+u+1]!==void 0&&e[r+u+1]!=="]"){let l=r+u+1,f=e[l]==="["?e[l+1]:void 0;if(f===":"||f==="=")throw new Error("Invalid range end");let c=f==="."?e.indexOf(".]",l+2):-1;if(f==="."&&c===-1)throw new Error("Unmatched [, [^, [:, [., or [=");let d=f==="."?l+2:l+(e[l]==="\\"?1:0);if(n&&(e.codePointAt(r+u-1)>127||e.codePointAt(d)>127))throw new Error("Invalid collation character");r=c===-1?l+(e[l]==="\\"?2:1):c+2,i=!0;continue}r+=u,i=!1}throw new Error("Unmatched [, [^, [:, [., or [=")}function Kt(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let o=n.classes?n.classes.body(r[1]):It[r[1]];if(o===void 0){if(n?.unknown!=="empty")throw new Error(`invalid character class \`[:${r[1]}:]\``);return{body:"",end:t+r[0].length}}return{body:o,end:t+r[0].length}}var _r={alpha:"1t:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,3:3,3:7,2:1,2:1,1:0,8:0,4:1,1:4,2:b,a:0,4:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,4:4,4:1,2:1,4:0,7:3,1:0,7:f,b:2,1:8,1:2,1:l,1:6,1:1,1:4,3:8,1:2,1:1,3:0,f:3,2:9,9:3,4:2,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,9:1,4:1,1:4,2:9,1:0,g:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:2,3:0,6:0,e:9,g:c,1:2,1:m,1:f,3:7,1:2,1:2,8:1,1:2,2:0,2:3,2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typeof e=="string"&&/^C\.UTF-?8$/iu.test(e),Xm=new Set(["LANG","LC_ALL","LC_CTYPE"]);function ja(e){if(e.locale===void 0||yi(e.locale))return ee;throw new TypeError(`createTerminal: ${Rr} (got ${JSON.stringify(e.locale)})`)}function Wa(e,t){if(!(Xm.has(e)?yi(t)||e!=="LANG"&&t==="":yi(t)||t==="C"||t==="POSIX"||t===""))throw new b("feature",e,`${e}: ${Rr}`)}var Mr=e=>e==="C"||e==="POSIX",le=e=>Mr(e.locale);function Ba(e){let t=[],n=-1;for(let r of e.split(",")){let[o,i]=r.split(":").map(u=>parseInt(u,36)),s=n+1+o;t.push([s,s+i]),n=s+i}return t}function Zm(e){let t=e.findIndex(([n])=>n>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function wi(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):e<128?"\\x"+e.toString(16).padStart(2,"0"):String.fromCodePoint(e)}var Ym=e=>e.map(([t,n])=>t===n?wi(t):`${wi(t)}-${wi(n)}`).join("");function Vm(e,t){let n=e.length-1,r=0;for(;r<=n;){let o=r+n>>1;if(t<e[o][0])n=o-1;else if(t>e[o][1])r=o+1;else return!0}return!1}var Pr=e=>e==="upper"||e==="lower"?"alpha":e,Km=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],Tt=/[\u1C80-\u1C88]/u;function Ua(e){let t=new Map;for(let n of e.split(",")){let[r,o,i,s]=n.split(":").map(u=>parseInt(u,36));for(let u=0;u<o;u++)t.set(r+u*s,r+u*s+i)}return t}var qa=(e,t)=>({up:e,low:t,folds:new Map});function Jm(){let e=new Map,t=new Map;for(let n=97;n<=122;n++)e.set(n,n-32),t.set(n-32,n);return qa(e,t)}function Qm(e){let t=[];for(let[n,r]of e.sort((o,i)=>o[0]-i[0])){let o=t.at(-1);o&&n<=o[1]+1?o[1]=Math.max(o[1],r):t.push([n,r])}return t}function za(e,t,n,r,o){let i=new Map,s=new Map,u=null,a=c=>(s.has(c)||s.set(c,n(c)),s.get(c)),l=()=>u??=o(),f={name:e,multibyte:t,ranges:a,body(c){return i.has(c)||i.set(c,r(c,a(c))),i.get(c)},has(c,d){let p=a(c);return p!==void 0&&Vm(p,d)},assertions(){if(f.js)return f.js;let c=f.body("space"),d=`[${f.body("word")}]`;return f.js={__proto__:null,"<":`(?<!${d})(?=${d})`,">":`(?<=${d})(?!${d})`,boundary:`(?:(?<!${d})(?=${d})|(?<=${d})(?!${d}))`,inside:`(?:(?<=${d})(?=${d})|(?<!${d})(?!${d}))`,word:d,nonWord:`[^${f.body("word")}]`,space:`[${c}]`,nonSpace:`[^${c}]`},f.js},up:c=>l().up.get(c)??c,low:c=>l().low.get(c)??c,fold(c){let{folds:d}=l(),p=d.get(c);if(p===void 0){let h=f.up(c),m=f.low(h),g=new Set([c,h]);m!==h&&f.up(m)===h&&g.add(m);for(let w of Km)f.up(w)===h&&g.add(w);p=[...g].sort((w,y)=>w-y),d.set(c,p)}return p},foldRange(c,d){let{up:p}=l(),h=p.get(c)??c,m=p.get(d)??d;if(h>m)return null;let g=[],w=[];for(let[S,I]of p){let M=S>=h&&S<=m;M!==(I>=h&&I<=m)&&(M?g:w).push(S)}let y=[],k=h;for(let S of g.sort((I,M)=>I-M))S>k&&y.push([k,S-1]),k=S+1;return k<=m&&y.push([k,m]),Qm([...y,...w.map(S=>[S,S])])}};return f}var e0=za("C",!1,e=>gi[e],e=>It[e],Jm),t0=za(ee,!0,e=>e==="word"?Zm(Ba(_r.alnum)):Object.hasOwn(_r,e)?Ba(_r[e]):void 0,(e,t)=>t===void 0?void 0:Ym(t),()=>qa(Ua(Pa),Ua(Da)));function re(e){if(e===ee)return t0;if(Mr(e))return e0;throw new b("feature","locale",`matching in the ${e} locale is not supported`)}var ue=(1n<<63n)-1n,ot=-ue-1n,it=(1n<<64n)-1n;function P(e,t,n,r){let o=E(e.cwd,n,e.fs,r);return R(e,t,n,o.error),o}function R(e,t,n,r){if(r!=="No such file or directory"||typeof n!="string")return;let o=n.startsWith("/"),i=o?"/":e.cwd,s=n.replace(/^\/+/u,""),u=new Set;for(let f of new Set(["/",e.mount??"/",e.home??"/"])){if(f===i)continue;let c=E(f,s,e.fs);c.error||u.add(c.path)}if(!u.size)return;let a=o?"":` from cwd ${JSON.stringify(e.cwd)}`,l=`${o?"absolute":"relative"} path ${JSON.stringify(n)} was not found${a}`;e.notes?.add(`${t}: ${l}. ${n0(e,u)}`)}function n0(e,t){let n=[...t].sort(j),r=n.map(u=>JSON.stringify(u));if(n.length===1)return`A ${e.fs.isDir(n[0])?"dir":"file"} exists at ${r[0]}.`;let i=n.every(u=>!e.fs.isDir(u)&&e.fs.isFile(u))&&n.some(u=>!e.fs.sameFileContents(n[0],u)),s=`${r.slice(0,-1).join(", ")} and ${r.at(-1)}`;return`${n.length===2?"Both":"All"} of ${s} exist${i?", and they differ in contents":""}.`}function Jt(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(".")&&e.add(Z(t,r))},emit(t,n,r,o=""){gt(t,{command:n,action:"omitted",noun:["hidden entry","hidden entries"],explanation:r,context:o,paths:e})}}}var Ha=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function Ga(e,t){for(let n of t.split(`
|
|
4
|
+
`))Ha.test(n)&&e.discarded?.add(n)}function bi(e,t,n){let r=new Map;for(let o of e){if(t.includes(o))continue;let{command:i,operand:s,reason:u}=Ha.exec(o).groups,a=/'([^']*)'$/u.exec(s)?.[1]??s;if([...n].some(f=>f.includes(JSON.stringify(a))))continue;let l=`${i}: ${u}`;r.has(l)||r.set(l,new Set),r.get(l).add(a)}return[...r].map(([o,i])=>`${o}: ${[...i].map(s=>JSON.stringify(s)).join(", ")}.`)}function Xa(e,t){return e==="status"?null:{name:t,search:e==="search"}}function Za(){let e=null,t=0;return{skip(n,r){!t&&n&&(e={...n,exitCode:r}),t++},flush(n){if(t&&e){let r=t===1?"the command":`the ${t} commands`,o=e.search&&e.exitCode===1?" A search that selects no lines exits 1, which is not a failure.":"";n.add(`${e.name}: exited ${e.exitCode}, so ${r} after && did not run.${o}`)}e=null,t=0}}}function gt(e,t){r0(e,t,t.paths.size,t.paths)}function r0(e,{command:t,action:n,noun:r,explanation:o="",context:i=""},s,u){if(!s)return;let a=s<10?": "+[...u].sort(j).map(f=>JSON.stringify(f)).join(", "):"",l=Array.isArray(r)?r[s===1?0:1]:r;e.add(`${t}: ${n} ${s} ${l}${i}${a}.${o?" "+o:""}`)}function he(e,t=`
|
|
5
|
+
`){if(e==="")return[];let n=e.split(t);return n.at(-1)===""&&n.pop(),n}var ge=(e,t=`
|
|
6
|
+
`)=>e.length===0?"":e.join(t)+t;function Ge(e,t=`
|
|
7
|
+
`){let n=[];for(let r=0;r<e.length;){let o=e.indexOf(t,r),i=o<0?e.length:o+t.length;n.push(e.slice(r,i)),r=i}return n}function q(e,t="",n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&rt(e.stdinBytes,Dr(null,e)),e.stdinLeft=t,e.stdinBytes=r}function st(e,t,n,r="",o={}){let i=[],s="",u=r,a=o.read??"text",l=a==="bytes"||a==="loose-bytes",f=l?"bytes":"content",c=p=>l?a==="loose-bytes"?A(p):B(p):p,d=(p,h)=>{if(l){p.bytes=Be(n.fs,h,a==="loose-bytes");return}if(a==="text"||n.fs.isBytes?.(h)!==!0){p.content=n.fs.readFile(h);return}p.bytes=n.fs.readBytes(h),p.content=a==="maybe-text"?me(p.bytes):void 0};for(let p of t){let h={name:p,[f]:c(""),kind:"file"},m;if(p==="/dev/stdin"&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),h[f]=c(n.stdinOrigin);else if(p==="-"||p==="/dev/stdin"){let g=u===r?n.stdinBytes??null:null;Object.assign(h,g===null?Ya(u,a,l):Va(g,a,l,e,n)),h.shared=!0,u="",q(n,"",!0)}else if(p!=="/dev/null"){let g=P(n,e,p);g.error?(h.kind="missing",m=g.error):n.fs.isDir(g.path)?(h.kind="dir",o.noRead||(m="Is a directory")):d(h,g.path)}if(i.push(h),m&&(s+=xi(e,p,m,h.kind==="dir")),h.kind!=="file"&&(o.stopOnError||h.kind==="dir"&&o.stopOnDir))break}return{inputs:i.filter(p=>p.kind==="file"),entries:i,stderr:s,failed:s!==""}}var o0={head:["cannot open '%s' for reading: %r","error reading '%s': Is a directory"],tail:["cannot open '%s' for reading: %r","error reading '%s': Is a directory"],sort:["cannot read: %s: %r","read failed: %s: Is a directory"],sed:["can't read %s: %r","read error on %s: Is a directory"],tac:["failed to open '%s' for reading: %r","%s: read error: Invalid argument"],base32:[null,"read error: Is a directory"],base64:[null,"read error: Is a directory"],uniq:[null,"error reading '%s': Is a directory"]};function xi(e,t,n,r=!1){let o=o0[e]?.[r?1:0],i=o?o.replace(/%[sr]/gu,s=>s==="%s"?t:n):`${t}: ${n}`;return`${e}: ${i}
|
|
8
|
+
`}function Be(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let o=e.readFile(t);if(o!==void 0)return n?A(o):B(o)}function wt(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:me(n),bytes:n}}function te(e,t,n,r,o){if(t.length===0){let i=r.stdinBytes??null;q(r,"",!0);let s=o?.read,u=s==="bytes"||s==="loose-bytes",a=[{name:null,kind:"file",...i===null?Ya(n,s,u):Va(i,s,u,e,r)}];return{inputs:a,entries:a,stderr:"",failed:!1}}return st(e,t,r,n,o)}var Ya=(e,t,n)=>n?{bytes:t==="loose-bytes"?A(e):B(e)}:{content:e};function Va(e,t,n,r,o){return n||t==="as-held"?{bytes:e}:t==="maybe-text"?{bytes:e,content:me(e)}:{content:rt(e,Dr(null,o))}}function Dr(e,t){return e===null||e==="-"||e==="/dev/stdin"?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):"standard input":JSON.stringify(E(t.cwd,e,t.fs).path??e)}function Ka(e,t,n,r){let o=te(e,t,n,r);return{content:o.inputs.map(i=>i.content).join(""),stderr:o.stderr,failed:o.failed}}var ne=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:t.failed?1:0});function be(e,t,n=e,{max:r=1/0,digitsOnly:o=!1}={}){if(typeof e!="string"||!(o?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:x(`${t}: invalid count: ${n}`)};let i=Number(e);return i>r?{error:x(`${t}: out of range: ${n}`)}:{value:Math.min(i,Number.MAX_SAFE_INTEGER)}}function Ja(e,t){if(typeof e!="string")return{error:x(`${t}: invalid count: ${e}`)};let n=e[0]==="+"||e[0]==="-"?e[0]:"",r=n==="-"?e.slice(1):e,o=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),i=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!o&&!i)return{error:x(`${t}: invalid count: ${e}`)};let s=o?.[2]??(i?r:""),u=ki(BigInt(o?.[1]??"1"),s,t,e);return u.error?u:{...u,sign:n}}function ki(e,t,n,r){let o=1n;t==="b"?o=512n:t&&(o=(t.length===2?1000n:1024n)**BigInt("KMGTPEZYRQ".indexOf(t[0].toUpperCase())+1));let i=e*o;return i>it?{error:x(`${n}: count out of range: ${r}`)}:{value:Number(i>BigInt(Number.MAX_SAFE_INTEGER)?BigInt(Number.MAX_SAFE_INTEGER):i)}}function V(e){try{let t=e?.message;return typeof t=="string"&&t!==""?t:String(e)}catch{return"threw a value with no message"}}var ut=e=>e==="/tmp"||e.startsWith("/tmp/");function Qa(e){let t=new Map,n=new Map,r=new Set(["/tmp"]),o,i=e.listDir("/"),s={dirs:[...i.dirs,"tmp"].sort(j),files:i.files,links:i.links??[]},u=f0(r,t,n),a=u.reshaped,l=(c,d)=>{if(!c.startsWith("/tmp/"))throw new Error("writable overlay paths must start with /tmp/");t.has(c)||a(),n.delete(c),t.set(c,d)},f={observeIo:c=>{o=c},fileIdentity:c=>t.get(c),fileSize:c=>t.get(c)?.bytes.length??(n.has(c)?B(n.get(c)).length:e.fileSize(c)),readIdentity:c=>(o?.read(c),W(c.bytes)),isFile:c=>t.has(c)||e.isFile(c),isDir:c=>r.has(c)||e.isDir(c),isLink:c=>n.has(c)||e.isLink?.(c)===!0,readLink:c=>n.get(c)??e.readLink?.(c),...i0(e,t,c=>o?.read(c)),sameFileContents:(c,d)=>c0(e,t,c,d),listDir:c=>c==="/"?s:r.has(c)?u.of(c):e.listDir(c),*walkFiles(c){for(let d of Fe(f,c))d.kind==="file"&&(yield d.path)},openWritable(c,d,p=!1){let h=se(f,c,d);if(h!=="/tmp"&&!h.startsWith("/tmp/"))return null;On(f,c,d);let m=t.get(h);return m?p||(o?.write(m),m.bytes=new Uint8Array):(m={bytes:new Uint8Array},l(h,m)),p0(h,m,p,()=>o?.write(m))},makeWritableDir:(c,d)=>s0(f,{dirs:r,files:t,links:n,reshaped:a},c,d),makeWritableLink:(c,d,p)=>u0(f,{links:n,reshaped:a},c,d,p),removeWritableDir:(c,d)=>l0(f,{dirs:r,reshaped:a},c,d),copyWritable(c,d,p){let h=se(f,c,p);if(!h.startsWith("/tmp/"))return!1;On(f,c,p);let m=t.get(d);if(d===h||m&&m===t.get(h))throw new Error("source and destination are the same file");o?.read(m??d);let g=m?m.bytes:Be(e,d);return f.openWritable(c,p).writeBytes(g),!0},replaceWritable:(c,d,p,h)=>a0(f,{files:t,links:n,put:l},c,d,p,h),removeWritable(c,d){let p=se(f,c,d,!1);if(p!=="/tmp"&&!p.startsWith("/tmp/"))return!1;let h=E(c,d,f,{follow:!1});if(h.error)throw Xe(d,h.error);if(f.isDir(h.path))throw new Error(`${d}: Is a directory`);return n.delete(h.path)||t.delete(h.path),a(),!0}};return f}function i0(e,t,n){return{readFile:r=>{let o=t.get(r);return n(o??r),o?rt(o.bytes,JSON.stringify(r)):e.readFile(r)},readBytes:(r,o=!1)=>{let i=t.get(r);return n(i??r),i?i.bytes:Be(e,r,o)},exactBytes:r=>t.get(r)?.bytes??e.exactBytes(r),isEmptyFile:r=>{let o=t.get(r);return o?o.bytes.length===0:e.isEmptyFile(r)},isBytes:r=>t.has(r)||e.isBytes?.(r)===!0}}function s0(e,t,n,r){let o=se(e,n,r,!1);if(o!=="/tmp"&&!o.startsWith("/tmp/"))return!1;if(t.dirs.has(o))return!0;if(On(e,n,r),t.files.has(o)||t.links.has(o))throw new Error(`${r}: File exists`);return t.dirs.add(o),t.reshaped(),!0}function u0(e,t,n,r,o){let i=se(e,n,r,!1);return i.startsWith("/tmp/")?(d0(e,n,r),t.links.set(i,o),t.reshaped(),!0):!1}function a0(e,t,n,r,o,i){let s=se(e,n,r,!1),u=i===void 0?null:se(e,n,i,!1);if(!s.startsWith("/tmp/")||u!==null&&!u.startsWith("/tmp/"))return!1;On(e,n,r);let a=t.files.get(s),l=t.links.get(s);if(!a&&l===void 0)throw Xe(r,"No such file or directory");u!==null&&On(e,n,i);let f={bytes:B(o)};return l===void 0?u!==null&&t.put(u,a):(t.links.delete(s),u!==null&&(t.links.set(u,l),t.files.delete(u))),t.put(s,f),!0}function l0(e,t,n,r){let o=se(e,n,r,!1);if(o!=="/tmp"&&!o.startsWith("/tmp/"))return!1;let i=E(n,r,e);if(i.error)throw Xe(r,i.error);if(!t.dirs.has(i.path))throw new Error(`${r}: Not a directory`);if(i.path==="/tmp")throw new Error(`${r}: Device or resource busy`);let{dirs:s,files:u,links:a}=e.listDir(i.path);if(s.length||u.length||a.length)throw new Error(`${r}: Directory not empty`);return t.dirs.delete(i.path),t.reshaped(),!0}function f0(e,t,n){let r=new Map,o=(i,s)=>[...i].filter(u=>u.startsWith(s)&&!u.slice(s.length).includes("/")).map(u=>u.slice(s.length)).sort(j);return{reshaped:()=>{r=new Map},of(i){let s=r.get(i);if(s)return s;let u={dirs:o(e,i+"/"),files:o(t.keys(),i+"/"),links:o(n.keys(),i+"/")};return r.set(i,u),u}}}function c0(e,t,n,r){let o=t.get(n),i=t.get(r);if(!o&&!i)return e.sameFileContents(n,r);let s=(u,a)=>a?a.bytes:e.exactBytes(u);return An(s(n,o),s(r,i))}function On(e,t,n){let r=ze(t,n,e);if(r.error===null){if(e.isDir(r.path))throw new Error(`${n}: Is a directory`);if(n.endsWith("/"))throw Xe(n,"Not a directory");return}if(r.rest.length>0||n.endsWith("/")||n.includes("\0"))throw Xe(n,r.error);if(!e.isDir(ye(r.path)))throw Xe(n,"No such file or directory")}function d0(e,t,n){if(n===""||n.includes("\0"))throw Xe(n,"No such file or directory");let r=ze(t,n,e,{follow:!1});if(r.error===null)throw Xe(n,"File exists");if(r.rest.length>0||n.endsWith("/"))throw Xe(n,r.error);if(!e.isDir(ye(r.path)))throw Xe(n,"Not a directory")}function Xe(e,t){return Object.assign(new Error(`${e}: ${t}`),{path:e,fsError:t})}function p0(e,t,n,r){let o=0,i=s=>{let u=t.bytes,a=n?u.length:o,l=Math.max(u.length,a+s.length),f=u.buffer;f.byteLength<l&&(f=new ArrayBuffer(Math.max(l,f.byteLength*2)),new Uint8Array(f).set(u));let c=new Uint8Array(f,0,l);c.set(s,a),t.bytes=c,o=a+s.length};return{path:e,identity:t,get position(){return n?t.bytes.length:o},write(s){s!==""&&(r(),i(B(s)))},writeBytes(s){s.length!==0&&(r(),i(s))}}}var el=["cwd","home","user","inherit"];function tl(e,t){let n=Cn(t,"mount","/"),r=Cn(t,"home",n),o=Cn(t,"cwd",n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!=="/tmp/")throw new TypeError("createTerminal: writable must be '/tmp/', false, or undefined");let i=t.writable==="/tmp/";if(i&&(n==="/"||n==="/tmp"||n.startsWith("/tmp/")))throw new Error("createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'");let s=_a(e,n);return{fs:i?Qa(s):s,cwd:o,home:r,mount:n,writable:i,locale:ja(t)}}function nl(e,t){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`fork: options must be an object (got ${t===null?"null":Array.isArray(t)?"an array":typeof t})`);for(let n of Object.keys(t))if(!el.includes(n))throw new Error(`fork: unknown option \`${n}\` (known: ${el.join(", ")}; the sources, the mount, the /tmp/ overlay and the commands come from the parent)`);if(t.inherit!==void 0&&typeof t.inherit!="boolean")throw new TypeError(`fork: inherit must be true or false (got ${t.inherit===null?"null":typeof t.inherit})`);return{cwd:Cn(t,"cwd",e.cwd,"fork",e.cwd),home:Cn(t,"home",e.home,"fork",e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function Cn(e,t,n,r="createTerminal",o="/"){let i=e[t]===void 0?n:e[t];if(typeof i!="string"||i.includes("\0"))throw new TypeError(`${r}: ${t} must be a string without NUL characters`);return Z(o,i)}function xe(e,t=0,n=e.value.length){return{value:e.value.slice(t,n),mask:e.mask===null?null:e.mask.slice(t,n),...e.empty?{empty:e.empty.filter(r=>r>=t&&r<=n).map(r=>r-t)}:{}}}function In(e){let t=/^([A-Za-z_][A-Za-z0-9_]*)=/u.exec(e.value);return!t||e.mask!==null&&/[12]/u.test(e.mask.slice(0,t[0].length))||e.empty?.some(n=>n<t[0].length)?null:{name:t[1],end:t[0].length}}var rl=(e,t)=>e.mask===null?"0":e.mask[t];function ol(e,t=!1){let n=new Set;if(!e.value.includes("~"))return n;let r=e.value,o=u=>rl(e,u)==="0",i=t?null:In(e)?.end??null,s=u=>t===!0||i!==null&&u>=i;for(let u=0;u<r.length;u++){let a=u===0||u===i||s(u)&&r[u-1]===":"&&o(u-1),l=s(u)||t==="parameterAssign";if(!a||r[u]!=="~"||!o(u)||!h0(e,u,l))continue;let f=r[u+1];if(f&&f!=="/"&&f!==":"&&o(u+1))throw new b("feature","tilde prefix","named-user and directory-stack tilde prefixes are not supported");(f===void 0||o(u+1)&&(f==="/"||f===":"&&l))&&n.add(u)}return n}function h0(e,t,n){for(let r=t;r<=e.value.length;r++){if(e.empty?.includes(r))return!1;if(r===e.value.length)return!0;if(rl(e,r)!=="0")return!1;if(e.value[r]==="/"||n&&e.value[r]===":")return!0}return!0}function il(...e){let t="",n="",r=[];for(let o of e){for(let i of o.empty??[])r.push(t.length+i);t+=o.value,n+=o.mask??"0".repeat(o.value.length)}return{value:t,mask:e.every(o=>o.mask===null)?null:n,...r.length?{empty:r}:{}}}var Qt=64;function at(e,t){let n="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(o!=="\\"){n+=o;continue}let i=e[r+1];if(i==="`")throw new b("feature","\\`","nested backtick command substitution is not supported; use `$( )` instead");if(i==="$"||i==="\\"){n+=i,r++;continue}if(i===`
|
|
9
|
+
`){r++;continue}n+=o}throw new Error("unterminated backtick substitution")}var sl=()=>({value:"",quoted:!1,started:!1}),ul=()=>new b("feature","command substitution depth",`command substitution nesting above ${Qt} is not supported`);function vi(e,t,n,r,o){if(r>=Qt)throw ul();let i={line:e,i:n+1,depth:r,helpers:o,parens:0,quote:null,word:sl(),command:!0,target:null,heredocs:[]};for(;i.i<e.length;)if(m0(i))return{raw:e.slice(t,i.i+1),command:e.slice(n+1,i.i)};throw i.quote?new Error(`unterminated ${i.quote==="'"?"single":"double"} quote`):new Error("unterminated command substitution")}function yt(e,t,n=!1){e.word.value+=t,e.word.quoted||=n,e.word.started=!0}function Si(e){let t=e.word;if(t.started){if(e.target)e.target.op==="heredoc"&&(e.target.delim=t.value,e.target.quotedDelim=t.quoted),e.target=null;else if(e.command&&!t.quoted){if(t.value==="case")throw new b("feature","case","`case` patterns inside command substitutions are not supported");e.command=["!","{","do","then","else","elif","if","while","until"].includes(t.value)||/^[A-Za-z_][A-Za-z0-9_]*=/u.test(t.value)}else e.command=!1;e.word=sl()}}function m0(e){let{line:t,i:n,quote:r}=e,o=t[n];if(r&&o===r)return e.quote=null,e.word.quoted=!0,e.i++,!1;if(r==="'")return yt(e,o,!0),e.i++,!1;if(o==="\\")return g0(e),!1;if(o==="$")return w0(e),!1;if(o==="`")return y0(e),!1;if(r)return yt(e,o,!0),e.i++,!1;if(o==="'"||o==='"')return e.quote=o,e.word.started=!0,e.i++,!1;if(e.command&&!e.target&&!e.word.started&&t.startsWith("[[",n)&&/[ \t\n()<>;&|]|^$/u.test(t[n+2]??"")){let s=e.helpers.readConditional(t,n,e.helpers,e.depth+e.parens+1);return e.i+=s.raw.length,e.command=!1,!1}if(o==="#"&&!e.word.started){let s=t.indexOf(`
|
|
10
|
+
`,n);return e.i=s===-1?t.length:s,!1}if(o===`
|
|
11
|
+
`)return x0(e),!1;if(o===" "||o===" ")return Si(e),e.i++,!1;let i;try{i=e.helpers.readOperator(t,n,!e.word.started)}catch(s){if(!(s instanceof b))throw s;return e.i++,!1}return i?b0(e,i):(yt(e,o),e.i++,!1)}function g0(e){let t=e.line[e.i+1];if(t===`
|
|
12
|
+
`){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(yt(e,t,!0),e.i+=2):(yt(e,"\\",!!e.quote),e.i++)}function w0(e){let{line:t,i:n}=e,r=e.helpers.skipContinuations(t,n+1);if(!e.quote&&t[r]==="'"){let s=e.helpers.decodeAnsiC(t,r+1);yt(e,s.text,!0),e.i=s.end;return}if(!e.quote&&t[r]==='"'){e.quote='"',e.word.started=!0,e.i=r+1;return}let i=e.helpers.readExpansion(t,n,e.depth+e.parens+1,e.quote==='"')?.raw??"$";yt(e,i,!!e.quote),e.i+=i.length}function y0(e){let t=e.i++;for(;e.i<e.line.length;){let n=e.line[e.i++];if(n==="`"){yt(e,e.line.slice(t,e.i),!!e.quote);return}n==="\\"&&e.i<e.line.length&&e.i++}throw new Error("unterminated backtick substitution")}function b0(e,t){Si(e);let n=t.token;if(n.kind==="paren_close"){if(e.parens===0){if(e.heredocs.length)throw new b("feature","command substitution heredoc","a command substitution heredoc must finish before its closing parenthesis");return!0}e.parens--,e.command=!1}else if(n.kind==="paren_open"){if(e.depth+ ++e.parens>=Qt)throw ul();e.command=!0}else n.kind==="redir"?(e.command=!1,n.op==="heredoc"&&e.heredocs.push(n),["dup","close"].includes(n.op)||(e.target=n)):e.command=!0;return e.i=t.end,!1}function x0(e){if(Si(e),e.heredocs.some(t=>t.delim===null))throw new Error("heredoc requires a delimiter");e.heredocs.length&&(e.i=e.helpers.readHeredocBodies(e.line,e.i,e.heredocs),e.heredocs=[]),e.command=!0,e.i++}function Ze(e){return Number.isInteger(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)}var Ue=e=>e>65535?2:1,Le=(e,t)=>Ue(e.codePointAt(t));var k0=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])(?![\s\S])/u,v0=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])/u;function Ft(e,t="unsupported or malformed parameter expansion"){return new b("feature","${",`${t}: \${${e}}`)}var Ei=e=>/^[0-9]+$/u.test(e)?e.replace(/^0+(?=[0-9])/u,""):e;function $i(e){let t=e.replaceAll(`\\
|
|
13
|
+
`,"");if(t.startsWith("#")&&t.length>1&&k0.test(t.slice(1)))return{name:Ei(t.slice(1)),operator:"length"};if(/^#[A-Za-z_0-9]/u.test(t))throw Ft(e);let n=v0.exec(t)?.[0];if(!n)throw Ft(e);let r=t.slice(n.length);if(!r)return{name:Ei(n),operator:""};if(n==="#"&&/^[%:=+/]$/u.test(r))throw Ft(e);let o=/^(?::[-+=?]|[-+=?]|##?|%%?|:|\/\/?)/u.exec(r)?.[0];if(!o)throw Ft(e);return{name:Ei(n),operator:o,word:e.slice(S0(e,n.length+o.length))}}function S0(e,t){let n=0;for(;t>0;)e[n]==="\\"&&e[n+1]===`
|
|
14
|
+
`?n+=2:(t--,n++);return n}var bt=(e,t)=>new b("feature",e,t),al=e=>{if(e>=64)throw bt("expansion depth","shell expansion nesting above 64 levels is not supported")};function ll(e,t,n,r,o,i){al(r);let s=n+1,u=null;for(let a=s;a<e.length;a++){let l=e[a];if(u==="'"){l==="'"&&(u=null);continue}if(l==="\\"){a++;continue}if(l==='"'){u=u==='"'?null:'"';continue}if(l==="'"&&!u){u="'";continue}if(l==="`")throw bt("`","command substitution (backticks) is not supported");if(l==="$"){let f=a+1;for(;e[f]==="\\"&&e[f+1]===`
|
|
15
|
+
`;)f+=2;if(e[f]==="'"&&!u){let d=i.decodeAnsiC(e,f+1),p=$i(e.slice(s,a)).operator;if(o&&/[-+?=]/u.test(p)&&/[$`"'\\}]/u.test(d.text))throw bt("${","active characters in ANSI-C quoted parameter operands are not supported");a=d.end-1;continue}let c=i.readExpansion(e,a,r+1,o||u==='"');if(c){a+=c.raw.length-1;continue}}if(l==="}"&&!u){let f=$i(e.slice(s,a));return{raw:e.slice(t,a+1),parameter:f}}}throw bt("${","unterminated parameter expansion")}function fl(e,t,n,r,o){al(r);let i=0;for(let s=n+1;s<e.length;s++){let u=e[s];if(u==="\\"){s++;continue}if(u==="$"){let l=o.readExpansion(e,s,r+1,!0);if(l){s+=l.raw.length-1;continue}}if(u==="`")throw bt("`","command substitution (backticks) is not supported");if(u==='"'||u==="'")throw bt("$((","quotes in arithmetic expressions are not supported");if(u==="("&&i++,u!==")")continue;if(i){i--;continue}let a=s+1;for(;e[a]==="\\"&&e[a+1]===`
|
|
16
|
+
`;)a+=2;if(e[a]!==")")throw bt("$((","arithmetic expansion requires a closing `))`");return{raw:e.slice(t,a+1),arithmetic:e.slice(n+1,s)}}throw bt("$((","unterminated arithmetic expansion")}var E0=/^-[abcdefghknoprstuvwxzGLNORS]$/u,$0=new Set(["=","==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]),N0=new Set(["end","&&","||",")"]),A0=/^[A-Za-z_][A-Za-z0-9_]*$/u;function Tn(e,t,n,r=0){let o={line:e,i:t+2,helpers:n,token:null,depth:0,terms:0,removed:0,expansionDepth:r};try{Ye(o,!0);let i=hl(o);return o.token.kind!=="end"&&xt(`unexpected token \`${o.token.value??o.token.kind}\``),{raw:e.slice(t,o.i+o.removed),expression:i}}catch(i){if(i instanceof b||i.conditional)throw i;xt(i.message)}}function hl(e){let t=cl(e);for(;e.token.kind==="||";)Ye(e,!0),t={kind:"or",left:t,right:cl(e)};return t}function cl(e){let t=Ni(e);for(;e.token.kind==="&&";)Ye(e,!0),t={kind:"and",left:t,right:Ni(e)};return t}function Ni(e){if(++e.terms>128)throw new b("feature","[[ complexity","conditional expressions above 128 terms are not supported");if(++e.depth>64)throw new b("feature","[[ nesting","conditional nesting above 64 levels is not supported");try{let t=e.token;if(t.kind==="("){Ye(e,!0);let o=hl(e);return e.token.kind!==")"&&xt("expected `)`"),Ye(e,!0),o}if(ml(t,"!"))return Ye(e,!0),{kind:"not",expression:Ni(e)};if(t.kind!=="word"&&xt("expected an operand"),Ye(e),!t.quoted&&E0.test(t.value)){let o=dl(e);return Ye(e,!0),{kind:"unary",op:t.value,word:o}}if(N0.has(e.token.kind))return{kind:"unary",op:"-n",word:t};let n=e.token;if((n.quoted||!$0.has(n.value))&&xt("conditional binary operator expected"),n.value==="=~")throw new b("feature","[[ =~","regular expression comparisons in [[ are not supported");Ye(e);let r=dl(e);return Ye(e,!0),{kind:"binary",op:n.value,left:t,right:r}}finally{e.depth--}}var ml=(e,t)=>e.kind==="word"&&!e.quoted&&e.value===t,xt=e=>{throw Object.assign(new Error(`[[ ${e}`),{conditional:!0})};function dl(e){return e.token.kind!=="word"&&xt("expected an operand"),e.token}function Ye(e,t=!1){if(e.token=pl(e),t)for(;e.token.kind==="newline";)e.token=pl(e)}function pl(e){for(;e.i<e.line.length;){let t=e.line[e.i];if(t===" "||t===" "){e.i++;continue}if(t==="\\"&&e.line[e.i+1]===`
|
|
17
|
+
`){e.i+=2;continue}if(t==="#"){let o=e.line.indexOf(`
|
|
18
|
+
`,e.i);e.i=o<0?e.line.length:o;continue}if(t===`
|
|
19
|
+
`)return e.i++,{kind:"newline"};let n=e.line.slice(e.i,e.i+2);if(n==="<("||n===">(")throw new b("feature",n,`process substitution (\`${n}\u2026\`) is not supported`);if(n==="&&"||n==="||")return e.i+=2,{kind:n};if("()<>;&|".includes(t))return e.i++,{kind:t,value:t};let r=O0(e);return ml(r,"]]")?{kind:"end"}:r}xt("missing `]]`")}function O0(e){let t={kind:"word",value:"",mask:"",quoted:!1,empty:[]},n=null,r=0;for(;e.i<e.line.length;){let o=e.line[e.i];if(n&&o===n){t.value.length===r&&t.empty.push(r),t.quoted=!0,n=null,e.i++;continue}if(n==="'"){_e(t,o,"1"),e.i++;continue}if(o==="\\"){C0(e,t,n);continue}if(o==="$"){if(I0(e),!n&&e.line[e.i+1]==='"'){n='"',r=t.value.length,e.i+=2;continue}T0(e,t,n);continue}if(o==="`"){let i=at(e.line,e.i);_e(t,"`",n?"2":"0"),_e(t,i.raw.slice(1),"1"),e.i+=i.raw.length;continue}if(n){_e(t,o,"2"),e.i++;continue}if(o==="'"||o==='"'){n=o,r=t.value.length,e.i++;continue}if(o==="("&&t.mask.at(-1)==="0"&&/[?*+@!]/u.test(t.value.at(-1))&&!t.empty.includes(t.value.length))throw new b("feature","[[ extglob","extended glob patterns in [[ are not supported");if(/[ \t\n()<>;&|]/u.test(o))break;_e(t,o,"0"),e.i++}return n&&xt(`unterminated ${n==="'"?"single":"double"} quote`),!t.quoted&&!/[12]/u.test(t.mask)&&(t.mask=null),t.empty.length===0&&delete t.empty,t}function _e(e,t,n,r=n!=="0"){e.value+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function C0(e,t,n){let r=e.line[e.i+1];if(r===`
|
|
20
|
+
`){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(_e(t,r,"1"),e.i+=2):(_e(t,"\\",n?"2":"1"),e.i++)}function I0(e){for(;e.line[e.i+1]==="\\"&&e.line[e.i+2]===`
|
|
21
|
+
`;)e.line=e.line.slice(0,e.i+1)+e.line.slice(e.i+3),e.removed+=2}function T0(e,t,n){let r=n?"2":"0";if(!n&&e.line[e.i+1]==="'"){let i=e.helpers.decodeAnsiC(e.line,e.i+2);i.text===""&&t.empty.push(t.value.length),_e(t,i.text,"1"),e.i=i.end;return}let o=e.helpers.readExpansion(e.line,e.i,e.expansionDepth+1,!!n);if(!o){_e(t,"$","1"),e.i++;return}if(o.command!==void 0||o.parameter!==void 0||o.arithmetic!==void 0)_e(t,"$",r),_e(t,o.raw.slice(1),"1",!1);else{let i=e.line[e.i+o.raw.length],s=A0.test(o.name)&&(i==="'"||i==='"')?"${"+o.name+"}":o.raw;_e(t,s,r)}e.i+=o.raw.length}var Lt=/^[A-Za-z_][A-Za-z0-9_]*$/u,F0=/[A-Za-z0-9_]/u,L0=/[?#@*$!0-9-]/u;function ae(e,t){for(;e[t]==="\\"&&e[t+1]===`
|
|
22
|
+
`;)t+=2;return t}function Ai(e,t,n=null){let r=s=>s<e.length&&(n===null||n[s]===n[t]);if(!r(t+1))return null;let o=e[t+1];if(L0.test(o))return{name:o,raw:e.slice(t,t+2)};if(!/[A-Za-z_]/u.test(o))return null;let i=t+2;for(;r(i)&&F0.test(e[i]);)i++;return{name:e.slice(t+1,i),raw:e.slice(t,i)}}function ft(e,t,n=0,r=!1,o={}){let i=(a,l,f,c)=>ft(a,l,f,c,o),s=ae(e,t+1),u=e[s];if(u==="("){let a=ae(e,s+1);if(e[a]==="(")return fl(e,t,a,n,{readExpansion:i});let l=vi(e,t,s,n,{readExpansion:i,decodeAnsiC:en,readHeredocBodies:Ln,readOperator:Br,readConditional:Tn,skipContinuations:ae});return o.validateSubstitution?.(l.command),l}if(u==="{")return ll(e,t,s,n,r,{readExpansion:i,decodeAnsiC:en});if(u==="[")throw new b("feature","$[","arithmetic expansion (`$[\u2026]`) is not supported");return Ai(e,t)}function yl(e,t,n={}){let r=(s,u,a,l)=>ft(s,u,a,l,n),o=ae(e,t+1),i=vi(e,t,o,0,{readExpansion:r,decodeAnsiC:en,readHeredocBodies:Ln,readOperator:Br,readConditional:Tn,skipContinuations:ae});return n.validateSubstitution?.(i.command),i}var gl={a:"\x07",b:"\b",e:"\x1B",E:"\x1B",f:"\f",n:`
|
|
23
|
+
`,r:"\r",t:" ",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function _0(e,t){for(let n=t;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==="'")return n;throw new Error("unterminated single quote")}function en(e,t){let n=_0(e,t),r=[],o=s=>{for(let u of A(s))r.push(u)};for(let s=t;s<n;s++){if(e[s]!=="\\"){let l=String.fromCodePoint(e.codePointAt(s));o(l),s+=l.length-1;continue}let u=e[s+1];if(u in gl){o(gl[u]),s++;continue}if(u==="x"&&e[s+2]==="{")throw new b("feature","ANSI-C hexadecimal escape","braced hexadecimal escapes in ANSI-C quotes are not supported");let a=/^(?:[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{1,4}|U[0-9a-fA-F]{1,8})/u.exec(e.slice(s+1,n));if(a){let l=a[0],f=/^[0-7]/u.test(l),c=f?parseInt(l,8):parseInt(l.slice(1),16);if(f||l[0]==="x")r.push(c&255);else{if(!Ze(c))throw new b("feature","ANSI-C Unicode escape","ANSI-C escapes outside Unicode scalar values are not supported");o(String.fromCodePoint(c))}s+=l.length;continue}if(u==="c"&&s+2<n){let l=e.codePointAt(s+2);if(l>127)throw new b("feature","ANSI-C control escape","ANSI-C control escapes require an ASCII character");r.push(l===63?127:l&31),s+=2,l===92&&e[s+1]==="\\"&&s++;continue}o("\\")}let i=r.indexOf(0);return{text:W(Uint8Array.from(i===-1?r:r.slice(0,i))),end:n+1}}function Br(e,t,n){let r=e[t];if(n&&/[0-9]/u.test(r)){let s="",u=t;for(;/[0-9]/u.test(e[u]??"");)s+=e[u],u=ae(e,u+1);return e[u]!==">"&&e[u]!=="<"||e[ae(e,u+1)]==="("?null:wl(e,u,Number(s))}let o=ae(e,t+1),i=e[o];switch(r){case"|":return i==="|"?lt("or",o+1):i==="&"?lt("pipe_err",o+1):lt("pipe",t+1);case"&":if(i==="&")return lt("and",o+1);if(i===">"){let s=ae(e,o+1),u=e[s]===">";return kt(1,u?"bothAppend":"both",(u?s:o)+1)}return lt("amp",t+1);case";":return i===";"?lt("dsemi",o+1):lt("semi",t+1);case"(":return lt("paren_open",t+1);case")":return lt("paren_close",t+1);case"<":case">":return wl(e,t,r==="<"?0:1);default:return null}}var R0={semi:";",dsemi:";;",pipe:"|",pipe_err:"|&",and:"&&",or:"||",amp:"&",paren_open:"(",paren_close:")"},M0={write:">",append:">>",read:"<",heredoc:"<<",herestring:"<<<",both:"&>",bothAppend:"&>>",dup:">&",close:">&-"};function Fn(e){if(e.kind==="word")return e.quoted?`"${e.value}"`:e.value;if(e.kind==="redir"){let t=M0[e.op];if(e.op==="both"||e.op==="bothAppend")return t;let n=e.fd===(e.op==="read"||e.op==="heredoc"||e.op==="herestring"?0:1)?"":String(e.fd);return e.op==="dup"?`${n}${e.fd===0?"<&":">&"}${e.toFd}`:e.op==="close"?`${n}${e.fd===0?"<&-":">&-"}`:n+t}return R0[e.kind]}var lt=(e,t)=>({token:{kind:e},end:t}),kt=(e,t,n,r)=>({token:{kind:"redir",fd:e,op:t,...r},end:n});function wl(e,t,n){let r=e[t],o=ae(e,t+1),i=e[o];if(i==="&")return P0(e,o,n,r==="<"?"<&":`${n===1&&r===">"?"":n}>&`);if(r==="<"){if(i===">")throw new b("feature","<>","read/write file redirects are not supported");if(i==="<"){let s=ae(e,o+1);if(e[s]==="<")return kt(n,"herestring",s+1);let u=e[s]==="-";return kt(n,"heredoc",(u?s:o)+1,{strip:u,delim:null,body:null})}return kt(n,"read",t+1)}return i===">"?kt(n,"append",o+1):kt(n,"write",(i==="|"?o:t)+1)}function P0(e,t,n,r){let o=ae(e,t+1),i=e[o],s=e[ae(e,o+1)],u=s===void 0||/[ \t\n|&>;()<]/u.test(s);if(/[0-9]/u.test(i??"")&&u)return kt(n,"dup",o+1,{toFd:Number(i)});if(i==="-"&&u)return kt(n,"close",o+1);throw new b("feature","redirect target",`redirect \`${r}\` requires a file descriptor number (or \`-\`) followed by a token boundary`)}function Ln(e,t,n){let r=t+1;for(let o of n){let i=[],s=!1;for(;r<e.length;){let u,a="";for(;;){u=e.indexOf(`
|
|
24
|
+
`,r);let l=u===-1?e.length:u;if(a+=e.slice(r,l),r=l+1,o.quotedDelim||u===-1||!D0(a))break;a=a.slice(0,-1)}if(u===-1&&a==="")break;if(o.strip&&(a=a.replace(/^\t+/u,"")),a===o.delim){s=!0;break}if(i.push(a),u===-1)break}o.body=i.length===0?"":i.join(`
|
|
25
25
|
`)+`
|
|
26
|
-
`,s||(
|
|
27
|
-
`)}return r-1}function
|
|
28
|
-
`){if(
|
|
29
|
-
`){e.i+=2;return}t!==void 0&&(!(e.quote||e.fragmentQuoted)||'$`"\\'.includes(t)||e.fragment&&t==="}")?(
|
|
30
|
-
`;)e.i++}function h0(e){Cn(e),e.heredocs.length>0&&(e.i=In(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!u0.has(t.kind)?e.tokens.push({kind:"semi",newline:!0}):(t?.kind==="semi"||t?.kind==="amp")&&(t.lineEnd=!0),e.i++}function Lr(e,t,n){let r={aliases:new Set(t),hasCommand:n};return xt(e,r),r.aliases}var Fn=(e,t)=>new Set([...e,...t]);function xt(e,t){let n=null;for(let r of e){let i=r.gate==="and"||r.gate==="or";if(i&&n!==null&&r.gate==="and"!=(n===0))continue;let o=i&&n===null?new Set(t.aliases):null,s=r.stages.length===1?r.stages[0]:null;n=s&&!s.isolate?m0(s,t):null,r.negate&&n!==null&&(n=+(n===0)),o&&(t.aliases=Fn(o,t.aliases),n=null)}return n}function m0(e,t){if(e.group)return xt(e.group,t);if(e.conditional)return g0(e.conditional,t);if(e.loop){if(e.loop.condition&&xt(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let i=new Set(t.aliases);xt(e.loop.body,t),t.aliases=Fn(i,t.aliases)}return null}let n=e.words[0]?.value;if(e.redirs.length===0&&(n==="true"||n==="false"))return+(n==="false");if(!["alias","unalias"].includes(n)||t.hasCommand(n))return null;let r=e.words.slice(1).map(i=>i.value);for(;r[0]?.startsWith("-")&&r[0]!=="-";){let i=r.shift();if(i==="--")break;if(!(n==="alias"?/^-p+$/u:/^-a+$/u).test(i))return null;if(n==="unalias")return t.aliases.clear(),null}for(let i of r)if(n==="unalias")t.aliases.delete(i);else{let o=i.indexOf("="),s=i.slice(0,o);o>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(s)&&t.aliases.add(s)}return null}function g0(e,t){let n=new Set;for(let r of e.branches){let i=xt(r.condition,t);if(i===0)return xt(r.body,t),t.aliases=Fn(n,t.aliases),null;if(i===null){let o={...t,aliases:new Set(t.aliases)};xt(r.body,o),n=Fn(n,o.aliases)}}return e.otherwise&&xt(e.otherwise,t),t.aliases=Fn(n,t.aliases),null}var Ye=class extends Error{constructor(t){super(t.message),this.finalError=t}},kt=e=>new Ye(new Error(e));function ye(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let n=e.read();e.raw=n.tokens,e.done=n.done}return e.raw[t]}function hl(e,t,n){let r=t.validation??new Map;return{validateSubstitution(i){r.has(i)||(vo(i,!0,e,{validation:r,syntaxOnly:!0},n),r.set(i,!0))}}}function vo(e,t,n,r,i){try{return i(_r(e,hl(n,r,i)),t,n,r)}catch(o){throw o instanceof Ye?o.finalError:o}}function w0(e,t,n,r){let i=ul(e,hl(n,{},r)),o=new Set,s=!1;return()=>{let u={aliases:o,aliasUsed:s,read:i.read,unit:!0},a=r([],t,n,u);return s=u.aliasUsed,o=Lr(a,o,n),i.reset(),{steps:a,done:u.done}}}function*ml(e,t,n,r){let i=w0(e,t,n,r);for(;;){let o;try{o=i()}catch(s){throw s instanceof Ye?s.finalError:s}if(o.steps.length>0&&(yield o.steps),o.done)return}}var b0=["elif","else","fi"];function wl(e,t){let n=[],r;do{Ve(e);let o=t(e,"then");Ve(e);let s=t(e,b0);n.push({condition:o,body:s}),r=e.raw[e.i-1].value}while(r==="elif");let i=null;return r==="else"&&(Ve(e),i=t(e,"fi")),{branches:n,otherwise:i}}function bl(e,t){let{raw:n}=e,r=e.loop;e.loop="for";let i=ye(e);if(i?.kind==="paren_open")throw new w("feature","for ((","arithmetic `for ((\u2026))` loops are not supported; use `for NAME in WORD...`");if(i===void 0||i.kind!=="word")throw new Error("for: expected a variable name");let o=i.value;if(i.quoted||!Ft.test(o))throw new Error(`for: \`${o}\` is not a valid variable name`);e.i++;let s=ye(e);s?.kind==="semi"&&e.i++;let u=ye(e);if(s?.kind==="semi"&&!s.newline&&Kt(u,"in"))throw new Error("for: unexpected `in` after `;`");if(!Kt(u,"in")){if(Kt(u,"do")||u===void 0){let d=new w("feature","for NAME; do",`\`for ${o}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${o} in WORD...\``);throw u===void 0?new Ye(d):d}throw new Error(`for: expected \`in\` after \`${o}\``)}e.i++;let a=[],l=!1;for(let d;(d=ye(e))&&d.kind!=="semi";e.i++){if(d.kind!=="word")throw new Error(`for: unexpected \`${On(d)}\` in word list`);Kt(d,"do")&&(l=!0),a.push(be(d))}n[e.i]?.kind==="semi"&&e.i++;let f=ye(e);if(!Kt(f,"do"))throw f===void 0?kt(l?"for: expected `;` or newline before `do`":"for: missing `do`"):l?new Error("for: expected `;` or newline before `do`"):new Error(`for: expected \`do\`, got \`${On(f)}\``);e.i++,Ve(e);let c={name:o,words:a,body:t(e,"done")};return e.loop=r,c}function yl(e,t,n){let r=e.loop;e.loop=t,Ve(e);let i=n(e,"do");Ve(e);let o={until:t==="until",condition:i,body:n(e,"done")};return e.loop=r,o}function xl(e,t,n){if(t.quoted||!Ft.test(t.value))throw new w("feature","function",`shell functions named \`${t.value}\` are not supported`);e.i+=2,Ve(e);let r=ye(e);if(!Kt(r,"{"))throw new w("feature","function",`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,Ve(e);let i=n(e,"}");if(!Tt(i))throw new w("feature","function",`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:i}}var Tt=e=>e.every(t=>t.stages.every(y0));function y0(e){return e.assigns.length>0||e.define?!1:e.test?Rr(e.test)&&e.redirs.every(gl):e.group?Tt(e.group):e.conditional?e.conditional.branches.every(t=>Tt(t.condition)&&Tt(t.body))&&Tt(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(Jt)&&Tt(e.loop.condition??[])&&Tt(e.loop.body):e.words.every(Jt)&&e.redirs.every(gl)}function Rr(e){return e.kind==="and"||e.kind==="or"?Rr(e.left)&&Rr(e.right):e.kind==="not"?Rr(e.expression):e.kind==="unary"?Jt(e.word):Jt(e.left)&&Jt(e.right)}var gl=e=>e.op==="text"?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||Jt(e.word);function Jt(e){for(let t=0;t<e.value.length;t++){let n=e.value[t];if((n==="$"||n==="`")&&(e.mask===null||e.mask[t]!=="1"))return!1}return!0}function Ve(e){for(let t;(t=ye(e))?.kind==="semi"&&t.newline;)e.i++}function Kt(e,t){return e!==void 0&&e.kind==="word"&&!e.quoted&&e.value===t}var Nl=(e,t=!1,n=()=>!1,r={})=>vo(e,t,n,r,Ol),Al=(e,t=!1,n=()=>!1)=>ml(e,t,n,Ol);function Ol(e,t,n,r){let i={raw:e,i:0,done:!r.read,read:r.read,unitOnly:r.unit,emptyStage:!1,writable:t,aliases:r.aliases??new Set,aliasUsed:r.aliasUsed??!1,hasCommand:n,syntaxOnly:r.syntaxOnly};try{let o=ye(i)?_t(i,null):[];if(i.emptyStage)throw new Error("empty pipeline stage");return r.aliasUsed=i.aliasUsed,r.done=i.done,o}catch(o){if(i.aliasUsed&&!(o instanceof w)){let s=new w("feature","alias expansion","alias expansion is not supported; input using aliases cannot be parsed");throw o instanceof Ye?new Ye(s):s}throw o}}function $o(e,t,n){t.stages.push(n),!Mr(n)&&!Eo(n)&&(e.emptyStage=!0)}var Eo=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,Mr=e=>e.group||e.loop||e.conditional||e.test||e.define,kl=()=>({words:[],assigns:[],redirs:[]}),So=e=>({gate:e,stages:[],negate:!1,bang:!1}),vl=(e,t)=>e.bang&&e.stages.length===0&&Qt(t)&&t.redirs.length===0,Qt=e=>!Mr(e)&&e.words.length===0&&e.assigns.length===0,x0=new Set(["for","while","until","do","done","if","{","}","!"]),k0=new Set(["then","else","elif","fi","esac","in"]),Sl=new Map([["case","`case` statements are not supported; gate on exit status with `&&` / `||` instead"],["select","`select` loops are not supported"],["function","shell functions are not supported"],["time","`time` is not supported"],["coproc","`coproc` is not supported"]]),v0=new Set(["alias","declare","typeset","local","readonly","export","eval","let"]),S0=new Set(["pipe","pipe_err","and","or","semi","amp"]),$l=new Set(["semi","amp"]);function _t(e,t){let{raw:n}=e,r=[So("first")];t===null&&(e.unit=r[0]);let i=0,o=kl();for(let s;s=ye(e);){if(s.kind==="condition"){if(!Qt(o))throw new Error("unexpected `[[`");o.test=s.expression,e.i++;continue}if(s.kind==="paren_close"){if(t!==")")throw new Error("unexpected `)`");return e.i++,El(e,r,o,t)}if(s.kind==="paren_open"){$0(e,o);continue}if(S0.has(s.kind)){if(s.kind==="pipe_err"&&(Eo(o)||Mr(o))&&o.redirs.push({fd:2,op:"dup",toFd:1}),s.kind==="semi"&&vl(r.at(-1),o)||$o(e,r.at(-1),o),s.kind==="amp"&&(r.at(-1).background=!0),o=kl(),s.kind==="and"||s.kind==="or"?r.push(So(s.kind)):$l.has(s.kind)&&r.push(So("seq")),t===null&&(s.newline||s.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=Lr(r.slice(i,-1),e.aliases,e.hasCommand),i=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(s.kind==="dsemi")throw new Error("syntax error near unexpected token `;;`");if(s.kind==="redir"){if(s.warning&&(e.unit.warnings=(e.unit.warnings??"")+s.warning),o.define)throw new w("feature","function",`\`${o.define.name}()\` with a redirect of its own is not supported`);let a=I0(e);a&&o.redirs.push(a);continue}if(o.group||o.define)throw new Error(`unexpected token after \`${o.isolate?")":"}"}\``);if(o.loop)throw new Error("unexpected token after `done`");if(o.conditional)throw new Error("unexpected token after `fi`");if(o.test)throw new Error("unexpected token after `]]`");if(!s.quoted&&o.words.length===0&&e.aliases.has(s.value)&&(e.aliasUsed=!0),!s.quoted&&Qt(o)){if(Array.isArray(t)?t.includes(s.value):s.value===t)return e.i++,El(e,r,o,t);if(E0(s,e,r.at(-1),o))continue}let u=o.words.length===0?Nn(s):null;u===null?o.words.push(be(s)):o.assigns.push({name:u.name,word:be(s,u.end)}),e.i++}if(t===")")throw kt("unmatched `(`");if(t==="}")throw kt("unmatched `{`");if(t==="do"||t==="done")throw kt(`${e.loop}: missing \`${t}\``);if(t)throw kt(`if: missing \`${t==="then"?"then":"fi"}\``);if(!e.emptyStage&&!Mr(o)&&!Eo(o)&&["and","or","pipe","pipe_err"].includes(n.at(-1)?.kind))throw kt("empty pipeline stage");return $l.has(n.at(-1)?.kind)?r.pop():vl(r.at(-1),o)||$o(e,r.at(-1),o),r}function $0(e,t){let{raw:n,i:r}=e,i=ye(e,r+1),o=n[r-1],s=t.words[0],u=t.words.at(-1);if(!(n[r-2]?.kind==="redir"&&!["dup","close"].includes(n[r-2].op))&&(t.words.length===0&&t.assigns.length>0||u&&u.value===o?.value&&(t.words.length===1||s.mask===null&&v0.has(s.value)))&&n[r].wordAdjacent&&o?.kind==="word"&&!o.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(o.value))throw new w("feature","array assignment","shell array assignments are not supported");if(i?.kind==="paren_open"&&i.adjacent&&Qt(t))throw new w("feature","((","arithmetic evaluation (`((\u2026))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&i?.kind==="paren_close"){t.define=xl(e,t.words.pop(),_t);return}if(!Qt(t))throw new Error("unexpected `(`");e.i++,t.group=_t(e,")"),t.isolate=!0}function E0(e,t,n,r){let i=e.value;if(Sl.has(i))throw new w("feature",i,Sl.get(i));if(k0.has(i))throw new Error(`syntax error near unexpected token \`${i}\``);if(!x0.has(i))return!1;if(t.i++,i==="!"){if(n.stages.length>0||r.redirs.length>0)throw new Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(i==="{")return Ve(t),r.group=_t(t,"}"),r.isolate=!1,!0;if(i==="}")throw new Error("syntax error near unexpected token `}`");if(i==="done")throw new Error("unexpected `done`");if(i==="do")throw new Error("unexpected `do`");return i==="if"?r.conditional=wl(t,_t):r.loop=i==="for"?bl(t,_t):yl(t,i,_t),!0}var N0={")":"empty subshell `()`","}":"empty group `{ }`"},A0=(e,t)=>t==="do"?`${e.loop}: empty condition`:t==="done"?`${e.loop}: empty loop body`:t==="then"?"if: empty condition":"if: empty branch body";function El(e,t,n,r){let i=t.at(-1),o=Qt(n)&&n.redirs.length===0&&i.stages.length===0;if(o&&t.length===1)throw new Error(N0[r]??A0(e,r));if(o&&i.bang)throw new Error("syntax error near unexpected token after `!`");return o&&i.gate==="seq"?t.pop():$o(e,i,n),t}var O0=new Set(["/dev/null","/dev/stdout","/dev/stderr"]);function I0(e){let t=e.raw[e.i++],n=On(t);if(e.syntaxOnly){if(!["dup","close"].includes(t.op)){let u=ye(e,e.i++);if(!u||u.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new w("feature",n,`only file descriptors 0, 1 and 2 are supported (got \`${n}\`)`);if(t.op==="dup"){if(t.fd===0&&t.toFd===0)return null;if(t.fd===0||t.toFd===0)throw new w("feature",n,`duplicating file descriptor 0 (\`${n}\`) is not supported`);return{fd:t.fd,op:"dup",toFd:t.toFd}}if(t.op==="close"){if(t.fd===0)throw new w("feature","0<&-","closing standard input is not supported");return{fd:t.fd,op:"close"}}let r=ye(e,e.i++);if(!r||r.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`);if(t.op==="heredoc"||t.op==="herestring"||t.op==="read"){if(t.fd!==0)throw new w("feature",n,`reading into file descriptor ${t.fd} (\`${n}\`) is not supported`);return t.op==="heredoc"?{fd:0,op:"text",body:t.body??"",expand:!t.quotedDelim}:{fd:0,op:t.op,word:be(r)}}if(t.fd===0)throw new w("feature",n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let i=t.op==="both"||t.op==="bothAppend",o=t.op==="append"||t.op==="bothAppend",s=be(r);if(C0(s))return{fd:t.fd,op:"to",word:s,both:i,append:o,label:n};if(!e.writable&&!O0.has(s.value))throw No(n,s.value,e.writable);return{fd:t.fd,op:"to",target:s.value,both:i,append:o,label:n}}function C0(e){for(let t=0;t<e.value.length;t++){let n=e.value[t],r=e.mask===null?"0":e.mask[t];if((n==="$"||n==="`")&&r!=="1"||r==="0"&&(/[~*?[{]/u.test(n)||(n==="<"||n===">")&&e.value[t+1]==="("))return!0}return!1}function No(e,t,n){let r=n?"only `/tmp/` is writable":"the filesystem is read-only";return new w("feature",e,`\`${e}\` cannot write to \`${t}\`: ${r}`)}var F0=/^[a-zA-Z0-9][\w.+-]*$/u,Ao=["run","pipe","hidden"],Oo=["stdout","stderr","exitCode"];function Cl(e,t){let n={__proto__:null},r=[],i=[];for(let[o,s]of T0(e)){let{run:u,pipe:a,hidden:l}=_0(o,s,t);l&&r.includes(o)||(n[o]=(f,c,d)=>L0(o,u,f,c,d),!l&&(r.push(o),a&&i.push(o)))}return{handlers:n,names:r,pipeNames:i}}function T0(e){if(e==null)return[];if(Array.isArray(e))throw new TypeError("createTerminal: opts.commands must be an object or a Map (got an array)");if(typeof e!="object")throw new TypeError(`createTerminal: opts.commands must be an object or a Map (got ${typeof e})`);if(typeof e.entries=="function")return[...e.entries()];let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new TypeError("createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)");return Object.entries(e)}function _0(e,t,n){if(typeof e!="string")throw new TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!F0.test(e))throw new Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw new Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t=="function"){for(let i of Object.keys(t))if(Ao.includes(i))throw new Error(`createTerminal: ${e}: \`${i}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(t===null||typeof t!="object")throw new TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!="function")throw new TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let i of Object.keys(t))if(!Ao.includes(i))throw new Error(`createTerminal: ${e}: unknown option \`${i}\` (known: ${Ao.join(", ")})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function L0(e,t,n,r,i){i.io?.bufferOutput(),X(i);let o={cwd:i.cwd,fs:i.fs,mount:i.mount,home:i.home,get notes(){return i.notes},command:e,stdinFile:i.stdinFile,stdinOrigin:i.stdinOrigin},s=!0,u=()=>{s=!1},a={name:e,args:r,stdin:n,cwd:o.cwd,fs:R0(o),readInputs:(f=[])=>{if(typeof f=="string")throw new TypeError(`readInputs: expected an array of paths, got a string: ${f}`);return se(e,[...f],n,o)},run:f=>{if(!s)throw new Error("run: the command this belongs to has finished, and its turn with it");return i.runLine(f)}},l=t(a);return typeof l?.then!="function"?(u(),Il(l)):l.then(Il).finally(u)}function R0(e){let t=n=>v(e.cwd,n,e.fs).path;return{resolve:n=>G(e.cwd,n),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:n=>e.fs.isLink?.(v(e.cwd,n,e.fs,{follow:!1}).path)===!0,readLink:n=>e.fs.readLink?.(v(e.cwd,n,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>Me(e.fs,t(n))?.slice(),listDir:n=>{let{path:r,error:i}=R(e,e.command,n);if(!e.fs.isDir(r))throw new Error(`${n}: ${i??"Not a directory"}`);let{dirs:o,files:s,links:u=[]}=e.fs.listDir(r);return{dirs:[...o],files:[...s],links:[...u]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function Il(e){if(e==null)return C();if(typeof e=="string")return C(e);if(typeof e!="object")throw new TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw new TypeError("invalid result: expected a string or an object, got an array (join the lines first)");let t=Object.keys(e);for(let o of t)if(!Oo.includes(o))throw new TypeError(`invalid result: unknown field \`${o}\` (known: ${Oo.join(", ")})`);if(t.length===0)throw new TypeError(`invalid result: an object with none of ${Oo.join(", ")} \u2014 return a string for plain output`);let{stdout:n="",stderr:r="",exitCode:i=0}=e;if(typeof n!="string")throw new TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!="string")throw new TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(i)||i<0)throw new TypeError(`invalid result: exitCode must be a non-negative integer (got ${i})`);return{stdout:n,stderr:r===""||r.endsWith(`
|
|
26
|
+
`,s||(o.warning=`warning: here-document delimited by end-of-file (wanted \`${o.delim}')
|
|
27
|
+
`)}return r-1}function D0(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t++;return t%2===1}var B0=new Set(["semi","amp","and","or","pipe","pipe_err","paren_open"]),U0=e=>e===" "||e===" ";function Ur(e,t={}){return kl(Oi(e,t),!1).tokens}function xl(e,t={}){let n=Oi(e,t);return{read:()=>kl(n,!0),reset:()=>{n.tokens=[]}}}function kl(e,t){for(;e.i<e.line.length;){let n=e.line[e.i];if(e.quote&&n===e.quote){vl(e),e.i++;continue}if(e.quote==="'"){fe(e,n,"1"),e.i++;continue}if(n==="\\"){Sl(e);continue}if(n==="$"){$l(e);continue}if(n==="`"){Nl(e);continue}if(e.quote){fe(e,n,"2"),e.i++;continue}if(n==="'"||n==='"'){Ii(e,n),e.i++;continue}let r=e.cur!==""||e.empty.length>0;if(!r&&e.line.startsWith("[[",e.i)&&/[ \t\n()<>;&|]|^$/u.test(e.line[e.i+2]??"")&&q0(e.tokens)){let i=Tn(e.line,e.i,{readExpansion:e.readExpansion,decodeAnsiC:en});bl(e,{kind:"condition",expression:i.expression}),e.i+=i.raw.length;continue}if(n==="#"&&!r){H0(e);continue}if(n===`
|
|
28
|
+
`){if(G0(e),t)return{tokens:e.tokens,done:e.i>=e.line.length};continue}if(U0(n)){_n(e),e.i++;continue}if(n==="("&&e.mask.at(-1)==="0"&&/[?*+@!]/u.test(e.cur.at(-1))&&!e.empty.includes(e.cur.length))throw new b("feature","extglob","extended glob patterns are not supported");if((n==="<"||n===">")&&e.line[ae(e.line,e.i+1)]==="("){z0(e);continue}let o=Br(e.line,e.i,!r);if(o?.token.kind==="paren_open"&&(o.token.wordAdjacent=r),o){_n(e),bl(e,o.token),e.i=o.end;continue}fe(e,n,"0"),e.i++}if(e.quote)throw new Error(`unterminated ${e.quote==="'"?"single":"double"} quote`);return _n(e),e.heredocs.length>0&&Ln(e.line,e.line.length,e.heredocs),{tokens:e.tokens,done:!0}}function Oi(e,t={}){return{line:e,i:0,tokens:[],cur:"",mask:"",empty:[],quoted:!1,quoteStart:0,quote:null,heredocs:[],lastParenAt:-2,readExpansion:(n,r,o=0,i=!1)=>ft(n,r,o,i,t),readProcess:(n,r)=>yl(n,r,t)}}function Ci(e,t=!1){let n={...Oi(e),fragment:!0,fragmentQuoted:t};for(;n.i<n.line.length;){let r=n.line[n.i];if(n.quote&&r===n.quote){vl(n),n.i++;continue}if(n.quote==="'"){fe(n,r,"1"),n.i++;continue}if(r==="\\"){Sl(n);continue}if(r==="$"){$l(n);continue}if(r==="`"){Nl(n);continue}if(n.quote){fe(n,r,"2"),n.i++;continue}if(r==='"'||r==="'"&&!t){Ii(n,r),n.i++;continue}if(!t&&(r==="<"||r===">")&&n.line[ae(n.line,n.i+1)]==="(")throw new b("feature",`${r}(`,"process substitution in parameter operands is not supported");fe(n,r,t?"2":"0"),n.i++}if(n.quote)throw new b("feature","${","unterminated quote in parameter operand");return _n(n),n.tokens[0]??{value:"",mask:t?"":null}}var j0=new Set(["semi","and","or","pipe","pipe_err","amp","paren_open"]),W0=new Set(["!","{","if","then","else","elif","while","until","do"]);function q0(e){let t=!0,n=null,r=!1;for(let o of e){let i=j0.has(o.kind)||o.kind==="paren_close"&&n?.kind==="paren_open";if(n=o,i){t=!0,r=!1;continue}if(o.kind==="redir"){t=!1,r=!["dup","close"].includes(o.op);continue}if(r){r=!1;continue}(!t||o.kind!=="word"||o.quoted||!W0.has(o.value))&&(t=!1)}return t&&!r}function Ii(e,t){e.quoteStart=e.cur.length,e.quote=t}function vl(e){e.cur.length===e.quoteStart&&e.empty.push(e.cur.length),e.quote=null}function fe(e,t,n,r=n!=="0"){e.cur+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function _n(e){if(e.cur!==""||e.empty.length>0){let t=e.empty.length>0||e.quoted,n={kind:"word",value:e.cur,mask:/[12]/u.test(e.mask)||t?e.mask:null,quoted:t,...e.empty.length?{empty:e.empty}:{}};e.tokens.push(n);let r=e.heredocs.find(o=>o.delim===null);r&&(r.delim=n.value,r.quotedDelim=t)}e.cur="",e.mask="",e.empty=[],e.quoted=!1}function bl(e,t){t.kind==="paren_open"&&(t.adjacent=ae(e.line,e.lastParenAt+1)===e.i,e.lastParenAt=e.i),t.kind==="redir"&&t.op==="heredoc"&&e.heredocs.push(t),e.tokens.push(t)}function Sl(e){let t=e.line[e.i+1];if(t===`
|
|
29
|
+
`){e.i+=2;return}t!==void 0&&(!(e.quote||e.fragmentQuoted)||'$`"\\'.includes(t)||e.fragment&&t==="}")?(fe(e,t,"1"),e.i+=2):(fe(e,"\\",e.quote||e.fragmentQuoted?"2":"1"),e.i++)}function El(e,t){let n=ae(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function $l(e){El(e,e.i+1);let{line:t}=e,n=e.quote==='"'||e.fragmentQuoted?"2":"0",r=t[e.i+1];if((n==="0"||e.fragmentQuoted&&!e.quote)&&r==="'"){let u=en(t,e.i+2);if(e.fragmentQuoted&&/[$`"\\]/u.test(u.text))throw new b("feature","${","active characters in ANSI-C quoted parameter operands are not supported");u.text===""&&e.empty.push(e.cur.length),fe(e,u.text,"1"),e.i=u.end;return}if((n==="0"||e.fragmentQuoted&&!e.quote)&&r==='"'){Ii(e,'"'),e.i+=2;return}let o=e.readExpansion(t,e.i,0,n==="2");if(!o){fe(e,"$","1"),e.i++;return}if(o.command!==void 0||o.parameter!==void 0||o.arithmetic!==void 0){fe(e,"$",n),fe(e,o.raw.slice(1),"1",!1),e.i+=o.raw.length;return}let i=t[e.i+o.raw.length],s=Lt.test(o.name)&&(i==='"'||i==="'")?"${"+o.name+"}":o.raw;fe(e,s,n),e.i+=o.raw.length}function z0(e){El(e,e.i+1);let{raw:t}=e.readProcess(e.line,e.i);fe(e,e.line[e.i],"0"),fe(e,t.slice(1),"1",!1),e.i+=t.length}function Nl(e){let t=e.quote==='"'||e.fragmentQuoted?"2":"0",{raw:n}=at(e.line,e.i);fe(e,"`",t),fe(e,n.slice(1),"1",!1),e.i+=n.length}function H0(e){for(;e.i<e.line.length&&e.line[e.i]!==`
|
|
30
|
+
`;)e.i++}function G0(e){_n(e),e.heredocs.length>0&&(e.i=Ln(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!B0.has(t.kind)?e.tokens.push({kind:"semi",newline:!0}):(t?.kind==="semi"||t?.kind==="amp")&&(t.lineEnd=!0),e.i++}function jr(e,t,n){let r={aliases:new Set(t),hasCommand:n};return vt(e,r),r.aliases}var Rn=(e,t)=>new Set([...e,...t]);function vt(e,t){let n=null;for(let r of e){let o=r.gate==="and"||r.gate==="or";if(o&&n!==null&&r.gate==="and"!=(n===0))continue;let i=o&&n===null?new Set(t.aliases):null,s=r.stages.length===1?r.stages[0]:null;n=s&&!s.isolate?X0(s,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=Rn(i,t.aliases),n=null)}return n}function X0(e,t){if(e.group)return vt(e.group,t);if(e.conditional)return Z0(e.conditional,t);if(e.loop){if(e.loop.condition&&vt(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let o=new Set(t.aliases);vt(e.loop.body,t),t.aliases=Rn(o,t.aliases)}return null}let n=e.words[0]?.value;if(e.redirs.length===0&&(n==="true"||n==="false"))return+(n==="false");if(!["alias","unalias"].includes(n)||t.hasCommand(n))return null;let r=e.words.slice(1).map(o=>o.value);for(;r[0]?.startsWith("-")&&r[0]!=="-";){let o=r.shift();if(o==="--")break;if(!(n==="alias"?/^-p+$/u:/^-a+$/u).test(o))return null;if(n==="unalias")return t.aliases.clear(),null}for(let o of r)if(n==="unalias")t.aliases.delete(o);else{let i=o.indexOf("="),s=o.slice(0,i);i>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(s)&&t.aliases.add(s)}return null}function Z0(e,t){let n=new Set;for(let r of e.branches){let o=vt(r.condition,t);if(o===0)return vt(r.body,t),t.aliases=Rn(n,t.aliases),null;if(o===null){let i={...t,aliases:new Set(t.aliases)};vt(r.body,i),n=Rn(n,i.aliases)}}return e.otherwise&&vt(e.otherwise,t),t.aliases=Rn(n,t.aliases),null}var Ve=class extends Error{constructor(t){super(t.message),this.finalError=t}},St=e=>new Ve(new Error(e));function ke(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let n=e.read();e.raw=n.tokens,e.done=n.done}return e.raw[t]}function Al(e,t,n){let r=t.validation??new Map;return{validateSubstitution(o){r.has(o)||(Ti(o,!0,e,{validation:r,syntaxOnly:!0},n),r.set(o,!0))}}}function Ti(e,t,n,r,o){try{return o(Ur(e,Al(n,r,o)),t,n,r)}catch(i){throw i instanceof Ve?i.finalError:i}}function Y0(e,t,n,r){let o=xl(e,Al(n,{},r)),i=new Set,s=!1;return()=>{let u={aliases:i,aliasUsed:s,read:o.read,unit:!0},a=r([],t,n,u);return s=u.aliasUsed,i=jr(a,i,n),o.reset(),{steps:a,done:u.done}}}function*Ol(e,t,n,r){let o=Y0(e,t,n,r);for(;;){let i;try{i=o()}catch(s){throw s instanceof Ve?s.finalError:s}if(i.steps.length>0&&(yield i.steps),i.done)return}}var V0=["elif","else","fi"];function Il(e,t){let n=[],r;do{Ke(e);let i=t(e,"then");Ke(e);let s=t(e,V0);n.push({condition:i,body:s}),r=e.raw[e.i-1].value}while(r==="elif");let o=null;return r==="else"&&(Ke(e),o=t(e,"fi")),{branches:n,otherwise:o}}function Tl(e,t){let{raw:n}=e,r=e.loop;e.loop="for";let o=ke(e);if(o?.kind==="paren_open")throw new b("feature","for ((","arithmetic `for ((\u2026))` loops are not supported; use `for NAME in WORD...`");if(o===void 0||o.kind!=="word")throw new Error("for: expected a variable name");let i=o.value;if(o.quoted||!Lt.test(i))throw new Error(`for: \`${i}\` is not a valid variable name`);e.i++;let s=ke(e);s?.kind==="semi"&&e.i++;let u=ke(e);if(s?.kind==="semi"&&!s.newline&&tn(u,"in"))throw new Error("for: unexpected `in` after `;`");if(!tn(u,"in")){if(tn(u,"do")||u===void 0){let d=new b("feature","for NAME; do",`\`for ${i}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${i} in WORD...\``);throw u===void 0?new Ve(d):d}throw new Error(`for: expected \`in\` after \`${i}\``)}e.i++;let a=[],l=!1;for(let d;(d=ke(e))&&d.kind!=="semi";e.i++){if(d.kind!=="word")throw new Error(`for: unexpected \`${Fn(d)}\` in word list`);tn(d,"do")&&(l=!0),a.push(xe(d))}n[e.i]?.kind==="semi"&&e.i++;let f=ke(e);if(!tn(f,"do"))throw f===void 0?St(l?"for: expected `;` or newline before `do`":"for: missing `do`"):l?new Error("for: expected `;` or newline before `do`"):new Error(`for: expected \`do\`, got \`${Fn(f)}\``);e.i++,Ke(e);let c={name:i,words:a,body:t(e,"done")};return e.loop=r,c}function Fl(e,t,n){let r=e.loop;e.loop=t,Ke(e);let o=n(e,"do");Ke(e);let i={until:t==="until",condition:o,body:n(e,"done")};return e.loop=r,i}function Ll(e,t,n){if(t.quoted||!Lt.test(t.value))throw new b("feature","function",`shell functions named \`${t.value}\` are not supported`);e.i+=2,Ke(e);let r=ke(e);if(!tn(r,"{"))throw new b("feature","function",`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,Ke(e);let o=n(e,"}");if(!_t(o))throw new b("feature","function",`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:o}}var _t=e=>e.every(t=>t.stages.every(K0));function K0(e){return e.assigns.length>0||e.define?!1:e.test?Wr(e.test)&&e.redirs.every(Cl):e.group?_t(e.group):e.conditional?e.conditional.branches.every(t=>_t(t.condition)&&_t(t.body))&&_t(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(nn)&&_t(e.loop.condition??[])&&_t(e.loop.body):e.words.every(nn)&&e.redirs.every(Cl)}function Wr(e){return e.kind==="and"||e.kind==="or"?Wr(e.left)&&Wr(e.right):e.kind==="not"?Wr(e.expression):e.kind==="unary"?nn(e.word):nn(e.left)&&nn(e.right)}var Cl=e=>e.op==="text"?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||nn(e.word);function nn(e){for(let t=0;t<e.value.length;t++){let n=e.value[t];if((n==="$"||n==="`")&&(e.mask===null||e.mask[t]!=="1"))return!1}return!0}function Ke(e){for(let t;(t=ke(e))?.kind==="semi"&&t.newline;)e.i++}function tn(e,t){return e!==void 0&&e.kind==="word"&&!e.quoted&&e.value===t}var Bl=(e,t=!1,n=()=>!1,r={})=>Ti(e,t,n,r,jl),Ul=(e,t=!1,n=()=>!1)=>Ol(e,t,n,jl);function jl(e,t,n,r){let o={raw:e,i:0,done:!r.read,read:r.read,unitOnly:r.unit,emptyStage:!1,writable:t,aliases:r.aliases??new Set,aliasUsed:r.aliasUsed??!1,hasCommand:n,syntaxOnly:r.syntaxOnly};try{let i=ke(o)?Rt(o,null):[];if(o.emptyStage)throw new Error("empty pipeline stage");return r.aliasUsed=o.aliasUsed,r.done=o.done,i}catch(i){if(o.aliasUsed&&!(i instanceof b)){let s=new b("feature","alias expansion","alias expansion is not supported; input using aliases cannot be parsed");throw i instanceof Ve?new Ve(s):s}throw i}}function Li(e,t,n){t.stages.push(n),!qr(n)&&!_i(n)&&(e.emptyStage=!0)}var _i=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,qr=e=>e.group||e.loop||e.conditional||e.test||e.define,_l=()=>({words:[],assigns:[],redirs:[]}),Fi=e=>({gate:e,stages:[],negate:!1,bang:!1}),Rl=(e,t)=>e.bang&&e.stages.length===0&&rn(t)&&t.redirs.length===0,rn=e=>!qr(e)&&e.words.length===0&&e.assigns.length===0,J0=new Set(["for","while","until","do","done","if","{","}","!"]),Q0=new Set(["then","else","elif","fi","esac","in"]),Ml=new Map([["case","`case` statements are not supported; gate on exit status with `&&` / `||` instead"],["select","`select` loops are not supported"],["function","shell functions are not supported"],["time","`time` is not supported"],["coproc","`coproc` is not supported"]]),eg=new Set(["alias","declare","typeset","local","readonly","export","eval","let"]),tg=new Set(["pipe","pipe_err","and","or","semi","amp"]),Pl=new Set(["semi","amp"]);function Rt(e,t){let{raw:n}=e,r=[Fi("first")];t===null&&(e.unit=r[0]);let o=0,i=_l();for(let s;s=ke(e);){if(s.kind==="condition"){if(!rn(i))throw new Error("unexpected `[[`");i.test=s.expression,e.i++;continue}if(s.kind==="paren_close"){if(t!==")")throw new Error("unexpected `)`");return e.i++,Dl(e,r,i,t)}if(s.kind==="paren_open"){ng(e,i);continue}if(tg.has(s.kind)){if(s.kind==="pipe_err"&&(_i(i)||qr(i))&&i.redirs.push({fd:2,op:"dup",toFd:1}),s.kind==="semi"&&Rl(r.at(-1),i)||Li(e,r.at(-1),i),s.kind==="amp"&&(r.at(-1).background=!0),i=_l(),s.kind==="and"||s.kind==="or"?r.push(Fi(s.kind)):Pl.has(s.kind)&&r.push(Fi("seq")),t===null&&(s.newline||s.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=jr(r.slice(o,-1),e.aliases,e.hasCommand),o=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(s.kind==="dsemi")throw new Error("syntax error near unexpected token `;;`");if(s.kind==="redir"){if(s.warning&&(e.unit.warnings=(e.unit.warnings??"")+s.warning),i.define)throw new b("feature","function",`\`${i.define.name}()\` with a redirect of its own is not supported`);let a=ug(e);a&&i.redirs.push(a);continue}if(i.group||i.define)throw new Error(`unexpected token after \`${i.isolate?")":"}"}\``);if(i.loop)throw new Error("unexpected token after `done`");if(i.conditional)throw new Error("unexpected token after `fi`");if(i.test)throw new Error("unexpected token after `]]`");if(!s.quoted&&i.words.length===0&&e.aliases.has(s.value)&&(e.aliasUsed=!0),!s.quoted&&rn(i)){if(Array.isArray(t)?t.includes(s.value):s.value===t)return e.i++,Dl(e,r,i,t);if(rg(s,e,r.at(-1),i))continue}let u=i.words.length===0?In(s):null;u===null?i.words.push(xe(s)):i.assigns.push({name:u.name,word:xe(s,u.end)}),e.i++}if(t===")")throw St("unmatched `(`");if(t==="}")throw St("unmatched `{`");if(t==="do"||t==="done")throw St(`${e.loop}: missing \`${t}\``);if(t)throw St(`if: missing \`${t==="then"?"then":"fi"}\``);if(!e.emptyStage&&!qr(i)&&!_i(i)&&["and","or","pipe","pipe_err"].includes(n.at(-1)?.kind))throw St("empty pipeline stage");return Pl.has(n.at(-1)?.kind)?r.pop():Rl(r.at(-1),i)||Li(e,r.at(-1),i),r}function ng(e,t){let{raw:n,i:r}=e,o=ke(e,r+1),i=n[r-1],s=t.words[0],u=t.words.at(-1);if(!(n[r-2]?.kind==="redir"&&!["dup","close"].includes(n[r-2].op))&&(t.words.length===0&&t.assigns.length>0||u&&u.value===i?.value&&(t.words.length===1||s.mask===null&&eg.has(s.value)))&&n[r].wordAdjacent&&i?.kind==="word"&&!i.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(i.value))throw new b("feature","array assignment","shell array assignments are not supported");if(o?.kind==="paren_open"&&o.adjacent&&rn(t))throw new b("feature","((","arithmetic evaluation (`((\u2026))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&o?.kind==="paren_close"){t.define=Ll(e,t.words.pop(),Rt);return}if(!rn(t))throw new Error("unexpected `(`");e.i++,t.group=Rt(e,")"),t.isolate=!0}function rg(e,t,n,r){let o=e.value;if(Ml.has(o))throw new b("feature",o,Ml.get(o));if(Q0.has(o))throw new Error(`syntax error near unexpected token \`${o}\``);if(!J0.has(o))return!1;if(t.i++,o==="!"){if(n.stages.length>0||r.redirs.length>0)throw new Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(o==="{")return Ke(t),r.group=Rt(t,"}"),r.isolate=!1,!0;if(o==="}")throw new Error("syntax error near unexpected token `}`");if(o==="done")throw new Error("unexpected `done`");if(o==="do")throw new Error("unexpected `do`");return o==="if"?r.conditional=Il(t,Rt):r.loop=o==="for"?Tl(t,Rt):Fl(t,o,Rt),!0}var og={")":"empty subshell `()`","}":"empty group `{ }`"},ig=(e,t)=>t==="do"?`${e.loop}: empty condition`:t==="done"?`${e.loop}: empty loop body`:t==="then"?"if: empty condition":"if: empty branch body";function Dl(e,t,n,r){let o=t.at(-1),i=rn(n)&&n.redirs.length===0&&o.stages.length===0;if(i&&t.length===1)throw new Error(og[r]??ig(e,r));if(i&&o.bang)throw new Error("syntax error near unexpected token after `!`");return i&&o.gate==="seq"?t.pop():Li(e,o,n),t}var sg=new Set(["/dev/null","/dev/stdout","/dev/stderr"]);function ug(e){let t=e.raw[e.i++],n=Fn(t);if(e.syntaxOnly){if(!["dup","close"].includes(t.op)){let u=ke(e,e.i++);if(!u||u.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new b("feature",n,`only file descriptors 0, 1 and 2 are supported (got \`${n}\`)`);if(t.op==="dup"){if(t.fd===0&&t.toFd===0)return null;if(t.fd===0||t.toFd===0)throw new b("feature",n,`duplicating file descriptor 0 (\`${n}\`) is not supported`);return{fd:t.fd,op:"dup",toFd:t.toFd}}if(t.op==="close"){if(t.fd===0)throw new b("feature","0<&-","closing standard input is not supported");return{fd:t.fd,op:"close"}}let r=ke(e,e.i++);if(!r||r.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`);if(t.op==="heredoc"||t.op==="herestring"||t.op==="read"){if(t.fd!==0)throw new b("feature",n,`reading into file descriptor ${t.fd} (\`${n}\`) is not supported`);return t.op==="heredoc"?{fd:0,op:"text",body:t.body??"",expand:!t.quotedDelim}:{fd:0,op:t.op,word:xe(r)}}if(t.fd===0)throw new b("feature",n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let o=t.op==="both"||t.op==="bothAppend",i=t.op==="append"||t.op==="bothAppend",s=xe(r);if(ag(s))return{fd:t.fd,op:"to",word:s,both:o,append:i,label:n};if(!e.writable&&!sg.has(s.value))throw Ri(n,s.value,e.writable);return{fd:t.fd,op:"to",target:s.value,both:o,append:i,label:n}}function ag(e){for(let t=0;t<e.value.length;t++){let n=e.value[t],r=e.mask===null?"0":e.mask[t];if((n==="$"||n==="`")&&r!=="1"||r==="0"&&(/[~*?[{]/u.test(n)||(n==="<"||n===">")&&e.value[t+1]==="("))return!0}return!1}function Ri(e,t,n){let r=n?"only `/tmp/` is writable":"the filesystem is read-only";return new b("feature",e,`\`${e}\` cannot write to \`${t}\`: ${r}`)}var lg=/^[a-zA-Z0-9][\w.+-]*$/u,Mi=["run","pipe","hidden"],Pi=["stdout","stderr","exitCode"];function ql(e,t){let n={__proto__:null},r=[],o=[];for(let[i,s]of fg(e)){let{run:u,pipe:a,hidden:l}=cg(i,s,t);l&&r.includes(i)||(n[i]=(f,c,d)=>dg(i,u,f,c,d),!l&&(r.push(i),a&&o.push(i)))}return{handlers:n,names:r,pipeNames:o}}function fg(e){if(e==null)return[];if(Array.isArray(e))throw new TypeError("createTerminal: opts.commands must be an object or a Map (got an array)");if(typeof e!="object")throw new TypeError(`createTerminal: opts.commands must be an object or a Map (got ${typeof e})`);if(typeof e.entries=="function")return[...e.entries()];let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new TypeError("createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)");return Object.entries(e)}function cg(e,t,n){if(typeof e!="string")throw new TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!lg.test(e))throw new Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw new Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t=="function"){for(let o of Object.keys(t))if(Mi.includes(o))throw new Error(`createTerminal: ${e}: \`${o}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(t===null||typeof t!="object")throw new TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!="function")throw new TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let o of Object.keys(t))if(!Mi.includes(o))throw new Error(`createTerminal: ${e}: unknown option \`${o}\` (known: ${Mi.join(", ")})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function dg(e,t,n,r,o){o.io?.bufferOutput(),q(o);let i={cwd:o.cwd,fs:o.fs,mount:o.mount,home:o.home,get notes(){return o.notes},command:e,stdinFile:o.stdinFile,stdinOrigin:o.stdinOrigin},s=!0,u=()=>{s=!1},a={name:e,args:r,stdin:n,cwd:i.cwd,fs:pg(i),readInputs:(f=[])=>{if(typeof f=="string")throw new TypeError(`readInputs: expected an array of paths, got a string: ${f}`);return te(e,[...f],n,i)},run:f=>{if(!s)throw new Error("run: the command this belongs to has finished, and its turn with it");return o.runLine(f)}},l=t(a);return typeof l?.then!="function"?(u(),Wl(l)):l.then(Wl).finally(u)}function pg(e){let t=n=>E(e.cwd,n,e.fs).path;return{resolve:n=>Z(e.cwd,n),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:n=>e.fs.isLink?.(E(e.cwd,n,e.fs,{follow:!1}).path)===!0,readLink:n=>e.fs.readLink?.(E(e.cwd,n,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>Be(e.fs,t(n))?.slice(),listDir:n=>{let{path:r,error:o}=P(e,e.command,n);if(!e.fs.isDir(r))throw new Error(`${n}: ${o??"Not a directory"}`);let{dirs:i,files:s,links:u=[]}=e.fs.listDir(r);return{dirs:[...i],files:[...s],links:[...u]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function Wl(e){if(e==null)return F();if(typeof e=="string")return F(e);if(typeof e!="object")throw new TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw new TypeError("invalid result: expected a string or an object, got an array (join the lines first)");let t=Object.keys(e);for(let i of t)if(!Pi.includes(i))throw new TypeError(`invalid result: unknown field \`${i}\` (known: ${Pi.join(", ")})`);if(t.length===0)throw new TypeError(`invalid result: an object with none of ${Pi.join(", ")} \u2014 return a string for plain output`);let{stdout:n="",stderr:r="",exitCode:o=0}=e;if(typeof n!="string")throw new TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!="string")throw new TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(o)||o<0)throw new TypeError(`invalid result: exitCode must be a non-negative integer (got ${o})`);return{stdout:n,stderr:r===""||r.endsWith(`
|
|
31
31
|
`)?r:r+`
|
|
32
|
-
`,exitCode:
|
|
33
|
-
|
|
34
|
-
`,e.status=
|
|
35
|
-
|
|
36
|
-
`,e.status=1
|
|
32
|
+
`,exitCode:o}}function N(e,t={}){let n=Mn(t.short),r=Mn(t.long),o=Mn(t.valueShort),i=Mn(t.valueLong),s=Mn(t.repeatable),u=new Set,a=new Map,l=[],f=[],c=0;function d(p,h,m=!1){let g=(m?"--":"-")+p,w=(m?i:o).has(p)||s.has(p)&&(!m||p.length>1);if(w){let y=h??e[++c];if(h===null&&c>=e.length)throw new Error(g+" requires an argument");if(s.has(p)){let k=a.get(p);k?k.push(y):a.set(p,[y])}else a.set(p,y);f.push({name:p,value:y})}else{if(!(m?r:n).has(p))throw new b("option",g,"unknown option: "+g);if(m&&h!==null)throw new Error("option "+g+" doesn't allow an argument");u.add(p),f.push({name:p})}return w}for(;c<e.length;c++){let p=e[c];if(p==="--"){l.push(...e.slice(c+1));break}if(p.startsWith("--")&&p.length>2){let h=p.indexOf("=");d(h===-1?p.slice(2):p.slice(2,h),h===-1?null:p.slice(h+1),!0);continue}if(p.startsWith("-")&&p.length>1&&!(t.numericOperands&&hg(p,n,o,s))){for(let h=1;h<p.length&&!d(p[h],h+1<p.length?p.slice(h+1):null);h++);continue}if(t.stopAtFirstPositional){l.push(...e.slice(c));break}l.push(p)}return{flags:u,values:a,positional:l,order:f}}function hg(e,t,n,r){if(!/^-\d/u.test(e))return!1;let o=e[1];return!t.has(o)&&!n.has(o)&&!r.has(o)}function Mn(e){return e instanceof Set?e:new Set(e??[])}function mg(e){try{return typeof DecompressionStream=="function"&&!!new DecompressionStream(e)}catch{return!1}}function gg(e){try{return typeof CompressionStream=="function"&&!!new CompressionStream(e)}catch{return!1}}var zr=e=>mg(e)&&gg(e);async function zl(e,t){let{readable:n,writable:r}=e,o=r.getWriter(),i=(async()=>{try{await o.write(t),await o.close()}catch{}})(),s=n.getReader(),u=[],a=null;try{for(;;){let{done:c,value:d}=await s.read();if(c)break;u.push(d)}}catch(c){a=c?.cause?.message??c?.message??"corrupt input"}await i;let l=new Uint8Array(u.reduce((c,d)=>c+d.length,0)),f=0;for(let c of u)l.set(c,f),f+=c.length;return{bytes:l,error:a}}var Hr=(e,t)=>zl(new DecompressionStream(t),e),Pn=async(e,t)=>(await zl(new CompressionStream(t),e)).bytes;var Di="brotli",Gr=".br",Gl=zr(Di)?{brotli:yg}:{},Xl="con",Zl=Object.freeze(["0","1","2","3","4","5","6","7","8","9"]),wg=`Usage: brotli [OPTION]... [FILE]...
|
|
33
|
+
`;async function yg(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:[...Zl,"d","c","k","j","f","Z"],long:["decompress","stdout","keep","rm","force","best"],valueShort:["q"],valueLong:["quality"]}),s=bg(r,o);if(s!==void 0)return v("option","brotli",s,`brotli: ${s}: choosing a compression level is not supported`,1);let u={decompressing:r.has("d")||r.has("decompress"),stdout:r.has("c")||r.has("stdout"),remove:r.has("j")||r.has("rm"),force:r.has("f")||r.has("force")};if(u.stdout&&i.length>1)return{stdout:wg,stderr:"",exitCode:1};let a={ctx:n,events:[],stderr:"",status:0,gap:null};for(let f of i.length===0?["-"]:i)if(!await xg(f,e,u,a))break;if(a.gap)return a.gap;let l=[...a.events,...a.stderr?[{fd:2,text:a.stderr}]:[]];return{stdout:"",stderr:a.stderr,exitCode:a.status,events:l}}function bg(e,t){let n=[...Zl,"Z"].find(r=>e.has(r));return n!==void 0?"-"+n:e.has("best")?"--best":t.has("q")?"-q":t.has("quality")?"--quality":void 0}function xg(e,t,n,r){let{ctx:o}=r;if(e==="-"){let u=o.stdinBytes,a=o.stdinLeft;return q(o,"",!0),Hl(u??B(a),Xl,null,n,r)}let i=null;if(!n.stdout)if(!n.decompressing)i=e+Gr;else{if(e.length<=Gr.length)return Mt(r,`empty output file name for [${e}] input file`);if(e.endsWith(Gr))i=e.slice(0,-Gr.length);else return Mt(r,`input file [${e}] suffix mismatch`)}let s=P(o,"brotli",e);return s.error?Mt(r,`failed to open input file [${e}]: ${s.error}`):i!==null&&!n.force&&P(o,"brotli",i).error===null?Mt(r,`failed to open output file [${i}]: File exists`):o.fs.isDir(s.path)?Mt(r,`failed to read input [${e}]: Is a directory`):Hl(Be(o.fs,s.path),e,i,n,r)}async function Hl(e,t,n,r,o){let{ctx:i}=o,s=r.decompressing?await Hr(e,Di):{bytes:await Pn(e,Di),error:null};if(s.error)return Mt(o,`corrupt input [${t}]`);if(n===null)o.events.push({fd:1,bytes:s.bytes});else if(!kg(n,s.bytes,o))return!1;return r.remove&&t!==Xl&&i.fs.removeWritable(i.cwd,t),!0}function kg(e,t,n){let{ctx:r}=n,o;try{o=r.writable&&r.fs.openWritable?.(r.cwd,e)}catch(i){return Mt(n,`failed to open output file [${e}]: ${i.message}`)}return o?(o.writeBytes(t),!0):(n.gap??=v("feature","brotli","read-only target",`brotli: ${e}: file system is read-only`,1),!1)}function Mt(e,t){return e.stderr+=`${t}
|
|
34
|
+
`,e.status=1,!1}var Xr="gzip",vg=(e,t,n)=>Ui(e,["-d",...t],n),Yl=(e,t,n)=>Ui(e,["-d","-c",...t],n),Jl=zr(Xr)?{gzip:Ui,gunzip:vg,zcat:Yl,gzcat:Yl}:{},Vl=Object.freeze([31,139]),Sg=e=>e!==void 0&&e.length>=2&&e[0]===Vl[0]&&e[1]===Vl[1],Eg={__proto__:null,"unexpected end of file":"unexpected end of file","incorrect data check":"invalid compressed data--crc error"},$g=e=>Eg[e]??"invalid compressed data--format violated",Ql=Object.freeze({__proto__:null,".gz":"",".tgz":".tar",".taz":".tar","-gz":"",".z":"","-z":"",_z:""}),Ng=".gz",Kl=Object.freeze(["1","2","3","4","5","6","7","8","9"]);async function Ui(e,t,n){let{flags:r,positional:o}=N(t,{short:[...Kl,"d","c","k"],long:["decompress","uncompress","stdout","to-stdout","keep"]}),i=Kl.find(l=>r.has(l));if(i!==void 0)return v("option","gzip",`-${i}`,`gzip: -${i}: choosing a compression level is not supported`,1);let s={decompressing:["d","decompress","uncompress"].some(l=>r.has(l)),stdout:["c","stdout","to-stdout"].some(l=>r.has(l)),keep:r.has("k")||r.has("keep")},u={ctx:n,events:[],stderr:"",status:0,gap:null};if(o.length===0)await Ag(e,s,u);else for(let l of o)await Og(l,s,u);if(u.gap)return u.gap;let a=[...u.events,...u.stderr?[{fd:2,text:u.stderr}]:[]];return{stdout:"",stderr:u.stderr,exitCode:u.status,events:a}}async function Ag(e,t,n){let r=n.ctx.stdinBytes;return q(n.ctx,"",!0),t.decompressing&&r!==null?ef("stdin",r,{...t,stdout:!0},n):t.decompressing?Bi(n,e===""?"stdin: unexpected end of file":"stdin: not in gzip format"):ji(await Pn(r??B(e),Xr),n)}function Og(e,t,n){let{ctx:r}=n,o=P(r,"gzip",e);return o.error?Pt(n,`${e}: ${o.error}`,1):r.fs.isDir(o.path)?Pt(n,`${e} is a directory -- ignored`,2):t.decompressing?Lg(e,o.path,t,n):Cg(e,o.path,t,n)}async function Cg(e,t,n,r){let{ctx:o}=r,i=tf(e);if(!n.stdout&&i!==void 0)return Rg(r,`${e} already has ${i} suffix -- unchanged`);let s=Fg(await Pn(Be(o.fs,t),Xr),e.slice(e.lastIndexOf("/")+1),Ig(o));return n.stdout?ji(s,r):nf(e+Ng,s,e,n,r)}var Ig=e=>Math.floor(e.createdAt/1e3),Dn=10,Tg=8;function Fg(e,t,n){let r=B(t);if(e.length<Dn||e[3]!==0||r.includes(0))return e;let o=new Uint8Array(e.length+r.length+1);o.set(e.subarray(0,Dn)),o[3]=Tg;for(let i=0;i<4;i++)o[4+i]=n>>>8*i&255;return o.set(r,Dn),o.set(e.subarray(Dn),Dn+r.length+1),o}function Lg(e,t,n,r){let{ctx:o}=r,i=o.fs.isBytes?.(t)===!0?Be(o.fs,t):void 0;return ef(e,i,n,r,t)}async function ef(e,t,n,r,o=null){let{ctx:i}=r;if(!Sg(t))return Bi(r,`${e}: ${_g(t,o,i)?"unexpected end of file":"not in gzip format"}`);let s=await Hr(t,Xr),u=tf(e);(n.stdout?ji(s.bytes,r):u===void 0?Pt(r,`${e}: unknown suffix -- ignored`,2):nf(e.slice(0,-u.length)+Ql[u],s.bytes,e,n,r))&&s.error&&Bi(r,`${e}: ${$g(s.error)}`)}var tf=e=>Object.keys(Ql).find(t=>e.length>t.length&&e.endsWith(t));function _g(e,t,n){if(e!==void 0)return e.length<2;let r=n.fs.readFile(t);return r.length<2&&A(r).length<2}var ji=(e,t)=>(t.events.push({fd:1,bytes:e}),!0);function nf(e,t,n,r,o){let{ctx:i}=o;if(P(i,"gzip",e).error===null)return Pt(o,`${e} already exists; not overwritten`,2);let s;try{s=i.writable&&i.fs.openWritable?.(i.cwd,e)}catch(u){return Pt(o,`${e}: ${u.message}`,1)}return s?(s.writeBytes(t),r.keep||i.fs.removeWritable(i.cwd,n),!0):(o.gap??=v("feature","gzip","read-only target",`gzip: ${e}: file system is read-only`,1),!1)}var Bi=(e,t)=>Pt(e,t,1,`
|
|
35
|
+
`),Rg=(e,t)=>Pt(e,t,e.status);function Pt(e,t,n,r=""){return e.stderr+=`${r}gzip: ${t}
|
|
36
|
+
`,e.status=e.status===1?1:n,!1}var Mg=Object.freeze({__proto__:null,1:"SHA-1",256:"SHA-256",384:"SHA-384",512:"SHA-512"}),Pg=Object.freeze(["1","224","256","384","512","512224","512256"]),Dg=()=>{try{return typeof crypto?.subtle?.digest=="function"}catch{return!1}};async function Bg(e,t){let n=new Uint8Array(await crypto.subtle.digest(e,t));return Array.from(n,r=>r.toString(16).padStart(2,"0")).join("")}function Ug(e,t,n){let r=e==="shasum"?n.get("a")??"1":String(t);if(e==="shasum"&&!Pg.includes(r))return{error:x(`${e}: Unrecognized algorithm
|
|
37
|
+
Type shasum -h for help
|
|
38
|
+
`,1)};let o=Mg[r];return o===void 0?{error:v("feature",e,`SHA-${r}`,`${e}: this runtime's crypto does not digest SHA-${r}`,1)}:{algorithm:o}}function Bn(e,t){return async(n,r,o)=>{let{flags:i,order:s,positional:u,values:a}=N(r,{short:e==="shasum"?["b","t","c"]:["b","t","c","z"],long:e==="shasum"?["binary","text","check","tag"]:["binary","text","check","tag","zero"],valueShort:e==="shasum"?["a"]:[]});if(i.has("c")||i.has("check"))return v("feature",e,"-c",`${e}: reading a list of digests back is not supported`,1);let{algorithm:l,error:f}=Ug(e,t,a);if(f)return f;let{mode:c,error:d}=zg(e,i,s);if(d)return d;let p=te(e,u,n,o,{read:"bytes"}),h=await Promise.all(p.inputs.map(g=>Bg(l,g.bytes))),m=Hg(l,i,c);return ne(p.inputs.map((g,w)=>m(h[w],g.name??"-")).join(""),p)}}var jg=new Set(["b","binary"]),Wg=new Set(["t","text"]);function qg(e,t){let n=!1,r=null,o=!1;for(let{name:i}of t)jg.has(i)?(n=!0,r="binary"):Wg.has(i)?(o=!0,r="text"):i==="tag"&&(r="binary");return e==="shasum"?{binary:n,text:o&&!n,ambiguous:n&&o}:{binary:r==="binary",text:r==="text",ambiguous:!1}}function zg(e,t,n){let r=qg(e,n),o=e==="shasum"?`Type ${e} -h for help
|
|
39
|
+
`:`Try '${e} --help' for more information.
|
|
40
|
+
`;return r.ambiguous?{error:x(`${e}: Ambiguous file mode
|
|
41
|
+
${o}`,1)}:t.has("tag")&&r.text?{error:x(`${e}: --tag does not support --text mode
|
|
42
|
+
${o}`,1)}:{mode:r}}function Hg(e,t,n){let r=t.has("z")||t.has("zero")?"\0":`
|
|
43
|
+
`;if(t.has("tag")){let o=e.replace("-","");return(i,s)=>`${o} (${s}) = ${i}${r}`}return(o,i)=>`${o}${n.binary?" *":" "}${i}${r}`}var rf=Dg()?{sha1sum:Bn("sha1sum",1),sha256sum:Bn("sha256sum",256),sha384sum:Bn("sha384sum",384),sha512sum:Bn("sha512sum",512),shasum:Bn("shasum",1)}:{};var of={...Jl,...Gl,...rf};var Gg=new Uint8Array;function Zr(e,t,n,r,o){let i=sf(e,o.skip,o.skipFlag,0),s=sf(e,o.len,o.lenFlag,Number.POSITIVE_INFINITY);if(i.error||s.error)return{error:i.error??s.error};let u=s.value,a=i.value,l=0,f=n,c=r.stdinBytes,d=[],p={stderr:"",failed:!1};for(let g of t.length?t:[null]){let w=te(e,g===null?[]:[g],f,r,{read:"loose-bytes",noRead:u===0&&a===0}),y=w.entries[0]?.kind==="dir";if(p.stderr+=w.stderr,p.failed||=w.failed&&!(e==="hexdump"&&y),a&&y)return{error:v("feature",e,"skip across unreadable input",`${e}: skipping across a directory operand is not supported`)};if(y&&e==="xxd")return{error:x(p.stderr,2)};if(!w.inputs.length&&!y)continue;let k=w.inputs[0],S=k&&(k.shared||k.name===null);if(e==="hexdump"&&a&&S&&!r.stdinFile)return q(r,f,!0,c),{error:x("hexdump: standard input: Illegal seek")};let I=S&&r.stdinFile&&o.skip!==void 0&&(e==="xxd"||e==="hexdump"&&i.value>0),M=I?A(r.stdinOrigin):k?.bytes??Gg,C=Math.min(a,M.length);a-=C,l+=C;let H=Math.min(u,M.length-C);if(d.push(M.subarray(C,C+H)),u-=H,S){let Y=M.subarray(C+H),D=c!==null&&!I&&Y.length>0?Y:null;f=D===null?W(Y):me(Y)??"",q(r,f,!0,D)}if(I&&a&&(l=i.value,a=0),u===0&&a===0)break}if(a&&o.skipPastEofErrors)return{error:x(p.stderr+`${e}: cannot skip past end of combined input`)};let h=new Uint8Array(d.reduce((g,w)=>g+w.length,0)),m=0;for(let g of d)h.set(g,m),m+=g.length;return{bytes:h,start:l,r:p}}function sf(e,t,n,r){if(t===void 0)return{value:r};if(e==="xxd"&&!/^(?:0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.test(t))return{error:v("feature",e,`${n} ${t}`,`xxd: this offset/count spelling is not supported: ${t}`)};if(e==="hexdump")return/^[ \t\n\r\v\f]*[+\d-]/u.test(t)?!/^\d+$/u.test(t)||/^0\d/u.test(t)?{error:v("feature",e,`${n} ${t}`,`hexdump: this offset/count spelling is not supported: ${t}`)}:BigInt(t)>BigInt(Number.MAX_SAFE_INTEGER)?{error:v("feature",e,"large byte count","hexdump: counts beyond exact integer precision are not supported")}:{value:Number(t)}:{error:x(`${e}: ${n}: invalid count: ${t}`)};let o=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(t);if(!o)return{error:x(`${e}: ${n}: invalid count: ${t}`)};let i=/^0\d/u.test(o[1])?"0o"+o[1].slice(1):o[1];return ki(BigInt(i),o[2],`${e}: ${n}`,t)}var Yr=16,Xg=47,Zg=39;function lf(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["C","v"],valueShort:["n","s"]});if(i.includes("-"))return v("feature","hexdump","hyphen input operand","hexdump: a hyphen input operand is not supported; omit operands to read stdin");let s=Zr("hexdump",i,e,n,{skip:o.get("s"),len:o.get("n"),skipFlag:"-s",lenFlag:"-n"});return s.error?s.error:ne(qi(s.bytes,s.start,r.has("v"),r.has("C")?Vg:Yg),s.r)}function ff(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["v"],valueShort:["j","N"]});if(!r.size&&!o.size&&(i.length===1&&/^\+\d/u.test(i[0])||i.length===2&&/^\+?\d/u.test(i[1])))return v("feature","od","legacy offset operand","od: legacy offset operands are not supported; use -j OFFSET");let s=Zr("od",i,e,n,{skip:o.get("j"),len:o.get("N"),skipFlag:"-j",lenFlag:"-N",skipPastEofErrors:!0});return s.error?s.error:ne(qi(s.bytes,s.start,r.has("v"),Kg),s.r)}function cf(e,t,n){let{values:r,positional:o}=N(t,{valueShort:["s","l"]});if(o.length>2)return x("xxd: too many operands");if(o.length===2&&o[1]!=="-")return v("feature","xxd","output file","xxd: output files are not supported (filesystem is read-only)");let i=Zr("xxd",o.slice(0,1),e,n,{skip:r.get("s"),len:r.get("l"),skipFlag:"-s",lenFlag:"-l"});return i.error?i.error:ne(qi(i.bytes,i.start,!1,Jg),i.r)}function qi(e,t,n,r){let o=[],i=null,s=!1;for(let a=0;a<e.length;a+=Yr){let l=e.subarray(a,a+Yr);r.compress&&!n&&i!==null&&l.length===Yr&&tw(l,i)?s||(o.push("*"),s=!0):(o.push(r.row(t+a,l)),s=!1),i=l}let u=t+e.length;return(r.trailer==="always"||r.trailer==="nonzero"&&u>0)&&o.push(r.addr(u)),ge(o)}var Yg={compress:!0,trailer:"nonzero",addr:uf,row:(e,t)=>(uf(e)+" "+df(t).map(nw).join(" ")).padEnd(Xg)},Vg={compress:!0,trailer:"nonzero",addr:zi,row:Qg},Kg={compress:!0,trailer:"always",addr:af,row:(e,t)=>af(e)+" "+df(t).map(rw).join(" ")},Jg={compress:!1,trailer:"never",row:(e,t)=>`${zi(e)}: ${ew(t).join(" ").padEnd(Zg)} ${pf(t)}`};function uf(e){return e.toString(16).padStart(7,"0")}function zi(e){return e.toString(16).padStart(8,"0")}function af(e){return e.toString(8).padStart(7,"0")}function Qg(e,t){let n=[];for(let i=0;i<Yr;i++)n.push(i<t.length?Wi(t[i]):" ");let r=n.slice(0,8).join(" "),o=n.slice(8).join(" ");return`${zi(e)} ${r} ${o} |${pf(t)}|`}function df(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(n+1<e.length?e[n]|e[n+1]<<8:e[n]);return t}function ew(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Wi(e[n])+(n+1<e.length?Wi(e[n+1]):""));return t}function pf(e){let t="";for(let n of e)t+=n>=32&&n<=126?String.fromCodePoint(n):".";return t}function tw(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}var Wi=e=>e.toString(16).padStart(2,"0"),nw=e=>e.toString(16).padStart(4,"0"),rw=e=>e.toString(8).padStart(6,"0");var ow=76;function Vr(e,{encode:t,decode:n}){return(r,o,i)=>{let{flags:s,positional:u,order:a}=N(o,{short:["d","i"],long:["decode","ignore-garbage"],valueShort:["w"],valueLong:["wrap"]}),l=ow;for(let{name:p,value:h}of a){if(p!=="w"&&p!=="wrap")continue;if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(h)||BigInt(h)<0n)return x(`${e}: invalid wrap size: ${h}`);let m=BigInt(h);l=m>ue?0:Number(m)}if(u.length>1)return x(`${e}: extra operand: ${u[1]}`);let f=te(e,u,r,i,{read:"as-held"});if(f.failed)return x(f.stderr);let{content:c,bytes:d}=f.inputs[0];return s.has("d")||s.has("decode")?sw(e,n(c??ui(d),s.has("i")||s.has("ignore-garbage"))):iw(t(d??B(c)),l)}}function iw(e,t){if(!t||e==="")return F(e);let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return F(n.join(`
|
|
37
44
|
`)+`
|
|
38
|
-
`)}function
|
|
39
|
-
`;return{stdout:
|
|
40
|
-
`)return!0;if(n!=="\\")continue;let r=e[t+1];if(r==="n"||r==="x"&&/^x\{?0*a\}?/iu.test(e.slice(t+1)))return!0;t++}return!1}function tf(e,t){if(!t)for(let n of e){for(let[r,i]of Eg)if(r.test(n))throw Rn(i,`${i} is not supported; ripgrep's regex engine rejects it too`);if(Ng(n))throw Rn("newline in a pattern","a newline in a pattern is not supported; ripgrep rejects one outside multiline mode")}}var $=class extends Error{constructor(t,n=null,r=null){super(t),this.line=n,this.gap=r}},nf=new Set(["BEGIN","END","BEGINFILE","ENDFILE","function","func","if","else","while","for","do","break","continue","next","nextfile","exit","return","delete","in","getline","print","printf","switch","case","default"]),Po={__proto__:null,length:[0,1],substr:[2,3],index:[2,2],split:[2,3],sub:[2,3],gsub:[2,3],gensub:[3,4],match:[2,3],sprintf:[1,1/0],sin:[1,1],cos:[1,1],atan2:[2,2],exp:[1,1],log:[1,1],sqrt:[1,1],int:[1,1],rand:[0,0],srand:[0,1],tolower:[1,1],toupper:[1,1],close:[1,2],fflush:[0,1],systime:[0,0],strtonum:[1,1],and:[2,1/0],or:[2,1/0],xor:[2,1/0],lshift:[2,2],rshift:[2,2],compl:[1,1],typeof:[1,1],isarray:[1,1]},jr=new Map([["system","system() is not supported: this terminal runs no processes"],["strftime","strftime() is not supported (gawk extension)"],["mktime","mktime() is not supported (gawk extension)"],["asort","asort() is not supported (gawk extension)"],["asorti","asorti() is not supported (gawk extension)"],["patsplit","patsplit() is not supported (gawk extension)"]]),rf=new Set([...Object.keys(Po),...jr.keys()]),Mn=5e6,Do=100,Ee=1e6,zr="this terminal runs no processes";function Hr(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;default:return t**n}}var of={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},Ag='^$.[]|()*+?{}\\/"',Uo=1e3,sf=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),uf=e=>e!==void 0&&e>="0"&&e<="7",Bo=class{constructor(t,n,r,i){this.src=t,this.i=0,this.warn=n,this.tables=r,this.ignoreCase=i,this.groups=0}fail(t){throw new $(`invalid regex /${this.src}/: ${t}`)}peek(){return this.src[this.i]}literal(){let t=this.src.codePointAt(this.i);return this.i+=Pe(t),this.charNode(t)}charNode(t){let n=this.ignoreCase?this.tables.fold(t):[t];return n.length===1?{type:"char",code:t}:{type:"set",negate:!1,items:n.map(r=>[r,r])}}parse(){return this.alternation(0)}alternation(t){let n=[this.concatenation(t)];for(;this.peek()==="|";)this.i++,n.push(this.concatenation(t));return n.length===1?n[0]:{type:"alt",nodes:n}}concatenation(t){let n=[];for(;!this.endsConcatenation(t);)n.push(this.quantified(this.atom(n.length===0,t)));return n.length===1?n[0]:{type:"cat",nodes:n}}endsConcatenation(t){let n=this.peek();return n===void 0||n==="|"||n===")"&&t>0}quantified(t){let n=t;for(;;){let r=this.peek();if(r==="*"){this.i++,n={type:"rep",node:n,min:0,max:null};continue}if(r==="+"){this.i++,n={type:"rep",node:n,min:1,max:null};continue}if(r==="?"){this.i++,n={type:"rep",node:n,min:0,max:1};continue}if(r==="{"){let i=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!i&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail("invalid content of {}"),!i||i[1]===""&&i[2]===void 0)return n;let o=i[1]===""?0:Number(i[1]),s=i[2]===void 0?o:i[3]===""?null:Number(i[3]);if(s!==null&&s<o&&this.fail(`invalid interval {${o},${s}}`),o>Uo||s!==null&&s>Uo)throw new $(`interval count above ${Uo} is not supported`,null,"regex interval limit");this.i+=i[0].length,n={type:"rep",node:n,min:o,max:s};continue}return n}}atom(t,n){let r=this.peek();if(r==="("){this.i++;let i=++this.groups,o=this.alternation(n+1);return this.peek()!==")"&&this.fail("missing `)`"),this.i++,{type:"group",index:i,node:o}}return r==="["?this.bracket():r==="\\"?this.escape():(this.i++,r==="."?{type:"any"}:r==="^"||r==="$"?{type:"assert",kind:r}:((r==="*"||r==="+"||r==="?")&&!t&&this.fail(`unexpected \`${r}\``),this.i--,this.literal()))}escape(){this.i++;let t=this.peek();return t===void 0&&this.fail("trailing backslash"),this.i++,t==="y"?{type:"assert",kind:"y"}:t==="<"||t===">"||t==="B"?{type:"assert",kind:t}:t==="`"?{type:"assert",kind:"^"}:t==="'"?{type:"assert",kind:"$"}:t==="s"||t==="S"?{type:"set",negate:t==="S",items:this.tables.ranges("space")}:t==="w"||t==="W"?{type:"set",negate:t==="W",items:this.tables.ranges("word")}:(t==="b"&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(t,!0)))}escapedCode(t,n){if(t in of)return of[t];if(uf(t)){let i=t;for(;i.length<3&&uf(this.peek());)i+=this.src[this.i++];return af(i,8)}if(t==="x"&&sf(this.peek())){let i="";for(;i.length<2&&sf(this.peek());)i+=this.src[this.i++];return af(i,16)}let r=this.src.codePointAt(this.i-1);return!Ag.includes(t)&&n&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(r)}' is not a known regexp operator`),this.i+=Pe(r)-1,r}bracket(){this.i++;let t=!1;this.peek()==="^"&&(t=!0,this.i++);let n=[],r=!0;for(;;){this.i>=this.src.length&&this.fail("unterminated bracket expression");let i=this.peek();if(i==="]"&&!r){this.i++;break}if(r=!1,i==="["&&this.src[this.i+1]===":"){let s=this.src.indexOf(":]",this.i+2);if(s!==-1){let u=this.src.slice(this.i+2,s),a=this.tables.ranges(this.ignoreCase?Fr(u):u);a===void 0&&this.fail(`invalid character class \`[:${u}:]\``),n.push(...a),this.i=s+2;continue}}let o=this.bracketChar();if(this.peek()==="-"&&this.src[this.i+1]!=="]"&&this.src[this.i+1]!==void 0){this.i++;let s=this.bracketChar(),u=this.ignoreCase?this.tables.foldRange(o,s):s<o?null:[[o,s]];u===null&&this.fail("invalid range end"),n.push(...u)}else this.ignoreCase?n.push(...this.tables.fold(o).map(s=>[s,s])):n.push([o,o])}return{type:"set",negate:t,items:n}}bracketChar(){let t=this.peek();if(t==="["&&(this.src[this.i+1]==="."||this.src[this.i+1]==="=")){let r=this.src.indexOf(this.src[this.i+1]+"]",this.i+2);if(r!==-1&&r>this.i+2){Array.from(this.src.slice(this.i+2,r)).length!==1&&this.fail("invalid collation character");let i=this.src.codePointAt(this.i+2);return this.i=r+2,i}}if(t==="\\"){this.i++,this.peek()===void 0&&this.fail("trailing backslash");let r=this.src[this.i++];return this.escapedCode(r,!1)}let n=this.src.codePointAt(this.i);return this.i+=Pe(n),n}};function Xr(e,t=null,n=Q(J),r=!1){let i=new Bo(e,t,n,r);return{ast:i.parse(),groups:i.groups}}function af(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new $("non-ASCII regex byte escapes are not supported",null,"regex byte escapes");return n}var Og=e=>`\\u{${e.toString(16)}}`,Gr=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):Og(e);function Ig(e,t){if(e==="^"||e==="$")return e;let n=t.assertions();return e==="y"?n.boundary:e==="B"?n.inside:n[e]}function qo(e,t=Q(J)){let n=r=>qo(r,t);switch(e.type){case"char":return Gr(e.code);case"any":return".";case"set":return`[${e.negate?"^":""}${e.items.map(([r,i])=>r===i?Gr(r):`${Gr(r)}-${Gr(i)}`).join("")}]`;case"assert":return Ig(e.kind,t);case"group":return`(${n(e.node)})`;case"cat":return e.nodes.map(n).join("");case"alt":return`(?:${e.nodes.map(n).join("|")})`;case"rep":{let r=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${r}*`:e.min===1?`${r}+`:`${r}{${e.min},}`:e.min===0&&e.max===1?`${r}?`:`${r}{${e.min},${e.max}}`}default:throw new $(`internal: unknown regex node ${e.type}`)}}var Cg=5e4;function Fg(e,t){let n=r=>{for(let i=0;i<e.length;i++)if(r>=e[i][0]&&r<=e[i][1])return!0;return!1};return t?r=>!n(r):n}function lf(e,t=Q(J)){let n=[],r=l=>{if(n.length>=Cg)throw new $("regex too large",null,"regex state limit");return n.push(l),n.length-1};function i(l,f){switch(l.type){case"char":return r({op:"char",codes:[l.code],next:f});case"any":return r({op:"any",next:f});case"set":return r({op:"set",test:Fg(l.items,l.negate),next:f});case"assert":return r({op:"assert",kind:l.kind,next:f});case"group":return i(l.node,f);case"cat":{let c=f;for(let d=l.nodes.length-1;d>=0;d--)c=i(l.nodes[d],c);return c}case"alt":{let c=l.nodes.map(p=>i(p,f)),d=c.at(-1);for(let p=c.length-2;p>=0;p--)d=r({op:"split",x:c[p],y:d});return d}case"rep":return o(l,f);default:throw new $(`internal: unknown regex node ${l.type}`)}}function o(l,f){let c=f;if(l.max===null){let d=r({op:"split",x:-1,y:f});n[d].x=i(l.node,d),c=d}else for(let d=l.max-l.min;d>0;d--)c=r({op:"split",x:i(l.node,c),y:f});for(let d=0;d<l.min;d++)c=i(l.node,c);return c}let s=i(e,r({op:"match"})),u="",a=s;for(;n[a].op==="char"&&n[a].codes.length===1&&n[a].codes[0]<128;)u+=String.fromCodePoint(n[a].codes[0]),a=n[a].next;return(n[a].op!=="match"||u==="")&&(u=null),{states:n,start:s,literal:u,isWord:l=>t.has("word",l),gen:new Int32Array(n.length).fill(-1),stamp:0}}function Tg(e,t){if(t<=0)return-1;let n=e.codePointAt(t-1);return n>=56320&&n<=57343&&t>=2?e.codePointAt(t-2):n}function _g(e,t,n,r){if(e==="^")return n===0;if(e==="$")return n===t.length;let i=r(Tg(t,n)),o=n<t.length&&r(t.codePointAt(n));return e==="y"?i!==o:e==="B"?i===o:e==="<"?!i&&o:i&&!o}function Lg(e,t){return e.op==="char"?e.codes.includes(t):e.op==="any"?!0:e.test(t)}function ff(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let p=t.indexOf(e.literal,n);return p<0?null:{start:p,end:p+e.literal.length}}let{states:r,gen:i}=e,o=t.length,s=[],u=(p,h,m,g,b)=>{for(s.push(h);s.length>0;){let x=s.pop();if(i[x]===b)continue;i[x]=b;let S=r[x];S.op==="split"?s.push(S.y,S.x):S.op==="assert"?_g(S.kind,t,g,e.isWord)&&s.push(S.next):p.push(x,m)}},a=[],l=[],f=null,c=n,d=++e.stamp;for(;;){f===null&&u(a,e.start,c,c,d);let p=c<o?t.codePointAt(c):-1,h=Pe(p);if(a.length===0){if(f!==null||c>=o)break;c+=h,d=++e.stamp;continue}let m=++e.stamp;for(let g=0;g<a.length;g+=2){let b=a[g],x=a[g+1];if(f!==null&&x>f.start)continue;let S=r[b];if(S.op==="match"){(f===null||x<f.start||x===f.start&&c>f.end)&&(f={start:x,end:c});continue}p!==-1&&Lg(S,p)&&u(l,S.next,x,c+h,m)}if(a.length=0,[a,l]=[l,a],d=m,c>=o)break;c+=h}return f}var Zr=new Map,at=class{constructor(t,n,r,i=Q(J)){let{ast:o,groups:s}=Xr(t,r,i,n);this.src=t,this.ignoreCase=n,this.tables=i,this.groupCount=s,this.source=qo(o,i),this.flags="su";try{this.js=new RegExp(this.source,this.flags)}catch(u){throw new $(`cannot compile regex /${t}/: ${u.message}`,null,"regex engine limit")}this.ast=o,this.nfa=null,this.capture=null,this.captureShape=cf(o)}test(t){return this.checkCase(t),this.js.test(t)}checkCase(t){if(this.ignoreCase&&It.test(t+this.src))throw new $("case-insensitive matching over Cyrillic Extended-C letters is not supported",null,"locale-sensitive regex")}search(t,n=0){return this.checkCase(t),this.nfa===null&&(this.nfa=lf(this.ast,this.tables)),ff(this.nfa,t,n)}groups(t,n,r){if(this.captureShape.unsafe)throw new $("capture extraction across repeated or alternative groups is not supported",null,"regex capture semantics");let i=this.capture??=new RegExp(this.source,this.flags+"dy");i.lastIndex=n;let o=i.exec(t);if(!o||o.index!==n||n+o[0].length!==r){let s=Array.from(t.slice(r)).length,u=new RegExp(`(?:${this.source})(?=.{${s}}(?![^]))`,this.flags+"dy");u.lastIndex=n,o=u.exec(t)}if(!o)throw new $("capture extraction for this match is not supported",null,"regex capture semantics");return o.indices.map((s,u)=>s===void 0?void 0:{text:o[u],start:s[0],end:s[1]})}};function cf(e){let n=(e.nodes??(e.node?[e.node]:[])).map(cf),r=n.reduce((s,u)=>s+u.groups,e.type==="group"?1:0),i=e.type==="assert"||(e.type==="group"||e.type==="cat")&&n.every(s=>s.nullable)||e.type==="alt"&&n.some(s=>s.nullable)||e.type==="rep"&&(e.min===0||n[0].nullable),o=e.type==="rep"&&(e.max===null||e.max>1)&&(r>1||r>0&&n[0].nullable);return{groups:r,nullable:i,unsafe:o||e.type==="alt"&&r>0||n.some(s=>s.unsafe)}}function Fe(e,t=!1,n=null,r=Q(J)){let i=(t?"i":"c")+r.name+"\0"+e,o=Zr.get(i);if(o)return o;Zr.size>=500&&Zr.clear();let s=new at(e,t,n,r);return Zr.set(i,s),s}function Wo(e,t,n){for(;;){let r=t.search(e,n);if(!r||r.start!==r.end)return r;if(r.end>=e.length)return null;n=r.end+Ie(e,r.end)}}function jo(e,t){let n=[],r=0;for(;;){let i=Wo(e,t,r);if(!i)break;n.push(e.slice(r,i.start)),r=i.end}return n.push(e.slice(r)),n}function Pn(e,t,n,r){let i=r!=="first",o=e.length,s="",u=0,a=-1,l=0;for(;u<=o;){let f=t.search(e,u);if(!f)break;let c=f.start===f.end;if(c&&f.start===a&&r!=="nth"){if(f.start>=o)break;let p=Ie(e,f.start);s+=e.slice(u,f.start+p),u=f.start+p;continue}l++;let d=n(f.start,f.end,l);if(s+=e.slice(u,f.start)+(d===null?e.slice(f.start,f.end):d),a=f.end,c){if(f.end>=o){u=o;break}let p=Ie(e,f.end);s+=e.slice(f.end,f.end+p),u=f.end+p}else u=f.end;if(!i)break}return{out:s+e.slice(u),count:l}}function Yr(e,t){let n="(){}+?|",r=!1,i=0,o=!1,s="";for(let u=0;u<e.length;u++){let a=e[u];if(o){if(a==="["&&(e[u+1]==="."||e[u+1]==="="))throw new w("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");if(a==="["){let l=Xt(e,u,{classes:t});if(l){s+=l.body,u=l.end-1;continue}}s+=a,a==="]"&&(o=!1,r=!0);continue}if(a==="["){s+=a,o=!0,e[u+1]==="^"&&(s+="^",u++),e[u+1]==="]"&&(s+="\\]",u++);continue}if(a==="\\"){let l=e[++u];if(l===void 0)return{error:"trailing backslash (\\)"};if(n.includes(l)){if((l==="+"||l==="?")&&!r){s+="\\"+l,r=!0;continue}if(l==="("&&i++,l===")"&&i--===0)return{error:"Unmatched ) or \\)"};(l==="("||l==="|")&&(r=!1),(l===")"||l==="}")&&(r=!0),s+=l}else s+="^$\\.*[]/bBsSwW<>`'123456789".includes(l)?"\\"+l:l,r=!"bB<>`'".includes(l);continue}if(a==="*"){s+=r?"*":"\\*",r=!0;continue}if(a==="^"){r=!Rg(e,u),s+=r?"\\^":"^";continue}if(a==="$"){r=!(u===e.length-1||e[u+1]==="\\"&&(e[u+2]===")"||e[u+2]==="|")),s+=r?"\\$":"$";continue}s+=n.includes(a)?"\\"+a:a,r=!0}return i>0?{error:"Unmatched ( or \\("}:{source:s}}function Rg(e,t){if(t===0)return!0;if(t<2||e[t-2]!=="\\"||e[t-1]!=="("&&e[t-1]!=="|")return!1;let n=0;for(let r=t-3;r>=0&&e[r]==="\\";r--)n++;return n%2===0}function Vr(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,i=!1,o=0,s=!1,u=[],a=new Set,l=!1;for(let f=0;f<e.length;f++){let c=e[f];if(c==="\\"){let d=e[++f];if(!i&&/[1-9]/u.test(d??"")){let p=Number(d);if(!t.has(p))throw new Error("Invalid back reference");(!a.has(p)||r.has(p))&&(s=!0)}u=[];continue}if(i){c==="]"&&(i=!1);continue}if(c==="["){i=!0,u=[];continue}if(c==="(")n.push({id:++o,entry:new Set(a),branches:[],start:f}),u=[];else if(c==="|"){let d=n.at(-1);d&&d.branches.push(a),a=new Set(d?.entry),u=[]}else if(c===")"){let d=n.pop();if(!d)continue;a=d.branches.reduce((p,h)=>p.intersection(h),a),a.add(d.id),t.add(d.id),u=[...a.difference(d.entry)],l=Mg(e.slice(d.start,f+1))}else if(c==="*"||c==="?"||c==="+"){if(c!=="?"&&l)for(let d of u)r.add(d);if(c!=="+")for(let d of u)a.delete(d)}else if(c==="{"){let d=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(f));if(d){Number(d[1])===0&&(a=a.difference(new Set(u)));let p=d[2]===void 0?Number(d[1]):d[2]===""?1/0:Number(d[2]);l&&p>1&&u.forEach(h=>r.add(h)),f+=d[0].length-1}else u=[]}else u=[]}return s}function Mg(e){try{return new RegExp(`^(?:${e})$`,"su").test("")}catch{return!0}}var Pg="bBsSwW";function Dn(e,t){let n="";for(let r=0;r<e.length;){let i=e[r];if(i==="["){let l=Dg(e,r,t);n+=l.text,r=l.end;continue}let o=i==="\\",s=e.codePointAt(r+(o?1:0)),u=(o?1:0)+Pe(s),a=o&&Pg.includes(e[r+1])?null:t.fold(s);n+=a===null||a.length===1?e.slice(r,r+u):`[${String.fromCodePoint(...a)}]`,r+=u}return n}function df(e,t){let n="";for(let r of e){let i=t.fold(r.codePointAt(0));n+=i.length===1?RegExp.escape(r):`[${String.fromCodePoint(...i)}]`}return n}function Dg(e,t,n){let r=t+1,i="[";e[r]==="^"&&(i+="^",r++);let o=!0;for(;;){let s=e[r];if(s==="]"&&!o)return{text:i+"]",end:r+1};if(o=!1,s==="["&&":.=".includes(e[r+1])){let l=e[r+1],f=e.indexOf(l+"]",r+2);i+=l===":"?`[:${Fr(e.slice(r+2,f))}:]`:e.slice(r,f+2),r=f+2;continue}let u=e.codePointAt(r),a=r+Pe(u);if(e[a]==="-"&&e[a+1]!==void 0&&e[a+1]!=="]"){let l=e.codePointAt(a+1),f=a+1+Pe(l);i+=Ug(u,l,e.slice(r,f),n),r=f;continue}i+=String.fromCodePoint(...n.fold(u)),r=a}}function Ug(e,t,n,r){let i=r.foldRange(e,t);if(i===null)throw new Error("Invalid range end");return i.length===1&&i[0][0]===e&&i[0][1]===t?n:i.map(([o,s])=>o===s?String.fromCodePoint(o):`${String.fromCodePoint(o)}-${String.fromCodePoint(s)}`).join("")}function Ne(e){throw new w("feature","PCRE "+e,`PCRE ${e} is not supported`)}function pf(e){let t={captures:0,closed:new Set,names:new Map,stack:[],behind:0,references:!1,risky:!1},n="";for(let r=0;r<e.length;){let i=e[r];if(i==="\\"){let o=hf(e,r,t,!1);n+=o.source,r=o.end;continue}if(i==="["){let o=Wg(e,r,t);n+=o.source,r=o.end;continue}if(i==="("){let o=Bg(e,r,t);n+=o.source,r=o.end;continue}if(i===")"){let o=t.stack.pop();o?.capture&&t.closed.add(o.capture),o?.behind&&t.behind--}if("*+?".includes(i)&&(t.behind&&Ne("variable-length lookbehind"),e[r+1]==="+"&&Ne("possessive repetition"),i!=="+"&&(t.risky=!0)),i==="|"&&(t.risky=!0),i==="{"){let o=qg(e,r,t);n+=o.source,r=o.end;continue}n+=i==="]"||i==="}"?"\\"+i:i,r++}return t.references&&t.risky&&Ne("conditional backreference"),n}function Bg(e,t,n){let r=!1,i=null,o="(";if(e[t+1]==="*"&&Ne("control verb"),e[t+1]==="?"){let s=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(s||Ne("group"),o=s[0],r=o==="(?<="||o==="(?<!",!s[1]&&o!=="(?:"&&(n.risky=!0),s[1]){if(i=++n.captures,n.names.has(s[1]))throw new Error("duplicate PCRE capture name");n.names.set(s[1],i)}}else i=++n.captures;return r&&n.behind++,n.stack.push({capture:i,behind:r}),{source:o,end:t+o.length}}function qg(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&Ne("repetition"),{source:"\\{",end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&Ne("variable-length lookbehind"),Number(r[1])>65535||Number(r[2])>65535)throw new Error("PCRE repetition count exceeds 65535");return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]==="+"&&Ne("possessive repetition"),{source:r[0],end:t+r[0].length}}function Wg(e,t,n){let r=t+1,i="[";for(e[r]==="^"&&(i+="^",r++),e[r]==="]"&&(i+="\\]",r++);r<e.length&&e[r]!=="]";)if(e[r]==="["&&":.=".includes(e[r+1]??"")&&Ne("character class"),e[r]==="\\"){let o=hf(e,r,n,!0);i+=o.source,r=o.end}else i+=e[r]==="["?"\\[":e[r],r++;return{source:i+(e[r]==="]"?"]":""),end:r+1}}function hf(e,t,n,r){let i=e[t+1];if(i===void 0)throw new Error("trailing backslash");if(i==="Q"){let s=e.indexOf("\\E",t+2);return{source:RegExp.escape(e.slice(t+2,s<0?void 0:s)),end:s<0?e.length:s+2}}if(i==="E")return{source:"",end:t+2};if(i==="x"||i==="0"||r&&/[1-7]/u.test(i))return jg(e,t);if(i==="a"||i==="e")return{source:i==="a"?"\\u0007":"\\u001B",end:t+2};if("AzZ".includes(i)&&!r)return{source:i==="A"?"^":"$",end:t+2};if(/[1-9]/u.test(i)&&!r)return(/\d/u.test(e[t+2]??"")||!n.closed.has(Number(i)))&&Ne("forward or ambiguous backreference"),n.references=!0,{source:"\\"+i,end:t+2};if(i==="k"&&!r){let s=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return(!s||!n.closed.has(n.names.get(s[1])))&&Ne("named backreference"),n.references=!0,{source:s[0],end:t+s[0].length}}if("dDsSwWfnrtbB".includes(i))return{source:"\\"+i,end:t+2};/[A-Za-z0-9]/u.test(i)&&Ne("escape \\"+i);let o=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(o),end:t+1+o.length}}function jg(e,t){let n=e[t+1]==="x",r=(n?/^\\x(?:\{([\da-fA-F]+)\}|([\da-fA-F]{1,2}))/u:/^\\([0-7]{1,3})/u).exec(e.slice(t));if(!r)throw new Error("invalid PCRE character escape");let i=n?16:8,o=parseInt(r[1]??r[2],i);return Xe(o)||Ne("character escape"),{source:`\\u{${o.toString(16)}}`,end:t+r[0].length}}function Ho(e,t){let n="",r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(o==="\\"){let s=e[++i]??"";n+=r?o+s:zg(s);continue}if(r&&o==="["){if(e[i+1]==="."||e[i+1]==="=")throw new w("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");let s=Xt(e,i,{classes:t});if(s){n+=s.body,i=s.end-1;continue}}if(o==="["&&!r){n+="[",r=!0,e[i+1]==="^"&&(n+="^",i++),e[i+1]==="]"&&(n+="\\]",i++);continue}o==="]"&&(r=!1),n+=o}return n}function zg(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?"\\"+e:RegExp.escape(e)}function Hg(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"){if("bBsSwW<>".includes(e[++t]??""))return!0}else if(".[*+?{".includes(e[t]))return!0;return!1}function Un(e,t=!1,n=Q(J)){let r=n.assertions(),i=t?{b:"\\y"}:{"<":r["<"],">":r[">"],b:r.boundary,B:r.inside,w:r.word,W:r.nonWord,s:r.space,S:r.nonSpace,"`":"^","'":"$"},o="",s=!1;for(let u=0;u<e.length;u++){let a=e[u];if(a==="\\"){let l=e[++u];o+=!s&&Object.hasOwn(i,l)?i[l]:a+l,!t&&!s&&/[1-9]/u.test(l)&&/\d/u.test(e[u+1]??"")&&(o+="(?:)")}else a==="["&&(s=!0),a==="]"&&(s=!1),o+=a}return o}var Go=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,Gg=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function mf(e,t,n){let r=(n?Go:Gg).exec(e.slice(t));if(!r&&!n)throw new Error("invalid repetition count");r&&$a(Number(r[1]),r[2]===void 0||r[2]===""?void 0:Number(r[2]))}var gf={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function Xg(e){if(gf[e])return gf[e];let t=Go.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===""?1/0:Number(t[2])}}var wf=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function Zg(e,t){let n=Math.max(t.min,1);if(n>t.max)return{min:0,max:0};if(e.min>0&&(t.min===0&&e.min>1||e.max!==1/0&&t.max>n&&(n+1)*e.min>n*e.max+1))return null;let r=wf(t.max,e.max);return r!==1/0&&r>Ar?null:{min:wf(t.min,e.min),max:r}}function zo(e){return e.max===1/0?e.min===0?"*":e.min===1?"+":`{${e.min},}`:e.min===0&&e.max===1?"?":e.min===e.max?`{${e.min}}`:`{${e.min},${e.max}}`}var Yg=e=>!e.startsWith("(")&&!/^\\[1-9]/u.test(e);function Vg(e,t){if(t.length===1)return e+zo(t[0].bounds);let n=t[0].bounds,r=null;for(let i=1;i<t.length;i++){let{bounds:o,text:s}=t[i],u=r===null?Zg(n,o):null;if(u){n=u;continue}if(!(r===null&&n.min===n.max&&Yg(e))&&o.max>1)throw new Error("stacked quantifier needs ambiguous nesting");r=`(?:${r??e+zo(n)})${s}`}return r??e+zo(n)}function Kg(e,t){let n=t+1;for(e[n]==="^"&&n++;n<e.length;n++){if(e[n]==="\\"){n++;continue}if(e[n]==="]")return n}return e.length-1}function Jg(e){let t="",n=-1,r=-1,i=[],o=()=>{i.length>0&&(t=t.slice(0,n)+Vg(t.slice(n,r),i)),i=[]},s=a=>{o(),n=t.length,r=-1,t+=a},u=[];for(let a=0;a<e.length;a++){let l=e[a];if(l==="\\"){s(l+(e[++a]??""));continue}if(l==="["){let c=Kg(e,a);s(e.slice(a,c+1)),a=c;continue}if(l==="("){o(),u.push(t.length),n=-1,t+=l;continue}if(l===")"){o(),t+=l,n=u.pop()??-1,r=-1;continue}if(l==="|"||l==="^"||l==="$"){o(),t+=l,n=-1;continue}let f=l==="{"?Go.exec(e.slice(a)):null;if(l==="*"||l==="+"||l==="?"||f){let c=f?f[0]:l;if(a+=c.length-1,n<0){t+=c;continue}i.length===0&&(r=t.length),i.push({bounds:Xg(c),text:c});continue}s(l)}return o(),t}function Xo(e,t,n=!1){let r=-1;for(let i=0;i<e.length;i++){let o=i<=r,s=e[i];if(s==="\\"){let u=e[++i];if(u===void 0)throw new Error("trailing backslash");if(o||u&&"dDxXuUpPkKcC".includes(u))throw new w("feature","regex escape","grep: this regex escape is not supported with GNU semantics");!t&&u==="{"&&mf(e,i-1,!1)}else if(s==="["&&!o)r=Ea(e,i,n);else{if(o)continue;if(t&&s==="{")mf(e,i,!0);else if(t&&s==="("&&e[i+1]==="?")throw new w("feature","regex extension","grep: ECMAScript group extensions are not supported in ERE")}}}function Qg(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"&&/[1-9]/u.test(e[++t]??""))return!0;return!1}function bf(e,t,n=J){let r=Q(n),i=[],o=t.has("x"),s=t.has("w")&&!o;if(t.has("P")&&new Set(e).size>1)return{error:y("grep: -P only supports a single pattern",2)};for(let u of e){let a=!t.has("F")&&!t.has("P");a&&Xo(u,t.has("E"),r.multibyte);let l=a&&Qg(u),f=t.has("i")&&!t.has("P")&&!l,c=t.has("i")&&!f?"isu":"su",d;if(t.has("F"))d=f?df(u,r):RegExp.escape(u);else if(t.has("P"))d=pf(u);else if(t.has("E"))d=Ho(f?Dn(u,r):u,r);else{let h=Yr(f?Dn(u,r):u,r);if(h.error)return{error:y(`grep: ${h.error}`,2)};d=h.source}let p=d;if(a&&Vr(p))return{error:k("feature","grep","conditional backreference","grep: backreferences with conditional or repeated-empty captures are not supported",2)};s&&(d=`(?<!${r.assertions().word})(?:${d})(?!${r.assertions().word})`),o&&(d=`^(?:${d})$`);try{let h=new RegExp(a?Un(Jg(d),!1,r):d,c);h.pcre=t.has("P"),h.localeSensitive=h.pcre?t.has("i")||s||Hg(p)||/\\[dD]/u.test(p):t.has("i")&&l,h.folded=f,h.extendedC=f&&It.test(u),h.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(u);let m=t.has("F")||!$f.test(u);if(h.binaryLiteral=!o&&!s&&m,m&&u.isWellFormed()&&(f||!t.has("i"))&&(h.literal={pattern:u,tables:r}),t.has("o")&&a&&!o){if(s||/\\[1-9]|\(\?/u.test(d))return{error:k("feature","grep","-o regex extent","grep: only-matching with backreferences, lookarounds or word constraints is not supported",2)};try{h.extent=new at(Un(d,!0,r),!1,null,r)}catch{return{error:k("feature","grep","-o regex extent","grep: POSIX match extent for this pattern is not supported",2)}}}i.push(h)}catch(h){if(!t.has("P")&&ew(p,t))return{error:k("feature","grep","GNU regex syntax","grep: this GNU regular expression cannot be represented by the JavaScript matcher",2)};let m=t.has("F")?`fixed-string /${c}`:t.has("P")?`PCRE subset /${c}`:t.has("E")?`ERE / ECMAScript /${c}`:`BRE /${c}`;return{error:y(`grep: invalid pattern (${m}): ${h.message}`,2)}}}return{res:i}}function ew(e,t){if(!t.has("E")&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return Xr(Un(e,!0)),!0}catch(n){return!!n.gap}}function yf({pattern:e,tables:t},n){return[...e].map(r=>(n?t.fold(r.codePointAt(0)):[r.codePointAt(0)]).map(o=>q(String.fromCodePoint(o))))}function xf(e,t){return t.every(n=>n.literal?(n.literalMask??=yf(n.literal,n.folded),!vf(e,n.literalMask)):!1)}function kf(e,t,n,r=J){let i=Q(r);return t.every(o=>(n||!$f.test(o))&&o.isWellFormed()&&!vf(e,yf({pattern:o,tables:i},!1)))}function vf(e,t){for(let n=0;n+t.length<=e.length;n++)if(Sf(e,n,t,0))return!0;return!1}function Sf(e,t,n,r){return r===n.length?!0:n[r].some(i=>i.every((o,s)=>e[t+s]===o)&&Sf(e,t+i.length,n,r+1))}var $f=/[\\.^$*+?()[\]{}|]/u;function Zo(e,t,n,r=!1,i=J){if(e.length===0)return null;if(e.some(a=>a.content===void 0))return k("feature","grep","binary input","grep: binary input detection and output are not supported",2);if(!r&&e.some(a=>a.content.includes("\0")&&(n||t.some(l=>!l.binaryLiteral||l.test(a.content)))))return k("feature","grep","binary input","grep: binary input detection and output are not supported",2);let o=/[\u0080-\u{10FFFF}]/u;if(i!==J&&t.some(a=>a.localeSensitive||a.folded)&&(t.some(a=>a.unicodePattern)||e.some(a=>o.test(a.content))))return k("feature","grep","locale",`grep: matching non-ASCII text in the ${i} locale is not supported`,2);if(t.some(a=>a.extendedC)||t.some(a=>a.folded)&&e.some(a=>It.test(a.content)))return k("feature","grep","locale-sensitive regex","grep: case-insensitive matching over Cyrillic Extended-C letters is not supported",2);let s=t.filter(a=>a.localeSensitive);if(s.length===0||!(s.some(a=>a.unicodePattern)||e.some(a=>o.test(a.content))))return null;let u=s.some(a=>a.pcre)?"PCRE matching":"case-insensitive matching with backreferences";return k("feature","grep","non-ASCII regex semantics",`grep: ${u} on non-ASCII input is not supported`,2)}var Yo=/[*?[]/u,Vo=/\P{ASCII}/u,tw=/[.+*?^${}()|[\]\\/]/u;function Te(e,t={}){try{return nw(e,t)}catch(n){throw n instanceof w?n:new w("feature","glob pattern",`unsupported glob pattern: ${n.message}`)}}function nw(e,t){let n="^",r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(o==="\\"&&i+1<e.length){let s=e[i+1];n+=Ef(s,t.ignoreCase),i++}else if(o==="*"){for(;e[i+1]==="*";)i++;n+=".*"}else if(o==="?")n+=".";else if(o==="["){let s=Nf(e,i,t);if(s?.voided)return/^(?!)$/u;s?(n+=s.source,i=s.end,r||=s.nonAsciiRange):n+="\\["}else n+=Ef(o,t.ignoreCase)}return iw(new RegExp(n+"(?![\\s\\S])","us"),e,t,r)}function Ef(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:tw.test(e)?"\\"+e:e}function rw(e,t,n){let r=new RegExp(`[${e}]`,"ui"),i=new RegExp(`[${t}]`,"u"),o="";for(let s=0;s<128;s++){let u=String.fromCodePoint(s);(r.test(u)||i.test(u))&&(o+="\\x"+s.toString(16).padStart(2,"0"))}return`[${n?"^":""}${o}]`}function iw(e,t,n,r){let i=/[?[]/u.test(t),o=Vo.test(t);return{test(s){if(r||n.ignoreCase&&o||(i||n.ignoreCase)&&Vo.test(s))throw new w("feature","non-ASCII glob matching","locale-dependent glob matching of non-ASCII names is not supported");return e.test(s)}}}function Nf(e,t,n){let{ignoreCase:r}=n,i=t+1,o=!1;(e[i]==="!"||e[i]==="^")&&(o=!0,i++);let s="",u="",a=!1,l=!1,f=!1,c=!1,d="",p=0,h="",m=0;for(e[i]==="]"&&(s+="\\]",i++,a=!0,d="]");i<e.length&&e[i]!=="]";i++){let g=e[i];if(g==="["&&(e[i+1]==="."||e[i+1]==="="))throw new w("feature","glob collating or equivalence class","glob collating symbols and equivalence classes are not supported");if(g==="["&&e[i+1]===":"){let b=n.bash?ow(e,i):Xt(e,i,{unknown:"empty"});if(b){if(!n.bash&&b.body==="")throw new w("feature","glob character class","unknown POSIX classes in command filename patterns are not supported");l&&(c=!0),r?u+=b.body:s+=b.body,i=b.end-1,a=!1,l=!1;continue}if(n.bash)continue}if(g==="-"&&a)m=p,h=d,s+="-",l=!0,a=!1;else{let b=g==="\\"&&i+1<e.length?e[++i]:g;p=s.length,d=b,l&&Vo.test(h+b)&&(f=!0),l&&b.codePointAt(0)<h.codePointAt(0)?s=s.slice(0,m):s+=/[\]\\^[-]/u.test(b)?`\\${b}`:b,a=!l,l=!1}}return i>=e.length?null:c?{voided:!0,end:i}:{source:r?rw(s,u,o):`[${o?"^":""}${s}]`,end:i,nonAsciiRange:f}}function ow(e,t){let n=e.indexOf(":]",t+2);if(n===-1)return null;let r=e.slice(t+2,n).replace(/\\([\s\S]|$)/gu,"$1");return{body:r==="ascii"?"\\x00-\\x7F":Ot[r]??"",end:n+2}}function Af(e,t){return Te(t).test(e)}function Of(e){let{value:t,mask:n}=e;if(n===null)return Yo.test(t);for(let r=0;r<t.length;r++)if(n[r]==="0"&&Yo.test(t[r]))return!0;return!1}function Bn(e){let t=n=>!e.mask||e.mask[n]==="0";for(let n=0;n<e.value.length;n++){let r=e.value[n];if(t(n)){if(r==="\\")n++;else if(r==="[")n=sw(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]==="("&&t(n+1))return!0}}return!1}function sw(e,t,n){let{value:r}=e,i=t+1;for(/[!^]/u.test(r[i])&&n(i)&&i++,r[i]==="]"&&n(i)&&i++;i<r.length;i++)if(n(i))if(r[i]==="\\")i++;else{if(r[i]==="]")return i;if(r[i]==="["&&/[.:=]/u.test(r[i+1])&&n(i+1)){let o=r.indexOf(r[i+1]+"]",i+2);o!==-1&&(i=o+1)}}return t}var uw=/[*?[\]^!\\:.=-]/u;function en(e){let{value:t,mask:n}=e;if(n===null)return t;let r="";for(let i=0;i<t.length;i++){let o=t[i];r+=n[i]!=="0"&&uw.test(o)?"\\"+o:o}return r}function If(e,t){let n=en(e),r=n.match(/[^/]+|\/+/gu)??[],i=Zt(),o=new Set,s=[{path:"",marks:null}],u;try{for(let l=0;l<r.length;l++){let f=r[l];if(f.startsWith("/")||!Yo.test(f)){s=s.map(c=>({...c,path:c.path+lw(f)}));continue}s=fw(s,f,l===r.length-1,t,o)}let a=s.filter(l=>v(t.cwd,l.path,t.fs,{follow:!1}).path!==null);for(let l of a)for(let f of l.marks??[])i.add(f);return u=a.filter(l=>l.marks===null).map(l=>l.path).sort(B),u}finally{if(u===void 0)for(let a of o)i.add(a);i.emit(t.notes,"glob","",` while expanding ${JSON.stringify(n)}`),u?.length===0&&r.some(aw)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function aw(e){for(let t=0;t<e.length;t++)if(e[t]==="\\")t++;else{if(e[t]==="*"||e[t]==="?")return!0;if(e[t]==="[")try{if(Nf(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var lw=e=>e.replace(/\\(.)/gu,"$1");function fw(e,t,n,r,i){let o=Te(t,{bash:!0}),s=t.startsWith(".")||t.startsWith("\\."),u=[];for(let a of e){let l=v(r.cwd,a.path||".",r.fs).path;if(!r.fs.isDir(l))continue;let{dirs:f,files:c,links:d}=r.fs.listDir(l),p=n?d:d.filter(h=>r.fs.isDir(v(l,h,r.fs).path));for(let h of n?[...f,...c,...p]:[...f,...p]){let m=!s&&h.startsWith(".");if(!m&&a.marks===null)o.test(h)&&u.push({path:a.path+h,marks:null});else if(cw(o,h)){if(!m){u.push({path:a.path+h,marks:a.marks});continue}let g=G(l,h);i.add(g),u.push({path:a.path+h,marks:[...a.marks??[],g]})}}}return u}function cw(e,t){try{return e.test(t)}catch{return!0}}var Jo=(e,t)=>e.some(n=>n.test(t)),Qo=()=>({stdout:"",stderr:"",exitCode:1});function es(e,t,n,r){let i=0;if(r===1/0){for(let s of pe(e))Jo(t,s)!==n&&i++;return i}let o=0;for(;o<e.length&&i<r;){let s=e.indexOf(`
|
|
41
|
-
`,
|
|
42
|
-
`),rest:
|
|
43
|
-
`))
|
|
44
|
-
or: grep ${
|
|
45
|
-
`,u=!0;continue}if(
|
|
46
|
-
`}:{input:{name:t,...
|
|
45
|
+
`)}function sw(e,{bytes:t,valid:n}){let r=me(t),o=n?"":`${e}: invalid input
|
|
46
|
+
`;if(r!==void 0&&n)return F(r);let i=r===void 0?{fd:1,bytes:t}:{fd:1,text:r};return{stdout:r??"",stderr:o,exitCode:n?0:1,events:[...t.length?[i]:[],...o?[{fd:2,text:o}]:[]]}}var hf=[{},{},{}],mf=[[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],[..."0123456789ABCDEFGHIJKLMNOPQRSTUV"],[..."0123456789ABCDEFGHJKMNPQRSTVWXYZ"]],Dt="Invalid character in base32 input",Hi="Invalid base32 padding",uw="Invalid base32 length",Kr="Invalid last chunk",aw=Ot;function gf(e,t,n){Zt(e);let r=Math.floor(e.length/5),o=r*5,i="",s=0,u=mf[t],a=hf[t];if(!a.pairs)if(a.pairs=[],Oe){a.codepairs=new Uint16Array(1024);let p=a.codepairs,h=new Uint8Array(p.buffer,p.byteOffset,p.byteLength);for(let m=0;m<32;m++){let g=u[m].charCodeAt(0);for(let w=0;w<32;w++)h[m<<6|w<<1]=h[w<<6|(m<<1)+1]=g}}else{let p=a.pairs;for(let h=0;h<32;h++)for(let m=0;m<32;m++)p.push(`${u[h]}${u[m]}`)}let{pairs:l,codepairs:f}=a;if(Oe){let p=new Uint16Array(r*4);for(let h=0;s<o;s+=5){let m=e[s],g=e[s+1],w=e[s+2],y=e[s+3],k=e[s+4],S=m<<2|g>>6,I=(g&63)<<4|w>>4,M=(w&15)<<6|y>>2,C=(y&3)<<8|k;p[h]=f[S],p[h+1]=f[I],p[h+2]=f[M],p[h+3]=f[C],h+=4}i=Or(p)}else if(aw)for(;s<o;s+=5){let p=e[s],h=e[s+1],m=e[s+2],g=e[s+3],w=e[s+4],y=p<<2|h>>6,k=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,I=(g&3)<<8|w;i+=`${l[y]}${l[k]}${l[S]}${l[I]}`}else for(;s<o;s+=5){let p=e[s],h=e[s+1],m=e[s+2],g=e[s+3],w=e[s+4],y=p<<2|h>>6,k=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,I=(g&3)<<8|w;i+=l[y],i+=l[k],i+=l[S],i+=l[I]}let c=0,d=3;for(;s<e.length;s++){let p=e[s];i+=u[c|p>>d],d>=5&&(d-=5,i+=u[p>>d&31]),c=p<<5-d&31,d+=3}return d!==3&&(i+=u[c]),n&&(i+=["","======","====","===","="][e.length-o]),i}var lw=Ae?128:65536;function wf(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,o=n%8,i=n-o;if(![0,2,4,5,7].includes(o))throw new SyntaxError(uw);if(r>7||r!==0&&e.length%8!==0)throw new SyntaxError(Hi);let s=mf[t],u=hf[t];if(!u.fromMap){u.fromMap=new Int8Array(lw).fill(-1);let g=u.fromMap;s.forEach((w,y)=>{g[w.charCodeAt(0)]=g[w.toLowerCase().charCodeAt(0)]=y}),t===2&&(g[73]=g[76]=g[105]=g[108]=g[49],g[79]=g[111]=g[48])}let a=u.fromMap,l=new Uint8Array(Math.floor(n*5/8)),f=0,c=0;if(Ae){let g=Cr(e,Dt);for(;c<i;c+=8){let w=g[c],y=g[c+1],k=g[c+2],S=g[c+3],I=g[c+4],M=g[c+5],C=g[c+6],H=g[c+7],Y=a[w]<<15|a[y]<<10|a[k]<<5|a[S],D=a[I]<<15|a[M]<<10|a[C]<<5|a[H];if(Y<0||D<0)throw new SyntaxError(Dt);l[f]=Y>>12,l[f+1]=Y>>4&255,l[f+2]=Y<<4&255|D>>16,l[f+3]=D>>8&255,l[f+4]=D&255,f+=5}}else for(;c<i;c+=8){let g=e.charCodeAt(c),w=e.charCodeAt(c+1),y=e.charCodeAt(c+2),k=e.charCodeAt(c+3),S=e.charCodeAt(c+4),I=e.charCodeAt(c+5),M=e.charCodeAt(c+6),C=e.charCodeAt(c+7),H=a[g]<<15|a[w]<<10|a[y]<<5|a[k],Y=a[S]<<15|a[I]<<10|a[M]<<5|a[C];if(H<0||Y<0)throw new SyntaxError(Dt);l[f]=H>>12,l[f+1]=H>>4&255,l[f+2]=H<<4&255|Y>>16,l[f+3]=Y>>8&255,l[f+4]=Y&255,f+=5}if(o<2)return l;let d=a[e.charCodeAt(c++)]<<5|a[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(Dt);if(l[f++]=d>>2,o<4){if(d&3)throw new SyntaxError(Kr);return l}let p=a[e.charCodeAt(c++)]<<5|a[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(Dt);if(l[f++]=d<<6&255|p>>4,o<5){if(p&15)throw new SyntaxError(Kr);return l}let h=a[e.charCodeAt(c++)];if(h<0)throw new SyntaxError(Dt);if(l[f++]=p<<4&255|h>>1,o<7){if(h&1)throw new SyntaxError(Kr);return l}let m=a[e.charCodeAt(c++)]<<5|a[e.charCodeAt(c++)];if(m<0)throw new SyntaxError(Dt);if(l[f++]=h<<7&255|m>>3,m&7)throw new SyntaxError(Kr);return l}function yf(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Yt);if(o!==null&&Ar(o),n===!0){if(e.length%8!==0)throw new SyntaxError(Hi)}else if(n===!1){if(e.endsWith("="))throw new SyntaxError("Did not expect padding in base32 input")}else if(n!=="both")throw new TypeError("Invalid padding option");return et(wf(e,t),r)}var Gi=e=>(t,n)=>{if(!n)return yf(t,e,"both","uint8",null);let{format:r="uint8",padding:o="both",...i}=n;return yf(t,e,o,r,i)},bf=Gi(0),PA=Gi(1),DA=Gi(2),xf=(e,{padding:t=!1}={})=>gf(e,0,t);var cw="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Un=8,dw=Object.freeze([2,4,5,7,8]),kf=Vr("base32",{encode:e=>xf(e,{padding:!0}),decode:hw}),pw=/[a-z]/u;function hw(e,t=!1){let n=e.replace(t?/[^A-Z2-7=]/gu:/\n/gu,"");try{let r=bf(n,{padding:!0});if(!pw.test(n))return{bytes:r,valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r}return mw(n)}function mw(e){let t=new Uint8Array(Math.ceil(e.length/Un)*5),n=0,r=0,o=!0;for(;r<e.length;){if(e.length-r<Un){o=!1;break}let i=e.slice(r,r+Un),s=/^[A-Z2-7]*/u.exec(i)[0];if(n+=gw(i,s,t.subarray(n)),!dw.includes(s.length)||i.slice(s.length)!=="=".repeat(Un-s.length)){o=!1;break}r+=Un}return{bytes:t.subarray(0,n),valid:o}}function gw(e,t,n){let r=0,o=0,i=0;for(let s of t)o=o<<5|cw.indexOf(s),r+=5,!(r<8)&&(r-=8,n[i++]=o>>r&255);return i}var Xi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",vf=Vr("base64",{encode:hi,decode:ww});function ww(e,t=!1){let n=e.replace(t?/[^A-Za-z0-9+/=]/gu:/\n/gu,"");try{return{bytes:$n(n,{padding:!0}),valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r;return yw(n)}}function yw(e){let t=new Uint8Array(Math.ceil(e.length/4)*3),n=/[A-Za-z0-9+/]*/uy,r=0,o=0,i=!0;for(;o<e.length;){n.lastIndex=o;let s=n.exec(e)[0].length,u=s-s%4;if(u){let p=$n(e.slice(o,o+u));t.set(p,r),r+=p.length,o+=u}if(o===e.length)break;let a=s%4;if(a<2){i=!1;break}let l=Xi.indexOf(e[o]),f=Xi.indexOf(e[o+1]),c=a===3?Xi.indexOf(e[o+2]):0;t[r++]=l<<2|f>>4,a===3&&(t[r++]=f<<4|c>>2);let d=4-a;if(o+=a,e.slice(o,o+d)!=="=".repeat(d)){i=!1;break}o+=d}return{bytes:t.subarray(0,r),valid:i}}var bw=["n","N","i","s","w","F","v","l","c","q","u","a","H","I"],xw=["line-number","no-line-number","ignore-case","case-sensitive","word-regexp","fixed-strings","invert-match","files-with-matches","files-without-match","count","quiet","hidden","no-ignore","no-heading","with-filename","no-filename","text","unrestricted"],Ef={short:bw,long:xw,valueShort:["A","B","C"],valueLong:["after-context","before-context","context"],repeatable:["e","regexp"]},kw=new Map(Object.entries({"line-number":"n","no-line-number":"N","ignore-case":"i","case-sensitive":"s","word-regexp":"w","fixed-strings":"F","invert-match":"v","files-with-matches":"l","files-without-match":"L",count:"c",quiet:"q",text:"a",unrestricted:"u","with-filename":"H","no-filename":"I",regexp:"e","after-context":"A","before-context":"B",context:"C"})),vw=new Set(["no-heading","no-ignore"]),jn=(e,t)=>new b("feature",e,`rg: ${t}`);function $f(e){let t={patterns:[],context:[],mode:null,showName:null,ignoreCase:!1,lineNumbers:!1,word:!1,literal:!1,invert:!1,quiet:!1,text:!1,hidden:!1,unrestricted:0};for(let{name:o,value:i}of e.order)vw.has(o)||Sw(t,kw.get(o)??o,i,Zi(o));let n=o=>t.context.findLast(([i])=>i===o)?.[1],r=o=>t.context.findLast(([i])=>i===o)?.[2]??"-"+o;if(t.after=Sf(n("A")??n("C"),n("A")===void 0?r("C"):r("A")),t.before=Sf(n("B")??n("C"),n("B")===void 0?r("C"):r("B")),t.unrestricted>=2&&(t.hidden=!0),t.unrestricted>=3)throw jn("-uuu","searching binary files is not supported");return t}function Sw(e,t,n,r){switch(t){case"i":e.ignoreCase=!0;return;case"s":e.ignoreCase=!1;return;case"n":e.lineNumbers=!0;return;case"N":e.lineNumbers=!1;return;case"l":case"L":case"c":e.mode=t;return;case"H":e.showName="H";return;case"I":e.showName="h";return;case"w":e.word=!0;return;case"F":e.literal=!0;return;case"v":e.invert=!0;return;case"q":e.quiet=!0;return;case"a":e.text=!0;return;case"e":e.patterns.push(n);return;case"hidden":e.hidden=!0;return;case"u":e.unrestricted++;return;case"A":case"B":case"C":e.context.push([t,n,r]);return;default:throw jn(Zi(t),`${Zi(t)} is not supported`)}}function Sf(e,t){if(e===void 0)return 0;if(!/^\d+$/u.test(e))throw jn(`${t} value`,`error parsing flag ${t}: value is not a valid number`);return Number(e)}var Zi=e=>(e.length===1?"-":"--")+e;function Nf(e,t){return t?e.flatMap(n=>["-e",n]):["-e",e.length===1?e[0]:e.map(n=>`(?:${n})`).join("|")]}var Ew=[[/\\[1-9]/u,"backreference"],[/\(\?<?[=!]/u,"look-around"],[/\\[QE]/u,String.raw`\Q…\E literal span`]];function $w(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`
|
|
47
|
+
`)return!0;if(n!=="\\")continue;let r=e[t+1];if(r==="n"||r==="x"&&/^x\{?0*a\}?/iu.test(e.slice(t+1)))return!0;t++}return!1}function Af(e,t){if(!t)for(let n of e){for(let[r,o]of Ew)if(r.test(n))throw jn(o,`${o} is not supported; ripgrep's regex engine rejects it too`);if($w(n))throw jn("newline in a pattern","a newline in a pattern is not supported; ripgrep rejects one outside multiline mode")}}var $=class extends Error{constructor(t,n=null,r=null){super(t),this.line=n,this.gap=r}},Of=new Set(["BEGIN","END","BEGINFILE","ENDFILE","function","func","if","else","while","for","do","break","continue","next","nextfile","exit","return","delete","in","getline","print","printf","switch","case","default"]),Yi={__proto__:null,length:[0,1],substr:[2,3],index:[2,2],split:[2,3],sub:[2,3],gsub:[2,3],gensub:[3,4],match:[2,3],sprintf:[1,1/0],sin:[1,1],cos:[1,1],atan2:[2,2],exp:[1,1],log:[1,1],sqrt:[1,1],int:[1,1],rand:[0,0],srand:[0,1],tolower:[1,1],toupper:[1,1],close:[1,2],fflush:[0,1],systime:[0,0],strtonum:[1,1],and:[2,1/0],or:[2,1/0],xor:[2,1/0],lshift:[2,2],rshift:[2,2],compl:[1,1],typeof:[1,1],isarray:[1,1]},Jr=new Map([["system","system() is not supported: this terminal runs no processes"],["strftime","strftime() is not supported (gawk extension)"],["mktime","mktime() is not supported (gawk extension)"],["asort","asort() is not supported (gawk extension)"],["asorti","asorti() is not supported (gawk extension)"],["patsplit","patsplit() is not supported (gawk extension)"]]),Cf=new Set([...Object.keys(Yi),...Jr.keys()]),Wn=5e6,Vi=100,Ce=1e6,Qr="this terminal runs no processes";function eo(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;default:return t**n}}var If={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},Nw='^$.[]|()*+?{}\\/"',Ki=1e3,Tf=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),Ff=e=>e!==void 0&&e>="0"&&e<="7",Ji=class{constructor(t,n,r,o){this.src=t,this.i=0,this.warn=n,this.tables=r,this.ignoreCase=o,this.groups=0}fail(t){throw new $(`invalid regex /${this.src}/: ${t}`)}peek(){return this.src[this.i]}literal(){let t=this.src.codePointAt(this.i);return this.i+=Ue(t),this.charNode(t)}charNode(t){let n=this.ignoreCase?this.tables.fold(t):[t];return n.length===1?{type:"char",code:t}:{type:"set",negate:!1,items:n.map(r=>[r,r])}}parse(){return this.alternation(0)}alternation(t){let n=[this.concatenation(t)];for(;this.peek()==="|";)this.i++,n.push(this.concatenation(t));return n.length===1?n[0]:{type:"alt",nodes:n}}concatenation(t){let n=[];for(;!this.endsConcatenation(t);)n.push(this.quantified(this.atom(n.length===0,t)));return n.length===1?n[0]:{type:"cat",nodes:n}}endsConcatenation(t){let n=this.peek();return n===void 0||n==="|"||n===")"&&t>0}quantified(t){let n=t;for(;;){let r=this.peek();if(r==="*"){this.i++,n={type:"rep",node:n,min:0,max:null};continue}if(r==="+"){this.i++,n={type:"rep",node:n,min:1,max:null};continue}if(r==="?"){this.i++,n={type:"rep",node:n,min:0,max:1};continue}if(r==="{"){let o=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!o&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail("invalid content of {}"),!o||o[1]===""&&o[2]===void 0)return n;let i=o[1]===""?0:Number(o[1]),s=o[2]===void 0?i:o[3]===""?null:Number(o[3]);if(s!==null&&s<i&&this.fail(`invalid interval {${i},${s}}`),i>Ki||s!==null&&s>Ki)throw new $(`interval count above ${Ki} is not supported`,null,"regex interval limit");this.i+=o[0].length,n={type:"rep",node:n,min:i,max:s};continue}return n}}atom(t,n){let r=this.peek();if(r==="("){this.i++;let o=++this.groups,i=this.alternation(n+1);return this.peek()!==")"&&this.fail("missing `)`"),this.i++,{type:"group",index:o,node:i}}return r==="["?this.bracket():r==="\\"?this.escape():(this.i++,r==="."?{type:"any"}:r==="^"||r==="$"?{type:"assert",kind:r}:((r==="*"||r==="+"||r==="?")&&!t&&this.fail(`unexpected \`${r}\``),this.i--,this.literal()))}escape(){this.i++;let t=this.peek();return t===void 0&&this.fail("trailing backslash"),this.i++,t==="y"?{type:"assert",kind:"y"}:t==="<"||t===">"||t==="B"?{type:"assert",kind:t}:t==="`"?{type:"assert",kind:"^"}:t==="'"?{type:"assert",kind:"$"}:t==="s"||t==="S"?{type:"set",negate:t==="S",items:this.tables.ranges("space")}:t==="w"||t==="W"?{type:"set",negate:t==="W",items:this.tables.ranges("word")}:(t==="b"&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(t,!0)))}escapedCode(t,n){if(t in If)return If[t];if(Ff(t)){let o=t;for(;o.length<3&&Ff(this.peek());)o+=this.src[this.i++];return Lf(o,8)}if(t==="x"&&Tf(this.peek())){let o="";for(;o.length<2&&Tf(this.peek());)o+=this.src[this.i++];return Lf(o,16)}let r=this.src.codePointAt(this.i-1);return!Nw.includes(t)&&n&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(r)}' is not a known regexp operator`),this.i+=Ue(r)-1,r}bracket(){this.i++;let t=!1;this.peek()==="^"&&(t=!0,this.i++);let n=[],r=!0;for(;;){this.i>=this.src.length&&this.fail("unterminated bracket expression");let o=this.peek();if(o==="]"&&!r){this.i++;break}if(r=!1,o==="["&&this.src[this.i+1]===":"){let s=this.src.indexOf(":]",this.i+2);if(s!==-1){let u=this.src.slice(this.i+2,s),a=this.tables.ranges(this.ignoreCase?Pr(u):u);a===void 0&&this.fail(`invalid character class \`[:${u}:]\``),n.push(...a),this.i=s+2;continue}}let i=this.bracketChar();if(this.peek()==="-"&&this.src[this.i+1]!=="]"&&this.src[this.i+1]!==void 0){this.i++;let s=this.bracketChar(),u=this.ignoreCase?this.tables.foldRange(i,s):s<i?null:[[i,s]];u===null&&this.fail("invalid range end"),n.push(...u)}else this.ignoreCase?n.push(...this.tables.fold(i).map(s=>[s,s])):n.push([i,i])}return{type:"set",negate:t,items:n}}bracketChar(){let t=this.peek();if(t==="["&&(this.src[this.i+1]==="."||this.src[this.i+1]==="=")){let r=this.src.indexOf(this.src[this.i+1]+"]",this.i+2);if(r!==-1&&r>this.i+2){Array.from(this.src.slice(this.i+2,r)).length!==1&&this.fail("invalid collation character");let o=this.src.codePointAt(this.i+2);return this.i=r+2,o}}if(t==="\\"){this.i++,this.peek()===void 0&&this.fail("trailing backslash");let r=this.src[this.i++];return this.escapedCode(r,!1)}let n=this.src.codePointAt(this.i);return this.i+=Ue(n),n}};function no(e,t=null,n=re(ee),r=!1){let o=new Ji(e,t,n,r);return{ast:o.parse(),groups:o.groups}}function Lf(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new $("non-ASCII regex byte escapes are not supported",null,"regex byte escapes");return n}var Aw=e=>`\\u{${e.toString(16)}}`,to=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):Aw(e);function Ow(e,t){if(e==="^"||e==="$")return e;let n=t.assertions();return e==="y"?n.boundary:e==="B"?n.inside:n[e]}function Qi(e,t=re(ee)){let n=r=>Qi(r,t);switch(e.type){case"char":return to(e.code);case"any":return".";case"set":return`[${e.negate?"^":""}${e.items.map(([r,o])=>r===o?to(r):`${to(r)}-${to(o)}`).join("")}]`;case"assert":return Ow(e.kind,t);case"group":return`(${n(e.node)})`;case"cat":return e.nodes.map(n).join("");case"alt":return`(?:${e.nodes.map(n).join("|")})`;case"rep":{let r=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${r}*`:e.min===1?`${r}+`:`${r}{${e.min},}`:e.min===0&&e.max===1?`${r}?`:`${r}{${e.min},${e.max}}`}default:throw new $(`internal: unknown regex node ${e.type}`)}}var Cw=5e4;function Iw(e,t){let n=r=>{for(let o=0;o<e.length;o++)if(r>=e[o][0]&&r<=e[o][1])return!0;return!1};return t?r=>!n(r):n}function _f(e,t=re(ee)){let n=[],r=l=>{if(n.length>=Cw)throw new $("regex too large",null,"regex state limit");return n.push(l),n.length-1};function o(l,f){switch(l.type){case"char":return r({op:"char",codes:[l.code],next:f});case"any":return r({op:"any",next:f});case"set":return r({op:"set",test:Iw(l.items,l.negate),next:f});case"assert":return r({op:"assert",kind:l.kind,next:f});case"group":return o(l.node,f);case"cat":{let c=f;for(let d=l.nodes.length-1;d>=0;d--)c=o(l.nodes[d],c);return c}case"alt":{let c=l.nodes.map(p=>o(p,f)),d=c.at(-1);for(let p=c.length-2;p>=0;p--)d=r({op:"split",x:c[p],y:d});return d}case"rep":return i(l,f);default:throw new $(`internal: unknown regex node ${l.type}`)}}function i(l,f){let c=f;if(l.max===null){let d=r({op:"split",x:-1,y:f});n[d].x=o(l.node,d),c=d}else for(let d=l.max-l.min;d>0;d--)c=r({op:"split",x:o(l.node,c),y:f});for(let d=0;d<l.min;d++)c=o(l.node,c);return c}let s=o(e,r({op:"match"})),u="",a=s;for(;n[a].op==="char"&&n[a].codes.length===1&&n[a].codes[0]<128;)u+=String.fromCodePoint(n[a].codes[0]),a=n[a].next;return(n[a].op!=="match"||u==="")&&(u=null),{states:n,start:s,literal:u,isWord:l=>t.has("word",l),gen:new Int32Array(n.length).fill(-1),stamp:0}}function Tw(e,t){if(t<=0)return-1;let n=e.codePointAt(t-1);return n>=56320&&n<=57343&&t>=2?e.codePointAt(t-2):n}function Fw(e,t,n,r){if(e==="^")return n===0;if(e==="$")return n===t.length;let o=r(Tw(t,n)),i=n<t.length&&r(t.codePointAt(n));return e==="y"?o!==i:e==="B"?o===i:e==="<"?!o&&i:o&&!i}function Lw(e,t){return e.op==="char"?e.codes.includes(t):e.op==="any"?!0:e.test(t)}function Rf(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let p=t.indexOf(e.literal,n);return p<0?null:{start:p,end:p+e.literal.length}}let{states:r,gen:o}=e,i=t.length,s=[],u=(p,h,m,g,w)=>{for(s.push(h);s.length>0;){let y=s.pop();if(o[y]===w)continue;o[y]=w;let k=r[y];k.op==="split"?s.push(k.y,k.x):k.op==="assert"?Fw(k.kind,t,g,e.isWord)&&s.push(k.next):p.push(y,m)}},a=[],l=[],f=null,c=n,d=++e.stamp;for(;;){f===null&&u(a,e.start,c,c,d);let p=c<i?t.codePointAt(c):-1,h=Ue(p);if(a.length===0){if(f!==null||c>=i)break;c+=h,d=++e.stamp;continue}let m=++e.stamp;for(let g=0;g<a.length;g+=2){let w=a[g],y=a[g+1];if(f!==null&&y>f.start)continue;let k=r[w];if(k.op==="match"){(f===null||y<f.start||y===f.start&&c>f.end)&&(f={start:y,end:c});continue}p!==-1&&Lw(k,p)&&u(l,k.next,y,c+h,m)}if(a.length=0,[a,l]=[l,a],d=m,c>=i)break;c+=h}return f}var ro=new Map,ct=class{constructor(t,n,r,o=re(ee)){let{ast:i,groups:s}=no(t,r,o,n);this.src=t,this.ignoreCase=n,this.tables=o,this.groupCount=s,this.source=Qi(i,o),this.flags="su";try{this.js=new RegExp(this.source,this.flags)}catch(u){throw new $(`cannot compile regex /${t}/: ${u.message}`,null,"regex engine limit")}this.ast=i,this.nfa=null,this.capture=null,this.captureShape=Mf(i)}test(t){return this.checkCase(t),this.js.test(t)}checkCase(t){if(this.ignoreCase&&Tt.test(t+this.src))throw new $("case-insensitive matching over Cyrillic Extended-C letters is not supported",null,"locale-sensitive regex")}search(t,n=0){return this.checkCase(t),this.nfa===null&&(this.nfa=_f(this.ast,this.tables)),Rf(this.nfa,t,n)}groups(t,n,r){if(this.captureShape.unsafe)throw new $("capture extraction across repeated or alternative groups is not supported",null,"regex capture semantics");let o=this.capture??=new RegExp(this.source,this.flags+"dy");o.lastIndex=n;let i=o.exec(t);if(!i||i.index!==n||n+i[0].length!==r){let s=Array.from(t.slice(r)).length,u=new RegExp(`(?:${this.source})(?=.{${s}}(?![^]))`,this.flags+"dy");u.lastIndex=n,i=u.exec(t)}if(!i)throw new $("capture extraction for this match is not supported",null,"regex capture semantics");return i.indices.map((s,u)=>s===void 0?void 0:{text:i[u],start:s[0],end:s[1]})}};function Mf(e){let n=(e.nodes??(e.node?[e.node]:[])).map(Mf),r=n.reduce((s,u)=>s+u.groups,e.type==="group"?1:0),o=e.type==="assert"||(e.type==="group"||e.type==="cat")&&n.every(s=>s.nullable)||e.type==="alt"&&n.some(s=>s.nullable)||e.type==="rep"&&(e.min===0||n[0].nullable),i=e.type==="rep"&&(e.max===null||e.max>1)&&(r>1||r>0&&n[0].nullable);return{groups:r,nullable:o,unsafe:i||e.type==="alt"&&r>0||n.some(s=>s.unsafe)}}function Re(e,t=!1,n=null,r=re(ee)){let o=(t?"i":"c")+r.name+"\0"+e,i=ro.get(o);if(i)return i;ro.size>=500&&ro.clear();let s=new ct(e,t,n,r);return ro.set(o,s),s}function es(e,t,n){for(;;){let r=t.search(e,n);if(!r||r.start!==r.end)return r;if(r.end>=e.length)return null;n=r.end+Le(e,r.end)}}function ts(e,t){let n=[],r=0;for(;;){let o=es(e,t,r);if(!o)break;n.push(e.slice(r,o.start)),r=o.end}return n.push(e.slice(r)),n}function qn(e,t,n,r){let o=r!=="first",i=e.length,s="",u=0,a=-1,l=0;for(;u<=i;){let f=t.search(e,u);if(!f)break;let c=f.start===f.end;if(c&&f.start===a&&r!=="nth"){if(f.start>=i)break;let p=Le(e,f.start);s+=e.slice(u,f.start+p),u=f.start+p;continue}l++;let d=n(f.start,f.end,l);if(s+=e.slice(u,f.start)+(d===null?e.slice(f.start,f.end):d),a=f.end,c){if(f.end>=i){u=i;break}let p=Le(e,f.end);s+=e.slice(f.end,f.end+p),u=f.end+p}else u=f.end;if(!o)break}return{out:s+e.slice(u),count:l}}function oo(e,t){let n="(){}+?|",r=!1,o=0,i=!1,s="";for(let u=0;u<e.length;u++){let a=e[u];if(i){if(a==="["&&(e[u+1]==="."||e[u+1]==="="))throw new b("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");if(a==="["){let l=Kt(e,u,{classes:t});if(l){s+=l.body,u=l.end-1;continue}}s+=a,a==="]"&&(i=!1,r=!0);continue}if(a==="["){s+=a,i=!0,e[u+1]==="^"&&(s+="^",u++),e[u+1]==="]"&&(s+="\\]",u++);continue}if(a==="\\"){let l=e[++u];if(l===void 0)return{error:"trailing backslash (\\)"};if(n.includes(l)){if((l==="+"||l==="?")&&!r){s+="\\"+l,r=!0;continue}if(l==="("&&o++,l===")"&&o--===0)return{error:"Unmatched ) or \\)"};(l==="("||l==="|")&&(r=!1),(l===")"||l==="}")&&(r=!0),s+=l}else s+="^$\\.*[]/bBsSwW<>`'123456789".includes(l)?"\\"+l:l,r=!"bB<>`'".includes(l);continue}if(a==="*"){s+=r?"*":"\\*",r=!0;continue}if(a==="^"){r=!_w(e,u),s+=r?"\\^":"^";continue}if(a==="$"){r=!(u===e.length-1||e[u+1]==="\\"&&(e[u+2]===")"||e[u+2]==="|")),s+=r?"\\$":"$";continue}s+=n.includes(a)?"\\"+a:a,r=!0}return o>0?{error:"Unmatched ( or \\("}:{source:s}}function _w(e,t){if(t===0)return!0;if(t<2||e[t-2]!=="\\"||e[t-1]!=="("&&e[t-1]!=="|")return!1;let n=0;for(let r=t-3;r>=0&&e[r]==="\\";r--)n++;return n%2===0}function io(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,o=!1,i=0,s=!1,u=[],a=new Set,l=!1;for(let f=0;f<e.length;f++){let c=e[f];if(c==="\\"){let d=e[++f];if(!o&&/[1-9]/u.test(d??"")){let p=Number(d);if(!t.has(p))throw new Error("Invalid back reference");(!a.has(p)||r.has(p))&&(s=!0)}u=[];continue}if(o){c==="]"&&(o=!1);continue}if(c==="["){o=!0,u=[];continue}if(c==="(")n.push({id:++i,entry:new Set(a),branches:[],start:f}),u=[];else if(c==="|"){let d=n.at(-1);d&&d.branches.push(a),a=new Set(d?.entry),u=[]}else if(c===")"){let d=n.pop();if(!d)continue;a=d.branches.reduce((p,h)=>p.intersection(h),a),a.add(d.id),t.add(d.id),u=[...a.difference(d.entry)],l=Rw(e.slice(d.start,f+1))}else if(c==="*"||c==="?"||c==="+"){if(c!=="?"&&l)for(let d of u)r.add(d);if(c!=="+")for(let d of u)a.delete(d)}else if(c==="{"){let d=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(f));if(d){Number(d[1])===0&&(a=a.difference(new Set(u)));let p=d[2]===void 0?Number(d[1]):d[2]===""?1/0:Number(d[2]);l&&p>1&&u.forEach(h=>r.add(h)),f+=d[0].length-1}else u=[]}else u=[]}return s}function Rw(e){try{return new RegExp(`^(?:${e})$`,"su").test("")}catch{return!0}}var Mw="bBsSwW";function zn(e,t){let n="";for(let r=0;r<e.length;){let o=e[r];if(o==="["){let l=Pw(e,r,t);n+=l.text,r=l.end;continue}let i=o==="\\",s=e.codePointAt(r+(i?1:0)),u=(i?1:0)+Ue(s),a=i&&Mw.includes(e[r+1])?null:t.fold(s);n+=a===null||a.length===1?e.slice(r,r+u):`[${String.fromCodePoint(...a)}]`,r+=u}return n}function Pf(e,t){let n="";for(let r of e){let o=t.fold(r.codePointAt(0));n+=o.length===1?RegExp.escape(r):`[${String.fromCodePoint(...o)}]`}return n}function Pw(e,t,n){let r=t+1,o="[";e[r]==="^"&&(o+="^",r++);let i=!0;for(;;){let s=e[r];if(s==="]"&&!i)return{text:o+"]",end:r+1};if(i=!1,s==="["&&":.=".includes(e[r+1])){let l=e[r+1],f=e.indexOf(l+"]",r+2);o+=l===":"?`[:${Pr(e.slice(r+2,f))}:]`:e.slice(r,f+2),r=f+2;continue}let u=e.codePointAt(r),a=r+Ue(u);if(e[a]==="-"&&e[a+1]!==void 0&&e[a+1]!=="]"){let l=e.codePointAt(a+1),f=a+1+Ue(l);o+=Dw(u,l,e.slice(r,f),n),r=f;continue}o+=String.fromCodePoint(...n.fold(u)),r=a}}function Dw(e,t,n,r){let o=r.foldRange(e,t);if(o===null)throw new Error("Invalid range end");return o.length===1&&o[0][0]===e&&o[0][1]===t?n:o.map(([i,s])=>i===s?String.fromCodePoint(i):`${String.fromCodePoint(i)}-${String.fromCodePoint(s)}`).join("")}function Ie(e){throw new b("feature","PCRE "+e,`PCRE ${e} is not supported`)}function Df(e){let t={captures:0,closed:new Set,names:new Map,stack:[],behind:0,references:!1,risky:!1},n="";for(let r=0;r<e.length;){let o=e[r];if(o==="\\"){let i=Bf(e,r,t,!1);n+=i.source,r=i.end;continue}if(o==="["){let i=jw(e,r,t);n+=i.source,r=i.end;continue}if(o==="("){let i=Bw(e,r,t);n+=i.source,r=i.end;continue}if(o===")"){let i=t.stack.pop();i?.capture&&t.closed.add(i.capture),i?.behind&&t.behind--}if("*+?".includes(o)&&(t.behind&&Ie("variable-length lookbehind"),e[r+1]==="+"&&Ie("possessive repetition"),o!=="+"&&(t.risky=!0)),o==="|"&&(t.risky=!0),o==="{"){let i=Uw(e,r,t);n+=i.source,r=i.end;continue}n+=o==="]"||o==="}"?"\\"+o:o,r++}return t.references&&t.risky&&Ie("conditional backreference"),n}function Bw(e,t,n){let r=!1,o=null,i="(";if(e[t+1]==="*"&&Ie("control verb"),e[t+1]==="?"){let s=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(s||Ie("group"),i=s[0],r=i==="(?<="||i==="(?<!",!s[1]&&i!=="(?:"&&(n.risky=!0),s[1]){if(o=++n.captures,n.names.has(s[1]))throw new Error("duplicate PCRE capture name");n.names.set(s[1],o)}}else o=++n.captures;return r&&n.behind++,n.stack.push({capture:o,behind:r}),{source:i,end:t+i.length}}function Uw(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&Ie("repetition"),{source:"\\{",end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&Ie("variable-length lookbehind"),Number(r[1])>65535||Number(r[2])>65535)throw new Error("PCRE repetition count exceeds 65535");return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]==="+"&&Ie("possessive repetition"),{source:r[0],end:t+r[0].length}}function jw(e,t,n){let r=t+1,o="[";for(e[r]==="^"&&(o+="^",r++),e[r]==="]"&&(o+="\\]",r++);r<e.length&&e[r]!=="]";)if(e[r]==="["&&":.=".includes(e[r+1]??"")&&Ie("character class"),e[r]==="\\"){let i=Bf(e,r,n,!0);o+=i.source,r=i.end}else o+=e[r]==="["?"\\[":e[r],r++;return{source:o+(e[r]==="]"?"]":""),end:r+1}}function Bf(e,t,n,r){let o=e[t+1];if(o===void 0)throw new Error("trailing backslash");if(o==="Q"){let s=e.indexOf("\\E",t+2);return{source:RegExp.escape(e.slice(t+2,s<0?void 0:s)),end:s<0?e.length:s+2}}if(o==="E")return{source:"",end:t+2};if(o==="x"||o==="0"||r&&/[1-7]/u.test(o))return Ww(e,t);if(o==="a"||o==="e")return{source:o==="a"?"\\u0007":"\\u001B",end:t+2};if("AzZ".includes(o)&&!r)return{source:o==="A"?"^":"$",end:t+2};if(/[1-9]/u.test(o)&&!r)return(/\d/u.test(e[t+2]??"")||!n.closed.has(Number(o)))&&Ie("forward or ambiguous backreference"),n.references=!0,{source:"\\"+o,end:t+2};if(o==="k"&&!r){let s=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return(!s||!n.closed.has(n.names.get(s[1])))&&Ie("named backreference"),n.references=!0,{source:s[0],end:t+s[0].length}}if("dDsSwWfnrtbB".includes(o))return{source:"\\"+o,end:t+2};/[A-Za-z0-9]/u.test(o)&&Ie("escape \\"+o);let i=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(i),end:t+1+i.length}}function Ww(e,t){let n=e[t+1]==="x",r=(n?/^\\x(?:\{([\da-fA-F]+)\}|([\da-fA-F]{1,2}))/u:/^\\([0-7]{1,3})/u).exec(e.slice(t));if(!r)throw new Error("invalid PCRE character escape");let o=n?16:8,i=parseInt(r[1]??r[2],o);return Ze(i)||Ie("character escape"),{source:`\\u{${i.toString(16)}}`,end:t+r[0].length}}function rs(e,t){let n="",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"){let s=e[++o]??"";n+=r?i+s:qw(s);continue}if(r&&i==="["){if(e[o+1]==="."||e[o+1]==="=")throw new b("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");let s=Kt(e,o,{classes:t});if(s){n+=s.body,o=s.end-1;continue}}if(i==="["&&!r){n+="[",r=!0,e[o+1]==="^"&&(n+="^",o++),e[o+1]==="]"&&(n+="\\]",o++);continue}i==="]"&&(r=!1),n+=i}return n}function qw(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?"\\"+e:RegExp.escape(e)}function zw(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"){if("bBsSwW<>".includes(e[++t]??""))return!0}else if(".[*+?{".includes(e[t]))return!0;return!1}function Hn(e,t=!1,n=re(ee)){let r=n.assertions(),o=t?{b:"\\y"}:{"<":r["<"],">":r[">"],b:r.boundary,B:r.inside,w:r.word,W:r.nonWord,s:r.space,S:r.nonSpace,"`":"^","'":"$"},i="",s=!1;for(let u=0;u<e.length;u++){let a=e[u];if(a==="\\"){let l=e[++u];i+=!s&&Object.hasOwn(o,l)?o[l]:a+l,!t&&!s&&/[1-9]/u.test(l)&&/\d/u.test(e[u+1]??"")&&(i+="(?:)")}else a==="["&&(s=!0),a==="]"&&(s=!1),i+=a}return i}var os=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,Hw=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function Uf(e,t,n){let r=(n?os:Hw).exec(e.slice(t));if(!r&&!n)throw new Error("invalid repetition count");r&&Ra(Number(r[1]),r[2]===void 0||r[2]===""?void 0:Number(r[2]))}var jf={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function Gw(e){if(jf[e])return jf[e];let t=os.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===""?1/0:Number(t[2])}}var Wf=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function Xw(e,t){let n=Math.max(t.min,1);if(n>t.max)return{min:0,max:0};if(e.min>0&&(t.min===0&&e.min>1||e.max!==1/0&&t.max>n&&(n+1)*e.min>n*e.max+1))return null;let r=Wf(t.max,e.max);return r!==1/0&&r>Lr?null:{min:Wf(t.min,e.min),max:r}}function ns(e){return e.max===1/0?e.min===0?"*":e.min===1?"+":`{${e.min},}`:e.min===0&&e.max===1?"?":e.min===e.max?`{${e.min}}`:`{${e.min},${e.max}}`}var Zw=e=>!e.startsWith("(")&&!/^\\[1-9]/u.test(e);function Yw(e,t){if(t.length===1)return e+ns(t[0].bounds);let n=t[0].bounds,r=null;for(let o=1;o<t.length;o++){let{bounds:i,text:s}=t[o],u=r===null?Xw(n,i):null;if(u){n=u;continue}if(!(r===null&&n.min===n.max&&Zw(e))&&i.max>1)throw new Error("stacked quantifier needs ambiguous nesting");r=`(?:${r??e+ns(n)})${s}`}return r??e+ns(n)}function Vw(e,t){let n=t+1;for(e[n]==="^"&&n++;n<e.length;n++){if(e[n]==="\\"){n++;continue}if(e[n]==="]")return n}return e.length-1}function Kw(e){let t="",n=-1,r=-1,o=[],i=()=>{o.length>0&&(t=t.slice(0,n)+Yw(t.slice(n,r),o)),o=[]},s=a=>{i(),n=t.length,r=-1,t+=a},u=[];for(let a=0;a<e.length;a++){let l=e[a];if(l==="\\"){s(l+(e[++a]??""));continue}if(l==="["){let c=Vw(e,a);s(e.slice(a,c+1)),a=c;continue}if(l==="("){i(),u.push(t.length),n=-1,t+=l;continue}if(l===")"){i(),t+=l,n=u.pop()??-1,r=-1;continue}if(l==="|"||l==="^"||l==="$"){i(),t+=l,n=-1;continue}let f=l==="{"?os.exec(e.slice(a)):null;if(l==="*"||l==="+"||l==="?"||f){let c=f?f[0]:l;if(a+=c.length-1,n<0){t+=c;continue}o.length===0&&(r=t.length),o.push({bounds:Gw(c),text:c});continue}s(l)}return i(),t}function is(e,t,n=!1){let r=-1;for(let o=0;o<e.length;o++){let i=o<=r,s=e[o];if(s==="\\"){let u=e[++o];if(u===void 0)throw new Error("trailing backslash");if(i||u&&"dDxXuUpPkKcC".includes(u))throw new b("feature","regex escape","grep: this regex escape is not supported with GNU semantics");!t&&u==="{"&&Uf(e,o-1,!1)}else if(s==="["&&!i)r=Ma(e,o,n);else{if(i)continue;if(t&&s==="{")Uf(e,o,!0);else if(t&&s==="("&&e[o+1]==="?")throw new b("feature","regex extension","grep: ECMAScript group extensions are not supported in ERE")}}}function Jw(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"&&/[1-9]/u.test(e[++t]??""))return!0;return!1}function qf(e,t,n=ee){let r=re(n),o=[],i=t.has("x"),s=t.has("w")&&!i;if(t.has("P")&&new Set(e).size>1)return{error:x("grep: -P only supports a single pattern",2)};for(let u of e){let a=!t.has("F")&&!t.has("P");a&&is(u,t.has("E"),r.multibyte);let l=a&&Jw(u),f=t.has("i")&&!t.has("P")&&!l,c=t.has("i")&&!f?"isu":"su",d;if(t.has("F"))d=f?Pf(u,r):RegExp.escape(u);else if(t.has("P"))d=Df(u);else if(t.has("E"))d=rs(f?zn(u,r):u,r);else{let h=oo(f?zn(u,r):u,r);if(h.error)return{error:x(`grep: ${h.error}`,2)};d=h.source}let p=d;if(a&&io(p))return{error:v("feature","grep","conditional backreference","grep: backreferences with conditional or repeated-empty captures are not supported",2)};s&&(d=`(?<!${r.assertions().word})(?:${d})(?!${r.assertions().word})`),i&&(d=`^(?:${d})$`);try{let h=new RegExp(a?Hn(Kw(d),!1,r):d,c);h.pcre=t.has("P"),h.localeSensitive=h.pcre?t.has("i")||s||zw(p)||/\\[dD]/u.test(p):t.has("i")&&l,h.folded=f,h.extendedC=f&&Tt.test(u),h.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(u);let m=t.has("F")||!Yf.test(u);if(h.binaryLiteral=!i&&!s&&m,m&&u.isWellFormed()&&(f||!t.has("i"))&&(h.literal={pattern:u,tables:r}),t.has("o")&&a&&!i){if(s||/\\[1-9]|\(\?/u.test(d))return{error:v("feature","grep","-o regex extent","grep: only-matching with backreferences, lookarounds or word constraints is not supported",2)};try{h.extent=new ct(Hn(d,!0,r),!1,null,r)}catch{return{error:v("feature","grep","-o regex extent","grep: POSIX match extent for this pattern is not supported",2)}}}o.push(h)}catch(h){if(!t.has("P")&&Qw(p,t))return{error:v("feature","grep","GNU regex syntax","grep: this GNU regular expression cannot be represented by the JavaScript matcher",2)};let m=t.has("F")?`fixed-string /${c}`:t.has("P")?`PCRE subset /${c}`:t.has("E")?`ERE / ECMAScript /${c}`:`BRE /${c}`;return{error:x(`grep: invalid pattern (${m}): ${h.message}`,2)}}}return{res:o}}function Qw(e,t){if(!t.has("E")&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return no(Hn(e,!0)),!0}catch(n){return!!n.gap}}function zf({pattern:e,tables:t},n){return[...e].map(r=>(n?t.fold(r.codePointAt(0)):[r.codePointAt(0)]).map(i=>B(String.fromCodePoint(i))))}function Hf(e,t){return t.every(n=>n.literal?(n.literalMask??=zf(n.literal,n.folded),!Xf(e,n.literalMask)):!1)}function Gf(e,t,n,r=ee){let o=re(r);return t.every(i=>(n||!Yf.test(i))&&i.isWellFormed()&&!Xf(e,zf({pattern:i,tables:o},!1)))}function Xf(e,t){for(let n=0;n+t.length<=e.length;n++)if(Zf(e,n,t,0))return!0;return!1}function Zf(e,t,n,r){return r===n.length?!0:n[r].some(o=>o.every((i,s)=>e[t+s]===i)&&Zf(e,t+o.length,n,r+1))}var Yf=/[\\.^$*+?()[\]{}|]/u;function ss(e,t,n,r=!1,o=ee){if(e.length===0)return null;if(e.some(a=>a.content===void 0))return v("feature","grep","binary input","grep: binary input detection and output are not supported",2);if(!r&&e.some(a=>a.content.includes("\0")&&(n||t.some(l=>!l.binaryLiteral||l.test(a.content)))))return v("feature","grep","binary input","grep: binary input detection and output are not supported",2);let i=/[\u0080-\u{10FFFF}]/u;if(o!==ee&&t.some(a=>a.localeSensitive||a.folded)&&(t.some(a=>a.unicodePattern)||e.some(a=>i.test(a.content))))return v("feature","grep","locale",`grep: matching non-ASCII text in the ${o} locale is not supported`,2);if(t.some(a=>a.extendedC)||t.some(a=>a.folded)&&e.some(a=>Tt.test(a.content)))return v("feature","grep","locale-sensitive regex","grep: case-insensitive matching over Cyrillic Extended-C letters is not supported",2);let s=t.filter(a=>a.localeSensitive);if(s.length===0||!(s.some(a=>a.unicodePattern)||e.some(a=>i.test(a.content))))return null;let u=s.some(a=>a.pcre)?"PCRE matching":"case-insensitive matching with backreferences";return v("feature","grep","non-ASCII regex semantics",`grep: ${u} on non-ASCII input is not supported`,2)}var us=/[*?[]/u,as=/\P{ASCII}/u,ey=/[.+*?^${}()|[\]\\/]/u;function Me(e,t={}){try{return ty(e,t)}catch(n){throw n instanceof b?n:new b("feature","glob pattern",`unsupported glob pattern: ${n.message}`)}}function ty(e,t){let n="^",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"&&o+1<e.length){let s=e[o+1];n+=Vf(s,t.ignoreCase),o++}else if(i==="*"){for(;e[o+1]==="*";)o++;n+=".*"}else if(i==="?")n+=".";else if(i==="["){let s=Kf(e,o,t);if(s?.voided)return/^(?!)$/u;s?(n+=s.source,o=s.end,r||=s.nonAsciiRange):n+="\\["}else n+=Vf(i,t.ignoreCase)}return ry(new RegExp(n+"(?![\\s\\S])","us"),e,t,r)}function Vf(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:ey.test(e)?"\\"+e:e}function ny(e,t,n){let r=new RegExp(`[${e}]`,"ui"),o=new RegExp(`[${t}]`,"u"),i="";for(let s=0;s<128;s++){let u=String.fromCodePoint(s);(r.test(u)||o.test(u))&&(i+="\\x"+s.toString(16).padStart(2,"0"))}return`[${n?"^":""}${i}]`}function ry(e,t,n,r){let o=/[?[]/u.test(t),i=as.test(t);return{test(s){if(r||n.ignoreCase&&i||(o||n.ignoreCase)&&as.test(s))throw new b("feature","non-ASCII glob matching","locale-dependent glob matching of non-ASCII names is not supported");return e.test(s)}}}function Kf(e,t,n){let{ignoreCase:r}=n,o=t+1,i=!1;(e[o]==="!"||e[o]==="^")&&(i=!0,o++);let s="",u="",a=!1,l=!1,f=!1,c=!1,d="",p=0,h="",m=0;for(e[o]==="]"&&(s+="\\]",o++,a=!0,d="]");o<e.length&&e[o]!=="]";o++){let g=e[o];if(g==="["&&(e[o+1]==="."||e[o+1]==="="))throw new b("feature","glob collating or equivalence class","glob collating symbols and equivalence classes are not supported");if(g==="["&&e[o+1]===":"){let w=n.bash?oy(e,o):Kt(e,o,{unknown:"empty"});if(w){if(!n.bash&&w.body==="")throw new b("feature","glob character class","unknown POSIX classes in command filename patterns are not supported");l&&(c=!0),r?u+=w.body:s+=w.body,o=w.end-1,a=!1,l=!1;continue}if(n.bash)continue}if(g==="-"&&a)m=p,h=d,s+="-",l=!0,a=!1;else{let w=g==="\\"&&o+1<e.length?e[++o]:g;p=s.length,d=w,l&&as.test(h+w)&&(f=!0),l&&w.codePointAt(0)<h.codePointAt(0)?s=s.slice(0,m):s+=/[\]\\^[-]/u.test(w)?`\\${w}`:w,a=!l,l=!1}}return o>=e.length?null:c?{voided:!0,end:o}:{source:r?ny(s,u,i):`[${i?"^":""}${s}]`,end:o,nonAsciiRange:f}}function oy(e,t){let n=e.indexOf(":]",t+2);if(n===-1)return null;let r=e.slice(t+2,n).replace(/\\([\s\S]|$)/gu,"$1");return{body:r==="ascii"?"\\x00-\\x7F":It[r]??"",end:n+2}}function Jf(e,t){return Me(t).test(e)}function Qf(e){let{value:t,mask:n}=e;if(n===null)return us.test(t);for(let r=0;r<t.length;r++)if(n[r]==="0"&&us.test(t[r]))return!0;return!1}function Gn(e){let t=n=>!e.mask||e.mask[n]==="0";for(let n=0;n<e.value.length;n++){let r=e.value[n];if(t(n)){if(r==="\\")n++;else if(r==="[")n=iy(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]==="("&&t(n+1))return!0}}return!1}function iy(e,t,n){let{value:r}=e,o=t+1;for(/[!^]/u.test(r[o])&&n(o)&&o++,r[o]==="]"&&n(o)&&o++;o<r.length;o++)if(n(o))if(r[o]==="\\")o++;else{if(r[o]==="]")return o;if(r[o]==="["&&/[.:=]/u.test(r[o+1])&&n(o+1)){let i=r.indexOf(r[o+1]+"]",o+2);i!==-1&&(o=i+1)}}return t}var sy=/[*?[\]^!\\:.=-]/u;function on(e){let{value:t,mask:n}=e;if(n===null)return t;let r="";for(let o=0;o<t.length;o++){let i=t[o];r+=n[o]!=="0"&&sy.test(i)?"\\"+i:i}return r}function ec(e,t){let n=on(e),r=n.match(/[^/]+|\/+/gu)??[],o=Jt(),i=new Set,s=[{path:"",marks:null}],u;try{for(let l=0;l<r.length;l++){let f=r[l];if(f.startsWith("/")||!us.test(f)){s=s.map(c=>({...c,path:c.path+ay(f)}));continue}s=ly(s,f,l===r.length-1,t,i)}let a=s.filter(l=>E(t.cwd,l.path,t.fs,{follow:!1}).path!==null);for(let l of a)for(let f of l.marks??[])o.add(f);return u=a.filter(l=>l.marks===null).map(l=>l.path).sort(j),u}finally{if(u===void 0)for(let a of i)o.add(a);o.emit(t.notes,"glob","",` while expanding ${JSON.stringify(n)}`),u?.length===0&&r.some(uy)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function uy(e){for(let t=0;t<e.length;t++)if(e[t]==="\\")t++;else{if(e[t]==="*"||e[t]==="?")return!0;if(e[t]==="[")try{if(Kf(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var ay=e=>e.replace(/\\(.)/gu,"$1");function ly(e,t,n,r,o){let i=Me(t,{bash:!0}),s=t.startsWith(".")||t.startsWith("\\."),u=[];for(let a of e){let l=E(r.cwd,a.path||".",r.fs).path;if(!r.fs.isDir(l))continue;let{dirs:f,files:c,links:d}=r.fs.listDir(l),p=n?d:d.filter(h=>r.fs.isDir(E(l,h,r.fs).path));for(let h of n?[...f,...c,...p]:[...f,...p]){let m=!s&&h.startsWith(".");if(!m&&a.marks===null)i.test(h)&&u.push({path:a.path+h,marks:null});else if(fy(i,h)){if(!m){u.push({path:a.path+h,marks:a.marks});continue}let g=Z(l,h);o.add(g),u.push({path:a.path+h,marks:[...a.marks??[],g]})}}}return u}function fy(e,t){try{return e.test(t)}catch{return!0}}var fs=(e,t)=>e.some(n=>n.test(t)),cs=()=>({stdout:"",stderr:"",exitCode:1});function ds(e,t,n,r){let o=0;if(r===1/0){for(let s of he(e))fs(t,s)!==n&&o++;return o}let i=0;for(;i<e.length&&o<r;){let s=e.indexOf(`
|
|
48
|
+
`,i);s<0&&(s=e.length),fs(t,e.slice(i,s))!==n&&o++,i=s+1}return o}function nc(e,t,n){let r=[],o=!1;for(let{name:i,content:s,recursive:u}of e){let a={...n,showName:n.showName??u,separate:o&&n.hasContext};cy(he(s),t,i,a,r)&&(o=!0)}return o?F(ge(r)):cs()}function cy(e,t,n,r,o){let{invert:i,after:s,before:u,max:a,hasContext:l}=r,f=-1,c=0,d=0;for(let p=0;p<e.length&&!(c===a&&d===0);p++){let h=fs(t,e[p])!==i,m=a!==void 0&&c>=a;if(h&&!m){c++,c===1&&r.separate&&o.push("--");let g=Math.max(0,p-u);l&&f>=0&&g>f+1&&o.push("--");for(let w=Math.max(g,f+1);w<p;w++)ls(e[w],n,w+1,t,r,!1,o);ls(e[p],n,p+1,t,r,!0,o),f=p,d=s;continue}d>0&&(ls(e[p],n,p+1,t,r,!1,o),f=p,d--)}return c>0}function ls(e,t,n,r,o,i,s){if(!o.only){s.push(tc(e,t,n,i,o));return}if(i===o.invert)return;let u=0;for(;u<e.length;){let a=null;for(let l of r){let f;if(l.extent)f=l.extent.search(e,u);else{let c=l.scan??=new RegExp(l.source,l.flags+"g");c.lastIndex=u;let d=c.exec(e);if(d&&d[0]===""&&l.pcre)throw new b("feature","PCRE empty match extent","only-matching with empty PCRE matches is not supported");f=d?{start:d.index,end:d.index+d[0].length}:null}f&&(!a||f.start<a.start||f.start===a.start&&f.end>a.end)&&(a=f)}if(!a)break;if(a.end===a.start){u=a.end+Le(e,a.end);continue}s.push(tc(e.slice(a.start,a.end),t,n,i,o)),u=a.end}}function tc(e,t,n,r,o){let i=r?":":"-";return(o.showName?(t??"(standard input)")+i:"")+(o.showLine?n+i:"")+e}function rc(e,t,{mode:n,invert:r,showName:o,max:i=1/0}){let s=[],u=!1,a=n==="c"?i:Math.min(1,i);for(let{name:l,content:f,recursive:c}of e){let d=ds(f,t,r,a);d>0&&(u=!0);let p=l??"(standard input)";n==="c"?s.push(o??c?p+":"+d:String(d)):d>0==(n==="l")&&s.push(p)}return{stdout:ge(s),stderr:"",exitCode:u?0:1}}function oc(e,t,n){let r=e.order.filter(s=>["e","f","file"].includes(s.name)),o=e.positional;if(r.length===0)return o.length?{patterns:o[0].split(`
|
|
49
|
+
`),rest:o.slice(1),stdin:t}:null;let i=new Set;for(let{name:s,value:u}of r){if(s==="e"){for(let f of u.split(`
|
|
50
|
+
`))i.add(f);continue}let a=st("grep",[u],n,t);if(a.failed)return{error:x(a.stderr,2)};let l=a.inputs[0];for(let f of he(l.content))i.add(f);l.shared&&(t="")}return{patterns:[...i],rest:o,stdin:t}}var ic="[-i] [-a|-I] [-s] [-v] [-n] [-r|-R] [-w] [-x] [-o] [-E|-F|-G|-P] [-l] [-L] [-c] [-q] [-m N] [-h] [-H] [-A N] [-B N] [-C N] [--include=GLOB] [--exclude=GLOB] [--exclude-dir=GLOB]",dy=`grep ${ic} PATTERN [PATH...]
|
|
51
|
+
or: grep ${ic} [-e PATTERN] [-f FILE] ... [PATH...]`,py=["i","v","n","r","R","l","L","c","w","x","h","H","o","E","F","G","P","q","I","a","s"],hy=["A","B","C","m"],lc={short:py,long:["text","no-messages"],valueShort:hy,repeatable:["e","f","file","include","exclude","exclude-dir"]};function fc(e){try{return N(e,lc).flags.has("q")}catch{return!1}}function so(e,t,n){let r;try{r=N(t,lc)}catch(m){return K(m,"grep",`grep: ${m.message}`,2)}let{flags:o,values:i}=r,s=oc(r,e,n);if(!s)return pe(dy,2);if(s.error)return s.error;let{patterns:u,rest:a}=s;e=s.stdin;let l=by(o);if(l)return l;let f;try{f=qf(u,o,n.locale)}catch(m){return K(m,"grep",`grep: ${m.message}`,2)}if(f.error)return f.error;let c=xy(i);if(c.error)return c.error;if(c.max===0&&(!o.has("L")||o.has("q")))return cs();if(c.max!==0&&n.stdinFile&&(o.has("q")||o.has("l")||o.has("L")||i.has("m"))&&(a.length===0||a.includes("-")))return v("feature","grep","partial stdin reads","grep: early termination on shared file input is not supported",2);let d=o.has("r")||o.has("R"),p=Sy(r,n),h=r.order.findLast(m=>["a","I","text"].includes(m.name))?.name;p.ignoreBinary=h==="I"&&c.max!==0,p.forceText=h==="a"||h==="text",p.silent=o.has("s")||o.has("no-messages"),p.follow=o.has("R");try{return my(e,a,n,d,p,f,o,c)}finally{yy(p,n.notes)}}function my(e,t,n,r,o,i,s,u){if(s.has("q"))return gy(e,t,n,r,o,i.res,s.has("v"));let a=dc(r,e,t,n,o);u.max===0&&q(n,e);let l=a.inputs;o.name.length>0&&(l=l.filter(g=>pc(g,o))),u.max!==0&&(l=l.map(g=>cc(g,o,i.res,s.has("v"))));let f=u.max===0?null:ss(l,i.res,s.has("v"),o.forceText,n.locale);if(f)return f;let c=ky(s,t.length),d=s.has("v"),p={showName:c,invert:d,showLine:s.has("n"),only:s.has("o"),...u},h=["l","L","c"].find(g=>s.has(g)),m;try{m=h?rc(l,i.res,{...p,mode:h}):nc(l,i.res,p)}catch(g){return g instanceof $&&g.gap?v("feature","grep",g.gap,`grep: ${g.message}`,2):K(g,"grep",`grep: ${g.message}`,2)}return a.failed?{stdout:m.stdout,stderr:a.stderr+m.stderr,exitCode:2}:m}function gy(e,t,n,r,o,i,s){let u="",a=!1;for(let l of t.length?t.map(f=>[f]):[[]]){let f=dc(r,e,l,n,o);u+=f.stderr,a||=f.failed,(l.includes("-")||l.includes("/dev/stdin")&&!n.stdinFile)&&(e="");for(let c of f.inputs){if(!pc(c,o))continue;let d=cc(c,o,i,s),p=ss([d],i,s,o.forceText,n.locale);if(p)return p.stderr=u+p.stderr,p;if(ds(d.content,i,s,1)>0)return{stdout:"",stderr:u,exitCode:0}}}return{stdout:"",stderr:u,exitCode:a?2:1}}function cc(e,t,n,r){if(e.content===void 0){if(!r&&Hf(e.bytes,n))return{...e,content:""};if(!t.ignoreBinary)return e;if(!wy(e.bytes,sc))throw new b("feature","late binary detection","grep: binary detection after the initial input buffer is not supported");return uc(e,t)}if(!e.content.includes("\0")||t.forceText)return e;if(!t.ignoreBinary)return/^[\0\n]+$/u.test(e.content)&&n.some(o=>o.test(""))===r?{...e,content:""}:e;if(A(e.content.slice(0,e.content.indexOf("\0"))).length>=sc)throw new b("feature","late binary detection","grep: binary detection after the initial input buffer is not supported");return uc(e,t)}var sc=96*1024;function uc(e,t){let n=e.name===null||e.name==="/dev/stdin"?t.stdinPath:Z(t.cwd,e.name);return n?t.binary.add(n):t.binaryStdin=!0,{...e,content:""}}function wy(e,t){if(e.length<=t)return!0;for(let n=t;n<=t+3&&n<=e.length;n++)if(me(e.subarray(0,n))!==void 0)return!1;return!0}function yy(e,t){let n="Binary input is treated as text with -a.";gt(t,{command:"grep",action:"skipped",noun:["binary file","binary files"],paths:e.binary,explanation:n}),e.binaryStdin&&t.add("grep: skipped binary standard input. "+n),gt(t,{command:"grep",action:"excluded",noun:["entry","entries"],paths:e.excluded,context:" by --include/--exclude/--exclude-dir rules"})}function by(e){if(e.has("h")&&e.has("H"))return v("option","grep","-h -H","grep: combining -h and -H is not supported");let t=["l","L","c"].filter(r=>e.has(r));if(t.length>1)return v("option","grep","combined output modes",`grep: ${t.map(r=>`-${r}`).join(" / ")} are mutually exclusive`);let n=["E","F","G","P"].filter(r=>e.has(r));return n.length>1?x(`grep: ${n.map(r=>`-${r}`).join(" / ")} are mutually exclusive`,2):null}function xy(e){let t={A:0,B:0,m:void 0};for(let n of["C","A","B","m"]){if(!e.has(n))continue;let r=be(e.get(n),"grep: -"+n);if(r.error)return n==="m"&&(r.error.exitCode=2),r;n==="C"?t.A=t.B=r.value:t[n]=r.value}return{after:t.A,before:t.B,max:t.m,hasContext:["A","B","C"].some(n=>e.has(n))}}function ky(e,t){return e.has("h")?!1:e.has("H")||t>1?!0:void 0}function dc(e,t,n,r,o){if(!e){let a=te("grep",n,t,r,{read:"maybe-text"});return{...a,stderr:o.silent?"":a.stderr,inputs:a.inputs.map(l=>l.name==="-"?{...l,name:null}:l)}}let i=[],s="",u=!1;for(let a of n.length?n:["."]){if(a==="-"||a==="/dev/stdin"||a==="/dev/null"){let d=st("grep",[a],r,t);i.push(...d.inputs.map(p=>({...p,name:a==="-"?null:a}))),(a==="-"||a==="/dev/stdin")&&(t="");continue}let{path:l,error:f}=P(r,"grep",a);if(r.fs.isFile(l)){i.push({name:a,...ps(r,l)});continue}if(f){s+=`grep: ${a}: ${f}
|
|
52
|
+
`,u=!0;continue}if(Ey(a,o.dir)){o.excluded.add(l);continue}let c=d=>d===l||o.dir.length===0||!hs(o.dir,nt(d))?!0:(o.excluded.add(d),!1);for(let d of Fe(r.fs,l,1/0,c)){if(d.kind==="link"){if(!o.follow)continue;let h=vy(d.path,ac(n.length?a:"",l,d.path),r,o);h?.input&&i.push(h.input),h?.error&&(s+=h.error,u=!0);continue}if(d.kind!=="file")continue;let p=d.path;i.push({name:ac(n.length?a:"",l,p),...ps(r,p),recursive:!0})}}return{inputs:i,stderr:o.silent?"":s,failed:u}}function vy(e,t,n,r){let o=E(n.cwd,e,n.fs),i=n.fs.isDir(o.path);if(!(i?r.dir.length===0||!hs(r.dir,nt(e)):hc(nt(e),r.name)))return r.excluded.add(e),null;if(i)throw new b("option","-R",`following a symbolic link to a directory is not supported: ${t}`);return o.error?{error:`grep: ${t}: ${o.error}
|
|
53
|
+
`}:{input:{name:t,...ps(n,o.path),recursive:!0}}}function ps(e,t){let{text:n,bytes:r}=wt(e.fs,t);return n===void 0?{content:void 0,bytes:r}:{content:n}}function Sy(e,t){let n=e.order.filter(o=>o.name==="include"||o.name==="exclude").map(o=>({include:o.name==="include",re:Me(o.value)})),r=(e.values.get("exclude-dir")??[]).map(o=>Me(o));return{name:n,dir:r,binary:new Set,excluded:new Set,cwd:t.cwd,stdinPath:t.stdinHandle?.path}}function hs(e,t){return e.some(n=>n.test(t))}function pc(e,t){return e.name===null||hc(nt(e.name),t.name)?!0:(t.excluded.add(Z(t.cwd,e.name)),!1)}function hc(e,t){if(t.length===0)return!0;let n=null;for(let r of t)r.re.test(e)&&(n=r);return n?n.include:!t[0].include}function Ey(e,t){return t.length===0||e.endsWith("/")?!1:hs(t,e.slice(e.lastIndexOf("/")+1))}function ac(e,t,n){let r=He(t,n);return e===""?r:e.endsWith("/")?e+r:e+"/"+r}var Xn=(e,t)=>v("feature","rg",e,`rg: ${t}`,2);function mc(e,t,n){let r=O(e)??e.note;return r?v(r.kind,"rg",r.detail,t,2):v(n,"rg",e.detail??t.replace(/^rg: /u,""),t,2)}function wc(e,t,n){let r,o;try{o=N(t,Ef),r=$f(o)}catch(d){return mc(d,d.message.startsWith("rg: ")?d.message:`rg: ${d.message}`,"option")}let i=[...o.positional];if(!r.patterns.length){if(!i.length)return Xn("usage","a pattern is required");r.patterns.push(i.shift())}try{Af(r.patterns,r.literal)}catch(d){return mc(d,d.message,"feature")}let u=!i.length&&!!n.stdinPiped?{roots:[],recursive:!1,stdin:!0}:Ay(i,n,r.hidden);if(u.error)return u.error;if(!o.flags.has("no-ignore")&&!r.unrestricted&&u.recursive){let d=Oy(u.roots,n);if(d)return Xn("ignore rules",`${JSON.stringify(d)} would change which files are searched, and its rules are not implemented`)}let a=$y(i,u,r,n),l=r.text?null:Cy(i,n);if(l)return Xn("named binary file",`${JSON.stringify(l)} is binary, and reporting a binary match is not supported`);let f=Ny(a,r,n);return f?Xn(f.detail,f.message):(u.stdin||i.length?1:a.length)===0?{stdout:"",exitCode:2,stderr:`rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
|
|
47
54
|
Running with --debug will show why files are being skipped.
|
|
48
|
-
`}:
|
|
49
|
-
`).some(
|
|
55
|
+
`}:Iy(e,r,i,u,n)}function $y(e,t,n,r){let o=e.map(i=>E(r.cwd,i,r.fs).path).filter(Boolean).map(i=>({path:i,named:!0}));for(let i of t.roots)for(let s of Fe(r.fs,i)){if(s.kind!=="file")continue;let u=He(i==="/"?"/":i,s.path).split("/");(n.hidden||u.every(a=>!a.startsWith(".")))&&o.push({path:s.path,named:!1})}return o}function Ny(e,t,n){for(let{path:r,named:o}of e){if(n.fs.isDir(r))continue;let{text:i,bytes:s}=wt(n.fs,r);if(i!==void 0&&!i.startsWith("\uFEFF")||(s===void 0?i.includes("\0"):s.includes(0))&&!o&&!t.text)continue;let a=JSON.stringify(He(n.cwd==="/"?"/":n.cwd,r)||r);if(i===void 0){if(!t.invert&&!t.ignoreCase&&Gf(s,t.patterns,t.literal,n.locale))continue;return{detail:"unreadable bytes",message:`${a} holds bytes that are not text, and searching them is not supported`}}if(i.startsWith("\uFEFF"))return{detail:"byte-order mark",message:`${a} begins with a byte-order mark, which ripgrep strips before matching`}}return null}function Ay(e,t,n){let r=[],o=!1;for(let s of e){let u=E(t.cwd,s,t.fs);u.path!==null&&t.fs.isDir(u.path)&&r.push(u.path),s.split("/").some(a=>a.startsWith(".")&&a!=="."&&a!=="..")&&(o=!0)}e.length||r.push(t.cwd);let i=r.length>0;return!n&&i&&o&&e.length?{error:Xn("named hidden path","a hidden path named beside a directory is searched by ripgrep but skipped while walking, and both cannot apply at once")}:{roots:r,recursive:i}}function Oy(e,t){let n=l=>He(t.cwd==="/"?"/":t.cwd,l)||l,r=(l,f=!0)=>{for(let c of e){for(let d of Fe(t.fs,c))if(nt(d.path)===l&&ms(d.path,f,t))return d.path;for(let d=c;d!=="/";d=ye(d)){let p=E(ye(d),l,t.fs);if(p.path!==null&&ms(p.path,f,t))return p.path}}return null},o=r(".ignore")??r(".rgignore");if(o)return n(o);let i=r(".git",!1);if(!i)return null;let s=E(i,"info/exclude",t.fs).path,u=s!==null&&ms(s,!0,t)?s:null,a=r(".gitignore")??u;return a?n(a):null}function ms(e,t,n){if(!t||n.fs.isDir(e))return!0;let r=E("/",e,n.fs).path,{text:o}=wt(n.fs,r??e);return(o??" ").split(`
|
|
56
|
+
`).some(i=>i.trim()!==""&&!i.trimStart().startsWith("#"))}function Cy(e,t){for(let n of e){let r=E(t.cwd,n,t.fs);if(r.path===null||t.fs.isDir(r.path))continue;let{text:o,bytes:i}=wt(t.fs,r.path);if(i===void 0?o?.includes("\0"):i.includes(0))return n}return null}function Iy(e,t,n,r,o){let i=t.literal?["-F"]:["-P"];t.ignoreCase&&i.push("-i"),t.lineNumbers&&i.push("-n"),t.word&&i.push("-w"),t.invert&&i.push("-v"),t.quiet&&i.push("-q"),t.mode&&i.push("-"+t.mode),t.showName&&i.push("-"+t.showName),i.push(t.text?"-a":"-I"),t.after&&i.push("-A",String(t.after)),t.before&&i.push("-B",String(t.before)),r.recursive&&i.push("-r"),r.recursive&&!t.hidden&&i.push("--exclude=.*","--exclude-dir=.[!.]*","--exclude-dir=..?*"),i.push(...Nf(t.patterns,t.literal)),r.stdin||i.push("--",...n.length?n:["."]);let s=new Set(o.notes),u=so(e,i,o);return Ry(o.notes,s,r),_y(Ty(u,t),n,t.patterns)}function Ty(e,t){if(t.mode!=="c")return e;let n=e.stdout.split(`
|
|
50
57
|
`).filter(r=>r!==""&&r!=="0"&&!r.endsWith(":0"));return{...e,stdout:n.length?n.join(`
|
|
51
58
|
`)+`
|
|
52
|
-
`:""}}var
|
|
53
|
-
`;o
|
|
54
|
-
`,"n"],["\r","r"],[" ","t"],["\v","v"]]);function
|
|
55
|
-
`,"n"],["\r","r"],[" ","t"],["\v","v"],['"','"'],["\\","\\"]]);function
|
|
56
|
-
`,!0)}}return p.result.exitCode=p.failed?1:0,p.result}function
|
|
57
|
-
`,!0);if(u.error)return a(`cannot stat ${
|
|
58
|
-
`,!1,!0);n.sources.add(u.path)}let l=
|
|
59
|
-
`,!0),f=
|
|
60
|
-
`,!1,!0);r.sources.add(t)}
|
|
61
|
-
`,!0),!1),a=
|
|
62
|
-
`))}function
|
|
63
|
-
`);if(r.path==="/tmp")
|
|
64
|
-
`);n.verbose&&
|
|
65
|
-
`,1)}function
|
|
66
|
-
`),!1),s=e.replace(/\/+$/u,"")||e,u=
|
|
67
|
-
`,1),!0}function
|
|
68
|
-
`,r.failed=!0}function
|
|
69
|
-
`,e.failed=!0}function
|
|
70
|
-
`,d=U(),p=!1;for(let h of
|
|
71
|
-
`);if(u==="")return a(` -> ${
|
|
72
|
-
`);try{if(!
|
|
73
|
-
`,1)}function db(e,t){if(t===""||t.includes("\0"))return"No such file or directory";let n=t.replace(/\/+$/u,"");if(n==="")return"File exists";let r=
|
|
59
|
+
`:""}}var gc=new Map([["No such file or directory",2],["Not a directory",20],["Is a directory",21]]),Fy=e=>e.replaceAll(/^(rg: .*: )([A-Z][a-z].*)$/gmu,(t,n,r)=>gc.has(r)?`${n}${r} (os error ${gc.get(r)})`:t),Ly=/^rg: (?:invalid pattern[^\n]*|trailing backslash)$/mu;function _y(e,t,n){let r=s=>t.length?s:s.replaceAll(/^\.\//gmu,""),o={...e,stdout:r(e.stdout),stderr:Fy(r(e.stderr).replaceAll(/^grep: /gmu,"rg: "))},i=O(e);return i?.detail==="non-ASCII regex semantics"?v("feature","rg","non-ASCII matching","rg: Unicode-aware matching on non-ASCII input is not supported",2):i?v(i.kind,"rg",i.detail,o.stderr.trimEnd()||i.message,e.exitCode):Ly.test(o.stderr)?v("feature","rg","regex parse error",`rg: regex parse error in ${JSON.stringify(n.join(" "))}; the reason ripgrep gives is not reproduced here`,2):o}function Ry(e,t,n){let r=[];for(let o of e)!t.has(o)&&o.startsWith("grep: excluded ")&&r.push(o);for(let o of r)e.delete(o),n.recursive&&e.add(o.replace(/^grep: excluded (\d+) (entry|entries) by --include\/--exclude\/--exclude-dir rules/u,"rg: skipped $1 hidden $2").replace(/\.$/u,". Hidden entries are searched with --hidden."))}var yc=e=>e.text??W(e.bytes),ws=(e,t)=>{e.bytes===void 0?t.write(e.text):t.writeBytes(e.bytes)},sn=e=>e.events??[...e.stdout?[{fd:1,text:e.stdout}]:[],...e.stderr?[{fd:2,text:e.stderr}]:[]],gs=e=>e.unordered??(!e.events&&e.stdout!==""&&e.stderr!==""),U=(e="")=>({stdout:"",stderr:e,exitCode:0,ignored:!1,events:e?[{fd:2,text:e}]:[],unordered:!1});function _(e,t){e.stdout+=t.stdout,e.stderr+=t.stderr,e.exitCode=t.exitCode,e.ignored=t.ignored??!1,e.events.push(...sn(t)),e.unordered||=gs(t)}function uo(e,t){t&&_(e.expansionOutput,un(U(t),{fds:e.expansionFds},e))}function un(e,t,n){let r=o=>My(e,t,n,o);return n.io?n.io.output(e,t,r):r(ws)}function My(e,t,n,r){let o=e,i=t.fds[1],s=t.fds[2];(i===s&&i!=="null"&&i!=="closed"||(i?.identity&&s?.identity?i.identity===s.identity:i?.path&&i.path===s?.path))&&gs(o)&&(o=v("feature",null,"combined output ordering","error: merging this command\u2019s stdout and stderr in order is not supported"),n.unsupported.add(O(o)));let a=[],l="",f="";for(let c of sn(o)){let d=t.fds[c.fd];if(typeof d=="object"){r(c,d);continue}if(t.deferred?.[c.fd]&&c.bytes!==void 0){a.push(c);continue}if(d!=="out"&&d!=="err"){c.fd===2&&Ga(n,yc(c));continue}let p=yc(c);a.push({fd:d==="out"?1:2,text:p}),d==="out"?f+=p:l+=p}return{...o,stdout:f,stderr:l,events:a,unordered:gs(o)&&f!==""&&l!==""}}var Py=new Map([["ls",2],["grep",2],["egrep",2],["fgrep",2],["sort",2],["xxd",3],["sed",4],["diff",2],["patch",2],["xargs",123],["hexdump",0],["tree",0]]),Dy=e=>e.stdout!==""||sn(e).some(t=>t.fd===1&&(t.bytes?.length??0)>0);function ys(e,t,n){return n.closed.out&&Dy(t)?By(e,t,n):t}function By(e,t,n){let r=Py.get(n.registry.resolveCommand(e))??1,o=sn(t).filter(a=>a.fd!==1),i=r===0?"":`${e}: write error: Bad file descriptor
|
|
60
|
+
`;i&&o.push({fd:2,text:i});let s={...t,stdout:"",stderr:t.stderr+i,exitCode:r||t.exitCode,events:o,unordered:!1},u=O(t);return u?ie(s,u.kind,u.command,u.detail,u.message):s}var Uy=new Map([["\0","0"],["\x07","a"],["\b","b"],["\f","f"],[`
|
|
61
|
+
`,"n"],["\r","r"],[" ","t"],["\v","v"]]);function X(e,t){let n=le(t),r=n?Array.from(B(e),s=>String.fromCodePoint(s)):[...e];if(!n&&r.some(s=>s.codePointAt(0)>127&&/[\p{C}\p{Zl}\p{Zp}]/u.test(s)))throw new b("feature","filename quoting","quoting nonprinting Unicode filenames is not supported");if(e.includes("'")&&r.every(s=>/[-a-zA-Z0-9 %+,./:_\]']/u.test(s)||!n&&s.codePointAt(0)>127))return'"'+e+'"';let o=!1,i="'";for(let s of r){let u=s.codePointAt(0),a=Uy.get(s)??(u<32||u===127||n&&u>127?u.toString(8).padStart(3,"0"):null);a!==null?(o||(i+="'$'"),o=!0,i+="\\"+a):s==="'"?(i+="'\\''",o=!1):(o&&(i+="''"),o=!1,i+=s)}return i+"'"}var jy=/^[#%+,\-./0-9@A-Z\]_a-z{}~]+$/u;function oe(e,t){return jy.test(e)&&!"#~".includes(e[0])?e:X(e,t)}var Wy=new Map([["\x07","a"],["\b","b"],["\f","f"],[`
|
|
62
|
+
`,"n"],["\r","r"],[" ","t"],["\v","v"],['"','"'],["\\","\\"]]);function bs(e,t){let n=le(t),r="",o=!1;for(let i of e){let s=i.codePointAt(0),u=Wy.get(i);if(u!==void 0)r+="\\"+u,o=!0;else if(i===" ")r+=i,o=!0;else if(s<32||s===127||s>127&&(n||/[\p{C}\p{Zl}\p{Zp}]/u.test(i))){for(let a of A(i))r+="\\"+a.toString(8).padStart(3,"0");o=!0}else r+=i}return o?`"${r}"`:e}var qy=new Set(["/dev/null","/dev/stdin","/dev/stdout","/dev/stderr"]);function xc(e,t,n){let r=N(t,{short:["f","n","v","T","r","R"],long:["force","no-clobber","verbose","no-target-directory","recursive"],valueShort:["t"],valueLong:["target-directory"]}),o=zy(r,n);if(o.error)return x("cp: "+o.error);let{sources:i,target:s,directory:u}=o,{flags:a}=r,l=a.has("v")||a.has("verbose"),f=a.has("r")||a.has("R")||a.has("recursive"),c=i.map(h=>[h,u?s.replace(/\/+$/u,"")+"/"+Xy(h):s]),d=a.has("n")||a.has("no-clobber"),p={ctx:n,result:U(),failed:!1,sources:new Set,copied:new Set,noClobber:d,force:a.has("f")||a.has("force"),verbose:l,recursive:f,outputOverlap:l&&Vy(c,n,{recursive:f,noClobber:d})};for(let[h,m]of c){n.io.setReads([]);try{Ec(h,m,p)}catch(g){R(n,"cp",g?.path,g?.fsError);let w=O(g),y="cp: "+V(g);if(w)return n.unsupported.add({...w,command:w.command??"cp",message:y}),_(p.result,x(y)),p.result;Bt(p,y+`
|
|
63
|
+
`,!0)}}return p.result.exitCode=p.failed?1:0,p.result}function zy({positional:e,flags:t,order:n},r){let o=n.filter(({name:f})=>f==="t"||f==="target-directory");if(o.length>1)return{error:"multiple target directories specified"};let i=o[0]?.value,s=t.has("T")||t.has("no-target-directory");if(e.length===0)return{error:"missing file operand"};if(i===void 0&&e.length===1)return{error:"missing destination file operand after "+X(e[0],r)};if(i!==void 0&&s)return{error:"cannot combine --target-directory (-t) and --no-target-directory (-T)"};if(s&&e.length>2)return{error:"extra operand "+X(e[2],r)};let u=i??e.at(-1),a=E(r.cwd,u,r.fs),l=!s&&r.fs.isDir(a.path);return!l&&(i!==void 0||e.length>2)?(R(r,"cp",u,a.error),{error:`${i===void 0?"target":"target directory"} ${X(u,r)}: ${a.error??"Not a directory"}`}):{target:u,directory:l,sources:i===void 0?e.slice(0,-1):e}}function Hy(e,t,n){let{ctx:r}=n,o=E(r.cwd,e,r.fs,{follow:!1}).path;if(o===null)return;let i=e.replace(/\/+$/u,""),s=t.replace(/\/+$/u,"");for(let u of Fe(r.fs,o)){if(u.kind!=="link")continue;let a=u.path===o?null:He(o,u.path);if(!kc(a===null?t:`${s}/${a}`,n)&&!(a!==null&&Gy(s,a,n)))throw vc(a===null?e:`${i}/${a}`)}}var kc=(e,t)=>t.noClobber&&E(t.ctx.cwd,e,t.ctx.fs,{follow:!1}).path!==null;function Gy(e,t,n){let{ctx:r}=n,o=t.split("/");for(let i=1;i<o.length;i++){let s=E(r.cwd,`${e}/${o.slice(0,i).join("/")}`,r.fs,{follow:!1});if(s.path!==null&&!r.fs.isDir(s.path))return!0}return!1}var vc=e=>new b("feature","symbolic link",`copying a symbolic link is not supported: ${e} (a recursive copy keeps the link, which cp does not make here)`),Sc=(e,t,n)=>n.path===null&&e.fs.isLink?.(E(e.cwd,t,e.fs,{follow:!1}).path)===!0,Xy=e=>{let t=e.replace(/\/+$/u,"").split("/").at(-1);return t===".."?".":t};function Ec(e,t,n,r=null){let{ctx:o}=n;if(bc(e,o.cwd)||bc(t,o.cwd))throw new b("feature","special file","copying special files is not supported");let i=X(e,o),s=X(t,o);if(n.recursive&&o.fs.isLink?.(E(o.cwd,e,o.fs,{follow:!1}).path)){if(!kc(t,n))throw vc(e);return}let u=P(o,"cp",e),a=d=>Bt(n,"cp: "+d+`
|
|
64
|
+
`,!0);if(u.error)return a(`cannot stat ${i}: ${u.error}`);if(o.fs.isDir(u.path))return n.recursive?Zy(e,u.path,t,n,r??{source:i,target:s},r===null):a(`-r not specified; omitting directory ${i}`);if(r===null){if(n.sources.has(u.path))return Bt(n,`cp: warning: source file ${i} specified more than once
|
|
65
|
+
`,!1,!0);n.sources.add(u.path)}let l=E(o.cwd,t,o.fs);if(l.error&&l.error!=="No such file or directory")return a(`cannot stat ${s}: ${l.error}`);if(n.noClobber&&l.path!==null)return;if(Ac(u.path,l.path,o.fs))return a(`${i} and ${s} are the same file`);if(o.fs.isDir(l.path))return a(`cannot overwrite directory ${s} with non-directory ${i}`);let f=se(o.fs,o.cwd,t);if(r===null&&n.copied.has(f))return a(`will not overwrite just-created ${s} with ${i}`);let c=tt(o.cwd,t,o.fs,l);if($c(i,s,n),Sc(o,t,l))return a(`not writing through dangling symlink ${s}`);if(c)return R(o,"cp",t,c),a(`cannot create regular file ${s}: ${c}`);try{if(!o.fs.copyWritable?.(o.cwd,u.path,t))return a(`${n.force&&l.path!==null?"cannot remove":"cannot create regular file"} ${s}: Read-only file system`)}catch(d){if(O(d))throw d;R(o,"cp",d?.path,d?.fsError);let p=V(d);return a(`cannot create regular file ${s}: ${p.startsWith(t+": ")?p.slice(t.length+2):p}`)}r===null&&n.copied.add(f)}function Zy(e,t,n,r,o,i){let{ctx:s}=r,u=X(e,s),a=X(n,s),l=y=>Bt(r,"cp: "+y+`
|
|
66
|
+
`,!0),f=E(s.cwd,n,s.fs,{follow:!1});if(f.error&&f.error!=="No such file or directory")return l(`cannot stat ${a}: ${f.error}`);let c=n.replace(/\/+$/u,"")||n;if(se(s.fs,s.cwd,c,!0)===t)return l(`${u} and ${a} are the same file`);if(f.path!==null&&!s.fs.isDir(f.path))return l(`cannot overwrite non-directory ${a} with directory ${u}`);let d=se(s.fs,s.cwd,c,!1);if(f.path===null){let y=tt(s.cwd,c,s.fs);if(y)return R(s,"cp",c,y),l(`cannot create directory ${a}: ${y}`);if(!s.writable||!ut(d))return l(`cannot create directory ${a}: Read-only file system`)}if(d.startsWith(t==="/"?"/":t+"/"))return l(`cannot copy a directory, ${o.source}, into itself, ${o.target}`);if(i){if(r.sources.has(t))return Bt(r,`cp: warning: source directory ${u} specified more than once
|
|
67
|
+
`,!1,!0);r.sources.add(t)}i&&Hy(e,n,r);let{dirs:p,files:h,links:m}=s.fs.listDir(t);if(f.path===null&&!Yy(e,n,c,d,r))return;let g=e.replace(/\/+$/u,""),w=n.replace(/\/+$/u,"");for(let y of[...p,...h,...m].sort(j))s.io.setReads([]),Ec(`${g}/${y}`,`${w}/${y}`,r,o)}function Yy(e,t,n,r,o){let{ctx:i}=o,s=X(t,i),u=l=>(Bt(o,"cp: cannot create directory "+s+": "+l+`
|
|
68
|
+
`,!0),!1),a=i.writable&&ut(r);a&&Nc(o);try{if(!a||!i.fs.makeWritableDir?.(i.cwd,n))return u("Read-only file system")}catch(l){if(O(l))throw l;R(i,"cp",l?.path,l?.fsError);let f=V(l);return u(f.startsWith(n+": ")?f.slice(n.length+2):f)}return $c(X(e,i),s,o),!0}function $c(e,t,n){n.verbose&&(Nc(n),Bt(n,`${e} -> ${t}
|
|
69
|
+
`))}function Nc(e){if(e.outputOverlap)throw new b("feature","copy output buffering","buffered verbose output sharing a copied file is not supported")}function Ac(e,t,n){if(e===t)return!0;let r=n.fileIdentity?.(e);return r!==void 0&&r===n.fileIdentity(t)}function Vy(e,t,{recursive:n,noClobber:r}){let o=t.outputFds[1];if(typeof o!="object")return!1;let i={ctx:t,recursive:n,noClobber:r,holds:s=>o.identity===void 0?o.path===s:o.identity===t.fs.fileIdentity?.(s),made:new Set,sources:new Set,copied:new Set};return e.some(([s,u])=>Ky(s,u,i))}function Ky(e,t,n){let{ctx:r}=n,o=E(r.cwd,e,r.fs),i=o.path??Z(r.cwd,e),s=o.error==="No such file or directory"&&(n.made.has(i)||eb(i,n));if(o.error&&!s)return!1;let u=se(r.fs,r.cwd,t);return(o.error===null?r.fs.isDir(o.path):!n.made.has(i))?!n.recursive||!nb(i,t,r)||n.sources.has(i)?!1:(n.sources.add(i),Jy(i,u,n)):n.sources.has(i)||(n.sources.add(i),n.copied.has(u)||!tb(i,u,t,r,n.noClobber))?!1:(n.copied.add(u),n.made.add(u),n.holds(i)||n.holds(u))}function Jy(e,t,n){let{ctx:r}=n,o=e==="/"?0:e.length;for(let i of Qy(e,n)){let s=t+i.slice(o);if(!Oc(i,s,E(r.cwd,s,r.fs),r,n.noClobber)&&(n.made.add(s),n.holds(i)||n.holds(s)))return!0}return!1}function Qy(e,t){let n=e==="/"?"/":e+"/",r=t.ctx.fs.isDir(e)?[...t.ctx.fs.walkFiles(e)]:[];return new Set([...r,...[...t.made].filter(o=>o.startsWith(n))])}var eb=(e,t)=>[...t.made].some(n=>n.startsWith(e+"/"));function Oc(e,t,n,r,o){return n.error&&n.error!=="No such file or directory"||o&&n.path!==null||Ac(e,n.path,r.fs)||r.fs.isDir(n.path)?!0:!r.writable||!ut(t)}function tb(e,t,n,r,o){let i=E(r.cwd,n,r.fs);return!Oc(e,t,i,r,o)&&!Sc(r,n,i)&&!tt(r.cwd,n,r.fs,i)}function nb(e,t,n){let r=E(n.cwd,t,n.fs,{follow:!1});if(r.error&&r.error!=="No such file or directory")return!1;let o=t.replace(/\/+$/u,"")||t;if(r.path!==null&&!n.fs.isDir(r.path)||r.path===null&&tt(n.cwd,o,n.fs))return!1;let i=se(n.fs,n.cwd,o,!1);return se(n.fs,n.cwd,o,!0)===e||i.startsWith(e==="/"?"/":e+"/")?!1:!!n.writable&&ut(i)}function bc(e,t){let n=e.startsWith("/")?e:t+"/"+e;return qy.has(n.replace(/\/\.(?=\/)/gu,"").replace(/\/+/gu,"/"))}function Bt(e,t,n=!1,r=!1){let o=n||r?U(t):{...U(),stdout:t,events:[{fd:1,text:t}]};_(e.result,e.ctx.flushOutput(o)),e.failed||=n}function Cc(e,t,n){let{flags:r,positional:o}=N(t,{short:["f","v","r","R"],long:["force","verbose","recursive"]}),i=r.has("f")||r.has("force"),s=r.has("v")||r.has("verbose"),u=r.has("r")||r.has("R")||r.has("recursive");if(o.length===0)return i?F(""):x("rm: missing operand");let a={ctx:n,force:i,verbose:s,recursive:u,events:[],stdout:"",stderr:""};try{for(let l of o)rb(l,a)}catch(l){R(n,"rm",l?.path,l?.fsError);let f=K(l,"rm","rm: "+V(l));return f.events=[...a.events,{fd:2,text:f.stderr}],f.stdout=a.stdout,f.stderr=a.stderr+f.stderr,f}return{stdout:a.stdout,stderr:a.stderr,events:a.events,exitCode:a.stderr?1:0}}function rb(e,t){let{ctx:n}=t,r=E(n.cwd,e,n.fs,{follow:!1}),o=r.error;if(!(t.force&&(o==="No such file or directory"||o==="Not a directory"))){if(R(n,"rm",e,o),o===null&&n.fs.isDir(r.path))if(!t.recursive)o="Is a directory";else{if([".",".."].includes(e.replace(/\/+$/u,"").split("/").at(-1)))return ks(t,`rm: refusing to remove '.' or '..' directory: skipping ${X(e,n)}
|
|
70
|
+
`);if(r.path==="/tmp")o="Device or resource busy";else if(!n.writable||!ut(r.path))o="Read-only file system";else return Ic(e,r.path,t,ob(n,e)?"Not a directory":null)}xs(e,r.path,t,!1,o)}}function ob(e,t){let n=t.replace(/\/+$/u,"");return n===t||n===""?!1:e.fs.isLink?.(E(e.cwd,n,e.fs,{follow:!1}).path)===!0}function Ic(e,t,n,r=null){let{ctx:o}=n,{dirs:i,files:s,links:u=[]}=o.fs.listDir(t),a=e.replace(/\/+$/u,"");for(let l of[...i,...s,...u].sort(j)){let f=Te(t,l);o.fs.isDir(f)?Ic(`${a}/${l}`,f,n):xs(`${a}/${l}`,f,n,!1,null)}xs(e,t,n,!0,r)}function xs(e,t,n,r,o){let{ctx:i}=n,s=n.verbose||o!==null||!i.writable||!t?.startsWith("/tmp/")?X(e,i):"",u=()=>r?i.fs.removeWritableDir?.(i.cwd,e):i.fs.removeWritable?.(i.cwd,e);try{o===null&&!u()&&(o="Read-only file system")}catch(a){if(O(a))throw a;R(i,"rm",a?.path,a?.fsError);let l=V(a);o=a?.fsError??(l.startsWith(e+": ")?l.slice(e.length+2):l)}if(o)return ks(n,`rm: cannot remove ${s}: ${o}
|
|
71
|
+
`);n.verbose&&ks(n,`removed ${r?"directory ":""}${s}
|
|
72
|
+
`,1)}function ks(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Fc(e,t,n){let{flags:r,positional:o}=N(t,{short:["p","v"],long:["parents","verbose"]});if(o.length===0)return x("mkdir: missing operand");let i={ctx:n,events:[],stdout:"",stderr:"",parents:r.has("p")||r.has("parents"),verbose:r.has("v")||r.has("verbose")};try{for(let s of o)i.parents?ib(s,i):vs(s,i,!0)}catch(s){R(n,"mkdir",s?.path,s?.fsError);let u=K(s,"mkdir","mkdir: "+V(s));return u.events=[...i.events,{fd:2,text:u.stderr}],u.stdout=i.stdout,u.stderr=i.stderr+u.stderr,u}return{stdout:i.stdout,stderr:i.stderr,events:i.events,exitCode:i.stderr?1:0}}function ib(e,t){let n=e.split("/"),r=[];for(let o=0;o<n.length;o++)n[o]!==""&&r.push(n.slice(0,o+1).join("/"));if(r.length===0){e===""&&vs(e,t,!0);return}r[r.length-1]=e;for(let[o,i]of r.entries())if(!vs(i,t,o===r.length-1))return}function vs(e,t,n){let{ctx:r}=t,o=X(e,r),i=l=>(Tc(t,`mkdir: cannot create directory ${o}: ${l}
|
|
73
|
+
`),!1),s=e.replace(/\/+$/u,"")||e,u=E(r.cwd,s,r.fs);if(u.error===null)return t.parents?r.fs.isDir(u.path)?!0:i(n?"File exists":"Not a directory"):i("File exists");if(E(r.cwd,s,r.fs,{follow:!1}).error===null)return i(!t.parents||n||u.error!=="Not a directory"?"File exists":"Not a directory");let a=tt(r.cwd,s,r.fs,u);if(a)return R(r,"mkdir",s,a),i(a);try{if(!r.fs.makeWritableDir?.(r.cwd,s))return i("Read-only file system")}catch(l){if(O(l))throw l;R(r,"mkdir",l?.path,l?.fsError);let f=V(l);return i(f.startsWith(s+": ")?f.slice(s.length+2):f)}return t.verbose&&Tc(t,`mkdir: created directory ${o}
|
|
74
|
+
`,1),!0}function Tc(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Lc(e,t,n){let{flags:r,positional:o}=N(t,{short:["c"],long:["no-create"]});if(o.length===0)return x("touch: missing file operand");let i=r.has("c")||r.has("no-create"),s={ctx:n,stderr:"",failed:!1,gap:null};for(let a of o)sb(a,i,s);let u={stdout:"",stderr:s.stderr,exitCode:s.failed?1:0};return s.gap?ie(u,"feature","touch","times",s.gap):u}function sb(e,t,n){let{ctx:r}=n,o=X(e,r),i=E(r.cwd,e,r.fs);if(i.error===null)return ub(e,o,i.path,n);let s=t||e.endsWith("/");if(t&&i.error==="No such file or directory")return;if(R(r,"touch",e,i.error),s)return Zn(n,`setting times of ${o}: ${i.error}`);let u=tt(r.cwd,e,r.fs,i);if(u)return Zn(n,`cannot touch ${o}: ${u}`);try{r.fs.openWritable?.(r.cwd,e,!0)||Zn(n,`cannot touch ${o}: Read-only file system`)}catch(a){if(O(a))throw a;R(r,"touch",a?.path,a?.fsError);let l=V(a);Zn(n,`cannot touch ${o}: ${l.startsWith(e+": ")?l.slice(e.length+2):l}`)}}function ub(e,t,n,r){let{ctx:o}=r;if(!o.writable||!ut(n))return Zn(r,`setting times of ${t}: Read-only file system`);let i=`touch: setting the times of ${t} is not supported (every entry here carries the one time this filesystem keeps)`;r.gap??=i,r.stderr+=i+`
|
|
75
|
+
`,r.failed=!0}function Zn(e,t){e.stderr+=`touch: ${t}
|
|
76
|
+
`,e.failed=!0}function Yn(e,t,n,r){if(t===""||t.includes("\0"))return{error:"No such file or directory"};if(r==="none")return ab(e,t,n);let o=t;if(r==="logical"){let s=n==="m"?{path:Z(e.cwd,t)}:Mc(e,t);if(s.error)return s;o=s.path+(t.endsWith("/")?"/":"")}let i=ze(e.cwd,o,e.fs,{lenient:n==="m"});return n==="m"?{path:i.rest.length?Z(i.path,i.rest.join("/")):i.path}:i.error==="No such file or directory"&&i.rest.length===0&&n!=="e"?{path:i.path}:i.error?{error:i.error}:t.endsWith("/")&&!e.fs.isDir(i.path)?{error:"Not a directory"}:{path:i.path}}function ab(e,t,n){if(n==="m")return{path:Z(e.cwd,t)};let r=Mc(e,t);if(r.error||n!=="e")return r;let o=E("/",r.path,e.fs);return o.error?{error:o.error}:r}function Mc(e,t){let n=(t.startsWith("/")?t:e.cwd+"/"+t).split("/").filter(Boolean),r="/";for(let o=0;o<n.length;o++){let i=n[o];if(i==="..")r=ye(r);else if(i!=="."){r=Te(r,i);let s=o+1;for(;n[s]===".";)s++;let u=n[s]===".."||s===n.length&&(o<n.length-1||t.endsWith("/"));if(u||o===n.length-1){let a=E("/",r+(u?"/":""),e.fs);if(a.error&&!(a.error==="No such file or directory"&&o===n.length-1))return a}}}return{path:r}}function Ss(e,t){let n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o++;return[...n.slice(o).map(()=>".."),...r.slice(o)].join("/")||"."}var Pc=(e,t)=>e==="/"||t===e||t.startsWith(e+"/"),_c={e:"e","canonicalize-existing":"e",m:"m","canonicalize-missing":"m"},Rc={P:"physical",physical:"physical",L:"logical",logical:"logical",s:"none",strip:"none","no-symlinks":"none"};function lb(e,t,n,r){let o=t.get("relative-base"),i=t.get("relative-to")??o,s={};for(let[u,a]of[["target",i],["base",o]]){if(a===void 0)continue;let l=Yn(e,a,n,r),f=l.error??(n==="e"&&!e.fs.isDir(l.path)?"Not a directory":null);if(f)return R(e,"realpath",a,f),{error:x(`realpath: ${oe(a,e)}: ${f}`)};s[u]=l.path}return s.base&&!Pc(s.base,s.target)&&delete s.target,s}function Dc(e,t,n){let{flags:r,values:o,positional:i,order:s}=N(t,{short:["e","m","L","P","s","q","z"],long:["canonicalize-existing","canonicalize-missing","logical","physical","strip","no-symlinks","quiet","zero"],valueLong:["relative-to","relative-base"]});if(!i.length)return x("realpath: missing operand");let u="physical",a="E";for(let{name:h}of s)Object.hasOwn(_c,h)&&(a=_c[h]),Object.hasOwn(Rc,h)&&(u=Rc[h]);let l=lb(n,o,a,u);if(l.error)return l.error;let f=r.has("q")||r.has("quiet"),c=r.has("z")||r.has("zero")?"\0":`
|
|
77
|
+
`,d=U(),p=!1;for(let h of i){let m=Yn(n,h,a,u);if(m.error)R(n,"realpath",h,m.error),f||_(d,x(`realpath: ${oe(h,n)}: ${m.error}`)),p=!0;else{let g=l.target&&(!l.base||Pc(l.base,m.path))?Ss(l.target,m.path):m.path;_(d,F(g+c))}}return d.exitCode=p?1:0,d}var ao={symbolic:"s",force:"f","no-dereference":"n","no-target-directory":"T",verbose:"v",relative:"r",logical:"L",physical:"P"};function Uc(e,t,n){let r=N(t,{short:Object.values(ao),long:Object.keys(ao),valueShort:["t"],valueLong:["target-directory"]}),o=l=>r.flags.has(l)||r.flags.has(Object.keys(ao).find(f=>ao[f]===l)),i={force:o("f"),noDereference:o("n"),noTargetDirectory:o("T"),verbose:o("v"),relative:o("r")},s=r.order.findLast(({name:l})=>l==="t"||l==="target-directory")?.value??null,u=r.positional;if(s!==null&&i.noTargetDirectory)return x("ln: cannot combine --target-directory and --no-target-directory");if(i.relative&&!o("s"))return x("ln: cannot do --relative without --symbolic");if(u.length===0)return x("ln: missing file operand");if(!o("s"))return v("feature","ln","hard link",`ln: hard links are not supported: ${X(u[0],n)} (ln -s makes a symbolic one)`);let a={ctx:n,events:[],stdout:"",stderr:""};try{let l=fb(u,s,i,n);if(l.error)return l.error;for(let[f,c,d]of l)cb(f,c,i,a,d)}catch(l){R(n,"ln",l?.path,l?.fsError);let f=K(l,"ln","ln: "+V(l));return f.events=[...a.events,{fd:2,text:f.stderr}],f.stdout=a.stdout,f.stderr=a.stderr+f.stderr,f}return{stdout:a.stdout,stderr:a.stderr,events:a.events,exitCode:a.stderr?1:0}}function fb(e,t,n,r){let o=a=>X(a,r);if(t!==null){let a=E(r.cwd,t,r.fs);return a.error?(R(r,"ln",t,a.error),{error:x(`ln: failed to access ${o(t)}: ${a.error}`)}):r.fs.isDir(a.path)?e.map(l=>Es(t,l)):{error:x(`ln: target ${o(t)} is not a directory`)}}if(e.length===1)return n.noTargetDirectory?{error:x(`ln: missing destination file operand after ${o(e[0])}`)}:[Es(".",e[0])];if(e.length===2){let a=E(r.cwd,e[1],r.fs,{follow:!n.noDereference});if(n.noTargetDirectory||a.error!==null||!r.fs.isDir(a.path))return[[e[0],e[1]]]}if(n.noTargetDirectory)return{error:x(`ln: extra operand ${o(e[2])}`)};let i=e.at(-1),s=E(r.cwd,i,r.fs),u=s.error??(r.fs.isDir(s.path)?null:"Not a directory");return u?(R(r,"ln",i,u),{error:x(`ln: target ${o(i)}: ${u}`)}):e.slice(0,-1).map(a=>Es(i,a))}function Es(e,t){let n=t.replace(/\/+$/u,"").split("/").at(-1);return[t,e+(e.endsWith("/")?"":"/")+n,n===""]}function cb(e,t,n,r,o=!1){let{ctx:i}=r,s=X(t,i),u=n.relative?pb(i,e,t):e,a=f=>$s(r,`ln: failed to create symbolic link ${s}${f}
|
|
78
|
+
`);if(u==="")return a(` -> ${X(u,i)}: No such file or directory`);if(o)return a(": No such file or directory");if(n.force){let f=E(i.cwd,t,i.fs,{follow:!1});if(f.error===null){if(i.fs.isDir(f.path))return $s(r,`ln: ${oe(t,i)}: cannot overwrite directory
|
|
79
|
+
`);try{if(!i.fs.removeWritable?.(i.cwd,t))return a(": Read-only file system")}catch(c){if(O(c))throw c;return a(`: ${Bc(c,t)}`)}}}let l=db(i,t);if(l)return R(i,"ln",t,l),a(`: ${l}`);try{if(!i.fs.makeWritableLink?.(i.cwd,t,u))return a(": Read-only file system")}catch(f){if(O(f))throw f;return R(i,"ln",f?.path,f?.fsError),a(`: ${Bc(f,t)}`)}n.verbose&&$s(r,`${s} -> ${X(u,i)}
|
|
80
|
+
`,1)}function db(e,t){if(t===""||t.includes("\0"))return"No such file or directory";let n=t.replace(/\/+$/u,"");if(n==="")return"File exists";let r=E(e.cwd,n,e.fs,{follow:!1});if(r.error===null)return"File exists";if(r.error!=="No such file or directory"||t!==n)return r.error;let o=ze(e.cwd,n,e.fs);return o.rest.length>0?o.error:null}function pb(e,t,n){let r=Yn(e,ye(n),"m","physical"),o=Yn(e,t,"m","physical");return r.error||o.error?t:Ss(r.path,o.path)}function Bc(e,t){let n=V(e);return e?.fsError??(n.startsWith(t+": ")?n.slice(t.length+2):n)}function $s(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}var jc={cp:xc,rm:Cc,mkdir:Fc,touch:Lc,ln:Uc};function hb(e,t,n){let{positional:r}=N(t),o=te("tac",r,e,n),i=[];for(let{content:s}of o.inputs)i.push(...Ge(s).toReversed());return ne(i.join(""),o)}var Wc=1e6;function mb(e,t){let{flags:n,values:r,positional:o}=N(t,{short:["w"],valueShort:["s"],numericOperands:!0});if(o.length===0||o.length>3)return pe("seq [-w] [-s SEP] LAST | seq FIRST LAST | seq FIRST INCR LAST");let i=[];for(let p of o){if(!/^[+-]?\d+$/u.test(p))return Number.isFinite(Number(p))&&p.trim()!==""||/^[+-]?inf(?:inity)?$/iu.test(p)?v("feature","seq","non-integer operands","seq: non-integer operands are not supported"):x(`seq: invalid integer: ${p}`);i.push(BigInt(p))}let s=i.length===1?1n:i[0],u=i.length===3?i[1]:1n,a=i.at(-1);if(u===0n)return x("seq: increment must be non-zero");let f=(u>0?s<=a:s>=a)?(a>s?a-s:s-a)/(u>0n?u:-u)+1n:0;if(f>Wc)return v("feature","seq","sequence limit",`seq: range too large: ${f} elements exceeds limit of ${Wc}`);let c=n.has("w")?Math.max(...[o[0],o.at(-1)].map(p=>p.replace(/^\+/u,"").length)):0,d=[];for(let p=0,h=s;p<f;p++,h+=u)d.push(gb(String(h),c));return F(d.length===0?"":d.join(r.get("s")??`
|
|
74
81
|
`)+`
|
|
75
|
-
`)}function gb(e,t){if(e.length>=t)return e;let n=e.startsWith("-"),r=n?e.slice(1):e;return(n?"-":"")+r.padStart(t-(n?1:0),"0")}var
|
|
76
|
-
`,exitCode:1};l.push(`${String(u).padStart(
|
|
77
|
-
`?d===""?[]:[d]:
|
|
78
|
-
`?
|
|
79
|
-
`:
|
|
80
|
-
`)}function
|
|
81
|
-
`)}var
|
|
82
|
-
`,t:" ","%":"%"};return t.replace(/%./gu,p=>{let h=d[p[1]];return typeof h=="function"?h():h??p})}function
|
|
83
|
-
`}if(
|
|
84
|
-
`),!r.scale){let
|
|
82
|
+
`)}function gb(e,t){if(e.length>=t)return e;let n=e.startsWith("-"),r=n?e.slice(1):e;return(n?"-":"")+r.padStart(t-(n?1:0),"0")}var zc=6,Hc=" ",wb=" ".repeat(zc+Hc.length);function yb(e,t,n){let{values:r,positional:o,order:i}=N(t,{valueShort:["b","v"],valueLong:["starting-line-number"]}),s=r.get("b")??"t";if(!["a","t","n"].includes(s)){let f=`nl: -b: only \`a\`, \`t\` and \`n\` are supported (got \`${s}\`)`;return s.startsWith("p")?v("option","nl","-b p",f):x(f)}let u=1n;for(let{name:f,value:c}of i)if(!(f!=="v"&&f!=="starting-line-number")){if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(c))return x(`nl: invalid starting line number: ${c}`);if(u=BigInt(c),u<ot||u>ue)return x(`nl: invalid starting line number: ${c}`)}let a=te("nl",o,e,n);if(a.inputs.some(({content:f})=>/(?:^|\n)(?:\\:){1,3}(?:\n|$)/u.test(f)))return v("feature","nl","logical pages","nl: logical page delimiters are not supported");let l=[];for(let{content:f}of a.inputs)for(let c of he(f))if(s==="a"||s==="t"&&c!==""){if(u>ue)return{stdout:ge(l),stderr:a.stderr+`nl: line number overflow
|
|
83
|
+
`,exitCode:1};l.push(`${String(u).padStart(zc)}${Hc}${c}`),u++}else l.push(wb+c);return ne(ge(l),a)}function bb(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["s"],valueShort:["d","f","c"]}),s=o.has("f"),u=o.has("c");if(s===u)return pe("cut -f LIST [-d DELIM] [-s] [file...] | cut -c LIST [file...]");if(u&&o.has("d"))return x("cut: -d is only valid with -f");if(u&&r.has("s"))return x("cut: -s is only valid with -f");let a=Sb(s?o.get("f"):o.get("c"),s?"field":"position");if(a.error)return a.error;let l=o.get("d")===""?"\0":o.get("d")??" ";if(s&&A(l).length!==1)return x("cut: -d delimiter must be a single byte");let f=te("cut",i,e,n),c=[];for(let{content:d}of f.inputs)for(let p of s&&l===`
|
|
84
|
+
`?d===""?[]:[d]:he(d)){if(s&&!p.includes(l)){r.has("s")||c.push(p);continue}c.push(s?Eb(p,l,a.ranges):xb(p,a.ranges))}return ne(ge(c),f)}function xb(e,t){let n=A(e);return W(Uint8Array.from(Gc(n,t)))}var kb={field:{zero:"fields are numbered from 1",range:"invalid field range",value:e=>`invalid field value '${e}'`,large:e=>`field number '${e}' is too large`},position:{zero:"byte/character positions are numbered from 1",range:"invalid byte or character range",value:e=>`invalid byte/character position '${e}'`,large:e=>`byte/character offset '${e}' is too large`}},vb=/^(\d*)(-?)(\d*)/u;function Sb(e,t){let n=kb[t],r=s=>({error:x(`cut: ${s}`)}),o=[];for(let s of e.split(/[, \t]/u)){if(s==="")return r(n.zero);let[u,a,l,f]=vb.exec(s),c=s.slice(u.length);if(c!=="")return r(c.startsWith("-")?n.range:n.value(c));for(let h of[a,f])if(h!==""&&BigInt(h)>it)return r(n.large(h));if(a===""&&f===""&&l==="")return r(n.value(s));let d=a===""?1:Number(a),p=l===""?d:f===""?1/0:Number(f);if(d<1)return r(n.zero);if(p<d)return r("invalid decreasing range");o.push([d,p])}o.sort((s,u)=>s[0]-u[0]);let i=[];for(let s of o){let u=i.at(-1);u&&s[0]<=u[1]+1?u[1]=Math.max(u[1],s[1]):i.push(s)}return{ranges:i}}function Gc(e,t){return t.flatMap(([n,r])=>Array.from(e.slice(n-1,r)))}function Eb(e,t,n){let r=t===`
|
|
85
|
+
`?he(e):e.split(t);return Gc(r,n).join(t)}function $b(e,t,n){let{flags:r,positional:o}=N(t,{short:["c","d","s"]}),i=r.has("d"),s=r.has("s"),u=r.has("c");if(i&&s)return v("option","tr","-d -s","tr: -d combined with -s is not supported");if(s&&!i&&o.length===2)return v("feature","tr","translate and squeeze","tr: combined translation and squeezing is not supported");let a=i||s?1:2;if(o.length!==a)return pe("tr [-c] SET1 SET2 | tr [-c] -d SET | tr [-c] -s SET");if(/\P{ASCII}/u.test(e+o.join("")))return v("feature","tr","non-ASCII bytes","tr: translation of non-ASCII bytes is not supported");if(o.some(g=>/\[[:.=]|\[[^\]]*\*/u.test(g)))return v("feature","tr","set expressions","tr: character classes, equivalence classes and repetition expressions are not supported");if(o.some(g=>/\\[0-7]{2}|\\[1-7abfrv]/u.test(g)))return v("feature","tr","set escapes","tr: these set escape sequences are not supported");if(o.some(g=>/(?:^|[^\\])(?:\\\\)*\\$/u.test(g)))return v("feature","tr","trailing backslash","tr: an unescaped trailing backslash in a set is not supported");let l=qc(o[0]);if(l.error)return l.error;let f=new Set(l.chars),c=g=>u!==f.has(g);if(i)return q(n),F([...e].filter(g=>!c(g)).join(""));if(s)return q(n),F(Nb(e,c));let d=qc(o[1]);if(d.error)return d.error;if(d.chars.length===0)return x("tr: when not truncating set1, string2 must be non-empty");q(n);let p=u?Array.from({length:256},(g,w)=>String.fromCodePoint(w)).filter(g=>!f.has(g)):l.chars,h=new Map,m=d.chars.at(-1);for(let g=0;g<p.length;g++)h.set(p[g],d.chars[g]??m);return F([...e].map(g=>h.get(g)??g).join(""))}function qc(e){let t=[],n=0,r=()=>{if(e[n]!=="\\")return e[n++];if(n+1>=e.length)return null;let o=e[n+1];return n+=2,o==="n"?`
|
|
86
|
+
`:o==="t"?" ":o==="\\"?"\\":o==="0"?"\0":o};for(;n<e.length;){let o=r();if(e[n]==="-"&&n+1<e.length){n++;let i=r();if(i===null)return{error:x("tr: trailing backslash in set")};let s=o.codePointAt(0),u=i.codePointAt(0);if(u<s)return{error:x(`tr: range-endpoints of '${o}-${i}' are in reverse collating sequence order`)};for(let a=s;a<=u;a++)t.push(String.fromCodePoint(a))}else t.push(o)}return{chars:t}}function Nb(e,t){let n="",r=null;for(let o of e)t(o)&&o===r||(n+=o,r=o);return n}function Ab(e,t,n){let{positional:r}=N(t);if(r.length===0)return pe("which COMMAND...");let o=[],i=0;for(let s of r)n.hasCommand(s)?o.push(`/usr/bin/${s}`):(o.push(`${s} not found`),i=1);return{stdout:ge(o),stderr:"",exitCode:i}}function Ob(e,t,n){let{positional:r}=N(t);return r.length>0?x(`whoami: extra operand: ${r[0]}`):F((n.user??"user")+`
|
|
87
|
+
`)}function Cb(e,t,n){let{flags:r,positional:o}=N(t,{short:["u"]});if(o.length>1)return x(`date: at most one +FORMAT argument is supported (got: ${o[1]})`);let i="%a %b %e %T %Z %Y";if(o.length===1){if(!o[0].startsWith("+"))return pe("date [-u] [+FORMAT]");i=o[0].slice(1)}return(i.match(/%./gu)??[]).some(s=>/%[-_0^#0-9:EOcCDgGhIjklNpPrRuUVwWxXy+]/u.test(s))?v("feature","date","format","date: this format directive or modifier is not supported"):F(Ns(new Date,i,r.has("u")||n.vars.has("TZ"))+`
|
|
88
|
+
`)}var Ib=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Tb=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Fb=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Lb=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ns(e,t,n){let r="get"+(n?"UTC":""),[o,i,s,u,a,l,f]=["FullYear","Month","Date","Hours","Minutes","Seconds","Day"].map(p=>e[r+p]()),c=(p,h="0")=>String(p).padStart(2,h),d={__proto__:null,Y:String(o),m:c(i+1),d:c(s),e:c(s," "),H:c(u),M:c(a),S:c(l),T:[u,a,l].map(p=>c(p)).join(":"),F:[o,c(i+1),c(s)].join("-"),q:String(Math.floor(i/3)+1),s:String(Math.floor(e.getTime()/1e3)),a:Ib[f],A:Tb[f],b:Fb[i],B:Lb[i],Z:()=>_b(e,n),z:()=>Rb(e,n),n:`
|
|
89
|
+
`,t:" ","%":"%"};return t.replace(/%./gu,p=>{let h=d[p[1]];return typeof h=="function"?h():h??p})}function _b(e,t){if(t)return"UTC";try{return new Intl.DateTimeFormat("en-US",{timeZoneName:"short"}).formatToParts(e).find(o=>o.type==="timeZoneName")?.value??"Local"}catch{return"Local"}}function Rb(e,t){if(t)return"+0000";let n=-e.getTimezoneOffset(),r=n>=0?"+":"-",o=Math.abs(n);return`${r}${String(Math.floor(o/60)).padStart(2,"0")}${String(o%60).padStart(2,"0")}`}var Xc={rg:wc,cut:bb,tac:hb,tr:$b,seq:mb,nl:yb,which:Ab,hexdump:lf,base64:vf,...jc},Zc={whoami:Ob,date:Cb,od:ff,xxd:cf,base32:kf,...of};var As=new Map(Object.entries({all:"a","apparent-size":"A",bytes:"b",total:"c",null:"0","count-links":"l",summarize:"s","separate-dirs":"S","human-readable":"h","max-depth":"d","block-size":"B",dereference:"L","dereference-args":"D","no-dereference":"P"})),Yc={P:"none",D:"args",H:"args",L:"all"};function Kc(e,t){let n=N(e,{short:["0","a","A","b","c","h","H","k","l","m","s","S","L","D","P"],long:[...As.keys()].filter(i=>!["d","B"].includes(As.get(i))).concat(["inodes","si"]),valueShort:["d","B"],valueLong:["max-depth","block-size"]}),r={operands:n.positional.length?n.positional:["."],depth:1/0,flags:new Set,links:"none",scale:null,stderr:""};for(let{name:i,value:s}of n.order){let u=As.get(i)??i;r.flags.add(u),Object.hasOwn(Yc,u)&&(r.links=Yc[u]),u==="d"&&(r.depth=Mb(s)),u==="B"&&(r.scale=Vc(s)),u==="b"&&(r.flags.add("A"),r.scale={unit:1n}),(u==="k"||u==="m")&&(r.scale={unit:u==="k"?1024n:1024n**2n}),(u==="h"||u==="si")&&(r.scale={base:u==="h"?1024n:1000n,unit:1n})}let{flags:o}=r;if(o.has("a")&&o.has("s"))throw new Error("cannot both summarize and show all entries");if(o.has("s")&&o.has("d")){if(r.depth!==0)throw new Error(`summarizing conflicts with --max-depth=${r.depth}`);r.stderr+=`du: warning: summarizing is the same as using --max-depth=0
|
|
90
|
+
`}if(o.has("s")&&(r.depth=0),o.has("inodes")&&o.has("A")&&(r.stderr+=`du: warning: options --apparent-size and -b are ineffective with --inodes
|
|
91
|
+
`),!r.scale){let i=t.vars.get("DU_BLOCK_SIZE")??t.vars.get("BLOCK_SIZE")??t.vars.get("BLOCKSIZE");try{r.scale=i===void 0?{unit:t.vars.has("POSIXLY_CORRECT")?512n:1024n}:Vc(i)}catch(s){throw s instanceof b?s:new b("feature","invalid block size environment","invalid block size environment settings are not supported")}}return o.has("inodes")&&(r.scale={...r.scale,unit:1n,suffix:r.scale.suffix?.endsWith("B")?"B":""}),r.scale.base&&Cs(t,r.scale.base),r}function Cs(e,t=1024n){let n=e.vars.get("LC_ALL")||e.vars.get("LC_NUMERIC")||e.locale;if(!/^(?:C|POSIX|C\.UTF-?8)$/iu.test(n))throw new b("feature","numeric locale","human-readable sizes in this numeric locale are not supported");return{base:t,unit:1n}}function Mb(e){let t=/^[ \t\n\r\v\f]*([+-]?)(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.exec(e);if(!t)throw new Error(`invalid maximum depth: ${e}`);let n=Jc(t[2]);if(n>ue||t[1]==="-"&&n!==0n)throw new Error(`invalid maximum depth: ${e}`);return Number(n)}function Jc(e){return BigInt(/^0[0-7]+$/u.test(e)?"0o"+e:e)}function Vc(e){let t=e&&["human-readable","si"].find(a=>a.startsWith(e));if(t)return{base:t==="si"?1000n:1024n,unit:1n};if(e.startsWith("'"))throw new b("feature","grouped block sizes","grouped block sizes are not supported");let n=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)?([kKmMgGtTPEZYRQ](?:i?B|D)?)?$/u.exec(e);if(!n||!n[1]&&e!==n[2])throw new Error(`invalid block size: ${e}`);let r=n[2]??"",o=r?"KMGTPEZYRQ".indexOf(r[0].toUpperCase())+1:0,i=/[BD]$/u.test(r)&&!r.endsWith("iB")?1000n:1024n,s=(n[1]?Jc(n[1]):1n)*i**BigInt(o);if(s===0n||s>it)throw new Error(`invalid block size: ${e}`);let u=n[1]||!r?"":(o===1&&r.endsWith("B")&&i===1000n?"k":r[0].toUpperCase())+(r.endsWith("B")?i===1000n?"B":"iB":"");return{unit:s,suffix:u}}var Vn=4096,Pb=60,lo=(e,t)=>t==="dir"?Vn:t==="link"&&e<Pb?0:Math.ceil(e/Vn)*Vn,Os=(e,t)=>(e+t-1n)/t;function Kn(e,{base:t,unit:n,suffix:r=""}){if(!t)return String(Os(e,n))+r;let o=1n,i=0;for(;e>=o*t;)o*=t,i++;if(!i)return String(e);let s=Os(e*10n,o),u;return s<100n?u=`${s/10n}.${s%10n}`:(s=Os(e,o),s===t?(i++,u="1.0"):u=String(s)),u+(i===1&&t===1000n?"k":"KMGTPEZYRQ"[i-1])}var Db=31556952*1e3/2;function Qc(e,t){for(let f of["LS_BLOCK_SIZE","BLOCK_SIZE","BLOCKSIZE"])if(e.vars.has(f))throw new b("feature","block size environment",`${f} is not supported in a long listing`);let n=t?Cs(e):null,r=e.user??"user",o=e.createdAt,i=Date.now(),s=o<=i&&i-o<Db,u=Ns(new Date(o),s?"%b %e %H:%M":"%b %e %Y",e.vars.has("TZ")),a=f=>n?Kn(BigInt(f),n):String(f),l=f=>Math.max(0,...f.map(c=>c.length));return{lines(f,c){let d=f.map(({name:g,abs:w,kind:y,target:k})=>{let S=y==="dir",I=S?Vn:e.fs.fileSize(w)??B(e.fs.readFile(w)).length,M=S?"drwx------":y==="link"?"lrwxrwxrwx":"-rw-------",C=lo(I,y)/512;return{name:y==="link"?`${g} -> ${k}`:g,mode:M,units:C,links:String(S?2+e.fs.listDir(w).dirs.length:1),size:a(I)}}),p=l(d.map(g=>g.links)),h=l(d.map(g=>g.size)),m=d.map(g=>`${g.mode} ${g.links.padStart(p)} ${r} ${r} ${g.size.padStart(h)} ${u} ${g.name}`);if(c){let g=d.reduce((w,y)=>w+y.units,0);m.unshift("total "+(n?Kn(BigInt(g)*512n,n):String(g/2)))}return m}}}function ed(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["a","d","F"],long:["noreport"],valueShort:["L"]});if(i.length>1)return v("feature","tree","multiple roots","tree: multiple roots are not supported");let s=o.has("L")?be(o.get("L"),"tree: -L",o.get("L"),{max:2147483647}):{value:Number.POSITIVE_INFINITY};if(s.error)return s.error;if(!s.value)return x("tree: -L must be greater than zero");let u=i[0]??".",{path:a,error:l}=P(n,"tree",u),f=!l&&n.fs.isDir(a),c=E(n.cwd,u,n.fs,{follow:!1}),d=!!l&&!!c.error,p={dirs:f&&fo(n.fs,a,r).length?1:0,files:!d&&!f?1:0},h=[u+Bb(n,r,c,f)+(f?"":" [error opening dir]")];if(f){let m=new Set,g=Jt();try{let w=Ub(n.fs,a,h,r,s.value,p,m,g);if(w)return w}finally{gt(n.notes,{command:"tree",action:"depth limit omitted contents of",noun:["directory","directories"],paths:m}),g.emit(n.notes,"tree","Hidden entries are included with -a.")}}if(!r.has("noreport")){let m=`${p.dirs} ${p.dirs===1?"directory":"directories"}`,g=`${p.files} ${p.files===1?"file":"files"}`;h.push("",r.has("d")?m:`${m}, ${g}`)}return{stdout:h.join(`
|
|
85
92
|
`)+`
|
|
86
|
-
`,stderr:"",exitCode:d?2:0}}function
|
|
87
|
-
`))),l.exitCode=1;continue}let h=new Set;for(let m of
|
|
88
|
-
`:"\0"),stderr:"",exitCode:0})),!0):e.mode==="batch"?(e.collected.push(t.path),!0):
|
|
89
|
-
`,set:!0}:e==="PWD"?{value:t.cwd,set:!0}:e==="HOME"?{value:t.home,set:!0}:e==="USER"||e==="LOGNAME"?{value:t.user,set:!0}:e==="LANG"?{value:t.locale,set:!0}:null}function
|
|
90
|
-
`),e.unsupported.add({kind:"feature",command:null,detail:t,message:n})}var
|
|
91
|
-
`;)
|
|
92
|
-
`;)f+=2;if(!
|
|
93
|
+
`,stderr:"",exitCode:d?2:0}}function Bb(e,t,n,r){return t.has("F")?!n.error&&e.fs.isLink?.(n.path)===!0?"@":r&&!t.has("d")?"/":"":""}function Ub(e,t,n,r,o,i,s,u){let a=[{dir:t,prefix:"",items:fo(e,t,r,u),i:0,depth:0}];for(;a.length;){let l=a.at(-1);if(l.i>=l.items.length){a.pop();continue}let{n:f,isDir:c,target:d}=l.items[l.i++];if([...f+(d??"")].some(w=>w.codePointAt(0)<32||w.codePointAt(0)===127||w==="\\"))return v("feature","tree","filename escaping","tree: listing names requiring escaping is not supported");let p=l.i===l.items.length,h=c&&r.has("F")&&!r.has("d")?"/":"";if(n.push(l.prefix+(p?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+f+(d===void 0?h:" -> "+d+h)),i[c?"dirs":"files"]++,!c||d!==void 0)continue;let m=Te(l.dir,f);if(l.depth+1>=o){fo(e,m,r).length&&s.add(m);continue}let g=fo(e,m,r,u);a.push({dir:m,prefix:l.prefix+(p?" ":"\u2502\xA0\xA0 "),items:g,i:0,depth:l.depth+1})}}function fo(e,t,n,r=null){let{dirs:o,files:i,links:s}=e.listDir(t),u=s.map(l=>{let f=E(t,l,e);return{n:l,isDir:!f.error&&e.isDir(f.path),target:e.readLink(Te(t,l))}}),a=n.has("d")?u.filter(({isDir:l})=>l):[...i.map(l=>({n:l,isDir:!1})),...u];return r&&!n.has("a")&&r.collect(t,[...o,...a.map(({n:l})=>l)]),[...o.map(l=>({n:l,isDir:!0})),...a].filter(({n:l})=>n.has("a")||!l.startsWith(".")).sort((l,f)=>j(l.n,f.n))}var jb=new Set(["name","iname","type","path","ipath","mindepth","maxdepth"]),Jn=(e,t)=>e==="-"+t||e==="--"+t;function nd(e){let t={tokens:e,i:0,depth:{minDepth:0,maxDepth:Number.POSITIVE_INFINITY},hasAction:!1,batches:[],error:null},n=[];for(e[0]==="--"&&t.i++;t.i<e.length&&!/^(?:-.+|!|\()$/u.test(e[t.i]);)n.push(e[t.i++]);let r=rd(t,0);if(t.error)return{error:t.error};if(!t.hasAction)for(let o of r)o.push({kind:"print"});return{starts:n.length?n:["."],...t.depth,groups:r,batches:t.batches}}function rd(e,t){let n=[[]],r=!1;if(t>128)return e.error=v("feature","find","expression depth","find: expression nesting above 128 is not supported"),n;for(;e.i<e.tokens.length&&!e.error;){let o=e.tokens[e.i];if(o===")"){t||(e.error=x("find: unexpected closing parenthesis"));break}if(o==="-a"||Jn(o,"and")||o==="-o"||Jn(o,"or")){if(r||n.at(-1).length===0){e.error=x(`find: ${o} with no left-hand expression`);break}(o==="-o"||Jn(o,"or"))&&n.push([]),e.i++,r=o;continue}let i=Wb(e,t);i&&n.at(-1).push(i),r=!1}return!e.error&&r&&(e.error=x(`find: ${r} with no right-hand expression`)),!e.error&&t&&n.at(-1).length===0&&(e.error=x("find: expected an expression")),!e.error&&t&&(e.tokens[e.i]===")"?e.i++:e.error=x("find: missing closing parenthesis")),n}function Wb(e,t){let n=e.i,r=!1;for(;e.tokens[e.i]==="!"||e.tokens[e.i]==="-not";)r=!r,e.i++;let o=e.tokens[e.i++];if(o==="(")return{kind:"group",groups:rd(e,t+1),negate:r};if(o===void 0||o===")"||o==="-a"||o==="-o"||Jn(o,"and")||Jn(o,"or"))return e.error=x(`find: -not or operator ${o??""} must be followed by a primary`),null;let i=o.startsWith("--")?o.slice(2):o.startsWith("-")?o.slice(1):null;if(["print","print0","prune","empty"].includes(i))return(i==="print"||i==="print0")&&(e.hasAction=!0),{kind:i,negate:r};if(i==="exec"){let s=Gb(e.tokens,e.i-1,r);return s.error?(e.error=s.error,null):(e.i=s.nextI+1,e.hasAction=!0,s.pred.mode==="batch"&&e.batches.push(s.pred),s.pred)}if(jb.has(i)){if(e.i===e.tokens.length)return e.error=x(`find: ${o} requires a value`),null;let s=qb(i,e.tokens[e.i++],r,e.depth);return s.error?(e.error=s.error,null):s}return o===","?(e.error=v("feature","find","comma operator","find: comma expressions are not supported"),null):e.i-1>n&&!o.startsWith("-")?(e.error=x(`find: -not must be followed by a primary, got: ${o}`),null):(e.error=o==="--"||!o.startsWith("-")?x(`find: paths must precede expression: ${o}`):v("option","find",o,`find: unknown option: ${o}`),null)}function qb(e,t,n,r){if(e==="type"){let o=Hb(t);return o.error?o:{kind:e,negate:n,types:o.types}}if(e==="mindepth"||e==="maxdepth"){let o=be(t,`find: -${e}`,t,{max:2147483647,digitsOnly:!0});return o.error?o:(r[e==="mindepth"?"minDepth":"maxDepth"]=o.value,{kind:"true",negate:n})}return{kind:e,negate:n,re:Me(t,{ignoreCase:e==="iname"||e==="ipath"})}}var td="fdl",zb="bcps";function Hb(e){let t=e.split(","),n=t.find((i,s)=>t.indexOf(i)!==s);if(n!==void 0)return{error:x(`find: Duplicate file type '${n}' in the argument list to -type.`)};if(t.every(i=>i.length===1&&td.includes(i)))return{types:t};let r=`find: -type/--type expects 'f', 'd' or 'l', got: ${e}`;return{error:t.every(i=>i.length===1&&(td+zb).includes(i))?v("option","find",`-type ${e}`,r):x(r)}}function Gb(e,t,n){let r=t+1;for(;r<e.length&&e[r]!==";"&&!(e[r]==="+"&&e[r-1]==="{}");)r++;if(r>=e.length)return{error:x("find: -exec: missing terminator (`;` or `{} +`); quote or escape `;`")};if(r===t+1)return{error:x("find: -exec: requires a command")};let o=e.slice(t+1,r),i=e[r]===";"?"each":"batch";if(i==="batch"){if(o.slice(0,-1).some(u=>u.includes("{}")))return{error:x("find: -exec ... +: only one instance of `{}` is supported")};if(n)return{error:v("feature","find","-not -exec ... +","find: `-not -exec ... +` is not supported (the `+` form has no meaningful negation)")}}let s={kind:"exec",mode:i,cmd:o[0],args:o.slice(1),negate:n};return i==="batch"&&(s.collected=[]),{pred:s,nextI:r}}var Xb={file:"f",dir:"d",link:"l"};async function od(e,t,n){let r=nd(t);if(r.error)return r.error;if(e!==""&&t.some(c=>c==="-exec"||c==="--exec"))return v("feature","find","-exec stdin","find: passing shared standard input to -exec is not supported");let{starts:o,minDepth:i,maxDepth:s,groups:u,batches:a}=r,l=U(),f=new Set;try{for(let c of o){let{path:d,error:p}=P(n,"find",c,{follow:!1});if(p){Is(l,n.flushOutput(U(`find: '${c}': ${p}
|
|
94
|
+
`))),l.exitCode=1;continue}let h=new Set;for(let m of Fe(n.fs,d,s,g=>!h.has(g))){let g=Yb(c,d,m.path);if(m.depth>=i&&await id(u,{kind:m.kind,path:g,abs:m.path,prune:h},n,l),m.kind!=="dir"||m.depth!==s||h.has(m.path))continue;let{dirs:w,files:y,links:k}=n.fs.listDir(m.path);(w.length||y.length||k.length)&&f.add(g)}}for(let c of a){if(c.collected.length===0)continue;let d=c.args.slice(0,-1).concat(c.collected);await sd(c.cmd,d,n,l)||(l.exitCode=1)}}finally{gt(n.notes,{command:"find",action:"depth limit omitted contents of",noun:["directory","directories"],paths:f})}return l}async function id(e,t,n,r){for(let o of e){let i=!0;for(let s of o)if(await Zb(s,t,n,r)===!!s.negate){i=!1;break}if(i)return!0}return!1}function Zb(e,t,n,r){if(e.kind==="group")return id(e.groups,t,n,r);if(e.kind==="true")return!0;if(e.kind==="type")return e.types.includes(Xb[t.kind]);if(e.kind==="name"||e.kind==="iname")return e.re.test(t.path.replace(/\/+$/u,"").split("/").at(-1)||"/");if(e.kind==="prune")return t.kind==="dir"&&t.prune.add(t.abs),!0;if(e.kind==="empty"){if(t.kind==="link")return!1;if(t.kind==="file")return n.fs.isEmptyFile(t.abs);let{dirs:o,files:i,links:s}=n.fs.listDir(t.abs);return o.length+i.length+s.length===0}return e.kind==="path"||e.kind==="ipath"?e.re.test(t.path):e.kind==="print"||e.kind==="print0"?(Is(r,n.flushOutput({stdout:t.path+(e.kind==="print"?`
|
|
95
|
+
`:"\0"),stderr:"",exitCode:0})),!0):e.mode==="batch"?(e.collected.push(t.path),!0):sd(e.cmd,e.args.map(o=>o.replaceAll("{}",t.path)),n,r)}async function sd(e,t,n,r){let o=await n.dispatch(e,t,"");return Is(r,o),o.exitCode===0}function Is(e,t){let n=e.exitCode;_(e,t),e.exitCode=n}function Yb(e,t,n){if(n===t)return e;let r=He(t,n);return e.endsWith("/")?e+r:e+"/"+r}var Fs=1e5,Vb=/^([+-]?\d+)\.\.([+-]?\d+)(?:\.\.([+-]?\d+))?$/u,Kb=/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([+-]?\d+))?$/u,ud=2n**63n-1n,ad=-(2n**63n),Ts=e=>{let t=BigInt(e);return t>ud||t<ad?null:t},ld=(e,t)=>e.mask===null?"0":e.mask[t];function Ls(e,t=Fs){if(!e.value.includes("{"))return[e];let n=Jb(e);for(let r=0;r<e.value.length;r++){if(e.value[r]!=="{"||ld(e,r)!=="0")continue;let o=n.get(r);if(!o)continue;let{end:i,commas:s}=o,u=s.length?[]:ex(xe(e,r+1,i));if(s.length){let c=r+1;for(let d of[...s,i])u.push(xe(e,c,d)),c=d+1}if(u===null)continue;let a=xe(e,0,r),l=xe(e,i+1),f=[];for(let c of u)if(f.push(...Ls(il(a,c,l),t)),f.length>t)throw new b("feature","brace expansion limit",`brace expansion \`${e.value}\` would produce more than ${t} words`);return f}return[e]}function Jb(e){let t=[],n=new Map;for(let r=0;r<e.value.length;r++){if(ld(e,r)!=="0")continue;let o=e.value[r];if(o==="{")t.push({start:r,commas:[]});else if(o==="}"&&t.length){let{start:i,commas:s}=t.pop();n.set(i,{end:r,commas:s})}else o===","&&t.length&&t.at(-1).commas.push(r)}return n}function Qb(e){if(e.mask!==null&&/[12]/u.test(e.mask))return null;let t=Vb.exec(e.value),n=t??Kb.exec(e.value);if(!n)return null;let[r,o]=t?[Ts(t[1]),Ts(t[2])]:[BigInt(n[1].codePointAt(0)),BigInt(n[2].codePointAt(0))],i=n[3]===void 0?1n:Ts(n[3]);if(r===null||o===null||i===null||i===ad)return null;let s=o>=r?o-r:r-o;return s>ud?null:{num:t,range:n,from:r,to:o,step:(i<0n?-i:i)||1n,span:s}}function ex(e){let t=Qb(e);if(t===null)return null;let{num:n,from:r,to:o,step:i,span:s}=t,u=s/i+1n;if(u>Fs)throw new b("feature","brace expansion limit",`brace expansion \`{${e.value}}\` would produce ${u} words (limit ${Fs})`);let a=n?tx(n[1],n[2]):0,l=[],f=o>=r?1n:-1n;for(let c=0n;c<u;c++){let d=r+f*c*i,p=n?nx(d,a):String.fromCodePoint(Number(d));l.push({value:p,mask:null})}return l}function tx(e,t){let n=r=>/^-?0\d/u.test(r);return n(e)||n(t)?Math.max(e.length,t.length):0}function nx(e,t){let n=String(e<0n?-e:e),r=e<0n?"-":"";return r+n.padStart(t-r.length,"0")}var _s=new Set(["CDPATH","GLOBIGNORE","GLOBSORT","BASH_COMPAT","POSIXLY_CORRECT","PATH","RANDOM","SRANDOM","SECONDS","EPOCHSECONDS","EPOCHREALTIME","BASHOPTS","SHELLOPTS","OPTIND"]),Je=class extends Map{constructor(t){super(t),this.unsetNames=new Set(t?.unsetNames)}set(t,n){if(this.expansionTargets?.has(t))throw new b("feature","temporary assignment side effects","modifying a temporary assignment target while expanding assignment values is not supported");if(_s.has(t)||t==="TZ"&&!["UTC","UTC0",""].includes(n))throw new b("feature",t,`shell variable ${t} is not supported with this value`);return(t==="LANG"||t.startsWith("LC_"))&&Wa(t,n),this.bound?.add(t),this.unsetNames?.delete(t),super.set(t,n)}delete(t){return this.unsetNames.add(t),super.delete(t)}};var fd=new Set(["$","!","0","-","_"]),rx=new Set(["PPID","UID","EUID","BASHPID","BASH_SUBSHELL","BASH_VERSION","BASH_VERSINFO","BASH_REMATCH","DIRSTACK","PIPESTATUS","FUNCNAME","LINENO","REPLY","BASH","BASH_COMMAND","BASH_ARGV0","BASH_ARGC","BASH_ARGV","BASH_SOURCE","BASH_LINENO","BASH_ALIASES","BASH_CMDS","GROUPS","HOSTTYPE","OSTYPE","MACHTYPE","HOSTNAME","SHLVL","SHELL","TERM","PS4","OPTERR","HISTCMD","BASH_EXECUTION_STRING","BASH_LOADABLES_PATH","COMP_WORDBREAKS"]);function Et(e,t){if(fd.has(e))throw Rs(e);let n=Ms(e,t);if(n)return n;if(cd(e))throw Rs(e);return{value:"",set:!1}}var cd=e=>_s.has(e)||rx.has(e),Rs=e=>new b("feature",`$${e}`,`shell parameter ${e} is not supported`),dd=(e,t)=>Ms(e,t)?.value??"";function Ms(e,t){return e==="?"?{value:String(t.lastExit),set:!0}:e==="#"?{value:"0",set:!0}:e==="@"?{value:"",set:!1,omit:!0}:e==="*"?{value:"",set:!1}:/^[1-9][0-9]*$/u.test(e)?{value:"",set:!1}:t.vars.has(e)?{value:t.vars.get(e),set:!0}:t.vars.unsetNames.has(e)?{value:"",set:!1}:e==="IFS"?{value:`
|
|
96
|
+
`,set:!0}:e==="PWD"?{value:t.cwd,set:!0}:e==="HOME"?{value:t.home,set:!0}:e==="USER"||e==="LOGNAME"?{value:t.user,set:!0}:e==="LANG"?{value:t.locale,set:!0}:null}function Ps(e,t){if(fd.has(e))throw new b("feature",`$${e}`,`shell parameter ${e} is not supported (this terminal runs no process)`);let n=Ms(e,t);if(n)return n;if(cd(e))throw Rs(e);return ox(t,`$${e}`,`warning: $${e} is unset (this shell has no environment variables; only \`for\` bindings and \`NAME=value\` assignments)`),{value:""}}function ox(e,t,n){uo(e,n+`
|
|
97
|
+
`),e.unsupported.add({kind:"feature",command:null,detail:t,message:n})}var pd=16e6,Qn=e=>new b("feature","${",e);function hd(e,t,n){if(Gn(t))throw Qn("extended glob patterns in parameter expansion are not supported");let r=on({value:t.value,mask:t.mask??null}),o=n[0]==="#",i=gd(r);if(i!==null)return o?e.startsWith(i)?e.slice(i.length):e:e.endsWith(i)?e.slice(0,e.length-i.length):e;let s=Me(r,{bash:!0}),u=n.length===2,a=o===u,l=a?e.length:0,f=0;for(;l>=0&&l<=e.length;){let c=o?e.slice(0,l):e.slice(l);if(f+=c.length+r.length,f>pd)throw Qn("parameter pattern removal exceeds the matching work limit");if(s.test(c))return o?e.slice(l):e.slice(0,l);l=co(e,l,a)}return e}function md(e,t,n,r){let o="";if(!r&&/^[#%]/u.test(t.value)&&(!t.mask||t.mask[0]==="0")&&(o=t.value[0],t={value:t.value.slice(1),mask:t.mask?.slice(1)??null}),Gn(t))throw Qn("extended glob patterns in parameter expansion are not supported");let i=on({value:t.value,mask:t.mask??null}),s={work:0},u=ux(n,s);if(!i)return o==="#"?u("")+e:o==="%"?e+u(""):e;if((/\\+$/u.exec(i)?.[0].length??0)%2)throw Qn("unescaped trailing backslashes in replacement patterns are not supported");let a=gd(i),l=a===null?sx(e,i,o,s):ix(e,a,o),f=[],c=0;do{let d=l(c);if(!d)break;let[p,h]=d,m=u(e.slice(p,h));if(Ds(s,p-c),f.push(e.slice(c,p),m),c=h,!r)break;if(p===h){let g=co(e,c,!1);f.push(e.slice(c,g)),c=g}}while(c<e.length);return f.push(e.slice(c)),f.join("")}function ix(e,t,n){return r=>{let o=n==="%"?e.length-t.length:e.indexOf(t,r);return o<r||n==="#"&&o!==0||e.slice(o,o+t.length)!==t?null:[o,o+t.length]}}function sx(e,t,n,r){let o=Me(t,{bash:!0});return i=>{for(let s=i;s<=e.length;s=co(e,s,!1)){for(let u=e.length;u>=s;u=co(e,u,!0)){if(Ds(r,u-s+t.length),o.test(e.slice(s,u)))return[s,u];if(n==="%")break}if(n==="#")break}return null}}function Ds(e,t){if(e.work+=t,e.work>pd)throw Qn("parameter replacement exceeds the matching work limit")}function ux(e,t){let n="";for(let r=0;r<e.value.length;r++){let o=e.value[r];e.mask?.[r]!==void 0&&e.mask[r]!=="0"&&(o==="&"||o==="\\")&&(n+="\\"),n+=o}return r=>{let o=[];for(let i=0;i<n.length;i++){let s=n[i],u=s==="\\"&&/[&\\]/u.test(n[i+1]??"")?n[++i]:s==="&"?r:s;Ds(t,u.length),o.push(u)}return o.join("")}}function co(e,t,n){let r=t+(n?-1:1);return r>0&&r<e.length&&/[\uDC00-\uDFFF]/u.test(e[r])&&/[\uD800-\uDBFF]/u.test(e[r-1])?r+(n?-1:1):r}function gd(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r==="\\"&&n+1<e.length)t+=e[++n];else{if(/[*?[]/u.test(r))return null;t+=r}}return t}var je=e=>BigInt.asIntN(64,e),J=(e,t)=>new b("feature","arithmetic "+e,"arithmetic expansion: "+t);function wd(e){let t=10n,n=!1,r=0n,o=0;if(e[0]==="0"&&(o=1,t=8n,n=!0,(e[1]==="x"||e[1]==="X")&&(t=16n,o=2)),o===2&&e.length===2)throw J("number","hexadecimal constant has no digits");for(;o<e.length;o++){let i=e[o];if(i==="#"){if(n||r<2n||r>64n||o===e.length-1)throw J("number","invalid arithmetic base or integer constant");t=r,r=0n,n=!0;continue}let s=i.codePointAt(0),u=s>=48&&s<=57?s-48:s>=97&&s<=122?s-87:s>=65&&s<=90?s-(t<=36n?55:29):i==="@"?62:i==="_"?63:-1;if(u<0||BigInt(u)>=t)throw J("number","value too great for base in "+e.slice(0,40));r=je(r*t+BigInt(u))}return r}function ax(e,t){if(t<0n)throw J("exponent","exponent less than zero");let n=1n;for(let r=t,o=e;r!==0n;r>>=1n,o=je(o*o))r&1n&&(n=je(n*o));return n}function Bs(e,t,n,r){switch(e){case"+":return je(t+n);case"-":return je(t-n);case"*":return je(t*n);case"/":case"%":{if(n===0n&&r)throw J("division","division by zero");let o=n===0n?1n:n;return je(e==="/"?t/o:t%o)}case"**":return ax(t,n);case"<<":case">>":{if(n<0n||n>63n)throw J("shift count","shift counts outside 0..63 are not supported");return je(e==="<<"?t<<n:t>>n)}case"&":return t&n;case"^":return t^n;case"|":return t|n;case"<":return BigInt(t<n);case"<=":return BigInt(t<=n);case">":return BigInt(t>n);case">=":return BigInt(t>=n);case"==":return BigInt(t===n);case"!=":return BigInt(t!==n);default:throw J("operator","unsupported operator "+e)}}var lx=new Set(["=","+=","-=","*=","/=","%=","<<=",">>=","&=","^=","|="]),fx=[["||"],["&&"],["|"],["^"],["&"],["==","!="],["<","<=",">",">="],["<<",">>"],["+","-"],["*","/","%"],["**"]],cx=new Map(fx.flatMap((e,t)=>e.map(n=>[n,t+3]))),dx=/^(?:<<=|>>=|\+\+|--|\*\*|&&|\|\||<<|>>|[+\-*/%&^|=!<>]=|[+\-*/%&^|=!~<>?:,()])/u;function px(e){let t=[];for(let n=0;n<e.length;){if(t.length>=1e4)throw J("limit","expression token limit exceeded");let r=e.slice(n),o=/^[ \t\n]+/u.exec(r);if(o){n+=o[0].length;continue}let i=/^[0-9][A-Za-z0-9#@_]*/u.exec(r),s=/^[A-Za-z_][A-Za-z0-9_]*/u.exec(r),u=dx.exec(r);if(i)t.push({type:"number",value:wd(i[0]),raw:i[0]});else if(s)t.push({type:"name",value:s[0],raw:s[0]});else if(u)t.push({type:"operator",value:u[0],raw:u[0]});else throw J(r[0]==="["||r[0]==="]"?"arrays":"syntax","unsupported expression token "+JSON.stringify(r[0]));n+=t.at(-1).raw.length}return t.push({type:"end",value:""}),t}function yd(e){let t=new Us(px(e));if(t.token.type==="end")return{type:"number",value:0n};let n=t.expression();if(t.token.type!=="end")throw J("syntax","unexpected token "+t.token.value);return n}var Us=class{constructor(t){this.tokens=t,this.at=0,this.depth=0}get token(){return this.tokens[this.at]}next(){return this.tokens[this.at++]}accept(t){return this.token.value===t?this.next():null}expect(t){if(!this.accept(t))throw J("syntax","expected "+t)}expression(t=0){if(++this.depth>128)throw J("limit","expression nesting limit exceeded");let n=this.prefix();for(;;){let r=this.token.value;if(r==="?"&&t<=2){this.next();let u=this.expression();this.expect(":"),n={type:"condition",test:n,consequent:u,alternate:this.expression(2)};continue}let o=lx.has(r),i=r===","?0:o?1:cx.get(r);if(i===void 0||i<t)break;if(this.next(),o&&n.type!=="name")throw J("assignment","attempted assignment to non-variable");let s=this.expression(i+(o||r==="**"?0:1));n={type:o?"assignment":"binary",op:r,left:n,right:s}}return this.depth--,n}prefix(){let t=this.next();if(["+","-","!","~"].includes(t.value))return{type:"unary",op:t.value,value:this.expression(14)};if(t.value==="++"||t.value==="--"){let n=this.next();if(n.type!=="name")throw J("increment","increment requires a scalar variable");return{type:"increment",op:t.value,name:n.value,post:!1}}if(t.value==="("){let n=this.expression();return this.expect(")"),{type:"group",value:n}}if(t.type!=="number"&&t.type!=="name")throw J("syntax","operand expected");return t.type==="name"&&(this.token.value==="++"||this.token.value==="--")?{type:"increment",op:this.next().value,name:t.value,post:!0}:t}};function Ut(e,t,n=0){return xd(e,{ctx:t,steps:1e4,characters:2e5},n,!0)}function xd(e,t,n,r){if(typeof e!="string")throw J("value","expression must be a string");if(t.characters-=e.length,e.length>1e5||t.characters<0)throw J("limit","expression size limit exceeded");if(n>128)throw J("limit","variable recursion limit exceeded");return kd(yd(e),t,n+1,r)}function js(e,t,n,r){if(!r)return 0n;let o;try{o=Et(e,t.ctx)}catch(i){throw J("variable",V(i))}return o.set&&o.value!==""?xd(o.value,t,n+1,!0):0n}function bd(e,t,n,r){if(r)try{Et(e,n.ctx),n.ctx.vars.set(e,t.toString())}catch(o){throw J("assignment",V(o))}return t}function kd(e,t,n,r){if(--t.steps<0||n>128)throw J("limit","expression evaluation limit exceeded");let o=(i,s=r)=>kd(i,t,n+1,s);switch(e.type){case"number":return e.value;case"name":return js(e.value,t,n,r);case"group":return o(e.value);case"unary":{let i=o(e.value);return e.op==="+"?i:e.op==="-"?je(-i):e.op==="!"?BigInt(i===0n):~i}case"increment":{let i=js(e.name,t,n,r),s=bd(e.name,je(i+(e.op==="++"?1n:-1n)),t,r);return e.post?i:s}case"assignment":{let i=e.left.value,s=e.op==="="?0n:js(i,t,n,r),u=o(e.right);return bd(i,e.op==="="?u:Bs(e.op.slice(0,-1),s,u,r),t,r)}case"condition":{let i=o(e.test)!==0n,s=o(e.consequent,r&&i),u=o(e.alternate,r&&!i);return i?s:u}case"binary":{let i=o(e.left),s=r&&(e.op==="&&"?i!==0n:e.op==="||"?i===0n:!0),u=o(e.right,s);return e.op===","?u:e.op==="&&"?BigInt(i!==0n&&u!==0n):e.op==="||"?BigInt(i!==0n||u!==0n):Bs(e.op,i,u,r)}default:throw J("syntax","unsupported expression")}}var po=e=>new b("feature","${",e);async function vd(e,t,n,r){if(e.name==="@"||e.name==="*")throw po("substring and replacement of positional parameter lists are not supported");if(!t.set)return t;if(e.operator===":")try{return{value:await hx(t.value,e.word,n,r)}}catch(l){throw l.halt=!0,l}let o=e.word,i=0;for(;o[i]==="\\"&&o[i+1]===`
|
|
98
|
+
`;)i+=2;let s=Sd(o,"/",r.readExpansion,o[i]==="/"?i+1:0),u=await r.expand(o.slice(0,s),{pattern:!0}),a=await r.expand(s<o.length?o.slice(s+1):"",{replacement:!0});return{value:md(t.value,u,a,e.operator==="//")}}async function hx(e,t,n,r){if(/\P{ASCII}/u.test(e))throw po("locale-dependent slicing of non-ASCII parameters is not supported");let o=Sd(t,":",r.readExpansion),i=async l=>Ut((await r.expand(l,{arithmetic:!0})).value,n),s=await i(t.slice(0,o)),u=BigInt(e.length);if(s<0n&&(s+=u),s<0n||s>u)return"";let a=u;if(o<t.length){let l=await i(t.slice(o+1));if(a=l<0n?u+l:s+l,a>ue)throw po("substring length overflows the shell integer range");if(a<s){let f=new Error(`${t.slice(o+1)}: substring expression < 0`);throw f.exitCode=1,f.halt=!0,f}}return e.slice(Number(s),Number(a>u?u:a))}function Sd(e,t,n,r=0){let o=0,i=null,s=0;for(let u=r;u<e.length;u++){let a=e[u];if(i==="'"){a==="'"&&(i=null);continue}if(i==="ansi"){a==="\\"?u++:a==="'"&&(i=null);continue}if(a==="\\"){u++;continue}if(t===":"&&(a==="'"||a==='"'))throw po("quoted substring arithmetic is not supported");if(a==='"'){i=i==='"'?null:'"';continue}if(a==="'"&&!i){i=a;continue}if(a==="$"){let l=n(e,u,0,t===":"||i==='"');if(l){u+=l.raw.length-1;continue}let f=u+1;for(;e[f]==="\\"&&e[f+1]===`
|
|
99
|
+
`;)f+=2;if(!i&&e[f]==="'"){i="ansi",u=f;continue}}if(!i){if(t===":"){if(a==="(")o++;else if(a===")")o--;else if(o===0&&a==="?")s++;else if(o===0&&a===":"&&s){s--;continue}if(o!==0)continue}if(a===t)return u}}return e.length}var mx=/^[A-Za-z_][A-Za-z0-9_]*$/u;async function Ed(e,t,n){let{lookup:r,expand:o}=n,{name:i,operator:s,word:u=""}=e,a=r(i,{quiet:s!==""});if(!s)return a;if(s==="length")return gx(i,a.value);if(s===":"||s.startsWith("/"))return vd(e,a,t,n);if(s[0]==="#"||s[0]==="%")return!a.value||!u?a:{value:hd(a.value,await o(u,{pattern:!0}),s)};let l=!a.set||s.startsWith(":")&&a.value==="",f=s[s.length-1];if(f==="+")return l?{value:"",...a.omit?{omit:!0}:{}}:o(u,{});if(!l)return a;if(f==="?")throw await wx(i,u,s.startsWith(":"),o,t);if(f!=="=")return o(u,{});if(!mx.test(i)){let d=new Error(`$${i}: cannot assign in this way`);throw d.exitCode=1,d.halt=!0,d}let c=await o(u,{assignment:!0});return t.vars.set(i,c.value),{value:t.vars.get(i)}}function gx(e,t){if(e==="*"||e==="@")return{value:"0"};if(/\P{ASCII}/u.test(t))throw Ft("#"+e,"locale-dependent length of non-ASCII parameters is not supported");return{value:String(t.length)}}async function wx(e,t,n,r,o){let i=t?yx(await r(t,{error:!0}),o):n?"parameter null or not set":"parameter not set",s=new Error(`${e}: ${i}`);return s.exitCode=1,s.halt=!0,s}function yx(e,t){let n=t.vars.get("IFS")??`
|
|
93
100
|
`;if(n==="")return e.value;if(n!==`
|
|
94
|
-
`)throw
|
|
101
|
+
`)throw Ft("?","custom IFS separators in parameter errors are not supported");let r=new Set(e.empty),o=[],i=!1,s="",u=()=>{(s||i)&&o.push(s),s="",i=!1};for(let a=0;a<=e.value.length&&(r.has(a)&&(i=!0),a!==e.value.length);a++){let l=e.value[a],f=!e.mask||e.mask[a]==="0";f&&/[ \t\n]/u.test(l)?u():(s+=l,i||=!f)}return u(),o.join(" ")}function $t(e,t){return ce(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new Je(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function ce(e,t,n){let r=Object.fromEntries(Object.keys(t).map(o=>[o,e[o]]));Object.assign(e,t);try{return await n()}finally{Object.assign(e,r)}}async function er(e,t){let n=[],r=e[0],o=r?.value==="export"&&!/[12]/u.test(r.mask??"")&&!r.empty?.length;for(let i of e)for(let s of Ls(i)){let u=o&&s===i&&In(i);if(u){let a=await xx(s,u.end,t);n.push({value:a,mask:"1".repeat(a.length),q:!0})}else n.push(...await Nd(ho(s,t,s===i?!1:"word"),t,!0))}return{argv:bx(n,t)}}function bx(e,t){let n=[];for(let r of e){if(Qf(r)){let o=ec(r,t);if(o.length>0){n.push(...o);continue}}(r.value!==""||r.q)&&n.push(r.value)}return n}async function Ws(e,t){let{argv:n}=await er([e],t);return n.length===1?{value:n[0]}:{error:`${e.value}: ambiguous redirect`}}async function xx(e,t,n){let r=xe(e,t);return e.value.slice(0,t)+await jt(r,n,!0)}async function jt(e,t,n=!1){return(await Nd(ho(e,t,n),t,!1,n))[0].value}var ln=e=>e.vars.get("HOME")??e.home,$d=(e,t)=>e.mask===null?"0":e.mask[t];function ho(e,t,n=!1){let r=ol(e,n);if(r.size===0)return e;let o=e.value,i=ln(t),s="",u="",a=[];for(let l=0;l<o.length;l++){if(e.empty?.includes(l)&&a.push(s.length),r.has(l)){let f=i==="/"&&o[l+1]==="/"?"":i;s+=f,u+="1".repeat(f.length);continue}s+=o[l],u+=$d(e,l)}return e.empty?.includes(o.length)&&a.push(s.length),{value:s,mask:/[12]/u.test(u)?u:null,...a.length?{empty:a}:{}}}function qs(e,t){return ce(t,{strictExpansion:!0},()=>zs(ho(e,t),t))}async function Nd(e,t,n,r=!1){let o=await zs(e,t,r);return n?Sx(o,t):[o]}async function zs(e,t,n=!1){let r={value:"",mask:"",empty:[],split:!1},o=(i,s)=>{r.value+=i,r.mask+=s};e.value===""&&e.mask!==null&&r.empty.push(0);for(let i=0;i<=e.value.length&&(e.empty?.includes(i)&&r.empty.push(r.value.length),i!==e.value.length);i++){let s=$d(e,i),u=e.value[i];if(s==="0"&&(u==="<"||u===">")&&e.value[i+1]==="(")throw new b("feature",`${u}(`,`process substitution (\`${u}(\u2026)\`) is not supported`);let a=s!=="1"&&(u==="$"||u==="`"),l=e.value[i+1]==="("||e.value[i+1]==="{",f=a?kx(e,i,u,s,l):null;if(!f){o(e.value[i],s);continue}i+=f.raw.length-1;let c=await vx(f,t,s==="2",n);if(c.literal){o(f.raw,s.repeat(f.raw.length));continue}if(!c.omit)if(s==="2")c.value===""&&r.empty.push(r.value.length),o(c.value,"2".repeat(c.value.length));else{r.split=!0;for(let d of c.empty??[])r.empty.push(r.value.length+d);c.q&&!c.value&&!c.empty?.length&&r.empty.push(r.value.length),o(c.value,c.mask??"0".repeat(c.value.length))}}return r.q=r.empty.length>0||/[12]/u.test(r.mask),r}function kx(e,t,n,r,o){return n==="`"?at(e.value,t):o?ft(e.value,t,0,r==="2"):Ai(e.value,t,e.mask)}async function vx(e,t,n,r){if(e.command!==void 0)return{value:await t.substitute(e.command,e.backtick)};if(e.arithmetic!==void 0)try{let o=await ce(t,{strictExpansion:!0},()=>jt(Ci(e.arithmetic,!0),t));return{value:String(Ut(o,t))}}catch(o){throw o.halt=!0,o}return e.parameter!==void 0?e.parameter.operator===""&&!t.strictExpansion&&!/^[0-9]{2,}$/u.test(e.parameter.name)?Ps(e.parameter.name,t):Ed(e.parameter,t,{lookup:o=>Et(o,t),readExpansion:ft,expand:(o,i={})=>{let s=i.pattern||i.error||i.replacement||i.arithmetic,u=Ci(o,i.arithmetic||!s&&n),a=!s&&(i.assignment||r),l=i.assignment?"parameterAssign":a?!0:"parameter";return ce(t,{strictExpansion:!0},()=>zs(i.arithmetic?u:ho(u,t,l),t,a))}}):t.strictExpansion?Et(e.name,t):Ps(e.name,t)}function Sx(e,t){if(!e.split)return e.value!==""||e.q?[e]:[];let n=t.vars.get("IFS")??`
|
|
95
102
|
`;if(n!==""&&n!==`
|
|
96
|
-
`)throw new
|
|
97
|
-
`}`;_(n.result,n.ctx.flushOutput({...U(),stdout:r,events:[{fd:1,text:r}]}))}var
|
|
98
|
-
`),t.byteLocale?r[0]:n.codePointAt(0)}function
|
|
99
|
-
`,n.failed=!0),
|
|
100
|
-
`,n.failed=!0,t?
|
|
101
|
-
`,n),
|
|
102
|
-
`?" ":l[0];if(f!==" "&&f!=="-"&&f!=="+")throw new
|
|
103
|
-
`?l:l.slice(1);if(
|
|
104
|
-
`)throw new
|
|
105
|
-
`?" ":s[0];if(u!==" "&&u!=="!"&&u!=="-"&&u!=="+")break;
|
|
106
|
-
`?s:s.slice(2)})}return{lines:
|
|
103
|
+
`)throw new b("feature","IFS","custom IFS separators are not supported");let r=[],o={value:"",mask:"",q:!1},i=()=>{(o.value!==""||o.q)&&r.push(o),o={value:"",mask:"",q:!1}},s=new Set(e.empty);for(let u=0;u<=e.value.length&&(s.has(u)&&(o.q=!0),u!==e.value.length);u++){let a=e.value[u],l=e.mask[u];if(n!==""&&l==="0"&&/[ \t\n]/u.test(a)){i();continue}o.value+=a,o.mask+=l,o.q||=l!=="0"}return i(),r}function Ad(e,t,n){let r=Kc(t,n),o={ctx:n,options:r,seen:new Set,result:U(),total:0n,failed:!1};r.stderr&&_(o.result,n.flushOutput(U(r.stderr)));for(let i of r.operands){let s=i.length>2?i.replace(/\/+$/u,"/"):i,u=P(n,"du",s,{follow:r.links!=="none"});if(u.error){_(o.result,n.flushOutput(x(`du: cannot access ${X(s,n)}: ${u.error}`))),o.failed=!0;continue}try{Ex(u.path,s,o)}catch(a){let l=O(a),f="du: "+V(a);if(l&&n.unsupported.add({...l,command:l.command??"du",message:f}),_(o.result,n.flushOutput(x(f))),o.failed=!0,l)return o.result}}return r.flags.has("c")&&Hs(o.total,"total",o),o.result.exitCode=o.failed?1:0,o.result}function Ex(e,t,n){let{ctx:r,options:o}=n;if(!o.flags.has("inodes")&&r.fs.isDir(e)&&Object.values(r.outputFds??{}).some(s=>typeof s=="object"&&s.path?.startsWith(e==="/"?"/":e+"/")))throw new b("feature","recursive metadata output overlap","output within a measured directory is not supported");let i=[{path:e,name:t,depth:0}];for(;i.length;){let s=i.pop();if(s.total!==void 0){s.depth<=o.depth&&Hs(s.total,s.name,n),s.parent&&!o.flags.has("S")&&(s.parent.total+=s.total);continue}let u=r.fs.isDir(s.path);if(u&&r.fs.isFile(s.path))throw new b("feature","ambiguous file type",`path is both a file and a directory: ${s.name}`);if(!u&&o.links==="all"&&r.fs.isLink?.(s.path))throw new b("option","dereference",`following symbolic links is not supported: ${s.name}`);let a=u?s.path:r.fs.fileIdentity?.(s.path)??s.path;if(!o.flags.has("l")&&n.seen.has(a))continue;n.seen.add(a);let l=u?"dir":r.fs.isLink?.(s.path)?"link":"file",f=u?0:r.fs.fileSize(s.path),c=o.flags.has("inodes")?1n:o.flags.has("A")?BigInt(f):BigInt(lo(f,l));if(n.total+=c,u){s.total=c,i.push(s);let d=r.fs.listDir(s.path),p=[...new Set([...d.dirs,...d.files,...d.links])].sort(j),h=s.name.endsWith("/")?s.name:s.name+"/";for(let m=p.length-1;m>=0;m--)i.push({path:Te(s.path,p[m]),name:h+p[m],depth:s.depth+1,parent:s})}else s.parent&&(s.parent.total+=c),(s.depth===0||o.flags.has("a")&&s.depth<=o.depth)&&Hs(c,s.name,n)}}function Hs(e,t,n){let r=`${Kn(e,n.options.scale)} ${t}${n.options.flags.has("0")?"\0":`
|
|
104
|
+
`}`;_(n.result,n.ctx.flushOutput({...U(),stdout:r,events:[{fd:1,text:r}]}))}var $x=/^%([-+ 0#']*)(\d+|\*)?'?(?:\.(\d+|\*)?)?[hlL]?(.)?/su,Nx="diouxXeEfFgGcs";function go(e){let t=[],n="";for(let r=0;r<e.length;r++){if(e[r]!=="%"){n+=e[r];continue}if(e[r+1]==="%"){n+="%",r++;continue}if(/^%[^a-zA-Z%]*\$/u.test(e.slice(r)))throw new $("positional printf arguments are not supported",null,"positional format arguments");let o=$x.exec(e.slice(r)),i=o[4];if(i==="a"||i==="A")throw new $("hexadecimal floating-point formats are not supported",null,"hexadecimal float format");if(i==="%"){n+="%",r+=o[0].length-1;continue}if(i===void 0||!Nx.includes(i)){n+=o[0],r+=o[0].length-1;continue}n!==""&&(t.push(n),n="");let s=o[1];t.push({minus:s.includes("-"),plus:s.includes("+"),space:s.includes(" "),zero:s.includes("0"),alt:s.includes("#"),width:o[2]===void 0?null:o[2]==="*"?"*":Number(o[2]),precision:o[3]===void 0?o[0].includes(".")?0:null:o[3]==="*"?"*":Number(o[3]),conv:i}),r+=o[0].length-1}return n!==""&&t.push(n),t}function Nt(e,t,n,r){let o=n.width??0;if(o>Ce)throw new $("format width exceeds the output limit",null,"format size limit");let i=o-e.length-[...t].length;return i<=0?e+t:n.minus?e+t+" ".repeat(i):n.zero&&r?e+"0".repeat(i)+t:" ".repeat(i)+e+t}var Id=e=>e.plus?"+":e.space?" ":"",Td=e=>e==="X"||e==="E"||e==="G"||e==="F";function Wt(e,t){if(t.precision>Ce)throw new $("format precision exceeds the output limit",null,"format size limit");let{conv:n}=t;if(!Number.isFinite(e)){if(Number.isNaN(e))throw new $("formatting signed NaN is not supported",null,"signed NaN");let r=e<0?"-inf":"+inf";return Td(n)?r.toUpperCase():r}return"ouxX".includes(n)&&(e>=2**64||e<-(2**63))?Od(e,{...t,conv:"g"}):"diouxX".includes(n)?Ax(e,t):Od(e,t)}function Ax(e,t){let{conv:n}=t,r=n==="d"||n==="i",o=r?Math.trunc(e)===0:e===0,i=BigInt(Math.trunc(e)),s=!1;i<0n&&(r?(s=!0,i=-i):i=BigInt.asUintN(64,i));let u=n==="o"?8:n==="x"||n==="X"?16:10,a=i.toString(u);n==="X"&&(a=a.toUpperCase()),t.precision!==null&&(t.precision===0&&o?a=t.alt&&!r?"0":"":a=a.padStart(t.precision,"0"));let l=s?"-":r&&a!==""?Id(t):"";return t.alt&&!o&&(n==="o"&&(a="0"+a),(n==="x"||n==="X")&&(l+=n==="x"?"0x":"0X")),Nt(l,a,t,t.precision===null)}var mo=100;function Od(e,t){let{conv:n}=t;if(t.precision>mo)throw new $(`floating-point precision above ${mo} is not supported`,null,"float precision limit");let r=t.precision??6,o=e<0||Object.is(e,-0),i=Math.abs(e),s;return n==="e"||n==="E"?s=Ld(i,r):n==="f"||n==="F"?s=_d(i,r):s=Ox(i,r,t.alt),t.alt&&r===0&&n!=="g"&&n!=="G"&&(s=n==="e"||n==="E"?s.replace("e",".e"):s+"."),Td(n)&&(s=s.toUpperCase()),Nt(o?"-":Id(t),s,t,!0)}function Fd(e,t,n,r){let o=t.slice(r);if(!/^50*$/u.test(o))return e;let i=t.slice(0,n),s=i.at(-1);return Number(s)%2===0?i:e}function Ld(e,t){let n=e.toExponential(mo),r=n.indexOf("."),o=n.indexOf("e"),[i,s]=e.toExponential(t).split("e"),u=Fd(i,n.slice(0,o),t===0?r:r+1+t,r+1+t),a=Number(u===i?s:n.slice(o+1));return`${u}e${a<0?"-":"+"}${String(Math.abs(a)).padStart(2,"0")}`}function _d(e,t){if(e>=1e21)return BigInt(e).toString()+(t>0?"."+"0".repeat(t):"");let n=e.toFixed(mo),r=n.indexOf(".");return Fd(e.toFixed(t),n,t===0?r:r+1+t,r+1+t)}function Ox(e,t,n){let r=t===0?1:t;if(e===0)return n?"0."+"0".repeat(r-1):"0";let o=Ld(e,r-1),i=o.indexOf("e"),s=Number(o.slice(i+1));if(s<-4||s>=r)return n?o.includes(".")?o:o.slice(0,i)+"."+o.slice(i):Cd(o.slice(0,i))+o.slice(i);let u=_d(e,r-1-s);return n?u.includes(".")?u:u+".":Cd(u)}var Cd=e=>e.includes(".")?e.replace(/\.?0+$/u,""):e;var Cx=/^[+-]?(?:0[bB][01]+|0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)/u,Ix=/^[+-]?(?:0[xX](?:[\da-fA-F]+(?:\.[\da-fA-F]*)?|\.[\da-fA-F]+)(?:[pP][+-]?\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|inf(?:inity)?|nan(?:\([\w]*\))?)/iu;function Pd(e,t){if(e?.[0]!=="'"&&e?.[0]!=='"')return null;let n=e.slice(1);if(n==="")return null;let r=A(n),o=t.byteLocale?1:A(String.fromCodePoint(n.codePointAt(0))).length;return r.length>o&&(t.stderr+=`printf: warning: ${W(r.slice(o))}: character(s) following character constant have been ignored
|
|
105
|
+
`),t.byteLocale?r[0]:n.codePointAt(0)}function Dd(e,t,n){if(e===void 0||e==="")return"0";let r=e.replace(/^[ \t\n\r\f\v]+/u,""),o=t.exec(r)?.[0]??"";return(o.length!==r.length||o==="")&&(n.stderr+=`printf: ${Bd(e,n)}: ${o?"value not completely converted":"expected a numeric value"}
|
|
106
|
+
`,n.failed=!0),o||"0"}var Rd={"\x07":"\\a","\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r","\\":"\\\\","'":"\\'"},Md=e=>"\\"+e.toString(8).padStart(3,"0");function Bd(e,t){let n="";for(let r of e){if(Rd[r]!==void 0){n+=Rd[r];continue}let o=r.codePointAt(0);if(o<32||o===127){n+=Md(o);continue}n+=o>127&&t.byteLocale?A(r).map(Md).join(""):r}return`'${n}'`}function wo(e,t,n){let r=Pd(e,n);if(r!==null)return BigInt(r);let o=Dd(e,Cx,n),i=o[0]==="-",s=o.replace(/^[+-]/u,""),u=BigInt(/^0[0-7]+$/u.test(s)?"0o"+s:s),a=i?-u:u;return(t?u>it:a<ot||a>ue)?(n.stderr+=`printf: ${Bd(e,n)}: Numerical result out of range
|
|
107
|
+
`,n.failed=!0,t?it:i?ot:ue):t?BigInt.asUintN(64,a):a}function yo(e,t){let{conv:n}=t,r=n==="d"||n==="i",o=e<0n,i=n==="o"?8:n==="x"||n==="X"?16:10,s=(o?-e:e).toString(i);n==="X"&&(s=s.toUpperCase()),e===0n&&t.precision===0&&(s=""),s=s.padStart(t.precision??0,"0");let u=o?"-":r?t.plus?"+":t.space?" ":"":"";return t.alt&&(n==="o"&&!s.startsWith("0")&&(s="0"+s),e!==0n&&(n==="x"||n==="X")&&(u=n==="x"?"0x":"0X")),Nt(u,s,t,t.precision===null)}function Ud(e,t,n){let r=Pd(e,n),o=r===null?Dd(e,Ix,n):String(r),i=o.replace(/^[+-]/u,"");if(/^(?:inf|nan)/iu.test(i)){let a=o.startsWith("-")?"-":t.plus?"+":t.space?" ":"",l=/^nan/iu.test(i)?"nan":"inf";return t.conv===t.conv.toUpperCase()&&(l=l.toUpperCase()),Nt(a,l,t,!1)}let s=Rx(i),u=o.startsWith("-")?-s.value:s.value;if(t.precision>100||"gG".includes(t.conv)&&t.precision>96)throw new b("feature","float precision limit","floating-point precision exceeds the supported limit");try{let a=Wt(u,t);if(!s.exact){let[l,f]=Tx(s.value);for(let c of[l,f])if(Wt(o.startsWith("-")?-c:c,t)!==a)throw new b("feature","floating-point precision","floating-point formatting at this precision is not supported")}return a}catch(a){throw a.gap?new b("feature",a.gap,a.message):a}}var fn=new DataView(new ArrayBuffer(8));function jd(e){return fn.setFloat64(0,e),fn.getBigUint64(0)}function Tx(e){let t=jd(e);fn.setBigUint64(0,t-1n);let n=fn.getFloat64(0);return fn.setBigUint64(0,t+1n),[n,fn.getFloat64(0)]}function Fx(e){let t=jd(e),n=Number(t>>52n);return{coefficient:t&(1n<<52n)-1n|(n?1n<<52n:0n),exponent:n?n-1075:-1074}}function Gs(e,t){let n=e.replace(/^0+|0+$/gu,"");return{digits:n||"0",exponent:n?t+e.length-e.replace(/0+$/u,"").length:0}}function Lx({coefficient:e,exponent:t}){return t<0?Gs((e*5n**BigInt(-t)).toString(),t):Gs((e<<BigInt(t)).toString(),0)}function _x(e,t){let n=e.exponent-t.exponent;return n>=0?e.coefficient<<BigInt(n)===t.coefficient:e.coefficient===t.coefficient<<BigInt(-n)}function Rx(e){let t=/^0x/iu.test(e),n,r;if(t)n=Mx(e),r=Px(n);else{let[u,a="0"]=e.split(/[eE]/u),[l,f=""]=u.split(".");n=Gs(l+f,Number(a)-f.length),r=Number(e)}if(!Number.isFinite(r))throw new b("feature","floating-point range","floating-point values outside the JavaScript number range are not supported");if(r===0){if(t?n.coefficient!==0n:n.digits!=="0")throw new b("feature","floating-point range","floating-point underflow is not supported");return{value:r,exact:!0}}let o=Fx(r),i=Lx(o),s=t?_x(n,o):n.digits===i.digits&&n.exponent===i.exponent;return{value:r,exact:s&&i.exponent>=-100&&i.digits.length<=101}}function Mx(e){let[t,n="0"]=e.slice(2).split(/[pP]/u),[r,o=""]=t.split("."),i=(r+o).replace(/^0+/u,"")||"0";if(i.length>4096)throw new b("feature","floating-point input limit","hexadecimal floating-point significands above 4096 digits are not supported");return{coefficient:BigInt("0x"+i),exponent:Number(n)-4*o.length}}function Px({coefficient:e,exponent:t}){if(e===0n)return 0;let n=e.toString(2).length,r=t+n-1;if(r>1023)return 1/0;if(r<-1075)return 0;let o=Math.max(0,n-53,-1074-t),i=e>>BigInt(o);if(o>0){let s=e-(i<<BigInt(o)),u=1n<<BigInt(o-1);(s>u||s===u&&i%2n!==0n)&&i++}return Number(i)*2**(t+o)}var Wd={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,'"':34,"\\":92};function zd(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]==="%"){if(e[r+1]==="%"||r+1===e.length){n.push([37]),r+=2;continue}let o=/^%([-+ #0']*)(\d+)?(?:\.(\d*))?([\s\S])?/u.exec(e.slice(r)),[,i,s,u,a]=o;if(!a||a==="%")throw new Error(`invalid directive: ${o[0]}`);if(!"nsF".includes(a))throw new b("feature","%"+a,`format %${a} is not supported`);if(i.includes("'"))throw new b("feature","grouped format","digit grouping in stat formats is not supported");let l={field:a,conv:"u",width:Number(s??0),precision:u===void 0?null:Number(u||0),minus:i.includes("-"),zero:i.includes("0"),plus:i.includes("+"),space:i.includes(" "),alt:i.includes("#")};if(l.width>Ce||l.precision>Ce)throw new b("feature","format size limit","format width or precision exceeds the output limit");n.push(l),r+=o[0].length}else if(e[r]==="\\"&&t){let o=e[r+1],i=/^(?:[0-7]{1,3}|x[\da-fA-F]{1,2})/u.exec(e.slice(r+1))?.[0];if(i){let s=i[0]==="x"?16:8;n.push([parseInt(s===16?i.slice(1):i,s)&255]),r+=i.length+1}else if(Object.hasOwn(Wd,o))n.push([Wd[o]]),r+=2;else throw new b("feature","format escape",`format escape ${JSON.stringify(e.slice(r,r+2))} is not supported`)}else{let o=r+1;for(;o<e.length&&e[o]!=="%"&&!(t&&e[o]==="\\");)o++;n.push(B(e.slice(r,o))),r=o}return t||n.push([10]),n}function Hd(e,t,n,r){let o=r.isDir(n);if(o&&r.isFile(n))throw new b("feature","ambiguous file type",`path is both a file and a directory: ${t}`);let i=!o&&r.isLink?.(n)===!0,s,u=e.map(f=>{if(!f.field)return f;if(f.field==="n")return qd(t,f);if(f.field==="s"&&o)throw new b("feature","directory byte size",`directory byte sizes are not available: ${t}`);return s??=o?0:r.fileSize(n),f.field==="F"?qd(o?"directory":i?"symbolic link":s===0?"regular empty file":"regular file",f):B(yo(BigInt(s),f))}),a=new Uint8Array(u.reduce((f,c)=>f+c.length,0)),l=0;for(let f of u)a.set(f,l),l+=f.length;return W(a)}function qd(e,t){let n=B(e);t.precision!==null&&(n=n.subarray(0,t.precision));let r=Math.max(0,t.width-n.length);if(!r)return n;let o=new Uint8Array(n.length+r).fill(32);return o.set(n,t.minus?0:r),o}function Gd(e,t,n){let{order:r,positional:o}=N(t,{short:["L","t"],long:["dereference","terse"],valueShort:["c"],valueLong:["format","printf","cached"]});if(!o.length)return x("stat: missing operand");let i=r.some(({name:f})=>f==="L"||f==="dereference"),s;for(let f of r)if(f.name==="cached"){if(!f.value||!["always","never","default"].some(c=>c.startsWith(f.value)))return x(`stat: invalid cache mode: ${f.value}`)}else["c","format","printf"].includes(f.name)&&(s=f);if(!s)return v("feature","stat","default metadata","stat: default output requires filesystem metadata that is not available");let u=zd(s.value,s.name==="printf");if(u.some(f=>f.field==="s"||f.field==="F")&&Bx(o,n,i))return v("feature","stat","metadata output overlap","stat: buffered output sharing a measured file is not supported");let a=U(),l=!1;for(let f of o){let c=Dx(u,f,n,i);_(a,c),l||=c.exitCode!==0}return a.exitCode=l?1:0,a}function Dx(e,t,n,r){if(t==="-"){let i=v("feature","stat","standard input metadata","stat: standard input metadata is not supported");return n.unsupported.add({kind:"feature",command:"stat",detail:"standard input metadata",message:i.stderr.trimEnd()}),i}let o=P(n,"stat",t,{follow:r});if(o.error)return x(`stat: cannot statx ${X(t,n)}: ${o.error}`);try{return F(Hd(e,t,o.path,n.fs))}catch(i){let s=K(i,"stat","stat: "+V(i)),u=O(s);return u&&n.unsupported.add(u),s}}function Bx(e,t,n){let r=Object.values(t.outputFds).filter(o=>typeof o=="object");return r.length?e.some(o=>{let i=E(t.cwd,o,t.fs,{follow:n});return!i.error&&r.some(s=>s.path===i.path||s.identity!==void 0&&s.identity===t.fs.fileIdentity?.(i.path))}):!1}var Ux=/[ \t\n\v\f\r]/gu,jx=/[ \t\n\v\f\r]+/gu,Xd=/[ \t\n\v\f\r]+$/u,Zd=e=>e.replace(/[A-Z]/gu,t=>t.toLowerCase());function bo({ignoreCase:e=!1,whitespace:t="none"}={}){let n=null;return t==="all"?n=r=>r.replace(Ux,""):t==="change"?n=r=>r.replace(Xd,"").replace(jx," "):t==="trailing"&&(n=r=>r.replace(Xd,"")),e?n?r=>Zd(n(r)):Zd:n}function At(e){let t=[];for(let n=0;n<e.length;){let r=e.indexOf(`
|
|
108
|
+
`,n),o=r<0?e.length:r+1;t.push(e.slice(n,o)),n=o}return t}var cn=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: ?(.*?))?\n?$/u,qt=/^\*{15,}(?: (.*?))?\n?$/u,xo=/^\*{3} (\d+)(?:,(\d+))? \*{4}\n?$/u,tr=/^--- (\d+)(?:,(\d+))? ----\n?$/u,dn=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n?$/u;var Pe=class extends Error{constructor(t,n){super(n===void 0?t:`${t} at line ${n+1}`),this.name="PatchError",this.line=n}},Yd=(e,t)=>t===0?Number(e):Number(e)-1,Xs=e=>e!==void 0&&e.startsWith("\\"),Zs=e=>e.replace(/\n$/u,"");function Ys(e){let t=At(e),n=[],r={old:null,new:null},o=!1;for(let i=0;i<t.length;){let s=t[i],u=Vd(s,o);if(o=s.startsWith("***************")?!1:s.startsWith("*** "),u){r=u.names??{...r,[u.slot]:u.name},i++;continue}let a=cn.test(s)?"unified":qt.test(s)?"context":dn.test(s)?"normal":null;if(a===null){i++;continue}let l=[],f=Xx[a];for(let c=f(t,i);c!==null&&(l.push(c.hunk),i=c.next,!(i>=t.length||Vd(t[i],!1)));c=f(t,i));n.push({old:r.old,new:r.new,format:a,hunks:l,blocks:Wx(l)}),r={old:null,new:null}}return n}function Vd(e,t){let n=/^diff --git (\S+) (\S+)\n?$/u.exec(e);if(n)return{names:{old:n[1],new:n[2]}};if(xo.test(e)||tr.test(e))return null;let r=/^(\*\*\* |--- |\+\+\+ )(.*?)(?:\t.*)?\n?$/u.exec(e);return r?r[1]==="--- "?{slot:t?"new":"old",name:r[2]}:{slot:r[1]==="*** "?"old":"new",name:r[2]}:null}function Wx(e){let t=[];for(let n of e){let r=n.oldStart,o=n.newStart,i=null,s=()=>{i&&(t.push(i),r=i.a1,o=i.b1,i=null)};for(let{tag:u,text:a}of n.lines){if(u===" "){s(),r++,o++;continue}u==="-"&&i?.insert.length&&s(),i??={a0:r,a1:r,b0:o,b1:o,remove:[],insert:[]},u==="-"?(i.a1++,i.remove.push(a)):(i.b1++,i.insert.push(a))}s()}return t}function qx(e,t){let n=cn.exec(e[t]??"");if(!n)return null;let r=n[2]===void 0?1:Number(n[2]),o=n[4]===void 0?1:Number(n[4]),i={oldStart:Yd(n[1],r),newStart:Yd(n[3],o),label:n[5]||null,lines:[]},s=0,u=t+1,a=0;for(;a<r||s<o;u++){let l=e[u];if(l===void 0)throw new Pe("the patch ends inside a hunk",u);let f=l===`
|
|
109
|
+
`?" ":l[0];if(f!==" "&&f!=="-"&&f!=="+")throw new Pe(`a hunk line begins with ${JSON.stringify(f)}`,u);let c=l===`
|
|
110
|
+
`?l:l.slice(1);if(Xs(e[u+1])&&(c=Zs(c),u++),f!=="+"&&a++,f!=="-"&&s++,a>r||s>o)throw new Pe("a hunk has more lines than its header says",u);i.lines.push({tag:f,text:c})}return{hunk:i,next:u}}function zx(e,t){let n=dn.exec(e[t]??"");if(!n)return null;let[,r,o,i,s,u]=n,a=i==="a"?0:Number(o??r)-Number(r)+1,l=i==="d"?0:Number(u??s)-Number(s)+1;if(a<0||l<0)throw new Pe("a change command counts backwards",t);let f={oldStart:i==="a"?Number(r):Number(r)-1,newStart:i==="d"?Number(s):Number(s)-1,label:null,lines:[]},c=t+1,d=(p,h,m)=>{for(let g=0;g<p;g++,c++){let w=e[c];if(w===void 0)throw new Pe("the patch ends inside a hunk",c);if(w[0]!==h)throw new Pe(`${JSON.stringify(h)} expected`,c);let y=w.slice(2);Xs(e[c+1])&&(y=Zs(y),c++),f.lines.push({tag:m,text:y})}};if(d(a,"<","-"),i==="c"){if(e[c]!==`---
|
|
111
|
+
`)throw new Pe("'---' expected",c);c++}return d(l,">","+"),{hunk:f,next:c}}function Hx(e,t){let n=qt.exec(e[t]??"");if(!n)return null;let r=xo.exec(e[t+1]??"");if(!r)throw new Pe("'*** ' range expected",t+1);let o=t+2,i=Jd(e,o,tr,"-");o=i.next;let s=tr.exec(e[o]??"");if(!s)throw new Pe("'--- ' range expected",o);let u=Jd(e,o+1,null,"+"),a=i.lines.length===0?u.lines.filter(d=>d.tag===" "):i.lines,l=u.lines.length===0?i.lines.filter(d=>d.tag===" "):u.lines,f=Kd(r,a.length),c=Kd(s,l.length);return{hunk:{oldStart:f,newStart:c,label:n[1]||null,lines:Gx(a,l)},next:u.next}}var Kd=(e,t)=>t===0?Number(e[1]):Number(e[1])-1;function Jd(e,t,n,r){let o=[],i=t;for(;i<e.length;i++){let s=e[i];if(n&&n.test(s)||qt.test(s)||xo.test(s)||!n&&tr.test(s))break;if(Xs(s)){o[o.length-1].text=Zs(o.at(-1).text);continue}let u=s===`
|
|
112
|
+
`?" ":s[0];if(u!==" "&&u!=="!"&&u!=="-"&&u!=="+")break;o.push({tag:u===" "?" ":r,text:s===`
|
|
113
|
+
`?s:s.slice(2)})}return{lines:o,next:i}}function Gx(e,t){let n=[],r=0,o=0;for(;r<e.length||o<t.length;){if(e[r]?.tag===" "&&t[o]?.tag===" "){n.push(e[r]),r++,o++;continue}for(;r<e.length&&e[r].tag!==" ";)n.push(e[r]),r++;for(;o<t.length&&t[o].tag!==" ";)n.push(t[o]),o++;e[r]?.tag===" "&&t[o]===void 0?(n.push(e[r]),r++):t[o]?.tag===" "&&e[r]===void 0&&(n.push(t[o]),o++)}return n}var Xx={unified:qx,context:Hx,normal:zx};var We=class extends Error{constructor(t){super(`the rendered diff does not say what the change set says (${t})`),this.name="FormatError"}};function Vs(e,t,n,r){if(n.length===0){if(r!=="")throw new We("there was nothing to print, and something was printed");return}let o;try{o=Ys(r)}catch(s){throw new We(`it does not read back (${s.message})`)}if(o.length!==1)throw new We(`${o.length} files read back, not one`);let i=o[0].blocks;if(i.length!==n.length)throw new We(`${i.length} blocks read back, not ${n.length}`);for(let[s,u]of i.entries()){let a=n[s];if(u.a0!==a.a0||u.a1!==a.a1||u.b0!==a.b0||u.b1!==a.b1)throw new We(`block ${s+1} reads back somewhere else`)}for(let s of o[0].hunks){let u=s.oldStart,a=s.newStart;for(let{tag:l,text:f}of s.lines){let c=l==="+"?t[a]:e[u];if(f!==c)throw new We(`a ${l==="+"?"added":l==="-"?"removed":"kept"} line is not the line it stands for`);l!=="+"&&u++,l!=="-"&&a++}}}function rp(e,t,n,r){let o=[],i=0;for(;i<e.length;){let s=i;for(;s+1<e.length&&e[s+1].a0-e[s].a1<=2*t;)s++;let u=e[i],a=e[s];o.push({blocks:e.slice(i,s+1),a0:Math.max(0,u.a0-t),a1:Math.min(n,a.a1+t),b0:Math.max(0,u.b0-t),b1:Math.min(r,a.b1+t)}),i=s+1}return o}var Zx=`
|
|
107
114
|
\
|
|
108
|
-
`,
|
|
109
|
-
`)?"":
|
|
110
|
-
`;for(let l=
|
|
111
|
-
`);for(let l=s;l<u;l++)r+=
|
|
112
|
-
`;let a=s.a0,l=s.b0;for(let{a0:f,a1:c,b1:d}of s.blocks){for(;a<f;a++,l++)
|
|
113
|
-
`,
|
|
114
|
-
`,s.blocks.some(a=>a.a0<a.a1)&&(
|
|
115
|
-
`,s.blocks.some(a=>a.b0<a.b1)&&(
|
|
116
|
-
`;function
|
|
115
|
+
`,dt=(e,t)=>e+t+(t.endsWith(`
|
|
116
|
+
`)?"":Zx);function Qd(e,t){return t>e+1?`${e+1},${t}`:`${t>e?e+1:e}`}function op(e,t,n){let r="";for(let{a0:o,a1:i,b0:s,b1:u}of n){let a=o===i?"a":s===u?"d":"c";r+=Qd(o,i)+a+Qd(s,u)+`
|
|
117
|
+
`;for(let l=o;l<i;l++)r+=dt("< ",e[l]);a==="c"&&(r+=`---
|
|
118
|
+
`);for(let l=s;l<u;l++)r+=dt("> ",t[l])}return Vs(e,t,n,r),r}function ep(e,t){return t<=e?`${e},0`:t===e+1?`${e+1}`:`${e+1},${t-e}`}function ip(e,t,n,{context:r,label:o=null}){let i="";for(let s of rp(n,r,e.length,t.length)){let u=o?o(s.a0):null;i+=`@@ -${ep(s.a0,s.a1)} +${ep(s.b0,s.b1)} @@${u===null?"":" "+u}
|
|
119
|
+
`;let a=s.a0,l=s.b0;for(let{a0:f,a1:c,b1:d}of s.blocks){for(;a<f;a++,l++)i+=dt(" ",e[a]);for(;a<c;a++)i+=dt("-",e[a]);for(;l<d;l++)i+=dt("+",t[l])}for(;a<s.a1;a++,l++)i+=dt(" ",e[a])}return Vs(e,t,n,i),i}function tp(e,t){return t<=e?`${e}`:t===e+1?`${e+1}`:`${e+1},${t}`}function sp(e,t,n,{context:r,label:o=null}){let i="";for(let s of rp(n,r,e.length,t.length)){let u=o?o(s.a0):null;i+=`***************${u===null?"":" "+u}
|
|
120
|
+
`,i+=`*** ${tp(s.a0,s.a1)} ****
|
|
121
|
+
`,s.blocks.some(a=>a.a0<a.a1)&&(i+=np(e,s.a0,s.a1,s.blocks,"a")),i+=`--- ${tp(s.b0,s.b1)} ----
|
|
122
|
+
`,s.blocks.some(a=>a.b0<a.b1)&&(i+=np(t,s.b0,s.b1,s.blocks,"b"))}return Vs(e,t,n,i),i}function np(e,t,n,r,o){let i=o+"1",s=o+"0",u=o==="a"?"b":"a",a="",l=t;for(let f of r){for(;l<f[s];l++)a+=dt(" ",e[l]);let c=f[u+"0"]<f[u+"1"]?"! ":o==="a"?"- ":"+ ";for(;l<f[i];l++)a+=dt(c,e[l])}for(;l<n;l++)a+=dt(" ",e[l]);return a}function Yx(e){let t=[];for(let n=0;;){let r=n;for(;n<e.length&&e[n];)n++;if(t.push(n>r),n===e.length)return t;n++}}function Ks(e,t,n){let r=t.length,o=Yx(n),i=0,s=0,u=0,a=()=>{if(i===r||e[u]!==e[i])return!1;for(t[u++]=0,t[i++]=1,s++;i<r&&t[i];)i++;return!0},l=()=>{if(u===0||e[u-1]!==e[i-1])return!1;for(t[--u]=1,t[--i]=0,s--;u>0&&t[u-1];)u--;return!0};for(let f=0;f<r;f++){if(!t[f]){s++;continue}for(u=f,i=f;i<r&&t[i];i++);let c=-1;for(let d=-1;d!==i-u;){for(d=i-u;l(););for(c=o[s]?i:-1;a();)o[s]&&(c=i)}if(c!==-1)for(let d=i-c;d>0;d--)l();f=i-1}}function Vx(e){let t=1;for(let n=e;n!==0;n>>=2)t<<=1;return Math.max(256,t)}function up(e,t,{ignoreCase:n=!1,whitespace:r="none",minimal:o=!1,slide:i=!0}={}){let s=bo({ignoreCase:n,whitespace:r});if(s===null&&Js(e,t,null))return[];let{A:u,B:a}=Kx(e,t,s),l=new Uint8Array(u.length),f=new Uint8Array(a.length);Jx(u,a,l,f,o),i&&(Ks(u,l,f),Ks(a,f,l));let c=t2(l,f);return n2(e,t,c,s),c}function Js(e,t,n=null){if(e.length!==t.length)return!1;let r=n?(o,i)=>n(o)===n(i):(o,i)=>o===i;for(let o=0;o<e.length;o++)if(!r(e[o],t[o]))return!1;return!0}function Kx(e,t,n){let r=new Map,o=u=>{let a=n?n(u):u,l=r.get(a);return l===void 0&&(l=r.size,r.set(a,l)),l},i=new Int32Array(e.length),s=new Int32Array(t.length);for(let u=0;u<e.length;u++)i[u]=o(e[u]);for(let u=0;u<t.length;u++)s[u]=o(t[u]);return{A:i,B:s}}function Jx(e,t,n,r,o){let i=e.length+t.length+3,s={A:e,B:t,fd:new Int32Array(i),bd:new Int32Array(i),base:t.length+1,limit:Vx(e.length+t.length)},u=[{xoff:0,xlim:e.length,yoff:0,ylim:t.length,minimal:o}],a={xmid:0,ymid:0,loMinimal:!1,hiMinimal:!1};for(;u.length;){let{xoff:l,xlim:f,yoff:c,ylim:d,minimal:p}=u.pop();for(;l<f&&c<d&&e[l]===t[c];)l++,c++;for(;l<f&&c<d&&e[f-1]===t[d-1];)f--,d--;if(l===f){for(;c<d;c++)r[c]=1;continue}if(c===d){for(;l<f;l++)n[l]=1;continue}Qx(s,l,f,c,d,p,a),u.push({xoff:a.xmid,xlim:f,yoff:a.ymid,ylim:d,minimal:a.hiMinimal}),u.push({xoff:l,xlim:a.xmid,yoff:c,ylim:a.ymid,minimal:a.loMinimal})}}function Qx(e,t,n,r,o,i,s){let{A:u,B:a,fd:l,bd:f,base:c,limit:d}=e,p=n-r,h=t-o,m=n-o,g=t-r,w=m,y=m,k=g,S=g,I=(g-m&1)!==0;l[c+g]=t,f[c+m]=n;for(let M=1;;M++){S>h?l[c+--S-1]=-1:++S,k<p?l[c+ ++k+1]=-1:--k;for(let C=k;C>=S;C-=2){let H=l[c+C+1],Y=l[c+C-1],D=Y<H?H:Y+1,de=D-C;for(;D<n&&de<o&&u[D]===a[de];)D++,de++;if(l[c+C]=D,I&&y<=C&&C<=w&&f[c+C]<=D){s.xmid=D,s.ymid=de,s.loMinimal=s.hiMinimal=!0;return}}y>h?f[c+--y-1]=2147483647:++y,w<p?f[c+ ++w+1]=2147483647:--w;for(let C=w;C>=y;C-=2){let H=f[c+C+1],Y=f[c+C-1],D=Y<H?Y:H-1,de=D-C;for(;t<D&&r<de&&u[D-1]===a[de-1];)D--,de--;if(f[c+C]=D,!I&&S<=C&&C<=k&&D<=l[c+C]){s.xmid=D,s.ymid=de,s.loMinimal=s.hiMinimal=!0;return}}if(!(i||M<d)){e2(e,{xoff:t,xlim:n,yoff:r,ylim:o,fmin:S,fmax:k,bmin:y,bmax:w},s);return}}}function e2(e,t,n){let{fd:r,bd:o,base:i}=e,{xoff:s,xlim:u,yoff:a,ylim:l,fmin:f,fmax:c,bmin:d,bmax:p}=t,h=0,m=-1;for(let y=c;y>=f;y-=2){let k=Math.min(r[i+y],u),S=k-y;l<S&&(k=l+y,S=l),m<k+S&&(m=k+S,h=k)}let g=0,w=2147483647;for(let y=p;y>=d;y-=2){let k=Math.max(s,o[i+y]),S=k-y;S<a&&(k=a+y,S=a),k+S<w&&(w=k+S,g=k)}u+l-w<m-(s+a)?(n.xmid=h,n.ymid=m-h,n.loMinimal=!0,n.hiMinimal=!1):(n.xmid=g,n.ymid=w-g,n.loMinimal=!1,n.hiMinimal=!0)}function t2(e,t){let n=[],r=t.length,o=e.length,i=0,s=0;for(;i<o||s<r;){if(i<o&&s<r&&!e[i]&&!t[s]){i++,s++;continue}let u=i,a=s;for(;i<o&&e[i];)i++;for(;s<r&&t[s];)s++;if(u===i&&a===s)throw new ve("a kept line has no counterpart");n.push({a0:u,a1:i,b0:a,b1:s})}return n}function n2(e,t,n,r=null){let o=r?(u,a)=>r(u)===r(a):(u,a)=>u===a,i=0,s=0;for(let{a0:u,a1:a,b0:l,b1:f}of n){if(u<i||l<s||a<u||f<l||a>e.length||f>t.length)throw new ve("a block is out of order or out of range");if(u===a&&l===f)throw new ve("a block changes nothing");if(u-i!==l-s)throw new ve("the kept lines before a block differ in count");for(;i<u;i++,s++)if(!o(e[i],t[s]))throw new ve(`kept line ${i+1} does not match`);i=a,s=f}if(e.length-i!==t.length-s)throw new ve("the kept lines after the last block differ in count");for(;i<e.length;i++,s++)if(!o(e[i],t[s]))throw new ve(`kept line ${i+1} does not match`)}var ve=class extends Error{constructor(t){super(`the computed change set does not reconstruct the second file (${t})`),this.name="DiffError"}};var r2={unified:ip,context:sp},ap=`Files differ
|
|
123
|
+
`;function o2(e,t,n){if(e===t)return"";let r=bo(n);return r===null?ap:Js(At(e),At(t),r)?"":ap}function nr(e,t,{format:n="unified",context:r=3,label:o=null,...i}={}){if(n==="brief")return o2(e,t,i);let s=At(e),u=At(t),{slide:a=n!=="normal"&&r>0,...l}=i,f=up(s,u,{...l,slide:a});return f.length===0?"":n==="normal"?op(s,u,f):r2[n](s,u,f,{context:r,label:o})}var i2=[" 1970-01-01 00:00:00.000000000 +0000"," Thu Jan 1 00:00:00 1970"];function lp(e,t,n,r,o){let{ctx:i,opts:s}=e,u=s2(s,t);if(u==="")return"";let a=c=>s.labels[c]??bs(n[c],i)+(r[c]?i2[s.style==="context"?1:0]:""),l=c=>s.labels[c]??bs(n[c],i),f=o?`diff${s.switches} ${l(0)} ${l(1)}
|
|
117
124
|
`:"";return s.style==="unified"?`${f}--- ${a(0)}
|
|
118
125
|
+++ ${a(1)}
|
|
119
126
|
${u}`:s.style==="context"?`${f}*** ${a(0)}
|
|
120
127
|
--- ${a(1)}
|
|
121
|
-
${u}`:f+u}function
|
|
122
|
-
diff: Try 'diff --help' for more information.`,2);function
|
|
123
|
-
`,1)}}function
|
|
124
|
-
`):
|
|
125
|
-
`,2,!0)}if(
|
|
126
|
-
`);else if(r===
|
|
127
|
-
`,1)}}var
|
|
128
|
-
`,2,!0)}else{let d=
|
|
129
|
-
`,2,!0):
|
|
130
|
-
`,2,!0),l=!0);if(l)return;if(s[0].identity!==void 0&&s[0].identity===s[1].identity&&!u[0])return
|
|
131
|
-
`,1);if(s.some(p=>p.content===void 0)){if(
|
|
132
|
-
`,1)}for(let[p,h]of s.entries())h.content===void 0&&
|
|
133
|
-
`,1);let d;try{d=
|
|
134
|
-
`)}var
|
|
135
|
-
`)
|
|
136
|
-
`;h&&(d=n);let g=m[0],
|
|
137
|
-
`?g=" ":
|
|
138
|
-
`?
|
|
128
|
+
${u}`:f+u}function s2(e,t){let n=e.showFunction?Ge(t[0]):null;return nr(t[0],t[1],{format:e.style??"normal",context:e.context,label:n?r=>a2(n,r):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace})}var u2=/^[A-Za-z$_]/u;function a2(e,t){for(let n=t-1;n>=0;n--){if(!u2.test(e[n]))continue;let r=A(e[n].replace(/\n$/u,"")),o=Math.min(40,r.length);for(;o>0&&l2(r[o-1]);)o--;return f2(r.subarray(0,o))}return null}var l2=e=>e===32||e>=9&&e<=13;function f2(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return W(e.subarray(0,t))}catch{}return""}var c2=["q","s","r","N","a","i","w","b","Z","p","d","u","c","e","n","y","t","T","l","E","B","P","v","H"],d2=["brief","report-identical-files","recursive","new-file","text","ignore-case","ignore-all-space","ignore-space-change","ignore-trailing-space","strip-trailing-cr","show-c-function","minimal","normal","unified","context","ed","rcs","side-by-side","expand-tabs","initial-tab","paginate","ignore-tab-expansion","ignore-blank-lines","unidirectional-new-file","version","help","suppress-common-lines","speed-large-files","ignore-file-name-case","no-ignore-file-name-case","no-dereference","left-column"],fp=["U","C","x","X","S","F","W","I","D"],cp=["show-function-line","exclude-from","starting-file","from-file","to-file","ifdef","width","tabsize","horizon-lines","ignore-matching-lines","line-format","old-line-format","new-line-format","unchanged-line-format","old-group-format","new-group-format","unchanged-group-format","changed-group-format","color","palette"],p2=["L","label","x","exclude"],h2=new Map([["e","ed script output"],["ed","ed script output"],["n","RCS output"],["rcs","RCS output"],["y","side-by-side output"],["side-by-side","side-by-side output"],["W","side-by-side output"],["width","side-by-side output"],["suppress-common-lines","side-by-side output"],["left-column","side-by-side output"],["t","tab expansion"],["expand-tabs","tab expansion"],["T","initial tabs"],["initial-tab","initial tabs"],["tabsize","tab expansion"],["E","tab expansion"],["ignore-tab-expansion","tab expansion"],["B","ignoring blank lines"],["ignore-blank-lines","ignoring blank lines"],["I","ignoring matching lines"],["ignore-matching-lines","ignoring matching lines"],["D","merged #ifdef output"],["ifdef","merged #ifdef output"],["l","pagination"],["paginate","pagination"],["F","a custom function regex"],["show-function-line","a custom function regex"],["X","reading exclusions from a file"],["exclude-from","reading exclusions from a file"],["S","a starting file"],["starting-file","a starting file"],["from-file","comparing one file to many"],["to-file","comparing one file to many"],["P","one-sided new files"],["unidirectional-new-file","one-sided new files"],["v","a version banner"],["version","a version banner"],["help","a help text"],["H","large-file heuristics"],["speed-large-files","large-file heuristics"],["horizon-lines","the horizon setting"],["ignore-file-name-case","case-insensitive names"],["no-ignore-file-name-case","case-insensitive names"],["no-dereference","symbolic links"],["color","colored output"],["palette","colored output"],["line-format","custom line formats"],["old-line-format","custom line formats"],["new-line-format","custom line formats"],["unchanged-line-format","custom line formats"],["old-group-format","custom group formats"],["new-group-format","custom group formats"],["unchanged-group-format","custom group formats"],["changed-group-format","custom group formats"]]),rr=e=>x(`diff: ${e}
|
|
129
|
+
diff: Try 'diff --help' for more information.`,2);function m2(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--"){t.push(...e.slice(n));break}if(r==="--unified"||r==="--context")t.push("-"+(r==="--unified"?"u":"c"));else if(r.startsWith("--unified=")||r.startsWith("--context="))t.push(r.startsWith("--u")?"-U":"-C",r.slice(10));else{if(r.startsWith("--color"))return{refused:"colored output",label:r};t.push(r)}}return{tokens:t}}function dp(e){let t=m2(e);if(t.refused)return{refused:v("option","diff",t.label.replace(/=.*/u,""),`diff: ${t.label}: ${t.refused} is not supported`,2)};let n;try{n=N(t.tokens,{short:c2,long:d2,valueShort:fp,valueLong:cp,repeatable:p2})}catch(o){let i=O(o);return i?{refused:v(i.kind,"diff",i.detail,`diff: ${o.message}`,2)}:{error:rr(o.message)}}let r={style:null,context:-1,labels:[],excludes:[],whitespace:"none",switches:y2(e)};for(let{name:o,value:i}of n.order){let s=h2.get(o),u=(o.length===1?"-":"--")+o;if(s)return{refused:v("option","diff",u,`diff: ${u}: ${s} is not supported`,2)};let a=g2(r,o,i);if(a)return{error:a}}return r.showFunction&&r.style===null&&(r.style="context"),r.context<0&&(r.context=3),n.positional.length<2?{error:rr(`missing operand after '${n.positional[0]??"diff"}'`)}:n.positional.length>2?{error:rr(`extra operand '${n.positional[2]}'`)}:{opts:r,operands:n.positional}}function g2(e,t,n){let r=o=>e.style!==null&&e.style!==o?rr("conflicting output style options"):(e.style=o,null);switch(t){case"u":case"c":{let o=r(t==="u"?"unified":"context");return e.context<3&&(e.context=3),o}case"U":case"C":{let o=w2(n);if(o===null)return rr(`invalid context length '${n}'`);let i=r(t==="U"?"unified":"context");return e.context<o&&(e.context=o),i}case"normal":return r("normal");case"q":case"brief":return e.brief=!0,null;case"s":case"report-identical-files":return e.identical=!0,null;case"r":case"recursive":return e.recursive=!0,null;case"N":case"new-file":return e.newFile=!0,null;case"a":case"text":return e.text=!0,null;case"i":case"ignore-case":return e.ignoreCase=!0,null;case"w":case"ignore-all-space":return e.whitespace="all",null;case"b":case"ignore-space-change":return e.whitespace!=="all"&&(e.whitespace="change"),null;case"Z":case"ignore-trailing-space":return e.whitespace==="none"&&(e.whitespace="trailing"),null;case"strip-trailing-cr":return e.stripCr=!0,null;case"p":case"show-c-function":return e.showFunction=!0,null;case"d":case"minimal":return e.minimal=!0,null;case"L":case"label":return e.labels.length===2?x("diff: too many file label options",2):(e.labels.push(n),null);case"x":case"exclude":return e.excludes.push(n),null;default:return null}}function w2(e){if(e==="")return 0;let t=be(e,"diff");return t.error?null:t.value}function y2(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--")break;!r.startsWith("-")||r==="-"||(t.push(r),b2(r)&&n+1<e.length&&t.push(e[++n]))}return t.map(n=>" "+oe(n,{vars:new Map})).join("")}function b2(e){if(e.startsWith("--"))return!e.includes("=")&&(cp.includes(e.slice(2))||e==="--label"||e==="--exclude");for(let t=1;t<e.length;t++){let n=e[t];if(fp.includes(n)||n==="L")return t+1===e.length}return!1}function So(e,t,n){let{ctx:r,opts:o}=e,i=v2(mp(e,t),mp(e,n));for(let[s,u,a]of i){let l=vo(t,s),f=vo(n,s),c=u?hp(r,l):null,d=a?hp(r,f):null;if(u&&a){k2(e,[l,f],[c,d]);continue}o.newFile?x2(e,[l,f],c??d,[u,a]):Se(e,`Only in ${u?t:n}: ${s}
|
|
130
|
+
`,1)}}function x2(e,[t,n],r,o){ko(r)?e.opts.recursive?gp(e,[t,n],o.map(i=>i?r:null)):Se(e,`Common subdirectories: ${t} and ${n}
|
|
131
|
+
`):or(e,t,n,!0,o)}function k2(e,[t,n],[r,o]){let{opts:i}=e,s=[r,o].indexOf("gone");if(s!==-1&&ko([r,o][1-s])){let u=[t,n][s];return Se(e,`diff: ${u}: ${E(e.ctx.cwd,u,e.ctx.fs).error}
|
|
132
|
+
`,2,!0)}if(ko(r)&&ko(o))i.recursive?gp(e,[t,n],[r,o]):Se(e,`Common subdirectories: ${t} and ${n}
|
|
133
|
+
`);else if(r===o||s!==-1)or(e,t,n,!0,[!0,!0]);else{let u=(a,l)=>i.labels[a]??l;Se(e,`File ${u(0,t)} is a ${pp[r]} while file ${u(1,n)} is a ${pp[o]}
|
|
134
|
+
`,1)}}var pp={dir:"directory",link:"directory",file:"regular file"},ko=e=>e==="dir"||e==="link";function hp(e,t){let n=E(e.cwd,t,e.fs);return n.error?"gone":e.fs.isDir(n.path)?e.fs.isLink?.(E(e.cwd,t,e.fs,{follow:!1}).path)?"link":"dir":"file"}function gp(e,[t,n],[r,o]){for(let[i,s]of[[r,t],[o,n]])if(i==="link")throw new b("feature","symbolic link to a directory",`comparing what a symbolic link to a directory holds is not supported: ${s}`);So(e,t,n)}function mp(e,t){let{ctx:n,opts:r}=e,o=E(n.cwd,t,n.fs);if(o.error||!n.fs.isDir(o.path))return[];let{dirs:i,files:s,links:u}=n.fs.listDir(o.path),a=[...i,...s,...u].sort(j);return r.excludes.length?a.filter(l=>!r.excludes.some(f=>Jf(l,f))):a}function v2(e,t){let n=[],r=0,o=0;for(;r<e.length||o<t.length;){let i=r===e.length?1:o===t.length?-1:j(e[r],t[o]);i===0?(n.push([e[r++],!0,!0]),o++):i<0?n.push([e[r++],!0,!1]):n.push([t[o++],!1,!0])}return n}function xp(e,t,n){let r=dp(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:o,operands:i}=r,s={ctx:n,opts:o,stdin:e,out:U(),status:0},[u,a]=i,l=i.map(f=>wp(s,f));if(l[0]==="dir"&&l[1]==="dir"&&S2(s,u,a))return s.out;if(l[0]==="dir"&&l[1]==="dir")So(s,u,a);else if(l[0]==="dir"||l[1]==="dir"){let f=l[0]==="dir"?0:1,c=i[1-f];if(c==="-")return x("diff: cannot compare '-' to a directory",2);if(l[1-f]==="missing"){let d=E(s.ctx.cwd,c,s.ctx.fs).error;o.newFile&&d==="No such file or directory"?So(s,u,a):Se(s,`diff: ${c}: ${d}
|
|
135
|
+
`,2,!0)}else{let d=vo(i[f],nt(c)),p=f===0?[d,c]:[c,d];wp(s,d)==="missing"?Se(s,`diff: ${d}: No such file or directory
|
|
136
|
+
`,2,!0):or(s,p[0],p[1],!1)}}else or(s,u,a,!1);return s.out.exitCode=s.status,s.out}function vo(e,t){let n=e.replace(/\/+$/u,"");return(n===""?"/":n+"/")+t}function S2(e,t,n){return E(e.ctx.cwd,t,e.ctx.fs).path===E(e.ctx.cwd,n,e.ctx.fs).path}function wp(e,t){if(t==="-")return"stdin";let n=E(e.ctx.cwd,t,e.ctx.fs);return n.error?"missing":e.ctx.fs.isDir(n.path)?"dir":"file"}function Se(e,t,n=0,r=!1){_(e.out,r?U(t):{...U(),stdout:t,events:[{fd:1,text:t}]}),e.status=Math.max(e.status,n)}function or(e,t,n,r,o=null){let{opts:i}=e,s=[t,n].map(p=>N2(e,p)),u=s.map(p=>p.content===null),a=i.newFile&&!(u[0]&&u[1]),l=!1;for(let p=0;p<2;p++)!u[p]||(o?!o[p]:a)||(Se(e,`diff: ${[t,n][p]}: ${s[p].error??"No such file or directory"}
|
|
137
|
+
`,2,!0),l=!0);if(l)return;if(s[0].identity!==void 0&&s[0].identity===s[1].identity&&!u[0])return ir(e,t,n);let f=p=>i.labels[p]??[t,n][p];if(!i.text&&s.some($2))return yp(s)?ir(e,t,n):Se(e,`${i.brief?"Files":"Binary files"} ${f(0)} and ${f(1)} differ
|
|
138
|
+
`,1);if(s.some(p=>p.content===void 0)){if(yp(s))return ir(e,t,n);if(i.brief&&!i.ignoreCase&&!i.stripCr&&i.whitespace==="none")return Se(e,`Files ${f(0)} and ${f(1)} differ
|
|
139
|
+
`,1)}for(let[p,h]of s.entries())h.content===void 0&&rt(h.bytes,JSON.stringify(f(p)));let c=s.map(p=>p.content??"");if(i.stripCr&&(c=c.map(E2)),i.brief)return nr(c[0],c[1],{format:"brief",ignoreCase:i.ignoreCase,whitespace:i.whitespace})===""?ir(e,t,n):Se(e,`Files ${f(0)} and ${f(1)} differ
|
|
140
|
+
`,1);let d;try{d=lp(e,c,[t,n],u,r)}catch(p){if(!(p instanceof ve)&&!(p instanceof We))throw p;let h=`diff: ${t} ${n}: ${p.message}`,m=p instanceof ve?"change set verification":"diff rendering verification";_(e.out,v("feature","diff",m,h,2)),e.status=2;return}if(d==="")return ir(e,t,n);Se(e,d,1)}function ir(e,t,n){e.opts.identical&&Se(e,`Files ${t} and ${n} are identical
|
|
141
|
+
`)}var E2=e=>e.replace(/\r\n/gu,`
|
|
142
|
+
`),$2=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes("\0")===!0,yp=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:An(e.bytes??bp,t.bytes??bp),bp=new Uint8Array;function N2(e,t){let{ctx:n}=e;if(t==="-")return q(n),{content:e.stdin,identity:n.stdinHandle?.identity??Symbol("stdin")};let r=P(n,"diff",t);if(r.error||n.fs.isDir(r.path))return{content:null,bytes:null,identity:void 0,error:r.error};let{text:o,bytes:i}=wt(n.fs,r.path);return{content:o,bytes:i,identity:n.fs.fileIdentity?.(r.path)??r.path}}var pn=(e,t,n)=>{throw new Q(`malformed patch at line ${Math.min(t,e.lines.length-1)+1}: ${n??""}`)};function sr(e,t){return!!e.lines[t+1]?.startsWith("\\")}function Sp(e){let{lines:t}=e,n=e.pos,r=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: (.*))?\n$/u.exec(t[n]??"");if(!r)return null;let o=n,i=Number(r[3]),s=Number(r[1]),u=r[2]===void 0?1:Number(r[2]),a=r[4]===void 0?1:Number(r[4]);u===0&&s++,a===0&&i++;let l=[],f=[],c=0,d=n,p=-1;for(n++;f.length<u||l.length<a;n+=1){let h=t[n]!==void 0;if(!h&&a-l.length>3)throw new Q("unexpected end of file in patch");let m=h?t[n]:`
|
|
143
|
+
`;h&&(d=n);let g=m[0],w=m;g===" "||g===`
|
|
144
|
+
`?g=" ":w=m.slice(1),g!=="-"&&g!=="+"&&g!==" "&&pn(e,n,m);let y=!1;g!=="+"&&(f.length>=u&&pn(e,n,m),y=h&&f.length+1===u&&sr(e,n),y&&(w=w.replace(/\n$/u,"")),f.push({tag:g,text:w}),g===" "&&c++),g!=="-"&&(l.length>=a&&pn(e,n,m),!y&&h&&l.length+1===a&&sr(e,n)&&(y=!0,w=w.replace(/\n$/u,"")),l.push({tag:g,text:w})),g!==" "&&(p===-1&&(p=c),c=0),y&&n++}return p===-1&&pn(e,d,t[d]),e.pos=n,{oldStart:s,oldLines:f,newStart:i,newLines:l,prefix:p,suffix:c,fn:r[5]===void 0?null:" "+r[5],marks:null,line:o}}function Qs(e){let{lines:t}=e,n=e.pos;if(!t[n]?.startsWith("********"))return null;let r=n,o=/^\*+( .*)?\n$/u.exec(t[n])?.[1]??null,i=/^\*\*\* (\d+)(?:,(\d+))?/u.exec(t[++n]??"");if(!i)throw new Q(`unexpected '***' at line ${n+1}: ${t[n]??""}`);let s=kp(i),u=[],a=c=>/^--- (\d+)(?:,(\d+))? ----/u.exec(t[c]??"")??/^--- (\d+)(?:,(\d+))?/u.exec(t[c]??"");for(n++;!a(n);n++){if(t[n]===void 0||u.length>=s.count)throw new Q(`no '---' found in patch at line ${r+1}`);u.push(vp(e,n,u.length+1===s.count)),u.at(-1).skip&&n++}let l=kp(a(n)),f=[];for(n++;f.length<l.count;n++){let c=t[n];if(c===void 0||!/^[ !+\-\t\n]/u.test(c)||c.startsWith("***"))break;f.push(vp(e,n,f.length+1===l.count)),f.at(-1).skip&&n++}return f.length!==0&&f.length<l.count&&pn(e,n,t[n]),e.pos=n,A2({oldRange:s,oldSide:u,newRange:l,newSide:f,fn:o,line:r})}function kp(e){let t=Number(e[1]),n=e[2]===void 0?t:Number(e[2]);return t===0&&e[2]===void 0?{first:1,count:0}:{first:t,count:n-t+1}}function vp(e,t,n){let r=e.lines[t],o=r[0];o===" "||o===`
|
|
145
|
+
`?o=" ":(r=r.slice(1),(r[0]===" "||r[0]===" ")&&(r=r.slice(1)));let i=n&&sr(e,t);return{mark:o,text:i?r.replace(/\n$/u,""):r,skip:i}}function A2({oldRange:e,oldSide:t,newRange:n,newSide:r,fn:o,line:i}){let s=r,u=t;if(t.length===0&&e.count&&(u=r.filter(p=>p.mark===" ")),r.length===0&&n.count&&(s=t.filter(p=>p.mark===" ")),u.length!==e.count||s.length!==n.count)throw new Q(`replacement text or line numbers mangled in hunk at line ${i+1}`);let a=u.map(p=>({tag:p.mark===" "?" ":"-",text:p.text})),l=s.map(p=>({tag:p.mark===" "?" ":"+",text:p.text})),f=p=>{let h=0;for(let m of p){if(m.tag!==" ")break;h++}return h},c=Math.min(f(a),f(l)),d=Math.min(f(a.toReversed()),f(l.toReversed()));if(a.every(p=>p.tag===" ")&&l.every(p=>p.tag===" "))throw new Q(`replacement text or line numbers mangled in hunk at line ${i+1}`);return{oldStart:e.first,oldLines:a,newStart:n.first,newLines:l,prefix:c,suffix:d,fn:o,marks:{old:u.map(p=>p.mark),new:s.map(p=>p.mark)},line:i}}function Ep(e){let{lines:t}=e,n=e.pos,r=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n$/u.exec(t[n]??"");if(!r)return null;let o=n,i=Number(r[1]),s=r[3]==="a"?0:r[2]===void 0?1:Number(r[2])-i+1;r[3]==="a"&&i++;let u=Number(r[4]),a=r[5]===void 0?u:Number(r[5]);r[3]==="d"&&u++;let l=a-u+1;(s<0||l<0)&&pn(e,n,t[n]);let f=[],c=[];n++;for(let d=0;d<s;d++,n++){if(t[n]===void 0)throw new Q(`unexpected end of file in patch at line ${n}`);if(!/^<[ \t]/u.test(t[n]))throw new Q(`'<' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===s&&sr(e,n);c.push({tag:"-",text:p?t[n].slice(2).replace(/\n$/u,""):t[n].slice(2)}),p&&n++}if(r[3]==="c"){if(t[n]===void 0)throw new Q(`unexpected end of file in patch at line ${n}`);if(!t[n].startsWith("-"))throw new Q(`'---' expected at line ${n+1} of patch`);n++}for(let d=0;d<l;d++,n++){if(t[n]===void 0)throw new Q(`unexpected end of file in patch at line ${n}`);if(!/^>[ \t]/u.test(t[n]))throw new Q(`'>' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===l&&sr(e,n);f.push({tag:"+",text:p?t[n].slice(2).replace(/\n$/u,""):t[n].slice(2)}),p&&n++}return e.pos=n,{oldStart:i,oldLines:c,newStart:u,newLines:f,prefix:0,suffix:0,fn:null,marks:null,line:o}}function Eo(e){let t=(r,o,i)=>r.map(s=>({tag:s.tag===o?i:s.tag,text:s.text})),n=(r,o,i)=>r.map(s=>s===o?i:s);return{...e,oldStart:e.newStart,newStart:e.oldStart,oldLines:t(e.newLines,"+","-"),newLines:t(e.oldLines,"-","+"),marks:e.marks&&{old:n(e.marks.new,"+","-"),new:n(e.marks.old,"-","+")}}}var Q=class extends Error{constructor(t){super(t),this.name="PatchFatal"}},hn=(e,t)=>{throw new b("feature",e,t)};function Cp(e){let t=Ge(e);return t.length&&!t.at(-1).endsWith(`
|
|
139
146
|
`)&&(t[t.length-1]+=`
|
|
140
|
-
`),{lines:t,pos:0,base:0,empty:e===""}}var
|
|
141
|
-
`)&&(d.startsWith("@@ -")||f)&&
|
|
142
|
-
`&&
|
|
143
|
-
`,l+1)!==-1))break}
|
|
144
|
-
`,r:"\r",t:" ",v:"\v","\\":"\\",'"':'"'};function
|
|
147
|
+
`),{lines:t,pos:0,base:0,empty:e===""}}var O2=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u,$p=/^(?:\d+(?:,\d+)?)?(?:[acdi]|s\/\.\/\/)[ \t]*\n$/u,Np=/^[0-9a-fA-F]+/u;function Ip(e,{needHeader:t,strip:n,format:r}){let{lines:o}=e,i={names:{old:null,new:null,index:null},stamps:{old:-1,new:-1},timestrs:{old:null,new:null},says:[0,0],git:!1,rename:[!1,!1],copy:[!1,!1],extended:!1},s=t&&r!=="normal"&&r!=="ed",u=!1,a=-1,l=!1,f=!1;for(let c=e.pos;;c++){if(c>=o.length)return u&&hn("ed script","ed scripts are not supported"),i.extended?{...i,type:"unified",start:c,hunkLine:c,empty:!0}:null;let d=o[c],p=d.replace(/^[ \tX]+/u,""),h=/^\d/u.test(p)&&O2.test(p);!s&&a<0&&($p.test(p)||h)&&(a=c,u=$p.test(p));let m=C2(d,i,n,f);if(m==="binary"&&hn("git binary patch","git binary diffs are not supported"),m==="prereq"&&hn("Prereq","Prereq: lines are not supported"),m==="git"&&i.extended)return{...i,type:"unified",start:c,hunkLine:c,empty:!0};m&&(s=!1);let g=d.startsWith("********");if(/^[ \t]+(?:@@ -\d|\*{8})/u.test(d)&&hn("indented patch","indented patches are not supported"),!s){if(d.endsWith(`\r
|
|
148
|
+
`)&&(d.startsWith("@@ -")||f)&&hn("CRLF patch","patches with CRLF line endings are not supported"),(r===null||r==="ed")&&a>=0&&d===`.
|
|
149
|
+
`&&hn("ed script","ed scripts are not supported"),(r===null||r==="unified")&&d.startsWith("@@ -"))return T2(i,c,d);if((r===null||r==="context")&&f&&d.startsWith("*** "))return F2(e,i,c,d);if((r===null||r==="normal")&&l&&(d.startsWith("< ")||d.startsWith("> ")))return{...i,type:"normal",start:c-1,hunkLine:c-1}}f=g,l=h}}function C2(e,t,n,r){if(!r&&e.startsWith("*** ")||e.startsWith("+++ "))return eu(t,"old",e.slice(4),n);if(e.startsWith("Index:"))return t.names.index=Fp(e.slice(6),n,!1).name,"index";if(e.startsWith("Prereq:"))return"prereq";if(e.startsWith("diff --git ")){let i=Ap(e.slice(11),n),s=i.name===null?null:Ap(i.rest,n);return t.names.old=s&&s.rest.trim()===""?i.name:null,t.names.new=t.names.old===null?null:s.name,t.git=!0,t.stamps.old=t.stamps.new=-1,"git"}if(t.git){let i=I2(e,t);if(i)return i}let o=e;for(;o.startsWith("- ");)o=o.slice(2);return o.startsWith("--- ")?eu(t,"new",o.slice(4),n):null}function I2(e,t){if(e.startsWith("index ")){let n=Np.exec(e.slice(6)),r=n?e.slice(6+n[0].length):"",o=r.startsWith("..")?Np.exec(r.slice(2)):null;return o?(t.says[0]=/^0+$/u.test(n[0])?2:0,t.says[1]=/^0+$/u.test(o[0])?2:0,t.extended=!0,"index"):null}return e.startsWith("old mode ")||e.startsWith("new mode ")?(t.extended=!0,"mode"):e.startsWith("deleted file mode ")?(t.says[1]=2,t.extended=!0,"mode"):e.startsWith("new file mode ")?(t.says[0]=2,t.extended=!0,"mode"):e.startsWith("rename from ")?(t.rename[0]=!0,t.extended=!0,"rename"):e.startsWith("rename to ")?(t.rename[1]=!0,t.extended=!0,"rename"):e.startsWith("copy from ")?(t.copy[0]=!0,t.extended=!0,"copy"):e.startsWith("copy to ")?(t.copy[1]=!0,t.extended=!0,"copy"):e.startsWith("GIT binary patch")?"binary":null}function eu(e,t,n,r){let o=Fp(n,r,!0);return o.stamp!==void 0&&(e.stamps[t]=o.stamp),o.name!==void 0&&(e.names[t]=o.name,e.timestrs[t]=o.timestr),"name"}function T2(e,t,n){let r={names:{...e.names,old:e.names.new,new:e.names.old},stamps:{old:e.stamps.new,new:e.stamps.old},timestrs:{old:e.timestrs.new,new:e.timestrs.old}},o=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/u.exec(n),i=[...e.says];return o&&o[1]==="0"&&(i[0]=1+(r.stamps.old===0?1:0)),o&&o[3]==="0"&&(i[1]=1+(r.stamps.new===0?1:0)),{...e,...r,says:i,type:"unified",start:t,hunkLine:t}}function F2(e,t,n,r){let o=[...t.says];/^\*\*\* 0(?!\d)/u.test(r)&&(o[0]=1+(t.stamps.old===0?1:0));let i={...e,pos:n-1};try{let s=Qs(i);s&&s.newLines.length===0&&s.newStart===1&&(o[1]=1+(t.stamps.new===0?1:0))}catch{}return{...t,says:o,type:"context",start:n-1,hunkLine:n-1}}function Tp(e,t){return t==="unified"?Sp(e):t==="context"?Qs(e):Ep(e)}function Fp(e,t,n){let r=e.replace(/^[ \t\n\v\f\r]+/u,""),o,i;if(r.startsWith('"')){let a=_p(r);if(!a)return{};o=a.value,i=a.rest}else{let a=0;for(;a<r.length;a++){if(!/[ \t\n\v\f\r]/u.test(r[a]))continue;let l=a;for(;r[l]!==" "&&/[ \t\n\v\f\r]/u.test(r[l+1]??"");)l++;if(!(r[l]!==" "&&r.indexOf(n?" ":`
|
|
150
|
+
`,l+1)!==-1))break}o=r.slice(0,a),i=r.slice(a)}if(o==="/dev/null")return{stamp:0};let s=Lp(o,t);if(s===null)return{};let u=i.replace(/\r?\n$/u,"");return{name:s,timestr:u,stamp:n&&u!==""?L2(u):-1}}function L2(e){let t=/^\s*(\d{4})-(\d\d)-(\d\d)[ T](\d\d):(\d\d):(\d\d)(?:\.\d+)?\s*(?:([+-])(\d\d):?(\d\d))?/u.exec(e),n;if(t){let[,r,o,i,s,u,a,l,f,c]=t;n=Date.UTC(Number(r),Number(o)-1,Number(i),Number(s),Number(u),Number(a))/1e3,l&&(n-=(l==="-"?-1:1)*(Number(f)*3600+Number(c)*60))}else{let r=/^\s*[A-Z][a-z]{2} ([A-Z][a-z]{2}) +(\d+) (\d\d):(\d\d):(\d\d) (\d{4})/u.exec(e);if(!r)return-1;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],[,i,s,u,a,l,f]=r;n=Date.UTC(Number(f),o.indexOf(i),Number(s),Number(u),Number(a),Number(l))/1e3}return n>-25*3600&&n<26*3600?0:n}function Lp(e,t){let n=t,r=0;for(let o=0;o<e.length;o++)if(e[o]==="/"){for(;e[o+1]==="/";)o++;(t<0||--n>=0)&&(r=o+1)}return(t<0||n<=0)&&r<e.length?e.slice(r):null}function Ap(e,t){let n=e.replace(/^[ \t\n\v\f\r]+/u,""),r,o;if(n.startsWith('"')){let i=_p(n);if(!i)return{name:null,rest:""};r=i.value,o=i.rest}else{let i=n.search(/[ \t\n\v\f\r]/u);r=i<0?n:n.slice(0,i),o=i<0?"":n.slice(i)}return{name:Lp(r,t),rest:o}}var Op={a:"\x07",b:"\b",f:"\f",n:`
|
|
151
|
+
`,r:"\r",t:" ",v:"\v","\\":"\\",'"':'"'};function _p(e){let t="";for(let n=1;n<e.length;n++){let r=e[n];if(r==='"')return{value:t,rest:e.slice(n+1)};if(r!=="\\"){t+=r;continue}let o=e[++n];if(o===void 0)return null;if(/[0-7]/u.test(o)){let i=/^[0-7]{1,3}/u.exec(e.slice(n))[0];t+=String.fromCodePoint(Number.parseInt(i,8)),n+=i.length-1}else if(o in Op)t+=Op[o];else return null}return null}function Rp(e,t){let n=i=>i.split("/").length-1,r=i=>i.slice(i.lastIndexOf("/")+1).length,o=-1;for(let i=0;i<e.length;i++){let s=e[i];if(s===null||t[i])continue;if(o===-1){o=i;continue}let[u,a]=[n(s),n(e[o])];if(u!==a){u<a&&(o=i);continue}let[l,f]=[r(s),r(e[o])];if(l!==f){l<f&&(o=i);continue}s.length<e[o].length&&(o=i)}return o}function tu(e,t){let{opts:n}=e;return(n.noReverse||!(n.force&&n.silent))&&e.say(t),n.noReverse?(e.say(` Skipping patch.
|
|
145
152
|
`),e.skipRest=!0,!1):n.force?(n.silent||e.say(` Applying it anyway.
|
|
146
153
|
`),!1):n.batch?(e.say(e.reverse?` Ignoring -R.
|
|
147
154
|
`:` Assuming -R.
|
|
@@ -149,118 +156,118 @@ diff: Try 'diff --help' for more information.`,2);function mx(e){let t=[];for(le
|
|
|
149
156
|
`:` Assume -R? [n]
|
|
150
157
|
`),e.say(`Apply anyway? [n]
|
|
151
158
|
`),n.silent||e.say(`Skipping patch.
|
|
152
|
-
`),e.skipRest=!0,!1)}function
|
|
153
|
-
which ${l}!`)&&(e.reverse=!e.reverse)}return u}function
|
|
154
|
-
`),e.skipRest=!0),
|
|
159
|
+
`),e.skipRest=!0,!1)}function Mp(e,t,n,r,o){let i=e.reverse?1:0,s=t.says,u=(o?0:1)<s[i^(o?1:0)];if(o&&s[i^(r?1:0)]===1&&s[1-i^(r?1:0)]===2)return!1;if(u){let a=r?"delete":o?"empty out":"create",l=r?"does not exist":o?"is already empty":"already exists";tu(e,`The next patch${e.reverse?", when reversed,":""} would ${a} the file ${e.quote(n)},
|
|
160
|
+
which ${l}!`)&&(e.reverse=!e.reverse)}return u}function Pp(e,t,n,r){let o=[t.names.old,t.names.new,t.names.index];(o[0]!==null||o[1]!==null)&&o[2]!==null&&(o[2]=null);let i=-1;if(n===null){let u=o.map(f=>f===null?null:r(f)),a=u.map(f=>f===null||!f.exists);i=Rp(o,a);let l=o.findIndex(f=>f!==null);if(l!==-1&&(i===-1||!u[i].isDir)){let f=i===-1;Mp(e,t,o[f?l:i],f,f||u[i].size===0)&&f&&(i=l)}i===-1&&t.says[e.reverse?1:0]&&(i=Rp(o,o.map(()=>!1)))}if((t.rename[0]||t.rename[1]||t.copy[0]||t.copy[1])&&n===null&&!((i===0||i===1)&&o[0]!==null&&o[1]!==null)&&(e.say(`Cannot ${t.rename[0]||t.rename[1]?"rename":"copy"} file without two valid file names
|
|
161
|
+
`),e.skipRest=!0),i===-1){if(n===null)return null;let u=r(n);return(!u.exists||!u.isDir)&&Mp(e,t,n,!u.exists,!u.exists||u.size===0),n}return o[i]}function Bp(e){return{input:e,frozen:0,inOffset:0,outOffset:0,out:[]}}var _2=(e,t)=>t<1||t>e.input.length?"":e.input[t-1];function R2(e,t){let n=r=>r.replace(/\n$/u,"").replace(/[ \t]+$/u,"").replace(/[ \t]+/gu," ");return n(e)===n(t)}function $o(e,t,n,r,o,i,s){let u=t.oldLines,a=u.length-i;for(let l=n+r+o,f=o;f<a;f++,l++){let c=_2(e,l),d=u[f].text;if(s?!R2(c,d):c!==d)return!1}return!0}function Dp(e,t,n,r){let o=t.oldStart+e.inOffset,i=t.oldLines.length,s=Math.max(t.prefix,t.suffix),u=n+t.prefix-s,a=n+t.suffix-s,l=e.input.length,f=l-(i-a)+1,c=e.frozen+1,d=f-o,p=o-c,h=Math.max(d,p);if(!i)return o;o<=p&&(p=o-1);let m=w=>(e.inOffset+=w,o+w);if(u<0&&t.oldStart<=1){if(a<0&&(i!==l||t.prefix<e.frozen))return 0;let w=1-o;return e.frozen<=t.prefix&&w<=d&&$o(e,t,o,w,0,a,r)?m(w):0}else u<0&&(u=0);if(a<0){let w=o-(l-i+1);return w<=p&&$o(e,t,o,-w,u,0,r)?m(-w):0}let g=d<0?o-f:p<0?o-c:0;for(let w=g;w<=h;w++){if(w<=d&&$o(e,t,o,w,u,a,r))return m(w);if(w<=p&&$o(e,t,o,-w,u,a,r))return m(-w)}return 0}function No(e,t){if(e.frozen>t)return!1;for(;e.frozen<t;)e.frozen<e.input.length&&e.out.push(e.input[e.frozen]),e.frozen++;return!0}function M2(e,t,n){let r=n-1,o=t.newLines,i=t.oldLines,s=0,u=0,a=()=>{throw new Q(`Out-of-sync patch, lines ${t.line+1+u+1},${t.line+1+i.length+s+1} -- mangled text or line numbers, maybe?`)};for(;u<i.length;)if(i[u].tag==="-"){if(!No(e,r+u))return!1;e.frozen++,u++}else{if(s>=o.length)break;if(o[s].tag==="+"){if(!No(e,r+u))return!1;e.out.push(o[s++].text)}else o[s].tag===i[u].tag?(u++,s++):a()}for(;s<o.length&&o[s].tag==="+";s++){if(!No(e,r+u))return!1;e.out.push(o[s].text)}return e.outOffset+=o.length-i.length,!0}var Up=e=>e.frozen>=e.input.length||No(e,e.input.length),jp=e=>e.map((t,n)=>n<e.length-1&&!t.endsWith(`
|
|
155
162
|
`)?t+`
|
|
156
|
-
`:t).join("");function
|
|
157
|
-
`);else if(!
|
|
158
|
-
`)}}return s}function
|
|
159
|
-
`,
|
|
160
|
-
`;return{get text(){return n},add(
|
|
161
|
-
`,
|
|
162
|
-
`;return
|
|
163
|
-
`,e.oldLines.forEach((s,u)=>{
|
|
164
|
-
`,e.newLines.forEach((s,u)=>{
|
|
165
|
-
patch: Try 'patch --help' for more information.`,2);function
|
|
163
|
+
`:t).join("");function Wp(e,t,n,r,o){let{opts:i}=e,s={count:0,failed:0,mismatch:!1,applyAnyway:!1};for(let u=n();u;u=n()){s.count++;let a=e.skipRest?{hunk:e.reverse?Eo(u):u,where:0,fuzz:0}:P2(e,r,e.reverse?Eo(u):u,s),{hunk:l,where:f,fuzz:c}=a,d=(f||l.oldStart)+r.outOffset,p=f===1&&t.says[e.reverse?1:0]===2&&r.input.length>0;if(e.skipRest||p||!f||!M2(r,l,f))e.skipRejectFile||o.add(l,s.failed===0,r.outOffset,e.reverse),s.failed++,!e.skipRest&&!i.silent&&e.say(`Hunk #${s.count} FAILED at ${d}.
|
|
164
|
+
`);else if(!i.silent&&(c||r.inOffset)){let h=r.inOffset?` (offset ${r.inOffset} line${r.inOffset===1?"":"s"})`:"";e.say(`Hunk #${s.count} succeeded at ${d}${c?` with fuzz ${c}`:""}${h}.
|
|
165
|
+
`)}}return s}function P2(e,t,n,r){let{opts:o}=e,i=0,s=n,u=0,a=Math.min(o.fuzz,Math.max(s.prefix,s.suffix));do if(u=Dp(t,s,i,o.loose),(!u||i||t.inOffset)&&(r.mismatch=!0),r.count===1&&!u&&!(o.force||r.applyAnyway)&&e.reverse===e.reverseFlag){let l=Eo(s);u=Dp(t,l,i,o.loose),u&&tu(e,`${e.reverse?"Unreversed":"Reversed (or previously applied)"} patch detected!`)?(e.reverse=!e.reverse,s=l):u&&(r.applyAnyway=!0,i--,u=0)}while(!e.skipRest&&!u&&++i<=a);return{hunk:s,where:u,fuzz:i}}var ur=(e,t)=>e+t;function Hp(e,t){let n="",r=(i,s)=>`${i} ${e.names[s]??"/dev/null"}${e.timestrs[s]??""}
|
|
166
|
+
`,o=e.names.index===null?"":`Index: ${e.names.index}
|
|
167
|
+
`;return{get text(){return n},add(i,s,u,a){let l=a?["new","old"]:["old","new"];t==="unified"?(s&&(n+=o+r("---",l[0])+r("+++",l[1])),n+=D2(i,u)):(s&&(n+=o+r("***",l[0])+r("---",l[1])),n+=B2(i,u,t))}}}var qp=(e,t)=>t===0?`${e-1},0`:t===1?`${e}`:`${e},${t}`;function D2(e,t){let n=e.newLines,r=e.oldLines,o=`@@ -${qp(e.oldStart+t,r.length)} +${qp(e.newStart+t,n.length)} @@${e.fn??""}
|
|
168
|
+
`,i=0,s=0;for(;;s++,i++){for(;s<r.length&&r[s].tag==="-";s++)o+=ur("-",r[s].text);for(;i<n.length&&n[i].tag==="+";i++)o+=ur("+",n[i].text);if(s>=r.length)break;o+=ur(" ",r[s].text)}return o}function zp(e,t){let n=e+t-1;return n<e?"0":n===e?`${e}`:`${e},${n}`}function B2(e,t,n){let r=n!=="normal",o=e.marks??(n==="normal"?U2(e):j2(e)),i=`***************${e.fn??""}
|
|
169
|
+
`;return i+=`*** ${zp(e.oldStart+t,e.oldLines.length)}${r?" ****":""}
|
|
170
|
+
`,e.oldLines.forEach((s,u)=>{i+=ur(o.old[u]+" ",s.text)}),i+=`--- ${zp(e.newStart+t,e.newLines.length)}${r?" ----":" -----"}
|
|
171
|
+
`,e.newLines.forEach((s,u)=>{i+=ur(o.new[u]+" ",s.text)}),i}var U2=e=>({old:e.oldLines.map(t=>t.tag),new:e.newLines.map(t=>t.tag)});function j2(e){let t=e.newLines.map(i=>i.tag),n=e.oldLines.map(i=>i.tag),r=0,o=0;for(;o<n.length;)if(n[o]==="-")if(r<t.length&&t[r]==="+"){do n[o++]="!";while(o<n.length&&n[o]==="-");do t[r++]="!";while(r<t.length&&t[r]==="+")}else do o++;while(o<n.length&&n[o]==="-");else if(r<t.length&&t[r]==="+")do r++;while(r<t.length&&t[r]==="+");else o++,r++;return{old:n,new:t}}var W2=["R","N","f","t","s","b","l","E","T","Z","e","u","c","n","v"],q2=["reverse","forward","force","batch","silent","quiet","backup","ignore-whitespace","remove-empty-files","dry-run","verbose","unified","context","normal","ed","binary","no-backup-if-mismatch","backup-if-mismatch","posix","follow-symlinks","help","version","set-time","set-utc"],z2=["p","i","o","d","r","F","z","B","Y","V","g","D","x"],H2=["strip","input","output","directory","reject-file","fuzz","suffix","prefix","basename-prefix","version-control","get","reject-format","quoting-style","read-only","merge","debug"],Gp=new Map([["T","setting file times"],["Z","setting file times"],["set-time","setting file times"],["set-utc","setting file times"],["e","ed scripts"],["ed","ed scripts"],["v","a version banner"],["version","a version banner"],["help","a help text"],["verbose","verbose output"],["B","backup prefixes"],["prefix","backup prefixes"],["Y","backup prefixes"],["basename-prefix","backup prefixes"],["V","numbered backups"],["version-control","numbered backups"],["g","version control"],["get","version control"],["D","merged #ifdef output"],["x","debugging output"],["debug","debugging output"],["posix","POSIX mode"],["follow-symlinks","symbolic links"],["quoting-style","quoting styles"],["read-only","read-only handling"],["merge","merging"]]),Xp=e=>x(`patch: ${e}
|
|
172
|
+
patch: Try 'patch --help' for more information.`,2);function Yp(e){for(let r of e){if(r==="--")break;let o=r.replace(/=.*/u,"");if(o==="--merge"||o==="--read-only")return{refused:v("option","patch",o,`patch: ${o}: ${Gp.get(o.slice(2))} is not supported`,2)}}let t;try{t=N(e,{short:W2,long:q2,valueShort:z2,valueLong:H2})}catch(r){let o=O(r);return o?{refused:v(o.kind,"patch",o.detail,`patch: ${r.message}`,2)}:{error:Xp(r.message)}}let n={strip:-1,input:null,output:null,directory:null,rejectFile:null,fuzz:2,suffix:".orig",format:null,rejectFormat:null,reverse:!1,noReverse:!1,force:!1,batch:!1,silent:!1,backup:!1,backupIfMismatch:!0,loose:!1,removeEmpty:!1,dryRun:!1};for(let{name:r,value:o}of t.order){let i=(r.length===1?"-":"--")+r,s=Gp.get(r);if(s)return{refused:v("option","patch",i,`patch: ${i}: ${s} is not supported`,2)};let u=G2(n,r,o);if(u)return{error:u}}return t.positional.length>2?{error:Xp(`${t.positional[2]}: extra operand`)}:{opts:n,operands:t.positional}}function Zp(e,t){if(!/^[+-]?\d+$/u.test(e))return{error:x(`patch: **** ${t} ${oe(e,{vars:new Map})} is not a number`,2)};let n=Number(e);return n<0?{error:x(`patch: **** ${t} ${e} is negative`,2)}:{value:Math.min(n,Number.MAX_SAFE_INTEGER)}}function G2(e,t,n){switch(t){case"p":case"strip":{let r=Zp(n,"strip count");return r.error?r.error:(e.strip=r.value,null)}case"F":case"fuzz":{let r=Zp(n,"fuzz factor");return r.error?r.error:(e.fuzz=r.value,null)}case"i":case"input":return e.input=n,null;case"o":case"output":return e.output=n,null;case"d":case"directory":return e.directory=n,null;case"r":case"reject-file":return e.rejectFile=n,null;case"z":case"suffix":return n===""?x("patch: **** backup suffix is empty",2):(e.suffix=n,null);case"R":case"reverse":return e.reverse=!0,null;case"N":case"forward":return e.noReverse=!0,null;case"f":case"force":return e.force=!0,null;case"t":case"batch":return e.batch=!0,null;case"s":case"silent":case"quiet":return e.silent=!0,null;case"b":case"backup":return e.backup=!0,null;case"l":case"ignore-whitespace":return e.loose=!0,null;case"E":case"remove-empty-files":return e.removeEmpty=!0,null;case"dry-run":return e.dryRun=!0,null;case"u":case"unified":return e.format="unified",null;case"c":case"context":return e.format="context",null;case"n":case"normal":return e.format="normal",null;case"no-backup-if-mismatch":return e.backupIfMismatch=!1,null;case"backup-if-mismatch":return e.backupIfMismatch=!0,null;case"reject-format":return n!=="unified"&&n!=="context"?x(`patch: **** unknown reject format ${n}`,2):(e.rejectFormat=n,null);default:return null}}function Kp(e,t,n){let r=Yp(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:o,operands:i}=r,s={ctx:n,opts:o,dir:n.cwd,events:[],stdout:"",stderr:"",skipRest:!1,skipRejectFile:!1,reverse:o.reverse,reverseFlag:o.reverse,someFailed:!1,rejectsMade:new Set,output:""},u=o.output==="-"?2:1;s.quote=a=>oe(a,n),s.say=a=>{u===1?s.stdout+=a:s.stderr+=a,s.events.push({fd:u,text:a})};try{if(o.directory!==null){let l=E(n.cwd,o.directory,n.fs);if(l.error||!n.fs.isDir(l.path))throw new Q(`Can't change to directory ${oe(o.directory,n)} : ${l.error??"Not a directory"}`);s.dir=l.path}let a=X2(s,e,o.input??i[1]??null);Z2(s,Cp(a),i[0]??null),o.output!==null&&o.output!=="-"&&Oo(s,o.output,s.output,!1)}catch(a){if(!(a instanceof Q)){let f=O(a);if(!f)throw a;let c=`patch: ${a.message}`,d={stdout:s.stdout,stderr:s.stderr+c+`
|
|
166
173
|
`,events:[...s.events,{fd:2,text:c+`
|
|
167
|
-
`}],exitCode:2};return
|
|
168
|
-
`;return{stdout:s.stdout,stderr:s.stderr+l,events:[...s.events,{fd:2,text:l}],exitCode:2}}return{stdout:s.stdout,stderr:s.stderr,events:s.events,exitCode:s.someFailed?1:0}}function
|
|
174
|
+
`}],exitCode:2};return ie(d,f.kind,"patch",f.detail,c)}let l=`patch: **** ${a.message}
|
|
175
|
+
`;return{stdout:s.stdout,stderr:s.stderr+l,events:[...s.events,{fd:2,text:l}],exitCode:2}}return{stdout:s.stdout,stderr:s.stderr,events:s.events,exitCode:s.someFailed?1:0}}function X2(e,t,n){if(n===null)return q(e.ctx),t;if(n==="-")return q(e.ctx),t;let r=P(e.ctx,"patch",n);if(r.error||e.ctx.fs.isDir(r.path))throw new Q(`Can't open patch file ${oe(n,e.ctx)} : ${r.error??"Is a directory"}`);return e.ctx.fs.readFile(r.path)}function Z2(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let o=Ip(t,{needHeader:n===null,strip:r.strip,format:r.format});if(o===null){if(t.base===0&&!t.empty)throw new Q("Only garbage was found in the patch input.");return}e.skipRest=!1,e.skipRejectFile=!1,e.reverse=e.reverseFlag;let i=Pp(e,o,n,s=>Co(e,s));i===null&&(i=Y2(e,t,o)),e.skipRest&&(e.someFailed=!0),t.pos=o.start,V2(e,t,o,i),t.base=t.pos}}function Y2(e,t,n){let{opts:r}=e;if(r.silent||(e.say(`can't find file to patch at input line ${n.hunkLine+1}
|
|
169
176
|
`),n.type!=="normal"&&e.say(r.strip===-1?`Perhaps you should have used the -p or --strip option?
|
|
170
177
|
`:`Perhaps you used the wrong -p or --strip option?
|
|
171
178
|
`)),t.base<n.start){e.say(`The text leading up to this was:
|
|
172
179
|
--------------------------
|
|
173
|
-
`);for(let
|
|
180
|
+
`);for(let o=t.base;o<n.start;o++)e.say("|"+t.lines[o]);e.say(`--------------------------
|
|
174
181
|
`)}return r.force||r.batch?e.say(`No file to patch. Skipping patch.
|
|
175
182
|
`):(e.say(`File to patch:
|
|
176
183
|
`),e.say(`Skip this patch? [y]
|
|
177
184
|
`),r.silent||e.say(`Skipping patch.
|
|
178
|
-
`)),e.skipRest=!0,null}function
|
|
179
|
-
`),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!
|
|
180
|
-
`)}let l=
|
|
185
|
+
`)),e.skipRest=!0,null}function V2(e,t,n,r){let{opts:o}=e,i=n.copy[0]||n.copy[1]||n.rename[0]||n.rename[1],s=null;e.skipRest||(s=o.output??(i?n.names[e.reverse?"old":"new"]:r));let u={exists:!1,isDir:!1,content:""};e.skipRest||(u=Co(e,r),(u.isDir||u.link)&&(e.say(`File ${oe(r,e.ctx)} is not a regular file -- refusing to patch
|
|
186
|
+
`),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!o.dryRun&&o.output===null&&(ar(e,s),i&&r!==s&&ar(e,r));let a=Bp(Ge(u.exists?u.content:""));if(!e.skipRest&&!o.silent){let p=r!==s,h=!p&&(n.rename[0]||n.rename[1]),m=n.copy[0]||n.copy[1]?"copied":n.rename[0]||n.rename[1]?"renamed":"read",g=h?n.names[r===n.names.old?"new":"old"]:r,w=p||h?` (${h?"already ":""}${m} from ${g})`:"";e.say(`${o.dryRun?"checking":"patching"} file ${oe(s,e.ctx)}${w}
|
|
187
|
+
`)}let l=Hp(n,o.rejectFormat??n.type),c=Wp(e,n,()=>n.empty?null:Tp(t,n.type),a,l);!e.skipRest&&!Up(a)&&(e.say(`misordered hunks! output would be garbled
|
|
181
188
|
Skipping patch.
|
|
182
|
-
`),e.skipRest=!0);let d=
|
|
183
|
-
`)),!r.dryRun){if(a.failed<a.count||f)
|
|
184
|
-
`);return}let o
|
|
185
|
-
`);return}e.say(` -- saving rejects to file ${
|
|
186
|
-
`),
|
|
187
|
-
`)}function
|
|
188
|
-
`:"";if(
|
|
189
|
-
`)]:[];for(let
|
|
190
|
-
`)),!!r.has("R"))for(let
|
|
189
|
+
`),e.skipRest=!0);let d=jp(a.out);o.output!==null&&!e.skipRest&&(o.output==="-"?(e.stdout+=d,e.events.push({fd:1,text:d})):e.output+=d),!e.skipRest&&o.output===null&&K2(e,n,{inname:r,outname:s,input:u,content:d,result:c,empty:a.out.length===0,renaming:i}),c.failed&&!e.skipRejectFile&&J2(e,s,c,l.text)}function K2(e,t,n){let{opts:r}=e,{inname:o,outname:i,input:s,content:u,result:a,empty:l,renaming:f}=n,c=r.backup||r.backupIfMismatch&&(a.mismatch||a.failed>0),d=t.says[e.reverse?0:1]===2;if(l&&(r.removeEmpty||d)){r.dryRun||Vp(e,i,c);return}if(!l&&d&&(e.someFailed=!0,r.silent||e.say(`Not deleting file ${oe(i,e.ctx)} as content differs from patch
|
|
190
|
+
`)),!r.dryRun){if(a.failed<a.count||f)Oo(e,i,u,c),f&&o!==i&&(t.rename[0]||t.rename[1])&&Vp(e,o,!1);else if(c){if(!s.exists)throw new Q(`Can't reopen file ${oe(i,e.ctx)} : No such file or directory`);Oo(e,Ao(e,i),s.content,!1)}}}function J2(e,t,n,r){let{opts:o}=e;if(e.someFailed=!0,e.say(`${n.failed} out of ${n.count} hunk${n.count===1?"":"s"} ${e.skipRest?"ignored":"FAILED"}`),t===null||o.rejectFile==="-"){e.say(`
|
|
191
|
+
`);return}let i=o.rejectFile??t+".rej";if(o.dryRun){e.say(`
|
|
192
|
+
`);return}e.say(` -- saving rejects to file ${oe(i,e.ctx)}
|
|
193
|
+
`),ar(e,i);let s=e.rejectsMade.has(Z(e.dir,i));e.rejectsMade.add(Z(e.dir,i));let u=s?Co(e,i).content:"";Oo(e,i,u+r,!1)}var Ao=(e,t)=>t+e.opts.suffix;function Co(e,t){let n=E(e.dir,t,e.ctx.fs,{follow:!1}),r=!n.error&&e.ctx.fs.isLink?.(n.path)===!0,o=E(e.dir,t,e.ctx.fs);if(o.error)return{exists:!1,isDir:!1,link:r,size:0,content:""};if(e.ctx.fs.isDir(o.path))return{exists:!0,isDir:!0,link:r,size:0,content:""};let i=e.ctx.fs.readFile(o.path);return{exists:!0,isDir:!1,link:r,size:i.length,content:i}}function ar(e,t){let n=se(e.ctx.fs,e.dir,t,!1);if(!(e.ctx.writable&&n.startsWith("/tmp/")))throw new b("feature","read-only target",`${t}: file system is read-only`)}function Oo(e,t,n,r){let{ctx:o}=e;ar(e,t);let i=E(e.dir,t,o.fs);try{if(!i.error){o.fs.replaceWritable(e.dir,t,n,r?Ao(e,t):void 0);return}r&&o.fs.openWritable(e.dir,Ao(e,t)),o.fs.openWritable(e.dir,t).write(n)}catch(s){throw new Q(`Can't create file ${oe(t,e.ctx)} : ${s?.fsError??s.message}`)}}function Vp(e,t,n){let{ctx:r}=e;ar(e,t);let o=Co(e,t);o.exists&&(n&&r.fs.openWritable(e.dir,Ao(e,t)).write(o.content),r.fs.removeWritable(e.dir,t))}var Jp={du:Ad,stat:Gd,realpath:Dc,diff:xp,patch:Kp};function Q2(e,t,n){return N(t),F(n.cwd+`
|
|
194
|
+
`)}function ek(e,t,n){let{positional:r}=N(t);if(r.length>1)return x("cd: too many arguments");if(!r.length&&n.vars.unsetNames.has("HOME"))return x("cd: HOME not set");let o=r[0]??ln(n);if(o==="-"){if(!n.vars.has("OLDPWD"))return x("cd: OLDPWD not set");o=n.vars.get("OLDPWD")}let i=r[0]==="-"?o+`
|
|
195
|
+
`:"";if(o==="")return F(i);let{path:s,error:u}=P(n,"cd",o);return u?x(`cd: ${o}: ${u}`):n.fs.isDir(s)?s!==Z(n.cwd,o)?v("feature","cd","symbolic link cwd",`cd: ${o}: a working directory reached through a symbolic link is not supported (it leads to ${s})`):(n.vars.set("OLDPWD",n.cwd),n.vars.set("PWD",s),n.cwd=s,F(i)):x(`cd: ${o}: Not a directory`)}var tk={dir:"/",link:"@",file:""};function nk(e,t,n){let{flags:r,positional:o}=N(t,{short:["1","l","a","A","R","d","r","F","h"]}),i=r.has("l")?Qc(n,r.has("h")):null,s=(o.length?o:["."]).toSorted(j);r.has("r")&&s.reverse();let u=[],a=[],l=[],f=Jt(),c=r.has("a")||r.has("A"),d=y=>n.fs.isDir(y)?"dir":n.fs.isLink?.(y)?"link":"file",p=y=>r.has("F")?tk[y]:"",h=(y,k,S)=>({raw:y,abs:k,kind:S,name:S==="link"&&i?y:y+(y.endsWith("/")?"":p(S)),target:S==="link"?n.fs.readLink(k)+p(d(E(n.cwd,k,n.fs).path??"")):null}),m=(y,k)=>i?i.lines(y,k):y.map(S=>S.name),g=!(r.has("l")||r.has("F")||r.has("d"));for(let y of s){let{path:k,error:S}=P(n,"ls",y,{follow:!1}),I=S||!g||!n.fs.isLink?.(k)?k:E(n.cwd,y,n.fs).path;S?a.push(`ls: cannot access '${y}': ${S}`):r.has("d")||n.fs.isFile(k)||!n.fs.isDir(I)?l.push(h(y,k,d(k))):u.push({path:y,abs:I})}let w=l.length?[m(l,!1).join(`
|
|
196
|
+
`)]:[];for(let y of u){let k=[y];for(;k.length;){let{path:S,abs:I}=k.pop(),M=n.fs.listDir(I);c||f.collect(I,[...M.dirs,...M.files,...M.links]);let C=(D,de)=>D.filter(Xt=>c||!Xt.startsWith(".")).map(Xt=>h(Xt,Z(I,Xt),de)),H=[...C(M.dirs,"dir"),...C(M.files,"file"),...C(M.links,"link")];r.has("a")&&H.push(h(".",I,"dir"),h("..",Z(I,".."),"dir")),H.sort((D,de)=>j(D.raw,de.raw)),r.has("r")&&H.reverse();let Y=m(H,!0);if((s.length>1||r.has("R"))&&Y.unshift(S+":"),Y.length&&w.push(Y.join(`
|
|
197
|
+
`)),!!r.has("R"))for(let D of H.toReversed())D.raw==="."||D.raw===".."||!n.fs.isDir(D.abs)||k.push({path:S.endsWith("/")?S+D.raw:S+"/"+D.raw,abs:D.abs})}}return f.emit(n.notes,"ls","Hidden entries are included with -a."),{stdout:w.length?w.join(`
|
|
191
198
|
|
|
192
199
|
`)+`
|
|
193
200
|
`:"",stderr:a.length?a.join(`
|
|
194
201
|
`)+`
|
|
195
|
-
`:"",exitCode:a.length?2:0}}function
|
|
196
|
-
`)}function
|
|
202
|
+
`:"",exitCode:a.length?2:0}}function rk(e,t){let{positional:n}=N(t);if(n.length===0)return pe("basename PATH [SUFFIX]");if(n.length>2)return x(`basename: extra operand: ${n[2]}`);let r=n[0].replace(/\/+$/u,""),o=r===""?n[0]===""?"":"/":r.slice(r.lastIndexOf("/")+1);return F(ok(o,n[1])+`
|
|
203
|
+
`)}function ok(e,t){return!t||t===e||!e.endsWith(t)?e:e.slice(0,-t.length)}function ik(e,t){let{positional:n}=N(t);return n.length===0?pe("dirname PATH"):F(n.map(r=>{let o=r.replace(/\/+$/u,""),i=o.lastIndexOf("/");return i<0?r.startsWith("/")?"/":".":o.slice(0,i).replace(/\/+$/u,"")||"/"}).join(`
|
|
197
204
|
`)+`
|
|
198
|
-
`)}var
|
|
199
|
-
`;continue}let
|
|
200
|
-
`),f=l?a.slice(0,-1):a,c=(t.has("b")?f!=="":t.has("n"))?`${String(++s).padStart(6)} `:"";return
|
|
205
|
+
`)}var Qp={pwd:Q2,cd:ek,ls:nk,find:od,tree:ed,basename:rk,dirname:ik,...Jp};function r1(e,t,n){let{flags:r,positional:o}=N(t,{short:["n","b","s","v","E","T","A","e","t"]}),i=u=>ak(u,r),s=sk(o,e,n,i,r.size!==0);if(s.bytes===void 0)return ne(i(s.content),s);if(r.size)throw new b("feature","binary file","cat: formatting bytes that spell no text is not supported");return{stdout:"",stderr:s.stderr,exitCode:s.failed?1:0,events:[{fd:1,bytes:s.bytes},...s.stderr?[{fd:2,text:s.stderr}]:[]]}}function e1(e,t,n){let r=te("cat",e,t,n,{read:"maybe-text"});return{parts:r.inputs.map(o=>o.content??o.bytes),stderr:r.stderr,failed:r.failed}}var t1=e=>e.every(t=>typeof t=="string")?{content:e.join("")}:{bytes:vn([...e.map(t=>typeof t=="string"?B(t):t),new Uint8Array])};function sk(e,t,n,r,o){let i=n.outputFds[1];if(!i?.path&&!n.outputFds[2]?.path){let f=e1(e,t,n);return{...t1(f.parts),stderr:f.stderr,failed:f.failed}}let s=[],u="",a=t,l="";for(let f of e.length?e:["-"]){let c=f==="-",d=c||f==="/dev/stdin",p=d?n.stdinHandle?.path:E(n.cwd,f,n.fs).path,h=d?n.stdinHandle?.identity:n.fs.fileIdentity?.(p);if(l&&n1(p,h,n.outputFds[2]))throw new b("feature","cat input modified by diagnostics","cat: reading an input after writing diagnostics to the same file is not supported");if(n1(p,h,i)){if((c?A(n.stdinHandle.content).length-A(a).length:0)<i.position+uk(s,u,r)){l+=`cat: ${f}: input file is output file
|
|
206
|
+
`;continue}let w=c?a:d?n.stdinOrigin:n.fs.readFile(p);if(o&&w!=="")throw new b("feature","cat transforms its input file","cat: transforming an input file through its own output descriptor is not supported")}let m=e1([f],a,n);s.push(...m.parts),u+=m.parts.filter(g=>typeof g=="string").join(""),l+=m.stderr,(c||f==="/dev/stdin"&&!n.stdinFile)&&(a="")}return{...t1(s),stderr:l,failed:l!==""}}var uk=(e,t,n)=>e.every(r=>typeof r=="string")?A(n(t)).length:e.reduce((r,o)=>r+(typeof o=="string"?A(o).length:o.length),0);function n1(e,t,n){return!e||!n?.path?!1:t!==void 0&&n.identity!==void 0?t===n.identity:e===n.path}function ak(e,t){if(!t.size)return e;let n=t.has("E")||t.has("A")||t.has("e"),r=t.has("T")||t.has("A")||t.has("t"),o=t.has("v")||t.has("A")||t.has("e")||t.has("t"),i=t.has("s")?lk(e):e,s=0;return Ge(i).map(a=>{let l=a.endsWith(`
|
|
207
|
+
`),f=l?a.slice(0,-1):a,c=(t.has("b")?f!=="":t.has("n"))?`${String(++s).padStart(6)} `:"";return o?f=[...A(f)].map(d=>o1(d,r)).join(""):(r&&(f=f.replaceAll(" ","^I")),n&&l&&f.endsWith("\r")&&(f=f.slice(0,-1)+"^M")),c+f+(l?n?`$
|
|
201
208
|
`:`
|
|
202
|
-
`:"")}).join("")}function
|
|
203
|
-
`)}var
|
|
204
|
-
`,t:" ",r:"\r",a:"\x07",f:"\f",v:"\v"};function
|
|
205
|
-
`)throw new Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw new Error("delimiter character is not a single-byte character");return n}function
|
|
206
|
-
`)throw new Error(`unterminated ${r}`);if(s===t&&!
|
|
207
|
-
`&&
|
|
208
|
-
`){
|
|
209
|
-
`))throw new Error(`unterminated ${r}`);
|
|
210
|
-
`)break;if(/\d/u.test(n)){if(t.nth!==null)throw new Error("multiple number options to substitute command");let r=/^\d*/u.exec(e.script.slice(e.i))[0];if(e.i+=r.length,t.nth=Number(n+r),t.nth===0)throw new Error("number option to substitute command may not be zero");Number.isSafeInteger(t.nth)||
|
|
211
|
-
`&&(e.textState.pending.raw=n)}
|
|
209
|
+
`:"")}).join("")}function o1(e,t){return e===9?t?"^I":" ":e>=128?"M-"+o1(e-128,!0):e<32?"^"+String.fromCodePoint(e+64):e===127?"^?":String.fromCodePoint(e)}function lk(e){return e.replace(/(^|\n)\n+/gu,`$1
|
|
210
|
+
`)}var Io="sed: supported commands are p, P, n, N, d, D, a, i, c, g, G, h, H, x, w, q, =, y, :, b, t, T, { }, and s/regexp/replacement/[NgiIpw]",nu=1e6,To=16*1024*1024,i1=64*1024*1024;function Ee(e="script"){throw new b("feature",e,Io)}function Fo(e){return e.gap?v("feature","sed",e.gap,`sed: ${e.message}`):e instanceof RangeError?v("feature","sed","regex runtime limit",`sed: ${e.message}`):K(e,"sed",`sed: ${e.message.replace(/^sed: /u,"")}`,e.exitCode)}function s1(e){let t=[],n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="--"){t.push(...e.slice(r));break}if(o==="--in-place"||o.startsWith("--in-place=")){n=o==="--in-place"?"":o.slice(11);continue}if(o.startsWith("--")||!o.startsWith("-")){t.push(o),(o==="--expression"||o==="--file")&&r+1<e.length&&t.push(e[++r]);continue}let i=o;for(let s=1;s<o.length;s++){let u=o[s];if(u==="i"){n=o.slice(s+1),i=o.slice(0,s);break}if(u==="e"||u==="f"){t.push(o),s+1===o.length&&r+1<e.length&&t.push(e[++r]),i="";break}if(!"nErsz".includes(u))break}i&&(i!=="-"||o==="-")&&t.push(i)}return{tokens:t,inPlace:n}}function u1(e,t,n,r,o){if(e.files.length===0)return x("sed: no input files",4);let i=U(),s=new Set([...t,"s"]),u=!1;for(let a of e.files){let l=fk(a,n);if(l.error){if(_(i,n.flushOutput(l.error)),l.error.exitCode!==2)return Lo(i,l.error);u=!0;continue}let f=o({...e,files:[l.path]},s),{content:c,...d}=f;if(_(i,d),f.failed||O(f))return Lo(i,f);let p=ck(a,r),h;try{h=n.fs.replaceWritable(n.cwd,a,c,p)}catch(m){R(n,"sed",m?.path,m?.fsError);let g=K(m,"sed",`sed: ${m.message}`,4);return _(i,g),Lo(i,g)}if(!h){let m=ru(p??a);return _(i,m),Lo(i,m)}if(f.quit)break}return u&&(i.exitCode=2),i}function fk(e,t){if(e==="/dev/null"||e==="/dev/stdin"&&!t.stdinFile||e==="/dev/stdout"&&!t.outputFds[1]?.path||e==="/dev/stderr"&&!t.outputFds[2]?.path)return{error:x(`sed: couldn't edit ${e}: not a regular file`,4)};if(e==="/dev/stdin"||e==="/dev/stdout"||e==="/dev/stderr")return{error:ru(e)};let n=P(t,"sed",e);if(n.error)return{error:x(xi("sed",e,n.error).trimEnd(),2)};if(t.fs.isDir(n.path))return{error:x(`sed: couldn't edit ${e}: not a regular file`,4)};let r=E(t.cwd,e,t.fs,{follow:!1}).path;return!t.writable||!r.startsWith("/tmp/")?{error:ru(e)}:n}function ck(e,t){if(!(t===""||t==="*"))return t.includes("*")?t.replaceAll("*",()=>e):e+t}function ru(e){return v("feature","sed","-i",`sed: ${e}: file system is read-only`)}function Lo(e,t){let n=O(t);return n?ie(e,n.kind,n.command,n.detail,n.message):e}function ou(e,t){let n=!1;return(r,o)=>{e((n?t:"")+r+(o??"")),n=o===""}}function a1(e,t){let n=new Map,r=0,o,i,s,u=()=>e.io.setReads([o,i?.identity]);function a(f,c){if(c==="")return;l(c),u();let d=e.outputFds[f];if(d?.path){d.write(c);return}if(d==="closed"){let p=new Error("write error: Bad file descriptor");throw p.exitCode=4,p}s[f===1?"stdout":"stderr"]+=c,s.events.push({fd:f,text:c})}function l(f){if(r+=f.length,r>i1)throw new b("feature","output limit","sed: output limit exceeded")}return{start(f){return s=U(),i=f,o=void 0,u(),s},record(f){o=f?.identity,u()},finish(){o=void 0,i=null,u()},stream:a,account:l,openWrite(f){if(n.has(f))return n.get(f);let c;if(f==="/dev/null")c=()=>{};else if(f==="/dev/stdout"||f==="/dev/stderr")c=p=>a(f==="/dev/stdout"?1:2,p);else{let p;try{p=e.writable&&e.fs.openWritable(e.cwd,f)}catch(h){throw R(e,"sed",h?.path,h?.fsError),h.exitCode=4,h}if(!p)throw new b("feature","output file",`sed: ${f}: Read-only file system`);c=h=>{l(h),u(),p.write(h)}}let d=ou(c,t);return n.set(f,d),d}}}function lr(e,t){let n=t.stdinHandle;if(!n)return e;let r=t.io.bufferReads(()=>t.fs.readIdentity(n.identity));if(r===n.content)return e;if(e!==n.content)throw new b("feature","modified redirected input","sed: reading an input file changed after partial consumption is not supported");return t.stdinHandle={...n,content:r},t.stdinOrigin=t.stdinLeft=r,r}function l1(e,t,n,r,o,i){let s=e.length?e:["-"],u={stderr:"",failed:!1},a=0,l=0,f=t,c=null;function d(){for(;c===null||c.pos===c.content.length;){if(a===s.length)return!1;c=null;let h=s[a++];h==="-"?f=lr(f,n):h==="/dev/stdin"&&n.stdinHandle&&(n.stdinOrigin=n.io.bufferReads(()=>n.fs.readIdentity(n.stdinHandle.identity)));let m=st("sed",[h],n,f);if(u.stderr+=m.stderr,u.failed||=m.failed,c=m.inputs.length?{...m.inputs[0],identity:dk(h,n),pos:0,first:!0}:null,m.stderr&&i&&i(m.stderr),m.entries.some(g=>g.kind==="dir"))return u.directory=!0,a=s.length,!1;c?.shared&&q(n,f),o&&(l=0)}return!0}function p(){if(!d())return null;let h=c.pos,m=c.content.indexOf(r,h),g=m<0?"":r,w=c.content.slice(h,m<0?c.content.length:m);c.pos=m<0?c.content.length:m+r.length,c.shared&&(f=c.content.slice(c.pos),q(n,f));let y=c.first;c.first=!1;let k;return{text:w,terminator:g,line:++l,reset:y,identity:c.identity,last:()=>k??=c.pos<c.content.length?!1:o||!d()}}return{next:p,status:u,get identity(){return c?.identity}}}function dk(e,t){return e==="-"||e==="/dev/stdin"?t.stdinHandle?.identity:t.fs.fileIdentity?.(E(t.cwd,e,t.fs).path??Z(t.cwd,e))}var _o={n:`
|
|
211
|
+
`,t:" ",r:"\r",a:"\x07",f:"\f",v:"\v"};function fr(e,t="substitute command"){let n=e.script[e.i++];if(n===void 0||n===`
|
|
212
|
+
`)throw new Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw new Error("delimiter character is not a single-byte character");return n}function Ro(e,t,n,r="substitute command"){let o="",i=!1;for(;e.i<e.script.length;){let s=e.script[e.i++];if(s===`
|
|
213
|
+
`)throw new Error(`unterminated ${r}`);if(s===t&&!i)return o;if(s==="\\"){let u=e.script[e.i++];if(u===void 0||u===`
|
|
214
|
+
`&&i)throw new Error(`unterminated ${r}`);if(u===`
|
|
215
|
+
`){o+=u;continue}o+=!i&&u===t&&(n||u!=="&")?u:s+u;continue}if(n&&s==="["&&!i){i=!0,o+=s,e.script[e.i]==="^"&&(o+=e.script[e.i++]),e.script[e.i]==="]"&&(o+=e.script[e.i++]);continue}if(n&&i&&s==="["&&/[:.=]/u.test(e.script[e.i]??"")){let u=e.script.indexOf(e.script[e.i]+"]",e.i+1);if(u<0)throw new Error("unterminated character class");if(e.script.slice(e.i,u).includes(`
|
|
216
|
+
`))throw new Error(`unterminated ${r}`);o+=s+e.script.slice(e.i,u+2),e.i=u+2;continue}n&&s==="]"&&(i=!1),o+=s}throw new Error(`unterminated ${r}`)}function f1(e){let t=fr(e),n=Ro(e,t,!0),r=Ro(e,t,!1),o=mk(r),i=pk(e);if(n===""&&(i.ignoreCase||i.multiline))throw new Error("cannot specify modifiers on empty regexp");i.multiline&&c1(i.multiline);let s=su(n,e.extended,!1,i.ignoreCase,e.locale);for(let u of o)if(typeof u=="number"&&u>s.re?.groupCount)throw new Error(`invalid reference \\${u} in replacement`);return{...s,parts:o,...i}}function pk(e){let t={global:!1,print:!1,nth:null};for(;e.i<e.script.length;){let n=e.script[e.i];if(/[;\n#}]/u.test(n))break;if(e.i++,!/[ \t]/u.test(n)){if(n==="\r"&&e.script[e.i]===`
|
|
217
|
+
`)break;if(/\d/u.test(n)){if(t.nth!==null)throw new Error("multiple number options to substitute command");let r=/^\d*/u.exec(e.script.slice(e.i))[0];if(e.i+=r.length,t.nth=Number(n+r),t.nth===0)throw new Error("number option to substitute command may not be zero");Number.isSafeInteger(t.nth)||Ee("substitution occurrence limit")}else if(n==="g"||n==="p"){let r=n==="g"?"global":"print";if(t[r])throw new Error("multiple substitution flags");t[r]=!0}else if(n==="w"){Object.assign(t,iu(e));break}else if(n==="i"||n==="I")t.ignoreCase=!0;else if(n==="m"||n==="M")t.multiline=n;else if(n==="e")c1(n);else throw new Error(`unknown option to substitute command: '${n}'`)}}return t}function c1(e){let t=e==="e"?"command evaluation":"multiline regex matching";throw new b("feature",`substitution flag ${e}`,`sed: substitution flag '${e}' (${t}) is not supported`)}function iu(e){let t=/^[ \t]*([^\n]*)/u.exec(e.script.slice(e.i));e.i+=t[0].length;let n=t[1].split("\0",1)[0];if(n==="")throw new Error("missing filename in r/R/w/W commands");return e.openWrite?{writer:e.openWrite(n)}:{writeName:n}}function su(e,t,n=!1,r=!1,o=ee){if(!e){if(r)throw new Error("cannot specify modifiers on empty regexp");return{re:null}}let i=re(o);is(e,t,i.multibyte);let s=e.replace(/\\(.)/gu,(f,c)=>(c==="o"&&Ee("regex escape"),Object.hasOwn(_o,c)?_o[c]:f)),u=r?zn(s,i):s,a=t?{source:rs(u,i)}:oo(u,i);if(a.error)throw new Error(a.error);hk(a.source,t),io(a.source);for(let[,f]of a.source.matchAll(/\\(.)/gu))/[1-9]/u.test(f)&&Ee("regex backreferences");return{re:new ct(Hn(a.source,!0,i),!1,null,i),noSub:n,locale:o,ignoreCase:r,pattern:s}}function hk(e,t){let n=!1,r=0,o=!1,i=!1;for(let s=0;s<e.length;s++){let u=e[s];if(u==="\\"){let a=e[++s];n||(o=!"bB<>`'".includes(a),i=!1);continue}if(n){u==="]"&&(n=!1,o=!0,i=!1);continue}if(u==="["){n=!0;continue}if(u==="("){r++,o=!1,i=!1;continue}if(u===")"){if(--r<0)throw new Error("unmatched )")}else if(u==="|"||u==="^"||u==="$"){o=!1,i=!1;continue}else if("*+?{".includes(u)){let a=u==="{"?/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u.exec(e.slice(s)):null;if(u==="{"&&a===null)throw new Error("invalid repetition count");if(!o||!t&&i&&(u==="*"||u==="{"))throw new Error("Invalid preceding regular expression");a&&(s+=a[0].length-1),i=!0;continue}o=!0,i=!1}if(r>0)throw new Error("unmatched (")}function mk(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="&"){t.push(0);continue}if(r!=="\\"){t.push(r);continue}let o=e[++n];/[0-9]/u.test(o)?t.push(Number(o)):o==="\\"||o==="&"?t.push(o):Object.hasOwn(_o,o)?t.push(_o[o]):Ee("replacement escape")}return t}function uu(e,t){if(/[\u0080-\u{10FFFF}]/u.test(e+t.re.src)){if(t.locale!==ee)throw new b("feature","locale",`matching non-ASCII text in the ${t.locale} locale is not supported`);t.ignoreCase&&Tt.test(e+t.pattern)&&Ee("case folding of Cyrillic Extended-C letters")}}function au(e,t,n=null){let r=e.re===null?t.last:e;if(!r)throw new Error("no previous regular expression");if(t.last=r,n!==null&&r.noSub){if(n>r.re.groupCount)throw new Error(`invalid reference \\${n} in replacement`);r.noSub=!1}return r}function lu(e,t,n){let r=t.parts.reduce((l,f)=>typeof f=="number"?Math.max(l,f):l,0),o=au(t,n,r);uu(e,o);let i=t.parts.some(l=>typeof l=="number"&&l>0&&l<=o.re.groupCount),s=0,u=t.nth&&!t.global?{search:(l,f)=>s?null:o.re.search(l,f)}:o.re;return{out:qn(e,u,(l,f,c)=>{if(t.nth&&c<t.nth)return null;s++;let d=i?o.re.groups(e,l,f):null;return t.parts.map(p=>typeof p=="string"?p:p===0?e.slice(l,f):d?.[p]?.text??"").join("")},t.global||t.nth?"global":"first").out,count:s}}var d1={a:7,f:12,n:10,r:13,t:9,v:11,"\n":10},p1={d:10,o:8,x:16};function m1(e,t){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;if(e.i===e.script.length)throw new Error("expected \\ after 'a', 'c' or 'i'");if(t.text=null,e.textState.pending={command:t,raw:""},e.script[e.i]==="\\"){let n=e.script[++e.i];if(n===void 0)return;e.i++,n!==`
|
|
218
|
+
`&&(e.textState.pending.raw=n)}cu(e)}function cu(e){let t=e.textState.pending;if(!t)return;let n=t.raw;for(;e.i<e.script.length&&e.script[e.i]!==`
|
|
212
219
|
`;){let r=e.script[e.i++];if(r==="\\"){if(e.i===e.script.length){t.raw=n+`
|
|
213
|
-
`;return}n+=r+e.script[e.i++]}else n+=r}t.command.text=
|
|
214
|
-
`),e.textState.pending=null}function
|
|
215
|
-
`)break;if(r===t)return n;if(r!=="\\"){n+=r;continue}let
|
|
216
|
-
`?
|
|
217
|
-
`,u=
|
|
218
|
-
`;continue}u!==-1?n.vars.set(l,(a?
|
|
219
|
-
`:
|
|
220
|
-
`,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let u=parseInt(e.slice(t+2,
|
|
221
|
-
`))return e;let n=
|
|
222
|
-
`){n.at(-1)?.type!=="newline"&&
|
|
223
|
-
`),r++,
|
|
224
|
-
`||e[
|
|
225
|
-
`)){
|
|
226
|
-
`?2:3,r++;continue}if(u==="#"){for(;
|
|
227
|
-
`;)
|
|
228
|
-
`,t:" ",r:"\r",a:"\x07",b:"\b",f:"\f",v:"\v",'"':'"',"\\":"\\"};function
|
|
229
|
-
`)break;if(s==="\\"&&e[
|
|
230
|
-
`){
|
|
231
|
-
`)break;if(o==="\\"){r+=2;continue}if(i){if(o==="["&&e[r+1]===":"){let s=e.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}o==="]"&&(i=!1),r++;continue}if(o==="["){i=!0,r++,e[r]==="^"&&r++,e[r]==="]"&&r++;continue}if(o==="/")return{value:e.slice(t,r),end:r+1};r++}throw new $("unterminated regexp",n)}function ar(e,t=null){return d1(e,0,t).value}function f1(e,t){if(t.byte===void 0)for(let n of A(t.text))e.push(n);else e.push(t.byte)}var V2=new Set(["=","+=","-=","*=","/=","%=","^=","**="]),p1=new Set(["<","<=","==","!=",">",">="]),fr=e=>e.type==="var"||e.type==="index"||e.type==="field";function h1(e){let t=e.tok;return g1(e)||t.type==="regex"||t.type==="keyword"&&t.value==="getline"||t.type==="punct"&&["!","-","+"].includes(t.value)}function cn(e,t){let n=[Se(e,t)];for(;e.accept(",");)e.skipNewlines(),n.push(Se(e,t));return n}function Se(e,t){let n=K2(e,t),r=e.tok;if(r.type==="punct"&&V2.has(r.value)){fr(n)||e.fail(`cannot assign to ${n.type==="regex"?"a regex":"a non-variable"} (left side of \`${r.value}\`)`),e.next();let i=Se(e,t);return{type:"assign",op:r.value==="**="?"^=":r.value,target:n,value:i}}return n}function K2(e,t){let n=au(e,t);if(!e.accept("?"))return n;e.skipNewlines();let r=Se(e,t);return e.skipNewlines(),e.expect(":"),e.skipNewlines(),{type:"cond",test:n,consequent:r,alternate:Se(e,t)}}var J2=[["or",["||"]],["and",["&&"]],["in",["in"]],["match",["~","!~"]],["compare",[...p1]],["concat",[]],["binary",["+","-"]],["binary",["*","/","%"]]],Q2=new Map(J2.flatMap(([e,t],n)=>t.map(r=>[r,{type:e,precedence:n}]))),ek={type:"concat",precedence:5};function au(e,t,n=0){let r=Ai(e,t),i=1/0;for(;;){let o=e.tok;n<=4&&i>4&&!t.noGt&&(e.is("|")||e.is("|&"))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${zr}`,'"cmd" | getline');let s=g1(e)?ek:o.type==="punct"||o.type==="keyword"&&o.value==="in"?Q2.get(o.value):void 0;if(!s||s.precedence<n||s.precedence>i||t.noGt&&e.is(">"))return r;let{type:u,precedence:a}=s,l=u==="concat"?null:e.next().value;if(i=a,(u==="or"||u==="and")&&e.skipNewlines(),u==="in"){r={type:u,keys:[r],array:m1(e)};continue}let f=au(e,t,a+1);(l==="/"||l==="%")&&lr(f)===0&&lr(r)!==null&&e.fail(l==="/"?"division by zero attempted":"division by zero attempted in `%`"),u==="compare"&&tk(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),u==="binary"||u==="compare"?r={type:u,op:l,left:r,right:f}:u==="match"?r={type:u,negate:l==="!~",left:r,right:f}:r={type:u,left:r,right:f}}}function m1(e){return e.tok.type!=="name"&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var tk=(e,t)=>e.tok.type==="punct"&&p1.has(e.tok.value)&&!(t.noGt&&e.tok.value===">");function g1(e){let t=e.tok;return t.type==="number"||t.type==="string"||t.type==="name"||t.type==="funcname"||t.type==="builtin"?!0:t.type==="punct"&&["$","(","++","--"].includes(t.value)}function w1(e,t){return au(e,t,5)}function lr(e){if(e.type==="num")return e.value;if(e.type==="neg"||e.type==="plus"){let r=lr(e.expr);return r===null?null:e.type==="neg"?-r:r}if(e.type!=="binary")return null;let t=lr(e.left),n=lr(e.right);return t===null||n===null?null:Hr(e.op,t,n)}var nk={__proto__:null,"!":"not","-":"neg","+":"plus"};function Ai(e,t,n=!1){if(n&&(e.is("$")||e.is("++")||e.is("--")))return Oi(e,t);let r=e.tok.type==="punct"&&nk[e.tok.value];return r?(e.next(),{type:r,expr:Ai(e,t,n)}):n?y1(e,t):rk(e,t)}function rk(e,t){let n=b1(e,t);return!e.is("^")&&!e.is("**")?n:(e.next(),{type:"binary",op:"^",left:n,right:Ai(e,t)})}function b1(e,t){let n=Oi(e,t);for(;(e.is("++")||e.is("--"))&&fr(n);)n={type:"postinc",op:e.next().value,target:n};return n}function Oi(e,t){if(e.accept("$"))return{type:"field",index:Ai(e,t,!0)};if(e.is("++")||e.is("--")){let n=e.next().value,r=Oi(e,t);return fr(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:"preinc",op:n,target:r}}return y1(e,t)}function y1(e,t){let n=e.tok;switch(n.type){case"number":return e.next(),{type:"num",value:Number(n.value)};case"string":return e.next(),{type:"str",value:n.value};case"regex":return e.next(),{type:"regex",source:n.value,re:ik(e,n.value)};case"name":return ok(e);case"funcname":return sk(e);case"builtin":return ak(e);case"keyword":return n.value==="getline"?lk(e,t):e.unexpected();case"punct":return n.value==="("?uk(e):e.unexpected();default:return e.unexpected()}}function ik(e,t){try{return Fe(t,!1,n=>e.warn(n))}catch(n){return e.fail(n.message,n.gap??null)}}function lu(e){if(!e.accept("["))return null;let t=cn(e,{});return e.expect("]"),e.is("[")&&e.fail("arrays of arrays are not supported","arrays of arrays"),t}function ok(e){let t=e.next().value,n=lu(e);return n!==null?{type:"index",name:t,subs:n}:(e.is("(")&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:"var",name:t})}function sk(e){return{type:"call",name:e.next().value,args:x1(e)}}function x1(e){e.expect("(");let t=e.is(")")?[]:cn(e,{});return e.expect(")"),t}function uk(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=cn(e,{});if(e.expect(")"),n.length===1){for(;t-- >0;)e.expect(")");return n[0]}return e.isKw("in")||e.fail("a parenthesized list must be followed by `in ARRAY`"),e.next(),{type:"in",keys:n,array:m1(e)}}function ak(e){let t=e.next().value;if(jr.has(t)&&e.fail(jr.get(t),`${t}()`),!e.is("(")){if(t==="length")return{type:"builtin",name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=x1(e),[r,i]=Po[t];return(n.length<r||n.length>i)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?"":"s"}; it takes ${r===i?r:`${r} to ${i===1/0?"any number":i}`}`),(t==="sub"||t==="gsub")&&n[2]&&!fr(n[2])&&e.fail(`${t}(): substitution into a temporary value is not supported`,"substitution into temporary value"),t==="split"&&n[1].type!=="var"&&e.fail("split(): second argument must be an array name"),t==="match"&&n[2]&&n[2].type!=="var"&&e.fail("match(): third argument must be an array name"),{type:"builtin",name:t,args:n}}function lk(e,t){e.next();let n=null;(e.tok.type==="name"||e.is("$"))&&(n=Oi(e,t),fr(n)||e.fail("getline: target must be a variable, field or array element"));let r=null;return e.accept("<")&&(r=b1(e,t)),{type:"getline",target:n,file:r}}var fk=new Set(["/dev/stdout","/dev/stderr","/dev/null"]),fu=class{constructor(t,n){this.toks=t,this.i=0,this.warnings=n,this.funcs=new Set,this.parens=new Map;let r=[];for(let i=0;i+1<t.length;i++){let o=t[i],s=t[i+1];o.type==="punct"&&(o.value==="("?r.push(i):o.value===")"&&r.length>0&&this.parens.set(r.pop(),i)),o.type==="keyword"&&o.value==="function"&&(s.type==="name"||s.type==="funcname")&&this.funcs.add(s.value)}this.loopDepth=0,this.switchDepth=0,this.context="main"}get tok(){return this.toks[this.i]}peek(t){return this.toks[Math.min(this.i+t,this.toks.length-1)]}is(t,n="punct"){return this.tok.type===n&&this.tok.value===t}isKw(t){return this.is(t,"keyword")}next(){return this.toks[this.i++]}accept(t,n="punct"){return this.is(t,n)?this.next():null}expect(t,n="punct"){return this.is(t,n)||this.fail(`expected \`${t}\` but found ${Wt(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type==="newline";)this.i++}skipTerminators(){for(;this.tok.type==="newline"||this.is(";");)this.i++}fail(t,n=null){throw new $(t,this.tok.line,n)}warn(t){this.warnings.push(t)}unexpected(){this.fail(`unexpected ${Wt(this.tok)}`)}};function Wt(e){return e.type==="eof"?"end of program":e.type==="newline"?"newline":e.type==="string"?`string "${e.value}"`:e.type==="regex"?`regex /${e.value}/`:`\`${e.value}\``}var k1={__proto__:null,BEGIN:"begin",END:"end",BEGINFILE:"beginFile",ENDFILE:"endFile"};function $1(e){let t=[],n=new fu(c1(e,i=>t.push(i)),t),r={begin:[],end:[],beginFile:[],endFile:[],rules:[],functions:new Map,warnings:t};for(n.skipNewlines();n.tok.type!=="eof";)n.is(";")&&n.fail("each rule must have a pattern or an action part"),ck(n,r),n.accept(";"),n.skipNewlines();return r}function ck(e,t){if(e.isKw("function")){dk(e,t);return}if(e.tok.type==="keyword"&&e.tok.value in k1){let o=e.next().value;e.is("{")||e.fail(`${o} requires an action: ${o} { ... }`),t[k1[o]].push(...cr(e,o.toLowerCase()));return}if(e.is("{")){t.rules.push({pattern:null,action:cr(e,"main")});return}let n=Se(e,{}),r=n;e.accept(",")&&(e.skipNewlines(),r={type:"range",from:n,to:Se(e,{})});let i=e.is("{")?cr(e,"main"):null;i===null&&!(e.tok.type==="newline"||e.tok.type==="eof"||e.is(";"))&&e.unexpected(),t.rules.push({pattern:r,action:i})}function dk(e,t){e.next();let n=e.tok;n.type==="builtin"&&e.fail(`cannot redefine builtin function \`${n.value}\``),n.type!=="name"&&n.type!=="funcname"&&e.fail(`expected a function name but found ${Wt(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect("(");let i=[];for(;!e.is(")");){let o=e.tok;if(o.type!=="name"&&e.fail(`expected a parameter name but found ${Wt(o)}`),(o.value===r||i.includes(o.value))&&e.fail(`duplicate parameter \`${o.value}\` in function \`${r}\``),i.push(e.next().value),!e.accept(","))break;e.skipNewlines()}e.expect(")"),e.skipNewlines(),t.functions.set(r,{params:i,body:cr(e,"function")})}function cr(e,t=e.context){let n=e.context;e.context=t,e.expect("{");let r=[];for(e.skipTerminators();!e.is("}");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),r.push(cu(e)),e.skipTerminators();return e.next(),e.context=n,r}function dr(e){if(e.is(";")||e.tok.type==="newline"){e.next();return}e.is("}")||e.tok.type==="eof"||e.unexpected()}var pk={__proto__:null,if:hk,while:mk,do:gk,for:wk,switch:bk,break:e=>dn(e,"break"),continue:e=>dn(e,"continue"),next:e=>dn(e,"next"),nextfile:e=>dn(e,"nextfile"),exit:e=>dn(e,"exit"),return:e=>dn(e,"return"),delete:xk,print:e=>S1(e,"print"),printf:e=>S1(e,"printf")};function cu(e){if(e.is("{"))return{type:"block",body:cr(e)};if(e.is(";"))return e.next(),{type:"empty"};let t=e.tok.type==="keyword"?pk[e.tok.value]:void 0;if(t)return t(e);let n=Se(e,{});return dr(e),{type:"expr",expr:n}}function pn(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=cu(e);return t&&e.loopDepth--,n}function Ii(e){e.next(),e.expect("(");let t=Se(e,{});return e.expect(")"),t}function hk(e){let t=Ii(e),n=pn(e,!1),r=e.i;return e.skipNewlines(),e.isKw("else")?(e.next(),{type:"if",test:t,consequent:n,alternate:pn(e,!1)}):(e.i=r,{type:"if",test:t,consequent:n,alternate:null})}function mk(e){return{type:"while",test:Ii(e),body:pn(e,!0)}}function gk(e){e.next();let t=pn(e,!0);e.skipTerminators(),e.isKw("while")||e.fail("`do` body must be followed by `while (...)`");let n=Ii(e);return dr(e),{type:"do",body:t,test:n}}function wk(e){if(e.next(),e.expect("("),e.tok.type==="name"&&e.peek(1).type==="keyword"&&e.peek(1).value==="in"&&e.peek(2).type==="name"&&e.peek(3).value===")"){let i=e.next().value;e.next();let o=e.next().value;return e.next(),{type:"forin",name:i,array:o,body:pn(e,!0)}}let t=e.is(";")?null:Se(e,{});e.expect(";"),e.skipNewlines();let n=e.is(";")?null:Se(e,{});e.expect(";"),e.skipNewlines();let r=e.is(")")?null:Se(e,{});return e.expect(")"),{type:"for",init:t,test:n,step:r,body:pn(e,!0)}}function bk(e){let t=Ii(e);e.skipNewlines(),e.expect("{");let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is("}");e.skipTerminators()){let i=null;e.accept("case","keyword")?i=yk(e):e.accept("default","keyword")||e.fail(`expected \`case\` or \`default\` in switch body but found ${Wt(e.tok)}`);let o=i===null?"default":i.type==="regex"?`/${i.source}/`:String(i.value);r.has(o)&&e.fail(`duplicate case values in switch body: ${o}`),r.add(o),e.expect(":");let s=[];for(e.skipTerminators();!e.is("}")&&!e.isKw("case")&&!e.isKw("default");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),s.push(cu(e)),e.skipTerminators();n.push({test:i,body:s})}return e.switchDepth--,e.next(),{type:"switch",expr:t,cases:n}}function yk(e){let t=e.accept("-")?-1:(e.accept("+"),1),n=e.tok;return n.type==="number"?(e.next(),{type:"num",value:t*Number(n.value)}):t===1&&n.type==="string"?(e.next(),{type:"str",value:n.value}):t===1&&n.type==="regex"?(e.next(),{type:"regex",source:n.value,re:Fe(n.value,!1,r=>e.warn(r))}):e.fail(`case value must be a number, string or regex constant, found ${Wt(n)}`)}function dn(e,t){t==="break"&&e.loopDepth===0&&e.switchDepth===0&&e.fail("`break` is not allowed outside a loop or switch"),t==="continue"&&e.loopDepth===0&&e.fail("`continue` is not allowed outside a loop"),t==="next"&&e.context!=="main"&&e.context!=="function"&&e.fail(`\`next\` cannot be used in a ${e.context.toUpperCase()} action`),t==="nextfile"&&(e.context==="begin"||e.context==="end"||e.context==="endfile")&&e.fail(`\`nextfile\` cannot be used in a ${e.context.toUpperCase()} action`),t==="return"&&e.context!=="function"&&e.fail("`return` is only allowed inside a function"),e.next();let n={type:t};return(t==="exit"||t==="return")&&(n.value=h1(e)?Se(e,{}):null),dr(e),n}function xk(e){e.next(),e.tok.type!=="name"&&e.fail(`\`delete\` needs an array name but found ${Wt(e.tok)}`);let t=e.next().value,n=lu(e);return dr(e),{type:"delete",name:t,subs:n}}var v1=e=>e.is(";")||e.is("}")||e.is(">")||e.is(">>")||e.is("|")||e.is("|&")||e.tok.type==="newline"||e.tok.type==="eof";function S1(e,t){e.next();let n=null;if(e.is("(")){let i=e.i;e.next();let o=e.is(")")?[]:cn(e,{});e.accept(")")&&v1(e)?n=o:e.i=i}n===null&&(n=v1(e)?[]:cn(e,{noGt:!0})),t==="printf"&&n.length===0&&e.fail("printf needs a format string");let r=null;return(e.is("|")||e.is("|&"))&&e.fail(`output pipes (\`${t} ... | "cmd"\`) are not supported: ${zr}`,`${t} | "cmd"`),(e.accept(">")||e.accept(">>"))&&(r=w1(e,{noGt:!0}),r.type==="str"&&!fk.has(r.value)&&e.fail(du(r.value),`${t} > FILE`)),dr(e),{type:t,args:n,dest:r}}function du(e){return`cannot redirect output to \`${e}\`: the filesystem is read-only (only /dev/stdout, /dev/stderr and /dev/null). To print a comparison, parenthesize it: print (a > b)`}var j=class{constructor(t){this.s=t,this.number=void 0,this.numeric=void 0}},pr="[ \\t\\n\\r\\f\\v]*",A1="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",kk=new RegExp(`^${pr}${A1}${pr}$`,"u"),vk=new RegExp(`^${pr}(${A1})`,"u"),O1=new RegExp(`^${pr}([+-])(inf|nan)${pr}$`,"iu"),pu=e=>kk.test(e)||O1.test(e);function E1(e){let t=vk.exec(e);if(t)return Number(t[1]);let n=O1.exec(e);return n?n[2].toLowerCase()==="nan"?Number.NaN:n[1]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:0}var hu=()=>new $("attempt to use an array in a scalar context");function W(e){if(typeof e=="number")return e;if(e===void 0)return 0;if(e instanceof j)return e.number??=E1(e.s);if(typeof e=="string")return E1(e);throw hu()}var Ci=new Map;function I1(e,t){if(Number.isNaN(e))throw new $("formatting signed NaN is not supported",null,"signed NaN");if(!Number.isFinite(e))return e<0?"-inf":"+inf";if(Number.isInteger(e))return Math.abs(e)<2**53?String(e):BigInt(e).toString();let n=Ci.get(t);if(n===void 0){Ci.size>64&&Ci.clear(),n=si(t);let r=n.filter(i=>typeof i!="string");if(r.length>1||r.some(i=>!"diouxXeEfFgG".includes(i.conv)||i.width==="*"||i.precision==="*"))throw new $("this numeric conversion format is not supported",null,"numeric conversion format");Ci.set(t,n)}return n.map(r=>typeof r=="string"?r:Ut(e,r)).join("")}var C1=e=>typeof e=="string"?e:e instanceof j?e.s:"%.6g",Sk=e=>C1(e.globals.get("CONVFMT")),$k=e=>C1(e.globals.get("OFMT"));function F(e,t){if(typeof e=="string")return ft(t,e);if(e instanceof j)return ft(t,e.s);if(typeof e=="number")return I1(e,Sk(t));if(e===void 0)return"";throw hu()}function ft(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new $("non-ASCII AWK text in a byte locale is not supported",null,"byte locale text");return t}function jt(e,t=!1){return[...e].map(n=>{let r=t?n.toUpperCase():n.toLowerCase();if([...r].length!==1)throw new $("Unicode case expansion is not supported",null,"Unicode case mapping");return r}).join("")}function F1(e,t){return typeof e=="number"?I1(e,$k(t)):F(e,t)}var mu=e=>e.numeric??=pu(e.s),N1=e=>typeof e=="number"||e===void 0||e instanceof j&&mu(e),Be=e=>$e(e.globals.get("IGNORECASE"));function Fi(e,t,n){if(N1(e)&&N1(t)){let o=W(e),s=W(t);return o<s?-1:o>s?1:o===s?0:Number.NaN}let r=F(e,n),i=F(t,n);return Be(n)&&(r=jt(r),i=jt(i)),B(r,i)}function $e(e){if(typeof e=="number")return e!==0&&!Number.isNaN(e);if(typeof e=="string")return e!=="";if(e instanceof j)return mu(e)?W(e)!==0:e.s!=="";if(e===void 0)return!1;throw hu()}var gu=(e,t)=>Number.isSafeInteger(e)?String(e):F(e,t);function wu(e){return e instanceof Map?"array":e===void 0?"untyped":typeof e=="number"?"number":e instanceof j&&mu(e)?"strnum":"string"}function T1(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t==="")return Ek(e);let i,o;if(t.length===1){let u=r.indexOf(t,e.pos);o=u===-1?r.length:u,i=u===-1?r.length:u+1}else{let u=Wo(r,Fe(t,n),e.pos);o=u?.start??r.length,i=u?.end??r.length}let s=r.slice(e.pos,o);return e.pos=i,{rec:s,rt:r.slice(o,i)}}function Ek(e){let{text:t}=e,n=e.pos;for(;t[n]===`
|
|
232
|
-
`;)n++;if(n>=t.length)return e.pos=n,null;let r=/\n\n+/gu;r.lastIndex=n;let
|
|
233
|
-
`))return e.split(t);if(n&&t==="^")throw new $('paragraph splitting with FS="^" is not supported',null,"paragraph FS caret");let
|
|
234
|
-
]`:t;return jo(e,Fe(i,r))}function _1(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let i=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),o=i?.[1]===void 0?0:Number(i[1]),s=i?.[2]==="*"?4294967295:Number(i?.[2]);if(!i||i[1]!==void 0&&o===0||o>4294967295||!(s>0&&s<=4294967295)||i[2]==="*"&&r!==t.length-1)throw new $(`invalid FIELDWIDTHS value \`${e}'`);return{skip:o,width:s}})}function Nk(e,t){let n=[...e],r=[],i=0;for(let{skip:o,width:s}of t){if(i>=n.length)break;i+=o,r.push(n.slice(i,i+s).join("")),i+=s}return r}function Ak(e,t){let n=[],r=0;for(;r<e.length;){let i=t.search(e.slice(r));if(n.length>0&&i?.end===0&&(r+=Ie(e,r),i=t.search(e.slice(r))),!i)break;n.push(e.slice(r+i.start,r+i.end)),r+=i.end}return n}function L1(e,t){let n=Be(e);return e.fieldMode==="FIELDWIDTHS"?Nk(t,e.widths):e.fieldMode==="FPAT"?Ak(t,Fe(F(e.globals.get("FPAT"),e),n,e.warn)):xu(t,F(e.globals.get("FS"),e),F(e.globals.get("RS"),e)==="",n)}var Ok=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,yu=e=>e!==void 0&&e.type==="exit",Ti=class{constructor(t,n){this.ctx=t,this.stdin=n,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(t){for(;this.exitSignal===void 0;){if(this.src){let n=T1(this.src,F(t.globals.get("RS"),t),Be(t));if(n!==null)return t.globals.set("NR",W(t.globals.get("NR"))+1),t.globals.set("FNR",W(t.globals.get("FNR"))+1),t.globals.set("RT",n.rt),n.rec;this.closeFile(t);continue}if(!this.open(t))return null}return null}open(t){for(;this.idx<Math.trunc(W(t.globals.get("ARGC")));){if(++t.steps>Mn)throw new $("input operand scan exceeded execution limit",null,"execution limit");let n=F(t.globals.get("ARGV").get(String(this.idx++)),t);if(n==="")continue;t.globals.set("ARGIND",this.idx-1);let r=Ok.exec(n);if(r){t.assign(r[1],new j(ar(r[2],t.warn)));continue}this.sawFile=!0;let{text:i,error:o}=this.readOperand(n);if(o==="Is a directory"){this.failFile(t,n,o),this.exitSignal===void 0&&t.warn(`command line argument \`${n}' is a directory: skipped`);continue}if(o){let s=this.failFile(t,n,o);if(s!==void 0&&s.type==="nextfile")continue;if(this.exitSignal!==void 0)return!1;throw new $(`${n}: ${o}`)}if(this.use(t,n,i))return!0}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(t,"-",this.takeStdin()))}readOperand(t){if(t==="/dev/null")return{text:""};if(t==="-"||t==="/dev/stdin")return{text:t==="/dev/stdin"&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:n,error:r}=R(this.ctx,"awk",t);return this.ctx.fs.isDir(n)?{error:"Is a directory"}:r?{error:r}:{text:this.ctx.fs.readFile(n)}}takeStdin(){let t=this.stdin;return this.stdin="",X(this.ctx),t}use(t,n,r){this.src={text:r,pos:0},t.globals.set("FILENAME",n),t.globals.set("FNR",0),t.globals.set("ERRNO","");let i=t.fileRule("begin");return yu(i)?(this.exitSignal=i,this.src=null,!1):i!==void 0&&i.type==="nextfile"?(this.closeFile(t),!1):(ft(t,r),!0)}failFile(t,n,r){if(t.globals.set("ERRNO",r),!t.hasFileRules)return;t.globals.set("FILENAME",n),t.globals.set("FNR",0);let i=t.fileRule("begin");return yu(i)&&(this.exitSignal=i),i}closeFile(t){this.src=null;let n=t.fileRule("end");yu(n)&&(this.exitSignal=n)}readNamed(t,n){let r=this.readers.get(n);if(!r){let{text:o,error:s}=this.readOperand(n);if(s)return t.globals.set("ERRNO",s),{status:-1};r={text:ft(t,o),pos:0},this.readers.set(n,r)}let i=T1(r,F(t.globals.get("RS"),t),Be(t));return i===null?{status:0}:(t.globals.set("RT",i.rt),{status:1,record:i.rec})}close(t,n){return this.readers.delete(n)?0:(t.globals.set("ERRNO","close of redirection that was never opened"),-1)}};var Ik=(e,t)=>({isRef:!0,scope:e,name:t}),hr=e=>typeof e=="object"&&e!==null&&e.isRef===!0,mr=class extends Error{constructor(t){super(t.type),this.signal=t}},P1=e=>new $(`attempt to use array \`${e}\` in a scalar context`);function _i(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function Ck(e){let t=e;for(;hr(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function hn(e,t){let n=_i(e,t).get(t);return hr(n)?Ck(n):n}var Fk=new Set(["FS","FIELDWIDTHS","FPAT"]);function Li(e,t,n){let r=_i(e,t);if(r.get(t)instanceof Map)throw P1(t);if(r===e.globals){if(t==="NF"){_k(e,n);return}if(t==="FIELDWIDTHS"&&(e.widths=_1(F(n,e))),(t==="FPAT"||(t==="FS"||t==="RS")&&F(n,e).length>1)&&Fe(F(n,e),Be(e),e.warn,e.tables),Fk.has(t)){e.fieldMode=t;let i=e.globals.get("PROCINFO");i instanceof Map&&i.set("FS",t)}}r.set(t,n)}function ct(e,t){let n=_i(e,t),r=t,i=n,o=i.get(r);if(o instanceof Map)return o;let s=hr(o);for(;hr(o);)i=o.scope,r=o.name,o=i.get(r);if(!(o instanceof Map)){if(o!==void 0)throw new $(`attempt to use scalar \`${r}\` as an array`);o=new Map,i.set(r,o)}return s&&n.set(t,o),o}function Ri(e,t,n=new j(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...L1(e,t).map(r=>new j(r))],e.nf=e.fields.length-1,e.globals.set("NF",e.nf)}function D1(e){let t=F(e.globals.get("OFS"),e);e.record=e.fields.slice(1).map(n=>F(n,e)).join(t),e.recordValue=e.record}function U1(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function Tk(e,t,n){if(t===0){let r=F(n,e);Ri(e,r,typeof n=="number"?r:n);return}for(;e.nf<t;)e.fields[++e.nf]="";e.fields[t]=n,e.globals.set("NF",e.nf),D1(e)}function _k(e,t){let n=Math.trunc(W(t));if(n<0)throw new $(`NF set to negative value ${n}`);for(;e.nf<n;)e.fields[++e.nf]="";e.fields.length=n+1,e.nf=n,e.globals.set("NF",n),D1(e)}function B1(e,t){let n=W(I(e,t));if(!(n>=0))throw new $(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function gr(e,t){if(t.length===1)return gu(I(e,t[0]),e);let n=F(e.globals.get("SUBSEP"),e);return t.map(r=>gu(I(e,r),e)).join(n)}function ku(e,t){return t.type==="var"?t:t.type==="index"?{type:"index",arr:ct(e,t.name),key:gr(e,t.subs)}:{type:"field",i:B1(e,t.index)}}function q1(e,t){return t.type==="var"?W1(hn(e,t.name),t.name):t.type==="index"?t.arr.get(t.key):U1(e,t.i)}function vu(e,t,n){t.type==="var"?Li(e,t.name,n):t.type==="index"?t.arr.set(t.key,n):Tk(e,t.i,n)}function Su(e,t,n){vu(e,ku(e,t),n)}function R1(e,t,n){if(n===0&&(e==="/"||e==="%"))throw new $(e==="/"?"division by zero attempted":"division by zero attempted in `%`");return Hr(e,t,n)}var Lk={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function dt(e,t){let n=Be(e);return t.type==="regex"?n?Fe(t.source,!0,null,e.tables):t.re:Fe(F(I(e,t),e),n,e.warn,e.tables)}function W1(e,t){if(e instanceof Map)throw P1(t);return e}function M1(e,t,n){let r=ku(e,t.target),i=W(q1(e,r)),o=t.op==="++"?i+1:i-1;return vu(e,r,o),n?i:o}function I(e,t){switch(t.type){case"num":case"str":return t.value;case"regex":return dt(e,t).test(e.record)?1:0;case"var":return W1(hn(e,t.name),t.name);case"index":{let n=ct(e,t.name),r=gr(e,t.subs),i=n.get(r);return i===void 0&&n.set(r,void 0),i}case"field":return U1(e,B1(e,t.index));case"assign":{let n=ku(e,t.target),r=I(e,t.value);if(r instanceof Map)throw new $("attempt to use an array in a scalar context");return t.op!=="="&&(r=R1(t.op[0],W(q1(e,n)),W(r))),vu(e,n,r),r}case"cond":return I(e,$e(I(e,t.test))?t.consequent:t.alternate);case"or":return $e(I(e,t.left))||$e(I(e,t.right))?1:0;case"and":return $e(I(e,t.left))&&$e(I(e,t.right))?1:0;case"not":return $e(I(e,t.expr))?0:1;case"neg":return-W(I(e,t.expr));case"plus":return W(I(e,t.expr));case"binary":return R1(t.op,W(I(e,t.left)),W(I(e,t.right)));case"concat":return F(I(e,t.left),e)+F(I(e,t.right),e);case"compare":return Lk[t.op](Fi(I(e,t.left),I(e,t.right),e))?1:0;case"match":{let n=F(I(e,t.left),e);return dt(e,t.right).test(n)===t.negate?0:1}case"in":return ct(e,t.array).has(gr(e,t.keys))?1:0;case"preinc":return M1(e,t,!1);case"postinc":return M1(e,t,!0);case"call":return Rk(e,t);case"builtin":return e.callBuiltin(e,t);case"getline":return Pk(e,t);default:throw new $(`unknown expression: ${t.type}`)}}function Rk(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new $(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new $(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=Do)throw new $(`function call nesting deeper than ${Do} levels (runaway recursion?)`,null,"call depth limit");let r=e.frame,i=new Map;for(let o=0;o<n.params.length;o++)i.set(n.params[o],o<t.args.length?Mk(e,t.args[o]):void 0);e.frame=i,e.callDepth++;try{let o=e.execStmts(e,n.body);if(o===void 0||o.type==="return")return o?.value;throw new mr(o)}finally{e.frame=r,e.callDepth--}}function Mk(e,t){if(t.type!=="var")return I(e,t);let n=_i(e,t.name),r=n.get(t.name);return r instanceof Map||hr(r)?r:r===void 0?Ik(n,t.name):r}function Pk(e,t){let n;if(t.file===null){if(n=e.input.next(e),n===null)return 0}else{let r=e.input.readNamed(e,F(I(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?Ri(e,n):Su(e,t.target,new j(n)),1}var Je=(e,t)=>W(I(e,t)),$u=2**32;function z1(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var H1=()=>({seed:1,state:z1(1)});function Dk(e){e.rng.state=(e.rng.state+1831565813)%$u;let t=e.rng.state;t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61);let n=t^t>>>14;return(n<0?n+$u:n)/$u}function Uk(e,t){let n=e.rng.seed,r=t.length>0?Je(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=z1(r),n}function Bk(e,t){let n=Je(e,t[0]);return n<0&&e.warn(`log: received negative argument ${F(n,e)}`),Math.log(n)}function qk(e,t){let n=Je(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${F(n,e)}`),Math.sqrt(n)}function Wk(e,t){let n=Je(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${F(n,e)} is out of range`),r}function jk(e,t){let n=I(e,t[0]);if(typeof n=="number")return n;let r=n instanceof j?n.s:F(n,e),i=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(i)return i[1]===""?0:Number.parseInt(i[1],16);let o=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return o?Number.parseInt(o[0],8):W(new j(r))}function wr(e,t,n,r){let i=Je(e,n);if(i<0)throw new $(`${t}: argument ${r} negative value ${F(i,e)} is not allowed`);if(!Number.isFinite(i))throw new $(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(i)))}function Nu(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function Eu(e,t){return(n,r)=>{if(r.length<2)throw new $(`${e}: called with less than two arguments`);let i=wr(n,e,r[0],1);for(let o=1;o<r.length;o++)i=t(i,wr(n,e,r[o],o+1));return Nu(i)}}function j1(e,t){return(n,r)=>{let i=wr(n,e,r[0],1),o=wr(n,e,r[1],2)%64n;return Nu(BigInt.asUintN(64,t?i<<o:i>>o))}}var G1={__proto__:null,sin:(e,t)=>Math.sin(Je(e,t[0])),cos:(e,t)=>Math.cos(Je(e,t[0])),atan2:(e,t)=>Math.atan2(Je(e,t[0]),Je(e,t[1])),exp:Wk,log:Bk,sqrt:qk,int:(e,t)=>Math.trunc(Je(e,t[0])),rand:Dk,srand:Uk,systime:()=>Math.floor(Date.now()/1e3),strtonum:jk,and:Eu("and",(e,t)=>e&t),or:Eu("or",(e,t)=>e|t),xor:Eu("xor",(e,t)=>e^t),lshift:j1("lshift",!0),rshift:j1("rshift",!1),compl:(e,t)=>Nu(BigInt.asUintN(64,~wr(e,"compl",t[0],1)))};var Mi=new Map;function zk(e){let t=Mi.get(e);return t||(Mi.size>=256&&Mi.clear(),t=si(e),Mi.set(e,t)),t}function Pi(e,t,n){let r=0,i=()=>{if(r>=n.length)throw new $("printf: not enough arguments to satisfy format string");return n[r++]},o="";for(let s of zk(t)){if(typeof s=="string"){o+=s;continue}let u={...s};if(s.width==="*"){let a=Math.trunc(W(i()));a<0?(u.minus=!0,u.width=-a):u.width=a}if(s.precision==="*"){let a=Math.trunc(W(i()));u.precision=a<0?null:a}if(u.width>Ee||u.precision>Ee)throw new $(`printf: field width or precision above ${Ee} is not supported`,null,"format size limit");o+=Hk(e,u,i())}return o}function Hk(e,t,n){if(t.conv==="s"){let r=F(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join("")),$t("",r,t,!1)}return t.conv==="c"?$t("",ft(e,Gk(n)),t,!1):Ut(W(n),t)}function Gk(e){if(typeof e=="number"||e instanceof j&&pu(e.s)){let r=Math.trunc(W(e));if(!Xe(r))throw new $("printf: character code outside Unicode scalar values is not supported",null,"character code");return String.fromCodePoint(r)}let n=e instanceof j?e.s:e??"";return n===""?"\0":String.fromCodePoint(n.codePointAt(0))}var me=(e,t)=>F(I(e,t),e),X1=(e,t)=>W(I(e,t)),Xk={type:"field",index:{type:"num",value:0}};function Zk(e,t){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\"){if(e[r+1]==="\\"&&e[r+2]==="\\"&&(e[r+3]==="&"||e[r+3]==="\\")){n+="\\"+e[r+3],r+=3;continue}if(e[r+1]==="\\"&&e[r+2]==="&"){n+="\\"+t,r+=2;continue}if(e[r+1]==="&"){n+="&",r++;continue}}n+=i==="&"?t:i}return n}function Z1(e,t,n){let r=dt(e,t[0]),i=me(e,t[1]),o=t[2]??Xk,s=me(e,o),{out:u,count:a}=Pn(s,r,(l,f)=>Zk(i,s.slice(l,f)),n?"global":"first");return a>0&&Su(e,o,u),a}function Yk(e,t){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\"&&r+1===e.length)throw new $("gensub with a trailing replacement backslash is not supported",null,"gensub trailing backslash");if(i==="\\"&&r+1<e.length){let o=e[++r];o>="0"&&o<="9"?n+=t[Number(o)]?.text??"":n+=o;continue}n+=i==="&"?t[0].text:i}return n}function Vk(e,t){let n=dt(e,t[0]),r=me(e,t[1]),i=I(e,t[2]),o=F(i,e),s=o.startsWith("g")||o.startsWith("G"),u=0;s||(u=Math.trunc(W(i)),u<1&&(e.warn(`gensub: third argument \`${o}' treated as 1`),u=1));let a=t[3]?me(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return Pn(a,n,(f,c,d)=>!s&&d!==u?null:Yk(r,l?n.groups(a,f,c):[{text:a.slice(f,c)}]),s?"global":"nth").out}function Kk(e,t){let n=me(e,t[0]),r=dt(e,t[1]),i=r.search(n,0),o=i?Array.from(n.slice(0,i.start)).length+1:0;if(e.globals.set("RSTART",o),e.globals.set("RLENGTH",i?Array.from(n.slice(i.start,i.end)).length:-1),t[2]){let s=ct(e,t[2].name);if(s.clear(),i){let u=F(e.globals.get("SUBSEP"),e);r.groups(n,i.start,i.end).forEach((a,l)=>{a!==void 0&&(s.set(String(l),new j(a.text)),s.set(`${l}${u}start`,Array.from(n.slice(0,a.start)).length+1),s.set(`${l}${u}length`,[...a.text].length))})}}return o}function Jk(e,t){let n=me(e,t[0]),r=ct(e,t[1].name),i;t[2]===void 0?i=F(e.globals.get("FS"),e):t[2].type==="regex"?i=dt(e,t[2]):i=me(e,t[2]);let o=xu(n,i,!1,Be(e));return r.clear(),o.forEach((s,u)=>r.set(String(u+1),new j(s))),o.length}function Qk(e,t){let n=[...me(e,t[0])],r=Math.trunc(X1(e,t[1])),i=Number.isNaN(r)?1:Math.max(r,1),o=n.length+1;if(t[2]){let s=Math.trunc(X1(e,t[2]));if(!(s>=1))return"";o=Math.min(o,i+s)}return o>i?n.slice(i-1,o-1).join(""):""}function ev(e,t){if(t.length===0)return[...e.record].length;if(t[0].type==="var"){let n=hn(e,t[0].name);return n instanceof Map?n.size:[...F(n,e)].length}return[...me(e,t[0])].length}function tv(e,t){let n=me(e,t[0]),r=me(e,t[1]);Be(e)&&(n=jt(n),r=jt(r));let i=n.indexOf(r);return i<0?0:Array.from(n.slice(0,i)).length+1}function nv(e,t){let n=me(e,t[0]);return n==="/dev/stdout"||n==="/dev/stderr"||n==="/dev/null"?0:e.input.close(e,n)}var rv=(e,t)=>t[0].type==="var"?wu(hn(e,t[0].name)):wu(I(e,t[0])),iv={__proto__:null,...G1,length:ev,substr:Qk,index:tv,split:Jk,sub:(e,t)=>Z1(e,t,!1),gsub:(e,t)=>Z1(e,t,!0),gensub:Vk,match:Kk,sprintf:(e,t)=>Pi(e,me(e,t[0]),t.slice(1).map(n=>I(e,n))),tolower:(e,t)=>jt(me(e,t[0])),toupper:(e,t)=>jt(me(e,t[0]),!0),close:nv,fflush:()=>0,typeof:rv,isarray:(e,t)=>t[0].type==="var"&&hn(e,t[0].name)instanceof Map?1:0};function Y1(e,t){let n=iv[t.name];if(!n)throw new $(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var Ui={type:"break"},Ou={type:"continue"},ov={type:"next"},sv={type:"nextfile"},uv={type:"exit"};function V1(e,t,n,r){let i=new Map([["0","awk"]]);r.forEach((u,a)=>i.set(String(a+1),new j(u)));let o=new Map([["FS"," "],["OFS"," "],["ORS",`
|
|
220
|
+
`;return}n+=r+e.script[e.i++]}else n+=r}t.command.text=gk(n+`
|
|
221
|
+
`),e.textState.pending=null}function du(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function gk(e){return W(fu(e))}function fu(e){let t=A(e),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(o!==92||r+1===t.length){n.push(o);continue}let i=String.fromCodePoint(t[++r]);if(Object.hasOwn(d1,i)){n.push(d1[i]);continue}if(Object.hasOwn(p1,i)){let s=p1[i],u=s===16?2:3,a=0,l=0;for(;a<u&&r+1<t.length;){let f=t[r+1],c=f>=48&&f<=57?f-48:(f|32)>=97&&(f|32)<=102?(f|32)-87:-1;if(c<0||c>=s)break;l=l*s+c,a++,r++}n.push(a?l&255:i.codePointAt(0))}else if(i==="c"){if(++r===t.length)continue;let s=t[r];if(s===92&&t[++r]!==92)throw new Error("recursive escaping after \\c not allowed");n.push((s>=97&&s<=122?s-32:s)^64)}else n.push(i.codePointAt(0))}return Uint8Array.from(n)}function g1(e){let t=fr(e,"'y' command"),n=fu(h1(e,t)),r=fu(h1(e,t)),o=e.byteLocale?n:[...W(n)],i=e.byteLocale?r:[...W(r)];if(o.length!==i.length)throw new Error("'y' command strings have different lengths");let s=e.byteLocale?Uint8Array.from({length:256},(u,a)=>a):new Map;for(let u=0;u<o.length;u++)e.byteLocale?s[o[u]]=i[u]:s.has(o[u])||s.set(o[u],i[u]);return{translation:s,byteLocale:e.byteLocale}}function h1(e,t){let n="";for(;e.i<e.script.length;){let r=e.script[e.i++];if(r===`
|
|
222
|
+
`)break;if(r===t)return n;if(r!=="\\"){n+=r;continue}let o=e.script[e.i++];if(o===void 0)break;n+=o===t||o===`
|
|
223
|
+
`?o:r+o}throw new Error("unterminated 'y' command")}function w1(e,t){if(t.byteLocale)return W(A(e).map(r=>t.translation[r]));let n="";for(let r of e)n+=t.translation.get(r)??r;return n}function pu(e,t=!1,n=ee,r=null){let o={script:e,i:0,extended:t,locale:n,byteLocale:Mr(n),textState:r??{},openWrite:r?.openWrite},i=[];for(cu(o);o.i<e.length;){if(/[;\n\r\f\v \t]/u.test(e[o.i])){o.i++;continue}e[o.i]==="#"&&Ee("comments");let s=y1(o),u=null;if(s&&e[o.i]===","&&(o.i++,u=y1(o,!0),u===null))throw new Error("missing second address");e[o.i]==="~"&&Ee("step address");let a=s?.type==="line"&&s.value===0;if(a&&u?.type!=="regex")throw new Error("line numbers must be >= 1");let l=!1;if(e[o.i]==="!"){for(l=!0,o.i++;/[ \t]/u.test(e[o.i]??"");)o.i++;if(e[o.i]==="!")throw new Error("multiple '!'s")}let f=e[o.i++],c={kind:f,start:s,end:u,active:a,negated:l};if(f&&"pPnNdD=gGhHx".includes(f))i.push(c);else if(f==="w"){i.push({...c,...iu(o)});continue}else if(f===":"||f==="b"||f==="t"||f==="T"){i.push({...c,label:wk(o,c)});continue}else if(f==="s")i.push({...c,...f1(o)});else if(f==="a"||f==="i"||f==="c")m1(o,c),i.push(c);else if(f==="y")i.push({...c,...g1(o)});else if(f==="q"){if(u!==null)throw new Error("command only uses one address");let d=/^[ \t]*(\d*)/u.exec(e.slice(o.i));o.i+=d[0].length;let p=BigInt.asIntN(32,BigInt(d[1]||"0"));i.push({...c,exitCode:p===-1n?0:Number(BigInt.asUintN(8,p))})}else if(f==="{"){o.textState.blockDepth=(o.textState.blockDepth??0)+1,i.push(c);continue}else if(f==="}"){if(!o.textState.blockDepth)throw new Error("unexpected '}'");if(s!==null)throw new Error("'}' doesn't want any addresses");o.textState.blockDepth--,i.push(c)}else{if(f===void 0)throw new Error("missing command");if("QlLFzrRWev".includes(f))Ee();else throw new Error(`unknown command: '${f}'`)}for(;/[ \t]/u.test(e[o.i]??"");)o.i++;if(e[o.i]==="#"&&Ee("comments"),o.i<e.length&&!/[;\n}]/u.test(e[o.i]))throw new Error("extra characters after command")}return r===null&&du(o.textState),i}function hu(e,t){let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.kind==="{"&&n.push(o),o.kind==="}"){if(n.length===0)throw new Error("unexpected '}'");n.pop().jump=r}}if(n.length)throw new Error("unmatched '{'");return du(t),yk(e),e}function wk(e,t){if(t.kind===":"&&t.start!==null)throw new Error("':' doesn't want any addresses");let n=/^[ \t]*([^ \t\n;}#]*)/u.exec(e.script.slice(e.i));e.i+=n[0].length;let r=n[1].split("\0",1)[0];if(t.kind===":"&&r==="")throw new Error("':' lacks a label");return r}function yk(e){let t=new Map;for(let n=0;n<e.length;n++)e[n].kind===":"&&t.set(e[n].label,n);for(let n=e.length-1;n>=0;n--){let r=e[n];if(!["b","t","T"].includes(r.kind))continue;let o=r.label===""?e.length:t.get(r.label);if(o===void 0)throw Object.assign(new Error(`can't find label for jump to \`${r.label}'`),{exitCode:4});r.jump=o}}function y1(e,t=!1){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;e.script[e.i]==="~"&&Ee("step address");let n=/^(\d+|\+[ \t]*\d+)/u.exec(e.script.slice(e.i)),r=null;if(n){let o=n[0][0]==="+";if(o&&!t)throw new Error("relative address requires a range");let i=Number(n[0].replace(/[ \t]/gu,""));Number.isSafeInteger(i)||Ee("address limit"),e.i+=n[0].length,r={type:o?"offset":"line",value:i}}else if(e.script[e.i]==="$")e.i++,r={type:"last"};else if(e.script[e.i]==="/"||e.script[e.i]==="\\"){e.script[e.i]==="\\"&&e.i++;let o=fr(e,"address regex"),i=Ro(e,o,!0,"address regex"),s=!1;for(;;){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;let u=e.script[e.i];if(u!=="I"&&u!=="M")break;if(i==="")throw new Error("cannot specify modifiers on empty regexp");u==="M"&&Ee("address regex flags"),s=!0,e.i++}r={type:"regex",...su(i,e.extended,!0,s,e.locale)}}for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;return r}function b1(e,t,n,r,o){let{start:i,end:s}=e;if(i===null)return!0;if(s===null)return Mo(i,t,n,r,o);if(!e.active){if(i.type==="line"){if(e.closed||n<i.value)return!1}else if(!Mo(i,t,n,r,o))return!1;if(e.active=!0,s.type==="regex")return!0;if(s.type==="offset"&&(e.until=n+s.value),s.type==="line")return e.active=n<s.value,e.closed=!e.active,n<=s.value||Mo(i,t,n,r,o)}return s.type==="line"?(e.active=n<s.value,e.closed=!e.active,n<=s.value):((s.type==="offset"?n>=e.until:Mo(s,t,n,r,o))&&(e.active=!1,e.closed=!0),!0)}function Mo(e,t,n,r,o){if(e.type==="line")return n===e.value;if(e.type==="last")return typeof r=="function"?r():r;let i=au(e,o);return uu(t,i),i.re.search(t)!==null}function mu(e,t,n,r=!1){let{output:o,delimiter:i}=e,s=t.has("n")||t.has("quiet")||t.has("silent"),u=t.has("s")||t.has("separate"),a=l1(e.files,e.stdin,n,i,u,p=>o.stream(2,p)),l=o.start(a),f=[],c=ou(r?p=>{o.account(p),f.push(p)}:p=>o.stream(1,p),i),d={delimiter:i,quiet:s,separate:u,hold:e.hold,regexState:e.regexState,budget:e.budget,emit:c,input:a,output:o};try{let p=bk(e.commands,d);l.quit=p!==null,l.exitCode=a.status.failed?a.status.directory?4:2:p??0,l.failed=a.status.failed}catch(p){let h=Fo(p);_(l,h);let m=O(h);m&&ie(l,m.kind,m.command,m.detail,m.message),l.failed=!0}finally{o.finish()}return r&&(l.content=f.join("")),l}function bk(e,t){let n=!0;for(let r=t.input.next();r;r=t.input.next()){if(n||t.separate&&r.reset){t.hold.text="";for(let s of e)s.active=s.start?.type==="line"&&s.start.value===0,s.closed=!1;n=!1}t.output.record(r);let o={...r,...t,append:[],exitCode:null,replaced:!1},i=xk(e,o);if(!t.quiet&&!i&&t.emit(o.text,o.terminator),o.exitCode!==null&&t.emit(""),x1(o),o.exitCode!==null)return o.exitCode;t.output.record(null)}return null}function xk(e,t){for(let n=0;n<e.length;n++){if(++t.budget.steps>nu)throw new b("feature","execution limit",`sed: execution limit reached after ${nu} commands (infinite loop?)`);let r=e[n];if(r.kind==="}"||r.kind===":")continue;if(b1(r,t.text,t.line,t.last,t.regexState)===!!r.negated){r.kind==="{"&&(n=r.jump);continue}let i=r.kind;if(i!=="{"){if(i==="b"||i==="t"||i==="T"){let s=i==="b"||(i==="t"?t.replaced:!t.replaced);i!=="b"&&(t.replaced=!1),s&&(n=r.jump-1);continue}if(i==="q"){t.exitCode=r.exitCode;break}if(i==="d")return!0;if(i==="D"){let s=t.text.indexOf(t.delimiter);if(s<0)return!0;t.text=t.text.slice(s+t.delimiter.length),n=-1;continue}if(i==="n"||i==="N"){if(!Sk(t,i==="N"))return!0;continue}if(i==="c")return!r.active&&r.text!==null&&t.emit(r.text.slice(0,-1),t.delimiter),!0;if(kk(r,t),t.text.length>To)throw new b("feature","pattern space limit","sed: pattern space limit exceeded")}}return!1}function kk(e,t){let{kind:n}=e;if(n==="a"){t.append.push(e.text);return}if(n==="i")e.text!==null&&t.emit(e.text.slice(0,-1),t.delimiter);else if(n==="p")t.emit(t.text,t.terminator);else if(n==="P"){let r=t.text.indexOf(t.delimiter);t.emit(r<0?t.text:t.text.slice(0,r),r<0?t.terminator:t.delimiter)}else if(n==="=")t.emit(String(t.line),t.delimiter);else if(n==="w")e.writer(t.text,t.terminator);else if("gGhHx".includes(n))vk(n,t);else if(n==="y")t.text=w1(t.text,e);else{let r=lu(t.text,e,t.regexState);if(t.text=r.out,!r.count)return;t.replaced=!0,e.print&&t.emit(t.text,t.terminator),e.writer&&e.writer(t.text,t.terminator)}}function vk(e,t){let n=t.hold;if(e==="x"){let{text:r,terminator:o}=t;Object.assign(t,n),Object.assign(n,{text:r,terminator:o})}else{let r=e==="h"||e==="H"?t:n,o=r===n?t:n;o.text=e==="G"||e==="H"?o.text+t.delimiter+r.text:r.text,o.terminator=r.terminator}if(n.text.length>To)throw new b("feature","hold space limit","sed: hold space limit exceeded")}function Sk(e,t){if(!t&&!e.quiet&&e.emit(e.text,e.terminator),e.last())return t&&!e.quiet&&e.emit(e.text,e.terminator),!1;x1(e);let n=e.input.next();if(!n)return t&&!e.quiet&&e.emit(e.text,e.delimiter),!1;let r=t?e.text+e.delimiter+n.text:n.text;if(r.length>To)throw new b("feature","pattern space limit","sed: pattern space limit exceeded");return Object.assign(e,n,{text:r,replaced:!1}),e.output.record(n),!0}function x1(e){if(e.append.length!==0){e.emit("");for(let t of e.append)e.emit(t??"");e.append.length=0}}function k1(e,t,n){try{let{tokens:r,inPlace:o}=s1(t),i=N(r,{short:["n","E","r","s","z"],long:["regexp-extended","quiet","silent","separate","null-data","zero-terminated"],repeatable:["e","expression","f","file"]}),s=i.flags.has("z")||i.flags.has("null-data")||i.flags.has("zero-terminated")?"\0":`
|
|
224
|
+
`,u=a1(n,s),a=Ek(i,e,n,u.openWrite);return a===null?x(Io):a.error?a.error:(Object.assign(a,{output:u,delimiter:s,hold:{text:"",terminator:s},regexState:{last:null},budget:{steps:0}}),a.stdin=lr(a.stdin,n),o===null?mu(a,i.flags,n):u1(a,i.flags,n,o,(l,f)=>mu(l,f,n,!0)))}catch(r){return Fo(r)}}function Ek({order:e,positional:t},n,r,o){let i=[],s={openWrite:o},u=!1,a=!1;for(let{name:l,value:f}of e){if((l==="E"||l==="r"||l==="regexp-extended")&&(u=!0),!["e","expression","f","file"].includes(l))continue;a=!0;let c=f;if(l==="f"||l==="file"){n=lr(n,r);let d=n,p=r.io.bufferReads(()=>st("sed",[f],r,d));if(p.failed)return{error:x(p.stderr,4)};c=p.inputs[0].content,p.inputs[0].shared&&(n="")}for(let d of pu(c,u,r.locale,s))i.push(d)}return a?{commands:hu(i,s),files:t,stdin:n}:t.length===0?null:{commands:hu(pu(t[0],u,r.locale,s),s),files:t.slice(1),stdin:n}}var $k=new Set(["-b","-c","-g","-k","-p","-r","-s","-t","-u","-v","-w","-x","-G","-N","-O","-R","-S","-o"]),Nk=new Set(["-nt","-ot","-ef","<",">"]),dr={__proto__:null,"-eq":(e,t)=>e===t,"-ne":(e,t)=>e!==t,"-lt":(e,t)=>e<t,"-le":(e,t)=>e<=t,"-gt":(e,t)=>e>t,"-ge":(e,t)=>e>=t},Ak=String(ue).length,Ok=new Set(["/dev/stdin","/dev/stdout","/dev/stderr"]);function E1(e,t,n){return N1("test",t,n)}function $1(e,t,n){return t.at(-1)!=="]"?x("[: missing `]'",2):N1("[",t.slice(0,-1),n)}function N1(e,t,n){try{return{...F(),exitCode:gu(t,n)?0:1}}catch(r){return K(r,e,`${e}: ${r.message}`,2)}}function gu(e,t){let[n,r,o]=e;if(e.length===0)return!1;if(e.length===1)return n!=="";if(e.length===2){if(n==="!")return r==="";if(n==="-n")return r!=="";if(n==="-z")return r==="";if(["-a","-e","-f","-d","-h","-L"].includes(n))return wu(n,r,t);throw $k.has(n)&&cr(n),new Error(`${n}: unary operator expected`)}if(e.length===3){if(r==="="||r==="==")return n===o;if(r==="!=")return n!==o;if(Object.hasOwn(dr,r))return dr[r](v1(n),v1(o));Nk.has(r)&&cr(r),(r==="-a"||r==="-o")&&cr("compound expressions")}if(e.length<=4){if(n==="!")return!gu(e.slice(1),t);if(n==="("&&e.at(-1)===")")return gu(e.slice(1,-1),t)}throw e.some(i=>["-a","-o","!","(",")"].includes(i))&&cr("compound expressions"),new Error(e.length>3?"too many arguments":`${r}: binary operator expected`)}function v1(e){let t=/^[ \t\n\r\f\v]*([+-]?)(\d+)[ \t]*$/u.exec(e);if(t&&t[0].length===e.length){let n=t[2].replace(/^0+/u,"")||"0";if(n.length<=Ak){let r=BigInt(t[1]+n);if(r>=ot&&r<=ue)return r}}throw new Error(`${e}: integer expression expected`)}function wu(e,t,n){let r={isDir:u=>u==="/dev"||u==="/dev/fd"||n.fs.isDir(u),isFile:u=>u==="/dev/null"||S1(u)||n.fs.isFile(u),isLink:u=>n.fs.isLink?.(u)===!0,readLink:u=>n.fs.readLink?.(u)},o=e==="-h"||e==="-L",{path:i,error:s}=E(n.cwd,t,r,{follow:!o});return s?!1:(S1(i)&&cr("stream device metadata"),o?r.isLink(i):e==="-e"||e==="-a"?!0:e==="-d"?r.isDir(i):i!=="/dev/null"&&n.fs.isFile(i))}function S1(e){return Ok.has(e)||/^\/dev\/fd\/\d+$/u.test(e)}function cr(e){throw new b("feature",e,`${e} is not supported`)}function C1(e){let t=e.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/gu,""),n=/^[+-]?\d+$/u.test(t)?BigInt(t):null,r=n!==null&&n>=ot&&n<=ue?n:null;return{arg:t,n:r}}var mn=e=>({...e,halt:!0});function Ck(e,t,n){let r=t[0]==="--"?t.slice(1):t;if(r.length===0)return mn({...F(),exitCode:n.lastExit});let{arg:o,n:i}=C1(r[0]);return i===null?mn(x(`exit: ${o}: numeric argument required`,2)):r.length>1?mn(x("exit: too many arguments")):mn({...F(),exitCode:Number((i%256n+256n)%256n)})}function A1(e){return(t,n,r)=>{let o=n[0]==="--"?n.slice(1):n;if(o.length>1)return mn(x(`${e}: too many arguments`));let{arg:i,n:s}=C1(o[0]??"1");return s===null?mn(x(`${e}: ${i}: numeric argument required`,128)):s<=0?{...x(`${e}: ${i}: loop count out of range`),control:r.loopDepth?{type:"break",levels:r.loopDepth}:void 0}:r.loopDepth===0?x(`${e}: only meaningful in a \`for\`, \`while\` or \`until\` loop`,0):{...F(),control:{type:e,levels:Number(s>BigInt(r.loopDepth)?BigInt(r.loopDepth):s)}}}}function Ik(e,t,n){let r=t[0]==="--",o=r?t.slice(1):t;if(o.length===0||!r&&o[0]==="-p")return v("option","export","-p","export: listing the environment is not supported (there is none)");let i="";for(let s of o){let u=s.indexOf("="),a=u>0&&s[u-1]==="+",l=u===-1?s:s.slice(0,a?u-1:u);if(!r&&s.startsWith("-"))return v("option","export",s,`export: option \`${s}\` is not supported`);if(!Lt.test(l)){i+=`export: \`${l}': not a valid identifier
|
|
225
|
+
`;continue}u!==-1?n.vars.set(l,(a?dd(l,n):"")+s.slice(u+1)):n.vars.has(l)&&n.vars.set(l,n.vars.get(l))}return{stdout:"",stderr:i,exitCode:i?1:0}}function Tk(e,t,n){let r=t[0]==="-v"?1:0,o=t[r]==="--";o&&r++;let i=t.slice(r);for(let s of i){if(!o&&s.startsWith("-"))return v("option","unset",s,`unset: option \`${s}\` is not supported`);if(s.includes("["))return v("feature","unset","array subscript","unset: array subscripts are not supported");if(s==="LANG")return v("feature","unset","LANG",`unset: LANG: ${Rr}`);n.vars.delete(s)}return F()}function Fk(e,t,n){let r=null;for(let o=0;o<t.length;o++){let i=t[o];if(i==="-e"||i==="+e")r=i==="-e";else if((i==="-o"||i==="+o")&&t[o+1]==="errexit")r=i==="-o",o++;else return O1()}return r===null?O1():(n.errexit=r,F())}var O1=()=>v("feature","set","set","set: `set` is supported only as `set -e` or `set +e`",127),yu={exit:Ck,break:A1("break"),continue:A1("continue"),export:Ik,set:Fk,unset:Tk},I1=new Map([["return"," (there are no shell functions)"],["source"," (nothing can be sourced into this shell)"],[".","","`.` (source)"],"eval","exec",["read"," (there is no interactive input)"],["shift"," (there are no positional parameters)"],"shopt",["local"," (there are no shell functions)"],["declare","; use `NAME=value`"],["typeset","; use `NAME=value`"],["readonly","; use `NAME=value`"],["let"," (no arithmetic)"],["type","; use `which`"],["command","; run the command directly"],"builtin","hash","alias","unalias","trap",["wait"," (nothing runs in the background)"],["kill"," (there are no processes)"],["jobs"," (there are no processes)"],["bg"," (there are no processes)"],["fg"," (there are no processes)"],["disown"," (there are no processes)"],"suspend","times","ulimit","umask",["pushd","; use `cd`"],["popd","; use `cd -`"],"dirs","history","help","logout","getopts","mapfile","readarray","caller","enable","compgen","complete","bind","fc"].map(e=>{let[t,n="",r="`"+t+"`"]=Array.isArray(e)?e:[e];return[t,r+" is not supported"+n]}));function T1(e,t){let n=0,r=!0,o=!1;for(;n<t.length&&/^-[neE]+$/u.test(t[n]);n++)for(let s of t[n].slice(1))s==="n"?r=!1:o=s==="e";let i=t.slice(n).join(" ");if(o){let s=Lk(i);i=s.text,s.stop&&(r=!1)}return F(r?i+`
|
|
226
|
+
`:i)}function Lk(e){let t={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92},n=[],r=i=>{for(let s of A(i))n.push(s)},o=i=>({text:W(Uint8Array.from(n)),stop:i});for(let i=0;i<e.length;i++){if(e[i]!=="\\"||i+1>=e.length){let l=e.indexOf("\\",i+1),f=l<0?e.length:l;r(e.slice(i,f)),i=f-1;continue}let s=e[++i];if(s==="c")return o(!0);if(s in t){n.push(t[s]);continue}if(s==="0"){let l="";for(;l.length<3&&/[0-7]/u.test(e[i+1]??"");)l+=e[++i];n.push(l===""?0:parseInt(l,8)&255);continue}let u=s==="x"?2:s==="u"?4:s==="U"?8:0;if(u>0&&/[0-9a-fA-F]/u.test(e[i+1]??"")){let l="";for(;l.length<u&&/[0-9a-fA-F]/u.test(e[i+1]??"");)l+=e[++i];let f=parseInt(l,16);if(s==="x")n.push(f);else{if(!Ze(f))throw new b("feature","echo Unicode escape","echo: escapes outside Unicode scalar values are not supported");r(String.fromCodePoint(f))}continue}let a=i+Le(e,i);r("\\"+e.slice(i,a)),i=a-1}return o(!1)}var F1={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92};function bu(e,t,n,r){let o=e[t+1],i=t+2;if(o===void 0)return{bytes:[92],end:t+1};if(n&&o==="c")return{bytes:[],end:i,stop:!0};if(Object.hasOwn(F1,o))return{bytes:[F1[o]],end:i};if(!n&&`'"?`.includes(o))return{bytes:[o.codePointAt(0)],end:i};if(/[0-7]/u.test(o)){let u=n&&o==="0"?4:3;for(;i<t+1+u&&/[0-7]/u.test(e[i]??"");)i++;return{bytes:[parseInt(e.slice(t+1,i),8)&255],end:i}}let s=o==="x"?2:o==="u"?4:o==="U"?8:0;if(s){for(;i<t+2+s&&/[\da-fA-F]/u.test(e[i]??"");)i++;if(i===t+2||o!=="x"&&i!==t+2+s)return r.stderr+=`printf: missing hexadecimal number in escape
|
|
227
|
+
`,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let u=parseInt(e.slice(t+2,i),16);if(o==="x")return{bytes:[u],end:i};if(!Ze(u))throw new b("feature","Unicode escape","escapes outside Unicode scalar values are not supported");if(r.byteLocale&&u>127)throw new b("feature","Unicode escape in C locale","non-ASCII Unicode escapes in the C locale are not supported");return{bytes:A(String.fromCodePoint(u)),end:i}}return i=t+1+Le(e,t+1),{bytes:A(e.slice(t,i)),end:i}}function L1(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]==="\\"){let o=bu(e,r,!0,t);for(let i of o.bytes)n.push(i);if(r=o.end,o.stop){t.stop=!0;break}}else{let o=e.indexOf("\\",r),i=o<0?e.length:o;for(let s of A(e.slice(r,i)))n.push(s);r=i}return Uint8Array.from(n)}var Rk=/^%([-+ #0']*)(\d+|\*)?(?:\.(-?\d+|\*)?)?([hlLjzt]*)(.)?/su,Mk=8e6;function _1(e,t,n){let r=t[0]==="--"?t.slice(1):t;if(r.length===0)return pe("printf format [arguments]");if(t[0]!=="--"&&/^-./su.test(t[0])){let s=t[0].startsWith("-v")?"-v":t[0];return v("option","printf",s,`printf: option ${s} is not supported`,2)}let o={args:r.slice(1),index:0,chunks:[],size:0,stderr:"",failed:!1,stop:!1,byteLocale:le(n)},i;try{if(r.some(s=>s.includes("\0")))throw new b("feature","NUL in argument","NUL bytes in command arguments are not supported");do{let s=o.index;if(Dk(r[0],o),o.index===s)break}while(!o.stop&&o.index<o.args.length);i=F()}catch(s){i=K(s,"printf",`printf: ${s.message}`)}try{i.stdout=Pk(o)}catch(s){let u=O(i);u&&n.unsupported.add(u,"printf");let a=K(s,"printf",`printf: ${s.message}`);a.stderr=i.stderr+a.stderr,i=a}return i.stderr=o.stderr+i.stderr,o.failed&&i.exitCode===0&&(i.exitCode=1),i}function zt(e,t){if(e.size+t.length>Mk)throw new b("feature","format size limit","formatted output exceeds the output limit");t.length&&e.chunks.push(t),e.size+=t.length}function Pk(e){let t=new Uint8Array(e.size),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return W(t)}var xu=e=>e.args[e.index++];function Dk(e,t){for(let n=0;n<e.length&&!t.stop;)if(e[n]==="\\"){let r=bu(e,n,!1,t);zt(t,r.bytes),n=r.end}else if(e[n]==="%"){if(e[n+1]==="%"){zt(t,[37]),n+=2;continue}let r=Bk(e.slice(n),t);n+=r.length;let o=xu(t);if("sbc".includes(r.conv))Uk(o??"",r,t);else{let i="diouxX".includes(r.conv)?yo(wo(o,"ouxX".includes(r.conv),t),r):Ud(o,r,t);zt(t,A(i))}}else{let r=n+1;for(;r<e.length&&e[r]!=="%"&&e[r]!=="\\";)r++;zt(t,A(e.slice(n,r))),n=r}}function Bk(e,t){if(/^%[-+ #0'\d.*]*\$/u.test(e))throw new b("feature","positional format arguments","positional format arguments are not supported");let n=Rk.exec(e),[,r,o,i,s,u]=n;if(u===void 0)throw new Error("missing format character");if(!"sbcdiouxXeEfFgG".includes(u))throw"aAqQnCS(p%I".includes(u)?new b("feature","%"+u,`format %${u} is not supported`):new Error(`invalid format character: ${u}`);if(s&&"sbc".includes(u))throw new b("feature","format length modifier","length modifiers on string and character formats are not supported");let a={conv:u,length:n[0].length,minus:r.includes("-"),plus:r.includes("+"),space:r.includes(" "),zero:r.includes("0"),alt:r.includes("#"),width:Number(o==="*"?wo(xu(t),!1,t):o??0),precision:i==="*"?Number(wo(xu(t),!1,t)):i===void 0?n[0].includes(".")?0:null:Number(i)};if(o==="*"&&Math.abs(a.width)>2147483647||i==="*"&&(a.precision<-2147483648||a.precision>2147483647))throw new b("feature","format size limit","star width or precision outside the signed 32-bit range is not supported");if(a.width<0&&(a.minus=!0,a.width=-a.width),a.precision<0&&(a.precision=null),a.width>Ce||a.precision>Ce)throw new b("feature","format size limit","format width or precision exceeds the output limit");return a}function Uk(e,t,n){let r=t.conv==="b"?L1(e,n):A(e);t.conv==="c"?r=r.length?r.subarray(0,1):new Uint8Array(1):t.precision!==null&&(r=r.subarray(0,t.precision));let o=Math.max(0,t.width-r.length),i=o?new Uint8Array(o).fill(32):[];t.minus||zt(n,i),zt(n,r),t.minus&&zt(n,i)}function jk(e,t){if(!e.includes(`
|
|
228
|
+
`))return e;let n=le(t);if(!n&&/[\u0080-\u009F\u2028\u2029]/u.test(e))throw new b("feature","filename quoting","wc: locale-sensitive filename quoting is not supported");let r=n?Array.from(A(e),u=>String.fromCodePoint(u)):[...e],o={7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r"},i=!1,s="'";for(let u of r){let a=u.codePointAt(0);a<32||a===127||n&&a>127?(i||(s+="'$'"),s+=o[a]??"\\"+a.toString(8).padStart(3,"0"),i=!0):(u==="'"?s+="'\\''":s+=(i?"''":"")+u,i=!1)}return s+"'"}function R1(e,t,n,r,o){let i=[];for(let s of["l","w","m","c"])n[s]&&i.push(String(e[s]).padStart(r));return i.join(" ")+(t?" "+jk(t,o):"")}var Wk=["**=","**","++","--","+=","-=","*=","/=","%=","^=","==","!=","<=",">=","&&","||","!~",">>","|&","+","-","*","/","%","^","!",">","<","|","?",":","~","$","=","(",")","{","}","[","]",";",","],qk=new Set(["number","string","name","builtin"]),zk=new Set([")","]","++","--"]),Hk=/^(?:0[xX][0-9a-fA-F]+|\d+\.?\d*(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/u,Gk=e=>e!==void 0&&/[A-Za-z_]/u.test(e),Xk=e=>e!==void 0&&/[A-Za-z0-9_]/u.test(e),M1=e=>e!==void 0&&e>="0"&&e<="9";function B1(e,t=null){let n=[],r=1,o=0,i=(u,a)=>n.push({type:u,value:a,line:r}),s=()=>{let u=n.at(-1);return u?qk.has(u.type)?!1:!(u.type==="punct"&&zk.has(u.value)):!0};for(;o<e.length;){let u=e[o];if(u===`
|
|
229
|
+
`){n.at(-1)?.type!=="newline"&&i("newline",`
|
|
230
|
+
`),r++,o++;continue}if(u===" "||u===" "||u==="\r"){o++;continue}if(u==="\\"&&(e[o+1]===`
|
|
231
|
+
`||e[o+1]==="\r"&&e[o+2]===`
|
|
232
|
+
`)){o+=e[o+1]===`
|
|
233
|
+
`?2:3,r++;continue}if(u==="#"){for(;o<e.length&&e[o]!==`
|
|
234
|
+
`;)o++;continue}if(u==='"'){let f=U1(e,o+1,t,r);i("string",f.value),o=f.end;continue}if(u==="/"&&s()){let f=Vk(e,o+1,r);i("regex",f.value),o=f.end;continue}if(M1(u)||u==="."&&M1(e[o+1])){let f=Zk(e,o);i("number",f.value),o=f.end;continue}if(Gk(u)){let f=o+1;for(;Xk(e[f]);)f++;let c=e.slice(o,f);if(e.slice(f,f+2)==="::")throw new $("namespaces are not supported",r,"namespaces");o=f,Of.has(c)?i("keyword",c==="func"?"function":c):Cf.has(c)?i("builtin",c):i(e[f]==="("?"funcname":"name",c);continue}let a=o,l=Wk.find(f=>e.startsWith(f,a));if(u==="@")throw new $("typed regexes, indirect calls and source directives are not supported",r,"@ extensions");if(!l)throw new $(`unexpected character \`${u}\``,r);i("punct",l),o+=l.length}return i("eof",""),n}function Zk(e,t){let n=Hk.exec(e.slice(t))[0],r=n;return/^0[xX]/u.test(n)?r=String(Number.parseInt(n.slice(2),16)):/^0[0-7]+$/u.test(n)&&(r=String(Number.parseInt(n,8))),{value:r,end:t+n.length}}var P1={__proto__:null,n:`
|
|
235
|
+
`,t:" ",r:"\r",a:"\x07",b:"\b",f:"\f",v:"\v",'"':'"',"\\":"\\"};function Yk(e,t,n){let r=e[t+1];if(r===void 0)return{text:"\\",end:t+1};if(r in P1)return{text:P1[r],end:t+2};if(r>="0"&&r<="7"){let o=t+1;for(;o<t+4&&e[o]>="0"&&e[o]<="7";)o++;return{byte:Number.parseInt(e.slice(t+1,o),8)&255,end:o}}if(r==="x"&&/[0-9a-fA-F]/u.test(e[t+2]??"")){let o=t+2;for(;o<t+4&&/[0-9a-fA-F]/u.test(e[o]??"");)o++;return{byte:Number.parseInt(e.slice(t+2,o),16),end:o}}if(r.codePointAt(0)>127)throw new $("non-ASCII characters after an escape are not supported",null,"non-ASCII string escape");return n?.(`escape sequence \`\\${r}' treated as plain \`${r}'`),{text:r,end:t+2}}function U1(e,t,n,r=null){let o=[],i=t;for(;i<e.length;){let s=e[i];if(r!==null){if(s==='"')return{value:W(Uint8Array.from(o)),end:i+1};if(s===`
|
|
236
|
+
`)break;if(s==="\\"&&e[i+1]===`
|
|
237
|
+
`){i+=2;continue}}if(s==="\\"){let u=Yk(e,i,n);D1(o,u),i=u.end}else{let u=String.fromCodePoint(e.codePointAt(i));D1(o,{text:u}),i+=u.length}}if(r!==null)throw new $("unterminated string",r);return{value:W(Uint8Array.from(o)),end:i}}function Vk(e,t,n){let r=t,o=!1;for(;r<e.length;){let i=e[r];if(i===`
|
|
238
|
+
`)break;if(i==="\\"){r+=2;continue}if(o){if(i==="["&&e[r+1]===":"){let s=e.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}i==="]"&&(o=!1),r++;continue}if(i==="["){o=!0,r++,e[r]==="^"&&r++,e[r]==="]"&&r++;continue}if(i==="/")return{value:e.slice(t,r),end:r+1};r++}throw new $("unterminated regexp",n)}function pr(e,t=null){return U1(e,0,t).value}function D1(e,t){if(t.byte===void 0)for(let n of A(t.text))e.push(n);else e.push(t.byte)}var Kk=new Set(["=","+=","-=","*=","/=","%=","^=","**="]),j1=new Set(["<","<=","==","!=",">",">="]),mr=e=>e.type==="var"||e.type==="index"||e.type==="field";function W1(e){let t=e.tok;return z1(e)||t.type==="regex"||t.type==="keyword"&&t.value==="getline"||t.type==="punct"&&["!","-","+"].includes(t.value)}function gn(e,t){let n=[$e(e,t)];for(;e.accept(",");)e.skipNewlines(),n.push($e(e,t));return n}function $e(e,t){let n=Jk(e,t),r=e.tok;if(r.type==="punct"&&Kk.has(r.value)){mr(n)||e.fail(`cannot assign to ${n.type==="regex"?"a regex":"a non-variable"} (left side of \`${r.value}\`)`),e.next();let o=$e(e,t);return{type:"assign",op:r.value==="**="?"^=":r.value,target:n,value:o}}return n}function Jk(e,t){let n=ku(e,t);if(!e.accept("?"))return n;e.skipNewlines();let r=$e(e,t);return e.skipNewlines(),e.expect(":"),e.skipNewlines(),{type:"cond",test:n,consequent:r,alternate:$e(e,t)}}var Qk=[["or",["||"]],["and",["&&"]],["in",["in"]],["match",["~","!~"]],["compare",[...j1]],["concat",[]],["binary",["+","-"]],["binary",["*","/","%"]]],ev=new Map(Qk.flatMap(([e,t],n)=>t.map(r=>[r,{type:e,precedence:n}]))),tv={type:"concat",precedence:5};function ku(e,t,n=0){let r=Po(e,t),o=1/0;for(;;){let i=e.tok;n<=4&&o>4&&!t.noGt&&(e.is("|")||e.is("|&"))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${Qr}`,'"cmd" | getline');let s=z1(e)?tv:i.type==="punct"||i.type==="keyword"&&i.value==="in"?ev.get(i.value):void 0;if(!s||s.precedence<n||s.precedence>o||t.noGt&&e.is(">"))return r;let{type:u,precedence:a}=s,l=u==="concat"?null:e.next().value;if(o=a,(u==="or"||u==="and")&&e.skipNewlines(),u==="in"){r={type:u,keys:[r],array:q1(e)};continue}let f=ku(e,t,a+1);(l==="/"||l==="%")&&hr(f)===0&&hr(r)!==null&&e.fail(l==="/"?"division by zero attempted":"division by zero attempted in `%`"),u==="compare"&&nv(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),u==="binary"||u==="compare"?r={type:u,op:l,left:r,right:f}:u==="match"?r={type:u,negate:l==="!~",left:r,right:f}:r={type:u,left:r,right:f}}}function q1(e){return e.tok.type!=="name"&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var nv=(e,t)=>e.tok.type==="punct"&&j1.has(e.tok.value)&&!(t.noGt&&e.tok.value===">");function z1(e){let t=e.tok;return t.type==="number"||t.type==="string"||t.type==="name"||t.type==="funcname"||t.type==="builtin"?!0:t.type==="punct"&&["$","(","++","--"].includes(t.value)}function H1(e,t){return ku(e,t,5)}function hr(e){if(e.type==="num")return e.value;if(e.type==="neg"||e.type==="plus"){let r=hr(e.expr);return r===null?null:e.type==="neg"?-r:r}if(e.type!=="binary")return null;let t=hr(e.left),n=hr(e.right);return t===null||n===null?null:eo(e.op,t,n)}var rv={__proto__:null,"!":"not","-":"neg","+":"plus"};function Po(e,t,n=!1){if(n&&(e.is("$")||e.is("++")||e.is("--")))return Do(e,t);let r=e.tok.type==="punct"&&rv[e.tok.value];return r?(e.next(),{type:r,expr:Po(e,t,n)}):n?X1(e,t):ov(e,t)}function ov(e,t){let n=G1(e,t);return!e.is("^")&&!e.is("**")?n:(e.next(),{type:"binary",op:"^",left:n,right:Po(e,t)})}function G1(e,t){let n=Do(e,t);for(;(e.is("++")||e.is("--"))&&mr(n);)n={type:"postinc",op:e.next().value,target:n};return n}function Do(e,t){if(e.accept("$"))return{type:"field",index:Po(e,t,!0)};if(e.is("++")||e.is("--")){let n=e.next().value,r=Do(e,t);return mr(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:"preinc",op:n,target:r}}return X1(e,t)}function X1(e,t){let n=e.tok;switch(n.type){case"number":return e.next(),{type:"num",value:Number(n.value)};case"string":return e.next(),{type:"str",value:n.value};case"regex":return e.next(),{type:"regex",source:n.value,re:iv(e,n.value)};case"name":return sv(e);case"funcname":return uv(e);case"builtin":return lv(e);case"keyword":return n.value==="getline"?fv(e,t):e.unexpected();case"punct":return n.value==="("?av(e):e.unexpected();default:return e.unexpected()}}function iv(e,t){try{return Re(t,!1,n=>e.warn(n))}catch(n){return e.fail(n.message,n.gap??null)}}function vu(e){if(!e.accept("["))return null;let t=gn(e,{});return e.expect("]"),e.is("[")&&e.fail("arrays of arrays are not supported","arrays of arrays"),t}function sv(e){let t=e.next().value,n=vu(e);return n!==null?{type:"index",name:t,subs:n}:(e.is("(")&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:"var",name:t})}function uv(e){return{type:"call",name:e.next().value,args:Z1(e)}}function Z1(e){e.expect("(");let t=e.is(")")?[]:gn(e,{});return e.expect(")"),t}function av(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=gn(e,{});if(e.expect(")"),n.length===1){for(;t-- >0;)e.expect(")");return n[0]}return e.isKw("in")||e.fail("a parenthesized list must be followed by `in ARRAY`"),e.next(),{type:"in",keys:n,array:q1(e)}}function lv(e){let t=e.next().value;if(Jr.has(t)&&e.fail(Jr.get(t),`${t}()`),!e.is("(")){if(t==="length")return{type:"builtin",name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=Z1(e),[r,o]=Yi[t];return(n.length<r||n.length>o)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?"":"s"}; it takes ${r===o?r:`${r} to ${o===1/0?"any number":o}`}`),(t==="sub"||t==="gsub")&&n[2]&&!mr(n[2])&&e.fail(`${t}(): substitution into a temporary value is not supported`,"substitution into temporary value"),t==="split"&&n[1].type!=="var"&&e.fail("split(): second argument must be an array name"),t==="match"&&n[2]&&n[2].type!=="var"&&e.fail("match(): third argument must be an array name"),{type:"builtin",name:t,args:n}}function fv(e,t){e.next();let n=null;(e.tok.type==="name"||e.is("$"))&&(n=Do(e,t),mr(n)||e.fail("getline: target must be a variable, field or array element"));let r=null;return e.accept("<")&&(r=G1(e,t)),{type:"getline",target:n,file:r}}var cv=new Set(["/dev/stdout","/dev/stderr","/dev/null"]),Su=class{constructor(t,n){this.toks=t,this.i=0,this.warnings=n,this.funcs=new Set,this.parens=new Map;let r=[];for(let o=0;o+1<t.length;o++){let i=t[o],s=t[o+1];i.type==="punct"&&(i.value==="("?r.push(o):i.value===")"&&r.length>0&&this.parens.set(r.pop(),o)),i.type==="keyword"&&i.value==="function"&&(s.type==="name"||s.type==="funcname")&&this.funcs.add(s.value)}this.loopDepth=0,this.switchDepth=0,this.context="main"}get tok(){return this.toks[this.i]}peek(t){return this.toks[Math.min(this.i+t,this.toks.length-1)]}is(t,n="punct"){return this.tok.type===n&&this.tok.value===t}isKw(t){return this.is(t,"keyword")}next(){return this.toks[this.i++]}accept(t,n="punct"){return this.is(t,n)?this.next():null}expect(t,n="punct"){return this.is(t,n)||this.fail(`expected \`${t}\` but found ${Ht(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type==="newline";)this.i++}skipTerminators(){for(;this.tok.type==="newline"||this.is(";");)this.i++}fail(t,n=null){throw new $(t,this.tok.line,n)}warn(t){this.warnings.push(t)}unexpected(){this.fail(`unexpected ${Ht(this.tok)}`)}};function Ht(e){return e.type==="eof"?"end of program":e.type==="newline"?"newline":e.type==="string"?`string "${e.value}"`:e.type==="regex"?`regex /${e.value}/`:`\`${e.value}\``}var Y1={__proto__:null,BEGIN:"begin",END:"end",BEGINFILE:"beginFile",ENDFILE:"endFile"};function J1(e){let t=[],n=new Su(B1(e,o=>t.push(o)),t),r={begin:[],end:[],beginFile:[],endFile:[],rules:[],functions:new Map,warnings:t};for(n.skipNewlines();n.tok.type!=="eof";)n.is(";")&&n.fail("each rule must have a pattern or an action part"),dv(n,r),n.accept(";"),n.skipNewlines();return r}function dv(e,t){if(e.isKw("function")){pv(e,t);return}if(e.tok.type==="keyword"&&e.tok.value in Y1){let i=e.next().value;e.is("{")||e.fail(`${i} requires an action: ${i} { ... }`),t[Y1[i]].push(...gr(e,i.toLowerCase()));return}if(e.is("{")){t.rules.push({pattern:null,action:gr(e,"main")});return}let n=$e(e,{}),r=n;e.accept(",")&&(e.skipNewlines(),r={type:"range",from:n,to:$e(e,{})});let o=e.is("{")?gr(e,"main"):null;o===null&&!(e.tok.type==="newline"||e.tok.type==="eof"||e.is(";"))&&e.unexpected(),t.rules.push({pattern:r,action:o})}function pv(e,t){e.next();let n=e.tok;n.type==="builtin"&&e.fail(`cannot redefine builtin function \`${n.value}\``),n.type!=="name"&&n.type!=="funcname"&&e.fail(`expected a function name but found ${Ht(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect("(");let o=[];for(;!e.is(")");){let i=e.tok;if(i.type!=="name"&&e.fail(`expected a parameter name but found ${Ht(i)}`),(i.value===r||o.includes(i.value))&&e.fail(`duplicate parameter \`${i.value}\` in function \`${r}\``),o.push(e.next().value),!e.accept(","))break;e.skipNewlines()}e.expect(")"),e.skipNewlines(),t.functions.set(r,{params:o,body:gr(e,"function")})}function gr(e,t=e.context){let n=e.context;e.context=t,e.expect("{");let r=[];for(e.skipTerminators();!e.is("}");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),r.push(Eu(e)),e.skipTerminators();return e.next(),e.context=n,r}function wr(e){if(e.is(";")||e.tok.type==="newline"){e.next();return}e.is("}")||e.tok.type==="eof"||e.unexpected()}var hv={__proto__:null,if:mv,while:gv,do:wv,for:yv,switch:bv,break:e=>wn(e,"break"),continue:e=>wn(e,"continue"),next:e=>wn(e,"next"),nextfile:e=>wn(e,"nextfile"),exit:e=>wn(e,"exit"),return:e=>wn(e,"return"),delete:kv,print:e=>K1(e,"print"),printf:e=>K1(e,"printf")};function Eu(e){if(e.is("{"))return{type:"block",body:gr(e)};if(e.is(";"))return e.next(),{type:"empty"};let t=e.tok.type==="keyword"?hv[e.tok.value]:void 0;if(t)return t(e);let n=$e(e,{});return wr(e),{type:"expr",expr:n}}function yn(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=Eu(e);return t&&e.loopDepth--,n}function Bo(e){e.next(),e.expect("(");let t=$e(e,{});return e.expect(")"),t}function mv(e){let t=Bo(e),n=yn(e,!1),r=e.i;return e.skipNewlines(),e.isKw("else")?(e.next(),{type:"if",test:t,consequent:n,alternate:yn(e,!1)}):(e.i=r,{type:"if",test:t,consequent:n,alternate:null})}function gv(e){return{type:"while",test:Bo(e),body:yn(e,!0)}}function wv(e){e.next();let t=yn(e,!0);e.skipTerminators(),e.isKw("while")||e.fail("`do` body must be followed by `while (...)`");let n=Bo(e);return wr(e),{type:"do",body:t,test:n}}function yv(e){if(e.next(),e.expect("("),e.tok.type==="name"&&e.peek(1).type==="keyword"&&e.peek(1).value==="in"&&e.peek(2).type==="name"&&e.peek(3).value===")"){let o=e.next().value;e.next();let i=e.next().value;return e.next(),{type:"forin",name:o,array:i,body:yn(e,!0)}}let t=e.is(";")?null:$e(e,{});e.expect(";"),e.skipNewlines();let n=e.is(";")?null:$e(e,{});e.expect(";"),e.skipNewlines();let r=e.is(")")?null:$e(e,{});return e.expect(")"),{type:"for",init:t,test:n,step:r,body:yn(e,!0)}}function bv(e){let t=Bo(e);e.skipNewlines(),e.expect("{");let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is("}");e.skipTerminators()){let o=null;e.accept("case","keyword")?o=xv(e):e.accept("default","keyword")||e.fail(`expected \`case\` or \`default\` in switch body but found ${Ht(e.tok)}`);let i=o===null?"default":o.type==="regex"?`/${o.source}/`:String(o.value);r.has(i)&&e.fail(`duplicate case values in switch body: ${i}`),r.add(i),e.expect(":");let s=[];for(e.skipTerminators();!e.is("}")&&!e.isKw("case")&&!e.isKw("default");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),s.push(Eu(e)),e.skipTerminators();n.push({test:o,body:s})}return e.switchDepth--,e.next(),{type:"switch",expr:t,cases:n}}function xv(e){let t=e.accept("-")?-1:(e.accept("+"),1),n=e.tok;return n.type==="number"?(e.next(),{type:"num",value:t*Number(n.value)}):t===1&&n.type==="string"?(e.next(),{type:"str",value:n.value}):t===1&&n.type==="regex"?(e.next(),{type:"regex",source:n.value,re:Re(n.value,!1,r=>e.warn(r))}):e.fail(`case value must be a number, string or regex constant, found ${Ht(n)}`)}function wn(e,t){t==="break"&&e.loopDepth===0&&e.switchDepth===0&&e.fail("`break` is not allowed outside a loop or switch"),t==="continue"&&e.loopDepth===0&&e.fail("`continue` is not allowed outside a loop"),t==="next"&&e.context!=="main"&&e.context!=="function"&&e.fail(`\`next\` cannot be used in a ${e.context.toUpperCase()} action`),t==="nextfile"&&(e.context==="begin"||e.context==="end"||e.context==="endfile")&&e.fail(`\`nextfile\` cannot be used in a ${e.context.toUpperCase()} action`),t==="return"&&e.context!=="function"&&e.fail("`return` is only allowed inside a function"),e.next();let n={type:t};return(t==="exit"||t==="return")&&(n.value=W1(e)?$e(e,{}):null),wr(e),n}function kv(e){e.next(),e.tok.type!=="name"&&e.fail(`\`delete\` needs an array name but found ${Ht(e.tok)}`);let t=e.next().value,n=vu(e);return wr(e),{type:"delete",name:t,subs:n}}var V1=e=>e.is(";")||e.is("}")||e.is(">")||e.is(">>")||e.is("|")||e.is("|&")||e.tok.type==="newline"||e.tok.type==="eof";function K1(e,t){e.next();let n=null;if(e.is("(")){let o=e.i;e.next();let i=e.is(")")?[]:gn(e,{});e.accept(")")&&V1(e)?n=i:e.i=o}n===null&&(n=V1(e)?[]:gn(e,{noGt:!0})),t==="printf"&&n.length===0&&e.fail("printf needs a format string");let r=null;return(e.is("|")||e.is("|&"))&&e.fail(`output pipes (\`${t} ... | "cmd"\`) are not supported: ${Qr}`,`${t} | "cmd"`),(e.accept(">")||e.accept(">>"))&&(r=H1(e,{noGt:!0}),r.type==="str"&&!cv.has(r.value)&&e.fail($u(r.value),`${t} > FILE`)),wr(e),{type:t,args:n,dest:r}}function $u(e){return`cannot redirect output to \`${e}\`: the filesystem is read-only (only /dev/stdout, /dev/stderr and /dev/null). To print a comparison, parenthesize it: print (a > b)`}var G=class{constructor(t){this.s=t,this.number=void 0,this.numeric=void 0}},yr="[ \\t\\n\\r\\f\\v]*",th="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",vv=new RegExp(`^${yr}${th}${yr}$`,"u"),Sv=new RegExp(`^${yr}(${th})`,"u"),nh=new RegExp(`^${yr}([+-])(inf|nan)${yr}$`,"iu"),Nu=e=>vv.test(e)||nh.test(e);function Q1(e){let t=Sv.exec(e);if(t)return Number(t[1]);let n=nh.exec(e);return n?n[2].toLowerCase()==="nan"?Number.NaN:n[1]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:0}var Au=()=>new $("attempt to use an array in a scalar context");function z(e){if(typeof e=="number")return e;if(e===void 0)return 0;if(e instanceof G)return e.number??=Q1(e.s);if(typeof e=="string")return Q1(e);throw Au()}var Uo=new Map;function rh(e,t){if(Number.isNaN(e))throw new $("formatting signed NaN is not supported",null,"signed NaN");if(!Number.isFinite(e))return e<0?"-inf":"+inf";if(Number.isInteger(e))return Math.abs(e)<2**53?String(e):BigInt(e).toString();let n=Uo.get(t);if(n===void 0){Uo.size>64&&Uo.clear(),n=go(t);let r=n.filter(o=>typeof o!="string");if(r.length>1||r.some(o=>!"diouxXeEfFgG".includes(o.conv)||o.width==="*"||o.precision==="*"))throw new $("this numeric conversion format is not supported",null,"numeric conversion format");Uo.set(t,n)}return n.map(r=>typeof r=="string"?r:Wt(e,r)).join("")}var oh=e=>typeof e=="string"?e:e instanceof G?e.s:"%.6g",Ev=e=>oh(e.globals.get("CONVFMT")),$v=e=>oh(e.globals.get("OFMT"));function L(e,t){if(typeof e=="string")return pt(t,e);if(e instanceof G)return pt(t,e.s);if(typeof e=="number")return rh(e,Ev(t));if(e===void 0)return"";throw Au()}function pt(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new $("non-ASCII AWK text in a byte locale is not supported",null,"byte locale text");return t}function Gt(e,t=!1){return[...e].map(n=>{let r=t?n.toUpperCase():n.toLowerCase();if([...r].length!==1)throw new $("Unicode case expansion is not supported",null,"Unicode case mapping");return r}).join("")}function ih(e,t){return typeof e=="number"?rh(e,$v(t)):L(e,t)}var Ou=e=>e.numeric??=Nu(e.s),eh=e=>typeof e=="number"||e===void 0||e instanceof G&&Ou(e),qe=e=>Ne(e.globals.get("IGNORECASE"));function jo(e,t,n){if(eh(e)&&eh(t)){let i=z(e),s=z(t);return i<s?-1:i>s?1:i===s?0:Number.NaN}let r=L(e,n),o=L(t,n);return qe(n)&&(r=Gt(r),o=Gt(o)),j(r,o)}function Ne(e){if(typeof e=="number")return e!==0&&!Number.isNaN(e);if(typeof e=="string")return e!=="";if(e instanceof G)return Ou(e)?z(e)!==0:e.s!=="";if(e===void 0)return!1;throw Au()}var Cu=(e,t)=>Number.isSafeInteger(e)?String(e):L(e,t);function Iu(e){return e instanceof Map?"array":e===void 0?"untyped":typeof e=="number"?"number":e instanceof G&&Ou(e)?"strnum":"string"}function sh(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t==="")return Nv(e);let o,i;if(t.length===1){let u=r.indexOf(t,e.pos);i=u===-1?r.length:u,o=u===-1?r.length:u+1}else{let u=es(r,Re(t,n),e.pos);i=u?.start??r.length,o=u?.end??r.length}let s=r.slice(e.pos,i);return e.pos=o,{rec:s,rt:r.slice(i,o)}}function Nv(e){let{text:t}=e,n=e.pos;for(;t[n]===`
|
|
239
|
+
`;)n++;if(n>=t.length)return e.pos=n,null;let r=/\n\n+/gu;r.lastIndex=n;let o=r.exec(t);if(!o){e.pos=t.length;let i=t.slice(n).replace(/\n+$/u,"");return{rec:i,rt:t.slice(n+i.length)}}return e.pos=o.index+o[0].length,{rec:t.slice(n,o.index),rt:o[0]}}function Lu(e,t,n,r){if(e==="")return[];if(t instanceof ct)return ts(e,t);if(t===" "){let i=e.replace(/^[ \t\n]+|[ \t\n]+$/gu,"");return i===""?[]:i.split(/[ \t\n]+/u)}if(t==="")return[...e];if(t.length===1&&(!n||t===`
|
|
240
|
+
`))return e.split(t);if(n&&t==="^")throw new $('paragraph splitting with FS="^" is not supported',null,"paragraph FS caret");let o=t.length===1?`[${"^$.[]|()*+?{}\\".includes(t)?"\\"+t:t}
|
|
241
|
+
]`:t;return ts(e,Re(o,r))}function uh(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let o=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),i=o?.[1]===void 0?0:Number(o[1]),s=o?.[2]==="*"?4294967295:Number(o?.[2]);if(!o||o[1]!==void 0&&i===0||i>4294967295||!(s>0&&s<=4294967295)||o[2]==="*"&&r!==t.length-1)throw new $(`invalid FIELDWIDTHS value \`${e}'`);return{skip:i,width:s}})}function Av(e,t){let n=[...e],r=[],o=0;for(let{skip:i,width:s}of t){if(o>=n.length)break;o+=i,r.push(n.slice(o,o+s).join("")),o+=s}return r}function Ov(e,t){let n=[],r=0;for(;r<e.length;){let o=t.search(e.slice(r));if(n.length>0&&o?.end===0&&(r+=Le(e,r),o=t.search(e.slice(r))),!o)break;n.push(e.slice(r+o.start,r+o.end)),r+=o.end}return n}function ah(e,t){let n=qe(e);return e.fieldMode==="FIELDWIDTHS"?Av(t,e.widths):e.fieldMode==="FPAT"?Ov(t,Re(L(e.globals.get("FPAT"),e),n,e.warn)):Lu(t,L(e.globals.get("FS"),e),L(e.globals.get("RS"),e)==="",n)}var Cv=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,Fu=e=>e!==void 0&&e.type==="exit",Wo=class{constructor(t,n){this.ctx=t,this.stdin=n,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(t){for(;this.exitSignal===void 0;){if(this.src){let n=sh(this.src,L(t.globals.get("RS"),t),qe(t));if(n!==null)return t.globals.set("NR",z(t.globals.get("NR"))+1),t.globals.set("FNR",z(t.globals.get("FNR"))+1),t.globals.set("RT",n.rt),n.rec;this.closeFile(t);continue}if(!this.open(t))return null}return null}open(t){for(;this.idx<Math.trunc(z(t.globals.get("ARGC")));){if(++t.steps>Wn)throw new $("input operand scan exceeded execution limit",null,"execution limit");let n=L(t.globals.get("ARGV").get(String(this.idx++)),t);if(n==="")continue;t.globals.set("ARGIND",this.idx-1);let r=Cv.exec(n);if(r){t.assign(r[1],new G(pr(r[2],t.warn)));continue}this.sawFile=!0;let{text:o,error:i}=this.readOperand(n);if(i==="Is a directory"){this.failFile(t,n,i),this.exitSignal===void 0&&t.warn(`command line argument \`${n}' is a directory: skipped`);continue}if(i){let s=this.failFile(t,n,i);if(s!==void 0&&s.type==="nextfile")continue;if(this.exitSignal!==void 0)return!1;throw new $(`${n}: ${i}`)}if(this.use(t,n,o))return!0}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(t,"-",this.takeStdin()))}readOperand(t){if(t==="/dev/null")return{text:""};if(t==="-"||t==="/dev/stdin")return{text:t==="/dev/stdin"&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:n,error:r}=P(this.ctx,"awk",t);return this.ctx.fs.isDir(n)?{error:"Is a directory"}:r?{error:r}:{text:this.ctx.fs.readFile(n)}}takeStdin(){let t=this.stdin;return this.stdin="",q(this.ctx),t}use(t,n,r){this.src={text:r,pos:0},t.globals.set("FILENAME",n),t.globals.set("FNR",0),t.globals.set("ERRNO","");let o=t.fileRule("begin");return Fu(o)?(this.exitSignal=o,this.src=null,!1):o!==void 0&&o.type==="nextfile"?(this.closeFile(t),!1):(pt(t,r),!0)}failFile(t,n,r){if(t.globals.set("ERRNO",r),!t.hasFileRules)return;t.globals.set("FILENAME",n),t.globals.set("FNR",0);let o=t.fileRule("begin");return Fu(o)&&(this.exitSignal=o),o}closeFile(t){this.src=null;let n=t.fileRule("end");Fu(n)&&(this.exitSignal=n)}readNamed(t,n){let r=this.readers.get(n);if(!r){let{text:i,error:s}=this.readOperand(n);if(s)return t.globals.set("ERRNO",s),{status:-1};r={text:pt(t,i),pos:0},this.readers.set(n,r)}let o=sh(r,L(t.globals.get("RS"),t),qe(t));return o===null?{status:0}:(t.globals.set("RT",o.rt),{status:1,record:o.rec})}close(t,n){return this.readers.delete(n)?0:(t.globals.set("ERRNO","close of redirection that was never opened"),-1)}};var Iv=(e,t)=>({isRef:!0,scope:e,name:t}),br=e=>typeof e=="object"&&e!==null&&e.isRef===!0,xr=class extends Error{constructor(t){super(t.type),this.signal=t}},ch=e=>new $(`attempt to use array \`${e}\` in a scalar context`);function qo(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function Tv(e){let t=e;for(;br(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function bn(e,t){let n=qo(e,t).get(t);return br(n)?Tv(n):n}var Fv=new Set(["FS","FIELDWIDTHS","FPAT"]);function zo(e,t,n){let r=qo(e,t);if(r.get(t)instanceof Map)throw ch(t);if(r===e.globals){if(t==="NF"){_v(e,n);return}if(t==="FIELDWIDTHS"&&(e.widths=uh(L(n,e))),(t==="FPAT"||(t==="FS"||t==="RS")&&L(n,e).length>1)&&Re(L(n,e),qe(e),e.warn,e.tables),Fv.has(t)){e.fieldMode=t;let o=e.globals.get("PROCINFO");o instanceof Map&&o.set("FS",t)}}r.set(t,n)}function ht(e,t){let n=qo(e,t),r=t,o=n,i=o.get(r);if(i instanceof Map)return i;let s=br(i);for(;br(i);)o=i.scope,r=i.name,i=o.get(r);if(!(i instanceof Map)){if(i!==void 0)throw new $(`attempt to use scalar \`${r}\` as an array`);i=new Map,o.set(r,i)}return s&&n.set(t,i),i}function Ho(e,t,n=new G(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...ah(e,t).map(r=>new G(r))],e.nf=e.fields.length-1,e.globals.set("NF",e.nf)}function dh(e){let t=L(e.globals.get("OFS"),e);e.record=e.fields.slice(1).map(n=>L(n,e)).join(t),e.recordValue=e.record}function ph(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function Lv(e,t,n){if(t===0){let r=L(n,e);Ho(e,r,typeof n=="number"?r:n);return}for(;e.nf<t;)e.fields[++e.nf]="";e.fields[t]=n,e.globals.set("NF",e.nf),dh(e)}function _v(e,t){let n=Math.trunc(z(t));if(n<0)throw new $(`NF set to negative value ${n}`);for(;e.nf<n;)e.fields[++e.nf]="";e.fields.length=n+1,e.nf=n,e.globals.set("NF",n),dh(e)}function hh(e,t){let n=z(T(e,t));if(!(n>=0))throw new $(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function kr(e,t){if(t.length===1)return Cu(T(e,t[0]),e);let n=L(e.globals.get("SUBSEP"),e);return t.map(r=>Cu(T(e,r),e)).join(n)}function _u(e,t){return t.type==="var"?t:t.type==="index"?{type:"index",arr:ht(e,t.name),key:kr(e,t.subs)}:{type:"field",i:hh(e,t.index)}}function mh(e,t){return t.type==="var"?gh(bn(e,t.name),t.name):t.type==="index"?t.arr.get(t.key):ph(e,t.i)}function Ru(e,t,n){t.type==="var"?zo(e,t.name,n):t.type==="index"?t.arr.set(t.key,n):Lv(e,t.i,n)}function Mu(e,t,n){Ru(e,_u(e,t),n)}function lh(e,t,n){if(n===0&&(e==="/"||e==="%"))throw new $(e==="/"?"division by zero attempted":"division by zero attempted in `%`");return eo(e,t,n)}var Rv={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function mt(e,t){let n=qe(e);return t.type==="regex"?n?Re(t.source,!0,null,e.tables):t.re:Re(L(T(e,t),e),n,e.warn,e.tables)}function gh(e,t){if(e instanceof Map)throw ch(t);return e}function fh(e,t,n){let r=_u(e,t.target),o=z(mh(e,r)),i=t.op==="++"?o+1:o-1;return Ru(e,r,i),n?o:i}function T(e,t){switch(t.type){case"num":case"str":return t.value;case"regex":return mt(e,t).test(e.record)?1:0;case"var":return gh(bn(e,t.name),t.name);case"index":{let n=ht(e,t.name),r=kr(e,t.subs),o=n.get(r);return o===void 0&&n.set(r,void 0),o}case"field":return ph(e,hh(e,t.index));case"assign":{let n=_u(e,t.target),r=T(e,t.value);if(r instanceof Map)throw new $("attempt to use an array in a scalar context");return t.op!=="="&&(r=lh(t.op[0],z(mh(e,n)),z(r))),Ru(e,n,r),r}case"cond":return T(e,Ne(T(e,t.test))?t.consequent:t.alternate);case"or":return Ne(T(e,t.left))||Ne(T(e,t.right))?1:0;case"and":return Ne(T(e,t.left))&&Ne(T(e,t.right))?1:0;case"not":return Ne(T(e,t.expr))?0:1;case"neg":return-z(T(e,t.expr));case"plus":return z(T(e,t.expr));case"binary":return lh(t.op,z(T(e,t.left)),z(T(e,t.right)));case"concat":return L(T(e,t.left),e)+L(T(e,t.right),e);case"compare":return Rv[t.op](jo(T(e,t.left),T(e,t.right),e))?1:0;case"match":{let n=L(T(e,t.left),e);return mt(e,t.right).test(n)===t.negate?0:1}case"in":return ht(e,t.array).has(kr(e,t.keys))?1:0;case"preinc":return fh(e,t,!1);case"postinc":return fh(e,t,!0);case"call":return Mv(e,t);case"builtin":return e.callBuiltin(e,t);case"getline":return Dv(e,t);default:throw new $(`unknown expression: ${t.type}`)}}function Mv(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new $(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new $(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=Vi)throw new $(`function call nesting deeper than ${Vi} levels (runaway recursion?)`,null,"call depth limit");let r=e.frame,o=new Map;for(let i=0;i<n.params.length;i++)o.set(n.params[i],i<t.args.length?Pv(e,t.args[i]):void 0);e.frame=o,e.callDepth++;try{let i=e.execStmts(e,n.body);if(i===void 0||i.type==="return")return i?.value;throw new xr(i)}finally{e.frame=r,e.callDepth--}}function Pv(e,t){if(t.type!=="var")return T(e,t);let n=qo(e,t.name),r=n.get(t.name);return r instanceof Map||br(r)?r:r===void 0?Iv(n,t.name):r}function Dv(e,t){let n;if(t.file===null){if(n=e.input.next(e),n===null)return 0}else{let r=e.input.readNamed(e,L(T(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?Ho(e,n):Mu(e,t.target,new G(n)),1}var Qe=(e,t)=>z(T(e,t)),Pu=2**32;function yh(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var bh=()=>({seed:1,state:yh(1)});function Bv(e){e.rng.state=(e.rng.state+1831565813)%Pu;let t=e.rng.state;t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61);let n=t^t>>>14;return(n<0?n+Pu:n)/Pu}function Uv(e,t){let n=e.rng.seed,r=t.length>0?Qe(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=yh(r),n}function jv(e,t){let n=Qe(e,t[0]);return n<0&&e.warn(`log: received negative argument ${L(n,e)}`),Math.log(n)}function Wv(e,t){let n=Qe(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${L(n,e)}`),Math.sqrt(n)}function qv(e,t){let n=Qe(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${L(n,e)} is out of range`),r}function zv(e,t){let n=T(e,t[0]);if(typeof n=="number")return n;let r=n instanceof G?n.s:L(n,e),o=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(o)return o[1]===""?0:Number.parseInt(o[1],16);let i=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return i?Number.parseInt(i[0],8):z(new G(r))}function vr(e,t,n,r){let o=Qe(e,n);if(o<0)throw new $(`${t}: argument ${r} negative value ${L(o,e)} is not allowed`);if(!Number.isFinite(o))throw new $(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(o)))}function Bu(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function Du(e,t){return(n,r)=>{if(r.length<2)throw new $(`${e}: called with less than two arguments`);let o=vr(n,e,r[0],1);for(let i=1;i<r.length;i++)o=t(o,vr(n,e,r[i],i+1));return Bu(o)}}function wh(e,t){return(n,r)=>{let o=vr(n,e,r[0],1),i=vr(n,e,r[1],2)%64n;return Bu(BigInt.asUintN(64,t?o<<i:o>>i))}}var xh={__proto__:null,sin:(e,t)=>Math.sin(Qe(e,t[0])),cos:(e,t)=>Math.cos(Qe(e,t[0])),atan2:(e,t)=>Math.atan2(Qe(e,t[0]),Qe(e,t[1])),exp:qv,log:jv,sqrt:Wv,int:(e,t)=>Math.trunc(Qe(e,t[0])),rand:Bv,srand:Uv,systime:()=>Math.floor(Date.now()/1e3),strtonum:zv,and:Du("and",(e,t)=>e&t),or:Du("or",(e,t)=>e|t),xor:Du("xor",(e,t)=>e^t),lshift:wh("lshift",!0),rshift:wh("rshift",!1),compl:(e,t)=>Bu(BigInt.asUintN(64,~vr(e,"compl",t[0],1)))};var Go=new Map;function Hv(e){let t=Go.get(e);return t||(Go.size>=256&&Go.clear(),t=go(e),Go.set(e,t)),t}function Xo(e,t,n){let r=0,o=()=>{if(r>=n.length)throw new $("printf: not enough arguments to satisfy format string");return n[r++]},i="";for(let s of Hv(t)){if(typeof s=="string"){i+=s;continue}let u={...s};if(s.width==="*"){let a=Math.trunc(z(o()));a<0?(u.minus=!0,u.width=-a):u.width=a}if(s.precision==="*"){let a=Math.trunc(z(o()));u.precision=a<0?null:a}if(u.width>Ce||u.precision>Ce)throw new $(`printf: field width or precision above ${Ce} is not supported`,null,"format size limit");i+=Gv(e,u,o())}return i}function Gv(e,t,n){if(t.conv==="s"){let r=L(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join("")),Nt("",r,t,!1)}return t.conv==="c"?Nt("",pt(e,Xv(n)),t,!1):Wt(z(n),t)}function Xv(e){if(typeof e=="number"||e instanceof G&&Nu(e.s)){let r=Math.trunc(z(e));if(!Ze(r))throw new $("printf: character code outside Unicode scalar values is not supported",null,"character code");return String.fromCodePoint(r)}let n=e instanceof G?e.s:e??"";return n===""?"\0":String.fromCodePoint(n.codePointAt(0))}var we=(e,t)=>L(T(e,t),e),kh=(e,t)=>z(T(e,t)),Zv={type:"field",index:{type:"num",value:0}};function Yv(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"){if(e[r+1]==="\\"&&e[r+2]==="\\"&&(e[r+3]==="&"||e[r+3]==="\\")){n+="\\"+e[r+3],r+=3;continue}if(e[r+1]==="\\"&&e[r+2]==="&"){n+="\\"+t,r+=2;continue}if(e[r+1]==="&"){n+="&",r++;continue}}n+=o==="&"?t:o}return n}function vh(e,t,n){let r=mt(e,t[0]),o=we(e,t[1]),i=t[2]??Zv,s=we(e,i),{out:u,count:a}=qn(s,r,(l,f)=>Yv(o,s.slice(l,f)),n?"global":"first");return a>0&&Mu(e,i,u),a}function Vv(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"&&r+1===e.length)throw new $("gensub with a trailing replacement backslash is not supported",null,"gensub trailing backslash");if(o==="\\"&&r+1<e.length){let i=e[++r];i>="0"&&i<="9"?n+=t[Number(i)]?.text??"":n+=i;continue}n+=o==="&"?t[0].text:o}return n}function Kv(e,t){let n=mt(e,t[0]),r=we(e,t[1]),o=T(e,t[2]),i=L(o,e),s=i.startsWith("g")||i.startsWith("G"),u=0;s||(u=Math.trunc(z(o)),u<1&&(e.warn(`gensub: third argument \`${i}' treated as 1`),u=1));let a=t[3]?we(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return qn(a,n,(f,c,d)=>!s&&d!==u?null:Vv(r,l?n.groups(a,f,c):[{text:a.slice(f,c)}]),s?"global":"nth").out}function Jv(e,t){let n=we(e,t[0]),r=mt(e,t[1]),o=r.search(n,0),i=o?Array.from(n.slice(0,o.start)).length+1:0;if(e.globals.set("RSTART",i),e.globals.set("RLENGTH",o?Array.from(n.slice(o.start,o.end)).length:-1),t[2]){let s=ht(e,t[2].name);if(s.clear(),o){let u=L(e.globals.get("SUBSEP"),e);r.groups(n,o.start,o.end).forEach((a,l)=>{a!==void 0&&(s.set(String(l),new G(a.text)),s.set(`${l}${u}start`,Array.from(n.slice(0,a.start)).length+1),s.set(`${l}${u}length`,[...a.text].length))})}}return i}function Qv(e,t){let n=we(e,t[0]),r=ht(e,t[1].name),o;t[2]===void 0?o=L(e.globals.get("FS"),e):t[2].type==="regex"?o=mt(e,t[2]):o=we(e,t[2]);let i=Lu(n,o,!1,qe(e));return r.clear(),i.forEach((s,u)=>r.set(String(u+1),new G(s))),i.length}function eS(e,t){let n=[...we(e,t[0])],r=Math.trunc(kh(e,t[1])),o=Number.isNaN(r)?1:Math.max(r,1),i=n.length+1;if(t[2]){let s=Math.trunc(kh(e,t[2]));if(!(s>=1))return"";i=Math.min(i,o+s)}return i>o?n.slice(o-1,i-1).join(""):""}function tS(e,t){if(t.length===0)return[...e.record].length;if(t[0].type==="var"){let n=bn(e,t[0].name);return n instanceof Map?n.size:[...L(n,e)].length}return[...we(e,t[0])].length}function nS(e,t){let n=we(e,t[0]),r=we(e,t[1]);qe(e)&&(n=Gt(n),r=Gt(r));let o=n.indexOf(r);return o<0?0:Array.from(n.slice(0,o)).length+1}function rS(e,t){let n=we(e,t[0]);return n==="/dev/stdout"||n==="/dev/stderr"||n==="/dev/null"?0:e.input.close(e,n)}var oS=(e,t)=>t[0].type==="var"?Iu(bn(e,t[0].name)):Iu(T(e,t[0])),iS={__proto__:null,...xh,length:tS,substr:eS,index:nS,split:Qv,sub:(e,t)=>vh(e,t,!1),gsub:(e,t)=>vh(e,t,!0),gensub:Kv,match:Jv,sprintf:(e,t)=>Xo(e,we(e,t[0]),t.slice(1).map(n=>T(e,n))),tolower:(e,t)=>Gt(we(e,t[0])),toupper:(e,t)=>Gt(we(e,t[0]),!0),close:rS,fflush:()=>0,typeof:oS,isarray:(e,t)=>t[0].type==="var"&&bn(e,t[0].name)instanceof Map?1:0};function Sh(e,t){let n=iS[t.name];if(!n)throw new $(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var Yo={type:"break"},ju={type:"continue"},sS={type:"next"},uS={type:"nextfile"},aS={type:"exit"};function Eh(e,t,n,r){let o=new Map([["0","awk"]]);r.forEach((u,a)=>o.set(String(a+1),new G(u)));let i=new Map([["FS"," "],["OFS"," "],["ORS",`
|
|
235
242
|
`],["RS",`
|
|
236
|
-
`],["RT",""],["NR",0],["NF",0],["FNR",0],["FILENAME",""],["SUBSEP",""],["CONVFMT","%.6g"],["OFMT","%.6g"],["RSTART",0],["RLENGTH",-1],["ERRNO",""],["IGNORECASE",0],["FIELDWIDTHS",""],["FPAT","[^[:space:]]+"],["ENVIRON",new
|
|
237
|
-
`),fileRule:u=>
|
|
238
|
-
`),a=2,c instanceof RangeError&&(l={detail:"runtime limit",message:`awk: ${c.message}`}),c.gap&&(l={detail:c.gap,message:`awk: ${c.message}`}),d&&(l={detail:d.detail,message:`awk: ${c.message}`})}let f={stdout:u.out.join(""),stderr:u.errOut.join(""),exitCode:a};return l===null?f:
|
|
239
|
-
`),operands:t}}function
|
|
240
|
-
`,d=f.inputs.flatMap(({content:g})=>
|
|
241
|
-
`,exitCode:124};if(
|
|
242
|
-
`)throw
|
|
243
|
-
`?(r&&t.push(
|
|
244
|
-
`));for(let
|
|
245
|
-
`,
|
|
246
|
-
`,r);r=
|
|
247
|
-
`:""}==> ${
|
|
248
|
-
${
|
|
243
|
+
`],["RT",""],["NR",0],["NF",0],["FNR",0],["FILENAME",""],["SUBSEP",""],["CONVFMT","%.6g"],["OFMT","%.6g"],["RSTART",0],["RLENGTH",-1],["ERRNO",""],["IGNORECASE",0],["FIELDWIDTHS",""],["FPAT","[^[:space:]]+"],["ENVIRON",new Zo("ENVIRON")],["PROCINFO",new Zo("PROCINFO",[["FS","FS"]])],["ARGC",r.length+1],["ARGV",o],["ARGIND",0]]),s={program:e,globals:i,frame:void 0,callDepth:0,record:"",recordValue:new G(""),fields:[void 0],nf:0,fieldMode:"FS",out:[],errOut:[],steps:0,exitCode:0,ranges:[],rng:bh(),input:new Wo(t,n),byteLocale:le(t),tables:re(t.locale),hasFileRules:e.beginFile.length>0,callBuiltin:Sh,execStmts:Vo,assign:(u,a)=>zo(s,u,a),warn:u=>s.errOut.push(`awk: warning: ${u}
|
|
244
|
+
`),fileRule:u=>lS(s,u)};return s}var Zo=class extends Map{constructor(t,n=[]){super(n),this.systemName=t}check(t){if(!this.systemName||this.systemName==="PROCINFO"&&t==="FS")return;let n=this.systemName==="ENVIRON"?"ENVIRON":`PROCINFO[${t??"*"}]`;throw new $(`${n} is not supported without the corresponding environment or process metadata`,null,n)}get(t){return this.check(t),super.get(t)}has(t){return this.check(t),super.has(t)}set(t,n){return this.check(t),super.set(t,n)}delete(t){return this.check(t),super.delete(t)}clear(){return this.check(),super.clear()}get size(){return this.check(),super.size}keys(){return this.check(),super.keys()}values(){return this.check(),super.values()}entries(){return this.check(),super.entries()}[Symbol.iterator](){return this.check(),super[Symbol.iterator]()}};function $h(e){let{program:t}=e,n=Uu(e,t.begin,"BEGIN"),r=t.rules.length>0||t.end.length>0||t.beginFile.length>0||t.endFile.length>0;return!Nh(n)&&r&&fS(e),Uu(e,t.end,"END"),e.exitCode}var Nh=e=>e!==void 0&&e.type==="exit";function Uu(e,t,n){let r=Ah(e,t);if(r!==void 0&&(r.type==="next"||r.type==="nextfile"&&(n==="BEGIN"||n==="END")))throw new $(`\`${r.type}' cannot be called from a ${n} rule`);return r}function lS(e,t){let n=t==="begin"?e.program.beginFile:e.program.endFile;return n.length===0?void 0:Uu(e,n,t==="begin"?"BEGINFILE":"ENDFILE")}function fS(e){for(;;){let t=e.input.next(e);if(t===null)return e.input.exitSignal;Ho(e,t);let n=cS(e);if(Nh(n))return n;n!==void 0&&n.type==="nextfile"&&e.input.closeFile(e)}}function cS(e){let{rules:t}=e.program;for(let n=0;n<t.length;n++){let r=t[n];if(!dS(e,r,n))continue;if(r.action===null){Wu(e,null,e.record+L(e.globals.get("ORS"),e));continue}let o=Ah(e,r.action);if(o!==void 0)return o}}function Ah(e,t){try{return Vo(e,t)}catch(n){if(!(n instanceof xr))throw n;return n.signal}}function dS(e,t,n){let{pattern:r}=t;if(r===null)return!0;if(r.type!=="range")return Ne(T(e,r));if(!e.ranges[n]){if(!Ne(T(e,r.from)))return!1;e.ranges[n]=!0}return Ne(T(e,r.to))&&(e.ranges[n]=!1),!0}function Vo(e,t){for(let n of t){let r=Sr(e,n);if(r!==void 0)return r}}function Sr(e,t){if(++e.steps>Wn)throw new $(`execution stopped after ${Wn} statements (infinite loop?)`,null,"execution limit");switch(t.type){case"block":return Vo(e,t.body);case"empty":return;case"expr":T(e,t.expr);return;case"print":return gS(e,t);case"printf":return wS(e,t);case"if":return Ne(T(e,t.test))?Sr(e,t.consequent):t.alternate===null?void 0:Sr(e,t.alternate);case"while":case"do":case"for":return pS(e,t);case"forin":return hS(e,t);case"switch":return mS(e,t);case"break":return Yo;case"continue":return ju;case"next":return sS;case"nextfile":return uS;case"exit":return yS(e,t);case"return":return{type:"return",value:t.value===null?void 0:T(e,t.value)};case"delete":{let n=ht(e,t.name);t.subs===null?n.clear():n.delete(kr(e,t.subs));return}default:throw new $(`unknown statement: ${t.type}`)}}function pS(e,t){t.init&&T(e,t.init);let n=!0;for(;t.type==="do"&&n||t.test===null||Ne(T(e,t.test));){n=!1;let r=Sr(e,t.body);if(r===Yo)return;if(r!==void 0&&r!==ju)return r;t.step&&T(e,t.step)}}function hS(e,t){let n=ht(e,t.array);for(let r of Array.from(n.keys())){zo(e,t.name,new G(r));let o=Sr(e,t.body);if(o===Yo)return;if(o!==void 0&&o!==ju)return o}}function mS(e,t){let n=T(e,t.expr),r=i=>i.test.type==="regex"?mt(e,i.test).test(L(n,e)):jo(n,i.test.value,e)===0,o=t.cases.findIndex(i=>i.test!==null&&r(i));if(o===-1&&(o=t.cases.findIndex(i=>i.test===null)),o!==-1)for(let i=o;i<t.cases.length;i++){let s=Vo(e,t.cases[i].body);if(s===Yo)return;if(s!==void 0)return s}}function Wu(e,t,n){if(t===null){e.out.push(n);return}let r=L(T(e,t),e);if(r==="/dev/stdout")e.out.push(n);else if(r==="/dev/stderr")e.errOut.push(n);else if(r!=="/dev/null")throw new $($u(r),null,"output redirection")}function gS(e,t){let n=L(e.globals.get("ORS"),e),r;if(t.args.length===0)r=e.record;else{let o=L(e.globals.get("OFS"),e);r=t.args.map(i=>ih(T(e,i),e)).join(o)}Wu(e,t.dest,r+n)}function wS(e,t){let n=t.args.map(r=>T(e,r));Wu(e,t.dest,Xo(e,L(n[0],e),n.slice(1)))}function yS(e,t){if(t.value!==null){let n=Math.trunc(z(T(e,t.value)));e.exitCode=(n%256+256)%256}return aS}var bS="awk [-F fs] [-v var=value] 'program' [file ...] | awk [-F fs] [-v var=value] -f progfile [file ...]",xS=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u;function Oh(e,t,n){let{values:r,positional:o}=N(vS(t),{valueShort:["F"],repeatable:["v","f"],stopAtFirstPositional:!0}),i=SS(r.get("f")??[],o,n);if(i.error)return i.error;let s;try{pt({byteLocale:le(n)},i.text),s=J1(i.text)}catch(c){if(c instanceof RangeError)return v("feature","awk","parser depth limit",`awk: program too deeply nested (${c.message})`);if(O(c))return K(c,"awk",`awk: ${c.message}`);if(!(c instanceof $))throw c;let d=c.line===null?`awk: ${c.message}`:`awk: syntax error at line ${c.line}: ${c.message}`;return c.gap===null?x(d):v("feature","awk",c.gap,d)}let u=Eh(s,n,e,i.operands);for(let c of s.warnings)u.warn(c);let a,l=null;try{r.has("F")&&u.assign("FS",pr(r.get("F"),u.warn));for(let c of r.get("v")??[]){let d=xS.exec(c);if(!d)return x(`awk: -v: expected var=value but got \`${c}\``);u.assign(d[1],new G(pr(d[2],u.warn)))}a=$h(u)}catch(c){let d=O(c);if(!(c instanceof $)&&!(c instanceof RangeError)&&!d)throw c;u.errOut.push(`awk: ${c.message}
|
|
245
|
+
`),a=2,c instanceof RangeError&&(l={detail:"runtime limit",message:`awk: ${c.message}`}),c.gap&&(l={detail:c.gap,message:`awk: ${c.message}`}),d&&(l={detail:d.detail,message:`awk: ${c.message}`})}let f={stdout:u.out.join(""),stderr:u.errOut.join(""),exitCode:a};return l===null?f:ie(f,"feature","awk",l.detail,l.message)}var kS=/^-[Fvf]\S*\s/su;function vS(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="-F"||r==="-v"||r==="-f"){t.push(r),n+1<e.length&&t.push(e[++n]);continue}if(kS.test(r)){t.push(r.slice(0,2),r.slice(2));continue}if(!r.startsWith("-")||r==="-"||r==="--"){t.push(...e.slice(n));break}t.push(r)}return t}function SS(e,t,n){if(e.length===0)return t.length===0?{error:pe(bS,2)}:{text:t[0],operands:t.slice(1)};let r=[];for(let o of e){let{path:i,error:s}=P(n,"awk",o);if(s||!n.fs.isFile(i))return{error:x(`awk: cannot open program file \`${o}\`: ${s??"Is a directory"}`,2)};r.push(n.fs.readFile(i))}return{text:r.join(`
|
|
246
|
+
`),operands:t}}function Ih(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["n","r","u","f","b","z"],valueShort:["t","o"],valueLong:["output"],repeatable:["k","o","output"]}),s=[...o.get("o")??[],...o.get("output")??[]];if(s.length>1)return x("sort: multiple output files specified",2);let u=o.get("t");if(u!==void 0&&A(u).length!==1)return x(`sort: multi-character tab '${u}'`,2);let a={n:r.has("n"),f:r.has("f"),b:r.has("b"),r:r.has("r")},l=IS(o.get("k")??[],a);if(l.error)return l.error;let f=te("sort",i,e,n,{stopOnError:!0});if(f.failed)return{stdout:"",stderr:f.stderr,exitCode:2};let c=r.has("z")?"\0":`
|
|
247
|
+
`,d=f.inputs.flatMap(({content:g})=>he(g,c)),p=l.specs.length?l.specs:[{start:1,...a}],h=_S(d,p,u,r.has("u"),a.r),m=ge(h,c);return s.length===0?ne(m,f):ES(s[0],m,n,f)}function ES(e,t,n,r){if(e==="/dev/null")return ne("",r);if(e==="/dev/stdout")return ne(t,r);n.io?.setReads([]);let o;try{o=n.writable&&n.fs.openWritable(n.cwd,e),o&&o.write(t)}catch(i){return R(n,"sort",i?.path,i?.fsError),K(i,"sort",`sort: open failed: ${i.message}`,2)}return o?ne("",r):v("feature","sort","-o",`sort: open failed: ${e}: Read-only file system`,2)}var $S="nrfb",NS="bdfghiMnRrV",AS=/^[ \t]*\+?(\d+)/u,OS=(e,t)=>x(`sort: ${e}: invalid count at start of '${t}'`,2),Ko=(e,t)=>x(`sort: ${e}: invalid field specification '${t}'`,2);function CS(e){let t=0,n=null,r=u=>{let a=AS.exec(e.slice(t));return a===null?(n=OS(u,e.slice(t)),null):(t+=a[0].length,Number(a[1]))},o=u=>{let a=r(u);if(a===null)return null;let l=null;if(e[t]==="."&&(t++,l=r("invalid number after '.'"),l===null))return null;let f=t;for(;t<e.length&&/[a-zA-Z]/u.test(e[t]);)t++;return{field:a,offset:l,mods:e.slice(f,t)}},i=o("invalid number at field start");if(i===null)return{error:n};let s=null;return e[t]===","&&(t++,s=o("invalid number after ','"),s===null)?{error:n}:i.field===0||s?.field===0?{error:Ko("field number is zero",e)}:i.offset===0?{error:Ko("character offset is zero",e)}:t!==e.length?{error:Ko("stray character in field spec",e)}:{from:i,to:s}}function IS(e,t){let n=[];for(let r of e){let o=CS(r);if(o.error)return{error:o.error};let{from:i,to:s}=o,u=i.mods+(s?.mods??"");for(let l of u)if(!$S.includes(l))return NS.includes(l)?{error:v("option","sort",`-k${r}`,`sort: unknown key option \`${l}\` in ${r}`,2)}:{error:Ko("stray character in field spec",r)};if(i.offset!==null||(s?.offset??0)!==0)return{error:v("option","sort",`-k${r}`,`sort: invalid key specification: ${r} (character offsets are not supported)`,2)};let a=u.length>0;n.push({start:i.field,end:s?.field,n:a?u.includes("n"):t.n,r:a?u.includes("r"):t.r,f:a?u.includes("f"):t.f,b:a?i.mods.includes("b"):t.b})}return{specs:n}}function TS(e,t){let n=[];if(t!==void 0){let o=0;for(;;){let i=e.indexOf(t,o);if(i===-1){n.push([o,e.length]);break}n.push([o,i]),o=i+t.length}return n}let r=0;do{let o=r;for(;r<e.length&&/[ \t]/u.test(e[r]);)r++;for(;r<e.length&&!/[ \t]/u.test(e[r]);)r++;n.push([o,r])}while(r<e.length);return n}function FS(e,t,n){if(t.start>n.length)return"";let r=n[t.start-1][0],o=t.end===void 0||t.end>n.length?e.length:n[t.end-1][1];if(t.b)for(;r<o&&/[ \t]/u.test(e[r]);)r++;return e.slice(r,Math.max(r,o))}var LS=e=>e.replace(/[a-z]/gu,t=>t.toUpperCase());function _S(e,t,n,r,o){let i=t.every(l=>l.start===1&&l.end===void 0);if(i&&t.length===1&&!t[0].n&&!t[0].f&&!t[0].b)return e.sort(e.some(l=>/[\u{10000}-\u{10FFFF}]/u.test(l))?j:void 0),t[0].r&&e.reverse(),r?e.filter((l,f)=>f===0||l!==e[f-1]):e;let s=e.map(l=>{let f=i?[[0,l.length]]:TS(l,n);return{line:l,keys:t.map(c=>{let d=FS(l,c,f);return c.n?RS(d):c.f?LS(d):d})}}),u=(l,f)=>{for(let c=0;c<t.length;c++){let d=t[c],p=d.n?MS(l.keys[c],f.keys[c]):j(l.keys[c],f.keys[c]);if(p!==0)return d.r?-p:p}return r?0:(o?-1:1)*j(l.line,f.line)};s.sort(u);let a=[];for(let l=0;l<s.length;l++)r&&l>0&&u(s[l-1],s[l])===0||a.push(s[l].line);return a}function RS(e){let t=/^[ \t]*(-?)(?:(\d+)(?:\.(\d*))?|\.(\d+))/u.exec(e),n=(t?.[2]??"").replace(/^0+/u,"")||"0",r=(t?.[3]??t?.[4]??"").replace(/0+$/u,"");return{integer:n,fraction:r,negative:t?.[1]==="-"&&(n!=="0"||r!=="")}}var Ch=(e,t)=>e<t?-1:e>t?1:0;function MS(e,t){if(e.negative!==t.negative)return e.negative?-1:1;let n=e.integer.length-t.integer.length||Ch(e.integer,t.integer)||Ch(e.fraction,t.fraction);return e.negative?-n:n}async function Fh(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["r","0"],valueShort:["n","I"],stopAtFirstPositional:!0}),[s="echo",...u]=i,a=o.get("I"),l=o.has("n")?be(o.get("n"),"xargs: -n"):{value:void 0};if(l.error)return l.error;if(l.value===0)return x("xargs: -n: must be at least 1");if(a==="")return x("xargs: -I: replacement string must not be empty");if(a!==void 0&&l.value!==void 0)return v("option","xargs","-I -n","xargs: combining replacement and chunk limits is not supported");if(q(n),!r.has("0")&&e.includes("\0"))return v("feature","xargs","NUL input","xargs: NUL input requires -0");let f;if(r.has("0"))f=he(e,"\0");else if(a===void 0)f=PS(e);else{if(/["'\\]/u.test(e))return v("feature","xargs","-I input quoting","xargs: quoted or escaped replacement lines are not supported");f=he(e).map(m=>m.replace(/^[ \t\r\f\v]+/u,"")).filter(Boolean)}if(f.length===0&&(r.has("r")||a!==void 0))return F();let c=a===void 0?l.value??Math.max(1,f.length):1,d=0,p="",h="";for(let m=0;m<Math.max(1,f.length);m+=c){let g=f[m],w=a===void 0?[...u,...f.slice(m,m+c)]:u.map(k=>k.replaceAll(a,g)),y=await n.dispatch(s,w,"");if(h+=y.stdout,p+=y.stderr,y.exitCode===255)return{stdout:h,stderr:p+"xargs: "+s+`: exited with status 255; aborting
|
|
248
|
+
`,exitCode:124};if(y.exitCode===127&&!n.hasCommand(n.registry.resolveCommand(s)))return{stdout:h,stderr:p,exitCode:127};y.exitCode!==0&&(d=123)}return{stdout:h,stderr:p,exitCode:d}}var Th=e=>new Error(`unmatched ${e==="'"?"single":"double"} quote; by default quotes are special to xargs unless you use the -0 option`);function PS(e){let t=[],n=null,r=!1,o="";for(let i=0;i<e.length;i++){let s=e[i];if(!(!r&&/[ \t\n\r\f\v]/u.test(s)))if(n)if(s===n)n=null;else{if(s===`
|
|
249
|
+
`)throw Th(n);o+=s}else if(s==='"'||s==="'")n=s,r=!0;else if(s==="\\"){if(i+1>=e.length)break;o+=e[++i],r=!0}else s===" "||s===" "||s===`
|
|
250
|
+
`?(r&&t.push(o),o="",r=!1):(o+=s,r=!0)}if(n)throw Th(n);return r&&t.push(o),t}function Lh(e,t,n,r){let{values:o,positional:i,order:s}=N(BS(n),{short:["q","v"],valueShort:["c","n"]}),u=s.findLast(w=>w.name==="n"||w.name==="c")?.name??"n",a=Ja(o.get(u)??"10",e+": -"+u);if(a.error)return a.error;let l=s.findLast(w=>w.name==="q"||w.name==="v"),f=l?l.name==="v":null,c=e==="head",d=a.sign==="+";if(c&&a.value===0&&a.sign!=="-")return _h(e,t,i,r,()=>"",{unit:u,banner:f,leftover:w=>w,readOptions:{noRead:!0}});if(!c&&a.value===0&&!d){if(!r.stdinFile&&(!i.length||i.includes("-")||i.includes("/dev/stdin"))){let w=Dh(e,t,"",u,"standard input");w&&r.notes.add(w)}return F()}let p=w=>c?[0,a.sign==="-"?Math.max(0,w-a.value):a.value]:[d?Math.min(w,Math.max(0,a.value-1)):Math.max(0,w-a.value),w],h=w=>{if(u==="c")return Ph(w,p);let y=c?a.sign==="-":!d,k=c||y?a.value:Math.max(0,a.value-1),S=Mh(w,k,y);return c?w.slice(0,S):w.slice(S)},m=c?DS(a,u,r):void 0;return _h(e,t,i,r,h,{unit:u,banner:f,leftover:m,readOptions:!c&&d?{stopOnDir:!0}:void 0})}function DS(e,t,n){return e.sign==="-"||t==="n"&&!n.stdinFile?()=>"":t==="c"?r=>Ph(r,o=>[Math.min(e.value,o),o]):r=>r.slice(Mh(r,e.value))}function Mh(e,t,n=!1){if(n){if(t===0)return e.length;let o=e.length-Number(e.endsWith(`
|
|
251
|
+
`));for(let i=0;i<t;i++)if(o<=0||(o=e.lastIndexOf(`
|
|
252
|
+
`,o-1),o<0))return 0;return o+1}let r=0;for(let o=0;o<t&&r<e.length;o++){let i=e.indexOf(`
|
|
253
|
+
`,r);r=i===-1?e.length:i+1}return r}function BS(e){return/^-\d+$/u.test(e[0]??"")?["-n",e[0].slice(1),...e.slice(1)]:e}function Ph(e,t){let n=A(e),[r,o]=t(n.length);return r===0&&o>=n.length?e:W(n.subarray(r,o))}function _h(e,t,n,r,o,{unit:i,banner:s,leftover:u=()=>"",readOptions:a}){let l=te(e,n,t,r,a),f=s??n.length>1,c=l.entries.filter(m=>m.kind!=="missing"),d=[],p=[],h=null;for(let m=0;m<c.length;m++){let{name:g,kind:w,shared:y}=c[m],{content:k}=c[m];(y||g===null)&&(h!==null&&(k=h),h=u(k),q(r,h));let S=w==="dir"?"":o(k);if(w==="file"&&S!==k){let M=Dh(e,k,S,i,Dr(g,r));M&&p.push(M)}let I=g===null||g==="-"?"standard input":g;d.push(f?`${m>0?`
|
|
254
|
+
`:""}==> ${I} <==
|
|
255
|
+
${S}`:S)}for(let m of p)r.notes.add(m);return ne(d.join(""),l)}function US(e){let t=+(e.length>0&&!e.endsWith(`
|
|
249
256
|
`));for(let n=e.indexOf(`
|
|
250
257
|
`);n!==-1;n=e.indexOf(`
|
|
251
|
-
`,n+1))t++;return t}function
|
|
252
|
-
`:10;for(let r=e.indexOf(n);r>=0;r=e.indexOf(n,r+1))t++;return t}function
|
|
253
|
-
`&&(
|
|
254
|
-
`,u);if(c===-1)return null;u=c-1;continue}if(a===" "||a===" "){
|
|
255
|
-
`||a==="("||a===")"&&
|
|
258
|
+
`,n+1))t++;return t}function Dh(e,t,n,r,o){let i=r==="c"?l=>A(l).length:US,s=i(n),u=i(t);if(s>=u)return null;let a=(r==="c"?"byte":"line")+(u===1?"":"s");return`${e}: selected ${s} of ${u} ${a} from ${o}.`}function jS(e,t,n){let{flags:r,positional:o}=N(t,{short:["l","w","c","m"]}),i=qS(r),s=te("wc",o,e,n,{read:"as-held"}),u=o.length>1||Object.values(i).filter(Boolean).length>1,a=[],l={l:0,w:0,m:0,c:0};for(let{name:c,content:d,bytes:p,kind:h,shared:m}of s.entries.filter(g=>g.kind!=="missing")){let g=zS(p??d,n,i,u);a.push({counts:g,name:c,kind:h,shared:m}),l.l+=g.l,l.w+=g.w,l.m+=g.m,l.c+=g.c}let f=u?WS(a,n.stdinFile):1;return o.length>1&&a.push({counts:l,name:"total"}),ne(ge(a.map(c=>R1(c.counts,c.name,i,f,n))),s)}function WS(e,t){let n=0,r=1;for(let{name:o,kind:i,shared:s,counts:u}of e)i==="dir"||(o===null||s)&&!t?r=7:n+=u.c;return Math.max(r,String(n).length)}function qS(e){return e.size===0?{l:!0,w:!0,m:!1,c:!0}:{l:e.has("l"),w:e.has("w"),m:e.has("m"),c:e.has("c")}}function zS(e,t,n,r){let o=le(t),i=n.c||r||n.m&&o?HS(e):0;return{l:n.l?GS(e):0,w:n.w?JS(e,t):0,m:n.m?o?i:XS(e):0,c:i}}var HS=e=>typeof e=="string"?A(e).length:e.length;function GS(e){let t=0,n=typeof e=="string"?`
|
|
259
|
+
`:10;for(let r=e.indexOf(n);r>=0;r=e.indexOf(n,r+1))t++;return t}function XS(e){if(typeof e=="string")return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of Nr(e))n>=0&&t++;return t}var ZS=new Set([9,10,11,12,13,32]),YS=new Set([160,8199,8239,8288]),qu=1,zu=0,Hu=2,VS=Uint8Array.from({length:128},(e,t)=>ZS.has(t)?qu:t>32&&t<127?Hu:zu),KS=(e,t)=>t.has("print",e)?t.has("space",e)||YS.has(e)?qu:Hu:zu;function JS(e,t){let n=re(t.locale),r=0,o=!1;for(let i of QS(e,t)){let s=i<0?zu:i<128?VS[i]:KS(i,n);s===qu?(o&&r++,o=!1):s===Hu&&(o=!0)}return o?r+1:r}function*QS(e,t){if(typeof e!="string"){yield*le(t)?e:Nr(e);return}if(le(t)){yield*A(e);return}for(let n=0;n<e.length;){let r=e.codePointAt(n);yield r>=55296&&r<=57343?65533:r,n+=r>65535?2:1}}function eE(e,t){let n=0;for(let r=0;r<t&&n<e.length;r++){for(;n<e.length&&/[ \t]/u.test(e[n]);)n++;for(;n<e.length&&!/[ \t]/u.test(e[n]);)n++}return e.slice(n)}function tE(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["c","d","u","i","D"],valueShort:["f","s","w"]});if(i.length>2)return x(`uniq: extra operand: ${i[2]}`);if(i.length===2&&i[1]!=="-")return v("feature","uniq","output file","uniq: output files are not supported (filesystem is read-only)");let s=be(o.get("f")??"0","uniq: -f");if(s.error)return s.error;let u=be(o.get("s")??"0","uniq: -s");if(u.error)return u.error;let a=o.has("w")?be(o.get("w"),"uniq: -w"):{value:void 0};if(a.error)return a.error;let l=r.has("D"),f=r.has("c");if(l&&f)return x("uniq: printing all duplicated lines and repeat counts is meaningless");let c=Ka("uniq",i.slice(0,1),e,n),d=r.has("d"),p=r.has("u"),h=r.has("i"),m=S=>{let I=s.value>0?eE(S,s.value):S;if(u.value===0&&a.value===void 0){let C=I.toWellFormed();return h?C.replace(/[A-Z]/gu,H=>H.toLowerCase()):C}let M=A(I).subarray(u.value,a.value===void 0?void 0:u.value+a.value);return(h?M.map(C=>C>=65&&C<=90?C+32:C):M).join(",")},g=he(c.content),w=[],y=0,k=g.length?m(g[0]):null;for(let S=1;S<=g.length;S++){let I=S===g.length?null:m(g[S]);if(S<g.length&&I===k)continue;let M=S-y,C=M>=2;(l?C:!(d&&p)&&(d?C:!p||!C))&&(l?w.push(...g.slice(y+(p?1:0),S)):w.push(f?String(M).padStart(7)+" "+g[y]:g[y])),y=S,k=I}return ne(ge(w),c)}function Rh(){return F()}function nE(){return{stdout:"",stderr:"",exitCode:1}}var Gu={grep:so,head:(e,t,n)=>Lh("head",e,t,n),tail:(e,t,n)=>Lh("tail",e,t,n),wc:jS,sort:Ih,uniq:tE,echo:T1,printf:_1,xargs:Fh,awk:Oh},Bh={true:Rh,false:nE,":":Rh};var qh={test:E1,cat:r1,...Gu,...Qp,...Xc},Uh=(e,t)=>(n,r,o)=>{let i=Gu.grep(n,[t,...r],o),s=O(i);return s?ie(i,s.kind,e,s.detail,s.message):i},Xu={__proto__:null,sed:k1,egrep:Uh("egrep","-E"),fgrep:Uh("fgrep","-F"),"[":$1,...Zc,...Bh,...yu,...qh},zh=new Set(["cd",":",...Object.keys(yu)]),rE=e=>!!Xu[e],oE=new Set(["basename","cp","dirname","ln","mkdir","patch","rm","touch"]),Hh=Object.fromEntries(Object.entries(qh).filter(([e])=>!oE.has(e))),iE=["ls","cd","cat","grep","rg","find","head","tail","wc","tree","du","stat","realpath","sort","uniq","cut","tr","awk","nl","tac","hexdump","base64","xargs","echo","printf","test","diff","pwd","seq","which"],jh=Object.keys(Xu).filter(e=>!zh.has(e)&&!Object.hasOwn(Hh,e)).sort(),sE=new Set(["base32","brotli","egrep","fgrep","gunzip","gzcat","gzip","od","sed","sha1sum","sha256sum","sha384sum","sha512sum","shasum","xxd","zcat"]),Wh=aE(),uE=["grep","head","tail","wc","sort","uniq","cut","xargs","awk","tr","nl","tac","hexdump","cat","base64","diff","patch"];function aE(){let e=new Set(Object.keys(Hh)),t=[];for(let n of iE)e.delete(n)&&t.push(n);return t.push(...[...e].sort()),t}var Gh=Object.freeze(["/usr/local/bin/","/usr/bin/","/bin/","/sbin/"]);function Xh(e,t){for(let n of Gh)if(e.startsWith(n)){let r=e.slice(n.length);if(t(r))return r}return e}var lE=new Set(["test","[","true","false"]),fE=new Set(["grep","egrep","fgrep"]);function cE(e,t){let n=Xh(e[0],t);return lE.has(n)?"status":fE.has(n)?fc(e.slice(1))?"status":"search":"work"}function Zu(e){let t=ql(e,rE),n=Object.freeze({__proto__:null,...Xu,...t.handlers}),r=i=>!!n[i],o=Object.freeze([...Wh,...jh,...t.names]);return Object.freeze({commands:n,names:o,pipeNames:Object.freeze([...uE,...jh.filter(i=>sE.has(i)),...t.pipeNames]),binPrefixes:Gh,has:r,shellOnly:i=>zh.has(i),resolveCommand:i=>Xh(i,r),chainRole:i=>cE(i,r),known:[...Wh,...t.names].join(", ")})}var Zh=Zu();function Yh(e,t){let n=I1.get(e);return n!==void 0?v("feature",e,e,`${e}: ${n}`,127):v("command",e,e,`${e}: command not found. Available: ${t.known}`,127)}function Kh(e,t,n){let r=mE(e);if(!r)return[];let{start:o,pipe:i,quote:s,words:u}=r;for(;dE.has(u[0]);)u.shift();if(pE.has(u[0]))return[];if(u[0]==="for"&&u.length<=2)return[];let a=e.slice(o),l=Vh(a,s);if(!l)return[];let f=u.length===0,c=f?"":n.resolveCommand(Vh(u[0],null)?.value??""),d=f?hE(l.value,i,n,t.functions):i?[]:wE(l,t,c==="cd"),p=e.slice(0,o),h=i&&a===""&&p.endsWith("|")?" ":"";return d.map(m=>p+h+a+gE(m.slice(l.value.length),s))}var dE=new Set(["!","{","do","then","else","elif","if","while","until"]),pE=new Set(["done","fi","}","esac"]);function hE(e,t,n,r){let o=t?n.pipeNames:n.names;for(let s of n.binPrefixes)if(e.startsWith(s))return o.filter(u=>u.startsWith(e.slice(s.length))).map(u=>s+u);if(e.startsWith("/")||e.startsWith("./"))return[];let i=[...r.keys()].filter(s=>!o.includes(s));return[...o,...i].filter(s=>s.startsWith(e))}function mE(e){let t=0,n=!1,r=null,o=!1,i=-1,s=[];for(let u=0;u<e.length;u++){let a=e[u];if(r==="'"){a===r&&(r=null);continue}if(a==="\\"&&(!r||'$`"\\\n'.includes(e[u+1]))){if(u+1===e.length)return null;e[++u]!==`
|
|
260
|
+
`&&(o=!0);continue}if(a==="`"||a==="$"&&e[u+1]==="(")return null;if(r){a===r&&(r=null);continue}if(a==="'"||a==='"'){r=a,o=!0;continue}if(a==="#"&&!o){let c=e.indexOf(`
|
|
261
|
+
`,u);if(c===-1)return null;u=c-1;continue}if(a===" "||a===" "){o&&s.push(e.slice(t,u)),t=u+1,o=!1;continue}let l=a==="|"&&e[u+1]==="|",f=a==="&"&&e[u+1]==="&";if(a==="|"||f||a===";"||a===`
|
|
262
|
+
`||a==="("||a===")"&&i===u-1){(l||f)&&u++,a==="("&&(i=u),t=u+1,n=a==="|"&&!l,s.length=0,o=!1;continue}o=!0}return{start:t,pipe:n,quote:r,words:s}}function Vh(e,t){if(e==="")return{value:"",mask:null};try{let n=Ur(e+(t??""));if(n.length!==1||n[0].kind!=="word")return null;let r=n[0];for(let o=0;o<r.value.length;o++){let i=r.mask?.[o]??"0";if(i!=="1"&&r.value[o]==="$"||i==="0"&&"*?[{".includes(r.value[o]))return null}return r}catch{return null}}function gE(e,t){return t==="'"?e.replaceAll("'","'\\''")+"'":t==='"'?e.replace(/[\\$`"]/gu,"\\$&")+'"':e.replace(/[\s\\'"`$&|;()<>*?[\]{}!#~]/gu,n=>n===`
|
|
256
263
|
`?`'
|
|
257
|
-
'`:"\\"+n)}function
|
|
258
|
-
`}
|
|
259
|
-
`;)f--;return a.slice(0,f)}async function
|
|
260
|
-
`,u=!1,f=!1;else{let
|
|
261
|
-
`,r.exitCode=t.lastExit}return
|
|
262
|
-
`),n=
|
|
263
|
-
`).map((n,r)=>({text:n,kind:t[r]===null?"":
|
|
264
|
-
`;var
|
|
265
|
-
`}];return}finally{this._running=!1}this._cwd=
|
|
266
|
-
`,
|
|
264
|
+
'`:"\\"+n)}function wE(e,t,n=!1){let r=e.value,o=r.startsWith("~")&&(e.mask?.[0]??"0")==="0"&&!e.empty?.some(h=>h<=1)&&(r.length===1||(e.mask?.[1]??"0")==="0");if(o&&r==="~")return t.fs.isDir(E(t.cwd,ln(t),t.fs).path)?["~/"]:[];if(o&&!r.startsWith("~/"))return[];let i=r.lastIndexOf("/"),s=r.slice(0,i+1),u=r.slice(i+1),a=o?ln(t)+s.slice(1):s||".",l=E(t.cwd,a,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:f,files:c,links:d}=t.fs.listDir(l),p=f.map(h=>h+"/");for(let h of d)t.fs.isDir(E(l,h,t.fs).path)?p.push(h+"/"):n||p.push(h);return n||p.push(...c),p.filter(h=>h.startsWith(u)&&(u.startsWith(".")||!h.startsWith("."))).filter(h=>s!==""||u===""||!h.startsWith("-")).map(h=>s===""&&h.startsWith("-")?"./"+h:s+h)}async function Jh(e,t,n,r=!1){let o=(t.substitutionDepth??0)+1;if(o>Qt)throw new b("feature","command substitution nesting limit",`command substitution nesting beyond ${Qt} levels is not supported`);let i=t.expansionFds[2],u=await ce(t,{substitutionDepth:o,outputFds:{1:"out",2:typeof i=="object"||i==="closed"?i:"err"},errexitOff:!0,closed:{out:!1,err:i==="closed"}},()=>$t(t,()=>{let c;try{c=Bl(e,t.writable,t.registry.has)}catch(p){let h=O(p);if(!h){if(r)return x(`error: command substitution: ${p.message}`,2);throw new b("feature","command substitution syntax",`runtime command substitution syntax errors are not supported: ${p.message}`)}return t.unsupported.add(h),x(`error: ${p.message}`,1)}let d=c.length===1&&!c[0].negate&&c[0].stages.length===1?c[0].stages[0]:null;return d&&!d.group&&!d.loop&&!d.conditional&&!d.test&&d.words.length===0&&d.assigns.length===0&&d.redirs.length===1&&d.redirs[0].op==="read"&&d.words.push({value:"cat",mask:null}),n(c,t,{text:t.stdinLeft,bytes:t.stdinBytes})}));t.lastExit=t.substitutionExit=u.exitCode;let a=u.stdout,l=u.stderr;if(a.includes("\0")){let c=a.length;a=a.replaceAll("\0","");let d=c-a.length;t.notes.add(`command substitution: discarded ${d} NUL ${d===1?"byte":"bytes"}.`),l+=`warning: command substitution: ignored null byte in input
|
|
265
|
+
`}uo(t,l);let f=a.length;for(;f>0&&a[f-1]===`
|
|
266
|
+
`;)f--;return a.slice(0,f)}async function Qh(e,t){return{stdout:"",stderr:"",exitCode:await xn(e,t)?0:1}}var Yu=async(e,t)=>(await qs(e,t)).value;async function xn(e,t){let{kind:n}=e;if(n==="not")return!await xn(e.expression,t);if(n==="and")return await xn(e.left,t)&&await xn(e.right,t);if(n==="or")return await xn(e.left,t)||await xn(e.right,t);let{op:r}=e;if(n==="unary"){let u=await Yu(e.word,t);if(r==="-n")return u!=="";if(r==="-z")return u==="";if(["-a","-e","-f","-d"].includes(r))return wu(r,u,t);if(r==="-v")return yE(u,t);Er(r)}["<",">","-nt","-ot","-ef"].includes(r)&&Er(r);let o=await Yu(e.left,t);if(Object.hasOwn(dr,r)){let u=await Yu(e.right,t);return dr[r](Ut(o,t),Ut(u,t))}let i=await qs(e.right,t);Gn(i)&&Er("extglob");let s=Me(on(i),{bash:!0}).test(o);return r==="!="?!s:s}function yE(e,t){return e.includes("[")&&Er("-v array subscript"),/^[ \t\n\r\f\v]*[+-]?0+[ \t]*$/u.test(e)&&Er("-v positional parameter"),/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?Et(e,t).set:!1}function Er(e){throw new b("feature",`[[ ${e}`,`${e} in [[ is not supported`)}function tm(e,t,n,r){return e.define?(t.functions.set(e.define.name,e.define.body),U()):e.test?Qh(e.test,t):e.group?SE(e,t,n,r):e.loop?e.loop.words?kE(e.loop,t,r):bE(e.loop,t,r):vE(e.conditional,t,n,r)}var nm=1e4,em={kind:"feature",command:null,detail:"loop limit",message:`a loop running more than ${nm} times is not supported`};async function bE(e,t,n){let r=U(),o={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let i=0;;i++){if(i===nm){t.unsupported.add(em),_(r,x(`error: ${em.message}`,1));break}let s=r.ignored,u=r.exitCode,a=await n(e.condition,t,o,!0);if(_(r,a),r.exitCode=u,r.ignored=s,a.halt||a.control)return{...r,halt:a.halt,control:a.control,blame:a.blame};if(a.exitCode===0==!!e.until)break;let l=await n(e.body,t,o);if(_(r,l),r.blame=l.blame,l.halt)return{...r,halt:!0};if(l.control?.levels>1)return{...r,control:{...l.control,levels:l.control.levels-1}};if(l.control?.type==="break")break}}finally{t.loopDepth--}return r}var xE={value:"for",mask:null};async function kE(e,t,n){let r=await er([xE,...e.words],t),o=U(),i={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let s of r.argv.slice(1)){t.vars.set(e.name,s);let u=await n(e.body,t,i);if(_(o,u),o.blame=u.blame,u.halt)return{...o,halt:!0};if(u.control?.levels>1)return{...o,control:{...u.control,levels:u.control.levels-1}};if(u.control?.type==="break")break}}finally{t.loopDepth--}return o}async function vE(e,t,n,r){let o=U(),i={text:n,bytes:t.stdinBytes};for(let u of e.branches){let a=await r(u.condition,t,i,!0);if(_(o,a),a.halt||a.control)return{...o,halt:a.halt,control:a.control,blame:a.blame};if(a.exitCode!==0)continue;let l=await r(u.body,t,i);return _(o,l),{...o,halt:l.halt,control:l.control,blame:l.blame}}if(!e.otherwise)return o.exitCode=0,o.ignored=!1,o;let s=await r(e.otherwise,t,i);return _(o,s),{...o,halt:s.halt,control:s.control,blame:s.blame}}async function SE(e,t,n,r){let o={text:n,bytes:t.stdinBytes};return e.isolate?{...await $t(t,()=>r(e.group,t,o)),halt:!1,control:void 0,ignored:!1}:r(e.group,t,o)}var EE=new Set(["sort","cat"]),$E=new Set(["wc","tac"]);function Vu(e){let t=null,n=null,r=i=>{t&&!t.bufferReads&&t.reads.push(i)},o=i=>{if(i!==void 0)for(let s=t;s;s=s.parent){if(!s.reads.includes(i)||s===t&&n?.scope===s&&(n.unsupported||s.buffered||n.fd===1&&(EE.has(s.name)||$E.has(s.name)&&!s.reads.slice(1).includes(i))))continue;if(s.failure)throw s.failure;let u=s===t&&n?.fd===2,a=u?"input modified by diagnostics":"streaming self-output",l=u?"reading input while diagnostics write to the same file is not supported":"writing to an actively read input file is not supported";throw s.failure=ie(new b("feature",a,l),"feature",s.name,a,l),s.failure}};return e.observeIo?.({read:r,write:o}),{read:r,bufferOutput(){t&&(t.buffered=!0)},bufferReads(i){if(!t)return i();let s=t,u=s.bufferReads;s.bufferReads=!0;try{return i()}finally{s.bufferReads=u}},setReads(i){t&&(t.reads=i)},async run(i,s){let u=t;t={name:i,reads:[],parent:u};try{return await s()}finally{t=u}},output(i,s,u){let a=n;n={scope:t,fd:null,unsupported:!!O(i)};try{for(let l of sn(i))l.text!==""&&(n.fd=l.fd,o(s.fds[l.fd]?.identity));return u((l,f)=>{n.fd=l.fd,ws(l,f)})}finally{n=a}}}}function Ju(e,t){let n={1:t.outputFds[1]?.path?t.outputFds[1]:"out",2:t.outputFds[2]?.path?t.outputFds[2]:"err"},r={1:rm(t.outputFds[1]),2:rm(t.outputFds[2])};return un(e,{fds:n,deferred:r},t)}var rm=e=>e!=="out"&&e!=="err"&&!e?.path;async function $r(e,t,n,r=!1){if(e.some(u=>u.background))throw new b("feature","&","background processes (`&`) are not supported");let o=U(),i=null,s=null;for(let[u,a]of e.entries()){if(a.warnings&&_(o,un({...U(a.warnings),exitCode:o.exitCode,ignored:o.ignored},{fds:t.outputFds},t)),a.gate==="and"&&o.exitCode!==0){(s??=Za()).skip(r?null:i,o.exitCode);continue}if(a.gate==="or"&&o.exitCode===0)continue;s?.flush(t.notes);let l=r||a.negate||NE(e,u),f=await(l?ce(t,{errexitOff:!0},()=>om(a.stages,t,n)):om(a.stages,t,n));if(_(o,f),a.negate&&!f.halt&&(o.exitCode=f.exitCode===0?1:0),l&&(o.ignored=!0),i=a.negate?null:f.blame,t.lastExit=o.exitCode,f.halt||f.control){Object.assign(o,{halt:f.halt,control:f.control});break}if(o.exitCode!==0&&!o.ignored&&t.errexit&&!t.errexitOff){o.halt=!0;break}}return s?.flush(t.notes),t.stdinLeft=n.text,t.stdinBytes=n.bytes??null,Object.assign(o,{blame:i})}var NE=(e,t)=>["and","or"].includes(e[t+1]?.gate);async function om(e,t,n){let r=U(),o=n.text,i=n.bytes??null;for(let s=0;s<e.length;s++){let u=e[s],a=s===0,l=s<e.length-1?AE():null,f={...t.outputFds};l&&(f[1]=l);let c=i,d=o,p=()=>OE(u,t,{stdin:d,stdinBytes:c,stdinFile:a&&t.stdinFile,fds:f,stdinPiped:a?t.stdinPiped:!0}),h=e.length>1?{...await $t(t,p),ignored:!1}:await p();a&&(n.text=h.inputLeft,n.bytes=h.bytesLeft??null),_(r,h);let m=l?.carried()??{text:""};i=m.bytes??null,o=m.text??me(m.bytes)??"",r.blame=h.blame,e.length===1&&(r.halt=h.halt,r.control=h.control)}return r}function AE(){let e="",t=null;return{write(n){t===null?e+=n:n!==""&&t.push(B(n))},writeBytes(n){t===null&&(t=e===""?[]:[B(e)],e=""),t.push(n)},carried:()=>t===null?{text:e}:{bytes:vn([...t,new Uint8Array])}}}function OE(e,t,{stdin:n,stdinBytes:r,stdinFile:o,fds:i,stdinPiped:s}){let u={fds:i,stdin:n,stdinBytes:r,stdinFile:o,stdinPiped:s,stdinOrigin:o?t.stdinOrigin:null,stdinHandle:o?t.stdinHandle:null};return ce(t,{substitutionExit:null,expansionOutput:U(),expansionFds:i},()=>Ku(u,t,async()=>{let a=!e.group&&!e.loop&&!e.conditional&&!e.test&&!e.define,l,f;try{a&&(l=await er(e.words,t),l.argv.length===0?await _E(e.assigns,t):l.temps=await RE(e.assigns,t))}catch(w){f=Jo(t,w)}if(f)return _(t.expansionOutput,im(f,u,t)),{...t.expansionOutput,inputLeft:t.stdinLeft,bytesLeft:t.stdinBytes,halt:f.halt};let c=await CE(e,t,t.stdinLeft,o,i);t.expansionFds=c.fds;let d=!1,p=null,h=await Ku(c,t,()=>IE(t,async()=>{if(c.error)return c.error;if(!a){let S=await tm(e,t,c.stdin,$r);return d=!0,p=S.blame??null,S}let w=l.argv.length>0?l.argv[0]:null,y=w===null?void 0:t.functions.get(w);if(y){if(d=!0,t.calling.has(w)){let S=v("feature",w,"function recursion",`${w}: a function calling itself is not supported`);return t.unsupported.add(O(S)),S}t.calling.add(w);try{return await ce(t,{loopDepth:0},async()=>({...await sm(l.temps,t,()=>$r(y,t,{text:c.stdin,bytes:c.stdinBytes})),ignored:!1}))}finally{t.calling.delete(w)}}let k=await LE(t,l);return l.argv.length&&(p=Xa(t.registry.chainRole(l.argv),l.argv[0])),k})),m=c.inherited?t.stdinLeft:c.parentLeft,g=c.inherited?t.stdinBytes:c.parentBytes;return _(t.expansionOutput,d?h:im(h,c,t)),{...t.expansionOutput,inputLeft:m,bytesLeft:g,halt:h.halt,control:h.control,blame:p}}))}function im(e,t,n){try{return un(e,t,n)}catch(r){return un(Jo(n,r),t,n)}}async function CE(e,t,n,r,o){let i={...o},s=n,u=r,a=u?t.stdinOrigin:null,l=u?t.stdinHandle:null,f=!0,c=n,d=!1,p=t.stdinBytes,h=p,m=!1,g=y=>({error:y,fds:i,stdin:s,stdinBytes:m?null:p,stdinFile:u,stdinPiped:d||t.stdinPiped,stdinOrigin:u?a:null,stdinHandle:u?l:null,inherited:f,parentLeft:c,parentBytes:h}),w=async y=>{let k=await ce(t,{expansionFds:i},()=>Ku({fds:i,stdin:s,stdinBytes:p,stdinFile:u,stdinOrigin:a,stdinHandle:l},t,y));return s=t.stdinLeft,p=t.stdinBytes,f&&(c=s,h=p),k};try{for(let y of e.redirs)if(y.op==="dup"){if(i[y.toFd]===void 0||i[y.toFd]==="closed")return g(x(`error: ${y.toFd}: Bad file descriptor`));i[y.fd]=i[y.toFd]}else if(y.op==="close")i[y.fd]="closed";else if(y.op==="to"){let k=y.target===void 0?await w(()=>Ws(y.word,t)):{value:y.target};if(k.error)return g(x(`error: ${k.error}`));let S=k.value==="/dev/null"?"null":k.value==="/dev/stdout"?i[1]:k.value==="/dev/stderr"?i[2]:t.writable?t.fs.openWritable(t.cwd,k.value,y.append):null;if(S===null){let I=Ri(y.label,k.value,t.writable);return t.unsupported.add(O(I)),g(x(`error: ${I.message}`))}if(S==="closed")return g(x(`error: ${k.value}: No such file or directory`));i[y.fd]=S,y.both&&(i[2]=S)}else if(y.op==="text")s=y.expand?await w(()=>jt(TE(y.body),t)):y.body,u=!1,f=!1,m=!0;else if(y.op==="herestring")s=await w(()=>jt(y.word,t))+`
|
|
267
|
+
`,u=!1,f=!1,m=!0;else{let k=await w(()=>Ws(y.word,t)),S=k.error?{error:x(`error: ${k.error}`)}:FE(k.value,t,u?a:s);if(S.error)return g(S.error);s=S.content,m=k.value!=="/dev/stdin",(k.value!=="/dev/stdin"||u)&&(f=!1),k.value!=="/dev/stdin"&&(u=k.value!=="/dev/null",a=u?s:null,l=S.handle,d=u)}if(u&&l){let y=t.io.bufferReads(()=>t.fs.readIdentity(l.identity));if(y!==l.content){if(f||s!==l.content)throw new b("feature","modified redirected input","reading an inherited input file after it changes is not supported");s=a=y,l={...l,content:y}}}}catch(y){return g(Jo(t,y))}return g()}function Jo(e,t){R(e,"shell",t?.path,t?.fsError);let n=O(t);return n&&e.unsupported.add(n),{...x(`error: ${V(t)}`,1),...t?.halt?{halt:!0}:{}}}async function IE(e,t){try{return await t()}catch(n){return Jo(e,n)}}function Ku(e,t,n){let r={outputFds:e.fds,closed:{out:e.fds[1]==="closed",err:e.fds[2]==="closed"},stdinFile:!!e.stdinFile,stdinPiped:e.stdinPiped??t.stdinPiped,stdinOrigin:e.stdinOrigin,stdinHandle:e.stdinHandle};return t.stdinLeft=e.stdin,t.stdinBytes=e.stdinBytes??null,ce(t,r,n)}function TE(e){let t="",n="";for(let r=0;r<e.length;r++){let o=e[r],i=e[r+1];if(o==="\\"&&(i==="$"||i==="\\"||i==="`")){t+=i,n+="1",r++;continue}if(o==="`"){let s=at(e,r);t+=s.raw,n+="2"+"1".repeat(s.raw.length-1),r+=s.raw.length-1;continue}if(o==="$"){let s=ft(e,r,0,!0);if(s?.command!==void 0||s?.parameter!==void 0||s?.arithmetic!==void 0){t+=s.raw,n+="2"+"1".repeat(s.raw.length-1),r+=s.raw.length-1;continue}}t+=o,n+="2"}return{value:t,mask:n}}function FE(e,t,n){if(e==="/dev/null")return{content:""};if(e==="/dev/stdin")return{content:n};let{path:r,error:o}=P(t,"shell",e);if(o)return{error:x(`error: ${e}: ${o}`)};if(t.fs.isFile(r)){let i=t.fs.readFile(r);return{content:i,handle:t.writable&&r.startsWith("/tmp/")?{path:r,content:i,identity:t.fs.fileIdentity(r)}:null}}return{error:x(`error: ${e}: Is a directory`)}}function LE(e,t){let{argv:n}=t;return n.length===0?{stdout:"",stderr:"",exitCode:e.substitutionExit??0}:sm(t.temps,e,()=>e.invoke(n[0],n.slice(1),e.stdinLeft))}async function _E(e,t){for(let n of e)t.vars.set(n.name,await jt(n.word,t,!0))}async function RE(e,t){if(e.length===0)return null;let n=t.vars,r=new Je(n),o=new Set(e.map(i=>i.name));r.bound=new Set;try{await ce(t,{vars:r},async()=>{for(let i of e){r.expansionTargets=o;let s=await jt(i.word,t,!0);r.expansionTargets=null,r.set(i.name,s)}})}finally{r.expansionTargets=null;for(let i of r.bound)o.has(i)||n.set(i,r.get(i))}return{vars:r,names:o}}async function sm(e,t,n){if(!e)return n();let r=t.vars,o=new Je(r),i=e.names;for(let s of i)o.set(s,e.vars.get(s));t.vars=o;try{return o.bound=new Set,await n()}finally{t.vars=r;for(let[s,u]of o)(!i.has(s)||o.bound?.has(s))&&r.set(s,u);for(let s of o.unsetNames)i.has(s)||r.delete(s)}}function am(e,t={}){let{fs:n,cwd:r,home:o,mount:i,writable:s,locale:u}=tl(e,t),a=t.commands===void 0?Zh:Zu(t.commands),l={fs:n,io:Vu(n),mount:i,writable:s,registry:a,createdAt:Date.now(),lock:{turn:Promise.resolve()}};return cm(fm(l,{cwd:r,home:o,user:t.user??"user",locale:u,...lm()}),"createTerminal")}var lm=()=>({vars:new Je,functions:new Map,lastExit:0,errexit:!1}),ME=e=>({vars:new Je(e.vars),functions:new Map(e.functions),lastExit:e.lastExit,errexit:e.errexit});function PE(e,t={}){let{cwd:n,home:r,user:o,locale:i,inherit:s}=nl(e,t),u=s?ME(e):lm();return cm(fm(e,{cwd:n,home:r,user:o,locale:i,...u}),"fork")}function fm({fs:e,io:t,mount:n,writable:r,registry:o,createdAt:i,lock:s},u){let a={fs:e,io:t,mount:n,writable:r,registry:o,createdAt:i,lock:s,...u,calling:new Set,outputFds:{1:"out",2:"err"},loopDepth:0,closed:{out:!1,err:!1},stdinFile:!1,stdinPiped:!1,stdinOrigin:null,stdinHandle:null,stdinLeft:"",stdinBytes:null,unsupported:ei(),notes:new Set};return a.dispatch=(l,f,c)=>ce(a,{stdinLeft:a.stdinLeft,stdinBytes:a.stdinBytes,stdinFile:!1,stdinPiped:!1,stdinOrigin:null,stdinHandle:null},()=>$t(a,()=>um(l,f,c,a,!0))),a.flushOutput=l=>Ju(l,a),a.hasCommand=l=>o.has(l)&&!o.shellOnly(l),a.invoke=(l,f,c)=>um(l,f,c,a),a.substitute=(l,f)=>Jh(l,a,$r,f),a.runLine=l=>dm(l,a),a}function cm(e,t){if(!e.fs.isDir(e.cwd))throw new Error(`${t}: cwd is not a directory: ${e.cwd}`);return{run:n=>BE(e,n),cwd:()=>e.cwd,complete:n=>Kh(n,e,e.registry),fork:n=>PE(e,n)}}async function um(e,t,n,r,o=!1){let i=r.registry,s=i.resolveCommand(e),u=()=>{if((o||e!==s)&&i.shellOnly(s))return v("command",e,e,`${e}: shell builtin cannot be invoked as an external command`,127);let l=i.commands[s];return l?l(n,t,r):Yh(e,i)},a=l=>Ju(DE(r,ys(e,l,r),s),r);try{return await r.io.run(s,async()=>a(await u()))}catch(l){R(r,e,l?.path,l?.fsError);let f=`${e}: ${V(l)}`,c=O(l);return c&&r.unsupported.add({...c,command:c.command??e,message:f},c.command??s),a(x(f))}}function DE(e,t,n){let r=O(t);return r&&e.unsupported.add(r,n),t}function BE(e,t){let{lock:n}=e,r=n.turn.then(()=>dm(t,e));return n.turn=r.then(()=>null,()=>null),r}function dm(e,t){let n=ei();return ce(t,{unsupported:n,notes:new Set,discarded:new Set,stdinFile:!1,stdinPiped:!1,stdinOrigin:null,stdinHandle:null,stdinBytes:null,closed:{out:!1,err:!1},outputFds:{1:"out",2:"err"}},async()=>{let r={stdout:"",stderr:"",exitCode:0},o={text:""};try{for(let i of Ul(e,t.writable,t.registry.has)){let s=await $r(i,t,o);if(r.stdout+=s.stdout,r.stderr+=s.stderr,r.exitCode=s.exitCode,s.halt||s.control)break}}catch(i){let s=O(i);s&&n.add(s),t.lastExit=i.exitCode??(s?1:2),r.stderr+=`error: ${i.message}
|
|
268
|
+
`,r.exitCode=t.lastExit}return UE(r,t,n)})}var UE=(e,t,n)=>({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,cwd:t.cwd,unsupported:Object.freeze(n.entries),notes:Object.freeze([...t.notes,...bi(t.discarded,e.stderr,t.notes)])});var jE={unified:[[/^--- /u,"bold"],[/^\+\+\+ /u,"bold"],[cn,"cyan"],[/^\+/u,"green"],[/^-/u,"red"],[/^\\ /u,"gray"]],context:[[qt,"cyan"],[/^\*{3} \d/u,"cyan"],[/^--- \d/u,"cyan"],[/^\*{3} /u,"bold"],[/^--- /u,"bold"],[/^! /u,"yellow"],[/^\+ /u,"green"],[/^- /u,"red"]],normal:[[dn,"cyan"],[/^< /u,"red"],[/^> /u,"green"],[/^---$/u,"gray"]]};function WE(e){return e.some(t=>qt.test(t))?"context":e.some(t=>cn.test(t))?"unified":e.some(t=>dn.test(t))?"normal":null}function pm(e){let t=e.split(`
|
|
269
|
+
`),n=jE[WE(t)];return n===void 0?null:t.map(r=>n.find(([o])=>o.test(r))?.[1]??null)}var qE={bold:"head",cyan:"hunk",green:"add",red:"del",yellow:"chg",gray:"meta"};function hm(e){let t=pm(e);return t===null?null:e.split(`
|
|
270
|
+
`).map((n,r)=>({text:n,kind:t[r]===null?"":qE[t[r]]??""}))}function mm({stdout:e,stderr:t,unsupported:n}){return n.filter(r=>!t.includes(r.message)&&!e.includes(r.message)).map(r=>r.message)}var gm=`:host{display:flex;flex-direction:column;position:relative;height:100%;min-height:0;background:var(--bg, #0c0c0c);color:var(--text, #e6edf3);font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:13px;line-height:1.45}.output{flex:1 1 auto;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;padding:12px 14px 6px;cursor:text}.banner{color:var(--muted, #8b949e);margin-bottom:8px;user-select:none}.banner .cmd{color:var(--accent, #58a6ff)}.banner .cmd:hover{text-decoration:underline}.line{white-space:pre-wrap;overflow-wrap:break-word}.cwd{color:var(--accent, #58a6ff)}.sigil{color:var(--muted, #8b949e)}.stdout,.stderr{margin:0 0 4px;font:inherit;white-space:pre-wrap;overflow-wrap:break-word}.stderr{color:var(--critical, #d8413a)}.diff-head{color:var(--text, #e6edf3);font-weight:600}.diff-hunk{color:var(--accent, #58a6ff)}.diff-add{color:var(--green, #3fb950)}.diff-del{color:var(--critical, #d8413a)}.diff-chg{color:var(--yellow, #d29922)}.diff-meta{color:var(--muted, #8b949e)}.form{flex:0 0 auto;display:flex;align-items:center;padding:8px 14px 10px;border-top:1px solid var(--border, #2c2c2c)}.form:focus-within{border-top-color:var(--accent, #58a6ff)}.form[aria-busy=true] .sigil{opacity:.4}.form[aria-busy=true] .input{caret-color:transparent}.form .cwd{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none}.form .sigil{flex:0 0 auto;user-select:none;margin:0 1ch}.input-wrap{flex:1 1 auto;min-width:0;position:relative;display:flex;align-items:center}.input{width:100%;background:transparent;border:none;outline:none;color:inherit;font:inherit;padding:0;position:relative}.ghost{position:absolute;inset:0;display:flex;align-items:center;font:inherit;white-space:pre;overflow:hidden;pointer-events:none;user-select:none;color:var(--muted, #8b949e);opacity:.55}.ghost-pad{color:transparent}.notes{position:absolute;top:8px;right:14px;z-index:2;display:flex;flex-direction:column;align-items:flex-end;gap:6px;max-width:min(52%,320px);pointer-events:none}.note{box-sizing:border-box;padding:5px 9px;border:1px solid var(--border, #2c2c2c);border-radius:5px;background:var(--bg, #0c0c0c);color:var(--muted, #8b949e);font-size:12px;line-height:1.4;text-align:left;overflow-wrap:break-word;animation:note-in .14s ease-out,note-out .4s ease-in var(--dwell-out, 5.6s) forwards}.note-gap{border-color:var(--warning, #d97706);color:var(--text, #e6edf3)}@keyframes note-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}@keyframes note-out{to{opacity:0;transform:translateY(-4px)}}@media(prefers-reduced-motion:reduce){.note{animation:none}}
|
|
271
|
+
`;var ea="/sources",HE={mount:ea,home:"/",writable:"/tmp/"};function GE(e){let n=["ls","find /",`grep -r ${XE(e)} .`];if(!e||e.size===0)return n;let r=null;for(let[o,i]of e){if(typeof i!="string")continue;let s=ZE(o);(r===null||s.length<r.length)&&(r=s)}return r&&n.push(`cat ${r} | head -n 20`),n}var Qu=["TODO","FIXME","XXX","HACK","NOTE","BUG","export","import","require","//"];function XE(e){if(!e||e.size===0)return Qu[0];for(let t of Qu)for(let n of e.values())if(typeof n=="string"&&n.includes(t))return t;return Qu[0]}function ZE(e){return e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e}var ta=class e extends ra{static properties={sources:{attribute:!1},_lines:{state:!0},_input:{state:!0},_cwd:{state:!0},_ghost:{state:!0},_notes:{state:!0},_running:{state:!0}};static styles=oa(gm);#n=null;#f=null;#t=[];#e=-1;#i="";#o=null;#s=null;static#h=200;#r=new Map;#m=0;static#g=3;static#w=400;constructor(){super(),this.sources=null,this._lines=[],this._input="",this._cwd=ea,this._ghost="",this._notes=[],this._running=!1}willUpdate(t){t.has("sources")&&this.sources!==this.#f&&(this.#n=this.sources?am(this.sources,HE):null,this._cwd=this.#n?this.#n.cwd():ea,this._lines=[{kind:"banner",commands:GE(this.sources)}],this.#t=[],this.#e=-1,this.#i="",this.#o=null,this._input="",this.#l(),this.#f=this.sources),t.has("_input")&&(this.#a(),this.#d())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#c())}disconnectedCallback(){super.disconnectedCallback(),this.#a(),this.#l()}firstUpdated(){this.#u()}updated(t){(t.has("_lines")||t.has("sources"))&&this.#c()}#u(){let t=this.renderRoot.querySelector(".input");t&&t.focus()}#c(){let t=this.renderRoot.querySelector(".output");t&&(t.scrollTop=t.scrollHeight)}#y=async t=>{if(t.preventDefault(),!this.#n||this._running)return;let n=this._input,r=n.trim();if(r==="clear"){this._lines=[],this.#l(),this._input="",r.length>0&&(this.#t=[...this.#t,n]),this.#e=-1;return}let o=this._cwd;r.length>0&&(this.#t=[...this.#t,n]),this.#e=-1,this._input="";let i;this._running=!0;try{i=await this.#n.run(n)}catch(u){this._lines=[...this._lines,{kind:"prompt",cwd:o,text:n},{kind:"stderr",text:`${u?.message??u}
|
|
272
|
+
`}];return}finally{this._running=!1}this._cwd=i.cwd;let s=[...this._lines,{kind:"prompt",cwd:o,text:n}];i.stdout&&s.push({kind:"stdout",text:i.stdout,diff:hm(i.stdout)}),i.stderr&&s.push({kind:"stderr",text:i.stderr}),this._lines=s,this.#v(i)};#b=t=>{if(t.key==="Tab"&&!t.shiftKey){t.preventDefault(),this.#x();return}this.#o=null,t.key==="ArrowUp"?(t.preventDefault(),this.#A()):t.key==="ArrowDown"&&(t.preventDefault(),this.#O()),this.#a(),this.#d()};#x(){if(!this.#n)return;let t=this.#o;if(t&&t.items[t.index]===this._input){t.index=(t.index+1)%t.items.length,this._input=t.items[t.index];return}let n=this.#n.complete(this._input);if(n.length===0){this.#o=null;return}this._input=n[0],this.#o=n.length>1?{items:n,index:0}:null}#a(){this._ghost="",this.#s!==null&&(clearTimeout(this.#s),this.#s=null)}#d(){this.#s=setTimeout(()=>{this.#s=null,this.#k()},e.#h)}#k(){if(!this.#n||this.#o)return;let t=this._input,n=t.slice(-1),r=t===""||n===" "||n==="|",o=/[\w./]/u.test(n);if(!r&&!o)return;let i=this.#n.complete(t);if(i.length===0)return;let s=i[0];!s.startsWith(t)||s===t||o&&i.includes(t)||(this._ghost=s.slice(t.length))}#v(t){let n=t.notes.map(r=>({text:r,kind:"note"}));for(let r of mm(t))n.push({text:`silenced: ${r}`,kind:"gap"});this.#S(n)}#S(t){if(t.length===0)return;let n=[...this._notes];for(let{text:r,kind:o}of t){let i=n.findIndex(s=>s.text===r);i!==-1&&this.#p(n,i),n.push({id:++this.#m,text:r,kind:o,dwell:e.#E(r)})}for(;n.length>e.#g;)this.#p(n,0);for(let r of n)this.#r.has(r.id)||this.#r.set(r.id,setTimeout(()=>this.#N(r.id),r.dwell));this._notes=n}static#E(t){return Math.min(1e4,3200+t.length*55)}#p(t,n){let[r]=t.splice(n,1);this.#$(r.id)}#$(t){let n=this.#r.get(t);n!==void 0&&(clearTimeout(n),this.#r.delete(t))}#N(t){this.#r.delete(t),this._notes=this._notes.filter(n=>n.id!==t)}#l(){for(let t of this.#r.values())clearTimeout(t);this.#r.clear(),this._notes=[]}#A(){this.#t.length!==0&&(this.#e<0?(this.#i=this._input,this.#e=this.#t.length-1):this.#e=Math.max(0,this.#e-1),this._input=this.#t[this.#e])}#O(){if(this.#e<0)return;let t=this.#e+1;t>=this.#t.length?(this.#e=-1,this._input=this.#i,this.#i=""):(this.#e=t,this._input=this.#t[t])}#C=t=>{this._input=t.target.value};#I=t=>{this._input=t,this.#e=-1,this.#i="",this.#u()};#T=()=>{let t=this.renderRoot.getSelection?.()??document.getSelection();t&&!t.isCollapsed||this.#u()};render(){return De`<div class="notes" role="log" aria-atomic="false">${ia(this._notes,t=>t.id,t=>De`<div class="note ${t.kind==="gap"?"note-gap":""}" style="--dwell-out: ${t.dwell-e.#w}ms">${t.text}</div>`)}</div><div class="output" @click="${this.#T}">${this._lines.map(t=>this.#F(t))}</div><form class="form" @submit="${this.#y}" aria-busy="${this._running?"true":"false"}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?De`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:Qo} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#C}" @keydown="${this.#b}"></div></form>`}#F(t){return t.kind==="banner"?De`<div class="banner">Virtual shell over the bundle source tree. Try ${t.commands.map((n,r)=>De`${r>0?", ":""}\`<span class="cmd" @click="${()=>this.#I(n)}">${n}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:t.kind==="prompt"?De`<div class="line"><span class="cwd">${t.cwd}</span>${" "}<span class="sigil">$</span>${" "}${t.text}</div>`:t.kind==="stdout"?this.#L(t):t.kind==="stderr"?De`<pre class="stderr">${t.text}</pre>`:Qo}#L(t){if(!t.diff)return De`<pre class="stdout">${t.text}</pre>`;let n=t.diff.flatMap((r,o)=>{let i=r.kind?De`<span class="diff-${r.kind}">${r.text}</span>`:r.text;return o===0?[i]:[`
|
|
273
|
+
`,i]});return De`<pre class="stdout">${n}</pre>`}};customElements.define("bundle-terminal",ta);function L_(e,t){let n=document.createElement("bundle-terminal");return n.dataset.integrity=t??"",n.sources=e,n}export{L_ as createTerminalElement};
|