/*! just-bash 3.4.2 (Vercel), Apache-2.0, with retained third-party dependencies. * Extracted from victor/MiniCPM5-2B-WebGPU-Pi: unused inference and Pi agent code removed; * original shell behavior preserved. See ../licenses/dependencies.txt for license texts. */ var q0=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),x4=class{diff(e,t,r={}){let n;typeof r=="function"?(n=r,r={}):"callback"in r&&(n=r.callback);let i=this.castInput(e,r),s=this.castInput(t,r),a=this.removeEmpty(this.tokenize(i,r)),o=this.removeEmpty(this.tokenize(s,r));return this.diffWithOptionsObj(a,o,r,n)}diffWithOptionsObj(e,t,r,n){let i=g=>{if(g=this.postProcess(g,r),n){setTimeout(function(){n(g)},0);return}return g},s=t.length,a=e.length,o=1,l=s+a;r.maxEditLength!=null&&(l=Math.min(l,r.maxEditLength));let u=r.timeout??1/0,c=Date.now()+u,p=[{oldPos:-1,lastComponent:void 0}],h=this.extractCommon(p[0],t,e,0,r);if(p[0].oldPos+1>=a&&h+1>=s)return i(this.buildValues(p[0].lastComponent,t,e));let f=-1/0,d=1/0,m=()=>{for(let g=Math.max(f,-o);g<=Math.min(d,o);g+=2){let v,y=p[g-1],x=p[g+1];y&&(p[g-1]=void 0);let b=!1;if(x){let E=x.oldPos-g;b=x&&0<=E&&E=a&&h+1>=s)return i(this.buildValues(v.lastComponent,t,e))||!0;p[g]=v,v.oldPos+1>=a&&(d=Math.min(d,g-1)),h+1>=s&&(f=Math.max(f,g+1))}o++};if(n)(function g(){setTimeout(function(){if(o>l||Date.now()>c)return n(void 0);m()||g()},0)})();else for(;o<=l&&Date.now()<=c;){let g=m();if(g)return g}}addToPath(e,t,r,n,i){let s=e.lastComponent;return s&&!i.oneChangePerToken&&s.added===t&&s.removed===r?{oldPos:e.oldPos+n,lastComponent:{count:s.count+1,added:t,removed:r,previousComponent:s.previousComponent}}:{oldPos:e.oldPos+n,lastComponent:{count:1,added:t,removed:r,previousComponent:s}}}extractCommon(e,t,r,n,i){let s=t.length,a=r.length,o=e.oldPos,l=o-n,u=0;for(;l+1p.length?f:p}),u.value=this.join(c)}else u.value=this.join(t.slice(o,o+u.count));o+=u.count,u.added||(l+=u.count)}}return n}},v4=new class extends x4{constructor(){super(...arguments),this.tokenize=b4}equals(e,t,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(` `))&&(e=e.trim()),(!r.newlineIsToken||!t.includes(` `))&&(t=t.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(e.endsWith(` `)&&(e=e.slice(0,-1)),t.endsWith(` `)&&(t=t.slice(0,-1))),super.equals(e,t,r)}};function M1(e,t,r){return v4.diff(e,t,r)}function b4(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,` `));let r=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let i=0;i{let h=u(p);c(h)}}))}else return u(M1(r,n,o));function u(c){if(!c)return;c.push({value:"",lines:[]});function p(y){return y.map(function(x){return" "+x})}let h=[],f=0,d=0,m=[],g=1,v=1;for(let y=0;y0?p(w.lines.slice(-l)):[],f-=m.length,d-=m.length)}for(let w of b)m.push((x.added?"+":"-")+w);x.added?v+=b.length:g+=b.length}else{if(f)if(b.length<=l*2&&y1&&!t.includeFileHeaders)throw Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return e.map(n=>iu(n,t)).join(` `)}let r=[];t.includeIndex&&e.oldFileName==e.newFileName&&r.push("Index: "+e.oldFileName),t.includeUnderline&&r.push("==================================================================="),t.includeFileHeaders&&(r.push("--- "+e.oldFileName+(e.oldHeader===void 0?"":" "+e.oldHeader)),r.push("+++ "+e.newFileName+(e.newHeader===void 0?"":" "+e.newHeader)));for(let n=0;n{o(l?iu(l,a.headerOptions):void 0)}}))}else{let o=F1(e,t,r,n,i,s,a);return o?iu(o,a?.headerOptions):void 0}}function S4(e){let t=e.endsWith(` `),r=e.split(` `).map(n=>n+` `);return t?r.pop():r.push(r.pop().slice(0,-1)),r}var Ui=q0((e=>{(function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function r(o){return i(a(o),arguments)}function n(o,l){return r.apply(null,[o].concat(l||[]))}function i(o,l){for(var u=1,c=o.length,p,h="",f=0,d,m,g,v,y,x,b;f=0),m.type){case"b":p=parseInt(p,10).toString(2);break;case"c":p=String.fromCharCode(parseInt(p,10));break;case"d":case"i":p=parseInt(p,10);break;case"j":p=JSON.stringify(p,null,m.width?parseInt(m.width):0);break;case"e":p=m.precision?parseFloat(p).toExponential(m.precision):parseFloat(p).toExponential();break;case"f":p=m.precision?parseFloat(p).toFixed(m.precision):parseFloat(p);break;case"g":p=m.precision?String(Number(p.toPrecision(m.precision))):parseFloat(p);break;case"o":p=(parseInt(p,10)>>>0).toString(8);break;case"s":p=String(p),p=m.precision?p.substring(0,m.precision):p;break;case"t":p=String(!!p),p=m.precision?p.substring(0,m.precision):p;break;case"T":p=Object.prototype.toString.call(p).slice(8,-1).toLowerCase(),p=m.precision?p.substring(0,m.precision):p;break;case"u":p=parseInt(p,10)>>>0;break;case"v":p=p.valueOf(),p=m.precision?p.substring(0,m.precision):p;break;case"x":p=(parseInt(p,10)>>>0).toString(16);break;case"X":p=(parseInt(p,10)>>>0).toString(16).toUpperCase()}t.json.test(m.type)?h+=p:(t.number.test(m.type)&&(!x||m.sign)?(b=x?"+":"-",p=p.toString().replace(t.sign,"")):b="",v=m.pad_char?m.pad_char==="0"?"0":m.pad_char.charAt(1):" ",y=m.width-(b+p).length,g=m.width&&y>0?v.repeat(y):"",h+=m.align?b+p+g:v==="0"?b+g+p:g+b+p)}return h}var s=Object.create(null);function a(o){if(s[o])return s[o];for(var l=o,u,c=[],p=0;l;){if((u=t.text.exec(l))!==null)c.push(u[0]);else if((u=t.modulo.exec(l))!==null)c.push("%");else if((u=t.placeholder.exec(l))!==null){if(u[2]){p|=1;var h=[],f=u[2],d=[];if((d=t.key.exec(f))!==null)for(h.push(d[1]);(f=f.substring(d[0].length))!=="";)if((d=t.key_access.exec(f))!==null)h.push(d[1]);else if((d=t.index_access.exec(f))!==null)h.push(d[1]);else throw SyntaxError("[sprintf] failed to parse named argument key");else throw SyntaxError("[sprintf] failed to parse named argument key");u[2]=h}else p|=2;if(p===3)throw Error("[sprintf] mixing positional and named placeholders is not (yet) supported");c.push({placeholder:u[0],param_no:u[1],keys:u[2],sign:u[3],pad_char:u[4],align:u[5],width:u[6],precision:u[7],type:u[8]})}else throw SyntaxError("[sprintf] unexpected placeholder");l=l.substring(u[0].length)}return s[o]=c}e!==void 0&&(e.sprintf=r,e.vsprintf=n),typeof window<"u"&&(window.sprintf=r,window.vsprintf=n,typeof define=="function"&&define.amd&&define(function(){return{sprintf:r,vsprintf:n}}))})()}))(),G0=(e,t,r)=>{let n=e instanceof RegExp?_1(e,r):e,i=t instanceof RegExp?_1(t,r):t,s=n!==null&&i!=null&&A4(n,i,r);return s&&{start:s[0],end:s[1],pre:r.slice(0,s[0]),body:r.slice(s[0]+n.length,s[1]),post:r.slice(s[1]+i.length)}},_1=(e,t)=>{let r=t.match(e);return r?r[0]:null},A4=(e,t,r)=>{let n,i,s,a,o,l=r.indexOf(e),u=r.indexOf(t,l+1),c=l;if(l>=0&&u>0){if(e===t)return[l,u];for(n=[],s=r.length;c>=0&&!o;){if(c===l)n.push(c),l=r.indexOf(e,c+1);else if(n.length===1){let p=n.pop();p!==void 0&&(o=[p,u])}else i=n.pop(),i!==void 0&&i=0?l:u}n.length&&a!==void 0&&(o=[s,a])}return o},H0="\0SLASH"+Math.random()+"\0",V0="\0OPEN"+Math.random()+"\0",bc="\0CLOSE"+Math.random()+"\0",Z0="\0COMMA"+Math.random()+"\0",Q0="\0PERIOD"+Math.random()+"\0",C4=new RegExp(H0,"g"),k4=new RegExp(V0,"g"),N4=new RegExp(bc,"g"),$4=new RegExp(Z0,"g"),O4=new RegExp(Q0,"g"),T4=/\\\\/g,I4=/\\{/g,R4=/\\}/g,P4=/\\,/g,D4=/\\\./g;function Lo(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function L4(e){return e.replace(T4,H0).replace(I4,V0).replace(R4,bc).replace(P4,Z0).replace(D4,Q0)}function M4(e){return e.replace(C4,"\\").replace(k4,"{").replace(N4,"}").replace($4,",").replace(O4,".")}function K0(e){if(!e)return[""];let t=[],r=G0("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:s}=r,a=n.split(",");a[a.length-1]+="{"+i+"}";let o=K0(s);return s.length&&(a[a.length-1]+=o.shift(),a.push.apply(a,o)),t.push.apply(t,a),t}function F4(e,t={}){if(!e)return[];let{max:r=1e5,maxLength:n=4e6}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),su(L4(e),r,n,!0).map(M4)}function _4(e){return"{"+e+"}"}function z4(e){return/^-?0\d/.test(e)}function B4(e,t){return e<=t}function U4(e,t){return e>=t}function Yi(e,t,r,n,i,s){let a=[],o=0;for(let l=0;l=n)return a;let c=e[l]+t+r[u];if(!s||c){if(o+c.length>i)return a;a.push(c),o+=c.length}}return a}function W4(e,t,r,n){let i=e.split(/\.\./),s=[];if(i[0]===void 0||i[1]===void 0)return s;let a=Lo(i[0]),o=Lo(i[1]),l=Math.max(i[0].length,i[1].length),u=i.length===3&&i[2]!==void 0?Math.max(Math.abs(Lo(i[2])),1):1,c=B4;o0){let g=Array(m+1).join("0");d=f<0?"-"+g+d.slice(1):g+d}}if(h+d.length>n)break;s.push(d),h+=d.length}return s}function su(e,t,r,n){let i=[""],s=!1,a=!0;for(;;){let o=G0("{","}",e);if(!o)return Yi(i,e,[""],t,r,s);let l=o.pre;if(/\$$/.test(l)){if(i=Yi(i,l+"{"+o.body+"}",[""],t,r,s&&!o.post.length),a=!1,!o.post.length)break;e=o.post;continue}let u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body),p=u||c,h=o.body.indexOf(",")>=0;if(!p&&!h){if(o.post.match(/,(?!,).*\}/)){e=o.pre+"{"+o.body+bc+o.post,n=!0;continue}return Yi(i,l+"{"+o.body+"}"+o.post,[""],t,r,s)}a&&=(s=n&&!p,!1);let f;if(p)f=W4(o.body,c,t,r);else{let d=K0(o.body);if(d.length===1&&d[0]!==void 0&&(d=su(d[0],t,r,!1).map(_4),d.length===1)){if(i=Yi(i,l+d[0],[""],t,r,s&&!o.post.length),!o.post.length)break;e=o.post;continue}let m=s&&!o.post.length&&!l;for(let v=0;m&&v=t||g+b.length>r)break e;f.push(b),g+=b.length}}}}if(i=Yi(i,l,f,t,r,s&&!o.post.length),!o.post.length)break;e=o.post}return i}var Ta=e=>{if(typeof e!="string")throw TypeError("invalid pattern");if(e.length>65536)throw TypeError("pattern is too long")},j4={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Ji=e=>e.replace(/[[\]\\-]/g,"\\$&"),q4=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z1=e=>e.join(""),G4=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw Error("not in a brace expression");let n=[],i=[],s=r+1,a=!1,o=!1,l=!1,u=!1,c=r,p="";e:for(;sp?n.push(Ji(p)+"-"+Ji(d)):d===p&&n.push(Ji(d)),p="",s++;continue}if(e.startsWith("-]",s+1)){n.push(Ji(d+"-")),s+=2;continue}if(e.startsWith("-",s+1)){p=d,s+=2;continue}n.push(Ji(d)),s++}if(cr?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1"),Gt,H4=new Set(["!","?","+","*","@"]),au=e=>H4.has(e),B1=e=>au(e.type),V4=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Z4=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Q4=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),U1=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Mo="(?!\\.)",K4=new Set(["[","."]),X4=new Set(["..","."]),Y4=new Set("().*{}+?[]^$\\!"),J4=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),W1="[^/]+?",e8=0,wc=class{type;#r;#n;#i=!1;#e=[];#t;#o;#u;#l=!1;#s;#a;#c=!1;id=++e8;get depth(){return(this.#t?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#r.id,parent:this.#t?.id,depth:this.depth,partsLength:this.#e.length,parts:this.#e}}constructor(e,t,r={}){this.type=e,e&&(this.#n=!0),this.#t=t,this.#r=this.#t?this.#t.#r:this,this.#s=this.#r===this?r:this.#r.#s,this.#u=this.#r===this?[]:this.#r.#u,e==="!"&&!this.#r.#l&&this.#u.push(this),this.#o=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let e of this.#e)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#a===void 0?this.#a=this.type?this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#e.map(e=>String(e)).join(""):this.#a}#y(){if(this!==this.#r)throw Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let e;for(;e=this.#u.pop();){if(e.type!=="!")continue;let t=e,r=t.#t;for(;r;){for(let n=t.#o+1;!r.type&&ntypeof t=="string"?t:t.toJSON()):[this.type,...this.#e.map(t=>t.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#r||this.#r.#l&&this.#t?.type==="!")&&e.push({}),e}isStart(){if(this.#r===this)return!0;if(!this.#t?.isStart())return!1;if(this.#o===0)return!0;let e=this.#t;for(let t=0;ttypeof p!="string"),l=this.#e.map(p=>{let[h,f,d,m]=typeof p=="string"?Gt.#S(p,this.#n,o):p.toRegExpSource(e);return this.#n=this.#n||d,this.#i=this.#i||m,h}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&X4.has(this.#e[0]))){let p=K4,h=t&&p.has(l.charAt(0))||l.startsWith("\\.")&&p.has(l.charAt(2))||l.startsWith("\\.\\.")&&p.has(l.charAt(4)),f=!t&&!e&&p.has(l.charAt(0));u=h?"(?!(?:^|/)\\.\\.?(?:$|/))":f?Mo:""}let c="";return this.isEnd()&&this.#r.#l&&this.#t?.type==="!"&&(c="(?:$|\\/)"),[u+l+c,hs(l),this.#n=!!this.#n,this.#i]}let r=this.type==="*"||this.type==="+",n=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#g(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){let o=this.toString(),l=this;return l.#e=[o],l.type=null,l.#n=void 0,[o,hs(this.toString()),!1,!1]}let s=!r||e||t?"":this.#g(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#c)a=(this.isStart()&&!t?Mo:"")+W1;else{let o=this.type==="!"?"))"+(this.isStart()&&!t&&!e?Mo:"")+"[^/]*?)":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=n+i+o}return[a,hs(i),this.#n=!!this.#n,this.#i]}#f(){if(B1(this)){let e=0,t=!1;do{t=!0;for(let r=0;r{if(typeof t=="string")throw Error("string type in extglob ast??");let[r,n,i,s]=t.toRegExpSource(e);return this.#i=this.#i||s,r}).filter(t=>!(this.isStart()&&this.isEnd())||!!t).join("|")}static#S(e,t,r=!1){let n=!1,i="",s=!1,a=!1;for(let o=0;or?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&"),Pt=(e,t,r={})=>(Ta(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Ia(t,r).match(e)),r8=/^\*+([^+@!?*[(]*)$/,n8=e=>t=>!t.startsWith(".")&&t.endsWith(e),i8=e=>t=>t.endsWith(e),s8=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),a8=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),o8=/^\*+\.\*+$/,l8=e=>!e.startsWith(".")&&e.includes("."),u8=e=>e!=="."&&e!==".."&&e.includes("."),c8=/^\.\*+$/,p8=e=>e!=="."&&e!==".."&&e.startsWith("."),h8=/^\*+$/,f8=e=>e.length!==0&&!e.startsWith("."),d8=e=>e.length!==0&&e!=="."&&e!=="..",m8=/^\?+([^+@!?*[(]*)?$/,g8=([e,t=""])=>{let r=X0([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},y8=([e,t=""])=>{let r=Y0([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},x8=([e,t=""])=>{let r=Y0([e]);return t?n=>r(n)&&n.endsWith(t):r},v8=([e,t=""])=>{let r=X0([e]);return t?n=>r(n)&&n.endsWith(t):r},X0=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Y0=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},J0=typeof process=="object"&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",j1={win32:{sep:"\\"},posix:{sep:"/"}};Pt.sep=J0==="win32"?j1.win32.sep:j1.posix.sep;var zt=Symbol("globstar **");Pt.GLOBSTAR=zt,Pt.filter=(e,t={})=>r=>Pt(r,e,t);var cr=(e,t={})=>Object.assign({},e,t);Pt.defaults=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Pt;let t=Pt;return Object.assign((r,n,i={})=>t(r,n,cr(e,i)),{Minimatch:class extends t.Minimatch{constructor(r,n={}){super(r,cr(e,n))}static defaults(r){return t.defaults(cr(e,r)).Minimatch}},AST:class extends t.AST{constructor(r,n,i={}){super(r,n,cr(e,i))}static fromGlob(r,n={}){return t.AST.fromGlob(r,cr(e,n))}},unescape:(r,n={})=>t.unescape(r,cr(e,n)),escape:(r,n={})=>t.escape(r,cr(e,n)),filter:(r,n={})=>t.filter(r,cr(e,n)),defaults:r=>t.defaults(cr(e,r)),makeRe:(r,n={})=>t.makeRe(r,cr(e,n)),braceExpand:(r,n={})=>t.braceExpand(r,cr(e,n)),match:(r,n,i={})=>t.match(r,n,cr(e,i)),sep:t.sep,GLOBSTAR:zt})};var em=(e,t={})=>(Ta(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:F4(e,{max:t.braceExpandMax}));Pt.braceExpand=em,Pt.makeRe=(e,t={})=>new Ia(e,t).makeRe(),Pt.match=(e,t,r={})=>{let n=new Ia(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};var q1=/[?*]|[+@!]\(.*?\)|\[|\]/,b8=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ia=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){Ta(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||J0,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let r=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(r),this.debug(this.pattern,this.globParts);let n=this.globParts.map((i,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let o=i[0]===""&&i[1]===""&&(i[2]==="?"||!q1.test(i[2]))&&!q1.test(i[3]),l=/^[a-z]:/i.test(i[0]);if(o)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(l)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(o=>this.parse(o))});if(this.debug(this.pattern,n),this.set=n.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let r=-1;for(;(r=t.indexOf("**",r+1))!==-1;){let n=r;for(;t[n+1]==="**";)n++;n!==r&&t.splice(r,n-r)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((r,n)=>{let i=r[r.length-1];return n==="**"&&i==="**"?r:n===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(r.pop(),r):(r.push(n),r)},[]),t.length===0?[""]:t))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;nn&&r.splice(n+1,s-n);let a=r[n+1],o=r[n+2],l=r[n+3];if(a!==".."||!o||o==="."||o===".."||!l||l==="."||l==="..")continue;t=!0,r.splice(n,1);let u=r.slice(0);u[n]="**",e.push(u),n--}if(!this.preserveMultipleSlashes){for(let s=1;st.length)}partsMatch(e,t,r=!1){let n=0,i=0,s=[],a="";for(;n=2&&(e=this.levelTwoFileOptimize(e)),t.includes(zt)?this.#r(e,t,r,n,i):this.#i(e,t,r,n,i)}#r(e,t,r,n,i){let s=t.indexOf(zt,i),a=t.lastIndexOf(zt),[o,l,u]=r?[t.slice(i,s),t.slice(s+1),[]]:[t.slice(i,s),t.slice(s+1,a),t.slice(a+1)];if(o.length){let v=e.slice(n,n+o.length);if(!this.#i(v,o,r,0,0))return!1;n+=o.length,i+=o.length}let c=0;if(u.length){if(u.length+n>e.length)return!1;let v=e.length-u.length;if(this.#i(e,u,r,v,0))c=u.length;else{if(e[e.length-1]!==""||n+u.length===e.length||(v--,!this.#i(e,u,r,v,0)))return!1;c=u.length+1}}if(!l.length){let v=!!c;for(let y=n;y{let l=o.map(c=>{if(c instanceof RegExp)for(let p of c.flags.split(""))n.add(p);return typeof c=="string"?b8(c):c===zt?zt:c._src});l.forEach((c,p)=>{let h=l[p+1],f=l[p-1];c===zt&&f!==zt&&(f===void 0?h!==void 0&&h!==zt?l[p+1]="(?:\\/|"+r+"\\/)?"+h:l[p]=r:h===void 0?l[p-1]=f+"(?:\\/|\\/"+r+")?":h!==zt&&(l[p-1]=f+"(?:\\/|\\/"+r+"\\/)"+h,l[p+1]=zt))});let u=l.filter(c=>c!==zt);if(this.partial&&u.length>=1){let c=[];for(let p=1;p<=u.length;p++)c.push(u.slice(0,p).join("/"));return"(?:"+c.join("|")+")"}return u.join("/")}).join("|"),[s,a]=e.length>1?["(?:",")"]:["",""];i="^"+s+i+a+"$",this.partial&&(i="^(?:\\/|"+s+i.slice(1,-1)+a+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...n].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;let r=this.options;this.isWindows&&(e=e.split("\\").join("/"));let n=this.slashSplit(e);this.debug(this.pattern,"split",n);let i=this.set;this.debug(this.pattern,"set",i);let s=n[n.length-1];if(!s)for(let a=n.length-2;!s&&a>=0;a--)s=n[a];for(let a of i){let o=n;if(r.matchBase&&a.length===1&&(o=[s]),this.matchOne(o,a,t))return r.flipNegate?!0:!this.negate}return!r.flipNegate&&this.negate}static defaults(e){return Pt.defaults(e).Minimatch}};Pt.AST=wc,Pt.Minimatch=Ia,Pt.escape=t8,Pt.unescape=hs;var Ti=q0(((e,t)=>{t.exports={}}))();function w8(e){for(var t=1;t0&&e[t-1]===` `;)t--;return e.substring(0,t)}function G1(e){return rm(tm(e))}var E8="ADDRESS.ARTICLE.ASIDE.AUDIO.BLOCKQUOTE.BODY.CANVAS.CENTER.DD.DIR.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.FRAMESET.H1.H2.H3.H4.H5.H6.HEADER.HGROUP.HR.HTML.ISINDEX.LI.MAIN.MENU.NAV.NOFRAMES.NOSCRIPT.OL.OUTPUT.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL".split(".");function Ec(e){return Sc(e,E8)}var nm=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function im(e){return Sc(e,nm)}function S8(e){return am(e,nm)}var sm=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function A8(e){return Sc(e,sm)}function C8(e){return am(e,sm)}function Sc(e,t){return t.indexOf(e.nodeName)>=0}function am(e,t){return e.getElementsByTagName&&t.some(function(r){return e.getElementsByTagName(r).length})}var k8=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function om(e){return k8.reduce(function(t,r){return t.replace(r[0],r[1])},e)}var Ft={};Ft.paragraph={filter:"p",replacement:function(e){return` `+e+` `}},Ft.lineBreak={filter:"br",replacement:function(e,t,r){return r.br+` `}},Ft.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,t,r){var n=Number(t.nodeName.charAt(1));if(r.headingStyle==="setext"&&n<3){var i=Fo(n===1?"=":"-",e.length);return` `+e+` `+i+` `}return` `+Fo("#",n)+" "+e+` `}},Ft.blockquote={filter:"blockquote",replacement:function(e){return e=G1(e).replace(/^/gm,"> "),` `+e+` `}},Ft.list={filter:["ul","ol"],replacement:function(e,t){var r=t.parentNode;return r.nodeName==="LI"&&r.lastElementChild===t?` `+e:` `+e+` `}},Ft.listItem={filter:"li",replacement:function(e,t,r){var n=r.bulletListMarker+" ",i=t.parentNode;if(i.nodeName==="OL"){var s=i.getAttribute("start"),a=Array.prototype.indexOf.call(i.children,t);n=(s?Number(s)+a:a+1)+". "}var o=/\n$/.test(e);return e=G1(e)+(o?` `:""),e=e.replace(/\n/gm,` `+" ".repeat(n.length)),n+e+(t.nextSibling?` `:"")}},Ft.indentedCodeBlock={filter:function(e,t){return t.codeBlockStyle==="indented"&&e.nodeName==="PRE"&&e.firstChild&&e.firstChild.nodeName==="CODE"},replacement:function(e,t,r){return` `+t.firstChild.textContent.replace(/\n/g,` `)+` `}},Ft.fencedCodeBlock={filter:function(e,t){return t.codeBlockStyle==="fenced"&&e.nodeName==="PRE"&&e.firstChild&&e.firstChild.nodeName==="CODE"},replacement:function(e,t,r){for(var n=((t.firstChild.getAttribute("class")||"").match(/language-(\S+)/)||[null,""])[1],i=t.firstChild.textContent,s=r.fence.charAt(0),a=3,o=RegExp("^"+s+"{3,}","gm"),l;l=o.exec(i);)l[0].length>=a&&(a=l[0].length+1);var u=Fo(s,a);return` `+u+n+` `+i.replace(/\n$/,"")+` `+u+` `}},Ft.horizontalRule={filter:"hr",replacement:function(e,t,r){return` `+r.hr+` `}},Ft.inlineLink={filter:function(e,t){return t.linkStyle==="inlined"&&e.nodeName==="A"&&e.getAttribute("href")},replacement:function(e,t){var r=_o(t.getAttribute("href")),n=zo(qs(t.getAttribute("title"))),i=n?' "'+n+'"':"";return"["+e+"]("+r+i+")"}},Ft.referenceLink={filter:function(e,t){return t.linkStyle==="referenced"&&e.nodeName==="A"&&e.getAttribute("href")},replacement:function(e,t,r){var n=_o(t.getAttribute("href")),i=qs(t.getAttribute("title"));i&&=' "'+zo(i)+'"';var s,a;switch(r.linkReferenceStyle){case"collapsed":s="["+e+"][]",a="["+e+"]: "+n+i;break;case"shortcut":s="["+e+"]",a="["+e+"]: "+n+i;break;default:var o=this.references.length+1;s="["+e+"]["+o+"]",a="["+o+"]: "+n+i}return this.references.push(a),s},references:[],append:function(e){var t="";return this.references.length&&(t=` `+this.references.join(` `)+` `,this.references=[]),t}},Ft.emphasis={filter:["em","i"],replacement:function(e,t,r){return e.trim()?r.emDelimiter+e+r.emDelimiter:""}},Ft.strong={filter:["strong","b"],replacement:function(e,t,r){return e.trim()?r.strongDelimiter+e+r.strongDelimiter:""}},Ft.code={filter:function(e){var t=e.previousSibling||e.nextSibling,r=e.parentNode.nodeName==="PRE"&&!t;return e.nodeName==="CODE"&&!r},replacement:function(e){if(!e)return"";e=e.replace(/\r?\n|\r/g," ");for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",r="`",n=e.match(/`+/gm)||[];n.indexOf(r)!==-1;)r+="`";return r+t+e+t+r}},Ft.image={filter:"img",replacement:function(e,t){var r=om(qs(t.getAttribute("alt"))),n=_o(t.getAttribute("src")||""),i=qs(t.getAttribute("title")),s=i?' "'+zo(i)+'"':"";return n?"!["+r+"]("+n+s+")":""}};function qs(e){return e?e.replace(/(\n+\s*)+/g,` `):""}function _o(e){var t=e.replace(/([<>()])/g,"\\$1");return t.indexOf(" ")>=0?"<"+t+">":t}function zo(e){return e.replace(/"/g,'\\"')}function lm(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}lm.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){if(e.isBlank)return this.blankRule;var t;return(t=Bo(this.array,e,this.options))||(t=Bo(this._keep,e,this.options))||(t=Bo(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(var t=0;t-1)return!0}else if(typeof n=="function"){if(n.call(e,t,r))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}function $8(e){var t=e.element,r=e.isBlock,n=e.isVoid,i=e.isPre||function(p){return p.nodeName==="PRE"};if(t.firstChild&&!i(t)){for(var s=null,a=!1,o=null,l=H1(o,t,i);l!==t;){if(l.nodeType===3||l.nodeType===4){var u=l.data.replace(/[ \r\n\t]+/g," ");if((!s||/ $/.test(s.data))&&!a&&u[0]===" "&&(u=u.substr(1)),!u){l=Uo(l);continue}l.data=u,s=l}else if(l.nodeType===1)r(l)||l.nodeName==="BR"?(s&&(s.data=s.data.replace(/ $/,"")),s=null,a=!1):n(l)||i(l)?(s=null,a=!0):s&&(a=!1);else{l=Uo(l);continue}var c=H1(o,l,i);o=l,l=c}s&&(s.data=s.data.replace(/ $/,""),s.data||Uo(s))}}function Uo(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function H1(e,t,r){return e&&e.parentNode===t||r(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}var Ac=typeof window<"u"?window:{};function O8(){var e=Ac.DOMParser,t=!1;try{new e().parseFromString("","text/html")&&(t=!0)}catch{}return t}function T8(){var e=function(){};return I8()?e.prototype.parseFromString=function(t){var r=new window.ActiveXObject("htmlfile");return r.designMode="on",r.open(),r.write(t),r.close(),r}:e.prototype.parseFromString=function(t){var r=document.implementation.createHTMLDocument("");return r.open(),r.write(t),r.close(),r},e}function I8(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch{Ac.ActiveXObject&&(e=!0)}return e}var R8=O8()?Ac.DOMParser:T8();function P8(e,t){var r=typeof e=="string"?D8().parseFromString(''+e+"","text/html").getElementById("turndown-root"):e.cloneNode(!0);return $8({element:r,isBlock:Ec,isVoid:im,isPre:t.preformattedCode?L8:null}),r}var V1;function D8(){return V1||=new R8,V1}function L8(e){return e.nodeName==="PRE"||e.nodeName==="CODE"}function M8(e,t){return e.isBlock=Ec(e),e.isCode=e.nodeName==="CODE"||e.parentNode.isCode,e.isBlank=F8(e),e.flankingWhitespace=_8(e,t),e}function F8(e){return!im(e)&&!A8(e)&&/^\s*$/i.test(e.textContent)&&!S8(e)&&!C8(e)}function _8(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var r=z8(e.textContent);return r.leadingAscii&&Z1("left",e,t)&&(r.leading=r.leadingNonAscii),r.trailingAscii&&Z1("right",e,t)&&(r.trailing=r.trailingNonAscii),{leading:r.leading,trailing:r.trailing}}function z8(e){var t=e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:t[1],leadingAscii:t[2],leadingNonAscii:t[3],trailing:t[4],trailingNonAscii:t[5],trailingAscii:t[6]}}function Z1(e,t,r){var n,i,s;return e==="left"?(n=t.previousSibling,i=/ $/):(n=t.nextSibling,i=/^ /),n&&(n.nodeType===3?s=i.test(n.nodeValue):r.preformattedCode&&n.nodeName==="CODE"?s=!1:n.nodeType===1&&!Ec(n)&&(s=i.test(n.textContent))),s}var B8=Array.prototype.reduce;function Ra(e){if(!(this instanceof Ra))return new Ra(e);var t={rules:Ft,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(r,n){return n.isBlock?` `:""},keepReplacement:function(r,n){return n.isBlock?` `+n.outerHTML+` `:n.outerHTML},defaultReplacement:function(r,n){return n.isBlock?` `+r+` `:r}};this.options=w8({},t,e),this.rules=new lm(this.options)}Ra.prototype={turndown:function(e){if(!j8(e))throw TypeError(e+" is not a string, or an element/document/fragment node.");if(e==="")return"";var t=um.call(this,new P8(e,this.options));return U8.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t()=>(e&&(t=e(e=0)),t),ao=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),re=(e,t)=>{for(var r in t)Cc(e,r,{get:t[r],enumerable:!0})},Q8=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of H8(t))!Z8.call(e,i)&&i!==r&&Cc(e,i,{get:()=>t[i],enumerable:!(n=G8(t,i))||n.enumerable});return e},pm=(e,t,r)=>(r=e==null?{}:q8(V8(e)),Q8(t||!e||!e.__esModule?Cc(r,"default",{value:e,enumerable:!0}):r,e)),hm={};re(hm,{AsyncLocalStorage:()=>dm,Module:()=>mm,lookup:()=>fm});function fm(){throw Error("node:dns is not available in browser environments")}var dm,mm,ou=M(()=>{dm=void 0,mm=void 0});function K8(){return lu||gm(),lu}function gm(){let e=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","NODE_ENV","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"seteuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.seteuid could escalate effective user privileges"},{prop:"setegid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setegid could escalate effective group privileges"},{prop:"initgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.initgroups could modify supplementary group IDs"},{prop:"setgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgroups could modify supplementary group IDs"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"cwd",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.cwd could disclose real host working directory path"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"report",target:process,violationType:"process_report",strategy:"throw",reason:"process.report could disclose full environment, host paths, and system info"},{prop:"loadEnvFile",target:process,violationType:"process_env",strategy:"throw",reason:"process.loadEnvFile could load env files bypassing env proxy"},{prop:"setUncaughtExceptionCaptureCallback",target:process,violationType:"process_exception_handler",strategy:"throw",reason:"setUncaughtExceptionCaptureCallback could intercept security errors"},...["on","once","addListener","prependListener","prependOnceListener"].map(r=>({prop:r,target:process,violationType:"process_exception_handler",strategy:"throw",reason:"process-global listeners can outlive the sandbox and lose its security context"})),{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"},{prop:"performance",target:globalThis,violationType:"performance_timing",strategy:"throw",reason:"performance.now() provides sub-millisecond timing for side-channel attacks"},{prop:"stdout",target:process,violationType:"process_stdout",strategy:"throw",reason:"process.stdout could bypass interpreter output to write to host stdout"},{prop:"stderr",target:process,violationType:"process_stderr",strategy:"throw",reason:"process.stderr could bypass interpreter output to write to host stderr"},{prop:"__defineGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineGetter__ allows prototype pollution via getter injection"},{prop:"__defineSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineSetter__ allows prototype pollution via setter injection"},{prop:"__lookupGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupGetter__ enables introspection for prototype pollution attacks"},{prop:"__lookupSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupSetter__ enables introspection for prototype pollution attacks"},{prop:"JSON",target:globalThis,violationType:"json_mutation",strategy:"freeze",reason:"Freeze JSON to prevent mutation of parsing/serialization"},{prop:"Math",target:globalThis,violationType:"math_mutation",strategy:"freeze",reason:"Freeze Math to prevent mutation of math utilities"}];try{let r=Object.getPrototypeOf(async()=>{}).constructor;r&&r!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let r=Object.getPrototypeOf(function*(){}).constructor;r&&r!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let r=Object.getPrototypeOf(async function*(){}).constructor;r&&r!==Function&&r!==Object.getPrototypeOf(async()=>{}).constructor&&e.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}let t=e.filter(r=>{try{return r.target[r.prop]!==void 0}catch{return!1}});return lu??=new Set(t.map(({violationType:r})=>r)),t}var lu,X8=M(()=>{});function Y8(){return Math.floor(ym+xm())}var ym,xm,J8=M(()=>{ym=performance.timeOrigin,xm=performance.now.bind(performance)});function e9(e){let t=e?.find(r=>kc.has(r));if(t)throw RangeError(`defenseInDepth.excludeViolationTypes cannot disable the non-excludable "${t}" protection`)}function t9(e,t,r){let n=r&&!kc.has(t)?` If this access is required by trusted host-runtime code, add "${t}" to defenseInDepth.excludeViolationTypes.`:"";return e+vm+n}var kc,vm,r9=M(()=>{kc=new Set(["function_constructor","async_function_constructor","generator_function_constructor","async_generator_function_constructor"]),vm=` This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`});function Q1(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function n9(e,t,...r){return je.run(e,()=>t(...r))}function K1(){return!jr&&typeof vi?.registerHooks=="function"}function X1(e){let t=typeof e=="boolean"?{enabled:e}:e??{};if(e9(t.excludeViolationTypes),t.enabled!==void 0&&t.enabled!==!0&&t.enabled!==!1&&t.enabled!=="auto")throw RangeError('defenseInDepth.enabled must be true, false, or "auto"');let r={...bm,...t},n=r.enabled==="auto"?"auto":r.enabled?"enabled":"disabled",i={...r,enabled:n!=="disabled",requested:n};return i.excludeViolationTypes&&=[...new Set(i.excludeViolationTypes)].sort(),i}function i9(e,t){if(e.enabled!==t.enabled||e.auditMode!==t.auditMode||e.processLifetimeIntrinsicHardening!==t.processLifetimeIntrinsicHardening||e.onViolation!==t.onViolation)return!1;let r=e.excludeViolationTypes??[],n=t.excludeViolationTypes??[];return r.length===n.length&&r.every((i,s)=>i===n[s])}var jr,Gs,vi,Wo,Ae,je,Y1,bm,Kt,Ar=M(()=>{if(ou(),ou(),X8(),J8(),r9(),jr=!0,Gs=null,vi=null,Wo=null,!jr)try{Gs=void 0,vi=hm,Wo=vi.Module??vi.default??null}catch{}Ae=class extends Error{violation;constructor(e,t){super(t9(e,t.type,t.type==="error_prepare_stack_trace"||K8().has(t.type))),this.violation=t,this.name="SecurityViolationError"}},je=!jr&&Gs?new Gs:null,Y1=1e3,bm={enabled:!0,auditMode:!1,processLifetimeIntrinsicHardening:!1},Kt=class Ue{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];temporaryIntrinsicDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(t){this.config=t}static getInstance(t){let r=X1(t);if(!Ue.instance)Ue.instance=new Ue(r);else{let n=Ue.instance.config;if(!i9(r,n))throw Error("DefenseInDepthBox config conflict: all resolved defense options, including exclusions and the violation callback, must match across Bash instances. Call DefenseInDepthBox.resetInstance() between incompatible configurations.")}return Ue.instance}static resetInstance(){Ue.instance&&=(Ue.instance.forceDeactivate(),null),Ue.trustedExecutionDepth.clear()}static isInSandboxedContext(){return je?je?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(je)return je?.getStore()?.executionId}static enterTrustedScope(t){let r=Ue.trustedExecutionDepth.get(t)??0;Ue.trustedExecutionDepth.set(t,r+1)}static leaveTrustedScope(t){let r=Ue.trustedExecutionDepth.get(t);if(r){if(r===1){Ue.trustedExecutionDepth.delete(t);return}Ue.trustedExecutionDepth.set(t,r-1)}}static isTrustedScopeActive(t){return t?(Ue.trustedExecutionDepth.get(t)??0)>0:!1}static isTrustedContext(t){return!t||t.forceUntrusted?!1:t.trusted===!0||Ue.isTrustedScopeActive(t.executionId)}isExecutionIdActive(t){return this.activeExecutionIds.has(t)}getCachedContext(t){let r=this.contextCache.get(t);return r||(r={sandboxActive:!0,executionId:t},this.contextCache.set(t,r)),r}static bindCurrentContext(t){if(!je)return t;let r=je.getStore(),n=r?.sandboxActive===!0?r.executionId:void 0;if(!n)return t;let i=Ue.instance?.getCachedContext(n)??{sandboxActive:!0,executionId:n},s=r?.forceUntrusted?{...i,forceUntrusted:!0}:i;return((...a)=>{let o=Ue.instance;if(!(o&&!o.isExecutionIdActive(n)&&(o.recordViolation("bound_callback_after_deactivate","bound callback","Bound callback blocked after originating execution was deactivated"),!o.config.auditMode)))return n9(s,t,...a)})}isEnabled(){return this.getStatus().state==="enabled"}getStatus(){let t=K1();return this.config.requested==="disabled"?{requested:"disabled",state:"disabled",level:"none",contextualDynamicImportProtection:t,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort"}:!je||jr?{requested:this.config.requested,state:"unsupported",level:"none",contextualDynamicImportProtection:!1,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:"context-aware ESM loader hooks (node:module.registerHooks) are unavailable"}:{requested:this.config.requested,state:"enabled",level:this.config.auditMode?"none":t?"full":"best-effort",contextualDynamicImportProtection:t,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?"process-lifetime":"scoped-best-effort",reason:this.config.auditMode?"audit mode records violations but does not block them":t?void 0:"best-effort protection; context-aware ESM loader hooks are unavailable"}}updateConfig(t){if(this.refCount>0)throw Error("DefenseInDepthBox configuration cannot change while protection is active");this.config=X1({...this.config,...t})}activate(){if(!jr&&this.config.enabled&&!je)throw Error("DefenseInDepthBox: enabled protection requires node:async_hooks and node:module");if(jr||!this.config.enabled){let n=Q1(),i=!1;return{run:s=>i?Promise.reject(Error("DefenseInDepthBox handle is deactivated and cannot run new work")):s(),deactivate:()=>{i=!0},executionId:n}}if(this.refCount++,this.refCount===1){try{this.applyPatches()}catch(n){throw this.restorePatches(),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0,n}this.activationTime=Date.now()}let t=Q1(),r=!1;return{run:n=>r?Promise.reject(Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(t),je.run({sandboxActive:!0,executionId:t},n)),deactivate:()=>{r||(r=!0,this.activeExecutionIds.delete(t),this.contextCache.delete(t),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:t}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(t,r){return t===globalThis?`globalThis.${r}`:t===process?`process.${r}`:t===Error?`Error.${r}`:t===Function.prototype?`Function.prototype.${r}`:t===Object.prototype?`Object.prototype.${r}`:`.${r}`}static runTrusted(t){if(!je)return t();let r=je.getStore();if(!r)return t();let{executionId:n}=r;return je.run({...r,trusted:!0,forceUntrusted:!1},()=>{Ue.enterTrustedScope(n);try{let i=t();return typeof i=="object"&&i&&"finally"in i&&typeof i.finally=="function"?i.finally(()=>{Ue.leaveTrustedScope(n)}):(Ue.leaveTrustedScope(n),i)}catch(i){throw Ue.leaveTrustedScope(n),i}})}static async runTrustedAsync(t){if(!je)return t();let r=je.getStore();if(!r)return t();let{executionId:n}=r;return je.run({...r,trusted:!0,forceUntrusted:!1},async()=>{Ue.enterTrustedScope(n);try{return await t()}finally{Ue.leaveTrustedScope(n)}})}static async runUntrustedAsync(t){if(!je)return t();let r=je.getStore();return r?je.run({...r,trusted:!1,forceUntrusted:!0},t):t()}shouldBlock(){if(jr||this.config.auditMode||!je)return!1;let t=je?.getStore();return!(t?.sandboxActive!==!0||Ue.isTrustedContext(t))}shouldAudit(){if(!this.config.auditMode||!je)return!1;let t=je.getStore();return t?.sandboxActive===!0&&!Ue.isTrustedContext(t)}recordViolation(t,r,n){let i={timestamp:Y8(),type:t,message:n,path:r,stack:Error().stack,executionId:je?.getStore()?.executionId};if(this.violations.length{let o=`${r} ${a} is blocked during script execution`,l=i.recordViolation(n,r,o);throw new Ae(o,l)};return new Proxy(t,{set(a,o,l,u){return i.shouldBlock()&&s("modification"),Reflect.set(a,o,l,u)},defineProperty(a,o,l){return i.shouldBlock()&&s("defineProperty"),Reflect.defineProperty(a,o,l)},deleteProperty(a,o){return i.shouldBlock()&&s("deletion"),Reflect.deleteProperty(a,o)},setPrototypeOf(a,o){return i.shouldBlock()&&s("setPrototypeOf"),Reflect.setPrototypeOf(a,o)},preventExtensions(a){return i.shouldBlock()&&s("preventExtensions"),Reflect.preventExtensions(a)}})}applyPatches(){this.patchFailures=[];let t=gm(),r=new Set(this.config.excludeViolationTypes??[]),n=new Set(["process_send","process_channel","process_stdout","process_stderr"]),i=[];for(let o of t)if(!r.has(o.violationType)&&!n.has(o.violationType)){if(o.strategy==="freeze"){i.push(o);continue}this.applyPatch(o)}this.protectConstructorChain(),r.has("error_prepare_stack_trace")||this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),K1()&&this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.protectProxyRevocable();let s=["Function.prototype.constructor","Module._load","Module._resolveFilename"],a=this.patchFailures.filter(o=>s.includes(o));if(a.length>0)throw this.restorePatches(),Error(`DefenseInDepthBox: critical patches failed: ${a.join(", ")}`);this.config.processLifetimeIntrinsicHardening||this.protectReversibleIntrinsics(i);for(let o of i)this.applyPatch(o,this.config.processLifetimeIntrinsicHardening===!0);this.config.processLifetimeIntrinsicHardening&&this.lockWellKnownSymbols()}protectReversibleIntrinsics(t){let r=new Set,n=(a,o)=>{let l=Object.getOwnPropertyDescriptor(a,o);!l||!("value"in l)||l.writable!==!0||l.configurable!==!0||(this.temporaryIntrinsicDescriptors.push({target:a,prop:o,descriptor:l}),Object.defineProperty(a,o,{...l,writable:!1}))};for(let{target:a,prop:o}of t){let l=a[o];if(typeof l=="object"&&l){r.add(l);for(let u of Reflect.ownKeys(l))n(l,u)}}let i=[];for(let a of[Array,Map,Set,RegExp,Promise])i.push([a,Symbol.species]);for(let a of[Array.prototype,String.prototype,Map.prototype,Set.prototype])i.push([a,Symbol.iterator]);i.push([Symbol.prototype,Symbol.toPrimitive],[Date.prototype,Symbol.toPrimitive],[Function.prototype,Symbol.hasInstance],[Array.prototype,Symbol.unscopables]);for(let a of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])i.push([RegExp.prototype,a]);for(let a of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])i.push([a,Symbol.toStringTag]);for(let[a,o]of i)r.add(a),n(a,o);let s=(a,o,l)=>{let u=Object.getOwnPropertyDescriptor(a,o);if(!u||!("value"in u)||typeof u.value!="function"||u.configurable!==!0)return;let c=u.value,p=this,h=function(...f){let d=f[0];if(p.shouldBlock()&&typeof d=="object"&&d&&r.has(d)){let m=`${l}.${o}`,g=`${m} is blocked for protected intrinsics during script execution`,v=p.recordViolation("prototype_mutation",m,g);throw new Ae(g,v)}return Reflect.apply(c,this,f)};this.temporaryIntrinsicDescriptors.push({target:a,prop:o,descriptor:u}),Object.defineProperty(a,o,{...u,value:h,writable:!1})};for(let a of["assign","defineProperties","defineProperty","freeze","preventExtensions","seal","setPrototypeOf"])s(Object,a,"Object");for(let a of["defineProperty","deleteProperty","preventExtensions","set","setPrototypeOf"])s(Reflect,a,"Reflect")}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(t){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(t){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(async function*(){}).constructor,r=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&t!==r&&this.patchPrototypeConstructor(t.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(t){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}}protectErrorPrepareStackTrace(){let t=this;try{let r=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:r});let n=r?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(i){if(t.shouldBlock()){let s="Error.prepareStackTrace modification is blocked during script execution",a=t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",s);throw new Ae(s,a)}t.shouldAudit()&&t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),n=i},configurable:!0})}catch(r){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",r instanceof Error?r.message:r)}}protectPromiseThen(){let t=this;try{let r=function(...s){return je.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,s);if(this.kind==="fulfilled")return s[0];throw s[0]}return Reflect.apply(this.cb,void 0,s)})},n=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:n});let i=n?.value;if(typeof i!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(s,a){if(!je)return Reflect.apply(i,this,[s,a]);let o=je.getStore(),l=o?.sandboxActive===!0&&o.trusted!==!0?o.executionId:void 0;if(!l)return Reflect.apply(i,this,[s,a]);let u=t.getCachedContext(l),c=o?.forceUntrusted?{...u,forceUntrusted:!0}:u,p=(h,f)=>typeof h=="function"?r.bind({box:t,executionId:l,captured:c,cb:h,kind:f}):h;return Reflect.apply(i,this,[p(s,"fulfilled"),p(a,"rejected")])},writable:!0,configurable:!0})}catch(r){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",r instanceof Error?r.message:r)}}patchPrototypeConstructor(t,r,n){let i=this;try{let s=Object.getOwnPropertyDescriptor(t,"constructor");this.originalDescriptors.push({target:t,prop:"constructor",descriptor:s});let a=s?.value;Object.defineProperty(t,"constructor",{get(){if(i.shouldBlock()){let o=`${r} access is blocked during script execution`,l=i.recordViolation(n,r,o);throw new Ae(o,l)}return i.shouldAudit()&&i.recordViolation(n,r,`${r} accessed (audit mode)`),a},set(o){if(i.shouldBlock()){let l=`${r} modification is blocked during script execution`,u=i.recordViolation(n,r,l);throw new Ae(l,u)}Object.defineProperty(this,"constructor",{value:o,writable:!0,configurable:!0})},configurable:!0})}catch(s){this.patchFailures.push(r),console.debug(`[DefenseInDepthBox] Could not patch ${r}:`,s instanceof Error?s.message:s)}}protectProcessMainModule(){if(typeof process>"u")return;let t=this;try{let r=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:r});let n=r?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(t.shouldBlock()){let i="process.mainModule access is blocked during script execution",s=t.recordViolation("process_main_module","process.mainModule",i);throw new Ae(i,s)}return t.shouldAudit()&&t.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),n},set(i){if(t.shouldBlock()){let s="process.mainModule modification is blocked during script execution",a=t.recordViolation("process_main_module","process.mainModule",s);throw new Ae(s,a)}Object.defineProperty(process,"mainModule",{value:i,writable:!0,configurable:!0})},configurable:!0})}catch(r){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",r instanceof Error?r.message:r)}}protectProcessExecPath(){if(typeof process>"u")return;let t=this;try{let r=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:r});let n=r?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(t.shouldBlock()){let i="process.execPath access is blocked during script execution",s=t.recordViolation("process_exec_path","process.execPath",i);throw new Ae(i,s)}return t.shouldAudit()&&t.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),n},set(i){if(t.shouldBlock()){let s="process.execPath modification is blocked during script execution",a=t.recordViolation("process_exec_path","process.execPath",s);throw new Ae(s,a)}Object.defineProperty(process,"execPath",{value:i,writable:!0,configurable:!0})},configurable:!0})}catch(r){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",r instanceof Error?r.message:r)}}lockWellKnownSymbols(){let t=(r,n)=>{try{let i=Object.getOwnPropertyDescriptor(r,n);if(i?.configurable){if("value"in i){Object.defineProperty(r,n,{...i,configurable:!1,writable:!1});return}Object.defineProperty(r,n,{...i,configurable:!1})}}catch{}};for(let r of[Array,Map,Set,RegExp,Promise])t(r,Symbol.species);for(let r of[Array.prototype,String.prototype,Map.prototype,Set.prototype])t(r,Symbol.iterator);t(Symbol.prototype,Symbol.toPrimitive),t(Date.prototype,Symbol.toPrimitive);for(let r of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])t(RegExp.prototype,r);t(Function.prototype,Symbol.hasInstance),t(Array.prototype,Symbol.unscopables);for(let r of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])t(r,Symbol.toStringTag)}protectProxyRevocable(){let t=this;try{let r=Proxy.revocable;if(typeof r!="function")return;let n=Object.getOwnPropertyDescriptor(Proxy,"revocable");this.originalDescriptors.push({target:Proxy,prop:"revocable",descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(i,s){if(t.shouldBlock()){let a="Proxy.revocable is blocked during script execution",o=t.recordViolation("proxy","Proxy.revocable",a);throw new Ae(a,o)}return t.shouldAudit()&&t.recordViolation("proxy","Proxy.revocable","Proxy.revocable called (audit mode)"),r(i,s)},writable:!1,configurable:!0})}catch(r){this.patchFailures.push("Proxy.revocable"),console.debug("[DefenseInDepthBox] Could not protect Proxy.revocable:",r instanceof Error?r.message:r)}}protectDynamicImport(){if(!(jr||Ue.importHooksRegistered))try{let t=vi;if(!t)throw Error("node:module is unavailable");let r=new Set;for(let s of t.builtinModules??[]){let a=s.startsWith("node:")?s.slice(5):s;r.add(a);let o=a.indexOf("/");o>0&&r.add(a.slice(0,o))}let n=s=>{if(s.startsWith("./")||s.startsWith("../")||s.startsWith("/")||s.startsWith("file:")||s.startsWith("data:")||s.startsWith("blob:")||s.startsWith("http:")||s.startsWith("https:"))return!1;let a=s.startsWith("node:")?s.slice(5):s;if(!a)return!1;if(typeof t.isBuiltin=="function"&&t.isBuiltin(a)||r.has(a))return!0;let o=a.indexOf("/");return o>0&&r.has(a.slice(0,o))},i=s=>{let a=je?.getStore();return s.config.auditMode===!0&&a?.sandboxActive===!0&&!Ue.isTrustedContext(a)};if(typeof t.registerHooks=="function"){t.registerHooks({resolve(s,a,o){let l=Ue.instance;if(!l)return o(s,a);if((s.startsWith("data:")||s.startsWith("blob:"))&&l.shouldBlock()){let u=`import(${s.startsWith("data:")?"data:":"blob:"})`,c=`dynamic import of ${s.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`,p=l.recordViolation("dynamic_import_builtin",u,c);throw new Ae(c,p)}if(n(s)){let u=`import(${s})`,c=`dynamic import of Node.js builtin '${s}' is blocked during script execution`;if(l.shouldBlock()){let p=l.recordViolation("dynamic_import_builtin",u,c);throw new Ae(c,p)}i(l)&&l.recordViolation("dynamic_import_builtin",u,`dynamic import of Node.js builtin '${s}' called (audit mode)`)}return o(s,a)}}),Ue.importHooksRegistered=!0;return}throw Error("context-aware ESM loader hooks (node:module.registerHooks) are unavailable")}catch(t){throw Error(`DefenseInDepthBox: could not register dynamic-import hooks: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}protectModuleLoad(){this.protectModuleMethod("_load","module_load")}protectModuleResolveFilename(){this.protectModuleMethod("_resolveFilename","module_resolve_filename")}protectModuleMethod(t,r){if(jr)return;let n=`Module.${t}`;try{let i=Wo,s=i?.[t];if(!i||typeof s!="function")throw Error("node:module Module class or method is unavailable");let a=Object.getOwnPropertyDescriptor(i,t);if(!a)throw Error("method has no own property descriptor");if(a.configurable===!1&&a.writable===!1)throw Error("method is non-configurable and non-writable");let o=this.createBlockingProxy(s,n,r);this.originalDescriptors.push({target:i,prop:t,descriptor:a}),Object.defineProperty(i,t,{...a,value:o});let l=Object.getOwnPropertyDescriptor(i,t);if(i[t]!==o||l?.value!==o)throw Error("installed patch failed verification")}catch{this.patchFailures.push(n)}}applyPatch(t,r=!1){let{target:n,prop:i,violationType:s,strategy:a}=t;try{let o=n[i];if(o===void 0)return;let l=Object.getOwnPropertyDescriptor(n,i);if(this.originalDescriptors.push({target:n,prop:i,descriptor:l}),a==="freeze"){if(typeof o=="object"&&o){r&&Object.freeze(o);let u=this.getPathForTarget(n,i),c=this.createReadonlyObjectProxy(o,u,s);Object.defineProperty(n,i,{...l,value:c})}}else{let u=this.getPathForTarget(n,i),c=typeof o=="function"?this.createBlockingProxy(o,u,s):this.createBlockingObjectProxy(o,u,s,t.allowedKeys);Object.defineProperty(n,i,{value:c,writable:!0,configurable:!0})}}catch(o){let l=this.getPathForTarget(n,i);this.patchFailures.push(l),console.debug(`[DefenseInDepthBox] Could not patch ${l}:`,o instanceof Error?o.message:o)}}restorePatches(){for(let t=this.temporaryIntrinsicDescriptors.length-1;t>=0;t--){let{target:r,prop:n,descriptor:i}=this.temporaryIntrinsicDescriptors[t];try{Object.defineProperty(r,n,i)}catch(s){console.debug(`[DefenseInDepthBox] Could not restore temporary intrinsic ${String(n)}:`,s instanceof Error?s.message:s)}}this.temporaryIntrinsicDescriptors=[];for(let t=this.originalDescriptors.length-1;t>=0;t--){let{target:r,prop:n,descriptor:i}=this.originalDescriptors[t];try{i?Object.defineProperty(r,n,i):delete r[n]}catch(s){let a=this.getPathForTarget(r,n);console.debug(`[DefenseInDepthBox] Could not restore ${a}:`,s instanceof Error?s.message:s)}}this.originalDescriptors=[]}}});function wm(e){return typeof e=="function"?Kt.bindCurrentContext(e):e}function uu(e,t){if(t===1/0)return;let r=wm(e),n={cleared:!1,remainingMs:Math.max(0,t),timer:void 0},i=()=>{if(n.cleared)return;let s=Math.min(n.remainingMs,Em);n.timer=pu(()=>{n.cleared||(n.remainingMs-=s,n.remainingMs>0?i():r())},s)};return i(),n}function cu(e){e&&(e.cleared=!0,e.timer!==void 0&&hu(e.timer))}var pu,hu,Es,oo,Em,Wi=M(()=>{Ar(),pu=globalThis.setTimeout.bind(globalThis),hu=globalThis.clearTimeout.bind(globalThis),globalThis.setInterval.bind(globalThis),globalThis.clearInterval.bind(globalThis),Es=((e,t,...r)=>pu(wm(e),t,...r)),oo=hu,Em=2147483647});function Nc(...e){let t=[...new Set(e.filter(i=>i!==void 0))];if(t.length===0)return{signal:void 0,cleanup(){}};if(t.length===1)return{signal:t[0],cleanup(){}};let r=new AbortController,n=[];for(let i of t){if(i.aborted){r.abort(i.reason);break}let s=()=>r.abort(i.reason);i.addEventListener("abort",s,{once:!0}),n.push([i,s])}return{signal:r.signal,cleanup(){for(let[i,s]of n)i.removeEventListener("abort",s)}}}var $c=M(()=>{});function Oc(e,t,r){if(!Number.isSafeInteger(e)||e<0||!Number.isSafeInteger(t)||t<0||e>t)throw RangeError(`${r}: byte conversion limit exceeded (${t} bytes)`)}function q(e){let t=0;for(let r=0;r=55296&&n<=56319&&r+1=56320&&i<=57343?(t+=4,r++):t+=3}else t+=3}return t}function ke(e,t=lo){let r=e;if(!r)return r;Oc(r.length,t,"UTF-8 decode");let n=!1;for(let s=0;s255)return r;a>127&&(n=!0)}if(!n)return r;let i=new Uint8Array(r.length);for(let s=0;s{Am=new TextDecoder("utf-8",{fatal:!0}),Cm=new TextEncoder,lo=536870912,km=""});function Nm(e){return e instanceof fn||e instanceof dn||e instanceof rn}var Nt,fn,dn,rn,mn,hr,ze,lt,hn,Ps,Tc,C,bt,Ds,cn,H=M(()=>{se(),Nt=class extends Error{stdout;stderr;internalOutputAccounting={stdout:0,stderr:0};constructor(e,t="",r=""){super(e),this.stdout=t,this.stderr=r}prependOutput(e,t){this.stdout=e+this.stdout,this.stderr=t+this.stderr,this.internalOutputAccounting.stdout+=q(e),this.internalOutputAccounting.stderr+=q(t)}},fn=class extends Nt{levels;name="BreakError";constructor(e=1,t="",r=""){super("break",t,r),this.levels=e}},dn=class extends Nt{levels;name="ContinueError";constructor(e=1,t="",r=""){super("continue",t,r),this.levels=e}},rn=class extends Nt{exitCode;name="ReturnError";constructor(e=0,t="",r=""){super("return",t,r),this.exitCode=e}},mn=class extends Nt{exitCode;name="ErrexitError";constructor(e,t="",r=""){super(`errexit: command exited with status ${e}`,t,r),this.exitCode=e}},hr=class extends Nt{varName;name="NounsetError";constructor(e,t=""){super(`${e}: unbound variable`,t,`bash: ${e}: unbound variable `),this.varName=e}},ze=class extends Nt{exitCode;name="ExitError";constructor(e,t="",r=""){super("exit",t,r),this.exitCode=e}},lt=class extends Nt{name="ArithmeticError";fatal;constructor(e,t="",r="",n=!1){super(e,t,r),this.stderr=r||`bash: ${e} `,this.fatal=n}},hn=class extends Nt{name="BadSubstitutionError";constructor(e,t="",r=""){super(e,t,r),this.stderr=r||`bash: ${e}: bad substitution `}},Ps=class extends Nt{name="GlobError";constructor(e,t="",r=""){super(`no match: ${e}`,t,r),this.stderr=r||`bash: no match: ${e} `}},Tc=class extends Nt{name="BraceExpansionError";constructor(e,t="",r=""){super(e,t,r),this.stderr=r||`bash: ${e} `}},C=class extends Nt{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,t,r="",n=""){super(e,r,n),this.limitType=t,this.stderr=n||`bash: ${e} `}},bt=class extends Nt{name="ExecutionAbortedError";constructor(e="",t=""){super("execution aborted",e,t)}},Ds=class extends Nt{name="SubshellExitError";constructor(e="",t=""){super("subshell exit",e,t)}},cn=class extends Nt{exitCode;name="PosixFatalError";constructor(e,t="",r=""){super("posix fatal error",t,r),this.exitCode=e}}});function Ir(e,t,r){let n=r==="width"?Math.abs(e):e;if(!Number.isFinite(e)||!Number.isSafeInteger(e)||n<0||n>t)throw new C(`format ${r} limit exceeded (${t} bytes)`,"string_length")}function uo(e,t,r,n=co){Ir(t,n,"width"),r!==-1&&Ir(r,n,"precision");let i=e;r>=0&&i.length>r&&(i=i.slice(0,r));let s=Math.abs(t);if(s>i.length){if(q(i)+s-i.length>n)throw new C(`formatted value size limit exceeded (${n} bytes)`,"string_length");i=t<0?i.padEnd(s," "):i.padStart(s," ")}if(q(i)>n)throw new C(`formatted value size limit exceeded (${n} bytes)`,"string_length");return i}function a9(e,t,r=co){let n=t,i=0,s=-1,a=!1;for(n0&&(i=-i),Ir(i,r,"width"),s!==-1&&Ir(s,r,"precision"),[i,s,n-t]}function $m(e,t=co){if(q(e)>t)throw new C(`escaped string size limit exceeded (${t} bytes)`,"string_length");let r="",n=0;for(;n0){try{let a=new TextDecoder("utf-8",{fatal:!0});r+=a.decode(new Uint8Array(i))}catch{for(let a of i)r+=String.fromCharCode(a)}n=s}else r+=e[n],n++;break}case"u":{let i="",s=n+2;for(;s{se(),H(),se(),co=10485760}),Om={};re(Om,{echoCommand:()=>Tm,flagsForFuzzing:()=>Im});function o9(e){let t="",r=0;for(;r=e.length){t+="\\";break}let n=e[r+1];switch(n){case"\\":t+="\\",r+=2;break;case"n":t+=` `,r+=2;break;case"t":t+=" ",r+=2;break;case"r":t+="\r",r+=2;break;case"a":t+="\x07",r+=2;break;case"b":t+="\b",r+=2;break;case"f":t+="\f",r+=2;break;case"v":t+="\v",r+=2;break;case"e":case"E":t+="\x1B",r+=2;break;case"c":return{output:t,stop:!0};case"0":{let i="",s=r+2;for(;s{Tm={name:"echo",async execute(e,t){let r=!1,n=t.xpgEcho??!1,i=0;for(;i{H(),Ar()});function ce(e){let t=`${e.name} - ${e.summary} `;if(t+=`Usage: ${e.usage} `,e.description){if(t+=` Description: `,typeof e.description=="string")for(let r of e.description.split(` `))t+=r?` ${r} `:` `;else if(e.description.length>0)for(let r of e.description)t+=r?` ${r} `:` `}if(e.options&&e.options.length>0){t+=` Options: `;for(let r of e.options)t+=` ${r} `}if(e.examples&&e.examples.length>0){t+=` Examples: `;for(let r of e.examples)t+=` ${r} `}if(e.notes&&e.notes.length>0){t+=` Notes: `;for(let r of e.notes)t+=` ${r} `}return{stdout:t,stderr:"",exitCode:0}}function he(e){return e.includes("--help")}function ve(e,t){return{stdout:"",stderr:t.startsWith("--")?`${e}: unrecognized option '${t}' `:`${e}: invalid option -- '${t.replace(/^-/,"")}' `,exitCode:1}}var le=M(()=>{});function At(e,t,r){let n=new Map,i=new Map;for(let[l,u]of Object.entries(r)){let c={name:l,type:u.type};u.short&&n.set(u.short,c),u.long&&i.set(u.long,c)}let s=Object.create(null);for(let[l,u]of Object.entries(r))u.default===void 0?u.type==="boolean"&&(s[l]=!1):s[l]=u.default;let a=[],o=!1;for(let l=0;l=t.length)return{ok:!1,error:{stdout:"",stderr:`${e}: option '--${p}' requires an argument `,exitCode:1}};h=t[++l]}s[d]=m==="number"?parseInt(h,10):h}}else{let c=u.slice(1);for(let p=0;p{le()}),po=M(()=>{});function Rm(e,t,r){if(!Number.isSafeInteger(t)||t<0||t>e.limits.maxInputBytes)throw new C(`${r}: input size limit exceeded (${e.limits.maxInputBytes} bytes)`,"string_length");e.executionScope?.consumeInput(t,r)}async function Pa(e,t,r){let{cmdName:n,allowStdinMarker:i=!0,stopOnError:s=!1,batchSize:a=100}=r;if(t.length===0)return{files:[{filename:"",content:e.stdin}],stderr:"",exitCode:0};let o=[],l="",u=0;for(let c=0;c{if(i&&f==="-")return{filename:"-",content:e.stdin,error:null};try{let d=e.fs.resolvePath(e.cwd,f);return{filename:f,content:await xn(e.fs,d),error:null}}catch{return{filename:f,content:km,error:`${n}: ${f}: No such file or directory `}}}));for(let f of h)if(f.error){if(l+=f.error,u=1,s)return{files:o,stderr:l,exitCode:u}}else o.push({filename:f.filename,content:f.content})}return{files:o,stderr:l,exitCode:u}}async function Ic(e,t,r){let n=await Pa(e,t,{...r,stopOnError:!0});return n.exitCode===0?{ok:!0,content:n.files.map(i=>i.content).join("")}:{ok:!1,error:{stdout:"",stderr:n.stderr,exitCode:n.exitCode}}}var ui=M(()=>{se(),H(),po()}),Pm={};re(Pm,{catCommand:()=>Dm,flagsForFuzzing:()=>Lm});function u9(e){if(e>=32){if(e<127)return String.fromCharCode(e);if(e===127)return"^?";let t=e-128;return t>=32?t===127?"M-^?":`M-${String.fromCharCode(t)}`:`M-^${String.fromCharCode(t+64)}`}return`^${String.fromCharCode(e+64)}`}function c9(e,t,r){if(!t.showNonprinting&&!t.showTabs)return e;let n="",i=s=>{if(s.length>r-n.length)throw new C("cat: output size limit exceeded","output_size");n+=s};for(let s=0;sn)throw new C(`cat: array element limit exceeded (${n})`,"array_elements");let s=e.split(` `),a="",o=1,l=!1,u=c=>{if(c.length>r-a.length)throw new C(`cat: output size limit exceeded (${r} bytes)`,"output_size");a+=c};for(let c=0;c{se(),Lt(),H(),Ct(),ui(),le(),ep={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-A, --show-all equivalent to -vET","-b, --number-nonblank number nonempty output lines, overrides -n","-e equivalent to -vE","-E, --show-ends display $ at end of each line","-n, --number number all output lines","-s, --squeeze-blank suppress repeated empty output lines","-t equivalent to -vT","-T, --show-tabs display TAB characters as ^I","-u (ignored)","-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB"," --help display this help and exit"]},tp={number:{short:"n",long:"number",type:"boolean"},numberNonblank:{short:"b",long:"number-nonblank",type:"boolean"},showEnds:{short:"E",long:"show-ends",type:"boolean"},showTabs:{short:"T",long:"show-tabs",type:"boolean"},showNonprinting:{short:"v",long:"show-nonprinting",type:"boolean"},showAll:{short:"A",long:"show-all",type:"boolean"},squeeze:{short:"s",long:"squeeze-blank",type:"boolean"},vE:{short:"e",type:"boolean"},vT:{short:"t",type:"boolean"},ignored:{short:"u",type:"boolean"}},Dm={name:"cat",async execute(e,t){if(he(e))return ce(ep);let r=At("cat",e,tp);if(!r.ok)return r.error;let n=r.result.flags,i=n.showEnds||n.showAll||n.vE,s=n.showTabs||n.showAll||n.vT,a=n.showNonprinting||n.showAll||n.vE||n.vT,o=n.squeeze,l=n.numberNonblank,u=n.number&&!l,c={numberAll:u,numberNonblank:l,showEnds:i,showTabs:s,showNonprinting:a,squeeze:o},p=r.result.positional,h=t.limits.maxStringLength,f=Math.min(h,t.limits.maxOutputSize),d=p.length===0?["-"]:p,m="",g=0,v=0,y,x=i||s||a||o||u||l,b="";for(let w of d)try{let E=w==="-"?t.stdin:await xn(t.fs,t.fs.resolvePath(t.cwd,w)),A=E.length,O=Math.min(x?h:f,t.limits.maxInputBytes);if(A>O-v)throw new C(`cat: ${x?"input":"output"} size limit exceeded (${O} bytes)`,x?"string_length":"output_size");w!=="-"&&Rm(t,A,"cat"),v+=A,b+=E}catch(E){Ie(E),m+=`cat: ${w}: No such file or directory `,g=1}return y=x?p9(b,c,f,t.limits.maxArrayElements):b,{stdout:y,stderr:m,exitCode:g,stdoutEncoding:"binary"}}},Lm={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0}});function ur(e){return e instanceof Error?e.message:String(e)}var Er=M(()=>{});function Mm(e,t,r,n={}){let i=new Date(t*1e3),s=f9(i,r),a="",o=0,l=0,u=0,c=new Map,p=h=>{let f=q(h);if(n.maxOutputBytes!==void 0&&f>n.maxOutputBytes-o)throw new C(`strftime: output size limit exceeded (${n.maxOutputBytes} bytes)`,"output_size");a+=h,o+=f};for(;ln.maxOperations)throw new C(`strftime: iteration limit exceeded (${n.maxOperations})`,"iterations");if(e[l]==="%"&&l+1n.find(u=>u.type===l)?.value??"",s=new Map([["Sun",0],["Mon",1],["Tue",2],["Wed",3],["Thu",4],["Fri",5],["Sat",6]]),a=i("weekday"),o=(l,u)=>{let c=Number.parseInt(l,10);return Number.isNaN(c)?u:c};return{year:o(i("year"),e.getFullYear()),month:o(i("month"),e.getMonth()+1),day:o(i("day"),e.getDate()),hour:o(i("hour"),e.getHours())%24,minute:o(i("minute"),e.getMinutes()),second:o(i("second"),e.getSeconds()),weekday:s.get(a)??e.getDay()}}catch{return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),weekday:e.getDay()}}}function d9(e,t,r,n){let i=(l,u=2)=>String(l).padStart(u,"0"),s=Fm(t.year,t.month,t.day),a=rp(t.year,t.month,t.day,t.weekday,0),o=rp(t.year,t.month,t.day,t.weekday,1);switch(r){case"a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.weekday];case"A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.weekday];case"b":case"h":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.month-1];case"B":return["January","February","March","April","May","June","July","August","September","October","November","December"][t.month-1];case"c":return`${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.weekday]} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.month-1]} ${String(t.day).padStart(2," ")} ${i(t.hour)}:${i(t.minute)}:${i(t.second)} ${t.year}`;case"C":return i(Math.floor(t.year/100));case"d":return i(t.day);case"D":return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case"e":return String(t.day).padStart(2," ");case"F":return`${t.year}-${i(t.month)}-${i(t.day)}`;case"g":return i(np(t.year,t.month,t.day)%100);case"G":return String(np(t.year,t.month,t.day));case"H":return i(t.hour);case"I":return i(t.hour%12||12);case"j":return String(s).padStart(3,"0");case"k":return String(t.hour).padStart(2," ");case"l":return String(t.hour%12||12).padStart(2," ");case"m":return i(t.month);case"M":return i(t.minute);case"n":return` `;case"N":return"000000000";case"p":return t.hour<12?"AM":"PM";case"P":return t.hour<12?"am":"pm";case"r":return`${i(t.hour%12||12)}:${i(t.minute)}:${i(t.second)} ${t.hour<12?"AM":"PM"}`;case"R":return`${i(t.hour)}:${i(t.minute)}`;case"s":return String(Math.floor(e.getTime()/1e3));case"S":return i(t.second);case"t":return" ";case"T":return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case"u":return String(t.weekday===0?7:t.weekday);case"U":return i(a);case"V":return i(y9(t.year,t.month,t.day));case"w":return String(t.weekday);case"W":return i(o);case"x":return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case"X":return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case"y":return i(t.year%100);case"Y":return String(t.year);case"z":return m9(e,n);case"Z":return g9(e,n);case"%":return"%";default:return null}}function m9(e,t){if(!t){let a=-e.getTimezoneOffset(),o=a>=0?"+":"-",l=Math.floor(Math.abs(a)/60),u=Math.abs(a)%60;return`${o}${String(l).padStart(2,"0")}${String(u).padStart(2,"0")}`}try{let a=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).formatToParts(e).find(o=>o.type==="timeZoneName");if(a){let o=a.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(o)return`${o[1]}${o[2]}${o[3]}`;if(a.value==="GMT"||a.value==="UTC")return"+0000"}}catch{}let r=-e.getTimezoneOffset(),n=r>=0?"+":"-",i=Math.floor(Math.abs(r)/60),s=Math.abs(r)%60;return`${n}${String(i).padStart(2,"0")}${String(s).padStart(2,"0")}`}function g9(e,t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(r=>r.type==="timeZoneName")?.value??"UTC"}catch{return"UTC"}}function Fm(e,t,r){let n=[31,28,31,30,31,30,31,31,30,31,30,31];(e%4==0&&e%100!=0||e%400==0)&&(n[1]=29);let i=r;for(let s=0;s{H(),wt()}),zm={};re(zm,{flagsForFuzzing:()=>Um,printfCommand:()=>Bm});function x9(e){let t="",r=0;for(;r=194){let i=(n&31)<<6|e[r+1]&63;t+=String.fromCharCode(i),r+=2;continue}t+=String.fromCharCode(n),r++;continue}if((n&240)==224){if(r+2=55296&&i<=57343){t+=String.fromCharCode(n),r++;continue}t+=String.fromCharCode(i),r+=3;continue}t+=String.fromCharCode(n),r++;continue}if((n&248)==240&&n<=244){if(r+31114111){t+=String.fromCharCode(n),r++;continue}t+=String.fromCodePoint(i),r+=4;continue}t+=String.fromCharCode(n),r++;continue}t+=String.fromCharCode(n),r++}return t}function v9(e,t,r,n,i=10485760){let s="",a=0,o=0,l=!1,u="",c=0,p=h=>{let f=q(h);if(f>i-c)throw new C(`printf: output size limit exceeded (${i} bytes)`,"string_length");s+=h,c+=f};for(;a=0?Ir(A,i-c,"precision"):Number.isSafeInteger(A)||Ir(A,i-c,"precision"),o++,v=v.replace(".*",`.${A}`)}w9(v,i-c);let y=t[r+o]||"";o++;let{value:x,parseError:b,parseErrMsg:w,stopped:E}=b9(v,g,y,i-c);if(p(x),b&&(l=!0,w&&(u=w)),E)return{result:s,argsConsumed:o,error:l,errMsg:u,stopped:!0}}else p(e[a]),a++;return{result:s,argsConsumed:o,error:l,errMsg:u,stopped:!1}}function b9(e,t,r,n){let i=!1,s="";switch(t){case"d":case"i":{let a=Hs(r);return i=gr,i&&(s=`printf: ${r}: invalid number `),{value:ip(e,a),parseError:i,parseErrMsg:s}}case"o":{let a=Hs(r);return i=gr,i&&(s=`printf: ${r}: invalid number `),{value:E9(e,a),parseError:i,parseErrMsg:s}}case"u":{let a=Hs(r);i=gr,i&&(s=`printf: ${r}: invalid number `);let o=a<0?a>>>0:a;return{value:ip(e.replace("u","d"),o),parseError:i,parseErrMsg:s}}case"x":case"X":{let a=Hs(r);return i=gr,i&&(s=`printf: ${r}: invalid number `),{value:S9(e,a),parseError:i,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":return{value:N9(e,t,parseFloat(r)||0),parseError:!1,parseErrMsg:""};case"c":{if(r==="")return{value:"",parseError:!1,parseErrMsg:""};let a=new TextEncoder().encode(r)[0];return{value:String.fromCharCode(a),parseError:!1,parseErrMsg:""}}case"s":return{value:C9(e,r,n),parseError:!1,parseErrMsg:""};case"q":return{value:k9(e,r,n),parseError:!1,parseErrMsg:""};case"b":{let a=$9(r,n);return{value:a.value,parseError:!1,parseErrMsg:"",stopped:a.stopped}}default:try{return{value:(0,Ui.sprintf)(e,r),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder `}}}}function w9(e,t){let r=e.match(/^%[-+0 #' ]*(\d*)(?:\.(\d*))?/);if(!r)return;let n=r[1]?Number(r[1]):0,i=r[2]===void 0?-1:Number(r[2]);Ir(n,t,"width"),i!==-1&&Ir(i,t,"precision")}function Hs(e){gr=!1;let t=e.trimStart(),r=t!==t.trimEnd();if(e=t.trimEnd(),e.startsWith("'")&&e.length>=2||e.startsWith('"')&&e.length>=2)return e.charCodeAt(1);if(e.startsWith("\\'")&&e.length>=3||e.startsWith('\\"')&&e.length>=3)return e.charCodeAt(2);if(e.startsWith("+")&&(e=e.slice(1)),e.startsWith("0x")||e.startsWith("0X")){let n=parseInt(e,16);return Number.isNaN(n)?(gr=!0,0):(r&&(gr=!0),n)}if(e.startsWith("0")&&e.length>1&&/^-?0[0-7]+$/.test(e))return r&&(gr=!0),parseInt(e,8)||0;if(/^\d+#/.test(e)){gr=!0;let n=e.match(/^(\d+)#/);return n?parseInt(n[1],10):0}if(e!==""&&!/^-?\d+$/.test(e)){gr=!0;let n=parseInt(e,10);return Number.isNaN(n)?0:n}return r&&(gr=!0),parseInt(e,10)||0}function ip(e,t){let r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!r)return(0,Ui.sprintf)(e.replace(/\.\d*/,""),t);let n=r[1]||"",i=r[2]?parseInt(r[2],10):0,s=r[3]===void 0?-1:r[4]?parseInt(r[4],10):0,a=t<0,o=String(Math.abs(t));s>=0&&(o=o.padStart(s,"0"));let l="";a?l="-":n.includes("+")?l="+":n.includes(" ")&&(l=" ");let u=l+o;return i>u.length&&(u=n.includes("-")?u.padEnd(i," "):n.includes("0")&&s<0?l+o.padStart(i-l.length,"0"):u.padStart(i," ")),u}function E9(e,t){let r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!r)return(0,Ui.sprintf)(e,t);let n=r[1]||"",i=r[2]?parseInt(r[2],10):0,s=r[3]===void 0?-1:r[4]?parseInt(r[4],10):0,a=Math.abs(t).toString(8);s>=0&&(a=a.padStart(s,"0")),n.includes("#")&&!a.startsWith("0")&&(a=`0${a}`);let o=a;return i>o.length&&(o=n.includes("-")?o.padEnd(i," "):n.includes("0")&&s<0?o.padStart(i,"0"):o.padStart(i," ")),o}function S9(e,t){let r=e.includes("X"),n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!n)return(0,Ui.sprintf)(e,t);let i=n[1]||"",s=n[2]?parseInt(n[2],10):0,a=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0,o=Math.abs(t).toString(16);r&&(o=o.toUpperCase()),a>=0&&(o=o.padStart(a,"0"));let l="";i.includes("#")&&t!==0&&(l=r?"0X":"0x");let u=l+o;return s>u.length&&(u=i.includes("-")?u.padEnd(s," "):i.includes("0")&&a<0?l+o.padStart(s-l.length,"0"):u.padStart(s," ")),u}function A9(e,t){if(e===""){if(t<2)throw new C(`printf: output size limit exceeded (${t} bytes)`,"string_length");return"''"}if(/^[a-zA-Z0-9_./-]+$/.test(e)){if(q(e)>t)throw new C(`printf: output size limit exceeded (${t} bytes)`,"string_length");return e}let r=/[\x00-\x1f\x7f-\xff]/.test(e),n=r?3:0;for(let s of e){let a=s.charCodeAt(0);if(n+=r?s==="'"||s==="\\"||s===` `||s===" "||s==="\r"||s==="\x07"||s==="\b"||s==="\f"||s==="\v"||s==="\x1B"||s==='"'?2:a<32||a>=127&&a<=255?4:q(s):q(s)+ +!!" |&;<>()$`\\\"'*?[#~=%!{}".includes(s),n>t)throw new C(`printf: output size limit exceeded (${t} bytes)`,"string_length")}if(r){let s="$'";for(let a of e){let o=a.charCodeAt(0);s+=a==="'"?"\\'":a==="\\"?"\\\\":a===` `?"\\n":a===" "?"\\t":a==="\r"?"\\r":a==="\x07"?"\\a":a==="\b"?"\\b":a==="\f"?"\\f":a==="\v"?"\\v":a==="\x1B"?"\\E":o<32||o>=127&&o<=255?`\\${o.toString(8).padStart(3,"0")}`:a==='"'?'\\"':a}return s+="'",s}let i="";for(let s of e)" |&;<>()$`\\\"'*?[#~=%!{}".includes(s)?i+=`\\${s}`:i+=s;return i}function C9(e,t,r){let n=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!n)return(0,Ui.sprintf)(e.replace(/0+(?=\d)/,""),t);let i=n[1]==="-",s=n[2]?parseInt(n[2],10):0,a=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0;return uo(t,i?-s:s,a,r)}function k9(e,t,r){let n=A9(t,r),i=e.match(/^%(-?)(\d*)q$/);if(!i)return n;let s=i[1]==="-",a=i[2]?parseInt(i[2],10):0;return uo(n,s?-a:a,-1,r)}function N9(e,t,r){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!n)return(0,Ui.sprintf)(e,r);let i=n[1]||"",s=n[2]?parseInt(n[2],10):0,a=n[3]===void 0?6:n[4]?parseInt(n[4],10):0,o,l=t.toLowerCase();if(l==="e"?(o=r.toExponential(a),o=o.replace(/e([+-])(\d)$/,"e$10$2"),t==="E"&&(o=o.toUpperCase())):l==="f"?(o=r.toFixed(a),i.includes("#")&&a===0&&!o.includes(".")&&(o+=".")):l==="g"?(o=r.toPrecision(a||1),i.includes("#")||(o=o.replace(/\.?0+$/,""),o=o.replace(/\.?0+e/,"e")),o=o.replace(/e([+-])(\d)$/,"e$10$2"),t==="G"&&(o=o.toUpperCase())):o=r.toString(),r>=0&&(i.includes("+")?o=`+${o}`:i.includes(" ")&&(o=` ${o}`)),s>o.length)if(i.includes("-"))o=o.padEnd(s," ");else if(i.includes("0")){let u=o.match(/^[+ -]/)?.[0]||"";o=u+(u?o.slice(1):o).padStart(s-u.length,"0")}else o=o.padStart(s," ");return o}function $9(e,t){if(q(e)>t)throw new C(`printf: output size limit exceeded (${t} bytes)`,"string_length");let r="",n=0;for(;n0?(r+=x9(i),n=s):(r+="\\x",n+=2);break}case"u":{let i="",s=n+2;for(;s{H(),Er(),le(),wt(),_m(),sp={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},Bm={name:"printf",async execute(e,t){if(he(e))return ce(sp);if(e.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments] `,exitCode:2,internalStdinConsumed:0};let r=null,n=0;for(;n=e.length)return{stdout:"",stderr:`printf: -v: option requires an argument `,exitCode:1,internalStdinConsumed:0};if(r=e[n+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]\n]+\])?$/.test(r)||/[;\r\\]/.test(r)||r.includes(".."))return{stdout:"",stderr:`printf: \`${r}': not a valid identifier `,exitCode:2,internalStdinConsumed:0};n+=2}else{if(a.startsWith("-")&&a!=="-")break;break}}if(n>=e.length)return{stdout:"",stderr:`printf: usage: printf format [arguments] `,exitCode:1,internalStdinConsumed:0};let i=e[n],s=e.slice(n+1);try{let a=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),o=$m(i,a),l="",u=0,c=0,p=!1,h="",f=t.env.get("TZ");do{let{result:d,argsConsumed:m,error:g,errMsg:v,stopped:y}=v9(o,s,c,f,a-u),x=q(d);if(x>a-u)throw new C(`printf: output size limit exceeded (${a} bytes)`,"string_length");if(l+=d,u+=x,c+=m,g&&(p=!0,v&&(h=v)),y)break}while(c0);if(c===0&&s.length,r){let d=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(d){let m=d[1],g=d[3];if(g=g.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(v,y)=>t.env.get(y)??""),t.assignShellVariable)await t.assignShellVariable(m,l,g);else throw Error("printf -v array assignment requires an interpreter assignment gateway")}else if(t.assignShellVariable)await t.assignShellVariable(r,l);else{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))throw Error(`${r}: not a valid identifier`);t.env.set(r,l)}return{stdout:"",stderr:h,exitCode:+!!p,internalStdinConsumed:0}}return{stdout:l,stderr:h,exitCode:+!!p,internalStdinConsumed:0}}catch(a){if(a instanceof C||typeof a=="object"&&a&&"name"in a&&a.name==="ExitError")throw a;return{stdout:"",stderr:`printf: ${ur(a)} `,exitCode:1,internalStdinConsumed:0}}}},gr=!1,Um={name:"printf",flags:[{flag:"-v",type:"value",valueHint:"string"}],stdinType:"none",needsArgs:!0}});function kn(e,t){if(!Number.isSafeInteger(e)||e<0)throw new C(`${t}: invalid bounded allocation count`,"array_elements")}function Wm(e){return new C(`${e}: invalid bounded allocation count`,"array_elements")}function ci(e,t,r){kn(e,r),kn(t,r);let n=e+t;if(!Number.isSafeInteger(n))throw Wm(r);return n}function T9(e,t,r){if(kn(e,r),kn(t,r),e!==0&&t>Math.floor((2**53-1)/e))throw Wm(r);return e*t}function Pi(e,t,r,n){let i=new st(r,n);for(let s=0;s0&&i.append(t),i.append(e[s]);return i.build()}var st,Et=M(()=>{se(),H(),st=class{maxBytes;label;createLimitError;reservedBytes;chunks=[];usedBytes=0;constructor(e,t,r=void 0,n=0){this.maxBytes=e,this.label=t,this.createLimitError=r,this.reservedBytes=n,kn(e,t),kn(n,t),n>e&&this.fail()}fail(){throw this.createLimitError?.()??new C(`${this.label}: output size limit exceeded (${this.maxBytes} bytes)`,"output_size")}get byteLength(){return this.usedBytes}get remainingBytes(){return this.maxBytes-this.reservedBytes-this.usedBytes}reserve(e){kn(e,this.label),e>this.remainingBytes&&this.fail()}append(e){let t=q(e);return this.reserve(t),e&&this.chunks.push(e),this.usedBytes+=t,this}repeat(e,t){kn(t,this.label);let r=q(e);return r!==0&&t>Math.floor(this.remainingBytes/r)&&this.fail(),this.append(e.repeat(t))}reset(){this.chunks.length=0,this.usedBytes=0}build(){return this.chunks.join("")}}});function we(e){if(!e||e==="/")return"/";let t=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;t.startsWith("/")||(t=`/${t}`);let r=t.split("/").filter(i=>i&&i!=="."),n=[];for(let i of r)i===".."?n.pop():n.push(i);return`/${n.join("/")}`||"/"}function ri(e,t){let r=we(e),n=we(t);return n===r||r==="/"||n.startsWith(`${r}/`)}function gt(e,t){if(e.includes("\0"))throw Error(`ENOENT: path contains null byte, ${t} '${e}'`)}function Da(e){let t=we(e);if(t==="/")return"/";let r=t.lastIndexOf("/");return r===0?"/":t.slice(0,r)}function jm(e,t){return t.startsWith("/")?we(t):we(e==="/"?`/${t}`:`${e}/${t}`)}function Vr(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function jo(e,t){return t.startsWith("/")?we(t):we(Vr(Da(e),t))}var Ls=M(()=>{});function I9(e,t,r){if(!e)return e;let n=e.replace(/\n\s+at\s.*/g,"");return r&&(n=n.replace(/\bfile:\/\/\/?[^\s'",)}\]:]+/g,"")),n=n.replace(t?/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap|workspace|root|srv|mnt|app))\b[^\s'",)}\]:]*/g:/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap))\b[^\s'",)}\]:]*/g,""),n=n.replace(/node:internal\/[^\s'",)}\]:]+/g,""),n=n.replace(/[A-Z]:\\[^\s'",)}\]:]+/g,""),r&&(n=n.replace(/\\\\[^\s\\]+\\[^\s'",)}\]:]+/g,"")),n}function xt(e){return I9(e,!1,!1)}var Mr=M(()=>{});function qm(e){if(e.identity!==void 0)return`identity:${e.identity}`;if(e.dev!==void 0&&e.ino!==void 0)return`inode:${String(e.dev)}:${String(e.ino)}`}function ap(e){let t=e instanceof Error?e.message:String(e);return t.includes("ENOENT")||t.includes("no such file")}async function Zr(e,t,r){let n=we(t),i;try{i=await e.stat(n)}catch(o){if(!ap(o))return{existence:"unknown"}}if(i!==void 0){let o=qm(i);try{return{existence:"existing",canonicalPath:we(await e.realpath(n)),stableIdentity:o}}catch{return o===void 0?{existence:"unknown"}:{existence:"existing",stableIdentity:o}}}let s=[],a=n;for(;;){r?.checkpoint();let o=Da(a);if(o===a)return{existence:"unknown"};s.unshift(a.slice(o==="/"?1:o.length+1)),a=o;try{let l=we(await e.realpath(a));return{existence:"missing",canonicalPath:s.reduce((u,c)=>Vr(u,c),l)}}catch(l){if(!ap(l))return{existence:"missing"}}}}async function Gm(e,t,r){let[n,i]=await Promise.all([Zr(e,t),Zr(e,r)]);return n.existence==="unknown"||i.existence==="unknown"?"unknown":n.existence==="missing"||i.existence==="missing"?n.existence===i.existence?n.canonicalPath!==void 0&&n.canonicalPath===i.canonicalPath?"same":"unknown":"different":n.stableIdentity!==void 0&&i.stableIdentity!==void 0?n.stableIdentity===i.stableIdentity?"same":"different":n.canonicalPath!==void 0&&n.canonicalPath===i.canonicalPath?"same":"unknown"}async function Hm(e,t,r,n){let[i,s]=await Promise.all([Zr(e,t,n),Zr(e,r,n)]);return i.existence!=="existing"||i.canonicalPath===void 0||s.existence==="unknown"||s.canonicalPath===void 0?"unknown":ri(i.canonicalPath,s.canonicalPath)?"inside":"outside"}async function Ms(e,t){let r=e.budget??new Fr(e),n=[{kind:"enter",path:we(e.root),depth:0}],i=new Set;for(;n.length>0;){r.checkpoint(0);let s=n.pop();if(!s)break;if(s.kind==="leave"){e.includeLeave&&await t({path:s.path,depth:s.depth,stat:s.stat,isSymlink:s.isSymlink,phase:"leave"}),s.identity&&i.delete(s.identity);continue}r.visit(s.depth);let a=await e.fs.lstat(s.path),o=a.isSymbolicLink,l=o&&e.symlinks==="follow"?await e.fs.stat(s.path):a;if(await t({path:s.path,depth:s.depth,stat:l,isSymlink:o,phase:"enter"}),!l.isDirectory||o&&e.symlinks!=="follow")continue;let u=qm(l)??await e.fs.realpath(s.path).then(we).catch(()=>{});if(u!==void 0){if(i.has(u))throw new Vm(e.site,s.path,"symbolic-link directory cycle detected");i.add(u)}n.push({kind:"leave",path:s.path,depth:s.depth,stat:l,isSymlink:o,identity:u});let c=await e.fs.readdir(s.path);r.checkpoint(),c.sort((p,h)=>p.localeCompare(h));for(let p=c.length-1;p>=0;p--)n.push({kind:"enter",path:Vr(s.path,c[p]),depth:s.depth+1})}}var Vm,Fr,_r=M(()=>{H(),Ls(),Mr(),Vm=class extends Error{operation;virtualPath;name="FileSystemPolicyError";constructor(e,t,r){super(`${e}: ${xt(r)}`),this.operation=e,this.virtualPath=t}},Fr=class{options;entries=0;discoveredEntries=1;work=0;constructor(e){this.options=e}checkpoint(e=1){if(this.options.signal?.aborted)throw new bt;if(this.options.executionScope?.throwIfAborted(this.options.site),!Number.isSafeInteger(e)||e<0||e>this.options.limits.maxTraversalWork-this.work)throw new C(`${this.options.site}: ${this.options.label??"filesystem traversal work"} limit exceeded (${this.options.limits.maxTraversalWork})`,"iterations");this.work+=e,this.options.executionScope?.consumeWork(e,`${this.options.site} filesystem traversal`)}visit(e){if(this.checkpoint(),e>this.options.limits.maxTraversalDepth)throw new C(`${this.options.site}: ${this.options.label??"filesystem traversal"} depth limit exceeded (${this.options.limits.maxTraversalDepth})`,"recursion");if(++this.entries>this.options.limits.maxTraversalEntries)throw new C(`${this.options.site}: ${this.options.label??"filesystem traversal"} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,"iterations")}discover(e){if(!Number.isSafeInteger(e)||e<0||e>this.options.limits.maxTraversalEntries-this.discoveredEntries)throw new C(`${this.options.site}: ${this.options.label??"filesystem traversal"} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,"iterations");this.checkpoint(e),this.discoveredEntries+=e}}}),Zm={};re(Zm,{flagsForFuzzing:()=>Xm,lsCommand:()=>Km});function It(e,t,r){if(q(r)>e.limits.maxOutputSize-q(t))throw new C(`ls: output size limit exceeded (${e.limits.maxOutputSize} bytes)`,"output_size");return t+r}function ms(e,t){let r=new st(e.limits.maxOutputSize,"ls");for(let n=0;n0&&r.append(` `),r.append(t[n]);return t.length>0&&r.append(` `),r.build()}function La(e){if(e<1024)return String(e);if(e<1048576){let r=e/1024;return r<10?`${r.toFixed(1)}K`:`${Math.round(r)}K`}if(e<1073741824){let r=e/1048576;return r<10?`${r.toFixed(1)}M`:`${Math.round(r)}M`}let t=e/1073741824;return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function Ma(e){let t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],r=String(e.getDate()).padStart(2," ");return e>new Date(new Date().getTime()-15552e6)?`${t} ${r} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`:`${t} ${r} ${e.getFullYear()}`}function Jn(e){return e.isDirectory?"/":e.isSymbolicLink?"@":e.mode&73?"*":""}async function R9(e,t,r,n,i,s=!1,a=!1,o=!1,l=!1,u){let c=r||n,p=t.fs.getAllPaths(),h=t.fs.resolvePath(t.cwd,"."),f=[];for(let d of p){u?.visit(d.split("/").length-1);let m=(d===h||h==="/"||d.startsWith(`${h}/`))&&d.slice(h==="/"?1:h.length+1)||d;if(Pt(m,e)||Pt(d,e)){let g=m.split("/").pop()||m;if(!c&&g.startsWith("."))continue;f.push(m||d)}}if(f.length===0)return{stdout:"",stderr:`ls: ${e}: No such file or directory `,exitCode:2};if(o){let d=[];for(let m of f){let g=t.fs.resolvePath(t.cwd,m);try{let v=await t.fs.stat(g);d.push({path:m,size:v.size??0})}catch{d.push({path:m,size:0})}}d.sort((m,g)=>g.size-m.size),f.length=0,f.push(...d.map(m=>m.path))}else f.sort();if(s&&f.reverse(),i){let d=[];for(let m of f){let g=t.fs.resolvePath(t.cwd,m);try{let v=await t.fs.stat(g),y=v.isDirectory?"drwxr-xr-x":"-rw-r--r--",x=l?Jn(await t.fs.lstat(g)):v.isDirectory?"/":"",b=v.size??0,w=a?La(b).padStart(5):String(b).padStart(5),E=Ma(v.mtime??new Date(0));d.push(`${y} 1 user user ${w} ${E} ${m}${x}`)}catch{d.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${m}`)}}return{stdout:ms(t,d),stderr:"",exitCode:0}}if(l){let d=[];for(let m of f){let g=t.fs.resolvePath(t.cwd,m);try{let v=await t.fs.lstat(g);d.push(`${m}${Jn(v)}`)}catch{d.push(m)}}return{stdout:ms(t,d),stderr:"",exitCode:0}}return{stdout:ms(t,f),stderr:"",exitCode:0}}async function Qm(e,t,r,n,i,s,a,o=!1,l=!1,u=!1,c=!1,p=!1,h=new Fr({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"}),f=0,d=new Set){let m=r||n,g=t.fs.resolvePath(t.cwd,e);try{h.visit(f);let v=await t.fs.stat(g);if(!v.isDirectory){let O=c?Jn(await t.fs.lstat(g)):"";if(i){let N=v.size??0;return{stdout:`-rw-r--r-- 1 user user ${l?La(N).padStart(5):String(N).padStart(5)} ${Ma(v.mtime??new Date(0))} ${e}${O} `,stderr:"",exitCode:0}}return{stdout:`${e}${O} `,stderr:"",exitCode:0}}let y=v.identity??(v.dev!==void 0&&v.ino!==void 0?`${String(v.dev)}:${String(v.ino)}`:await t.fs.realpath(g).catch(()=>{}));if(y!==void 0&&d.has(y))return{stdout:"",stderr:`ls: ${e}: symbolic link cycle detected `,exitCode:2};let x=new Set(d);y!==void 0&&x.add(y);let b=await t.fs.readdir(g);if(h.checkpoint(),m||(b=b.filter(O=>!O.startsWith("."))),u){let O=[];for(let N of b){let D=g==="/"?`/${N}`:`${g}/${N}`;try{let $=await t.fs.stat(D);O.push({name:N,size:$.size??0})}catch{O.push({name:N,size:0})}}O.sort((N,D)=>D.size-N.size),b=O.map(N=>N.name)}else b.sort();r&&(b=[".","..",...b]),o&&b.reverse();let w="",E="",A=0;if((s||a)&&(w=It(t,w,`${e}: `)),i){w=It(t,w,`total ${b.length} `);let O=b.filter(L=>L==="."||L===".."),N=b.filter(L=>L!=="."&&L!=="..");for(let L of O)w=It(t,w,`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${L} `);let D=[];for(let L=0;L{let j=g==="/"?`/${B}`:`${g}/${B}`;try{let P=await t.fs.stat(j),F=P.isDirectory?"drwxr-xr-x":"-rw-r--r--",G=c?Jn(await t.fs.lstat(j)):P.isDirectory?"/":"",z=P.size??0;return{name:B,line:`${F} 1 user user ${l?La(z).padStart(5):String(z).padStart(5)} ${Ma(P.mtime??new Date(0))} ${B}${G} `}}catch{return{name:B,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${B} `}}}));D.push(...R)}let $=new Map(N.map((L,_)=>[L,_]));D.sort((L,_)=>($.get(L.name)??0)-($.get(_.name)??0));for(let{line:L}of D)w=It(t,w,L)}else if(c){let O=[],N=b.filter($=>$!=="."&&$!==".."),D=b.filter($=>$==="."||$==="..");for(let $ of D)O.push(`${$}/`);for(let $=0;${let B=g==="/"?`/${R}`:`${g}/${R}`;try{return`${R}${Jn(await t.fs.lstat(B))}`}catch{return R}}));O.push(..._)}w=It(t,w,ms(t,O))}else w=It(t,w,ms(t,b));if(s){let O=b.filter($=>$!=="."&&$!==".."),N=[];if(t.fs.readdirWithFileTypes)N=(await t.fs.readdirWithFileTypes(g)).filter($=>$.isDirectory&&O.includes($.name)).map($=>({name:$.name,isDirectory:!0}));else for(let $=0;${let B=g==="/"?`/${R}`:`${g}/${R}`;try{return{name:R,isDirectory:(await t.fs.stat(B)).isDirectory}}catch{return{name:R,isDirectory:!1}}}));N.push(..._.filter(R=>R.isDirectory))}N.sort(($,L)=>$.name.localeCompare(L.name)),o&&N.reverse();let D=[];for(let $=0;${let B=await Qm(e==="."?`./${R.name}`:`${e}/${R.name}`,t,r,n,i,s,!1,o,l,u,c,!0,h,f+1,x);return{name:R.name,result:B}}));D.push(..._)}D.sort(($,L)=>$.name.localeCompare(L.name)),o&&D.reverse();for(let{result:$}of D)w=It(t,w,` `),w=It(t,w,$.stdout),E=It(t,E,$.stderr),$.exitCode!==0&&(A=$.exitCode)}return{stdout:w,stderr:E,exitCode:A}}catch(v){if(v instanceof C||v instanceof bt)throw v;return{stdout:"",stderr:`ls: ${e}: No such file or directory `,exitCode:2}}}var op,lp,Km,Xm,P9=M(()=>{Et(),se(),_r(),H(),Ct(),po(),le(),op={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-F, --classify append indicator (one of */=>@) to entries","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},lp={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},classifyFiles:{short:"F",long:"classify",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},Km={name:"ls",async execute(e,t){if(he(e))return ce(op);let r=At("ls",e,lp);if(!r.ok)return r.error;let n=r.result.flags.showAll,i=r.result.flags.showAlmostAll,s=r.result.flags.longFormat,a=r.result.flags.humanReadable,o=r.result.flags.recursive,l=r.result.flags.reverse,u=r.result.flags.sortBySize,c=r.result.flags.classifyFiles,p=r.result.flags.directoryOnly;r.result.flags.sortByTime,r.result.flags.onePerLine;let h=r.result.positional;h.length===0&&h.push(".");let f="",d="",m=0,g=new Fr({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"ls"});for(let v=0;v0&&f&&!f.endsWith(` `)&&(f=It(t,f,` `)),p){let x=t.fs.resolvePath(t.cwd,y);try{let b=await t.fs.stat(x);if(s){let w=b.isDirectory?"drwxr-xr-x":"-rw-r--r--",E=c?Jn(await t.fs.lstat(x)):b.isDirectory?"/":"",A=b.size??0,O=a?La(A).padStart(5):String(A).padStart(5),N=Ma(b.mtime??new Date(0));f=It(t,f,`${w} 1 user user ${O} ${N} ${y}${E} `)}else{let w=c?Jn(await t.fs.lstat(x)):"";f=It(t,f,`${y}${w} `)}}catch{d=It(t,d,`ls: cannot access '${y}': No such file or directory `),m=2}continue}if(y.includes("*")||y.includes("?")||y.includes("[")){let x=await R9(y,t,n,i,s,l,a,u,c,g);f=It(t,f,x.stdout),d=It(t,d,x.stderr),x.exitCode!==0&&(m=x.exitCode)}else{let x=await Qm(y,t,n,i,s,o,h.length>1,l,a,u,c,!1,g,0,new Set);f=It(t,f,x.stdout),d=It(t,d,x.stderr),x.exitCode!==0&&(m=x.exitCode)}}return{stdout:f,stderr:d,exitCode:m}}},Xm={name:"ls",flags:[{flag:"-a",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-1",type:"boolean"}],needsFiles:!0}}),Ym={};re(Ym,{flagsForFuzzing:()=>eg,mkdirCommand:()=>Jm});var up,Jm,eg,D9=M(()=>{Mr(),Er(),Ct(),up={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Jm={name:"mkdir",async execute(e,t){let r=At("mkdir",e,up);if(!r.ok)return r.error;let n=r.result.flags.recursive,i=r.result.flags.verbose,s=r.result.positional;if(s.length===0)return{stdout:"",stderr:`mkdir: missing operand `,exitCode:1};let a="",o="",l=0;for(let u of s)try{let c=t.fs.resolvePath(t.cwd,u);await t.fs.mkdir(c,{recursive:n}),i&&(a+=`mkdir: created directory '${u}' `)}catch(c){let p=ur(c);p.includes("ENOENT")||p.includes("no such file")?o+=`mkdir: cannot create directory '${u}': No such file or directory `:p.includes("EEXIST")||p.includes("already exists")?o+=`mkdir: cannot create directory '${u}': File exists `:o+=`mkdir: cannot create directory '${u}': ${xt(p)} `,l=1}return{stdout:a,stderr:o,exitCode:l}}},eg={name:"mkdir",flags:[{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0}}),tg={};re(tg,{flagsForFuzzing:()=>ng,rmdirCommand:()=>rg});async function L9(e,t,r,n,i){let s="",a="",o=e.fs.resolvePath(e.cwd,t),l=await cp(e,o,t,n);if(s+=l.stdout,a+=l.stderr,l.exitCode!==0)return{stdout:s,stderr:a,exitCode:l.exitCode};if(r){let u=o,c=t;for(;;){i.visit(0);let p=pp(u),h=pp(c);if(p===u||p==="/"||p==="."||h==="."||h==="")break;let f=await cp(e,p,h,n);if(s+=f.stdout,f.exitCode!==0)break;u=p,c=h}}return{stdout:s,stderr:a,exitCode:0}}async function cp(e,t,r,n){try{if(!await e.fs.exists(t))return{stdout:"",stderr:`rmdir: failed to remove '${r}': No such file or directory `,exitCode:1};if(!(await e.fs.stat(t)).isDirectory)return{stdout:"",stderr:`rmdir: failed to remove '${r}': Not a directory `,exitCode:1};if((await e.fs.readdir(t)).length>0)return{stdout:"",stderr:`rmdir: failed to remove '${r}': Directory not empty `,exitCode:1};await e.fs.rm(t,{recursive:!1,force:!1});let i="";return n&&(i=`rmdir: removing directory, '${r}' `),{stdout:i,stderr:"",exitCode:0}}catch(i){return{stdout:"",stderr:`rmdir: failed to remove '${r}': ${ur(i)} `,exitCode:1}}}function pp(e){let t=e.replace(/\/+$/,""),r=t.lastIndexOf("/");return r===-1?".":r===0?"/":t.substring(0,r)}var hp,fp,rg,ng,M9=M(()=>{_r(),Er(),Ct(),hp=`Usage: rmdir [-pv] DIRECTORY... Remove empty directories. Options: -p, --parents Remove DIRECTORY and its ancestors -v, --verbose Output a diagnostic for every directory processed`,fp={parents:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},help:{long:"help",type:"boolean"}},rg={name:"rmdir",async execute(e,t){let r=At("rmdir",e,fp);if(!r.ok)return r.error;if(r.result.flags.help)return{stdout:`${hp} `,stderr:"",exitCode:0};let n=r.result.flags.parents,i=r.result.flags.verbose,s=r.result.positional;if(s.length===0)return{stdout:"",stderr:`rmdir: missing operand `,exitCode:1};let a="",o="",l=0,u=new Fr({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"rmdir",label:"parent traversal"});for(let c of s){let p=await L9(t,c,n,i,u);a+=p.stdout,o+=p.stderr,p.exitCode!==0&&(l=p.exitCode)}return{stdout:a,stderr:o,exitCode:l}}},ng={name:"rmdir",flags:[{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0}}),ig={};re(ig,{flagsForFuzzing:()=>ag,touchCommand:()=>sg});function F9(e){let t=e.replace(/\//g,"-"),r=new Date(t);if(!Number.isNaN(r.getTime()))return r;let n=t.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(n){let[,s,a,o]=n;if(r=new Date(Number.parseInt(s,10),Number.parseInt(a,10)-1,Number.parseInt(o,10)),!Number.isNaN(r.getTime()))return r}let i=t.match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})$/);if(i){let[,s,a,o,l,u,c]=i;if(r=new Date(Number.parseInt(s,10),Number.parseInt(a,10)-1,Number.parseInt(o,10),Number.parseInt(l,10),Number.parseInt(u,10),Number.parseInt(c,10)),!Number.isNaN(r.getTime()))return r}return null}var sg,ag,_9=M(()=>{Er(),le(),sg={name:"touch",async execute(e,t){let r=[],n=null,i=!1;for(let l=0;l=e.length)return{stdout:"",stderr:`touch: option requires an argument -- 'd' `,exitCode:1};n=e[++l]}else if(u.startsWith("--date="))n=u.slice(7);else if(u==="-c"||u==="--no-create")i=!0;else if(u==="-a"||u==="-m"||u==="-r"||u==="-t")(u==="-r"||u==="-t")&&l++;else{if(u.startsWith("--"))return ve("touch",u);if(u.startsWith("-")&&u.length>1){let c=!1;for(let p of u.slice(1))if(p==="c")i=!0;else if(p!=="a"&&p!=="m"){if(p==="d"){if(l+1>=e.length)return{stdout:"",stderr:`touch: option requires an argument -- 'd' `,exitCode:1};n=e[++l],c=!0;break}if(p==="r"||p==="t"){l++,c=!0;break}return ve("touch",`-${p}`)}if(c)continue}else r.push(u)}}if(r.length===0)return{stdout:"",stderr:`touch: missing file operand `,exitCode:1};let s=null;if(n!==null&&(s=F9(n),s===null))return{stdout:"",stderr:`touch: invalid date format '${n}' `,exitCode:1};let a="",o=0;for(let l of r)try{let u=t.fs.resolvePath(t.cwd,l);if(!await t.fs.exists(u)){if(i)continue;await t.fs.writeFile(u,"")}let c=s??new Date;await t.fs.utimes(u,c,c)}catch(u){a+=`touch: cannot touch '${l}': ${ur(u)} `,o=1}return{stdout:"",stderr:a,exitCode:o}}},ag={name:"touch",flags:[{flag:"-c",type:"boolean"},{flag:"-a",type:"boolean"},{flag:"-m",type:"boolean"},{flag:"-d",type:"value",valueHint:"string"}],needsArgs:!0}}),og={};re(og,{flagsForFuzzing:()=>ug,rmCommand:()=>lg});var dp,lg,ug,z9=M(()=>{Mr(),Er(),Ct(),dp={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},lg={name:"rm",async execute(e,t){let r=At("rm",e,dp);if(!r.ok)return r.error;let n=r.result.flags.recursive||r.result.flags.recursiveUpper,i=r.result.flags.force,s=r.result.flags.verbose,a=r.result.positional;if(a.length===0)return i?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand `,exitCode:1};let o="",l="",u=0;for(let c of a)try{let p=t.fs.resolvePath(t.cwd,c);if((await t.fs.stat(p)).isDirectory&&!n){l+=`rm: cannot remove '${c}': Is a directory `,u=1;continue}await t.fs.rm(p,{recursive:n,force:i}),s&&(o+=`removed '${c}' `)}catch(p){if(!i){let h=ur(p);h.includes("ENOENT")||h.includes("no such file")?l+=`rm: cannot remove '${c}': No such file or directory `:h.includes("ENOTEMPTY")||h.includes("not empty")?l+=`rm: cannot remove '${c}': Directory not empty `:l+=`rm: cannot remove '${c}': ${xt(h)} `,u=1}}return{stdout:o,stderr:l,exitCode:u}}},ug={name:"rm",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0}}),cg={};re(cg,{cpCommand:()=>pg,flagsForFuzzing:()=>hg});var mp,gp,pg,hg,B9=M(()=>{Ls(),_r(),H(),Er(),Ct(),le(),mp={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},gp={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},pg={name:"cp",async execute(e,t){if(he(e))return ce(mp);let r=At("cp",e,gp);if(!r.ok)return r.error;let n=r.result.flags.recursive||r.result.flags.recursiveUpper,i=r.result.flags.noClobber;r.result.flags.preserve;let s=r.result.flags.verbose,a=r.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand `,exitCode:1};let o=a.pop()??"",l=a,u=t.fs.resolvePath(t.cwd,o),c="",p="",h=0,f=new Fr({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"cp"}),d=!1;try{d=(await t.fs.stat(u)).isDirectory}catch{}if(l.length>1&&!d)return{stdout:"",stderr:`cp: target '${o}' is not a directory `,exitCode:1};for(let m of l)try{let g=t.fs.resolvePath(t.cwd,m),v=await t.fs.stat(g),y=u;if(d){let b=m.split("/").pop()||m;y=u==="/"?`/${b}`:`${u}/${b}`}if(v.isDirectory&&!n){p+=`cp: -r not specified; omitting directory '${m}' `,h=1;continue}if(v.isDirectory){let b=await Hm(t.fs,g,y,f);if(ri(g,y)||b==="inside"){p+=`cp: cannot copy '${m}' into itself, '${y}' `,h=1;continue}if(b==="unknown"){p+=`cp: cannot safely determine whether '${y}' is inside '${m}' `,h=1;continue}}if(i)try{await t.fs.stat(y);continue}catch{}let x=await Gm(t.fs,g,y);if(x==="same"){p+=`cp: '${m}' and '${y}' are the same file `,h=1;continue}if(x==="unknown"){p+=`cp: cannot safely determine whether '${m}' and '${y}' are the same file `,h=1;continue}v.isDirectory&&await Ms({fs:t.fs,root:g,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"cp",symlinks:"never",budget:f},()=>{}),await t.fs.cp(g,y,{recursive:n}),s&&(c+=`'${m}' -> '${y}' `)}catch(g){if(g instanceof C||g instanceof bt)throw g;let v=ur(g);v.includes("ENOENT")||v.includes("no such file")?p+=`cp: cannot stat '${m}': No such file or directory `:p+=`cp: cannot copy '${m}': ${v} `,h=1}return{stdout:c,stderr:p,exitCode:h}}},hg={name:"cp",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2}}),fg={};re(fg,{flagsForFuzzing:()=>mg,mvCommand:()=>dg});var yp,xp,dg,mg,U9=M(()=>{Ls(),_r(),H(),Er(),Ct(),le(),yp={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},xp={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},dg={name:"mv",async execute(e,t){if(he(e))return ce(yp);let r=At("mv",e,xp);if(!r.ok)return r.error;r.result.flags.force;let n=r.result.flags.noClobber,i=r.result.flags.verbose,s=r.result.positional;if(s.length<2)return{stdout:"",stderr:`mv: missing destination file operand `,exitCode:1};let a=s.pop()??"",o=s,l=t.fs.resolvePath(t.cwd,a),u="",c="",p=0,h=new Fr({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"mv"}),f=!1;try{f=(await t.fs.stat(l)).isDirectory}catch{}if(o.length>1&&!f)return{stdout:"",stderr:`mv: target '${a}' is not a directory `,exitCode:1};for(let d of o)try{let m=t.fs.resolvePath(t.cwd,d),g=await t.fs.stat(m),v=l;if(f){let x=d.split("/").pop()||d;v=l==="/"?`/${x}`:`${l}/${x}`}if(g.isDirectory){let x=await Hm(t.fs,m,v,h);if(ri(m,v)||x==="inside"){c+=`mv: cannot move '${d}' into itself, '${v}' `,p=1;continue}if(x==="unknown"){c+=`mv: cannot safely determine whether '${v}' is inside '${d}' `,p=1;continue}}if(n)try{await t.fs.stat(v);continue}catch{}let y=await Gm(t.fs,m,v);if(y==="same")continue;if(y==="unknown"){c+=`mv: cannot safely determine whether '${d}' and '${v}' are the same file `,p=1;continue}if(g.isDirectory&&await Ms({fs:t.fs,root:m,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"mv",symlinks:"never",budget:h},()=>{}),await t.fs.mv(m,v),i){let x=f?`${a}/${d.split("/").pop()||d}`:a;u+=`renamed '${d}' -> '${x}' `}}catch(m){if(m instanceof C||m instanceof bt)throw m;let g=ur(m);g.includes("ENOENT")||g.includes("no such file")?c+=`mv: cannot stat '${d}': No such file or directory `:c+=`mv: cannot move '${d}': ${g} `,p=1}return{stdout:u,stderr:c,exitCode:p}}},mg={name:"mv",flags:[{flag:"-f",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2}}),gg={};re(gg,{flagsForFuzzing:()=>xg,lnCommand:()=>yg});var vp,yg,xg,W9=M(()=>{Mr(),le(),vp={name:"ln",summary:"make links between files",usage:"ln [OPTIONS] TARGET LINK_NAME",options:["-s create a symbolic link instead of a hard link","-f remove existing destination files","-n treat LINK_NAME as a normal file if it is a symbolic link to a directory","-v print name of each linked file"," --help display this help and exit"]},yg={name:"ln",async execute(e,t){if(he(e))return ce(vp);let r=!1,n=!1,i=!1,s=0;for(;s2)return{stdout:"",stderr:`ln: extra operand '${a[2]}' `,exitCode:1};let o=a[0],l=a[1],u=t.fs.resolvePath(t.cwd,l);if(await t.fs.exists(u))if(n)try{await t.fs.rm(u,{force:!0})}catch{return{stdout:"",stderr:`ln: cannot remove '${l}': Permission denied `,exitCode:1}}else return{stdout:"",stderr:`ln: failed to create ${r?"symbolic ":""}link '${l}': File exists `,exitCode:1};try{if(r)await t.fs.symlink(o,u);else{let p=t.fs.resolvePath(t.cwd,o);if(!await t.fs.exists(p))return{stdout:"",stderr:`ln: failed to access '${o}': No such file or directory `,exitCode:1};await t.fs.link(p,u)}}catch(p){let h=p;return h.message.includes("EPERM")?{stdout:"",stderr:`ln: '${o}': hard link not allowed for directory `,exitCode:1}:{stdout:"",stderr:`ln: ${xt(h.message)} `,exitCode:1}}let c="";return i&&(c=`'${l}' -> '${o}' `),{stdout:c,stderr:"",exitCode:0}}},xg={name:"ln",flags:[{flag:"-s",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2}}),vg={};re(vg,{chmodCommand:()=>bg,flagsForFuzzing:()=>wg});async function j9(e,t,r,n,i,s){let a=new Fr({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"chmod"});await Ms({fs:e.fs,root:t,symlinks:"never",budget:a,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"chmod"},async o=>{if(o.depth===0||o.phase!=="enter")return;let l=r===void 0?n===void 0?420:fu(n,o.stat.mode):r;await e.fs.chmod(o.path,l),i&&s.append(`mode of '${o.path}' changed to ${l.toString(8).padStart(4,"0")} `)})}function fu(e,t=420){if(/^[0-7]+$/.test(e))return parseInt(e,8);let r=t&4095,n=e.split(",");for(let i of n){let s=i.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!s)throw Error(`Invalid mode: ${e}`);let a=s[1]||"a",o=s[2],l=s[3];(a==="a"||a==="")&&(a="ugo");let u=0;l.includes("r")&&(u|=4),l.includes("w")&&(u|=2),(l.includes("x")||l.includes("X"))&&(u|=1);let c=0;l.includes("s")&&(a.includes("u")&&(c|=2048),a.includes("g")&&(c|=1024)),l.includes("t")&&(c|=512);for(let p of a){let h=0;p==="u"?h=6:p==="g"?h=3:p==="o"&&(h=0);let f=u<{Et(),Lt(),_r(),le(),bp={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},bg={name:"chmod",async execute(e,t){if(he(e))return ce(bp);if(e.length<2)return{stdout:"",stderr:`chmod: missing operand `,exitCode:1};let r=!1,n=!1,i=0;for(;iAg,pwdCommand:()=>Sg});var Sg,Ag,G9=M(()=>{Sg={name:"pwd",async execute(e,t){let r=!1;for(let i of e)if(i==="-P")r=!0;else if(i==="-L")r=!1;else{if(i==="--")break;i.startsWith("-")}let n=t.cwd;if(r)try{n=await t.fs.realpath(t.cwd)}catch{}return{stdout:`${n} `,stderr:"",exitCode:0}}},Ag={name:"pwd",flags:[{flag:"-P",type:"boolean"},{flag:"-L",type:"boolean"}]}}),Cg={};re(Cg,{flagsForFuzzing:()=>Ng,readlinkCommand:()=>kg});var wp,kg,Ng,H9=M(()=>{_r(),H(),le(),wp={name:"readlink",summary:"print resolved symbolic links or canonical file names",usage:"readlink [OPTIONS] FILE...",options:["-f canonicalize by following every symlink in every component of the given name recursively"," --help display this help and exit"]},kg={name:"readlink",async execute(e,t){if(he(e))return ce(wp);let r=!1,n=0;for(;ne.limits.maxArrayElements)throw new C(`${r}: file operand limit exceeded (${e.limits.maxArrayElements})`,"array_elements");if(a.length===0)return{stdout:n(e.stdin),stderr:"",exitCode:0,stdoutEncoding:"binary"};let o=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),l=new st(o,r),u=new st(o,r),c=0,p=0,h=s||!i&&a.length>1,f=0;for(let d=0;de.limits.maxInputBytes-p)throw new C(`${r}: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,"string_length");let v=await xn(e.fs,g);if(v.length>e.limits.maxInputBytes-p)throw new C(`${r}: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,"string_length");p+=v.length,e.executionScope?.consumeInput(v.length,r),h&&(f>0&&l.append(` `),l.append(ti(`==> ${m} <== `))),l.append(n(v)),f++}catch(g){Ie(g),u.append(`${r}: ${m}: No such file or directory `),c=1}}return{stdout:l.build(),stderr:u.build(),exitCode:c,stdoutEncoding:"binary"}}function V9(e,t,r){if(r!==null)return e.slice(0,r);if(t===0)return"";let n=0,i=0,s=e.length;for(;n0?e.slice(0,n):""}function Z9(e,t,r,n){if(r!==null)return r===0?"":e.slice(-r);let i=e.length;if(i===0)return"";if(n){let o=0,l=1;for(;o=0&&a{Et(),se(),Lt(),H(),le()}),Ig={};re(Ig,{flagsForFuzzing:()=>Pg,headCommand:()=>Rg});var Ep,Rg,Pg,Q9=M(()=>{le(),Tg(),Ep={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},Rg={name:"head",async execute(e,t){if(he(e))return ce(Ep);let r=$g(e,"head");if(!r.ok)return r.error;let{lines:n,bytes:i}=r.options;return Og(t,r.options,"head",s=>V9(s,n,i))}},Pg={name:"head",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}}),Dg={};re(Dg,{flagsForFuzzing:()=>Mg,tailCommand:()=>Lg});var Sp,Lg,Mg,K9=M(()=>{Tg(),le(),Sp={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},Lg={name:"tail",async execute(e,t){if(he(e))return ce(Sp);let r=$g(e,"tail");if(!r.ok)return r.error;let{lines:n,bytes:i,fromLine:s}=r.options;return Og(t,r.options,"tail",a=>Z9(a,n,i,s??!1))}},Mg={name:"tail",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}}),Fg={};re(Fg,{flagsForFuzzing:()=>zg,wcCommand:()=>_g});function Ap(e,t){let r=e,n=r.length,i=t?Array.from(ke(e)).length:n,s=0,a=0,o=!1;for(let l=0;l{se(),Ct(),ui(),le(),Cp={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},kp={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},_g={name:"wc",async execute(e,t){if(he(e))return ce(Cp);let r=At("wc",e,kp);if(!r.ok)return r.error;let{lines:n,words:i}=r.result.flags,s=r.result.flags.bytes,a=r.result.flags.chars,o=r.result.positional;!n&&!i&&!s&&!a&&(n=i=s=!0);let l=s||a,u=await Pa(t,o,{cmdName:"wc",stopOnError:!1});if(o.length===0)return{stdout:`${qo(Ap(u.files[0].content,a),n,i,l,"",0)} `,stderr:"",exitCode:0};let c=[],p=0,h=0,f=0;for(let{filename:x,content:b}of u.files){let w=Ap(b,a);p+=w.lines,h+=w.words,f+=w.third,c.push({filename:x,stats:w})}let d=o.length>1?p:Math.max(...c.map(x=>x.stats.lines)),m=o.length>1?h:Math.max(...c.map(x=>x.stats.words)),g=o.length>1?f:Math.max(...c.map(x=>x.stats.third)),v=o.length>1?3:0;n&&(v=Math.max(v,String(d).length)),i&&(v=Math.max(v,String(m).length)),l&&(v=Math.max(v,String(g).length));let y="";for(let{filename:x,stats:b}of c)y+=`${qo(b,n,i,l,x,v)} `;return o.length>1&&(y+=`${qo({lines:p,words:h,third:f},n,i,l,"total",v)} `),{stdout:y,stderr:u.stderr,exitCode:u.exitCode}}},zg={name:"wc",flags:[{flag:"-l",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-m",type:"boolean"}],stdinType:"text",needsFiles:!0}});function du(e,t){return(t?"d":"-")+[e&256?"r":"-",e&128?"w":"-",e&64?"x":"-",e&32?"r":"-",e&16?"w":"-",e&8?"x":"-",e&4?"r":"-",e&2?"w":"-",e&1?"x":"-"].join("")}var Bg=M(()=>{}),Ug={};re(Ug,{flagsForFuzzing:()=>jg,statCommand:()=>Wg});var Np,$p,Wg,jg,Y9=M(()=>{se(),Lt(),H(),Ct(),Bg(),le(),Np={name:"stat",summary:"display file or file system status",usage:"stat [OPTION]... FILE...",options:["-c FORMAT use the specified FORMAT instead of the default"," --help display this help and exit"]},$p={format:{short:"c",type:"string"}},Wg={name:"stat",async execute(e,t){if(he(e))return ce(Np);let r=At("stat",e,$p);if(!r.ok)return r.error;let n=r.result.flags.format??null,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:`stat: missing operand `,exitCode:1};let s="",a="",o=!1,l=0,u=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),c=p=>{let h=q(p);if(h>u-l)throw new C(`stat: output size limit exceeded (${u} bytes)`,"output_size");s+=p,l+=h};for(let p of i){let h=t.fs.resolvePath(t.cwd,p);try{let f=await t.fs.stat(h);if(n){let d=f.mode.toString(8),m=du(f.mode,f.isDirectory),g=new Map([["%n",p],["%N",`'${p}'`],["%s",String(f.size)],["%F",f.isDirectory?"directory":"regular file"],["%a",d],["%A",m],["%u","1000"],["%U","user"],["%g","1000"],["%G","group"]]);c(`${n.replace(/%[nNsFaAuUgG]/g,v=>g.get(v)??v)} `)}else{let d=f.mode.toString(8).padStart(4,"0"),m=du(f.mode,f.isDirectory);c(` File: ${p} Size: ${f.size} Blocks: ${Math.ceil(f.size/512)} Access: (${d}/${m}) Modify: ${f.mtime.toISOString()} `)}}catch(f){Ie(f),a+=`stat: cannot stat '${p}': No such file or directory `,o=!0}}return{stdout:s,stderr:a,exitCode:+!!o}}},jg={name:"stat",flags:[{flag:"-c",type:"value",valueHint:"format"},{flag:"-L",type:"boolean"}],needsArgs:!0}}),K,U,T,kr,me,Pe,Go,Dn,Ho,Op,es,sn,Tp,Ip,ot,ts,Xe,Rp,Ur,Pp,Dp,ye,Lp,Vo,Vs,Mp,Fp,_p,zp,W,Bp,rs,Up,Wp,De,Zo,Qo,Ko,Xo,Yo,Jo,el,tl,rl,nl,il,sl,al,ol,ll,ul,cl,pl,hl,an,Zs,jp,qp,Gp,Hp,Vp,Ii,J9=M(()=>{K=class Bn{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=Bn.CLASS_NL|Bn.DOT_NL;static PERL=Bn.CLASS_NL|Bn.ONE_LINE|Bn.PERL_X|Bn.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},U=class{static CODES=new Map([["\x07",7],["\b",8],[" ",9],[` `,10],["\v",11],["\f",12],["\r",13],[" ",32],['"',34],["$",36],["&",38],["(",40],[")",41],["*",42],["+",43],["-",45],[".",46],["0",48],["1",49],["2",50],["3",51],["4",52],["5",53],["6",54],["7",55],["8",56],["9",57],[":",58],["<",60],[">",62],["?",63],["A",65],["B",66],["C",67],["F",70],["P",80],["Q",81],["U",85],["Z",90],["[",91],["\\",92],["]",93],["^",94],["_",95],["a",97],["b",98],["f",102],["i",105],["m",109],["n",110],["r",114],["s",115],["t",116],["v",118],["x",120],["z",122],["{",123],["|",124],["}",125]]);static toUpperCase(e){let t=String.fromCodePoint(e).toUpperCase();if(t.length>1)return e;let r=String.fromCodePoint(t.codePointAt(0)).toLowerCase();return r.length>1||r.codePointAt(0)!==e?e:t.codePointAt(0)}static toLowerCase(e){let t=String.fromCodePoint(e).toLowerCase();if(t.length>1)return e;let r=String.fromCodePoint(t.codePointAt(0)).toUpperCase();return r.length>1||r.codePointAt(0)!==e?e:t.codePointAt(0)}},T=class{SIZE=3;constructor(e){this.data=e}getLo(e){return this.data[e*this.SIZE]}getHi(e){return this.data[e*this.SIZE+1]}getStride(e){return this.data[e*this.SIZE+2]}get(e){let t=e*this.SIZE;return[this.data[t],this.data[t+1],this.data[t+2]]}get length(){return this.data.length/this.SIZE}},kr=class I{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[68944,68976],[68976,68944],[68945,68977],[68977,68945],[68946,68978],[68978,68946],[68947,68979],[68979,68947],[68948,68980],[68980,68948],[68949,68981],[68981,68949],[68950,68982],[68982,68950],[68951,68983],[68983,68951],[68952,68984],[68984,68952],[68953,68985],[68985,68953],[68954,68986],[68986,68954],[68955,68987],[68987,68955],[68956,68988],[68988,68956],[68957,68989],[68989,68957],[68958,68990],[68990,68958],[68959,68991],[68991,68959],[68960,68992],[68992,68960],[68961,68993],[68993,68961],[68962,68994],[68994,68962],[68963,68995],[68995,68963],[68964,68996],[68996,68964],[68965,68997],[68997,68965],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[93771,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=new T(new Uint32Array([0,31,1,127,159,1,173,888,715,889,896,7,897,899,1,907,909,2,930,1328,398,1367,1368,1,1419,1420,1,1424,1480,56,1481,1487,1,1515,1518,1,1525,1541,1,1564,1757,193,1806,1807,1,1867,1868,1,1970,1983,1,2043,2044,1,2094,2095,1,2111,2140,29,2141,2143,2,2155,2159,1,2191,2198,1,2274,2436,162,2445,2446,1,2449,2450,1,2473,2481,8,2483,2485,1,2490,2491,1,2501,2502,1,2505,2506,1,2511,2518,1,2520,2523,1,2526,2532,6,2533,2559,26,2560,2564,4,2571,2574,1,2577,2578,1,2601,2609,8,2612,2618,3,2619,2621,2,2627,2630,1,2633,2634,1,2638,2640,1,2642,2648,1,2653,2655,2,2656,2661,1,2679,2688,1,2692,2702,10,2706,2729,23,2737,2740,3,2746,2747,1,2758,2766,4,2767,2769,2,2770,2783,1,2788,2789,1,2802,2808,1,2816,2820,4,2829,2830,1,2833,2834,1,2857,2865,8,2868,2874,6,2875,2885,10,2886,2889,3,2890,2894,4,2895,2900,1,2904,2907,1,2910,2916,6,2917,2936,19,2937,2945,1,2948,2955,7,2956,2957,1,2961,2966,5,2967,2968,1,2971,2973,2,2976,2978,1,2981,2983,1,2987,2989,1,3002,3005,1,3011,3013,1,3017,3022,5,3023,3025,2,3026,3030,1,3032,3045,1,3067,3071,1,3085,3089,4,3113,3130,17,3131,3141,10,3145,3150,5,3151,3156,1,3159,3163,4,3164,3166,2,3167,3172,5,3173,3184,11,3185,3190,1,3213,3217,4,3241,3252,11,3258,3259,1,3269,3273,4,3278,3284,1,3287,3292,1,3295,3300,5,3301,3312,11,3316,3327,1,3341,3345,4,3397,3401,4,3408,3411,1,3428,3429,1,3456,3460,4,3479,3481,1,3506,3516,10,3518,3519,1,3527,3529,1,3531,3534,1,3541,3543,2,3552,3557,1,3568,3569,1,3573,3584,1,3643,3646,1,3676,3712,1,3715,3717,2,3723,3748,25,3750,3774,24,3775,3781,6,3783,3791,8,3802,3803,1,3808,3839,1,3912,3949,37,3950,3952,1,3992,4029,37,4045,4059,14,4060,4095,1,4294,4296,2,4297,4300,1,4302,4303,1,4681,4686,5,4687,4695,8,4697,4702,5,4703,4745,42,4750,4751,1,4785,4790,5,4791,4799,8,4801,4806,5,4807,4823,16,4881,4886,5,4887,4955,68,4956,4989,33,4990,4991,1,5018,5023,1,5110,5111,1,5118,5119,1,5789,5791,1,5881,5887,1,5910,5918,1,5943,5951,1,5972,5983,1,5997,6001,4,6004,6015,1,6110,6111,1,6122,6127,1,6138,6143,1,6158,6170,12,6171,6175,1,6265,6271,1,6315,6319,1,6390,6399,1,6431,6444,13,6445,6447,1,6460,6463,1,6465,6467,1,6510,6511,1,6517,6527,1,6572,6575,1,6602,6607,1,6619,6621,1,6684,6685,1,6751,6781,30,6782,6794,12,6795,6799,1,6810,6815,1,6830,6831,1,6863,6911,1,6989,7156,167,7157,7163,1,7224,7226,1,7242,7244,1,7307,7311,1,7355,7356,1,7368,7375,1,7419,7423,1,7958,7959,1,7966,7967,1,8006,8007,1,8014,8015,1,8024,8030,2,8062,8063,1,8117,8133,16,8148,8149,1,8156,8176,20,8177,8181,4,8191,8203,12,8204,8207,1,8234,8238,1,8288,8303,1,8306,8307,1,8335,8349,14,8350,8351,1,8385,8399,1,8433,8447,1,8588,8591,1,9258,9279,1,9291,9311,1,11124,11125,1,11158,11508,350,11509,11512,1,11558,11560,2,11561,11564,1,11566,11567,1,11624,11630,1,11633,11646,1,11671,11679,1,11687,11743,8,11870,11903,1,11930,12020,90,12021,12031,1,12246,12271,1,12352,12439,87,12440,12544,104,12545,12548,1,12592,12687,95,12774,12782,1,12831,42125,29294,42126,42127,1,42183,42191,1,42540,42559,1,42744,42751,1,42958,42959,1,42962,42964,2,42973,42993,1,43053,43055,1,43066,43071,1,43128,43135,1,43206,43213,1,43226,43231,1,43348,43358,1,43389,43391,1,43470,43482,12,43483,43485,1,43519,43575,56,43576,43583,1,43598,43599,1,43610,43611,1,43715,43738,1,43767,43776,1,43783,43784,1,43791,43792,1,43799,43807,1,43815,43823,8,43884,43887,1,44014,44015,1,44026,44031,1,55204,55215,1,55239,55242,1,55292,63743,1,64110,64111,1,64218,64255,1,64263,64274,1,64280,64284,1,64311,64317,6,64319,64325,3,64451,64466,1,64912,64913,1,64968,64974,1,64976,65007,1,65050,65055,1,65107,65127,20,65132,65135,1,65141,65277,136,65278,65280,1,65471,65473,1,65480,65481,1,65488,65489,1,65496,65497,1,65501,65503,1,65511,65519,8,65520,65531,1,65534,65535,1,65548,65575,27,65595,65598,3,65614,65615,1,65630,65663,1,65787,65791,1,65795,65798,1,65844,65846,1,65935,65949,14,65950,65951,1,65953,65999,1,66046,66175,1,66205,66207,1,66257,66271,1,66300,66303,1,66340,66348,1,66379,66383,1,66427,66431,1,66462,66500,38,66501,66503,1,66518,66559,1,66718,66719,1,66730,66735,1,66772,66775,1,66812,66815,1,66856,66863,1,66916,66926,1,66939,66955,16,66963,66966,3,66978,66994,16,67002,67005,3,67006,67007,1,67060,67071,1,67383,67391,1,67414,67423,1,67432,67455,1,67462,67505,43,67515,67583,1,67590,67591,1,67593,67638,45,67641,67643,1,67645,67646,1,67670,67743,73,67744,67750,1,67760,67807,1,67827,67830,3,67831,67834,1,67868,67870,1,67898,67902,1,67904,67967,1,68024,68027,1,68048,68049,1,68100,68103,3,68104,68107,1,68116,68120,4,68150,68151,1,68155,68158,1,68169,68175,1,68185,68191,1,68256,68287,1,68327,68330,1,68343,68351,1,68406,68408,1,68438,68439,1,68467,68471,1,68498,68504,1,68509,68520,1,68528,68607,1,68681,68735,1,68787,68799,1,68851,68857,1,68904,68911,1,68922,68927,1,68966,68968,1,68998,69005,1,69008,69215,1,69247,69290,43,69294,69295,1,69298,69313,1,69317,69371,1,69416,69423,1,69466,69487,1,69514,69551,1,69580,69599,1,69623,69631,1,69710,69713,1,69750,69758,1,69821,69827,6,69828,69839,1,69865,69871,1,69882,69887,1,69941,69960,19,69961,69967,1,70007,70015,1,70112,70133,21,70134,70143,1,70162,70210,48,70211,70271,1,70279,70281,2,70286,70302,16,70314,70319,1,70379,70383,1,70394,70399,1,70404,70413,9,70414,70417,3,70418,70441,23,70449,70452,3,70458,70469,11,70470,70473,3,70474,70478,4,70479,70481,2,70482,70486,1,70488,70492,1,70500,70501,1,70509,70511,1,70517,70527,1,70538,70540,2,70541,70543,2,70582,70593,11,70595,70596,1,70598,70603,5,70614,70617,3,70618,70624,1,70627,70655,1,70748,70754,6,70755,70783,1,70856,70863,1,70874,71039,1,71094,71095,1,71134,71167,1,71237,71247,1,71258,71263,1,71277,71295,1,71354,71359,1,71370,71375,1,71396,71423,1,71451,71452,1,71468,71471,1,71495,71679,1,71740,71839,1,71923,71934,1,71943,71944,1,71946,71947,1,71956,71959,3,71990,71993,3,71994,72007,13,72008,72015,1,72026,72095,1,72104,72105,1,72152,72153,1,72165,72191,1,72264,72271,1,72355,72367,1,72441,72447,1,72458,72639,1,72674,72687,1,72698,72703,1,72713,72759,46,72774,72783,1,72813,72815,1,72848,72849,1,72872,72887,15,72888,72959,1,72967,72970,3,73015,73017,1,73019,73022,3,73032,73039,1,73050,73055,1,73062,73065,3,73103,73106,3,73113,73119,1,73130,73439,1,73465,73471,1,73489,73531,42,73532,73533,1,73563,73647,1,73649,73663,1,73714,73726,1,74650,74751,1,74863,74869,6,74870,74879,1,75076,77711,1,77811,77823,1,78896,78911,1,78934,78943,1,82939,82943,1,83527,90367,1,90426,92159,1,92729,92735,1,92767,92778,11,92779,92781,1,92863,92874,11,92875,92879,1,92910,92911,1,92918,92927,1,92998,93007,1,93018,93026,8,93048,93052,1,93072,93503,1,93562,93759,1,93851,93951,1,94027,94030,1,94088,94094,1,94112,94175,1,94181,94191,1,94194,94207,1,100344,100351,1,101590,101630,1,101641,110575,1,110580,110588,8,110591,110883,292,110884,110897,1,110899,110927,1,110931,110932,1,110934,110947,1,110952,110959,1,111356,113663,1,113771,113775,1,113789,113791,1,113801,113807,1,113818,113819,1,113824,117759,1,118010,118015,1,118452,118527,1,118574,118575,1,118599,118607,1,118724,118783,1,119030,119039,1,119079,119080,1,119155,119162,1,119275,119295,1,119366,119487,1,119508,119519,1,119540,119551,1,119639,119647,1,119673,119807,1,119893,119965,72,119968,119969,1,119971,119972,1,119975,119976,1,119981,119994,13,119996,120004,8,120070,120075,5,120076,120085,9,120093,120122,29,120127,120133,6,120135,120137,1,120145,120486,341,120487,120780,293,120781,121484,703,121485,121498,1,121504,121520,16,121521,122623,1,122655,122660,1,122667,122879,1,122887,122905,18,122906,122914,8,122917,122923,6,122924,122927,1,122990,123022,1,123024,123135,1,123181,123183,1,123198,123199,1,123210,123213,1,123216,123535,1,123567,123583,1,123642,123646,1,123648,124111,1,124154,124367,1,124411,124414,1,124416,124895,1,124903,124908,5,124911,124927,16,125125,125126,1,125143,125183,1,125260,125263,1,125274,125277,1,125280,126064,1,126133,126208,1,126270,126463,1,126468,126496,28,126499,126501,2,126502,126504,2,126515,126520,5,126522,126524,2,126525,126529,1,126531,126534,1,126536,126540,2,126544,126547,3,126549,126550,1,126552,126560,2,126563,126565,2,126566,126571,5,126579,126589,5,126591,126602,11,126620,126624,1,126628,126634,6,126652,126703,1,126706,126975,1,127020,127023,1,127124,127135,1,127151,127152,1,127168,127184,16,127222,127231,1,127406,127461,1,127491,127503,1,127548,127551,1,127561,127567,1,127570,127583,1,127590,127743,1,128728,128731,1,128749,128751,1,128765,128767,1,128887,128890,1,128986,128991,1,129004,129007,1,129009,129023,1,129036,129039,1,129096,129103,1,129114,129119,1,129160,129167,1,129198,129199,1,129212,129215,1,129218,129279,1,129620,129631,1,129646,129647,1,129661,129663,1,129674,129678,1,129735,129741,1,129757,129758,1,129770,129775,1,129785,129791,1,129939,130042,103,130043,131071,1,173792,173823,1,177978,177983,1,178206,178207,1,183970,183983,1,191457,191471,1,192094,194559,1,195102,196607,1,201547,201551,1,205744,917759,1,918e3,1114111,1]));static Cc=new T(new Uint32Array([0,31,1,127,159,1]));static Cf=new T(new Uint32Array([173,1536,1363,1537,1541,1,1564,1757,193,1807,2192,385,2193,2274,81,6158,8203,2045,8204,8207,1,8234,8238,1,8288,8292,1,8294,8303,1,65279,65529,250,65530,65531,1,69821,69837,16,78896,78911,1,113824,113827,1,119155,119162,1,917505,917536,31,917537,917631,1]));static Co=new T(new Uint32Array([57344,63743,1,983040,1048573,1,1048576,1114109,1]));static Cs=new T(new Uint32Array([55296,57343,1]));static L=new T(new Uint32Array([65,90,1,97,122,1,170,181,11,186,192,6,193,214,1,216,246,1,248,705,1,710,721,1,736,740,1,748,750,2,880,884,1,886,887,1,890,893,1,895,902,7,904,906,1,908,910,2,911,929,1,931,1013,1,1015,1153,1,1162,1327,1,1329,1366,1,1369,1376,7,1377,1416,1,1488,1514,1,1519,1522,1,1568,1610,1,1646,1647,1,1649,1747,1,1749,1765,16,1766,1774,8,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2036,2037,1,2042,2048,6,2049,2069,1,2074,2084,10,2088,2112,24,2113,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2249,1,2308,2361,1,2365,2384,19,2392,2401,1,2417,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3654,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3782,3804,22,3805,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4256,18,4257,4293,1,4295,4301,6,4304,4346,1,4348,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5024,5109,1,5112,5117,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6103,6108,5,6176,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6823,6917,94,6918,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7293,1,7296,7306,1,7312,7354,1,7357,7359,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,7424,6,7425,7615,1,7680,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8124,1,8126,8130,4,8131,8132,1,8134,8140,1,8144,8147,1,8150,8155,1,8160,8172,1,8178,8180,1,8182,8188,1,8305,8319,14,8336,8348,1,8450,8455,5,8458,8467,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8495,8505,1,8508,8511,1,8517,8521,1,8526,8579,53,8580,11264,2684,11265,11492,1,11499,11502,1,11506,11507,1,11520,11557,1,11559,11565,6,11568,11623,1,11631,11648,17,11649,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11823,12293,470,12294,12337,43,12338,12341,1,12347,12348,1,12353,12438,1,12445,12447,1,12449,12538,1,12540,12543,1,12549,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,42124,1,42192,42237,1,42240,42508,1,42512,42527,1,42538,42539,1,42560,42606,1,42623,42653,1,42656,42725,1,42775,42783,1,42786,42888,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43471,43488,17,43489,43492,1,43494,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43741,1,43744,43754,1,43762,43764,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43866,1,43868,43881,1,43888,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65313,65338,1,65345,65370,1,65382,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66560,66717,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68736,68786,1,68800,68850,1,68864,68899,1,68938,68965,1,68975,68997,1,69248,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71840,71903,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,92992,92995,1,93027,93047,1,93053,93071,1,93504,93548,1,93760,93823,1,93952,94026,1,94032,94099,67,94100,94111,1,94176,94177,1,94179,94208,29,94209,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120512,1,120514,120538,1,120540,120570,1,120572,120596,1,120598,120628,1,120630,120654,1,120656,120686,1,120688,120712,1,120714,120744,1,120746,120770,1,120772,120779,1,122624,122654,1,122661,122666,1,122928,122989,1,123136,123180,1,123191,123197,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124139,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125184,125251,1,125259,126464,1205,126465,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static foldL=new T(new Uint32Array([837,837,1]));static Ll=new T(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,311,2,312,328,2,329,375,2,378,382,2,383,384,1,387,389,2,392,396,4,397,402,5,405,409,4,410,411,1,414,417,3,419,421,2,424,426,2,427,429,2,432,436,4,438,441,3,442,445,3,446,447,1,454,460,3,462,476,2,477,495,2,496,499,3,501,505,4,507,563,2,564,569,1,572,575,3,576,578,2,583,591,2,592,659,1,661,687,1,881,883,2,887,891,4,892,893,1,912,940,28,941,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1020,1072,52,1073,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1376,1416,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7424,118,7425,7467,1,7531,7543,1,7545,7578,1,7681,7829,2,7830,7837,1,7839,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8016,8023,1,8032,8039,1,8048,8061,1,8064,8071,1,8080,8087,1,8096,8103,1,8112,8116,1,8118,8119,1,8126,8130,4,8131,8132,1,8134,8135,1,8144,8147,1,8150,8151,1,8160,8167,1,8178,8180,1,8182,8183,1,8458,8462,4,8463,8467,4,8495,8505,5,8508,8509,1,8518,8521,1,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11377,11379,2,11380,11382,2,11383,11387,1,11393,11491,2,11492,11500,8,11502,11507,5,11520,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42800,42801,1,42803,42865,2,42866,42872,1,42874,42876,2,42879,42887,2,42892,42894,2,42897,42899,2,42900,42901,1,42903,42921,2,42927,42933,6,42935,42947,2,42952,42954,2,42957,42961,4,42963,42971,2,42998,43002,4,43824,43866,1,43872,43880,1,43888,43967,1,64256,64262,1,64275,64279,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,119834,119859,1,119886,119892,1,119894,119911,1,119938,119963,1,119990,119993,1,119995,119997,2,119998,120003,1,120005,120015,1,120042,120067,1,120094,120119,1,120146,120171,1,120198,120223,1,120250,120275,1,120302,120327,1,120354,120379,1,120406,120431,1,120458,120485,1,120514,120538,1,120540,120545,1,120572,120596,1,120598,120603,1,120630,120654,1,120656,120661,1,120688,120712,1,120714,120719,1,120746,120770,1,120772,120777,1,120779,122624,1845,122625,122633,1,122635,122654,1,122661,122666,1,125218,125251,1]));static foldLl=new T(new Uint32Array([65,90,1,192,214,1,216,222,1,256,302,2,306,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,453,1,455,456,1,458,459,1,461,475,2,478,494,2,497,498,1,500,502,2,503,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,837,880,43,882,886,4,895,902,7,904,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,984,9,986,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8072,8079,1,8088,8095,1,8104,8111,1,8120,8124,1,8136,8140,1,8152,8155,1,8168,8172,1,8184,8188,1,8486,8490,4,8491,8498,7,8579,11264,2685,11265,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,125184,125217,1]));static Lm=new T(new Uint32Array([688,705,1,710,721,1,736,740,1,748,750,2,884,890,6,1369,1600,231,1765,1766,1,2036,2037,1,2042,2074,32,2084,2088,4,2249,2417,168,3654,3782,128,4348,6103,1755,6211,6823,612,7288,7293,1,7468,7530,1,7544,7579,35,7580,7615,1,8305,8319,14,8336,8348,1,11388,11389,1,11631,11823,192,12293,12337,44,12338,12341,1,12347,12445,98,12446,12540,94,12541,12542,1,40981,42232,1251,42233,42237,1,42508,42623,115,42652,42653,1,42775,42783,1,42864,42888,24,42994,42996,1,43e3,43001,1,43471,43494,23,43632,43741,109,43763,43764,1,43868,43871,1,43881,65392,21511,65438,65439,1,67456,67461,1,67463,67504,1,67506,67514,1,68942,68975,33,92992,92995,1,93504,93506,1,93547,93548,1,94099,94111,1,94176,94177,1,94179,110576,16397,110577,110579,1,110581,110587,1,110589,110590,1,122928,122989,1,123191,123197,1,124139,125259,1120]));static Lo=new T(new Uint32Array([170,186,16,443,448,5,449,451,1,660,1488,828,1489,1514,1,1519,1522,1,1568,1599,1,1601,1610,1,1646,1647,1,1649,1747,1,1749,1774,25,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2048,2069,1,2112,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2248,1,2308,2361,1,2365,2384,19,2392,2401,1,2418,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3653,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3804,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4352,114,4353,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6108,6176,68,6177,6210,1,6212,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6917,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7287,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,8501,1083,8502,8504,1,11568,11623,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,12294,12348,54,12353,12438,1,12447,12449,2,12450,12538,1,12543,12549,6,12550,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,40980,1,40982,42124,1,42192,42231,1,42240,42507,1,42512,42527,1,42538,42539,1,42606,42656,50,42657,42725,1,42895,42999,104,43003,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43488,43492,1,43495,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43631,1,43633,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43740,1,43744,43754,1,43762,43777,15,43778,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43968,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65382,65391,1,65393,65437,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66640,66717,1,66816,66855,1,66864,66915,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68864,68899,1,68938,68941,1,68943,69248,305,69249,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,93027,93047,1,93053,93071,1,93507,93546,1,93952,94026,1,94032,94208,176,94209,100343,1,100352,101589,1,101631,101640,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,122634,123136,502,123137,123180,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124138,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Lt=new T(new Uint32Array([453,459,3,498,8072,7574,8073,8079,1,8088,8095,1,8104,8111,1,8124,8140,16,8188,8188,1]));static foldLt=new T(new Uint32Array([452,454,2,455,457,2,458,460,2,497,499,2,8064,8071,1,8080,8087,1,8096,8103,1,8115,8131,16,8179,8179,1]));static Lu=new T(new Uint32Array([65,90,1,192,214,1,216,222,1,256,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,461,3,463,475,2,478,494,2,497,500,3,502,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,880,882,2,886,895,9,902,904,2,905,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,978,3,979,980,1,984,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8120,8123,1,8136,8139,1,8152,8155,1,8168,8172,1,8184,8187,1,8450,8455,5,8459,8461,1,8464,8466,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8496,8499,1,8510,8511,1,8517,8579,62,11264,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,119808,119833,1,119860,119885,1,119912,119937,1,119964,119966,2,119967,119973,3,119974,119977,3,119978,119980,1,119982,119989,1,120016,120041,1,120068,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120120,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120172,120197,1,120224,120249,1,120276,120301,1,120328,120353,1,120380,120405,1,120432,120457,1,120488,120512,1,120546,120570,1,120604,120628,1,120662,120686,1,120720,120744,1,120778,125184,4406,125185,125217,1]));static Upper=this.Lu;static foldLu=new T(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,303,2,307,311,2,314,328,2,331,375,2,378,382,2,383,384,1,387,389,2,392,396,4,402,405,3,409,411,1,414,417,3,419,421,2,424,429,5,432,436,4,438,441,3,445,447,2,453,454,1,456,457,1,459,460,1,462,476,2,477,495,2,498,499,1,501,505,4,507,543,2,547,563,2,572,575,3,576,578,2,583,591,2,592,596,1,598,599,1,601,603,2,604,608,4,609,611,2,612,614,1,616,620,1,623,625,2,626,629,3,637,640,3,642,643,1,647,652,1,658,669,11,670,837,167,881,883,2,887,891,4,892,893,1,940,943,1,945,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1072,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1377,1414,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7545,239,7549,7566,17,7681,7829,2,7835,7841,6,7843,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8017,8023,2,8032,8039,1,8048,8061,1,8112,8113,1,8126,8144,18,8145,8160,15,8161,8165,4,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11379,11382,3,11393,11491,2,11500,11502,2,11507,11520,13,11521,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42803,42863,2,42874,42876,2,42879,42887,2,42892,42897,5,42899,42900,1,42903,42921,2,42933,42947,2,42952,42954,2,42957,42961,4,42967,42971,2,42998,43859,861,43888,43967,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,125218,125251,1]));static M=new T(new Uint32Array([768,879,1,1155,1161,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2307,1,2362,2364,1,2366,2383,1,2385,2391,1,2402,2403,1,2433,2435,1,2492,2494,2,2495,2500,1,2503,2504,1,2507,2509,1,2519,2530,11,2531,2558,27,2561,2563,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2672,31,2673,2677,4,2689,2691,1,2748,2750,2,2751,2757,1,2759,2761,1,2763,2765,1,2786,2787,1,2810,2815,1,2817,2819,1,2876,2878,2,2879,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2914,2915,1,2946,3006,60,3007,3010,1,3014,3016,1,3018,3021,1,3031,3072,41,3073,3076,1,3132,3134,2,3135,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3203,1,3260,3262,2,3263,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3298,3299,1,3315,3328,13,3329,3331,1,3387,3388,1,3390,3396,1,3398,3400,1,3402,3405,1,3415,3426,11,3427,3457,30,3458,3459,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3570,3571,1,3633,3636,3,3637,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3902,3903,1,3953,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4139,101,4140,4158,1,4182,4185,1,4190,4192,1,4194,4196,1,4199,4205,1,4209,4212,1,4226,4237,1,4239,4250,11,4251,4253,1,4957,4959,1,5906,5909,1,5938,5940,1,5970,5971,1,6002,6003,1,6068,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6443,1,6448,6459,1,6679,6683,1,6741,6750,1,6752,6780,1,6783,6832,49,6833,6862,1,6912,6916,1,6964,6980,1,7019,7027,1,7040,7042,1,7073,7085,1,7142,7155,1,7204,7223,1,7376,7378,1,7380,7400,1,7405,7412,7,7415,7417,1,7616,7679,1,8400,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12335,1,12441,12442,1,42607,42610,1,42612,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43043,24,43044,43047,1,43052,43136,84,43137,43188,51,43189,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43347,1,43392,43395,1,43443,43456,1,43493,43561,68,43562,43574,1,43587,43596,9,43597,43643,46,43644,43645,1,43696,43698,2,43699,43700,1,43703,43704,1,43710,43711,1,43713,43755,42,43756,43759,1,43765,43766,1,44003,44010,1,44012,44013,1,64286,65024,738,65025,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69632,69634,1,69688,69702,1,69744,69747,3,69748,69759,11,69760,69762,1,69808,69818,1,69826,69888,62,69889,69890,1,69927,69940,1,69957,69958,1,70003,70016,13,70017,70018,1,70067,70080,1,70089,70092,1,70094,70095,1,70188,70199,1,70206,70209,3,70367,70378,1,70400,70403,1,70459,70460,1,70462,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70502,3,70503,70508,1,70512,70516,1,70584,70592,1,70594,70597,3,70599,70602,1,70604,70608,1,70610,70625,15,70626,70709,83,70710,70726,1,70750,70832,82,70833,70851,1,71087,71093,1,71096,71104,1,71132,71133,1,71216,71232,1,71339,71351,1,71453,71467,1,71724,71738,1,71984,71989,1,71991,71992,1,71995,71998,1,72e3,72002,2,72003,72145,142,72146,72151,1,72154,72160,1,72164,72193,29,72194,72202,1,72243,72249,1,72251,72254,1,72263,72273,10,72274,72283,1,72330,72345,1,72751,72758,1,72760,72767,1,72850,72871,1,72873,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73098,67,73099,73102,1,73104,73105,1,73107,73111,1,73459,73462,1,73472,73473,1,73475,73524,49,73525,73530,1,73534,73538,1,73562,78912,5350,78919,78933,1,90398,90415,1,92912,92916,1,92976,92982,1,94031,94033,2,94034,94087,1,94095,94098,1,94180,94192,12,94193,113821,19628,113822,118528,4706,118529,118573,1,118576,118598,1,119141,119145,1,119149,119154,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldM=new T(new Uint32Array([921,953,32,8126,8126,1]));static Mc=new T(new Uint32Array([2307,2363,56,2366,2368,1,2377,2380,1,2382,2383,1,2434,2435,1,2494,2496,1,2503,2504,1,2507,2508,1,2519,2563,44,2622,2624,1,2691,2750,59,2751,2752,1,2761,2763,2,2764,2818,54,2819,2878,59,2880,2887,7,2888,2891,3,2892,2903,11,3006,3007,1,3009,3010,1,3014,3016,1,3018,3020,1,3031,3073,42,3074,3075,1,3137,3140,1,3202,3203,1,3262,3264,2,3265,3268,1,3271,3272,1,3274,3275,1,3285,3286,1,3315,3330,15,3331,3390,59,3391,3392,1,3398,3400,1,3402,3404,1,3415,3458,43,3459,3535,76,3536,3537,1,3544,3551,1,3570,3571,1,3902,3903,1,3967,4139,172,4140,4145,5,4152,4155,3,4156,4182,26,4183,4194,11,4195,4196,1,4199,4205,1,4227,4228,1,4231,4236,1,4239,4250,11,4251,4252,1,5909,5940,31,6070,6078,8,6079,6085,1,6087,6088,1,6435,6438,1,6441,6443,1,6448,6449,1,6451,6456,1,6681,6682,1,6741,6743,2,6753,6755,2,6756,6765,9,6766,6770,1,6916,6965,49,6971,6973,2,6974,6977,1,6979,6980,1,7042,7073,31,7078,7079,1,7082,7143,61,7146,7148,1,7150,7154,4,7155,7204,49,7205,7211,1,7220,7221,1,7393,7415,22,12334,12335,1,43043,43044,1,43047,43136,89,43137,43188,51,43189,43203,1,43346,43347,1,43395,43444,49,43445,43450,5,43451,43454,3,43455,43456,1,43567,43568,1,43571,43572,1,43597,43643,46,43645,43755,110,43758,43759,1,43765,44003,238,44004,44006,2,44007,44009,2,44010,44012,2,69632,69634,2,69762,69808,46,69809,69810,1,69815,69816,1,69932,69957,25,69958,70018,60,70067,70069,1,70079,70080,1,70094,70188,94,70189,70190,1,70194,70195,1,70197,70368,171,70369,70370,1,70402,70403,1,70462,70463,1,70465,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70584,85,70585,70586,1,70594,70597,3,70599,70602,1,70604,70605,1,70607,70709,102,70710,70711,1,70720,70721,1,70725,70832,107,70833,70834,1,70841,70843,2,70844,70846,1,70849,71087,238,71088,71089,1,71096,71099,1,71102,71216,114,71217,71218,1,71227,71228,1,71230,71340,110,71342,71343,1,71350,71454,104,71456,71457,1,71462,71724,262,71725,71726,1,71736,71984,248,71985,71989,1,71991,71992,1,71997,72e3,3,72002,72145,143,72146,72147,1,72156,72159,1,72164,72249,85,72279,72280,1,72343,72751,408,72766,72873,107,72881,72884,3,73098,73102,1,73107,73108,1,73110,73461,351,73462,73475,13,73524,73525,1,73534,73535,1,73537,90410,16873,90411,90412,1,94033,94087,1,94192,94193,1,119141,119142,1,119149,119154,1]));static Me=new T(new Uint32Array([1160,1161,1,6846,8413,1567,8414,8416,1,8418,8420,1,42608,42610,1]));static Mn=new T(new Uint32Array([768,879,1,1155,1159,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2306,1,2362,2364,2,2369,2376,1,2381,2385,4,2386,2391,1,2402,2403,1,2433,2492,59,2497,2500,1,2509,2530,21,2531,2558,27,2561,2562,1,2620,2625,5,2626,2631,5,2632,2635,3,2636,2637,1,2641,2672,31,2673,2677,4,2689,2690,1,2748,2753,5,2754,2757,1,2759,2760,1,2765,2786,21,2787,2810,23,2811,2815,1,2817,2876,59,2879,2881,2,2882,2884,1,2893,2901,8,2902,2914,12,2915,2946,31,3008,3021,13,3072,3076,4,3132,3134,2,3135,3136,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3260,59,3263,3270,7,3276,3277,1,3298,3299,1,3328,3329,1,3387,3388,1,3393,3396,1,3405,3426,21,3427,3457,30,3530,3538,8,3539,3540,1,3542,3633,91,3636,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3953,3966,1,3968,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4141,103,4142,4144,1,4146,4151,1,4153,4154,1,4157,4158,1,4184,4185,1,4190,4192,1,4209,4212,1,4226,4229,3,4230,4237,7,4253,4957,704,4958,4959,1,5906,5908,1,5938,5939,1,5970,5971,1,6002,6003,1,6068,6069,1,6071,6077,1,6086,6089,3,6090,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6434,1,6439,6440,1,6450,6457,7,6458,6459,1,6679,6680,1,6683,6742,59,6744,6750,1,6752,6754,2,6757,6764,1,6771,6780,1,6783,6832,49,6833,6845,1,6847,6862,1,6912,6915,1,6964,6966,2,6967,6970,1,6972,6978,6,7019,7027,1,7040,7041,1,7074,7077,1,7080,7081,1,7083,7085,1,7142,7144,2,7145,7149,4,7151,7153,1,7212,7219,1,7222,7223,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8400,8412,1,8417,8421,4,8422,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12333,1,12441,12442,1,42607,42612,5,42613,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43045,26,43046,43052,6,43204,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43345,1,43392,43394,1,43443,43446,3,43447,43449,1,43452,43453,1,43493,43561,68,43562,43566,1,43569,43570,1,43573,43574,1,43587,43596,9,43644,43696,52,43698,43700,1,43703,43704,1,43710,43711,1,43713,43756,43,43757,43766,9,44005,44008,3,44013,64286,20273,65024,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69633,69688,55,69689,69702,1,69744,69747,3,69748,69759,11,69760,69761,1,69811,69814,1,69817,69818,1,69826,69888,62,69889,69890,1,69927,69931,1,69933,69940,1,70003,70016,13,70017,70070,53,70071,70078,1,70089,70092,1,70095,70191,96,70192,70193,1,70196,70198,2,70199,70206,7,70209,70367,158,70371,70378,1,70400,70401,1,70459,70460,1,70464,70502,38,70503,70508,1,70512,70516,1,70587,70592,1,70606,70610,2,70625,70626,1,70712,70719,1,70722,70724,1,70726,70750,24,70835,70840,1,70842,70847,5,70848,70850,2,70851,71090,239,71091,71093,1,71100,71101,1,71103,71104,1,71132,71133,1,71219,71226,1,71229,71231,2,71232,71339,107,71341,71344,3,71345,71349,1,71351,71453,102,71455,71458,3,71459,71461,1,71463,71467,1,71727,71735,1,71737,71738,1,71995,71996,1,71998,72003,5,72148,72151,1,72154,72155,1,72160,72193,33,72194,72202,1,72243,72248,1,72251,72254,1,72263,72273,10,72274,72278,1,72281,72283,1,72330,72342,1,72344,72345,1,72752,72758,1,72760,72765,1,72767,72850,83,72851,72871,1,72874,72880,1,72882,72883,1,72885,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73104,73,73105,73109,4,73111,73459,348,73460,73472,12,73473,73526,53,73527,73530,1,73536,73538,2,73562,78912,5350,78919,78933,1,90398,90409,1,90413,90415,1,92912,92916,1,92976,92982,1,94031,94095,64,94096,94098,1,94180,113821,19641,113822,118528,4706,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldMn=new T(new Uint32Array([921,953,32,8126,8126,1]));static N=new T(new Uint32Array([48,57,1,178,179,1,185,188,3,189,190,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2548,2553,1,2662,2671,1,2790,2799,1,2918,2927,1,2930,2935,1,3046,3058,1,3174,3183,1,3192,3198,1,3302,3311,1,3416,3422,1,3430,3448,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3891,1,4160,4169,1,4240,4249,1,4969,4988,1,5870,5872,1,6112,6121,1,6128,6137,1,6160,6169,1,6470,6479,1,6608,6618,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,8304,8308,4,8309,8313,1,8320,8329,1,8528,8578,1,8581,8585,1,9312,9371,1,9450,9471,1,10102,10131,1,11517,12295,778,12321,12329,1,12344,12346,1,12690,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,42528,42537,1,42726,42735,1,43056,43061,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,65799,65843,1,65856,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,66369,66378,9,66513,66517,1,66720,66729,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,68912,68921,1,68928,68937,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70113,70132,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71483,1,71904,71922,1,72016,72025,1,72688,72697,1,72784,72812,1,73040,73049,1,73120,73129,1,73552,73561,1,73664,73684,1,74752,74862,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93019,93025,1,93552,93561,1,93824,93846,1,118e3,118009,1,119488,119507,1,119520,119539,1,119648,119672,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125127,125135,1,125264,125273,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1,130032,130041,1]));static Nd=new T(new Uint32Array([48,57,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2662,2671,1,2790,2799,1,2918,2927,1,3046,3055,1,3174,3183,1,3302,3311,1,3430,3439,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3881,1,4160,4169,1,4240,4249,1,6112,6121,1,6160,6169,1,6470,6479,1,6608,6617,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,42528,42537,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,66720,66729,1,68912,68921,1,68928,68937,1,69734,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71481,1,71904,71913,1,72016,72025,1,72688,72697,1,72784,72793,1,73040,73049,1,73120,73129,1,73552,73561,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93552,93561,1,118e3,118009,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125264,125273,1,130032,130041,1]));static Nl=new T(new Uint32Array([5870,5872,1,8544,8578,1,8581,8584,1,12295,12321,26,12322,12329,1,12344,12346,1,42726,42735,1,65856,65908,1,66369,66378,9,66513,66517,1,74752,74862,1]));static No=new T(new Uint32Array([178,179,1,185,188,3,189,190,1,2548,2553,1,2930,2935,1,3056,3058,1,3192,3198,1,3416,3422,1,3440,3448,1,3882,3891,1,4969,4988,1,6128,6137,1,6618,8304,1686,8308,8313,1,8320,8329,1,8528,8543,1,8585,9312,727,9313,9371,1,9450,9471,1,10102,10131,1,11517,12690,1173,12691,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,43056,43061,1,65799,65843,1,65909,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69733,1,70113,70132,1,71482,71483,1,71914,71922,1,72794,72812,1,73664,73684,1,93019,93025,1,93824,93846,1,119488,119507,1,119520,119539,1,119648,119672,1,125127,125135,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1]));static P=new T(new Uint32Array([33,35,1,37,42,1,44,47,1,58,59,1,63,64,1,91,93,1,95,123,28,125,161,36,167,171,4,182,183,1,187,191,4,894,903,9,1370,1375,1,1417,1418,1,1470,1472,2,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3898,38,3899,3901,1,3973,4048,75,4049,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5120,5742,622,5787,5788,1,5867,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8208,829,8209,8231,1,8240,8259,1,8261,8273,1,8275,8286,1,8317,8318,1,8333,8334,1,8968,8971,1,9001,9002,1,10088,10101,1,10181,10182,1,10214,10223,1,10627,10648,1,10712,10715,1,10748,10749,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11822,1,11824,11855,1,11858,11869,1,12289,12291,1,12296,12305,1,12308,12319,1,12336,12349,13,12448,12539,91,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,64830,20819,64831,65040,209,65041,65049,1,65072,65106,1,65108,65121,1,65123,65128,5,65130,65131,1,65281,65283,1,65285,65290,1,65292,65295,1,65306,65307,1,65311,65312,1,65339,65341,1,65343,65371,28,65373,65375,2,65376,65381,1,65792,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,68974,69293,319,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Pc=new T(new Uint32Array([95,8255,8160,8256,8276,20,65075,65076,1,65101,65103,1,65343,65343,1]));static Pd=new T(new Uint32Array([45,1418,1373,1470,5120,3650,6150,8208,2058,8209,8213,1,11799,11802,3,11834,11835,1,11840,11869,29,12316,12336,20,12448,65073,52625,65074,65112,38,65123,65293,170,68974,69293,319]));static Pe=new T(new Uint32Array([41,93,52,125,3899,3774,3901,5788,1887,8262,8318,56,8334,8969,635,8971,9002,31,10089,10101,2,10182,10215,33,10217,10223,2,10628,10648,2,10713,10715,2,10749,11811,1062,11813,11817,2,11862,11868,2,12297,12305,2,12309,12315,2,12318,12319,1,64830,65048,218,65078,65092,2,65096,65114,18,65116,65118,2,65289,65341,52,65373,65379,3]));static Pf=new T(new Uint32Array([187,8217,8030,8221,8250,29,11779,11781,2,11786,11789,3,11805,11809,4]));static Pi=new T(new Uint32Array([171,8216,8045,8219,8220,1,8223,8249,26,11778,11780,2,11785,11788,3,11804,11808,4]));static Po=new T(new Uint32Array([33,35,1,37,39,1,42,46,2,47,58,11,59,63,4,64,92,28,161,167,6,182,183,1,191,894,703,903,1370,467,1371,1375,1,1417,1472,55,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3973,113,4048,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5742,5867,125,5868,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6149,1,6151,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8214,835,8215,8224,9,8225,8231,1,8240,8248,1,8251,8254,1,8257,8259,1,8263,8273,1,8275,8277,2,8278,8286,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11782,5,11783,11784,1,11787,11790,3,11791,11798,1,11800,11801,1,11803,11806,3,11807,11818,11,11819,11822,1,11824,11833,1,11836,11839,1,11841,11843,2,11844,11855,1,11858,11860,1,12289,12291,1,12349,12539,190,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,65040,21029,65041,65046,1,65049,65072,23,65093,65094,1,65097,65100,1,65104,65106,1,65108,65111,1,65119,65121,1,65128,65130,2,65131,65281,150,65282,65283,1,65285,65287,1,65290,65294,2,65295,65306,11,65307,65311,4,65312,65340,28,65377,65380,3,65381,65792,411,65793,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Ps=new T(new Uint32Array([40,91,51,123,3898,3775,3900,5787,1887,8218,8222,4,8261,8317,56,8333,8968,635,8970,9001,31,10088,10100,2,10181,10214,33,10216,10222,2,10627,10647,2,10712,10714,2,10748,11810,1062,11812,11816,2,11842,11861,19,11863,11867,2,12296,12304,2,12308,12314,2,12317,64831,52514,65047,65077,30,65079,65091,2,65095,65113,18,65115,65117,2,65288,65339,51,65371,65375,4,65378,65378,1]));static S=new T(new Uint32Array([36,43,7,60,62,1,94,96,2,124,126,2,162,166,1,168,169,1,172,174,2,175,177,1,180,184,4,215,247,32,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,1014,113,1154,1421,267,1422,1423,1,1542,1544,1,1547,1550,3,1551,1758,207,1769,1789,20,1790,2038,248,2046,2047,1,2184,2546,362,2547,2554,7,2555,2801,246,2928,3059,131,3060,3066,1,3199,3407,208,3449,3647,198,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6107,366,6464,6622,158,6623,6655,1,7009,7018,1,7028,7036,1,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,8260,8274,14,8314,8316,1,8330,8332,1,8352,8384,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8472,1,8478,8483,1,8485,8489,2,8494,8506,12,8507,8512,5,8513,8516,1,8522,8525,1,8527,8586,59,8587,8592,5,8593,8967,1,8972,9e3,1,9003,9257,1,9280,9290,1,9372,9449,1,9472,10087,1,10132,10180,1,10183,10213,1,10224,10626,1,10649,10711,1,10716,10747,1,10750,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12443,12444,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,42752,42774,1,42784,42785,1,42889,42890,1,43048,43051,1,43062,43065,1,43639,43641,1,43867,43882,15,43883,64297,20414,64434,64450,1,64832,64847,1,64975,65020,45,65021,65023,1,65122,65124,2,65125,65126,1,65129,65284,155,65291,65308,17,65309,65310,1,65342,65344,2,65372,65374,2,65504,65510,1,65512,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,69006,710,69007,71487,2480,73685,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,123647,432,126124,126128,4,126254,126704,450,126705,126976,271,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Sc=new T(new Uint32Array([36,162,126,163,165,1,1423,1547,124,2046,2047,1,2546,2547,1,2555,2801,246,3065,3647,582,6107,8352,2245,8353,8384,1,43064,65020,21956,65129,65284,155,65504,65505,1,65509,65510,1,73693,73696,1,123647,126128,2481]));static Sk=new T(new Uint32Array([94,96,2,168,175,7,180,184,4,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,2184,1283,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,12443,12444,1,42752,42774,1,42784,42785,1,42889,42890,1,43867,43882,15,43883,64434,20551,64435,64450,1,65342,65344,2,65507,127995,62488,127996,127999,1]));static Sm=new T(new Uint32Array([43,60,17,61,62,1,124,126,2,172,177,5,215,247,32,1014,1542,528,1543,1544,1,8260,8274,14,8314,8316,1,8330,8332,1,8472,8512,40,8513,8516,1,8523,8592,69,8593,8596,1,8602,8603,1,8608,8614,3,8622,8654,32,8655,8658,3,8660,8692,32,8693,8959,1,8992,8993,1,9084,9115,31,9116,9139,1,9180,9185,1,9655,9665,10,9720,9727,1,9839,10176,337,10177,10180,1,10183,10213,1,10224,10239,1,10496,10626,1,10649,10711,1,10716,10747,1,10750,11007,1,11056,11076,1,11079,11084,1,64297,65122,825,65124,65126,1,65291,65308,17,65309,65310,1,65372,65374,2,65506,65513,7,65514,65516,1,69006,69007,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,126704,126705,1]));static So=new T(new Uint32Array([166,169,3,174,176,2,1154,1421,267,1422,1550,128,1551,1758,207,1769,1789,20,1790,2038,248,2554,2928,374,3059,3064,1,3066,3199,133,3407,3449,42,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6464,723,6622,6655,1,7009,7018,1,7028,7036,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8478,7,8479,8483,1,8485,8489,2,8494,8506,12,8507,8522,15,8524,8525,1,8527,8586,59,8587,8597,10,8598,8601,1,8604,8607,1,8609,8610,1,8612,8613,1,8615,8621,1,8623,8653,1,8656,8657,1,8659,8661,2,8662,8691,1,8960,8967,1,8972,8991,1,8994,9e3,1,9003,9083,1,9085,9114,1,9140,9179,1,9186,9257,1,9280,9290,1,9372,9449,1,9472,9654,1,9656,9664,1,9666,9719,1,9728,9838,1,9840,10087,1,10132,10175,1,10240,10495,1,11008,11055,1,11077,11078,1,11085,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,43048,43051,1,43062,43063,1,43065,43639,574,43640,43641,1,64832,64847,1,64975,65021,46,65022,65023,1,65508,65512,4,65517,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,71487,3191,73685,73692,1,73697,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,126124,2909,126254,126976,722,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,127994,1,128e3,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Z=new T(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8232,8233,1,8239,8287,48,12288,12288,1]));static Zl=new T(new Uint32Array([8232,8232,1]));static Zp=new T(new Uint32Array([8233,8233,1]));static Zs=new T(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8239,8287,48,12288,12288,1]));static Adlam=new T(new Uint32Array([125184,125259,1,125264,125273,1,125278,125279,1]));static Ahom=new T(new Uint32Array([71424,71450,1,71453,71467,1,71472,71494,1]));static Anatolian_Hieroglyphs=new T(new Uint32Array([82944,83526,1]));static Arabic=new T(new Uint32Array([1536,1540,1,1542,1547,1,1549,1562,1,1564,1566,1,1568,1599,1,1601,1610,1,1622,1647,1,1649,1756,1,1758,1791,1,1872,1919,1,2160,2190,1,2192,2193,1,2199,2273,1,2275,2303,1,64336,64450,1,64467,64829,1,64832,64911,1,64914,64967,1,64975,65008,33,65009,65023,1,65136,65140,1,65142,65276,1,69216,69246,1,69314,69316,1,69372,69375,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1]));static Armenian=new T(new Uint32Array([1329,1366,1,1369,1418,1,1421,1423,1,64275,64279,1]));static Avestan=new T(new Uint32Array([68352,68405,1,68409,68415,1]));static Balinese=new T(new Uint32Array([6912,6988,1,6990,7039,1]));static Bamum=new T(new Uint32Array([42656,42743,1,92160,92728,1]));static Bassa_Vah=new T(new Uint32Array([92880,92909,1,92912,92917,1]));static Batak=new T(new Uint32Array([7104,7155,1,7164,7167,1]));static Bengali=new T(new Uint32Array([2432,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1]));static Bhaiksuki=new T(new Uint32Array([72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1]));static Bopomofo=new T(new Uint32Array([746,747,1,12549,12591,1,12704,12735,1]));static Brahmi=new T(new Uint32Array([69632,69709,1,69714,69749,1,69759,69759,1]));static Braille=new T(new Uint32Array([10240,10495,1]));static Buginese=new T(new Uint32Array([6656,6683,1,6686,6687,1]));static Buhid=new T(new Uint32Array([5952,5971,1]));static Canadian_Aboriginal=new T(new Uint32Array([5120,5759,1,6320,6389,1,72368,72383,1]));static Carian=new T(new Uint32Array([66208,66256,1]));static Caucasian_Albanian=new T(new Uint32Array([66864,66915,1,66927,66927,1]));static Chakma=new T(new Uint32Array([69888,69940,1,69942,69959,1]));static Cham=new T(new Uint32Array([43520,43574,1,43584,43597,1,43600,43609,1,43612,43615,1]));static Cherokee=new T(new Uint32Array([5024,5109,1,5112,5117,1,43888,43967,1]));static Chorasmian=new T(new Uint32Array([69552,69579,1]));static Common=new T(new Uint32Array([0,64,1,91,96,1,123,169,1,171,185,1,187,191,1,215,247,32,697,735,1,741,745,1,748,767,1,884,894,10,901,903,2,1541,1548,7,1563,1567,4,1600,1757,157,2274,2404,130,2405,3647,1242,4053,4056,1,4347,5867,1520,5868,5869,1,5941,5942,1,6146,6147,1,6149,7379,1230,7393,7401,8,7402,7404,1,7406,7411,1,7413,7415,1,7418,8192,774,8193,8203,1,8206,8292,1,8294,8304,1,8308,8318,1,8320,8334,1,8352,8384,1,8448,8485,1,8487,8489,1,8492,8497,1,8499,8525,1,8527,8543,1,8585,8587,1,8592,9257,1,9280,9290,1,9312,10239,1,10496,11123,1,11126,11157,1,11159,11263,1,11776,11869,1,12272,12292,1,12294,12296,2,12297,12320,1,12336,12343,1,12348,12351,1,12443,12444,1,12448,12539,91,12540,12688,148,12689,12703,1,12736,12773,1,12783,12832,49,12833,12895,1,12927,13007,1,13055,13144,89,13145,13311,1,19904,19967,1,42752,42785,1,42888,42890,1,43056,43065,1,43310,43471,161,43867,43882,15,43883,64830,20947,64831,65040,209,65041,65049,1,65072,65106,1,65108,65126,1,65128,65131,1,65279,65281,2,65282,65312,1,65339,65344,1,65371,65381,1,65392,65438,46,65439,65504,65,65505,65510,1,65512,65518,1,65529,65533,1,65792,65794,1,65799,65843,1,65847,65855,1,65936,65948,1,66e3,66044,1,66273,66299,1,113824,113827,1,117760,118009,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119142,1,119146,119162,1,119171,119172,1,119180,119209,1,119214,119274,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,120831,1,126065,126132,1,126209,126269,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127487,1,127489,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,917505,917536,31,917537,917631,1]));static foldCommon=new T(new Uint32Array([924,956,32]));static Coptic=new T(new Uint32Array([994,1007,1,11392,11507,1,11513,11519,1]));static Cuneiform=new T(new Uint32Array([73728,74649,1,74752,74862,1,74864,74868,1,74880,75075,1]));static Cypriot=new T(new Uint32Array([67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3]));static Cypro_Minoan=new T(new Uint32Array([77712,77810,1]));static Cyrillic=new T(new Uint32Array([1024,1156,1,1159,1327,1,7296,7306,1,7467,7544,77,11744,11775,1,42560,42655,1,65070,65071,1,122928,122989,1,123023,123023,1]));static Deseret=new T(new Uint32Array([66560,66639,1]));static Devanagari=new T(new Uint32Array([2304,2384,1,2389,2403,1,2406,2431,1,43232,43263,1,72448,72457,1]));static Dives_Akuru=new T(new Uint32Array([71936,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1]));static Dogra=new T(new Uint32Array([71680,71739,1]));static Duployan=new T(new Uint32Array([113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1]));static Egyptian_Hieroglyphs=new T(new Uint32Array([77824,78933,1,78944,82938,1]));static Elbasan=new T(new Uint32Array([66816,66855,1]));static Elymaic=new T(new Uint32Array([69600,69622,1]));static Ethiopic=new T(new Uint32Array([4608,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,124896,124902,1,124904,124907,1,124909,124910,1,124912,124926,1]));static Garay=new T(new Uint32Array([68928,68965,1,68969,68997,1,69006,69007,1]));static Georgian=new T(new Uint32Array([4256,4293,1,4295,4301,6,4304,4346,1,4348,4351,1,7312,7354,1,7357,7359,1,11520,11557,1,11559,11565,6]));static Glagolitic=new T(new Uint32Array([11264,11359,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1]));static Gothic=new T(new Uint32Array([66352,66378,1]));static Grantha=new T(new Uint32Array([70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70460,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1]));static Greek=new T(new Uint32Array([880,883,1,885,887,1,890,893,1,895,900,5,902,904,2,905,906,1,908,910,2,911,929,1,931,993,1,1008,1023,1,7462,7466,1,7517,7521,1,7526,7530,1,7615,7936,321,7937,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8486,43877,35391,65856,65934,1,65952,119296,53344,119297,119365,1]));static foldGreek=new T(new Uint32Array([181,837,656]));static Gujarati=new T(new Uint32Array([2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1]));static Gunjala_Gondi=new T(new Uint32Array([73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1]));static Gurmukhi=new T(new Uint32Array([2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1]));static Gurung_Khema=new T(new Uint32Array([90368,90425,1]));static Han=new T(new Uint32Array([11904,11929,1,11931,12019,1,12032,12245,1,12293,12295,2,12321,12329,1,12344,12347,1,13312,19903,1,19968,40959,1,63744,64109,1,64112,64217,1,94178,94179,1,94192,94193,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Hangul=new T(new Uint32Array([4352,4607,1,12334,12335,1,12593,12686,1,12800,12830,1,12896,12926,1,43360,43388,1,44032,55203,1,55216,55238,1,55243,55291,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1]));static Hanifi_Rohingya=new T(new Uint32Array([68864,68903,1,68912,68921,1]));static Hanunoo=new T(new Uint32Array([5920,5940,1]));static Hatran=new T(new Uint32Array([67808,67826,1,67828,67829,1,67835,67839,1]));static Hebrew=new T(new Uint32Array([1425,1479,1,1488,1514,1,1519,1524,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64335,1]));static Hiragana=new T(new Uint32Array([12353,12438,1,12445,12447,1,110593,110879,1,110898,110928,30,110929,110930,1,127488,127488,1]));static Imperial_Aramaic=new T(new Uint32Array([67648,67669,1,67671,67679,1]));static Inherited=new T(new Uint32Array([768,879,1,1157,1158,1,1611,1621,1,1648,2385,737,2386,2388,1,6832,6862,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8204,8205,1,8400,8432,1,12330,12333,1,12441,12442,1,65024,65039,1,65056,65069,1,66045,66272,227,70459,118528,48069,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,917760,917999,1]));static foldInherited=new T(new Uint32Array([921,953,32,8126,8126,1]));static Inscriptional_Pahlavi=new T(new Uint32Array([68448,68466,1,68472,68479,1]));static Inscriptional_Parthian=new T(new Uint32Array([68416,68437,1,68440,68447,1]));static Javanese=new T(new Uint32Array([43392,43469,1,43472,43481,1,43486,43487,1]));static Kaithi=new T(new Uint32Array([69760,69826,1,69837,69837,1]));static Kannada=new T(new Uint32Array([3200,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1]));static Katakana=new T(new Uint32Array([12449,12538,1,12541,12543,1,12784,12799,1,13008,13054,1,13056,13143,1,65382,65391,1,65393,65437,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110880,288,110881,110882,1,110933,110948,15,110949,110951,1]));static Kawi=new T(new Uint32Array([73472,73488,1,73490,73530,1,73534,73562,1]));static Kayah_Li=new T(new Uint32Array([43264,43309,1,43311,43311,1]));static Kharoshthi=new T(new Uint32Array([68096,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1]));static Khitan_Small_Script=new T(new Uint32Array([94180,101120,6940,101121,101589,1,101631,101631,1]));static Khmer=new T(new Uint32Array([6016,6109,1,6112,6121,1,6128,6137,1,6624,6655,1]));static Khojki=new T(new Uint32Array([70144,70161,1,70163,70209,1]));static Khudawadi=new T(new Uint32Array([70320,70378,1,70384,70393,1]));static Kirat_Rai=new T(new Uint32Array([93504,93561,1]));static Lao=new T(new Uint32Array([3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1]));static Latin=new T(new Uint32Array([65,90,1,97,122,1,170,186,16,192,214,1,216,246,1,248,696,1,736,740,1,7424,7461,1,7468,7516,1,7522,7525,1,7531,7543,1,7545,7614,1,7680,7935,1,8305,8319,14,8336,8348,1,8490,8491,1,8498,8526,28,8544,8584,1,11360,11391,1,42786,42887,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43007,1,43824,43866,1,43868,43876,1,43878,43881,1,64256,64262,1,65313,65338,1,65345,65370,1,67456,67461,1,67463,67504,1,67506,67514,1,122624,122654,1,122661,122666,1]));static Lepcha=new T(new Uint32Array([7168,7223,1,7227,7241,1,7245,7247,1]));static Limbu=new T(new Uint32Array([6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6479,1]));static Linear_A=new T(new Uint32Array([67072,67382,1,67392,67413,1,67424,67431,1]));static Linear_B=new T(new Uint32Array([65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1]));static Lisu=new T(new Uint32Array([42192,42239,1,73648,73648,1]));static Lycian=new T(new Uint32Array([66176,66204,1]));static Lydian=new T(new Uint32Array([67872,67897,1,67903,67903,1]));static Mahajani=new T(new Uint32Array([69968,70006,1]));static Makasar=new T(new Uint32Array([73440,73464,1]));static Malayalam=new T(new Uint32Array([3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1]));static Mandaic=new T(new Uint32Array([2112,2139,1,2142,2142,1]));static Manichaean=new T(new Uint32Array([68288,68326,1,68331,68342,1]));static Marchen=new T(new Uint32Array([72816,72847,1,72850,72871,1,72873,72886,1]));static Masaram_Gondi=new T(new Uint32Array([72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1]));static Medefaidrin=new T(new Uint32Array([93760,93850,1]));static Meetei_Mayek=new T(new Uint32Array([43744,43766,1,43968,44013,1,44016,44025,1]));static Mende_Kikakui=new T(new Uint32Array([124928,125124,1,125127,125142,1]));static Meroitic_Cursive=new T(new Uint32Array([68e3,68023,1,68028,68047,1,68050,68095,1]));static Meroitic_Hieroglyphs=new T(new Uint32Array([67968,67999,1]));static Miao=new T(new Uint32Array([93952,94026,1,94031,94087,1,94095,94111,1]));static Modi=new T(new Uint32Array([71168,71236,1,71248,71257,1]));static Mongolian=new T(new Uint32Array([6144,6145,1,6148,6150,2,6151,6169,1,6176,6264,1,6272,6314,1,71264,71276,1]));static Mro=new T(new Uint32Array([92736,92766,1,92768,92777,1,92782,92783,1]));static Multani=new T(new Uint32Array([70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1]));static Myanmar=new T(new Uint32Array([4096,4255,1,43488,43518,1,43616,43647,1,71376,71395,1]));static Nabataean=new T(new Uint32Array([67712,67742,1,67751,67759,1]));static Nag_Mundari=new T(new Uint32Array([124112,124153,1]));static Nandinagari=new T(new Uint32Array([72096,72103,1,72106,72151,1,72154,72164,1]));static New_Tai_Lue=new T(new Uint32Array([6528,6571,1,6576,6601,1,6608,6618,1,6622,6623,1]));static Newa=new T(new Uint32Array([70656,70747,1,70749,70753,1]));static Nko=new T(new Uint32Array([1984,2042,1,2045,2047,1]));static Nushu=new T(new Uint32Array([94177,110960,16783,110961,111355,1]));static Nyiakeng_Puachue_Hmong=new T(new Uint32Array([123136,123180,1,123184,123197,1,123200,123209,1,123214,123215,1]));static Ogham=new T(new Uint32Array([5760,5788,1]));static Ol_Chiki=new T(new Uint32Array([7248,7295,1]));static Ol_Onal=new T(new Uint32Array([124368,124410,1,124415,124415,1]));static Old_Hungarian=new T(new Uint32Array([68736,68786,1,68800,68850,1,68858,68863,1]));static Old_Italic=new T(new Uint32Array([66304,66339,1,66349,66351,1]));static Old_North_Arabian=new T(new Uint32Array([68224,68255,1]));static Old_Permic=new T(new Uint32Array([66384,66426,1]));static Old_Persian=new T(new Uint32Array([66464,66499,1,66504,66517,1]));static Old_Sogdian=new T(new Uint32Array([69376,69415,1]));static Old_South_Arabian=new T(new Uint32Array([68192,68223,1]));static Old_Turkic=new T(new Uint32Array([68608,68680,1]));static Old_Uyghur=new T(new Uint32Array([69488,69513,1]));static Oriya=new T(new Uint32Array([2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1]));static Osage=new T(new Uint32Array([66736,66771,1,66776,66811,1]));static Osmanya=new T(new Uint32Array([66688,66717,1,66720,66729,1]));static Pahawh_Hmong=new T(new Uint32Array([92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1]));static Palmyrene=new T(new Uint32Array([67680,67711,1]));static Pau_Cin_Hau=new T(new Uint32Array([72384,72440,1]));static Phags_Pa=new T(new Uint32Array([43072,43127,1]));static Phoenician=new T(new Uint32Array([67840,67867,1,67871,67871,1]));static Psalter_Pahlavi=new T(new Uint32Array([68480,68497,1,68505,68508,1,68521,68527,1]));static Rejang=new T(new Uint32Array([43312,43347,1,43359,43359,1]));static Runic=new T(new Uint32Array([5792,5866,1,5870,5880,1]));static Samaritan=new T(new Uint32Array([2048,2093,1,2096,2110,1]));static Saurashtra=new T(new Uint32Array([43136,43205,1,43214,43225,1]));static Sharada=new T(new Uint32Array([70016,70111,1]));static Shavian=new T(new Uint32Array([66640,66687,1]));static Siddham=new T(new Uint32Array([71040,71093,1,71096,71133,1]));static SignWriting=new T(new Uint32Array([120832,121483,1,121499,121503,1,121505,121519,1]));static Sinhala=new T(new Uint32Array([3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,70113,70132,1]));static Sogdian=new T(new Uint32Array([69424,69465,1]));static Sora_Sompeng=new T(new Uint32Array([69840,69864,1,69872,69881,1]));static Soyombo=new T(new Uint32Array([72272,72354,1]));static Sundanese=new T(new Uint32Array([7040,7103,1,7360,7367,1]));static Sunuwar=new T(new Uint32Array([72640,72673,1,72688,72697,1]));static Syloti_Nagri=new T(new Uint32Array([43008,43052,1]));static Syriac=new T(new Uint32Array([1792,1805,1,1807,1866,1,1869,1871,1,2144,2154,1]));static Tagalog=new T(new Uint32Array([5888,5909,1,5919,5919,1]));static Tagbanwa=new T(new Uint32Array([5984,5996,1,5998,6e3,1,6002,6003,1]));static Tai_Le=new T(new Uint32Array([6480,6509,1,6512,6516,1]));static Tai_Tham=new T(new Uint32Array([6688,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1]));static Tai_Viet=new T(new Uint32Array([43648,43714,1,43739,43743,1]));static Takri=new T(new Uint32Array([71296,71353,1,71360,71369,1]));static Tamil=new T(new Uint32Array([2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,73664,73713,1,73727,73727,1]));static Tangsa=new T(new Uint32Array([92784,92862,1,92864,92873,1]));static Tangut=new T(new Uint32Array([94176,94208,32,94209,100343,1,100352,101119,1,101632,101640,1]));static Telugu=new T(new Uint32Array([3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3199,1]));static Thaana=new T(new Uint32Array([1920,1969,1]));static Thai=new T(new Uint32Array([3585,3642,1,3648,3675,1]));static Tibetan=new T(new Uint32Array([3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4052,1,4057,4058,1]));static Tifinagh=new T(new Uint32Array([11568,11623,1,11631,11632,1,11647,11647,1]));static Tirhuta=new T(new Uint32Array([70784,70855,1,70864,70873,1]));static Todhri=new T(new Uint32Array([67008,67059,1]));static Toto=new T(new Uint32Array([123536,123566,1]));static Tulu_Tigalari=new T(new Uint32Array([70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1]));static Ugaritic=new T(new Uint32Array([66432,66461,1,66463,66463,1]));static Vai=new T(new Uint32Array([42240,42539,1]));static Vithkuqi=new T(new Uint32Array([66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1]));static Wancho=new T(new Uint32Array([123584,123641,1,123647,123647,1]));static Warang_Citi=new T(new Uint32Array([71840,71922,1,71935,71935,1]));static Yezidi=new T(new Uint32Array([69248,69289,1,69291,69293,1,69296,69297,1]));static Yi=new T(new Uint32Array([40960,42124,1,42128,42182,1]));static Zanabazar_Square=new T(new Uint32Array([72192,72263,1]));static CATEGORIES=new Map([["C",I.C],["Cc",I.Cc],["Cf",I.Cf],["Co",I.Co],["Cs",I.Cs],["L",I.L],["Ll",I.Ll],["Lm",I.Lm],["Lo",I.Lo],["Lt",I.Lt],["Lu",I.Lu],["M",I.M],["Mc",I.Mc],["Me",I.Me],["Mn",I.Mn],["N",I.N],["Nd",I.Nd],["Nl",I.Nl],["No",I.No],["P",I.P],["Pc",I.Pc],["Pd",I.Pd],["Pe",I.Pe],["Pf",I.Pf],["Pi",I.Pi],["Po",I.Po],["Ps",I.Ps],["S",I.S],["Sc",I.Sc],["Sk",I.Sk],["Sm",I.Sm],["So",I.So],["Z",I.Z],["Zl",I.Zl],["Zp",I.Zp],["Zs",I.Zs]]);static SCRIPTS=new Map([["Adlam",I.Adlam],["Ahom",I.Ahom],["Anatolian_Hieroglyphs",I.Anatolian_Hieroglyphs],["Arabic",I.Arabic],["Armenian",I.Armenian],["Avestan",I.Avestan],["Balinese",I.Balinese],["Bamum",I.Bamum],["Bassa_Vah",I.Bassa_Vah],["Batak",I.Batak],["Bengali",I.Bengali],["Bhaiksuki",I.Bhaiksuki],["Bopomofo",I.Bopomofo],["Brahmi",I.Brahmi],["Braille",I.Braille],["Buginese",I.Buginese],["Buhid",I.Buhid],["Canadian_Aboriginal",I.Canadian_Aboriginal],["Carian",I.Carian],["Caucasian_Albanian",I.Caucasian_Albanian],["Chakma",I.Chakma],["Cham",I.Cham],["Cherokee",I.Cherokee],["Chorasmian",I.Chorasmian],["Common",I.Common],["Coptic",I.Coptic],["Cuneiform",I.Cuneiform],["Cypriot",I.Cypriot],["Cypro_Minoan",I.Cypro_Minoan],["Cyrillic",I.Cyrillic],["Deseret",I.Deseret],["Devanagari",I.Devanagari],["Dives_Akuru",I.Dives_Akuru],["Dogra",I.Dogra],["Duployan",I.Duployan],["Egyptian_Hieroglyphs",I.Egyptian_Hieroglyphs],["Elbasan",I.Elbasan],["Elymaic",I.Elymaic],["Ethiopic",I.Ethiopic],["Garay",I.Garay],["Georgian",I.Georgian],["Glagolitic",I.Glagolitic],["Gothic",I.Gothic],["Grantha",I.Grantha],["Greek",I.Greek],["Gujarati",I.Gujarati],["Gunjala_Gondi",I.Gunjala_Gondi],["Gurmukhi",I.Gurmukhi],["Gurung_Khema",I.Gurung_Khema],["Han",I.Han],["Hangul",I.Hangul],["Hanifi_Rohingya",I.Hanifi_Rohingya],["Hanunoo",I.Hanunoo],["Hatran",I.Hatran],["Hebrew",I.Hebrew],["Hiragana",I.Hiragana],["Imperial_Aramaic",I.Imperial_Aramaic],["Inherited",I.Inherited],["Inscriptional_Pahlavi",I.Inscriptional_Pahlavi],["Inscriptional_Parthian",I.Inscriptional_Parthian],["Javanese",I.Javanese],["Kaithi",I.Kaithi],["Kannada",I.Kannada],["Katakana",I.Katakana],["Kawi",I.Kawi],["Kayah_Li",I.Kayah_Li],["Kharoshthi",I.Kharoshthi],["Khitan_Small_Script",I.Khitan_Small_Script],["Khmer",I.Khmer],["Khojki",I.Khojki],["Khudawadi",I.Khudawadi],["Kirat_Rai",I.Kirat_Rai],["Lao",I.Lao],["Latin",I.Latin],["Lepcha",I.Lepcha],["Limbu",I.Limbu],["Linear_A",I.Linear_A],["Linear_B",I.Linear_B],["Lisu",I.Lisu],["Lycian",I.Lycian],["Lydian",I.Lydian],["Mahajani",I.Mahajani],["Makasar",I.Makasar],["Malayalam",I.Malayalam],["Mandaic",I.Mandaic],["Manichaean",I.Manichaean],["Marchen",I.Marchen],["Masaram_Gondi",I.Masaram_Gondi],["Medefaidrin",I.Medefaidrin],["Meetei_Mayek",I.Meetei_Mayek],["Mende_Kikakui",I.Mende_Kikakui],["Meroitic_Cursive",I.Meroitic_Cursive],["Meroitic_Hieroglyphs",I.Meroitic_Hieroglyphs],["Miao",I.Miao],["Modi",I.Modi],["Mongolian",I.Mongolian],["Mro",I.Mro],["Multani",I.Multani],["Myanmar",I.Myanmar],["Nabataean",I.Nabataean],["Nag_Mundari",I.Nag_Mundari],["Nandinagari",I.Nandinagari],["New_Tai_Lue",I.New_Tai_Lue],["Newa",I.Newa],["Nko",I.Nko],["Nushu",I.Nushu],["Nyiakeng_Puachue_Hmong",I.Nyiakeng_Puachue_Hmong],["Ogham",I.Ogham],["Ol_Chiki",I.Ol_Chiki],["Ol_Onal",I.Ol_Onal],["Old_Hungarian",I.Old_Hungarian],["Old_Italic",I.Old_Italic],["Old_North_Arabian",I.Old_North_Arabian],["Old_Permic",I.Old_Permic],["Old_Persian",I.Old_Persian],["Old_Sogdian",I.Old_Sogdian],["Old_South_Arabian",I.Old_South_Arabian],["Old_Turkic",I.Old_Turkic],["Old_Uyghur",I.Old_Uyghur],["Oriya",I.Oriya],["Osage",I.Osage],["Osmanya",I.Osmanya],["Pahawh_Hmong",I.Pahawh_Hmong],["Palmyrene",I.Palmyrene],["Pau_Cin_Hau",I.Pau_Cin_Hau],["Phags_Pa",I.Phags_Pa],["Phoenician",I.Phoenician],["Psalter_Pahlavi",I.Psalter_Pahlavi],["Rejang",I.Rejang],["Runic",I.Runic],["Samaritan",I.Samaritan],["Saurashtra",I.Saurashtra],["Sharada",I.Sharada],["Shavian",I.Shavian],["Siddham",I.Siddham],["SignWriting",I.SignWriting],["Sinhala",I.Sinhala],["Sogdian",I.Sogdian],["Sora_Sompeng",I.Sora_Sompeng],["Soyombo",I.Soyombo],["Sundanese",I.Sundanese],["Sunuwar",I.Sunuwar],["Syloti_Nagri",I.Syloti_Nagri],["Syriac",I.Syriac],["Tagalog",I.Tagalog],["Tagbanwa",I.Tagbanwa],["Tai_Le",I.Tai_Le],["Tai_Tham",I.Tai_Tham],["Tai_Viet",I.Tai_Viet],["Takri",I.Takri],["Tamil",I.Tamil],["Tangsa",I.Tangsa],["Tangut",I.Tangut],["Telugu",I.Telugu],["Thaana",I.Thaana],["Thai",I.Thai],["Tibetan",I.Tibetan],["Tifinagh",I.Tifinagh],["Tirhuta",I.Tirhuta],["Todhri",I.Todhri],["Toto",I.Toto],["Tulu_Tigalari",I.Tulu_Tigalari],["Ugaritic",I.Ugaritic],["Vai",I.Vai],["Vithkuqi",I.Vithkuqi],["Wancho",I.Wancho],["Warang_Citi",I.Warang_Citi],["Yezidi",I.Yezidi],["Yi",I.Yi],["Zanabazar_Square",I.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([["L",I.foldL],["Ll",I.foldLl],["Lt",I.foldLt],["Lu",I.foldLu],["M",I.foldM],["Mn",I.foldMn]]);static FOLD_SCRIPT=new Map([["Common",I.foldCommon],["Greek",I.foldGreek],["Inherited",I.foldInherited]]);static Print=new T(new Uint32Array([33,126,1,161,172,1,174,887,1,890,895,1,900,906,1,908,910,2,911,929,1,931,1327,1,1329,1366,1,1369,1418,1,1421,1423,1,1425,1479,1,1488,1514,1,1519,1524,1,1542,1563,1,1565,1756,1,1758,1805,1,1808,1866,1,1869,1969,1,1984,2042,1,2045,2093,1,2096,2110,1,2112,2139,1,2142,2144,2,2145,2154,1,2160,2190,1,2199,2273,1,2275,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1,2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1,2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1,2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1,2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1,3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1,3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,3585,3642,1,3647,3675,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1,3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4058,1,4096,4293,1,4295,4301,6,4304,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,5024,5109,1,5112,5117,1,5120,5759,1,5761,5788,1,5792,5880,1,5888,5909,1,5919,5942,1,5952,5971,1,5984,5996,1,5998,6e3,1,6002,6003,1,6016,6109,1,6112,6121,1,6128,6137,1,6144,6157,1,6159,6169,1,6176,6264,1,6272,6314,1,6320,6389,1,6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6608,6618,1,6622,6683,1,6686,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1,6832,6862,1,6912,6988,1,6990,7155,1,7164,7223,1,7227,7241,1,7245,7306,1,7312,7354,1,7357,7367,1,7376,7418,1,7424,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8208,8231,1,8240,8286,1,8304,8305,1,8308,8334,1,8336,8348,1,8352,8384,1,8400,8432,1,8448,8587,1,8592,9257,1,9280,9290,1,9312,11123,1,11126,11157,1,11159,11507,1,11513,11557,1,11559,11565,6,11568,11623,1,11631,11632,1,11647,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11744,11869,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12289,12351,1,12353,12438,1,12441,12543,1,12549,12591,1,12593,12686,1,12688,12773,1,12783,12830,1,12832,42124,1,42128,42182,1,42192,42539,1,42560,42743,1,42752,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43052,1,43056,43065,1,43072,43127,1,43136,43205,1,43214,43225,1,43232,43347,1,43359,43388,1,43392,43469,1,43471,43481,1,43486,43518,1,43520,43574,1,43584,43597,1,43600,43609,1,43612,43714,1,43739,43766,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43883,1,43888,44013,1,44016,44025,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64450,1,64467,64911,1,64914,64967,1,64975,65008,33,65009,65049,1,65056,65106,1,65108,65126,1,65128,65131,1,65136,65140,1,65142,65276,1,65281,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65504,65510,1,65512,65518,1,65532,65533,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,65792,65794,1,65799,65843,1,65847,65934,1,65936,65948,1,65952,66e3,48,66001,66045,1,66176,66204,1,66208,66256,1,66272,66299,1,66304,66339,1,66349,66378,1,66384,66426,1,66432,66461,1,66463,66499,1,66504,66517,1,66560,66717,1,66720,66729,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66927,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67671,67742,1,67751,67759,1,67808,67826,1,67828,67829,1,67835,67867,1,67871,67897,1,67903,67968,65,67969,68023,1,68028,68047,1,68050,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1,68192,68255,1,68288,68326,1,68331,68342,1,68352,68405,1,68409,68437,1,68440,68466,1,68472,68497,1,68505,68508,1,68521,68527,1,68608,68680,1,68736,68786,1,68800,68850,1,68858,68903,1,68912,68921,1,68928,68965,1,68969,68997,1,69006,69007,1,69216,69246,1,69248,69289,1,69291,69293,1,69296,69297,1,69314,69316,1,69372,69415,1,69424,69465,1,69488,69513,1,69552,69579,1,69600,69622,1,69632,69709,1,69714,69749,1,69759,69820,1,69822,69826,1,69840,69864,1,69872,69881,1,69888,69940,1,69942,69959,1,69968,70006,1,70016,70111,1,70113,70132,1,70144,70161,1,70163,70209,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1,70320,70378,1,70384,70393,1,70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70459,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1,70656,70747,1,70749,70753,1,70784,70855,1,70864,70873,1,71040,71093,1,71096,71133,1,71168,71236,1,71248,71257,1,71264,71276,1,71296,71353,1,71360,71369,1,71376,71395,1,71424,71450,1,71453,71467,1,71472,71494,1,71680,71739,1,71840,71922,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1,72096,72103,1,72106,72151,1,72154,72164,1,72192,72263,1,72272,72354,1,72368,72440,1,72448,72457,1,72640,72673,1,72688,72697,1,72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1,72816,72847,1,72850,72871,1,72873,72886,1,72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1,73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1,73440,73464,1,73472,73488,1,73490,73530,1,73534,73562,1,73648,73664,16,73665,73713,1,73727,74649,1,74752,74862,1,74864,74868,1,74880,75075,1,77712,77810,1,77824,78895,1,78912,78933,1,78944,82938,1,82944,83526,1,90368,90425,1,92160,92728,1,92736,92766,1,92768,92777,1,92782,92862,1,92864,92873,1,92880,92909,1,92912,92917,1,92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1,93504,93561,1,93760,93850,1,93952,94026,1,94031,94087,1,94095,94111,1,94176,94180,1,94192,94193,1,94208,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1,117760,118009,1,118016,118451,1,118528,118573,1,118576,118598,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119154,1,119163,119274,1,119296,119365,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,121483,1,121499,121503,1,121505,121519,1,122624,122654,1,122661,122666,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,122928,122989,1,123023,123136,113,123137,123180,1,123184,123197,1,123200,123209,1,123214,123215,1,123536,123566,1,123584,123641,1,123647,124112,465,124113,124153,1,124368,124410,1,124415,124896,481,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125127,125142,1,125184,125259,1,125264,125273,1,125278,125279,1,126065,126132,1,126209,126269,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1,917760,917999,1]))},me=class{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,t){let r=0,n=e.length;for(;re.getHi(r))continue;let n=e.getLo(r);if(t0&&t>=e.getLo(0)&&this.is32(e,t)}static isUpper(e){if(e<=this.MAX_LATIN1){let t=String.fromCodePoint(e);return t.toUpperCase()===t&&t.toLowerCase()!==t}return this.is(kr.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?e>=32&&e=161&&e!==173:this.is(kr.Print,e)}static simpleFold(e){if(kr.CASE_ORBIT.has(e))return kr.CASE_ORBIT.get(e);let t=U.toLowerCase(e);return t===e?U.toUpperCase(e):t}static equalsIgnoreCase(e,t){if(e<0||t<0||e===t)return!0;if(e<=this.MAX_ASCII&&t<=this.MAX_ASCII)return U.CODES.get("A")<=e&&e<=U.CODES.get("Z")&&(e|=32),U.CODES.get("A")<=t&&t<=U.CODES.get("Z")&&(t|=32),e===t;for(let r=this.simpleFold(e);r!==e;r=this.simpleFold(r))if(r===t)return!0;return!1}},Pe=class{static METACHARACTERS="\\.+*?()|[]{}^$";static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return U.CODES.get("0")<=e&&e<=U.CODES.get("9")||U.CODES.get("a")<=e&&e<=U.CODES.get("z")||U.CODES.get("A")<=e&&e<=U.CODES.get("Z")}static unhex(e){return U.CODES.get("0")<=e&&e<=U.CODES.get("9")?e-U.CODES.get("0"):U.CODES.get("a")<=e&&e<=U.CODES.get("f")?e-U.CODES.get("a")+10:U.CODES.get("A")<=e&&e<=U.CODES.get("F")?e-U.CODES.get("A")+10:-1}static escapeRune(e){let t="";if(me.isPrint(e))this.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(t+="\\"),t+=String.fromCodePoint(e);else switch(e){case U.CODES.get('"'):t+='\\"';break;case U.CODES.get("\\"):t+="\\\\";break;case U.CODES.get(" "):t+="\\t";break;case U.CODES.get(` `):t+="\\n";break;case U.CODES.get("\r"):t+="\\r";break;case U.CODES.get("\b"):t+="\\b";break;case U.CODES.get("\f"):t+="\\f";break;default:{let r=e.toString(16);e<256?(t+="\\x",r.length===1&&(t+="0"),t+=r):t+=`\\x{${r}}`;break}}return t}static stringToRunes(e){return String(e).split("").map(t=>t.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return U.CODES.get("a")<=e&&e<=U.CODES.get("z")||U.CODES.get("A")<=e&&e<=U.CODES.get("Z")||U.CODES.get("0")<=e&&e<=U.CODES.get("9")||e===U.CODES.get("_")}static emptyOpContext(e,t){let r=0;return e<0&&(r|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===U.CODES.get(` `)&&(r|=this.EMPTY_BEGIN_LINE),t<0&&(r|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===U.CODES.get(` `)&&(r|=this.EMPTY_END_LINE),this.isWordRune(e)===this.isWordRune(t)?r|=this.EMPTY_NO_WORD_BOUNDARY:r|=this.EMPTY_WORD_BOUNDARY,r}static quoteMeta(e){return e.split("").map(t=>this.METACHARACTERS.indexOf(t)>=0?`\\${t}`:t).join("")}static charCount(e){return e>me.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let t=[],r=0;for(let n=0;n>6|192,t[r++]=i&63|128):(i&64512)==55296&&n+1>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=i&63|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=i&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder("utf-8").decode(new Uint8Array(e));{let t=[],r=0,n=0;for(;r191&&i<224){let s=e[r++];t[n++]=String.fromCharCode((i&31)<<6|s&63)}else if(i>239&&i<365){let s=e[r++],a=e[r++],o=e[r++],l=((i&7)<<18|(s&63)<<12|(a&63)<<6|o&63)-65536;t[n++]=String.fromCharCode(55296+(l>>10)),t[n++]=String.fromCharCode(56320+(l&1023))}else{let s=e[r++],a=e[r++];t[n++]=String.fromCharCode((i&15)<<12|(s&63)<<6|a&63)}}return t.join("")}}},Go=(e=[],t=0)=>{let r={};for(let n=0;ne.codePointAt(0))}length(){return this.charSequence.length}},es=class{static utf16(e){return new Op(e)}static utf8(e){return Array.isArray(e)?new Ho(e):new Ho(Pe.stringToUtf8ByteArray(e))}},sn=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},Tp=class extends sn{constructor(e,t=0,r=e.length){super(),this.bytes=e,this.start=t,this.end=r}step(e){if(e+=this.start,e>=this.end)return sn.EOF();let t=this.bytes[e++]&255;return t&128?(t&224)==192?(t&=31,e>=this.end?sn.EOF():(t=t<<6|this.bytes[e++]&63,t<<3|2)):(t&240)==224?(t&=15,e+1>=this.end?sn.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|3)):(t&=7,e+2>=this.end?sn.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|4)):t<<3|1}index(e,t){t+=this.start;let r=this.indexOf(this.bytes,e.prefixUTF8,t);return r<0?r:r-t}context(e){e+=this.start;let t=-1;if(e>this.start&&e<=this.end){let n=e-1;if(t=this.bytes[n--],t>=128){let i=e-4;for(i=i&&(this.bytes[n]&192)==128;)n--;n>3}}let r=e>3:-1;return Pe.emptyOpContext(t,r)}indexOf(e,t,r=0){let n=t.length;if(n===0)return-1;let i=e.length;for(let s=r;s<=i-n;s++)for(let a=0;a0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,r=e{let r=t.codePointAt(0);return r===U.CODES.get("\\")||r===U.CODES.get("$")?`\\${t}`:t}).join("")}constructor(e,t){if(e===null)throw Error("pattern is null");this.patternInput=e;let r=this.patternInput.re2();this.patternGroupCount=r.numberOfCapturingGroups(),this.groups=[],this.namedGroups=r.namedGroups,this.numberOfInstructions=r.numberOfInstructions(),t instanceof Dn?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(es.utf8(t)):this.resetMatcherInput(es.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw Error("input is null");return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e=="string"){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Ur(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e=="string"){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Ur(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}programSize(){return this.numberOfInstructions}group(e=0){if(typeof e=="string"){let n=this.namedGroups[e];if(!Number.isFinite(n))throw new Ur(`group '${e}' not found`);e=n}let t=this.start(e),r=this.end(e);return t<0&&r<0?null:this.substring(t,r)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new Ur(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new Ur("perhaps no match attempted");if(e===0||this.hasGroups)return;let t=this.groups[1]+1;t>this.matcherInputLength&&(t=this.matcherInputLength);let r=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!r[0])throw new Ur("inconsistency in matching group data");this.groups=r[1],this.hasGroups=!0}matches(){return this.genMatch(0,K.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,K.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new Ur(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,K.UNANCHORED)}genMatch(e,t){let r=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return r[0]?(this.groups=r[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0):!1}substring(e,t){return this.matcherInput.isUTF8Encoding()?Pe.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let r="",n=this.start(),i=this.end();return this.appendPosU.CODES.get("9")||a*10+s-U.CODES.get("0")>this.patternGroupCount));i++)a=a*10+s-U.CODES.get("0");if(a>this.patternGroupCount)throw new Ur(`n > number of groups: ${a}`);let o=this.group(a);o!==null&&(t+=o),r=i,i--;continue}if(s===U.CODES.get("{")){rU.CODES.get("9")||a*10+s-U.CODES.get("0")>this.patternGroupCount));i++)a=a*10+s-U.CODES.get("0");if(a>this.patternGroupCount){t+=`$${a}`,r=i,i--;continue}let o=this.group(a);o!==null&&(t+=o),r=i,i--;continue}if(s===U.CODES.get("<")){r")&&e.codePointAt(a)!==U.CODES.get(" ");)a++;if(a===e.length||e.codePointAt(a)!==U.CODES.get(">")){t+=e.substring(i-1,a+1),r=a+1;continue}let o=e.substring(i+1,a);Object.prototype.hasOwnProperty.call(this.namedGroups,o)?t+=this.group(o):t+=`$<${o}>`,r=a+1}}return r ${this.out}, ${this.arg}`;case _t.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case _t.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case _t.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case _t.MATCH:return"match";case _t.FAIL:return"fail";case _t.NOP:return`nop -> ${this.out}`;case _t.RUNE:return this.runes===null?"rune ":["rune ",_t.escapeRunes(this.runes),(this.arg&K.FOLD_CASE)===0?"":"/i"," -> ",this.out].join("");case _t.RUNE1:return`rune1 ${_t.escapeRunes(this.runes)} -> ${this.out}`;case _t.RUNE_ANY:return`any -> ${this.out}`;case _t.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw Error("unhandled case in Inst.toString")}}},Lp=class{constructor(){this.inst=null,this.cap=[]}},Vo=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let t=this.sparse[e];return tthis.matchcap.length?this.initNewCap(t):this.resetCap(t)}resetCap(t){for(let r=0;r0?(this.poolSize--,r=this.pool[this.poolSize]):r=new Lp,r.inst=t,r}freeQueue(t,r=0){let n=t.size-r,i=this.poolSize+n;this.pool.length>3,u=o&7,c=-1,p=0;o!==sn.EOF()&&(o=t.step(r+u),c=o>>3,p=o&7);let h;for(h=r===0?Pe.emptyOpContext(-1,l):t.context(r);;){if(s.isEmpty()){if((i&Pe.EMPTY_BEGIN_TEXT)!==0&&r!==0||this.matched)break;if(this.re2.prefix.length!==0&&c!==this.re2.prefixRune&&t.canCheckPrefix()){let m=t.index(this.re2,r);if(m<0)break;r+=m,o=t.step(r),l=o>>3,u=o&7,o=t.step(r+u),c=o>>3,p=o&7}}!this.matched&&(r===0||n===K.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=r),this.add(s,this.prog.start,r,this.matchcap,h,null));let f=r+u;if(h=t.context(f),this.step(s,a,r,f,l,h,n,r===t.endPos()),u===0||this.ncap===0&&this.matched)break;r+=u,l=c,u=p,l!==-1&&(o=t.step(r+u),c=o>>3,p=o&7);let d=s;s=a,a=d}return this.freeQueue(a),this.matched}step(t,r,n,i,s,a,o,l){let u=this.re2.longest;for(let c=0;c0&&this.matchcap[0]0&&(!u||!this.matched||this.matchcap[1]0&&a.cap!==i&&(a.cap=i.slice(0,this.ncap)),t.denseThreads[o]=a,a=null;break;default:throw Error("unhandled")}return a}},Mp=e=>{let t=-2128831035;for(let r=0;r{if(e.length!==t.length)return!1;for(let r=0;r0;){let i=r.pop();if(t.has(i))continue;t.add(i);let s=this.prog.getInst(i);switch(s.op){case ye.MATCH:n=!0;break;case ye.ALT:case ye.ALT_MATCH:r.push(s.out),r.push(s.arg);break;case ye.NOP:case ye.CAPTURE:r.push(s.out);break;case ye.EMPTY_WIDTH:return null}}return{pcs:Int32Array.from(t).sort(),isMatch:n}}getState(e){let t=this.computeClosure(e);if(!t)return null;let r=t.pcs,n=Mp(r),i=this.stateCache.get(n);if(i)for(let a=0;a=this.stateLimit)return this.stateCache.clear(),this.stateCount=0,this.startState=null,null;let s=new _p(r,t.isMatch);return i.push(s),this.stateCount++,s}step(e,t,r){if(r===K.UNANCHORED&&t<=me.MAX_ASCII){let s=e.nextAscii[t];if(s!==null)return s}else{let s=t+(r===K.UNANCHORED?0:me.MAX_RUNE+1);if(e.nextMap.has(s))return e.nextMap.get(s)}let n=[];for(let s=0;s>3,l=a&7;if(l===0)break;if(i=this.step(i,o,r),i===null)return null;if(i.isMatch)if(r===K.ANCHOR_BOTH){if(s+l===n)return!0}else return!0;if(i.nfaStates.length===0&&r!==K.UNANCHORED)return!1;s+=l}return!1}},W=class ge{static Op=Go(["NO_MATCH","EMPTY_MATCH","LITERAL","CHAR_CLASS","ANY_CHAR_NOT_NL","ANY_CHAR","BEGIN_LINE","END_LINE","BEGIN_TEXT","END_TEXT","WORD_BOUNDARY","NO_WORD_BOUNDARY","CAPTURE","STAR","PLUS","QUEST","REPEAT","CONCAT","ALTERNATE","LEFT_PAREN","VERTICAL_BAR"]);static isPseudoOp(t){return t>=ge.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(t){return t===U.CODES.get("-")?"\\":""}static fromRegexp(t){let r=new ge(t.op);return r.flags=t.flags,r.subs=t.subs,r.runes=t.runes,r.cap=t.cap,r.min=t.min,r.max=t.max,r.name=t.name,r.namedGroups=t.namedGroups,r}constructor(t){this.op=t,this.flags=0,this.subs=ge.emptySubs(),this.runes=[],this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=ge.emptySubs(),this.runes=[],this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t="";switch(this.op){case ge.Op.NO_MATCH:t+="[^\\x00-\\x{10FFFF}]";break;case ge.Op.EMPTY_MATCH:t+="(?:)";break;case ge.Op.STAR:case ge.Op.PLUS:case ge.Op.QUEST:case ge.Op.REPEAT:{let r=this.subs[0];switch(r.op>ge.Op.CAPTURE||r.op===ge.Op.LITERAL&&r.runes.length>1?t+=`(?:${r.appendTo()})`:t+=r.appendTo(),this.op){case ge.Op.STAR:t+="*";break;case ge.Op.PLUS:t+="+";break;case ge.Op.QUEST:t+="?";break;case ge.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=",",this.max>=0&&(t+=this.max)),t+="}"}(this.flags&K.NON_GREEDY)!==0&&(t+="?");break}case ge.Op.CONCAT:for(let r of this.subs)r.op===ge.Op.ALTERNATE?t+=`(?:${r.appendTo()})`:t+=r.appendTo();break;case ge.Op.ALTERNATE:{let r="";for(let n of this.subs)t+=r,r="|",t+=n.appendTo();break}case ge.Op.LITERAL:(this.flags&K.FOLD_CASE)!==0&&(t+="(?i:");for(let r of this.runes)t+=Pe.escapeRune(r);(this.flags&K.FOLD_CASE)!==0&&(t+=")");break;case ge.Op.ANY_CHAR_NOT_NL:t+="(?-s:.)";break;case ge.Op.ANY_CHAR:t+="(?s:.)";break;case ge.Op.CAPTURE:this.name===null||this.name.length===0?t+="(":t+=`(?P<${this.name}>`,this.subs[0].op!==ge.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=")";break;case ge.Op.BEGIN_TEXT:t+="\\A";break;case ge.Op.END_TEXT:(this.flags&K.WAS_DOLLAR)===0?t+="\\z":t+="(?-m:$)";break;case ge.Op.BEGIN_LINE:t+="^";break;case ge.Op.END_LINE:t+="$";break;case ge.Op.WORD_BOUNDARY:t+="\\b";break;case ge.Op.NO_WORD_BOUNDARY:t+="\\B";break;case ge.Op.CHAR_CLASS:if(this.runes.length%2!=0){t+="[invalid char class]";break}if(t+="[",this.runes.length===0)t+="^\\x00-\\x{10FFFF}";else if(this.runes[0]===0&&this.runes[this.runes.length-1]===me.MAX_RUNE){t+="^";for(let r=1;r>1];return e&1?t.arg:t.out}patch(e,t){for(;e!==0;){let r=this.inst[e>>1];e&1?(e=r.arg,r.arg=t):(e=r.out,r.out=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let r=e;for(;;){let i=this.next(r);if(i===0)break;r=i}let n=this.inst[r>>1];return r&1?n.arg=t:n.out=t,e}toString(){let e="";for(let t=0;t0){n=[];for(let i=0;it.min){let i=qr.simplify1(W.Op.QUEST,t.flags,r,null);for(let s=t.min+1;s0&&(n+=" ");let s=t[i],a=t[i+1];n+=s===a?`0x${s.toString(16)}`:`0x${s.toString(16)}-0x${a.toString(16)}`}return n+="]",n}static cmp(t,r,n,i){let s=t[r]-n;return s===0?i-t[r+1]:s}static qsortIntPair(t,r,n){let i=((r+n)/2|0)&-2,s=t[i],a=t[i+1],o=r,l=n;for(;o<=l;){for(;or&&En.cmp(t,l,s,a)>0;)l-=2;if(o<=l){if(o!==l){let u=t[o];t[o]=t[l],t[l]=u,u=t[o+1],t[o+1]=t[l+1],t[l+1]=u}o+=2,l-=2}}rthis.r[t-1]&&(this.r[t-1]=i);continue}this.r[t]=n,this.r[t+1]=i,t+=2}return this.len=t,this}appendLiteral(t,r){return(r&K.FOLD_CASE)===0?this.appendRange(t,t):this.appendFoldedRange(t,t)}appendRange(t,r){if(this.len>0){for(let n=2;n<=4;n+=2)if(this.len>=n){let i=this.r[this.len-n],s=this.r[this.len-n+1];if(t<=s+1&&i<=r+1)return ts&&(this.r[this.len-n+1]=r),this}}return this.r[this.len++]=t,this.r[this.len++]=r,this}appendFoldedRange(t,r){if(t<=me.MIN_FOLD&&r>=me.MAX_FOLD||rme.MAX_FOLD)return this.appendRange(t,r);tme.MAX_FOLD&&(this.appendRange(me.MAX_FOLD+1,r),r=me.MAX_FOLD);for(let n=t;n<=r;n++){this.appendRange(n,n);for(let i=me.simpleFold(n);i!==n;i=me.simpleFold(i))this.appendRange(i,i)}return this}appendClass(t){for(let r=0;rme.MAX_FOLD)return t;let r=t,n=t;for(t=me.simpleFold(t);t!==n;t=me.simpleFold(t))r>t&&(r=t);return r}static leadingRegexp(t){if(t.op===W.Op.EMPTY_MATCH)return null;if(t.op===W.Op.CONCAT&&t.subs.length>0){let r=t.subs[0];return r.op===W.Op.EMPTY_MATCH?null:r}return t}static literalRegexp(t,r){let n=new W(W.Op.LITERAL);return n.flags=r,n.runes=Pe.stringToRunes(t),n}static parse(t,r){return new pe(t,r).parseInternal()}static parseRepeat(t){let r=t.pos();if(!t.more()||!t.lookingAt("{"))return-1;t.skip(1);let n=pe.parseInt(t);if(n===-1||!t.more())return-1;let i;if(!t.lookingAt(","))i=n;else{if(t.skip(1),!t.more())return-1;if(t.lookingAt("}"))i=-1;else if((i=pe.parseInt(t))===-1)return-1}if(!t.more()||!t.lookingAt("}"))return-1;if(t.skip(1),n<0||n>1e3||i===-2||i>1e3||i>=0&&n>i)throw new Xe(pe.ERR_INVALID_REPEAT_SIZE,t.from(r));return n<<16|i&me.MAX_BMP}static isValidCaptureName(t){if(t.length===0)return!1;for(let r=0;r=U.CODES.get("0")&&t.peek()<=U.CODES.get("9");)t.skip(1);let n=t.from(r);return n.length===0||n.length>1&&n.codePointAt(0)===U.CODES.get("0")?-1:n.length>8?-2:parseFloat(n,10)}static isCharClass(t){return t.op===W.Op.LITERAL&&t.runes.length===1||t.op===W.Op.CHAR_CLASS||t.op===W.Op.ANY_CHAR_NOT_NL||t.op===W.Op.ANY_CHAR}static matchRune(t,r){switch(t.op){case W.Op.LITERAL:return t.runes.length===1&&t.runes[0]===r;case W.Op.CHAR_CLASS:for(let n=0;nU.CODES.get("7"))break;case U.CODES.get("0"):{let i=n-U.CODES.get("0");for(let s=1;s<3&&!(!t.more()||t.peek()U.CODES.get("7"));s++)i=i*8+t.peek()-U.CODES.get("0"),t.skip(1);return i}case U.CODES.get("x"):{if(!t.more())break;if(n=t.pop(),n===U.CODES.get("{")){let a=0,o=0;for(;;){if(!t.more())break e;if(n=t.pop(),n===U.CODES.get("}"))break;let l=Pe.unhex(n);if(l<0||(o=o*16+l,o>me.MAX_RUNE))break e;a++}if(a===0)break e;return o}let i=Pe.unhex(n);if(!t.more())break;n=t.pop();let s=Pe.unhex(n);if(i<0||s<0)break;return i*16+s}case U.CODES.get("a"):return U.CODES.get("\x07");case U.CODES.get("f"):return U.CODES.get("\f");case U.CODES.get("n"):return U.CODES.get(` `);case U.CODES.get("r"):return U.CODES.get("\r");case U.CODES.get("t"):return U.CODES.get(" ");case U.CODES.get("v"):return U.CODES.get("\v");default:if(n<=me.MAX_ASCII&&!Pe.isalnum(n))return n}throw new Xe(pe.ERR_INVALID_ESCAPE,t.from(r))}static parseClassChar(t,r){if(!t.more())throw new Xe(pe.ERR_MISSING_BRACKET,t.from(r));return t.lookingAt("\\")?pe.parseEscape(t):t.pop()}static concatRunes(t,r){return[...t,...r]}constructor(t,r=0){this.wholeRegexp=t,this.flags=r,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(t){let r=this.free;return r!==null&&r.subs!==null&&r.subs.length>0?(this.free=r.subs[0],r.reinit(),r.op=t):(r=new W(t),this.numRegexp+=1),r}reuse(t){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,t)&&delete this.height[t],t.subs!==null&&t.subs.length>0&&(t.subs[0]=this.free),this.free=t}checkLimits(t){if(this.numRunes>pe.MAX_RUNES)throw new Xe(pe.ERR_LARGE);this.checkSize(t),this.checkHeight(t)}checkSize(t){if(this.size===null){if(this.repeats===0&&(this.repeats=1),t.op===W.Op.REPEAT){let r=t.max;r===-1&&(r=t.min),r<=0&&(r=1),r>pe.MAX_SIZE/this.repeats?this.repeats=pe.MAX_SIZE:this.repeats*=r}if(this.numRegexppe.MAX_SIZE)throw new Xe(pe.ERR_LARGE)}calcSize(t,r=!1){if(!r&&Object.prototype.hasOwnProperty.call(this.size,t))return this.size[t];let n=0;switch(t.op){case W.Op.LITERAL:n=t.runes.length;break;case W.Op.CAPTURE:case W.Op.STAR:n=2+this.calcSize(t.subs[0]);break;case W.Op.PLUS:case W.Op.QUEST:n=1+this.calcSize(t.subs[0]);break;case W.Op.CONCAT:for(let i of t.subs)n+=this.calcSize(i);break;case W.Op.ALTERNATE:for(let i of t.subs)n+=this.calcSize(i);t.subs.length>1&&(n=n+t.subs.length-1);break;case W.Op.REPEAT:{let i=this.calcSize(t.subs[0]);if(t.max===-1){n=t.min===0?2+i:1+t.min*i;break}n=t.max*i+(t.max-t.min);break}}return n=Math.max(1,n),this.size[t]=n,n}checkHeight(t){if(!(this.numRegexppe.MAX_HEIGHT)throw new Xe(pe.ERR_NESTING_DEPTH)}}calcHeight(t,r=!1){if(!r&&Object.prototype.hasOwnProperty.call(this.height,t))return this.height[t];let n=1;for(let i of t.subs){let s=this.calcHeight(i);n<1+s&&(n=1+s)}return this.height[t]=n,n}pop(){return this.stack.pop()}popToPseudo(){let t=this.stack.length,r=t;for(;r>0&&!W.isPseudoOp(this.stack[r-1].op);)r--;let n=this.stack.slice(r,t);return this.stack=this.stack.slice(0,r),n}push(t){if(this.numRunes+=t.runes.length,t.op===W.Op.CHAR_CLASS&&t.runes.length===2&&t.runes[0]===t.runes[1]){if(this.maybeConcat(t.runes[0],this.flags&-2))return null;t.op=W.Op.LITERAL,t.runes=[t.runes[0]],t.flags=this.flags&-2}else if(t.op===W.Op.CHAR_CLASS&&t.runes.length===4&&t.runes[0]===t.runes[1]&&t.runes[2]===t.runes[3]&&me.simpleFold(t.runes[0])===t.runes[2]&&me.simpleFold(t.runes[2])===t.runes[0]||t.op===W.Op.CHAR_CLASS&&t.runes.length===2&&t.runes[0]+1===t.runes[1]&&me.simpleFold(t.runes[0])===t.runes[1]&&me.simpleFold(t.runes[1])===t.runes[0]){if(this.maybeConcat(t.runes[0],this.flags|K.FOLD_CASE))return null;t.op=W.Op.LITERAL,t.runes=[t.runes[0]],t.flags=this.flags|K.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(t),this.checkLimits(t),t}maybeConcat(t,r){let n=this.stack.length;if(n<2)return!1;let i=this.stack[n-1],s=this.stack[n-2];return i.op!==W.Op.LITERAL||s.op!==W.Op.LITERAL||(i.flags&K.FOLD_CASE)!==(s.flags&K.FOLD_CASE)?!1:(s.runes=pe.concatRunes(s.runes,i.runes),t>=0?(i.runes=[t],i.flags=r,!0):(this.pop(),this.reuse(i),!1))}newLiteral(t,r){let n=this.newRegexp(W.Op.LITERAL);return n.flags=r,(r&K.FOLD_CASE)!==0&&(t=pe.minFoldRune(t)),n.runes=[t],n}literal(t){this.push(this.newLiteral(t,this.flags))}op(t){let r=this.newRegexp(t);return r.flags=this.flags,this.push(r)}repeat(t,r,n,i,s,a){let o=this.flags;if((o&K.PERL_X)!==0&&(s.more()&&s.lookingAt("?")&&(s.skip(1),o^=K.NON_GREEDY),a!==-1))throw new Xe(pe.ERR_INVALID_REPEAT_OP,s.from(a));let l=this.stack.length;if(l===0)throw new Xe(pe.ERR_MISSING_REPEAT_ARGUMENT,s.from(i));let u=this.stack[l-1];if(W.isPseudoOp(u.op))throw new Xe(pe.ERR_MISSING_REPEAT_ARGUMENT,s.from(i));let c=this.newRegexp(t);if(c.min=r,c.max=n,c.flags=o,c.subs=[u],this.stack[l-1]=c,this.checkLimits(c),t===W.Op.REPEAT&&(r>=2||n>=2)&&!this.repeatIsValid(c,1e3))throw new Xe(pe.ERR_INVALID_REPEAT_SIZE,s.from(i))}repeatIsValid(t,r){if(t.op===W.Op.REPEAT){let n=t.max;if(n===0)return!0;if(n<0&&(n=t.min),n>r)return!1;n>0&&(r=Math.trunc(r/n))}for(let n of t.subs)if(!this.repeatIsValid(n,r))return!1;return!0}concat(){this.maybeConcat(-1,0);let t=this.popToPseudo();return t.length===0?this.push(this.newRegexp(W.Op.EMPTY_MATCH)):this.push(this.collapse(t,W.Op.CONCAT))}alternate(){let t=this.popToPseudo();return t.length>0&&this.cleanAlt(t[t.length-1]),t.length===0?this.push(this.newRegexp(W.Op.NO_MATCH)):this.push(this.collapse(t,W.Op.ALTERNATE))}cleanAlt(t){t.op===W.Op.CHAR_CLASS&&(t.runes=new an(t.runes).cleanClass().toArray(),t.runes.length===2&&t.runes[0]===0&&t.runes[1]===me.MAX_RUNE?(t.runes=[],t.op=W.Op.ANY_CHAR):t.runes.length===4&&t.runes[0]===0&&t.runes[1]===U.CODES.get(` `)-1&&t.runes[2]===U.CODES.get(` `)+1&&t.runes[3]===me.MAX_RUNE&&(t.runes=[],t.op=W.Op.ANY_CHAR_NOT_NL))}collapse(t,r){if(t.length===1)return t[0];let n=0;for(let o of t)n+=o.op===r?o.subs.length:1;let i=Array(n).fill(null),s=0;for(let o of t)o.op===r?(i.splice(s,o.subs.length,...o.subs),s+=o.subs.length,this.reuse(o)):i[s++]=o;let a=this.newRegexp(r);if(a.subs=i,r===W.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let o=a;a=a.subs[0],this.reuse(o)}return a}factor(t){if(t.length<2)return t;let r=0,n=t.length,i=0,s=null,a=0,o=0,l=0;for(let c=0;c<=n;c++){let p=null,h=0,f=0;if(c0&&(d=d.subs[0]),d.op===W.Op.LITERAL&&(p=d.runes,h=d.runes.length,f=d.flags&K.FOLD_CASE),f===o){let m=0;for(;m0){a=m;continue}}}if(c!==l)if(c===l+1)t[i++]=t[r+l];else{let d=this.newRegexp(W.Op.LITERAL);d.flags=o,d.runes=s.slice(0,a);for(let v=l;v0){let n=this.removeLeadingString(t.subs[0],r);if(t.subs[0]=n,n.op===W.Op.EMPTY_MATCH)switch(this.reuse(n),t.subs.length){case 0:case 1:t.op=W.Op.EMPTY_MATCH,t.subs=null;break;case 2:{let i=t;t=t.subs[1],this.reuse(i);break}default:t.subs=t.subs.slice(1,t.subs.length)}return t}return t.op===W.Op.LITERAL&&(t.runes=t.runes.slice(r,t.runes.length),t.runes.length===0&&(t.op=W.Op.EMPTY_MATCH)),t}removeLeadingRegexp(t,r){if(t.op===W.Op.CONCAT&&t.subs.length>0){switch(r&&this.reuse(t.subs[0]),t.subs=t.subs.slice(1,t.subs.length),t.subs.length){case 0:t.op=W.Op.EMPTY_MATCH,t.subs=W.emptySubs();break;case 1:{let n=t;t=t.subs[0],this.reuse(n);break}}return t}return r&&this.reuse(t),this.newRegexp(W.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&K.LITERAL)!==0)return pe.literalRegexp(this.wholeRegexp,this.flags);let t=-1,r=-1,n=-1,i=new jp(this.wholeRegexp);for(;i.more();){let s=-1;e:switch(i.peek()){case U.CODES.get("("):if((this.flags&K.PERL_X)!==0&&i.lookingAt("(?")){this.parsePerlFlags(i);break}this.op(W.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case U.CODES.get("|"):this.parseVerticalBar(),i.skip(1);break;case U.CODES.get(")"):this.parseRightParen(),i.skip(1);break;case U.CODES.get("^"):(this.flags&K.ONE_LINE)===0?this.op(W.Op.BEGIN_LINE):this.op(W.Op.BEGIN_TEXT),i.skip(1);break;case U.CODES.get("$"):(this.flags&K.ONE_LINE)===0?this.op(W.Op.END_LINE):this.op(W.Op.END_TEXT).flags|=K.WAS_DOLLAR,i.skip(1);break;case U.CODES.get("."):(this.flags&K.DOT_NL)===0?this.op(W.Op.ANY_CHAR_NOT_NL):this.op(W.Op.ANY_CHAR),i.skip(1);break;case U.CODES.get("["):this.parseClass(i);break;case U.CODES.get("*"):case U.CODES.get("+"):case U.CODES.get("?"):{s=i.pos();let a=null;switch(i.pop()){case U.CODES.get("*"):a=W.Op.STAR;break;case U.CODES.get("+"):a=W.Op.PLUS;break;case U.CODES.get("?"):a=W.Op.QUEST}this.repeat(a,r,n,s,i,t);break}case U.CODES.get("{"):{s=i.pos();let a=pe.parseRepeat(i);if(a<0){i.rewindTo(s),this.literal(i.pop());break}r=a>>16,n=(a&me.MAX_BMP)<<16>>16,this.repeat(W.Op.REPEAT,r,n,s,i,t);break}case U.CODES.get("\\"):{let a=i.pos();if(i.skip(1),(this.flags&K.PERL_X)!==0&&i.more())switch(i.pop()){case U.CODES.get("A"):this.op(W.Op.BEGIN_TEXT);break e;case U.CODES.get("b"):this.op(W.Op.WORD_BOUNDARY);break e;case U.CODES.get("B"):this.op(W.Op.NO_WORD_BOUNDARY);break e;case U.CODES.get("C"):throw new Xe(pe.ERR_INVALID_ESCAPE,"\\C");case U.CODES.get("Q"):{let u=i.rest(),c=u.indexOf("\\E");c>=0&&(u=u.substring(0,c)),i.skipString(u),i.skipString("\\E");let p=0;for(;p");if(l<0)throw new Xe(pe.ERR_INVALID_NAMED_CAPTURE,n);let u=n.substring(o,l);if(t.skipString(u),t.skip(o+1),!pe.isValidCaptureName(u))throw new Xe(pe.ERR_INVALID_NAMED_CAPTURE,n.substring(0,l+1));let c=this.op(W.Op.LEFT_PAREN);if(c.cap=++this.numCap,this.namedGroups[u])throw new Xe(pe.ERR_DUPLICATE_NAMED_CAPTURE,u);this.namedGroups[u]=this.numCap,c.name=u;return}t.skip(2);let i=this.flags,s=1,a=!1;e:for(;t.more();){let o=t.pop();switch(o){case U.CODES.get("i"):i|=K.FOLD_CASE,a=!0;break;case U.CODES.get("m"):i&=-17,a=!0;break;case U.CODES.get("s"):i|=K.DOT_NL,a=!0;break;case U.CODES.get("U"):i|=K.NON_GREEDY,a=!0;break;case U.CODES.get("-"):if(s<0)break e;s=-1,i=~i,a=!1;break;case U.CODES.get(":"):case U.CODES.get(")"):if(s<0){if(!a)break e;i=~i}o===U.CODES.get(":")&&this.op(W.Op.LEFT_PAREN),this.flags=i;return;default:break e}}throw new Xe(pe.ERR_INVALID_PERL_OP,t.from(r))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(W.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===W.Op.VERTICAL_BAR&&pe.isCharClass(this.stack[t-1])&&pe.isCharClass(this.stack[t-3])){let r=this.stack[t-1],n=this.stack[t-3];if(r.op>n.op){let i=n;n=r,r=i,this.stack[t-3]=n}return pe.mergeCharClass(n,r),this.reuse(r),this.pop(),!0}if(t>=2){let r=this.stack[t-1],n=this.stack[t-2];if(n.op===W.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=r,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new Xe(pe.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let t=this.pop(),r=this.pop();if(r.op!==W.Op.LEFT_PAREN)throw new Xe(pe.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=r.flags,r.cap===0?this.push(t):(r.op=W.Op.CAPTURE,r.subs=[t],this.push(r))}parsePerlClassEscape(t,r){let n=t.pos();if((this.flags&K.PERL_X)===0||!t.more()||t.pop()!==U.CODES.get("\\")||!t.more())return!1;t.pop();let i=t.from(n),s=Xo.has(i)?Xo.get(i):null;return s!==null&&(r.appendGroup(s,(this.flags&K.FOLD_CASE)!==0),!0)}parseNamedClass(t,r){let n=t.rest(),i=n.indexOf(":]");if(i<0)return!1;let s=n.substring(0,i+2);t.skipString(s);let a=hl.has(s)?hl.get(s):null;if(a===null)throw new Xe(pe.ERR_INVALID_CHAR_RANGE,s);return r.appendGroup(a,(this.flags&K.FOLD_CASE)!==0),!0}parseUnicodeClass(t,r){let n=t.pos();if((this.flags&K.UNICODE_GROUPS)===0||!t.lookingAt("\\p")&&!t.lookingAt("\\P"))return!1;t.skip(1);let i=1,s=t.pop();if(s===U.CODES.get("P")&&(i=-1),!t.more())throw t.rewindTo(n),new Xe(pe.ERR_INVALID_CHAR_RANGE,t.rest());s=t.pop();let a;if(s!==U.CODES.get("{"))a=Pe.runeToString(s);else{let c=t.rest(),p=c.indexOf("}");if(p<0)throw t.rewindTo(n),new Xe(pe.ERR_INVALID_CHAR_RANGE,t.rest());a=c.substring(0,p),t.skipString(a),t.skip(1)}a.length!==0&&a.codePointAt(0)===U.CODES.get("^")&&(i=0-i,a=a.substring(1));let o=pe.unicodeTable(a);if(o===null)throw new Xe(pe.ERR_INVALID_CHAR_RANGE,t.from(n));let l=o.first,u=o.second;if((this.flags&K.FOLD_CASE)===0||u===null)r.appendTableWithSign(l,i);else{let c=new an().appendTable(l).appendTable(u).cleanClass().toArray();r.appendClassWithSign(c,i)}return!0}parseClass(t){let r=t.pos();t.skip(1);let n=this.newRegexp(W.Op.CHAR_CLASS);n.flags=this.flags;let i=new an,s=1;t.more()&&t.lookingAt("^")&&(s=-1,t.skip(1),(this.flags&K.CLASS_NL)===0&&i.appendRange(U.CODES.get(` `),U.CODES.get(` `)));let a=!0;for(;!t.more()||t.peek()!==U.CODES.get("]")||a;){if(t.more()&&t.lookingAt("-")&&(this.flags&K.PERL_X)===0&&!a){let c=t.rest();if(c==="-"||!c.startsWith("-]"))throw t.rewindTo(r),new Xe(pe.ERR_INVALID_CHAR_RANGE,t.rest())}a=!1;let o=t.pos();if(t.lookingAt("[:")){if(this.parseNamedClass(t,i))continue;t.rewindTo(o)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(o);let l=pe.parseClassChar(t,r),u=l;if(t.more()&&t.lookingAt("-")){if(t.skip(1),t.more()&&t.lookingAt("]"))t.skip(-1);else if(u=pe.parseClassChar(t,r),u0&&(o.prefixRune=o.prefix.codePointAt(0)),o.namedGroups=i.namedGroups,o}static match(t,r){return Un.compile(t).match(r)}constructor(t,r,n=0,i=0){this.expr=t,this.prog=r,this.numSubexp=n,this.longest=i,this.cond=r.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new Gp,this.dfa=new zp(r)}executeEngine(t,r,n,i){if(i>0)return this.doExecuteNFA(t,r,n,i);let s=this.dfa.match(t,r,n);return s===null?this.doExecuteNFA(t,r,n,i):s?[]:null}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let t;do t=this.pooled.get();while(t&&!this.pooled.compareAndSet(t,t.next));return t}reset(){this.pooled.set(null)}put(t,r){let n=this.pooled.get();do n=this.pooled.get(),!r&&n&&(t=Vs.fromMachine(t),r=!0),t.next!==n&&(t.next=n);while(!this.pooled.compareAndSet(n,t))}toString(){return this.expr}doExecuteNFA(t,r,n,i){let s=this.get(),a=!1;s?s.next!==null&&(s=Vs.fromMachine(s),a=!0):(s=Vs.fromRE2(this),a=!0),s.init(i);let o=s.match(t,r,n)?s.submatches():null;return this.put(s,a),o}match(t){return this.executeEngine(ot.fromUTF16(t),0,K.UNANCHORED,0)!==null}matchWithGroup(t,r,n,i,s){return t instanceof Dn||(t=es.utf16(t)),this.matchMachineInput(t,r,n,i,s)}matchMachineInput(t,r,n,i,s){if(r>n)return[!1,null];let a=t.isUTF16Encoding()?ot.fromUTF16(t.asCharSequence(),0,n):ot.fromUTF8(t.asBytes(),0,n),o=this.executeEngine(a,r,i,2*s);return o===null?[!1,null]:[!0,o]}matchUTF8(t){return this.executeEngine(ot.fromUTF8(t),0,K.UNANCHORED,0)!==null}replaceAll(t,r){return this.replaceAllFunc(t,()=>r,2*t.length+1)}replaceFirst(t,r){return this.replaceAllFunc(t,()=>r,1)}replaceAllFunc(t,r,n){let i=0,s=0,a="",o=ot.fromUTF16(t),l=0;for(;s<=t.length;){let u=this.executeEngine(o,s,K.UNANCHORED,2);if(u===null||u.length===0)break;a+=t.substring(i,u[0]),(u[1]>i||u[0]===0)&&(a+=r(t.substring(u[0],u[1])),l++),i=u[1];let c=o.step(s)&7;if(s+c>u[1]?s+=c:s+1>u[1]?s++:s=u[1],l>=n)break}return a+=t.substring(i),a}pad(t){if(t===null)return null;let r=(1+this.numSubexp)*2;if(t.lengthi){let i=[],s=t.endPos();r<0&&(r=s+1);let a=0,o=0,l=-1;for(;o=0&&(n[i]=t.slice(r[2*i],r[2*i+1]));return n}findUTF8SubmatchIndex(t){return this.pad(this.executeEngine(ot.fromUTF8(t),0,K.UNANCHORED,this.prog.numCap))}findSubmatch(t){let r=this.executeEngine(ot.fromUTF16(t),0,K.UNANCHORED,this.prog.numCap);if(r===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let i=0;i=0&&(n[i]=t.substring(r[2*i],r[2*i+1]));return n}findSubmatchIndex(t){return this.pad(this.executeEngine(ot.fromUTF16(t),0,K.UNANCHORED,this.prog.numCap))}findAllUTF8(t,r){let n=this.allMatches(ot.fromUTF8(t),r,i=>t.slice(i[0],i[1]));return n.length===0?null:n}findAllUTF8Index(t,r){let n=this.allMatches(ot.fromUTF8(t),r,i=>i.slice(0,2));return n.length===0?null:n}findAll(t,r){let n=this.allMatches(ot.fromUTF16(t),r,i=>t.substring(i[0],i[1]));return n.length===0?null:n}findAllIndex(t,r){let n=this.allMatches(ot.fromUTF16(t),r,i=>i.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(t,r){let n=this.allMatches(ot.fromUTF8(t),r,i=>{let s=Array(i.length/2|0).fill(null);for(let a=0;a=0&&(s[a]=t.slice(i[2*a],i[2*a+1]));return s});return n.length===0?null:n}findAllUTF8SubmatchIndex(t,r){let n=this.allMatches(ot.fromUTF8(t),r);return n.length===0?null:n}findAllSubmatch(t,r){let n=this.allMatches(ot.fromUTF16(t),r,i=>{let s=Array(i.length/2|0).fill(null);for(let a=0;a=0&&(s[a]=t.substring(i[2*a],i[2*a+1]));return s});return n.length===0?null:n}findAllSubmatchIndex(t,r){let n=this.allMatches(ot.fromUTF16(t),r);return n.length===0?null:n}},Vp=class bi{static isUpperCaseAlpha(t){return"A"<=t&&t<="Z"}static isHexadecimal(t){return"0"<=t&&t<="9"||"A"<=t&&t<="F"||"a"<=t&&t<="f"}static getUtf8CharSize(t){let r=t.charCodeAt(0);return r<128?1:r<2048?2:r<65536?3:4}static translate(t){if(typeof t!="string")return t;let r="",n=!1,i=t.length;i===0&&(r="(?:)",n=!0);let s=0;for(;s>4).toString(16).toUpperCase(),r+=(l.charCodeAt(0)-64&15).toString(16).toUpperCase(),s+=3,n=!0;continue}}r+="\\c",s+=2;continue;case"u":if(s+2=i||t[s+3]!=="="&&t[s+3]!=="!")){r+="(?P<",s+=3,n=!0;continue}let o=bi.getUtf8CharSize(a);r+=t.substring(s,s+o),s+=o}return n?r:t}},Ii=class Ht{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(t){return Pe.quoteMeta(t)}static translateRegExp(t){return Vp.translate(t)}static compile(t,r=0){let n=t;if((r&Ht.CASE_INSENSITIVE)!==0&&(n=`(?i)${n}`),(r&Ht.DOTALL)!==0&&(n=`(?s)${n}`),(r&Ht.MULTILINE)!==0&&(n=`(?m)${n}`),(r&~(Ht.MULTILINE|Ht.DOTALL|Ht.CASE_INSENSITIVE|Ht.DISABLE_UNICODE_GROUPS|Ht.LONGEST_MATCH))!==0)throw new Pp("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH");let i=K.PERL;(r&Ht.DISABLE_UNICODE_GROUPS)!==0&&(i&=-129);let s=new Ht(t,r);return s.re2Input=Hp.compileImpl(n,i,(r&Ht.LONGEST_MATCH)!==0),s}static matches(t,r){return Ht.compile(t).testExact(r)}static initTest(t,r,n){if(t==null)throw Error("pattern is null");if(n==null)throw Error("re2 is null");let i=new Ht(t,r);return i.re2Input=n,i}constructor(t,r){this.patternInput=t,this.flagsInput=r}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(t){return this.testExact(t)}matcher(t){return Array.isArray(t)&&(t=es.utf8(t)),new Dp(this,t)}test(t){return Array.isArray(t)?this.re2Input.matchUTF8(t):this.re2Input.match(t)}testExact(t){let r=Array.isArray(t)?ot.fromUTF8(t):ot.fromUTF16(t);return this.re2Input.executeEngine(r,0,K.ANCHOR_BOTH,0)!==null}split(t,r=0){let n=this.matcher(t),i=[],s=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(r>0&&i.length===r-1)break;if(a===n.start()){if(r===0){s+=1,a=n.end();continue}}else for(;s>0;)i.push(""),--s;i.push(n.substring(a,n.start())),a=n.end()}if(r===0&&a!==n.inputLength()){for(;s>0;)i.push(""),--s;i.push(n.substring(a,n.inputLength()))}return(r!==0||i.length===0)&&i.push(n.substring(a,n.inputLength())),i}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(t){return this===t?!0:t===null||this.constructor!==t.constructor?!1:this.flagsInput===t.flagsInput&&this.patternInput===t.patternInput}}});function ev(e){let t=0;return e.includes("i")&&(t|=Ii.CASE_INSENSITIVE),e.includes("m")&&(t|=Ii.MULTILINE),e.includes("s")&&(t|=Ii.DOTALL),t}function tv(e){return Ii.translateRegExp(e)}function de(e,t="",r={}){return new Gg(e,t,r)}var Zp,Qp,Gg,ho,rv=M(()=>{J9(),Et(),H(),Zp=1e6,Qp=67108864,Gg=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;_matcher=null;_matcherInput=null;maxResults;maxOutputBytes;signal;assertResultCount(e){if(this.signal?.aborted)throw Error("regular expression aborted");if(e>this.maxResults)throw new C(`regular expression result limit exceeded (${this.maxResults})`,"array_elements")}expandReplacement(e,t){let r=new st(this.maxOutputBytes,"regular expression replacement"),n=this._re2.groupCount(),i=this._re2.namedGroups();for(let s=0;s=t.length){r.append(a);continue}if(t[s+1]==="{"){let o=t.indexOf("}",s+2);if(o!==-1){let l=t.slice(s+2,o),u=i?.[l];if(u!==void 0){r.append(e.group(u)??""),s=o;continue}}}if(/\d/.test(t[s+1])){let o=s+1,l=0;for(;on)break;l=u,o++}r.append(e.group(l)??""),s=o-1;continue}r.append(a)}return r.build()}acquireMatcher(e){return this._matcher===null?(this._matcher=this._re2.matcher(e),this._matcherInput=e,this._matcher):(this._matcherInput!==e&&(this._matcher.matcherInput.charSequence=e,this._matcherInput=e),this._matcher.reset(),this._matcher)}constructor(e,t="",r={}){if(this._pattern=e,this._flags=t,this._global=t.includes("g"),this._ignoreCase=t.includes("i"),this._multiline=t.includes("m"),this.maxResults=r.maxResults??Zp,this.maxOutputBytes=r.maxOutputBytes??Qp,this.signal=r.signal,!Number.isSafeInteger(this.maxResults)||this.maxResults<0||!Number.isSafeInteger(this.maxOutputBytes)||this.maxOutputBytes<0)throw Error("invalid regular expression limits");try{let n=tv(e),i=ev(t);this._re2=Ii.compile(n,i)}catch(n){if(n instanceof Xe){let i=n.message||"",s="";throw i.includes("(?=")||i.includes("(?!")||i.includes("(?<")||i.includes("(?0){let o=Object.create(null);for(let[l,u]of Object.entries(a)){let c=t.group(u);c!==null&&(o[l]=c)}s.groups=o}return this._global&&(this._lastIndex=t.end(0),t.start(0)===t.end(0)&&this._lastIndex++),s}match(e){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(e);let t=[],r=this.acquireMatcher(e),n=0;for(;r.find(n);){let i=r.group(0)??"";if(this.assertResultCount(t.length+1),t.push(i),n=r.end(0),r.start(0)===r.end(0)&&n++,n>e.length)break}return t.length>0?t:null}replace(e,t){if(this._global&&(this._lastIndex=0),typeof t=="string"){let u=this._re2.matcher(e),c=new st(this.maxOutputBytes,"regular expression replacement"),p=0,h=0,f=0;for(;u.find(h);){this.assertResultCount(++f);let d=u.start(0),m=u.end(0);if(c.append(e.slice(p,d)),c.append(this.expandReplacement(u,t)),p=m,h=m>d?m:m+1,!this._global||h>e.length)break}return c.append(e.slice(p)),c.build()}let r=new st(this.maxOutputBytes,"regular expression replacement"),n=this._re2.matcher(e),i=0,s=0,a=0,o=this._re2.groupCount(),l=this._re2.namedGroups();for(;n.find(s);){this.assertResultCount(++a),r.append(e.slice(i,n.start(0)));let u=[],c=n.group(0)??"";for(let f=1;f<=o;f++)u.push(n.group(f));if(u.push(n.start(0)),u.push(e),l&&Object.keys(l).length>0){let f=Object.create(null);for(let[d,m]of Object.entries(l))f[d]=n.group(m)??"";u.push(f)}let p=n.start(0),h=n.end(0);if(r.append(t(c,...u)),i=h,s=i,p===h&&s++,!this._global||s>e.length)break}return r.append(e.slice(i)),r.build()}split(e,t){if(t===0)return[];let r=t===void 0||t<0?this.maxResults:Math.min(t,this.maxResults),n=[],i=this._re2.matcher(e),s=0,a=0;for(;n.lengthi.start(0)?i.end(0):i.end(0)+1;return n.length0){let l=Object.create(null);for(let[u,c]of Object.entries(n)){let p=t.group(c);p!==null&&(l[u]=p)}o.groups=l}if(yield o,i=t.end(0),t.start(0)===t.end(0)&&i++,i>e.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=RegExp("",this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(e){this._lastIndex=e}},ho=class{_regex;constructor(e){this._regex=e}test(e){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(e)}exec(e){return this._regex.exec(e)}match(e){return this._regex.global&&(this._regex.lastIndex=0),e.match(this._regex)}replace(e,t){return this._regex.global&&(this._regex.lastIndex=0),e.replace(this._regex,t)}split(e,t){return e.split(this._regex,t)}search(e){return e.search(this._regex)}*matchAll(e){if(!this._regex.global)throw Error("matchAll requires global flag");this._regex.lastIndex=0;let t=this._regex.exec(e);for(;t!==null;)yield t,t[0].length===0&&this._regex.lastIndex++,t=this._regex.exec(e)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(e){this._regex.lastIndex=e}}}),at=M(()=>{rv()});function sr(e,t,r){let n=typeof r=="boolean"?{ignoreCase:r}:r??{},i=t;n.stripQuotes&&(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1));let s=n.ignoreCase?`i:${i}`:i,a=wi.get(s);if(!a){if(a=nv(i,n.ignoreCase),wi.size>=Hg){let o=wi.keys().next().value;o!==void 0&&wi.delete(o)}wi.set(s,a)}return a.test(e)}function nv(e,t){let r="^";for(let n=0;n{at(),Hg=2048,wi=new Map});function fs(e,t){let r=e.ignoreCase?t.toLowerCase():t,n=e.needles;for(let i=0;i]+)>)/g,(r,n,i)=>n==="&"?t[0]:i===void 0?t[parseInt(n,10)]??"":t.groups?.[i]??"")}function Fa(e,t,r={}){let{invertMatch:n=!1,showLineNumbers:i=!1,countOnly:s=!1,countMatches:a=!1,filename:o="",onlyMatching:l=!1,beforeContext:u=0,afterContext:c=0,maxCount:p=0,contextSeparator:h="--",showColumn:f=!1,vimgrep:d=!1,showByteOffset:m=!1,replace:g=null,passthru:v=!1,multiline:y=!1,kResetGroup:x,preFilter:b,maxWork:w,maxMatches:E,signal:A}=r;if(y)return iv(e,t,{invertMatch:n,showLineNumbers:i,countOnly:s,countMatches:a,filename:o,onlyMatching:l,beforeContext:u,afterContext:c,maxCount:p,contextSeparator:h,showColumn:f,showByteOffset:m,replace:g,kResetGroup:x,preFilter:b,maxWork:w,maxMatches:E,signal:A});let O=0,N=(z=1)=>{if(A?.aborted)throw new bt;if(O+=z,w!==void 0&&O>w)throw new C(`search: matching work limit exceeded (${w})`,"iterations")},D=(z,V)=>{if(E!==void 0&&z.length>=E)throw new C(`search: result limit exceeded (${E})`,"array_elements");z.push(V)},$=1;for(let z=0;zE))throw new C(`search: line limit exceeded (${E})`,"array_elements");let L=e.split(` `),_=L.length,R=_>0&&L[_-1]===""?_-1:_;if(s||a){let z=0,V=(a||l)&&!n;for(let ae=0;ae0,matchCount:z}}if(u===0&&c===0&&!v){let z=[],V=!1,ae=0,te=0;for(let ie=0;ie0&&ae>=p));ie++){let Se=L[ie],be=null;if(b&&!fs(b,Se)||(t.lastIndex=0,be=t.exec(Se)),be!==null!==n)if(V=!0,ae++,l)for(let fe=be;fe!==null;fe=t.exec(Se)){N();let Ne=x===void 0?fe[0]:fe[x]??"",Ge=g===null?Ne:Kp(g,fe),Y=o?`${o}:`:"";m&&(Y+=`${te+fe.index}:`),i&&(Y+=`${ie+1}:`),f&&(Y+=`${fe.index+1}:`),D(z,Y+Ge),fe[0].length===0&&t.lastIndex++}else if(d)for(let fe=be;fe!==null;fe=t.exec(Se)){N();let Ne=o?`${o}:`:"";m&&(Ne+=`${te+fe.index}:`),i&&(Ne+=`${ie+1}:`),f&&(Ne+=`${fe.index+1}:`),D(z,Ne+Se),fe[0].length===0&&t.lastIndex++}else{let fe=be?be.index+1:1,Ne=Se;g!==null&&(t.lastIndex=0,Ne=t.replace(Se,(...Y)=>{if(Y[0].length===0)return"";let oe=Y,Fe=Y[Y.length-1];return typeof Fe=="object"&&Fe?(oe.groups=Fe,oe.input=Y[Y.length-2],oe.index=Y[Y.length-3]):(oe.input=Y[Y.length-1],oe.index=Y[Y.length-2]),Kp(g,oe)}));let Ge=o?`${o}:`:"";m&&(Ge+=`${te+(be?be.index:0)}:`),i&&(Ge+=`${ie+1}:`),f&&(Ge+=`${fe}:`),D(z,Ge+Ne)}te+=Se.length+1}return{output:z.length>0?`${z.join(` `)} `:"",matched:V,matchCount:ae}}if(v){let z=[],V=!1,ae=0;for(let te=0;te0?`${z.join(` `)} `:"",matched:V,matchCount:ae}}let B=[],j=0,P=new Set,F=-1,G=[];for(let z=0;z0&&j>=p));z++){let V=L[z],ae;if(b&&!fs(b,V)?ae=!1:(t.lastIndex=0,ae=t.test(V)),ae!==n){if(E!==void 0&&G.length>=E)throw new C(`search: match limit exceeded (${E})`,"array_elements");G.push(z),j++}}for(let z of G){N();let V=Math.max(0,z-u);F>=0&&V>F+1&&D(B,h);for(let te=V;te0?`${B.join(` `)} `:"",matched:j>0,matchCount:j}}function iv(e,t,r){let{invertMatch:n,showLineNumbers:i,countOnly:s,countMatches:a,filename:o,onlyMatching:l,beforeContext:u,afterContext:c,maxCount:p,contextSeparator:h,showColumn:f,showByteOffset:d,replace:m,kResetGroup:g,preFilter:v,maxWork:y,maxMatches:x,signal:b}=r,w=0,E=(P=1)=>{if(b?.aborted)throw new bt;if(w+=P,y!==void 0&&w>y)throw new C(`search: matching work limit exceeded (${y})`,"iterations")};if(v&&!n&&!fs(v,e))return s||a?{output:`${o?`${o}:0`:"0"} `,matched:!1,matchCount:0}:{output:"",matched:!1,matchCount:0};let A=[0];for(let P=0;P=x)throw new C(`search: line index limit exceeded (${x})`,"array_elements");A.push(P+1)}let O=e.split(` `),N=O.length,D=N>0&&O[N-1]===""?N-1:N,$=P=>{let F=0,G=A.length;for(;F{let F=$(P);return P-A[F]+1};if(s||a){let P=0,F=0,G=-1;t.lastIndex=0;for(let V=t.exec(e);V!==null&&(E(),!(p>0&&P>=p));V=t.exec(e)){if(P++,!a){let ae=$(V.index),te=$(V.index+Math.max(0,V[0].length-1)),ie=Math.max(ae,G+1);ie<=te&&(F+=te-ie+1,G=te)}V[0].length===0&&t.lastIndex++}let z=a?n?0:P:n?D-F:F;return{output:`${o?`${o}:${z}`:String(z)} `,matched:z>0,matchCount:z}}let _=[];t.lastIndex=0;for(let P=t.exec(e);P!==null&&(E(),!(p>0&&_.length>=p));P=t.exec(e)){if(x!==void 0&&_.length>=x)throw new C(`search: match limit exceeded (${x})`,"array_elements");let F=$(P.index),G=$(P.index+Math.max(0,P[0].length-1)),z=g===void 0?P[0]:P[g]??"";_.push({startLine:F,endLine:G,byteOffset:P.index,column:L(P.index),matchText:z}),P[0].length===0&&t.lastIndex++}if(n){let P=new Set;for(let G of _)for(let z=G.startLine;z<=G.endLine;z++)E(),P.add(z);let F=[];for(let G=0;G0?`${F.join(` `)} `:"",matched:F.length>0,matchCount:F.length}}if(_.length===0)return{output:"",matched:!1,matchCount:0};let R=new Set,B=-1,j=[];for(let P of _){E();let F=Math.max(0,P.startLine-u),G=Math.min(D-1,P.endLine+c);B>=0&&F>B+1&&j.push(h);for(let z=F;z0?`${j.join(` `)} `:"",matched:!0,matchCount:_.length}}var sv=M(()=>{H()});function Xp(e){let t="",r=0;for(;r:]]"){t+="\\b",r+=7;continue}if(e[r]==="["){let n="[";for(r++,r]+)>/g,"(?<$1>"),t.mode==="perl"){r=uv(r),r=cv(r),r=pv(r);let o=mv(r);r=o.pattern,n=o.kResetGroup}break;default:r=Xp(e),r=xv(r)}t.wholeWord&&(r=`\\b(?:${r})\\b`),t.lineRegexp&&(r=`^(?:${r})$`);let i=/\\u\{[0-9A-Fa-f]+\}/.test(r),s="g"+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.multilineDotall?"s":"")+(i?"u":""),a=av(r,t.ignoreCase??!1);return{regex:de(r,s),kResetGroup:n,preFilter:a??void 0}}function av(e,t){let r=e;if(r.startsWith("\\b(?:")&&r.endsWith(")\\b")?r=r.slice(5,r.length-3):r.startsWith("\\b")&&r.endsWith("\\b")&&r.length>=4&&(r=r.slice(2,r.length-2)),r.length===0)return null;let n=ov(r);if(n===null)return null;let i=[];for(let s of n){let a=lv(s);if(a===null||a.length===0)return null;i.push(a)}return i.length===0?null:{needles:t?i.map(s=>s.toLowerCase()):i,ignoreCase:t}}function ov(e){let t=[],r=0,n=!1,i=0;for(let s=0;s=0&&t[i]==="\\";i--)n++;n%2==0&&(t=t.slice(0,-1))}if(t.length===0)return null;let r="";for(let n=0;n0&&r+1=0&&e[n]==="\\";)r++,n--;if(r%2==0)return t}t+=2}else t++;return-1}function yv(e){let t=0,r=0;for(;r"),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,"$$<$1>"),t}function xv(e){let t="",r=0,n=!0,i=0;for(;r{at(),Qg=new Map([["alpha","a-zA-Z"],["digit","0-9"],["alnum","a-zA-Z0-9"],["lower","a-z"],["upper","A-Z"],["xdigit","0-9A-Fa-f"],["space"," \\t\\n\\r\\f\\v"],["blank"," \\t"],["punct","!-/:-@\\[-`{-~"],["graph","!-~"],["print"," -~"],["cntrl","\\x00-\\x1F\\x7F"],["ascii","\\x00-\\x7F"],["word","a-zA-Z0-9_"]])}),Kg=M(()=>{sv(),vv()}),la={};re(la,{egrepCommand:()=>Jg,egrepFlagsForFuzzing:()=>r2,fgrepCommand:()=>Yg,fgrepFlagsForFuzzing:()=>t2,flagsForFuzzing:()=>e2,grepCommand:()=>ua});function Yp(e){let t=e.limits.maxLoopIterations,r=e.limits.maxArrayElements;return Math.max(t,Math.min(r,t*10))}function xr(e){if(++e.operations>e.maxOperations)throw new C(`grep: glob operation limit exceeded (${e.maxOperations})`,"glob_operations")}function As(e){if(e.results>=e.maxResults)throw new C(`grep: array element limit exceeded (${e.maxResults})`,"array_elements");e.results++}function bv(e){return e.split(` `)}function wv(e){if(e==="")return[];let t=e.split(` `);return t[t.length-1]===""&&t.pop(),t}function Ev(e,t){return e.length===1?{pattern:e[0],mode:t}:t==="fixed"?{pattern:e.map(r=>`(?:${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`).join("|"),mode:"extended"}:t==="basic"?{pattern:e.join("\\|"),mode:t}:{pattern:e.map(r=>`(?:${r})`).join("|"),mode:t}}async function Xg(e,t,r,n,i,s=0){if(s>=Rc)return;let a=r.fs.resolvePath(r.cwd,e);try{if(xr(i),!(await r.fs.stat(a)).isDirectory){let l=e.split("/").pop()||"";t&&sr(l,t.replace(/^\//,""),{stripQuotes:!0})&&(As(i),n.push(e));return}xr(i);let o=await r.fs.readdir(a);for(let l of o){let u=e==="."?l:`${e}/${l}`,c=r.fs.resolvePath(r.cwd,u);xr(i),(await r.fs.stat(c)).isDirectory?await Xg(u,t,r,n,i,s+1):t&&sr(l,t.replace(/^\//,""),{stripQuotes:!0})&&(As(i),n.push(u))}}catch(o){Ie(o)}}async function Sv(e,t,r){let n=[],i=e.lastIndexOf("/"),s,a;if(i===-1?(s=t.cwd,a=e):(s=e.slice(0,i)||"/",a=e.slice(i+1)),e.includes("**")){let l=[],u=e.split("**");return await Xg(u[0].replace(/\/$/,"")||".",u[1]||"",t,l,r),l.map(c=>({path:c}))}let o=t.fs.resolvePath(t.cwd,s);try{if(t.fs.readdirWithFileTypes){xr(r);let l=await t.fs.readdirWithFileTypes(o);for(let u of l)if(xr(r),sr(u.name,a,{stripQuotes:!0})){let c=i===-1?u.name:`${s}/${u.name}`;As(r),n.push({path:c,isFile:u.isFile})}}else{xr(r);let l=await t.fs.readdir(o);for(let u of l)if(xr(r),sr(u,a,{stripQuotes:!0})){let c=i===-1?u:`${s}/${u}`;As(r),n.push({path:c})}}}catch(l){Ie(l)}return n.sort((l,u)=>l.path.localeCompare(u.path))}async function _a(e,t,r=[],n=[],i=[],s,a={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},o=[],l=0){if(l>=Rc)return o;let u=t.fs.resolvePath(t.cwd,e);try{let c,p;if(s!==void 0)c=s,p=!s;else{xr(a);let f=await t.fs.stat(u);c=f.isFile,p=f.isDirectory}if(c){let f=e.split("/").pop()||e;return n.length>0&&n.some(d=>sr(f,d,{stripQuotes:!0}))||r.length>0&&!r.some(d=>sr(f,d,{stripQuotes:!0}))||(As(a),o.push({path:e,isFile:!0})),o}if(!p)return o;let h=e.split("/").pop()||e;if(i.length>0&&i.some(f=>sr(h,f,{stripQuotes:!0})))return o;if(t.fs.readdirWithFileTypes){xr(a);let f=await t.fs.readdirWithFileTypes(u);for(let d of f)xr(a),!d.name.startsWith(".")&&await _a(e==="."?d.name:`${e}/${d.name}`,t,r,n,i,d.isFile,a,o,l+1)}else{xr(a);let f=await t.fs.readdir(u);for(let d of f)xr(a),!d.startsWith(".")&&await _a(e==="."?d:`${e}/${d}`,t,r,n,i,void 0,a,o,l+1)}}catch(c){Ie(c)}return o}var Jp,eh,th,ua,Rc,Yg,Jg,e2,t2,r2,fl=M(()=>{se(),Lt(),H(),Vg(),le(),Kg(),Jp="(standard input)",eh="[^\\s\\S]",th={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",description:["Search for PATTERN in each FILE.","With no FILE, or when FILE is -, read standard input."],options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching","-f FILE, --file=FILE obtain patterns from FILE, one per line"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},ua={name:"grep",async execute(e,t){let r=!1,n=!1,i=!1,s=!1,a=!1,o=!1,l=!1,u=!1,c=!1,p=!1,h=!1,f=!1,d=!1,m=!1,g=!1,v=0,y=0,x=0,b=[],w=[],E=[],A=null,O=[],N=[],D=!0;for(let Y=0;Y0)O.push(Mt);else if(Y+1t.limits.maxArrayElements)throw new C(`grep: array element limit exceeded (${t.limits.maxArrayElements})`,"array_elements");L.push(...Fe)}if(L.length===0&&!i&&!o)return{stdout:"",stderr:"",exitCode:1};let R=f?"fixed":p?"extended":h?"perl":"basic";if(R==="perl"&&new Set(L).size>1)return{stdout:"",stderr:`grep: the -P option only supports a single pattern `,exitCode:2};if(L.length>1&&R!=="fixed")for(let Y of L)try{yu(Y,{mode:R})}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${Y} `,exitCode:2}}let B=L.length===0?{pattern:eh,mode:"extended"}:Ev(L,R),j,P,F;try{let Y=yu(B.pattern,{mode:B.mode,ignoreCase:r,wholeWord:u,lineRegexp:c});j=Y.regex,P=Y.kResetGroup,F=Y.preFilter}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${L.join(` `)} `,exitCode:2}}if($.length===0&&t.stdin!==void 0){let Y=Fa(_?"":ke(t.stdin),j,{invertMatch:i,showLineNumbers:n,countOnly:s,filename:"",onlyMatching:d,beforeContext:y,afterContext:x,maxCount:v,kResetGroup:P,preFilter:F,maxWork:Yp(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return g?{stdout:"",stderr:"",exitCode:+!Y.matched}:{stdout:Y.output,stderr:"",exitCode:+!Y.matched}}if($.length===0)return{stdout:"",stderr:`grep: no input files `,exitCode:2};let G="",z="",V=!1,ae=!1,te=[],ie={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},Se=Y=>{if(Y.length>ie.maxResults-te.length)throw new C(`grep: array element limit exceeded (${ie.maxResults})`,"array_elements");te.push(...Y)},be=!1,fe=!1;for(let Y of $){if(Y==="-"){if(te.length>=ie.maxResults)throw new C(`grep: array element limit exceeded (${ie.maxResults})`,"array_elements");te.push({path:Jp,isFile:!0,isStdin:!0,stdinAtEof:be}),be=!0;continue}if(fe=!0,Y.includes("*")||Y.includes("?")||Y.includes("[")){let oe=await Sv(Y,t,ie);if(l)for(let Fe of oe)Se(await _a(Fe.path,t,b,w,E,Fe.isFile,ie));else Se(oe)}else if(l)Se(await _a(Y,t,b,w,E,void 0,ie));else{if(te.length>=ie.maxResults)throw new C(`grep: array element limit exceeded (${ie.maxResults})`,"array_elements");te.push({path:Y})}}let Ne=(te.length>1||l&&fe)&&!m;for(let Y=0;Y{let Re=Ee.path,Ke=Re.split("/").pop()||Re;if(w.length>0&&!l&&!Ee.isStdin&&w.some(ue=>sr(Ke,ue,{stripQuotes:!0}))||b.length>0&&!l&&!Ee.isStdin&&!b.some(ue=>sr(Ke,ue,{stripQuotes:!0})))return null;try{let ue;if(Ee.isStdin)ue=Ee.stdinAtEof||t.stdin===void 0?"":ke(t.stdin);else{let Mt=t.fs.resolvePath(t.cwd,Re),mt=!1;if(mt=Ee.isFile===void 0?(await t.fs.stat(Mt)).isDirectory:!Ee.isFile,mt)return l?null:{error:`grep: ${Re}: Is a directory `};ue=await t.fs.readFile(Mt)}if(F&&!i){let Mt=F.ignoreCase?ue.toLowerCase():ue;if(!F.needles.some(mt=>Mt.includes(mt)))return s?{file:Re,result:{output:`${Ne?`${Re}:0`:"0"} `,matched:!1,matchCount:0}}:{file:Re,result:{output:"",matched:!1,matchCount:0}}}return{file:Re,result:Fa(ue,j,{invertMatch:i,showLineNumbers:n,countOnly:s,filename:Ne?Re:"",onlyMatching:d,beforeContext:y,afterContext:x,maxCount:v,kResetGroup:P,preFilter:F,maxWork:Yp(t),maxMatches:t.limits.maxArrayElements,signal:t.signal})}}catch(ue){return Ie(ue),{error:`grep: ${Re}: No such file or directory `}}}));for(let Ee of Fe){if(Ee===null)continue;if("error"in Ee&&Ee.error){z+=Ee.error,Ee.error.includes("Is a directory")||(ae=!0);continue}if(!("file"in Ee)||!Ee.result)continue;let{file:Re,result:Ke}=Ee;if(Ke.matched){if(V=!0,g)return{stdout:"",stderr:"",exitCode:0};a?G+=`${Re} `:o||(G+=Ke.output)}else o?G+=`${Re} `:s&&!a&&(G+=Ke.output)}}let Ge;return Ge=ae?2:+!V,g?{stdout:"",stderr:"",exitCode:Ge}:{stdout:G,stderr:z,exitCode:Ge}}},Rc=256,Yg={name:"fgrep",async execute(e,t){return ua.execute(["-F",...e],t)}},Jg={name:"egrep",async execute(e,t){return ua.execute(["-E",...e],t)}},e2={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"},{flag:"-f",type:"value",valueHint:"path"}],stdinType:"text",needsArgs:!0},t2={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},r2={name:"egrep",flags:[],stdinType:"text",needsArgs:!0}});function n2(e,t){if(Array.isArray(e))throw TypeError(`${t}: expected object, got array`);if(Object.getPrototypeOf(e)!==null)throw TypeError(`${t}: expected null-prototype object, got prototypal object`)}function et(e){return!xu.has(e)}function Je(e,t,r){n2(e,"safeSet"),et(t)&&(e[t]=r)}function fo(e,t){return n2(e,"safeHasOwn"),Object.hasOwn(e,t)}function ca(e,t={}){let r=t.maxDepth??2e3,n=t.maxElements??1e6,i=new WeakMap,s=t.elementBudget??{used:0};if(!Number.isSafeInteger(s.used)||s.used<0||s.used>n)throw new C(`query input element limit exceeded (${n})`,"array_elements");let a=()=>{if(++s.used>n)throw new C(`query input element limit exceeded (${n})`,"array_elements")},o=(c,p,h)=>{if(typeof c!="object"||!c||c instanceof Date)return c;let f=i.get(c);if(f!==void 0)return f;if(p>r)throw new C(`query depth limit exceeded (${r})`,"recursion");let d=Array.isArray(c)?[]:Object.create(null);return i.set(c,d),h.push({source:c,target:d,depth:p}),d},l=[],u=o(e,0,l);for(;l.length>0;){let c=l.pop();if(!c)break;let{source:p,target:h,depth:f}=c;if(Array.isArray(p)&&Array.isArray(h)){if(p.length>n-s.used)throw new C(`query input element limit exceeded (${n})`,"array_elements");h.length=p.length;for(let v=p.length-1;v>=0;v--)a(),h[v]=o(p[v],f+1,l);continue}let d=p,m=h,g=Object.keys(d);if(g.length>n-s.used)throw new C(`query input element limit exceeded (${n})`,"array_elements");for(let v=0;v{H(),xu=new Set(["__proto__","constructor","prototype"]),[...xu]});function Cv(){let e=[];for(let[t,r]of Object.entries(vu).sort()){let n=[];for(let i of r.extensions)n.push(`*${i}`);for(let i of r.globs)n.push(i);e.push(`${t}: ${n.join(", ")}`)}return`${e.join(` `)} `}var vu,Pc,s2=M(()=>{at(),nn(),vu=Av({js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}}),Pc=class{types;constructor(){this.types=new Map(Object.entries(vu).map(([e,t])=>[e,{extensions:[...t.extensions],globs:[...t.globs]}]))}addType(e){let t=e.indexOf(":");if(t===-1)return;let r=e.slice(0,t),n=e.slice(t+1);if(n.startsWith("include:")){let i=n.slice(8),s=this.types.get(i);if(s){let a=this.types.get(r)||{extensions:[],globs:[]};a.extensions.push(...s.extensions),a.globs.push(...s.globs),this.types.set(r,a)}}else{let i=this.types.get(r)||{extensions:[],globs:[]};if(n.startsWith("*.")&&!n.slice(2).includes("*")){let s=n.slice(1);i.extensions.includes(s)||i.extensions.push(s)}else i.globs.includes(n)||i.globs.push(n);this.types.set(r,i)}}clearType(e){let t=this.types.get(e);t&&(t.extensions=[],t.globs=[])}getType(e){return this.types.get(e)}getAllTypes(){return this.types}matchesType(e,t){let r=e.toLowerCase();for(let n of t){if(n==="all"){if(this.matchesAnyType(e))return!0;continue}let i=this.types.get(n);if(i){for(let s of i.extensions)if(r.endsWith(s))return!0;for(let s of i.globs)if(s.includes("*")){if(de(`^${s.replace(/\./g,"\\.").replace(/\*/g,".*")}$`,"i").test(e))return!0}else if(r===s.toLowerCase())return!0}}return!1}matchesAnyType(e){let t=e.toLowerCase();for(let r of this.types.values()){for(let n of r.extensions)if(t.endsWith(n))return!0;for(let n of r.globs)if(n.includes("*")){if(de(`^${n.replace(/\./g,"\\.").replace(/\*/g,".*")}$`,"i").test(e))return!0}else if(t===n.toLowerCase())return!0}return!1}}});function kv(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:256,maxFilesize:536870912,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var Nv=M(()=>{});function $v(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let r=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return r*1024;case"M":return r*1024*1024;case"G":return r*1024*1024*1024;default:return r}}function Ov(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e} `,exitCode:1}}function Tv(e,t){return!/^\d+$/.test(t)||!Number.isSafeInteger(Number(t))?{stdout:"",stderr:`rg: invalid --${e} value: ${t} `,exitCode:1}:null}function rh(e){return null}function Iv(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function Rv(e,t,r){let n=e[t];for(let i of Dc){if(n.startsWith(`--${i.long}=`)){let s=pa(r,i,n.slice(`--${i.long}=`.length));return s?{newIndex:t,error:s}:{newIndex:t}}if(i.short&&n.startsWith(`-${i.short}`)&&n.length>2){let s=pa(r,i,n.slice(2));return s?{newIndex:t,error:s}:{newIndex:t}}if(i.short&&n===`-${i.short}`||n===`--${i.long}`){if(t+1>=e.length)return null;let s=e[t+1],a=pa(r,i,s);return a?{newIndex:t+1,error:a}:{newIndex:t+1}}}return null}function Pv(e){return Dc.find(t=>t.short===e)}function pa(e,t,r){if(t.validate){let i=t.validate(r);if(i)return i}if(t.ignored||!t.target)return;let n=t.parse?t.parse(r):r;t.multi?e[t.target].push(n):e[t.target]=n}function Dv(e,t){let r=e[t];if(r==="--sort"&&t+1=e.length)return{success:!1,error:ve("rg",`-${m}`)};let y=pa(t,v,e[l+1]);if(y)return{success:!1,error:y};l++;continue}}let g=a2.get(m);if(g){g(t);continue}if(m.startsWith("--"))return{success:!1,error:ve("rg",m)};if(m.length===1)return{success:!1,error:ve("rg",`-${m}`)}}}else r===null&&t.patterns.length===0&&t.patternFiles.length===0?r=u:n.push(u)}return(i>=0||a>=0)&&(t.afterContext=Math.max(i>=0?i:0,a>=0?a:0)),(s>=0||a>=0)&&(t.beforeContext=Math.max(s>=0?s:0,a>=0?a:0)),r!==null&&t.patterns.push(r),(t.column||t.vimgrep)&&(o=!0),{success:!0,options:t,paths:n,explicitLineNumbers:o}}var Dc,a2,o2,_v=M(()=>{le(),Nv(),Dc=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:rh},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:rh},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:e=>Number(e),validate:e=>Tv("max-depth",e)},{long:"max-filesize",target:"maxFilesize",parse:$v,validate:Ov},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",ignored:!0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],a2=new Map([["i",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["--ignore-case",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["s",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["--case-sensitive",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["S",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["--smart-case",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["F",e=>{e.fixedStrings=!0}],["--fixed-strings",e=>{e.fixedStrings=!0}],["w",e=>{e.wordRegexp=!0}],["--word-regexp",e=>{e.wordRegexp=!0}],["x",e=>{e.lineRegexp=!0}],["--line-regexp",e=>{e.lineRegexp=!0}],["v",e=>{e.invertMatch=!0}],["--invert-match",e=>{e.invertMatch=!0}],["U",e=>{e.multiline=!0}],["--multiline",e=>{e.multiline=!0}],["--multiline-dotall",e=>{e.multilineDotall=!0,e.multiline=!0}],["c",e=>{e.count=!0}],["--count",e=>{e.count=!0}],["--count-matches",e=>{e.countMatches=!0}],["l",e=>{e.filesWithMatches=!0}],["--files",e=>{e.files=!0}],["--files-with-matches",e=>{e.filesWithMatches=!0}],["--files-without-match",e=>{e.filesWithoutMatch=!0}],["--stats",e=>{e.stats=!0}],["o",e=>{e.onlyMatching=!0}],["--only-matching",e=>{e.onlyMatching=!0}],["q",e=>{e.quiet=!0}],["--quiet",e=>{e.quiet=!0}],["N",e=>{e.lineNumber=!1}],["--no-line-number",e=>{e.lineNumber=!1}],["H",e=>{e.withFilename=!0}],["--with-filename",e=>{e.withFilename=!0}],["I",e=>{e.noFilename=!0}],["--no-filename",e=>{e.noFilename=!0}],["0",e=>{e.nullSeparator=!0}],["--null",e=>{e.nullSeparator=!0}],["b",e=>{e.byteOffset=!0}],["--byte-offset",e=>{e.byteOffset=!0}],["--column",e=>{e.column=!0,e.lineNumber=!0}],["--no-column",e=>{e.column=!1}],["--vimgrep",e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0}],["--json",e=>{e.json=!0}],["--hidden",e=>{e.hidden=!0}],["--no-ignore",e=>{e.noIgnore=!0}],["--no-ignore-dot",e=>{e.noIgnoreDot=!0}],["--no-ignore-vcs",e=>{e.noIgnoreVcs=!0}],["L",e=>{e.followSymlinks=!0}],["--follow",e=>{e.followSymlinks=!0}],["z",e=>{e.searchZip=!0}],["--search-zip",e=>{e.searchZip=!0}],["a",e=>{e.searchBinary=!0}],["--text",e=>{e.searchBinary=!0}],["--heading",e=>{e.heading=!0}],["--passthru",e=>{e.passthru=!0}],["--include-zero",e=>{e.includeZero=!0}],["--glob-case-insensitive",e=>{e.globCaseInsensitive=!0}]]),o2=new Set(["n","--line-number"])});function zv(e){return`'${e.replace(/'/g,"'\\''")}'`}function ni(e){return e.map(zv).join(" ")}var ji=M(()=>{});async function l2(e,t,r=!1,n=!1,i=[]){let s=new Lc(e,t,r,n);await s.load(t);for(let a of i)try{let o=e.resolvePath(t,a),l=await e.readFile(o);s.addPatternsFromContent(l,t)}catch{}return s}var Qs,Lc,Bv=M(()=>{at(),Qs=class{patterns=[];basePath;constructor(e="/"){this.basePath=e}parse(e){let t=e.split(` `);for(let r of t){let n=r.replace(/\s+$/,"");if(!n||n.startsWith("#"))continue;let i=!1;n.startsWith("!")&&(i=!0,n=n.slice(1));let s=!1;n.endsWith("/")&&(s=!0,n=n.slice(0,-1));let a=!1;n.startsWith("/")?(a=!0,n=n.slice(1)):n.includes("/")&&!n.startsWith("**/")&&(a=!0);let o=this.patternToRegex(n,a);this.patterns.push({pattern:r,regex:o,negated:i,directoryOnly:s,rooted:a})}}patternToRegex(e,t){let r="";r=t?"^":"(?:^|/)";let n=0;for(;n=2&&e[0]===31&&e[1]===139}function Wv(e){let t=!1;for(let r=0;re.limits.maxStringLength||t>Math.floor(e.limits.maxLiveBytes/3))throw new C(t>e.limits.maxStringLength?`rg: pattern file exceeds string limit (${e.limits.maxStringLength} bytes)`:`rg: live byte limit exceeded (${e.limits.maxLiveBytes} bytes)`,"string_length");return e.executionScope?.reserveBytes("rg pattern files",t*3,"rg")??{release:()=>{}}}function jv(e,t,r){let n=0;for(let i=0;i<=t.length;i++)if(!(in){if(e.length>=r.limits.maxArrayElements)throw new C(`rg: pattern limit exceeded (${r.limits.maxArrayElements})`,"iterations");r.executionScope?.consumeWork(1,"rg pattern insertion"),e.push(t.slice(n,i))}n=i+1}}function ih(e,t,r){if(t>e.limits.maxInputBytes-r)throw new C(`rg: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,"string_length");return e.executionScope?.consumeInput(t,"rg pattern files"),r+t}async function qv(e){let{ctx:t,options:r,paths:n,explicitLineNumbers:i}=e;for(let x of r.globs){let b=Wv(x.startsWith("!")?x.slice(1):x);if(b)return{stdout:"",stderr:`${b} `,exitCode:1}}if(r.files)return Vv(t,[...r.patterns,...n],r);if(r.patterns.length>t.limits.maxArrayElements)throw new C(`rg: pattern limit exceeded (${t.limits.maxArrayElements})`,"iterations");let s=r.patterns.slice(),a=[],o=0,l,u;try{for(let b of r.patternFiles)try{let w,E;if(b==="-")w=t.stdin,E=t.stdin.length,o=ih(t,E,o);else{let O=t.fs.resolvePath(t.cwd,b);E=(await t.fs.stat(O)).size,o=ih(t,E,o);let N=nh(t,E);a.push(N),w=await xn(t.fs,O);let D=w.length;if(D>E)throw new C("rg: pattern file grew while being read","string_length");E=D}b==="-"&&a.push(nh(t,E));let A=ke(w,t.limits.maxStringLength);t.executionScope?.consumeWork(A.length,"rg pattern file parsing"),jv(s,A,t)}catch(w){return Ie(w),{stdout:"",stderr:`rg: ${b}: No such file or directory `,exitCode:2}}if(s.length===0)return r.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given `,exitCode:2};let x=Gv(r,s);try{let b=Hv(s,r,x);l=b.regex,u=b.kResetGroup}catch{return{stdout:"",stderr:`rg: invalid regex: ${s.join(", ")} `,exitCode:2}}}finally{for(let x of a)x.release()}let c=r.patternFiles.includes("-"),p=ke(t.stdin);if(n.length===0&&p.length>0&&!c){let x=Fa(p,l,{invertMatch:r.invertMatch,showLineNumbers:r.lineNumber,countOnly:r.count,countMatches:r.countMatches,filename:"",onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace===null?null:Zg(r.replace),passthru:r.passthru,multiline:r.multiline,kResetGroup:u,maxWork:t.limits.maxLoopIterations,maxMatches:t.limits.maxArrayElements,signal:t.signal});return r.quiet?{stdout:"",stderr:"",exitCode:+!x.matched}:r.filesWithMatches?{stdout:x.matched?`(standard input) `:"",stderr:"",exitCode:+!x.matched}:r.filesWithoutMatch?{stdout:x.matched?"":`(standard input) `,stderr:"",exitCode:+!!x.matched}:{stdout:x.output,stderr:"",exitCode:+!x.matched}}let h=n.length===0?["."]:n,f=null;r.noIgnore||(f=await l2(t.fs,t.cwd,r.noIgnoreDot,r.noIgnoreVcs,r.ignoreFiles));let d=new Pc;for(let x of r.typeClear)d.clearType(x);for(let x of r.typeAdd)d.addType(x);let{files:m,singleExplicitFile:g}=await u2(t,h,r,f,d);if(m.length===0)return{stdout:"",stderr:"",exitCode:1};let v=!r.noFilename&&(r.withFilename||!g||m.length>1),y=r.lineNumber;return i||(g&&m.length===1&&(y=!1),r.onlyMatching&&(y=!1)),Xv(t,m,l,r,v,y,u)}function Gv(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(r=>/[A-Z]/.test(r)):!1}function Hv(e,t,r){let n;return n=e.length===1?e[0]:e.map(i=>t.fixedStrings?i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${i})`).join("|"),yu(n,{mode:t.fixedStrings&&e.length===1?"fixed":"perl",ignoreCase:r,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function u2(e,t,r,n,i){let s=[],a=new Fr({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"rg"}),o=0,l=0;for(let u of t){a.checkpoint();let c=e.fs.resolvePath(e.cwd,u);try{let p=await e.fs.stat(c);if(p.isFile){if(o++,r.maxFilesize>0&&p.size>r.maxFilesize)continue;if(p2(u,r,n,c,i)){if(s.length>=e.limits.maxArrayElements)throw new C(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,"array_elements");s.push(u)}}else p.isDirectory&&(l++,await c2(e,u,c,0,r,n,i,s,a,new Set))}catch(p){Ie(p)}}return{files:r.sort==="path"?s.sort():s,singleExplicitFile:o===1&&l===0}}async function c2(e,t,r,n,i,s,a,o,l,u){if(n>=i.maxDepth)return;l.visit(n);let c;if(i.followSymlinks)try{let p=await e.fs.stat(r);if(c=p.identity===void 0?p.dev!==void 0&&p.ino!==void 0?`inode:${String(p.dev)}:${String(p.ino)}`:`path:${await e.fs.realpath(r)}`:`identity:${p.identity}`,u.has(c))return;u.add(c)}catch(p){Ie(p);return}s&&await s.loadForDirectory(r);try{let p=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(r):(await e.fs.readdir(r)).map(h=>({name:h,isFile:void 0}));for(let h of p){l.checkpoint();let f=h.name;if(!i.noIgnore&&Lc.isCommonIgnored(f))continue;let d=f.startsWith("."),m=t==="."?f:t==="./"?`./${f}`:t.endsWith("/")?`${t}${f}`:`${t}/${f}`,g=e.fs.resolvePath(r,f),v,y,x=!1;if(h.isFile!==void 0&&"isDirectory"in h){let b=h;if(x=b.isSymbolicLink===!0,x&&!i.followSymlinks)continue;if(x&&i.followSymlinks)try{let w=await e.fs.stat(g);v=w.isFile,y=w.isDirectory}catch{continue}else v=b.isFile,y=b.isDirectory}else try{let b=e.fs.lstat?await e.fs.lstat(g):await e.fs.stat(g);if(x=b.isSymbolicLink===!0,x&&!i.followSymlinks)continue;let w=x&&i.followSymlinks?await e.fs.stat(g):b;v=w.isFile,y=w.isDirectory}catch{continue}if(!s?.matches(g,y)&&(!d||i.hidden||s?.isWhitelisted(g,y))){if(y)await c2(e,m,g,n+1,i,s,a,o,l,u);else if(v){if(l.visit(n+1),i.maxFilesize>0)try{if((await e.fs.stat(g)).size>i.maxFilesize)continue}catch{continue}if(p2(m,i,s,g,a)){if(o.length>=e.limits.maxArrayElements)throw new C(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,"array_elements");o.push(m)}}}}}catch(p){Ie(p)}finally{c!==void 0&&u.delete(c)}}function p2(e,t,r,n,i){let s=e.split("/").pop()||e;if(r?.matches(n,!1)||t.types.length>0&&!i.matchesType(s,t.types)||t.typesNot.length>0&&i.matchesType(s,t.typesNot))return!1;if(t.globs.length>0){let a=t.globCaseInsensitive,o=t.globs.filter(u=>!u.startsWith("!")),l=t.globs.filter(u=>u.startsWith("!")).map(u=>u.slice(1));if(o.length>0){let u=!1;for(let c of o)if(Or(s,c,a)||Or(e,c,a)){u=!0;break}if(!u)return!1}for(let u of l)if(u.startsWith("/")){if(Or(e,u.slice(1),a))return!1}else if(Or(s,u,a)||Or(e,u,a))return!1}if(t.iglobs.length>0){let a=t.iglobs.filter(l=>!l.startsWith("!")),o=t.iglobs.filter(l=>l.startsWith("!")).map(l=>l.slice(1));if(a.length>0){let l=!1;for(let u of a)if(Or(s,u,!0)||Or(e,u,!0)){l=!0;break}if(!l)return!1}for(let l of o)if(l.startsWith("/")){if(Or(e,l.slice(1),!0))return!1}else if(Or(s,l,!0)||Or(e,l,!0))return!1}return!0}function Or(e,t,r=!1){let n="^";for(let i=0;iu.size)throw c?.release(),new C("rg: file grew while being read","string_length");if(e.executionScope?.consumeInput(p.byteLength,"rg"),Uv(p)){let h;try{let f=Math.min(e.limits.maxStringLength,e.limits.maxOutputSize,Math.floor((e.executionScope?.remainingLiveBytes??e.limits.maxLiveBytes)/2));h=e.executionScope?.reserveBytes("rg decompressed text",f*2,"rg");let d=(0,Ti.gunzipSync)(p,{maxOutputLength:f}),m=new TextDecoder().decode(d);return{content:m,isBinary:m.slice(0,8192).includes("\0"),lease:Kv(c,h)}}catch(f){return h?.release(),c?.release(),Ie(f),null}}c?.release()}let s=await e.fs.stat(t);i=e.executionScope?.reserveBytes("rg file text",s.size*2,"rg");let a=await xn(e.fs,t),o=a.length;if(o>s.size)throw new C("rg: file grew while being read","string_length");e.executionScope?.consumeInput(o,"rg");let l=ke(a,e.limits.maxStringLength);return{content:l,isBinary:l.slice(0,8192).includes("\0"),lease:i}}catch(s){return i?.release(),Ie(s),null}}function Kv(...e){let t=e.filter(r=>r!==void 0);if(t.length!==0)return{release:()=>{for(let r of t)r.release()}}}async function Xv(e,t,r,n,i,s,a){let o="",l=!1,u=[],c=0,p=0,h=0,f=n.searchZip?2:50;e:for(let g=0;g{let b=await Qv(e,e.fs.resolvePath(e.cwd,x),x,n);if(!b)return null;let{content:w,isBinary:E,lease:A}=b;if(h+=w.length,E&&!n.searchBinary)return A?.release(),null;let O=i&&!n.heading?x:"";try{let N=Fa(w,r,{invertMatch:n.invertMatch,showLineNumbers:s,countOnly:n.count,countMatches:n.countMatches,filename:O,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace===null?null:Zg(n.replace),passthru:n.passthru,multiline:n.multiline,kResetGroup:a,maxWork:e.limits.maxLoopIterations,maxMatches:e.limits.maxArrayElements,signal:e.signal});return n.json&&N.matched?{file:x,result:N,content:w,isBinary:!1,lease:A}:(A?.release(),{file:x,result:N})}catch(N){throw A?.release(),N}}));for(let x of y){if(!x)continue;let{file:b,result:w}=x;if(w.matched){if(l=!0,p++,c+=w.matchCount,n.quiet&&!n.json)break e;if(n.json&&!n.quiet){let E=x.content||"";u.push(JSON.stringify({type:"begin",data:{path:{text:b}}}));let A=E.split(` `);r.lastIndex=0;let O=0;for(let N=0;N0){let L={type:"match",data:{path:{text:b},lines:{text:`${D} `},line_number:N+1,absolute_offset:O,submatches:$}};u.push(JSON.stringify(L))}O+=D.length+1}u.push(JSON.stringify({type:"end",data:{path:{text:b},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:E.length,bytes_printed:0,matched_lines:w.matchCount,matches:w.matchCount}}}))}else if(n.filesWithMatches){let E=n.nullSeparator?"\0":` `;o+=`${b}${E}`}else n.filesWithoutMatch||(n.heading&&!n.noFilename&&(o+=`${b} `),o+=w.output)}else if(n.filesWithoutMatch){let E=n.nullSeparator?"\0":` `;o+=`${b}${E}`}else n.includeZero&&(n.count||n.countMatches)&&(o+=w.output);x.lease?.release()}}n.json&&(u.push(JSON.stringify({type:"summary",data:{elapsed_total:{secs:0,nanos:0,human:"0s"},stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:t.length,searches_with_match:p,bytes_searched:h,bytes_printed:0,matched_lines:c,matches:c}}})),o=`${u.join(` `)} `);let d=n.quiet&&!n.json?"":o;if(n.stats&&!n.json){let g=["",`${c} matches`,`${c} matched lines`,`${p} files contained matches`,`${t.length} files searched`,`${h} bytes searched`].join(` `);d+=`${g} `}let m;return m=n.filesWithoutMatch?o.length>0?0:1:+!l,{stdout:d,stderr:"",exitCode:m}}var Yv=M(()=>{Et(),se(),Lt(),_r(),ji(),H(),at(),Kg(),s2(),Bv()}),h2={};re(h2,{flagsForFuzzing:()=>d2,rgCommand:()=>f2});var sh,f2,d2,Jv=M(()=>{le(),s2(),_v(),Yv(),sh={name:"rg",summary:"recursively search for a pattern",usage:"rg [OPTIONS] PATTERN [PATH ...]",description:`rg (ripgrep) recursively searches directories for a regex pattern. Unlike grep, rg is recursive by default and respects .gitignore files. EXAMPLES: rg foo Search for 'foo' in current directory rg foo src/ Search in src/ directory rg -i foo Case-insensitive search rg -w foo Match whole words only rg -t js foo Search only JavaScript files rg -g '*.ts' foo Search files matching glob rg --hidden foo Include hidden files rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},f2={name:"rg",async execute(e,t){if(he(e))return ce(sh);if(e.includes("--type-list"))return{stdout:Cv(),stderr:"",exitCode:0};let r=Fv(e);return r.success?qv({ctx:t,options:r.options,paths:r.paths,explicitLineNumbers:r.explicitLineNumbers}):r.error}},d2={name:"rg",flags:[{flag:"-i",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-N",type:"boolean"},{flag:"--hidden",type:"boolean"},{flag:"--no-ignore",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-g",type:"value",valueHint:"pattern"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-T",type:"value",valueHint:"string"}],needsArgs:!0}});function Zt(e,t,r){if(!e||Kt.isInSandboxedContext())return;let n=`${t} ${r} attempted outside defense context`;throw new Ae(n,{timestamp:Date.now(),type:"missing_defense_context",message:n,path:"DefenseInDepthBox.context",stack:Error().stack,executionId:Kt.getCurrentExecutionId()})}async function In(e,t,r,n){Zt(e,t,`${r} (pre-await)`);let i=await n();return Zt(e,t,`${r} (post-await)`),i}var vn=M(()=>{Ar()});function m2(e){let t="",r=0,n=!1;for(;r=127?`\\${i.toString(8).padStart(3,"0")}`:n}return`${t}$`}var ha,tb=M(()=>{ha=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]])});function rb(e,t,r){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:e,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:t,pendingFileReads:[],pendingFileWrites:[],rangeStates:r||new Map,linesConsumedInCycle:0}}function nb(e){return typeof e=="object"&&"first"in e&&"step"in e}function ib(e){return typeof e=="object"&&"offset"in e}function pi(e,t,r,n,i){if(e==="$")return t===r;if(typeof e=="number")return t===e;if(nb(e)){let{first:s,step:a}=e;return a===0?t===s:(t-s)%a===0&&t>=s}if(typeof e=="object"&&"pattern"in e)try{let s=e.pattern;return s===""&&i?.lastPattern?s=i.lastPattern:s!==""&&i&&(i.lastPattern=s),de(g2(m2(s))).test(n)}catch{return!1}return!1}function dl(e){let t=r=>r===void 0?"undefined":r==="$"?"$":typeof r=="number"?String(r):"pattern"in r?`/${r.pattern}/`:"first"in r?`${r.first}~${r.step}`:"unknown";return`${t(e.start)},${t(e.end)}`}function sb(e,t,r,n,i,s){if(!e||!e.start&&!e.end)return!0;let a=e.start,o=e.end;if(a!==void 0&&o===void 0)return pi(a,t,r,n,s);if(a!==void 0&&o!==void 0){let l=typeof a=="object"&&"pattern"in a,u=typeof o=="object"&&"pattern"in o,c=ib(o);if(c&&i){let p=dl(e),h=i.get(p);return h||(h={active:!1},i.set(p,h)),h.active?(t>=(h.startLine||t)+o.offset&&(h.active=!1,i.set(p,h)),!0):pi(a,t,r,n,s)?(h.active=!0,h.startLine=t,i.set(p,h),o.offset===0&&(h.active=!1,i.set(p,h)),!0):!1}if(!l&&!u&&!c){let p=typeof a=="number"?a:a==="$"?r:1,h=typeof o=="number"?o:r;if(p<=h)return t>=p&&t<=h;if(i){let f=dl(e),d=i.get(f);return d||(d={active:!1},i.set(f,d)),!d.completed&&t>=p&&(d.completed=!0,i.set(f,d),!0)}return!1}if(i){let p=dl(e),h=i.get(p);if(h||(h={active:!1},i.set(p,h)),h.active)return pi(o,t,r,n,s)&&(h.active=!1,typeof a=="number"&&(h.completed=!0),i.set(p,h)),!0;{if(h.completed)return!1;let f=!1;return f=typeof a=="number"?t>=a:pi(a,t,r,n,s),f?(h.active=!0,h.startLine=t,i.set(p,h),pi(o,t,r,n,s)&&(h.active=!1,typeof a=="number"&&(h.completed=!0),i.set(p,h)),!0):!1}}return pi(a,t,r,n,s)}return!0}function Wn(e,t,r,n,i,s){let a=sb(e,t,r,n,i,s);return e?.negated?!a:a}function ab(e,t,r,n){let i="",s=0,a=!1;for(;s<=e.length;){t.lastIndex=s;let o=t.exec(e);if(!o){i+=e.slice(s);break}if(o.index!==s){i+=e.slice(s,o.index),s=o.index,a=!1;continue}let l=o[0],u=o.slice(1);if(a&&l.length===0){if(s=1&&a<=9){n+=r[a-1]||"",i+=2;continue}n+=s,i+=2;continue}if(e[i]==="&"){n+=t,i++;continue}n+=e[i],i++}return n}function ah(e,t,r){if(t>0&&e.length>t)throw new C(`sed: ${r} size limit exceeded (${t} bytes)`,"string_length")}function ob(e,t,r){let{lineNumber:n,totalLines:i,patternSpace:s}=t;if(e.type==="label"){t.coverage?.hit(`sed:cmd:${e.type}`);return}if(Wn(e.address,n,i,s,t.rangeStates,t))switch(t.coverage?.hit(`sed:cmd:${e.type}`),e.type){case"substitute":{let a=e,o="";a.global&&(o+="g"),a.ignoreCase&&(o+="i");let l=a.pattern;l===""&&t.lastPattern?l=t.lastPattern:l!==""&&(t.lastPattern=l);let u=g2(a.extendedRegex?l:m2(l));try{let c=de(u,o),p=c.test(t.patternSpace);if(c.lastIndex=0,p){if(t.substitutionMade=!0,a.nthOccurrence&&a.nthOccurrence>0&&!a.global){let h=0,f=a.nthOccurrence;t.patternSpace=de(u,`g${a.ignoreCase?"i":""}`).replace(t.patternSpace,(d,...m)=>{if(h++,h===f){let g=m.slice(0,-2);return ml(a.replacement,d,g)}return d})}else if(a.global){let h=de(u,`g${a.ignoreCase?"i":""}`);t.patternSpace=ab(t.patternSpace,h,a.replacement,(f,d)=>ml(a.replacement,f,d))}else t.patternSpace=c.replace(t.patternSpace,(h,...f)=>{let d=f.slice(0,-2);return ml(a.replacement,h,d)});a.printOnMatch&&t.lineNumberOutput.push(t.patternSpace)}}catch{}break}case"print":t.lineNumberOutput.push(t.patternSpace);break;case"printFirstLine":{let a=t.patternSpace.indexOf(` `);a===-1?t.lineNumberOutput.push(t.patternSpace):t.lineNumberOutput.push(t.patternSpace.slice(0,a));break}case"delete":t.deleted=!0;break;case"deleteFirstLine":{let a=t.patternSpace.indexOf(` `);a===-1?t.deleted=!0:(t.patternSpace=t.patternSpace.slice(a+1),t.restartCycle=!0,t.inDRestartedCycle=!0);break}case"zap":t.patternSpace="";break;case"append":t.appendBuffer.push(e.text);break;case"insert":t.appendBuffer.unshift(`__INSERT__${e.text}`);break;case"change":t.deleted=!0,t.changedText=e.text;break;case"hold":t.holdSpace=t.patternSpace;break;case"holdAppend":t.holdSpace?t.holdSpace+=` ${t.patternSpace}`:t.holdSpace=t.patternSpace,ah(t.holdSpace,r?.maxStringLength??0,"hold space");break;case"get":t.patternSpace=t.holdSpace;break;case"getAppend":t.patternSpace+=` ${t.holdSpace}`,ah(t.patternSpace,r?.maxStringLength??0,"pattern space");break;case"exchange":{let a=t.patternSpace;t.patternSpace=t.holdSpace,t.holdSpace=a;break}case"next":t.printed=!0;break;case"quit":t.quit=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case"quitSilent":t.quit=!0,t.quitSilent=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case"list":{let a=eb(t.patternSpace);t.lineNumberOutput.push(a);break}case"printFilename":t.currentFilename&&t.lineNumberOutput.push(t.currentFilename);break;case"version":{let a=[4,8,0];if(e.minVersion){let o=e.minVersion.split("."),l=[],u=!1;for(let c of o){let p=parseInt(c,10);if(Number.isNaN(p)||p<0){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: invalid version string: ${e.minVersion}`,u=!0;break}l.push(p)}if(!u){for(;l.length<3;)l.push(0);for(let c=0;c<3;c++){if(l[c]>a[c]){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: this is not GNU sed version ${e.minVersion}`;break}if(l[c]s)throw new C(`sed: command execution exceeded maximum iterations (${s})`,"iterations");if(t.deleted||t.quit||t.quitSilent||t.restartCycle)break;let l=e[o];if(l.type==="next"){if(Wn(l.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t))if(t.coverage?.hit("sed:cmd:next"),t.nCommandOutput.push(t.patternSpace),r&&r.currentLineIndex+t.linesConsumedInCycle+1{H(),at(),tb(),x2=1e4}),ne,v2,cb=M(()=>{H(),(function(e){e.NUMBER="NUMBER",e.DOLLAR="DOLLAR",e.PATTERN="PATTERN",e.STEP="STEP",e.RELATIVE_OFFSET="RELATIVE_OFFSET",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.SEMICOLON="SEMICOLON",e.NEWLINE="NEWLINE",e.COMMA="COMMA",e.NEGATION="NEGATION",e.COMMAND="COMMAND",e.SUBSTITUTE="SUBSTITUTE",e.TRANSLITERATE="TRANSLITERATE",e.LABEL_DEF="LABEL_DEF",e.BRANCH="BRANCH",e.BRANCH_ON_SUBST="BRANCH_ON_SUBST",e.BRANCH_ON_NO_SUBST="BRANCH_ON_NO_SUBST",e.TEXT_CMD="TEXT_CMD",e.FILE_READ="FILE_READ",e.FILE_READ_LINE="FILE_READ_LINE",e.FILE_WRITE="FILE_WRITE",e.FILE_WRITE_LINE="FILE_WRITE_LINE",e.EXECUTE="EXECUTE",e.VERSION="VERSION",e.EOF="EOF",e.ERROR="ERROR"})(ne||={}),v2=class{maxInputLength;maxTokens;input;pos=0;line=1;column=1;constructor(e,t=1048576,r=1e5){this.maxInputLength=t,this.maxTokens=r,this.input=e}tokenize(){if(this.input.length>this.maxInputLength)throw new C(`sed: script size limit exceeded (${this.maxInputLength} bytes)`,"string_length");let e=[];for(;this.pos=this.maxTokens-1)throw new C(`sed: token limit exceeded (${this.maxTokens})`,"array_elements");e.push(t)}}return e.push(this.makeToken(ne.EOF,"")),e}makeToken(e,t,r){return{type:e,value:t,line:this.line,column:this.column,...r}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===` `?(this.line++,this.column=1):this.column++,e}readEscapedString(e){let t="";for(;this.pos=this.input.length)return null;let e=this.line,t=this.column,r=this.peek();return r===` `?(this.advance(),{type:ne.NEWLINE,value:` `,line:e,column:t}):r===";"?(this.advance(),{type:ne.SEMICOLON,value:";",line:e,column:t}):r==="{"?(this.advance(),{type:ne.LBRACE,value:"{",line:e,column:t}):r==="}"?(this.advance(),{type:ne.RBRACE,value:"}",line:e,column:t}):r===","?(this.advance(),{type:ne.COMMA,value:",",line:e,column:t}):r==="!"?(this.advance(),{type:ne.NEGATION,value:"!",line:e,column:t}):r==="$"?(this.advance(),{type:ne.DOLLAR,value:"$",line:e,column:t}):this.isDigit(r)?this.readNumber():r==="+"&&this.isDigit(this.input[this.pos+1]||"")?this.readRelativeOffset():r==="/"?this.readPattern():r===":"?this.readLabelDef():this.readCommand()}readNumber(){let e=this.line,t=this.column,r="";for(;this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="~"){this.advance();let n="";for(;this.isDigit(this.peek());)n+=this.advance();let i=parseInt(r,10),s=parseInt(n,10)||0;return{type:ne.STEP,value:`${i}~${s}`,first:i,step:s,line:e,column:t}}return{type:ne.NUMBER,value:parseInt(r,10),line:e,column:t}}readRelativeOffset(){let e=this.line,t=this.column;this.advance();let r="";for(;this.isDigit(this.peek());)r+=this.advance();let n=parseInt(r,10)||0;return{type:ne.RELATIVE_OFFSET,value:`+${n}`,offset:n,line:e,column:t}}readPattern(){let e=this.line,t=this.column;this.advance();let r="",n=!1;for(;this.pos="0"&&e<="9"}}});function pb(e,t=!1,r){if(r){if(e.length>r.maxArrayElements)throw new C(`sed: script count limit exceeded (${r.maxArrayElements})`,"array_elements");let l=Math.max(0,e.length-1);for(let u of e)if(l+=q(u),l>r.maxStringLength)throw new C(`sed: script size limit exceeded (${r.maxStringLength} bytes)`,"string_length")}let n=!1,i=!1,s=[];for(let l=0;l0&&s[s.length-1].endsWith("\\")){let c=s[s.length-1];s[s.length-1]=`${c} ${u}`}else s.push(u)}let a=s.join(` `),o=new E2([a],t||i,r).parse();if(!o.error&&o.commands.length>0){let l=hb(o.commands);if(l)return{commands:[],error:l,silentMode:n,extendedRegexMode:i}}return{...o,silentMode:n,extendedRegexMode:i}}function hb(e){let t=new Set;b2(e,t);let r=w2(e,t);if(r)return`undefined label '${r}'`}function b2(e,t){for(let r of e)r.type==="label"?t.add(r.name):r.type==="group"&&b2(r.commands,t)}function w2(e,t){for(let r of e){if((r.type==="branch"||r.type==="branchOnSubst"||r.type==="branchOnNoSubst")&&r.label&&!t.has(r.label))return r.label;if(r.type==="group"){let n=w2(r.commands,t);if(n)return n}}}var E2,fb=M(()=>{H(),wt(),cb(),E2=class{scripts;limits;tokens=[];pos=0;extendedRegex=!1;constructor(e,t=!1,r){this.scripts=e,this.limits=r,this.extendedRegex=t}parse(){let e=[];for(let t of this.scripts){let r=new v2(t,this.limits?.maxStringLength,this.limits?.maxArrayElements);for(this.tokens=r.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(ne.NEWLINE)||this.check(ne.SEMICOLON)){this.advance();continue}let n=this.pos,i=this.parseCommand();if(i.error)return{commands:[],error:i.error};if(i.command&&e.push(i.command),this.pos===n&&!this.isAtEnd())return{commands:[],error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();if(e?.error)return{command:null,error:e.error};let t=e?.address;for(this.check(ne.NEGATION)&&(this.advance(),t&&(t.negated=!0));this.check(ne.NEWLINE)||this.check(ne.SEMICOLON);)this.advance();if(this.isAtEnd())return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:"command expected"}:{command:null};let r=this.peek();switch(r.type){case ne.COMMAND:return this.parseSimpleCommand(r,t);case ne.SUBSTITUTE:return this.parseSubstituteFromToken(r,t);case ne.TRANSLITERATE:return this.parseTransliterateFromToken(r,t);case ne.LABEL_DEF:return this.advance(),{command:{type:"label",name:r.label||""}};case ne.BRANCH:return this.advance(),{command:{type:"branch",address:t,label:r.label}};case ne.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:t,label:r.label}};case ne.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:t,label:r.label}};case ne.TEXT_CMD:return this.advance(),this.parseTextCommand(r,t);case ne.FILE_READ:return this.advance(),{command:{type:"readFile",address:t,filename:r.filename||""}};case ne.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:t,filename:r.filename||""}};case ne.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:t,filename:r.filename||""}};case ne.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:t,filename:r.filename||""}};case ne.EXECUTE:return this.advance(),{command:{type:"execute",address:t,command:r.command}};case ne.VERSION:return this.advance(),{command:{type:"version",address:t,minVersion:r.label}};case ne.LBRACE:return this.parseGroup(t);case ne.RBRACE:return{command:null};case ne.ERROR:return{command:null,error:`invalid command: ${r.value}`};default:return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:"command expected"}:{command:null}}}parseSimpleCommand(e,t){this.advance();let r=e.value;switch(r){case"p":return{command:{type:"print",address:t}};case"P":return{command:{type:"printFirstLine",address:t}};case"d":return{command:{type:"delete",address:t}};case"D":return{command:{type:"deleteFirstLine",address:t}};case"h":return{command:{type:"hold",address:t}};case"H":return{command:{type:"holdAppend",address:t}};case"g":return{command:{type:"get",address:t}};case"G":return{command:{type:"getAppend",address:t}};case"x":return{command:{type:"exchange",address:t}};case"n":return{command:{type:"next",address:t}};case"N":return{command:{type:"nextAppend",address:t}};case"q":return{command:{type:"quit",address:t}};case"Q":return{command:{type:"quitSilent",address:t}};case"z":return{command:{type:"zap",address:t}};case"=":return{command:{type:"lineNumber",address:t}};case"l":return{command:{type:"list",address:t}};case"F":return{command:{type:"printFilename",address:t}};default:return{command:null,error:`unknown command: ${r}`}}}parseSubstituteFromToken(e,t){this.advance();let r=e.flags||"",n,i=r.match(/(\d+)/);return i&&(n=parseInt(i[1],10)),{command:{type:"substitute",address:t,pattern:e.pattern||"",replacement:e.replacement||"",global:r.includes("g"),ignoreCase:r.includes("i")||r.includes("I"),printOnMatch:r.includes("p"),nthOccurrence:n,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,t){this.advance();let r=e.source||"",n=e.dest||"";return r.length===n.length?{command:{type:"transliterate",address:t,source:r,dest:n}}:{command:null,error:"transliteration sets must have same length"}}parseTextCommand(e,t){let r=e.value,n=e.text||"";switch(r){case"a":return{command:{type:"append",address:t,text:n}};case"i":return{command:{type:"insert",address:t,text:n}};case"c":return{command:{type:"change",address:t,text:n}};default:return{command:null,error:`unknown text command: ${r}`}}}parseGroup(e){this.advance();let t=[];for(;!this.isAtEnd()&&!this.check(ne.RBRACE);){if(this.check(ne.NEWLINE)||this.check(ne.SEMICOLON)){this.advance();continue}let r=this.pos,n=this.parseCommand();if(n.error)return{command:null,error:n.error};if(n.command&&t.push(n.command),this.pos===r&&!this.isAtEnd())return{command:null,error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}return this.check(ne.RBRACE)?(this.advance(),{command:{type:"group",address:e,commands:t}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){if(this.check(ne.COMMA))return{error:"expected context address"};let e=this.parseAddress();if(e===void 0)return;let t;if(this.check(ne.RELATIVE_OFFSET))t={offset:this.advance().offset||0};else if(this.check(ne.COMMA)&&(this.advance(),t=this.parseAddress(),t===void 0))return{error:"expected context address"};return{address:{start:e,end:t}}}parseAddress(){let e=this.peek();switch(e.type){case ne.NUMBER:return this.advance(),e.value;case ne.DOLLAR:return this.advance(),"$";case ne.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case ne.STEP:return this.advance(),{first:e.first||0,step:e.step||0};case ne.RELATIVE_OFFSET:return this.advance(),{offset:e.offset||0};default:return}}peek(){return this.tokens[this.pos]||{type:ne.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===ne.EOF}}}),S2={};re(S2,{flagsForFuzzing:()=>C2,sedCommand:()=>A2});async function gl(e,t,r,n={}){let{limits:i,filename:s,fs:a,cwd:o,coverage:l,requireDefenseContext:u}=n;Zt(u,"sed","processing entry");let c=(D,$)=>In(u,"sed",D,$),p=e.endsWith(` `),h=e.split(` `);h.length>0&&h[h.length-1]===""&&h.pop();let f=h.length,d="",m,g=!1,v=i?.maxStringLength??0,y=D=>{if(d+=D,v>0&&d.length>v)throw new C(`sed: output size limit exceeded (${v} bytes)`,"string_length")},x="",b,w=new Map,E=new Map,A=new Map,O=new Map,N=i?{maxIterations:i.maxSedIterations,maxStringLength:v}:void 0;for(let D=0;D1e4)break;if($.restartCycle=!1,$.pendingFileReads=[],$.pendingFileWrites=[],y2(t,$,L,N),a&&o){for(let F of $.pendingFileReads){let G=a.resolvePath(o,F.filename);try{if(F.wholeFile){let z=await c("read command file",()=>a.readFile(G));$.appendBuffer.push(z.replace(/\n$/,""))}else{if(!E.has(G)){let ae=await c("read command file line cache",()=>a.readFile(G));E.set(G,ae.split(` `)),A.set(G,0)}let z=E.get(G),V=A.get(G);z&&V!==void 0&&V0;for(let F of $.lineNumberOutput)y(`${F} `);let B=[],j=[];for(let F of $.appendBuffer)F.startsWith("__INSERT__")?B.push(F.slice(10)):j.push(F);for(let F of B)y(`${F} `);let P=!1;!$.deleted&&!$.quitSilent?r?$.printed&&(y(`${$.patternSpace} `),P=!0):(y(`${$.patternSpace} `),P=!0):$.changedText!==void 0&&(y(`${$.changedText} `),P=!0);for(let F of j)y(`${F} `);if(g=(R||P)&&j.length===0,$.quit||$.quitSilent){if($.exitCode!==void 0&&(m=$.exitCode),$.errorMessage)return{output:"",exitCode:m||1,errorMessage:$.errorMessage};break}}if(a&&o)for(let[D,$]of O)try{await c("flush pending file writes",()=>a.writeFile(D,$))}catch(L){if(L instanceof Ae)throw L}return!p&&g&&d.endsWith(` `)&&(d=d.slice(0,-1)),{output:d,exitCode:m}}var oh,A2,C2,db=M(()=>{se(),Mr(),H(),vn(),Ar(),le(),ub(),fb(),oh={name:"sed",summary:"stream editor for filtering and transforming text",usage:"sed [OPTION]... {script} [input-file]...",options:["-n, --quiet, --silent suppress automatic printing of pattern space","-e script add the script to commands to be executed","-f script-file read script from file","-i, --in-place edit files in place","-E, -r, --regexp-extended use extended regular expressions"," --help display this help and exit"],description:`Commands: s/regexp/replacement/[flags] substitute d delete pattern space p print pattern space a\\ text append text after line i\\ text insert text before line c\\ text change (replace) line with text h copy pattern space to hold space H append pattern space to hold space g copy hold space to pattern space G append hold space to pattern space x exchange pattern and hold spaces n read next line into pattern space N append next line to pattern space y/source/dest/ transliterate characters = print line number l list pattern space (escape special chars) b [label] branch to label t [label] branch on substitution T [label] branch if no substitution :label define label q quit Q quit without printing Addresses: N line number $ last line /regexp/ lines matching regexp N,M range from line N to M first~step every step-th line starting at first`},A2={name:"sed",async execute(e,t){Zt(t.requireDefenseContext,"sed","execution entry");let r=(m,g)=>In(t.requireDefenseContext,"sed",m,g);if(he(e))return ce(oh);let n=[],i=[],s=!1,a=!1,o=!1,l=[];for(let m=0;m1){for(let v of g.slice(1))if(v!=="n"&&v!=="e"&&v!=="f"&&v!=="i"&&v!=="E"&&v!=="r")return ve("sed",`-${v}`);g.includes("n")&&(s=!0),g.includes("i")&&(a=!0),(g.includes("E")||g.includes("r"))&&(o=!0),g.includes("e")&&!g.includes("n")&&!g.includes("i")&&m+1t.fs.readFile(g));for(let y of v.split(` `)){let x=y.trim();x&&!x.startsWith("#")&&n.push(x)}}catch(v){if(v instanceof Ae)throw v;return{stdout:"",stderr:`sed: couldn't open file ${m}: No such file or directory `,exitCode:1}}}if(n.length===0)return{stdout:"",stderr:`sed: no script specified `,exitCode:1};let{commands:u,error:c,silentMode:p}=pb(n,o,t.limits);if(c)return{stdout:"",stderr:`sed: ${c} `,exitCode:1};let h=!!(s||p);if(a){if(l.length===0)return{stdout:"",stderr:`sed: -i requires at least one file argument `,exitCode:1};for(let m of l){if(m==="-")continue;let g=t.fs.resolvePath(t.cwd,m);try{let v=await r("in-place input read",()=>t.fs.readFile(g)),y=await r("in-place processing",()=>gl(v,u,h,{limits:t.limits,filename:m,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));if(y.errorMessage)return{stdout:"",stderr:`${y.errorMessage} `,exitCode:y.exitCode??1};await r("in-place output write",()=>t.fs.writeFile(g,y.output))}catch(v){if(v instanceof Ae)throw v;return v instanceof C?{stdout:"",stderr:`sed: ${xt(v.message)} `,exitCode:C.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory `,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}let f="";if(l.length===0){f=ke(t.stdin);try{let m=await r("stdin processing",()=>gl(f,u,h,{limits:t.limits,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage} `:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof Ae)throw m;if(m instanceof C)return{stdout:"",stderr:`sed: ${xt(m.message)} `,exitCode:C.EXIT_CODE};throw m}}let d=!1;for(let m of l){let g;if(m==="-")d?g="":(g=ke(t.stdin),d=!0);else{let v=t.fs.resolvePath(t.cwd,m);try{g=await r("input file read",()=>t.fs.readFile(v))}catch(y){if(y instanceof Ae)throw y;return y instanceof C?{stdout:"",stderr:`sed: ${xt(y.message)} `,exitCode:C.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory `,exitCode:1}}}f.length>0&&g.length>0&&!f.endsWith(` `)&&(f+=` `),f+=g}try{let m=await r("final processing",()=>gl(f,u,h,{limits:t.limits,filename:l.length===1?l[0]:void 0,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage} `:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof Ae)throw m;if(m instanceof C)return{stdout:"",stderr:`sed: ${xt(m.message)} `,exitCode:C.EXIT_CODE};throw m}}},C2={name:"sed",flags:[{flag:"-n",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-E",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-e",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function Kr(e){return Object.assign(Object.create(null),Object.fromEntries(e))}function pr(e,t){return Object.assign(Object.create(null),Object.fromEntries(e),t)}function za(...e){return Object.assign(Object.create(null),...e)}var Rn=M(()=>{});function mb(e={}){let{fieldSep:t=$2,maxIterations:r=k2,maxRecursionDepth:n=N2,maxOutputSize:i=0,maxArrayElements:s=1e5,fs:a,cwd:o,exec:l,coverage:u,requireDefenseContext:c}=e;return{FS:" ",OFS:" ",ORS:` `,OFMT:"%.6g",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,getlineCommandStreams:new Map,getlineFileStreams:new Map,fieldSep:t,maxIterations:r,maxRecursionDepth:n,maxOutputSize:i,maxArrayElements:s,arrayElementCount:0,recordsProcessed:0,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:a,cwd:o,exec:l,coverage:u,requireDefenseContext:c}}var k2,N2,$2,gb=M(()=>{at(),k2=1e4,N2=100,$2=new ho(/\s+/)});function yb(e,t,r){switch(r){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return t===0?0:e/t;case"%":return t===0?0:e%t;case"^":case"**":return e**t;default:return 0}}var xb=M(()=>{});function Sr(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function Dt(e){return typeof e=="string"?e:String(e)}function Mc(e){return new st(e,"awk string",()=>new C(`string size limit exceeded (${e} bytes)`,"string_length"))}function pn(e){return e.maxOutputSize>0?e.maxOutputSize:_c}function Ba(e,t,r,n,i){let s=Mc(i),a=0,o=0,l=0;for(let u of t.matchAll(e)){let c=u.index??0;o++,s.append(e.slice(a,c)),r(o)?(s.append(n(u)),l++):s.append(u[0]),a=c+u[0].length}return s.append(e.slice(a)),{value:s.build(),replacements:l}}async function mo(e,t){if(e.type==="regex")return e.pattern;let r=Dt(await t.evalExpr(e));return r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)),r}async function O2(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(Sr(await t.evalExpr(e.index)))}`:"$0":"$0"}function T2(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let r=parseInt(e.slice(1),10)-1;return t.fields[r]||""}return Dt(t.vars[e]??"")}function I2(e,t,r){if(e==="$0")r.line=t,r.fields=r.FS===" "?t.trim().split(/\s+/).filter(Boolean):r.fieldSep.split(t),r.NF=r.fields.length;else if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;for(;r.fields.length<=n;)r.fields.push("");r.fields[n]=t,r.NF=r.fields.length,r.line=r.fields.join(r.OFS)}else r.vars[e]=t}async function vb(e,t,r){return e.length===0?t.line.length:Dt(await r.evalExpr(e[0])).length}async function bb(e,t,r){if(e.length<2)return"";let n=Dt(await r.evalExpr(e[0])),i=Math.floor(Sr(await r.evalExpr(e[1])))-1;if(e.length>=3){let s=Math.floor(Sr(await r.evalExpr(e[2])));return n.substr(Math.max(0,i),s)}return n.substr(Math.max(0,i))}async function wb(e,t,r){if(e.length<2)return 0;let n=Dt(await r.evalExpr(e[0])),i=Dt(await r.evalExpr(e[1])),s=n.indexOf(i);return s===-1?0:s+1}async function Eb(e,t,r){if(e.length<2)return 0;let n=Dt(await r.evalExpr(e[0])),i=e[1];if(i.type!=="variable")return 0;let s=i.name,a=t.FS;if(e.length>=3){let c=e[2];if(c.type==="regex")a=de(c.pattern);else{let p=Dt(await r.evalExpr(c));a=p===" "?de("\\s+"):p}}else t.FS===" "&&(a=de("\\s+"));let o=Object.keys(t.arrays[s]??{}).length,l=t.maxArrayElements-t.arrayElementCount+o,u=typeof a=="string"?n.split(a,l+1):a.split(n,l+1);if(u.length>l)throw new C(`array element limit exceeded (${t.maxArrayElements})`,"array_elements");t.arrays[s]=Object.create(null);for(let c=0;cl===1,l=>R2(i,l[0],pn(t)),pn(t));return I2(s,o.value,t),o.replacements}catch(o){return Ie(o),0}}async function Ab(e,t,r){if(e.length<2)return 0;let n=await mo(e[0],r),i=Dt(await r.evalExpr(e[1])),s=await O2(e[2],r),a=T2(s,t);try{let o=Ba(a,de(n,"g"),()=>!0,l=>R2(i,l[0],pn(t)),pn(t));return I2(s,o.value,t),o.replacements}catch(o){return Ie(o),0}}function R2(e,t,r){let n=Mc(r),i=0;for(;i=4?Dt(await r.evalExpr(e[3])):t.line;try{let o=s.toLowerCase()==="g",l=o?0:parseInt(s,10)||1;return o?Ba(a,de(n,"g"),()=>!0,u=>lh(i,u[0],u.slice(1),pn(t)),pn(t)).value:Ba(a,de(n,"g"),u=>u===l,u=>lh(i,u[0],u.slice(1),pn(t)),pn(t)).value}catch(o){return Ie(o),a}}function lh(e,t,r,n){let i=Mc(n),s=0;for(;s="1"&&a<="9"){let o=parseInt(a,10)-1;i.append(r[o]||""),s+=2}else a==="n"?(i.append(` `),s+=2):a==="t"?(i.append(" "),s+=2):(i.append(a),s+=2)}else e[s]==="&"?(i.append(t),s++):(i.append(e[s]),s++);return i.build()}async function Nb(e,t,r){return e.length===0?"":Dt(await r.evalExpr(e[0])).toLowerCase()}async function $b(e,t,r){return e.length===0?"":Dt(await r.evalExpr(e[0])).toUpperCase()}async function Ob(e,t,r){if(e.length===0)return"";let n=Dt(await r.evalExpr(e[0])),i=[];for(let s=1;s0?Sr(await r.evalExpr(e[0])):0,i=e.length>1?Sr(await r.evalExpr(e[1])):0;return Math.atan2(n,i)}async function Lb(e,t,r){return e.length===0?0:Math.log(Sr(await r.evalExpr(e[0])))}async function Mb(e,t,r){return e.length===0?1:Math.exp(Sr(await r.evalExpr(e[0])))}function Fb(e,t,r){return t.random?t.random():Math.random()}async function _b(e,t,r){let n=e.length>0?Sr(await r.evalExpr(e[0])):Date.now();return t.vars._srand_seed=n,n}function zb(e,t){return()=>{throw Error(`${e}() is not supported - ${t}`)}}function yl(e){return()=>{throw Error(`function '${e}()' is not implemented`)}}function Fc(e,t,r=_c){let n=0,i="",s=0,a=0,o=Math.min(P2,r),l=u=>{let c=q(u);if(c>r-s)throw new C(`formatted string size limit exceeded (${r} bytes)`,"string_length");i+=u,s+=c};for(;ad&&e[u]==="$"?(f=parseInt(e.substring(d,u),10)-1,u++):u=d;let m=()=>{if(uo)throw new C(`printf width limit exceeded (${o} bytes)`,"string_length");if(e[u]==="."){if(u++,e[u]==="*"){let y=t[n++],x=y===void 0?0:Math.floor(Number(y));if(!Number.isFinite(x)||!Number.isSafeInteger(x))throw new C(`printf precision limit exceeded (${o} bytes)`,"string_length");h=x<0?"":String(x),u++}else for(;uo)throw new C(`printf precision limit exceeded (${o} bytes)`,"string_length")}m();let g=e[u],v=t[f===void 0?n:f];switch(g){case"s":{let y=v===void 0?"":String(v);if(h&&(y=y.substring(0,parseInt(h,10))),p){let x=parseInt(p,10);y=c.includes("-")?y.padEnd(x):y.padStart(x)}l(y),f===void 0&&n++;break}case"d":case"i":{let y=v===void 0?0:Math.floor(Number(v));Number.isNaN(y)&&(y=0);let x=y<0,b=Math.abs(y).toString();if(h){let A=parseInt(h,10);b=b.padStart(A,"0")}let w="";x?w="-":c.includes("+")?w="+":c.includes(" ")&&(w=" ");let E=w+b;if(p){let A=parseInt(p,10);E=c.includes("-")?E.padEnd(A):c.includes("0")&&!h?w+b.padStart(A-w.length,"0"):E.padStart(A)}l(E),f===void 0&&n++;break}case"f":{let y=v===void 0?0:Number(v);Number.isNaN(y)&&(y=0);let x=h?parseInt(h,10):6;if(x>100)throw new C("printf floating-point precision limit exceeded (100 digits)","string_length");let b=y.toFixed(x);if(p){let w=parseInt(p,10);b=c.includes("-")?b.padEnd(w):b.padStart(w)}l(b),f===void 0&&n++;break}case"e":case"E":{let y=v===void 0?0:Number(v);Number.isNaN(y)&&(y=0);let x=h?parseInt(h,10):6;if(x>100)throw new C("printf floating-point precision limit exceeded (100 digits)","string_length");let b=y.toExponential(x);if(g==="E"&&(b=b.toUpperCase()),p){let w=parseInt(p,10);b=c.includes("-")?b.padEnd(w):b.padStart(w)}l(b),f===void 0&&n++;break}case"g":case"G":{let y=v===void 0?0:Number(v);Number.isNaN(y)&&(y=0);let x=h?parseInt(h,10):6;if(x>100)throw new C("printf floating-point precision limit exceeded (100 digits)","string_length");let b=y===0?0:Math.floor(Math.log10(Math.abs(y))),w;if(y===0?w="0":b<-4||b>=x?(w=y.toExponential(x-1),g==="G"&&(w=w.toUpperCase())):w=y.toPrecision(x),w.includes(".")&&(w=w.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),w.includes("e")&&(w=w.replace(/\.?0+e/,"e")),p){let E=parseInt(p,10);w=c.includes("-")?w.padEnd(E):w.padStart(E)}l(w),f===void 0&&n++;break}case"x":case"X":{let y=v===void 0?0:Math.floor(Number(v));Number.isNaN(y)&&(y=0);let x=Math.abs(y).toString(16);if(g==="X"&&(x=x.toUpperCase()),h){let E=parseInt(h,10);x=x.padStart(E,"0")}let b=y<0?"-":"",w=b+x;if(p){let E=parseInt(p,10);w=c.includes("-")?w.padEnd(E):c.includes("0")&&!h?b+x.padStart(E-b.length,"0"):w.padStart(E)}l(w),f===void 0&&n++;break}case"o":{let y=v===void 0?0:Math.floor(Number(v));Number.isNaN(y)&&(y=0);let x=Math.abs(y).toString(8);if(h){let E=parseInt(h,10);x=x.padStart(E,"0")}let b=y<0?"-":"",w=b+x;if(p){let E=parseInt(p,10);w=c.includes("-")?w.padEnd(E):c.includes("0")&&!h?b+x.padStart(E-b.length,"0"):w.padStart(E)}l(w),f===void 0&&n++;break}case"c":l(typeof v=="number"?String.fromCharCode(v):String(v??"").charAt(0)||""),f===void 0&&n++;break;case"%":l("%");break;default:l(e.substring(a,u+1))}a=u+1}else if(e[a]==="\\"&&a+1{Et(),se(),Lt(),H(),at(),_c=10485760,P2=1e4,D2=new Map([["length",vb],["substr",bb],["index",wb],["split",Eb],["sub",Sb],["gsub",Ab],["match",Cb],["gensub",kb],["tolower",Nb],["toupper",$b],["sprintf",Ob],["int",Tb],["sqrt",Ib],["sin",Rb],["cos",Pb],["atan2",Db],["log",Lb],["exp",Mb],["rand",Fb],["srand",_b],["system",zb("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",yl("systime")],["mktime",yl("mktime")],["strftime",yl("strftime")]])});function br(e){return typeof e=="number"?e!==0:e!==""&&e!=="0"}function vt(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function Ze(e){return typeof e=="string"?e:String(e)}function uh(e){if(typeof e=="number")return!0;let t=String(e).trim();return t!==""&&!Number.isNaN(Number(t))}function bu(e,t){try{return de(e).test(t)}catch{return!1}}var Fs=M(()=>{at()});function M2(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function zc(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function F2(e,t,r){if(t===0)e.line=Ze(r),e.fields=M2(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length{at(),Fs()});function Uc(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;case"OFMT":return e.OFMT;case"NR":return e.NR;case"NF":return e.NF;case"FNR":return e.FNR;case"FILENAME":return e.FILENAME;case"RSTART":return e.RSTART;case"RLENGTH":return e.RLENGTH;case"SUBSEP":return e.SUBSEP;case"ARGC":return e.ARGC}return e.vars[t]??""}function _s(e,t,r){switch(t){case"FS":Bb(e,Ze(r));return;case"OFS":e.OFS=Ze(r);return;case"ORS":e.ORS=Ze(r);return;case"OFMT":e.OFMT=Ze(r);return;case"NR":e.NR=Math.floor(vt(r));return;case"NF":{let n=Math.floor(vt(r));if(ne.NF){for(;e.fields.length=e.maxArrayElements)throw new C(`array element limit exceeded (${e.maxArrayElements})`,"array_elements");e.arrayElementCount++}e.arrays[i][r]=n}function Ub(e,t,r){if(t==="ARGV")return e.ARGV[r]!==void 0;if(t==="ENVIRON")return e.ENVIRON[r]!==void 0;let n=zs(e,t);return e.arrays[n]?.[r]!==void 0}function Wb(e,t,r){let n=zs(e,t);e.arrays[n]&&(r in e.arrays[n]&&e.arrayElementCount--,delete e.arrays[n][r])}function jb(e,t){let r=zs(e,t);e.arrayElementCount-=Object.keys(e.arrays[r]??{}).length,delete e.arrays[r]}var z2=M(()=>{H(),Bc(),Fs()});function qb(e){jc=e}function tr(e,t){Zt(e.requireDefenseContext,"awk",t)}function _e(e,t,r){return In(e.requireDefenseContext,"awk",t,r)}async function xe(e,t){switch(tr(e,"expression evaluation"),e.coverage?.hit(`awk:expr:${t.type}`),t.type){case"number":return t.value;case"string":return t.value;case"regex":return+!!bu(t.pattern,e.line);case"field":return Gb(e,t);case"variable":return Uc(e,t.name);case"array_access":return Hb(e,t);case"binary":return Vb(e,t);case"unary":return Kb(e,t);case"ternary":return br(await _e(e,"ternary condition evaluation",()=>xe(e,t.condition)))?await _e(e,"ternary consequent evaluation",()=>xe(e,t.consequent)):await _e(e,"ternary alternate evaluation",()=>xe(e,t.alternate));case"call":return Xb(e,t.name,t.args);case"assignment":return Jb(e,t);case"pre_increment":return ew(e,t.operand);case"pre_decrement":return tw(e,t.operand);case"post_increment":return rw(e,t.operand);case"post_decrement":return nw(e,t.operand);case"in":return iw(e,t.key,t.array);case"getline":return sw(e,t.variable,t.file,t.command);case"tuple":return lw(e,t.elements);default:return""}}async function Gb(e,t){return tr(e,"field reference evaluation"),zc(e,Math.floor(vt(await _e(e,"field index evaluation",()=>xe(e,t.index)))))}async function Hb(e,t){tr(e,"array access evaluation");let r=Ze(await _e(e,"array key evaluation",()=>xe(e,t.key)));return Wc(e,t.array,r)}async function Vb(e,t){tr(e,"binary expression evaluation");let r=t.operator;if(r==="||")return br(await _e(e,"logical-or left evaluation",()=>xe(e,t.left)))||br(await _e(e,"logical-or right evaluation",()=>xe(e,t.right)))?1:0;if(r==="&&")return br(await _e(e,"logical-and left evaluation",()=>xe(e,t.left)))&&br(await _e(e,"logical-and right evaluation",()=>xe(e,t.right)))?1:0;if(r==="~"){let s=await _e(e,"regex left evaluation",()=>xe(e,t.left));t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let a=t.right.type==="regex"?t.right.pattern:Ze(await _e(e,"regex right evaluation",()=>xe(e,t.right)));try{return+!!de(a).test(Ze(s))}catch{return 0}}if(r==="!~"){let s=await _e(e,"negated-regex left evaluation",()=>xe(e,t.left));t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let a=t.right.type==="regex"?t.right.pattern:Ze(await _e(e,"negated-regex right evaluation",()=>xe(e,t.right)));try{return+!de(a).test(Ze(s))}catch{return 1}}let n=await _e(e,"binary left evaluation",()=>xe(e,t.left)),i=await _e(e,"binary right evaluation",()=>xe(e,t.right));if(r===" "){let s=Ze(n)+Ze(i);if(e.maxOutputSize>0&&s.length>e.maxOutputSize)throw new C(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output);return s}return Zb(r)?Qb(n,i,r):yb(vt(n),vt(i),r)}function Zb(e){return["<","<=",">",">=","==","!="].includes(e)}function Qb(e,t,r){let n=uh(e),i=uh(t);if(n&&i){let o=vt(e),l=vt(t);switch(r){case"<":return+(o":return+(o>l);case">=":return+(o>=l);case"==":return+(o===l);case"!=":return o===l?0:1}}let s=Ze(e),a=Ze(t);switch(r){case"<":return+(s":return+(s>a);case">=":return+(s>=a);case"==":return+(s===a);case"!=":return s===a?0:1}return 0}async function Kb(e,t){tr(e,"unary expression evaluation");let r=await _e(e,"unary operand evaluation",()=>xe(e,t.operand));switch(t.operator){case"!":return+!br(r);case"-":return-vt(r);case"+":return+vt(r);default:return r}}async function Xb(e,t,r){tr(e,"function call evaluation");let n=D2.get(t);if(n)return n(r,e,{evalExpr:s=>xe(e,s)});let i=e.functions.get(t);return i?Yb(e,i,r):""}async function Yb(e,t,r){if(tr(e,"user function call"),e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new C(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let n=Object.create(null);for(let o of t.params)n[o]=e.vars[o];let i=[];for(let o=0;oxe(e,u));e.vars[l]=c}else e.vars[l]=""}e.hasReturn=!1,e.returnValue=void 0;let s=jc;s&&await _e(e,"user function body execution",()=>s(e,t.body.statements));let a=e.returnValue??"";for(let o of t.params)n[o]===void 0?delete e.vars[o]:e.vars[o]=n[o];for(let o of i)e.arrayAliases.delete(o);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,a}async function Jb(e,t){tr(e,"assignment evaluation");let r=await _e(e,"assignment value evaluation",()=>xe(e,t.value)),n=t.target,i=t.operator,s;if(i==="=")s=r;else{let a;if(n.type==="field")a=zc(e,Math.floor(vt(await _e(e,"assignment field index",()=>xe(e,n.index)))));else if(n.type==="variable")a=Uc(e,n.name);else{let u=Ze(await _e(e,"assignment array key",()=>xe(e,n.key)));a=Wc(e,n.array,u)}let o=vt(a),l=vt(r);switch(i){case"+=":s=o+l;break;case"-=":s=o-l;break;case"*=":s=o*l;break;case"/=":s=l===0?0:o/l;break;case"%=":s=l===0?0:o%l;break;case"^=":s=o**l;break;default:s=r}}if(n.type==="field")F2(e,Math.floor(vt(await _e(e,"assignment target field index",()=>xe(e,n.index)))),s);else if(n.type==="variable")_s(e,n.name,s);else{let a=Ze(await _e(e,"assignment target array key",()=>xe(e,n.key)));_2(e,n.array,a,s)}return s}async function yo(e,t,r,n){tr(e,"inc/dec evaluation");let i;if(t.type==="field"){let s=Math.floor(vt(await _e(e,"inc/dec field index",()=>xe(e,t.index))));i=vt(zc(e,s)),F2(e,s,i+r)}else if(t.type==="variable")i=vt(Uc(e,t.name)),_s(e,t.name,i+r);else{let s=Ze(await _e(e,"inc/dec array key",()=>xe(e,t.key)));i=vt(Wc(e,t.array,s)),_2(e,t.array,s,i+r)}return n?i+r:i}async function ew(e,t){return yo(e,t,1,!0)}async function tw(e,t){return yo(e,t,-1,!0)}async function rw(e,t){return yo(e,t,1,!1)}async function nw(e,t){return yo(e,t,-1,!1)}async function iw(e,t,r){tr(e,"in-expression evaluation");let n;if(t.type==="tuple"){e.coverage?.hit("awk:expr:tuple");let i=[];for(let s of t.elements)i.push(Ze(await _e(e,"tuple key element evaluation",()=>xe(e,s))));n=i.join(e.SUBSEP)}else n=Ze(await _e(e,"in-expression key evaluation",()=>xe(e,t)));return+!!Ub(e,r,n)}async function sw(e,t,r,n){if(tr(e,"getline evaluation"),n)return aw(e,t,n);if(r)return ow(e,t,r);if(!e.lines||e.lineIndex===void 0)return-1;let i=e.lineIndex+1;if(i>=e.lines.length)return 0;let s=e.lines[i];return t?_s(e,t,s):go(e,s),e.NR++,e.lineIndex=i,1}async function aw(e,t,r){let n=e.exec;if(!n)return-1;tr(e,"getline command source");let i=Ze(await _e(e,"getline command expression",()=>xe(e,r))),s=e.getlineCommandStreams.get(i);if(!s)try{let l=ke((await _e(e,"getline command exec",()=>n(i))).stdout).split(` `);l.length>0&&l[l.length-1]===""&&l.pop(),s={lines:l,index:-1},e.getlineCommandStreams.set(i,s)}catch(l){if(l instanceof Ae)throw l;return-1}let a=s.index+1;if(a>=s.lines.length)return 0;let o=s.lines[a];return s.index=a,t?_s(e,t,o):go(e,o),1}async function ow(e,t,r){let n=e.fs;if(!n||!e.cwd)return-1;tr(e,"getline file source");let i=Ze(await _e(e,"getline filename evaluation",()=>xe(e,r)));if(i==="/dev/null")return 0;let s=n.resolvePath(e.cwd,i),a=e.getlineFileStreams.get(s);if(!a)try{let u=(await _e(e,"getline file read",()=>n.readFile(s))).split(` `);u.length>0&&u[u.length-1]===""&&u.pop(),a={lines:u,index:-1},e.getlineFileStreams.set(s,a)}catch(u){if(u instanceof Ae)throw u;return-1}let o=a.index+1;if(o>=a.lines.length)return 0;let l=a.lines[o];return a.index=o,t?_s(e,t,l):go(e,l),1}async function lw(e,t){if(tr(e,"tuple evaluation"),t.length===0)return"";for(let r=0;rxe(e,t[r]));return _e(e,"tuple final element",()=>xe(e,t[t.length-1]))}var jc,B2=M(()=>{se(),H(),at(),vn(),Ar(),xb(),L2(),Bc(),Fs(),z2(),jc=null});function qc(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new C(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output)}function zr(e,t){Zt(e.requireDefenseContext,"awk",t)}function Le(e,t,r){return In(e.requireDefenseContext,"awk",t,r)}async function gs(e,t){zr(e,"block execution");for(let r of t)if(await Le(e,"statement execution",()=>ii(e,r)),uw(e))break}function uw(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function ii(e,t){switch(zr(e,"single statement execution"),e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case"block":await Le(e,"nested block statement",()=>gs(e,t.statements));break;case"expr_stmt":await Le(e,"expression statement",()=>xe(e,t.expression));break;case"print":await Le(e,"print statement",()=>cw(e,t.args,t.output));break;case"printf":await Le(e,"printf statement",()=>pw(e,t.format,t.args,t.output));break;case"if":await Le(e,"if statement",()=>hw(e,t));break;case"while":await Le(e,"while statement",()=>fw(e,t));break;case"do_while":await Le(e,"do-while statement",()=>dw(e,t));break;case"for":await Le(e,"for statement",()=>mw(e,t));break;case"for_in":await Le(e,"for-in statement",()=>gw(e,t));break;case"break":e.loopBreak=!0;break;case"continue":e.loopContinue=!0;break;case"next":e.shouldNext=!0;break;case"nextfile":e.shouldNextFile=!0;break;case"exit":e.shouldExit=!0;{let r=t.code;e.exitCode=r?Math.floor(vt(await Le(e,"exit code expression",()=>xe(e,r)))):0}break;case"return":e.hasReturn=!0;{let r=t.value;e.returnValue=r?await Le(e,"return expression",()=>xe(e,r)):""}break;case"delete":await Le(e,"delete statement",()=>yw(e,t.target))}}async function cw(e,t,r){zr(e,"print execution");let n=[];for(let s of t){let a=await Le(e,"print argument evaluation",()=>xe(e,s));typeof a=="number"?Number.isInteger(a)&&Math.abs(a)<2**53-1?n.push(String(a)):n.push(Fc(e.OFMT,[a],e.maxOutputSize||void 0)):n.push(Ze(a))}let i=n.join(e.OFS)+e.ORS;r?await Le(e,"print redirection write",()=>U2(e,r.redirect,r.file,i)):(e.output+=i,qc(e))}async function pw(e,t,r,n){zr(e,"printf execution");let i=Ze(await Le(e,"printf format evaluation",()=>xe(e,t))),s=[];for(let o of r)s.push(await Le(e,"printf argument evaluation",()=>xe(e,o)));let a=Fc(i,s,e.maxOutputSize>0?Math.max(0,e.maxOutputSize-q(e.output)):void 0);n?await Le(e,"printf redirection write",()=>U2(e,n.redirect,n.file,a)):(e.output+=a,qc(e))}async function U2(e,t,r,n){zr(e,"file write execution");let i=e.fs;if(!i||!e.cwd){e.output+=n,qc(e);return}let s=Ze(await Le(e,"redirection filename evaluation",()=>xe(e,r))),a=i.resolvePath(e.cwd,s);t===">"?e.openedFiles.has(a)?await Le(e,"redirection append write",()=>i.appendFile(a,n)):(await Le(e,"redirection overwrite write",()=>i.writeFile(a,n)),e.openedFiles.add(a)):(e.openedFiles.has(a)||e.openedFiles.add(a),await Le(e,"redirection append mode write",()=>i.appendFile(a,n)))}async function hw(e,t){if(zr(e,"if execution"),br(await Le(e,"if condition evaluation",()=>xe(e,t.condition))))await Le(e,"if consequent execution",()=>ii(e,t.consequent));else if(t.alternate){let r=t.alternate;await Le(e,"if alternate execution",()=>ii(e,r))}}async function fw(e,t){zr(e,"while execution");let r=0;for(;br(await Le(e,"while condition evaluation",()=>xe(e,t.condition)));){if(r++,r>e.maxIterations)throw new C(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await Le(e,"while body execution",()=>ii(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function dw(e,t){zr(e,"do-while execution");let r=0;do{if(r++,r>e.maxIterations)throw new C(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await Le(e,"do-while body execution",()=>ii(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(br(await Le(e,"do-while condition evaluation",()=>xe(e,t.condition))))}async function mw(e,t){zr(e,"for execution");let r=t.init,n=t.condition,i=t.update;r&&await Le(e,"for init evaluation",()=>xe(e,r));let s=0;for(;!n||br(await Le(e,"for condition evaluation",()=>xe(e,n)));){if(s++,s>e.maxIterations)throw new C(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await Le(e,"for body execution",()=>ii(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;i&&await Le(e,"for update evaluation",()=>xe(e,i))}}async function gw(e,t){zr(e,"for-in execution");let r=e.arrays[t.array];if(r)for(let n of Object.keys(r)){if(e.vars[t.variable]=n,e.loopContinue=!1,await Le(e,"for-in body execution",()=>ii(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function yw(e,t){if(zr(e,"delete execution"),t.type==="array_access"){let r=Ze(await Le(e,"delete key evaluation",()=>xe(e,t.key)));Wb(e,t.array,r)}else t.type==="variable"&&jb(e,t.name)}var xw=M(()=>{H(),vn(),wt(),L2(),B2(),Fs(),z2(),qb(gs)}),W2,vw=M(()=>{H(),vn(),B2(),Bc(),xw(),Fs(),W2=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}assertDefenseContext(e){Zt(this.ctx.requireDefenseContext,"awk",e)}withDefenseContext(e,t){return In(this.ctx.requireDefenseContext,"awk",e,t)}execute(e){this.assertDefenseContext("program initialization"),this.program=e,this.ctx.output="";for(let t of e.functions)this.ctx.functions.set(t.name,t);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.assertDefenseContext("BEGIN execution entry"),this.program){for(let e of this.program.rules)if(e.pattern?.type==="begin"&&(await this.withDefenseContext("BEGIN block execution",()=>gs(this.ctx,e.action.statements)),this.ctx.shouldExit))break}}async executeLine(e){if(this.assertDefenseContext("line execution entry"),this.program&&!this.ctx.shouldExit){if(this.ctx.recordsProcessed++,this.ctx.recordsProcessed>this.ctx.maxIterations)throw new C(`record limit exceeded (${this.ctx.maxIterations})`,"iterations");go(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let t=0;tthis.matchesRule(r,t))&&await this.withDefenseContext("rule block execution",()=>gs(this.ctx,r.action.statements))}}}async executeEnd(){if(this.assertDefenseContext("END execution entry"),this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let e of this.program.rules)if(e.pattern?.type==="end"&&(await this.withDefenseContext("END block execution",()=>gs(this.ctx,e.action.statements)),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,t){this.assertDefenseContext("rule matching");let r=e.pattern;if(!r)return!0;switch(r.type){case"begin":case"end":return!1;case"regex_pattern":return bu(r.pattern,this.ctx.line);case"expr_pattern":return br(await this.withDefenseContext("expression pattern evaluation",()=>xe(this.ctx,r.expression)));case"range":{let n=await this.withDefenseContext("range start pattern",()=>this.matchPattern(r.start)),i=await this.withDefenseContext("range end pattern",()=>this.matchPattern(r.end));return this.rangeStates[t]?(i&&(this.rangeStates[t]=!1),!0):n?(this.rangeStates[t]=!0,i&&(this.rangeStates[t]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(this.assertDefenseContext("pattern matching"),e.type){case"regex_pattern":return bu(e.pattern,this.ctx.line);case"expr_pattern":return br(await this.withDefenseContext("nested expression pattern",()=>xe(this.ctx,e.expression)));default:return!1}}}}),bw=M(()=>{gb(),vw()});function ww(e){return e.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var k,ch,ph,j2,Ew=M(()=>{H(),(function(e){e.NUMBER="NUMBER",e.STRING="STRING",e.REGEX="REGEX",e.IDENT="IDENT",e.BEGIN="BEGIN",e.END="END",e.IF="IF",e.ELSE="ELSE",e.WHILE="WHILE",e.DO="DO",e.FOR="FOR",e.IN="IN",e.BREAK="BREAK",e.CONTINUE="CONTINUE",e.NEXT="NEXT",e.NEXTFILE="NEXTFILE",e.EXIT="EXIT",e.RETURN="RETURN",e.DELETE="DELETE",e.FUNCTION="FUNCTION",e.PRINT="PRINT",e.PRINTF="PRINTF",e.GETLINE="GETLINE",e.PLUS="PLUS",e.MINUS="MINUS",e.STAR="STAR",e.SLASH="SLASH",e.PERCENT="PERCENT",e.CARET="CARET",e.EQ="EQ",e.NE="NE",e.LT="LT",e.GT="GT",e.LE="LE",e.GE="GE",e.MATCH="MATCH",e.NOT_MATCH="NOT_MATCH",e.AND="AND",e.OR="OR",e.NOT="NOT",e.ASSIGN="ASSIGN",e.PLUS_ASSIGN="PLUS_ASSIGN",e.MINUS_ASSIGN="MINUS_ASSIGN",e.STAR_ASSIGN="STAR_ASSIGN",e.SLASH_ASSIGN="SLASH_ASSIGN",e.PERCENT_ASSIGN="PERCENT_ASSIGN",e.CARET_ASSIGN="CARET_ASSIGN",e.INCREMENT="INCREMENT",e.DECREMENT="DECREMENT",e.QUESTION="QUESTION",e.COLON="COLON",e.COMMA="COMMA",e.SEMICOLON="SEMICOLON",e.NEWLINE="NEWLINE",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.LBRACKET="LBRACKET",e.RBRACKET="RBRACKET",e.DOLLAR="DOLLAR",e.APPEND="APPEND",e.PIPE="PIPE",e.EOF="EOF"})(k||={}),ch=new Map([["BEGIN",k.BEGIN],["END",k.END],["if",k.IF],["else",k.ELSE],["while",k.WHILE],["do",k.DO],["for",k.FOR],["in",k.IN],["break",k.BREAK],["continue",k.CONTINUE],["next",k.NEXT],["nextfile",k.NEXTFILE],["exit",k.EXIT],["return",k.RETURN],["delete",k.DELETE],["function",k.FUNCTION],["print",k.PRINT],["printf",k.PRINTF],["getline",k.GETLINE]]),ph=new Set([k.COMMA,k.LBRACE,k.AND,k.OR,k.QUESTION,k.COLON,k.DO,k.ELSE,k.IF,k.WHILE]),j2=class{maxTokens;input;pos=0;line=1;column=1;lastTokenType=null;constructor(e,t=1e5){this.maxTokens=t,this.input=e}tokenize(){let e=[];for(;this.pos=this.maxTokens)throw new C(`awk: token limit exceeded (${this.maxTokens})`,"array_elements");e.push(t),this.lastTokenType=t.type}}if(e.length>=this.maxTokens)throw new C(`awk: token limit exceeded (${this.maxTokens})`,"array_elements");return e.push(this.makeToken(k.EOF,"")),e}makeToken(e,t){return{type:e,value:t,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===` `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos=this.input.length)return null;let e=this.line,t=this.column,r=this.peek();return r===` `?(this.advance(),{type:k.NEWLINE,value:` `,line:e,column:t}):r==='"'?this.readString():r==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(r)||r==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(r)||r==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,k.NEWLINE,k.SEMICOLON,k.LBRACE,k.RBRACE,k.LPAREN,k.LBRACKET,k.COMMA,k.ASSIGN,k.PLUS_ASSIGN,k.MINUS_ASSIGN,k.STAR_ASSIGN,k.SLASH_ASSIGN,k.PERCENT_ASSIGN,k.CARET_ASSIGN,k.AND,k.OR,k.NOT,k.MATCH,k.NOT_MATCH,k.QUESTION,k.COLON,k.LT,k.GT,k.LE,k.GE,k.EQ,k.NE,k.PLUS,k.MINUS,k.STAR,k.PERCENT,k.CARET,k.PRINT,k.PRINTF,k.IF,k.WHILE,k.DO,k.FOR,k.RETURN]).has(this.lastTokenType)}readString(){let e=this.line,t=this.column;this.advance();let r="";for(;this.pos0?r+=String.fromCharCode(parseInt(i,16)):r+="x";break}default:if(/[0-7]/.test(n)){let i=n;for(;i.length<3&&/[0-7]/.test(this.peek());)i+=this.advance();r+=String.fromCharCode(parseInt(i,8))}else r+=n}}else r+=this.advance();return this.peek()==='"'&&this.advance(),{type:k.STRING,value:r,line:e,column:t}}readRegex(){let e=this.line,t=this.column;this.advance();let r="";for(;this.pos":return n==="="?(this.advance(),{type:k.GE,value:">=",line:e,column:t}):n===">"?(this.advance(),{type:k.APPEND,value:">>",line:e,column:t}):{type:k.GT,value:">",line:e,column:t};case"&":return n==="&"?(this.advance(),{type:k.AND,value:"&&",line:e,column:t}):{type:k.IDENT,value:"&",line:e,column:t};case"|":return n==="|"?(this.advance(),{type:k.OR,value:"||",line:e,column:t}):{type:k.PIPE,value:"|",line:e,column:t};case"~":return{type:k.MATCH,value:"~",line:e,column:t};case"?":return{type:k.QUESTION,value:"?",line:e,column:t};case":":return{type:k.COLON,value:":",line:e,column:t};case",":return{type:k.COMMA,value:",",line:e,column:t};case";":return{type:k.SEMICOLON,value:";",line:e,column:t};case"(":return{type:k.LPAREN,value:"(",line:e,column:t};case")":return{type:k.RPAREN,value:")",line:e,column:t};case"{":return{type:k.LBRACE,value:"{",line:e,column:t};case"}":return{type:k.RBRACE,value:"}",line:e,column:t};case"[":return{type:k.LBRACKET,value:"[",line:e,column:t};case"]":return{type:k.RBRACKET,value:"]",line:e,column:t};case"$":return{type:k.DOLLAR,value:"$",line:e,column:t};default:return{type:k.IDENT,value:r,line:e,column:t}}}isDigit(e){return e>="0"&&e<="9"}isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}}});function Sw(e){e.expect(ee.PRINT);let t=[];if(e.check(ee.NEWLINE)||e.check(ee.SEMICOLON)||e.check(ee.RBRACE)||e.check(ee.PIPE)||e.check(ee.GT)||e.check(ee.APPEND))t.push({type:"field",index:{type:"number",value:0}});else for(e.assertArrayLength(t.length),t.push(Ua(e));e.check(ee.COMMA);)e.advance(),e.assertArrayLength(t.length),t.push(Ua(e));let r;return e.check(ee.GT)?(e.advance(),r={redirect:">",file:e.parsePrimary()}):e.check(ee.APPEND)&&(e.advance(),r={redirect:">>",file:e.parsePrimary()}),{type:"print",args:t,output:r}}function Ua(e){return Aw(e)?wu(e,!0):wu(e,!1)}function wu(e,t){let r=t?e.parseTernary():Cw(e);if(e.match(ee.ASSIGN,ee.PLUS_ASSIGN,ee.MINUS_ASSIGN,ee.STAR_ASSIGN,ee.SLASH_ASSIGN,ee.PERCENT_ASSIGN,ee.CARET_ASSIGN)){let n=e.advance(),i=e.withDepth(()=>wu(e,t));if(r.type!=="variable"&&r.type!=="field"&&r.type!=="array_access")throw Error("Invalid assignment target");return{type:"assignment",operator:new Map([["=","="],["+=","+="],["-=","-="],["*=","*="],["/=","/="],["%=","%="],["^=","^="]]).get(n.value)??"=",target:r,value:i}}return r}function Aw(e){let t=0,r=e.pos;for(;r=",">="],["==","=="],["!=","!="]]).get(r.value)??"==",left:t,right:n}}return t}function Nw(e){return e.match(ee.NUMBER,ee.STRING,ee.IDENT,ee.DOLLAR,ee.LPAREN,ee.NOT,ee.MINUS,ee.PLUS,ee.INCREMENT,ee.DECREMENT)}function $w(e){return e.match(ee.AND,ee.OR,ee.QUESTION,ee.ASSIGN,ee.PLUS_ASSIGN,ee.MINUS_ASSIGN,ee.STAR_ASSIGN,ee.SLASH_ASSIGN,ee.PERCENT_ASSIGN,ee.CARET_ASSIGN,ee.COMMA,ee.SEMICOLON,ee.NEWLINE,ee.RBRACE,ee.RPAREN,ee.RBRACKET,ee.COLON,ee.PIPE,ee.APPEND,ee.GT,ee.IN)}function Ow(e){e.expect(ee.PRINTF);let t=e.check(ee.LPAREN);t&&(e.advance(),e.skipNewlines());let r=t?e.parseExpression():Ua(e),n=[];for(;e.check(ee.COMMA);)e.advance(),t&&e.skipNewlines(),e.assertArrayLength(n.length),n.push(t?e.parseExpression():Ua(e));t&&(e.skipNewlines(),e.expect(ee.RPAREN));let i;return e.check(ee.GT)?(e.advance(),i={redirect:">",file:e.parsePrimary()}):e.check(ee.APPEND)&&(e.advance(),i={redirect:">>",file:e.parsePrimary()}),{type:"printf",format:r,args:n,output:i}}var ee,Tw=M(()=>{ee={LPAREN:"LPAREN",RPAREN:"RPAREN",QUESTION:"QUESTION",NEWLINE:"NEWLINE",SEMICOLON:"SEMICOLON",RBRACE:"RBRACE",COMMA:"COMMA",PIPE:"PIPE",GT:"GT",APPEND:"APPEND",AND:"AND",OR:"OR",ASSIGN:"ASSIGN",PLUS_ASSIGN:"PLUS_ASSIGN",MINUS_ASSIGN:"MINUS_ASSIGN",STAR_ASSIGN:"STAR_ASSIGN",SLASH_ASSIGN:"SLASH_ASSIGN",PERCENT_ASSIGN:"PERCENT_ASSIGN",CARET_ASSIGN:"CARET_ASSIGN",RBRACKET:"RBRACKET",COLON:"COLON",IN:"IN",PRINT:"PRINT",PRINTF:"PRINTF",IDENT:"IDENT",LT:"LT",LE:"LE",GE:"GE",EQ:"EQ",NE:"NE",MATCH:"MATCH",NOT_MATCH:"NOT_MATCH",NUMBER:"NUMBER",STRING:"STRING",DOLLAR:"DOLLAR",NOT:"NOT",MINUS:"MINUS",PLUS:"PLUS",INCREMENT:"INCREMENT",DECREMENT:"DECREMENT"}}),q2,Iw=M(()=>{H(),Ew(),Tw(),q2=class{tokens=[];pos=0;depth=0;operations=0;limits;constructor(e={}){this.limits={maxSourceLength:e.maxSourceLength??10485760,maxTokens:e.maxTokens??1e5,maxDepth:e.maxDepth??100,maxOperations:e.maxOperations??1e5}}parse(e){if(e.length>this.limits.maxSourceLength)throw new C(`awk: source length limit exceeded (${this.limits.maxSourceLength})`,"string_length");let t=new j2(e,this.limits.maxTokens);this.tokens=t.tokenize(),this.pos=0,this.depth=0,this.operations=0;let r=0;for(let n of this.tokens)if(this.useOperation(),n.type===k.LPAREN||n.type===k.LBRACKET||n.type===k.LBRACE){if(r++,r>this.limits.maxDepth)throw new C(`awk: parser depth limit exceeded (${this.limits.maxDepth})`,"recursion")}else(n.type===k.RPAREN||n.type===k.RBRACKET||n.type===k.RBRACE)&&(r=Math.max(0,r-1));return this.parseProgram()}setPos(e){this.pos=e}current(){return this.tokens[this.pos]||{type:k.EOF,value:"",line:0,column:0}}advance(){this.useOperation();let e=this.current();return this.posthis.limits.maxOperations-this.operations)throw new C(`awk: parser operation limit exceeded (${this.limits.maxOperations})`,"iterations");this.operations+=e}withDepth(e){if(this.depth>=this.limits.maxDepth)throw new C(`awk: parser depth limit exceeded (${this.limits.maxDepth})`,"recursion");this.depth++;try{return e()}finally{this.depth--}}assertArrayLength(e){if(e>=this.limits.maxTokens)throw new C(`awk: AST array limit exceeded (${this.limits.maxTokens})`,"array_elements")}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,t){if(!this.check(e)){let r=this.current();throw Error(t||`Expected ${e}, got ${r.type} at line ${r.line}:${r.column}`)}return this.advance()}skipNewlines(){for(;this.check(k.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(k.NEWLINE)||this.check(k.SEMICOLON);)this.advance()}parseProgram(){let e=[],t=[];for(this.skipNewlines();!this.check(k.EOF)&&(this.skipNewlines(),!this.check(k.EOF));)this.check(k.FUNCTION)?e.push(this.parseFunction()):t.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:t}}parseFunction(){this.expect(k.FUNCTION);let e=this.expect(k.IDENT).value;this.expect(k.LPAREN);let t=[];if(!this.check(k.RPAREN))for(t.push(this.expect(k.IDENT).value);this.check(k.COMMA);)this.advance(),t.push(this.expect(k.IDENT).value);return this.expect(k.RPAREN),this.skipNewlines(),{name:e,params:t,body:this.parseBlock()}}parseRule(){let e;if(this.check(k.BEGIN))this.advance(),e={type:"begin"};else if(this.check(k.END))this.advance(),e={type:"end"};else if(this.check(k.LBRACE))e=void 0;else if(this.check(k.REGEX)){let r=this.advance();if(this.check(k.AND)||this.check(k.OR)){let n={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:r.value}};e={type:"expr_pattern",expression:this.parseLogicalOrRest(n)}}else{let n={type:"regex_pattern",pattern:r.value};if(this.check(k.COMMA)){this.advance();let i;i=this.check(k.REGEX)?{type:"regex_pattern",pattern:this.advance().value}:{type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:n,end:i}}else e=n}}else{let r={type:"expr_pattern",expression:this.parseExpression()};if(this.check(k.COMMA)){this.advance();let n;n=this.check(k.REGEX)?{type:"regex_pattern",pattern:this.advance().value}:{type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:r,end:n}}else e=r}this.skipNewlines();let t;return t=this.check(k.LBRACE)?this.parseBlock():{type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:e,action:t}}parseBlock(){this.expect(k.LBRACE),this.skipNewlines();let e=[];for(;!this.check(k.RBRACE)&&!this.check(k.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(k.RBRACE),{type:"block",statements:e}}parseStatement(){return this.withDepth(()=>this.parseStatementAtDepth())}parseStatementAtDepth(){if(this.check(k.SEMICOLON)||this.check(k.NEWLINE))return this.advance(),{type:"block",statements:[]};if(this.check(k.LBRACE))return this.parseBlock();if(this.check(k.IF))return this.parseIf();if(this.check(k.WHILE))return this.parseWhile();if(this.check(k.DO))return this.parseDoWhile();if(this.check(k.FOR))return this.parseFor();if(this.check(k.BREAK))return this.advance(),{type:"break"};if(this.check(k.CONTINUE))return this.advance(),{type:"continue"};if(this.check(k.NEXT))return this.advance(),{type:"next"};if(this.check(k.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(k.EXIT)){this.advance();let e;return!this.check(k.NEWLINE)&&!this.check(k.SEMICOLON)&&!this.check(k.RBRACE)&&!this.check(k.EOF)&&(e=this.parseExpression()),{type:"exit",code:e}}if(this.check(k.RETURN)){this.advance();let e;return!this.check(k.NEWLINE)&&!this.check(k.SEMICOLON)&&!this.check(k.RBRACE)&&!this.check(k.EOF)&&(e=this.parseExpression()),{type:"return",value:e}}if(this.check(k.DELETE)){this.advance();let e=this.parsePrimary();if(e.type!=="array_access"&&e.type!=="variable")throw Error("delete requires array element or array");return{type:"delete",target:e}}return this.check(k.PRINT)?Sw(this):this.check(k.PRINTF)?Ow(this):{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(k.IF),this.expect(k.LPAREN);let e=this.parseExpression();this.expect(k.RPAREN),this.skipNewlines();let t=this.parseStatement();this.skipTerminators();let r;return this.check(k.ELSE)&&(this.advance(),this.skipNewlines(),r=this.parseStatement()),{type:"if",condition:e,consequent:t,alternate:r}}parseWhile(){this.expect(k.WHILE),this.expect(k.LPAREN);let e=this.parseExpression();return this.expect(k.RPAREN),this.skipNewlines(),{type:"while",condition:e,body:this.parseStatement()}}parseDoWhile(){this.expect(k.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(k.WHILE),this.expect(k.LPAREN);let t=this.parseExpression();return this.expect(k.RPAREN),{type:"do_while",body:e,condition:t}}parseFor(){if(this.expect(k.FOR),this.expect(k.LPAREN),this.check(k.IDENT)){let i=this.advance();if(this.check(k.IN)){this.advance();let s=this.expect(k.IDENT).value;this.expect(k.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for_in",variable:i.value,array:s,body:a}}this.pos--}let e;this.check(k.SEMICOLON)||(e=this.parseExpression()),this.expect(k.SEMICOLON);let t;this.check(k.SEMICOLON)||(t=this.parseExpression()),this.expect(k.SEMICOLON);let r;this.check(k.RPAREN)||(r=this.parseExpression()),this.expect(k.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:"for",init:e,condition:t,update:r,body:n}}parseExpression(){return this.withDepth(()=>this.parseAssignment())}parseAssignment(){let e=this.parseTernary();if(this.match(k.ASSIGN,k.PLUS_ASSIGN,k.MINUS_ASSIGN,k.STAR_ASSIGN,k.SLASH_ASSIGN,k.PERCENT_ASSIGN,k.CARET_ASSIGN)){let t=this.advance(),r=this.parseExpression();if(e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw Error("Invalid assignment target");let n=new Set(["=","+=","-=","*=","/=","%=","^="]),i=t.value;if(!n.has(i))throw Error(`Unknown assignment operator: ${i}`);return{type:"assignment",operator:i,target:e,value:r}}return e}parseTernary(){let e=this.parsePipeGetline();if(this.check(k.QUESTION)){this.advance();let t=this.parseExpression();this.expect(k.COLON);let r=this.parseExpression();e={type:"ternary",condition:e,consequent:t,alternate:r}}return e}parsePipeGetline(){let e=this.parseOr();if(this.check(k.PIPE)){if(this.advance(),!this.check(k.GETLINE))throw Error("Expected 'getline' after '|' in expression context");this.advance();let t;return this.check(k.IDENT)&&(t=this.advance().value),{type:"getline",command:e,variable:t}}return e}parseOr(){let e=this.parseAnd();for(;this.check(k.OR);){this.advance();let t=this.parseAnd();e={type:"binary",operator:"||",left:e,right:t}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(k.OR);){this.advance();let t=this.parseAnd();e={type:"binary",operator:"||",left:e,right:t}}return e}parseLogicalAndRest(e){for(;this.check(k.AND);){this.advance();let t=this.parseIn();e={type:"binary",operator:"&&",left:e,right:t}}return e}parseAnd(){let e=this.parseIn();for(;this.check(k.AND);){this.advance();let t=this.parseIn();e={type:"binary",operator:"&&",left:e,right:t}}return e}parseIn(){let e=this.parseConcatenation();return this.check(k.IN)?(this.advance(),{type:"in",key:e,array:this.expect(k.IDENT).value}):e}parseConcatenation(){let e=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let t=this.parseMatch();e={type:"binary",operator:" ",left:e,right:t}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(k.MATCH,k.NOT_MATCH);){let t=this.advance().type===k.MATCH?"~":"!~",r=this.parseComparison();e={type:"binary",operator:t,left:e,right:r}}return e}parseComparison(){let e=this.parseAddSub();for(;this.match(k.LT,k.LE,k.GT,k.GE,k.EQ,k.NE);){let t=this.advance(),r=this.parseAddSub();e={type:"binary",operator:new Map([["<","<"],["<=","<="],[">",">"],[">=",">="],["==","=="],["!=","!="]]).get(t.value)??"==",left:e,right:r}}return e}canStartExpression(){return this.match(k.NUMBER,k.STRING,k.IDENT,k.DOLLAR,k.LPAREN,k.NOT,k.MINUS,k.PLUS,k.INCREMENT,k.DECREMENT)}isConcatTerminator(){return this.match(k.AND,k.OR,k.QUESTION,k.ASSIGN,k.PLUS_ASSIGN,k.MINUS_ASSIGN,k.STAR_ASSIGN,k.SLASH_ASSIGN,k.PERCENT_ASSIGN,k.CARET_ASSIGN,k.COMMA,k.SEMICOLON,k.NEWLINE,k.RBRACE,k.RPAREN,k.RBRACKET,k.COLON,k.PIPE,k.APPEND,k.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(k.PLUS,k.MINUS);){let t=this.advance().value,r=this.parseMulDiv();e={type:"binary",operator:t,left:e,right:r}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(k.STAR,k.SLASH,k.PERCENT);){let t=this.advance(),r=this.parseUnary();e={type:"binary",operator:new Map([["*","*"],["/","/"],["%","%"]]).get(t.value)??"*",left:e,right:r}}return e}parseUnary(){if(this.check(k.INCREMENT)){this.advance();let e=this.withDepth(()=>this.parseUnary());return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:e}}:{type:"pre_increment",operand:e}}if(this.check(k.DECREMENT)){this.advance();let e=this.withDepth(()=>this.parseUnary());return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:e}}:{type:"pre_decrement",operand:e}}return this.match(k.NOT,k.MINUS,k.PLUS)?{type:"unary",operator:this.advance().value,operand:this.withDepth(()=>this.parseUnary())}:this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(k.CARET)){this.advance();let t=this.withDepth(()=>this.parsePower());e={type:"binary",operator:"^",left:e,right:t}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(k.INCREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw Error("Invalid increment operand");return{type:"post_increment",operand:e}}if(this.check(k.DECREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw Error("Invalid decrement operand");return{type:"post_decrement",operand:e}}return e}parseFieldIndex(){if(this.check(k.INCREMENT)){this.advance();let e=this.withDepth(()=>this.parseFieldIndex());return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:e}}:{type:"pre_increment",operand:e}}if(this.check(k.DECREMENT)){this.advance();let e=this.withDepth(()=>this.parseFieldIndex());return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:e}}:{type:"pre_decrement",operand:e}}return this.match(k.NOT,k.MINUS,k.PLUS)?{type:"unary",operator:this.advance().value,operand:this.withDepth(()=>this.parseFieldIndex())}:this.parseFieldIndexPower()}parseFieldIndexPower(){let e=this.parseFieldIndexPrimary();if(this.check(k.CARET)){this.advance();let t=this.withDepth(()=>this.parseFieldIndexPower());e={type:"binary",operator:"^",left:e,right:t}}return e}parseFieldIndexPrimary(){if(this.check(k.NUMBER))return{type:"number",value:this.advance().value};if(this.check(k.STRING))return{type:"string",value:this.advance().value};if(this.check(k.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(k.LPAREN)){this.advance();let e=this.parseExpression();return this.expect(k.RPAREN),e}if(this.check(k.IDENT)){let e=this.advance().value;if(this.check(k.LPAREN)){this.advance();let t=[];if(!this.check(k.RPAREN))for(t.push(this.parseExpression());this.check(k.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(k.RPAREN),{type:"call",name:e,args:t}}if(this.check(k.LBRACKET)){this.advance();let t=this.parseExpression();if(this.check(k.COMMA)){let r=[t];for(;this.check(k.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(k.RBRACKET),{type:"array_access",array:e,key:r.reduce((n,i)=>({type:"binary",operator:" ",left:{type:"binary",operator:" ",left:n,right:{type:"variable",name:"SUBSEP"}},right:i}))}}return this.expect(k.RBRACKET),{type:"array_access",array:e,key:t}}return{type:"variable",name:e}}throw Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(k.NUMBER))return{type:"number",value:this.advance().value};if(this.check(k.STRING))return{type:"string",value:this.advance().value};if(this.check(k.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(k.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(k.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(k.COMMA)){let t=[e];for(;this.check(k.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(k.RPAREN),{type:"tuple",elements:t}}return this.expect(k.RPAREN),e}if(this.check(k.GETLINE)){this.advance();let e,t;return this.check(k.IDENT)&&(e=this.advance().value),this.check(k.LT)&&(this.advance(),t=this.parsePrimary()),{type:"getline",variable:e,file:t}}if(this.check(k.IDENT)){let e=this.advance().value;if(this.check(k.LPAREN)){this.advance();let t=[];if(this.skipNewlines(),!this.check(k.RPAREN))for(t.push(this.parseExpression());this.check(k.COMMA);)this.advance(),this.skipNewlines(),t.push(this.parseExpression());return this.skipNewlines(),this.expect(k.RPAREN),{type:"call",name:e,args:t}}if(this.check(k.LBRACKET)){this.advance();let t=[this.parseExpression()];for(;this.check(k.COMMA);)this.advance(),t.push(this.parseExpression());this.expect(k.RBRACKET);let r;if(t.length===1)r=t[0];else{r=t[0];for(let n=1;nH2,flagsForFuzzing:()=>V2});function xl(e){return e.replace(/\\t/g," ").replace(/\\n/g,` `).replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\a/g,"\x07").replace(/\\v/g,"\v").replace(/\\\\/g,"\\")}function gh(e){if(e===" ")return de("\\s+");if(/[[\](){}.*+?^$|\\]/.test(e))try{return de(e)}catch{return de(yh(e))}return de(yh(e))}function yh(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var xh,H2,V2,Rw=M(()=>{se(),Lt(),Rn(),H(),at(),vn(),Ar(),le(),wt(),bw(),Iw(),xh={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},H2={name:"awk",async execute(e,t){Zt(t.requireDefenseContext,"awk","execution entry");let r=(v,y)=>In(t.requireDefenseContext,"awk",v,y);if(he(e))return ce(xh);let n=new ho(/\s+/),i=" ",s=Object.create(null),a=0;for(let v=0;v0){let w=x.slice(0,b);s[w]=xl(x.slice(b+1))}a=v+1}else{if(y.startsWith("--"))return ve("awk",y);if(y.startsWith("-")&&y.length>1){let x=y[1];if(x!=="F"&&x!=="v")return ve("awk",`-${x}`);a=v+1}else if(!y.startsWith("-")){a=v;break}}}if(a>=e.length)return{stdout:"",stderr:`awk: missing program `,exitCode:1};let o=e[a],l=e.slice(a+1),u=new q2({maxSourceLength:t.limits.maxStringLength,maxTokens:t.limits.maxAwkParserTokens,maxDepth:t.limits.maxAwkParserDepth,maxOperations:t.limits.maxAwkParserOperations}),c;try{c=u.parse(o)}catch(v){return Ie(v),{stdout:"",stderr:`awk: ${v instanceof Error?v.message:String(v)} `,exitCode:1}}let p={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(v,y)=>{try{let x=await r("appendFile read",()=>t.fs.readFile(v));await r("appendFile write",()=>t.fs.writeFile(v,x+y))}catch(x){if(x instanceof Ae)throw x;await r("appendFile create",()=>t.fs.writeFile(v,y))}},resolvePath:t.fs.resolvePath.bind(t.fs)},h=t.exec,f=mb({fieldSep:n,maxIterations:t.limits.maxAwkIterations,maxOutputSize:Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),maxArrayElements:t.limits.maxArrayElements,fs:p,cwd:t.cwd,exec:h?v=>r("command pipe exec",()=>h(v,{cwd:t.cwd,signal:t.signal})):void 0,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext});f.FS=i,f.vars=Object.assign(Object.create(null),s),f.ARGC=l.length+1,f.ARGV=Object.create(null),f.ARGV[0]="awk";for(let v=0;vv.pattern?.type!=="begin"&&v.pattern?.type!=="end"),g=c.rules.some(v=>v.pattern?.type==="end");try{if(await r("BEGIN execution",()=>d.executeBegin()),f.shouldExit)return await r("END execution after BEGIN exit",()=>d.executeEnd()),{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()};if(!m&&!g)return{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()};let v=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),y=t.limits.maxArrayElements,x=0,b=async(w,E)=>{let A=q(E);if(A>v-x)throw new C(`aggregate input size limit exceeded (${v} bytes)`,"string_length");x+=A;let O=+(E.length>0);for(let D=0;Dy+1)throw new C(`record array limit exceeded (${y})`,"array_elements");let N=E.split(` `);if(N.length>0&&N[N.length-1]===""&&N.pop(),N.length>y)throw new C(`record array limit exceeded (${y})`,"array_elements");for(f.FILENAME=w,f.FNR=0,f.lines=N,f.lineIndex=-1,f.shouldNextFile=!1;f.lineIndexd.executeLine(N[D])),f.shouldExit||f.shouldNextFile)break}};if(l.length>0)for(let w of l){let E;try{let A=t.fs.resolvePath(t.cwd,w);if((await r("input file stat",()=>t.fs.stat(A))).size>v-x)throw new C(`aggregate input size limit exceeded (${v} bytes)`,"string_length");E=await r("input file read",()=>t.fs.readFile(A))}catch(A){if(A instanceof Ae||A instanceof C)throw A;return{stdout:"",stderr:`awk: ${w}: No such file or directory `,exitCode:1}}if(await r("input processing",()=>b(w,E)),f.shouldExit)break}else await r("stdin processing",()=>b("",ke(t.stdin)));return await r("END execution",()=>d.executeEnd()),{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()}}catch(v){if(v instanceof Ae)throw v;let y=v instanceof Error?v.message:String(v),x=v instanceof C?C.EXIT_CODE:2;return{stdout:d.getOutput(),stderr:`awk: ${y} `,exitCode:x}}}},V2={name:"awk",flags:[{flag:"-F",type:"value",valueHint:"delimiter"},{flag:"-v",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function vh(e){let t=e.trim(),r=t.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!r){let s=parseFloat(t);return Number.isNaN(s)?0:s}let n=parseFloat(r[1]),i=(r[2]||"").toLowerCase();return n*(Z2.get(i)??1)}function bh(e){let t=e.trim().toLowerCase().slice(0,3);return Q2.get(t)??0}function Pw(e,t){let r=e.split(/(\d+)/),n=t.split(/(\d+)/),i=Math.max(r.length,n.length);for(let s=0;s=i.length)return"";if(t.endField===void 0){let l=i[s]||"";return t.startChar!==void 0&&(l=l.slice(t.startChar-1)),t.ignoreLeading&&(l=l.trimStart()),l}let a=Math.min(t.endField-1,i.length-1),o="";for(let l=s;l<=a&&ls&&(o+=r||" "),o+=u}return t.ignoreLeading&&(o=o.trimStart()),o}function Eh(e,t,r){let n=e,i=t;return r.dictionaryOrder&&(n=wh(n),i=wh(i)),r.ignoreCase&&(n=n.toLowerCase(),i=i.toLowerCase()),r.monthSort?bh(n)-bh(i):r.humanNumeric?vh(n)-vh(i):r.versionSort?Pw(n,i):r.numeric?(parseFloat(n)||0)-(parseFloat(i)||0):n.localeCompare(i)}function Dw(e){let{keys:t,fieldDelimiter:r,numeric:n,ignoreCase:i,reverse:s,humanNumeric:a,versionSort:o,dictionaryOrder:l,monthSort:u,ignoreLeadingBlanks:c,stable:p}=e;return(h,f)=>{let d=h,m=f;if(c&&(d=d.trimStart(),m=m.trimStart()),t.length===0){let g=Eh(d,m,{numeric:n,ignoreCase:i,humanNumeric:a,versionSort:o,dictionaryOrder:l,monthSort:u});if(g!==0)return s?-g:g;if(!p){let v=h.localeCompare(f);return s?-v:v}return 0}for(let g of t){let v=Eu(d,g,r),y=Eu(m,g,r);g.ignoreLeading&&(v=v.trimStart(),y=y.trimStart());let x={numeric:g.numeric??n,ignoreCase:g.ignoreCase??i,humanNumeric:g.humanNumeric??a,versionSort:g.versionSort??o,dictionaryOrder:g.dictionaryOrder??l,monthSort:g.monthSort??u},b=g.reverse??s,w=Eh(v,y,x);if(w!==0)return b?-w:w}if(!p){let g=h.localeCompare(f);return s?-g:g}return 0}}function Lw(e,t){if(t.keys.length===0){if(t.ignoreCase){let i=new Set;return e.filter(s=>{let a=s.toLowerCase();return!i.has(a)&&(i.add(a),!0)})}return[...new Set(e)]}let r=t.keys[0],n=new Set;return e.filter(i=>{let s=Eu(i,r,t.fieldDelimiter);return(r.ignoreCase??t.ignoreCase)&&(s=s.toLowerCase()),!n.has(s)&&(n.add(s),!0)})}var Z2,Q2,Mw=M(()=>{Z2=new Map([["",1],["k",1024],["m",1048576],["g",1073741824],["t",1099511627776],["p",0x4000000000000],["e",1152921504606847e3]]),Q2=new Map([["jan",1],["feb",2],["mar",3],["apr",4],["may",5],["jun",6],["jul",7],["aug",8],["sep",9],["oct",10],["nov",11],["dec",12]])});function vl(e){let t={startField:1},r="",n=e,i=n.match(/([bdfhMnrV]+)$/);i&&(r=i[1],n=n.slice(0,-r.length)),r.includes("n")&&(t.numeric=!0),r.includes("r")&&(t.reverse=!0),r.includes("f")&&(t.ignoreCase=!0),r.includes("b")&&(t.ignoreLeading=!0),r.includes("h")&&(t.humanNumeric=!0),r.includes("V")&&(t.versionSort=!0),r.includes("d")&&(t.dictionaryOrder=!0),r.includes("M")&&(t.monthSort=!0);let s=n.split(",");if(s.length===0||s[0]==="")return null;let a=s[0].split("."),o=parseInt(a[0],10);if(Number.isNaN(o)||o<1)return null;if(t.startField=o,a.length>1&&a[1]){let l=parseInt(a[1],10);!Number.isNaN(l)&&l>=1&&(t.startChar=l)}if(s.length>1&&s[1]){let l=s[1],u=l.match(/([bdfhMnrV]+)$/);if(u){let p=u[1];p.includes("n")&&(t.numeric=!0),p.includes("r")&&(t.reverse=!0),p.includes("f")&&(t.ignoreCase=!0),p.includes("b")&&(t.ignoreLeading=!0),p.includes("h")&&(t.humanNumeric=!0),p.includes("V")&&(t.versionSort=!0),p.includes("d")&&(t.dictionaryOrder=!0),p.includes("M")&&(t.monthSort=!0),l=l.slice(0,-p.length)}let c=l.split(".");if(c[0]){let p=parseInt(c[0],10);if(!Number.isNaN(p)&&p>=1&&(t.endField=p),c.length>1&&c[1]){let h=parseInt(c[1],10);!Number.isNaN(h)&&h>=1&&(t.endChar=h)}}}return t}var Fw=M(()=>{}),K2={};re(K2,{flagsForFuzzing:()=>Y2,sortCommand:()=>X2});var Sh,X2,Y2,_w=M(()=>{se(),ui(),le(),Mw(),Fw(),Sh={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]] F is a field number (1-indexed) C is a character position within the field (1-indexed) OPTS can be: b d f h M n r V (per-key modifiers) Examples: -k1 sort by first field -k2,2 sort by second field only -k1.3 sort by first field starting at 3rd character -k1,2n sort by fields 1-2 numerically -k2 -k1 sort by field 2, then by field 1`},X2={name:"sort",async execute(e,t){if(he(e))return ce(Sh);let r={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},n=[];for(let l=0;l0&&s[s.length-1]===""&&s.pop();let a=Dw(r);if(r.checkOnly){let l=n.length>0?n[0]:"-";for(let u=1;u0)return{stdout:"",stderr:`sort: ${l}:${u+1}: disorder: ${s[u]} `,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}s.sort(a),r.unique&&(s=Lw(s,r));let o=s.length>0?`${s.join(` `)} `:"";if(r.outputFile){let l=t.fs.resolvePath(t.cwd,r.outputFile);return await t.fs.writeFile(l,o),{stdout:"",stderr:"",exitCode:0}}return{stdout:o,stderr:"",exitCode:0}}},Y2={name:"sort",flags:[{flag:"-r",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-V",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-M",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-k",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"delimiter"},{flag:"-o",type:"value",valueHint:"path"}],stdinType:"text",needsFiles:!0}}),J2={};re(J2,{flagsForFuzzing:()=>t6,uniqCommand:()=>e6});var Ah,Ch,e6,t6,zw=M(()=>{se(),Ct(),ui(),le(),Ah={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},Ch={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},e6={name:"uniq",async execute(e,t){if(he(e))return ce(Ah);let r=At("uniq",e,Ch);if(!r.ok)return r.error;let{count:n,duplicatesOnly:i,uniqueOnly:s,ignoreCase:a}=r.result.flags,o=r.result.positional,l=await Ic(t,o,{cmdName:"uniq"});if(!l.ok)return l.error;let u=(a?ke(l.content):l.content).split(` `);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let c=[],p=u[0],h=1,f=(g,v)=>a?g.toLowerCase()===v.toLowerCase():g===v;for(let g=1;gg.count>1):s&&(d=c.filter(g=>g.count===1));let m="";for(let{line:g,count:v}of d)m+=n?`${String(v).padStart(4)} ${g} `:`${g} `;return a?{stdout:m,stderr:"",exitCode:0}:{stdout:m,stderr:"",exitCode:0,stdoutKind:"bytes",stdoutEncoding:"binary"}}},t6={name:"uniq",flags:[{flag:"-c",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-i",type:"boolean"}],stdinType:"text",needsFiles:!0}}),r6={};re(r6,{commCommand:()=>n6,flagsForFuzzing:()=>i6});var kh,n6,i6,Bw=M(()=>{se(),le(),kh={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},n6={name:"comm",async execute(e,t){if(he(e))return ce(kh);let r=!1,n=!1,i=!1,s=[];for(let g of e)if(g==="-1")r=!0;else if(g==="-2")n=!0;else if(g==="-3")i=!0;else if(g==="-12"||g==="-21")r=!0,n=!0;else if(g==="-13"||g==="-31")r=!0,i=!0;else if(g==="-23"||g==="-32")n=!0,i=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")r=!0,n=!0,i=!0;else{if(g.startsWith("-")&&g!=="-")return ve("comm",g);s.push(g)}if(s.length!==2)return{stdout:"",stderr:`comm: missing operand Try 'comm --help' for more information. `,exitCode:1};let a=async g=>{if(g==="-")return ke(t.stdin);try{let v=t.fs.resolvePath(t.cwd,g);return await t.fs.readFile(v)}catch{return null}},o=await a(s[0]);if(o===null)return{stdout:"",stderr:`comm: ${s[0]}: No such file or directory `,exitCode:1};let l=await a(s[1]);if(l===null)return{stdout:"",stderr:`comm: ${s[1]}: No such file or directory `,exitCode:1};let u=o.split(` `),c=l.split(` `);u.length>0&&u[u.length-1]===""&&u.pop(),c.length>0&&c[c.length-1]===""&&c.pop();let p=0,h=0,f="",d=r?"":" ",m=(r?"":" ")+(n?"":" ");for(;p=u.length?(n||(f+=`${d}${c[h]} `),h++):h>=c.length||u[p]c[h]?(n||(f+=`${d}${c[h]} `),h++):(i||(f+=`${m}${u[p]} `),p++,h++);return{stdout:f,stderr:"",exitCode:0}}},i6={name:"comm",flags:[{flag:"-1",type:"boolean"},{flag:"-2",type:"boolean"},{flag:"-3",type:"boolean"}],needsArgs:!0,minArgs:2}}),s6={};re(s6,{cutCommand:()=>a6,flagsForFuzzing:()=>o6});function Uw(e,t){let r=[],n=e.split(",");if(n.length>t)throw new C(`cut: range count limit exceeded (${t})`,"array_elements");for(let i of n)if(i.includes("-")){let[s,a]=i.split("-"),o=s?Number(s):1,l=a?Number(a):null;if(!Number.isSafeInteger(o)||o<1||l!==null&&(!Number.isSafeInteger(l)||l=0&&!n.has(o)&&(n.add(o),r.push(e[o]))}return r}var Nh,a6,o6,jw=M(()=>{Et(),se(),H(),ui(),le(),Nh={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]},a6={name:"cut",async execute(e,t){if(he(e))return ce(Nh);let r=" ",n=null,i=null,s=!1,a=[];for(let f=0;f0&&l[l.length-1]===""&&l.pop();let u=Uw(n||i||"1",t.limits.maxArrayElements),c=new st(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),"cut"),p=0,h=f=>{if(!Number.isSafeInteger(f)||f<0||f>t.limits.maxLoopIterations-p)throw new C(`cut: range expansion limit exceeded (${t.limits.maxLoopIterations})`,"iterations");p+=f,t.executionScope?.consumeWork(f,"cut range expansion")};for(let f of l)if(i){let d=Array.from(f),m=[];for(let g of u){let v=g.start-1,y=g.end===null?d.length:g.end;h(Math.max(0,Math.min(y,d.length)-v));for(let x=v;x=0&&m.push(d[x])}c.append(`${m.join("")} `)}else{if(s&&!f.includes(r))continue;let d=f.split(r);for(let g of u){let v=g.start-1,y=g.end===null?d.length:g.end;h(Math.max(0,Math.min(y,d.length)-v))}let m=Ww(d,u);c.append(`${m.join(r)} `)}return i?{stdout:c.build(),stderr:"",exitCode:0}:{stdout:c.build(),stderr:"",exitCode:0,stdoutKind:"bytes",stdoutEncoding:"binary"}}},o6={name:"cut",flags:[{flag:"-d",type:"value",valueHint:"delimiter"},{flag:"-f",type:"value",valueHint:"string"},{flag:"-c",type:"value",valueHint:"string"},{flag:"-s",type:"boolean"}],stdinType:"text",needsFiles:!0}}),l6={};re(l6,{flagsForFuzzing:()=>c6,pasteCommand:()=>u6});function $h(e,t){if(e.length===0)return"";if(e.length===1)return e[0];if(t.length===0)return e.join("");let r=e[0];for(let n=1;n{Et(),se(),Lt(),H(),Ct(),le(),Oh={name:"paste",summary:"merge lines of files",usage:"paste [OPTION]... [FILE]...",description:["Write lines consisting of the sequentially corresponding lines from","each FILE, separated by TABs, to standard output.","","With no FILE, or when FILE is -, read standard input."],options:["-d, --delimiters=LIST reuse characters from LIST instead of TABs","-s, --serial paste one file at a time instead of in parallel"," --help display this help and exit"],examples:["paste file1 file2 Merge file1 and file2 side by side","paste -d, file1 file2 Use comma as delimiter","paste -s file1 Paste all lines of file1 on one line","paste - - < file Paste pairs of lines from file"]},Th={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},u6={name:"paste",async execute(e,t){if(he(e))return ce(Oh);let r=At("paste",e,Th);if(!r.ok)return r.error;let n=r.result.flags.delimiter,i=r.result.flags.serial,s=r.result.positional;if(s.length>t.limits.maxArrayElements)throw new C(`paste: file operand limit exceeded (${t.limits.maxArrayElements})`,"array_elements");if(q(n)>t.limits.maxStringLength)throw new C(`paste: delimiter size limit exceeded (${t.limits.maxStringLength} bytes)`,"string_length");if(s.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ... `,exitCode:1};let a=ke(t.stdin),o=a?a.split(` `):[""];o.length>0&&o[o.length-1]===""&&o.pop();let l=s.filter(m=>m==="-").length,u=[],c=0,p=q(a),h=m=>{if(m.length>t.limits.maxArrayElements-c)throw new C(`paste: line limit exceeded (${t.limits.maxArrayElements})`,"array_elements");c+=m.length,t.executionScope?.consumeWork(m.length,"paste lines")},f=0;for(let m of s)if(m==="-"){let g=[];for(let v=f;vt.limits.maxInputBytes-p)throw new C(`paste: aggregate input size limit exceeded (${t.limits.maxInputBytes} bytes)`,"string_length");p+=y,t.executionScope?.consumeInput(y,"paste");let x=v.split(` `);x.length>0&&x[x.length-1]===""&&x.pop(),h(x),u.push(x)}catch(v){return Ie(v),{stdout:"",stderr:`paste: ${m}: No such file or directory `,exitCode:1}}}let d=new st(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),"paste");if(i)for(let m of u)m&&d.append(`${$h(m,n)} `);else{let m=0;for(let g of u)m=Math.max(m,g?.length??0);for(let g=0;gd6,trCommand:()=>f6});function Ih(e,t,r,n){let i="",s=0,a=l=>{if(l.length>t-i.length)throw new C(`tr: expanded SET exceeds string length limit (${t})`,"string_length");i+=l},o=(l=1)=>{if(l>r-n.iterations)throw new C(`tr: SET expansion iteration limit exceeded (${r})`,"iterations");n.iterations+=l};for(;s=l?u-l+1:0;if(o(c),c>t-i.length)throw new C(`tr: expanded SET exceeds string length limit (${t})`,"string_length");for(let p=l;p<=u;p++)i+=String.fromCharCode(p);s+=3;continue}a(e[s]),s++}return i}var Rh,h6,Ph,f6,d6,Gw=M(()=>{se(),Lt(),Mr(),H(),Ct(),le(),Rh={name:"tr",summary:"translate or delete characters",usage:"tr [OPTION]... SET1 [SET2]",options:["-c, -C, --complement use the complement of SET1","-d, --delete delete characters in SET1","-s, --squeeze-repeats squeeze repeated characters"," --help display this help and exit"],description:`SET syntax: a-z character range [:alnum:] all letters and digits [:alpha:] all letters [:digit:] all digits [:lower:] all lowercase letters [:upper:] all uppercase letters [:space:] all whitespace [:blank:] horizontal whitespace [:punct:] all punctuation [:print:] all printable characters [:graph:] all printable characters except space [:cntrl:] all control characters [:xdigit:] all hexadecimal digits \\n, \\t, \\r escape sequences`},h6=new Map([["[:alnum:]","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"],["[:alpha:]","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],["[:blank:]"," "],["[:cntrl:]",Array.from({length:32},(e,t)=>String.fromCharCode(t)).join("").concat("\x7F")],["[:digit:]","0123456789"],["[:graph:]",Array.from({length:94},(e,t)=>String.fromCharCode(33+t)).join("")],["[:lower:]","abcdefghijklmnopqrstuvwxyz"],["[:print:]",Array.from({length:95},(e,t)=>String.fromCharCode(32+t)).join("")],["[:punct:]","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"],["[:space:]",` \r\f\v`],["[:upper:]","ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["[:xdigit:]","0123456789ABCDEFabcdef"]]),Ph={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},f6={name:"tr",async execute(e,t){if(he(e))return ce(Rh);let r=At("tr",e,Ph);if(!r.ok)return r.error;let n=r.result.flags.complement||r.result.flags.complementUpper,i=r.result.flags.delete,s=r.result.flags.squeeze,a=r.result.positional;if(a.length<1)return{stdout:"",stderr:`tr: missing operand `,exitCode:1};if(!i&&!s&&a.length<2)return{stdout:"",stderr:`tr: missing operand after SET1 `,exitCode:1};let o,l,u=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),c=t.limits.maxLoopIterations,p=t.limits.maxArrayElements,h=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength);try{let b={iterations:0};o=Ih(a[0],u,c,b),l=a.length>1?Ih(a[1],u,c,b):""}catch(b){return Ie(b),{stdout:"",stderr:`${xt(b.message)} `,exitCode:1}}if(t.stdin.length>u)throw new C(`tr: input size limit exceeded (${u} bytes)`,"string_length");let f=ke(t.stdin);if(o.length>p||l.length>p)throw new C(`tr: array element limit exceeded (${p})`,"array_elements");let d=new Set(o),m=new Set(l),g=b=>{let w=d.has(b);return n?!w:w},v="",y=0,x=b=>{let w=q(b);if(w>h-y)throw new C(`tr: output size limit exceeded (${h} bytes)`,"output_size");v+=b,y+=w};if(i)for(let b of f)g(b)||x(b);else if(s&&a.length===1){let b="";for(let w of f)g(w)&&w===b||(x(w),b=w)}else{let b="",w=E=>{s&&m.has(E)&&E===b||(x(E),b=E)};if(n){let E=l.length>0?l[l.length-1]:"";for(let A of f)d.has(A)?w(A):w(E)}else{let E=new Map;for(let A=0;Ay6,rev:()=>g6});function Hw(e){return Array.from(e).reverse().join("")}var Dh,g6,y6,Vw=M(()=>{se(),le(),Dh={name:"rev",summary:"reverse lines characterwise",usage:"rev [file ...]",description:"Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.",examples:["echo 'hello' | rev # Output: olleh","rev file.txt # Reverse each line in file"]},g6={name:"rev",execute:async(e,t)=>{if(he(e))return ce(Dh);let r=[];for(let s of e)if(s==="--"){let a=e.indexOf(s);r.push(...e.slice(a+1));break}else{if(s.startsWith("-")&&s!=="-")return ve("rev",s);r.push(s)}let n="",i=s=>{let a=s.split(` `),o=s.endsWith(` `)&&a[a.length-1]==="";return o&&a.pop(),a.map(Hw).join(` `)+(o?` `:"")};if(r.length===0)n=i(ke(t.stdin)??"");else for(let s of r)if(s==="-"){let a=ke(t.stdin)??"";n+=i(a)}else{let a=t.fs.resolvePath(t.cwd,s),o=await t.fs.readFile(a);if(o===null)return{exitCode:1,stdout:n,stderr:`rev: ${s}: No such file or directory `};n+=i(o)}return{exitCode:0,stdout:n,stderr:""}}},y6={name:"rev",flags:[],stdinType:"text",needsFiles:!0}}),x6={};re(x6,{flagsForFuzzing:()=>b6,nl:()=>v6});function Zw(e,t,r){let n=String(e);switch(t){case"ln":return n.padEnd(r);case"rn":return n.padStart(r);case"rz":return n.padStart(r,"0");default:return t}}function Qw(e,t){switch(t){case"a":return!0;case"t":return e.trim().length>0;case"n":return!1;default:return t}}function Lh(e,t,r,n){if(e==="")return{output:"",nextNumber:r};let i=e.split(` `),s=[],a=0,o=r,l=e.endsWith(` `)&&i[i.length-1]==="";l&&i.pop();for(let u of i){let c=+(s.length>0),p=q(t.separator)+q(u);if(Qw(u,t.bodyStyle)){let h=Math.max(String(o).length,t.width)+p+c;if(h>n-a)throw new C(`nl: output size limit exceeded (${n} bytes)`,"output_size");let f=`${Zw(o,t.numberFormat,t.width)}${t.separator}${u}`;s.push(f),a+=h,o+=t.increment}else{let h=t.width+p+c;if(h>n-a)throw new C(`nl: output size limit exceeded (${n} bytes)`,"output_size");let f=`${" ".repeat(t.width)}${t.separator}${u}`;s.push(f),a+=h}}if(l&&a+1>n)throw new C(`nl: output size limit exceeded (${n} bytes)`,"output_size");return{output:s.join(` `)+(l?` `:""),nextNumber:o}}var Mh,v6,b6,Kw=M(()=>{se(),H(),le(),Mh={name:"nl",summary:"number lines of files",usage:"nl [OPTION]... [FILE]...",description:"Write each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.",options:["-b STYLE Body numbering style: a (all), t (non-empty), n (none)","-n FORMAT Number format: ln (left), rn (right), rz (right zeros)","-w WIDTH Number width (default: 6)","-s SEP Separator after number (default: TAB)","-v START Starting line number (default: 1)","-i INCR Line number increment (default: 1)"],examples:["nl file.txt # Number non-empty lines","nl -ba file.txt # Number all lines","nl -n rz -w 3 file.txt # Right-justified with zeros","nl -s ': ' file.txt # Use ': ' as separator"]},v6={name:"nl",execute:async(e,t)=>{if(he(e))return ce(Mh);let r={bodyStyle:"t",numberFormat:"rn",width:6,separator:" ",startNumber:1,increment:1},n=[],i=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),s=i,a=0;for(;ai)return{exitCode:1,stdout:"",stderr:`nl: invalid line number field width: '${e[a+1]}' `};r.width=c,a+=2}else if(u.startsWith("-w")){let c=/^\d+$/.test(u.slice(2))?Number(u.slice(2)):NaN;if(!Number.isSafeInteger(c)||c<1||c>i)return{exitCode:1,stdout:"",stderr:`nl: invalid line number field width: '${u.slice(2)}' `};r.width=c,a++}else if(u==="-s"&&a+1S6,fold:()=>E6});function Xw(e,t,r){return r?q(e):e===" "?8-t%8:e==="\b"?-1:1}function Yw(e,t){if(e.length===0)return e;let{width:r,breakAtSpaces:n,countBytes:i}=t,s=[],a="",o=0,l=-1,u=0;for(let c of e){let p=Xw(c,o,i);o+p>r&&a.length>0?n&&l>=0?(s.push(a.slice(0,l+1)),a=a.slice(l+1)+c,o=o-u-1+p,l=-1,u=0):(s.push(a),a=c,o=p,l=-1,u=0):(a+=c,o+=p,(c===" "||c===" ")&&(l=a.length-1,u=o-p))}return a.length>0&&s.push(a),s.join(` `)}function Fh(e,t){if(e==="")return"";let r=e.split(` `),n=e.endsWith(` `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>Yw(i,t)).join(` `)+(n?` `:"")}var _h,E6,S6,Jw=M(()=>{se(),le(),_h={name:"fold",summary:"wrap each input line to fit in specified width",usage:"fold [OPTION]... [FILE]...",description:"Wrap input lines in each FILE, writing to standard output. If no FILE is specified, standard input is read.",options:["-w WIDTH Use WIDTH columns instead of 80","-s Break at spaces","-b Count bytes rather than columns"],examples:["fold -w 40 file.txt # Wrap at 40 columns","fold -sw 40 file.txt # Word wrap at 40 columns","echo 'long line' | fold -w 5 # Force wrap at 5"]},E6={name:"fold",execute:async(e,t)=>{if(he(e))return ce(_h);let r={width:80,breakAtSpaces:!1,countBytes:!1},n=[],i=0;for(;i2){let o=parseInt(a.slice(2),10);if(Number.isNaN(o)||o<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${a.slice(2)}' `};r.width=o,i++}else if(a==="-s")r.breakAtSpaces=!0,i++;else if(a==="-b")r.countBytes=!0,i++;else if(a==="-bs"||a==="-sb")r.breakAtSpaces=!0,r.countBytes=!0,i++;else if(a.match(/^-[sb]+w\d+$/)){a.includes("s")&&(r.breakAtSpaces=!0),a.includes("b")&&(r.countBytes=!0);let o=a.replace(/^-[sb]+w/,""),l=parseInt(o,10);if(Number.isNaN(l)||l<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${o}' `};r.width=l,i++}else if(a.match(/^-[sb]+w$/)&&i+1C6,flagsForFuzzing:()=>k6});function Ks(e,t,r){let n=e.split(",").map(s=>s.trim());if(n.length>r)return null;let i=[];for(let s of n){let a=/^\d+$/.test(s)?Number(s):NaN;if(!Number.isSafeInteger(a)||a<1||a>t)return null;i.push(a)}for(let s=1;se)return r-e;if(t.length>=2){let r=t[t.length-1]-t[t.length-2],n=t[t.length-1];return n+(Math.floor((e-n)/r)+1)*r-e}return 1}function t5(e,t,r){let{tabStops:n,leadingOnly:i}=t,s="",a=0,o=!0,l=0;for(let u of e)if(u===" ")if(i&&!o){if(l+1>r)throw new C(`expand: output size limit exceeded (${r} bytes)`,"output_size");s+=u,l++,a++}else{let c=e5(a,n);if(c>r-l)throw new C(`expand: output size limit exceeded (${r} bytes)`,"output_size");s+=" ".repeat(c),l+=c,a+=c}else{u!==" "&&u!==" "&&(o=!1);let c=q(u);if(c>r-l)throw new C(`expand: output size limit exceeded (${r} bytes)`,"output_size");s+=u,l+=c,a++}return s}function zh(e,t,r){if(e==="")return"";let n=e.split(` `),i=e.endsWith(` `)&&n[n.length-1]==="";i&&n.pop();let s=[],a=0;for(let o of n){let l=+(s.length>0),u=t5(o,t,r-a-l);a+=l+q(u),s.push(u)}if(i&&a+1>r)throw new C(`expand: output size limit exceeded (${r} bytes)`,"output_size");return s.join(` `)+(i?` `:"")}var Bh,C6,k6,r5=M(()=>{se(),H(),le(),wt(),Bh={name:"expand",summary:"convert tabs to spaces",usage:"expand [OPTION]... [FILE]...",description:"Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-i Only convert leading tabs on each line"],examples:["expand file.txt # Convert all tabs to 8 spaces","expand -t 4 file.txt # Use 4-space tabs","expand -t 4,8,12 file.txt # Custom tab stops"]},C6={name:"expand",execute:async(e,t)=>{if(he(e))return ce(Bh);let r={tabStops:[8],leadingOnly:!1},n=[],i=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),s=t.limits.maxArrayElements,a=0;for(;a2){let u=Ks(l.slice(2),i,s);if(!u)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${l.slice(2)}' `};r.tabStops=u,a++}else if(l==="--tabs"&&a+1O6,unexpand:()=>$6});function Xs(e){let t=e.split(",").map(n=>n.trim()),r=[];for(let n of t){let i=parseInt(n,10);if(Number.isNaN(i)||i<1)return null;r.push(i)}for(let n=1;ne)return r;if(t.length>=2){let r=t[t.length-1]-t[t.length-2],n=t[t.length-1];return n+(Math.floor((e-n)/r)+1)*r}return-1}function n5(e,t){let{tabStops:r,allBlanks:n}=t,i="",s=0,a="",o=0,l=!0,u=()=>{if(a.length===0)return;let c=o+a.length;if(!n&&!l){i+=a,a="";return}let p=o,h="";for(;pp)h+=" ",p=d;else break}let f=c-p;f>0&&(h+=" ".repeat(f)),i+=h,a=""};for(let c of e)c===" "?(a.length===0&&(o=s),a+=c,s++):c===" "?(u(),i+=c,s=Uh(s,r)):(u(),i+=c,s++,l=!1);return u(),i}function Wh(e,t){if(e==="")return"";let r=e.split(` `),n=e.endsWith(` `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>n5(i,t)).join(` `)+(n?` `:"")}var jh,$6,O6,i5=M(()=>{se(),le(),jh={name:"unexpand",summary:"convert spaces to tabs",usage:"unexpand [OPTION]... [FILE]...",description:"Convert blanks in each FILE to TABs, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-a Convert all sequences of blanks (not just leading)"],examples:["unexpand file.txt # Convert leading spaces to tabs","unexpand -a file.txt # Convert all space sequences","unexpand -t 4 file.txt # Use 4-space tabs"]},$6={name:"unexpand",execute:async(e,t)=>{if(he(e))return ce(jh);let r={tabStops:[8],allBlanks:!1},n=[],i=0;for(;i2){let o=Xs(a.slice(2));if(!o)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${a.slice(2)}' `};r.tabStops=o,i++}else if(a==="--tabs"&&i+1R6,strings:()=>I6});function s5(e){return e>=32&&e<=126||e===9}function qh(e,t){if(t===null)return"";switch(t){case"o":return`${e.toString(8).padStart(7," ")} `;case"x":return`${e.toString(16).padStart(7," ")} `;case"d":return`${e.toString(10).padStart(7," ")} `;default:return t}}function Gh(e,t,r,n=!1,i){let s=[],a=0,o=0,l=typeof e=="string"&&!n?new TextEncoder().encode(e):e;if(l.length>r.maxStringLength-r.inputBytes)throw new C(`strings: aggregate input size limit exceeded (${r.maxStringLength} bytes)`,"string_length");r.inputBytes+=l.length;let u=new TextDecoder,c=(h,f)=>typeof l=="string"?l.slice(h,f):u.decode(l.subarray(h,f)),p=h=>{if(++r.iterations>r.maxIterations)throw new C(`strings: iteration limit exceeded (${r.maxIterations})`,"iterations");if(r.resultCount>=r.maxArrayElements)throw new C(`strings: array element limit exceeded (${r.maxArrayElements})`,"array_elements");let f=h.length+1;if(f>r.maxOutputSize-r.outputBytes)throw new C(`strings: output size limit exceeded (${r.maxOutputSize} bytes)`,"output_size");s.push(h),r.resultCount++,r.outputBytes+=f};for(let h=0;h=r.maxStringLength)throw new C(`strings: string length limit exceeded (${r.maxStringLength} bytes)`,"string_length");a++}else a>=t.minLength&&p(`${qh(o,t.offsetFormat)}${c(o,h)}`),a=0}return a>=t.minLength&&p(`${qh(o,t.offsetFormat)}${c(o,l.length)}`),s}var Hh,I6,R6,a5=M(()=>{H(),le(),Hh={name:"strings",summary:"print the sequences of printable characters in files",usage:"strings [OPTION]... [FILE]...",description:"For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.",options:["-n MIN Print sequences of at least MIN characters (default: 4)","-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)","-a Scan the entire file (default behavior)","-e ENCODING Select character encoding (s=7-bit, S=8-bit)"],examples:["strings file.bin # Extract strings (min 4 chars)","strings -n 8 file.bin # Extract strings (min 8 chars)","strings -t x file.bin # Show hex offset","echo 'hello' | strings # Read from stdin"]},I6={name:"strings",execute:async(e,t)=>{if(he(e))return ce(Hh);let r={minLength:4,offsetFormat:null},n=[],i=0;for(;it.stdin;if(n.length===0){let l=Gh(o(),r,a,!0,t.signal);s=l.length>0?`${l.join(` `)} `:""}else for(let l of n){let u;if(l==="-")u=o();else{let p=t.fs.resolvePath(t.cwd,l);try{u=await t.fs.readFileBuffer(p)}catch{return{exitCode:1,stdout:s,stderr:`strings: ${l}: No such file or directory `}}}let c=Gh(u,r,a,typeof u=="string",t.signal);c.length>0&&(s+=`${c.join(` `)} `)}return{exitCode:0,stdout:s,stderr:""}}},R6={name:"strings",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-a",type:"boolean"},{flag:"-e",type:"value",valueHint:"string"}],stdinType:"text",needsFiles:!0}}),P6={};re(P6,{flagsForFuzzing:()=>M6,split:()=>L6});function o5(e){return Uint8Array.from(e,t=>t.charCodeAt(0))}function Vh(e){let t=e.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!t)return null;let r=Number(t[1]);if(!Number.isSafeInteger(r)||r<1)return null;let n=(t[2]||"").toUpperCase(),i=new Map([["",1],["K",1024],["M",1048576],["G",1073741824],["T",1099511627776],["P",0x4000000000000]]).get(n);return i===void 0||r>Math.floor((2**53-1)/i)?null:r*i}function hi(e){if(!/^[0-9]+$/.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}function l5(e,t,r){if(t)return e.toString().padStart(r,"0");let n=Array(r),i=e;for(let s=r-1;s>=0;s--)n[s]="abcdefghijklmnopqrstuvwxyz"[i%26],i=Math.floor(i/26);return n.join("")}function u5(e,t){let r=[],n=0,i=0;for(let s=0;s{se(),Lt(),_r(),H(),le(),Qh={name:"split",summary:"split a file into pieces",usage:"split [OPTION]... [FILE [PREFIX]]",description:"Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.",options:["-l N Put N lines per output file","-b SIZE Put SIZE bytes per output file (K, M, G suffixes)","-n CHUNKS Split into CHUNKS equal-sized files","-d Use numeric suffixes (00, 01, ...) instead of alphabetic","-a LENGTH Use suffixes of length LENGTH (default: 2)","--additional-suffix=SUFFIX Append SUFFIX to file names"],examples:["split -l 100 file.txt # Split into 100-line chunks","split -b 1M file.bin # Split into 1MB chunks","split -n 5 file.txt # Split into 5 equal parts","split -d file.txt part_ # part_00, part_01, ...","split -a 3 -d file.txt x # x000, x001, ..."]},ns=1e5,D6=0,L6={name:"split",execute:async(e,t)=>{if(he(e))return ce(Qh);let r={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},n=[],i=0;for(;iMath.min(t.limits.maxStringLength,t.limits.maxArrayElements))return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${e[i+1]}' `};r.suffixLength=p,i+=2}else if(c.match(/^-a\d+$/)){let p=hi(c.slice(2));if(p===null||p>Math.min(t.limits.maxStringLength,t.limits.maxArrayElements))return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${c.slice(2)}' `};r.suffixLength=p,i++}else if(c==="-d"||c==="--numeric-suffixes")r.useNumericSuffix=!0,i++;else if(c.startsWith("--additional-suffix="))r.additionalSuffix=c.slice(20),i++;else if(c==="--additional-suffix"&&i+1=1&&(s=n[0]),n.length>=2&&(a=n[1]),n.length>2)return{exitCode:1,stdout:"",stderr:`split: extra operand '${n[2]}' `};if(q(a)>t.limits.maxStringLength||q(r.additionalSuffix)>t.limits.maxStringLength||r.suffixLength>t.limits.maxStringLength-Math.min(t.limits.maxStringLength,q(a))-Math.min(t.limits.maxStringLength,q(r.additionalSuffix)))return{exitCode:1,stdout:"",stderr:`split: output filename exceeds configured string limit `};let o,l=null,u;if(s==="-"){let c=t.stdin.length;u=t.executionScope?.reserveBytes("split transaction",c*2,"split"),o=o5(t.stdin)}else{l=t.fs.resolvePath(t.cwd,s);try{let c=await t.fs.stat(l);if(u=t.executionScope?.reserveBytes("split transaction",c.size*2,"split"),o=await t.fs.readFileBuffer(l),o.byteLength>c.size)throw new C("split: input grew while being read","string_length");t.executionScope?.consumeInput(o.byteLength,"split")}catch(c){return u?.release(),Ie(c),{exitCode:1,stdout:"",stderr:`split: ${s}: No such file or directory `}}}try{if(o.length===0)return{exitCode:0,stdout:"",stderr:""};if(r.mode==="chunks"&&r.chunks>ns)return{exitCode:1,stdout:"",stderr:`split: too many output files (${r.chunks}), limit is ${ns} `};let c;switch(r.mode){case"lines":c=u5(o,r.lines);break;case"bytes":c=c5(o,r.bytes);break;case"chunks":c=p5(o,r.chunks);break;default:return r.mode}if(c.length>ns)return{exitCode:1,stdout:"",stderr:`split: too many output files (${c.length}), limit is ${ns} `};let p=h5(r.useNumericSuffix,r.suffixLength);if(c.length>p)return{exitCode:1,stdout:"",stderr:`split: output file suffixes exhausted at ${p} files `};t.executionScope?.consumeWork(c.length*r.suffixLength,"split suffix generation");let h=[],f=new Set,d=l?await Zr(t.fs,l):null;if(d?.existence==="unknown")return{exitCode:1,stdout:"",stderr:`split: cannot safely identify input file `};for(let m=0;m{}),void 0)}catch{for(let m of[...h].reverse())m.committed&&await t.fs.rm(m.path,{force:!0,recursive:!0}).catch(()=>{}),m.backupPath&&await t.fs.mv(m.backupPath,m.path).catch(()=>{}),m.stagePath&&await t.fs.rm(m.stagePath,{force:!0,recursive:!0}).catch(()=>{});return{exitCode:1,stdout:"",stderr:`split: failed to write output `}}return{exitCode:0,stdout:"",stderr:""}}finally{u?.release()}}},M6={name:"split",flags:[{flag:"-l",type:"value",valueHint:"number"},{flag:"-b",type:"value",valueHint:"string"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-d",type:"boolean"},{flag:"-a",type:"value",valueHint:"number"}],needsFiles:!0}}),F6={};re(F6,{column:()=>_6,flagsForFuzzing:()=>z6});function Kh(e,t,r,n){return t?r?e.split(t,n):e.split(t,n).filter(i=>i.length>0):r?e.split(/[ \t]/,n):e.split(/[ \t]+/,n).filter(i=>i.length>0)}function m5(e){let t=[];for(let r of e)for(let n=0;nt[n])&&(t[n]=i)}return t}function g5(e,t,r){if(e.length===0)return"";let n=m5(e),i=new st(r,"column",void 0,1);for(let s=0;s0&&i.append(` `);for(let o=0;o0&&i.append(t),i.append(a[o]),o0&&u.append(` `);let p=!1;for(let h=0;h=e.length?(p&&u.append(r),u.append(e[f])):(p&&u.append(r),u.append(e[f]),u.repeat(" ",i-e[f].length)),p=!0)}}return u.build()}var Xh,Yh,_6,z6,x5=M(()=>{Et(),se(),H(),Ct(),le(),Xh={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},Yh={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}},_6={name:"column",execute:async(e,t)=>{if(he(e))return ce(Xh);let r=At("column",e,Yh);if(!r.ok)return r.error;let{table:n,separator:i,outputSep:s,width:a,noMerge:o}=r.result.flags,l=r.result.positional,u=s??" ",c=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),p=t.limits.maxArrayElements,h=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize);if(!Number.isFinite(a)||!Number.isSafeInteger(a)||a<=0||a>10485760)return{exitCode:1,stdout:"",stderr:`column: invalid width: ${a} `};let f;if(l.length===0)f=ke(t.stdin)??"";else{let v=[],y=0;for(let x of l)if(x==="-"){let b=ke(t.stdin)??"";if(y+=q(b),y>c)throw new C(`column: input size limit exceeded (${c} bytes)`,"string_length");v.push(b)}else{let b=t.fs.resolvePath(t.cwd,x),w=await t.fs.readFile(b);if(w===null)return{exitCode:1,stdout:"",stderr:`column: ${x}: No such file or directory `};if(y+=q(w),y>c)throw new C(`column: input size limit exceeded (${c} bytes)`,"string_length");v.push(w)}f=v.join("")}if(q(f)>c)throw new C(`column: input size limit exceeded (${c} bytes)`,"string_length");if(f===""||f.trim()==="")return{exitCode:0,stdout:"",stderr:""};let d=f.split(` `,p+1);if(d.length>p)throw new C(`column: field limit exceeded (${p})`,"array_elements");f.endsWith(` `)&&d[d.length-1]===""&&d.pop();let m=d.filter(v=>v.trim().length>0),g;if(n){let v=[],y=0;for(let x of m){let b=Kh(x,i,o,p-y+1);if(y+=b.length,y>p)throw new C(`column: field limit exceeded (${p})`,"array_elements");v.push(b)}g=g5(v,u,h)}else{let v=[];for(let y of m){let x=p-v.length,b=Kh(y,i,o,x+1);if(b.length>x)throw new C(`column: field limit exceeded (${p})`,"array_elements");for(let w of b)v.push(w)}g=y5(v,a,u,h)}return g.length>0&&(g+=` `),{exitCode:0,stdout:g,stderr:""}}},z6={name:"column",flags:[{flag:"-t",type:"boolean"},{flag:"-s",type:"value",valueHint:"delimiter"},{flag:"-o",type:"value",valueHint:"string"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-n",type:"boolean"}],stdinType:"text",needsFiles:!0}}),B6={};re(B6,{flagsForFuzzing:()=>W6,join:()=>U6});function v5(e,t){return t?e.split(t):e.split(/[ \t]+/).filter(r=>r.length>0)}function b5(e,t,r,n){let i=v5(e,t),s=i[r-1]??"";return n&&(s=s.toLowerCase()),{fields:i,joinKey:s,original:e}}function wl(e,t,r){let n=r.separator??" ";if(r.outputFormat){let a=[];for(let{file:o,field:l}of r.outputFormat){let u=o===1?e:t;u&&l===0?a.push(u.joinKey):u&&u.fields[l-1]!==void 0?a.push(u.fields[l-1]):a.push(r.emptyString)}return a.join(n)}let i=[],s=e?.joinKey??t?.joinKey??"";if(i.push(s),e)for(let a=0;a{se(),H(),le(),wt(),Jh={name:"join",summary:"join lines of two files on a common field",usage:"join [OPTION]... FILE1 FILE2",description:"For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.",options:["-1 FIELD Join on this FIELD of file 1 (default: 1)","-2 FIELD Join on this FIELD of file 2 (default: 1)","-t CHAR Use CHAR as input and output field separator","-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)","-v FILENUM Like -a but only output unpairable lines","-e STRING Replace missing fields with STRING","-o FORMAT Output format (comma-separated list of FILENUM.FIELD)","-i Ignore case when comparing fields"],examples:["join file1 file2 # Join on first field","join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1","join -t ',' file1.csv file2.csv # Join CSV files","join -a 1 file1 file2 # Left outer join"]},U6={name:"join",execute:async(e,t)=>{if(he(e))return ce(Jh);let r={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},n=[],i=0;for(;i2)r.separator=w.slice(2),i++;else if(w==="-a"&&i+1w+q(E),0)>l)throw new C(`join: aggregate input size limit exceeded (${l} bytes)`,"string_length");let c=0,p=0,h=()=>{if(++p>o)throw new C(`join: iteration limit exceeded (${o})`,"iterations")},f=(w,E)=>{let A=+(w.length>0);for(let N=0;Na-c)throw new C(`join: array element limit exceeded (${a})`,"array_elements");c+=A;let O=w.split(` `);return w.endsWith(` `)&&O[O.length-1]===""&&O.pop(),O.filter(N=>N.length>0).map(N=>b5(N,r.separator,E,r.ignoreCase))},d=f(s[0],r.field1),m=f(s[1],r.field2),g=new Map;for(let w of m){let E=g.get(w.joinKey);E?E.push(w):g.set(w.joinKey,[w])}let v=[],y=0,x=w=>{if(h(),v.length>=a)throw new C(`join: array element limit exceeded (${a})`,"array_elements");let E=q(w)+1;if(E>u-y)throw new C(`join: output size limit exceeded (${u} bytes)`,"output_size");v.push(w),y+=E},b=new Set;for(let w of d){let E=g.get(w.joinKey);if(E&&E.length>0){if(b.add(w.joinKey),r.onlyUnpairable.size===0)for(let A of E)x(wl(w,A,r))}else(r.printUnpairable.has(1)||r.onlyUnpairable.has(1))&&x(wl(w,null,r))}if(r.printUnpairable.has(2)||r.onlyUnpairable.has(2))for(let w of m)b.has(w.joinKey)||x(wl(null,w,r));return{exitCode:0,stdout:ti(v.length>0?`${v.join(` `)} `:""),stderr:"",stdoutEncoding:"binary"}}},W6={name:"join",flags:[{flag:"-1",type:"value",valueHint:"number"},{flag:"-2",type:"value",valueHint:"number"},{flag:"-t",type:"value",valueHint:"delimiter"},{flag:"-a",type:"value",valueHint:"number"},{flag:"-v",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"string"},{flag:"-o",type:"value",valueHint:"format"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2}}),j6={};re(j6,{flagsForFuzzing:()=>G6,teeCommand:()=>q6});var ef,tf,q6,G6,S5=M(()=>{se(),Ct(),le(),ef={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append append to the given FILEs, do not overwrite"," --help display this help and exit"]},tf={append:{short:"a",long:"append",type:"boolean"}},q6={name:"tee",async execute(e,t){if(he(e))return ce(ef);let r=At("tee",e,tf);if(!r.ok)return r.error;let{append:n}=r.result.flags,i=r.result.positional,s=t.stdin,a="",o=0;for(let l of i)try{let u=t.fs.resolvePath(t.cwd,l);n?await t.fs.appendFile(u,s,"binary"):await t.fs.writeFile(u,s,"binary")}catch{a+=`tee: ${l}: No such file or directory `,o=1}return{stdout:s,stderr:a,exitCode:o,stdoutEncoding:"binary"}}},G6={name:"tee",flags:[{flag:"-a",type:"boolean"}],stdinType:"text",needsArgs:!0}}),Tn,Bs=M(()=>{se(),H(),Tn=class{scope;site;stdoutChunks=[];stderrChunks=[];stdoutBytes=0;stderrBytes=0;attachedErrors=new WeakSet;constructor(e,t){this.scope=e,this.site=t}append(e,t,r=0,n="text"){let i;try{i=this.scope.appendOutput(e,t,this.site,r,n)}catch(s){throw this.prependTo(s),s}t&&(e==="stdout"?this.stdoutChunks:this.stderrChunks).push(t),e==="stdout"?this.stdoutBytes+=i:this.stderrBytes+=i}prependTo(e){e instanceof Nt&&(this.attachedErrors.has(e)||(this.attachedErrors.add(e),e.prependOutput(this.stdout,this.stderr)))}appendResult(e,t=e.stdout){let r=e.stdoutKind==="bytes"||e.stdoutEncoding==="binary"?"bytes":"text",n=r==="bytes"?t.length:q(t);this.append("stdout",t,Math.min(e.internalOutputAccounting?.stdout??0,n),r),this.append("stderr",e.stderr,e.internalOutputAccounting?.stderr??0)}build(e,t){return{stdout:this.stdoutChunks.join(""),stderr:this.stderrChunks.join(""),exitCode:e,...t,internalOutputAccounting:{stdout:this.stdoutBytes,stderr:this.stderrBytes}}}get stdout(){return this.stdoutChunks.join("")}get stderr(){return this.stderrChunks.join("")}}});function Rr(e,t){switch(e.type){case"name":{let r=e.pattern,n=r.match(/^\*(\.[a-zA-Z0-9]+)$/);if(n){let i=n[1],s=t.name;if(e.ignoreCase){if(!s.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!s.endsWith(i))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:sr(t.name,r,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let r=e.pattern,n=t.relativePath,i=r.split("/");for(let a=0;ae.days:e.comparison==="less"?rr,pruned:!1,printed:!1}}case"size":{let r=e.value;switch(e.unit){case"c":r=e.value;break;case"k":r=e.value*1024;break;case"M":r=e.value*1024*1024;break;case"G":r=e.value*1024*1024*1024;break;case"b":r=e.value*512}let n;return n=e.comparison==="more"?t.size>r:e.comparison==="less"?t.size{n&&(n.type==="newer"?t.push(n.refPath):n.type==="not"?r(n.expr):(n.type==="and"||n.type==="or")&&(r(n.left),r(n.right)))};return r(e),t}function ma(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":return!0;case"action":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return ma(e.expr);case"and":case"or":return ma(e.left)&&ma(e.right)}}function Ei(e,t,r,n,i){switch(e.type){case"name":{let s=e.pattern,a=s.match(/^\*(\.[a-zA-Z0-9]+)$/);if(a){let o=a[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(o))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:sr(t,s,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let s=e.pattern,a=s.split("/");for(let l=0;l{at(),Vg()});function N5(e,t){let r=[],n=t,i=o=>({expr:null,pathIndex:n,error:`find: missing argument to \`${o}' `}),s=(o,l)=>({expr:null,pathIndex:n,error:`find: invalid argument \`${l}' to \`${o}' `});for(;n=e.length)return i(o);r.push({type:"expr",expr:{type:"name",pattern:e[++n]}})}else if(o==="-iname"){if(n+1>=e.length)return i(o);r.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}})}else if(o==="-path"){if(n+1>=e.length)return i(o);r.push({type:"expr",expr:{type:"path",pattern:e[++n]}})}else if(o==="-ipath"){if(n+1>=e.length)return i(o);r.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}})}else if(o==="-regex"){if(n+1>=e.length)return i(o);r.push({type:"expr",expr:{type:"regex",pattern:e[++n]}})}else if(o==="-iregex"){if(n+1>=e.length)return i(o);r.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}})}else if(o==="-type"){if(n+1>=e.length)return i(o);let l=e[++n];if(l==="f"||l==="d")r.push({type:"expr",expr:{type:"type",fileType:l}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${l} `}}else if(o==="-empty")r.push({type:"expr",expr:{type:"empty"}});else if(o==="-mtime"){if(n+1>=e.length)return i(o);let l=e[++n],u="exact",c=l;if(l.startsWith("+")?(u="more",c=l.slice(1)):l.startsWith("-")&&(u="less",c=l.slice(1)),!/^\d+$/.test(c))return s(o,l);let p=Number(c);if(!Number.isSafeInteger(p))return s(o,l);r.push({type:"expr",expr:{type:"mtime",days:p,comparison:u}})}else if(o==="-newer"){if(n+1>=e.length)return i(o);let l=e[++n];r.push({type:"expr",expr:{type:"newer",refPath:l}})}else if(o==="-size"){if(n+1>=e.length)return i(o);let l=e[++n],u="exact",c=l;l.startsWith("+")?(u="more",c=l.slice(1)):l.startsWith("-")&&(u="less",c=l.slice(1));let p=c.match(/^(\d+)([ckMGb])?$/);if(!p)return s(o,l);let h=Number(p[1]);if(!Number.isSafeInteger(h))return s(o,l);let f=p[2]||"b",d=f==="G"?1024**3:f==="M"?1024**2:f==="k"?1024:f==="b"?512:1;if(!Number.isSafeInteger(h*d))return s(o,l);r.push({type:"expr",expr:{type:"size",value:h,unit:f,comparison:u}})}else if(o==="-perm"){if(n+1>=e.length)return i(o);let l=e[++n],u="exact",c=l;if(l.startsWith("-")?(u="all",c=l.slice(1)):l.startsWith("/")&&(u="any",c=l.slice(1)),!/^[0-7]{1,4}$/.test(c))return s(o,l);let p=Number.parseInt(c,8);r.push({type:"expr",expr:{type:"perm",mode:p,matchType:u}})}else if(o==="-prune")r.push({type:"expr",expr:{type:"prune"}});else if(o==="-not"||o==="!")r.push({type:"not"});else if(o==="-o"||o==="-or")r.push({type:"op",op:"or"});else if(o==="-a"||o==="-and")r.push({type:"op",op:"and"});else if(o==="-maxdepth"||o==="-mindepth"){if(n+1>=e.length)return i(o);n++}else if(o!=="-depth")if(o==="-exec"){let l=[];for(n++;n=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n"};if(l.length===0)return i("-exec");let u=e[n]==="+";if(u&&(l.at(-1)!=="{}"||l.filter(c=>c==="{}").length!==1))return s("-exec","+");r.push({type:"expr",expr:{type:"action",action:{type:"exec",command:l,batchMode:u}}})}else if(o==="-print")r.push({type:"expr",expr:{type:"action",action:{type:"print"}}});else if(o==="-print0")r.push({type:"expr",expr:{type:"action",action:{type:"print0"}}});else if(o==="-printf"){if(n+1>=e.length)return i(o);let l=e[++n];r.push({type:"expr",expr:{type:"action",action:{type:"printf",format:l}}})}else if(o==="-delete")r.push({type:"expr",expr:{type:"action",action:{type:"delete"}}});else return o.startsWith("-")?{expr:null,pathIndex:n,error:`find: unknown predicate '${o}' `}:{expr:null,pathIndex:n,error:`find: paths must precede expression: \`${o}' `};n++}if(r.length===0)return{expr:null,pathIndex:n};let a=$5(r);return a.error?{expr:null,pathIndex:n,error:a.error}:{expr:a.expr,pathIndex:n}}function $5(e){let t=0,r;function n(){let l=i();if(!l)return null;for(;t=e.length)return null;let l=e[t];if(l.type==="lparen"){t++;let u=n();return!u||t>=e.length||e[t].type!=="rparen"?(r="find: missing closing `)'\n",null):(t++,u)}return l.type==="expr"?(t++,l.expr):(l.type,null)}let o=n();return!r&&t{}),H6={};re(H6,{findCommand:()=>V6,flagsForFuzzing:()=>Z6});function T5(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function I5(e,t,r){e({category:"find",name:"summary",durationMs:r,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:r-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}function xa(e){return e?e.type==="action"?[e.action]:e.type==="not"?xa(e.expr):e.type==="and"||e.type==="or"?[...xa(e.left),...xa(e.right)]:[]:[]}function R5(e,t){let r=$m(e),n="",i=0;for(;i=r.length){n+="%";break}let l=r[i],u;switch(l){case"f":u=t.name,i++;break;case"h":{let c=t.path.lastIndexOf("/");u=c>0?t.path.slice(0,c):".",i++;break}case"p":u=t.path,i++;break;case"P":{let c=t.startingPoint;u=t.path===c?"":t.path.startsWith(`${c}/`)?t.path.slice(c.length+1):c==="."&&t.path.startsWith("./")?t.path.slice(2):t.path,i++;break}case"s":u=String(t.size),i++;break;case"d":u=String(t.depth),i++;break;case"m":u=(t.mode&511).toString(8),i++;break;case"M":u=du(t.mode,t.isDirectory),i++;break;case"t":u=P5(new Date(t.mtime)),i++;break;case"T":if(i+1{se(),Bs(),_r(),ji(),H(),Bg(),le(),wt(),k5(),O5(),El=500,rf={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:"-name PATTERN file name matches shell pattern PATTERN.-iname PATTERN like -name but case insensitive.-path PATTERN file path matches shell pattern PATTERN.-ipath PATTERN like -path but case insensitive.-regex PATTERN file path matches regular expression PATTERN.-iregex PATTERN like -regex but case insensitive.-type TYPE file is of type: f (regular file), d (directory).-empty file is empty or directory is empty.-mtime N file's data was modified N*24 hours ago.-newer FILE file was modified more recently than FILE.-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks).-perm MODE file's permission bits are exactly MODE (octal).-perm -MODE all permission bits MODE are set.-perm /MODE any permission bits MODE are set.-maxdepth LEVELS descend at most LEVELS directories.-mindepth LEVELS do not apply tests at levels less than LEVELS.-depth process directory contents before directory itself.-prune do not descend into this directory.-not, ! negate the following expression.-a, -and logical AND (default).-o, -or logical OR.-exec CMD {} ; execute CMD on each file ({} is replaced by filename).-exec CMD {} + execute CMD with multiple files at once.-print print the full file name (default action).-print0 print the full file name followed by a null character.-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t.-delete delete found files/directories. --help display this help and exit".split(".")},V6={name:"find",async execute(e,t){if(he(e))return ce(rf);let r=[],n=null,i=null,s=!1,a=e.length;for(let _=0;_0;u.some(_=>_.type==="delete")&&(s=!0);let p=[],h=0,f=t.executionScope?new Tn(t.executionScope,"find"):void 0,d=[],m=[],g=0,v=new Fr({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:"find"}),y=_=>{if(f)f.append("stdout",_);else{let R=q(_);if(R>t.limits.maxOutputSize-g)throw new C(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");_&&d.push(_),g+=R}},x=_=>{if(f)f.append("stderr",_);else{let R=q(_);if(R>t.limits.maxOutputSize-g)throw new C(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,"output_size");_&&m.push(_),g+=R}},b=A5(o),w=new Map;for(let _ of b){let R=t.fs.resolvePath(t.cwd,_);try{let B=await t.fs.stat(R);w.set(_,B.mtime?.getTime()??Date.now())}catch{}}let E=u.some(_=>{if(_.type!=="printf")return!1;let R=_.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(R)}),A=fa(o)||E,O=da(o),N=ga(o),D=ma(o),$=typeof t.fs.readdirWithFileTypes=="function";for(let _ of r){let R=function(V){if(!(i===null||V.depth>=i))return[];let ae=!0,te=[];if(o!==null){let be=Date.now(),fe;if(D)fe=Ei(o,V.name,V.relativePath,V.isFile,V.isDirectory);else{let Ne={name:V.name,relativePath:V.relativePath,isFile:V.isFile,isDirectory:V.isDirectory,isEmpty:V.isEmpty,mtime:V.stat?.mtime?.getTime()??Date.now(),size:V.stat?.size??0,mode:V.stat?.mode??420,newerRefTimes:w};fe=Rr(o,Ne)}ae=fe.matches,te=fe.actions??[],j.evalCalls++,j.evalTime+=Date.now()-be}if(!c&&ae&&(te=[{type:"print"}]),te.length===0)return[];let ie={path:V.relativePath,name:V.name,size:V.stat?.size??0,mtime:V.stat?.mtime?.getTime()??Date.now(),mode:V.stat?.mode??420,isDirectory:V.isDirectory,depth:V.depth,startingPoint:_};v.checkpoint(te.length);let Se=[];for(let be of te)Se.push({action:be,path:V.relativePath,printfData:ie});return Se};_.length>1&&_.endsWith("/")&&(_=_.slice(0,-1));let B=t.fs.resolvePath(t.cwd,_);try{await t.fs.stat(B)}catch{x(`find: ${_}: No such file or directory `),h=1;continue}let j=T5(),P=Date.now();async function F(V){let{path:ae,depth:te,typeInfo:ie}=V;if(v.visit(te),j.nodeCount++,te>(n??t.limits.maxTraversalDepth))return null;let Se,be,fe;if(ie&&!A)Se=ie.isFile,be=ie.isDirectory;else{try{let Mt=Date.now();fe=await t.fs.lstat(ae),j.statCalls++,j.statTime+=Date.now()-Mt}catch{return null}if(!fe)return null;Se=fe.isFile,be=fe.isDirectory}let Ne;Ne=ae===B?_.split("/").pop()||_:ae.split("/").pop()||"";let Ge=ae===B?_:_==="."?`./${ae.slice(B==="/"?B.length:B.length+1)}`:_+ae.slice(B.length),Y=[],oe=null,Fe=null,Ee=!1;be&&N&&!s&&(Ee=C5(o,{name:Ne,relativePath:Ge,isFile:Se,isDirectory:be}).shouldPrune,Ee&&j.earlyPrunes++);let Re=!(te>=(n??t.limits.maxTraversalDepth))&&!Ee;if(be&&(Re||O)&&!Ee){let Mt=Date.now();if($&&t.fs.readdirWithFileTypes){oe=await t.fs.readdirWithFileTypes(ae),v.checkpoint(),v.discover(oe.length),Fe=[];for(let mt of oe)Fe.push(mt.name);if(j.readdirCalls++,j.readdirTime+=Date.now()-Mt,Re)for(let mt=0;mtF(Y.item)));j.batchCount++,j.batchTime+=Date.now()-be;for(let Y=0;Y=0){let Re=ie.get(Fe.parentIndex)||[];Re.push(Ee),ie.set(Fe.parentIndex,Re)}ae.push({node:oe,parentIndex:Fe.parentIndex,childIndices:[]});for(let Re=0;Re=0&&be0){let be=[{index:0,visited:!1}];for(;be.length>0;){v.checkpoint();let fe=be.pop();if(!fe)break;let Ne=ae[fe.index];if(Ne){if(fe.visited){for(let Ge of R(Ne.node))V.effects.push(Ge);continue}be.push({index:fe.index,visited:!0});for(let Ge=Ne.childIndices.length-1;Ge>=0;Ge--)be.push({index:Ne.childIndices[Ge],visited:!1})}}}}else{let ae=new Map,te=0,ie=[{item:{path:B,depth:0,resultIndex:0},orderIndex:te++}],Se=new Map,be=0;for(;be{let Re=await F(Fe);return Re?{node:Re,orderIndex:Ee}:null}));j.batchCount++,j.batchTime+=Date.now()-Ne;for(let Fe of oe){if(!Fe)continue;let{node:Ee,orderIndex:Re}=Fe,Ke=R(Ee);if(Ke.length>0&&ae.set(Re,Ke),Ee.children.length>0){let ue=[];for(let Mt of Ee.children){let mt=te++;ue.push(mt),ie.push({item:Mt,orderIndex:mt})}Se.set(Re,ue)}}}let fe=[0];for(;fe.length>0;){v.checkpoint();let Ne=fe.pop();if(Ne===void 0)break;let Ge=ae.get(Ne);if(Ge)for(let oe of Ge)V.effects.push(oe);let Y=Se.get(Ne);if(Y)for(let oe=Y.length-1;oe>=0;oe--)fe.push(Y[oe])}}return V}let z=await G();for(let V of z.effects)p.push(V);if(t.trace){let V=Date.now()-P;I5(t.trace,j,V),t.trace({category:"find",name:"searchPath",durationMs:V,details:{path:_,resultsFound:z.effects.length}})}}let L=new Map;for(let _ of p){let{action:R,path:B}=_;switch(R.type){case"print":y(`${B} `);break;case"print0":y(`${B}\0`);break;case"printf":y(R5(R.format,_.printfData));break;case"delete":{let j=t.fs.resolvePath(t.cwd,B);try{await t.fs.rm(j,{recursive:!1})}catch(P){x(`find: cannot delete '${B}': ${P instanceof Error?P.message:String(P)} `),h=1}break}case"exec":{if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context `,exitCode:1};if(R.batchMode){let F=L.get(R)??[];F.push(B),L.set(R,F);break}let j=R.command.map(F=>F==="{}"?B:F),P=await t.exec(ni([j[0]]),{cwd:t.cwd,signal:t.signal,args:j.slice(1)});f?f.appendResult(P):(y(P.stdout),x(P.stderr)),P.exitCode!==0&&(h=P.exitCode);break}}}for(let[_,R]of L){if(_.type!=="exec"||!t.exec||R.length===0)continue;let B=[];for(let P of _.command)P==="{}"?B.push(...R):B.push(P);let j=await t.exec(ni([B[0]]),{cwd:t.cwd,signal:t.signal,args:B.slice(1)});f?f.appendResult(j):(y(j.stdout),x(j.stderr)),j.exitCode!==0&&(h=j.exitCode)}return f?.build(h)??{stdout:d.join(""),stderr:m.join(""),exitCode:h}}},Z6={name:"find",flags:[{flag:"-name",type:"value",valueHint:"pattern"},{flag:"-iname",type:"value",valueHint:"pattern"},{flag:"-type",type:"value",valueHint:"string"},{flag:"-maxdepth",type:"value",valueHint:"number"},{flag:"-mindepth",type:"value",valueHint:"number"},{flag:"-empty",type:"boolean"},{flag:"-print",type:"boolean"},{flag:"-print0",type:"boolean"}],needsFiles:!0}}),Q6={};re(Q6,{basenameCommand:()=>K6,flagsForFuzzing:()=>X6});var nf,K6,X6,M5=M(()=>{le(),nf={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX] basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},K6={name:"basename",async execute(e,t){if(he(e))return ce(nf);let r=!1,n="",i=[];for(let a=0;a=2&&(n=i.pop()??"");let s=[];for(let a of i){let o=a.replace(/\/+$/,""),l=o.split("/").pop()||o;n&&l.endsWith(n)&&(l=l.slice(0,-n.length)),s.push(l)}return{stdout:`${s.join(` `)} `,stderr:"",exitCode:0}}},X6={name:"basename",flags:[{flag:"-a",type:"boolean"},{flag:"-s",type:"value",valueHint:"string"}],needsArgs:!0}}),Y6={};re(Y6,{dirnameCommand:()=>J6,flagsForFuzzing:()=>ey});var sf,J6,ey,F5=M(()=>{le(),sf={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},J6={name:"dirname",async execute(e,t){if(he(e))return ce(sf);let r=e.filter(i=>!i.startsWith("-"));if(r.length===0)return{stdout:"",stderr:`dirname: missing operand `,exitCode:1};let n=[];for(let i of r){let s=i.replace(/\/+$/,""),a=s.lastIndexOf("/");a===-1?n.push("."):a===0?n.push("/"):n.push(s.slice(0,a))}return{stdout:`${n.join(` `)} `,stderr:"",exitCode:0}}},ey={name:"dirname",flags:[],needsArgs:!0}}),ty={};re(ty,{flagsForFuzzing:()=>iy,treeCommand:()=>ny});async function _5(e,t,r,n,i){let s={output:"",stderr:"",dirCount:0,fileCount:0},a=e.fs.resolvePath(e.cwd,t);try{if(!(await e.fs.stat(a)).isDirectory)return s.output=`${t} `,s.fileCount=1,s}catch{return s.stderr=`tree: ${t}: No such file or directory `,s}if(s.output=`${t} `,r.maxDepth!==null&&i>=r.maxDepth)return s;try{let o=[];if(e.fs.readdirWithFileTypes)o=(await e.fs.readdirWithFileTypes(a)).map(u=>({name:u.name,isDirectory:u.isDirectory}));else{let u=await e.fs.readdir(a);for(let c=0;c{let d=a==="/"?`/${f}`:`${a}/${f}`;try{return{name:f,isDirectory:(await e.fs.stat(d)).isDirectory}}catch{return null}}));o.push(...h.filter(f=>f!==null))}}let l=o.filter(u=>!(!r.showHidden&&u.name.startsWith(".")||r.directoriesOnly&&!u.isDirectory));l.sort((u,c)=>u.name.localeCompare(c.name));for(let u=0;u=r.maxDepth)return s;try{let a=[];if(e.fs.readdirWithFileTypes)a=(await e.fs.readdirWithFileTypes(t)).map(l=>({name:l.name,isDirectory:l.isDirectory}));else{let l=await e.fs.readdir(t);for(let u=0;u{let f=t==="/"?`/${h}`:`${t}/${h}`;try{return{name:h,isDirectory:(await e.fs.stat(f)).isDirectory}}catch{return null}}));a.push(...p.filter(h=>h!==null))}}let o=a.filter(l=>!(!r.showHidden&&l.name.startsWith(".")||r.directoriesOnly&&!l.isDirectory));o.sort((l,u)=>l.name.localeCompare(u.name));for(let l=0;l{Ct(),po(),le(),af={name:"tree",summary:"list contents of directories in a tree-like format",usage:"tree [OPTION]... [DIRECTORY]...",options:["-a include hidden files","-d list directories only","-L LEVEL limit depth of directory tree","-f print full path prefix for each file"," --help display this help and exit"]},of={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},ny={name:"tree",async execute(e,t){if(he(e))return ce(af);let r=At("tree",e,of);if(!r.ok)return r.error;let n={showHidden:r.result.flags.showHidden,directoriesOnly:r.result.flags.directoriesOnly,maxDepth:r.result.flags.maxDepth??null,fullPath:r.result.flags.fullPath},i=r.result.positional;i.length===0&&i.push(".");let s="",a="",o=0,l=0;for(let u of i){let c=await _5(t,u,n,"",0);s+=c.output,a+=c.stderr,o+=c.dirCount,l+=c.fileCount}return s+=` ${o} director${o===1?"y":"ies"}`,n.directoriesOnly||(s+=`, ${l} file${l===1?"":"s"}`),s+=` `,{stdout:s,stderr:a,exitCode:+!!a}}},iy={name:"tree",flags:[{flag:"-a",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-L",type:"value",valueHint:"number"}],needsFiles:!0}}),sy={};re(sy,{duCommand:()=>ay,flagsForFuzzing:()=>oy});async function B5(e,t,r,n,i){let s={output:"",totalSize:0,stderr:""},a=new Map;return await Ms({fs:e.fs,root:t,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:"du",symlinks:"never",includeLeave:!0},o=>{let l=o.path.slice(t.length).replace(/^\//,""),u=l?r==="."?l:`${r}/${l}`:r,c=o.path==="/"?"/":o.path.slice(0,o.path.lastIndexOf("/"))||"/";if(o.phase==="enter"){if(o.stat.isDirectory){a.set(o.path,0);return}a.set(c,(a.get(c)??0)+o.stat.size),(n.allFiles||o.depth===i)&&!n.summarize&&(s.output+=`${Au(o.stat.size,n.humanReadable)} ${u} `),o.depth===i&&(s.totalSize=o.stat.size);return}let p=a.get(o.path)??0;o.depth>i?a.set(c,(a.get(c)??0)+p):s.totalSize=p;let h=o.depth-i;(n.summarize&&h===0||!n.summarize&&(n.maxDepth===null||h<=n.maxDepth))&&(s.output+=`${Au(p,n.humanReadable)} ${u} `)}),s}function Au(e,t){return t?e<1024?`${e}`:e<1048576?`${(e/1024).toFixed(1)}K`:e<1073741824?`${(e/1048576).toFixed(1)}M`:`${(e/1073741824).toFixed(1)}G`:String(Math.ceil(e/1024)||1)}var lf,uf,ay,oy,U5=M(()=>{_r(),H(),Ct(),le(),lf={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},uf={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},ay={name:"du",async execute(e,t){if(he(e))return ce(lf);let r=At("du",e,uf);if(!r.ok)return r.error;let n={allFiles:r.result.flags.allFiles,humanReadable:r.result.flags.humanReadable,summarize:r.result.flags.summarize,grandTotal:r.result.flags.grandTotal,maxDepth:r.result.flags.maxDepth??null},i=r.result.positional;i.length===0&&i.push(".");let s="",a="",o=0;for(let l of i){let u=t.fs.resolvePath(t.cwd,l);try{await t.fs.stat(u);let c=await B5(t,u,l,n,0);s+=c.output,o+=c.totalSize,a+=c.stderr}catch(c){if(c instanceof C||c instanceof bt)throw c;a+=`du: cannot access '${l}': No such file or directory `}}return n.grandTotal&&i.length>0&&(s+=`${Au(o,n.humanReadable)} total `),{stdout:s,stderr:a,exitCode:+!!a}}},oy={name:"du",flags:[{flag:"-a",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"--max-depth",type:"value",valueHint:"number"}],needsFiles:!0}}),Cu={};re(Cu,{envCommand:()=>ly,flagsForFuzzing:()=>cy,printenvCommand:()=>uy,printenvFlagsForFuzzing:()=>py});var cf,ly,pf,uy,cy,py,hf=M(()=>{se(),Rn(),le(),cf={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},ly={name:"env",async execute(e,t){if(he(e))return ce(cf);let r=!1,n=[],i=new Map,s=-1;for(let l=0;l0?` `:""),stderr:"",exitCode:0}}if(!t.exec)return{stdout:"",stderr:`env: command execution not supported in this context `,exitCode:1};let o=e.slice(s);return t.exec("command",{cwd:t.cwd,env:Kr(a),replaceEnv:!0,stdin:t.stdin,stdinKind:"bytes",signal:t.signal,args:o})}},pf={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},uy={name:"printenv",async execute(e,t){if(he(e))return ce(pf);let r=e.filter(s=>!s.startsWith("-"));if(r.length===0){let s=[];for(let[a,o]of t.env)s.push(`${a}=${o}`);return{stdout:s.join(` `)+(s.length>0?` `:""),stderr:"",exitCode:0}}let n=[],i=0;for(let s of r){let a=t.env.get(s);a===void 0?i=1:n.push(a)}return{stdout:n.join(` `)+(n.length>0?` `:""),stderr:"",exitCode:i}}},cy={name:"env",flags:[{flag:"-i",type:"boolean"},{flag:"-u",type:"value",valueHint:"string"}]},py={name:"printenv",flags:[]}}),ku={};re(ku,{aliasCommand:()=>hy,flagsForFuzzing:()=>dy,unaliasCommand:()=>fy,unaliasFlagsForFuzzing:()=>my});var ff,Ln,hy,fy,dy,my,df=M(()=>{le(),ff={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},Ln="BASH_ALIAS_",hy={name:"alias",async execute(e,t){if(he(e))return ce(ff);if(e.length===0){let n="";for(let[i,s]of t.env)if(i.startsWith(Ln)){let a=i.slice(Ln.length);n+=`alias ${a}='${s}' `}return{stdout:n,stderr:"",exitCode:0}}let r=e[0]==="--"?e.slice(1):e;for(let n of r){let i=n.indexOf("=");if(i===-1){let s=Ln+n;return t.env.get(s)?{stdout:`alias ${n}='${t.env.get(s)}' `,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${n}: not found `,exitCode:1}}{let s=n.slice(0,i),a=n.slice(i+1);(a.startsWith("'")&&a.endsWith("'")||a.startsWith('"')&&a.endsWith('"'))&&(a=a.slice(1,-1)),t.env.set(Ln+s,a)}}return{stdout:"",stderr:"",exitCode:0}}},fy={name:"unalias",async execute(e,t){if(he(e))return ce({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(e.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...] `,exitCode:1};if(e[0]==="-a"){for(let s of t.env.keys())s.startsWith(Ln)&&t.env.delete(s);return{stdout:"",stderr:"",exitCode:0}}let r=e[0]==="--"?e.slice(1):e,n=!1,i="";for(let s of r){let a=Ln+s;t.env.get(a)?t.env.delete(a):(i+=`unalias: ${s}: not found `,n=!0)}return{stdout:"",stderr:i,exitCode:+!!n}}},dy={name:"alias",flags:[]},my={name:"unalias",flags:[{flag:"-a",type:"boolean"}]}}),gy={};re(gy,{flagsForFuzzing:()=>xy,historyCommand:()=>yy});var mf,Sl,yy,xy,W5=M(()=>{le(),mf={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},Sl="BASH_HISTORY",yy={name:"history",async execute(e,t){if(he(e))return ce(mf);let r=t.env.get(Sl)||"[]",n;try{n=JSON.parse(r)}catch{n=[]}if(e[0]==="-c")return t.env.set(Sl,"[]"),{stdout:"",stderr:"",exitCode:0};let i=n.length;e[0]&&/^\d+$/.test(e[0])&&(i=Math.min(parseInt(e[0],10),n.length));let s=n.length-i,a="";for(let o=s;owy,xargsCommand:()=>by});function gf(e,t,r){if(t.length===0)throw Error("xargs: delimiter must not be empty");let n=[],i=0;for(;i<=e.length;){let s=e.indexOf(t,i),a=e.slice(i,s===-1?e.length:s);if(a.length>0){if(n.length>=r)throw new C(`xargs: array element limit exceeded (${r})`,"array_elements");n.push(a)}if(s===-1)break;i=s+t.length}return n}function j5(e,t){let r=[],n=-1;for(let i=0;i<=e.length;i++){let s=i===e.length||/\s/.test(e[i]);if(!s&&n===-1&&(n=i),s&&n!==-1){if(r.length>=t)throw new C(`xargs: array element limit exceeded (${t})`,"array_elements");r.push(e.slice(n,i)),n=-1}}return r}var yf,by,wy,q5=M(()=>{se(),Bs(),ji(),H(),le(),wt(),yf={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},by={name:"xargs",async execute(e,t){if(he(e))return ce(yf);let r=null,n=null,i=null,s=null,a=!1,o=!1,l=0;for(let $=0;$1){for(let _ of L.slice(1))if(!"0tr".includes(_))return ve("xargs",`-${_}`);L.includes("0")&&(a=!0),L.includes("t")&&(o=!0),L.includes("r"),l=$+1}else if(!L.startsWith("-")){l=$;break}}}let u=e.slice(l);u.length===0&&u.push("echo");let c=ke(t.stdin),p=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),h=t.limits.maxArrayElements,f=t.limits.maxLoopIterations,d=t.limits.maxOutputSize;if(q(c)>p)throw new C(`xargs: input size limit exceeded (${p} bytes)`,"string_length");if(s!==null&&s>h)throw new C(`xargs: array element limit exceeded (${h})`,"array_elements");let m;if(a)m=gf(c,"\0",h);else if(n!==null){let $=c.replace(/\n$/,"");try{m=gf($,n,h)}catch(L){if(L instanceof C)throw L;return{stdout:"",stderr:`xargs: delimiter must not be empty `,exitCode:1}}}else m=j5(c,h);if(m.length===0)return{stdout:"",stderr:"",exitCode:0};let g=[],v=[],y=0,x=0,b=0,w=t.executionScope?new Tn(t.executionScope,"xargs"):void 0,E=$=>{if(w){w.appendResult($);return}let L=q($.stdout)+q($.stderr);if(L>d-x)throw new C(`xargs: output size limit exceeded (${d} bytes)`,"output_size");$.stdout&&g.push($.stdout),$.stderr&&v.push($.stderr),x+=L},A=$=>{if(w){w.append("stderr",$);return}let L=q($);if(L>d-x)throw new C(`xargs: output size limit exceeded (${d} bytes)`,"output_size");$&&v.push($),x+=L},O=$=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test($)?`"${$.replace(/([\\"`$])/g,"\\$1")}"`:$,N=async $=>{if(++b>f)throw new C(`xargs: iteration limit exceeded (${f})`,"iterations");if($.length>h)throw new C(`xargs: array element limit exceeded (${h})`,"array_elements");for(let L of $)if(q(L)>p)throw new C(`xargs: string length limit exceeded (${p} bytes)`,"string_length");if(o){let L=$.map(O).join(" ");A(`${L} `)}return t.exec?t.exec(ni([$[0]]),{cwd:t.cwd,signal:t.signal,args:$.slice(1)}):{stdout:`${$.map(O).join(" ")} `,stderr:"",exitCode:0}},D=async $=>{if(s!==null&&s>1)for(let L=0;L<$.length;L+=s){let _=$.slice(L,L+s),R=await Promise.all(_.map(N));for(let B of R)E(B),B.exitCode!==0&&(y=B.exitCode)}else for(let L of $){let _=await N(L);E(_),_.exitCode!==0&&(y=_.exitCode)}};if(r!==null){if(m.length>f)throw new C(`xargs: iteration limit exceeded (${f})`,"iterations");if(r.length===0)return{stdout:"",stderr:`xargs: replacement string must not be empty `,exitCode:1};if(u.length>0&&m.length>Math.floor(h/u.length))throw new C(`xargs: array element limit exceeded (${h})`,"array_elements");let $=(L,_)=>{let R=0,B=0;for(;B=L.indexOf(r,B),B!==-1;)R++,B+=r.length;if(q(L)+R*(q(_)-q(r))>p)throw new C(`xargs: string length limit exceeded (${p} bytes)`,"string_length");return L.replaceAll(r,_)};await D(m.map(L=>u.map(_=>$(_,L))))}else if(i!==null){let $=[],L=Math.ceil(m.length/i);if(L>Math.min(h,f))throw new C(`xargs: iteration limit exceeded (${f})`,"iterations");if(m.length+L*u.length>h)throw new C(`xargs: array element limit exceeded (${h})`,"array_elements");for(let _=0;_Sy,falseFlagsForFuzzing:()=>Cy,flagsForFuzzing:()=>Ay,trueCommand:()=>Ey});var Ey,Sy,Ay,Cy,xf=M(()=>{Ey={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},Sy={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}},Ay={name:"true",flags:[]},Cy={name:"false",flags:[]}}),ky={};re(ky,{clearCommand:()=>Ny,flagsForFuzzing:()=>$y});var vf,Ny,$y,G5=M(()=>{le(),vf={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},Ny={name:"clear",async execute(e,t){return he(e)?ce(vf):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}},$y={name:"clear",flags:[]}}),$u={};re($u,{bashCommand:()=>Oy,flagsForFuzzing:()=>Iy,shCommand:()=>Ty,shFlagsForFuzzing:()=>Ry});async function fi(e,t,r,n){if(!n.exec)return{stdout:"",stderr:`bash: internal error: exec function not available `,exitCode:1};let i=za(n.exportedEnv||{},{0:t,"#":String(r.length),"@":r.join(" "),"*":r.join(" ")});r.forEach((o,l)=>{i[String(l+1)]=o});let s=e;if(s.startsWith("#!")){let o=s.indexOf(` `);o!==-1&&(s=s.slice(o+1))}let a=n.execWithInheritedStdin;return a?await a(s,{env:i,cwd:n.cwd,signal:n.signal}):await n.exec(s,{env:i,cwd:n.cwd,stdin:n.stdin,stdinKind:"bytes",signal:n.signal})}var Al,Oy,Ty,Iy,Ry,bf=M(()=>{se(),Rn(),le(),Al={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},Oy={name:"bash",async execute(e,t){if(he(e))return ce(Al);if(e[0]==="-c"&&e.length>=2){let i=e[1];return fi(i,e[2]||"bash",e.slice(3),t)}if(e.length===0){let i=ke(t.stdin);return i.trim()?fi(i,"bash",[],t):{stdout:"",stderr:"",exitCode:0}}let r=e[0],n=e.slice(1);try{let i=t.fs.resolvePath(t.cwd,r);return fi(await t.fs.readFile(i),r,n,t)}catch{return{stdout:"",stderr:`bash: ${r}: No such file or directory `,exitCode:127}}}},Ty={name:"sh",async execute(e,t){if(he(e))return ce({...Al,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(e[0]==="-c"&&e.length>=2){let i=e[1];return fi(i,e[2]||"sh",e.slice(3),t)}if(e.length===0){let i=ke(t.stdin);return i.trim()?fi(i,"sh",[],t):{stdout:"",stderr:"",exitCode:0}}let r=e[0],n=e.slice(1);try{let i=t.fs.resolvePath(t.cwd,r);return fi(await t.fs.readFile(i),r,n,t)}catch{return{stdout:"",stderr:`sh: ${r}: No such file or directory `,exitCode:127}}}},Iy={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},Ry={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function is(e,t,r=1){let n=e.limits.maxArrayElements;if(r<0||t>n-r)throw new C(`query result element limit exceeded (${n})`,"array_elements")}function H5(e,t,r,n,i,s,a,o,l,u){switch(t){case"sort":return Array.isArray(e)?[[...e].sort(a)]:[null];case"sort_by":return!Array.isArray(e)||r.length===0?[null]:[[...e].sort((c,p)=>{let h=i(c,r[0],n)[0],f=i(p,r[0],n)[0];return a(h,f)})];case"bsearch":if(!Array.isArray(e))throw Error(`${e===null?"null":typeof e=="object"?"object":typeof e} (${JSON.stringify(e)}) cannot be searched from`);return r.length===0?[null]:i(e,r[0],n).map(c=>{let p=0,h=e.length;for(;p>>1;a(e[f],c)<0?p=f+1:h=f}return pa(h.key,f.key)),[p.map(h=>h.item)]}case"group_by":{if(!Array.isArray(e)||r.length===0)return[null];let c=new Map;for(let p of e){let h=JSON.stringify(i(p,r[0],n)[0]);c.has(h)||c.set(h,[]),c.get(h)?.push(p)}return[[...c.values()]]}case"max":return Array.isArray(e)&&e.length>0?[e.reduce((c,p)=>a(c,p)>0?c:p)]:[null];case"max_by":return!Array.isArray(e)||e.length===0||r.length===0?[null]:[e.reduce((c,p)=>{let h=i(c,r[0],n)[0],f=i(p,r[0],n)[0];return a(h,f)>0?c:p})];case"min":return Array.isArray(e)&&e.length>0?[e.reduce((c,p)=>a(c,p)<0?c:p)]:[null];case"min_by":return!Array.isArray(e)||e.length===0||r.length===0?[null]:[e.reduce((c,p)=>{let h=i(c,r[0],n)[0],f=i(p,r[0],n)[0];return a(h,f)<0?c:p})];case"add":{let c=p=>{let h=p.filter(f=>f!==null);return h.length===0?null:h.every(f=>typeof f=="number")?h.reduce((f,d)=>f+d,0):h.every(f=>typeof f=="string")?h.join(""):h.every(f=>Array.isArray(f))?h.flat():h.every(f=>f&&typeof f=="object"&&!Array.isArray(f))?za(...h):null};return r.length>=1?[c(i(e,r[0],n))]:Array.isArray(e)?[c(e)]:[null]}case"any":if(r.length>=2){try{let c=s(e,r[0],n);for(let p of c)if(i(p,r[1],n).some(o))return[!0]}catch(c){if(c instanceof u)throw c}return[!1]}return r.length===1?Array.isArray(e)?[e.some(c=>o(i(c,r[0],n)[0]))]:[!1]:Array.isArray(e)?[e.some(o)]:[!1];case"all":if(r.length>=2){try{let c=s(e,r[0],n);for(let p of c)if(!i(p,r[1],n).some(o))return[!1]}catch(c){if(c instanceof u)throw c}return[!0]}return r.length===1?Array.isArray(e)?[e.every(c=>o(i(c,r[0],n)[0]))]:[!0]:Array.isArray(e)?[e.every(o)]:[!0];case"select":return r.length===0||i(e,r[0],n).some(o)?[e]:[];case"map":{if(r.length===0||!Array.isArray(e))return[null];is(n,0,e.length);let c=[];for(let p of e){let h=i(p,r[0],n);is(n,c.length,h.length);for(let f of h)c.push(f)}return[c]}case"map_values":if(r.length===0)return[null];if(Array.isArray(e)){is(n,0,e.length);let c=[];for(let p of e){let h=i(p,r[0],n);is(n,c.length,h.length);for(let f of h)c.push(f)}return[c]}if(e&&typeof e=="object"){let c=Object.create(null),p=Object.keys(e);is(n,0,p.length);for(let h of p){if(!et(h))continue;let f=e[h],d=i(f,r[0],n);d.length>0&&Je(c,h,d[0])}return[c]}return[null];case"has":{if(r.length===0)return[!1];let c=i(e,r[0],n)[0];return Array.isArray(e)&&typeof c=="number"?[c>=0&&c=0&&e{Rn(),H(),nn()});function Z5(e,t,r,n,i,s,a,o){switch(t){case"first":if(r.length>0)try{let l=s(e,r[0],n);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof o)throw l;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case"last":if(r.length>0){let l=i(e,r[0],n);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case"nth":{if(r.length<1)return[null];let l=i(e,r[0],n);if(r.length>1){for(let c of l)if(c<0)throw Error("nth doesn't support negative indices");let u;try{u=s(e,r[1],n)}catch(c){if(c instanceof o)throw c;u=[]}return l.flatMap(c=>{let p=c;return p{let c=u;if(c<0)throw Error("nth doesn't support negative indices");return c{if(d.length>=l)throw new o(`query result element limit exceeded (${l})`,"array_elements");d.push(m)},c=i(e,r[0],n);if(r.length===1){let d=[];for(let m of c){let g=m;for(let v=0;v0)for(let b=v;by;b+=x)u(f,b)}return f}case"limit":return r.length<2?[]:i(e,r[0],n).flatMap(l=>{let u=l;if(u<0)throw Error("limit doesn't support negative count");if(u===0)return[];let c;try{c=s(e,r[1],n)}catch(p){if(p instanceof o)throw p;c=[]}return c.slice(0,u)});case"isempty":if(r.length<1)return[!0];try{return[s(e,r[0],n).length===0]}catch(l){if(l instanceof o)throw l;return[!0]}case"isvalid":if(r.length<1)return[!0];try{return[i(e,r[0],n).length>0]}catch(l){if(l instanceof o)throw l;return[!1]}case"skip":return r.length<2?[]:i(e,r[0],n).flatMap(l=>{let u=l;if(u<0)throw Error("skip doesn't support negative count");return i(e,r[1],n).slice(u)});case"until":{if(r.length<2)return[e];let l=e,u=n.limits.maxIterations;for(let c=0;c=c)throw new o(`jq while: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(r.length===0)return[e];let l=[],u=e,c=n.limits.maxIterations;for(let p=0;p=c)throw new o(`jq repeat: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var Q5=M(()=>{});function Cl(e,t){if(!Number.isFinite(e)||Math.abs(e)>864e10)throw Error(`${t} timestamp is outside the supported range`);return new Date(e*1e3)}function wf(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(!t)return null;let[,r,n,i,s,a,o]=t.map(Number),l=Date.UTC(r,n-1,i,s,a,o);if(!Number.isFinite(l))return null;let u=new Date(l);return u.getUTCFullYear()!==r||u.getUTCMonth()!==n-1||u.getUTCDate()!==i||u.getUTCHours()!==s||u.getUTCMinutes()!==a||u.getUTCSeconds()!==o?null:u}function K5(e,t,r,n,i){switch(t){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof e!="number")return[null];let s=Cl(e,"gmtime"),a=s.getUTCFullYear(),o=s.getUTCMonth(),l=s.getUTCDate(),u=s.getUTCHours(),c=s.getUTCMinutes(),p=s.getUTCSeconds(),h=s.getUTCDay(),f=Date.UTC(a,0,1);return[[a,o,l,u,c,p,h,Math.floor((s.getTime()-f)/864e5)]]}case"mktime":{if(!Array.isArray(e))throw Error("mktime requires parsed datetime inputs");let[s,a,o,l=0,u=0,c=0]=e;if(typeof s!="number"||typeof a!="number")throw Error("mktime requires parsed datetime inputs");return[Math.floor(Date.UTC(s,a,o??1,l??0,u??0,c??0)/1e3)]}case"strftime":{if(r.length===0)return[null];let s=i(e,r[0],n)[0];if(typeof s!="string")throw Error("strftime/1 requires a string format");let a;if(typeof e=="number")a=Cl(e,"strftime");else if(Array.isArray(e)){let[c,p,h,f=0,d=0,m=0]=e;if(typeof c!="number"||typeof p!="number")throw Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(c,p,h??1,f??0,d??0,m??0))}else throw Error("strftime/1 requires parsed datetime inputs");let o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],l=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(c,p=2)=>String(c).padStart(p,"0");return[s.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,u(a.getUTCMonth()+1)).replace(/%d/g,u(a.getUTCDate())).replace(/%H/g,u(a.getUTCHours())).replace(/%M/g,u(a.getUTCMinutes())).replace(/%S/g,u(a.getUTCSeconds())).replace(/%A/g,o[a.getUTCDay()]).replace(/%B/g,l[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(r.length===0)return[null];if(typeof e!="string")throw Error("strptime/1 requires a string input");let s=i(e,r[0],n)[0];if(typeof s!="string")throw Error("strptime/1 requires a string format");if(s!==Ou)throw Error(`strptime format is not supported: ${s}`);let a=wf(e);if(a){let o=a.getUTCFullYear(),l=a.getUTCMonth(),u=a.getUTCDate(),c=a.getUTCHours(),p=a.getUTCMinutes(),h=a.getUTCSeconds(),f=a.getUTCDay(),d=Date.UTC(o,0,1);return[[o,l,u,c,p,h,f,Math.floor((a.getTime()-d)/864e5)]]}throw Error(`Cannot parse date: ${e}`)}case"fromdate":{if(typeof e!="string")throw Error("fromdate requires a string input");let s=wf(e);if(!s)throw Error(`date "${e}" does not match format "${Ou}"`);return[Math.floor(s.getTime()/1e3)]}case"todate":if(typeof e!="number")throw Error("todate requires a number input");return[Cl(e,"todate").toISOString().replace(/\.\d{3}Z$/,"Z")];default:return null}}var Ou,X5=M(()=>{Ou="%Y-%m-%dT%H:%M:%SZ"});function Dr(e){return e!==!1&&e!==null}function Cs(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ys(e,t){return typeof e=="number"&&typeof t=="number"?e-t:typeof e=="string"&&typeof t=="string"?e.localeCompare(t):0}function Y5(e,t,r={}){let n=r.maxDepth??2e3,i=Rt(e),s=[{target:i,source:t,depth:0}];for(;s.length>0;){let a=s.pop();if(!a)break;if(a.depth>n)throw new C(`query depth limit exceeded (${n})`,"recursion");for(let o of Object.keys(a.source)){if(r.visit?.(),!et(o))continue;let l=fo(a.target,o)?it(a.target[o]):null,u=it(a.source[o]);if(l&&u){let c=Rt(l);Je(a.target,o,c),s.push({target:c,source:u,depth:a.depth+1})}else Je(a.target,o,a.source[o])}}return i}function ks(e,t=3e3){if(typeof e!="object"||!e)return 0;if(t<=1)return t;let r=(u,c)=>({value:u,keys:Array.isArray(u)?void 0:Object.keys(u),nextChild:0,pathDepth:c,maxChildDepth:0}),n=u=>u.keys===void 0?u.value.length:u.keys.length,i=u=>{if(u.keys){let c=u.keys[u.nextChild++];return u.value[c]}return u.value[u.nextChild++]},s=new WeakMap,a=new WeakMap,o=e,l=[r(o,1)];for(s.set(o,"visiting");l.length>0;){let u=l[l.length-1];if(u.nextChild=t)return t;u.maxChildDepth=Math.max(u.maxChildDepth,g);continue}let d=u.pathDepth+1;if(d>=t)return t;let m=h;s.set(h,"visiting"),l.push(r(m,d));continue}let c=u.maxChildDepth+1;a.set(u.value,c),s.set(u.value,"done"),l.pop();let p=l.at(-1);if(p)p.maxChildDepth=Math.max(p.maxChildDepth,c);else return c}return 0}function Tu(e,t){let r=o=>o===null?0:typeof o=="boolean"?1:typeof o=="number"?2:typeof o=="string"?3:Array.isArray(o)?4:typeof o=="object"?5:6,n=r(e),i=r(t);if(n!==i)return n-i;if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="string"&&typeof t=="string")return e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return!!e-+!!t;if(Array.isArray(e)&&Array.isArray(t)){for(let o=0;oe.some(s=>Iu(s,i)));let r=it(e),n=it(t);return r&&n?Object.keys(n).every(i=>fo(r,i)&&Iu(r[i],n[i])):!1}var xo=M(()=>{H(),nn()});function J5(e){let t=[];for(let r=0;r{if(n===null)return"";if(typeof n=="boolean")return n?"true":"false";if(typeof n=="number")return String(n);let i=String(n);return i.includes(",")||i.includes('"')||i.includes(` `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(e)?[e.map(n=>String(n??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let n=r??Py;return ks(e,n+1)>n?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")]:[null];case"@sh":return typeof e=="string"?[`'${e.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof e=="string"?[e]:e==null?[""]:[String(e)];default:return null}}var Py,rE=M(()=>{xo(),Py=2e3});function nE(e,t,r,n,i,s){switch(t){case"index":return r.length===0?[null]:i(e,r[0],n).map(a=>{if(typeof e=="string"&&typeof a=="string"){if(a===""&&e==="")return null;let o=e.indexOf(a);return o>=0?o:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let l=0;l<=e.length-a.length;l++){let u=!0;for(let c=0;cs(l,a));return o>=0?o:null}return null});case"rindex":return r.length===0?[null]:i(e,r[0],n).map(a=>{if(typeof e=="string"&&typeof a=="string"){let o=e.lastIndexOf(a);return o>=0?o:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let o=e.length-a.length;o>=0;o--){let l=!0;for(let u=0;u=0;o--)if(s(e[o],a))return o;return null}return null});case"indices":return r.length===0?[[]]:i(e,r[0],n).map(a=>{let o=[];if(typeof e=="string"&&typeof a=="string"){let l=e.indexOf(a);for(;l!==-1;)o.push(l),l=e.indexOf(a,l+1)}else if(Array.isArray(e))if(Array.isArray(a)){let l=a.length;if(l===0)for(let u=0;u<=e.length;u++)o.push(u);else for(let u=0;u<=e.length-l;u++){let c=!0;for(let p=0;p{});function sE(e,t,r,n,i){switch(t){case"fabs":case"abs":return typeof e=="number"?[Math.abs(e)]:typeof e=="string"?[e]:[null];case"exp10":return typeof e=="number"?[10**e]:[null];case"exp2":return typeof e=="number"?[2**e]:[null];case"pow":{if(r.length<2)return[null];let s=i(e,r[0],n),a=i(e,r[1],n),o=s[0],l=a[0];return typeof o!="number"||typeof l!="number"?[null]:[o**l]}case"atan2":{if(r.length<2)return[null];let s=i(e,r[0],n),a=i(e,r[1],n),o=s[0],l=a[0];return typeof o!="number"||typeof l!="number"?[null]:[Math.atan2(o,l)]}case"hypot":{if(typeof e!="number"||r.length===0)return[null];let s=i(e,r[0],n)[0];return[Math.hypot(e,s)]}case"fma":{if(typeof e!="number"||r.length<2)return[null];let s=i(e,r[0],n)[0],a=i(e,r[1],n)[0];return[e*s+a]}case"copysign":{if(typeof e!="number"||r.length===0)return[null];let s=i(e,r[0],n)[0];return[Math.sign(s)*Math.abs(e)]}case"drem":case"remainder":{if(typeof e!="number"||r.length===0)return[null];let s=i(e,r[0],n)[0];return[e-Math.round(e/s)*s]}case"fdim":{if(typeof e!="number"||r.length===0)return[null];let s=i(e,r[0],n)[0];return[Math.max(0,e-s)]}case"fmax":{if(typeof e!="number"||r.length===0)return[null];let s=i(e,r[0],n)[0];return[Math.max(e,s)]}case"fmin":{if(typeof e!="number"||r.length===0)return[null];let s=i(e,r[0],n)[0];return[Math.min(e,s)]}case"ldexp":return typeof e!="number"||r.length===0?[null]:[e*2**i(e,r[0],n)[0]];case"scalbn":case"scalbln":return typeof e!="number"||r.length===0?[null]:[e*2**i(e,r[0],n)[0]];case"nearbyint":return typeof e=="number"?[Math.round(e)]:[null];case"logb":return typeof e=="number"?[Math.floor(Math.log2(Math.abs(e)))]:[null];case"significand":return typeof e=="number"?[e/2**Math.floor(Math.log2(Math.abs(e)))]:[null];case"frexp":if(typeof e=="number"){if(e===0)return[[0,0]];let s=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**s,s]]}return[null];case"modf":if(typeof e=="number"){let s=Math.trunc(e);return[[e-s,s]]}return[null];default:return null}}var aE=M(()=>{});function di(e){let t=e.limits.maxIterations;return{maxDepth:e.limits.maxDepth,maxResults:e.limits.maxArrayElements,maxIterations:t}}function Si(e){throw new C(e,"array_elements")}function kl(e,t){let r=1;for(let n of e){if(!Number.isSafeInteger(n)||n<0)throw Error("combinations requires finite array lengths");n!==0&&r>Math.floor(t/n)&&Si(`query combination limit exceeded (${t})`),r*=n}return r}function oE(e,t,r,n,i,s,a,o){switch(t){case"recurse":{let l=[],u=di(n),c=r.length>=2?r[1]:null,p=[{value:e,depth:0}],h=0;for(;p.length>0;){let f=p.pop();if(!f)break;if(++h>u.maxIterations)throw new C(`query iteration limit exceeded (${u.maxIterations})`,"iterations");if(f.depth>u.maxDepth)throw new C(`query depth limit exceeded (${u.maxDepth})`,"recursion");if(c&&!i(f.value,c,n).some(s))continue;l.length>=u.maxResults&&Si(`query result element limit exceeded (${u.maxResults})`),l.push(f.value);let d=[];r.length===0?Array.isArray(f.value)?d=f.value:f.value&&typeof f.value=="object"&&(d=Object.keys(f.value).map(m=>f.value[m])):d=i(f.value,r[0],n).filter(m=>m!=null),p.length>u.maxResults-d.length&&Si(`query traversal queue limit exceeded (${u.maxResults})`);for(let m=d.length-1;m>=0;m--)p.push({value:d[m],depth:f.depth+1})}return l}case"recurse_down":return o(e,"recurse",r,n);case"walk":{if(r.length===0)return[e];let l=di(n),u=new WeakSet,c=new WeakMap,p=[{value:e,depth:0,expanded:!1}],h=e,f=0;for(;p.length>0;){let d=p.pop();if(!d)break;if(++f>l.maxIterations)throw new C(`query iteration limit exceeded (${l.maxIterations})`,"iterations");if(d.depth>l.maxDepth)throw new C(`query depth limit exceeded (${l.maxDepth})`,"recursion");let m=d.value!==null&&typeof d.value=="object"?d.value:null;if(!d.expanded&&m){if(u.has(m))continue;u.add(m),p.push({...d,expanded:!0});let y=it(d.value),x=Array.isArray(d.value)?d.value:Object.keys(y??{}).map(b=>y?.[b]);p.length>l.maxResults-x.length&&Si(`query traversal queue limit exceeded (${l.maxResults})`);for(let b=x.length-1;b>=0;b--)p.push({value:x[b],depth:d.depth+1,expanded:!1});continue}let g=d.value;if(Array.isArray(d.value))g=d.value.map(y=>typeof y=="object"&&y?c.get(y)??y:y);else if(m){let y=Object.create(null),x=it(d.value);for(let b of Object.keys(x??{})){if(!et(b))continue;let w=x?.[b];Je(y,b,typeof w=="object"&&w?c.get(w)??w:w)}g=y}let v=i(g,r[0],n)[0];m&&c.set(m,v),d.depth===0&&(h=v)}return[h]}case"transpose":{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let l=di(n),u=0;for(let p of e)Array.isArray(p)&&(u=Math.max(u,p.length));kl([e.length,u],l.maxResults);let c=[];for(let p=0;pArray.isArray(h)?h[p]:null));return[c]}case"combinations":{if(r.length>0){let f=i(e,r[0],n)[0];if(!Array.isArray(e))return[];if(!Number.isFinite(f)||!Number.isSafeInteger(f)||f<0)throw Error("combinations length must be a finite non-negative integer");let d=di(n);if(f>d.maxDepth||f>d.maxResults)throw new C(`query depth limit exceeded (${d.maxDepth})`,"recursion");if(f===0)return d.maxResults<1&&Si("query combination limit exceeded (0)"),[[]];let m=kl(Array.from({length:f},()=>e.length),d.maxResults);if(m===0)return[];let g=[],v=Array(f).fill(0);for(let y=0;ye[x]));for(let x=f-1;x>=0&&(v[x]++,!(v[x]l.maxDepth)throw new C(`query depth limit exceeded (${l.maxDepth})`,"recursion");let c=kl(u.map(f=>f.length),l.maxResults);if(c===0)return[];let p=[],h=Array(u.length).fill(0);for(let f=0;fu[m][d]));for(let d=u.length-1;d>=0&&(h[d]++,!(h[d]0?i(e,r[0],n)[0]:1;if(u>=0){if(u>l.length)return[];let c=l.slice(0,l.length-u);return[a(n.root,c)]}{let c=-u-1;if(c>=l.length)return[e];let p=l.slice(0,c);return[a(n.root,p)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let l=n.currentPath,u=[];for(let c=l.length-1;c>=0;c--)u.push(a(n.root,l.slice(0,c)));return[u]}case"root":return n.root===void 0?[]:[n.root];default:return null}}var lE=M(()=>{H(),nn()});function rr(e){return e.limits.maxArrayElements}function Js(e,t){let r=rr(e);if(t>=r)throw new C(`query result element limit exceeded (${r})`,"array_elements")}function uE(e,t){let r=t.limits.maxDepth??Wa;if(e.length>r)throw new C(`query depth limit exceeded (${r})`,"recursion");let n=t.limits.maxArrayElements;for(let i of e)if(typeof i=="number"){if(!Number.isSafeInteger(i)||i<0||i>=n)throw new C(`query array index limit exceeded (${n})`,"array_elements")}else if(typeof i!="string")throw Error("stream path components must be strings or integers")}function cE(e,t,r,n,i){switch(t){case"keys":return Array.isArray(e)?[e.map((s,a)=>a)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((s,a)=>a)]:e&&typeof e=="object"?[Object.keys(e)]:[null];case"length":return typeof e=="string"||Array.isArray(e)?[e.length]:e&&typeof e=="object"?[Object.keys(e).length]:e===null?[0]:typeof e=="number"?[Math.abs(e)]:[null];case"utf8bytelength":{if(typeof e=="string")return[q(e)];let s=e===null?"null":Array.isArray(e)?"array":typeof e,a=s==="array"||s==="object"?JSON.stringify(e):String(e);throw Error(`${s} (${a}) only strings have UTF-8 byte length`)}case"to_entries":{let s=it(e);if(s){let a=Object.keys(s);if(a.length>rr(n))throw new C(`query result element limit exceeded (${rr(n)})`,"array_elements");return[a.map(o=>{let l=Object.create(null);return Je(l,"key",o),Je(l,"value",s[o]),l})]}return[null]}case"from_entries":if(Array.isArray(e)){let s=Object.create(null);for(let a of e){let o=it(a);if(o){let l=o.key??o.Key??o.name??o.Name??o.k,u=o.value??o.Value??o.v;if(l!==void 0){let c=String(l);et(c)&&Je(s,c,u)}}}return[s]}return[null];case"with_entries":{if(r.length===0)return[e];let s=it(e);if(s){let a=Object.keys(s);if(a.length>rr(n))throw new C(`query result element limit exceeded (${rr(n)})`,"array_elements");let o=[];for(let u of a){let c=Object.create(null);Je(c,"key",u),Je(c,"value",s[u]);let p=i(c,r[0],n);if(o.length>rr(n)-p.length)throw new C(`query result element limit exceeded (${rr(n)})`,"array_elements");for(let h of p)o.push(h)}let l=Object.create(null);for(let u of o){let c=it(u);if(c){let p=c.key??c.name??c.k,h=c.value??c.v;if(p!==void 0){let f=String(p);et(f)&&Je(l,f,h)}}}return[l]}return[null]}case"reverse":return Array.isArray(e)?[[...e].reverse()]:typeof e=="string"?[e.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(e)?(r.length>0?i(e,r[0],n):[1/0]).map(s=>{let a=s;if(a<0)throw Error("flatten depth must not be negative");return e.flat(a)}):[null];case"unique":if(Array.isArray(e)){let s=new Set,a=[];for(let o of e){let l=JSON.stringify(o);s.has(l)||(s.add(l),a.push(o))}return[a]}return[null];case"tojson":case"tojsonstream":{let s=n.limits.maxDepth??Wa;return ks(e,s+1)>s?[null]:[JSON.stringify(e)]}case"fromjson":if(typeof e=="string"){let s=e.trim().toLowerCase();if(s==="nan")return[NaN];if(s==="inf"||s==="infinity")return[1/0];if(s==="-inf"||s==="-infinity")return[-1/0];try{return[ca(JSON.parse(e),{maxDepth:n.limits.maxDepth,maxElements:n.limits.maxArrayElements})]}catch(a){throw a instanceof C?a:Error(`Invalid JSON: ${e}`)}}return[e];case"tostring":return typeof e=="string"?[e]:[JSON.stringify(e)];case"tonumber":if(typeof e=="number")return[e];if(typeof e=="string"){let s=Number(e);if(Number.isNaN(s))throw Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[s]}throw Error(`${typeof e} cannot be parsed as a number`);case"toboolean":{if(typeof e=="boolean")return[e];if(typeof e=="string"){if(e==="true")return[!0];if(e==="false")return[!1];throw Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let s=e===null?"null":Array.isArray(e)?"array":typeof e,a=s==="array"||s==="object"?JSON.stringify(e):String(e);throw Error(`${s} (${a}) cannot be parsed as a boolean`)}case"tostream":{let s=[],a=n.limits.maxDepth??Wa,o=[{value:e,path:[]}],l=new WeakSet,u=0;for(;o.length>0;){let c=o.pop();if(!c)break;if(++u>n.limits.maxIterations)throw new C(`query iteration limit exceeded (${n.limits.maxIterations})`,"iterations");if(c.path.length>a)throw new C(`query depth limit exceeded (${a})`,"recursion");let p=c.value;if(typeof p!="object"||!p)Js(n,s.length),s.push([c.path,p]);else if(Array.isArray(p)){if(l.has(p))throw new C("cyclic value cannot be converted to a stream","recursion");if(l.add(p),p.length===0)Js(n,s.length),s.push([c.path,[]]);else{if(o.length>rr(n)-p.length)throw new C(`query traversal queue limit exceeded (${rr(n)})`,"array_elements");for(let h=p.length-1;h>=0;h--)o.push({value:p[h],path:[...c.path,h]})}}else{if(l.has(p))throw new C("cyclic value cannot be converted to a stream","recursion");l.add(p);let h=Object.keys(p);if(h.length===0)Js(n,s.length),s.push([c.path,Object.create(null)]);else{if(o.length>rr(n)-h.length)throw new C(`query traversal queue limit exceeded (${rr(n)})`,"array_elements");for(let f=h.length-1;f>=0;f--){let d=h[f];o.push({value:p[d],path:[...c.path,d]})}}}}return Js(n,s.length),s.push([[]]),s}case"fromstream":{if(r.length===0)return[e];let s=i(e,r[0],n);if(s.length>rr(n))throw new C(`query stream item limit exceeded (${rr(n)})`,"array_elements");let a=null,o=0;for(let l of s){if(!Array.isArray(l)||l.length===1&&Array.isArray(l[0])&&l[0].length===0||l.length!==2)continue;let[u,c]=l;if(!Array.isArray(u))continue;if(uE(u,n),u.length===0){a=c;continue}a===null&&(a=typeof u[0]=="number"?[]:Object.create(null));let p=a;for(let f=0;fn.limits.maxIterations-o)throw new C(`query iteration limit exceeded (${n.limits.maxIterations})`,"iterations");for(o+=Math.max(0,g);p.length<=d;)p.push(null);p[d]===null&&(p[d]=typeof m=="number"?[]:Object.create(null)),p=p[d]}else{let g=it(p);if(g){let v=String(d);if(!et(v))continue;(g[v]===null||g[v]===void 0)&&Je(g,v,typeof m=="number"?[]:Object.create(null)),p=g[v]}}}let h=u[u.length-1];if(Array.isArray(p)&&typeof h=="number"){let f=h+1-p.length;if(f>n.limits.maxIterations-o)throw new C(`query iteration limit exceeded (${n.limits.maxIterations})`,"iterations");for(o+=Math.max(0,f);p.length<=h;)p.push(null);p[h]=c}else{let f=it(p);if(f){let d=String(h);et(d)&&Je(f,d,c)}}}return[a]}case"truncate_stream":{let s=typeof e=="number"?Math.floor(e):0;if(r.length===0)return[];let a=[],o=i(e,r[0],n);for(let l of o)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let u=l[0];u.length>s&&a.push([u.slice(s)]);continue}if(l.length===2&&Array.isArray(l[0])){let u=l[0],c=l[1];u.length>s&&a.push([u.slice(s),c])}}return a}default:return null}}var Wa,pE=M(()=>{se(),H(),nn(),xo(),Wa=2e3});function Ef(e,t){if(!Array.isArray(e))throw Error("path must be an array");let r=t.limits.maxDepth;if(e.length>r)throw new C(`query depth limit exceeded (${r})`,"recursion");let n=t.limits.maxArrayElements,i=0;for(let s of e)if(typeof s=="number"){if(!Number.isSafeInteger(s)||s<0||s>=n)throw new C(`query array index limit exceeded (${n})`,"array_elements");let a=s+1;if(i>n-a)throw new C(`query cumulative array allocation limit exceeded (${n})`,"array_elements");i+=a}else if(typeof s!="string")throw Error("path components must be strings or integers");return ir(t,i+e.length),e}function Sf(e,t,r){let n=[],i=[{value:e,path:[],isRoot:!0}];for(;i.length>0;){let s=i.pop();if(!s)break;if(ir(t),s.path.length>t.limits.maxDepth)throw new C(`query depth limit exceeded (${t.limits.maxDepth})`,"recursion");if(s.value===null||typeof s.value!="object"){(r||!s.isRoot)&&($t(t,n.length),n.push(s.path));continue}!r&&!s.isRoot&&($t(t,n.length),n.push(s.path));let a=Array.isArray(s.value)?s.value.map((o,l)=>[l,o]):Object.keys(s.value).map(o=>[o,s.value[o]]);$t(t,n.length,i.length+a.length);for(let o=a.length-1;o>=0;o--){let[l,u]=a[o],c=[...s.path,l];i.push({value:u,path:c,isRoot:!1})}}return n}function hE(e,t,r,n,i,s,a,o,l,u){switch(t){case"getpath":{if(r.length===0)return[null];let c=i(e,r[0],n),p=[];for(let h of c){let f=h,d=e;for(let m of f){if(d==null){d=null;break}if(Array.isArray(d)&&typeof m=="number")d=d[m];else if(typeof m=="string"){let g=it(d);if(!g||!Object.hasOwn(g,m)){d=null;break}d=g[m]}else{d=null;break}}p.push(d)}return p}case"setpath":{if(r.length<2)return[null];let c=Ef(i(e,r[0],n)[0],n),p=i(e,r[1],n)[0];return[a(e,c,p)]}case"delpaths":{if(r.length===0)return[e];let c=i(e,r[0],n)[0],p=e;for(let h of c.sort((f,d)=>d.length-f.length))p=o(p,h);return[p]}case"path":{if(r.length===0)return[[]];let c=[];return u(e,r[0],n,[],c),c}case"del":return r.length===0?[e]:[l(e,r[0],n)];case"pick":{if(r.length===0)return[null];let c=[];for(let h of r)u(e,h,n,[],c);let p=null;for(let h of c){for(let d of h)if(typeof d=="number"&&d<0)throw Error("Out of bounds negative array index");Ef(h,n);let f=e;for(let d of h){if(f==null)break;if(Array.isArray(f)&&typeof d=="number")f=f[d];else if(typeof d=="string"){let m=it(f);if(!m||!Object.hasOwn(m,d)){f=null;break}f=m[d]}else{f=null;break}}p=a(p,h,f)}return[p]}case"paths":{let c=Sf(e,n,!1);return r.length>0?c.filter(p=>{let h=e;for(let f of p)if(Array.isArray(h)&&typeof f=="number")h=h[f];else if(typeof f=="string"){let d=it(h);if(!d||!Object.hasOwn(d,f))return!1;h=d[f]}else return!1;return i(h,r[0],n).some(s)}):c}case"leaf_paths":return Sf(e,n,!0);default:return null}}var fE=M(()=>{H(),_y(),nn()});function dE(e,t,r,n,i,s){switch(t){case"IN":{if(r.length===0)return[!1];if(r.length===1){let u=i(e,r[0],n);for(let c of u)if(s(e,c))return[!0];return[!1]}let a=i(e,r[0],n),o=i(e,r[1],n),l=new Set(o.map(u=>JSON.stringify(u)));for(let u of a)if(l.has(JSON.stringify(u)))return[!0];return[!1]}case"INDEX":{if(r.length===0)return[Object.create(null)];if(r.length===1){let l=i(e,r[0],n),u=Object.create(null);for(let c of l){let p=String(c);et(p)&&Je(u,p,c)}return[u]}if(r.length===2){let l=i(e,r[0],n),u=Object.create(null);for(let c of l){let p=i(c,r[1],n);if(p.length>0){let h=String(p[0]);et(h)&&Je(u,h,c)}}return[u]}let a=i(e,r[0],n),o=Object.create(null);for(let l of a){let u=i(l,r[1],n),c=i(l,r[2],n);if(u.length>0&&c.length>0){let p=String(u[0]);et(p)&&Je(o,p,c[0])}}return[o]}case"JOIN":{if(r.length<2)return[null];let a=it(i(e,r[0],n)[0]);if(!a||!Array.isArray(e))return[null];let o=[];for(let l of e){let u=i(l,r[1],n),c=u.length>0?String(u[0]):"",p=fo(a,c)?a[c]:null;o.push([l,p])}return[o]}default:return null}}var mE=M(()=>{nn()});function Dy(e){return e.limits.maxArrayElements}function Af(e){return Math.min(e.limits.maxStringLength,e.limits.maxOutputSize)}function Mn(e,t){let r=Dy(e);if(!Number.isSafeInteger(t)||t<0||t>r)throw new C(`query result element limit exceeded (${r})`,"array_elements")}function gE(e,t,r){if(e==="")return t===""?0:1;if(t==="")return e.length;let n=1,i=0;for(;;){let s=e.indexOf(t,i);if(s<0||(n++,n>r))return n;i=s+t.length}}function yE(e,t,r,n,i){switch(t){case"join":{if(!Array.isArray(e))return[null];let s=r.length>0?i(e,r[0],n):[""];for(let a of e)if(Array.isArray(a)||typeof a=="object"&&a)throw Error("cannot join: contains arrays or objects");return Mn(n,s.length),s.map(a=>{let o=String(a),l=0;for(let u=0;u0&&(l+=q(o)),l>Af(n))throw new C(`query string size limit exceeded (${Af(n)} bytes)`,"string_length")}return e.map(u=>u===null?"":typeof u=="string"?u:String(u)).join(o)})}case"split":{if(typeof e!="string"||r.length===0)return[null];let s=i(e,r[0],n),a=String(s[0]);return Mn(n,gE(e,a,Dy(n))),[e.split(a)]}case"splits":{if(typeof e!="string"||r.length===0)return[];let s=i(e,r[0],n),a=String(s[0]);try{let o=r.length>1?String(i(e,r[1],n)[0]):"g",l=de(a,o.includes("g")?o:`${o}g`),u=1;for(let p of l.matchAll(e))u+=Math.max(1,p.length),Mn(n,u);let c=l.split(e);return Mn(n,c.length),c}catch(o){if(o instanceof C)throw o;return[]}}case"scan":{if(typeof e!="string"||r.length===0)return[];let s=i(e,r[0],n),a=String(s[0]);try{let o=r.length>1?String(i(e,r[1],n)[0]):"",l=de(a,o.includes("g")?o:`${o}g`),u=[];for(let c of l.matchAll(e))Mn(n,u.length+1),c.length>1?(Mn(n,c.length-1),u.push(c.slice(1))):u.push(c[0]);return u}catch(o){if(o instanceof C)throw o;return[]}}case"test":{if(typeof e!="string"||r.length===0)return[!1];let s=i(e,r[0],n),a=String(s[0]);try{return[de(a,r.length>1?String(i(e,r[1],n)[0]):"").test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||r.length===0)return[null];let s=i(e,r[0],n),a=String(s[0]);try{let o=de(a,`${r.length>1?String(i(e,r[1],n)[0]):""}d`).exec(e);if(!o)return[];let l=o.indices;return[{offset:o.index,length:o[0].length,string:o[0],captures:o.slice(1).map((u,c)=>({offset:l?.[c+1]?.[0]??null,length:u?.length??0,string:u??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof e!="string"||r.length===0)return[null];let s=i(e,r[0],n),a=String(s[0]);try{let o=de(a,r.length>1?String(i(e,r[1],n)[0]):"").match(e);return!o||!o.groups?[Object.create(null)]:[o.groups]}catch{return[null]}}case"sub":{if(typeof e!="string"||r.length<2)return[null];let s=i(e,r[0],n),a=i(e,r[1],n),o=String(s[0]),l=String(a[0]);try{return[de(o,r.length>2?String(i(e,r[2],n)[0]):"").replace(e,l)]}catch{return[e]}}case"gsub":{if(typeof e!="string"||r.length<2)return[null];let s=i(e,r[0],n),a=i(e,r[1],n),o=String(s[0]),l=String(a[0]);try{let u=r.length>2?String(i(e,r[2],n)[0]):"g";return[de(o,u.includes("g")?u:`${u}g`).replace(e,l)]}catch{return[e]}}case"ascii_downcase":return typeof e=="string"?[e.replace(/[A-Z]/g,s=>String.fromCharCode(s.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof e=="string"?[e.replace(/[a-z]/g,s=>String.fromCharCode(s.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof e!="string"||r.length===0)return[e];let s=i(e,r[0],n),a=String(s[0]);return[e.startsWith(a)?e.slice(a.length):e]}case"rtrimstr":{if(typeof e!="string"||r.length===0)return[e];let s=i(e,r[0],n),a=String(s[0]);return a===""?[e]:[e.endsWith(a)?e.slice(0,-a.length):e]}case"trimstr":{if(typeof e!="string"||r.length===0)return[e];let s=i(e,r[0],n),a=String(s[0]);if(a==="")return[e];let o=e;return o.startsWith(a)&&(o=o.slice(a.length)),o.endsWith(a)&&(o=o.slice(0,-a.length)),[o]}case"trim":if(typeof e=="string")return[e.trim()];throw Error("trim input must be a string");case"ltrim":if(typeof e=="string")return[e.trimStart()];throw Error("trim input must be a string");case"rtrim":if(typeof e=="string")return[e.trimEnd()];throw Error("trim input must be a string");case"startswith":{if(typeof e!="string"||r.length===0)return[!1];let s=i(e,r[0],n);return[e.startsWith(String(s[0]))]}case"endswith":{if(typeof e!="string"||r.length===0)return[!1];let s=i(e,r[0],n);return[e.endsWith(String(s[0]))]}case"ascii":return typeof e=="string"&&e.length>0?[e.charCodeAt(0)]:[null];case"explode":if(typeof e=="string"){let s=0;for(let a of e)s++,Mn(n,s);return[Array.from(e).map(a=>a.codePointAt(0))]}return[null];case"implode":if(!Array.isArray(e))throw Error("implode input must be an array");return[e.map(s=>{if(typeof s=="string")throw Error(`string (${JSON.stringify(s)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof s!="number"||Number.isNaN(s))throw Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let a=Math.trunc(s);return a<0||a>1114111||a>=55296&&a<=57343?String.fromCodePoint(65533):String.fromCodePoint(a)}).join("")];default:return null}}var xE=M(()=>{H(),at(),wt()});function vE(e,t){switch(t){case"type":return e===null?["null"]:Array.isArray(e)?["array"]:typeof e=="boolean"?["boolean"]:typeof e=="number"?["number"]:typeof e=="string"?["string"]:typeof e=="object"?["object"]:["null"];case"infinite":return[1/0];case"nan":return[NaN];case"isinfinite":return[typeof e=="number"&&!Number.isFinite(e)];case"isnan":return[typeof e=="number"&&Number.isNaN(e)];case"isnormal":return[typeof e=="number"&&Number.isFinite(e)&&e!==0];case"isfinite":return[typeof e=="number"&&Number.isFinite(e)];case"numbers":return typeof e=="number"?[e]:[];case"strings":return typeof e=="string"?[e]:[];case"booleans":return typeof e=="boolean"?[e]:[];case"nulls":return e===null?[e]:[];case"arrays":return Array.isArray(e)?[e]:[];case"objects":return e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"iterables":return Array.isArray(e)||e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"scalars":return!Array.isArray(e)&&!(e&&typeof e=="object")?[e]:[];case"values":return e===null?[]:[e];case"not":return e===!1||e===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var bE=M(()=>{}),wE=M(()=>{V5(),Q5(),X5(),rE(),iE(),aE(),lE(),pE(),fE(),mE(),xE(),bE()});function Ru(e,t,r){if(t.length===0)return r;let[n,...i]=t;if(typeof n=="number"){if(e&&typeof e=="object"&&!Array.isArray(e))throw Error("Cannot index object with number");if(n>536870911)throw Error("Array index too large");if(n<0)throw Error("Out of bounds negative array index");let o=Array.isArray(e)?[...e]:[];for(;o.length<=n;)o.push(null);return o[n]=Ru(o[n],i,r),o}if(Array.isArray(e))throw Error("Cannot index array with string");if(!et(n))return e??Object.create(null);let s=it(e),a=s?Rt(s):Object.create(null);return Je(a,n,Ru(Object.hasOwn(a,n)?a[n]:void 0,i,r)),a}function Pu(e,t){if(t.length===0)return null;if(t.length===1){let i=t[0];if(Array.isArray(e)&&typeof i=="number"){let s=[...e];return s.splice(i,1),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s=String(i);if(!et(s))return e;let a=Rt(e);return delete a[s],a}return e}let[r,...n]=t;if(Array.isArray(e)&&typeof r=="number"){let i=[...e];return i[r]=Pu(i[r],n),i}if(e&&typeof e=="object"&&!Array.isArray(e)){let i=String(r);if(!et(i))return e;let s=Rt(e);return Object.hasOwn(s,i)&&Je(s,i,Pu(s[i],n)),s}return e}var EE=M(()=>{nn()});function si(e,t){return new C(e,t)}function ir(e,t=1){if(!Number.isSafeInteger(t)||t<0||e.budget.operations>e.limits.maxIterations-t)throw si(`query evaluation: too many iterations (${e.limits.maxIterations})`,"iterations");e.budget.operations+=t}function $t(e,t,r=1){let n=e.limits.maxArrayElements;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(r)||t<0||r<0||t>n-r)throw si(`query result element limit exceeded (${n})`,"array_elements")}function Qn(e,t,r){$t(e,t.length,r.length);for(let n of r)t.push(n)}function fr(e,t,r){let n=[];for(let i of t)ir(e),Qn(e,n,r(i));return n}function SE(e){let t=new Map;if(e?.namedArgs)for(let[r,n]of e.namedArgs)t.set(`$${r}`,n);return{vars:t,limits:{maxIterations:e?.limits?.maxIterations??My,maxDepth:e?.limits?.maxDepth??Hc,maxStringLength:e?.limits?.maxStringLength??Lu,maxOutputSize:e?.limits?.maxOutputSize??Lu,maxArrayElements:e?.limits?.maxArrayElements??1e5},env:e?.env,namedArgs:e?.namedArgs,positionalArgs:e?.positionalArgs,coverage:e?.coverage,requireDefenseContext:e?.requireDefenseContext,defenseContextChecked:!1,budget:e?.budget??{operations:0,callDepth:0}}}function ja(e,t,r){let n=new Map(e.vars);return n.set(t,r),{vars:n,limits:e.limits,env:e.env,namedArgs:e.namedArgs,positionalArgs:e.positionalArgs,requireDefenseContext:e.requireDefenseContext,defenseContextChecked:e.defenseContextChecked,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels,coverage:e.coverage,budget:e.budget}}function ys(e,t,r){switch(t.type){case"var":return ja(e,t.name,r);case"array":{if(!Array.isArray(r))return null;let n=e;for(let i=0;i0&&t.args[0].type==="Literal"){let n=t.args[0].value;typeof n=="number"&&(r=n)}if(r>=0)return e.slice(0,Math.max(0,e.length-r));{let n=-r-1;return e.slice(0,Math.min(n,e.length))}}if(t.name==="root")return[]}if(t.type==="Field"){let r=$n(t);if(r!==null)return[...e,...r]}if(t.type==="Index"&&t.index.type==="Literal"){let r=$n(t);if(r!==null)return[...e,...r]}if(t.type==="Pipe"){let r=Du(e,t.left);return r===null?null:Du(r,t.right)}return t.type==="Identity"?e:null}function Cf(e,t,r){if(t.type==="Comma"){let n=[];try{Qn(r,n,X(e,t.left,r))}catch(i){if(i instanceof C)throw i;if(n.length>0)return n;throw Error("evaluation failed")}try{Qn(r,n,X(e,t.right,r))}catch(i){if(i instanceof C)throw i;return n}return n}return X(e,t,r)}function X(e,t,r){let n=r&&"vars"in r?r:SE(r);if(n.defenseContextChecked||(Zt(n.requireDefenseContext,"query-engine","evaluation"),n={...n,defenseContextChecked:!0}),n.root===void 0&&(n={...n,root:e,currentPath:[]}),ir(n),n.budget.callDepth++,n.budget.callDepth>n.limits.maxDepth)throw n.budget.callDepth--,si(`query depth limit exceeded (${n.limits.maxDepth})`,"recursion");try{let i=CE(e,t,n);return $t(n,0,i.length),i}finally{n.budget.callDepth--}}function CE(e,t,r){switch(r.coverage?.hit(`jq:node:${t.type}`),t.type){case"Identity":return[e];case"Field":return fr(r,t.base?X(e,t.base,r):[e],n=>{let i=it(n);if(i){if(!Object.hasOwn(i,t.name))return[null];let s=i[t.name];return[s===void 0?null:s]}if(n===null)return[null];throw Error(`Cannot index ${Array.isArray(n)?"array":typeof n} with string "${t.name}"`)});case"Index":return fr(r,t.base?X(e,t.base,r):[e],n=>fr(r,X(n,t.index,r),i=>{if(typeof i=="number"&&Array.isArray(n)){if(Number.isNaN(i))return[null];let s=Math.trunc(i),a=s<0?n.length+s:s;return a>=0&&a{if(n===null)return[null];if(!Array.isArray(n)&&typeof n!="string")throw Error(`Cannot slice ${typeof n} (${JSON.stringify(n)})`);let i=n.length,s=t.start?X(e,t.start,r):[0],a=t.end?X(e,t.end,r):[i];return $t(r,0,s.length*a.length),fr(r,s,o=>a.map(l=>{let u=o,c=l,p=Number.isNaN(u)?0:Number.isInteger(u)?u:Math.floor(u),h=Number.isNaN(c)?i:Number.isInteger(c)?c:Math.ceil(c),f=kf(p,i),d=kf(h,i);return n.slice(f,d)}))});case"Iterate":return fr(r,t.base?X(e,t.base,r):[e],n=>Array.isArray(n)?n:n&&typeof n=="object"?Object.values(n):[]);case"Pipe":{let n=X(e,t.left,r),i=$n(t.left),s=[];for(let a of n)try{if(i!==null){let o={...r,currentPath:[...r.currentPath??[],...i]};Qn(r,s,X(a,t.right,o))}else Qn(r,s,X(a,t.right,r))}catch(o){throw o instanceof ds?o.withPrependedResults(s):o}return s}case"Comma":{let n=X(e,t.left,r),i=X(e,t.right,r);return $t(r,n.length,i.length),[...n,...i]}case"Literal":return[t.value];case"Array":return t.elements?[X(e,t.elements,r)]:[[]];case"Object":{let n=[Object.create(null)];for(let i of t.entries){let s=typeof i.key=="string"?[i.key]:X(e,i.key,r),a=X(e,i.value,r),o=[],l=s.filter(c=>typeof c=="string"&&et(c)).length,u=l+(s.length-l);$t(r,0,n.length*u*a.length);for(let c of n)for(let p of s){if(typeof p!="string")throw Error(`Cannot use ${p===null?"null":Array.isArray(p)?"array":typeof p} (${JSON.stringify(p)}) as object key`);if(!et(p)){for(let h of a)o.push(Rt(c));continue}for(let h of a){let f=Rt(c);Je(f,p,h),o.push(f)}}n.length=0,Qn(r,n,o)}return n}case"Paren":return X(e,t.expr,r);case"BinaryOp":return $E(e,t.op,t.left,t.right,r);case"UnaryOp":return X(e,t.operand,r).map(n=>{if(t.op==="-"){if(typeof n=="number")return-n;if(typeof n=="string")throw Error(`string (${(i=>i.length>5?`"${i.slice(0,3)}...`:JSON.stringify(i))(n)}) cannot be negated`);return null}return t.op==="not"?!Dr(n):null});case"Cond":return fr(r,X(e,t.cond,r),n=>{if(Dr(n))return X(e,t.then,r);for(let i of t.elifs)if(X(e,i.cond,r).some(Dr))return X(e,i.then,r);return t.else?X(e,t.else,r):[e]});case"Try":try{return X(e,t.body,r)}catch(n){if(n instanceof C)throw n;return t.catch?X(n instanceof Gc?n.value:n instanceof Error?n.message:String(n),t.catch,r):[]}case"Call":return Ly(e,t.name,t.args,r);case"VarBind":return fr(r,X(e,t.value,r),n=>{let i=null,s=[];if(t.pattern?s.push(t.pattern):t.name&&s.push({type:"var",name:t.name}),t.alternatives)for(let a of t.alternatives)s.push(a);for(let a of s)if(i=ys(r,a,n),i!==null)break;return i===null?[]:X(e,t.body,i)});case"VarRef":{if(t.name==="$ENV")return[r.env?Kr(r.env):Object.create(null)];if(t.name==="$ARGS"){let i=Object.create(null);if(r.namedArgs)for(let[a,o]of r.namedArgs)Object.defineProperty(i,a,{value:o,enumerable:!0,writable:!0,configurable:!0});let s=Object.create(null);return s.positional=r.positionalArgs?[...r.positionalArgs]:[],s.named=i,[s]}let n=r.vars.get(t.name);return n===void 0?[null]:[n]}case"Recurse":{let n=[],i=new WeakSet,s=[{val:e,depth:0}];for(;s.length>0;){let a=s.pop();if(!a)break;let{val:o,depth:l}=a;if(ir(r),l>r.limits.maxDepth)throw si(`query depth limit exceeded (${r.limits.maxDepth})`,"recursion");if(o&&typeof o=="object"){if(i.has(o))continue;i.add(o)}if($t(r,n.length),n.push(o),Array.isArray(o))for(let u=o.length-1;u>=0;u--)s.push({val:o[u],depth:l+1});else if(o&&typeof o=="object"){let u=Object.keys(o);for(let c=u.length-1;c>=0;c--)s.push({val:o[u[c]],depth:l+1})}}return n}case"Optional":try{return X(e,t.expr,r)}catch(n){if(n instanceof C)throw n;return[]}case"StringInterp":{let n=new st(r.limits.maxStringLength,"query string interpolation",()=>new C(`string size limit exceeded (${r.limits.maxStringLength} bytes)`,"string_length"));for(let i of t.parts){if(typeof i=="string"){n.append(i);continue}let s=X(e,i,r);for(let a of s){if(ir(r),ks(a,r.limits.maxDepth+1)>r.limits.maxDepth)throw si(`query depth limit exceeded (${r.limits.maxDepth})`,"recursion");n.append(typeof a=="string"?a:JSON.stringify(a))}}return[n.build()]}case"UpdateOp":return[kE(e,t.path,t.op,t.value,r)];case"Reduce":{let n=X(e,t.expr,r),i=X(e,t.init,r)[0],s=r.limits.maxDepth??Hc;for(let a of n){let o;if(t.pattern){if(o=ys(r,t.pattern,a),o===null)continue}else o=ja(r,t.varName,a);if(i=X(i,t.update,o)[0],ks(i,s+1)>s)return[null]}return[i]}case"Foreach":{let n=X(e,t.expr,r),i=X(e,t.init,r)[0],s=[];for(let a of n)try{let o;if(t.pattern){if(o=ys(r,t.pattern,a),o===null)continue}else o=ja(r,t.varName,a);i=X(i,t.update,o)[0],t.extract?Qn(r,s,X(i,t.extract,o)):($t(r,s.length),s.push(i))}catch(o){throw o instanceof ds?o.withPrependedResults(s):o}return s}case"Label":try{return X(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(n){if(n instanceof ds&&n.label===t.name)return n.partialResults;throw n}case"Break":throw new ds(t.name);case"Def":{let n=new Map(r.funcs??[]),i=`${t.name}/${t.params.length}`;n.set(i,{params:t.params,body:t.funcBody,closure:new Map(r.funcs??[])});let s={...r,funcs:n};return X(e,t.body,s)}default:throw Error(`Unknown AST node type: ${t.type}`)}}function kf(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function kE(e,t,r,n,i){function s(o,l){switch(r){case"=":return l;case"|=":return X(o,n,i)[0]??null;case"+=":return typeof o=="number"&&typeof l=="number"||typeof o=="string"&&typeof l=="string"?o+l:Array.isArray(o)&&Array.isArray(l)?($t(i,o.length,l.length),[...o,...l]):o&&l&&typeof o=="object"&&typeof l=="object"?i2(o,l):l;case"-=":return typeof o=="number"&&typeof l=="number"?o-l:o;case"*=":return typeof o=="number"&&typeof l=="number"?o*l:o;case"/=":return typeof o=="number"&&typeof l=="number"?o/l:o;case"%=":return typeof o=="number"&&typeof l=="number"?o%l:o;case"//=":return o===null||o===!1?l:o;default:return l}}function a(o,l,u){switch(l.type){case"Identity":return u(o);case"Field":if(!et(l.name))return o;if(l.base)return a(o,l.base,c=>{if(c&&typeof c=="object"&&!Array.isArray(c)){let p=Rt(c),h=Object.hasOwn(p,l.name)?p[l.name]:void 0;return Je(p,l.name,u(h)),p}return c});if(o&&typeof o=="object"&&!Array.isArray(o)){let c=Rt(o),p=Object.hasOwn(c,l.name)?c[l.name]:void 0;return Je(c,l.name,u(p)),c}return o;case"Index":{let c=X(e,l.index,i)[0];if(typeof c=="number"&&Number.isNaN(c))throw Error("Cannot set array element at NaN index");if(typeof c=="number"&&!Number.isFinite(c))throw Error("array index must be finite");if(typeof c=="number"&&!Number.isInteger(c)&&(c=Math.trunc(c)),l.base)return a(o,l.base,p=>{if(typeof c=="number"&&Array.isArray(p)){let h=[...p],f=c<0?h.length+c:c;if(f>=0){$t(i,0,f+1),h.length<=f&&(h.length=f+1);for(let d=p.length;d536870911)throw Error("Array index too large");if(c<0&&(!o||!Array.isArray(o)))throw Error("Out of bounds negative array index");if(Array.isArray(o)){let p=[...o],h=c<0?p.length+c:c;if(h>=0){$t(i,0,h+1),p.length<=h&&(p.length=h+1);for(let f=o.length;f{if(Array.isArray(p)){$t(i,0,p.length);let h=[];for(let f of p)ir(i),h.push(u(f));return h}if(p&&typeof p=="object"){let h=Object.create(null);for(let[f,d]of Object.entries(p))et(f)&&Je(h,f,u(d));return h}return p};return l.base?a(o,l.base,c):c(o)}case"Pipe":return a(a(o,l.left,c=>c),l.right,u);default:return u(o)}}return a(e,t,o=>r==="|="?s(o,o):s(o,X(e,n,i)[0]??null))}function NE(e,t,r){function n(s,a,o){switch(a.type){case"Identity":return o;case"Field":if(!et(a.name))return s;if(a.base){let l=X(s,a.base,r)[0],u=n(l,{type:"Field",name:a.name},o);return n(s,a.base,u)}if(s&&typeof s=="object"&&!Array.isArray(s)){let l=Rt(s);return Je(l,a.name,o),l}return s;case"Index":{if(a.base){let u=X(s,a.base,r)[0],c=n(u,{type:"Index",index:a.index},o);return n(s,a.base,c)}let l=X(e,a.index,r)[0];if(typeof l=="number"&&Array.isArray(s)){let u=[...s],c=l<0?u.length+l:l;return c>=0&&c=0&&u=0&&gDr(l)?fr(i,X(e,n,i),u=>[Dr(u)]):[!1]);if(t==="or")return fr(i,X(e,r,i),l=>Dr(l)?[!0]:fr(i,X(e,n,i),u=>[Dr(u)]));if(t==="//"){let l=X(e,r,i).filter(u=>u!=null&&u!==!1);return l.length>0?l:X(e,n,i)}let s=X(e,r,i),a=X(e,n,i),o=s.length*a.length;return $t(i,0,o),ir(i,o),s.flatMap(l=>a.map(u=>{switch(t){case"+":if(l===null)return u;if(u===null)return l;if(typeof l=="number"&&typeof u=="number")return l+u;if(typeof l=="string"&&typeof u=="string"){let c=i.limits.maxStringLength;if(q(l)+q(u)>c)throw new C(`string size limit exceeded (${c} bytes)`,"string_length");return l+u}return Array.isArray(l)&&Array.isArray(u)?($t(i,l.length,u.length),[...l,...u]):l&&u&&typeof l=="object"&&typeof u=="object"&&!Array.isArray(l)&&!Array.isArray(u)?i2(l,u):null;case"-":if(typeof l=="number"&&typeof u=="number")return l-u;if(Array.isArray(l)&&Array.isArray(u)){let c=new Set(u.map(p=>JSON.stringify(p)));return l.filter(p=>!c.has(JSON.stringify(p)))}if(typeof l=="string"&&typeof u=="string"){let c=p=>p.length>10?`"${p.slice(0,10)}...`:JSON.stringify(p);throw Error(`string (${c(l)}) and string (${c(u)}) cannot be subtracted`)}return null;case"*":if(typeof l=="number"&&typeof u=="number")return l*u;if(typeof l=="string"&&typeof u=="number"){if(!Number.isFinite(u))throw Error(`invalid string repetition count: ${u}`);let c=Math.trunc(u);if(c<0)return null;let p=q(l),h=i.limits.maxStringLength;if(p>0&&c>Math.floor(h/p))throw new C(`string size limit exceeded (${h} bytes)`,"string_length");return l.repeat(c)}{let c=it(l),p=it(u);if(c&&p)return Y5(c,p,{maxDepth:i.limits.maxDepth,visit:()=>ir(i)})}return null;case"/":if(typeof l=="number"&&typeof u=="number"){if(u===0)throw Error(`number (${l}) and number (${u}) cannot be divided because the divisor is zero`);return l/u}return typeof l=="string"&&typeof u=="string"?l.split(u):null;case"%":if(typeof l=="number"&&typeof u=="number"){if(u===0)throw Error(`number (${l}) and number (${u}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(l)&&!Number.isNaN(l)?!Number.isFinite(u)&&!Number.isNaN(u)&&l<0&&u>0?-1:0:l%u}return null;case"==":return Cs(l,u);case"!=":return!Cs(l,u);case"<":return Ys(l,u)<0;case"<=":return Ys(l,u)<=0;case">":return Ys(l,u)>0;case">=":return Ys(l,u)>=0;default:return null}}))}function Ly(e,t,r,n){let i=Fy.get(t);if(i)return typeof e=="number"?[i(e)]:[null];let s=sE(e,t,r,n,X);if(s!==null)return s;let a=yE(e,t,r,n,X);if(a!==null)return a;let o=K5(e,t,r,n,X);if(o!==null)return o;let l=tE(e,t,n.limits.maxDepth);if(l!==null)return l;let u=vE(e,t);if(u!==null)return u;let c=cE(e,t,r,n,X);if(c!==null)return c;let p=H5(e,t,r,n,X,Cf,Tu,Dr,Iu,C);if(p!==null)return p;let h=hE(e,t,r,n,X,Dr,Ru,Pu,NE,va);if(h!==null)return h;let f=nE(e,t,r,n,X,Cs);if(f!==null)return f;let d=Z5(e,t,r,n,X,Cf,Dr,C);if(d!==null)return d;let m=oE(e,t,r,n,X,Dr,AE,Ly);if(m!==null)return m;let g=dE(e,t,r,n,X,Cs);if(g!==null)return g;switch(t){case"builtins":return["add/0.all/0.all/1.all/2.any/0.any/1.any/2.arrays/0.ascii/0.ascii_downcase/0.ascii_upcase/0.booleans/0.bsearch/1.builtins/0.combinations/0.combinations/1.contains/1.debug/0.del/1.delpaths/1.empty/0.env/0.error/0.error/1.explode/0.first/0.first/1.flatten/0.flatten/1.floor/0.from_entries/0.fromdate/0.fromjson/0.getpath/1.gmtime/0.group_by/1.gsub/2.gsub/3.has/1.implode/0.IN/1.IN/2.INDEX/1.INDEX/2.index/1.indices/1.infinite/0.inside/1.isempty/1.isnan/0.isnormal/0.isvalid/1.iterables/0.join/1.keys/0.keys_unsorted/0.last/0.last/1.length/0.limit/2.ltrimstr/1.map/1.map_values/1.match/1.match/2.max/0.max_by/1.min/0.min_by/1.mktime/0.modulemeta/1.nan/0.not/0.nth/1.nth/2.null/0.nulls/0.numbers/0.objects/0.path/1.paths/0.paths/1.pick/1.range/1.range/2.range/3.recurse/0.recurse/1.recurse_down/0.repeat/1.reverse/0.rindex/1.rtrimstr/1.scalars/0.scan/1.scan/2.select/1.setpath/2.skip/2.sort/0.sort_by/1.split/1.splits/1.splits/2.sqrt/0.startswith/1.strftime/1.strings/0.strptime/1.sub/2.sub/3.test/1.test/2.to_entries/0.toboolean/0.todate/0.tojson/0.tostream/0.fromstream/1.truncate_stream/1.tonumber/0.tostring/0.transpose/0.trim/0.ltrim/0.rtrim/0.type/0.unique/0.unique_by/1.until/2.utf8bytelength/0.values/0.walk/1.while/2.with_entries/1".split(".")];case"error":{let v=r.length>0?X(e,r[0],n)[0]:e;throw new Gc(v)}case"env":return[n.env?Kr(n.env):Object.create(null)];case"debug":return[e];case"input_line_number":return[1];default:{let v=`${t}/${r.length}`,y=n.funcs?.get(v);if(y){let x=y.closure??n.funcs??new Map,b=new Map(x);b.set(v,y);for(let E=0;E=0;$--)D={type:"Comma",left:{type:"Literal",value:N[$]},right:D}}b.set(`${A}/0`,{params:[],body:D})}}let w={...n,funcs:b};return X(e,y.body,w)}throw Error(`Unknown function: ${t}`)}}}function va(e,t,r,n,i){if(ir(r),n.length>r.limits.maxDepth)throw si(`query depth limit exceeded (${r.limits.maxDepth})`,"recursion");let s=o=>{if(o.length>r.limits.maxDepth)throw si(`query depth limit exceeded (${r.limits.maxDepth})`,"recursion");$t(r,i.length),i.push(o)};if(t.type==="Comma"){let o=t;va(e,o.left,r,n,i),va(e,o.right,r,n,i);return}let a=$n(t);if(a!==null){s([...n,...a]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let o=0;o0;){let l=o.pop();if(!l)break;if(ir(r),s([...n,...l.path]),l.value&&typeof l.value=="object"){let u=Array.isArray(l.value)?l.value.map((c,p)=>[p,c]):Object.keys(l.value).map(c=>[c,l.value[c]]);$t(r,0,o.length+u.length);for(let c=u.length-1;c>=0;c--){let[p,h]=u[c];o.push({value:h,path:[...l.path,p]})}}}return}if(t.type==="Pipe"){let o=$n(t.left);if(o!==null){let l=X(e,t.left,r);for(let u of l)va(u,t.right,r,[...n,...o],i);return}}X(e,t,r).length>0&&s(n)}var ds,Gc,My,Lu,Hc,Fy,_y=M(()=>{Et(),Rn(),H(),vn(),wt(),wE(),EE(),nn(),xo(),ds=class zy extends Error{label;partialResults;constructor(t,r=[]){super(`break ${t}`),this.label=t,this.partialResults=r,this.name="BreakError"}withPrependedResults(t){return new zy(this.label,[...t,...this.partialResults])}},Gc=class extends Error{value;constructor(e){super(typeof e=="string"?e:JSON.stringify(e)),this.value=e,this.name="JqError"}},My=1e4,Lu=10485760,Hc=2e3,Fy=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function By(e){let t=[],r=0,n=(u=0)=>e[r+u],i=()=>e[r++],s=()=>r>=e.length,a=u=>u>="0"&&u<="9",o=u=>u>="a"&&u<="z"||u>="A"&&u<="Z"||u==="_",l=u=>o(u)||a(u);for(;!s();){let u=r,c=i();if(c!==" "&&c!==" "&&c!==` `&&c!=="\r"){if(c==="#"){for(;!s()&&n()!==` `;)i();continue}if(c==="."&&n()==="."){i(),t.push({type:"DOTDOT",pos:u});continue}if(c==="="&&n()==="="){i(),t.push({type:"EQ",pos:u});continue}if(c==="!"&&n()==="="){i(),t.push({type:"NE",pos:u});continue}if(c==="<"&&n()==="="){i(),t.push({type:"LE",pos:u});continue}if(c===">"&&n()==="="){i(),t.push({type:"GE",pos:u});continue}if(c==="/"&&n()==="/"){i(),n()==="="?(i(),t.push({type:"UPDATE_ALT",pos:u})):t.push({type:"ALT",pos:u});continue}if(c==="+"&&n()==="="){i(),t.push({type:"UPDATE_ADD",pos:u});continue}if(c==="-"&&n()==="="){i(),t.push({type:"UPDATE_SUB",pos:u});continue}if(c==="*"&&n()==="="){i(),t.push({type:"UPDATE_MUL",pos:u});continue}if(c==="/"&&n()==="="){i(),t.push({type:"UPDATE_DIV",pos:u});continue}if(c==="%"&&n()==="="){i(),t.push({type:"UPDATE_MOD",pos:u});continue}if(c==="="&&n()!=="="){t.push({type:"ASSIGN",pos:u});continue}if(c==="."){t.push({type:"DOT",pos:u});continue}if(c==="|"){n()==="="?(i(),t.push({type:"UPDATE_PIPE",pos:u})):t.push({type:"PIPE",pos:u});continue}if(c===","){t.push({type:"COMMA",pos:u});continue}if(c===":"){t.push({type:"COLON",pos:u});continue}if(c===";"){t.push({type:"SEMICOLON",pos:u});continue}if(c==="("){t.push({type:"LPAREN",pos:u});continue}if(c===")"){t.push({type:"RPAREN",pos:u});continue}if(c==="["){t.push({type:"LBRACKET",pos:u});continue}if(c==="]"){t.push({type:"RBRACKET",pos:u});continue}if(c==="{"){t.push({type:"LBRACE",pos:u});continue}if(c==="}"){t.push({type:"RBRACE",pos:u});continue}if(c==="?"){t.push({type:"QUESTION",pos:u});continue}if(c==="+"){t.push({type:"PLUS",pos:u});continue}if(c==="-"){t.push({type:"MINUS",pos:u});continue}if(c==="*"){t.push({type:"STAR",pos:u});continue}if(c==="/"){t.push({type:"SLASH",pos:u});continue}if(c==="%"){t.push({type:"PERCENT",pos:u});continue}if(c==="<"){t.push({type:"LT",pos:u});continue}if(c===">"){t.push({type:"GT",pos:u});continue}if(a(c)){let p=c;for(;!s()&&(a(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(e[r+1]==="+"||e[r+1]==="-")&&(p+=i()),p+=i();t.push({type:"NUMBER",value:Number(p),pos:u});continue}if(c==='"'){let p="",h=0;for(;!s();){let f=n();if(h===0&&f==='"')break;if(h===0&&f==="\\"){if(i(),s())break;let d=i();switch(d){case"n":p+=` `;break;case"r":p+="\r";break;case"t":p+=" ";break;case"\\":p+="\\";break;case'"':p+='"';break;case"(":p+="\\(",h=1;break;default:p+=d}continue}if(h>0){if(f==='"'){for(p+=i();!s();){let d=n();if(d==="\\"){p+=i(),s()||(p+=i());continue}if(p+=i(),d==='"')break}continue}f==="("?h++:f===")"&&h--,p+=i();continue}p+=i()}s()||i(),t.push({type:"STRING",value:p,pos:u});continue}if(o(c)||c==="$"||c==="@"){let p=c;for(;!s()&&l(n());)p+=i();let h=Mu.get(p);h?t.push({type:h,value:p,pos:u}):t.push({type:"IDENT",value:p,pos:u});continue}throw Error(`Unexpected character '${c}' at position ${u}`)}}return t.push({type:"EOF",pos:r}),t}function OE(e,t={}){let r=t.maxDepth??256,n=t.maxTokens??1e5,i=t.maxSourceLength??1048576;if(e.length>i)throw Error(`query source length limit exceeded (${i} characters)`);if(e.length+1>n)throw Error(`query token limit exceeded (${n})`);let s=By(e);return new Uy(s,r).parse()}var Mu,ss,Uy,TE=M(()=>{Mu=new Map([["and","AND"],["or","OR"],["not","NOT"],["if","IF"],["then","THEN"],["elif","ELIF"],["else","ELSE"],["end","END"],["as","AS"],["try","TRY"],["catch","CATCH"],["true","TRUE"],["false","FALSE"],["null","NULL"],["reduce","REDUCE"],["foreach","FOREACH"],["label","LABEL"],["break","BREAK"],["def","DEF"]]),ss=new Set(Mu.values()),Uy=class Wy{maxDepth;tokens;pos=0;depth;constructor(t,r,n=0){this.maxDepth=r,this.tokens=t,this.depth=n}peek(t=0){return this.tokens[this.pos+t]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(t){return this.peek().type===t}match(...t){for(let r of t)if(this.check(r))return this.advance();return null}expect(t,r){if(!this.check(t))throw Error(`${r} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}withDepth(t){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return t()}finally{this.depth--}}isFieldNameAfterDot(t=0){let r=this.peek(t),n=this.peek(t+1);return n.type==="STRING"?!0:n.type==="IDENT"||ss.has(n.type)?n.pos===r.pos+1:!1}isIdentLike(){let t=this.peek().type;return t==="IDENT"||ss.has(t)}consumeFieldNameAfterDot(t){let r=this.peek();return r.type==="STRING"||(r.type==="IDENT"||ss.has(r.type))&&r.pos===t.pos+1?this.advance().value:null}parse(){let t=this.parseExpr();if(!this.check("EOF"))throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return t}parseExpr(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePipe()}finally{this.depth--}}parsePattern(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePatternInner()}finally{this.depth--}}parsePatternInner(){if(this.match("LBRACKET")){let n=[];if(!this.check("RBRACKET"))for(n.push(this.parsePattern());this.match("COMMA")&&!this.check("RBRACKET");)n.push(this.parsePattern());return this.expect("RBRACKET","Expected ']' after array pattern"),{type:"array",elements:n}}if(this.match("LBRACE")){let n=[];if(!this.check("RBRACE"))for(n.push(this.parsePatternField());this.match("COMMA")&&!this.check("RBRACE");)n.push(this.parsePatternField());return this.expect("RBRACE","Expected '}' after object pattern"),{type:"object",fields:n}}let t=this.expect("IDENT","Expected variable name in pattern"),r=t.value;if(!r.startsWith("$"))throw Error(`Variable name must start with $ at position ${t.pos}`);return{type:"var",name:r}}parsePatternField(){if(this.match("LPAREN")){let r=this.parseExpr();return this.expect("RPAREN","Expected ')' after computed key"),this.expect("COLON","Expected ':' after computed key"),{key:r,pattern:this.parsePattern()}}let t=this.peek();if(t.type==="IDENT"||ss.has(t.type)){let r=t.value;if(r.startsWith("$")){if(this.advance(),this.match("COLON")){let n=this.parsePattern();return{key:r.slice(1),pattern:n,keyVar:r}}return{key:r.slice(1),pattern:{type:"var",name:r}}}return this.advance(),this.match("COLON")?{key:r,pattern:this.parsePattern()}:{key:r,pattern:{type:"var",name:`$${r}`}}}throw Error(`Expected field name in object pattern at position ${t.pos}`)}parsePipe(){let t=this.parseComma();for(;this.match("PIPE");){let r=this.parseComma();t={type:"Pipe",left:t,right:r}}return t}parseComma(){let t=this.parseVarBind();for(;this.match("COMMA");){let r=this.parseVarBind();t={type:"Comma",left:t,right:r}}return t}parseVarBind(){let t=this.parseUpdate();if(this.match("AS")){let r=this.parsePattern(),n=[];for(;this.check("QUESTION")&&this.peekAhead(1)?.type==="ALT";)this.advance(),this.advance(),n.push(this.parsePattern());this.expect("PIPE","Expected '|' after variable binding");let i=this.parseExpr();return r.type==="var"&&n.length===0?{type:"VarBind",name:r.name,value:t,body:i}:{type:"VarBind",name:r.type==="var"?r.name:"",value:t,body:i,pattern:r.type==="var"?void 0:r,alternatives:n.length>0?n:void 0}}return t}peekAhead(t){let r=this.pos+t;return rthis.parseVarBind()),s=r.get(n.type);if(s)return{type:"UpdateOp",op:s,path:t,value:i}}return t}parseAlt(){let t=this.parseOr();for(;this.match("ALT");){let r=this.parseOr();t={type:"BinaryOp",op:"//",left:t,right:r}}return t}parseOr(){let t=this.parseAnd();for(;this.match("OR");){let r=this.parseAnd();t={type:"BinaryOp",op:"or",left:t,right:r}}return t}parseAnd(){let t=this.parseNot();for(;this.match("AND");){let r=this.parseNot();t={type:"BinaryOp",op:"and",left:t,right:r}}return t}parseNot(){return this.parseComparison()}parseComparison(){let t=this.parseAddSub(),r=new Map([["EQ","=="],["NE","!="],["LT","<"],["LE","<="],["GT",">"],["GE",">="]]),n=this.match("EQ","NE","LT","LE","GT","GE");if(n){let i=r.get(n.type);if(i){let s=this.parseAddSub();t={type:"BinaryOp",op:i,left:t,right:s}}}return t}parseAddSub(){let t=this.parseMulDiv();for(;;)if(this.match("PLUS")){let r=this.parseMulDiv();t={type:"BinaryOp",op:"+",left:t,right:r}}else if(this.match("MINUS")){let r=this.parseMulDiv();t={type:"BinaryOp",op:"-",left:t,right:r}}else break;return t}parseMulDiv(){let t=this.parseUnary();for(;;)if(this.match("STAR")){let r=this.parseUnary();t={type:"BinaryOp",op:"*",left:t,right:r}}else if(this.match("SLASH")){let r=this.parseUnary();t={type:"BinaryOp",op:"/",left:t,right:r}}else if(this.match("PERCENT")){let r=this.parseUnary();t={type:"BinaryOp",op:"%",left:t,right:r}}else break;return t}parseUnary(){let t=0;for(;this.match("MINUS");)if(t++,this.depth+t>this.maxDepth)throw Error(`query parse depth limit exceeded (${this.maxDepth})`);let r=this.parsePostfix();for(;t-- >0;)r={type:"UnaryOp",op:"-",operand:r};return r}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("QUESTION"))t={type:"Optional",expr:t};else if(this.check("DOT")&&this.isFieldNameAfterDot())this.advance(),t={type:"Field",name:this.advance().value,base:t};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))t={type:"Iterate",base:t};else if(this.check("COLON")){this.advance();let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),t={type:"Slice",end:r,base:t}}else{let r=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),t={type:"Slice",start:r,end:n,base:t}}else this.expect("RBRACKET","Expected ']'"),t={type:"Index",index:r,base:t}}else break;return t}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.check("DOT")){let t=this.advance();if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let i=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:i}}let n=this.parseExpr();if(this.match("COLON")){let i=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:n,end:i}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:n}}let r=this.consumeFieldNameAfterDot(t);return r===null?{type:"Identity"}:{type:"Field",name:r}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let t=this.advance().value;return t.includes("\\(")?this.parseStringInterpolation(t):{type:"Literal",value:t}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let t=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:t}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let t=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:t}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let t=this.withDepth(()=>this.parsePostfix()),r;return this.match("CATCH")&&(r=this.withDepth(()=>this.parsePostfix())),{type:"Try",body:t,catch:r}}if(this.match("REDUCE")){let t=this.parseAddSub();this.expect("AS","Expected 'as' after reduce expression");let r=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr();return this.expect("RPAREN","Expected ')' after update expression"),{type:"Reduce",expr:t,varName:r.type==="var"?r.name:"",init:n,update:i,pattern:r.type==="var"?void 0:r}}if(this.match("FOREACH")){let t=this.parseAddSub();this.expect("AS","Expected 'as' after foreach expression");let r=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr(),s;return this.match("SEMICOLON")&&(s=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions"),{type:"Foreach",expr:t,varName:r.type==="var"?r.name:"",init:n,update:i,extract:s,pattern:r.type==="var"?void 0:r}}if(this.match("LABEL")){let t=this.expect("IDENT","Expected label name (e.g., $out)"),r=t.value;if(!r.startsWith("$"))throw Error(`Label name must start with $ at position ${t.pos}`);return this.expect("PIPE","Expected '|' after label name"),{type:"Label",name:r,body:this.parseExpr()}}if(this.match("BREAK")){let t=this.expect("IDENT","Expected label name to break to"),r=t.value;if(!r.startsWith("$"))throw Error(`Break label must start with $ at position ${t.pos}`);return{type:"Break",name:r}}if(this.match("DEF")){let t=this.expect("IDENT","Expected function name after def").value,r=[];if(this.match("LPAREN")){if(!this.check("RPAREN")){let i=this.expect("IDENT","Expected parameter name");for(r.push(i.value);this.match("SEMICOLON");){let s=this.expect("IDENT","Expected parameter name");r.push(s.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let n=this.parseExpr();return this.expect("SEMICOLON","Expected ';' after function body"),{type:"Def",name:t,params:r,funcBody:n,body:this.parseExpr()}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let t=this.advance().value;if(t.startsWith("$"))return{type:"VarRef",name:t};if(this.match("LPAREN")){let r=[];if(!this.check("RPAREN"))for(r.push(this.parseExpr());this.match("SEMICOLON");)r.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:t,args:r}}return{type:"Call",name:t,args:[]}}throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parseObjectConstructionInner()}finally{this.depth--}}parseObjectConstructionInner(){let t=[];if(!this.check("RBRACE"))do{let r,n;if(this.match("LPAREN"))r=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else if(this.isIdentLike()){let i=this.advance().value;this.match("COLON")?(r=i,n=this.parseObjectValue()):(r=i,n={type:"Field",name:i})}else if(this.check("STRING"))r=this.advance().value,this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else throw Error(`Expected object key at position ${this.peek().pos}`);t.push({key:r,value:n})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:t}}parseObjectValue(){let t=this.parseVarBind();for(;this.match("PIPE");){let r=this.parseVarBind();t={type:"Pipe",left:t,right:r}}return t}parseIf(){let t=this.parseExpr();this.expect("THEN","Expected 'then'");let r=this.parseExpr(),n=[];for(;this.match("ELIF");){let s=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let a=this.parseExpr();n.push({cond:s,then:a})}let i;return this.match("ELSE")&&(i=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:t,then:r,elifs:n,else:i}}parseStringInterpolation(t){let r=[],n="",i=0;for(;i0;){let u=t[i];if(u==='"'){for(a+=u,i++;i0&&(a+=u),i++}let o=By(a),l=new Wy(o,this.maxDepth,this.depth);r.push(l.parse())}else n+=t[i],i++;return n&&r.push(n),{type:"StringInterp",parts:r}}}}),IE=M(()=>{_y(),TE()});function RE(e,t,r={}){let n=new st(t,"query JSON output",()=>new C(`output size limit exceeded (${t} bytes)`,r.limitKind??"output_size"));return Fu(n,e,r,0),n.build()}function Fu(e,t,r,n){if(t==null){e.append("null");return}if(typeof t=="boolean"){e.append(String(t));return}if(typeof t=="number"){e.append(Number.isFinite(t)?String(t):"null");return}if(typeof t=="string"){r.raw&&n===0?e.append(t):Nf(e,t);return}let i=r.compact??!1,s=r.indent??2,a=r.useTab?" ":" ".repeat(s);if(Array.isArray(t)){e.append("[");for(let l=0;l0&&e.append(` `).repeat(a,n),e.append("]");return}let o=Object.keys(t);r.sortKeys&&(o=o.sort()),e.append("{");for(let l=0;l0&&e.append(` `).repeat(a,n),e.append("}")}function Nf(e,t){e.append('"');let r=0;for(let n=0;n{Et(),H()}),jy={};re(jy,{flagsForFuzzing:()=>Gy,jqCommand:()=>qy});function DE(e){switch(e){case"\b":return"\\b";case"\f":return"\\f";case` `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`}}function LE(e){let t="",r=!1,n=!1;for(let i=0;i{if(r.length>=t.maxElements)throw new C(`query result element limit exceeded (${t.maxElements})`,"array_elements");r.push(a)},i=0,s=e.length;for(;i=s)break;let a=i,o=e[i];if(o==="{"||o==="["){let l=[o==="{"?"}":"]"],u=!1,c=!1;for(i++;i0;){let p=e[i];if(c)c=!1;else if(p==="\\")c=!0;else if(p==='"')u=!u;else if(!u){if(p==="{"||p==="["){if(l.push(p==="{"?"}":"]"),l.length>t.maxDepth)throw new C(`query depth limit exceeded (${t.maxDepth})`,"recursion")}else if((p==="}"||p==="]")&&l.pop()!==p)throw Error(`Mismatched JSON delimiter at position ${i}`)}i++}if(l.length!==0)throw Error(`Unexpected end of JSON input at position ${i} (unclosed ${o})`);n(ca(Nl(e,a,i),{maxDepth:t.maxDepth,maxElements:t.maxElements}))}else if(o==='"'){let l=!1;for(i++;i="0"&&o<="9"){for(;i{se(),Mr(),H(),vn(),Ar(),ui(),le(),wt(),IE(),PE(),nn(),xo(),$f={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE...]",options:["-R, --raw-input read each line as string instead of JSON","-r, --raw-output output strings without quotes","-c, --compact-output compact instead of pretty-printed output","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --arg NAME VALUE bind $NAME to the string VALUE"," --argjson NAME JSON bind $NAME to the JSON-decoded value JSON"," --rawfile NAME FILE bind $NAME to the raw contents of FILE"," --slurpfile NAME FILE bind $NAME to the array of JSON values in FILE"," --args remaining arguments are string positional args ($ARGS.positional)"," --jsonargs remaining arguments are JSON positional args ($ARGS.positional)"," --help display this help and exit"]},qy={name:"jq",async execute(e,t){Zt(t.requireDefenseContext,"jq","execution entry");let r=(w,E)=>In(t.requireDefenseContext,"jq",w,E);if(he(e))return ce($f);let n=!1,i=!1,s=!1,a=!1,o=!1,l=!1,u=!1,c=!1,p=!1,h=".",f=!1,d="none",m=[],g=new Map,v=[],y=[],x={maxDepth:t.limits.maxQueryDepth,maxElements:t.limits.maxQueryElements};for(let w=0;w0){let w=await r("arg file read",()=>Pa(t,y.map(E=>E.file),{cmdName:"jq",stopOnError:!0}));if(w.exitCode!==0)return{stdout:"",stderr:w.stderr,exitCode:2};for(let E=0;EPa(t,m,{cmdName:"jq",stopOnError:!0}));if(w.exitCode!==0)return{stdout:"",stderr:w.stderr,exitCode:2};b=w.files.map(E=>({source:E.filename||"stdin",content:ke(E.content)}))}try{let w=OE(h,{maxDepth:t.limits.maxQueryDepth,maxTokens:t.limits.maxQueryTokens,maxSourceLength:t.limits.maxStringLength}),E=[],A={limits:t.limits?{maxIterations:t.limits.maxJqIterations,maxStringLength:t.limits.maxStringLength,maxOutputSize:t.limits.maxOutputSize,maxArrayElements:t.limits.maxQueryElements,maxDepth:t.limits.maxQueryDepth}:void 0,env:t.env,namedArgs:g,positionalArgs:v,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext,budget:{operations:0,callDepth:0}},O=(B,j)=>{if(j.length>t.limits.maxQueryElements-B.length)throw new C(`query result element limit exceeded (${t.limits.maxQueryElements})`,"array_elements");for(let P of j)B.push(P)};if(l)E=X(null,w,A);else if(i&&o)E=X(b.map(({content:B})=>B).join(""),w,A);else if(i){let B="";for(let{content:j}of b){let P=B+j,F=0,G=P.indexOf(` `,F);for(;G!==-1;)O(E,X(P.slice(F,G),w,A)),F=G+1,G=P.indexOf(` `,F);B=P.slice(F)}B!==""&&O(E,X(B,w,A))}else if(o){let B=[];for(let{content:j}of b){let P=j.trim();P&&O(B,as(P,x))}E=X(B,w,A)}else for(let{content:B}of b){let j=B.trim();if(!j)continue;let P=as(j,x);for(let F of P)O(E,X(F,w,A))}let N=u?"":` `,D=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),$=[],L=0;for(let B of E){let j=$.length>0?N.length:0,P=+!u,F=D-L-j-P;if(F<0)throw new C(`output size limit exceeded (${D} bytes)`,"string_length");if(ks(B,t.limits.maxQueryDepth+1)>t.limits.maxQueryDepth)throw new C(`query depth limit exceeded (${t.limits.maxQueryDepth})`,"recursion");let G=RE(B,F,{compact:s,raw:n,sortKeys:c,useTab:p,limitKind:"string_length"}),z=q(G);if(L+j+z+P>D)throw new C(`output size limit exceeded (${D} bytes)`,"string_length");L+=j+z,$.push(G)}let _=$.join(N),R=a&&(E.length===0||E.every(B=>B==null||B===!1))?1:0;return{stdout:_?u?_:`${_} `:"",stderr:"",exitCode:R}}catch(w){if(w instanceof Ae)throw w;if(w instanceof C)return{stdout:"",stderr:`jq: ${xt(w.message)} `,exitCode:C.EXIT_CODE};let E=xt(w.message);return E.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${E} `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${E} `,exitCode:5}}}},Gy={name:"jq",flags:[{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-j",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"--tab",type:"boolean"}],stdinType:"json",needsArgs:!0}}),Hy={};re(Hy,{base64Command:()=>Vy,flagsForFuzzing:()=>Zy});function dr(e,t,r,n){if(e>t)throw new C(`base64: ${r} limit exceeded (${t} bytes)`,n)}function Of(e){let t=[];for(let r=0;ru.charCodeAt(0))};let s=[],a=0;for(let u of t){if(u==="-"){dr(a+i.length,n,"input size","string_length"),s.push(Uint8Array.from(i,c=>c.charCodeAt(0))),a+=i.length;continue}try{let c=e.fs.resolvePath(e.cwd,u),p=await e.fs.stat(c);dr(a+p.size,n,"input size","string_length");let h=await e.fs.readFileBuffer(c);dr(a+h.length,n,"input size","string_length"),Rm(e,h.length,r),s.push(h),a+=h.length}catch(c){return Ie(c),{ok:!1,error:{stdout:"",stderr:`${r}: ${u}: No such file or directory `,exitCode:1}}}}let o=new Uint8Array(a),l=0;for(let u of s)o.set(u,l),l+=u.length;return{ok:!0,data:o}}var Rf,Pf,Vy,Zy,FE=M(()=>{se(),Lt(),H(),Ct(),ui(),le(),Rf={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},Pf={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}},Vy={name:"base64",async execute(e,t){if(he(e))return ce(Rf);let r=At("base64",e,Pf);if(!r.ok)return r.error;let n=r.result.flags.decode,i=r.result.flags.wrap,s=r.result.positional;if(!Number.isSafeInteger(i)||i<0)return{stdout:"",stderr:`base64: invalid wrap size `,exitCode:1};try{if(n){let c=await If(t,s,"base64");if(!c.ok)return c.error;if(typeof Buffer<"u"){let d=Buffer.from(c.data).toString("utf8").replace(/\s/g,""),m=Tf(d);dr(m,t.limits.maxStringLength,"decoded size","string_length"),dr(m,t.limits.maxOutputSize,"output size","output_size");let g=Buffer.from(d,"base64");return dr(g.length,t.limits.maxOutputSize,"output size","output_size"),{stdout:g.toString("latin1"),stderr:"",exitCode:0,stdoutEncoding:"binary"}}let p=Of(c.data).replace(/\s/g,""),h=Tf(p);dr(h,t.limits.maxStringLength,"decoded size","string_length"),dr(h,t.limits.maxOutputSize,"output size","output_size");let f=atob(p);return dr(f.length,t.limits.maxOutputSize,"output size","output_size"),{stdout:f,stderr:"",exitCode:0,stdoutEncoding:"binary"}}let a=await If(t,s,"base64");if(!a.ok)return a.error;let o=Math.ceil(a.data.length/3)*4,l=i>0&&o>0?Math.ceil(o/i):0;if(l>t.limits.maxArrayElements)throw new C(`base64: wrapped line limit exceeded (${t.limits.maxArrayElements})`,"array_elements");dr(o,t.limits.maxStringLength,"encoded size","string_length"),dr(o+l,t.limits.maxOutputSize,"output size","output_size");let u;if(u=typeof Buffer<"u"?Buffer.from(a.data).toString("base64"):btoa(Of(a.data)),i>0){let c=[];for(let p=0;p0?` `:"")}return{stdout:u,stderr:"",exitCode:0}}catch(a){return Ie(a),{stdout:"",stderr:`base64: invalid input `,exitCode:1}}}},Zy={name:"base64",flags:[{flag:"-d",type:"boolean"},{flag:"-w",type:"value",valueHint:"number"}],stdinType:"text",needsFiles:!0}}),Qy={};re(Qy,{diffCommand:()=>Ky,flagsForFuzzing:()=>Xy});var Df,Lf,Ky,Xy,_E=M(()=>{se(),Ct(),le(),Df={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},Lf={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},Ky={name:"diff",async execute(e,t){if(he(e))return ce(Df);let r=At("diff",e,Lf);if(!r.ok)return r.error;let n=r.result.flags.brief,i=r.result.flags.reportSame,s=r.result.flags.ignoreCase,a=r.result.positional;if(r.result.flags.unified,a.length<2)return{stdout:"",stderr:`diff: missing operand `,exitCode:2};let o,l,[u,c]=a;try{o=u==="-"?ke(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory `,exitCode:2}}try{l=c==="-"?ke(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory `,exitCode:2}}let p=o,h=l;return s&&(p=p.toLowerCase(),h=h.toLowerCase()),p===h?i?{stdout:`Files ${u} and ${c} are identical `,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:n?{stdout:`Files ${u} and ${c} differ `,stderr:"",exitCode:1}:{stdout:E4(u,c,o,l,"","",{context:3}),stderr:"",exitCode:1}}},Xy={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2}}),Yy={};re(Yy,{dateCommand:()=>Jy,flagsForFuzzing:()=>e7});function zE(e){try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}}function BE(e,t){let r=new Intl.DateTimeFormat("en-US",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(e),n=a=>r.find(o=>o.type===a)?.value??"00",i=Number.parseInt(n("hour"),10)%24,s=new Date(`${n("year")}-${n("month")}-${n("day")}T${String(i).padStart(2,"0")}:${n("minute")}:${n("second")}Z`);return Number.isNaN(s.getTime())?null:s}function UE(e,t){let r=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/);if(!r)return null;let[,n,i,s,a="00",o="00",l="00"]=r,u=new Date(`${n}-${i}-${s}T${a}:${o}:${l}Z`);if(Number.isNaN(u.getTime()))return null;try{let c=u;for(let p=0;p<3;p++){let h=BE(c,t);if(h===null)return null;let f=h.getTime()-u.getTime();if(f===0)return c;c=new Date(c.getTime()-f)}return c}catch{return null}}function WE(e,t){if(e.startsWith("@")){let i=e.slice(1);if(!/^-?\d+$/.test(i))return null;let s=Number(i);if(!Number.isSafeInteger(s))return null;let a=new Date(s*1e3);return Number.isNaN(a.getTime())?null:a}let r=e.toLowerCase().trim();if(r==="now"||r==="today")return new Date;if(r==="yesterday")return new Date(Date.now()-864e5);if(r==="tomorrow")return new Date(Date.now()+864e5);if(t&&!/Z$/i.test(e)&&!/[+-]\d{2}:?\d{2}$/.test(e)){let i=UE(e,t);if(i)return i}let n=new Date(e);return Number.isNaN(n.getTime())?null:n}var Mf,Jy,e7,jE=M(()=>{le(),_m(),Mf={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING, not 'now'","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},Jy={name:"date",async execute(e,t){if(he(e))return ce(Mf);let r=!1,n=null,i=null,s=!1,a=!1;for(let f=0;f{}),n7={};re(n7,{flagsForFuzzing:()=>s7,sleepCommand:()=>i7});var Ff,$l,i7,s7,qE=M(()=>{Wi(),r7(),le(),Ff={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be: s - seconds (default) m - minutes h - hours d - days NUMBER may be a decimal number.`,options:[" --help display this help and exit"]},$l=36e5,i7={name:"sleep",async execute(e,t){if(he(e))return ce(Ff);if(e.length===0)return{stdout:"",stderr:`sleep: missing operand `,exitCode:1};let r=0;for(let n of e){let i=t7(n);if(i===null)return{stdout:"",stderr:`sleep: invalid time interval '${n}' `,exitCode:1};r+=i}if(r>$l&&(r=$l),t.signal?.aborted)return{stdout:"",stderr:"",exitCode:0};if(t.sleep){let n=Promise.resolve(t.sleep(r));if(t.signal){let i,s=new Promise(a=>{i=a,t.signal?.addEventListener("abort",i,{once:!0}),t.signal?.aborted&&a()});try{await Promise.race([n,s])}finally{i&&t.signal.removeEventListener("abort",i)}}else await n}else t.signal?await new Promise(n=>{let i=()=>{oo(s),n()},s=Es(()=>{t.signal?.removeEventListener("abort",i),n()},r);t.signal?.addEventListener("abort",i,{once:!0})}):await new Promise(n=>Es(n,r));return{stdout:"",stderr:"",exitCode:0}}},s7={name:"sleep",flags:[],needsArgs:!0}}),a7={};re(a7,{flagsForFuzzing:()=>l7,timeoutCommand:()=>o7});var _f,o7,l7,GE=M(()=>{$c(),se(),ji(),Wi(),r7(),le(),_f={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION. DURATION is a number with optional suffix: s - seconds (default) m - minutes h - hours d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]},o7={name:"timeout",async execute(e,t){if(he(e))return ce(_f);let r=0;for(let p=0;p1&&h!=="--")if(h.startsWith("-k"))r=p+1;else if(h.startsWith("-s"))r=p+1;else return ve("timeout",h);else{r=p;break}}}let n=e.slice(r);if(n.length===0)return{stdout:"",stderr:`timeout: missing operand `,exitCode:1};let i=n[0],s=t7(i);if(s===null)return{stdout:"",stderr:`timeout: invalid time interval '${i}' `,exitCode:1};let a=n.slice(1);if(a.length===0)return{stdout:"",stderr:`timeout: missing operand `,exitCode:1};if(!t.exec)return{stdout:"",stderr:`timeout: exec not available `,exitCode:1};let o=new AbortController,l=Nc(t.signal,o.signal),u,c;try{let p=new Promise(d=>{c=()=>d({timedOut:!0}),l.signal?.addEventListener("abort",c,{once:!0}),u=Es(()=>{o.abort()},s)}),h=t.exec(ni([a[0]]),{cwd:t.cwd,signal:l.signal,stdin:t.stdin,stdinKind:"bytes",args:a.slice(1)}).then(d=>({timedOut:!1,result:d})),f=await Promise.race([p,h]);return f.timedOut?(await h.catch(()=>{}),{stdout:"",stderr:"",exitCode:124}):f.result}finally{u!==void 0&&oo(u),c&&l.signal?.removeEventListener("abort",c),l.cleanup()}}},l7={name:"timeout",flags:[{flag:"-k",type:"value",valueHint:"string"},{flag:"-s",type:"value",valueHint:"string"},{flag:"--preserve-status",type:"boolean"},{flag:"--foreground",type:"boolean"}],needsArgs:!0,minArgs:2}}),Ns,Vc,u7,Us=M(()=>{globalThis.SharedArrayBuffer,globalThis.Atomics,Ns=performance.now.bind(performance),Vc=globalThis.Headers,u7=globalThis.Proxy}),c7={};re(c7,{flagsForFuzzing:()=>h7,timeCommand:()=>p7});function HE(e){let t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=e%60;return t>0?`${t}:${r.toString().padStart(2,"0")}:${n.toFixed(2).padStart(5,"0")}`:`${r}:${n.toFixed(2).padStart(5,"0")}`}var p7,h7,VE=M(()=>{se(),Mr(),Rn(),ji(),Us(),p7={name:"time",async execute(e,t){let r="%e %M",n=null,i=!1,s=!1,a=0;for(;a=e.length)return{stdout:"",stderr:`time: missing argument to '-f' `,exitCode:1};r=e[a],a++}else if(f==="-o"||f==="--output"){if(a++,a>=e.length)return{stdout:"",stderr:`time: missing argument to '-o' `,exitCode:1};n=e[a],a++}else if(f==="-a"||f==="--append")i=!0,a++;else if(f==="-v"||f==="--verbose")r=`Command being timed: %C Elapsed (wall clock) time: %e seconds Maximum resident set size (kbytes): %M`,a++;else if(f==="-p"||f==="--portability")s=!0,a++;else if(f==="--"){a++;break}else if(f.startsWith("-"))a++;else break}let o=e.slice(a);if(o.length===0)return{stdout:"",stderr:"",exitCode:0};let l=Ns(),u=o.join(" "),c;try{if(!t.exec)return{stdout:"",stderr:`time: exec not available `,exitCode:1};c=await t.exec(ni([o[0]]),{env:Kr(t.env),cwd:t.cwd,stdin:t.stdin,stdinKind:"bytes",signal:t.signal,args:o.slice(1)})}catch(f){c={stdout:"",stderr:`time: ${xt(f.message)} `,exitCode:127}}let p=(Ns()-l)/1e3,h;if(s?h=`real ${p.toFixed(2)} user 0.00 sys 0.00 `:(h=r.replace(/%e/g,p.toFixed(2)).replace(/%E/g,HE(p)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,u),h.endsWith(` `)||(h+=` `)),n)try{let f=t.fs.resolvePath(t.cwd,n);if(i&&await t.fs.exists(f)){let d=await t.fs.readFile(f);await t.fs.writeFile(f,d+h)}else await t.fs.writeFile(f,h)}catch(f){let d=xt(f.message);return{stdout:c.stdout,stderr:c.stderr+`time: cannot write to '${n}': ${d} `,exitCode:c.exitCode}}else c={...c,stderr:c.stderr+h};return c}},h7={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0}}),f7={};re(f7,{flagsForFuzzing:()=>m7,seqCommand:()=>d7});var d7,m7,ZE=M(()=>{Et(),se(),H(),d7={name:"seq",async execute(e,t){let r=` `,n=!1,i=[],s=0;for(;s2){r=x.slice(2),s++;continue}if((x==="-ws"||x==="-sw")&&(n=!0,s+1!Number.isFinite(parseFloat(x)))}' `,exitCode:1};if(o===0)return{stdout:"",stderr:`seq: invalid Zero increment value: '0' `,exitCode:1};let u=[],c=x=>{let b=String(x),w=b.indexOf(".");return w===-1?0:b.length-w-1},p=Math.max(c(a),c(o),c(l)),h=Math.min(t.limits.maxLoopIterations,t.limits.maxArrayElements),f=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),d=q(r),m=0,g=0,v=x=>{if(g>=h)throw new C(`seq: iteration limit exceeded (${h})`,"iterations");let b=ci(ci(m,u.length>0?d:0,"seq"),ci(q(x),1,"seq"),"seq");if(b>f)throw new C(`seq: output size limit exceeded (${f} bytes)`,"output_size");m=b-1,u.push(x),g++};if(o>0)for(let x=a;x<=l+1e-10;x+=o)v(p>0?x.toFixed(p):String(Math.round(x)));else for(let x=a;x>=l-1e-10;x+=o)v(p>0?x.toFixed(p):String(Math.round(x)));if(n&&u.length>0){let x=0;for(let b of u)x=Math.max(x,b.startsWith("-")?b.length-1:b.length);if(ci(ci(u.reduce((b,w)=>ci(b,x+ +!!w.startsWith("-"),"seq"),0),T9(d,Math.max(0,u.length-1),"seq"),"seq"),1,"seq")>f)throw new C(`seq: output size limit exceeded (${f} bytes)`,"output_size");for(let b=0;by7,flagsForFuzzing:()=>x7});function QE(e,t){if(e.length===1)return e[0];let r=0;function n(){let p=i();for(;r","<=",">="].includes(h)){r++;let f=a(),d=parseInt(p,10),m=parseInt(f,10),g=!Number.isNaN(d)&&!Number.isNaN(m),v;v=h==="="?g?d===m:p===f:h==="!="?g?d!==m:p!==f:h==="<"?g?d"?g?d>m:p>f:h==="<="?g?d<=m:p<=f:g?d>=m:p>=f,p=v?"1":"0"}else break}return p}function a(){let p=o();for(;r=e.length)throw Error("syntax error");let p=e[r];if(p==="match"){r++;let h=u(),f=de(u()).match(h);return f?f[1]===void 0?String(f[0].length):f[1]:"0"}if(p==="substr"){r++;let h=u(),f=parseInt(u(),10),d=parseInt(u(),10);if(Number.isNaN(f)||Number.isNaN(d))throw Error("non-integer argument");return h.substring(f-1,f-1+d)}if(p==="index"){r++;let h=u(),f=u();t(f.length+h.length);let d=new Set;for(let m=0;m=e.length||e[r]!==")")throw Error("syntax error");return r++,h}return r++,p}let c=n();if(r!==e.length)throw Error("syntax error");return c}var y7,x7,KE=M(()=>{Lt(),Mr(),at(),y7={name:"expr",async execute(e,t){if(e.length===0)return{stdout:"",stderr:`expr: missing operand `,exitCode:2};try{let r=QE(e,i=>t.executionScope?.consumeWork(i,"expr index")),n=+(r==="0"||r==="");return{stdout:`${r} `,stderr:"",exitCode:n}}catch(r){return Ie(r),{stdout:"",stderr:`expr: ${xt(r.message)} `,exitCode:2}}}},x7={name:"expr",flags:[],needsArgs:!0}});function XE(e){function t(f,d){return f<>>32-d}let r=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],i=e.length*8,s=(e.length%64<56?56:120)-e.length%64,a=new Uint8Array(e.length+s+8);a.set(e),a[e.length]=128;let o=new DataView(a.buffer);o.setUint32(a.length-8,i>>>0,!0),o.setUint32(a.length-4,Math.floor(i/4294967296),!0);let l=1732584193,u=4023233417,c=2562383102,p=271733878;for(let f=0;f>>0,m=y,y=v,v=g,g=g+t(b,n[x])>>>0}l=l+m>>>0,u=u+g>>>0,c=c+v>>>0,p=p+y>>>0}let h=new Uint8Array(16);return new DataView(h.buffer).setUint32(0,l,!0),new DataView(h.buffer).setUint32(4,u,!0),new DataView(h.buffer).setUint32(8,c,!0),new DataView(h.buffer).setUint32(12,p,!0),Array.from(h).map(f=>f.toString(16).padStart(2,"0")).join("")}async function zf(e,t){if(e==="md5")return XE(t);let r=v7.get(e);if(!r)throw Error(`Unknown algorithm: ${e}`);let n=await globalThis.crypto.subtle.digest(r,new Uint8Array(t).buffer);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}function Zc(e,t,r){let n={name:e,summary:r,usage:`${e} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:e,async execute(i,s){if(he(i))return ce(n);let a=!1,o=[];for(let p of i)if(p==="-c"||p==="--check")a=!0;else if(p!=="-b"&&p!=="-t"&&p!=="--binary"&&p!=="--text"){if(p.startsWith("-")&&p!=="-")return ve(e,p);o.push(p)}o.length===0&&o.push("-");let l=async p=>{if(p==="-")return Uint8Array.from(s.stdin,h=>h.charCodeAt(0));try{return await s.fs.readFileBuffer(s.fs.resolvePath(s.cwd,p))}catch{return null}};if(a){let p=0,h="";for(let f of o){let d=f==="-"?ke(s.stdin):await s.fs.readFile(s.fs.resolvePath(s.cwd,f)).catch(()=>null);if(d===null)return{stdout:"",stderr:`${e}: ${f}: No such file or directory `,exitCode:1};for(let m of d.split(` `)){let g=m.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!g)continue;let[,v,y]=g,x=await l(y);if(x===null){h+=`${y}: FAILED open or read `,p++;continue}let b=await zf(t,x)===v.toLowerCase();h+=`${y}: ${b?"OK":"FAILED"} `,b||p++}}return p>0&&(h+=`${e}: WARNING: ${p} computed checksum${p>1?"s":""} did NOT match `),{stdout:h,stderr:"",exitCode:+(p>0)}}let u="",c=0;for(let p of o){let h=await l(p);if(h===null){u+=`${e}: ${p}: No such file or directory `,c=1;continue}u+=`${await zf(t,h)} ${p} `}return{stdout:u,stderr:"",exitCode:c}}}}var v7,Qc=M(()=>{se(),le(),v7=new Map([["sha1","SHA-1"],["sha256","SHA-256"]])}),b7={};re(b7,{flagsForFuzzing:()=>E7,md5sumCommand:()=>w7});var w7,E7,YE=M(()=>{Qc(),w7=Zc("md5sum","md5","compute MD5 message digest"),E7={name:"md5sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}}),S7={};re(S7,{flagsForFuzzing:()=>C7,sha1sumCommand:()=>A7});var A7,C7,JE=M(()=>{Qc(),A7=Zc("sha1sum","sha1","compute SHA1 message digest"),C7={name:"sha1sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}}),k7={};re(k7,{flagsForFuzzing:()=>$7,sha256sumCommand:()=>N7});var N7,$7,eS=M(()=>{Qc(),N7=Zc("sha256sum","sha256","compute SHA256 message digest"),$7={name:"sha256sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}}),tS=ao(e=>{e.read=function(t,r,n,i,s){var a,o,l=s*8-i-1,u=(1<>1,p=-7,h=n?s-1:0,f=n?-1:1,d=t[r+h];for(h+=f,a=d&(1<<-p)-1,d>>=-p,p+=l;p>0;a=a*256+t[r+h],h+=f,p-=8);for(o=a&(1<<-p)-1,a>>=-p,p+=i;p>0;o=o*256+t[r+h],h+=f,p-=8);if(a===0)a=1-c;else{if(a===u)return o?NaN:1/0*(d?-1:1);o+=2**i,a-=c}return(d?-1:1)*o*2**(a-i)},e.write=function(t,r,n,i,s,a){var o,l,u,c=a*8-s-1,p=(1<>1,f=s===23?2**-24-2**-77:0,d=i?0:a-1,m=i?1:-1,g=+(r<0||r===0&&1/r<0);for(r=Math.abs(r),isNaN(r)||r===1/0?(l=+!!isNaN(r),o=p):(o=Math.floor(Math.log(r)/Math.LN2),r*(u=2**-o)<1&&(o--,u*=2),o+h>=1?r+=f/u:r+=f*2**(1-h),r*u>=2&&(o++,u/=2),o+h>=p?(l=0,o=p):o+h>=1?(l=(r*u-1)*2**s,o+=h):(l=r*2**(h-1)*2**s,o=0));s>=8;t[n+d]=l&255,d+=m,l/=256,s-=8);for(o=o<0;t[n+d]=o&255,d+=m,o/=256,c-=8);t[n+d-m]|=g*128}});function rS(){if(!(typeof globalThis.TextDecoder>"u"))return cS??=new globalThis.TextDecoder("utf-8")}function nS(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":{let r=rS();return r?r.decode(e):sS(e)}case"utf-16le":return aS(e);case"us-ascii":case"ascii":return oS(e);case"latin1":case"iso-8859-1":return lS(e);case"windows-1252":return uS(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function Kc(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function St(e,t,r){t.push(r),t.length>=ai&&Kc(e,t)}function iS(e,t,r){if(r<=65535){St(e,t,r);return}r-=65536,St(e,t,55296+(r>>10)),St(e,t,56320+(r&1023))}function sS(e){let t=[],r=[],n=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(n=3);n244){St(t,r,yr),n++;continue}if(i<=223){if(n+1>=e.length){St(t,r,yr),n++;continue}let l=e[n+1];if((l&192)!=128){St(t,r,yr),n++;continue}St(t,r,(i&31)<<6|l&63),n+=2;continue}if(i<=239){if(n+2>=e.length){St(t,r,yr),n++;continue}let l=e[n+1],u=e[n+2];if((l&192)!=128||(u&192)!=128||i===224&&l<160||i===237&&l>=160){St(t,r,yr),n++;continue}St(t,r,(i&15)<<12|(l&63)<<6|u&63),n+=3;continue}if(n+3>=e.length){St(t,r,yr),n++;continue}let s=e[n+1],a=e[n+2],o=e[n+3];if((s&192)!=128||(a&192)!=128||(o&192)!=128||i===240&&s<144||i===244&&s>143){St(t,r,yr),n++;continue}iS(t,r,(i&7)<<18|(s&63)<<12|(a&63)<<6|o&63),n+=4}return Kc(t,r),t.join("")}function aS(e){let t=[],r=[],n=e.length,i=0;for(;i+1=55296&&s<=56319){if(i+1=56320&&a<=57343?(St(t,r,s),St(t,r,a),i+=2):St(t,r,yr)}else St(t,r,yr);continue}if(s>=56320&&s<=57343){St(t,r,yr);continue}St(t,r,s)}return i=128&&i<=159?_u[i]:void 0;r+=s??String.fromCharCode(i),r.length>=ai&&(t.push(r),r="")}return r&&t.push(r),t.join("")}var _u,Bf,cS,ai,yr,pS=M(()=>{_u={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},Bf={};for(let[e,t]of Object.entries(_u))Bf[t]=Number.parseInt(e,10);ai=32768,yr=65533});function qt(e){return new DataView(e.buffer,e.byteOffset)}var O7,pt,jn,ht,zu,T7,I7,Hr,vo=M(()=>{pm(tS(),1),pS(),O7={len:1,get(e,t){return qt(e).getUint8(t)},put(e,t,r){return qt(e).setUint8(t,r),t+1}},pt={len:2,get(e,t){return qt(e).getUint16(t,!0)},put(e,t,r){return qt(e).setUint16(t,r,!0),t+2}},jn={len:2,get(e,t){return qt(e).getUint16(t)},put(e,t,r){return qt(e).setUint16(t,r),t+2}},ht={len:4,get(e,t){return qt(e).getUint32(t,!0)},put(e,t,r){return qt(e).setUint32(t,r,!0),t+4}},zu={len:4,get(e,t){return qt(e).getUint32(t)},put(e,t,r){return qt(e).setUint32(t,r),t+4}},T7={len:4,get(e,t){return qt(e).getInt32(t)},put(e,t,r){return qt(e).setInt32(t,r),t+4}},I7={len:8,get(e,t){return qt(e).getBigUint64(t,!0)},put(e,t,r){return qt(e).setBigUint64(t,r,!0),t+8}},Hr=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){return nS(e.subarray(t,t+this.len),this.encoding)}}}),Uf,yt,R7,bo=M(()=>{Uf="End-Of-Stream",yt=class extends Error{constructor(){super(Uf),this.name="EndOfStreamError"}},R7=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}}),hS=M(()=>{}),Xc,Yc=M(()=>{bo(),Xc=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let r=await this.read(e,t);return this.peekQueue.push(e.subarray(0,r)),r}async read(e,t=!1){if(e.length===0)return 0;let r=this.readFromPeekBuffer(e);if(this.endOfStream||(r+=await this.readRemainderFromStream(e.subarray(r),t)),r===0&&!t)throw new yt;return r}readFromPeekBuffer(e){let t=e.length,r=0;for(;this.peekQueue.length>0&&t>0;){let n=this.peekQueue.pop();if(!n)throw Error("peekData should be defined");let i=Math.min(n.length,t);e.set(n.subarray(0,i),r),r+=i,t-=i,i{bo(),hS(),Yc()}),P7,dS=M(()=>{Yc(),P7=class extends Xc{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}}),D7,L7=M(()=>{dS(),D7=class extends P7{async readFromStream(e,t){if(e.length===0)return 0;let r=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return r.done&&(this.endOfStream=r.done),r.value?(e.set(r.value),r.value.length):0}}}),Bu,M7=M(()=>{bo(),Yc(),Bu=class extends Xc{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let r=Math.min(t.length,e.length);return e.set(t.subarray(0,r)),this.buffer=r{L7(),M7()}),Di=M(()=>{bo(),fS(),L7(),M7(),gS()}),wo,Eo=M(()=>{Di(),wo=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,t=this.position){let r=new Uint8Array(e.len);if(await this.readBuffer(r,{position:t})t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position{Eo(),Di(),Wf=256e3,F7=class extends wo{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let r=this.normalizeOptions(e,t),n=r.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(e,t);if(n<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(r.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,r.length),r.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i0){let s=new Uint8Array(r.length+i);return n=await this.peekBuffer(s,{mayBeLess:r.mayBeLess}),e.set(s.subarray(i)),n-i}if(i<0)throw Error("Cannot peek from a negative offset in a stream")}if(r.length>0){try{n=await this.streamReader.peek(e.subarray(0,r.length),r.mayBeLess)}catch(i){if(t?.mayBeLess&&i instanceof yt)return 0;throw i}if(!r.mayBeLess&&n{Di(),Eo(),_7=class extends wo{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let r=await this.peekBuffer(e,t);return this.position+=r,r}async peekBuffer(e,t){let r=this.normalizeOptions(e,t),n=Math.min(this.uint8Array.length-r.position,r.length);if(!r.mayBeLess&&n{Di(),Eo(),z7=class extends wo{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let r=await this.peekBuffer(e,t);return this.position+=r,r}async peekBuffer(e,t){let r=this.normalizeOptions(e,t),n=Math.min(this.blob.size-r.position,r.length);if(!r.mayBeLess&&n{if(await r.close(),i)return i()},new F7(r,n)}function wS(e,t){return new _7(e,t)}function ES(e,t){return new z7(e,t)}var SS=M(()=>{Di(),yS(),xS(),vS(),Di(),Eo()}),AS=ao((e,t)=>{var r=1e3,n=r*60,i=n*60,s=i*24,a=s*7,o=s*365.25;t.exports=function(h,f){f||={};var d=typeof h;if(d==="string"&&h.length>0)return l(h);if(d==="number"&&isFinite(h))return f.long?c(h):u(h);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(h))};function l(h){if(h=String(h),!(h.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(h);if(f){var d=parseFloat(f[1]);switch((f[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return d*o;case"weeks":case"week":case"w":return d*a;case"days":case"day":case"d":return d*s;case"hours":case"hour":case"hrs":case"hr":case"h":return d*i;case"minutes":case"minute":case"mins":case"min":case"m":return d*n;case"seconds":case"second":case"secs":case"sec":case"s":return d*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function u(h){var f=Math.abs(h);return f>=s?Math.round(h/s)+"d":f>=i?Math.round(h/i)+"h":f>=n?Math.round(h/n)+"m":f>=r?Math.round(h/r)+"s":h+"ms"}function c(h){var f=Math.abs(h);return f>=s?p(h,f,s,"day"):f>=i?p(h,f,i,"hour"):f>=n?p(h,f,n,"minute"):f>=r?p(h,f,r,"second"):h+" ms"}function p(h,f,d,m){var g=f>=d*1.5;return Math.round(h/d)+" "+m+(g?"s":"")}}),CS=ao((e,t)=>{function r(n){s.debug=s,s.default=s,s.coerce=p,s.disable=u,s.enable=o,s.enabled=c,s.humanize=AS(),s.destroy=h,Object.keys(n).forEach(f=>{s[f]=n[f]}),s.names=[],s.skips=[],s.formatters={};function i(f){let d=0;for(let m=0;m{if(A==="%%")return"%";E++;let N=s.formatters[O];if(typeof N=="function"){let D=x[E];A=N.call(b,D),x.splice(E,1),E--}return A}),s.formatArgs.call(b,x),(b.log||s.log).apply(b,x)}return y.namespace=f,y.useColors=s.useColors(),y.color=s.selectColor(f),y.extend=a,y.destroy=s.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>m===null?(g!==s.namespaces&&(g=s.namespaces,v=s.enabled(f)),v):m,set:x=>{m=x}}),typeof s.init=="function"&&s.init(y),y}function a(f,d){let m=s(this.namespace+(typeof d>"u"?":":d)+f);return m.log=this.log,m}function o(f){s.save(f),s.namespaces=f,s.names=[],s.skips=[];let d=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let m of d)m[0]==="-"?s.skips.push(m.slice(1)):s.names.push(m)}function l(f,d){let m=0,g=0,v=-1,y=0;for(;m"-"+d)].join(",");return s.enable(""),f}function c(f){for(let d of s.skips)if(l(f,d))return!1;for(let d of s.names)if(l(f,d))return!0;return!1}function p(f){return f instanceof Error?f.stack||f.message:f}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return s.enable(s.load()),s}t.exports=r}),kS=ao((e,t)=>{e.formatArgs=n,e.save=i,e.load=s,e.useColors=r,e.storage=a(),e.destroy=(()=>{let l=!1;return()=>{l||(l=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors="#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33".split(".");function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let l;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(l=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(l[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;let u="color: "+this.color;l.splice(1,0,u,"color: inherit");let c=0,p=0;l[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(c++,h==="%c"&&(p=c))}),l.splice(p,0,u)}e.log=console.debug||console.log||(()=>{});function i(l){try{l?e.storage.setItem("debug",l):e.storage.removeItem("debug")}catch{}}function s(){let l;try{l=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch{}return!l&&typeof process<"u"&&"env"in process&&(l={}.DEBUG),l}function a(){try{return localStorage}catch{}}t.exports=CS()(e);var{formatters:o}=t.exports;o.j=function(l){try{return JSON.stringify(l)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}}),qn,Uu,B7,U7,W7,NS=M(()=>{vo(),qn={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Uu={get(e){return{signature:ht.get(e,0),compressedSize:ht.get(e,8),uncompressedSize:ht.get(e,12)}},len:16},B7={get(e){let t=pt.get(e,6);return{signature:ht.get(e,0),minVersion:pt.get(e,4),dataDescriptor:!!(t&8),compressedMethod:pt.get(e,8),compressedSize:ht.get(e,18),uncompressedSize:ht.get(e,22),filenameLength:pt.get(e,26),extraFieldLength:pt.get(e,28),filename:null}},len:30},U7={get(e){return{signature:ht.get(e,0),nrOfThisDisk:pt.get(e,4),nrOfThisDiskWithTheStart:pt.get(e,6),nrOfEntriesOnThisDisk:pt.get(e,8),nrOfEntriesOfSize:pt.get(e,10),sizeOfCd:ht.get(e,12),offsetOfStartOfCd:ht.get(e,16),zipFileCommentLength:pt.get(e,20)}},len:22},W7={get(e){let t=pt.get(e,8);return{signature:ht.get(e,0),minVersion:pt.get(e,6),dataDescriptor:!!(t&8),compressedMethod:pt.get(e,10),compressedSize:ht.get(e,20),uncompressedSize:ht.get(e,24),filenameLength:pt.get(e,28),extraFieldLength:pt.get(e,30),fileCommentLength:pt.get(e,32),relativeOffsetOfLocalHeader:ht.get(e,42),filename:null}},len:46}});function jf(e){let t=new Uint8Array(ht.len);return ht.put(t,0,e),t}function $S(e,t){let r=e.length,n=t.length;if(n>r)return-1;for(let i=0;i<=r-n;i++){let s=!0;for(let a=0;ai+s.length,0),r=new Uint8Array(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return r}var qf,Nr,ea,Gf,os,ba,TS=M(()=>{vo(),qf=pm(kS(),1),NS(),Nr=(0,qf.default)("tokenizer:inflate"),ea=262144,Gf=jf(qn.DataDescriptor),os=jf(qn.EndOfCentralDirectory),ba=class j7{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(ea)}async isZip(){return await this.peekSignature()===qn.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(ht)}async findEndOfCentralDirectoryLocator(){let t=this.tokenizer,r=Math.min(16384,t.fileInfo.size),n=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(n,{position:t.fileInfo.size-r});for(let i=n.length-4;i>=0;i--)if(n[i]===os[0]&&n[i+1]===os[1]&&n[i+2]===os[2]&&n[i+3]===os[3])return t.fileInfo.size-r+i;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){Nr("Cannot reading central-directory without random-read support");return}Nr("Reading central-directory...");let t=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){Nr("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(U7,r),i=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let s=0;s=0?u:l;if(s.handler){let p=new Uint8Array(c);await this.tokenizer.readBuffer(p),o.push(p)}else await this.tokenizer.ignore(c)}Nr(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),s.handler&&await this.inflate(i,OS(o),s.handler)}else s.handler?(Nr(`Reading compressed-file-data: ${i.compressedSize} bytes`),a=new Uint8Array(i.compressedSize),await this.tokenizer.readBuffer(a),await this.inflate(i,a,s.handler)):(Nr(`Ignoring compressed-file-data: ${i.compressedSize} bytes`),await this.tokenizer.ignore(i.compressedSize));if(Nr(`Reading data-descriptor at pos=${this.tokenizer.position}`),i.dataDescriptor&&(await this.tokenizer.readToken(Uu)).signature!==134695760)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Uu.len}`)}while(!n)}async iterateOverCentralDirectory(t,r){for(let n of t){let i=r(n);if(i.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let s=await this.readLocalFileHeader();if(s){await this.tokenizer.ignore(s.extraFieldLength);let a=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(a),await this.inflate(s,a,i.handler)}}if(i.stop)break}}async inflate(t,r,n){if(t.compressedMethod===0)return n(r);if(t.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);return Nr(`Decompress filename=${t.filename}, compressed-size=${r.length}`),n(await j7.decompressDeflateRaw(r))}static async decompressDeflateRaw(t){let r=new ReadableStream({start(s){s.enqueue(t),s.close()}}),n=new DecompressionStream("deflate-raw"),i=r.pipeThrough(n);try{let s=await new Response(i).arrayBuffer();return new Uint8Array(s)}catch(s){let a=s instanceof Error?`Failed to deflate ZIP entry: ${s.message}`:"Unknown decompression error in ZIP entry";throw TypeError(a)}}async readLocalFileHeader(){let t=await this.tokenizer.peekToken(ht);if(t===qn.LocalFileHeader){let r=await this.tokenizer.readToken(B7);return r.filename=await this.tokenizer.readToken(new Hr(r.filenameLength,"utf-8")),r}if(t===qn.CentralFileHeader)return!1;throw Error(t===3759263696?"Encrypted ZIP":"Unexpected signature")}}}),q7,IS=M(()=>{q7=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let r=new Uint8Array(1024),n=await e.readBuffer(r,{mayBeLess:!0});if(n===0){t.close();return}t.enqueue(r.subarray(0,n))}}).pipeThrough(new DecompressionStream("gzip"))}}}),RS=M(()=>{TS(),IS()});function Hf(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}var PS=M(()=>{new globalThis.TextDecoder("utf8"),new globalThis.TextEncoder,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});function DS(e,t){if(t==="utf-16le"){let r=[];for(let n=0;n>8&255)}return r}if(t==="utf-16be"){let r=[];for(let n=0;n>8&255,i&255)}return r}return[...e].map(r=>r.charCodeAt(0))}function LS(e,t=0){let r=Number.parseInt(new Hr(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=256;for(let i=t;i{vo(),G7={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}}),H7,V7,FS=M(()=>{H7="jpg,png,apng,gif,webp,flif,xcf,cr2,cr3,orf,arw,dng,nef,rw2,raf,tif,bmp,icns,jxr,psd,indd,zip,tar,rar,gz,bz2,7z,dmg,mp4,mid,mkv,webm,mov,avi,mpg,mp2,mp3,m4a,oga,ogg,ogv,opus,flac,wav,spx,amr,pdf,epub,elf,macho,exe,swf,rtf,wasm,woff,woff2,eot,ttf,otf,ttc,ico,flv,ps,xz,sqlite,nes,crx,xpi,cab,deb,ar,rpm,Z,lz,cfb,mxf,mts,blend,bpg,docx,pptx,xlsx,3gp,3g2,j2c,jp2,jpm,jpx,mj2,aif,qcp,odt,ods,odp,xml,mobi,heic,cur,ktx,ape,wv,dcm,ics,glb,pcap,dsf,lnk,alias,voc,ac3,m4v,m4p,m4b,f4v,f4p,f4b,f4a,mie,asf,ogm,ogx,mpc,arrow,shp,aac,mp1,it,s3m,xm,skp,avif,eps,lzh,pgp,asar,stl,chm,3mf,zst,jxl,vcf,jls,pst,dwg,parquet,class,arj,cpio,ace,avro,icc,fbx,vsdx,vtt,apk,drc,lz4,potx,xltx,dotx,xltm,ott,ots,otp,odg,otg,xlsm,docm,dotm,potm,pptm,jar,jmp,rm,sav,ppsm,ppsx,tar.gz,reg,dat".split(","),V7="image/jpeg,image/png,image/gif,image/webp,image/flif,image/x-xcf,image/x-canon-cr2,image/x-canon-cr3,image/tiff,image/bmp,image/vnd.ms-photo,image/vnd.adobe.photoshop,application/x-indesign,application/epub+zip,application/x-xpinstall,application/vnd.ms-powerpoint.slideshow.macroenabled.12,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/zip,application/x-tar,application/x-rar-compressed,application/gzip,application/x-bzip2,application/x-7z-compressed,application/x-apple-diskimage,application/vnd.apache.arrow.file,video/mp4,audio/midi,video/matroska,video/webm,video/quicktime,video/vnd.avi,audio/wav,audio/qcelp,audio/x-ms-asf,video/x-ms-asf,application/vnd.ms-asf,video/mpeg,video/3gpp,audio/mpeg,audio/mp4,video/ogg,audio/ogg,audio/ogg; codecs=opus,application/ogg,audio/flac,audio/ape,audio/wavpack,audio/amr,application/pdf,application/x-elf,application/x-mach-binary,application/x-msdownload,application/x-shockwave-flash,application/rtf,application/wasm,font/woff,font/woff2,application/vnd.ms-fontobject,font/ttf,font/otf,font/collection,image/x-icon,video/x-flv,application/postscript,application/eps,application/x-xz,application/x-sqlite3,application/x-nintendo-nes-rom,application/x-google-chrome-extension,application/vnd.ms-cab-compressed,application/x-deb,application/x-unix-archive,application/x-rpm,application/x-compress,application/x-lzip,application/x-cfb,application/x-mie,application/mxf,video/mp2t,application/x-blender,image/bpg,image/j2c,image/jp2,image/jpx,image/jpm,image/mj2,audio/aiff,application/xml,application/x-mobipocket-ebook,image/heif,image/heif-sequence,image/heic,image/heic-sequence,image/icns,image/ktx,application/dicom,audio/x-musepack,text/calendar,text/vcard,text/vtt,model/gltf-binary,application/vnd.tcpdump.pcap,audio/x-dsf,application/x.ms.shortcut,application/x.apple.alias,audio/x-voc,audio/vnd.dolby.dd-raw,audio/x-m4a,image/apng,image/x-olympus-orf,image/x-sony-arw,image/x-adobe-dng,image/x-nikon-nef,image/x-panasonic-rw2,image/x-fujifilm-raf,video/x-m4v,video/3gpp2,application/x-esri-shape,audio/aac,audio/x-it,audio/x-s3m,audio/x-xm,video/MP1S,video/MP2P,application/vnd.sketchup.skp,image/avif,application/x-lzh-compressed,application/pgp-encrypted,application/x-asar,model/stl,application/vnd.ms-htmlhelp,model/3mf,image/jxl,application/zstd,image/jls,application/vnd.ms-outlook,image/vnd.dwg,application/vnd.apache.parquet,application/java-vm,application/x-arj,application/x-cpio,application/x-ace-compressed,application/avro,application/vnd.iccprofile,application/x.autodesk.fbx,application/vnd.visio,application/vnd.android.package-archive,application/vnd.google.draco,application/x-lz4,application/vnd.openxmlformats-officedocument.presentationml.template,application/vnd.openxmlformats-officedocument.spreadsheetml.template,application/vnd.openxmlformats-officedocument.wordprocessingml.template,application/vnd.ms-excel.template.macroenabled.12,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.spreadsheet-template,application/vnd.oasis.opendocument.presentation-template,application/vnd.oasis.opendocument.graphics,application/vnd.oasis.opendocument.graphics-template,application/vnd.ms-excel.sheet.macroenabled.12,application/vnd.ms-word.document.macroenabled.12,application/vnd.ms-word.template.macroenabled.12,application/vnd.ms-powerpoint.template.macroenabled.12,application/vnd.ms-powerpoint.presentation.macroenabled.12,application/java-archive,application/vnd.rn-realmedia,application/x-spss-sav,application/x-ms-regedit,application/x-ft-windows-registry-hive,application/x-jmp-data".split(",")});function _S(e){let t=e?.streamReader;if(t?.constructor?.name!=="WebStreamByobReader")return e;let{reader:r}=t,n=async()=>{await r.cancel(),r.releaseLock()};return t.close=n,t.abort=async()=>{t.interrupted=!0,await n()},e}function Jc(e,t,r){if(!Number.isFinite(e)||e<0||e>t)throw new An(`${r} has invalid size ${e} (maximum ${t} bytes)`);return e}async function Sn(e,t,{maximumLength:r=nr,reason:n="skip"}={}){let i=Jc(t,r,n);await e.ignore(i)}async function Ol(e,t,r,{maximumLength:n=t.length,reason:i="read"}={}){let s=Jc(r?.length??t.length,n,i);return e.readBuffer(t,{...r,length:s})}async function zS(e,{maximumLength:t=Pr}={}){let r=new ReadableStream({start(o){o.enqueue(e),o.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),n=[],i=0;try{for(;;){let{done:o,value:l}=await r.read();if(o)break;if(i+=l.length,i>t)throw await r.cancel(),Error(`ZIP entry decompressed data exceeds ${t} bytes`);n.push(l)}}finally{r.releaseLock()}let s=new Uint8Array(i),a=0;for(let o of n)s.set(o,a),a+=o.length;return s}function BS(e,t){if(e.length=0?0:o===i?Math.min(J7,o-1):0,c=l>=0?l:o-u;if(c===0)break;if(a+=c,a>r)throw Error(`ZIP entry compressed data exceeds ${r} bytes`);if(t){let p=new Uint8Array(c);await e.tokenizer.readBuffer(p),s.push(p)}else await e.tokenizer.ignore(c);if(l>=0)break}if(jt(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=a),t)return WS(s,a)}function qS(e,t){return jt(e.tokenizer)?Math.max(0,nr-(e.tokenizer.position-t)):Math.max(0,Pr-e.knownSizeDescriptorScannedBytes)}async function GS(e,t,{shouldBuffer:r,maximumDescriptorLength:n=Pr}={}){if(t.dataDescriptor&&t.compressedSize===0)return jS(e,{shouldBuffer:r,maximumLength:n});if(!r){await Sn(e.tokenizer,t.compressedSize,{maximumLength:jt(e.tokenizer)?Pr:e.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}let i=YS(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>i)throw Error(`ZIP entry compressed data exceeds ${i} bytes`);let s=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(s),s}function HS(e,t){let r=e.getReader(),n=0,i=!1,s=!1,a=async o=>{i||s||(s=!0,await r.cancel(o))};return new ReadableStream({async pull(o){if(n>=t){o.close(),await a();return}let{done:l,value:u}=await r.read();if(l||!u){i=!0,o.close();return}let c=t-n;if(u.length>c){o.enqueue(u.subarray(0,c)),n+=c,o.close(),await a();return}o.enqueue(u),n+=u.length},async cancel(o){await a(o)}})}async function VS(e,t){return new ex(t).fromBuffer(e)}function Vf(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function Wr(e,t,r){r={offset:0,...r};for(let[n,i]of t.entries())if(r.mask){if(i!==(r.mask[n]&e[n+r.offset]))return!1}else if(i!==e[n+r.offset])return!1;return!0}function ZS(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):Ai}function QS(e,t,r){return r===void 0?e.read(t):(r.throwIfAborted(),new Promise((n,i)=>{let s=()=>{r.removeEventListener("abort",a)},a=()=>{let o=r.reason;s(),(async()=>{try{await e.cancel(o)}catch{}})(),i(o)};r.addEventListener("abort",a,{once:!0}),(async()=>{try{let o=await e.read(t);s(),n(o)}catch(o){s(),i(o)}})()}))}function KS(e){return Number.isFinite(e)?Math.max(0,Math.min(Z7,Math.trunc(e))):0}function XS(e){return Number.isFinite(e)?Math.max(0,e):2**53-1}function jt(e){let t=e.fileInfo.size;return!Number.isFinite(t)||t===2**53-1}function ls(e,t,r){return jt(e)&&e.position-t>r}function YS(e){let t=e.fileInfo.size,r=Number.isFinite(t)?Math.max(0,t-e.position):2**53-1;return Math.min(r,Q7)}function JS(e){if(e instanceof yt||e instanceof An)return!0;if(!(e instanceof Error))return!1;if(K7.has(e.message)||Y7.has(e.code))return!0;for(let t of X7)if(e.message.startsWith(t))return!0;return!1}function Zf(e,t=Pr){let r=[e.compressedSize,e.uncompressedSize];for(let n of r)if(!Number.isFinite(n)||n<0||n>t)return!1;return!0}function eA(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function tA(e,t){t.startsWith("word/")&&(e.hasWordDirectory=!0),t.startsWith("ppt/")&&(e.hasPresentationDirectory=!0),t.startsWith("xl/")&&(e.hasSpreadsheetDirectory=!0),t.startsWith("3D/")&&t.endsWith(".model")&&(e.hasThreeDimensionalModelEntry=!0)}function Qf(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(e.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(e.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(e.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function rA(e){let t=e.indexOf('.main+xml"');if(t===-1){let i="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return e.includes(`ContentType="${i}"`)?i:void 0}let r=e.slice(0,t),n=r.lastIndexOf('"');return r.slice(n+1)}var Ai,Z7,Pr,Tl,Q7,nr,us,Il,Kf,Xf,Rl,ta,Pl,Dl,Yf,Jf,ed,td,rd,Ll,Ml,Fl,nd,_l,K7,X7,Y7,An,Wu,xs,J7,ex,nA=M(()=>{vo(),SS(),RS(),PS(),MS(),FS(),Ai=4100,Z7=Ai-2,Pr=1048576,Tl=1024,Q7=2**31-1,nr=16777216,us=Pr,Il=Pr,Kf=nr,Xf=1,Rl=100,ta=nr,Pl=64,Dl=us,Yf=256,Jf=512,ed=nr,td=512,rd=512,Ll=256,Ml=us,Fl=us,nd=us,_l=nr,K7=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),X7=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],Y7=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]),An=class extends Error{},Wu=134695760,xs=16,J7=xs-1,ba.prototype.inflate=async function(e,t,r){if(e.compressedMethod===0)return r(t);if(e.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);return r(await zS(t,{maximumLength:Pr}))},ba.prototype.unzip=async function(e){let t=!1,r=0,n=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(ls(this.tokenizer,n,nr))throw new An(`ZIP stream probing exceeds ${nr} bytes`);let i=await this.readLocalFileHeader();if(!i)break;if(r++,r>Tl)throw Error(`ZIP entry count exceeds ${Tl}`);let s=e(i);t=!!s.stop,await this.tokenizer.ignore(i.extraFieldLength);let a=await GS(this,i,{shouldBuffer:!!s.handler,maximumDescriptorLength:Math.min(Pr,qS(this,n))});if(s.handler&&await this.inflate(i,a,s.handler),i.dataDescriptor){let o=new Uint8Array(xs);if(await this.tokenizer.readBuffer(o),ht.get(o,0)!==Wu)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-o.length}`)}if(ls(this.tokenizer,n,nr))throw new An(`ZIP stream probing exceeds ${nr} bytes`)}while(!t)},ex=class tx{constructor(t){let r=KS(t?.mpegOffsetTolerance);this.options={...t,mpegOffsetTolerance:r},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(t){return _S(bS(t,this.getTokenizerOptions()))}async parseTokenizer(t,r=0){this.detectionReentryCount=r;let n=t.position;for(let i of this.detectors){let s;try{s=await i.detect(t)}catch(a){if(a instanceof yt||a instanceof An)return;throw a}if(s)return s;if(n!==t.position)return}}async fromTokenizer(t){try{return await this.parseTokenizer(t)}finally{await t.close()}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);let r=t instanceof Uint8Array?t:new Uint8Array(t);if(r?.length>1)return this.fromTokenizer(wS(r,this.getTokenizerOptions()))}async fromBlob(t){this.options.signal?.throwIfAborted();let r=ES(t,this.getTokenizerOptions());return this.fromTokenizer(r)}async fromStream(t){this.options.signal?.throwIfAborted();let r=this.createTokenizerFromWebStream(t);return this.fromTokenizer(r)}async toDetectionStream(t,r){let n=ZS(r?.sampleSize??Ai),i,s,a=t.getReader({mode:"byob"});try{let{value:u,done:c}=await QS(a,new Uint8Array(n),this.options.signal);if(s=u,!c&&u)try{i=await this.fromBuffer(u.subarray(0,n))}catch(p){if(!(p instanceof yt))throw p;i=void 0}s=u}finally{a.releaseLock()}let o=new TransformStream({async start(u){u.enqueue(s)},transform(u,c){c.enqueue(u)}}),l=t.pipeThrough(o);return l.fileType=i,l}async detectGzip(t){if(this.gzipProbeDepth>=Xf)return{ext:"gz",mime:"application/gzip"};let r=HS(new q7(t).inflate(),Kf),n=jt(t),i,s,a,o;if(n){let l=new AbortController;i=setTimeout(()=>{l.abort(new DOMException(`Operation timed out after ${Rl} ms`,"TimeoutError"))},Rl),s=this.options.signal===void 0?l.signal:AbortSignal.any([this.options.signal,l.signal]),a=new tx({...this.options,signal:s}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{o=await(a??this).fromStream(r)}catch(l){if(l?.name==="AbortError"&&s?.reason?.name!=="TimeoutError")throw l}finally{clearTimeout(i),n||this.gzipProbeDepth--}return o?.ext==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(t,r){return Wr(this.buffer,t,r)}checkString(t,r){return this.check(DS(t,r?.encoding),r)}detectConfident=async t=>{if(this.buffer=new Uint8Array(Ai),t.fileInfo.size===void 0&&(t.fileInfo.size=2**53-1),this.tokenizer=t,jt(t)&&(await t.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(t);if(await t.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await t.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=Ll?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(t));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(t);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Sn(t,6,{maximumLength:6,reason:"ID3 header prefix"});let r=await t.readToken(G7),n=jt(t);if(!Number.isFinite(r)||r<0||n&&(r>ta||t.position+r>ta))return;if(t.position+r>t.fileInfo.size)return n?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Sn(t,r,{maximumLength:n?ta:t.fileInfo.size,reason:"ID3 payload"})}catch(i){if(i instanceof yt)return;throw i}return this.detectionReentryCount>=Ll?void 0:(this.detectionReentryCount++,this.parseTokenizer(t,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let r,n=eA();try{await new ba(t).unzip(i=>{tA(n,i.filename);let s=i.filename==="[Content_Types].xml",a=Qf(n);if(!s&&a)return r=a,{stop:!0};switch(i.filename){case"META-INF/mozilla.rsa":return r={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return r={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return Zf(i,Il)?{async handler(o){r=Vf(new TextDecoder("utf-8").decode(o).trim())},stop:!0}:{};case"[Content_Types].xml":return n.hasContentTypesEntry=!0,Zf(i,Il)?(n.isParsingContentTypes=!0,{async handler(o){let l=rA(new TextDecoder("utf-8").decode(o));l&&(r=Vf(l)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(i.filename)?(r={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(i){if(!JS(i))throw i;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return r??Qf(n)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let r=new Uint8Array(8);return await t.readBuffer(r),Wr(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Wr(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Wr(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Wr(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Wr(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Wr(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){let r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){let o=await t.peekNumber(O7),l=128,u=0;for(;(o&l)===0&&l!==0;)++u,l>>=1;let c=new Uint8Array(u+1);return await Ol(t,c,void 0,{maximumLength:c.length,reason:"EBML field"}),c}async function n(){let o=await r(),l=await r();l[0]^=128>>l.length-1;let u=Math.min(6,l.length),c=new DataView(o.buffer),p=new DataView(l.buffer,l.length-u,u);return{id:Hf(c),len:Hf(p)}}async function i(o){let l=0;for(;o>0;){if(l++,l>Yf||ls(t,a,nr))return;let u=t.position,c=await n();if(c.id===17026){if(c.len>Pl)return;let p=Jc(c.len,Pl,"EBML DocType");return(await t.readToken(new Hr(p))).replaceAll(/\00.*$/g,"")}if(jt(t)&&(!Number.isFinite(c.len)||c.len<0||c.len>Dl)||(await Sn(t,c.len,{maximumLength:jt(t)?Dl:t.fileInfo.size,reason:"EBML payload"}),--o,t.position<=u))return}}let s=await n(),a=t.position;switch(await i(s.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){let r=zu.get(this.buffer,4),n=jn.get(this.buffer,6);if(r>0&&r<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(n>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!"))return await t.ignore(8),await t.readToken(new Hr(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[` `,"\r"," "," ","\0"].some(r=>this.checkString(r,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){let r={ext:"png",mime:"image/png"},n={ext:"apng",mime:"image/apng"};await t.ignore(8);async function i(){return{length:await t.readToken(T7),type:await t.readToken(new Hr(4,"latin1"))}}let s=jt(t),a=t.position,o=0,l=!1;do{if(o++,o>Jf||ls(t,a,ed))break;let u=t.position,c=await i();if(c.length<0)return;if(c.type==="IHDR"){if(c.length!==13)return;l=!0}switch(c.type){case"IDAT":return r;case"acTL":return n;default:if(!l&&c.type!=="CgBI")return;if(s&&c.length>Ml)return l&&US(c.type)?r:void 0;try{await Sn(t,c.length+4,{maximumLength:s?Ml+4:t.fileInfo.size,reason:"PNG chunk payload"})}catch(p){if(!s&&(p instanceof An||p instanceof yt))return r;throw p}}if(t.position<=u)break}while(t.position+8td||ls(t,s,nr)));){let o=t.position,l=await n(),u=l.size-24;if(!Number.isFinite(u)||u<0){r=!0;break}if(Wr(l.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let c=new Uint8Array(16);if(u-=await Ol(t,c,void 0,{maximumLength:c.length,reason:"ASF stream type GUID"}),Wr(c,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Wr(c,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(i&&u>Fl){r=!0;break}if(await Sn(t,u,{maximumLength:i?Fl:t.fileInfo.size,reason:"ASF header payload"}),t.position<=o){r=!0;break}}}catch(n){if(n instanceof yt||n instanceof An)jt(t)&&(r=!0);else throw n}return r?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await t.ignore(20),await t.readToken(new Hr(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("=16){let r=new DataView(this.buffer.buffer).getUint32(12,!0);if(r>12&&this.buffer.length>=r+16)try{let n=new TextDecoder().decode(this.buffer.subarray(16,r+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await t.peekBuffer(this.buffer,{length:Math.min(512,t.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&LS(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let r="utf-16le";return this.checkString("{this.buffer=new Uint8Array(Ai);let r=XS(t.fileInfo.size);if(await t.peekBuffer(this.buffer,{length:Math.min(8,r),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await t.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,r),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let n=0;n<=this.options.mpegOffsetTolerance;++n){let i=this.scanMpeg(n);if(i)return i}};async readTiffTag(t){let r=await this.tokenizer.readToken(t?jn:pt);switch(await this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(t){let r=await this.tokenizer.readToken(t?jn:pt);if(!(r>rd)&&!(jt(this.tokenizer)&&2+r*12>_l))for(let n=0;n=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i>=8){let o=(t?jn:pt).get(this.buffer,8),l=(t?jn:pt).get(this.buffer,10);if(o===28&&l===254||o===31&&l===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(jt(this.tokenizer)&&i>nd)return r;let s=jt(this.tokenizer)?_l:this.tokenizer.fileInfo.size;try{await Sn(this.tokenizer,i,{maximumLength:s,reason:"TIFF IFD offset"})}catch(o){if(o instanceof yt)return;throw o}let a;try{a=await this.readTiffIFD(t)}catch(o){if(o instanceof yt)return;throw o}return a??r}if(n===43)return r}scanMpeg(t){if(this.check([255,224],{offset:t,mask:[255,224]})){if(this.check([16],{offset:t+1,mask:[22]}))return this.check([8],{offset:t+1,mask:[8]}),{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:t+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:t+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:t+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},new Set(H7),new Set(V7)}),rx={};re(rx,{fileCommand:()=>sx,flagsForFuzzing:()=>ax});function iA(e,t){let r=ix.get(e);if(r)return r;let[n,i]=t.split("/"),s=i?.split("+")[0]?.replace(/-/g," ")||e;switch(n){case"image":return`${s.toUpperCase()} image data`;case"audio":return`${s.toUpperCase()} audio`;case"video":return`${s.toUpperCase()} video`;case"font":return`${s} font`;case"model":return`${s} 3D model`;case"application":return i?.includes("zip")||i?.includes("compressed")?`${s} archive data`:i?.includes("executable")?`${s} executable`:`${e.toUpperCase()} data`;default:return`${e.toUpperCase()} data`}}function sA(e){let t=e.split("/").pop()||e;if(t.startsWith(".")&&!t.includes(".",1))return t;let r=t.lastIndexOf(".");return r===-1||r===0?"":t.slice(r).toLowerCase()}function aA(e,t){if(e.startsWith("#!")){let u=e.split(` `)[0];return u.includes("python")?{description:"Python script, ASCII text executable",mime:"text/x-python"}:u.includes("node")||u.includes("bun")||u.includes("deno")?{description:"JavaScript script, ASCII text executable",mime:"text/javascript"}:u.includes("bash")?{description:"Bourne-Again shell script, ASCII text executable",mime:"text/x-shellscript"}:u.includes("sh")?{description:"POSIX shell script, ASCII text executable",mime:"text/x-shellscript"}:u.includes("ruby")?{description:"Ruby script, ASCII text executable",mime:"text/x-ruby"}:u.includes("perl")?{description:"Perl script, ASCII text executable",mime:"text/x-perl"}:{description:"script, ASCII text executable",mime:"text/plain"}}let r=e.trimStart();if(r.startsWith("127){l=!0;break}return l?{description:`UTF-8 Unicode text${s}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${s}`,mime:"text/plain"}}async function oA(e,t){if(t.length===0)return{description:"empty",mime:"inode/x-empty"};let r=await VS(t);return r?{description:iA(r.ext,r.mime),mime:r.mime}:aA(new TextDecoder("utf-8",{fatal:!1}).decode(t),e)}var id,nx,ix,sx,ax,lA=M(()=>{nA(),Et(),Lt(),le(),id={name:"file",summary:"determine file type",usage:"file [OPTION]... FILE...",options:["-b, --brief do not prepend filenames to output","-i, --mime output MIME type strings","-L, --dereference follow symlinks"," --help display this help and exit"]},nx=new Map([[".js",{description:"JavaScript source",mime:"text/javascript"}],[".mjs",{description:"JavaScript module",mime:"text/javascript"}],[".cjs",{description:"CommonJS module",mime:"text/javascript"}],[".ts",{description:"TypeScript source",mime:"text/typescript"}],[".tsx",{description:"TypeScript JSX source",mime:"text/typescript"}],[".jsx",{description:"JavaScript JSX source",mime:"text/javascript"}],[".py",{description:"Python script",mime:"text/x-python"}],[".rb",{description:"Ruby script",mime:"text/x-ruby"}],[".go",{description:"Go source",mime:"text/x-go"}],[".rs",{description:"Rust source",mime:"text/x-rust"}],[".c",{description:"C source",mime:"text/x-c"}],[".h",{description:"C header",mime:"text/x-c"}],[".cpp",{description:"C++ source",mime:"text/x-c++"}],[".hpp",{description:"C++ header",mime:"text/x-c++"}],[".java",{description:"Java source",mime:"text/x-java"}],[".sh",{description:"Bourne-Again shell script",mime:"text/x-shellscript"}],[".bash",{description:"Bourne-Again shell script",mime:"text/x-shellscript"}],[".zsh",{description:"Zsh shell script",mime:"text/x-shellscript"}],[".json",{description:"JSON data",mime:"application/json"}],[".yaml",{description:"YAML data",mime:"text/yaml"}],[".yml",{description:"YAML data",mime:"text/yaml"}],[".xml",{description:"XML document",mime:"application/xml"}],[".csv",{description:"CSV text",mime:"text/csv"}],[".toml",{description:"TOML data",mime:"text/toml"}],[".html",{description:"HTML document",mime:"text/html"}],[".htm",{description:"HTML document",mime:"text/html"}],[".css",{description:"CSS stylesheet",mime:"text/css"}],[".svg",{description:"SVG image",mime:"image/svg+xml"}],[".md",{description:"Markdown document",mime:"text/markdown"}],[".markdown",{description:"Markdown document",mime:"text/markdown"}],[".txt",{description:"ASCII text",mime:"text/plain"}],[".rst",{description:"reStructuredText",mime:"text/x-rst"}],[".env",{description:"ASCII text",mime:"text/plain"}],[".gitignore",{description:"ASCII text",mime:"text/plain"}],[".dockerignore",{description:"ASCII text",mime:"text/plain"}]]),ix=new Map([["jpg","JPEG image data"],["jpeg","JPEG image data"],["png","PNG image data"],["gif","GIF image data"],["webp","WebP image data"],["bmp","PC bitmap"],["ico","MS Windows icon resource"],["tif","TIFF image data"],["tiff","TIFF image data"],["psd","Adobe Photoshop Document"],["avif","AVIF image"],["heic","HEIC image"],["heif","HEIF image"],["jxl","JPEG XL image"],["icns","Mac OS X icon"],["svg","SVG Scalable Vector Graphics image"],["pdf","PDF document"],["epub","EPUB document"],["mobi","Mobipocket E-book"],["djvu","DjVu document"],["zip","Zip archive data"],["gz","gzip compressed data"],["gzip","gzip compressed data"],["bz2","bzip2 compressed data"],["xz","XZ compressed data"],["tar","POSIX tar archive"],["rar","RAR archive data"],["7z","7-zip archive data"],["lz","lzip compressed data"],["lzma","LZMA compressed data"],["zst","Zstandard compressed data"],["cab","Microsoft Cabinet archive"],["ar","Unix ar archive"],["rpm","RPM package"],["deb","Debian binary package"],["apk","Android Package"],["dmg","Apple disk image"],["iso","ISO 9660 CD-ROM filesystem data"],["vhd","Microsoft Virtual Hard Disk"],["vhdx","Microsoft Virtual Hard Disk (new format)"],["qcow2","QEMU QCOW Image"],["mp3","Audio file with ID3"],["m4a","MPEG-4 audio"],["aac","AAC audio"],["wav","RIFF (little-endian) data, WAVE audio"],["flac","FLAC audio bitstream data"],["ogg","Ogg data"],["oga","Ogg audio"],["opus","Ogg Opus audio"],["aiff","AIFF audio"],["wma","Windows Media Audio"],["amr","AMR audio"],["mid","MIDI audio"],["midi","MIDI audio"],["ape","Monkey's Audio"],["mp4","ISO Media, MPEG-4"],["m4v","MPEG-4 video"],["webm","WebM"],["avi","RIFF (little-endian) data, AVI"],["mov","ISO Media, Apple QuickTime movie"],["mkv","Matroska data"],["wmv","Windows Media Video"],["flv","Flash Video"],["3gp","3GPP multimedia"],["3g2","3GPP2 multimedia"],["ogv","Ogg video"],["mts","MPEG transport stream"],["m2ts","MPEG transport stream"],["ts","MPEG transport stream"],["mpg","MPEG video"],["mpeg","MPEG video"],["exe","PE32 executable"],["dll","PE32 DLL"],["elf","ELF executable"],["mach","Mach-O executable"],["wasm","WebAssembly (wasm) binary module"],["dex","Android Dalvik executable"],["class","Java class file"],["swf","Adobe Flash"],["doc","Microsoft Word Document"],["docx","Microsoft Word 2007+ Document"],["xls","Microsoft Excel Spreadsheet"],["xlsx","Microsoft Excel 2007+ Spreadsheet"],["ppt","Microsoft PowerPoint Presentation"],["pptx","Microsoft PowerPoint 2007+ Presentation"],["odt","OpenDocument Text"],["ods","OpenDocument Spreadsheet"],["odp","OpenDocument Presentation"],["ttf","TrueType Font"],["otf","OpenType Font"],["woff","Web Open Font Format"],["woff2","Web Open Font Format 2"],["eot","Embedded OpenType font"],["stl","Stereolithography CAD"],["obj","Wavefront 3D Object"],["gltf","GL Transmission Format"],["glb","GL Transmission Format (binary)"],["sqlite","SQLite 3.x database"],["mdb","Microsoft Access Database"],["xml","XML document"],["json","JSON data"],["macho","Mach-O binary"],["ics","iCalendar data"],["vcf","vCard data"],["msi","Microsoft Installer"],["ps","PostScript"],["ai","Adobe Illustrator"],["indd","Adobe InDesign"],["sketch","Sketch design file"],["fig","Figma design file"],["xd","Adobe XD"],["blend","Blender"],["fbx","Autodesk FBX"],["lnk","MS Windows shortcut"],["alias","Mac OS alias"],["torrent","BitTorrent file"],["pcap","pcap capture file"],["arrow","Apache Arrow"],["parquet","Apache Parquet"]]),sx={name:"file",async execute(e,t){if(he(e))return ce(id);let r=!1,n=!1,i=!1,s=[];for(let l of e)if(l.startsWith("--"))if(l==="--brief")r=!0;else if(l==="--mime"||l==="--mime-type")n=!0;else if(l==="--dereference")i=!0;else return ve("file",l);else if(l.startsWith("-")&&l!=="-")for(let u of l.slice(1))if(u==="b")r=!0;else if(u==="i")n=!0;else if(u==="L")i=!0;else return ve("file",`-${u}`);else s.push(l);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE... `,exitCode:1};let a=new st(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),"file"),o=0;for(let l of s){t.executionScope?.consumeLimited("file-operands",1,t.limits.maxArrayElements,"file");try{let u=t.fs.resolvePath(t.cwd,l),c=i?await t.fs.stat(u):await t.fs.lstat(u);if(c.isSymbolicLink){let d=await t.fs.readlink(u),m=n?"inode/symlink":`symbolic link to ${d}`;a.append(r?`${m} `:`${l}: ${m} `);continue}if(c.isDirectory){let d=n?"inode/directory":"directory";a.append(r?`${d} `:`${l}: ${d} `);continue}let p=await t.fs.readFileBuffer(u);t.executionScope?.consumeInput(p.byteLength,"file");let h=await oA(l,p),f=n?h.mime:h.description;a.append(r?`${f} `:`${l}: ${f} `)}catch(u){Ie(u),a.append(r?`cannot open `:`${l}: cannot open (No such file or directory) `),o=1}}return{stdout:a.build(),stderr:"",exitCode:o}}},ax={name:"file",flags:[{flag:"-b",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-L",type:"boolean"}],needsArgs:!0}}),ox={};re(ox,{flagsForFuzzing:()=>ux,htmlToMarkdownCommand:()=>lx});var sd,lx,ux,uA=M(()=>{se(),Lt(),H(),le(),sd={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 ![alt](src)"," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '

Hello

World

' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},lx={name:"html-to-markdown",async execute(e,t){if(he(e))return ce(sd);let r="-",n="```",i="---",s="atx",a=[];for(let g=0;gl)throw new C(`html-to-markdown: input size limit exceeded (${l} bytes)`,"string_length");o=ke(t.stdin)}else try{let g=t.fs.resolvePath(t.cwd,a[0]);if((await t.fs.stat(g)).size>l||(o=await t.fs.readFile(g),q(o)>l))throw new C(`html-to-markdown: input size limit exceeded (${l} bytes)`,"string_length")}catch(g){return Ie(g),{stdout:"",stderr:`html-to-markdown: ${a[0]}: No such file or directory `,exitCode:1}}if(!o.trim())return{stdout:"",stderr:"",exitCode:0};if(!["-","+","*"].includes(r))return{stdout:"",stderr:`html-to-markdown: invalid bullet marker `,exitCode:1};if(n!=="```"&&n!=="~~~")return{stdout:"",stderr:`html-to-markdown: invalid code fence `,exitCode:1};let u=0,c=t.limits.maxLoopIterations;for(let g=0;gc)throw new C(`html-to-markdown: complexity limit exceeded (${c} tags)`,"iterations");t.executionScope?.consumeWork(u,"html-to-markdown tags");let p=q(o),h=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize);if(p>Math.floor((h-1)/4))throw new C(`html-to-markdown: prospective output size limit exceeded (${h} bytes)`,"output_size");let f=p*4+1,d=t.executionScope?.reserveBytes("html input",p,"html-to-markdown"),m=t.executionScope?.reserveBytes("html prospective output",f,"html-to-markdown");try{let g=new Ra({bulletListMarker:r,codeBlockStyle:"fenced",fence:n,hr:i,headingStyle:s});g.remove(["script","style","footer"]);let v=g.turndown(o).trim();if(q(v)+1>h)throw new C(`html-to-markdown: output size limit exceeded (${h} bytes)`,"output_size");return{stdout:`${v} `,stderr:"",exitCode:0}}catch(g){return Ie(g),{stdout:"",stderr:`html-to-markdown: conversion error: ${g.message} `,exitCode:1}}finally{m?.release(),d?.release()}}},ux={name:"html-to-markdown",flags:[],stdinType:"text"}}),cx={};re(cx,{flagsForFuzzing:()=>fx,helpCommand:()=>hx});function cA(e){let t=[],r=new Set(e);t.push(`Available commands: `);let n=[];for(let[i,s]of px){let a=s.filter(o=>r.has(o));if(a.length>0){t.push(` ${i}:`),t.push(` ${a.join(", ")} `);for(let o of a)r.delete(o)}}for(let i of r)n.push(i);return n.length>0&&(t.push(" Other:"),t.push(` ${n.sort().join(", ")} `)),t.push("Use ' --help' for details on a specific command."),`${t.join(` `)} `}var px,hx,fx,pA=M(()=>{ji(),px=new Map([["File operations",["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"]],["Text processing",["grep","sed","awk","sort","uniq","cut","tr","tee","diff"]],["Search",["find"]],["Navigation & paths",["pwd","basename","dirname","tree","du"]],["Environment & shell",["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"]],["Data processing",["xargs","jq","base64","date"]],["Network",["curl","html-to-markdown"]]]),hx={name:"help",async execute(e,t){if(e.includes("--help")||e.includes("-h"))return{stdout:`help - display available commands Usage: help [command] Options: -h, --help Show this help message If a command name is provided, shows help for that command. Otherwise, lists all available commands. `,stderr:"",exitCode:0};if(e.length>0&&t.exec){let r=e[0];return t.exec(ni([r]),{cwd:t.cwd,signal:t.signal,args:["--help"]})}return{stdout:cA(t.getRegisteredCommands?.()??[]),stderr:"",exitCode:0}}},fx={name:"help",flags:[]}}),dx={};re(dx,{flagsForFuzzing:()=>gx,whichCommand:()=>mx});var ad,od,mx,gx,hA=M(()=>{Ct(),le(),ad={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},od={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},mx={name:"which",async execute(e,t){if(he(e))return ce(ad);let r=At("which",e,od);if(!r.ok)return r.error;let n=r.result.flags.showAll,i=r.result.flags.silent,s=r.result.positional;if(s.length===0)return{stdout:"",stderr:"",exitCode:1};let a=(t.env.get("PATH")||"/usr/bin:/bin").split(":"),o="",l=!0;for(let u of s){let c=!1;for(let p of a){if(!p)continue;let h=t.fs.resolvePath(p,u);if(await t.fs.exists(h)&&(c=!0,i||(o+=`${h} `),!n))break}c||(l=!1)}return{stdout:o,stderr:"",exitCode:+!l}}},gx={name:"which",flags:[{flag:"-a",type:"boolean"},{flag:"-s",type:"boolean"}],needsArgs:!0}}),yx={};re(yx,{flagsForFuzzing:()=>vx,tac:()=>xx});async function fA(e,t){if(e.length>0&&e[0]!=="-"){let i=t.fs.resolvePath(t.cwd,e[0]);try{let s=(await t.fs.readFile(i)).split(` `);s[s.length-1]===""&&s.pop();let a=s.reverse();return{stdout:a.length>0?`${a.join(` `)} `:"",stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`tac: ${e[0]}: No such file or directory `,exitCode:1}}}let r=t.stdin.split(` `);r[r.length-1]===""&&r.pop();let n=r.reverse();return{stdout:n.length>0?`${n.join(` `)} `:"",stderr:"",exitCode:0,stdoutKind:"bytes"}}var xx,vx,dA=M(()=>{se(),xx={name:"tac",execute:fA},vx={name:"tac",flags:[],stdinType:"text",needsFiles:!0}}),bx={};re(bx,{flagsForFuzzing:()=>Ex,hostname:()=>wx});async function mA(e,t){return{stdout:`localhost `,stderr:"",exitCode:0}}var wx,Ex,gA=M(()=>{wx={name:"hostname",execute:mA},Ex={name:"hostname",flags:[]}}),Sx={};re(Sx,{flagsForFuzzing:()=>Cx,whoami:()=>Ax});async function yA(e,t){return{stdout:`user `,stderr:"",exitCode:0}}var Ax,Cx,xA=M(()=>{Ax={name:"whoami",execute:yA},Cx={name:"whoami",flags:[]}}),kx={};re(kx,{flagsForFuzzing:()=>$x,od:()=>Nx});async function vA(e,t){let r="octal",n=[],i=[];for(let d=0;d=32&&d<127?` ${String.fromCharCode(d)}`:` ${d.toString(8).padStart(3,"0")}`}function u(d){return o?` ${d.toString(16).padStart(2,"0")}`:` ${d.toString(16).padStart(2,"0")}`}function c(d){return` ${d.toString(8).padStart(3,"0")}`}let p=s.build(),h=new st(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),"od"),f=n.length;if(f>0&&p.length>Math.floor(t.limits.maxLoopIterations/f))throw new C(`od: format work limit exceeded (${t.limits.maxLoopIterations})`,"iterations");t.executionScope?.consumeWork(p.length*f,"od formatting");for(let d=0;dl(x.charCodeAt(0))):g==="hex"?Array.from(p.slice(d,d+16),x=>u(x.charCodeAt(0))):Array.from(p.slice(d,d+16),x=>c(x.charCodeAt(0)));let y="";m===0&&r!=="none"?y=`${d.toString(8).padStart(7,"0")} `:(m>0||r==="none")&&(y=r==="none"?"":" "),h.append(y+v.join("")).append(` `)}return r!=="none"&&p.length>0&&h.append(p.length.toString(8).padStart(7,"0")).append(` `),{stdout:h.build(),stderr:"",exitCode:0}}var Nx,$x,bA=M(()=>{Et(),se(),Lt(),H(),Nx={name:"od",execute:vA},$x={name:"od",flags:[{flag:"-c",type:"boolean"},{flag:"-A",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-N",type:"value",valueHint:"number"}],stdinType:"text",needsFiles:!0}}),e1,wA=M(()=>{e1=class{options;inputBytes=0;outputBytes=0;workBytes=0;label;constructor(e){this.options=e,this.label=e.label??"codec";for(let[t,r]of[["maxInputBytes",e.maxInputBytes],["maxOutputBytes",e.maxOutputBytes],["maxExpansionRatio",e.maxExpansionRatio],["ratioGraceBytes",e.ratioGraceBytes],["maxWorkBytes",e.maxWorkBytes]])if(r!==void 0&&(!Number.isSafeInteger(r)||r<0))throw Error(`${this.label}: invalid ${t}`)}checkpoint(){if(this.options.signal?.aborted)throw Error(`${this.label}: operation aborted`)}acceptInput(e){this.checkpoint(),this.inputBytes=this.addWithinLimit(this.inputBytes,e,this.options.maxInputBytes,"input"),this.chargeWork(e)}acceptOutput(e){this.checkpoint();let t=this.addWithinLimit(this.outputBytes,e,this.options.maxOutputBytes,"output"),r=this.options.ratioGraceBytes??1048576,n=this.options.maxExpansionRatio;if(n!==void 0&&t>r&&(this.inputBytes===0||t>this.inputBytes*n))throw Error(`${this.label}: expansion ratio exceeds limit (${n}:1)`);this.outputBytes=t,this.chargeWork(e)}get inputLength(){return this.inputBytes}get outputLength(){return this.outputBytes}chargeWork(e){let t=this.options.maxWorkBytes??this.options.maxInputBytes+this.options.maxOutputBytes;this.workBytes=this.addWithinLimit(this.workBytes,e,t,"work")}addWithinLimit(e,t,r,n){if(!Number.isSafeInteger(t)||t<0||t>r-e)throw Error(`${this.label}: ${n} exceeds limit (${r} bytes)`);return e+t}}}),wa={};re(wa,{flagsForFuzzing:()=>Wx,gunzipCommand:()=>Bx,gunzipFlagsForFuzzing:()=>jx,gzipCommand:()=>zx,zcatCommand:()=>Ux,zcatFlagsForFuzzing:()=>qx});function ld(e){return e.best?Ti.constants.Z_BEST_COMPRESSION:e.level8?8:e.level7?7:e.level6?6:e.level5?5:e.level4?4:e.level3?3:e.level2?2:e.fast?Ti.constants.Z_BEST_SPEED:Ti.constants.Z_DEFAULT_COMPRESSION}function Ox(e){if(e.length<10||e[0]!==31||e[1]!==139)return{originalName:null,mtime:null,headerSize:0};let t=e[3],r=e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n=10;if(t&4){if(n+2>e.length)return{originalName:null,mtime:null,headerSize:0};let s=e[n]|e[n+1]<<8;n+=2+s}let i=null;if(t&8){let s=n;for(;n0?new Date(r*1e3):null,headerSize:n}}function EA(e){return e.length===0||e==="."||e===".."||e.includes("/")||e.includes("\\")||/[\0-\x1f\x7f]/.test(e)?null:e}function Tx(e){if(e.length<4)return 0;let t=e.length;return e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24}function qa(e){return e.length>=2&&e[0]===31&&e[1]===139}function ra(e){return Buffer.from(e).toString("latin1")}function Ix(e){return e.limits.maxOutputSize}function ju(e,t,r,n,i){if(t<=0)throw Error("decompressed data exceeds limit (0 bytes)");let s=new e1({maxInputBytes:r,maxOutputBytes:t,maxExpansionRatio:1e4,signal:n,label:"gzip"});if(s.acceptInput(e.length),Tx(e)>t)throw Error(`decompressed data exceeds limit (${t} bytes)`);let a;try{let o=Math.min(t,Math.floor((i?.executionScope?.remainingLiveBytes??t*2)/2));if(o<=0)throw Error("gzip: live byte limit exceeded");a=i?.executionScope?.reserveBytes("gzip output",o*2,"gzip");let l=(0,Ti.gunzipSync)(e,{maxOutputLength:o});return s.acceptOutput(l.length),{data:l,lease:a}}catch(o){throw a?.release(),o}}function ud(e,t,r){let n=new e1({maxInputBytes:r.limits.maxInputBytes,maxOutputBytes:r.limits.maxOutputSize,signal:r.signal,label:"gzip"});n.acceptInput(e.length);let i;try{let s=Math.min(r.limits.maxOutputSize,Math.floor((r.executionScope?.remainingLiveBytes??r.limits.maxOutputSize*2)/2));if(s<=0)throw Error("gzip: live byte limit exceeded");i=r.executionScope?.reserveBytes("gzip output",s*2,"gzip");let a=(0,Ti.gzipSync)(e,{level:t,maxOutputLength:s});return n.acceptOutput(a.length),{data:a,lease:i}}catch(s){throw i?.release(),s}}async function Rx(e,t,r){let n=await e.fs.stat(t);if(n.size>e.limits.maxInputBytes)throw new C(`input size limit exceeded (${e.limits.maxInputBytes} bytes)`,"string_length");let i=e.executionScope?.reserveBytes("gzip input",n.size,r);try{let s=await e.fs.readFileBuffer(t);if(s.byteLength>n.size)throw new C("gzip: input grew while being read","string_length");return e.executionScope?.consumeInput(s.byteLength,r),{data:s,lease:i}}catch(s){throw i?.release(),s}}async function Px(e,t,r){if(t!=="-"&&t!=="")return Rx(e,e.fs.resolvePath(e.cwd,t),r);let n=e.stdin,i=e.executionScope?.reserveBytes("gzip input",n.length,r);try{return{data:Uint8Array.from(n,s=>s.charCodeAt(0)),lease:i}}catch(s){throw i?.release(),s}}async function Dx(e,t,r,n,i,s){let a=r.suffix,o,l,u,c=Ix(e);if(t==="-"||t===""){let f=e.stdin,d=e.executionScope?.reserveBytes("gzip input",f.length,n),m;try{if(u=Uint8Array.from(f,g=>g.charCodeAt(0)),i){if(!qa(u))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: stdin: not in gzip format `,exitCode:1};try{let g=ju(u,c,e.limits.maxInputBytes,e.signal,e);return m=g.lease,{stdout:ra(g.data),stderr:"",exitCode:0}}catch(g){return Ie(g),{stdout:"",stderr:`${n}: stdin: ${g instanceof Error?g.message:"unknown error"} `,exitCode:1}}}{let g=ud(u,ld(r),e);return m=g.lease,{stdout:ra(g.data),stderr:"",exitCode:0}}}finally{m?.release(),d?.release()}}o=e.fs.resolvePath(e.cwd,t);try{let f=await e.fs.stat(o);if(f.size>e.limits.maxInputBytes)return{stdout:"",stderr:`${n}: ${t}: input size limit exceeded (${e.limits.maxInputBytes} bytes) `,exitCode:1};if(f.isDirectory)return r.recursive?await SA(e,o,r,n,i,s):r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${t}: is a directory -- ignored `,exitCode:1}}catch{return{stdout:"",stderr:`${n}: ${t}: No such file or directory `,exitCode:1}}let p,h;try{let f=await Rx(e,o,n);u=f.data,p=f.lease}catch(f){return Ie(f),{stdout:"",stderr:`${n}: ${t}: No such file or directory `,exitCode:1}}try{if(i){if(!t.endsWith(a))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${t}: unknown suffix -- ignored `,exitCode:1};if(!qa(u))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${t}: not in gzip format `,exitCode:1};let f;try{let d=ju(u,c,e.limits.maxInputBytes,e.signal,e);f=d.data,h=d.lease}catch(d){return Ie(d),{stdout:"",stderr:`${n}: ${t}: ${d instanceof Error?d.message:"unknown error"} `,exitCode:1}}if(s)return{stdout:ra(f),stderr:"",exitCode:0};if(r.name){let d=Ox(u),m=d.originalName?EA(d.originalName):null;l=m?e.fs.resolvePath(e.cwd,m):o.slice(0,-a.length)}else l=o.slice(0,-a.length);if(!r.force)try{return await e.fs.stat(l),{stdout:"",stderr:`${n}: ${l} already exists; not overwritten `,exitCode:1}}catch{}return await e.fs.writeFile(l,f),!r.keep&&!s&&await e.fs.rm(o),r.verbose?{stdout:"",stderr:`${t}: ${u.length>0?((1-u.length/f.length)*100).toFixed(1):"0.0"}% -- replaced with ${l.split("/").pop()} `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}{if(t.endsWith(a))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${t} already has ${a} suffix -- unchanged `,exitCode:1};let f=ld(r),d;try{let m=ud(u,f,e);d=m.data,h=m.lease}catch(m){return Ie(m),{stdout:"",stderr:`${n}: ${t}: ${m instanceof Error?m.message:"unknown error"} `,exitCode:1}}if(s)return{stdout:ra(d),stderr:"",exitCode:0};if(l=o+a,!r.force)try{return await e.fs.stat(l),{stdout:"",stderr:`${n}: ${l} already exists; not overwritten `,exitCode:1}}catch{}return await e.fs.writeFile(l,d),!r.keep&&!s&&await e.fs.rm(o),r.verbose?{stdout:"",stderr:`${t}: ${u.length>0?((1-d.length/u.length)*100).toFixed(1):"0.0"}% -- replaced with ${l.split("/").pop()} `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}}finally{h?.release(),p?.release()}}async function SA(e,t,r,n,i,s){let a=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),o=new st(a,n),l=new st(a,n),u=0;return await Ms({fs:e.fs,root:t,symlinks:"never",limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:n},async c=>{if(c.depth===0||c.phase!=="enter"||!c.stat.isFile)return;let p=r.suffix;if(i&&!c.path.endsWith(p)||!i&&c.path.endsWith(p))return;let h=await Dx(e,c.path.startsWith(`${e.cwd}/`)?c.path.slice(e.cwd.length+1):c.path,r,n,i,s);o.append(h.stdout),l.append(h.stderr),h.exitCode!==0&&(u=h.exitCode)}),{stdout:o.build(),stderr:l.build(),exitCode:u}}async function AA(e,t,r,n){let i,s;try{let a=await Px(e,t,n);i=a.data,s=a.lease}catch(a){return Ie(a),{stdout:"",stderr:`${n}: ${t}: No such file or directory `,exitCode:1}}try{if(!qa(i))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${t}: not in gzip format `,exitCode:1};let a=i.length,o=Tx(i),l=o>0?((1-a/o)*100).toFixed(1):"0.0",u=Ox(i).originalName||(t==="-"?"":t.replace(/\.gz$/,""));return{stdout:`${a.toString().padStart(10)} ${o.toString().padStart(10)} ${l.padStart(5)}% ${u} `,stderr:"",exitCode:0}}finally{s?.release()}}async function CA(e,t,r,n){let i,s;try{let a=await Px(e,t,n);i=a.data,s=a.lease}catch(a){return Ie(a),{stdout:"",stderr:`${n}: ${t}: No such file or directory `,exitCode:1}}try{if(!qa(i))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${t}: not in gzip format `,exitCode:1};try{return ju(i,Ix(e),e.limits.maxInputBytes,e.signal,e).lease?.release(),r.verbose?{stdout:"",stderr:`${t}: OK `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(a){return Ie(a),{stdout:"",stderr:`${n}: ${t}: ${a instanceof Error?a.message:"invalid"} `,exitCode:1}}}finally{s?.release()}}async function zl(e,t,r){let n=r==="zcat"?Fx:r==="gunzip"?Mx:Lx;if(he(e))return ce(n);let i=At(r,e,_x);if(!i.ok)return i.error.stderr.includes("unrecognized option"),i.error;let s=i.result.flags,a=i.result.positional,o=r==="gunzip"||r==="zcat"||s.decompress||s.uncompress,l=r==="zcat"||s.stdout||s.toStdout;if(s.list){a.length===0&&(a=["-"]);let h=` compressed uncompressed ratio uncompressed_name `,f="",d=0;for(let m of a){let g=await AA(t,m,s,r);h+=g.stdout,f+=g.stderr,g.exitCode!==0&&(d=g.exitCode)}return{stdout:h,stderr:f,exitCode:d}}if(s.test){a.length===0&&(a=["-"]);let h="",f="",d=0;for(let m of a){let g=await CA(t,m,s,r);h+=g.stdout,f+=g.stderr,g.exitCode!==0&&(d=g.exitCode)}return{stdout:h,stderr:f,exitCode:d}}a.length===0&&(a=["-"]);let u="",c="",p=0;for(let h of a){let f=await Dx(t,h,s,r,o,l);u+=f.stdout,c+=f.stderr,f.exitCode!==0&&(p=f.exitCode)}return{stdout:u,stderr:c,exitCode:p}}var Lx,Mx,Fx,_x,zx,Bx,Ux,Wx,jx,qx,Bl=M(()=>{Et(),se(),Lt(),_r(),H(),Ct(),wA(),le(),Lx={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place). When no FILE is given, or when FILE is -, read from standard input. With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},Mx={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place). When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},Fx={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output. When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},_x={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}},zx={name:"gzip",async execute(e,t){return{...await zl(e,t,"gzip"),stdoutEncoding:"binary"}}},Bx={name:"gunzip",async execute(e,t){return{...await zl(e,t,"gunzip"),stdoutEncoding:"binary"}}},Ux={name:"zcat",async execute(e,t){return{...await zl(e,t,"zcat"),stdoutEncoding:"binary"}}},Wx={name:"gzip",flags:[{flag:"-c",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-k",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-1",type:"boolean"},{flag:"-9",type:"boolean"}],stdinType:"binary",needsFiles:!0},jx={name:"gunzip",flags:[{flag:"-c",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-k",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"binary",needsFiles:!0},qx={name:"zcat",flags:[{flag:"-f",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"binary",needsFiles:!0}});function cd(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),r=>r.charCodeAt(0));if(t==="hex"){let r=new Uint8Array(e.length/2);for(let n=0;nn.charCodeAt(0));let r=new Uint8Array(e.length);for(let n=0;nr.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let r=65536;if(e.length<=r)return String.fromCharCode(...e);let n="";for(let i=0;i{Gx=new TextEncoder,Hx=new TextDecoder});function Gu(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16)}`).replace(/%20/g,"+").replace(/%[0-9A-F]{2}/g,t=>t.toLowerCase())}function kA(e){let t=e.indexOf("=");if(t>=0){let r=e.slice(0,t),n=Gu(e.slice(t+1));return r?`${r}=${n}`:n}return Gu(e)}function pd(e){let t=e.indexOf("=");if(t<0)return null;let r=e.slice(0,t),n=e.slice(t+1),i,s,a=n.match(/;type=([^;]+)$/);a&&(s=a[1],n=n.slice(0,-a[0].length));let o=n.match(/;filename=([^;]+)/);return o&&(i=o[1],n=n.replace(o[0],"")),(n.startsWith("@")||n.startsWith("<"))&&(i??=n.slice(1).split("/").pop()),{name:r,value:n,filename:i,contentType:s}}function NA(e,t){let r=`----CurlFormBoundary${Date.now().toString(36)}`,n=[];for(let i of e){let s=i.value;if(s.startsWith("@")||s.startsWith("<")){let o=s.slice(1);s=t.get(o)??""}let a=`--${r}\r `;i.filename?(a+=`Content-Disposition: form-data; name="${i.name}"; filename="${i.filename}"\r `,i.contentType&&(a+=`Content-Type: ${i.contentType}\r `)):a+=`Content-Disposition: form-data; name="${i.name}"\r `,a+=`\r ${s}\r `,n.push(a)}return n.push(`--${r}--\r `),{body:n.join(""),boundary:r}}var Zx=M(()=>{}),Qx,$A=M(()=>{Qx={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data (DATA=@file reads from file, strips newlines)","-G, --get Append data payloads to URL query string"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data (DATA=@file reads file verbatim)"," --data-urlencode DATA URL-encode and POST data (supports @file and name@file)","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]}});function Fn(e,t,r){r.allowFile&&t.startsWith("@")?e.dataParts.push({file:{path:t.slice(1),mode:r.binary?"binary":"ascii"}}):e.dataParts.push({value:t}),r.binary&&(e.dataBinary=!0)}function hd(e,t){if(t.startsWith("@")){e.dataParts.push({file:{path:t.slice(1),mode:"urlencode"}});return}let r=t.indexOf("@"),n=t.indexOf("=");if(r>0&&(n<0||r0){let l=a.slice(0,o).trim(),u=a.slice(o+1).trim();t.headers.append(l,u)}}}else if(s.startsWith("--header=")){let a=s.slice(9),o=a.indexOf(":");if(o>0){let l=a.slice(0,o).trim(),u=a.slice(o+1).trim();t.headers.append(l,u)}}else if(s==="-G"||s==="--get")t.getMode=!0,n||(t.method="GET");else if(s==="-d"||s==="--data")Fn(t,e[++i]??"",{binary:!1,allowFile:!0}),r=!0;else if(s==="--data-raw")Fn(t,e[++i]??"",{binary:!1,allowFile:!1}),r=!0;else if(s.startsWith("-d"))Fn(t,s.slice(2),{binary:!1,allowFile:!0}),r=!0;else if(s.startsWith("--data="))Fn(t,s.slice(7),{binary:!1,allowFile:!0}),r=!0;else if(s.startsWith("--data-raw="))Fn(t,s.slice(11),{binary:!1,allowFile:!1}),r=!0;else if(s==="--data-binary")Fn(t,e[++i]??"",{binary:!0,allowFile:!0}),r=!0;else if(s.startsWith("--data-binary="))Fn(t,s.slice(14),{binary:!0,allowFile:!0}),r=!0;else if(s==="--data-urlencode")hd(t,e[++i]??""),r=!0;else if(s.startsWith("--data-urlencode="))hd(t,s.slice(17)),r=!0;else if(s==="-F"||s==="--form"){let a=pd(e[++i]??"");a&&t.formFields.push(a),r=!0}else if(s.startsWith("--form=")){let a=pd(s.slice(7));a&&t.formFields.push(a),r=!0}else if(s==="-u"||s==="--user")t.user=e[++i];else if(s.startsWith("-u"))t.user=s.slice(2);else if(s.startsWith("--user="))t.user=s.slice(7);else if(s==="-A"||s==="--user-agent")t.headers.set("User-Agent",e[++i]??"");else if(s.startsWith("-A"))t.headers.set("User-Agent",s.slice(2));else if(s.startsWith("--user-agent="))t.headers.set("User-Agent",s.slice(13));else if(s==="-e"||s==="--referer")t.headers.set("Referer",e[++i]??"");else if(s.startsWith("-e"))t.headers.set("Referer",s.slice(2));else if(s.startsWith("--referer="))t.headers.set("Referer",s.slice(10));else if(s==="-b"||s==="--cookie")t.headers.set("Cookie",e[++i]??"");else if(s.startsWith("-b"))t.headers.set("Cookie",s.slice(2));else if(s.startsWith("--cookie="))t.headers.set("Cookie",s.slice(9));else if(s==="-c"||s==="--cookie-jar")t.cookieJar=e[++i];else if(s.startsWith("--cookie-jar="))t.cookieJar=s.slice(13);else if(s==="-T"||s==="--upload-file")t.uploadFile=e[++i],t.method==="GET"&&(t.method="PUT");else if(s.startsWith("--upload-file="))t.uploadFile=s.slice(14),t.method==="GET"&&(t.method="PUT");else if(s==="-m"||s==="--max-time"){let a=parseFloat(e[++i]??"0");!Number.isNaN(a)&&a>0&&(t.timeoutMs=a*1e3)}else if(s.startsWith("--max-time=")){let a=parseFloat(s.slice(11));!Number.isNaN(a)&&a>0&&(t.timeoutMs=a*1e3)}else if(s==="--connect-timeout"){let a=parseFloat(e[++i]??"0");!Number.isNaN(a)&&a>0&&t.timeoutMs===void 0&&(t.timeoutMs=a*1e3)}else if(s.startsWith("--connect-timeout=")){let a=parseFloat(s.slice(18));!Number.isNaN(a)&&a>0&&t.timeoutMs===void 0&&(t.timeoutMs=a*1e3)}else if(s==="-o"||s==="--output")t.outputFile=e[++i];else if(s.startsWith("--output="))t.outputFile=s.slice(9);else if(s==="-O"||s==="--remote-name")t.useRemoteName=!0;else if(s==="-I"||s==="--head")t.headOnly=!0,t.method="HEAD",n=!0;else if(s==="-i"||s==="--include")t.includeHeaders=!0;else if(s==="-s"||s==="--silent")t.silent=!0;else if(s==="-S"||s==="--show-error")t.showError=!0;else if(s==="-f"||s==="--fail")t.failSilently=!0;else if(s==="-L"||s==="--location")t.followRedirects=!0;else if(s==="--max-redirs"){let a=e[++i];if(a===void 0||!/^\d+$/.test(a))return{stdout:"",stderr:`curl: option --max-redirs: expected a non-negative integer `,exitCode:2};let o=Number(a);if(!Number.isSafeInteger(o))return{stdout:"",stderr:`curl: option --max-redirs: value is out of range `,exitCode:2};t.maxRedirects=o}else if(s.startsWith("--max-redirs=")){let a=s.slice(13);if(!/^\d+$/.test(a)||!Number.isSafeInteger(Number(a)))return{stdout:"",stderr:`curl: option --max-redirs: expected a non-negative integer `,exitCode:2};t.maxRedirects=Number(a)}else if(s==="-w"||s==="--write-out")t.writeOut=e[++i];else if(s.startsWith("--write-out="))t.writeOut=s.slice(12);else if(s==="-v"||s==="--verbose")t.verbose=!0;else{if(s.startsWith("--")&&s!=="--")return ve("curl",s);if(s.startsWith("-")&&s!=="-")for(let a of s.slice(1))switch(a){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD",n=!0;break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;case"G":t.getMode=!0,n||(t.method="GET");break;default:return ve("curl",`-${a}`)}else s.startsWith("-")||(t.url=s)}}return r&&!n&&!t.getMode&&(t.method="POST"),t}var TA=M(()=>{Us(),le(),Zx()});function fd(e){return Object.entries(e).map(([t,r])=>`${t}: ${r}`).join(`\r `)}function IA(e){try{return new URL(e).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function Kx(e,t){let r=e;return r=r.replace(/%\{http_code\}/g,String(t.status)),r=r.replace(/%\{content_type\}/g,t.headers["content-type"]||""),r=r.replace(/%\{url_effective\}/g,t.url),r=r.replace(/%\{size_download\}/g,String(t.bodyLength)),r=r.replace(/\\n/g,` `),r}var RA=M(()=>{}),Xx={};re(Xx,{curlCommand:()=>Yx});async function PA(e,t){if(e.dataParts.length===0)return;let r=[];for(let n of e.dataParts)if(n.file){let i=t.fs.resolvePath(t.cwd,n.file.path),s=await t.fs.readFile(i);if(n.file.mode==="ascii")r.push(s.replace(/[\r\n]/g,""));else if(n.file.mode==="binary")r.push(s);else{let a=Gu(s);r.push(n.file.name?`${n.file.name}=${a}`:a)}}else r.push(n.value??"");return r.join("&")}async function DA(e,t,r){if(e.uploadFile){let n=t.fs.resolvePath(t.cwd,e.uploadFile);return{body:await t.fs.readFile(n)}}if(e.formFields.length>0){let n=new Map;for(let a of e.formFields)if(a.value.startsWith("@")||a.value.startsWith("<")){let o=t.fs.resolvePath(t.cwd,a.value.slice(1));try{let l=await t.fs.readFile(o);n.set(a.value.slice(1),l)}catch{n.set(a.value.slice(1),"")}}let{body:i,boundary:s}=NA(e.formFields,n);return{body:i,contentType:`multipart/form-data; boundary=${s}`}}return r!==void 0&&!e.getMode?{body:r,contentType:"application/x-www-form-urlencoded"}:{}}function LA(e,t){if(!t)return e;let r=e.indexOf("#"),n=r===-1?e:e.slice(0,r),i=r===-1?"":e.slice(r);return`${n}${n.endsWith("?")||n.endsWith("&")?"":n.includes("?")?"&":"?"}${t}${i}`}function MA(e,t){let r=new Vc(e.headers);if(e.user){let n=Buffer.from(e.user).toString("base64");r.set("Authorization",`Basic ${n}`)}return t&&!r.has("Content-Type")&&r.set("Content-Type",t),r}async function FA(e,t,r){if(!e.cookieJar)return;let n=t["set-cookie"];if(!n)return;let i=r.fs.resolvePath(r.cwd,e.cookieJar);await r.fs.writeFile(i,n)}function _A(e){return qu(e,"binary")}function zA(e,t,r){let n="";if(e.verbose){n+=`> ${e.method} ${r} `;for(let[i,s]of e.headers)n+=`> ${i}: ${s} `;n+=`> `,n+=`< HTTP/1.1 ${t.status} ${t.statusText} `;for(let[i,s]of Object.entries(t.headers))n+=`< ${i}: ${s} `;n+=`< `}return e.includeHeaders&&!e.verbose&&(n+=`HTTP/1.1 ${t.status} ${t.statusText}\r `,n+=fd(t.headers),n+=`\r \r `),e.headOnly?e.includeHeaders||e.verbose||(n+=`HTTP/1.1 ${t.status} ${t.statusText}\r `,n+=fd(t.headers),n+=`\r `):n+=_A(t.body),e.writeOut&&(n+=Kx(e.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.byteLength})),n}var Yx,BA=M(()=>{Vx(),Er(),Us(),le(),Zx(),$A(),TA(),RA(),Yx={name:"curl",async execute(e,t){if(he(e))return ce(Qx);let r=OA(e);if("exitCode"in r)return r;let n=r;if(!n.url)return{stdout:"",stderr:`curl: no URL specified `,exitCode:2};if(!t.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available `,exitCode:1};let i=n.url;i.match(/^https?:\/\//)||(i=`https://${i}`);try{let s=await PA(n,t);n.getMode&&(i=LA(i,s));let{body:a,contentType:o}=await DA(n,t,s),l=MA(n,o),u=await t.fetch(i,{method:n.method,headers:l,body:a,followRedirects:n.followRedirects,timeoutMs:n.timeoutMs,maxRedirects:n.maxRedirects,signal:t.signal});if(await FA(n,u.headers,t),n.failSilently&&u.status>=400)return{stdout:"",stderr:n.showError||!n.silent?`curl: (22) The requested URL returned error: ${u.status} `:"",exitCode:22};let c=zA(n,u,i);if(n.outputFile||n.useRemoteName){let p=n.outputFile||IA(i),h=t.fs.resolvePath(t.cwd,p);await t.fs.writeFile(h,n.headOnly?"":u.body),n.verbose||(c=""),n.writeOut&&(c=Kx(n.writeOut,{status:u.status,headers:u.headers,url:u.url,bodyLength:u.body.byteLength}))}return{stdout:c,stderr:"",exitCode:0,stdoutKind:"bytes"}}catch(s){let a=ur(s),o=1;return a.includes("Network access denied")?o=7:a.includes("HTTP method")&&a.includes("not allowed")?o=3:a.includes("Redirect target not in allow-list")||a.includes("Too many redirects")?o=47:a.includes("aborted")&&(o=28),{stdout:"",stderr:!n.silent||n.showError?`curl: (${o}) ${a} `:"",exitCode:o}}}}});Wi(),$c(),wt(),Ar();var dd=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(l9(),Om))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(h9(),Pm))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(O9(),zm))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(P9(),Zm))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(D9(),Ym))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(M9(),tg))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(_9(),ig))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(z9(),og))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(B9(),cg))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(U9(),fg))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(W9(),gg))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(q9(),vg))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(G9(),Eg))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(H9(),Cg))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(Q9(),Ig))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(K9(),Dg))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(X9(),Fg))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(Y9(),Ug))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(fl(),la))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(fl(),la))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(fl(),la))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(Jv(),h2))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(db(),S2))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(Rw(),G2))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(_w(),K2))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(zw(),J2))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(Bw(),r6))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(jw(),s6))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(qw(),l6))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(Gw(),p6))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(Vw(),m6))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(Kw(),x6))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Jw(),w6))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(r5(),A6))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(i5(),N6))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(a5(),T6))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(d5(),P6))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(x5(),F6))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(E5(),B6))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(S5(),j6))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(L5(),H6))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(M5(),Q6))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(F5(),Y6))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(z5(),ty))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(U5(),sy))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(hf(),Cu))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(hf(),Cu))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(df(),ku))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(df(),ku))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(W5(),gy))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(q5(),vy))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(xf(),Nu))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(xf(),Nu))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(G5(),ky))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(bf(),$u))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(bf(),$u))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(ME(),jy))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(FE(),Hy))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(_E(),Qy))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(jE(),Yy))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(qE(),n7))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(GE(),a7))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(VE(),c7))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(ZE(),f7))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(KE(),g7))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(YE(),b7))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(JE(),S7))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(eS(),k7))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(lA(),rx))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(uA(),ox))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(pA(),cx))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(hA(),dx))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(dA(),yx))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(gA(),bx))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(xA(),Sx))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(bA(),kx))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Bl(),wa))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Bl(),wa))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Bl(),wa))).zcatCommand}],UA=[],WA=[],jA=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(BA(),Xx))).curlCommand}],md=new Map;function So(e){return{name:e.name,async execute(t,r){let n=md.get(e.name);return n||(n=await Kt.runTrustedAsync(()=>e.load()),md.set(e.name,n)),r.coverage,n.execute(t,r)}}}function qA(e){return(e?dd.filter(t=>e.includes(t.name)):dd).map(So)}function GA(){return jA.map(So)}function HA(){return UA.map(So)}function VA(){return WA.map(So)}se();var gd=new WeakMap,Jx=new WeakSet;function ZA(e){let t=gd.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),gd.set(e,t),Jx.add(t)),t}function QA(e){return Jx.has(e)}var e3={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},KA={...e3,maxSourceBytes:8388608,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxFileSystemBytes:134217728,maxDatabaseBytes:67108864,maxDatabaseResultBytes:16777216,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5,maxWorkerMessageBytes:16777216,maxExecutionTimeMs:3e4};function XA(e,t="normal"){if(t!=="normal"&&t!=="hardened")throw RangeError('executionLimitProfile must be "normal" or "hardened"');let r=t==="hardened"?KA:e3;if(!e)return{...r};let n={maxSourceBytes:e.maxSourceBytes??r.maxSourceBytes,maxExecDepth:e.maxExecDepth??r.maxExecDepth,maxCallDepth:e.maxCallDepth??r.maxCallDepth,maxCommandCount:e.maxCommandCount??r.maxCommandCount,maxLoopIterations:e.maxLoopIterations??r.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??r.maxAwkIterations,maxSedIterations:e.maxSedIterations??r.maxSedIterations,maxJqIterations:e.maxJqIterations??r.maxJqIterations,maxQueryTokens:e.maxQueryTokens??r.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??r.maxQueryDepth,maxQueryElements:e.maxQueryElements??r.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??r.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??r.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??r.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??r.maxCsvRows,maxCsvCells:e.maxCsvCells??r.maxCsvCells,maxWorkUnits:e.maxWorkUnits??r.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??r.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??r.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??r.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??r.maxLiveBytes,maxInputBytes:e.maxInputBytes??r.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??r.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??r.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??r.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??r.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??r.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??r.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??r.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??r.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??r.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??r.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??r.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??r.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??r.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??r.maxGlobOperations,maxStringLength:e.maxStringLength??r.maxStringLength,maxArrayElements:e.maxArrayElements??r.maxArrayElements,maxHeredocSize:e.maxHeredocSize??r.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??r.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??r.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??r.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??r.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??r.maxSourceDepth};for(let i of Object.keys(n)){let s=n[i];if(s!==1/0&&(!Number.isSafeInteger(s)||s<0))throw RangeError(`${i} must be a non-negative safe integer or positive Infinity`)}return n}function YA(e){return"load"in e&&typeof e.load=="function"}function JA(e){let t=null,r=null;return{name:e.name,trusted:e.trusted!==!1,async execute(n,i){if(!t){let a=r;a||(a=e.load().then(o=>(t=o,o)),r=a);try{t=await a}catch(o){throw r===a&&(r=null),o}}let s=t;if(!s)throw Error(`Failed to load command: ${e.name}`);return s.execute(n,i)}}}se(),se(),H(),Wi();var t3=Object.freeze(Object.create(null)),eC=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(e,t=void 0){this.limits=e,this.signal=t}fail(e){throw this.poisoned??=e,this.poisoned}poisonAfterAbort(e){this.poisoned??=e}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw Error("execution budget is already closed");this.throwIfAborted()}chargeCommand(){return this.consume("commands",1,"execution")}consumeWork(e=1,t="execution"){return this.consume("work",e,t)}consumeLimited(e,t,r,n=e){this.assertUsable();let i=this.countersByKind.get(e)??0;return(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(r)||r<0||t>r-i)&&this.fail(new C(`${n}: ${e} work limit exceeded (${r})`,"iterations")),t>this.limits.maxWorkUnits-this.workUnits&&this.fail(new C(`${n}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,"iterations")),this.countersByKind.set(e,i+t),this.workUnits+=t,i+t}consumeInput(e,t="execution"){return this.assertUsable(),(!Number.isSafeInteger(e)||e<0||e>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new C(`${t}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,"string_length")),this.inputBytes+=e,this.inputBytes}consume(e,t=1,r=e){this.assertUsable();let n=this.countersByKind.get(e)??0,i=e==="commands"?this.commandCount:this.workUnits,s=e==="commands"?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(t)||t<0||t>s-i)&&this.fail(new C(e==="commands"?`too many commands executed (>${s}), increase executionLimits.maxCommandCount`:`${r}: ${e} work limit exceeded (${s})`,e==="commands"?"commands":"iterations"));let a=i+t;return e==="commands"?this.commandCount=a:this.workUnits=a,this.countersByKind.set(e,n+t),a}reserveBytes(e,t,r){this.assertUsable();let n=typeof e=="string"?e:"live",i=typeof e=="string"?t:e,s=typeof e=="string"?r??n:t??"execution";(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new C(`${s}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,"string_length")),this.liveBytes+=i,this.bytesByKind.set(n,(this.bytesByKind.get(n)??0)+i);let a=!1;return{release:()=>{if(a)return;a=!0,this.liveBytes-=i;let o=(this.bytesByKind.get(n)??i)-i;o<=0?this.bytesByKind.delete(n):this.bytesByKind.set(n,o)}}}appendOutput(e,t,r="execution",n=0,i="text"){this.assertUsable();let s=i==="bytes"?t.length:q(t);(!Number.isSafeInteger(n)||n<0||n>s)&&this.fail(new C(`${r}: invalid ${e} accounting`,"output_size"));let a=s-n;return a>this.limits.maxOutputSize-this.outputBytes&&this.fail(new C(`${r}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,"output_size")),this.outputBytes+=a,s}accountResult(e,t="execution",r=1/0){let n=e.internalOutputAccounting,i=Math.min(n?.stdout??0,r),s=Math.min(n?.stderr??0,Math.max(0,r-i)),a=this.appendOutput("stdout",e.stdout,t,i,e.stdoutKind==="bytes"||e.stdoutEncoding==="binary"?"bytes":"text"),o=this.appendOutput("stderr",e.stderr,t,s);return Object.isExtensible(e)?(e.internalOutputAccounting={stdout:a,stderr:o},e):a===0&&o===0?e:{...e,internalOutputAccounting:{stdout:a,stderr:o}}}relinquishOutput(e,t,r){this.assertUsable(),r!==t3&&this.fail(new C(`${t}: unauthorized output accounting release`,"output_size")),(!Number.isSafeInteger(e)||e<0||e>this.outputBytes)&&this.fail(new C(`${t}: invalid output accounting release`,"output_size")),this.outputBytes-=e}enterDepth(e,t=this.limits.maxCallDepth,r){this.assertUsable();let n=typeof t=="number"?t:this.limits.maxCallDepth,i=typeof t=="string"?t:r??e,s=this.depthByKind.get(e)??0;s>=n&&this.fail(new C(`${i}: maximum depth (${n}) exceeded`,"recursion")),this.depthByKind.set(e,s+1);let a=!1;return{release:()=>{if(a)return;a=!0;let o=(this.depthByKind.get(e)??1)-1;o<=0?this.depthByKind.delete(e):this.depthByKind.set(e,o)}}}throwIfAborted(e="execution"){this.signal?.aborted&&this.fail(new bt("",`bash: ${e} aborted `)),Date.now()-this.startedAt>this.limits.maxExecutionTimeMs&&this.fail(new bt("",`bash: ${e} exceeded execution deadline (${this.limits.maxExecutionTimeMs}ms) `))}remainingTimeMs(){return Math.max(0,this.limits.maxExecutionTimeMs-(Date.now()-this.startedAt))}registerCleanup(e){this.assertUsable(),this.cleanupCallbacks.push(e);let t=!0;return()=>{if(!t)return;t=!1;let r=this.cleanupCallbacks.indexOf(e);r>=0&&this.cleanupCallbacks.splice(r,1)}}async close(){if(this.closed)return;this.closed=!0;let e=[],t=Date.now()+this.limits.maxExtensionCleanupTimeMs;for(let r=this.cleanupCallbacks.length-1;r>=0;r--)try{let n=t-Date.now();if(n<=0){e.push(Error("execution cleanup grace period exceeded"));break}let i,s=await Promise.race([Promise.resolve().then(this.cleanupCallbacks[r]).then(()=>({ok:!0}),a=>({ok:!1,error:a})),new Promise(a=>{i=uu(()=>a({ok:!1,error:Error("execution cleanup grace period exceeded")}),n)})]);if(cu(i),!s.ok&&(e.push(s.error),Date.now()>=t))break}catch(n){e.push(n)}if(this.cleanupCallbacks.length=0,this.depthByKind.clear(),this.bytesByKind.clear(),this.liveBytes=0,e.length>0)throw AggregateError(e,"execution cleanup failed")}assertExecDepth(e){this.assertUsable(),e>this.limits.maxExecDepth&&this.fail(new C(`maximum nested execution depth (${this.limits.maxExecDepth}) exceeded`,"recursion"))}};function tC(e){let t=Object.create(null);return Object.defineProperties(t,{remainingLiveBytes:{enumerable:!0,get:()=>e.remainingLiveBytes},consumeWork:{enumerable:!0,value:e.consumeWork.bind(e)},consumeLimited:{enumerable:!0,value:e.consumeLimited.bind(e)},consumeInput:{enumerable:!0,value:e.consumeInput.bind(e)},reserveBytes:{enumerable:!0,value:e.reserveBytes.bind(e)},enterDepth:{enumerable:!0,value:e.enterDepth.bind(e)},throwIfAborted:{enumerable:!0,value:e.throwIfAborted.bind(e)},remainingTimeMs:{enumerable:!0,value:e.remainingTimeMs.bind(e)},registerCleanup:{enumerable:!0,value:e.registerCleanup.bind(e)}}),Object.freeze(t)}function rC(e,t,r="pipeline"){e.relinquishOutput(t,r,t3)}se(),Vx(),Ls();var _n=new TextEncoder;function nC(e){return typeof e=="object"&&!!e&&!(e instanceof Uint8Array)&&"content"in e}var Ga=class{data=new Map;entryIdentities=new WeakMap;nextEntryIdentity=1;maxTotalBytes;retainedBytes=0;contentReferences=new WeakMap;materializedContent(e){return e?.type==="file"&&"content"in e?e.content:null}storedByteLength(e){return e===null?0:e instanceof Uint8Array?e.byteLength:q(e)}wouldReleaseBytes(e){let t=this.materializedContent(e);return t===null?0:t instanceof Uint8Array?this.contentReferences.get(t)===1?t.byteLength:0:this.storedByteLength(t)}assertCanAllocate(e,t){let r=this.wouldReleaseBytes(this.data.get(e));if(!Number.isSafeInteger(t)||t<0||t>this.maxTotalBytes-this.retainedBytes+r)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`)}setEntry(e,t){let r=this.data.get(e),n=this.materializedContent(r),i=this.materializedContent(t);if(n===i){this.data.set(e,t);return}let s=this.wouldReleaseBytes(r),a=i instanceof Uint8Array?this.contentReferences.has(i)?0:i.byteLength:this.storedByteLength(i);if(a>this.maxTotalBytes-this.retainedBytes+s)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`);if(n instanceof Uint8Array){let o=this.contentReferences.get(n)??0;o<=1?this.contentReferences.delete(n):this.contentReferences.set(n,o-1)}i instanceof Uint8Array&&this.contentReferences.set(i,(this.contentReferences.get(i)??0)+1),this.retainedBytes+=a-s,this.data.set(e,t)}deleteEntry(e){let t=this.data.get(e);if(!t)return!1;let r=this.materializedContent(t),n=this.wouldReleaseBytes(t);if(r instanceof Uint8Array){let i=this.contentReferences.get(r)??0;i<=1?this.contentReferences.delete(r):this.contentReferences.set(r,i-1)}return this.retainedBytes-=n,this.data.delete(e)}contentByteLength(e,t){if(e instanceof Uint8Array)return e.byteLength;if(t==="hex")return Math.floor(e.length/2);if(t==="base64"){let r=e.endsWith("==")?2:+!!e.endsWith("=");return Math.max(0,Math.floor(e.length*3/4)-r)}return t==="binary"||t==="latin1"?e.length:q(e)}identityFor(e){let t=this.entryIdentities.get(e);return t||(t=`memfs:${this.nextEntryIdentity++}`,this.entryIdentities.set(e,t)),t}constructor(e,t={}){if(this.maxTotalBytes=t.maxTotalBytes??1073741824,!Number.isSafeInteger(this.maxTotalBytes)||this.maxTotalBytes<0)throw Error("InMemoryFs: invalid maxTotalBytes");if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[r,n]of Object.entries(e))typeof n=="function"?this.writeFileLazy(r,n):nC(n)?this.writeFileSync(r,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(r,n)}ensureParentDirs(e){let t=Da(e);t!=="/"&&(this.data.has(t)||(this.ensureParentDirs(t),this.data.set(t,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,t,r,n){gt(e,"write");let i=we(e);this.ensureParentDirs(i);let s=Ul(r);this.assertCanAllocate(i,this.contentByteLength(t,s));let a=cd(t,s);this.setEntry(i,{type:"file",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}writeFileLazy(e,t,r){gt(e,"write");let n=we(e);this.ensureParentDirs(n),this.setEntry(n,{type:"file",lazy:t,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(e,t){let r=await t.lazy(),n=typeof r=="string"?_n.encode(r):r,i={type:"file",content:n,mode:t.mode,mtime:t.mtime};return this.assertCanAllocate(e,n.byteLength),this.setEntry(e,i),i}async readFile(e,t){return qu(await this.readFileBuffer(e),Ul(t))}async readFileBytes(e){return qu(await this.readFileBuffer(e),"binary")}async readFileBuffer(e){gt(e,"open");let t=this.resolvePathWithSymlinks(e),r=this.data.get(t);if(!r)throw Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw Error(`EISDIR: illegal operation on a directory, read '${e}'`);if("lazy"in r){let n=await this.materializeLazy(t,r);return n.content instanceof Uint8Array?n.content:_n.encode(n.content)}return r.content instanceof Uint8Array?r.content:_n.encode(r.content)}async writeFile(e,t,r){this.writeFileSync(e,t,r)}async appendFile(e,t,r){gt(e,"append");let n=we(e),i=this.data.get(n);if(i&&i.type==="directory")throw Error(`EISDIR: illegal operation on a directory, write '${e}'`);let s=Ul(r),a=this.contentByteLength(t,s);if(i?.type==="file"){let o=i;"lazy"in o&&(o=await this.materializeLazy(n,o));let l="content"in o&&o.content instanceof Uint8Array?o.content:_n.encode("content"in o?o.content:"");this.assertCanAllocate(n,l.byteLength+a);let u=cd(t,s),c=new Uint8Array(l.length+u.length);c.set(l),c.set(u,l.length),this.setEntry(n,{type:"file",content:c,mode:o.mode,mtime:new Date})}else this.writeFileSync(e,t,r)}async exists(e){if(e.includes("\0"))return!1;try{let t=this.resolvePathWithSymlinks(e);return this.data.has(t)}catch{return!1}}async stat(e){gt(e,"stat");let t=this.resolvePathWithSymlinks(e),r=this.data.get(t);if(!r)throw Error(`ENOENT: no such file or directory, stat '${e}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(t,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(n=r.content instanceof Uint8Array?r.content.length:_n.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date,identity:this.identityFor(r)}}async lstat(e){gt(e,"lstat");let t=this.resolveIntermediateSymlinks(e),r=this.data.get(t);if(!r)throw Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(t,r));let n=0;return r.type==="file"&&"content"in r&&r.content&&(n=r.content instanceof Uint8Array?r.content.length:_n.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date,identity:this.identityFor(r)}}resolveIntermediateSymlinks(e){let t=we(e);if(t==="/")return"/";let r=t.slice(1).split("/");if(r.length<=1)return t;let n="",i=new Set;for(let s=0;s=40)throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(e){let t=we(e);if(t==="/")return"/";let r=t.slice(1).split("/"),n="",i=new Set;for(let s of r){n=`${n}/${s}`;let a=this.data.get(n),o=0;for(;a&&a.type==="symlink"&&o<40;){if(i.has(n))throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(n),n=jo(n,a.target),a=this.data.get(n),o++}if(o>=40)throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return n}async mkdir(e,t){this.mkdirSync(e,t)}mkdirSync(e,t){gt(e,"mkdir");let r=we(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw Error(`EEXIST: file already exists, mkdir '${e}'`);if(!t?.recursive)throw Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let n=Da(r);if(n!=="/"&&!this.data.has(n))if(t?.recursive)this.mkdirSync(n,{recursive:!0});else throw Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(t=>t.name)}async readdirWithFileTypes(e){gt(e,"scandir");let t=we(e),r=this.data.get(t);if(!r)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);let n=new Set;for(;r&&r.type==="symlink";){if(n.has(t))throw Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);n.add(t),t=jo(t,r.target),r=this.data.get(t)}if(!r)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=t==="/"?"/":`${t}/`,s=new Map;for(let[a,o]of this.data.entries())if(a!==t&&a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&!s.has(u)&&s.set(u,{name:u,isFile:o.type==="file",isDirectory:o.type==="directory",isSymbolicLink:o.type==="symlink"})}return Array.from(s.values()).sort((a,o)=>a.nameo.name))}async rm(e,t){gt(e,"rm");let r=we(e),n=this.data.get(r);if(!n){if(t?.force)return;throw Error(`ENOENT: no such file or directory, rm '${e}'`)}if(n.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!t?.recursive)throw Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let s of i){let a=Vr(r,s);await this.rm(a,t)}}}this.deleteEntry(r)}async cp(e,t,r){gt(e,"cp"),gt(t,"cp");let n=we(e),i=we(t),s=this.data.get(n);if(!s)throw Error(`ENOENT: no such file or directory, cp '${e}'`);if(s.type==="file")if(this.ensureParentDirs(i),"content"in s){let a=s.content instanceof Uint8Array?s.content.byteLength:_n.encode(s.content).byteLength;this.assertCanAllocate(i,a);let o=s.content instanceof Uint8Array?new Uint8Array(s.content):s.content;this.setEntry(i,{...s,content:o})}else this.setEntry(i,{...s});else if(s.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...s});else if(s.type==="directory"){if(!r?.recursive)throw Error(`EISDIR: is a directory, cp '${e}'`);if(ri(n,i))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(n);for(let o of a){let l=Vr(n,o),u=Vr(i,o);await this.cp(l,u,r)}}}async mv(e,t){gt(e,"mv"),gt(t,"mv");let r=we(e),n=we(t);if(r===n)return;let i=this.data.get(r);if(!i)throw Error(`ENOENT: no such file or directory, mv '${e}'`);if(i.type==="directory"&&ri(r,n))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(i.type==="directory"){await this.mkdir(n,{recursive:!0});let s=await this.readdir(r);for(let a of s)await this.mv(Vr(r,a),Vr(n,a));this.deleteEntry(r);return}this.ensureParentDirs(n),this.setEntry(n,i),this.deleteEntry(r)}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,t){return jm(e,t)}async chmod(e,t){gt(e,"chmod");let r=we(e),n=this.data.get(r);if(!n)throw Error(`ENOENT: no such file or directory, chmod '${e}'`);n.mode=t}async symlink(e,t){gt(t,"symlink");let r=we(t);if(this.data.has(r))throw Error(`EEXIST: file already exists, symlink '${t}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,t){gt(e,"link"),gt(t,"link");let r=we(e),n=we(t),i=this.data.get(r);if(!i)throw Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(n))throw Error(`EEXIST: file already exists, link '${t}'`);let s=i;"lazy"in s&&(s=await this.materializeLazy(r,s)),this.ensureParentDirs(n);let a={type:"file",content:s.content,mode:s.mode,mtime:s.mtime};this.entryIdentities.set(a,this.identityFor(s)),this.setEntry(n,a)}async readlink(e){gt(e,"readlink");let t=we(e),r=this.data.get(t);if(!r)throw Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}async realpath(e){gt(e,"realpath");let t=this.resolvePathWithSymlinks(e);if(!this.data.has(t))throw Error(`ENOENT: no such file or directory, realpath '${e}'`);return t}async utimes(e,t,r){gt(e,"utimes");let n=we(e),i=this.resolvePathWithSymlinks(n),s=this.data.get(i);if(!s)throw Error(`ENOENT: no such file or directory, utimes '${e}'`);s.mtime=r}},iC="5.1.0(1)-release",sC="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function yd(e){let{pid:t,ppid:r,uid:n,gid:i}=e;return`Name: bash State: R (running) Pid: ${t} PPid: ${r} Uid: ${n} ${n} ${n} ${n} Gid: ${i} ${i} ${i} ${i} `}function aC(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function oC(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function lC(e){e.mkdirSync("/dev",{recursive:!0}),e.mkdirSync("/dev/fd",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function uC(e,t){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${sC} `),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash `),e.writeFileLazy?e.writeFileLazy("/proc/self/status",()=>yd(t)):e.writeFileSync("/proc/self/status",yd(t)),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function cC(e,t,r={pid:1,ppid:0,uid:1e3,gid:1e3}){aC(e)&&(oC(e,t),lC(e),uC(e,r))}Mr(),Rn(),H(),se(),H();function gn(e){return{kind:e.kind,elements:new Map(e.elements)}}function qi(e){return new Map(Array.from(e??[],([t,r])=>[t,gn(r)]))}function or(e,t){return e.state.arrays?.get(t)}function Ao(e,t,r="indexed"){e.state.arrays??=new Map;let n=e.state.arrays.get(t);return n||(n={kind:r,elements:new Map},e.state.arrays.set(t,n)),n}function Ni(e,t,r){let n=Ao(e,t,r);return n.kind=r,n}function Yr(e,t){return e.state.arrays?.has(t)??!1}function tt(e,t,r){return or(e,t)?.elements.get(String(r))}function $i(e,t,r){return or(e,t)?.elements.has(String(r))??!1}function Ce(e,t,r,n,i){let s=Ao(e,t,i),a=String(r);if(!s.elements.has(a)&&s.elements.size>=e.limits.maxArrayElements)throw new C(`array element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");if(q(n)>e.limits.maxStringLength)throw new C(`array value string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");s.elements.set(a,n)}function $s(e,t,r,n=!1){let i=new Set(n?[]:or(e,t)?.elements.keys()??[]);for(let s of r)if(i.add(String(s)),i.size>e.limits.maxArrayElements)throw new C(`array element limit exceeded (${e.limits.maxArrayElements})`,"array_elements")}function mi(e,t,r){return or(e,t)?.elements.delete(String(r))??!1}function na(e,t){e.state.arrays?.delete(t),e.state.associativeArrays?.delete(t)}function Qt(e,t){return Array.from(or(e,t)?.elements.keys()??[]).filter(r=>/^(0|[1-9]\d*)$/.test(r)).map(Number).sort((r,n)=>r-n)}function ar(e,t){Ao(e,t,e.state.associativeArrays?.has(t)?"associative":"indexed").elements.clear()}function Gi(e,t){return Array.from(or(e,t)?.elements.keys()??[]).sort()}function t1(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function r3(e){if(e.parts.length<2)return null;let t=e.parts[0],r=e.parts[1];if(t.type!=="Glob"||!t.pattern.startsWith("["))return null;let n,i=r,s=1;if(r.type==="Literal"&&r.value.startsWith("]")){let p=r.value.slice(1);if(p.startsWith("+=")||p.startsWith("="))n=t.pattern.slice(1);else if(p===""){if(e.parts.length<3)return null;let h=e.parts[2];if(h.type!=="Literal"||!h.value.startsWith("=")&&!h.value.startsWith("+="))return null;n=t.pattern.slice(1),i=h,s=2}else return null}else if(t.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(e.parts.length<3)return null;let p=e.parts[2];if(p.type!=="Literal"||!p.value.startsWith("]=")&&!p.value.startsWith("]+="))return null;if(r.type==="SingleQuoted")n=r.value;else{n="";for(let h of r.parts)(h.type==="Literal"||h.type==="Escaped")&&(n+=h.value)}i=p,s=2}else if(t.pattern.endsWith("]")){if(r.type!=="Literal"||!r.value.startsWith("=")&&!r.value.startsWith("+="))return null;n=t.pattern.slice(1,-1)}else return null;n=t1(n);let a;if(i.type!=="Literal")return null;a=i.value.startsWith("]=")||i.value.startsWith("]+=")?i.value.slice(1):i.value;let o=a.startsWith("+=");if(!o&&!a.startsWith("="))return null;let l=[],u=o?2:1,c=a.slice(u);c&&l.push({type:"Literal",value:c});for(let p=s+1;p{if(t.type==="Range"){let r=`${t.startStr??String(t.start)}..${t.endStr??String(t.end)}`;return t.step&&(r+=`..${t.step}`),r}return Co(t.word)}).join(",")}}`}function Co(e){let t="";for(let r of e.parts)switch(r.type){case"Literal":t+=r.value;break;case"Glob":t+=r.pattern;break;case"SingleQuoted":t+=r.value;break;case"DoubleQuoted":for(let n of r.parts)(n.type==="Literal"||n.type==="Escaped")&&(t+=n.value);break;case"Escaped":t+=r.value;break;case"BraceExpansion":t+="{",t+=r.items.map(n=>n.type==="Range"?`${n.startStr}..${n.endStr}${n.step?`..${n.step}`:""}`:Co(n.word)).join(","),t+="}";break;case"TildeExpansion":t+="~",r.user&&(t+=r.user)}return t}var hC=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],fC=["braceexpand","hashall","interactive-comments"];function n3(e){let t=[],r=[...fC.map(n=>({name:n,enabled:!0})),...hC.map(n=>({name:n,enabled:e[n]}))].sort((n,i)=>n.name.localeCompare(i.name));for(let n of r)n.enabled&&t.push(n.name);return t.join(":")}function Ha(e){e.state.env.set("SHELLOPTS",n3(e.state.options))}var dC=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function i3(e){let t=[];for(let r of dC)e[r]&&t.push(r);return t.join(":")}function xd(e){e.state.env.set("BASHOPTS",i3(e.state.shoptOptions))}se(),Bs(),Rn();var J={script(e){return{type:"Script",statements:e}},statement(e,t=[],r=!1,n,i){let s={type:"Statement",pipelines:e,operators:t,background:r};return n&&(s.deferredError=n),i!==void 0&&(s.sourceText=i),s},pipeline(e,t=!1,r=!1,n=!1,i){return{type:"Pipeline",commands:e,negated:t,timed:r,timePosix:n,pipeStderr:i}},simpleCommand(e,t=[],r=[],n=[]){return{type:"SimpleCommand",name:e,args:t,assignments:r,redirections:n}},word(e){return{type:"Word",parts:e}},literal(e){return{type:"Literal",value:e}},singleQuoted(e){return{type:"SingleQuoted",value:e}},doubleQuoted(e){return{type:"DoubleQuoted",parts:e}},escaped(e){return{type:"Escaped",value:e}},parameterExpansion(e,t=null){return{type:"ParameterExpansion",parameter:e,operation:t}},commandSubstitution(e,t=!1){return{type:"CommandSubstitution",body:e,legacy:t}},arithmeticExpansion(e){return{type:"ArithmeticExpansion",expression:e}},processSubstitution(e,t){return{type:"ProcessSubstitution",body:e,direction:t}},assignment(e,t,r=!1,n=null){return{type:"Assignment",name:e,value:t,append:r,array:n}},redirection(e,t,r=null,n){let i={type:"Redirection",fd:r,operator:e,target:t};return n&&(i.fdVariable=n),i},hereDoc(e,t,r=!1,n=!1,i){let s={type:"HereDoc",delimiter:e,content:t,stripTabs:r,quoted:n};return i!==void 0&&(s.terminated=i),s},ifNode(e,t=null,r=[]){return{type:"If",clauses:e,elseBody:t,redirections:r}},forNode(e,t,r,n=[]){return{type:"For",variable:e,words:t,body:r,redirections:n}},whileNode(e,t,r=[]){return{type:"While",condition:e,body:t,redirections:r}},untilNode(e,t,r=[]){return{type:"Until",condition:e,body:t,redirections:r}},caseNode(e,t,r=[]){return{type:"Case",word:e,items:t,redirections:r}},caseItem(e,t,r=";;"){return{type:"CaseItem",patterns:e,body:t,terminator:r}},subshell(e,t=[]){return{type:"Subshell",body:e,redirections:t}},group(e,t=[]){return{type:"Group",body:e,redirections:t}},functionDef(e,t,r=[],n){return{type:"FunctionDef",name:e,body:t,redirections:r,sourceFile:n}},conditionalCommand(e,t=[],r){return{type:"ConditionalCommand",expression:e,redirections:t,line:r}},arithmeticCommand(e,t=[],r){return{type:"ArithmeticCommand",expression:e,redirections:t,line:r}}};function mC(e,t){let r=e.length,n=t+3,i=2,s=!1,a=!1;for(;n0;){let o=e[n];if(s){o==="'"&&(s=!1),n++;continue}if(a){if(o==="\\"){n+=2;continue}o==='"'&&(a=!1),n++;continue}if(o==="'"){s=!0,n++;continue}if(o==='"'){a=!0,n++;continue}if(o==="\\"){n+=2;continue}if(o==="("){i++,n++;continue}if(o===")"){if(i--,i===1){let l=n+1;return!(ll===" "||l===" "||l===` `||l===";"||l==="&"||l==="|"||l==="<"||l===">"||l==="("||l===")";for(;n0;for(u||(s=!0),u&&(r+=l),n++;n0;for(u||(s=!0),u&&(r+=l),n++;n0){r+=e.slice(n,n+2),n+=2;continue}s=!0;let u=e[n+1];u!==` `&&(r+=u),n+=2;continue}if(i===0&&(l==="$"||l==="<"||l===">")&&e[n+1]==="("){r+=`${l}(`,i=1,n+=2;continue}if(i===0&&o(l))break;i>0&&(l==="("?i++:l===")"&&i--),r+=l,n++}return{delim:r,endPos:n,quoted:s,unclosedQuote:a,unclosedSubstitution:i>0}}function gC(e,t,r){let n=t+1;for(let{delim:i,stripTabs:s}of r)for(;;){if(n>=e.length)return e.length;let a=e.indexOf(` `,n);a===-1&&(a=e.length);let o=e.slice(n,a);if(s&&(o=o.replace(/^\t+/,"")),o===i){n=a+1;break}if(a>=e.length)return e.length;n=a+1}return Math.min(n,e.length)}function s3(e,t,r){let n=1,i=t,s=!1,a=!1,o=0,l=!1,u="",c=[],p=0;for(;i0;){let h=e[i];if(s)h==="'"&&(s=!1);else if(a)h==="\\"&&i+10&&p--,p===0&&h==="<"&&e[i+1]==="<"&&e[i+2]!=="<"){let f=i+2,d=!1;for(e[f]==="-"&&(d=!0,f++);e[f]===" "||e[f]===" ";)f++;let{delim:m,endPos:g,unclosedQuote:v,unclosedSubstitution:y}=Hu(e,f);if(v&&r(`unexpected EOF while looking for matching \`${v}'`),y&&r("unexpected EOF while looking for matching `)'"),m.length>0){c.push({delim:m,stripTabs:d}),u="",i=g;continue}}if(h===` `&&c.length>0){let f=gC(e,i,c);c.length=0,u="",i=f;continue}h==="'"?(s=!0,u=""):h==='"'?(a=!0,u=""):h==="\\"&&i+10?l=!0:u==="esac"&&o>0&&(o--,l=!1),u="",h==="("?i>0&&e[i-1]==="$"?n++:l||n++:h===")"?l?l=!1:n--:h===";"&&o>0&&i+10&&i++}return n>0&&r("unexpected EOF while looking for matching `)'"),i}function yC(e,t,r,n){let i=t+2,s=s3(e,i,n),a=e.slice(i,s),o=r().parse(a);return{part:J.commandSubstitution(o,!1),endIndex:s+1}}function xC(e,t,r,n){let i=e[t]==="<"?"input":"output",s=t+2,a=s3(e,s,n),o=r().parse(e.slice(s,a));return{part:J.processSubstitution(o,i),endIndex:a+1}}function vC(e,t,r,n,i){let s=t+1,a="";for(;s=e.length&&i("unexpected EOF while looking for matching ``'");let o=n().parse(a);return{part:J.commandSubstitution(o,!0),endIndex:s+1}}var bC=10485760,S;(function(e){e.EOF="EOF",e.NEWLINE="NEWLINE",e.SEMICOLON="SEMICOLON",e.AMP="AMP",e.PIPE="PIPE",e.PIPE_AMP="PIPE_AMP",e.AND_AND="AND_AND",e.OR_OR="OR_OR",e.BANG="BANG",e.LESS="LESS",e.GREAT="GREAT",e.DLESS="DLESS",e.DGREAT="DGREAT",e.LESSAND="LESSAND",e.GREATAND="GREATAND",e.LESSGREAT="LESSGREAT",e.DLESSDASH="DLESSDASH",e.CLOBBER="CLOBBER",e.TLESS="TLESS",e.AND_GREAT="AND_GREAT",e.AND_DGREAT="AND_DGREAT",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.DSEMI="DSEMI",e.SEMI_AND="SEMI_AND",e.SEMI_SEMI_AND="SEMI_SEMI_AND",e.DBRACK_START="DBRACK_START",e.DBRACK_END="DBRACK_END",e.DPAREN_START="DPAREN_START",e.DPAREN_END="DPAREN_END",e.IF="IF",e.THEN="THEN",e.ELSE="ELSE",e.ELIF="ELIF",e.FI="FI",e.FOR="FOR",e.WHILE="WHILE",e.UNTIL="UNTIL",e.DO="DO",e.DONE="DONE",e.CASE="CASE",e.ESAC="ESAC",e.IN="IN",e.FUNCTION="FUNCTION",e.SELECT="SELECT",e.TIME="TIME",e.COPROC="COPROC",e.WORD="WORD",e.NAME="NAME",e.NUMBER="NUMBER",e.ASSIGNMENT_WORD="ASSIGNMENT_WORD",e.FD_VARIABLE="FD_VARIABLE",e.COMMENT="COMMENT",e.HEREDOC_CONTENT="HEREDOC_CONTENT"})(S||={});var Gr=class extends Error{line;column;constructor(e,t,r){super(`line ${t}: ${e}`),this.line=t,this.column=r,this.name="LexerError"}},Vu=new Map([["if",S.IF],["then",S.THEN],["else",S.ELSE],["elif",S.ELIF],["fi",S.FI],["for",S.FOR],["while",S.WHILE],["until",S.UNTIL],["do",S.DO],["done",S.DONE],["case",S.CASE],["esac",S.ESAC],["in",S.IN],["function",S.FUNCTION],["select",S.SELECT],["time",S.TIME],["coproc",S.COPROC]]),wC=new Set(Vu.values());function vd(e){return wC.has(e)}function bd(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let r=e.slice(t[0].length);if(r===""||r==="+")return!0;if(r[0]==="["){let n=0,i=0;for(;i=r.length)return!1;let s=r.slice(i+1);return s===""||s==="+"}return!1}function wd(e){let t=0;for(let r=0;r",">",S.AND_DGREAT]],SC=[["[","[",S.DBRACK_START],["]","]",S.DBRACK_END],["(","(",S.DPAREN_START],[")",")",S.DPAREN_END],["&","&",S.AND_AND],["|","|",S.OR_OR],[";",";",S.DSEMI],[";","&",S.SEMI_AND],["|","&",S.PIPE_AMP],[">",">",S.DGREAT],["<","&",S.LESSAND],[">","&",S.GREATAND],["<",">",S.LESSGREAT],[">","|",S.CLOBBER],["&",">",S.AND_GREAT]],AC=new Map([["|",S.PIPE],["&",S.AMP],[";",S.SEMICOLON],["(",S.LPAREN],[")",S.RPAREN],["<",S.LESS],[">",S.GREAT]]);function CC(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Ed(e){return e===" "||e===" "||e===` `||e===";"||e==="&"||e==="|"||e==="("||e===")"||e==="<"||e===">"}var kC=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];pendingHeredocDelimiterMode;dparenDepth=0;maxHeredocSize;constructor(e,t){this.input=e,this.maxHeredocSize=t?.maxHeredocSize??bC}tokenize(){let e=this.input.length,t=this.tokens,r=this.pendingHeredocs;for(;this.pos0&&t.length>0&&t[t.length-1].type===S.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=e)break;let n=this.nextToken();n&&t.push(n)}return r.length>0&&this.readHeredocContent(),t.push({type:S.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),t}skipWhitespace(){let e=this.input,t=e.length,r=this.pos,n=this.column,i=this.line;for(;r0?(this.pos=t+1,this.column=n+1,this.dparenDepth++,this.makeToken(S.LPAREN,"(",t,r,n)):this.looksLikeNestedSubshells(t+2)||this.dparenClosesWithSpacedParens(t+2)?(this.pos=t+1,this.column=n+1,this.makeToken(S.LPAREN,"(",t,r,n)):(this.pos=t+2,this.column=n+2,this.dparenDepth=1,this.makeToken(S.DPAREN_START,"((",t,r,n))}if(i===")"&&s===")")return this.dparenDepth===1?(this.pos=t+2,this.column=n+2,this.dparenDepth=0,this.makeToken(S.DPAREN_END,"))",t,r,n)):this.dparenDepth>1?(this.pos=t+1,this.column=n+1,this.dparenDepth--,this.makeToken(S.RPAREN,")",t,r,n)):(this.pos=t+1,this.column=n+1,this.makeToken(S.RPAREN,")",t,r,n));for(let[u,c,p]of SC)if(!(u==="("&&c==="("||u===")"&&c===")")&&!(this.dparenDepth>0&&u===";"&&(p===S.DSEMI||p===S.SEMI_AND||p===S.SEMI_SEMI_AND))&&i===u&&s===c){if(p===S.DBRACK_START||p===S.DBRACK_END){let h=e[t+2];if(h!==void 0&&h!==" "&&h!==" "&&h!==` `&&h!==";"&&h!=="&"&&h!=="|"&&h!=="("&&h!==")"&&h!=="<"&&h!==">")break}return this.pos=t+2,this.column=n+2,this.makeToken(p,u+c,t,r,n)}if(i==="("&&this.dparenDepth>0)return this.pos=t+1,this.column=n+1,this.dparenDepth++,this.makeToken(S.LPAREN,"(",t,r,n);if(i===")"&&this.dparenDepth>1)return this.pos=t+1,this.column=n+1,this.dparenDepth--,this.makeToken(S.RPAREN,")",t,r,n);let l=AC.get(i);if(l!==void 0)return this.pos=t+1,this.column=n+1,this.makeToken(l,i,t,r,n);if(i==="{"){let u=this.scanFdVariable(t);return u===null?s==="}"?(this.pos=t+2,this.column=n+2,{type:S.WORD,value:"{}",start:t,end:t+2,line:r,column:n,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(t)===null&&this.scanLiteralBraceWord(t)===null?s!==void 0&&s!==" "&&s!==" "&&s!==` `?this.readWord(t,r,n):(this.pos=t+1,this.column=n+1,this.makeToken(S.LBRACE,"{",t,r,n)):this.readWordWithBraceExpansion(t,r,n):(this.pos=u.end,this.column=n+(u.end-t),{type:S.FD_VARIABLE,value:u.varname,start:t,end:u.end,line:r,column:n})}return i==="}"?this.isWordCharFollowing(t+1)?this.readWord(t,r,n):(this.pos=t+1,this.column=n+1,this.makeToken(S.RBRACE,"}",t,r,n)):i==="!"?s==="="?(this.pos=t+2,this.column=n+2,this.makeToken(S.WORD,"!=",t,r,n)):(this.pos=t+1,this.column=n+1,this.makeToken(S.BANG,"!",t,r,n)):this.readWord(t,r,n)}looksLikeNestedSubshells(e){let t=this.input,r=t.length,n=e;for(;n=r)return!1;let i=t[n];if(i==="(")return this.looksLikeNestedSubshells(n+1);let s=/[a-zA-Z_]/.test(i),a=i==="!"||i==="[";if(!s&&!a)return!1;let o=n;for(;o=r)return!1;let u=t[l];if(u==="="&&t[l+1]!=="="||u===` `||o===l&&/[+\-*/%<>&|^!~?:]/.test(u)&&u!=="-"||u===")"&&t[l+1]===")")return!1;if(l>o&&(u==="-"||u==='"'||u==="'"||u==="$"||/[a-zA-Z_/.]/.test(u))){let c=l;for(;c"||y==="'"||y==='"'||y==="\\"||y==="$"||y==="`"||y==="{"||y==="}"||y==="~"||y==="*"||y==="?"||y==="[")break;s++}if(s>a){let y=n[s];if(!(y==="("&&s>a&&"@*+?!".includes(n[s-1]))&&(s>=i||y===" "||y===" "||y===` `||y===";"||y==="&"||y==="|"||y==="("||y===")"||y==="<"||y===">")){let x=n.slice(a,s);this.pos=s,this.column=r+(s-a);let b=Vu.get(x);if(b!==void 0)return{type:b,value:x,start:e,end:s,line:t,column:r};let w=wd(x);return w>0&&bd(x.slice(0,w))?{type:S.ASSIGNMENT_WORD,value:x,start:e,end:s,line:t,column:r}:/^[0-9]+$/.test(x)?{type:S.NUMBER,value:x,start:e,end:s,line:t,column:r}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(x)?{type:S.NAME,value:x,start:e,end:s,line:t,column:r,quoted:!1,singleQuoted:!1}:{type:S.WORD,value:x,start:e,end:s,line:t,column:r,quoted:!1,singleQuoted:!1}}}s=this.pos;let o=this.column,l=this.line,u="",c=!1,p=!1,h=!1,f=!1,d=n[s]==='"'||n[s]==="'",m=!1,g=0;for(;s0&&"@*+?!".includes(u[u.length-1])){let x=this.scanExtglobPattern(s);if(x!==null){u+=x.content,s=x.end,o+=x.content.length;continue}}if(y==="["&&g===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){let x=s+10){u.length>0&&u[u.length-1]!=="\\"&&g++,u+=y,s++,o++;continue}else if(y==="]"&&g>0){u.length>0&&u[u.length-1]!=="\\"&&g--,u+=y,s++,o++;continue}if(g>0){if(y===` `)break;u+=y,s++,o++;continue}if(y===" "||y===" "||y===` `||y===";"||y==="&"||y==="|"||y==="("||y===")"||y==="<"||y===">")break}if(y==="$"&&s+10&&s0&&$--,$===0&&L==="<"&&n[s+1]==="<"&&n[s+2]!=="<"){let _=s+2,R=!1;for(n[_]==="-"&&(R=!0,_++);n[_]===" "||n[_]===" ";)_++;let{delim:B,endPos:j,unclosedQuote:P,unclosedSubstitution:F}=Hu(n,_);if(P)throw new Gr(`unexpected EOF while looking for matching \`${P}'`,l,o);if(F)throw new Gr("unexpected EOF while looking for matching `)'",l,o);if(B.length>0){u+=n.slice(s+1,j),o+=j-s,N.push({delim:B,stripTabs:R}),s=j;continue}}if(L===` `&&N.length>0){l++,o=0;let _=s+1;for(let{delim:R,stripTabs:B}of N)for(;!(_>=i);){let j=n.indexOf(` `,_);j===-1&&(j=i);let P=n.slice(_,j),F=B?P.replace(/^\t+/,""):P;u+=n.slice(_,Math.min(j+1,i)),j=i;if(_=j+1,F===R||G)break}N.length=0,o=0,s=Math.min(_,i);continue}if(L==="'")b=!0,O="";else if(L==='"')w=!0,O="";else if(L==="\\"&&s+10&&s0?A=!0:O==="esac"&&E>0&&(E--,A=!1),O="",L==="("?s>0&&n[s-1]==="$"?x++:A||x++:L===")"?A?A=!1:x--:L===";"&&E>0&&(s+10&&s0&&s="0"&&x<="9"){u+=y+x,s+=2,o+=2;continue}}if(y==="`"&&!h){for(u+=y,s++,o++;s=2){if(u[0]==="'"&&u[u.length-1]==="'"){let y=u.slice(1,-1);!y.includes("'")&&!y.includes('"')&&(u=y,c=!0,p=!0)}else if(u[0]==='"'&&u[u.length-1]==='"'){let y=u.slice(1,-1),x=!1;for(let b=0;b0&&bd(u.slice(0,y)))return{type:S.ASSIGNMENT_WORD,value:u,start:e,end:s,line:t,column:r,quoted:c,singleQuoted:p}}return/^[0-9]+$/.test(u)?{type:S.NUMBER,value:u,start:e,end:s,line:t,column:r}:CC(u)?{type:S.NAME,value:u,start:e,end:s,line:t,column:r,quoted:c,singleQuoted:p}:{type:S.WORD,value:u,start:e,end:s,line:t,column:r,quoted:c,singleQuoted:p}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let t=this.pos,r=this.line,n=this.column,i="",s=!1;for(;this.pos=this.input.length)break;l=l.slice(0,-1),o+=`${a} `,this.pos++,this.line++,this.column=1}if((e.stripTabs?l.replace(/^\t+/,""):l)===e.delimiter){s=!0,this.pos0&&(i+=` `),i.length>this.maxHeredocSize)throw new Gr(`Heredoc size limit exceeded (${this.maxHeredocSize} bytes)`,r,n)}this.tokens.push({type:S.HEREDOC_CONTENT,value:i,start:t,end:this.pos,line:r,column:n,heredocTerminated:s})}}readHeredocDelimiterToken(e,t,r,n){let i=this.input,{delim:s,endPos:a,quoted:o,unclosedQuote:l,unclosedSubstitution:u}=Hu(i,e);if(l)throw new Gr(`unexpected EOF while looking for matching \`${l}'`,t,r);if(u)throw new Gr("unexpected EOF while looking for matching `)'",t,r);if(a===e)throw new Gr("Expected here-document delimiter",t,r);let c=t,p=r;for(let h=e;h=this.input.length)return!1;let t=this.input[e];return t!==" "&&t!==" "&&t!==` `&&t!==";"&&t!=="&"&&t!=="|"&&t!=="("&&t!==")"&&t!=="<"&&t!==">"}readWordWithBraceExpansion(e,t,r){let n=this.input,i=n.length,s=e,a=r;for(;s")break;if(l==="{"){if(this.scanBraceExpansion(s)!==null){let u=1;for(s++,a++;s0;)n[s]==="{"?u++:n[s]==="}"&&u--,s++,a++;continue}s++,a++;continue}if(l==="}"){s++,a++;continue}if(l==="$"&&s+10&&s0&&s0;){let o=t[n];if(o==="{")i++,n++;else if(o==="}")i--,n++;else if(o===","&&i===1)s=!0,n++;else if(o==="."&&n+10;){let s=t[n];if(s==="{")i++,n++;else if(s==="}"){if(i--,i===0)return t.slice(e,n+1);n++}else{if(s===" "||s===" "||s===` `||s===";"||s==="&"||s==="|")return null;n++}}return null}scanExtglobPattern(e){let t=this.input,r=t.length,n=e+1,i=1;for(;n0;){let s=t[n];if(s==="\\"&&n+1="a"&&l<="z"||l>="A"&&l<="Z"||l==="_"))return null}else if(!(l>="a"&&l<="z"||l>="A"&&l<="Z"||l>="0"&&l<="9"||l==="_"))break;n++}if(n===i)return null;let s=t.slice(i,n);if(n>=r||t[n]!=="}"||(n++,n>=r))return null;let a=t[n],o=n+1"||a==="<"||a==="&"&&(o===">"||o==="<")?{varname:s,end:n}:null}dollarDparenIsSubshell(e){let t=this.input,r=t.length,n=e+1,i=2,s=!1,a=!1,o=!1;for(;n0;){let l=t[n];if(s){l==="'"&&(s=!1),l===` `&&(o=!0),n++;continue}if(a){if(l==="\\"){n+=2;continue}l==='"'&&(a=!1),l===` `&&(o=!0),n++;continue}if(l==="'"){s=!0,n++;continue}if(l==='"'){a=!0,n++;continue}if(l==="\\"){n+=2;continue}if(l===` `&&(o=!0),l==="("){i++,n++;continue}if(l===")"){if(i--,i===1){let u=n+1;if(u0;){let o=t[n];if(s){o==="'"&&(s=!1),n++;continue}if(a){if(o==="\\"){n+=2;continue}o==='"'&&(a=!1),n++;continue}if(o==="'"){s=!0,n++;continue}if(o==='"'){a=!0,n++;continue}if(o==="\\"){n+=2;continue}if(o==="("){i++,n++;continue}if(o===")"){if(i--,i===1){let l=n+1;if(lNC)throw new vr("Maximum parse iterations exceeded (possible infinite loop)",e,t)}chargeTokens(e,t=1,r=1){if(this.tokens+=e,this.tokens>Va)throw new vr(`Too many tokens: cumulative count exceeds limit of ${Va}`,t,r)}enter(e,t){if(this.depth++,this.depth>Ad)throw this.depth--,new vr(`Maximum parser nesting depth exceeded (${Ad})`,e,t);let r=!0;return()=>{r&&(r=!1,this.depth--)}}};Ar(),wt(),H();function ut(e,t){for(;t>=","&=","|=","^="];function Qu(e){if(e.includes("#")){let r=e.split("#");if(r.length!==2)return NaN;let[n,i]=r;if(!/^\d+$/.test(n)||i.length===0)return NaN;let s=Number.parseInt(n,10);if(s<2||s>64)return NaN;let a=0;for(let o of i){let l;if(/[0-9]/.test(o))l=o.charCodeAt(0)-48;else if(/[a-z]/.test(o))l=o.charCodeAt(0)-97+10;else if(/[A-Z]/.test(o))l=o.charCodeAt(0)-65+(s<=36?10:36);else if(o==="@")l=62;else if(o==="_")l=63;else return NaN;if(l>=s)return NaN;if(a=a*s+l,a>2**53-1)return 2**53-1}return a}if(e.startsWith("0x")||e.startsWith("0X")){let r=Number.parseInt(e.slice(2),16);return r>2**53-1?2**53-1:r}if(e.startsWith("0")&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return NaN;let r=Number.parseInt(e,8);return r>2**53-1?2**53-1:r}let t=Number.parseInt(e,10);return t>2**53-1?2**53-1:t}function RC(e,t,r,n){if(r.slice(n,n+3)!=="$((")return null;let i=n+3,s=1,a=i;for(;i0;)r[i]==="("&&r[i+1]==="("?(s++,i+=2):r[i]===")"&&r[i+1]===")"?(s--,s>0&&(i+=2)):i++;let{expr:o}=e(t,r.slice(a,i),0);return i+=2,{expr:{type:"ArithNested",expression:o},pos:i}}function PC(e,t){if(e.slice(t,t+2)!=="$'")return null;let r=t+2,n="";for(;r=e.length}function Ws(e,t,r){return MC(e,t,r)}function Kn(e,t,r){return e.withDepth(()=>Ws(e,t,r))}function MC(e,t,r){let{expr:n,pos:i}=Os(e,t,r);for(i=ut(t,i);t[i]===",";){if(i++,Yt(t,i))return Xt(",",i);let{expr:s,pos:a}=Os(e,t,i);n={type:"ArithBinary",operator:",",left:n,right:s},i=ut(t,a)}return{expr:n,pos:i}}function Os(e,t,r){let{expr:n,pos:i}=FC(e,t,r);if(i=ut(t,i),t[i]==="?"){i++;let{expr:s,pos:a}=Kn(e,t,i);if(i=ut(t,a),t[i]===":"){i++;let{expr:o,pos:l}=Kn(e,t,i);return{expr:{type:"ArithTernary",condition:n,consequent:s,alternate:o},pos:l}}}return{expr:n,pos:i}}function FC(e,t,r){let{expr:n,pos:i}=Cd(e,t,r);for(;i=ut(t,i),t.slice(i,i+2)==="||";){if(i+=2,Yt(t,i))return Xt("||",i);let{expr:s,pos:a}=Cd(e,t,i);n={type:"ArithBinary",operator:"||",left:n,right:s},i=a}return{expr:n,pos:i}}function Cd(e,t,r){let{expr:n,pos:i}=kd(e,t,r);for(;i=ut(t,i),t.slice(i,i+2)==="&&";){if(i+=2,Yt(t,i))return Xt("&&",i);let{expr:s,pos:a}=kd(e,t,i);n={type:"ArithBinary",operator:"&&",left:n,right:s},i=a}return{expr:n,pos:i}}function kd(e,t,r){let{expr:n,pos:i}=Nd(e,t,r);for(;i=ut(t,i),t[i]==="|"&&t[i+1]!=="|";){if(i++,Yt(t,i))return Xt("|",i);let{expr:s,pos:a}=Nd(e,t,i);n={type:"ArithBinary",operator:"|",left:n,right:s},i=a}return{expr:n,pos:i}}function Nd(e,t,r){let{expr:n,pos:i}=$d(e,t,r);for(;i=ut(t,i),t[i]==="^";){if(i++,Yt(t,i))return Xt("^",i);let{expr:s,pos:a}=$d(e,t,i);n={type:"ArithBinary",operator:"^",left:n,right:s},i=a}return{expr:n,pos:i}}function $d(e,t,r){let{expr:n,pos:i}=Od(e,t,r);for(;i=ut(t,i),t[i]==="&"&&t[i+1]!=="&";){if(i++,Yt(t,i))return Xt("&",i);let{expr:s,pos:a}=Od(e,t,i);n={type:"ArithBinary",operator:"&",left:n,right:s},i=a}return{expr:n,pos:i}}function Od(e,t,r){let{expr:n,pos:i}=Td(e,t,r);for(;i=ut(t,i),t.slice(i,i+2)==="=="||t.slice(i,i+2)==="!=";){let s=t.slice(i,i+2);if(i+=2,Yt(t,i))return Xt(s,i);let{expr:a,pos:o}=Td(e,t,i);n={type:"ArithBinary",operator:s,left:n,right:a},i=o}return{expr:n,pos:i}}function Td(e,t,r){let{expr:n,pos:i}=Wl(e,t,r);for(;;)if(i=ut(t,i),t.slice(i,i+2)==="<="||t.slice(i,i+2)===">="){let s=t.slice(i,i+2);if(i+=2,Yt(t,i))return Xt(s,i);let{expr:a,pos:o}=Wl(e,t,i);n={type:"ArithBinary",operator:s,left:n,right:a},i=o}else if(t[i]==="<"||t[i]===">"){let s=t[i];if(i++,Yt(t,i))return Xt(s,i);let{expr:a,pos:o}=Wl(e,t,i);n={type:"ArithBinary",operator:s,left:n,right:a},i=o}else break;return{expr:n,pos:i}}function Wl(e,t,r){let{expr:n,pos:i}=Id(e,t,r);for(;i=ut(t,i),t.slice(i,i+2)==="<<"||t.slice(i,i+2)===">>";){let s=t.slice(i,i+2);if(i+=2,Yt(t,i))return Xt(s,i);let{expr:a,pos:o}=Id(e,t,i);n={type:"ArithBinary",operator:s,left:n,right:a},i=o}return{expr:n,pos:i}}function Id(e,t,r){let{expr:n,pos:i}=Rd(e,t,r);for(;i=ut(t,i),(t[i]==="+"||t[i]==="-")&&t[i+1]!==t[i];){let s=t[i];if(i++,Yt(t,i))return Xt(s,i);let{expr:a,pos:o}=Rd(e,t,i);n={type:"ArithBinary",operator:s,left:n,right:a},i=o}return{expr:n,pos:i}}function Rd(e,t,r){let{expr:n,pos:i}=Ea(e,t,r);for(;;)if(i=ut(t,i),t[i]==="*"&&t[i+1]!=="*"){if(i++,Yt(t,i))return Xt("*",i);let{expr:s,pos:a}=Ea(e,t,i);n={type:"ArithBinary",operator:"*",left:n,right:s},i=a}else if(t[i]==="/"||t[i]==="%"){let s=t[i];if(i++,Yt(t,i))return Xt(s,i);let{expr:a,pos:o}=Ea(e,t,i);n={type:"ArithBinary",operator:s,left:n,right:a},i=o}else break;return{expr:n,pos:i}}function Ea(e,t,r){let{expr:n,pos:i}=Ku(e,t,r),s=ut(t,i);if(t.slice(s,s+2)==="**"){if(s+=2,Yt(t,s))return Xt("**",s);let{expr:a,pos:o}=e.withDepth(()=>Ea(e,t,s));return{expr:{type:"ArithBinary",operator:"**",left:n,right:a},pos:o}}return{expr:n,pos:i}}function Ku(e,t,r){let n=ut(t,r);if(t.slice(n,n+2)==="++"||t.slice(n,n+2)==="--"){let i=t.slice(n,n+2);n+=2;let{expr:s,pos:a}=e.withDepth(()=>Ku(e,t,n));return{expr:{type:"ArithUnary",operator:i,operand:s,prefix:!0},pos:a}}if(t[n]==="+"||t[n]==="-"||t[n]==="!"||t[n]==="~"){let i=t[n];n++;let{expr:s,pos:a}=e.withDepth(()=>Ku(e,t,n));return{expr:{type:"ArithUnary",operator:i,operand:s,prefix:!0},pos:a}}return zC(e,t,n)}function _C(e,t){let r=e[t];return r==="$"||r==="`"}function zC(e,t,r){let{expr:n,pos:i}=Pd(e,t,r,!1),s=[n];for(;_C(t,i);){let{expr:o,pos:l}=Pd(e,t,i,!0);s.push(o),i=l}s.length>1&&(n={type:"ArithConcat",parts:s});let a;if(t[i]==="["&&n.type==="ArithConcat"){i++;let{expr:o,pos:l}=Kn(e,t,i);a=o,i=l,t[i]==="]"&&i++}if(a&&n.type==="ArithConcat"&&(n={type:"ArithDynamicElement",nameExpr:n,subscript:a},a=void 0),i=ut(t,i),n.type==="ArithConcat"||n.type==="ArithVariable"||n.type==="ArithDynamicElement"){for(let o of Zu)if(t.slice(i,i+o.length)===o&&t.slice(i,i+o.length+1)!=="=="){i+=o.length;let{expr:l,pos:u}=e.withDepth(()=>Os(e,t,i));return n.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:o,target:n.nameExpr,subscript:n.subscript,value:l},pos:u}:n.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:o,target:n,value:l},pos:u}:{expr:{type:"ArithAssignment",operator:o,variable:n.name,value:l},pos:u}}}if(t.slice(i,i+2)==="++"||t.slice(i,i+2)==="--"){let o=t.slice(i,i+2);return i+=2,{expr:{type:"ArithUnary",operator:o,operand:n,prefix:!1},pos:i}}return{expr:n,pos:i}}function Pd(e,t,r,n=!1){let i=ut(t,r),s=RC(Kn,e,t,i);if(s)return s;let a=PC(t,i);if(a)return a;let o=DC(t,i);if(o)return o;if(t.slice(i,i+2)==="$("&&t[i+2]!=="("){i+=2;let u=1,c=i;for(;i0;)t[i]==="("?u++:t[i]===")"&&u--,u>0&&i++;let p=t.slice(c,i);return i++,{expr:{type:"ArithCommandSubst",command:p},pos:i}}if(t[i]==="`"){i++;let u=i;for(;i0;)t[p]==="{"?c++:t[p]==="}"&&c--,c>0&&p++;let h=t.slice(u,p),f=p+1;if(t[f]==="#"){let d=f+1;for(;dOs(e,t,i));return{expr:{type:"ArithAssignment",operator:h,variable:u,subscript:p,stringKey:c,value:f},pos:d}}}return{expr:{type:"ArithArrayElement",array:u,index:p,stringKey:c},pos:i}}if(i=ut(t,i),!n){for(let c of Zu)if(t.slice(i,i+c.length)===c&&t.slice(i,i+c.length+1)!=="=="){i+=c.length;let{expr:p,pos:h}=e.withDepth(()=>Os(e,t,i));return{expr:{type:"ArithAssignment",operator:c,variable:u,value:p},pos:h}}}return{expr:{type:"ArithVariable",name:u,hasDollarPrefix:l},pos:i}}if(t[i]==="#"){let u=i+1;for(;u{let t,r="";for(let n=0;n=194){let i=(n&31)<<6|e[r+1]&63;t+=String.fromCharCode(i),r+=2;continue}t+=String.fromCharCode(n),r++;continue}if((n&240)==224){if(r+2=55296&&i<=57343){t+=String.fromCharCode(n),r++;continue}t+=String.fromCharCode(i),r+=3;continue}t+=String.fromCharCode(n),r++;continue}if((n&248)==240&&n<=244){if(r+31114111){t+=String.fromCharCode(n),r++;continue}t+=String.fromCodePoint(i),r+=4;continue}t+=String.fromCharCode(n),r++;continue}t+=String.fromCharCode(n),r++}return t}function UC(e,t,r){let n=r+1;for(;n0;)t[a]===n?s++:t[a]===i&&s--,s>0&&a++;return s===0?a:-1}function gi(e,t,r){let n=r,i=1;for(;n0;){let s=t[n];if(s==="\\"&&n+10&&n++}return n}function WC(e,t,r){let n=r,i=!1;for(;n0)a.push(u),o+=2+l.length;else break}a.length>0?(n+=BC(a),i=o):(n+="\\x",i+=2);break}case"u":{let a=t.slice(i+2,i+6),o=parseInt(a,16);Number.isNaN(o)?(n+="\\u",i+=2):(n+=String.fromCharCode(o),i+=6);break}case"c":if(i+2e.withDepth(()=>({type:"Word",word:J.word(n(e,l,!1,!1,!1))})))},endIndex:i+1}:s.includes(",")?{part:{type:"BraceExpansion",items:Ld(s).map(l=>({type:"Word",word:J.word([J.literal(l)])}))},endIndex:i+1}:null}function l3(e,t){let r="";for(let n of t.parts)switch(n.type){case"Literal":r+=n.value;break;case"SingleQuoted":r+=`'${n.value}'`;break;case"Escaped":r+=n.value;break;case"DoubleQuoted":r+='"';for(let i of n.parts)i.type==="Literal"||i.type==="Escaped"?r+=i.value:i.type==="ParameterExpansion"&&(r+=`\${${i.parameter}}`);r+='"';break;case"ParameterExpansion":r+=`\${${n.parameter}}`;break;case"Glob":r+=n.pattern;break;case"TildeExpansion":r+="~",n.user&&(r+=n.user);break;case"BraceExpansion":{r+="{";let i=[];for(let s of n.items)if(s.type==="Range"){let a=s.startStr??String(s.start),o=s.endStr??String(s.end);s.step===void 0?i.push(`${a}..${o}`):i.push(`${a}..${o}..${s.step}`)}else i.push(l3(e,s.word));i.length===1&&n.items[0].type==="Range"?r+=i[0]:r+=i.join(","),r+="}";break}default:r+=n.type}return r}function VC(e,t){return{[S.LESS]:"<",[S.GREAT]:">",[S.DGREAT]:">>",[S.LESSAND]:"<&",[S.GREATAND]:">&",[S.LESSGREAT]:"<>",[S.CLOBBER]:">|",[S.TLESS]:"<<<",[S.AND_GREAT]:"&>",[S.AND_DGREAT]:"&>>",[S.DLESS]:"<",[S.DLESSDASH]:"<"}[t]||">"}function Za(e){let t=e.current(),r=t.type;if(r===S.NUMBER){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:OC.has(n.type)}if(r===S.FD_VARIABLE){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:TC.has(n.type)}return!e.isProcessSubstitutionStart()&&$C.has(r)}function Xu(e){let t=null,r;e.check(S.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(S.FD_VARIABLE)&&(r=e.advance().value);let n=e.advance(),i=VC(e,n.type);if(n.type===S.DLESS||n.type===S.DLESSDASH)return ZC(e,t,r,n.type===S.DLESSDASH);e.isWord()||e.error("Expected redirection target");let s=e.parseWord();return J.redirection(i,s,t,r)}function ZC(e,t,r,n){e.isWord()||e.error("Expected here-document delimiter");let i=e.advance(),s=i.heredocDelimiter??i.value,a=i.quoted||!1,o=J.redirection(n?"<<-":"<<",J.hereDoc(s,J.word([]),n,a),t,r);return e.addPendingHeredoc(o,s,n,a),o}function Md(e){let t=e.getSourceLine(),r=[],n=null,i=[],s=[];for(;e.check(S.ASSIGNMENT_WORD)||Za(e);)e.checkIterationLimit(),e.check(S.ASSIGNMENT_WORD)?r.push(QC(e)):s.push(Xu(e));if(e.isWord())n=e.parseWord();else if(r.length>0&&(e.check(S.DBRACK_START)||e.check(S.DPAREN_START))){let o=e.advance();n=J.word([J.literal(o.value)])}for(;(!e.isStatementEnd()||e.check(S.RBRACE))&&!e.check(S.PIPE,S.PIPE_AMP);)if(e.checkIterationLimit(),Za(e))s.push(Xu(e));else if(e.check(S.ASSIGNMENT_WORD)){let o=e.advance(),l=o.value,u=l.endsWith("="),c=l.endsWith("=(");if((u||c)&&(c||e.check(S.LPAREN))){let p=c?l.slice(0,-2):l.slice(0,-1);c||e.expect(S.LPAREN);let h=Yu(e);e.expect(S.RPAREN);let f=`${p}=(${h.map(d=>l3(e,d)).join(" ")})`;i.push(e.parseWordFromString(f,!1,!1,!0))}else{let p=e.parseWordFromString(l,o.quoted,o.singleQuoted,!0);i.push(e.parseAdjacentWordParts(p.parts,o.end,Vt.Assignment))}}else if(e.isWord())i.push(e.parseWord());else if(e.check(S.RBRACE)){let o=e.advance();i.push(e.parseWordFromString(o.value,!1,!1))}else if(e.check(S.LBRACE)){let o=e.advance();i.push(e.parseWordFromString(o.value,!1,!1))}else if(e.check(S.DBRACK_END)){let o=e.advance();i.push(e.parseWordFromString(o.value,!1,!1))}else if(e.check(S.LPAREN))e.error("syntax error near unexpected token `('");else break;let a=J.simpleCommand(n,i,r,s);return a.line=t,a}function QC(e){let t=e.expect(S.ASSIGNMENT_WORD),r=t.value,n=r.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);n||e.error(`Invalid assignment: ${r}`);let i=n[0],s,a=i.length;if(r[a]==="["){let p=0,h=a+1;for(;a2)break}else p.value==="("&&l++,p.value===")"&&l--,a[o]+=p.value}e.expect(S.DPAREN_END),a[0].trim()&&(n=ct(e,a[0].trim())),a[1].trim()&&(i=ct(e,a[1].trim())),a[2].trim()&&(s=ct(e,a[2].trim())),e.skipNewlines(),e.check(S.SEMICOLON)&&e.advance(),e.skipNewlines();let u;e.check(S.LBRACE)?(e.advance(),u=e.parseCompoundList(),e.expect(S.RBRACE)):(e.expect(S.DO),u=e.parseCompoundList(),e.expect(S.DONE));let c=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:"CStyleFor",init:n,condition:i,update:s,body:u,redirections:c,line:r}}function zd(e,t){e.expect(S.WHILE);let r=e.parseCompoundList();e.expect(S.DO);let n=e.parseCompoundList();n.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(S.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return J.whileNode(r,n,i)}function Bd(e,t){e.expect(S.UNTIL);let r=e.parseCompoundList();e.expect(S.DO);let n=e.parseCompoundList();n.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(S.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return J.untilNode(r,n,i)}function Ud(e,t){e.expect(S.CASE),e.isWord()||e.error("Expected word after 'case'");let r=e.parseWord();e.skipNewlines(),e.expect(S.IN),e.skipNewlines();let n=[];for(;!e.check(S.ESAC,S.EOF);){e.checkIterationLimit();let s=e.getPos(),a=YC(e);if(a&&n.push(a),e.skipNewlines(),e.getPos()===s&&!a)break}e.expect(S.ESAC);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return J.caseNode(r,n,i)}function YC(e){e.check(S.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(S.PIPE));)e.advance();if(t.length===0)return null;e.expect(S.RPAREN),e.skipNewlines();let r=[];for(;!e.check(S.DSEMI,S.SEMI_AND,S.SEMI_SEMI_AND,S.ESAC,S.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===S.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(S.LPAREN)&&e.peek(1).type===S.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let i=e.getPos(),s=e.parseStatement();if(s&&r.push(s),e.skipSeparators(!1),e.getPos()===i&&!s)break}let n=";;";return e.check(S.DSEMI)?(e.advance(),n=";;"):e.check(S.SEMI_AND)?(e.advance(),n=";&"):e.check(S.SEMI_SEMI_AND)&&(e.advance(),n=";;&"),J.caseItem(t,r,n)}function Wd(e,t){e.expect(S.LPAREN);let r=e.parseCompoundList();e.expect(S.RPAREN);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return J.subshell(r,n)}function jd(e,t){e.expect(S.LBRACE);let r=e.parseCompoundList();e.expect(S.RBRACE);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return J.group(r,n)}var JC="-a.-b.-c.-d.-e.-f.-g.-h.-k.-p.-r.-s.-t.-u.-w.-x.-G.-L.-N.-O.-S.-z.-n.-o.-v.-R".split("."),ek=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"];function qd(e){return e.isWord()||e.check(S.LBRACE)||e.check(S.RBRACE)||e.check(S.ASSIGNMENT_WORD)}function Gd(e){if(e.check(S.BANG)&&e.peek(1).type===S.LPAREN){e.advance(),e.advance();let t=1,r="!(";for(;t>0&&!e.check(S.EOF);)if(e.check(S.LPAREN))t++,r+="(",e.advance();else if(e.check(S.RPAREN))t--,t>0&&(r+=")"),e.advance();else if(e.isWord())r+=e.advance().value;else if(e.check(S.PIPE))r+="|",e.advance();else break;return r+=")",e.parseWordFromString(r,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function u3(e){return e.skipNewlines(),tk(e)}function tk(e){let t=Hd(e);for(e.skipNewlines();e.check(S.OR_OR);){e.advance(),e.skipNewlines();let r=Hd(e);t={type:"CondOr",left:t,right:r},e.skipNewlines()}return t}function Hd(e){let t=Ju(e);for(e.skipNewlines();e.check(S.AND_AND);){e.advance(),e.skipNewlines();let r=Ju(e);t={type:"CondAnd",left:t,right:r},e.skipNewlines()}return t}function Ju(e){return e.skipNewlines(),e.check(S.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:e.withDepth(()=>Ju(e))}):rk(e)}function rk(e){if(e.check(S.LPAREN)){e.advance();let t=e.withDepth(()=>u3(e));return e.expect(S.RPAREN),{type:"CondGroup",expression:t}}if(qd(e)){let t=e.current(),r=t.value;if(JC.includes(r)&&!t.quoted){if(e.advance(),e.check(S.DBRACK_END)&&e.error(`Expected operand after ${r}`),qd(e))return{type:"CondUnary",operator:r,operand:e.parseWordNoBraceExpansion()};let i=e.current();e.error(`unexpected argument \`${i.value}' to conditional unary operator`)}let n=e.parseWordNoBraceExpansion();if(e.isWord()&&ek.includes(e.current().value)){let i=e.advance().value,s;return s=i==="=~"?nk(e):i==="=="||i==="!="?Gd(e):e.parseWordNoBraceExpansion(),{type:"CondBinary",operator:i,left:n,right:s}}return e.check(S.LESS)?(e.advance(),{type:"CondBinary",operator:"<",left:n,right:e.parseWordNoBraceExpansion()}):e.check(S.GREAT)?(e.advance(),{type:"CondBinary",operator:">",left:n,right:e.parseWordNoBraceExpansion()}):e.isWord()&&e.current().value==="="?(e.advance(),{type:"CondBinary",operator:"==",left:n,right:Gd(e)}):{type:"CondWord",word:n}}e.error("Expected conditional expression")}function nk(e){let t=[],r=0,n=-1,i=e.getInput(),s=()=>e.check(S.DBRACK_END)||e.check(S.AND_AND)||e.check(S.OR_OR)||e.check(S.NEWLINE)||e.check(S.EOF);for(;!s();){let a=e.current(),o=n>=0&&a.start>n;if(r===0&&o)break;if(r>0&&o){let l=i.slice(n,a.start);t.push({type:"Literal",value:l})}if(e.isWord()||e.check(S.ASSIGNMENT_WORD)){let l=e.parseWordForRegex();t.push(...l.parts),n=e.peek(-1).end}else if(e.check(S.LPAREN)){let l=e.advance();t.push({type:"Literal",value:"("}),r++,n=l.end}else if(e.check(S.DPAREN_START)){let l=e.advance();t.push({type:"Literal",value:"(("}),r+=2,n=l.end}else if(e.check(S.DPAREN_END))if(r>=2){let l=e.advance();t.push({type:"Literal",value:"))"}),r-=2,n=l.end}else{if(r===1)break;break}else if(e.check(S.RPAREN))if(r>0){let l=e.advance();t.push({type:"Literal",value:")"}),r--,n=l.end}else break;else if(e.check(S.PIPE)){let l=e.advance();t.push({type:"Literal",value:"|"}),n=l.end}else if(e.check(S.SEMICOLON))if(r>0){let l=e.advance();t.push({type:"Literal",value:";"}),n=l.end}else break;else if(r>0&&e.check(S.LESS)){let l=e.advance();t.push({type:"Literal",value:"<"}),n=l.end}else if(r>0&&e.check(S.GREAT)){let l=e.advance();t.push({type:"Literal",value:">"}),n=l.end}else if(r>0&&e.check(S.DGREAT)){let l=e.advance();t.push({type:"Literal",value:">>"}),n=l.end}else if(r>0&&e.check(S.DLESS)){let l=e.advance();t.push({type:"Literal",value:"<<"}),n=l.end}else if(r>0&&e.check(S.LESSAND)){let l=e.advance();t.push({type:"Literal",value:"<&"}),n=l.end}else if(r>0&&e.check(S.GREATAND)){let l=e.advance();t.push({type:"Literal",value:">&"}),n=l.end}else if(r>0&&e.check(S.LESSGREAT)){let l=e.advance();t.push({type:"Literal",value:"<>"}),n=l.end}else if(r>0&&e.check(S.CLOBBER)){let l=e.advance();t.push({type:"Literal",value:">|"}),n=l.end}else if(r>0&&e.check(S.TLESS)){let l=e.advance();t.push({type:"Literal",value:"<<<"}),n=l.end}else if(r>0&&e.check(S.AMP)){let l=e.advance();t.push({type:"Literal",value:"&"}),n=l.end}else if(r>0&&e.check(S.LBRACE)){let l=e.advance();t.push({type:"Literal",value:"{"}),n=l.end}else if(r>0&&e.check(S.RBRACE)){let l=e.advance();t.push({type:"Literal",value:"}"}),n=l.end}else break}return t.length===0&&e.error("Expected regex pattern after =~"),{type:"Word",parts:t}}function ik(e){let t="";for(let r=0;r0?e:[J.literal("")]}function sk(e,t){let r=1,n=t+1;for(;n0;){let i=e[n];if(i==="\\"){n+=2;continue}if("@*+?!".includes(i)&&n+10;)t[h]==="{"?p++:t[h]==="}"&&p--,p>0&&h++;let f=t.slice(r+2,h);return{part:J.parameterExpansion("",{type:"BadSubstitution",text:f}),endIndex:h+1}}}if(o===""&&!s&&!a&&t[i]!=="}"){let c=1,p=i;for(;p0;)t[p]==="{"?c++:t[p]==="}"&&c--,c>0&&p++;if(c>0)throw new vr("unexpected EOF while looking for matching '}'",0,0);let h=t.slice(r+2,p);return{part:J.parameterExpansion("",{type:"BadSubstitution",text:h}),endIndex:p+1}}let u=null;if(s){let c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(c)if(i=t.length)throw new vr("unexpected EOF while looking for matching '}'",0,0);return{part:J.parameterExpansion(o,u),endIndex:i+1}}function jl(e,t,r,n,i=!1){let s=r,a=t[s],o=t[s+1]||"";if(a===":"){let l=o;if("-=?+".includes(l)){s+=2;let g=gi(e,t,s),v=t.slice(s,g),y=e.withDepth(()=>Vn(e,v,!1,!1,!0,!1,i,!1,!1,!0)),x=J.word(cs(y));if(l==="-")return{operation:{type:"DefaultValue",word:x,checkEmpty:!0},endIndex:g};if(l==="=")return{operation:{type:"AssignDefault",word:x,checkEmpty:!0},endIndex:g};if(l==="?")return{operation:{type:"ErrorIfUnset",word:x,checkEmpty:!0},endIndex:g};if(l==="+")return{operation:{type:"UseAlternative",word:x,checkEmpty:!0},endIndex:g}}s++;let u=gi(e,t,s),c=t.slice(s,u),p=-1,h=0,f=0;for(let g=0;g0)f--;else{p=g;break}}let d=p>=0?c.slice(0,p):c,m=p>=0?c.slice(p+1):null;return{operation:{type:"Substring",offset:Dd(e,d),length:m===null?null:Dd(e,m)},endIndex:u}}if("-=?+".includes(a)){s++;let l=gi(e,t,s),u=t.slice(s,l),c=e.withDepth(()=>Vn(e,u,!1,!1,!0,!1,i,!1,!1,!0)),p=J.word(cs(c));if(a==="-")return{operation:{type:"DefaultValue",word:p,checkEmpty:!1},endIndex:l};if(a==="=")return{operation:{type:"AssignDefault",word:p,checkEmpty:!1},endIndex:l};if(a==="?")return{operation:{type:"ErrorIfUnset",word:u?p:null,checkEmpty:!1},endIndex:l};if(a==="+")return{operation:{type:"UseAlternative",word:p,checkEmpty:!1},endIndex:l}}if(a==="#"||a==="%"){let l=o===a,u=a==="#"?"prefix":"suffix";s+=l?2:1;let c=gi(e,t,s),p=t.slice(s,c),h=e.withDepth(()=>Vn(e,p,!1,!1,!1));return{operation:{type:"PatternRemoval",pattern:J.word(cs(h)),side:u,greedy:l},endIndex:c}}if(a==="/"){let l=o==="/";s+=l?2:1;let u=null;t[s]==="#"?(u="start",s++):t[s]==="%"&&(u="end",s++);let c;c=u!==null&&(t[s]==="/"||t[s]==="}")?s:WC(e,t,s);let p=t.slice(s,c),h=e.withDepth(()=>Vn(e,p,!1,!1,!1)),f=J.word(cs(h)),d=null,m=c;if(t[c]==="/"){let g=c+1,v=gi(e,t,g),y=t.slice(g,v),x=e.withDepth(()=>Vn(e,y,!1,!1,!1));d=J.word(cs(x)),m=v}return{operation:{type:"PatternReplacement",pattern:f,replacement:d,all:l,anchor:u},endIndex:m}}if(a==="^"||a===","){let l=o===a,u=a==="^"?"upper":"lower";s+=l?2:1;let c=gi(e,t,s),p=t.slice(s,c);return{operation:{type:"CaseModification",direction:u,all:l,pattern:p?J.word([J.literal(p)]):null},endIndex:c}}return a==="@"&&/[QPaAEKkuUL]/.test(o)?{operation:{type:"Transform",operator:o},endIndex:s+2}:{operation:null,endIndex:s}}function r1(e,t,r,n=!1){let i=r+1;if(i>=t.length)return{part:J.literal("$"),endIndex:i};let s=t[i];if(s==="("&&t[i+1]==="(")return e.isDollarDparenSubshell(t,r)?e.parseCommandSubstitution(t,r):e.parseArithmeticExpansion(t,r);if(s==="["){let a=1,o=i+1;for(;o0;)t[o]==="["?a++:t[o]==="]"&&a--,a>0&&o++;if(a===0){let l=ct(e,t.slice(i+1,o));return{part:J.arithmeticExpansion(l),endIndex:o+1}}}return s==="("?e.parseCommandSubstitution(t,r):s==="{"?ok(e,t,r,n):/[a-zA-Z_0-9@*#?$!-]/.test(s)?ak(e,t,r):{part:J.literal("$"),endIndex:i}}function Vd(e,t){let r=[],n=0,i="",s=()=>{i&&=(r.push(J.literal(i)),"")};for(;n{s&&=(n.push(J.literal(s)),"")};for(;i=2&&t[0]==='"'&&t[t.length-1]==='"'){let m=t.slice(1,-1),g=!1;for(let v=0;v{f&&=(p.push(J.literal(f)),"")};for(;h")&&t[h+1]==="("&&!s&&!a){d();let{part:g,endIndex:v}=e.parseProcessSubstitutionFromString(t,h);p.push(g),h=v;continue}if(m==="~"){let g=h>0?t[h-1]:"";if(h===0&&c||g==="="||i&&g===":"){let v=UC(e,t,h),y=t[v];if(y===void 0||y==="/"||y===":"){d();let x=t.slice(h+1,v)||null;p.push({type:"TildeExpansion",user:x}),h=v;continue}}}if("@*+?!".includes(m)&&h+1Sd)throw new vr(`Input too large: ${t.length} bytes exceeds limit of ${Sd}`,1,1);this._input=t,this.processLineState=void 0;let i=new kC(t,r);if(this.tokens=i.tokenize(),this.tokens.length>Va)throw new vr(`Too many tokens: ${this.tokens.length} exceeds limit of ${Va}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseBudget.chargeTokens(this.tokens.length),this.parseScript()}finally{n?.()}}parseTokens(t){this.ownsParseBudget&&this.parseBudget.reset();let r=this.ownsParseBudget?void 0:this.enterDepth();try{return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.processLineState=void 0,this.parseBudget.chargeTokens(t.length),this.parseScript()}finally{r?.()}}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(t=0){return this.tokens[this.pos+t]||this.tokens[this.tokens.length-1]}advance(){let t=this.current();return this.posr.currentPhysicalLine&&(r.currentPhysicalLine=t.line,r.currentLogicalLine+=1),r.currentLogicalLine):t.line}check(t,r,n,i,...s){let a=this.tokens[this.pos]?.type;return a===t||r!==void 0&&a===r||n!==void 0&&a===n||i!==void 0&&a===i||s.length>0&&s.includes(a)}expect(t,r){if(this.check(t))return this.advance();let n=this.current();throw new vr(r||`Expected ${t}, got ${n.type}`,n.line,n.column,n)}error(t){let r=this.current();throw new vr(t,r.line,r.column,r)}skipNewlines(){for(;this.check(S.NEWLINE,S.COMMENT);)this.check(S.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(S.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(S.SEMICOLON,S.COMMENT)){this.advance();continue}if(t&&this.check(S.DSEMI,S.SEMI_AND,S.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,r,n,i){this.pendingHeredocs.push({redirect:t,delimiter:r,stripTabs:n,quoted:i})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(S.HEREDOC_CONTENT)){let r=this.advance(),n;n=t.quoted?J.word([J.literal(r.value)]):this.parseWordFromString(r.value,!1,!1,!1,!0),t.redirect.target=J.hereDoc(t.delimiter,n,t.stripTabs,t.quoted,r.heredocTerminated??!1)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(S.EOF,S.NEWLINE,S.SEMICOLON,S.AMP,S.AND_AND,S.OR_OR,S.RPAREN,S.RBRACE,S.DSEMI,S.SEMI_AND,S.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return this.isWord()||t===S.ASSIGNMENT_WORD||t===S.FD_VARIABLE||t===S.LPAREN||t===S.LBRACE||t===S.DPAREN_START||t===S.DBRACK_START||Za(this)}parseScript(){let t=[],r=0;for(this.skipNewlines();!this.check(S.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)");let n=this.checkUnexpectedToken();if(n){t.push(n),this.skipSeparators(!1);continue}let i=this.pos,s=this.parseStatement();s&&t.push(s),this.check(S.HEREDOC_CONTENT)&&this.processHeredocs(),this.skipSeparators(!1),this.check(S.DSEMI,S.SEMI_AND,S.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(S.EOF)&&this.error(`syntax error near unexpected token \`${this.current().value}'`)}return J.script(t)}checkUnexpectedToken(){let t=this.current().type,r=this.current().value;if(this.currentTokenJoinsProcessSubstitution())return null;if((t===S.DO||t===S.DONE||t===S.THEN||t===S.ELSE||t===S.ELIF||t===S.FI||t===S.ESAC)&&this.error(`syntax error near unexpected token \`${r}'`),t===S.RBRACE||t===S.RPAREN){let n=`syntax error near unexpected token \`${r}'`;return this.advance(),J.statement([J.pipeline([J.simpleCommand(null,[],[],[])])],[],!1,{message:n,token:r})}return(t===S.DSEMI||t===S.SEMI_AND||t===S.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${r}'`),t===S.SEMICOLON&&this.error(`syntax error near unexpected token \`${r}'`),(t===S.AMP||t===S.AND_AND||t===S.OR_OR||t===S.PIPE||t===S.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${r}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,r=[],n=[],i=!1,s=this.parsePipeline();for(r.push(s);this.check(S.AND_AND,S.OR_OR);){let l=this.advance();n.push(l.type===S.AND_AND?"&&":"||"),this.skipNewlines();let u=this.parsePipeline();r.push(u)}this.check(S.AMP)&&(this.advance(),i=!0);let a=this.pos>0?this.tokens[this.pos-1].end:t,o=this._input.slice(t,a);return J.statement(r,n,i,void 0,o)}parseTimePrefix(){if(!this.check(S.TIME)||this.currentTokenJoinsProcessSubstitution())return;this.advance();let t=!1;return this.check(S.WORD,S.NAME)&&this.current().value==="-p"&&(this.advance(),t=!0),t}parsePipeline(){let t=!1,r=!1,n=0;for(;this.check(S.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++;if(n===0){let l=this.parseTimePrefix();if(l!==void 0)for(t=!0,r=l;this.check(S.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++}let i=n%2==1,s=[],a=[],o=this.parseCommand();for(s.push(o);this.check(S.PIPE,S.PIPE_AMP);){let l=this.advance();this.skipNewlines(),a.push(l.type===S.PIPE_AMP);let u=this.parseCommand();s.push(u)}return J.pipeline(s,i,t,r,a.length>0?a:void 0)}parseCommand(){if(this.currentTokenJoinsProcessSubstitution())return Md(this);let t=this.current();switch(t.type){case S.IF:return Fd(this);case S.FOR:return _d(this);case S.WHILE:return zd(this);case S.UNTIL:return Bd(this);case S.CASE:return Ud(this);case S.LPAREN:return Wd(this);case S.LBRACE:return jd(this);case S.DPAREN_START:return this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand();case S.DBRACK_START:return this.parseConditionalCommand();case S.FUNCTION:return this.parseFunctionDef();case S.TIME:break;case S.BANG:this.error(`syntax error near unexpected token \`${t.value}'`);break;default:vd(t.type)&&this.error(`syntax error near unexpected token \`${t.value}'`)}return this.check(S.NAME,S.WORD)&&this.peek(1).type===S.LPAREN&&this.peek(2).type===S.RPAREN?this.parseFunctionDef():Md(this)}dparenClosesWithSpacedParens(){let t=1,r=1;for(;rnew Sa(this.parseBudget),n=>this.error(n))}parseProcessSubstitutionFromString(t,r){return xC(t,r,()=>new Sa(this.parseBudget),n=>this.error(n))}parseProcessSubstitution(){let t=this.advance();this.expect(S.LPAREN);let r=this.processLineState,n=this.getSourceLine(t);this.processLineState={currentLogicalLine:n};let i;try{i=J.script(this.parseCompoundList())}finally{this.processLineState=r}return this.check(S.EOF)&&this.error("unexpected EOF while looking for matching `)'"),this.expect(S.RPAREN),J.processSubstitution(i,t.type===S.LESS?"input":"output")}parseBacktickSubstitution(t,r,n=!1){return vC(t,r,n,()=>new Sa(this.parseBudget),i=>this.error(i))}isDollarDparenSubshell(t,r){return mC(t,r)}parseArithmeticExpansion(t,r){let n=r+3,i=1,s=0,a=n;for(;a0;)t[a]==="$"&&t[a+1]==="("?t[a+2]==="("?(i++,a+=3):(s++,a+=2):t[a]==="("&&t[a+1]==="("?(i++,a+=2):t[a]===")"&&t[a+1]===")"?s>0?(s--,a++):(i--,i>0&&(a+=2)):t[a]==="("?(s++,a++):(t[a]===")"&&s>0&&s--,a++);let o=t.slice(n,a),l=this.parseArithmeticExpression(o);return{part:J.arithmeticExpansion(l),endIndex:a+2}}parseArithmeticCommand(){let t=this.expect(S.DPAREN_START),r="",n=1,i=0,s=!1,a=!1;for(;n>0&&!this.check(S.EOF);){if(s){if(s=!1,i>0){i--,r+=")";continue}if(this.check(S.RPAREN)){n--,a=!0,this.advance();continue}if(this.check(S.DPAREN_END)){n--,a=!0;continue}r+=")";continue}if(this.check(S.DPAREN_START))n++,r+="((",this.advance();else if(this.check(S.DPAREN_END))i>=2?(i-=2,r+="))",this.advance()):i===1?(i--,r+=")",s=!0,this.advance()):(n--,a=!0,n>0&&(r+="))"),this.advance());else if(this.check(S.LPAREN))i++,r+="(",this.advance();else if(this.check(S.RPAREN))i>0&&i--,r+=")",this.advance();else{let u=this.current().value,c=r.length>0?r[r.length-1]:"";r.length>0&&!r.endsWith(" ")&&!(u==="="&&/[|&^+\-*/%<>]$/.test(r))&&(u!=="<"||c!=="<")&&(u!==">"||c!==">")&&(r+=" "),r+=u,this.advance()}}a||this.expect(S.DPAREN_END);let o=this.parseArithmeticExpression(r.trim()),l=this.parseOptionalRedirections();return J.arithmeticCommand(o,l,this.getSourceLine(t))}parseConditionalCommand(){let t=this.expect(S.DBRACK_START),r=u3(this);this.expect(S.DBRACK_END);let n=this.parseOptionalRedirections();return J.conditionalCommand(r,n,this.getSourceLine(t))}parseFunctionDef(){let t;if(this.check(S.FUNCTION)){if(this.advance(),this.check(S.NAME)||this.check(S.WORD))t=this.advance().value;else{let i=this.current();throw new vr("Expected function name",i.line,i.column,i)}this.check(S.LPAREN)&&(this.advance(),this.expect(S.RPAREN))}else t=this.advance().value,t.includes("$")&&this.error(`\`${t}': not a valid identifier`),this.expect(S.LPAREN),this.expect(S.RPAREN);this.skipNewlines();let r=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return J.functionDef(t,r,n)}parseCompoundCommandBody(t){let r=t?.forFunctionBody;if(this.check(S.LBRACE))return jd(this,{skipRedirections:r});if(this.check(S.LPAREN))return Wd(this,{skipRedirections:r});if(this.check(S.IF))return Fd(this,{skipRedirections:r});if(this.check(S.FOR))return _d(this,{skipRedirections:r});if(this.check(S.WHILE))return zd(this,{skipRedirections:r});if(this.check(S.UNTIL))return Bd(this,{skipRedirections:r});if(this.check(S.CASE))return Ud(this,{skipRedirections:r});this.error("Expected compound command for function body")}parseCompoundList(){let t=this.enterDepth();try{let r=[];for(this.skipNewlines();(this.currentTokenJoinsProcessSubstitution()||!this.check(S.EOF,S.FI,S.ELSE,S.ELIF,S.THEN,S.DO,S.DONE,S.ESAC,S.RPAREN,S.RBRACE,S.DSEMI,S.SEMI_AND,S.SEMI_SEMI_AND))&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,i=this.parseStatement();if(i&&r.push(i),this.skipSeparators(),this.pos===n&&!i)break}return r}finally{t()}}parseOptionalRedirections(){let t=[];for(;Za(this);){this.checkIterationLimit();let r=this.pos;if(t.push(Xu(this)),this.pos===r)break}return t}parseArithmeticExpression(t){return ct(this,t)}};function Li(e,t){return new Be().parse(e,t)}function uk(e){return Xn(e)}function Xn(e){return e.statements.map(c3).join(` `)}function c3(e){let t=[];for(let n=0;n0?`${t.join(" ")} `:"")+r.join(" ")}function p3(e){switch(e.type){case"SimpleCommand":return pk(e);case"If":return bk(e);case"For":return wk(e);case"CStyleFor":return Ek(e);case"While":return Sk(e);case"Until":return Ak(e);case"Case":return Ck(e);case"Subshell":return Nk(e);case"Group":return $k(e);case"ArithmeticCommand":return Ok(e);case"ConditionalCommand":return Tk(e);case"FunctionDef":return Ik(e);default:throw Error(`Unsupported command type: ${e.type}`)}}function pk(e){let t=[];for(let r of e.assignments)t.push(hk(r));e.name&&t.push(Tt(e.name));for(let r of e.args)t.push(Tt(r));for(let r of e.redirections)t.push(d3(r));return t.join(" ")}function hk(e){let t=e.append?"+=":"=";if(e.array){let r=e.array.map(Tt).join(" ");return`${e.name}${t}(${r})`}return e.value?`${e.name}${t}${Tt(e.value)}`:`${e.name}${t}`}function Tt(e){return e.parts.map(t=>ko(t,!1)).join("")}function bn(e){return e.parts.map(t=>ko(t,!0)).join("")}function ko(e,t){switch(e.type){case"Literal":return t?dk(e.value):fk(e.value);case"SingleQuoted":return`'${e.value}'`;case"DoubleQuoted":return`"${e.parts.map(r=>ko(r,!0)).join("")}"`;case"Escaped":return`\\${e.value}`;case"ParameterExpansion":return h3(e);case"CommandSubstitution":return e.legacy?`\`${Xn(e.body)}\``:`$(${Xn(e.body)})`;case"ArithmeticExpansion":return`$((${He(e.expression.expression)}))`;case"ProcessSubstitution":return e.direction==="input"?`<(${Xn(e.body)})`:`>(${Xn(e.body)})`;case"BraceExpansion":return xk(e);case"TildeExpansion":return e.user===null?"~":`~${e.user}`;case"Glob":return e.pattern;default:throw Error(`Unsupported word part type: ${e.type}`)}}function fk(e){return e.replace(/[\s\\'"`!|&;()<>{}[\]*?~#]/g,"\\$&")}function dk(e){return e.replace(/[$`"\\]/g,"\\$&")}function mk(e,t){return e.parts.map(r=>gk(r,t)).join("")}function gk(e,t){switch(e.type){case"Literal":return t?e.value:e.value.replace(/[$`]/g,"\\$&");case"Escaped":return`\\${e.value}`;case"ParameterExpansion":return h3(e);case"CommandSubstitution":return e.legacy?`\`${Xn(e.body)}\``:`$(${Xn(e.body)})`;case"ArithmeticExpansion":return`$((${He(e.expression.expression)}))`;default:return ko(e,!1)}}function h3(e){return e.operation?`\${${f3(e.parameter,e.operation)}}`:yk(e.parameter)?`\${${e.parameter}}`:`$${e.parameter}`}function yk(e){return!(/^[?#@*$!\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function f3(e,t){switch(t.type){case"Length":return`#${e}`;case"LengthSliceError":return`#${e}:`;case"BadSubstitution":return t.text;case"DefaultValue":return`${e}${t.checkEmpty?":":""}-${bn(t.word)}`;case"AssignDefault":return`${e}${t.checkEmpty?":":""}=${bn(t.word)}`;case"ErrorIfUnset":return`${e}${t.checkEmpty?":":""}?${t.word?bn(t.word):""}`;case"UseAlternative":return`${e}${t.checkEmpty?":":""}+${bn(t.word)}`;case"Substring":{let r=He(t.offset.expression);return t.length?`${e}:${r}:${He(t.length.expression)}`:`${e}:${r}`}case"PatternRemoval":{let r=t.side==="prefix"?"#":"%";return`${e}${t.greedy?`${r}${r}`:r}${bn(t.pattern)}`}case"PatternReplacement":{let r="/";t.all?r="//":t.anchor==="start"?r="/#":t.anchor==="end"&&(r="/%");let n=t.replacement?`/${bn(t.replacement)}`:"";return`${e}${r}${bn(t.pattern)}${n}`}case"CaseModification":{let r=t.direction==="upper"?"^":",";return`${e}${t.all?`${r}${r}`:r}${t.pattern?bn(t.pattern):""}`}case"Transform":return`${e}@${t.operator}`;case"Indirection":return t.innerOp?`!${f3(e,t.innerOp)}`:`!${e}`;case"ArrayKeys":return`!${t.array}[${t.star?"*":"@"}]`;case"VarNamePrefix":return`!${t.prefix}${t.star?"*":"@"}`;default:throw Error(`Unsupported parameter operation type: ${t.type}`)}}function xk(e){return`{${e.items.map(vk).join(",")}}`}function vk(e){if(e.type==="Word")return Tt(e.word);let t=e.startStr??String(e.start),r=e.endStr??String(e.end);return e.step===void 0?`${t}..${r}`:`${t}..${r}..${e.step}`}function d3(e){let t=e.fdVariable?`{${e.fdVariable}}`:e.fd===null?"":String(e.fd);if(e.operator==="<<"||e.operator==="<<-"){let r=e.target;if(r.terminated===!1)throw Error("Cannot serialize an unterminated here-document");let n=r.quoted?`'${r.delimiter}'`:r.delimiter,i=mk(r.content,r.quoted);return`${t}${e.operator}${n} ${i}${r.delimiter}`}return e.operator==="<<<"?`${t}<<< ${Tt(e.target)}`:e.operator==="&>"||e.operator==="&>>"?`${e.operator} ${Tt(e.target)}`:`${t}${e.operator} ${Tt(e.target)}`}function Br(e){return e.length===0?"":` ${e.map(d3).join(" ")}`}function wr(e){return e.map(c3).join(` `)}function bk(e){let t=[];for(let r=0;rr-n.value)throw new C(`alias expansion exceeds string length limit (${r} bytes)`,"string_length");return n.value+=i,e+t}function Zd(e){return e.parts.length===1&&e.parts[0].type==="Literal"}function Qd(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Kd(e,t){return e.env.get(`${Rk}${t}`)}function Pk(e,t,r){return m3(e,t,r)}function m3(e,t,r,n=!0){if(!t.name||!Zd(t.name))return t;let i=Qd(t.name);if(!i)return t;let s=Kd(e,i);if(!s||r.has(i))return t;try{r.add(i);let a=new Be,o={value:0},l=Qa("",s,e.limits.maxStringLength,o),u=s.endsWith(" ");if(!u)for(let f of t.args){let d=Tt(f);l=Qa(l,` ${d}`,e.limits.maxStringLength,o)}let c;try{c=a.parse(l)}catch(f){if(f instanceof vr)throw f;return t}if(c.statements.length!==1||c.statements[0].pipelines.length!==1||c.statements[0].pipelines[0].commands.length!==1)return Xd(e,t,s);let p=c.statements[0].pipelines[0].commands[0];if(p.type!=="SimpleCommand")return Xd(e,t,s);let h={...p,assignments:[...t.assignments,...p.assignments],redirections:[...p.redirections,...t.redirections],line:t.line};if(u&&t.args.length>0){h={...h,args:[...h.args,...t.args]};let f=1;for(;n&&h.args.length>0;){let d=h.args[0];if(!Zd(d))break;let m=Qd(d),g=m?Kd(e,m):null;if(!g)break;if(f>=e.limits.maxCallDepth)throw new C(`alias expansion depth limit exceeded (${e.limits.maxCallDepth})`,"recursion");f++;let v={type:"SimpleCommand",name:d,args:h.args.slice(1),assignments:[],redirections:[]},y=m3(e,v,r,!1);if(y===v||(h={...h,name:y.name,args:[...y.args]},!g.endsWith(" ")))break}}return h}catch(a){throw r.delete(i),a}}function Xd(e,t,r){let n={value:0},i=Qa("",r,e.limits.maxStringLength,n);for(let l of t.args){let u=Tt(l);i=Qa(i,` ${u}`,e.limits.maxStringLength,n)}let s=new Be,a=s.parseWordFromString("eval",!1,!1),o=0;for(let l of i)l==="'"&&o++;if(n.value+2+o*3>e.limits.maxStringLength)throw new C(`alias expansion exceeds string length limit (${e.limits.maxStringLength} bytes)`,"string_length");return{type:"SimpleCommand",name:a,args:[s.parseWordFromString(`'${i.replace(/'/g,"'\\''")}'`,!1,!1)],assignments:t.assignments,redirections:t.redirections,line:t.line}}H(),H(),at(),po(),at();var Dk=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9a-fA-F"]]);function g3(e){return Dk.get(e)??""}function Lk(e){let t=[],r="",n=0;for(;n0;){let i=e[n];if(i==="\\"){n+=2;continue}if(i==="(")r++;else if(i===")"&&(r--,r===0))return n;n++}return-1}function Jd(e){let t=[],r="",n=0,i=!1,s=0;for(;sthis.maxOps)throw new C(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations");this.consumeOperation?.()}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(t=>{let r=t.split("/").pop()||t;if((this.hasGlobignore||this.globskipdots)&&(r==="."||r===".."))return!1;if(this.hasGlobignore){for(let n of this.globignorePatterns)if(this.matchGlobignorePattern(t,n))return!1}return!0})}matchGlobignorePattern(e,t){return Mk(t).test(e)}isGlobPattern(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,t){let r=e.map((s,a)=>(t?.[a]??!1)||!this.isGlobPattern(s)?null:this.expand(s)),n=await Promise.all(r.map(s=>s||Promise.resolve(null))),i=[];for(let s=0;s0?i.push(...a):i.push(e[s])}return i}async expand(e){if(this.globstar){let r=e.split("/"),n=0;for(let i of r)if(i==="**"&&(n++,n>e0))throw new C(`Glob pattern has too many ** segments (max ${e0})`,"glob_operations")}let t;if(e.includes("**")&&this.globstar&&this.isGlobstarValid(e))t=await this.expandRecursive(e);else{let r=e.replace(/\*\*+/g,"*");t=await this.expandSimple(r)}return this.filterGlobignore(t)}isGlobstarValid(e){let t=e.split("/");for(let r of t)if(r.includes("**")&&r!=="**")return!1;return!0}hasGlobChars(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let t=e.startsWith("/"),r=e.split("/").filter(o=>o!==""),n=-1;for(let o=0;of.name==="."),h=a.some(f=>f.name==="..");p||l.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),h||l.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let p of l)if((!p.name.startsWith(".")||n.startsWith(".")||u)&&this.matchPattern(p.name,n)){let h=e==="/"?`/${p.name}`:`${e}/${p.name}`,f;f=t===""?p.name:t==="/"?`/${p.name}`:`${t}/${p.name}`,i.length===0?o.push(Promise.resolve([f])):p.isDirectory&&o.push(this.expandSegments(h,f,i))}let c=await Promise.all(o);for(let p of c)s.push(...p)}else{this.checkOpsLimit();let a=await this.fs.readdir(e),o=[],l=[...a],u=this.dotglob||this.hasGlobignore;(n.startsWith(".")||this.dotglob)&&(a.includes(".")||l.push("."),a.includes("..")||l.push(".."));for(let p of l)if((!p.startsWith(".")||n.startsWith(".")||u)&&this.matchPattern(p,n)){let h=e==="/"?`/${p}`:`${e}/${p}`,f;f=t===""?p:t==="/"?`/${p}`:`${t}/${p}`,i.length===0?o.push(Promise.resolve([f])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory)return this.expandSegments(h,f,i)}catch(d){if(d instanceof C)throw d}return[]})())}let c=await Promise.all(o);for(let p of c)s.push(...p)}}catch(a){if(a instanceof C)throw a}return s}async expandRecursive(e){let t=[],r=e.indexOf("**"),n=e.slice(0,r).replace(/\/$/,"")||".",i=e.slice(r+2).replace(/^\//,"");return i.includes("**")&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(n,i,t),[...new Set(t)].sort()):(await this.walkDirectory(n,i,t),t.sort())}async walkDirectoryMultiGlobstar(e,t,r){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(n):null;if(i){let s=[];for(let l of i){let u=e==="."?l.name:`${e}/${l.name}`;l.isDirectory&&s.push(u)}let a=e==="."?t:`${e}/${t}`,o=await this.expandRecursive(a);r.push(...o);for(let l=0;lthis.walkDirectoryMultiGlobstar(c,t,r)))}}else{this.checkOpsLimit();let s=await this.fs.readdir(n),a=[];for(let u of s){let c=e==="."?u:`${e}/${u}`,p=this.fs.resolvePath(this.cwd,c);try{this.checkOpsLimit(),(await this.fs.stat(p)).isDirectory&&a.push(c)}catch(h){if(h instanceof C)throw h}}let o=e==="."?t:`${e}/${t}`,l=await this.expandRecursive(o);r.push(...l);for(let u=0;uthis.walkDirectoryMultiGlobstar(p,t,r)))}}}catch(i){if(i instanceof C)throw i}}async walkDirectory(e,t,r){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(n),s=[],a=[];for(let o of i){let l=e==="."?o.name:`${e}/${o.name}`;o.isDirectory?a.push(l):t&&this.matchPattern(o.name,t)&&s.push(l)}r.push(...s);for(let o=0;othis.walkDirectory(u,t,r)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(n),s=[];for(let o=0;o{let p=e==="."?c:`${e}/${c}`,h=this.fs.resolvePath(this.cwd,p);try{return this.checkOpsLimit(),{name:c,path:p,isDirectory:(await this.fs.stat(h)).isDirectory}}catch(f){if(f instanceof C)throw f;return null}}));s.push(...u.filter(c=>c!==null))}for(let o of s)!o.isDirectory&&t&&this.matchPattern(o.name,t)&&r.push(o.path);let a=s.filter(o=>o.isDirectory);for(let o=0;othis.walkDirectory(u.path,t,r)))}}}catch(i){if(i instanceof C)throw i}}matchPattern(e,t){return this.patternToRegex(t).test(e)}patternToRegex(e){return de(`^${this.patternToRegexStr(e)}$`)}patternToRegexStr(e){let t="",r=!1;for(let n=0;nthis.patternToRegexStr(u)),l=o.length>0?o.join("|"):"(?:)";if(i==="@")t+=`(?:${l})`;else if(i==="*")t+=`(?:${l})*`;else if(i==="+")t+=`(?:${l})+`;else if(i==="?")t+=`(?:${l})?`;else if(i==="!")if(sthis.computePatternLength(c));if(u.every(c=>c!==null)&&u.every(c=>c===u[0])&&u[0]!==null){let c=u[0];if(c===0)t+="(?:.+)";else{let p=[];c>0&&p.push(`.{0,${c-1}}`),p.push(`.{${c+1},}`),p.push(`(?!(?:${l})).{${c}}`),t+=`(?:${p.join("|")})`}}else t+=`(?:(?!(?:${l})).)*?`}else t+=`(?!(?:${l})$).*`;n=s;continue}}if(i==="*")t+=".*";else if(i==="?")t+=".";else if(i==="["){let s=n+1,a="[";sthis.computePatternLength(o));if(a.every(o=>o!==null)&&a.every(o=>o===a[0])){t+=a[0],r=s+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){t+=1,r++;continue}if(i==="["){let s=e.indexOf("]",r+1);if(s!==-1){t+=1,r=s+1;continue}t+=1,r++;continue}if(i==="\\"){t+=1,r+=2;continue}t+=1,r++}return t}};H();function y3(e){for(let t=0;t=t)throw new C(`array element limit exceeded (${t})`,"array_elements")}function ql(e,t,r,n,i){Yn(e.length,i),Yn(t.length,i),e.push(r),t.push(n)}function Wt(e){return e.get("IFS")??zk}function Jt(e){return e.get("IFS")===""}function i1(e){let t=Wt(e);if(t==="")return!0;for(let r of t)if(r!==" "&&r!==" "&&r!==` `)return!1;return!0}function Bk(e){let t=!1,r=[];for(let n of e.split(""))n==="-"?t=!0:/[\\^$.*+?()[\]{}|]/.test(n)?r.push(`\\${n}`):n===" "?r.push("\\t"):n===` `?r.push("\\n"):r.push(n);return t&&r.push("\\-"),r.join("")}function Oe(e){let t=e.get("IFS");return t===void 0?" ":t[0]||""}var Uk=` `;function Wk(e){return Uk.includes(e)}function s1(e){let t=new Set,r=new Set;for(let n of e)Wk(n)?t.add(n):r.add(n);return{whitespace:t,nonWhitespace:r}}function t0(e,t,r,n,i){if(t==="")return e===""?{words:[],wordStarts:[]}:(Yn(0,r),{words:[e],wordStarts:[0]});let{whitespace:s,nonWhitespace:a}=s1(t),o=[],l=[],u=0;for(;u=e.length)return{words:[],wordStarts:[]};if(a.has(e[u]))for(ql(o,l,"",u,r),u++;u=n);){let c=u;for(;u=e.length)break;for(;u=n);)for(ql(o,l,"",u,r),u++;uu&&(o=!0),a>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(i.has(e[a]))for(Yn(s.length,r),s.push(""),a++;a=e.length){l=!1;break}let p=a;for(;a=e.length&&a>p&&(l=!0)}return{words:s,hadLeadingDelimiter:o,hadTrailingDelimiter:l}}function nt(e,t,r){return a1(e,t,r).words}function jk(e,t){for(let r of e)if(t.has(r))return!0;return!1}function qk(e,t,r){if(t==="")return e;let{whitespace:n,nonWhitespace:i}=s1(t),s=e.length;for(;s>0&&n.has(e[s-1]);){if(!r&&s>=2){let o=0,l=s-2;for(;l>=0&&e[l]==="\\";)o++,l--;if(o%2==1)break}s--}let a=e.substring(0,s);if(a.length>=1&&i.has(a[a.length-1])){if(!r&&a.length>=2){let l=0,u=a.length-2;for(;u>=0&&a[u]==="\\";)l++,u--;if(l%2==1)return a}let o=a.substring(0,a.length-1);if(!jk(o,i))return o}return a}function dt(e,t){return e.state.namerefs?.has(t)??!1}function Zn(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function Gk(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Hk(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function x3(e,t){return e.state.invalidNamerefs?.has(t)??!1}function r0(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function tc(e,t){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let n=r[1],i=Yr(e,n),s=e.state.associativeArrays?.has(n)??!1;return i||s}return Yr(e,t)?!0:e.state.env.has(t)}function Jr(e,t,r=100){if(!dt(e,t)||x3(e,t))return t;let n=new Set,i=t;for(;r-- >0;){if(n.has(i))return;if(n.add(i),!dt(e,i))return i;let s=e.state.env.get(i);if(s===void 0||s===""||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(s))return i;i=s}}function No(e,t){if(dt(e,t))return e.state.env.get(t)}function v3(e,t,r,n=100){if(!dt(e,t)||x3(e,t))return t;let i=new Set,s=t;for(;n-- >0;){if(i.has(s))return;if(i.add(s),!dt(e,s))return s;let a=e.state.env.get(s);if(a===void 0||a==="")return r===void 0||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&tc(e,r)?s:null;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(a))return s;s=a}}function b3(e,t){let r=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(n,i)=>e.state.env.get(i)??"");return r=r.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(n,i)=>e.state.env.get(i)??""),r}function Te(e,t){return t==="FUNCNAME"?(e.state.funcNameStack??[]).map((r,n)=>[n,r]):t==="BASH_LINENO"?(e.state.callLineStack??[]).map((r,n)=>[n,String(r)]):t==="BASH_SOURCE"?(e.state.sourceStack??[]).map((r,n)=>[n,r]):e.state.associativeArrays?.has(t)?Gi(e,t).map(r=>[r,tt(e,t,r)??""]):Qt(e,t).map(r=>[r,tt(e,t,r)??""])}function oi(e,t){return t==="FUNCNAME"?(e.state.funcNameStack?.length??0)>0:t==="BASH_LINENO"?(e.state.callLineStack?.length??0)>0:t==="BASH_SOURCE"?(e.state.sourceStack?.length??0)>0:(e.state.associativeArrays?.has(t),Yr(e,t))}async function Ve(e,t,r=!0,n=!1){switch(t){case"?":return String(e.state.lastExitCode);case"$":return String(e.state.virtualPid);case"#":return e.state.env.get("#")||"0";case"@":return e.state.env.get("@")||"";case"_":return e.state.lastArg;case"-":{let a="";return a+="h",e.state.options.errexit&&(a+="e"),e.state.options.noglob&&(a+="f"),e.state.options.nounset&&(a+="u"),e.state.options.verbose&&(a+="v"),e.state.options.xtrace&&(a+="x"),a+="B",e.state.options.noclobber&&(a+="C"),a+="s",a}case"*":{let a=Number.parseInt(e.state.env.get("#")||"0",10);if(a===0)return"";let o=[];for(let l=1;l<=a;l++)o.push(e.state.env.get(String(l))||"");return o.join(Oe(e.state.env))}case"0":return e.state.env.get("0")||"bash";case"PWD":return e.state.env.get("PWD")??"";case"OLDPWD":return e.state.env.get("OLDPWD")??"";case"PPID":return String(e.state.virtualPpid);case"UID":return String(e.state.virtualUid);case"EUID":return String(e.state.virtualUid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-e.state.startTime)/1e3));case"BASH_VERSION":return iC;case"!":return String(e.state.lastBackgroundPid);case"BASHPID":return String(e.state.bashPid);case"LINENO":return String(e.state.currentLine);case"FUNCNAME":{let a=e.state.funcNameStack?.[0];if(a!==void 0)return a;if(r&&e.state.options.nounset)throw new hr("FUNCNAME");return""}case"BASH_LINENO":{let a=e.state.callLineStack?.[0];if(a!==void 0)return String(a);if(r&&e.state.options.nounset)throw new hr("BASH_LINENO");return""}case"BASH_SOURCE":{let a=e.state.sourceStack?.[0];if(a!==void 0)return a;if(r&&e.state.options.nounset)throw new hr("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new hn(`\${${t}}`);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let a=i[1],o=i[2];if(dt(e,a)){let c=Jr(e,a);if(c&&c!==a){if(c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return"";a=c}}if(o==="@"||o==="*"){let c=Te(e,a);if(c.length>0)return c.map(([,h])=>h).join(" ");let p=e.state.env.get(a);return p===void 0?"":p}if(a==="FUNCNAME"){let c=Number.parseInt(o,10);return!Number.isNaN(c)&&c>=0?e.state.funcNameStack?.[c]??"":""}if(a==="BASH_LINENO"){let c=Number.parseInt(o,10);if(!Number.isNaN(c)&&c>=0){let p=e.state.callLineStack?.[c];return p===void 0?"":String(p)}return""}if(a==="BASH_SOURCE"){let c=Number.parseInt(o,10);return!Number.isNaN(c)&&c>=0?e.state.sourceStack?.[c]??"":""}if(e.state.associativeArrays?.has(a)){let c=t1(o);c=b3(e,c);let p=tt(e,a,c);if(p===void 0&&r&&e.state.options.nounset)throw new hr(`${a}[${o}]`);return p||""}let l;if(/^-?\d+$/.test(o))l=Number.parseInt(o,10);else try{l=await qe(e,ct(new Be,o).expression)}catch{let c=e.state.env.get(o);l=c?Number.parseInt(c,10):0,Number.isNaN(l)&&(l=0)}if(l<0){let c=Te(e,a),p=e.state.currentLine;if(c.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${p}: ${a}: bad array subscript `,"";let h=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l;return h<0?(e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${p}: ${a}: bad array subscript `,""):tt(e,a,h)||""}let u=tt(e,a,l);if(u!==void 0)return u;if(l===0){let c=e.state.env.get(a);if(c!==void 0)return c}if(r&&e.state.options.nounset)throw new hr(`${a}[${l}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let a=e.state.env.get(t);if(a===void 0&&r&&e.state.options.nounset)throw new hr(t);return a||""}if(dt(e,t)){let a=Jr(e,t);if(a===void 0)return"";if(a!==t)return await Ve(e,a,r,n);let o=e.state.env.get(t);if((o===void 0||o==="")&&r&&e.state.options.nounset)throw new hr(t);return o||""}let s=e.state.env.get(t);if(s!==void 0)return e.state.tempEnvBindings?.some(a=>a.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),s;if(oi(e,t)){let a=tt(e,t,0);if(a!==void 0)return a;if(r&&e.state.options.nounset)throw new hr(t);return""}if(r&&e.state.options.nounset)throw new hr(t);return""}async function Hi(e,t){if(new Set(["?","$","#","_","-","0","PPID","UID","EUID","RANDOM","SECONDS","BASH_VERSION","!","BASHPID","LINENO"]).has(t))return!0;if(t==="@"||t==="*")return Number.parseInt(e.state.env.get("#")||"0",10)>0;if(t==="PWD"||t==="OLDPWD")return e.state.env.has(t);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let n=r[1],i=r[2];if(dt(e,n)){let a=Jr(e,n);if(a&&a!==n){if(a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;n=a}}if(i==="@"||i==="*")return Te(e,n).length>0||e.state.env.has(n);if(e.state.associativeArrays?.has(n)){let a=b3(e,t1(i));return $i(e,n,a)}let s;if(/^-?\d+$/.test(i))s=Number.parseInt(i,10);else try{s=await qe(e,ct(new Be,i).expression)}catch{let a=e.state.env.get(i);s=a?Number.parseInt(a,10):0,Number.isNaN(s)&&(s=0)}if(s<0){let a=Te(e,n);if(a.length===0)return!1;let o=Math.max(...a.map(([l])=>typeof l=="number"?l:0))+1+s;return o<0?!1:$i(e,n,o)}return $i(e,n,s)}if(dt(e,t)){let n=Jr(e,t);return n===void 0||n===t?e.state.env.has(t):Hi(e,n)}return e.state.env.has(t)?!0:oi(e,t)?$i(e,t,0):!1}async function Vk(e,t){let r="",n=0;for(;n0;)t[s]==="{"?i++:t[s]==="}"&&i--,s++;r+=t.slice(n,s),n=s;continue}if(t[n+1]==="("){let i=1,s=n+2;for(;s0;)t[s]==="("?i++:t[s]===")"&&i--,s++;r+=t.slice(n,s),n=s;continue}if(/[a-zA-Z_]/.test(t[n+1]||"")){let i=n+1;for(;i0;)r[l]==="("&&r[l-1]==="$"||r[l]==="("?o++:r[l]===")"&&o--,l++;let u=r.slice(a+2,l-1);if(e.execFn){let c=await e.execFn(u,{signal:e.state.signal});s+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}a=l}else if(r[a+1]==="{"){let o=1,l=a+2;for(;l0;)r[l]==="{"?o++:r[l]==="}"&&o--,l++;let u=await Ve(e,r.slice(a+2,l-1));s+=u,a=l}else if(/[a-zA-Z_]/.test(r[a+1]||"")){let o=a+1;for(;o=r.maxResults)return!1;let i=q(t);if(i>r.maxStringBytes-n.value)throw new C(`brace expansion string limit exceeded (${r.maxStringBytes} bytes)`,"string_length");return e.push(t),n.value+=i,!0}function Zk(e,t,r,n,i,s=o1){let a=r??1;a===0&&(a=1);let o=Math.abs(a),l=[],u=0;if(n?.match(/^-?0\d/)&&(u=Math.max(u,n.replace(/^-/,"").length)),i?.match(/^-?0\d/)&&(u=Math.max(u,i.replace(/^-/,"").length)),u>s.maxStringBytes)throw new C(`brace expansion padding limit exceeded (${s.maxStringBytes} bytes)`,"string_length");let c={value:0},p=h=>{if(u>0){let f=h<0,d=String(Math.abs(h)).padStart(u,"0");return f?`-${d}`:d}return String(h)};if(e<=t)for(let h=e,f=0;h<=t&&f=t&&f="A"&&e<="Z"&&t>="a"&&t<="z"||e>="a"&&e<="z"&&t>="A"&&t<="Z"){let c=r===void 0?"":`..${r}`;throw new Tc(`{${e}..${t}${c}}: invalid sequence`)}let l=[],u={value:0};if(s<=a)for(let c=s,p=0;c<=a&&p=a&&p$e(u,t,r)),l=o.length>0?o.join("|"):"(?:)";s==="@"?n+=`(?:${l})`:s==="*"?n+=`(?:${l})*`:s==="+"?n+=`(?:${l})+`:s==="?"?n+=`(?:${l})?`:s==="!"&&(n+=`(?!(?:${l})$).*`),i=a+1;continue}}if(s==="\\")if(i+10;){let i=e[n];if(i==="\\"){n+=2;continue}if(i==="(")r++;else if(i===")"&&(r--,r===0))return n;n++}return-1}function Yk(e){let t=[],r="",n=0,i=0;for(;i0&&rnew C(`pattern replacement: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length"));r.lastIndex=0;let a=0,o=r.exec(t);for(;o!==null&&(e.executionScope.consumeLimited("pattern_operations",1,e.limits.maxGlobOperations,"pattern replacement"),!(i&&o[0].length===0&&o.index===t.length||(s.append(t.slice(a,o.index)),s.append(n),a=o.index+o[0].length,!i)));)o[0].length===0&&(a++,r.lastIndex<=o.index&&(r.lastIndex=o.index+1)),o=r.exec(t);return s.append(t.slice(a)),r.lastIndex=0,s.build()}wt(),H();function S3(e){let t=[],r=0;return{append(n){let i=q(n);if(i>e-r)throw new C(`prompt expansion exceeds string length limit (${e} bytes)`,"string_length");n&&t.push(n),r+=i},build:()=>t.join("")}}function nN(e,t,r){let n=(a,o=2)=>String(a).padStart(o,"0");if(e==="")return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;let i=S3(r),s=0;for(;s=e.length){i.append("%"),s++;continue}let a=e[s+1];switch(a){case"H":i.append(n(t.getHours()));break;case"M":i.append(n(t.getMinutes()));break;case"S":i.append(n(t.getSeconds()));break;case"d":i.append(n(t.getDate()));break;case"m":i.append(n(t.getMonth()+1));break;case"Y":i.append(String(t.getFullYear()));break;case"y":i.append(n(t.getFullYear()%100));break;case"I":{let o=t.getHours()%12;o===0&&(o=12),i.append(n(o));break}case"p":i.append(t.getHours()<12?"AM":"PM");break;case"P":i.append(t.getHours()<12?"am":"pm");break;case"%":i.append("%");break;case"a":i.append(["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()]);break;case"b":i.append(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()]);break;default:i.append(`%${a}`)}s+=2}else i.append(e[s]),s++;return i.build()}function nc(e,t){let r=S3(e.limits.maxStringLength),n=0,i=e.state.env.get("USER")||e.state.env.get("LOGNAME")||"user",s=e.state.env.get("HOSTNAME")||"localhost",a=s.split(".")[0],o=e.state.env.get("PWD")||"/",l=e.state.env.get("HOME")||"/",u=o.startsWith(l)?`~${o.slice(l.length)}`:o,c=o.split("/").pop()||o,p=new Date,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d=e.state.env.get("__COMMAND_NUMBER")||"1";for(;n=t.length){r.append("\\"),n++;continue}let g=t[n+1];if(g>="0"&&g<="7"){let v="",y=n+1;for(;y="0"&&t[y]<="7";)v+=t[y],y++;let x=Number.parseInt(v,8)%256;r.append(String.fromCharCode(x)),n=y;continue}switch(g){case"\\":r.append("\\"),n+=2;break;case"a":r.append("\x07"),n+=2;break;case"e":r.append("\x1B"),n+=2;break;case"n":r.append(` `),n+=2;break;case"r":r.append("\r"),n+=2;break;case"$":r.append("$"),n+=2;break;case"[":case"]":n+=2;break;case"u":r.append(i),n+=2;break;case"h":r.append(a),n+=2;break;case"H":r.append(s),n+=2;break;case"w":r.append(u),n+=2;break;case"W":r.append(c),n+=2;break;case"d":{let v=String(p.getDate()).padStart(2," ");r.append(`${h[p.getDay()]} ${f[p.getMonth()]} ${v}`),n+=2;break}case"t":{let v=String(p.getHours()).padStart(2,"0"),y=String(p.getMinutes()).padStart(2,"0"),x=String(p.getSeconds()).padStart(2,"0");r.append(`${v}:${y}:${x}`),n+=2;break}case"T":{let v=p.getHours()%12;v===0&&(v=12);let y=String(v).padStart(2,"0"),x=String(p.getMinutes()).padStart(2,"0"),b=String(p.getSeconds()).padStart(2,"0");r.append(`${y}:${x}:${b}`),n+=2;break}case"@":{let v=p.getHours()%12;v===0&&(v=12);let y=String(v).padStart(2,"0"),x=String(p.getMinutes()).padStart(2,"0"),b=p.getHours()<12?"AM":"PM";r.append(`${y}:${x} ${b}`),n+=2;break}case"A":{let v=String(p.getHours()).padStart(2,"0"),y=String(p.getMinutes()).padStart(2,"0");r.append(`${v}:${y}`),n+=2;break}case"D":if(n+20&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!r){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length0?String(s.length):e.state.env.get(i)===void 0?"0":"1"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&oi(e,t)){if(t==="FUNCNAME"){let s=e.state.funcNameStack?.[0]||"";return String([...s].length)}if(t==="BASH_LINENO"){let s=e.state.callLineStack?.[0];return String(s===void 0?0:[...String(s)].length)}let i=tt(e,t,0)||"";return String([...i].length)}return String([...r].length)}async function pN(e,t,r,n){e.coverage?.hit("bash:expansion:substring");let i=await qe(e,n.offset.expression),s=n.length?await qe(e,n.length.expression):void 0;if(t==="@"||t==="*"){let u=Number.parseInt(e.state.env.get("#")||"0",10),c=[];for(let d=1;d<=u;d++)c.push(e.state.env.get(String(d))||"");let p=e.state.env.get("0")||"bash",h,f;if(i<=0)if(h=[p,...c],i<0){if(f=h.length+i,f<0)return""}else f=0;else h=c,f=i-1;if(f<0||f>=h.length)return"";if(s!==void 0){let d=s<0?h.length+s:f+s;return h.slice(f,Math.max(f,d)).join(" ")}return h.slice(f).join(" ")}let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(a){let u=a[1];if(e.state.associativeArrays?.has(u))throw new ze(1,"",`bash: \${${u}[@]: 0: 3}: bad substitution `);let c=Te(e,u),p=0;if(i<0){if(c.length>0){let h=c[c.length-1][0],f=(typeof h=="number"?h:0)+1+i;if(f<0||(p=c.findIndex(([d])=>typeof d=="number"&&d>=f),p<0))return""}}else if(p=c.findIndex(([h])=>typeof h=="number"&&h>=i),p<0)return"";if(s!==void 0){if(s<0)throw new lt(`${a[1]}[@]: substring expression < 0`);return c.slice(p,p+s).map(([,h])=>h).join(" ")}return c.slice(p).map(([,h])=>h).join(" ")}let o=[...r],l=i;if(l<0&&(l=Math.max(0,o.length+l)),s!==void 0){if(s<0){let u=o.length+s;return o.slice(l,Math.max(l,u)).join("")}return o.slice(l,l+s).join("")}return o.slice(l).join("")}async function hN(e,t,r,n,i){if(e.coverage?.hit("bash:expansion:case_modification"),r.pattern){let s=e.state.shoptOptions.extglob,a="";for(let p of r.pattern.parts)if(p.type==="Glob")a+=$e(p.pattern,!0,s);else if(p.type==="Literal")a+=$e(p.value,!0,s);else if(p.type==="SingleQuoted"||p.type==="Escaped")a+=Me(p.value);else if(p.type==="DoubleQuoted"){let h=await n(e,p.parts);a+=Me(h)}else if(p.type==="ParameterExpansion"){let h=await i(e,p);a+=$e(h,!0,s)}let o=de(`^(?:${a})$`),l=r.direction==="upper"?p=>p.toUpperCase():p=>p.toLowerCase(),u="",c=!1;for(let p of t)!r.all&&c?u+=p:o.test(p)?(u+=l(p),c=!0):u+=p;return u}return r.direction==="upper"?r.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):r.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function fN(e,t,r,n,i){e.coverage?.hit("bash:expansion:transform");let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(s&&i.operator==="Q")return Te(e,s[1]).map(([,o])=>Oi(o)).join(" ");if(s&&i.operator==="a")return vs(e,s[1]);let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(a&&i.operator==="a")return vs(e,a[1]);switch(i.operator){case"Q":return n?"":Oi(r);case"P":return nc(e,r);case"a":return vs(e,t);case"A":return n?"":`${t}=${Oi(r)}`;case"E":return r.replace(/\\([\\abefnrtv'"?])/g,(o,l)=>{switch(l){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return` `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return l}});case"K":case"k":return n?"":Oi(r);case"u":return r.charAt(0).toUpperCase()+r.slice(1);case"U":return r.toUpperCase();case"L":return r.toLowerCase();default:return r}}async function dN(e,t,r,n,i,s,a=!1){if(e.coverage?.hit("bash:expansion:indirection"),dt(e,t))return No(e,t)||"";let o=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(n){if(i.innerOp?.type==="UseAlternative")return"";throw new hn(`\${!${t}}`)}let l=r;if(o&&(l===""||l.includes(" ")))throw new hn(`\${!${t}}`);let u=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(u&&u[1].includes("~"))throw new hn(`\${!${t}}`);return i.innerOp?s(e,{type:"ParameterExpansion",parameter:l,operation:i.innerOp},a):await Ve(e,l)}function mN(e,t){e.coverage?.hit("bash:expansion:array_keys");let r=Te(e,t.array).map(([n])=>String(n));return t.star?r.join(Oe(e.state.env)):r.join(" ")}function gN(e,t){e.coverage?.hit("bash:expansion:var_name_prefix");let r=l1(e,t.prefix);return t.star?r.join(Oe(e.state.env)):r.join(" ")}function yN(e,t,r,n){let i=Number.parseInt(e.state.env.get("#")||"0",10),s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t==="*")return{isEmpty:i===0,effectiveValue:r};if(t==="@")return{isEmpty:i===0||i===1&&e.state.env.get("1")==="",effectiveValue:r};if(s){let[,a,o]=s,l=Te(e,a);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(o==="*"){let u=Oe(e.state.env),c=l.map(([,p])=>p).join(u);return{isEmpty:n?c==="":!1,effectiveValue:c}}return{isEmpty:l.length===1&&l.every(([,u])=>u===""),effectiveValue:l.map(([,u])=>u).join(" ")}}return{isEmpty:r==="",effectiveValue:r}}H();function xN(e){let t=0;for(;t0;){let a=e[n];if(a==="\\"&&!i&&n+1N3(e,r)).join(":")}H(),H();function er(e,t,r,n){if(e.length>r-t.length)throw new C(`${n} element limit exceeded (${r})`,"array_elements");for(let i of t)e.push(i)}at();async function EN(e,t,r,n){let i="";for(let s of t.parts)if(s.type==="Glob")i+=$e(s.pattern,!0,e.state.shoptOptions.extglob);else if(s.type==="Literal")i+=$e(s.value,!0,e.state.shoptOptions.extglob);else if(s.type==="SingleQuoted"||s.type==="Escaped")i+=Me(s.value);else if(s.type==="DoubleQuoted"){let a=await r(e,s.parts);i+=Me(a)}else if(s.type==="ParameterExpansion"){let a=await n(e,s);i+=$e(a,!0,e.state.shoptOptions.extglob)}else{let a=await n(e,s);i+=Me(a)}return i}async function SN(e,t,r,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="PatternReplacement")return null;let s=i.parts[0],a=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],l=a[2]==="*",u=s.operation,c=Te(e,o),p=c.map(([,g])=>g);if(c.length===0){let g=e.state.env.get(o);g!==void 0&&p.push(g)}if(p.length===0)return{values:[],quoted:!0};let h="";u.pattern&&(h=await EN(e,u.pattern,r,n));let f=u.replacement?await r(e,u.replacement.parts):"",d=h;u.anchor==="start"?d=`^${h}`:u.anchor==="end"&&(d=`${h}$`);let m=[];try{let g=de(d,u.all?"g":"");for(let v of p)m.push(g.replace(v,f))}catch{m.push(...p)}if(l){let g=Oe(e.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}async function AN(e,t,r,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="PatternRemoval")return null;let s=i.parts[0],a=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],l=a[2]==="*",u=s.operation,c=Te(e,o),p=c.map(([,m])=>m);if(c.length===0){let m=e.state.env.get(o);m!==void 0&&p.push(m)}if(p.length===0)return{values:[],quoted:!0};let h="",f=e.state.shoptOptions.extglob;if(u.pattern)for(let m of u.pattern.parts)if(m.type==="Glob")h+=$e(m.pattern,u.greedy,f);else if(m.type==="Literal")h+=$e(m.value,u.greedy,f);else if(m.type==="SingleQuoted"||m.type==="Escaped")h+=Me(m.value);else if(m.type==="DoubleQuoted"){let g=await r(e,m.parts);h+=Me(g)}else if(m.type==="ParameterExpansion"){let g=await n(e,m);h+=$e(g,u.greedy,f)}else{let g=await n(e,m);h+=Me(g)}let d=[];for(let m of p)d.push(Vi(e,m,h,u.side,u.greedy));if(l){let m=Oe(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}at();async function CN(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="DefaultValue"&&r.parts[0].operation?.type!=="UseAlternative"&&r.parts[0].operation?.type!=="AssignDefault")return null;let n=r.parts[0],i=n.operation,s=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),a,o=!1;if(s){let l=s[1];o=s[2]==="*";let u=Te(e,l),c=u.length>0||e.state.env.has(l),p=u.length===0||u.length===1&&u.every(([,f])=>f===""),h=i.checkEmpty??!1;if(a=i.type==="UseAlternative"?c&&!(h&&p):!c||h&&p,!a){if(u.length>0){let d=u.map(([,m])=>m);if(o){let m=Oe(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}let f=e.state.env.get(l);return f===void 0?{values:[],quoted:!0}:{values:[f],quoted:!0}}}else{let l=n.parameter,u=await Hi(e,l),c=await Ve(e,l),p=c==="",h=i.checkEmpty??!1;if(a=i.type==="UseAlternative"?u&&!(h&&p):!u||h&&p,!a)return{values:[c],quoted:!0}}if(a&&i.word){let l=i.word.parts,u=null,c=!1;for(let p of l)if(p.type==="ParameterExpansion"&&!p.operation){let h=p.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){u=h[1],c=h[2]==="*";break}}if(u){let p=Te(e,u);if(p.length>0){let f=p.map(([,d])=>d);if(c||o){let d=Oe(e.state.env);return{values:[f.join(d)],quoted:!0}}return{values:f,quoted:!0}}let h=e.state.env.get(u);return h===void 0?{values:[],quoted:!0}:{values:[h],quoted:!0}}}return null}async function kN(e,t,r,n,i){if(!r||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],a=-1,o="",l=!1,u=null;for(let d=0;dd);if(h.length===0){let d=e.state.env.get(o);if(d!==void 0)f=[d];else{if(l)return{values:[c+p],quoted:!0};let m=c+p;return{values:m?[m]:[],quoted:!0}}}if(u?.type==="PatternRemoval"){let d=u,m="",g=e.state.shoptOptions.extglob;if(d.pattern)for(let v of d.pattern.parts)if(v.type==="Glob")m+=$e(v.pattern,d.greedy,g);else if(v.type==="Literal")m+=$e(v.value,d.greedy,g);else if(v.type==="SingleQuoted"||v.type==="Escaped")m+=Me(v.value);else if(v.type==="DoubleQuoted"){let y=await i(e,v.parts);m+=Me(y)}else if(v.type==="ParameterExpansion"){let y=await n(e,v);m+=$e(y,d.greedy,g)}else{let y=await n(e,v);m+=Me(y)}f=f.map(v=>Vi(e,v,m,d.side,d.greedy))}else if(u?.type==="PatternReplacement"){let d=u,m="";if(d.pattern)for(let y of d.pattern.parts)if(y.type==="Glob")m+=$e(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")m+=$e(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")m+=Me(y.value);else if(y.type==="DoubleQuoted"){let x=await i(e,y.parts);m+=Me(x)}else if(y.type==="ParameterExpansion"){let x=await n(e,y);m+=$e(x,!0,e.state.shoptOptions.extglob)}else{let x=await n(e,y);m+=Me(x)}let g=d.replacement?await i(e,d.replacement.parts):"",v=m;d.anchor==="start"?v=`^${m}`:d.anchor==="end"&&(v=`${m}$`);try{let y=de(v,d.all?"g":"");f=f.map(x=>y.replace(x,g))}catch{}}if(l){let d=Oe(e.state.env);return{values:[c+f.join(d)+p],quoted:!0}}return f.length===1?{values:[c+f[0]+p],quoted:!0}:{values:[c+f[0],...f.slice(1,-1),f[f.length-1]+p],quoted:!0}}async function NN(e,t,r,n){if(!r||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],s=-1,a="",o=!1;for(let h=0;hh);if(c.length===0){let h=e.state.env.get(a);if(h!==void 0)return{values:[l+h+u],quoted:!0};if(o)return{values:[l+u],quoted:!0};let f=l+u;return{values:f?[f]:[],quoted:!0}}if(o){let h=Oe(e.state.env);return{values:[l+p.join(h)+u],quoted:!0}}return p.length===1?{values:[l+p[0]+u],quoted:!0}:{values:[l+p[0],...p.slice(1,-1),p[p.length-1]+u],quoted:!0}}wt(),H();async function $N(e,t,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="Substring")return null;let i=n.parts[0],s=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let a=s[1],o=s[2]==="*",l=i.operation;if(e.state.associativeArrays?.has(a))throw new ze(1,"",`bash: \${${a}[@]: 0: 3}: bad substitution `);let u=l.offset?await r(e,l.offset.expression):0,c=l.length?await r(e,l.length.expression):void 0,p=Te(e,a);if(p.length>e.limits.maxArrayElements)throw new C(`array transform element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");let h=0;if(u<0){if(p.length>0){let d=p[p.length-1][0],m=(typeof d=="number"?d:0)+1+u;if(m<0)return{values:[],quoted:!0};h=p.findIndex(([g])=>typeof g=="number"&&g>=m),h<0&&(h=p.length)}}else h=p.findIndex(([d])=>typeof d=="number"&&d>=u),h<0&&(h=p.length);let f;if(c!==void 0){if(c<0)throw new lt(`${a}[@]: substring expression < 0`);f=p.slice(h,h+c).map(([,d])=>d)}else f=p.slice(h).map(([,d])=>d);if(f.length===0)return{values:[],quoted:!0};if(o){let d=Oe(e.state.env);return{values:[f.join(d)],quoted:!0}}return{values:f,quoted:!0}}function ON(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="Transform")return null;let n=r.parts[0],i=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let s=i[1],a=i[2]==="*",o=n.operation,l=Te(e,s);if(l.length===0){let h=e.state.env.get(s);if(h!==void 0){let f;switch(o.operator){case"a":f="";break;case"P":f=nc(e,h);break;case"Q":f=Oi(h);break;default:f=h}if(q(f)>e.limits.maxStringLength)throw new C(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");return{values:[f],quoted:!0}}return a?{values:[""],quoted:!0}:{values:[],quoted:!0}}let u=vs(e,s),c=[],p=0;for(let[,h]of l){let f;switch(o.operator){case"a":f=u;break;case"P":f=nc(e,h);break;case"Q":f=Oi(h);break;case"u":f=h.charAt(0).toUpperCase()+h.slice(1);break;case"U":f=h.toUpperCase();break;case"L":f=h.toLowerCase();break;default:f=h}let d=q(f);if(d>e.limits.maxStringLength-p)throw new C(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");c.push(f),p+=d}if(a){let h=Oe(e.state.env);if(Math.max(0,c.length-1)*q(h)>e.limits.maxStringLength-p)throw new C(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");return{values:[c.join(h)],quoted:!0}}return{values:c,quoted:!0}}function TN(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion")return null;let n=r.parts[0];if(n.operation)return null;let i=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!i)return null;let s=i[1];if(dt(e,s)){let l=No(e,s);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let a=Te(e,s);if(a.length>0)return{values:a.map(([,l])=>l),quoted:!0};let o=e.state.env.get(s);return o===void 0?{values:[],quoted:!0}:{values:[o],quoted:!0}}function IN(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation)return null;let n=r.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||!dt(e,n))return null;let i=No(e,n);if(!i)return null;let s=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let a=s[1],o=Te(e,a);if(o.length>0)return{values:o.map(([,u])=>u),quoted:!0};let l=e.state.env.get(a);return l===void 0?{values:[],quoted:!0}:{values:[l],quoted:!0}}H();async function RN(e,t,r,n,i){if(!r||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="Indirection")return null;let a=s.parts[0],o=a.operation,l=await Ve(e,a.parameter),u=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!u){if(!o.innerOp&&(l==="@"||l==="*")){let d=Number.parseInt(e.state.env.get("#")||"0",10),m=[];for(let g=1;g<=d;g++)m.push(e.state.env.get(String(g))||"");return l==="*"?{values:[m.join(Oe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}return null}let c=u[1],p=u[2]==="*",h=Te(e,c);if(o.innerOp){if(o.innerOp.type==="Substring")return PN(e,h,c,p,o.innerOp);if(o.innerOp.type==="DefaultValue"||o.innerOp.type==="UseAlternative"||o.innerOp.type==="AssignDefault"||o.innerOp.type==="ErrorIfUnset")return DN(e,h,c,p,o.innerOp,i);if(o.innerOp.type==="Transform"&&o.innerOp.operator==="a"){let m=vs(e,c),g=h.map(()=>m);return p?{values:[g.join(Oe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let d=[];for(let[,m]of h){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:o.innerOp},v=e.state.env.get("_indirect_elem_");e.state.env.set("_indirect_elem_",m);try{let y=await n(e,g,!0);d.push(y)}finally{v===void 0?e.state.env.delete("_indirect_elem_"):e.state.env.set("_indirect_elem_",v)}}return p?{values:[d.join(Oe(e.state.env))],quoted:!0}:{values:d,quoted:!0}}if(h.length>0){let d=h.map(([,m])=>m);return p?{values:[d.join(Oe(e.state.env))],quoted:!0}:{values:d,quoted:!0}}let f=e.state.env.get(c);return f===void 0?{values:[],quoted:!0}:{values:[f],quoted:!0}}async function PN(e,t,r,n,i){let s=i.offset?await qe(e,i.offset.expression):0,a=i.length?await qe(e,i.length.expression):void 0,o=0;if(s<0){if(t.length>0){let c=t[t.length-1][0],p=(typeof c=="number"?c:0)+1+s;if(p<0||(o=t.findIndex(([h])=>typeof h=="number"&&h>=p),o<0))return{values:[],quoted:!0}}}else if(o=t.findIndex(([c])=>typeof c=="number"&&c>=s),o<0)return{values:[],quoted:!0};let l;if(a!==void 0){if(a<0)throw new lt(`${r}[@]: substring expression < 0`);l=t.slice(o,o+a)}else l=t.slice(o);let u=l.map(([,c])=>c);return n?{values:[u.join(Oe(e.state.env))],quoted:!0}:{values:u,quoted:!0}}async function DN(e,t,r,n,i,s){let a=i.checkEmpty??!1,o=t.map(([,c])=>c),l=t.length===0,u=t.length===0;if(i.type==="UseAlternative")return!u&&!(a&&l)&&i.word?{values:[await s(e,i.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(i.type==="DefaultValue")return(u||a&&l)&&i.word?{values:[await s(e,i.word.parts,!0)],quoted:!0}:n?{values:[o.join(Oe(e.state.env))],quoted:!0}:{values:o,quoted:!0};if(i.type==="AssignDefault"){if((u||a&&l)&&i.word){let c=await s(e,i.word.parts,!0);return Ce(e,r,0,c),{values:[c],quoted:!0}}return n?{values:[o.join(Oe(e.state.env))],quoted:!0}:{values:o,quoted:!0}}return n?{values:[o.join(Oe(e.state.env))],quoted:!0}:{values:o,quoted:!0}}async function LN(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="UseAlternative"&&t[0].operation?.type!=="DefaultValue")return null;let r=t[0],n=r.operation,i=n?.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let s=i.parts[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="Indirection")return null;let a=s.parts[0],o=(await Ve(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let l=await Hi(e,r.parameter),u=await Ve(e,r.parameter)==="",c=n.checkEmpty??!1,p;if(p=n.type==="UseAlternative"?l&&!(c&&u):!l||c&&u,p){let h=o[1],f=o[2]==="*",d=Te(e,h);if(d.length>0){let g=d.map(([,v])=>v);return f?{values:[g.join(Oe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let m=e.state.env.get(h);return m===void 0?{values:[],quoted:!0}:{values:[m],quoted:!0}}return{values:[],quoted:!1}}async function MN(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="Indirection")return null;let r=t[0],n=r.operation.innerOp;if(!n||n.type!=="UseAlternative"&&n.type!=="DefaultValue")return null;let i=n.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let s=i.parts[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="Indirection")return null;let a=s.parts[0],o=(await Ve(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let l=await Ve(e,r.parameter),u=await Hi(e,r.parameter),c=l==="",p=n.checkEmpty??!1,h;if(h=n.type==="UseAlternative"?u&&!(p&&c):!u||p&&c,h){let f=o[1],d=o[2]==="*",m=Te(e,f);if(m.length>0){let v=m.map(([,y])=>y);return d?{values:[v.join(Oe(e.state.env))],quoted:!0}:{values:v,quoted:!0}}let g=e.state.env.get(f);return g===void 0?{values:[],quoted:!0}:{values:[g],quoted:!0}}return{values:[],quoted:!1}}wt(),at(),H();function $3(e){let t=Number.parseInt(e.state.env.get("#")||"0",10);if(t>e.limits.maxArrayElements)throw new C(`positional parameter element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");let r=[],n=0;for(let i=1;i<=t;i++){let s=e.state.env.get(String(i))||"",a=q(s);if(a>e.limits.maxStringLength-n)throw new C(`positional parameter string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");r.push(s),n+=a}return r}function Ya(e,t,r){if(q(t)>r-q(e))throw new C(`positional expansion string limit exceeded (${r} bytes)`,"string_length");return e+t}function ic(e,t,r,n){if(e.length>=n.limits.maxArrayElements)throw new C(`positional expansion element limit exceeded (${n.limits.maxArrayElements})`,"array_elements");let i=q(t);if(i>n.limits.maxStringLength-r.value)throw new C(`positional expansion string limit exceeded (${n.limits.maxStringLength} bytes)`,"string_length");e.push(t),r.value+=i}async function FN(e,t,r,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],s=-1,a=!1;for(let g=0;g=p.length)f=[];else if(u!==void 0){let v=u<0?p.length+u:g+u;f=p.slice(g,Math.max(g,v))}else f=p.slice(g)}let d="";for(let g=0;g]+>|`|')/g;for(;E.exec(h)!==null;)w++;if(x+y*b+y*w*x>e.limits.maxStringLength-m.value)throw new C(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");ic(d,g.replace(v,h),m,e)}}catch(g){if(g instanceof C)throw g;for(let v of l)ic(d,v,m,e)}if(a){let g=Oe(e.state.env);if(m.value+Math.max(0,d.length-1)*q(g)+q(u)+q(c)>e.limits.maxStringLength)throw new C(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");return{values:[u+d.join(g)+c],quoted:!0}}if(q(u)+m.value+q(c)>e.limits.maxStringLength)throw new C(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");return d.length===1?{values:[u+d[0]+c],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+c],quoted:!0}}async function zN(e,t,r,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],s=-1,a=!1;for(let m=0;me.limits.maxStringLength)throw new C(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");return{values:[u+f.join(m)+c],quoted:!0}}if(q(u)+d.value+q(c)>e.limits.maxStringLength)throw new C(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");return f.length===1?{values:[u+f[0]+c],quoted:!0}:{values:[u+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}async function BN(e,t,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0],i=-1,s=!1;for(let p=0;p=e.limits.maxArrayElements)throw new C(`unquoted expansion element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");let i=q(r);if(i>e.limits.maxStringLength-n.value)throw new C(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");t.push(r),n.value+=i}function u1(e,t,r,n){let i=q(r),s=Math.max(0,t.length-1);if(i>0&&s>Math.floor((e.limits.maxStringLength-n)/i))throw new C(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");return t.join(r)}function UN(e){return new n1(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited("glob_operations",1,e.limits.maxGlobOperations,"glob expansion")})}async function $o(e,t){if(e.state.options.noglob)return t;let r=UN(e),n=[];for(let i of t)if(ei(i,e.state.shoptOptions.extglob)){let s=await r.expand(i);if(s.length>0)er(n,s,e.limits.maxArrayElements,"unquoted glob expansion");else{if(r.hasFailglob())throw new Ps(i);r.hasNullglob()||n.push(i)}}else n.push(i);return n}async function WN(e,t,r,n){let i=-1,s="",a=!1;for(let x=0;xx);if(l.length===0){let x=e.state.env.get(s);x!==void 0&&(u=[x])}if(u.length===0)return{values:[],quoted:!1};let c="";if(o.pattern)for(let x of o.pattern.parts)if(x.type==="Glob")c+=$e(x.pattern,!0,e.state.shoptOptions.extglob);else if(x.type==="Literal")c+=$e(x.value,!0,e.state.shoptOptions.extglob);else if(x.type==="SingleQuoted"||x.type==="Escaped")c+=Me(x.value);else if(x.type==="DoubleQuoted"){let b=await r(e,x.parts);c+=Me(b)}else if(x.type==="ParameterExpansion"){let b=await n(e,x);c+=$e(b,!0,e.state.shoptOptions.extglob)}else{let b=await n(e,x);c+=Me(b)}let p=o.replacement?await r(e,o.replacement.parts):"",h=c;o.anchor==="start"?h=`^${c}`:o.anchor==="end"&&(h=`${c}$`);let f=[],d={value:0};try{let x=de(h,o.all?"g":"");for(let b of u)Xr(e,f,E3(e,b,x,p,o.all),d)}catch(x){if(x instanceof C)throw x;for(let b of u)Xr(e,f,b,d)}let m=Wt(e.state.env),g=Jt(e.state.env);if(a){let x=u1(e,f,Oe(e.state.env),d.value);return g?{values:x?[x]:[],quoted:!1}:{values:nt(x,m,e.limits.maxArrayElements),quoted:!1}}if(g)return{values:f,quoted:!1};let v=[],y={value:0};for(let x of f)if(x==="")Xr(e,v,"",y);else for(let b of nt(x,m,e.limits.maxArrayElements))Xr(e,v,b,y);return{values:v,quoted:!1}}async function jN(e,t,r,n){let i=-1,s="",a=!1;for(let y=0;yy);if(l.length===0){let y=e.state.env.get(s);y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let c="",p=e.state.shoptOptions.extglob;if(o.pattern)for(let y of o.pattern.parts)if(y.type==="Glob")c+=$e(y.pattern,o.greedy,p);else if(y.type==="Literal")c+=$e(y.value,o.greedy,p);else if(y.type==="SingleQuoted"||y.type==="Escaped")c+=Me(y.value);else if(y.type==="DoubleQuoted"){let x=await r(e,y.parts);c+=Me(x)}else if(y.type==="ParameterExpansion"){let x=await n(e,y);c+=$e(x,o.greedy,p)}else{let x=await n(e,y);c+=Me(x)}let h=[],f={value:0};for(let y of u)Xr(e,h,Vi(e,y,c,o.side,o.greedy),f);let d=Wt(e.state.env),m=Jt(e.state.env);if(a){let y=u1(e,h,Oe(e.state.env),f.value);return m?{values:y?[y]:[],quoted:!1}:{values:nt(y,d,e.limits.maxArrayElements),quoted:!1}}if(m)return{values:h,quoted:!1};let g=[],v={value:0};for(let y of h)if(y==="")Xr(e,g,"",v);else for(let x of nt(y,d,e.limits.maxArrayElements))Xr(e,g,x,v);return{values:g,quoted:!1}}async function qN(e,t,r,n){let i=-1,s=!1;for(let v=0;v=c.length)h=[];else if(l!==void 0){let x=l<0?c.length+l:y+l;h=c.slice(y,Math.max(y,x))}else h=c.slice(y)}let f="";for(let y=0;yu!=="");else{let u=Oe(e.state.env);l=nt(i.join(u),s,e.limits.maxArrayElements)}else if(a)l=i.filter(u=>u!=="");else if(o){l=[];for(let u of i){if(u==="")continue;let c=nt(u,s,e.limits.maxArrayElements);er(l,c,e.limits.maxArrayElements,"unquoted expansion")}}else{l=[];for(let u of i)if(u==="")l.push("");else{let c=nt(u,s,e.limits.maxArrayElements);er(l,c,e.limits.maxArrayElements,"unquoted expansion")}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await $o(e,l),quoted:!1}}async function VN(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation)return null;let r=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!r)return null;let n=r[1],i=r[2]==="*",s=Te(e,n),a;if(s.length===0){let p=e.state.env.get(n);if(p!==void 0)a=[p];else return{values:[],quoted:!1}}else a=s.map(([,p])=>p);let o=Wt(e.state.env),l=Jt(e.state.env),u=i1(e.state.env),c;if(i)if(l)c=a.filter(p=>p!=="");else{let p=Oe(e.state.env);c=nt(a.join(p),o,e.limits.maxArrayElements)}else if(l)c=a.filter(p=>p!=="");else if(u){c=[];for(let p of a){if(p==="")continue;let h=nt(p,o,e.limits.maxArrayElements);er(c,h,e.limits.maxArrayElements,"unquoted expansion")}}else{c=[];for(let p of a)if(p==="")c.push("");else{let h=nt(p,o,e.limits.maxArrayElements);er(c,h,e.limits.maxArrayElements,"unquoted expansion")}for(;c.length>0&&c[c.length-1]==="";)c.pop()}return{values:await $o(e,c),quoted:!1}}function ZN(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let r=t[0].operation,n=l1(e,r.prefix);if(n.length===0)return{values:[],quoted:!1};let i=Wt(e.state.env),s=Jt(e.state.env),a;if(r.star)if(s)a=n;else{let o=Oe(e.state.env);a=nt(n.join(o),i,e.limits.maxArrayElements)}else if(s)a=n;else{a=[];for(let o of n){let l=nt(o,i,e.limits.maxArrayElements);er(a,l,e.limits.maxArrayElements,"unquoted expansion")}}return{values:a,quoted:!1}}function QN(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="ArrayKeys")return null;let r=t[0].operation,n=Te(e,r.array).map(([o])=>String(o));if(n.length===0)return{values:[],quoted:!1};let i=Wt(e.state.env),s=Jt(e.state.env),a;if(r.star)if(s)a=n;else{let o=Oe(e.state.env);a=nt(n.join(o),i,e.limits.maxArrayElements)}else if(s)a=n;else{a=[];for(let o of n){let l=nt(o,i,e.limits.maxArrayElements);er(a,l,e.limits.maxArrayElements,"unquoted expansion")}}return{values:a,quoted:!1}}async function KN(e,t,r){let n=-1;for(let h=0;hf!=="");else if(c){p=[];for(let f of h){if(f==="")continue;let d=nt(f,l,e.limits.maxArrayElements);er(p,d,e.limits.maxArrayElements,"unquoted expansion")}}else{p=[];for(let f of h)if(f==="")p.push("");else{let d=nt(f,l,e.limits.maxArrayElements);er(p,d,e.limits.maxArrayElements,"unquoted expansion")}for(;p.length>0&&p[p.length-1]==="";)p.pop()}}return p.length===0?{values:[],quoted:!1}:{values:await $o(e,p),quoted:!1}}async function XN(e,t,r){e.coverage?.hit("bash:expansion:word_glob");let n=t.parts,{hasQuoted:i,hasCommandSub:s,hasArrayVar:a,hasArrayAtExpansion:o,hasParamExpansion:l,hasVarNamePrefixExpansion:u,hasIndirection:c}=ec(n),p=r.hasBraceExpansion(n)?await r.expandWordWithBracesAsync(e,t):null;if(p&&p.length>1)return YN(e,p,i);let h=await JN(e,n,o,u,c,r);if(h!==null)return h;let f=await t$(e,n,r);if(f!==null)return f;let d=await r$(e,n,r);if(d!==null)return d;let m=await i$(e,n,r.expandPart);if(m!==null)return a0(e,m);if((s||a||l)&&!Jt(e.state.env)){let g=Wt(e.state.env),v=r.buildIfsCharClassPattern(g);return a0(e,await r.smartWordSplit(e,n,g,v,r.expandPart))}return s$(e,t,n,await r.expandWordAsync(e,t),i,r.expandWordForGlobbing)}async function YN(e,t,r){let n=[];for(let i of t)(r||i!=="")&&(!r&&!e.state.options.noglob&&ei(i,e.state.shoptOptions.extglob)?er(n,await Ja(e,i),e.limits.maxArrayElements,"brace/glob expansion"):n.push(i));return{values:n,quoted:!1}}async function JN(e,t,r,n,i,s){if(r){let a=TN(e,t);if(a!==null)return a}{let a=IN(e,t);if(a!==null)return a}{let a=await CN(e,t);if(a!==null)return a}{let a=await kN(e,t,r,s.expandPart,s.expandWordPartsAsync);if(a!==null)return a}{let a=await NN(e,t,r,s.expandPart);if(a!==null)return a}{let a=await $N(e,t,s.evaluateArithmetic);if(a!==null)return a}{let a=ON(e,t);if(a!==null)return a}{let a=await SN(e,t,s.expandWordPartsAsync,s.expandPart);if(a!==null)return a}{let a=await AN(e,t,s.expandWordPartsAsync,s.expandPart);if(a!==null)return a}if(n&&t.length===1&&t[0].type==="DoubleQuoted"){let a=e$(e,t);if(a!==null)return a}{let a=await RN(e,t,i,s.expandParameterAsync,s.expandWordPartsAsync);if(a!==null)return a}{let a=await LN(e,t);if(a!==null)return a}{let a=await MN(e,t);if(a!==null)return a}return null}function e$(e,t){let r=t[0];if(r.type!=="DoubleQuoted")return null;if(r.parts.length===1&&r.parts[0].type==="ParameterExpansion"&&r.parts[0].operation?.type==="VarNamePrefix"){let n=r.parts[0].operation,i=l1(e,n.prefix);return n.star?{values:[i.join(Oe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}if(r.parts.length===1&&r.parts[0].type==="ParameterExpansion"&&r.parts[0].operation?.type==="ArrayKeys"){let n=r.parts[0].operation,i=Te(e,n.array).map(([s])=>String(s));return n.star?{values:[i.join(Oe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function t$(e,t,r){{let n=await FN(e,t,r.evaluateArithmetic,r.expandPart);if(n!==null)return n}{let n=await _N(e,t,r.expandPart,r.expandWordPartsAsync);if(n!==null)return n}{let n=await zN(e,t,r.expandPart,r.expandWordPartsAsync);if(n!==null)return n}{let n=await BN(e,t,r.expandPart);if(n!==null)return n}return null}async function r$(e,t,r){{let n=await WN(e,t,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await jN(e,t,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await qN(e,t,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await GN(e,t,r.evaluateArithmetic,r.expandPart);if(n!==null)return n}{let n=await HN(e,t);if(n!==null)return n}{let n=await VN(e,t);if(n!==null)return n}{let n=ZN(e,t);if(n!==null)return n}{let n=QN(e,t);if(n!==null)return n}{let n=await KN(e,t,r.expandPart);if(n!==null)return n}return null}function s0(e){if(e.type!=="DoubleQuoted")return null;for(let t=0;to),a.length===0){let o=e.state.env.get(r.name);o!==void 0&&(a=[o])}}else{let o=Number.parseInt(e.state.env.get("#")||"0",10);a=[];for(let l=1;l<=o;l++)a.push(e.state.env.get(String(l))||"")}if(r.isStar){let o=Oe(e.state.env),l=a.join(o);return[i+l+s]}if(a.length===0){let o=i+s;return o?[o]:[]}return a.length===1?[i+a[0]+s]:[i+a[0],...a.slice(1,-1),a[a.length-1]+s]}async function i$(e,t,r){if(t.length<2)return null;let n=!1;for(let l of t)if(s0(l)){n=!0;break}if(!n)return null;let i=Wt(e.state.env),s=Jt(e.state.env),a=[];for(let l of t){let u=s0(l);if(u&&l.type==="DoubleQuoted"){let c=await n$(e,l,u,r);a.push(c)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let c=await r(e,l);a.push([c])}else if(l.type==="Literal")a.push([l.value]);else if(l.type==="ParameterExpansion"){let c=await r(e,l);if(s)a.push(c?[c]:[]);else{let p=nt(c,i,e.limits.maxArrayElements);a.push(p)}}else{let c=await r(e,l);if(s)a.push(c?[c]:[]);else{let p=nt(c,i,e.limits.maxArrayElements);a.push(p)}}}let o=[];for(let l of a)if(l.length!==0)if(o.length===0)er(o,l,e.limits.maxArrayElements,"word expansion");else{let u=o.length-1;o[u]=o[u]+l[0];for(let c=1;ce.executionScope.consumeLimited("glob_operations",1,e.limits.maxGlobOperations,"glob expansion")}),n=await r.expand(t);if(n.length>0)return n;if(r.hasFailglob())throw new Ps(t);return r.hasNullglob()?[]:[t]}async function s$(e,t,r,n,i,s){let a=r.some(o=>o.type==="Glob");if(!e.state.options.noglob&&a){let o=await s(e,t);if(ei(o,e.state.shoptOptions.extglob)){let u=await Ja(e,o);if(u.length>0&&u[0]!==o)return{values:u,quoted:!1};if(u.length===0)return{values:[],quoted:!1}}let l=i0(n);return Jt(e.state.env)?{values:[l],quoted:!1}:{values:nt(l,Wt(e.state.env),e.limits.maxArrayElements),quoted:!1}}if(!i&&!e.state.options.noglob&&ei(n,e.state.shoptOptions.extglob)){let o=await s(e,t);if(ei(o,e.state.shoptOptions.extglob)){let l=await Ja(e,o);if(l.length>0&&l[0]!==o)return{values:l,quoted:!1}}}if(n===""&&!i)return{values:[],quoted:!1};if(a&&!i){let o=i0(n);return Jt(e.state.env)?{values:[o],quoted:!1}:{values:nt(o,Wt(e.state.env),e.limits.maxArrayElements),quoted:!1}}return{values:[n],quoted:i}}H();function Ut(e,t,r){if(t.length>=e.limits.maxArrayElements)throw new C(`word splitting element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");t.push(r)}async function O3(e,t){let r=t.operation;if(!r||r.type!=="DefaultValue"&&r.type!=="AssignDefault"&&r.type!=="UseAlternative")return null;let n=r.word;if(!n||n.parts.length===0)return null;let i=await Hi(e,t.parameter),s=await Ve(e,t.parameter,!1)==="",a=r.checkEmpty??!1,o;return o=r.type==="UseAlternative"?i&&!(a&&s):!i||a&&s,o?n.parts:null}function a$(e){return e.type==="SingleQuoted"||e.type==="DoubleQuoted"&&e.parts.every(t=>t.type==="Literal")}async function o$(e,t){if(t.type!=="ParameterExpansion")return null;let r=await O3(e,t);if(!r||r.length<=1)return null;let n=r.some(s=>a$(s)),i=r.some(s=>s.type==="Literal"||s.type==="ParameterExpansion"||s.type==="CommandSubstitution"||s.type==="ArithmeticExpansion");return n&&i?r:null}function l$(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?y3(e.pattern):!(e.type!=="ParameterExpansion"&&e.type!=="CommandSubstitution"&&e.type!=="ArithmeticExpansion"||e.type==="ParameterExpansion"&&_k(e))}async function u$(e,t,r,n,i){if(e.coverage?.hit("bash:expansion:word_split"),t.length===1&&t[0].type==="ParameterExpansion"){let h=t[0],f=await O3(e,h);if(f&&f.length>0&&f.length>1&&f.some(d=>d.type==="DoubleQuoted"||d.type==="SingleQuoted")&&f.some(d=>d.type==="Literal"||d.type==="ParameterExpansion"||d.type==="CommandSubstitution"||d.type==="ArithmeticExpansion"))return o0(e,f,r,n,i)}let s=[],a=!1;for(let h of t){let f=l$(h),d=h.type==="DoubleQuoted"||h.type==="SingleQuoted",m=f?await o$(e,h):null,g=await i(e,h);s.push({value:g,isSplittable:f,isQuoted:d,mixedDefaultParts:m??void 0}),f&&(a=!0)}if(!a){let h=s.map(f=>f.value).join("");return h?[h]:[]}let o=[],l="",u=!1,c=!1,p=!1;for(let h of s)if(!h.isSplittable)c?h.isQuoted&&h.value===""?(l!==""&&Ut(e,o,l),Ut(e,o,""),u=!0,l="",c=!1,p=!0):h.value===""?(l+=h.value,p=!1):(l!==""&&Ut(e,o,l),l=h.value,c=!1,p=!1):(l+=h.value,p=h.isQuoted&&h.value==="");else if(h.mixedDefaultParts){let f=await o0(e,h.mixedDefaultParts,r,n,i);if(f.length!==0)if(f.length===1)l+=f[0],u=!0;else{l+=f[0],Ut(e,o,l),u=!0;for(let d=1;d0&&t.includes(e[0])}async function o0(e,t,r,n,i){let s=[];for(let c of t){let p=c.type!=="DoubleQuoted"&&c.type!=="SingleQuoted",h=await i(e,c);s.push({value:h,isSplittable:p})}let a=[],o="",l=!1,u=!1;for(let c of s)if(!c.isSplittable)u&&c.value!==""?(o!==""&&Ut(e,a,o),o=c.value,u=!1):o+=c.value;else{c$(c.value,r)&&o!==""&&(Ut(e,a,o),o="",l=!0);let{words:p,hadTrailingDelimiter:h}=a1(c.value,r,e.limits.maxArrayElements);if(p.length===0)h&&(u=!0);else if(p.length===1)o+=p[0],l=!0,u=h;else{o+=p[0],Ut(e,a,o),l=!0;for(let f=1;f({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let t=we(e);return this.mounts.has(t)}validateMountPath(e){let t=e.split("/");for(let r of t)if(r==="."||r==="..")throw Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e==="/")throw Error("Cannot mount at root '/'");for(let t of this.mounts.keys())if(t!==e){if(e.startsWith(`${t}/`))throw Error(`Cannot mount at '${e}': inside existing mount '${t}'`);if(t.startsWith(`${e}/`))throw Error(`Cannot mount at '${e}': would contain existing mount '${t}'`)}}routePath(e){gt(e,"access");let t=we(e),r=null,n=0;for(let i of this.mounts.values()){let s=i.mountPoint;if(t===s)return{fs:i.filesystem,relativePath:"/"};t.startsWith(`${s}/`)&&s.length>n&&(r=i,n=s.length)}if(r){let i=t.slice(n);return{fs:r.filesystem,relativePath:i||"/"}}return{fs:this.baseFs,relativePath:t}}getChildMountPoints(e){let t=we(e),r=t==="/"?"/":`${t}/`,n=[];for(let i of this.mounts.keys())if(i.startsWith(r)){let s=i.slice(r.length).split("/")[0];s&&!n.includes(s)&&n.push(s)}return n}async readFile(e,t){let{fs:r,relativePath:n}=this.routePath(e);return r.readFile(n,t)}async readFileBytes(e){let{fs:t,relativePath:r}=this.routePath(e);return xn(t,r)}async readFileBuffer(e){let{fs:t,relativePath:r}=this.routePath(e);return t.readFileBuffer(r)}async writeFile(e,t,r){let{fs:n,relativePath:i}=this.routePath(e);return n.writeFile(i,t,r)}async appendFile(e,t,r){let{fs:n,relativePath:i}=this.routePath(e);return n.appendFile(i,t,r)}async exists(e){let t=we(e);if(this.mounts.has(t)||this.getChildMountPoints(t).length>0)return!0;let{fs:r,relativePath:n}=this.routePath(e);return r.exists(n)}async stat(e){let t=we(e),r=this.mounts.get(t);if(r)try{return await r.filesystem.stat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(t).length>0)try{return await this.baseFs.stat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:n,relativePath:i}=this.routePath(e);return n.stat(i)}async lstat(e){let t=we(e),r=this.mounts.get(t);if(r)try{return await r.filesystem.lstat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(t).length>0)try{return await this.baseFs.lstat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:n,relativePath:i}=this.routePath(e);return n.lstat(i)}async mkdir(e,t){let r=we(e);if(this.mounts.has(r)){if(t?.recursive)return;throw Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(r).length>0&&t?.recursive)return;let{fs:n,relativePath:i}=this.routePath(e);return n.mkdir(i,t)}async readdir(e){let t=we(e),r=new Set,n=null,{fs:i,relativePath:s}=this.routePath(e);try{let o=await i.readdir(s);for(let l of o)r.add(l)}catch(o){let l=o.code,u=o.message||"";if(l!=="ENOENT"&&!u.includes("ENOENT"))throw o;n=o}let a=this.getChildMountPoints(t);for(let o of a)r.add(o);if(r.size===0&&n&&!this.mounts.has(t))throw n;return Array.from(r).sort()}async rm(e,t){let r=we(e);if(this.mounts.has(r))throw Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(r).length>0)throw Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:n,relativePath:i}=this.routePath(e);return n.rm(i,t)}async cp(e,t,r){if((await this.stat(e)).isDirectory&&ri(e,t))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);let n=this.routePath(e),i=this.routePath(t);return n.fs===i.fs?n.fs.cp(n.relativePath,i.relativePath,r):this.crossMountCopy(e,t,r)}async mv(e,t){let r=we(e);if((await this.stat(e)).isDirectory&&ri(e,t))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(this.mounts.has(r))throw Error(`EBUSY: mount point, cannot move '${e}'`);let n=this.routePath(e),i=this.routePath(t);if(n.fs===i.fs)return n.fs.mv(n.relativePath,i.relativePath);await this.cp(e,t,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,t){return jm(e,t)}getAllPaths(){let e=new Set;for(let t of this.baseFs.getAllPaths())e.add(t);for(let t of this.mounts.keys()){let r=t.split("/").filter(Boolean),n="";for(let s of r)n=`${n}/${s}`,e.add(n);let i=this.mounts.get(t);if(i)for(let s of i.filesystem.getAllPaths())s==="/"?e.add(t):e.add(`${t}${s}`)}return Array.from(e).sort()}async chmod(e,t){let r=we(e),n=this.mounts.get(r);if(n)return n.filesystem.chmod("/",t);let{fs:i,relativePath:s}=this.routePath(e);return i.chmod(s,t)}async symlink(e,t){let{fs:r,relativePath:n}=this.routePath(t);return r.symlink(e,n)}async link(e,t){let r=this.routePath(e),n=this.routePath(t);if(r.fs!==n.fs)throw Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${t}'`);return r.fs.link(r.relativePath,n.relativePath)}async readlink(e){let{fs:t,relativePath:r}=this.routePath(e);return t.readlink(r)}async realpath(e){let t=we(e);if(this.mounts.get(t))return t;let{fs:r,relativePath:n}=this.routePath(e),i=await r.realpath(n);for(let[s,a]of this.mounts)if(t===s||t.startsWith(`${s}/`))return i==="/"?s:`${s}${i}`;return i}async crossMountCopy(e,t,r){let n=await this.lstat(e);if(n.isFile){let i=await this.readFileBuffer(e);await this.writeFile(t,i),await this.chmod(t,n.mode)}else if(n.isDirectory){if(!r?.recursive)throw Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(t,{recursive:!0});let i=await this.readdir(e);for(let s of i){let a=Vr(e,s),o=Vr(t,s);await this.crossMountCopy(a,o,r)}}else if(n.isSymbolicLink){let i=await this.readlink(e);await this.symlink(i,t)}}async utimes(e,t,r){let{fs:n,relativePath:i}=this.routePath(e);return n.utimes(i,t,r)}};H();var eo="/dev/fd",T3=63,l0=T3-10+1,d$=class extends Ga{isLiveDescriptor;constructor(e){super(),this.isLiveDescriptor=e}assertLiveDescriptor(e,t){this.isLiveDescriptor(e)||this.refuse(e,t)}refuse(e,t){throw Error(`EROFS: read-only file system, ${t} '${eo}${e}'`)}async writeFile(e,t,r){return this.assertLiveDescriptor(e,"write"),super.writeFile(e,t,r)}async appendFile(e,t,r){return this.assertLiveDescriptor(e,"append"),super.appendFile(e,t,r)}async rm(e,t){return this.assertLiveDescriptor(e,"rm"),super.rm(e,t)}async mkdir(e,t){this.refuse(e,"mkdir")}async cp(e,t){this.refuse(t,"cp")}async mv(e,t){this.refuse(t,"mv")}async symlink(e,t){this.refuse(t,"symlink")}async link(e,t){this.refuse(t,"link")}async chmod(e,t){this.refuse(e,"chmod")}async utimes(e,t,r){this.refuse(e,"utimes")}};function m$(e){let t=new d$(r=>I3(e).some(n=>n.path===`${eo}${r}`));e.fs=new f$({base:e.fs,mounts:[{mountPoint:eo,filesystem:t}]}),e.state.processSubstitutionFsMounted=!0}async function g$(e,t,r){try{await e.fs.writeFile(t,r,"binary");return}catch(n){if(e.state.processSubstitutionFsMounted)throw n;m$(e)}await e.fs.writeFile(t,r,"binary")}async function y$(e,t){try{await e.fs.rm(t,{force:!0})}catch{}}function I3(e){let t=e.state.processSubstitutions;if(t)return t;let r=[];return e.state.processSubstitutions=r,r}async function R3(e,t,r){let n=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(n>=i)throw new C(`Process substitution nesting limit exceeded (${i})`,"substitution_depth");let s=e.substitutionDepth,a=new Map(e.state.env),o=qi(e.state.arrays),l=e.state.cwd,u=e.state.bashPid,c=e.state.suppressVerbose,p=e.state.groupStdin,h=e.state.lastExitCode,f=e.state.env.get("?");e.substitutionDepth=n+1,e.state.bashPid=e.state.nextVirtualPid++,e.state.suppressVerbose=!0,r!==void 0&&(e.state.groupStdin=r);let d;try{d=await e.executeScript(t)}catch(m){if(m instanceof C)throw m;if(m instanceof ze)return{stdout:m.stdout,stderr:m.stderr,exitCode:m.exitCode};throw m}finally{e.substitutionDepth=s,e.state.env=a,e.state.arrays=o,e.state.cwd=l,e.state.bashPid=u,e.state.suppressVerbose=c,e.state.groupStdin=p,e.state.lastExitCode=h,f===void 0?e.state.env.delete("?"):e.state.env.set("?",f)}return d}async function x$(e,t){let r=I3(e);if(r.length>=l0)throw new C(`Process substitution limit exceeded (${l0} concurrent)`,"file_descriptors");let n="";if(t.direction==="input"){let a=await R3(e,t.body,void 0);if(a.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+a.stderr),n=Ss(a),n.length>e.limits.maxStringLength)throw new C(`process substitution: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length")}let i=T3-r.length,s=`${eo}/${i}`;r.push({fd:i,path:s,direction:t.direction,body:t.body});try{await g$(e,s,n)}catch(a){throw r.pop(),a}return s}function v$(e){return e.state.processSubstitutions?.length??0}var b$={stdout:"",stderr:""};async function u0(e,t){let r=e.state.processSubstitutions;if(!r||r.length<=t)return b$;let n="",i="";for(;r.length>t;){let s=r[r.length-1],a="";if(s.direction==="output")try{a=await xn(e.fs,s.path)}catch{}if(await y$(e,s.path),r.pop(),s.direction==="output"){let o=await R3(e,s.body,a);n+=Ss(o),i+=o.stderr}}return{stdout:n,stderr:i}}function On(e,t,r){if(e.length>t)throw new C(`${r}: string length limit exceeded (${t} bytes)`,"string_length")}async function Tr(e,t,r=!1){let n=[];for(let i of t)n.push(await lr(e,i,r));return n.join("")}function w$(e){return h$(e)}function E$(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!w$(t))return!1;return!0}function S$(e,t,r=!1){let n=p$(t);if(n!==null)return n;switch(t.type){case"TildeExpansion":return r?t.user===null?"~":`~${t.user}`:(e.coverage?.hit("bash:expansion:tilde"),t.user===null?e.state.env.get("HOME")??"/home/user":t.user==="root"?"/root":`~${t.user}`);case"Glob":return k3(e,t.pattern);default:return null}}async function Qe(e,t){return c1(e,t)}async function A$(e,t){let r=[];for(let n of t.parts)if(n.type==="Escaped")r.push(rc(n.value));else if(n.type==="SingleQuoted")r.push(n.value);else if(n.type==="DoubleQuoted"){let i=await Tr(e,n.parts);r.push(i)}else if(n.type==="TildeExpansion"){let i=await lr(e,n);r.push(rc(i))}else r.push(await lr(e,n));return r.join("")}async function C$(e,t){let r=[];for(let n of t.parts)if(n.type==="Escaped"){let i=n.value;"()|*?[]".includes(i)?r.push(`\\${i}`):r.push(i)}else if(n.type==="SingleQuoted")r.push(yn(n.value));else if(n.type==="DoubleQuoted"){let i=await Tr(e,n.parts);r.push(yn(i))}else r.push(await lr(e,n));return r.join("")}async function P3(e,t){let r=[];for(let n of t.parts)if(n.type==="SingleQuoted")r.push(yn(n.value));else if(n.type==="Escaped"){let i=n.value;"*?[]\\()|".includes(i)?r.push(`\\${i}`):r.push(i)}else if(n.type==="DoubleQuoted"){let i=await Tr(e,n.parts);r.push(yn(i))}else n.type==="Glob"?xN(n.pattern)?r.push(await bN(e,n.pattern)):r.push(k3(e,n.pattern)):n.type==="Literal"?r.push(n.value):r.push(await lr(e,n));return r.join("")}function Oo(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&Oo(t.parts))return!0;return!1}var c0=1e5;async function D3(e,t,r={count:0}){let n=()=>{r.count++,e.executionScope.consumeLimited("brace_operations",1,Math.min(c0,e.limits.maxBraceExpansionResults),"brace expansion")},i=(a,o)=>{if(a.length>=e.limits.maxBraceExpansionResults)throw new C(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,"array_elements");n(),a.push(o)},s=[[]];for(let a of t)if(a.type==="BraceExpansion"){let o=[],l=!1,u="";for(let p of a.items)if(p.type==="Range"){let h=w3(p.start,p.end,p.step,p.startStr,p.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(h.expanded)for(let f of h.expanded)i(o,f);else{l=!0,u=h.literal;break}}else{let h=await D3(e,p.word.parts,r);for(let f of h){let d=[];for(let m of f)typeof m=="string"?d.push(m):d.push(await lr(e,m));i(o,d.join(""))}}if(l){for(let p of s)n(),p.push(u);continue}if(s.length*o.length>e.limits.maxBraceExpansionResults||r.count>c0)throw new C(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,"array_elements");let c=[];for(let p of s)for(let h of o){if(c.length>=e.limits.maxBraceExpansionResults)throw new C(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,"array_elements");n(),c.push([...p,h])}s=c}else for(let o of s)n(),o.push(a);return s}async function L3(e,t){let r=t.parts;if(!Oo(r))return[await Qe(e,t)];let n=await D3(e,r),i=[];for(let s of n){let a=[];for(let o of s)typeof o=="string"?a.push(o):a.push(await lr(e,o));i.push(N3(e,a.join("")))}return i}function k$(){return{expandWordAsync:c1,expandWordForGlobbing:P3,expandWordWithBracesAsync:L3,expandWordPartsAsync:Tr,expandPart:lr,expandParameterAsync:to,hasBraceExpansion:Oo,evaluateArithmetic:qe,buildIfsCharClassPattern:Bk,smartWordSplit:u$}}async function li(e,t){return XN(e,t,k$())}function N$(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function M3(e,t){if(Number.parseInt(e.state.env.get("#")||"0",10)<2)return!1;function r(n){for(let i of n)if(i.type==="DoubleQuoted"){for(let s of i.parts)if(s.type==="ParameterExpansion"&&s.parameter==="@"&&!s.operation)return!0}return!1}return r(t.parts)}async function $$(e,t){if(M3(e,t))return{error:`bash: $@: ambiguous redirect `};let r=t.parts,{hasQuoted:n}=ec(r);if(Oo(r)&&(await L3(e,t)).length>1)return{error:`bash: ${r.map(c=>c.type==="Literal"?c.value:c.type==="BraceExpansion"?`{${c.items.map(p=>{if(p.type==="Range"){let h=p.step?`..${p.step}`:"";return`${p.startStr??p.start}..${p.endStr??p.end}${h}`}return p.word.parts.map(h=>h.type==="Literal"?h.value:"").join("")}).join(",")}}`:"").join("")}: ambiguous redirect `};let i=await c1(e,t),{hasParamExpansion:s,hasCommandSub:a}=ec(r);if((s||a)&&!n&&!Jt(e.state.env)&&nt(i,Wt(e.state.env),e.limits.maxArrayElements).length>1)return{error:`bash: $${N$(r)}: ambiguous redirect `};if(n||e.state.options.noglob||r.some(c=>c.type==="ProcessSubstitution"))return{target:i};let o=await P3(e,t);if(!ei(o,e.state.shoptOptions.extglob))return{target:i};let l=new n1(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited("glob_operations",1,e.limits.maxGlobOperations,"glob expansion")}),u=await l.expand(o);return u.length===0?l.hasFailglob()?{error:`bash: no match: ${i} `}:{target:i}:u.length===1?{target:u[0]}:{error:`bash: ${i}: ambiguous redirect `}}async function c1(e,t){let r=t.parts,n=r.length;if(n===1){let a=await lr(e,r[0]);return On(a,e.limits.maxStringLength,"word expansion"),a}let i=[];for(let a=0;a=a)throw new C(`Command substitution nesting limit exceeded (${a})`,"substitution_depth");let o=e.substitutionDepth;e.substitutionDepth=s+1;let l=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let u=new Map(e.state.env),c=qi(e.state.arrays),p=e.state.cwd,h=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let f=await e.executeScript(t.body),d=f.exitCode;e.state.env=u,e.state.arrays=c,e.state.cwd=p,e.state.suppressVerbose=h,e.state.lastExitCode=d,e.state.env.set("?",String(d)),f.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+f.stderr),e.state.bashPid=l,e.substitutionDepth=o;let m=f.stdout.replace(/\n+$/,"");return On(m,e.limits.maxStringLength,"command substitution"),m}catch(f){if(e.state.env=u,e.state.arrays=c,e.state.cwd=p,e.state.bashPid=l,e.substitutionDepth=o,e.state.suppressVerbose=h,f instanceof C)throw f;if(f instanceof ze){e.state.lastExitCode=f.exitCode,e.state.env.set("?",String(f.exitCode)),f.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+f.stderr);let d=f.stdout.replace(/\n+$/,"");return On(d,e.limits.maxStringLength,"command substitution"),d}throw f}}case"ProcessSubstitution":return x$(e,t);case"ArithmeticExpansion":{let i=t.expression.originalText;if(i&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(i)){let s=await Vk(e,i),a=ct(new Be,s);return String(await qe(e,a.expression,!0))}return String(await qe(e,t.expression.expression,!0))}case"BraceExpansion":{let i=[];for(let s of t.items)if(s.type==="Range"){let a=w3(s.start,s.end,s.step,s.startStr,s.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(a.expanded)i.push(...a.expanded);else return a.literal}else i.push(await Qe(e,s.word));return i.join(" ")}default:return""}}async function to(e,t,r=!1){let{parameter:n}=t,{operation:i}=t,s=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let[,h,f]=s;(e.state.associativeArrays?.has(h)||f.includes("$(")||f.includes("`")||f.includes("${"))&&(n=`${h}[${await n0(e,f)}]`)}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&dt(e,n)){let h=Jr(e,n);if(h&&h!==n){let f=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,d,m]=f;(e.state.associativeArrays?.has(d)||m.includes("$(")||m.includes("`")||m.includes("${"))&&(n=`${d}[${await n0(e,m)}]`)}}}let a=i&&(i.type==="DefaultValue"||i.type==="AssignDefault"||i.type==="UseAlternative"||i.type==="ErrorIfUnset"),o=await Ve(e,n,!a);if(!i)return o;let l=!await Hi(e,n),{isEmpty:u,effectiveValue:c}=yN(e,n,o,r),p={value:o,isUnset:l,isEmpty:u,effectiveValue:c,inDoubleQuotes:r};switch(i.type){case"DefaultValue":return iN(e,i,p,Tr);case"AssignDefault":return sN(e,n,i,p,Tr);case"ErrorIfUnset":return aN(e,n,i,p,Tr);case"UseAlternative":return oN(e,i,p,Tr);case"PatternRemoval":{let h=await lN(e,o,i,Tr,lr);return On(h,e.limits.maxStringLength,"pattern removal"),h}case"PatternReplacement":{let h=await uN(e,o,i,Tr,lr);return On(h,e.limits.maxStringLength,"pattern replacement"),h}case"Length":return cN(e,n,o);case"LengthSliceError":throw new hn(n);case"BadSubstitution":throw new hn(i.text);case"Substring":return pN(e,n,o,i);case"CaseModification":{let h=await hN(e,o,i,Tr,to);return On(h,e.limits.maxStringLength,"case modification"),h}case"Transform":return fN(e,n,o,l,i);case"Indirection":return dN(e,n,o,l,i,to,r);case"ArrayKeys":return mN(e,i);case"VarNamePrefix":return gN(e,i);default:return o}}function F3(){return{visited:new Set,depth:0}}function O$(e,t,r){switch(r){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":if(t===0)throw new lt("division by 0");return Math.trunc(e/t);case"%":if(t===0)throw new lt("division by 0");return e%t;case"**":if(t<0)throw new lt("exponent less than 0");return e**t;case"<<":return e<>":return e>>t;case"<":return+(e":return+(e>t);case">=":return+(e>=t);case"==":return+(e===t);case"!=":return e===t?0:1;case"&":return e&t;case"|":return e|t;case"^":return e^t;case",":return t;default:return 0}}function p0(e,t,r){switch(r){case"=":return t;case"+=":return e+t;case"-=":return e-t;case"*=":return e*t;case"/=":return t===0?0:Math.trunc(e/t);case"%=":return t===0?0:e%t;case"<<=":return e<>=":return e>>t;case"&=":return e&t;case"|=":return e|t;case"^=":return e^t;default:return t}}function T$(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return+(e===0);case"~":return~e;default:return e}}async function I$(e,t){let r=e.state.env.get(t);if(r!==void 0)return r;let n=tt(e,t,0);return n===void 0?await Ve(e,t):n}async function R$(e,t,r){if(!t)return 0;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(t.trim()))return n;let i=t.trim();if(!i)return 0;let{expr:s,pos:a}=Ws(new Be,i,0);if(a100)throw new lt("maximum variable indirection depth exceeded");if(n.visited.has(t))throw new lt(`arithmetic variable cycle detected at ${t}`);n.visited.add(t),n.depth++;try{return await R$(e,r,n)}finally{n.depth--,n.visited.delete(t)}}async function sc(e,t,r){if(r.depth>100)throw new lt("maximum variable indirection depth exceeded");if(r.visited.has(t))throw new lt(`arithmetic variable cycle detected at ${t}`);r.visited.add(t),r.depth++;try{let n=await I$(e,t);if(!n)return 0;let i=Number.parseInt(n,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(n.trim()))return i;let s=n.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return await sc(e,s,r);let{expr:a,pos:o}=Ws(new Be,s,0);if(o0&&(n===-1||hMi(e,s,a,n);switch(t.type){case"ArithNumber":if(Number.isNaN(t.value))throw new lt("value too great for base");return t.value;case"ArithVariable":return await sc(e,t.name,n);case"ArithSpecialVar":{let s=(await Ve(e,t.name)).trim();if(!s)return 0;let a=Number.parseInt(s,10);if(!Number.isNaN(a)&&/^-?\d+$/.test(s))return a;let{expr:o}=Ws(new Be,s,0);return await i(o)}case"ArithNested":return await i(t.expression);case"ArithCommandSubst":if(e.execFn){let s=await e.execFn(t.command,{signal:e.state.signal});s.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+s.stderr);let a=s.stdout.trim();return Number.parseInt(a,10)||0}return 0;case"ArithBracedExpansion":{let s=await Aa(e,t.content);return Number.parseInt(s,10)||0}case"ArithDynamicBase":{let s=await Aa(e,t.baseExpr),a=Number.parseInt(s,10);return a<2||a>64?0:Qu(`${a}#${t.value}`)}case"ArithDynamicNumber":return Qu(await Aa(e,t.prefix)+t.suffix);case"ArithArrayElement":{let s=e.state.associativeArrays?.has(t.array),a=async o=>{let l=tt(e,t.array,o);return l===void 0?0:await ia(e,`${t.array}[${o}]`,l,n)};if(t.stringKey!==void 0)return await a(t.stringKey);if(s&&t.index?.type==="ArithVariable"&&!t.index.hasDollarPrefix)return await a(t.index.name);if(s&&t.index?.type==="ArithVariable"&&t.index.hasDollarPrefix)return await a(await Ve(e,t.index.name));if(t.index){let o=await i(t.index);if(o<0){let c=Te(e,t.array),p=e.state.currentLine;if(c.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${p}: ${t.array}: bad array subscript `,0;let h=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+o;if(h<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${p}: ${t.array}: bad array subscript `,0;o=h}let l=`${t.array}[${o}]`,u=tt(e,t.array,o);if(u!==void 0)return ia(e,l,u,n);if(o===0){let c=e.state.env.get(t.array);if(c!==void 0)return ia(e,t.array,c,n)}if(e.state.options.nounset&&!(e.state.env.has(t.array)||Yr(e,t.array)))throw new hr(`${t.array}[${o}]`);return 0}return 0}case"ArithDoubleSubscript":throw new lt("double subscript","","");case"ArithNumberSubscript":throw new lt(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new lt(t.message,"","",!0);case"ArithSingleQuote":if(r)throw new lt(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value;case"ArithBinary":return t.operator==="||"?await i(t.left)||await i(t.right)?1:0:t.operator==="&&"?await i(t.left)&&await i(t.right)?1:0:O$(await i(t.left),await i(t.right),t.operator);case"ArithUnary":{let s=await i(t.operand);if(t.operator==="++"||t.operator==="--"){if(t.operand.type==="ArithVariable"){let a=t.operand.name,o=Number.parseInt(await Ve(e,a),10)||0,l=t.operator==="++"?o+1:o-1;return e.state.env.set(a,String(l)),t.prefix?l:o}if(t.operand.type==="ArithArrayElement"){let a=t.operand.array,o=e.state.associativeArrays?.has(a),l;if(t.operand.stringKey!==void 0)l=t.operand.stringKey;else if(o&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)l=t.operand.index.name;else if(o&&t.operand.index?.type==="ArithVariable"&&t.operand.index.hasDollarPrefix)l=await Ve(e,t.operand.index.name);else if(t.operand.index){let p=await i(t.operand.index);l=String(p)}else return s;let u=Number.parseInt(tt(e,a,l)||"0",10)||0,c=t.operator==="++"?u+1:u-1;return Ce(e,a,l,String(c),o?"associative":"indexed"),t.prefix?c:u}if(t.operand.type==="ArithConcat"){let a="";for(let o of t.operand.parts)a+=await Ci(e,o,r,n);if(a&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){let o=Number.parseInt(e.state.env.get(a)||"0",10)||0,l=t.operator==="++"?o+1:o-1;return e.state.env.set(a,String(l)),t.prefix?l:o}}if(t.operand.type==="ArithDynamicElement"){let a="";if(t.operand.nameExpr.type==="ArithConcat")for(let o of t.operand.nameExpr.parts)a+=await Ci(e,o,r,n);else t.operand.nameExpr.type==="ArithVariable"&&(a=t.operand.nameExpr.hasDollarPrefix?await Ve(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(a&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){let o=await i(t.operand.subscript),l=Number.parseInt(tt(e,a,o)||"0",10)||0,u=t.operator==="++"?l+1:l-1;return Ce(e,a,o,String(u)),t.prefix?u:l}}return s}return T$(s,t.operator)}case"ArithTernary":return await i(t.condition)?await i(t.consequent):await i(t.alternate);case"ArithAssignment":{let s=t.variable,a=s,o;if(t.stringKey!==void 0)o=t.stringKey;else if(t.subscript){let c=e.state.associativeArrays?.has(s);if(c&&t.subscript.type==="ArithVariable"&&!t.subscript.hasDollarPrefix)o=t.subscript.name;else if(c&&t.subscript.type==="ArithVariable"&&t.subscript.hasDollarPrefix)o=await Ve(e,t.subscript.name)||"\\";else if(c){let p=await i(t.subscript);o=String(p)}else{let p=await i(t.subscript);if(p<0){let h=Te(e,s);h.length>0&&(p=Math.max(...h.map(([f])=>typeof f=="number"?f:0))+1+p)}o=String(p)}}let l=o===void 0?e.state.env.get(a):tt(e,s,o),u=p0(Number.parseInt(l||"0",10)||0,await i(t.value),t.operator);return o===void 0?e.state.env.set(a,String(u)):Ce(e,s,o,String(u),e.state.associativeArrays?.has(s)?"associative":"indexed"),u}case"ArithGroup":return await i(t.expression);case"ArithConcat":{let s="";for(let a of t.parts)s+=await Ci(e,a,r,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?await sc(e,s,n):Number.parseInt(s,10)||0}case"ArithDynamicAssignment":{let s="";if(t.target.type==="ArithConcat")for(let l of t.target.parts)s+=await Ci(e,l,r,n);else t.target.type==="ArithVariable"&&(s=t.target.hasDollarPrefix?await Ve(e,t.target.name):t.target.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let a=s;if(t.subscript){let l=await i(t.subscript);a=`${s}_${l}`}let o=p0(Number.parseInt(e.state.env.get(a)||"0",10)||0,await i(t.value),t.operator);return e.state.env.set(a,String(o)),o}case"ArithDynamicElement":{let s="";if(t.nameExpr.type==="ArithConcat")for(let u of t.nameExpr.parts)s+=await Ci(e,u,r,n);else t.nameExpr.type==="ArithVariable"&&(s=t.nameExpr.hasDollarPrefix?await Ve(e,t.nameExpr.name):t.nameExpr.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let a=await i(t.subscript),o=`${s}_${a}`,l=e.state.env.get(o);return l===void 0?0:ia(e,o,l,n)}default:return 0}}async function Ci(e,t,r=!1,n=F3()){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await Mi(e,t,r,n));case"ArithVariable":return t.hasDollarPrefix?await Ve(e,t.name):t.name;case"ArithSpecialVar":return await Ve(e,t.name);case"ArithBracedExpansion":return await Aa(e,t.content);case"ArithCommandSubst":return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():"0";case"ArithConcat":{let i="";for(let s of t.parts)i+=await Ci(e,s,r,n);return i}default:return String(await Mi(e,t,r,n))}}wt(),H();async function P$(e,t){let r="",n=0;for(let w of t.parts){let E=w.type==="Literal"?w.value:"\0",A=q(E);if(A>e.limits.maxStringLength-n)throw new C(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");r+=E,n+=A}let i=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!i||!r.endsWith(")"))return null;let s=i[1],a=[],o=[],l=!1,u="",c=0,p=0,h=!1,f=!0,d=w=>{let E=q(w);if(E>e.limits.maxStringLength-p-c)throw new C(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");u+=w,c+=E},m=(w,E=!1)=>{if(a.length>=e.limits.maxArrayElements)throw new C(`array assignment element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");let A=q(w);if(A>e.limits.maxStringLength-p)throw new C(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");a.push(w),o.push(E),p+=A},g=()=>{m(u,f),u="",c=0,h=!1,f=!0};for(let w of t.parts)if(w.type==="Literal"){let E=w.value;if(!l){let A=E.indexOf("=(");A!==-1&&(l=!0,E=E.slice(A+2))}if(l){E.endsWith(")")&&(E=E.slice(0,-1));for(let A of E)/\s/.test(A)?(u||h)&&g():d(A)}}else if(l)if(w.type==="BraceExpansion")if(/^\[.+\]=/.test(u))d(Co({type:"Word",parts:[w]}));else{(u||h)&&g();let E=await li(e,{type:"Word",parts:[w]});for(let A of E.values)m(A)}else(w.type==="SingleQuoted"||w.type==="DoubleQuoted"||w.type==="Escaped")&&(h=!0),f=!1,d(await Qe(e,{type:"Word",parts:[w]}));(u||h)&&g();let v=a.splice(0),y=o.splice(0);p=0;for(let w=0;wN.type==="BraceExpansion")){let N=await li(e,O);for(let D of N.values)m(D);continue}}m(E)}let x=[`${s}=(`],b=q(x[0]);for(let w=0;w()]/.test(E)&&!E.startsWith("'")&&!E.startsWith('"')?`'${E.replace(/'/g,"'\\''")}'`:E;let O=`${w>0?" ":""}${A}`,N=q(O);if(N+1>e.limits.maxStringLength-b)throw new C(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");x.push(O),b+=N}return x.push(")"),x.join("")}async function D$(e,t){let r=-1,n=-1,i=!1;for(let d=0;d0?await Qe(e,h):"";return`${p}${i?"+=":"="}${f}`}var L$=["tar","yq","xan","sqlite3","python3","python"];function M$(e){return L$.includes(e)}se(),Mr(),vn(),Ar(),Us(),Wi(),H(),H();var rt=Object.freeze({stdout:"",stderr:"",exitCode:0,internalStdinConsumed:0});function We(e=""){return{stdout:e,stderr:"",exitCode:0}}function Z(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function Q(e,t,r){return{stdout:e,stderr:t,exitCode:r}}function Ot(e){return{stdout:"",stderr:"",exitCode:+!e,internalStdinConsumed:0}}function Zi(e,t,r="",n=""){throw new C(e,t,r,n)}function F$(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new C(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,"file_descriptors")}function _$(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ds;return rt}if(t.length>1)throw new ze(1,"",`bash: break: too many arguments `);let r=1;if(t.length>0){let n=Number.parseInt(t[0],10);if(Number.isNaN(n)||n<1)throw new ze(128,"",`bash: break: ${t[0]}: numeric argument required `);r=n}throw new fn(r)}async function z$(e,t){let r,n=!1,i=!1,s=0;for(;sh);for(let h of p){let f=h.startsWith("/")?`${h}/${r}`:`${e.state.cwd}/${h}/${r}`;try{if((await e.fs.stat(f)).isDirectory){r=f,n=!0;break}}catch{}}}}let o=(r.startsWith("/")?r:`${e.state.cwd}/${r}`).split("/").filter(c=>c&&c!=="."),l="";for(let c of o)if(c==="..")l=l.split("/").slice(0,-1).join("/")||"/";else{l=l?`${l}/${c}`:`/${c}`;try{if(!(await e.fs.stat(l)).isDirectory)return Z(`bash: cd: ${r}: Not a directory `)}catch{return Z(`bash: cd: ${r}: No such file or directory `)}}let u=l||"/";if(i)try{u=await e.fs.realpath(u)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=u,e.state.env.set("PWD",e.state.cwd),e.state.env.set("OLDPWD",e.state.previousDir),We(n?`${u} `:"")}Et(),se(),at(),H();function ac(e,t){return e.fs.resolvePath(e.state.cwd,t)}var B$=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function p1(e){return B$.includes(e)}async function h1(e,t,r){let n=ac(e,r);switch(t){case"-e":case"-a":return e.fs.exists(n);case"-f":return await e.fs.exists(n)?(await e.fs.stat(n)).isFile:!1;case"-d":return await e.fs.exists(n)?(await e.fs.stat(n)).isDirectory:!1;case"-r":return await e.fs.exists(n)?!!((await e.fs.stat(n)).mode&256):!1;case"-w":return await e.fs.exists(n)?!!((await e.fs.stat(n)).mode&128):!1;case"-x":return await e.fs.exists(n)?!!((await e.fs.stat(n)).mode&64):!1;case"-s":return await e.fs.exists(n)?(await e.fs.stat(n)).size>0:!1;case"-L":case"-h":try{return(await e.fs.lstat(n)).isSymbolicLink}catch{return!1}case"-k":return await e.fs.exists(n)?!!((await e.fs.stat(n)).mode&512):!1;case"-g":return await e.fs.exists(n)?!!((await e.fs.stat(n)).mode&1024):!1;case"-u":return await e.fs.exists(n)?!!((await e.fs.stat(n)).mode&2048):!1;case"-G":case"-O":return e.fs.exists(n);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].includes(n);case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return e.fs.exists(n);default:return!1}}var U$=["-nt","-ot","-ef"];function f1(e){return U$.includes(e)}async function d1(e,t,r,n){let i=ac(e,r),s=ac(e,n);switch(t){case"-nt":{let[a,o]=await Promise.all([e.fs.stat(i).catch(()=>null),e.fs.stat(s).catch(()=>null)]);return a!==null&&(o===null||a.mtime>o.mtime)}case"-ot":{let[a,o]=await Promise.all([e.fs.stat(i).catch(()=>null),e.fs.stat(s).catch(()=>null)]);return o!==null&&(a===null||a.mtimer;case"-ge":return t>=r}}function ro(e){return e==="="||e==="=="||e==="!="}function y1(e,t,r,n=!1,i=!1,s=!1,a=256){if(n){let l=w1(t,r,i,s,a);return e==="!="?!l:l}if(i){let l=t.toLowerCase()===r.toLowerCase();return e==="!="?!l:l}let o=t===r;return e==="!="?!o:o}var j$=new Set(["-z","-n"]);function x1(e){return j$.has(e)}function v1(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}async function b1(e,t){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let n=r[1],i=r[2];if(e.state.associativeArrays?.has(n)){let a=i;return(a.startsWith("'")&&a.endsWith("'")||a.startsWith('"')&&a.endsWith('"'))&&(a=a.slice(1,-1)),a=a.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(o,l)=>e.state.env.get(l)||""),$i(e,n,a)}let s;try{s=await qe(e,ct(new Be,i).expression)}catch{if(/^-?\d+$/.test(i))s=Number.parseInt(i,10);else{let a=e.state.env.get(i);s=a?Number.parseInt(a,10):0}}if(s<0){let a=Qt(e,n),o=e.state.currentLine;if(a.length===0||(s=Math.max(...a)+1+s,s<0))return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${o}: ${n}: bad array subscript `,!1}return $i(e,n,s)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?Gi(e,t).length>0:Qt(e,t).length>0}async function Hn(e,t){switch(t.type){case"CondBinary":{let r=await Qe(e,t.left),n=t.right.parts.length>0&&t.right.parts.every(s=>s.type==="SingleQuoted"||s.type==="DoubleQuoted"||s.type==="Escaped"&&t.operator!=="=~"),i;if(i=t.operator==="=~"?n?rc(await Qe(e,t.right)):await A$(e,t.right):ro(t.operator)&&!n?await C$(e,t.right):await Qe(e,t.right),ro(t.operator)){let s=e.state.shoptOptions.nocasematch;return y1(t.operator,r,i,!n,s,!0,e.limits.maxCallDepth)}if(m1(t.operator))return g1(t.operator,await f0(e,r),await f0(e,i));if(f1(t.operator))return d1(e,t.operator,r,i);switch(t.operator){case"=~":try{let s=e.state.shoptOptions.nocasematch,a=de(Z$(i),s?"i":"").match(r);if(ar(e,"BASH_REMATCH"),a)for(let o=0;o":return r>i;default:return!1}}case"CondUnary":{let r=await Qe(e,t.operand);return p1(t.operator)?h1(e,t.operator,r):x1(t.operator)?v1(t.operator,r):t.operator==="-v"?await b1(e,r):t.operator==="-o"&&E1(e,r)}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await Qe(e,t.operand.expression.word)})`!="":!await Hn(e,t.operand);case"CondAnd":return await Hn(e,t.left)?await Hn(e,t.right):!1;case"CondOr":return await Hn(e,t.left)?!0:await Hn(e,t.right);case"CondGroup":return await Hn(e,t.expression);case"CondWord":return await Qe(e,t.word)!=="";default:return!1}}async function Ca(e,t){if(t.length===0)return Q("","",1);if(t.length===1)return Ot(!!t[0]);if(t.length===2){let n=t[0],i=t[1];return n==="("?Z(`test: '(' without matching ')' `,2):p1(n)?Ot(await h1(e,n,i)):x1(n)?Ot(v1(n,i)):n==="!"?Ot(!i):n==="-v"?Ot(await b1(e,i)):n==="-o"?Ot(E1(e,i)):n==="="||n==="=="||n==="!="||n==="<"||n===">"||n==="-eq"||n==="-ne"||n==="-lt"||n==="-le"||n==="-gt"||n==="-ge"||n==="-nt"||n==="-ot"||n==="-ef"?Z(`test: ${n}: unary operator expected `,2):Q("","",1)}if(t.length===3){let n=t[0],i=t[1],s=t[2];if(ro(i))return Ot(y1(i,n,s));if(m1(i)){let a=no(n),o=no(s);return!a.valid||!o.valid?Q("","",2):Ot(g1(i,a.value,o.value))}if(f1(i))return Ot(await d1(e,i,n,s));switch(i){case"-a":return Ot(n!==""&&s!=="");case"-o":return Ot(n!==""||s!=="");case">":return Ot(n>s);case"<":return Ot(n0&&"@*+?!".includes(e[i-1]);if(n.push(s),s&&r++,r>t)throw new C(`extglob maximum depth (${t}) exceeded`,"recursion")}else e[i]===")"&&n.length>0&&n.pop()&&r--}}function z3(e,t){let r="";for(let n=0;nz3(u,t)),l=o.length>0?o.join("|"):"(?:)";if(i==="@")r+=`(?:${l})`;else if(i==="*")r+=`(?:${l})*`;else if(i==="+")r+=`(?:${l})+`;else if(i==="?")r+=`(?:${l})?`;else if(i==="!")if(sW3(c,t));if(u.every(c=>c!==null)&&u.every(c=>c===u[0])&&u[0]!==null){let c=u[0];if(c===0)r+="(?:.+)";else{let p=[];c>0&&p.push(`.{0,${c-1}}`),p.push(`.{${c+1},}`),p.push(`(?!(?:${l})).{${c}}`),r+=`(?:${p.join("|")})`}}else r+=`(?:(?!(?:${l})).)*?`}else r+=`(?!(?:${l})$).*`;n=s;continue}}if(i==="\\")if(n+10;){let i=e[n];if(i==="\\"){n+=2;continue}if(i==="(")r++;else if(i===")"&&(r--,r===0))return n;n++}return-1}function U3(e){let t=[],r="",n=0,i=0;for(;iW3(o,t));if(a.every(o=>o!==null)&&a.every(o=>o===a[0])){r+=a[0],n=s+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){r+=1,n++;continue}if(i==="["){let s=e.indexOf("]",n+1);if(s!==-1){r+=1,n=s+1;continue}r+=1,n++;continue}if(i==="\\"){r+=1,n+=2;continue}r+=1,n++}return r}function E1(e,t){let r=new Map([["errexit",()=>e.state.options.errexit===!0],["nounset",()=>e.state.options.nounset===!0],["pipefail",()=>e.state.options.pipefail===!0],["xtrace",()=>e.state.options.xtrace===!0],["e",()=>e.state.options.errexit===!0],["u",()=>e.state.options.nounset===!0],["x",()=>e.state.options.xtrace===!0]]).get(t);return r?r():!1}async function f0(e,t){if(t=t.trim(),t==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return d0(t);try{return await qe(e,ct(new Be,t).expression)}catch{return d0(t)}}function V$(e,t){let r=0;for(let n of e){let i;if(n>="0"&&n<="9")i=n.charCodeAt(0)-48;else if(n>="a"&&n<="z")i=n.charCodeAt(0)-97+10;else if(n>="A"&&n<="Z")i=n.charCodeAt(0)-65+36;else if(n==="@")i=62;else if(n==="_")i=63;else return NaN;if(i>=t)return NaN;r=r*t+i}return r}function d0(e){if(e=e.trim(),e==="")return 0;let t=!1;e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1));let r,n=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(n){let i=Number.parseInt(n[1],10);r=i>=2&&i<=64?V$(n[2],i):0}else r=/^0[xX][0-9a-fA-F]+$/.test(e)?Number.parseInt(e,16):/^0[0-7]+$/.test(e)?Number.parseInt(e,8):Number.parseInt(e,10);return Number.isNaN(r)&&(r=0),t?-r:r}function no(e){if(e=e.trim(),e==="")return{value:0,valid:!0};let t=!1;if(e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let r=Number.parseInt(e,10);return Number.isNaN(r)?{value:0,valid:!1}:{value:t?-r:r,valid:!0}}function Z$(e){let t="",r=0;for(;r=r.maxElements)throw new C(`array element limit exceeded (${r.maxElements})`,"array_elements");e.push(t)}function Fi(e,t){if(t&&q(e)>t.maxStringBytes)throw new C(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,"string_length");let r=[],n="",i=!1,s=!1,a=!1,o=!1;for(let l of e){if(a){n+=l,a=!1,o=!0;continue}if(l==="\\"){a=!0;continue}if(l==="'"&&!s){i||(o=!0),i=!i;continue}if(l==='"'&&!i){s||(o=!0),s=!s;continue}if((l===" "||l===" "||l===` `)&&!i&&!s){o&&=(lc(r,n,t),n="",!1);continue}n+=l,o=!0}return o&&lc(r,n,t),r}function uc(e,t){if(t&&q(e)>t.maxStringBytes)throw new C(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,"string_length");let r=[],n=0;for(;n=e.length)break;if(e[n]!=="["){n++;continue}n++;let i="";if(e[n]==="'"||e[n]==='"'){let a=e[n];for(n++;n0&&n[n.length-1].scopeIndex===t;)n.pop();n.length===0&&e.state.localVarStack.delete(r)}}H();var j3=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function rO(e){return j3.has(e)}var q3=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),To=new Set(":,true,false,cd,export,unset,exit,local,set,break,continue,return,eval,shift,getopts,compgen,complete,compopt,pushd,popd,dirs,source,.,read,mapfile,readarray,declare,typeset,readonly,let,command,shopt,exec,test,[,echo,printf,pwd,alias,unalias,type,hash,ulimit,umask,trap,times,wait,kill,jobs,fg,bg,disown,suspend,fc,history,help,enable,builtin,caller".split(","));se(),H();var pc="__file__:",hc="__file_append__:",S1="__rw__:",fc="__dupout__:",dc="__dupin__:",kt=3;function nO(e){let t=e.slice(S1.length),r=t.indexOf(":");if(r===-1)return null;let n=Number.parseInt(t.slice(0,r),10);if(Number.isNaN(n)||n<0)return null;let i=r+1,s=t.slice(i,i+n),a=t.slice(i+n+1),o=a.indexOf(":");if(o===-1)return null;let l=Number.parseInt(a.slice(0,o),10);return Number.isNaN(l)||l<0?null:{path:s,position:l,content:a.slice(o+1)}}function g0(e,t){let r=Number.parseInt(e.slice(t.length),10);return Number.isNaN(r)?null:r}function iO(e){if(e.startsWith(pc))return{kind:"output",path:e.slice(pc.length),append:!1};if(e.startsWith(hc))return{kind:"output",path:e.slice(hc.length),append:!0};if(e.startsWith(S1)){let t=nO(e);if(t)return{kind:"readwrite",...t}}if(e.startsWith(fc)){let t=g0(e,fc);if(t!==null)return{kind:"dup-out",sourceFd:t}}if(e.startsWith(dc)){let t=g0(e,dc);if(t!==null)return{kind:"dup-in",sourceFd:t}}return{kind:"input",content:e}}function A1(e){switch(e.kind){case"input":return e.content;case"output":return`${e.append?hc:pc}${e.path}`;case"readwrite":return`${S1}${e.path.length}:${e.path}:${e.position}:${e.content}`;case"dup-out":return`${fc}${e.sourceFd}`;case"dup-in":return`${dc}${e.sourceFd}`;case"closed":throw Error("Closed descriptors have no table encoding")}}function sO(e){return e.state.fileDescriptors??=new Map,e.state.fileDescriptors}function aO(e,t,r){r?(e.state.inputFds??=new Set,e.state.inputFds.add(t)):e.state.inputFds?.delete(t)}function Qi(e,t){return e.state.fdAliases?.get(t)}function Ri(e,t){return[...Qi(e,t)??[t]]}function G3(e,t){let r=Qi(e,t);if(r&&(r.delete(t),e.state.fdAliases?.delete(t),r.size<2))for(let n of r)e.state.fdAliases?.delete(n)}function C1(e,t,r){if(t===r)return;e.state.fdAliases??=new Map;let n=Qi(e,r)??new Set([r]);n.add(t);for(let i of n)e.state.fdAliases.set(i,n)}function Io(e,t){return e.state.fileDescriptors?.get(t)}function en(e,t){let r=Io(e,t);if(r!==void 0)return e.state.inputFds?.has(t)?{kind:"input",content:r}:iO(r)}function _i(e,t){return e.state.fileDescriptors?.has(t)===!0}function k1(e,t,r,n){let i=sO(e);i.has(t)||F$(e),i.set(t,r),aO(e,t,n)}function Ro(e,t,r,n=!1){G3(e,t),k1(e,t,r,n)}function $r(e,t,r){Ro(e,t,A1(r),r.kind==="input")}function un(e,t){e.state.fileDescriptors?.delete(t),e.state.inputFds?.delete(t),G3(e,t)}function Hl(e,t,r){let n=Io(e,r);return n!==void 0&&(Ro(e,t,n,e.state.inputFds?.has(r)===!0),C1(e,t,r),!0)}function y0(e,t,r){let n=Io(e,r);if(n===void 0)return!1;if(t===r)return!0;let i=e.state.inputFds?.has(r)===!0,s=[...Qi(e,r)??[]].filter(o=>o!==r);un(e,r),Ro(e,t,n,i);let a=s.find(o=>_i(e,o));return a!==void 0&&C1(e,t,a),!0}function H3(e,t){let r=en(e,t);if(r===void 0)return{error:"not-open"};switch(r.kind){case"input":return{content:r.content};case"readwrite":return{content:r.content.slice(r.position)};case"output":case"dup-out":return{error:"write-only"};case"dup-in":return{error:"not-open"};case"closed":return{error:"not-open"}}}function bs(e,t,r){let n=en(e,t);if(n===void 0)return;let i;if(n.kind==="input")i={kind:"input",content:n.content.slice(r)};else if(n.kind==="readwrite")i={...n,position:n.position+r};else return;let s=A1(i),a=i.kind==="input";for(let o of Qi(e,t)??[t])k1(e,o,s,a)}async function x0(e,t,r,n,i){if(t.kind==="output")return await e.fs.appendFile(t.path,n,i),!0;let s=r.map(u=>en(e,u)).find(u=>u?.kind==="readwrite")??t;if(s.kind!=="readwrite")return!1;let a=s.content.slice(0,s.position)+n+s.content.slice(s.position+n.length),o={...s,position:s.position+n.length,content:a};await e.fs.writeFile(s.path,a,i);let l=A1(o);for(let u of r)_i(e,u)&&k1(e,u,l,!1);return!0}function zn(e,t,r){if(t.has(r))return;let n=Qi(e,r);t.set(r,{raw:Io(e,r),isInput:e.state.inputFds?.has(r)===!0,aliases:n?[...n].filter(i=>i!==r):[]})}function Vl(e,t){let r=e.state.fileDescriptors;if(r)for(let[n,{raw:i,isInput:s,aliases:a}]of t){if(i===void 0){un(e,n);continue}Ro(e,n,i,s);let o=a.find(l=>r.has(l));o!==void 0&&C1(e,n,o)}}function V3(e){switch(e.operator){case"<":case"<>":case"<<":case"<<-":case"<<<":case"<&":return e.fd??0;case">":case">>":case">|":case">&":return e.fd??1;default:return null}}function oO(e){if(e.fdVariable)return!1;let t=V3(e);return t!==null&&t>=kt}async function lO(e,t,r,n){try{if(!await e.fs.exists(t))return null;if((await e.fs.stat(t)).isDirectory)return`bash: ${r}: Is a directory `;if(n.checkNoclobber&&e.state.options.noclobber&&!n.isClobber&&r!=="/dev/null")return`bash: ${r}: cannot overwrite existing file `}catch{return`bash: ${r}: cannot open redirect target `}return null}function v0(e){let t=Math.min(e.length,8192);for(let r=0;r127)return"utf8";return"binary"}var N1="scoped",uO="bare",cO="persistent",pO=e=>new C(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,"file_descriptors"),hO=(e,t)=>_i(e,t)||(e.state.fileDescriptors?.size??0){let t=Math.max(e.state.nextFd??10,10);for(;_i(e,t);)t+=1;return t},ka=e=>{let t=e.endsWith("-"),r=t?e.slice(0,-1):e;return/^\d+$/.test(r)?{sourceFd:Number.parseInt(r,10),move:t}:null},fO=(e,t,r)=>{let n=en(e,t);return t{let r=await Qe(e,t.content);return t.stripTabs?r.split(` `).map(n=>n.replace(/^\t+/,"")).join(` `):r};async function mO(e,t,r,n){let i=new Map,s=new Map,a=(y,x)=>e.state.closedStandardFds?.has(y)?{kind:"closed"}:en(e,y)??x,o=new Map([[0,a(0,{kind:"dup-in",sourceFd:0})],[1,a(1,{kind:"dup-out",sourceFd:1})],[2,a(2,{kind:"dup-out",sourceFd:2})]]),l=n.numericSnapshot,u,c=-1,p=o.get(0);p?.kind==="input"?(u=p.content,c=0):p?.kind==="readwrite"&&(u=p.content.slice(p.position),c=0);let h=()=>({targets:i,dupSources:s,standardRoutes:o,stdin:u,stdinSourceFd:c,error:null}),f=async(y,x,b)=>{let w={...h(),error:await zi(e,y,t.slice(0,x),i,s,o)};return b?{...w,errorCause:b}:w},d=async(y,x)=>{if(hO(e,y))return null;let b=pO(e);return f(Q("",b.stderr,C.EXIT_CODE),x,b)},m=(y,x)=>{y!==null&&y{o.set(y,x),zn(e,n.standardSnapshot,y),n.standardClosedSnapshot.has(y)||n.standardClosedSnapshot.set(y,e.state.closedStandardFds?.has(y)===!0),e.state.closedStandardFds?.delete(y),$r(e,y,x)},v=(y,x)=>{if(y=kt){let O=await d(b,y);if(O)return O;zn(e,l,b),$r(e,b,{kind:"input",content:A})}else if(b===0||b===null)u=ti(A),c=-1,m(b,{kind:"input",content:u});else{let O={kind:"input",content:A};n.policy==="persistent"?m(b,O):g(b,O)}continue}let w,E=x.operator===">&"||x.operator==="<&";if(E){if(M3(e,x.target))return f(Q("",`bash: $@: ambiguous redirect `,1),y);w=await Qe(e,x.target)}else if(x.operator==="<<<")w=await Qe(e,x.target);else{let A=await $$(e,x.target);if("error"in A)return f(Q("",A.error,1),y);w=A.target}if(i.set(y,w),w.includes("\0"))return f(Q("",`bash: ${w.replace(/\0/g,"")}: No such file or directory `,1),y);if(x.fdVariable){try{ft(e,x.fdVariable)}catch($){if(!($ instanceof ze))throw $;return f(Q($.stdout,$.stderr,$.exitCode),y,$)}if(E&&w==="-"){let $=Number.parseInt(e.state.env.get(x.fdVariable)??"",10);Number.isNaN($)||(zn(e,n.fdVariableSnapshot,$),un(e,$));continue}let A=b0(e),O=E?ka(w):null;if(O&&!v(O.sourceFd,x.operator==="<&"))return f(Q("",`bash: ${O.sourceFd}: Bad file descriptor `,1),y);if(!(O?.move===!0&&O.sourceFd>=kt)){let $=await d(A,y);if($)return $}zn(e,n.fdVariableSnapshot,A),n.fdVariableEnv.has(x.fdVariable)||n.fdVariableEnv.set(x.fdVariable,e.state.env.get(x.fdVariable));let N,D;if(E){let $=O;if($){let L=v($.sourceFd,x.operator==="<&");if(!L)return f(Q("",`bash: ${$.sourceFd}: Bad file descriptor `,1),y);D=$,L.kind==="standard"?N={kind:x.operator==="<&"?"dup-in":"dup-out",sourceFd:L.fd}:$.sourceFd"||x.operator===">|"||x.operator===">>"||x.operator==="&>"||x.operator==="&>>"){let $=x.operator===">>"||x.operator==="&>>",L=await yi(e,w,$,x.operator===">|");if(L.error)return f(L.error,y);N=L.entry}else if(x.operator==="<<<")N={kind:"input",content:`${w} `};else if(x.operator==="<"||x.operator==="<>"){let $=await Zl(e,w,x.operator==="<>");if($.error)return f($.error,y);N=$.entry}if(D&&D.sourceFd>=kt){if(!(D.move?y0(e,A,D.sourceFd):Hl(e,A,D.sourceFd)))return f(Q("",`bash: ${D.sourceFd}: Bad file descriptor `,1),y)}else N&&$r(e,A,N);D?.move&&D.sourceFd!==A&&D.sourceFd=kt)){let N=await d(A,y);if(N)return N}if(zn(e,l,A),E){let N=O;if(!N){if(x.operator==="<&")return f(Q("",`bash: ${w}: ambiguous redirect `,1),y);let $=await yi(e,w,!1,!1);if($.error)return f($.error,y);$r(e,A,$.entry);continue}let D=v(N.sourceFd,x.operator==="<&");if(!D)return f(Q("",`bash: ${N.sourceFd}: Bad file descriptor `,1),y);if(D.kind==="standard")$r(e,A,{kind:x.operator==="<&"?"dup-in":"dup-out",sourceFd:D.fd});else if(N.sourceFd"||x.operator===">|"||x.operator===">>"){let N=await yi(e,w,x.operator===">>",x.operator===">|");if(N.error)return f(N.error,y);$r(e,A,N.entry)}else if(x.operator==="<<<")$r(e,A,{kind:"input",content:`${w} `});else if(x.operator==="<"||x.operator==="<>"){let N=await Zl(e,w,x.operator==="<>");if(N.error)return f(N.error,y);$r(e,A,N.entry)}continue}if(E){if(w==="-"){b===0&&(u="",c=-1),b!==null&&b=kt){if(!Hl(e,b,A.sourceFd))return f(Q("",`bash: ${A.sourceFd}: Bad file descriptor `,1),y);o.set(b,en(e,b)),e.state.closedStandardFds?.delete(b)}else O.kind==="standard"?m(b,{kind:x.operator==="<&"?"dup-in":"dup-out",sourceFd:O.fd}):m(b,O.entry);if(x.operator==="<&"&&b===0)if(O.kind==="standard")u=O.fd===0?r:"",c=-1;else if(O.entry.kind==="input"||O.entry.kind==="readwrite"){let N=A.sourceFd=kt?un(e,A.sourceFd):(o.set(A.sourceFd,{kind:"closed"}),n.policy==="persistent"&&(un(e,A.sourceFd),e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(A.sourceFd))));continue}if(x.operator===">"||x.operator===">|"||x.operator===">>"||x.operator==="&>"||x.operator==="&>>"){let A=await yi(e,w,x.operator===">>"||x.operator==="&>>",x.operator===">|",!1);if(A.error)return f(A.error,y);let O=A.entry;x.operator==="&>"||x.operator==="&>>"?(m(1,O),m(2,O)):m(b,O);continue}if(x.operator==="<<<")u=ti(`${w} `),c=-1,m(b,{kind:"input",content:u});else if(x.operator==="<"){let A=e.fs.resolvePath(e.state.cwd,w);try{u=await xn(e.fs,A),c=-1,m(b,{kind:"input",content:u})}catch{return f(Q("",`bash: ${w}: No such file or directory `,1),y)}}else if(x.operator==="<>"){let A=await Zl(e,w,!0);if(A.error)return f(A.error,y);let O=A.entry;m(b,O),b===0&&O.kind==="readwrite"&&(u=O.content,c=-1)}}return h()}function io(e,t,r){let n={numericSnapshot:new Map,fdVariableSnapshot:new Map,standardSnapshot:new Map,standardClosedSnapshot:new Map,fdVariableEnv:new Map,nextFd:e.state.nextFd,policy:r},i=!1;return{prepare:(s="")=>mO(e,t,s,n),finish:()=>{if(!i){if(i=!0,r!=="persistent"&&Vl(e,n.numericSnapshot),r!=="persistent"){Vl(e,n.standardSnapshot);for(let[s,a]of n.standardClosedSnapshot)a?(e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(s)):e.state.closedStandardFds?.delete(s)}if(r==="bare"){Vl(e,n.fdVariableSnapshot);for(let[s,a]of n.fdVariableEnv)a===void 0?e.state.env.delete(s):e.state.env.set(s,a);e.state.nextFd=n.nextFd}}}}}function so(e){if(!e.error)throw Error("Expected a redirection error");if(e.errorCause)throw e.errorCause.stdout=e.error.stdout,e.errorCause.stderr=e.error.stderr,e.errorCause;return e.error}async function Z3(e,t,r,n){let i=t instanceof ze||t instanceof rn||t instanceof mn?t.exitCode:t instanceof C?C.EXIT_CODE:0,s=await zi(e,Q(t.stdout,t.stderr,i),r,n.targets,n.dupSources,n.standardRoutes);t.stdout=s.stdout,t.stderr=s.stderr,t.internalOutputAccounting=s.internalOutputAccounting??{stdout:q(s.stdout),stderr:q(s.stderr)}}async function tn(e,t,r,n){let i=io(e,t,N1),s;try{if(s=await i.prepare(r),s.error)return so(s);let a=e.state.groupStdin,o=e.state.groupStdinSourceFd;s.stdin!==void 0&&(e.state.groupStdin=s.stdin,e.state.groupStdinSourceFd=s.stdinSourceFd);try{return await zi(e,await n(s),t,s.targets,s.dupSources,s.standardRoutes)}finally{s.stdin!==void 0&&(e.state.groupStdin=a,e.state.groupStdinSourceFd=o)}}catch(a){throw!(a instanceof Nt)||!s||await Z3(e,a,t,s),a}finally{i.finish()}}async function zi(e,t,r,n,i=new Map,s=new Map,a="bash",o=!1){r.length>0&&(t=e.executionScope.accountResult(t,"redirection"));let{stdout:l,stderr:u,exitCode:c}=t,p=t.stdoutKind==="bytes"||t.stdoutKind===void 0&&t.stdoutEncoding==="binary"?"binary":"utf8",h=y=>p,f={kind:"live-stdout"},d={kind:"live-stderr"},m=y=>{if(!y)return null;if(y.kind==="entry"){if(y.entry.kind==="dup-out"){if(y.entry.sourceFd===1)return{kind:"live-stdout"};if(y.entry.sourceFd===2)return{kind:"live-stderr"}}return y.entry.kind==="output"||y.entry.kind==="readwrite"?{kind:"descriptor",source:y}:null}return y.fd===1?f:y.fd===2?d:null},g=y=>{let x=s.get(y)??en(e,y);return x?x.kind==="closed"||x.kind==="input"||x.kind==="dup-in"?{kind:"invalid-output",fd:y}:x.kind==="dup-out"?x.sourceFd===1?{kind:"live-stdout"}:x.sourceFd===2?{kind:"live-stderr"}:null:x.kind==="output"||x.kind==="readwrite"?{kind:"descriptor",source:{kind:"entry",entry:x,descriptors:Ri(e,y)}}:null:null};f=g(1)??f,d=g(2)??d;for(let y=0;y":case">|":case">>":{let w=x.fd??1;if(w!==1&&w!==2)break;let E=x.operator===">>";if(b==="/dev/stdout"){w===2&&(d=f);break}if(b==="/dev/stderr"){w===1&&(f=d);break}if(b==="/dev/full"){u+=`bash: echo: write error: No space left on device `,c=1,w===1&&(l="");break}if(b==="/dev/null"&&w===2){d={kind:"discard"};break}let A=e.fs.resolvePath(e.state.cwd,b);w===1?f={kind:"file",path:A,append:E}:d={kind:"file",path:A,append:E};break}case">&":case"<&":{let w=x.fd??(x.operator==="<&"?0:1);if(w>=kt||w===0)break;if(b==="-"){w===1?f={kind:"discard"}:d={kind:"discard"};break}let E=m(i.get(y));if(!E)break;x.fd==null&&ka(b)===null?(f=E,d=E):w===1?f=E:w===2&&(d=E);break}case"&>":f={kind:"file",path:e.fs.resolvePath(e.state.cwd,b),append:!1},d=f;break;case"&>>":f={kind:"file",path:e.fs.resolvePath(e.state.cwd,b),append:!0},d=f}}if(l!==""||u!==""){let y=l,x=u;l="",u="",f.kind==="invalid-output"&&y!==""&&(y="",x+=`${o?"":"bash: "}${a}: write error: Bad file descriptor `,c=1),d.kind==="invalid-output"&&(x="");let b=async(w,E,A)=>{w.append?await e.fs.appendFile(w.path,E,A):await e.fs.writeFile(w.path,E,A)};if(f===d&&(f.kind==="file"||f.kind==="descriptor")){let w=y+x;w!==""&&(f.kind==="file"?await b(f,w,h(w)):await x0(e,f.source.entry,f.source.descriptors,w,h(w)))}else for(let[w,E,A]of[[y,f,!0],[x,d,!1]])if(w!=="")switch(E.kind){case"live-stdout":l+=w;break;case"live-stderr":u+=w;break;case"file":await b(E,w,A?h(w):v0(w));break;case"descriptor":await x0(e,E.source.entry,E.source.descriptors,w,A?h(w):v0(w))}}let v=Q(l,u,c);if(t.stdoutKind&&(v.stdoutKind=t.stdoutKind),t.stdoutEncoding==="binary"&&(v.stdoutEncoding="binary"),t.internalPipeStatusOverride&&(v.internalPipeStatusOverride=t.internalPipeStatusOverride),r.length>0||e.state.fileDescriptors?.has(1)===!0||e.state.fileDescriptors?.has(2)===!0){let y=(t.internalOutputAccounting?.stdout??0)+(t.internalOutputAccounting?.stderr??0),x=q(v.stdout),b=q(v.stderr),w=Math.min(x,y);v.internalOutputAccounting={stdout:w,stderr:Math.min(b,y-w)},e.executionScope.accountResult(v,"redirection")}else t.internalOutputAccounting&&(v.internalOutputAccounting=t.internalOutputAccounting);return v}function gO(e,t){if(e.state.options.posix&&j3.has(t.name)){let n=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin `;throw new ze(2,"",n)}let r={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,r),rt}async function Q3(e,t,r,n="",i,s=!1){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,Zi(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(i??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??"main"),e.state.localScopes.push(new Map),e.state.localArrayScopes??=[],e.state.localArrayScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let a=new Map,o=Number.parseInt(e.state.env.get("#")??"0",10),l=Math.max(r.length,o);for(let f=0;f{if(u)return;u=!0;let f=e.state.localScopes.length-1,d=e.state.localScopes.pop(),m=e.state.localArrayScopes?.pop();if(d)for(let[g,v]of d)v===void 0?e.state.env.delete(g):e.state.env.set(g,v);if(m){e.state.arrays??=new Map;for(let[g,v]of m)v===void 0?(e.state.arrays.delete(g),e.state.associativeArrays?.delete(g)):(e.state.arrays.set(g,gn(v)),e.state.associativeArrays??=new Set,v.kind==="associative"?e.state.associativeArrays.add(g):e.state.associativeArrays.delete(g))}if(tO(e,f),e.state.fullyUnsetLocals)for(let[g,v]of e.state.fullyUnsetLocals.entries())v===f&&e.state.fullyUnsetLocals.delete(g);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let g=e.state.localExportedVars.pop();if(g)for(let v of g)e.state.exportedVars?.delete(v)}for(let[g,v]of a)v===void 0?e.state.env.delete(g):e.state.env.set(g,v);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},p=null,h=io(e,t.redirections,N1);try{if(p=await h.prepare(n),p.error)return so(p);let f=p.stdin??n,d=s||p.stdin!==void 0||n!=="";return zi(e,await e.executeCommand(t.body,f,d),t.redirections,p.targets,p.dupSources,p.standardRoutes)}catch(f){if(f instanceof Nt&&p&&(await Z3(e,f,t.redirections,p),f instanceof rn))return Q(f.stdout,f.stderr,f.exitCode);throw f}finally{h.finish(),c()}}var K3=e=>e.type==="Escaped"?J.literal(`\\${e.value}`):e.type==="DoubleQuoted"?{...e,parts:e.parts.map(K3)}:e,X3=["!","[[","]]","case","do","done","elif","else","esac","fi","for","function","if","in","then","time","until","while","{","}"],$1=".,:,[,alias,bg,bind,break,builtin,caller,cd,command,compgen,complete,compopt,continue,declare,dirs,disown,echo,enable,eval,exec,exit,export,false,fc,fg,getopts,hash,help,history,jobs,kill,let,local,logout,mapfile,popd,printf,pushd,pwd,read,readarray,readonly,return,set,shift,shopt,source,suspend,test,times,trap,true,type,typeset,ulimit,umask,unalias,unset,wait".split(","),yO="autocd.assoc_expand_once.cdable_vars.cdspell.checkhash.checkjobs.checkwinsize.cmdhist.compat31.compat32.compat40.compat41.compat42.compat43.compat44.complete_fullquote.direxpand.dirspell.dotglob.execfail.expand_aliases.extdebug.extglob.extquote.failglob.force_fignore.globasciiranges.globstar.gnu_errfmt.histappend.histreedit.histverify.hostcomplete.huponexit.inherit_errexit.interactive_comments.lastpipe.lithist.localvar_inherit.localvar_unset.login_shell.mailwarn.no_empty_cmd_completion.nocaseglob.nocasematch.nullglob.progcomp.progcomp_alias.promptvars.restricted_shell.shift_verbose.sourcepath.xpg_echo".split("."),xO=$1;async function vO(e,t){let r=[],n=null,i="",s="",a=null,o=!1,l=!1,u=!1,c=null,p=null,h=null,f=[],d=["alias","arrayvar","binding","builtin","command","directory","disabled","enabled","export","file","function","group","helptopic","hostname","job","keyword","running","service","setopt","shopt","signal","stopped","user","variable"];for(let E=0;E=t.length)return Z(`compgen: -A: option requires an argument `,2);let O=t[E];if(!d.includes(O))return Z(`compgen: ${O}: invalid action name `,2);r.push(O)}else if(A==="-W"){if(E++,E>=t.length)return Z(`compgen: -W: option requires an argument `,2);n=t[E]}else if(A==="-P"){if(E++,E>=t.length)return Z(`compgen: -P: option requires an argument `,2);i=t[E]}else if(A==="-S"){if(E++,E>=t.length)return Z(`compgen: -S: option requires an argument `,2);s=t[E]}else if(A==="-o"){if(E++,E>=t.length)return Z(`compgen: -o: option requires an argument `,2);let O=t[E];if(O==="plusdirs")o=!0;else if(O==="dirnames")l=!0;else if(O==="default")u=!0;else if(O!=="filenames"&&O!=="nospace"&&O!=="bashdefault"&&O!=="noquote")return Z(`compgen: ${O}: invalid option name `,2)}else if(A==="-F"){if(E++,E>=t.length)return Z(`compgen: -F: option requires an argument `,2);p=t[E]}else if(A==="-C"){if(E++,E>=t.length)return Z(`compgen: -C: option requires an argument `,2);h=t[E]}else if(A==="-X"){if(E++,E>=t.length)return Z(`compgen: -X: option requires an argument `,2);c=t[E]}else if(A==="-G"){if(E++,E>=t.length)return Z(`compgen: -G: option requires an argument `,2)}else if(A==="--"){f.push(...t.slice(E+1));break}else A.startsWith("-")||f.push(A)}a=f[0]??null;let m=[],g=new Set,v=()=>e.limits.maxArrayElements-m.length,y=E=>{for(let A of E){if(m.length>=e.limits.maxArrayElements)throw new C(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");if(q(A)>e.limits.maxStringLength)throw new C(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");e.executionScope.consumeWork(1,"compgen completion"),m.push(A),g.add(A)}};l&&y(await Ql(e,a,v())),u&&y(await w0(e,a,v()));for(let E of r)E==="variable"?y(bO(e,a,v())):E==="export"?y(wO(e,a,v())):E==="function"?y(EO(e,a,v())):E==="builtin"?y(SO(e,a,v())):E==="keyword"?y(AO(e,a,v())):E==="alias"?y(CO(e,a,v())):E==="shopt"?y(kO(e,a,v())):E==="helptopic"?y(NO(e,a,v())):E==="directory"?y(await Ql(e,a,v())):E==="file"?y(await w0(e,a,v())):E==="user"?y($O(e,a,v())):E==="command"&&y(await OO(e,a,v()));if(n!==null)try{let E=IO(e,await TO(e,n),v(),a);for(let A of E)y([A])}catch(E){if(E instanceof C)throw E;return Q("","",1)}if(o){let E=await Ql(e,a,v(),g);for(let A of E)g.has(A)||y([A])}let x="";if(p!==null){let E=e.state.functions.get(p);if(E){let A=new Map,O=or(e,"COMP_WORDS"),N=O?gn(O):void 0;ar(e,"COMP_WORDS"),Ao(e,"COMP_WORDS"),A.set("COMP_CWORD",e.state.env.get("COMP_CWORD")),e.state.env.set("COMP_CWORD","-1"),A.set("COMP_LINE",e.state.env.get("COMP_LINE")),e.state.env.set("COMP_LINE",""),A.set("COMP_POINT",e.state.env.get("COMP_POINT")),e.state.env.set("COMP_POINT","0");let D=or(e,"COMPREPLY"),$=D?gn(D):void 0,L=e.state.env.get("COMPREPLY");ar(e,"COMPREPLY"),e.state.env.delete("COMPREPLY");let _=["compgen",f[0]??"",""];try{let R=await Q3(e,E,_,"");if(R.exitCode!==0)return Kl(e,A),xi(e,"COMP_WORDS",N),xi(e,"COMPREPLY",$),L!==void 0&&e.state.env.set("COMPREPLY",L),Q("",R.stderr,1);x=R.stdout,y(RO(e,v()))}catch(R){if(R instanceof C)throw R;return Kl(e,A),xi(e,"COMP_WORDS",N),xi(e,"COMPREPLY",$),L!==void 0&&e.state.env.set("COMPREPLY",L),Q("","",1)}Kl(e,A),xi(e,"COMP_WORDS",N),xi(e,"COMPREPLY",$),L!==void 0&&e.state.env.set("COMPREPLY",L)}}if(h!==null)try{let E=Li(h),A=await e.executeScript(E);if(A.exitCode!==0)return Q("",A.stderr,A.exitCode);if(A.stdout)for(let O of PO(A.stdout))O.length>0&&y([O])}catch(E){if(E.name==="ParseException")return Z(`compgen: -C: ${E.message} `,2);throw E}let b=m;if(c!==null){let E=c.startsWith("!"),A=E?c.slice(1):c;b=m.filter(O=>{let N=w1(O,A,!1,!0,e.limits.maxCallDepth);return E?N:!N})}if(b.length===0&&a!==null)return Q(x,"",1);let w=new st(e.limits.maxOutputSize,"compgen");w.append(x);for(let E of b)w.append(i).append(E).append(s).append(` `);return We(w.build())}function bO(e,t,r){let n=Cr(e,t,r);for(let i of e.state.env.keys())/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&n.add(i);for(let i of e.state.arrays?.keys()??[])n.add(i);return n.build()}function wO(e,t,r){let n=Cr(e,t,r),i=e.state.exportedVars??new Set;for(let s of i)e.state.env.has(s)&&n.add(s);return n.build()}function EO(e,t,r){let n=Cr(e,t,r);for(let i of e.state.functions.keys())n.add(i);return n.build()}function SO(e,t,r){let n=Cr(e,t,r);for(let i of $1)n.add(i);return n.build()}function AO(e,t,r){let n=Cr(e,t,r);for(let i of X3)n.add(i);return n.build()}function CO(e,t,r){let n=Cr(e,t,r);for(let i of e.state.env.keys())if(i.startsWith("BASH_ALIAS_")){let s=i.slice(11);n.add(s)}return n.build()}function kO(e,t,r){let n=Cr(e,t,r);for(let i of yO)n.add(i);return n.build()}function NO(e,t,r){let n=Cr(e,t,r);for(let i of xO)n.add(i);return n.build()}async function Ql(e,t,r=e.limits.maxArrayElements,n){let i=Cr(e,null,r,n);try{let s=e.state.cwd,a=t??"";if(t){let l=t.lastIndexOf("/");if(l!==-1){let u=t.slice(0,l)||"/";a=t.slice(l+1),s=u.startsWith("/")?u:`${e.state.cwd}/${u}`}}let o=await e.fs.readdir(s);for(let l of o){e.executionScope.consumeWork(1,"compgen directory scan");let u=`${s}/${l}`;try{if((await e.fs.stat(u)).isDirectory&&(!a||l.startsWith(a)))if(t?.includes("/")){let c=t.lastIndexOf("/"),p=t.slice(0,c+1);i.add(p+l)}else i.add(l)}catch(c){if(c instanceof C)throw c}}}catch(s){if(s instanceof C)throw s}return i.build()}async function w0(e,t,r=e.limits.maxArrayElements){let n=Cr(e,null,r);try{let i=e.state.cwd,s=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let l=t.slice(0,o)||"/";s=t.slice(o+1),i=l.startsWith("/")?l:`${e.state.cwd}/${l}`}}let a=await e.fs.readdir(i);for(let o of a)if(e.executionScope.consumeWork(1,"compgen file scan"),!s||o.startsWith(s))if(t?.includes("/")){let l=t.lastIndexOf("/"),u=t.slice(0,l+1);n.add(u+o)}else n.add(o)}catch(i){if(i instanceof C)throw i}return n.build()}function $O(e,t,r){let n=Cr(e,t,r);return n.add("root"),n.add("nobody"),n.build()}async function OO(e,t,r){let n=Cr(e,t,r);for(let s of $1)n.add(s);for(let s of e.state.functions.keys())n.add(s);for(let s of e.state.env.keys())s.startsWith("BASH_ALIAS_")&&n.add(s.slice(11));for(let s of X3)n.add(s);let i=e.state.env.get("PATH")??"/usr/bin:/bin";for(let s of i.split(":"))if(s)try{let a=await e.fs.readdir(s);for(let o of a)n.add(o)}catch(a){if(a instanceof C)throw a}return n.build()}function Cr(e,t,r,n){let i=new Set;return{add(s){if(e.executionScope.consumeWork(1,"compgen candidate collection"),(t===null||s.startsWith(t))&&!n?.has(s)&&!i.has(s)){if(i.size>=r)throw new C(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");if(q(s)>e.limits.maxStringLength)throw new C(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");i.add(s)}},build(){return Array.from(i).sort()}}}async function TO(e,t){let r=new Be().parseWordFromString(t,!1,!1);return await Qe(e,J.word(r.parts.map(K3)))}function IO(e,t,r,n){let i=e.state.env.get("IFS")??` `;if(i.length===0){if(n!==null&&!t.startsWith(n))return[];if(r===0)throw new C(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");return[t]}let s=new Set(i.split("")),a=[],o=c=>{if(n===null||c.startsWith(n)){if(a.length>=r)throw new C(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");a.push(c)}},l="",u=0;for(;u0&&(o(l),l=""),u++):(l+=c,u++)}return l.length>0&&o(l),a}function Kl(e,t){for(let[r,n]of t)n===void 0?e.state.env.delete(r):e.state.env.set(r,n)}function xi(e,t,r){e.state.arrays??=new Map,r?e.state.arrays.set(t,gn(r)):e.state.arrays.delete(t)}function RO(e,t){let r=[],n=i=>{if(r.length>=t)throw new C(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");r.push(i)};if(Yr(e,"COMPREPLY")){let i=Te(e,"COMPREPLY");for(let[,s]of i)n(s)}else{let i=e.state.env.get("COMPREPLY");i!==void 0&&n(i)}return r}function*PO(e){let t=0;for(;t<=e.length;){let r=e.indexOf(` `,t),n=r===-1?e.length:r;if(n>t&&(yield e.slice(t,n)),r===-1)return;t=r+1}}se();function js(e){for(let t=0;t=t.length)return Z(`complete: -W: option requires an argument `,2);s=t[p]}else if(h==="-F"){if(p++,p>=t.length)return Z(`complete: -F: option requires an argument `,2);a=t[p]}else if(h==="-o"){if(p++,p>=t.length)return Z(`complete: -o: option requires an argument `,2);let f=t[p];if(!LO.includes(f))return Z(`complete: ${f}: invalid option name `,2);l.push(f)}else if(h==="-A"){if(p++,p>=t.length)return Z(`complete: -A: option requires an argument `,2);u.push(t[p])}else if(h==="-C"){if(p++,p>=t.length)return Z(`complete: -C: option requires an argument `,2);o=t[p]}else if(h==="-G"){if(p++,p>=t.length)return Z(`complete: -G: option requires an argument `,2)}else if(h==="-P"){if(p++,p>=t.length)return Z(`complete: -P: option requires an argument `,2)}else if(h==="-S"){if(p++,p>=t.length)return Z(`complete: -S: option requires an argument `,2)}else if(h==="-X"){if(p++,p>=t.length)return Z(`complete: -X: option requires an argument `,2)}else if(h==="--"){c.push(...t.slice(p+1));break}else h.startsWith("-")||c.push(h)}if(n){if(c.length===0)return e.state.completionSpecs.clear(),e.state.defaultCompletionSpec=void 0,e.state.emptyCompletionSpec=void 0,We("");for(let p of c)e.state.completionSpecs.delete(p);return We("")}if(r)return c.length===0?Xl(e):Xl(e,c);if(t.length===0||c.length===0&&!s&&!a&&!o&&l.length===0&&u.length===0&&!i)return Xl(e);if(a&&c.length===0&&!i)return Z(`complete: -F: option requires a command name `,2);if(i){let p={isDefault:!0};return s!==void 0&&(p.wordlist=s),a!==void 0&&(p.function=a),o!==void 0&&(p.command=o),l.length>0&&(p.options=l),u.length>0&&(p.actions=u),e.state.defaultCompletionSpec=p,We("")}for(let p of c){let h=Object.create(null);s!==void 0&&(h.wordlist=s),a!==void 0&&(h.function=a),o!==void 0&&(h.command=o),l.length>0&&(h.options=l),u.length>0&&(h.actions=u),e.state.completionSpecs.set(p,h)}return We("")}function Xl(e,t){let r=e.state.completionSpecs??new Map;if(r.size===0&&!e.state.defaultCompletionSpec){if(t&&t.length>0){let s="";for(let a of t)s+=`complete: ${a}: no completion specification `;return Q("",s,1)}return We("")}let n=[],i=t||Array.from(r.keys());for(let s of i){let a=r.get(s);if(!a){if(t)return Q(n.join(` `)+(n.length>0?` `:""),`complete: ${s}: no completion specification `,1);continue}let o="complete";if(a.options)for(let l of a.options)o+=` -o ${Bt(l)}`;if(a.actions)for(let l of a.actions)o+=` -A ${Bt(l)}`;a.wordlist!==void 0&&(a.wordlist.includes(" ")||a.wordlist.includes("'"),o+=` -W ${Bt(a.wordlist)}`),a.function!==void 0&&(o+=` -F ${Bt(a.function)}`),a.command!==void 0&&(o+=` -C ${Bt(a.command)}`),a.isDefault&&(o+=" -D"),o+=`${s.startsWith("-")?" -- ":" "}${Bt(s)}`,n.push(o)}if(!t&&e.state.defaultCompletionSpec){let s=e.state.defaultCompletionSpec,a="complete";for(let o of s.options??[])a+=` -o ${Bt(o)}`;for(let o of s.actions??[])a+=` -A ${Bt(o)}`;s.wordlist!==void 0&&(a+=` -W ${Bt(s.wordlist)}`),s.function!==void 0&&(a+=` -F ${Bt(s.function)}`),s.command!==void 0&&(a+=` -C ${Bt(s.command)}`),a+=" -D",n.push(a)}return n.length===0?We(""):We(`${n.join(` `)} `)}var E0=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function FO(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let r=!1,n=!1,i=[],s=[],a=[];for(let o=0;o=t.length)return Z(`compopt: -o: option requires an argument `,2);let u=t[o];if(!E0.includes(u))return Z(`compopt: ${u}: invalid option name `,2);i.push(u)}else if(l==="+o"){if(o++,o>=t.length)return Z(`compopt: +o: option requires an argument `,2);let u=t[o];if(!E0.includes(u))return Z(`compopt: ${u}: invalid option name `,2);s.push(u)}else if(l==="--"){a.push(...t.slice(o+1));break}else!l.startsWith("-")&&!l.startsWith("+")&&a.push(l)}if(r){let o=e.state.defaultCompletionSpec??{isDefault:!0},l=new Set(o.options??[]);for(let u of i)l.add(u);for(let u of s)l.delete(u);return o.options=l.size>0?Array.from(l):void 0,e.state.defaultCompletionSpec=o,We("")}if(n){let o=e.state.emptyCompletionSpec??Object.create(null),l=new Set(o.options??[]);for(let u of i)l.add(u);for(let u of s)l.delete(u);return o.options=l.size>0?Array.from(l):void 0,e.state.emptyCompletionSpec=o,We("")}if(a.length>0){for(let o of a){let l=e.state.completionSpecs.get(o)??{},u=new Set(l.options??[]);for(let c of i)u.add(c);for(let c of s)u.delete(c);l.options=u.size>0?Array.from(u):void 0,e.state.completionSpecs.set(o,l)}return We("")}return Z(`compopt: not currently executing completion function `,1)}H();function _O(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ds;return rt}if(t.length>1)throw new ze(1,"",`bash: continue: too many arguments `);let r=1;if(t.length>0){let n=Number.parseInt(t[0],10);if(Number.isNaN(n)||n<1)throw new ze(1,"",`bash: continue: ${t[0]}: numeric argument required `);r=n}throw new dn(r)}Et();function J3(e,t){let r="";return e.state.integerVars?.has(t)&&(r+="i"),e.state.lowercaseVars?.has(t)&&(r+="l"),dt(e,t)&&(r+="n"),e.state.readonlyVars?.has(t)&&(r+="r"),e.state.uppercaseVars?.has(t)&&(r+="u"),e.state.exportedVars?.has(t)&&(r+="x"),r===""?"--":`-${r}`}function R1(e){return Bt(e)}function P1(e){return`'${e.replace(/'/g,"'\\''")}'`}function zO(e,t){let r="",n="",i=!1;for(let s of t){let a=J3(e,s);if(e.state.associativeArrays?.has(s)){let u=Gi(e,s);if(u.length===0)r+=`declare -A ${s}=() `;else{let c=u.map(p=>{let h=R1(tt(e,s,p)??"");return`[${P1(p)}]=${h}`});r+=`declare -A ${s}=(${c.join(" ")}) `}continue}let o=Qt(e,s);if(o.length>0){let u=o.map(c=>`[${c}]=${Ki(tt(e,s,c)??"")}`);r+=`declare -a ${s}=(${u.join(" ")}) `;continue}if(Yr(e,s)){r+=`declare -a ${s}=() `;continue}let l=e.state.env.get(s);if(l!==void 0)r+=`declare ${a} ${s}=${I1(l)} `;else{let u=e.state.declaredVars?.has(s),c=e.state.localVarDepth?.has(s);u||c?r+=`declare ${a} ${s} `:(n+=`bash: declare: ${s}: not found `,i=!0)}}return Q(r,n,+!!i)}function BO(e,t){let{filterExport:r,filterReadonly:n,filterNameref:i,filterIndexedArray:s,filterAssocArray:a}=t,o=r||n||i||s||a,l="",u=new Set;for(let p of e.state.env.keys())p.startsWith("BASH_")||u.add(p);for(let p of e.state.arrays?.keys()??[])u.add(p);if(e.state.localVarDepth)for(let p of e.state.localVarDepth.keys())u.add(p);if(e.state.associativeArrays)for(let p of e.state.associativeArrays)u.add(p);let c=Array.from(u).sort();for(let p of c){let h=J3(e,p),f=e.state.associativeArrays?.has(p),d=Qt(e,p),m=!f&&Yr(e,p);if(o&&(a&&!f||s&&!m||r&&!e.state.exportedVars?.has(p)||n&&!e.state.readonlyVars?.has(p)||i&&!dt(e,p)))continue;if(f){let v=Gi(e,p);if(v.length===0)l+=`declare -A ${p}=() `;else{let y=v.map(x=>{let b=R1(tt(e,p,x)??"");return`[${P1(x)}]=${b}`});l+=`declare -A ${p}=(${y.join(" ")}) `}continue}if(d.length>0){let v=d.map(y=>`[${y}]=${Ki(tt(e,p,y)??"")}`);l+=`declare -a ${p}=(${v.join(" ")}) `;continue}if(Yr(e,p)){l+=`declare -a ${p}=() `;continue}let g=e.state.env.get(p);g!==void 0&&(l+=`declare ${h} ${p}=${I1(g)} `)}return We(l)}function UO(e){let t="",r=Array.from(e.state.associativeArrays??[]).sort();for(let n of r){let i=Gi(e,n);if(i.length===0)t+=`declare -A ${n}=() `;else{let s=i.map(a=>{let o=R1(tt(e,n,a)??"");return`[${P1(a)}]=${o}`});t+=`declare -A ${n}=(${s.join(" ")}) `}}return We(t)}function WO(e){let t="",r=new Set(Array.from(e.state.arrays??[]).filter(([,i])=>i.kind==="indexed").map(([i])=>i)),n=Array.from(r).sort();for(let i of n){let s=Qt(e,i);if(s.length===0)t+=`declare -a ${i}=() `;else{let a=s.map(o=>`[${o}]=${Ki(tt(e,i,o)??"")}`);t+=`declare -a ${i}=(${a.join(" ")}) `}}return We(t)}function jO(e){let t="",r=new Set;for(let i of e.state.env.keys())i.startsWith("BASH_")||r.add(i);let n=Array.from(r).sort();for(let i of n){if(e.state.associativeArrays?.has(i)||Qt(e,i).length>0||Yr(e,i))continue;let s=e.state.env.get(i);s!==void 0&&(t+=`${i}=${Bt(s)} `)}return We(t)}function Yl(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function mc(e,t){return e.state.integerVars?.has(t)??!1}function Jl(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function qO(e,t){return e.state.lowercaseVars?.has(t)??!1}function eu(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function GO(e,t){return e.state.uppercaseVars?.has(t)??!1}function Na(e,t,r){return qO(e,t)?r.toLowerCase():GO(e,t)?r.toUpperCase():r}async function S0(e,t){try{let r=await qe(e,ct(new Be,t).expression);return String(r)}catch{return"0"}}function HO(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let r=t[0],n=r.length;if(e[n]!=="[")return null;let i=0,s=n+1;for(;n0&&!v,b=N=>{if(!x)return;let D=e.state.localScopes[e.state.localScopes.length-1];D.has(N)||D.set(N,e.state.env.get(N))},w=N=>{if(!x)return;let D=e.state.localScopes[e.state.localScopes.length-1];for(D.has(N)||D.set(N,e.state.env.get(N)),e.state.localArrayScopes??=[];e.state.localArrayScopes.length{x&&ki(e,N)};if(g){if(y.length===0){let $=Array.from(e.state.functions.keys()).sort(),L="";for(let _ of $)L+=`declare -f ${_} `;return We(L)}let N=!0,D="";for(let $ of y)e.state.functions.has($)?D+=`${$} `:N=!1;return Q(D,"",+!N)}if(m){if(y.length===0){let D="",$=Array.from(e.state.functions.keys()).sort();for(let L of $)D+=`${L} () { # function body } `;return We(D)}let N=!0;for(let D of y)e.state.functions.has(D)||(N=!1);return Q("","",+!N)}if(o&&y.length>0)return zO(e,y);if(o&&y.length===0)return BO(e,{filterExport:a,filterReadonly:s,filterNameref:l,filterIndexedArray:n,filterAssocArray:i});if(y.length===0&&i&&!o)return UO(e);if(y.length===0&&n&&!o)return WO(e);if(y.length===0&&!o)return jO(e);let A="",O=0;for(let N of y){let D=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(D&&!c){let R=D[1],B=D[2],j=ft(e,R);if(j)return j;if(i&&Qt(e,R).length>0){A+=`bash: declare: ${R}: cannot convert indexed to associative array `,O=1;continue}if((n||!i&&!n)&&e.state.associativeArrays?.has(R)){A+=`bash: declare: ${R}: cannot convert associative to indexed array `,O=1;continue}let P=i&&B.includes("[")?uc(B,r):void 0,F=P===void 0?Fi(B,{...r,maxElements:i?r.maxElements*2:r.maxElements}):void 0;if(e.executionScope.consumeWork(P?.length??F?.length??0,"declare array assignment"),w(R),i?(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(R),Ni(e,R,"associative")):Ni(e,R,"indexed"),ar(e,R),e.state.env.delete(R),i&&B.includes("["))for(let[G,z]of P??[])Ce(e,R,G,Is(e,z),"associative");else if(i){let G=F??[];for(let z=0;z/^\[[^\]]+\]=/.test(z))){let z=0;for(let V of G){let ae=V.match(/^\[([^\]]+)\]=(.*)$/);if(ae){let te=ae[1],ie=ae[2],Se;if(/^-?\d+$/.test(te))Se=Number.parseInt(te,10);else try{Se=await qe(e,ct(new Be,te).expression)}catch{Se=0}Ce(e,R,Se,Is(e,ie)),z=Se+1}else Ce(e,R,z,V),z++}}else for(let z=0;zG));for(let[G,z]of F)Ce(e,R,G,z,"associative")}else{e.executionScope.consumeWork(P.length,"declare array append");let F=Qt(e,R),G=0,z=e.state.env.get(R);F.length===0&&z!==void 0?(Ce(e,R,0,z),e.state.env.delete(R),G=1):F.length>0&&(G=Math.max(...F)+1),$s(e,R,Array.from({length:P.length},(V,ae)=>G+ae));for(let V=0;V0||e.state.associativeArrays?.has(R);if(mc(e,R)){let F=e.state.env.get(R)??"0",G=parseInt(F,10)||0,z=parseInt(await S0(e,B),10)||0;B=String(G+z),e.state.env.set(R,B)}else if(P)B=Na(e,R,B),Ce(e,R,0,Pi([tt(e,R,0)??"",B],"",e.limits.maxStringLength,"declare append"));else{B=Na(e,R,B);let F=e.state.env.get(R)??"";e.state.env.set(R,Pi([F,B],"",e.limits.maxStringLength,"declare append"))}E(R),s&&mr(e,R),a&&ln(e,R),e.state.options.allexport&&!p&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(R));continue}if(N.includes("=")){let R=N.indexOf("="),B=N.slice(0,R),j=N.slice(R+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(B)){A+=`bash: typeset: \`${B}': not a valid identifier `,O=1;continue}let P=ft(e,B);if(P)return P;if(b(B),l){if(j!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(j)){A+=`bash: declare: \`${j}': invalid variable name for name reference `,O=1;continue}e.state.env.set(B,j),Zn(e,B),j!==""&&tc(e,j)&&r0(e,B),E(B),s&&mr(e,B),a&&ln(e,B);continue}if(h&&Yl(e,B),f&&Jl(e,B),d&&eu(e,B),mc(e,B)&&(j=await S0(e,j)),j=Na(e,B,j),dt(e,B)){let F=Jr(e,B);F&&F!==B?e.state.env.set(F,j):e.state.env.set(B,j)}else e.state.env.set(B,j);E(B),s&&mr(e,B),a&&ln(e,B),e.state.options.allexport&&!p&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(B))}else{let R=N;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(R)){A+=`bash: typeset: \`${R}': not a valid identifier `,O=1;continue}if(n||i?w(R):b(R),l){Zn(e,R);let j=e.state.env.get(R);j!==void 0&&j!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(j)?Hk(e,R):j&&tc(e,j)&&r0(e,R),E(R),s&&mr(e,R),a&&ln(e,R);continue}if(h&&Yl(e,R),f&&Jl(e,R),d&&eu(e,R),i){if(Qt(e,R).length>0){A+=`bash: declare: ${R}: cannot convert indexed to associative array `,O=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(R),Ni(e,R,"associative")}let B=Yr(e,R);!e.state.env.has(R)&&!B&&(n||i?Ni(e,R,i?"associative":"indexed"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(R))),E(R),s&&mr(e,R),a&&ln(e,R)}}return Q("",A,O)}async function ZO(e,t){let r={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength},n=[];for(let i=0;id));for(let[d,m]of f)Ce(e,u,d,m,"associative")}else{e.executionScope.consumeWork(h.length,"readonly array append");let f=Qt(e,u),d=0,m=e.state.env.get(u);f.length===0&&m!==void 0?(Ce(e,u,0,m),e.state.env.delete(u),d=1):f.length>0&&(d=Math.max(...f)+1),$s(e,u,Array.from({length:h.length},(g,v)=>d+v));for(let g=0;gn&&n!=="."),r=[];for(let n of t)n===".."?r.pop():r.push(n);return`/${r.join("/")}`}async function KO(e,t){let r=D1(e),n;for(let a=0;ao);a.pop(),i=`/${a.join("/")}`}else i=n==="."?e.state.cwd:n.startsWith("~")?(e.state.env.get("HOME")||"/")+n.slice(1):`${e.state.cwd}/${n}`;i=QO(i);try{if(!(await e.fs.stat(i)).isDirectory)return Z(`bash: pushd: ${n}: Not a directory `,1)}catch{return Z(`bash: pushd: ${n}: No such file or directory `,1)}r.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=i,e.state.env.set("PWD",i),e.state.env.set("OLDPWD",e.state.previousDir);let s=e.state.env.get("HOME")||"";return We(`${[i,...r].map(a=>ws(a,s)).join(" ")} `)}function XO(e,t){let r=D1(e);for(let s of t)if(s!=="--")return s.startsWith("-")&&s!=="-"?Z(`bash: popd: ${s}: invalid option `,2):Z(`bash: popd: too many arguments `,2);if(r.length===0)return Z(`bash: popd: directory stack empty `,1);let n=r.shift();if(!n)return Z(`bash: popd: directory stack empty `,1);e.state.previousDir=e.state.cwd,e.state.cwd=n,e.state.env.set("PWD",n),e.state.env.set("OLDPWD",e.state.previousDir);let i=e.state.env.get("HOME")||"";return We(`${[n,...r].map(s=>ws(s,i)).join(" ")} `)}function YO(e,t){let r=D1(e),n=!1,i=!1,s=!1,a=!1;for(let c of t)if(c!=="--")if(c.startsWith("-"))for(let p of c.slice(1))if(p==="c")n=!0;else if(p==="l")i=!0;else if(p==="p")s=!0;else if(p==="v")s=!0,a=!0;else return Z(`bash: dirs: -${p}: invalid option `,2);else return Z(`bash: dirs: too many arguments `,1);if(n)return e.state.directoryStack=[],rt;let o=[e.state.cwd,...r],l=e.state.env.get("HOME")||"",u;return a?(u=o.map((c,p)=>` ${p} ${i?c:ws(c,l)}`).join(` `),u+=` `):u=s?o.map(c=>i?c:ws(c,l)).join(` `)+` `:o.map(c=>i?c:ws(c,l)).join(" ")+` `,We(u)}H();async function A0(e,t,r,n=!1){let i=t;if(i.length>0){let l=i[0];if(l==="--")i=i.slice(1);else if(l.startsWith("-")&&l!=="-"&&l.length>1)return Z(`bash: eval: ${l}: invalid option eval: usage: eval [arg ...] `,2)}if(i.length===0)return rt;let s=i.join(" ");if(s.trim()==="")return rt;let a=e.state.groupStdin,o=n||r!==void 0&&r!=="";o&&(e.state.groupStdin=r??"");try{let l=Li(s);return await e.executeScript(l)}catch(l){if(l instanceof fn||l instanceof dn||l instanceof rn||l instanceof ze)throw l;if(l.name==="ParseException")return Z(`bash: eval: ${l.message} `);throw l}finally{(o||a!==void 0&&e.state.groupStdin===void 0)&&(e.state.groupStdin=a)}}H();function JO(e,t){let r,n="";if(t.length===0)r=e.state.lastExitCode;else{let i=t[0];if(i===""||!/^-?\d+$/.test(i))n=`bash: exit: ${i}: numeric argument required `,r=2;else{let s=BigInt(i);r=Number((s%256n+256n)%256n)}}throw new ze(r,"",n)}function eT(e,t){let r=!1,n=[];for(let a of t)a==="-n"?r=!0:a==="-p"||a==="--"||n.push(a);if(n.length===0&&!r){let a="",o=e.state.exportedVars??new Set,l=Array.from(o).sort();for(let u of l){let c=e.state.env.get(u);c!==void 0&&(a+=`declare -x ${u}=${I1(c)} `)}return We(a)}if(r){for(let a of n){let o,l;if(a.includes("=")){let u=a.indexOf("=");o=a.slice(0,u),l=a.slice(u+1)}else o=a;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o))return Q("",`bash: export: \`${a}': not a valid identifier `,1);l!==void 0&&(ft(e,o),e.state.env.set(o,l)),A3(e,o)}return rt}let i="",s=0;for(let a of n){let o,l,u=!1,c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(c)o=c[1],l=c[2],u=!0;else if(a.includes("=")){let p=a.indexOf("=");o=a.slice(0,p),l=a.slice(p+1)}else o=a;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){i+=`bash: export: \`${a}': not a valid identifier `,s=1;continue}if(l!==void 0)if(ft(e,o),u){let p=e.state.env.get(o)??"";e.state.env.set(o,p+l)}else e.state.env.set(o,l);else e.state.env.has(o)||e.state.env.set(o,"");ln(e,o)}return Q("",i,s)}function e4(e,t){if(t.length<2)return Z(`bash: getopts: usage: getopts optstring name [arg ...] `);let r=t[0],n=t[1],i=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n),s=r.startsWith(":"),a=s?r.slice(1):r,o;if(t.length>2)o=t.slice(2);else{let d=Number.parseInt(e.state.env.get("#")||"0",10);o=[];for(let m=1;m<=d;m++)o.push(e.state.env.get(String(m))||"")}let l=Number.parseInt(e.state.env.get("OPTIND")||"1",10);l<1&&(l=1);let u=Number.parseInt(e.state.env.get("__GETOPTS_CHARINDEX")||"0",10);if(e.state.env.set("OPTARG",""),l>o.length)return i||e.state.env.set(n,"?"),e.state.env.set("OPTIND",String(o.length+1)),e.state.env.set("__GETOPTS_CHARINDEX","0"),{exitCode:i?2:1,stdout:"",stderr:""};let c=o[l-1];if(!c||c==="-"||!c.startsWith("-"))return i||e.state.env.set(n,"?"),{exitCode:i?2:1,stdout:"",stderr:""};if(c==="--")return e.state.env.set("OPTIND",String(l+1)),e.state.env.set("__GETOPTS_CHARINDEX","0"),i||e.state.env.set(n,"?"),{exitCode:i?2:1,stdout:"",stderr:""};let p=u===0?1:u,h=c[p];if(!h)return e.state.env.set("OPTIND",String(l+1)),e.state.env.set("__GETOPTS_CHARINDEX","0"),e4(e,t);let f=a.indexOf(h);if(f===-1){let d="";return s?e.state.env.set("OPTARG",h):d=`bash: illegal option -- ${h} `,i||e.state.env.set(n,"?"),p+1=o.length){let d="";return s?(e.state.env.set("OPTARG",h),i||e.state.env.set(n,":")):(d=`bash: option requires an argument -- ${h} `,i||e.state.env.set(n,"?")),e.state.env.set("OPTIND",String(l+1)),e.state.env.set("__GETOPTS_CHARINDEX","0"),{exitCode:i?2:0,stdout:"",stderr:d}}e.state.env.set("OPTARG",o[l]),e.state.env.set("OPTIND",String(l+2)),e.state.env.set("__GETOPTS_CHARINDEX","0")}else p+1=t.length)return Z(`bash: hash: -p: option requires an argument `,1);o=t[u],u++}else if(f.startsWith("-")&&f.length>1){for(let d of f.slice(1))if(d==="r")r=!0;else if(d==="d")n=!0;else if(d==="l")i=!0;else if(d==="t")a=!0;else return Z(d==="p"?`bash: hash: -p: option requires an argument `:`bash: hash: -${d}: invalid option `,1);u++}else l.push(f),u++}if(r)return e.state.hashTable.clear(),rt;if(n){if(l.length===0)return Z(`bash: hash: -d: option requires an argument `,1);let f=!1,d="";for(let m of l)e.state.hashTable.has(m)?e.state.hashTable.delete(m):(d+=`bash: hash: ${m}: not found `,f=!0);return f?Z(d,1):rt}if(a){if(l.length===0)return Z(`bash: hash: -t: option requires an argument `,1);let f="",d=!1,m="";for(let g of l){let v=e.state.hashTable.get(g);v?l.length>1?f+=`${g} ${v} `:f+=`${v} `:(m+=`bash: hash: ${g}: not found `,d=!0)}return d?{exitCode:1,stdout:f,stderr:m}:We(f)}if(s){if(l.length===0)return Z(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...] `,1);let f=l[0];return e.state.hashTable.set(f,o),rt}if(l.length===0){if(e.state.hashTable.size===0)return We(`hash: hash table empty `);let f="";if(i)for(let[d,m]of e.state.hashTable){let g=d.startsWith("-")?" --":"";f+=`builtin hash -p ${Bt(m)}${g} ${Bt(d)} `}else{f=`hits command `;for(let[,d]of e.state.hashTable)f+=` 1 ${d} `}return We(f)}let c=!1,p="",h=(e.state.env.get("PATH")||"/usr/bin:/bin").split(":");for(let f of l){if(f.includes("/")){p+=`bash: hash: ${f}: cannot use / in name `,c=!0;continue}let d=!1;for(let m of h){if(!m)continue;let g=`${m}/${f}`;if(await e.fs.exists(g)){e.state.hashTable.set(f,g),d=!0;break}}d||(p+=`bash: hash: ${f}: not found `,c=!0)}return c?Z(p,1):rt}at();var t4=new Map([[":",[": [arguments]",`Null command. No effect; the command does nothing. Exit Status: Always succeeds.`]],[".",[". filename [arguments]",`Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. Exit Status: Returns the status of the last command executed in FILENAME.`]],["[",["[ arg... ]",`Evaluate conditional expression. This is a synonym for the "test" builtin, but the last argument must be a literal \`]', to match the opening \`['.`]],["alias",["alias [-p] [name[=value] ... ]",`Define or display aliases. Without arguments, \`alias' prints the list of aliases in the reusable form \`alias NAME=VALUE' on standard output. Exit Status: alias returns true unless a NAME is supplied for which no alias has been defined.`]],["bg",["bg [job_spec ...]",`Move jobs to the background. Place the jobs identified by each JOB_SPEC in the background, as if they had been started with \`&'.`]],["break",["break [n]",`Exit for, while, or until loops. Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing loops. Exit Status: The exit status is 0 unless N is not greater than or equal to 1.`]],["builtin",["builtin [shell-builtin [arg ...]]",`Execute shell builtins. Execute SHELL-BUILTIN with arguments ARGs without performing command lookup. This is useful when you wish to reimplement a shell builtin as a shell function, but need to execute the builtin within the function. Exit Status: Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is not a shell builtin.`]],["caller",["caller [expr]",`Return the context of the current subroutine call. Without EXPR, returns "$line $filename". With EXPR, returns "$line $subroutine $filename"; this extra information can be used to provide a stack trace. Exit Status: Returns 0 unless the shell is not executing a subroutine call or EXPR is invalid.`]],["cd",["cd [-L|-P] [dir]",`Change the shell working directory. Change the current directory to DIR. The default DIR is the value of the HOME shell variable. The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as the current directory. If DIR begins with a slash (/), then CDPATH is not used. If the directory is not found, and the shell option \`cdable_vars' is set, the word is assumed to be a variable name. If that variable has a value, its value is used for DIR. Options: -L force symbolic links to be followed -P use the physical directory structure without following symbolic links The default is to follow symbolic links, as if \`-L' were specified. Exit Status: Returns 0 if the directory is changed; non-zero otherwise.`]],["command",["command [-pVv] command [arg ...]",`Execute a simple command or display information about commands. Runs COMMAND with ARGS suppressing shell function lookup, or display information about the specified COMMANDs. Options: -p use a default value for PATH that is guaranteed to find all of the standard utilities -v print a description of COMMAND similar to the \`type' builtin -V print a more verbose description of each COMMAND Exit Status: Returns exit status of COMMAND, or failure if COMMAND is not found.`]],["compgen",["compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]",`Display possible completions depending on the options. Intended to be used from within a shell function generating possible completions. If the optional WORD argument is supplied, matches against WORD are generated. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],["complete",["complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]",`Specify how arguments are to be completed. For each NAME, specify how arguments are to be completed. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],["continue",["continue [n]",`Resume for, while, or until loops. Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop. If N is specified, resumes the Nth enclosing loop. Exit Status: The exit status is 0 unless N is not greater than or equal to 1.`]],["declare",["declare [-aAfFgilnrtux] [-p] [name[=value] ...]",`Set variable values and attributes. Declare variables and give them attributes. If no NAMEs are given, display the attributes and values of all variables. Options: -a to make NAMEs indexed arrays (if supported) -A to make NAMEs associative arrays (if supported) -i to make NAMEs have the \`integer' attribute -l to convert the value of each NAME to lower case on assignment -n make NAME a reference to the variable named by its value -r to make NAMEs readonly -t to make NAMEs have the \`trace' attribute -u to convert the value of each NAME to upper case on assignment -x to make NAMEs export Exit Status: Returns success unless an invalid option is supplied or a variable assignment error occurs.`]],["dirs",["dirs [-clpv] [+N] [-N]",`Display directory stack. Display the list of currently remembered directories. Directories find their way onto the list with the \`pushd' command; you can get back up through the list with the \`popd' command. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],["disown",["disown [-h] [-ar] [jobspec ...]",`Remove jobs from current shell. Without any JOBSPECs, remove the current job.`]],["echo",["echo [-neE] [arg ...]",`Write arguments to the standard output. Display the ARGs, separated by a single space character and followed by a newline, on the standard output. Options: -n do not append a newline -e enable interpretation of the following backslash escapes -E explicitly suppress interpretation of backslash escapes Exit Status: Returns success unless a write error occurs.`]],["enable",["enable [-a] [-dnps] [-f filename] [name ...]",`Enable and disable shell builtins. Enables and disables builtin shell commands. Exit Status: Returns success unless NAME is not a shell builtin or an error occurs.`]],["eval",["eval [arg ...]",`Execute arguments as a shell command. Combine ARGs into a single string, use the result as input to the shell, and execute the resulting commands. Exit Status: Returns exit status of command or success if command is null.`]],["exec",["exec [-cl] [-a name] [command [arguments ...]] [redirection ...]",`Replace the shell with the given command. Execute COMMAND, replacing this shell with the specified program. ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified, any redirections take effect in the current shell. Exit Status: Returns success unless COMMAND is not found or a redirection error occurs.`]],["exit",["exit [n]",`Exit the shell. Exits the shell with a status of N. If N is omitted, the exit status is that of the last command executed.`]],["export",["export [-fn] [name[=value] ...] or export -p",`Set export attribute for shell variables. Marks each NAME for automatic export to the environment of subsequently executed commands. If VALUE is supplied, assign VALUE before exporting. Options: -f refer to shell functions -n remove the export property from each NAME -p display a list of all exported variables and functions Exit Status: Returns success unless an invalid option is given or NAME is invalid.`]],["false",["false",`Return an unsuccessful result. Exit Status: Always fails.`]],["fc",["fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]",`Display or execute commands from the history list. Exit Status: Returns success or status of executed command.`]],["fg",["fg [job_spec]",`Move job to the foreground. Place the job identified by JOB_SPEC in the foreground, making it the current job.`]],["getopts",["getopts optstring name [arg]",`Parse option arguments. Getopts is used by shell procedures to parse positional parameters as options. OPTSTRING contains the option letters to be recognized; if a letter is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. Exit Status: Returns success if an option is found; fails if the end of options is encountered or an error occurs.`]],["hash",["hash [-lr] [-p pathname] [-dt] [name ...]",`Remember or display program locations. Determine and remember the full pathname of each command NAME. Exit Status: Returns success unless NAME is not found or an invalid option is given.`]],["help",["help [-s] [pattern ...]",`Display information about builtin commands. Displays brief summaries of builtin commands. If PATTERN is specified, gives detailed help on all commands matching PATTERN, otherwise the list of help topics is printed. Options: -s output only a short usage synopsis for each topic matching PATTERN Exit Status: Returns success unless PATTERN is not found.`]],["history",["history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]",`Display or manipulate the history list. Display the history list with line numbers, prefixing each modified entry with a \`*'. Exit Status: Returns success unless an invalid option is given or an error occurs.`]],["jobs",["jobs [-lnprs] [jobspec ...] or jobs -x command [args]",`Display status of jobs. Lists the active jobs. Exit Status: Returns success unless an invalid option is given or an error occurs.`]],["kill",["kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]",`Send a signal to a job. Send the processes identified by PID or JOBSPEC the signal named by SIGSPEC or SIGNUM. Exit Status: Returns success unless an invalid option is given or an error occurs.`]],["let",["let arg [arg ...]",`Evaluate arithmetic expressions. Evaluate each ARG as an arithmetic expression. Evaluation is done in fixed-width integers with no check for overflow, though division by 0 is trapped and flagged as an error. Exit Status: If the last ARG evaluates to 0, let returns 1; 0 is returned otherwise.`]],["local",["local [option] name[=value] ...",`Define local variables. Create a local variable called NAME, and give it VALUE. OPTION can be any option accepted by \`declare'. Local can only be used within a function; it makes the variable NAME have a visible scope restricted to that function and its children. Exit Status: Returns success unless an invalid option is supplied, a variable assignment error occurs, or the shell is not executing a function.`]],["logout",["logout [n]",`Exit a login shell. Exits a login shell with exit status N. Returns an error if not executed in a login shell.`]],["mapfile",["mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]",`Read lines from the standard input into an indexed array variable. Read lines from the standard input into the indexed array variable ARRAY, or from file descriptor FD if the -u option is supplied. Options: -d delim Use DELIM to terminate lines, instead of newline -n count Copy at most COUNT lines -O origin Begin assigning to ARRAY at index ORIGIN -s count Discard the first COUNT lines read -t Remove a trailing DELIM from each line read (default newline) -u fd Read lines from file descriptor FD instead of standard input Exit Status: Returns success unless an invalid option is given or ARRAY is readonly.`]],["popd",["popd [-n] [+N | -N]",`Remove directories from stack. Removes entries from the directory stack. Exit Status: Returns success unless an invalid argument is supplied or the directory change fails.`]],["printf",["printf [-v var] format [arguments]",`Formats and prints ARGUMENTS under control of the FORMAT. Options: -v var assign the output to shell variable VAR rather than display it on the standard output FORMAT is a character string which contains three types of objects: plain characters, which are simply copied to standard output; character escape sequences, which are converted and copied to the standard output; and format specifications, each of which causes printing of the next successive argument. Exit Status: Returns success unless an invalid option is given or a write or assignment error occurs.`]],["pushd",["pushd [-n] [+N | -N | dir]",`Add directories to stack. Adds a directory to the top of the directory stack, or rotates the stack, making the new top of the stack the current working directory. Exit Status: Returns success unless an invalid argument is supplied or the directory change fails.`]],["pwd",["pwd [-LP]",`Print the name of the current working directory. Options: -L print the value of $PWD if it names the current working directory -P print the physical directory, without any symbolic links By default, \`pwd' behaves as if \`-L' were specified. Exit Status: Returns 0 unless an invalid option is given or the current directory cannot be read.`]],["read",["read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]",`Read a line from the standard input and split it into fields. Reads a single line from the standard input, or from file descriptor FD if the -u option is supplied. The line is split into fields as with word splitting, and the first word is assigned to the first NAME, the second word to the second NAME, and so on, with any leftover words assigned to the last NAME. Exit Status: The return code is zero, unless end-of-file is encountered, read times out, or an invalid file descriptor is supplied as the argument to -u.`]],["readarray",["readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]","Read lines from a file into an array variable.\n A synonym for `mapfile'."]],["readonly",["readonly [-aAf] [name[=value] ...] or readonly -p",`Mark shell variables as unchangeable. Mark each NAME as read-only; the values of these NAMEs may not be changed by subsequent assignment. Exit Status: Returns success unless an invalid option is given or NAME is invalid.`]],["return",["return [n]",`Return from a shell function. Causes a function or sourced script to exit with the return value specified by N. If N is omitted, the return status is that of the last command executed within the function or script. Exit Status: Returns N, or failure if the shell is not executing a function or script.`]],["set",["set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]",`Set or unset values of shell options and positional parameters. Change the value of shell attributes and positional parameters, or display the names and values of shell variables. Options: -e Exit immediately if a command exits with a non-zero status. -u Treat unset variables as an error when substituting. -x Print commands and their arguments as they are executed. -o option-name Set the variable corresponding to option-name Exit Status: Returns success unless an invalid option is given.`]],["shift",["shift [n]",`Shift positional parameters. Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is not given, it is assumed to be 1. Exit Status: Returns success unless N is negative or greater than $#.`]],["shopt",["shopt [-pqsu] [-o] [optname ...]",`Set and unset shell options. Change the setting of each shell option OPTNAME. Without any option arguments, list each supplied OPTNAME, or all shell options if no OPTNAMEs are given, with an indication of whether or not each is set. Options: -o restrict OPTNAMEs to those defined for use with \`set -o' -p print each shell option with an indication of its status -q suppress output -s enable (set) each OPTNAME -u disable (unset) each OPTNAME Exit Status: Returns success if OPTNAME is enabled; fails if an invalid option is given or OPTNAME is disabled.`]],["source",["source filename [arguments]",`Execute commands from a file in the current shell. Read and execute commands from FILENAME in the current shell. The entries in $PATH are used to find the directory containing FILENAME. Exit Status: Returns the status of the last command executed in FILENAME.`]],["suspend",["suspend [-f]",`Suspend shell execution. Suspend the execution of this shell until it receives a SIGCONT signal.`]],["test",["test [expr]",`Evaluate conditional expression. Exits with a status of 0 (true) or 1 (false) depending on the evaluation of EXPR. Expressions may be unary or binary. Exit Status: Returns success if EXPR evaluates to true; fails if EXPR evaluates to false or an invalid argument is given.`]],["times",["times",`Display process times. Prints the accumulated user and system times for the shell and all of its child processes. Exit Status: Always succeeds.`]],["trap",["trap [-lp] [[arg] signal_spec ...]",`Trap signals and other events. Defines and activates handlers to be run when the shell receives signals or other conditions. Exit Status: Returns success unless a SIGSPEC is invalid or an invalid option is given.`]],["true",["true",`Return a successful result. Exit Status: Always succeeds.`]],["type",["type [-afptP] name [name ...]",`Display information about command type. For each NAME, indicate how it would be interpreted if used as a command name. Options: -a display all locations containing an executable named NAME -f suppress shell function lookup -P force a PATH search for each NAME, even if it is an alias, builtin, or function, and returns the name of the disk file that would be executed -p returns either the name of the disk file that would be executed, or nothing if \`type -t NAME' would not return \`file' -t output a single word which is one of \`alias', \`keyword', \`function', \`builtin', \`file' or \`', if NAME is an alias, shell reserved word, shell function, shell builtin, disk file, or not found, respectively Exit Status: Returns success if all of the NAMEs are found; fails if any are not found.`]],["typeset",["typeset [-aAfFgilnrtux] [-p] name[=value] ...","Set variable values and attributes.\n A synonym for `declare'."]],["ulimit",["ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]",`Modify shell resource limits. Provides control over the resources available to the shell and processes it creates, on systems that allow such control. Exit Status: Returns success unless an invalid option is supplied or an error occurs.`]],["umask",["umask [-p] [-S] [mode]",`Display or set file mode mask. Sets the user file-creation mask to MODE. If MODE is omitted, prints the current value of the mask. Exit Status: Returns success unless MODE is invalid or an invalid option is given.`]],["unalias",["unalias [-a] name [name ...]",`Remove each NAME from the list of defined aliases. Exit Status: Returns success unless a NAME is not an existing alias.`]],["unset",["unset [-f] [-v] [-n] [name ...]",`Unset values and attributes of shell variables and functions. For each NAME, remove the corresponding variable or function. Options: -f treat each NAME as a shell function -v treat each NAME as a shell variable -n treat each NAME as a name reference and unset the variable itself rather than the variable it references Without options, unset first tries to unset a variable, and if that fails, tries to unset a function. Exit Status: Returns success unless an invalid option is given or a NAME is read-only.`]],["wait",["wait [-fn] [id ...]",`Wait for job completion and return exit status. Waits for each process identified by an ID, which may be a process ID or a job specification, and reports its termination status. Exit Status: Returns the status of the last ID; fails if ID is invalid or an invalid option is given.`]]]),r4=[...t4.keys()].sort();function rT(e,t){let r=!1,n=[],i=0;for(;i1){for(let u=1;ut.test(r))}function iT(){let e=[];e.push("just-bash shell builtins"),e.push("These shell commands are defined internally. Type `help' to see this list."),e.push("Type `help name' to find out more about the function `name'."),e.push("");let t=r4.slice(),r=Math.ceil(t.length/2);for(let n=0;n0&&s.pipelines[0].commands.length>0){let a=s.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(n=await qe(e,a.expression.expression))}}catch(s){return Z(`bash: let: ${i}: ${s.message} `)}return Q("","",+(n===0))}Et();async function oT(e,t){let r={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength};if(e.state.localScopes.length===0)return Z(`bash: local: can only be used in a function `);let n=e.state.localScopes[e.state.localScopes.length-1];for(e.state.localArrayScopes??=[];e.state.localArrayScopes.length{if(n.has(p)||n.set(p,e.state.env.get(p)),i&&!i.has(p)){let h=or(e,p);i.set(p,h?gn(h):void 0)}},a="",o=0,l=!1,u=!1,c=[];for(let p of t)if(p==="-n")l=!0;else if(p==="-a")u=!0;else if(p!=="-p")if(p.startsWith("-")&&!p.includes("="))for(let h of p.slice(1))h==="n"?l=!0:h==="a"&&(u=!0);else c.push(p);if(c.length===0){let p="",h=Array.from(n.keys()).sort();for(let f of h){let d=e.state.env.get(f);d!==void 0&&(p+=`${f}=${d} `)}return Q(p,"",0)}for(let p of c){let h,f,d=p.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(d){h=d[1];let x=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(h)){a+=`bash: local: \`${p}': not a valid identifier `,o=1;continue}ft(e,h,"bash");let b=Fi(x,r);e.executionScope.consumeWork(b.length,"local array assignment"),s(h),ar(e,h),Ni(e,h,"indexed");for(let w=0;w0&&(E=Math.max(...w)+1),$s(e,h,Array.from({length:b.length},(O,N)=>E+N));for(let O=0;O=0;E--){let A=e.state.tempEnvBindings[E];if(A.has(h)){x=A.get(h);break}}}eO(e,h,x)}if(!y){let x=e.state.env.get(h);if(e.state.tempEnvBindings)for(let b=e.state.tempEnvBindings.length-1;b>=0;b--){let w=e.state.tempEnvBindings[b];if(w.has(h)){x=w.get(h);break}}n.set(h,x),u&&s(h)}if(u&&f===void 0)ar(e,h),Ni(e,h,"indexed");else if(f!==void 0){if(ft(e,h,"bash"),l&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){a+=`bash: local: \`${f}': invalid variable name for name reference `,o=1;continue}e.state.env.set(h,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(h))}else{let x=e.state.tempEnvBindings?.some(b=>b.has(h));!y&&!x&&e.state.env.delete(h)}ki(e,h),l&&Zn(e,h)}return Q("",a,o)}se(),H();function lT(e,t,r){let n=` `,i=0,s=0,a=0,o=!1,l="MAPFILE",u=0;for(;u{if(q(y)>e.limits.maxStringLength)throw new C(`mapfile: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");p.push(y)};for(;h=m)return Q("",`mapfile: array element limit exceeded (${m}) `,1);g(w),f++}}break}let x=c.slice(h,y),b=x.indexOf("\0");if(b!==-1&&(x=x.substring(0,b)),!o&&n!=="\0"&&(x+=n),h=y+n.length,d0&&f>=i)break;if(p.length>=m)return Q("",`mapfile: array element limit exceeded (${m}) `,1);g(x),f++}let v=new Set(s===0?[]:e.state.arrays?.get(l)?.elements.keys()??[]);for(let y=0;ym)return Q("",`mapfile: array element limit exceeded (${m}) `,1);s===0&&ar(e,l);for(let y=0;y{let G=1;for(;G1&&P!=="--"){let F=d(P,h);if(F.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(F.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};h=F.nextArgIndex}else if(P==="--")for(h++;h=0&&p.length===0&&m.add("REPLY");for(let P of m){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P))return Q("",`bash: read: \`${P}': not a valid identifier `,1);ft(e,P,"bash")}if(c===0){if(l)ar(e,l);else{for(let P of p)e.state.env.set(P,"");p.length===0&&e.state.env.set("REPLY","")}return Q("","",0)}if(c<0&&c!==-1)return Q("","",1);let g=r,v=en(e,u),y=u>0&&(v?.kind!=="dup-in"||v.sourceFd!==0);if(y){let P=H3(e,u);if("error"in P)return Q("",P.error==="write-only"||u===1||u===2?`bash: read: read error: ${u}: Bad file descriptor `:`bash: read: ${u}: invalid file descriptor: Bad file descriptor `,1);g=P.content}else!g&&e.state.groupStdin!==void 0&&(g=e.state.groupStdin);let x=s===""?"\0":s,b="",w=0,E=P=>{let F=q(P);if(F>e.limits.maxStringLength-w)throw new C(`read: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length");b+=P,w+=F},A=P=>{if(q(P)>e.limits.maxStringLength)throw new C(`read: string length limit exceeded (${e.limits.maxStringLength} bytes)`,"string_length")},O=0,N=!0,D=P=>{y?bs(e,u,P):n>=0?bs(e,n,P):e.state.groupStdin!==void 0&&!r&&(e.state.groupStdin=g.substring(P),e.state.groupStdinSourceFd!==void 0&&bs(e,e.state.groupStdinSourceFd,P))};if(o>=0){let P=Math.min(o,g.length);b=g.substring(0,P),A(b),O=P,N=P>=o,D(O);let F=p[0]||"REPLY";e.state.env.set(F,b);for(let G=1;G=0){let P=0,F=0,G=!1;for(;F=a||G,D(O)}else{O=0;let P=0;for(;P=g.length&&(N=!1,O=P,b.length===0&&g.length===0)){for(let F of p)e.state.env.set(F,"");return l&&ar(e,l),Q("","",1)}D(O)}x===` `&&b.endsWith(` `)&&(b=b.slice(0,-1));let $=P=>i?P:P.replace(/\\(.)/g,"$1");if(p.length===1&&p[0]==="REPLY")return e.state.env.set("REPLY",$(b)),Q("","",+!N);let L=Wt(e.state.env),_=e.limits.maxArrayElements;if(l){let{words:P}=t0(b,L,_,void 0,i);ar(e,l);for(let F=0;F0){let n=t[0],i=Number.parseInt(n,10);if(n===""||Number.isNaN(i)||!/^-?\d+$/.test(n))return Z(`bash: return: ${n}: numeric argument required `,2);r=(i%256+256)%256}throw new rn(r)}Et(),H();var ps=`set: usage: set [-eux] [+eux] [-o option] [+o option] Options: -e Exit immediately if a command exits with non-zero status +e Disable -e -u Treat unset variables as an error when substituting +u Disable -u -x Print commands and their arguments as they are executed +x Disable -x -o errexit Same as -e +o errexit Disable errexit -o nounset Same as -u +o nounset Disable nounset -o pipefail Return status of last failing command in pipeline +o pipefail Disable pipefail -o xtrace Same as -x +o xtrace Disable xtrace `,C0=new Map([["e","errexit"],["u","nounset"],["x","xtrace"],["v","verbose"],["f","noglob"],["C","noclobber"],["a","allexport"],["n","noexec"],["h",null],["b",null],["m",null],["B",null],["H",null],["P",null],["T",null],["E",null],["p",null]]),sa=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["noclobber","noclobber"],["noglob","noglob"],["allexport","allexport"],["noexec","noexec"],["posix","posix"],["vi","vi"],["emacs","emacs"],["notify",null],["monitor",null],["braceexpand",null],["histexpand",null],["physical",null],["functrace",null],["errtrace",null],["privileged",null],["hashall",null],["ignoreeof",null],["interactive-comments",null],["keyword",null],["onecmd",null]]),n4=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],i4=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function tu(e,t,r){t!==null&&(r&&(t==="vi"?e.state.options.emacs=!1:t==="emacs"&&(e.state.options.vi=!1)),e.state.options[t]=r,Ha(e))}function pT(e,t){return t+10&&t.append(" "),t.append(`[${s}]=`),t.reserve(T1(a)),t.append(Ki(a))}t.append(")")}function fT(e,t){if(/^[a-zA-Z0-9_]+$/.test(t)){e.append(t);return}e.reserve(T1(t)),e.append(Ki(t))}function dT(e,t,r){let n=Gi(e,r);if(n.length===0){t.append(r).append("=()");return}t.append(r).append("=(");for(let i=0;i0&&t.append(" "),t.append("["),fT(t,s),t.append("]="),t.reserve(T1(a)),t.append(Ki(a))}t.append(" )")}function mT(e){let t=new Set,r=e.state.associativeArrays??new Set;for(let[n,i]of e.state.arrays??[])i.kind==="indexed"&&!r.has(n)&&t.add(n);return t}function gT(e){return e.state.associativeArrays??new Set}function k0(e){let t=n4.map(n=>`${n.padEnd(16)}${e.state.options[n]?"on":"off"}`),r=i4.map(n=>`${n.padEnd(16)}off`);return`${[...t,...r].sort().join(` `)} `}function N0(e){let t=n4.map(n=>`set ${e.state.options[n]?"-o":"+o"} ${n}`),r=i4.map(n=>`set +o ${n}`);return`${[...t,...r].sort().join(` `)} `}function yT(e,t){if(t.includes("--help"))return We(ps);if(t.length===0){let s=mT(e),a=gT(e),o=[];for(let[c,p]of e.state.env)/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c)&&(s.has(c)||a.has(c)||o.push([c,p]));let l=[...o.map(([c,p])=>({kind:"scalar",name:c,value:p})),...Array.from(s,c=>({kind:"indexed",name:c})),...Array.from(a,c=>({kind:"associative",name:c}))];l.sort((c,p)=>c.namep.name));let u=new st(e.limits.maxOutputSize,"set");for(let c of l)e.executionScope.consumeWork(1,"set variable listing"),c.kind==="scalar"?(u.append(c.name).append("="),u.reserve(DO(c.value)),u.append(Bt(c.value))):c.kind==="indexed"?hT(e,u,c.name):dT(e,u,c.name),u.append(` `);return We(u.build())}let r=[],n=()=>r.length>0?We(r.join("")):rt,i=0;for(;i1&&(s[0]==="-"||s[0]==="+")&&s[1]!=="-"){let a=s[0]==="-",o=0;for(let l=1;l0){let a=Number.parseInt(t[0],10);if(Number.isNaN(a)||a<0){let o=`bash: shift: ${t[0]}: numeric argument required `;if(e.state.options.posix)throw new cn(1,"",o);return Z(o)}r=a}let n=Number.parseInt(e.state.env.get("#")||"0",10);if(r>n){let a=`bash: shift: shift count out of range `;if(e.state.options.posix)throw new cn(1,"",a);return Z(a)}if(r===0)return rt;let i=[];for(let a=1;a<=n;a++)i.push(e.state.env.get(String(a))||"");let s=i.slice(r);for(let a=1;a<=n;a++)e.state.env.delete(String(a));for(let a=0;a0&&r[0]==="--"&&(r=r.slice(1)),r.length===0)return Q("",`bash: source: filename argument required `,2);let n=r[0],i=null;if(n.includes("/")){let l=e.fs.resolvePath(e.state.cwd,n);try{i=await e.fs.readFile(l)}catch{}}else{let l=(e.state.env.get("PATH")||"").split(":").filter(u=>u);for(let u of l){let c=e.fs.resolvePath(e.state.cwd,`${u}/${n}`);try{if((await e.fs.stat(c)).isDirectory)continue;i=await e.fs.readFile(c);break}catch{}}if(i===null){let u=e.fs.resolvePath(e.state.cwd,n);try{i=await e.fs.readFile(u)}catch{}}}if(i===null)return Z(`bash: ${n}: No such file or directory `);let s=new Map;if(r.length>1){for(let u=1;u<=9;u++)s.set(String(u),e.state.env.get(String(u)));s.set("#",e.state.env.get("#")),s.set("@",e.state.env.get("@"));let l=r.slice(1);e.state.env.set("#",String(l.length)),e.state.env.set("@",l.join(" "));for(let u=0;u{if(e.state.sourceDepth--,e.state.currentSource=a,r.length>1)for(let[l,u]of s)u===void 0?e.state.env.delete(l):e.state.env.set(l,u)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new C(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,"recursion");e.state.currentSource=n;try{let l=Li(i),u=await e.executeScript(l);return o(),u}catch(l){if(o(),l instanceof ze)throw l;if(l instanceof rn)return Q(l.stdout,l.stderr,l.exitCode);if(l.name==="ParseException")return Z(`bash: ${n}: ${l.message} `);throw l}}function $0(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function bT(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function O0(e,t){if(bT(t))return null;try{return await qe(e,ct(new Be,t).expression)}catch{let r=parseInt(t,10);return Number.isNaN(r)?0:r}}function T0(e,t){if(e.state.localVarStack?.has(t)){let r=cc(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let n=e.state.localVarStack?.get(t);if(!n||n.length===0)Gl(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),gc(e,t);else{let i=n[n.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),Gl(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let n=e.state.localScopes[r];if(n.has(t)){let i=n.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t);let s=!1;for(let a=r-1;a>=0;a--)if(e.state.localScopes[a].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,a+1),s=!0;break}return s||Gl(e,t),!0}}return!1}function gc(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let r=e.state.tempEnvBindings.length-1;r>=0;r--){let n=e.state.tempEnvBindings[r];if(n.has(t)){let i=n.get(t);return i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t),!0}}return!1}async function I0(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let r=t.slice(1,-1);return Qe(e,new Be().parseWordFromString(r,!0,!1))}return t.includes("$")?Qe(e,new Be().parseWordFromString(t,!1,!1)):t}async function wT(e,t){let r="both",n="",i=0;for(let s of t){if(s==="-v"){r="variable";continue}if(s==="-f"){r="function";continue}if(r==="function"){e.state.functions.delete(s);continue}if(r==="variable"){let u=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(u){let h=u[1],f=u[2];if(Lr(e,h)){n+=`bash: unset: ${h}: cannot unset: readonly variable `,i=1;continue}if(f==="@"||f==="*"){na(e,h),e.state.env.delete(h);continue}let d=e.state.associativeArrays?.has(h);if(d){mi(e,h,await I0(e,f));continue}let m=oi(e,h),g=e.state.declaredVars?.has(h);if((e.state.env.has(h)||g)&&!m&&!d){n+=`bash: unset: ${h}: not an array variable `,i=1;continue}let v=await O0(e,f);if(v===null&&m){n+=`bash: unset: ${f}: not a valid identifier `,i=1;continue}if(v===null)continue;if(v<0){let y=Te(e,h),x=y.length,b=e.state.currentLine;if(x===0){n+=`bash: line ${b}: unset: [${v}]: bad array subscript `,i=1;continue}let w=x+v;if(w<0){n+=`bash: line ${b}: unset: [${v}]: bad array subscript `,i=1;continue}let E=y[w][0];mi(e,h,E);continue}mi(e,h,v);continue}if(!$0(s)){n+=`bash: unset: \`${s}': not a valid identifier `,i=1;continue}let c=s;if(dt(e,s)){let h=Jr(e,s);h&&h!==s&&(c=h)}if(Lr(e,c)){n+=`bash: unset: ${c}: cannot unset: readonly variable `,i=1;continue}na(e,c);let p=m0(e,c);if(p!==void 0&&p!==e.state.callDepth)T0(e,c);else if(e.state.fullyUnsetLocals?.has(c))e.state.env.delete(c);else if(p!==void 0){let h=e.state.accessedTempEnvVars?.has(c),f=e.state.mutatedTempEnvVars?.has(c);if((h||f)&&e.state.localVarStack?.has(c)){let d=cc(e,c);d?d.value===void 0?e.state.env.delete(c):e.state.env.set(c,d.value):e.state.env.delete(c)}else e.state.env.delete(c)}else gc(e,c)||e.state.env.delete(c);e.state.exportedVars?.delete(c);continue}let a=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let u=a[1],c=a[2];if(Lr(e,u)){n+=`bash: unset: ${u}: cannot unset: readonly variable `,i=1;continue}if(c==="@"||c==="*"){na(e,u),e.state.env.delete(u);continue}let p=e.state.associativeArrays?.has(u);if(p){mi(e,u,await I0(e,c));continue}let h=oi(e,u);if(e.state.env.has(u)&&!h&&!p){n+=`bash: unset: ${u}: not an array variable `,i=1;continue}let f=await O0(e,c);if(f===null&&h){n+=`bash: unset: ${c}: not a valid identifier `,i=1;continue}if(f===null)continue;if(f<0){let d=Te(e,u),m=d.length,g=e.state.currentLine;if(m===0){n+=`bash: line ${g}: unset: [${f}]: bad array subscript `,i=1;continue}let v=m+f;if(v<0){n+=`bash: line ${g}: unset: [${f}]: bad array subscript `,i=1;continue}let y=d[v][0];mi(e,u,y);continue}mi(e,u,f);continue}if(!$0(s)){n+=`bash: unset: \`${s}': not a valid identifier `,i=1;continue}let o=s;if(dt(e,s)){let u=Jr(e,s);u&&u!==s&&(o=u)}if(Lr(e,o)){n+=`bash: unset: ${o}: cannot unset: readonly variable `,i=1;continue}na(e,o);let l=m0(e,o);if(l!==void 0&&l!==e.state.callDepth)T0(e,o);else if(e.state.fullyUnsetLocals?.has(o))e.state.env.delete(o);else if(l!==void 0){let u=e.state.accessedTempEnvVars?.has(o),c=e.state.mutatedTempEnvVars?.has(o);if((u||c)&&e.state.localVarStack?.has(o)){let p=cc(e,o);p?p.value===void 0?e.state.env.delete(o):e.state.env.set(o,p.value):e.state.env.delete(o)}else e.state.env.delete(o)}else gc(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(s)}return Q("",n,i)}wt(),H();function Qr(e,t,r,n){let i=r+q(t)+1;if(i>n)throw new C(`shopt: output size limit exceeded (${n} bytes)`,"output_size");return e.push(t),i}var yc=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],ET="autocd.cdable_vars.cdspell.checkhash.checkjobs.checkwinsize.cmdhist.compat31.compat32.compat40.compat41.compat42.compat43.compat44.complete_fullquote.direxpand.dirspell.execfail.extdebug.extquote.force_fignore.globasciiranges.gnu_errfmt.histappend.histreedit.histverify.hostcomplete.huponexit.inherit_errexit.interactive_comments.lithist.localvar_inherit.localvar_unset.login_shell.mailwarn.no_empty_cmd_completion.progcomp.progcomp_alias.promptvars.restricted_shell.shift_verbose.sourcepath".split(".");function aa(e){return yc.includes(e)}function ST(e){return ET.includes(e)}function AT(e,t){let r=e.limits.maxArrayElements;if(t.length>r)throw new C(`shopt: argument limit exceeded (${r})`,"array_elements");let n=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),i=!1,s=!1,a=!1,o=!1,l=!1,u=[],c=0;for(;c1){for(let v=1;v0?`${v.join(` `)} `:"",stderr:""}}let g=[];for(let v of yc){let y=e.state.shoptOptions[v];g.push(a?`shopt ${y?"-s":"-u"} ${v}`:`${v} ${y?"on":"off"}`)}return{exitCode:0,stdout:`${g.join(` `)} `,stderr:""}}let p=!1,h=[],f=0,d=[],m=0;for(let g of u){if(!aa(g)&&!ST(g)){f=Qr(h,`shopt: ${g}: invalid shell option name`,f,n),p=!0;continue}if(i)aa(g)&&(e.state.shoptOptions[g]=!0,xd(e));else if(s)aa(g)&&(e.state.shoptOptions[g]=!1,xd(e));else if(aa(g)){let v=e.state.shoptOptions[g];o?v||(p=!0):a?(m=Qr(d,`shopt ${v?"-s":"-u"} ${g}`,m,n),v||(p=!0)):(m=Qr(d,`${g} ${v?"on":"off"}`,m,n),v||(p=!0))}else o?p=!0:a?(m=Qr(d,`shopt -u ${g}`,m,n),p=!0):(m=Qr(d,`${g} off`,m,n),p=!0)}return{exitCode:+!!p,stdout:d.length>0?`${d.join(` `)} `:"",stderr:h.length>0?`${h.join(` `)} `:""}}function CT(e,t,r,n,i,s){let a=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),o=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["posix","posix"],["allexport","allexport"],["noclobber","noclobber"],["noglob","noglob"],["noexec","noexec"],["vi","vi"],["emacs","emacs"]]),l=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"],u=[...o.keys(),...l].sort();if(t.length===0){let m=[];for(let g of u){let v=l.includes(g),y=o.get(g),x=v||!y?!1:e.state.options[y];r&&!x||n&&x||m.push(i?`set ${x?"-o":"+o"} ${g}`:`${g} ${x?"on":"off"}`)}return{exitCode:0,stdout:m.length>0?`${m.join(` `)} `:"",stderr:""}}let c=!1,p=[],h=0,f=[],d=0;for(let m of t){let g=o.has(m),v=l.includes(m);if(!g&&!v){h=Qr(p,`shopt: ${m}: invalid option name`,h,a),c=!0;continue}if(v){r||n||(s?c=!0:i?(d=Qr(f,`set +o ${m}`,d,a),c=!0):(d=Qr(f,`${m} off`,d,a),c=!0));continue}let y=o.get(m);if(y)if(r)y==="vi"?e.state.options.emacs=!1:y==="emacs"&&(e.state.options.vi=!1),e.state.options[y]=!0,Ha(e);else if(n)e.state.options[y]=!1,Ha(e);else{let x=e.state.options[y];s?x||(c=!0):i?(d=Qr(f,`set ${x?"-o":"+o"} ${m}`,d,a),x||(c=!0)):(d=Qr(f,`${m} ${x?"on":"off"}`,d,a),x||(c=!0))}}return{exitCode:+!!c,stdout:f.length>0?`${f.join(` `)} `:"",stderr:p.length>0?`${p.join(` `)} `:""}}function $a(e,t){return e===`/bin/${t}`||e===`/usr/bin/${t}`}async function kT(e,t,r){if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(i))return{error:"not_found",path:i};try{let s=await e.fs.stat(i);if(s.isDirectory)return{error:"permission_denied",path:i};let a=i.split("/").pop()||t,o=e.commands.get(a);return o&&$a(i,a)?{cmd:o,path:i}:s.mode&73?{script:!0,path:i}:{error:"permission_denied",path:i}}catch{return{error:"not_found",path:i}}}if(!r&&e.state.hashTable){let i=e.state.hashTable.get(t);if(i){try{let s=await e.fs.stat(i);if(!s.isDirectory){let a=e.commands.get(t);if(a&&$a(i,t))return{cmd:a,path:i};if(s.mode&73)return{script:!0,path:i}}}catch{}e.state.hashTable.delete(t)}}let n=(r??e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let i of n){if(!i)continue;let s=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(s))try{let a=await e.fs.stat(s);if(a.isDirectory)continue;let o=!!(a.mode&73),l=e.commands.get(t),u=$a(s,t);if(l&&u)return{cmd:l,path:s};if(o&&(l&&!u||!l))return{script:!0,path:s}}catch{}}if(!await e.fs.exists("/usr/bin")){let i=e.commands.get(t);if(i)return{cmd:i,path:`/usr/bin/${t}`}}return null}async function s4(e,t){let r=[];if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let s=await e.fs.stat(i);s.isDirectory||s.mode&73&&r.push(t)}catch{}return r}let n=(e.state.env.get("PATH")||"/usr/bin:/bin").split(":");for(let i of n){if(!i)continue;let s=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if($a(s,t)&&e.commands.has(t)){r.push(s);continue}if(await e.fs.exists(s)){try{let a=await e.fs.stat(s);if(a.isDirectory||!(a.mode&73))continue}catch{continue}r.push(i.startsWith("/")?s:`${i}/${t}`)}}return r}vn();function NT(e){return typeof e=="object"&&!!e&&"then"in e&&typeof e.then=="function"}function Ye(e,t,r,n){return((...i)=>{Zt(t,r,`${n} call`);let s=e(...i);return NT(s)?s.then(a=>(Zt(t,r,`${n} post-await`),a),a=>{throw Zt(t,r,`${n} post-await`),a}):(Zt(t,r,`${n} return`),s)})}function $T(e,t,r){let n={readFile:Ye(e.readFile.bind(e),t,r,"fs.readFile"),...typeof e.readFileBytes=="function"?{readFileBytes:Ye(e.readFileBytes.bind(e),t,r,"fs.readFileBytes")}:Object.create(null),readFileBuffer:Ye(e.readFileBuffer.bind(e),t,r,"fs.readFileBuffer"),writeFile:Ye(e.writeFile.bind(e),t,r,"fs.writeFile"),appendFile:Ye(e.appendFile.bind(e),t,r,"fs.appendFile"),exists:Ye(e.exists.bind(e),t,r,"fs.exists"),stat:Ye(e.stat.bind(e),t,r,"fs.stat"),mkdir:Ye(e.mkdir.bind(e),t,r,"fs.mkdir"),readdir:Ye(e.readdir.bind(e),t,r,"fs.readdir"),rm:Ye(e.rm.bind(e),t,r,"fs.rm"),cp:Ye(e.cp.bind(e),t,r,"fs.cp"),mv:Ye(e.mv.bind(e),t,r,"fs.mv"),resolvePath:Ye(e.resolvePath.bind(e),t,r,"fs.resolvePath"),getAllPaths:Ye(e.getAllPaths.bind(e),t,r,"fs.getAllPaths"),chmod:Ye(e.chmod.bind(e),t,r,"fs.chmod"),symlink:Ye(e.symlink.bind(e),t,r,"fs.symlink"),link:Ye(e.link.bind(e),t,r,"fs.link"),readlink:Ye(e.readlink.bind(e),t,r,"fs.readlink"),lstat:Ye(e.lstat.bind(e),t,r,"fs.lstat"),realpath:Ye(e.realpath.bind(e),t,r,"fs.realpath"),utimes:Ye(e.utimes.bind(e),t,r,"fs.utimes")};return e.readdirWithFileTypes&&(n.readdirWithFileTypes=Ye(e.readdirWithFileTypes.bind(e),t,r,"fs.readdirWithFileTypes")),n}function R0(e,t){if(!e.requireDefenseContext)return e;let r=`command:${t}`,n=Object.getOwnPropertyDescriptors(e);n.fs={value:$T(e.fs,e.requireDefenseContext,r),enumerable:!0,configurable:!0,writable:!0};let i=Object.defineProperties(Object.create(Object.getPrototypeOf(e)),n);return e.exec&&(i.exec=Ye(e.exec,e.requireDefenseContext,r,"exec")),e.origCommand&&(i.origCommand=Ye(e.origCommand,e.requireDefenseContext,r,"origCommand")),e.fetch&&(i.fetch=Ye(e.fetch,e.requireDefenseContext,r,"fetch")),e.sleep&&(i.sleep=Ye(e.sleep,e.requireDefenseContext,r,"sleep")),e.getRegisteredCommands&&(i.getRegisteredCommands=Ye(e.getRegisteredCommands,e.requireDefenseContext,r,"getRegisteredCommands")),i}H(),Er(),Et(),H(),H();var P0="+ ";async function a4(e){let t=e.state.env.get("PS4");if(t===void 0)return P0;if(t==="")return"";let r=e.state.options.xtrace;e.state.options.xtrace=!1;try{return await Qe(e,new Be().parseWordFromString(t,!1,!1))}catch(n){if(n instanceof lt&&!n.fatal)return t;if(n instanceof Nt||n instanceof Error&&n.name==="AbortError")throw n;return e.state.expansionStderr=`${e.state.expansionStderr||""}bash: ${t}: bad substitution `,t||P0}finally{e.state.options.xtrace=r}}function OT(e){return e.map(t=>TT(t)).join(" ")}function TT(e){if(e==="")return"''";if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let t=/[\x00-\x1f\x7f]/.test(e),r=e.includes(` `),n=e.includes(" "),i=e.includes("\\"),s=e.includes("'");if(t||r||n||i){let a="";for(let o of e){let l=o.charCodeAt(0);a+=o===` `?"\\n":o===" "?"\\t":o==="\\"?"\\\\":o==="'"?"'":o==='"'?'"':l<32||l===127?l<256?`\\x${l.toString(16).padStart(2,"0")}`:`\\u${l.toString(16).padStart(4,"0")}`:o}return`$'${a}'`}return s?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function IT(e,t,r){return e.state.options.xtrace?`${await a4(e)}${OT([t,...r])} `:""}async function RT(e,t,r){return e.state.options.xtrace?`${await a4(e)}${t}=${r} `:""}function Po(e,t,r){return Pi([t,r],"",e.limits.maxStringLength,"array assignment")}async function PT(e,t){let r=new Map,n="";for(let i of t.assignments){let s=i.name;if(i.array){let u=await DT(e,t,s,i.array,i.append,r);if(u.error)return{continueToNext:!1,xtraceOutput:n,tempAssignments:r,error:u.error};if(n+=u.xtraceOutput,u.continueToNext)continue}let a=i.value?await Qe(e,i.value):"";if(s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:n,tempAssignments:r,error:Q("",`bash: ${s}: bad array subscript `,1)};let o=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let u=await zT(e,t,o[1],o[2],a,i.append,r);if(u.error)return{continueToNext:!1,xtraceOutput:n,tempAssignments:r,error:u.error};if(u.continueToNext)continue}let l=await BT(e,t,s,a,i.append,r);if(l.error)return{continueToNext:!1,xtraceOutput:n,tempAssignments:r,error:l.error};n+=l.xtraceOutput,l.continueToNext}return{continueToNext:!1,xtraceOutput:n,tempAssignments:r}}async function DT(e,t,r,n,i,s){let a="";if(/\[.+\]$/.test(r))return{continueToNext:!1,xtraceOutput:"",error:Q("",`bash: ${r}: cannot assign list to array member `,1)};if(dt(e,r)){let d=No(e,r);if(d===void 0||d==="")throw new ze(1,"","");let m=Jr(e,r);if(m&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(m))return{continueToNext:!1,xtraceOutput:"",error:Q("",`bash: ${r}: cannot assign list to array member `,1)}}if(Lr(e,r)){if(t.name)return a+=`bash: ${r}: readonly variable `,{continueToNext:!0,xtraceOutput:a};let d=ft(e,r);if(d)return{continueToNext:!1,xtraceOutput:"",error:d}}let o=e.state.associativeArrays?.has(r),l=or(e,r),u=l?gn(l):void 0,c=e.state.env.get(r),p=()=>{e.state.arrays??=new Map,u?e.state.arrays.set(r,u):e.state.arrays.delete(r),c===void 0?e.state.env.delete(r):e.state.env.set(r,c)},h=LT(n),f=()=>{ar(e,r),e.state.env.delete(r)};try{o&&h?await MT(e,t,r,n,i,f,d=>{a+=d}):h?await FT(e,r,n,i,f):await _T(e,r,n,i,f)}catch(d){throw p(),d}if(t.name){s.set(r,e.state.env.get(r));let d=`(${n.map(m=>Co(m)).join(" ")})`;e.state.env.set(r,d)}return{continueToNext:!0,xtraceOutput:a}}function LT(e){return e.some(t=>{if(t.parts.length>=2){let r=t.parts[0],n=t.parts[1];if(r.type!=="Glob"||!r.pattern.startsWith("["))return!1;if(r.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(t.parts.length<3)return!1;let i=t.parts[2];return i.type==="Literal"?i.value.startsWith("]=")||i.value.startsWith("]+="):!1}return n.type==="Literal"?n.value.startsWith("]")?n.value.startsWith("]=")||n.value.startsWith("]+="):r.pattern.endsWith("]")?n.value.startsWith("=")||n.value.startsWith("+="):!1:!1}return!1})}async function MT(e,t,r,n,i,s,a){let o=[];for(let l of n){if(o.length>=e.limits.maxArrayElements)throw new C(`array element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");let u=r3(l);if(u){let{key:c,valueParts:p,append:h}=u,f;p.length>0?(f=await Qe(e,{type:"Word",parts:p}),p.every(d=>d.type==="Literal"||d.type==="TildeExpansion")&&(f=Is(e,f))):f="",o.push({type:"keyed",key:c,value:f,append:h})}else{let c=await Qe(e,l);o.push({type:"invalid",expandedValue:c})}}e.executionScope.consumeWork(o.length,"associative array assignment"),i||s();for(let l of o)if(l.type==="keyed")if(l.append){let u=tt(e,r,l.key)??"";Ce(e,r,l.key,Po(e,u,l.value),"associative")}else Ce(e,r,l.key,l.value,"associative");else a(`bash: line ${t.line??e.state.currentLine??1}: ${r}: ${l.expandedValue}: must use subscript when assigning associative array `)}async function FT(e,t,r,n,i){let s=[],a=0;for(let l of r){let u=r3(l);if(u){if(a>=e.limits.maxArrayElements)throw new C(`array element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");let{key:c,valueParts:p,append:h}=u,f;p.length>0?(f=await Qe(e,{type:"Word",parts:p}),p.every(d=>d.type==="Literal"||d.type==="TildeExpansion")&&(f=Is(e,f))):f="",s.push({type:"keyed",indexExpr:c,value:f,append:h}),a++}else{let c=await li(e,l);if(c.values.length>e.limits.maxArrayElements-a)throw new C(`array element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");s.push({type:"non-keyed",values:c.values}),a+=c.values.length}}e.executionScope.consumeWork(a,"indexed array assignment"),n||i();let o=0;for(let l of s)if(l.type==="keyed"){let u;try{u=await qe(e,ct(new Be,l.indexExpr).expression,!1)}catch{if(/^-?\d+$/.test(l.indexExpr))u=Number.parseInt(l.indexExpr,10);else{let c=e.state.env.get(l.indexExpr);u=c?Number.parseInt(c,10):0,Number.isNaN(u)&&(u=0)}}if(l.append){let c=tt(e,t,u)??"";Ce(e,t,u,Po(e,c,l.value))}else Ce(e,t,u,l.value);o=u+1}else for(let u of l.values)Ce(e,t,o++,u)}async function _T(e,t,r,n,i){let s=[];for(let o of r){let l=await li(e,o);for(let u of l.values){if(s.length>=e.limits.maxArrayElements)throw new C(`array element limit exceeded (${e.limits.maxArrayElements})`,"array_elements");s.push(u)}}let a=0;if(e.executionScope.consumeWork(s.length,"indexed array assignment"),n){let o=Te(e,t);if(o.length>0)a=Math.max(...o.map(([l])=>typeof l=="number"?l:0))+1;else{let l=e.state.env.get(t);l!==void 0&&(Ce(e,t,0,l),e.state.env.delete(t),a=1)}}else i();for(let o=0;o=2&&(n=r.slice(1,-1));let i;if(/^-?\d+$/.test(n))i=Number.parseInt(n,10);else{try{i=await qe(e,ct(new Be,n).expression,!1)}catch(s){if(s instanceof ze)throw s;if(s instanceof lt){let o=`bash: line ${e.state.currentLine}: ${r}: ${s.message} `;if(s.fatal)throw new ze(1,"",o);return{index:0,error:Q("",o,1)}}let a=e.state.currentLine;return{index:0,error:Q("",`bash: line ${a}: ${t}[${r}]: bad array subscript `,1)}}Number.isNaN(i)&&(i=0)}if(i<0){let s=Te(e,t);if(s.length===0){let a=e.state.currentLine;return{index:0,error:Q("",`bash: line ${a}: ${t}[${r}]: bad array subscript `,1)}}if(i=Math.max(...s.map(([a])=>typeof a=="number"?a:0))+1+i,i<0){let a=e.state.currentLine;return{index:0,error:Q("",`bash: line ${a}: ${t}[${r}]: bad array subscript `,1)}}}return{index:i}}async function BT(e,t,r,n,i,s){let a="",o=r,l=null;if(dt(e,r)){let p=v3(e,r,n);if(p===void 0)return{continueToNext:!1,xtraceOutput:"",error:Q("",`bash: ${r}: circular name reference `,1)};if(p===null)return{continueToNext:!0,xtraceOutput:""};o=p;let h=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);h&&(l={arrayName:h[1],subscriptExpr:h[2]},o=h[1])}if(Lr(e,o)){if(t.name)return a+=`bash: ${o}: readonly variable `,{continueToNext:!0,xtraceOutput:a};let p=ft(e,o);if(p)return{continueToNext:!1,xtraceOutput:"",error:p}}let u;if(mc(e,o))try{let p=new Be;if(i){let h=ct(p,`(${e.state.env.get(o)||"0"}) + (${n})`);u=String(await qe(e,h.expression))}else{let h=ct(p,n);u=String(await qe(e,h.expression))}}catch{u="0"}else{let p=oi(e,o)?tt(e,o,0):e.state.env.get(o);u=i?Po(e,p||"",n):n}u=Na(e,o,u),a+=await RT(e,o,u);let c;return l?c=await UT(e,l):oi(e,o)&&(c="0"),t.name?c===void 0&&(s.set(o,e.state.env.get(o)),e.state.env.set(o,u)):(c===void 0?e.state.env.set(o,u):Ce(e,o,c,u),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(o)),e.state.tempEnvBindings?.some(p=>p.has(o))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(o))),{continueToNext:!1,xtraceOutput:a}}async function UT(e,t){let{arrayName:r,subscriptExpr:n}=t;if(e.state.associativeArrays?.has(r))return o4(e,n);let i;if(/^-?\d+$/.test(n))i=Number.parseInt(n,10);else{try{i=await qe(e,ct(new Be,n).expression,!1)}catch{let s=e.state.env.get(n);i=s?Number.parseInt(s,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let s=Te(e,r);s.length>0&&(i=Math.max(...s.map(a=>a[0]))+1+i)}return String(i)}async function WT(e,t,r,n){let i=!1,s=!1,a=!1,o=!1,l=!1,u=[];for(let m of t)if(m.startsWith("-")&&m.length>1)for(let g of m.slice(1))g==="t"?i=!0:g==="p"?s=!0:g==="P"?a=!0:g==="a"?o=!0:g==="f"&&(l=!0);else u.push(m);let c="",p="",h=0,f=!1,d=!1;for(let m of u){let g=!1;if(a){if(o){let x=await n(m);if(x.length>0){for(let b of x)c+=`${b} `;f=!0,g=!0}}else{let x=await r(m);x&&(c+=`${x} `,f=!0,g=!0)}g||(d=!0);continue}let v=!l&&e.state.functions.has(m);if(o&&v){if(!s)if(i)c+=`function `;else{let x=e.state.functions.get(m),b=x?D0(m,x):`${m} is a function `;c+=b}g=!0}let y=e.state.env.get(`BASH_ALIAS_${m}`);if(!(y!==void 0&&(o||!g)&&(s||(c+=i?`alias `:`${m} is aliased to \`${y}' `),g=!0,!o)||q3.has(m)&&(o||!g)&&(s||(c+=i?`keyword `:`${m} is a shell keyword `),g=!0,!o))){if(!o&&v&&!g){if(!s)if(i)c+=`function `;else{let x=e.state.functions.get(m),b=x?D0(m,x):`${m} is a function `;c+=b}g=!0;continue}if(!(To.has(m)&&(o||!g)&&(s||(c+=i?`builtin `:`${m} is a shell builtin `),g=!0,!o))){if(o){let x=await n(m);for(let b of x)c+=s?`${b} `:i?`file `:`${m} is ${b} `,f=!0,g=!0}else if(!g){let x=await r(m);x&&(c+=s?`${x} `:i?`file `:`${m} is ${x} `,f=!0,g=!0)}if(!g&&(d=!0,!i&&!s)){let x=!0;if(m.includes("/")){let b=e.fs.resolvePath(e.state.cwd,m);await e.fs.exists(b)&&(x=!1)}x&&(p+=`bash: type: ${m}: not found `)}}}}return h=s?d&&!f?1:0:+!!d,Q(c,p,h)}function D0(e,t){let r;return r=t.body.type==="Group"?t.body.body.map(n=>Rs(n)).join("; "):Rs(t.body),`${e} is a function ${e} () { ${r} } `}function Rs(e){if(Array.isArray(e))return e.map(t=>Rs(t)).join("; ");if(e.type==="Statement"){let t=[];for(let r=0;rRs(t)).join("; ")}; }`:"..."}function L0(e){return e.parts.map(u4).join("")}function u4(e){switch(e.type){case"Literal":return e.value;case"Escaped":return`\\${e.value}`;case"SingleQuoted":return`'${e.value}'`;case"DoubleQuoted":return`"${e.parts.map(u4).join("")}"`;default:return Tt(J.word([e]))}}function jT(e){let t=e.commands.map(r=>Rs(r));return(e.negated?"! ":"")+t.join(" | ")}async function qT(e,t,r,n){let i="",s="",a=0;for(let o of t){if(!o){a=1;continue}let l=e.state.env.get(`BASH_ALIAS_${o}`);if(l!==void 0)i+=n?`${o} is an alias for "${l}" `:`alias ${o}='${l}' `;else if(q3.has(o))i+=n?`${o} is a shell keyword `:`${o} `;else if(To.has(o))i+=n?`${o} is a shell builtin `:`${o} `;else if(e.state.functions.has(o))i+=n?`${o} is a function `:`${o} `;else if(o.includes("/")){let u=e.fs.resolvePath(e.state.cwd,o),c=!1;if(await e.fs.exists(u))try{let p=await e.fs.stat(u);p.isDirectory||p.mode&73&&(i+=n?`${o} is ${o} `:`${o} `,c=!0)}catch{}c||(n&&(s+=`${o}: not found `),a=1)}else if(e.commands.has(o)){let u=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":"),c=null;for(let p of u){if(!p)continue;let h=`${p}/${o}`;try{let f=await e.fs.stat(h);if(!f.isDirectory&&f.mode&73){c=h;break}}catch{}}c||=`/usr/bin/${o}`,i+=n?`${o} is ${c} `:`${c} `}else n&&(s+=`${o}: not found `),a=1}return Q(i,s,a)}async function GT(e,t){if(t.includes("/")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!(i.mode&73))return null}catch{return null}return t}return null}let r=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let n of r){if(!n)continue;let i=`${n.startsWith("/")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(i)){try{let s=await e.fs.stat(i);if(s.isDirectory||!(s.mode&73))continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n==="/usr/bin"||n==="/bin")return`${n}/${t}`;return`/usr/bin/${t}`}return null}function M0(e,t){let r=!0,n=e.signal?new AbortController:void 0,i=new WeakMap,s=()=>{if(!r)throw new bt("",`bash: ${t} used its context after cancellation `)},a=p=>{if(p===null||typeof p!="object"&&typeof p!="function")return p;let h=i.get(p);if(h!==void 0)return h;if(typeof p=="object"&&QA(p))return p;if(p instanceof Uint8Array){let g=new Uint8Array(p);return i.set(p,g),g}if(p instanceof ArrayBuffer){let g=p.slice(0);return i.set(p,g),g}if(p instanceof Promise){let g=p.then(v=>(s(),a(v)));return i.set(p,g),g}if(typeof p=="function"){let g=function(...v){return s(),a(Reflect.apply(p,this,v))};return i.set(p,g),g}let f=Object.getPrototypeOf(p);if(Array.isArray(p)||f===Object.prototype||f===null){let g=Array.isArray(p)?[]:Object.create(f);i.set(p,g);let v=Object.getOwnPropertyDescriptors(p);for(let y of Object.values(v)){if("value"in y){let x=y.value;y.value=typeof x=="function"?(...b)=>(s(),a(Reflect.apply(x,p,b))):a(x)}if(y.get){let x=y.get;y.get=()=>(s(),a(Reflect.apply(x,p,[])))}if(y.set){let x=y.set;y.set=b=>{s(),Reflect.apply(x,p,[b])}}}return Object.defineProperties(g,v),g}let d=new Map,m=new u7(p,{get(g,v){if(s(),v==="constructor"||v==="prototype"||v==="__proto__")throw Error(`${t}: unsafe context property access`);let y=Reflect.get(g,v,g);if(typeof y!="function")return a(y);if(d.has(v))return d.get(v);let x=(...b)=>(s(),a(Reflect.apply(y,g,b)));return d.set(v,x),x},set(g,v,y){if(s(),v==="constructor"||v==="prototype"||v==="__proto__")throw Error(`${t}: unsafe context property access`);return Reflect.set(g,v,y,g)}});return i.set(p,m),m},o=p=>a(p),l=p=>p&&((...h)=>(s(),a(p(...h)))),u=p=>({value:p,enumerable:!0,configurable:!0,writable:!0}),c=Object.getOwnPropertyDescriptors(e);return Object.assign(c,{fs:u(o(e.fs)),env:u(o(e.env)),limits:u(Object.freeze({...e.limits})),exportedEnv:u(e.exportedEnv?Object.freeze({...e.exportedEnv}):void 0),executionScope:u(e.executionScope?o(e.executionScope):void 0),fileDescriptors:u(e.fileDescriptors?o(e.fileDescriptors):void 0),coverage:u(e.coverage?o(e.coverage):void 0),assignShellVariable:u(l(e.assignShellVariable)),exec:u(l(e.exec)),origCommand:u(l(e.origCommand)),execWithInheritedStdin:u(l(e.execWithInheritedStdin)),fetch:u(l(e.fetch)),getRegisteredCommands:u(l(e.getRegisteredCommands)),sleep:u(l(e.sleep)),trace:u(l(e.trace)),invokeTool:u(l(e.invokeTool)),signal:u(n?.signal)}),{context:Object.defineProperties(Object.create(Object.getPrototypeOf(e)),c),revoke(){r=!1,n?.signal.aborted||n?.abort(new bt("",`bash: ${t} context revoked `))}}}async function HT(e,t,r,n,i,s){let a=i.remainingTimeMs()??t.limits.maxExecutionTimeMs,o=t.limits.maxExtensionCleanupTimeMs,l,u,c,p=Promise.resolve().then(e).then(f=>({kind:"result",result:f}),f=>({kind:"error",error:f})),h=new Promise(f=>{let d=()=>{r(),f({kind:"abort"})};u=d,s?.addEventListener("abort",d,{once:!0}),s?.aborted&&d(),l=uu(()=>{r(),f({kind:"deadline"})},a)});try{let f=await Promise.race([p,h]);if(f.kind==="result")return f.result;if(f.kind==="error")throw f.error;r();let d=await Promise.race([p.then(()=>!0),new Promise(g=>{c=uu(()=>g(!1),o)})]),m=f.kind==="deadline"?new bt("",`bash: ${n} exceeded its execution deadline `):new bt("",`bash: execution aborted `);throw d||i.poisonAfterAbort(m),m}finally{r(),cu(l),cu(c),u&&s?.removeEventListener("abort",u)}}async function VT(e,t,r,n,i,s,a,o,l=!1){let{ctx:u,runCommand:c}=e;if(u.coverage&&To.has(t)&&u.coverage.hit(`bash:builtin:${t}`),t==="export")return eT(u,r);if(t==="unset")return wT(u,r);if(t==="exit")return JO(u,r);if(t==="local")return oT(u,r);if(t==="set")return yT(u,r);if(t==="break")return _$(u,r);if(t==="continue")return _O(u,r);if(t==="return")return cT(u,r);if(t==="eval"&&u.state.options.posix)return A0(u,r,i,l);if(t==="shift")return xT(u,r);if(t==="getopts")return e4(u,r);if(t==="compgen")return vO(u,r);if(t==="complete")return MO(u,r);if(t==="compopt")return FO(u,r);if(t==="pushd")return await KO(u,r);if(t==="popd")return XO(u,r);if(t==="dirs")return YO(u,r);if(t==="source"||t===".")return vT(u,r);if(t==="read")return uT(u,r,i,o);if(t==="mapfile"||t==="readarray")return lT(u,r,i);if(t==="declare"||t==="typeset")return VO(u,r);if(t==="readonly")return ZO(u,r);if(!s){let p=u.state.functions.get(t);if(p)return Q3(u,p,r,i,void 0,l)}if(t==="__just_bash_tee_restore"){if(r.length===0||r.length>u.limits.maxArrayElements)return Z(`bash: invalid internal pipeline status restore `,2);let p=[];for(let d of r){if(!/^(?:0|[1-9][0-9]{0,2})$/.test(d))return Z(`bash: invalid internal pipeline status restore `,2);let m=Number(d);if(!Number.isSafeInteger(m)||m>255)return Z(`bash: invalid internal pipeline status restore `,2);p.push(m)}let h=p[p.length-1]??0,f=[...p].reverse().find(d=>d!==0);return{stdout:"",stderr:"",exitCode:u.state.options.pipefail&&f!==void 0?f:h,internalPipeStatusOverride:p}}if(t==="eval")return A0(u,r,i,l);if(t==="cd")return await z$(u,r);if(t===":"||t==="true")return rt;if(t==="false")return Ot(!1);if(t==="let")return aT(u,r);if(t==="command")return ZT(e,r,i,l);if(t==="builtin")return QT(e,r,i,l);if(t==="shopt")return AT(u,r);if(t==="exec"){if(r.length===0)return rt;let[p,...h]=r;return{...await c(p,h,[],i,!1,!1,-1,l),internalProducerOmitsShellPrefix:!0}}if(t==="wait")return rt;if(t==="type")return await WT(u,r,p=>GT(u,p),p=>s4(u,p));if(t==="hash")return tT(u,r);if(t==="help")return rT(u,r);if(t==="["||t==="test"){let p=r;if(t==="["){if(r[r.length-1]!=="]")return Z("[: missing `]'\n",2);p=r.slice(0,-1)}return Ca(u,p)}return null}async function ZT(e,t,r,n=!1){let{ctx:i,runCommand:s}=e;if(t.length===0)return rt;let a=!1,o=!1,l=!1,u=t;for(;u.length>0&&u[0].startsWith("-");){let h=u[0];if(h==="--"){u=u.slice(1);break}for(let f of h.slice(1))f==="p"?a=!0:f==="V"?o=!0:f==="v"&&(l=!0);u=u.slice(1)}if(u.length===0)return rt;if(l||o)return await qT(i,u,l,o);let[c,...p]=u;return s(c,p,[],r,!0,a,-1,n)}async function QT(e,t,r,n=!1){let{runCommand:i}=e;if(t.length===0)return rt;let s=t;if(s[0]==="--"&&(s=s.slice(1),s.length===0))return rt;let a=s[0];if(a!=="__just_bash_tee_restore"&&!To.has(a))return Z(`bash: builtin: ${a}: not a shell builtin `);let[,...o]=s;return i(a,o,[],r,!0,!1,-1,n)}async function KT(e,t,r,n,i){let{ctx:s,buildExportedEnv:a,executeUserScript:o}=e,l=await kT(s,t,i?"/usr/bin:/bin":void 0);if(!l)return M$(t)?Z(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle. `,127):Z(`bash: ${t}: command not found `,127);if("error"in l)return l.error==="permission_denied"?Z(`bash: ${t}: Permission denied `,126):Z(`bash: ${t}: No such file or directory `,127);if("script"in l)return t.includes("/")||(s.state.hashTable||(s.state.hashTable=new Map),s.state.hashTable.set(t,l.path)),await o(l.path,r,n);let{cmd:u,path:c}=l;t.includes("/")||(s.state.hashTable||(s.state.hashTable=new Map),s.state.hashTable.set(t,c));let p=n||s.state.groupStdin||"",h=!1,f=a();s.state.fileDescriptors??=new Map;let d={fs:s.fs,fsIdentity:ZA(s.fs),cwd:s.state.cwd,env:s.state.env,assignShellVariable:async(b,w,E)=>{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b))throw Error(`${b}: not a valid identifier`);let A=E===void 0?b:`${b}[${E}]`,O=v3(s,b,w);if(O===void 0)throw Error(`${b}: circular name reference`);if(O===null)return;let N=O.match(/^([a-zA-Z_][a-zA-Z0-9_]*)(?:\[(.*)\])?$/);if(!N)throw Error(`${A}: not a valid identifier`);let D=N[1],$=N[2]??E;if(Lr(s,b)||Lr(s,D))throw Error(`${D}: readonly variable`);if($===void 0)s.state.env.set(D,w);else{let L=s.state.associativeArrays?.has(D)?"associative":"indexed";if(L==="associative"){Ce(s,D,$,w,L);return}let _=await l4(s,D,$);if(_.error)throw new ze(_.error.exitCode,_.error.stdout,_.error.stderr);Ce(s,D,_.index,w,L)}},exportedEnv:f,get stdin(){return h=!0,p},limits:s.limits,executionScope:u.internalIsExtension?tC(s.executionScope):s.executionScope,exec:(b,w)=>s.execFn(b,w,!1),execWithInheritedStdin:(b,w)=>s.execFn(b,{...w,stdin:p,stdinKind:"bytes"},!0),fetch:s.fetch,getRegisteredCommands:()=>Array.from(s.commands.keys()),sleep:s.sleep,trace:s.trace,fileDescriptors:s.state.fileDescriptors,xpgEcho:s.state.shoptOptions.xpg_echo,coverage:s.coverage,signal:s.state.signal,requireDefenseContext:s.requireDefenseContext,jsBootstrapCode:s.jsBootstrapCode,invokeTool:s.invokeTool},m=u.internalOriginalCommand,g=()=>{};if(m){let b=Object.getOwnPropertyDescriptors(d);b.executionScope={value:s.executionScope,enumerable:!0,configurable:!0,writable:!0};let w=M0(Object.defineProperties(Object.create(Object.getPrototypeOf(d)),b),m.name),E=R0(w.context,m.name);g=w.revoke,d.origCommand=A=>{let O=()=>m.execute(A,E);return m.trusted?Kt.runTrustedAsync(O):Kt.runUntrustedAsync(O)}}let v=M0(d,t),y=R0(v.context,t),x=()=>{v.revoke(),g()};try{let b=()=>In(s.requireDefenseContext,"command",`${t} execution`,()=>u.execute(r,y)),w=()=>HT(b,y,x,t,s.executionScope,s.state.signal),E=u.trusted?await Kt.runTrustedAsync(w):await w();return{...E,internalStdinConsumed:E.internalStdinConsumed??(h?n.length:0)}}catch(b){if(b instanceof C||b instanceof bt||b instanceof Ae)throw b;return Z(`${t}: ${xt(ur(b))} `)}}se(),H(),Bs();async function c4(e,t){let r=e.state.inCondition;e.state.inCondition=!0;let n=new Tn(e.executionScope,"condition"),i=0;try{for(let s of t){let a=await e.executeStatement(s);n.appendResult(a),i=a.exitCode}}catch(s){throw n.prependTo(s),s}finally{e.state.inCondition=r}return n.build(i)}Er(),H(),Er();function Do(e,t,r,n){if(e instanceof fn)return t+=e.stdout,r+=e.stderr,e.levels>1&&n>1?(e.levels--,e.stdout=t,e.stderr=r,{action:"rethrow",stdout:t,stderr:r,error:e}):{action:"break",stdout:t,stderr:r};if(e instanceof dn)return t+=e.stdout,r+=e.stderr,e.levels>1&&n>1?(e.levels--,e.stdout=t,e.stderr=r,{action:"rethrow",stdout:t,stderr:r,error:e}):{action:"continue",stdout:t,stderr:r};if(e instanceof rn||e instanceof mn||e instanceof ze||e instanceof C)return e.prependOutput(t,r),{action:"rethrow",stdout:t,stderr:r,error:e};let i=ur(e);return{action:"error",stdout:t,stderr:`${r}${i} `,exitCode:1}}function p4(e,t){return e===void 0?t===""?{owns:!1}:{owns:!0,stdin:t}:{owns:!0,stdin:e}}var Xi=class{ctx;stdoutChunks=[];stderrChunks=[];totalBytes=0;constructor(e){this.ctx=e}append(e,t){let r=q(e)+q(t);r>this.ctx.limits.maxOutputSize-this.totalBytes&&Zi(`total output size exceeded (>${this.ctx.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,"output_size"),e&&this.stdoutChunks.push(e),t&&this.stderrChunks.push(t),this.totalBytes+=r}appendUnaccounted(e,t){this.ctx.executionScope.appendOutput("stdout",e,"control-flow"),this.ctx.executionScope.appendOutput("stderr",t,"control-flow"),this.append(e,t)}replace(e,t){this.stdoutChunks=[],this.stderrChunks=[],this.totalBytes=0,this.append(e,t)}get stdout(){return this.stdoutChunks.join("")}get stderr(){return this.stderrChunks.join("")}build(e){let t=this.stdout,r=this.stderr;return{stdout:t,stderr:r,exitCode:e,internalOutputAccounting:{stdout:q(t),stderr:q(r)}}}};async function xc(e,t,r){let n=0;try{for(let i of t){let s=await e.executeStatement(i);r.append(s.stdout,s.stderr),n=s.exitCode}}catch(i){if(Nm(i)||i instanceof mn||i instanceof ze||i instanceof C||i instanceof Ds)throw i.prependOutput(r.stdout,r.stderr),i;return r.appendUnaccounted("",`${ur(i)} `),r.build(1)}return r.build(n)}async function XT(e,t){return tn(e,t.redirections,"",()=>YT(e,t))}async function YT(e,t){let r=new Xi(e);for(let n of t.clauses){let i=await c4(e,n.condition);if(r.append(i.stdout,i.stderr),i.exitCode===0)return xc(e,n.body,r)}return t.elseBody?xc(e,t.elseBody,r):r.build(0)}async function JT(e,t){return tn(e,t.redirections,"",()=>eI(e,t))}async function eI(e,t){let r=new Xi(e),n=0,i=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return Z(`bash: \`${t.variable}': not a valid identifier `);let s=[];if(t.words===null)s=(e.state.env.get("@")||"").split(" ").filter(Boolean);else if(t.words.length===0)s=[];else try{for(let a of t.words){let o=await li(e,a);er(s,o.values,e.limits.maxArrayElements,"for-loop expansion")}}catch(a){if(a instanceof Ps)return{stdout:"",stderr:a.stderr,exitCode:1};throw a}e.state.loopDepth++;try{for(let a of s){i++,i>e.limits.maxLoopIterations&&Zi(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r.stdout,r.stderr),e.state.env.set(t.variable,a);try{for(let o of t.body){let l=await e.executeStatement(o);r.append(l.stdout,l.stderr),n=l.exitCode}}catch(o){let l=Do(o,r.stdout,r.stderr,e.state.loopDepth);if(r.replace(l.stdout,l.stderr),l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return r.build(l.exitCode??1);throw l.error}}}finally{e.state.loopDepth--}return r.build(n)}async function tI(e,t){return tn(e,t.redirections,"",()=>rI(e,t))}async function rI(e,t){let r=t.line;r!==void 0&&(e.state.currentLine=r);let n=new Xi(e),i=0,s=0;t.init&&await qe(e,t.init.expression),e.state.loopDepth++;try{for(;s++,s>e.limits.maxLoopIterations&&Zi(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n.stdout,n.stderr),!(t.condition&&(r!==void 0&&(e.state.currentLine=r),await qe(e,t.condition.expression)===0));){try{for(let a of t.body){let o=await e.executeStatement(a);n.append(o.stdout,o.stderr),i=o.exitCode}}catch(a){let o=Do(a,n.stdout,n.stderr,e.state.loopDepth);if(n.replace(o.stdout,o.stderr),o.action==="break")break;if(o.action==="continue"){t.update&&await qe(e,t.update.expression);continue}if(o.action==="error")return n.build(o.exitCode??1);throw o.error}t.update&&await qe(e,t.update.expression)}}finally{e.state.loopDepth--}return n.build(i)}async function nI(e,t,r=""){return tn(e,t.redirections,r,n=>iI(e,t,r,n))}async function iI(e,t,r,n){let i=new Xi(e),s=0,a=0,o=p4(n.stdin,r),l=e.state.groupStdin;o.owns&&(e.state.groupStdin=o.stdin),e.state.loopDepth++;try{for(;;){a++,a>e.limits.maxLoopIterations&&Zi(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",i.stdout,i.stderr);let u=0,c=!1,p=!1,h=e.state.inCondition;e.state.inCondition=!0;try{for(let f of t.condition){let d=await e.executeStatement(f);i.append(d.stdout,d.stderr),u=d.exitCode}}catch(f){if(f instanceof fn){if(i.append(f.stdout,f.stderr),f.levels>1&&e.state.loopDepth>1)throw f.levels--,f.stdout=i.stdout,f.stderr=i.stderr,e.state.inCondition=h,f;c=!0}else if(f instanceof dn){if(i.append(f.stdout,f.stderr),f.levels>1&&e.state.loopDepth>1)throw f.levels--,f.stdout=i.stdout,f.stderr=i.stderr,e.state.inCondition=h,f;p=!0}else throw e.state.inCondition=h,f}finally{e.state.inCondition=h}if(c)break;if(!p){if(u!==0)break;try{for(let f of t.body){let d=await e.executeStatement(f);i.append(d.stdout,d.stderr),s=d.exitCode}}catch(f){let d=Do(f,i.stdout,i.stderr,e.state.loopDepth);if(i.replace(d.stdout,d.stderr),d.action==="break")break;if(d.action==="continue")continue;if(d.action==="error")return i.build(d.exitCode??1);throw d.error}}}}finally{e.state.loopDepth--,o.owns&&(e.state.groupStdin=l)}return i.build(s)}async function sI(e,t,r=""){return tn(e,t.redirections,r,n=>aI(e,t,r,n))}async function aI(e,t,r,n){let i=new Xi(e),s=0,a=0,o=p4(n.stdin,r),l=e.state.groupStdin;o.owns&&(e.state.groupStdin=o.stdin),e.state.loopDepth++;try{for(;;){a++,a>e.limits.maxLoopIterations&&Zi(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",i.stdout,i.stderr);let u=await c4(e,t.condition);if(i.append(u.stdout,u.stderr),u.exitCode===0)break;try{for(let c of t.body){let p=await e.executeStatement(c);i.append(p.stdout,p.stderr),s=p.exitCode}}catch(c){let p=Do(c,i.stdout,i.stderr,e.state.loopDepth);if(i.replace(p.stdout,p.stderr),p.action==="break")break;if(p.action==="continue")continue;if(p.action==="error")return i.build(p.exitCode??1);throw p.error}}}finally{e.state.loopDepth--,o.owns&&(e.state.groupStdin=l)}return i.build(s)}async function oI(e,t){return tn(e,t.redirections,"",()=>lI(e,t))}async function lI(e,t){let r=new Xi(e),n=0,i=await Qe(e,t.word),s=!1;for(let a=0;a1,p=e.state.lastArg,h=e.state.groupStdin,f=e.state.groupStdinSourceFd;for(let y=0;y1)N={stdout:$.stdout,stderr:$.stderr,exitCode:$.exitCode};else if($ instanceof mn&&t.commands.length>1)N={stdout:$.stdout,stderr:$.stderr,exitCode:$.exitCode};else throw A&&(e.state.env=A,e.state.arrays=O??new Map),$}finally{c&&(w&&(h=e.state.groupStdin,f=e.state.groupStdinSourceFd),e.state.groupStdin=h,e.state.groupStdinSourceFd=f)}if(A&&(e.state.env=A,e.state.arrays=O??new Map),N=e.executionScope.accountResult(N,"pipeline",e.executionScope.outputBytesUsed-D),!b){let $=t.pipeStderr?.[y]??!1,L=N.internalOutputAccounting?.stdout??0,_=$?N.internalOutputAccounting?.stderr??0:0;rC(e.executionScope,L+_,"pipeline"),N={...N,internalOutputAccounting:{stdout:0,stderr:$?0:N.internalOutputAccounting?.stderr??0}}}o.push(N.exitCode),N.exitCode!==0&&(a=N.exitCode),b?s=N:(t.pipeStderr?.[y]??!1?i=ti(N.stderr)+Ss(N):(i=Ss(N),l+=N.stderr,u+=N.internalOutputAccounting?.stderr??0),s={stdout:"",stderr:"",exitCode:N.exitCode})}l&&(s={...s,stderr:l+s.stderr,internalOutputAccounting:{stdout:s.internalOutputAccounting?.stdout??0,stderr:u+(s.internalOutputAccounting?.stderr??0)}});let d=t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand",m=s.internalPipeStatusOverride??o;if(d){ar(e,"PIPESTATUS");for(let y=0;y[t,vc(r)])):void 0}function pI(e){if(!e)return;let t=new Map,r=new Map;for(let[n,i]of e){let s=t.get(i);s||(s=new Set(i),t.set(i,s)),r.set(n,s)}return r}function hI(e){return e?.map(t=>new Map(Array.from(t,([r,n])=>[r,n?{kind:n.kind,elements:new Map(n.elements)}:void 0])))}function fI(e){return e?new Map(Array.from(e,([t,r])=>[t,r.map(n=>({...n}))])):void 0}function h4(e){let t={env:e.env,arrays:e.arrays,cwd:e.cwd,previousDir:e.previousDir,lastExitCode:e.lastExitCode,lastArg:e.lastArg,currentLine:e.currentLine,options:e.options,shoptOptions:e.shoptOptions,fileDescriptors:e.fileDescriptors,inputFds:e.inputFds,fdAliases:e.fdAliases,closedStandardFds:e.closedStandardFds,nextFd:e.nextFd,readonlyVars:e.readonlyVars,associativeArrays:e.associativeArrays,namerefs:e.namerefs,boundNamerefs:e.boundNamerefs,invalidNamerefs:e.invalidNamerefs,integerVars:e.integerVars,lowercaseVars:e.lowercaseVars,uppercaseVars:e.uppercaseVars,exportedVars:e.exportedVars,tempExportedVars:e.tempExportedVars,localExportedVars:e.localExportedVars,declaredVars:e.declaredVars,localScopes:e.localScopes,localArrayScopes:e.localArrayScopes,localVarDepth:e.localVarDepth,localVarStack:e.localVarStack,fullyUnsetLocals:e.fullyUnsetLocals,tempEnvBindings:e.tempEnvBindings,mutatedTempEnvVars:e.mutatedTempEnvVars,accessedTempEnvVars:e.accessedTempEnvVars,functions:e.functions,callDepth:e.callDepth,sourceDepth:e.sourceDepth,callLineStack:e.callLineStack,funcNameStack:e.funcNameStack,sourceStack:e.sourceStack,currentSource:e.currentSource,inCondition:e.inCondition,loopDepth:e.loopDepth,parentHasLoopContext:e.parentHasLoopContext,errexitSafe:e.errexitSafe,directoryStack:e.directoryStack,hashTable:e.hashTable,completionSpecs:e.completionSpecs,defaultCompletionSpec:e.defaultCompletionSpec,emptyCompletionSpec:e.emptyCompletionSpec,groupStdin:e.groupStdin,groupStdinSourceFd:e.groupStdinSourceFd,bashPid:e.bashPid,expansionExitCode:e.expansionExitCode,expansionStderr:e.expansionStderr};e.env=new Map(e.env),e.arrays=qi(e.arrays),e.options={...e.options},e.shoptOptions={...e.shoptOptions},e.fileDescriptors=e.fileDescriptors?new Map(e.fileDescriptors):void 0,e.inputFds=e.inputFds?new Set(e.inputFds):void 0,e.fdAliases=pI(e.fdAliases),e.closedStandardFds=e.closedStandardFds?new Set(e.closedStandardFds):void 0,e.readonlyVars=new Set(e.readonlyVars),e.associativeArrays=new Set(e.associativeArrays),e.namerefs=new Set(e.namerefs),e.boundNamerefs=new Set(e.boundNamerefs),e.invalidNamerefs=new Set(e.invalidNamerefs),e.integerVars=new Set(e.integerVars),e.lowercaseVars=new Set(e.lowercaseVars),e.uppercaseVars=new Set(e.uppercaseVars),e.exportedVars=new Set(e.exportedVars),e.tempExportedVars=new Set(e.tempExportedVars),e.localExportedVars=e.localExportedVars?.map(n=>new Set(n)),e.declaredVars=new Set(e.declaredVars),e.localScopes=e.localScopes.map(n=>new Map(n)),e.localArrayScopes=hI(e.localArrayScopes),e.localVarDepth=e.localVarDepth?new Map(e.localVarDepth):void 0,e.localVarStack=fI(e.localVarStack),e.fullyUnsetLocals=e.fullyUnsetLocals?new Map(e.fullyUnsetLocals):void 0,e.tempEnvBindings=e.tempEnvBindings?.map(n=>new Map(n)),e.mutatedTempEnvVars=e.mutatedTempEnvVars?new Set(e.mutatedTempEnvVars):void 0,e.accessedTempEnvVars=e.accessedTempEnvVars?new Set(e.accessedTempEnvVars):void 0,e.functions=new Map(e.functions),e.callLineStack=e.callLineStack?[...e.callLineStack]:void 0,e.funcNameStack=e.funcNameStack?[...e.funcNameStack]:void 0,e.sourceStack=e.sourceStack?[...e.sourceStack]:void 0,e.directoryStack=e.directoryStack?[...e.directoryStack]:void 0,e.hashTable=e.hashTable?new Map(e.hashTable):void 0,e.completionSpecs=cI(e.completionSpecs),e.defaultCompletionSpec=vc(e.defaultCompletionSpec),e.emptyCompletionSpec=vc(e.emptyCompletionSpec);let r=!1;return()=>{r||(r=!0,Object.assign(e,t))}}async function dI(e,t,r,n,i=!1){let s=e.state.loopDepth,a=new Map;for(let l of e.state.fileDescriptors?.keys()??[]){let u=en(e,l);u&&a.set(l,u)}let o=h4(e.state);e.state.parentHasLoopContext=s>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++;try{return await tn(e,t.redirections,r,l=>mI(e,t,l.stdin??r,n,i||l.stdin!==void 0))}finally{let l=new Map;for(let[u,c]of a){let p=en(e,u),h=c.kind==="input"&&p?.kind==="input"?c.content.length-p.content.length:c.kind==="readwrite"&&p?.kind==="readwrite"&&c.path===p.path?p.position-c.position:0;if(h<=0)continue;let f=Math.min(...Ri(e,u));l.set(f,Math.max(l.get(f)??0,h))}o();for(let[u,c]of l)bs(e,u,c)}}async function mI(e,t,r,n,i){(i||r)&&(e.state.groupStdin=r);let s=new Tn(e.executionScope,"subshell"),a=0;try{for(let o of t.body){let l=await n(o);s.appendResult(l),a=l.exitCode}}catch(o){if(o instanceof C)throw s.prependTo(o),o;return o instanceof Ds||o instanceof fn||o instanceof dn?(s.append("stdout",o.stdout,o.internalOutputAccounting.stdout),s.append("stderr",o.stderr,o.internalOutputAccounting.stderr),s.build(0)):o instanceof ze||o instanceof rn||o instanceof mn?(s.append("stdout",o.stdout,o.internalOutputAccounting.stdout),s.append("stderr",o.stderr,o.internalOutputAccounting.stderr),s.build(o.exitCode)):(s.append("stderr",`${ur(o)} `),s.build(1))}return s.build(a)}async function gI(e,t,r,n,i=!1){return tn(e,t.redirections,r,s=>yI(e,t,r,n,i,s))}async function yI(e,t,r,n,i,s){let a=new Tn(e.executionScope,"group"),o=0,l=s.stdin??r,u=i||r!==""||s.stdin!==void 0,c=e.state.groupStdin;u&&(e.state.groupStdin=l);let p=()=>{(u||c!==void 0&&e.state.groupStdin===void 0)&&(e.state.groupStdin=c)};try{for(let h of t.body){let f=await n(h);a.appendResult(f),o=f.exitCode}}catch(h){if(p(),h instanceof C)throw a.prependTo(h),h;if(Nm(h)||h instanceof mn||h instanceof ze)throw h.prependOutput(a.stdout,a.stderr),h;return a.append("stderr",`${ur(h)} `),a.build(1)}return p(),a.build(o)}async function xI(e,t,r,n,i){let s;try{s=await e.fs.readFile(t)}catch{return Z(`bash: ${t}: No such file or directory `,127)}if(s.startsWith("#!")){let l=s.indexOf(` `);l!==-1&&(s=s.slice(l+1))}let a=e.state.loopDepth,o=h4(e.state);e.state.parentHasLoopContext=a>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,n&&(e.state.groupStdin=n),e.state.currentSource=t,e.state.env.set("0",t),e.state.env.set("#",String(r.length)),e.state.env.set("@",r.join(" ")),e.state.env.set("*",r.join(" "));for(let l=0;l0)throw i.prependOutput(r.stdout,r.stderr),i;r.append("stdout",i.stdout),r.append("stderr",i.stderr);continue}throw i instanceof rn&&i.prependOutput(r.stdout,r.stderr),i}return{...r.build(t),env:Kr(this.ctx.state.env)}}async executeUserScript(e,t,r=""){return xI(this.ctx,e,t,r,n=>this.executeScript(n))}async executeStatement(e){if(this.assertDefenseContext("statement"),this.ctx.state.signal?.aborted)throw new bt;if(e.deferredError)throw new vr(e.deferredError.message,e.line??1,1);if(this.ctx.state.options.noexec)return rt;this.ctx.state.errexitSafe=!1;let t=new Tn(this.ctx.executionScope,"statement");this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&e.sourceText&&t.append("stderr",`${e.sourceText} `);let r=0,n=-1,i=!1;try{for(let o=0;o0?e.operators[o-1]:null;if(u==="&&"&&r!==0||u==="||"&&r===0)continue;let c=await this.executePipeline(l);t.appendResult(c,J1(c)),r=c.exitCode,n=o,i=l.negated,this.ctx.state.lastExitCode=r,this.ctx.state.env.set("?",String(r))}}catch(o){throw t.prependTo(o),o}let s=nthis.executeCommand(t,r))}async executeCommand(e,t,r=!1){let n=v$(this.ctx),i;try{i=await this.executeCommandInner(e,t,r)}catch(a){throw await u0(this.ctx,n).catch(()=>{}),a}let s=await u0(this.ctx,n);return!s.stdout&&!s.stderr?i:{...i,stdout:s.stdout?Ss(i)+s.stdout:i.stdout,stdoutKind:s.stdout?"bytes":i.stdoutKind,stderr:i.stderr+s.stderr}}async executeCommandInner(e,t,r){switch(this.assertDefenseContext("command"),this.ctx.coverage?.hit(`bash:cmd:${e.type}`),e.type){case"SimpleCommand":return this.executeSimpleCommand(e,t);case"If":return XT(this.ctx,e);case"For":return JT(this.ctx,e);case"CStyleFor":return tI(this.ctx,e);case"While":return nI(this.ctx,e,t);case"Until":return sI(this.ctx,e,t);case"Case":return oI(this.ctx,e);case"Subshell":return this.executeSubshell(e,t,r);case"Group":return this.executeGroup(e,t,r);case"FunctionDef":return gO(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return vI(e)}}async executeSimpleCommand(e,t){let r;try{return await this.executeSimpleCommandInner(e,t,n=>{r=n})}catch(n){if(r?.finish(),n instanceof Ps)return Z(n.stderr);throw n}}async executeSimpleCommandInner(e,t,r){if(e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.shoptOptions.expand_aliases&&e.name){let A=e,O=0;for(;;){let N=this.expandAlias(A);if(N===A)break;if(O>=this.ctx.limits.maxCallDepth)throw new C(`alias expansion depth limit exceeded (${this.ctx.limits.maxCallDepth})`,"recursion");O++,A=N}this.aliasExpansionStack.clear(),A!==e&&(e=A)}this.ctx.state.expansionStderr="";let n=await PT(this.ctx,e);if(n.error)return n.error;let i=n.tempAssignments,s=n.xtraceOutput,a=()=>{for(let[A,O]of i)O===void 0?this.ctx.state.env.delete(A):this.ctx.state.env.set(A,O)};if(!e.name){if(e.redirections.length>0){let O=io(this.ctx,e.redirections,uO);r(O);let N=await O.prepare(t);if(N.error){if(a(),!N.errorCause)return O.finish(),N.error;try{return so(N)}finally{O.finish()}}let D=Q("",s,0),$=await zi(this.ctx,D,e.redirections,N.targets,N.dupSources,N.standardRoutes);return O.finish(),$}this.ctx.state.lastArg="";let A=(this.ctx.state.expansionStderr||"")+s;return this.ctx.state.expansionStderr="",Q("",A,this.ctx.state.lastExitCode)}let o=e.name&&F0(e.name,["local","declare","typeset","export","readonly"]),l=Array.from(i.keys());if(l.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let A of l)this.ctx.state.tempExportedVars.add(A)}let u=await Qe(this.ctx,e.name),c=[],p=[],h=(A,O)=>{if(c.length>=this.ctx.limits.maxArrayElements)throw new C(`expanded argument element limit exceeded (${this.ctx.limits.maxArrayElements})`,"array_elements");c.push(A),p.push(O)};if(F0(e.name,["local","declare","typeset","export","readonly"])&&(u==="local"||u==="declare"||u==="typeset"||u==="export"||u==="readonly"))for(let A of e.args){let O=await P$(this.ctx,A);if(O)h(O,!0);else{let N=await D$(this.ctx,A);if(N!==null)h(N,!0);else{let D=await li(this.ctx,A);for(let $ of D.values)h($,D.quoted)}}}else for(let A of e.args){let O=await li(this.ctx,A);for(let N of O.values)h(N,O.quoted)}let f=e.name.parts.every(A=>A.type==="CommandSubstitution"||A.type==="ParameterExpansion"||A.type==="ArithmeticExpansion");!u&&f&&c.length>0&&(u=c.shift(),p.shift());let d=io(this.ctx,e.redirections,u==="exec"?cO:N1);r(d);let m=await d.prepare(t);if(m.error)return a(),m.errorCause?so(m):(d.finish(),m.error);let g=m.stdinSourceFd,v=m.stdin!==void 0;if(m.stdin!==void 0&&(t=m.stdin),!u)return f?(d.finish(),Q("","",this.ctx.state.lastExitCode)):(d.finish(),Z(`bash: : command not found `,127));if(u==="exec"&&(c.length===0||c[0]==="--")){for(let[A,O]of i)O===void 0?this.ctx.state.env.delete(A):this.ctx.state.env.set(A,O);if(this.ctx.state.tempExportedVars)for(let A of i.keys())this.ctx.state.tempExportedVars.delete(A);return d.finish(),rt}if(this.ctx.state.extraArgs){let A=this.ctx.state.extraArgs;this.ctx.state.extraArgs=void 0;for(let O of A)h(O,!0)}let y=await IT(this.ctx,u,c);i.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(i)));let x,b=null;try{x=await this.runCommand(u,c,p,t,!1,!1,g,v)}catch(A){if(A instanceof fn||A instanceof dn)b=A,x=rt;else throw A}g>=0&&u!=="read"&&bs(this.ctx,g,x.internalStdinConsumed??0);let w=s+y;if(w&&(x={...x,stderr:w+x.stderr}),x=await zi(this.ctx,x,e.redirections,m.targets,m.dupSources,m.standardRoutes,x.internalProducerCommand??u,x.internalProducerOmitsShellPrefix),d.finish(),b)throw b;if(c.length>0){let A=c[c.length-1];if((u==="declare"||u==="local"||u==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(A)){let O=A.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);O&&(A=O[1])}this.ctx.state.lastArg=A}else this.ctx.state.lastArg=u;let E=rO(u)&&u!=="unset"&&u!=="eval";if(!this.ctx.state.options.posix||!E)for(let[A,O]of i)this.ctx.state.fullyUnsetLocals?.has(A)||(O===void 0?this.ctx.state.env.delete(A):this.ctx.state.env.set(A,O));if(this.ctx.state.tempExportedVars)for(let A of i.keys())this.ctx.state.tempExportedVars.delete(A);return i.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(x={...x,stderr:this.ctx.state.expansionStderr+x.stderr},this.ctx.state.expansionStderr=""),x}async runCommand(e,t,r,n,i=!1,s=!1,a=-1,o=!1){let l={ctx:this.ctx,runCommand:(c,p,h,f,d,m,g,v)=>this.runCommand(c,p,h,f,d,m,g,v),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(c,p,h)=>this.executeUserScript(c,p,h)},u=await VT(l,e,t,r,n,i,s,a,o);return u===null?{...await KT(l,e,t,n,s),internalProducerCommand:e}:u.internalProducerCommand===void 0?{...u,internalProducerCommand:e}:u}aliasExpansionStack=new Set;expandAlias(e){return Pk({env:this.ctx.state.env,limits:this.ctx.limits},e,this.aliasExpansionStack)}async findCommandInPath(e){return s4(this.ctx,e)}async executeSubshell(e,t="",r=!1){return dI(this.ctx,e,t,n=>this.executeStatement(n),r)}async executeGroup(e,t="",r=!1){return gI(this.ctx,e,t,n=>this.executeStatement(n),r)}async executeArithmeticCommand(e){return e.line!==void 0&&(this.ctx.state.currentLine=e.line),tn(this.ctx,e.redirections,"",async()=>{try{let t=Ot(await qe(this.ctx,e.expression.expression)!==0);return this.ctx.state.expansionStderr&&(t={...t,stderr:this.ctx.state.expansionStderr+t.stderr},this.ctx.state.expansionStderr=""),t}catch(t){return Z(`bash: arithmetic expression: ${t.message} `)}})}async executeConditionalCommand(e){return e.line!==void 0&&(this.ctx.state.currentLine=e.line),tn(this.ctx,e.redirections,"",async()=>{try{let t=Ot(await Hn(this.ctx,e.expression));return this.ctx.state.expansionStderr&&(t={...t,stderr:this.ctx.state.expansionStderr+t.stderr},this.ctx.state.expansionStderr=""),t}catch(t){let r=t instanceof lt?1:2;return Z(`bash: conditional expression: ${t.message} `,r)}})}};ou(),$c(),Ar(),Wi();function L1(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function wI(e){let t=L1(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}var EI=3;function f4(e){let t=e;for(let r=0;rd4(e,m4(r)))}function _0(e){let t=CI(e);if(t==="localhost"||t.endsWith(".localhost"))return!0;let r=g4(t);if(r)return Oa(r);let n=NI(t);return n?$I(n):!1}function CI(e){let t=e.trim().toLowerCase();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}function kI(e){if(!e)return null;let t=10,r=e;if(r.startsWith("0x")||r.startsWith("0X")?(t=16,r=r.slice(2)):r.length>1&&r.startsWith("0")&&(t=8),!r||t===16&&!/^[0-9a-fA-F]+$/.test(r)||t===10&&!/^\d+$/.test(r)||t===8&&!/^[0-7]+$/.test(r))return null;let n=Number.parseInt(r,t);return!Number.isFinite(n)||n<0?null:n}function g4(e){let t=e.split(".");if(t.length===0||t.length>4)return null;let r=t.map(l=>kI(l));if(r.some(l=>l===null))return null;let n=r;if(t.length===1){let l=n[0];return l>4294967295?null:[l>>>24&255,l>>>16&255,l>>>8&255,l&255]}if(t.length===2){let[l,u]=n;return l>255||u>16777215?null:[l,u>>>16&255,u>>>8&255,u&255]}if(t.length===3){let[l,u,c]=n;return l>255||u>255||c>65535?null:[l,u,c>>>8&255,c&255]}let[i,s,a,o]=n;return i>255||s>255||a>255||o>255?null:[i,s,a,o]}function NI(e){let t=e,r=null;if(t.includes(".")){let m=t.lastIndexOf(":");if(m<0)return null;let g=g4(t.slice(m+1));if(!g)return null;r=g,t=t.slice(0,m)}let n=t.includes("::")?t.split("::").length-1:0;if(n>1)return null;let[i,s]=t.split("::"),a=i?i.split(":").filter(Boolean):[],o=s?s.split(":").filter(Boolean):[],l=m=>/^[0-9a-f]{1,4}$/i.test(m)?Number.parseInt(m,16):null,u=a.map(l),c=o.map(l);if(u.some(m=>m===null)||c.some(m=>m===null))return null;let p=r?2:0,h=u.length+c.length+p,f=0;if(n===1){if(f=8-h,f<0)return null}else if(h!==8)return null;let d=[...u,...Array(f).fill(0),...c];return r&&(d.push(r[0]<<8|r[1]),d.push(r[2]<<8|r[3])),d.length===8?d:null}function Oa(e){let[t,r]=e;return t===127||t===10||t===172&&r>=16&&r<=31||t===192&&r===168||t===169&&r===254||t===0||t===100&&r>=64&&r<=127||t===198&&(r===18||r===19)||t===192&&r===0&&e[2]===0||t===192&&r===0&&e[2]===2||t===198&&r===51&&e[2]===100||t===203&&r===0&&e[2]===113||t>=240}function $I(e){return e.every(t=>t===0)||e.slice(0,7).every(t=>t===0)&&e[7]===1||(e[0]&65472)==65152||(e[0]&65024)==64512?!0:e[0]===0&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===65535?Oa([e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255]):e[0]===8193&&e[1]===3512?!0:e[0]===100&&e[1]===65435&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===0?Oa([e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255]):e[0]===100&&e[1]===65435&&e[2]===1||e[0]===8194&&Oa([e[1]>>>8&255,e[1]&255,e[2]>>>8&255,e[2]&255])}function OI(e){let t=[];for(let r of e){if(typeof r!="string"&&(typeof r!="object"||!r||!("url"in r)||typeof r.url!="string")){t.push('Invalid allow-list entry: must be a string URL or an object with a "url" string property');continue}let n=m4(r);if(!L1(n)){t.push(`Invalid URL in allow-list: "${n}" - must be a valid URL with scheme and host (e.g., "https://example.com")`);continue}let i=new URL(n);if(i.protocol!=="http:"&&i.protocol!=="https:"){t.push(`Only http and https URLs are allowed in allow-list: "${n}"`);continue}if(!i.hostname){t.push(`Allow-list entry must include a hostname: "${n}"`);continue}if(i.pathname!=="/"&&i.pathname!==""&&f4(i.pathname)){t.push(`Allow-list entry contains ambiguous path separators: "${n}"`);continue}(i.search||i.hash)&&t.push(`Query strings and fragments are ignored in allow-list entries: "${n}"`)}return t}var y4=class extends Error{constructor(){super("DNS pinning is unavailable in this runtime"),this.name="DnsPinningUnavailableError"}},TI=async e=>{throw new y4},wn=class extends Error{constructor(e,t){super(`Network access denied: ${t??"URL not in allow-list"}: ${e}`),this.name="NetworkAccessDeniedError"}},II=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name="TooManyRedirectsError"}},RI=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name="RedirectNotAllowedError"}},PI=class extends Error{constructor(e,t){super(`HTTP method '${e}' not allowed. Allowed methods: ${t.join(", ")}`),this.name="MethodNotAllowedError"}},nu=class extends Error{constructor(e){super(`Response body too large (max: ${e} bytes)`),this.name="ResponseTooLargeError"}};function DI(e){return new Promise((t,r)=>{fm(e,{all:!0},(n,i)=>{n?r(n):t(i)})})}var LI=20,MI=3e4,FI=10485760,_I=["GET","HEAD"],zI=new Set(["GET","HEAD","OPTIONS"]),BI=new Set([301,302,303,307,308]);function Bi(e){return e.reason instanceof Error?e.reason:new DOMException("The operation was aborted","AbortError")}function z0(e){if(e?.aborted)throw Bi(e)}async function Cn(e,t){if(!t)return e;if(t.aborted)throw e.catch(()=>{}),Bi(t);let r,n=new Promise((i,s)=>{r=()=>s(Bi(t)),t.addEventListener("abort",r,{once:!0})});try{return await Promise.race([e,n])}finally{r&&t.removeEventListener("abort",r)}}async function UI(e,t){try{return await Cn(e,t)}catch(r){throw t?.aborted&&e.then(n=>Kt.runTrustedAsync(()=>n.close())).catch(()=>{}),r}}async function WI(e){e.body&&!e.body.locked&&await e.body.cancel()}function jI(e){let t=e.allowedUrlPrefixes??[];if(!e.dangerouslyAllowFullInternetAccess){let g=OI(t);if(g.length>0)throw Error(`Invalid network allow-list: ${g.join(` `)}`)}let r=[];for(let g of t)typeof g=="object"&&g.transform&&g.transform.length>0&&r.push(g);function n(g){if(r.length===0)return null;let v=null;for(let y of r)if(d4(g,y.url)&&y.transform){v||=new Headers;for(let x of y.transform)for(let[b,w]of Object.entries(x.headers))v.set(b,w)}return v}if(e.maxRedirects!==void 0&&(!Number.isSafeInteger(e.maxRedirects)||e.maxRedirects<0))throw RangeError("maxRedirects must be a non-negative safe integer");let i=e.maxRedirects??LI,s=e.timeoutMs??MI,a=e.maxResponseSize??FI,o=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??_I,l=e.denyPrivateRanges??(typeof process<"u"&&!0),u=e._dnsResolve??DI,c=e._createConnectionOwner??TI;function p(g){let v=g.startsWith("[")&&g.endsWith("]")?g.slice(1,-1):g;if(/^(?:0|[1-9]\d{0,2})(?:\.(?:0|[1-9]\d{0,2})){3}$/.test(v)&&v.split(".").every(y=>Number(y)<=255))return 4;if(v.includes(":")&&!v.includes("%"))try{if(new URL(`http://[${v}]/`).hostname.length>2)return 6}catch{}return null}function h(g,v,y){let{address:x,family:b}=y;if(p(x)!==b)throw new wn(g,"DNS returned an invalid address for private IP check");return{hostname:v,address:x,family:b}}async function f(g,v){if(z0(v),!e.dangerouslyAllowFullInternetAccess&&!AI(g,t))throw new wn(g);if(!l)return null;let y;try{y=new URL(g)}catch{throw new wn(g,"invalid URL")}if(_0(y.hostname))throw new wn(g,"private/loopback IP address blocked");let x=y.hostname;if(p(x)!==null)return null;let b;try{b=await Cn(u(x),v)}catch{throw v?.aborted?Bi(v):new wn(g,"DNS resolution failed for private IP check")}if(!Array.isArray(b)||b.length===0)throw new wn(g,"DNS resolution returned no addresses for private IP check");let w=b.map(E=>h(g,x,E));for(let{address:E}of w)if(_0(E))throw new wn(g,"hostname resolves to private/loopback IP address");return w[0]}function d(g){if(e.dangerouslyAllowFullInternetAccess)return;let v=g.toUpperCase();if(!o.includes(v))throw new PI(v,o)}async function m(g,v={}){let y=v.method?.toUpperCase()??"GET",x=v.followRedirects??!0;if(v.maxRedirects!==void 0&&(!Number.isSafeInteger(v.maxRedirects)||v.maxRedirects<0))throw RangeError("maxRedirects must be a non-negative safe integer");let b=v.maxRedirects??i,w=Math.min(i,b),E=v.timeoutMs===void 0?s:Math.min(v.timeoutMs,s),A=new AbortController,O=Es(()=>A.abort(new DOMException("The operation was aborted","AbortError")),E),N=Nc(v.signal,A.signal);try{let D=await f(g,N.signal);d(y);let $=g,L=0;for(;;){z0(N.signal);let _;try{let R=await Kt.runTrustedAsync(async()=>{let B=n($),j=qI(v.headers,B),P={method:y,headers:j,signal:N.signal,redirect:"manual"};if(v.body&&!zI.has(y)&&(P.body=v.body),!D)return await Cn(fetch($,P),N.signal);try{return _=await UI(c(D),N.signal),await Cn(_.fetch($,P),N.signal)}catch(F){throw F instanceof y4?new wn($,"DNS pinning unavailable for private IP enforcement"):F}});if(BI.has(R.status)&&x){let B=R.headers.get("location");if(!B)return await B0(R,$,a,N.signal);let j=new URL(B,$).href;await Cn(WI(R),N.signal);try{D=await f(j,N.signal)}catch{throw N.signal?.aborted?Bi(N.signal):new RI(j)}if(L++,L>w)throw new II(w);$=j;continue}return await B0(R,$,a,N.signal)}finally{if(_){let R=_;await Cn(Kt.runTrustedAsync(()=>R.close()),N.signal)}}}}finally{oo(O),N.cleanup()}}return m}function qI(e,t){if(!e&&!t)return;if(!t)return e;let r=(e instanceof Headers,new Headers(e));for(let[n,i]of t)r.set(n,i);return r}async function B0(e,t,r,n){let i=Object.create(null);if(e.headers.forEach((a,o)=>{i[o.toLowerCase()]=a}),r>0){let a=e.headers.get("content-length");if(a){let o=parseInt(a,10);if(!Number.isNaN(o)&&o>r)throw new nu(r)}}let s;if(r>0&&e.body){let a=e.body.getReader(),o=[],l=0;try{for(;;){let{done:c,value:p}=await Cn(a.read(),n);if(c)break;if(p){if(l+=p.byteLength,l>r)throw await a.cancel(),new nu(r);o.push(p)}}}catch(c){throw n?.aborted&&await a.cancel(Bi(n)).catch(()=>{}),c}s=new Uint8Array(l);let u=0;for(let c of o)s.set(c,u),u+=c.byteLength}else{let a=await Cn(e.arrayBuffer(),n);if(r>0&&a.byteLength>r)throw new nu(r);s=new Uint8Array(a)}return{status:e.status,statusText:e.statusText,headers:i,body:s,url:t}}Ar(),wt(),H();function U0(e,t){if(e.length>t||q(e)>t)throw new C(`script input size limit exceeded (${t} bytes)`,"string_length")}var ZI=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(e={}){this.limits=XA({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}},e.executionLimitProfile);let t=e.fs??new Ga(e.files,{maxTotalBytes:this.limits.maxFileSystemBytes});this.fs=t,this.useDefaultLayout=!e.cwd&&!e.files;let r=e.cwd||(this.useDefaultLayout?"/home/user":"/"),n=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",` `],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(e.env??{})]);if(e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=jI(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:n,arrays:new Map,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(e.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",n3(this.state.options)),this.state.env.set("BASHOPTS",i3(this.state.shoptOptions)),cC(t,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&t instanceof Ga)try{t.mkdirSync(r,{recursive:!0})}catch{}for(let s of qA(e.commands))this.registerBundledCommand(s);if(e.fetch||e.network)for(let s of GA())this.registerBundledCommand(s);if(e.python)for(let s of HA())this.registerBundledCommand(s);let i=typeof e.javascript=="object"?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let s of VA())this.registerBundledCommand(s);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let s of e.customCommands)if(YA(s)){let a=JA(s);this.registerCommandInternal(a,!0)}else this.registerCommandInternal(s,!0)}registerCommand(e){this.registerCommandInternal(e,!0)}registerBundledCommand(e){this.registerCommandInternal(e,!1)}registerCommandInternal(e,t,r=t?e.trusted??!0:e.trusted){let n=this.commands.get(e.name),i=t?n?.internalOriginalCommand??(n&&!n.internalIsExtension?n:void 0):void 0,s={name:e.name,trusted:r,internalIsExtension:t,internalOriginalCommand:i,execute:(o,l)=>e.execute(o,l)};this.commands.set(e.name,s);let a=this.fs;if(typeof a.writeFileSync=="function"){let o=`#!/bin/bash # Built-in command: ${e.name} `;try{a.writeFileSync(`/bin/${e.name}`,o)}catch{}try{a.writeFileSync(`/usr/bin/${e.name}`,o)}catch{}}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug("stdout",{output:e.stdout}),e.stderr&&this.logger.info("stderr",{output:e.stderr}),this.logger.info("exit",{exitCode:e.exitCode})),e.stdout=j0(e.stdout),e.stderr=j0(e.stderr),e}async exec(e,t){let r=new eC(this.limits,t?.signal),n;try{n=await this.execInScope(e,t,r,0,t?.signal,!1,!1)}catch(s){try{await r.close()}catch{}throw s}let i=n;try{await r.close()}catch{i={...n,stderr:`${n.stderr}bash: execution cleanup failed `,exitCode:126}}return e.trim()?this.logResult(i):i}async execInScope(e,t,r,n,i,s=!1,a=!0){let o=c=>a?this.logResult(c):c,l=Nc(i,t?.signal),u=t?{...t,signal:l.signal}:{signal:l.signal};try{if(r.assertExecDepth(n),U0(e,this.limits.maxSourceBytes),!e.trim())return{stdout:"",stderr:"",exitCode:0,env:pr(this.state.env,u.env)};this.logger?.info("exec",{command:e});let c=u.cwd??this.state.cwd,p,h=c;if(u.cwd)if(u.env&&"PWD"in u.env)p=u.env.PWD;else if(u.env&&!("PWD"in u.env))try{p=await this.fs.realpath(c),h=p}catch{p=c}else p=c;let f=u.replaceEnv?new Map:new Map(this.state.env);if(u.env)for(let[y,x]of Object.entries(u.env))f.set(y,x);p!==void 0&&f.set("PWD",p);let d={...this.state,env:f,arrays:u.replaceEnv?new Map:qi(this.state.arrays),cwd:h,previousDir:u.env?.OLDPWD??this.state.previousDir,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:VI(u.stdin,u.stdinKind,this.limits.maxInputBytes,this.limits.maxStringLength,r,s),signal:u.signal,extraArgs:u.args},m=e;u.rawScript||(m=W0(e));let g=this.defenseInDepthConfig?Kt.getInstance(this.defenseInDepthConfig):null,v=g?.activate();try{let y=async()=>{let x=Li(m,{maxHeredocSize:this.limits.maxHeredocSize}),b;if(this.transformPlugins.length>0){let E=Object.create(null);for(let A of this.transformPlugins){let O=A.transform({ast:x,metadata:E});x=O.ast,O.metadata&&(E=za(E,O.metadata))}b=E}let w=await new bI({fs:this.fs,commands:this.commands,limits:this.limits,executionScope:r,exec:(E,A,O=!1)=>this.execInScope(E,A,r,n+1,u.signal,O),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:g?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},d).executeScript(x);return b&&(w.metadata=b),o(w)};return v?await v.run(y):await y()}catch(y){if(y instanceof ze)return o({stdout:y.stdout,stderr:y.stderr,exitCode:y.exitCode,internalOutputAccounting:y.internalOutputAccounting,env:pr(this.state.env,u.env)});if(y instanceof cn)return o({stdout:y.stdout,stderr:y.stderr,exitCode:y.exitCode,env:pr(this.state.env,u.env)});if(y instanceof lt)return o({stdout:y.stdout,stderr:y.stderr,exitCode:1,env:pr(this.state.env,u.env)});if(y instanceof bt)return o({stdout:y.stdout,stderr:y.stderr,exitCode:124,env:pr(this.state.env,u.env)});if(y instanceof C)return o({stdout:y.stdout,stderr:xt(y.stderr),exitCode:C.EXIT_CODE,internalOutputAccounting:y.internalOutputAccounting,env:pr(this.state.env,u.env)});if(y instanceof Ae)return o({stdout:"",stderr:`bash: security violation: ${xt(y.message)} `,exitCode:1,env:pr(this.state.env,u.env)});if(y.name==="ParseException")return o({stdout:"",stderr:`bash: syntax error: ${xt(y.message)} `,exitCode:2,env:pr(this.state.env,u.env)});if(y instanceof Gr)return o({stdout:"",stderr:`bash: ${xt(y.message)} `,exitCode:2,env:pr(this.state.env,u.env)});if(y instanceof RangeError)return o({stdout:"",stderr:`bash: ${xt(y.message)} `,exitCode:1,env:pr(this.state.env,u.env)});throw y}finally{v?.deactivate()}}catch(c){if(c instanceof bt)return o({stdout:c.stdout,stderr:c.stderr,exitCode:124,env:pr(this.state.env,u.env)});if(c instanceof C)return o({stdout:c.stdout,stderr:xt(c.stderr),exitCode:C.EXIT_CODE,internalOutputAccounting:c.internalOutputAccounting,env:pr(this.state.env,u.env)});throw c}finally{l.cleanup()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,t){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),t)}getCwd(){return this.state.cwd}getEnv(){return Kr(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){U0(e,this.limits.maxSourceBytes);let t=Li(W0(e),{maxHeredocSize:this.limits.maxHeredocSize}),r=Object.create(null);for(let n of this.transformPlugins){let i=n.transform({ast:t,metadata:r});t=i.ast,i.metadata&&(r=za(r,i.metadata))}return{script:uk(t),ast:t,metadata:r}}};function GI(e,t){let r=t;for(let n=0;n0){let u=n[n.length-1];if((u.stripTabs?a.replace(/^\t+/,""):a)===u.delimiter){r.push(a.trimStart()),n.pop();continue}r.push(a);continue}let o=i,l=o==="none"?a.trimStart():a;if(r.push(l),i=GI(a,o),o==="none")for(let u of l.matchAll(/<<(-?)\s*(['"]?)([\w-]+)\2/g)){let c=u[1]==="-",p=u[3];n.push({delimiter:p,stripTabs:c})}}return r.join(` `)}var HI=new TextDecoder("utf-8",{fatal:!0});function j0(e){if(!e)return e;let t=!1;for(let n=0;n255)return e;i>127&&(t=!0)}if(!t)return e;let r=new Uint8Array(e.length);for(let n=0;nr||a>n)throw new C(`stdin size limit exceeded (${Math.min(r,n)} bytes)`,"string_length");return s||i.consumeInput(a,"stdin"),t==="bytes"?e:ti(e)}export{ZI as Bash}; /*! Bundled license information: re2js/build/index.esm.js: (*! * re2js * RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching * * @version v1.3.3 * @author Alexey Vasiliev * @homepage https://github.com/le0pard/re2js#readme * @repository github:le0pard/re2js * @license MIT *) ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) */