just-bash 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -474,7 +474,7 @@ Try 'comm --help' for more information.
474
474
  `)&&m[m.length-1]===""&&m.pop(),m.filter(h=>h.length>0).map(h=>rE(h,n.separator,d,n.ignoreCase))},a=o(i[0],n.field1),l=o(i[1],n.field2),c=new Map;for(let p of l){let d=c.get(p.joinKey);d?d.push(p):c.set(p.joinKey,[p])}let u=[],f=new Set;for(let p of a){let d=c.get(p.joinKey);if(d&&d.length>0){if(f.add(p.joinKey),n.onlyUnpairable.size===0)for(let m of d)u.push(yo(p,m,n))}else(n.printUnpairable.has(1)||n.onlyUnpairable.has(1))&&u.push(yo(p,null,n))}if(n.printUnpairable.has(2)||n.onlyUnpairable.has(2))for(let p of l)f.has(p.joinKey)||u.push(yo(null,p,n));return{exitCode:0,stdout:u.length>0?`${u.join(`
475
475
  `)}
476
476
  `:"",stderr:""}}}});var np={};V(np,{teeCommand:()=>lE});var oE,aE,lE,rp=v(()=>{"use strict";Oe();X();oE={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"]},aE={append:{short:"a",long:"append",type:"boolean"}},lE={name:"tee",async execute(e,t){if(_(e))return F(oE);let n=fe("tee",e,aE);if(!n.ok)return n.error;let{append:r}=n.result.flags,s=n.result.positional,i=t.stdin,o="",a=0;for(let l of s)try{let c=t.fs.resolvePath(t.cwd,l);r?await t.fs.appendFile(c,i):await t.fs.writeFile(c,i)}catch{o+=`tee: ${l}: No such file or directory
477
- `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function kt(e,t){switch(e.type){case"name":{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],i=t.name;if(e.ignoreCase){if(!i.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Ye(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,r=t.relativePath,s=n.split("/");for(let o=0;o<s.length-1;o++){let a=s[o];if(a&&a!=="."&&a!==".."&&!a.includes("*")&&!a.includes("?")&&!a.includes("[")){let l=`/${a}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(l))return{matches:!1,pruned:!1,printed:!1}}}let i=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let o=i[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(o))return{matches:!1,pruned:!1,printed:!1}}return{matches:Ye(r,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24),s;return e.comparison==="more"?s=r>e.days:e.comparison==="less"?s=r<e.days:s=Math.floor(r)===e.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=t.size>n:e.comparison==="less"?r=t.size<n:e.unit==="b"?r=Math.ceil(t.size/512)===e.value:r=t.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,r=e.mode&511,s;return e.matchType==="exact"?s=n===r:e.matchType==="all"?s=(n&r)===r:s=(n&r)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=kt(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=kt(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=kt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=kt(e.left,t);if(n.matches)return n;let r=kt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function Er(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return Er(e.expr);case"and":case"or":return Er(e.left)||Er(e.right)}}function Sr(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return Sr(e.expr);case"and":case"or":return Sr(e.left)||Sr(e.right);default:return!1}}function sp(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=cE(e);if(uE(e)&&n.length===1){let i=n[0].split("/").filter(o=>o.length>0);if(i.length>=2)for(let o=i.length-2;o>=0;o--){let a=i[o];if(!a.includes("*")&&!a.includes("?")&&!a.includes("[")&&a!=="."&&a!==".."){let l=i[o+1];if(l&&(l.includes("*")||l.includes("?"))){t.terminalDirName=a;let c=l.match(/^\*(\.[a-zA-Z0-9]+)$/);c&&(t.requiredExtension=c[1])}break}}}return t}function cE(e){let t=[],n=r=>{r.type==="path"?t.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(e),t}function uE(e){let t=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?t(n.expr):n.type==="and"||n.type==="or"?t(n.left)||t(n.right):!1;return t(e)}function ip(e){let t=[],n=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),t}function Ar(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return Ar(e.expr);case"and":case"or":return Ar(e.left)&&Ar(e.right)}}function mn(e,t,n,r,s){switch(e.type){case"name":{let i=e.pattern,o=i.match(/^\*(\.[a-zA-Z0-9]+)$/);if(o){let a=o[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Ye(t,i,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let i=e.pattern,o=i.split("/");for(let l=0;l<o.length-1;l++){let c=o[l];if(c&&c!=="."&&c!==".."&&!c.includes("*")&&!c.includes("?")&&!c.includes("[")){let u=`/${c}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let a=i.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let l=a[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(l))return{matches:!1,pruned:!1,printed:!1}}return{matches:Ye(n,i,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let i=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,i).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:r,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let i=mn(e.expr,t,n,r,s);return{matches:!i.matches,pruned:i.pruned,printed:!1}}case"and":{let i=mn(e.left,t,n,r,s);if(!i.matches)return{matches:!1,pruned:i.pruned,printed:!1};let o=mn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:i.printed||o.printed}}case"or":{let i=mn(e.left,t,n,r,s);if(i.matches)return i;let o=mn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:o.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function Cr(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return Cr(e.expr);case"and":case"or":return Cr(e.left)||Cr(e.right);default:return!1}}function Jt(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return Jt(e.expr);case"and":case"or":return Jt(e.left)&&Jt(e.right)}}function op(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!Jt(e))return bo(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:kt(e,n).pruned}}function bo(e,t){switch(e.type){case"or":{if(Jt(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(kt(e.left,n).pruned)return{shouldPrune:!0}}return bo(e.right,t)}case"and":{if(Jt(e.left)&&Jt(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:kt(e,n).pruned}}if(Jt(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return kt(e.left,n).matches?bo(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var ap=v(()=>{"use strict";Hi()});function lp(e,t){let n=[],r=[],s=t;for(;s<e.length;){let o=e[s];if(o==="("||o==="\\("){n.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){n.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(o==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(o==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(o==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<e.length){let a=e[++s];if(a==="f"||a==="d")n.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
477
+ `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function kt(e,t){switch(e.type){case"name":{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],i=t.name;if(e.ignoreCase){if(!i.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Ye(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,r=t.relativePath,s=n.split("/");for(let o=0;o<s.length-1;o++){let a=s[o];if(a&&a!=="."&&a!==".."&&!a.includes("*")&&!a.includes("?")&&!a.includes("[")){let l=`/${a}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(l))return{matches:!1,pruned:!1,printed:!1}}}let i=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let o=i[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(o))return{matches:!1,pruned:!1,printed:!1}}return{matches:Ye(r,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24),s;return e.comparison==="more"?s=r>e.days:e.comparison==="less"?s=r<e.days:s=Math.floor(r)===e.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=t.size>n:e.comparison==="less"?r=t.size<n:e.unit==="b"?r=Math.ceil(t.size/512)===e.value:r=t.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,r=e.mode&511,s;return e.matchType==="exact"?s=n===r:e.matchType==="all"?s=(n&r)===r:s=(n&r)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=kt(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=kt(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=kt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=kt(e.left,t);if(n.matches)return n;let r=kt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function Er(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return Er(e.expr);case"and":case"or":return Er(e.left)||Er(e.right)}}function Sr(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return Sr(e.expr);case"and":case"or":return Sr(e.left)||Sr(e.right);default:return!1}}function sp(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=cE(e);if(uE(e)&&n.length===1){let i=n[0].split("/").filter(o=>o.length>0);if(i.length>=2)for(let o=i.length-2;o>=0;o--){let a=i[o];if(!a.includes("*")&&!a.includes("?")&&!a.includes("[")&&a!=="."&&a!==".."){let l=i[o+1];if(l&&(l.includes("*")||l.includes("?"))){t.terminalDirName=a;let c=l.match(/^\*(\.[a-zA-Z0-9]+)$/);c&&(t.requiredExtension=c[1])}break}}}return t}function cE(e){let t=[],n=r=>{r.type==="path"?t.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(e),t}function uE(e){let t=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?t(n.expr):n.type==="and"||n.type==="or"?t(n.left)||t(n.right):!1;return t(e)}function ip(e){let t=[],n=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),t}function Ar(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return Ar(e.expr);case"and":case"or":return Ar(e.left)&&Ar(e.right)}}function mn(e,t,n,r,s){switch(e.type){case"name":{let i=e.pattern,o=i.match(/^\*(\.[a-zA-Z0-9]+)$/);if(o){let a=o[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Ye(t,i,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let i=e.pattern,o=i.split("/");for(let l=0;l<o.length-1;l++){let c=o[l];if(c&&c!=="."&&c!==".."&&!c.includes("*")&&!c.includes("?")&&!c.includes("[")){let u=`/${c}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let a=i.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let l=a[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(l))return{matches:!1,pruned:!1,printed:!1}}return{matches:Ye(n,i,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let i=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,i).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:r,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let i=mn(e.expr,t,n,r,s);return{matches:!i.matches,pruned:i.pruned,printed:!1}}case"and":{let i=mn(e.left,t,n,r,s);if(!i.matches)return{matches:!1,pruned:i.pruned,printed:!1};let o=mn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:i.printed||o.printed}}case"or":{let i=mn(e.left,t,n,r,s);if(i.matches)return i;let o=mn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:o.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function Cr(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return Cr(e.expr);case"and":case"or":return Cr(e.left)||Cr(e.right);default:return!1}}function Yt(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return Yt(e.expr);case"and":case"or":return Yt(e.left)&&Yt(e.right)}}function op(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!Yt(e))return bo(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:kt(e,n).pruned}}function bo(e,t){switch(e.type){case"or":{if(Yt(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(kt(e.left,n).pruned)return{shouldPrune:!0}}return bo(e.right,t)}case"and":{if(Yt(e.left)&&Yt(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:kt(e,n).pruned}}if(Yt(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return kt(e.left,n).matches?bo(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var ap=v(()=>{"use strict";Hi()});function lp(e,t){let n=[],r=[],s=t;for(;s<e.length;){let o=e[s];if(o==="("||o==="\\("){n.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){n.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(o==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(o==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(o==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<e.length){let a=e[++s];if(a==="f"||a==="d")n.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
478
478
  `,actions:[]}}else if(o==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(o==="-mtime"&&s+1<e.length){let a=e[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=parseInt(c,10);Number.isNaN(u)||n.push({type:"expr",expr:{type:"mtime",days:u,comparison:l}})}else if(o==="-newer"&&s+1<e.length){let a=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:a}})}else if(o==="-size"&&s+1<e.length){let a=e[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=c.match(/^(\d+)([ckMGb])?$/);if(u){let f=parseInt(u[1],10),p=u[2]||"b";n.push({type:"expr",expr:{type:"size",value:f,unit:p,comparison:l}})}}else if(o==="-perm"&&s+1<e.length){let a=e[++s],l="exact",c=a;a.startsWith("-")?(l="all",c=a.slice(1)):a.startsWith("/")&&(l="any",c=a.slice(1));let u=parseInt(c,8);Number.isNaN(u)||n.push({type:"expr",expr:{type:"perm",mode:u,matchType:l}})}else if(o==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(o==="-not"||o==="!")n.push({type:"not"});else if(o==="-o"||o==="-or")n.push({type:"op",op:"or"});else if(o==="-a"||o==="-and")n.push({type:"op",op:"and"});else if(o==="-maxdepth"||o==="-mindepth")s++;else if(o!=="-depth")if(o==="-exec"){let a=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)a.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let l=e[s]==="+";r.push({type:"exec",command:a,batchMode:l})}else if(o==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(o==="-print0")r.push({type:"print0"});else if(o==="-printf"&&s+1<e.length){let a=e[++s];r.push({type:"printf",format:a})}else if(o==="-delete")r.push({type:"delete"});else{if(o.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${o}'
479
479
  `,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let i=fE(n);return i.error?{expr:null,pathIndex:s,error:i.error,actions:r}:{expr:i.expr,pathIndex:s,actions:r}}function fE(e){let t=0;function n(){let a=r();if(!a)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="or"){t++;let c=r();if(!c)return a;a={type:"or",left:a,right:c}}else break}return a}function r(){let a=s();if(!a)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="and"){t++;let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else if(l.type==="expr"||l.type==="not"||l.type==="lparen"){let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else break}return a}function s(){if(t<e.length&&e[t].type==="not"){t++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(t>=e.length)return null;let a=e[t];if(a.type==="lparen"){t++;let l=n();return t<e.length&&e[t].type==="rparen"&&t++,l}return a.type==="expr"?(t++,a.expr):(a.type==="rparen",null)}return{expr:n()}}var cp=v(()=>{"use strict"});var fp={};V(fp,{findCommand:()=>gE});function pE(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function dE(e,t,n){e({category:"find",name:"summary",durationMs:n,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:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}function yE(e,t){let n=Jr(e),r="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){r+="%",s++;continue}let[i,o,a]=tc(n,s);if(s+=a,s>=n.length){r+="%";break}let l=n[s],c;switch(l){case"f":c=t.name,s++;break;case"h":{let u=t.path.lastIndexOf("/");c=u>0?t.path.slice(0,u):".",s++;break}case"p":c=t.path,s++;break;case"P":{let u=t.startingPoint;t.path===u?c="":t.path.startsWith(`${u}/`)?c=t.path.slice(u.length+1):u==="."&&t.path.startsWith("./")?c=t.path.slice(2):c=t.path,s++;break}case"s":c=String(t.size),s++;break;case"d":c=String(t.depth),s++;break;case"m":c=(t.mode&511).toString(8),s++;break;case"M":c=bE(t.mode,t.isDirectory),s++;break;case"t":{let u=new Date(t.mtime);c=wE(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(t.mtime);c=xE(f,u),s+=2}else c="%T",s++;break}default:r+=`%${i!==0||o!==-1?`${i}.${o}`:""}${l}`,s++;continue}r+=Xr(c,i,o)}else r+=n[s],s++;return r}function bE(e,t){let n=e&511,r=t?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function wE(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=t[e.getDay()],s=n[e.getMonth()],i=String(e.getDate()).padStart(2," "),o=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0"),c=e.getFullYear();return`${r} ${s} ${i} ${o}:${a}:${l} ${c}`}function xE(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var up,hE,mE,gE,pp=v(()=>{"use strict";X();Bi();ap();cp();up=500;hE={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"]},mE=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),gE={name:"find",async execute(e,t){if(_(e))return F(hE);let n=[],r=null,s=null,i=!1,o=!1;for(let N=0;N<e.length;N++){let P=e[N];if(P==="-maxdepth"&&N+1<e.length)o=!0,r=parseInt(e[++N],10);else if(P==="-mindepth"&&N+1<e.length)o=!0,s=parseInt(e[++N],10);else if(P==="-depth")o=!0,i=!0;else if(P==="-exec")for(o=!0,N++;N<e.length&&e[N]!==";"&&e[N]!=="+";)N++;else!P.startsWith("-")&&P!==";"&&P!=="+"&&P!=="("&&P!==")"&&P!=="\\("&&P!=="\\)"&&P!=="!"?o||n.push(P):mE.has(P)?(o=!0,N++):(P.startsWith("-")||P==="("||P==="\\("||P==="!")&&(o=!0)}n.length===0&&n.push(".");let{expr:a,error:l,actions:c}=lp(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some(N=>N.type==="print"),f=c.length===0,p=[],d=c.some(N=>N.type==="printf"),m=[],h="",g=0,b=ip(a),y=new Map;for(let N of b){let P=t.fs.resolvePath(t.cwd,N);try{let k=await t.fs.stat(P);y.set(N,k.mtime?.getTime()??Date.now())}catch{}}let w=c.some(N=>{if(N.type!=="printf")return!1;let P=N.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(P)}),E=Er(a)||w,C=Sr(a),A=sp(a),I=Cr(a),O=Ar(a),L=typeof t.fs.readdirWithFileTypes=="function";for(let N of n){let Y=function(B){let be=s===null||B.depth>=s,ee=!1;if(be&&a!==null){let U=Date.now(),ye;if(O)ye=mn(a,B.name,B.relativePath,B.isFile,B.isDirectory);else{let Ce={name:B.name,relativePath:B.relativePath,isFile:B.isFile,isDirectory:B.isDirectory,isEmpty:B.isEmpty,mtime:B.stat?.mtime?.getTime()??Date.now(),size:B.stat?.size??0,mode:B.stat?.mode??420,newerRefTimes:y};ye=kt(a,Ce)}be=ye.matches,ee=u?ye.printed:be,k.evalCalls++,k.evalTime+=Date.now()-U}else be&&(ee=!0);return ee?{print:!0,printfData:d?{path:B.relativePath,name:B.name,size:B.stat?.size??0,mtime:B.stat?.mtime?.getTime()??Date.now(),mode:B.stat?.mode??420,isDirectory:B.isDirectory,depth:B.depth,startingPoint:N}:null}:{print:!1,printfData:null}};var $=Y;N.length>1&&N.endsWith("/")&&(N=N.slice(0,-1));let P=t.fs.resolvePath(t.cwd,N);try{await t.fs.stat(P)}catch{h+=`find: ${N}: No such file or directory
480
480
  `,g=1;continue}let k=pE(),R=Date.now();async function T(B){let{path:q,depth:be,typeInfo:ee}=B;if(k.nodeCount++,r!==null&&be>r)return null;let ge,U,ye;if(ee&&!E)ge=ee.isFile,U=ee.isDirectory;else{try{let un=Date.now();ye=await t.fs.stat(q),k.statCalls++,k.statTime+=Date.now()-un}catch{return null}if(!ye)return null;ge=ye.isFile,U=ye.isDirectory}let Ce;q===P?Ce=N.split("/").pop()||N:Ce=q.split("/").pop()||"";let Re=q===P?N:N==="."?`./${q.slice(P==="/"?P.length:P.length+1)}`:N+q.slice(P.length),Me=[],ze=null,We=null,Be=!1;U&&I&&!i&&(Be=op(a,{name:Ce,relativePath:Re,isFile:ge,isDirectory:U}).shouldPrune,Be&&k.earlyPrunes++);let yt=r!==null&&be>=r,bt=A.terminalDirName!==null&&Ce===A.terminalDirName,dr=!yt&&!bt&&!Be;if(U&&((dr||C||bt)&&!Be)){let un=Date.now();if(L&&t.fs.readdirWithFileTypes){if(ze=await t.fs.readdirWithFileTypes(q),We=ze.map(at=>at.name),k.readdirCalls++,k.readdirTime+=Date.now()-un,dr)Me=ze.map((at,Ct)=>({path:q==="/"?`/${at.name}`:`${q}/${at.name}`,depth:be+1,typeInfo:{isFile:at.isFile,isDirectory:at.isDirectory},resultIndex:Ct}));else if(bt){let at=A.requiredExtension;Me=ze.filter(Ct=>Ct.isFile&&(!at||Ct.name.endsWith(at))).map((Ct,Vy)=>({path:q==="/"?`/${Ct.name}`:`${q}/${Ct.name}`,depth:be+1,typeInfo:{isFile:Ct.isFile,isDirectory:Ct.isDirectory},resultIndex:Vy}))}}else We=await t.fs.readdir(q),k.readdirCalls++,k.readdirTime+=Date.now()-un,dr&&(Me=We.map((at,Ct)=>({path:q==="/"?`/${at}`:`${q}/${at}`,depth:be+1,resultIndex:Ct})))}let Qr=ge?(ye?.size??0)===0:We!==null&&We.length===0,Rn=Be;if(!i&&a!==null&&!Be&&I){let un=Date.now(),at={name:Ce,relativePath:Re,isFile:ge,isDirectory:U,isEmpty:Qr,mtime:ye?.mtime?.getTime()??Date.now(),size:ye?.size??0,mode:ye?.mode??420,newerRefTimes:y};Rn=kt(a,at).pruned,k.evalCalls++,k.evalTime+=Date.now()-un}return{relativePath:Re,name:Ce,isFile:ge,isDirectory:U,isEmpty:Qr,stat:ye,depth:be,children:Rn?[]:Me,pruned:Rn}}async function ie(){let B={paths:[],printfData:[]};if(i){let ye=function(Ce){let Re={paths:[],printfData:[]},Me=ee[Ce];if(!Me)return Re;for(let Be of Me.childIndices){let yt=ye(Be);Re.paths.push(...yt.paths),Re.printfData.push(...yt.printfData)}let{print:ze,printfData:We}=Y(Me.node);return ze&&(Re.paths.push(Me.node.relativePath),We&&Re.printfData.push(We)),Re};var q=ye;let ee=[],ge=[{item:{path:P,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],U=new Map;for(;ge.length>0;){let Ce=Date.now(),Re=ge.splice(0,up),Me=await Promise.all(Re.map(ze=>T(ze.item)));k.batchCount++,k.batchTime+=Date.now()-Ce;for(let ze=0;ze<Re.length;ze++){let We=Me[ze],Be=Re[ze];if(!We)continue;let yt=ee.length;if(Be.parentIndex>=0){let bt=U.get(Be.parentIndex)||[];bt.push(yt),U.set(Be.parentIndex,bt)}ee.push({node:We,parentIndex:Be.parentIndex,childIndices:[]});for(let bt=0;bt<We.children.length;bt++)ge.push({item:We.children[bt],parentIndex:yt,childOrderInParent:bt})}}for(let[Ce,Re]of U)Ce>=0&&Ce<ee.length&&(ee[Ce].childIndices=Re);if(ee.length>0){let Ce=ye(0);B.paths.push(...Ce.paths),B.printfData.push(...Ce.printfData)}}else{let Ce=function(Re){let Me=ee.get(Re);Me&&(B.paths.push(Me.path),Me.printfData&&B.printfData.push(Me.printfData));let ze=ye.get(Re);if(ze)for(let We of ze)Ce(We)};var be=Ce;let ee=new Map,ge=0,U=[{item:{path:P,depth:0,resultIndex:0},orderIndex:ge++}],ye=new Map;for(;U.length>0;){let Re=Date.now(),Me=U.splice(0,up),ze=await Promise.all(Me.map(async({item:We,orderIndex:Be})=>{let yt=await T(We);return yt?{node:yt,orderIndex:Be}:null}));k.batchCount++,k.batchTime+=Date.now()-Re;for(let We of ze){if(!We)continue;let{node:Be,orderIndex:yt}=We,{print:bt,printfData:dr}=Y(Be);if(bt&&ee.set(yt,{path:Be.relativePath,printfData:dr}),Be.children.length>0){let Mi=[];for(let Qr of Be.children){let Rn=ge++;Mi.push(Rn),U.push({item:Qr,orderIndex:Rn})}ye.set(yt,Mi)}}}Ce(0)}return B}let K=await ie();if(p.push(...K.paths),m.push(...K.printfData),t.trace){let B=Date.now()-R;dE(t.trace,k,B),t.trace({category:"find",name:"searchPath",durationMs:B,details:{path:N,resultsFound:K.paths.length}})}}let D="";if(c.length>0)for(let N of c)switch(N.type){case"print":D+=p.length>0?`${p.join(`
@@ -527,7 +527,7 @@ ${a} director${a===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"
527
527
  `);a!==-1&&(i=i.slice(a+1))}return await r.exec(i,{env:s,cwd:r.cwd})}var Rp,GE,ZE,ko=v(()=>{"use strict";X();Rp={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).']},GE={name:"bash",async execute(e,t){if(_(e))return F(Rp);if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"bash",o=e.slice(3);return zn(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?zn(t.stdin,"bash",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return zn(i,n,r,t)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
528
528
  `,exitCode:127}}}},ZE={name:"sh",async execute(e,t){if(_(e))return F({...Rp,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"sh",o=e.slice(3);return zn(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?zn(t.stdin,"sh",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return zn(i,n,r,t)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
529
529
  `,exitCode:127}}}}});function vo(e,t,n,r,s,i,o,a,l,c){switch(t){case"sort":return Array.isArray(e)?[[...e].sort(o)]:[null];case"sort_by":return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((f,p)=>{let d=s(f,n[0],r)[0],m=s(p,n[0],r)[0];return o(d,m)})];case"bsearch":{if(!Array.isArray(e)){let f=e===null?"null":typeof e=="object"?"object":typeof e;throw new Error(`${f} (${JSON.stringify(e)}) cannot be searched from`)}return n.length===0?[null]:s(e,n[0],r).map(f=>{let p=0,d=e.length;for(;p<d;){let m=p+d>>>1;o(e[m],f)<0?p=m+1:d=m}return p<e.length&&o(e[p],f)===0?p:-p-1})}case"unique_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let p of e){let d=s(p,n[0],r)[0],m=JSON.stringify(d);u.has(m)||u.set(m,{item:p,key:d})}let f=[...u.values()];return f.sort((p,d)=>o(p.key,d.key)),[f.map(p=>p.item)]}case"group_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let f of e){let p=JSON.stringify(s(f,n[0],r)[0]);u.has(p)||u.set(p,[]),u.get(p)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)>0?u:f)]:[null];case"max_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let p=s(u,n[0],r)[0],d=s(f,n[0],r)[0];return o(p,d)>0?u:f})];case"min":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)<0?u:f)]:[null];case"min_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let p=s(u,n[0],r)[0],d=s(f,n[0],r)[0];return o(p,d)<0?u:f})];case"add":{let u=f=>{let p=f.filter(d=>d!==null);return p.length===0?null:p.every(d=>typeof d=="number")?p.reduce((d,m)=>d+m,0):p.every(d=>typeof d=="string")?p.join(""):p.every(d=>Array.isArray(d))?p.flat():p.every(d=>d&&typeof d=="object"&&!Array.isArray(d))?Object.assign({},...p):null};if(n.length>=1){let f=s(e,n[0],r);return[u(f)]}return Array.isArray(e)?[u(e)]:[null]}case"any":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(s(f,n[1],r).some(a))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(e)?[e.some(u=>a(s(u,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(a)]:[!1]}case"all":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(!s(f,n[1],r).some(a))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(e)?[e.every(u=>a(s(u,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(a)]:[!0]}case"select":return n.length===0?[e]:s(e,n[0],r).some(a)?[e]:[];case"map":return n.length===0||!Array.isArray(e)?[null]:[e.flatMap(f=>s(f,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(e))return[e.flatMap(u=>s(u,n[0],r))];if(e&&typeof e=="object"){let u={};for(let[f,p]of Object.entries(e)){let d=s(p,n[0],r);d.length>0&&(u[f]=d[0])}return[u]}return[null]}case"has":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(e)&&typeof f=="number"?[f>=0&&f<e.length]:e&&typeof e=="object"&&typeof f=="string"?[f in e]:[!1]}case"in":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(f)&&typeof e=="number"?[e>=0&&e<f.length]:f&&typeof f=="object"&&typeof e=="string"?[e in f]:[!1]}case"contains":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(e,u[0])]}case"inside":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(u[0],e)]}default:return null}}var Pp=v(()=>{"use strict"});function $o(e,t,n,r,s,i,o,a){switch(t){case"first":if(n.length>0)try{let l=i(e,n[0],r);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof a)throw l;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case"last":if(n.length>0){let l=s(e,n[0],r);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case"nth":{if(n.length<1)return[null];let l=s(e,n[0],r);if(n.length>1){for(let u of l)if(u<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(e,n[1],r)}catch(u){if(u instanceof a)throw u;c=[]}return l.flatMap(u=>{let f=u;return f<c.length?[c[f]]:[]})}return Array.isArray(e)?l.flatMap(c=>{let u=c;if(u<0)throw new Error("nth doesn't support negative indices");return u<e.length?[e[u]]:[null]}):[null]}case"range":{if(n.length===0)return[];let l=s(e,n[0],r);if(n.length===1){let p=[];for(let d of l){let m=d;for(let h=0;h<m;h++)p.push(h)}return p}let c=s(e,n[1],r);if(n.length===2){let p=[];for(let d of l)for(let m of c){let h=d,g=m;for(let b=h;b<g;b++)p.push(b)}return p}let u=s(e,n[2],r),f=[];for(let p of l)for(let d of c)for(let m of u){let h=p,g=d,b=m;if(b!==0)if(b>0)for(let y=h;y<g;y+=b)f.push(y);else for(let y=h;y>g;y+=b)f.push(y)}return f}case"limit":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(e,n[1],r)}catch(p){if(p instanceof a)throw p;f=[]}return f.slice(0,u)});case"isempty":{if(n.length<1)return[!0];try{return[i(e,n[0],r).length===0]}catch(l){if(l instanceof a)throw l;return[!0]}}case"isvalid":{if(n.length<1)return[!0];try{return[s(e,n[0],r).length>0]}catch(l){if(l instanceof a)throw l;return[!1]}}case"skip":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("skip doesn't support negative count");return s(e,n[1],r).slice(u)});case"until":{if(n.length<2)return[e];let l=e,c=r.limits.maxIterations;for(let u=0;u<c;u++){if(s(l,n[0],r).some(o))return[l];let p=s(l,n[1],r);if(p.length===0)return[l];l=p[0]}throw new a(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u&&s(c,n[0],r).some(o);f++){l.push(c);let d=s(c,n[1],r);if(d.length===0)break;c=d[0]}if(l.length>=u)throw new a(`jq while: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(n.length===0)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u;f++){l.push(c);let p=s(c,n[0],r);if(p.length===0)break;c=p[0]}if(l.length>=u)throw new a(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var Tp=v(()=>{"use strict"});function Io(e,t,n,r,s){switch(t){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof e!="number")return[null];let i=new Date(e*1e3),o=i.getUTCFullYear(),a=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),p=i.getUTCDay(),d=Date.UTC(o,0,1),m=Math.floor((i.getTime()-d)/(1440*60*1e3));return[[o,a,l,c,u,f,p,m]]}case"mktime":{if(!Array.isArray(e))throw new Error("mktime requires parsed datetime inputs");let[i,o,a,l=0,c=0,u=0]=e;if(typeof i!="number"||typeof o!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,o,a??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strftime/1 requires a string format");let a;if(typeof e=="number")a=new Date(e*1e3);else if(Array.isArray(e)){let[p,d,m,h=0,g=0,b=0]=e;if(typeof p!="number"||typeof d!="number")throw new Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(p,d,m??1,h??0,g??0,b??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(p,d=2)=>String(p).padStart(d,"0");return[o.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,l[a.getUTCDay()]).replace(/%B/g,c[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(n.length===0)return[null];if(typeof e!="string")throw new Error("strptime/1 requires a string input");let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strptime/1 requires a string format");if(o==="%Y-%m-%dT%H:%M:%SZ"){let l=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(l){let[,c,u,f,p,d,m]=l.map(Number),h=new Date(Date.UTC(c,u-1,f,p,d,m)),g=h.getUTCDay(),b=Date.UTC(c,0,1),y=Math.floor((h.getTime()-b)/(1440*60*1e3));return[[c,u-1,f,p,d,m,g,y]]}}let a=new Date(e);if(!Number.isNaN(a.getTime())){let l=a.getUTCFullYear(),c=a.getUTCMonth(),u=a.getUTCDate(),f=a.getUTCHours(),p=a.getUTCMinutes(),d=a.getUTCSeconds(),m=a.getUTCDay(),h=Date.UTC(l,0,1),g=Math.floor((a.getTime()-h)/(1440*60*1e3));return[[l,c,u,f,p,d,m,g]]}throw new Error(`Cannot parse date: ${e}`)}case"fromdate":{if(typeof e!="string")throw new Error("fromdate requires a string input");let i=new Date(e);if(Number.isNaN(i.getTime()))throw new Error(`date "${e}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof e!="number")throw new Error("todate requires a number input");return[new Date(e*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}var Op=v(()=>{"use strict"});function vt(e){return e!==!1&&e!==null}function jn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Nr(e,t){return typeof e=="number"&&typeof t=="number"?e-t:typeof e=="string"&&typeof t=="string"?e.localeCompare(t):0}function Ro(e,t){let n={...e};for(let r of Object.keys(t))r in n&&n[r]&&typeof n[r]=="object"&&!Array.isArray(n[r])&&t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])?n[r]=Ro(n[r],t[r]):n[r]=t[r];return n}function Hn(e,t=3e3){let n=0,r=e;for(;n<t;)if(Array.isArray(r)){if(r.length===0)return n+1;r=r[0],n++}else if(r!==null&&typeof r=="object"){let s=Object.keys(r);if(s.length===0)return n+1;r=r[s[0]],n++}else return n;return n}function Cs(e,t){let n=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,r=n(e),s=n(t);if(r!==s)return r-s;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?1:0)-(t?1:0);if(Array.isArray(e)&&Array.isArray(t)){for(let i=0;i<Math.min(e.length,t.length);i++){let o=Cs(e[i],t[i]);if(o!==0)return o}return e.length-t.length}if(e&&t&&typeof e=="object"&&typeof t=="object"){let i=e,o=t,a=Object.keys(i).sort(),l=Object.keys(o).sort();for(let c=0;c<Math.min(a.length,l.length);c++){let u=a[c].localeCompare(l[c]);if(u!==0)return u}if(a.length!==l.length)return a.length-l.length;for(let c of a){let u=Cs(i[c],o[c]);if(u!==0)return u}}return 0}function Ns(e,t){if(jn(e,t))return!0;if(typeof e=="string"&&typeof t=="string")return e.includes(t);if(Array.isArray(e)&&Array.isArray(t))return t.every(n=>e.some(r=>Ns(r,n)));if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let n=e,r=t;return Object.keys(r).every(s=>s in n&&Ns(n[s],r[s]))}return!1}var ks=v(()=>{"use strict"});function Po(e,t,n){switch(t){case"@base64":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"utf-8").toString("base64")]:[btoa(e)]:[null];case"@base64d":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"base64").toString("utf-8")]:[atob(e)]:[null];case"@uri":return typeof e=="string"?[encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof e=="string"?[decodeURIComponent(e)]:[null];case"@csv":return Array.isArray(e)?[e.map(s=>{if(s===null)return"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="number")return String(s);let i=String(s);return i.includes(",")||i.includes('"')||i.includes(`
530
- `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(e)?[e.map(r=>String(r??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let r=n??QE;return Hn(e,r+1)>r?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[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 QE,Dp=v(()=>{"use strict";ks();QE=2e3});function To(e,t,n,r,s,i){switch(t){case"index":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){if(a===""&&e==="")return null;let l=e.indexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let c=0;c<=e.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(e[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=e.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){let l=e.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let l=e.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(e[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=e.length-1;l>=0;l--)if(i(e[l],a))return l;return null}return null});case"indices":return n.length===0?[[]]:s(e,n[0],r).map(a=>{let l=[];if(typeof e=="string"&&typeof a=="string"){let c=e.indexOf(a);for(;c!==-1;)l.push(c),c=e.indexOf(a,c+1)}else if(Array.isArray(e))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=e.length;u++)l.push(u);else for(let u=0;u<=e.length-c;u++){let f=!0;for(let p=0;p<c;p++)if(!i(e[u+p],a[p])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<e.length;c++)i(e[c],a)&&l.push(c);return l});default:return null}}var Fp=v(()=>{"use strict"});function Oo(e,t,n,r,s){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(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.hypot(e,i)]}case"fma":{if(typeof e!="number"||n.length<2)return[null];let i=s(e,n[0],r)[0],o=s(e,n[1],r)[0];return[e*i+o]}case"copysign":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.sign(i)*Math.abs(e)]}case"drem":case"remainder":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e-Math.round(e/i)*i]}case"fdim":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(0,e-i)]}case"fmax":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(e,i)]}case"fmin":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.min(e,i)]}case"ldexp":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"scalbn":case"scalbln":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}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":if(typeof e=="number"){let i=Math.floor(Math.log2(Math.abs(e)));return[e/2**i]}return[null];case"frexp":if(typeof e=="number"){if(e===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**i,i]]}return[null];case"modf":if(typeof e=="number"){let i=Math.trunc(e);return[[e-i,i]]}return[null];default:return null}}var _p=v(()=>{"use strict"});function Do(e,t,n,r,s,i,o,a){switch(t){case"recurse":{if(n.length===0){let d=[],m=h=>{if(d.push(h),Array.isArray(h))for(let g of h)m(g);else if(h&&typeof h=="object")for(let g of Object.keys(h))m(h[g])};return m(e),d}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,p=d=>{if(f++>u||c&&!s(d,c,r).some(i))return;l.push(d);let m=s(d,n[0],r);for(let h of m)h!=null&&p(h)};return p(e),l}case"recurse_down":return a(e,"recurse",n,r);case"walk":{if(n.length===0)return[e];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let d={};for(let[m,h]of Object.entries(u))d[m]=c(h);f=d}else f=u;return s(f,n[0],r)[0]};return[c(e)]}case"transpose":{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let l=Math.max(...e.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(e.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(n.length>0){let f=s(e,n[0],r)[0];if(!Array.isArray(e)||f<0)return[];if(f===0)return[[]];let p=[],d=(m,h)=>{if(h===f){p.push([...m]);return}for(let g of e)m.push(g),d(m,h+1),m.pop()};return d([],0),p}if(!Array.isArray(e))return[];if(e.length===0)return[[]];for(let u of e)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===e.length){l.push([...f]);return}let p=e[u];for(let d of p)f.push(d),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let l=r.currentPath;if(l.length===0)return[];let c=n.length>0?s(e,n[0],r)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[e];let f=l.slice(0,u);return[o(r.root,f)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let l=r.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var Lp=v(()=>{"use strict"});function Fo(e,t,n,r,s){switch(t){case"keys":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e)]:[null];case"length":return typeof e=="string"?[e.length]: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[new TextEncoder().encode(e).length];let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":return e&&typeof e=="object"&&!Array.isArray(e)?[Object.entries(e).map(([i,o])=>({key:i,value:o}))]:[null];case"from_entries":if(Array.isArray(e)){let i={};for(let o of e)if(o&&typeof o=="object"){let a=o,l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;l!==void 0&&(i[String(l)]=c)}return[i]}return[null];case"with_entries":{if(n.length===0)return[e];if(e&&typeof e=="object"&&!Array.isArray(e)){let o=Object.entries(e).map(([l,c])=>({key:l,value:c})).flatMap(l=>s(l,n[0],r)),a={};for(let l of o)if(l&&typeof l=="object"){let c=l,u=c.key??c.name??c.k,f=c.value??c.v;u!==void 0&&(a[String(u)]=f)}return[a]}return[null]}case"reverse":return Array.isArray(e)?[[...e].reverse()]:typeof e=="string"?[e.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(e)?(n.length>0?s(e,n[0],r):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return e.flat(a)}):[null];case"unique":if(Array.isArray(e)){let i=new Set,o=[];for(let a of e){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??KE;return Hn(e,i+1)>i?[null]:[JSON.stringify(e)]}case"fromjson":{if(typeof e=="string"){let i=e.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(e)]}catch{throw new 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 i=Number(e);if(Number.isNaN(i))throw new Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[i]}throw new 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 new Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,{}]);else for(let u of c)o(a[u],[...l,u])}};return o(e,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[e];let i=s(e,n[0],r),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:{});let u=o;for(let p=0;p<l.length-1;p++){let d=l[p],m=l[p+1];if(Array.isArray(u)&&typeof d=="number"){for(;u.length<=d;)u.push(null);u[d]===null&&(u[d]=typeof m=="number"?[]:{}),u=u[d]}else if(u&&typeof u=="object"&&!Array.isArray(u)){let h=u;(h[String(d)]===null||h[String(d)]===void 0)&&(h[String(d)]=typeof m=="number"?[]:{}),u=h[String(d)]}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else u&&typeof u=="object"&&!Array.isArray(u)&&(u[String(f)]=c)}return[o]}case"truncate_stream":{let i=typeof e=="number"?Math.floor(e):0;if(n.length===0)return[];let o=[],a=s(e,n[0],r);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var KE,Mp=v(()=>{"use strict";ks();KE=2e3});function _o(e,t,n,r,s,i,o,a,l,c){switch(t){case"getpath":{if(n.length===0)return[null];let u=s(e,n[0],r),f=[];for(let p of u){let d=p,m=e;for(let h of d){if(m==null){m=null;break}if(Array.isArray(m)&&typeof h=="number")m=m[h];else if(typeof m=="object"&&typeof h=="string")m=m[h];else{m=null;break}}f.push(m)}return f}case"setpath":{if(n.length<2)return[null];let f=s(e,n[0],r)[0],d=s(e,n[1],r)[0];return[o(e,f,d)]}case"delpaths":{if(n.length===0)return[e];let f=s(e,n[0],r)[0],p=e;for(let d of f.sort((m,h)=>h.length-m.length))p=a(p,d);return[p]}case"path":{if(n.length===0)return[[]];let u=[];return c(e,n[0],r,[],u),u}case"del":return n.length===0?[e]:[l(e,n[0],r)];case"pick":{if(n.length===0)return[null];let u=[];for(let p of n)c(e,p,r,[],u);let f=null;for(let p of u){for(let m of p)if(typeof m=="number"&&m<0)throw new Error("Out of bounds negative array index");let d=e;for(let m of p){if(d==null)break;if(Array.isArray(d)&&typeof m=="number")d=d[m];else if(typeof d=="object"&&typeof m=="string")d=d[m];else{d=null;break}}f=o(f,p,d)}return[f]}case"paths":{let u=[],f=(p,d)=>{if(p&&typeof p=="object")if(Array.isArray(p))for(let m=0;m<p.length;m++)u.push([...d,m]),f(p[m],[...d,m]);else for(let m of Object.keys(p))u.push([...d,m]),f(p[m],[...d,m])};return f(e,[]),n.length>0?u.filter(p=>{let d=e;for(let h of p)if(Array.isArray(d)&&typeof h=="number")d=d[h];else if(d&&typeof d=="object"&&typeof h=="string")d=d[h];else return!1;return s(d,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(p,d)=>{if(p===null||typeof p!="object")u.push(d);else if(Array.isArray(p))for(let m=0;m<p.length;m++)f(p[m],[...d,m]);else for(let m of Object.keys(p))f(p[m],[...d,m])};return f(e,[]),u}default:return null}}var Wp=v(()=>{"use strict"});function Lo(e,t,n,r,s,i){switch(t){case"IN":{if(n.length===0)return[!1];if(n.length===1){let c=s(e,n[0],r);for(let u of c)if(i(e,u))return[!0];return[!1]}let o=s(e,n[0],r),a=s(e,n[1],r),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(n.length===0)return[{}];if(n.length===1){let l=s(e,n[0],r),c={};for(let u of l){let f=String(u);c[f]=u}return[c]}if(n.length===2){let l=s(e,n[0],r),c={};for(let u of l){let f=s(u,n[1],r);if(f.length>0){let p=String(f[0]);c[p]=u}}return[c]}let o=s(e,n[0],r),a={};for(let l of o){let c=s(l,n[1],r),u=s(l,n[2],r);if(c.length>0&&u.length>0){let f=String(c[0]);a[f]=u[0]}}return[a]}case"JOIN":{if(n.length<2)return[null];let o=s(e,n[0],r)[0];if(!o||typeof o!="object"||Array.isArray(o))return[null];let a=o;if(!Array.isArray(e))return[null];let l=[];for(let c of e){let u=s(c,n[1],r),f=u.length>0?String(u[0]):"",p=f in a?a[f]:null;l.push([c,p])}return[l]}default:return null}}var Bp=v(()=>{"use strict"});function Mo(e,t,n,r,s){switch(t){case"join":{if(!Array.isArray(e))return[null];let i=n.length>0?s(e,n[0],r):[""];for(let o of e)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>e.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);return[e.split(o)]}case"splits":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"g",l=new RegExp(o,a.includes("g")?a:`${a}g`);return e.split(l)}catch{return[]}}case"scan":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",l=new RegExp(o,a.includes("g")?a:`${a}g`);return[...e.matchAll(l)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[new RegExp(o,a).test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=new RegExp(o,`${a}d`).exec(e);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,p)=>({offset:u?.[p+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",l=new RegExp(o,a),c=e.match(l);return!c||!c.groups?[{}]:[c.groups]}catch{return[null]}}case"sub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"";return[e.replace(new RegExp(a,c),l)]}catch{return[e]}}case"gsub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[e.replace(new RegExp(a,u),l)]}catch{return[e]}}case"ascii_downcase":return typeof e=="string"?[e.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof e=="string"?[e.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return[e.startsWith(o)?e.slice(o.length):e]}case"rtrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return o===""?[e]:[e.endsWith(o)?e.slice(0,-o.length):e]}case"trimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);if(o==="")return[e];let a=e;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof e=="string")return[e.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof e=="string")return[e.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof e=="string")return[e.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.startsWith(String(i[0]))]}case"endswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.endsWith(String(i[0]))]}case"ascii":return typeof e=="string"&&e.length>0?[e.charCodeAt(0)]:[null];case"explode":return typeof e=="string"?[Array.from(e).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(e))throw new Error("implode input must be an array");return[e.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var Up=v(()=>{"use strict"});function Wo(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[Number.POSITIVE_INFINITY];case"nan":return[Number.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 zp=v(()=>{"use strict"});var jp=v(()=>{"use strict";Pp();Tp();Op();Dp();Fp();_p();Lp();Mp();Wp();Bp();Up();zp()});function vs(e,t,n){if(t.length===0)return n;let[r,...s]=t;if(typeof r=="number"){if(e&&typeof e=="object"&&!Array.isArray(e))throw new Error("Cannot index object with number");if(r>536870911)throw new Error("Array index too large");if(r<0)throw new Error("Out of bounds negative array index");let a=Array.isArray(e)?[...e]:[];for(;a.length<=r;)a.push(null);return a[r]=vs(a[r],s,n),a}if(Array.isArray(e))throw new Error("Cannot index array with string");let i=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};return i[r]=vs(i[r],s,n),i}function $s(e,t){if(t.length===0)return null;if(t.length===1){let s=t[0];if(Array.isArray(e)&&typeof s=="number"){let i=[...e];return i.splice(s,1),i}if(e&&typeof e=="object"&&!Array.isArray(e)){let i={...e};return delete i[String(s)],i}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n=="number"){let s=[...e];return s[n]=$s(s[n],r),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s={...e};return s[String(n)]=$s(s[String(n)],r),s}return e}var Hp=v(()=>{"use strict"});function YE(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??XE,maxDepth:e?.limits?.maxDepth??Gp},env:e?.env}}function Ps(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels}}function kr(e,t,n){switch(t.type){case"var":return Ps(e,t.name,n);case"array":{if(!Array.isArray(n))return null;let r=e;for(let s=0;s<t.elements.length;s++){let i=t.elements[s],o=s<n.length?n[s]:null,a=kr(r,i,o);if(a===null)return null;r=a}return r}case"object":{if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,s=e;for(let i of t.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=z(n,i.key,e);if(c.length===0)return null;o=String(c[0])}let a=o in r?r[o]:null;i.keyVar&&(s=Ps(s,i.keyVar,a));let l=kr(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function eS(e,t){let n=e;for(let r of t)if(n&&typeof n=="object")n=n[r];else return;return n}function Yt(e){if(e.type==="Identity")return[];if(e.type==="Field"){let t=e.base?Yt(e.base):[];return t===null?null:[...t,e.name]}if(e.type==="Index"&&e.index.type==="Literal"){let t=e.base?Yt(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n=="number"||typeof n=="string"?[...t,n]:null}if(e.type==="Pipe"){let t=Yt(e.left);return t===null?null:Bo(t,e.right)}if(e.type==="Call"){if(e.name==="parent"||e.name==="root")return null;if(e.name==="first"&&e.args.length===0)return[0];if(e.name==="last"&&e.args.length===0)return[-1]}return null}function Bo(e,t){if(t.type==="Call"){if(t.name==="parent"){let n=1;if(t.args.length>0&&t.args[0].type==="Literal"){let r=t.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let r=-n-1;return e.slice(0,Math.min(r,e.length))}}if(t.name==="root")return[]}if(t.type==="Field"){let n=Yt(t);if(n!==null)return[...e,...n]}if(t.type==="Index"&&t.index.type==="Literal"){let n=Yt(t);if(n!==null)return[...e,...n]}if(t.type==="Pipe"){let n=Bo(e,t.left);return n===null?null:Bo(n,t.right)}return t.type==="Identity"?e:null}function Vp(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...z(e,t.left,n))}catch(s){if(s instanceof ne)throw s;if(r.length>0)return r;throw new Error("evaluation failed")}try{r.push(...z(e,t.right,n))}catch(s){if(s instanceof ne)throw s;return r}return r}return z(e,t,n)}function z(e,t,n){let r=n&&"vars"in n?n:YE(n);switch(r.root===void 0&&(r={...r,root:e,currentPath:[]}),t.type){case"Identity":return[e];case"Field":return(t.base?z(e,t.base,r):[e]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i[t.name];return[a===void 0?null:a]}if(i===null)return[null];let o=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${o} with string "${t.name}"`)});case"Index":return(t.base?z(e,t.base,r):[e]).flatMap(i=>z(i,t.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}return typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[a]]:[null]}));case"Slice":return(t.base?z(e,t.base,r):[e]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=t.start?z(e,t.start,r):[0],l=t.end?z(e,t.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=c,p=u,d=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),m=Number.isNaN(p)?o:Number.isInteger(p)?p:Math.ceil(p),h=qp(d,o),g=qp(m,o);return Array.isArray(i),i.slice(h,g)}))});case"Iterate":return(t.base?z(e,t.base,r):[e]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=z(e,t.left,r),i=Yt(t.left),o=[];for(let a of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};o.push(...z(a,t.right,l))}else o.push(...z(a,t.right,r))}catch(l){throw l instanceof Vn?l.withPrependedResults(o):l}return o}case"Comma":{let s=z(e,t.left,r),i=z(e,t.right,r);return[...s,...i]}case"Literal":return[t.value];case"Array":return t.elements?[z(e,t.elements,r)]:[[]];case"Object":{let s=[{}];for(let i of t.entries){let o=typeof i.key=="string"?[i.key]:z(e,i.key,r),a=z(e,i.value,r),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}for(let f of a)l.push({...c,[u]:f})}s.length=0,s.push(...l)}return s}case"Paren":return z(e,t.expr,r);case"BinaryOp":return rS(e,t.op,t.left,t.right,r);case"UnaryOp":return z(e,t.operand,r).map(i=>{if(t.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return t.op==="not"?!vt(i):null});case"Cond":return z(e,t.cond,r).flatMap(i=>{if(vt(i))return z(e,t.then,r);for(let o of t.elifs)if(z(e,o.cond,r).some(vt))return z(e,o.then,r);return t.else?z(e,t.else,r):[e]});case"Try":try{return z(e,t.body,r)}catch(s){if(t.catch){let i=s instanceof Rs?s.value:s instanceof Error?s.message:String(s);return z(i,t.catch,r)}return[]}case"Call":return Zp(e,t.name,t.args,r);case"VarBind":return z(e,t.value,r).flatMap(i=>{let o=null,a=[];t.pattern?a.push(t.pattern):t.name&&a.push({type:"var",name:t.name}),t.alternatives&&a.push(...t.alternatives);for(let l of a)if(o=kr(r,l,i),o!==null)break;return o===null?[]:z(e,t.body,o)});case"VarRef":{if(t.name==="$ENV")return[r.env??{}];let s=r.vars.get(t.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(e),s}case"Optional":try{return z(e,t.expr,r)}catch{return[]}case"StringInterp":return[t.parts.map(i=>typeof i=="string"?i:z(e,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[tS(e,t.path,t.op,t.value,r)];case"Reduce":{let s=z(e,t.expr,r),i=z(e,t.init,r)[0],o=r.limits.maxDepth??Gp;for(let a of s){let l;if(t.pattern){if(l=kr(r,t.pattern,a),l===null)continue}else l=Ps(r,t.varName,a);if(i=z(i,t.update,l)[0],Hn(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=z(e,t.expr,r),i=z(e,t.init,r)[0],o=[];for(let a of s)try{let l;if(t.pattern){if(l=kr(r,t.pattern,a),l===null)continue}else l=Ps(r,t.varName,a);if(i=z(i,t.update,l)[0],t.extract){let c=z(i,t.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof Vn?l.withPrependedResults(o):l}return o}case"Label":try{return z(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(s){if(s instanceof Vn&&s.label===t.name)return s.partialResults;throw s}case"Break":throw new Vn(t.name);case"Def":{let s=new Map(r.funcs??[]),i=`${t.name}/${t.params.length}`;s.set(i,{params:t.params,body:t.funcBody,closure:new Map(r.funcs??[])});let o={...r,funcs:s};return z(e,t.body,o)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function qp(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function tS(e,t,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return z(l,r,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?{...l,...c}:c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let p={...f};return p[c.name]=u(p[c.name]),p}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l};return f[c.name]=u(f[c.name]),f}return l}case"Index":{let p=z(e,c.index,s)[0];if(typeof p=="number"&&Number.isNaN(p))throw new Error("Cannot set array element at NaN index");if(typeof p=="number"&&!Number.isInteger(p)&&(p=Math.trunc(p)),c.base)return o(l,c.base,d=>{if(typeof p=="number"&&Array.isArray(d)){let m=[...d],h=p<0?m.length+p:p;if(h>=0){for(;m.length<=h;)m.push(null);m[h]=u(m[h])}return m}if(typeof p=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){let m={...d};return m[p]=u(m[p]),m}return d});if(typeof p=="number"){if(p>536870911)throw new Error("Array index too large");if(p<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let m=[...l],h=p<0?m.length+p:p;if(h>=0){for(;m.length<=h;)m.push(null);m[h]=u(m[h])}return m}if(l==null){let m=[];for(;m.length<=p;)m.push(null);return m[p]=u(null),m}return l}if(typeof p=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){let d={...l};return d[p]=u(d[p]),d}return l}case"Iterate":{let f=p=>{if(Array.isArray(p))return p.map(d=>u(d));if(p&&typeof p=="object"){let d={};for(let[m,h]of Object.entries(p))d[m]=u(h);return d}return p};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,p=>p);return o(f,c.right,u)}default:return u(l)}}return o(e,t,l=>{if(n==="|=")return i(l,l);let c=z(e,r,s);return i(l,c[0]??null)})}function nS(e,t,n){function r(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(o.base){let l=z(i,o.base,n)[0],c=r(l,{type:"Field",name:o.name},a);return r(i,o.base,c)}return i&&typeof i=="object"&&!Array.isArray(i)?{...i,[o.name]:a}:i}case"Index":{if(o.base){let u=z(i,o.base,n)[0],f=r(u,{type:"Index",index:o.index},a);return r(i,o.base,f)}let c=z(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}return typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?{...i,[c]:a}:i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(o.base){let l=z(i,o.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l={...i};return delete l[o.name],l}return i}case"Index":{if(o.base){let u=z(i,o.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return r(i,o.base,f)}let c=z(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let u={...i};return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?{}:i;case"Pipe":{let u=function(d,m,h){switch(m.type){case"Identity":return h;case"Field":return d&&typeof d=="object"&&!Array.isArray(d)?{...d,[m.name]:h}:d;case"Index":{let b=z(e,m.index,n)[0];if(typeof b=="number"&&Array.isArray(d)){let y=[...d],w=b<0?y.length+b:b;return w>=0&&w<y.length&&(y[w]=h),y}return typeof b=="string"&&d&&typeof d=="object"&&!Array.isArray(d)?{...d,[b]:h}:d}case"Pipe":{let g=z(d,m.left,n)[0],b=u(g,m.right,h);return u(d,m.left,b)}default:return d}};var a=u;let l=o.left,c=o.right,f=z(i,l,n)[0];if(f==null)return i;let p=s(f,c);return u(i,l,p)}default:return i}}return s(e,t)}function rS(e,t,n,r,s){if(t==="and")return z(e,n,s).flatMap(l=>vt(l)?z(e,r,s).map(u=>vt(u)):[!1]);if(t==="or")return z(e,n,s).flatMap(l=>vt(l)?[!0]:z(e,r,s).map(u=>vt(u)));if(t==="//"){let l=z(e,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:z(e,r,s)}let i=z(e,n,s),o=z(e,r,s);return i.flatMap(a=>o.map(l=>{switch(t){case"+":return a===null?l:l===null?a:typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?{...a,...l}:null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":return typeof a=="number"&&typeof l=="number"?a*l:typeof a=="string"&&typeof l=="number"?a.repeat(l):a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?Ro(a,l):null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return jn(a,l);case"!=":return!jn(a,l);case"<":return Nr(a,l)<0;case"<=":return Nr(a,l)<=0;case">":return Nr(a,l)>0;case">=":return Nr(a,l)>=0;default:return null}}))}function Zp(e,t,n,r){let s=JE[t];if(s)return typeof e=="number"?[s(e)]:[null];let i=Oo(e,t,n,r,z);if(i!==null)return i;let o=Mo(e,t,n,r,z);if(o!==null)return o;let a=Io(e,t,n,r,z);if(a!==null)return a;let l=Po(e,t,r.limits.maxDepth);if(l!==null)return l;let c=Wo(e,t);if(c!==null)return c;let u=Fo(e,t,n,r,z);if(u!==null)return u;let f=vo(e,t,n,r,z,Vp,Cs,vt,Ns,ne);if(f!==null)return f;let p=_o(e,t,n,r,z,vt,vs,$s,nS,Is);if(p!==null)return p;let d=To(e,t,n,r,z,jn);if(d!==null)return d;let m=$o(e,t,n,r,z,Vp,vt,ne);if(m!==null)return m;let h=Do(e,t,n,r,z,vt,eS,Zp);if(h!==null)return h;let g=Lo(e,t,n,r,z,jn);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"]];case"error":{let b=n.length>0?z(e,n[0],r)[0]:e;throw new Rs(b)}case"env":return[r.env??{}];case"debug":return[e];case"input_line_number":return[1];default:{let b=`${t}/${n.length}`,y=r.funcs?.get(b);if(y){let w=y.closure??r.funcs??new Map,E=new Map(w);E.set(b,y);for(let A=0;A<y.params.length;A++){let I=y.params[A],O=n[A];if(O){let L=z(e,O,r),D;if(L.length===0)D={type:"Call",name:"empty",args:[]};else if(L.length===1)D={type:"Literal",value:L[0]};else{D={type:"Literal",value:L[L.length-1]};for(let $=L.length-2;$>=0;$--)D={type:"Comma",left:{type:"Literal",value:L[$]},right:D}}E.set(`${I}/0`,{params:[],body:D})}}let C={...r,funcs:E};return z(e,y.body,C)}throw new Error(`Unknown function: ${t}`)}}}function Is(e,t,n,r,s){if(t.type==="Comma"){let a=t;Is(e,a.left,n,r,s),Is(e,a.right,n,r,s);return}let i=Yt(t);if(i!==null){s.push([...r,...i]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let a=0;a<e.length;a++)s.push([...r,a]);else if(e&&typeof e=="object")for(let a of Object.keys(e))s.push([...r,a]);return}if(t.type==="Recurse"){let a=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(e,[]);return}if(t.type==="Pipe"){let a=Yt(t.left);if(a!==null){let l=z(e,t.left,n);for(let c of l)Is(c,t.right,n,[...r,...a],s);return}}z(e,t,n).length>0&&s.push(r)}var Vn,Rs,XE,Gp,JE,Qp=v(()=>{"use strict";de();jp();Hp();ks();Vn=class e extends Error{label;partialResults;constructor(t,n=[]){super(`break ${t}`),this.label=t,this.partialResults=n,this.name="BreakError"}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},Rs=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},XE=1e4,Gp=2e3,JE={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 Kp(e){let t=[],n=0,r=(c=0)=>e[n+c],s=()=>e[n++],i=()=>n>=e.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
530
+ `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(e)?[e.map(r=>String(r??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let r=n??QE;return Hn(e,r+1)>r?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[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 QE,Dp=v(()=>{"use strict";ks();QE=2e3});function To(e,t,n,r,s,i){switch(t){case"index":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){if(a===""&&e==="")return null;let l=e.indexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let c=0;c<=e.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(e[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=e.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){let l=e.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let l=e.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(e[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=e.length-1;l>=0;l--)if(i(e[l],a))return l;return null}return null});case"indices":return n.length===0?[[]]:s(e,n[0],r).map(a=>{let l=[];if(typeof e=="string"&&typeof a=="string"){let c=e.indexOf(a);for(;c!==-1;)l.push(c),c=e.indexOf(a,c+1)}else if(Array.isArray(e))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=e.length;u++)l.push(u);else for(let u=0;u<=e.length-c;u++){let f=!0;for(let p=0;p<c;p++)if(!i(e[u+p],a[p])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<e.length;c++)i(e[c],a)&&l.push(c);return l});default:return null}}var Fp=v(()=>{"use strict"});function Oo(e,t,n,r,s){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(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.hypot(e,i)]}case"fma":{if(typeof e!="number"||n.length<2)return[null];let i=s(e,n[0],r)[0],o=s(e,n[1],r)[0];return[e*i+o]}case"copysign":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.sign(i)*Math.abs(e)]}case"drem":case"remainder":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e-Math.round(e/i)*i]}case"fdim":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(0,e-i)]}case"fmax":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(e,i)]}case"fmin":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.min(e,i)]}case"ldexp":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"scalbn":case"scalbln":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}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":if(typeof e=="number"){let i=Math.floor(Math.log2(Math.abs(e)));return[e/2**i]}return[null];case"frexp":if(typeof e=="number"){if(e===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**i,i]]}return[null];case"modf":if(typeof e=="number"){let i=Math.trunc(e);return[[e-i,i]]}return[null];default:return null}}var _p=v(()=>{"use strict"});function Do(e,t,n,r,s,i,o,a){switch(t){case"recurse":{if(n.length===0){let d=[],m=h=>{if(d.push(h),Array.isArray(h))for(let g of h)m(g);else if(h&&typeof h=="object")for(let g of Object.keys(h))m(h[g])};return m(e),d}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,p=d=>{if(f++>u||c&&!s(d,c,r).some(i))return;l.push(d);let m=s(d,n[0],r);for(let h of m)h!=null&&p(h)};return p(e),l}case"recurse_down":return a(e,"recurse",n,r);case"walk":{if(n.length===0)return[e];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let d={};for(let[m,h]of Object.entries(u))d[m]=c(h);f=d}else f=u;return s(f,n[0],r)[0]};return[c(e)]}case"transpose":{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let l=Math.max(...e.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(e.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(n.length>0){let f=s(e,n[0],r)[0];if(!Array.isArray(e)||f<0)return[];if(f===0)return[[]];let p=[],d=(m,h)=>{if(h===f){p.push([...m]);return}for(let g of e)m.push(g),d(m,h+1),m.pop()};return d([],0),p}if(!Array.isArray(e))return[];if(e.length===0)return[[]];for(let u of e)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===e.length){l.push([...f]);return}let p=e[u];for(let d of p)f.push(d),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let l=r.currentPath;if(l.length===0)return[];let c=n.length>0?s(e,n[0],r)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[e];let f=l.slice(0,u);return[o(r.root,f)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let l=r.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var Lp=v(()=>{"use strict"});function Fo(e,t,n,r,s){switch(t){case"keys":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e)]:[null];case"length":return typeof e=="string"?[e.length]: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[new TextEncoder().encode(e).length];let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":return e&&typeof e=="object"&&!Array.isArray(e)?[Object.entries(e).map(([i,o])=>({key:i,value:o}))]:[null];case"from_entries":if(Array.isArray(e)){let i={};for(let o of e)if(o&&typeof o=="object"){let a=o,l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;l!==void 0&&(i[String(l)]=c)}return[i]}return[null];case"with_entries":{if(n.length===0)return[e];if(e&&typeof e=="object"&&!Array.isArray(e)){let o=Object.entries(e).map(([l,c])=>({key:l,value:c})).flatMap(l=>s(l,n[0],r)),a={};for(let l of o)if(l&&typeof l=="object"){let c=l,u=c.key??c.name??c.k,f=c.value??c.v;u!==void 0&&(a[String(u)]=f)}return[a]}return[null]}case"reverse":return Array.isArray(e)?[[...e].reverse()]:typeof e=="string"?[e.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(e)?(n.length>0?s(e,n[0],r):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return e.flat(a)}):[null];case"unique":if(Array.isArray(e)){let i=new Set,o=[];for(let a of e){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??KE;return Hn(e,i+1)>i?[null]:[JSON.stringify(e)]}case"fromjson":{if(typeof e=="string"){let i=e.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(e)]}catch{throw new 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 i=Number(e);if(Number.isNaN(i))throw new Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[i]}throw new 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 new Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,{}]);else for(let u of c)o(a[u],[...l,u])}};return o(e,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[e];let i=s(e,n[0],r),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:{});let u=o;for(let p=0;p<l.length-1;p++){let d=l[p],m=l[p+1];if(Array.isArray(u)&&typeof d=="number"){for(;u.length<=d;)u.push(null);u[d]===null&&(u[d]=typeof m=="number"?[]:{}),u=u[d]}else if(u&&typeof u=="object"&&!Array.isArray(u)){let h=u;(h[String(d)]===null||h[String(d)]===void 0)&&(h[String(d)]=typeof m=="number"?[]:{}),u=h[String(d)]}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else u&&typeof u=="object"&&!Array.isArray(u)&&(u[String(f)]=c)}return[o]}case"truncate_stream":{let i=typeof e=="number"?Math.floor(e):0;if(n.length===0)return[];let o=[],a=s(e,n[0],r);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var KE,Mp=v(()=>{"use strict";ks();KE=2e3});function _o(e,t,n,r,s,i,o,a,l,c){switch(t){case"getpath":{if(n.length===0)return[null];let u=s(e,n[0],r),f=[];for(let p of u){let d=p,m=e;for(let h of d){if(m==null){m=null;break}if(Array.isArray(m)&&typeof h=="number")m=m[h];else if(typeof m=="object"&&typeof h=="string")m=m[h];else{m=null;break}}f.push(m)}return f}case"setpath":{if(n.length<2)return[null];let f=s(e,n[0],r)[0],d=s(e,n[1],r)[0];return[o(e,f,d)]}case"delpaths":{if(n.length===0)return[e];let f=s(e,n[0],r)[0],p=e;for(let d of f.sort((m,h)=>h.length-m.length))p=a(p,d);return[p]}case"path":{if(n.length===0)return[[]];let u=[];return c(e,n[0],r,[],u),u}case"del":return n.length===0?[e]:[l(e,n[0],r)];case"pick":{if(n.length===0)return[null];let u=[];for(let p of n)c(e,p,r,[],u);let f=null;for(let p of u){for(let m of p)if(typeof m=="number"&&m<0)throw new Error("Out of bounds negative array index");let d=e;for(let m of p){if(d==null)break;if(Array.isArray(d)&&typeof m=="number")d=d[m];else if(typeof d=="object"&&typeof m=="string")d=d[m];else{d=null;break}}f=o(f,p,d)}return[f]}case"paths":{let u=[],f=(p,d)=>{if(p&&typeof p=="object")if(Array.isArray(p))for(let m=0;m<p.length;m++)u.push([...d,m]),f(p[m],[...d,m]);else for(let m of Object.keys(p))u.push([...d,m]),f(p[m],[...d,m])};return f(e,[]),n.length>0?u.filter(p=>{let d=e;for(let h of p)if(Array.isArray(d)&&typeof h=="number")d=d[h];else if(d&&typeof d=="object"&&typeof h=="string")d=d[h];else return!1;return s(d,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(p,d)=>{if(p===null||typeof p!="object")u.push(d);else if(Array.isArray(p))for(let m=0;m<p.length;m++)f(p[m],[...d,m]);else for(let m of Object.keys(p))f(p[m],[...d,m])};return f(e,[]),u}default:return null}}var Wp=v(()=>{"use strict"});function Lo(e,t,n,r,s,i){switch(t){case"IN":{if(n.length===0)return[!1];if(n.length===1){let c=s(e,n[0],r);for(let u of c)if(i(e,u))return[!0];return[!1]}let o=s(e,n[0],r),a=s(e,n[1],r),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(n.length===0)return[{}];if(n.length===1){let l=s(e,n[0],r),c={};for(let u of l){let f=String(u);c[f]=u}return[c]}if(n.length===2){let l=s(e,n[0],r),c={};for(let u of l){let f=s(u,n[1],r);if(f.length>0){let p=String(f[0]);c[p]=u}}return[c]}let o=s(e,n[0],r),a={};for(let l of o){let c=s(l,n[1],r),u=s(l,n[2],r);if(c.length>0&&u.length>0){let f=String(c[0]);a[f]=u[0]}}return[a]}case"JOIN":{if(n.length<2)return[null];let o=s(e,n[0],r)[0];if(!o||typeof o!="object"||Array.isArray(o))return[null];let a=o;if(!Array.isArray(e))return[null];let l=[];for(let c of e){let u=s(c,n[1],r),f=u.length>0?String(u[0]):"",p=f in a?a[f]:null;l.push([c,p])}return[l]}default:return null}}var Bp=v(()=>{"use strict"});function Mo(e,t,n,r,s){switch(t){case"join":{if(!Array.isArray(e))return[null];let i=n.length>0?s(e,n[0],r):[""];for(let o of e)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>e.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);return[e.split(o)]}case"splits":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"g",l=new RegExp(o,a.includes("g")?a:`${a}g`);return e.split(l)}catch{return[]}}case"scan":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",l=new RegExp(o,a.includes("g")?a:`${a}g`);return[...e.matchAll(l)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[new RegExp(o,a).test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=new RegExp(o,`${a}d`).exec(e);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,p)=>({offset:u?.[p+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",l=new RegExp(o,a),c=e.match(l);return!c||!c.groups?[{}]:[c.groups]}catch{return[null]}}case"sub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"";return[e.replace(new RegExp(a,c),l)]}catch{return[e]}}case"gsub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[e.replace(new RegExp(a,u),l)]}catch{return[e]}}case"ascii_downcase":return typeof e=="string"?[e.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof e=="string"?[e.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return[e.startsWith(o)?e.slice(o.length):e]}case"rtrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return o===""?[e]:[e.endsWith(o)?e.slice(0,-o.length):e]}case"trimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);if(o==="")return[e];let a=e;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof e=="string")return[e.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof e=="string")return[e.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof e=="string")return[e.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.startsWith(String(i[0]))]}case"endswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.endsWith(String(i[0]))]}case"ascii":return typeof e=="string"&&e.length>0?[e.charCodeAt(0)]:[null];case"explode":return typeof e=="string"?[Array.from(e).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(e))throw new Error("implode input must be an array");return[e.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var Up=v(()=>{"use strict"});function Wo(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[Number.POSITIVE_INFINITY];case"nan":return[Number.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 zp=v(()=>{"use strict"});var jp=v(()=>{"use strict";Pp();Tp();Op();Dp();Fp();_p();Lp();Mp();Wp();Bp();Up();zp()});function vs(e,t,n){if(t.length===0)return n;let[r,...s]=t;if(typeof r=="number"){if(e&&typeof e=="object"&&!Array.isArray(e))throw new Error("Cannot index object with number");if(r>536870911)throw new Error("Array index too large");if(r<0)throw new Error("Out of bounds negative array index");let a=Array.isArray(e)?[...e]:[];for(;a.length<=r;)a.push(null);return a[r]=vs(a[r],s,n),a}if(Array.isArray(e))throw new Error("Cannot index array with string");let i=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};return i[r]=vs(i[r],s,n),i}function $s(e,t){if(t.length===0)return null;if(t.length===1){let s=t[0];if(Array.isArray(e)&&typeof s=="number"){let i=[...e];return i.splice(s,1),i}if(e&&typeof e=="object"&&!Array.isArray(e)){let i={...e};return delete i[String(s)],i}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n=="number"){let s=[...e];return s[n]=$s(s[n],r),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s={...e};return s[String(n)]=$s(s[String(n)],r),s}return e}var Hp=v(()=>{"use strict"});function YE(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??XE,maxDepth:e?.limits?.maxDepth??Gp},env:e?.env}}function Ps(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels}}function kr(e,t,n){switch(t.type){case"var":return Ps(e,t.name,n);case"array":{if(!Array.isArray(n))return null;let r=e;for(let s=0;s<t.elements.length;s++){let i=t.elements[s],o=s<n.length?n[s]:null,a=kr(r,i,o);if(a===null)return null;r=a}return r}case"object":{if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,s=e;for(let i of t.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=z(n,i.key,e);if(c.length===0)return null;o=String(c[0])}let a=o in r?r[o]:null;i.keyVar&&(s=Ps(s,i.keyVar,a));let l=kr(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function eS(e,t){let n=e;for(let r of t)if(n&&typeof n=="object")n=n[r];else return;return n}function en(e){if(e.type==="Identity")return[];if(e.type==="Field"){let t=e.base?en(e.base):[];return t===null?null:[...t,e.name]}if(e.type==="Index"&&e.index.type==="Literal"){let t=e.base?en(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n=="number"||typeof n=="string"?[...t,n]:null}if(e.type==="Pipe"){let t=en(e.left);return t===null?null:Bo(t,e.right)}if(e.type==="Call"){if(e.name==="parent"||e.name==="root")return null;if(e.name==="first"&&e.args.length===0)return[0];if(e.name==="last"&&e.args.length===0)return[-1]}return null}function Bo(e,t){if(t.type==="Call"){if(t.name==="parent"){let n=1;if(t.args.length>0&&t.args[0].type==="Literal"){let r=t.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let r=-n-1;return e.slice(0,Math.min(r,e.length))}}if(t.name==="root")return[]}if(t.type==="Field"){let n=en(t);if(n!==null)return[...e,...n]}if(t.type==="Index"&&t.index.type==="Literal"){let n=en(t);if(n!==null)return[...e,...n]}if(t.type==="Pipe"){let n=Bo(e,t.left);return n===null?null:Bo(n,t.right)}return t.type==="Identity"?e:null}function Vp(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...z(e,t.left,n))}catch(s){if(s instanceof ne)throw s;if(r.length>0)return r;throw new Error("evaluation failed")}try{r.push(...z(e,t.right,n))}catch(s){if(s instanceof ne)throw s;return r}return r}return z(e,t,n)}function z(e,t,n){let r=n&&"vars"in n?n:YE(n);switch(r.root===void 0&&(r={...r,root:e,currentPath:[]}),t.type){case"Identity":return[e];case"Field":return(t.base?z(e,t.base,r):[e]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i[t.name];return[a===void 0?null:a]}if(i===null)return[null];let o=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${o} with string "${t.name}"`)});case"Index":return(t.base?z(e,t.base,r):[e]).flatMap(i=>z(i,t.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}return typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[a]]:[null]}));case"Slice":return(t.base?z(e,t.base,r):[e]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=t.start?z(e,t.start,r):[0],l=t.end?z(e,t.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=c,p=u,d=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),m=Number.isNaN(p)?o:Number.isInteger(p)?p:Math.ceil(p),h=qp(d,o),g=qp(m,o);return Array.isArray(i),i.slice(h,g)}))});case"Iterate":return(t.base?z(e,t.base,r):[e]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=z(e,t.left,r),i=en(t.left),o=[];for(let a of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};o.push(...z(a,t.right,l))}else o.push(...z(a,t.right,r))}catch(l){throw l instanceof Vn?l.withPrependedResults(o):l}return o}case"Comma":{let s=z(e,t.left,r),i=z(e,t.right,r);return[...s,...i]}case"Literal":return[t.value];case"Array":return t.elements?[z(e,t.elements,r)]:[[]];case"Object":{let s=[{}];for(let i of t.entries){let o=typeof i.key=="string"?[i.key]:z(e,i.key,r),a=z(e,i.value,r),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}for(let f of a)l.push({...c,[u]:f})}s.length=0,s.push(...l)}return s}case"Paren":return z(e,t.expr,r);case"BinaryOp":return rS(e,t.op,t.left,t.right,r);case"UnaryOp":return z(e,t.operand,r).map(i=>{if(t.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return t.op==="not"?!vt(i):null});case"Cond":return z(e,t.cond,r).flatMap(i=>{if(vt(i))return z(e,t.then,r);for(let o of t.elifs)if(z(e,o.cond,r).some(vt))return z(e,o.then,r);return t.else?z(e,t.else,r):[e]});case"Try":try{return z(e,t.body,r)}catch(s){if(t.catch){let i=s instanceof Rs?s.value:s instanceof Error?s.message:String(s);return z(i,t.catch,r)}return[]}case"Call":return Zp(e,t.name,t.args,r);case"VarBind":return z(e,t.value,r).flatMap(i=>{let o=null,a=[];t.pattern?a.push(t.pattern):t.name&&a.push({type:"var",name:t.name}),t.alternatives&&a.push(...t.alternatives);for(let l of a)if(o=kr(r,l,i),o!==null)break;return o===null?[]:z(e,t.body,o)});case"VarRef":{if(t.name==="$ENV")return[r.env??{}];let s=r.vars.get(t.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(e),s}case"Optional":try{return z(e,t.expr,r)}catch{return[]}case"StringInterp":return[t.parts.map(i=>typeof i=="string"?i:z(e,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[tS(e,t.path,t.op,t.value,r)];case"Reduce":{let s=z(e,t.expr,r),i=z(e,t.init,r)[0],o=r.limits.maxDepth??Gp;for(let a of s){let l;if(t.pattern){if(l=kr(r,t.pattern,a),l===null)continue}else l=Ps(r,t.varName,a);if(i=z(i,t.update,l)[0],Hn(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=z(e,t.expr,r),i=z(e,t.init,r)[0],o=[];for(let a of s)try{let l;if(t.pattern){if(l=kr(r,t.pattern,a),l===null)continue}else l=Ps(r,t.varName,a);if(i=z(i,t.update,l)[0],t.extract){let c=z(i,t.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof Vn?l.withPrependedResults(o):l}return o}case"Label":try{return z(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(s){if(s instanceof Vn&&s.label===t.name)return s.partialResults;throw s}case"Break":throw new Vn(t.name);case"Def":{let s=new Map(r.funcs??[]),i=`${t.name}/${t.params.length}`;s.set(i,{params:t.params,body:t.funcBody,closure:new Map(r.funcs??[])});let o={...r,funcs:s};return z(e,t.body,o)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function qp(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function tS(e,t,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return z(l,r,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?{...l,...c}:c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let p={...f};return p[c.name]=u(p[c.name]),p}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l};return f[c.name]=u(f[c.name]),f}return l}case"Index":{let p=z(e,c.index,s)[0];if(typeof p=="number"&&Number.isNaN(p))throw new Error("Cannot set array element at NaN index");if(typeof p=="number"&&!Number.isInteger(p)&&(p=Math.trunc(p)),c.base)return o(l,c.base,d=>{if(typeof p=="number"&&Array.isArray(d)){let m=[...d],h=p<0?m.length+p:p;if(h>=0){for(;m.length<=h;)m.push(null);m[h]=u(m[h])}return m}if(typeof p=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){let m={...d};return m[p]=u(m[p]),m}return d});if(typeof p=="number"){if(p>536870911)throw new Error("Array index too large");if(p<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let m=[...l],h=p<0?m.length+p:p;if(h>=0){for(;m.length<=h;)m.push(null);m[h]=u(m[h])}return m}if(l==null){let m=[];for(;m.length<=p;)m.push(null);return m[p]=u(null),m}return l}if(typeof p=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){let d={...l};return d[p]=u(d[p]),d}return l}case"Iterate":{let f=p=>{if(Array.isArray(p))return p.map(d=>u(d));if(p&&typeof p=="object"){let d={};for(let[m,h]of Object.entries(p))d[m]=u(h);return d}return p};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,p=>p);return o(f,c.right,u)}default:return u(l)}}return o(e,t,l=>{if(n==="|=")return i(l,l);let c=z(e,r,s);return i(l,c[0]??null)})}function nS(e,t,n){function r(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(o.base){let l=z(i,o.base,n)[0],c=r(l,{type:"Field",name:o.name},a);return r(i,o.base,c)}return i&&typeof i=="object"&&!Array.isArray(i)?{...i,[o.name]:a}:i}case"Index":{if(o.base){let u=z(i,o.base,n)[0],f=r(u,{type:"Index",index:o.index},a);return r(i,o.base,f)}let c=z(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}return typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?{...i,[c]:a}:i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(o.base){let l=z(i,o.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l={...i};return delete l[o.name],l}return i}case"Index":{if(o.base){let u=z(i,o.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return r(i,o.base,f)}let c=z(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let u={...i};return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?{}:i;case"Pipe":{let u=function(d,m,h){switch(m.type){case"Identity":return h;case"Field":return d&&typeof d=="object"&&!Array.isArray(d)?{...d,[m.name]:h}:d;case"Index":{let b=z(e,m.index,n)[0];if(typeof b=="number"&&Array.isArray(d)){let y=[...d],w=b<0?y.length+b:b;return w>=0&&w<y.length&&(y[w]=h),y}return typeof b=="string"&&d&&typeof d=="object"&&!Array.isArray(d)?{...d,[b]:h}:d}case"Pipe":{let g=z(d,m.left,n)[0],b=u(g,m.right,h);return u(d,m.left,b)}default:return d}};var a=u;let l=o.left,c=o.right,f=z(i,l,n)[0];if(f==null)return i;let p=s(f,c);return u(i,l,p)}default:return i}}return s(e,t)}function rS(e,t,n,r,s){if(t==="and")return z(e,n,s).flatMap(l=>vt(l)?z(e,r,s).map(u=>vt(u)):[!1]);if(t==="or")return z(e,n,s).flatMap(l=>vt(l)?[!0]:z(e,r,s).map(u=>vt(u)));if(t==="//"){let l=z(e,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:z(e,r,s)}let i=z(e,n,s),o=z(e,r,s);return i.flatMap(a=>o.map(l=>{switch(t){case"+":return a===null?l:l===null?a:typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?{...a,...l}:null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":return typeof a=="number"&&typeof l=="number"?a*l:typeof a=="string"&&typeof l=="number"?a.repeat(l):a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?Ro(a,l):null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return jn(a,l);case"!=":return!jn(a,l);case"<":return Nr(a,l)<0;case"<=":return Nr(a,l)<=0;case">":return Nr(a,l)>0;case">=":return Nr(a,l)>=0;default:return null}}))}function Zp(e,t,n,r){let s=JE[t];if(s)return typeof e=="number"?[s(e)]:[null];let i=Oo(e,t,n,r,z);if(i!==null)return i;let o=Mo(e,t,n,r,z);if(o!==null)return o;let a=Io(e,t,n,r,z);if(a!==null)return a;let l=Po(e,t,r.limits.maxDepth);if(l!==null)return l;let c=Wo(e,t);if(c!==null)return c;let u=Fo(e,t,n,r,z);if(u!==null)return u;let f=vo(e,t,n,r,z,Vp,Cs,vt,Ns,ne);if(f!==null)return f;let p=_o(e,t,n,r,z,vt,vs,$s,nS,Is);if(p!==null)return p;let d=To(e,t,n,r,z,jn);if(d!==null)return d;let m=$o(e,t,n,r,z,Vp,vt,ne);if(m!==null)return m;let h=Do(e,t,n,r,z,vt,eS,Zp);if(h!==null)return h;let g=Lo(e,t,n,r,z,jn);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"]];case"error":{let b=n.length>0?z(e,n[0],r)[0]:e;throw new Rs(b)}case"env":return[r.env??{}];case"debug":return[e];case"input_line_number":return[1];default:{let b=`${t}/${n.length}`,y=r.funcs?.get(b);if(y){let w=y.closure??r.funcs??new Map,E=new Map(w);E.set(b,y);for(let A=0;A<y.params.length;A++){let I=y.params[A],O=n[A];if(O){let L=z(e,O,r),D;if(L.length===0)D={type:"Call",name:"empty",args:[]};else if(L.length===1)D={type:"Literal",value:L[0]};else{D={type:"Literal",value:L[L.length-1]};for(let $=L.length-2;$>=0;$--)D={type:"Comma",left:{type:"Literal",value:L[$]},right:D}}E.set(`${I}/0`,{params:[],body:D})}}let C={...r,funcs:E};return z(e,y.body,C)}throw new Error(`Unknown function: ${t}`)}}}function Is(e,t,n,r,s){if(t.type==="Comma"){let a=t;Is(e,a.left,n,r,s),Is(e,a.right,n,r,s);return}let i=en(t);if(i!==null){s.push([...r,...i]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let a=0;a<e.length;a++)s.push([...r,a]);else if(e&&typeof e=="object")for(let a of Object.keys(e))s.push([...r,a]);return}if(t.type==="Recurse"){let a=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(e,[]);return}if(t.type==="Pipe"){let a=en(t.left);if(a!==null){let l=z(e,t.left,n);for(let c of l)Is(c,t.right,n,[...r,...a],s);return}}z(e,t,n).length>0&&s.push(r)}var Vn,Rs,XE,Gp,JE,Qp=v(()=>{"use strict";de();jp();Hp();ks();Vn=class e extends Error{label;partialResults;constructor(t,n=[]){super(`break ${t}`),this.label=t,this.partialResults=n,this.name="BreakError"}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},Rs=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},XE=1e4,Gp=2e3,JE={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 Kp(e){let t=[],n=0,r=(c=0)=>e[n+c],s=()=>e[n++],i=()=>n>=e.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
531
531
  `||u==="\r")){if(u==="#"){for(;!i()&&r()!==`
532
532
  `;)s();continue}if(u==="."&&r()==="."){s(),t.push({type:"DOTDOT",pos:c});continue}if(u==="="&&r()==="="){s(),t.push({type:"EQ",pos:c});continue}if(u==="!"&&r()==="="){s(),t.push({type:"NE",pos:c});continue}if(u==="<"&&r()==="="){s(),t.push({type:"LE",pos:c});continue}if(u===">"&&r()==="="){s(),t.push({type:"GE",pos:c});continue}if(u==="/"&&r()==="/"){s(),r()==="="?(s(),t.push({type:"UPDATE_ALT",pos:c})):t.push({type:"ALT",pos:c});continue}if(u==="+"&&r()==="="){s(),t.push({type:"UPDATE_ADD",pos:c});continue}if(u==="-"&&r()==="="){s(),t.push({type:"UPDATE_SUB",pos:c});continue}if(u==="*"&&r()==="="){s(),t.push({type:"UPDATE_MUL",pos:c});continue}if(u==="/"&&r()==="="){s(),t.push({type:"UPDATE_DIV",pos:c});continue}if(u==="%"&&r()==="="){s(),t.push({type:"UPDATE_MOD",pos:c});continue}if(u==="="&&r()!=="="){t.push({type:"ASSIGN",pos:c});continue}if(u==="."){t.push({type:"DOT",pos:c});continue}if(u==="|"){r()==="="?(s(),t.push({type:"UPDATE_PIPE",pos:c})):t.push({type:"PIPE",pos:c});continue}if(u===","){t.push({type:"COMMA",pos:c});continue}if(u===":"){t.push({type:"COLON",pos:c});continue}if(u===";"){t.push({type:"SEMICOLON",pos:c});continue}if(u==="("){t.push({type:"LPAREN",pos:c});continue}if(u===")"){t.push({type:"RPAREN",pos:c});continue}if(u==="["){t.push({type:"LBRACKET",pos:c});continue}if(u==="]"){t.push({type:"RBRACKET",pos:c});continue}if(u==="{"){t.push({type:"LBRACE",pos:c});continue}if(u==="}"){t.push({type:"RBRACE",pos:c});continue}if(u==="?"){t.push({type:"QUESTION",pos:c});continue}if(u==="+"){t.push({type:"PLUS",pos:c});continue}if(u==="-"){t.push({type:"MINUS",pos:c});continue}if(u==="*"){t.push({type:"STAR",pos:c});continue}if(u==="/"){t.push({type:"SLASH",pos:c});continue}if(u==="%"){t.push({type:"PERCENT",pos:c});continue}if(u==="<"){t.push({type:"LT",pos:c});continue}if(u===">"){t.push({type:"GT",pos:c});continue}if(o(u)){let f=u;for(;!i()&&(o(r())||r()==="."||r()==="e"||r()==="E");)(r()==="e"||r()==="E")&&(e[n+1]==="+"||e[n+1]==="-")&&(f+=s()),f+=s();t.push({type:"NUMBER",value:Number(f),pos:c});continue}if(u==='"'){let f="";for(;!i()&&r()!=='"';)if(r()==="\\"){if(s(),i())break;let p=s();switch(p){case"n":f+=`
533
533
  `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=p}}else f+=s();i()||s(),t.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(r());)f+=s();let p=sS[f];p?t.push({type:p,pos:c}):t.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return t.push({type:"EOF",pos:n}),t}function Xp(e){let t=Kp(e);return new Uo(t).parse()}var sS,Uo,Jp=v(()=>{"use strict";sS={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"};Uo=class e{tokens;pos=0;constructor(t){this.tokens=t}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 n of t)if(this.check(n))return this.advance();return null}expect(t,n){if(!this.check(t))throw new Error(`${n} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let t=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return t}parseExpr(){return this.parsePipe()}parsePattern(){if(this.match("LBRACKET")){let r=[];if(!this.check("RBRACKET"))for(r.push(this.parsePattern());this.match("COMMA")&&!this.check("RBRACKET");)r.push(this.parsePattern());return this.expect("RBRACKET","Expected ']' after array pattern"),{type:"array",elements:r}}if(this.match("LBRACE")){let r=[];if(!this.check("RBRACE"))for(r.push(this.parsePatternField());this.match("COMMA")&&!this.check("RBRACE");)r.push(this.parsePatternField());return this.expect("RBRACE","Expected '}' after object pattern"),{type:"object",fields:r}}let t=this.expect("IDENT","Expected variable name in pattern"),n=t.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${t.pos}`);return{type:"var",name:n}}parsePatternField(){if(this.match("LPAREN")){let n=this.parseExpr();this.expect("RPAREN","Expected ')' after computed key"),this.expect("COLON","Expected ':' after computed key");let r=this.parsePattern();return{key:n,pattern:r}}let t=this.peek();if(t.type==="IDENT"){let n=t.value;if(n.startsWith("$")){if(this.advance(),this.match("COLON")){let r=this.parsePattern();return{key:n.slice(1),pattern:r,keyVar:n}}return{key:n.slice(1),pattern:{type:"var",name:n}}}if(this.advance(),this.match("COLON")){let r=this.parsePattern();return{key:n,pattern:r}}return{key:n,pattern:{type:"var",name:`$${n}`}}}throw new Error(`Expected field name in object pattern at position ${t.pos}`)}parsePipe(){let t=this.parseComma();for(;this.match("PIPE");){let n=this.parseComma();t={type:"Pipe",left:t,right:n}}return t}parseComma(){let t=this.parseVarBind();for(;this.match("COMMA");){let n=this.parseVarBind();t={type:"Comma",left:t,right:n}}return t}parseVarBind(){let t=this.parseUpdate();if(this.match("AS")){let n=this.parsePattern(),r=[];for(;this.check("QUESTION")&&this.peekAhead(1)?.type==="ALT";)this.advance(),this.advance(),r.push(this.parsePattern());this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return n.type==="var"&&r.length===0?{type:"VarBind",name:n.name,value:t,body:s}:{type:"VarBind",name:n.type==="var"?n.name:"",value:t,body:s,pattern:n.type!=="var"?n:void 0,alternatives:r.length>0?r:void 0}}return t}peekAhead(t){let n=this.pos+t;return n<this.tokens.length?this.tokens[n]:void 0}parseUpdate(){let t=this.parseAlt(),n={ASSIGN:"=",UPDATE_ADD:"+=",UPDATE_SUB:"-=",UPDATE_MUL:"*=",UPDATE_DIV:"/=",UPDATE_MOD:"%=",UPDATE_ALT:"//=",UPDATE_PIPE:"|="},r=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(r){let s=this.parseVarBind();return{type:"UpdateOp",op:n[r.type],path:t,value:s}}return t}parseAlt(){let t=this.parseOr();for(;this.match("ALT");){let n=this.parseOr();t={type:"BinaryOp",op:"//",left:t,right:n}}return t}parseOr(){let t=this.parseAnd();for(;this.match("OR");){let n=this.parseAnd();t={type:"BinaryOp",op:"or",left:t,right:n}}return t}parseAnd(){let t=this.parseNot();for(;this.match("AND");){let n=this.parseNot();t={type:"BinaryOp",op:"and",left:t,right:n}}return t}parseNot(){return this.parseComparison()}parseComparison(){let t=this.parseAddSub(),n={EQ:"==",NE:"!=",LT:"<",LE:"<=",GT:">",GE:">="},r=this.match("EQ","NE","LT","LE","GT","GE");if(r){let s=this.parseAddSub();t={type:"BinaryOp",op:n[r.type],left:t,right:s}}return t}parseAddSub(){let t=this.parseMulDiv();for(;;)if(this.match("PLUS")){let n=this.parseMulDiv();t={type:"BinaryOp",op:"+",left:t,right:n}}else if(this.match("MINUS")){let n=this.parseMulDiv();t={type:"BinaryOp",op:"-",left:t,right:n}}else break;return t}parseMulDiv(){let t=this.parseUnary();for(;;)if(this.match("STAR")){let n=this.parseUnary();t={type:"BinaryOp",op:"*",left:t,right:n}}else if(this.match("SLASH")){let n=this.parseUnary();t={type:"BinaryOp",op:"/",left:t,right:n}}else if(this.match("PERCENT")){let n=this.parseUnary();t={type:"BinaryOp",op:"%",left:t,right:n}}else break;return t}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("QUESTION"))t={type:"Optional",expr:t};else if(this.check("DOT")&&(this.peek(1).type==="IDENT"||this.peek(1).type==="STRING"))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 n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),t={type:"Slice",end:n,base:t}}else{let n=this.parseExpr();if(this.match("COLON")){let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),t={type:"Slice",start:n,end:r,base:t}}else this.expect("RBRACKET","Expected ']'"),t={type:"Index",index:n,base:t}}else break;return t}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.match("DOT")){if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:n}}let t=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:t,end:n}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:t}}return this.check("IDENT")||this.check("STRING")?{type:"Field",name:this.advance().value}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let n=this.advance().value;return n.includes("\\(")?this.parseStringInterpolation(n):{type:"Literal",value:n}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let 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.parsePostfix(),n;return this.match("CATCH")&&(n=this.parsePostfix()),{type:"Try",body:t,catch:n}}if(this.match("REDUCE")){let t=this.parseAddSub();this.expect("AS","Expected 'as' after reduce expression");let n=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let r=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr();this.expect("RPAREN","Expected ')' after update expression");let i=n.type==="var"?n.name:"";return{type:"Reduce",expr:t,varName:i,init:r,update:s,pattern:n.type!=="var"?n:void 0}}if(this.match("FOREACH")){let t=this.parseAddSub();this.expect("AS","Expected 'as' after foreach expression");let n=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let r=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr(),i;this.match("SEMICOLON")&&(i=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions");let o=n.type==="var"?n.name:"";return{type:"Foreach",expr:t,varName:o,init:r,update:s,extract:i,pattern:n.type!=="var"?n:void 0}}if(this.match("LABEL")){let t=this.expect("IDENT","Expected label name (e.g., $out)"),n=t.value;if(!n.startsWith("$"))throw new Error(`Label name must start with $ at position ${t.pos}`);this.expect("PIPE","Expected '|' after label name");let r=this.parseExpr();return{type:"Label",name:n,body:r}}if(this.match("BREAK")){let t=this.expect("IDENT","Expected label name to break to"),n=t.value;if(!n.startsWith("$"))throw new Error(`Break label must start with $ at position ${t.pos}`);return{type:"Break",name:n}}if(this.match("DEF")){let n=this.expect("IDENT","Expected function name after def").value,r=[];if(this.match("LPAREN")){if(!this.check("RPAREN")){let o=this.expect("IDENT","Expected parameter name");for(r.push(o.value);this.match("SEMICOLON");){let a=this.expect("IDENT","Expected parameter name");r.push(a.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after function body");let i=this.parseExpr();return{type:"Def",name:n,params:r,funcBody:s,body:i}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let n=this.advance().value;if(n.startsWith("$"))return{type:"VarRef",name:n};if(this.match("LPAREN")){let r=[];if(!this.check("RPAREN"))for(r.push(this.parseExpr());this.match("SEMICOLON");)r.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:n,args:r}}return{type:"Call",name:n,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let t=[];if(!this.check("RBRACE"))do{let n,r;if(this.match("LPAREN"))n=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else if(this.check("IDENT")){let s=this.advance().value;this.match("COLON")?(n=s,r=this.parseObjectValue()):(n=s,r={type:"Field",name:s})}else if(this.check("STRING"))n=this.advance().value,this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);t.push({key:n,value:r})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:t}}parseObjectValue(){let t=this.parseVarBind();for(;this.match("PIPE");){let n=this.parseVarBind();t={type:"Pipe",left:t,right:n}}return t}parseIf(){let t=this.parseExpr();this.expect("THEN","Expected 'then'");let n=this.parseExpr(),r=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();r.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:t,then:n,elifs:r,else:s}}parseStringInterpolation(t){let n=[],r="",s=0;for(;s<t.length;)if(t[s]==="\\"&&t[s+1]==="("){r&&(n.push(r),r=""),s+=2;let i=1,o="";for(;s<t.length&&i>0;)t[s]==="("?i++:t[s]===")"&&i--,i>0&&(o+=t[s]),s++;let a=Kp(o),l=new e(a);n.push(l.parse())}else r+=t[s],s++;return r&&n.push(r),{type:"StringInterp",parts:n}}}});var Yp=v(()=>{"use strict";Qp();Jp()});var td={};V(td,{jqCommand:()=>oS});function ed(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&/\s/.test(e[n]);)n++;if(n>=r)break;let s=n,i=e[n];if(i==="{"||i==="["){let o=i,a=i==="{"?"}":"]",l=1,c=!1,u=!1;for(n++;n<r&&l>0;){let f=e[n];u?u=!1:f==="\\"?u=!0:f==='"'?c=!c:c||(f===o?l++:f===a&&l--),n++}if(l!==0)throw new Error(`Unexpected end of JSON input at position ${n} (unclosed ${o})`);t.push(JSON.parse(e.slice(s,n)))}else if(i==='"'){let o=!1;for(n++;n<r;){let a=e[n];if(o)o=!1;else if(a==="\\")o=!0;else if(a==='"'){n++;break}n++}t.push(JSON.parse(e.slice(s,n)))}else if(i==="-"||i>="0"&&i<="9"){for(;n<r&&/[\d.eE+-]/.test(e[n]);)n++;t.push(JSON.parse(e.slice(s,n)))}else if(e.slice(n,n+4)==="true")t.push(!0),n+=4;else if(e.slice(n,n+5)==="false")t.push(!1),n+=5;else if(e.slice(n,n+4)==="null")t.push(null),n+=4;else{let o=e.slice(n,n+10);throw new Error(`Invalid JSON at position ${s}: unexpected '${o.split(/\s/)[0]}'`)}}return t}function vr(e,t,n,r,s,i=0){if(e===null||e===void 0)return"null";if(typeof e=="boolean")return String(e);if(typeof e=="number")return Number.isFinite(e)?String(e):"null";if(typeof e=="string")return n?e:JSON.stringify(e);let o=s?" ":" ";if(Array.isArray(e))return e.length===0?"[]":t?`[${e.map(l=>vr(l,!0,!1,r,s)).join(",")}]`:`[
@@ -701,7 +701,7 @@ PPid: ${t}
701
701
  Uid: ${n} ${n} ${n} ${n}
702
702
  Gid: ${r} ${r} ${r} ${r}
703
703
  `}var rm,sm,ca=v(()=>{"use strict";rm="5.1.0(1)-release",sm="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT"});function am(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let n=e.slice(t[0].length);if(n===""||n==="+")return!0;if(n[0]==="["){let r=0,s=0;for(;s<n.length;s++)if(n[s]==="[")r++;else if(n[s]==="]"&&(r--,r===0))break;if(r!==0||s>=n.length)return!1;let i=n.slice(s+1);return i===""||i==="+"}return!1}function lm(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r==="[")t++;else if(r==="]")t--;else{if(t===0&&r==="=")return n;if(t===0&&r==="+"&&e[n+1]==="=")return n+1}}return-1}function aC(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function cm(e){return e===" "||e===" "||e===`
704
- `||e===";"||e==="&"||e==="|"||e==="("||e===")"||e==="<"||e===">"}var x,Sn,Gs,sC,iC,oC,Zs,en=v(()=>{"use strict";(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"})(x||(x={}));Sn=class extends Error{line;column;constructor(t,n,r){super(`line ${n}: ${t}`),this.line=n,this.column=r,this.name="LexerError"}},Gs={if:x.IF,then:x.THEN,else:x.ELSE,elif:x.ELIF,fi:x.FI,for:x.FOR,while:x.WHILE,until:x.UNTIL,do:x.DO,done:x.DONE,case:x.CASE,esac:x.ESAC,in:x.IN,function:x.FUNCTION,select:x.SELECT,time:x.TIME,coproc:x.COPROC};sC=[[";",";","&",x.SEMI_SEMI_AND],["<","<","<",x.TLESS],["&",">",">",x.AND_DGREAT]],iC=[["[","[",x.DBRACK_START],["]","]",x.DBRACK_END],["(","(",x.DPAREN_START],[")",")",x.DPAREN_END],["&","&",x.AND_AND],["|","|",x.OR_OR],[";",";",x.DSEMI],[";","&",x.SEMI_AND],["|","&",x.PIPE_AMP],[">",">",x.DGREAT],["<","&",x.LESSAND],[">","&",x.GREATAND],["<",">",x.LESSGREAT],[">","|",x.CLOBBER],["&",">",x.AND_GREAT]],oC={"|":x.PIPE,"&":x.AMP,";":x.SEMICOLON,"(":x.LPAREN,")":x.RPAREN,"<":x.LESS,">":x.GREAT};Zs=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];dparenDepth=0;constructor(t){this.input=t}tokenize(){let n=this.input.length,r=this.tokens,s=this.pendingHeredocs;for(;this.pos<n;){if(s.length>0&&r.length>0&&r[r.length-1].type===x.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=n)break;let i=this.nextToken();i&&r.push(i)}return r.push({type:x.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),r}skipWhitespace(){let t=this.input,n=t.length,r=this.pos,s=this.column,i=this.line;for(;r<n;){let o=t[r];if(o===" "||o===" ")r++,s++;else if(o==="\\"&&t[r+1]===`
704
+ `||e===";"||e==="&"||e==="|"||e==="("||e===")"||e==="<"||e===">"}var x,Sn,Gs,sC,iC,oC,Zs,tn=v(()=>{"use strict";(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"})(x||(x={}));Sn=class extends Error{line;column;constructor(t,n,r){super(`line ${n}: ${t}`),this.line=n,this.column=r,this.name="LexerError"}},Gs={if:x.IF,then:x.THEN,else:x.ELSE,elif:x.ELIF,fi:x.FI,for:x.FOR,while:x.WHILE,until:x.UNTIL,do:x.DO,done:x.DONE,case:x.CASE,esac:x.ESAC,in:x.IN,function:x.FUNCTION,select:x.SELECT,time:x.TIME,coproc:x.COPROC};sC=[[";",";","&",x.SEMI_SEMI_AND],["<","<","<",x.TLESS],["&",">",">",x.AND_DGREAT]],iC=[["[","[",x.DBRACK_START],["]","]",x.DBRACK_END],["(","(",x.DPAREN_START],[")",")",x.DPAREN_END],["&","&",x.AND_AND],["|","|",x.OR_OR],[";",";",x.DSEMI],[";","&",x.SEMI_AND],["|","&",x.PIPE_AMP],[">",">",x.DGREAT],["<","&",x.LESSAND],[">","&",x.GREATAND],["<",">",x.LESSGREAT],[">","|",x.CLOBBER],["&",">",x.AND_GREAT]],oC={"|":x.PIPE,"&":x.AMP,";":x.SEMICOLON,"(":x.LPAREN,")":x.RPAREN,"<":x.LESS,">":x.GREAT};Zs=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];dparenDepth=0;constructor(t){this.input=t}tokenize(){let n=this.input.length,r=this.tokens,s=this.pendingHeredocs;for(;this.pos<n;){if(s.length>0&&r.length>0&&r[r.length-1].type===x.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=n)break;let i=this.nextToken();i&&r.push(i)}return r.push({type:x.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),r}skipWhitespace(){let t=this.input,n=t.length,r=this.pos,s=this.column,i=this.line;for(;r<n;){let o=t[r];if(o===" "||o===" ")r++,s++;else if(o==="\\"&&t[r+1]===`
705
705
  `)r+=2,i++,s=1;else break}this.pos=r,this.column=s,this.line=i}nextToken(){let t=this.input,n=this.pos,r=this.line,s=this.column,i=t[n],o=t[n+1],a=t[n+2];if(i==="#"&&this.dparenDepth===0)return this.readComment(n,r,s);if(i===`
706
706
  `)return this.pos=n+1,this.line++,this.column=1,{type:x.NEWLINE,value:`
707
707
  `,start:n,end:n+1,line:r,column:s};if(i==="<"&&o==="<"&&a==="-")return this.pos=n+3,this.column=s+3,this.registerHeredocFromLookahead(!0),this.makeToken(x.DLESSDASH,"<<-",n,r,s);for(let[c,u,f,p]of sC)if(i===c&&o===u&&a===f)return this.pos=n+3,this.column=s+3,this.makeToken(p,c+u+f,n,r,s);if(i==="<"&&o==="<")return this.pos=n+2,this.column=s+2,this.registerHeredocFromLookahead(!1),this.makeToken(x.DLESS,"<<",n,r,s);if(i==="("&&o==="(")return this.dparenDepth>0?(this.pos=n+1,this.column=s+1,this.dparenDepth++,this.makeToken(x.LPAREN,"(",n,r,s)):this.looksLikeNestedSubshells(n+2)||this.dparenClosesWithSpacedParens(n+2)?(this.pos=n+1,this.column=s+1,this.makeToken(x.LPAREN,"(",n,r,s)):(this.pos=n+2,this.column=s+2,this.dparenDepth=1,this.makeToken(x.DPAREN_START,"((",n,r,s));if(i===")"&&o===")")return this.dparenDepth===1?(this.pos=n+2,this.column=s+2,this.dparenDepth=0,this.makeToken(x.DPAREN_END,"))",n,r,s)):this.dparenDepth>1?(this.pos=n+1,this.column=s+1,this.dparenDepth--,this.makeToken(x.RPAREN,")",n,r,s)):(this.pos=n+1,this.column=s+1,this.makeToken(x.RPAREN,")",n,r,s));for(let[c,u,f]of iC)if(!(c==="("&&u==="("||c===")"&&u===")")&&!(this.dparenDepth>0&&c===";"&&(f===x.DSEMI||f===x.SEMI_AND||f===x.SEMI_SEMI_AND))&&i===c&&o===u){if(f===x.DBRACK_START||f===x.DBRACK_END){let p=t[n+2];if(p!==void 0&&p!==" "&&p!==" "&&p!==`
@@ -738,48 +738,48 @@ Gid: ${r} ${r} ${r} ${r}
738
738
  `&&(l=!0),s++;continue}if(c==="'"){o=!0,s++;continue}if(c==='"'){a=!0,s++;continue}if(c==="\\"){s+=2;continue}if(c===`
739
739
  `&&(l=!0),c==="("){i++,s++;continue}if(c===")"){if(i--,i===1){let u=s+1;if(u<r&&n[u]===")")return!1;let f=u,p=!1;for(;f<r&&(n[f]===" "||n[f]===" "||n[f]===`
740
740
  `);)p=!0,f++;if(p&&f<r&&n[f]===")"||l)return!0}if(i===0)return!1;s++;continue}s++}return!1}dparenClosesWithSpacedParens(t){let n=this.input,r=n.length,s=t,i=2,o=!1,a=!1;for(;s<r&&i>0;){let l=n[s];if(o){l==="'"&&(o=!1),s++;continue}if(a){if(l==="\\"){s+=2;continue}l==='"'&&(a=!1),s++;continue}if(l==="'"){o=!0,s++;continue}if(l==='"'){a=!0,s++;continue}if(l==="\\"){s+=2;continue}if(l==="("){i++,s++;continue}if(l===")"){if(i--,i===1){let c=s+1;if(c<r&&n[c]===")")return!1;let u=c,f=!1;for(;u<r&&(n[u]===" "||n[u]===" "||n[u]===`
741
- `);)f=!0,u++;if(f&&u<r&&n[u]===")")return!0}if(i===0)return!1;s++;continue}if(i===1&&(l==="|"&&s+1<r&&n[s+1]==="|"||l==="&"&&s+1<r&&n[s+1]==="&"||l==="|"&&s+1<r&&n[s+1]!=="|"))return!0;s++}return!1}}});var da,ha,um,fm,pm,dm,Ge,An=v(()=>{"use strict";en();da=1e6,ha=1e5,um=1e6,fm=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS,x.AND_GREAT,x.AND_DGREAT]),pm=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS]),dm=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS,x.AND_GREAT,x.AND_DGREAT]),Ge=class extends Error{line;column;token;constructor(t,n,r,s=void 0){super(`Parse error at ${n}:${r}: ${t}`),this.line=n,this.column=r,this.token=s,this.name="ParseException"}}});var j,Cn=v(()=>{"use strict";j={script(e){return{type:"Script",statements:e}},statement(e,t=[],n=!1,r,s){let i={type:"Statement",pipelines:e,operators:t,background:n};return r&&(i.deferredError=r),s!==void 0&&(i.sourceText=s),i},pipeline(e,t=!1,n=!1,r=!1,s){return{type:"Pipeline",commands:e,negated:t,timed:n,timePosix:r,pipeStderr:s}},simpleCommand(e,t=[],n=[],r=[]){return{type:"SimpleCommand",name:e,args:t,assignments:n,redirections:r}},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}},assignment(e,t,n=!1,r=null){return{type:"Assignment",name:e,value:t,append:n,array:r}},redirection(e,t,n=null,r){let s={type:"Redirection",fd:n,operator:e,target:t};return r&&(s.fdVariable=r),s},hereDoc(e,t,n=!1,r=!1){return{type:"HereDoc",delimiter:e,content:t,stripTabs:n,quoted:r}},ifNode(e,t=null,n=[]){return{type:"If",clauses:e,elseBody:t,redirections:n}},forNode(e,t,n,r=[]){return{type:"For",variable:e,words:t,body:n,redirections:r}},whileNode(e,t,n=[]){return{type:"While",condition:e,body:t,redirections:n}},untilNode(e,t,n=[]){return{type:"Until",condition:e,body:t,redirections:n}},caseNode(e,t,n=[]){return{type:"Case",word:e,items:t,redirections:n}},caseItem(e,t,n=";;"){return{type:"CaseItem",patterns:e,body:t,terminator:n}},subshell(e,t=[]){return{type:"Subshell",body:e,redirections:t}},group(e,t=[]){return{type:"Group",body:e,redirections:t}},functionDef(e,t,n=[],r){return{type:"FunctionDef",name:e,body:t,redirections:n,sourceFile:r}},conditionalCommand(e,t=[],n){return{type:"ConditionalCommand",expression:e,redirections:t,line:n}},arithmeticCommand(e,t=[],n){return{type:"ArithmeticCommand",expression:e,redirections:t,line:n}}}});function ve(e,t){for(;t<e.length;){if(e[t]==="\\"&&e[t+1]===`
741
+ `);)f=!0,u++;if(f&&u<r&&n[u]===")")return!0}if(i===0)return!1;s++;continue}if(i===1&&(l==="|"&&s+1<r&&n[s+1]==="|"||l==="&"&&s+1<r&&n[s+1]==="&"||l==="|"&&s+1<r&&n[s+1]!=="|"))return!0;s++}return!1}}});var da,ha,um,fm,pm,dm,Ge,An=v(()=>{"use strict";tn();da=1e6,ha=1e5,um=1e6,fm=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS,x.AND_GREAT,x.AND_DGREAT]),pm=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS]),dm=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS,x.AND_GREAT,x.AND_DGREAT]),Ge=class extends Error{line;column;token;constructor(t,n,r,s=void 0){super(`Parse error at ${n}:${r}: ${t}`),this.line=n,this.column=r,this.token=s,this.name="ParseException"}}});var j,Cn=v(()=>{"use strict";j={script(e){return{type:"Script",statements:e}},statement(e,t=[],n=!1,r,s){let i={type:"Statement",pipelines:e,operators:t,background:n};return r&&(i.deferredError=r),s!==void 0&&(i.sourceText=s),i},pipeline(e,t=!1,n=!1,r=!1,s){return{type:"Pipeline",commands:e,negated:t,timed:n,timePosix:r,pipeStderr:s}},simpleCommand(e,t=[],n=[],r=[]){return{type:"SimpleCommand",name:e,args:t,assignments:n,redirections:r}},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}},assignment(e,t,n=!1,r=null){return{type:"Assignment",name:e,value:t,append:n,array:r}},redirection(e,t,n=null,r){let s={type:"Redirection",fd:n,operator:e,target:t};return r&&(s.fdVariable=r),s},hereDoc(e,t,n=!1,r=!1){return{type:"HereDoc",delimiter:e,content:t,stripTabs:n,quoted:r}},ifNode(e,t=null,n=[]){return{type:"If",clauses:e,elseBody:t,redirections:n}},forNode(e,t,n,r=[]){return{type:"For",variable:e,words:t,body:n,redirections:r}},whileNode(e,t,n=[]){return{type:"While",condition:e,body:t,redirections:n}},untilNode(e,t,n=[]){return{type:"Until",condition:e,body:t,redirections:n}},caseNode(e,t,n=[]){return{type:"Case",word:e,items:t,redirections:n}},caseItem(e,t,n=";;"){return{type:"CaseItem",patterns:e,body:t,terminator:n}},subshell(e,t=[]){return{type:"Subshell",body:e,redirections:t}},group(e,t=[]){return{type:"Group",body:e,redirections:t}},functionDef(e,t,n=[],r){return{type:"FunctionDef",name:e,body:t,redirections:n,sourceFile:r}},conditionalCommand(e,t=[],n){return{type:"ConditionalCommand",expression:e,redirections:t,line:n}},arithmeticCommand(e,t=[],n){return{type:"ArithmeticCommand",expression:e,redirections:t,line:n}}}});function ve(e,t){for(;t<e.length;){if(e[t]==="\\"&&e[t+1]===`
742
742
  `){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}function Fr(e){if(e.includes("#")){let[t,n]=e.split("#"),r=Number.parseInt(t,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let i of n){let o;if(/[0-9]/.test(i))o=i.charCodeAt(0)-48;else if(/[a-z]/.test(i))o=i.charCodeAt(0)-97+10;else if(/[A-Z]/.test(i))o=i.charCodeAt(0)-65+36;else if(i==="@")o=62;else if(i==="_")o=63;else return Number.NaN;if(o>=r)return Number.NaN;s=s*r+o}return s}return e.startsWith("0x")||e.startsWith("0X")?Number.parseInt(e.slice(2),16):e.startsWith("0")&&e.length>1&&/^[0-9]+$/.test(e)?/[89]/.test(e)?Number.NaN:Number.parseInt(e,8):Number.parseInt(e,10)}function hm(e,t,n,r){if(n.slice(r,r+3)!=="$((")return null;let s=r+3,i=1,o=s;for(;s<n.length-1&&i>0;)n[s]==="("&&n[s+1]==="("?(i++,s+=2):n[s]===")"&&n[s+1]===")"?(i--,i>0&&(s+=2)):s++;let a=n.slice(o,s),{expr:l}=e(t,a,0);return s+=2,{expr:{type:"ArithNested",expression:l},pos:s}}function mm(e,t){if(e.slice(t,t+2)!=="$'")return null;let n=t+2,r="";for(;n<e.length&&e[n]!=="'";)if(e[n]==="\\"&&n+1<e.length){let i=e[n+1];switch(i){case"n":r+=`
743
743
  `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case"'":r+="'";break;default:r+=i}n+=2}else r+=e[n],n++;e[n]==="'"&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}function gm(e,t){if(e.slice(t,t+2)!=='$"')return null;let n=t+2,r="";for(;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]==='"'&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}var Qs,ym=v(()=>{"use strict";Qs=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function lC(e){let t="",n=0;for(;n<e.length;)if(e[n]==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function he(e,t){let n=lC(t),{expr:r,pos:s}=Et(e,n,0),i=ve(n,s);if(i<n.length){let o=t.slice(i).trim();if(o)return{type:"ArithmeticExpression",originalText:t,expression:{type:"ArithSyntaxError",errorToken:o,message:`${o}: syntax error: invalid arithmetic operator (error token is "${o}")`}}}return{type:"ArithmeticExpression",expression:r,originalText:t}}function pt(e,t){return{expr:{type:"ArithSyntaxError",errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function dt(e,t){return ve(e,t)>=e.length}function Et(e,t,n){return cC(e,t,n)}function cC(e,t,n){let{expr:r,pos:s}=_r(e,t,n);for(s=ve(t,s);t[s]===",";){if(s++,dt(t,s))return pt(",",s);let{expr:o,pos:a}=_r(e,t,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=ve(t,a)}return{expr:r,pos:s}}function _r(e,t,n){let{expr:r,pos:s}=uC(e,t,n);if(s=ve(t,s),t[s]==="?"){s++;let{expr:i,pos:o}=Et(e,t,s);if(s=ve(t,o),t[s]===":"){s++;let{expr:a,pos:l}=Et(e,t,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:a},pos:l}}}return{expr:r,pos:s}}function uC(e,t,n){let{expr:r,pos:s}=bm(e,t,n);for(;s=ve(t,s),t.slice(s,s+2)==="||";){if(s+=2,dt(t,s))return pt("||",s);let{expr:o,pos:a}=bm(e,t,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=a}return{expr:r,pos:s}}function bm(e,t,n){let{expr:r,pos:s}=wm(e,t,n);for(;s=ve(t,s),t.slice(s,s+2)==="&&";){if(s+=2,dt(t,s))return pt("&&",s);let{expr:o,pos:a}=wm(e,t,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=a}return{expr:r,pos:s}}function wm(e,t,n){let{expr:r,pos:s}=xm(e,t,n);for(;s=ve(t,s),t[s]==="|"&&t[s+1]!=="|";){if(s++,dt(t,s))return pt("|",s);let{expr:o,pos:a}=xm(e,t,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=a}return{expr:r,pos:s}}function xm(e,t,n){let{expr:r,pos:s}=Em(e,t,n);for(;s=ve(t,s),t[s]==="^";){if(s++,dt(t,s))return pt("^",s);let{expr:o,pos:a}=Em(e,t,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=a}return{expr:r,pos:s}}function Em(e,t,n){let{expr:r,pos:s}=Sm(e,t,n);for(;s=ve(t,s),t[s]==="&"&&t[s+1]!=="&";){if(s++,dt(t,s))return pt("&",s);let{expr:o,pos:a}=Sm(e,t,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=a}return{expr:r,pos:s}}function Sm(e,t,n){let{expr:r,pos:s}=Am(e,t,n);for(;s=ve(t,s),t.slice(s,s+2)==="=="||t.slice(s,s+2)==="!=";){let i=t.slice(s,s+2);if(s+=2,dt(t,s))return pt(i,s);let{expr:o,pos:a}=Am(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Am(e,t,n){let{expr:r,pos:s}=ma(e,t,n);for(;;)if(s=ve(t,s),t.slice(s,s+2)==="<="||t.slice(s,s+2)===">="){let i=t.slice(s,s+2);if(s+=2,dt(t,s))return pt(i,s);let{expr:o,pos:a}=ma(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else if(t[s]==="<"||t[s]===">"){let i=t[s];if(s++,dt(t,s))return pt(i,s);let{expr:o,pos:a}=ma(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function ma(e,t,n){let{expr:r,pos:s}=Cm(e,t,n);for(;s=ve(t,s),t.slice(s,s+2)==="<<"||t.slice(s,s+2)===">>";){let i=t.slice(s,s+2);if(s+=2,dt(t,s))return pt(i,s);let{expr:o,pos:a}=Cm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Cm(e,t,n){let{expr:r,pos:s}=Nm(e,t,n);for(;s=ve(t,s),(t[s]==="+"||t[s]==="-")&&t[s+1]!==t[s];){let i=t[s];if(s++,dt(t,s))return pt(i,s);let{expr:o,pos:a}=Nm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Nm(e,t,n){let{expr:r,pos:s}=Ks(e,t,n);for(;;)if(s=ve(t,s),t[s]==="*"&&t[s+1]!=="*"){if(s++,dt(t,s))return pt("*",s);let{expr:o,pos:a}=Ks(e,t,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=a}else if(t[s]==="/"||t[s]==="%"){let i=t[s];if(s++,dt(t,s))return pt(i,s);let{expr:o,pos:a}=Ks(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function Ks(e,t,n){let{expr:r,pos:s}=ga(e,t,n),i=ve(t,s);if(t.slice(i,i+2)==="**"){if(i+=2,dt(t,i))return pt("**",i);let{expr:a,pos:l}=Ks(e,t,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:a},pos:l}}return{expr:r,pos:s}}function ga(e,t,n){let r=ve(t,n);if(t.slice(r,r+2)==="++"||t.slice(r,r+2)==="--"){let s=t.slice(r,r+2);r+=2;let{expr:i,pos:o}=ga(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(t[r]==="+"||t[r]==="-"||t[r]==="!"||t[r]==="~"){let s=t[r];r++;let{expr:i,pos:o}=ga(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return pC(e,t,r)}function fC(e,t){let n=e[t];return n==="$"||n==="`"}function pC(e,t,n){let{expr:r,pos:s}=km(e,t,n,!1),i=[r];for(;fC(t,s);){let{expr:a,pos:l}=km(e,t,s,!0);i.push(a),s=l}i.length>1&&(r={type:"ArithConcat",parts:i});let o;if(t[s]==="["&&r.type==="ArithConcat"){s++;let{expr:a,pos:l}=Et(e,t,s);o=a,s=l,t[s]==="]"&&s++}if(o&&r.type==="ArithConcat"&&(r={type:"ArithDynamicElement",nameExpr:r,subscript:o},o=void 0),s=ve(t,s),r.type==="ArithConcat"||r.type==="ArithVariable"||r.type==="ArithDynamicElement"){for(let a of Qs)if(t.slice(s,s+a.length)===a&&t.slice(s,s+a.length+1)!=="=="){s+=a.length;let{expr:l,pos:c}=_r(e,t,s);return r.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r.nameExpr,subscript:r.subscript,value:l},pos:c}:r.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r,value:l},pos:c}:{expr:{type:"ArithAssignment",operator:a,variable:r.name,value:l},pos:c}}}if(t.slice(s,s+2)==="++"||t.slice(s,s+2)==="--"){let a=t.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:a,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function km(e,t,n,r=!1){let s=ve(t,n),i=hm(Et,e,t,s);if(i)return i;let o=mm(t,s);if(o)return o;let a=gm(t,s);if(a)return a;if(t.slice(s,s+2)==="$("&&t[s+2]!=="("){s+=2;let c=1,u=s;for(;s<t.length&&c>0;)t[s]==="("?c++:t[s]===")"&&c--,c>0&&s++;let f=t.slice(u,s);return s++,{expr:{type:"ArithCommandSubst",command:f},pos:s}}if(t[s]==="`"){s++;let c=s;for(;s<t.length&&t[s]!=="`";)s++;let u=t.slice(c,s);return t[s]==="`"&&s++,{expr:{type:"ArithCommandSubst",command:u},pos:s}}if(t[s]==="("){s++;let{expr:c,pos:u}=Et(e,t,s);return s=ve(t,u),t[s]===")"&&s++,{expr:{type:"ArithGroup",expression:c},pos:s}}if(t[s]==="'"){s++;let c="";for(;s<t.length&&t[s]!=="'";)c+=t[s],s++;t[s]==="'"&&s++;let u=Number.parseInt(c,10);return{expr:{type:"ArithSingleQuote",content:c,value:Number.isNaN(u)?0:u},pos:s}}if(t[s]==='"'){s++;let c="";for(;s<t.length&&t[s]!=='"';)t[s]==="\\"&&s+1<t.length?(c+=t[s+1],s+=2):(c+=t[s],s++);t[s]==='"'&&s++;let u=c.trim();if(!u)return{expr:{type:"ArithNumber",value:0},pos:s};let{expr:f}=Et(e,u,0);return{expr:f,pos:s}}if(/[0-9]/.test(t[s])){let c="",u=!1,f=!1;for(;s<t.length;){let d=t[s];if(u)if(/[0-9a-zA-Z@_]/.test(d))c+=d,s++;else break;else if(d==="#")u=!0,c+=d,s++;else if(c==="0"&&(d==="x"||d==="X")&&s+1<t.length&&/[0-9a-fA-F]/.test(t[s+1]))f=!0,c+=d,s++;else if(f&&/[0-9a-fA-F]/.test(d))c+=d,s++;else if(!f&&/[0-9]/.test(d))c+=d,s++;else break}if(s<t.length&&/[a-zA-Z_]/.test(t[s])){let d=c;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)d+=t[s],s++;return{expr:{type:"ArithSyntaxError",errorToken:d,message:`${d}: value too great for base (error token is "${d}")`},pos:s}}if(t[s]==="."&&/[0-9]/.test(t[s+1]))throw new Ee(`${c}.${t[s+1]}...: syntax error: invalid arithmetic operator`);if(t[s]==="["){let d=t.slice(s).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:d},pos:t.length}}return{expr:{type:"ArithNumber",value:Fr(c)},pos:s}}if(t[s]==="$"&&t[s+1]==="{"){let c=s+2,u=1,f=c;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;let p=t.slice(c,f),d=f+1;if(t[d]==="#"){let m=d+1;for(;m<t.length&&/[0-9a-zA-Z@_]/.test(t[m]);)m++;let h=t.slice(d+1,m);return{expr:{type:"ArithDynamicBase",baseExpr:p,value:h},pos:m}}if(/[0-9]/.test(t[d])||t[d]==="x"||t[d]==="X"){let m=d;if(t[d]==="x"||t[d]==="X")for(m++;m<t.length&&/[0-9a-fA-F]/.test(t[m]);)m++;else for(;m<t.length&&/[0-9]/.test(t[m]);)m++;let h=t.slice(d,m);return{expr:{type:"ArithDynamicNumber",prefix:p,suffix:h},pos:m}}return s=d,{expr:{type:"ArithBracedExpansion",content:p},pos:s}}if(t[s]==="$"&&s+1<t.length&&/[0-9]/.test(t[s+1])){s++;let c="";for(;s<t.length&&/[0-9]/.test(t[s]);)c+=t[s],s++;return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:!0},pos:s}}if(t[s]==="$"&&s+1<t.length&&/[*@#?\-!$]/.test(t[s+1])){let c=t[s+1];return s+=2,{expr:{type:"ArithSpecialVar",name:c},pos:s}}let l=!1;if(t[s]==="$"&&s+1<t.length&&/[a-zA-Z_]/.test(t[s+1])&&(l=!0,s++),s<t.length&&/[a-zA-Z_]/.test(t[s])){let c="";for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)c+=t[s],s++;if(t[s]==="["&&!r){s++;let u;if(t[s]==="'"||t[s]==='"'){let p=t[s];for(s++,u="";s<t.length&&t[s]!==p;)u+=t[s],s++;t[s]===p&&s++,s=ve(t,s),t[s]==="]"&&s++}let f;if(u===void 0){let{expr:p,pos:d}=Et(e,t,s);f=p,s=d,t[s]==="]"&&s++}if(s=ve(t,s),t[s]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:s};if(!r){for(let p of Qs)if(t.slice(s,s+p.length)===p&&t.slice(s,s+p.length+1)!=="=="){s+=p.length;let{expr:d,pos:m}=_r(e,t,s);return{expr:{type:"ArithAssignment",operator:p,variable:c,subscript:f,stringKey:u,value:d},pos:m}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:s}}if(s=ve(t,s),!r){for(let u of Qs)if(t.slice(s,s+u.length)===u&&t.slice(s,s+u.length+1)!=="=="){s+=u.length;let{expr:f,pos:p}=_r(e,t,s);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:p}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:l},pos:s}}if(t[s]==="#"){let c=s+1;for(;c<t.length&&t[c]!==`
744
744
  `;)c++;let u=t.slice(s,c).trim()||"#";return{expr:{type:"ArithSyntaxError",errorToken:u,message:`${u}: syntax error: invalid arithmetic operator (error token is "${u}")`},pos:t.length}}return{expr:{type:"ArithNumber",value:0},pos:s}}var Je=v(()=>{"use strict";de();ym()});function dC(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<e.length&&(e[n+1]&192)===128&&r>=194){let s=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(s),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let s=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(s>=55296&&s<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(s),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128&&(e[n+3]&192)===128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let s=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(s>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(s),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function Im(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function ya(e,t,n,r,s){let i=1,o=n+1;for(;o<t.length&&i>0;)t[o]===r?i++:t[o]===s&&i--,i>0&&o++;return i===0?o:-1}function Nn(e,t,n){let r=n,s=1;for(;r<t.length&&s>0;){let i=t[r];if(i==="\\"&&r+1<t.length){r+=2;continue}if(i==="'"){let o=t.indexOf("'",r+1);if(o!==-1){r=o+1;continue}}if(i==='"'){for(r++;r<t.length&&t[r]!=='"';)t[r]==="\\"&&r+1<t.length?r+=2:r++;r<t.length&&r++;continue}i==="{"?s++:i==="}"&&s--,s>0&&r++}return r}function Rm(e,t,n){let r=n,s=!1;for(;r<t.length;){let i=t[r];if(i==="/"&&s||i==="}")break;if(i==="'"){let o=t.indexOf("'",r+1);if(o!==-1){r=o+1,s=!0;continue}}if(i==='"'){for(r++;r<t.length&&t[r]!=='"';)t[r]==="\\"&&r+1<t.length?r+=2:r++;r<t.length&&r++,s=!0;continue}i==="\\"?(r+=2,s=!0):(r++,s=!0)}return r}function Pm(e,t,n){let r=n,s="";for(;r<t.length;){let i=t[r];if(i==="*"||i==="?")s+=i,r++;else if(i==="["){let o=hC(t,r);o===-1?(s+=i,r++):(s+=t.slice(r,o+1),r=o+1)}else break}return{pattern:s,endIndex:r}}function hC(e,t){let n=t+1;for(n<e.length&&e[n]==="^"&&n++,n<e.length&&e[n]==="]"&&n++;n<e.length;){let r=e[n];if(r==="\\"&&n+1<e.length){let s=e[n+1];if(s==='"'||s==="'")return-1;n+=2;continue}if(r==="]")return n;if(r==='"'||r==="$"||r==="`")return-1;if(r==="'"){let s=e.indexOf("'",n+1);if(s!==-1){n=s+1;continue}}if(r==="["&&n+1<e.length&&e[n+1]===":"){let s=e.indexOf(":]",n+2);if(s!==-1){n=s+2;continue}}if(r==="["&&n+1<e.length&&(e[n+1]==="."||e[n+1]==="=")){let i=`${e[n+1]}]`,o=e.indexOf(i,n+2);if(o!==-1){n=o+2;continue}}n++}return-1}function Tm(e,t,n){let r="",s=n;for(;s<t.length&&t[s]!=="'";){let i=t[s];if(i==="\\"&&s+1<t.length)switch(t[s+1]){case"n":r+=`
745
- `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=[],l=s;for(;l+1<t.length&&t[l]==="\\"&&t[l+1]==="x";){let c=t.slice(l+2,l+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)a.push(u),l+=2+c.length;else break}a.length>0?(r+=dC(a),s=l):(r+="\\x",s+=2);break}case"u":{let a=t.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"c":{if(s+2<t.length){let l=t[s+2].charCodeAt(0)&31;r+=String.fromCharCode(l),s+=3}else r+="\\c",s+=2;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<t.length&&l<s+4&&/[0-7]/.test(t[l]);)a+=t[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<t.length&&t[s]==="'"&&s++,{part:j.literal(r),endIndex:s}}function ba(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:he(e,n)}function $m(e){let t=[],n="",r=0;for(let s=0;s<e.length;s++){let i=e[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(t.push(n),n=""):n+=i}return t.push(n),t}function Om(e,t,n,r){let s=ya(e,t,n,"{","}");if(s===-1)return null;let i=t.slice(n+1,s),o=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:$m(i).map(u=>({type:"Word",word:j.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:$m(i).map(u=>({type:"Word",word:j.word([j.literal(u)])}))},endIndex:s+1}:null}function wa(e,t){let n="";for(let r of t.parts)switch(r.type){case"Literal":n+=r.value;break;case"SingleQuoted":n+=`'${r.value}'`;break;case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;case"TildeExpansion":n+="~",r.user&&(n+=r.user);break;case"BraceExpansion":{n+="{";let s=[];for(let i of r.items)if(i.type==="Range"){let o=i.startStr??String(i.start),a=i.endStr??String(i.end);i.step!==void 0?s.push(`${o}..${a}..${i.step}`):s.push(`${o}..${a}`)}else s.push(wa(e,i.word));s.length===1&&r.items[0].type==="Range"?n+=s[0]:n+=s.join(","),n+="}";break}default:n+=r.type}return n}function Dm(e,t){return{[x.LESS]:"<",[x.GREAT]:">",[x.DGREAT]:">>",[x.LESSAND]:"<&",[x.GREATAND]:">&",[x.LESSGREAT]:"<>",[x.CLOBBER]:">|",[x.TLESS]:"<<<",[x.AND_GREAT]:"&>",[x.AND_DGREAT]:"&>>",[x.DLESS]:"<",[x.DLESSDASH]:"<"}[t]||">"}var xa=v(()=>{"use strict";Cn();Je();en()});function Xs(e){let t=e.current(),n=t.type;if(n===x.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:pm.has(r.type)}if(n===x.FD_VARIABLE){let r=e.peek(1);return dm.has(r.type)}return fm.has(n)}function Js(e){let t=null,n;e.check(x.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(x.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),s=Dm(e,r.type);if(r.type===x.DLESS||r.type===x.DLESSDASH)return mC(e,s,t,r.type===x.DLESSDASH);e.isWord()||e.error("Expected redirection target");let i=e.parseWord();return j.redirection(s,i,t,n)}function mC(e,t,n,r){e.isWord()||e.error("Expected here-document delimiter");let s=e.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=j.redirection(r?"<<-":"<<",j.hereDoc(i,j.word([]),r,o),n);return e.addPendingHeredoc(a,i,r,o),a}function _m(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(x.ASSIGNMENT_WORD)||Xs(e);)e.checkIterationLimit(),e.check(x.ASSIGNMENT_WORD)?n.push(gC(e)):i.push(Js(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(x.DBRACK_START)||e.check(x.DPAREN_START))){let a=e.advance();r=j.word([j.literal(a.value)])}for(;(!e.isStatementEnd()||e.check(x.RBRACE))&&!e.check(x.PIPE,x.PIPE_AMP);)if(e.checkIterationLimit(),Xs(e))i.push(Js(e));else if(e.check(x.RBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(x.LBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(x.DBRACK_END)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.isWord())s.push(e.parseWord());else if(e.check(x.ASSIGNMENT_WORD)){let a=e.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||e.check(x.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||e.expect(x.LPAREN);let p=Ea(e);e.expect(x.RPAREN);let d=p.map(h=>wa(e,h)),m=`${f}=(${d.join(" ")})`;s.push(e.parseWordFromString(m,!1,!1))}else s.push(e.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(e.check(x.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=j.simpleCommand(r,s,n,i);return o.line=t,o}function gC(e){let t=e.expect(x.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,p=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${n}`),i=n.slice(p,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&e.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=Ea(e);e.expect(x.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return j.assignment(p,null,a,f)}if(l===""&&e.check(x.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let p=Ea(e);e.expect(x.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return j.assignment(d,null,a,p)}}let c=l?e.parseWordFromString(l,t.quoted,t.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return j.assignment(u,c,a,null)}function Ea(e){let t=[];for(e.skipNewlines();!e.check(x.RPAREN,x.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):yC.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var yC,Lm=v(()=>{"use strict";Cn();en();An();xa();yC=new Set([x.AMP,x.PIPE,x.PIPE_AMP,x.SEMICOLON,x.AND_AND,x.OR_OR,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND])});function Sa(e,t){e.expect(x.IF);let n=[],r=e.parseCompoundList();e.expect(x.THEN);let s=e.parseCompoundList();if(s.length===0){let a=e.check(x.FI)?"fi":e.check(x.ELSE)?"else":e.check(x.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${a}'`)}for(n.push({condition:r,body:s});e.check(x.ELIF);){e.advance();let a=e.parseCompoundList();e.expect(x.THEN);let l=e.parseCompoundList();if(l.length===0){let c=e.check(x.FI)?"fi":e.check(x.ELSE)?"else":e.check(x.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${c}'`)}n.push({condition:a,body:l})}let i=null;e.check(x.ELSE)&&(e.advance(),i=e.parseCompoundList(),i.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(x.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.ifNode(n,i,o)}function Aa(e,t){let n=e.expect(x.FOR);if(e.check(x.DPAREN_START))return wC(e,t,n.line);e.isWord()||e.error("Expected variable name in for loop");let s=e.advance().value,i=null;if(e.skipNewlines(),e.check(x.IN))for(e.advance(),i=[];!e.check(x.SEMICOLON,x.NEWLINE,x.DO,x.EOF)&&e.isWord();)i.push(e.parseWord());e.check(x.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(x.DO);let o=e.parseCompoundList();e.expect(x.DONE);let a=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.forNode(s,i,o,a)}function wC(e,t,n){e.expect(x.DPAREN_START);let r=null,s=null,i=null,o=["","",""],a=0,l=0;for(;!e.check(x.DPAREN_END,x.EOF);){let f=e.advance();if(f.type===x.SEMICOLON&&l===0){if(a++,a>2)break}else f.value==="("&&l++,f.value===")"&&l--,o[a]+=f.value}e.expect(x.DPAREN_END),o[0].trim()&&(r=he(e,o[0].trim())),o[1].trim()&&(s=he(e,o[1].trim())),o[2].trim()&&(i=he(e,o[2].trim())),e.skipNewlines(),e.check(x.SEMICOLON)&&e.advance(),e.skipNewlines();let c;e.check(x.LBRACE)?(e.advance(),c=e.parseCompoundList(),e.expect(x.RBRACE)):(e.expect(x.DO),c=e.parseCompoundList(),e.expect(x.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:"CStyleFor",init:r,condition:s,update:i,body:c,redirections:u,line:n}}function Ca(e,t){e.expect(x.WHILE);let n=e.parseCompoundList();e.expect(x.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(x.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.whileNode(n,r,s)}function Na(e,t){e.expect(x.UNTIL);let n=e.parseCompoundList();e.expect(x.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(x.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.untilNode(n,r,s)}function ka(e,t){e.expect(x.CASE),e.isWord()||e.error("Expected word after 'case'");let n=e.parseWord();e.skipNewlines(),e.expect(x.IN),e.skipNewlines();let r=[];for(;!e.check(x.ESAC,x.EOF);){e.checkIterationLimit();let i=e.getPos(),o=xC(e);if(o&&r.push(o),e.skipNewlines(),e.getPos()===i&&!o)break}e.expect(x.ESAC);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.caseNode(n,r,s)}function xC(e){e.check(x.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(x.PIPE));)e.advance();if(t.length===0)return null;e.expect(x.RPAREN),e.skipNewlines();let n=[];for(;!e.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND,x.ESAC,x.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===x.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(x.LPAREN)&&e.peek(1).type===x.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let s=e.getPos(),i=e.parseStatement();if(i&&n.push(i),e.skipSeparators(!1),e.getPos()===s&&!i)break}let r=";;";return e.check(x.DSEMI)?(e.advance(),r=";;"):e.check(x.SEMI_AND)?(e.advance(),r=";&"):e.check(x.SEMI_SEMI_AND)&&(e.advance(),r=";;&"),j.caseItem(t,n,r)}function va(e,t){e.expect(x.LPAREN);let n=e.parseCompoundList();e.expect(x.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.subshell(n,r)}function $a(e,t){e.expect(x.LBRACE);let n=e.parseCompoundList();e.expect(x.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.group(n,r)}var Mm=v(()=>{"use strict";Cn();Je();en()});function Wm(e){return e.isWord()||e.check(x.LBRACE)||e.check(x.RBRACE)||e.check(x.ASSIGNMENT_WORD)}function Bm(e){if(e.check(x.BANG)&&e.peek(1).type===x.LPAREN){e.advance(),e.advance();let t=1,n="!(";for(;t>0&&!e.check(x.EOF);)if(e.check(x.LPAREN))t++,n+="(",e.advance();else if(e.check(x.RPAREN))t--,t>0&&(n+=")"),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(x.PIPE))n+="|",e.advance();else break;return n+=")",e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function Ra(e){return e.skipNewlines(),CC(e)}function CC(e){let t=Um(e);for(e.skipNewlines();e.check(x.OR_OR);){e.advance(),e.skipNewlines();let n=Um(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function Um(e){let t=Ia(e);for(e.skipNewlines();e.check(x.AND_AND);){e.advance(),e.skipNewlines();let n=Ia(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function Ia(e){return e.skipNewlines(),e.check(x.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:Ia(e)}):NC(e)}function NC(e){if(e.check(x.LPAREN)){e.advance();let t=Ra(e);return e.expect(x.RPAREN),{type:"CondGroup",expression:t}}if(Wm(e)){let t=e.current(),n=t.value;if(SC.includes(n)&&!t.quoted){if(e.advance(),e.check(x.DBRACK_END)&&e.error(`Expected operand after ${n}`),Wm(e)){let i=e.parseWordNoBraceExpansion();return{type:"CondUnary",operator:n,operand:i}}let s=e.current();e.error(`unexpected argument \`${s.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&AC.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=kC(e):s==="=="||s==="!="?i=Bm(e):i=e.parseWordNoBraceExpansion(),{type:"CondBinary",operator:s,left:r,right:i}}if(e.check(x.LESS)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:"<",left:r,right:s}}if(e.check(x.GREAT)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:">",left:r,right:s}}if(e.isWord()&&e.current().value==="="){e.advance();let s=Bm(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function kC(e){let t=[],n=0,r=-1,s=e.getInput(),i=()=>e.check(x.DBRACK_END)||e.check(x.AND_AND)||e.check(x.OR_OR)||e.check(x.NEWLINE)||e.check(x.EOF);for(;!i();){let o=e.current(),a=r>=0&&o.start>r;if(n===0&&a)break;if(n>0&&a){let l=s.slice(r,o.start);t.push({type:"Literal",value:l})}if(e.isWord()||e.check(x.ASSIGNMENT_WORD)){let l=e.parseWordForRegex();t.push(...l.parts),r=e.peek(-1).end}else if(e.check(x.LPAREN)){let l=e.advance();t.push({type:"Literal",value:"("}),n++,r=l.end}else if(e.check(x.DPAREN_START)){let l=e.advance();t.push({type:"Literal",value:"(("}),n+=2,r=l.end}else if(e.check(x.DPAREN_END))if(n>=2){let l=e.advance();t.push({type:"Literal",value:"))"}),n-=2,r=l.end}else{if(n===1)break;break}else if(e.check(x.RPAREN))if(n>0){let l=e.advance();t.push({type:"Literal",value:")"}),n--,r=l.end}else break;else if(e.check(x.PIPE)){let l=e.advance();t.push({type:"Literal",value:"|"}),r=l.end}else if(e.check(x.SEMICOLON))if(n>0){let l=e.advance();t.push({type:"Literal",value:";"}),r=l.end}else break;else if(n>0&&e.check(x.LESS)){let l=e.advance();t.push({type:"Literal",value:"<"}),r=l.end}else if(n>0&&e.check(x.GREAT)){let l=e.advance();t.push({type:"Literal",value:">"}),r=l.end}else if(n>0&&e.check(x.DGREAT)){let l=e.advance();t.push({type:"Literal",value:">>"}),r=l.end}else if(n>0&&e.check(x.DLESS)){let l=e.advance();t.push({type:"Literal",value:"<<"}),r=l.end}else if(n>0&&e.check(x.LESSAND)){let l=e.advance();t.push({type:"Literal",value:"<&"}),r=l.end}else if(n>0&&e.check(x.GREATAND)){let l=e.advance();t.push({type:"Literal",value:">&"}),r=l.end}else if(n>0&&e.check(x.LESSGREAT)){let l=e.advance();t.push({type:"Literal",value:"<>"}),r=l.end}else if(n>0&&e.check(x.CLOBBER)){let l=e.advance();t.push({type:"Literal",value:">|"}),r=l.end}else if(n>0&&e.check(x.TLESS)){let l=e.advance();t.push({type:"Literal",value:"<<<"}),r=l.end}else if(n>0&&e.check(x.AMP)){let l=e.advance();t.push({type:"Literal",value:"&"}),r=l.end}else if(n>0&&e.check(x.LBRACE)){let l=e.advance();t.push({type:"Literal",value:"{"}),r=l.end}else if(n>0&&e.check(x.RBRACE)){let l=e.advance();t.push({type:"Literal",value:"}"}),r=l.end}else break}return t.length===0&&e.error("Expected regex pattern after =~"),{type:"Word",parts:t}}var SC,AC,zm=v(()=>{"use strict";en();SC=["-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"],AC=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function $C(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if("@*+?!".includes(s)&&r+1<e.length&&e[r+1]==="("){r++,n++,r++;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function IC(e,t,n){let r=n+1,s=t[r];if("@*#?$!-0123456789".includes(s))return{part:j.parameterExpansion(s),endIndex:r+1};let i="";for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)i+=t[r],r++;return{part:j.parameterExpansion(i),endIndex:r}}function RC(e,t,n,r=!1){let s=n+2,i=!1;t[s]==="!"&&(i=!0,s++);let o=!1;t[s]==="#"&&!/[}:#%/^,]/.test(t[s+1]||"}")&&(o=!0,s++);let a="",l=t[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(t[s+1]||""))a=l,s++;else for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)a+=t[s],s++;if(t[s]==="["){let u=ya(e,t,s,"[","]");if(a+=t.slice(s,u+1),s=u+1,t[s]==="["){let f=1,p=s;for(;p<t.length&&f>0;)t[p]==="{"?f++:t[p]==="}"&&f--,f>0&&p++;let d=t.slice(n+2,p);return{part:j.parameterExpansion("",{type:"BadSubstitution",text:d}),endIndex:p+1}}}if(a===""&&!i&&!o&&t[s]!=="}"){let u=1,f=s;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;if(u>0)throw new Ge("unexpected EOF while looking for matching '}'",0,0);let p=t.slice(n+2,f);return{part:j.parameterExpansion("",{type:"BadSubstitution",text:p}),endIndex:f+1}}let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pa(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(t[s]==="*"||t[s]==="@"&&!/[QPaAEKkuUL]/.test(t[s+1]||"")){let f=t[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pa(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(o)if(t[s]===":")for(c={type:"LengthSliceError"};s<t.length&&t[s]!=="}";)s++;else t[s]!=="}"&&/[-+=?]/.test(t[s])?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):t[s]==="/"?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<t.length&&t[s]!=="}"){let u=Pa(e,t,s,a,r);c=u.operation,s=u.endIndex}if(s<t.length&&t[s]!=="}"){let u=t[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<t.length&&t[f]!=="}";)f++;let p=t.slice(n,f+1);e.error(`\${${p.slice(2,-1)}}: bad substitution`)}}for(;s<t.length&&t[s]!=="}";)s++;if(s>=t.length)throw new Ge("unexpected EOF while looking for matching '}'",0,0);return{part:j.parameterExpansion(a,c),endIndex:s+1}}function Pa(e,t,n,r,s=!1){let i=n,o=t[i],a=t[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let b=Nn(e,t,i),y=t.slice(i,b),w=tn(e,y,!1,!1,!0,!1,s,!1,!1,!0),E=j.word(w.length>0?w:[j.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:E,checkEmpty:!0},endIndex:b};if(l==="=")return{operation:{type:"AssignDefault",word:E,checkEmpty:!0},endIndex:b};if(l==="?")return{operation:{type:"ErrorIfUnset",word:E,checkEmpty:!0},endIndex:b};if(l==="+")return{operation:{type:"UseAlternative",word:E,checkEmpty:!0},endIndex:b}}i++;let c=Nn(e,t,i),u=t.slice(i,c),f=-1,p=0,d=0;for(let g=0;g<u.length;g++){let b=u[g];if(b==="("||b==="[")p++;else if(b===")"||b==="]")p--;else if(b==="?"&&p===0)d++;else if(b===":"&&p===0)if(d>0)d--;else{f=g;break}}let m=f>=0?u.slice(0,f):u,h=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:ba(e,m),length:h!==null?ba(e,h):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=Nn(e,t,i),c=t.slice(i,l),u=tn(e,c,!1,!1,!0,!1,s,!1,!1,!0),f=j.word(u.length>0?u:[j.literal("")]);if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=Nn(e,t,i),f=t.slice(i,u),p=tn(e,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:j.word(p.length>0?p:[j.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;t[i]==="#"?(c="start",i++):t[i]==="%"&&(c="end",i++);let u;c!==null&&(t[i]==="/"||t[i]==="}")?u=i:u=Rm(e,t,i);let f=t.slice(i,u),p=tn(e,f,!1,!1,!1),d=j.word(p.length>0?p:[j.literal("")]),m=null,h=u;if(t[u]==="/"){let g=u+1,b=Nn(e,t,g),y=t.slice(g,b),w=tn(e,y,!1,!1,!1);m=j.word(w.length>0?w:[j.literal("")]),h=b}return{operation:{type:"PatternReplacement",pattern:d,replacement:m,all:l,anchor:c},endIndex:h}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=Nn(e,t,i),f=t.slice(i,u),p=f?j.word([j.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:p},endIndex:u}}return o==="@"&&/[QPaAEKkuUL]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function Ta(e,t,n,r=!1){let s=n+1;if(s>=t.length)return{part:j.literal("$"),endIndex:s};let i=t[s];if(i==="("&&t[s+1]==="(")return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(i==="["){let o=1,a=s+1;for(;a<t.length&&o>0;)t[a]==="["?o++:t[a]==="]"&&o--,o>0&&a++;if(o===0){let l=t.slice(s+1,a),c=he(e,l);return{part:j.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?e.parseCommandSubstitution(t,n):i==="{"?RC(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?IC(e,t,n):{part:j.literal("$"),endIndex:s}}function jm(e,t){let n=[],r=0,s="",i=()=>{s&&(n.push(j.literal(s)),s="")};for(;r<t.length;){let o=t[r];if(o==="\\"&&r+1<t.length){let a=t[r+1];if(a==="$"||a==="`"||a==='"'||a==="\\"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=Ta(e,t,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=e.parseBacktickSubstitution(t,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function PC(e,t,n){let r=[],s=n,i="",o=()=>{i&&(r.push(j.literal(i)),i="")};for(;s<t.length&&t[s]!=='"';){let a=t[s];if(a==="\\"&&s+1<t.length){let l=t[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=Ta(e,t,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:j.doubleQuoted(r),endIndex:s}}function tn(e,t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1){if(r)return[j.singleQuoted(t)];if(n){let m=jm(e,t);return[j.doubleQuoted(m)]}if(t.length>=2&&t[0]==='"'&&t[t.length-1]==='"'){let m=t.slice(1,-1),h=!1;for(let g=0;g<m.length;g++){if(m[g]==='"'){h=!0;break}m[g]==="\\"&&g+1<m.length&&g++}if(!h){let g=jm(e,m);return[j.doubleQuoted(g)]}}let u=[],f=0,p="",d=()=>{p&&(u.push(j.literal(p)),p="")};for(;f<t.length;){let m=t[f];if(m==="\\"&&f+1<t.length){let h=t[f+1];if(l){d(),u.push(j.escaped(h)),f+=2;continue}let g=i?h==="$"||h==="`"||h===`
745
+ `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=[],l=s;for(;l+1<t.length&&t[l]==="\\"&&t[l+1]==="x";){let c=t.slice(l+2,l+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)a.push(u),l+=2+c.length;else break}a.length>0?(r+=dC(a),s=l):(r+="\\x",s+=2);break}case"u":{let a=t.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"c":{if(s+2<t.length){let l=t[s+2].charCodeAt(0)&31;r+=String.fromCharCode(l),s+=3}else r+="\\c",s+=2;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<t.length&&l<s+4&&/[0-7]/.test(t[l]);)a+=t[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<t.length&&t[s]==="'"&&s++,{part:j.literal(r),endIndex:s}}function ba(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:he(e,n)}function $m(e){let t=[],n="",r=0;for(let s=0;s<e.length;s++){let i=e[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(t.push(n),n=""):n+=i}return t.push(n),t}function Om(e,t,n,r){let s=ya(e,t,n,"{","}");if(s===-1)return null;let i=t.slice(n+1,s),o=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:$m(i).map(u=>({type:"Word",word:j.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:$m(i).map(u=>({type:"Word",word:j.word([j.literal(u)])}))},endIndex:s+1}:null}function wa(e,t){let n="";for(let r of t.parts)switch(r.type){case"Literal":n+=r.value;break;case"SingleQuoted":n+=`'${r.value}'`;break;case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;case"TildeExpansion":n+="~",r.user&&(n+=r.user);break;case"BraceExpansion":{n+="{";let s=[];for(let i of r.items)if(i.type==="Range"){let o=i.startStr??String(i.start),a=i.endStr??String(i.end);i.step!==void 0?s.push(`${o}..${a}..${i.step}`):s.push(`${o}..${a}`)}else s.push(wa(e,i.word));s.length===1&&r.items[0].type==="Range"?n+=s[0]:n+=s.join(","),n+="}";break}default:n+=r.type}return n}function Dm(e,t){return{[x.LESS]:"<",[x.GREAT]:">",[x.DGREAT]:">>",[x.LESSAND]:"<&",[x.GREATAND]:">&",[x.LESSGREAT]:"<>",[x.CLOBBER]:">|",[x.TLESS]:"<<<",[x.AND_GREAT]:"&>",[x.AND_DGREAT]:"&>>",[x.DLESS]:"<",[x.DLESSDASH]:"<"}[t]||">"}var xa=v(()=>{"use strict";Cn();Je();tn()});function Xs(e){let t=e.current(),n=t.type;if(n===x.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:pm.has(r.type)}if(n===x.FD_VARIABLE){let r=e.peek(1);return dm.has(r.type)}return fm.has(n)}function Js(e){let t=null,n;e.check(x.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(x.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),s=Dm(e,r.type);if(r.type===x.DLESS||r.type===x.DLESSDASH)return mC(e,s,t,r.type===x.DLESSDASH);e.isWord()||e.error("Expected redirection target");let i=e.parseWord();return j.redirection(s,i,t,n)}function mC(e,t,n,r){e.isWord()||e.error("Expected here-document delimiter");let s=e.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=j.redirection(r?"<<-":"<<",j.hereDoc(i,j.word([]),r,o),n);return e.addPendingHeredoc(a,i,r,o),a}function _m(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(x.ASSIGNMENT_WORD)||Xs(e);)e.checkIterationLimit(),e.check(x.ASSIGNMENT_WORD)?n.push(gC(e)):i.push(Js(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(x.DBRACK_START)||e.check(x.DPAREN_START))){let a=e.advance();r=j.word([j.literal(a.value)])}for(;(!e.isStatementEnd()||e.check(x.RBRACE))&&!e.check(x.PIPE,x.PIPE_AMP);)if(e.checkIterationLimit(),Xs(e))i.push(Js(e));else if(e.check(x.RBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(x.LBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(x.DBRACK_END)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.isWord())s.push(e.parseWord());else if(e.check(x.ASSIGNMENT_WORD)){let a=e.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||e.check(x.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||e.expect(x.LPAREN);let p=Ea(e);e.expect(x.RPAREN);let d=p.map(h=>wa(e,h)),m=`${f}=(${d.join(" ")})`;s.push(e.parseWordFromString(m,!1,!1))}else s.push(e.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(e.check(x.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=j.simpleCommand(r,s,n,i);return o.line=t,o}function gC(e){let t=e.expect(x.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,p=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${n}`),i=n.slice(p,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&e.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=Ea(e);e.expect(x.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return j.assignment(p,null,a,f)}if(l===""&&e.check(x.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let p=Ea(e);e.expect(x.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return j.assignment(d,null,a,p)}}let c=l?e.parseWordFromString(l,t.quoted,t.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return j.assignment(u,c,a,null)}function Ea(e){let t=[];for(e.skipNewlines();!e.check(x.RPAREN,x.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):yC.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var yC,Lm=v(()=>{"use strict";Cn();tn();An();xa();yC=new Set([x.AMP,x.PIPE,x.PIPE_AMP,x.SEMICOLON,x.AND_AND,x.OR_OR,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND])});function Sa(e,t){e.expect(x.IF);let n=[],r=e.parseCompoundList();e.expect(x.THEN);let s=e.parseCompoundList();if(s.length===0){let a=e.check(x.FI)?"fi":e.check(x.ELSE)?"else":e.check(x.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${a}'`)}for(n.push({condition:r,body:s});e.check(x.ELIF);){e.advance();let a=e.parseCompoundList();e.expect(x.THEN);let l=e.parseCompoundList();if(l.length===0){let c=e.check(x.FI)?"fi":e.check(x.ELSE)?"else":e.check(x.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${c}'`)}n.push({condition:a,body:l})}let i=null;e.check(x.ELSE)&&(e.advance(),i=e.parseCompoundList(),i.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(x.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.ifNode(n,i,o)}function Aa(e,t){let n=e.expect(x.FOR);if(e.check(x.DPAREN_START))return wC(e,t,n.line);e.isWord()||e.error("Expected variable name in for loop");let s=e.advance().value,i=null;if(e.skipNewlines(),e.check(x.IN))for(e.advance(),i=[];!e.check(x.SEMICOLON,x.NEWLINE,x.DO,x.EOF)&&e.isWord();)i.push(e.parseWord());e.check(x.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(x.DO);let o=e.parseCompoundList();e.expect(x.DONE);let a=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.forNode(s,i,o,a)}function wC(e,t,n){e.expect(x.DPAREN_START);let r=null,s=null,i=null,o=["","",""],a=0,l=0;for(;!e.check(x.DPAREN_END,x.EOF);){let f=e.advance();if(f.type===x.SEMICOLON&&l===0){if(a++,a>2)break}else f.value==="("&&l++,f.value===")"&&l--,o[a]+=f.value}e.expect(x.DPAREN_END),o[0].trim()&&(r=he(e,o[0].trim())),o[1].trim()&&(s=he(e,o[1].trim())),o[2].trim()&&(i=he(e,o[2].trim())),e.skipNewlines(),e.check(x.SEMICOLON)&&e.advance(),e.skipNewlines();let c;e.check(x.LBRACE)?(e.advance(),c=e.parseCompoundList(),e.expect(x.RBRACE)):(e.expect(x.DO),c=e.parseCompoundList(),e.expect(x.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:"CStyleFor",init:r,condition:s,update:i,body:c,redirections:u,line:n}}function Ca(e,t){e.expect(x.WHILE);let n=e.parseCompoundList();e.expect(x.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(x.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.whileNode(n,r,s)}function Na(e,t){e.expect(x.UNTIL);let n=e.parseCompoundList();e.expect(x.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(x.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.untilNode(n,r,s)}function ka(e,t){e.expect(x.CASE),e.isWord()||e.error("Expected word after 'case'");let n=e.parseWord();e.skipNewlines(),e.expect(x.IN),e.skipNewlines();let r=[];for(;!e.check(x.ESAC,x.EOF);){e.checkIterationLimit();let i=e.getPos(),o=xC(e);if(o&&r.push(o),e.skipNewlines(),e.getPos()===i&&!o)break}e.expect(x.ESAC);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.caseNode(n,r,s)}function xC(e){e.check(x.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(x.PIPE));)e.advance();if(t.length===0)return null;e.expect(x.RPAREN),e.skipNewlines();let n=[];for(;!e.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND,x.ESAC,x.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===x.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(x.LPAREN)&&e.peek(1).type===x.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let s=e.getPos(),i=e.parseStatement();if(i&&n.push(i),e.skipSeparators(!1),e.getPos()===s&&!i)break}let r=";;";return e.check(x.DSEMI)?(e.advance(),r=";;"):e.check(x.SEMI_AND)?(e.advance(),r=";&"):e.check(x.SEMI_SEMI_AND)&&(e.advance(),r=";;&"),j.caseItem(t,n,r)}function va(e,t){e.expect(x.LPAREN);let n=e.parseCompoundList();e.expect(x.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.subshell(n,r)}function $a(e,t){e.expect(x.LBRACE);let n=e.parseCompoundList();e.expect(x.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return j.group(n,r)}var Mm=v(()=>{"use strict";Cn();Je();tn()});function Wm(e){return e.isWord()||e.check(x.LBRACE)||e.check(x.RBRACE)||e.check(x.ASSIGNMENT_WORD)}function Bm(e){if(e.check(x.BANG)&&e.peek(1).type===x.LPAREN){e.advance(),e.advance();let t=1,n="!(";for(;t>0&&!e.check(x.EOF);)if(e.check(x.LPAREN))t++,n+="(",e.advance();else if(e.check(x.RPAREN))t--,t>0&&(n+=")"),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(x.PIPE))n+="|",e.advance();else break;return n+=")",e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function Ra(e){return e.skipNewlines(),CC(e)}function CC(e){let t=Um(e);for(e.skipNewlines();e.check(x.OR_OR);){e.advance(),e.skipNewlines();let n=Um(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function Um(e){let t=Ia(e);for(e.skipNewlines();e.check(x.AND_AND);){e.advance(),e.skipNewlines();let n=Ia(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function Ia(e){return e.skipNewlines(),e.check(x.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:Ia(e)}):NC(e)}function NC(e){if(e.check(x.LPAREN)){e.advance();let t=Ra(e);return e.expect(x.RPAREN),{type:"CondGroup",expression:t}}if(Wm(e)){let t=e.current(),n=t.value;if(SC.includes(n)&&!t.quoted){if(e.advance(),e.check(x.DBRACK_END)&&e.error(`Expected operand after ${n}`),Wm(e)){let i=e.parseWordNoBraceExpansion();return{type:"CondUnary",operator:n,operand:i}}let s=e.current();e.error(`unexpected argument \`${s.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&AC.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=kC(e):s==="=="||s==="!="?i=Bm(e):i=e.parseWordNoBraceExpansion(),{type:"CondBinary",operator:s,left:r,right:i}}if(e.check(x.LESS)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:"<",left:r,right:s}}if(e.check(x.GREAT)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:">",left:r,right:s}}if(e.isWord()&&e.current().value==="="){e.advance();let s=Bm(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function kC(e){let t=[],n=0,r=-1,s=e.getInput(),i=()=>e.check(x.DBRACK_END)||e.check(x.AND_AND)||e.check(x.OR_OR)||e.check(x.NEWLINE)||e.check(x.EOF);for(;!i();){let o=e.current(),a=r>=0&&o.start>r;if(n===0&&a)break;if(n>0&&a){let l=s.slice(r,o.start);t.push({type:"Literal",value:l})}if(e.isWord()||e.check(x.ASSIGNMENT_WORD)){let l=e.parseWordForRegex();t.push(...l.parts),r=e.peek(-1).end}else if(e.check(x.LPAREN)){let l=e.advance();t.push({type:"Literal",value:"("}),n++,r=l.end}else if(e.check(x.DPAREN_START)){let l=e.advance();t.push({type:"Literal",value:"(("}),n+=2,r=l.end}else if(e.check(x.DPAREN_END))if(n>=2){let l=e.advance();t.push({type:"Literal",value:"))"}),n-=2,r=l.end}else{if(n===1)break;break}else if(e.check(x.RPAREN))if(n>0){let l=e.advance();t.push({type:"Literal",value:")"}),n--,r=l.end}else break;else if(e.check(x.PIPE)){let l=e.advance();t.push({type:"Literal",value:"|"}),r=l.end}else if(e.check(x.SEMICOLON))if(n>0){let l=e.advance();t.push({type:"Literal",value:";"}),r=l.end}else break;else if(n>0&&e.check(x.LESS)){let l=e.advance();t.push({type:"Literal",value:"<"}),r=l.end}else if(n>0&&e.check(x.GREAT)){let l=e.advance();t.push({type:"Literal",value:">"}),r=l.end}else if(n>0&&e.check(x.DGREAT)){let l=e.advance();t.push({type:"Literal",value:">>"}),r=l.end}else if(n>0&&e.check(x.DLESS)){let l=e.advance();t.push({type:"Literal",value:"<<"}),r=l.end}else if(n>0&&e.check(x.LESSAND)){let l=e.advance();t.push({type:"Literal",value:"<&"}),r=l.end}else if(n>0&&e.check(x.GREATAND)){let l=e.advance();t.push({type:"Literal",value:">&"}),r=l.end}else if(n>0&&e.check(x.LESSGREAT)){let l=e.advance();t.push({type:"Literal",value:"<>"}),r=l.end}else if(n>0&&e.check(x.CLOBBER)){let l=e.advance();t.push({type:"Literal",value:">|"}),r=l.end}else if(n>0&&e.check(x.TLESS)){let l=e.advance();t.push({type:"Literal",value:"<<<"}),r=l.end}else if(n>0&&e.check(x.AMP)){let l=e.advance();t.push({type:"Literal",value:"&"}),r=l.end}else if(n>0&&e.check(x.LBRACE)){let l=e.advance();t.push({type:"Literal",value:"{"}),r=l.end}else if(n>0&&e.check(x.RBRACE)){let l=e.advance();t.push({type:"Literal",value:"}"}),r=l.end}else break}return t.length===0&&e.error("Expected regex pattern after =~"),{type:"Word",parts:t}}var SC,AC,zm=v(()=>{"use strict";tn();SC=["-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"],AC=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function $C(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if("@*+?!".includes(s)&&r+1<e.length&&e[r+1]==="("){r++,n++,r++;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function IC(e,t,n){let r=n+1,s=t[r];if("@*#?$!-0123456789".includes(s))return{part:j.parameterExpansion(s),endIndex:r+1};let i="";for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)i+=t[r],r++;return{part:j.parameterExpansion(i),endIndex:r}}function RC(e,t,n,r=!1){let s=n+2,i=!1;t[s]==="!"&&(i=!0,s++);let o=!1;t[s]==="#"&&!/[}:#%/^,]/.test(t[s+1]||"}")&&(o=!0,s++);let a="",l=t[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(t[s+1]||""))a=l,s++;else for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)a+=t[s],s++;if(t[s]==="["){let u=ya(e,t,s,"[","]");if(a+=t.slice(s,u+1),s=u+1,t[s]==="["){let f=1,p=s;for(;p<t.length&&f>0;)t[p]==="{"?f++:t[p]==="}"&&f--,f>0&&p++;let d=t.slice(n+2,p);return{part:j.parameterExpansion("",{type:"BadSubstitution",text:d}),endIndex:p+1}}}if(a===""&&!i&&!o&&t[s]!=="}"){let u=1,f=s;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;if(u>0)throw new Ge("unexpected EOF while looking for matching '}'",0,0);let p=t.slice(n+2,f);return{part:j.parameterExpansion("",{type:"BadSubstitution",text:p}),endIndex:f+1}}let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pa(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(t[s]==="*"||t[s]==="@"&&!/[QPaAEKkuUL]/.test(t[s+1]||"")){let f=t[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pa(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(o)if(t[s]===":")for(c={type:"LengthSliceError"};s<t.length&&t[s]!=="}";)s++;else t[s]!=="}"&&/[-+=?]/.test(t[s])?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):t[s]==="/"?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<t.length&&t[s]!=="}"){let u=Pa(e,t,s,a,r);c=u.operation,s=u.endIndex}if(s<t.length&&t[s]!=="}"){let u=t[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<t.length&&t[f]!=="}";)f++;let p=t.slice(n,f+1);e.error(`\${${p.slice(2,-1)}}: bad substitution`)}}for(;s<t.length&&t[s]!=="}";)s++;if(s>=t.length)throw new Ge("unexpected EOF while looking for matching '}'",0,0);return{part:j.parameterExpansion(a,c),endIndex:s+1}}function Pa(e,t,n,r,s=!1){let i=n,o=t[i],a=t[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let b=Nn(e,t,i),y=t.slice(i,b),w=nn(e,y,!1,!1,!0,!1,s,!1,!1,!0),E=j.word(w.length>0?w:[j.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:E,checkEmpty:!0},endIndex:b};if(l==="=")return{operation:{type:"AssignDefault",word:E,checkEmpty:!0},endIndex:b};if(l==="?")return{operation:{type:"ErrorIfUnset",word:E,checkEmpty:!0},endIndex:b};if(l==="+")return{operation:{type:"UseAlternative",word:E,checkEmpty:!0},endIndex:b}}i++;let c=Nn(e,t,i),u=t.slice(i,c),f=-1,p=0,d=0;for(let g=0;g<u.length;g++){let b=u[g];if(b==="("||b==="[")p++;else if(b===")"||b==="]")p--;else if(b==="?"&&p===0)d++;else if(b===":"&&p===0)if(d>0)d--;else{f=g;break}}let m=f>=0?u.slice(0,f):u,h=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:ba(e,m),length:h!==null?ba(e,h):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=Nn(e,t,i),c=t.slice(i,l),u=nn(e,c,!1,!1,!0,!1,s,!1,!1,!0),f=j.word(u.length>0?u:[j.literal("")]);if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=Nn(e,t,i),f=t.slice(i,u),p=nn(e,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:j.word(p.length>0?p:[j.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;t[i]==="#"?(c="start",i++):t[i]==="%"&&(c="end",i++);let u;c!==null&&(t[i]==="/"||t[i]==="}")?u=i:u=Rm(e,t,i);let f=t.slice(i,u),p=nn(e,f,!1,!1,!1),d=j.word(p.length>0?p:[j.literal("")]),m=null,h=u;if(t[u]==="/"){let g=u+1,b=Nn(e,t,g),y=t.slice(g,b),w=nn(e,y,!1,!1,!1);m=j.word(w.length>0?w:[j.literal("")]),h=b}return{operation:{type:"PatternReplacement",pattern:d,replacement:m,all:l,anchor:c},endIndex:h}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=Nn(e,t,i),f=t.slice(i,u),p=f?j.word([j.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:p},endIndex:u}}return o==="@"&&/[QPaAEKkuUL]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function Ta(e,t,n,r=!1){let s=n+1;if(s>=t.length)return{part:j.literal("$"),endIndex:s};let i=t[s];if(i==="("&&t[s+1]==="(")return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(i==="["){let o=1,a=s+1;for(;a<t.length&&o>0;)t[a]==="["?o++:t[a]==="]"&&o--,o>0&&a++;if(o===0){let l=t.slice(s+1,a),c=he(e,l);return{part:j.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?e.parseCommandSubstitution(t,n):i==="{"?RC(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?IC(e,t,n):{part:j.literal("$"),endIndex:s}}function jm(e,t){let n=[],r=0,s="",i=()=>{s&&(n.push(j.literal(s)),s="")};for(;r<t.length;){let o=t[r];if(o==="\\"&&r+1<t.length){let a=t[r+1];if(a==="$"||a==="`"||a==='"'||a==="\\"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=Ta(e,t,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=e.parseBacktickSubstitution(t,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function PC(e,t,n){let r=[],s=n,i="",o=()=>{i&&(r.push(j.literal(i)),i="")};for(;s<t.length&&t[s]!=='"';){let a=t[s];if(a==="\\"&&s+1<t.length){let l=t[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=Ta(e,t,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:j.doubleQuoted(r),endIndex:s}}function nn(e,t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1){if(r)return[j.singleQuoted(t)];if(n){let m=jm(e,t);return[j.doubleQuoted(m)]}if(t.length>=2&&t[0]==='"'&&t[t.length-1]==='"'){let m=t.slice(1,-1),h=!1;for(let g=0;g<m.length;g++){if(m[g]==='"'){h=!0;break}m[g]==="\\"&&g+1<m.length&&g++}if(!h){let g=jm(e,m);return[j.doubleQuoted(g)]}}let u=[],f=0,p="",d=()=>{p&&(u.push(j.literal(p)),p="")};for(;f<t.length;){let m=t[f];if(m==="\\"&&f+1<t.length){let h=t[f+1];if(l){d(),u.push(j.escaped(h)),f+=2;continue}let g=i?h==="$"||h==="`"||h===`
746
746
  `:h==="$"||h==="`"||h==='"'||h==="'"||h===`
747
- `||c&&h==="}",b=o?"*?[]\\".includes(h):"*?[]\\(){}.^+".includes(h);g?p+=h:b?(d(),u.push(j.escaped(h))):p+=`\\${h}`,f+=2;continue}if(m==="'"&&!o&&!i){d();let h=t.indexOf("'",f+1);if(h===-1){p+=t.slice(f);break}u.push(j.singleQuoted(t.slice(f+1,h))),f=h+1;continue}if(m==='"'&&!i){d();let{part:h,endIndex:g}=PC(e,t,f+1);u.push(h),f=g+1;continue}if(m==="$"&&t[f+1]==="'"){d();let{part:h,endIndex:g}=Tm(e,t,f+2);u.push(h),f=g;continue}if(m==="$"){d();let{part:h,endIndex:g}=Ta(e,t,f);h&&u.push(h),f=g;continue}if(m==="`"){d();let{part:h,endIndex:g}=e.parseBacktickSubstitution(t,f);u.push(h),f=g;continue}if(m==="~"){let h=f>0?t[f-1]:"";if(f===0||h==="="||s&&h===":"){let b=Im(e,t,f),y=t[b];if(y===void 0||y==="/"||y===":"){d();let w=t.slice(f+1,b)||null;u.push({type:"TildeExpansion",user:w}),f=b;continue}}}if("@*+?!".includes(m)&&f+1<t.length&&t[f+1]==="("){let h=$C(t,f+1);if(h!==-1){d();let g=t.slice(f,h+1);u.push({type:"Glob",pattern:g}),f=h+1;continue}}if(m==="*"||m==="?"||m==="["){d();let{pattern:h,endIndex:g}=Pm(e,t,f);u.push({type:"Glob",pattern:h}),f=g;continue}if(m==="{"&&!s&&!a){let h=Om(e,t,f,tn);if(h){d(),u.push(h.part),f=h.endIndex;continue}}p+=m,f++}return d(),u}var Hm=v(()=>{"use strict";Cn();Je();An();xa()});function Vm(e,t){let n=e.length,r=t+3,s=2,i=!1,o=!1;for(;r<n&&s>0;){let a=e[r];if(i){a==="'"&&(i=!1),r++;continue}if(o){if(a==="\\"){r+=2;continue}a==='"'&&(o=!1),r++;continue}if(a==="'"){i=!0,r++;continue}if(a==='"'){o=!0,r++;continue}if(a==="\\"){r+=2;continue}if(a==="("){s++,r++;continue}if(a===")"){if(s--,s===1){let l=r+1;return!(l<n&&e[l]===")")}if(s===0)return!1;r++;continue}if(s===1&&(a==="|"&&r+1<n&&e[r+1]==="|"||a==="&"&&r+1<n&&e[r+1]==="&"||a==="|"&&r+1<n&&e[r+1]!=="|"))return!0;r++}return!1}function qm(e,t,n,r){let s=t+2,i=1,o=s,a=!1,l=!1,c=0,u=!1,f="";for(;o<e.length&&i>0;){let h=e[o];a?h==="'"&&(a=!1):l?h==="\\"&&o+1<e.length?o++:h==='"'&&(l=!1):h==="'"?(a=!0,f=""):h==='"'?(l=!0,f=""):h==="\\"&&o+1<e.length?(o++,f=""):/[a-zA-Z_]/.test(h)?f+=h:(f==="case"?(c++,u=!1):f==="in"&&c>0?u=!0:f==="esac"&&c>0&&(c--,u=!1),f="",h==="("?o>0&&e[o-1]==="$"?i++:u||i++:h===")"?u?u=!1:i--:h===";"&&c>0&&o+1<e.length&&e[o+1]===";"&&(u=!0)),i>0&&o++}i>0&&r("unexpected EOF while looking for matching `)'");let p=e.slice(s,o),m=n().parse(p);return{part:j.commandSubstitution(m,!1),endIndex:o+1}}function Gm(e,t,n,r,s){let o=t+1,a="";for(;o<e.length&&e[o]!=="`";)if(e[o]==="\\"){let u=e[o+1];u==="$"||u==="`"||u==="\\"||u===`
747
+ `||c&&h==="}",b=o?"*?[]\\".includes(h):"*?[]\\(){}.^+".includes(h);g?p+=h:b?(d(),u.push(j.escaped(h))):p+=`\\${h}`,f+=2;continue}if(m==="'"&&!o&&!i){d();let h=t.indexOf("'",f+1);if(h===-1){p+=t.slice(f);break}u.push(j.singleQuoted(t.slice(f+1,h))),f=h+1;continue}if(m==='"'&&!i){d();let{part:h,endIndex:g}=PC(e,t,f+1);u.push(h),f=g+1;continue}if(m==="$"&&t[f+1]==="'"){d();let{part:h,endIndex:g}=Tm(e,t,f+2);u.push(h),f=g;continue}if(m==="$"){d();let{part:h,endIndex:g}=Ta(e,t,f);h&&u.push(h),f=g;continue}if(m==="`"){d();let{part:h,endIndex:g}=e.parseBacktickSubstitution(t,f);u.push(h),f=g;continue}if(m==="~"){let h=f>0?t[f-1]:"";if(f===0||h==="="||s&&h===":"){let b=Im(e,t,f),y=t[b];if(y===void 0||y==="/"||y===":"){d();let w=t.slice(f+1,b)||null;u.push({type:"TildeExpansion",user:w}),f=b;continue}}}if("@*+?!".includes(m)&&f+1<t.length&&t[f+1]==="("){let h=$C(t,f+1);if(h!==-1){d();let g=t.slice(f,h+1);u.push({type:"Glob",pattern:g}),f=h+1;continue}}if(m==="*"||m==="?"||m==="["){d();let{pattern:h,endIndex:g}=Pm(e,t,f);u.push({type:"Glob",pattern:h}),f=g;continue}if(m==="{"&&!s&&!a){let h=Om(e,t,f,nn);if(h){d(),u.push(h.part),f=h.endIndex;continue}}p+=m,f++}return d(),u}var Hm=v(()=>{"use strict";Cn();Je();An();xa()});function Vm(e,t){let n=e.length,r=t+3,s=2,i=!1,o=!1;for(;r<n&&s>0;){let a=e[r];if(i){a==="'"&&(i=!1),r++;continue}if(o){if(a==="\\"){r+=2;continue}a==='"'&&(o=!1),r++;continue}if(a==="'"){i=!0,r++;continue}if(a==='"'){o=!0,r++;continue}if(a==="\\"){r+=2;continue}if(a==="("){s++,r++;continue}if(a===")"){if(s--,s===1){let l=r+1;return!(l<n&&e[l]===")")}if(s===0)return!1;r++;continue}if(s===1&&(a==="|"&&r+1<n&&e[r+1]==="|"||a==="&"&&r+1<n&&e[r+1]==="&"||a==="|"&&r+1<n&&e[r+1]!=="|"))return!0;r++}return!1}function qm(e,t,n,r){let s=t+2,i=1,o=s,a=!1,l=!1,c=0,u=!1,f="";for(;o<e.length&&i>0;){let h=e[o];a?h==="'"&&(a=!1):l?h==="\\"&&o+1<e.length?o++:h==='"'&&(l=!1):h==="'"?(a=!0,f=""):h==='"'?(l=!0,f=""):h==="\\"&&o+1<e.length?(o++,f=""):/[a-zA-Z_]/.test(h)?f+=h:(f==="case"?(c++,u=!1):f==="in"&&c>0?u=!0:f==="esac"&&c>0&&(c--,u=!1),f="",h==="("?o>0&&e[o-1]==="$"?i++:u||i++:h===")"?u?u=!1:i--:h===";"&&c>0&&o+1<e.length&&e[o+1]===";"&&(u=!0)),i>0&&o++}i>0&&r("unexpected EOF while looking for matching `)'");let p=e.slice(s,o),m=n().parse(p);return{part:j.commandSubstitution(m,!1),endIndex:o+1}}function Gm(e,t,n,r,s){let o=t+1,a="";for(;o<e.length&&e[o]!=="`";)if(e[o]==="\\"){let u=e[o+1];u==="$"||u==="`"||u==="\\"||u===`
748
748
  `||n&&u==='"'?(u!==`
749
- `&&(a+=u),o+=2):(a+=e[o],o++)}else a+=e[o],o++;o>=e.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(a);return{part:j.commandSubstitution(c,!0),endIndex:o+1}}var Zm=v(()=>{"use strict";Cn()});function Bt(e){return new se().parse(e)}var se,Fe=v(()=>{"use strict";Cn();Je();Lm();Mm();zm();Hm();en();Zm();An();An();se=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>um)throw new Ge("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(t){if(t.length>da)throw new Ge(`Input too large: ${t.length} bytes exceeds limit of ${da}`,1,1);this._input=t;let n=new Zs(t);if(this.tokens=n.tokenize(),this.tokens.length>ha)throw new Ge(`Too many tokens: ${this.tokens.length} exceeds limit of ${ha}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseScript()}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.pos<this.tokens.length-1&&this.pos++,t}getPos(){return this.pos}check(t,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===t||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(t,n){if(this.check(t))return this.advance();let r=this.current();throw new Ge(n||`Expected ${t}, got ${r.type}`,r.line,r.column,r)}error(t){let n=this.current();throw new Ge(t,n.line,n.column,n)}skipNewlines(){for(;this.check(x.NEWLINE,x.COMMENT);)this.check(x.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(x.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(x.SEMICOLON,x.COMMENT)){this.advance();continue}if(t&&this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,n,r,s){this.pendingHeredocs.push({redirect:t,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(x.HEREDOC_CONTENT)){let n=this.advance(),r;t.quoted?r=j.word([j.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),t.redirect.target=j.hereDoc(t.delimiter,r,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(x.EOF,x.NEWLINE,x.SEMICOLON,x.AMP,x.AND_AND,x.OR_OR,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===x.WORD||t===x.NAME||t===x.NUMBER||t===x.ASSIGNMENT_WORD||t===x.IF||t===x.FOR||t===x.WHILE||t===x.UNTIL||t===x.CASE||t===x.LPAREN||t===x.LBRACE||t===x.DPAREN_START||t===x.DBRACK_START||t===x.FUNCTION||t===x.BANG||t===x.TIME||t===x.IN||t===x.LESS||t===x.GREAT||t===x.DLESS||t===x.DGREAT||t===x.LESSAND||t===x.GREATAND||t===x.LESSGREAT||t===x.DLESSDASH||t===x.CLOBBER||t===x.TLESS||t===x.AND_GREAT||t===x.AND_DGREAT}parseScript(){let t=[],r=0;for(this.skipNewlines();!this.check(x.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){t.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&t.push(o),this.skipSeparators(!1),this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(x.EOF)&&this.advance()}return j.script(t)}checkUnexpectedToken(){let t=this.current().type,n=this.current().value;if((t===x.DO||t===x.DONE||t===x.THEN||t===x.ELSE||t===x.ELIF||t===x.FI||t===x.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),t===x.RBRACE||t===x.RPAREN){let r=`syntax error near unexpected token \`${n}'`;return this.advance(),j.statement([j.pipeline([j.simpleCommand(null,[],[],[])])],[],!1,{message:r,token:n})}return(t===x.DSEMI||t===x.SEMI_AND||t===x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),t===x.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`),(t===x.PIPE||t===x.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${n}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,n=[],r=[],s=!1,i=this.parsePipeline();for(n.push(i);this.check(x.AND_AND,x.OR_OR);){let l=this.advance();r.push(l.type===x.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();n.push(c)}this.check(x.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:t,a=this._input.slice(t,o);return j.statement(n,r,s,void 0,a)}parsePipeline(){let t=!1,n=!1;this.check(x.TIME)&&(this.advance(),t=!0,this.check(x.WORD,x.NAME)&&this.current().value==="-p"&&(this.advance(),n=!0));let r=0;for(;this.check(x.BANG);)this.advance(),r++;let s=r%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(x.PIPE,x.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===x.PIPE_AMP);let c=this.parseCommand();i.push(c)}return j.pipeline(i,s,t,n,o.length>0?o:void 0)}parseCommand(){return this.check(x.IF)?Sa(this):this.check(x.FOR)?Aa(this):this.check(x.WHILE)?Ca(this):this.check(x.UNTIL)?Na(this):this.check(x.CASE)?ka(this):this.check(x.LPAREN)?va(this):this.check(x.LBRACE)?$a(this):this.check(x.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(x.DBRACK_START)?this.parseConditionalCommand():this.check(x.FUNCTION)?this.parseFunctionDef():this.check(x.NAME,x.WORD)&&this.peek(1).type===x.LPAREN&&this.peek(2).type===x.RPAREN?this.parseFunctionDef():_m(this)}dparenClosesWithSpacedParens(){let t=1,n=1;for(;n<this.tokens.length-this.pos;){let r=this.peek(n);if(r.type===x.EOF)return!1;if(r.type===x.DPAREN_START||r.type===x.LPAREN)t++;else if(r.type===x.DPAREN_END){if(t-=2,t<=0)return!1}else if(r.type===x.RPAREN&&(t--,t===0&&this.peek(n+1).type===x.RPAREN))return!0;n++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(x.RPAREN),this.expect(x.RPAREN);let n=this.parseOptionalRedirections(),r=j.subshell(t,[]);return j.subshell([j.statement([j.pipeline([r],!1,!1,!1)])],n)}isWord(){let t=this.current().type;return t===x.WORD||t===x.NAME||t===x.NUMBER||t===x.IF||t===x.FOR||t===x.WHILE||t===x.UNTIL||t===x.CASE||t===x.FUNCTION||t===x.ELSE||t===x.ELIF||t===x.FI||t===x.THEN||t===x.DO||t===x.DONE||t===x.ESAC||t===x.IN||t===x.SELECT||t===x.TIME||t===x.COPROC||t===x.BANG}parseWord(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted)}parseWordNoBraceExpansion(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0)}parseWordForRegex(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0,!0)}parseWordFromString(t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1){let l=tn(this,t,n,r,s,i,!1,o,a);return j.word(l)}parseCommandSubstitution(t,n){return qm(t,n,()=>new e,r=>this.error(r))}parseBacktickSubstitution(t,n,r=!1){return Gm(t,n,r,()=>new e,s=>this.error(s))}isDollarDparenSubshell(t,n){return Vm(t,n)}parseArithmeticExpansion(t,n){let r=n+3,s=1,i=0,o=r;for(;o<t.length-1&&s>0;)t[o]==="$"&&t[o+1]==="("?t[o+2]==="("?(s++,o+=3):(i++,o+=2):t[o]==="("&&t[o+1]==="("?(s++,o+=2):t[o]===")"&&t[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):t[o]==="("?(i++,o++):(t[o]===")"&&i>0&&i--,o++);let a=t.slice(r,o),l=this.parseArithmeticExpression(a);return{part:j.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let t=this.expect(x.DPAREN_START),n="",r=1,s=0,i=!1,o=!1;for(;r>0&&!this.check(x.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(x.RPAREN)){r--,o=!0,this.advance();continue}if(this.check(x.DPAREN_END)){r--,o=!0;continue}n+=")";continue}if(this.check(x.DPAREN_START))r++,n+="((",this.advance();else if(this.check(x.DPAREN_END))s>=2?(s-=2,n+="))",this.advance()):s===1?(s--,n+=")",i=!0,this.advance()):(r--,o=!0,r>0&&(n+="))"),this.advance());else if(this.check(x.LPAREN))s++,n+="(",this.advance();else if(this.check(x.RPAREN))s>0&&s--,n+=")",this.advance();else{let c=this.current().value,u=n.length>0?n[n.length-1]:"";n.length>0&&!n.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(n))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(n+=" "),n+=c,this.advance()}}o||this.expect(x.DPAREN_END);let a=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return j.arithmeticCommand(a,l,t.line)}parseConditionalCommand(){let t=this.expect(x.DBRACK_START),n=Ra(this);this.expect(x.DBRACK_END);let r=this.parseOptionalRedirections();return j.conditionalCommand(n,r,t.line)}parseFunctionDef(){let t;if(this.check(x.FUNCTION)){if(this.advance(),this.check(x.NAME)||this.check(x.WORD))t=this.advance().value;else{let s=this.current();throw new Ge("Expected function name",s.line,s.column,s)}this.check(x.LPAREN)&&(this.advance(),this.expect(x.RPAREN))}else t=this.advance().value,t.includes("$")&&this.error(`\`${t}': not a valid identifier`),this.expect(x.LPAREN),this.expect(x.RPAREN);this.skipNewlines();let n=this.parseCompoundCommandBody({forFunctionBody:!0}),r=this.parseOptionalRedirections();return j.functionDef(t,n,r)}parseCompoundCommandBody(t){let n=t?.forFunctionBody;if(this.check(x.LBRACE))return $a(this,{skipRedirections:n});if(this.check(x.LPAREN))return va(this,{skipRedirections:n});if(this.check(x.IF))return Sa(this,{skipRedirections:n});if(this.check(x.FOR))return Aa(this,{skipRedirections:n});if(this.check(x.WHILE))return Ca(this,{skipRedirections:n});if(this.check(x.UNTIL))return Na(this,{skipRedirections:n});if(this.check(x.CASE))return ka(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let t=[];for(this.skipNewlines();!this.check(x.EOF,x.FI,x.ELSE,x.ELIF,x.THEN,x.DO,x.DONE,x.ESAC,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,r=this.parseStatement();if(r&&t.push(r),this.skipSeparators(),this.pos===n&&!r)break}return t}parseOptionalRedirections(){let t=[];for(;Xs(this);){this.checkIterationLimit();let n=this.pos;if(t.push(Js(this)),this.pos===n)break}return t}parseArithmeticExpression(t){return he(this,t)}}});function Da(e){return DC[e]||""}function eg(e){let t=[],n="",r=0;for(;r<e.length;){let s=e[r];if(s==="["){for(n+=s,r++,r<e.length&&(e[r]==="!"||e[r]==="^")&&(n+=e[r],r++),r<e.length&&e[r]==="]"&&(n+=e[r],r++);r<e.length&&e[r]!=="]";){if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let i=e.indexOf(":]",r+2);if(i!==-1){n+=e.slice(r,i+2),r=i+2;continue}}if(e[r]==="\\"&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]==="]"&&(n+=e[r],r++)}else s===":"?(n!==""&&t.push(n),n="",r++):s==="\\"&&r+1<e.length?(n+=s+e[r+1],r+=2):(n+=s,r++)}return n!==""&&t.push(n),t}function tg(e){let t="^";for(let n=0;n<e.length;n++){let r=e[n];if(r==="*")t+="[^/]*";else if(r==="?")t+="[^/]";else if(r==="["){let s=n+1,i="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(i+="^",s++),s<e.length&&e[s]==="]"&&(i+="\\]",s++);let o=s;for(;o<e.length;){if(e[o]==="\\"&&o+1<e.length){o+=2;continue}if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let l=e.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(e[o]==="]")break;o++}let a=s;for(;s<e.length&&e[s]!=="]";){if(e[s]==="["&&s+1<e.length&&e[s+1]===":"){let l=e.indexOf(":]",s+2);if(l!==-1){let c=e.slice(s+2,l),u=Da(c);i+=u,s=l+2;continue}}if(e[s]==="\\"&&s+1<e.length){i+=`\\${e[s+1]}`,s+=2;continue}if(e[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=e[s];s++}i+="]",t+=i,n=s}else if(r==="\\"&&n+1<e.length){let s=e[n+1];/[.+^${}()|\\*?[\]]/.test(s)?t+=`\\${s}`:t+=s,n++}else/[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+="$",new RegExp(t)}function Fa(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function _a(e){let t=[],n="",r=0,s=!1,i=0;for(;i<e.length;){let o=e[i];if(o==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=o,i++;continue}if(o==="\\"){n+=o,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}o==="("?(r++,n+=o):o===")"?(r--,n+=o):o==="|"&&r===0?(t.push(n),n=""):n+=o,i++}return t.push(n),t}var DC,ng=v(()=>{"use strict";DC={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"}});var nn,Ys=v(()=>{"use strict";Pn();ng();nn=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;constructor(t,n,r,s){this.fs=t,this.cwd=n,typeof s=="boolean"?this.globstar=s:s&&(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0);let i=r?.GLOBIGNORE;i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=eg(i))}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(n=>{let r=n.split("/").pop()||n;if((this.hasGlobignore||this.globskipdots)&&(r==="."||r===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(n,s))return!1}return!0})}matchGlobignorePattern(t,n){return tg(n).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,n){let r=t.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<t.length;o++){let a=s[o];a===null?i.push(t[o]):a.length>0?i.push(...a):i.push(t[o])}return i}async expand(t){let n;if(t.includes("**")&&this.globstar&&this.isGlobstarValid(t))n=await this.expandRecursive(t);else{let r=t.replace(/\*\*+/g,"*");n=await this.expandSimple(r)}return this.filterGlobignore(n)}isGlobstarValid(t){let n=t.split("/");for(let r of n)if(r.includes("**")&&r!=="**")return!1;return!0}hasGlobChars(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandSimple(t){let n=t.startsWith("/"),r=t.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<r.length;c++)if(this.hasGlobChars(r[c])){s=c;break}if(s===-1)return[t];let i,o;if(s===0)n?(i="/",o="/"):(i=this.cwd,o="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=r.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(t,n,r){if(r.length===0)return[n];let[s,...i]=r,o=[];try{if(this.fs.readdirWithFileTypes){let a=await this.fs.readdirWithFileTypes(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let p=a.some(m=>m.name==="."),d=a.some(m=>m.name==="..");p||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let p of c)if(!(p.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p.name,s)){let d=t==="/"?`/${p.name}`:`${t}/${p.name}`,m;n===""?m=p.name:n==="/"?m=`/${p.name}`:m=`${n}/${p.name}`,i.length===0?l.push(Promise.resolve([m])):p.isDirectory&&l.push(this.expandSegments(d,m,i))}let f=await Promise.all(l);for(let p of f)o.push(...p)}else{let a=await this.fs.readdir(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let p of c)if(!(p.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p,s)){let d=t==="/"?`/${p}`:`${t}/${p}`,m;n===""?m=p:n==="/"?m=`/${p}`:m=`${n}/${p}`,i.length===0?l.push(Promise.resolve([m])):l.push((async()=>{try{if((await this.fs.stat(d)).isDirectory)return this.expandSegments(d,m,i)}catch{}return[]})())}let f=await Promise.all(l);for(let p of f)o.push(...p)}}catch{}return o}async expandRecursive(t){let n=[],r=t.indexOf("**"),s=t.slice(0,r).replace(/\/$/,"")||".",o=t.slice(r+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,n),[...new Set(n)].sort()):(await this.walkDirectory(s,o,n),n.sort())}async walkDirectoryMultiGlobstar(t,n,r){let s=this.fs.resolvePath(this.cwd,t);try{let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&o.push(u)}let a=t==="."?n:`${t}/${n}`,l=await this.expandRecursive(a);r.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{let o=await this.fs.readdir(s),a=[];for(let u of o){let f=t==="."?u:`${t}/${u}`,p=this.fs.resolvePath(this.cwd,f);try{(await this.fs.stat(p)).isDirectory&&a.push(f)}catch{}}let l=t==="."?n:`${t}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(p=>this.walkDirectoryMultiGlobstar(p,n,r)))}}}catch{}}async walkDirectory(t,n,r){let s=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=t==="."?l.name:`${t}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,n,r)))}}else{let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let p=t==="."?f:`${t}/${f}`,d=this.fs.resolvePath(this.cwd,p);try{let m=await this.fs.stat(d);return{name:f,path:p,isDirectory:m.isDirectory}}catch{return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch{}}matchPattern(t,n){return this.patternToRegex(n).test(t)}patternToRegex(t){let n=this.patternToRegexStr(t);return new RegExp(`^${n}$`)}patternToRegexStr(t){let n="",r=!1;for(let s=0;s<t.length;s++){if(t.slice(s,s+13)==="\0QUOTE_START\0"){r=!0,s+=12;continue}if(t.slice(s,s+11)==="\0QUOTE_END\0"){r=!1,s+=10;continue}let i=t[s];if(r){/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<t.length&&t[s+1]==="("){let o=Fa(t,s+1);if(o!==-1){let a=t.slice(s+2,o),l=_a(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")n+=`(?:${u})`;else if(i==="*")n+=`(?:${u})*`;else if(i==="+")n+=`(?:${u})+`;else if(i==="?")n+=`(?:${u})?`;else if(i==="!")if(o<t.length-1){let p=l.map(m=>this.computePatternLength(m));if(p.every(m=>m!==null)&&p.every(m=>m===p[0])&&p[0]!==null){let m=p[0];if(m===0)n+="(?:.+)";else{let h=[];m>0&&h.push(`.{0,${m-1}}`),h.push(`.{${m+1},}`),h.push(`(?!(?:${u})).{${m}}`),n+=`(?:${h.join("|")})`}}else n+=`(?:(?!(?:${u})).)*?`}else n+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let o=s+1,a="[";o<t.length&&(t[o]==="^"||t[o]==="!")&&(a+="^",o++),o<t.length&&t[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<t.length;){if(t[l]==="\\"&&l+1<t.length){l+=2;continue}if(t[l]==="["&&l+1<t.length&&t[l+1]===":"){let u=t.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(t[l]==="]")break;l++}let c=o;for(;o<t.length&&t[o]!=="]";){if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let u=t.indexOf(":]",o+2);if(u!==-1){let f=t.slice(o+2,u),p=Da(f);a+=p,o=u+2;continue}}if(t[o]==="\\"&&o+1<t.length){a+=`\\${t[o+1]}`,o+=2;continue}if(t[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=t[o];o++}a+="]",n+=a,s=o}else if(i==="\\"&&s+1<t.length){let o=t[s+1];/[.+^${}()|\\*?[\]]/.test(o)?n+=`\\${o}`:n+=o,s++}else/[.+^${}()|]/.test(i)?n+=`\\${i}`:n+=i}return n}computePatternLength(t){let n=0,r=0,s=!1;for(;r<t.length;){if(t.slice(r,r+13)==="\0QUOTE_START\0"){s=!0,r+=13;continue}if(t.slice(r,r+11)==="\0QUOTE_END\0"){s=!1,r+=11;continue}let i=t[r];if(s){n+=1,r++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&r+1<t.length&&t[r+1]==="("){let o=Fa(t,r+1);if(o!==-1){if(i==="@"){let a=t.slice(r+2,o),c=_a(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let o=t.indexOf("]",r+1);if(o!==-1){n+=1,r=o+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function La(e){for(let t=0;t<e.length;t++){if(e[t]==="\\"){t++;continue}if(e[t]==="$"){let n=e[t+1];if(n==="{"||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function FC(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function rg(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n||n.length===0)return!1;for(let r of n)if(r.type!=="DoubleQuoted"&&r.type!=="SingleQuoted")return!1;return!0}function Lr(e){let t=!1,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1;for(let l of e){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(t=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),FC(l)&&(t=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&La(l.pattern)&&(i=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var ei=v(()=>{"use strict"});function _e(e,t){let n=`${t}_`,r=[];for(let s of Object.keys(e.state.env))if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function Ut(e,t){let n=`${t}_`;for(let r of Object.keys(e.state.env))r.startsWith(n)&&delete e.state.env[r]}function Pt(e,t){let n=`${t}_`,r=`${t}__length`,s=[];for(let i of Object.keys(e.state.env))if(i!==r&&i.startsWith(n)){let o=i.slice(n.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function ti(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Ma(e){if(e.parts.length<2)return null;let t=e.parts[0],n=e.parts[1];if(t.type!=="Glob"||!t.pattern.startsWith("["))return null;let r,s=n,i=1;if(n.type==="Literal"&&n.value.startsWith("]")){let f=n.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))r=t.pattern.slice(1);else if(f===""){if(e.parts.length<3)return null;let p=e.parts[2];if(p.type!=="Literal"||!p.value.startsWith("=")&&!p.value.startsWith("+="))return null;r=t.pattern.slice(1),s=p,i=2}else return null}else if(t.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(e.parts.length<3)return null;let f=e.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(n.type==="SingleQuoted")r=n.value;else{r="";for(let p of n.parts)(p.type==="Literal"||p.type==="Escaped")&&(r+=p.value)}s=f,i=2}else if(t.pattern.endsWith("]")){if(n.type!=="Literal"||!n.value.startsWith("=")&&!n.value.startsWith("+="))return null;r=t.pattern.slice(1,-1)}else return null;r=ti(r);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<e.parts.length;f++){let p=e.parts[f];p.type==="BraceExpansion"?l.push({type:"Literal",value:_C(p)}):l.push(p)}return{key:r,valueParts:l,append:a}}function _C(e){return`{${e.items.map(n=>{if(n.type==="Range"){let r=n.startStr??String(n.start),s=n.endStr??String(n.end),i=`${r}..${s}`;return n.step&&(i+=`..${n.step}`),i}return Yn(n.word)}).join(",")}}`}function Yn(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value;break;case"Glob":t+=n.pattern;break;case"SingleQuoted":t+=n.value;break;case"DoubleQuoted":for(let r of n.parts)(r.type==="Literal"||r.type==="Escaped")&&(t+=r.value);break;case"Escaped":t+=n.value;break;case"BraceExpansion":t+="{",t+=n.items.map(r=>r.type==="Range"?`${r.startStr}..${r.endStr}${r.step?`..${r.step}`:""}`:Yn(r.word)).join(","),t+="}";break;case"TildeExpansion":t+="~",n.user&&(t+=n.user);break}return t}var $t=v(()=>{"use strict"});function Ue(e){return e.IFS??`
749
+ `&&(a+=u),o+=2):(a+=e[o],o++)}else a+=e[o],o++;o>=e.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(a);return{part:j.commandSubstitution(c,!0),endIndex:o+1}}var Zm=v(()=>{"use strict";Cn()});function Bt(e){return new se().parse(e)}var se,Fe=v(()=>{"use strict";Cn();Je();Lm();Mm();zm();Hm();tn();Zm();An();An();se=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>um)throw new Ge("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(t){if(t.length>da)throw new Ge(`Input too large: ${t.length} bytes exceeds limit of ${da}`,1,1);this._input=t;let n=new Zs(t);if(this.tokens=n.tokenize(),this.tokens.length>ha)throw new Ge(`Too many tokens: ${this.tokens.length} exceeds limit of ${ha}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseScript()}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.pos<this.tokens.length-1&&this.pos++,t}getPos(){return this.pos}check(t,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===t||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(t,n){if(this.check(t))return this.advance();let r=this.current();throw new Ge(n||`Expected ${t}, got ${r.type}`,r.line,r.column,r)}error(t){let n=this.current();throw new Ge(t,n.line,n.column,n)}skipNewlines(){for(;this.check(x.NEWLINE,x.COMMENT);)this.check(x.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(x.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(x.SEMICOLON,x.COMMENT)){this.advance();continue}if(t&&this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,n,r,s){this.pendingHeredocs.push({redirect:t,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(x.HEREDOC_CONTENT)){let n=this.advance(),r;t.quoted?r=j.word([j.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),t.redirect.target=j.hereDoc(t.delimiter,r,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(x.EOF,x.NEWLINE,x.SEMICOLON,x.AMP,x.AND_AND,x.OR_OR,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===x.WORD||t===x.NAME||t===x.NUMBER||t===x.ASSIGNMENT_WORD||t===x.IF||t===x.FOR||t===x.WHILE||t===x.UNTIL||t===x.CASE||t===x.LPAREN||t===x.LBRACE||t===x.DPAREN_START||t===x.DBRACK_START||t===x.FUNCTION||t===x.BANG||t===x.TIME||t===x.IN||t===x.LESS||t===x.GREAT||t===x.DLESS||t===x.DGREAT||t===x.LESSAND||t===x.GREATAND||t===x.LESSGREAT||t===x.DLESSDASH||t===x.CLOBBER||t===x.TLESS||t===x.AND_GREAT||t===x.AND_DGREAT}parseScript(){let t=[],r=0;for(this.skipNewlines();!this.check(x.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){t.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&t.push(o),this.skipSeparators(!1),this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(x.EOF)&&this.advance()}return j.script(t)}checkUnexpectedToken(){let t=this.current().type,n=this.current().value;if((t===x.DO||t===x.DONE||t===x.THEN||t===x.ELSE||t===x.ELIF||t===x.FI||t===x.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),t===x.RBRACE||t===x.RPAREN){let r=`syntax error near unexpected token \`${n}'`;return this.advance(),j.statement([j.pipeline([j.simpleCommand(null,[],[],[])])],[],!1,{message:r,token:n})}return(t===x.DSEMI||t===x.SEMI_AND||t===x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),t===x.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`),(t===x.PIPE||t===x.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${n}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,n=[],r=[],s=!1,i=this.parsePipeline();for(n.push(i);this.check(x.AND_AND,x.OR_OR);){let l=this.advance();r.push(l.type===x.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();n.push(c)}this.check(x.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:t,a=this._input.slice(t,o);return j.statement(n,r,s,void 0,a)}parsePipeline(){let t=!1,n=!1;this.check(x.TIME)&&(this.advance(),t=!0,this.check(x.WORD,x.NAME)&&this.current().value==="-p"&&(this.advance(),n=!0));let r=0;for(;this.check(x.BANG);)this.advance(),r++;let s=r%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(x.PIPE,x.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===x.PIPE_AMP);let c=this.parseCommand();i.push(c)}return j.pipeline(i,s,t,n,o.length>0?o:void 0)}parseCommand(){return this.check(x.IF)?Sa(this):this.check(x.FOR)?Aa(this):this.check(x.WHILE)?Ca(this):this.check(x.UNTIL)?Na(this):this.check(x.CASE)?ka(this):this.check(x.LPAREN)?va(this):this.check(x.LBRACE)?$a(this):this.check(x.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(x.DBRACK_START)?this.parseConditionalCommand():this.check(x.FUNCTION)?this.parseFunctionDef():this.check(x.NAME,x.WORD)&&this.peek(1).type===x.LPAREN&&this.peek(2).type===x.RPAREN?this.parseFunctionDef():_m(this)}dparenClosesWithSpacedParens(){let t=1,n=1;for(;n<this.tokens.length-this.pos;){let r=this.peek(n);if(r.type===x.EOF)return!1;if(r.type===x.DPAREN_START||r.type===x.LPAREN)t++;else if(r.type===x.DPAREN_END){if(t-=2,t<=0)return!1}else if(r.type===x.RPAREN&&(t--,t===0&&this.peek(n+1).type===x.RPAREN))return!0;n++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(x.RPAREN),this.expect(x.RPAREN);let n=this.parseOptionalRedirections(),r=j.subshell(t,[]);return j.subshell([j.statement([j.pipeline([r],!1,!1,!1)])],n)}isWord(){let t=this.current().type;return t===x.WORD||t===x.NAME||t===x.NUMBER||t===x.IF||t===x.FOR||t===x.WHILE||t===x.UNTIL||t===x.CASE||t===x.FUNCTION||t===x.ELSE||t===x.ELIF||t===x.FI||t===x.THEN||t===x.DO||t===x.DONE||t===x.ESAC||t===x.IN||t===x.SELECT||t===x.TIME||t===x.COPROC||t===x.BANG}parseWord(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted)}parseWordNoBraceExpansion(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0)}parseWordForRegex(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0,!0)}parseWordFromString(t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1){let l=nn(this,t,n,r,s,i,!1,o,a);return j.word(l)}parseCommandSubstitution(t,n){return qm(t,n,()=>new e,r=>this.error(r))}parseBacktickSubstitution(t,n,r=!1){return Gm(t,n,r,()=>new e,s=>this.error(s))}isDollarDparenSubshell(t,n){return Vm(t,n)}parseArithmeticExpansion(t,n){let r=n+3,s=1,i=0,o=r;for(;o<t.length-1&&s>0;)t[o]==="$"&&t[o+1]==="("?t[o+2]==="("?(s++,o+=3):(i++,o+=2):t[o]==="("&&t[o+1]==="("?(s++,o+=2):t[o]===")"&&t[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):t[o]==="("?(i++,o++):(t[o]===")"&&i>0&&i--,o++);let a=t.slice(r,o),l=this.parseArithmeticExpression(a);return{part:j.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let t=this.expect(x.DPAREN_START),n="",r=1,s=0,i=!1,o=!1;for(;r>0&&!this.check(x.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(x.RPAREN)){r--,o=!0,this.advance();continue}if(this.check(x.DPAREN_END)){r--,o=!0;continue}n+=")";continue}if(this.check(x.DPAREN_START))r++,n+="((",this.advance();else if(this.check(x.DPAREN_END))s>=2?(s-=2,n+="))",this.advance()):s===1?(s--,n+=")",i=!0,this.advance()):(r--,o=!0,r>0&&(n+="))"),this.advance());else if(this.check(x.LPAREN))s++,n+="(",this.advance();else if(this.check(x.RPAREN))s>0&&s--,n+=")",this.advance();else{let c=this.current().value,u=n.length>0?n[n.length-1]:"";n.length>0&&!n.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(n))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(n+=" "),n+=c,this.advance()}}o||this.expect(x.DPAREN_END);let a=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return j.arithmeticCommand(a,l,t.line)}parseConditionalCommand(){let t=this.expect(x.DBRACK_START),n=Ra(this);this.expect(x.DBRACK_END);let r=this.parseOptionalRedirections();return j.conditionalCommand(n,r,t.line)}parseFunctionDef(){let t;if(this.check(x.FUNCTION)){if(this.advance(),this.check(x.NAME)||this.check(x.WORD))t=this.advance().value;else{let s=this.current();throw new Ge("Expected function name",s.line,s.column,s)}this.check(x.LPAREN)&&(this.advance(),this.expect(x.RPAREN))}else t=this.advance().value,t.includes("$")&&this.error(`\`${t}': not a valid identifier`),this.expect(x.LPAREN),this.expect(x.RPAREN);this.skipNewlines();let n=this.parseCompoundCommandBody({forFunctionBody:!0}),r=this.parseOptionalRedirections();return j.functionDef(t,n,r)}parseCompoundCommandBody(t){let n=t?.forFunctionBody;if(this.check(x.LBRACE))return $a(this,{skipRedirections:n});if(this.check(x.LPAREN))return va(this,{skipRedirections:n});if(this.check(x.IF))return Sa(this,{skipRedirections:n});if(this.check(x.FOR))return Aa(this,{skipRedirections:n});if(this.check(x.WHILE))return Ca(this,{skipRedirections:n});if(this.check(x.UNTIL))return Na(this,{skipRedirections:n});if(this.check(x.CASE))return ka(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let t=[];for(this.skipNewlines();!this.check(x.EOF,x.FI,x.ELSE,x.ELIF,x.THEN,x.DO,x.DONE,x.ESAC,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,r=this.parseStatement();if(r&&t.push(r),this.skipSeparators(),this.pos===n&&!r)break}return t}parseOptionalRedirections(){let t=[];for(;Xs(this);){this.checkIterationLimit();let n=this.pos;if(t.push(Js(this)),this.pos===n)break}return t}parseArithmeticExpression(t){return he(this,t)}}});function Da(e){return DC[e]||""}function eg(e){let t=[],n="",r=0;for(;r<e.length;){let s=e[r];if(s==="["){for(n+=s,r++,r<e.length&&(e[r]==="!"||e[r]==="^")&&(n+=e[r],r++),r<e.length&&e[r]==="]"&&(n+=e[r],r++);r<e.length&&e[r]!=="]";){if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let i=e.indexOf(":]",r+2);if(i!==-1){n+=e.slice(r,i+2),r=i+2;continue}}if(e[r]==="\\"&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]==="]"&&(n+=e[r],r++)}else s===":"?(n!==""&&t.push(n),n="",r++):s==="\\"&&r+1<e.length?(n+=s+e[r+1],r+=2):(n+=s,r++)}return n!==""&&t.push(n),t}function tg(e){let t="^";for(let n=0;n<e.length;n++){let r=e[n];if(r==="*")t+="[^/]*";else if(r==="?")t+="[^/]";else if(r==="["){let s=n+1,i="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(i+="^",s++),s<e.length&&e[s]==="]"&&(i+="\\]",s++);let o=s;for(;o<e.length;){if(e[o]==="\\"&&o+1<e.length){o+=2;continue}if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let l=e.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(e[o]==="]")break;o++}let a=s;for(;s<e.length&&e[s]!=="]";){if(e[s]==="["&&s+1<e.length&&e[s+1]===":"){let l=e.indexOf(":]",s+2);if(l!==-1){let c=e.slice(s+2,l),u=Da(c);i+=u,s=l+2;continue}}if(e[s]==="\\"&&s+1<e.length){i+=`\\${e[s+1]}`,s+=2;continue}if(e[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=e[s];s++}i+="]",t+=i,n=s}else if(r==="\\"&&n+1<e.length){let s=e[n+1];/[.+^${}()|\\*?[\]]/.test(s)?t+=`\\${s}`:t+=s,n++}else/[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+="$",new RegExp(t)}function Fa(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function _a(e){let t=[],n="",r=0,s=!1,i=0;for(;i<e.length;){let o=e[i];if(o==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=o,i++;continue}if(o==="\\"){n+=o,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}o==="("?(r++,n+=o):o===")"?(r--,n+=o):o==="|"&&r===0?(t.push(n),n=""):n+=o,i++}return t.push(n),t}var DC,ng=v(()=>{"use strict";DC={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"}});var rn,Ys=v(()=>{"use strict";Pn();ng();rn=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;constructor(t,n,r,s){this.fs=t,this.cwd=n,typeof s=="boolean"?this.globstar=s:s&&(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0);let i=r?.GLOBIGNORE;i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=eg(i))}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(n=>{let r=n.split("/").pop()||n;if((this.hasGlobignore||this.globskipdots)&&(r==="."||r===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(n,s))return!1}return!0})}matchGlobignorePattern(t,n){return tg(n).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,n){let r=t.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<t.length;o++){let a=s[o];a===null?i.push(t[o]):a.length>0?i.push(...a):i.push(t[o])}return i}async expand(t){let n;if(t.includes("**")&&this.globstar&&this.isGlobstarValid(t))n=await this.expandRecursive(t);else{let r=t.replace(/\*\*+/g,"*");n=await this.expandSimple(r)}return this.filterGlobignore(n)}isGlobstarValid(t){let n=t.split("/");for(let r of n)if(r.includes("**")&&r!=="**")return!1;return!0}hasGlobChars(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandSimple(t){let n=t.startsWith("/"),r=t.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<r.length;c++)if(this.hasGlobChars(r[c])){s=c;break}if(s===-1)return[t];let i,o;if(s===0)n?(i="/",o="/"):(i=this.cwd,o="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=r.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(t,n,r){if(r.length===0)return[n];let[s,...i]=r,o=[];try{if(this.fs.readdirWithFileTypes){let a=await this.fs.readdirWithFileTypes(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let p=a.some(m=>m.name==="."),d=a.some(m=>m.name==="..");p||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let p of c)if(!(p.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p.name,s)){let d=t==="/"?`/${p.name}`:`${t}/${p.name}`,m;n===""?m=p.name:n==="/"?m=`/${p.name}`:m=`${n}/${p.name}`,i.length===0?l.push(Promise.resolve([m])):p.isDirectory&&l.push(this.expandSegments(d,m,i))}let f=await Promise.all(l);for(let p of f)o.push(...p)}else{let a=await this.fs.readdir(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let p of c)if(!(p.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p,s)){let d=t==="/"?`/${p}`:`${t}/${p}`,m;n===""?m=p:n==="/"?m=`/${p}`:m=`${n}/${p}`,i.length===0?l.push(Promise.resolve([m])):l.push((async()=>{try{if((await this.fs.stat(d)).isDirectory)return this.expandSegments(d,m,i)}catch{}return[]})())}let f=await Promise.all(l);for(let p of f)o.push(...p)}}catch{}return o}async expandRecursive(t){let n=[],r=t.indexOf("**"),s=t.slice(0,r).replace(/\/$/,"")||".",o=t.slice(r+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,n),[...new Set(n)].sort()):(await this.walkDirectory(s,o,n),n.sort())}async walkDirectoryMultiGlobstar(t,n,r){let s=this.fs.resolvePath(this.cwd,t);try{let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&o.push(u)}let a=t==="."?n:`${t}/${n}`,l=await this.expandRecursive(a);r.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{let o=await this.fs.readdir(s),a=[];for(let u of o){let f=t==="."?u:`${t}/${u}`,p=this.fs.resolvePath(this.cwd,f);try{(await this.fs.stat(p)).isDirectory&&a.push(f)}catch{}}let l=t==="."?n:`${t}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(p=>this.walkDirectoryMultiGlobstar(p,n,r)))}}}catch{}}async walkDirectory(t,n,r){let s=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=t==="."?l.name:`${t}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,n,r)))}}else{let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let p=t==="."?f:`${t}/${f}`,d=this.fs.resolvePath(this.cwd,p);try{let m=await this.fs.stat(d);return{name:f,path:p,isDirectory:m.isDirectory}}catch{return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch{}}matchPattern(t,n){return this.patternToRegex(n).test(t)}patternToRegex(t){let n=this.patternToRegexStr(t);return new RegExp(`^${n}$`)}patternToRegexStr(t){let n="",r=!1;for(let s=0;s<t.length;s++){if(t.slice(s,s+13)==="\0QUOTE_START\0"){r=!0,s+=12;continue}if(t.slice(s,s+11)==="\0QUOTE_END\0"){r=!1,s+=10;continue}let i=t[s];if(r){/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<t.length&&t[s+1]==="("){let o=Fa(t,s+1);if(o!==-1){let a=t.slice(s+2,o),l=_a(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")n+=`(?:${u})`;else if(i==="*")n+=`(?:${u})*`;else if(i==="+")n+=`(?:${u})+`;else if(i==="?")n+=`(?:${u})?`;else if(i==="!")if(o<t.length-1){let p=l.map(m=>this.computePatternLength(m));if(p.every(m=>m!==null)&&p.every(m=>m===p[0])&&p[0]!==null){let m=p[0];if(m===0)n+="(?:.+)";else{let h=[];m>0&&h.push(`.{0,${m-1}}`),h.push(`.{${m+1},}`),h.push(`(?!(?:${u})).{${m}}`),n+=`(?:${h.join("|")})`}}else n+=`(?:(?!(?:${u})).)*?`}else n+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let o=s+1,a="[";o<t.length&&(t[o]==="^"||t[o]==="!")&&(a+="^",o++),o<t.length&&t[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<t.length;){if(t[l]==="\\"&&l+1<t.length){l+=2;continue}if(t[l]==="["&&l+1<t.length&&t[l+1]===":"){let u=t.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(t[l]==="]")break;l++}let c=o;for(;o<t.length&&t[o]!=="]";){if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let u=t.indexOf(":]",o+2);if(u!==-1){let f=t.slice(o+2,u),p=Da(f);a+=p,o=u+2;continue}}if(t[o]==="\\"&&o+1<t.length){a+=`\\${t[o+1]}`,o+=2;continue}if(t[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=t[o];o++}a+="]",n+=a,s=o}else if(i==="\\"&&s+1<t.length){let o=t[s+1];/[.+^${}()|\\*?[\]]/.test(o)?n+=`\\${o}`:n+=o,s++}else/[.+^${}()|]/.test(i)?n+=`\\${i}`:n+=i}return n}computePatternLength(t){let n=0,r=0,s=!1;for(;r<t.length;){if(t.slice(r,r+13)==="\0QUOTE_START\0"){s=!0,r+=13;continue}if(t.slice(r,r+11)==="\0QUOTE_END\0"){s=!1,r+=11;continue}let i=t[r];if(s){n+=1,r++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&r+1<t.length&&t[r+1]==="("){let o=Fa(t,r+1);if(o!==-1){if(i==="@"){let a=t.slice(r+2,o),c=_a(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let o=t.indexOf("]",r+1);if(o!==-1){n+=1,r=o+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function La(e){for(let t=0;t<e.length;t++){if(e[t]==="\\"){t++;continue}if(e[t]==="$"){let n=e[t+1];if(n==="{"||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function FC(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function rg(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n||n.length===0)return!1;for(let r of n)if(r.type!=="DoubleQuoted"&&r.type!=="SingleQuoted")return!1;return!0}function Lr(e){let t=!1,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1;for(let l of e){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(t=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),FC(l)&&(t=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&La(l.pattern)&&(i=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var ei=v(()=>{"use strict"});function _e(e,t){let n=`${t}_`,r=[];for(let s of Object.keys(e.state.env))if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function Ut(e,t){let n=`${t}_`;for(let r of Object.keys(e.state.env))r.startsWith(n)&&delete e.state.env[r]}function Pt(e,t){let n=`${t}_`,r=`${t}__length`,s=[];for(let i of Object.keys(e.state.env))if(i!==r&&i.startsWith(n)){let o=i.slice(n.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function ti(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Ma(e){if(e.parts.length<2)return null;let t=e.parts[0],n=e.parts[1];if(t.type!=="Glob"||!t.pattern.startsWith("["))return null;let r,s=n,i=1;if(n.type==="Literal"&&n.value.startsWith("]")){let f=n.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))r=t.pattern.slice(1);else if(f===""){if(e.parts.length<3)return null;let p=e.parts[2];if(p.type!=="Literal"||!p.value.startsWith("=")&&!p.value.startsWith("+="))return null;r=t.pattern.slice(1),s=p,i=2}else return null}else if(t.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(e.parts.length<3)return null;let f=e.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(n.type==="SingleQuoted")r=n.value;else{r="";for(let p of n.parts)(p.type==="Literal"||p.type==="Escaped")&&(r+=p.value)}s=f,i=2}else if(t.pattern.endsWith("]")){if(n.type!=="Literal"||!n.value.startsWith("=")&&!n.value.startsWith("+="))return null;r=t.pattern.slice(1,-1)}else return null;r=ti(r);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<e.parts.length;f++){let p=e.parts[f];p.type==="BraceExpansion"?l.push({type:"Literal",value:_C(p)}):l.push(p)}return{key:r,valueParts:l,append:a}}function _C(e){return`{${e.items.map(n=>{if(n.type==="Range"){let r=n.startStr??String(n.start),s=n.endStr??String(n.end),i=`${r}..${s}`;return n.step&&(i+=`..${n.step}`),i}return Yn(n.word)}).join(",")}}`}function Yn(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value;break;case"Glob":t+=n.pattern;break;case"SingleQuoted":t+=n.value;break;case"DoubleQuoted":for(let r of n.parts)(r.type==="Literal"||r.type==="Escaped")&&(t+=r.value);break;case"Escaped":t+=n.value;break;case"BraceExpansion":t+="{",t+=n.items.map(r=>r.type==="Range"?`${r.startStr}..${r.endStr}${r.step?`..${r.step}`:""}`:Yn(r.word)).join(","),t+="}";break;case"TildeExpansion":t+="~",n.user&&(t+=n.user);break}return t}var $t=v(()=>{"use strict"});function Ue(e){return e.IFS??`
750
750
  `}function Ze(e){return e.IFS===""}function ni(e){let t=Ue(e);if(t==="")return!0;for(let n of t)if(n!==" "&&n!==" "&&n!==`
751
751
  `)return!1;return!0}function sg(e){return e.split("").map(t=>/[\\^$.*+?()[\]{}|-]/.test(t)?`\\${t}`:t===" "?"\\t":t===`
752
752
  `?"\\n":t).join("")}function oe(e){let t=e.IFS;return t===void 0?" ":t[0]||""}function MC(e){return LC.includes(e)}function Wa(e){let t=new Set,n=new Set;for(let r of e)MC(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function Ba(e,t,n,r){if(t==="")return e===""?{words:[],wordStarts:[]}:{words:[e],wordStarts:[0]};let{whitespace:s,nonWhitespace:i}=Wa(t),o=[],a=[],l=0;for(;l<e.length&&s.has(e[l]);)l++;if(l>=e.length)return{words:[],wordStarts:[]};if(i.has(e[l]))for(o.push(""),a.push(l),l++;l<e.length&&s.has(e[l]);)l++;for(;l<e.length&&!(n!==void 0&&o.length>=n);){let c=l;for(a.push(c);l<e.length;){let u=e[l];if(!r&&u==="\\"){l++,l<e.length&&l++;continue}if(s.has(u)||i.has(u))break;l++}if(o.push(e.substring(c,l)),l>=e.length)break;for(;l<e.length&&s.has(e[l]);)l++;if(l<e.length&&i.has(e[l])){for(l++;l<e.length&&s.has(e[l]);)l++;for(;l<e.length&&i.has(e[l])&&!(n!==void 0&&o.length>=n);)for(o.push(""),a.push(l),l++;l<e.length&&s.has(e[l]);)l++}}return{words:o,wordStarts:a}}function ri(e,t){if(t==="")return{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e==="")return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:n,nonWhitespace:r}=Wa(t),s=[],i=0,o=!1,a=!1,l=i;for(;i<e.length&&n.has(e[i]);)i++;if(i>l&&(o=!0),i>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(r.has(e[i]))for(s.push(""),i++;i<e.length&&n.has(e[i]);)i++;for(;i<e.length;){let c=i;for(;i<e.length;){let f=e[i];if(n.has(f)||r.has(f))break;i++}if(s.push(e.substring(c,i)),i>=e.length){a=!1;break}let u=i;for(;i<e.length&&n.has(e[i]);)i++;if(i<e.length&&r.has(e[i])){for(i++;i<e.length&&n.has(e[i]);)i++;for(;i<e.length&&r.has(e[i]);)for(s.push(""),i++;i<e.length&&n.has(e[i]);)i++}i>=e.length&&i>u&&(a=!0)}return{words:s,hadLeadingDelimiter:o,hadTrailingDelimiter:a}}function Ae(e,t){return ri(e,t).words}function WC(e,t){for(let n of e)if(t.has(n))return!0;return!1}function ig(e,t,n){if(t==="")return e;let{whitespace:r,nonWhitespace:s}=Wa(t),i=e.length;for(;i>0&&r.has(e[i-1]);){if(!n&&i>=2){let a=0,l=i-2;for(;l>=0&&e[l]==="\\";)a++,l--;if(a%2===1)break}i--}let o=e.substring(0,i);if(o.length>=1&&s.has(o[o.length-1])){if(!n&&o.length>=2){let l=0,c=o.length-2;for(;c>=0&&o[c]==="\\";)l++,c--;if(l%2===1)return o}let a=o.substring(0,o.length-1);if(!WC(a,s))return a}return o}var LC,St=v(()=>{"use strict";LC=`
753
753
  `});function Se(e,t){return e.state.namerefs?.has(t)??!1}function Zt(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function og(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function ag(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function lg(e,t){return e.state.invalidNamerefs?.has(t)??!1}function Ua(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function si(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let s=n[1],i=Object.keys(e.state.env).some(a=>a.startsWith(`${s}_`)&&!a.includes("__")),o=e.state.associativeArrays?.has(s)??!1;return i||o}return Object.keys(e.state.env).some(s=>s.startsWith(`${t}_`)&&!s.includes("__"))?!0:e.state.env[t]!==void 0}function st(e,t,n=100){if(!Se(e,t)||lg(e,t))return t;let r=new Set,s=t;for(;n-- >0;){if(r.has(s))return;if(r.add(s),!Se(e,s))return s;let i=e.state.env[s];if(i===void 0||i===""||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i))return s;s=i}}function kn(e,t){if(Se(e,t))return e.state.env[t]}function cg(e,t,n,r=100){if(!Se(e,t)||lg(e,t))return t;let s=new Set,i=t;for(;r-- >0;){if(s.has(i))return;if(s.add(i),!Se(e,i))return i;let o=e.state.env[i];if(o===void 0||o==="")return n!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&si(e,n)?i:null:i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(o))return i;i=o}}var Tt=v(()=>{"use strict"});function BC(e,t){let n=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(r,s)=>e.state.env[s]??"");return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(r,s)=>e.state.env[s]??""),n}function te(e,t){return t==="FUNCNAME"?(e.state.funcNameStack??[]).map((i,o)=>[o,i]):t==="BASH_LINENO"?(e.state.callLineStack??[]).map((i,o)=>[o,String(i)]):t==="BASH_SOURCE"?(e.state.sourceStack??[]).map((i,o)=>[o,i]):e.state.associativeArrays?.has(t)?Pt(e,t).map(i=>[i,e.state.env[`${t}_${i}`]]):_e(e,t).map(s=>[s,e.state.env[`${t}_${s}`]])}function Qt(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)?Pt(e,t).length>0:_e(e,t).length>0}async function me(e,t,n=!0,r=!1){switch(t){case"?":return String(e.state.lastExitCode);case"$":return String(process.pid);case"#":return e.state.env["#"]||"0";case"@":return e.state.env["@"]||"";case"_":return e.state.lastArg;case"-":{let o="";return o+="h",e.state.options.errexit&&(o+="e"),e.state.options.noglob&&(o+="f"),e.state.options.nounset&&(o+="u"),e.state.options.verbose&&(o+="v"),e.state.options.xtrace&&(o+="x"),o+="B",e.state.options.noclobber&&(o+="C"),o+="s",o}case"*":{let o=Number.parseInt(e.state.env["#"]||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(e.state.env[String(l)]||"");return a.join(oe(e.state.env))}case"0":return e.state.env[0]||"bash";case"PWD":return e.state.env.PWD!==void 0?e.state.env.PWD:"";case"OLDPWD":return e.state.env.OLDPWD!==void 0?e.state.env.OLDPWD:"";case"PPID":{let{ppid:o}=Dr();return String(o)}case"UID":{let{uid:o}=Dr();return String(o)}case"EUID":return String(process.geteuid?.()??Dr().uid);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 rm;case"!":return String(e.state.lastBackgroundPid);case"BASHPID":return String(e.state.bashPid);case"LINENO":return String(e.state.currentLine);case"FUNCNAME":{let o=e.state.funcNameStack?.[0];if(o!==void 0)return o;if(n&&e.state.options.nounset)throw new tt("FUNCNAME");return""}case"BASH_LINENO":{let o=e.state.callLineStack?.[0];if(o!==void 0)return String(o);if(n&&e.state.options.nounset)throw new tt("BASH_LINENO");return""}case"BASH_SOURCE":{let o=e.state.sourceStack?.[0];if(o!==void 0)return o;if(n&&e.state.options.nounset)throw new tt("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new nt(`\${${t}}`);let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(Se(e,o)){let f=st(e,o);if(f&&f!==o){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return"";o=f}}if(a==="@"||a==="*"){let f=te(e,o);if(f.length>0)return f.map(([,d])=>d).join(" ");let p=e.state.env[o];return p!==void 0?p:""}if(o==="FUNCNAME"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?e.state.funcNameStack?.[f]??"":""}if(o==="BASH_LINENO"){let f=Number.parseInt(a,10);if(!Number.isNaN(f)&&f>=0){let p=e.state.callLineStack?.[f];return p!==void 0?String(p):""}return""}if(o==="BASH_SOURCE"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?e.state.sourceStack?.[f]??"":""}if(e.state.associativeArrays?.has(o)){let f=ti(a);f=BC(e,f);let p=e.state.env[`${o}_${f}`];if(p===void 0&&n&&e.state.options.nounset)throw new tt(`${o}[${a}]`);return p||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new se,p=he(f,a);c=await Q(e,p.expression)}catch{let f=e.state.env[a];c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=te(e,o),p=e.state.currentLine;if(f.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${p}: ${o}: bad array subscript
754
754
  `,"";let m=Math.max(...f.map(([g])=>typeof g=="number"?g:0))+1+c;return m<0?(e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${p}: ${o}: bad array subscript
755
755
  `,""):e.state.env[`${o}_${m}`]||""}let u=e.state.env[`${o}_${c}`];if(u!==void 0)return u;if(c===0){let f=e.state.env[o];if(f!==void 0)return f}if(n&&e.state.options.nounset)throw new tt(`${o}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let o=e.state.env[t];if(o===void 0&&n&&e.state.options.nounset)throw new tt(t);return o||""}if(Se(e,t)){let o=st(e,t);if(o===void 0)return"";if(o!==t)return await me(e,o,n,r);let a=e.state.env[t];if((a===void 0||a==="")&&n&&e.state.options.nounset)throw new tt(t);return a||""}let i=e.state.env[t];if(i!==void 0)return e.state.tempEnvBindings?.some(o=>o.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),i;if(Qt(e,t)){let o=e.state.env[`${t}_0`];return o!==void 0?o:""}if(n&&e.state.options.nounset)throw new tt(t);return""}async function zt(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["#"]||"0",10)>0;if(t==="PWD"||t==="OLDPWD")return t in e.state.env;let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let s=r[1],i=r[2];if(Se(e,s)){let l=st(e,s);if(l&&l!==s){if(l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;s=l}}if(i==="@"||i==="*")return te(e,s).length>0?!0:s in e.state.env;if(e.state.associativeArrays?.has(s)){let l=ti(i);return`${s}_${l}`in e.state.env}let a;if(/^-?\d+$/.test(i))a=Number.parseInt(i,10);else try{let l=new se,c=he(l,i);a=await Q(e,c.expression)}catch{let l=e.state.env[i];a=l?Number.parseInt(l,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let l=te(e,s);if(l.length===0)return!1;let u=Math.max(...l.map(([f])=>typeof f=="number"?f:0))+1+a;return u<0?!1:`${s}_${u}`in e.state.env}return`${s}_${a}`in e.state.env}if(Se(e,t)){let s=st(e,t);return s===void 0||s===t?t in e.state.env:zt(e,s)}return!!(t in e.state.env||Qt(e,t))}var ht=v(()=>{"use strict";Je();Fe();ca();it();de();$t();St();Tt()});async function ug(e,t){let n="",r=0;for(;r<t.length;){if(t[r]==="$"){if(t[r+1]==="{"){let s=1,i=r+2;for(;i<t.length&&s>0;)t[i]==="{"?s++:t[i]==="}"&&s--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]==="("){let s=1,i=r+2;for(;i<t.length&&s>0;)t[i]==="("?s++:t[i]===")"&&s--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await me(e,i);n+=o,r=s;continue}if(/[0-9]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[0-9]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await me(e,i);n+=o,r=s;continue}if(/[*@#?\-!$]/.test(t[r+1]||"")){let s=t[r+1],i=await me(e,s);n+=i,r+=2;continue}}if(t[r]==='"'){for(n+='"',r++;r<t.length&&t[r]!=='"';)if(t[r]==="$"&&/[a-zA-Z_]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await me(e,i);n+=o,r=s}else t[r]==="\\"?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+='"',r++);continue}n+=t[r],r++}return n}async function za(e,t){let n=t,r=t.startsWith('"')&&t.endsWith('"'),s=t.startsWith("'")&&t.endsWith("'");if((r||s)&&(n=t.slice(1,-1)),s)return n;let i="",o=0;for(;o<n.length;)if(n[o]==="$")if(n[o+1]==="("){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="("&&n[l-1]==="$"||n[l]==="("?a++:n[l]===")"&&a--,l++;let c=n.slice(o+2,l-1);if(e.execFn){let u=await e.execFn(c);i+=u.stdout.replace(/\n+$/,""),u.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+u.stderr)}o=l}else if(n[o+1]==="{"){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="{"?a++:n[l]==="}"&&a--,l++;let c=n.slice(o+2,l-1),u=await me(e,c);i+=u,o=l}else if(/[a-zA-Z_]/.test(n[o+1]||"")){let a=o+1;for(;a<n.length&&/[a-zA-Z0-9_]/.test(n[a]);)a++;let l=n.slice(o+1,a),c=await me(e,l);i+=c,o=a}else i+=n[o],o++;else if(n[o]==="`"){let a=o+1;for(;a<n.length&&n[a]!=="`";)a++;let l=n.slice(o+1,a);if(e.execFn){let c=await e.execFn(l);i+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}o=a+1}else i+=n[o],o++;return i}var fg=v(()=>{"use strict";ht()});function UC(e,t,n,r,s){let i=n??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,p=String(Math.abs(u)).padStart(l,"0");return f?`-${p}`:p}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<ii;u+=o,f++)a.push(c(u));else for(let u=e,f=0;u>=t&&f<ii;u-=o,f++)a.push(c(u));return a}function zC(e,t,n){let r=n??1;r===0&&(r=1);let s=e.charCodeAt(0),i=t.charCodeAt(0),o=Math.abs(r),a=e>="A"&&e<="Z",l=e>="a"&&e<="z",c=t>="A"&&t<="Z",u=t>="a"&&t<="z";if(a&&u||l&&c){let p=n!==void 0?`..${n}`:"";throw new Fn(`{${e}..${t}${p}}: invalid sequence`)}let f=[];if(s<=i)for(let p=s,d=0;p<=i&&d<ii;p+=o,d++)f.push(String.fromCharCode(p));else for(let p=s,d=0;p>=i&&d<ii;p-=o,d++)f.push(String.fromCharCode(p));return f}function ja(e,t,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:UC(e,t,n,r,s),literal:`{${e}..${t}${i}}`}:typeof e=="string"&&typeof t=="string"?{expanded:zC(e,t,n),literal:`{${e}..${t}${i}}`}:{expanded:null,literal:`{${e}..${t}${i}}`}}var ii,pg=v(()=>{"use strict";de();ii=1e4});function dg(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!=="SimpleCommand")return null;let s=r;if(s.name!==null||s.args.length!==0||s.assignments.length!==0||s.redirections.length!==1)return null;let i=s.redirections[0];return i.operator!=="<"||i.target.type!=="Word"?null:{target:i.target}}var hg=v(()=>{"use strict"});function jt(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function Ha(e){let t="",n=0;for(;n<e.length;)e[n]==="\\"&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function mt(e){return e.replace(/([*?[\]\\()|])/g,"\\$1")}function er(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}var tr=v(()=>{"use strict"});function pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nr=v(()=>{"use strict"});function ce(e,t,n=!1){let r="",s=0;for(;s<e.length;){let i=e[s];if(n&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<e.length&&e[s+1]==="("){let o=jC(e,s+1);if(o!==-1){let a=e.slice(s+2,o),c=HC(a).map(f=>ce(f,t,n)),u=c.length>0?c.join("|"):"(?:)";i==="@"?r+=`(?:${u})`:i==="*"?r+=`(?:${u})*`:i==="+"?r+=`(?:${u})+`:i==="?"?r+=`(?:${u})?`:i==="!"&&(r+=`(?!(?:${u})$).*`),s=o+1;continue}}if(i==="\\")if(s+1<e.length){let o=e[s+1];/[\\^$.|+(){}[\]*?]/.test(o)?r+=`\\${o}`:r+=o,s+=2}else r+="\\\\",s++;else if(i==="*")r+=t?".*":".*?",s++;else if(i==="?")r+=".",s++;else if(i==="["){let o=VC(e,s);if(o===-1)r+="\\[",s++;else{let a=e.slice(s+1,o);r+=qC(a),s=o+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function jC(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function HC(e){let t=[],n="",r=0,s=0;for(;s<e.length;){let i=e[s];if(i==="\\"){n+=i,s+1<e.length?(n+=e[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(t.push(n),n=""):n+=i,s++}return t.push(n),t}function VC(e,t){let n=t+1;for(n<e.length&&e[n]==="^"&&n++,n<e.length&&e[n]==="]"&&n++;n<e.length;){if(e[n]==="\\"&&n+1<e.length){n+=2;continue}if(e[n]==="]")return n;if(e[n]==="'"){let r=e.indexOf("'",n+1);if(r!==-1){n=r+1;continue}}if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let r=e.indexOf(":]",n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function qC(e){let t="[",n=0;for((e[0]==="^"||e[0]==="!")&&(t+="^",n++);n<e.length;){if(e[n]==="'"){let s=e.indexOf("'",n+1);if(s!==-1){let i=e.slice(n+1,s);for(let o of i)o==="\\"?t+="\\\\":o==="]"?t+="\\]":o==="^"&&t==="["?t+="\\^":t+=o;n=s+1;continue}}if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let s=e.indexOf(":]",n+2);if(s!==-1){let i=e.slice(n+2,s);t+=ZC(i),n=s+2;continue}}let r=e[n];r==="\\"?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+="\\\\",n++):r==="-"&&n>0&&n<e.length-1?(t+="-",n++):r==="^"&&n===0?(t+="^",n++):(r==="]"&&n===0?t+="\\]":t+=r,n++)}return t+="]",t}function ZC(e){return GC[e]??""}var GC,rr=v(()=>{"use strict";GC={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 Kt(e,t,n,r){if(n==="prefix")return e.replace(new RegExp(`^${t}`,"s"),"");let s=new RegExp(`${t}$`,"s");if(r)return e.replace(s,"");for(let i=e.length;i>=0;i--){let o=e.slice(i);if(s.test(o))return e.slice(0,i)}return e}function sr(e,t){let n=Object.keys(e.state.env),r=new Set,s=e.state.associativeArrays??new Set,i=new Set;for(let a of n){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l&&i.add(l[1]);let c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&i.add(c[1])}let o=a=>{for(let l of s){let c=`${l}_`;if(a.startsWith(c)&&a!==l)return!0}return!1};for(let a of n)if(a.startsWith(t))if(a.includes("__")){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);l?.[1].startsWith(t)&&r.add(l[1])}else if(/_\d+$/.test(a)){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l?.[1].startsWith(t)&&r.add(l[1])}else o(a)||r.add(a);return[...r].sort()}var vn=v(()=>{"use strict"});function QC(e,t){let n=(i,o=2)=>String(i).padStart(o,"0");if(e===""){let i=n(t.getHours()),o=n(t.getMinutes()),a=n(t.getSeconds());return`${i}:${o}:${a}`}let r="",s=0;for(;s<e.length;)if(e[s]==="%"){if(s+1>=e.length){r+="%",s++;continue}let i=e[s+1];switch(i){case"H":r+=n(t.getHours());break;case"M":r+=n(t.getMinutes());break;case"S":r+=n(t.getSeconds());break;case"d":r+=n(t.getDate());break;case"m":r+=n(t.getMonth()+1);break;case"Y":r+=t.getFullYear();break;case"y":r+=n(t.getFullYear()%100);break;case"I":{let o=t.getHours()%12;o===0&&(o=12),r+=n(o);break}case"p":r+=t.getHours()<12?"AM":"PM";break;case"P":r+=t.getHours()<12?"am":"pm";break;case"%":r+="%";break;case"a":{r+=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()];break}case"b":{r+=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()];break}default:r+=`%${i}`}s+=2}else r+=e[s],s++;return r}function Mr(e,t){let n="",r=0,s=e.state.env.USER||e.state.env.LOGNAME||"user",i=e.state.env.HOSTNAME||"localhost",o=i.split(".")[0],a=e.state.env.PWD||"/",l=e.state.env.HOME||"/",c=a.startsWith(l)?`~${a.slice(l.length)}`:a,u=a.split("/").pop()||a,f=new Date,p=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=e.state.env.__COMMAND_NUMBER||"1";for(;r<t.length;){let h=t[r];if(h==="\\"){if(r+1>=t.length){n+="\\",r++;continue}let g=t[r+1];if(g>="0"&&g<="7"){let b="",y=r+1;for(;y<t.length&&y<r+4&&t[y]>="0"&&t[y]<="7";)b+=t[y],y++;let w=Number.parseInt(b,8)%256;n+=String.fromCharCode(w),r=y;continue}switch(g){case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"e":n+="\x1B",r+=2;break;case"n":n+=`
756
- `,r+=2;break;case"r":n+="\r",r+=2;break;case"$":n+="$",r+=2;break;case"[":case"]":r+=2;break;case"u":n+=s,r+=2;break;case"h":n+=o,r+=2;break;case"H":n+=i,r+=2;break;case"w":n+=c,r+=2;break;case"W":n+=u,r+=2;break;case"d":{let b=String(f.getDate()).padStart(2," ");n+=`${p[f.getDay()]} ${d[f.getMonth()]} ${b}`,r+=2;break}case"t":{let b=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0"),w=String(f.getSeconds()).padStart(2,"0");n+=`${b}:${y}:${w}`,r+=2;break}case"T":{let b=f.getHours()%12;b===0&&(b=12);let y=String(b).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0"),E=String(f.getSeconds()).padStart(2,"0");n+=`${y}:${w}:${E}`,r+=2;break}case"@":{let b=f.getHours()%12;b===0&&(b=12);let y=String(b).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0"),E=f.getHours()<12?"AM":"PM";n+=`${y}:${w} ${E}`,r+=2;break}case"A":{let b=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0");n+=`${b}:${y}`,r+=2;break}case"D":if(r+2<t.length&&t[r+2]==="{"){let b=t.indexOf("}",r+3);if(b!==-1){let y=t.slice(r+3,b);n+=QC(y,f),r=b+1}else n+="\\D",r+=2}else n+="\\D",r+=2;break;case"s":n+="bash",r+=2;break;case"v":n+="5.0",r+=2;break;case"V":n+="5.0.0",r+=2;break;case"j":n+="0",r+=2;break;case"l":n+="tty",r+=2;break;case"#":n+=m,r+=2;break;case"!":n+=m,r+=2;break;case"x":n+="\\x",r+=2;break;default:n+=`\\${g}`,r+=2}}else n+=h,r++}return n}var Va=v(()=>{"use strict"});function rn(e){if(e==="")return"''";if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let n="$'";for(let r of e)switch(r){case"'":n+="\\'";break;case"\\":n+="\\\\";break;case`
756
+ `,r+=2;break;case"r":n+="\r",r+=2;break;case"$":n+="$",r+=2;break;case"[":case"]":r+=2;break;case"u":n+=s,r+=2;break;case"h":n+=o,r+=2;break;case"H":n+=i,r+=2;break;case"w":n+=c,r+=2;break;case"W":n+=u,r+=2;break;case"d":{let b=String(f.getDate()).padStart(2," ");n+=`${p[f.getDay()]} ${d[f.getMonth()]} ${b}`,r+=2;break}case"t":{let b=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0"),w=String(f.getSeconds()).padStart(2,"0");n+=`${b}:${y}:${w}`,r+=2;break}case"T":{let b=f.getHours()%12;b===0&&(b=12);let y=String(b).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0"),E=String(f.getSeconds()).padStart(2,"0");n+=`${y}:${w}:${E}`,r+=2;break}case"@":{let b=f.getHours()%12;b===0&&(b=12);let y=String(b).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0"),E=f.getHours()<12?"AM":"PM";n+=`${y}:${w} ${E}`,r+=2;break}case"A":{let b=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0");n+=`${b}:${y}`,r+=2;break}case"D":if(r+2<t.length&&t[r+2]==="{"){let b=t.indexOf("}",r+3);if(b!==-1){let y=t.slice(r+3,b);n+=QC(y,f),r=b+1}else n+="\\D",r+=2}else n+="\\D",r+=2;break;case"s":n+="bash",r+=2;break;case"v":n+="5.0",r+=2;break;case"V":n+="5.0.0",r+=2;break;case"j":n+="0",r+=2;break;case"l":n+="tty",r+=2;break;case"#":n+=m,r+=2;break;case"!":n+=m,r+=2;break;case"x":n+="\\x",r+=2;break;default:n+=`\\${g}`,r+=2}}else n+=h,r++}return n}var Va=v(()=>{"use strict"});function sn(e){if(e==="")return"''";if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let n="$'";for(let r of e)switch(r){case"'":n+="\\'";break;case"\\":n+="\\\\";break;case`
757
757
  `:n+="\\n";break;case"\r":n+="\\r";break;case" ":n+="\\t";break;default:{let s=r.charCodeAt(0);s<32||s===127?n+=`\\${s.toString(8).padStart(3,"0")}`:n+=r}}return`${n}'`}return`'${e}'`}var qa=v(()=>{"use strict"});function gt(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function Ht(e,t){return e.state.readonlyVars?.has(t)??!1}function je(e,t,n="bash"){if(Ht(e,t)){let r=`${n}: ${t}: readonly variable
758
- `;throw new ae(1,"",r)}return null}function Ot(e,t){let n=e.state.exportedVars?.has(t)??!1;if(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t),e.state.localScopes.length>0&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!n){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length<e.state.localScopes.length;)e.state.localExportedVars.push(new Set);e.state.localExportedVars[e.state.localExportedVars.length-1].add(t)}}function oi(e,t){e.state.exportedVars?.delete(t)}var sn=v(()=>{"use strict";de()});function on(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return"";let n="",r=e.state.env[`${t}__length`]!==void 0||Object.keys(e.state.env).some(i=>i.startsWith(`${t}_`)&&/^[0-9]+$/.test(i.slice(t.length+1))),s=e.state.associativeArrays?.has(t)??!1;return r&&!s&&(n+="a"),s&&(n+="A"),e.state.integerVars?.has(t)&&(n+="i"),Se(e,t)&&(n+="n"),Ht(e,t)&&(n+="r"),e.state.exportedVars?.has(t)&&(n+="x"),n}var ai=v(()=>{"use strict";Tt();sn()});async function mg(e,t,n,r){return(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function gg(e,t,n,r,s){if((r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let o=await s(e,n.word.parts,r.inDoubleQuotes),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,l,c]=a,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let p=new se,d=he(p,c);u=await Q(e,d.expression)}catch{let p=e.state.env[c];u=p?Number.parseInt(p,10):0}Number.isNaN(u)&&(u=0)}e.state.env[`${l}_${u}`]=o;let f=Number.parseInt(e.state.env[`${l}__length`]||"0",10);u>=f&&(e.state.env[`${l}__length`]=String(u+1))}else e.state.env[t]=o;return o}return r.effectiveValue}async function yg(e,t,n,r,s){if(r.isUnset||n.checkEmpty&&r.isEmpty){let o=n.word?await s(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new ae(1,"",`bash: ${o}
758
+ `;throw new ae(1,"",r)}return null}function Ot(e,t){let n=e.state.exportedVars?.has(t)??!1;if(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t),e.state.localScopes.length>0&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!n){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length<e.state.localScopes.length;)e.state.localExportedVars.push(new Set);e.state.localExportedVars[e.state.localExportedVars.length-1].add(t)}}function oi(e,t){e.state.exportedVars?.delete(t)}var on=v(()=>{"use strict";de()});function an(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return"";let n="",r=e.state.env[`${t}__length`]!==void 0||Object.keys(e.state.env).some(i=>i.startsWith(`${t}_`)&&/^[0-9]+$/.test(i.slice(t.length+1))),s=e.state.associativeArrays?.has(t)??!1;return r&&!s&&(n+="a"),s&&(n+="A"),e.state.integerVars?.has(t)&&(n+="i"),Se(e,t)&&(n+="n"),Ht(e,t)&&(n+="r"),e.state.exportedVars?.has(t)&&(n+="x"),n}var ai=v(()=>{"use strict";Tt();on()});async function mg(e,t,n,r){return(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function gg(e,t,n,r,s){if((r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let o=await s(e,n.word.parts,r.inDoubleQuotes),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,l,c]=a,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let p=new se,d=he(p,c);u=await Q(e,d.expression)}catch{let p=e.state.env[c];u=p?Number.parseInt(p,10):0}Number.isNaN(u)&&(u=0)}e.state.env[`${l}_${u}`]=o;let f=Number.parseInt(e.state.env[`${l}__length`]||"0",10);u>=f&&(e.state.env[`${l}__length`]=String(u+1))}else e.state.env[t]=o;return o}return r.effectiveValue}async function yg(e,t,n,r,s){if(r.isUnset||n.checkEmpty&&r.isEmpty){let o=n.word?await s(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new ae(1,"",`bash: ${o}
759
759
  `)}return r.effectiveValue}async function bg(e,t,n,r){return!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):""}async function wg(e,t,n,r,s){let i="",o=e.state.shoptOptions.extglob;if(n.pattern)for(let l of n.pattern.parts)if(l.type==="Glob")i+=ce(l.pattern,n.greedy,o);else if(l.type==="Literal")i+=ce(l.value,n.greedy,o);else if(l.type==="SingleQuoted"||l.type==="Escaped")i+=pe(l.value);else if(l.type==="DoubleQuoted"){let c=await r(e,l.parts);i+=pe(c)}else if(l.type==="ParameterExpansion"){let c=await s(e,l);i+=ce(c,n.greedy,o)}else{let c=await s(e,l);i+=pe(c)}if(n.side==="prefix")return t.replace(new RegExp(`^${i}`,"s"),"");let a=new RegExp(`${i}$`,"s");if(n.greedy)return t.replace(a,"");for(let l=t.length;l>=0;l--){let c=t.slice(l);if(a.test(c))return t.slice(0,l)}return t}async function xg(e,t,n,r,s){let i="",o=e.state.shoptOptions.extglob;if(n.pattern)for(let c of n.pattern.parts)if(c.type==="Glob")i+=ce(c.pattern,!0,o);else if(c.type==="Literal")i+=ce(c.value,!0,o);else if(c.type==="SingleQuoted"||c.type==="Escaped")i+=pe(c.value);else if(c.type==="DoubleQuoted"){let u=await r(e,c.parts);i+=pe(u)}else if(c.type==="ParameterExpansion"){let u=await s(e,c);i+=ce(u,!0,o)}else{let u=await s(e,c);i+=pe(u)}let a=n.replacement?await r(e,n.replacement.parts):"";if(n.anchor==="start"?i=`^${i}`:n.anchor==="end"&&(i=`${i}$`),i==="")return t;let l=n.all?"gs":"s";try{let c=new RegExp(i,l);if(n.all){let u="",f=0,p=c.exec(t);for(;p!==null&&!(p[0].length===0&&p.index===t.length);)u+=t.slice(f,p.index)+a,f=p.index+p[0].length,p[0].length===0&&f++,p=c.exec(t);return u+=t.slice(f),u}return t.replace(c,a)}catch{return t}}function Eg(e,t,n){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let s=r[1],i=te(e,s);return i.length>0?String(i.length):e.state.env[s]!==void 0?"1":"0"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&Qt(e,t)){if(t==="FUNCNAME"){let i=e.state.funcNameStack?.[0]||"";return String([...i].length)}if(t==="BASH_LINENO"){let i=e.state.callLineStack?.[0];return String(i!==void 0?[...String(i)].length:0)}let s=e.state.env[`${t}_0`]||"";return String([...s].length)}return String([...n].length)}async function Sg(e,t,n,r){let s=await Q(e,r.offset.expression),i=r.length?await Q(e,r.length.expression):void 0;if(t==="@"||t==="*"){let c=Number.parseInt(e.state.env["#"]||"0",10),u=[];for(let m=1;m<=c;m++)u.push(e.state.env[String(m)]||"");let f=e.state.env[0]||"bash",p,d;if(s<=0)if(p=[f,...u],s<0){if(d=p.length+s,d<0)return""}else d=0;else p=u,d=s-1;if(d<0||d>=p.length)return"";if(i!==void 0){let m=i<0?p.length+i:d+i;return p.slice(d,Math.max(d,m)).join(" ")}return p.slice(d).join(" ")}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let c=o[1];if(e.state.associativeArrays?.has(c))throw new ae(1,"",`bash: \${${c}[@]: 0: 3}: bad substitution
760
- `);let u=te(e,c),f=0;if(s<0){if(u.length>0){let p=u[u.length-1][0],m=(typeof p=="number"?p:0)+1+s;if(m<0||(f=u.findIndex(([h])=>typeof h=="number"&&h>=m),f<0))return""}}else if(f=u.findIndex(([p])=>typeof p=="number"&&p>=s),f<0)return"";if(i!==void 0){if(i<0)throw new Ee(`${o[1]}[@]: substring expression < 0`);return u.slice(f,f+i).map(([,p])=>p).join(" ")}return u.slice(f).map(([,p])=>p).join(" ")}let a=[...n],l=s;if(l<0&&(l=Math.max(0,a.length+l)),i!==void 0){if(i<0){let c=a.length+i;return a.slice(l,Math.max(l,c)).join("")}return a.slice(l,l+i).join("")}return a.slice(l).join("")}async function Ag(e,t,n,r,s){if(n.pattern){let i=e.state.shoptOptions.extglob,o="";for(let f of n.pattern.parts)if(f.type==="Glob")o+=ce(f.pattern,!0,i);else if(f.type==="Literal")o+=ce(f.value,!0,i);else if(f.type==="SingleQuoted"||f.type==="Escaped")o+=pe(f.value);else if(f.type==="DoubleQuoted"){let p=await r(e,f.parts);o+=pe(p)}else if(f.type==="ParameterExpansion"){let p=await s(e,f);o+=ce(p,!0,i)}let a=new RegExp(`^(?:${o})$`),l=n.direction==="upper"?f=>f.toUpperCase():f=>f.toLowerCase(),c="",u=!1;for(let f of t)!n.all&&u?c+=f:a.test(f)?(c+=l(f),u=!0):c+=f;return c}return n.direction==="upper"?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function Cg(e,t,n,r,s){let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(i&&s.operator==="Q")return te(e,i[1]).map(([,c])=>rn(c)).join(" ");if(i&&s.operator==="a")return on(e,i[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&s.operator==="a")return on(e,o[1]);switch(s.operator){case"Q":return r?"":rn(n);case"P":return Mr(e,n);case"a":return on(e,t);case"A":return r?"":`${t}=${rn(n)}`;case"E":return n.replace(/\\([\\abefnrtv'"?])/g,(a,l)=>{switch(l){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
761
- `;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 r?"":rn(n);case"u":return n.charAt(0).toUpperCase()+n.slice(1);case"U":return n.toUpperCase();case"L":return n.toLowerCase();default:return n}}async function Ng(e,t,n,r,s,i,o=!1){if(Se(e,t))return kn(e,t)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new nt(`\${!${t}}`)}let l=n;if(a&&(l===""||l.includes(" ")))throw new nt(`\${!${t}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new nt(`\${!${t}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(e,u,o)}return await me(e,l)}function kg(e,t){let r=te(e,t.array).map(([s])=>String(s));return t.star?r.join(oe(e.state.env)):r.join(" ")}function vg(e,t){let n=sr(e,t.prefix);return t.star?n.join(oe(e.state.env)):n.join(" ")}function $g(e,t,n,r){let s=Number.parseInt(e.state.env["#"]||"0",10),i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t==="*")return{isEmpty:s===0,effectiveValue:n};if(t==="@")return{isEmpty:s===0||s===1&&e.state.env[1]==="",effectiveValue:n};if(i){let[,o,a]=i,l=te(e,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=oe(e.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:r?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:n==="",effectiveValue:n}}var Ig=v(()=>{"use strict";Je();Fe();it();de();St();Tt();nr();rr();vn();Va();qa();ht();ai()});function Rg(e){let t=0;for(;t<e.length;){let n=e[t];if(n==="\\"&&t+1<e.length){t+=2;continue}if(n==="'"){let r=e.indexOf("'",t+1);if(r!==-1){t=r+1;continue}}if(n==="$"&&t+1<e.length&&e[t+1]==="("||n==="`")return!0;t++}return!1}function Pg(e,t){let n=1,r=t,s=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r];if(o==="\\"&&!s&&r+1<e.length){r+=2;continue}if(o==="'"&&!i){s=!s,r++;continue}if(o==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(o==="(")n++;else if(o===")"&&(n--,n===0))return r}r++}return-1}async function li(e,t){let n=new se,r;try{r=n.parse(t)}catch{return""}let s=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let i={...e.state.env},o=e.state.cwd,a=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let l=await e.executeScript(r),c=l.exitCode;return e.state.env=i,e.state.cwd=o,e.state.suppressVerbose=a,e.state.lastExitCode=c,e.state.env["?"]=String(c),l.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+l.stderr),e.state.bashPid=s,l.stdout.replace(/\n+$/,"")}catch(l){if(e.state.env=i,e.state.cwd=o,e.state.bashPid=s,e.state.suppressVerbose=a,l instanceof ne)throw l;return l instanceof ae?(e.state.lastExitCode=l.exitCode,e.state.env["?"]=String(l.exitCode),l.stdout?.replace(/\n+$/,"")??""):""}}function Ga(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=mt(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=KC(e,a);n+=mt(l),r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}function KC(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}n+=s,r++}return n}async function Tg(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=mt(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=await XC(e,a);n+=mt(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=Pg(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}async function XC(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=Pg(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}n+=s,r++}return n}var Og=v(()=>{"use strict";Fe();de();tr()});function Dg(e,t){if(!t.startsWith("~"))return t;let n=e.state.env.HOME!==void 0?e.state.env.HOME:"/home/user";if(t==="~"||t.startsWith("~/"))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let s=t.slice(1,r),i=t.slice(r);return i!==""&&!i.startsWith("/")?t:s==="root"?`/root${i}`:t}var Fg=v(()=>{"use strict"});async function JC(e,t,n,r){let s="";for(let i of t.parts)if(i.type==="Glob")s+=ce(i.pattern,!0,e.state.shoptOptions.extglob);else if(i.type==="Literal")s+=ce(i.value,!0,e.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=pe(i.value);else if(i.type==="DoubleQuoted"){let o=await n(e,i.parts);s+=pe(o)}else if(i.type==="ParameterExpansion"){let o=await r(e,i);s+=ce(o,!0,e.state.shoptOptions.extglob)}else{let o=await r(e,i);s+=pe(o)}return s}async function _g(e,t,n,r){if(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!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=te(e,a),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env[a];g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let p="";c.pattern&&(p=await JC(e,c.pattern,n,r));let d=c.replacement?await n(e,c.replacement.parts):"",m=p;c.anchor==="start"?m=`^${p}`:c.anchor==="end"&&(m=`${p}$`);let h=[];try{let g=new RegExp(m,c.all?"g":"");for(let b of f)h.push(b.replace(g,d))}catch{h.push(...f)}if(l){let g=oe(e.state.env);return{values:[h.join(g)],quoted:!0}}return{values:h,quoted:!0}}async function Lg(e,t,n,r){if(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!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=te(e,a),f=u.map(([,h])=>h);if(u.length===0){let h=e.state.env[a];h!==void 0&&f.push(h)}if(f.length===0)return{values:[],quoted:!0};let p="",d=e.state.shoptOptions.extglob;if(c.pattern)for(let h of c.pattern.parts)if(h.type==="Glob")p+=ce(h.pattern,c.greedy,d);else if(h.type==="Literal")p+=ce(h.value,c.greedy,d);else if(h.type==="SingleQuoted"||h.type==="Escaped")p+=pe(h.value);else if(h.type==="DoubleQuoted"){let g=await n(e,h.parts);p+=pe(g)}else if(h.type==="ParameterExpansion"){let g=await r(e,h);p+=ce(g,c.greedy,d)}else{let g=await r(e,h);p+=pe(g)}let m=[];for(let h of f)m.push(Kt(h,p,c.side,c.greedy));if(l){let h=oe(e.state.env);return{values:[m.join(h)],quoted:!0}}return{values:m,quoted:!0}}var Mg=v(()=>{"use strict";St();nr();rr();vn();ht()});async function Wg(e,t){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!=="DefaultValue"&&n.parts[0].operation?.type!=="UseAlternative"&&n.parts[0].operation?.type!=="AssignDefault")return null;let r=n.parts[0],s=r.operation,i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=te(e,l),u=c.length>0||e.state.env[l]!==void 0,f=c.length===0||c.length===1&&c.every(([,d])=>d===""),p=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(p&&f):o=!u||p&&f,!o){if(c.length>0){let m=c.map(([,h])=>h);if(a){let h=oe(e.state.env);return{values:[m.join(h)],quoted:!0}}return{values:m,quoted:!0}}let d=e.state.env[l];return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await zt(e,l),u=await me(e,l),f=u==="",p=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(p&&f):o=!c||p&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let p=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(p){c=p[1],u=p[2]==="*";break}}if(c){let f=te(e,c);if(f.length>0){let d=f.map(([,m])=>m);if(u||a){let m=oe(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}let p=e.state.env[c];return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}}return null}async function Bg(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],o=-1,a="",l=!1,c=null;for(let h=0;h<i.parts.length;h++){let g=i.parts[h];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let b=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){o=h,a=b[1],l=b[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let h=0;h<o;h++)u+=await r(e,i.parts[h]);let f="";for(let h=o+1;h<i.parts.length;h++)f+=await r(e,i.parts[h]);let p=te(e,a),d=p.map(([,h])=>h);if(p.length===0){let h=e.state.env[a];if(h!==void 0)d=[h];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let h=c,g="",b=e.state.shoptOptions.extglob;if(h.pattern)for(let y of h.pattern.parts)if(y.type==="Glob")g+=ce(y.pattern,h.greedy,b);else if(y.type==="Literal")g+=ce(y.value,h.greedy,b);else if(y.type==="SingleQuoted"||y.type==="Escaped")g+=pe(y.value);else if(y.type==="DoubleQuoted"){let w=await s(e,y.parts);g+=pe(w)}else if(y.type==="ParameterExpansion"){let w=await r(e,y);g+=ce(w,h.greedy,b)}else{let w=await r(e,y);g+=pe(w)}d=d.map(y=>Kt(y,g,h.side,h.greedy))}else if(c?.type==="PatternReplacement"){let h=c,g="";if(h.pattern)for(let w of h.pattern.parts)if(w.type==="Glob")g+=ce(w.pattern,!0,e.state.shoptOptions.extglob);else if(w.type==="Literal")g+=ce(w.value,!0,e.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")g+=pe(w.value);else if(w.type==="DoubleQuoted"){let E=await s(e,w.parts);g+=pe(E)}else if(w.type==="ParameterExpansion"){let E=await r(e,w);g+=ce(E,!0,e.state.shoptOptions.extglob)}else{let E=await r(e,w);g+=pe(E)}let b=h.replacement?await s(e,h.replacement.parts):"",y=g;h.anchor==="start"?y=`^${g}`:h.anchor==="end"&&(y=`${g}$`);try{let w=new RegExp(y,h.all?"g":"");d=d.map(E=>E.replace(w,b))}catch{}}if(l){let h=oe(e.state.env);return{values:[u+d.join(h)+f],quoted:!0}}return d.length===1?{values:[u+d[0]+f],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+f],quoted:!0}}async function Ug(e,t,n,r){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o="",a=!1;for(let d=0;d<s.parts.length;d++){let m=s.parts[d];if(m.type==="ParameterExpansion"&&!m.operation){let h=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){i=d,o=h[1],a=h[2]==="*";break}}}if(i===-1)return null;let l="";for(let d=0;d<i;d++)l+=await r(e,s.parts[d]);let c="";for(let d=i+1;d<s.parts.length;d++)c+=await r(e,s.parts[d]);let u=te(e,o),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env[o];if(d!==void 0)return{values:[l+d+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let m=l+c;return{values:m?[m]:[],quoted:!0}}if(a){let d=oe(e.state.env);return{values:[l+f.join(d)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var zg=v(()=>{"use strict";St();nr();rr();vn();ht()});async function jg(e,t,n){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!=="Substring")return null;let s=r.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(e.state.associativeArrays?.has(o))throw new ae(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
762
- `);let c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=te(e,o),p=0;if(c<0){if(f.length>0){let m=f[f.length-1][0],g=(typeof m=="number"?m:0)+1+c;if(g<0)return{values:[],quoted:!0};p=f.findIndex(([b])=>typeof b=="number"&&b>=g),p<0&&(p=f.length)}}else p=f.findIndex(([m])=>typeof m=="number"&&m>=c),p<0&&(p=f.length);let d;if(u!==void 0){if(u<0)throw new Ee(`${o}[@]: substring expression < 0`);d=f.slice(p,p+u).map(([,m])=>m)}else d=f.slice(p).map(([,m])=>m);if(d.length===0)return{values:[],quoted:!0};if(a){let m=oe(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}function Hg(e,t){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!=="Transform")return null;let r=n.parts[0],s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=r.operation,l=te(e,i);if(l.length===0){let f=e.state.env[i];if(f!==void 0){let p;switch(a.operator){case"a":p="";break;case"P":p=Mr(e,f);break;case"Q":p=rn(f);break;default:p=f}return{values:[p],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=on(e,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>Mr(e,f));break;case"Q":u=l.map(([,f])=>rn(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=oe(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var Vg=v(()=>{"use strict";de();St();Va();qa();ht();ai()});function qg(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion")return null;let r=n.parts[0];if(r.operation)return null;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(Se(e,i)){let l=kn(e,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=te(e,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=e.state.env[i];return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function Gg(e,t){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)return null;let s=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!Se(e,s))return null;let i=kn(e,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=te(e,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=e.state.env[a];return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var Zg=v(()=>{"use strict";Tt();ht()});async function Qg(e,t,n,r,s){if(!n||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!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await me(e,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let m=Number.parseInt(e.state.env["#"]||"0",10),h=[];for(let g=1;g<=m;g++)h.push(e.state.env[String(g)]||"");return l==="*"?{values:[h.join(oe(e.state.env))],quoted:!0}:{values:h,quoted:!0}}return null}let u=c[1],f=c[2]==="*",p=te(e,u);if(a.innerOp){if(a.innerOp.type==="Substring")return YC(e,p,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return eN(e,p,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let h=on(e,u),g=p.map(()=>h);return f?{values:[g.join(oe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let m=[];for(let[,h]of p){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},b=e.state.env._indirect_elem_;e.state.env._indirect_elem_=h;try{let y=await r(e,g,!0);m.push(y)}finally{b!==void 0?e.state.env._indirect_elem_=b:delete e.state.env._indirect_elem_}}return f?{values:[m.join(oe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(p.length>0){let m=p.map(([,h])=>h);return f?{values:[m.join(oe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let d=e.state.env[u];return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function YC(e,t,n,r,s){let i=s.offset?await Q(e,s.offset.expression):0,o=s.length?await Q(e,s.length.expression):void 0,a=0;if(i<0){if(t.length>0){let u=t[t.length-1][0],p=(typeof u=="number"?u:0)+1+i;if(p<0)return{values:[],quoted:!0};if(a=t.findIndex(([d])=>typeof d=="number"&&d>=p),a<0)return{values:[],quoted:!0}}}else if(a=t.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new Ee(`${n}[@]: substring expression < 0`);l=t.slice(a,a+o)}else l=t.slice(a);let c=l.map(([,u])=>u);return r?{values:[c.join(oe(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function eN(e,t,n,r,s,i){let o=s.checkEmpty??!1,a=t.map(([,u])=>u),l=t.length===0,c=t.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:r?{values:[a.join(oe(e.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(e,s.word.parts,!0);return e.state.env[`${n}_0`]=f,e.state.env[`${n}__length`]="1",{values:[f],quoted:!0}}return r?{values:[a.join(oe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}return r?{values:[a.join(oe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}async function Kg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="UseAlternative"&&t[0].operation?.type!=="DefaultValue")return null;let n=t[0],r=n.operation,s=r?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await me(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await zt(e,n.parameter),u=await me(e,n.parameter)==="",f=r.checkEmpty??!1,p;if(r.type==="UseAlternative"?p=c&&!(f&&u):p=!c||f&&u,p){let d=l[1],m=l[2]==="*",h=te(e,d);if(h.length>0){let b=h.map(([,y])=>y);return m?{values:[b.join(oe(e.state.env))],quoted:!0}:{values:b,quoted:!0}}let g=e.state.env[d];return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function Xg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="Indirection")return null;let n=t[0],s=n.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await me(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await me(e,n.parameter),f=await zt(e,n.parameter),p=u==="",d=s.checkEmpty??!1,m;if(s.type==="UseAlternative"?m=f&&!(d&&p):m=!f||d&&p,m){let h=c[1],g=c[2]==="*",b=te(e,h);if(b.length>0){let w=b.map(([,E])=>E);return g?{values:[w.join(oe(e.state.env))],quoted:!0}:{values:w,quoted:!0}}let y=e.state.env[h];return y!==void 0?{values:[y],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var Jg=v(()=>{"use strict";it();de();St();ht();ai()});function Yg(e){let t=Number.parseInt(e.state.env["#"]||"0",10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env[String(r)]||"");return n}async function e0(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let w=s.parts[y];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="Substring"){i=y,o=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=Number.parseInt(e.state.env["#"]||"0",10),p=[];for(let y=1;y<=f;y++)p.push(e.state.env[String(y)]||"");let d=e.state.env[0]||"bash",m;if(c<=0){let y=[d,...p],w=y.length+c;if(w<0)m=[];else{let E=c<0?w:0;if(u!==void 0){let C=u<0?y.length+u:E+u;m=y.slice(E,Math.max(E,C))}else m=y.slice(E)}}else{let y=c-1;if(y>=p.length)m=[];else if(u!==void 0){let w=u<0?p.length+u:y+u;m=p.slice(y,Math.max(y,w))}else m=p.slice(y)}let h="";for(let y=0;y<i;y++)h+=await r(e,s.parts[y]);let g="";for(let y=i+1;y<s.parts.length;y++)g+=await r(e,s.parts[y]);if(m.length===0){let y=h+g;return{values:y?[y]:[],quoted:!0}}if(o){let y=oe(e.state.env);return{values:[h+m.join(y)+g],quoted:!0}}return m.length===1?{values:[h+m[0]+g],quoted:!0}:{values:[h+m[0],...m.slice(1,-1),m[m.length-1]+g],quoted:!0}}async function t0(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let b=0;b<s.parts.length;b++){let y=s.parts[b];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternReplacement"){i=b,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=Yg(e),u="";for(let b=0;b<i;b++)u+=await n(e,s.parts[b]);let f="";for(let b=i+1;b<s.parts.length;b++)f+=await n(e,s.parts[b]);if(c.length===0){let b=u+f;return{values:b?[b]:[],quoted:!0}}let p="";if(l.pattern)for(let b of l.pattern.parts)if(b.type==="Glob")p+=ce(b.pattern,!0,e.state.shoptOptions.extglob);else if(b.type==="Literal")p+=ce(b.value,!0,e.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")p+=pe(b.value);else if(b.type==="DoubleQuoted"){let y=await r(e,b.parts);p+=pe(y)}else if(b.type==="ParameterExpansion"){let y=await n(e,b);p+=ce(y,!0,e.state.shoptOptions.extglob)}else{let y=await n(e,b);p+=pe(y)}let d=l.replacement?await r(e,l.replacement.parts):"",m=p;l.anchor==="start"?m=`^${p}`:l.anchor==="end"&&(m=`${p}$`);let h=[];try{let b=new RegExp(m,l.all?"g":"");for(let y of c)h.push(y.replace(b,d))}catch{h.push(...c)}if(o){let b=oe(e.state.env);return{values:[u+h.join(b)+f],quoted:!0}}return h.length===1?{values:[u+h[0]+f],quoted:!0}:{values:[u+h[0],...h.slice(1,-1),h[h.length-1]+f],quoted:!0}}async function n0(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let b=s.parts[g];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="PatternRemoval"){i=g,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=Yg(e),u="";for(let g=0;g<i;g++)u+=await n(e,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await n(e,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let p="",d=e.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")p+=ce(g.pattern,l.greedy,d);else if(g.type==="Literal")p+=ce(g.value,l.greedy,d);else if(g.type==="SingleQuoted"||g.type==="Escaped")p+=pe(g.value);else if(g.type==="DoubleQuoted"){let b=await r(e,g.parts);p+=pe(b)}else if(g.type==="ParameterExpansion"){let b=await n(e,g);p+=ce(b,l.greedy,d)}else{let b=await n(e,g);p+=pe(b)}let m=[];for(let g of c)m.push(Kt(g,p,l.side,l.greedy));if(o){let g=oe(e.state.env);return{values:[u+m.join(g)+f],quoted:!0}}return m.length===1?{values:[u+m[0]+f],quoted:!0}:{values:[u+m[0],...m.slice(1,-1),m[m.length-1]+f],quoted:!0}}async function r0(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0],s=-1,i=!1;for(let p=0;p<r.parts.length;p++){let d=r.parts[p];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")){s=p,i=d.parameter==="*";break}}if(s===-1)return null;let o=r.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(e.state.env["#"]||"0",10),l="";for(let p=0;p<s;p++)l+=await n(e,r.parts[p]);let c="";for(let p=s+1;p<r.parts.length;p++)c+=await n(e,r.parts[p]);if(a===0){if(i)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}let u=[];for(let p=1;p<=a;p++)u.push(e.state.env[String(p)]||"");if(i){let p=oe(e.state.env);return{values:[l+u.join(p)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var s0=v(()=>{"use strict";St();nr();rr();vn()});function tN(e){return new nn(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})}async function ci(e,t){if(e.state.options.noglob)return t;let n=tN(e),r=[];for(let s of t)if(jt(s,e.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new _t(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function i0(e,t,n,r){let s=-1,i="",o=!1;for(let y=0;y<t.length;y++){let w=t[y];if(w.type==="ParameterExpansion"&&w.operation?.type==="PatternReplacement"){let E=w.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(E){s=y,i=E[1],o=E[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=te(e,i),u=c.map(([,y])=>y);if(c.length===0){let y=e.state.env[i];y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=ce(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")f+=ce(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=pe(y.value);else if(y.type==="DoubleQuoted"){let w=await n(e,y.parts);f+=pe(w)}else if(y.type==="ParameterExpansion"){let w=await r(e,y);f+=ce(w,!0,e.state.shoptOptions.extglob)}else{let w=await r(e,y);f+=pe(w)}let p=l.replacement?await n(e,l.replacement.parts):"",d=f;l.anchor==="start"?d=`^${f}`:l.anchor==="end"&&(d=`${f}$`);let m=[];try{let y=new RegExp(d,l.all?"g":"");for(let w of u)m.push(w.replace(y,p))}catch{m.push(...u)}let h=Ue(e.state.env),g=Ze(e.state.env);if(o){let y=oe(e.state.env),w=m.join(y);return g?{values:w?[w]:[],quoted:!1}:{values:Ae(w,h),quoted:!1}}if(g)return{values:m,quoted:!1};let b=[];for(let y of m)y===""?b.push(""):b.push(...Ae(y,h));return{values:b,quoted:!1}}async function o0(e,t,n,r){let s=-1,i="",o=!1;for(let b=0;b<t.length;b++){let y=t[b];if(y.type==="ParameterExpansion"&&y.operation?.type==="PatternRemoval"){let w=y.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(w){s=b,i=w[1],o=w[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=te(e,i),u=c.map(([,b])=>b);if(c.length===0){let b=e.state.env[i];b!==void 0&&(u=[b])}if(u.length===0)return{values:[],quoted:!1};let f="",p=e.state.shoptOptions.extglob;if(l.pattern)for(let b of l.pattern.parts)if(b.type==="Glob")f+=ce(b.pattern,l.greedy,p);else if(b.type==="Literal")f+=ce(b.value,l.greedy,p);else if(b.type==="SingleQuoted"||b.type==="Escaped")f+=pe(b.value);else if(b.type==="DoubleQuoted"){let y=await n(e,b.parts);f+=pe(y)}else if(b.type==="ParameterExpansion"){let y=await r(e,b);f+=ce(y,l.greedy,p)}else{let y=await r(e,b);f+=pe(y)}let d=[];for(let b of u)d.push(Kt(b,f,l.side,l.greedy));let m=Ue(e.state.env),h=Ze(e.state.env);if(o){let b=oe(e.state.env),y=d.join(b);return h?{values:y?[y]:[],quoted:!1}:{values:Ae(y,m),quoted:!1}}if(h)return{values:d,quoted:!1};let g=[];for(let b of d)b===""?g.push(""):g.push(...Ae(b,m));return{values:g,quoted:!1}}async function a0(e,t,n,r){let s=-1,i=!1;for(let g=0;g<t.length;g++){let b=t[g];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="PatternRemoval"){s=g,i=b.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=Number.parseInt(e.state.env["#"]||"0",10),c=[];for(let g=1;g<=l;g++)c.push(e.state.env[String(g)]||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=e.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=ce(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=ce(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=pe(g.value);else if(g.type==="DoubleQuoted"){let b=await n(e,g.parts);u+=pe(b)}else if(g.type==="ParameterExpansion"){let b=await r(e,g);u+=ce(b,a.greedy,f)}else{let b=await r(e,g);u+=pe(b)}let p=[];for(let g of c)p.push(Kt(g,u,a.side,a.greedy));let d=Ue(e.state.env),m=Ze(e.state.env);if(i){let g=oe(e.state.env),b=p.join(g);return m?{values:b?[b]:[],quoted:!1}:{values:Ae(b,d),quoted:!1}}if(m)return{values:p,quoted:!1};let h=[];for(let g of p)g===""?h.push(""):h.push(...Ae(g,d));return{values:h,quoted:!1}}async function l0(e,t,n,r){let s=-1,i=!1;for(let w=0;w<t.length;w++){let E=t[w];if(E.type==="ParameterExpansion"&&(E.parameter==="@"||E.parameter==="*")&&E.operation?.type==="Substring"){s=w,i=E.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=a.offset?await n(e,a.offset.expression):0,c=a.length?await n(e,a.length.expression):void 0,u=Number.parseInt(e.state.env["#"]||"0",10),f=[];for(let w=1;w<=u;w++)f.push(e.state.env[String(w)]||"");let p=e.state.env[0]||"bash",d;if(l<=0){let w=[p,...f],E=w.length+l;if(E<0)d=[];else{let C=l<0?E:0;if(c!==void 0){let A=c<0?w.length+c:C+c;d=w.slice(C,Math.max(C,A))}else d=w.slice(C)}}else{let w=l-1;if(w>=f.length)d=[];else if(c!==void 0){let E=c<0?f.length+c:w+c;d=f.slice(w,Math.max(w,E))}else d=f.slice(w)}let m="";for(let w=0;w<s;w++)m+=await r(e,t[w]);let h="";for(let w=s+1;w<t.length;w++)h+=await r(e,t[w]);let g=Ue(e.state.env),b=Ze(e.state.env);if(d.length===0){let w=m+h;return w?b?{values:[w],quoted:!1}:{values:Ae(w,g),quoted:!1}:{values:[],quoted:!1}}let y;if(i){let w=oe(e.state.env),E=m+d.join(w)+h;b?y=E?[E]:[]:y=Ae(E,g)}else if(b)d.length===1?y=[m+d[0]+h]:y=[m+d[0],...d.slice(1,-1),d[d.length-1]+h];else{y=[];for(let w=0;w<d.length;w++){let E=d[w];if(w===0&&(E=m+E),w===d.length-1&&(E=E+h),E==="")y.push("");else{let C=Ae(E,g);y.push(...C)}}}return{values:await ci(e,y),quoted:!1}}async function c0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].parameter!=="@"&&t[0].parameter!=="*"||t[0].operation)return null;let n=t[0].parameter==="*",r=Number.parseInt(e.state.env["#"]||"0",10);if(r===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=r;c++)s.push(e.state.env[String(c)]||"");let i=Ue(e.state.env),o=Ze(e.state.env),a=ni(e.state.env),l;if(n)if(o)l=s.filter(c=>c!=="");else{let c=oe(e.state.env),u=s.join(c);l=Ae(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=Ae(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=Ae(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await ci(e,l),quoted:!1}}async function u0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],s=n[2]==="*",i=te(e,r),o;if(i.length===0){let f=e.state.env[r];if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=Ue(e.state.env),l=Ze(e.state.env),c=ni(e.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=oe(e.state.env),p=o.join(f);u=Ae(p,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let p=Ae(f,a);u.push(...p)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let p=Ae(f,a);u.push(...p)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await ci(e,u),quoted:!1}}function f0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=sr(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=Ue(e.state.env),i=Ze(e.state.env),o;if(n.star)if(i)o=r;else{let a=oe(e.state.env),l=r.join(a);o=Ae(l,s)}else if(i)o=r;else{o=[];for(let a of r){let l=Ae(a,s);o.push(...l)}}return{values:o,quoted:!1}}function p0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="ArrayKeys")return null;let n=t[0].operation,s=te(e,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=Ue(e.state.env),o=Ze(e.state.env),a;if(n.star)if(o)a=s;else{let l=oe(e.state.env),c=s.join(l);a=Ae(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=Ae(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function d0(e,t,n){let r=-1;for(let p=0;p<t.length;p++){let d=t[p];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")&&!d.operation){r=p;break}}if(r===-1||t.length<=1)return null;let s=Number.parseInt(e.state.env["#"]||"0",10),i=[];for(let p=1;p<=s;p++)i.push(e.state.env[String(p)]||"");let o="";for(let p=0;p<r;p++)o+=await n(e,t[p]);let a="";for(let p=r+1;p<t.length;p++)a+=await n(e,t[p]);let l=Ue(e.state.env),c=Ze(e.state.env),u=ni(e.state.env);if(s===0){let p=o+a;return{values:p?[p]:[],quoted:!1}}let f;{let p=[];for(let d=0;d<i.length;d++){let m=i[d];d===0&&(m=o+m),d===i.length-1&&(m=m+a),p.push(m)}if(c)f=p.filter(d=>d!=="");else if(u){f=[];for(let d of p){if(d==="")continue;let m=Ae(d,l);f.push(...m)}}else{f=[];for(let d of p)if(d==="")f.push("");else{let m=Ae(d,l);f.push(...m)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await ci(e,f),quoted:!1}}var h0=v(()=>{"use strict";Ys();de();St();nr();tr();rr();vn();ht()});async function y0(e,t,n){let r=t.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=Lr(r),p=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(p&&p.length>1)return nN(e,p,s);let d=await rN(e,r,a,c,u,n);if(d!==null)return d;let m=await iN(e,r,n);if(m!==null)return m;let h=await oN(e,r,n);if(h!==null)return h;let g=await lN(e,r,n.expandPart);if(g!==null)return g0(e,g);if((i||o||l)&&!Ze(e.state.env)){let y=Ue(e.state.env),w=n.buildIfsCharClassPattern(y),E=await n.smartWordSplit(e,r,y,w,n.expandPart);return g0(e,E)}let b=await n.expandWordAsync(e,t);return cN(e,t,r,b,s,n.expandWordForGlobbing)}async function nN(e,t,n){let r=[];for(let s of t)if(!(!n&&s===""))if(!n&&!e.state.options.noglob&&jt(s,e.state.shoptOptions.extglob)){let i=await ui(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function rN(e,t,n,r,s,i){if(n){let o=qg(e,t);if(o!==null)return o}{let o=Gg(e,t);if(o!==null)return o}{let o=await Wg(e,t);if(o!==null)return o}{let o=await Bg(e,t,n,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await Ug(e,t,n,i.expandPart);if(o!==null)return o}{let o=await jg(e,t,i.evaluateArithmetic);if(o!==null)return o}{let o=Hg(e,t);if(o!==null)return o}{let o=await _g(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await Lg(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let o=sN(e,t);if(o!==null)return o}{let o=await Qg(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await Kg(e,t);if(o!==null)return o}{let o=await Xg(e,t);if(o!==null)return o}return null}function sN(e,t){let n=t[0];if(n.type!=="DoubleQuoted")return null;if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="VarNamePrefix"){let r=n.parts[0].operation,s=sr(e,r.prefix);return r.star?{values:[s.join(oe(e.state.env))],quoted:!0}:{values:s,quoted:!0}}if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="ArrayKeys"){let r=n.parts[0].operation,i=te(e,r.array).map(([o])=>String(o));return r.star?{values:[i.join(oe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function iN(e,t,n){{let r=await e0(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await t0(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await n0(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await r0(e,t,n.expandPart);if(r!==null)return r}return null}async function oN(e,t,n){{let r=await i0(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await o0(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await a0(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await l0(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await c0(e,t);if(r!==null)return r}{let r=await u0(e,t);if(r!==null)return r}{let r=f0(e,t);if(r!==null)return r}{let r=p0(e,t);if(r!==null)return r}{let r=await d0(e,t,n.expandPart);if(r!==null)return r}return null}function m0(e){if(e.type!=="DoubleQuoted")return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!=="ParameterExpansion"||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:"array",name:r[1],atIndex:t,isStar:r[2]==="*"};if(n.parameter==="@"||n.parameter==="*")return{type:"positional",atIndex:t,isStar:n.parameter==="*"}}return null}async function aN(e,t,n,r){let s="";for(let a=0;a<n.atIndex;a++)s+=await r(e,t.parts[a]);let i="";for(let a=n.atIndex+1;a<t.parts.length;a++)i+=await r(e,t.parts[a]);let o;if(n.type==="array"){if(o=te(e,n.name).map(([,l])=>l),o.length===0){let l=e.state.env[n.name];l!==void 0&&(o=[l])}}else{let a=Number.parseInt(e.state.env["#"]||"0",10);o=[];for(let l=1;l<=a;l++)o.push(e.state.env[String(l)]||"")}if(n.isStar){let a=oe(e.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function lN(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(m0(l)){r=!0;break}if(!r)return null;let s=Ue(e.state.env),i=Ze(e.state.env),o=[];for(let l of t){let c=m0(l);if(c&&l.type==="DoubleQuoted"){let u=await aN(e,l,c,n);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(e,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Ae(u,s);o.push(f)}}else{let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Ae(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function g0(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(jt(r,e.state.shoptOptions.extglob)){let s=await ui(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function ui(e,t){let n=new nn(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}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new _t(t);return n.hasNullglob()?[]:[t]}async function cN(e,t,n,r,s,i){let o=n.some(a=>a.type==="Glob");if(!e.state.options.noglob&&o){let a=await i(e,t);if(jt(a,e.state.shoptOptions.extglob)){let c=await ui(e,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=Ha(r);if(!Ze(e.state.env)){let c=Ue(e.state.env);return{values:Ae(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!e.state.options.noglob&&jt(r,e.state.shoptOptions.extglob)){let a=await i(e,t);if(jt(a,e.state.shoptOptions.extglob)){let l=await ui(e,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=Ha(r);if(!Ze(e.state.env)){let l=Ue(e.state.env);return{values:Ae(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[r],quoted:s}}var b0=v(()=>{"use strict";Ys();de();St();ei();Mg();zg();Vg();Zg();tr();Jg();vn();s0();h0();ht()});async function x0(e,t){let n=t.operation;if(!n||n.type!=="DefaultValue"&&n.type!=="AssignDefault"&&n.type!=="UseAlternative")return null;let r=n.word;if(!r||r.parts.length===0)return null;let s=await zt(e,t.parameter),o=await me(e,t.parameter,!1)==="",a=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?r.parts:null}function uN(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function fN(e,t){if(t.type!=="ParameterExpansion")return null;let n=await x0(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>uN(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function pN(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?La(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&rg(e))}async function E0(e,t,n,r,s){if(t.length===1&&t[0].type==="ParameterExpansion"){let p=t[0],d=await x0(e,p);if(d&&d.length>0&&d.length>1&&d.some(h=>h.type==="DoubleQuoted"||h.type==="SingleQuoted")&&d.some(h=>h.type==="Literal"||h.type==="ParameterExpansion"||h.type==="CommandSubstitution"||h.type==="ArithmeticExpansion"))return w0(e,d,n,r,s)}let i=[],o=!1;for(let p of t){let d=pN(p),m=p.type==="DoubleQuoted"||p.type==="SingleQuoted",h=d?await fN(e,p):null,g=await s(e,p);i.push({value:g,isSplittable:d,isQuoted:m,mixedDefaultParts:h??void 0}),d&&(o=!0)}if(!o){let p=i.map(d=>d.value).join("");return p?[p]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let p of i)if(!p.isSplittable)u?p.isQuoted&&p.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):p.value!==""?(l!==""&&a.push(l),l=p.value,u=!1,f=!1):(l+=p.value,f=!1):(l+=p.value,f=p.isQuoted&&p.value==="");else if(p.mixedDefaultParts){let d=await w0(e,p.mixedDefaultParts,n,r,s);if(d.length!==0)if(d.length===1)l+=d[0],c=!0;else{l+=d[0],a.push(l),c=!0;for(let m=1;m<d.length-1;m++)a.push(d[m]);l=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:m,hadTrailingDelimiter:h}=ri(p.value,n);if(f&&m&&l===""&&(a.push(""),c=!0),d.length===0)h&&(u=!0);else if(d.length===1)l+=d[0],c=!0,u=h;else{l+=d[0],a.push(l),c=!0;for(let g=1;g<d.length-1;g++)a.push(d[g]);l=d[d.length-1],u=h}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function dN(e,t){return e.length>0&&t.includes(e[0])}async function w0(e,t,n,r,s){let i=[];for(let u of t){let p=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),d=await s(e,u);i.push({value:d,isSplittable:p})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{dN(u.value,n)&&a!==""&&(o.push(a),a="",l=!0);let{words:p,hadTrailingDelimiter:d}=ri(u.value,n);if(p.length===0)d&&(c=!0);else if(p.length===1)a+=p[0],l=!0,c=d;else{a+=p[0],o.push(a),l=!0;for(let m=1;m<p.length-1;m++)o.push(p[m]);a=p[p.length-1],c=d}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var S0=v(()=>{"use strict";ht();St();ei()});function A0(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function C0(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var N0=v(()=>{"use strict"});var Ya={};V(Ya,{escapeGlobChars:()=>mt,escapeRegexChars:()=>er,expandRedirectTarget:()=>Br,expandWord:()=>J,expandWordForPattern:()=>Xa,expandWordForRegex:()=>Ka,expandWordWithGlob:()=>Ft,getArrayElements:()=>te,getVariable:()=>me,hasQuotedMultiValueAt:()=>Wr,isArray:()=>Qt,isWordFullyQuoted:()=>Qa});async function Dt(e,t,n=!1){let r=[];for(let s of t)r.push(await At(e,s,n));return r.join("")}function hN(e){return C0(e)}function Qa(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!hN(t))return!1;return!0}function mN(e,t,n=!1){let r=A0(t);if(r!==null)return r;switch(t.type){case"TildeExpansion":return n?t.user===null?"~":`~${t.user}`:t.user===null?e.state.env.HOME!==void 0?e.state.env.HOME:"/home/user":t.user==="root"?"/root":`~${t.user}`;case"Glob":return Ga(e,t.pattern);default:return null}}async function J(e,t){return Ja(e,t)}async function Ka(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped")n.push(`\\${r.value}`);else if(r.type==="SingleQuoted")n.push(r.value);else if(r.type==="DoubleQuoted"){let s=await Dt(e,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await At(e,r);n.push(er(s))}else n.push(await At(e,r));return n.join("")}async function Xa(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped"){let s=r.value;"()|*?[]".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="SingleQuoted")n.push(mt(r.value));else if(r.type==="DoubleQuoted"){let s=await Dt(e,r.parts);n.push(mt(s))}else n.push(await At(e,r));return n.join("")}async function k0(e,t){let n=[];for(let r of t.parts)if(r.type==="SingleQuoted")n.push(mt(r.value));else if(r.type==="Escaped"){let s=r.value;"*?[]\\()|".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="DoubleQuoted"){let s=await Dt(e,r.parts);n.push(mt(s))}else r.type==="Glob"?Rg(r.pattern)?n.push(await Tg(e,r.pattern)):n.push(Ga(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await At(e,r));return n.join("")}function pi(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&pi(t.parts))return!0;return!1}async function v0(e,t,n={count:0}){if(n.count>Za)return[[]];let r=[[]];for(let s of t)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=ja(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let p of f.expanded)n.count++,i.push(p);else{o=!0,a=f.literal;break}}else{let f=await v0(e,u.word.parts,n);for(let p of f){n.count++;let d=[];for(let m of p)typeof m=="string"?d.push(m):d.push(await At(e,m));i.push(d.join(""))}}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>gN||n.count>Za)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>Za)return c.length>0?c:r;c.push([...u,f])}r=c}else for(let i of r)n.count++,i.push(s);return r}async function $0(e,t){let n=t.parts;if(!pi(n))return[await J(e,t)];let r=await v0(e,n),s=[];for(let i of r){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await At(e,a));s.push(Dg(e,o.join("")))}return s}function yN(){return{expandWordAsync:Ja,expandWordForGlobbing:k0,expandWordWithBracesAsync:$0,expandWordPartsAsync:Dt,expandPart:At,expandParameterAsync:fi,hasBraceExpansion:pi,evaluateArithmetic:Q,buildIfsCharClassPattern:sg,smartWordSplit:E0}}async function Ft(e,t){return y0(e,t,yN())}function bN(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function Wr(e,t){if(Number.parseInt(e.state.env["#"]||"0",10)<2)return!1;function r(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return r(t.parts)}async function Br(e,t){if(Wr(e,t))return{error:`bash: $@: ambiguous redirect
760
+ `);let u=te(e,c),f=0;if(s<0){if(u.length>0){let p=u[u.length-1][0],m=(typeof p=="number"?p:0)+1+s;if(m<0||(f=u.findIndex(([h])=>typeof h=="number"&&h>=m),f<0))return""}}else if(f=u.findIndex(([p])=>typeof p=="number"&&p>=s),f<0)return"";if(i!==void 0){if(i<0)throw new Ee(`${o[1]}[@]: substring expression < 0`);return u.slice(f,f+i).map(([,p])=>p).join(" ")}return u.slice(f).map(([,p])=>p).join(" ")}let a=[...n],l=s;if(l<0&&(l=Math.max(0,a.length+l)),i!==void 0){if(i<0){let c=a.length+i;return a.slice(l,Math.max(l,c)).join("")}return a.slice(l,l+i).join("")}return a.slice(l).join("")}async function Ag(e,t,n,r,s){if(n.pattern){let i=e.state.shoptOptions.extglob,o="";for(let f of n.pattern.parts)if(f.type==="Glob")o+=ce(f.pattern,!0,i);else if(f.type==="Literal")o+=ce(f.value,!0,i);else if(f.type==="SingleQuoted"||f.type==="Escaped")o+=pe(f.value);else if(f.type==="DoubleQuoted"){let p=await r(e,f.parts);o+=pe(p)}else if(f.type==="ParameterExpansion"){let p=await s(e,f);o+=ce(p,!0,i)}let a=new RegExp(`^(?:${o})$`),l=n.direction==="upper"?f=>f.toUpperCase():f=>f.toLowerCase(),c="",u=!1;for(let f of t)!n.all&&u?c+=f:a.test(f)?(c+=l(f),u=!0):c+=f;return c}return n.direction==="upper"?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function Cg(e,t,n,r,s){let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(i&&s.operator==="Q")return te(e,i[1]).map(([,c])=>sn(c)).join(" ");if(i&&s.operator==="a")return an(e,i[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&s.operator==="a")return an(e,o[1]);switch(s.operator){case"Q":return r?"":sn(n);case"P":return Mr(e,n);case"a":return an(e,t);case"A":return r?"":`${t}=${sn(n)}`;case"E":return n.replace(/\\([\\abefnrtv'"?])/g,(a,l)=>{switch(l){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
761
+ `;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 r?"":sn(n);case"u":return n.charAt(0).toUpperCase()+n.slice(1);case"U":return n.toUpperCase();case"L":return n.toLowerCase();default:return n}}async function Ng(e,t,n,r,s,i,o=!1){if(Se(e,t))return kn(e,t)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new nt(`\${!${t}}`)}let l=n;if(a&&(l===""||l.includes(" ")))throw new nt(`\${!${t}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new nt(`\${!${t}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(e,u,o)}return await me(e,l)}function kg(e,t){let r=te(e,t.array).map(([s])=>String(s));return t.star?r.join(oe(e.state.env)):r.join(" ")}function vg(e,t){let n=sr(e,t.prefix);return t.star?n.join(oe(e.state.env)):n.join(" ")}function $g(e,t,n,r){let s=Number.parseInt(e.state.env["#"]||"0",10),i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t==="*")return{isEmpty:s===0,effectiveValue:n};if(t==="@")return{isEmpty:s===0||s===1&&e.state.env[1]==="",effectiveValue:n};if(i){let[,o,a]=i,l=te(e,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=oe(e.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:r?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:n==="",effectiveValue:n}}var Ig=v(()=>{"use strict";Je();Fe();it();de();St();Tt();nr();rr();vn();Va();qa();ht();ai()});function Rg(e){let t=0;for(;t<e.length;){let n=e[t];if(n==="\\"&&t+1<e.length){t+=2;continue}if(n==="'"){let r=e.indexOf("'",t+1);if(r!==-1){t=r+1;continue}}if(n==="$"&&t+1<e.length&&e[t+1]==="("||n==="`")return!0;t++}return!1}function Pg(e,t){let n=1,r=t,s=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r];if(o==="\\"&&!s&&r+1<e.length){r+=2;continue}if(o==="'"&&!i){s=!s,r++;continue}if(o==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(o==="(")n++;else if(o===")"&&(n--,n===0))return r}r++}return-1}async function li(e,t){let n=new se,r;try{r=n.parse(t)}catch{return""}let s=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let i={...e.state.env},o=e.state.cwd,a=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let l=await e.executeScript(r),c=l.exitCode;return e.state.env=i,e.state.cwd=o,e.state.suppressVerbose=a,e.state.lastExitCode=c,e.state.env["?"]=String(c),l.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+l.stderr),e.state.bashPid=s,l.stdout.replace(/\n+$/,"")}catch(l){if(e.state.env=i,e.state.cwd=o,e.state.bashPid=s,e.state.suppressVerbose=a,l instanceof ne)throw l;return l instanceof ae?(e.state.lastExitCode=l.exitCode,e.state.env["?"]=String(l.exitCode),l.stdout?.replace(/\n+$/,"")??""):""}}function Ga(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=mt(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=KC(e,a);n+=mt(l),r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}function KC(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}n+=s,r++}return n}async function Tg(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=mt(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=await XC(e,a);n+=mt(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=Pg(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}async function XC(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=Pg(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await li(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env[a]??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env[a]??"",r=o;continue}}n+=s,r++}return n}var Og=v(()=>{"use strict";Fe();de();tr()});function Dg(e,t){if(!t.startsWith("~"))return t;let n=e.state.env.HOME!==void 0?e.state.env.HOME:"/home/user";if(t==="~"||t.startsWith("~/"))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let s=t.slice(1,r),i=t.slice(r);return i!==""&&!i.startsWith("/")?t:s==="root"?`/root${i}`:t}var Fg=v(()=>{"use strict"});async function JC(e,t,n,r){let s="";for(let i of t.parts)if(i.type==="Glob")s+=ce(i.pattern,!0,e.state.shoptOptions.extglob);else if(i.type==="Literal")s+=ce(i.value,!0,e.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=pe(i.value);else if(i.type==="DoubleQuoted"){let o=await n(e,i.parts);s+=pe(o)}else if(i.type==="ParameterExpansion"){let o=await r(e,i);s+=ce(o,!0,e.state.shoptOptions.extglob)}else{let o=await r(e,i);s+=pe(o)}return s}async function _g(e,t,n,r){if(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!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=te(e,a),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env[a];g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let p="";c.pattern&&(p=await JC(e,c.pattern,n,r));let d=c.replacement?await n(e,c.replacement.parts):"",m=p;c.anchor==="start"?m=`^${p}`:c.anchor==="end"&&(m=`${p}$`);let h=[];try{let g=new RegExp(m,c.all?"g":"");for(let b of f)h.push(b.replace(g,d))}catch{h.push(...f)}if(l){let g=oe(e.state.env);return{values:[h.join(g)],quoted:!0}}return{values:h,quoted:!0}}async function Lg(e,t,n,r){if(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!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=te(e,a),f=u.map(([,h])=>h);if(u.length===0){let h=e.state.env[a];h!==void 0&&f.push(h)}if(f.length===0)return{values:[],quoted:!0};let p="",d=e.state.shoptOptions.extglob;if(c.pattern)for(let h of c.pattern.parts)if(h.type==="Glob")p+=ce(h.pattern,c.greedy,d);else if(h.type==="Literal")p+=ce(h.value,c.greedy,d);else if(h.type==="SingleQuoted"||h.type==="Escaped")p+=pe(h.value);else if(h.type==="DoubleQuoted"){let g=await n(e,h.parts);p+=pe(g)}else if(h.type==="ParameterExpansion"){let g=await r(e,h);p+=ce(g,c.greedy,d)}else{let g=await r(e,h);p+=pe(g)}let m=[];for(let h of f)m.push(Kt(h,p,c.side,c.greedy));if(l){let h=oe(e.state.env);return{values:[m.join(h)],quoted:!0}}return{values:m,quoted:!0}}var Mg=v(()=>{"use strict";St();nr();rr();vn();ht()});async function Wg(e,t){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!=="DefaultValue"&&n.parts[0].operation?.type!=="UseAlternative"&&n.parts[0].operation?.type!=="AssignDefault")return null;let r=n.parts[0],s=r.operation,i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=te(e,l),u=c.length>0||e.state.env[l]!==void 0,f=c.length===0||c.length===1&&c.every(([,d])=>d===""),p=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(p&&f):o=!u||p&&f,!o){if(c.length>0){let m=c.map(([,h])=>h);if(a){let h=oe(e.state.env);return{values:[m.join(h)],quoted:!0}}return{values:m,quoted:!0}}let d=e.state.env[l];return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await zt(e,l),u=await me(e,l),f=u==="",p=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(p&&f):o=!c||p&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let p=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(p){c=p[1],u=p[2]==="*";break}}if(c){let f=te(e,c);if(f.length>0){let d=f.map(([,m])=>m);if(u||a){let m=oe(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}let p=e.state.env[c];return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}}return null}async function Bg(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],o=-1,a="",l=!1,c=null;for(let h=0;h<i.parts.length;h++){let g=i.parts[h];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let b=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){o=h,a=b[1],l=b[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let h=0;h<o;h++)u+=await r(e,i.parts[h]);let f="";for(let h=o+1;h<i.parts.length;h++)f+=await r(e,i.parts[h]);let p=te(e,a),d=p.map(([,h])=>h);if(p.length===0){let h=e.state.env[a];if(h!==void 0)d=[h];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let h=c,g="",b=e.state.shoptOptions.extglob;if(h.pattern)for(let y of h.pattern.parts)if(y.type==="Glob")g+=ce(y.pattern,h.greedy,b);else if(y.type==="Literal")g+=ce(y.value,h.greedy,b);else if(y.type==="SingleQuoted"||y.type==="Escaped")g+=pe(y.value);else if(y.type==="DoubleQuoted"){let w=await s(e,y.parts);g+=pe(w)}else if(y.type==="ParameterExpansion"){let w=await r(e,y);g+=ce(w,h.greedy,b)}else{let w=await r(e,y);g+=pe(w)}d=d.map(y=>Kt(y,g,h.side,h.greedy))}else if(c?.type==="PatternReplacement"){let h=c,g="";if(h.pattern)for(let w of h.pattern.parts)if(w.type==="Glob")g+=ce(w.pattern,!0,e.state.shoptOptions.extglob);else if(w.type==="Literal")g+=ce(w.value,!0,e.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")g+=pe(w.value);else if(w.type==="DoubleQuoted"){let E=await s(e,w.parts);g+=pe(E)}else if(w.type==="ParameterExpansion"){let E=await r(e,w);g+=ce(E,!0,e.state.shoptOptions.extglob)}else{let E=await r(e,w);g+=pe(E)}let b=h.replacement?await s(e,h.replacement.parts):"",y=g;h.anchor==="start"?y=`^${g}`:h.anchor==="end"&&(y=`${g}$`);try{let w=new RegExp(y,h.all?"g":"");d=d.map(E=>E.replace(w,b))}catch{}}if(l){let h=oe(e.state.env);return{values:[u+d.join(h)+f],quoted:!0}}return d.length===1?{values:[u+d[0]+f],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+f],quoted:!0}}async function Ug(e,t,n,r){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o="",a=!1;for(let d=0;d<s.parts.length;d++){let m=s.parts[d];if(m.type==="ParameterExpansion"&&!m.operation){let h=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){i=d,o=h[1],a=h[2]==="*";break}}}if(i===-1)return null;let l="";for(let d=0;d<i;d++)l+=await r(e,s.parts[d]);let c="";for(let d=i+1;d<s.parts.length;d++)c+=await r(e,s.parts[d]);let u=te(e,o),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env[o];if(d!==void 0)return{values:[l+d+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let m=l+c;return{values:m?[m]:[],quoted:!0}}if(a){let d=oe(e.state.env);return{values:[l+f.join(d)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var zg=v(()=>{"use strict";St();nr();rr();vn();ht()});async function jg(e,t,n){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!=="Substring")return null;let s=r.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(e.state.associativeArrays?.has(o))throw new ae(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
762
+ `);let c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=te(e,o),p=0;if(c<0){if(f.length>0){let m=f[f.length-1][0],g=(typeof m=="number"?m:0)+1+c;if(g<0)return{values:[],quoted:!0};p=f.findIndex(([b])=>typeof b=="number"&&b>=g),p<0&&(p=f.length)}}else p=f.findIndex(([m])=>typeof m=="number"&&m>=c),p<0&&(p=f.length);let d;if(u!==void 0){if(u<0)throw new Ee(`${o}[@]: substring expression < 0`);d=f.slice(p,p+u).map(([,m])=>m)}else d=f.slice(p).map(([,m])=>m);if(d.length===0)return{values:[],quoted:!0};if(a){let m=oe(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}function Hg(e,t){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!=="Transform")return null;let r=n.parts[0],s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=r.operation,l=te(e,i);if(l.length===0){let f=e.state.env[i];if(f!==void 0){let p;switch(a.operator){case"a":p="";break;case"P":p=Mr(e,f);break;case"Q":p=sn(f);break;default:p=f}return{values:[p],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=an(e,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>Mr(e,f));break;case"Q":u=l.map(([,f])=>sn(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=oe(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var Vg=v(()=>{"use strict";de();St();Va();qa();ht();ai()});function qg(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion")return null;let r=n.parts[0];if(r.operation)return null;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(Se(e,i)){let l=kn(e,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=te(e,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=e.state.env[i];return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function Gg(e,t){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)return null;let s=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!Se(e,s))return null;let i=kn(e,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=te(e,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=e.state.env[a];return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var Zg=v(()=>{"use strict";Tt();ht()});async function Qg(e,t,n,r,s){if(!n||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!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await me(e,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let m=Number.parseInt(e.state.env["#"]||"0",10),h=[];for(let g=1;g<=m;g++)h.push(e.state.env[String(g)]||"");return l==="*"?{values:[h.join(oe(e.state.env))],quoted:!0}:{values:h,quoted:!0}}return null}let u=c[1],f=c[2]==="*",p=te(e,u);if(a.innerOp){if(a.innerOp.type==="Substring")return YC(e,p,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return eN(e,p,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let h=an(e,u),g=p.map(()=>h);return f?{values:[g.join(oe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let m=[];for(let[,h]of p){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},b=e.state.env._indirect_elem_;e.state.env._indirect_elem_=h;try{let y=await r(e,g,!0);m.push(y)}finally{b!==void 0?e.state.env._indirect_elem_=b:delete e.state.env._indirect_elem_}}return f?{values:[m.join(oe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(p.length>0){let m=p.map(([,h])=>h);return f?{values:[m.join(oe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let d=e.state.env[u];return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function YC(e,t,n,r,s){let i=s.offset?await Q(e,s.offset.expression):0,o=s.length?await Q(e,s.length.expression):void 0,a=0;if(i<0){if(t.length>0){let u=t[t.length-1][0],p=(typeof u=="number"?u:0)+1+i;if(p<0)return{values:[],quoted:!0};if(a=t.findIndex(([d])=>typeof d=="number"&&d>=p),a<0)return{values:[],quoted:!0}}}else if(a=t.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new Ee(`${n}[@]: substring expression < 0`);l=t.slice(a,a+o)}else l=t.slice(a);let c=l.map(([,u])=>u);return r?{values:[c.join(oe(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function eN(e,t,n,r,s,i){let o=s.checkEmpty??!1,a=t.map(([,u])=>u),l=t.length===0,c=t.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:r?{values:[a.join(oe(e.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(e,s.word.parts,!0);return e.state.env[`${n}_0`]=f,e.state.env[`${n}__length`]="1",{values:[f],quoted:!0}}return r?{values:[a.join(oe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}return r?{values:[a.join(oe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}async function Kg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="UseAlternative"&&t[0].operation?.type!=="DefaultValue")return null;let n=t[0],r=n.operation,s=r?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await me(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await zt(e,n.parameter),u=await me(e,n.parameter)==="",f=r.checkEmpty??!1,p;if(r.type==="UseAlternative"?p=c&&!(f&&u):p=!c||f&&u,p){let d=l[1],m=l[2]==="*",h=te(e,d);if(h.length>0){let b=h.map(([,y])=>y);return m?{values:[b.join(oe(e.state.env))],quoted:!0}:{values:b,quoted:!0}}let g=e.state.env[d];return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function Xg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="Indirection")return null;let n=t[0],s=n.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await me(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await me(e,n.parameter),f=await zt(e,n.parameter),p=u==="",d=s.checkEmpty??!1,m;if(s.type==="UseAlternative"?m=f&&!(d&&p):m=!f||d&&p,m){let h=c[1],g=c[2]==="*",b=te(e,h);if(b.length>0){let w=b.map(([,E])=>E);return g?{values:[w.join(oe(e.state.env))],quoted:!0}:{values:w,quoted:!0}}let y=e.state.env[h];return y!==void 0?{values:[y],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var Jg=v(()=>{"use strict";it();de();St();ht();ai()});function Yg(e){let t=Number.parseInt(e.state.env["#"]||"0",10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env[String(r)]||"");return n}async function e0(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let w=s.parts[y];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="Substring"){i=y,o=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=Number.parseInt(e.state.env["#"]||"0",10),p=[];for(let y=1;y<=f;y++)p.push(e.state.env[String(y)]||"");let d=e.state.env[0]||"bash",m;if(c<=0){let y=[d,...p],w=y.length+c;if(w<0)m=[];else{let E=c<0?w:0;if(u!==void 0){let C=u<0?y.length+u:E+u;m=y.slice(E,Math.max(E,C))}else m=y.slice(E)}}else{let y=c-1;if(y>=p.length)m=[];else if(u!==void 0){let w=u<0?p.length+u:y+u;m=p.slice(y,Math.max(y,w))}else m=p.slice(y)}let h="";for(let y=0;y<i;y++)h+=await r(e,s.parts[y]);let g="";for(let y=i+1;y<s.parts.length;y++)g+=await r(e,s.parts[y]);if(m.length===0){let y=h+g;return{values:y?[y]:[],quoted:!0}}if(o){let y=oe(e.state.env);return{values:[h+m.join(y)+g],quoted:!0}}return m.length===1?{values:[h+m[0]+g],quoted:!0}:{values:[h+m[0],...m.slice(1,-1),m[m.length-1]+g],quoted:!0}}async function t0(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let b=0;b<s.parts.length;b++){let y=s.parts[b];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternReplacement"){i=b,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=Yg(e),u="";for(let b=0;b<i;b++)u+=await n(e,s.parts[b]);let f="";for(let b=i+1;b<s.parts.length;b++)f+=await n(e,s.parts[b]);if(c.length===0){let b=u+f;return{values:b?[b]:[],quoted:!0}}let p="";if(l.pattern)for(let b of l.pattern.parts)if(b.type==="Glob")p+=ce(b.pattern,!0,e.state.shoptOptions.extglob);else if(b.type==="Literal")p+=ce(b.value,!0,e.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")p+=pe(b.value);else if(b.type==="DoubleQuoted"){let y=await r(e,b.parts);p+=pe(y)}else if(b.type==="ParameterExpansion"){let y=await n(e,b);p+=ce(y,!0,e.state.shoptOptions.extglob)}else{let y=await n(e,b);p+=pe(y)}let d=l.replacement?await r(e,l.replacement.parts):"",m=p;l.anchor==="start"?m=`^${p}`:l.anchor==="end"&&(m=`${p}$`);let h=[];try{let b=new RegExp(m,l.all?"g":"");for(let y of c)h.push(y.replace(b,d))}catch{h.push(...c)}if(o){let b=oe(e.state.env);return{values:[u+h.join(b)+f],quoted:!0}}return h.length===1?{values:[u+h[0]+f],quoted:!0}:{values:[u+h[0],...h.slice(1,-1),h[h.length-1]+f],quoted:!0}}async function n0(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let b=s.parts[g];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="PatternRemoval"){i=g,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=Yg(e),u="";for(let g=0;g<i;g++)u+=await n(e,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await n(e,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let p="",d=e.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")p+=ce(g.pattern,l.greedy,d);else if(g.type==="Literal")p+=ce(g.value,l.greedy,d);else if(g.type==="SingleQuoted"||g.type==="Escaped")p+=pe(g.value);else if(g.type==="DoubleQuoted"){let b=await r(e,g.parts);p+=pe(b)}else if(g.type==="ParameterExpansion"){let b=await n(e,g);p+=ce(b,l.greedy,d)}else{let b=await n(e,g);p+=pe(b)}let m=[];for(let g of c)m.push(Kt(g,p,l.side,l.greedy));if(o){let g=oe(e.state.env);return{values:[u+m.join(g)+f],quoted:!0}}return m.length===1?{values:[u+m[0]+f],quoted:!0}:{values:[u+m[0],...m.slice(1,-1),m[m.length-1]+f],quoted:!0}}async function r0(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0],s=-1,i=!1;for(let p=0;p<r.parts.length;p++){let d=r.parts[p];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")){s=p,i=d.parameter==="*";break}}if(s===-1)return null;let o=r.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(e.state.env["#"]||"0",10),l="";for(let p=0;p<s;p++)l+=await n(e,r.parts[p]);let c="";for(let p=s+1;p<r.parts.length;p++)c+=await n(e,r.parts[p]);if(a===0){if(i)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}let u=[];for(let p=1;p<=a;p++)u.push(e.state.env[String(p)]||"");if(i){let p=oe(e.state.env);return{values:[l+u.join(p)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var s0=v(()=>{"use strict";St();nr();rr();vn()});function tN(e){return new rn(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})}async function ci(e,t){if(e.state.options.noglob)return t;let n=tN(e),r=[];for(let s of t)if(jt(s,e.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new _t(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function i0(e,t,n,r){let s=-1,i="",o=!1;for(let y=0;y<t.length;y++){let w=t[y];if(w.type==="ParameterExpansion"&&w.operation?.type==="PatternReplacement"){let E=w.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(E){s=y,i=E[1],o=E[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=te(e,i),u=c.map(([,y])=>y);if(c.length===0){let y=e.state.env[i];y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=ce(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")f+=ce(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=pe(y.value);else if(y.type==="DoubleQuoted"){let w=await n(e,y.parts);f+=pe(w)}else if(y.type==="ParameterExpansion"){let w=await r(e,y);f+=ce(w,!0,e.state.shoptOptions.extglob)}else{let w=await r(e,y);f+=pe(w)}let p=l.replacement?await n(e,l.replacement.parts):"",d=f;l.anchor==="start"?d=`^${f}`:l.anchor==="end"&&(d=`${f}$`);let m=[];try{let y=new RegExp(d,l.all?"g":"");for(let w of u)m.push(w.replace(y,p))}catch{m.push(...u)}let h=Ue(e.state.env),g=Ze(e.state.env);if(o){let y=oe(e.state.env),w=m.join(y);return g?{values:w?[w]:[],quoted:!1}:{values:Ae(w,h),quoted:!1}}if(g)return{values:m,quoted:!1};let b=[];for(let y of m)y===""?b.push(""):b.push(...Ae(y,h));return{values:b,quoted:!1}}async function o0(e,t,n,r){let s=-1,i="",o=!1;for(let b=0;b<t.length;b++){let y=t[b];if(y.type==="ParameterExpansion"&&y.operation?.type==="PatternRemoval"){let w=y.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(w){s=b,i=w[1],o=w[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=te(e,i),u=c.map(([,b])=>b);if(c.length===0){let b=e.state.env[i];b!==void 0&&(u=[b])}if(u.length===0)return{values:[],quoted:!1};let f="",p=e.state.shoptOptions.extglob;if(l.pattern)for(let b of l.pattern.parts)if(b.type==="Glob")f+=ce(b.pattern,l.greedy,p);else if(b.type==="Literal")f+=ce(b.value,l.greedy,p);else if(b.type==="SingleQuoted"||b.type==="Escaped")f+=pe(b.value);else if(b.type==="DoubleQuoted"){let y=await n(e,b.parts);f+=pe(y)}else if(b.type==="ParameterExpansion"){let y=await r(e,b);f+=ce(y,l.greedy,p)}else{let y=await r(e,b);f+=pe(y)}let d=[];for(let b of u)d.push(Kt(b,f,l.side,l.greedy));let m=Ue(e.state.env),h=Ze(e.state.env);if(o){let b=oe(e.state.env),y=d.join(b);return h?{values:y?[y]:[],quoted:!1}:{values:Ae(y,m),quoted:!1}}if(h)return{values:d,quoted:!1};let g=[];for(let b of d)b===""?g.push(""):g.push(...Ae(b,m));return{values:g,quoted:!1}}async function a0(e,t,n,r){let s=-1,i=!1;for(let g=0;g<t.length;g++){let b=t[g];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="PatternRemoval"){s=g,i=b.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=Number.parseInt(e.state.env["#"]||"0",10),c=[];for(let g=1;g<=l;g++)c.push(e.state.env[String(g)]||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=e.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=ce(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=ce(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=pe(g.value);else if(g.type==="DoubleQuoted"){let b=await n(e,g.parts);u+=pe(b)}else if(g.type==="ParameterExpansion"){let b=await r(e,g);u+=ce(b,a.greedy,f)}else{let b=await r(e,g);u+=pe(b)}let p=[];for(let g of c)p.push(Kt(g,u,a.side,a.greedy));let d=Ue(e.state.env),m=Ze(e.state.env);if(i){let g=oe(e.state.env),b=p.join(g);return m?{values:b?[b]:[],quoted:!1}:{values:Ae(b,d),quoted:!1}}if(m)return{values:p,quoted:!1};let h=[];for(let g of p)g===""?h.push(""):h.push(...Ae(g,d));return{values:h,quoted:!1}}async function l0(e,t,n,r){let s=-1,i=!1;for(let w=0;w<t.length;w++){let E=t[w];if(E.type==="ParameterExpansion"&&(E.parameter==="@"||E.parameter==="*")&&E.operation?.type==="Substring"){s=w,i=E.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=a.offset?await n(e,a.offset.expression):0,c=a.length?await n(e,a.length.expression):void 0,u=Number.parseInt(e.state.env["#"]||"0",10),f=[];for(let w=1;w<=u;w++)f.push(e.state.env[String(w)]||"");let p=e.state.env[0]||"bash",d;if(l<=0){let w=[p,...f],E=w.length+l;if(E<0)d=[];else{let C=l<0?E:0;if(c!==void 0){let A=c<0?w.length+c:C+c;d=w.slice(C,Math.max(C,A))}else d=w.slice(C)}}else{let w=l-1;if(w>=f.length)d=[];else if(c!==void 0){let E=c<0?f.length+c:w+c;d=f.slice(w,Math.max(w,E))}else d=f.slice(w)}let m="";for(let w=0;w<s;w++)m+=await r(e,t[w]);let h="";for(let w=s+1;w<t.length;w++)h+=await r(e,t[w]);let g=Ue(e.state.env),b=Ze(e.state.env);if(d.length===0){let w=m+h;return w?b?{values:[w],quoted:!1}:{values:Ae(w,g),quoted:!1}:{values:[],quoted:!1}}let y;if(i){let w=oe(e.state.env),E=m+d.join(w)+h;b?y=E?[E]:[]:y=Ae(E,g)}else if(b)d.length===1?y=[m+d[0]+h]:y=[m+d[0],...d.slice(1,-1),d[d.length-1]+h];else{y=[];for(let w=0;w<d.length;w++){let E=d[w];if(w===0&&(E=m+E),w===d.length-1&&(E=E+h),E==="")y.push("");else{let C=Ae(E,g);y.push(...C)}}}return{values:await ci(e,y),quoted:!1}}async function c0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].parameter!=="@"&&t[0].parameter!=="*"||t[0].operation)return null;let n=t[0].parameter==="*",r=Number.parseInt(e.state.env["#"]||"0",10);if(r===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=r;c++)s.push(e.state.env[String(c)]||"");let i=Ue(e.state.env),o=Ze(e.state.env),a=ni(e.state.env),l;if(n)if(o)l=s.filter(c=>c!=="");else{let c=oe(e.state.env),u=s.join(c);l=Ae(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=Ae(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=Ae(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await ci(e,l),quoted:!1}}async function u0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],s=n[2]==="*",i=te(e,r),o;if(i.length===0){let f=e.state.env[r];if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=Ue(e.state.env),l=Ze(e.state.env),c=ni(e.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=oe(e.state.env),p=o.join(f);u=Ae(p,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let p=Ae(f,a);u.push(...p)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let p=Ae(f,a);u.push(...p)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await ci(e,u),quoted:!1}}function f0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=sr(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=Ue(e.state.env),i=Ze(e.state.env),o;if(n.star)if(i)o=r;else{let a=oe(e.state.env),l=r.join(a);o=Ae(l,s)}else if(i)o=r;else{o=[];for(let a of r){let l=Ae(a,s);o.push(...l)}}return{values:o,quoted:!1}}function p0(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="ArrayKeys")return null;let n=t[0].operation,s=te(e,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=Ue(e.state.env),o=Ze(e.state.env),a;if(n.star)if(o)a=s;else{let l=oe(e.state.env),c=s.join(l);a=Ae(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=Ae(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function d0(e,t,n){let r=-1;for(let p=0;p<t.length;p++){let d=t[p];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")&&!d.operation){r=p;break}}if(r===-1||t.length<=1)return null;let s=Number.parseInt(e.state.env["#"]||"0",10),i=[];for(let p=1;p<=s;p++)i.push(e.state.env[String(p)]||"");let o="";for(let p=0;p<r;p++)o+=await n(e,t[p]);let a="";for(let p=r+1;p<t.length;p++)a+=await n(e,t[p]);let l=Ue(e.state.env),c=Ze(e.state.env),u=ni(e.state.env);if(s===0){let p=o+a;return{values:p?[p]:[],quoted:!1}}let f;{let p=[];for(let d=0;d<i.length;d++){let m=i[d];d===0&&(m=o+m),d===i.length-1&&(m=m+a),p.push(m)}if(c)f=p.filter(d=>d!=="");else if(u){f=[];for(let d of p){if(d==="")continue;let m=Ae(d,l);f.push(...m)}}else{f=[];for(let d of p)if(d==="")f.push("");else{let m=Ae(d,l);f.push(...m)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await ci(e,f),quoted:!1}}var h0=v(()=>{"use strict";Ys();de();St();nr();tr();rr();vn();ht()});async function y0(e,t,n){let r=t.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=Lr(r),p=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(p&&p.length>1)return nN(e,p,s);let d=await rN(e,r,a,c,u,n);if(d!==null)return d;let m=await iN(e,r,n);if(m!==null)return m;let h=await oN(e,r,n);if(h!==null)return h;let g=await lN(e,r,n.expandPart);if(g!==null)return g0(e,g);if((i||o||l)&&!Ze(e.state.env)){let y=Ue(e.state.env),w=n.buildIfsCharClassPattern(y),E=await n.smartWordSplit(e,r,y,w,n.expandPart);return g0(e,E)}let b=await n.expandWordAsync(e,t);return cN(e,t,r,b,s,n.expandWordForGlobbing)}async function nN(e,t,n){let r=[];for(let s of t)if(!(!n&&s===""))if(!n&&!e.state.options.noglob&&jt(s,e.state.shoptOptions.extglob)){let i=await ui(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function rN(e,t,n,r,s,i){if(n){let o=qg(e,t);if(o!==null)return o}{let o=Gg(e,t);if(o!==null)return o}{let o=await Wg(e,t);if(o!==null)return o}{let o=await Bg(e,t,n,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await Ug(e,t,n,i.expandPart);if(o!==null)return o}{let o=await jg(e,t,i.evaluateArithmetic);if(o!==null)return o}{let o=Hg(e,t);if(o!==null)return o}{let o=await _g(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await Lg(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let o=sN(e,t);if(o!==null)return o}{let o=await Qg(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await Kg(e,t);if(o!==null)return o}{let o=await Xg(e,t);if(o!==null)return o}return null}function sN(e,t){let n=t[0];if(n.type!=="DoubleQuoted")return null;if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="VarNamePrefix"){let r=n.parts[0].operation,s=sr(e,r.prefix);return r.star?{values:[s.join(oe(e.state.env))],quoted:!0}:{values:s,quoted:!0}}if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="ArrayKeys"){let r=n.parts[0].operation,i=te(e,r.array).map(([o])=>String(o));return r.star?{values:[i.join(oe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function iN(e,t,n){{let r=await e0(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await t0(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await n0(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await r0(e,t,n.expandPart);if(r!==null)return r}return null}async function oN(e,t,n){{let r=await i0(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await o0(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await a0(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await l0(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await c0(e,t);if(r!==null)return r}{let r=await u0(e,t);if(r!==null)return r}{let r=f0(e,t);if(r!==null)return r}{let r=p0(e,t);if(r!==null)return r}{let r=await d0(e,t,n.expandPart);if(r!==null)return r}return null}function m0(e){if(e.type!=="DoubleQuoted")return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!=="ParameterExpansion"||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:"array",name:r[1],atIndex:t,isStar:r[2]==="*"};if(n.parameter==="@"||n.parameter==="*")return{type:"positional",atIndex:t,isStar:n.parameter==="*"}}return null}async function aN(e,t,n,r){let s="";for(let a=0;a<n.atIndex;a++)s+=await r(e,t.parts[a]);let i="";for(let a=n.atIndex+1;a<t.parts.length;a++)i+=await r(e,t.parts[a]);let o;if(n.type==="array"){if(o=te(e,n.name).map(([,l])=>l),o.length===0){let l=e.state.env[n.name];l!==void 0&&(o=[l])}}else{let a=Number.parseInt(e.state.env["#"]||"0",10);o=[];for(let l=1;l<=a;l++)o.push(e.state.env[String(l)]||"")}if(n.isStar){let a=oe(e.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function lN(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(m0(l)){r=!0;break}if(!r)return null;let s=Ue(e.state.env),i=Ze(e.state.env),o=[];for(let l of t){let c=m0(l);if(c&&l.type==="DoubleQuoted"){let u=await aN(e,l,c,n);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(e,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Ae(u,s);o.push(f)}}else{let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Ae(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function g0(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(jt(r,e.state.shoptOptions.extglob)){let s=await ui(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function ui(e,t){let n=new rn(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}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new _t(t);return n.hasNullglob()?[]:[t]}async function cN(e,t,n,r,s,i){let o=n.some(a=>a.type==="Glob");if(!e.state.options.noglob&&o){let a=await i(e,t);if(jt(a,e.state.shoptOptions.extglob)){let c=await ui(e,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=Ha(r);if(!Ze(e.state.env)){let c=Ue(e.state.env);return{values:Ae(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!e.state.options.noglob&&jt(r,e.state.shoptOptions.extglob)){let a=await i(e,t);if(jt(a,e.state.shoptOptions.extglob)){let l=await ui(e,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=Ha(r);if(!Ze(e.state.env)){let l=Ue(e.state.env);return{values:Ae(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[r],quoted:s}}var b0=v(()=>{"use strict";Ys();de();St();ei();Mg();zg();Vg();Zg();tr();Jg();vn();s0();h0();ht()});async function x0(e,t){let n=t.operation;if(!n||n.type!=="DefaultValue"&&n.type!=="AssignDefault"&&n.type!=="UseAlternative")return null;let r=n.word;if(!r||r.parts.length===0)return null;let s=await zt(e,t.parameter),o=await me(e,t.parameter,!1)==="",a=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?r.parts:null}function uN(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function fN(e,t){if(t.type!=="ParameterExpansion")return null;let n=await x0(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>uN(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function pN(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?La(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&rg(e))}async function E0(e,t,n,r,s){if(t.length===1&&t[0].type==="ParameterExpansion"){let p=t[0],d=await x0(e,p);if(d&&d.length>0&&d.length>1&&d.some(h=>h.type==="DoubleQuoted"||h.type==="SingleQuoted")&&d.some(h=>h.type==="Literal"||h.type==="ParameterExpansion"||h.type==="CommandSubstitution"||h.type==="ArithmeticExpansion"))return w0(e,d,n,r,s)}let i=[],o=!1;for(let p of t){let d=pN(p),m=p.type==="DoubleQuoted"||p.type==="SingleQuoted",h=d?await fN(e,p):null,g=await s(e,p);i.push({value:g,isSplittable:d,isQuoted:m,mixedDefaultParts:h??void 0}),d&&(o=!0)}if(!o){let p=i.map(d=>d.value).join("");return p?[p]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let p of i)if(!p.isSplittable)u?p.isQuoted&&p.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):p.value!==""?(l!==""&&a.push(l),l=p.value,u=!1,f=!1):(l+=p.value,f=!1):(l+=p.value,f=p.isQuoted&&p.value==="");else if(p.mixedDefaultParts){let d=await w0(e,p.mixedDefaultParts,n,r,s);if(d.length!==0)if(d.length===1)l+=d[0],c=!0;else{l+=d[0],a.push(l),c=!0;for(let m=1;m<d.length-1;m++)a.push(d[m]);l=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:m,hadTrailingDelimiter:h}=ri(p.value,n);if(f&&m&&l===""&&(a.push(""),c=!0),d.length===0)h&&(u=!0);else if(d.length===1)l+=d[0],c=!0,u=h;else{l+=d[0],a.push(l),c=!0;for(let g=1;g<d.length-1;g++)a.push(d[g]);l=d[d.length-1],u=h}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function dN(e,t){return e.length>0&&t.includes(e[0])}async function w0(e,t,n,r,s){let i=[];for(let u of t){let p=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),d=await s(e,u);i.push({value:d,isSplittable:p})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{dN(u.value,n)&&a!==""&&(o.push(a),a="",l=!0);let{words:p,hadTrailingDelimiter:d}=ri(u.value,n);if(p.length===0)d&&(c=!0);else if(p.length===1)a+=p[0],l=!0,c=d;else{a+=p[0],o.push(a),l=!0;for(let m=1;m<p.length-1;m++)o.push(p[m]);a=p[p.length-1],c=d}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var S0=v(()=>{"use strict";ht();St();ei()});function A0(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function C0(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var N0=v(()=>{"use strict"});var Ya={};V(Ya,{escapeGlobChars:()=>mt,escapeRegexChars:()=>er,expandRedirectTarget:()=>Br,expandWord:()=>J,expandWordForPattern:()=>Xa,expandWordForRegex:()=>Ka,expandWordWithGlob:()=>Ft,getArrayElements:()=>te,getVariable:()=>me,hasQuotedMultiValueAt:()=>Wr,isArray:()=>Qt,isWordFullyQuoted:()=>Qa});async function Dt(e,t,n=!1){let r=[];for(let s of t)r.push(await At(e,s,n));return r.join("")}function hN(e){return C0(e)}function Qa(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!hN(t))return!1;return!0}function mN(e,t,n=!1){let r=A0(t);if(r!==null)return r;switch(t.type){case"TildeExpansion":return n?t.user===null?"~":`~${t.user}`:t.user===null?e.state.env.HOME!==void 0?e.state.env.HOME:"/home/user":t.user==="root"?"/root":`~${t.user}`;case"Glob":return Ga(e,t.pattern);default:return null}}async function J(e,t){return Ja(e,t)}async function Ka(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped")n.push(`\\${r.value}`);else if(r.type==="SingleQuoted")n.push(r.value);else if(r.type==="DoubleQuoted"){let s=await Dt(e,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await At(e,r);n.push(er(s))}else n.push(await At(e,r));return n.join("")}async function Xa(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped"){let s=r.value;"()|*?[]".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="SingleQuoted")n.push(mt(r.value));else if(r.type==="DoubleQuoted"){let s=await Dt(e,r.parts);n.push(mt(s))}else n.push(await At(e,r));return n.join("")}async function k0(e,t){let n=[];for(let r of t.parts)if(r.type==="SingleQuoted")n.push(mt(r.value));else if(r.type==="Escaped"){let s=r.value;"*?[]\\()|".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="DoubleQuoted"){let s=await Dt(e,r.parts);n.push(mt(s))}else r.type==="Glob"?Rg(r.pattern)?n.push(await Tg(e,r.pattern)):n.push(Ga(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await At(e,r));return n.join("")}function pi(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&pi(t.parts))return!0;return!1}async function v0(e,t,n={count:0}){if(n.count>Za)return[[]];let r=[[]];for(let s of t)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=ja(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let p of f.expanded)n.count++,i.push(p);else{o=!0,a=f.literal;break}}else{let f=await v0(e,u.word.parts,n);for(let p of f){n.count++;let d=[];for(let m of p)typeof m=="string"?d.push(m):d.push(await At(e,m));i.push(d.join(""))}}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>gN||n.count>Za)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>Za)return c.length>0?c:r;c.push([...u,f])}r=c}else for(let i of r)n.count++,i.push(s);return r}async function $0(e,t){let n=t.parts;if(!pi(n))return[await J(e,t)];let r=await v0(e,n),s=[];for(let i of r){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await At(e,a));s.push(Dg(e,o.join("")))}return s}function yN(){return{expandWordAsync:Ja,expandWordForGlobbing:k0,expandWordWithBracesAsync:$0,expandWordPartsAsync:Dt,expandPart:At,expandParameterAsync:fi,hasBraceExpansion:pi,evaluateArithmetic:Q,buildIfsCharClassPattern:sg,smartWordSplit:E0}}async function Ft(e,t){return y0(e,t,yN())}function bN(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function Wr(e,t){if(Number.parseInt(e.state.env["#"]||"0",10)<2)return!1;function r(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return r(t.parts)}async function Br(e,t){if(Wr(e,t))return{error:`bash: $@: ambiguous redirect
763
763
  `};let n=t.parts,{hasQuoted:r}=Lr(n);if(pi(n)&&(await $0(e,t)).length>1)return{error:`bash: ${n.map(d=>d.type==="Literal"?d.value:d.type==="BraceExpansion"?`{${d.items.map(h=>{if(h.type==="Range"){let g=h.step?`..${h.step}`:"";return`${h.startStr??h.start}..${h.endStr??h.end}${g}`}return h.word.parts.map(g=>g.type==="Literal"?g.value:"").join("")}).join(",")}}`:"").join("")}: ambiguous redirect
764
764
  `};let s=await Ja(e,t),{hasParamExpansion:i,hasCommandSub:o}=Lr(n);if((i||o)&&!r&&!Ze(e.state.env)){let f=Ue(e.state.env);if(Ae(s,f).length>1)return{error:`bash: $${bN(n)}: ambiguous redirect
765
- `}}if(r||e.state.options.noglob)return{target:s};let l=await k0(e,t);if(!jt(l,e.state.shoptOptions.extglob))return{target:s};let c=new nn(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}),u=await c.expand(l);return u.length===0?c.hasFailglob()?{error:`bash: no match: ${s}
765
+ `}}if(r||e.state.options.noglob)return{target:s};let l=await k0(e,t);if(!jt(l,e.state.shoptOptions.extglob))return{target:s};let c=new rn(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}),u=await c.expand(l);return u.length===0?c.hasFailglob()?{error:`bash: no match: ${s}
766
766
  `}:{target:s}:u.length===1?{target:u[0]}:{error:`bash: ${s}: ambiguous redirect
767
767
  `}}async function Ja(e,t){let n=t.parts,r=n.length;if(r===1)return At(e,n[0]);let s=[];for(let i=0;i<r;i++)s.push(await At(e,n[i]));return s.join("")}async function At(e,t,n=!1){if(t.type==="ParameterExpansion")return fi(e,t,n);let r=mN(e,t,n);if(r!==null)return r;switch(t.type){case"DoubleQuoted":{let s=[];for(let i of t.parts)s.push(await At(e,i,!0));return s.join("")}case"CommandSubstitution":{let s=dg(t.body);if(s)try{let c=await J(e,s.target),u=c.startsWith("/")?c:`${e.state.cwd}/${c}`,f=await e.fs.readFile(u);return e.state.lastExitCode=0,e.state.env["?"]="0",f.replace(/\n+$/,"")}catch{return e.state.lastExitCode=1,e.state.env["?"]="1",""}let i=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let o={...e.state.env},a=e.state.cwd,l=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let c=await e.executeScript(t.body),u=c.exitCode;return e.state.env=o,e.state.cwd=a,e.state.suppressVerbose=l,e.state.lastExitCode=u,e.state.env["?"]=String(u),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr),e.state.bashPid=i,c.stdout.replace(/\n+$/,"")}catch(c){if(e.state.env=o,e.state.cwd=a,e.state.bashPid=i,e.state.suppressVerbose=l,c instanceof ne)throw c;if(c instanceof ae)return e.state.lastExitCode=c.exitCode,e.state.env["?"]=String(c.exitCode),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr),c.stdout.replace(/\n+$/,"");throw c}}case"ArithmeticExpansion":{let s=t.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let o=await ug(e,s),a=new se,l=he(a,o);return String(await Q(e,l.expression,!0))}return String(await Q(e,t.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of t.items)if(i.type==="Range"){let o=ja(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(await J(e,i.word));return s.join(" ")}default:return""}}async function fi(e,t,n=!1){let{parameter:r}=t,{operation:s}=t,i=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,p,d]=i;if(e.state.associativeArrays?.has(p)||d.includes("$(")||d.includes("`")||d.includes("${")){let h=await za(e,d);r=`${p}[${h}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&Se(e,r)){let p=st(e,r);if(p&&p!==r){let d=p.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let[,m,h]=d;if(e.state.associativeArrays?.has(m)||h.includes("$(")||h.includes("`")||h.includes("${")){let b=await za(e,h);r=`${m}[${b}]`}}}}let o=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),a=await me(e,r,!o);if(!s)return a;let l=!await zt(e,r),{isEmpty:c,effectiveValue:u}=$g(e,r,a,n),f={value:a,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:n};switch(s.type){case"DefaultValue":return mg(e,s,f,Dt);case"AssignDefault":return gg(e,r,s,f,Dt);case"ErrorIfUnset":return yg(e,r,s,f,Dt);case"UseAlternative":return bg(e,s,f,Dt);case"PatternRemoval":return wg(e,a,s,Dt,At);case"PatternReplacement":return xg(e,a,s,Dt,At);case"Length":return Eg(e,r,a);case"LengthSliceError":throw new nt(r);case"BadSubstitution":throw new nt(s.text);case"Substring":return Sg(e,r,a,s);case"CaseModification":return Ag(e,a,s,Dt,fi);case"Transform":return Cg(e,r,a,l,s);case"Indirection":return Ng(e,r,a,l,s,fi,n);case"ArrayKeys":return kg(e,s);case"VarNamePrefix":return vg(e,s);default:return a}}var gN,Za,ot=v(()=>{"use strict";Je();Fe();Ys();it();de();ei();fg();pg();hg();tr();Ig();Og();Fg();ht();b0();S0();St();Tt();N0();tr();ht();gN=1e4,Za=1e5});function wN(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":if(t===0)throw new Ee("division by 0");return Math.trunc(e/t);case"%":if(t===0)throw new Ee("division by 0");return e%t;case"**":if(t<0)throw new Ee("exponent less than 0");return e**t;case"<<":return e<<t;case">>":return e>>t;case"<":return e<t?1:0;case"<=":return e<=t?1:0;case">":return e>t?1:0;case">=":return e>=t?1:0;case"==":return e===t?1:0;case"!=":return e!==t?1:0;case"&":return e&t;case"|":return e|t;case"^":return e^t;case",":return t;default:return 0}}function I0(e,t,n){switch(n){case"=":return t;case"+=":return e+t;case"-=":return e-t;case"*=":return e*t;case"/=":return t!==0?Math.trunc(e/t):0;case"%=":return t!==0?e%t:0;case"<<=":return e<<t;case">>=":return e>>t;case"&=":return e&t;case"|=":return e|t;case"^=":return e^t;default:return t}}function xN(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return e===0?1:0;case"~":return~e;default:return e}}async function EN(e,t){let n=e.state.env[t];if(n!==void 0)return n;let r=e.state.env[`${t}_0`];return r!==void 0?r:await me(e,t)}function SN(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\d+$/.test(e.trim()))return t;let n=e.trim();if(!n)return 0;try{let r=new se,{expr:s,pos:i}=Et(r,n,0);if(i<n.length){let o=n.slice(i).trim().split(/\s+/)[0];throw new Ee(`${n}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:t||0}catch(r){if(r instanceof Ee)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new Ee(`${n}: syntax error in expression (error token is "${s}")`)}}async function el(e,t){if(!t)return 0;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(t.trim()))return n;let r=t.trim();if(!r)return 0;let s=new se,{expr:i,pos:o}=Et(s,r,0);if(o<r.length){let a=r.slice(o).trim(),l=a.split(/\s+/)[0]||a;throw new Ee(`syntax error in expression (error token is "${l}")`,"","")}return await Q(e,i)}async function tl(e,t,n=new Set){if(n.has(t))return 0;n.add(t);let r=await EN(e,t);if(!r)return 0;let s=Number.parseInt(r,10);if(!Number.isNaN(s)&&/^-?\d+$/.test(r.trim()))return s;let i=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return await tl(e,i,n);let o=new se,{expr:a,pos:l}=Et(o,i,0);if(l<i.length){let c=i.slice(l).trim(),u=c.split(/\s+/)[0]||c;throw new Ee(`${i}: syntax error in expression (error token is "${u}")`)}return await Q(e,a)}async function di(e,t){if(t.startsWith("#")){let f=t.slice(1),p=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(p){let m=p[1],h=te(e,m);return String(h.length)}let d=e.state.env[f]||"";return String(d.length)}if(t.startsWith("!")){let f=t.slice(1),p=e.state.env[f]||"";return e.state.env[p]||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let p=t.indexOf(f);p>0&&(r===-1||p<r)&&(r=p,s=f)}if(r===-1)return await me(e,t);let i=t.slice(0,r),o=t.slice(r+s.length),a=e.state.env[i],l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(e.state.env[i]=o,o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}async function Q(e,t,n=!1){switch(t.type){case"ArithNumber":if(Number.isNaN(t.value))throw new Ee("value too great for base");return t.value;case"ArithVariable":return await tl(e,t.name);case"ArithSpecialVar":{let s=(await me(e,t.name)).trim();if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s))return i;let o=new se,{expr:a}=Et(o,s,0);return await Q(e,a)}case"ArithNested":return await Q(e,t.expression);case"ArithCommandSubst":{if(e.execFn){let r=await e.execFn(t.command);r.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+r.stderr);let s=r.stdout.trim();return Number.parseInt(s,10)||0}return 0}case"ArithBracedExpansion":{let r=await di(e,t.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=await di(e,t.baseExpr),s=Number.parseInt(r,10);if(s<2||s>64)return 0;let i=`${s}#${t.value}`;return Fr(i)}case"ArithDynamicNumber":{let s=await di(e,t.prefix)+t.suffix;return Fr(s)}case"ArithArrayElement":{let r=e.state.associativeArrays?.has(t.array),s=async i=>{let o=e.state.env[i];return o!==void 0?await el(e,o):0};if(t.stringKey!==void 0)return await s(`${t.array}_${t.stringKey}`);if(r&&t.index?.type==="ArithVariable"&&!t.index.hasDollarPrefix)return await s(`${t.array}_${t.index.name}`);if(r&&t.index?.type==="ArithVariable"&&t.index.hasDollarPrefix){let i=await me(e,t.index.name);return await s(`${t.array}_${i}`)}if(t.index){let i=await Q(e,t.index,n);if(i<0){let l=te(e,t.array),c=e.state.currentLine;if(l.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
768
768
  `,0;let f=Math.max(...l.map(([p])=>typeof p=="number"?p:0))+1+i;if(f<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
769
769
  `,0;i=f}let o=`${t.array}_${i}`,a=e.state.env[o];if(a!==void 0)return el(e,a);if(i===0){let l=e.state.env[t.array];if(l!==void 0)return el(e,l)}if(e.state.options.nounset&&!Object.keys(e.state.env).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new tt(`${t.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new Ee("double subscript","","");case"ArithNumberSubscript":throw new Ee(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new Ee(t.message,"","",!0);case"ArithSingleQuote":{if(n)throw new Ee(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value}case"ArithBinary":{if(t.operator==="||")return await Q(e,t.left,n)||await Q(e,t.right,n)?1:0;if(t.operator==="&&")return await Q(e,t.left,n)&&await Q(e,t.right,n)?1:0;let r=await Q(e,t.left,n),s=await Q(e,t.right,n);return wN(r,s,t.operator)}case"ArithUnary":{let r=await Q(e,t.operand,n);if(t.operator==="++"||t.operator==="--"){if(t.operand.type==="ArithVariable"){let s=t.operand.name,i=Number.parseInt(await me(e,s),10)||0,o=t.operator==="++"?i+1:i-1;return e.state.env[s]=String(o),t.prefix?o:i}if(t.operand.type==="ArithArrayElement"){let s=t.operand.array,i=e.state.associativeArrays?.has(s),o;if(t.operand.stringKey!==void 0)o=`${s}_${t.operand.stringKey}`;else if(i&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)o=`${s}_${t.operand.index.name}`;else if(i&&t.operand.index?.type==="ArithVariable"&&t.operand.index.hasDollarPrefix){let c=await me(e,t.operand.index.name);o=`${s}_${c}`}else if(t.operand.index){let c=await Q(e,t.operand.index,n);o=`${s}_${c}`}else return r;let a=Number.parseInt(e.state.env[o]||"0",10)||0,l=t.operator==="++"?a+1:a-1;return e.state.env[o]=String(l),t.prefix?l:a}if(t.operand.type==="ArithConcat"){let s="";for(let i of t.operand.parts)s+=await ir(e,i,n);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=Number.parseInt(e.state.env[s]||"0",10)||0,o=t.operator==="++"?i+1:i-1;return e.state.env[s]=String(o),t.prefix?o:i}}if(t.operand.type==="ArithDynamicElement"){let s="";if(t.operand.nameExpr.type==="ArithConcat")for(let i of t.operand.nameExpr.parts)s+=await ir(e,i,n);else t.operand.nameExpr.type==="ArithVariable"&&(s=t.operand.nameExpr.hasDollarPrefix?await me(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=await Q(e,t.operand.subscript,n),o=`${s}_${i}`,a=Number.parseInt(e.state.env[o]||"0",10)||0,l=t.operator==="++"?a+1:a-1;return e.state.env[o]=String(l),t.prefix?l:a}}return r}return xN(r,t.operator)}case"ArithTernary":return await Q(e,t.condition,n)?await Q(e,t.consequent,n):await Q(e,t.alternate,n);case"ArithAssignment":{let r=t.variable,s=r;if(t.stringKey!==void 0)s=`${r}_${t.stringKey}`;else if(t.subscript){let l=e.state.associativeArrays?.has(r);if(l&&t.subscript.type==="ArithVariable"&&!t.subscript.hasDollarPrefix)s=`${r}_${t.subscript.name}`;else if(l&&t.subscript.type==="ArithVariable"&&t.subscript.hasDollarPrefix){let c=await me(e,t.subscript.name);s=`${r}_${c||"\\"}`}else if(l){let c=await Q(e,t.subscript,n);s=`${r}_${c}`}else{let c=await Q(e,t.subscript,n);if(c<0){let u=te(e,r);u.length>0&&(c=Math.max(...u.map(([p])=>typeof p=="number"?p:0))+1+c)}s=`${r}_${c}`}}let i=Number.parseInt(e.state.env[s]||"0",10)||0,o=await Q(e,t.value,n),a=I0(i,o,t.operator);return e.state.env[s]=String(a),a}case"ArithGroup":return await Q(e,t.expression,n);case"ArithConcat":{let r="";for(let s of t.parts)r+=await ir(e,s,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await tl(e,r):Number.parseInt(r,10)||0}case"ArithDynamicAssignment":{let r="";if(t.target.type==="ArithConcat")for(let l of t.target.parts)r+=await ir(e,l,n);else t.target.type==="ArithVariable"&&(r=t.target.hasDollarPrefix?await me(e,t.target.name):t.target.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=r;if(t.subscript){let l=await Q(e,t.subscript,n);s=`${r}_${l}`}let i=Number.parseInt(e.state.env[s]||"0",10)||0,o=await Q(e,t.value,n),a=I0(i,o,t.operator);return e.state.env[s]=String(a),a}case"ArithDynamicElement":{let r="";if(t.nameExpr.type==="ArithConcat")for(let a of t.nameExpr.parts)r+=await ir(e,a,n);else t.nameExpr.type==="ArithVariable"&&(r=t.nameExpr.hasDollarPrefix?await me(e,t.nameExpr.name):t.nameExpr.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=await Q(e,t.subscript,n),i=`${r}_${s}`,o=e.state.env[i];return o!==void 0?SN(o):0}default:return 0}}async function ir(e,t,n=!1){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await Q(e,t,n));case"ArithVariable":return t.hasDollarPrefix?await me(e,t.name):t.name;case"ArithSpecialVar":return await me(e,t.name);case"ArithBracedExpansion":return await di(e,t.content);case"ArithCommandSubst":return e.execFn?(await e.execFn(t.command)).stdout.trim():"0";case"ArithConcat":{let r="";for(let s of t.parts)r+=await ir(e,s,n);return r}default:return String(await Q(e,t,n))}}var it=v(()=>{"use strict";Je();Fe();de();ot()});var aa=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(Jl(),Xl))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(ec(),Yl))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(cc(),lc))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(dc(),pc))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(mc(),hc))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(wc(),bc))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Ec(),xc))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(Ac(),Sc))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Nc(),Cc))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(vc(),kc))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Ic(),$c))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(Tc(),Pc))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(Dc(),Oc))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(_c(),Fc))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(Bc(),Wc))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(zc(),Uc))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(Vc(),Hc))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(Zc(),Gc))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(os(),is))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(os(),is))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(os(),is))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(gu(),mu))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(vu(),ku))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(of(),sf))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(gf(),mf))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(bf(),yf))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(xf(),wf))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(Sf(),Ef))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(Nf(),Cf))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>($f(),vf))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(Rf(),If))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(Of(),Tf))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(_f(),Ff))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(Wf(),Mf))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(jf(),zf))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(Gf(),qf))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Kf(),Qf))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Yf(),Jf))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(tp(),ep))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(rp(),np))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(pp(),fp))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(hp(),dp))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(gp(),mp))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(wp(),bp))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(Sp(),Ep))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(xo(),wo))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(xo(),wo))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(So(),Eo))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(So(),Eo))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(Np(),Cp))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(vp(),kp))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Co(),Ao))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Co(),Ao))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(Ip(),$p))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(ko(),No))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(ko(),No))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(nd(),td))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(id(),sd))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(ld(),ad))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(ud(),cd))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(pd(),fd))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(hd(),dd))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(gd(),md))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(bd(),yd))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(xd(),wd))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(Ad(),Sd))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(Nd(),Cd))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(vd(),kd))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(xh(),wh))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(Sh(),Eh))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(Ch(),Ah))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(kh(),Nh))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>($h(),vh))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(Rh(),Ih))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(Th(),Ph))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(Dh(),Oh))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Hs(),js))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Hs(),js))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Hs(),js))).zcatCommand}],Kh=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(Zh(),Gh))).curlCommand}],Qh=new Map;function Xh(e){return{name:e.name,async execute(t,n){let r=Qh.get(e.name);return r||(r=await e.load(),Qh.set(e.name,r)),r.execute(t,n)}}}function VA(){return aa.map(e=>e.name)}function qA(){return Kh.map(e=>e.name)}function Jh(e){return(e?aa.filter(n=>e.includes(n.name)):aa).map(Xh)}function Yh(){return Kh.map(Xh)}function em(e){return"load"in e&&typeof e.load=="function"}function GA(e,t){return{name:e,execute:t}}function tm(e){let t=null;return{name:e.name,async execute(n,r){return t||(t=await e.load()),t.execute(n,r)}}}var ZA=new TextEncoder,QA=new TextDecoder;function la(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),n=>n.charCodeAt(0));if(t==="hex"){let n=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)n[r/2]=parseInt(e.slice(r,r+2),16);return n}return t==="binary"||t==="latin1"?Uint8Array.from(e,n=>n.charCodeAt(0)):ZA.encode(e)}function nm(e,t){return t==="base64"?btoa(String.fromCharCode(...e)):t==="hex"?Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join(""):t==="binary"||t==="latin1"?String.fromCharCode(...e):QA.decode(e)}function Vs(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var qs=new TextEncoder;function KA(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}var En=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[n,r]of Object.entries(t))KA(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(t){if(!t||t==="/")return"/";let n=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(i=>i&&i!=="."),s=[];for(let i of r)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(t){let n=this.dirname(t);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,n,r,s){let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Vs(r),a=la(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(t,n){let r=await this.readFileBuffer(t),s=Vs(n);return nm(r,s)}async readFileBuffer(t){let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return r.content instanceof Uint8Array?r.content:qs.encode(r.content)}async writeFile(t,n,r){this.writeFileSync(t,n,r)}async appendFile(t,n,r){let s=this.normalizePath(t),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=Vs(r),a=la(n,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:qs.encode(i.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:i.mode,mtime:new Date})}else this.writeFileSync(t,n,r)}async exists(t){try{let n=this.resolvePathWithSymlinks(t);return this.data.has(n)}catch{return!1}}async stat(t){let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=qs.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(t){let n=this.resolveIntermediateSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=qs.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(t,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}resolveIntermediateSymlinks(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(s),s=this.resolveSymlink(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(s),s=this.resolveSymlink(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return s}async mkdir(t,n){this.mkdirSync(t,n)}mkdirSync(t,n){let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);s.add(n),n=this.resolveSymlink(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,n){let r=this.normalizePath(t),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(t,n,r){let s=this.normalizePath(t),i=this.normalizePath(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,r)}}}async mv(t,n){await this.cp(t,n,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,n){if(n.startsWith("/"))return this.normalizePath(n);let r=t==="/"?`/${n}`:`${t}/${n}`;return this.normalizePath(r)}async chmod(t,n){let r=this.normalizePath(t),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);s.mode=n}async symlink(t,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,n){let r=this.normalizePath(t),s=this.normalizePath(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){let n=this.resolvePathWithSymlinks(t);if(!this.data.has(n))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return n}async utimes(t,n,r){let s=this.normalizePath(t),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};ca();function XA(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function JA(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 YA(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function eC(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${sm}
770
770
  `),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
771
- `),e.writeFileSync("/proc/self/status",im()),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 om(e,t){XA(e)&&(JA(e,t),YA(e),eC(e))}de();var tC=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],nC=["braceexpand","hashall","interactive-comments"];function ua(e){let t=[],n=[...nC.map(r=>({name:r,enabled:!0})),...tC.map(r=>({name:r,enabled:e[r]}))].sort((r,s)=>r.name.localeCompare(s.name));for(let r of n)r.enabled&&t.push(r.name);return t.join(":")}function Jn(e){e.state.env.SHELLOPTS=ua(e.state.options)}var rC=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function fa(e){let t=[];for(let n of rC)e[n]&&t.push(n);return t.join(":")}function pa(e){e.state.env.BASHOPTS=fa(e.state.shoptOptions)}An();Fe();An();var OC="BASH_ALIAS_";function Qm(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Km(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Xm(e,t){return e.env[`${OC}${t}`]}function Oa(e,t,n){if(!t.name||!Qm(t.name))return t;let r=Km(t.name);if(!r)return t;let s=Xm(e,r);if(!s||n.has(r))return t;try{n.add(r);let i=new se,o=s,a=s.endsWith(" ");if(!a)for(let f of t.args){let p=Ym(f);o+=` ${p}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof Ge)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Jm(t,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Jm(t,s);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(Qm(f)){let p=Km(f);if(p&&Xm(e,p)){let d={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Oa(e,d,n);m!==d&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw n.delete(r),i}}function Jm(e,t){let n=t;for(let o of e.args){let a=Ym(o);n+=` ${a}`}let r=new se,s=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${n.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Ym(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${n.value}'`;break;case"DoubleQuoted":t+=`"${n.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${n.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${n.expression}))`;break;case"Glob":t+=n.pattern;break;default:break}return t}it();ot();$t();async function R0(e,t){let n=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!n.endsWith(")"))return null;let s=r[1],i=[],o=!1,a="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let p=f.indexOf("=(");p!==-1&&(o=!0,f=f.slice(p+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let p=f.split(/(\s+)/);for(let d of p)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Yn({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let p=await Ft(e,{type:"Word",parts:[u]});i.push(...p.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await J(e,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function P0(e,t){let n=-1,r=-1,s=!1;for(let h=0;h<t.parts.length;h++){let g=t.parts[h];if(g.type==="Literal"){let b=g.value.indexOf("+=");if(b!==-1){let w=g.value.slice(0,b);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)){n=h,r=b,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(w)){n=h,r=b,s=!0;break}}let y=g.value.indexOf("=");if(y!==-1&&(y===0||g.value[y-1]!=="+")){let w=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(w)){n=h,r=y;break}}}}if(n===-1)return null;let i=t.parts.slice(0,n),o=t.parts[n];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(n+1),f="";for(let h of i)f+=await J(e,{type:"Word",parts:[h]});f+=l;let p={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},d=p.parts.length>0?await J(e,p):"";return`${f}${s?"+=":"="}${d}`}var AN=["tar","yq","xan","sqlite3"];function T0(e){return AN.includes(e)}de();de();var le=Object.freeze({stdout:"",stderr:"",exitCode:0});function ue(e=""){return{stdout:e,stderr:"",exitCode:0}}function M(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function W(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function Le(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Xt(e,t,n="",r=""){throw new ne(e,t,n,r)}function nl(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Lt;return le}if(t.length>1)throw new ae(1,"",`bash: break: too many arguments
771
+ `),e.writeFileSync("/proc/self/status",im()),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 om(e,t){XA(e)&&(JA(e,t),YA(e),eC(e))}de();var tC=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],nC=["braceexpand","hashall","interactive-comments"];function ua(e){let t=[],n=[...nC.map(r=>({name:r,enabled:!0})),...tC.map(r=>({name:r,enabled:e[r]}))].sort((r,s)=>r.name.localeCompare(s.name));for(let r of n)r.enabled&&t.push(r.name);return t.join(":")}function Jn(e){e.state.env.SHELLOPTS=ua(e.state.options)}var rC=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function fa(e){let t=[];for(let n of rC)e[n]&&t.push(n);return t.join(":")}function pa(e){e.state.env.BASHOPTS=fa(e.state.shoptOptions)}An();Fe();An();var OC="BASH_ALIAS_";function Qm(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Km(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Xm(e,t){return e.env[`${OC}${t}`]}function Oa(e,t,n){if(!t.name||!Qm(t.name))return t;let r=Km(t.name);if(!r)return t;let s=Xm(e,r);if(!s||n.has(r))return t;try{n.add(r);let i=new se,o=s,a=s.endsWith(" ");if(!a)for(let f of t.args){let p=Ym(f);o+=` ${p}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof Ge)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Jm(t,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Jm(t,s);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(Qm(f)){let p=Km(f);if(p&&Xm(e,p)){let d={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Oa(e,d,n);m!==d&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw n.delete(r),i}}function Jm(e,t){let n=t;for(let o of e.args){let a=Ym(o);n+=` ${a}`}let r=new se,s=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${n.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Ym(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${n.value}'`;break;case"DoubleQuoted":t+=`"${n.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${n.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${n.expression}))`;break;case"Glob":t+=n.pattern;break;default:break}return t}it();ot();$t();async function R0(e,t){let n=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!n.endsWith(")"))return null;let s=r[1],i=[],o=!1,a="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let p=f.indexOf("=(");p!==-1&&(o=!0,f=f.slice(p+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let p=f.split(/(\s+)/);for(let d of p)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Yn({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let p=await Ft(e,{type:"Word",parts:[u]});i.push(...p.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await J(e,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function P0(e,t){let n=-1,r=-1,s=!1;for(let h=0;h<t.parts.length;h++){let g=t.parts[h];if(g.type==="Literal"){let b=g.value.indexOf("+=");if(b!==-1){let w=g.value.slice(0,b);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)){n=h,r=b,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(w)){n=h,r=b,s=!0;break}}let y=g.value.indexOf("=");if(y!==-1&&(y===0||g.value[y-1]!=="+")){let w=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(w)){n=h,r=y;break}}}}if(n===-1)return null;let i=t.parts.slice(0,n),o=t.parts[n];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(n+1),f="";for(let h of i)f+=await J(e,{type:"Word",parts:[h]});f+=l;let p={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},d=p.parts.length>0?await J(e,p):"";return`${f}${s?"+=":"="}${d}`}var AN=["tar","yq","xan","sqlite3","python3","python"];function T0(e){return AN.includes(e)}de();de();var le=Object.freeze({stdout:"",stderr:"",exitCode:0});function ue(e=""){return{stdout:e,stderr:"",exitCode:0}}function M(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function W(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function Le(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Xt(e,t,n="",r=""){throw new ne(e,t,n,r)}function nl(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Lt;return le}if(t.length>1)throw new ae(1,"",`bash: break: too many arguments
772
772
  `);let n=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new ae(128,"",`bash: break: ${t[0]}: numeric argument required
773
773
  `);n=r}throw new Qe(n)}async function rl(e,t){let n,r=!1,s=!1,i=0;for(;i<t.length;)if(t[i]==="--"){i++;break}else if(t[i]==="-L")s=!1,i++;else if(t[i]==="-P")s=!0,i++;else if(t[i].startsWith("-")&&t[i]!=="-")i++;else break;let o=t.slice(i);if(o.length===0||o[0]==="~"?n=e.state.env.HOME||"/":o[0]==="-"?(n=e.state.previousDir,r=!0):n=o[0],!n.startsWith("/")&&!n.startsWith("./")&&!n.startsWith("../")&&n!=="."&&n!==".."){let f=e.state.env.CDPATH;if(f){let p=f.split(":").filter(d=>d);for(let d of p){let m=d.startsWith("/")?`${d}/${n}`:`${e.state.cwd}/${d}/${n}`;try{if((await e.fs.stat(m)).isDirectory){n=m,r=!0;break}}catch{}}}}let l=(n.startsWith("/")?n:`${e.state.cwd}/${n}`).split("/").filter(f=>f&&f!=="."),c="";for(let f of l)if(f==="..")c=c.split("/").slice(0,-1).join("/")||"/";else{c=c?`${c}/${f}`:`/${f}`;try{if(!(await e.fs.stat(c)).isDirectory)return M(`bash: cd: ${n}: Not a directory
774
774
  `)}catch{return M(`bash: cd: ${n}: No such file or directory
775
775
  `)}}let u=c||"/";if(s)try{u=await e.fs.realpath(u)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=u,e.state.env.PWD=e.state.cwd,e.state.env.OLDPWD=e.state.previousDir,ue(r?`${u}
776
776
  `:"")}Fe();Je();Fe();it();ot();$t();function sl(e,t){return e.fs.resolvePath(e.state.cwd,t)}var CN=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function hi(e){return CN.includes(e)}async function mi(e,t,n){let r=sl(e,n);switch(t){case"-e":case"-a":return e.fs.exists(r);case"-f":return await e.fs.exists(r)?(await e.fs.stat(r)).isFile:!1;case"-d":return await e.fs.exists(r)?(await e.fs.stat(r)).isDirectory:!1;case"-r":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&256)!==0:!1;case"-w":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&128)!==0:!1;case"-x":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&64)!==0:!1;case"-s":return await e.fs.exists(r)?(await e.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await e.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&512)!==0:!1;case"-g":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return e.fs.exists(r);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>r===i||r.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return e.fs.exists(r);default:return!1}}var NN=["-nt","-ot","-ef"];function gi(e){return NN.includes(e)}async function yi(e,t,n,r){let s=sl(e,n),i=sl(e,r);switch(t){case"-nt":try{let o=await e.fs.stat(s),a=await e.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await e.fs.stat(s),a=await e.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await e.fs.exists(s)||!await e.fs.exists(i))return!1;let o=e.fs.resolvePath(e.state.cwd,s),a=e.fs.resolvePath(e.state.cwd,i);return o===a}catch{return!1}default:return!1}}var kN=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function bi(e){return kN.has(e)}function wi(e,t,n){switch(e){case"-eq":return t===n;case"-ne":return t!==n;case"-lt":return t<n;case"-le":return t<=n;case"-gt":return t>n;case"-ge":return t>=n}}function Ur(e){return e==="="||e==="=="||e==="!="}function xi(e,t,n,r=!1,s=!1,i=!1){if(r){let a=or(t,n,s,i);return e==="!="?!a:a}if(s){let a=t.toLowerCase()===n.toLowerCase();return e==="!="?!a:a}let o=t===n;return e==="!="?!o:o}var vN=new Set(["-z","-n"]);function Ei(e){return vN.has(e)}function Si(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}Je();Fe();it();$t();async function Ai(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let r=n[1],s=n[2];if(e.state.associativeArrays?.has(r)){let a=s;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,(l,c)=>e.state.env[c]||""),`${r}_${a}`in e.state.env}let o;try{let a=new se,l=he(a,s);o=await Q(e,l.expression)}catch{if(/^-?\d+$/.test(s))o=Number.parseInt(s,10);else{let a=e.state.env[s];o=a?Number.parseInt(a,10):0}}if(o<0){let a=_e(e,r),l=e.state.currentLine;if(a.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
777
777
  `,!1;if(o=Math.max(...a)+1+o,o<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
778
- `,!1}return`${r}_${o}`in e.state.env}return t in e.state.env?!0:e.state.associativeArrays?.has(t)?Pt(e,t).length>0:_e(e,t).length>0}async function an(e,t){switch(t.type){case"CondBinary":{let n=await J(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),s;if(t.operator==="=~")if(r){let i=await J(e,t.right);s=er(i)}else s=await Ka(e,t.right);else Ur(t.operator)&&!r?s=await Xa(e,t.right):s=await J(e,t.right);if(Ur(t.operator)){let i=e.state.shoptOptions.nocasematch;return xi(t.operator,n,s,!r,i,!0)}if(bi(t.operator))return wi(t.operator,await D0(e,n),await D0(e,s));if(gi(t.operator))return yi(e,t.operator,n,s);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,o=PN(s),a=new RegExp(o,i?"i":""),l=n.match(a);if(Ut(e,"BASH_REMATCH"),l)for(let c=0;c<l.length;c++)e.state.env[`BASH_REMATCH_${c}`]=l[c]||"";return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return n<s;case">":return n>s;default:return!1}}case"CondUnary":{let n=await J(e,t.operand);return hi(t.operator)?mi(e,t.operator,n):Ei(t.operator)?Si(t.operator,n):t.operator==="-v"?await Ai(e,n):t.operator==="-o"?ol(e,n):!1}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await J(e,t.operand.expression.word)})`!=="":!await an(e,t.operand);case"CondAnd":return await an(e,t.left)?await an(e,t.right):!1;case"CondOr":return await an(e,t.left)?!0:await an(e,t.right);case"CondGroup":return await an(e,t.expression);case"CondWord":return await J(e,t.word)!=="";default:return!1}}async function zr(e,t){if(t.length===0)return W("","",1);if(t.length===1)return Le(!!t[0]);if(t.length===2){let r=t[0],s=t[1];return r==="("?M(`test: '(' without matching ')'
778
+ `,!1}return`${r}_${o}`in e.state.env}return t in e.state.env?!0:e.state.associativeArrays?.has(t)?Pt(e,t).length>0:_e(e,t).length>0}async function ln(e,t){switch(t.type){case"CondBinary":{let n=await J(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),s;if(t.operator==="=~")if(r){let i=await J(e,t.right);s=er(i)}else s=await Ka(e,t.right);else Ur(t.operator)&&!r?s=await Xa(e,t.right):s=await J(e,t.right);if(Ur(t.operator)){let i=e.state.shoptOptions.nocasematch;return xi(t.operator,n,s,!r,i,!0)}if(bi(t.operator))return wi(t.operator,await D0(e,n),await D0(e,s));if(gi(t.operator))return yi(e,t.operator,n,s);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,o=PN(s),a=new RegExp(o,i?"i":""),l=n.match(a);if(Ut(e,"BASH_REMATCH"),l)for(let c=0;c<l.length;c++)e.state.env[`BASH_REMATCH_${c}`]=l[c]||"";return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return n<s;case">":return n>s;default:return!1}}case"CondUnary":{let n=await J(e,t.operand);return hi(t.operator)?mi(e,t.operator,n):Ei(t.operator)?Si(t.operator,n):t.operator==="-v"?await Ai(e,n):t.operator==="-o"?ol(e,n):!1}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await J(e,t.operand.expression.word)})`!=="":!await ln(e,t.operand);case"CondAnd":return await ln(e,t.left)?await ln(e,t.right):!1;case"CondOr":return await ln(e,t.left)?!0:await ln(e,t.right);case"CondGroup":return await ln(e,t.expression);case"CondWord":return await J(e,t.word)!=="";default:return!1}}async function zr(e,t){if(t.length===0)return W("","",1);if(t.length===1)return Le(!!t[0]);if(t.length===2){let r=t[0],s=t[1];return r==="("?M(`test: '(' without matching ')'
779
779
  `,2):hi(r)?Le(await mi(e,r,s)):Ei(r)?Le(Si(r,s)):r==="!"?Le(!s):r==="-v"?Le(await Ai(e,s)):r==="-o"?Le(ol(e,s)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?M(`test: ${r}: unary operator expected
780
780
  `,2):W("","",1)}if(t.length===3){let r=t[0],s=t[1],i=t[2];if(Ur(s))return Le(xi(s,r,i));if(bi(s)){let o=Ci(r),a=Ci(i);return!o.valid||!a.valid?W("","",2):Le(wi(s,o.value,a.value))}if(gi(s))return Le(await yi(e,s,r,i));switch(s){case"-a":return Le(r!==""&&i!=="");case"-o":return Le(r!==""||i!=="");case">":return Le(r>i);case"<":return Le(r<i)}if(r==="!"){let o=await zr(e,[s,i]);return W("",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r==="("&&i===")")return Le(s!=="")}if(t.length===4){if(t[0]==="!"){let r=await zr(e,t.slice(1));return W("",r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]==="("&&t[3]===")")return zr(e,[t[1],t[2]])}let n=await _0(e,t,0);return n.pos<t.length?M(`test: too many arguments
781
- `,2):Le(n.value)}async function _0(e,t,n){return $N(e,t,n)}async function $N(e,t,n){let{value:r,pos:s}=await O0(e,t,n);for(;t[s]==="-o";){let i=await O0(e,t,s+1);r=r||i.value,s=i.pos}return{value:r,pos:s}}async function O0(e,t,n){let{value:r,pos:s}=await il(e,t,n);for(;t[s]==="-a";){let i=await il(e,t,s+1);r=r&&i.value,s=i.pos}return{value:r,pos:s}}async function il(e,t,n){if(t[n]==="!"){let{value:r,pos:s}=await il(e,t,n+1);return{value:!r,pos:s}}return IN(e,t,n)}async function IN(e,t,n){let r=t[n];if(r==="("){let{value:i,pos:o}=await _0(e,t,n+1);return{value:i,pos:t[o]===")"?o+1:o}}let s=t[n+1];if(Ur(s)){let i=r,o=t[n+2]??"";return{value:xi(s,i,o),pos:n+3}}if(bi(s)){let i=Ci(r),o=Ci(t[n+2]??"0");return!i.valid||!o.valid?{value:!1,pos:n+3}:{value:wi(s,i.value,o.value),pos:n+3}}if(gi(s)){let i=r,o=t[n+2]??"";return{value:await yi(e,s,i,o),pos:n+3}}if(hi(r)){let i=t[n+1]??"";return{value:await mi(e,r,i),pos:n+2}}if(Ei(r)){let i=t[n+1]??"";return{value:Si(r,i),pos:n+2}}if(r==="-v"){let i=t[n+1]??"";return{value:await Ai(e,i),pos:n+2}}if(r==="-o"){let i=t[n+1]??"";return{value:ol(e,i),pos:n+2}}return{value:r!==void 0&&r!=="",pos:n+1}}function or(e,t,n=!1,r=!1){let s=`^${L0(t,r)}$`,i=n?"is":"s";return new RegExp(s,i).test(e)}function L0(e,t){let n="";for(let r=0;r<e.length;r++){let s=e[r];if(t&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<e.length&&e[r+1]==="("){let i=M0(e,r+1);if(i!==-1){let o=e.slice(r+2,i),a=W0(o),l=a.map(u=>L0(u,t)),c=l.length>0?l.join("|"):"(?:)";if(s==="@")n+=`(?:${c})`;else if(s==="*")n+=`(?:${c})*`;else if(s==="+")n+=`(?:${c})+`;else if(s==="?")n+=`(?:${c})?`;else if(s==="!")if(i<e.length-1){let f=a.map(d=>B0(d,t));if(f.every(d=>d!==null)&&f.every(d=>d===f[0])&&f[0]!==null){let d=f[0];if(d===0)n+="(?:.+)";else{let m=[];d>0&&m.push(`.{0,${d-1}}`),m.push(`.{${d+1},}`),m.push(`(?!(?:${c})).{${d}}`),n+=`(?:${m.join("|")})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`;r=i;continue}}if(s==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r++}else n+="\\\\";else if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=e.indexOf("]",r+1);i!==-1?(n+=e.slice(r,i+1),r=i):n+="\\["}else/[\\^$.|+(){}]/.test(s)?n+=`\\${s}`:n+=s}return n}function M0(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function W0(e){let t=[],n="",r=0,s=0;for(;s<e.length;){let i=e[s];if(i==="\\"){n+=i,s+1<e.length?(n+=e[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(t.push(n),n=""):n+=i,s++}return t.push(n),t}function B0(e,t){let n=0,r=0;for(;r<e.length;){let s=e[r];if(t&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<e.length&&e[r+1]==="("){let i=M0(e,r+1);if(i!==-1){if(s==="@"){let o=e.slice(r+2,i),l=W0(o).map(c=>B0(c,t));if(l.every(c=>c!==null)&&l.every(c=>c===l[0])){n+=l[0],r=i+1;continue}return null}return null}}if(s==="*")return null;if(s==="?"){n+=1,r++;continue}if(s==="["){let i=e.indexOf("]",r+1);if(i!==-1){n+=1,r=i+1;continue}n+=1,r++;continue}if(s==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}function ol(e,t){let r={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}[t];return r?r():!1}async function D0(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 F0(t);try{let n=new se,r=he(n,t);return await Q(e,r.expression)}catch{return F0(t)}}function RN(e,t){let n=0;for(let r of e){let s;if(r>="0"&&r<="9")s=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")s=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")s=r.charCodeAt(0)-65+36;else if(r==="@")s=62;else if(r==="_")s=63;else return Number.NaN;if(s>=t)return Number.NaN;n=n*t+s}return n}function F0(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 n,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let s=Number.parseInt(r[1],10);s>=2&&s<=64?n=RN(r[2],s):n=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?n=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?n=Number.parseInt(e,8):n=Number.parseInt(e,10);return Number.isNaN(n)&&(n=0),t?-n:n}function Ci(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 n=Number.parseInt(e,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:t?-n:n,valid:!0}}function PN(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length)t+=e[n]+e[n+1],n+=2;else if(e[n]==="["){let r=TN(e,n);t+=r.converted,n=r.endIndex}else t+=e[n],n++;return t}function TN(e,t){let n=t+1,r="[";n<e.length&&(e[n]==="^"||e[n]==="!")&&(r+="^",n++);let s=!1;n<e.length&&e[n]==="]"&&(s=!0,n++);let i=!1;n<e.length&&e[n]==="["&&n+1<e.length&&e[n+1]!==":"&&(i=!0,n++);let o="",a=!1;for(;n<e.length;){let l=e[n];if(l==="]"){a=!0,n++;break}if(l==="["&&n+1<e.length&&e[n+1]===":"){let c=e.indexOf(":]",n+2);if(c!==-1){let u=e.slice(n+2,c);o+=ON(u),n=c+2;continue}}if(l==="["&&n+1<e.length){let c=e[n+1];if(c==="."||c==="="){let u=`${c}]`,f=e.indexOf(u,n+2);if(f!==-1){let p=e.slice(n+2,f);o+=p,n=f+2;continue}}}if(l==="\\"&&n+1<e.length){o+=l+e[n+1],n+=2;continue}o+=l,n++}return a?(s&&(r+="\\]"),i&&(r+="\\["),r+=o,r+="]",{converted:r,endIndex:n}):{converted:"\\[",endIndex:t+1}}function ON(e){return{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"!-~",lower:"a-z",print:" -~",punct:"!-/:-@\\[-`{-~",space:" \\t\\n\\r\\f\\v",upper:"A-Z",word:"a-zA-Z0-9_",xdigit:"0-9A-Fa-f"}[e]??""}ot();Je();Fe();it();sn();function Vt(e){let t=[],n="",r=!1,s=!1,i=!1,o=!1;for(let a of e){if(i){n+=a,i=!1,o=!0;continue}if(a==="\\"){i=!0;continue}if(a==="'"&&!s){r||(o=!0),r=!r;continue}if(a==='"'&&!r){s||(o=!0),s=!s;continue}if((a===" "||a===" "||a===`
782
- `)&&!r&&!s){o&&(t.push(n),n="",o=!1);continue}n+=a,o=!0}return o&&t.push(n),t}function Ni(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]!=="["){n++;continue}n++;let r="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)r+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&e[n]!=="]"&&e[n]!=="=";)r+=e[n],n++;for(;n<e.length&&e[n]!=="]";)n++;if(e[n]==="]"&&n++,e[n]!=="=")continue;n++;let s="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)e[n]==="\\"&&n+1<e.length&&n++,s+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;t.push([r,s])}return t}function U0(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:Vt(t[2])};let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(n)return{name:n[1],isArray:!1,arrayIndex:n[2],value:n[3]};if(e.includes("=")){let r=e.indexOf("=");return{name:e.slice(0,r),isArray:!1,value:e.slice(r+1)}}return{name:e,isArray:!1}}async function DN(e,t){try{let n=new se,r=he(n,t);return await Q(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}async function z0(e,t,n={}){let{name:r,isArray:s,arrayElements:i,value:o,arrayIndex:a}=t,{makeReadonly:l=!1,checkReadonly:c=!0}=n;if(c){let u=je(e,r);if(u)return u}if(s&&i){for(let u=0;u<i.length;u++)e.state.env[`${r}_${u}`]=i[u];e.state.env[`${r}__length`]=String(i.length)}else if(a!==void 0&&o!==void 0){let u=await DN(e,a);e.state.env[`${r}_${u}`]=o;let f=parseInt(e.state.env[`${r}__length`]??"0",10);u>=f&&(e.state.env[`${r}__length`]=String(u+1))}else o!==void 0&&(e.state.env[r]=o);return l&&gt(e,r),null}function ln(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function ar(e,t){return e.state.localVarDepth?.get(t)}function ki(e,t){e.state.localVarDepth?.delete(t)}function j0(e,t,n){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:n,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function vi(e,t){let n=e.state.localVarStack?.get(t);if(!(!n||n.length===0))return n.pop()}function H0(e,t){if(e.state.localVarStack)for(let[n,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(n)}}de();ot();var al=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function V0(e){return al.has(e)}var ll=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),jr=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"]);ot();async function $n(e,t,n,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${n}: Is a directory
781
+ `,2):Le(n.value)}async function _0(e,t,n){return $N(e,t,n)}async function $N(e,t,n){let{value:r,pos:s}=await O0(e,t,n);for(;t[s]==="-o";){let i=await O0(e,t,s+1);r=r||i.value,s=i.pos}return{value:r,pos:s}}async function O0(e,t,n){let{value:r,pos:s}=await il(e,t,n);for(;t[s]==="-a";){let i=await il(e,t,s+1);r=r&&i.value,s=i.pos}return{value:r,pos:s}}async function il(e,t,n){if(t[n]==="!"){let{value:r,pos:s}=await il(e,t,n+1);return{value:!r,pos:s}}return IN(e,t,n)}async function IN(e,t,n){let r=t[n];if(r==="("){let{value:i,pos:o}=await _0(e,t,n+1);return{value:i,pos:t[o]===")"?o+1:o}}let s=t[n+1];if(Ur(s)){let i=r,o=t[n+2]??"";return{value:xi(s,i,o),pos:n+3}}if(bi(s)){let i=Ci(r),o=Ci(t[n+2]??"0");return!i.valid||!o.valid?{value:!1,pos:n+3}:{value:wi(s,i.value,o.value),pos:n+3}}if(gi(s)){let i=r,o=t[n+2]??"";return{value:await yi(e,s,i,o),pos:n+3}}if(hi(r)){let i=t[n+1]??"";return{value:await mi(e,r,i),pos:n+2}}if(Ei(r)){let i=t[n+1]??"";return{value:Si(r,i),pos:n+2}}if(r==="-v"){let i=t[n+1]??"";return{value:await Ai(e,i),pos:n+2}}if(r==="-o"){let i=t[n+1]??"";return{value:ol(e,i),pos:n+2}}return{value:r!==void 0&&r!=="",pos:n+1}}function or(e,t,n=!1,r=!1){let s=`^${L0(t,r)}$`,i=n?"is":"s";return new RegExp(s,i).test(e)}function L0(e,t){let n="";for(let r=0;r<e.length;r++){let s=e[r];if(t&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<e.length&&e[r+1]==="("){let i=M0(e,r+1);if(i!==-1){let o=e.slice(r+2,i),a=W0(o),l=a.map(u=>L0(u,t)),c=l.length>0?l.join("|"):"(?:)";if(s==="@")n+=`(?:${c})`;else if(s==="*")n+=`(?:${c})*`;else if(s==="+")n+=`(?:${c})+`;else if(s==="?")n+=`(?:${c})?`;else if(s==="!")if(i<e.length-1){let f=a.map(d=>B0(d,t));if(f.every(d=>d!==null)&&f.every(d=>d===f[0])&&f[0]!==null){let d=f[0];if(d===0)n+="(?:.+)";else{let m=[];d>0&&m.push(`.{0,${d-1}}`),m.push(`.{${d+1},}`),m.push(`(?!(?:${c})).{${d}}`),n+=`(?:${m.join("|")})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`;r=i;continue}}if(s==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r++}else n+="\\\\";else if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=e.indexOf("]",r+1);i!==-1?(n+=e.slice(r,i+1),r=i):n+="\\["}else/[\\^$.|+(){}]/.test(s)?n+=`\\${s}`:n+=s}return n}function M0(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function W0(e){let t=[],n="",r=0,s=0;for(;s<e.length;){let i=e[s];if(i==="\\"){n+=i,s+1<e.length?(n+=e[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(t.push(n),n=""):n+=i,s++}return t.push(n),t}function B0(e,t){let n=0,r=0;for(;r<e.length;){let s=e[r];if(t&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<e.length&&e[r+1]==="("){let i=M0(e,r+1);if(i!==-1){if(s==="@"){let o=e.slice(r+2,i),l=W0(o).map(c=>B0(c,t));if(l.every(c=>c!==null)&&l.every(c=>c===l[0])){n+=l[0],r=i+1;continue}return null}return null}}if(s==="*")return null;if(s==="?"){n+=1,r++;continue}if(s==="["){let i=e.indexOf("]",r+1);if(i!==-1){n+=1,r=i+1;continue}n+=1,r++;continue}if(s==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}function ol(e,t){let r={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}[t];return r?r():!1}async function D0(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 F0(t);try{let n=new se,r=he(n,t);return await Q(e,r.expression)}catch{return F0(t)}}function RN(e,t){let n=0;for(let r of e){let s;if(r>="0"&&r<="9")s=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")s=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")s=r.charCodeAt(0)-65+36;else if(r==="@")s=62;else if(r==="_")s=63;else return Number.NaN;if(s>=t)return Number.NaN;n=n*t+s}return n}function F0(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 n,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let s=Number.parseInt(r[1],10);s>=2&&s<=64?n=RN(r[2],s):n=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?n=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?n=Number.parseInt(e,8):n=Number.parseInt(e,10);return Number.isNaN(n)&&(n=0),t?-n:n}function Ci(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 n=Number.parseInt(e,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:t?-n:n,valid:!0}}function PN(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length)t+=e[n]+e[n+1],n+=2;else if(e[n]==="["){let r=TN(e,n);t+=r.converted,n=r.endIndex}else t+=e[n],n++;return t}function TN(e,t){let n=t+1,r="[";n<e.length&&(e[n]==="^"||e[n]==="!")&&(r+="^",n++);let s=!1;n<e.length&&e[n]==="]"&&(s=!0,n++);let i=!1;n<e.length&&e[n]==="["&&n+1<e.length&&e[n+1]!==":"&&(i=!0,n++);let o="",a=!1;for(;n<e.length;){let l=e[n];if(l==="]"){a=!0,n++;break}if(l==="["&&n+1<e.length&&e[n+1]===":"){let c=e.indexOf(":]",n+2);if(c!==-1){let u=e.slice(n+2,c);o+=ON(u),n=c+2;continue}}if(l==="["&&n+1<e.length){let c=e[n+1];if(c==="."||c==="="){let u=`${c}]`,f=e.indexOf(u,n+2);if(f!==-1){let p=e.slice(n+2,f);o+=p,n=f+2;continue}}}if(l==="\\"&&n+1<e.length){o+=l+e[n+1],n+=2;continue}o+=l,n++}return a?(s&&(r+="\\]"),i&&(r+="\\["),r+=o,r+="]",{converted:r,endIndex:n}):{converted:"\\[",endIndex:t+1}}function ON(e){return{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"!-~",lower:"a-z",print:" -~",punct:"!-/:-@\\[-`{-~",space:" \\t\\n\\r\\f\\v",upper:"A-Z",word:"a-zA-Z0-9_",xdigit:"0-9A-Fa-f"}[e]??""}ot();Je();Fe();it();on();function Vt(e){let t=[],n="",r=!1,s=!1,i=!1,o=!1;for(let a of e){if(i){n+=a,i=!1,o=!0;continue}if(a==="\\"){i=!0;continue}if(a==="'"&&!s){r||(o=!0),r=!r;continue}if(a==='"'&&!r){s||(o=!0),s=!s;continue}if((a===" "||a===" "||a===`
782
+ `)&&!r&&!s){o&&(t.push(n),n="",o=!1);continue}n+=a,o=!0}return o&&t.push(n),t}function Ni(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]!=="["){n++;continue}n++;let r="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)r+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&e[n]!=="]"&&e[n]!=="=";)r+=e[n],n++;for(;n<e.length&&e[n]!=="]";)n++;if(e[n]==="]"&&n++,e[n]!=="=")continue;n++;let s="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)e[n]==="\\"&&n+1<e.length&&n++,s+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;t.push([r,s])}return t}function U0(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:Vt(t[2])};let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(n)return{name:n[1],isArray:!1,arrayIndex:n[2],value:n[3]};if(e.includes("=")){let r=e.indexOf("=");return{name:e.slice(0,r),isArray:!1,value:e.slice(r+1)}}return{name:e,isArray:!1}}async function DN(e,t){try{let n=new se,r=he(n,t);return await Q(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}async function z0(e,t,n={}){let{name:r,isArray:s,arrayElements:i,value:o,arrayIndex:a}=t,{makeReadonly:l=!1,checkReadonly:c=!0}=n;if(c){let u=je(e,r);if(u)return u}if(s&&i){for(let u=0;u<i.length;u++)e.state.env[`${r}_${u}`]=i[u];e.state.env[`${r}__length`]=String(i.length)}else if(a!==void 0&&o!==void 0){let u=await DN(e,a);e.state.env[`${r}_${u}`]=o;let f=parseInt(e.state.env[`${r}__length`]??"0",10);u>=f&&(e.state.env[`${r}__length`]=String(u+1))}else o!==void 0&&(e.state.env[r]=o);return l&&gt(e,r),null}function cn(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function ar(e,t){return e.state.localVarDepth?.get(t)}function ki(e,t){e.state.localVarDepth?.delete(t)}function j0(e,t,n){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:n,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function vi(e,t){let n=e.state.localVarStack?.get(t);if(!(!n||n.length===0))return n.pop()}function H0(e,t){if(e.state.localVarStack)for(let[n,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(n)}}de();ot();var al=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function V0(e){return al.has(e)}var ll=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),jr=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"]);ot();async function $n(e,t,n,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${n}: Is a directory
783
783
  `;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&n!=="/dev/null")return`bash: ${n}: cannot overwrite existing file
784
784
  `}catch{}return null}function He(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return"utf8";return"binary"}function FN(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),n=t.indexOf(":");if(n===-1)return null;let r=Number.parseInt(t.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let s=n+1,i=t.slice(s,s+r),o=s+r+1,a=t.slice(o),l=a.indexOf(":");if(l===-1)return null;let c=Number.parseInt(a.slice(0,l),10);if(Number.isNaN(c)||c<0)return null;let u=a.slice(l+1);return{path:i,position:c,content:u}}async function q0(e,t){let n=new Map;for(let r=0;r<t.length;r++){let s=t[r];if(s.target.type==="HereDoc")continue;if(s.operator===">&"||s.operator==="<&"){if(Wr(e,s.target))return{targets:n,error:`bash: $@: ambiguous redirect
785
785
  `};n.set(r,await J(e,s.target))}else{let o=await Br(e,s.target);if("error"in o)return{targets:n,error:o.error};n.set(r,o.target)}}return{targets:n}}function _N(e){e.state.nextFd===void 0&&(e.state.nextFd=10);let t=e.state.nextFd;return e.state.nextFd++,t}async function $i(e,t){for(let n of t){if(!n.fdVariable)continue;if(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),(n.operator===">&"||n.operator==="<&")&&n.target.type==="Word"&&await J(e,n.target)==="-"){let i=e.state.env[n.fdVariable];if(i!==void 0){let o=Number.parseInt(i,10);Number.isNaN(o)||e.state.fileDescriptors.delete(o)}continue}let r=_N(e);if(e.state.env[n.fdVariable]=String(r),n.target.type==="Word"){let s=await J(e,n.target);if(n.operator===">&"||n.operator==="<&"){let i=Number.parseInt(s,10);if(!Number.isNaN(i)){let o=e.state.fileDescriptors.get(i);o!==void 0&&e.state.fileDescriptors.set(r,o);continue}}if(n.operator===">"||n.operator===">>"||n.operator===">|"||n.operator==="&>"||n.operator==="&>>"){let i=e.fs.resolvePath(e.state.cwd,s);(n.operator===">"||n.operator===">|"||n.operator==="&>")&&await e.fs.writeFile(i,"","binary"),e.state.fileDescriptors.set(r,`__file__:${i}`)}else if(n.operator==="<<<")e.state.fileDescriptors.set(r,`${s}
@@ -841,7 +841,7 @@ Gid: ${r} ${r} ${r} ${r}
841
841
  `,2);i.push(c)}else if(l==="--"){o.push(...t.slice(a+1));break}else!l.startsWith("-")&&!l.startsWith("+")&&o.push(l)}if(n){let a=e.state.completionSpecs.get("__default__")??{isDefault:!0},l=new Set(a.options??[]);for(let c of s)l.add(c);for(let c of i)l.delete(c);return a.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__default__",a),ue("")}if(r){let a=e.state.completionSpecs.get("__empty__")??{},l=new Set(a.options??[]);for(let c of s)l.add(c);for(let c of i)l.delete(c);return a.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__empty__",a),ue("")}if(o.length>0){for(let a of o){let l=e.state.completionSpecs.get(a)??{},c=new Set(l.options??[]);for(let u of s)c.add(u);for(let u of i)c.delete(u);l.options=c.size>0?Array.from(c):void 0,e.state.completionSpecs.set(a,l)}return ue("")}return M(`compopt: not currently executing completion function
842
842
  `,1)}de();function ml(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Lt;return le}if(t.length>1)throw new ae(1,"",`bash: continue: too many arguments
843
843
  `);let n=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new ae(1,"",`bash: continue: ${t[0]}: numeric argument required
844
- `);n=r}throw new Ke(n)}Je();Fe();it();$t();Tt();sn();function Te(e,t){let n=e.state.env.HOME||"/home/user";return t.split(":").map(i=>i==="~"?n:i==="~root"?"/root":i.startsWith("~/")?n+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}$t();Tt();function gl(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!0}return!1}function yl(e){let t="$'";for(let n=0;n<e.length;n++){let r=e[n],s=e.charCodeAt(n);s===7?t+="\\a":s===8?t+="\\b":s===9?t+="\\t":s===10?t+="\\n":s===11?t+="\\v":s===12?t+="\\f":s===13?t+="\\r":s===27?t+="\\e":s===39?t+="\\'":s===92?t+="\\\\":s<32||s===127?t+=`\\${s.toString(8).padStart(3,"0")}`:t+=r}return t+="'",t}function Ri(e){return gl(e)?yl(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function In(e){return gl(e)?yl(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function bl(e){return gl(e)?yl(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function X0(e,t){let n="";return e.state.integerVars?.has(t)&&(n+="i"),e.state.lowercaseVars?.has(t)&&(n+="l"),Se(e,t)&&(n+="n"),e.state.readonlyVars?.has(t)&&(n+="r"),e.state.uppercaseVars?.has(t)&&(n+="u"),e.state.exportedVars?.has(t)&&(n+="x"),n===""?"--":`-${n}`}function wl(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function J0(e,t){let n="",r="",s=!1;for(let i of t){let o=X0(e,i);if(e.state.associativeArrays?.has(i)){let u=Pt(e,i);if(u.length===0)n+=`declare -A ${i}=()
844
+ `);n=r}throw new Ke(n)}Je();Fe();it();$t();Tt();on();function Te(e,t){let n=e.state.env.HOME||"/home/user";return t.split(":").map(i=>i==="~"?n:i==="~root"?"/root":i.startsWith("~/")?n+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}$t();Tt();function gl(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!0}return!1}function yl(e){let t="$'";for(let n=0;n<e.length;n++){let r=e[n],s=e.charCodeAt(n);s===7?t+="\\a":s===8?t+="\\b":s===9?t+="\\t":s===10?t+="\\n":s===11?t+="\\v":s===12?t+="\\f":s===13?t+="\\r":s===27?t+="\\e":s===39?t+="\\'":s===92?t+="\\\\":s<32||s===127?t+=`\\${s.toString(8).padStart(3,"0")}`:t+=r}return t+="'",t}function Ri(e){return gl(e)?yl(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function In(e){return gl(e)?yl(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function bl(e){return gl(e)?yl(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function X0(e,t){let n="";return e.state.integerVars?.has(t)&&(n+="i"),e.state.lowercaseVars?.has(t)&&(n+="l"),Se(e,t)&&(n+="n"),e.state.readonlyVars?.has(t)&&(n+="r"),e.state.uppercaseVars?.has(t)&&(n+="u"),e.state.exportedVars?.has(t)&&(n+="x"),n===""?"--":`-${n}`}function wl(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function J0(e,t){let n="",r="",s=!1;for(let i of t){let o=X0(e,i);if(e.state.associativeArrays?.has(i)){let u=Pt(e,i);if(u.length===0)n+=`declare -A ${i}=()
845
845
  `;else{let f=u.map(p=>{let d=e.state.env[`${i}_${p}`]??"",m=wl(d);return`['${p}']=${m}`});n+=`declare -A ${i}=(${f.join(" ")})
846
846
  `}continue}let l=_e(e,i);if(l.length>0){let u=l.map(f=>{let p=e.state.env[`${i}_${f}`]??"";return`[${f}]=${In(p)}`});n+=`declare -a ${i}=(${u.join(" ")})
847
847
  `;continue}if(e.state.env[`${i}__length`]!==void 0){n+=`declare -a ${i}=()
@@ -860,7 +860,7 @@ Gid: ${r} ${r} ${r} ${r}
860
860
  `}}return ue(t)}function ny(e){let t="",n=new Set;for(let s of Object.keys(e.state.env)){if(s.startsWith("BASH_"))continue;if(s.endsWith("__length")){let o=s.slice(0,-8);n.add(o);continue}let i=s.lastIndexOf("_");if(i>0){let o=s.slice(0,i),a=s.slice(i+1);if(/^\d+$/.test(a)||e.state.associativeArrays?.has(o)){n.add(o);continue}}n.add(s)}let r=Array.from(n).sort();for(let s of r){if(e.state.associativeArrays?.has(s)||_e(e,s).length>0||e.state.env[`${s}__length`]!==void 0)continue;let a=e.state.env[s];a!==void 0&&(t+=`${s}=${Ri(a)}
861
861
  `)}return ue(t)}function xl(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function Hr(e,t){return e.state.integerVars?.has(t)??!1}function El(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function ek(e,t){return e.state.lowercaseVars?.has(t)??!1}function Sl(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function tk(e,t){return e.state.uppercaseVars?.has(t)??!1}function cr(e,t,n){return ek(e,t)?n.toLowerCase():tk(e,t)?n.toUpperCase():n}async function ry(e,t){try{let n=new se,r=he(n,t),s=await Q(e,r.expression);return String(s)}catch{return"0"}}function nk(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let n=t[0],r=n.length;if(e[r]!=="[")return null;let s=0,i=r+1;for(;r<e.length;r++)if(e[r]==="[")s++;else if(e[r]==="]"&&(s--,s===0))break;if(s!==0)return null;let o=e.slice(i,r);if(r++,e[r]!=="=")return null;r++;let a=e.slice(r);return{name:n,indexExpr:o,value:a}}async function Al(e,t){let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,p=!1,d=!1,m=!1,h=!1,g=!1,b=[];for(let L=0;L<t.length;L++){let D=t[L];if(D==="-a")n=!0;else if(D==="-A")r=!0;else if(D==="-r")s=!0;else if(D==="-x")i=!0;else if(D==="-p")o=!0;else if(D==="-n")a=!0;else if(D==="+n")l=!0;else if(D==="+a")c=!0;else if(D==="+x")u=!0;else if(D==="--"){b.push(...t.slice(L+1));break}else if(D.startsWith("+")){for(let $ of D.slice(1))if($==="n")l=!0;else if($==="a")c=!0;else if($==="x")u=!0;else if($!=="r"){if($!=="i"){if(!($==="f"||$==="F"))return W("",`bash: typeset: +${$}: invalid option
862
862
  `,2)}}}else if(D==="-i")f=!0;else if(D==="-l")p=!0;else if(D==="-u")d=!0;else if(D==="-f")m=!0;else if(D==="-F")h=!0;else if(D==="-g")g=!0;else if(D.startsWith("-"))for(let $ of D.slice(1))if($==="a")n=!0;else if($==="A")r=!0;else if($==="r")s=!0;else if($==="x")i=!0;else if($==="p")o=!0;else if($==="n")a=!0;else if($==="i")f=!0;else if($==="l")p=!0;else if($==="u")d=!0;else if($==="f")m=!0;else if($==="F")h=!0;else if($==="g")g=!0;else return W("",`bash: typeset: -${$}: invalid option
863
- `,2);else b.push(D)}let w=e.state.localScopes.length>0&&!g,E=L=>{if(!w)return;let D=e.state.localScopes[e.state.localScopes.length-1];D.has(L)||D.set(L,e.state.env[L])},C=L=>{if(!w)return;let D=e.state.localScopes[e.state.localScopes.length-1];D.has(L)||D.set(L,e.state.env[L]);let $=`${L}_`;for(let P of Object.keys(e.state.env))P.startsWith($)&&!P.includes("__")&&(D.has(P)||D.set(P,e.state.env[P]));let N=`${L}__length`;e.state.env[N]!==void 0&&!D.has(N)&&D.set(N,e.state.env[N])},A=L=>{w&&ln(e,L)};if(h){if(b.length===0){let $=Array.from(e.state.functions.keys()).sort(),N="";for(let P of $)N+=`declare -f ${P}
863
+ `,2);else b.push(D)}let w=e.state.localScopes.length>0&&!g,E=L=>{if(!w)return;let D=e.state.localScopes[e.state.localScopes.length-1];D.has(L)||D.set(L,e.state.env[L])},C=L=>{if(!w)return;let D=e.state.localScopes[e.state.localScopes.length-1];D.has(L)||D.set(L,e.state.env[L]);let $=`${L}_`;for(let P of Object.keys(e.state.env))P.startsWith($)&&!P.includes("__")&&(D.has(P)||D.set(P,e.state.env[P]));let N=`${L}__length`;e.state.env[N]!==void 0&&!D.has(N)&&D.set(N,e.state.env[N])},A=L=>{w&&cn(e,L)};if(h){if(b.length===0){let $=Array.from(e.state.functions.keys()).sort(),N="";for(let P of $)N+=`declare -f ${P}
864
864
  `;return ue(N)}let L=!0,D="";for(let $ of b)e.state.functions.has($)?D+=`${$}
865
865
  `:L=!1;return W(D,"",L?0:1)}if(m){if(b.length===0){let D="",$=Array.from(e.state.functions.keys()).sort();for(let N of $)D+=`${N} ()
866
866
  {
@@ -896,7 +896,7 @@ Gid: ${r} ${r} ${r} ${r}
896
896
  eval: usage: eval [arg ...]
897
897
  `,2)}if(r.length===0)return le;let s=r.join(" ");if(s.trim()==="")return le;let i=e.state.groupStdin,o=n??e.state.groupStdin;o!==void 0&&(e.state.groupStdin=o);try{let a=Bt(s);return await e.executeScript(a)}catch(a){if(a instanceof Qe||a instanceof Ke||a instanceof Ve||a instanceof ae)throw a;if(a.name==="ParseException")return M(`bash: eval: ${a.message}
898
898
  `);throw a}finally{e.state.groupStdin=i}}de();function Il(e,t){let n,r="";if(t.length===0)n=e.state.lastExitCode;else{let s=t[0],i=Number.parseInt(s,10);s===""||Number.isNaN(i)||!/^-?\d+$/.test(s)?(r=`bash: exit: ${s}: numeric argument required
899
- `,n=2):n=(i%256+256)%256}throw new ae(n,"",r)}sn();function Rl(e,t){let n=!1,r=[];for(let o of t)o==="-n"?n=!0:o==="-p"||o==="--"||r.push(o);if(r.length===0&&!n){let o="",a=e.state.exportedVars??new Set,l=Array.from(a).sort();for(let c of l){let u=e.state.env[c];if(u!==void 0){let f=u.replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -x ${c}="${f}"
899
+ `,n=2):n=(i%256+256)%256}throw new ae(n,"",r)}on();function Rl(e,t){let n=!1,r=[];for(let o of t)o==="-n"?n=!0:o==="-p"||o==="--"||r.push(o);if(r.length===0&&!n){let o="",a=e.state.exportedVars??new Set,l=Array.from(a).sort();for(let c of l){let u=e.state.env[c];if(u!==void 0){let f=u.replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -x ${c}="${f}"
900
900
  `}}return ue(o)}if(n){for(let o of r){let a,l;if(o.includes("=")){let c=o.indexOf("=");a=o.slice(0,c),l=Te(e,o.slice(c+1)),e.state.env[a]=l}else a=o;oi(e,a)}return le}let s="",i=0;for(let o of r){let a,l,c=!1,u=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(u)a=u[1],l=Te(e,u[2]),c=!0;else if(o.includes("=")){let f=o.indexOf("=");a=o.slice(0,f),l=Te(e,o.slice(f+1))}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){s+=`bash: export: \`${o}': not a valid identifier
901
901
  `,i=1;continue}if(l!==void 0)if(c){let f=e.state.env[a]??"";e.state.env[a]=f+l}else e.state.env[a]=l;else a in e.state.env||(e.state.env[a]="");Ot(e,a)}return W("",s,i)}function Ti(e,t){if(t.length<2)return M(`bash: getopts: usage: getopts optstring name [arg ...]
902
902
  `);let n=t[0],r=t[1],s=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),i=n.startsWith(":"),o=i?n.slice(1):n,a;if(t.length>2)a=t.slice(2);else{let h=Number.parseInt(e.state.env["#"]||"0",10);a=[];for(let g=1;g<=h;g++)a.push(e.state.env[String(g)]||"")}let l=Number.parseInt(e.state.env.OPTIND||"1",10);l<1&&(l=1);let c=Number.parseInt(e.state.env.__GETOPTS_CHARINDEX||"0",10);if(e.state.env.OPTARG="",l>a.length)return s||(e.state.env[r]="?"),e.state.env.OPTIND=String(a.length+1),e.state.env.__GETOPTS_CHARINDEX="0",{exitCode:s?2:1,stdout:"",stderr:""};let u=a[l-1];if(!u||u==="-"||!u.startsWith("-"))return s||(e.state.env[r]="?"),{exitCode:s?2:1,stdout:"",stderr:""};if(u==="--")return e.state.env.OPTIND=String(l+1),e.state.env.__GETOPTS_CHARINDEX="0",s||(e.state.env[r]="?"),{exitCode:s?2:1,stdout:"",stderr:""};let f=c===0?1:c,p=u[f];if(!p)return e.state.env.OPTIND=String(l+1),e.state.env.__GETOPTS_CHARINDEX="0",Ti(e,t);let d=o.indexOf(p);if(d===-1){let h="";return i?e.state.env.OPTARG=p:h=`bash: illegal option -- ${p}
@@ -1271,12 +1271,12 @@ ${p}
1271
1271
  `)}
1272
1272
  `)}Fe();it();function ok(e){let t=[],n="",r=0;for(let s of e){for(let i of s)i==="("?r++:i===")"&&r--;n?n+=` ${s}`:n=s,r===0&&(t.push(n),n="")}return n&&t.push(n),t}async function Ol(e,t){if(t.length===0)return M(`bash: let: expression expected
1273
1273
  `);let n=ok(t),r=0;for(let s of n)try{let o=Bt(`(( ${s} ))`).statements[0];if(o&&o.pipelines.length>0&&o.pipelines[0].commands.length>0){let a=o.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(r=await Q(e,a.expression.expression))}}catch(i){return M(`bash: let: ${s}: ${i.message}
1274
- `)}return W("","",r===0?1:0)}Je();Fe();it();$t();Tt();sn();async function Dl(e,t){if(e.state.localScopes.length===0)return M(`bash: local: can only be used in a function
1274
+ `)}return W("","",r===0?1:0)}Je();Fe();it();$t();Tt();on();async function Dl(e,t){if(e.state.localScopes.length===0)return M(`bash: local: can only be used in a function
1275
1275
  `);let n=e.state.localScopes[e.state.localScopes.length-1],r="",s=0,i=!1,o=!1,a=!1,l=[];for(let c of t)if(c==="-n")i=!0;else if(c==="-a")o=!0;else if(c==="-p")a=!0;else if(c.startsWith("-")&&!c.includes("="))for(let u of c.slice(1))u==="n"?i=!0:u==="a"?o=!0:u==="p"&&(a=!0);else l.push(c);if(l.length===0){let c="",u=Array.from(n.keys()).filter(f=>!f.includes("_")||!f.match(/_\d+$/)).filter(f=>!f.includes("__length")).sort();for(let f of u){let p=e.state.env[f];p!==void 0&&(c+=`${f}=${p}
1276
1276
  `)}return W(c,"",0)}for(let c of l){let u,f,p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(p){u=p[1];let b=p[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1277
- `,s=1;continue}if(je(e,u,"bash"),!n.has(u)){n.set(u,e.state.env[u]);let E=`${u}_`;for(let C of Object.keys(e.state.env))C.startsWith(E)&&!C.includes("__")&&(n.has(C)||n.set(C,e.state.env[C]))}let y=`${u}_`;for(let E of Object.keys(e.state.env))E.startsWith(y)&&!E.includes("__")&&delete e.state.env[E];let w=Vt(b);for(let E=0;E<w.length;E++)e.state.env[`${u}_${E}`]=w[E];e.state.env[`${u}__length`]=String(w.length),ln(e,u),i&&Zt(e,u);continue}let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(d){u=d[1];let b=d[2];if(je(e,u,"bash"),!n.has(u)){n.set(u,e.state.env[u]);let A=`${u}_`;for(let O of Object.keys(e.state.env))O.startsWith(A)&&!O.includes("__")&&(n.has(O)||n.set(O,e.state.env[O]));let I=`${u}__length`;e.state.env[I]!==void 0&&!n.has(I)&&n.set(I,e.state.env[I])}let y=Vt(b),w=_e(e,u),E=0;if(w.length===0&&e.state.env[u]!==void 0){let A=e.state.env[u];e.state.env[`${u}_0`]=A,delete e.state.env[u],E=1}else w.length>0&&(E=Math.max(...w)+1);for(let A=0;A<y.length;A++)e.state.env[`${u}_${E+A}`]=Te(e,y[A]);let C=E+y.length;e.state.env[`${u}__length`]=String(C),ln(e,u),i&&Zt(e,u);continue}let m=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){u=m[1];let b=Te(e,m[2]);je(e,u,"bash"),n.has(u)||n.set(u,e.state.env[u]);let y=e.state.env[u]??"";e.state.env[u]=y+b,ln(e,u),i&&Zt(e,u);continue}let h=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(h){u=h[1];let b=h[2],y=Te(e,h[3]);if(je(e,u,"bash"),!n.has(u)){n.set(u,e.state.env[u]);let C=`${u}_`;for(let I of Object.keys(e.state.env))I.startsWith(C)&&!I.includes("__")&&(n.has(I)||n.set(I,e.state.env[I]));let A=`${u}__length`;e.state.env[A]!==void 0&&!n.has(A)&&n.set(A,e.state.env[A])}let w;try{let C=new se,A=he(C,b);w=await Q(e,A.expression)}catch{let C=parseInt(b,10);w=Number.isNaN(C)?0:C}e.state.env[`${u}_${w}`]=y;let E=parseInt(e.state.env[`${u}__length`]??"0",10);w>=E&&(e.state.env[`${u}__length`]=String(w+1)),ln(e,u),i&&Zt(e,u);continue}if(c.includes("=")){let b=c.indexOf("=");u=c.slice(0,b),f=Te(e,c.slice(b+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1277
+ `,s=1;continue}if(je(e,u,"bash"),!n.has(u)){n.set(u,e.state.env[u]);let E=`${u}_`;for(let C of Object.keys(e.state.env))C.startsWith(E)&&!C.includes("__")&&(n.has(C)||n.set(C,e.state.env[C]))}let y=`${u}_`;for(let E of Object.keys(e.state.env))E.startsWith(y)&&!E.includes("__")&&delete e.state.env[E];let w=Vt(b);for(let E=0;E<w.length;E++)e.state.env[`${u}_${E}`]=w[E];e.state.env[`${u}__length`]=String(w.length),cn(e,u),i&&Zt(e,u);continue}let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(d){u=d[1];let b=d[2];if(je(e,u,"bash"),!n.has(u)){n.set(u,e.state.env[u]);let A=`${u}_`;for(let O of Object.keys(e.state.env))O.startsWith(A)&&!O.includes("__")&&(n.has(O)||n.set(O,e.state.env[O]));let I=`${u}__length`;e.state.env[I]!==void 0&&!n.has(I)&&n.set(I,e.state.env[I])}let y=Vt(b),w=_e(e,u),E=0;if(w.length===0&&e.state.env[u]!==void 0){let A=e.state.env[u];e.state.env[`${u}_0`]=A,delete e.state.env[u],E=1}else w.length>0&&(E=Math.max(...w)+1);for(let A=0;A<y.length;A++)e.state.env[`${u}_${E+A}`]=Te(e,y[A]);let C=E+y.length;e.state.env[`${u}__length`]=String(C),cn(e,u),i&&Zt(e,u);continue}let m=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){u=m[1];let b=Te(e,m[2]);je(e,u,"bash"),n.has(u)||n.set(u,e.state.env[u]);let y=e.state.env[u]??"";e.state.env[u]=y+b,cn(e,u),i&&Zt(e,u);continue}let h=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(h){u=h[1];let b=h[2],y=Te(e,h[3]);if(je(e,u,"bash"),!n.has(u)){n.set(u,e.state.env[u]);let C=`${u}_`;for(let I of Object.keys(e.state.env))I.startsWith(C)&&!I.includes("__")&&(n.has(I)||n.set(I,e.state.env[I]));let A=`${u}__length`;e.state.env[A]!==void 0&&!n.has(A)&&n.set(A,e.state.env[A])}let w;try{let C=new se,A=he(C,b);w=await Q(e,A.expression)}catch{let C=parseInt(b,10);w=Number.isNaN(C)?0:C}e.state.env[`${u}_${w}`]=y;let E=parseInt(e.state.env[`${u}__length`]??"0",10);w>=E&&(e.state.env[`${u}__length`]=String(w+1)),cn(e,u),i&&Zt(e,u);continue}if(c.includes("=")){let b=c.indexOf("=");u=c.slice(0,b),f=Te(e,c.slice(b+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1278
1278
  `,s=1;continue}let g=n.has(u);if(f!==void 0){let b=e.state.env[u];if(e.state.tempEnvBindings){let y=e.state.accessedTempEnvVars?.has(u),w=e.state.mutatedTempEnvVars?.has(u);if(!y&&!w)for(let E=e.state.tempEnvBindings.length-1;E>=0;E--){let C=e.state.tempEnvBindings[E];if(C.has(u)){b=C.get(u);break}}}j0(e,u,b)}if(!g){let b=e.state.env[u];if(e.state.tempEnvBindings)for(let y=e.state.tempEnvBindings.length-1;y>=0;y--){let w=e.state.tempEnvBindings[y];if(w.has(u)){b=w.get(u);break}}if(n.set(u,b),o){let y=`${u}_`;for(let E of Object.keys(e.state.env))E.startsWith(y)&&!E.includes("__")&&(n.has(E)||n.set(E,e.state.env[E]));let w=`${u}__length`;e.state.env[w]!==void 0&&!n.has(w)&&n.set(w,e.state.env[w])}}if(o&&f===void 0){let b=`${u}_`;for(let y of Object.keys(e.state.env))y.startsWith(b)&&!y.includes("__")&&delete e.state.env[y];e.state.env[`${u}__length`]="0"}else if(f!==void 0){if(je(e,u,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){r+=`bash: local: \`${f}': invalid variable name for name reference
1279
- `,s=1;continue}e.state.env[u]=f,e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(u))}else{let b=e.state.tempEnvBindings?.some(y=>y.has(u));!g&&!b&&delete e.state.env[u]}ln(e,u),i&&Zt(e,u)}return W("",r,s)}$t();function Fl(e,t,n){let r=`
1279
+ `,s=1;continue}e.state.env[u]=f,e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(u))}else{let b=e.state.tempEnvBindings?.some(y=>y.has(u));!g&&!b&&delete e.state.env[u]}cn(e,u),i&&Zt(e,u)}return W("",r,s)}$t();function Fl(e,t,n){let r=`
1280
1280
  `,s=0,i=0,o=0,a=!1,l="MAPFILE",c=0;for(;c<t.length;){let b=t[c];b==="-d"&&c+1<t.length?(r=t[c+1]===""?"\0":t[c+1]||`
1281
1281
  `,c+=2):b==="-n"&&c+1<t.length?(s=Number.parseInt(t[c+1],10)||0,c+=2):b==="-O"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):b==="-s"&&c+1<t.length?(o=Number.parseInt(t[c+1],10)||0,c+=2):b==="-t"?(a=!0,c++):b==="-u"||b==="-C"||b==="-c"?c+=2:(b.startsWith("-")||(l=b),c++)}let u=n;!u&&e.state.groupStdin!==void 0&&(u=e.state.groupStdin);let f=[],p=u,d=0,m=0;for(;p.length>0;){let b=p.indexOf(r);if(b===-1){if(p.length>0){if(m<o)m++;else if(s===0||d<s){let E=p,C=E.indexOf("\0");C!==-1&&(E=E.substring(0,C)),f.push(E),d++}}break}let y=p.substring(0,b),w=y.indexOf("\0");if(w!==-1&&(y=y.substring(0,w)),!a&&r!=="\0"&&(y+=r),p=p.substring(b+r.length),m<o){m++;continue}if(s>0&&d>=s)break;f.push(y),d++}i===0&&Ut(e,l);for(let b=0;b<f.length;b++)e.state.env[`${l}_${i+b}`]=f[b];let h=parseInt(e.state.env[`${l}__length`]||"0",10),g=i+f.length;return e.state.env[`${l}__length`]=String(Math.max(h,g)),e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=""),W("","",0)}$t();St();function ak(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),n=t.indexOf(":");if(n===-1)return null;let r=Number.parseInt(t.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let s=n+1,i=t.slice(s,s+r),o=s+r+1,a=t.slice(o),l=a.indexOf(":");if(l===-1)return null;let c=Number.parseInt(a.slice(0,l),10);if(Number.isNaN(c)||c<0)return null;let u=a.slice(l+1);return{path:i,position:c,content:u}}function lk(e,t,n){return`__rw__:${e.length}:${e}:${t}:${n}`}function _l(e,t,n,r=-1){let s=!1,i=`
1282
1282
  `,o="",a=-1,l=-1,c=null,u=-1,f=-1,p=[],d=0,m=!1,h=($,N)=>{let P=1;for(;P<$.length;){let k=$[P];if(k==="r")s=!0,P++;else if(k==="s")P++;else{if(k==="d")return P+1<$.length?(i=$.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(i=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(k==="n"){if(P+1<$.length){let R=$.substring(P+1);return a=Number.parseInt(R,10),(Number.isNaN(a)||a<0)&&(m=!0,a=0),{nextArgIndex:N+1}}else if(N+1<t.length)return a=Number.parseInt(t[N+1],10),(Number.isNaN(a)||a<0)&&(m=!0,a=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(k==="N"){if(P+1<$.length){let R=$.substring(P+1);return l=Number.parseInt(R,10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:N+1}}else if(N+1<t.length)return l=Number.parseInt(t[N+1],10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else{if(k==="a")return P+1<$.length?(c=$.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(c=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(k==="p")return P+1<$.length?(o=$.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(o=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(k==="u"){if(P+1<$.length){let R=$.substring(P+1);return u=Number.parseInt(R,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:N+1}}else if(N+1<t.length)return u=Number.parseInt(t[N+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(k==="t"){if(P+1<$.length){let R=$.substring(P+1);return f=Number.parseFloat(R),Number.isNaN(f)&&(f=0),{nextArgIndex:N+1}}else if(N+1<t.length)return f=Number.parseFloat(t[N+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(k==="e"||k==="i"||k==="P"){if(k==="i"&&N+1<t.length)return{nextArgIndex:N+2};P++}else P++}}}return{nextArgIndex:N+1}};for(;d<t.length;){let $=t[d];if($.startsWith("-")&&$.length>1&&$!=="--"){let N=h($,d);if(N.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(N.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};d=N.nextArgIndex}else if($==="--")for(d++;d<t.length;)p.push(t[d]),d++;else p.push($),d++}if(m)return W("","",1);if(p.length===0&&c===null&&p.push("REPLY"),f===0){if(c)Ut(e,c);else{for(let $ of p)e.state.env[$]="";p.length===0&&(e.state.env.REPLY="")}return W("","",0)}if(f<0&&f!==-1)return W("","",1);let g=n;u>=0?e.state.fileDescriptors?g=e.state.fileDescriptors.get(u)||"":g="":!g&&e.state.groupStdin!==void 0&&(g=e.state.groupStdin);let b=i===""?"\0":i,y="",w=0,E=!0,C=$=>{if(u>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(u,g.substring($));else if(r>=0&&e.state.fileDescriptors){let N=e.state.fileDescriptors.get(r);if(N?.startsWith("__rw__:")){let P=ak(N);if(P){let k=P.position+$;e.state.fileDescriptors.set(r,lk(P.path,k,P.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=g.substring($))};if(l>=0){let $=Math.min(l,g.length);y=g.substring(0,$),w=$,E=$>=l,C(w);let N=p[0]||"REPLY";e.state.env[N]=y;for(let P=1;P<p.length;P++)e.state.env[p[P]]="";return W("","",E?0:1)}else if(a>=0){let $=0,N=0,P=!1;for(;N<g.length&&$<a;){let k=g[N];if(k===b){w=N+1,P=!0;break}if(!s&&k==="\\"&&N+1<g.length){let R=g[N+1];if(R===b&&b===`
@@ -1314,7 +1314,7 @@ ${Oi}`;if(e.state.options.posix)throw new xt(1,"",s);return M(s)}return Ml(e,t.s
1314
1314
  `;if(e.state.options.posix)throw new xt(1,"",o);return M(o)}if(n===0)return le;let s=[];for(let o=1;o<=r;o++)s.push(e.state.env[String(o)]||"");let i=s.slice(n);for(let o=1;o<=r;o++)delete e.state.env[String(o)];for(let o=0;o<i.length;o++)e.state.env[String(o+1)]=i[o];return e.state.env["#"]=String(i.length),e.state.env["@"]=i.join(" "),le}Fe();de();async function Ul(e,t){let n=t;if(n.length>0&&n[0]==="--"&&(n=n.slice(1)),n.length===0)return W("",`bash: source: filename argument required
1315
1315
  `,2);let r=n[0],s=null,i=null;if(r.includes("/")){let c=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(c),s=c}catch{}}else{let u=(e.state.env.PATH||"").split(":").filter(f=>f);for(let f of u){let p=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(p)).isDirectory)continue;i=await e.fs.readFile(p),s=p;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(f),s=f}catch{}}}if(i===null)return M(`bash: ${r}: No such file or directory
1316
1316
  `);let o={};if(n.length>1){for(let u=1;u<=9;u++)o[String(u)]=e.state.env[String(u)];o["#"]=e.state.env["#"],o["@"]=e.state.env["@"];let c=n.slice(1);e.state.env["#"]=String(c.length),e.state.env["@"]=c.join(" ");for(let u=0;u<c.length&&u<9;u++)e.state.env[String(u+1)]=c[u];for(let u=c.length+1;u<=9;u++)delete e.state.env[String(u)]}let a=e.state.currentSource,l=()=>{if(e.state.sourceDepth--,e.state.currentSource=a,n.length>1)for(let[c,u]of Object.entries(o))u===void 0?delete e.state.env[c]:e.state.env[c]=u};e.state.sourceDepth++,e.state.currentSource=r;try{let c=Bt(i),u=await e.executeScript(c);return l(),u}catch(c){if(l(),c instanceof ae)throw c;if(c instanceof Ve)return W(c.stdout,c.stderr,c.exitCode);if(c.name==="ParseException")return M(`bash: ${r}: ${c.message}
1317
- `);throw c}}Je();Fe();it();ht();ot();Tt();sn();function fy(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function mk(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function py(e,t){if(mk(t))return null;try{let n=new se,r=he(n,t);return await Q(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}function dy(e,t){if(e.state.localVarStack?.has(t)){let r=vi(e,t);if(r){r.value===void 0?delete e.state.env[t]:e.state.env[t]=r.value;let s=e.state.localVarStack?.get(t);if(!s||s.length===0)ki(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),zl(e,t);else{let i=s[s.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return delete e.state.env[t],ki(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 s=e.state.localScopes[r];if(s.has(t)){let i=s.get(t);i===void 0?delete e.state.env[t]:e.state.env[t]=i,s.delete(t);let o=!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),o=!0;break}return o||ki(e,t),!0}}return!1}function zl(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(t)){let s=r.get(t);return s===void 0?delete e.state.env[t]:e.state.env[t]=s,r.delete(t),!0}}return!1}async function hy(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let n=t.slice(1,-1),s=new se().parseWordFromString(n,!0,!1);return J(e,s)}if(t.includes("$")){let r=new se().parseWordFromString(t,!1,!1);return J(e,r)}return t}async function jl(e,t){let n="both",r="",s=0;for(let i of t){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){e.state.functions.delete(i);continue}if(n==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let p=c[1],d=c[2];if(d==="@"||d==="*"){let w=te(e,p);for(let[E]of w)delete e.state.env[`${p}_${E}`];delete e.state.env[p];continue}let m=e.state.associativeArrays?.has(p);if(m){let w=await hy(e,d);delete e.state.env[`${p}_${w}`];continue}let h=Qt(e,p),g=e.state.declaredVars?.has(p);if((p in e.state.env||g)&&!h&&!m){r+=`bash: unset: ${p}: not an array variable
1317
+ `);throw c}}Je();Fe();it();ht();ot();Tt();on();function fy(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function mk(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function py(e,t){if(mk(t))return null;try{let n=new se,r=he(n,t);return await Q(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}function dy(e,t){if(e.state.localVarStack?.has(t)){let r=vi(e,t);if(r){r.value===void 0?delete e.state.env[t]:e.state.env[t]=r.value;let s=e.state.localVarStack?.get(t);if(!s||s.length===0)ki(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),zl(e,t);else{let i=s[s.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return delete e.state.env[t],ki(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 s=e.state.localScopes[r];if(s.has(t)){let i=s.get(t);i===void 0?delete e.state.env[t]:e.state.env[t]=i,s.delete(t);let o=!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),o=!0;break}return o||ki(e,t),!0}}return!1}function zl(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(t)){let s=r.get(t);return s===void 0?delete e.state.env[t]:e.state.env[t]=s,r.delete(t),!0}}return!1}async function hy(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let n=t.slice(1,-1),s=new se().parseWordFromString(n,!0,!1);return J(e,s)}if(t.includes("$")){let r=new se().parseWordFromString(t,!1,!1);return J(e,r)}return t}async function jl(e,t){let n="both",r="",s=0;for(let i of t){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){e.state.functions.delete(i);continue}if(n==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let p=c[1],d=c[2];if(d==="@"||d==="*"){let w=te(e,p);for(let[E]of w)delete e.state.env[`${p}_${E}`];delete e.state.env[p];continue}let m=e.state.associativeArrays?.has(p);if(m){let w=await hy(e,d);delete e.state.env[`${p}_${w}`];continue}let h=Qt(e,p),g=e.state.declaredVars?.has(p);if((p in e.state.env||g)&&!h&&!m){r+=`bash: unset: ${p}: not an array variable
1318
1318
  `,s=1;continue}let y=await py(e,d);if(y===null&&h){r+=`bash: unset: ${d}: not a valid identifier
1319
1319
  `,s=1;continue}if(y===null)continue;if(y<0){let w=te(e,p),E=w.length,C=e.state.currentLine;if(E===0){r+=`bash: line ${C}: unset: [${y}]: bad array subscript
1320
1320
  `,s=1;continue}let A=E+y;if(A<0){r+=`bash: line ${C}: unset: [${y}]: bad array subscript
@@ -1403,7 +1403,7 @@ sys 0.00
1403
1403
  real ${`${d}m${m.toFixed(3)}s`}
1404
1404
  user 0m0.000s
1405
1405
  sys 0m0.000s
1406
- `,i={...i,stderr:i.stderr+h}}return l&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=c),i}Je();Fe();it();de();ot();$t();Tt();sn();async function Ly(e,t){let n={},r="";for(let s of t.assignments){let i=s.name;if(s.array){let u=await Ck(e,t,i,s.array,s.append,n);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:u.error};if(r+=u.xtraceOutput,u.continueToNext)continue}let o=s.value?await J(e,s.value):"";if(i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:W("",`bash: ${i}: bad array subscript
1406
+ `,i={...i,stderr:i.stderr+h}}return l&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=c),i}Je();Fe();it();de();ot();$t();Tt();on();async function Ly(e,t){let n={},r="";for(let s of t.assignments){let i=s.name;if(s.array){let u=await Ck(e,t,i,s.array,s.append,n);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:u.error};if(r+=u.xtraceOutput,u.continueToNext)continue}let o=s.value?await J(e,s.value):"";if(i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:W("",`bash: ${i}: bad array subscript
1407
1407
  `,1)};let l=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(l){let u=await Ik(e,t,l[1],l[2],o,s.append,n);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:u.error};if(u.continueToNext)continue}let c=await Pk(e,t,i,o,s.append,n);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:n}}async function Ck(e,t,n,r,s,i){let o="";if(/\[.+\]$/.test(n))return{continueToNext:!1,xtraceOutput:"",error:W("",`bash: ${n}: cannot assign list to array member
1408
1408
  `,1)};if(Se(e,n)){let u=kn(e,n);if(u===void 0||u==="")throw new ae(1,"","");let f=st(e,n);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:W("",`bash: ${n}: cannot assign list to array member
1409
1409
  `,1)}}if(Ht(e,n)){if(t.name)return o+=`bash: ${n}: readonly variable
@@ -1431,8 +1431,8 @@ sys 0m0.000s
1431
1431
  `)}if(E.operator==="<&"&&E.target.type==="Word"){let C=await J(this.ctx,E.target),A=Number.parseInt(C,10);if(!Number.isNaN(A)&&this.ctx.state.fileDescriptors){let I=this.ctx.state.fileDescriptors.get(A);if(I!==void 0)if(I.startsWith("__rw__:")){let O=Py(I);O&&(n=O.content.slice(O.position),c=A)}else I.startsWith("__file__:")||I.startsWith("__file_append__:")||(n=I)}}}let u=await J(this.ctx,t.name),f=[],p=[];if(ql(t.name,["local","declare","typeset","export","readonly"])&&(u==="local"||u==="declare"||u==="typeset"||u==="export"||u==="readonly"))for(let E of t.args){let C=await R0(this.ctx,E);if(C)f.push(C),p.push(!0);else{let A=await P0(this.ctx,E);if(A!==null)f.push(A),p.push(!0);else{let I=await Ft(this.ctx,E);for(let O of I.values)f.push(O),p.push(I.quoted)}}}else for(let E of t.args){let C=await Ft(this.ctx,E);for(let A of C.values)f.push(A),p.push(C.quoted)}if(!u){if(t.name.parts.every(C=>C.type==="CommandSubstitution"||C.type==="ParameterExpansion"||C.type==="ArithmeticExpansion")){if(f.length>0){let C=f.shift();return p.shift(),await this.runCommand(C,f,p,n,!1,!1,c)}return W("","",this.ctx.state.lastExitCode)}return M(`bash: : command not found
1432
1432
  `,127)}if(u==="exec"&&(f.length===0||f[0]==="--")){for(let E of t.redirections){if(E.target.type==="HereDoc"||E.fdVariable)continue;let C=await J(this.ctx,E.target),A=E.fd??(E.operator==="<"||E.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),E.operator){case">":case">|":{let I=this.ctx.fs.resolvePath(this.ctx.state.cwd,C);await this.ctx.fs.writeFile(I,"","utf8"),this.ctx.state.fileDescriptors.set(A,`__file__:${I}`);break}case">>":{let I=this.ctx.fs.resolvePath(this.ctx.state.cwd,C);this.ctx.state.fileDescriptors.set(A,`__file_append__:${I}`);break}case"<":{let I=this.ctx.fs.resolvePath(this.ctx.state.cwd,C);try{let O=await this.ctx.fs.readFile(I);this.ctx.state.fileDescriptors.set(A,O)}catch{return M(`bash: ${C}: No such file or directory
1433
1433
  `)}break}case"<>":{let I=this.ctx.fs.resolvePath(this.ctx.state.cwd,C);try{let O=await this.ctx.fs.readFile(I);this.ctx.state.fileDescriptors.set(A,`__rw__:${I.length}:${I}:0:${O}`)}catch{await this.ctx.fs.writeFile(I,"","utf8"),this.ctx.state.fileDescriptors.set(A,`__rw__:${I.length}:${I}:0:`)}break}case">&":{if(C==="-")this.ctx.state.fileDescriptors.delete(A);else if(C.endsWith("-")){let I=C.slice(0,-1),O=Number.parseInt(I,10);if(!Number.isNaN(O)){let L=this.ctx.state.fileDescriptors.get(O);L!==void 0?this.ctx.state.fileDescriptors.set(A,L):this.ctx.state.fileDescriptors.set(A,`__dupout__:${O}`),this.ctx.state.fileDescriptors.delete(O)}}else{let I=Number.parseInt(C,10);Number.isNaN(I)||this.ctx.state.fileDescriptors.set(A,`__dupout__:${I}`)}break}case"<&":{if(C==="-")this.ctx.state.fileDescriptors.delete(A);else if(C.endsWith("-")){let I=C.slice(0,-1),O=Number.parseInt(I,10);if(!Number.isNaN(O)){let L=this.ctx.state.fileDescriptors.get(O);L!==void 0?this.ctx.state.fileDescriptors.set(A,L):this.ctx.state.fileDescriptors.set(A,`__dupin__:${O}`),this.ctx.state.fileDescriptors.delete(O)}}else{let I=Number.parseInt(C,10);Number.isNaN(I)||this.ctx.state.fileDescriptors.set(A,`__dupin__:${I}`)}break}}}for(let[E,C]of Object.entries(s))C===void 0?delete this.ctx.state.env[E]:this.ctx.state.env[E]=C;if(this.ctx.state.tempExportedVars)for(let E of Object.keys(s))this.ctx.state.tempExportedVars.delete(E);return le}let m=await Dy(this.ctx,u,f);Object.keys(s).length>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(Object.entries(s))));let h,g=null;try{h=await this.runCommand(u,f,p,n,!1,!1,c)}catch(E){if(E instanceof Qe||E instanceof Ke)g=E,h=le;else throw E}let b=i+m;if(b&&(h={...h,stderr:b+h.stderr}),h=await $e(this.ctx,h,t.redirections),g)throw g;if(f.length>0){let E=f[f.length-1];if((u==="declare"||u==="local"||u==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(E)){let C=E.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);C&&(E=C[1])}this.ctx.state.lastArg=E}else this.ctx.state.lastArg=u;let y=V0(u)&&u!=="unset"&&u!=="eval";if(!this.ctx.state.options.posix||!y)for(let[E,C]of Object.entries(s))this.ctx.state.fullyUnsetLocals?.has(E)||(C===void 0?delete this.ctx.state.env[E]:this.ctx.state.env[E]=C);if(this.ctx.state.tempExportedVars)for(let E of Object.keys(s))this.ctx.state.tempExportedVars.delete(E);return Object.keys(s).length>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(h={...h,stderr:this.ctx.state.expansionStderr+h.stderr},this.ctx.state.expansionStderr=""),h}async runCommand(t,n,r,s,i=!1,o=!1,a=-1){let l={ctx:this.ctx,runCommand:(u,f,p,d,m,h,g)=>this.runCommand(u,f,p,d,m,h,g),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(u,f,p)=>this.executeUserScript(u,f,p)},c=await Ay(l,t,n,r,s,i,o,a);return c!==null?c:Cy(l,t,n,s,o)}aliasExpansionStack=new Set;expandAlias(t){return Oa(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return Fi(this.ctx,t)}async executeSubshell(t,n=""){return Wy(this.ctx,t,n,r=>this.executeStatement(r))}async executeGroup(t,n=""){return By(this.ctx,t,n,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await qt(this.ctx,t.redirections);if(n)return n;try{let r=await Q(this.ctx,t.expression.expression),s=Le(r!==0);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),$e(this.ctx,s,t.redirections)}catch(r){let s=M(`bash: arithmetic expression: ${r.message}
1434
- `);return $e(this.ctx,s,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await qt(this.ctx,t.redirections);if(n)return n;try{let r=await an(this.ctx,t.expression),s=Le(r);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),$e(this.ctx,s,t.redirections)}catch(r){let s=r instanceof Ee?1:2,i=M(`bash: conditional expression: ${r.message}
1435
- `,s);return $e(this.ctx,i,t.redirections)}}};var cn={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3};function zy(e){return e?{maxCallDepth:e.maxCallDepth??cn.maxCallDepth,maxCommandCount:e.maxCommandCount??cn.maxCommandCount,maxLoopIterations:e.maxLoopIterations??cn.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??cn.maxAwkIterations,maxSedIterations:e.maxSedIterations??cn.maxSedIterations,maxJqIterations:e.maxJqIterations??cn.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??cn.maxSqliteTimeoutMs}:{...cn}}function jy(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Ok(e){let t=jy(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Dk(e,t){let n=jy(e);if(!n)return!1;let r=Ok(t);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function Gl(e,t){return!t||t.length===0?!1:t.some(n=>Dk(e,n))}var ur=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},fr=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},pr=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Li=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}};var Fk=20,_k=3e4,Lk=["GET","HEAD"],Mk=new Set(["GET","HEAD","OPTIONS"]),Wk=new Set([301,302,303,307,308]);function Zl(e){let t=e.maxRedirects??Fk,n=e.timeoutMs??_k,r=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??Lk;function s(a){if(!e.dangerouslyAllowFullInternetAccess&&!Gl(a,e.allowedUrlPrefixes??[]))throw new ur(a)}function i(a){if(e.dangerouslyAllowFullInternetAccess)return;let l=a.toUpperCase();if(!r.includes(l))throw new Li(l,r)}async function o(a,l={}){let c=l.method?.toUpperCase()??"GET";s(a),i(c);let u=a,f=0,p=l.followRedirects??!0,d=l.timeoutMs!==void 0?Math.min(l.timeoutMs,n):n;for(;;){let m=new AbortController,h=setTimeout(()=>m.abort(),d);try{let g={method:c,headers:l.headers,signal:m.signal,redirect:"manual"};l.body&&!Mk.has(c)&&(g.body=l.body);let b=await fetch(u,g);if(Wk.has(b.status)&&p){let y=b.headers.get("location");if(!y)return await Hy(b,u);let w=new URL(y,u).href;if(!e.dangerouslyAllowFullInternetAccess&&!Gl(w,e.allowedUrlPrefixes??[]))throw new pr(w);if(f++,f>t)throw new fr(t);u=w;continue}return await Hy(b,u)}finally{clearTimeout(h)}}}return o}async function Hy(e,t){let n={};return e.headers.forEach((r,s)=>{n[s.toLowerCase()]=r}),{status:e.status,statusText:e.statusText,headers:n,body:await e.text(),url:t}}en();Fe();var Ql=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;state;constructor(t={}){let n=t.fs??new En(t.files);this.fs=n,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),s={HOME:this.useDefaultLayout?"/home/user":"/",PATH:"/usr/bin:/bin",IFS:`
1434
+ `);return $e(this.ctx,s,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await qt(this.ctx,t.redirections);if(n)return n;try{let r=await ln(this.ctx,t.expression),s=Le(r);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),$e(this.ctx,s,t.redirections)}catch(r){let s=r instanceof Ee?1:2,i=M(`bash: conditional expression: ${r.message}
1435
+ `,s);return $e(this.ctx,i,t.redirections)}}};var Jt={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:3e4};function zy(e){return e?{maxCallDepth:e.maxCallDepth??Jt.maxCallDepth,maxCommandCount:e.maxCommandCount??Jt.maxCommandCount,maxLoopIterations:e.maxLoopIterations??Jt.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??Jt.maxAwkIterations,maxSedIterations:e.maxSedIterations??Jt.maxSedIterations,maxJqIterations:e.maxJqIterations??Jt.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??Jt.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??Jt.maxPythonTimeoutMs}:{...Jt}}function jy(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Ok(e){let t=jy(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Dk(e,t){let n=jy(e);if(!n)return!1;let r=Ok(t);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function Gl(e,t){return!t||t.length===0?!1:t.some(n=>Dk(e,n))}var ur=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},fr=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},pr=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Li=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}};var Fk=20,_k=3e4,Lk=["GET","HEAD"],Mk=new Set(["GET","HEAD","OPTIONS"]),Wk=new Set([301,302,303,307,308]);function Zl(e){let t=e.maxRedirects??Fk,n=e.timeoutMs??_k,r=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??Lk;function s(a){if(!e.dangerouslyAllowFullInternetAccess&&!Gl(a,e.allowedUrlPrefixes??[]))throw new ur(a)}function i(a){if(e.dangerouslyAllowFullInternetAccess)return;let l=a.toUpperCase();if(!r.includes(l))throw new Li(l,r)}async function o(a,l={}){let c=l.method?.toUpperCase()??"GET";s(a),i(c);let u=a,f=0,p=l.followRedirects??!0,d=l.timeoutMs!==void 0?Math.min(l.timeoutMs,n):n;for(;;){let m=new AbortController,h=setTimeout(()=>m.abort(),d);try{let g={method:c,headers:l.headers,signal:m.signal,redirect:"manual"};l.body&&!Mk.has(c)&&(g.body=l.body);let b=await fetch(u,g);if(Wk.has(b.status)&&p){let y=b.headers.get("location");if(!y)return await Hy(b,u);let w=new URL(y,u).href;if(!e.dangerouslyAllowFullInternetAccess&&!Gl(w,e.allowedUrlPrefixes??[]))throw new pr(w);if(f++,f>t)throw new fr(t);u=w;continue}return await Hy(b,u)}finally{clearTimeout(h)}}}return o}async function Hy(e,t){let n={};return e.headers.forEach((r,s)=>{n[s.toLowerCase()]=r}),{status:e.status,statusText:e.statusText,headers:n,body:await e.text(),url:t}}tn();Fe();var Ql=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;state;constructor(t={}){let n=t.fs??new En(t.files);this.fs=n,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),s={HOME:this.useDefaultLayout?"/home/user":"/",PATH:"/usr/bin:/bin",IFS:`
1436
1436
  `,OSTYPE:"linux-gnu",MACHTYPE:"x86_64-pc-linux-gnu",HOSTTYPE:"x86_64",HOSTNAME:"localhost",PWD:r,OLDPWD:r,OPTIND:"1",...t.env};if(this.limits=zy({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=Zl(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,bashPid:process.pid,nextVirtualPid:process.pid+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(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.SHELLOPTS=ua(this.state.options),this.state.env.BASHOPTS=fa(this.state.shoptOptions),om(n,this.useDefaultLayout),r!=="/"&&n instanceof En)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let i of Jh(t.commands))this.registerCommand(i);if(t.network)for(let i of Yh())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)em(i)?this.registerCommand(tm(i)):this.registerCommand(i)}registerCommand(t){this.commands.set(t.name,t);let n=this.fs;if(typeof n.writeFileSync=="function"){let r=`#!/bin/bash
1437
1437
  # Built-in command: ${t.name}
1438
1438
  `;try{n.writeFileSync(`/bin/${t.name}`,r)}catch{}try{n.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t}async exec(t,n){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.