@keystrokehq/cli 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dist-BCJ2M6AP.mjs → dist-CLPEmwi4.mjs} +8 -2
- package/dist/{dist-BCJ2M6AP.mjs.map → dist-CLPEmwi4.mjs.map} +1 -1
- package/dist/{dist-CkZVZjrB.mjs → dist-DtU9BFPv.mjs} +2 -2
- package/dist/{dist-CkZVZjrB.mjs.map → dist-DtU9BFPv.mjs.map} +1 -1
- package/dist/dist-oR75r9SP.mjs +3 -0
- package/dist/{dist-D3CcImHe.mjs → dist-zZv_cvqN.mjs} +3 -3
- package/dist/{dist-D3CcImHe.mjs.map → dist-zZv_cvqN.mjs.map} +1 -1
- package/dist/index.mjs +9 -14
- package/dist/index.mjs.map +1 -1
- package/dist/{maybe-auto-update-Cir__-VX.mjs → maybe-auto-update-BMl6P8Nl.mjs} +2 -2
- package/dist/{maybe-auto-update-Cir__-VX.mjs.map → maybe-auto-update-BMl6P8Nl.mjs.map} +1 -1
- package/dist/{version-BCmCJixt.mjs → version-DjIL45j1.mjs} +2 -2
- package/dist/{version-BCmCJixt.mjs.map → version-DjIL45j1.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/dist-CB-gBQLB.mjs +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dist-CkZVZjrB.mjs","names":["Qt","z.enum","z.object","z.string","z.array","z.union","z.literal","SKIP_DIRS","Guard.IsObject","Guard.HasPropertyKey","Guard.IsArray","Settings.Get","Settings.Get","Guard.IsObject","Memory.Update","Guard.HasPropertyKey","Memory.Create","Guard.Keys","Memory.Create","Number","Memory.Create","String","Memory.Create","AllowedDigits","Type.Object","Type.String","Type.Array","Type.Optional","Type.Number","z.toJSONSchema","z.custom","z.ZodType","z.string","z.union","z.function","z.object","z.literal","z.array","z.discriminatedUnion"],"sources":["../../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/chunks/chunk-G5EVRAOO.js","../../../packages/manifest/dist/discovery-CWjr_liZ.mjs","../../../packages/sandbox/dist/files-BOUCjfCQ.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/metrics.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/guard/guard.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/clone.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/settings/settings.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/create.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/update.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/schema.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/_optional.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/array.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/properties.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/object.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/hashing/hash.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/integer.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/number.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/string.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/record.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/internal/char.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/unsigned_integer.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/ident.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/unsigned_number.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/engine/indexed/from_object.mjs","../../../packages/sandbox/dist/create-coding-tools-d9-WzxBW.mjs","../../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/index.js","../../../packages/manifest/dist/index.mjs"],"sourcesContent":["import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);\nimport{a as O}from\"./chunk-4RUAZWKT.js\";import{e as j,f as K,g as C,h as re,i as Pe,j as It,k as L}from\"./chunk-SAI2SPQQ.js\";function $(e,t){for(;t<e.length;){if(e[t]===\"\\\\\"&&e[t+1]===`\n`){t+=2;continue}if(/\\s/.test(e[t])){t++;continue}break}return t}var Re=[\"=\",\"+=\",\"-=\",\"*=\",\"/=\",\"%=\",\"<<=\",\">>=\",\"&=\",\"|=\",\"^=\"];function ge(e){if(e.includes(\"#\")){let[r,s]=e.split(\"#\"),n=Number.parseInt(r,10);if(n<2||n>64)return Number.NaN;if(n<=36){let i=Number.parseInt(s,n);return i>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:i}let a=0;for(let i of s){let l;if(/[0-9]/.test(i))l=i.charCodeAt(0)-48;else if(/[a-z]/.test(i))l=i.charCodeAt(0)-97+10;else if(/[A-Z]/.test(i))l=i.charCodeAt(0)-65+36;else if(i===\"@\")l=62;else if(i===\"_\")l=63;else return Number.NaN;if(l>=n)return Number.NaN;if(a=a*n+l,a>Number.MAX_SAFE_INTEGER)return Number.MAX_SAFE_INTEGER}return a}if(e.startsWith(\"0x\")||e.startsWith(\"0X\")){let r=Number.parseInt(e.slice(2),16);return r>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:r}if(e.startsWith(\"0\")&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return Number.NaN;let r=Number.parseInt(e,8);return r>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:r}let t=Number.parseInt(e,10);return t>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:t}function vt(e,t,r,s){if(r.slice(s,s+3)!==\"$((\")return null;let n=s+3,a=1,i=n;for(;n<r.length-1&&a>0;)r[n]===\"(\"&&r[n+1]===\"(\"?(a++,n+=2):r[n]===\")\"&&r[n+1]===\")\"?(a--,a>0&&(n+=2)):n++;let l=r.slice(i,n),{expr:o}=e(t,l,0);return n+=2,{expr:{type:\"ArithNested\",expression:o},pos:n}}function Dt(e,t){if(e.slice(t,t+2)!==\"$'\")return null;let r=t+2,s=\"\";for(;r<e.length&&e[r]!==\"'\";)if(e[r]===\"\\\\\"&&r+1<e.length){let a=e[r+1];switch(a){case\"n\":s+=`\n`;break;case\"t\":s+=\"\t\";break;case\"r\":s+=\"\\r\";break;case\"\\\\\":s+=\"\\\\\";break;case\"'\":s+=\"'\";break;default:s+=a}r+=2}else s+=e[r],r++;e[r]===\"'\"&&r++;let n=Number.parseInt(s,10);return{expr:{type:\"ArithNumber\",value:Number.isNaN(n)?0:n},pos:r}}function xt(e,t){if(e.slice(t,t+2)!=='$\"')return null;let r=t+2,s=\"\";for(;r<e.length&&e[r]!=='\"';)e[r]===\"\\\\\"&&r+1<e.length?(s+=e[r+1],r+=2):(s+=e[r],r++);e[r]==='\"'&&r++;let n=Number.parseInt(s,10);return{expr:{type:\"ArithNumber\",value:Number.isNaN(n)?0:n},pos:r}}function kr(e){let t=\"\",r=0;for(;r<e.length;)if(e[r]==='\"'){for(r++;r<e.length&&e[r]!=='\"';)e[r]===\"\\\\\"&&r+1<e.length?(t+=e[r+1],r+=2):(t+=e[r],r++);r<e.length&&r++}else t+=e[r],r++;return t}function M(e,t){let r=kr(t),{expr:s,pos:n}=Z(e,r,0),a=$(r,n);if(a<r.length){let i=t.slice(a).trim();if(i)return{type:\"ArithmeticExpression\",originalText:t,expression:{type:\"ArithSyntaxError\",errorToken:i,message:`${i}: syntax error: invalid arithmetic operator (error token is \"${i}\")`}}}return{type:\"ArithmeticExpression\",expression:s,originalText:t}}function F(e,t){return{expr:{type:\"ArithSyntaxError\",errorToken:e,message:`syntax error: operand expected (error token is \"${e}\")`},pos:t}}function z(e,t){return $(e,t)>=e.length}function Z(e,t,r){return Pr(e,t,r)}function Pr(e,t,r){let{expr:s,pos:n}=ye(e,t,r);for(n=$(t,n);t[n]===\",\";){if(n++,z(t,n))return F(\",\",n);let{expr:i,pos:l}=ye(e,t,n);s={type:\"ArithBinary\",operator:\",\",left:s,right:i},n=$(t,l)}return{expr:s,pos:n}}function ye(e,t,r){let{expr:s,pos:n}=Rr(e,t,r);if(n=$(t,n),t[n]===\"?\"){n++;let{expr:a,pos:i}=Z(e,t,n);if(n=$(t,i),t[n]===\":\"){n++;let{expr:l,pos:o}=Z(e,t,n);return{expr:{type:\"ArithTernary\",condition:s,consequent:a,alternate:l},pos:o}}}return{expr:s,pos:n}}function Rr(e,t,r){let{expr:s,pos:n}=_t(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"||\";){if(n+=2,z(t,n))return F(\"||\",n);let{expr:i,pos:l}=_t(e,t,n);s={type:\"ArithBinary\",operator:\"||\",left:s,right:i},n=l}return{expr:s,pos:n}}function _t(e,t,r){let{expr:s,pos:n}=$t(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"&&\";){if(n+=2,z(t,n))return F(\"&&\",n);let{expr:i,pos:l}=$t(e,t,n);s={type:\"ArithBinary\",operator:\"&&\",left:s,right:i},n=l}return{expr:s,pos:n}}function $t(e,t,r){let{expr:s,pos:n}=Ct(e,t,r);for(;n=$(t,n),t[n]===\"|\"&&t[n+1]!==\"|\";){if(n++,z(t,n))return F(\"|\",n);let{expr:i,pos:l}=Ct(e,t,n);s={type:\"ArithBinary\",operator:\"|\",left:s,right:i},n=l}return{expr:s,pos:n}}function Ct(e,t,r){let{expr:s,pos:n}=Ot(e,t,r);for(;n=$(t,n),t[n]===\"^\";){if(n++,z(t,n))return F(\"^\",n);let{expr:i,pos:l}=Ot(e,t,n);s={type:\"ArithBinary\",operator:\"^\",left:s,right:i},n=l}return{expr:s,pos:n}}function Ot(e,t,r){let{expr:s,pos:n}=Lt(e,t,r);for(;n=$(t,n),t[n]===\"&\"&&t[n+1]!==\"&\";){if(n++,z(t,n))return F(\"&\",n);let{expr:i,pos:l}=Lt(e,t,n);s={type:\"ArithBinary\",operator:\"&\",left:s,right:i},n=l}return{expr:s,pos:n}}function Lt(e,t,r){let{expr:s,pos:n}=Wt(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"==\"||t.slice(n,n+2)===\"!=\";){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=Wt(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Wt(e,t,r){let{expr:s,pos:n}=ze(e,t,r);for(;;)if(n=$(t,n),t.slice(n,n+2)===\"<=\"||t.slice(n,n+2)===\">=\"){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=ze(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}else if(t[n]===\"<\"||t[n]===\">\"){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=ze(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}else break;return{expr:s,pos:n}}function ze(e,t,r){let{expr:s,pos:n}=Tt(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"<<\"||t.slice(n,n+2)===\">>\";){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=Tt(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Tt(e,t,r){let{expr:s,pos:n}=Mt(e,t,r);for(;n=$(t,n),(t[n]===\"+\"||t[n]===\"-\")&&t[n+1]!==t[n];){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=Mt(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Mt(e,t,r){let{expr:s,pos:n}=Ie(e,t,r);for(;;)if(n=$(t,n),t[n]===\"*\"&&t[n+1]!==\"*\"){if(n++,z(t,n))return F(\"*\",n);let{expr:i,pos:l}=Ie(e,t,n);s={type:\"ArithBinary\",operator:\"*\",left:s,right:i},n=l}else if(t[n]===\"/\"||t[n]===\"%\"){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=Ie(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}else break;return{expr:s,pos:n}}function Ie(e,t,r){let{expr:s,pos:n}=Ge(e,t,r),a=$(t,n);if(t.slice(a,a+2)===\"**\"){if(a+=2,z(t,a))return F(\"**\",a);let{expr:l,pos:o}=Ie(e,t,a);return{expr:{type:\"ArithBinary\",operator:\"**\",left:s,right:l},pos:o}}return{expr:s,pos:n}}function Ge(e,t,r){let s=$(t,r);if(t.slice(s,s+2)===\"++\"||t.slice(s,s+2)===\"--\"){let n=t.slice(s,s+2);s+=2;let{expr:a,pos:i}=Ge(e,t,s);return{expr:{type:\"ArithUnary\",operator:n,operand:a,prefix:!0},pos:i}}if(t[s]===\"+\"||t[s]===\"-\"||t[s]===\"!\"||t[s]===\"~\"){let n=t[s];s++;let{expr:a,pos:i}=Ge(e,t,s);return{expr:{type:\"ArithUnary\",operator:n,operand:a,prefix:!0},pos:i}}return vr(e,t,s)}function Ir(e,t){let r=e[t];return r===\"$\"||r===\"`\"}function vr(e,t,r){let{expr:s,pos:n}=Vt(e,t,r,!1),a=[s];for(;Ir(t,n);){let{expr:l,pos:o}=Vt(e,t,n,!0);a.push(l),n=o}a.length>1&&(s={type:\"ArithConcat\",parts:a});let i;if(t[n]===\"[\"&&s.type===\"ArithConcat\"){n++;let{expr:l,pos:o}=Z(e,t,n);i=l,n=o,t[n]===\"]\"&&n++}if(i&&s.type===\"ArithConcat\"&&(s={type:\"ArithDynamicElement\",nameExpr:s,subscript:i},i=void 0),n=$(t,n),s.type===\"ArithConcat\"||s.type===\"ArithVariable\"||s.type===\"ArithDynamicElement\"){for(let l of Re)if(t.slice(n,n+l.length)===l&&t.slice(n,n+l.length+1)!==\"==\"){n+=l.length;let{expr:o,pos:c}=ye(e,t,n);return s.type===\"ArithDynamicElement\"?{expr:{type:\"ArithDynamicAssignment\",operator:l,target:s.nameExpr,subscript:s.subscript,value:o},pos:c}:s.type===\"ArithConcat\"?{expr:{type:\"ArithDynamicAssignment\",operator:l,target:s,value:o},pos:c}:{expr:{type:\"ArithAssignment\",operator:l,variable:s.name,value:o},pos:c}}}if(t.slice(n,n+2)===\"++\"||t.slice(n,n+2)===\"--\"){let l=t.slice(n,n+2);return n+=2,{expr:{type:\"ArithUnary\",operator:l,operand:s,prefix:!1},pos:n}}return{expr:s,pos:n}}function Vt(e,t,r,s=!1){let n=$(t,r),a=vt(Z,e,t,n);if(a)return a;let i=Dt(t,n);if(i)return i;let l=xt(t,n);if(l)return l;if(t.slice(n,n+2)===\"$(\"&&t[n+2]!==\"(\"){n+=2;let c=1,u=n;for(;n<t.length&&c>0;)t[n]===\"(\"?c++:t[n]===\")\"&&c--,c>0&&n++;let f=t.slice(u,n);return n++,{expr:{type:\"ArithCommandSubst\",command:f},pos:n}}if(t[n]===\"`\"){n++;let c=n;for(;n<t.length&&t[n]!==\"`\";)n++;let u=t.slice(c,n);return t[n]===\"`\"&&n++,{expr:{type:\"ArithCommandSubst\",command:u},pos:n}}if(t[n]===\"(\"){n++;let{expr:c,pos:u}=Z(e,t,n);return n=$(t,u),t[n]===\")\"&&n++,{expr:{type:\"ArithGroup\",expression:c},pos:n}}if(t[n]===\"'\"){n++;let c=\"\";for(;n<t.length&&t[n]!==\"'\";)c+=t[n],n++;t[n]===\"'\"&&n++;let u=Number.parseInt(c,10);return{expr:{type:\"ArithSingleQuote\",content:c,value:Number.isNaN(u)?0:u},pos:n}}if(t[n]==='\"'){n++;let c=\"\";for(;n<t.length&&t[n]!=='\"';)t[n]===\"\\\\\"&&n+1<t.length?(c+=t[n+1],n+=2):(c+=t[n],n++);t[n]==='\"'&&n++;let u=c.trim();if(!u)return{expr:{type:\"ArithNumber\",value:0},pos:n};let{expr:f}=Z(e,u,0);return{expr:f,pos:n}}if(/[0-9]/.test(t[n])){let c=\"\",u=!1,f=!1;for(;n<t.length;){let d=t[n];if(u)if(/[0-9a-zA-Z@_]/.test(d))c+=d,n++;else break;else if(d===\"#\")u=!0,c+=d,n++;else if(c===\"0\"&&(d===\"x\"||d===\"X\")&&n+1<t.length&&/[0-9a-fA-F]/.test(t[n+1]))f=!0,c+=d,n++;else if(f&&/[0-9a-fA-F]/.test(d))c+=d,n++;else if(!f&&/[0-9]/.test(d))c+=d,n++;else break}if(n<t.length&&/[a-zA-Z_]/.test(t[n])){let d=c;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)d+=t[n],n++;return{expr:{type:\"ArithSyntaxError\",errorToken:d,message:`${d}: value too great for base (error token is \"${d}\")`},pos:n}}if(t[n]===\".\"&&/[0-9]/.test(t[n+1]))throw new C(`${c}.${t[n+1]}...: syntax error: invalid arithmetic operator`);if(t[n]===\"[\"){let d=t.slice(n).trim();return{expr:{type:\"ArithNumberSubscript\",number:c,errorToken:d},pos:t.length}}return{expr:{type:\"ArithNumber\",value:ge(c)},pos:n}}if(t[n]===\"$\"&&t[n+1]===\"{\"){let c=n+2,u=1,f=c;for(;f<t.length&&u>0;)t[f]===\"{\"?u++:t[f]===\"}\"&&u--,u>0&&f++;let h=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 g=t.slice(d+1,m);return{expr:{type:\"ArithDynamicBase\",baseExpr:h,value:g},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 g=t.slice(d,m);return{expr:{type:\"ArithDynamicNumber\",prefix:h,suffix:g},pos:m}}return n=d,{expr:{type:\"ArithBracedExpansion\",content:h},pos:n}}if(t[n]===\"$\"&&n+1<t.length&&/[0-9]/.test(t[n+1])){n++;let c=\"\";for(;n<t.length&&/[0-9]/.test(t[n]);)c+=t[n],n++;return{expr:{type:\"ArithVariable\",name:c,hasDollarPrefix:!0},pos:n}}if(t[n]===\"$\"&&n+1<t.length&&/[*@#?\\-!$]/.test(t[n+1])){let c=t[n+1];return n+=2,{expr:{type:\"ArithSpecialVar\",name:c},pos:n}}let o=!1;if(t[n]===\"$\"&&n+1<t.length&&/[a-zA-Z_]/.test(t[n+1])&&(o=!0,n++),n<t.length&&/[a-zA-Z_]/.test(t[n])){let c=\"\";for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)c+=t[n],n++;if(t[n]===\"[\"&&!s){n++;let u;if(t[n]===\"'\"||t[n]==='\"'){let h=t[n];for(n++,u=\"\";n<t.length&&t[n]!==h;)u+=t[n],n++;t[n]===h&&n++,n=$(t,n),t[n]===\"]\"&&n++}let f;if(u===void 0){let{expr:h,pos:d}=Z(e,t,n);f=h,n=d,t[n]===\"]\"&&n++}if(n=$(t,n),t[n]===\"[\"&&f)return{expr:{type:\"ArithDoubleSubscript\",array:c,index:f},pos:n};if(!s){for(let h of Re)if(t.slice(n,n+h.length)===h&&t.slice(n,n+h.length+1)!==\"==\"){n+=h.length;let{expr:d,pos:m}=ye(e,t,n);return{expr:{type:\"ArithAssignment\",operator:h,variable:c,subscript:f,stringKey:u,value:d},pos:m}}}return{expr:{type:\"ArithArrayElement\",array:c,index:f,stringKey:u},pos:n}}if(n=$(t,n),!s){for(let u of Re)if(t.slice(n,n+u.length)===u&&t.slice(n,n+u.length+1)!==\"==\"){n+=u.length;let{expr:f,pos:h}=ye(e,t,n);return{expr:{type:\"ArithAssignment\",operator:u,variable:c,value:f},pos:h}}}return{expr:{type:\"ArithVariable\",name:c,hasDollarPrefix:o},pos:n}}if(t[n]===\"#\"){let c=n+1;for(;c<t.length&&t[c]!==`\n`;)c++;let u=t.slice(n,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:n}}var w={script(e){return{type:\"Script\",statements:e}},statement(e,t=[],r=!1,s,n){let a={type:\"Statement\",pipelines:e,operators:t,background:r};return s&&(a.deferredError=s),n!==void 0&&(a.sourceText=n),a},pipeline(e,t=!1,r=!1,s=!1,n){return{type:\"Pipeline\",commands:e,negated:t,timed:r,timePosix:s,pipeStderr:n}},simpleCommand(e,t=[],r=[],s=[]){return{type:\"SimpleCommand\",name:e,args:t,assignments:r,redirections:s}},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,r=!1,s=null){return{type:\"Assignment\",name:e,value:t,append:r,array:s}},redirection(e,t,r=null,s){let n={type:\"Redirection\",fd:r,operator:e,target:t};return s&&(n.fdVariable=s),n},hereDoc(e,t,r=!1,s=!1){return{type:\"HereDoc\",delimiter:e,content:t,stripTabs:r,quoted:s}},ifNode(e,t=null,r=[]){return{type:\"If\",clauses:e,elseBody:t,redirections:r}},forNode(e,t,r,s=[]){return{type:\"For\",variable:e,words:t,body:r,redirections:s}},whileNode(e,t,r=[]){return{type:\"While\",condition:e,body:t,redirections:r}},untilNode(e,t,r=[]){return{type:\"Until\",condition:e,body:t,redirections:r}},caseNode(e,t,r=[]){return{type:\"Case\",word:e,items:t,redirections:r}},caseItem(e,t,r=\";;\"){return{type:\"CaseItem\",patterns:e,body:t,terminator:r}},subshell(e,t=[]){return{type:\"Subshell\",body:e,redirections:t}},group(e,t=[]){return{type:\"Group\",body:e,redirections:t}},functionDef(e,t,r=[],s){return{type:\"FunctionDef\",name:e,body:t,redirections:r,sourceFile:s}},conditionalCommand(e,t=[],r){return{type:\"ConditionalCommand\",expression:e,redirections:t,line:r}},arithmeticCommand(e,t=[],r){return{type:\"ArithmeticCommand\",expression:e,redirections:t,line:r}}};var p;(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\"})(p||(p={}));var pe=class extends Error{line;column;constructor(t,r,s){super(`line ${r}: ${t}`),this.line=r,this.column=s,this.name=\"LexerError\"}},Bt=new Map([[\"if\",p.IF],[\"then\",p.THEN],[\"else\",p.ELSE],[\"elif\",p.ELIF],[\"fi\",p.FI],[\"for\",p.FOR],[\"while\",p.WHILE],[\"until\",p.UNTIL],[\"do\",p.DO],[\"done\",p.DONE],[\"case\",p.CASE],[\"esac\",p.ESAC],[\"in\",p.IN],[\"function\",p.FUNCTION],[\"select\",p.SELECT],[\"time\",p.TIME],[\"coproc\",p.COPROC]]);function Ft(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let r=e.slice(t[0].length);if(r===\"\"||r===\"+\")return!0;if(r[0]===\"[\"){let s=0,n=0;for(;n<r.length;n++)if(r[n]===\"[\")s++;else if(r[n]===\"]\"&&(s--,s===0))break;if(s!==0||n>=r.length)return!1;let a=r.slice(n+1);return a===\"\"||a===\"+\"}return!1}function zt(e){let t=0;for(let r=0;r<e.length;r++){let s=e[r];if(s===\"[\")t++;else if(s===\"]\")t--;else{if(t===0&&s===\"=\")return r;if(t===0&&s===\"+\"&&e[r+1]===\"=\")return r+1}}return-1}var Dr=[[\";\",\";\",\"&\",p.SEMI_SEMI_AND],[\"<\",\"<\",\"<\",p.TLESS],[\"&\",\">\",\">\",p.AND_DGREAT]],xr=[[\"[\",\"[\",p.DBRACK_START],[\"]\",\"]\",p.DBRACK_END],[\"(\",\"(\",p.DPAREN_START],[\")\",\")\",p.DPAREN_END],[\"&\",\"&\",p.AND_AND],[\"|\",\"|\",p.OR_OR],[\";\",\";\",p.DSEMI],[\";\",\"&\",p.SEMI_AND],[\"|\",\"&\",p.PIPE_AMP],[\">\",\">\",p.DGREAT],[\"<\",\"&\",p.LESSAND],[\">\",\"&\",p.GREATAND],[\"<\",\">\",p.LESSGREAT],[\">\",\"|\",p.CLOBBER],[\"&\",\">\",p.AND_GREAT]],_r=new Map([[\"|\",p.PIPE],[\"&\",p.AMP],[\";\",p.SEMICOLON],[\"(\",p.LPAREN],[\")\",p.RPAREN],[\"<\",p.LESS],[\">\",p.GREAT]]);function $r(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Gt(e){return e===\" \"||e===\"\t\"||e===`\n`||e===\";\"||e===\"&\"||e===\"|\"||e===\"(\"||e===\")\"||e===\"<\"||e===\">\"}var ve=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];dparenDepth=0;maxHeredocSize;constructor(t,r){this.input=t,this.maxHeredocSize=r?.maxHeredocSize??10485760}tokenize(){let r=this.input.length,s=this.tokens,n=this.pendingHeredocs;for(;this.pos<r;){if(n.length>0&&s.length>0&&s[s.length-1].type===p.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=r)break;let a=this.nextToken();a&&s.push(a)}return s.push({type:p.EOF,value:\"\",start:this.pos,end:this.pos,line:this.line,column:this.column}),s}skipWhitespace(){let t=this.input,r=t.length,s=this.pos,n=this.column,a=this.line;for(;s<r;){let i=t[s];if(i===\" \"||i===\"\t\")s++,n++;else if(i===\"\\\\\"&&t[s+1]===`\n`)s+=2,a++,n=1;else break}this.pos=s,this.column=n,this.line=a}nextToken(){let t=this.input,r=this.pos,s=this.line,n=this.column,a=t[r],i=t[r+1],l=t[r+2];if(a===\"#\"&&this.dparenDepth===0)return this.readComment(r,s,n);if(a===`\n`)return this.pos=r+1,this.line++,this.column=1,{type:p.NEWLINE,value:`\n`,start:r,end:r+1,line:s,column:n};if(a===\"<\"&&i===\"<\"&&l===\"-\")return this.pos=r+3,this.column=n+3,this.registerHeredocFromLookahead(!0),this.makeToken(p.DLESSDASH,\"<<-\",r,s,n);for(let[c,u,f,h]of Dr)if(a===c&&i===u&&l===f)return this.pos=r+3,this.column=n+3,this.makeToken(h,c+u+f,r,s,n);if(a===\"<\"&&i===\"<\")return this.pos=r+2,this.column=n+2,this.registerHeredocFromLookahead(!1),this.makeToken(p.DLESS,\"<<\",r,s,n);if(a===\"(\"&&i===\"(\")return this.dparenDepth>0?(this.pos=r+1,this.column=n+1,this.dparenDepth++,this.makeToken(p.LPAREN,\"(\",r,s,n)):this.looksLikeNestedSubshells(r+2)||this.dparenClosesWithSpacedParens(r+2)?(this.pos=r+1,this.column=n+1,this.makeToken(p.LPAREN,\"(\",r,s,n)):(this.pos=r+2,this.column=n+2,this.dparenDepth=1,this.makeToken(p.DPAREN_START,\"((\",r,s,n));if(a===\")\"&&i===\")\")return this.dparenDepth===1?(this.pos=r+2,this.column=n+2,this.dparenDepth=0,this.makeToken(p.DPAREN_END,\"))\",r,s,n)):this.dparenDepth>1?(this.pos=r+1,this.column=n+1,this.dparenDepth--,this.makeToken(p.RPAREN,\")\",r,s,n)):(this.pos=r+1,this.column=n+1,this.makeToken(p.RPAREN,\")\",r,s,n));for(let[c,u,f]of xr)if(!(c===\"(\"&&u===\"(\"||c===\")\"&&u===\")\")&&!(this.dparenDepth>0&&c===\";\"&&(f===p.DSEMI||f===p.SEMI_AND||f===p.SEMI_SEMI_AND))&&a===c&&i===u){if(f===p.DBRACK_START||f===p.DBRACK_END){let h=t[r+2];if(h!==void 0&&h!==\" \"&&h!==\"\t\"&&h!==`\n`&&h!==\";\"&&h!==\"&\"&&h!==\"|\"&&h!==\"(\"&&h!==\")\"&&h!==\"<\"&&h!==\">\")break}return this.pos=r+2,this.column=n+2,this.makeToken(f,c+u,r,s,n)}if(a===\"(\"&&this.dparenDepth>0)return this.pos=r+1,this.column=n+1,this.dparenDepth++,this.makeToken(p.LPAREN,\"(\",r,s,n);if(a===\")\"&&this.dparenDepth>1)return this.pos=r+1,this.column=n+1,this.dparenDepth--,this.makeToken(p.RPAREN,\")\",r,s,n);let o=_r.get(a);if(o!==void 0)return this.pos=r+1,this.column=n+1,this.makeToken(o,a,r,s,n);if(a===\"{\"){let c=this.scanFdVariable(r);return c!==null?(this.pos=c.end,this.column=n+(c.end-r),{type:p.FD_VARIABLE,value:c.varname,start:r,end:c.end,line:s,column:n}):i===\"}\"?(this.pos=r+2,this.column=n+2,{type:p.WORD,value:\"{}\",start:r,end:r+2,line:s,column:n,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(r)!==null?this.readWordWithBraceExpansion(r,s,n):this.scanLiteralBraceWord(r)!==null?this.readWordWithBraceExpansion(r,s,n):i!==void 0&&i!==\" \"&&i!==\"\t\"&&i!==`\n`?this.readWord(r,s,n):(this.pos=r+1,this.column=n+1,this.makeToken(p.LBRACE,\"{\",r,s,n))}return a===\"}\"?this.isWordCharFollowing(r+1)?this.readWord(r,s,n):(this.pos=r+1,this.column=n+1,this.makeToken(p.RBRACE,\"}\",r,s,n)):a===\"!\"?i===\"=\"?(this.pos=r+2,this.column=n+2,this.makeToken(p.WORD,\"!=\",r,s,n)):(this.pos=r+1,this.column=n+1,this.makeToken(p.BANG,\"!\",r,s,n)):this.readWord(r,s,n)}looksLikeNestedSubshells(t){let r=this.input,s=r.length,n=t;for(;n<s&&(r[n]===\" \"||r[n]===\"\t\");)n++;if(n>=s)return!1;let a=r[n];if(a===\"(\")return this.looksLikeNestedSubshells(n+1);let i=/[a-zA-Z_]/.test(a),l=a===\"!\"||a===\"[\";if(!i&&!l)return!1;let o=n;for(;o<s&&/[a-zA-Z0-9_\\-.]/.test(r[o]);)o++;if(o===n)return l;let c=o;for(;c<s&&(r[c]===\" \"||r[c]===\"\t\");)c++;if(c>=s)return!1;let u=r[c];if(u===\"=\"&&r[c+1]!==\"=\"||u===`\n`||o===c&&/[+\\-*/%<>&|^!~?:]/.test(u)&&u!==\"-\"||u===\")\"&&r[c+1]===\")\")return!1;if(c>o&&(u===\"-\"||u==='\"'||u===\"'\"||u===\"$\"||/[a-zA-Z_/.]/.test(u))){let f=c;for(;f<s&&r[f]!==`\n`;){if(r[f]===\")\")return!0;f++}return!1}if(u===\")\"){let f=c+1;for(;f<s&&(r[f]===\" \"||r[f]===\"\t\");)f++;if(r[f]===\"|\"&&r[f+1]===\"|\"||r[f]===\"&\"&&r[f+1]===\"&\"||r[f]===\";\"||r[f]===\"|\"&&r[f+1]!==\"|\")return!0}return!1}makeToken(t,r,s,n,a){return{type:t,value:r,start:s,end:this.pos,line:n,column:a}}readComment(t,r,s){let n=this.input,a=n.length,i=this.pos;for(;i<a&&n[i]!==`\n`;)i++;let l=n.slice(t,i);return this.pos=i,this.column=s+(i-t),{type:p.COMMENT,value:l,start:t,end:i,line:r,column:s}}readWord(t,r,s){let n=this.input,a=n.length,i=this.pos,l=i;for(;i<a;){let y=n[i];if(y===\" \"||y===\"\t\"||y===`\n`||y===\";\"||y===\"&\"||y===\"|\"||y===\"(\"||y===\")\"||y===\"<\"||y===\">\"||y===\"'\"||y==='\"'||y===\"\\\\\"||y===\"$\"||y===\"`\"||y===\"{\"||y===\"}\"||y===\"~\"||y===\"*\"||y===\"?\"||y===\"[\")break;i++}if(i>l){let y=n[i];if(!(y===\"(\"&&i>l&&\"@*+?!\".includes(n[i-1]))){if(i>=a||y===\" \"||y===\"\t\"||y===`\n`||y===\";\"||y===\"&\"||y===\"|\"||y===\"(\"||y===\")\"||y===\"<\"||y===\">\"){let b=n.slice(l,i);this.pos=i,this.column=s+(i-l);let D=Bt.get(b);if(D!==void 0)return{type:D,value:b,start:t,end:i,line:r,column:s};let Q=zt(b);return Q>0&&Ft(b.slice(0,Q))?{type:p.ASSIGNMENT_WORD,value:b,start:t,end:i,line:r,column:s}:/^[0-9]+$/.test(b)?{type:p.NUMBER,value:b,start:t,end:i,line:r,column:s}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)?{type:p.NAME,value:b,start:t,end:i,line:r,column:s,quoted:!1,singleQuoted:!1}:{type:p.WORD,value:b,start:t,end:i,line:r,column:s,quoted:!1,singleQuoted:!1}}}}i=this.pos;let o=this.column,c=this.line,u=\"\",f=!1,h=!1,d=!1,m=!1,g=n[i]==='\"'||n[i]===\"'\",E=!1,A=0;for(;i<a;){let y=n[i];if(!d&&!m){if(y===\"(\"&&u.length>0&&\"@*+?!\".includes(u[u.length-1])){let b=this.scanExtglobPattern(i);if(b!==null){u+=b.content,i=b.end,o+=b.content.length;continue}}if(y===\"[\"&&A===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){let b=i+1<a?n[i+1]:\"\";if(b===\"^\"||b===\"!\"){u+=y,i++,o++;continue}A=1,u+=y,i++,o++;continue}}else if(y===\"[\"&&A>0){u.length>0&&u[u.length-1]!==\"\\\\\"&&A++,u+=y,i++,o++;continue}else if(y===\"]\"&&A>0){u.length>0&&u[u.length-1]!==\"\\\\\"&&A--,u+=y,i++,o++;continue}if(A>0){if(y===`\n`)break;u+=y,i++,o++;continue}if(y===\" \"||y===\"\t\"||y===`\n`||y===\";\"||y===\"&\"||y===\"|\"||y===\"(\"||y===\")\"||y===\"<\"||y===\">\")break}if(y===\"$\"&&i+1<a&&n[i+1]===\"'\"&&!d&&!m){for(u+=\"$'\",i+=2,o+=2;i<a&&n[i]!==\"'\";)n[i]===\"\\\\\"&&i+1<a?(u+=n[i]+n[i+1],i+=2,o+=2):(u+=n[i],i++,o++);i<a&&(u+=\"'\",i++,o++);continue}if(y===\"$\"&&i+1<a&&n[i+1]==='\"'&&!d&&!m){i++,o++,m=!0,f=!0,u===\"\"&&(g=!0),i++,o++;continue}if(y===\"'\"&&!m){if(d)if(d=!1,!g||E)u+=y;else{let b=i+1<a?n[i+1]:\"\";b&&!Gt(b)&&b!==\"'\"&&(b==='\"'?(E=!0,u+=y,h=!1,f=!1):(E=!0,u+=y))}else d=!0,g&&!E?(h=!0,f=!0):u+=y;i++,o++;continue}if(y==='\"'&&!d){if(m)if(m=!1,!g||E)u+=y;else{let b=i+1<a?n[i+1]:\"\";b&&!Gt(b)&&b!=='\"'&&(b===\"'\"?(E=!0,u+=y,h=!1,f=!1):(E=!0,u+=y))}else m=!0,g&&!E?f=!0:u+=y;i++,o++;continue}if(y===\"\\\\\"&&!d&&i+1<a){let b=n[i+1];if(b===`\n`){i+=2,c++,o=1;continue}if(m){if(b==='\"'||b===\"\\\\\"||b===\"$\"||b===\"`\"||b===`\n`){if(b===`\n`){i+=2,o=1,c++;continue}u+=y+b,i+=2,o+=2;continue}}else{b===\"\\\\\"||b==='\"'||b===\"'\"||b===\"`\"||b===\"*\"||b===\"?\"||b===\"[\"||b===\"]\"||b===\"(\"||b===\")\"||b===\"$\"||b===\"-\"||b===\".\"||b===\"^\"||b===\"+\"||b===\"{\"||b===\"}\"?u+=y+b:u+=b,i+=2,o+=2;continue}}if(y===\"$\"&&i+1<a&&n[i+1]===\"(\"&&!d){u+=y,i++,o++,u+=n[i],i++,o++;let b=1,D=!1,Q=!1,ie=0,H=!1,B=\"\",Ne=n[i]===\"(\"&&!this.dollarDparenIsSubshell(i);for(;b>0&&i<a;){let _=n[i];if(u+=_,D)_===\"'\"&&(D=!1);else if(Q)_===\"\\\\\"&&i+1<a?(u+=n[i+1],i++,o++):_==='\"'&&(Q=!1);else if(_===\"'\")D=!0,B=\"\";else if(_==='\"')Q=!0,B=\"\";else if(_===\"\\\\\"&&i+1<a)u+=n[i+1],i++,o++,B=\"\";else if(_===\"$\"&&i+1<a&&n[i+1]===\"{\"){i++,o++,u+=n[i],i++,o++;let Be=1,ke=!1,Fe=!1;for(;Be>0&&i<a;){let Y=n[i];if(Y===\"\\\\\"&&i+1<a&&!ke){u+=Y,i++,o++,u+=n[i],i++,o++;continue}u+=Y,ke?Y===\"'\"&&(ke=!1):Fe?Y==='\"'&&(Fe=!1):Y===\"'\"?ke=!0:Y==='\"'?Fe=!0:Y===\"{\"?Be++:Y===\"}\"&&Be--,Y===`\n`?(c++,o=0):o++,i++}B=\"\";continue}else if(_===\"#\"&&!Ne&&(B===\"\"||/\\s/.test(n[i-1]||\"\"))){for(;i+1<a&&n[i+1]!==`\n`;)i++,o++,u+=n[i];B=\"\"}else/[a-zA-Z_]/.test(_)?B+=_:(B===\"case\"?(ie++,H=!1):B===\"in\"&&ie>0?H=!0:B===\"esac\"&&ie>0&&(ie--,H=!1),B=\"\",_===\"(\"?i>0&&n[i-1]===\"$\"?b++:H||b++:_===\")\"?H?H=!1:b--:_===\";\"&&ie>0&&(i+1<a&&n[i+1]===\";\"||i+1<a&&n[i+1]===\"&\")&&(H=!0));_===`\n`&&(c++,o=0,B=\"\"),i++,o++}continue}if(y===\"$\"&&i+1<a&&n[i+1]===\"[\"&&!d){u+=y,i++,o++,u+=n[i],i++,o++;let b=1;for(;b>0&&i<a;){let D=n[i];u+=D,D===\"[\"?b++:D===\"]\"?b--:D===`\n`&&(c++,o=0),i++,o++}continue}if(y===\"$\"&&i+1<a&&n[i+1]===\"{\"&&!d){u+=y,i++,o++,u+=n[i],i++,o++;let b=1,D=!1,Q=!1,ie=c,H=o,B=c,Ne=o;for(;b>0&&i<a;){let _=n[i];if(_===\"\\\\\"&&i+1<a&&n[i+1]===`\n`){i+=2,c++,o=1;continue}if(_===\"\\\\\"&&i+1<a&&!D){u+=_,i++,o++,u+=n[i],i++,o++;continue}u+=_,D?_===\"'\"&&(D=!1):Q?_==='\"'&&(Q=!1):_===\"'\"?(D=!0,ie=c,H=o):_==='\"'?(Q=!0,B=c,Ne=o):_===\"{\"?b++:_===\"}\"&&b--,_===`\n`&&(c++,o=0),i++,o++}if(D)throw new pe(\"unexpected EOF while looking for matching `''\",ie,H);if(Q)throw new pe(\"unexpected EOF while looking for matching `\\\"'\",B,Ne);continue}if(y===\"$\"&&i+1<a&&!d){let b=n[i+1];if(b===\"#\"||b===\"?\"||b===\"$\"||b===\"!\"||b===\"@\"||b===\"*\"||b===\"-\"||b>=\"0\"&&b<=\"9\"){u+=y+b,i+=2,o+=2;continue}}if(y===\"`\"&&!d){for(u+=y,i++,o++;i<a&&n[i]!==\"`\";){let b=n[i];u+=b,b===\"\\\\\"&&i+1<a&&(u+=n[i+1],i++,o++),b===`\n`&&(c++,o=0),i++,o++}i<a&&(u+=n[i],i++,o++);continue}u+=y,i++,y===`\n`?(c++,o=1):o++}if(this.pos=i,this.column=o,this.line=c,E&&g&&(u=n[t]+u,f=!1,h=!1),d||m){let y=d?\"'\":'\"';throw new pe(`unexpected EOF while looking for matching \\`${y}'`,r,s)}if(!g&&u.length>=2){if(u[0]===\"'\"&&u[u.length-1]===\"'\"){let y=u.slice(1,-1);!y.includes(\"'\")&&!y.includes('\"')&&(u=y,f=!0,h=!0)}else if(u[0]==='\"'&&u[u.length-1]==='\"'){let y=u.slice(1,-1),b=!1;for(let D=0;D<y.length;D++){if(y[D]==='\"'){b=!0;break}y[D]===\"\\\\\"&&D+1<y.length&&D++}b||(u=y,f=!0,h=!1)}}if(u===\"\")return{type:p.WORD,value:\"\",start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h};let S=Bt.get(u);if(!f&&S!==void 0)return{type:S,value:u,start:t,end:i,line:r,column:s};if(!g){let y=zt(u);if(y>0&&Ft(u.slice(0,y)))return{type:p.ASSIGNMENT_WORD,value:u,start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h}}return/^[0-9]+$/.test(u)?{type:p.NUMBER,value:u,start:t,end:i,line:r,column:s}:$r(u)?{type:p.NAME,value:u,start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h}:{type:p.WORD,value:u,start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let t=this.pendingHeredocs.shift();if(!t)break;let r=this.pos,s=this.line,n=this.column,a=\"\";for(;this.pos<this.input.length;){let i=\"\";for(;this.pos<this.input.length&&this.input[this.pos]!==`\n`;)i+=this.input[this.pos],this.pos++,this.column++;if((t.stripTabs?i.replace(/^\\t+/,\"\"):i)===t.delimiter){this.pos<this.input.length&&this.input[this.pos]===`\n`&&(this.pos++,this.line++,this.column=1);break}if(a+=i,a.length>this.maxHeredocSize)throw new pe(`Heredoc size limit exceeded (${this.maxHeredocSize} bytes)`,s,n);this.pos<this.input.length&&this.input[this.pos]===`\n`&&(a+=`\n`,this.pos++,this.line++,this.column=1)}this.tokens.push({type:p.HEREDOC_CONTENT,value:a,start:r,end:this.pos,line:s,column:n})}}addPendingHeredoc(t,r,s){this.pendingHeredocs.push({delimiter:t,stripTabs:r,quoted:s})}registerHeredocFromLookahead(t){let r=this.pos,s=this.column;for(;this.pos<this.input.length&&(this.input[this.pos]===\" \"||this.input[this.pos]===\"\t\");)this.pos++,this.column++;let n=\"\",a=!1;for(;this.pos<this.input.length;){let i=this.input[this.pos];if(/[\\s;<>&|()]/.test(i))break;if(i===\"'\"||i==='\"'){a=!0;let l=i;for(this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]!==l;)n+=this.input[this.pos],this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]===l&&(this.pos++,this.column++)}else i===\"\\\\\"?(a=!0,this.pos++,this.column++,this.pos<this.input.length&&(n+=this.input[this.pos],this.pos++,this.column++)):(n+=i,this.pos++,this.column++)}this.pos=r,this.column=s,n&&this.pendingHeredocs.push({delimiter:n,stripTabs:t,quoted:a})}isWordCharFollowing(t){if(t>=this.input.length)return!1;let r=this.input[t];return!(r===\" \"||r===\"\t\"||r===`\n`||r===\";\"||r===\"&\"||r===\"|\"||r===\"(\"||r===\")\"||r===\"<\"||r===\">\")}readWordWithBraceExpansion(t,r,s){let n=this.input,a=n.length,i=t,l=s;for(;i<a;){let c=n[i];if(c===\" \"||c===\"\t\"||c===`\n`||c===\";\"||c===\"&\"||c===\"|\"||c===\"(\"||c===\")\"||c===\"<\"||c===\">\")break;if(c===\"{\"){if(this.scanBraceExpansion(i)!==null){let f=1;for(i++,l++;i<a&&f>0;)n[i]===\"{\"?f++:n[i]===\"}\"&&f--,i++,l++;continue}i++,l++;continue}if(c===\"}\"){i++,l++;continue}if(c===\"$\"&&i+1<a&&n[i+1]===\"(\"){i++,l++,i++,l++;let u=1;for(;u>0&&i<a;)n[i]===\"(\"?u++:n[i]===\")\"&&u--,i++,l++;continue}if(c===\"$\"&&i+1<a&&n[i+1]===\"{\"){i++,l++,i++,l++;let u=1;for(;u>0&&i<a;)n[i]===\"{\"?u++:n[i]===\"}\"&&u--,i++,l++;continue}if(c===\"`\"){for(i++,l++;i<a&&n[i]!==\"`\";)n[i]===\"\\\\\"&&i+1<a?(i+=2,l+=2):(i++,l++);i<a&&(i++,l++);continue}i++,l++}let o=n.slice(t,i);return this.pos=i,this.column=l,{type:p.WORD,value:o,start:t,end:i,line:r,column:s,quoted:!1,singleQuoted:!1}}scanBraceExpansion(t){let r=this.input,s=r.length,n=t+1,a=1,i=!1,l=!1;for(;n<s&&a>0;){let o=r[n];if(o===\"{\")a++,n++;else if(o===\"}\")a--,n++;else if(o===\",\"&&a===1)i=!0,n++;else if(o===\".\"&&n+1<s&&r[n+1]===\".\")l=!0,n+=2;else{if(o===\" \"||o===\"\t\"||o===`\n`||o===\";\"||o===\"&\"||o===\"|\")return null;n++}}return a===0&&(i||l)?r.slice(t,n):null}scanLiteralBraceWord(t){let r=this.input,s=r.length,n=t+1,a=1;for(;n<s&&a>0;){let i=r[n];if(i===\"{\")a++,n++;else if(i===\"}\"){if(a--,a===0)return r.slice(t,n+1);n++}else{if(i===\" \"||i===\"\t\"||i===`\n`||i===\";\"||i===\"&\"||i===\"|\")return null;n++}}return null}scanExtglobPattern(t){let r=this.input,s=r.length,n=t+1,a=1;for(;n<s&&a>0;){let i=r[n];if(i===\"\\\\\"&&n+1<s){n+=2;continue}if(\"@*+?!\".includes(i)&&n+1<s&&r[n+1]===\"(\"){n++,a++,n++;continue}if(i===\"(\")a++,n++;else if(i===\")\")a--,n++;else{if(i===`\n`)return null;n++}}return a===0?{content:r.slice(t,n),end:n}:null}scanFdVariable(t){let r=this.input,s=r.length,n=t+1,a=n;for(;n<s;){let u=r[n];if(n===a){if(!(u>=\"a\"&&u<=\"z\"||u>=\"A\"&&u<=\"Z\"||u===\"_\"))return null}else if(!(u>=\"a\"&&u<=\"z\"||u>=\"A\"&&u<=\"Z\"||u>=\"0\"&&u<=\"9\"||u===\"_\"))break;n++}if(n===a)return null;let i=r.slice(a,n);if(n>=s||r[n]!==\"}\"||(n++,n>=s))return null;let l=r[n],o=n+1<s?r[n+1]:\"\";return l===\">\"||l===\"<\"||l===\"&\"&&(o===\">\"||o===\"<\")?{varname:i,end:n}:null}dollarDparenIsSubshell(t){let r=this.input,s=r.length,n=t+1,a=2,i=!1,l=!1,o=!1;for(;n<s&&a>0;){let c=r[n];if(i){c===\"'\"&&(i=!1),c===`\n`&&(o=!0),n++;continue}if(l){if(c===\"\\\\\"){n+=2;continue}c==='\"'&&(l=!1),c===`\n`&&(o=!0),n++;continue}if(c===\"'\"){i=!0,n++;continue}if(c==='\"'){l=!0,n++;continue}if(c===\"\\\\\"){n+=2;continue}if(c===`\n`&&(o=!0),c===\"(\"){a++,n++;continue}if(c===\")\"){if(a--,a===1){let u=n+1;if(u<s&&r[u]===\")\")return!1;let f=u,h=!1;for(;f<s&&(r[f]===\" \"||r[f]===\"\t\"||r[f]===`\n`);)h=!0,f++;if(h&&f<s&&r[f]===\")\"||o)return!0}if(a===0)return!1;n++;continue}n++}return!1}dparenClosesWithSpacedParens(t){let r=this.input,s=r.length,n=t,a=2,i=!1,l=!1;for(;n<s&&a>0;){let o=r[n];if(i){o===\"'\"&&(i=!1),n++;continue}if(l){if(o===\"\\\\\"){n+=2;continue}o==='\"'&&(l=!1),n++;continue}if(o===\"'\"){i=!0,n++;continue}if(o==='\"'){l=!0,n++;continue}if(o===\"\\\\\"){n+=2;continue}if(o===\"(\"){a++,n++;continue}if(o===\")\"){if(a--,a===1){let c=n+1;if(c<s&&r[c]===\")\")return!1;let u=c,f=!1;for(;u<s&&(r[u]===\" \"||r[u]===\"\t\"||r[u]===`\n`);)f=!0,u++;if(f&&u<s&&r[u]===\")\")return!0}if(a===0)return!1;n++;continue}if(a===1&&(o===\"|\"&&n+1<s&&r[n+1]===\"|\"||o===\"&\"&&n+1<s&&r[n+1]===\"&\"||o===\"|\"&&n+1<s&&r[n+1]!==\"|\"))return!0;n++}return!1}};var Qe=1e6,Ze=1e5,Qt=1e6,Ue=200,Zt=new Set([p.LESS,p.GREAT,p.DLESS,p.DGREAT,p.LESSAND,p.GREATAND,p.LESSGREAT,p.DLESSDASH,p.CLOBBER,p.TLESS,p.AND_GREAT,p.AND_DGREAT]),Ut=new Set([p.LESS,p.GREAT,p.DLESS,p.DGREAT,p.LESSAND,p.GREATAND,p.LESSGREAT,p.DLESSDASH,p.CLOBBER,p.TLESS]),Ht=new Set([p.LESS,p.GREAT,p.DLESS,p.DGREAT,p.LESSAND,p.GREATAND,p.LESSGREAT,p.DLESSDASH,p.CLOBBER,p.TLESS,p.AND_GREAT,p.AND_DGREAT]),G=class extends Error{line;column;token;constructor(t,r,s,n=void 0){super(`Parse error at ${r}:${s}: ${t}`),this.line=r,this.column=s,this.token=n,this.name=\"ParseException\"}};function Cr(e){let t=\"\",r=0;for(;r<e.length;){let s=e[r];if(s<128){t+=String.fromCharCode(s),r++;continue}if((s&224)===192){if(r+1<e.length&&(e[r+1]&192)===128&&s>=194){let n=(s&31)<<6|e[r+1]&63;t+=String.fromCharCode(n),r+=2;continue}t+=String.fromCharCode(s),r++;continue}if((s&240)===224){if(r+2<e.length&&(e[r+1]&192)===128&&(e[r+2]&192)===128){if(s===224&&e[r+1]<160){t+=String.fromCharCode(s),r++;continue}let n=(s&15)<<12|(e[r+1]&63)<<6|e[r+2]&63;if(n>=55296&&n<=57343){t+=String.fromCharCode(s),r++;continue}t+=String.fromCharCode(n),r+=3;continue}t+=String.fromCharCode(s),r++;continue}if((s&248)===240&&s<=244){if(r+3<e.length&&(e[r+1]&192)===128&&(e[r+2]&192)===128&&(e[r+3]&192)===128){if(s===240&&e[r+1]<144){t+=String.fromCharCode(s),r++;continue}let n=(s&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63;if(n>1114111){t+=String.fromCharCode(s),r++;continue}t+=String.fromCodePoint(n),r+=4;continue}t+=String.fromCharCode(s),r++;continue}t+=String.fromCharCode(s),r++}return t}function Kt(e,t,r){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_-]/.test(t[s]);)s++;return s}function He(e,t,r,s,n){let a=1,i=r+1;for(;i<t.length&&a>0;)t[i]===s?a++:t[i]===n&&a--,a>0&&i++;return a===0?i:-1}function fe(e,t,r){let s=r,n=1;for(;s<t.length&&n>0;){let a=t[s];if(a===\"\\\\\"&&s+1<t.length){s+=2;continue}if(a===\"'\"){let i=t.indexOf(\"'\",s+1);if(i!==-1){s=i+1;continue}}if(a==='\"'){for(s++;s<t.length&&t[s]!=='\"';)t[s]===\"\\\\\"&&s+1<t.length?s+=2:s++;s<t.length&&s++;continue}a===\"{\"?n++:a===\"}\"&&n--,n>0&&s++}return s}function Xt(e,t,r){let s=r,n=!1;for(;s<t.length;){let a=t[s];if(a===\"/\"&&n||a===\"}\")break;if(a===\"'\"){let i=t.indexOf(\"'\",s+1);if(i!==-1){s=i+1,n=!0;continue}}if(a==='\"'){for(s++;s<t.length&&t[s]!=='\"';)t[s]===\"\\\\\"&&s+1<t.length?s+=2:s++;s<t.length&&s++,n=!0;continue}a===\"\\\\\"?(s+=2,n=!0):(s++,n=!0)}return s}function Jt(e,t,r){let s=r,n=\"\";for(;s<t.length;){let a=t[s];if(a===\"*\"||a===\"?\")n+=a,s++;else if(a===\"[\"){let i=Or(t,s);i===-1?(n+=a,s++):(n+=t.slice(s,i+1),s=i+1)}else break}return{pattern:n,endIndex:s}}function Or(e,t){let r=t+1;for(r<e.length&&e[r]===\"^\"&&r++,r<e.length&&e[r]===\"]\"&&r++;r<e.length;){let s=e[r];if(s===\"\\\\\"&&r+1<e.length){let n=e[r+1];if(n==='\"'||n===\"'\")return-1;r+=2;continue}if(s===\"]\")return r;if(s==='\"'||s===\"$\"||s===\"`\")return-1;if(s===\"'\"){let n=e.indexOf(\"'\",r+1);if(n!==-1){r=n+1;continue}}if(s===\"[\"&&r+1<e.length&&e[r+1]===\":\"){let n=e.indexOf(\":]\",r+2);if(n!==-1){r=n+2;continue}}if(s===\"[\"&&r+1<e.length&&(e[r+1]===\".\"||e[r+1]===\"=\")){let a=`${e[r+1]}]`,i=e.indexOf(a,r+2);if(i!==-1){r=i+2;continue}}r++}return-1}function Yt(e,t,r){let s=\"\",n=r;for(;n<t.length&&t[n]!==\"'\";){let a=t[n];if(a===\"\\\\\"&&n+1<t.length)switch(t[n+1]){case\"n\":s+=`\n`,n+=2;break;case\"t\":s+=\"\t\",n+=2;break;case\"r\":s+=\"\\r\",n+=2;break;case\"\\\\\":s+=\"\\\\\",n+=2;break;case\"'\":s+=\"'\",n+=2;break;case'\"':s+='\"',n+=2;break;case\"a\":s+=\"\\x07\",n+=2;break;case\"b\":s+=\"\\b\",n+=2;break;case\"e\":case\"E\":s+=\"\\x1B\",n+=2;break;case\"f\":s+=\"\\f\",n+=2;break;case\"v\":s+=\"\\v\",n+=2;break;case\"x\":{let l=[],o=n;for(;o+1<t.length&&t[o]===\"\\\\\"&&t[o+1]===\"x\";){let c=t.slice(o+2,o+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)l.push(u),o+=2+c.length;else break}l.length>0?(s+=Cr(l),n=o):(s+=\"\\\\x\",n+=2);break}case\"u\":{let l=t.slice(n+2,n+6),o=parseInt(l,16);Number.isNaN(o)?(s+=\"\\\\u\",n+=2):(s+=String.fromCharCode(o),n+=6);break}case\"c\":{if(n+2<t.length){let o=t[n+2].charCodeAt(0)&31;s+=String.fromCharCode(o),n+=3}else s+=\"\\\\c\",n+=2;break}case\"0\":case\"1\":case\"2\":case\"3\":case\"4\":case\"5\":case\"6\":case\"7\":{let l=\"\",o=n+1;for(;o<t.length&&o<n+4&&/[0-7]/.test(t[o]);)l+=t[o],o++;let c=parseInt(l,8);s+=String.fromCharCode(c),n=o;break}default:s+=a,n++}else s+=a,n++}return n<t.length&&t[n]===\"'\"&&n++,{part:w.literal(s),endIndex:n}}function je(e,t){let r=t.trim();return r===\"\"?{type:\"ArithmeticExpression\",expression:{type:\"ArithNumber\",value:0}}:M(e,r)}function jt(e){let t=[],r=\"\",s=0;for(let n=0;n<e.length;n++){let a=e[n];a===\"{\"?(s++,r+=a):a===\"}\"?(s--,r+=a):a===\",\"&&s===0?(t.push(r),r=\"\"):r+=a}return t.push(r),t}function en(e,t,r,s){let n=He(e,t,r,\"{\",\"}\");if(n===-1)return null;let a=t.slice(r+1,n),i=a.match(/^(-?\\d+)\\.\\.(-?\\d+)(?:\\.\\.(-?\\d+))?$/);if(i)return{part:{type:\"BraceExpansion\",items:[{type:\"Range\",start:Number.parseInt(i[1],10),end:Number.parseInt(i[2],10),step:i[3]?Number.parseInt(i[3],10):void 0,startStr:i[1],endStr:i[2]}]},endIndex:n+1};let l=a.match(/^([a-zA-Z])\\.\\.([a-zA-Z])(?:\\.\\.(-?\\d+))?$/);return l?{part:{type:\"BraceExpansion\",items:[{type:\"Range\",start:l[1],end:l[2],step:l[3]?Number.parseInt(l[3],10):void 0}]},endIndex:n+1}:a.includes(\",\")&&s?{part:{type:\"BraceExpansion\",items:jt(a).map(u=>({type:\"Word\",word:w.word(s(e,u,!1,!1,!1))}))},endIndex:n+1}:a.includes(\",\")?{part:{type:\"BraceExpansion\",items:jt(a).map(u=>({type:\"Word\",word:w.word([w.literal(u)])}))},endIndex:n+1}:null}function Ke(e,t){let r=\"\";for(let s of t.parts)switch(s.type){case\"Literal\":r+=s.value;break;case\"SingleQuoted\":r+=`'${s.value}'`;break;case\"Escaped\":r+=s.value;break;case\"DoubleQuoted\":r+='\"';for(let n of s.parts)n.type===\"Literal\"||n.type===\"Escaped\"?r+=n.value:n.type===\"ParameterExpansion\"&&(r+=`\\${${n.parameter}}`);r+='\"';break;case\"ParameterExpansion\":r+=`\\${${s.parameter}}`;break;case\"Glob\":r+=s.pattern;break;case\"TildeExpansion\":r+=\"~\",s.user&&(r+=s.user);break;case\"BraceExpansion\":{r+=\"{\";let n=[];for(let a of s.items)if(a.type===\"Range\"){let i=a.startStr??String(a.start),l=a.endStr??String(a.end);a.step!==void 0?n.push(`${i}..${l}..${a.step}`):n.push(`${i}..${l}`)}else n.push(Ke(e,a.word));n.length===1&&s.items[0].type===\"Range\"?r+=n[0]:r+=n.join(\",\"),r+=\"}\";break}default:r+=s.type}return r}function tn(e,t){return{[p.LESS]:\"<\",[p.GREAT]:\">\",[p.DGREAT]:\">>\",[p.LESSAND]:\"<&\",[p.GREATAND]:\">&\",[p.LESSGREAT]:\"<>\",[p.CLOBBER]:\">|\",[p.TLESS]:\"<<<\",[p.AND_GREAT]:\"&>\",[p.AND_DGREAT]:\"&>>\",[p.DLESS]:\"<\",[p.DLESSDASH]:\"<\"}[t]||\">\"}function De(e){let t=e.current(),r=t.type;if(r===p.NUMBER){let s=e.peek(1);return t.end!==s.start?!1:Ut.has(s.type)}if(r===p.FD_VARIABLE){let s=e.peek(1);return Ht.has(s.type)}return Zt.has(r)}function xe(e){let t=null,r;e.check(p.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(p.FD_VARIABLE)&&(r=e.advance().value);let s=e.advance(),n=tn(e,s.type);if(s.type===p.DLESS||s.type===p.DLESSDASH)return Lr(e,n,t,s.type===p.DLESSDASH);e.isWord()||e.error(\"Expected redirection target\");let a=e.parseWord();return w.redirection(n,a,t,r)}function Lr(e,t,r,s){e.isWord()||e.error(\"Expected here-document delimiter\");let n=e.advance(),a=n.value,i=n.quoted||!1;(a.startsWith(\"'\")&&a.endsWith(\"'\")||a.startsWith('\"')&&a.endsWith('\"'))&&(a=a.slice(1,-1));let l=w.redirection(s?\"<<-\":\"<<\",w.hereDoc(a,w.word([]),s,i),r);return e.addPendingHeredoc(l,a,s,i),l}function rn(e){let t=e.current().line,r=[],s=null,n=[],a=[];for(;e.check(p.ASSIGNMENT_WORD)||De(e);)e.checkIterationLimit(),e.check(p.ASSIGNMENT_WORD)?r.push(Wr(e)):a.push(xe(e));if(e.isWord())s=e.parseWord();else if(r.length>0&&(e.check(p.DBRACK_START)||e.check(p.DPAREN_START))){let l=e.advance();s=w.word([w.literal(l.value)])}for(;(!e.isStatementEnd()||e.check(p.RBRACE))&&!e.check(p.PIPE,p.PIPE_AMP);)if(e.checkIterationLimit(),De(e))a.push(xe(e));else if(e.check(p.RBRACE)){let l=e.advance();n.push(e.parseWordFromString(l.value,!1,!1))}else if(e.check(p.LBRACE)){let l=e.advance();n.push(e.parseWordFromString(l.value,!1,!1))}else if(e.check(p.DBRACK_END)){let l=e.advance();n.push(e.parseWordFromString(l.value,!1,!1))}else if(e.isWord())n.push(e.parseWord());else if(e.check(p.ASSIGNMENT_WORD)){let l=e.advance(),o=l.value,c=o.endsWith(\"=\"),u=o.endsWith(\"=(\");if((c||u)&&(u||e.check(p.LPAREN))){let f=u?o.slice(0,-2):o.slice(0,-1);u||e.expect(p.LPAREN);let h=Xe(e);e.expect(p.RPAREN);let d=h.map(g=>Ke(e,g)),m=`${f}=(${d.join(\" \")})`;n.push(e.parseWordFromString(m,!1,!1))}else n.push(e.parseWordFromString(o,l.quoted,l.singleQuoted))}else if(e.check(p.LPAREN))e.error(\"syntax error near unexpected token `('\");else break;let i=w.simpleCommand(s,n,r,a);return i.line=t,i}function Wr(e){let t=e.expect(p.ASSIGNMENT_WORD),r=t.value,s=r.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);s||e.error(`Invalid assignment: ${r}`);let n=s[0],a,i=n.length;if(r[i]===\"[\"){let f=0,h=i+1;for(;i<r.length;i++)if(r[i]===\"[\")f++;else if(r[i]===\"]\"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${r}`),a=r.slice(h,i),i++}let l=r[i]===\"+\";l&&i++,r[i]!==\"=\"&&e.error(`Invalid assignment: ${r}`),i++;let o=r.slice(i);if(o===\"(\"){let f=Xe(e);e.expect(p.RPAREN);let h=a!==void 0?`${n}[${a}]`:n;return w.assignment(h,null,l,f)}if(o===\"\"&&e.check(p.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let h=Xe(e);e.expect(p.RPAREN);let d=a!==void 0?`${n}[${a}]`:n;return w.assignment(d,null,l,h)}}let c=o?e.parseWordFromString(o,t.quoted,t.singleQuoted,!0):null,u=a!==void 0?`${n}[${a}]`:n;return w.assignment(u,c,l,null)}var Tr=new Set([p.AMP,p.PIPE,p.PIPE_AMP,p.SEMICOLON,p.AND_AND,p.OR_OR,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND]);function Xe(e){let t=[];for(e.skipNewlines();!e.check(p.RPAREN,p.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):Tr.has(e.current().type)?e.error(`syntax error near unexpected token \\`${e.current().value}'`):e.advance(),e.skipNewlines();return t}function Je(e,t){e.expect(p.IF);let r=[],s=e.parseCompoundList();e.expect(p.THEN);let n=e.parseCompoundList();if(n.length===0){let l=e.check(p.FI)?\"fi\":e.check(p.ELSE)?\"else\":e.check(p.ELIF)?\"elif\":\"fi\";e.error(`syntax error near unexpected token \\`${l}'`)}for(r.push({condition:s,body:n});e.check(p.ELIF);){e.advance();let l=e.parseCompoundList();e.expect(p.THEN);let o=e.parseCompoundList();if(o.length===0){let c=e.check(p.FI)?\"fi\":e.check(p.ELSE)?\"else\":e.check(p.ELIF)?\"elif\":\"fi\";e.error(`syntax error near unexpected token \\`${c}'`)}r.push({condition:l,body:o})}let a=null;e.check(p.ELSE)&&(e.advance(),a=e.parseCompoundList(),a.length===0&&e.error(\"syntax error near unexpected token `fi'\")),e.expect(p.FI);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.ifNode(r,a,i)}function Ye(e,t){let r=e.expect(p.FOR);if(e.check(p.DPAREN_START))return Vr(e,t,r.line);e.isWord()||e.error(\"Expected variable name in for loop\");let n=e.advance().value,a=null;if(e.skipNewlines(),e.check(p.IN))for(e.advance(),a=[];!e.check(p.SEMICOLON,p.NEWLINE,p.DO,p.EOF)&&e.isWord();)a.push(e.parseWord());e.check(p.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(p.DO);let i=e.parseCompoundList();e.expect(p.DONE);let l=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.forNode(n,a,i,l)}function Vr(e,t,r){e.expect(p.DPAREN_START);let s=null,n=null,a=null,i=[\"\",\"\",\"\"],l=0,o=0;for(;!e.check(p.DPAREN_END,p.EOF);){let f=e.advance();if(f.type===p.SEMICOLON&&o===0){if(l++,l>2)break}else f.value===\"(\"&&o++,f.value===\")\"&&o--,i[l]+=f.value}e.expect(p.DPAREN_END),i[0].trim()&&(s=M(e,i[0].trim())),i[1].trim()&&(n=M(e,i[1].trim())),i[2].trim()&&(a=M(e,i[2].trim())),e.skipNewlines(),e.check(p.SEMICOLON)&&e.advance(),e.skipNewlines();let c;e.check(p.LBRACE)?(e.advance(),c=e.parseCompoundList(),e.expect(p.RBRACE)):(e.expect(p.DO),c=e.parseCompoundList(),e.expect(p.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:\"CStyleFor\",init:s,condition:n,update:a,body:c,redirections:u,line:r}}function et(e,t){e.expect(p.WHILE);let r=e.parseCompoundList();e.expect(p.DO);let s=e.parseCompoundList();s.length===0&&e.error(\"syntax error near unexpected token `done'\"),e.expect(p.DONE);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.whileNode(r,s,n)}function tt(e,t){e.expect(p.UNTIL);let r=e.parseCompoundList();e.expect(p.DO);let s=e.parseCompoundList();s.length===0&&e.error(\"syntax error near unexpected token `done'\"),e.expect(p.DONE);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.untilNode(r,s,n)}function nt(e,t){e.expect(p.CASE),e.isWord()||e.error(\"Expected word after 'case'\");let r=e.parseWord();e.skipNewlines(),e.expect(p.IN),e.skipNewlines();let s=[];for(;!e.check(p.ESAC,p.EOF);){e.checkIterationLimit();let a=e.getPos(),i=qr(e);if(i&&s.push(i),e.skipNewlines(),e.getPos()===a&&!i)break}e.expect(p.ESAC);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.caseNode(r,s,n)}function qr(e){e.check(p.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(p.PIPE));)e.advance();if(t.length===0)return null;e.expect(p.RPAREN),e.skipNewlines();let r=[];for(;!e.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND,p.ESAC,p.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===p.RPAREN&&e.error(\"syntax error near unexpected token `)'\"),e.check(p.LPAREN)&&e.peek(1).type===p.WORD&&e.error(`syntax error near unexpected token \\`${e.peek(1).value}'`);let n=e.getPos(),a=e.parseStatement();if(a&&r.push(a),e.skipSeparators(!1),e.getPos()===n&&!a)break}let s=\";;\";return e.check(p.DSEMI)?(e.advance(),s=\";;\"):e.check(p.SEMI_AND)?(e.advance(),s=\";&\"):e.check(p.SEMI_SEMI_AND)&&(e.advance(),s=\";;&\"),w.caseItem(t,r,s)}function rt(e,t){e.expect(p.LPAREN);let r=e.parseCompoundList();e.expect(p.RPAREN);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.subshell(r,s)}function st(e,t){e.expect(p.LBRACE);let r=e.parseCompoundList();e.expect(p.RBRACE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.group(r,s)}var Fr=[\"-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\"],zr=[\"==\",\"!=\",\"=~\",\"<\",\">\",\"-eq\",\"-ne\",\"-lt\",\"-le\",\"-gt\",\"-ge\",\"-nt\",\"-ot\",\"-ef\"];function sn(e){return e.isWord()||e.check(p.LBRACE)||e.check(p.RBRACE)||e.check(p.ASSIGNMENT_WORD)}function an(e){if(e.check(p.BANG)&&e.peek(1).type===p.LPAREN){e.advance(),e.advance();let t=1,r=\"!(\";for(;t>0&&!e.check(p.EOF);)if(e.check(p.LPAREN))t++,r+=\"(\",e.advance();else if(e.check(p.RPAREN))t--,t>0&&(r+=\")\"),e.advance();else if(e.isWord())r+=e.advance().value;else if(e.check(p.PIPE))r+=\"|\",e.advance();else break;return r+=\")\",e.parseWordFromString(r,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function at(e){return e.skipNewlines(),Gr(e)}function Gr(e){let t=on(e);for(e.skipNewlines();e.check(p.OR_OR);){e.advance(),e.skipNewlines();let r=on(e);t={type:\"CondOr\",left:t,right:r},e.skipNewlines()}return t}function on(e){let t=it(e);for(e.skipNewlines();e.check(p.AND_AND);){e.advance(),e.skipNewlines();let r=it(e);t={type:\"CondAnd\",left:t,right:r},e.skipNewlines()}return t}function it(e){return e.skipNewlines(),e.check(p.BANG)?(e.advance(),e.skipNewlines(),{type:\"CondNot\",operand:it(e)}):Qr(e)}function Qr(e){if(e.check(p.LPAREN)){e.advance();let t=at(e);return e.expect(p.RPAREN),{type:\"CondGroup\",expression:t}}if(sn(e)){let t=e.current(),r=t.value;if(Fr.includes(r)&&!t.quoted){if(e.advance(),e.check(p.DBRACK_END)&&e.error(`Expected operand after ${r}`),sn(e)){let a=e.parseWordNoBraceExpansion();return{type:\"CondUnary\",operator:r,operand:a}}let n=e.current();e.error(`unexpected argument \\`${n.value}' to conditional unary operator`)}let s=e.parseWordNoBraceExpansion();if(e.isWord()&&zr.includes(e.current().value)){let n=e.advance().value,a;return n===\"=~\"?a=Zr(e):n===\"==\"||n===\"!=\"?a=an(e):a=e.parseWordNoBraceExpansion(),{type:\"CondBinary\",operator:n,left:s,right:a}}if(e.check(p.LESS)){e.advance();let n=e.parseWordNoBraceExpansion();return{type:\"CondBinary\",operator:\"<\",left:s,right:n}}if(e.check(p.GREAT)){e.advance();let n=e.parseWordNoBraceExpansion();return{type:\"CondBinary\",operator:\">\",left:s,right:n}}if(e.isWord()&&e.current().value===\"=\"){e.advance();let n=an(e);return{type:\"CondBinary\",operator:\"==\",left:s,right:n}}return{type:\"CondWord\",word:s}}e.error(\"Expected conditional expression\")}function Zr(e){let t=[],r=0,s=-1,n=e.getInput(),a=()=>e.check(p.DBRACK_END)||e.check(p.AND_AND)||e.check(p.OR_OR)||e.check(p.NEWLINE)||e.check(p.EOF);for(;!a();){let i=e.current(),l=s>=0&&i.start>s;if(r===0&&l)break;if(r>0&&l){let o=n.slice(s,i.start);t.push({type:\"Literal\",value:o})}if(e.isWord()||e.check(p.ASSIGNMENT_WORD)){let o=e.parseWordForRegex();t.push(...o.parts),s=e.peek(-1).end}else if(e.check(p.LPAREN)){let o=e.advance();t.push({type:\"Literal\",value:\"(\"}),r++,s=o.end}else if(e.check(p.DPAREN_START)){let o=e.advance();t.push({type:\"Literal\",value:\"((\"}),r+=2,s=o.end}else if(e.check(p.DPAREN_END))if(r>=2){let o=e.advance();t.push({type:\"Literal\",value:\"))\"}),r-=2,s=o.end}else{if(r===1)break;break}else if(e.check(p.RPAREN))if(r>0){let o=e.advance();t.push({type:\"Literal\",value:\")\"}),r--,s=o.end}else break;else if(e.check(p.PIPE)){let o=e.advance();t.push({type:\"Literal\",value:\"|\"}),s=o.end}else if(e.check(p.SEMICOLON))if(r>0){let o=e.advance();t.push({type:\"Literal\",value:\";\"}),s=o.end}else break;else if(r>0&&e.check(p.LESS)){let o=e.advance();t.push({type:\"Literal\",value:\"<\"}),s=o.end}else if(r>0&&e.check(p.GREAT)){let o=e.advance();t.push({type:\"Literal\",value:\">\"}),s=o.end}else if(r>0&&e.check(p.DGREAT)){let o=e.advance();t.push({type:\"Literal\",value:\">>\"}),s=o.end}else if(r>0&&e.check(p.DLESS)){let o=e.advance();t.push({type:\"Literal\",value:\"<<\"}),s=o.end}else if(r>0&&e.check(p.LESSAND)){let o=e.advance();t.push({type:\"Literal\",value:\"<&\"}),s=o.end}else if(r>0&&e.check(p.GREATAND)){let o=e.advance();t.push({type:\"Literal\",value:\">&\"}),s=o.end}else if(r>0&&e.check(p.LESSGREAT)){let o=e.advance();t.push({type:\"Literal\",value:\"<>\"}),s=o.end}else if(r>0&&e.check(p.CLOBBER)){let o=e.advance();t.push({type:\"Literal\",value:\">|\"}),s=o.end}else if(r>0&&e.check(p.TLESS)){let o=e.advance();t.push({type:\"Literal\",value:\"<<<\"}),s=o.end}else if(r>0&&e.check(p.AMP)){let o=e.advance();t.push({type:\"Literal\",value:\"&\"}),s=o.end}else if(r>0&&e.check(p.LBRACE)){let o=e.advance();t.push({type:\"Literal\",value:\"{\"}),s=o.end}else if(r>0&&e.check(p.RBRACE)){let o=e.advance();t.push({type:\"Literal\",value:\"}\"}),s=o.end}else break}return t.length===0&&e.error(\"Expected regex pattern after =~\"),{type:\"Word\",parts:t}}function Ee(e){return e.length>0?e:[w.literal(\"\")]}function Hr(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n===\"\\\\\"){s+=2;continue}if(\"@*+?!\".includes(n)&&s+1<e.length&&e[s+1]===\"(\"){s++,r++,s++;continue}if(n===\"(\")r++;else if(n===\")\"&&(r--,r===0))return s;s++}return-1}function jr(e,t,r){let s=r+1,n=t[s];if(\"@*#?$!-0123456789\".includes(n))return{part:w.parameterExpansion(n),endIndex:s+1};let a=\"\";for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)a+=t[s],s++;return{part:w.parameterExpansion(a),endIndex:s}}function Kr(e,t,r,s=!1){let n=r+2,a=!1;t[n]===\"!\"&&(a=!0,n++);let i=!1;t[n]===\"#\"&&!/[}:#%/^,]/.test(t[n+1]||\"}\")&&(i=!0,n++);let l=\"\",o=t[n];if(/[@*#?$!-]/.test(o)&&!/[a-zA-Z0-9_]/.test(t[n+1]||\"\"))l=o,n++;else for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)l+=t[n],n++;if(t[n]===\"[\"){let u=He(e,t,n,\"[\",\"]\");if(l+=t.slice(n,u+1),n=u+1,t[n]===\"[\"){let f=1,h=n;for(;h<t.length&&f>0;)t[h]===\"{\"?f++:t[h]===\"}\"&&f--,f>0&&h++;let d=t.slice(r+2,h);return{part:w.parameterExpansion(\"\",{type:\"BadSubstitution\",text:d}),endIndex:h+1}}}if(l===\"\"&&!a&&!i&&t[n]!==\"}\"){let u=1,f=n;for(;f<t.length&&u>0;)t[f]===\"{\"?u++:t[f]===\"}\"&&u--,u>0&&f++;if(u>0)throw new G(\"unexpected EOF while looking for matching '}'\",0,0);let h=t.slice(r+2,f);return{part:w.parameterExpansion(\"\",{type:\"BadSubstitution\",text:h}),endIndex:f+1}}let c=null;if(a){let u=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(u)if(n<t.length&&t[n]!==\"}\"&&/[:=\\-+?#%/^,@]/.test(t[n])){let f=ot(e,t,n,l,s);f.operation?(c={type:\"Indirection\",innerOp:f.operation},n=f.endIndex):(c={type:\"ArrayKeys\",array:u[1],star:u[2]===\"*\"},l=\"\")}else c={type:\"ArrayKeys\",array:u[1],star:u[2]===\"*\"},l=\"\";else if(t[n]===\"*\"||t[n]===\"@\"&&!/[QPaAEKkuUL]/.test(t[n+1]||\"\")){let f=t[n];n++,c={type:\"VarNamePrefix\",prefix:l,star:f===\"*\"},l=\"\"}else if(n<t.length&&t[n]!==\"}\"&&/[:=\\-+?#%/^,@]/.test(t[n])){let f=ot(e,t,n,l,s);f.operation?(c={type:\"Indirection\",innerOp:f.operation},n=f.endIndex):c={type:\"Indirection\"}}else c={type:\"Indirection\"}}else if(i)if(t[n]===\":\")for(c={type:\"LengthSliceError\"};n<t.length&&t[n]!==\"}\";)n++;else t[n]!==\"}\"&&/[-+=?]/.test(t[n])?e.error(`\\${#${l}${t.slice(n,t.indexOf(\"}\",n))}}: bad substitution`):t[n]===\"/\"?e.error(`\\${#${l}${t.slice(n,t.indexOf(\"}\",n))}}: bad substitution`):c={type:\"Length\"};if(!c&&n<t.length&&t[n]!==\"}\"){let u=ot(e,t,n,l,s);c=u.operation,n=u.endIndex}if(n<t.length&&t[n]!==\"}\"){let u=t[n];if(!/[:\\-+=?#%/^,@[]/.test(u)){let f=n;for(;f<t.length&&t[f]!==\"}\";)f++;let h=t.slice(r,f+1);e.error(`\\${${h.slice(2,-1)}}: bad substitution`)}}for(;n<t.length&&t[n]!==\"}\";)n++;if(n>=t.length)throw new G(\"unexpected EOF while looking for matching '}'\",0,0);return{part:w.parameterExpansion(l,c),endIndex:n+1}}function ot(e,t,r,s,n=!1){let a=r,i=t[a],l=t[a+1]||\"\";if(i===\":\"){let o=l;if(\"-=?+\".includes(o)){a+=2;let A=fe(e,t,a),S=t.slice(a,A),y=ae(e,S,!1,!1,!0,!1,n,!1,!1,!0),b=w.word(Ee(y));if(o===\"-\")return{operation:{type:\"DefaultValue\",word:b,checkEmpty:!0},endIndex:A};if(o===\"=\")return{operation:{type:\"AssignDefault\",word:b,checkEmpty:!0},endIndex:A};if(o===\"?\")return{operation:{type:\"ErrorIfUnset\",word:b,checkEmpty:!0},endIndex:A};if(o===\"+\")return{operation:{type:\"UseAlternative\",word:b,checkEmpty:!0},endIndex:A}}a++;let c=fe(e,t,a),u=t.slice(a,c),f=-1,h=0,d=0;for(let E=0;E<u.length;E++){let A=u[E];if(A===\"(\"||A===\"[\")h++;else if(A===\")\"||A===\"]\")h--;else if(A===\"?\"&&h===0)d++;else if(A===\":\"&&h===0)if(d>0)d--;else{f=E;break}}let m=f>=0?u.slice(0,f):u,g=f>=0?u.slice(f+1):null;return{operation:{type:\"Substring\",offset:je(e,m),length:g!==null?je(e,g):null},endIndex:c}}if(\"-=?+\".includes(i)){a++;let o=fe(e,t,a),c=t.slice(a,o),u=ae(e,c,!1,!1,!0,!1,n,!1,!1,!0),f=w.word(Ee(u));if(i===\"-\")return{operation:{type:\"DefaultValue\",word:f,checkEmpty:!1},endIndex:o};if(i===\"=\")return{operation:{type:\"AssignDefault\",word:f,checkEmpty:!1},endIndex:o};if(i===\"?\")return{operation:{type:\"ErrorIfUnset\",word:c?f:null,checkEmpty:!1},endIndex:o};if(i===\"+\")return{operation:{type:\"UseAlternative\",word:f,checkEmpty:!1},endIndex:o}}if(i===\"#\"||i===\"%\"){let o=l===i,c=i===\"#\"?\"prefix\":\"suffix\";a+=o?2:1;let u=fe(e,t,a),f=t.slice(a,u),h=ae(e,f,!1,!1,!1);return{operation:{type:\"PatternRemoval\",pattern:w.word(Ee(h)),side:c,greedy:o},endIndex:u}}if(i===\"/\"){let o=l===\"/\";a+=o?2:1;let c=null;t[a]===\"#\"?(c=\"start\",a++):t[a]===\"%\"&&(c=\"end\",a++);let u;c!==null&&(t[a]===\"/\"||t[a]===\"}\")?u=a:u=Xt(e,t,a);let f=t.slice(a,u),h=ae(e,f,!1,!1,!1),d=w.word(Ee(h)),m=null,g=u;if(t[u]===\"/\"){let E=u+1,A=fe(e,t,E),S=t.slice(E,A),y=ae(e,S,!1,!1,!1);m=w.word(Ee(y)),g=A}return{operation:{type:\"PatternReplacement\",pattern:d,replacement:m,all:o,anchor:c},endIndex:g}}if(i===\"^\"||i===\",\"){let o=l===i,c=i===\"^\"?\"upper\":\"lower\";a+=o?2:1;let u=fe(e,t,a),f=t.slice(a,u),h=f?w.word([w.literal(f)]):null;return{operation:{type:\"CaseModification\",direction:c,all:o,pattern:h},endIndex:u}}return i===\"@\"&&/[QPaAEKkuUL]/.test(l)?{operation:{type:\"Transform\",operator:l},endIndex:a+2}:{operation:null,endIndex:a}}function lt(e,t,r,s=!1){let n=r+1;if(n>=t.length)return{part:w.literal(\"$\"),endIndex:n};let a=t[n];if(a===\"(\"&&t[n+1]===\"(\")return e.isDollarDparenSubshell(t,r)?e.parseCommandSubstitution(t,r):e.parseArithmeticExpansion(t,r);if(a===\"[\"){let i=1,l=n+1;for(;l<t.length&&i>0;)t[l]===\"[\"?i++:t[l]===\"]\"&&i--,i>0&&l++;if(i===0){let o=t.slice(n+1,l),c=M(e,o);return{part:w.arithmeticExpansion(c),endIndex:l+1}}}return a===\"(\"?e.parseCommandSubstitution(t,r):a===\"{\"?Kr(e,t,r,s):/[a-zA-Z_0-9@*#?$!-]/.test(a)?jr(e,t,r):{part:w.literal(\"$\"),endIndex:n}}function ln(e,t){let r=[],s=0,n=\"\",a=()=>{n&&(r.push(w.literal(n)),n=\"\")};for(;s<t.length;){let i=t[s];if(i===\"\\\\\"&&s+1<t.length){let l=t[s+1];if(l===\"$\"||l===\"`\"||l==='\"'||l===\"\\\\\"){n+=l,s+=2;continue}n+=i,s++;continue}if(i===\"$\"){a();let{part:l,endIndex:o}=lt(e,t,s,!0);l&&r.push(l),s=o;continue}if(i===\"`\"){a();let{part:l,endIndex:o}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=o;continue}n+=i,s++}return a(),r}function Xr(e,t,r){let s=[],n=r,a=\"\",i=()=>{a&&(s.push(w.literal(a)),a=\"\")};for(;n<t.length&&t[n]!=='\"';){let l=t[n];if(l===\"\\\\\"&&n+1<t.length){let o=t[n+1];if('\"\\\\$`\\n'.includes(o)){a+=o,n+=2;continue}a+=l,n++;continue}if(l===\"$\"){i();let{part:o,endIndex:c}=lt(e,t,n,!0);o&&s.push(o),n=c;continue}if(l===\"`\"){i();let{part:o,endIndex:c}=e.parseBacktickSubstitution(t,n,!0);s.push(o),n=c;continue}a+=l,n++}return i(),{part:w.doubleQuoted(s),endIndex:n}}function ae(e,t,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1,o=!1,c=!1){if(s)return[w.singleQuoted(t)];if(r){let m=ln(e,t);return[w.doubleQuoted(m)]}if(t.length>=2&&t[0]==='\"'&&t[t.length-1]==='\"'){let m=t.slice(1,-1),g=!1;for(let E=0;E<m.length;E++){if(m[E]==='\"'){g=!0;break}m[E]===\"\\\\\"&&E+1<m.length&&E++}if(!g){let E=ln(e,m);return[w.doubleQuoted(E)]}}let u=[],f=0,h=\"\",d=()=>{h&&(u.push(w.literal(h)),h=\"\")};for(;f<t.length;){let m=t[f];if(m===\"\\\\\"&&f+1<t.length){let g=t[f+1];if(o){d(),u.push(w.escaped(g)),f+=2;continue}let E=a?g===\"$\"||g===\"`\"||g===`\n`:g===\"$\"||g===\"`\"||g==='\"'||g===\"'\"||g===`\n`||c&&g===\"}\",A=i?\"*?[]\\\\\".includes(g):\"*?[]\\\\(){}.^+\".includes(g);E?h+=g:A?(d(),u.push(w.escaped(g))):h+=`\\\\${g}`,f+=2;continue}if(m===\"'\"&&!i&&!a){d();let g=t.indexOf(\"'\",f+1);if(g===-1){h+=t.slice(f);break}u.push(w.singleQuoted(t.slice(f+1,g))),f=g+1;continue}if(m==='\"'&&!a){d();let{part:g,endIndex:E}=Xr(e,t,f+1);u.push(g),f=E+1;continue}if(m===\"$\"&&t[f+1]===\"'\"){d();let{part:g,endIndex:E}=Yt(e,t,f+2);u.push(g),f=E;continue}if(m===\"$\"){d();let{part:g,endIndex:E}=lt(e,t,f);g&&u.push(g),f=E;continue}if(m===\"`\"){d();let{part:g,endIndex:E}=e.parseBacktickSubstitution(t,f);u.push(g),f=E;continue}if(m===\"~\"){let g=f>0?t[f-1]:\"\";if(f===0||g===\"=\"||n&&g===\":\"){let A=Kt(e,t,f),S=t[A];if(S===void 0||S===\"/\"||S===\":\"){d();let y=t.slice(f+1,A)||null;u.push({type:\"TildeExpansion\",user:y}),f=A;continue}}}if(\"@*+?!\".includes(m)&&f+1<t.length&&t[f+1]===\"(\"){let g=Hr(t,f+1);if(g!==-1){d();let E=t.slice(f,g+1);u.push({type:\"Glob\",pattern:E}),f=g+1;continue}}if(m===\"*\"||m===\"?\"||m===\"[\"){d();let{pattern:g,endIndex:E}=Jt(e,t,f);u.push({type:\"Glob\",pattern:g}),f=E;continue}if(m===\"{\"&&!n&&!l&&!a){let g=en(e,t,f,ae);if(g){d(),u.push(g.part),f=g.endIndex;continue}}h+=m,f++}return d(),u}function un(e,t){let r=e.length,s=t+3,n=2,a=!1,i=!1;for(;s<r&&n>0;){let l=e[s];if(a){l===\"'\"&&(a=!1),s++;continue}if(i){if(l===\"\\\\\"){s+=2;continue}l==='\"'&&(i=!1),s++;continue}if(l===\"'\"){a=!0,s++;continue}if(l==='\"'){i=!0,s++;continue}if(l===\"\\\\\"){s+=2;continue}if(l===\"(\"){n++,s++;continue}if(l===\")\"){if(n--,n===1){let o=s+1;return!(o<r&&e[o]===\")\")}if(n===0)return!1;s++;continue}if(n===1&&(l===\"|\"&&s+1<r&&e[s+1]===\"|\"||l===\"&\"&&s+1<r&&e[s+1]===\"&\"||l===\"|\"&&s+1<r&&e[s+1]!==\"|\"))return!0;s++}return!1}function cn(e,t,r,s){let n=t+2,a=1,i=n,l=!1,o=!1,c=0,u=!1,f=\"\";for(;i<e.length&&a>0;){let g=e[i];l?g===\"'\"&&(l=!1):o?g===\"\\\\\"&&i+1<e.length?i++:g==='\"'&&(o=!1):g===\"'\"?(l=!0,f=\"\"):g==='\"'?(o=!0,f=\"\"):g===\"\\\\\"&&i+1<e.length?(i++,f=\"\"):/[a-zA-Z_]/.test(g)?f+=g:(f===\"case\"?(c++,u=!1):f===\"in\"&&c>0?u=!0:f===\"esac\"&&c>0&&(c--,u=!1),f=\"\",g===\"(\"?i>0&&e[i-1]===\"$\"?a++:u||a++:g===\")\"?u?u=!1:a--:g===\";\"&&c>0&&i+1<e.length&&e[i+1]===\";\"&&(u=!0)),a>0&&i++}a>0&&s(\"unexpected EOF while looking for matching `)'\");let h=e.slice(n,i),m=r().parse(h);return{part:w.commandSubstitution(m,!1),endIndex:i+1}}function fn(e,t,r,s,n){let i=t+1,l=\"\";for(;i<e.length&&e[i]!==\"`\";)if(e[i]===\"\\\\\"){let u=e[i+1];u===\"$\"||u===\"`\"||u===\"\\\\\"||u===`\n`||r&&u==='\"'?(u!==`\n`&&(l+=u),i+=2):(l+=e[i],i++)}else l+=e[i],i++;i>=e.length&&n(\"unexpected EOF while looking for matching ``'\");let c=s().parse(l);return{part:w.commandSubstitution(c,!0),endIndex:i+1}}var V=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input=\"\";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Qt)throw new G(\"Maximum parse iterations exceeded (possible infinite loop)\",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Ue)throw new G(`Maximum parser nesting depth exceeded (${Ue})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(t,r){if(t.length>Qe)throw new G(`Input too large: ${t.length} bytes exceeds limit of ${Qe}`,1,1);this._input=t;let s=new ve(t,r);if(this.tokens=s.tokenize(),this.tokens.length>Ze)throw new G(`Too many tokens: ${this.tokens.length} exceeds limit of ${Ze}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,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,r,s,n,...a){let i=this.tokens[this.pos]?.type;return i===t||r!==void 0&&i===r||s!==void 0&&i===s||n!==void 0&&i===n?!0:a.length>0?a.includes(i):!1}expect(t,r){if(this.check(t))return this.advance();let s=this.current();throw new G(r||`Expected ${t}, got ${s.type}`,s.line,s.column,s)}error(t){let r=this.current();throw new G(t,r.line,r.column,r)}skipNewlines(){for(;this.check(p.NEWLINE,p.COMMENT);)this.check(p.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(p.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(p.SEMICOLON,p.COMMENT)){this.advance();continue}if(t&&this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,r,s,n){this.pendingHeredocs.push({redirect:t,delimiter:r,stripTabs:s,quoted:n})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(p.HEREDOC_CONTENT)){let r=this.advance(),s;t.quoted?s=w.word([w.literal(r.value)]):s=this.parseWordFromString(r.value,!1,!1,!1,!0),t.redirect.target=w.hereDoc(t.delimiter,s,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(p.EOF,p.NEWLINE,p.SEMICOLON,p.AMP,p.AND_AND,p.OR_OR,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.ASSIGNMENT_WORD||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.LPAREN||t===p.LBRACE||t===p.DPAREN_START||t===p.DBRACK_START||t===p.FUNCTION||t===p.BANG||t===p.TIME||t===p.IN||t===p.LESS||t===p.GREAT||t===p.DLESS||t===p.DGREAT||t===p.LESSAND||t===p.GREATAND||t===p.LESSGREAT||t===p.DLESSDASH||t===p.CLOBBER||t===p.TLESS||t===p.AND_GREAT||t===p.AND_DGREAT}parseScript(){let t=[],s=0;for(this.skipNewlines();!this.check(p.EOF);){s++,s>1e4&&this.error(\"Parser stuck: too many iterations (>10000)\");let n=this.checkUnexpectedToken();if(n){t.push(n),this.skipSeparators(!1);continue}let a=this.pos,i=this.parseStatement();i&&t.push(i),this.skipSeparators(!1),this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \\`${this.current().value}'`),this.pos===a&&!this.check(p.EOF)&&this.advance()}return w.script(t)}checkUnexpectedToken(){let t=this.current().type,r=this.current().value;if((t===p.DO||t===p.DONE||t===p.THEN||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.ESAC)&&this.error(`syntax error near unexpected token \\`${r}'`),t===p.RBRACE||t===p.RPAREN){let s=`syntax error near unexpected token \\`${r}'`;return this.advance(),w.statement([w.pipeline([w.simpleCommand(null,[],[],[])])],[],!1,{message:s,token:r})}return(t===p.DSEMI||t===p.SEMI_AND||t===p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \\`${r}'`),t===p.SEMICOLON&&this.error(`syntax error near unexpected token \\`${r}'`),(t===p.PIPE||t===p.PIPE_AMP)&&this.error(`syntax error near unexpected token \\`${r}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,r=[],s=[],n=!1,a=this.parsePipeline();for(r.push(a);this.check(p.AND_AND,p.OR_OR);){let o=this.advance();s.push(o.type===p.AND_AND?\"&&\":\"||\"),this.skipNewlines();let c=this.parsePipeline();r.push(c)}this.check(p.AMP)&&(this.advance(),n=!0);let i=this.pos>0?this.tokens[this.pos-1].end:t,l=this._input.slice(t,i);return w.statement(r,s,n,void 0,l)}parsePipeline(){let t=!1,r=!1;this.check(p.TIME)&&(this.advance(),t=!0,this.check(p.WORD,p.NAME)&&this.current().value===\"-p\"&&(this.advance(),r=!0));let s=0;for(;this.check(p.BANG);)this.advance(),s++;let n=s%2===1,a=[],i=[],l=this.parseCommand();for(a.push(l);this.check(p.PIPE,p.PIPE_AMP);){let o=this.advance();this.skipNewlines(),i.push(o.type===p.PIPE_AMP);let c=this.parseCommand();a.push(c)}return w.pipeline(a,n,t,r,i.length>0?i:void 0)}parseCommand(){return this.check(p.IF)?Je(this):this.check(p.FOR)?Ye(this):this.check(p.WHILE)?et(this):this.check(p.UNTIL)?tt(this):this.check(p.CASE)?nt(this):this.check(p.LPAREN)?rt(this):this.check(p.LBRACE)?st(this):this.check(p.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(p.DBRACK_START)?this.parseConditionalCommand():this.check(p.FUNCTION)?this.parseFunctionDef():this.check(p.NAME,p.WORD)&&this.peek(1).type===p.LPAREN&&this.peek(2).type===p.RPAREN?this.parseFunctionDef():rn(this)}dparenClosesWithSpacedParens(){let t=1,r=1;for(;r<this.tokens.length-this.pos;){let s=this.peek(r);if(s.type===p.EOF)return!1;if(s.type===p.DPAREN_START||s.type===p.LPAREN)t++;else if(s.type===p.DPAREN_END){if(t-=2,t<=0)return!1}else if(s.type===p.RPAREN&&(t--,t===0&&this.peek(r+1).type===p.RPAREN))return!0;r++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(p.RPAREN),this.expect(p.RPAREN);let r=this.parseOptionalRedirections(),s=w.subshell(t,[]);return w.subshell([w.statement([w.pipeline([s],!1,!1,!1)])],r)}isWord(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.FUNCTION||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.THEN||t===p.DO||t===p.DONE||t===p.ESAC||t===p.IN||t===p.SELECT||t===p.TIME||t===p.COPROC||t===p.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,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1){let o=ae(this,t,r,s,n,a,!1,i,l);return w.word(o)}parseCommandSubstitution(t,r){return cn(t,r,()=>new e,s=>this.error(s))}parseBacktickSubstitution(t,r,s=!1){return fn(t,r,s,()=>new e,n=>this.error(n))}isDollarDparenSubshell(t,r){return un(t,r)}parseArithmeticExpansion(t,r){let s=r+3,n=1,a=0,i=s;for(;i<t.length-1&&n>0;)t[i]===\"$\"&&t[i+1]===\"(\"?t[i+2]===\"(\"?(n++,i+=3):(a++,i+=2):t[i]===\"(\"&&t[i+1]===\"(\"?(n++,i+=2):t[i]===\")\"&&t[i+1]===\")\"?a>0?(a--,i++):(n--,n>0&&(i+=2)):t[i]===\"(\"?(a++,i++):(t[i]===\")\"&&a>0&&a--,i++);let l=t.slice(s,i),o=this.parseArithmeticExpression(l);return{part:w.arithmeticExpansion(o),endIndex:i+2}}parseArithmeticCommand(){let t=this.expect(p.DPAREN_START),r=\"\",s=1,n=0,a=!1,i=!1;for(;s>0&&!this.check(p.EOF);){if(a){if(a=!1,n>0){n--,r+=\")\";continue}if(this.check(p.RPAREN)){s--,i=!0,this.advance();continue}if(this.check(p.DPAREN_END)){s--,i=!0;continue}r+=\")\";continue}if(this.check(p.DPAREN_START))s++,r+=\"((\",this.advance();else if(this.check(p.DPAREN_END))n>=2?(n-=2,r+=\"))\",this.advance()):n===1?(n--,r+=\")\",a=!0,this.advance()):(s--,i=!0,s>0&&(r+=\"))\"),this.advance());else if(this.check(p.LPAREN))n++,r+=\"(\",this.advance();else if(this.check(p.RPAREN))n>0&&n--,r+=\")\",this.advance();else{let c=this.current().value,u=r.length>0?r[r.length-1]:\"\";r.length>0&&!r.endsWith(\" \")&&!(c===\"=\"&&/[|&^+\\-*/%<>]$/.test(r))&&!(c===\"<\"&&u===\"<\")&&!(c===\">\"&&u===\">\")&&(r+=\" \"),r+=c,this.advance()}}i||this.expect(p.DPAREN_END);let l=this.parseArithmeticExpression(r.trim()),o=this.parseOptionalRedirections();return w.arithmeticCommand(l,o,t.line)}parseConditionalCommand(){let t=this.expect(p.DBRACK_START),r=at(this);this.expect(p.DBRACK_END);let s=this.parseOptionalRedirections();return w.conditionalCommand(r,s,t.line)}parseFunctionDef(){let t;if(this.check(p.FUNCTION)){if(this.advance(),this.check(p.NAME)||this.check(p.WORD))t=this.advance().value;else{let n=this.current();throw new G(\"Expected function name\",n.line,n.column,n)}this.check(p.LPAREN)&&(this.advance(),this.expect(p.RPAREN))}else t=this.advance().value,t.includes(\"$\")&&this.error(`\\`${t}': not a valid identifier`),this.expect(p.LPAREN),this.expect(p.RPAREN);this.skipNewlines();let r=this.parseCompoundCommandBody({forFunctionBody:!0}),s=this.parseOptionalRedirections();return w.functionDef(t,r,s)}parseCompoundCommandBody(t){let r=t?.forFunctionBody;if(this.check(p.LBRACE))return st(this,{skipRedirections:r});if(this.check(p.LPAREN))return rt(this,{skipRedirections:r});if(this.check(p.IF))return Je(this,{skipRedirections:r});if(this.check(p.FOR))return Ye(this,{skipRedirections:r});if(this.check(p.WHILE))return et(this,{skipRedirections:r});if(this.check(p.UNTIL))return tt(this,{skipRedirections:r});if(this.check(p.CASE))return nt(this,{skipRedirections:r});this.error(\"Expected compound command for function body\")}parseCompoundList(){let t=this.enterDepth(),r=[];for(this.skipNewlines();!this.check(p.EOF,p.FI,p.ELSE,p.ELIF,p.THEN,p.DO,p.DONE,p.ESAC,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let s=this.pos,n=this.parseStatement();if(n&&r.push(n),this.skipSeparators(),this.pos===s&&!n)break}return t(),r}parseOptionalRedirections(){let t=[];for(;De(this);){this.checkIterationLimit();let r=this.pos;if(t.push(xe(this)),this.pos===r)break}return t}parseArithmeticExpression(t){return M(this,t)}};function di(e,t){return new V().parse(e,t)}var Yr=new Map([[\"alnum\",\"a-zA-Z0-9\"],[\"alpha\",\"a-zA-Z\"],[\"ascii\",\"\\\\x00-\\\\x7F\"],[\"blank\",\" \\\\t\"],[\"cntrl\",\"\\\\x00-\\\\x1F\\\\x7F\"],[\"digit\",\"0-9\"],[\"graph\",\"!-~\"],[\"lower\",\"a-z\"],[\"print\",\" -~\"],[\"punct\",\"!-/:-@\\\\[-`{-~\"],[\"space\",\" \\\\t\\\\n\\\\r\\\\f\\\\v\"],[\"upper\",\"A-Z\"],[\"word\",\"a-zA-Z0-9_\"],[\"xdigit\",\"0-9a-fA-F\"]]);function ut(e){return Yr.get(e)??\"\"}function hn(e){let t=[],r=\"\",s=0;for(;s<e.length;){let n=e[s];if(n===\"[\"){for(r+=n,s++,s<e.length&&(e[s]===\"!\"||e[s]===\"^\")&&(r+=e[s],s++),s<e.length&&e[s]===\"]\"&&(r+=e[s],s++);s<e.length&&e[s]!==\"]\";){if(e[s]===\"[\"&&s+1<e.length&&e[s+1]===\":\"){let a=e.indexOf(\":]\",s+2);if(a!==-1){r+=e.slice(s,a+2),s=a+2;continue}}if(e[s]===\"\\\\\"&&s+1<e.length){r+=e[s]+e[s+1],s+=2;continue}r+=e[s],s++}s<e.length&&e[s]===\"]\"&&(r+=e[s],s++)}else n===\":\"?(r!==\"\"&&t.push(r),r=\"\",s++):n===\"\\\\\"&&s+1<e.length?(r+=n+e[s+1],s+=2):(r+=n,s++)}return r!==\"\"&&t.push(r),t}function pn(e){let t=\"^\";for(let r=0;r<e.length;r++){let s=e[r];if(s===\"*\")t+=\"[^/]*\";else if(s===\"?\")t+=\"[^/]\";else if(s===\"[\"){let n=r+1,a=\"[\";n<e.length&&(e[n]===\"^\"||e[n]===\"!\")&&(a+=\"^\",n++),n<e.length&&e[n]===\"]\"&&(a+=\"\\\\]\",n++);let i=n;for(;i<e.length;){if(e[i]===\"\\\\\"&&i+1<e.length){i+=2;continue}if(e[i]===\"[\"&&i+1<e.length&&e[i+1]===\":\"){let o=e.indexOf(\":]\",i+2);if(o!==-1){i=o+2;continue}}if(e[i]===\"]\")break;i++}let l=n;for(;n<e.length&&e[n]!==\"]\";){if(e[n]===\"[\"&&n+1<e.length&&e[n+1]===\":\"){let o=e.indexOf(\":]\",n+2);if(o!==-1){let c=e.slice(n+2,o),u=ut(c);a+=u,n=o+2;continue}}if(e[n]===\"\\\\\"&&n+1<e.length){a+=`\\\\${e[n+1]}`,n+=2;continue}if(e[n]===\"-\"){let o=n===l,c=n+1===i;o||c?a+=\"\\\\-\":a+=\"-\"}else a+=e[n];n++}a+=\"]\",t+=a,r=n}else if(s===\"\\\\\"&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\\\*?[\\]]/.test(n)?t+=`\\\\${n}`:t+=n,r++}else/[.+^${}()|]/.test(s)?t+=`\\\\${s}`:t+=s}return t+=\"$\",O(t)}function ct(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n===\"\\\\\"){s+=2;continue}if(n===\"(\")r++;else if(n===\")\"&&(r--,r===0))return s;s++}return-1}function ft(e){let t=[],r=\"\",s=0,n=!1,a=0;for(;a<e.length;){let i=e[a];if(i===\"'\"&&!n){n=!0,r+=\"\\0QUOTE_START\\0\",a++;continue}if(i===\"'\"&&n){n=!1,r+=\"\\0QUOTE_END\\0\",a++;continue}if(n){r+=i,a++;continue}if(i===\"\\\\\"){r+=i,a+1<e.length?(r+=e[a+1],a+=2):a++;continue}i===\"(\"?(s++,r+=i):i===\")\"?(s--,r+=i):i===\"|\"&&s===0?(t.push(r),r=\"\"):r+=i,a++}return t.push(r),t}var dn=5,oe=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(t,r,s,n){this.fs=t,this.cwd=r,typeof n==\"boolean\"?(this.globstar=n,this.maxOps=1e5):n?(this.globstar=n.globstar??!1,this.nullglob=n.nullglob??!1,this.failglob=n.failglob??!1,this.dotglob=n.dotglob??!1,this.extglob=n.extglob??!1,this.globskipdots=n.globskipdots??!0,this.maxOps=n.maxGlobOperations??1e5):this.maxOps=1e5;let a=s?.get(\"GLOBIGNORE\");a!==void 0&&a!==\"\"&&(this.hasGlobignore=!0,this.globignorePatterns=hn(a))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new L(`Glob operation limit exceeded (${this.maxOps})`,\"glob_operations\")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(r=>{let s=r.split(\"/\").pop()||r;if((this.hasGlobignore||this.globskipdots)&&(s===\".\"||s===\"..\"))return!1;if(this.hasGlobignore){for(let n of this.globignorePatterns)if(this.matchGlobignorePattern(r,n))return!1}return!0})}matchGlobignorePattern(t,r){return pn(r).test(t)}isGlobPattern(t){return!!(t.includes(\"*\")||t.includes(\"?\")||/\\[.*\\]/.test(t)||this.extglob&&/[@*+?!]\\(/.test(t))}async expandArgs(t,r){let s=t.map((i,l)=>(r?.[l]??!1)||!this.isGlobPattern(i)?null:this.expand(i)),n=await Promise.all(s.map(i=>i||Promise.resolve(null))),a=[];for(let i=0;i<t.length;i++){let l=n[i];l===null?a.push(t[i]):l.length>0?a.push(...l):a.push(t[i])}return a}async expand(t){if(this.globstar){let s=t.split(\"/\"),n=0;for(let a of s)if(a===\"**\"&&(n++,n>dn))throw new L(`Glob pattern has too many ** segments (max ${dn})`,\"glob_operations\")}let r;if(t.includes(\"**\")&&this.globstar&&this.isGlobstarValid(t))r=await this.expandRecursive(t);else{let s=t.replace(/\\*\\*+/g,\"*\");r=await this.expandSimple(s)}return this.filterGlobignore(r)}isGlobstarValid(t){let r=t.split(\"/\");for(let s of r)if(s.includes(\"**\")&&s!==\"**\")return!1;return!0}hasGlobChars(t){return!!(t.includes(\"*\")||t.includes(\"?\")||/\\[.*\\]/.test(t)||this.extglob&&/[@*+?!]\\(/.test(t))}async expandSimple(t){let r=t.startsWith(\"/\"),s=t.split(\"/\").filter(c=>c!==\"\"),n=-1;for(let c=0;c<s.length;c++)if(this.hasGlobChars(s[c])){n=c;break}if(n===-1)return[t];let a,i;if(n===0)r?(a=\"/\",i=\"/\"):(a=this.cwd,i=\"\");else{let c=s.slice(0,n);r?(a=`/${c.join(\"/\")}`,i=`/${c.join(\"/\")}`):(a=this.fs.resolvePath(this.cwd,c.join(\"/\")),i=c.join(\"/\"))}let l=s.slice(n);return(await this.expandSegments(a,i,l)).sort()}async expandSegments(t,r,s){if(this.checkOpsLimit(),s.length===0)return[r];let[n,...a]=s,i=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let l=await this.fs.readdirWithFileTypes(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;if(n.startsWith(\".\")||this.dotglob){let h=l.some(m=>m.name===\".\"),d=l.some(m=>m.name===\"..\");h||c.push({name:\".\",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:\"..\",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(\".\")&&!n.startsWith(\".\")&&!u)&&this.matchPattern(h.name,n)){let d=t===\"/\"?`/${h.name}`:`${t}/${h.name}`,m;r===\"\"?m=h.name:r===\"/\"?m=`/${h.name}`:m=`${r}/${h.name}`,a.length===0?o.push(Promise.resolve([m])):h.isDirectory&&o.push(this.expandSegments(d,m,a))}let f=await Promise.all(o);for(let h of f)i.push(...h)}else{this.checkOpsLimit();let l=await this.fs.readdir(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;(n.startsWith(\".\")||this.dotglob)&&(l.includes(\".\")||c.push(\".\"),l.includes(\"..\")||c.push(\"..\"));for(let h of c)if(!(h.startsWith(\".\")&&!n.startsWith(\".\")&&!u)&&this.matchPattern(h,n)){let d=t===\"/\"?`/${h}`:`${t}/${h}`,m;r===\"\"?m=h:r===\"/\"?m=`/${h}`:m=`${r}/${h}`,a.length===0?o.push(Promise.resolve([m])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,m,a)}catch(g){if(g instanceof L)throw g}return[]})())}let f=await Promise.all(o);for(let h of f)i.push(...h)}}catch(l){if(l instanceof L)throw l}return i}async expandRecursive(t){let r=[],s=t.indexOf(\"**\"),n=t.slice(0,s).replace(/\\/$/,\"\")||\".\",i=t.slice(s+2).replace(/^\\//,\"\");return i.includes(\"**\")&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(n,i,r),[...new Set(r)].sort()):(await this.walkDirectory(n,i,r),r.sort())}async walkDirectoryMultiGlobstar(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{this.checkOpsLimit();let a=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(n):null;if(a){let i=[];for(let c of a){let u=t===\".\"?c.name:`${t}/${c.name}`;c.isDirectory&&i.push(u)}let l=t===\".\"?r:`${t}/${r}`,o=await this.expandRecursive(l);s.push(...o);for(let c=0;c<i.length;c+=100){let u=i.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,r,s)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(n),l=[];for(let u of i){let f=t===\".\"?u:`${t}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&l.push(f)}catch(d){if(d instanceof L)throw d}}let o=t===\".\"?r:`${t}/${r}`,c=await this.expandRecursive(o);s.push(...c);for(let u=0;u<l.length;u+=100){let f=l.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,r,s)))}}}catch(a){if(a instanceof L)throw a}}async walkDirectory(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(n),i=[],l=[];for(let o of a){let c=t===\".\"?o.name:`${t}/${o.name}`;o.isDirectory?l.push(c):r&&this.matchPattern(o.name,r)&&i.push(c)}s.push(...i);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u,r,s)))}}else{this.checkOpsLimit();let a=await this.fs.readdir(n),i=[];for(let o=0;o<a.length;o+=100){let c=a.slice(o,o+100),u=await Promise.all(c.map(async f=>{let h=t===\".\"?f:`${t}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let m=await this.fs.stat(d);return{name:f,path:h,isDirectory:m.isDirectory}}catch(m){if(m instanceof L)throw m;return null}}));i.push(...u.filter(f=>f!==null))}for(let o of i)!o.isDirectory&&r&&this.matchPattern(o.name,r)&&s.push(o.path);let l=i.filter(o=>o.isDirectory);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,r,s)))}}}catch(a){if(a instanceof L)throw a}}matchPattern(t,r){return this.patternToRegex(r).test(t)}patternToRegex(t){let r=this.patternToRegexStr(t);return O(`^${r}$`)}patternToRegexStr(t){let r=\"\",s=!1;for(let n=0;n<t.length;n++){if(t.slice(n,n+13)===\"\\0QUOTE_START\\0\"){s=!0,n+=12;continue}if(t.slice(n,n+11)===\"\\0QUOTE_END\\0\"){s=!1,n+=10;continue}let a=t[n];if(s){/[.+^${}()|\\\\*?[\\]]/.test(a)?r+=`\\\\${a}`:r+=a;continue}if(this.extglob&&(a===\"@\"||a===\"*\"||a===\"+\"||a===\"?\"||a===\"!\")&&n+1<t.length&&t[n+1]===\"(\"){let i=ct(t,n+1);if(i!==-1){let l=t.slice(n+2,i),o=ft(l),c=o.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join(\"|\"):\"(?:)\";if(a===\"@\")r+=`(?:${u})`;else if(a===\"*\")r+=`(?:${u})*`;else if(a===\"+\")r+=`(?:${u})+`;else if(a===\"?\")r+=`(?:${u})?`;else if(a===\"!\")if(i<t.length-1){let h=o.map(m=>this.computePatternLength(m));if(h.every(m=>m!==null)&&h.every(m=>m===h[0])&&h[0]!==null){let m=h[0];if(m===0)r+=\"(?:.+)\";else{let g=[];m>0&&g.push(`.{0,${m-1}}`),g.push(`.{${m+1},}`),g.push(`(?!(?:${u})).{${m}}`),r+=`(?:${g.join(\"|\")})`}}else r+=`(?:(?!(?:${u})).)*?`}else r+=`(?!(?:${u})$).*`;n=i;continue}}if(a===\"*\")r+=\".*\";else if(a===\"?\")r+=\".\";else if(a===\"[\"){let i=n+1,l=\"[\";i<t.length&&(t[i]===\"^\"||t[i]===\"!\")&&(l+=\"^\",i++),i<t.length&&t[i]===\"]\"&&(l+=\"\\\\]\",i++);let o=i;for(;o<t.length;){if(t[o]===\"\\\\\"&&o+1<t.length){o+=2;continue}if(t[o]===\"[\"&&o+1<t.length&&t[o+1]===\":\"){let u=t.indexOf(\":]\",o+2);if(u!==-1){o=u+2;continue}}if(t[o]===\"]\")break;o++}let c=i;for(;i<t.length&&t[i]!==\"]\";){if(t[i]===\"[\"&&i+1<t.length&&t[i+1]===\":\"){let u=t.indexOf(\":]\",i+2);if(u!==-1){let f=t.slice(i+2,u),h=ut(f);l+=h,i=u+2;continue}}if(t[i]===\"\\\\\"&&i+1<t.length){l+=`\\\\${t[i+1]}`,i+=2;continue}if(t[i]===\"-\"){let u=i===c,f=i+1===o;u||f?l+=\"\\\\-\":l+=\"-\"}else l+=t[i];i++}l+=\"]\",r+=l,n=i}else if(a===\"\\\\\"&&n+1<t.length){let i=t[n+1];/[.+^${}()|\\\\*?[\\]]/.test(i)?r+=`\\\\${i}`:r+=i,n++}else/[.+^${}()|]/.test(a)?r+=`\\\\${a}`:r+=a}return r}computePatternLength(t){let r=0,s=0,n=!1;for(;s<t.length;){if(t.slice(s,s+13)===\"\\0QUOTE_START\\0\"){n=!0,s+=13;continue}if(t.slice(s,s+11)===\"\\0QUOTE_END\\0\"){n=!1,s+=11;continue}let a=t[s];if(n){r+=1,s++;continue}if((a===\"@\"||a===\"*\"||a===\"+\"||a===\"?\"||a===\"!\")&&s+1<t.length&&t[s+1]===\"(\"){let i=ct(t,s+1);if(i!==-1){if(a===\"@\"){let l=t.slice(s+2,i),c=ft(l).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){r+=c[0],s=i+1;continue}return null}return null}}if(a===\"*\")return null;if(a===\"?\"){r+=1,s++;continue}if(a===\"[\"){let i=t.indexOf(\"]\",s+1);if(i!==-1){r+=1,s=i+1;continue}r+=1,s++;continue}if(a===\"\\\\\"){r+=1,s+=2;continue}r+=1,s++}return r}};function es(e,t,r){switch(r){case\"+\":return e+t;case\"-\":return e-t;case\"*\":return e*t;case\"/\":if(t===0)throw new C(\"division by 0\");return Math.trunc(e/t);case\"%\":if(t===0)throw new C(\"division by 0\");return e%t;case\"**\":if(t<0)throw new C(\"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 mn(e,t,r){switch(r){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 ts(e,t){switch(t){case\"-\":return-e;case\"+\":return+e;case\"!\":return e===0?1:0;case\"~\":return~e;default:return e}}async function ns(e,t){let r=e.state.env.get(t);if(r!==void 0)return r;let s=e.state.env.get(`${t}_0`);return s!==void 0?s:await v(e,t)}function rs(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\\d+$/.test(e.trim()))return t;let r=e.trim();if(!r)return 0;try{let s=new V,{expr:n,pos:a}=Z(s,r,0);if(a<r.length){let i=r.slice(a).trim().split(/\\s+/)[0];throw new C(`${r}: syntax error in expression (error token is \"${i}\")`)}return n.type===\"ArithNumber\"?n.value:t||0}catch(s){if(s instanceof C)throw s;let n=r.split(/\\s+/).slice(1)[0]||r;throw new C(`${r}: syntax error in expression (error token is \"${n}\")`)}}async function ht(e,t){if(!t)return 0;let r=Number.parseInt(t,10);if(!Number.isNaN(r)&&/^-?\\d+$/.test(t.trim()))return r;let s=t.trim();if(!s)return 0;let n=new V,{expr:a,pos:i}=Z(n,s,0);if(i<s.length){let l=s.slice(i).trim(),o=l.split(/\\s+/)[0]||l;throw new C(`syntax error in expression (error token is \"${o}\")`,\"\",\"\")}return await R(e,a)}async function pt(e,t,r=new Set,s=0){if(s>100)throw new C(\"maximum variable indirection depth exceeded\");if(r.has(t))return 0;r.add(t);let n=await ns(e,t);if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\\d+$/.test(n.trim()))return a;let i=n.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return await pt(e,i,r,s+1);let l=new V,{expr:o,pos:c}=Z(l,i,0);if(c<i.length){let u=i.slice(c).trim(),f=u.split(/\\s+/)[0]||u;throw new C(`${i}: syntax error in expression (error token is \"${f}\")`)}return await R(e,o)}async function _e(e,t){if(t.startsWith(\"#\")){let f=t.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(h){let m=h[1],g=P(e,m);return String(g.length)}let d=e.state.env.get(f)||\"\";return String(d.length)}if(t.startsWith(\"!\")){let f=t.slice(1),h=e.state.env.get(f)||\"\";return e.state.env.get(h)||\"\"}let r=[\":-\",\":=\",\":?\",\":+\",\"-\",\"=\",\"?\",\"+\"],s=-1,n=\"\";for(let f of r){let h=t.indexOf(f);h>0&&(s===-1||h<s)&&(s=h,n=f)}if(s===-1)return await v(e,t);let a=t.slice(0,s),i=t.slice(s+n.length),l=e.state.env.get(a),o=l===void 0,c=l===\"\",u=n.startsWith(\":\");switch(n){case\":-\":case\"-\":return o||u&&c?i:l||\"\";case\":=\":case\"=\":return o||u&&c?(e.state.env.set(a,i),i):l||\"\";case\":+\":case\"+\":return!(o||u&&c)?i:\"\";case\":?\":case\"?\":{if(o||u&&c)throw new Error(i||`${a}: parameter null or not set`);return l||\"\"}default:return l||\"\"}}async function R(e,t,r=!1){switch(t.type){case\"ArithNumber\":if(Number.isNaN(t.value))throw new C(\"value too great for base\");return t.value;case\"ArithVariable\":return await pt(e,t.name);case\"ArithSpecialVar\":{let n=(await v(e,t.name)).trim();if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\\d+$/.test(n))return a;let i=new V,{expr:l}=Z(i,n,0);return await R(e,l)}case\"ArithNested\":return await R(e,t.expression);case\"ArithCommandSubst\":{if(e.execFn){let s=await e.execFn(t.command,{signal:e.state.signal});s.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+s.stderr);let n=s.stdout.trim();return Number.parseInt(n,10)||0}return 0}case\"ArithBracedExpansion\":{let s=await _e(e,t.content);return Number.parseInt(s,10)||0}case\"ArithDynamicBase\":{let s=await _e(e,t.baseExpr),n=Number.parseInt(s,10);if(n<2||n>64)return 0;let a=`${n}#${t.value}`;return ge(a)}case\"ArithDynamicNumber\":{let n=await _e(e,t.prefix)+t.suffix;return ge(n)}case\"ArithArrayElement\":{let s=e.state.associativeArrays?.has(t.array),n=async a=>{let i=e.state.env.get(a);return i!==void 0?await ht(e,i):0};if(t.stringKey!==void 0)return await n(`${t.array}_${t.stringKey}`);if(s&&t.index?.type===\"ArithVariable\"&&!t.index.hasDollarPrefix)return await n(`${t.array}_${t.index.name}`);if(s&&t.index?.type===\"ArithVariable\"&&t.index.hasDollarPrefix){let a=await v(e,t.index.name);return await n(`${t.array}_${a}`)}if(t.index){let a=await R(e,t.index,r);if(a<0){let o=P(e,t.array),c=e.state.currentLine;if(o.length===0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${c}: ${t.array}: bad array subscript\n`,0;let f=Math.max(...o.map(([h])=>typeof h==\"number\"?h:0))+1+a;if(f<0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${c}: ${t.array}: bad array subscript\n`,0;a=f}let i=`${t.array}_${a}`,l=e.state.env.get(i);if(l!==void 0)return ht(e,l);if(a===0){let o=e.state.env.get(t.array);if(o!==void 0)return ht(e,o)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new j(`${t.array}[${a}]`);return 0}return 0}case\"ArithDoubleSubscript\":throw new C(\"double subscript\",\"\",\"\");case\"ArithNumberSubscript\":throw new C(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is \"${t.errorToken}\")`);case\"ArithSyntaxError\":throw new C(t.message,\"\",\"\",!0);case\"ArithSingleQuote\":{if(r)throw new C(`syntax error: operand expected (error token is \"'${t.content}'\")`);return t.value}case\"ArithBinary\":{if(t.operator===\"||\")return await R(e,t.left,r)||await R(e,t.right,r)?1:0;if(t.operator===\"&&\")return await R(e,t.left,r)&&await R(e,t.right,r)?1:0;let s=await R(e,t.left,r),n=await R(e,t.right,r);return es(s,n,t.operator)}case\"ArithUnary\":{let s=await R(e,t.operand,r);if(t.operator===\"++\"||t.operator===\"--\"){if(t.operand.type===\"ArithVariable\"){let n=t.operand.name,a=Number.parseInt(await v(e,n),10)||0,i=t.operator===\"++\"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}if(t.operand.type===\"ArithArrayElement\"){let n=t.operand.array,a=e.state.associativeArrays?.has(n),i;if(t.operand.stringKey!==void 0)i=`${n}_${t.operand.stringKey}`;else if(a&&t.operand.index?.type===\"ArithVariable\"&&!t.operand.index.hasDollarPrefix)i=`${n}_${t.operand.index.name}`;else if(a&&t.operand.index?.type===\"ArithVariable\"&&t.operand.index.hasDollarPrefix){let c=await v(e,t.operand.index.name);i=`${n}_${c}`}else if(t.operand.index){let c=await R(e,t.operand.index,r);i=`${n}_${c}`}else return s;let l=Number.parseInt(e.state.env.get(i)||\"0\",10)||0,o=t.operator===\"++\"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}if(t.operand.type===\"ArithConcat\"){let n=\"\";for(let a of t.operand.parts)n+=await de(e,a,r);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=Number.parseInt(e.state.env.get(n)||\"0\",10)||0,i=t.operator===\"++\"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}}if(t.operand.type===\"ArithDynamicElement\"){let n=\"\";if(t.operand.nameExpr.type===\"ArithConcat\")for(let a of t.operand.nameExpr.parts)n+=await de(e,a,r);else t.operand.nameExpr.type===\"ArithVariable\"&&(n=t.operand.nameExpr.hasDollarPrefix?await v(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=await R(e,t.operand.subscript,r),i=`${n}_${a}`,l=Number.parseInt(e.state.env.get(i)||\"0\",10)||0,o=t.operator===\"++\"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}}return s}return ts(s,t.operator)}case\"ArithTernary\":return await R(e,t.condition,r)?await R(e,t.consequent,r):await R(e,t.alternate,r);case\"ArithAssignment\":{let s=t.variable,n=s;if(t.stringKey!==void 0)n=`${s}_${t.stringKey}`;else if(t.subscript){let o=e.state.associativeArrays?.has(s);if(o&&t.subscript.type===\"ArithVariable\"&&!t.subscript.hasDollarPrefix)n=`${s}_${t.subscript.name}`;else if(o&&t.subscript.type===\"ArithVariable\"&&t.subscript.hasDollarPrefix){let c=await v(e,t.subscript.name);n=`${s}_${c||\"\\\\\"}`}else if(o){let c=await R(e,t.subscript,r);n=`${s}_${c}`}else{let c=await R(e,t.subscript,r);if(c<0){let u=P(e,s);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h==\"number\"?h:0))+1+c)}n=`${s}_${c}`}}let a=Number.parseInt(e.state.env.get(n)||\"0\",10)||0,i=await R(e,t.value,r),l=mn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case\"ArithGroup\":return await R(e,t.expression,r);case\"ArithConcat\":{let s=\"\";for(let n of t.parts)s+=await de(e,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?await pt(e,s):Number.parseInt(s,10)||0}case\"ArithDynamicAssignment\":{let s=\"\";if(t.target.type===\"ArithConcat\")for(let o of t.target.parts)s+=await de(e,o,r);else t.target.type===\"ArithVariable\"&&(s=t.target.hasDollarPrefix?await v(e,t.target.name):t.target.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=s;if(t.subscript){let o=await R(e,t.subscript,r);n=`${s}_${o}`}let a=Number.parseInt(e.state.env.get(n)||\"0\",10)||0,i=await R(e,t.value,r),l=mn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case\"ArithDynamicElement\":{let s=\"\";if(t.nameExpr.type===\"ArithConcat\")for(let l of t.nameExpr.parts)s+=await de(e,l,r);else t.nameExpr.type===\"ArithVariable\"&&(s=t.nameExpr.hasDollarPrefix?await v(e,t.nameExpr.name):t.nameExpr.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=await R(e,t.subscript,r),a=`${s}_${n}`,i=e.state.env.get(a);return i!==void 0?rs(i):0}default:return 0}}async function de(e,t,r=!1){switch(t.type){case\"ArithNumber\":return String(t.value);case\"ArithSingleQuote\":return String(await R(e,t,r));case\"ArithVariable\":return t.hasDollarPrefix?await v(e,t.name):t.name;case\"ArithSpecialVar\":return await v(e,t.name);case\"ArithBracedExpansion\":return await _e(e,t.content);case\"ArithCommandSubst\":return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():\"0\";case\"ArithConcat\":{let s=\"\";for(let n of t.parts)s+=await de(e,n,r);return s}default:return String(await R(e,t,r))}}function dt(e){for(let t=0;t<e.length;t++){if(e[t]===\"\\\\\"){t++;continue}if(e[t]===\"$\"){let r=e[t+1];if(r===\"{\"||r&&/[a-zA-Z_]/.test(r))return!0}}return!1}function ss(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type===\"DefaultValue\"||t.type===\"AssignDefault\"||t.type===\"UseAlternative\"||t.type===\"ErrorIfUnset\")&&(r=t.word?.parts),!r)return!1;for(let s of r)if(s.type===\"DoubleQuoted\"||s.type===\"SingleQuoted\")return!0;return!1}function gn(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type===\"DefaultValue\"||t.type===\"AssignDefault\"||t.type===\"UseAlternative\"||t.type===\"ErrorIfUnset\")&&(r=t.word?.parts),!r||r.length===0)return!1;for(let s of r)if(s.type!==\"DoubleQuoted\"&&s.type!==\"SingleQuoted\")return!1;return!0}function Ae(e){let t=!1,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1;for(let o of e){if((o.type===\"SingleQuoted\"||o.type===\"DoubleQuoted\")&&(t=!0,o.type===\"DoubleQuoted\"))for(let c of o.parts)c.type===\"ParameterExpansion\"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/)&&(!c.operation||c.operation.type===\"PatternRemoval\"||c.operation.type===\"PatternReplacement\")&&(n=!0),(c.operation?.type===\"VarNamePrefix\"||c.operation?.type===\"ArrayKeys\")&&(i=!0),c.operation?.type===\"Indirection\"&&(l=!0));o.type===\"CommandSubstitution\"&&(r=!0),o.type===\"ParameterExpansion\"&&(a=!0,(o.parameter===\"@\"||o.parameter===\"*\")&&(s=!0),ss(o)&&(t=!0),(o.operation?.type===\"VarNamePrefix\"||o.operation?.type===\"ArrayKeys\")&&(i=!0),o.operation?.type===\"Indirection\"&&(l=!0)),o.type===\"Glob\"&&dt(o.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:r,hasArrayVar:s,hasArrayAtExpansion:n,hasParamExpansion:a,hasVarNamePrefixExpansion:i,hasIndirection:l}}var yn=\"5.1.0(1)-release\",xi=\"Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT\";function _i(e){let{pid:t,ppid:r,uid:s,gid:n}=e;return`Name:\tbash\nState:\tR (running)\nPid:\t${t}\nPPid:\t${r}\nUid:\t${s}\t${s}\t${s}\t${s}\nGid:\t${n}\t${n}\t${n}\t${n}\n`}function mt(e,t){let r=`${t}_`,s=[];for(let n of e.state.env.keys())if(n.startsWith(r)){let a=n.slice(r.length),i=Number.parseInt(a,10);!Number.isNaN(i)&&String(i)===a&&s.push(i)}return s.sort((n,a)=>n-a)}function Ci(e,t){let r=`${t}_`;for(let s of e.state.env.keys())s.startsWith(r)&&e.state.env.delete(s)}function gt(e,t){let r=`${t}_`,s=`${t}__length`,n=[];for(let a of e.state.env.keys())if(a!==s&&a.startsWith(r)){let i=a.slice(r.length);if(i.startsWith(\"_length\"))continue;n.push(i)}return n.sort()}function $e(e){return e.startsWith(\"'\")&&e.endsWith(\"'\")||e.startsWith('\"')&&e.endsWith('\"')?e.slice(1,-1):e}function Oi(e){if(e.parts.length<2)return null;let t=e.parts[0],r=e.parts[1];if(t.type!==\"Glob\"||!t.pattern.startsWith(\"[\"))return null;let s,n=r,a=1;if(r.type===\"Literal\"&&r.value.startsWith(\"]\")){let f=r.value.slice(1);if(f.startsWith(\"+=\")||f.startsWith(\"=\"))s=t.pattern.slice(1);else if(f===\"\"){if(e.parts.length<3)return null;let h=e.parts[2];if(h.type!==\"Literal\"||!h.value.startsWith(\"=\")&&!h.value.startsWith(\"+=\"))return null;s=t.pattern.slice(1),n=h,a=2}else return null}else if(t.pattern===\"[\"&&(r.type===\"DoubleQuoted\"||r.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(r.type===\"SingleQuoted\")s=r.value;else{s=\"\";for(let h of r.parts)(h.type===\"Literal\"||h.type===\"Escaped\")&&(s+=h.value)}n=f,a=2}else if(t.pattern.endsWith(\"]\")){if(r.type!==\"Literal\"||!r.value.startsWith(\"=\")&&!r.value.startsWith(\"+=\"))return null;s=t.pattern.slice(1,-1)}else return null;s=$e(s);let i;if(n.type!==\"Literal\")return null;n.value.startsWith(\"]=\")||n.value.startsWith(\"]+=\")?i=n.value.slice(1):i=n.value;let l=i.startsWith(\"+=\");if(!l&&!i.startsWith(\"=\"))return null;let o=[],c=l?2:1,u=i.slice(c);u&&o.push({type:\"Literal\",value:u});for(let f=a+1;f<e.parts.length;f++){let h=e.parts[f];h.type===\"BraceExpansion\"?o.push({type:\"Literal\",value:is(h)}):o.push(h)}return{key:s,valueParts:o,append:l}}function is(e){return`{${e.items.map(r=>{if(r.type===\"Range\"){let s=r.startStr??String(r.start),n=r.endStr??String(r.end),a=`${s}..${n}`;return r.step&&(a+=`..${r.step}`),a}return En(r.word)}).join(\",\")}}`}function En(e){let t=\"\";for(let r of e.parts)switch(r.type){case\"Literal\":t+=r.value;break;case\"Glob\":t+=r.pattern;break;case\"SingleQuoted\":t+=r.value;break;case\"DoubleQuoted\":for(let s of r.parts)(s.type===\"Literal\"||s.type===\"Escaped\")&&(t+=s.value);break;case\"Escaped\":t+=r.value;break;case\"BraceExpansion\":t+=\"{\",t+=r.items.map(s=>s.type===\"Range\"?`${s.startStr}..${s.endStr}${s.step?`..${s.step}`:\"\"}`:En(s.word)).join(\",\"),t+=\"}\";break;case\"TildeExpansion\":t+=\"~\",r.user&&(t+=r.user);break}return t}function T(e){return e.get(\"IFS\")??` \t\n`}function q(e){return e.get(\"IFS\")===\"\"}function Ce(e){let t=T(e);if(t===\"\")return!0;for(let r of t)if(r!==\" \"&&r!==\"\t\"&&r!==`\n`)return!1;return!0}function An(e){let t=!1,r=[];for(let s of e.split(\"\"))s===\"-\"?t=!0:/[\\\\^$.*+?()[\\]{}|]/.test(s)?r.push(`\\\\${s}`):s===\"\t\"?r.push(\"\\\\t\"):s===`\n`?r.push(\"\\\\n\"):r.push(s);return t&&r.push(\"\\\\-\"),r.join(\"\")}function N(e){let t=e.get(\"IFS\");return t===void 0?\" \":t[0]||\"\"}var as=` \t\n`;function os(e){return as.includes(e)}function yt(e){let t=new Set,r=new Set;for(let s of e)os(s)?t.add(s):r.add(s);return{whitespace:t,nonWhitespace:r}}function Wi(e,t,r,s){if(t===\"\")return e===\"\"?{words:[],wordStarts:[]}:{words:[e],wordStarts:[0]};let{whitespace:n,nonWhitespace:a}=yt(t),i=[],l=[],o=0;for(;o<e.length&&n.has(e[o]);)o++;if(o>=e.length)return{words:[],wordStarts:[]};if(a.has(e[o]))for(i.push(\"\"),l.push(o),o++;o<e.length&&n.has(e[o]);)o++;for(;o<e.length&&!(r!==void 0&&i.length>=r);){let c=o;for(l.push(c);o<e.length;){let u=e[o];if(!s&&u===\"\\\\\"){o++,o<e.length&&o++;continue}if(n.has(u)||a.has(u))break;o++}if(i.push(e.substring(c,o)),o>=e.length)break;for(;o<e.length&&n.has(e[o]);)o++;if(o<e.length&&a.has(e[o])){for(o++;o<e.length&&n.has(e[o]);)o++;for(;o<e.length&&a.has(e[o])&&!(r!==void 0&&i.length>=r);)for(i.push(\"\"),l.push(o),o++;o<e.length&&n.has(e[o]);)o++}}return{words:i,wordStarts:l}}function Oe(e,t){if(t===\"\")return{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e===\"\")return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:r,nonWhitespace:s}=yt(t),n=[],a=0,i=!1,l=!1,o=a;for(;a<e.length&&r.has(e[a]);)a++;if(a>o&&(i=!0),a>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(s.has(e[a]))for(n.push(\"\"),a++;a<e.length&&r.has(e[a]);)a++;for(;a<e.length;){let c=a;for(;a<e.length;){let f=e[a];if(r.has(f)||s.has(f))break;a++}if(n.push(e.substring(c,a)),a>=e.length){l=!1;break}let u=a;for(;a<e.length&&r.has(e[a]);)a++;if(a<e.length&&s.has(e[a])){for(a++;a<e.length&&r.has(e[a]);)a++;for(;a<e.length&&s.has(e[a]);)for(n.push(\"\"),a++;a<e.length&&r.has(e[a]);)a++}a>=e.length&&a>u&&(l=!0)}return{words:n,hadLeadingDelimiter:i,hadTrailingDelimiter:l}}function x(e,t){return Oe(e,t).words}function ls(e,t){for(let r of e)if(t.has(r))return!0;return!1}function Ti(e,t,r){if(t===\"\")return e;let{whitespace:s,nonWhitespace:n}=yt(t),a=e.length;for(;a>0&&s.has(e[a-1]);){if(!r&&a>=2){let l=0,o=a-2;for(;o>=0&&e[o]===\"\\\\\";)l++,o--;if(l%2===1)break}a--}let i=e.substring(0,a);if(i.length>=1&&n.has(i[i.length-1])){if(!r&&i.length>=2){let o=0,c=i.length-2;for(;c>=0&&i[c]===\"\\\\\";)o++,c--;if(o%2===1)return i}let l=i.substring(0,i.length-1);if(!ls(l,n))return l}return i}function W(e,t){return e.state.namerefs?.has(t)??!1}function Vi(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function qi(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Bi(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function Sn(e,t){return e.state.invalidNamerefs?.has(t)??!1}function Fi(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function us(e,t){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(r){let n=r[1],a=Array.from(e.state.env.keys()).some(l=>l.startsWith(`${n}_`)&&!l.includes(\"__\")),i=e.state.associativeArrays?.has(n)??!1;return a||i}return Array.from(e.state.env.keys()).some(n=>n.startsWith(`${t}_`)&&!n.includes(\"__\"))?!0:e.state.env.has(t)}function he(e,t,r=100){if(!W(e,t)||Sn(e,t))return t;let s=new Set,n=t;for(;r-- >0;){if(s.has(n))return;if(s.add(n),!W(e,n))return n;let a=e.state.env.get(n);if(a===void 0||a===\"\"||!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(a))return n;n=a}}function Se(e,t){if(W(e,t))return e.state.env.get(t)}function zi(e,t,r,s=100){if(!W(e,t)||Sn(e,t))return t;let n=new Set,a=t;for(;s-- >0;){if(n.has(a))return;if(n.add(a),!W(e,a))return a;let i=e.state.env.get(a);if(i===void 0||i===\"\")return r!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&us(e,r)?a:null:a;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(i))return a;a=i}}function cs(e,t){let r=t.replace(/\\$\\{([a-zA-Z_][a-zA-Z0-9_]*)\\}/g,(s,n)=>e.state.env.get(n)??\"\");return r=r.replace(/\\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(s,n)=>e.state.env.get(n)??\"\"),r}function P(e,t){return t===\"FUNCNAME\"?(e.state.funcNameStack??[]).map((a,i)=>[i,a]):t===\"BASH_LINENO\"?(e.state.callLineStack??[]).map((a,i)=>[i,String(a)]):t===\"BASH_SOURCE\"?(e.state.sourceStack??[]).map((a,i)=>[i,a]):e.state.associativeArrays?.has(t)?gt(e,t).map(a=>[a,e.state.env.get(`${t}_${a}`)??\"\"]):mt(e,t).map(n=>[n,e.state.env.get(`${t}_${n}`)??\"\"])}function be(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)?gt(e,t).length>0:mt(e,t).length>0}async function v(e,t,r=!0,s=!1){switch(t){case\"?\":return String(e.state.lastExitCode);case\"$\":return String(e.state.virtualPid);case\"#\":return e.state.env.get(\"#\")||\"0\";case\"@\":return e.state.env.get(\"@\")||\"\";case\"_\":return e.state.lastArg;case\"-\":{let i=\"\";return i+=\"h\",e.state.options.errexit&&(i+=\"e\"),e.state.options.noglob&&(i+=\"f\"),e.state.options.nounset&&(i+=\"u\"),e.state.options.verbose&&(i+=\"v\"),e.state.options.xtrace&&(i+=\"x\"),i+=\"B\",e.state.options.noclobber&&(i+=\"C\"),i+=\"s\",i}case\"*\":{let i=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);if(i===0)return\"\";let l=[];for(let o=1;o<=i;o++)l.push(e.state.env.get(String(o))||\"\");return l.join(N(e.state.env))}case\"0\":return e.state.env.get(\"0\")||\"bash\";case\"PWD\":return e.state.env.get(\"PWD\")??\"\";case\"OLDPWD\":return e.state.env.get(\"OLDPWD\")??\"\";case\"PPID\":return String(e.state.virtualPpid);case\"UID\":return String(e.state.virtualUid);case\"EUID\":return String(e.state.virtualUid);case\"RANDOM\":return String(Math.floor(Math.random()*32768));case\"SECONDS\":return String(Math.floor((Date.now()-e.state.startTime)/1e3));case\"BASH_VERSION\":return yn;case\"!\":return String(e.state.lastBackgroundPid);case\"BASHPID\":return String(e.state.bashPid);case\"LINENO\":return String(e.state.currentLine);case\"FUNCNAME\":{let i=e.state.funcNameStack?.[0];if(i!==void 0)return i;if(r&&e.state.options.nounset)throw new j(\"FUNCNAME\");return\"\"}case\"BASH_LINENO\":{let i=e.state.callLineStack?.[0];if(i!==void 0)return String(i);if(r&&e.state.options.nounset)throw new j(\"BASH_LINENO\");return\"\"}case\"BASH_SOURCE\":{let i=e.state.sourceStack?.[0];if(i!==void 0)return i;if(r&&e.state.options.nounset)throw new j(\"BASH_SOURCE\");return\"\"}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\\[\\]$/.test(t))throw new re(`\\${${t}}`);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(n){let i=n[1],l=n[2];if(W(e,i)){let f=he(e,i);if(f&&f!==i){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/))return\"\";i=f}}if(l===\"@\"||l===\"*\"){let f=P(e,i);if(f.length>0)return f.map(([,d])=>d).join(\" \");let h=e.state.env.get(i);return h!==void 0?h:\"\"}if(i===\"FUNCNAME\"){let f=Number.parseInt(l,10);return!Number.isNaN(f)&&f>=0?e.state.funcNameStack?.[f]??\"\":\"\"}if(i===\"BASH_LINENO\"){let f=Number.parseInt(l,10);if(!Number.isNaN(f)&&f>=0){let h=e.state.callLineStack?.[f];return h!==void 0?String(h):\"\"}return\"\"}if(i===\"BASH_SOURCE\"){let f=Number.parseInt(l,10);return!Number.isNaN(f)&&f>=0?e.state.sourceStack?.[f]??\"\":\"\"}if(e.state.associativeArrays?.has(i)){let f=$e(l);f=cs(e,f);let h=e.state.env.get(`${i}_${f}`);if(h===void 0&&r&&e.state.options.nounset)throw new j(`${i}[${l}]`);return h||\"\"}let c;if(/^-?\\d+$/.test(l))c=Number.parseInt(l,10);else try{let f=new V,h=M(f,l);c=await R(e,h.expression)}catch{let f=e.state.env.get(l);c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=P(e,i),h=e.state.currentLine;if(f.length===0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${h}: ${i}: bad array subscript\n`,\"\";let m=Math.max(...f.map(([E])=>typeof E==\"number\"?E:0))+1+c;return m<0?(e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${h}: ${i}: bad array subscript\n`,\"\"):e.state.env.get(`${i}_${m}`)||\"\"}let u=e.state.env.get(`${i}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(i);if(f!==void 0)return f}if(r&&e.state.options.nounset)throw new j(`${i}[${c}]`);return\"\"}if(/^[1-9][0-9]*$/.test(t)){let i=e.state.env.get(t);if(i===void 0&&r&&e.state.options.nounset)throw new j(t);return i||\"\"}if(W(e,t)){let i=he(e,t);if(i===void 0)return\"\";if(i!==t)return await v(e,i,r,s);let l=e.state.env.get(t);if((l===void 0||l===\"\")&&r&&e.state.options.nounset)throw new j(t);return l||\"\"}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(i=>i.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(be(e,t)){let i=e.state.env.get(`${t}_0`);return i!==void 0?i:\"\"}if(r&&e.state.options.nounset)throw new j(t);return\"\"}async function te(e,t){if(new Set([\"?\",\"$\",\"#\",\"_\",\"-\",\"0\",\"PPID\",\"UID\",\"EUID\",\"RANDOM\",\"SECONDS\",\"BASH_VERSION\",\"!\",\"BASHPID\",\"LINENO\"]).has(t))return!0;if(t===\"@\"||t===\"*\")return Number.parseInt(e.state.env.get(\"#\")||\"0\",10)>0;if(t===\"PWD\"||t===\"OLDPWD\")return e.state.env.has(t);let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(s){let n=s[1],a=s[2];if(W(e,n)){let o=he(e,n);if(o&&o!==n){if(o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/))return!1;n=o}}if(a===\"@\"||a===\"*\")return P(e,n).length>0?!0:e.state.env.has(n);if(e.state.associativeArrays?.has(n)){let o=$e(a);return e.state.env.has(`${n}_${o}`)}let l;if(/^-?\\d+$/.test(a))l=Number.parseInt(a,10);else try{let o=new V,c=M(o,a);l=await R(e,c.expression)}catch{let o=e.state.env.get(a);l=o?Number.parseInt(o,10):0,Number.isNaN(l)&&(l=0)}if(l<0){let o=P(e,n);if(o.length===0)return!1;let u=Math.max(...o.map(([f])=>typeof f==\"number\"?f:0))+1+l;return u<0?!1:e.state.env.has(`${n}_${u}`)}return e.state.env.has(`${n}_${l}`)}if(W(e,t)){let n=he(e,t);return n===void 0||n===t?e.state.env.has(t):te(e,n)}return!!(e.state.env.has(t)||be(e,t))}async function bn(e,t){let r=\"\",s=0;for(;s<t.length;){if(t[s]===\"$\"){if(t[s+1]===\"{\"){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]===\"{\"?n++:t[a]===\"}\"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(t[s+1]===\"(\"){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]===\"(\"?n++:t[a]===\")\"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(/[a-zA-Z_]/.test(t[s+1]||\"\")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[0-9]/.test(t[s+1]||\"\")){let n=s+1;for(;n<t.length&&/[0-9]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[*@#?\\-!$]/.test(t[s+1]||\"\")){let n=t[s+1],a=await v(e,n);r+=a,s+=2;continue}}if(t[s]==='\"'){for(r+='\"',s++;s<t.length&&t[s]!=='\"';)if(t[s]===\"$\"&&/[a-zA-Z_]/.test(t[s+1]||\"\")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n}else t[s]===\"\\\\\"?(r+=t[s],s++,s<t.length&&(r+=t[s],s++)):(r+=t[s],s++);s<t.length&&(r+='\"',s++);continue}r+=t[s],s++}return r}async function Et(e,t){let r=t,s=t.startsWith('\"')&&t.endsWith('\"'),n=t.startsWith(\"'\")&&t.endsWith(\"'\");if((s||n)&&(r=t.slice(1,-1)),n)return r;let a=\"\",i=0;for(;i<r.length;)if(r[i]===\"$\")if(r[i+1]===\"(\"){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]===\"(\"&&r[o-1]===\"$\"||r[o]===\"(\"?l++:r[o]===\")\"&&l--,o++;let c=r.slice(i+2,o-1);if(e.execFn){let u=await e.execFn(c,{signal:e.state.signal});a+=u.stdout.replace(/\\n+$/,\"\"),u.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+u.stderr)}i=o}else if(r[i+1]===\"{\"){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]===\"{\"?l++:r[o]===\"}\"&&l--,o++;let c=r.slice(i+2,o-1),u=await v(e,c);a+=u,i=o}else if(/[a-zA-Z_]/.test(r[i+1]||\"\")){let l=i+1;for(;l<r.length&&/[a-zA-Z0-9_]/.test(r[l]);)l++;let o=r.slice(i+1,l),c=await v(e,o);a+=c,i=l}else a+=r[i],i++;else if(r[i]===\"`\"){let l=i+1;for(;l<r.length&&r[l]!==\"`\";)l++;let o=r.slice(i+1,l);if(e.execFn){let c=await e.execFn(o,{signal:e.state.signal});a+=c.stdout.replace(/\\n+$/,\"\"),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+c.stderr)}i=l+1}else a+=r[i],i++;return a}var Le=1e4;function fs(e,t,r,s,n){let a=r??1;a===0&&(a=1);let i=Math.abs(a),l=[],o=0;s?.match(/^-?0\\d/)&&(o=Math.max(o,s.replace(/^-/,\"\").length)),n?.match(/^-?0\\d/)&&(o=Math.max(o,n.replace(/^-/,\"\").length));let c=u=>{if(o>0){let f=u<0,h=String(Math.abs(u)).padStart(o,\"0\");return f?`-${h}`:h}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<Le;u+=i,f++)l.push(c(u));else for(let u=e,f=0;u>=t&&f<Le;u-=i,f++)l.push(c(u));return l}function hs(e,t,r){let s=r??1;s===0&&(s=1);let n=e.charCodeAt(0),a=t.charCodeAt(0),i=Math.abs(s),l=e>=\"A\"&&e<=\"Z\",o=e>=\"a\"&&e<=\"z\",c=t>=\"A\"&&t<=\"Z\",u=t>=\"a\"&&t<=\"z\";if(l&&u||o&&c){let h=r!==void 0?`..${r}`:\"\";throw new It(`{${e}..${t}${h}}: invalid sequence`)}let f=[];if(n<=a)for(let h=n,d=0;h<=a&&d<Le;h+=i,d++)f.push(String.fromCharCode(h));else for(let h=n,d=0;h>=a&&d<Le;h-=i,d++)f.push(String.fromCharCode(h));return f}function At(e,t,r,s,n){let a=r!==void 0?`..${r}`:\"\";return typeof e==\"number\"&&typeof t==\"number\"?{expanded:fs(e,t,r,s,n),literal:`{${e}..${t}${a}}`}:typeof e==\"string\"&&typeof t==\"string\"?{expanded:hs(e,t,r),literal:`{${e}..${t}${a}}`}:{expanded:null,literal:`{${e}..${t}${a}}`}}function wn(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 r=t.pipelines[0];if(r.negated||r.commands.length!==1)return null;let s=r.commands[0];if(s.type!==\"SimpleCommand\")return null;let n=s;if(n.name!==null||n.args.length!==0||n.assignments.length!==0||n.redirections.length!==1)return null;let a=n.redirections[0];return a.operator!==\"<\"||a.target.type!==\"Word\"?null:{target:a.target}}function ne(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\\(/.test(e))}function St(e){let t=\"\",r=0;for(;r<e.length;)e[r]===\"\\\\\"&&r+1<e.length?(t+=e[r+1],r+=2):(t+=e[r],r++);return t}function X(e){return e.replace(/([*?[\\]\\\\()|])/g,\"\\\\$1\")}function bt(e){return e.replace(/[\\\\^$.*+?()[\\]{}|]/g,\"\\\\$&\")}function I(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function k(e,t,r=!1){let s=\"\",n=0;for(;n<e.length;){let a=e[n];if(r&&(a===\"@\"||a===\"*\"||a===\"+\"||a===\"?\"||a===\"!\")&&n+1<e.length&&e[n+1]===\"(\"){let i=ps(e,n+1);if(i!==-1){let l=e.slice(n+2,i),c=ds(l).map(f=>k(f,t,r)),u=c.length>0?c.join(\"|\"):\"(?:)\";a===\"@\"?s+=`(?:${u})`:a===\"*\"?s+=`(?:${u})*`:a===\"+\"?s+=`(?:${u})+`:a===\"?\"?s+=`(?:${u})?`:a===\"!\"&&(s+=`(?!(?:${u})$).*`),n=i+1;continue}}if(a===\"\\\\\")if(n+1<e.length){let i=e[n+1];/[\\\\^$.|+(){}[\\]*?]/.test(i)?s+=`\\\\${i}`:s+=i,n+=2}else s+=\"\\\\\\\\\",n++;else if(a===\"*\")s+=t?\".*\":\".*?\",n++;else if(a===\"?\")s+=\".\",n++;else if(a===\"[\"){let i=ms(e,n);if(i===-1)s+=\"\\\\[\",n++;else{let l=e.slice(n+1,i);s+=gs(l),n=i+1}}else/[\\^$.|+(){}]/.test(a)?(s+=`\\\\${a}`,n++):(s+=a,n++)}return s}function ps(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n===\"\\\\\"){s+=2;continue}if(n===\"(\")r++;else if(n===\")\"&&(r--,r===0))return s;s++}return-1}function ds(e){let t=[],r=\"\",s=0,n=0;for(;n<e.length;){let a=e[n];if(a===\"\\\\\"){r+=a,n+1<e.length?(r+=e[n+1],n+=2):n++;continue}a===\"(\"?(s++,r+=a):a===\")\"?(s--,r+=a):a===\"|\"&&s===0?(t.push(r),r=\"\"):r+=a,n++}return t.push(r),t}function ms(e,t){let r=t+1;for(r<e.length&&e[r]===\"^\"&&r++,r<e.length&&e[r]===\"]\"&&r++;r<e.length;){if(e[r]===\"\\\\\"&&r+1<e.length){r+=2;continue}if(e[r]===\"]\")return r;if(e[r]===\"'\"){let s=e.indexOf(\"'\",r+1);if(s!==-1){r=s+1;continue}}if(e[r]===\"[\"&&r+1<e.length&&e[r+1]===\":\"){let s=e.indexOf(\":]\",r+2);if(s!==-1){r=s+2;continue}}r++}return-1}function gs(e){let t=\"[\",r=0;for((e[0]===\"^\"||e[0]===\"!\")&&(t+=\"^\",r++);r<e.length;){if(e[r]===\"'\"){let n=e.indexOf(\"'\",r+1);if(n!==-1){let a=e.slice(r+1,n);for(let i of a)i===\"\\\\\"?t+=\"\\\\\\\\\":i===\"]\"?t+=\"\\\\]\":i===\"^\"&&t===\"[\"?t+=\"\\\\^\":t+=i;r=n+1;continue}}if(e[r]===\"[\"&&r+1<e.length&&e[r+1]===\":\"){let n=e.indexOf(\":]\",r+2);if(n!==-1){let a=e.slice(r+2,n);t+=Es(a),r=n+2;continue}}let s=e[r];s===\"\\\\\"?r+1<e.length?(t+=`\\\\${e[r+1]}`,r+=2):(t+=\"\\\\\\\\\",r++):s===\"-\"&&r>0&&r<e.length-1?(t+=\"-\",r++):s===\"^\"&&r===0?(t+=\"^\",r++):(s===\"]\"&&r===0?t+=\"\\\\]\":t+=s,r++)}return t+=\"]\",t}var ys=new Map([[\"alnum\",\"a-zA-Z0-9\"],[\"alpha\",\"a-zA-Z\"],[\"ascii\",\"\\\\x00-\\\\x7F\"],[\"blank\",\" \\\\t\"],[\"cntrl\",\"\\\\x00-\\\\x1F\\\\x7F\"],[\"digit\",\"0-9\"],[\"graph\",\"!-~\"],[\"lower\",\"a-z\"],[\"print\",\" -~\"],[\"punct\",\"!-/:-@\\\\[-`{-~\"],[\"space\",\" \\\\t\\\\n\\\\r\\\\f\\\\v\"],[\"upper\",\"A-Z\"],[\"word\",\"a-zA-Z0-9_\"],[\"xdigit\",\"0-9A-Fa-f\"]]);function Es(e){return ys.get(e)??\"\"}function se(e,t,r,s){if(r===\"prefix\")return O(`^${t}`,\"s\").replace(e,\"\");let n=O(`${t}$`,\"s\");if(s)return n.replace(e,\"\");for(let a=e.length;a>=0;a--){let i=e.slice(a);if(n.test(i))return e.slice(0,a)}return e}function me(e,t){let r=Array.from(e.state.env.keys()),s=new Set,n=e.state.associativeArrays??new Set,a=new Set;for(let l of r){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\\d+$/);o&&a.add(o[1]);let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&a.add(c[1])}let i=l=>{for(let o of n){let c=`${o}_`;if(l.startsWith(c)&&l!==o)return!0}return!1};for(let l of r)if(l.startsWith(t))if(l.includes(\"__\")){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);o?.[1].startsWith(t)&&s.add(o[1])}else if(/_\\d+$/.test(l)){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\\d+$/);o?.[1].startsWith(t)&&s.add(o[1])}else i(l)||s.add(l);return[...s].sort()}function As(e,t){let r=(a,i=2)=>String(a).padStart(i,\"0\");if(e===\"\"){let a=r(t.getHours()),i=r(t.getMinutes()),l=r(t.getSeconds());return`${a}:${i}:${l}`}let s=\"\",n=0;for(;n<e.length;)if(e[n]===\"%\"){if(n+1>=e.length){s+=\"%\",n++;continue}let a=e[n+1];switch(a){case\"H\":s+=r(t.getHours());break;case\"M\":s+=r(t.getMinutes());break;case\"S\":s+=r(t.getSeconds());break;case\"d\":s+=r(t.getDate());break;case\"m\":s+=r(t.getMonth()+1);break;case\"Y\":s+=t.getFullYear();break;case\"y\":s+=r(t.getFullYear()%100);break;case\"I\":{let i=t.getHours()%12;i===0&&(i=12),s+=r(i);break}case\"p\":s+=t.getHours()<12?\"AM\":\"PM\";break;case\"P\":s+=t.getHours()<12?\"am\":\"pm\";break;case\"%\":s+=\"%\";break;case\"a\":{s+=[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"][t.getDay()];break}case\"b\":{s+=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"][t.getMonth()];break}default:s+=`%${a}`}n+=2}else s+=e[n],n++;return s}function we(e,t){let r=\"\",s=0,n=e.state.env.get(\"USER\")||e.state.env.get(\"LOGNAME\")||\"user\",a=e.state.env.get(\"HOSTNAME\")||\"localhost\",i=a.split(\".\")[0],l=e.state.env.get(\"PWD\")||\"/\",o=e.state.env.get(\"HOME\")||\"/\",c=l.startsWith(o)?`~${l.slice(o.length)}`:l,u=l.split(\"/\").pop()||l,f=new Date,h=[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"],d=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],m=e.state.env.get(\"__COMMAND_NUMBER\")||\"1\";for(;s<t.length;){let g=t[s];if(g===\"\\\\\"){if(s+1>=t.length){r+=\"\\\\\",s++;continue}let E=t[s+1];if(E>=\"0\"&&E<=\"7\"){let A=\"\",S=s+1;for(;S<t.length&&S<s+4&&t[S]>=\"0\"&&t[S]<=\"7\";)A+=t[S],S++;let y=Number.parseInt(A,8)%256;r+=String.fromCharCode(y),s=S;continue}switch(E){case\"\\\\\":r+=\"\\\\\",s+=2;break;case\"a\":r+=\"\\x07\",s+=2;break;case\"e\":r+=\"\\x1B\",s+=2;break;case\"n\":r+=`\n`,s+=2;break;case\"r\":r+=\"\\r\",s+=2;break;case\"$\":r+=\"$\",s+=2;break;case\"[\":case\"]\":s+=2;break;case\"u\":r+=n,s+=2;break;case\"h\":r+=i,s+=2;break;case\"H\":r+=a,s+=2;break;case\"w\":r+=c,s+=2;break;case\"W\":r+=u,s+=2;break;case\"d\":{let A=String(f.getDate()).padStart(2,\" \");r+=`${h[f.getDay()]} ${d[f.getMonth()]} ${A}`,s+=2;break}case\"t\":{let A=String(f.getHours()).padStart(2,\"0\"),S=String(f.getMinutes()).padStart(2,\"0\"),y=String(f.getSeconds()).padStart(2,\"0\");r+=`${A}:${S}:${y}`,s+=2;break}case\"T\":{let A=f.getHours()%12;A===0&&(A=12);let S=String(A).padStart(2,\"0\"),y=String(f.getMinutes()).padStart(2,\"0\"),b=String(f.getSeconds()).padStart(2,\"0\");r+=`${S}:${y}:${b}`,s+=2;break}case\"@\":{let A=f.getHours()%12;A===0&&(A=12);let S=String(A).padStart(2,\"0\"),y=String(f.getMinutes()).padStart(2,\"0\"),b=f.getHours()<12?\"AM\":\"PM\";r+=`${S}:${y} ${b}`,s+=2;break}case\"A\":{let A=String(f.getHours()).padStart(2,\"0\"),S=String(f.getMinutes()).padStart(2,\"0\");r+=`${A}:${S}`,s+=2;break}case\"D\":if(s+2<t.length&&t[s+2]===\"{\"){let A=t.indexOf(\"}\",s+3);if(A!==-1){let S=t.slice(s+3,A);r+=As(S,f),s=A+1}else r+=\"\\\\D\",s+=2}else r+=\"\\\\D\",s+=2;break;case\"s\":r+=\"bash\",s+=2;break;case\"v\":r+=\"5.0\",s+=2;break;case\"V\":r+=\"5.0.0\",s+=2;break;case\"j\":r+=\"0\",s+=2;break;case\"l\":r+=\"tty\",s+=2;break;case\"#\":r+=m,s+=2;break;case\"!\":r+=m,s+=2;break;case\"x\":r+=\"\\\\x\",s+=2;break;default:r+=`\\\\${E}`,s+=2}}else r+=g,s++}return r}function le(e){if(e===\"\")return\"''\";if(/[\\n\\r\\t\\x00-\\x1f\\x7f']/.test(e)){let r=\"$'\";for(let s of e)switch(s){case\"'\":r+=\"\\\\'\";break;case\"\\\\\":r+=\"\\\\\\\\\";break;case`\n`:r+=\"\\\\n\";break;case\"\\r\":r+=\"\\\\r\";break;case\"\t\":r+=\"\\\\t\";break;default:{let n=s.charCodeAt(0);n<32||n===127?r+=`\\\\${n.toString(8).padStart(3,\"0\")}`:r+=s}}return`${r}'`}return`'${e}'`}function pa(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function wt(e,t){return e.state.readonlyVars?.has(t)??!1}function da(e,t,r=\"bash\"){if(wt(e,t)){let s=`${r}: ${t}: readonly variable\n`;throw new K(1,\"\",s)}return null}function ma(e,t){let r=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)&&!r){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 ga(e,t){e.state.exportedVars?.delete(t)}function ue(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return\"\";let r=\"\",s=e.state.env.has(`${t}__length`)||Array.from(e.state.env.keys()).some(a=>a.startsWith(`${t}_`)&&/^[0-9]+$/.test(a.slice(t.length+1))),n=e.state.associativeArrays?.has(t)??!1;return s&&!n&&(r+=\"a\"),n&&(r+=\"A\"),e.state.integerVars?.has(t)&&(r+=\"i\"),W(e,t)&&(r+=\"n\"),wt(e,t)&&(r+=\"r\"),e.state.exportedVars?.has(t)&&(r+=\"x\"),r}async function Nn(e,t,r,s){return e.coverage?.hit(\"bash:expansion:default_value\"),(r.isUnset||t.checkEmpty&&r.isEmpty)&&t.word?s(e,t.word.parts,r.inDoubleQuotes):r.effectiveValue}async function kn(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:assign_default\"),(s.isUnset||r.checkEmpty&&s.isEmpty)&&r.word){let i=await n(e,r.word.parts,s.inDoubleQuotes),l=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(l){let[,o,c]=l,u;if(/^\\d+$/.test(c))u=Number.parseInt(c,10);else{try{let h=new V,d=M(h,c);u=await R(e,d.expression)}catch{let h=e.state.env.get(c);u=h?Number.parseInt(h,10):0}Number.isNaN(u)&&(u=0)}e.state.env.set(`${o}_${u}`,i);let f=Number.parseInt(e.state.env.get(`${o}__length`)||\"0\",10);u>=f&&e.state.env.set(`${o}__length`,String(u+1))}else e.state.env.set(t,i);return i}return s.effectiveValue}async function Pn(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:error_if_unset\"),s.isUnset||r.checkEmpty&&s.isEmpty){let i=r.word?await n(e,r.word.parts,s.inDoubleQuotes):`${t}: parameter null or not set`;throw new K(1,\"\",`bash: ${i}\n`)}return s.effectiveValue}async function Rn(e,t,r,s){return e.coverage?.hit(\"bash:expansion:use_alternative\"),!(r.isUnset||t.checkEmpty&&r.isEmpty)&&t.word?s(e,t.word.parts,r.inDoubleQuotes):\"\"}async function In(e,t,r,s,n){e.coverage?.hit(\"bash:expansion:pattern_removal\");let a=\"\",i=e.state.shoptOptions.extglob;if(r.pattern)for(let o of r.pattern.parts)if(o.type===\"Glob\")a+=k(o.pattern,r.greedy,i);else if(o.type===\"Literal\")a+=k(o.value,r.greedy,i);else if(o.type===\"SingleQuoted\"||o.type===\"Escaped\")a+=I(o.value);else if(o.type===\"DoubleQuoted\"){let c=await s(e,o.parts);a+=I(c)}else if(o.type===\"ParameterExpansion\"){let c=await n(e,o);a+=k(c,r.greedy,i)}else{let c=await n(e,o);a+=I(c)}if(r.side===\"prefix\")return O(`^${a}`,\"s\").replace(t,\"\");let l=O(`${a}$`,\"s\");if(r.greedy)return l.replace(t,\"\");for(let o=t.length;o>=0;o--){let c=t.slice(o);if(l.test(c))return t.slice(0,o)}return t}async function vn(e,t,r,s,n){e.coverage?.hit(\"bash:expansion:pattern_replacement\");let a=\"\",i=e.state.shoptOptions.extglob;if(r.pattern)for(let c of r.pattern.parts)if(c.type===\"Glob\")a+=k(c.pattern,!0,i);else if(c.type===\"Literal\")a+=k(c.value,!0,i);else if(c.type===\"SingleQuoted\"||c.type===\"Escaped\")a+=I(c.value);else if(c.type===\"DoubleQuoted\"){let u=await s(e,c.parts);a+=I(u)}else if(c.type===\"ParameterExpansion\"){let u=await n(e,c);a+=k(u,!0,i)}else{let u=await n(e,c);a+=I(u)}let l=r.replacement?await s(e,r.replacement.parts):\"\";if(r.anchor===\"start\"?a=`^${a}`:r.anchor===\"end\"&&(a=`${a}$`),a===\"\")return t;let o=r.all?\"gs\":\"s\";try{let c=O(a,o);if(r.all){let u=\"\",f=0,h=0,d=e.limits.maxStringLength,m=c.exec(t);for(;m!==null&&!(m[0].length===0&&m.index===t.length);){if(u+=t.slice(f,m.index)+l,f=m.index+m[0].length,m[0].length===0&&f++,h++,h%100===0&&u.length>d)throw new L(`pattern replacement: string length limit exceeded (${d} bytes)`,\"string_length\");m=c.exec(t)}return u+=t.slice(f),u}return c.replace(t,l)}catch(c){if(c instanceof L)throw c;return t}}function Dn(e,t,r){e.coverage?.hit(\"bash:expansion:length\");let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(s){let n=s[1],a=P(e,n);return a.length>0?String(a.length):e.state.env.get(n)!==void 0?\"1\":\"0\"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&be(e,t)){if(t===\"FUNCNAME\"){let a=e.state.funcNameStack?.[0]||\"\";return String([...a].length)}if(t===\"BASH_LINENO\"){let a=e.state.callLineStack?.[0];return String(a!==void 0?[...String(a)].length:0)}let n=e.state.env.get(`${t}_0`)||\"\";return String([...n].length)}return String([...r].length)}async function xn(e,t,r,s){e.coverage?.hit(\"bash:expansion:substring\");let n=await R(e,s.offset.expression),a=s.length?await R(e,s.length.expression):void 0;if(t===\"@\"||t===\"*\"){let c=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),u=[];for(let m=1;m<=c;m++)u.push(e.state.env.get(String(m))||\"\");let f=e.state.env.get(\"0\")||\"bash\",h,d;if(n<=0)if(h=[f,...u],n<0){if(d=h.length+n,d<0)return\"\"}else d=0;else h=u,d=n-1;if(d<0||d>=h.length)return\"\";if(a!==void 0){let m=a<0?h.length+a:d+a;return h.slice(d,Math.max(d,m)).join(\" \")}return h.slice(d).join(\" \")}let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(i){let c=i[1];if(e.state.associativeArrays?.has(c))throw new K(1,\"\",`bash: \\${${c}[@]: 0: 3}: bad substitution\n`);let u=P(e,c),f=0;if(n<0){if(u.length>0){let h=u[u.length-1][0],m=(typeof h==\"number\"?h:0)+1+n;if(m<0||(f=u.findIndex(([g])=>typeof g==\"number\"&&g>=m),f<0))return\"\"}}else if(f=u.findIndex(([h])=>typeof h==\"number\"&&h>=n),f<0)return\"\";if(a!==void 0){if(a<0)throw new C(`${i[1]}[@]: substring expression < 0`);return u.slice(f,f+a).map(([,h])=>h).join(\" \")}return u.slice(f).map(([,h])=>h).join(\" \")}let l=[...r],o=n;if(o<0&&(o=Math.max(0,l.length+o)),a!==void 0){if(a<0){let c=l.length+a;return l.slice(o,Math.max(o,c)).join(\"\")}return l.slice(o,o+a).join(\"\")}return l.slice(o).join(\"\")}async function _n(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:case_modification\"),r.pattern){let a=e.state.shoptOptions.extglob,i=\"\";for(let f of r.pattern.parts)if(f.type===\"Glob\")i+=k(f.pattern,!0,a);else if(f.type===\"Literal\")i+=k(f.value,!0,a);else if(f.type===\"SingleQuoted\"||f.type===\"Escaped\")i+=I(f.value);else if(f.type===\"DoubleQuoted\"){let h=await s(e,f.parts);i+=I(h)}else if(f.type===\"ParameterExpansion\"){let h=await n(e,f);i+=k(h,!0,a)}let l=O(`^(?:${i})$`),o=r.direction===\"upper\"?f=>f.toUpperCase():f=>f.toLowerCase(),c=\"\",u=!1;for(let f of t)!r.all&&u?c+=f:l.test(f)?(c+=o(f),u=!0):c+=f;return c}return r.direction===\"upper\"?r.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):r.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function $n(e,t,r,s,n){e.coverage?.hit(\"bash:expansion:transform\");let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(a&&n.operator===\"Q\")return P(e,a[1]).map(([,c])=>le(c)).join(\" \");if(a&&n.operator===\"a\")return ue(e,a[1]);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[.+\\]$/);if(i&&n.operator===\"a\")return ue(e,i[1]);switch(n.operator){case\"Q\":return s?\"\":le(r);case\"P\":return we(e,r);case\"a\":return ue(e,t);case\"A\":return s?\"\":`${t}=${le(r)}`;case\"E\":return r.replace(/\\\\([\\\\abefnrtv'\"?])/g,(l,o)=>{switch(o){case\"\\\\\":return\"\\\\\";case\"a\":return\"\\x07\";case\"b\":return\"\\b\";case\"e\":return\"\\x1B\";case\"f\":return\"\\f\";case\"n\":return`\n`;case\"r\":return\"\\r\";case\"t\":return\"\t\";case\"v\":return\"\\v\";case\"'\":return\"'\";case'\"':return'\"';case\"?\":return\"?\";default:return o}});case\"K\":case\"k\":return s?\"\":le(r);case\"u\":return r.charAt(0).toUpperCase()+r.slice(1);case\"U\":return r.toUpperCase();case\"L\":return r.toLowerCase();default:return r}}async function Cn(e,t,r,s,n,a,i=!1){if(e.coverage?.hit(\"bash:expansion:indirection\"),W(e,t))return Se(e,t)||\"\";let l=/^[a-zA-Z_][a-zA-Z0-9_]*\\[([@*])\\]$/.test(t);if(s){if(n.innerOp?.type===\"UseAlternative\")return\"\";throw new re(`\\${!${t}}`)}let o=r;if(l&&(o===\"\"||o.includes(\" \")))throw new re(`\\${!${t}}`);let c=o.match(/^[a-zA-Z_][a-zA-Z0-9_]*\\[(.+)\\]$/);if(c&&c[1].includes(\"~\"))throw new re(`\\${!${t}}`);if(n.innerOp){let u={type:\"ParameterExpansion\",parameter:o,operation:n.innerOp};return a(e,u,i)}return await v(e,o)}function On(e,t){e.coverage?.hit(\"bash:expansion:array_keys\");let s=P(e,t.array).map(([n])=>String(n));return t.star?s.join(N(e.state.env)):s.join(\" \")}function Ln(e,t){e.coverage?.hit(\"bash:expansion:var_name_prefix\");let r=me(e,t.prefix);return t.star?r.join(N(e.state.env)):r.join(\" \")}function Wn(e,t,r,s){let n=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(t===\"*\")return{isEmpty:n===0,effectiveValue:r};if(t===\"@\")return{isEmpty:n===0||n===1&&e.state.env.get(\"1\")===\"\",effectiveValue:r};if(a){let[,i,l]=a,o=P(e,i);if(o.length===0)return{isEmpty:!0,effectiveValue:\"\"};if(l===\"*\"){let c=N(e.state.env),u=o.map(([,f])=>f).join(c);return{isEmpty:s?u===\"\":!1,effectiveValue:u}}return{isEmpty:o.length===1&&o.every(([,c])=>c===\"\"),effectiveValue:o.map(([,c])=>c).join(\" \")}}return{isEmpty:r===\"\",effectiveValue:r}}function Tn(e){let t=0;for(;t<e.length;){let r=e[t];if(r===\"\\\\\"&&t+1<e.length){t+=2;continue}if(r===\"'\"){let s=e.indexOf(\"'\",t+1);if(s!==-1){t=s+1;continue}}if(r===\"$\"&&t+1<e.length&&e[t+1]===\"(\"||r===\"`\")return!0;t++}return!1}function Mn(e,t){let r=1,s=t,n=!1,a=!1;for(;s<e.length&&r>0;){let i=e[s];if(i===\"\\\\\"&&!n&&s+1<e.length){s+=2;continue}if(i===\"'\"&&!a){n=!n,s++;continue}if(i==='\"'&&!n){a=!a,s++;continue}if(!n&&!a){if(i===\"(\")r++;else if(i===\")\"&&(r--,r===0))return s}s++}return-1}async function We(e,t){let r=new V,s;try{s=r.parse(t)}catch{return\"\"}let n=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let a=new Map(e.state.env),i=e.state.cwd,l=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let o=await e.executeScript(s),c=o.exitCode;return e.state.env=a,e.state.cwd=i,e.state.suppressVerbose=l,e.state.lastExitCode=c,e.state.env.set(\"?\",String(c)),o.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+o.stderr),e.state.bashPid=n,o.stdout.replace(/\\n+$/,\"\")}catch(o){if(e.state.env=a,e.state.cwd=i,e.state.bashPid=n,e.state.suppressVerbose=l,o instanceof L)throw o;return o instanceof K?(e.state.lastExitCode=o.exitCode,e.state.env.set(\"?\",String(o.exitCode)),o.stdout?.replace(/\\n+$/,\"\")??\"\"):\"\"}}function Nt(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"'\"){let a=t.indexOf(\"'\",s+1);if(a!==-1){let i=t.slice(s+1,a);r+=X(i),s=a+1;continue}}if(n==='\"'){let a=-1,i=s+1;for(;i<t.length;){if(t[i]===\"\\\\\"){i+=2;continue}if(t[i]==='\"'){a=i;break}i++}if(a!==-1){let l=t.slice(s+1,a),o=Ss(e,l);r+=X(o),s=a+1;continue}}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}if(n===\"\\\\\"&&s+1<t.length){r+=n+t[s+1],s+=2;continue}r+=n,s++}return r}function Ss(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"\\\\\"&&s+1<t.length){let a=t[s+1];if(a===\"$\"||a===\"`\"||a===\"\\\\\"||a==='\"'){r+=a,s+=2;continue}r+=n,s++;continue}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}r+=n,s++}return r}async function Vn(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"'\"){let a=t.indexOf(\"'\",s+1);if(a!==-1){let i=t.slice(s+1,a);r+=X(i),s=a+1;continue}}if(n==='\"'){let a=-1,i=s+1;for(;i<t.length;){if(t[i]===\"\\\\\"){i+=2;continue}if(t[i]==='\"'){a=i;break}i++}if(a!==-1){let l=t.slice(s+1,a),o=await bs(e,l);r+=X(o),s=a+1;continue}}if(n===\"$\"&&s+1<t.length&&t[s+1]===\"(\"){let a=Mn(t,s+2);if(a!==-1){let i=t.slice(s+2,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"`\"){let a=t.indexOf(\"`\",s+1);if(a!==-1){let i=t.slice(s+1,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}if(n===\"\\\\\"&&s+1<t.length){r+=n+t[s+1],s+=2;continue}r+=n,s++}return r}async function bs(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"\\\\\"&&s+1<t.length){let a=t[s+1];if(a===\"$\"||a===\"`\"||a===\"\\\\\"||a==='\"'){r+=a,s+=2;continue}r+=n,s++;continue}if(n===\"$\"&&s+1<t.length&&t[s+1]===\"(\"){let a=Mn(t,s+2);if(a!==-1){let i=t.slice(s+2,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"`\"){let a=t.indexOf(\"`\",s+1);if(a!==-1){let i=t.slice(s+1,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}r+=n,s++}return r}function qn(e,t){if(!t.startsWith(\"~\"))return t;e.coverage?.hit(\"bash:expansion:tilde\");let r=e.state.env.get(\"HOME\")!==void 0?e.state.env.get(\"HOME\"):\"/home/user\";if(t===\"~\"||t.startsWith(\"~/\"))return r+t.slice(1);let s=1;for(;s<t.length&&/[a-zA-Z0-9_-]/.test(t[s]);)s++;let n=t.slice(1,s),a=t.slice(s);return a!==\"\"&&!a.startsWith(\"/\")?t:n===\"root\"?`/root${a}`:t}async function ws(e,t,r,s){let n=\"\";for(let a of t.parts)if(a.type===\"Glob\")n+=k(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===\"Literal\")n+=k(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===\"SingleQuoted\"||a.type===\"Escaped\")n+=I(a.value);else if(a.type===\"DoubleQuoted\"){let i=await r(e,a.parts);n+=I(i)}else if(a.type===\"ParameterExpansion\"){let i=await s(e,a);n+=k(i,!0,e.state.shoptOptions.extglob)}else{let i=await s(e,a);n+=I(i)}return n}async function Bn(e,t,r,s){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!==\"PatternReplacement\")return null;let a=n.parts[0],i=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!i)return null;let l=i[1],o=i[2]===\"*\",c=a.operation,u=P(e,l),f=u.map(([,E])=>E);if(u.length===0){let E=e.state.env.get(l);E!==void 0&&f.push(E)}if(f.length===0)return{values:[],quoted:!0};let h=\"\";c.pattern&&(h=await ws(e,c.pattern,r,s));let d=c.replacement?await r(e,c.replacement.parts):\"\",m=h;c.anchor===\"start\"?m=`^${h}`:c.anchor===\"end\"&&(m=`${h}$`);let g=[];try{let E=O(m,c.all?\"g\":\"\");for(let A of f)g.push(E.replace(A,d))}catch{g.push(...f)}if(o){let E=N(e.state.env);return{values:[g.join(E)],quoted:!0}}return{values:g,quoted:!0}}async function Fn(e,t,r,s){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!==\"PatternRemoval\")return null;let a=n.parts[0],i=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!i)return null;let l=i[1],o=i[2]===\"*\",c=a.operation,u=P(e,l),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env.get(l);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h=\"\",d=e.state.shoptOptions.extglob;if(c.pattern)for(let g of c.pattern.parts)if(g.type===\"Glob\")h+=k(g.pattern,c.greedy,d);else if(g.type===\"Literal\")h+=k(g.value,c.greedy,d);else if(g.type===\"SingleQuoted\"||g.type===\"Escaped\")h+=I(g.value);else if(g.type===\"DoubleQuoted\"){let E=await r(e,g.parts);h+=I(E)}else if(g.type===\"ParameterExpansion\"){let E=await s(e,g);h+=k(E,c.greedy,d)}else{let E=await s(e,g);h+=I(E)}let m=[];for(let g of f)m.push(se(g,h,c.side,c.greedy));if(o){let g=N(e.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}async function zn(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\"||r.parts[0].operation?.type!==\"DefaultValue\"&&r.parts[0].operation?.type!==\"UseAlternative\"&&r.parts[0].operation?.type!==\"AssignDefault\")return null;let s=r.parts[0],n=s.operation,a=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/),i,l=!1;if(a){let o=a[1];l=a[2]===\"*\";let c=P(e,o),u=c.length>0||e.state.env.has(o),f=c.length===0||c.length===1&&c.every(([,d])=>d===\"\"),h=n.checkEmpty??!1;if(n.type===\"UseAlternative\"?i=u&&!(h&&f):i=!u||h&&f,!i){if(c.length>0){let m=c.map(([,g])=>g);if(l){let g=N(e.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}let d=e.state.env.get(o);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let o=s.parameter,c=await te(e,o),u=await v(e,o),f=u===\"\",h=n.checkEmpty??!1;if(n.type===\"UseAlternative\"?i=c&&!(h&&f):i=!c||h&&f,!i)return{values:[u],quoted:!0}}if(i&&n.word){let o=n.word.parts,c=null,u=!1;for(let f of o)if(f.type===\"ParameterExpansion\"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(h){c=h[1],u=h[2]===\"*\";break}}if(c){let f=P(e,c);if(f.length>0){let d=f.map(([,m])=>m);if(u||l){let m=N(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}let h=e.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function Gn(e,t,r,s,n){if(!r||t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let a=t[0],i=-1,l=\"\",o=!1,c=null;for(let g=0;g<a.parts.length;g++){let E=a.parts[g];if(E.type===\"ParameterExpansion\"&&(E.operation?.type===\"PatternRemoval\"||E.operation?.type===\"PatternReplacement\")){let A=E.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(A){i=g,l=A[1],o=A[2]===\"*\",c=E.operation;break}}}if(i===-1||i===0&&i===a.parts.length-1)return null;let u=\"\";for(let g=0;g<i;g++)u+=await s(e,a.parts[g]);let f=\"\";for(let g=i+1;g<a.parts.length;g++)f+=await s(e,a.parts[g]);let h=P(e,l),d=h.map(([,g])=>g);if(h.length===0){let g=e.state.env.get(l);if(g!==void 0)d=[g];else{if(o)return{values:[u+f],quoted:!0};let E=u+f;return{values:E?[E]:[],quoted:!0}}}if(c?.type===\"PatternRemoval\"){let g=c,E=\"\",A=e.state.shoptOptions.extglob;if(g.pattern)for(let S of g.pattern.parts)if(S.type===\"Glob\")E+=k(S.pattern,g.greedy,A);else if(S.type===\"Literal\")E+=k(S.value,g.greedy,A);else if(S.type===\"SingleQuoted\"||S.type===\"Escaped\")E+=I(S.value);else if(S.type===\"DoubleQuoted\"){let y=await n(e,S.parts);E+=I(y)}else if(S.type===\"ParameterExpansion\"){let y=await s(e,S);E+=k(y,g.greedy,A)}else{let y=await s(e,S);E+=I(y)}d=d.map(S=>se(S,E,g.side,g.greedy))}else if(c?.type===\"PatternReplacement\"){let g=c,E=\"\";if(g.pattern)for(let y of g.pattern.parts)if(y.type===\"Glob\")E+=k(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type===\"Literal\")E+=k(y.value,!0,e.state.shoptOptions.extglob);else if(y.type===\"SingleQuoted\"||y.type===\"Escaped\")E+=I(y.value);else if(y.type===\"DoubleQuoted\"){let b=await n(e,y.parts);E+=I(b)}else if(y.type===\"ParameterExpansion\"){let b=await s(e,y);E+=k(b,!0,e.state.shoptOptions.extglob)}else{let b=await s(e,y);E+=I(b)}let A=g.replacement?await n(e,g.replacement.parts):\"\",S=E;g.anchor===\"start\"?S=`^${E}`:g.anchor===\"end\"&&(S=`${E}$`);try{let y=O(S,g.all?\"g\":\"\");d=d.map(b=>y.replace(b,A))}catch{}}if(o){let g=N(e.state.env);return{values:[u+d.join(g)+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 Qn(e,t,r,s){if(!r||t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=\"\",l=!1;for(let d=0;d<n.parts.length;d++){let m=n.parts[d];if(m.type===\"ParameterExpansion\"&&!m.operation){let g=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(g){a=d,i=g[1],l=g[2]===\"*\";break}}}if(a===-1)return null;let o=\"\";for(let d=0;d<a;d++)o+=await s(e,n.parts[d]);let c=\"\";for(let d=a+1;d<n.parts.length;d++)c+=await s(e,n.parts[d]);let u=P(e,i),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env.get(i);if(d!==void 0)return{values:[o+d+c],quoted:!0};if(l)return{values:[o+c],quoted:!0};let m=o+c;return{values:m?[m]:[],quoted:!0}}if(l){let d=N(e.state.env);return{values:[o+f.join(d)+c],quoted:!0}}return f.length===1?{values:[o+f[0]+c],quoted:!0}:{values:[o+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}async function Zn(e,t,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!==\"Substring\")return null;let n=s.parts[0],a=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!a)return null;let i=a[1],l=a[2]===\"*\",o=n.operation;if(e.state.associativeArrays?.has(i))throw new K(1,\"\",`bash: \\${${i}[@]: 0: 3}: bad substitution\n`);let c=o.offset?await r(e,o.offset.expression):0,u=o.length?await r(e,o.length.expression):void 0,f=P(e,i),h=0;if(c<0){if(f.length>0){let m=f[f.length-1][0],E=(typeof m==\"number\"?m:0)+1+c;if(E<0)return{values:[],quoted:!0};h=f.findIndex(([A])=>typeof A==\"number\"&&A>=E),h<0&&(h=f.length)}}else h=f.findIndex(([m])=>typeof m==\"number\"&&m>=c),h<0&&(h=f.length);let d;if(u!==void 0){if(u<0)throw new C(`${i}[@]: substring expression < 0`);d=f.slice(h,h+u).map(([,m])=>m)}else d=f.slice(h).map(([,m])=>m);if(d.length===0)return{values:[],quoted:!0};if(l){let m=N(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}function Un(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\"||r.parts[0].operation?.type!==\"Transform\")return null;let s=r.parts[0],n=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!n)return null;let a=n[1],i=n[2]===\"*\",l=s.operation,o=P(e,a);if(o.length===0){let f=e.state.env.get(a);if(f!==void 0){let h;switch(l.operator){case\"a\":h=\"\";break;case\"P\":h=we(e,f);break;case\"Q\":h=le(f);break;default:h=f}return{values:[h],quoted:!0}}return i?{values:[\"\"],quoted:!0}:{values:[],quoted:!0}}let c=ue(e,a),u;switch(l.operator){case\"a\":u=o.map(()=>c);break;case\"P\":u=o.map(([,f])=>we(e,f));break;case\"Q\":u=o.map(([,f])=>le(f));break;case\"u\":u=o.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case\"U\":u=o.map(([,f])=>f.toUpperCase());break;case\"L\":u=o.map(([,f])=>f.toLowerCase());break;default:u=o.map(([,f])=>f)}if(i){let f=N(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}function Hn(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\")return null;let s=r.parts[0];if(s.operation)return null;let n=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(@)\\]$/);if(!n)return null;let a=n[1];if(W(e,a)){let o=Se(e,a);if(o?.endsWith(\"[@]\")||o?.endsWith(\"[*]\"))return{values:[],quoted:!0}}let i=P(e,a);if(i.length>0)return{values:i.map(([,o])=>o),quoted:!0};let l=e.state.env.get(a);return l!==void 0?{values:[l],quoted:!0}:{values:[],quoted:!0}}function jn(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\"||r.parts[0].operation)return null;let n=r.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||!W(e,n))return null;let a=Se(e,n);if(!a)return null;let i=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(@)\\]$/);if(!i)return null;let l=i[1],o=P(e,l);if(o.length>0)return{values:o.map(([,u])=>u),quoted:!0};let c=e.state.env.get(l);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}async function Kn(e,t,r,s,n){if(!r||t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==\"ParameterExpansion\"||a.parts[0].operation?.type!==\"Indirection\")return null;let i=a.parts[0],l=i.operation,o=await v(e,i.parameter),c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!c){if(!l.innerOp&&(o===\"@\"||o===\"*\")){let m=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),g=[];for(let E=1;E<=m;E++)g.push(e.state.env.get(String(E))||\"\");return o===\"*\"?{values:[g.join(N(e.state.env))],quoted:!0}:{values:g,quoted:!0}}return null}let u=c[1],f=c[2]===\"*\",h=P(e,u);if(l.innerOp){if(l.innerOp.type===\"Substring\")return Ns(e,h,u,f,l.innerOp);if(l.innerOp.type===\"DefaultValue\"||l.innerOp.type===\"UseAlternative\"||l.innerOp.type===\"AssignDefault\"||l.innerOp.type===\"ErrorIfUnset\")return ks(e,h,u,f,l.innerOp,n);if(l.innerOp.type===\"Transform\"&&l.innerOp.operator===\"a\"){let g=ue(e,u),E=h.map(()=>g);return f?{values:[E.join(N(e.state.env))],quoted:!0}:{values:E,quoted:!0}}let m=[];for(let[,g]of h){let E={type:\"ParameterExpansion\",parameter:\"_indirect_elem_\",operation:l.innerOp},A=e.state.env.get(\"_indirect_elem_\");e.state.env.set(\"_indirect_elem_\",g);try{let S=await s(e,E,!0);m.push(S)}finally{A!==void 0?e.state.env.set(\"_indirect_elem_\",A):e.state.env.delete(\"_indirect_elem_\")}}return f?{values:[m.join(N(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(h.length>0){let m=h.map(([,g])=>g);return f?{values:[m.join(N(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let d=e.state.env.get(u);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function Ns(e,t,r,s,n){let a=n.offset?await R(e,n.offset.expression):0,i=n.length?await R(e,n.length.expression):void 0,l=0;if(a<0){if(t.length>0){let u=t[t.length-1][0],h=(typeof u==\"number\"?u:0)+1+a;if(h<0)return{values:[],quoted:!0};if(l=t.findIndex(([d])=>typeof d==\"number\"&&d>=h),l<0)return{values:[],quoted:!0}}}else if(l=t.findIndex(([u])=>typeof u==\"number\"&&u>=a),l<0)return{values:[],quoted:!0};let o;if(i!==void 0){if(i<0)throw new C(`${r}[@]: substring expression < 0`);o=t.slice(l,l+i)}else o=t.slice(l);let c=o.map(([,u])=>u);return s?{values:[c.join(N(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function ks(e,t,r,s,n,a){let i=n.checkEmpty??!1,l=t.map(([,u])=>u),o=t.length===0,c=t.length===0;if(n.type===\"UseAlternative\")return!c&&!(i&&o)&&n.word?{values:[await a(e,n.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(n.type===\"DefaultValue\")return(c||i&&o)&&n.word?{values:[await a(e,n.word.parts,!0)],quoted:!0}:s?{values:[l.join(N(e.state.env))],quoted:!0}:{values:l,quoted:!0};if(n.type===\"AssignDefault\"){if((c||i&&o)&&n.word){let f=await a(e,n.word.parts,!0);return e.state.env.set(`${r}_0`,f),e.state.env.set(`${r}__length`,\"1\"),{values:[f],quoted:!0}}return s?{values:[l.join(N(e.state.env))],quoted:!0}:{values:l,quoted:!0}}return s?{values:[l.join(N(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function Xn(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"UseAlternative\"&&t[0].operation?.type!==\"DefaultValue\")return null;let r=t[0],s=r.operation,n=s?.word;if(!n||n.parts.length!==1||n.parts[0].type!==\"DoubleQuoted\")return null;let a=n.parts[0];if(a.parts.length!==1||a.parts[0].type!==\"ParameterExpansion\"||a.parts[0].operation?.type!==\"Indirection\")return null;let i=a.parts[0],o=(await v(e,i.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!o)return null;let c=await te(e,r.parameter),u=await v(e,r.parameter)===\"\",f=s.checkEmpty??!1,h;if(s.type===\"UseAlternative\"?h=c&&!(f&&u):h=!c||f&&u,h){let d=o[1],m=o[2]===\"*\",g=P(e,d);if(g.length>0){let A=g.map(([,S])=>S);return m?{values:[A.join(N(e.state.env))],quoted:!0}:{values:A,quoted:!0}}let E=e.state.env.get(d);return E!==void 0?{values:[E],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function Jn(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"Indirection\")return null;let r=t[0],n=r.operation.innerOp;if(!n||n.type!==\"UseAlternative\"&&n.type!==\"DefaultValue\")return null;let a=n.word;if(!a||a.parts.length!==1||a.parts[0].type!==\"DoubleQuoted\")return null;let i=a.parts[0];if(i.parts.length!==1||i.parts[0].type!==\"ParameterExpansion\"||i.parts[0].operation?.type!==\"Indirection\")return null;let l=i.parts[0],c=(await v(e,l.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!c)return null;let u=await v(e,r.parameter),f=await te(e,r.parameter),h=u===\"\",d=n.checkEmpty??!1,m;if(n.type===\"UseAlternative\"?m=f&&!(d&&h):m=!f||d&&h,m){let g=c[1],E=c[2]===\"*\",A=P(e,g);if(A.length>0){let y=A.map(([,b])=>b);return E?{values:[y.join(N(e.state.env))],quoted:!0}:{values:y,quoted:!0}}let S=e.state.env.get(g);return S!==void 0?{values:[S],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}function Yn(e){let t=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),r=[];for(let s=1;s<=t;s++)r.push(e.state.env.get(String(s))||\"\");return r}async function er(e,t,r,s){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=!1;for(let S=0;S<n.parts.length;S++){let y=n.parts[S];if(y.type===\"ParameterExpansion\"&&(y.parameter===\"@\"||y.parameter===\"*\")&&y.operation?.type===\"Substring\"){a=S,i=y.parameter===\"*\";break}}if(a===-1)return null;let o=n.parts[a].operation,c=o.offset?await r(e,o.offset.expression):0,u=o.length?await r(e,o.length.expression):void 0,f=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),h=[];for(let S=1;S<=f;S++)h.push(e.state.env.get(String(S))||\"\");let d=e.state.env.get(\"0\")||\"bash\",m;if(c<=0){let S=[d,...h],y=S.length+c;if(y<0)m=[];else{let b=c<0?y:0;if(u!==void 0){let D=u<0?S.length+u:b+u;m=S.slice(b,Math.max(b,D))}else m=S.slice(b)}}else{let S=c-1;if(S>=h.length)m=[];else if(u!==void 0){let y=u<0?h.length+u:S+u;m=h.slice(S,Math.max(S,y))}else m=h.slice(S)}let g=\"\";for(let S=0;S<a;S++)g+=await s(e,n.parts[S]);let E=\"\";for(let S=a+1;S<n.parts.length;S++)E+=await s(e,n.parts[S]);if(m.length===0){let S=g+E;return{values:S?[S]:[],quoted:!0}}if(i){let S=N(e.state.env);return{values:[g+m.join(S)+E],quoted:!0}}return m.length===1?{values:[g+m[0]+E],quoted:!0}:{values:[g+m[0],...m.slice(1,-1),m[m.length-1]+E],quoted:!0}}async function tr(e,t,r,s){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=!1;for(let A=0;A<n.parts.length;A++){let S=n.parts[A];if(S.type===\"ParameterExpansion\"&&(S.parameter===\"@\"||S.parameter===\"*\")&&S.operation?.type===\"PatternReplacement\"){a=A,i=S.parameter===\"*\";break}}if(a===-1)return null;let o=n.parts[a].operation,c=Yn(e),u=\"\";for(let A=0;A<a;A++)u+=await r(e,n.parts[A]);let f=\"\";for(let A=a+1;A<n.parts.length;A++)f+=await r(e,n.parts[A]);if(c.length===0){let A=u+f;return{values:A?[A]:[],quoted:!0}}let h=\"\";if(o.pattern)for(let A of o.pattern.parts)if(A.type===\"Glob\")h+=k(A.pattern,!0,e.state.shoptOptions.extglob);else if(A.type===\"Literal\")h+=k(A.value,!0,e.state.shoptOptions.extglob);else if(A.type===\"SingleQuoted\"||A.type===\"Escaped\")h+=I(A.value);else if(A.type===\"DoubleQuoted\"){let S=await s(e,A.parts);h+=I(S)}else if(A.type===\"ParameterExpansion\"){let S=await r(e,A);h+=k(S,!0,e.state.shoptOptions.extglob)}else{let S=await r(e,A);h+=I(S)}let d=o.replacement?await s(e,o.replacement.parts):\"\",m=h;o.anchor===\"start\"?m=`^${h}`:o.anchor===\"end\"&&(m=`${h}$`);let g=[];try{let A=O(m,o.all?\"g\":\"\");for(let S of c)g.push(A.replace(S,d))}catch{g.push(...c)}if(i){let A=N(e.state.env);return{values:[u+g.join(A)+f],quoted:!0}}return g.length===1?{values:[u+g[0]+f],quoted:!0}:{values:[u+g[0],...g.slice(1,-1),g[g.length-1]+f],quoted:!0}}async function nr(e,t,r,s){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=!1;for(let E=0;E<n.parts.length;E++){let A=n.parts[E];if(A.type===\"ParameterExpansion\"&&(A.parameter===\"@\"||A.parameter===\"*\")&&A.operation?.type===\"PatternRemoval\"){a=E,i=A.parameter===\"*\";break}}if(a===-1)return null;let o=n.parts[a].operation,c=Yn(e),u=\"\";for(let E=0;E<a;E++)u+=await r(e,n.parts[E]);let f=\"\";for(let E=a+1;E<n.parts.length;E++)f+=await r(e,n.parts[E]);if(c.length===0){let E=u+f;return{values:E?[E]:[],quoted:!0}}let h=\"\",d=e.state.shoptOptions.extglob;if(o.pattern)for(let E of o.pattern.parts)if(E.type===\"Glob\")h+=k(E.pattern,o.greedy,d);else if(E.type===\"Literal\")h+=k(E.value,o.greedy,d);else if(E.type===\"SingleQuoted\"||E.type===\"Escaped\")h+=I(E.value);else if(E.type===\"DoubleQuoted\"){let A=await s(e,E.parts);h+=I(A)}else if(E.type===\"ParameterExpansion\"){let A=await r(e,E);h+=k(A,o.greedy,d)}else{let A=await r(e,E);h+=I(A)}let m=[];for(let E of c)m.push(se(E,h,o.side,o.greedy));if(i){let E=N(e.state.env);return{values:[u+m.join(E)+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 rr(e,t,r){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let s=t[0],n=-1,a=!1;for(let h=0;h<s.parts.length;h++){let d=s.parts[h];if(d.type===\"ParameterExpansion\"&&(d.parameter===\"@\"||d.parameter===\"*\")){n=h,a=d.parameter===\"*\";break}}if(n===-1)return null;let i=s.parts[n];if(i.type===\"ParameterExpansion\"&&i.operation)return null;let l=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),o=\"\";for(let h=0;h<n;h++)o+=await r(e,s.parts[h]);let c=\"\";for(let h=n+1;h<s.parts.length;h++)c+=await r(e,s.parts[h]);if(l===0){if(a)return{values:[o+c],quoted:!0};let h=o+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=l;h++)u.push(e.state.env.get(String(h))||\"\");if(a){let h=N(e.state.env);return{values:[o+u.join(h)+c],quoted:!0}}return u.length===1?{values:[o+u[0]+c],quoted:!0}:{values:[o+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}function Ps(e){return new oe(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations})}async function Te(e,t){if(e.state.options.noglob)return t;let r=Ps(e),s=[];for(let n of t)if(ne(n,e.state.shoptOptions.extglob)){let a=await r.expand(n);if(a.length>0)s.push(...a);else{if(r.hasFailglob())throw new Pe(n);r.hasNullglob()||s.push(n)}}else s.push(n);return s}async function sr(e,t,r,s){let n=-1,a=\"\",i=!1;for(let S=0;S<t.length;S++){let y=t[S];if(y.type===\"ParameterExpansion\"&&y.operation?.type===\"PatternReplacement\"){let b=y.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(b){n=S,a=b[1],i=b[2]===\"*\";break}}}if(n===-1)return null;let o=t[n].operation,c=P(e,a),u=c.map(([,S])=>S);if(c.length===0){let S=e.state.env.get(a);S!==void 0&&(u=[S])}if(u.length===0)return{values:[],quoted:!1};let f=\"\";if(o.pattern)for(let S of o.pattern.parts)if(S.type===\"Glob\")f+=k(S.pattern,!0,e.state.shoptOptions.extglob);else if(S.type===\"Literal\")f+=k(S.value,!0,e.state.shoptOptions.extglob);else if(S.type===\"SingleQuoted\"||S.type===\"Escaped\")f+=I(S.value);else if(S.type===\"DoubleQuoted\"){let y=await r(e,S.parts);f+=I(y)}else if(S.type===\"ParameterExpansion\"){let y=await s(e,S);f+=k(y,!0,e.state.shoptOptions.extglob)}else{let y=await s(e,S);f+=I(y)}let h=o.replacement?await r(e,o.replacement.parts):\"\",d=f;o.anchor===\"start\"?d=`^${f}`:o.anchor===\"end\"&&(d=`${f}$`);let m=[];try{let S=O(d,o.all?\"g\":\"\");for(let y of u)m.push(S.replace(y,h))}catch{m.push(...u)}let g=T(e.state.env),E=q(e.state.env);if(i){let S=N(e.state.env),y=m.join(S);return E?{values:y?[y]:[],quoted:!1}:{values:x(y,g),quoted:!1}}if(E)return{values:m,quoted:!1};let A=[];for(let S of m)S===\"\"?A.push(\"\"):A.push(...x(S,g));return{values:A,quoted:!1}}async function ir(e,t,r,s){let n=-1,a=\"\",i=!1;for(let A=0;A<t.length;A++){let S=t[A];if(S.type===\"ParameterExpansion\"&&S.operation?.type===\"PatternRemoval\"){let y=S.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(y){n=A,a=y[1],i=y[2]===\"*\";break}}}if(n===-1)return null;let o=t[n].operation,c=P(e,a),u=c.map(([,A])=>A);if(c.length===0){let A=e.state.env.get(a);A!==void 0&&(u=[A])}if(u.length===0)return{values:[],quoted:!1};let f=\"\",h=e.state.shoptOptions.extglob;if(o.pattern)for(let A of o.pattern.parts)if(A.type===\"Glob\")f+=k(A.pattern,o.greedy,h);else if(A.type===\"Literal\")f+=k(A.value,o.greedy,h);else if(A.type===\"SingleQuoted\"||A.type===\"Escaped\")f+=I(A.value);else if(A.type===\"DoubleQuoted\"){let S=await r(e,A.parts);f+=I(S)}else if(A.type===\"ParameterExpansion\"){let S=await s(e,A);f+=k(S,o.greedy,h)}else{let S=await s(e,A);f+=I(S)}let d=[];for(let A of u)d.push(se(A,f,o.side,o.greedy));let m=T(e.state.env),g=q(e.state.env);if(i){let A=N(e.state.env),S=d.join(A);return g?{values:S?[S]:[],quoted:!1}:{values:x(S,m),quoted:!1}}if(g)return{values:d,quoted:!1};let E=[];for(let A of d)A===\"\"?E.push(\"\"):E.push(...x(A,m));return{values:E,quoted:!1}}async function ar(e,t,r,s){let n=-1,a=!1;for(let E=0;E<t.length;E++){let A=t[E];if(A.type===\"ParameterExpansion\"&&(A.parameter===\"@\"||A.parameter===\"*\")&&A.operation?.type===\"PatternRemoval\"){n=E,a=A.parameter===\"*\";break}}if(n===-1)return null;let l=t[n].operation,o=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),c=[];for(let E=1;E<=o;E++)c.push(e.state.env.get(String(E))||\"\");if(c.length===0)return{values:[],quoted:!1};let u=\"\",f=e.state.shoptOptions.extglob;if(l.pattern)for(let E of l.pattern.parts)if(E.type===\"Glob\")u+=k(E.pattern,l.greedy,f);else if(E.type===\"Literal\")u+=k(E.value,l.greedy,f);else if(E.type===\"SingleQuoted\"||E.type===\"Escaped\")u+=I(E.value);else if(E.type===\"DoubleQuoted\"){let A=await r(e,E.parts);u+=I(A)}else if(E.type===\"ParameterExpansion\"){let A=await s(e,E);u+=k(A,l.greedy,f)}else{let A=await s(e,E);u+=I(A)}let h=[];for(let E of c)h.push(se(E,u,l.side,l.greedy));let d=T(e.state.env),m=q(e.state.env);if(a){let E=N(e.state.env),A=h.join(E);return m?{values:A?[A]:[],quoted:!1}:{values:x(A,d),quoted:!1}}if(m)return{values:h,quoted:!1};let g=[];for(let E of h)E===\"\"?g.push(\"\"):g.push(...x(E,d));return{values:g,quoted:!1}}async function or(e,t,r,s){let n=-1,a=!1;for(let y=0;y<t.length;y++){let b=t[y];if(b.type===\"ParameterExpansion\"&&(b.parameter===\"@\"||b.parameter===\"*\")&&b.operation?.type===\"Substring\"){n=y,a=b.parameter===\"*\";break}}if(n===-1)return null;let l=t[n].operation,o=l.offset?await r(e,l.offset.expression):0,c=l.length?await r(e,l.length.expression):void 0,u=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),f=[];for(let y=1;y<=u;y++)f.push(e.state.env.get(String(y))||\"\");let h=e.state.env.get(\"0\")||\"bash\",d;if(o<=0){let y=[h,...f],b=y.length+o;if(b<0)d=[];else{let D=o<0?b:0;if(c!==void 0){let Q=c<0?y.length+c:D+c;d=y.slice(D,Math.max(D,Q))}else d=y.slice(D)}}else{let y=o-1;if(y>=f.length)d=[];else if(c!==void 0){let b=c<0?f.length+c:y+c;d=f.slice(y,Math.max(y,b))}else d=f.slice(y)}let m=\"\";for(let y=0;y<n;y++)m+=await s(e,t[y]);let g=\"\";for(let y=n+1;y<t.length;y++)g+=await s(e,t[y]);let E=T(e.state.env),A=q(e.state.env);if(d.length===0){let y=m+g;return y?A?{values:[y],quoted:!1}:{values:x(y,E),quoted:!1}:{values:[],quoted:!1}}let S;if(a){let y=N(e.state.env),b=m+d.join(y)+g;A?S=b?[b]:[]:S=x(b,E)}else if(A)d.length===1?S=[m+d[0]+g]:S=[m+d[0],...d.slice(1,-1),d[d.length-1]+g];else{S=[];for(let y=0;y<d.length;y++){let b=d[y];if(y===0&&(b=m+b),y===d.length-1&&(b=b+g),b===\"\")S.push(\"\");else{let D=x(b,E);S.push(...D)}}}return{values:await Te(e,S),quoted:!1}}async function lr(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].parameter!==\"@\"&&t[0].parameter!==\"*\"||t[0].operation)return null;let r=t[0].parameter===\"*\",s=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);if(s===0)return{values:[],quoted:!1};let n=[];for(let c=1;c<=s;c++)n.push(e.state.env.get(String(c))||\"\");let a=T(e.state.env),i=q(e.state.env),l=Ce(e.state.env),o;if(r)if(i)o=n.filter(c=>c!==\"\");else{let c=N(e.state.env),u=n.join(c);o=x(u,a)}else if(i)o=n.filter(c=>c!==\"\");else if(l){o=[];for(let c of n){if(c===\"\")continue;let u=x(c,a);o.push(...u)}}else{o=[];for(let c of n)if(c===\"\")o.push(\"\");else{let u=x(c,a);o.push(...u)}for(;o.length>0&&o[o.length-1]===\"\";)o.pop()}return{values:await Te(e,o),quoted:!1}}async function ur(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation)return null;let r=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!r)return null;let s=r[1],n=r[2]===\"*\",a=P(e,s),i;if(a.length===0){let f=e.state.env.get(s);if(f!==void 0)i=[f];else return{values:[],quoted:!1}}else i=a.map(([,f])=>f);let l=T(e.state.env),o=q(e.state.env),c=Ce(e.state.env),u;if(n)if(o)u=i.filter(f=>f!==\"\");else{let f=N(e.state.env),h=i.join(f);u=x(h,l)}else if(o)u=i.filter(f=>f!==\"\");else if(c){u=[];for(let f of i){if(f===\"\")continue;let h=x(f,l);u.push(...h)}}else{u=[];for(let f of i)if(f===\"\")u.push(\"\");else{let h=x(f,l);u.push(...h)}for(;u.length>0&&u[u.length-1]===\"\";)u.pop()}return{values:await Te(e,u),quoted:!1}}function cr(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"VarNamePrefix\")return null;let r=t[0].operation,s=me(e,r.prefix);if(s.length===0)return{values:[],quoted:!1};let n=T(e.state.env),a=q(e.state.env),i;if(r.star)if(a)i=s;else{let l=N(e.state.env),o=s.join(l);i=x(o,n)}else if(a)i=s;else{i=[];for(let l of s){let o=x(l,n);i.push(...o)}}return{values:i,quoted:!1}}function fr(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"ArrayKeys\")return null;let r=t[0].operation,n=P(e,r.array).map(([o])=>String(o));if(n.length===0)return{values:[],quoted:!1};let a=T(e.state.env),i=q(e.state.env),l;if(r.star)if(i)l=n;else{let o=N(e.state.env),c=n.join(o);l=x(c,a)}else if(i)l=n;else{l=[];for(let o of n){let c=x(o,a);l.push(...c)}}return{values:l,quoted:!1}}async function hr(e,t,r){let s=-1;for(let h=0;h<t.length;h++){let d=t[h];if(d.type===\"ParameterExpansion\"&&(d.parameter===\"@\"||d.parameter===\"*\")&&!d.operation){s=h;break}}if(s===-1||t.length<=1)return null;let n=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),a=[];for(let h=1;h<=n;h++)a.push(e.state.env.get(String(h))||\"\");let i=\"\";for(let h=0;h<s;h++)i+=await r(e,t[h]);let l=\"\";for(let h=s+1;h<t.length;h++)l+=await r(e,t[h]);let o=T(e.state.env),c=q(e.state.env),u=Ce(e.state.env);if(n===0){let h=i+l;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let d=0;d<a.length;d++){let m=a[d];d===0&&(m=i+m),d===a.length-1&&(m=m+l),h.push(m)}if(c)f=h.filter(d=>d!==\"\");else if(u){f=[];for(let d of h){if(d===\"\")continue;let m=x(d,o);f.push(...m)}}else{f=[];for(let d of h)if(d===\"\")f.push(\"\");else{let m=x(d,o);f.push(...m)}for(;f.length>0&&f[f.length-1]===\"\";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await Te(e,f),quoted:!1}}async function mr(e,t,r){e.coverage?.hit(\"bash:expansion:word_glob\");let s=t.parts,{hasQuoted:n,hasCommandSub:a,hasArrayVar:i,hasArrayAtExpansion:l,hasParamExpansion:o,hasVarNamePrefixExpansion:c,hasIndirection:u}=Ae(s),h=r.hasBraceExpansion(s)?await r.expandWordWithBracesAsync(e,t):null;if(h&&h.length>1)return Rs(e,h,n);let d=await Is(e,s,l,c,u,r);if(d!==null)return d;let m=await Ds(e,s,r);if(m!==null)return m;let g=await xs(e,s,r);if(g!==null)return g;let E=await $s(e,s,r.expandPart);if(E!==null)return dr(e,E);if((a||i||o)&&!q(e.state.env)){let S=T(e.state.env),y=r.buildIfsCharClassPattern(S),b=await r.smartWordSplit(e,s,S,y,r.expandPart);return dr(e,b)}let A=await r.expandWordAsync(e,t);return Cs(e,t,s,A,n,r.expandWordForGlobbing)}async function Rs(e,t,r){let s=[];for(let n of t)if(!(!r&&n===\"\"))if(!r&&!e.state.options.noglob&&ne(n,e.state.shoptOptions.extglob)){let a=await Me(e,n);s.push(...a)}else s.push(n);return{values:s,quoted:!1}}async function Is(e,t,r,s,n,a){if(r){let i=Hn(e,t);if(i!==null)return i}{let i=jn(e,t);if(i!==null)return i}{let i=await zn(e,t);if(i!==null)return i}{let i=await Gn(e,t,r,a.expandPart,a.expandWordPartsAsync);if(i!==null)return i}{let i=await Qn(e,t,r,a.expandPart);if(i!==null)return i}{let i=await Zn(e,t,a.evaluateArithmetic);if(i!==null)return i}{let i=Un(e,t);if(i!==null)return i}{let i=await Bn(e,t,a.expandWordPartsAsync,a.expandPart);if(i!==null)return i}{let i=await Fn(e,t,a.expandWordPartsAsync,a.expandPart);if(i!==null)return i}if(s&&t.length===1&&t[0].type===\"DoubleQuoted\"){let i=vs(e,t);if(i!==null)return i}{let i=await Kn(e,t,n,a.expandParameterAsync,a.expandWordPartsAsync);if(i!==null)return i}{let i=await Xn(e,t);if(i!==null)return i}{let i=await Jn(e,t);if(i!==null)return i}return null}function vs(e,t){let r=t[0];if(r.type!==\"DoubleQuoted\")return null;if(r.parts.length===1&&r.parts[0].type===\"ParameterExpansion\"&&r.parts[0].operation?.type===\"VarNamePrefix\"){let s=r.parts[0].operation,n=me(e,s.prefix);return s.star?{values:[n.join(N(e.state.env))],quoted:!0}:{values:n,quoted:!0}}if(r.parts.length===1&&r.parts[0].type===\"ParameterExpansion\"&&r.parts[0].operation?.type===\"ArrayKeys\"){let s=r.parts[0].operation,a=P(e,s.array).map(([i])=>String(i));return s.star?{values:[a.join(N(e.state.env))],quoted:!0}:{values:a,quoted:!0}}return null}async function Ds(e,t,r){{let s=await er(e,t,r.evaluateArithmetic,r.expandPart);if(s!==null)return s}{let s=await tr(e,t,r.expandPart,r.expandWordPartsAsync);if(s!==null)return s}{let s=await nr(e,t,r.expandPart,r.expandWordPartsAsync);if(s!==null)return s}{let s=await rr(e,t,r.expandPart);if(s!==null)return s}return null}async function xs(e,t,r){{let s=await sr(e,t,r.expandWordPartsAsync,r.expandPart);if(s!==null)return s}{let s=await ir(e,t,r.expandWordPartsAsync,r.expandPart);if(s!==null)return s}{let s=await ar(e,t,r.expandWordPartsAsync,r.expandPart);if(s!==null)return s}{let s=await or(e,t,r.evaluateArithmetic,r.expandPart);if(s!==null)return s}{let s=await lr(e,t);if(s!==null)return s}{let s=await ur(e,t);if(s!==null)return s}{let s=cr(e,t);if(s!==null)return s}{let s=fr(e,t);if(s!==null)return s}{let s=await hr(e,t,r.expandPart);if(s!==null)return s}return null}function pr(e){if(e.type!==\"DoubleQuoted\")return null;for(let t=0;t<e.parts.length;t++){let r=e.parts[t];if(r.type!==\"ParameterExpansion\"||r.operation)continue;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(s)return{type:\"array\",name:s[1],atIndex:t,isStar:s[2]===\"*\"};if(r.parameter===\"@\"||r.parameter===\"*\")return{type:\"positional\",atIndex:t,isStar:r.parameter===\"*\"}}return null}async function _s(e,t,r,s){let n=\"\";for(let l=0;l<r.atIndex;l++)n+=await s(e,t.parts[l]);let a=\"\";for(let l=r.atIndex+1;l<t.parts.length;l++)a+=await s(e,t.parts[l]);let i;if(r.type===\"array\"){if(i=P(e,r.name).map(([,o])=>o),i.length===0){let o=e.state.env.get(r.name);o!==void 0&&(i=[o])}}else{let l=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);i=[];for(let o=1;o<=l;o++)i.push(e.state.env.get(String(o))||\"\")}if(r.isStar){let l=N(e.state.env),o=i.join(l);return[n+o+a]}if(i.length===0){let l=n+a;return l?[l]:[]}return i.length===1?[n+i[0]+a]:[n+i[0],...i.slice(1,-1),i[i.length-1]+a]}async function $s(e,t,r){if(t.length<2)return null;let s=!1;for(let o of t)if(pr(o)){s=!0;break}if(!s)return null;let n=T(e.state.env),a=q(e.state.env),i=[];for(let o of t){let c=pr(o);if(c&&o.type===\"DoubleQuoted\"){let u=await _s(e,o,c,r);i.push(u)}else if(o.type===\"DoubleQuoted\"||o.type===\"SingleQuoted\"){let u=await r(e,o);i.push([u])}else if(o.type===\"Literal\")i.push([o.value]);else if(o.type===\"ParameterExpansion\"){let u=await r(e,o);if(a)i.push(u?[u]:[]);else{let f=x(u,n);i.push(f)}}else{let u=await r(e,o);if(a)i.push(u?[u]:[]);else{let f=x(u,n);i.push(f)}}}let l=[];for(let o of i)if(o.length!==0)if(l.length===0)l.push(...o);else{let c=l.length-1;l[c]=l[c]+o[0];for(let u=1;u<o.length;u++)l.push(o[u])}return l}async function dr(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let r=[];for(let s of t)if(ne(s,e.state.shoptOptions.extglob)){let n=await Me(e,s);r.push(...n)}else r.push(s);return{values:r,quoted:!1}}async function Me(e,t){let r=new oe(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),s=await r.expand(t);if(s.length>0)return s;if(r.hasFailglob())throw new Pe(t);return r.hasNullglob()?[]:[t]}async function Cs(e,t,r,s,n,a){let i=r.some(l=>l.type===\"Glob\");if(!e.state.options.noglob&&i){let l=await a(e,t);if(ne(l,e.state.shoptOptions.extglob)){let c=await Me(e,l);if(c.length>0&&c[0]!==l)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let o=St(s);if(!q(e.state.env)){let c=T(e.state.env);return{values:x(o,c),quoted:!1}}return{values:[o],quoted:!1}}if(!n&&!e.state.options.noglob&&ne(s,e.state.shoptOptions.extglob)){let l=await a(e,t);if(ne(l,e.state.shoptOptions.extglob)){let o=await Me(e,l);if(o.length>0&&o[0]!==l)return{values:o,quoted:!1}}}if(s===\"\"&&!n)return{values:[],quoted:!1};if(i&&!n){let l=St(s);if(!q(e.state.env)){let o=T(e.state.env);return{values:x(l,o),quoted:!1}}return{values:[l],quoted:!1}}return{values:[s],quoted:n}}async function yr(e,t){let r=t.operation;if(!r||r.type!==\"DefaultValue\"&&r.type!==\"AssignDefault\"&&r.type!==\"UseAlternative\")return null;let s=r.word;if(!s||s.parts.length===0)return null;let n=await te(e,t.parameter),i=await v(e,t.parameter,!1)===\"\",l=r.checkEmpty??!1,o;return r.type===\"UseAlternative\"?o=n&&!(l&&i):o=!n||l&&i,o?s.parts:null}function Os(e){return e.type===\"SingleQuoted\"?!0:e.type===\"DoubleQuoted\"?e.parts.every(r=>r.type===\"Literal\"):!1}async function Ls(e,t){if(t.type!==\"ParameterExpansion\")return null;let r=await yr(e,t);if(!r||r.length<=1)return null;let s=r.some(a=>Os(a)),n=r.some(a=>a.type===\"Literal\"||a.type===\"ParameterExpansion\"||a.type===\"CommandSubstitution\"||a.type===\"ArithmeticExpansion\");return s&&n?r:null}function Ws(e){return e.type===\"DoubleQuoted\"||e.type===\"SingleQuoted\"||e.type===\"Literal\"?!1:e.type===\"Glob\"?dt(e.pattern):!(!(e.type===\"ParameterExpansion\"||e.type===\"CommandSubstitution\"||e.type===\"ArithmeticExpansion\")||e.type===\"ParameterExpansion\"&&gn(e))}async function Er(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:word_split\"),t.length===1&&t[0].type===\"ParameterExpansion\"){let h=t[0],d=await yr(e,h);if(d&&d.length>0&&d.length>1&&d.some(g=>g.type===\"DoubleQuoted\"||g.type===\"SingleQuoted\")&&d.some(g=>g.type===\"Literal\"||g.type===\"ParameterExpansion\"||g.type===\"CommandSubstitution\"||g.type===\"ArithmeticExpansion\"))return gr(e,d,r,s,n)}let a=[],i=!1;for(let h of t){let d=Ws(h),m=h.type===\"DoubleQuoted\"||h.type===\"SingleQuoted\",g=d?await Ls(e,h):null,E=await n(e,h);a.push({value:E,isSplittable:d,isQuoted:m,mixedDefaultParts:g??void 0}),d&&(i=!0)}if(!i){let h=a.map(d=>d.value).join(\"\");return h?[h]:[]}let l=[],o=\"\",c=!1,u=!1,f=!1;for(let h of a)if(!h.isSplittable)u?h.isQuoted&&h.value===\"\"?(o!==\"\"&&l.push(o),l.push(\"\"),c=!0,o=\"\",u=!1,f=!0):h.value!==\"\"?(o!==\"\"&&l.push(o),o=h.value,u=!1,f=!1):(o+=h.value,f=!1):(o+=h.value,f=h.isQuoted&&h.value===\"\");else if(h.mixedDefaultParts){let d=await gr(e,h.mixedDefaultParts,r,s,n);if(d.length!==0)if(d.length===1)o+=d[0],c=!0;else{o+=d[0],l.push(o),c=!0;for(let m=1;m<d.length-1;m++)l.push(d[m]);o=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:m,hadTrailingDelimiter:g}=Oe(h.value,r);if(f&&m&&o===\"\"&&(l.push(\"\"),c=!0),d.length===0)g&&(u=!0);else if(d.length===1)o+=d[0],c=!0,u=g;else{o+=d[0],l.push(o),c=!0;for(let E=1;E<d.length-1;E++)l.push(d[E]);o=d[d.length-1],u=g}f=!1}return o!==\"\"?l.push(o):l.length===0&&c&&l.push(\"\"),l}function Ts(e,t){return e.length>0&&t.includes(e[0])}async function gr(e,t,r,s,n){let a=[];for(let u of t){let h=!(u.type===\"DoubleQuoted\"||u.type===\"SingleQuoted\"),d=await n(e,u);a.push({value:d,isSplittable:h})}let i=[],l=\"\",o=!1,c=!1;for(let u of a)if(!u.isSplittable)c&&u.value!==\"\"?(l!==\"\"&&i.push(l),l=u.value,c=!1):l+=u.value;else{Ts(u.value,r)&&l!==\"\"&&(i.push(l),l=\"\",o=!0);let{words:h,hadTrailingDelimiter:d}=Oe(u.value,r);if(h.length===0)d&&(c=!0);else if(h.length===1)l+=h[0],o=!0,c=d;else{l+=h[0],i.push(l),o=!0;for(let m=1;m<h.length-1;m++)i.push(h[m]);l=h[h.length-1],c=d}}return l!==\"\"?i.push(l):i.length===0&&o&&i.push(\"\"),i}function Ar(e){switch(e.type){case\"Literal\":return e.value;case\"SingleQuoted\":return e.value;case\"Escaped\":return e.value;default:return null}}function Sr(e){switch(e.type){case\"SingleQuoted\":case\"Escaped\":case\"DoubleQuoted\":return!0;case\"Literal\":return e.value===\"\";default:return!1}}function ce(e,t,r){if(e.length>t)throw new L(`${r}: string length limit exceeded (${t} bytes)`,\"string_length\")}async function J(e,t,r=!1){let s=[];for(let n of t)s.push(await U(e,n,r));return s.join(\"\")}function Ms(e){return Sr(e)}function Al(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!Ms(t))return!1;return!0}function Vs(e,t,r=!1){let s=Ar(t);if(s!==null)return s;switch(t.type){case\"TildeExpansion\":return r?t.user===null?\"~\":`~${t.user}`:(e.coverage?.hit(\"bash:expansion:tilde\"),t.user===null?e.state.env.get(\"HOME\")??\"/home/user\":t.user===\"root\"?\"/root\":`~${t.user}`);case\"Glob\":return Nt(e,t.pattern);default:return null}}async function Pt(e,t){return Rt(e,t)}async function Sl(e,t){let r=[];for(let s of t.parts)if(s.type===\"Escaped\")r.push(`\\\\${s.value}`);else if(s.type===\"SingleQuoted\")r.push(s.value);else if(s.type===\"DoubleQuoted\"){let n=await J(e,s.parts);r.push(n)}else if(s.type===\"TildeExpansion\"){let n=await U(e,s);r.push(bt(n))}else r.push(await U(e,s));return r.join(\"\")}async function bl(e,t){let r=[];for(let s of t.parts)if(s.type===\"Escaped\"){let n=s.value;\"()|*?[]\".includes(n)?r.push(`\\\\${n}`):r.push(n)}else if(s.type===\"SingleQuoted\")r.push(X(s.value));else if(s.type===\"DoubleQuoted\"){let n=await J(e,s.parts);r.push(X(n))}else r.push(await U(e,s));return r.join(\"\")}async function br(e,t){let r=[];for(let s of t.parts)if(s.type===\"SingleQuoted\")r.push(X(s.value));else if(s.type===\"Escaped\"){let n=s.value;\"*?[]\\\\()|\".includes(n)?r.push(`\\\\${n}`):r.push(n)}else if(s.type===\"DoubleQuoted\"){let n=await J(e,s.parts);r.push(X(n))}else s.type===\"Glob\"?Tn(s.pattern)?r.push(await Vn(e,s.pattern)):r.push(Nt(e,s.pattern)):s.type===\"Literal\"?r.push(s.value):r.push(await U(e,s));return r.join(\"\")}function qe(e){for(let t of e)if(t.type===\"BraceExpansion\"||t.type===\"DoubleQuoted\"&&qe(t.parts))return!0;return!1}var kt=1e5;async function wr(e,t,r={count:0}){if(r.count>kt)return[[]];let s=[[]];for(let n of t)if(n.type===\"BraceExpansion\"){let a=[],i=!1,l=\"\";for(let u of n.items)if(u.type===\"Range\"){let f=At(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)r.count++,a.push(h);else{i=!0,l=f.literal;break}}else{let f=await wr(e,u.word.parts,r);for(let h of f){r.count++;let d=[];for(let m of h)typeof m==\"string\"?d.push(m):d.push(await U(e,m));a.push(d.join(\"\"))}}if(i){for(let u of s)r.count++,u.push(l);continue}if(s.length*a.length>e.limits.maxBraceExpansionResults||r.count>kt)return s;let c=[];for(let u of s)for(let f of a){if(r.count++,r.count>kt)return c.length>0?c:s;c.push([...u,f])}s=c}else for(let a of s)r.count++,a.push(n);return s}async function Nr(e,t){let r=t.parts;if(!qe(r))return[await Pt(e,t)];let s=await wr(e,r),n=[];for(let a of s){let i=[];for(let l of a)typeof l==\"string\"?i.push(l):i.push(await U(e,l));n.push(qn(e,i.join(\"\")))}return n}function qs(){return{expandWordAsync:Rt,expandWordForGlobbing:br,expandWordWithBracesAsync:Nr,expandWordPartsAsync:J,expandPart:U,expandParameterAsync:Ve,hasBraceExpansion:qe,evaluateArithmetic:R,buildIfsCharClassPattern:An,smartWordSplit:Er}}async function wl(e,t){return mr(e,t,qs())}function Bs(e){for(let t of e){if(t.type===\"ParameterExpansion\")return t.parameter;if(t.type===\"Literal\")return t.value}return\"\"}function Fs(e,t){if(Number.parseInt(e.state.env.get(\"#\")||\"0\",10)<2)return!1;function s(n){for(let a of n)if(a.type===\"DoubleQuoted\"){for(let i of a.parts)if(i.type===\"ParameterExpansion\"&&i.parameter===\"@\"&&!i.operation)return!0}return!1}return s(t.parts)}async function Nl(e,t){if(Fs(e,t))return{error:`bash: $@: ambiguous redirect\n`};let r=t.parts,{hasQuoted:s}=Ae(r);if(qe(r)&&(await Nr(e,t)).length>1)return{error:`bash: ${r.map(d=>d.type===\"Literal\"?d.value:d.type===\"BraceExpansion\"?`{${d.items.map(g=>{if(g.type===\"Range\"){let E=g.step?`..${g.step}`:\"\";return`${g.startStr??g.start}..${g.endStr??g.end}${E}`}return g.word.parts.map(E=>E.type===\"Literal\"?E.value:\"\").join(\"\")}).join(\",\")}}`:\"\").join(\"\")}: ambiguous redirect\n`};let n=await Rt(e,t),{hasParamExpansion:a,hasCommandSub:i}=Ae(r);if((a||i)&&!s&&!q(e.state.env)){let f=T(e.state.env);if(x(n,f).length>1)return{error:`bash: $${Bs(r)}: ambiguous redirect\n`}}if(s||e.state.options.noglob)return{target:n};let o=await br(e,t);if(!ne(o,e.state.shoptOptions.extglob))return{target:n};let c=new oe(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),u=await c.expand(o);return u.length===0?c.hasFailglob()?{error:`bash: no match: ${n}\n`}:{target:n}:u.length===1?{target:u[0]}:{error:`bash: ${n}: ambiguous redirect\n`}}async function Rt(e,t){let r=t.parts,s=r.length;if(s===1){let i=await U(e,r[0]);return ce(i,e.limits.maxStringLength,\"word expansion\"),i}let n=[];for(let i=0;i<s;i++)n.push(await U(e,r[i]));let a=n.join(\"\");return ce(a,e.limits.maxStringLength,\"word expansion\"),a}async function U(e,t,r=!1){if(t.type===\"ParameterExpansion\")return Ve(e,t,r);let s=Vs(e,t,r);if(s!==null)return s;switch(t.type){case\"DoubleQuoted\":{let n=[];for(let a of t.parts)n.push(await U(e,a,!0));return n.join(\"\")}case\"CommandSubstitution\":{let n=wn(t.body);if(n)try{let h=await Pt(e,n.target),d=h.startsWith(\"/\")?h:`${e.state.cwd}/${h}`,m=await e.fs.readFile(d);e.state.lastExitCode=0,e.state.env.set(\"?\",\"0\");let g=m.replace(/\\n+$/,\"\");return ce(g,e.limits.maxStringLength,\"command substitution\"),g}catch(h){if(h instanceof L)throw h;return e.state.lastExitCode=1,e.state.env.set(\"?\",\"1\"),\"\"}let a=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(a>=i)throw new L(`Command substitution nesting limit exceeded (${i})`,\"substitution_depth\");let l=e.substitutionDepth;e.substitutionDepth=a+1;let o=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let c=new Map(e.state.env),u=e.state.cwd,f=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let h=await e.executeScript(t.body),d=h.exitCode;e.state.env=c,e.state.cwd=u,e.state.suppressVerbose=f,e.state.lastExitCode=d,e.state.env.set(\"?\",String(d)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+h.stderr),e.state.bashPid=o,e.substitutionDepth=l;let m=h.stdout.replace(/\\n+$/,\"\");return ce(m,e.limits.maxStringLength,\"command substitution\"),m}catch(h){if(e.state.env=c,e.state.cwd=u,e.state.bashPid=o,e.substitutionDepth=l,e.state.suppressVerbose=f,h instanceof L)throw h;if(h instanceof K){e.state.lastExitCode=h.exitCode,e.state.env.set(\"?\",String(h.exitCode)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+h.stderr);let d=h.stdout.replace(/\\n+$/,\"\");return ce(d,e.limits.maxStringLength,\"command substitution\"),d}throw h}}case\"ArithmeticExpansion\":{let n=t.expression.originalText;if(n&&/\\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(n)){let i=await bn(e,n),l=new V,o=M(l,i);return String(await R(e,o.expression,!0))}return String(await R(e,t.expression.expression,!0))}case\"BraceExpansion\":{let n=[];for(let a of t.items)if(a.type===\"Range\"){let i=At(a.start,a.end,a.step,a.startStr,a.endStr);if(i.expanded)n.push(...i.expanded);else return i.literal}else n.push(await Pt(e,a.word));return n.join(\" \")}default:return\"\"}}async function Ve(e,t,r=!1){let{parameter:s}=t,{operation:n}=t,a=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(a){let[,h,d]=a;if(e.state.associativeArrays?.has(h)||d.includes(\"$(\")||d.includes(\"`\")||d.includes(\"${\")){let g=await Et(e,d);s=`${h}[${g}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)&&W(e,s)){let h=he(e,s);if(h&&h!==s){let d=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(d){let[,m,g]=d;if(e.state.associativeArrays?.has(m)||g.includes(\"$(\")||g.includes(\"`\")||g.includes(\"${\")){let A=await Et(e,g);s=`${m}[${A}]`}}}}let i=n&&(n.type===\"DefaultValue\"||n.type===\"AssignDefault\"||n.type===\"UseAlternative\"||n.type===\"ErrorIfUnset\"),l=await v(e,s,!i);if(!n)return l;let o=!await te(e,s),{isEmpty:c,effectiveValue:u}=Wn(e,s,l,r),f={value:l,isUnset:o,isEmpty:c,effectiveValue:u,inDoubleQuotes:r};switch(n.type){case\"DefaultValue\":return Nn(e,n,f,J);case\"AssignDefault\":return kn(e,s,n,f,J);case\"ErrorIfUnset\":return Pn(e,s,n,f,J);case\"UseAlternative\":return Rn(e,n,f,J);case\"PatternRemoval\":{let h=await In(e,l,n,J,U);return ce(h,e.limits.maxStringLength,\"pattern removal\"),h}case\"PatternReplacement\":{let h=await vn(e,l,n,J,U);return ce(h,e.limits.maxStringLength,\"pattern replacement\"),h}case\"Length\":return Dn(e,s,l);case\"LengthSliceError\":throw new re(s);case\"BadSubstitution\":throw new re(n.text);case\"Substring\":return xn(e,s,l,n);case\"CaseModification\":{let h=await _n(e,l,n,J,Ve);return ce(h,e.limits.maxStringLength,\"case modification\"),h}case\"Transform\":return $n(e,s,l,o,n);case\"Indirection\":return Cn(e,s,l,o,n,Ve,r);case\"ArrayKeys\":return On(e,n);case\"VarNamePrefix\":return Ln(e,n);default:return l}}export{xi as a,_i as b,pe as c,G as d,M as e,V as f,di as g,mt as h,Ci as i,gt as j,Oi as k,En as l,T as m,Wi as n,Ti as o,W as p,Vi as q,qi as r,Bi as s,Fi as t,us as u,he as v,Se as w,zi as x,P as y,be as z,v as A,X as B,bt as C,pa as D,wt as E,da as F,ma as G,ga as H,Al as I,Pt as J,Sl as K,bl as L,wl as M,Fs as N,Nl as O,R as P};\n","import { join, relative, sep } from \"node:path\";\nimport { readdir, stat } from \"node:fs/promises\";\nimport { readFileSync } from \"node:fs\";\n//#region src/discovery/entry-from-file.ts\nconst SOURCE_EXT = /\\.(ts|mts|mjs|js)$/;\nconst DECLARATION_FILE$1 = /\\.d\\.(ts|mts|cts)$/;\nfunction entryIdFromFile(rootDir, filePath, options) {\n\tif (DECLARATION_FILE$1.test(filePath)) return null;\n\tconst baseName = filePath.split(sep).at(-1) ?? \"\";\n\tif (/\\.(int\\.)?test\\.(ts|mts)$/.test(baseName)) return null;\n\tconst segments = relative(rootDir, filePath).replace(SOURCE_EXT, \"\").split(sep).filter((segment) => segment.length > 0);\n\tif (segments.length === 1) return segments[0] ?? null;\n\tconst last = segments.at(-1);\n\tconst entryNames = new Set([options.nestedEntry]);\n\tif (options.allowIndex !== false) entryNames.add(\"index\");\n\tif (!last || !entryNames.has(last)) return null;\n\tconst id = segments.slice(0, -1).join(\"/\");\n\treturn id.length > 0 ? id : null;\n}\n//#endregion\n//#region src/discovery/walk-typescript-files.ts\nconst SOURCE_FILE = /\\.(ts|mts|mjs|js)$/;\nconst TEST_FILE = /\\.(int\\.)?test\\.(ts|mts)$/;\nconst DECLARATION_FILE = /\\.d\\.(ts|mts|cts)$/;\nconst JUNK_FILE = /^\\._|\\.DS_Store$/;\nasync function walkTypeScriptFiles(dir) {\n\tlet names;\n\ttry {\n\t\tnames = await readdir(dir);\n\t} catch (error) {\n\t\tif (error.code === \"ENOENT\") return [];\n\t\tthrow error;\n\t}\n\tconst files = [];\n\tfor (const name of names) {\n\t\tconst path = join(dir, name);\n\t\tif ((await stat(path)).isDirectory()) files.push(...await walkTypeScriptFiles(path));\n\t\telse if (!JUNK_FILE.test(name) && SOURCE_FILE.test(name) && !DECLARATION_FILE.test(name) && !TEST_FILE.test(name)) files.push(path);\n\t}\n\treturn files;\n}\n//#endregion\n//#region src/discovery/discover-entries.ts\nasync function discoverEntries(rootDir, options) {\n\tconst files = await walkTypeScriptFiles(rootDir);\n\tconst byKey = /* @__PURE__ */ new Map();\n\tfor (const filePath of files) {\n\t\tconst id = entryIdFromFile(rootDir, filePath, options);\n\t\tif (!id) continue;\n\t\tconst key = options.formatKey(id);\n\t\tconst moduleFile = relative(rootDir, filePath);\n\t\tconst existing = byKey.get(key);\n\t\tif (existing) throw new Error(`Duplicate ${options.duplicateLabel} ${key}: ${existing.filePath} and ${filePath}`);\n\t\tbyKey.set(key, {\n\t\t\tkey,\n\t\t\tfilePath,\n\t\t\tmoduleFile\n\t\t});\n\t}\n\treturn [...byKey.values()];\n}\n//#endregion\n//#region src/discovery/discover-module-entries.ts\nasync function discoverModuleFileEntries(rootDir, options) {\n\treturn (await discoverEntries(rootDir, {\n\t\tnestedEntry: options.nestedEntry,\n\t\tformatKey: (id) => id,\n\t\tduplicateLabel: options.duplicateLabel\n\t})).filter((entry) => options.shouldDiscoverFile?.(entry.filePath) ?? true).map(({ filePath, moduleFile }) => ({\n\t\tfilePath,\n\t\tmoduleFile\n\t}));\n}\nfunction moduleFileKeyFromPath(rootDir, filePath, nestedEntry) {\n\treturn entryIdFromFile(rootDir, filePath, { nestedEntry });\n}\n//#endregion\n//#region src/discovery/keystroke-ignore-directive.ts\nconst HEADER_BYTES = 2048;\nconst DIRECTIVE_RE = /@keystroke\\s+ignore(?::([a-z]+))?/;\n/** Parse `@keystroke ignore` directives from a file header snippet. */\nfunction parseKeystrokeIgnoreDirective(header) {\n\tfor (const line of header.slice(0, HEADER_BYTES).split(\"\\n\")) {\n\t\tconst trimmed = line.trim();\n\t\tif (trimmed.length === 0) continue;\n\t\tif (!isCommentLine(trimmed)) break;\n\t\tconst match = DIRECTIVE_RE.exec(trimmed);\n\t\tif (!match) continue;\n\t\tconst scope = match[1];\n\t\tif (!scope) return \"ignore\";\n\t\tif (scope === \"deploy\") return \"ignore:deploy\";\n\t\tthrow new Error(`Unknown @keystroke ignore target \"${scope}\" in directive \"@keystroke ignore:${scope}\"`);\n\t}\n\treturn null;\n}\n/** Read `@keystroke ignore` directives from the top of a module file. */\nfunction readKeystrokeIgnoreDirective(filePath) {\n\treturn parseKeystrokeIgnoreDirective(readFileSync(filePath, \"utf8\").slice(0, HEADER_BYTES));\n}\n/** Whether a discovered module file should be skipped for the given build phase. */\nfunction shouldSkipKeystrokeModuleFile(directive, phase) {\n\tif (!directive) return false;\n\tif (directive === \"ignore\") return true;\n\treturn phase === \"deploy\";\n}\nfunction isCommentLine(line) {\n\treturn line.startsWith(\"//\") || line.startsWith(\"/*\") || line.startsWith(\"*\");\n}\n//#endregion\n//#region src/discovery/validate-unique-module-keys.ts\nfunction validateUniqueModuleKeys(entries) {\n\tconst byKey = /* @__PURE__ */ new Map();\n\tfor (const entry of entries) {\n\t\tconst list = byKey.get(entry.key) ?? [];\n\t\tlist.push(entry);\n\t\tbyKey.set(entry.key, list);\n\t}\n\tfor (const [key, clashes] of byKey) {\n\t\tif (clashes.length <= 1) continue;\n\t\tconst detail = clashes.map((entry) => `${entry.kind} (${entry.filePath})`).join(\", \");\n\t\tthrow new Error(`Duplicate module key \"${key}\": ${detail}`);\n\t}\n}\n//#endregion\nexport { discoverModuleFileEntries as a, walkTypeScriptFiles as c, shouldSkipKeystrokeModuleFile as i, entryIdFromFile as l, parseKeystrokeIgnoreDirective as n, moduleFileKeyFromPath as o, readKeystrokeIgnoreDirective as r, discoverEntries as s, validateUniqueModuleKeys as t };\n\n//# sourceMappingURL=discovery-CWjr_liZ.mjs.map","import { a as writeWorkspaceFileIfAbsent, n as resolveAgentRoot, t as ensureWorkspaceDir } from \"./sandbox-dirs-DMDj1_61.mjs\";\nimport { createRequire } from \"node:module\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/files/schemas.ts\nconst SandboxModeSchema = z.enum([\"in-process\", \"vm\"]);\nconst SandboxFileContentSchema = z.object({\n\tpath: z.string(),\n\tfile: z.string()\n});\n/** Destination path under `/workspace`. For `dir`, used as a prefix. */\nconst SandboxFileSchema = z.object({\n\tpath: z.string(),\n\t/** Single file body — typically from a build-time import (`import doc from \"./doc.md\"`). */\n\tfile: z.string().optional(),\n\t/** Directory contents — each path is relative to `path`. */\n\tdir: z.array(SandboxFileContentSchema).optional()\n});\n/** Author-facing project file set reference under `src/files/`. */\nconst SandboxProjectFilesSchema = z.union([z.literal(true), z.string()]);\n/** Author-facing sandbox files: inline entries or a project file set. */\nconst SandboxFilesInputSchema = z.union([z.array(SandboxFileSchema), SandboxProjectFilesSchema]);\n/** Author-facing sandbox definition (`defineSandbox`, agent `sandbox`). */\nconst SandboxDefinitionInputSchema = z.object({\n\tkey: z.string().optional(),\n\t/** Sandbox execution mode. Defaults to in-process when omitted. */\n\tmode: SandboxModeSchema.optional(),\n\tfiles: SandboxFilesInputSchema.optional()\n});\n/** Normalized sandbox definition after project file sets are resolved. */\nconst SandboxDefinitionSchema = z.object({\n\tkey: z.string().optional(),\n\tmode: SandboxModeSchema.optional(),\n\tfiles: z.array(SandboxFileSchema).optional()\n});\n//#endregion\n//#region src/files/define-sandbox.ts\n/** Define a reusable sandbox file layout. */\nfunction defineSandbox(def) {\n\treturn def;\n}\n//#endregion\n//#region src/files/flatten-sandbox-files.ts\n/** Expand directory entries into flat `{ path, file }` records under `/workspace`. */\nfunction flattenSandboxFiles(files) {\n\tif (!files?.length) return [];\n\tconst flattened = [];\n\tfor (const entry of files) {\n\t\tif (entry.dir !== void 0) {\n\t\t\tconst prefix = entry.path.replace(/\\/+$/, \"\");\n\t\t\tfor (const child of entry.dir) flattened.push({\n\t\t\t\tpath: prefix ? `${prefix}/${child.path}` : child.path,\n\t\t\t\tfile: child.file\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.file === void 0) continue;\n\t\tflattened.push({\n\t\t\tpath: entry.path,\n\t\t\tfile: entry.file\n\t\t});\n\t}\n\treturn flattened;\n}\n//#endregion\n//#region src/files/materialize-sandbox.ts\nasync function materializeSandbox(options) {\n\tconst root = resolveAgentRoot(options.workspacesRoot, options.agentId);\n\tawait ensureWorkspaceDir(root);\n\tconst files = flattenSandboxFiles(options.definition?.files);\n\tif (files.length) await applySandboxFiles(root, files);\n\treturn {\n\t\troot,\n\t\tagentId: options.agentId,\n\t\t...options.definition !== void 0 ? { definition: options.definition } : {}\n\t};\n}\nasync function applySandboxFiles(root, files) {\n\tfor (const entry of files) await writeWorkspaceFileIfAbsent(resolve(root, entry.path), entry.file);\n}\n//#endregion\n//#region src/files/pack-dir.ts\nconst SKIP_DIRS$1 = new Set([\".git\", \"node_modules\"]);\n/** Recursively read a host file or directory into sandbox-relative `{ path, file }` entries. */\nfunction packDirFromDisk(rootPath) {\n\tconst stat = statSync(rootPath);\n\tif (stat.isFile()) return [{\n\t\tpath: basename(rootPath),\n\t\tfile: readFileSync(rootPath, \"utf8\")\n\t}];\n\tif (!stat.isDirectory()) throw new Error(`Expected a file or directory at ${rootPath}`);\n\tconst files = [];\n\twalkDir(rootPath, rootPath, files);\n\treturn files;\n}\nfunction walkDir(rootPath, currentPath, files) {\n\tfor (const name of readdirSync(currentPath)) {\n\t\tif (SKIP_DIRS$1.has(name)) continue;\n\t\tconst entryPath = join(currentPath, name);\n\t\tconst stat = statSync(entryPath);\n\t\tif (stat.isDirectory()) {\n\t\t\twalkDir(rootPath, entryPath, files);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stat.isFile()) continue;\n\t\tfiles.push({\n\t\t\tpath: relative(rootPath, entryPath),\n\t\t\tfile: readFileSync(entryPath, \"utf8\")\n\t\t});\n\t}\n}\n//#endregion\n//#region src/files/pack-asset-dirs.ts\nconst SKIP_DIRS = new Set([\".git\", \"node_modules\"]);\n/** Pack every subdir under `src/skills/` and `src/files/` into an asset manifest. */\nfunction packAssetDirs(appRoot, srcDir = \"src\") {\n\treturn {\n\t\tskills: packAssetRoot(join(appRoot, srcDir, \"skills\")),\n\t\tfiles: packAssetRoot(join(appRoot, srcDir, \"files\"))\n\t};\n}\nfunction packAssetRoot(rootPath) {\n\tif (!statSync(rootPath, { throwIfNoEntry: false })?.isDirectory()) return {};\n\tconst manifest = {};\n\tfor (const name of readdirSync(rootPath)) {\n\t\tif (SKIP_DIRS.has(name)) continue;\n\t\tconst entryPath = join(rootPath, name);\n\t\tif (!statSync(entryPath).isDirectory()) continue;\n\t\tmanifest[name] = packDirFromDisk(entryPath);\n\t}\n\treturn manifest;\n}\n//#endregion\n//#region src/files/app-root-scope.ts\nconst appRootStorage = new AsyncLocalStorage();\n/** Run with an explicit user-app root (parallel-safe alternative to mutating `KEYSTROKE_ROOT`). */\nfunction runWithAppRoot(appRoot, fn) {\n\treturn appRootStorage.run(appRoot, fn);\n}\nfunction getBoundAppRoot() {\n\treturn appRootStorage.getStore();\n}\n//#endregion\n//#region src/files/resolve-sandbox-definition.ts\nfunction parseAssetModule(source) {\n\tconst trimmed = source.trim();\n\tif (!trimmed.startsWith(\"export default \")) return null;\n\tconst json = trimmed.slice(15).replace(/;\\s*$/, \"\");\n\treturn JSON.parse(json);\n}\nfunction loadBuiltManifest(appRoot) {\n\tconst candidates = [\n\t\tjoin(appRoot, \"dist/.keystroke/assets.mjs\"),\n\t\tjoin(appRoot, \"dist/.agent/assets.mjs\"),\n\t\tjoin(appRoot, \".keystroke/assets.mjs\"),\n\t\tjoin(appRoot, \".agent/assets.mjs\")\n\t];\n\tfor (const candidate of candidates) {\n\t\tif (!existsSync(candidate)) continue;\n\t\ttry {\n\t\t\tconst fromSource = parseAssetModule(readFileSync(candidate, \"utf8\"));\n\t\t\tif (fromSource) return fromSource;\n\t\t} catch {}\n\t\ttry {\n\t\t\tconst mod = createRequire(join(appRoot, \"package.json\"))(candidate);\n\t\t\treturn mod.default ?? mod;\n\t\t} catch {}\n\t}\n\treturn null;\n}\nfunction loadAssetManifest(appRoot) {\n\treturn loadBuiltManifest(appRoot) ?? packAssetDirs(appRoot);\n}\nfunction resolveProjectSetKey(set, options) {\n\tif (set === true) {\n\t\tconst projectSlug = options.projectSlug?.trim();\n\t\tif (!projectSlug) throw new Error(\"sandbox files: true requires a project slug at resolve time (e.g. defineAgent({ slug: \\\"support\\\", sandbox: defineSandbox({ files: true }) }))\");\n\t\treturn projectSlug;\n\t}\n\treturn set;\n}\nfunction loadProjectFileSet(set, options) {\n\tconst setKey = resolveProjectSetKey(set, options);\n\tconst files = loadAssetManifest(options.appRoot ?? getBoundAppRoot() ?? process.env.KEYSTROKE_ROOT ?? process.cwd()).files[setKey];\n\tif (!files?.length) throw new Error(`Unknown file set \"${setKey}\" — expected src/files/${setKey}/`);\n\treturn files.map((entry) => ({\n\t\tpath: entry.path,\n\t\tfile: entry.file\n\t}));\n}\nfunction resolveSandboxFiles(files, options) {\n\tif (files === void 0) return;\n\tif (Array.isArray(files)) return files;\n\treturn loadProjectFileSet(files, options);\n}\n/** Resolve author sandbox input into a normalized definition for materialization/runtime. */\nfunction resolveSandboxDefinition(input, options = {}) {\n\tconst resolvedFiles = resolveSandboxFiles(input.files, options);\n\treturn {\n\t\t...input.key !== void 0 ? { key: input.key } : {},\n\t\t...input.mode !== void 0 ? { mode: input.mode } : {},\n\t\t...resolvedFiles !== void 0 ? { files: resolvedFiles } : {}\n\t};\n}\n//#endregion\n//#region src/files/resolve-app-root.ts\n/** Walk upward from a module file to find the user app root (`src/agents`, `src/skills`, etc.). */\nfunction resolveAppRoot(fromPath) {\n\tlet dir = statSync(fromPath).isDirectory() ? fromPath : dirname(fromPath);\n\twhile (dir !== dirname(dir)) {\n\t\tif (hasAppLayout(dir)) return dir;\n\t\tdir = dirname(dir);\n\t}\n\treturn process.env.KEYSTROKE_ROOT ?? process.cwd();\n}\n/** Resolve app root from an agent (or other) module URL. */\nfunction resolveAppRootFromModule(moduleUrl) {\n\treturn resolveAppRoot(fileURLToPath(moduleUrl));\n}\nfunction hasAppLayout(dir) {\n\tconst src = join(dir, \"src\");\n\tconst dist = join(dir, \"dist\");\n\treturn existsSync(join(src, \"agents\")) || existsSync(join(src, \"skills\")) || existsSync(join(src, \"files\")) || existsSync(join(dist, \"agents\")) || existsSync(join(dist, \".keystroke\", \"assets.mjs\"));\n}\n//#endregion\nexport { SandboxModeSchema as _, getBoundAppRoot as a, packDirFromDisk as c, defineSandbox as d, SandboxDefinitionInputSchema as f, SandboxFilesInputSchema as g, SandboxFileSchema as h, resolveSandboxDefinition as i, materializeSandbox as l, SandboxFileContentSchema as m, resolveAppRootFromModule as n, runWithAppRoot as o, SandboxDefinitionSchema as p, loadAssetManifest as r, packAssetDirs as s, resolveAppRoot as t, flattenSandboxFiles as u, SandboxProjectFilesSchema as v };\n\n//# sourceMappingURL=files-BOUCjfCQ.mjs.map","/** TypeBox instantiation metrics */\nexport const Metrics = {\n assign: 0,\n create: 0,\n clone: 0,\n discard: 0,\n update: 0\n};\n","import * as String from './string.mjs';\n// --------------------------------------------------------------------------\n// Guards\n// --------------------------------------------------------------------------\n/** Returns true if this value is an array */\nexport function IsArray(value) {\n return Array.isArray(value);\n}\n/** Returns true if this value is an async iterator */\nexport function IsAsyncIterator(value) {\n return IsObject(value) && Symbol.asyncIterator in value;\n}\n/** Returns true if this value is bigint */\nexport function IsBigInt(value) {\n return IsEqual(typeof value, 'bigint');\n}\n/** Returns true if this value is a boolean */\nexport function IsBoolean(value) {\n return IsEqual(typeof value, 'boolean');\n}\n/** Returns true if this value is a constructor */\nexport function IsConstructor(value) {\n if (IsUndefined(value) || !IsFunction(value))\n return false;\n const result = Function.prototype.toString.call(value);\n if (/^class\\s/.test(result))\n return true;\n if (/\\[native code\\]/.test(result))\n return true;\n return false;\n}\n/** Returns true if this value is a function */\nexport function IsFunction(value) {\n return IsEqual(typeof value, 'function');\n}\n/** Returns true if this value is integer */\nexport function IsInteger(value) {\n return Number.isInteger(value);\n}\n/** Returns true if this value is an iterator */\nexport function IsIterator(value) {\n return IsObject(value) && Symbol.iterator in value;\n}\n/** Returns true if this value is null */\nexport function IsNull(value) {\n return IsEqual(value, null);\n}\n/** Returns true if this value is number */\nexport function IsNumber(value) {\n return Number.isFinite(value);\n}\n/** Returns true if this value is an object but not an array */\nexport function IsObjectNotArray(value) {\n return IsObject(value) && !IsArray(value);\n}\n/** Returns true if this value is an object */\nexport function IsObject(value) {\n return IsEqual(typeof value, 'object') && !(IsNull(value));\n}\n/** Returns true if this value is string */\nexport function IsString(value) {\n return IsEqual(typeof value, 'string');\n}\n/** Returns true if this value is symbol */\nexport function IsSymbol(value) {\n return IsEqual(typeof value, 'symbol');\n}\n/** Returns true if this value is undefined */\nexport function IsUndefined(value) {\n return IsEqual(value, undefined);\n}\n// --------------------------------------------------------------------------\n// Relational\n// --------------------------------------------------------------------------\nexport function IsEqual(left, right) {\n return left === right;\n}\nexport function IsGreaterThan(left, right) {\n return left > right;\n}\nexport function IsLessThan(left, right) {\n return left < right;\n}\nexport function IsLessEqualThan(left, right) {\n return left <= right;\n}\nexport function IsGreaterEqualThan(left, right) {\n return left >= right;\n}\n// --------------------------------------------------------------------------\n// MultipleOf\n// --------------------------------------------------------------------------\nexport function IsMultipleOf(dividend, divisor) {\n if (IsBigInt(dividend) || IsBigInt(divisor)) {\n return BigInt(dividend) % BigInt(divisor) === 0n;\n }\n const tolerance = 1e-10;\n if (!IsNumber(dividend))\n return true;\n if (IsInteger(dividend) && (1 / divisor) % 1 === 0)\n return true;\n const mod = dividend % divisor;\n return Math.min(Math.abs(mod), Math.abs(mod - divisor)) < tolerance;\n}\n// ------------------------------------------------------------------\n// IsClassInstance\n// ------------------------------------------------------------------\n/** Returns true if the value appears to be an instance of a class. */\nexport function IsClassInstance(value) {\n if (!IsObject(value))\n return false;\n const proto = globalThis.Object.getPrototypeOf(value);\n if (IsNull(proto))\n return false;\n return IsEqual(typeof proto.constructor, 'function') &&\n !(IsEqual(proto.constructor, globalThis.Object) ||\n IsEqual(proto.constructor.name, 'Object'));\n}\n// ------------------------------------------------------------------\n// IsValueLike\n// ------------------------------------------------------------------\nexport function IsValueLike(value) {\n return IsBigInt(value) ||\n IsBoolean(value) ||\n IsNull(value) ||\n IsNumber(value) ||\n IsString(value) ||\n IsUndefined(value);\n}\n// --------------------------------------------------------------------------\n// String\n// --------------------------------------------------------------------------\n/** Returns the number of grapheme clusters in the string */\nexport function GraphemeCount(value) {\n return String.GraphemeCount(value);\n}\n/** Returns true if the string has at most the given number of graphemes */\nexport function IsMaxLength(value, length) {\n return String.IsMaxLengthFast(value, length);\n}\n/** Returns true if the string has at least the given number of graphemes */\nexport function IsMinLength(value, length) {\n return String.IsMinLengthFast(value, length);\n}\n// --------------------------------------------------------------------------\n// Array\n// --------------------------------------------------------------------------\n/** Returns true if all elements from offset satisfy the callback, short-circuiting on the first failure */\nexport function Every(value, offset, callback) {\n for (let index = offset; index < value.length; index++) {\n if (!callback(value[index], index))\n return false;\n }\n return true;\n}\n/** Returns true if all elements from offset satisfy the callback, visiting every element regardless of failure */\nexport function EveryAll(value, offset, callback) {\n let result = true;\n for (let index = offset; index < value.length; index++) {\n if (!callback(value[index], index))\n result = false;\n }\n return result;\n}\n/** Takes the left-most element from an array and dispatches to the true arm, or the false arm if empty */\nexport function TakeLeft(array, true_, false_) {\n return (IsEqual(array.length, 0) ? false_() : true_(array[0], array.slice(1)));\n}\n// --------------------------------------------------------------------------\n// Object\n// --------------------------------------------------------------------------\n/** Returns true if the PropertyKey is Unsafe (ref: prototype-pollution). */\nexport function IsUnsafePropertyKey(key) {\n return IsEqual(key, '__proto__') || IsEqual(key, 'constructor') || IsEqual(key, 'prototype');\n}\n/** Returns true if this value has this property key */\nexport function HasPropertyKey(value, key) {\n return IsUnsafePropertyKey(key) ? Object.prototype.hasOwnProperty.call(value, key) : key in value;\n}\n/** Returns object entries as `[RegExp, Value][]` */\nexport function EntriesRegExp(value) {\n return Keys(value).map((key) => [new RegExp(`^${key}$`), value[key]]);\n}\n/** Returns object entries as `[string, Value][]` */\nexport function Entries(value) {\n return Object.entries(value);\n}\n/** Returns property keys for this object via `Object.getOwnPropertyKeys({ ... })` */\nexport function Keys(value) {\n return Object.getOwnPropertyNames(value);\n}\n/** Returns the property keys for this object via `Object.getOwnPropertyKeys({ ... })` */\nexport function Symbols(value) {\n return Object.getOwnPropertySymbols(value);\n}\n/** Returns the property values for the given object via `Object.values()` */\nexport function Values(value) {\n return Object.values(value);\n}\n// ------------------------------------------------------------------\n// IsDeepEqual\n// ------------------------------------------------------------------\nfunction DeepEqualObject(left, right) {\n if (!IsObject(right))\n return false;\n const keys = Keys(left);\n return IsEqual(keys.length, Keys(right).length) &&\n keys.every((key) => IsDeepEqual(left[key], right[key]));\n}\nfunction DeepEqualArray(left, right) {\n return IsArray(right) && IsEqual(left.length, right.length) &&\n left.every((_, index) => IsDeepEqual(left[index], right[index]));\n}\n/** Tests values for deep equality */\nexport function IsDeepEqual(left, right) {\n return (IsArray(left) ? DeepEqualArray(left, right) : IsObject(left) ? DeepEqualObject(left, right) : IsEqual(left, right));\n}\n","// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\nimport { Metrics } from './metrics.mjs';\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\nfunction IsGuard(value) {\n return Guard.IsObject(value) && Guard.HasPropertyKey(value, '~guard');\n}\nfunction FromGuard(value) {\n return value; // non-clonable\n}\n// ------------------------------------------------------------------\n// Array\n// ------------------------------------------------------------------\nfunction FromArray(value) {\n return value.map((value) => FromValue(value));\n}\n// ------------------------------------------------------------------\n// Object\n// ------------------------------------------------------------------\nfunction FromObject(value) {\n const result = {};\n const descriptors = Object.getOwnPropertyDescriptors(value);\n for (const key of Object.keys(descriptors)) {\n const descriptor = descriptors[key];\n if (Guard.HasPropertyKey(descriptor, 'value')) {\n Object.defineProperty(result, key, { ...descriptor, value: FromValue(descriptor.value) });\n }\n }\n return result;\n}\n// ------------------------------------------------------------------\n// RegExp\n// ------------------------------------------------------------------\nfunction FromRegExp(value) {\n return new RegExp(value.source, value.flags);\n}\n// ------------------------------------------------------------------\n// RegExp\n// ------------------------------------------------------------------\nfunction FromUnknown(value) {\n return value;\n}\n// ------------------------------------------------------------------\n// Value\n// ------------------------------------------------------------------\nfunction FromValue(value) {\n return (value instanceof RegExp ? FromRegExp(value) :\n IsGuard(value) ? FromGuard(value) :\n Guard.IsArray(value) ? FromArray(value) :\n Guard.IsObject(value) ? FromObject(value) :\n FromUnknown(value));\n}\n/**\n * Clones a value using the TypeBox type cloning strategy. This function preserves non-enumerable\n * properties from the source value. This is to ensure cloned types retain discriminable\n * hidden properties.\n */\nexport function Clone(value) {\n Metrics.clone += 1;\n return FromValue(value);\n}\n","import { Guard } from '../../guard/index.mjs';\n// Internal mutable state\nconst settings = {\n immutableTypes: false,\n maxErrors: 8,\n useAcceleration: true,\n exactOptionalPropertyTypes: false,\n enumerableKind: false,\n correctiveParse: false\n};\n/** Resets system settings to defaults */\nexport function Reset() {\n settings.immutableTypes = false;\n settings.maxErrors = 8;\n settings.useAcceleration = true;\n settings.exactOptionalPropertyTypes = false;\n settings.enumerableKind = false;\n settings.correctiveParse = false;\n}\n/** Sets system settings */\nexport function Set(options) {\n for (const key of Guard.Keys(options)) {\n const value = options[key];\n if (value !== undefined) {\n Object.defineProperty(settings, key, { value });\n }\n }\n}\n/** Gets current system settings */\nexport function Get() {\n return settings;\n}\n","// deno-lint-ignore-file no-explicit-any\n// deno-fmt-ignore-file\nimport { Settings } from '../settings/index.mjs';\nimport { Metrics } from './metrics.mjs';\nfunction MergeHidden(left, right) {\n for (const key of Object.keys(right)) {\n Object.defineProperty(left, key, {\n configurable: true,\n writable: true,\n enumerable: false,\n value: right[key]\n });\n }\n return left;\n}\nfunction Merge(left, right) {\n return { ...left, ...right };\n}\n/**\n * Creates an object with hidden, enumerable, and optional property sets. This function\n * ensures types are instantiated according to configuration rules for enumerable and\n * non-enumerable properties.\n */\nexport function Create(hidden, enumerable, options = {}) {\n Metrics.create += 1;\n const settings = Settings.Get();\n const withOptions = Merge(enumerable, options);\n const withHidden = settings.enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);\n return settings.immutableTypes ? Object.freeze(withHidden) : withHidden;\n}\n","// deno-fmt-ignore-file\nimport { Settings } from '../settings/index.mjs';\nimport { Metrics } from './metrics.mjs';\nimport { Clone } from './clone.mjs';\n/**\n * Updates a value with new properties while preserving property enumerability. Use this function to modify\n * existing types without altering their configuration.\n */\nexport function Update(current, hidden, enumerable) {\n Metrics.update += 1;\n const settings = Settings.Get();\n const result = Clone(current);\n // hidden\n for (const key of Object.keys(hidden)) {\n Object.defineProperty(result, key, {\n configurable: true,\n writable: true,\n enumerable: settings.enumerableKind,\n value: hidden[key]\n });\n }\n // enumerable\n for (const key of Object.keys(enumerable)) {\n Object.defineProperty(result, key, {\n configurable: true,\n enumerable: true,\n writable: true,\n value: enumerable[key]\n });\n }\n return result;\n}\n","// deno-lint-ignore-file\n// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\n// ------------------------------------------------------------------\n// Kind\n// ------------------------------------------------------------------\nexport function IsKind(value, kind) {\n return Guard.IsObject(value) && Guard.HasPropertyKey(value, '~kind') && Guard.IsEqual(value[\"~kind\"], kind);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\nexport function IsSchema(value) {\n return Guard.IsObject(value);\n}\n","// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsSchema } from './schema.mjs';\n/** Removes Optional from the given type. */\nexport function OptionalRemove(type) {\n const result = Memory.Discard(type, ['~optional']);\n return result;\n}\n/** Adds Optional to the given type. */\nexport function OptionalAdd(type) {\n return Memory.Update(type, { '~optional': true }, {});\n}\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Applies an Optional modifier to the given type. */\nexport function Optional(type) {\n return OptionalAdd(type);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TOptional */\nexport function IsOptional(value) {\n return IsSchema(value) && Guard.HasPropertyKey(value, '~optional');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates an Array type. */\nexport function _Array_(items, options) {\n return Memory.Create({ '~kind': 'Array' }, { type: 'array', items }, options);\n}\nexport { _Array_ as Array }; // Prevent Collision With Global Scope\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is a TArray. */\nexport function IsArray(value) {\n return IsKind(value, 'Array');\n}\n// ------------------------------------------------------------------\n// Options\n// ------------------------------------------------------------------\n/** Extracts options from a TArray. */\nexport function ArrayOptions(type) {\n return Memory.Discard(type, ['~kind', 'type', 'items']);\n}\n","// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\nimport { IsOptional } from './_optional.mjs';\n/** Creates a RequiredArray derived from the given TProperties value. */\nexport function RequiredArray(properties) {\n return Guard.Keys(properties).filter((key) => !IsOptional(properties[key]));\n}\n/** Extracts a tuple of keys from a TProperties value. */\nexport function PropertyKeys(properties) {\n return Guard.Keys(properties);\n}\n/** Extracts a tuple of property values from a TProperties value. */\nexport function PropertyValues(properties) {\n return Guard.Values(properties);\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\nimport { RequiredArray } from './properties.mjs';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates an Object type. */\nexport function _Object_(properties, options = {}) {\n const requiredKeys = RequiredArray(properties);\n const required = requiredKeys.length > 0 ? { required: requiredKeys } : {};\n return Memory.Create({ '~kind': 'Object' }, { type: 'object', ...required, properties }, options);\n}\nexport { _Object_ as Object }; // Prevent Collision With Global Scope\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TObject. */\nexport function IsObject(value) {\n return IsKind(value, 'Object');\n}\n// ------------------------------------------------------------------\n// Options\n// ------------------------------------------------------------------\n/** Extracts options from a TObject. */\nexport function ObjectOptions(type) {\n return Memory.Discard(type, ['~kind', 'type', 'properties', 'required']);\n}\n","// deno-fmt-ignore-file\nimport { Unreachable } from '../unreachable/index.mjs';\nimport { Guard, GlobalsGuard } from '../../guard/index.mjs';\n// ------------------------------------------------------------------\n// InstanceKeys\n//\n// Retrieves all enumerable and non-enumerable own property keys \n// and inherited prototype keys (excluding symbols and the 'constructor') \n// from an object instance.\n//\n// This function is useful for differentiating between class instances \n// based on their structural keys rather than relying on the \n// constructor name. It provides a more reliable structural comparison \n// by capturing both own and prototype properties.\n//\n// ------------------------------------------------------------------\nfunction InstanceKeys(value) {\n const propertyKeys = new Set();\n let current = value;\n while (current && current !== Object.prototype) {\n for (const key of Reflect.ownKeys(current)) {\n if (key !== 'constructor' && typeof key !== 'symbol')\n propertyKeys.add(key);\n }\n current = Object.getPrototypeOf(current);\n }\n return [...propertyKeys];\n}\n// ------------------------------------------------------------------\n// IsIEEE754\n//\n// TypeBox guards do not consider +/- Infinity or NaN as valid\n// numbers, but they are valid IEEE754 numbers. We use a special\n// guard to ensure these numbers are considered for hashing.\n//\n// ------------------------------------------------------------------\nfunction IsIEEE754(value) {\n return typeof value === 'number';\n}\n// ------------------------------------------------------------------\n// ByteMarker\n// ------------------------------------------------------------------\nvar ByteMarker;\n(function (ByteMarker) {\n ByteMarker[ByteMarker[\"Array\"] = 0] = \"Array\";\n ByteMarker[ByteMarker[\"BigInt\"] = 1] = \"BigInt\";\n ByteMarker[ByteMarker[\"Boolean\"] = 2] = \"Boolean\";\n ByteMarker[ByteMarker[\"Date\"] = 3] = \"Date\";\n ByteMarker[ByteMarker[\"Constructor\"] = 4] = \"Constructor\";\n ByteMarker[ByteMarker[\"Function\"] = 5] = \"Function\";\n ByteMarker[ByteMarker[\"Null\"] = 6] = \"Null\";\n ByteMarker[ByteMarker[\"Number\"] = 7] = \"Number\";\n ByteMarker[ByteMarker[\"Object\"] = 8] = \"Object\";\n ByteMarker[ByteMarker[\"RegExp\"] = 9] = \"RegExp\";\n ByteMarker[ByteMarker[\"String\"] = 10] = \"String\";\n ByteMarker[ByteMarker[\"Symbol\"] = 11] = \"Symbol\";\n ByteMarker[ByteMarker[\"TypeArray\"] = 12] = \"TypeArray\";\n ByteMarker[ByteMarker[\"Undefined\"] = 13] = \"Undefined\";\n})(ByteMarker || (ByteMarker = {}));\n// ------------------------------------------------------------------\n// State\n// ------------------------------------------------------------------\nlet Accumulator = BigInt('14695981039346656037');\nconst [Prime, Size] = [BigInt('1099511628211'), BigInt('18446744073709551616' /* 2 ^ 64 */)];\nconst Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i));\nconst F64 = new Float64Array(1);\nconst F64In = new DataView(F64.buffer);\nconst F64Out = new Uint8Array(F64.buffer);\n// ------------------------------------------------------------------\n// Operation\n// ------------------------------------------------------------------\nfunction FNV1A64_OP(byte) {\n Accumulator = Accumulator ^ Bytes[byte];\n Accumulator = (Accumulator * Prime) % Size;\n}\n// ------------------------------------------------------------------\n// Array\n// ------------------------------------------------------------------\nfunction FromArray(value) {\n FNV1A64_OP(ByteMarker.Array);\n for (const item of value) {\n FromValue(item);\n }\n}\n// ------------------------------------------------------------------\n// BigInt\n// ------------------------------------------------------------------\nfunction FromBigInt(value) {\n FNV1A64_OP(ByteMarker.BigInt);\n F64In.setBigInt64(0, value);\n for (const byte of F64Out) {\n FNV1A64_OP(byte);\n }\n}\n// ------------------------------------------------------------------\n// Boolean\n// ------------------------------------------------------------------\nfunction FromBoolean(value) {\n FNV1A64_OP(ByteMarker.Boolean);\n FNV1A64_OP(value ? 1 : 0);\n}\n// ------------------------------------------------------------------\n// Constructor\n// ------------------------------------------------------------------\nfunction FromConstructor(value) {\n FNV1A64_OP(ByteMarker.Constructor);\n FromValue(value.toString());\n}\n// ------------------------------------------------------------------\n// Date\n// ------------------------------------------------------------------\nfunction FromDate(value) {\n FNV1A64_OP(ByteMarker.Date);\n FromValue(value.getTime());\n}\n// ------------------------------------------------------------------\n// Function\n// ------------------------------------------------------------------\nfunction FromFunction(value) {\n FNV1A64_OP(ByteMarker.Function);\n FromValue(value.toString());\n}\n// ------------------------------------------------------------------\n// Null\n// ------------------------------------------------------------------\nfunction FromNull(_value) {\n FNV1A64_OP(ByteMarker.Null);\n}\n// ------------------------------------------------------------------\n// Number | IEEE754\n// ------------------------------------------------------------------\nfunction FromNumber(value) {\n FNV1A64_OP(ByteMarker.Number);\n F64In.setFloat64(0, value, true /* little-endian */);\n for (const byte of F64Out) {\n FNV1A64_OP(byte);\n }\n}\n// ------------------------------------------------------------------\n// Object\n// ------------------------------------------------------------------\nfunction FromObject(value) {\n FNV1A64_OP(ByteMarker.Object);\n for (const key of InstanceKeys(value).sort()) {\n FromValue(key);\n FromValue(value[key]);\n }\n}\n// ------------------------------------------------------------------\n// RegExp\n// ------------------------------------------------------------------\nfunction FromRegExp(value) {\n FNV1A64_OP(ByteMarker.RegExp);\n FromString(value.toString());\n}\n// ------------------------------------------------------------------\n// String\n// ------------------------------------------------------------------\nconst encoder = new TextEncoder();\nfunction FromString(value) {\n FNV1A64_OP(ByteMarker.String);\n for (const byte of encoder.encode(value)) {\n FNV1A64_OP(byte);\n }\n}\n// ------------------------------------------------------------------\n// Symbol\n// ------------------------------------------------------------------\nfunction FromSymbol(value) {\n FNV1A64_OP(ByteMarker.Symbol);\n FromValue(value.toString());\n}\n// ------------------------------------------------------------------\n// TypeArray\n// ------------------------------------------------------------------\nfunction FromTypeArray(value) {\n FNV1A64_OP(ByteMarker.TypeArray);\n const buffer = new Uint8Array(value.buffer);\n for (let i = 0; i < buffer.length; i++) {\n FNV1A64_OP(buffer[i]);\n }\n}\n// ------------------------------------------------------------------\n// Undefined\n// ------------------------------------------------------------------\nfunction FromUndefined(_value) {\n return FNV1A64_OP(ByteMarker.Undefined);\n}\n// ------------------------------------------------------------------\n// Hash\n//\n// deno-coverage-ignore-start - unreachable\n//\n// This function should all JavaScript values so we can't reach the\n// fall-through. We use Unreachable to assert that no values pass\n// through. We will need to handle these should they arise.\n//\n// ------------------------------------------------------------------\nfunction FromValue(value) {\n return (GlobalsGuard.IsTypeArray(value) ? FromTypeArray(value) :\n GlobalsGuard.IsDate(value) ? FromDate(value) :\n GlobalsGuard.IsRegExp(value) ? FromRegExp(value) :\n GlobalsGuard.IsBoolean(value) ? FromBoolean(value.valueOf()) :\n GlobalsGuard.IsString(value) ? FromString(value.valueOf()) :\n GlobalsGuard.IsNumber(value) ? FromNumber(value.valueOf()) :\n IsIEEE754(value) ? FromNumber(value) :\n Guard.IsArray(value) ? FromArray(value) :\n Guard.IsBoolean(value) ? FromBoolean(value) :\n Guard.IsBigInt(value) ? FromBigInt(value) :\n Guard.IsConstructor(value) ? FromConstructor(value) :\n Guard.IsNull(value) ? FromNull(value) :\n Guard.IsObject(value) ? FromObject(value) :\n Guard.IsString(value) ? FromString(value) :\n Guard.IsSymbol(value) ? FromSymbol(value) :\n Guard.IsUndefined(value) ? FromUndefined(value) :\n Guard.IsFunction(value) ? FromFunction(value) :\n Unreachable());\n}\n// deno-coverage-ignore-stop\n// ------------------------------------------------------------------\n// Hash\n// ------------------------------------------------------------------\n/** Generates a FNV1A-64 non cryptographic hash of the given value */\nexport function HashCode(value) {\n Accumulator = BigInt('14695981039346656037');\n FromValue(value);\n return Accumulator;\n}\n/** Generates a FNV1A-64 non cryptographic hash of the given value */\nexport function Hash(value) {\n return HashCode(value).toString(16).padStart(16, '0');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// Pattern\n// ------------------------------------------------------------------\nexport const IntegerPattern = '-?(?:0|[1-9][0-9]*)';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates a Integer type. */\nexport function Integer(options) {\n return Memory.Create({ '~kind': 'Integer' }, { type: 'integer' }, options);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TInteger. */\nexport function IsInteger(value) {\n return IsKind(value, 'Integer');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// Pattern\n// ------------------------------------------------------------------\nexport const NumberPattern = '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates a Number type. */\nexport function Number(options) {\n return Memory.Create({ '~kind': 'Number' }, { type: 'number' }, options);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is a TNumber. */\nexport function IsNumber(value) {\n return IsKind(value, 'Number');\n}\n","// deno-lint-ignore-file\n// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// StringPattern\n// ------------------------------------------------------------------\nexport const StringPattern = '.*';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates a String type. */\nexport function String(options) {\n return Memory.Create({ '~kind': 'String' }, { type: 'string' }, options);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TString. */\nexport function IsString(value) {\n return IsKind(value, 'String');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { Guard } from '../../guard/index.mjs';\nimport { IsKind } from './schema.mjs';\nimport { Integer, IntegerPattern } from './integer.mjs';\nimport { Number, NumberPattern } from './number.mjs';\nimport { String, StringPattern } from './string.mjs';\nimport { Deferred } from './deferred.mjs';\nimport { TemplateLiteralDecodeUnsafe } from '../engine/template_literal/decode.mjs';\nimport { CreateRecord } from '../engine/record/record_create.mjs';\nimport { RecordAction } from '../engine/record/instantiate.mjs';\nexport const IntegerKey = `^${IntegerPattern}$`;\nexport const NumberKey = `^${NumberPattern}$`;\nexport const StringKey = `^${StringPattern}$`;\n/** Represents a deferred Record action. */\nexport function RecordDeferred(key, value, options = {}) {\n return Deferred('Record', [key, value], options);\n}\n// -------------------------------------------------------------------\n// Factory\n// -------------------------------------------------------------------\n/** Creates a Record type. */\nexport function Record(key, value, options = {}) {\n return RecordAction(key, value, options);\n}\n// -------------------------------------------------------------------\n// FromPattern\n// -------------------------------------------------------------------\n/** Creates a Record type from regular expression pattern. */\nexport function RecordFromPattern(key, value) {\n return CreateRecord(key, value);\n}\n/** Returns the raw string pattern used for the Record key */\nexport function RecordPattern(type) {\n return Guard.Keys(type.patternProperties)[0];\n}\n/** Returns the Record key as a TypeBox type */\nexport function RecordKey(type) {\n const pattern = RecordPattern(type);\n const result = (Guard.IsEqual(pattern, StringKey) ? String() :\n Guard.IsEqual(pattern, IntegerKey) ? Integer() :\n Guard.IsEqual(pattern, NumberKey) ? Number() :\n TemplateLiteralDecodeUnsafe(pattern));\n return result;\n}\nexport function RecordValue(type) {\n return type.patternProperties[RecordPattern(type)];\n}\n// -------------------------------------------------------------------\n// Guard\n// -------------------------------------------------------------------\nexport function IsRecord(value) {\n return IsKind(value, 'Record');\n}\n// -------------------------------------------------------------------\n// Options\n// -------------------------------------------------------------------\nexport function RecordOptions(type) {\n return Memory.Discard(type, ['~kind', 'type', 'patternProperties']);\n}\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\n// ------------------------------------------------------------------\n// Range\n// ------------------------------------------------------------------\nfunction Range(start, end) {\n return Array.from({ length: end - start + 1 }, (_, i) => String.fromCharCode(start + i));\n}\nexport const Alpha = [\n ...Range(97, 122), // Lowercase\n ...Range(65, 90) // Uppercase\n];\nexport const Zero = '0';\nexport const NonZero = Range(49, 57); // 1 - 9\nexport const Digit = [Zero, ...NonZero];\n// ------------------------------------------------------------------\n// Characters\n// ------------------------------------------------------------------\nexport const WhiteSpace = ' ';\nexport const NewLine = '\\n';\nexport const TabSpace = '\\t';\nexport const UnderScore = '_';\nexport const Dot = '.';\nexport const DollarSign = '$';\nexport const Hyphen = '-';\n// deno-coverage-ignore-stop\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\nimport { Match } from './internal/match.mjs';\nimport { Trim } from './internal/trim.mjs';\nimport { Take } from './internal/take.mjs';\nimport { Many } from './internal/many.mjs';\nimport { Digit } from './internal/char.mjs';\nimport { Zero } from './internal/char.mjs';\nimport { NonZero } from './internal/char.mjs';\nimport { UnderScore } from './internal/char.mjs';\nfunction TakeNonZero(input) {\n return Take(NonZero, input);\n}\nconst AllowedDigits = [...Digit, UnderScore];\nfunction TakeDigits(input) {\n return Many(AllowedDigits, [UnderScore], input);\n}\nfunction TakeUnsignedInteger(input) {\n return Match(Take([Zero], input), (Zero, ZeroRest) => [Zero, ZeroRest], () => Match(TakeNonZero(input), (NonZero, NonZeroRest) => Match(TakeDigits(NonZeroRest), (Digits, DigitsRest) => [`${NonZero}${Digits}`, DigitsRest], () => []), // fail: did not match Digits\n () => [])); // fail: did not match NonZero\n}\n/** Matches if next is a UnsignedInteger */\nexport function UnsignedInteger(input) {\n return TakeUnsignedInteger(Trim(input));\n}\n// deno-coverage-ignore-stop\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\nimport { Match } from './internal/match.mjs';\nimport { Trim } from './internal/trim.mjs';\nimport { Take } from './internal/take.mjs';\nimport { Alpha } from './internal/char.mjs';\nimport { Digit } from './internal/char.mjs';\nimport { UnderScore } from './internal/char.mjs';\nimport { DollarSign } from './internal/char.mjs';\nconst Initial = [...Alpha, UnderScore, DollarSign];\nfunction TakeInitial(input) {\n return Take(Initial, input);\n}\nconst Remaining = [...Initial, ...Digit];\nfunction TakeRemaining(input, result = '') {\n return Match(Take(Remaining, input), (Remaining, RemainingRest) => TakeRemaining(RemainingRest, `${result}${Remaining}`), () => [result, input]);\n}\nfunction TakeIdent(input) {\n return Match(TakeInitial(input), (Initial, InitialRest) => Match(TakeRemaining(InitialRest), (Remaining, RemainingRest) => [`${Initial}${Remaining}`, RemainingRest], () => []), // fail: did not match Remaining\n () => []); // fail: did not match Initial\n}\n/** Matches if next is an Ident */\nexport function Ident(input) {\n return TakeIdent(Trim(input));\n}\n// deno-coverage-ignore-stop\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\nimport { IsEqual } from './internal/guard.mjs';\nimport { IsMatch, Match } from './internal/match.mjs';\nimport { Trim } from './internal/trim.mjs';\nimport { Take } from './internal/take.mjs';\nimport { Many } from './internal/many.mjs';\nimport { Digit, UnderScore } from './internal/char.mjs';\nimport { Dot } from './internal/char.mjs';\nimport { UnsignedInteger } from './unsigned_integer.mjs';\nconst AllowedDigits = [...Digit, UnderScore];\nfunction IsLeadingDot(input) {\n return IsMatch(Take([Dot], input));\n}\nfunction TakeFractional(input) {\n return Match(Many(AllowedDigits, [UnderScore], input), (Digits, DigitsRest) => IsEqual(Digits, '')\n ? [] // fail: no Digits\n : [Digits, DigitsRest], () => []); // fail: did not match Digits\n}\nfunction LeadingDot(input) {\n return Match(Take([Dot], input), (Dot, DotRest) => Match(TakeFractional(DotRest), (Fractional, FractionalRest) => [`0${Dot}${Fractional}`, FractionalRest], () => []), // fail: did not match Fractional\n () => []); // fail: did not match Dot\n}\nfunction LeadingInteger(input) {\n return Match(UnsignedInteger(input), (Integer, IntegerRest) => Match(Take([Dot], IntegerRest), (Dot, DotRest) => Match(TakeFractional(DotRest), (Fractional, FractionalRest) => [`${Integer}${Dot}${Fractional}`, FractionalRest], () => [`${Integer}`, DotRest]), // fail: did not match Fractional, use Integer\n () => [`${Integer}`, IntegerRest]), // fail: did not match Dot, use Integer\n () => []); // fail: did not match Integer\n}\nfunction TakeUnsignedNumber(input) {\n return (IsLeadingDot(input)\n ? LeadingDot(input)\n : LeadingInteger(input));\n}\n/** Matches if next is a UnsignedNumber */\nexport function UnsignedNumber(input) {\n return TakeUnsignedNumber(Trim(input));\n}\n// deno-coverage-ignore-stop\n","// deno-fmt-ignore-file\nimport { IsNumber } from '../../types/number.mjs';\nimport { Never } from '../../types/never.mjs';\nimport { PropertyKeys } from '../../types/properties.mjs';\nimport { EvaluateUnion } from '../evaluate/evaluate.mjs';\nimport { ToIndexableKeys } from '../indexable/to_indexable_keys.mjs';\nimport { IntegerKey } from '../../types/record.mjs';\nimport { ExpandThis } from '../this/expand_this.mjs';\nfunction IndexProperty(properties, key) {\n const selectedType = key in properties ? properties[key] : Never();\n const result = ExpandThis(properties, selectedType);\n return result;\n}\nfunction IndexProperties(properties, keys) {\n return keys.reduce((result, left) => {\n return [...result, IndexProperty(properties, left)];\n }, []);\n}\nfunction FromIndexer(properties, indexer) {\n const keys = ToIndexableKeys(indexer);\n const variants = IndexProperties(properties, keys);\n const result = EvaluateUnion(variants);\n return result;\n}\nconst NumericKeyPattern = new RegExp(IntegerKey);\nfunction NumericKeys(keys) {\n const result = keys.filter(key => NumericKeyPattern.test(key));\n return result;\n}\nfunction FromIndexerNumber(properties) {\n const keys = PropertyKeys(properties);\n const numericKeys = NumericKeys(keys);\n const variants = IndexProperties(properties, numericKeys);\n const result = EvaluateUnion(variants);\n return result;\n}\nexport function FromObject(properties, indexer) {\n const result = IsNumber(indexer) ? FromIndexerNumber(properties) : FromIndexer(properties, indexer);\n return result;\n}\n","import { posix } from \"node:path\";\nimport { Type } from \"typebox\";\n//#region src/tools/workspace-path.ts\nconst WORKSPACE_PREFIX = \"/workspace\";\n/** Guest parent directory for agent + session mounts. */\nconst WORKSPACE_MOUNT = WORKSPACE_PREFIX;\n/** Persistent per-agent files and skills. */\nconst AGENT_MOUNT = `${WORKSPACE_PREFIX}/agent`;\n/** Ephemeral per-session scratch space. */\nconst SESSION_MOUNT = `${WORKSPACE_PREFIX}/session`;\nfunction isAgentOrSessionRelative(relative) {\n\treturn relative === \"agent\" || relative.startsWith(\"agent/\") || relative === \"session\" || relative.startsWith(\"session/\");\n}\n/** Bare relative paths (no agent/ or session/ prefix) land in session scratch. */\nfunction withSessionDefault(relative) {\n\tif (relative === \"\" || isAgentOrSessionRelative(relative)) return relative;\n\treturn posix.join(\"session\", relative);\n}\n/**\n* Map a tool-supplied path to a canonical `/workspace/...` guest path.\n*\n* Unprefixed relative paths resolve under `/workspace/session`. Use an `agent/`\n* prefix for cross-session persistence. Absolute paths must stay under `/workspace`.\n*/\nfunction normalizeWorkspacePath(path) {\n\tconst normalized = path.replace(/\\\\/g, \"/\");\n\tlet relative;\n\tif (normalized === WORKSPACE_PREFIX || normalized === `${WORKSPACE_PREFIX}/`) relative = \"\";\n\telse if (normalized.startsWith(`${WORKSPACE_PREFIX}/`)) relative = normalized.slice(11);\n\telse if (normalized.startsWith(\"/\")) throw new Error(`Path must be under ${WORKSPACE_PREFIX} (e.g. /workspace/session/file.txt). For other paths use bash.`);\n\telse relative = normalized.replace(/^\\.\\//, \"\");\n\tconst beforeDefault = posix.join(WORKSPACE_PREFIX, relative);\n\tif (beforeDefault !== WORKSPACE_PREFIX && !beforeDefault.startsWith(`${WORKSPACE_PREFIX}/`)) throw new Error(`Path escapes workspace: ${path}`);\n\trelative = withSessionDefault(relative);\n\tconst resolved = posix.join(WORKSPACE_PREFIX, relative);\n\tif (resolved !== WORKSPACE_PREFIX && !resolved.startsWith(`${WORKSPACE_PREFIX}/`)) throw new Error(`Path escapes workspace: ${path}`);\n\tlet mount = \"parent\";\n\tif (resolved === AGENT_MOUNT || resolved.startsWith(`${AGENT_MOUNT}/`)) mount = \"agent\";\n\telse if (resolved === SESSION_MOUNT || resolved.startsWith(`${SESSION_MOUNT}/`)) mount = \"session\";\n\treturn {\n\t\tpath: resolved,\n\t\tdisplayPath: resolved,\n\t\tmount\n\t};\n}\n//#endregion\n//#region src/define-tool.ts\n/**\n* Identity helper for authoring agent tools. Generic over the parameter schema\n* so `execute`'s `params` is inferred as `Static<typeof parameters>` — no cast\n* needed inside `execute`.\n*/\nfunction defineTool(tool) {\n\treturn tool;\n}\n//#endregion\n//#region src/tools/helpers/format-exec.ts\nfunction formatExecResult(result) {\n\tconst parts = [];\n\tif (result.stdout) parts.push(result.stdout);\n\tif (result.stderr) parts.push(result.stderr);\n\tif (result.exitCode !== 0) parts.push(`[exit ${result.exitCode}]`);\n\treturn parts.join(\"\\n\").trim() || \"(no output)\";\n}\n//#endregion\n//#region src/tools/bash-tool.ts\nfunction createBashTool(runtime, options = {}) {\n\treturn defineTool({\n\t\tname: \"bash\",\n\t\tlabel: \"Bash\",\n\t\tdescription: [\n\t\t\t\"Run bash in the agent sandbox (cwd /workspace).\",\n\t\t\t\"Use session/ for session scratch and agent/ for persistent cross-session files.\",\n\t\t\t\"Prefer read, write, and edit for file operations.\",\n\t\t\t\"Use bash for grep, find, ls, jq, and shell pipelines.\",\n\t\t\toptions.codemode ?? true ? \"Use js-exec for JavaScript/TypeScript scripts; call host tools from scripts via tools.<toolName>(args).\" : \"Use node or python via bash for scripts when needed.\"\n\t\t].join(\" \"),\n\t\tparameters: Type.Object({ command: Type.String({ description: \"Bash script or command to run in the sandbox\" }) }, { additionalProperties: false }),\n\t\tasync execute(_id, params) {\n\t\t\tconst { command } = params;\n\t\t\tconst result = await runtime.exec(command);\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: formatExecResult(result)\n\t\t\t\t}],\n\t\t\t\tdetails: result\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/helpers/edit-apply.ts\nfunction applyEditsToOriginal(content, edits) {\n\tif (edits.length === 0) throw new Error(\"edits must contain at least one replacement\");\n\tconst ranges = [];\n\tfor (const edit of edits) {\n\t\tconst start = content.indexOf(edit.oldText);\n\t\tif (start === -1) throw new Error(\"oldText not found in file\");\n\t\tif (content.indexOf(edit.oldText, start + edit.oldText.length) !== -1) throw new Error(\"oldText must be unique in file\");\n\t\tranges.push({\n\t\t\tstart,\n\t\t\tend: start + edit.oldText.length,\n\t\t\tnewText: edit.newText\n\t\t});\n\t}\n\tconst sorted = [...ranges].sort((a, b) => a.start - b.start);\n\tfor (let i = 1; i < sorted.length; i++) {\n\t\tconst prev = sorted[i - 1];\n\t\tif (sorted[i].start < prev.end) throw new Error(\"edits must not overlap\");\n\t}\n\tlet result = \"\";\n\tlet cursor = 0;\n\tfor (const range of sorted) {\n\t\tresult += content.slice(cursor, range.start);\n\t\tresult += range.newText;\n\t\tcursor = range.end;\n\t}\n\tresult += content.slice(cursor);\n\treturn result;\n}\n//#endregion\n//#region src/tools/edit-tool.ts\nconst replaceEditSchema = Type.Object({\n\toldText: Type.String({ description: \"Exact text to replace. Must be unique in the file and must not overlap other edits in this call.\" }),\n\tnewText: Type.String({ description: \"Replacement text\" })\n}, { additionalProperties: false });\nconst editSchema = Type.Object({\n\tpath: Type.String({ description: \"Path under /workspace (e.g. session/out.txt or agent/data.json)\" }),\n\tedits: Type.Array(replaceEditSchema, { description: \"Replacements applied against the original file (not chained). Each oldText must be unique and non-overlapping.\" })\n}, { additionalProperties: false });\nfunction createEditTool(runtime) {\n\treturn defineTool({\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription: \"Edit a file under /workspace using exact text replacement. Unprefixed paths resolve under session/; prefix agent/ for cross-session files. Each edits[].oldText must match the original file uniquely. Merge nearby changes into one edit when possible.\",\n\t\tparameters: editSchema,\n\t\tasync execute(_id, params, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst { path, edits } = params;\n\t\t\tconst { path: filePath, displayPath } = normalizeWorkspacePath(path);\n\t\t\tconst updated = applyEditsToOriginal(await runtime.readFile(filePath), edits);\n\t\t\tawait runtime.writeFile(filePath, updated);\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Successfully replaced ${edits.length} block(s) in ${displayPath}`\n\t\t\t\t}],\n\t\t\t\tdetails: {\n\t\t\t\t\tpath: displayPath,\n\t\t\t\t\teditCount: edits.length\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/helpers/truncate.ts\nconst DEFAULT_MAX_LINES = 2e3;\nconst DEFAULT_MAX_BYTES = 256 * 1024;\nfunction truncateHead(text, maxLines = DEFAULT_MAX_LINES, maxBytes = DEFAULT_MAX_BYTES) {\n\tconst lines = text.split(\"\\n\");\n\tconst totalLines = lines.length;\n\tlet truncatedBy;\n\tlet sliceEnd = lines.length;\n\tif (lines.length > maxLines) {\n\t\tsliceEnd = maxLines;\n\t\ttruncatedBy = \"lines\";\n\t}\n\tlet content = lines.slice(0, sliceEnd).join(\"\\n\");\n\tconst buf = Buffer.from(content, \"utf-8\");\n\tif (buf.byteLength > maxBytes) {\n\t\tcontent = buf.subarray(0, maxBytes).toString(\"utf-8\");\n\t\ttruncatedBy = \"bytes\";\n\t}\n\tconst outputLines = content.split(\"\\n\").length;\n\treturn {\n\t\tcontent,\n\t\ttruncated: truncatedBy !== void 0,\n\t\toutputLines,\n\t\ttotalLines,\n\t\ttruncatedBy\n\t};\n}\n//#endregion\n//#region src/tools/read-tool.ts\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path under /workspace (e.g. session/out.txt or agent/data.json)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" }))\n});\nfunction createReadTool(runtime) {\n\treturn defineTool({\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read a file under /workspace. Unprefixed paths resolve under session/; prefix agent/ for cross-session files. Text is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB. Use offset/limit to continue. Prefer read over cat.`,\n\t\tparameters: readSchema,\n\t\tasync execute(_id, params, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst { path, offset, limit } = params;\n\t\t\tconst { path: filePath, displayPath } = normalizeWorkspacePath(path);\n\t\t\tconst allLines = (await runtime.readFile(filePath)).split(\"\\n\");\n\t\t\tconst startLine = offset ? Math.max(0, offset - 1) : 0;\n\t\t\tif (startLine >= allLines.length) throw new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);\n\t\t\tlet selected;\n\t\t\tif (limit !== void 0) {\n\t\t\t\tconst endLine = Math.min(startLine + limit, allLines.length);\n\t\t\t\tselected = allLines.slice(startLine, endLine).join(\"\\n\");\n\t\t\t} else selected = allLines.slice(startLine).join(\"\\n\");\n\t\t\tconst truncation = truncateHead(selected);\n\t\t\tlet output = truncation.content;\n\t\t\tconst startDisplay = startLine + 1;\n\t\t\tif (truncation.truncated) {\n\t\t\t\tconst nextOffset = startDisplay + truncation.outputLines;\n\t\t\t\toutput += `\\n\\n[Truncated. Use offset=${nextOffset} on ${displayPath} to continue.]`;\n\t\t\t} else if (limit !== void 0 && startLine + limit < allLines.length) {\n\t\t\t\tconst nextOffset = startLine + limit + 1;\n\t\t\t\toutput += `\\n\\n[More lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: output\n\t\t\t\t}],\n\t\t\t\tdetails: {\n\t\t\t\t\tpath: displayPath,\n\t\t\t\t\ttruncation\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/write-tool.ts\nconst writeSchema = Type.Object({\n\tpath: Type.String({ description: \"Path under /workspace (e.g. session/out.txt or agent/data.json)\" }),\n\tcontent: Type.String({ description: \"Content to write to the file\" })\n});\nfunction createWriteTool(runtime) {\n\treturn defineTool({\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription: \"Write content to a file under /workspace. Unprefixed paths go to session/; prefix agent/ for cross-session persistence. Creates parent directories if needed. Overwrites existing files. Use write for new files or full rewrites; use edit for partial changes.\",\n\t\tparameters: writeSchema,\n\t\tasync execute(_id, params, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst { path, content } = params;\n\t\t\tconst { path: filePath, displayPath } = normalizeWorkspacePath(path);\n\t\t\tawait runtime.writeFile(filePath, content);\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Successfully wrote ${content.length} bytes to ${displayPath}`\n\t\t\t\t}],\n\t\t\t\tdetails: { path: displayPath }\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/create-coding-tools.ts\nfunction createCodingTools(runtime, options = {}) {\n\tconst codemode = options.codemode ?? true;\n\treturn [\n\t\tcreateReadTool(runtime),\n\t\tcreateWriteTool(runtime),\n\t\tcreateEditTool(runtime),\n\t\tcreateBashTool(runtime, { codemode })\n\t];\n}\n//#endregion\nexport { WORKSPACE_MOUNT as a, SESSION_MOUNT as i, defineTool as n, AGENT_MOUNT as r, createCodingTools as t };\n\n//# sourceMappingURL=create-coding-tools-d9-WzxBW.mjs.map","import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);\nimport{B as on,C as an,D as de,E as et,F as se,G as ke,H as Kt,I as ln,J as L,K as cn,L as un,M as xe,N as Us,O as Xt,P as H,a as Yr,b as Ms,c as Qr,d as qt,e as ee,f as B,g as fe,h as ne,i as Oe,j as He,k as Ws,l as Gt,m as Jr,n as zs,o as en,p as Ee,q as We,r as tn,s as sn,t as Vs,u as Bs,v as Ze,w as rn,x as nn,y as Ae,z as js}from\"./chunks/chunk-G5EVRAOO.js\";import{a as Fe,b as Me,c as be}from\"./chunks/chunk-WNH3HOQA.js\";import{c as Fs}from\"./chunks/chunk-HBVMHTO5.js\";import{a as Mt,b as Wt}from\"./chunks/chunk-XRFHFXFP.js\";import{a as Ls}from\"./chunks/chunk-L2UW7DWF.js\";import{a as Ue,b as ve,c as Ct}from\"./chunks/chunk-DLL7UR66.js\";import{a as _t,b as Xr}from\"./chunks/chunk-L64BMZUV.js\";import{a as Ve,b as me}from\"./chunks/chunk-TN7HHBQW.js\";import{a as kt}from\"./chunks/chunk-4RUAZWKT.js\";import{a as At,b as zt,c as io,d as Be,e as oo,f as Vt,g as ao,h as Bt,i as lo,j as co}from\"./chunks/chunk-NRSASXYY.js\";import{a as ye,b as ge,c as ue,d as we,e as Gr,f as j,g as Je,h as jt,i as Ut,j as Kr,k as J,l as Ht,m as je,n as Zt,o as Pe}from\"./chunks/chunk-SAI2SPQQ.js\";import\"./chunks/chunk-STHBFACM.js\";import{a as Le}from\"./chunks/chunk-FOCWZZDE.js\";import{a as Ie}from\"./chunks/chunk-W5DWRFSU.js\";import{a as Is}from\"./chunks/chunk-BZUGFHVS.js\";var tt=[{name:\"echo\",load:async()=>(await import(\"./chunks/echo-NDWZZHPO.js\")).echoCommand},{name:\"cat\",load:async()=>(await import(\"./chunks/cat-TSFMZVYS.js\")).catCommand},{name:\"printf\",load:async()=>(await import(\"./chunks/printf-TWGXF445.js\")).printfCommand},{name:\"ls\",load:async()=>(await import(\"./chunks/ls-ZJGQER7M.js\")).lsCommand},{name:\"mkdir\",load:async()=>(await import(\"./chunks/mkdir-MEPGZOB6.js\")).mkdirCommand},{name:\"rmdir\",load:async()=>(await import(\"./chunks/rmdir-OC4ZLPYA.js\")).rmdirCommand},{name:\"touch\",load:async()=>(await import(\"./chunks/touch-UA33VN3N.js\")).touchCommand},{name:\"rm\",load:async()=>(await import(\"./chunks/rm-SSGETQVQ.js\")).rmCommand},{name:\"cp\",load:async()=>(await import(\"./chunks/cp-BISAAS7A.js\")).cpCommand},{name:\"mv\",load:async()=>(await import(\"./chunks/mv-W5BIQ646.js\")).mvCommand},{name:\"ln\",load:async()=>(await import(\"./chunks/ln-4LGSXXGD.js\")).lnCommand},{name:\"chmod\",load:async()=>(await import(\"./chunks/chmod-TFEPA42X.js\")).chmodCommand},{name:\"pwd\",load:async()=>(await import(\"./chunks/pwd-WE6EN5AV.js\")).pwdCommand},{name:\"readlink\",load:async()=>(await import(\"./chunks/readlink-OPJF4DL5.js\")).readlinkCommand},{name:\"head\",load:async()=>(await import(\"./chunks/head-442HYESI.js\")).headCommand},{name:\"tail\",load:async()=>(await import(\"./chunks/tail-R4PCA2C4.js\")).tailCommand},{name:\"wc\",load:async()=>(await import(\"./chunks/wc-LF7NU4LA.js\")).wcCommand},{name:\"stat\",load:async()=>(await import(\"./chunks/stat-CD34IZ4P.js\")).statCommand},{name:\"grep\",load:async()=>(await import(\"./chunks/grep-V3LQVMRQ.js\")).grepCommand},{name:\"fgrep\",load:async()=>(await import(\"./chunks/grep-V3LQVMRQ.js\")).fgrepCommand},{name:\"egrep\",load:async()=>(await import(\"./chunks/grep-V3LQVMRQ.js\")).egrepCommand},{name:\"rg\",load:async()=>(await import(\"./chunks/rg-S4FXYXWB.js\")).rgCommand},{name:\"sed\",load:async()=>(await import(\"./chunks/sed-S5UIK574.js\")).sedCommand},{name:\"awk\",load:async()=>(await import(\"./chunks/awk2-LA3USKJP.js\")).awkCommand2},{name:\"sort\",load:async()=>(await import(\"./chunks/sort-SW2YEO5B.js\")).sortCommand},{name:\"uniq\",load:async()=>(await import(\"./chunks/uniq-XSIZR6PB.js\")).uniqCommand},{name:\"comm\",load:async()=>(await import(\"./chunks/comm-VV2LDX2J.js\")).commCommand},{name:\"cut\",load:async()=>(await import(\"./chunks/cut-OKARJCCV.js\")).cutCommand},{name:\"paste\",load:async()=>(await import(\"./chunks/paste-7JC6S4DX.js\")).pasteCommand},{name:\"tr\",load:async()=>(await import(\"./chunks/tr-36LHWFRQ.js\")).trCommand},{name:\"rev\",load:async()=>(await import(\"./chunks/rev-5EHFX4EJ.js\")).rev},{name:\"nl\",load:async()=>(await import(\"./chunks/nl-WSDW7I4O.js\")).nl},{name:\"fold\",load:async()=>(await import(\"./chunks/fold-4TQNYMSW.js\")).fold},{name:\"expand\",load:async()=>(await import(\"./chunks/expand-JSPG6VOP.js\")).expand},{name:\"unexpand\",load:async()=>(await import(\"./chunks/unexpand-CADSA4VO.js\")).unexpand},{name:\"strings\",load:async()=>(await import(\"./chunks/strings-6WDHLGMX.js\")).strings},{name:\"split\",load:async()=>(await import(\"./chunks/split-4KKZZXXE.js\")).split},{name:\"column\",load:async()=>(await import(\"./chunks/column-XT6UFXNQ.js\")).column},{name:\"join\",load:async()=>(await import(\"./chunks/join-TBRGI3LQ.js\")).join},{name:\"tee\",load:async()=>(await import(\"./chunks/tee-YUZ2FKCJ.js\")).teeCommand},{name:\"find\",load:async()=>(await import(\"./chunks/find-INTH3OLC.js\")).findCommand},{name:\"basename\",load:async()=>(await import(\"./chunks/basename-UB3CIYNI.js\")).basenameCommand},{name:\"dirname\",load:async()=>(await import(\"./chunks/dirname-MPHRFUTI.js\")).dirnameCommand},{name:\"tree\",load:async()=>(await import(\"./chunks/tree-YLD52CNT.js\")).treeCommand},{name:\"du\",load:async()=>(await import(\"./chunks/du-572XNP42.js\")).duCommand},{name:\"env\",load:async()=>(await import(\"./chunks/env-36M5BO7M.js\")).envCommand},{name:\"printenv\",load:async()=>(await import(\"./chunks/env-36M5BO7M.js\")).printenvCommand},{name:\"alias\",load:async()=>(await import(\"./chunks/alias-RTYYYW3D.js\")).aliasCommand},{name:\"unalias\",load:async()=>(await import(\"./chunks/alias-RTYYYW3D.js\")).unaliasCommand},{name:\"history\",load:async()=>(await import(\"./chunks/history-WYYKSLSZ.js\")).historyCommand},{name:\"xargs\",load:async()=>(await import(\"./chunks/xargs-MGZPH7AX.js\")).xargsCommand},{name:\"true\",load:async()=>(await import(\"./chunks/true-FHQXJXBE.js\")).trueCommand},{name:\"false\",load:async()=>(await import(\"./chunks/true-FHQXJXBE.js\")).falseCommand},{name:\"clear\",load:async()=>(await import(\"./chunks/clear-HKGFEOF6.js\")).clearCommand},{name:\"bash\",load:async()=>(await import(\"./chunks/bash-YZ33HQZQ.js\")).bashCommand},{name:\"sh\",load:async()=>(await import(\"./chunks/bash-YZ33HQZQ.js\")).shCommand},{name:\"jq\",load:async()=>(await import(\"./chunks/jq-4XLYLOS5.js\")).jqCommand},{name:\"base64\",load:async()=>(await import(\"./chunks/base64-C2AIWVNC.js\")).base64Command},{name:\"diff\",load:async()=>(await import(\"./chunks/diff-MWJFIG7X.js\")).diffCommand},{name:\"date\",load:async()=>(await import(\"./chunks/date-UUUPW43J.js\")).dateCommand},{name:\"sleep\",load:async()=>(await import(\"./chunks/sleep-X22JJINO.js\")).sleepCommand},{name:\"timeout\",load:async()=>(await import(\"./chunks/timeout-YDCRSLPQ.js\")).timeoutCommand},{name:\"time\",load:async()=>(await import(\"./chunks/time-D4LNBSWX.js\")).timeCommand},{name:\"seq\",load:async()=>(await import(\"./chunks/seq-M5EC7Q57.js\")).seqCommand},{name:\"expr\",load:async()=>(await import(\"./chunks/expr-5JAACS4X.js\")).exprCommand},{name:\"md5sum\",load:async()=>(await import(\"./chunks/md5sum-SPU24VSG.js\")).md5sumCommand},{name:\"sha1sum\",load:async()=>(await import(\"./chunks/sha1sum-2PTOAFR6.js\")).sha1sumCommand},{name:\"sha256sum\",load:async()=>(await import(\"./chunks/sha256sum-NS7D3IXX.js\")).sha256sumCommand},{name:\"file\",load:async()=>(await import(\"./chunks/file-IPZJC3FQ.js\")).fileCommand},{name:\"html-to-markdown\",load:async()=>(await import(\"./chunks/html-to-markdown-JW4MSQZO.js\")).htmlToMarkdownCommand},{name:\"help\",load:async()=>(await import(\"./chunks/help-HZ6M2CKN.js\")).helpCommand},{name:\"which\",load:async()=>(await import(\"./chunks/which-XEM24D5D.js\")).whichCommand},{name:\"tac\",load:async()=>(await import(\"./chunks/tac-2STMMJYW.js\")).tac},{name:\"hostname\",load:async()=>(await import(\"./chunks/hostname-C4HQXXUP.js\")).hostname},{name:\"whoami\",load:async()=>(await import(\"./chunks/whoami-XMTX52VE.js\")).whoami},{name:\"od\",load:async()=>(await import(\"./chunks/od-WOKFDJTP.js\")).od},{name:\"gzip\",load:async()=>(await import(\"./chunks/gzip-O5ASJAFY.js\")).gzipCommand},{name:\"gunzip\",load:async()=>(await import(\"./chunks/gzip-O5ASJAFY.js\")).gunzipCommand},{name:\"zcat\",load:async()=>(await import(\"./chunks/gzip-O5ASJAFY.js\")).zcatCommand}];(typeof __BROWSER__>\"u\"||!__BROWSER__)&&(tt.push({name:\"tar\",load:async()=>(await import(\"./chunks/tar-STHHZTZ6.js\")).tarCommand}),tt.push({name:\"yq\",load:async()=>(await import(\"./chunks/yq-4QJW3EQG.js\")).yqCommand}),tt.push({name:\"xan\",load:async()=>(await import(\"./chunks/xan-Y6WF3IRG.js\")).xanCommand}),tt.push({name:\"sqlite3\",load:async()=>(await import(\"./chunks/sqlite3-CGOEFJAO.js\")).sqlite3Command}));var Yt=[];(typeof __BROWSER__>\"u\"||!__BROWSER__)&&(Yt.push({name:\"python3\",load:async()=>(await import(\"./chunks/python3-POMOR4OA.js\")).python3Command}),Yt.push({name:\"python\",load:async()=>(await import(\"./chunks/python3-POMOR4OA.js\")).pythonCommand}));var Qt=[];(typeof __BROWSER__>\"u\"||!__BROWSER__)&&(Qt.push({name:\"js-exec\",load:async()=>(await import(\"./chunks/js-exec-N5KEZBH7.js\")).jsExecCommand}),Qt.push({name:\"node\",load:async()=>(await import(\"./chunks/js-exec-N5KEZBH7.js\")).nodeStubCommand}));var dn=[{name:\"curl\",load:async()=>(await import(\"./chunks/curl-LV5Y3AMS.js\")).curlCommand}],fn=new Map;function Jt(e){return{name:e.name,async execute(t,s){let r=fn.get(e.name);if(r||(r=await me.runTrustedAsync(()=>e.load()),fn.set(e.name,r)),s.coverage&&(typeof __BROWSER__>\"u\"||!__BROWSER__)){let{emitFlagCoverage:n}=await import(\"./chunks/flag-coverage-XWSYNE72.js\");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function uo(){return tt.map(e=>e.name)}function fo(){return dn.map(e=>e.name)}function hn(e){return(e?tt.filter(s=>e.includes(s.name)):tt).map(Jt)}function pn(){return dn.map(Jt)}function ho(){return Yt.map(e=>e.name)}function mn(){return Yt.map(Jt)}function po(){return Qt.map(e=>e.name)}function yn(){return Qt.map(Jt)}function gn(e){return\"load\"in e&&typeof e.load==\"function\"}function mo(e,t){return{name:e,trusted:!0,execute:t}}function wn(e){let t=null;return{name:e.name,trusted:!0,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}function O(e){if(!e||e===\"/\")return\"/\";let t=e.endsWith(\"/\")&&e!==\"/\"?e.slice(0,-1):e;t.startsWith(\"/\")||(t=`/${t}`);let s=t.split(\"/\").filter(n=>n&&n!==\".\"),r=[];for(let n of s)n===\"..\"?r.pop():r.push(n);return`/${r.join(\"/\")}`||\"/\"}function x(e,t){if(e.includes(\"\\0\"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}function st(e){let t=O(e);if(t===\"/\")return\"/\";let s=t.lastIndexOf(\"/\");return s===0?\"/\":t.slice(0,s)}function qe(e,t){if(t.startsWith(\"/\"))return O(t);let s=e===\"/\"?`/${t}`:`${e}/${t}`;return O(s)}function Ge(e,t){return e===\"/\"?`/${t}`:`${e}/${t}`}function ct(e,t){if(t.startsWith(\"/\"))return O(t);let s=st(e);return O(Ge(s,t))}var ut=new TextEncoder;function yo(e){return typeof e==\"object\"&&e!==null&&!(e instanceof Uint8Array)&&\"content\"in e}var ze=class{data=new Map;constructor(t){if(this.data.set(\"/\",{type:\"directory\",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))typeof r==\"function\"?this.writeFileLazy(s,r):yo(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}ensureParentDirs(t){let s=st(t);s!==\"/\"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:\"directory\",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){x(t,\"write\");let i=O(t);this.ensureParentDirs(i);let o=be(r),a=Fe(s,o);this.data.set(i,{type:\"file\",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}writeFileLazy(t,s,r){x(t,\"write\");let n=O(t);this.ensureParentDirs(n),this.data.set(n,{type:\"file\",lazy:s,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,s){let r=await s.lazy(),i={type:\"file\",content:typeof r==\"string\"?ut.encode(r):r,mode:s.mode,mtime:s.mtime};return this.data.set(t,i),i}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,\"binary\")}async readFileBuffer(t){x(t,\"open\");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);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}'`);if(\"lazy\"in r){let n=await this.materializeLazy(s,r);return n.content instanceof Uint8Array?n.content:ut.encode(n.content)}return r.content instanceof Uint8Array?r.content:ut.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){x(t,\"append\");let n=O(t),i=this.data.get(n);if(i&&i.type===\"directory\")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=be(r),a=Fe(s,o);if(i?.type===\"file\"){let l=i;\"lazy\"in l&&(l=await this.materializeLazy(n,l));let c=\"content\"in l&&l.content instanceof Uint8Array?l.content:ut.encode(\"content\"in l?l.content:\"\"),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(n,{type:\"file\",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes(\"\\0\"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){x(t,\"stat\");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);r.type===\"file\"&&\"lazy\"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type===\"file\"&&\"content\"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type===\"file\",isDirectory:r.type===\"directory\",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){x(t,\"lstat\");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);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};r.type===\"file\"&&\"lazy\"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type===\"file\"&&\"content\"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type===\"file\",isDirectory:r.type===\"directory\",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveIntermediateSymlinks(t){let s=O(t);if(s===\"/\")return\"/\";let r=s.slice(1).split(\"/\");if(r.length<=1)return s;let n=\"\",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type===\"symlink\"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=ct(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=O(t);if(s===\"/\")return\"/\";let r=s.slice(1).split(\"/\"),n=\"\",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type===\"symlink\"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=ct(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){x(t,\"mkdir\");let r=O(t);if(this.data.has(r)){if(this.data.get(r)?.type===\"file\")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=st(r);if(n!==\"/\"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{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){x(t,\"scandir\");let s=O(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type===\"symlink\";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=ct(s,r.target),r=this.data.get(s)}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=s===\"/\"?\"/\":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&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,s){x(t,\"rm\");let r=O(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type===\"directory\"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=Ge(r,o);await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){x(t,\"cp\"),x(s,\"cp\");let n=O(t),i=O(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type===\"file\")if(this.ensureParentDirs(i),\"content\"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type===\"symlink\")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(n);for(let l of a){let c=Ge(n,l),u=Ge(i,l);await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){return qe(t,s)}async chmod(t,s){x(t,\"chmod\");let r=O(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){x(s,\"symlink\");let r=O(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:\"symlink\",target:t,mode:511,mtime:new Date})}async link(t,s){x(t,\"link\"),x(s,\"link\");let r=O(t),n=O(s),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(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let o=i;\"lazy\"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(n),this.data.set(n,{type:\"file\",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(t){x(t,\"readlink\");let s=O(t),r=this.data.get(s);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){x(t,\"realpath\");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){x(t,\"utimes\");let n=O(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function go(e){let t=e;return typeof t.mkdirSync==\"function\"&&typeof t.writeFileSync==\"function\"}function wo(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 vo(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 bo(e,t){e.mkdirSync(\"/proc/self/fd\",{recursive:!0}),e.writeFileSync(\"/proc/version\",`${Yr}\n`),e.writeFileSync(\"/proc/self/exe\",\"/bin/bash\"),e.writeFileSync(\"/proc/self/cmdline\",\"bash\\0\"),e.writeFileSync(\"/proc/self/comm\",`bash\n`),e.writeFileLazy?e.writeFileLazy(\"/proc/self/status\",()=>Ms(t)):e.writeFileSync(\"/proc/self/status\",Ms(t)),e.writeFileSync(\"/proc/self/fd/0\",\"/dev/stdin\"),e.writeFileSync(\"/proc/self/fd/1\",\"/dev/stdout\"),e.writeFileSync(\"/proc/self/fd/2\",\"/dev/stderr\")}function vn(e,t,s={pid:1,ppid:0,uid:1e3,gid:1e3}){go(e)&&(wo(e,t),vo(e),bo(e,s))}var Eo=[\"allexport\",\"errexit\",\"noglob\",\"noclobber\",\"noexec\",\"nounset\",\"pipefail\",\"posix\",\"verbose\",\"xtrace\"],$o=[\"braceexpand\",\"hashall\",\"interactive-comments\"];function Zs(e){let t=[],s=[...$o.map(r=>({name:r,enabled:!0})),...Eo.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(\":\")}function dt(e){e.state.env.set(\"SHELLOPTS\",Zs(e.state.options))}var So=[\"dotglob\",\"expand_aliases\",\"extglob\",\"failglob\",\"globskipdots\",\"globstar\",\"lastpipe\",\"nocaseglob\",\"nocasematch\",\"nullglob\",\"xpg_echo\"];function qs(e){let t=[];for(let s of So)e[s]&&t.push(s);return t.join(\":\")}function Gs(e){e.state.env.set(\"BASHOPTS\",qs(e.state.shoptOptions))}var Po=\"BASH_ALIAS_\";function bn(e){return e.parts.length!==1?!1:e.parts[0].type===\"Literal\"}function En(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type===\"Literal\"?t.value:null}function $n(e,t){return e.env.get(`${Po}${t}`)}function Ks(e,t,s){if(!t.name||!bn(t.name))return t;let r=En(t.name);if(!r)return t;let n=$n(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new B,o=n,a=n.endsWith(\" \");if(!a)for(let f of t.args){let d=Pn(f);o+=` ${d}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof qt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Sn(t,n);let c=l.statements[0].pipelines[0].commands[0];if(c.type!==\"SimpleCommand\")return Sn(t,n);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(bn(f)){let d=En(f);if(d&&$n(e,d)){let p={type:\"SimpleCommand\",name:f,args:u.args.slice(1),assignments:[],redirections:[]},y=Ks(e,p,s);y!==p&&(u={...u,name:y.name,args:[...y.args]})}}}return u}catch(i){throw s.delete(r),i}}function Sn(e,t){let s=t;for(let o of e.args){let a=Pn(o);s+=` ${a}`}let r=new B,n=r.parseWordFromString(\"eval\",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,\"'\\\\''\")}'`,!1,!1);return{type:\"SimpleCommand\",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Pn(e){let t=\"\";for(let s of e.parts)switch(s.type){case\"Literal\":t+=s.value.replace(/([\\s\"'$`\\\\*?[\\]{}()<>|&;#!])/g,\"\\\\$1\");break;case\"SingleQuoted\":t+=`'${s.value}'`;break;case\"DoubleQuoted\":t+=`\"${s.parts.map(r=>r.type===\"Literal\"?r.value:`$${r.type}`).join(\"\")}\"`;break;case\"ParameterExpansion\":t+=`\\${${s.parameter}}`;break;case\"CommandSubstitution\":t+=\"$(...)\";break;case\"ArithmeticExpansion\":t+=`$((${s.expression}))`;break;case\"Glob\":t+=s.pattern;break;default:break}return t}async function An(e,t){let s=t.parts.map(u=>u.type===\"Literal\"?u.value:\"\\0\").join(\"\"),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\(/);if(!r||!s.endsWith(\")\"))return null;let n=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 d=f.indexOf(\"=(\");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(\")\")&&(f=f.slice(0,-1));let d=f.split(/(\\s+)/);for(let p of d)/^\\s+$/.test(p)?(a||l)&&(i.push(a),a=\"\",l=!1):p&&(a+=p)}}else if(o)if(u.type===\"BraceExpansion\")if(/^\\[.+\\]=/.test(a))a+=Gt({type:\"Word\",parts:[u]});else{(a||l)&&(i.push(a),a=\"\",l=!1);let d=await xe(e,{type:\"Word\",parts:[u]});i.push(...d.values)}else{(u.type===\"SingleQuoted\"||u.type===\"DoubleQuoted\"||u.type===\"Escaped\")&&(l=!0);let f=await L(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`${n}=(${c.join(\" \")})`}async function kn(e,t){let s=-1,r=-1,n=!1;for(let h=0;h<t.parts.length;h++){let w=t.parts[h];if(w.type===\"Literal\"){let E=w.value.indexOf(\"+=\");if(E!==-1){let b=w.value.slice(0,E);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){s=h,r=E,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\\[[^\\]]+\\]$/.test(b)){s=h,r=E,n=!0;break}}let g=w.value.indexOf(\"=\");if(g!==-1&&(g===0||w.value[g-1]!==\"+\")){let b=w.value.slice(0,g);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\\[[^\\]]+\\]$/.test(b)){s=h,r=g;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!==\"Literal\")return null;let a=n?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(s+1),f=\"\";for(let h of i)f+=await L(e,{type:\"Word\",parts:[h]});f+=l;let d={type:\"Word\",parts:c!==\"\"?[{type:\"Literal\",value:c},...u]:u},p=d.parts.length>0?await L(e,d):\"\";return`${f}${n?\"+=\":\"=\"}${p}`}var Ao=[\"tar\",\"yq\",\"xan\",\"sqlite3\",\"python3\",\"python\"];function _n(e){return Ao.includes(e)}var W=Object.freeze({stdout:\"\",stderr:\"\",exitCode:0});function z(e=\"\"){return{stdout:e,stderr:\"\",exitCode:0}}function A(e,t=1){return{stdout:\"\",stderr:e,exitCode:t}}function _(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function Q(e){return{stdout:\"\",stderr:\"\",exitCode:e?0:1}}function Te(e,t,s=\"\",r=\"\"){throw new J(e,t,s,r)}function le(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new J(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,\"file_descriptors\")}function Xs(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new je;return W}if(t.length>1)throw new j(1,\"\",`bash: break: too many arguments\n`);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new j(128,\"\",`bash: break: ${t[0]}: numeric argument required\n`);s=r}throw new ye(s)}async function Ys(e,t){let s,r=!1,n=!1,i=0;for(;i<t.length;)if(t[i]===\"--\"){i++;break}else if(t[i]===\"-L\")n=!1,i++;else if(t[i]===\"-P\")n=!0,i++;else if(t[i].startsWith(\"-\")&&t[i]!==\"-\")i++;else break;let o=t.slice(i);if(o.length===0||o[0]===\"~\"?s=e.state.env.get(\"HOME\")||\"/\":o[0]===\"-\"?(s=e.state.previousDir,r=!0):s=o[0],!s.startsWith(\"/\")&&!s.startsWith(\"./\")&&!s.startsWith(\"../\")&&s!==\".\"&&s!==\"..\"){let f=e.state.env.get(\"CDPATH\");if(f){let d=f.split(\":\").filter(p=>p);for(let p of d){let y=p.startsWith(\"/\")?`${p}/${s}`:`${e.state.cwd}/${p}/${s}`;try{if((await e.fs.stat(y)).isDirectory){s=y,r=!0;break}}catch{}}}}let l=(s.startsWith(\"/\")?s:`${e.state.cwd}/${s}`).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 A(`bash: cd: ${s}: Not a directory\n`)}catch{return A(`bash: cd: ${s}: No such file or directory\n`)}}let u=c||\"/\";if(n)try{u=await e.fs.realpath(u)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=u,e.state.env.set(\"PWD\",e.state.cwd),e.state.env.set(\"OLDPWD\",e.state.previousDir),z(r?`${u}\n`:\"\")}function Qs(e,t){return e.fs.resolvePath(e.state.cwd,t)}var ko=[\"-e\",\"-a\",\"-f\",\"-d\",\"-r\",\"-w\",\"-x\",\"-s\",\"-L\",\"-h\",\"-k\",\"-g\",\"-u\",\"-G\",\"-O\",\"-b\",\"-c\",\"-p\",\"-S\",\"-t\",\"-N\"];function ts(e){return ko.includes(e)}async function ss(e,t,s){let r=Qs(e,s);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\"].includes(r);case\"-p\":return!1;case\"-S\":return!1;case\"-t\":return!1;case\"-N\":return e.fs.exists(r);default:return!1}}var _o=[\"-nt\",\"-ot\",\"-ef\"];function rs(e){return _o.includes(e)}async function ns(e,t,s,r){let n=Qs(e,s),i=Qs(e,r);switch(t){case\"-nt\":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case\"-ot\":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case\"-ef\":try{if(!await e.fs.exists(n)||!await e.fs.exists(i))return!1;let o=e.fs.resolvePath(e.state.cwd,n),a=e.fs.resolvePath(e.state.cwd,i);return o===a}catch{return!1}default:return!1}}var Co=new Set([\"-eq\",\"-ne\",\"-lt\",\"-le\",\"-gt\",\"-ge\"]);function is(e){return Co.has(e)}function os(e,t,s){switch(e){case\"-eq\":return t===s;case\"-ne\":return t!==s;case\"-lt\":return t<s;case\"-le\":return t<=s;case\"-gt\":return t>s;case\"-ge\":return t>=s}}function Nt(e){return e===\"=\"||e===\"==\"||e===\"!=\"}function as(e,t,s,r=!1,n=!1,i=!1){if(r){let a=ht(t,s,n,i);return e===\"!=\"?!a:a}if(n){let a=t.toLowerCase()===s.toLowerCase();return e===\"!=\"?!a:a}let o=t===s;return e===\"!=\"?!o:o}var No=new Set([\"-z\",\"-n\"]);function ls(e){return No.has(e)}function cs(e,t){switch(e){case\"-z\":return t===\"\";case\"-n\":return t!==\"\"}}async function us(e,t){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(s){let r=s[1],n=s[2];if(e.state.associativeArrays?.has(r)){let a=n;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.get(c)||\"\"),e.state.env.has(`${r}_${a}`)}let o;try{let a=new B,l=ee(a,n);o=await H(e,l.expression)}catch{if(/^-?\\d+$/.test(n))o=Number.parseInt(n,10);else{let a=e.state.env.get(n);o=a?Number.parseInt(a,10):0}}if(o<0){let a=ne(e,r),l=e.state.currentLine;if(a.length===0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${l}: ${r}: bad array subscript\n`,!1;if(o=Math.max(...a)+1+o,o<0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${l}: ${r}: bad array subscript\n`,!1}return e.state.env.has(`${r}_${o}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?He(e,t).length>0:ne(e,t).length>0}async function Ke(e,t){switch(t.type){case\"CondBinary\":{let s=await L(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!==\"=~\"),n;if(t.operator===\"=~\")if(r){let i=await L(e,t.right);n=an(i)}else n=await cn(e,t.right);else Nt(t.operator)&&!r?n=await un(e,t.right):n=await L(e,t.right);if(Nt(t.operator)){let i=e.state.shoptOptions.nocasematch;return as(t.operator,s,n,!r,i,!0)}if(is(t.operator))return os(t.operator,await Nn(e,s),await Nn(e,n));if(rs(t.operator))return ns(e,t.operator,s,n);switch(t.operator){case\"=~\":try{let i=e.state.shoptOptions.nocasematch,o=Do(n),l=kt(o,i?\"i\":\"\").match(s);if(Oe(e,\"BASH_REMATCH\"),l)for(let c=0;c<l.length;c++)e.state.env.set(`BASH_REMATCH_${c}`,l[c]||\"\");return l!==null}catch{throw new Error(\"syntax error in regular expression\")}case\"<\":return s<n;case\">\":return s>n;default:return!1}}case\"CondUnary\":{let s=await L(e,t.operand);return ts(t.operator)?ss(e,t.operator,s):ls(t.operator)?cs(t.operator,s):t.operator===\"-v\"?await us(e,s):t.operator===\"-o\"?er(e,s):!1}case\"CondNot\":return e.state.shoptOptions.extglob&&t.operand.type===\"CondGroup\"&&t.operand.expression.type===\"CondWord\"?`!(${await L(e,t.operand.expression.word)})`!==\"\":!await Ke(e,t.operand);case\"CondAnd\":return await Ke(e,t.left)?await Ke(e,t.right):!1;case\"CondOr\":return await Ke(e,t.left)?!0:await Ke(e,t.right);case\"CondGroup\":return await Ke(e,t.expression);case\"CondWord\":return await L(e,t.word)!==\"\";default:return!1}}async function Ot(e,t){if(t.length===0)return _(\"\",\"\",1);if(t.length===1)return Q(!!t[0]);if(t.length===2){let r=t[0],n=t[1];return r===\"(\"?A(`test: '(' without matching ')'\n`,2):ts(r)?Q(await ss(e,r,n)):ls(r)?Q(cs(r,n)):r===\"!\"?Q(!n):r===\"-v\"?Q(await us(e,n)):r===\"-o\"?Q(er(e,n)):r===\"=\"||r===\"==\"||r===\"!=\"||r===\"<\"||r===\">\"||r===\"-eq\"||r===\"-ne\"||r===\"-lt\"||r===\"-le\"||r===\"-gt\"||r===\"-ge\"||r===\"-nt\"||r===\"-ot\"||r===\"-ef\"?A(`test: ${r}: unary operator expected\n`,2):_(\"\",\"\",1)}if(t.length===3){let r=t[0],n=t[1],i=t[2];if(Nt(n))return Q(as(n,r,i));if(is(n)){let o=fs(r),a=fs(i);return!o.valid||!a.valid?_(\"\",\"\",2):Q(os(n,o.value,a.value))}if(rs(n))return Q(await ns(e,n,r,i));switch(n){case\"-a\":return Q(r!==\"\"&&i!==\"\");case\"-o\":return Q(r!==\"\"||i!==\"\");case\">\":return Q(r>i);case\"<\":return Q(r<i)}if(r===\"!\"){let o=await Ot(e,[n,i]);return _(\"\",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r===\"(\"&&i===\")\")return Q(n!==\"\")}if(t.length===4){if(t[0]===\"!\"){let r=await Ot(e,t.slice(1));return _(\"\",r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]===\"(\"&&t[3]===\")\")return Ot(e,[t[1],t[2]])}let s=await xn(e,t,0);return s.pos<t.length?A(`test: too many arguments\n`,2):Q(s.value)}async function xn(e,t,s){return Oo(e,t,s)}async function Oo(e,t,s){let{value:r,pos:n}=await Cn(e,t,s);for(;t[n]===\"-o\";){let i=await Cn(e,t,n+1);r=r||i.value,n=i.pos}return{value:r,pos:n}}async function Cn(e,t,s){let{value:r,pos:n}=await Js(e,t,s);for(;t[n]===\"-a\";){let i=await Js(e,t,n+1);r=r&&i.value,n=i.pos}return{value:r,pos:n}}async function Js(e,t,s){if(t[s]===\"!\"){let{value:r,pos:n}=await Js(e,t,s+1);return{value:!r,pos:n}}return xo(e,t,s)}async function xo(e,t,s){let r=t[s];if(r===\"(\"){let{value:i,pos:o}=await xn(e,t,s+1);return{value:i,pos:t[o]===\")\"?o+1:o}}let n=t[s+1];if(Nt(n)){let i=r,o=t[s+2]??\"\";return{value:as(n,i,o),pos:s+3}}if(is(n)){let i=fs(r),o=fs(t[s+2]??\"0\");return!i.valid||!o.valid?{value:!1,pos:s+3}:{value:os(n,i.value,o.value),pos:s+3}}if(rs(n)){let i=r,o=t[s+2]??\"\";return{value:await ns(e,n,i,o),pos:s+3}}if(ts(r)){let i=t[s+1]??\"\";return{value:await ss(e,r,i),pos:s+2}}if(ls(r)){let i=t[s+1]??\"\";return{value:cs(r,i),pos:s+2}}if(r===\"-v\"){let i=t[s+1]??\"\";return{value:await us(e,i),pos:s+2}}if(r===\"-o\"){let i=t[s+1]??\"\";return{value:er(e,i),pos:s+2}}return{value:r!==void 0&&r!==\"\",pos:s+1}}function ht(e,t,s=!1,r=!1){let n=`^${Tn(t,r)}$`;return kt(n,s?\"is\":\"s\").test(e)}function Tn(e,t){let s=\"\";for(let r=0;r<e.length;r++){let n=e[r];if(t&&(n===\"@\"||n===\"*\"||n===\"+\"||n===\"?\"||n===\"!\")&&r+1<e.length&&e[r+1]===\"(\"){let i=Dn(e,r+1);if(i!==-1){let o=e.slice(r+2,i),a=Rn(o),l=a.map(u=>Tn(u,t)),c=l.length>0?l.join(\"|\"):\"(?:)\";if(n===\"@\")s+=`(?:${c})`;else if(n===\"*\")s+=`(?:${c})*`;else if(n===\"+\")s+=`(?:${c})+`;else if(n===\"?\")s+=`(?:${c})?`;else if(n===\"!\")if(i<e.length-1){let f=a.map(p=>In(p,t));if(f.every(p=>p!==null)&&f.every(p=>p===f[0])&&f[0]!==null){let p=f[0];if(p===0)s+=\"(?:.+)\";else{let y=[];p>0&&y.push(`.{0,${p-1}}`),y.push(`.{${p+1},}`),y.push(`(?!(?:${c})).{${p}}`),s+=`(?:${y.join(\"|\")})`}}else s+=`(?:(?!(?:${c})).)*?`}else s+=`(?!(?:${c})$).*`;r=i;continue}}if(n===\"\\\\\")if(r+1<e.length){let i=e[r+1];/[\\\\^$.|+(){}[\\]*?]/.test(i)?s+=`\\\\${i}`:s+=i,r++}else s+=\"\\\\\\\\\";else if(n===\"*\")s+=\".*\";else if(n===\"?\")s+=\".\";else if(n===\"[\"){let i=e.indexOf(\"]\",r+1);i!==-1?(s+=e.slice(r,i+1),r=i):s+=\"\\\\[\"}else/[\\\\^$.|+(){}]/.test(n)?s+=`\\\\${n}`:s+=n}return s}function Dn(e,t){let s=1,r=t+1;for(;r<e.length&&s>0;){let n=e[r];if(n===\"\\\\\"){r+=2;continue}if(n===\"(\")s++;else if(n===\")\"&&(s--,s===0))return r;r++}return-1}function Rn(e){let t=[],s=\"\",r=0,n=0;for(;n<e.length;){let i=e[n];if(i===\"\\\\\"){s+=i,n+1<e.length?(s+=e[n+1],n+=2):n++;continue}i===\"(\"?(r++,s+=i):i===\")\"?(r--,s+=i):i===\"|\"&&r===0?(t.push(s),s=\"\"):s+=i,n++}return t.push(s),t}function In(e,t){let s=0,r=0;for(;r<e.length;){let n=e[r];if(t&&(n===\"@\"||n===\"*\"||n===\"+\"||n===\"?\"||n===\"!\")&&r+1<e.length&&e[r+1]===\"(\"){let i=Dn(e,r+1);if(i!==-1){if(n===\"@\"){let o=e.slice(r+2,i),l=Rn(o).map(c=>In(c,t));if(l.every(c=>c!==null)&&l.every(c=>c===l[0])){s+=l[0],r=i+1;continue}return null}return null}}if(n===\"*\")return null;if(n===\"?\"){s+=1,r++;continue}if(n===\"[\"){let i=e.indexOf(\"]\",r+1);if(i!==-1){s+=1,r=i+1;continue}s+=1,r++;continue}if(n===\"\\\\\"){s+=1,r+=2;continue}s+=1,r++}return s}function er(e,t){let r=new Map([[\"errexit\",()=>e.state.options.errexit===!0],[\"nounset\",()=>e.state.options.nounset===!0],[\"pipefail\",()=>e.state.options.pipefail===!0],[\"xtrace\",()=>e.state.options.xtrace===!0],[\"e\",()=>e.state.options.errexit===!0],[\"u\",()=>e.state.options.nounset===!0],[\"x\",()=>e.state.options.xtrace===!0]]).get(t);return r?r():!1}async function Nn(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 On(t);try{let s=new B,r=ee(s,t);return await H(e,r.expression)}catch{return On(t)}}function To(e,t){let s=0;for(let r of e){let n;if(r>=\"0\"&&r<=\"9\")n=r.charCodeAt(0)-48;else if(r>=\"a\"&&r<=\"z\")n=r.charCodeAt(0)-97+10;else if(r>=\"A\"&&r<=\"Z\")n=r.charCodeAt(0)-65+36;else if(r===\"@\")n=62;else if(r===\"_\")n=63;else return Number.NaN;if(n>=t)return Number.NaN;s=s*t+n}return s}function On(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 s,r=e.match(/^(\\d+)#([a-zA-Z0-9@_]+)$/);if(r){let n=Number.parseInt(r[1],10);n>=2&&n<=64?s=To(r[2],n):s=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?s=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?s=Number.parseInt(e,8):s=Number.parseInt(e,10);return Number.isNaN(s)&&(s=0),t?-s:s}function fs(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 s=Number.parseInt(e,10);return Number.isNaN(s)?{value:0,valid:!1}:{value:t?-s:s,valid:!0}}function Do(e){let t=\"\",s=0;for(;s<e.length;)if(e[s]===\"\\\\\"&&s+1<e.length)t+=e[s]+e[s+1],s+=2;else if(e[s]===\"[\"){let r=Ro(e,s);t+=r.converted,s=r.endIndex}else t+=e[s],s++;return t}function Ro(e,t){let s=t+1,r=\"[\";s<e.length&&(e[s]===\"^\"||e[s]===\"!\")&&(r+=\"^\",s++);let n=!1;s<e.length&&e[s]===\"]\"&&(n=!0,s++);let i=!1;s<e.length&&e[s]===\"[\"&&s+1<e.length&&e[s+1]!==\":\"&&(i=!0,s++);let o=\"\",a=!1;for(;s<e.length;){let l=e[s];if(l===\"]\"){a=!0,s++;break}if(l===\"[\"&&s+1<e.length&&e[s+1]===\":\"){let c=e.indexOf(\":]\",s+2);if(c!==-1){let u=e.slice(s+2,c);o+=Io(u),s=c+2;continue}}if(l===\"[\"&&s+1<e.length){let c=e[s+1];if(c===\".\"||c===\"=\"){let u=`${c}]`,f=e.indexOf(u,s+2);if(f!==-1){let d=e.slice(s+2,f);o+=d,s=f+2;continue}}}if(l===\"\\\\\"&&s+1<e.length){o+=l+e[s+1],s+=2;continue}o+=l,s++}return a?(n&&(r+=\"\\\\]\"),i&&(r+=\"\\\\[\"),r+=o,r+=\"]\",{converted:r,endIndex:s}):{converted:\"\\\\[\",endIndex:t+1}}function Io(e){return new Map([[\"alnum\",\"a-zA-Z0-9\"],[\"alpha\",\"a-zA-Z\"],[\"ascii\",\"\\\\x00-\\\\x7F\"],[\"blank\",\" \\\\t\"],[\"cntrl\",\"\\\\x00-\\\\x1F\\\\x7F\"],[\"digit\",\"0-9\"],[\"graph\",\"!-~\"],[\"lower\",\"a-z\"],[\"print\",\" -~\"],[\"punct\",\"!-/:-@\\\\[-`{-~\"],[\"space\",\" \\\\t\\\\n\\\\r\\\\f\\\\v\"],[\"upper\",\"A-Z\"],[\"word\",\"a-zA-Z0-9_\"],[\"xdigit\",\"0-9A-Fa-f\"]]).get(e)??\"\"}function De(e){let t=[],s=\"\",r=!1,n=!1,i=!1,o=!1;for(let a of e){if(i){s+=a,i=!1,o=!0;continue}if(a===\"\\\\\"){i=!0;continue}if(a===\"'\"&&!n){r||(o=!0),r=!r;continue}if(a==='\"'&&!r){n||(o=!0),n=!n;continue}if((a===\" \"||a===\"\t\"||a===`\n`)&&!r&&!n){o&&(t.push(s),s=\"\",o=!1);continue}s+=a,o=!0}return o&&t.push(s),t}function ds(e){let t=[],s=0;for(;s<e.length;){for(;s<e.length&&/\\s/.test(e[s]);)s++;if(s>=e.length)break;if(e[s]!==\"[\"){s++;continue}s++;let r=\"\";if(e[s]===\"'\"||e[s]==='\"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)r+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&e[s]!==\"]\"&&e[s]!==\"=\";)r+=e[s],s++;for(;s<e.length&&e[s]!==\"]\";)s++;if(e[s]===\"]\"&&s++,e[s]!==\"=\")continue;s++;let n=\"\";if(e[s]===\"'\"||e[s]==='\"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)e[s]===\"\\\\\"&&s+1<e.length&&s++,n+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&!/\\s/.test(e[s]);)n+=e[s],s++;t.push([r,n])}return t}function Ln(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\((.*)\\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:De(t[2])};let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([^\\]]+)\\]=(.*)$/s);if(s)return{name:s[1],isArray:!1,arrayIndex:s[2],value:s[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 Lo(e,t){try{let s=new B,r=ee(s,t);return await H(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}async function Fn(e,t,s={}){let{name:r,isArray:n,arrayElements:i,value:o,arrayIndex:a}=t,{makeReadonly:l=!1,checkReadonly:c=!0}=s;if(c){let u=se(e,r);if(u)return u}if(n&&i){for(let u=0;u<i.length;u++)e.state.env.set(`${r}_${u}`,i[u]);e.state.env.set(`${r}__length`,String(i.length))}else if(a!==void 0&&o!==void 0){let u=await Lo(e,a);e.state.env.set(`${r}_${u}`,o);let f=parseInt(e.state.env.get(`${r}__length`)??\"0\",10);u>=f&&e.state.env.set(`${r}__length`,String(u+1))}else o!==void 0&&e.state.env.set(r,o);return l&&de(e,r),null}function Xe(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function pt(e,t){return e.state.localVarDepth?.get(t)}function hs(e,t){e.state.localVarDepth?.delete(t)}function Mn(e,t,s){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:s,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function ps(e,t){let s=e.state.localVarStack?.get(t);if(!(!s||s.length===0))return s.pop()}function Wn(e,t){if(e.state.localVarStack)for(let[s,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(s)}}var tr=new Set([\":\",\".\",\"break\",\"continue\",\"eval\",\"exec\",\"exit\",\"export\",\"readonly\",\"return\",\"set\",\"shift\",\"trap\",\"unset\"]);function zn(e){return tr.has(e)}var sr=new Set([\"if\",\"then\",\"else\",\"elif\",\"fi\",\"case\",\"esac\",\"for\",\"select\",\"while\",\"until\",\"do\",\"done\",\"in\",\"function\",\"{\",\"}\",\"time\",\"[[\",\"]]\",\"!\"]),mt=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\"]);async function rt(e,t,s,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${s}: Is a directory\n`;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&s!==\"/dev/null\")return`bash: ${s}: cannot overwrite existing file\n`}catch{}return null}function Ye(e){let s=Math.min(e.length,8192);for(let r=0;r<s;r++)if(e.charCodeAt(r)>127)return\"utf8\";return\"binary\"}function Fo(e){if(!e.startsWith(\"__rw__:\"))return null;let t=e.slice(7),s=t.indexOf(\":\");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+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 Vn(e,t){let s=new Map;for(let r=0;r<t.length;r++){let n=t[r];if(n.target.type===\"HereDoc\")continue;if(n.operator===\">&\"||n.operator===\"<&\"){if(Us(e,n.target))return{targets:s,error:`bash: $@: ambiguous redirect\n`};s.set(r,await L(e,n.target))}else{let o=await Xt(e,n.target);if(\"error\"in o)return{targets:s,error:o.error};s.set(r,o.target)}}return{targets:s}}function Mo(e){e.state.nextFd===void 0&&(e.state.nextFd=10);let t=e.state.nextFd,s=e.limits.maxFileDescriptors;if(t>=s)throw new Error(`bash: cannot allocate file descriptor: too many open files (max ${s})`);return e.state.nextFd++,t}async function ms(e,t){for(let s of t){if(!s.fdVariable)continue;if(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),(s.operator===\">&\"||s.operator===\"<&\")&&s.target.type===\"Word\"&&await L(e,s.target)===\"-\"){let i=e.state.env.get(s.fdVariable);if(i!==void 0){let o=Number.parseInt(i,10);Number.isNaN(o)||e.state.fileDescriptors.delete(o)}continue}let r=Mo(e);if(e.state.env.set(s.fdVariable,String(r)),s.target.type===\"Word\"){let n=await L(e,s.target);if(s.operator===\">&\"||s.operator===\"<&\"){let i=Number.parseInt(n,10);if(!Number.isNaN(i)){let o=e.state.fileDescriptors.get(i);o!==void 0&&(le(e),e.state.fileDescriptors.set(r,o));continue}}if(s.operator===\">\"||s.operator===\">>\"||s.operator===\">|\"||s.operator===\"&>\"||s.operator===\"&>>\"){let i=e.fs.resolvePath(e.state.cwd,n);(s.operator===\">\"||s.operator===\">|\"||s.operator===\"&>\")&&await e.fs.writeFile(i,\"\",\"binary\"),le(e),e.state.fileDescriptors.set(r,`__file__:${i}`)}else if(s.operator===\"<<<\")le(e),e.state.fileDescriptors.set(r,`${n}\n`);else if(s.operator===\"<\"||s.operator===\"<>\")try{let i=e.fs.resolvePath(e.state.cwd,n),o=await e.fs.readFile(i);le(e),e.state.fileDescriptors.set(r,o)}catch{return _(\"\",`bash: ${n}: No such file or directory\n`,1)}}}return null}async function Re(e,t){for(let s of t){if(s.target.type===\"HereDoc\")continue;let r=s.operator===\">&\";if(s.operator!==\">\"&&s.operator!==\">|\"&&s.operator!==\"&>\"&&!r)continue;let n;if(r){if(n=await L(e,s.target),n===\"-\"||!Number.isNaN(Number.parseInt(n,10))||s.fd!=null)continue}else{let a=await Xt(e,s.target);if(\"error\"in a)return _(\"\",a.error,1);n=a.target}let i=e.fs.resolvePath(e.state.cwd,n),o=s.operator===\">|\";if(i.includes(\"\\0\"))return _(\"\",`bash: ${n}: No such file or directory\n`,1);try{let a=await e.fs.stat(i);if(a.isDirectory)return _(\"\",`bash: ${n}: Is a directory\n`,1);if(e.state.options.noclobber&&!o&&!a.isDirectory&&n!==\"/dev/null\")return _(\"\",`bash: ${n}: cannot overwrite existing file\n`,1)}catch{}if(n!==\"/dev/null\"&&n!==\"/dev/stdout\"&&n!==\"/dev/stderr\"&&n!==\"/dev/full\"&&await e.fs.writeFile(i,\"\",\"binary\"),n===\"/dev/full\")return _(\"\",`bash: /dev/full: No space left on device\n`,1)}return null}async function K(e,t,s,r){let{stdout:n,stderr:i,exitCode:o}=t,l=t.stdoutKind===\"bytes\"||t.stdoutKind===void 0&&t.stdoutEncoding===\"binary\"?\"binary\":\"utf8\",c=p=>l;for(let p=0;p<s.length;p++){let y=s[p];if(y.target.type===\"HereDoc\")continue;let h,w=r?.get(p);if(w!==void 0)h=w;else if(y.operator===\">&\"||y.operator===\"<&\"){if(Us(e,y.target)){i+=`bash: $@: ambiguous redirect\n`,o=1,n=\"\";continue}h=await L(e,y.target)}else{let g=await Xt(e,y.target);if(\"error\"in g){i+=g.error,o=1,n=\"\";continue}h=g.target}if(!y.fdVariable){if(h.includes(\"\\0\")){i+=`bash: ${h.replace(/\\0/g,\"\")}: No such file or directory\n`,o=1,n=\"\";continue}switch(y.operator){case\">\":case\">|\":{let E=y.fd??1,g=y.operator===\">|\";if(E===1){if(h===\"/dev/stdout\")break;if(h===\"/dev/stderr\"){i+=n,n=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let b=e.fs.resolvePath(e.state.cwd,h),m=await rt(e,b,h,{checkNoclobber:!0,isClobber:g});if(m){i+=m,o=1,n=\"\";break}await e.fs.writeFile(b,n,c(n)),n=\"\"}else if(E===2){if(h===\"/dev/stderr\")break;if(h===\"/dev/stdout\"){n+=i,i=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1;break}if(h===\"/dev/null\")i=\"\";else{let b=e.fs.resolvePath(e.state.cwd,h),m=await rt(e,b,h,{checkNoclobber:!0,isClobber:g});if(m){i+=m,o=1;break}await e.fs.writeFile(b,i,Ye(i)),i=\"\"}}break}case\">>\":{let E=y.fd??1;if(E===1){if(h===\"/dev/stdout\")break;if(h===\"/dev/stderr\"){i+=n,n=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let g=e.fs.resolvePath(e.state.cwd,h),b=await rt(e,g,h,{});if(b){i+=b,o=1,n=\"\";break}await e.fs.appendFile(g,n,c(n)),n=\"\"}else if(E===2){if(h===\"/dev/stderr\")break;if(h===\"/dev/stdout\"){n+=i,i=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1;break}let g=e.fs.resolvePath(e.state.cwd,h),b=await rt(e,g,h,{});if(b){i+=b,o=1;break}await e.fs.appendFile(g,i,Ye(i)),i=\"\"}break}case\">&\":case\"<&\":{let E=y.fd??1;if(h===\"-\")break;if(h.endsWith(\"-\")){let g=h.slice(0,-1),b=Number.parseInt(g,10);if(!Number.isNaN(b)){let m=e.state.fileDescriptors?.get(b);m!==void 0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(E,m),b>=3&&e.state.fileDescriptors?.delete(b)):b===1||b===2?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(E,`__dupout__:${b}`)):b===0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(E,`__dupin__:${b}`)):b>=3&&(i+=`bash: ${b}: Bad file descriptor\n`,o=1)}break}if(h===\"2\"||h===\"&2\")E===1&&(i+=n,n=\"\");else if(h===\"1\"||h===\"&1\")n+=i,i=\"\";else{let g=Number.parseInt(h,10);if(Number.isNaN(g)){if(y.operator===\">&\"){let b=e.fs.resolvePath(e.state.cwd,h),m=await rt(e,b,h,{checkNoclobber:!0});if(m){i=m,o=1,n=\"\";break}if(y.fd==null){let v=n+i;await e.fs.writeFile(b,v,c(v)),n=\"\",i=\"\"}else E===1?(await e.fs.writeFile(b,n,c(n)),n=\"\"):E===2&&(await e.fs.writeFile(b,i,Ye(i)),i=\"\")}}else{let b=e.state.fileDescriptors?.get(g);if(b?.startsWith(\"__file__:\")){let m=b.slice(9);E===1?(await e.fs.appendFile(m,n,c(n)),n=\"\"):E===2&&(await e.fs.appendFile(m,i,Ye(i)),i=\"\")}else if(b?.startsWith(\"__rw__:\")){let m=Fo(b);m&&(E===1?(await e.fs.appendFile(m.path,n,c(n)),n=\"\"):E===2&&(await e.fs.appendFile(m.path,i,Ye(i)),i=\"\"))}else if(b?.startsWith(\"__dupout__:\")){let m=Number.parseInt(b.slice(11),10);if(m!==1)if(m===2)E===1&&(i+=n,n=\"\");else{let v=e.state.fileDescriptors?.get(m);if(v?.startsWith(\"__file__:\")){let $=v.slice(9);E===1?(await e.fs.appendFile($,n,c(n)),n=\"\"):E===2&&(await e.fs.appendFile($,i,Ye(i)),i=\"\")}}}else b?.startsWith(\"__dupin__:\")?(i+=`bash: ${g}: Bad file descriptor\n`,o=1,n=\"\"):g>=3&&(i+=`bash: ${g}: Bad file descriptor\n`,o=1,n=\"\")}}break}case\"&>\":{if(h===\"/dev/full\"){i=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let E=e.fs.resolvePath(e.state.cwd,h),g=await rt(e,E,h,{checkNoclobber:!0});if(g){i=g,o=1,n=\"\";break}let b=n+i;await e.fs.writeFile(E,b,c(b)),n=\"\",i=\"\";break}case\"&>>\":{if(h===\"/dev/full\"){i=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let E=e.fs.resolvePath(e.state.cwd,h),g=await rt(e,E,h,{});if(g){i=g,o=1,n=\"\";break}let b=n+i;await e.fs.appendFile(E,b,c(b)),n=\"\",i=\"\";break}}}}let u=e.state.fileDescriptors?.get(1);if(u){if(u===\"__dupout__:2\")i+=n,n=\"\";else if(u.startsWith(\"__file__:\")){let p=u.slice(9);await e.fs.appendFile(p,n,c(n)),n=\"\"}else if(u.startsWith(\"__file_append__:\")){let p=u.slice(16);await e.fs.appendFile(p,n,c(n)),n=\"\"}}let f=e.state.fileDescriptors?.get(2);if(f){if(f===\"__dupout__:1\")n+=i,i=\"\";else if(f.startsWith(\"__file__:\")){let p=f.slice(9);await e.fs.appendFile(p,i,Ye(i)),i=\"\"}else if(f.startsWith(\"__file_append__:\")){let p=f.slice(16);await e.fs.appendFile(p,i,Ye(i)),i=\"\"}}let d=_(n,i,o);return t.stdoutKind&&(d.stdoutKind=t.stdoutKind),t.stdoutEncoding===\"binary\"&&(d.stdoutEncoding=\"binary\"),d}function Bn(e,t){if(e.state.options.posix&&tr.has(t.name)){let r=`bash: line ${e.state.currentLine}: \\`${t.name}': is a special builtin\n`;throw new j(2,\"\",r)}let s={...t,sourceFile:t.sourceFile??e.state.currentSource??\"main\"};return e.state.functions.set(t.name,s),W}async function Wo(e,t){let s=\"\";for(let r of t)if((r.operator===\"<<\"||r.operator===\"<<-\")&&r.target.type===\"HereDoc\"){let n=r.target,i=await L(e,n.content);n.stripTabs&&(i=i.split(`\n`).map(a=>a.replace(/^\\t+/,\"\")).join(`\n`)),(r.fd??0)===0&&(s=i)}else if(r.operator===\"<<<\"&&r.target.type===\"Word\")s=`${await L(e,r.target)}\n`;else if(r.operator===\"<\"&&r.target.type===\"Word\"){let n=await L(e,r.target),i=e.fs.resolvePath(e.state.cwd,n);try{s=await e.fs.readFile(i)}catch{}}return s}async function ys(e,t,s,r=\"\",n){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,Te(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,\"recursion\")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(n??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??\"main\"),e.state.localScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let i=new Map;for(let c=0;c<s.length;c++)i.set(String(c+1),e.state.env.get(String(c+1))),e.state.env.set(String(c+1),s[c]);i.set(\"@\",e.state.env.get(\"@\")),i.set(\"#\",e.state.env.get(\"#\")),e.state.env.set(\"@\",s.join(\" \")),e.state.env.set(\"#\",String(s.length));let o=()=>{let c=e.state.localScopes.length-1,u=e.state.localScopes.pop();if(u)for(let[f,d]of u)d===void 0?e.state.env.delete(f):e.state.env.set(f,d);if(Wn(e,c),e.state.fullyUnsetLocals)for(let[f,d]of e.state.fullyUnsetLocals.entries())d===c&&e.state.fullyUnsetLocals.delete(f);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let f=e.state.localExportedVars.pop();if(f)for(let d of f)e.state.exportedVars?.delete(d)}for(let[f,d]of i)d===void 0?e.state.env.delete(f):e.state.env.set(f,d);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},{targets:a,error:l}=await Vn(e,t.redirections);if(l)return o(),_(\"\",l,1);try{let c=await Wo(e,t.redirections),u=r||c,f=await e.executeCommand(t.body,u);return o(),K(e,f,t.redirections,a)}catch(c){if(o(),c instanceof ue){let u=_(c.stdout,c.stderr,c.exitCode);return K(e,u,t.redirections,a)}throw c}}var Un=[\"!\",\"[[\",\"]]\",\"case\",\"do\",\"done\",\"elif\",\"else\",\"esac\",\"fi\",\"for\",\"function\",\"if\",\"in\",\"then\",\"time\",\"until\",\"while\",\"{\",\"}\"],nr=[\".\",\":\",\"[\",\"alias\",\"bg\",\"bind\",\"break\",\"builtin\",\"caller\",\"cd\",\"command\",\"compgen\",\"complete\",\"compopt\",\"continue\",\"declare\",\"dirs\",\"disown\",\"echo\",\"enable\",\"eval\",\"exec\",\"exit\",\"export\",\"false\",\"fc\",\"fg\",\"getopts\",\"hash\",\"help\",\"history\",\"jobs\",\"kill\",\"let\",\"local\",\"logout\",\"mapfile\",\"popd\",\"printf\",\"pushd\",\"pwd\",\"read\",\"readarray\",\"readonly\",\"return\",\"set\",\"shift\",\"shopt\",\"source\",\"suspend\",\"test\",\"times\",\"trap\",\"true\",\"type\",\"typeset\",\"ulimit\",\"umask\",\"unalias\",\"unset\",\"wait\"],zo=[\"autocd\",\"assoc_expand_once\",\"cdable_vars\",\"cdspell\",\"checkhash\",\"checkjobs\",\"checkwinsize\",\"cmdhist\",\"compat31\",\"compat32\",\"compat40\",\"compat41\",\"compat42\",\"compat43\",\"compat44\",\"complete_fullquote\",\"direxpand\",\"dirspell\",\"dotglob\",\"execfail\",\"expand_aliases\",\"extdebug\",\"extglob\",\"extquote\",\"failglob\",\"force_fignore\",\"globasciiranges\",\"globstar\",\"gnu_errfmt\",\"histappend\",\"histreedit\",\"histverify\",\"hostcomplete\",\"huponexit\",\"inherit_errexit\",\"interactive_comments\",\"lastpipe\",\"lithist\",\"localvar_inherit\",\"localvar_unset\",\"login_shell\",\"mailwarn\",\"no_empty_cmd_completion\",\"nocaseglob\",\"nocasematch\",\"nullglob\",\"progcomp\",\"progcomp_alias\",\"promptvars\",\"restricted_shell\",\"shift_verbose\",\"sourcepath\",\"xpg_echo\"],Vo=nr;async function ir(e,t){let s=[],r=null,n=\"\",i=\"\",o=null,a=!1,l=!1,c=!1,u=null,f=null,d=null,p=[],y=[\"alias\",\"arrayvar\",\"binding\",\"builtin\",\"command\",\"directory\",\"disabled\",\"enabled\",\"export\",\"file\",\"function\",\"group\",\"helptopic\",\"hostname\",\"job\",\"keyword\",\"running\",\"service\",\"setopt\",\"shopt\",\"signal\",\"stopped\",\"user\",\"variable\"];for(let m=0;m<t.length;m++){let v=t[m];if(v===\"-v\")s.push(\"variable\");else if(v===\"-e\")s.push(\"export\");else if(v===\"-f\")s.push(\"file\");else if(v===\"-d\")s.push(\"directory\");else if(v===\"-k\")s.push(\"keyword\");else if(v===\"-A\"){if(m++,m>=t.length)return A(`compgen: -A: option requires an argument\n`,2);let $=t[m];if(!y.includes($))return A(`compgen: ${$}: invalid action name\n`,2);s.push($)}else if(v===\"-W\"){if(m++,m>=t.length)return A(`compgen: -W: option requires an argument\n`,2);r=t[m]}else if(v===\"-P\"){if(m++,m>=t.length)return A(`compgen: -P: option requires an argument\n`,2);n=t[m]}else if(v===\"-S\"){if(m++,m>=t.length)return A(`compgen: -S: option requires an argument\n`,2);i=t[m]}else if(v===\"-o\"){if(m++,m>=t.length)return A(`compgen: -o: option requires an argument\n`,2);let $=t[m];if($===\"plusdirs\")a=!0;else if($===\"dirnames\")l=!0;else if($===\"default\")c=!0;else if(!($===\"filenames\"||$===\"nospace\"||$===\"bashdefault\"||$===\"noquote\"))return A(`compgen: ${$}: invalid option name\n`,2)}else if(v===\"-F\"){if(m++,m>=t.length)return A(`compgen: -F: option requires an argument\n`,2);f=t[m]}else if(v===\"-C\"){if(m++,m>=t.length)return A(`compgen: -C: option requires an argument\n`,2);d=t[m]}else if(v===\"-X\"){if(m++,m>=t.length)return A(`compgen: -X: option requires an argument\n`,2);u=t[m]}else if(v===\"-G\"){if(m++,m>=t.length)return A(`compgen: -G: option requires an argument\n`,2)}else if(v===\"--\"){p.push(...t.slice(m+1));break}else v.startsWith(\"-\")||p.push(v)}o=p[0]??null;let h=[];if(l){let m=await rr(e,o);h.push(...m)}if(c){let m=await jn(e,o);h.push(...m)}for(let m of s)if(m===\"variable\"){let v=Bo(e,o);h.push(...v)}else if(m===\"export\"){let v=jo(e,o);h.push(...v)}else if(m===\"function\"){let v=Uo(e,o);h.push(...v)}else if(m===\"builtin\"){let v=Ho(o);h.push(...v)}else if(m===\"keyword\"){let v=Zo(o);h.push(...v)}else if(m===\"alias\"){let v=qo(e,o);h.push(...v)}else if(m===\"shopt\"){let v=Go(o);h.push(...v)}else if(m===\"helptopic\"){let v=Ko(o);h.push(...v)}else if(m===\"directory\"){let v=await rr(e,o);h.push(...v)}else if(m===\"file\"){let v=await jn(e,o);h.push(...v)}else if(m===\"user\"){let v=Xo(o);h.push(...v)}else if(m===\"command\"){let v=await Yo(e,o);h.push(...v)}if(r!==null)try{let m=await Qo(e,r),v=Jo(e,m);for(let $ of v)(o===null||$.startsWith(o))&&h.push($)}catch{return _(\"\",\"\",1)}if(a){let m=await rr(e,o);for(let v of m)h.includes(v)||h.push(v)}let w=\"\";if(f!==null){let m=e.state.functions.get(f);if(m){let v=new Map;v.set(\"COMP_WORDS__length\",e.state.env.get(\"COMP_WORDS__length\")),e.state.env.set(\"COMP_WORDS__length\",\"0\"),v.set(\"COMP_CWORD\",e.state.env.get(\"COMP_CWORD\")),e.state.env.set(\"COMP_CWORD\",\"-1\"),v.set(\"COMP_LINE\",e.state.env.get(\"COMP_LINE\")),e.state.env.set(\"COMP_LINE\",\"\"),v.set(\"COMP_POINT\",e.state.env.get(\"COMP_POINT\")),e.state.env.set(\"COMP_POINT\",\"0\");let $=new Map;for(let T of e.state.env.keys())(T===\"COMPREPLY\"||T.startsWith(\"COMPREPLY_\")||T===\"COMPREPLY__length\")&&($.set(T,e.state.env.get(T)),e.state.env.delete(T));let S=[\"compgen\",p[0]??\"\",\"\"];try{let T=await ys(e,m,S,\"\");if(T.exitCode!==0)return yt(e,v),yt(e,$),_(\"\",T.stderr,1);w=T.stdout;let N=ea(e);h.push(...N)}catch{return yt(e,v),yt(e,$),_(\"\",\"\",1)}yt(e,v),yt(e,$)}}if(d!==null)try{let m=fe(d),v=await e.executeScript(m);if(v.exitCode!==0)return _(\"\",v.stderr,v.exitCode);if(v.stdout){let $=v.stdout.split(`\n`);for(let S of $)S.length>0&&h.push(S)}}catch(m){if(m.name===\"ParseException\")return A(`compgen: -C: ${m.message}\n`,2);throw m}let E=h;if(u!==null){let m=u.startsWith(\"!\"),v=m?u.slice(1):u;E=h.filter($=>{let S=ht($,v,!1,!0);return m?S:!S})}if(E.length===0&&o!==null)return _(w,\"\",1);let g=E.map(m=>`${n}${m}${i}`).join(`\n`),b=w+(g?`${g}\n`:\"\");return z(b)}function Bo(e,t){let s=new Set;for(let n of e.state.env.keys()){if(n.includes(\"_\")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\\d+$/.test(n)||n.endsWith(\"__length\"))continue;let i=n.split(\"_\")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?s.add(n):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&s.add(i)}let r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function jo(e,t){let s=e.state.exportedVars??new Set,r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r=r.filter(n=>n.includes(\"_\")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\\d+$/.test(n)||n.endsWith(\"__length\")?!1:e.state.env.has(n)),r.sort()}function Uo(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(r=>r.startsWith(t))),s.sort()}function Ho(e){let t=[...nr];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Zo(e){let t=[...Un];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function qo(e,t){let s=[];for(let n of e.state.env.keys())if(n.startsWith(\"BASH_ALIAS_\")){let i=n.slice(11);s.push(i)}let r=s;return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function Go(e){let t=[...zo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Ko(e){let t=[...Vo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}async function rr(e,t){let s=[];try{let r=e.state.cwd,n=t??\"\";if(t){let o=t.lastIndexOf(\"/\");if(o!==-1){let a=t.slice(0,o)||\"/\";n=t.slice(o+1),a.startsWith(\"/\")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i){let a=`${r}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!n||o.startsWith(n)))if(t?.includes(\"/\")){let c=t.lastIndexOf(\"/\"),u=t.slice(0,c+1);s.push(u+o)}else s.push(o)}catch{}}}catch{}return s.sort()}async function jn(e,t){let s=[];try{let r=e.state.cwd,n=t??\"\";if(t){let o=t.lastIndexOf(\"/\");if(o!==-1){let a=t.slice(0,o)||\"/\";n=t.slice(o+1),a.startsWith(\"/\")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i)if(!n||o.startsWith(n))if(t?.includes(\"/\")){let a=t.lastIndexOf(\"/\"),l=t.slice(0,a+1);s.push(l+o)}else s.push(o)}catch{}return s.sort()}function Xo(e){return[\"root\",\"nobody\"]}async function Yo(e,t){let s=new Set;for(let i of nr)s.add(i);for(let i of e.state.functions.keys())s.add(i);for(let i of e.state.env.keys())i.startsWith(\"BASH_ALIAS_\")&&s.add(i.slice(11));for(let i of Un)s.add(i);let r=e.state.env.get(\"PATH\")??\"/usr/bin:/bin\";for(let i of r.split(\":\"))if(i)try{let o=await e.fs.readdir(i);for(let a of o)s.add(a)}catch{}let n=Array.from(s);return t!==null&&(n=n.filter(i=>i.startsWith(t))),n.sort()}async function Qo(e,t){let r=new B().parseWordFromString(t,!1,!1);return await L(e,r)}function Jo(e,t){let s=e.state.env.get(\"IFS\")??` \t\n`;if(s.length===0)return[t];let r=new Set(s.split(\"\")),n=[],i=\"\",o=0;for(;o<t.length;){let a=t[o];if(a===\"\\\\\"&&o+1<t.length){let l=t[o+1];i+=l,o+=2}else r.has(a)?(i.length>0&&(n.push(i),i=\"\"),o++):(i+=a,o++)}return i.length>0&&n.push(i),n}function yt(e,t){for(let[s,r]of t)r===void 0?e.state.env.delete(s):e.state.env.set(s,r)}function ea(e){let t=[];if(e.state.env.get(\"COMPREPLY__length\")!==void 0){let n=Ae(e,\"COMPREPLY\");for(let[,i]of n)t.push(i)}else{let n=e.state.env.get(\"COMPREPLY\");n!==void 0&&t.push(n)}return t}var ta=[\"bashdefault\",\"default\",\"dirnames\",\"filenames\",\"noquote\",\"nosort\",\"nospace\",\"plusdirs\"];function ar(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=!1,i,o,a,l=[],c=[],u=[];for(let f=0;f<t.length;f++){let d=t[f];if(d===\"-p\")s=!0;else if(d===\"-r\")r=!0;else if(d===\"-D\")n=!0;else if(d===\"-W\"){if(f++,f>=t.length)return A(`complete: -W: option requires an argument\n`,2);i=t[f]}else if(d===\"-F\"){if(f++,f>=t.length)return A(`complete: -F: option requires an argument\n`,2);o=t[f]}else if(d===\"-o\"){if(f++,f>=t.length)return A(`complete: -o: option requires an argument\n`,2);let p=t[f];if(!ta.includes(p))return A(`complete: ${p}: invalid option name\n`,2);l.push(p)}else if(d===\"-A\"){if(f++,f>=t.length)return A(`complete: -A: option requires an argument\n`,2);c.push(t[f])}else if(d===\"-C\"){if(f++,f>=t.length)return A(`complete: -C: option requires an argument\n`,2);a=t[f]}else if(d===\"-G\"){if(f++,f>=t.length)return A(`complete: -G: option requires an argument\n`,2)}else if(d===\"-P\"){if(f++,f>=t.length)return A(`complete: -P: option requires an argument\n`,2)}else if(d===\"-S\"){if(f++,f>=t.length)return A(`complete: -S: option requires an argument\n`,2)}else if(d===\"-X\"){if(f++,f>=t.length)return A(`complete: -X: option requires an argument\n`,2)}else if(d===\"--\"){u.push(...t.slice(f+1));break}else d.startsWith(\"-\")||u.push(d)}if(r){if(u.length===0)return e.state.completionSpecs.clear(),z(\"\");for(let f of u)e.state.completionSpecs.delete(f);return z(\"\")}if(s)return u.length===0?or(e):or(e,u);if(t.length===0||u.length===0&&!i&&!o&&!a&&l.length===0&&c.length===0&&!n)return or(e);if(o&&u.length===0&&!n)return A(`complete: -F: option requires a command name\n`,2);if(n){let f={isDefault:!0};return i!==void 0&&(f.wordlist=i),o!==void 0&&(f.function=o),a!==void 0&&(f.command=a),l.length>0&&(f.options=l),c.length>0&&(f.actions=c),e.state.completionSpecs.set(\"__default__\",f),z(\"\")}for(let f of u){let d=Object.create(null);i!==void 0&&(d.wordlist=i),o!==void 0&&(d.function=o),a!==void 0&&(d.command=a),l.length>0&&(d.options=l),c.length>0&&(d.actions=c),e.state.completionSpecs.set(f,d)}return z(\"\")}function or(e,t){let s=e.state.completionSpecs;if(!s||s.size===0){if(t&&t.length>0){let i=\"\";for(let o of t)i+=`complete: ${o}: no completion specification\n`;return _(\"\",i,1)}return z(\"\")}let r=[],n=t||Array.from(s.keys());for(let i of n){if(i===\"__default__\")continue;let o=s.get(i);if(!o){if(t)return _(r.join(`\n`)+(r.length>0?`\n`:\"\"),`complete: ${i}: no completion specification\n`,1);continue}let a=\"complete\";if(o.options)for(let l of o.options)a+=` -o ${l}`;if(o.actions)for(let l of o.actions)a+=` -A ${l}`;o.wordlist!==void 0&&(o.wordlist.includes(\" \")||o.wordlist.includes(\"'\")?a+=` -W '${o.wordlist}'`:a+=` -W ${o.wordlist}`),o.function!==void 0&&(a+=` -F ${o.function}`),o.isDefault&&(a+=\" -D\"),a+=` ${i}`,r.push(a)}return r.length===0?z(\"\"):z(`${r.join(`\n`)}\n`)}var Hn=[\"bashdefault\",\"default\",\"dirnames\",\"filenames\",\"noquote\",\"nosort\",\"nospace\",\"plusdirs\"];function lr(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=[],i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a];if(l===\"-D\")s=!0;else if(l===\"-E\")r=!0;else if(l===\"-o\"){if(a++,a>=t.length)return A(`compopt: -o: option requires an argument\n`,2);let c=t[a];if(!Hn.includes(c))return A(`compopt: ${c}: invalid option name\n`,2);n.push(c)}else if(l===\"+o\"){if(a++,a>=t.length)return A(`compopt: +o: option requires an argument\n`,2);let c=t[a];if(!Hn.includes(c))return A(`compopt: ${c}: invalid option name\n`,2);i.push(c)}else if(l===\"--\"){o.push(...t.slice(a+1));break}else!l.startsWith(\"-\")&&!l.startsWith(\"+\")&&o.push(l)}if(s){let a=e.state.completionSpecs.get(\"__default__\")??{isDefault:!0},l=new Set(a.options??[]);for(let c of n)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),z(\"\")}if(r){let a=e.state.completionSpecs.get(\"__empty__\")??{},l=new Set(a.options??[]);for(let c of n)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),z(\"\")}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 n)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 z(\"\")}return A(`compopt: not currently executing completion function\n`,1)}function cr(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new je;return W}if(t.length>1)throw new j(1,\"\",`bash: continue: too many arguments\n`);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new j(1,\"\",`bash: continue: ${t[0]}: numeric argument required\n`);s=r}throw new ge(s)}function X(e,t){let s=e.state.env.get(\"HOME\")||\"/home/user\";return t.split(\":\").map(i=>i===\"~\"?s:i===\"~root\"?\"/root\":i.startsWith(\"~/\")?s+i.slice(1):i.startsWith(\"~root/\")?`/root${i.slice(5)}`:i).join(\":\")}function ur(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32||s===127)return!0}return!1}function fr(e){let t=\"$'\";for(let s=0;s<e.length;s++){let r=e[s],n=e.charCodeAt(s);n===7?t+=\"\\\\a\":n===8?t+=\"\\\\b\":n===9?t+=\"\\\\t\":n===10?t+=\"\\\\n\":n===11?t+=\"\\\\v\":n===12?t+=\"\\\\f\":n===13?t+=\"\\\\r\":n===27?t+=\"\\\\e\":n===39?t+=\"\\\\'\":n===92?t+=\"\\\\\\\\\":n<32||n===127?t+=`\\\\${n.toString(8).padStart(3,\"0\")}`:t+=r}return t+=\"'\",t}function gs(e){return ur(e)?fr(e):/^[a-zA-Z0-9_/.:\\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,\"'\\\\''\")}'`}function nt(e){return ur(e)?fr(e):`\"${e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"')}\"`}function dr(e){return ur(e)?fr(e):`\"${e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"')}\"`}function Zn(e,t){let s=\"\";return e.state.integerVars?.has(t)&&(s+=\"i\"),e.state.lowercaseVars?.has(t)&&(s+=\"l\"),Ee(e,t)&&(s+=\"n\"),e.state.readonlyVars?.has(t)&&(s+=\"r\"),e.state.uppercaseVars?.has(t)&&(s+=\"u\"),e.state.exportedVars?.has(t)&&(s+=\"x\"),s===\"\"?\"--\":`-${s}`}function hr(e){return e===\"\"?\"''\":/[\\s'\\\\]/.test(e)?`'${e.replace(/'/g,\"'\\\\''\")}'`:e}function qn(e,t){let s=\"\",r=\"\",n=!1;for(let i of t){let o=Zn(e,i);if(e.state.associativeArrays?.has(i)){let u=He(e,i);if(u.length===0)s+=`declare -A ${i}=()\n`;else{let f=u.map(d=>{let p=e.state.env.get(`${i}_${d}`)??\"\",y=hr(p);return`['${d}']=${y}`});s+=`declare -A ${i}=(${f.join(\" \")})\n`}continue}let l=ne(e,i);if(l.length>0){let u=l.map(f=>{let d=e.state.env.get(`${i}_${f}`)??\"\";return`[${f}]=${nt(d)}`});s+=`declare -a ${i}=(${u.join(\" \")})\n`;continue}if(e.state.env.has(`${i}__length`)){s+=`declare -a ${i}=()\n`;continue}let c=e.state.env.get(i);if(c!==void 0)s+=`declare ${o} ${i}=${dr(c)}\n`;else{let u=e.state.declaredVars?.has(i),f=e.state.localVarDepth?.has(i);u||f?s+=`declare ${o} ${i}\n`:(r+=`bash: declare: ${i}: not found\n`,n=!0)}}return _(s,r,n?1:0)}function Gn(e,t){let{filterExport:s,filterReadonly:r,filterNameref:n,filterIndexedArray:i,filterAssocArray:o}=t,a=s||r||n||i||o,l=\"\",c=new Set;for(let f of e.state.env.keys()){if(f.startsWith(\"BASH_\"))continue;if(f.endsWith(\"__length\")){let p=f.slice(0,-8);c.add(p);continue}let d=f.lastIndexOf(\"_\");if(d>0){let p=f.slice(0,d),y=f.slice(d+1);if(/^\\d+$/.test(y)||e.state.associativeArrays?.has(p)){c.add(p);continue}}c.add(f)}if(e.state.localVarDepth)for(let f of e.state.localVarDepth.keys())c.add(f);if(e.state.associativeArrays)for(let f of e.state.associativeArrays)c.add(f);let u=Array.from(c).sort();for(let f of u){let d=Zn(e,f),p=e.state.associativeArrays?.has(f),y=ne(e,f),h=!p&&(y.length>0||e.state.env.has(`${f}__length`));if(a&&(o&&!p||i&&!h||s&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||n&&!Ee(e,f)))continue;if(p){let E=He(e,f);if(E.length===0)l+=`declare -A ${f}=()\n`;else{let g=E.map(b=>{let m=e.state.env.get(`${f}_${b}`)??\"\",v=hr(m);return`['${b}']=${v}`});l+=`declare -A ${f}=(${g.join(\" \")})\n`}continue}if(y.length>0){let E=y.map(g=>{let b=e.state.env.get(`${f}_${g}`)??\"\";return`[${g}]=${nt(b)}`});l+=`declare -a ${f}=(${E.join(\" \")})\n`;continue}if(e.state.env.has(`${f}__length`)){l+=`declare -a ${f}=()\n`;continue}let w=e.state.env.get(f);w!==void 0&&(l+=`declare ${d} ${f}=${dr(w)}\n`)}return z(l)}function Kn(e){let t=\"\",s=Array.from(e.state.associativeArrays??[]).sort();for(let r of s){let n=He(e,r);if(n.length===0)t+=`declare -A ${r}=()\n`;else{let i=n.map(o=>{let a=e.state.env.get(`${r}_${o}`)??\"\",l=hr(a);return`['${o}']=${l}`});t+=`declare -A ${r}=(${i.join(\" \")})\n`}}return z(t)}function Xn(e){let t=\"\",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith(\"BASH_\"))continue;if(n.endsWith(\"__length\")){let o=n.slice(0,-8);e.state.associativeArrays?.has(o)||s.add(o);continue}let i=n.lastIndexOf(\"_\");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);/^\\d+$/.test(a)&&(e.state.associativeArrays?.has(o)||s.add(o))}}let r=Array.from(s).sort();for(let n of r){let i=ne(e,n);if(i.length===0)t+=`declare -a ${n}=()\n`;else{let o=i.map(a=>{let l=e.state.env.get(`${n}_${a}`)??\"\";return`[${a}]=${nt(l)}`});t+=`declare -a ${n}=(${o.join(\" \")})\n`}}return z(t)}function Yn(e){let t=\"\",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith(\"BASH_\"))continue;if(n.endsWith(\"__length\")){let o=n.slice(0,-8);s.add(o);continue}let i=n.lastIndexOf(\"_\");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);if(/^\\d+$/.test(a)||e.state.associativeArrays?.has(o)){s.add(o);continue}}s.add(n)}let r=Array.from(s).sort();for(let n of r){if(e.state.associativeArrays?.has(n)||ne(e,n).length>0||e.state.env.has(`${n}__length`))continue;let a=e.state.env.get(n);a!==void 0&&(t+=`${n}=${gs(a)}\n`)}return z(t)}function pr(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function xt(e,t){return e.state.integerVars?.has(t)??!1}function mr(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function sa(e,t){return e.state.lowercaseVars?.has(t)??!1}function yr(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function ra(e,t){return e.state.uppercaseVars?.has(t)??!1}function gt(e,t,s){return sa(e,t)?s.toLowerCase():ra(e,t)?s.toUpperCase():s}async function Qn(e,t){try{let s=new B,r=ee(s,t),n=await H(e,r.expression);return String(n)}catch{return\"0\"}}function na(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let s=t[0],r=s.length;if(e[r]!==\"[\")return null;let n=0,i=r+1;for(;r<e.length;r++)if(e[r]===\"[\")n++;else if(e[r]===\"]\"&&(n--,n===0))break;if(n!==0)return null;let o=e.slice(i,r);if(r++,e[r]!==\"=\")return null;r++;let a=e.slice(r);return{name:s,indexExpr:o,value:a}}async function gr(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,d=!1,p=!1,y=!1,h=!1,w=!1,E=[];for(let N=0;N<t.length;N++){let F=t[N];if(F===\"-a\")s=!0;else if(F===\"-A\")r=!0;else if(F===\"-r\")n=!0;else if(F===\"-x\")i=!0;else if(F===\"-p\")o=!0;else if(F===\"-n\")a=!0;else if(F===\"+n\")l=!0;else if(F===\"+a\")c=!0;else if(F===\"+x\")u=!0;else if(F===\"--\"){E.push(...t.slice(N+1));break}else if(F.startsWith(\"+\")){for(let k of F.slice(1))if(k===\"n\")l=!0;else if(k===\"a\")c=!0;else if(k===\"x\")u=!0;else if(k!==\"r\"){if(k!==\"i\"){if(!(k===\"f\"||k===\"F\"))return _(\"\",`bash: typeset: +${k}: invalid option\n`,2)}}}else if(F===\"-i\")f=!0;else if(F===\"-l\")d=!0;else if(F===\"-u\")p=!0;else if(F===\"-f\")y=!0;else if(F===\"-F\")h=!0;else if(F===\"-g\")w=!0;else if(F.startsWith(\"-\"))for(let k of F.slice(1))if(k===\"a\")s=!0;else if(k===\"A\")r=!0;else if(k===\"r\")n=!0;else if(k===\"x\")i=!0;else if(k===\"p\")o=!0;else if(k===\"n\")a=!0;else if(k===\"i\")f=!0;else if(k===\"l\")d=!0;else if(k===\"u\")p=!0;else if(k===\"f\")y=!0;else if(k===\"F\")h=!0;else if(k===\"g\")w=!0;else return _(\"\",`bash: typeset: -${k}: invalid option\n`,2);else E.push(F)}let b=e.state.localScopes.length>0&&!w,m=N=>{if(!b)return;let F=e.state.localScopes[e.state.localScopes.length-1];F.has(N)||F.set(N,e.state.env.get(N))},v=N=>{if(!b)return;let F=e.state.localScopes[e.state.localScopes.length-1];F.has(N)||F.set(N,e.state.env.get(N));let k=`${N}_`;for(let D of e.state.env.keys())D.startsWith(k)&&!D.includes(\"__\")&&(F.has(D)||F.set(D,e.state.env.get(D)));let C=`${N}__length`;e.state.env.has(C)&&!F.has(C)&&F.set(C,e.state.env.get(C))},$=N=>{b&&Xe(e,N)};if(h){if(E.length===0){let k=Array.from(e.state.functions.keys()).sort(),C=\"\";for(let D of k)C+=`declare -f ${D}\n`;return z(C)}let N=!0,F=\"\";for(let k of E)e.state.functions.has(k)?F+=`${k}\n`:N=!1;return _(F,\"\",N?0:1)}if(y){if(E.length===0){let F=\"\",k=Array.from(e.state.functions.keys()).sort();for(let C of k)F+=`${C} ()\n{\n # function body\n}\n`;return z(F)}let N=!0;for(let F of E)e.state.functions.has(F)||(N=!1);return _(\"\",\"\",N?0:1)}if(o&&E.length>0)return qn(e,E);if(o&&E.length===0)return Gn(e,{filterExport:i,filterReadonly:n,filterNameref:a,filterIndexedArray:s,filterAssocArray:r});if(E.length===0&&r&&!o)return Kn(e);if(E.length===0&&s&&!o)return Xn(e);if(E.length===0&&!o)return Yn(e);let S=\"\",T=0;for(let N of E){let F=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\((.*)\\)$/s);if(F&&!c){let P=F[1],R=F[2];if(r&&ne(e,P).length>0){S+=`bash: declare: ${P}: cannot convert indexed to associative array\n`,T=1;continue}if((s||!r&&!s)&&e.state.associativeArrays?.has(P)){S+=`bash: declare: ${P}: cannot convert associative to indexed array\n`,T=1;continue}if(v(P),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(P)),Oe(e,P),e.state.env.delete(P),e.state.env.delete(`${P}__length`),r&&R.includes(\"[\")){let M=ds(R);for(let[te,V]of M){let Y=X(e,V);e.state.env.set(`${P}_${te}`,Y)}}else if(r){let M=De(R);for(let te=0;te<M.length;te+=2){let V=M[te],Y=te+1<M.length?X(e,M[te+1]):\"\";e.state.env.set(`${P}_${V}`,Y)}}else{let M=De(R);if(M.some(V=>/^\\[[^\\]]+\\]=/.test(V))){let V=0;for(let Y of M){let oe=Y.match(/^\\[([^\\]]+)\\]=(.*)$/);if(oe){let pe=oe[1],lt=oe[2],so=X(e,lt),Pt;if(/^-?\\d+$/.test(pe))Pt=Number.parseInt(pe,10);else try{let ro=new B,no=ee(ro,pe);Pt=await H(e,no.expression)}catch{Pt=0}e.state.env.set(`${P}_${Pt}`,so),V=Pt+1}else{let pe=X(e,Y);e.state.env.set(`${P}_${V}`,pe),V++}}}else{for(let V=0;V<M.length;V++)e.state.env.set(`${P}_${V}`,M[V]);e.state.env.set(`${P}__length`,String(M.length))}}$(P),n&&de(e,P),i&&ke(e,P);continue}if(l){let P=N.includes(\"=\")?N.slice(0,N.indexOf(\"=\")):N;if(tn(e,P),!N.includes(\"=\"))continue}if(u){let P=N.includes(\"=\")?N.slice(0,N.indexOf(\"=\")):N;if(Kt(e,P),!N.includes(\"=\"))continue}let k=na(N);if(k){let{name:P,indexExpr:R,value:M}=k,te=se(e,P);if(te)return te;v(P);let V;try{let oe=new B,pe=ee(oe,R);V=await H(e,pe.expression)}catch{let oe=parseInt(R,10);V=Number.isNaN(oe)?0:oe}e.state.env.set(`${P}_${V}`,M);let Y=parseInt(e.state.env.get(`${P}__length`)??\"0\",10);V>=Y&&e.state.env.set(`${P}__length`,String(V+1)),$(P),n&&de(e,P),i&&ke(e,P);continue}let C=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=\\((.*)\\)$/s);if(C&&!c){let P=C[1],R=C[2],M=se(e,P);if(M)return M;v(P);let te=De(R);if(e.state.associativeArrays?.has(P)){let V=ds(R);for(let[Y,oe]of V){let pe=X(e,oe);e.state.env.set(`${P}_${Y}`,pe)}}else{let V=ne(e,P),Y=0,oe=e.state.env.get(P);V.length===0&&oe!==void 0?(e.state.env.set(`${P}_0`,oe),e.state.env.delete(P),Y=1):V.length>0&&(Y=Math.max(...V)+1);for(let lt=0;lt<te.length;lt++)e.state.env.set(`${P}_${Y+lt}`,X(e,te[lt]));let pe=Y+te.length;e.state.env.set(`${P}__length`,String(pe))}$(P),n&&de(e,P),i&&ke(e,P);continue}let D=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=(.*)$/);if(D){let P=D[1],R=X(e,D[2]),M=se(e,P);if(M)return M;m(P),f&&pr(e,P),d&&mr(e,P),p&&yr(e,P);let V=ne(e,P).length>0||e.state.associativeArrays?.has(P);if(xt(e,P)){let Y=e.state.env.get(P)??\"0\",oe=parseInt(Y,10)||0,pe=parseInt(await Qn(e,R),10)||0;R=String(oe+pe),e.state.env.set(P,R)}else if(V){R=gt(e,P,R);let Y=`${P}_0`,oe=e.state.env.get(Y)??\"\";e.state.env.set(Y,oe+R)}else{R=gt(e,P,R);let Y=e.state.env.get(P)??\"\";e.state.env.set(P,Y+R)}$(P),n&&de(e,P),i&&ke(e,P),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(P));continue}if(N.includes(\"=\")){let P=N.indexOf(\"=\"),R=N.slice(0,P),M=N.slice(P+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(R)){S+=`bash: typeset: \\`${R}': not a valid identifier\n`,T=1;continue}let te=se(e,R);if(te)return te;if(m(R),a){if(M!==\"\"&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(M)){S+=`bash: declare: \\`${M}': invalid variable name for name reference\n`,T=1;continue}e.state.env.set(R,M),We(e,R),M!==\"\"&&Bs(e,M)&&Vs(e,R),$(R),n&&de(e,R),i&&ke(e,R);continue}if(f&&pr(e,R),d&&mr(e,R),p&&yr(e,R),xt(e,R)&&(M=await Qn(e,M)),M=gt(e,R,M),Ee(e,R)){let V=Ze(e,R);V&&V!==R?e.state.env.set(V,M):e.state.env.set(R,M)}else e.state.env.set(R,M);$(R),n&&de(e,R),i&&ke(e,R),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(R))}else{let P=N;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)){S+=`bash: typeset: \\`${P}': not a valid identifier\n`,T=1;continue}if(s||r?v(P):m(P),a){We(e,P);let M=e.state.env.get(P);M!==void 0&&M!==\"\"&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(M)?sn(e,P):M&&Bs(e,M)&&Vs(e,P),$(P),n&&de(e,P),i&&ke(e,P);continue}if(f&&pr(e,P),d&&mr(e,P),p&&yr(e,P),r){if(ne(e,P).length>0){S+=`bash: declare: ${P}: cannot convert indexed to associative array\n`,T=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(P)}let R=Array.from(e.state.env.keys()).some(M=>M.startsWith(`${P}_`)&&!M.startsWith(`${P}__length`));!e.state.env.has(P)&&!R&&(s||r?e.state.env.set(`${P}__length`,\"0\"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(P))),$(P),n&&de(e,P),i&&ke(e,P)}}return _(\"\",S,T)}async function wr(e,t){let s=!1,r=!1,n=!1,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a===\"-a\")s=!0;else if(a===\"-A\")r=!0;else if(a===\"-p\")n=!0;else if(a===\"--\"){i.push(...t.slice(o+1));break}else a.startsWith(\"-\")||i.push(a)}if(i.length===0){let o=\"\",a=Array.from(e.state.readonlyVars||[]).sort();for(let l of a){let c=e.state.env.get(l);if(c!==void 0){let u=c.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"');o+=`declare -r ${l}=\"${u}\"\n`}}return z(o)}for(let o of i){let a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=\\((.*)\\)$/s);if(a){let f=a[1],d=a[2],p=se(e,f);if(p)return p;let y=De(d);if(e.state.associativeArrays?.has(f)){let h=ds(d);for(let[w,E]of h){let g=X(e,E);e.state.env.set(`${f}_${w}`,g)}}else{let h=ne(e,f),w=0,E=e.state.env.get(f);h.length===0&&E!==void 0?(e.state.env.set(`${f}_0`,E),e.state.env.delete(f),w=1):h.length>0&&(w=Math.max(...h)+1);for(let b=0;b<y.length;b++)e.state.env.set(`${f}_${w+b}`,X(e,y[b]));let g=w+y.length;e.state.env.set(`${f}__length`,String(g))}de(e,f);continue}let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=(.*)$/);if(l){let f=l[1],d=X(e,l[2]),p=se(e,f);if(p)return p;let y=e.state.env.get(f)??\"\";e.state.env.set(f,y+d),de(e,f);continue}let c=Ln(o);if(c.value===void 0&&!c.isArray){de(e,c.name);continue}let u=await Fn(e,c,{makeReadonly:!0});if(u)return u}return W}function vr(e){return e.state.directoryStack??=[],e.state.directoryStack}function Tt(e,t){return t&&e===t?\"~\":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function ia(e){let t=e.split(\"/\").filter(r=>r&&r!==\".\"),s=[];for(let r of t)r===\"..\"?s.pop():s.push(r);return`/${s.join(\"/\")}`}async function br(e,t){let s=vr(e),r;for(let a=0;a<t.length;a++){let l=t[a];if(l===\"--\"){if(a+1<t.length){if(r!==void 0)return A(`bash: pushd: too many arguments\n`,2);r=t[a+1],a++}}else{if(l.startsWith(\"-\")&&l!==\"-\")return A(`bash: pushd: ${l}: invalid option\n`,2);if(r!==void 0)return A(`bash: pushd: too many arguments\n`,2);r=l}}if(r===void 0){if(s.length<2)return A(`bash: pushd: no other directory\n`,1);let a=s[0];s[0]=s[1],s[1]=a,r=s[0]}let n;if(r.startsWith(\"/\"))n=r;else if(r===\"..\"){let a=e.state.cwd.split(\"/\").filter(l=>l);a.pop(),n=`/${a.join(\"/\")}`}else r===\".\"?n=e.state.cwd:r.startsWith(\"~\")?n=(e.state.env.get(\"HOME\")||\"/\")+r.slice(1):n=`${e.state.cwd}/${r}`;n=ia(n);try{if(!(await e.fs.stat(n)).isDirectory)return A(`bash: pushd: ${r}: Not a directory\n`,1)}catch{return A(`bash: pushd: ${r}: No such file or directory\n`,1)}s.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=n,e.state.env.set(\"PWD\",n),e.state.env.set(\"OLDPWD\",e.state.previousDir);let i=e.state.env.get(\"HOME\")||\"\",o=`${[n,...s].map(a=>Tt(a,i)).join(\" \")}\n`;return z(o)}function Er(e,t){let s=vr(e);for(let o of t)if(o!==\"--\")return o.startsWith(\"-\")&&o!==\"-\"?A(`bash: popd: ${o}: invalid option\n`,2):A(`bash: popd: too many arguments\n`,2);if(s.length===0)return A(`bash: popd: directory stack empty\n`,1);let r=s.shift();if(!r)return A(`bash: popd: directory stack empty\n`,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,e.state.env.set(\"PWD\",r),e.state.env.set(\"OLDPWD\",e.state.previousDir);let n=e.state.env.get(\"HOME\")||\"\",i=`${[r,...s].map(o=>Tt(o,n)).join(\" \")}\n`;return z(i)}function $r(e,t){let s=vr(e),r=!1,n=!1,i=!1,o=!1;for(let u of t)if(u!==\"--\")if(u.startsWith(\"-\"))for(let f of u.slice(1))if(f===\"c\")r=!0;else if(f===\"l\")n=!0;else if(f===\"p\")i=!0;else if(f===\"v\")i=!0,o=!0;else return A(`bash: dirs: -${f}: invalid option\n`,2);else return A(`bash: dirs: too many arguments\n`,1);if(r)return e.state.directoryStack=[],W;let a=[e.state.cwd,...s],l=e.state.env.get(\"HOME\")||\"\",c;return o?(c=a.map((u,f)=>{let d=n?u:Tt(u,l);return` ${f} ${d}`}).join(`\n`),c+=`\n`):i?c=a.map(u=>n?u:Tt(u,l)).join(`\n`)+`\n`:c=a.map(u=>n?u:Tt(u,l)).join(\" \")+`\n`,z(c)}async function ws(e,t,s){let r=t;if(r.length>0){let a=r[0];if(a===\"--\")r=r.slice(1);else if(a.startsWith(\"-\")&&a!==\"-\"&&a.length>1)return A(`bash: eval: ${a}: invalid option\neval: usage: eval [arg ...]\n`,2)}if(r.length===0)return W;let n=r.join(\" \");if(n.trim()===\"\")return W;let i=e.state.groupStdin,o=s??e.state.groupStdin;o!==void 0&&(e.state.groupStdin=o);try{let a=fe(n);return await e.executeScript(a)}catch(a){if(a instanceof ye||a instanceof ge||a instanceof ue||a instanceof j)throw a;if(a.name===\"ParseException\")return A(`bash: eval: ${a.message}\n`);throw a}finally{e.state.groupStdin=i}}function Sr(e,t){let s,r=\"\";if(t.length===0)s=e.state.lastExitCode;else{let n=t[0],i=Number.parseInt(n,10);n===\"\"||Number.isNaN(i)||!/^-?\\d+$/.test(n)?(r=`bash: exit: ${n}: numeric argument required\n`,s=2):s=(i%256+256)%256}throw new j(s,\"\",r)}function Pr(e,t){let s=!1,r=[];for(let o of t)o===\"-n\"?s=!0:o===\"-p\"||o===\"--\"||r.push(o);if(r.length===0&&!s){let o=\"\",a=e.state.exportedVars??new Set,l=Array.from(a).sort();for(let c of l){let u=e.state.env.get(c);if(u!==void 0){let f=u.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"');o+=`declare -x ${c}=\"${f}\"\n`}}return z(o)}if(s){for(let o of r){let a,l;if(o.includes(\"=\")){let c=o.indexOf(\"=\");a=o.slice(0,c),l=X(e,o.slice(c+1)),e.state.env.set(a,l)}else a=o;Kt(e,a)}return W}let n=\"\",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=X(e,u[2]),c=!0;else if(o.includes(\"=\")){let f=o.indexOf(\"=\");a=o.slice(0,f),l=X(e,o.slice(f+1))}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){n+=`bash: export: \\`${o}': not a valid identifier\n`,i=1;continue}if(l!==void 0)if(c){let f=e.state.env.get(a)??\"\";e.state.env.set(a,f+l)}else e.state.env.set(a,l);else e.state.env.has(a)||e.state.env.set(a,\"\");ke(e,a)}return _(\"\",n,i)}function vs(e,t){if(t.length<2)return A(`bash: getopts: usage: getopts optstring name [arg ...]\n`);let s=t[0],r=t[1],n=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),i=s.startsWith(\":\"),o=i?s.slice(1):s,a;if(t.length>2)a=t.slice(2);else{let h=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);a=[];for(let w=1;w<=h;w++)a.push(e.state.env.get(String(w))||\"\")}let l=Number.parseInt(e.state.env.get(\"OPTIND\")||\"1\",10);l<1&&(l=1);let c=Number.parseInt(e.state.env.get(\"__GETOPTS_CHARINDEX\")||\"0\",10);if(e.state.env.set(\"OPTARG\",\"\"),l>a.length)return n||e.state.env.set(r,\"?\"),e.state.env.set(\"OPTIND\",String(a.length+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),{exitCode:n?2:1,stdout:\"\",stderr:\"\"};let u=a[l-1];if(!u||u===\"-\"||!u.startsWith(\"-\"))return n||e.state.env.set(r,\"?\"),{exitCode:n?2:1,stdout:\"\",stderr:\"\"};if(u===\"--\")return e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),n||e.state.env.set(r,\"?\"),{exitCode:n?2:1,stdout:\"\",stderr:\"\"};let f=c===0?1:c,d=u[f];if(!d)return e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),vs(e,t);let p=o.indexOf(d);if(p===-1){let h=\"\";return i?e.state.env.set(\"OPTARG\",d):h=`bash: illegal option -- ${d}\n`,n||e.state.env.set(r,\"?\"),f+1<u.length?(e.state.env.set(\"__GETOPTS_CHARINDEX\",String(f+1)),e.state.env.set(\"OPTIND\",String(l))):(e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\")),{exitCode:n?2:0,stdout:\"\",stderr:h}}if(p+1<o.length&&o[p+1]===\":\")if(f+1<u.length)e.state.env.set(\"OPTARG\",u.slice(f+1)),e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\");else{if(l>=a.length){let h=\"\";return i?(e.state.env.set(\"OPTARG\",d),n||e.state.env.set(r,\":\")):(h=`bash: option requires an argument -- ${d}\n`,n||e.state.env.set(r,\"?\")),e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),{exitCode:n?2:0,stdout:\"\",stderr:h}}e.state.env.set(\"OPTARG\",a[l]),e.state.env.set(\"OPTIND\",String(l+2)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\")}else f+1<u.length?(e.state.env.set(\"__GETOPTS_CHARINDEX\",String(f+1)),e.state.env.set(\"OPTIND\",String(l))):(e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"));return n||e.state.env.set(r,d),{exitCode:n?2:0,stdout:\"\",stderr:\"\"}}async function Ar(e,t){e.state.hashTable||(e.state.hashTable=new Map);let s=!1,r=!1,n=!1,i=!1,o=!1,a=\"\",l=[],c=0;for(;c<t.length;){let y=t[c];if(y===\"--\"){c++,l.push(...t.slice(c));break}if(y===\"-r\")s=!0,c++;else if(y===\"-d\")r=!0,c++;else if(y===\"-l\")n=!0,c++;else if(y===\"-t\")o=!0,c++;else if(y===\"-p\"){if(i=!0,c++,c>=t.length)return A(`bash: hash: -p: option requires an argument\n`,1);a=t[c],c++}else if(y.startsWith(\"-\")&&y.length>1){for(let h of y.slice(1))if(h===\"r\")s=!0;else if(h===\"d\")r=!0;else if(h===\"l\")n=!0;else if(h===\"t\")o=!0;else return h===\"p\"?A(`bash: hash: -p: option requires an argument\n`,1):A(`bash: hash: -${h}: invalid option\n`,1);c++}else l.push(y),c++}if(s)return e.state.hashTable.clear(),W;if(r){if(l.length===0)return A(`bash: hash: -d: option requires an argument\n`,1);let y=!1,h=\"\";for(let w of l)e.state.hashTable.has(w)?e.state.hashTable.delete(w):(h+=`bash: hash: ${w}: not found\n`,y=!0);return y?A(h,1):W}if(o){if(l.length===0)return A(`bash: hash: -t: option requires an argument\n`,1);let y=\"\",h=!1,w=\"\";for(let E of l){let g=e.state.hashTable.get(E);g?l.length>1?y+=`${E}\t${g}\n`:y+=`${g}\n`:(w+=`bash: hash: ${E}: not found\n`,h=!0)}return h?{exitCode:1,stdout:y,stderr:w}:z(y)}if(i){if(l.length===0)return A(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]\n`,1);let y=l[0];return e.state.hashTable.set(y,a),W}if(l.length===0){if(e.state.hashTable.size===0)return z(`hash: hash table empty\n`);let y=\"\";if(n)for(let[h,w]of e.state.hashTable)y+=`builtin hash -p ${w} ${h}\n`;else{y=`hits\tcommand\n`;for(let[,h]of e.state.hashTable)y+=` 1\t${h}\n`}return z(y)}let u=!1,f=\"\",p=(e.state.env.get(\"PATH\")||\"/usr/bin:/bin\").split(\":\");for(let y of l){if(y.includes(\"/\")){f+=`bash: hash: ${y}: cannot use / in name\n`,u=!0;continue}let h=!1;for(let w of p){if(!w)continue;let E=`${w}/${y}`;if(await e.fs.exists(E)){e.state.hashTable.set(y,E),h=!0;break}}h||(f+=`bash: hash: ${y}: not found\n`,u=!0)}return u?A(f,1):W}var Jn=new Map([[\":\",[\": [arguments]\",`Null command.\n No effect; the command does nothing.\n Exit Status:\n Always succeeds.`]],[\".\",[\". filename [arguments]\",`Execute commands from a file in the current shell.\n Read and execute commands from FILENAME in the current shell.\n The entries in $PATH are used to find the directory containing FILENAME.\n Exit Status:\n Returns the status of the last command executed in FILENAME.`]],[\"[\",[\"[ arg... ]\",`Evaluate conditional expression.\n This is a synonym for the \"test\" builtin, but the last argument must\n be a literal \\`]', to match the opening \\`['.`]],[\"alias\",[\"alias [-p] [name[=value] ... ]\",`Define or display aliases.\n Without arguments, \\`alias' prints the list of aliases in the reusable\n form \\`alias NAME=VALUE' on standard output.\n Exit Status:\n alias returns true unless a NAME is supplied for which no alias has been\n defined.`]],[\"bg\",[\"bg [job_spec ...]\",`Move jobs to the background.\n Place the jobs identified by each JOB_SPEC in the background, as if they\n had been started with \\`&'.`]],[\"break\",[\"break [n]\",`Exit for, while, or until loops.\n Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing\n loops.\n Exit Status:\n The exit status is 0 unless N is not greater than or equal to 1.`]],[\"builtin\",[\"builtin [shell-builtin [arg ...]]\",`Execute shell builtins.\n Execute SHELL-BUILTIN with arguments ARGs without performing command\n lookup. This is useful when you wish to reimplement a shell builtin\n as a shell function, but need to execute the builtin within the function.\n Exit Status:\n Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is\n not a shell builtin.`]],[\"caller\",[\"caller [expr]\",`Return the context of the current subroutine call.\n Without EXPR, returns \"$line $filename\". With EXPR, returns\n \"$line $subroutine $filename\"; this extra information can be used to\n provide a stack trace.\n Exit Status:\n Returns 0 unless the shell is not executing a subroutine call or\n EXPR is invalid.`]],[\"cd\",[\"cd [-L|-P] [dir]\",`Change the shell working directory.\n Change the current directory to DIR. The default DIR is the value of the\n HOME shell variable.\n\n The variable CDPATH defines the search path for the directory containing\n DIR. Alternative directory names in CDPATH are separated by a colon (:).\n A null directory name is the same as the current directory. If DIR begins\n with a slash (/), then CDPATH is not used.\n\n If the directory is not found, and the shell option \\`cdable_vars' is set,\n the word is assumed to be a variable name. If that variable has a value,\n its value is used for DIR.\n\n Options:\n -L\tforce symbolic links to be followed\n -P\tuse the physical directory structure without following symbolic\n \tlinks\n\n The default is to follow symbolic links, as if \\`-L' were specified.\n\n Exit Status:\n Returns 0 if the directory is changed; non-zero otherwise.`]],[\"command\",[\"command [-pVv] command [arg ...]\",`Execute a simple command or display information about commands.\n Runs COMMAND with ARGS suppressing shell function lookup, or display\n information about the specified COMMANDs.\n\n Options:\n -p\tuse a default value for PATH that is guaranteed to find all of\n \tthe standard utilities\n -v\tprint a description of COMMAND similar to the \\`type' builtin\n -V\tprint a more verbose description of each COMMAND\n\n Exit Status:\n Returns exit status of COMMAND, or failure if COMMAND is not found.`]],[\"compgen\",[\"compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]\",`Display possible completions depending on the options.\n Intended to be used from within a shell function generating possible\n completions. If the optional WORD argument is supplied, matches against\n WORD are generated.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"complete\",[\"complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]\",`Specify how arguments are to be completed.\n For each NAME, specify how arguments are to be completed.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"continue\",[\"continue [n]\",`Resume for, while, or until loops.\n Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.\n If N is specified, resumes the Nth enclosing loop.\n Exit Status:\n The exit status is 0 unless N is not greater than or equal to 1.`]],[\"declare\",[\"declare [-aAfFgilnrtux] [-p] [name[=value] ...]\",`Set variable values and attributes.\n Declare variables and give them attributes. If no NAMEs are given,\n display the attributes and values of all variables.\n\n Options:\n -a\tto make NAMEs indexed arrays (if supported)\n -A\tto make NAMEs associative arrays (if supported)\n -i\tto make NAMEs have the \\`integer' attribute\n -l\tto convert the value of each NAME to lower case on assignment\n -n\tmake NAME a reference to the variable named by its value\n -r\tto make NAMEs readonly\n -t\tto make NAMEs have the \\`trace' attribute\n -u\tto convert the value of each NAME to upper case on assignment\n -x\tto make NAMEs export\n\n Exit Status:\n Returns success unless an invalid option is supplied or a variable\n assignment error occurs.`]],[\"dirs\",[\"dirs [-clpv] [+N] [-N]\",`Display directory stack.\n Display the list of currently remembered directories. Directories\n find their way onto the list with the \\`pushd' command; you can get\n back up through the list with the \\`popd' command.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"disown\",[\"disown [-h] [-ar] [jobspec ...]\",`Remove jobs from current shell.\n Without any JOBSPECs, remove the current job.`]],[\"echo\",[\"echo [-neE] [arg ...]\",`Write arguments to the standard output.\n Display the ARGs, separated by a single space character and followed by a\n newline, on the standard output.\n\n Options:\n -n\tdo not append a newline\n -e\tenable interpretation of the following backslash escapes\n -E\texplicitly suppress interpretation of backslash escapes\n\n Exit Status:\n Returns success unless a write error occurs.`]],[\"enable\",[\"enable [-a] [-dnps] [-f filename] [name ...]\",`Enable and disable shell builtins.\n Enables and disables builtin shell commands.\n Exit Status:\n Returns success unless NAME is not a shell builtin or an error occurs.`]],[\"eval\",[\"eval [arg ...]\",`Execute arguments as a shell command.\n Combine ARGs into a single string, use the result as input to the shell,\n and execute the resulting commands.\n Exit Status:\n Returns exit status of command or success if command is null.`]],[\"exec\",[\"exec [-cl] [-a name] [command [arguments ...]] [redirection ...]\",`Replace the shell with the given command.\n Execute COMMAND, replacing this shell with the specified program.\n ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,\n any redirections take effect in the current shell.\n Exit Status:\n Returns success unless COMMAND is not found or a redirection error occurs.`]],[\"exit\",[\"exit [n]\",`Exit the shell.\n Exits the shell with a status of N. If N is omitted, the exit status\n is that of the last command executed.`]],[\"export\",[\"export [-fn] [name[=value] ...] or export -p\",`Set export attribute for shell variables.\n Marks each NAME for automatic export to the environment of subsequently\n executed commands. If VALUE is supplied, assign VALUE before exporting.\n\n Options:\n -f\trefer to shell functions\n -n\tremove the export property from each NAME\n -p\tdisplay a list of all exported variables and functions\n\n Exit Status:\n Returns success unless an invalid option is given or NAME is invalid.`]],[\"false\",[\"false\",`Return an unsuccessful result.\n Exit Status:\n Always fails.`]],[\"fc\",[\"fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]\",`Display or execute commands from the history list.\n Exit Status:\n Returns success or status of executed command.`]],[\"fg\",[\"fg [job_spec]\",`Move job to the foreground.\n Place the job identified by JOB_SPEC in the foreground, making it the\n current job.`]],[\"getopts\",[\"getopts optstring name [arg]\",`Parse option arguments.\n Getopts is used by shell procedures to parse positional parameters\n as options.\n\n OPTSTRING contains the option letters to be recognized; if a letter\n is followed by a colon, the option is expected to have an argument,\n which should be separated from it by white space.\n Exit Status:\n Returns success if an option is found; fails if the end of options is\n encountered or an error occurs.`]],[\"hash\",[\"hash [-lr] [-p pathname] [-dt] [name ...]\",`Remember or display program locations.\n Determine and remember the full pathname of each command NAME.\n Exit Status:\n Returns success unless NAME is not found or an invalid option is given.`]],[\"help\",[\"help [-s] [pattern ...]\",`Display information about builtin commands.\n Displays brief summaries of builtin commands. If PATTERN is\n specified, gives detailed help on all commands matching PATTERN,\n otherwise the list of help topics is printed.\n\n Options:\n -s\toutput only a short usage synopsis for each topic matching\n \tPATTERN\n\n Exit Status:\n Returns success unless PATTERN is not found.`]],[\"history\",[\"history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]\",`Display or manipulate the history list.\n Display the history list with line numbers, prefixing each modified\n entry with a \\`*'.\n Exit Status:\n Returns success unless an invalid option is given or an error occurs.`]],[\"jobs\",[\"jobs [-lnprs] [jobspec ...] or jobs -x command [args]\",`Display status of jobs.\n Lists the active jobs.\n Exit Status:\n Returns success unless an invalid option is given or an error occurs.`]],[\"kill\",[\"kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]\",`Send a signal to a job.\n Send the processes identified by PID or JOBSPEC the signal named by\n SIGSPEC or SIGNUM.\n Exit Status:\n Returns success unless an invalid option is given or an error occurs.`]],[\"let\",[\"let arg [arg ...]\",`Evaluate arithmetic expressions.\n Evaluate each ARG as an arithmetic expression. Evaluation is done in\n fixed-width integers with no check for overflow, though division by 0\n is trapped and flagged as an error.\n Exit Status:\n If the last ARG evaluates to 0, let returns 1; 0 is returned otherwise.`]],[\"local\",[\"local [option] name[=value] ...\",`Define local variables.\n Create a local variable called NAME, and give it VALUE. OPTION can\n be any option accepted by \\`declare'.\n\n Local can only be used within a function; it makes the variable NAME\n have a visible scope restricted to that function and its children.\n Exit Status:\n Returns success unless an invalid option is supplied, a variable\n assignment error occurs, or the shell is not executing a function.`]],[\"logout\",[\"logout [n]\",`Exit a login shell.\n Exits a login shell with exit status N. Returns an error if not executed\n in a login shell.`]],[\"mapfile\",[\"mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]\",`Read lines from the standard input into an indexed array variable.\n Read lines from the standard input into the indexed array variable ARRAY,\n or from file descriptor FD if the -u option is supplied.\n\n Options:\n -d delim\tUse DELIM to terminate lines, instead of newline\n -n count\tCopy at most COUNT lines\n -O origin\tBegin assigning to ARRAY at index ORIGIN\n -s count\tDiscard the first COUNT lines read\n -t\tRemove a trailing DELIM from each line read (default newline)\n -u fd\tRead lines from file descriptor FD instead of standard input\n\n Exit Status:\n Returns success unless an invalid option is given or ARRAY is readonly.`]],[\"popd\",[\"popd [-n] [+N | -N]\",`Remove directories from stack.\n Removes entries from the directory stack.\n Exit Status:\n Returns success unless an invalid argument is supplied or the directory\n change fails.`]],[\"printf\",[\"printf [-v var] format [arguments]\",`Formats and prints ARGUMENTS under control of the FORMAT.\n\n Options:\n -v var\tassign the output to shell variable VAR rather than\n \t\tdisplay it on the standard output\n\n FORMAT is a character string which contains three types of objects: plain\n characters, which are simply copied to standard output; character escape\n sequences, which are converted and copied to the standard output; and\n format specifications, each of which causes printing of the next successive\n argument.\n Exit Status:\n Returns success unless an invalid option is given or a write or assignment\n error occurs.`]],[\"pushd\",[\"pushd [-n] [+N | -N | dir]\",`Add directories to stack.\n Adds a directory to the top of the directory stack, or rotates\n the stack, making the new top of the stack the current working\n directory.\n Exit Status:\n Returns success unless an invalid argument is supplied or the directory\n change fails.`]],[\"pwd\",[\"pwd [-LP]\",`Print the name of the current working directory.\n\n Options:\n -L\tprint the value of $PWD if it names the current working\n \tdirectory\n -P\tprint the physical directory, without any symbolic links\n\n By default, \\`pwd' behaves as if \\`-L' were specified.\n Exit Status:\n Returns 0 unless an invalid option is given or the current directory\n cannot be read.`]],[\"read\",[\"read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]\",`Read a line from the standard input and split it into fields.\n Reads a single line from the standard input, or from file descriptor FD\n if the -u option is supplied. The line is split into fields as with word\n splitting, and the first word is assigned to the first NAME, the second\n word to the second NAME, and so on, with any leftover words assigned to\n the last NAME.\n Exit Status:\n The return code is zero, unless end-of-file is encountered, read times out,\n or an invalid file descriptor is supplied as the argument to -u.`]],[\"readarray\",[\"readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]\",\"Read lines from a file into an array variable.\\n A synonym for `mapfile'.\"]],[\"readonly\",[\"readonly [-aAf] [name[=value] ...] or readonly -p\",`Mark shell variables as unchangeable.\n Mark each NAME as read-only; the values of these NAMEs may not be\n changed by subsequent assignment.\n Exit Status:\n Returns success unless an invalid option is given or NAME is invalid.`]],[\"return\",[\"return [n]\",`Return from a shell function.\n Causes a function or sourced script to exit with the return value\n specified by N. If N is omitted, the return status is that of the\n last command executed within the function or script.\n Exit Status:\n Returns N, or failure if the shell is not executing a function or script.`]],[\"set\",[\"set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]\",`Set or unset values of shell options and positional parameters.\n Change the value of shell attributes and positional parameters, or\n display the names and values of shell variables.\n\n Options:\n -e Exit immediately if a command exits with a non-zero status.\n -u Treat unset variables as an error when substituting.\n -x Print commands and their arguments as they are executed.\n -o option-name\n Set the variable corresponding to option-name\n\n Exit Status:\n Returns success unless an invalid option is given.`]],[\"shift\",[\"shift [n]\",`Shift positional parameters.\n Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is\n not given, it is assumed to be 1.\n Exit Status:\n Returns success unless N is negative or greater than $#.`]],[\"shopt\",[\"shopt [-pqsu] [-o] [optname ...]\",`Set and unset shell options.\n Change the setting of each shell option OPTNAME. Without any option\n arguments, list each supplied OPTNAME, or all shell options if no\n OPTNAMEs are given, with an indication of whether or not each is set.\n\n Options:\n -o\trestrict OPTNAMEs to those defined for use with \\`set -o'\n -p\tprint each shell option with an indication of its status\n -q\tsuppress output\n -s\tenable (set) each OPTNAME\n -u\tdisable (unset) each OPTNAME\n\n Exit Status:\n Returns success if OPTNAME is enabled; fails if an invalid option is\n given or OPTNAME is disabled.`]],[\"source\",[\"source filename [arguments]\",`Execute commands from a file in the current shell.\n Read and execute commands from FILENAME in the current shell.\n The entries in $PATH are used to find the directory containing FILENAME.\n Exit Status:\n Returns the status of the last command executed in FILENAME.`]],[\"suspend\",[\"suspend [-f]\",`Suspend shell execution.\n Suspend the execution of this shell until it receives a SIGCONT signal.`]],[\"test\",[\"test [expr]\",`Evaluate conditional expression.\n Exits with a status of 0 (true) or 1 (false) depending on\n the evaluation of EXPR. Expressions may be unary or binary.\n Exit Status:\n Returns success if EXPR evaluates to true; fails if EXPR evaluates to\n false or an invalid argument is given.`]],[\"times\",[\"times\",`Display process times.\n Prints the accumulated user and system times for the shell and all of its\n child processes.\n Exit Status:\n Always succeeds.`]],[\"trap\",[\"trap [-lp] [[arg] signal_spec ...]\",`Trap signals and other events.\n Defines and activates handlers to be run when the shell receives signals\n or other conditions.\n Exit Status:\n Returns success unless a SIGSPEC is invalid or an invalid option is given.`]],[\"true\",[\"true\",`Return a successful result.\n Exit Status:\n Always succeeds.`]],[\"type\",[\"type [-afptP] name [name ...]\",`Display information about command type.\n For each NAME, indicate how it would be interpreted if used as a\n command name.\n\n Options:\n -a\tdisplay all locations containing an executable named NAME\n -f\tsuppress shell function lookup\n -P\tforce a PATH search for each NAME, even if it is an alias,\n \tbuiltin, or function, and returns the name of the disk file\n \tthat would be executed\n -p\treturns either the name of the disk file that would be executed,\n \tor nothing if \\`type -t NAME' would not return \\`file'\n -t\toutput a single word which is one of \\`alias', \\`keyword',\n \t\\`function', \\`builtin', \\`file' or \\`', if NAME is an alias,\n \tshell reserved word, shell function, shell builtin, disk file,\n \tor not found, respectively\n\n Exit Status:\n Returns success if all of the NAMEs are found; fails if any are not found.`]],[\"typeset\",[\"typeset [-aAfFgilnrtux] [-p] name[=value] ...\",\"Set variable values and attributes.\\n A synonym for `declare'.\"]],[\"ulimit\",[\"ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]\",`Modify shell resource limits.\n Provides control over the resources available to the shell and processes\n it creates, on systems that allow such control.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"umask\",[\"umask [-p] [-S] [mode]\",`Display or set file mode mask.\n Sets the user file-creation mask to MODE. If MODE is omitted, prints\n the current value of the mask.\n Exit Status:\n Returns success unless MODE is invalid or an invalid option is given.`]],[\"unalias\",[\"unalias [-a] name [name ...]\",`Remove each NAME from the list of defined aliases.\n Exit Status:\n Returns success unless a NAME is not an existing alias.`]],[\"unset\",[\"unset [-f] [-v] [-n] [name ...]\",`Unset values and attributes of shell variables and functions.\n For each NAME, remove the corresponding variable or function.\n\n Options:\n -f\ttreat each NAME as a shell function\n -v\ttreat each NAME as a shell variable\n -n\ttreat each NAME as a name reference and unset the variable itself\n \trather than the variable it references\n\n Without options, unset first tries to unset a variable, and if that fails,\n tries to unset a function.\n Exit Status:\n Returns success unless an invalid option is given or a NAME is read-only.`]],[\"wait\",[\"wait [-fn] [id ...]\",`Wait for job completion and return exit status.\n Waits for each process identified by an ID, which may be a process ID or a\n job specification, and reports its termination status.\n Exit Status:\n Returns the status of the last ID; fails if ID is invalid or an invalid\n option is given.`]]]),ei=[...Jn.keys()].sort();function kr(e,t){let s=!1,r=[],n=0;for(;n<t.length;){let l=t[n];if(l===\"--\"){for(n++;n<t.length;)r.push(t[n]),n++;break}if(l.startsWith(\"-\")&&l.length>1){for(let c=1;c<l.length;c++){let u=l[c];if(u===\"s\")s=!0;else return A(`bash: help: -${u}: invalid option\n`,2)}n++}else r.push(l),n++}if(r.length===0)return aa();let i=\"\",o=!1,a=\"\";for(let l of r){let c=oa(l);if(c.length===0){a+=`bash: help: no help topics match \\`${l}'. Try \\`help help' or \\`man -k ${l}' or \\`info ${l}'.\n`,o=!0;continue}for(let u of c){let f=Jn.get(u);if(!f)continue;let[d,p]=f;s?i+=`${u}: ${d}\n`:i+=`${u}: ${d}\n${p}\n`}}return{exitCode:o?1:0,stdout:i,stderr:a}}function oa(e){let t=e.replace(/[.+^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/\\*/g,\".*\").replace(/\\?/g,\".\"),s=kt(`^${t}$`);return ei.filter(r=>s.test(r))}function aa(){let e=[];e.push(\"just-bash shell builtins\"),e.push(\"These shell commands are defined internally. Type `help' to see this list.\"),e.push(\"Type `help name' to find out more about the function `name'.\"),e.push(\"\");let t=36,s=ei.slice(),r=Math.ceil(s.length/2);for(let n=0;n<r;n++){let i=s[n]||\"\",o=s[n+r]||\"\",a=i.padEnd(t);e.push(o?`${a}${o}`:i)}return z(`${e.join(`\n`)}\n`)}function la(e){let t=[],s=\"\",r=0;for(let n of e){for(let i of n)i===\"(\"?r++:i===\")\"&&r--;s?s+=` ${n}`:s=n,r===0&&(t.push(s),s=\"\")}return s&&t.push(s),t}async function _r(e,t){if(t.length===0)return A(`bash: let: expression expected\n`);let s=la(t),r=0;for(let n of s)try{let o=fe(`(( ${n} ))`).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 H(e,a.expression.expression))}}catch(i){return A(`bash: let: ${n}: ${i.message}\n`)}return _(\"\",\"\",r===0?1:0)}async function Cr(e,t){if(e.state.localScopes.length===0)return A(`bash: local: can only be used in a function\n`);let s=e.state.localScopes[e.state.localScopes.length-1],r=\"\",n=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(s.keys()).filter(f=>!f.includes(\"_\")||!f.match(/_\\d+$/)).filter(f=>!f.includes(\"__length\")).sort();for(let f of u){let d=e.state.env.get(f);d!==void 0&&(c+=`${f}=${d}\n`)}return _(c,\"\",0)}for(let c of l){let u,f,d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\((.*)\\)$/s);if(d){u=d[1];let E=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \\`${c}': not a valid identifier\n`,n=1;continue}if(se(e,u,\"bash\"),!s.has(u)){s.set(u,e.state.env.get(u));let m=`${u}_`;for(let v of e.state.env.keys())v.startsWith(m)&&!v.includes(\"__\")&&(s.has(v)||s.set(v,e.state.env.get(v)))}let g=`${u}_`;for(let m of e.state.env.keys())m.startsWith(g)&&!m.includes(\"__\")&&e.state.env.delete(m);let b=De(E);for(let m=0;m<b.length;m++)e.state.env.set(`${u}_${m}`,b[m]);e.state.env.set(`${u}__length`,String(b.length)),Xe(e,u),i&&We(e,u);continue}let p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=\\((.*)\\)$/s);if(p){u=p[1];let E=p[2];if(se(e,u,\"bash\"),!s.has(u)){s.set(u,e.state.env.get(u));let S=`${u}_`;for(let N of e.state.env.keys())N.startsWith(S)&&!N.includes(\"__\")&&(s.has(N)||s.set(N,e.state.env.get(N)));let T=`${u}__length`;e.state.env.has(T)&&!s.has(T)&&s.set(T,e.state.env.get(T))}let g=De(E),b=ne(e,u),m=0,v=e.state.env.get(u);b.length===0&&v!==void 0?(e.state.env.set(`${u}_0`,v),e.state.env.delete(u),m=1):b.length>0&&(m=Math.max(...b)+1);for(let S=0;S<g.length;S++)e.state.env.set(`${u}_${m+S}`,X(e,g[S]));let $=m+g.length;e.state.env.set(`${u}__length`,String($)),Xe(e,u),i&&We(e,u);continue}let y=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=(.*)$/);if(y){u=y[1];let E=X(e,y[2]);se(e,u,\"bash\"),s.has(u)||s.set(u,e.state.env.get(u));let g=e.state.env.get(u)??\"\";e.state.env.set(u,g+E),Xe(e,u),i&&We(e,u);continue}let h=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([^\\]]+)\\]=(.*)$/s);if(h){u=h[1];let E=h[2],g=X(e,h[3]);if(se(e,u,\"bash\"),!s.has(u)){s.set(u,e.state.env.get(u));let v=`${u}_`;for(let S of e.state.env.keys())S.startsWith(v)&&!S.includes(\"__\")&&(s.has(S)||s.set(S,e.state.env.get(S)));let $=`${u}__length`;e.state.env.has($)&&!s.has($)&&s.set($,e.state.env.get($))}let b;try{let v=new B,$=ee(v,E);b=await H(e,$.expression)}catch{let v=parseInt(E,10);b=Number.isNaN(v)?0:v}e.state.env.set(`${u}_${b}`,g);let m=parseInt(e.state.env.get(`${u}__length`)??\"0\",10);b>=m&&e.state.env.set(`${u}__length`,String(b+1)),Xe(e,u),i&&We(e,u);continue}if(c.includes(\"=\")){let E=c.indexOf(\"=\");u=c.slice(0,E),f=X(e,c.slice(E+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \\`${c}': not a valid identifier\n`,n=1;continue}let w=s.has(u);if(f!==void 0){let E=e.state.env.get(u);if(e.state.tempEnvBindings){let g=e.state.accessedTempEnvVars?.has(u),b=e.state.mutatedTempEnvVars?.has(u);if(!g&&!b)for(let m=e.state.tempEnvBindings.length-1;m>=0;m--){let v=e.state.tempEnvBindings[m];if(v.has(u)){E=v.get(u);break}}}Mn(e,u,E)}if(!w){let E=e.state.env.get(u);if(e.state.tempEnvBindings)for(let g=e.state.tempEnvBindings.length-1;g>=0;g--){let b=e.state.tempEnvBindings[g];if(b.has(u)){E=b.get(u);break}}if(s.set(u,E),o){let g=`${u}_`;for(let m of e.state.env.keys())m.startsWith(g)&&!m.includes(\"__\")&&(s.has(m)||s.set(m,e.state.env.get(m)));let b=`${u}__length`;e.state.env.has(b)&&!s.has(b)&&s.set(b,e.state.env.get(b))}}if(o&&f===void 0){let E=`${u}_`;for(let g of e.state.env.keys())g.startsWith(E)&&!g.includes(\"__\")&&e.state.env.delete(g);e.state.env.set(`${u}__length`,\"0\")}else if(f!==void 0){if(se(e,u,\"bash\"),i&&f!==\"\"&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(f)){r+=`bash: local: \\`${f}': invalid variable name for name reference\n`,n=1;continue}e.state.env.set(u,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(u))}else{let E=e.state.tempEnvBindings?.some(g=>g.has(u));!w&&!E&&e.state.env.delete(u)}Xe(e,u),i&&We(e,u)}return _(\"\",r,n)}function Nr(e,t,s){let r=`\n`,n=0,i=0,o=0,a=!1,l=\"MAPFILE\",c=0;for(;c<t.length;){let g=t[c];g===\"-d\"&&c+1<t.length?(r=t[c+1]===\"\"?\"\\0\":t[c+1]||`\n`,c+=2):g===\"-n\"&&c+1<t.length?(n=Number.parseInt(t[c+1],10)||0,c+=2):g===\"-O\"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):g===\"-s\"&&c+1<t.length?(o=Number.parseInt(t[c+1],10)||0,c+=2):g===\"-t\"?(a=!0,c++):g===\"-u\"||g===\"-C\"||g===\"-c\"?c+=2:(g.startsWith(\"-\")||(l=g),c++)}let u=s;!u&&e.state.groupStdin!==void 0&&(u=e.state.groupStdin);let f=[],d=u,p=0,y=0,h=e.limits?.maxArrayElements??1e5;for(;d.length>0;){let g=d.indexOf(r);if(g===-1){if(d.length>0){if(y<o)y++;else if(n===0||p<n){if(i+p>=h)return _(\"\",`mapfile: array element limit exceeded (${h})\n`,1);let v=d,$=v.indexOf(\"\\0\");$!==-1&&(v=v.substring(0,$)),f.push(v),p++}}break}let b=d.substring(0,g),m=b.indexOf(\"\\0\");if(m!==-1&&(b=b.substring(0,m)),!a&&r!==\"\\0\"&&(b+=r),d=d.substring(g+r.length),y<o){y++;continue}if(n>0&&p>=n)break;if(i+p>=h)return _(\"\",`mapfile: array element limit exceeded (${h})\n`,1);f.push(b),p++}i===0&&Oe(e,l);for(let g=0;g<f.length;g++)e.state.env.set(`${l}_${i+g}`,f[g]);let w=parseInt(e.state.env.get(`${l}__length`)||\"0\",10),E=i+f.length;return e.state.env.set(`${l}__length`,String(Math.max(w,E))),e.state.groupStdin!==void 0&&!s&&(e.state.groupStdin=\"\"),_(\"\",\"\",0)}function ca(e){if(!e.startsWith(\"__rw__:\"))return null;let t=e.slice(7),s=t.indexOf(\":\");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+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 ua(e,t,s){return`__rw__:${e.length}:${e}:${t}:${s}`}function Or(e,t,s,r=-1){let n=!1,i=`\n`,o=\"\",a=-1,l=-1,c=null,u=-1,f=-1,d=[],p=0,y=!1,h=(k,C)=>{let D=1;for(;D<k.length;){let P=k[D];if(P===\"r\")n=!0,D++;else if(P===\"s\")D++;else{if(P===\"d\")return D+1<k.length?(i=k.substring(D+1),{nextArgIndex:C+1}):C+1<t.length?(i=t[C+1],{nextArgIndex:C+2}):{nextArgIndex:C+1};if(P===\"n\"){if(D+1<k.length){let R=k.substring(D+1);return a=Number.parseInt(R,10),(Number.isNaN(a)||a<0)&&(y=!0,a=0),{nextArgIndex:C+1}}else if(C+1<t.length)return a=Number.parseInt(t[C+1],10),(Number.isNaN(a)||a<0)&&(y=!0,a=0),{nextArgIndex:C+2};return{nextArgIndex:C+1}}else if(P===\"N\"){if(D+1<k.length){let R=k.substring(D+1);return l=Number.parseInt(R,10),(Number.isNaN(l)||l<0)&&(y=!0,l=0),{nextArgIndex:C+1}}else if(C+1<t.length)return l=Number.parseInt(t[C+1],10),(Number.isNaN(l)||l<0)&&(y=!0,l=0),{nextArgIndex:C+2};return{nextArgIndex:C+1}}else{if(P===\"a\")return D+1<k.length?(c=k.substring(D+1),{nextArgIndex:C+1}):C+1<t.length?(c=t[C+1],{nextArgIndex:C+2}):{nextArgIndex:C+1};if(P===\"p\")return D+1<k.length?(o=k.substring(D+1),{nextArgIndex:C+1}):C+1<t.length?(o=t[C+1],{nextArgIndex:C+2}):{nextArgIndex:C+1};if(P===\"u\"){if(D+1<k.length){let R=k.substring(D+1);return u=Number.parseInt(R,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:C+1}}else if(C+1<t.length)return u=Number.parseInt(t[C+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:C+2};return{nextArgIndex:C+1}}else if(P===\"t\"){if(D+1<k.length){let R=k.substring(D+1);return f=Number.parseFloat(R),Number.isNaN(f)&&(f=0),{nextArgIndex:C+1}}else if(C+1<t.length)return f=Number.parseFloat(t[C+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:C+2};return{nextArgIndex:C+1}}else if(P===\"e\"||P===\"i\"||P===\"P\"){if(P===\"i\"&&C+1<t.length)return{nextArgIndex:C+2};D++}else D++}}}return{nextArgIndex:C+1}};for(;p<t.length;){let k=t[p];if(k.startsWith(\"-\")&&k.length>1&&k!==\"--\"){let C=h(k,p);if(C.nextArgIndex===-1)return{stdout:\"\",stderr:\"\",exitCode:2};if(C.nextArgIndex===-2)return{stdout:\"\",stderr:\"\",exitCode:1};p=C.nextArgIndex}else if(k===\"--\")for(p++;p<t.length;)d.push(t[p]),p++;else d.push(k),p++}if(y)return _(\"\",\"\",1);if(d.length===0&&c===null&&d.push(\"REPLY\"),f===0){if(c)Oe(e,c);else{for(let k of d)e.state.env.set(k,\"\");d.length===0&&e.state.env.set(\"REPLY\",\"\")}return _(\"\",\"\",0)}if(f<0&&f!==-1)return _(\"\",\"\",1);let w=s;u>=0?e.state.fileDescriptors?w=e.state.fileDescriptors.get(u)||\"\":w=\"\":!w&&e.state.groupStdin!==void 0&&(w=e.state.groupStdin);let E=i===\"\"?\"\\0\":i,g=\"\",b=0,m=!0,v=k=>{if(u>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(u,w.substring(k));else if(r>=0&&e.state.fileDescriptors){let C=e.state.fileDescriptors.get(r);if(C?.startsWith(\"__rw__:\")){let D=ca(C);if(D){let P=D.position+k;e.state.fileDescriptors.set(r,ua(D.path,P,D.content))}}}else e.state.groupStdin!==void 0&&!s&&(e.state.groupStdin=w.substring(k))};if(l>=0){let k=Math.min(l,w.length);g=w.substring(0,k),b=k,m=k>=l,v(b);let C=d[0]||\"REPLY\";e.state.env.set(C,g);for(let D=1;D<d.length;D++)e.state.env.set(d[D],\"\");return _(\"\",\"\",m?0:1)}else if(a>=0){let k=0,C=0,D=!1;for(;C<w.length&&k<a;){let P=w[C];if(P===E){b=C+1,D=!0;break}if(!n&&P===\"\\\\\"&&C+1<w.length){let R=w[C+1];if(R===E&&E===`\n`){C+=2,b=C;continue}if(R===E){C+=2,k++,g+=R,b=C;continue}g+=R,C+=2,k++,b=C}else g+=P,C++,k++,b=C}m=k>=a||D,v(b)}else{b=0;let k=0;for(;k<w.length;){let C=w[k];if(C===E){b=k+E.length,m=!0;break}if(!n&&C===\"\\\\\"&&k+1<w.length){let D=w[k+1];if(D===`\n`){k+=2;continue}if(D===E){g+=D,k+=2;continue}g+=C,g+=D,k+=2;continue}g+=C,k++}if(k>=w.length&&(m=!1,b=k,g.length===0&&w.length===0)){for(let C of d)e.state.env.set(C,\"\");return c&&Oe(e,c),_(\"\",\"\",1)}v(b)}E===`\n`&&g.endsWith(`\n`)&&(g=g.slice(0,-1));let $=k=>n?k:k.replace(/\\\\(.)/g,\"$1\");if(d.length===1&&d[0]===\"REPLY\")return e.state.env.set(\"REPLY\",$(g)),_(\"\",\"\",m?0:1);let S=Jr(e.state.env);if(c){let{words:k}=zs(g,S,void 0,n),C=e.limits?.maxArrayElements??1e5;if(k.length>C)return _(\"\",`read: array element limit exceeded (${C})\n`,1);Oe(e,c);for(let D=0;D<k.length;D++)e.state.env.set(`${c}_${D}`,$(k[D]));return _(\"\",\"\",m?0:1)}let T=d.length,{words:N,wordStarts:F}=zs(g,S,T,n);for(let k=0;k<d.length;k++){let C=d[k];if(k<d.length-1)e.state.env.set(C,$(N[k]??\"\"));else if(k<F.length){let D=g.substring(F[k]);D=en(D,S,n),D=$(D),e.state.env.set(C,D)}else e.state.env.set(C,\"\")}return _(\"\",\"\",m?0:1)}function xr(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return A(\"bash: return: can only `return' from a function or sourced script\\n\");let s=e.state.lastExitCode;if(t.length>0){let r=t[0],n=Number.parseInt(r,10);if(r===\"\"||Number.isNaN(n)||!/^-?\\d+$/.test(r))return A(`bash: return: ${r}: numeric argument required\n`,2);s=(n%256+256)%256}throw new ue(s)}var bs=`set: usage: set [-eux] [+eux] [-o option] [+o option]\nOptions:\n -e Exit immediately if a command exits with non-zero status\n +e Disable -e\n -u Treat unset variables as an error when substituting\n +u Disable -u\n -x Print commands and their arguments as they are executed\n +x Disable -x\n -o errexit Same as -e\n +o errexit Disable errexit\n -o nounset Same as -u\n +o nounset Disable nounset\n -o pipefail Return status of last failing command in pipeline\n +o pipefail Disable pipefail\n -o xtrace Same as -x\n +o xtrace Disable xtrace\n`,ti=new Map([[\"e\",\"errexit\"],[\"u\",\"nounset\"],[\"x\",\"xtrace\"],[\"v\",\"verbose\"],[\"f\",\"noglob\"],[\"C\",\"noclobber\"],[\"a\",\"allexport\"],[\"n\",\"noexec\"],[\"h\",null],[\"b\",null],[\"m\",null],[\"B\",null],[\"H\",null],[\"P\",null],[\"T\",null],[\"E\",null],[\"p\",null]]),si=new Map([[\"errexit\",\"errexit\"],[\"pipefail\",\"pipefail\"],[\"nounset\",\"nounset\"],[\"xtrace\",\"xtrace\"],[\"verbose\",\"verbose\"],[\"noclobber\",\"noclobber\"],[\"noglob\",\"noglob\"],[\"allexport\",\"allexport\"],[\"noexec\",\"noexec\"],[\"posix\",\"posix\"],[\"vi\",\"vi\"],[\"emacs\",\"emacs\"],[\"notify\",null],[\"monitor\",null],[\"braceexpand\",null],[\"histexpand\",null],[\"physical\",null],[\"functrace\",null],[\"errtrace\",null],[\"privileged\",null],[\"hashall\",null],[\"ignoreeof\",null],[\"interactive-comments\",null],[\"keyword\",null],[\"onecmd\",null]]),ri=[\"errexit\",\"nounset\",\"pipefail\",\"verbose\",\"xtrace\",\"posix\",\"allexport\",\"noclobber\",\"noglob\",\"noexec\",\"vi\",\"emacs\"],ni=[\"braceexpand\",\"errtrace\",\"functrace\",\"hashall\",\"histexpand\",\"history\",\"ignoreeof\",\"interactive-comments\",\"keyword\",\"monitor\",\"nolog\",\"notify\",\"onecmd\",\"physical\",\"privileged\"];function ii(e,t,s){t!==null&&(s&&(t===\"vi\"?e.state.options.emacs=!1:t===\"emacs\"&&(e.state.options.vi=!1)),e.state.options[t]=s,dt(e))}function fa(e,t){return t+1<e.length&&!e[t+1].startsWith(\"-\")&&!e[t+1].startsWith(\"+\")}function da(e,t){let s=ne(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=e.state.env.get(`${t}_${n}`)??\"\";return`[${n}]=${nt(i)}`});return`${t}=(${r.join(\" \")})`}function ha(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`\"${e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"')}\"`}function pa(e,t){let s=He(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=e.state.env.get(`${t}_${n}`)??\"\";return`[${ha(n)}]=${nt(i)}`});return`${t}=(${r.join(\" \")} )`}function ma(e){let t=new Set,s=e.state.associativeArrays??new Set;for(let r of e.state.env.keys()){let n=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\\d+)$/);if(n){let i=n[1];s.has(i)||t.add(i)}}return t}function ya(e){return e.state.associativeArrays??new Set}function Dr(e,t){if(t.includes(\"--help\"))return z(bs);if(t.length===0){let r=ma(e),n=ya(e),i=l=>{for(let c of n){let u=`${c}_`,f=`${c}__length`;if(l!==f&&l.startsWith(u)){if(l.slice(u.length).startsWith(\"_length\"))continue;return!0}}return!1},o=[];for(let[l,c]of e.state.env){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)||r.has(l)||n.has(l))continue;let u=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\\d+)$/);if(u&&r.has(u[1]))continue;let f=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&r.has(f[1])||i(l)||f&&n.has(f[1])||o.push([l,c])}let a=[];for(let[l,c]of o.sort(([u],[f])=>u<f?-1:u>f?1:0))a.push(`${l}=${gs(c)}`);for(let l of[...r].sort((c,u)=>c<u?-1:c>u?1:0))a.push(da(e,l));for(let l of[...n].sort((c,u)=>c<u?-1:c>u?1:0))a.push(pa(e,l));return a.sort((l,c)=>{let u=l.split(\"=\")[0],f=c.split(\"=\")[0];return u<f?-1:u>f?1:0}),z(a.length>0?`${a.join(`\n`)}\n`:\"\")}let s=0;for(;s<t.length;){let r=t[s];if((r===\"-o\"||r===\"+o\")&&fa(t,s)){let n=t[s+1];if(!si.has(n)){let i=`bash: set: ${n}: invalid option name\n${bs}`;if(e.state.options.posix)throw new Pe(1,\"\",i);return A(i)}ii(e,si.get(n)??null,r===\"-o\"),s+=2;continue}if(r===\"-o\"){let n=ri.map(a=>`${a.padEnd(16)}${e.state.options[a]?\"on\":\"off\"}`),i=ni.map(a=>`${a.padEnd(16)}off`),o=[...n,...i].sort();return z(`${o.join(`\n`)}\n`)}if(r===\"+o\"){let n=ri.map(a=>`set ${e.state.options[a]?\"-o\":\"+o\"} ${a}`),i=ni.map(a=>`set +o ${a}`),o=[...n,...i].sort();return z(`${o.join(`\n`)}\n`)}if(r.length>1&&(r[0]===\"-\"||r[0]===\"+\")&&r[1]!==\"-\"){let n=r[0]===\"-\";for(let i=1;i<r.length;i++){let o=r[i];if(!ti.has(o)){let a=`bash: set: ${r[0]}${o}: invalid option\n${bs}`;if(e.state.options.posix)throw new Pe(1,\"\",a);return A(a)}ii(e,ti.get(o)??null,n)}s++;continue}if(r===\"--\")return Tr(e,t.slice(s+1)),W;if(r===\"-\"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,dt(e),s+1<t.length)return Tr(e,t.slice(s+1)),W;s++;continue}if(r===\"+\"){s++;continue}if(r.startsWith(\"-\")||r.startsWith(\"+\")){let n=`bash: set: ${r}: invalid option\n${bs}`;if(e.state.options.posix)throw new Pe(1,\"\",n);return A(n)}return Tr(e,t.slice(s)),W}return W}function Tr(e,t){let s=1;for(;e.state.env.has(String(s));)e.state.env.delete(String(s)),s++;for(let r=0;r<t.length;r++)e.state.env.set(String(r+1),t[r]);e.state.env.set(\"#\",String(t.length)),e.state.env.set(\"@\",t.join(\" \")),e.state.env.set(\"*\",t.join(\" \"))}function Rr(e,t){let s=1;if(t.length>0){let o=Number.parseInt(t[0],10);if(Number.isNaN(o)||o<0){let a=`bash: shift: ${t[0]}: numeric argument required\n`;if(e.state.options.posix)throw new Pe(1,\"\",a);return A(a)}s=o}let r=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);if(s>r){let o=`bash: shift: shift count out of range\n`;if(e.state.options.posix)throw new Pe(1,\"\",o);return A(o)}if(s===0)return W;let n=[];for(let o=1;o<=r;o++)n.push(e.state.env.get(String(o))||\"\");let i=n.slice(s);for(let o=1;o<=r;o++)e.state.env.delete(String(o));for(let o=0;o<i.length;o++)e.state.env.set(String(o+1),i[o]);return e.state.env.set(\"#\",String(i.length)),e.state.env.set(\"@\",i.join(\" \")),W}async function Ir(e,t){let s=t;if(s.length>0&&s[0]===\"--\"&&(s=s.slice(1)),s.length===0)return _(\"\",`bash: source: filename argument required\n`,2);let r=s[0],n=null,i=null;if(r.includes(\"/\")){let c=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(c),n=c}catch{}}else{let u=(e.state.env.get(\"PATH\")||\"\").split(\":\").filter(f=>f);for(let f of u){let d=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(d)).isDirectory)continue;i=await e.fs.readFile(d),n=d;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(f),n=f}catch{}}}if(i===null)return A(`bash: ${r}: No such file or directory\n`);let o=new Map;if(s.length>1){for(let u=1;u<=9;u++)o.set(String(u),e.state.env.get(String(u)));o.set(\"#\",e.state.env.get(\"#\")),o.set(\"@\",e.state.env.get(\"@\"));let c=s.slice(1);e.state.env.set(\"#\",String(c.length)),e.state.env.set(\"@\",c.join(\" \"));for(let u=0;u<c.length&&u<9;u++)e.state.env.set(String(u+1),c[u]);for(let u=c.length+1;u<=9;u++)e.state.env.delete(String(u))}let a=e.state.currentSource,l=()=>{if(e.state.sourceDepth--,e.state.currentSource=a,s.length>1)for(let[c,u]of o)u===void 0?e.state.env.delete(c):e.state.env.set(c,u)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new J(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,\"recursion\");e.state.currentSource=r;try{let c=fe(i),u=await e.executeScript(c);return l(),u}catch(c){if(l(),c instanceof j)throw c;if(c instanceof ue)return _(c.stdout,c.stderr,c.exitCode);if(c.name===\"ParseException\")return A(`bash: ${r}: ${c.message}\n`);throw c}}function oi(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function ga(e){return e.startsWith(\"'\")&&e.endsWith(\"'\")||e.startsWith('\"')&&e.endsWith('\"')}async function ai(e,t){if(ga(t))return null;try{let s=new B,r=ee(s,t);return await H(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function li(e,t){if(e.state.localVarStack?.has(t)){let r=ps(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let n=e.state.localVarStack?.get(t);if(!n||n.length===0)hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),Lr(e,t);else{let i=n[n.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let n=e.state.localScopes[r];if(n.has(t)){let i=n.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t);let 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||hs(e,t),!0}}return!1}function Lr(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let s=e.state.tempEnvBindings.length-1;s>=0;s--){let r=e.state.tempEnvBindings[s];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function ci(e,t){if(t.startsWith(\"'\")&&t.endsWith(\"'\"))return t.slice(1,-1);if(t.startsWith('\"')&&t.endsWith('\"')){let s=t.slice(1,-1),n=new B().parseWordFromString(s,!0,!1);return L(e,n)}if(t.includes(\"$\")){let r=new B().parseWordFromString(t,!1,!1);return L(e,r)}return t}async function Fr(e,t){let s=\"both\",r=\"\",n=0;for(let i of t){if(i===\"-v\"){s=\"variable\";continue}if(i===\"-f\"){s=\"function\";continue}if(s===\"function\"){e.state.functions.delete(i);continue}if(s===\"variable\"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(c){let d=c[1],p=c[2];if(p===\"@\"||p===\"*\"){let b=Ae(e,d);for(let[m]of b)e.state.env.delete(`${d}_${m}`);e.state.env.delete(d);continue}let y=e.state.associativeArrays?.has(d);if(y){let b=await ci(e,p);e.state.env.delete(`${d}_${b}`);continue}let h=js(e,d),w=e.state.declaredVars?.has(d);if((e.state.env.has(d)||w)&&!h&&!y){r+=`bash: unset: ${d}: not an array variable\n`,n=1;continue}let g=await ai(e,p);if(g===null&&h){r+=`bash: unset: ${p}: not a valid identifier\n`,n=1;continue}if(g===null)continue;if(g<0){let b=Ae(e,d),m=b.length,v=e.state.currentLine;if(m===0){r+=`bash: line ${v}: unset: [${g}]: bad array subscript\n`,n=1;continue}let $=m+g;if($<0){r+=`bash: line ${v}: unset: [${g}]: bad array subscript\n`,n=1;continue}let S=b[$][0];e.state.env.delete(`${d}_${S}`);continue}e.state.env.delete(`${d}_${g}`);continue}if(!oi(i)){r+=`bash: unset: \\`${i}': not a valid identifier\n`,n=1;continue}let u=i;if(Ee(e,i)){let d=Ze(e,i);d&&d!==i&&(u=d)}if(et(e,u)){r+=`bash: unset: ${u}: cannot unset: readonly variable\n`,n=1;continue}let f=pt(e,u);if(f!==void 0&&f!==e.state.callDepth)li(e,u);else if(e.state.fullyUnsetLocals?.has(u))e.state.env.delete(u);else if(f!==void 0){let d=e.state.accessedTempEnvVars?.has(u),p=e.state.mutatedTempEnvVars?.has(u);if((d||p)&&e.state.localVarStack?.has(u)){let y=ps(e,u);y?y.value===void 0?e.state.env.delete(u):e.state.env.set(u,y.value):e.state.env.delete(u)}else e.state.env.delete(u)}else Lr(e,u)||e.state.env.delete(u);e.state.exportedVars?.delete(u);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(o){let c=o[1],u=o[2];if(u===\"@\"||u===\"*\"){let h=Ae(e,c);for(let[w]of h)e.state.env.delete(`${c}_${w}`);e.state.env.delete(c);continue}let f=e.state.associativeArrays?.has(c);if(f){let h=await ci(e,u);e.state.env.delete(`${c}_${h}`);continue}let d=js(e,c);if(e.state.env.has(c)&&!d&&!f){r+=`bash: unset: ${c}: not an array variable\n`,n=1;continue}let y=await ai(e,u);if(y===null&&d){r+=`bash: unset: ${u}: not a valid identifier\n`,n=1;continue}if(y===null)continue;if(y<0){let h=Ae(e,c),w=h.length,E=e.state.currentLine;if(w===0){r+=`bash: line ${E}: unset: [${y}]: bad array subscript\n`,n=1;continue}let g=w+y;if(g<0){r+=`bash: line ${E}: unset: [${y}]: bad array subscript\n`,n=1;continue}let b=h[g][0];e.state.env.delete(`${c}_${b}`);continue}e.state.env.delete(`${c}_${y}`);continue}if(!oi(i)){r+=`bash: unset: \\`${i}': not a valid identifier\n`,n=1;continue}let a=i;if(Ee(e,i)){let c=Ze(e,i);c&&c!==i&&(a=c)}if(et(e,a)){r+=`bash: unset: ${a}: cannot unset: readonly variable\n`,n=1;continue}let l=pt(e,a);if(l!==void 0&&l!==e.state.callDepth)li(e,a);else if(e.state.fullyUnsetLocals?.has(a))e.state.env.delete(a);else if(l!==void 0){let c=e.state.accessedTempEnvVars?.has(a),u=e.state.mutatedTempEnvVars?.has(a);if((c||u)&&e.state.localVarStack?.has(a)){let f=ps(e,a);f?f.value===void 0?e.state.env.delete(a):e.state.env.set(a,f.value):e.state.env.delete(a)}else e.state.env.delete(a)}else Lr(e,a)||e.state.env.delete(a);e.state.exportedVars?.delete(a),e.state.functions.delete(i)}return _(\"\",r,n)}var Mr=[\"extglob\",\"dotglob\",\"nullglob\",\"failglob\",\"globstar\",\"globskipdots\",\"nocaseglob\",\"nocasematch\",\"expand_aliases\",\"lastpipe\",\"xpg_echo\"],wa=[\"autocd\",\"cdable_vars\",\"cdspell\",\"checkhash\",\"checkjobs\",\"checkwinsize\",\"cmdhist\",\"compat31\",\"compat32\",\"compat40\",\"compat41\",\"compat42\",\"compat43\",\"compat44\",\"complete_fullquote\",\"direxpand\",\"dirspell\",\"execfail\",\"extdebug\",\"extquote\",\"force_fignore\",\"globasciiranges\",\"gnu_errfmt\",\"histappend\",\"histreedit\",\"histverify\",\"hostcomplete\",\"huponexit\",\"inherit_errexit\",\"interactive_comments\",\"lithist\",\"localvar_inherit\",\"localvar_unset\",\"login_shell\",\"mailwarn\",\"no_empty_cmd_completion\",\"progcomp\",\"progcomp_alias\",\"promptvars\",\"restricted_shell\",\"shift_verbose\",\"sourcepath\"];function Es(e){return Mr.includes(e)}function va(e){return wa.includes(e)}function ui(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=[],l=0;for(;l<t.length;){let d=t[l];if(d===\"--\"){l++;break}if(d.startsWith(\"-\")&&d.length>1){for(let p=1;p<d.length;p++){let y=d[p];switch(y){case\"s\":s=!0;break;case\"u\":r=!0;break;case\"p\":n=!0;break;case\"q\":i=!0;break;case\"o\":o=!0;break;default:return{exitCode:2,stdout:\"\",stderr:`shopt: -${y}: invalid option\n`}}}l++}else break}for(;l<t.length;)a.push(t[l]),l++;if(o)return ba(e,a,s,r,n,i);if(s&&r)return{exitCode:1,stdout:\"\",stderr:`shopt: cannot set and unset shell options simultaneously\n`};if(a.length===0){if(s||r){let p=[];for(let y of Mr){let h=e.state.shoptOptions[y];s&&h?p.push(n?`shopt -s ${y}`:`${y}\t\ton`):r&&!h&&p.push(n?`shopt -u ${y}`:`${y}\t\toff`)}return{exitCode:0,stdout:p.length>0?`${p.join(`\n`)}\n`:\"\",stderr:\"\"}}let d=[];for(let p of Mr){let y=e.state.shoptOptions[p];d.push(n?`shopt ${y?\"-s\":\"-u\"} ${p}`:`${p}\t\t${y?\"on\":\"off\"}`)}return{exitCode:0,stdout:`${d.join(`\n`)}\n`,stderr:\"\"}}let c=!1,u=\"\",f=[];for(let d of a){if(!Es(d)&&!va(d)){u+=`shopt: ${d}: invalid shell option name\n`,c=!0;continue}if(s)Es(d)&&(e.state.shoptOptions[d]=!0,Gs(e));else if(r)Es(d)&&(e.state.shoptOptions[d]=!1,Gs(e));else if(Es(d)){let p=e.state.shoptOptions[d];i?p||(c=!0):n?(f.push(`shopt ${p?\"-s\":\"-u\"} ${d}`),p||(c=!0)):(f.push(`${d}\t\t${p?\"on\":\"off\"}`),p||(c=!0))}else i?c=!0:n?(f.push(`shopt -u ${d}`),c=!0):(f.push(`${d}\t\toff`),c=!0)}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`\n`)}\n`:\"\",stderr:u}}function ba(e,t,s,r,n,i){let o=new Map([[\"errexit\",\"errexit\"],[\"pipefail\",\"pipefail\"],[\"nounset\",\"nounset\"],[\"xtrace\",\"xtrace\"],[\"verbose\",\"verbose\"],[\"posix\",\"posix\"],[\"allexport\",\"allexport\"],[\"noclobber\",\"noclobber\"],[\"noglob\",\"noglob\"],[\"noexec\",\"noexec\"],[\"vi\",\"vi\"],[\"emacs\",\"emacs\"]]),a=[\"braceexpand\",\"errtrace\",\"functrace\",\"hashall\",\"histexpand\",\"history\",\"ignoreeof\",\"interactive-comments\",\"keyword\",\"monitor\",\"nolog\",\"notify\",\"onecmd\",\"physical\",\"privileged\"],l=[...o.keys(),...a].sort();if(t.length===0){let d=[];for(let p of l){let y=a.includes(p),h=o.get(p),w=y||!h?!1:e.state.options[h];s&&!w||r&&w||d.push(n?`set ${w?\"-o\":\"+o\"} ${p}`:`${p}\t\t${w?\"on\":\"off\"}`)}return{exitCode:0,stdout:d.length>0?`${d.join(`\n`)}\n`:\"\",stderr:\"\"}}let c=!1,u=\"\",f=[];for(let d of t){let p=o.has(d),y=a.includes(d);if(!p&&!y){u+=`shopt: ${d}: invalid option name\n`,c=!0;continue}if(y){s||r||(i?c=!0:n?(f.push(`set +o ${d}`),c=!0):(f.push(`${d}\t\toff`),c=!0));continue}let h=o.get(d);if(h)if(s)h===\"vi\"?e.state.options.emacs=!1:h===\"emacs\"&&(e.state.options.vi=!1),e.state.options[h]=!0,dt(e);else if(r)e.state.options[h]=!1,dt(e);else{let w=e.state.options[h];i?w||(c=!0):n?(f.push(`set ${w?\"-o\":\"+o\"} ${d}`),w||(c=!0)):(f.push(`${d}\t\t${w?\"on\":\"off\"}`),w||(c=!0))}}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`\n`)}\n`:\"\",stderr:u}}async function fi(e,t,s){if(t.includes(\"/\")){let o=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(o))return{error:\"not_found\",path:o};let a=o.split(\"/\").pop()||t,l=e.commands.get(a);try{let c=await e.fs.stat(o);return c.isDirectory?{error:\"permission_denied\",path:o}:l?{cmd:l,path:o}:(c.mode&73)!==0?{script:!0,path:o}:{error:\"permission_denied\",path:o}}catch{return{error:\"not_found\",path:o}}}if(!s&&e.state.hashTable){let o=e.state.hashTable.get(t);if(o)if(await e.fs.exists(o)){let a=e.commands.get(t);if(a)return{cmd:a,path:o};try{let l=await e.fs.stat(o);if(!l.isDirectory&&(l.mode&73)!==0)return{script:!0,path:o}}catch{}}else e.state.hashTable.delete(t)}let n=(s??e.state.env.get(\"PATH\")??\"/usr/bin:/bin\").split(\":\");for(let o of n){if(!o)continue;let l=`${o.startsWith(\"/\")?o:e.fs.resolvePath(e.state.cwd,o)}/${t}`;if(await e.fs.exists(l))try{let c=await e.fs.stat(l);if(c.isDirectory)continue;let u=(c.mode&73)!==0,f=e.commands.get(t),d=o===\"/bin\"||o===\"/usr/bin\";if(f&&d)return{cmd:f,path:l};if(u){if(f&&!d)return{script:!0,path:l};if(!f)return{script:!0,path:l}}}catch{}}if(!await e.fs.exists(\"/usr/bin\")){let o=e.commands.get(t);if(o)return{cmd:o,path:`/usr/bin/${t}`}}return null}async function $s(e,t){let s=[];if(t.includes(\"/\")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let o=await e.fs.stat(i);o.isDirectory||(o.mode&73)!==0&&s.push(t)}catch{}return s}let n=(e.state.env.get(\"PATH\")||\"/usr/bin:/bin\").split(\":\");for(let i of n){if(!i)continue;let a=`${i.startsWith(\"/\")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}s.push(i.startsWith(\"/\")?a:`${i}/${t}`)}}return s}function Ea(e){return e!==null&&typeof e==\"object\"&&\"then\"in e&&typeof e.then==\"function\"}function G(e,t,s,r){return((...n)=>{_t(t,s,`${r} call`);let i=e(...n);return Ea(i)?i.then(o=>(_t(t,s,`${r} post-await`),o),o=>{throw _t(t,s,`${r} post-await`),o}):(_t(t,s,`${r} return`),i)})}function $a(e,t,s){let r={readFile:G(e.readFile.bind(e),t,s,\"fs.readFile\"),...typeof e.readFileBytes==\"function\"?{readFileBytes:G(e.readFileBytes.bind(e),t,s,\"fs.readFileBytes\")}:Object.create(null),readFileBuffer:G(e.readFileBuffer.bind(e),t,s,\"fs.readFileBuffer\"),writeFile:G(e.writeFile.bind(e),t,s,\"fs.writeFile\"),appendFile:G(e.appendFile.bind(e),t,s,\"fs.appendFile\"),exists:G(e.exists.bind(e),t,s,\"fs.exists\"),stat:G(e.stat.bind(e),t,s,\"fs.stat\"),mkdir:G(e.mkdir.bind(e),t,s,\"fs.mkdir\"),readdir:G(e.readdir.bind(e),t,s,\"fs.readdir\"),rm:G(e.rm.bind(e),t,s,\"fs.rm\"),cp:G(e.cp.bind(e),t,s,\"fs.cp\"),mv:G(e.mv.bind(e),t,s,\"fs.mv\"),resolvePath:G(e.resolvePath.bind(e),t,s,\"fs.resolvePath\"),getAllPaths:G(e.getAllPaths.bind(e),t,s,\"fs.getAllPaths\"),chmod:G(e.chmod.bind(e),t,s,\"fs.chmod\"),symlink:G(e.symlink.bind(e),t,s,\"fs.symlink\"),link:G(e.link.bind(e),t,s,\"fs.link\"),readlink:G(e.readlink.bind(e),t,s,\"fs.readlink\"),lstat:G(e.lstat.bind(e),t,s,\"fs.lstat\"),realpath:G(e.realpath.bind(e),t,s,\"fs.realpath\"),utimes:G(e.utimes.bind(e),t,s,\"fs.utimes\")};return e.readdirWithFileTypes&&(r.readdirWithFileTypes=G(e.readdirWithFileTypes.bind(e),t,s,\"fs.readdirWithFileTypes\")),r}function di(e,t){if(!e.requireDefenseContext)return e;let s=`command:${t}`,r={...e,fs:$a(e.fs,e.requireDefenseContext,s)};return e.exec&&(r.exec=G(e.exec,e.requireDefenseContext,s,\"exec\")),e.fetch&&(r.fetch=G(e.fetch,e.requireDefenseContext,s,\"fetch\")),e.sleep&&(r.sleep=G(e.sleep,e.requireDefenseContext,s,\"sleep\")),e.getRegisteredCommands&&(r.getRegisteredCommands=G(e.getRegisteredCommands,e.requireDefenseContext,s,\"getRegisteredCommands\")),r}async function yi(e,t,s,r){let n=!1,i=!1,o=!1,a=!1,l=!1,c=[];for(let h of t)if(h.startsWith(\"-\")&&h.length>1)for(let w of h.slice(1))w===\"t\"?n=!0:w===\"p\"?i=!0:w===\"P\"?o=!0:w===\"a\"?a=!0:w===\"f\"&&(l=!0);else c.push(h);let u=\"\",f=\"\",d=0,p=!1,y=!1;for(let h of c){let w=!1;if(o){if(a){let $=await r(h);if($.length>0){for(let S of $)u+=`${S}\n`;p=!0,w=!0}}else{let $=await s(h);$&&(u+=`${$}\n`,p=!0,w=!0)}w||(y=!0);continue}let E=!l&&e.state.functions.has(h);if(a&&E){if(!i)if(n)u+=`function\n`;else{let $=e.state.functions.get(h),S=$?hi(h,$):`${h} is a function\n`;u+=S}w=!0}let g=e.state.env.get(`BASH_ALIAS_${h}`);if(g!==void 0&&(a||!w)&&(i||(n?u+=`alias\n`:u+=`${h} is aliased to \\`${g}'\n`),w=!0,!a)||sr.has(h)&&(a||!w)&&(i||(n?u+=`keyword\n`:u+=`${h} is a shell keyword\n`),w=!0,!a))continue;if(!a&&E&&!w){if(!i)if(n)u+=`function\n`;else{let $=e.state.functions.get(h),S=$?hi(h,$):`${h} is a function\n`;u+=S}w=!0;continue}if(!(mt.has(h)&&(a||!w)&&(i||(n?u+=`builtin\n`:u+=`${h} is a shell builtin\n`),w=!0,!a))){if(a){let $=await r(h);for(let S of $)i?u+=`${S}\n`:n?u+=`file\n`:u+=`${h} is ${S}\n`,p=!0,w=!0}else if(!w){let $=await s(h);$&&(i?u+=`${$}\n`:n?u+=`file\n`:u+=`${h} is ${$}\n`,p=!0,w=!0)}if(!w&&(y=!0,!n&&!i)){let $=!0;if(h.includes(\"/\")){let S=e.fs.resolvePath(e.state.cwd,h);await e.fs.exists(S)&&($=!1)}$&&(f+=`bash: type: ${h}: not found\n`)}}}return i?d=y&&!p?1:0:d=y?1:0,_(u,f,d)}function hi(e,t){let s;return t.body.type===\"Group\"?s=t.body.body.map(n=>Dt(n)).join(\"; \"):s=Dt(t.body),`${e} is a function\n${e} () \n{ \n ${s}\n}\n`}function Dt(e){if(Array.isArray(e))return e.map(t=>Dt(t)).join(\"; \");if(e.type===\"Statement\"){let t=[];for(let s=0;s<e.pipelines.length;s++){let r=e.pipelines[s];t.push(Sa(r)),e.operators[s]&&t.push(e.operators[s])}return t.join(\" \")}if(e.type===\"SimpleCommand\"){let t=e,s=[];t.name&&s.push(pi(t.name));for(let r of t.args)s.push(pi(r));return s.join(\" \")}return e.type===\"Group\"?`{ ${e.body.map(r=>Dt(r)).join(\"; \")}; }`:\"...\"}function Sa(e){let t=e.commands.map(s=>Dt(s));return(e.negated?\"! \":\"\")+t.join(\" | \")}function pi(e){let t=\"\";for(let s of e.parts)s.type===\"Literal\"?t+=s.value:s.type===\"DoubleQuoted\"?t+=`\"${s.parts.map(r=>mi(r)).join(\"\")}\"`:s.type===\"SingleQuoted\"?t+=`'${s.value}'`:t+=mi(s);return t}function mi(e){let t=e;return t.type===\"Literal\"?t.value??\"\":t.type===\"Variable\"?`$${t.name}`:\"\"}async function gi(e,t,s,r){let n=\"\",i=\"\",o=0;for(let a of t){if(!a){o=1;continue}let l=e.state.env.get(`BASH_ALIAS_${a}`);if(l!==void 0)r?n+=`${a} is an alias for \"${l}\"\n`:n+=`alias ${a}='${l}'\n`;else if(sr.has(a))r?n+=`${a} is a shell keyword\n`:n+=`${a}\n`;else if(mt.has(a))r?n+=`${a} is a shell builtin\n`:n+=`${a}\n`;else if(e.state.functions.has(a))r?n+=`${a} is a function\n`:n+=`${a}\n`;else if(a.includes(\"/\")){let c=e.fs.resolvePath(e.state.cwd,a),u=!1;if(await e.fs.exists(c))try{let f=await e.fs.stat(c);f.isDirectory||(f.mode&73)!==0&&(r?n+=`${a} is ${a}\n`:n+=`${a}\n`,u=!0)}catch{}u||(r&&(i+=`${a}: not found\n`),o=1)}else if(e.commands.has(a)){let u=(e.state.env.get(\"PATH\")??\"/usr/bin:/bin\").split(\":\"),f=null;for(let d of u){if(!d)continue;let p=`${d}/${a}`;try{let y=await e.fs.stat(p);if(!y.isDirectory&&(y.mode&73)!==0){f=p;break}}catch{}}f||(f=`/usr/bin/${a}`),r?n+=`${a} is ${f}\n`:n+=`${f}\n`}else r&&(i+=`${a}: not found\n`),o=1}return _(n,i,o)}async function wi(e,t){if(t.includes(\"/\")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=(e.state.env.get(\"PATH\")??\"/usr/bin:/bin\").split(\":\");for(let n of r){if(!n)continue;let o=`${n.startsWith(\"/\")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n===\"/usr/bin\"||n===\"/bin\")return`${n}/${t}`;return`/usr/bin/${t}`}return null}async function vi(e,t,s,r,n,i,o,a){let{ctx:l,runCommand:c}=e;if(l.coverage&&mt.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t===\"export\")return Pr(l,s);if(t===\"unset\")return Fr(l,s);if(t===\"exit\")return Sr(l,s);if(t===\"local\")return Cr(l,s);if(t===\"set\")return Dr(l,s);if(t===\"break\")return Xs(l,s);if(t===\"continue\")return cr(l,s);if(t===\"return\")return xr(l,s);if(t===\"eval\"&&l.state.options.posix)return ws(l,s,n);if(t===\"shift\")return Rr(l,s);if(t===\"getopts\")return vs(l,s);if(t===\"compgen\")return ir(l,s);if(t===\"complete\")return ar(l,s);if(t===\"compopt\")return lr(l,s);if(t===\"pushd\")return await br(l,s);if(t===\"popd\")return Er(l,s);if(t===\"dirs\")return $r(l,s);if(t===\"source\"||t===\".\")return Ir(l,s);if(t===\"read\")return Or(l,s,n,a);if(t===\"mapfile\"||t===\"readarray\")return Nr(l,s,n);if(t===\"declare\"||t===\"typeset\")return gr(l,s);if(t===\"readonly\")return wr(l,s);if(!i){let u=l.state.functions.get(t);if(u)return ys(l,u,s,n)}if(t===\"eval\")return ws(l,s,n);if(t===\"cd\")return await Ys(l,s);if(t===\":\"||t===\"true\")return W;if(t===\"false\")return Q(!1);if(t===\"let\")return _r(l,s);if(t===\"command\")return Pa(e,s,n);if(t===\"builtin\")return Aa(e,s,n);if(t===\"shopt\")return ui(l,s);if(t===\"exec\"){if(s.length===0)return W;let[u,...f]=s;return c(u,f,[],n,!1,!1,-1)}if(t===\"wait\")return W;if(t===\"type\")return await yi(l,s,u=>wi(l,u),u=>$s(l,u));if(t===\"hash\")return Ar(l,s);if(t===\"help\")return kr(l,s);if(t===\"[\"||t===\"test\"){let u=s;if(t===\"[\"){if(s[s.length-1]!==\"]\")return A(\"[: missing `]'\\n\",2);u=s.slice(0,-1)}return Ot(l,u)}return null}async function Pa(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return W;let i=!1,o=!1,a=!1,l=t;for(;l.length>0&&l[0].startsWith(\"-\");){let f=l[0];if(f===\"--\"){l=l.slice(1);break}for(let d of f.slice(1))d===\"p\"?i=!0:d===\"V\"?o=!0:d===\"v\"&&(a=!0);l=l.slice(1)}if(l.length===0)return W;if(a||o)return await gi(r,l,a,o);let[c,...u]=l;return n(c,u,[],s,!0,i,-1)}async function Aa(e,t,s){let{runCommand:r}=e;if(t.length===0)return W;let n=t;if(n[0]===\"--\"&&(n=n.slice(1),n.length===0))return W;let i=n[0];if(!mt.has(i))return A(`bash: builtin: ${i}: not a shell builtin\n`);let[,...o]=n;return r(i,o,[],s,!0,!1,-1)}async function bi(e,t,s,r,n){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=e,c=await fi(i,t,n?\"/usr/bin:/bin\":void 0);if(!c)return _n(t)?A(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.\n`,127):A(`bash: ${t}: command not found\n`,127);if(\"error\"in c)return c.error===\"permission_denied\"?A(`bash: ${t}: Permission denied\n`,126):A(`bash: ${t}: No such file or directory\n`,127);if(\"script\"in c)return t.includes(\"/\")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,c.path)),await a(c.path,s,r);let{cmd:u,path:f}=c;t.includes(\"/\")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,f));let d=r||i.state.groupStdin||\"\",p=o(),y={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:p,stdin:d,limits:i.limits,exec:i.execFn,fetch:i.fetch,getRegisteredCommands:()=>Array.from(i.commands.keys()),sleep:i.sleep,trace:i.trace,fileDescriptors:i.state.fileDescriptors,xpgEcho:i.state.shoptOptions.xpg_echo,coverage:i.coverage,signal:i.state.signal,requireDefenseContext:i.requireDefenseContext,jsBootstrapCode:i.jsBootstrapCode,invokeTool:i.invokeTool},h=di(y,t);try{let w=()=>Xr(i.requireDefenseContext,\"command\",`${t} execution`,()=>u.execute(s,h));return u.trusted?await me.runTrustedAsync(()=>w()):await w()}catch(w){if(w instanceof J||w instanceof Ve)throw w;return A(`${t}: ${Le(Ie(w))}\n`)}}async function Wr(e,t){let s=e.state.inCondition;e.state.inCondition=!0;let r=\"\",n=\"\",i=0;try{for(let o of t){let a=await e.executeStatement(o);r+=a.stdout,n+=a.stderr,i=a.exitCode}}finally{e.state.inCondition=s}return{stdout:r,stderr:n,exitCode:i}}function Rt(e,t,s,r){if(e instanceof ye)return t+=e.stdout,s+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:\"rethrow\",stdout:t,stderr:s,error:e}):{action:\"break\",stdout:t,stderr:s};if(e instanceof ge)return t+=e.stdout,s+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:\"rethrow\",stdout:t,stderr:s,error:e}):{action:\"continue\",stdout:t,stderr:s};if(e instanceof ue||e instanceof we||e instanceof j||e instanceof J)return e.prependOutput(t,s),{action:\"rethrow\",stdout:t,stderr:s,error:e};let n=Ie(e);return{action:\"error\",stdout:t,stderr:`${s}${n}\n`,exitCode:1}}async function Ss(e,t,s=\"\",r=\"\"){let n=s,i=r,o=0;try{for(let a of t){let l=await e.executeStatement(a);n+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(Zt(a)||a instanceof we||a instanceof j||a instanceof J||a instanceof je)throw a.prependOutput(n,i),a;return{stdout:n,stderr:`${i}${Ie(a)}\n`,exitCode:1}}return{stdout:n,stderr:i,exitCode:o}}async function Ei(e,t){let s=\"\",r=\"\";for(let n of t.clauses){let i=await Wr(e,n.condition);if(s+=i.stdout,r+=i.stderr,i.exitCode===0)return Ss(e,n.body,s,r)}return t.elseBody?Ss(e,t.elseBody,s,r):_(s,r,0)}async function $i(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=\"\",n=\"\",i=0,o=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return A(`bash: \\`${t.variable}': not a valid identifier\n`);let a=[];if(t.words===null)a=(e.state.env.get(\"@\")||\"\").split(\" \").filter(Boolean);else if(t.words.length===0)a=[];else try{for(let c of t.words){let u=await xe(e,c);a.push(...u.values)}}catch(c){if(c instanceof Ut)return{stdout:\"\",stderr:c.stderr,exitCode:1};throw c}e.state.loopDepth++;try{for(let c of a){o++,o>e.limits.maxLoopIterations&&Te(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",r,n),e.state.env.set(t.variable,c);try{for(let u of t.body){let f=await e.executeStatement(u);r+=f.stdout,n+=f.stderr,i=f.exitCode}}catch(u){let f=Rt(u,r,n,e.state.loopDepth);if(r=f.stdout,n=f.stderr,f.action===\"break\")break;if(f.action===\"continue\")continue;if(f.action===\"error\"){let d=_(r,n,f.exitCode??1);return K(e,d,t.redirections)}throw f.error}}}finally{e.state.loopDepth--}let l=_(r,n,i);return K(e,l,t.redirections)}async function Si(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=t.line;r!==void 0&&(e.state.currentLine=r);let n=\"\",i=\"\",o=0,a=0;t.init&&await H(e,t.init.expression),e.state.loopDepth++;try{for(;a++,a>e.limits.maxLoopIterations&&Te(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",n,i),!(t.condition&&(r!==void 0&&(e.state.currentLine=r),await H(e,t.condition.expression)===0));){try{for(let c of t.body){let u=await e.executeStatement(c);n+=u.stdout,i+=u.stderr,o=u.exitCode}}catch(c){let u=Rt(c,n,i,e.state.loopDepth);if(n=u.stdout,i=u.stderr,u.action===\"break\")break;if(u.action===\"continue\"){t.update&&await H(e,t.update.expression);continue}if(u.action===\"error\"){let f=_(n,i,u.exitCode??1);return K(e,f,t.redirections)}throw u.error}t.update&&await H(e,t.update.expression)}}finally{e.state.loopDepth--}let l=_(n,i,o);return K(e,l,t.redirections)}async function Pi(e,t,s=\"\"){let r=\"\",n=\"\",i=0,o=0,a=s;for(let c of t.redirections)if((c.operator===\"<<\"||c.operator===\"<<-\")&&c.target.type===\"HereDoc\"){let u=c.target,f=await L(e,u.content);u.stripTabs&&(f=f.split(`\n`).map(d=>d.replace(/^\\t+/,\"\")).join(`\n`)),a=f}else if(c.operator===\"<<<\"&&c.target.type===\"Word\")a=`${await L(e,c.target)}\n`;else if(c.operator===\"<\"&&c.target.type===\"Word\")try{let u=await L(e,c.target),f=e.fs.resolvePath(e.state.cwd,u);a=await e.fs.readFile(f)}catch{let u=await L(e,c.target);return A(`bash: ${u}: No such file or directory\n`)}let l=e.state.groupStdin;a&&(e.state.groupStdin=a),e.state.loopDepth++;try{for(;;){o++,o>e.limits.maxLoopIterations&&Te(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",r,n);let c=0,u=!1,f=!1,d=e.state.inCondition;e.state.inCondition=!0;try{for(let p of t.condition){let y=await e.executeStatement(p);r+=y.stdout,n+=y.stderr,c=y.exitCode}}catch(p){if(p instanceof ye){if(r+=p.stdout,n+=p.stderr,p.levels>1&&e.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=n,e.state.inCondition=d,p;u=!0}else if(p instanceof ge){if(r+=p.stdout,n+=p.stderr,p.levels>1&&e.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=n,e.state.inCondition=d,p;f=!0}else throw e.state.inCondition=d,p}finally{e.state.inCondition=d}if(u)break;if(!f){if(c!==0)break;try{for(let p of t.body){let y=await e.executeStatement(p);r+=y.stdout,n+=y.stderr,i=y.exitCode}}catch(p){let y=Rt(p,r,n,e.state.loopDepth);if(r=y.stdout,n=y.stderr,y.action===\"break\")break;if(y.action===\"continue\")continue;if(y.action===\"error\")return _(r,n,y.exitCode??1);throw y.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=l}return _(r,n,i)}async function Ai(e,t){let s=\"\",r=\"\",n=0,i=0;e.state.loopDepth++;try{for(;;){i++,i>e.limits.maxLoopIterations&&Te(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",s,r);let o=await Wr(e,t.condition);if(s+=o.stdout,r+=o.stderr,o.exitCode===0)break;try{for(let a of t.body){let l=await e.executeStatement(a);s+=l.stdout,r+=l.stderr,n=l.exitCode}}catch(a){let l=Rt(a,s,r,e.state.loopDepth);if(s=l.stdout,r=l.stderr,l.action===\"break\")break;if(l.action===\"continue\")continue;if(l.action===\"error\")return _(s,r,l.exitCode??1);throw l.error}}}finally{e.state.loopDepth--}return _(s,r,n)}async function ki(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=\"\",n=\"\",i=0,o=await L(e,t.word),a=!1;for(let c=0;c<t.items.length;c++){let u=t.items[c],f=a;if(!a)for(let d of u.patterns){let p=await L(e,d);ln(d)&&(p=on(p));let y=e.state.shoptOptions.nocasematch,h=e.state.shoptOptions.extglob;if(ht(o,p,y,h)){f=!0;break}}if(f){let d=await Ss(e,u.body,r,n);if(r=d.stdout,n=d.stderr,i=d.exitCode,u.terminator===\";;\")break;u.terminator===\";&\"?a=!0:a=!1}else a=!1}let l=_(r,n,i);return K(e,l,t.redirections)}function zr(e,t){if(e.parts.length!==1)return!1;let s=e.parts[0];return s.type!==\"Literal\"?!1:t.includes(s.value)}function _i(e){if(!e.startsWith(\"__rw__:\"))return null;let t=e.slice(7),s=t.indexOf(\":\");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+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}}var Ci=\"+ \";async function Ni(e){let t=e.state.env.get(\"PS4\");if(t===void 0)return Ci;if(t===\"\")return\"\";try{let r=new B().parseWordFromString(t,!1,!1);return await L(e,r)}catch{return e.state.expansionStderr=`${e.state.expansionStderr||\"\"}bash: ${t}: bad substitution\n`,t||Ci}}function ka(e){return e.map(t=>_a(t)).join(\" \")}function _a(e){if(e===\"\")return\"''\";if(!/[\\s'\"\\\\$`!*?[\\]{}|&;<>()~#\\n\\t]/.test(e))return e;let s=/[\\x00-\\x1f\\x7f]/.test(e),r=e.includes(`\n`),n=e.includes(\"\t\"),i=e.includes(\"\\\\\"),o=e.includes(\"'\");if(s||r||n||i){let l=\"\";for(let c of e){let u=c.charCodeAt(0);c===`\n`?l+=\"\\\\n\":c===\"\t\"?l+=\"\\\\t\":c===\"\\\\\"?l+=\"\\\\\\\\\":c===\"'\"?l+=\"'\":c==='\"'?l+='\"':u<32||u===127?u<256?l+=`\\\\x${u.toString(16).padStart(2,\"0\")}`:l+=`\\\\u${u.toString(16).padStart(4,\"0\")}`:l+=c}return`$'${l}'`}return o?`\"${e.replace(/([\\\\$`\"])/g,\"\\\\$1\")}\"`:`'${e}'`}async function Oi(e,t,s){if(!e.state.options.xtrace)return\"\";let r=await Ni(e),n=[t,...s],i=ka(n);return`${r}${i}\n`}async function xi(e,t,s){return e.state.options.xtrace?`${await Ni(e)}${t}=${s}\n`:\"\"}async function Ti(e,t,s){let r=t.timed?Fs():0,n=\"\",i=W,o=0,a=[],l=\"\",c=t.commands.length>1,u=e.state.lastArg;for(let d=0;d<t.commands.length;d++){let p=t.commands[d],y=d===t.commands.length-1,h=d===0;c&&(e.state.lastArg=\"\",h||(e.state.groupStdin=void 0));let E=c&&(!y||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,g;try{g=await s(p,n)}catch(b){if(b instanceof jt)g={stdout:b.stdout,stderr:b.stderr,exitCode:1};else if(b instanceof j&&t.commands.length>1)g={stdout:b.stdout,stderr:b.stderr,exitCode:b.exitCode};else if(b instanceof we&&t.commands.length>1)g={stdout:b.stdout,stderr:b.stderr,exitCode:b.exitCode};else throw E&&(e.state.env=E),b}E&&(e.state.env=E),a.push(g.exitCode),g.exitCode!==0&&(o=g.exitCode),y?i=g:(t.pipeStderr?.[d]??!1?n=Be(g.stderr)+Bt(g):(n=Bt(g),l+=g.stderr),i={stdout:\"\",stderr:\"\",exitCode:g.exitCode})}if(l&&(i={...i,stderr:l+i.stderr}),t.commands.length>1||t.commands.length===1&&t.commands[0].type===\"SimpleCommand\"){for(let d of e.state.env.keys())d.startsWith(\"PIPESTATUS_\")&&e.state.env.delete(d);for(let d=0;d<a.length;d++)e.state.env.set(`PIPESTATUS_${d}`,String(a[d]));e.state.env.set(\"PIPESTATUS__length\",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let p=(Fs()-r)/1e3,y=Math.floor(p/60),h=p%60,w;t.timePosix?w=`real ${p.toFixed(2)}\nuser 0.00\nsys 0.00\n`:w=`\nreal\t${`${y}m${h.toFixed(3)}s`}\nuser\t0m0.000s\nsys\t0m0.000s\n`,i={...i,stderr:i.stderr+w}}return c&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}async function Di(e,t){let s=new Map,r=\"\";for(let n of t.assignments){let i=n.name;if(n.array){let u=await Ca(e,t,i,n.array,n.append,s);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:u.error};if(r+=u.xtraceOutput,u.continueToNext)continue}let o=n.value?await L(e,n.value):\"\";if(i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[\\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:_(\"\",`bash: ${i}: bad array subscript\n`,1)};let l=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(l){let u=await Da(e,t,l[1],l[2],o,n.append,s);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:u.error};if(u.continueToNext)continue}let c=await Ia(e,t,i,o,n.append,s);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:s}}async function Ca(e,t,s,r,n,i){let o=\"\";if(/\\[.+\\]$/.test(s))return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: ${s}: cannot assign list to array member\n`,1)};if(Ee(e,s)){let u=rn(e,s);if(u===void 0||u===\"\")throw new j(1,\"\",\"\");let f=Ze(e,s);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\\[@\\]$/.test(f))return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: ${s}: cannot assign list to array member\n`,1)}}if(et(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable\n`,{continueToNext:!0,xtraceOutput:o};let u=se(e,s);if(u)return{continueToNext:!1,xtraceOutput:\"\",error:u}}let a=e.state.associativeArrays?.has(s),l=Na(r),c=()=>{let u=`${s}_`;for(let f of e.state.env.keys())f.startsWith(u)&&!f.includes(\"__\")&&e.state.env.delete(f);e.state.env.delete(s)};if(a&&l?await Oa(e,t,s,r,n,c,u=>{o+=u}):l?await xa(e,s,r,n,c):await Ta(e,s,r,n,c),t.name){i.set(s,e.state.env.get(s));let f=`(${r.map(d=>Gt(d)).join(\" \")})`;e.state.env.set(s,f)}return{continueToNext:!0,xtraceOutput:o}}function Na(e){return e.some(t=>{if(t.parts.length>=2){let s=t.parts[0],r=t.parts[1];if(s.type!==\"Glob\"||!s.pattern.startsWith(\"[\"))return!1;if(s.pattern===\"[\"&&(r.type===\"DoubleQuoted\"||r.type===\"SingleQuoted\")){if(t.parts.length<3)return!1;let n=t.parts[2];return n.type!==\"Literal\"?!1:n.value.startsWith(\"]=\")||n.value.startsWith(\"]+=\")}return r.type!==\"Literal\"?!1:r.value.startsWith(\"]\")?r.value.startsWith(\"]=\")||r.value.startsWith(\"]+=\"):s.pattern.endsWith(\"]\")?r.value.startsWith(\"=\")||r.value.startsWith(\"+=\"):!1}return!1})}async function Oa(e,t,s,r,n,i,o){let a=[];for(let l of r){let c=Ws(l);if(c){let{key:u,valueParts:f,append:d}=c,p;f.length>0?p=await L(e,{type:\"Word\",parts:f}):p=\"\",p=X(e,p),a.push({type:\"keyed\",key:u,value:p,append:d})}else{let u=await L(e,l);a.push({type:\"invalid\",expandedValue:u})}}n||i();for(let l of a)if(l.type===\"keyed\")if(l.append){let c=e.state.env.get(`${s}_${l.key}`)??\"\";e.state.env.set(`${s}_${l.key}`,c+l.value)}else e.state.env.set(`${s}_${l.key}`,l.value);else{let c=t.line??e.state.currentLine??1;o(`bash: line ${c}: ${s}: ${l.expandedValue}: must use subscript when assigning associative array\n`)}}async function xa(e,t,s,r,n){let i=[];for(let a of s){let l=Ws(a);if(l){let{key:c,valueParts:u,append:f}=l,d;u.length>0?d=await L(e,{type:\"Word\",parts:u}):d=\"\",d=X(e,d),i.push({type:\"keyed\",indexExpr:c,value:d,append:f})}else{let c=await xe(e,a);i.push({type:\"non-keyed\",values:c.values})}}r||n();let o=0;for(let a of i)if(a.type===\"keyed\"){let l;try{let c=new B,u=ee(c,a.indexExpr);l=await H(e,u.expression,!1)}catch{if(/^-?\\d+$/.test(a.indexExpr))l=Number.parseInt(a.indexExpr,10);else{let c=e.state.env.get(a.indexExpr);l=c?Number.parseInt(c,10):0,Number.isNaN(l)&&(l=0)}}if(a.append){let c=e.state.env.get(`${t}_${l}`)??\"\";e.state.env.set(`${t}_${l}`,c+a.value)}else e.state.env.set(`${t}_${l}`,a.value);o=l+1}else for(let l of a.values)e.state.env.set(`${t}_${o++}`,l)}async function Ta(e,t,s,r,n){let i=[];for(let a of s){let l=await xe(e,a);i.push(...l.values)}let o=0;if(r){let a=Ae(e,t);if(a.length>0)o=Math.max(...a.map(([c])=>typeof c==\"number\"?c:0))+1;else{let l=e.state.env.get(t);l!==void 0&&(e.state.env.set(`${t}_0`,l),e.state.env.delete(t),o=1)}}else n();for(let a=0;a<i.length;a++)e.state.env.set(`${t}_${o+a}`,i[a]);r||e.state.env.set(`${t}__length`,String(i.length))}async function Da(e,t,s,r,n,i,o){let a=s;if(Ee(e,s)){let f=Ze(e,s);if(f&&f!==s){if(f.includes(\"[\"))return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: \\`${f}': not a valid identifier\n`,1)};a=f}}if(et(e,a)){if(t.name)return{continueToNext:!0,xtraceOutput:\"\"};let f=se(e,a);if(f)return{continueToNext:!1,xtraceOutput:\"\",error:f}}let l=e.state.associativeArrays?.has(a),c;if(l)c=await Ri(e,a,r);else{let f=await Ra(e,a,r);if(f.error)return{continueToNext:!1,xtraceOutput:\"\",error:f.error};c=`${a}_${f.index}`}let u=i?(e.state.env.get(c)||\"\")+n:n;if(t.name)o.set(c,e.state.env.get(c)),e.state.env.set(c,u);else{let f=pt(e,a);if(f!==void 0&&f===e.state.callDepth&&e.state.localScopes.length>0){let d=e.state.localScopes[e.state.localScopes.length-1];d.has(c)||d.set(c,e.state.env.get(c))}e.state.env.set(c,u)}return{continueToNext:!0,xtraceOutput:\"\"}}async function Ri(e,t,s){let r;if(s.startsWith(\"'\")&&s.endsWith(\"'\"))r=s.slice(1,-1);else if(s.startsWith('\"')&&s.endsWith('\"')){let n=s.slice(1,-1),o=new B().parseWordFromString(n,!0,!1);r=await L(e,o)}else if(s.includes(\"$\")){let i=new B().parseWordFromString(s,!1,!1);r=await L(e,i)}else r=s;return`${t}_${r}`}async function Ra(e,t,s){let r=s;s.startsWith('\"')&&s.endsWith('\"')&&s.length>=2&&(r=s.slice(1,-1));let n;if(/^-?\\d+$/.test(r))n=Number.parseInt(r,10);else{try{let i=new B,o=ee(i,r);n=await H(e,o.expression,!1)}catch(i){if(i instanceof Je){let l=`bash: line ${e.state.currentLine}: ${s}: ${i.message}\n`;if(i.fatal)throw new j(1,\"\",l);return{index:0,error:_(\"\",l,1)}}let o=e.state.env.get(s);n=o?Number.parseInt(o,10):0}Number.isNaN(n)&&(n=0)}if(n<0){let i=Ae(e,t);if(i.length===0){let a=e.state.currentLine;return{index:0,error:_(\"\",`bash: line ${a}: ${t}[${s}]: bad array subscript\n`,1)}}if(n=Math.max(...i.map(([a])=>typeof a==\"number\"?a:0))+1+n,n<0){let a=e.state.currentLine;return{index:0,error:_(\"\",`bash: line ${a}: ${t}[${s}]: bad array subscript\n`,1)}}}return{index:n}}async function Ia(e,t,s,r,n,i){let o=\"\",a=s,l=null;if(Ee(e,s)){let f=nn(e,s,r);if(f===void 0)return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: ${s}: circular name reference\n`,1)};if(f===null)return{continueToNext:!0,xtraceOutput:\"\"};a=f;let d=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);d&&(l={arrayName:d[1],subscriptExpr:d[2]},a=d[1])}if(et(e,a)){if(t.name)return o+=`bash: ${a}: readonly variable\n`,{continueToNext:!0,xtraceOutput:o};let f=se(e,a);if(f)return{continueToNext:!1,xtraceOutput:\"\",error:f}}let c;if(xt(e,a))try{let f=new B;if(n){let p=`(${e.state.env.get(a)||\"0\"}) + (${r})`,y=ee(f,p);c=String(await H(e,y.expression))}else{let d=ee(f,r);c=String(await H(e,d.expression))}}catch{c=\"0\"}else{let{isArray:f}=await import(\"./chunks/expansion-R25BK4W3.js\"),d=f(e,a)?`${a}_0`:a;c=n?(e.state.env.get(d)||\"\")+r:r}c=gt(e,a,c),o+=await xi(e,a,c);let u=a;if(l)u=await La(e,l);else{let{isArray:f}=await import(\"./chunks/expansion-R25BK4W3.js\");f(e,a)&&(u=`${a}_0`)}return t.name?(i.set(u,e.state.env.get(u)),e.state.env.set(u,c)):(e.state.env.set(u,c),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(a)),e.state.tempEnvBindings?.some(f=>f.has(a))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function La(e,t){let{arrayName:s,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(s))return Ri(e,s,r);let i;if(/^-?\\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new B,a=ee(o,r);i=await H(e,a.expression,!1)}catch{let o=e.state.env.get(r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=Ae(e,s);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${s}_${i}`}async function Ii(e,t,s,r){let n=await Re(e,t.redirections);if(n)return n;let i=new Map(e.state.env),o=e.state.cwd,a={...e.state.options},l=new Map(e.state.functions),c=e.state.localScopes,u=e.state.localVarStack,f=e.state.localVarDepth,d=e.state.fullyUnsetLocals;if(e.state.localScopes=c.map(S=>new Map(S)),u){e.state.localVarStack=new Map;for(let[S,T]of u.entries())e.state.localVarStack.set(S,T.map(N=>({...N})))}f&&(e.state.localVarDepth=new Map(f)),d&&(e.state.fullyUnsetLocals=new Map(d));let p=e.state.loopDepth,y=e.state.parentHasLoopContext;e.state.parentHasLoopContext=p>0,e.state.loopDepth=0;let h=e.state.lastArg,w=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let E=e.state.groupStdin;s&&(e.state.groupStdin=s);let g=\"\",b=\"\",m=0,v=()=>{e.state.env=i,e.state.cwd=o,e.state.options=a,e.state.functions=l,e.state.localScopes=c,e.state.localVarStack=u,e.state.localVarDepth=f,e.state.fullyUnsetLocals=d,e.state.loopDepth=p,e.state.parentHasLoopContext=y,e.state.groupStdin=E,e.state.bashPid=w,e.state.lastArg=h};try{for(let S of t.body){let T=await r(S);g+=T.stdout,b+=T.stderr,m=T.exitCode}}catch(S){if(v(),S instanceof J)throw S;if(S instanceof je){g+=S.stdout,b+=S.stderr;let N=_(g,b,0);return K(e,N,t.redirections)}if(S instanceof ye||S instanceof ge){g+=S.stdout,b+=S.stderr;let N=_(g,b,0);return K(e,N,t.redirections)}if(S instanceof j){g+=S.stdout,b+=S.stderr;let N=_(g,b,S.exitCode);return K(e,N,t.redirections)}if(S instanceof ue){g+=S.stdout,b+=S.stderr;let N=_(g,b,S.exitCode);return K(e,N,t.redirections)}if(S instanceof we){let N=_(g+S.stdout,b+S.stderr,S.exitCode);return K(e,N,t.redirections)}let T=_(g,`${b}${Ie(S)}\n`,1);return K(e,T,t.redirections)}v();let $=_(g,b,m);return K(e,$,t.redirections)}async function Li(e,t,s,r){let n=\"\",i=\"\",o=0,a=await ms(e,t.redirections);if(a)return a;let l=s;for(let f of t.redirections)if((f.operator===\"<<\"||f.operator===\"<<-\")&&f.target.type===\"HereDoc\"){let d=f.target,p=await L(e,d.content);d.stripTabs&&(p=p.split(`\n`).map(h=>h.replace(/^\\t+/,\"\")).join(`\n`));let y=f.fd??0;y!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),le(e),e.state.fileDescriptors.set(y,p)):l=p}else if(f.operator===\"<<<\"&&f.target.type===\"Word\")l=`${await L(e,f.target)}\n`;else if(f.operator===\"<\"&&f.target.type===\"Word\")try{let d=await L(e,f.target),p=e.fs.resolvePath(e.state.cwd,d);l=await e.fs.readFile(p)}catch{let d=await L(e,f.target);return _(\"\",`bash: ${d}: No such file or directory\n`,1)}let c=e.state.groupStdin;l&&(e.state.groupStdin=l);try{for(let f of t.body){let d=await r(f);n+=d.stdout,i+=d.stderr,o=d.exitCode}}catch(f){if(e.state.groupStdin=c,f instanceof J)throw f;if(Zt(f)||f instanceof we||f instanceof j)throw f.prependOutput(n,i),f;return _(n,`${i}${Ie(f)}\n`,1)}e.state.groupStdin=c;let u=_(n,i,o);return K(e,u,t.redirections)}async function Fi(e,t,s,r,n){let i;try{i=await e.fs.readFile(t)}catch{return A(`bash: ${t}: No such file or directory\n`,127)}if(i.startsWith(\"#!\")){let w=i.indexOf(`\n`);w!==-1&&(i=i.slice(w+1))}let o=new Map(e.state.env),a=e.state.cwd,l={...e.state.options},c=e.state.loopDepth,u=e.state.parentHasLoopContext,f=e.state.lastArg,d=e.state.bashPid,p=e.state.groupStdin,y=e.state.currentSource;e.state.parentHasLoopContext=c>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,r&&(e.state.groupStdin=r),e.state.currentSource=t,e.state.env.set(\"0\",t),e.state.env.set(\"#\",String(s.length)),e.state.env.set(\"@\",s.join(\" \")),e.state.env.set(\"*\",s.join(\" \"));for(let w=0;w<s.length&&w<9;w++)e.state.env.set(String(w+1),s[w]);for(let w=s.length+1;w<=9;w++)e.state.env.delete(String(w));let h=()=>{e.state.env=o,e.state.cwd=a,e.state.options=l,e.state.loopDepth=c,e.state.parentHasLoopContext=u,e.state.lastArg=f,e.state.bashPid=d,e.state.groupStdin=p,e.state.currentSource=y};try{let E=new B().parse(i),g=await n(E);return h(),g}catch(w){if(h(),w instanceof j||w instanceof J)throw w;if(w.name===\"ParseException\")return A(`bash: ${t}: ${w.message}\n`);throw w}}var It=class{ctx;constructor(t,s){this.ctx={state:s,fs:t.fs,commands:t.commands,limits:t.limits,execFn:t.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:t.fetch,sleep:t.sleep,trace:t.trace,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext??!1,jsBootstrapCode:t.jsBootstrapCode,invokeTool:t.invokeTool}}assertDefenseContext(t){if(!this.ctx.requireDefenseContext||me.isInSandboxedContext())return;let s=`interpreter ${t} attempted outside defense context`;throw new Ve(s,{timestamp:Date.now(),type:\"missing_defense_context\",message:s,path:\"DefenseInDepthBox.context\",stack:new Error().stack,executionId:me.getCurrentExecutionId()})}buildExportedEnv(){let t=this.ctx.state.exportedVars,s=this.ctx.state.tempExportedVars,r=new Set;if(t)for(let i of t)r.add(i);if(s)for(let i of s)r.add(i);if(r.size===0)return Object.create(null);let n=Object.create(null);for(let i of r){let o=this.ctx.state.env.get(i);o!==void 0&&(n[i]=o)}return n}async executeScript(t){this.assertDefenseContext(\"execution\");let s=\"\",r=\"\",n=0,i=this.ctx.limits.maxOutputSize,o=(a,l)=>{s.length+r.length+a.length+l.length>i&&Te(`total output size exceeded (>${i} bytes), increase executionLimits.maxOutputSize`,\"output_size\"),s+=a,r+=l};for(let a of t.statements)try{let l=await this.executeStatement(a);o(l.stdout,l.stderr),n=l.exitCode,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n))}catch(l){if(l instanceof j)throw l.prependOutput(s,r),l;if(l instanceof Pe)return o(l.stdout,l.stderr),n=l.exitCode,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof J)throw l;if(l instanceof we)return o(l.stdout,l.stderr),n=l.exitCode,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof Gr)return o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof jt)return o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof Je){o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n));continue}if(l instanceof Kr){o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n));continue}if(l instanceof ye||l instanceof ge){if(this.ctx.state.loopDepth>0)throw l.prependOutput(s,r),l;o(l.stdout,l.stderr);continue}throw l instanceof ue&&l.prependOutput(s,r),l}return{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)}}async executeUserScript(t,s,r=\"\"){return Fi(this.ctx,t,s,r,n=>this.executeScript(n))}async executeStatement(t){if(this.assertDefenseContext(\"statement\"),this.ctx.state.signal?.aborted)throw new Ht;if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Te(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,\"commands\"),t.deferredError)throw new qt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return W;this.ctx.state.errexitSafe=!1;let s=\"\",r=\"\";this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&(r+=`${t.sourceText}\n`);let n=0,i=-1,o=!1;for(let c=0;c<t.pipelines.length;c++){let u=t.pipelines[c],f=c>0?t.operators[c-1]:null;if(f===\"&&\"&&n!==0||f===\"||\"&&n===0)continue;let d=await this.executePipeline(u);s+=d.stdout,r+=d.stderr,n=d.exitCode,i=c,o=u.negated,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n))}let a=i<t.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||l,this.ctx.state.options.errexit&&n!==0&&i===t.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!l)throw new we(n,s,r);return _(s,r,n)}async executePipeline(t){return Ti(this.ctx,t,(s,r)=>this.executeCommand(s,r))}async executeCommand(t,s){switch(this.assertDefenseContext(\"command\"),this.ctx.coverage?.hit(`bash:cmd:${t.type}`),t.type){case\"SimpleCommand\":return this.executeSimpleCommand(t,s);case\"If\":return Ei(this.ctx,t);case\"For\":return $i(this.ctx,t);case\"CStyleFor\":return Si(this.ctx,t);case\"While\":return Pi(this.ctx,t,s);case\"Until\":return Ai(this.ctx,t);case\"Case\":return ki(this.ctx,t);case\"Subshell\":return this.executeSubshell(t,s);case\"Group\":return this.executeGroup(t,s);case\"FunctionDef\":return Bn(this.ctx,t);case\"ArithmeticCommand\":return this.executeArithmeticCommand(t);case\"ConditionalCommand\":return this.executeConditionalCommand(t);default:return W}}async executeSimpleCommand(t,s){try{return await this.executeSimpleCommandInner(t,s)}catch(r){if(r instanceof Ut)return A(r.stderr);throw r}}async executeSimpleCommandInner(t,s){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let m=t,v=100;for(;v>0;){let $=this.expandAlias(m);if($===m)break;m=$,v--}this.aliasExpansionStack.clear(),m!==t&&(t=m)}this.ctx.state.expansionStderr=\"\";let r=await Di(this.ctx,t);if(r.error)return r.error;let n=r.tempAssignments,i=r.xtraceOutput;if(!t.name){if(t.redirections.length>0){let v=await Re(this.ctx,t.redirections);if(v)return v;let $=_(\"\",i,0);return K(this.ctx,$,t.redirections)}this.ctx.state.lastArg=\"\";let m=(this.ctx.state.expansionStderr||\"\")+i;return this.ctx.state.expansionStderr=\"\",_(\"\",m,this.ctx.state.lastExitCode)}let o=t.name&&zr(t.name,[\"local\",\"declare\",\"typeset\",\"export\",\"readonly\"]),a=Array.from(n.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let m of a)this.ctx.state.tempExportedVars.add(m)}let l=await ms(this.ctx,t.redirections);if(l){for(let[m,v]of n)v===void 0?this.ctx.state.env.delete(m):this.ctx.state.env.set(m,v);return l}let c=-1;for(let m of t.redirections){if((m.operator===\"<<\"||m.operator===\"<<-\")&&m.target.type===\"HereDoc\"){let v=m.target,$=await L(this.ctx,v.content);v.stripTabs&&($=$.split(`\n`).map(T=>T.replace(/^\\t+/,\"\")).join(`\n`)),$=Be($);let S=m.fd??0;S!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),le(this.ctx),this.ctx.state.fileDescriptors.set(S,$)):s=$;continue}if(m.operator===\"<<<\"&&m.target.type===\"Word\"){s=Be(`${await L(this.ctx,m.target)}\n`);continue}if(m.operator===\"<\"&&m.target.type===\"Word\")try{let v=await L(this.ctx,m.target),$=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);s=await Vt(this.ctx.fs,$)}catch{let v=await L(this.ctx,m.target);for(let[$,S]of n)S===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,S);return A(`bash: ${v}: No such file or directory\n`)}if(m.operator===\"<&\"&&m.target.type===\"Word\"){let v=await L(this.ctx,m.target),$=Number.parseInt(v,10);if(!Number.isNaN($)&&this.ctx.state.fileDescriptors){let S=this.ctx.state.fileDescriptors.get($);if(S!==void 0)if(S.startsWith(\"__rw__:\")){let T=_i(S);T&&(s=T.content.slice(T.position),c=$)}else S.startsWith(\"__file__:\")||S.startsWith(\"__file_append__:\")||(s=S)}}}let u=await L(this.ctx,t.name),f=[],d=[];if(zr(t.name,[\"local\",\"declare\",\"typeset\",\"export\",\"readonly\"])&&(u===\"local\"||u===\"declare\"||u===\"typeset\"||u===\"export\"||u===\"readonly\"))for(let m of t.args){let v=await An(this.ctx,m);if(v)f.push(v),d.push(!0);else{let $=await kn(this.ctx,m);if($!==null)f.push($),d.push(!0);else{let S=await xe(this.ctx,m);for(let T of S.values)f.push(T),d.push(S.quoted)}}}else for(let m of t.args){let v=await xe(this.ctx,m);for(let $ of v.values)f.push($),d.push(v.quoted)}if(!u){if(t.name.parts.every(v=>v.type===\"CommandSubstitution\"||v.type===\"ParameterExpansion\"||v.type===\"ArithmeticExpansion\")){if(f.length>0){let v=f.shift();return d.shift(),await this.runCommand(v,f,d,s,!1,!1,c)}return _(\"\",\"\",this.ctx.state.lastExitCode)}return A(`bash: : command not found\n`,127)}if(u===\"exec\"&&(f.length===0||f[0]===\"--\")){for(let m of t.redirections){if(m.target.type===\"HereDoc\"||m.fdVariable)continue;let v=await L(this.ctx,m.target),$=m.fd??(m.operator===\"<\"||m.operator===\"<>\"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),m.operator){case\">\":case\">|\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);await this.ctx.fs.writeFile(S,\"\",\"utf8\"),le(this.ctx),this.ctx.state.fileDescriptors.set($,`__file__:${S}`);break}case\">>\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);le(this.ctx),this.ctx.state.fileDescriptors.set($,`__file_append__:${S}`);break}case\"<\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);try{let T=await this.ctx.fs.readFile(S);le(this.ctx),this.ctx.state.fileDescriptors.set($,T)}catch{return A(`bash: ${v}: No such file or directory\n`)}break}case\"<>\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);try{let T=await this.ctx.fs.readFile(S);le(this.ctx),this.ctx.state.fileDescriptors.set($,`__rw__:${S.length}:${S}:0:${T}`)}catch{await this.ctx.fs.writeFile(S,\"\",\"utf8\"),le(this.ctx),this.ctx.state.fileDescriptors.set($,`__rw__:${S.length}:${S}:0:`)}break}case\">&\":{if(v===\"-\")this.ctx.state.fileDescriptors.delete($);else if(v.endsWith(\"-\")){let S=v.slice(0,-1),T=Number.parseInt(S,10);if(!Number.isNaN(T)){let N=this.ctx.state.fileDescriptors.get(T);N!==void 0?this.ctx.state.fileDescriptors.set($,N):this.ctx.state.fileDescriptors.set($,`__dupout__:${T}`),this.ctx.state.fileDescriptors.delete(T)}}else{let S=Number.parseInt(v,10);Number.isNaN(S)||(le(this.ctx),this.ctx.state.fileDescriptors.set($,`__dupout__:${S}`))}break}case\"<&\":{if(v===\"-\")this.ctx.state.fileDescriptors.delete($);else if(v.endsWith(\"-\")){let S=v.slice(0,-1),T=Number.parseInt(S,10);if(!Number.isNaN(T)){let N=this.ctx.state.fileDescriptors.get(T);N!==void 0?this.ctx.state.fileDescriptors.set($,N):this.ctx.state.fileDescriptors.set($,`__dupin__:${T}`),this.ctx.state.fileDescriptors.delete(T)}}else{let S=Number.parseInt(v,10);Number.isNaN(S)||(le(this.ctx),this.ctx.state.fileDescriptors.set($,`__dupin__:${S}`))}break}}}for(let[m,v]of n)v===void 0?this.ctx.state.env.delete(m):this.ctx.state.env.set(m,v);if(this.ctx.state.tempExportedVars)for(let m of n.keys())this.ctx.state.tempExportedVars.delete(m);return W}if(this.ctx.state.extraArgs){f.push(...this.ctx.state.extraArgs);for(let m=0;m<this.ctx.state.extraArgs.length;m++)d.push(!0);this.ctx.state.extraArgs=void 0}let y=await Oi(this.ctx,u,f);n.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(n)));let h,w=null;try{h=await this.runCommand(u,f,d,s,!1,!1,c)}catch(m){if(m instanceof ye||m instanceof ge)w=m,h=W;else throw m}let E=i+y;if(E&&(h={...h,stderr:E+h.stderr}),h=await K(this.ctx,h,t.redirections),w)throw w;if(f.length>0){let m=f[f.length-1];if((u===\"declare\"||u===\"local\"||u===\"typeset\")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\\(/.test(m)){let v=m.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\(/);v&&(m=v[1])}this.ctx.state.lastArg=m}else this.ctx.state.lastArg=u;let g=zn(u)&&u!==\"unset\"&&u!==\"eval\";if(!this.ctx.state.options.posix||!g)for(let[m,v]of n)this.ctx.state.fullyUnsetLocals?.has(m)||(v===void 0?this.ctx.state.env.delete(m):this.ctx.state.env.set(m,v));if(this.ctx.state.tempExportedVars)for(let m of n.keys())this.ctx.state.tempExportedVars.delete(m);return n.size>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,s,r,n,i=!1,o=!1,a=-1){let l={ctx:this.ctx,runCommand:(u,f,d,p,y,h,w)=>this.runCommand(u,f,d,p,y,h,w),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(u,f,d)=>this.executeUserScript(u,f,d)},c=await vi(l,t,s,r,n,i,o,a);return c!==null?c:bi(l,t,s,n,o)}aliasExpansionStack=new Set;expandAlias(t){return Ks(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return $s(this.ctx,t)}async executeSubshell(t,s=\"\"){return Ii(this.ctx,t,s,r=>this.executeStatement(r))}async executeGroup(t,s=\"\"){return Li(this.ctx,t,s,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Re(this.ctx,t.redirections);if(s)return s;try{let r=await H(this.ctx,t.expression.expression),n=Q(r!==0);return this.ctx.state.expansionStderr&&(n={...n,stderr:this.ctx.state.expansionStderr+n.stderr},this.ctx.state.expansionStderr=\"\"),K(this.ctx,n,t.redirections)}catch(r){let n=A(`bash: arithmetic expression: ${r.message}\n`);return K(this.ctx,n,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Re(this.ctx,t.redirections);if(s)return s;try{let r=await Ke(this.ctx,t.expression),n=Q(r);return this.ctx.state.expansionStderr&&(n={...n,stderr:this.ctx.state.expansionStderr+n.stderr},this.ctx.state.expansionStderr=\"\"),K(this.ctx,n,t.redirections)}catch(r){let n=r instanceof Je?1:2,i=A(`bash: conditional expression: ${r.message}\n`,n);return K(this.ctx,i,t.redirections)}}};var re={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxSubstitutionDepth:50,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxSourceDepth:100};function Mi(e){return e?{maxCallDepth:e.maxCallDepth??re.maxCallDepth,maxCommandCount:e.maxCommandCount??re.maxCommandCount,maxLoopIterations:e.maxLoopIterations??re.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??re.maxAwkIterations,maxSedIterations:e.maxSedIterations??re.maxSedIterations,maxJqIterations:e.maxJqIterations??re.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??re.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??re.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??re.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??re.maxGlobOperations,maxStringLength:e.maxStringLength??re.maxStringLength,maxArrayElements:e.maxArrayElements??re.maxArrayElements,maxHeredocSize:e.maxHeredocSize??re.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??re.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??re.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??re.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??re.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??re.maxSourceDepth}:{...re}}import{lookup as Za}from\"node:dns\";function Vr(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Fa(e){let t=Vr(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Wi(e){if(e.includes(\"\\\\\"))return!0;let t=e.toLowerCase();return t.includes(\"%2f\")||t.includes(\"%5c\")}function Ma(e,t){return t===\"/\"||t===\"\"?!0:t.endsWith(\"/\")?e.startsWith(t):e===t||e.startsWith(`${t}/`)}function Br(e,t){let s=Vr(e);if(!s)return!1;let r=Fa(t);return!r||s.origin!==r.origin||r.pathPrefix!==\"/\"&&r.pathPrefix!==\"\"&&Wi(s.pathname)?!1:Ma(s.pathname,r.pathPrefix)}function zi(e){return typeof e==\"string\"?e:e.url}function Vi(e,t){return!t||t.length===0?!1:t.some(s=>Br(e,zi(s)))}function jr(e){let t=Wa(e);if(t===\"localhost\"||t.endsWith(\".localhost\"))return!0;let s=Bi(t);if(s)return Ps(s);let r=Va(t);return r?Ba(r):!1}function Wa(e){let t=e.trim().toLowerCase();return t.startsWith(\"[\")&&t.endsWith(\"]\")?t.slice(1,-1):t}function za(e){if(!e)return null;let t=10,s=e;if(s.startsWith(\"0x\")||s.startsWith(\"0X\")?(t=16,s=s.slice(2)):s.length>1&&s.startsWith(\"0\")&&(t=8),!s||t===16&&!/^[0-9a-fA-F]+$/.test(s)||t===10&&!/^\\d+$/.test(s)||t===8&&!/^[0-7]+$/.test(s))return null;let r=Number.parseInt(s,t);return!Number.isFinite(r)||r<0?null:r}function Bi(e){let t=e.split(\".\");if(t.length===0||t.length>4)return null;let s=t.map(l=>za(l));if(s.some(l=>l===null))return null;let r=s;if(t.length===1){let l=r[0];return l>4294967295?null:[l>>>24&255,l>>>16&255,l>>>8&255,l&255]}if(t.length===2){let[l,c]=r;return l>255||c>16777215?null:[l,c>>>16&255,c>>>8&255,c&255]}if(t.length===3){let[l,c,u]=r;return l>255||c>255||u>65535?null:[l,c,u>>>8&255,u&255]}let[n,i,o,a]=r;return n>255||i>255||o>255||a>255?null:[n,i,o,a]}function Va(e){let t=e,s=null;if(t.includes(\".\")){let h=t.lastIndexOf(\":\");if(h<0)return null;let w=t.slice(h+1),E=Bi(w);if(!E)return null;s=E,t=t.slice(0,h)}let r=t.includes(\"::\")?t.split(\"::\").length-1:0;if(r>1)return null;let[n,i]=t.split(\"::\"),o=n?n.split(\":\").filter(Boolean):[],a=i?i.split(\":\").filter(Boolean):[],l=h=>/^[0-9a-f]{1,4}$/i.test(h)?Number.parseInt(h,16):null,c=o.map(l),u=a.map(l);if(c.some(h=>h===null)||u.some(h=>h===null))return null;let f=s?2:0,d=c.length+u.length+f,p=0;if(r===1){if(p=8-d,p<0)return null}else if(d!==8)return null;let y=[...c,...new Array(p).fill(0),...u];return s&&(y.push(s[0]<<8|s[1]),y.push(s[2]<<8|s[3])),y.length===8?y:null}function Ps(e){let[t,s]=e;return t===127||t===10||t===172&&s>=16&&s<=31||t===192&&s===168||t===169&&s===254||t===0||t===100&&s>=64&&s<=127||t===198&&(s===18||s===19)||t===192&&s===0&&e[2]===0||t===192&&s===0&&e[2]===2||t===198&&s===51&&e[2]===100||t===203&&s===0&&e[2]===113||t>=240}function Ba(e){if(e.every(n=>n===0)||e.slice(0,7).every(n=>n===0)&&e[7]===1||(e[0]&65472)===65152||(e[0]&65024)===64512)return!0;if(e[0]===0&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===65535){let n=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Ps(n)}if(e[0]===8193&&e[1]===3512)return!0;if(e[0]===100&&e[1]===65435&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===0){let n=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Ps(n)}if(e[0]===100&&e[1]===65435&&e[2]===1)return!0;if(e[0]===8194){let n=[e[1]>>>8&255,e[1]&255,e[2]>>>8&255,e[2]&255];return Ps(n)}return!1}function ji(e){let t=[];for(let s of e){if(typeof s!=\"string\"&&(s===null||typeof s!=\"object\"||!(\"url\"in s)||typeof s.url!=\"string\")){t.push('Invalid allow-list entry: must be a string URL or an object with a \"url\" string property');continue}let r=zi(s);if(!Vr(r)){t.push(`Invalid URL in allow-list: \"${r}\" - must be a valid URL with scheme and host (e.g., \"https://example.com\")`);continue}let i=new URL(r);if(i.protocol!==\"http:\"&&i.protocol!==\"https:\"){t.push(`Only http and https URLs are allowed in allow-list: \"${r}\"`);continue}if(!i.hostname){t.push(`Allow-list entry must include a hostname: \"${r}\"`);continue}if(i.pathname!==\"/\"&&i.pathname!==\"\"&&Wi(i.pathname)){t.push(`Allow-list entry contains ambiguous path separators: \"${r}\"`);continue}(i.search||i.hash)&&t.push(`Query strings and fragments are ignored in allow-list entries: \"${r}\"`)}return t}var ja=typeof __BROWSER__<\"u\"&&__BROWSER__,wt=null,As=null,Ui=!1;function Ua(){if(wt===null&&!ja)try{let e=Is(\"node:async_hooks\");As=Is(\"node:dns\"),wt=new e.AsyncLocalStorage}catch{}}function Ha(){if(Ui||(Ua(),!wt||!As))return;Ui=!0;let e=wt,t=As.lookup;function s(...r){let n=r[0],i=e.getStore();if(typeof n!=\"string\"||!i||i.hostname.toLowerCase()!==n.toLowerCase())return t.apply(this,r);let o={},a;if(r.length===2)a=r[1];else if(r.length>=3){let c=r[1];typeof c==\"number\"?o={family:c}:c&&typeof c==\"object\"&&(o=c),a=r[2]}if(typeof a!=\"function\")return t.apply(this,r);let l=a;if(o.family!==void 0&&o.family!==0&&o.family!==i.family){let c=new Error(`ENOTFOUND ${n}`);c.code=\"ENOTFOUND\",c.errno=-3008,c.syscall=\"getaddrinfo\",c.hostname=n,process.nextTick(()=>l(c));return}process.nextTick(()=>{o.all?l(null,[{address:i.address,family:i.family}]):l(null,i.address,i.family)})}Object.defineProperty(As,\"lookup\",{value:s,writable:!0,configurable:!0})}function Hi(e,t){return Ha(),wt?wt.run(e,t):t()}var _e=class extends Error{constructor(t,s){let r=s??\"URL not in allow-list\";super(`Network access denied: ${r}: ${t}`),this.name=\"NetworkAccessDeniedError\"}},vt=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name=\"TooManyRedirectsError\"}},bt=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name=\"RedirectNotAllowedError\"}},ks=class extends Error{constructor(t,s){super(`HTTP method '${t}' not allowed. Allowed methods: ${s.join(\", \")}`),this.name=\"MethodNotAllowedError\"}},Et=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name=\"ResponseTooLargeError\"}};function qa(e){return new Promise((t,s)=>{Za(e,{all:!0},(r,n)=>{r?s(r):t(n)})})}var Ga=20,Ka=3e4,Xa=10485760,Ya=[\"GET\",\"HEAD\"],Qa=new Set([\"GET\",\"HEAD\",\"OPTIONS\"]),Ja=new Set([301,302,303,307,308]);function Ur(e){let t=e.allowedUrlPrefixes??[];if(!e.dangerouslyAllowFullInternetAccess){let p=ji(t);if(p.length>0)throw new Error(`Invalid network allow-list:\n${p.join(`\n`)}`)}let s=[];for(let p of t)typeof p==\"object\"&&p.transform&&p.transform.length>0&&s.push(p);function r(p){if(s.length===0)return null;let y=null;for(let h of s)if(Br(p,h.url)&&h.transform){y||(y=new Headers);for(let w of h.transform)for(let[E,g]of Object.entries(w.headers))y.set(E,g)}return y}let n=e.maxRedirects??Ga,i=e.timeoutMs??Ka,o=e.maxResponseSize??Xa,a=e.dangerouslyAllowFullInternetAccess?[\"GET\",\"HEAD\",\"POST\",\"PUT\",\"DELETE\",\"PATCH\",\"OPTIONS\"]:e.allowedMethods??Ya,l=e.denyPrivateRanges??(typeof process<\"u\"&&process.env?.NODE_ENV===\"production\"),c=e._dnsResolve??qa;async function u(p){if(!e.dangerouslyAllowFullInternetAccess&&!Vi(p,t))throw new _e(p);if(l)try{let y=new URL(p);if(jr(y.hostname))throw new _e(p,\"private/loopback IP address blocked\");let h=y.hostname;if(/[a-zA-Z]/.test(h))try{let E=await c(h);for(let{address:b}of E)if(jr(b))throw new _e(p,\"hostname resolves to private/loopback IP address\");let g=E[0];if(g)return{hostname:h,address:g.address,family:g.family===6?6:4}}catch(E){if(E instanceof _e)throw E;let g=E?.code;if(!(g===\"ENOTFOUND\"||g===\"ENODATA\"))throw new _e(p,\"DNS resolution failed for private IP check\")}}catch(y){if(y instanceof _e)throw y}return null}function f(p){if(e.dangerouslyAllowFullInternetAccess)return;let y=p.toUpperCase();if(!a.includes(y))throw new ks(y,a)}async function d(p,y={}){let h=y.method?.toUpperCase()??\"GET\",w=await u(p);f(h);let E=p,g=0,b=y.followRedirects??!0,m=y.timeoutMs!==void 0?Math.min(y.timeoutMs,i):i;for(;;){let v=new AbortController,$=Mt(()=>v.abort(),m);try{let S=await me.runTrustedAsync(()=>{let T=r(E),N=el(y.headers,T),F={method:h,headers:N,signal:v.signal,redirect:\"manual\"};return y.body&&!Qa.has(h)&&(F.body=y.body),w?Hi(w,()=>fetch(E,F)):fetch(E,F)});if(Ja.has(S.status)&&b){let T=S.headers.get(\"location\");if(!T)return await Zi(S,E,o);let N=new URL(T,E).href;try{w=await u(N)}catch{throw new bt(N)}if(g++,g>n)throw new vt(n);E=N;continue}return await Zi(S,E,o)}finally{Wt($)}}}return d}function el(e,t){if(!e&&!t)return;if(!t)return e;let s=e instanceof Headers?new Headers(e):new Headers(e);for(let[r,n]of t)s.set(r,n);return s}async function Zi(e,t,s){let r=Object.create(null);if(e.headers.forEach((i,o)=>{r[o.toLowerCase()]=i}),s>0){let i=e.headers.get(\"content-length\");if(i){let o=parseInt(i,10);if(!Number.isNaN(o)&&o>s)throw new Et(s)}}let n;if(s>0&&e.body){let i=e.body.getReader(),o=[],a=0;for(;;){let{done:c,value:u}=await i.read();if(c)break;if(u){if(a+=u.byteLength,a>s)throw i.cancel(),new Et(s);o.push(u)}}n=new Uint8Array(a);let l=0;for(let c of o)n.set(c,l),l+=c.byteLength}else{let i=await e.arrayBuffer();if(s>0&&i.byteLength>s)throw new Et(s);n=new Uint8Array(i)}return{status:e.status,statusText:e.statusText,headers:r,body:n,url:t}}function Lt(e){return ot(e)}function ot(e){return e.statements.map(qi).join(`\n`)}function qi(e){let t=[];for(let r=0;r<e.pipelines.length;r++)t.push(tl(e.pipelines[r])),r<e.operators.length&&t.push(e.operators[r]);let s=t.join(\" \");return e.background&&(s+=\" &\"),s}function tl(e){let t=[];e.timed&&t.push(e.timePosix?\"time -p\":\"time\"),e.negated&&t.push(\"!\");let s=[];for(let n=0;n<e.commands.length;n++)if(s.push(Gi(e.commands[n])),n<e.commands.length-1){let i=e.pipeStderr?.[n];s.push(i?\"|&\":\"|\")}return(t.length>0?`${t.join(\" \")} `:\"\")+s.join(\" \")}function Gi(e){switch(e.type){case\"SimpleCommand\":return sl(e);case\"If\":return fl(e);case\"For\":return dl(e);case\"CStyleFor\":return hl(e);case\"While\":return pl(e);case\"Until\":return ml(e);case\"Case\":return yl(e);case\"Subshell\":return wl(e);case\"Group\":return vl(e);case\"ArithmeticCommand\":return bl(e);case\"ConditionalCommand\":return El(e);case\"FunctionDef\":return $l(e);default:{let t=e;throw new Error(`Unsupported command type: ${t.type}`)}}}function sl(e){let t=[];for(let s of e.assignments)t.push(rl(s));e.name&&t.push(ie(e.name));for(let s of e.args)t.push(ie(s));for(let s of e.redirections)t.push(Yi(s));return t.join(\" \")}function rl(e){let t=e.append?\"+=\":\"=\";if(e.array){let s=e.array.map(ie).join(\" \");return`${e.name}${t}(${s})`}return e.value?`${e.name}${t}${ie(e.value)}`:`${e.name}${t}`}function ie(e){return e.parts.map(t=>_s(t,!1)).join(\"\")}function Qe(e){return e.parts.map(t=>_s(t,!0)).join(\"\")}function _s(e,t){switch(e.type){case\"Literal\":return t?il(e.value):nl(e.value);case\"SingleQuoted\":return`'${e.value}'`;case\"DoubleQuoted\":return`\"${e.parts.map(s=>_s(s,!0)).join(\"\")}\"`;case\"Escaped\":return`\\\\${e.value}`;case\"ParameterExpansion\":return Ki(e);case\"CommandSubstitution\":return e.legacy?`\\`${ot(e.body)}\\``:`$(${ot(e.body)})`;case\"ArithmeticExpansion\":return`$((${Z(e.expression.expression)}))`;case\"ProcessSubstitution\":return e.direction===\"input\"?`<(${ot(e.body)})`:`>(${ot(e.body)})`;case\"BraceExpansion\":return cl(e);case\"TildeExpansion\":return e.user!==null?`~${e.user}`:\"~\";case\"Glob\":return e.pattern;default:{let s=e;throw new Error(`Unsupported word part type: ${s.type}`)}}}function nl(e){return e.replace(/[\\s\\\\'\"`!|&;()<>{}[\\]*?~#]/g,\"\\\\$&\")}function il(e){return e.replace(/[$`\"\\\\]/g,\"\\\\$&\")}function ol(e,t){return e.parts.map(s=>al(s,t)).join(\"\")}function al(e,t){switch(e.type){case\"Literal\":return t?e.value:e.value.replace(/[$`]/g,\"\\\\$&\");case\"Escaped\":return`\\\\${e.value}`;case\"ParameterExpansion\":return Ki(e);case\"CommandSubstitution\":return e.legacy?`\\`${ot(e.body)}\\``:`$(${ot(e.body)})`;case\"ArithmeticExpansion\":return`$((${Z(e.expression.expression)}))`;default:return _s(e,!1)}}function Ki(e){return e.operation?`\\${${Xi(e.parameter,e.operation)}}`:ll(e.parameter)?`\\${${e.parameter}}`:`$${e.parameter}`}function ll(e){return!(/^[?#@*$!\\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function Xi(e,t){switch(t.type){case\"Length\":return`#${e}`;case\"LengthSliceError\":return`#${e}:`;case\"BadSubstitution\":return t.text;case\"DefaultValue\":return`${e}${t.checkEmpty?\":\":\"\"}-${Qe(t.word)}`;case\"AssignDefault\":return`${e}${t.checkEmpty?\":\":\"\"}=${Qe(t.word)}`;case\"ErrorIfUnset\":return`${e}${t.checkEmpty?\":\":\"\"}?${t.word?Qe(t.word):\"\"}`;case\"UseAlternative\":return`${e}${t.checkEmpty?\":\":\"\"}+${Qe(t.word)}`;case\"Substring\":{let s=Z(t.offset.expression);return t.length?`${e}:${s}:${Z(t.length.expression)}`:`${e}:${s}`}case\"PatternRemoval\":{let s=t.side===\"prefix\"?\"#\":\"%\",r=t.greedy?`${s}${s}`:s;return`${e}${r}${Qe(t.pattern)}`}case\"PatternReplacement\":{let s=\"/\";t.all?s=\"//\":t.anchor===\"start\"?s=\"/#\":t.anchor===\"end\"&&(s=\"/%\");let r=t.replacement?`/${Qe(t.replacement)}`:\"\";return`${e}${s}${Qe(t.pattern)}${r}`}case\"CaseModification\":{let s=t.direction===\"upper\"?\"^\":\",\",r=t.all?`${s}${s}`:s,n=t.pattern?Qe(t.pattern):\"\";return`${e}${r}${n}`}case\"Transform\":return`${e}@${t.operator}`;case\"Indirection\":return t.innerOp?`!${Xi(e,t.innerOp)}`:`!${e}`;case\"ArrayKeys\":return`!${t.array}[${t.star?\"*\":\"@\"}]`;case\"VarNamePrefix\":return`!${t.prefix}${t.star?\"*\":\"@\"}`;default:{let s=t;throw new Error(`Unsupported parameter operation type: ${s.type}`)}}}function cl(e){return`{${e.items.map(ul).join(\",\")}}`}function ul(e){if(e.type===\"Word\")return ie(e.word);let t=e.startStr??String(e.start),s=e.endStr??String(e.end);return e.step!==void 0?`${t}..${s}..${e.step}`:`${t}..${s}`}function Yi(e){let t=e.fdVariable?`{${e.fdVariable}}`:e.fd!==null?String(e.fd):\"\";if(e.operator===\"<<\"||e.operator===\"<<-\"){let s=e.target,r=s.quoted?`'${s.delimiter}'`:s.delimiter,n=ol(s.content,s.quoted);return`${t}${e.operator}${r}\n${n}${s.delimiter}`}return e.operator===\"<<<\"?`${t}<<< ${ie(e.target)}`:e.operator===\"&>\"||e.operator===\"&>>\"?`${e.operator} ${ie(e.target)}`:`${t}${e.operator} ${ie(e.target)}`}function Ce(e){return e.length===0?\"\":` ${e.map(Yi).join(\" \")}`}function $e(e){return e.map(qi).join(`\n`)}function fl(e){let t=[];for(let s=0;s<e.clauses.length;s++){let r=e.clauses[s],n=s===0?\"if\":\"elif\";t.push(`${n} ${$e(r.condition)}; then\n${$e(r.body)}`)}return e.elseBody&&t.push(`else\n${$e(e.elseBody)}`),`${t.join(`\n`)}\nfi${Ce(e.redirections)}`}function dl(e){let t;if(e.words===null)t=`for ${e.variable}`;else{let s=e.words.map(ie).join(\" \");t=`for ${e.variable} in ${s}`}return`${t}; do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function hl(e){let t=e.init?Z(e.init.expression):\"\",s=e.condition?Z(e.condition.expression):\"\",r=e.update?Z(e.update.expression):\"\";return`for ((${t}; ${s}; ${r})); do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function pl(e){return`while ${$e(e.condition)}; do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function ml(e){return`until ${$e(e.condition)}; do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function yl(e){let t=e.items.map(gl).join(`\n`);return`case ${ie(e.word)} in\n${t}\nesac${Ce(e.redirections)}`}function gl(e){let t=e.patterns.map(ie).join(\" | \"),s=$e(e.body);return s?`${t})\n${s}\n${e.terminator}`:`${t})\n${e.terminator}`}function wl(e){return`(${$e(e.body)})${Ce(e.redirections)}`}function vl(e){return`{ ${$e(e.body)}; }${Ce(e.redirections)}`}function bl(e){return`((${Z(e.expression.expression)}))${Ce(e.redirections)}`}function El(e){return`[[ ${it(e.expression)} ]]${Ce(e.redirections)}`}function $l(e){let t=Gi(e.body);return`${e.name}() ${t}${Ce(e.redirections)}`}function Z(e){switch(e.type){case\"ArithNumber\":return String(e.value);case\"ArithVariable\":return e.hasDollarPrefix?`$${e.name}`:e.name;case\"ArithSpecialVar\":return`$${e.name}`;case\"ArithBinary\":return`${Z(e.left)} ${e.operator} ${Z(e.right)}`;case\"ArithUnary\":return e.prefix?`${e.operator}${Z(e.operand)}`:`${Z(e.operand)}${e.operator}`;case\"ArithTernary\":return`${Z(e.condition)} ? ${Z(e.consequent)} : ${Z(e.alternate)}`;case\"ArithAssignment\":return`${e.subscript?`${e.variable}[${Z(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${Z(e.value)}`;case\"ArithDynamicAssignment\":return`${e.subscript?`${Z(e.target)}[${Z(e.subscript)}]`:Z(e.target)} ${e.operator} ${Z(e.value)}`;case\"ArithDynamicElement\":return`${Z(e.nameExpr)}[${Z(e.subscript)}]`;case\"ArithGroup\":return`(${Z(e.expression)})`;case\"ArithNested\":return`$((${Z(e.expression)}))`;case\"ArithCommandSubst\":return`$(${e.command})`;case\"ArithBracedExpansion\":return`\\${${e.content}}`;case\"ArithArrayElement\":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${Z(e.index)}]`:e.array;case\"ArithDynamicBase\":return`\\${${e.baseExpr}}#${e.value}`;case\"ArithDynamicNumber\":return`\\${${e.prefix}}${e.suffix}`;case\"ArithConcat\":return e.parts.map(Z).join(\"\");case\"ArithDoubleSubscript\":return`${e.array}[${Z(e.index)}]`;case\"ArithNumberSubscript\":return`${e.number}[${e.errorToken}]`;case\"ArithSyntaxError\":return e.errorToken;case\"ArithSingleQuote\":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function it(e){switch(e.type){case\"CondBinary\":return`${ie(e.left)} ${e.operator} ${ie(e.right)}`;case\"CondUnary\":return`${e.operator} ${ie(e.operand)}`;case\"CondNot\":return`! ${it(e.operand)}`;case\"CondAnd\":return`${it(e.left)} && ${it(e.right)}`;case\"CondOr\":return`${it(e.left)} || ${it(e.right)}`;case\"CondGroup\":return`( ${it(e.expression)} )`;case\"CondWord\":return ie(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var Ft=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let s=t.fs??new ze(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?\"/home/user\":\"/\"),n=new Map([[\"HOME\",this.useDefaultLayout?\"/home/user\":\"/\"],[\"PATH\",\"/usr/bin:/bin\"],[\"IFS\",` \t\n`],[\"OSTYPE\",\"linux-gnu\"],[\"MACHTYPE\",\"x86_64-pc-linux-gnu\"],[\"HOSTTYPE\",\"x86_64\"],[\"HOSTNAME\",\"localhost\"],[\"PWD\",r],[\"OLDPWD\",r],[\"OPTIND\",\"1\"],...Object.entries(t.env??{})]);if(this.limits=Mi({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Ur(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth??!0,this.coverageWriter=t.coverage,this.state={env:n,cwd:r,previousDir:\"/home/user\",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:\"\",startTime:Date.now(),lastBackgroundPid:0,virtualPid:t.processInfo?.pid??1,virtualPpid:t.processInfo?.ppid??0,virtualUid:t.processInfo?.uid??1e3,virtualGid:t.processInfo?.gid??1e3,bashPid:t.processInfo?.pid??1,nextVirtualPid:(t.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set([\"HOME\",\"PATH\",\"PWD\",\"OLDPWD\",...Object.keys(t.env||{})]),readonlyVars:new Set([\"SHELLOPTS\",\"BASHOPTS\"]),hashTable:new Map},this.state.env.set(\"SHELLOPTS\",Zs(this.state.options)),this.state.env.set(\"BASHOPTS\",qs(this.state.shoptOptions)),vn(s,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!==\"/\"&&s instanceof ze)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let o of hn(t.commands))this.registerCommand(o);if(t.fetch||t.network)for(let o of pn())this.registerCommand(o);if(t.python)for(let o of mn())this.registerCommand(o);let i=typeof t.javascript==\"object\"?t.javascript:Object.create(null);if(t.javascript||i.invokeTool){for(let o of yn())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(t.customCommands)for(let o of t.customCommands)gn(o)?this.registerCommand(wn(o)):this.registerCommand({...o,trusted:o.trusted??!0})}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync==\"function\"){let r=`#!/bin/bash\n# Built-in command: ${t.name}\n`;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.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.stdout=Ji(t.stdout),t.stderr=Ji(t.stderr),t}async exec(t,s){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.\n`,exitCode:1,env:ve(this.state.env,s?.env)};if(!t.trim())return{stdout:\"\",stderr:\"\",exitCode:0,env:ve(this.state.env,s?.env)};this.logger?.info(\"exec\",{command:t});let r=s?.cwd??this.state.cwd,n,i=r;if(s?.cwd)if(s.env&&\"PWD\"in s.env)n=s.env.PWD;else if(s?.env&&!(\"PWD\"in s.env))try{n=await this.fs.realpath(r),i=n}catch{n=r}else n=r;let o=s?.replaceEnv?new Map:new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);n!==void 0&&o.set(\"PWD\",n);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:Pl(s?.stdin,s?.stdinKind),signal:s?.signal,extraArgs:s?.args},l=t;s?.rawScript||(l=Qi(t));let c=this.defenseInDepthConfig?me.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let d=fe(l,{maxHeredocSize:this.limits.maxHeredocSize}),p;if(this.transformPlugins.length>0){let g=Object.create(null);for(let b of this.transformPlugins){let m=b.transform({ast:d,metadata:g});d=m.ast,m.metadata&&(g=Ct(g,m.metadata))}p=g}let y={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},E=await new It(y,a).executeScript(d);return p&&(E.metadata=p),this.logResult(E)};return u?await u.run(f):await f()}catch(f){if(f instanceof j)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof Pe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof Je)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:ve(this.state.env,s?.env)});if(f instanceof Ht)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:ve(this.state.env,s?.env)});if(f instanceof J)return this.logResult({stdout:f.stdout,stderr:Le(f.stderr),exitCode:J.EXIT_CODE,env:ve(this.state.env,s?.env)});if(f instanceof Ve)return this.logResult({stdout:\"\",stderr:`bash: security violation: ${Le(f.message)}\n`,exitCode:1,env:ve(this.state.env,s?.env)});if(f.name===\"ParseException\")return this.logResult({stdout:\"\",stderr:`bash: syntax error: ${Le(f.message)}\n`,exitCode:2,env:ve(this.state.env,s?.env)});if(f instanceof Qr)return this.logResult({stdout:\"\",stderr:`bash: ${Le(f.message)}\n`,exitCode:2,env:ve(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:\"\",stderr:`bash: ${Le(f.message)}\n`,exitCode:1,env:ve(this.state.env,s?.env)});throw f}finally{u?.deactivate()}}async readFile(t){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,t))}async writeFile(t,s){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,t),s)}getCwd(){return this.state.cwd}getEnv(){return Ue(this.state.env)}registerTransformPlugin(t){this.transformPlugins.push(t)}transform(t){let s=Qi(t),r=fe(s,{maxHeredocSize:this.limits.maxHeredocSize}),n=Object.create(null);for(let i of this.transformPlugins){let o=i.transform({ast:r,metadata:n});r=o.ast,o.metadata&&(n=Ct(n,o.metadata))}return{script:Lt(r),ast:r,metadata:n}}};function Qi(e){let t=e.split(`\n`),s=[],r=[];for(let n=0;n<t.length;n++){let i=t[n];if(r.length>0){let l=r[r.length-1];if((l.stripTabs?i.replace(/^\\t+/,\"\"):i)===l.delimiter){s.push(i.trimStart()),r.pop();continue}s.push(i);continue}let o=i.trimStart();s.push(o);let a=/<<(-?)\\s*(['\"]?)([\\w-]+)\\2/g;for(let l of o.matchAll(a)){let c=l[1]===\"-\",u=l[3];r.push({delimiter:u,stripTabs:c})}}return s.join(`\n`)}var Sl=new TextDecoder(\"utf-8\",{fatal:!0});function Ji(e){if(!e)return e;let t=!1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>255)return e;n>127&&(t=!0)}if(!t)return e;let s=new Uint8Array(e.length);for(let r=0;r<e.length;r++)s[r]=e.charCodeAt(r);try{return Sl.decode(s)}catch{return e}}function Pl(e,t){if(e!==void 0)return t===\"bytes\"?e:Be(e)}var Cs=class{baseFs;mounts=new Map;constructor(t){if(this.baseFs=t?.base??new ze,t?.mounts)for(let{mountPoint:s,filesystem:r}of t.mounts)this.mount(s,r)}mount(t,s){this.validateMountPath(t);let r=O(t);this.validateMount(r),this.mounts.set(r,{mountPoint:r,filesystem:s})}unmount(t){let s=O(t);if(!this.mounts.has(s))throw new Error(`No filesystem mounted at '${t}'`);this.mounts.delete(s)}getMounts(){return Array.from(this.mounts.values()).map(t=>({mountPoint:t.mountPoint,filesystem:t.filesystem}))}isMountPoint(t){let s=O(t);return this.mounts.has(s)}validateMountPath(t){let s=t.split(\"/\");for(let r of s)if(r===\".\"||r===\"..\")throw new Error(`Invalid mount point '${t}': contains '.' or '..' segments`)}validateMount(t){if(t===\"/\")throw new Error(\"Cannot mount at root '/'\");for(let s of this.mounts.keys())if(s!==t){if(t.startsWith(`${s}/`))throw new Error(`Cannot mount at '${t}': inside existing mount '${s}'`);if(s.startsWith(`${t}/`))throw new Error(`Cannot mount at '${t}': would contain existing mount '${s}'`)}}routePath(t){x(t,\"access\");let s=O(t),r=null,n=0;for(let i of this.mounts.values()){let o=i.mountPoint;if(s===o)return{fs:i.filesystem,relativePath:\"/\"};s.startsWith(`${o}/`)&&o.length>n&&(r=i,n=o.length)}if(r){let i=s.slice(n);return{fs:r.filesystem,relativePath:i||\"/\"}}return{fs:this.baseFs,relativePath:s}}getChildMountPoints(t){let s=O(t),r=s===\"/\"?\"/\":`${s}/`,n=[];for(let i of this.mounts.keys())if(i.startsWith(r)){let a=i.slice(r.length).split(\"/\")[0];a&&!n.includes(a)&&n.push(a)}return n}async readFile(t,s){let{fs:r,relativePath:n}=this.routePath(t);return r.readFile(n,s)}async readFileBytes(t){let{fs:s,relativePath:r}=this.routePath(t);return Vt(s,r)}async readFileBuffer(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readFileBuffer(r)}async writeFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.writeFile(i,s,r)}async appendFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.appendFile(i,s,r)}async exists(t){let s=O(t);if(this.mounts.has(s)||this.getChildMountPoints(s).length>0)return!0;let{fs:n,relativePath:i}=this.routePath(t);return n.exists(i)}async stat(t){let s=O(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.stat(\"/\")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.stat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(t);return i.stat(o)}async lstat(t){let s=O(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.lstat(\"/\")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.lstat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(t);return i.lstat(o)}async mkdir(t,s){let r=O(t);if(this.mounts.has(r)){if(s?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${t}'`)}if(this.getChildMountPoints(r).length>0&&s?.recursive)return;let{fs:i,relativePath:o}=this.routePath(t);return i.mkdir(o,s)}async readdir(t){let s=O(t),r=new Set,n=null,{fs:i,relativePath:o}=this.routePath(t);try{let l=await i.readdir(o);for(let c of l)r.add(c)}catch(l){let c=l.code,u=l.message||\"\";if(c!==\"ENOENT\"&&!u.includes(\"ENOENT\"))throw l;n=l}let a=this.getChildMountPoints(s);for(let l of a)r.add(l);if(r.size===0&&n&&!this.mounts.has(s))throw n;return Array.from(r).sort()}async rm(t,s){let r=O(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot remove '${t}'`);if(this.getChildMountPoints(r).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${t}'`);let{fs:i,relativePath:o}=this.routePath(t);return i.rm(o,s)}async cp(t,s,r){let n=this.routePath(t),i=this.routePath(s);return n.fs===i.fs?n.fs.cp(n.relativePath,i.relativePath,r):this.crossMountCopy(t,s,r)}async mv(t,s){let r=O(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot move '${t}'`);let n=this.routePath(t),i=this.routePath(s);if(n.fs===i.fs)return n.fs.mv(n.relativePath,i.relativePath);await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){return qe(t,s)}getAllPaths(){let t=new Set;for(let s of this.baseFs.getAllPaths())t.add(s);for(let s of this.mounts.keys()){let r=s.split(\"/\").filter(Boolean),n=\"\";for(let o of r)n=`${n}/${o}`,t.add(n);let i=this.mounts.get(s);if(i)for(let o of i.filesystem.getAllPaths())o===\"/\"?t.add(s):t.add(`${s}${o}`)}return Array.from(t).sort()}async chmod(t,s){let r=O(t),n=this.mounts.get(r);if(n)return n.filesystem.chmod(\"/\",s);let{fs:i,relativePath:o}=this.routePath(t);return i.chmod(o,s)}async symlink(t,s){let{fs:r,relativePath:n}=this.routePath(s);return r.symlink(t,n)}async link(t,s){let r=this.routePath(t),n=this.routePath(s);if(r.fs!==n.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${t}' -> '${s}'`);return r.fs.link(r.relativePath,n.relativePath)}async readlink(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readlink(r)}async realpath(t){let s=O(t);if(this.mounts.get(s))return s;let{fs:n,relativePath:i}=this.routePath(t),o=await n.realpath(i);for(let[a,l]of this.mounts)if(s===a||s.startsWith(`${a}/`))return o===\"/\"?a:`${a}${o}`;return o}async crossMountCopy(t,s,r){let n=await this.lstat(t);if(n.isFile){let i=await this.readFileBuffer(t);await this.writeFile(s,i),await this.chmod(s,n.mode)}else if(n.isDirectory){if(!r?.recursive)throw new Error(`cp: ${t} is a directory (not copied)`);await this.mkdir(s,{recursive:!0});let i=await this.readdir(t);for(let o of i){let a=Ge(t,o),l=Ge(s,o);await this.crossMountCopy(a,l,r)}}else if(n.isSymbolicLink){let i=await this.readlink(t);await this.symlink(i,s)}}async utimes(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.utimes(i,s,r)}};import*as q from\"node:fs\";import*as ae from\"node:path\";import*as Se from\"node:fs\";import*as ce from\"node:path\";function Ne(e,t){if(e===t)return!0;let s=e[t.length];return(s===\"/\"||s===\"\\\\\")&&e.startsWith(t)}function at(e,t){try{let s=Se.realpathSync(e);return Ne(s,t)?s:null}catch(s){if(s.code===\"ENOENT\"){let r=ce.dirname(e);if(r===e)return null;let n=at(r,t);if(n===null)return null;try{if(Se.lstatSync(e).isSymbolicLink()){let o=Se.readlinkSync(e),a=ce.isAbsolute(o)?o:ce.resolve(ce.dirname(e),o);if(at(a,t)===null)return null}}catch{}return ce.join(n,ce.basename(e))}return null}}function Ns(e,t,s){let r=at(e,s);if(r===null)return null;let n=ce.resolve(e),i=n.slice(t.length),o=r.slice(s.length);if(i!==o)return null;try{if(Se.lstatSync(n).isSymbolicLink())return null}catch{}return r}function Os(e,t){if(!Se.existsSync(e))throw new Error(`${t} root does not exist`);if(!Se.statSync(e).isDirectory())throw new Error(`${t} root is not a directory`)}function eo(e,t){if(!ce.isAbsolute(e))return{withinRoot:!0,relativePath:e};let s;try{s=Se.realpathSync(e)}catch{s=ce.resolve(e)}return Ne(s,t)?{withinRoot:!0,relativePath:s.slice(t.length).replace(/\\\\/g,\"/\")||\"/\"}:{withinRoot:!1,safeName:ce.basename(e)}}function xs(e,t,s,r){let n=e;if(n.path===void 0){for(let o of r)if(n.message?.includes(o))throw e}let i=n.code||\"EIO\";throw new Error(`${i}: ${s} '${t}'`)}var Al=[\"ELOOP\",\"EFBIG\",\"EPERM\"],kl=\"/home/user/project\",$t=class{root;canonicalRoot;mountPoint;readOnly;maxFileReadSize;allowSymlinks;memory=new Map;deleted=new Set;constructor(t){this.root=ae.resolve(t.root);let s=t.mountPoint??kl;if(this.mountPoint=s===\"/\"?\"/\":s.replace(/\\/+$/,\"\"),!this.mountPoint.startsWith(\"/\"))throw new Error(`Mount point must be an absolute path: ${s}`);this.readOnly=t.readOnly??!1,this.maxFileReadSize=t.maxFileReadSize??10485760,this.allowSymlinks=t.allowSymlinks??!1,Os(this.root,\"OverlayFs\"),this.canonicalRoot=q.realpathSync(this.root),this.createMountPointDirs()}assertWritable(t){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${t}`)}createMountPointDirs(){let t=this.mountPoint.split(\"/\").filter(Boolean),s=\"\";for(let r of t)s+=`/${r}`,this.memory.has(s)||this.memory.set(s,{type:\"directory\",mode:493,mtime:new Date});this.memory.has(\"/\")||this.memory.set(\"/\",{type:\"directory\",mode:493,mtime:new Date})}getMountPoint(){return this.mountPoint}mkdirSync(t,s){let n=O(t).split(\"/\").filter(Boolean),i=\"\";for(let o of n)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:\"directory\",mode:493,mtime:new Date})}writeFileSync(t,s){let r=O(t),n=this.getDirname(r);n!==\"/\"&&this.mkdirSync(n);let i=s instanceof Uint8Array?s:new TextEncoder().encode(s);this.memory.set(r,{type:\"file\",content:i,mode:420,mtime:new Date})}getDirname(t){let s=t.lastIndexOf(\"/\");return s===0?\"/\":t.slice(0,s)}getRelativeToMount(t){return this.mountPoint===\"/\"?t:t===this.mountPoint?\"/\":t.startsWith(`${this.mountPoint}/`)?t.slice(this.mountPoint.length):null}toRealPath(t){let s=O(t),r=this.getRelativeToMount(s);if(r===null)return null;let n=ae.join(this.root,r),i=ae.resolve(n);return Ne(i,this.root)?i:null}resolveRealPath_(t){return t?this.allowSymlinks?at(t,this.canonicalRoot):Ns(t,this.root,this.canonicalRoot):null}resolveRealPathParent_(t){if(!t)return null;let s=ae.dirname(t),r=this.resolveRealPath_(s);return r===null?null:ae.join(r,ae.basename(t))}sanitizeError(t,s,r){xs(t,s,r,Al)}ensureParentDirs(t){let s=st(t);s!==\"/\"&&(this.memory.has(s)||(this.ensureParentDirs(s),this.memory.set(s,{type:\"directory\",mode:493,mtime:new Date})),this.deleted.delete(s))}async existsInOverlay(t){let s=O(t);if(this.deleted.has(s))return!1;if(this.memory.has(s))return!0;let r=this.resolveRealPathParent_(this.toRealPath(s));if(!r)return!1;try{return await q.promises.lstat(r),!0}catch{return!1}}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,\"binary\")}async readFileBuffer(t,s=new Set){x(t,\"open\");let r=O(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let n=this.memory.get(r);if(n){if(n.type===\"symlink\"){let o=this.resolveSymlink(r,n.target);return this.readFileBuffer(o,s)}if(n.type!==\"file\")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let o=await q.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, open '${t}'`);let c=await q.promises.readlink(i),u=this.realTargetToVirtual(r,c),f=this.resolveSymlink(r,u);return this.readFileBuffer(f,s)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${o.size} bytes, max ${this.maxFileReadSize})`);let a=this.allowSymlinks?q.constants.O_RDONLY:q.constants.O_RDONLY|q.constants.O_NOFOLLOW,l=await q.promises.open(i,a);try{let c=await l.readFile();return new Uint8Array(c)}finally{await l.close()}}catch(o){let a=o.code;if(a===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(a===\"ELOOP\")throw new Error(`ENOENT: no such file or directory, open '${t}'`);this.sanitizeError(o,t,\"open\")}}async writeFile(t,s,r){x(t,\"write\"),this.assertWritable(`write '${t}'`);let n=O(t);this.ensureParentDirs(n);let i=be(r),o=Fe(s,i);this.memory.set(n,{type:\"file\",content:o,mode:420,mtime:new Date}),this.deleted.delete(n)}async appendFile(t,s,r){x(t,\"append\"),this.assertWritable(`append '${t}'`);let n=O(t),i=be(r),o=Fe(s,i),a;try{a=await this.readFileBuffer(n)}catch{a=new Uint8Array(0)}let l=new Uint8Array(a.length+o.length);l.set(a),l.set(o,a.length),this.ensureParentDirs(n),this.memory.set(n,{type:\"file\",content:l,mode:420,mtime:new Date}),this.deleted.delete(n)}async exists(t){return t.includes(\"\\0\")?!1:this.existsInOverlay(t)}async stat(t,s=new Set){x(t,\"stat\");let r=O(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, stat '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=this.memory.get(r);if(n){if(n.type===\"symlink\"){let a=this.resolveSymlink(r,n.target);return this.stat(a,s)}let o=0;return n.type===\"file\"&&(o=n.content.length),{isFile:n.type===\"file\",isDirectory:n.type===\"directory\",isSymbolicLink:!1,mode:n.mode,size:o,mtime:n.mtime}}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);try{let o=await q.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let a=await q.promises.readlink(i),l=this.realTargetToVirtual(r,a),c=this.resolveSymlink(r,l);return this.stat(c,s)}return{isFile:o.isFile(),isDirectory:o.isDirectory(),isSymbolicLink:!1,mode:o.mode,size:o.size,mtime:o.mtime}}catch(o){if(o.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, stat '${t}'`);this.sanitizeError(o,t,\"stat\")}}async lstat(t){x(t,\"lstat\");let s=O(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);let r=this.memory.get(s);if(r){if(r.type===\"symlink\")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime};let i=0;return r.type===\"file\"&&(i=r.content.length),{isFile:r.type===\"file\",isDirectory:r.type===\"directory\",isSymbolicLink:!1,mode:r.mode,size:i,mtime:r.mtime}}let n=this.resolveRealPathParent_(this.toRealPath(s));if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);try{let i=await q.promises.lstat(n);return{isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink(),mode:i.mode,size:i.size,mtime:i.mtime}}catch(i){if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);this.sanitizeError(i,t,\"lstat\")}}resolveSymlink(t,s){return ct(t,s)}realTargetToVirtual(t,s){let r=eo(s,this.canonicalRoot);if(r.withinRoot){if(!ae.isAbsolute(s))return s;let n=r.relativePath;return this.mountPoint===\"/\"?n:`${this.mountPoint}${n}`}return r.safeName}async mkdir(t,s){x(t,\"mkdir\"),this.assertWritable(`mkdir '${t}'`);let r=O(t);if(await this.existsInOverlay(r)){if(!s?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${t}'`);return}let i=st(r);if(i!==\"/\"&&!await this.existsInOverlay(i))if(s?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.memory.set(r,{type:\"directory\",mode:493,mtime:new Date}),this.deleted.delete(r)}async readdirCore(t,s){if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Map,n=new Set,i=s===\"/\"?\"/\":`${s}/`;for(let a of this.deleted)if(a.startsWith(i)){let l=a.slice(i.length),c=l.split(\"/\")[0];c&&!l.includes(\"/\",c.length)&&n.add(c)}for(let[a,l]of this.memory)if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split(\"/\")[0];u&&!n.has(u)&&!c.includes(\"/\",1)&&r.set(u,{name:u,isFile:l.type===\"file\",isDirectory:l.type===\"directory\",isSymbolicLink:l.type===\"symlink\"})}let o=this.resolveRealPath_(this.toRealPath(s));if(o)try{if(!this.allowSymlinks&&(await q.promises.lstat(o)).isSymbolicLink()){if(!this.memory.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);return r}let a=await q.promises.readdir(o,{withFileTypes:!0});for(let l of a)!n.has(l.name)&&!r.has(l.name)&&r.set(l.name,{name:l.name,isFile:l.isFile(),isDirectory:l.isDirectory(),isSymbolicLink:l.isSymbolicLink()})}catch(a){if(a.code===\"ENOENT\"){if(!this.memory.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`)}else a.code!==\"ENOTDIR\"&&this.sanitizeError(a,t,\"scandir\")}return r}async resolveForReaddir(t,s=!1){let r=O(t),n=new Set,i=s,o=this.memory.get(r);for(;o&&o.type===\"symlink\";){if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(r),i=!0,r=this.resolveSymlink(r,o.target),o=this.memory.get(r)}if(o)return{normalized:r,outsideOverlay:!1};if(this.getRelativeToMount(r)===null)return{normalized:r,outsideOverlay:!0};let l=this.resolveRealPath_(this.toRealPath(r));if(!l)return{normalized:r,outsideOverlay:!0};try{if((await q.promises.lstat(l)).isSymbolicLink()){if(!this.allowSymlinks)return{normalized:r,outsideOverlay:!0};let u=await q.promises.readlink(l),f=this.realTargetToVirtual(r,u),d=this.resolveSymlink(r,f);return this.resolveForReaddir(d,!0)}return{normalized:r,outsideOverlay:!1}}catch{return i?{normalized:r,outsideOverlay:!0}:{normalized:r,outsideOverlay:!1}}}async readdir(t){x(t,\"scandir\");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.keys()).sort((i,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(t){x(t,\"scandir\");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.values()).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(t,s){x(t,\"rm\"),this.assertWritable(`rm '${t}'`);let r=O(t);if(!await this.existsInOverlay(r)){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}try{if((await this.stat(r)).isDirectory){let o=await this.readdir(r);if(o.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let a of o){let l=r===\"/\"?`/${a}`:`${r}/${a}`;await this.rm(l,s)}}}}catch(i){if(i instanceof Error&&(i.message.includes(\"ENOTEMPTY\")||i.message.includes(\"EISDIR\")))throw i}this.memory.delete(r),this.existsOnRealFs(r)&&this.deleted.add(r)}existsOnRealFs(t){let s=this.toRealPath(t),r=this.resolveRealPathParent_(s);if(!r)return!1;try{return q.lstatSync(r),!0}catch{return!1}}async cp(t,s,r){x(t,\"cp\"),x(s,\"cp\"),this.assertWritable(`cp '${s}'`);let n=O(t),i=O(s);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, cp '${t}'`);let a=await this.stat(n);if(a.isFile){let l=await this.readFileBuffer(n);await this.writeFile(i,l)}else if(a.isDirectory){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(n);for(let c of l){let u=n===\"/\"?`/${c}`:`${n}/${c}`,f=i===\"/\"?`/${c}`:`${i}/${c}`;await this.cp(u,f,r)}}}async mv(t,s){this.assertWritable(`mv '${s}'`),await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){return qe(t,s)}getAllPaths(){let t=new Set(this.memory.keys());for(let s of this.deleted)t.delete(s);return this.scanRealFs(\"/\",t),Array.from(t)}scanRealFs(t,s){if(this.deleted.has(t))return;let r=this.resolveRealPath_(this.toRealPath(t));if(r)try{let n=q.readdirSync(r);for(let i of n){let o=t===\"/\"?`/${i}`:`${t}/${i}`;if(this.deleted.has(o))continue;s.add(o);let a=ae.join(r,i);q.lstatSync(a).isDirectory()&&this.scanRealFs(o,s)}}catch{}}async chmod(t,s){x(t,\"chmod\"),this.assertWritable(`chmod '${t}'`);let r=O(t);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);let i=this.memory.get(r);if(i){i.mode=s;return}let o=await this.stat(r);if(o.isFile){let a=await this.readFileBuffer(r);this.memory.set(r,{type:\"file\",content:a,mode:s,mtime:new Date})}else o.isDirectory&&this.memory.set(r,{type:\"directory\",mode:s,mtime:new Date})}async symlink(t,s){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${s}'`);x(s,\"symlink\"),this.assertWritable(`symlink '${s}'`);let r=O(s);if(await this.existsInOverlay(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.memory.set(r,{type:\"symlink\",target:t,mode:511,mtime:new Date}),this.deleted.delete(r)}async link(t,s){x(t,\"link\"),x(s,\"link\"),this.assertWritable(`link '${s}'`);let r=O(t),n=O(s);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, link '${t}'`);let o=await this.stat(r);if(!o.isFile)throw new Error(`EPERM: operation not permitted, link '${t}'`);if(await this.existsInOverlay(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let l=await this.readFileBuffer(r);this.ensureParentDirs(n),this.memory.set(n,{type:\"file\",content:l,mode:o.mode,mtime:new Date}),this.deleted.delete(n)}async readlink(t){x(t,\"readlink\");let s=O(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);let r=this.memory.get(s);if(r){if(r.type!==\"symlink\")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}let n=this.resolveRealPathParent_(this.toRealPath(s));if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);try{let i=await q.promises.readlink(n);if(!ae.isAbsolute(i)){let o=ae.resolve(ae.dirname(n),i),a;try{a=q.realpathSync(o)}catch{a=o}if(!Ne(a,this.canonicalRoot))return ae.basename(i)}return this.realTargetToVirtual(s,i)}catch(i){if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(i.code===\"EINVAL\")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);this.sanitizeError(i,t,\"readlink\")}}async realpath(t){x(t,\"realpath\");let s=O(t),r=new Set,n=async a=>{let l=a===\"/\"?[]:a.slice(1).split(\"/\"),c=\"\";for(let u of l){if(c=`${c}/${u}`,r.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);let f=this.memory.get(c),d=0,p=40;for(;f&&f.type===\"symlink\"&&d<p;){if(r.add(c),c=this.resolveSymlink(c,f.target),d++,r.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);f=this.memory.get(c)}if(d>=p)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(!f){let y=this.toRealPath(c),h=this.resolveRealPath_(y);if(h)try{if((await q.promises.lstat(h)).isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);let E=await q.promises.readlink(h),g=this.realTargetToVirtual(c,E);return r.add(c),c=this.resolveSymlink(c,g),n(c)}}catch(w){if(w.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);this.sanitizeError(w,t,\"realpath\")}else if(!this.allowSymlinks){let w=this.resolveRealPathParent_(y);if(w)try{if((await q.promises.lstat(w)).isSymbolicLink())throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}catch(E){if(E.message?.includes(\"ENOENT\")||E.message?.includes(\"ELOOP\"))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);this.sanitizeError(E,t,\"realpath\")}}}}return c||\"/\"},i=await n(s);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return i}async utimes(t,s,r){x(t,\"utimes\"),this.assertWritable(`utimes '${t}'`);let n=O(t);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);let o=this.memory.get(n);if(o){o.mtime=r;return}let a=await this.stat(n);if(a.isFile){let l=await this.readFileBuffer(n);this.memory.set(n,{type:\"file\",content:l,mode:a.mode,mtime:r})}else a.isDirectory&&this.memory.set(n,{type:\"directory\",mode:a.mode,mtime:r})}};import*as I from\"node:fs\";import*as U from\"node:path\";var _l=[\"EACCES\",\"escaping sandbox\",\"EFBIG\"],Ts=class{root;canonicalRoot;maxFileReadSize;allowSymlinks;constructor(t){this.root=U.resolve(t.root),this.maxFileReadSize=t.maxFileReadSize??10485760,this.allowSymlinks=t.allowSymlinks??!1,Os(this.root,\"ReadWriteFs\"),this.canonicalRoot=I.realpathSync(this.root)}resolveAndValidate(t,s){let r=this.allowSymlinks?at(t,this.canonicalRoot):Ns(t,this.root,this.canonicalRoot);if(r===null)throw new Error(`EACCES: permission denied, '${s}' resolves outside sandbox`);return r}validateParent(t,s){let r=U.dirname(t),n=this.resolveAndValidate(r,s);return U.join(n,U.basename(t))}toRealPath(t){let s=O(t),r=U.join(this.root,s);return U.resolve(r)}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,\"binary\")}async readFileBuffer(t){x(t,\"open\");let s=this.toRealPath(t),r=this.resolveAndValidate(s,t);try{let n=this.allowSymlinks?I.constants.O_RDONLY:I.constants.O_RDONLY|I.constants.O_NOFOLLOW,i=await I.promises.open(r,n);try{if(this.maxFileReadSize>0){let a=await i.stat();if(a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${a.size} bytes, max ${this.maxFileReadSize})`)}let o=await i.readFile();return new Uint8Array(o)}finally{await i.close()}}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(i.code===\"EISDIR\")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(i.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(n,t,\"open\")}}async writeFile(t,s,r){x(t,\"write\");let n=this.toRealPath(t),i=this.resolveAndValidate(n,t),o=be(r),a=Fe(s,o),l=U.dirname(i);try{await I.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(n,t);let c=this.allowSymlinks?0:I.constants.O_NOFOLLOW,u=I.constants.O_WRONLY|I.constants.O_CREAT|I.constants.O_TRUNC|c,f=await I.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(c,t,\"write\")}}async appendFile(t,s,r){x(t,\"append\");let n=this.toRealPath(t),i=this.resolveAndValidate(n,t),o=be(r),a=Fe(s,o),l=U.dirname(i);try{await I.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(n,t);let c=this.allowSymlinks?0:I.constants.O_NOFOLLOW,u=I.constants.O_WRONLY|I.constants.O_CREAT|I.constants.O_APPEND|c,f=await I.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(c,t,\"append\")}}async exists(t){if(t.includes(\"\\0\"))return!1;let s=this.toRealPath(t);try{let r=this.resolveAndValidate(s,t);return await I.promises.access(r),!0}catch{return!1}}async stat(t){x(t,\"stat\");let s=this.toRealPath(t),r=this.resolveAndValidate(s,t);try{let n=await I.promises.lstat(r);if(!this.allowSymlinks&&n.isSymbolicLink())throw new Error(`EACCES: permission denied, '${t}' is a symlink`);return{isFile:n.isFile(),isDirectory:n.isDirectory(),isSymbolicLink:n.isSymbolicLink(),mode:n.mode,size:n.size,mtime:n.mtime}}catch(n){if(n.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, stat '${t}'`);this.sanitizeError(n,t,\"stat\")}}async lstat(t){x(t,\"lstat\");let s=this.toRealPath(t),r=this.validateParent(s,t);try{let n=await I.promises.lstat(r);return{isFile:n.isFile(),isDirectory:n.isDirectory(),isSymbolicLink:n.isSymbolicLink(),mode:n.mode,size:n.size,mtime:n.mtime}}catch(n){if(n.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);this.sanitizeError(n,t,\"lstat\")}}async mkdir(t,s){x(t,\"mkdir\");let r=this.toRealPath(t),n=this.resolveAndValidate(r,t);try{await I.promises.mkdir(n,{recursive:s?.recursive})}catch(i){let o=i;if(o.code===\"EEXIST\")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(o.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.sanitizeError(i,t,\"mkdir\")}}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){x(t,\"scandir\");let s=this.toRealPath(t),r=this.resolveAndValidate(s,t);try{if(!this.allowSymlinks&&(await I.promises.lstat(r)).isSymbolicLink())throw new Error(`EACCES: permission denied, '${t}' is a symlink`);return(await I.promises.readdir(r,{withFileTypes:!0})).map(i=>({name:i.name,isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink()})).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(i.code===\"ENOTDIR\")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);this.sanitizeError(n,t,\"scandir\")}}async rm(t,s){x(t,\"rm\");let r=this.toRealPath(t),n=this.resolveAndValidate(r,t);try{await I.promises.rm(n,{recursive:s?.recursive??!1,force:s?.force??!1})}catch(i){let o=i;if(o.code===\"ENOENT\"&&!s?.force)throw new Error(`ENOENT: no such file or directory, rm '${t}'`);if(o.code===\"ENOTEMPTY\")throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);this.sanitizeError(i,t,\"rm\")}}async cp(t,s,r){x(t,\"cp\"),x(s,\"cp\");let n=this.toRealPath(t),i=this.toRealPath(s),o=this.resolveAndValidate(n,t),a=this.resolveAndValidate(i,s);try{await I.promises.cp(o,a,{recursive:r?.recursive??!1,filter:async l=>{try{if(I.lstatSync(l).isSymbolicLink()){let u=await I.promises.realpath(l).catch(()=>null);return u===null?!1:Ne(u,this.canonicalRoot)}return!0}catch(c){return c.code===\"ENOENT\"}}})}catch(l){let c=l;if(c.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(c.code===\"EISDIR\")throw new Error(`EISDIR: is a directory, cp '${t}'`);this.sanitizeError(l,t,\"cp\")}}async mv(t,s){x(t,\"mv\"),x(s,\"mv\");let r=this.toRealPath(t),n=this.toRealPath(s),i=this.validateParent(r,t),o=this.validateParent(n,s);try{if((await I.promises.lstat(i)).isSymbolicLink()){let c=await I.promises.readlink(i),u=U.resolve(U.dirname(o),c),f=await I.promises.realpath(u).catch(()=>u);if(!Ne(f,this.canonicalRoot))throw new Error(`EACCES: permission denied, mv '${t}' -> '${s}' would create symlink escaping sandbox`)}}catch(l){let c=l;if(c.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, mv '${t}'`);if(c.message?.includes(\"EACCES\")||c.message?.includes(\"escaping sandbox\"))throw l}let a=U.dirname(o);try{await I.promises.mkdir(a,{recursive:!0})}catch(l){this.sanitizeError(l,s,\"mv\")}try{await I.promises.rename(i,o)}catch(l){let c=l;if(c.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, mv '${t}'`);if(c.code===\"EXDEV\"){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0});return}this.sanitizeError(l,t,\"mv\")}try{if(I.lstatSync(o).isDirectory()&&this.findEscapingSymlinks(o).length>0)throw await I.promises.rename(o,i),new Error(`EACCES: permission denied, mv '${t}' -> '${s}' would create symlinks escaping sandbox`)}catch(l){if(l.message?.includes(\"EACCES\")||l.message?.includes(\"escaping sandbox\"))throw l}}resolvePath(t,s){return qe(t,s)}getAllPaths(){let t=[];return this.scanDir(\"/\",t),t}sanitizeError(t,s,r){xs(t,s,r,_l)}findEscapingSymlinks(t){let s=[];try{let r=I.readdirSync(t);for(let n of r){let i=U.join(t,n);try{let o=I.lstatSync(i);if(o.isSymbolicLink()){let a=I.readlinkSync(i),l=U.resolve(t,a),c;try{c=I.realpathSync(l)}catch{c=l}Ne(c,this.canonicalRoot)||s.push(i)}else o.isDirectory()&&s.push(...this.findEscapingSymlinks(i))}catch{}}}catch{}return s}scanDir(t,s){let r=this.toRealPath(t),n;try{n=this.resolveAndValidate(r,t)}catch{return}try{let i=I.readdirSync(n);for(let o of i){let a=t===\"/\"?`/${o}`:`${t}/${o}`;s.push(a);let l=U.join(n,o);I.lstatSync(l).isDirectory()&&this.scanDir(a,s)}}catch{}}async chmod(t,s){x(t,\"chmod\");let r=this.toRealPath(t),n=this.resolveAndValidate(r,t);try{let i=this.allowSymlinks?I.constants.O_RDONLY:I.constants.O_RDONLY|I.constants.O_NOFOLLOW,o=await I.promises.open(n,i);try{await o.chmod(s)}finally{await o.close()}}catch(i){let o=i;if(o.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);if(o.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(i,t,\"chmod\")}}async symlink(t,s){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${s}'`);x(s,\"symlink\");let r=this.toRealPath(s),n=this.validateParent(r,s),i=O(s),o=O(U.dirname(i)),a=t.startsWith(\"/\")?O(t):O(o===\"/\"?`/${t}`:`${o}/${t}`),l=U.join(this.canonicalRoot,a),c=U.dirname(n),u=t.startsWith(\"/\")?l:U.relative(c,l)||\".\";try{await I.promises.symlink(u,n)}catch(f){if(f.code===\"EEXIST\")throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.sanitizeError(f,s,\"symlink\")}}async link(t,s){x(t,\"link\"),x(s,\"link\");let r=this.toRealPath(t),n=this.toRealPath(s),i=this.resolveAndValidate(r,t),o=this.resolveAndValidate(n,s);try{await I.promises.link(i,o)}catch(a){let l=a;if(l.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(l.code===\"EEXIST\")throw new Error(`EEXIST: file already exists, link '${s}'`);if(l.code===\"EPERM\")throw new Error(`EPERM: operation not permitted, link '${t}'`);this.sanitizeError(a,t,\"link\")}}async readlink(t){x(t,\"readlink\");let s=this.toRealPath(t),r=this.validateParent(s,t);try{let n=await I.promises.readlink(r),i=O(t),o=U.dirname(i),a=U.isAbsolute(n)?n:U.resolve(U.dirname(r),n),l=await I.promises.realpath(a).catch(()=>a);if(Ne(l,this.canonicalRoot)){let c=l.slice(this.canonicalRoot.length)||\"/\";return o===\"/\"?c.startsWith(\"/\")?c.slice(1)||\".\":c:U.relative(o,c)}return U.basename(n)}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(i.code===\"EINVAL\")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);this.sanitizeError(n,t,\"readlink\")}}async realpath(t){x(t,\"realpath\");let s=this.toRealPath(t);try{this.resolveAndValidate(s,t)}catch{throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}let r;try{r=await I.promises.realpath(s)}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);if(i.code===\"ELOOP\")throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);this.sanitizeError(n,t,\"realpath\")}if(Ne(r,this.canonicalRoot))return r.slice(this.canonicalRoot.length)||\"/\";throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}async utimes(t,s,r){x(t,\"utimes\");let n=this.toRealPath(t),i=this.resolveAndValidate(n,t);try{let o=this.allowSymlinks?I.constants.O_RDONLY:I.constants.O_RDONLY|I.constants.O_NOFOLLOW,a=await I.promises.open(i,o);try{await a.utimes(s,r)}finally{await a.close()}}catch(o){let a=o;if(a.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);if(a.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(o,t,\"utimes\")}}};var St=class{cmdId;cwd;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;signal;timeoutMs;abortController=new AbortController;timeoutId;externalAbortListener;resultPromise;constructor(t,s,r,n,i=!1,o,a){this.cmdId=crypto.randomUUID(),this.cwd=r,this.startedAt=new Date,this.bashEnv=t,this.cmdLine=s,this.env=n,this.explicitCwd=i,this.signal=o,this.timeoutMs=a,this.setupCancellation(),this.resultPromise=this.execute()}setupCancellation(){if(this.signal&&(this.signal.aborted?this.abortController.abort(this.signal.reason):(this.externalAbortListener=()=>{this.abortController.abort(this.signal?.reason)},this.signal.addEventListener(\"abort\",this.externalAbortListener,{once:!0}))),this.timeoutMs!==void 0){let t=Math.max(0,this.timeoutMs);this.timeoutId=Mt(()=>{this.abortController.abort(new Error(`sandbox command timeout after ${t}ms`))},t)}}cleanupCancellation(){this.timeoutId!==void 0&&(Wt(this.timeoutId),this.timeoutId=void 0),this.signal&&this.externalAbortListener&&(this.signal.removeEventListener(\"abort\",this.externalAbortListener),this.externalAbortListener=void 0)}async execute(){let t={cwd:this.explicitCwd?this.cwd:void 0,env:this.env,signal:this.abortController.signal};try{let s=await this.bashEnv.exec(this.cmdLine,t);return this.exitCode=s.exitCode,s}finally{this.cleanupCancellation()}}async*logs(){let t=await this.resultPromise;t.stdout&&(yield{type:\"stdout\",data:t.stdout,timestamp:new Date}),t.stderr&&(yield{type:\"stderr\",data:t.stderr,timestamp:new Date})}async wait(){return await this.resultPromise,this}async output(){let t=await this.resultPromise;return t.stdout+t.stderr}async stdout(){return(await this.resultPromise).stdout}async stderr(){return(await this.resultPromise).stderr}async kill(){this.abortController.abort(new Error(\"command killed\"))}};var Ds=class e{bashEnv;timeoutMs;constructor(t,s){this.bashEnv=t,this.timeoutMs=s}static async create(t){let s=t?.fs;if(t?.overlayRoot){if(t?.fs)throw new Error(\"Cannot specify both 'fs' and 'overlayRoot' options\");s=new $t({root:t.overlayRoot})}let r=new Ft({env:t?.env,cwd:t?.cwd,fs:s,maxCallDepth:t?.maxCallDepth,maxCommandCount:t?.maxCommandCount,maxLoopIterations:t?.maxLoopIterations,network:t?.network,defenseInDepth:t?.defenseInDepth});return new e(r,t?.timeoutMs)}async runCommand(t,s,r){let n,i,o,a,l=!1,c,u;if(typeof t==\"object\"){let h=t,w=[h.cmd,...h.args??[]];n=Ls(w),i=h.cwd,o=h.env,a=h.signal,l=h.detached??!1,c=h.stdout,u=h.stderr}else if(Array.isArray(s)){let h=r;n=Ls([t,...s]),a=h?.signal}else{n=t;let h=s;i=h?.cwd,o=h?.env}let f=i??this.bashEnv.getCwd(),d=i!==void 0,p=new St(this.bashEnv,n,f,o,d,a,this.timeoutMs);if(l)return p;let y=await p.wait();if(c){let h=await p.stdout();h&&c.write(h)}if(u){let h=await p.stderr();h&&u.write(h)}return y}async writeFiles(t){let s=this.bashEnv.getCwd();for(let[r,n]of Object.entries(t)){let i;typeof n==\"string\"?i=n:n.encoding===\"base64\"?i=Buffer.from(n.content,\"base64\").toString(\"utf-8\"):i=n.content;let o=this.bashEnv.fs.resolvePath(s,r),a=o.substring(0,o.lastIndexOf(\"/\"))||\"/\";a!==\"/\"&&await this.bashEnv.fs.mkdir(a,{recursive:!0}),await this.bashEnv.writeFile(o,i)}}async readFile(t,s){let r=await this.bashEnv.readFile(t);return s===\"base64\"?Buffer.from(r).toString(\"base64\"):r}async mkDir(t,s){let r=this.bashEnv.fs.resolvePath(this.bashEnv.getCwd(),t);await this.bashEnv.fs.mkdir(r,{recursive:s?.recursive??!1})}async stop(){}async extendTimeout(t){}get domain(){}get bashEnvInstance(){return this.bashEnv}};var Rs=class{violations=[];violationsByType=new Map;options;constructor(t={}){this.options={maxViolationsPerType:t.maxViolationsPerType??100,maxViolationsTotal:t.maxViolationsTotal??1e3,includeStackTraces:t.includeStackTraces??!0,onViolation:t.onViolation??(()=>{}),logToConsole:t.logToConsole??!1}}record(t){let s=this.options.includeStackTraces?t:{...t,stack:void 0};this.violations.unshift(s),this.violations.length>this.options.maxViolationsTotal&&(this.violations.length=this.options.maxViolationsTotal);let r=this.violationsByType.get(t.type);r||(r=[],this.violationsByType.set(t.type,r)),r.length<this.options.maxViolationsPerType&&r.push(s),this.options.logToConsole&&console.warn(`[SecurityViolation] ${t.type}: ${t.message}`,t.path),this.options.onViolation(s)}getViolations(){return[...this.violations]}getViolationsByType(t){return[...this.violationsByType.get(t)??[]]}getSummary(){let t=[];for(let[s,r]of this.violationsByType){if(r.length===0)continue;let n=new Set,i=Number.POSITIVE_INFINITY,o=0;for(let a of r)n.add(a.path),i=Math.min(i,a.timestamp),o=Math.max(o,a.timestamp);t.push({type:s,count:r.length,firstSeen:i,lastSeen:o,paths:Array.from(n)})}return t.sort((s,r)=>r.count-s.count),t}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return t=>this.record(t)}};function to(){return e=>{console.warn(\"[DefenseInDepth] Security violation detected:\",`\n Type: ${e.type}`,`\n Path: ${e.path}`,`\n Message: ${e.message}`,e.executionId?`\n ExecutionId: ${e.executionId}`:\"\")}}var Hr=class{plugins=[];use(t){return this.plugins.push(t),this}transform(t){let s=fe(t),r=Object.create(null);for(let n of this.plugins){let i=n.transform({ast:s,metadata:r});s=i.ast,i.metadata&&(r=Ct(r,i.metadata))}return{script:Lt(s),ast:s,metadata:r}}};var Zr=class{name=\"command-collector\";transform(t){let s=new Set;return this.walkScript(t.ast,s),{ast:t.ast,metadata:{commands:[...s].sort()}}}walkScript(t,s){for(let r of t.statements)this.walkStatement(r,s)}walkStatement(t,s){for(let r of t.pipelines)this.walkPipeline(r,s)}walkPipeline(t,s){for(let r of t.commands)this.walkCommand(r,s)}walkCommand(t,s){switch(t.type){case\"SimpleCommand\":if(t.name){let r=this.extractName(t.name);r&&s.add(r)}t.name&&this.walkWordParts(t.name.parts,s);for(let r of t.args)this.walkWordParts(r.parts,s);for(let r of t.assignments)if(r.value&&this.walkWordParts(r.value.parts,s),r.array)for(let n of r.array)this.walkWordParts(n.parts,s);break;case\"If\":for(let r of t.clauses){for(let n of r.condition)this.walkStatement(n,s);for(let n of r.body)this.walkStatement(n,s)}if(t.elseBody)for(let r of t.elseBody)this.walkStatement(r,s);break;case\"For\":if(t.words)for(let r of t.words)this.walkWordParts(r.parts,s);for(let r of t.body)this.walkStatement(r,s);break;case\"CStyleFor\":for(let r of t.body)this.walkStatement(r,s);break;case\"While\":case\"Until\":for(let r of t.condition)this.walkStatement(r,s);for(let r of t.body)this.walkStatement(r,s);break;case\"Case\":this.walkWordParts(t.word.parts,s);for(let r of t.items)for(let n of r.body)this.walkStatement(n,s);break;case\"Subshell\":case\"Group\":for(let r of t.body)this.walkStatement(r,s);break;case\"ArithmeticCommand\":case\"ConditionalCommand\":break;case\"FunctionDef\":this.walkCommand(t.body,s);break}}walkWordParts(t,s){for(let r of t)switch(r.type){case\"CommandSubstitution\":this.walkScript(r.body,s);break;case\"ProcessSubstitution\":this.walkScript(r.body,s);break;case\"DoubleQuoted\":this.walkWordParts(r.parts,s);break;case\"ParameterExpansion\":r.operation&&this.walkParameterOp(r.operation,s);break}}walkParameterOp(t,s){switch(t.type){case\"DefaultValue\":case\"AssignDefault\":case\"UseAlternative\":this.walkWordParts(t.word.parts,s);break;case\"ErrorIfUnset\":t.word&&this.walkWordParts(t.word.parts,s);break;case\"PatternRemoval\":this.walkWordParts(t.pattern.parts,s);break;case\"PatternReplacement\":this.walkWordParts(t.pattern.parts,s),t.replacement&&this.walkWordParts(t.replacement.parts,s);break;case\"CaseModification\":t.pattern&&this.walkWordParts(t.pattern.parts,s);break;case\"Indirection\":t.innerOp&&this.walkParameterOp(t.innerOp,s);break}}extractName(t){return t.parts.length===1&&t.parts[0].type===\"Literal\"?t.parts[0].value:null}};var qr=class{name=\"tee\";options;counter=0;constructor(t){this.options=t}transform(t){let s=[],r=this.options.timestamp??new Date;return{ast:this.transformScript(t.ast,s,r),metadata:{teeFiles:s}}}formatTimestamp(t){return t.toISOString().replace(/:/g,\"-\")}generateStdoutPath(t,s,r){let n=this.formatTimestamp(r),i=String(t).padStart(3,\"0\");return`${this.options.outputDir}/${n}-${i}-${s}.stdout.txt`}transformScript(t,s,r){return{...t,statements:t.statements.map(n=>this.transformStatement(n,s,r))}}transformStatement(t,s,r){let n=[],i=[];for(let o=0;o<t.pipelines.length;o++){let a=t.pipelines[o];o>0&&i.push(t.operators[o-1]);let l=this.transformPipeline(a,s,r);if(n.push(l.pipeline),l.origCmdNewIndices!==null){let c=l.origCmdNewIndices;i.push(\";\"),n.push(this.makePipestatusSave(c)),i.push(\";\"),n.push(this.makePipestatusRestore(c.length,l.negated))}}return{...t,pipelines:n,operators:i}}transformPipeline(t,s,r){if(t.commands.length<=1)return{pipeline:t,origCmdNewIndices:null,negated:!1};let n=[],i=[],o=[],a=!1;for(let l=0;l<t.commands.length;l++){let c=t.commands[l],u=l===t.commands.length-1;if(c.type!==\"SimpleCommand\"||!c.name||!this.shouldTarget(c)){o.push(n.length),n.push(c),u||i.push(t.pipeStderr?.[l]??!1);continue}let f=this.getCommandName(c.name)??\"unknown\",d=this.counter++,p=this.generateStdoutPath(d,f,r),y=this.makeTeeCommand(p),h=this.serializeCommand(c);s.push({commandIndex:d,commandName:f,command:h,stdoutFile:p}),o.push(n.length),n.push(c),i.push(t.pipeStderr?.[l]??!1),n.push(y),u||i.push(!1),a=!0}return a?{pipeline:{...t,negated:!1,commands:n,pipeStderr:i.length>0?i:void 0},origCmdNewIndices:o,negated:t.negated}:{pipeline:t,origCmdNewIndices:null,negated:!1}}makePipestatusSave(t){return{type:\"Pipeline\",commands:[{type:\"SimpleCommand\",assignments:t.map((s,r)=>({type:\"Assignment\",name:`__tps${r}`,value:{type:\"Word\",parts:[{type:\"ParameterExpansion\",parameter:`PIPESTATUS[${s}]`,operation:null}]},append:!1,array:null})),name:null,args:[],redirections:[]}],negated:!1}}makePipestatusRestore(t,s){let r=[];for(let n=0;n<t;n++)r.push({type:\"Subshell\",body:[{type:\"Statement\",pipelines:[{type:\"Pipeline\",commands:[{type:\"SimpleCommand\",assignments:[],name:{type:\"Word\",parts:[{type:\"Literal\",value:\"exit\"}]},args:[{type:\"Word\",parts:[{type:\"ParameterExpansion\",parameter:`__tps${n}`,operation:null}]}],redirections:[]}],negated:!1}],operators:[],background:!1}],redirections:[]});return{type:\"Pipeline\",commands:r,negated:s}}shouldTarget(t){if(!this.options.targetCommandPattern)return!0;let s=this.getCommandName(t.name);return s!==null&&this.options.targetCommandPattern.test(s)}getCommandName(t){return t&&t.parts.length===1&&t.parts[0].type===\"Literal\"?t.parts[0].value:null}serializeCommand(t){let s=[];t.name&&s.push(ie(t.name));for(let r of t.args)s.push(ie(r));return s.join(\" \")}makeTeeCommand(t){return{type:\"SimpleCommand\",assignments:[],name:{type:\"Word\",parts:[{type:\"Literal\",value:\"tee\"}]},args:[{type:\"Word\",parts:[{type:\"Literal\",value:t}]}],redirections:[]}}};export{Ft as Bash,Hr as BashTransformPipeline,Zr as CommandCollectorPlugin,me as DefenseInDepthBox,oo as EMPTY_BYTES,ze as InMemoryFs,Cs as MountableFs,_e as NetworkAccessDeniedError,$t as OverlayFs,Ts as ReadWriteFs,bt as RedirectNotAllowedError,Ds as Sandbox,St as SandboxCommand,Ve as SecurityViolationError,Rs as SecurityViolationLogger,qr as TeePlugin,vt as TooManyRedirectsError,co as bytesOutput,to as createConsoleViolationCallback,io as decodeBytesToUtf8,mo as defineCommand,Be as encodeUtf8ToBytes,uo as getCommandNames,po as getJavaScriptCommandNames,fo as getNetworkCommandNames,ho as getPythonCommandNames,zt as latin1FromBytes,fe as parse,Lt as serialize,Bt as stdoutAsBytes,ao as stdoutKind,lo as textOutput,At as unsafeBytesFromLatin1};\n","import { a as discoverModuleFileEntries, c as walkTypeScriptFiles, l as entryIdFromFile, o as moduleFileKeyFromPath, s as discoverEntries, t as validateUniqueModuleKeys } from \"./discovery-CWjr_liZ.mjs\";\nimport { pathToFileURL } from \"node:url\";\nimport { resolveAppRoot, runWithAppRoot } from \"@keystrokehq/sandbox\";\nimport { dirname, join, relative, sep } from \"node:path\";\nimport { PromptResponseSchema, ROUTE_MANIFEST_REL_PATH, normalizeCredentialList, parseStoredRouteManifest } from \"@keystrokehq/shared\";\nimport { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from \"node:fs\";\nimport { z } from \"zod\";\n//#region src/guards/agent.ts\nfunction isManifestAgent(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst agent = value;\n\treturn typeof agent.slug === \"string\" && agent.slug.trim().length > 0 && typeof agent.buildRuntime === \"function\" && typeof agent.model === \"string\" && typeof agent.systemPrompt === \"string\";\n}\nfunction validateManifestAgent(value, filePath) {\n\tif (!isManifestAgent(value)) throw new Error(`${filePath} must default-export defineAgent(...)`);\n\treturn value;\n}\n//#endregion\n//#region src/routes.ts\nfunction normalizeWebhookEndpoint(endpoint) {\n\treturn endpoint.replace(/^\\/+|\\/+$/g, \"\").replace(/^triggers\\/?/, \"\");\n}\nfunction agentRouteFromKey(key) {\n\treturn `/agents/${key}`;\n}\nfunction workflowRouteFromKey(key) {\n\treturn `/workflows/${key}`;\n}\nfunction pollRouteFromKey(attachmentKey) {\n\treturn `/triggers/${attachmentKey}/poll`;\n}\nfunction pollGroupRouteFromId(pollId) {\n\treturn `/triggers/polls/${pollId}/run`;\n}\nfunction webhookRouteFromEndpoint(endpoint) {\n\tconst normalized = normalizeWebhookEndpoint(endpoint);\n\tif (!normalized) throw new Error(\"Webhook endpoint must not be empty\");\n\treturn `/triggers/${normalized}`;\n}\n//#endregion\n//#region src/agents/discover.ts\nasync function discoverAgentEntries(agentsDir, options) {\n\tconst files = await discoverModuleFileEntries(agentsDir, {\n\t\tnestedEntry: \"agent\",\n\t\tduplicateLabel: \"agent module file\"\n\t});\n\tconst entries = [];\n\tfor (const { filePath, moduleFile } of files) {\n\t\tconst agent = await importAgentDefinition(filePath, options);\n\t\tentries.push({\n\t\t\tkey: agent.slug,\n\t\t\troute: agentRouteFromKey(agent.slug),\n\t\t\tfilePath,\n\t\t\tmoduleFile\n\t\t});\n\t}\n\treturn entries;\n}\nasync function importAgentDefinition(filePath, options) {\n\tconst appRoot = resolveAppRoot(filePath);\n\tconst href = pathToFileURL(filePath).href;\n\treturn runWithAppRoot(appRoot, async () => {\n\t\treturn validateManifestAgent((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);\n\t});\n}\n//#endregion\n//#region src/guards/action.ts\nconst ACTION = Symbol.for(\"keystroke.action\");\nfunction isManifestAction(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\treturn ACTION in value && value[ACTION] === true;\n}\nfunction getManifestActionCredentialRequirements(action) {\n\treturn Array.isArray(action.credentials) ? action.credentials : void 0;\n}\n//#endregion\n//#region src/agents/count-agent-credentials.ts\nfunction actionSlug(tool) {\n\tconst record = tool;\n\treturn typeof record.slug === \"string\" ? record.slug : void 0;\n}\n/** App-kind slugs required by the agent's tools (same as `credential_instances.app_slug`). */\nfunction collectAgentAppSlugs(agent) {\n\tconst slugs = /* @__PURE__ */ new Set();\n\tfor (const tool of agent.tools ?? []) {\n\t\tconst record = tool;\n\t\tconst requirements = isManifestAction(tool) ? getManifestActionCredentialRequirements(tool) : \"credentials\" in record && Array.isArray(record.credentials) ? record.credentials : void 0;\n\t\tif (!requirements?.length) continue;\n\t\tfor (const requirement of normalizeCredentialList(requirements)) slugs.add(requirement.key);\n\t}\n\treturn [...slugs].sort();\n}\nfunction collectAgentToolSlugs(agent) {\n\tconst slugs = [];\n\tfor (const tool of agent.tools ?? []) {\n\t\tconst slug = actionSlug(tool);\n\t\tif (slug) slugs.push(slug);\n\t}\n\treturn slugs;\n}\nfunction countAgentCredentials(agent) {\n\treturn collectAgentAppSlugs(agent).length;\n}\n//#endregion\n//#region src/agents/agent-manifest-entry.ts\n/** Single source of truth for the `kind: \"agent\"` route-manifest entry shape. */\nfunction agentManifestEntry(agent, options) {\n\treturn {\n\t\tkind: \"agent\",\n\t\tslug: agent.slug,\n\t\tmoduleFile: options.moduleFile,\n\t\tname: agent.name,\n\t\tdescription: agent.description,\n\t\tmodel: agent.model,\n\t\tsystemPrompt: agent.systemPrompt,\n\t\ttoolCount: agent.tools?.length ?? 0,\n\t\tcredentialCount: countAgentCredentials(agent),\n\t\tappSlugs: collectAgentAppSlugs(agent),\n\t\ttoolSlugs: collectAgentToolSlugs(agent)\n\t};\n}\n//#endregion\n//#region src/skills/discover-manifest-entries.ts\nconst SKIP_DIRS = new Set([\".git\", \"node_modules\"]);\nfunction toPosix$1(path) {\n\treturn path.split(sep).join(\"/\");\n}\nfunction parseSkillFrontmatter(raw) {\n\tconst match = raw.match(/^---\\s*\\n([\\s\\S]*?)\\n---/);\n\tif (!match) return {};\n\tconst out = {};\n\tfor (const line of match[1]?.split(\"\\n\") ?? []) {\n\t\tconst trimmed = line.trim();\n\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\t\tconst colon = trimmed.indexOf(\":\");\n\t\tif (colon < 0) continue;\n\t\tconst key = trimmed.slice(0, colon).trim();\n\t\tlet value = trimmed.slice(colon + 1).trim();\n\t\tif (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\") || value.startsWith(\"'\") && value.endsWith(\"'\")) value = value.slice(1, -1);\n\t\tif (key === \"name\") out.name = value;\n\t\telse if (key === \"description\") out.description = value;\n\t}\n\treturn out;\n}\nfunction walkSkillFiles(root, dir, out) {\n\tfor (const name of readdirSync(dir).sort()) {\n\t\tconst absolute = join(dir, name);\n\t\tconst stats = statSync(absolute);\n\t\tif (stats.isDirectory()) {\n\t\t\tif (SKIP_DIRS.has(name)) continue;\n\t\t\twalkSkillFiles(root, absolute, out);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stats.isFile() || name !== \"SKILL.md\") continue;\n\t\tconst moduleFile = toPosix$1(relative(root, absolute));\n\t\tconst slug = toPosix$1(relative(join(root, \"src\", \"skills\"), absolute)).replace(/\\/?SKILL\\.md$/, \"\");\n\t\tif (!slug) continue;\n\t\tconst frontmatter = parseSkillFrontmatter(readFileSync(absolute, \"utf8\"));\n\t\tout.push({\n\t\t\tslug,\n\t\t\tname: frontmatter.name,\n\t\t\tdescription: frontmatter.description,\n\t\t\tmoduleFile\n\t\t});\n\t}\n}\n/** Discover skill metadata from src/skills SKILL.md files for the route manifest. */\nfunction discoverSkillManifestEntries(projectRoot) {\n\tconst skillsDir = join(projectRoot, \"src\", \"skills\");\n\tif (!statSync(skillsDir, { throwIfNoEntry: false })?.isDirectory()) return [];\n\tconst entries = [];\n\twalkSkillFiles(projectRoot, skillsDir, entries);\n\treturn entries;\n}\n//#endregion\n//#region src/openapi/schema-to-json.ts\nfunction schemaToJson(schema) {\n\treturn z.toJSONSchema(schema, { target: \"openapi-3.0\" });\n}\n//#endregion\n//#region src/openapi/serialize-manifest.ts\nfunction collectIntegrationKeys(integrations) {\n\treturn integrations.map((integration) => integration.key);\n}\nfunction serializeRouteManifest(manifest) {\n\tconst entries = [];\n\tfor (const entry of manifest) switch (entry.kind) {\n\t\tcase \"health\":\n\t\t\tentries.push(entry);\n\t\t\tbreak;\n\t\tcase \"agent\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tslug: entry.slug,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tname: entry.name,\n\t\t\t\tdescription: entry.description,\n\t\t\t\tmodel: entry.model,\n\t\t\t\tsystemPrompt: entry.systemPrompt,\n\t\t\t\ttoolCount: entry.toolCount,\n\t\t\t\tcredentialCount: entry.credentialCount,\n\t\t\t\tappSlugs: entry.appSlugs,\n\t\t\t\ttoolSlugs: entry.toolSlugs\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"workflow\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tslug: entry.slug,\n\t\t\t\tname: entry.name,\n\t\t\t\tdescription: entry.description,\n\t\t\t\tsubscribable: entry.subscribable,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\trequestSchema: schemaToJson(entry.request)\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"trigger-webhook\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tendpoint: entry.endpoint,\n\t\t\t\tattachmentIds: entry.attachmentIds,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tattachmentSchemas: Object.fromEntries(Object.entries(entry.attachmentSchemas).map(([attachmentKey, schemas]) => [attachmentKey, {\n\t\t\t\t\trequestSchema: schemaToJson(schemas.request),\n\t\t\t\t\t...schemas.filter ? { filterSchema: schemaToJson(schemas.filter) } : {}\n\t\t\t\t}]))\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"trigger-poll\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tattachmentId: entry.attachmentId,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tschedule: entry.schedule\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"trigger-poll-group\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tpollId: entry.pollId,\n\t\t\t\tattachmentIds: entry.attachmentIds,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tschedule: entry.schedule\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"cron-schedule\":\n\t\t\tentries.push(entry);\n\t\t\tbreak;\n\t\tdefault: break;\n\t}\n\treturn entries;\n}\nfunction toStoredRouteManifest(manifest, options) {\n\treturn {\n\t\tversion: 2,\n\t\tentries: serializeRouteManifest(manifest),\n\t\tskills: options?.skills ?? [],\n\t\tintegrations: options?.integrations\n\t};\n}\nfunction buildStoredRouteManifestFromContext(ctx) {\n\tconst integrations = ctx.options?.integrations ?? ctx.options?.plugins?.map((plugin) => ({\n\t\tkey: plugin.name,\n\t\tmount: plugin.register\n\t})) ?? [];\n\treturn toStoredRouteManifest(ctx.manifest, {\n\t\tintegrations: collectIntegrationKeys(integrations),\n\t\tskills: ctx.skills ?? (ctx.projectRoot ? discoverSkillManifestEntries(ctx.projectRoot) : void 0) ?? []\n\t});\n}\nfunction findWorkflowManifestEntry(manifest, workflowSlug) {\n\treturn manifest.entries.find((entry) => entry.kind === \"workflow\" && entry.slug === workflowSlug);\n}\nfunction findWebhookManifestEntryByEndpoint(manifest, endpoint) {\n\treturn manifest.entries.find((entry) => entry.kind === \"trigger-webhook\" && entry.endpoint === endpoint);\n}\n/** @deprecated Use {@link findWebhookManifestEntryByEndpoint}. */\nfunction findWebhookManifestEntryByPath(manifest, route) {\n\treturn findWebhookManifestEntryByEndpoint(manifest, route.replace(/^\\/triggers\\//, \"\").replace(/^\\/+|\\/+$/g, \"\"));\n}\n//#endregion\n//#region src/persist.ts\nfunction persistStoredRouteManifest(projectRoot, manifest) {\n\tconst path = join(projectRoot, ROUTE_MANIFEST_REL_PATH);\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(manifest, null, 2)}\\n`);\n}\n//#endregion\n//#region src/guards/workflow.ts\nconst WORKFLOW = Symbol.for(\"keystroke.workflow\");\nfunction isManifestWorkflow(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(WORKFLOW in value) || value[WORKFLOW] !== true) return false;\n\tconst workflow = value;\n\treturn typeof workflow.slug === \"string\" && workflow.slug.trim().length > 0 && workflow.input instanceof Object && \"safeParse\" in workflow.input && workflow.output instanceof Object && \"safeParse\" in workflow.output;\n}\nfunction validateManifestWorkflow(value, filePath) {\n\tif (!isManifestWorkflow(value)) throw new Error(`${filePath} must default-export defineWorkflow(...)`);\n\treturn value;\n}\n//#endregion\n//#region src/guards/trigger.ts\nconst TRIGGER_ATTACHMENT = Symbol.for(\"keystroke.triggerAttachment\");\nconst zodSchema = z.custom((value) => value instanceof z.ZodType, \"must be a Zod schema\");\nconst cronScheduleSchema = z.string().trim().min(1, \"cron schedule must be a non-empty string\");\nconst workflowSchema = z.custom((value) => isManifestWorkflow(value), \"must be defineWorkflow(...)\");\nconst agentSchema = z.custom((value) => typeof value === \"object\" && value !== null && typeof value.slug === \"string\" && value.slug.trim().length > 0 && typeof value.prompt === \"function\", \"must be defineAgent(...)\");\nconst promptSchema = z.union([z.string(), z.function()]);\nconst baseSourceShape = {\n\tkey: z.string().trim().min(1),\n\tattach: z.function()\n};\nconst webhookSourceSchema = z.object({\n\tkind: z.literal(\"webhook\"),\n\t...baseSourceShape,\n\tendpoint: z.string().min(1),\n\trequest: zodSchema,\n\tfilter: zodSchema.optional(),\n\tpasses: z.function()\n});\nconst cronSourceSchema = z.object({\n\tkind: z.literal(\"cron\"),\n\t...baseSourceShape,\n\tschedule: cronScheduleSchema\n});\nconst pollSourceSchema = z.object({\n\tkind: z.literal(\"poll\"),\n\t...baseSourceShape,\n\tid: z.string().optional(),\n\tschedule: cronScheduleSchema,\n\trun: z.function(),\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\nconst triggerSourceSchema = z.discriminatedUnion(\"kind\", [\n\twebhookSourceSchema,\n\tcronSourceSchema,\n\tpollSourceSchema\n]);\nconst workflowAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"workflow\"),\n\tworkflow: workflowSchema,\n\ttransform: z.function().optional()\n});\nconst agentAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"agent\"),\n\tagent: agentSchema,\n\tprompt: promptSchema\n});\nconst triggerAttachmentCoreSchema = z.discriminatedUnion(\"target\", [workflowAttachmentSchema, agentAttachmentSchema]);\nfunction isManifestTriggerAttachment(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(TRIGGER_ATTACHMENT in value) || value[TRIGGER_ATTACHMENT] !== true) return false;\n\treturn triggerAttachmentCoreSchema.safeParse(value).success;\n}\nfunction validateManifestTriggerAttachment(value, filePath) {\n\tif (!isManifestTriggerAttachment(value)) throw new Error(`${filePath} must default-export a trigger attachment from .attach({ workflow }) or .attach({ agent, prompt })`);\n\treturn value;\n}\n//#endregion\n//#region src/triggers/discover.ts\nfunction shouldDiscoverTriggerFile(triggersDir, filePath) {\n\treturn !relative(triggersDir, filePath).split(sep).includes(\"sources\");\n}\nasync function discoverTriggerAttachments(triggersDir, options) {\n\tconst files = await discoverModuleFileEntries(triggersDir, {\n\t\tnestedEntry: \"trigger\",\n\t\tduplicateLabel: \"trigger module file\",\n\t\tshouldDiscoverFile: (filePath) => shouldDiscoverTriggerFile(triggersDir, filePath)\n\t});\n\tconst attachments = [];\n\tfor (const { filePath, moduleFile } of files) {\n\t\tconst attachment = await importTriggerAttachment(filePath, options);\n\t\tattachments.push({\n\t\t\tkey: attachment.key,\n\t\t\tfilePath,\n\t\t\tmoduleFile,\n\t\t\tattachment\n\t\t});\n\t}\n\treturn attachments;\n}\nfunction validateImportedTriggerAttachment(def, filePath) {\n\treturn validateManifestTriggerAttachment(def, filePath);\n}\nasync function importTriggerAttachment(filePath, options) {\n\tconst href = pathToFileURL(filePath).href;\n\treturn validateImportedTriggerAttachment((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);\n}\n//#endregion\n//#region src/triggers/poll/groups.ts\nfunction pollGroupId(discovered) {\n\tconst source = discovered.attachment.source;\n\tif (source.kind !== \"poll\") throw new Error(`Attachment \"${discovered.key}\" is not a poll trigger`);\n\treturn source.id ?? source.key;\n}\nfunction buildPollGroups(attachments) {\n\tconst byId = /* @__PURE__ */ new Map();\n\tfor (const discovered of attachments) {\n\t\tif (discovered.attachment.source.kind !== \"poll\") continue;\n\t\tconst id = pollGroupId(discovered);\n\t\tconst group = byId.get(id) ?? [];\n\t\tgroup.push(discovered);\n\t\tbyId.set(id, group);\n\t}\n\treturn [...byId.entries()].map(([id, groupAttachments]) => ({\n\t\tid,\n\t\tattachments: groupAttachments\n\t}));\n}\nfunction validatePollGroups(groups) {\n\tfor (const group of groups) {\n\t\tif (group.attachments.length <= 1) continue;\n\t\tif (new Set(group.attachments.map((discovered) => {\n\t\t\tconst source = discovered.attachment.source;\n\t\t\tif (source.kind !== \"poll\") throw new Error(`Poll group \"${group.id}\" has non-poll attachment ${discovered.key}`);\n\t\t\treturn source.schedule;\n\t\t})).size > 1) {\n\t\t\tconst keys = group.attachments.map((discovered) => discovered.key).join(\", \");\n\t\t\tthrow new Error(`Poll group \"${group.id}\" has attachments with different schedules (${keys})`);\n\t\t}\n\t}\n}\nfunction matchesPollRunTarget(attachmentKey, workflowKey, target) {\n\tif (!target?.workflows?.length && !target?.attachments?.length) return true;\n\tif (target.attachments?.length && !target.attachments.includes(attachmentKey)) return false;\n\tif (target.workflows?.length && !target.workflows.includes(workflowKey)) return false;\n\treturn true;\n}\n//#endregion\n//#region src/triggers/webhook/build-webhook-bindings.ts\nfunction buildWebhookBindingsByRoute(attachments, handlerOptionsFor) {\n\tconst webhookBindingsByRoute = /* @__PURE__ */ new Map();\n\tfor (const discovered of attachments) {\n\t\tconst source = discovered.attachment.source;\n\t\tif (source.kind !== \"webhook\") continue;\n\t\tconst route = webhookRouteFromEndpoint(source.endpoint);\n\t\tconst bindings = webhookBindingsByRoute.get(route) ?? [];\n\t\tbindings.push({\n\t\t\tdiscovered,\n\t\t\toptions: handlerOptionsFor(discovered.key)\n\t\t});\n\t\twebhookBindingsByRoute.set(route, bindings);\n\t}\n\treturn webhookBindingsByRoute;\n}\n//#endregion\n//#region src/triggers/webhook/webhook-schemas.ts\nfunction webhookSchemaEntriesFromBindings(bindings) {\n\treturn bindings.flatMap((binding) => {\n\t\tconst source = binding.discovered.attachment.source;\n\t\tif (source.kind !== \"webhook\") return [];\n\t\treturn [{\n\t\t\tattachmentKey: binding.discovered.key,\n\t\t\trequest: source.request,\n\t\t\t...source.filter ? { filter: source.filter } : {}\n\t\t}];\n\t});\n}\nfunction webhookAttachmentSchemasFromBindings(bindings) {\n\treturn webhookSchemaEntriesFromBindings(bindings).map((entry) => ({\n\t\tattachmentKey: entry.attachmentKey,\n\t\trequestSchema: schemaToJson(entry.request),\n\t\t...entry.filter ? { filterSchema: schemaToJson(entry.filter) } : {}\n\t}));\n}\nfunction webhookMatchSchemaForBindings(bindings) {\n\tconst schemas = bindings.flatMap((binding) => {\n\t\tconst source = binding.discovered.attachment.source;\n\t\treturn source.kind === \"webhook\" ? [source.request] : [];\n\t});\n\tif (schemas.length === 0) throw new Error(\"Webhook bindings require at least one webhook source\");\n\tif (schemas.length === 1) return schemas[0];\n\treturn z.union(schemas);\n}\nfunction webhookManifestAttachmentSchemasFromBindings(bindings) {\n\treturn Object.fromEntries(webhookSchemaEntriesFromBindings(bindings).map((entry) => [entry.attachmentKey, {\n\t\trequest: entry.request,\n\t\t...entry.filter ? { filter: entry.filter } : {}\n\t}]));\n}\n//#endregion\n//#region src/workflows/discover.ts\nasync function discoverWorkflowEntries(workflowsDir, options) {\n\tconst files = await discoverModuleFileEntries(workflowsDir, {\n\t\tnestedEntry: \"workflow\",\n\t\tduplicateLabel: \"workflow module file\"\n\t});\n\tconst entries = [];\n\tfor (const { filePath, moduleFile } of files) {\n\t\tconst definition = await importWorkflowDefinition(filePath, options);\n\t\tentries.push({\n\t\t\tkey: definition.slug,\n\t\t\troute: workflowRouteFromKey(definition.slug),\n\t\t\tfilePath,\n\t\t\tmoduleFile\n\t\t});\n\t}\n\treturn entries;\n}\nfunction validateImportedWorkflowDefinition(def, filePath) {\n\treturn validateManifestWorkflow(def, filePath);\n}\nasync function importWorkflowDefinition(filePath, options) {\n\tconst href = pathToFileURL(filePath).href;\n\treturn validateImportedWorkflowDefinition((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);\n}\nasync function discoverWorkflows(workflowsDir, options) {\n\tconst entries = await discoverWorkflowEntries(workflowsDir, options);\n\tconst workflows = [];\n\tfor (const entry of entries) {\n\t\tconst definition = await importWorkflowDefinition(entry.filePath, options);\n\t\tworkflows.push({\n\t\t\tkey: definition.slug,\n\t\t\troute: workflowRouteFromKey(definition.slug),\n\t\t\tfilePath: entry.filePath,\n\t\t\tdefinition\n\t\t});\n\t}\n\treturn workflows;\n}\n//#endregion\n//#region src/build-stored-manifest.ts\nfunction resolveDistModuleDirs(projectRoot) {\n\tconst distBase = join(projectRoot, \"dist\");\n\tif (!existsSync(distBase)) throw new Error(`Build output missing at ${distBase}. Run keystroke build before emitting the route manifest.`);\n\treturn {\n\t\tagentsDir: join(distBase, \"agents\"),\n\t\tworkflowsDir: join(distBase, \"workflows\"),\n\t\ttriggersDir: join(distBase, \"triggers\")\n\t};\n}\nfunction toPosix(path) {\n\treturn path.split(sep).join(\"/\");\n}\n/**\n* Resolve manifest moduleFile values to project-root-relative source paths.\n*\n* Discovery runs over compiled `dist/` modules, so the raw moduleFile is a\n* dist-relative `.mjs` path. Dist entries are named by their source entry id\n* (`team/escalation.mjs` ← `src/agents/team/escalation/agent.ts`), so walking\n* the matching source dir by the same id rules recovers the source path. Falls\n* back to the dist-relative value when no source file matches (e.g. building\n* a dist-only artifact with no `src/`).\n*/\nvar SourceModuleFileResolver = class {\n\tprojectRoot;\n\tmapsByKind = /* @__PURE__ */ new Map();\n\tconstructor(projectRoot) {\n\t\tthis.projectRoot = projectRoot;\n\t}\n\tasync sourceMapFor(kindDir, nestedEntry) {\n\t\tconst existing = this.mapsByKind.get(kindDir);\n\t\tif (existing) return existing;\n\t\tconst map = /* @__PURE__ */ new Map();\n\t\tconst sourceDir = join(this.projectRoot, \"src\", kindDir);\n\t\tfor (const filePath of await walkTypeScriptFiles(sourceDir)) {\n\t\t\tconst id = entryIdFromFile(sourceDir, filePath, { nestedEntry });\n\t\t\tif (id) map.set(id, toPosix(relative(this.projectRoot, filePath)));\n\t\t}\n\t\tthis.mapsByKind.set(kindDir, map);\n\t\treturn map;\n\t}\n\tasync resolve(kindDir, nestedEntry, distDir, distFilePath) {\n\t\tconst fallback = toPosix(relative(distDir, distFilePath));\n\t\tconst id = entryIdFromFile(distDir, distFilePath, { nestedEntry });\n\t\tif (!id) return fallback;\n\t\treturn (await this.sourceMapFor(kindDir, nestedEntry)).get(id) ?? fallback;\n\t}\n};\n/** Build a stored route manifest from compiled dist/ modules without starting a server. */\nasync function buildStoredRouteManifestForProject(projectRoot, options) {\n\tconst previousRoot = process.env.KEYSTROKE_ROOT;\n\tprocess.env.KEYSTROKE_ROOT = projectRoot;\n\tconst reload = options?.reloadModules ? { reload: true } : void 0;\n\ttry {\n\t\tconst dirs = resolveDistModuleDirs(projectRoot);\n\t\tconst sourcePaths = new SourceModuleFileResolver(projectRoot);\n\t\tconst manifest = [{ kind: \"health\" }];\n\t\tconst agentEntries = await discoverAgentEntries(dirs.agentsDir, reload);\n\t\tfor (const entry of agentEntries) {\n\t\t\tconst agent = await importAgentDefinition(entry.filePath, reload);\n\t\t\tconst moduleFile = await sourcePaths.resolve(\"agents\", \"agent\", dirs.agentsDir, entry.filePath);\n\t\t\tmanifest.push(agentManifestEntry(agent, { moduleFile }));\n\t\t}\n\t\tconst workflows = await discoverWorkflows(dirs.workflowsDir, reload);\n\t\tfor (const workflow of workflows) {\n\t\t\tconst moduleFile = await sourcePaths.resolve(\"workflows\", \"workflow\", dirs.workflowsDir, workflow.filePath);\n\t\t\tmanifest.push({\n\t\t\t\tkind: \"workflow\",\n\t\t\t\tslug: workflow.definition.slug,\n\t\t\t\tname: workflow.definition.name,\n\t\t\t\tdescription: workflow.definition.description,\n\t\t\t\tsubscribable: workflow.definition.subscription?.mode === \"subscribable\",\n\t\t\t\tmoduleFile,\n\t\t\t\trequest: workflow.definition.input\n\t\t\t});\n\t\t}\n\t\tconst attachments = await discoverTriggerAttachments(dirs.triggersDir, reload);\n\t\tconst discoveredByKey = new Map(attachments.map((attachment) => [attachment.key, attachment]));\n\t\tconst pollGroups = buildPollGroups(attachments);\n\t\tfor (const discovered of discoveredByKey.values()) {\n\t\t\tconst source = discovered.attachment.source;\n\t\t\tconst moduleFile = await sourcePaths.resolve(\"triggers\", \"trigger\", dirs.triggersDir, discovered.filePath);\n\t\t\tif (source.kind === \"cron\") {\n\t\t\t\tmanifest.push({\n\t\t\t\t\tkind: \"cron-schedule\",\n\t\t\t\t\tattachmentId: discovered.key,\n\t\t\t\t\tmoduleFile,\n\t\t\t\t\tschedule: source.schedule\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (source.kind === \"poll\") {\n\t\t\t\tmanifest.push({\n\t\t\t\t\tkind: \"trigger-poll\",\n\t\t\t\t\tattachmentId: discovered.key,\n\t\t\t\t\tmoduleFile,\n\t\t\t\t\tschedule: source.schedule,\n\t\t\t\t\tresponse: PromptResponseSchema\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (source.kind === \"webhook\") {\n\t\t\t\tconst route = webhookRouteFromEndpoint(source.endpoint);\n\t\t\t\tconst bindings = buildWebhookBindingsByRoute(discoveredByKey.values(), () => ({\n\t\t\t\t\texecution: { attachmentKey: discovered.key },\n\t\t\t\t\tattachmentKey: discovered.key\n\t\t\t\t})).get(route) ?? [{\n\t\t\t\t\tdiscovered,\n\t\t\t\t\toptions: { attachmentKey: discovered.key }\n\t\t\t\t}];\n\t\t\t\tmanifest.push({\n\t\t\t\t\tkind: \"trigger-webhook\",\n\t\t\t\t\tendpoint: source.endpoint,\n\t\t\t\t\tattachmentIds: bindings.map(({ discovered: row }) => row.key),\n\t\t\t\t\tmoduleFile,\n\t\t\t\t\trequest: webhookMatchSchemaForBindings(bindings),\n\t\t\t\t\tattachmentSchemas: webhookManifestAttachmentSchemasFromBindings(bindings),\n\t\t\t\t\tresponse: PromptResponseSchema\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tfor (const group of pollGroups) {\n\t\t\tif (group.attachments.length <= 1) continue;\n\t\t\tconst first = group.attachments[0];\n\t\t\tconst source = first.attachment.source;\n\t\t\tmanifest.push({\n\t\t\t\tkind: \"trigger-poll-group\",\n\t\t\t\tpollId: group.id,\n\t\t\t\tattachmentIds: group.attachments.map((attachment) => attachment.key),\n\t\t\t\tmoduleFile: await sourcePaths.resolve(\"triggers\", \"trigger\", dirs.triggersDir, first.filePath),\n\t\t\t\tschedule: source.kind === \"poll\" ? source.schedule : \"\",\n\t\t\t\tresponse: PromptResponseSchema\n\t\t\t});\n\t\t}\n\t\treturn buildStoredRouteManifestFromContext({\n\t\t\tmanifest,\n\t\t\toptions: {},\n\t\t\tprojectRoot,\n\t\t\tskills: discoverSkillManifestEntries(projectRoot)\n\t\t});\n\t} finally {\n\t\tif (previousRoot === void 0) delete process.env.KEYSTROKE_ROOT;\n\t\telse process.env.KEYSTROKE_ROOT = previousRoot;\n\t}\n}\n/** Write `dist/.keystroke/route-manifest.json` for the project. */\nasync function emitStoredRouteManifestForProject(projectRoot) {\n\tpersistStoredRouteManifest(projectRoot, await buildStoredRouteManifestForProject(projectRoot));\n}\n//#endregion\n//#region src/openapi/manifest.ts\nfunction schedulesFromManifest(manifest) {\n\tconst schedules = [];\n\tfor (const entry of manifest) {\n\t\tif (entry.kind === \"cron-schedule\") {\n\t\t\tschedules.push({\n\t\t\t\tattachmentId: entry.attachmentId,\n\t\t\t\ttype: \"cron\",\n\t\t\t\tschedule: entry.schedule\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.kind === \"trigger-poll\") schedules.push({\n\t\t\tattachmentId: entry.attachmentId,\n\t\t\ttype: \"poll\",\n\t\t\tschedule: entry.schedule\n\t\t});\n\t}\n\treturn schedules;\n}\n//#endregion\n//#region src/load-route-manifest.ts\nfunction routeManifestPathForProjectRoot(projectRoot) {\n\treturn join(projectRoot, ROUTE_MANIFEST_REL_PATH);\n}\nfunction readRouteManifest(projectRoot) {\n\tconst path = routeManifestPathForProjectRoot(projectRoot);\n\tif (!existsSync(path)) throw new Error(`${ROUTE_MANIFEST_REL_PATH} not found — start the project server once to emit the manifest`);\n\tconst raw = readFileSync(path, \"utf8\");\n\treturn parseStoredRouteManifest(JSON.parse(raw));\n}\n//#endregion\nexport { agentManifestEntry, agentRouteFromKey, buildPollGroups, buildStoredRouteManifestForProject, buildStoredRouteManifestFromContext, buildWebhookBindingsByRoute, collectAgentAppSlugs, collectAgentToolSlugs, countAgentCredentials, discoverAgentEntries, discoverEntries, discoverModuleFileEntries, discoverSkillManifestEntries, discoverTriggerAttachments, discoverWorkflowEntries, discoverWorkflows, emitStoredRouteManifestForProject, entryIdFromFile, findWebhookManifestEntryByEndpoint, findWebhookManifestEntryByPath, findWorkflowManifestEntry, importAgentDefinition, importTriggerAttachment, importWorkflowDefinition, matchesPollRunTarget, moduleFileKeyFromPath, persistStoredRouteManifest, pollGroupId, pollGroupRouteFromId, pollRouteFromKey, readRouteManifest, routeManifestPathForProjectRoot, schedulesFromManifest, schemaToJson, serializeRouteManifest, toStoredRouteManifest, validateImportedTriggerAttachment, validateImportedWorkflowDefinition, validatePollGroups, validateUniqueModuleKeys, walkTypeScriptFiles, webhookAttachmentSchemasFromBindings, webhookManifestAttachmentSchemasFromBindings, webhookMatchSchemaForBindings, webhookRouteFromEndpoint, workflowRouteFromKey };\n\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,25],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"dist-DtU9BFPv.mjs","names":["Qt","z.enum","z.object","z.string","z.array","z.union","z.literal","SKIP_DIRS","Guard.IsObject","Guard.HasPropertyKey","Guard.IsArray","Settings.Get","Settings.Get","Guard.IsObject","Memory.Update","Guard.HasPropertyKey","Memory.Create","Guard.Keys","Memory.Create","Number","Memory.Create","String","Memory.Create","AllowedDigits","Type.Object","Type.String","Type.Array","Type.Optional","Type.Number","z.toJSONSchema","z.custom","z.ZodType","z.string","z.union","z.function","z.object","z.literal","z.array","z.discriminatedUnion"],"sources":["../../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/chunks/chunk-G5EVRAOO.js","../../../packages/manifest/dist/discovery-CWjr_liZ.mjs","../../../packages/sandbox/dist/files-BOUCjfCQ.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/metrics.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/guard/guard.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/clone.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/settings/settings.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/create.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/memory/update.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/schema.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/_optional.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/array.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/properties.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/object.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/system/hashing/hash.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/integer.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/number.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/string.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/types/record.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/internal/char.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/unsigned_integer.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/ident.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/script/token/unsigned_number.mjs","../../../node_modules/.pnpm/typebox@1.1.38/node_modules/typebox/build/type/engine/indexed/from_object.mjs","../../../packages/sandbox/dist/create-coding-tools-d9-WzxBW.mjs","../../../node_modules/.pnpm/just-bash@3.0.1/node_modules/just-bash/dist/bundle/index.js","../../../packages/manifest/dist/index.mjs"],"sourcesContent":["import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);\nimport{a as O}from\"./chunk-4RUAZWKT.js\";import{e as j,f as K,g as C,h as re,i as Pe,j as It,k as L}from\"./chunk-SAI2SPQQ.js\";function $(e,t){for(;t<e.length;){if(e[t]===\"\\\\\"&&e[t+1]===`\n`){t+=2;continue}if(/\\s/.test(e[t])){t++;continue}break}return t}var Re=[\"=\",\"+=\",\"-=\",\"*=\",\"/=\",\"%=\",\"<<=\",\">>=\",\"&=\",\"|=\",\"^=\"];function ge(e){if(e.includes(\"#\")){let[r,s]=e.split(\"#\"),n=Number.parseInt(r,10);if(n<2||n>64)return Number.NaN;if(n<=36){let i=Number.parseInt(s,n);return i>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:i}let a=0;for(let i of s){let l;if(/[0-9]/.test(i))l=i.charCodeAt(0)-48;else if(/[a-z]/.test(i))l=i.charCodeAt(0)-97+10;else if(/[A-Z]/.test(i))l=i.charCodeAt(0)-65+36;else if(i===\"@\")l=62;else if(i===\"_\")l=63;else return Number.NaN;if(l>=n)return Number.NaN;if(a=a*n+l,a>Number.MAX_SAFE_INTEGER)return Number.MAX_SAFE_INTEGER}return a}if(e.startsWith(\"0x\")||e.startsWith(\"0X\")){let r=Number.parseInt(e.slice(2),16);return r>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:r}if(e.startsWith(\"0\")&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return Number.NaN;let r=Number.parseInt(e,8);return r>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:r}let t=Number.parseInt(e,10);return t>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:t}function vt(e,t,r,s){if(r.slice(s,s+3)!==\"$((\")return null;let n=s+3,a=1,i=n;for(;n<r.length-1&&a>0;)r[n]===\"(\"&&r[n+1]===\"(\"?(a++,n+=2):r[n]===\")\"&&r[n+1]===\")\"?(a--,a>0&&(n+=2)):n++;let l=r.slice(i,n),{expr:o}=e(t,l,0);return n+=2,{expr:{type:\"ArithNested\",expression:o},pos:n}}function Dt(e,t){if(e.slice(t,t+2)!==\"$'\")return null;let r=t+2,s=\"\";for(;r<e.length&&e[r]!==\"'\";)if(e[r]===\"\\\\\"&&r+1<e.length){let a=e[r+1];switch(a){case\"n\":s+=`\n`;break;case\"t\":s+=\"\t\";break;case\"r\":s+=\"\\r\";break;case\"\\\\\":s+=\"\\\\\";break;case\"'\":s+=\"'\";break;default:s+=a}r+=2}else s+=e[r],r++;e[r]===\"'\"&&r++;let n=Number.parseInt(s,10);return{expr:{type:\"ArithNumber\",value:Number.isNaN(n)?0:n},pos:r}}function xt(e,t){if(e.slice(t,t+2)!=='$\"')return null;let r=t+2,s=\"\";for(;r<e.length&&e[r]!=='\"';)e[r]===\"\\\\\"&&r+1<e.length?(s+=e[r+1],r+=2):(s+=e[r],r++);e[r]==='\"'&&r++;let n=Number.parseInt(s,10);return{expr:{type:\"ArithNumber\",value:Number.isNaN(n)?0:n},pos:r}}function kr(e){let t=\"\",r=0;for(;r<e.length;)if(e[r]==='\"'){for(r++;r<e.length&&e[r]!=='\"';)e[r]===\"\\\\\"&&r+1<e.length?(t+=e[r+1],r+=2):(t+=e[r],r++);r<e.length&&r++}else t+=e[r],r++;return t}function M(e,t){let r=kr(t),{expr:s,pos:n}=Z(e,r,0),a=$(r,n);if(a<r.length){let i=t.slice(a).trim();if(i)return{type:\"ArithmeticExpression\",originalText:t,expression:{type:\"ArithSyntaxError\",errorToken:i,message:`${i}: syntax error: invalid arithmetic operator (error token is \"${i}\")`}}}return{type:\"ArithmeticExpression\",expression:s,originalText:t}}function F(e,t){return{expr:{type:\"ArithSyntaxError\",errorToken:e,message:`syntax error: operand expected (error token is \"${e}\")`},pos:t}}function z(e,t){return $(e,t)>=e.length}function Z(e,t,r){return Pr(e,t,r)}function Pr(e,t,r){let{expr:s,pos:n}=ye(e,t,r);for(n=$(t,n);t[n]===\",\";){if(n++,z(t,n))return F(\",\",n);let{expr:i,pos:l}=ye(e,t,n);s={type:\"ArithBinary\",operator:\",\",left:s,right:i},n=$(t,l)}return{expr:s,pos:n}}function ye(e,t,r){let{expr:s,pos:n}=Rr(e,t,r);if(n=$(t,n),t[n]===\"?\"){n++;let{expr:a,pos:i}=Z(e,t,n);if(n=$(t,i),t[n]===\":\"){n++;let{expr:l,pos:o}=Z(e,t,n);return{expr:{type:\"ArithTernary\",condition:s,consequent:a,alternate:l},pos:o}}}return{expr:s,pos:n}}function Rr(e,t,r){let{expr:s,pos:n}=_t(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"||\";){if(n+=2,z(t,n))return F(\"||\",n);let{expr:i,pos:l}=_t(e,t,n);s={type:\"ArithBinary\",operator:\"||\",left:s,right:i},n=l}return{expr:s,pos:n}}function _t(e,t,r){let{expr:s,pos:n}=$t(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"&&\";){if(n+=2,z(t,n))return F(\"&&\",n);let{expr:i,pos:l}=$t(e,t,n);s={type:\"ArithBinary\",operator:\"&&\",left:s,right:i},n=l}return{expr:s,pos:n}}function $t(e,t,r){let{expr:s,pos:n}=Ct(e,t,r);for(;n=$(t,n),t[n]===\"|\"&&t[n+1]!==\"|\";){if(n++,z(t,n))return F(\"|\",n);let{expr:i,pos:l}=Ct(e,t,n);s={type:\"ArithBinary\",operator:\"|\",left:s,right:i},n=l}return{expr:s,pos:n}}function Ct(e,t,r){let{expr:s,pos:n}=Ot(e,t,r);for(;n=$(t,n),t[n]===\"^\";){if(n++,z(t,n))return F(\"^\",n);let{expr:i,pos:l}=Ot(e,t,n);s={type:\"ArithBinary\",operator:\"^\",left:s,right:i},n=l}return{expr:s,pos:n}}function Ot(e,t,r){let{expr:s,pos:n}=Lt(e,t,r);for(;n=$(t,n),t[n]===\"&\"&&t[n+1]!==\"&\";){if(n++,z(t,n))return F(\"&\",n);let{expr:i,pos:l}=Lt(e,t,n);s={type:\"ArithBinary\",operator:\"&\",left:s,right:i},n=l}return{expr:s,pos:n}}function Lt(e,t,r){let{expr:s,pos:n}=Wt(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"==\"||t.slice(n,n+2)===\"!=\";){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=Wt(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Wt(e,t,r){let{expr:s,pos:n}=ze(e,t,r);for(;;)if(n=$(t,n),t.slice(n,n+2)===\"<=\"||t.slice(n,n+2)===\">=\"){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=ze(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}else if(t[n]===\"<\"||t[n]===\">\"){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=ze(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}else break;return{expr:s,pos:n}}function ze(e,t,r){let{expr:s,pos:n}=Tt(e,t,r);for(;n=$(t,n),t.slice(n,n+2)===\"<<\"||t.slice(n,n+2)===\">>\";){let a=t.slice(n,n+2);if(n+=2,z(t,n))return F(a,n);let{expr:i,pos:l}=Tt(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Tt(e,t,r){let{expr:s,pos:n}=Mt(e,t,r);for(;n=$(t,n),(t[n]===\"+\"||t[n]===\"-\")&&t[n+1]!==t[n];){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=Mt(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}return{expr:s,pos:n}}function Mt(e,t,r){let{expr:s,pos:n}=Ie(e,t,r);for(;;)if(n=$(t,n),t[n]===\"*\"&&t[n+1]!==\"*\"){if(n++,z(t,n))return F(\"*\",n);let{expr:i,pos:l}=Ie(e,t,n);s={type:\"ArithBinary\",operator:\"*\",left:s,right:i},n=l}else if(t[n]===\"/\"||t[n]===\"%\"){let a=t[n];if(n++,z(t,n))return F(a,n);let{expr:i,pos:l}=Ie(e,t,n);s={type:\"ArithBinary\",operator:a,left:s,right:i},n=l}else break;return{expr:s,pos:n}}function Ie(e,t,r){let{expr:s,pos:n}=Ge(e,t,r),a=$(t,n);if(t.slice(a,a+2)===\"**\"){if(a+=2,z(t,a))return F(\"**\",a);let{expr:l,pos:o}=Ie(e,t,a);return{expr:{type:\"ArithBinary\",operator:\"**\",left:s,right:l},pos:o}}return{expr:s,pos:n}}function Ge(e,t,r){let s=$(t,r);if(t.slice(s,s+2)===\"++\"||t.slice(s,s+2)===\"--\"){let n=t.slice(s,s+2);s+=2;let{expr:a,pos:i}=Ge(e,t,s);return{expr:{type:\"ArithUnary\",operator:n,operand:a,prefix:!0},pos:i}}if(t[s]===\"+\"||t[s]===\"-\"||t[s]===\"!\"||t[s]===\"~\"){let n=t[s];s++;let{expr:a,pos:i}=Ge(e,t,s);return{expr:{type:\"ArithUnary\",operator:n,operand:a,prefix:!0},pos:i}}return vr(e,t,s)}function Ir(e,t){let r=e[t];return r===\"$\"||r===\"`\"}function vr(e,t,r){let{expr:s,pos:n}=Vt(e,t,r,!1),a=[s];for(;Ir(t,n);){let{expr:l,pos:o}=Vt(e,t,n,!0);a.push(l),n=o}a.length>1&&(s={type:\"ArithConcat\",parts:a});let i;if(t[n]===\"[\"&&s.type===\"ArithConcat\"){n++;let{expr:l,pos:o}=Z(e,t,n);i=l,n=o,t[n]===\"]\"&&n++}if(i&&s.type===\"ArithConcat\"&&(s={type:\"ArithDynamicElement\",nameExpr:s,subscript:i},i=void 0),n=$(t,n),s.type===\"ArithConcat\"||s.type===\"ArithVariable\"||s.type===\"ArithDynamicElement\"){for(let l of Re)if(t.slice(n,n+l.length)===l&&t.slice(n,n+l.length+1)!==\"==\"){n+=l.length;let{expr:o,pos:c}=ye(e,t,n);return s.type===\"ArithDynamicElement\"?{expr:{type:\"ArithDynamicAssignment\",operator:l,target:s.nameExpr,subscript:s.subscript,value:o},pos:c}:s.type===\"ArithConcat\"?{expr:{type:\"ArithDynamicAssignment\",operator:l,target:s,value:o},pos:c}:{expr:{type:\"ArithAssignment\",operator:l,variable:s.name,value:o},pos:c}}}if(t.slice(n,n+2)===\"++\"||t.slice(n,n+2)===\"--\"){let l=t.slice(n,n+2);return n+=2,{expr:{type:\"ArithUnary\",operator:l,operand:s,prefix:!1},pos:n}}return{expr:s,pos:n}}function Vt(e,t,r,s=!1){let n=$(t,r),a=vt(Z,e,t,n);if(a)return a;let i=Dt(t,n);if(i)return i;let l=xt(t,n);if(l)return l;if(t.slice(n,n+2)===\"$(\"&&t[n+2]!==\"(\"){n+=2;let c=1,u=n;for(;n<t.length&&c>0;)t[n]===\"(\"?c++:t[n]===\")\"&&c--,c>0&&n++;let f=t.slice(u,n);return n++,{expr:{type:\"ArithCommandSubst\",command:f},pos:n}}if(t[n]===\"`\"){n++;let c=n;for(;n<t.length&&t[n]!==\"`\";)n++;let u=t.slice(c,n);return t[n]===\"`\"&&n++,{expr:{type:\"ArithCommandSubst\",command:u},pos:n}}if(t[n]===\"(\"){n++;let{expr:c,pos:u}=Z(e,t,n);return n=$(t,u),t[n]===\")\"&&n++,{expr:{type:\"ArithGroup\",expression:c},pos:n}}if(t[n]===\"'\"){n++;let c=\"\";for(;n<t.length&&t[n]!==\"'\";)c+=t[n],n++;t[n]===\"'\"&&n++;let u=Number.parseInt(c,10);return{expr:{type:\"ArithSingleQuote\",content:c,value:Number.isNaN(u)?0:u},pos:n}}if(t[n]==='\"'){n++;let c=\"\";for(;n<t.length&&t[n]!=='\"';)t[n]===\"\\\\\"&&n+1<t.length?(c+=t[n+1],n+=2):(c+=t[n],n++);t[n]==='\"'&&n++;let u=c.trim();if(!u)return{expr:{type:\"ArithNumber\",value:0},pos:n};let{expr:f}=Z(e,u,0);return{expr:f,pos:n}}if(/[0-9]/.test(t[n])){let c=\"\",u=!1,f=!1;for(;n<t.length;){let d=t[n];if(u)if(/[0-9a-zA-Z@_]/.test(d))c+=d,n++;else break;else if(d===\"#\")u=!0,c+=d,n++;else if(c===\"0\"&&(d===\"x\"||d===\"X\")&&n+1<t.length&&/[0-9a-fA-F]/.test(t[n+1]))f=!0,c+=d,n++;else if(f&&/[0-9a-fA-F]/.test(d))c+=d,n++;else if(!f&&/[0-9]/.test(d))c+=d,n++;else break}if(n<t.length&&/[a-zA-Z_]/.test(t[n])){let d=c;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)d+=t[n],n++;return{expr:{type:\"ArithSyntaxError\",errorToken:d,message:`${d}: value too great for base (error token is \"${d}\")`},pos:n}}if(t[n]===\".\"&&/[0-9]/.test(t[n+1]))throw new C(`${c}.${t[n+1]}...: syntax error: invalid arithmetic operator`);if(t[n]===\"[\"){let d=t.slice(n).trim();return{expr:{type:\"ArithNumberSubscript\",number:c,errorToken:d},pos:t.length}}return{expr:{type:\"ArithNumber\",value:ge(c)},pos:n}}if(t[n]===\"$\"&&t[n+1]===\"{\"){let c=n+2,u=1,f=c;for(;f<t.length&&u>0;)t[f]===\"{\"?u++:t[f]===\"}\"&&u--,u>0&&f++;let h=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 g=t.slice(d+1,m);return{expr:{type:\"ArithDynamicBase\",baseExpr:h,value:g},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 g=t.slice(d,m);return{expr:{type:\"ArithDynamicNumber\",prefix:h,suffix:g},pos:m}}return n=d,{expr:{type:\"ArithBracedExpansion\",content:h},pos:n}}if(t[n]===\"$\"&&n+1<t.length&&/[0-9]/.test(t[n+1])){n++;let c=\"\";for(;n<t.length&&/[0-9]/.test(t[n]);)c+=t[n],n++;return{expr:{type:\"ArithVariable\",name:c,hasDollarPrefix:!0},pos:n}}if(t[n]===\"$\"&&n+1<t.length&&/[*@#?\\-!$]/.test(t[n+1])){let c=t[n+1];return n+=2,{expr:{type:\"ArithSpecialVar\",name:c},pos:n}}let o=!1;if(t[n]===\"$\"&&n+1<t.length&&/[a-zA-Z_]/.test(t[n+1])&&(o=!0,n++),n<t.length&&/[a-zA-Z_]/.test(t[n])){let c=\"\";for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)c+=t[n],n++;if(t[n]===\"[\"&&!s){n++;let u;if(t[n]===\"'\"||t[n]==='\"'){let h=t[n];for(n++,u=\"\";n<t.length&&t[n]!==h;)u+=t[n],n++;t[n]===h&&n++,n=$(t,n),t[n]===\"]\"&&n++}let f;if(u===void 0){let{expr:h,pos:d}=Z(e,t,n);f=h,n=d,t[n]===\"]\"&&n++}if(n=$(t,n),t[n]===\"[\"&&f)return{expr:{type:\"ArithDoubleSubscript\",array:c,index:f},pos:n};if(!s){for(let h of Re)if(t.slice(n,n+h.length)===h&&t.slice(n,n+h.length+1)!==\"==\"){n+=h.length;let{expr:d,pos:m}=ye(e,t,n);return{expr:{type:\"ArithAssignment\",operator:h,variable:c,subscript:f,stringKey:u,value:d},pos:m}}}return{expr:{type:\"ArithArrayElement\",array:c,index:f,stringKey:u},pos:n}}if(n=$(t,n),!s){for(let u of Re)if(t.slice(n,n+u.length)===u&&t.slice(n,n+u.length+1)!==\"==\"){n+=u.length;let{expr:f,pos:h}=ye(e,t,n);return{expr:{type:\"ArithAssignment\",operator:u,variable:c,value:f},pos:h}}}return{expr:{type:\"ArithVariable\",name:c,hasDollarPrefix:o},pos:n}}if(t[n]===\"#\"){let c=n+1;for(;c<t.length&&t[c]!==`\n`;)c++;let u=t.slice(n,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:n}}var w={script(e){return{type:\"Script\",statements:e}},statement(e,t=[],r=!1,s,n){let a={type:\"Statement\",pipelines:e,operators:t,background:r};return s&&(a.deferredError=s),n!==void 0&&(a.sourceText=n),a},pipeline(e,t=!1,r=!1,s=!1,n){return{type:\"Pipeline\",commands:e,negated:t,timed:r,timePosix:s,pipeStderr:n}},simpleCommand(e,t=[],r=[],s=[]){return{type:\"SimpleCommand\",name:e,args:t,assignments:r,redirections:s}},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,r=!1,s=null){return{type:\"Assignment\",name:e,value:t,append:r,array:s}},redirection(e,t,r=null,s){let n={type:\"Redirection\",fd:r,operator:e,target:t};return s&&(n.fdVariable=s),n},hereDoc(e,t,r=!1,s=!1){return{type:\"HereDoc\",delimiter:e,content:t,stripTabs:r,quoted:s}},ifNode(e,t=null,r=[]){return{type:\"If\",clauses:e,elseBody:t,redirections:r}},forNode(e,t,r,s=[]){return{type:\"For\",variable:e,words:t,body:r,redirections:s}},whileNode(e,t,r=[]){return{type:\"While\",condition:e,body:t,redirections:r}},untilNode(e,t,r=[]){return{type:\"Until\",condition:e,body:t,redirections:r}},caseNode(e,t,r=[]){return{type:\"Case\",word:e,items:t,redirections:r}},caseItem(e,t,r=\";;\"){return{type:\"CaseItem\",patterns:e,body:t,terminator:r}},subshell(e,t=[]){return{type:\"Subshell\",body:e,redirections:t}},group(e,t=[]){return{type:\"Group\",body:e,redirections:t}},functionDef(e,t,r=[],s){return{type:\"FunctionDef\",name:e,body:t,redirections:r,sourceFile:s}},conditionalCommand(e,t=[],r){return{type:\"ConditionalCommand\",expression:e,redirections:t,line:r}},arithmeticCommand(e,t=[],r){return{type:\"ArithmeticCommand\",expression:e,redirections:t,line:r}}};var p;(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\"})(p||(p={}));var pe=class extends Error{line;column;constructor(t,r,s){super(`line ${r}: ${t}`),this.line=r,this.column=s,this.name=\"LexerError\"}},Bt=new Map([[\"if\",p.IF],[\"then\",p.THEN],[\"else\",p.ELSE],[\"elif\",p.ELIF],[\"fi\",p.FI],[\"for\",p.FOR],[\"while\",p.WHILE],[\"until\",p.UNTIL],[\"do\",p.DO],[\"done\",p.DONE],[\"case\",p.CASE],[\"esac\",p.ESAC],[\"in\",p.IN],[\"function\",p.FUNCTION],[\"select\",p.SELECT],[\"time\",p.TIME],[\"coproc\",p.COPROC]]);function Ft(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let r=e.slice(t[0].length);if(r===\"\"||r===\"+\")return!0;if(r[0]===\"[\"){let s=0,n=0;for(;n<r.length;n++)if(r[n]===\"[\")s++;else if(r[n]===\"]\"&&(s--,s===0))break;if(s!==0||n>=r.length)return!1;let a=r.slice(n+1);return a===\"\"||a===\"+\"}return!1}function zt(e){let t=0;for(let r=0;r<e.length;r++){let s=e[r];if(s===\"[\")t++;else if(s===\"]\")t--;else{if(t===0&&s===\"=\")return r;if(t===0&&s===\"+\"&&e[r+1]===\"=\")return r+1}}return-1}var Dr=[[\";\",\";\",\"&\",p.SEMI_SEMI_AND],[\"<\",\"<\",\"<\",p.TLESS],[\"&\",\">\",\">\",p.AND_DGREAT]],xr=[[\"[\",\"[\",p.DBRACK_START],[\"]\",\"]\",p.DBRACK_END],[\"(\",\"(\",p.DPAREN_START],[\")\",\")\",p.DPAREN_END],[\"&\",\"&\",p.AND_AND],[\"|\",\"|\",p.OR_OR],[\";\",\";\",p.DSEMI],[\";\",\"&\",p.SEMI_AND],[\"|\",\"&\",p.PIPE_AMP],[\">\",\">\",p.DGREAT],[\"<\",\"&\",p.LESSAND],[\">\",\"&\",p.GREATAND],[\"<\",\">\",p.LESSGREAT],[\">\",\"|\",p.CLOBBER],[\"&\",\">\",p.AND_GREAT]],_r=new Map([[\"|\",p.PIPE],[\"&\",p.AMP],[\";\",p.SEMICOLON],[\"(\",p.LPAREN],[\")\",p.RPAREN],[\"<\",p.LESS],[\">\",p.GREAT]]);function $r(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Gt(e){return e===\" \"||e===\"\t\"||e===`\n`||e===\";\"||e===\"&\"||e===\"|\"||e===\"(\"||e===\")\"||e===\"<\"||e===\">\"}var ve=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];dparenDepth=0;maxHeredocSize;constructor(t,r){this.input=t,this.maxHeredocSize=r?.maxHeredocSize??10485760}tokenize(){let r=this.input.length,s=this.tokens,n=this.pendingHeredocs;for(;this.pos<r;){if(n.length>0&&s.length>0&&s[s.length-1].type===p.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=r)break;let a=this.nextToken();a&&s.push(a)}return s.push({type:p.EOF,value:\"\",start:this.pos,end:this.pos,line:this.line,column:this.column}),s}skipWhitespace(){let t=this.input,r=t.length,s=this.pos,n=this.column,a=this.line;for(;s<r;){let i=t[s];if(i===\" \"||i===\"\t\")s++,n++;else if(i===\"\\\\\"&&t[s+1]===`\n`)s+=2,a++,n=1;else break}this.pos=s,this.column=n,this.line=a}nextToken(){let t=this.input,r=this.pos,s=this.line,n=this.column,a=t[r],i=t[r+1],l=t[r+2];if(a===\"#\"&&this.dparenDepth===0)return this.readComment(r,s,n);if(a===`\n`)return this.pos=r+1,this.line++,this.column=1,{type:p.NEWLINE,value:`\n`,start:r,end:r+1,line:s,column:n};if(a===\"<\"&&i===\"<\"&&l===\"-\")return this.pos=r+3,this.column=n+3,this.registerHeredocFromLookahead(!0),this.makeToken(p.DLESSDASH,\"<<-\",r,s,n);for(let[c,u,f,h]of Dr)if(a===c&&i===u&&l===f)return this.pos=r+3,this.column=n+3,this.makeToken(h,c+u+f,r,s,n);if(a===\"<\"&&i===\"<\")return this.pos=r+2,this.column=n+2,this.registerHeredocFromLookahead(!1),this.makeToken(p.DLESS,\"<<\",r,s,n);if(a===\"(\"&&i===\"(\")return this.dparenDepth>0?(this.pos=r+1,this.column=n+1,this.dparenDepth++,this.makeToken(p.LPAREN,\"(\",r,s,n)):this.looksLikeNestedSubshells(r+2)||this.dparenClosesWithSpacedParens(r+2)?(this.pos=r+1,this.column=n+1,this.makeToken(p.LPAREN,\"(\",r,s,n)):(this.pos=r+2,this.column=n+2,this.dparenDepth=1,this.makeToken(p.DPAREN_START,\"((\",r,s,n));if(a===\")\"&&i===\")\")return this.dparenDepth===1?(this.pos=r+2,this.column=n+2,this.dparenDepth=0,this.makeToken(p.DPAREN_END,\"))\",r,s,n)):this.dparenDepth>1?(this.pos=r+1,this.column=n+1,this.dparenDepth--,this.makeToken(p.RPAREN,\")\",r,s,n)):(this.pos=r+1,this.column=n+1,this.makeToken(p.RPAREN,\")\",r,s,n));for(let[c,u,f]of xr)if(!(c===\"(\"&&u===\"(\"||c===\")\"&&u===\")\")&&!(this.dparenDepth>0&&c===\";\"&&(f===p.DSEMI||f===p.SEMI_AND||f===p.SEMI_SEMI_AND))&&a===c&&i===u){if(f===p.DBRACK_START||f===p.DBRACK_END){let h=t[r+2];if(h!==void 0&&h!==\" \"&&h!==\"\t\"&&h!==`\n`&&h!==\";\"&&h!==\"&\"&&h!==\"|\"&&h!==\"(\"&&h!==\")\"&&h!==\"<\"&&h!==\">\")break}return this.pos=r+2,this.column=n+2,this.makeToken(f,c+u,r,s,n)}if(a===\"(\"&&this.dparenDepth>0)return this.pos=r+1,this.column=n+1,this.dparenDepth++,this.makeToken(p.LPAREN,\"(\",r,s,n);if(a===\")\"&&this.dparenDepth>1)return this.pos=r+1,this.column=n+1,this.dparenDepth--,this.makeToken(p.RPAREN,\")\",r,s,n);let o=_r.get(a);if(o!==void 0)return this.pos=r+1,this.column=n+1,this.makeToken(o,a,r,s,n);if(a===\"{\"){let c=this.scanFdVariable(r);return c!==null?(this.pos=c.end,this.column=n+(c.end-r),{type:p.FD_VARIABLE,value:c.varname,start:r,end:c.end,line:s,column:n}):i===\"}\"?(this.pos=r+2,this.column=n+2,{type:p.WORD,value:\"{}\",start:r,end:r+2,line:s,column:n,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(r)!==null?this.readWordWithBraceExpansion(r,s,n):this.scanLiteralBraceWord(r)!==null?this.readWordWithBraceExpansion(r,s,n):i!==void 0&&i!==\" \"&&i!==\"\t\"&&i!==`\n`?this.readWord(r,s,n):(this.pos=r+1,this.column=n+1,this.makeToken(p.LBRACE,\"{\",r,s,n))}return a===\"}\"?this.isWordCharFollowing(r+1)?this.readWord(r,s,n):(this.pos=r+1,this.column=n+1,this.makeToken(p.RBRACE,\"}\",r,s,n)):a===\"!\"?i===\"=\"?(this.pos=r+2,this.column=n+2,this.makeToken(p.WORD,\"!=\",r,s,n)):(this.pos=r+1,this.column=n+1,this.makeToken(p.BANG,\"!\",r,s,n)):this.readWord(r,s,n)}looksLikeNestedSubshells(t){let r=this.input,s=r.length,n=t;for(;n<s&&(r[n]===\" \"||r[n]===\"\t\");)n++;if(n>=s)return!1;let a=r[n];if(a===\"(\")return this.looksLikeNestedSubshells(n+1);let i=/[a-zA-Z_]/.test(a),l=a===\"!\"||a===\"[\";if(!i&&!l)return!1;let o=n;for(;o<s&&/[a-zA-Z0-9_\\-.]/.test(r[o]);)o++;if(o===n)return l;let c=o;for(;c<s&&(r[c]===\" \"||r[c]===\"\t\");)c++;if(c>=s)return!1;let u=r[c];if(u===\"=\"&&r[c+1]!==\"=\"||u===`\n`||o===c&&/[+\\-*/%<>&|^!~?:]/.test(u)&&u!==\"-\"||u===\")\"&&r[c+1]===\")\")return!1;if(c>o&&(u===\"-\"||u==='\"'||u===\"'\"||u===\"$\"||/[a-zA-Z_/.]/.test(u))){let f=c;for(;f<s&&r[f]!==`\n`;){if(r[f]===\")\")return!0;f++}return!1}if(u===\")\"){let f=c+1;for(;f<s&&(r[f]===\" \"||r[f]===\"\t\");)f++;if(r[f]===\"|\"&&r[f+1]===\"|\"||r[f]===\"&\"&&r[f+1]===\"&\"||r[f]===\";\"||r[f]===\"|\"&&r[f+1]!==\"|\")return!0}return!1}makeToken(t,r,s,n,a){return{type:t,value:r,start:s,end:this.pos,line:n,column:a}}readComment(t,r,s){let n=this.input,a=n.length,i=this.pos;for(;i<a&&n[i]!==`\n`;)i++;let l=n.slice(t,i);return this.pos=i,this.column=s+(i-t),{type:p.COMMENT,value:l,start:t,end:i,line:r,column:s}}readWord(t,r,s){let n=this.input,a=n.length,i=this.pos,l=i;for(;i<a;){let y=n[i];if(y===\" \"||y===\"\t\"||y===`\n`||y===\";\"||y===\"&\"||y===\"|\"||y===\"(\"||y===\")\"||y===\"<\"||y===\">\"||y===\"'\"||y==='\"'||y===\"\\\\\"||y===\"$\"||y===\"`\"||y===\"{\"||y===\"}\"||y===\"~\"||y===\"*\"||y===\"?\"||y===\"[\")break;i++}if(i>l){let y=n[i];if(!(y===\"(\"&&i>l&&\"@*+?!\".includes(n[i-1]))){if(i>=a||y===\" \"||y===\"\t\"||y===`\n`||y===\";\"||y===\"&\"||y===\"|\"||y===\"(\"||y===\")\"||y===\"<\"||y===\">\"){let b=n.slice(l,i);this.pos=i,this.column=s+(i-l);let D=Bt.get(b);if(D!==void 0)return{type:D,value:b,start:t,end:i,line:r,column:s};let Q=zt(b);return Q>0&&Ft(b.slice(0,Q))?{type:p.ASSIGNMENT_WORD,value:b,start:t,end:i,line:r,column:s}:/^[0-9]+$/.test(b)?{type:p.NUMBER,value:b,start:t,end:i,line:r,column:s}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)?{type:p.NAME,value:b,start:t,end:i,line:r,column:s,quoted:!1,singleQuoted:!1}:{type:p.WORD,value:b,start:t,end:i,line:r,column:s,quoted:!1,singleQuoted:!1}}}}i=this.pos;let o=this.column,c=this.line,u=\"\",f=!1,h=!1,d=!1,m=!1,g=n[i]==='\"'||n[i]===\"'\",E=!1,A=0;for(;i<a;){let y=n[i];if(!d&&!m){if(y===\"(\"&&u.length>0&&\"@*+?!\".includes(u[u.length-1])){let b=this.scanExtglobPattern(i);if(b!==null){u+=b.content,i=b.end,o+=b.content.length;continue}}if(y===\"[\"&&A===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){let b=i+1<a?n[i+1]:\"\";if(b===\"^\"||b===\"!\"){u+=y,i++,o++;continue}A=1,u+=y,i++,o++;continue}}else if(y===\"[\"&&A>0){u.length>0&&u[u.length-1]!==\"\\\\\"&&A++,u+=y,i++,o++;continue}else if(y===\"]\"&&A>0){u.length>0&&u[u.length-1]!==\"\\\\\"&&A--,u+=y,i++,o++;continue}if(A>0){if(y===`\n`)break;u+=y,i++,o++;continue}if(y===\" \"||y===\"\t\"||y===`\n`||y===\";\"||y===\"&\"||y===\"|\"||y===\"(\"||y===\")\"||y===\"<\"||y===\">\")break}if(y===\"$\"&&i+1<a&&n[i+1]===\"'\"&&!d&&!m){for(u+=\"$'\",i+=2,o+=2;i<a&&n[i]!==\"'\";)n[i]===\"\\\\\"&&i+1<a?(u+=n[i]+n[i+1],i+=2,o+=2):(u+=n[i],i++,o++);i<a&&(u+=\"'\",i++,o++);continue}if(y===\"$\"&&i+1<a&&n[i+1]==='\"'&&!d&&!m){i++,o++,m=!0,f=!0,u===\"\"&&(g=!0),i++,o++;continue}if(y===\"'\"&&!m){if(d)if(d=!1,!g||E)u+=y;else{let b=i+1<a?n[i+1]:\"\";b&&!Gt(b)&&b!==\"'\"&&(b==='\"'?(E=!0,u+=y,h=!1,f=!1):(E=!0,u+=y))}else d=!0,g&&!E?(h=!0,f=!0):u+=y;i++,o++;continue}if(y==='\"'&&!d){if(m)if(m=!1,!g||E)u+=y;else{let b=i+1<a?n[i+1]:\"\";b&&!Gt(b)&&b!=='\"'&&(b===\"'\"?(E=!0,u+=y,h=!1,f=!1):(E=!0,u+=y))}else m=!0,g&&!E?f=!0:u+=y;i++,o++;continue}if(y===\"\\\\\"&&!d&&i+1<a){let b=n[i+1];if(b===`\n`){i+=2,c++,o=1;continue}if(m){if(b==='\"'||b===\"\\\\\"||b===\"$\"||b===\"`\"||b===`\n`){if(b===`\n`){i+=2,o=1,c++;continue}u+=y+b,i+=2,o+=2;continue}}else{b===\"\\\\\"||b==='\"'||b===\"'\"||b===\"`\"||b===\"*\"||b===\"?\"||b===\"[\"||b===\"]\"||b===\"(\"||b===\")\"||b===\"$\"||b===\"-\"||b===\".\"||b===\"^\"||b===\"+\"||b===\"{\"||b===\"}\"?u+=y+b:u+=b,i+=2,o+=2;continue}}if(y===\"$\"&&i+1<a&&n[i+1]===\"(\"&&!d){u+=y,i++,o++,u+=n[i],i++,o++;let b=1,D=!1,Q=!1,ie=0,H=!1,B=\"\",Ne=n[i]===\"(\"&&!this.dollarDparenIsSubshell(i);for(;b>0&&i<a;){let _=n[i];if(u+=_,D)_===\"'\"&&(D=!1);else if(Q)_===\"\\\\\"&&i+1<a?(u+=n[i+1],i++,o++):_==='\"'&&(Q=!1);else if(_===\"'\")D=!0,B=\"\";else if(_==='\"')Q=!0,B=\"\";else if(_===\"\\\\\"&&i+1<a)u+=n[i+1],i++,o++,B=\"\";else if(_===\"$\"&&i+1<a&&n[i+1]===\"{\"){i++,o++,u+=n[i],i++,o++;let Be=1,ke=!1,Fe=!1;for(;Be>0&&i<a;){let Y=n[i];if(Y===\"\\\\\"&&i+1<a&&!ke){u+=Y,i++,o++,u+=n[i],i++,o++;continue}u+=Y,ke?Y===\"'\"&&(ke=!1):Fe?Y==='\"'&&(Fe=!1):Y===\"'\"?ke=!0:Y==='\"'?Fe=!0:Y===\"{\"?Be++:Y===\"}\"&&Be--,Y===`\n`?(c++,o=0):o++,i++}B=\"\";continue}else if(_===\"#\"&&!Ne&&(B===\"\"||/\\s/.test(n[i-1]||\"\"))){for(;i+1<a&&n[i+1]!==`\n`;)i++,o++,u+=n[i];B=\"\"}else/[a-zA-Z_]/.test(_)?B+=_:(B===\"case\"?(ie++,H=!1):B===\"in\"&&ie>0?H=!0:B===\"esac\"&&ie>0&&(ie--,H=!1),B=\"\",_===\"(\"?i>0&&n[i-1]===\"$\"?b++:H||b++:_===\")\"?H?H=!1:b--:_===\";\"&&ie>0&&(i+1<a&&n[i+1]===\";\"||i+1<a&&n[i+1]===\"&\")&&(H=!0));_===`\n`&&(c++,o=0,B=\"\"),i++,o++}continue}if(y===\"$\"&&i+1<a&&n[i+1]===\"[\"&&!d){u+=y,i++,o++,u+=n[i],i++,o++;let b=1;for(;b>0&&i<a;){let D=n[i];u+=D,D===\"[\"?b++:D===\"]\"?b--:D===`\n`&&(c++,o=0),i++,o++}continue}if(y===\"$\"&&i+1<a&&n[i+1]===\"{\"&&!d){u+=y,i++,o++,u+=n[i],i++,o++;let b=1,D=!1,Q=!1,ie=c,H=o,B=c,Ne=o;for(;b>0&&i<a;){let _=n[i];if(_===\"\\\\\"&&i+1<a&&n[i+1]===`\n`){i+=2,c++,o=1;continue}if(_===\"\\\\\"&&i+1<a&&!D){u+=_,i++,o++,u+=n[i],i++,o++;continue}u+=_,D?_===\"'\"&&(D=!1):Q?_==='\"'&&(Q=!1):_===\"'\"?(D=!0,ie=c,H=o):_==='\"'?(Q=!0,B=c,Ne=o):_===\"{\"?b++:_===\"}\"&&b--,_===`\n`&&(c++,o=0),i++,o++}if(D)throw new pe(\"unexpected EOF while looking for matching `''\",ie,H);if(Q)throw new pe(\"unexpected EOF while looking for matching `\\\"'\",B,Ne);continue}if(y===\"$\"&&i+1<a&&!d){let b=n[i+1];if(b===\"#\"||b===\"?\"||b===\"$\"||b===\"!\"||b===\"@\"||b===\"*\"||b===\"-\"||b>=\"0\"&&b<=\"9\"){u+=y+b,i+=2,o+=2;continue}}if(y===\"`\"&&!d){for(u+=y,i++,o++;i<a&&n[i]!==\"`\";){let b=n[i];u+=b,b===\"\\\\\"&&i+1<a&&(u+=n[i+1],i++,o++),b===`\n`&&(c++,o=0),i++,o++}i<a&&(u+=n[i],i++,o++);continue}u+=y,i++,y===`\n`?(c++,o=1):o++}if(this.pos=i,this.column=o,this.line=c,E&&g&&(u=n[t]+u,f=!1,h=!1),d||m){let y=d?\"'\":'\"';throw new pe(`unexpected EOF while looking for matching \\`${y}'`,r,s)}if(!g&&u.length>=2){if(u[0]===\"'\"&&u[u.length-1]===\"'\"){let y=u.slice(1,-1);!y.includes(\"'\")&&!y.includes('\"')&&(u=y,f=!0,h=!0)}else if(u[0]==='\"'&&u[u.length-1]==='\"'){let y=u.slice(1,-1),b=!1;for(let D=0;D<y.length;D++){if(y[D]==='\"'){b=!0;break}y[D]===\"\\\\\"&&D+1<y.length&&D++}b||(u=y,f=!0,h=!1)}}if(u===\"\")return{type:p.WORD,value:\"\",start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h};let S=Bt.get(u);if(!f&&S!==void 0)return{type:S,value:u,start:t,end:i,line:r,column:s};if(!g){let y=zt(u);if(y>0&&Ft(u.slice(0,y)))return{type:p.ASSIGNMENT_WORD,value:u,start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h}}return/^[0-9]+$/.test(u)?{type:p.NUMBER,value:u,start:t,end:i,line:r,column:s}:$r(u)?{type:p.NAME,value:u,start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h}:{type:p.WORD,value:u,start:t,end:i,line:r,column:s,quoted:f,singleQuoted:h}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let t=this.pendingHeredocs.shift();if(!t)break;let r=this.pos,s=this.line,n=this.column,a=\"\";for(;this.pos<this.input.length;){let i=\"\";for(;this.pos<this.input.length&&this.input[this.pos]!==`\n`;)i+=this.input[this.pos],this.pos++,this.column++;if((t.stripTabs?i.replace(/^\\t+/,\"\"):i)===t.delimiter){this.pos<this.input.length&&this.input[this.pos]===`\n`&&(this.pos++,this.line++,this.column=1);break}if(a+=i,a.length>this.maxHeredocSize)throw new pe(`Heredoc size limit exceeded (${this.maxHeredocSize} bytes)`,s,n);this.pos<this.input.length&&this.input[this.pos]===`\n`&&(a+=`\n`,this.pos++,this.line++,this.column=1)}this.tokens.push({type:p.HEREDOC_CONTENT,value:a,start:r,end:this.pos,line:s,column:n})}}addPendingHeredoc(t,r,s){this.pendingHeredocs.push({delimiter:t,stripTabs:r,quoted:s})}registerHeredocFromLookahead(t){let r=this.pos,s=this.column;for(;this.pos<this.input.length&&(this.input[this.pos]===\" \"||this.input[this.pos]===\"\t\");)this.pos++,this.column++;let n=\"\",a=!1;for(;this.pos<this.input.length;){let i=this.input[this.pos];if(/[\\s;<>&|()]/.test(i))break;if(i===\"'\"||i==='\"'){a=!0;let l=i;for(this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]!==l;)n+=this.input[this.pos],this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]===l&&(this.pos++,this.column++)}else i===\"\\\\\"?(a=!0,this.pos++,this.column++,this.pos<this.input.length&&(n+=this.input[this.pos],this.pos++,this.column++)):(n+=i,this.pos++,this.column++)}this.pos=r,this.column=s,n&&this.pendingHeredocs.push({delimiter:n,stripTabs:t,quoted:a})}isWordCharFollowing(t){if(t>=this.input.length)return!1;let r=this.input[t];return!(r===\" \"||r===\"\t\"||r===`\n`||r===\";\"||r===\"&\"||r===\"|\"||r===\"(\"||r===\")\"||r===\"<\"||r===\">\")}readWordWithBraceExpansion(t,r,s){let n=this.input,a=n.length,i=t,l=s;for(;i<a;){let c=n[i];if(c===\" \"||c===\"\t\"||c===`\n`||c===\";\"||c===\"&\"||c===\"|\"||c===\"(\"||c===\")\"||c===\"<\"||c===\">\")break;if(c===\"{\"){if(this.scanBraceExpansion(i)!==null){let f=1;for(i++,l++;i<a&&f>0;)n[i]===\"{\"?f++:n[i]===\"}\"&&f--,i++,l++;continue}i++,l++;continue}if(c===\"}\"){i++,l++;continue}if(c===\"$\"&&i+1<a&&n[i+1]===\"(\"){i++,l++,i++,l++;let u=1;for(;u>0&&i<a;)n[i]===\"(\"?u++:n[i]===\")\"&&u--,i++,l++;continue}if(c===\"$\"&&i+1<a&&n[i+1]===\"{\"){i++,l++,i++,l++;let u=1;for(;u>0&&i<a;)n[i]===\"{\"?u++:n[i]===\"}\"&&u--,i++,l++;continue}if(c===\"`\"){for(i++,l++;i<a&&n[i]!==\"`\";)n[i]===\"\\\\\"&&i+1<a?(i+=2,l+=2):(i++,l++);i<a&&(i++,l++);continue}i++,l++}let o=n.slice(t,i);return this.pos=i,this.column=l,{type:p.WORD,value:o,start:t,end:i,line:r,column:s,quoted:!1,singleQuoted:!1}}scanBraceExpansion(t){let r=this.input,s=r.length,n=t+1,a=1,i=!1,l=!1;for(;n<s&&a>0;){let o=r[n];if(o===\"{\")a++,n++;else if(o===\"}\")a--,n++;else if(o===\",\"&&a===1)i=!0,n++;else if(o===\".\"&&n+1<s&&r[n+1]===\".\")l=!0,n+=2;else{if(o===\" \"||o===\"\t\"||o===`\n`||o===\";\"||o===\"&\"||o===\"|\")return null;n++}}return a===0&&(i||l)?r.slice(t,n):null}scanLiteralBraceWord(t){let r=this.input,s=r.length,n=t+1,a=1;for(;n<s&&a>0;){let i=r[n];if(i===\"{\")a++,n++;else if(i===\"}\"){if(a--,a===0)return r.slice(t,n+1);n++}else{if(i===\" \"||i===\"\t\"||i===`\n`||i===\";\"||i===\"&\"||i===\"|\")return null;n++}}return null}scanExtglobPattern(t){let r=this.input,s=r.length,n=t+1,a=1;for(;n<s&&a>0;){let i=r[n];if(i===\"\\\\\"&&n+1<s){n+=2;continue}if(\"@*+?!\".includes(i)&&n+1<s&&r[n+1]===\"(\"){n++,a++,n++;continue}if(i===\"(\")a++,n++;else if(i===\")\")a--,n++;else{if(i===`\n`)return null;n++}}return a===0?{content:r.slice(t,n),end:n}:null}scanFdVariable(t){let r=this.input,s=r.length,n=t+1,a=n;for(;n<s;){let u=r[n];if(n===a){if(!(u>=\"a\"&&u<=\"z\"||u>=\"A\"&&u<=\"Z\"||u===\"_\"))return null}else if(!(u>=\"a\"&&u<=\"z\"||u>=\"A\"&&u<=\"Z\"||u>=\"0\"&&u<=\"9\"||u===\"_\"))break;n++}if(n===a)return null;let i=r.slice(a,n);if(n>=s||r[n]!==\"}\"||(n++,n>=s))return null;let l=r[n],o=n+1<s?r[n+1]:\"\";return l===\">\"||l===\"<\"||l===\"&\"&&(o===\">\"||o===\"<\")?{varname:i,end:n}:null}dollarDparenIsSubshell(t){let r=this.input,s=r.length,n=t+1,a=2,i=!1,l=!1,o=!1;for(;n<s&&a>0;){let c=r[n];if(i){c===\"'\"&&(i=!1),c===`\n`&&(o=!0),n++;continue}if(l){if(c===\"\\\\\"){n+=2;continue}c==='\"'&&(l=!1),c===`\n`&&(o=!0),n++;continue}if(c===\"'\"){i=!0,n++;continue}if(c==='\"'){l=!0,n++;continue}if(c===\"\\\\\"){n+=2;continue}if(c===`\n`&&(o=!0),c===\"(\"){a++,n++;continue}if(c===\")\"){if(a--,a===1){let u=n+1;if(u<s&&r[u]===\")\")return!1;let f=u,h=!1;for(;f<s&&(r[f]===\" \"||r[f]===\"\t\"||r[f]===`\n`);)h=!0,f++;if(h&&f<s&&r[f]===\")\"||o)return!0}if(a===0)return!1;n++;continue}n++}return!1}dparenClosesWithSpacedParens(t){let r=this.input,s=r.length,n=t,a=2,i=!1,l=!1;for(;n<s&&a>0;){let o=r[n];if(i){o===\"'\"&&(i=!1),n++;continue}if(l){if(o===\"\\\\\"){n+=2;continue}o==='\"'&&(l=!1),n++;continue}if(o===\"'\"){i=!0,n++;continue}if(o==='\"'){l=!0,n++;continue}if(o===\"\\\\\"){n+=2;continue}if(o===\"(\"){a++,n++;continue}if(o===\")\"){if(a--,a===1){let c=n+1;if(c<s&&r[c]===\")\")return!1;let u=c,f=!1;for(;u<s&&(r[u]===\" \"||r[u]===\"\t\"||r[u]===`\n`);)f=!0,u++;if(f&&u<s&&r[u]===\")\")return!0}if(a===0)return!1;n++;continue}if(a===1&&(o===\"|\"&&n+1<s&&r[n+1]===\"|\"||o===\"&\"&&n+1<s&&r[n+1]===\"&\"||o===\"|\"&&n+1<s&&r[n+1]!==\"|\"))return!0;n++}return!1}};var Qe=1e6,Ze=1e5,Qt=1e6,Ue=200,Zt=new Set([p.LESS,p.GREAT,p.DLESS,p.DGREAT,p.LESSAND,p.GREATAND,p.LESSGREAT,p.DLESSDASH,p.CLOBBER,p.TLESS,p.AND_GREAT,p.AND_DGREAT]),Ut=new Set([p.LESS,p.GREAT,p.DLESS,p.DGREAT,p.LESSAND,p.GREATAND,p.LESSGREAT,p.DLESSDASH,p.CLOBBER,p.TLESS]),Ht=new Set([p.LESS,p.GREAT,p.DLESS,p.DGREAT,p.LESSAND,p.GREATAND,p.LESSGREAT,p.DLESSDASH,p.CLOBBER,p.TLESS,p.AND_GREAT,p.AND_DGREAT]),G=class extends Error{line;column;token;constructor(t,r,s,n=void 0){super(`Parse error at ${r}:${s}: ${t}`),this.line=r,this.column=s,this.token=n,this.name=\"ParseException\"}};function Cr(e){let t=\"\",r=0;for(;r<e.length;){let s=e[r];if(s<128){t+=String.fromCharCode(s),r++;continue}if((s&224)===192){if(r+1<e.length&&(e[r+1]&192)===128&&s>=194){let n=(s&31)<<6|e[r+1]&63;t+=String.fromCharCode(n),r+=2;continue}t+=String.fromCharCode(s),r++;continue}if((s&240)===224){if(r+2<e.length&&(e[r+1]&192)===128&&(e[r+2]&192)===128){if(s===224&&e[r+1]<160){t+=String.fromCharCode(s),r++;continue}let n=(s&15)<<12|(e[r+1]&63)<<6|e[r+2]&63;if(n>=55296&&n<=57343){t+=String.fromCharCode(s),r++;continue}t+=String.fromCharCode(n),r+=3;continue}t+=String.fromCharCode(s),r++;continue}if((s&248)===240&&s<=244){if(r+3<e.length&&(e[r+1]&192)===128&&(e[r+2]&192)===128&&(e[r+3]&192)===128){if(s===240&&e[r+1]<144){t+=String.fromCharCode(s),r++;continue}let n=(s&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63;if(n>1114111){t+=String.fromCharCode(s),r++;continue}t+=String.fromCodePoint(n),r+=4;continue}t+=String.fromCharCode(s),r++;continue}t+=String.fromCharCode(s),r++}return t}function Kt(e,t,r){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_-]/.test(t[s]);)s++;return s}function He(e,t,r,s,n){let a=1,i=r+1;for(;i<t.length&&a>0;)t[i]===s?a++:t[i]===n&&a--,a>0&&i++;return a===0?i:-1}function fe(e,t,r){let s=r,n=1;for(;s<t.length&&n>0;){let a=t[s];if(a===\"\\\\\"&&s+1<t.length){s+=2;continue}if(a===\"'\"){let i=t.indexOf(\"'\",s+1);if(i!==-1){s=i+1;continue}}if(a==='\"'){for(s++;s<t.length&&t[s]!=='\"';)t[s]===\"\\\\\"&&s+1<t.length?s+=2:s++;s<t.length&&s++;continue}a===\"{\"?n++:a===\"}\"&&n--,n>0&&s++}return s}function Xt(e,t,r){let s=r,n=!1;for(;s<t.length;){let a=t[s];if(a===\"/\"&&n||a===\"}\")break;if(a===\"'\"){let i=t.indexOf(\"'\",s+1);if(i!==-1){s=i+1,n=!0;continue}}if(a==='\"'){for(s++;s<t.length&&t[s]!=='\"';)t[s]===\"\\\\\"&&s+1<t.length?s+=2:s++;s<t.length&&s++,n=!0;continue}a===\"\\\\\"?(s+=2,n=!0):(s++,n=!0)}return s}function Jt(e,t,r){let s=r,n=\"\";for(;s<t.length;){let a=t[s];if(a===\"*\"||a===\"?\")n+=a,s++;else if(a===\"[\"){let i=Or(t,s);i===-1?(n+=a,s++):(n+=t.slice(s,i+1),s=i+1)}else break}return{pattern:n,endIndex:s}}function Or(e,t){let r=t+1;for(r<e.length&&e[r]===\"^\"&&r++,r<e.length&&e[r]===\"]\"&&r++;r<e.length;){let s=e[r];if(s===\"\\\\\"&&r+1<e.length){let n=e[r+1];if(n==='\"'||n===\"'\")return-1;r+=2;continue}if(s===\"]\")return r;if(s==='\"'||s===\"$\"||s===\"`\")return-1;if(s===\"'\"){let n=e.indexOf(\"'\",r+1);if(n!==-1){r=n+1;continue}}if(s===\"[\"&&r+1<e.length&&e[r+1]===\":\"){let n=e.indexOf(\":]\",r+2);if(n!==-1){r=n+2;continue}}if(s===\"[\"&&r+1<e.length&&(e[r+1]===\".\"||e[r+1]===\"=\")){let a=`${e[r+1]}]`,i=e.indexOf(a,r+2);if(i!==-1){r=i+2;continue}}r++}return-1}function Yt(e,t,r){let s=\"\",n=r;for(;n<t.length&&t[n]!==\"'\";){let a=t[n];if(a===\"\\\\\"&&n+1<t.length)switch(t[n+1]){case\"n\":s+=`\n`,n+=2;break;case\"t\":s+=\"\t\",n+=2;break;case\"r\":s+=\"\\r\",n+=2;break;case\"\\\\\":s+=\"\\\\\",n+=2;break;case\"'\":s+=\"'\",n+=2;break;case'\"':s+='\"',n+=2;break;case\"a\":s+=\"\\x07\",n+=2;break;case\"b\":s+=\"\\b\",n+=2;break;case\"e\":case\"E\":s+=\"\\x1B\",n+=2;break;case\"f\":s+=\"\\f\",n+=2;break;case\"v\":s+=\"\\v\",n+=2;break;case\"x\":{let l=[],o=n;for(;o+1<t.length&&t[o]===\"\\\\\"&&t[o+1]===\"x\";){let c=t.slice(o+2,o+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)l.push(u),o+=2+c.length;else break}l.length>0?(s+=Cr(l),n=o):(s+=\"\\\\x\",n+=2);break}case\"u\":{let l=t.slice(n+2,n+6),o=parseInt(l,16);Number.isNaN(o)?(s+=\"\\\\u\",n+=2):(s+=String.fromCharCode(o),n+=6);break}case\"c\":{if(n+2<t.length){let o=t[n+2].charCodeAt(0)&31;s+=String.fromCharCode(o),n+=3}else s+=\"\\\\c\",n+=2;break}case\"0\":case\"1\":case\"2\":case\"3\":case\"4\":case\"5\":case\"6\":case\"7\":{let l=\"\",o=n+1;for(;o<t.length&&o<n+4&&/[0-7]/.test(t[o]);)l+=t[o],o++;let c=parseInt(l,8);s+=String.fromCharCode(c),n=o;break}default:s+=a,n++}else s+=a,n++}return n<t.length&&t[n]===\"'\"&&n++,{part:w.literal(s),endIndex:n}}function je(e,t){let r=t.trim();return r===\"\"?{type:\"ArithmeticExpression\",expression:{type:\"ArithNumber\",value:0}}:M(e,r)}function jt(e){let t=[],r=\"\",s=0;for(let n=0;n<e.length;n++){let a=e[n];a===\"{\"?(s++,r+=a):a===\"}\"?(s--,r+=a):a===\",\"&&s===0?(t.push(r),r=\"\"):r+=a}return t.push(r),t}function en(e,t,r,s){let n=He(e,t,r,\"{\",\"}\");if(n===-1)return null;let a=t.slice(r+1,n),i=a.match(/^(-?\\d+)\\.\\.(-?\\d+)(?:\\.\\.(-?\\d+))?$/);if(i)return{part:{type:\"BraceExpansion\",items:[{type:\"Range\",start:Number.parseInt(i[1],10),end:Number.parseInt(i[2],10),step:i[3]?Number.parseInt(i[3],10):void 0,startStr:i[1],endStr:i[2]}]},endIndex:n+1};let l=a.match(/^([a-zA-Z])\\.\\.([a-zA-Z])(?:\\.\\.(-?\\d+))?$/);return l?{part:{type:\"BraceExpansion\",items:[{type:\"Range\",start:l[1],end:l[2],step:l[3]?Number.parseInt(l[3],10):void 0}]},endIndex:n+1}:a.includes(\",\")&&s?{part:{type:\"BraceExpansion\",items:jt(a).map(u=>({type:\"Word\",word:w.word(s(e,u,!1,!1,!1))}))},endIndex:n+1}:a.includes(\",\")?{part:{type:\"BraceExpansion\",items:jt(a).map(u=>({type:\"Word\",word:w.word([w.literal(u)])}))},endIndex:n+1}:null}function Ke(e,t){let r=\"\";for(let s of t.parts)switch(s.type){case\"Literal\":r+=s.value;break;case\"SingleQuoted\":r+=`'${s.value}'`;break;case\"Escaped\":r+=s.value;break;case\"DoubleQuoted\":r+='\"';for(let n of s.parts)n.type===\"Literal\"||n.type===\"Escaped\"?r+=n.value:n.type===\"ParameterExpansion\"&&(r+=`\\${${n.parameter}}`);r+='\"';break;case\"ParameterExpansion\":r+=`\\${${s.parameter}}`;break;case\"Glob\":r+=s.pattern;break;case\"TildeExpansion\":r+=\"~\",s.user&&(r+=s.user);break;case\"BraceExpansion\":{r+=\"{\";let n=[];for(let a of s.items)if(a.type===\"Range\"){let i=a.startStr??String(a.start),l=a.endStr??String(a.end);a.step!==void 0?n.push(`${i}..${l}..${a.step}`):n.push(`${i}..${l}`)}else n.push(Ke(e,a.word));n.length===1&&s.items[0].type===\"Range\"?r+=n[0]:r+=n.join(\",\"),r+=\"}\";break}default:r+=s.type}return r}function tn(e,t){return{[p.LESS]:\"<\",[p.GREAT]:\">\",[p.DGREAT]:\">>\",[p.LESSAND]:\"<&\",[p.GREATAND]:\">&\",[p.LESSGREAT]:\"<>\",[p.CLOBBER]:\">|\",[p.TLESS]:\"<<<\",[p.AND_GREAT]:\"&>\",[p.AND_DGREAT]:\"&>>\",[p.DLESS]:\"<\",[p.DLESSDASH]:\"<\"}[t]||\">\"}function De(e){let t=e.current(),r=t.type;if(r===p.NUMBER){let s=e.peek(1);return t.end!==s.start?!1:Ut.has(s.type)}if(r===p.FD_VARIABLE){let s=e.peek(1);return Ht.has(s.type)}return Zt.has(r)}function xe(e){let t=null,r;e.check(p.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(p.FD_VARIABLE)&&(r=e.advance().value);let s=e.advance(),n=tn(e,s.type);if(s.type===p.DLESS||s.type===p.DLESSDASH)return Lr(e,n,t,s.type===p.DLESSDASH);e.isWord()||e.error(\"Expected redirection target\");let a=e.parseWord();return w.redirection(n,a,t,r)}function Lr(e,t,r,s){e.isWord()||e.error(\"Expected here-document delimiter\");let n=e.advance(),a=n.value,i=n.quoted||!1;(a.startsWith(\"'\")&&a.endsWith(\"'\")||a.startsWith('\"')&&a.endsWith('\"'))&&(a=a.slice(1,-1));let l=w.redirection(s?\"<<-\":\"<<\",w.hereDoc(a,w.word([]),s,i),r);return e.addPendingHeredoc(l,a,s,i),l}function rn(e){let t=e.current().line,r=[],s=null,n=[],a=[];for(;e.check(p.ASSIGNMENT_WORD)||De(e);)e.checkIterationLimit(),e.check(p.ASSIGNMENT_WORD)?r.push(Wr(e)):a.push(xe(e));if(e.isWord())s=e.parseWord();else if(r.length>0&&(e.check(p.DBRACK_START)||e.check(p.DPAREN_START))){let l=e.advance();s=w.word([w.literal(l.value)])}for(;(!e.isStatementEnd()||e.check(p.RBRACE))&&!e.check(p.PIPE,p.PIPE_AMP);)if(e.checkIterationLimit(),De(e))a.push(xe(e));else if(e.check(p.RBRACE)){let l=e.advance();n.push(e.parseWordFromString(l.value,!1,!1))}else if(e.check(p.LBRACE)){let l=e.advance();n.push(e.parseWordFromString(l.value,!1,!1))}else if(e.check(p.DBRACK_END)){let l=e.advance();n.push(e.parseWordFromString(l.value,!1,!1))}else if(e.isWord())n.push(e.parseWord());else if(e.check(p.ASSIGNMENT_WORD)){let l=e.advance(),o=l.value,c=o.endsWith(\"=\"),u=o.endsWith(\"=(\");if((c||u)&&(u||e.check(p.LPAREN))){let f=u?o.slice(0,-2):o.slice(0,-1);u||e.expect(p.LPAREN);let h=Xe(e);e.expect(p.RPAREN);let d=h.map(g=>Ke(e,g)),m=`${f}=(${d.join(\" \")})`;n.push(e.parseWordFromString(m,!1,!1))}else n.push(e.parseWordFromString(o,l.quoted,l.singleQuoted))}else if(e.check(p.LPAREN))e.error(\"syntax error near unexpected token `('\");else break;let i=w.simpleCommand(s,n,r,a);return i.line=t,i}function Wr(e){let t=e.expect(p.ASSIGNMENT_WORD),r=t.value,s=r.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);s||e.error(`Invalid assignment: ${r}`);let n=s[0],a,i=n.length;if(r[i]===\"[\"){let f=0,h=i+1;for(;i<r.length;i++)if(r[i]===\"[\")f++;else if(r[i]===\"]\"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${r}`),a=r.slice(h,i),i++}let l=r[i]===\"+\";l&&i++,r[i]!==\"=\"&&e.error(`Invalid assignment: ${r}`),i++;let o=r.slice(i);if(o===\"(\"){let f=Xe(e);e.expect(p.RPAREN);let h=a!==void 0?`${n}[${a}]`:n;return w.assignment(h,null,l,f)}if(o===\"\"&&e.check(p.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let h=Xe(e);e.expect(p.RPAREN);let d=a!==void 0?`${n}[${a}]`:n;return w.assignment(d,null,l,h)}}let c=o?e.parseWordFromString(o,t.quoted,t.singleQuoted,!0):null,u=a!==void 0?`${n}[${a}]`:n;return w.assignment(u,c,l,null)}var Tr=new Set([p.AMP,p.PIPE,p.PIPE_AMP,p.SEMICOLON,p.AND_AND,p.OR_OR,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND]);function Xe(e){let t=[];for(e.skipNewlines();!e.check(p.RPAREN,p.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):Tr.has(e.current().type)?e.error(`syntax error near unexpected token \\`${e.current().value}'`):e.advance(),e.skipNewlines();return t}function Je(e,t){e.expect(p.IF);let r=[],s=e.parseCompoundList();e.expect(p.THEN);let n=e.parseCompoundList();if(n.length===0){let l=e.check(p.FI)?\"fi\":e.check(p.ELSE)?\"else\":e.check(p.ELIF)?\"elif\":\"fi\";e.error(`syntax error near unexpected token \\`${l}'`)}for(r.push({condition:s,body:n});e.check(p.ELIF);){e.advance();let l=e.parseCompoundList();e.expect(p.THEN);let o=e.parseCompoundList();if(o.length===0){let c=e.check(p.FI)?\"fi\":e.check(p.ELSE)?\"else\":e.check(p.ELIF)?\"elif\":\"fi\";e.error(`syntax error near unexpected token \\`${c}'`)}r.push({condition:l,body:o})}let a=null;e.check(p.ELSE)&&(e.advance(),a=e.parseCompoundList(),a.length===0&&e.error(\"syntax error near unexpected token `fi'\")),e.expect(p.FI);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.ifNode(r,a,i)}function Ye(e,t){let r=e.expect(p.FOR);if(e.check(p.DPAREN_START))return Vr(e,t,r.line);e.isWord()||e.error(\"Expected variable name in for loop\");let n=e.advance().value,a=null;if(e.skipNewlines(),e.check(p.IN))for(e.advance(),a=[];!e.check(p.SEMICOLON,p.NEWLINE,p.DO,p.EOF)&&e.isWord();)a.push(e.parseWord());e.check(p.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(p.DO);let i=e.parseCompoundList();e.expect(p.DONE);let l=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.forNode(n,a,i,l)}function Vr(e,t,r){e.expect(p.DPAREN_START);let s=null,n=null,a=null,i=[\"\",\"\",\"\"],l=0,o=0;for(;!e.check(p.DPAREN_END,p.EOF);){let f=e.advance();if(f.type===p.SEMICOLON&&o===0){if(l++,l>2)break}else f.value===\"(\"&&o++,f.value===\")\"&&o--,i[l]+=f.value}e.expect(p.DPAREN_END),i[0].trim()&&(s=M(e,i[0].trim())),i[1].trim()&&(n=M(e,i[1].trim())),i[2].trim()&&(a=M(e,i[2].trim())),e.skipNewlines(),e.check(p.SEMICOLON)&&e.advance(),e.skipNewlines();let c;e.check(p.LBRACE)?(e.advance(),c=e.parseCompoundList(),e.expect(p.RBRACE)):(e.expect(p.DO),c=e.parseCompoundList(),e.expect(p.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:\"CStyleFor\",init:s,condition:n,update:a,body:c,redirections:u,line:r}}function et(e,t){e.expect(p.WHILE);let r=e.parseCompoundList();e.expect(p.DO);let s=e.parseCompoundList();s.length===0&&e.error(\"syntax error near unexpected token `done'\"),e.expect(p.DONE);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.whileNode(r,s,n)}function tt(e,t){e.expect(p.UNTIL);let r=e.parseCompoundList();e.expect(p.DO);let s=e.parseCompoundList();s.length===0&&e.error(\"syntax error near unexpected token `done'\"),e.expect(p.DONE);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.untilNode(r,s,n)}function nt(e,t){e.expect(p.CASE),e.isWord()||e.error(\"Expected word after 'case'\");let r=e.parseWord();e.skipNewlines(),e.expect(p.IN),e.skipNewlines();let s=[];for(;!e.check(p.ESAC,p.EOF);){e.checkIterationLimit();let a=e.getPos(),i=qr(e);if(i&&s.push(i),e.skipNewlines(),e.getPos()===a&&!i)break}e.expect(p.ESAC);let n=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.caseNode(r,s,n)}function qr(e){e.check(p.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(p.PIPE));)e.advance();if(t.length===0)return null;e.expect(p.RPAREN),e.skipNewlines();let r=[];for(;!e.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND,p.ESAC,p.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===p.RPAREN&&e.error(\"syntax error near unexpected token `)'\"),e.check(p.LPAREN)&&e.peek(1).type===p.WORD&&e.error(`syntax error near unexpected token \\`${e.peek(1).value}'`);let n=e.getPos(),a=e.parseStatement();if(a&&r.push(a),e.skipSeparators(!1),e.getPos()===n&&!a)break}let s=\";;\";return e.check(p.DSEMI)?(e.advance(),s=\";;\"):e.check(p.SEMI_AND)?(e.advance(),s=\";&\"):e.check(p.SEMI_SEMI_AND)&&(e.advance(),s=\";;&\"),w.caseItem(t,r,s)}function rt(e,t){e.expect(p.LPAREN);let r=e.parseCompoundList();e.expect(p.RPAREN);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.subshell(r,s)}function st(e,t){e.expect(p.LBRACE);let r=e.parseCompoundList();e.expect(p.RBRACE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return w.group(r,s)}var Fr=[\"-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\"],zr=[\"==\",\"!=\",\"=~\",\"<\",\">\",\"-eq\",\"-ne\",\"-lt\",\"-le\",\"-gt\",\"-ge\",\"-nt\",\"-ot\",\"-ef\"];function sn(e){return e.isWord()||e.check(p.LBRACE)||e.check(p.RBRACE)||e.check(p.ASSIGNMENT_WORD)}function an(e){if(e.check(p.BANG)&&e.peek(1).type===p.LPAREN){e.advance(),e.advance();let t=1,r=\"!(\";for(;t>0&&!e.check(p.EOF);)if(e.check(p.LPAREN))t++,r+=\"(\",e.advance();else if(e.check(p.RPAREN))t--,t>0&&(r+=\")\"),e.advance();else if(e.isWord())r+=e.advance().value;else if(e.check(p.PIPE))r+=\"|\",e.advance();else break;return r+=\")\",e.parseWordFromString(r,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function at(e){return e.skipNewlines(),Gr(e)}function Gr(e){let t=on(e);for(e.skipNewlines();e.check(p.OR_OR);){e.advance(),e.skipNewlines();let r=on(e);t={type:\"CondOr\",left:t,right:r},e.skipNewlines()}return t}function on(e){let t=it(e);for(e.skipNewlines();e.check(p.AND_AND);){e.advance(),e.skipNewlines();let r=it(e);t={type:\"CondAnd\",left:t,right:r},e.skipNewlines()}return t}function it(e){return e.skipNewlines(),e.check(p.BANG)?(e.advance(),e.skipNewlines(),{type:\"CondNot\",operand:it(e)}):Qr(e)}function Qr(e){if(e.check(p.LPAREN)){e.advance();let t=at(e);return e.expect(p.RPAREN),{type:\"CondGroup\",expression:t}}if(sn(e)){let t=e.current(),r=t.value;if(Fr.includes(r)&&!t.quoted){if(e.advance(),e.check(p.DBRACK_END)&&e.error(`Expected operand after ${r}`),sn(e)){let a=e.parseWordNoBraceExpansion();return{type:\"CondUnary\",operator:r,operand:a}}let n=e.current();e.error(`unexpected argument \\`${n.value}' to conditional unary operator`)}let s=e.parseWordNoBraceExpansion();if(e.isWord()&&zr.includes(e.current().value)){let n=e.advance().value,a;return n===\"=~\"?a=Zr(e):n===\"==\"||n===\"!=\"?a=an(e):a=e.parseWordNoBraceExpansion(),{type:\"CondBinary\",operator:n,left:s,right:a}}if(e.check(p.LESS)){e.advance();let n=e.parseWordNoBraceExpansion();return{type:\"CondBinary\",operator:\"<\",left:s,right:n}}if(e.check(p.GREAT)){e.advance();let n=e.parseWordNoBraceExpansion();return{type:\"CondBinary\",operator:\">\",left:s,right:n}}if(e.isWord()&&e.current().value===\"=\"){e.advance();let n=an(e);return{type:\"CondBinary\",operator:\"==\",left:s,right:n}}return{type:\"CondWord\",word:s}}e.error(\"Expected conditional expression\")}function Zr(e){let t=[],r=0,s=-1,n=e.getInput(),a=()=>e.check(p.DBRACK_END)||e.check(p.AND_AND)||e.check(p.OR_OR)||e.check(p.NEWLINE)||e.check(p.EOF);for(;!a();){let i=e.current(),l=s>=0&&i.start>s;if(r===0&&l)break;if(r>0&&l){let o=n.slice(s,i.start);t.push({type:\"Literal\",value:o})}if(e.isWord()||e.check(p.ASSIGNMENT_WORD)){let o=e.parseWordForRegex();t.push(...o.parts),s=e.peek(-1).end}else if(e.check(p.LPAREN)){let o=e.advance();t.push({type:\"Literal\",value:\"(\"}),r++,s=o.end}else if(e.check(p.DPAREN_START)){let o=e.advance();t.push({type:\"Literal\",value:\"((\"}),r+=2,s=o.end}else if(e.check(p.DPAREN_END))if(r>=2){let o=e.advance();t.push({type:\"Literal\",value:\"))\"}),r-=2,s=o.end}else{if(r===1)break;break}else if(e.check(p.RPAREN))if(r>0){let o=e.advance();t.push({type:\"Literal\",value:\")\"}),r--,s=o.end}else break;else if(e.check(p.PIPE)){let o=e.advance();t.push({type:\"Literal\",value:\"|\"}),s=o.end}else if(e.check(p.SEMICOLON))if(r>0){let o=e.advance();t.push({type:\"Literal\",value:\";\"}),s=o.end}else break;else if(r>0&&e.check(p.LESS)){let o=e.advance();t.push({type:\"Literal\",value:\"<\"}),s=o.end}else if(r>0&&e.check(p.GREAT)){let o=e.advance();t.push({type:\"Literal\",value:\">\"}),s=o.end}else if(r>0&&e.check(p.DGREAT)){let o=e.advance();t.push({type:\"Literal\",value:\">>\"}),s=o.end}else if(r>0&&e.check(p.DLESS)){let o=e.advance();t.push({type:\"Literal\",value:\"<<\"}),s=o.end}else if(r>0&&e.check(p.LESSAND)){let o=e.advance();t.push({type:\"Literal\",value:\"<&\"}),s=o.end}else if(r>0&&e.check(p.GREATAND)){let o=e.advance();t.push({type:\"Literal\",value:\">&\"}),s=o.end}else if(r>0&&e.check(p.LESSGREAT)){let o=e.advance();t.push({type:\"Literal\",value:\"<>\"}),s=o.end}else if(r>0&&e.check(p.CLOBBER)){let o=e.advance();t.push({type:\"Literal\",value:\">|\"}),s=o.end}else if(r>0&&e.check(p.TLESS)){let o=e.advance();t.push({type:\"Literal\",value:\"<<<\"}),s=o.end}else if(r>0&&e.check(p.AMP)){let o=e.advance();t.push({type:\"Literal\",value:\"&\"}),s=o.end}else if(r>0&&e.check(p.LBRACE)){let o=e.advance();t.push({type:\"Literal\",value:\"{\"}),s=o.end}else if(r>0&&e.check(p.RBRACE)){let o=e.advance();t.push({type:\"Literal\",value:\"}\"}),s=o.end}else break}return t.length===0&&e.error(\"Expected regex pattern after =~\"),{type:\"Word\",parts:t}}function Ee(e){return e.length>0?e:[w.literal(\"\")]}function Hr(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n===\"\\\\\"){s+=2;continue}if(\"@*+?!\".includes(n)&&s+1<e.length&&e[s+1]===\"(\"){s++,r++,s++;continue}if(n===\"(\")r++;else if(n===\")\"&&(r--,r===0))return s;s++}return-1}function jr(e,t,r){let s=r+1,n=t[s];if(\"@*#?$!-0123456789\".includes(n))return{part:w.parameterExpansion(n),endIndex:s+1};let a=\"\";for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)a+=t[s],s++;return{part:w.parameterExpansion(a),endIndex:s}}function Kr(e,t,r,s=!1){let n=r+2,a=!1;t[n]===\"!\"&&(a=!0,n++);let i=!1;t[n]===\"#\"&&!/[}:#%/^,]/.test(t[n+1]||\"}\")&&(i=!0,n++);let l=\"\",o=t[n];if(/[@*#?$!-]/.test(o)&&!/[a-zA-Z0-9_]/.test(t[n+1]||\"\"))l=o,n++;else for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)l+=t[n],n++;if(t[n]===\"[\"){let u=He(e,t,n,\"[\",\"]\");if(l+=t.slice(n,u+1),n=u+1,t[n]===\"[\"){let f=1,h=n;for(;h<t.length&&f>0;)t[h]===\"{\"?f++:t[h]===\"}\"&&f--,f>0&&h++;let d=t.slice(r+2,h);return{part:w.parameterExpansion(\"\",{type:\"BadSubstitution\",text:d}),endIndex:h+1}}}if(l===\"\"&&!a&&!i&&t[n]!==\"}\"){let u=1,f=n;for(;f<t.length&&u>0;)t[f]===\"{\"?u++:t[f]===\"}\"&&u--,u>0&&f++;if(u>0)throw new G(\"unexpected EOF while looking for matching '}'\",0,0);let h=t.slice(r+2,f);return{part:w.parameterExpansion(\"\",{type:\"BadSubstitution\",text:h}),endIndex:f+1}}let c=null;if(a){let u=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(u)if(n<t.length&&t[n]!==\"}\"&&/[:=\\-+?#%/^,@]/.test(t[n])){let f=ot(e,t,n,l,s);f.operation?(c={type:\"Indirection\",innerOp:f.operation},n=f.endIndex):(c={type:\"ArrayKeys\",array:u[1],star:u[2]===\"*\"},l=\"\")}else c={type:\"ArrayKeys\",array:u[1],star:u[2]===\"*\"},l=\"\";else if(t[n]===\"*\"||t[n]===\"@\"&&!/[QPaAEKkuUL]/.test(t[n+1]||\"\")){let f=t[n];n++,c={type:\"VarNamePrefix\",prefix:l,star:f===\"*\"},l=\"\"}else if(n<t.length&&t[n]!==\"}\"&&/[:=\\-+?#%/^,@]/.test(t[n])){let f=ot(e,t,n,l,s);f.operation?(c={type:\"Indirection\",innerOp:f.operation},n=f.endIndex):c={type:\"Indirection\"}}else c={type:\"Indirection\"}}else if(i)if(t[n]===\":\")for(c={type:\"LengthSliceError\"};n<t.length&&t[n]!==\"}\";)n++;else t[n]!==\"}\"&&/[-+=?]/.test(t[n])?e.error(`\\${#${l}${t.slice(n,t.indexOf(\"}\",n))}}: bad substitution`):t[n]===\"/\"?e.error(`\\${#${l}${t.slice(n,t.indexOf(\"}\",n))}}: bad substitution`):c={type:\"Length\"};if(!c&&n<t.length&&t[n]!==\"}\"){let u=ot(e,t,n,l,s);c=u.operation,n=u.endIndex}if(n<t.length&&t[n]!==\"}\"){let u=t[n];if(!/[:\\-+=?#%/^,@[]/.test(u)){let f=n;for(;f<t.length&&t[f]!==\"}\";)f++;let h=t.slice(r,f+1);e.error(`\\${${h.slice(2,-1)}}: bad substitution`)}}for(;n<t.length&&t[n]!==\"}\";)n++;if(n>=t.length)throw new G(\"unexpected EOF while looking for matching '}'\",0,0);return{part:w.parameterExpansion(l,c),endIndex:n+1}}function ot(e,t,r,s,n=!1){let a=r,i=t[a],l=t[a+1]||\"\";if(i===\":\"){let o=l;if(\"-=?+\".includes(o)){a+=2;let A=fe(e,t,a),S=t.slice(a,A),y=ae(e,S,!1,!1,!0,!1,n,!1,!1,!0),b=w.word(Ee(y));if(o===\"-\")return{operation:{type:\"DefaultValue\",word:b,checkEmpty:!0},endIndex:A};if(o===\"=\")return{operation:{type:\"AssignDefault\",word:b,checkEmpty:!0},endIndex:A};if(o===\"?\")return{operation:{type:\"ErrorIfUnset\",word:b,checkEmpty:!0},endIndex:A};if(o===\"+\")return{operation:{type:\"UseAlternative\",word:b,checkEmpty:!0},endIndex:A}}a++;let c=fe(e,t,a),u=t.slice(a,c),f=-1,h=0,d=0;for(let E=0;E<u.length;E++){let A=u[E];if(A===\"(\"||A===\"[\")h++;else if(A===\")\"||A===\"]\")h--;else if(A===\"?\"&&h===0)d++;else if(A===\":\"&&h===0)if(d>0)d--;else{f=E;break}}let m=f>=0?u.slice(0,f):u,g=f>=0?u.slice(f+1):null;return{operation:{type:\"Substring\",offset:je(e,m),length:g!==null?je(e,g):null},endIndex:c}}if(\"-=?+\".includes(i)){a++;let o=fe(e,t,a),c=t.slice(a,o),u=ae(e,c,!1,!1,!0,!1,n,!1,!1,!0),f=w.word(Ee(u));if(i===\"-\")return{operation:{type:\"DefaultValue\",word:f,checkEmpty:!1},endIndex:o};if(i===\"=\")return{operation:{type:\"AssignDefault\",word:f,checkEmpty:!1},endIndex:o};if(i===\"?\")return{operation:{type:\"ErrorIfUnset\",word:c?f:null,checkEmpty:!1},endIndex:o};if(i===\"+\")return{operation:{type:\"UseAlternative\",word:f,checkEmpty:!1},endIndex:o}}if(i===\"#\"||i===\"%\"){let o=l===i,c=i===\"#\"?\"prefix\":\"suffix\";a+=o?2:1;let u=fe(e,t,a),f=t.slice(a,u),h=ae(e,f,!1,!1,!1);return{operation:{type:\"PatternRemoval\",pattern:w.word(Ee(h)),side:c,greedy:o},endIndex:u}}if(i===\"/\"){let o=l===\"/\";a+=o?2:1;let c=null;t[a]===\"#\"?(c=\"start\",a++):t[a]===\"%\"&&(c=\"end\",a++);let u;c!==null&&(t[a]===\"/\"||t[a]===\"}\")?u=a:u=Xt(e,t,a);let f=t.slice(a,u),h=ae(e,f,!1,!1,!1),d=w.word(Ee(h)),m=null,g=u;if(t[u]===\"/\"){let E=u+1,A=fe(e,t,E),S=t.slice(E,A),y=ae(e,S,!1,!1,!1);m=w.word(Ee(y)),g=A}return{operation:{type:\"PatternReplacement\",pattern:d,replacement:m,all:o,anchor:c},endIndex:g}}if(i===\"^\"||i===\",\"){let o=l===i,c=i===\"^\"?\"upper\":\"lower\";a+=o?2:1;let u=fe(e,t,a),f=t.slice(a,u),h=f?w.word([w.literal(f)]):null;return{operation:{type:\"CaseModification\",direction:c,all:o,pattern:h},endIndex:u}}return i===\"@\"&&/[QPaAEKkuUL]/.test(l)?{operation:{type:\"Transform\",operator:l},endIndex:a+2}:{operation:null,endIndex:a}}function lt(e,t,r,s=!1){let n=r+1;if(n>=t.length)return{part:w.literal(\"$\"),endIndex:n};let a=t[n];if(a===\"(\"&&t[n+1]===\"(\")return e.isDollarDparenSubshell(t,r)?e.parseCommandSubstitution(t,r):e.parseArithmeticExpansion(t,r);if(a===\"[\"){let i=1,l=n+1;for(;l<t.length&&i>0;)t[l]===\"[\"?i++:t[l]===\"]\"&&i--,i>0&&l++;if(i===0){let o=t.slice(n+1,l),c=M(e,o);return{part:w.arithmeticExpansion(c),endIndex:l+1}}}return a===\"(\"?e.parseCommandSubstitution(t,r):a===\"{\"?Kr(e,t,r,s):/[a-zA-Z_0-9@*#?$!-]/.test(a)?jr(e,t,r):{part:w.literal(\"$\"),endIndex:n}}function ln(e,t){let r=[],s=0,n=\"\",a=()=>{n&&(r.push(w.literal(n)),n=\"\")};for(;s<t.length;){let i=t[s];if(i===\"\\\\\"&&s+1<t.length){let l=t[s+1];if(l===\"$\"||l===\"`\"||l==='\"'||l===\"\\\\\"){n+=l,s+=2;continue}n+=i,s++;continue}if(i===\"$\"){a();let{part:l,endIndex:o}=lt(e,t,s,!0);l&&r.push(l),s=o;continue}if(i===\"`\"){a();let{part:l,endIndex:o}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=o;continue}n+=i,s++}return a(),r}function Xr(e,t,r){let s=[],n=r,a=\"\",i=()=>{a&&(s.push(w.literal(a)),a=\"\")};for(;n<t.length&&t[n]!=='\"';){let l=t[n];if(l===\"\\\\\"&&n+1<t.length){let o=t[n+1];if('\"\\\\$`\\n'.includes(o)){a+=o,n+=2;continue}a+=l,n++;continue}if(l===\"$\"){i();let{part:o,endIndex:c}=lt(e,t,n,!0);o&&s.push(o),n=c;continue}if(l===\"`\"){i();let{part:o,endIndex:c}=e.parseBacktickSubstitution(t,n,!0);s.push(o),n=c;continue}a+=l,n++}return i(),{part:w.doubleQuoted(s),endIndex:n}}function ae(e,t,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1,o=!1,c=!1){if(s)return[w.singleQuoted(t)];if(r){let m=ln(e,t);return[w.doubleQuoted(m)]}if(t.length>=2&&t[0]==='\"'&&t[t.length-1]==='\"'){let m=t.slice(1,-1),g=!1;for(let E=0;E<m.length;E++){if(m[E]==='\"'){g=!0;break}m[E]===\"\\\\\"&&E+1<m.length&&E++}if(!g){let E=ln(e,m);return[w.doubleQuoted(E)]}}let u=[],f=0,h=\"\",d=()=>{h&&(u.push(w.literal(h)),h=\"\")};for(;f<t.length;){let m=t[f];if(m===\"\\\\\"&&f+1<t.length){let g=t[f+1];if(o){d(),u.push(w.escaped(g)),f+=2;continue}let E=a?g===\"$\"||g===\"`\"||g===`\n`:g===\"$\"||g===\"`\"||g==='\"'||g===\"'\"||g===`\n`||c&&g===\"}\",A=i?\"*?[]\\\\\".includes(g):\"*?[]\\\\(){}.^+\".includes(g);E?h+=g:A?(d(),u.push(w.escaped(g))):h+=`\\\\${g}`,f+=2;continue}if(m===\"'\"&&!i&&!a){d();let g=t.indexOf(\"'\",f+1);if(g===-1){h+=t.slice(f);break}u.push(w.singleQuoted(t.slice(f+1,g))),f=g+1;continue}if(m==='\"'&&!a){d();let{part:g,endIndex:E}=Xr(e,t,f+1);u.push(g),f=E+1;continue}if(m===\"$\"&&t[f+1]===\"'\"){d();let{part:g,endIndex:E}=Yt(e,t,f+2);u.push(g),f=E;continue}if(m===\"$\"){d();let{part:g,endIndex:E}=lt(e,t,f);g&&u.push(g),f=E;continue}if(m===\"`\"){d();let{part:g,endIndex:E}=e.parseBacktickSubstitution(t,f);u.push(g),f=E;continue}if(m===\"~\"){let g=f>0?t[f-1]:\"\";if(f===0||g===\"=\"||n&&g===\":\"){let A=Kt(e,t,f),S=t[A];if(S===void 0||S===\"/\"||S===\":\"){d();let y=t.slice(f+1,A)||null;u.push({type:\"TildeExpansion\",user:y}),f=A;continue}}}if(\"@*+?!\".includes(m)&&f+1<t.length&&t[f+1]===\"(\"){let g=Hr(t,f+1);if(g!==-1){d();let E=t.slice(f,g+1);u.push({type:\"Glob\",pattern:E}),f=g+1;continue}}if(m===\"*\"||m===\"?\"||m===\"[\"){d();let{pattern:g,endIndex:E}=Jt(e,t,f);u.push({type:\"Glob\",pattern:g}),f=E;continue}if(m===\"{\"&&!n&&!l&&!a){let g=en(e,t,f,ae);if(g){d(),u.push(g.part),f=g.endIndex;continue}}h+=m,f++}return d(),u}function un(e,t){let r=e.length,s=t+3,n=2,a=!1,i=!1;for(;s<r&&n>0;){let l=e[s];if(a){l===\"'\"&&(a=!1),s++;continue}if(i){if(l===\"\\\\\"){s+=2;continue}l==='\"'&&(i=!1),s++;continue}if(l===\"'\"){a=!0,s++;continue}if(l==='\"'){i=!0,s++;continue}if(l===\"\\\\\"){s+=2;continue}if(l===\"(\"){n++,s++;continue}if(l===\")\"){if(n--,n===1){let o=s+1;return!(o<r&&e[o]===\")\")}if(n===0)return!1;s++;continue}if(n===1&&(l===\"|\"&&s+1<r&&e[s+1]===\"|\"||l===\"&\"&&s+1<r&&e[s+1]===\"&\"||l===\"|\"&&s+1<r&&e[s+1]!==\"|\"))return!0;s++}return!1}function cn(e,t,r,s){let n=t+2,a=1,i=n,l=!1,o=!1,c=0,u=!1,f=\"\";for(;i<e.length&&a>0;){let g=e[i];l?g===\"'\"&&(l=!1):o?g===\"\\\\\"&&i+1<e.length?i++:g==='\"'&&(o=!1):g===\"'\"?(l=!0,f=\"\"):g==='\"'?(o=!0,f=\"\"):g===\"\\\\\"&&i+1<e.length?(i++,f=\"\"):/[a-zA-Z_]/.test(g)?f+=g:(f===\"case\"?(c++,u=!1):f===\"in\"&&c>0?u=!0:f===\"esac\"&&c>0&&(c--,u=!1),f=\"\",g===\"(\"?i>0&&e[i-1]===\"$\"?a++:u||a++:g===\")\"?u?u=!1:a--:g===\";\"&&c>0&&i+1<e.length&&e[i+1]===\";\"&&(u=!0)),a>0&&i++}a>0&&s(\"unexpected EOF while looking for matching `)'\");let h=e.slice(n,i),m=r().parse(h);return{part:w.commandSubstitution(m,!1),endIndex:i+1}}function fn(e,t,r,s,n){let i=t+1,l=\"\";for(;i<e.length&&e[i]!==\"`\";)if(e[i]===\"\\\\\"){let u=e[i+1];u===\"$\"||u===\"`\"||u===\"\\\\\"||u===`\n`||r&&u==='\"'?(u!==`\n`&&(l+=u),i+=2):(l+=e[i],i++)}else l+=e[i],i++;i>=e.length&&n(\"unexpected EOF while looking for matching ``'\");let c=s().parse(l);return{part:w.commandSubstitution(c,!0),endIndex:i+1}}var V=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input=\"\";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Qt)throw new G(\"Maximum parse iterations exceeded (possible infinite loop)\",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Ue)throw new G(`Maximum parser nesting depth exceeded (${Ue})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(t,r){if(t.length>Qe)throw new G(`Input too large: ${t.length} bytes exceeds limit of ${Qe}`,1,1);this._input=t;let s=new ve(t,r);if(this.tokens=s.tokenize(),this.tokens.length>Ze)throw new G(`Too many tokens: ${this.tokens.length} exceeds limit of ${Ze}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,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,r,s,n,...a){let i=this.tokens[this.pos]?.type;return i===t||r!==void 0&&i===r||s!==void 0&&i===s||n!==void 0&&i===n?!0:a.length>0?a.includes(i):!1}expect(t,r){if(this.check(t))return this.advance();let s=this.current();throw new G(r||`Expected ${t}, got ${s.type}`,s.line,s.column,s)}error(t){let r=this.current();throw new G(t,r.line,r.column,r)}skipNewlines(){for(;this.check(p.NEWLINE,p.COMMENT);)this.check(p.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(p.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(p.SEMICOLON,p.COMMENT)){this.advance();continue}if(t&&this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,r,s,n){this.pendingHeredocs.push({redirect:t,delimiter:r,stripTabs:s,quoted:n})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(p.HEREDOC_CONTENT)){let r=this.advance(),s;t.quoted?s=w.word([w.literal(r.value)]):s=this.parseWordFromString(r.value,!1,!1,!1,!0),t.redirect.target=w.hereDoc(t.delimiter,s,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(p.EOF,p.NEWLINE,p.SEMICOLON,p.AMP,p.AND_AND,p.OR_OR,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.ASSIGNMENT_WORD||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.LPAREN||t===p.LBRACE||t===p.DPAREN_START||t===p.DBRACK_START||t===p.FUNCTION||t===p.BANG||t===p.TIME||t===p.IN||t===p.LESS||t===p.GREAT||t===p.DLESS||t===p.DGREAT||t===p.LESSAND||t===p.GREATAND||t===p.LESSGREAT||t===p.DLESSDASH||t===p.CLOBBER||t===p.TLESS||t===p.AND_GREAT||t===p.AND_DGREAT}parseScript(){let t=[],s=0;for(this.skipNewlines();!this.check(p.EOF);){s++,s>1e4&&this.error(\"Parser stuck: too many iterations (>10000)\");let n=this.checkUnexpectedToken();if(n){t.push(n),this.skipSeparators(!1);continue}let a=this.pos,i=this.parseStatement();i&&t.push(i),this.skipSeparators(!1),this.check(p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \\`${this.current().value}'`),this.pos===a&&!this.check(p.EOF)&&this.advance()}return w.script(t)}checkUnexpectedToken(){let t=this.current().type,r=this.current().value;if((t===p.DO||t===p.DONE||t===p.THEN||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.ESAC)&&this.error(`syntax error near unexpected token \\`${r}'`),t===p.RBRACE||t===p.RPAREN){let s=`syntax error near unexpected token \\`${r}'`;return this.advance(),w.statement([w.pipeline([w.simpleCommand(null,[],[],[])])],[],!1,{message:s,token:r})}return(t===p.DSEMI||t===p.SEMI_AND||t===p.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \\`${r}'`),t===p.SEMICOLON&&this.error(`syntax error near unexpected token \\`${r}'`),(t===p.PIPE||t===p.PIPE_AMP)&&this.error(`syntax error near unexpected token \\`${r}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,r=[],s=[],n=!1,a=this.parsePipeline();for(r.push(a);this.check(p.AND_AND,p.OR_OR);){let o=this.advance();s.push(o.type===p.AND_AND?\"&&\":\"||\"),this.skipNewlines();let c=this.parsePipeline();r.push(c)}this.check(p.AMP)&&(this.advance(),n=!0);let i=this.pos>0?this.tokens[this.pos-1].end:t,l=this._input.slice(t,i);return w.statement(r,s,n,void 0,l)}parsePipeline(){let t=!1,r=!1;this.check(p.TIME)&&(this.advance(),t=!0,this.check(p.WORD,p.NAME)&&this.current().value===\"-p\"&&(this.advance(),r=!0));let s=0;for(;this.check(p.BANG);)this.advance(),s++;let n=s%2===1,a=[],i=[],l=this.parseCommand();for(a.push(l);this.check(p.PIPE,p.PIPE_AMP);){let o=this.advance();this.skipNewlines(),i.push(o.type===p.PIPE_AMP);let c=this.parseCommand();a.push(c)}return w.pipeline(a,n,t,r,i.length>0?i:void 0)}parseCommand(){return this.check(p.IF)?Je(this):this.check(p.FOR)?Ye(this):this.check(p.WHILE)?et(this):this.check(p.UNTIL)?tt(this):this.check(p.CASE)?nt(this):this.check(p.LPAREN)?rt(this):this.check(p.LBRACE)?st(this):this.check(p.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(p.DBRACK_START)?this.parseConditionalCommand():this.check(p.FUNCTION)?this.parseFunctionDef():this.check(p.NAME,p.WORD)&&this.peek(1).type===p.LPAREN&&this.peek(2).type===p.RPAREN?this.parseFunctionDef():rn(this)}dparenClosesWithSpacedParens(){let t=1,r=1;for(;r<this.tokens.length-this.pos;){let s=this.peek(r);if(s.type===p.EOF)return!1;if(s.type===p.DPAREN_START||s.type===p.LPAREN)t++;else if(s.type===p.DPAREN_END){if(t-=2,t<=0)return!1}else if(s.type===p.RPAREN&&(t--,t===0&&this.peek(r+1).type===p.RPAREN))return!0;r++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(p.RPAREN),this.expect(p.RPAREN);let r=this.parseOptionalRedirections(),s=w.subshell(t,[]);return w.subshell([w.statement([w.pipeline([s],!1,!1,!1)])],r)}isWord(){let t=this.current().type;return t===p.WORD||t===p.NAME||t===p.NUMBER||t===p.IF||t===p.FOR||t===p.WHILE||t===p.UNTIL||t===p.CASE||t===p.FUNCTION||t===p.ELSE||t===p.ELIF||t===p.FI||t===p.THEN||t===p.DO||t===p.DONE||t===p.ESAC||t===p.IN||t===p.SELECT||t===p.TIME||t===p.COPROC||t===p.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,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1){let o=ae(this,t,r,s,n,a,!1,i,l);return w.word(o)}parseCommandSubstitution(t,r){return cn(t,r,()=>new e,s=>this.error(s))}parseBacktickSubstitution(t,r,s=!1){return fn(t,r,s,()=>new e,n=>this.error(n))}isDollarDparenSubshell(t,r){return un(t,r)}parseArithmeticExpansion(t,r){let s=r+3,n=1,a=0,i=s;for(;i<t.length-1&&n>0;)t[i]===\"$\"&&t[i+1]===\"(\"?t[i+2]===\"(\"?(n++,i+=3):(a++,i+=2):t[i]===\"(\"&&t[i+1]===\"(\"?(n++,i+=2):t[i]===\")\"&&t[i+1]===\")\"?a>0?(a--,i++):(n--,n>0&&(i+=2)):t[i]===\"(\"?(a++,i++):(t[i]===\")\"&&a>0&&a--,i++);let l=t.slice(s,i),o=this.parseArithmeticExpression(l);return{part:w.arithmeticExpansion(o),endIndex:i+2}}parseArithmeticCommand(){let t=this.expect(p.DPAREN_START),r=\"\",s=1,n=0,a=!1,i=!1;for(;s>0&&!this.check(p.EOF);){if(a){if(a=!1,n>0){n--,r+=\")\";continue}if(this.check(p.RPAREN)){s--,i=!0,this.advance();continue}if(this.check(p.DPAREN_END)){s--,i=!0;continue}r+=\")\";continue}if(this.check(p.DPAREN_START))s++,r+=\"((\",this.advance();else if(this.check(p.DPAREN_END))n>=2?(n-=2,r+=\"))\",this.advance()):n===1?(n--,r+=\")\",a=!0,this.advance()):(s--,i=!0,s>0&&(r+=\"))\"),this.advance());else if(this.check(p.LPAREN))n++,r+=\"(\",this.advance();else if(this.check(p.RPAREN))n>0&&n--,r+=\")\",this.advance();else{let c=this.current().value,u=r.length>0?r[r.length-1]:\"\";r.length>0&&!r.endsWith(\" \")&&!(c===\"=\"&&/[|&^+\\-*/%<>]$/.test(r))&&!(c===\"<\"&&u===\"<\")&&!(c===\">\"&&u===\">\")&&(r+=\" \"),r+=c,this.advance()}}i||this.expect(p.DPAREN_END);let l=this.parseArithmeticExpression(r.trim()),o=this.parseOptionalRedirections();return w.arithmeticCommand(l,o,t.line)}parseConditionalCommand(){let t=this.expect(p.DBRACK_START),r=at(this);this.expect(p.DBRACK_END);let s=this.parseOptionalRedirections();return w.conditionalCommand(r,s,t.line)}parseFunctionDef(){let t;if(this.check(p.FUNCTION)){if(this.advance(),this.check(p.NAME)||this.check(p.WORD))t=this.advance().value;else{let n=this.current();throw new G(\"Expected function name\",n.line,n.column,n)}this.check(p.LPAREN)&&(this.advance(),this.expect(p.RPAREN))}else t=this.advance().value,t.includes(\"$\")&&this.error(`\\`${t}': not a valid identifier`),this.expect(p.LPAREN),this.expect(p.RPAREN);this.skipNewlines();let r=this.parseCompoundCommandBody({forFunctionBody:!0}),s=this.parseOptionalRedirections();return w.functionDef(t,r,s)}parseCompoundCommandBody(t){let r=t?.forFunctionBody;if(this.check(p.LBRACE))return st(this,{skipRedirections:r});if(this.check(p.LPAREN))return rt(this,{skipRedirections:r});if(this.check(p.IF))return Je(this,{skipRedirections:r});if(this.check(p.FOR))return Ye(this,{skipRedirections:r});if(this.check(p.WHILE))return et(this,{skipRedirections:r});if(this.check(p.UNTIL))return tt(this,{skipRedirections:r});if(this.check(p.CASE))return nt(this,{skipRedirections:r});this.error(\"Expected compound command for function body\")}parseCompoundList(){let t=this.enterDepth(),r=[];for(this.skipNewlines();!this.check(p.EOF,p.FI,p.ELSE,p.ELIF,p.THEN,p.DO,p.DONE,p.ESAC,p.RPAREN,p.RBRACE,p.DSEMI,p.SEMI_AND,p.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let s=this.pos,n=this.parseStatement();if(n&&r.push(n),this.skipSeparators(),this.pos===s&&!n)break}return t(),r}parseOptionalRedirections(){let t=[];for(;De(this);){this.checkIterationLimit();let r=this.pos;if(t.push(xe(this)),this.pos===r)break}return t}parseArithmeticExpression(t){return M(this,t)}};function di(e,t){return new V().parse(e,t)}var Yr=new Map([[\"alnum\",\"a-zA-Z0-9\"],[\"alpha\",\"a-zA-Z\"],[\"ascii\",\"\\\\x00-\\\\x7F\"],[\"blank\",\" \\\\t\"],[\"cntrl\",\"\\\\x00-\\\\x1F\\\\x7F\"],[\"digit\",\"0-9\"],[\"graph\",\"!-~\"],[\"lower\",\"a-z\"],[\"print\",\" -~\"],[\"punct\",\"!-/:-@\\\\[-`{-~\"],[\"space\",\" \\\\t\\\\n\\\\r\\\\f\\\\v\"],[\"upper\",\"A-Z\"],[\"word\",\"a-zA-Z0-9_\"],[\"xdigit\",\"0-9a-fA-F\"]]);function ut(e){return Yr.get(e)??\"\"}function hn(e){let t=[],r=\"\",s=0;for(;s<e.length;){let n=e[s];if(n===\"[\"){for(r+=n,s++,s<e.length&&(e[s]===\"!\"||e[s]===\"^\")&&(r+=e[s],s++),s<e.length&&e[s]===\"]\"&&(r+=e[s],s++);s<e.length&&e[s]!==\"]\";){if(e[s]===\"[\"&&s+1<e.length&&e[s+1]===\":\"){let a=e.indexOf(\":]\",s+2);if(a!==-1){r+=e.slice(s,a+2),s=a+2;continue}}if(e[s]===\"\\\\\"&&s+1<e.length){r+=e[s]+e[s+1],s+=2;continue}r+=e[s],s++}s<e.length&&e[s]===\"]\"&&(r+=e[s],s++)}else n===\":\"?(r!==\"\"&&t.push(r),r=\"\",s++):n===\"\\\\\"&&s+1<e.length?(r+=n+e[s+1],s+=2):(r+=n,s++)}return r!==\"\"&&t.push(r),t}function pn(e){let t=\"^\";for(let r=0;r<e.length;r++){let s=e[r];if(s===\"*\")t+=\"[^/]*\";else if(s===\"?\")t+=\"[^/]\";else if(s===\"[\"){let n=r+1,a=\"[\";n<e.length&&(e[n]===\"^\"||e[n]===\"!\")&&(a+=\"^\",n++),n<e.length&&e[n]===\"]\"&&(a+=\"\\\\]\",n++);let i=n;for(;i<e.length;){if(e[i]===\"\\\\\"&&i+1<e.length){i+=2;continue}if(e[i]===\"[\"&&i+1<e.length&&e[i+1]===\":\"){let o=e.indexOf(\":]\",i+2);if(o!==-1){i=o+2;continue}}if(e[i]===\"]\")break;i++}let l=n;for(;n<e.length&&e[n]!==\"]\";){if(e[n]===\"[\"&&n+1<e.length&&e[n+1]===\":\"){let o=e.indexOf(\":]\",n+2);if(o!==-1){let c=e.slice(n+2,o),u=ut(c);a+=u,n=o+2;continue}}if(e[n]===\"\\\\\"&&n+1<e.length){a+=`\\\\${e[n+1]}`,n+=2;continue}if(e[n]===\"-\"){let o=n===l,c=n+1===i;o||c?a+=\"\\\\-\":a+=\"-\"}else a+=e[n];n++}a+=\"]\",t+=a,r=n}else if(s===\"\\\\\"&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\\\*?[\\]]/.test(n)?t+=`\\\\${n}`:t+=n,r++}else/[.+^${}()|]/.test(s)?t+=`\\\\${s}`:t+=s}return t+=\"$\",O(t)}function ct(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n===\"\\\\\"){s+=2;continue}if(n===\"(\")r++;else if(n===\")\"&&(r--,r===0))return s;s++}return-1}function ft(e){let t=[],r=\"\",s=0,n=!1,a=0;for(;a<e.length;){let i=e[a];if(i===\"'\"&&!n){n=!0,r+=\"\\0QUOTE_START\\0\",a++;continue}if(i===\"'\"&&n){n=!1,r+=\"\\0QUOTE_END\\0\",a++;continue}if(n){r+=i,a++;continue}if(i===\"\\\\\"){r+=i,a+1<e.length?(r+=e[a+1],a+=2):a++;continue}i===\"(\"?(s++,r+=i):i===\")\"?(s--,r+=i):i===\"|\"&&s===0?(t.push(r),r=\"\"):r+=i,a++}return t.push(r),t}var dn=5,oe=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(t,r,s,n){this.fs=t,this.cwd=r,typeof n==\"boolean\"?(this.globstar=n,this.maxOps=1e5):n?(this.globstar=n.globstar??!1,this.nullglob=n.nullglob??!1,this.failglob=n.failglob??!1,this.dotglob=n.dotglob??!1,this.extglob=n.extglob??!1,this.globskipdots=n.globskipdots??!0,this.maxOps=n.maxGlobOperations??1e5):this.maxOps=1e5;let a=s?.get(\"GLOBIGNORE\");a!==void 0&&a!==\"\"&&(this.hasGlobignore=!0,this.globignorePatterns=hn(a))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new L(`Glob operation limit exceeded (${this.maxOps})`,\"glob_operations\")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(r=>{let s=r.split(\"/\").pop()||r;if((this.hasGlobignore||this.globskipdots)&&(s===\".\"||s===\"..\"))return!1;if(this.hasGlobignore){for(let n of this.globignorePatterns)if(this.matchGlobignorePattern(r,n))return!1}return!0})}matchGlobignorePattern(t,r){return pn(r).test(t)}isGlobPattern(t){return!!(t.includes(\"*\")||t.includes(\"?\")||/\\[.*\\]/.test(t)||this.extglob&&/[@*+?!]\\(/.test(t))}async expandArgs(t,r){let s=t.map((i,l)=>(r?.[l]??!1)||!this.isGlobPattern(i)?null:this.expand(i)),n=await Promise.all(s.map(i=>i||Promise.resolve(null))),a=[];for(let i=0;i<t.length;i++){let l=n[i];l===null?a.push(t[i]):l.length>0?a.push(...l):a.push(t[i])}return a}async expand(t){if(this.globstar){let s=t.split(\"/\"),n=0;for(let a of s)if(a===\"**\"&&(n++,n>dn))throw new L(`Glob pattern has too many ** segments (max ${dn})`,\"glob_operations\")}let r;if(t.includes(\"**\")&&this.globstar&&this.isGlobstarValid(t))r=await this.expandRecursive(t);else{let s=t.replace(/\\*\\*+/g,\"*\");r=await this.expandSimple(s)}return this.filterGlobignore(r)}isGlobstarValid(t){let r=t.split(\"/\");for(let s of r)if(s.includes(\"**\")&&s!==\"**\")return!1;return!0}hasGlobChars(t){return!!(t.includes(\"*\")||t.includes(\"?\")||/\\[.*\\]/.test(t)||this.extglob&&/[@*+?!]\\(/.test(t))}async expandSimple(t){let r=t.startsWith(\"/\"),s=t.split(\"/\").filter(c=>c!==\"\"),n=-1;for(let c=0;c<s.length;c++)if(this.hasGlobChars(s[c])){n=c;break}if(n===-1)return[t];let a,i;if(n===0)r?(a=\"/\",i=\"/\"):(a=this.cwd,i=\"\");else{let c=s.slice(0,n);r?(a=`/${c.join(\"/\")}`,i=`/${c.join(\"/\")}`):(a=this.fs.resolvePath(this.cwd,c.join(\"/\")),i=c.join(\"/\"))}let l=s.slice(n);return(await this.expandSegments(a,i,l)).sort()}async expandSegments(t,r,s){if(this.checkOpsLimit(),s.length===0)return[r];let[n,...a]=s,i=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let l=await this.fs.readdirWithFileTypes(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;if(n.startsWith(\".\")||this.dotglob){let h=l.some(m=>m.name===\".\"),d=l.some(m=>m.name===\"..\");h||c.push({name:\".\",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:\"..\",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(\".\")&&!n.startsWith(\".\")&&!u)&&this.matchPattern(h.name,n)){let d=t===\"/\"?`/${h.name}`:`${t}/${h.name}`,m;r===\"\"?m=h.name:r===\"/\"?m=`/${h.name}`:m=`${r}/${h.name}`,a.length===0?o.push(Promise.resolve([m])):h.isDirectory&&o.push(this.expandSegments(d,m,a))}let f=await Promise.all(o);for(let h of f)i.push(...h)}else{this.checkOpsLimit();let l=await this.fs.readdir(t),o=[],c=[...l],u=this.dotglob||this.hasGlobignore;(n.startsWith(\".\")||this.dotglob)&&(l.includes(\".\")||c.push(\".\"),l.includes(\"..\")||c.push(\"..\"));for(let h of c)if(!(h.startsWith(\".\")&&!n.startsWith(\".\")&&!u)&&this.matchPattern(h,n)){let d=t===\"/\"?`/${h}`:`${t}/${h}`,m;r===\"\"?m=h:r===\"/\"?m=`/${h}`:m=`${r}/${h}`,a.length===0?o.push(Promise.resolve([m])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,m,a)}catch(g){if(g instanceof L)throw g}return[]})())}let f=await Promise.all(o);for(let h of f)i.push(...h)}}catch(l){if(l instanceof L)throw l}return i}async expandRecursive(t){let r=[],s=t.indexOf(\"**\"),n=t.slice(0,s).replace(/\\/$/,\"\")||\".\",i=t.slice(s+2).replace(/^\\//,\"\");return i.includes(\"**\")&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(n,i,r),[...new Set(r)].sort()):(await this.walkDirectory(n,i,r),r.sort())}async walkDirectoryMultiGlobstar(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{this.checkOpsLimit();let a=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(n):null;if(a){let i=[];for(let c of a){let u=t===\".\"?c.name:`${t}/${c.name}`;c.isDirectory&&i.push(u)}let l=t===\".\"?r:`${t}/${r}`,o=await this.expandRecursive(l);s.push(...o);for(let c=0;c<i.length;c+=100){let u=i.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,r,s)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(n),l=[];for(let u of i){let f=t===\".\"?u:`${t}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&l.push(f)}catch(d){if(d instanceof L)throw d}}let o=t===\".\"?r:`${t}/${r}`,c=await this.expandRecursive(o);s.push(...c);for(let u=0;u<l.length;u+=100){let f=l.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,r,s)))}}}catch(a){if(a instanceof L)throw a}}async walkDirectory(t,r,s){this.checkOpsLimit();let n=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(n),i=[],l=[];for(let o of a){let c=t===\".\"?o.name:`${t}/${o.name}`;o.isDirectory?l.push(c):r&&this.matchPattern(o.name,r)&&i.push(c)}s.push(...i);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u,r,s)))}}else{this.checkOpsLimit();let a=await this.fs.readdir(n),i=[];for(let o=0;o<a.length;o+=100){let c=a.slice(o,o+100),u=await Promise.all(c.map(async f=>{let h=t===\".\"?f:`${t}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let m=await this.fs.stat(d);return{name:f,path:h,isDirectory:m.isDirectory}}catch(m){if(m instanceof L)throw m;return null}}));i.push(...u.filter(f=>f!==null))}for(let o of i)!o.isDirectory&&r&&this.matchPattern(o.name,r)&&s.push(o.path);let l=i.filter(o=>o.isDirectory);for(let o=0;o<l.length;o+=100){let c=l.slice(o,o+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,r,s)))}}}catch(a){if(a instanceof L)throw a}}matchPattern(t,r){return this.patternToRegex(r).test(t)}patternToRegex(t){let r=this.patternToRegexStr(t);return O(`^${r}$`)}patternToRegexStr(t){let r=\"\",s=!1;for(let n=0;n<t.length;n++){if(t.slice(n,n+13)===\"\\0QUOTE_START\\0\"){s=!0,n+=12;continue}if(t.slice(n,n+11)===\"\\0QUOTE_END\\0\"){s=!1,n+=10;continue}let a=t[n];if(s){/[.+^${}()|\\\\*?[\\]]/.test(a)?r+=`\\\\${a}`:r+=a;continue}if(this.extglob&&(a===\"@\"||a===\"*\"||a===\"+\"||a===\"?\"||a===\"!\")&&n+1<t.length&&t[n+1]===\"(\"){let i=ct(t,n+1);if(i!==-1){let l=t.slice(n+2,i),o=ft(l),c=o.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join(\"|\"):\"(?:)\";if(a===\"@\")r+=`(?:${u})`;else if(a===\"*\")r+=`(?:${u})*`;else if(a===\"+\")r+=`(?:${u})+`;else if(a===\"?\")r+=`(?:${u})?`;else if(a===\"!\")if(i<t.length-1){let h=o.map(m=>this.computePatternLength(m));if(h.every(m=>m!==null)&&h.every(m=>m===h[0])&&h[0]!==null){let m=h[0];if(m===0)r+=\"(?:.+)\";else{let g=[];m>0&&g.push(`.{0,${m-1}}`),g.push(`.{${m+1},}`),g.push(`(?!(?:${u})).{${m}}`),r+=`(?:${g.join(\"|\")})`}}else r+=`(?:(?!(?:${u})).)*?`}else r+=`(?!(?:${u})$).*`;n=i;continue}}if(a===\"*\")r+=\".*\";else if(a===\"?\")r+=\".\";else if(a===\"[\"){let i=n+1,l=\"[\";i<t.length&&(t[i]===\"^\"||t[i]===\"!\")&&(l+=\"^\",i++),i<t.length&&t[i]===\"]\"&&(l+=\"\\\\]\",i++);let o=i;for(;o<t.length;){if(t[o]===\"\\\\\"&&o+1<t.length){o+=2;continue}if(t[o]===\"[\"&&o+1<t.length&&t[o+1]===\":\"){let u=t.indexOf(\":]\",o+2);if(u!==-1){o=u+2;continue}}if(t[o]===\"]\")break;o++}let c=i;for(;i<t.length&&t[i]!==\"]\";){if(t[i]===\"[\"&&i+1<t.length&&t[i+1]===\":\"){let u=t.indexOf(\":]\",i+2);if(u!==-1){let f=t.slice(i+2,u),h=ut(f);l+=h,i=u+2;continue}}if(t[i]===\"\\\\\"&&i+1<t.length){l+=`\\\\${t[i+1]}`,i+=2;continue}if(t[i]===\"-\"){let u=i===c,f=i+1===o;u||f?l+=\"\\\\-\":l+=\"-\"}else l+=t[i];i++}l+=\"]\",r+=l,n=i}else if(a===\"\\\\\"&&n+1<t.length){let i=t[n+1];/[.+^${}()|\\\\*?[\\]]/.test(i)?r+=`\\\\${i}`:r+=i,n++}else/[.+^${}()|]/.test(a)?r+=`\\\\${a}`:r+=a}return r}computePatternLength(t){let r=0,s=0,n=!1;for(;s<t.length;){if(t.slice(s,s+13)===\"\\0QUOTE_START\\0\"){n=!0,s+=13;continue}if(t.slice(s,s+11)===\"\\0QUOTE_END\\0\"){n=!1,s+=11;continue}let a=t[s];if(n){r+=1,s++;continue}if((a===\"@\"||a===\"*\"||a===\"+\"||a===\"?\"||a===\"!\")&&s+1<t.length&&t[s+1]===\"(\"){let i=ct(t,s+1);if(i!==-1){if(a===\"@\"){let l=t.slice(s+2,i),c=ft(l).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){r+=c[0],s=i+1;continue}return null}return null}}if(a===\"*\")return null;if(a===\"?\"){r+=1,s++;continue}if(a===\"[\"){let i=t.indexOf(\"]\",s+1);if(i!==-1){r+=1,s=i+1;continue}r+=1,s++;continue}if(a===\"\\\\\"){r+=1,s+=2;continue}r+=1,s++}return r}};function es(e,t,r){switch(r){case\"+\":return e+t;case\"-\":return e-t;case\"*\":return e*t;case\"/\":if(t===0)throw new C(\"division by 0\");return Math.trunc(e/t);case\"%\":if(t===0)throw new C(\"division by 0\");return e%t;case\"**\":if(t<0)throw new C(\"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 mn(e,t,r){switch(r){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 ts(e,t){switch(t){case\"-\":return-e;case\"+\":return+e;case\"!\":return e===0?1:0;case\"~\":return~e;default:return e}}async function ns(e,t){let r=e.state.env.get(t);if(r!==void 0)return r;let s=e.state.env.get(`${t}_0`);return s!==void 0?s:await v(e,t)}function rs(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\\d+$/.test(e.trim()))return t;let r=e.trim();if(!r)return 0;try{let s=new V,{expr:n,pos:a}=Z(s,r,0);if(a<r.length){let i=r.slice(a).trim().split(/\\s+/)[0];throw new C(`${r}: syntax error in expression (error token is \"${i}\")`)}return n.type===\"ArithNumber\"?n.value:t||0}catch(s){if(s instanceof C)throw s;let n=r.split(/\\s+/).slice(1)[0]||r;throw new C(`${r}: syntax error in expression (error token is \"${n}\")`)}}async function ht(e,t){if(!t)return 0;let r=Number.parseInt(t,10);if(!Number.isNaN(r)&&/^-?\\d+$/.test(t.trim()))return r;let s=t.trim();if(!s)return 0;let n=new V,{expr:a,pos:i}=Z(n,s,0);if(i<s.length){let l=s.slice(i).trim(),o=l.split(/\\s+/)[0]||l;throw new C(`syntax error in expression (error token is \"${o}\")`,\"\",\"\")}return await R(e,a)}async function pt(e,t,r=new Set,s=0){if(s>100)throw new C(\"maximum variable indirection depth exceeded\");if(r.has(t))return 0;r.add(t);let n=await ns(e,t);if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\\d+$/.test(n.trim()))return a;let i=n.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return await pt(e,i,r,s+1);let l=new V,{expr:o,pos:c}=Z(l,i,0);if(c<i.length){let u=i.slice(c).trim(),f=u.split(/\\s+/)[0]||u;throw new C(`${i}: syntax error in expression (error token is \"${f}\")`)}return await R(e,o)}async function _e(e,t){if(t.startsWith(\"#\")){let f=t.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(h){let m=h[1],g=P(e,m);return String(g.length)}let d=e.state.env.get(f)||\"\";return String(d.length)}if(t.startsWith(\"!\")){let f=t.slice(1),h=e.state.env.get(f)||\"\";return e.state.env.get(h)||\"\"}let r=[\":-\",\":=\",\":?\",\":+\",\"-\",\"=\",\"?\",\"+\"],s=-1,n=\"\";for(let f of r){let h=t.indexOf(f);h>0&&(s===-1||h<s)&&(s=h,n=f)}if(s===-1)return await v(e,t);let a=t.slice(0,s),i=t.slice(s+n.length),l=e.state.env.get(a),o=l===void 0,c=l===\"\",u=n.startsWith(\":\");switch(n){case\":-\":case\"-\":return o||u&&c?i:l||\"\";case\":=\":case\"=\":return o||u&&c?(e.state.env.set(a,i),i):l||\"\";case\":+\":case\"+\":return!(o||u&&c)?i:\"\";case\":?\":case\"?\":{if(o||u&&c)throw new Error(i||`${a}: parameter null or not set`);return l||\"\"}default:return l||\"\"}}async function R(e,t,r=!1){switch(t.type){case\"ArithNumber\":if(Number.isNaN(t.value))throw new C(\"value too great for base\");return t.value;case\"ArithVariable\":return await pt(e,t.name);case\"ArithSpecialVar\":{let n=(await v(e,t.name)).trim();if(!n)return 0;let a=Number.parseInt(n,10);if(!Number.isNaN(a)&&/^-?\\d+$/.test(n))return a;let i=new V,{expr:l}=Z(i,n,0);return await R(e,l)}case\"ArithNested\":return await R(e,t.expression);case\"ArithCommandSubst\":{if(e.execFn){let s=await e.execFn(t.command,{signal:e.state.signal});s.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+s.stderr);let n=s.stdout.trim();return Number.parseInt(n,10)||0}return 0}case\"ArithBracedExpansion\":{let s=await _e(e,t.content);return Number.parseInt(s,10)||0}case\"ArithDynamicBase\":{let s=await _e(e,t.baseExpr),n=Number.parseInt(s,10);if(n<2||n>64)return 0;let a=`${n}#${t.value}`;return ge(a)}case\"ArithDynamicNumber\":{let n=await _e(e,t.prefix)+t.suffix;return ge(n)}case\"ArithArrayElement\":{let s=e.state.associativeArrays?.has(t.array),n=async a=>{let i=e.state.env.get(a);return i!==void 0?await ht(e,i):0};if(t.stringKey!==void 0)return await n(`${t.array}_${t.stringKey}`);if(s&&t.index?.type===\"ArithVariable\"&&!t.index.hasDollarPrefix)return await n(`${t.array}_${t.index.name}`);if(s&&t.index?.type===\"ArithVariable\"&&t.index.hasDollarPrefix){let a=await v(e,t.index.name);return await n(`${t.array}_${a}`)}if(t.index){let a=await R(e,t.index,r);if(a<0){let o=P(e,t.array),c=e.state.currentLine;if(o.length===0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${c}: ${t.array}: bad array subscript\n`,0;let f=Math.max(...o.map(([h])=>typeof h==\"number\"?h:0))+1+a;if(f<0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${c}: ${t.array}: bad array subscript\n`,0;a=f}let i=`${t.array}_${a}`,l=e.state.env.get(i);if(l!==void 0)return ht(e,l);if(a===0){let o=e.state.env.get(t.array);if(o!==void 0)return ht(e,o)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new j(`${t.array}[${a}]`);return 0}return 0}case\"ArithDoubleSubscript\":throw new C(\"double subscript\",\"\",\"\");case\"ArithNumberSubscript\":throw new C(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is \"${t.errorToken}\")`);case\"ArithSyntaxError\":throw new C(t.message,\"\",\"\",!0);case\"ArithSingleQuote\":{if(r)throw new C(`syntax error: operand expected (error token is \"'${t.content}'\")`);return t.value}case\"ArithBinary\":{if(t.operator===\"||\")return await R(e,t.left,r)||await R(e,t.right,r)?1:0;if(t.operator===\"&&\")return await R(e,t.left,r)&&await R(e,t.right,r)?1:0;let s=await R(e,t.left,r),n=await R(e,t.right,r);return es(s,n,t.operator)}case\"ArithUnary\":{let s=await R(e,t.operand,r);if(t.operator===\"++\"||t.operator===\"--\"){if(t.operand.type===\"ArithVariable\"){let n=t.operand.name,a=Number.parseInt(await v(e,n),10)||0,i=t.operator===\"++\"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}if(t.operand.type===\"ArithArrayElement\"){let n=t.operand.array,a=e.state.associativeArrays?.has(n),i;if(t.operand.stringKey!==void 0)i=`${n}_${t.operand.stringKey}`;else if(a&&t.operand.index?.type===\"ArithVariable\"&&!t.operand.index.hasDollarPrefix)i=`${n}_${t.operand.index.name}`;else if(a&&t.operand.index?.type===\"ArithVariable\"&&t.operand.index.hasDollarPrefix){let c=await v(e,t.operand.index.name);i=`${n}_${c}`}else if(t.operand.index){let c=await R(e,t.operand.index,r);i=`${n}_${c}`}else return s;let l=Number.parseInt(e.state.env.get(i)||\"0\",10)||0,o=t.operator===\"++\"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}if(t.operand.type===\"ArithConcat\"){let n=\"\";for(let a of t.operand.parts)n+=await de(e,a,r);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=Number.parseInt(e.state.env.get(n)||\"0\",10)||0,i=t.operator===\"++\"?a+1:a-1;return e.state.env.set(n,String(i)),t.prefix?i:a}}if(t.operand.type===\"ArithDynamicElement\"){let n=\"\";if(t.operand.nameExpr.type===\"ArithConcat\")for(let a of t.operand.nameExpr.parts)n+=await de(e,a,r);else t.operand.nameExpr.type===\"ArithVariable\"&&(n=t.operand.nameExpr.hasDollarPrefix?await v(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(n&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){let a=await R(e,t.operand.subscript,r),i=`${n}_${a}`,l=Number.parseInt(e.state.env.get(i)||\"0\",10)||0,o=t.operator===\"++\"?l+1:l-1;return e.state.env.set(i,String(o)),t.prefix?o:l}}return s}return ts(s,t.operator)}case\"ArithTernary\":return await R(e,t.condition,r)?await R(e,t.consequent,r):await R(e,t.alternate,r);case\"ArithAssignment\":{let s=t.variable,n=s;if(t.stringKey!==void 0)n=`${s}_${t.stringKey}`;else if(t.subscript){let o=e.state.associativeArrays?.has(s);if(o&&t.subscript.type===\"ArithVariable\"&&!t.subscript.hasDollarPrefix)n=`${s}_${t.subscript.name}`;else if(o&&t.subscript.type===\"ArithVariable\"&&t.subscript.hasDollarPrefix){let c=await v(e,t.subscript.name);n=`${s}_${c||\"\\\\\"}`}else if(o){let c=await R(e,t.subscript,r);n=`${s}_${c}`}else{let c=await R(e,t.subscript,r);if(c<0){let u=P(e,s);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h==\"number\"?h:0))+1+c)}n=`${s}_${c}`}}let a=Number.parseInt(e.state.env.get(n)||\"0\",10)||0,i=await R(e,t.value,r),l=mn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case\"ArithGroup\":return await R(e,t.expression,r);case\"ArithConcat\":{let s=\"\";for(let n of t.parts)s+=await de(e,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?await pt(e,s):Number.parseInt(s,10)||0}case\"ArithDynamicAssignment\":{let s=\"\";if(t.target.type===\"ArithConcat\")for(let o of t.target.parts)s+=await de(e,o,r);else t.target.type===\"ArithVariable\"&&(s=t.target.hasDollarPrefix?await v(e,t.target.name):t.target.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=s;if(t.subscript){let o=await R(e,t.subscript,r);n=`${s}_${o}`}let a=Number.parseInt(e.state.env.get(n)||\"0\",10)||0,i=await R(e,t.value,r),l=mn(a,i,t.operator);return e.state.env.set(n,String(l)),l}case\"ArithDynamicElement\":{let s=\"\";if(t.nameExpr.type===\"ArithConcat\")for(let l of t.nameExpr.parts)s+=await de(e,l,r);else t.nameExpr.type===\"ArithVariable\"&&(s=t.nameExpr.hasDollarPrefix?await v(e,t.nameExpr.name):t.nameExpr.name);if(!s||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))return 0;let n=await R(e,t.subscript,r),a=`${s}_${n}`,i=e.state.env.get(a);return i!==void 0?rs(i):0}default:return 0}}async function de(e,t,r=!1){switch(t.type){case\"ArithNumber\":return String(t.value);case\"ArithSingleQuote\":return String(await R(e,t,r));case\"ArithVariable\":return t.hasDollarPrefix?await v(e,t.name):t.name;case\"ArithSpecialVar\":return await v(e,t.name);case\"ArithBracedExpansion\":return await _e(e,t.content);case\"ArithCommandSubst\":return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():\"0\";case\"ArithConcat\":{let s=\"\";for(let n of t.parts)s+=await de(e,n,r);return s}default:return String(await R(e,t,r))}}function dt(e){for(let t=0;t<e.length;t++){if(e[t]===\"\\\\\"){t++;continue}if(e[t]===\"$\"){let r=e[t+1];if(r===\"{\"||r&&/[a-zA-Z_]/.test(r))return!0}}return!1}function ss(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type===\"DefaultValue\"||t.type===\"AssignDefault\"||t.type===\"UseAlternative\"||t.type===\"ErrorIfUnset\")&&(r=t.word?.parts),!r)return!1;for(let s of r)if(s.type===\"DoubleQuoted\"||s.type===\"SingleQuoted\")return!0;return!1}function gn(e){if(!e.operation)return!1;let t=e.operation,r;if((t.type===\"DefaultValue\"||t.type===\"AssignDefault\"||t.type===\"UseAlternative\"||t.type===\"ErrorIfUnset\")&&(r=t.word?.parts),!r||r.length===0)return!1;for(let s of r)if(s.type!==\"DoubleQuoted\"&&s.type!==\"SingleQuoted\")return!1;return!0}function Ae(e){let t=!1,r=!1,s=!1,n=!1,a=!1,i=!1,l=!1;for(let o of e){if((o.type===\"SingleQuoted\"||o.type===\"DoubleQuoted\")&&(t=!0,o.type===\"DoubleQuoted\"))for(let c of o.parts)c.type===\"ParameterExpansion\"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/)&&(!c.operation||c.operation.type===\"PatternRemoval\"||c.operation.type===\"PatternReplacement\")&&(n=!0),(c.operation?.type===\"VarNamePrefix\"||c.operation?.type===\"ArrayKeys\")&&(i=!0),c.operation?.type===\"Indirection\"&&(l=!0));o.type===\"CommandSubstitution\"&&(r=!0),o.type===\"ParameterExpansion\"&&(a=!0,(o.parameter===\"@\"||o.parameter===\"*\")&&(s=!0),ss(o)&&(t=!0),(o.operation?.type===\"VarNamePrefix\"||o.operation?.type===\"ArrayKeys\")&&(i=!0),o.operation?.type===\"Indirection\"&&(l=!0)),o.type===\"Glob\"&&dt(o.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:r,hasArrayVar:s,hasArrayAtExpansion:n,hasParamExpansion:a,hasVarNamePrefixExpansion:i,hasIndirection:l}}var yn=\"5.1.0(1)-release\",xi=\"Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT\";function _i(e){let{pid:t,ppid:r,uid:s,gid:n}=e;return`Name:\tbash\nState:\tR (running)\nPid:\t${t}\nPPid:\t${r}\nUid:\t${s}\t${s}\t${s}\t${s}\nGid:\t${n}\t${n}\t${n}\t${n}\n`}function mt(e,t){let r=`${t}_`,s=[];for(let n of e.state.env.keys())if(n.startsWith(r)){let a=n.slice(r.length),i=Number.parseInt(a,10);!Number.isNaN(i)&&String(i)===a&&s.push(i)}return s.sort((n,a)=>n-a)}function Ci(e,t){let r=`${t}_`;for(let s of e.state.env.keys())s.startsWith(r)&&e.state.env.delete(s)}function gt(e,t){let r=`${t}_`,s=`${t}__length`,n=[];for(let a of e.state.env.keys())if(a!==s&&a.startsWith(r)){let i=a.slice(r.length);if(i.startsWith(\"_length\"))continue;n.push(i)}return n.sort()}function $e(e){return e.startsWith(\"'\")&&e.endsWith(\"'\")||e.startsWith('\"')&&e.endsWith('\"')?e.slice(1,-1):e}function Oi(e){if(e.parts.length<2)return null;let t=e.parts[0],r=e.parts[1];if(t.type!==\"Glob\"||!t.pattern.startsWith(\"[\"))return null;let s,n=r,a=1;if(r.type===\"Literal\"&&r.value.startsWith(\"]\")){let f=r.value.slice(1);if(f.startsWith(\"+=\")||f.startsWith(\"=\"))s=t.pattern.slice(1);else if(f===\"\"){if(e.parts.length<3)return null;let h=e.parts[2];if(h.type!==\"Literal\"||!h.value.startsWith(\"=\")&&!h.value.startsWith(\"+=\"))return null;s=t.pattern.slice(1),n=h,a=2}else return null}else if(t.pattern===\"[\"&&(r.type===\"DoubleQuoted\"||r.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(r.type===\"SingleQuoted\")s=r.value;else{s=\"\";for(let h of r.parts)(h.type===\"Literal\"||h.type===\"Escaped\")&&(s+=h.value)}n=f,a=2}else if(t.pattern.endsWith(\"]\")){if(r.type!==\"Literal\"||!r.value.startsWith(\"=\")&&!r.value.startsWith(\"+=\"))return null;s=t.pattern.slice(1,-1)}else return null;s=$e(s);let i;if(n.type!==\"Literal\")return null;n.value.startsWith(\"]=\")||n.value.startsWith(\"]+=\")?i=n.value.slice(1):i=n.value;let l=i.startsWith(\"+=\");if(!l&&!i.startsWith(\"=\"))return null;let o=[],c=l?2:1,u=i.slice(c);u&&o.push({type:\"Literal\",value:u});for(let f=a+1;f<e.parts.length;f++){let h=e.parts[f];h.type===\"BraceExpansion\"?o.push({type:\"Literal\",value:is(h)}):o.push(h)}return{key:s,valueParts:o,append:l}}function is(e){return`{${e.items.map(r=>{if(r.type===\"Range\"){let s=r.startStr??String(r.start),n=r.endStr??String(r.end),a=`${s}..${n}`;return r.step&&(a+=`..${r.step}`),a}return En(r.word)}).join(\",\")}}`}function En(e){let t=\"\";for(let r of e.parts)switch(r.type){case\"Literal\":t+=r.value;break;case\"Glob\":t+=r.pattern;break;case\"SingleQuoted\":t+=r.value;break;case\"DoubleQuoted\":for(let s of r.parts)(s.type===\"Literal\"||s.type===\"Escaped\")&&(t+=s.value);break;case\"Escaped\":t+=r.value;break;case\"BraceExpansion\":t+=\"{\",t+=r.items.map(s=>s.type===\"Range\"?`${s.startStr}..${s.endStr}${s.step?`..${s.step}`:\"\"}`:En(s.word)).join(\",\"),t+=\"}\";break;case\"TildeExpansion\":t+=\"~\",r.user&&(t+=r.user);break}return t}function T(e){return e.get(\"IFS\")??` \t\n`}function q(e){return e.get(\"IFS\")===\"\"}function Ce(e){let t=T(e);if(t===\"\")return!0;for(let r of t)if(r!==\" \"&&r!==\"\t\"&&r!==`\n`)return!1;return!0}function An(e){let t=!1,r=[];for(let s of e.split(\"\"))s===\"-\"?t=!0:/[\\\\^$.*+?()[\\]{}|]/.test(s)?r.push(`\\\\${s}`):s===\"\t\"?r.push(\"\\\\t\"):s===`\n`?r.push(\"\\\\n\"):r.push(s);return t&&r.push(\"\\\\-\"),r.join(\"\")}function N(e){let t=e.get(\"IFS\");return t===void 0?\" \":t[0]||\"\"}var as=` \t\n`;function os(e){return as.includes(e)}function yt(e){let t=new Set,r=new Set;for(let s of e)os(s)?t.add(s):r.add(s);return{whitespace:t,nonWhitespace:r}}function Wi(e,t,r,s){if(t===\"\")return e===\"\"?{words:[],wordStarts:[]}:{words:[e],wordStarts:[0]};let{whitespace:n,nonWhitespace:a}=yt(t),i=[],l=[],o=0;for(;o<e.length&&n.has(e[o]);)o++;if(o>=e.length)return{words:[],wordStarts:[]};if(a.has(e[o]))for(i.push(\"\"),l.push(o),o++;o<e.length&&n.has(e[o]);)o++;for(;o<e.length&&!(r!==void 0&&i.length>=r);){let c=o;for(l.push(c);o<e.length;){let u=e[o];if(!s&&u===\"\\\\\"){o++,o<e.length&&o++;continue}if(n.has(u)||a.has(u))break;o++}if(i.push(e.substring(c,o)),o>=e.length)break;for(;o<e.length&&n.has(e[o]);)o++;if(o<e.length&&a.has(e[o])){for(o++;o<e.length&&n.has(e[o]);)o++;for(;o<e.length&&a.has(e[o])&&!(r!==void 0&&i.length>=r);)for(i.push(\"\"),l.push(o),o++;o<e.length&&n.has(e[o]);)o++}}return{words:i,wordStarts:l}}function Oe(e,t){if(t===\"\")return{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e===\"\")return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:r,nonWhitespace:s}=yt(t),n=[],a=0,i=!1,l=!1,o=a;for(;a<e.length&&r.has(e[a]);)a++;if(a>o&&(i=!0),a>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(s.has(e[a]))for(n.push(\"\"),a++;a<e.length&&r.has(e[a]);)a++;for(;a<e.length;){let c=a;for(;a<e.length;){let f=e[a];if(r.has(f)||s.has(f))break;a++}if(n.push(e.substring(c,a)),a>=e.length){l=!1;break}let u=a;for(;a<e.length&&r.has(e[a]);)a++;if(a<e.length&&s.has(e[a])){for(a++;a<e.length&&r.has(e[a]);)a++;for(;a<e.length&&s.has(e[a]);)for(n.push(\"\"),a++;a<e.length&&r.has(e[a]);)a++}a>=e.length&&a>u&&(l=!0)}return{words:n,hadLeadingDelimiter:i,hadTrailingDelimiter:l}}function x(e,t){return Oe(e,t).words}function ls(e,t){for(let r of e)if(t.has(r))return!0;return!1}function Ti(e,t,r){if(t===\"\")return e;let{whitespace:s,nonWhitespace:n}=yt(t),a=e.length;for(;a>0&&s.has(e[a-1]);){if(!r&&a>=2){let l=0,o=a-2;for(;o>=0&&e[o]===\"\\\\\";)l++,o--;if(l%2===1)break}a--}let i=e.substring(0,a);if(i.length>=1&&n.has(i[i.length-1])){if(!r&&i.length>=2){let o=0,c=i.length-2;for(;c>=0&&i[c]===\"\\\\\";)o++,c--;if(o%2===1)return i}let l=i.substring(0,i.length-1);if(!ls(l,n))return l}return i}function W(e,t){return e.state.namerefs?.has(t)??!1}function Vi(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function qi(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Bi(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function Sn(e,t){return e.state.invalidNamerefs?.has(t)??!1}function Fi(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function us(e,t){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(r){let n=r[1],a=Array.from(e.state.env.keys()).some(l=>l.startsWith(`${n}_`)&&!l.includes(\"__\")),i=e.state.associativeArrays?.has(n)??!1;return a||i}return Array.from(e.state.env.keys()).some(n=>n.startsWith(`${t}_`)&&!n.includes(\"__\"))?!0:e.state.env.has(t)}function he(e,t,r=100){if(!W(e,t)||Sn(e,t))return t;let s=new Set,n=t;for(;r-- >0;){if(s.has(n))return;if(s.add(n),!W(e,n))return n;let a=e.state.env.get(n);if(a===void 0||a===\"\"||!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(a))return n;n=a}}function Se(e,t){if(W(e,t))return e.state.env.get(t)}function zi(e,t,r,s=100){if(!W(e,t)||Sn(e,t))return t;let n=new Set,a=t;for(;s-- >0;){if(n.has(a))return;if(n.add(a),!W(e,a))return a;let i=e.state.env.get(a);if(i===void 0||i===\"\")return r!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&us(e,r)?a:null:a;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(i))return a;a=i}}function cs(e,t){let r=t.replace(/\\$\\{([a-zA-Z_][a-zA-Z0-9_]*)\\}/g,(s,n)=>e.state.env.get(n)??\"\");return r=r.replace(/\\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(s,n)=>e.state.env.get(n)??\"\"),r}function P(e,t){return t===\"FUNCNAME\"?(e.state.funcNameStack??[]).map((a,i)=>[i,a]):t===\"BASH_LINENO\"?(e.state.callLineStack??[]).map((a,i)=>[i,String(a)]):t===\"BASH_SOURCE\"?(e.state.sourceStack??[]).map((a,i)=>[i,a]):e.state.associativeArrays?.has(t)?gt(e,t).map(a=>[a,e.state.env.get(`${t}_${a}`)??\"\"]):mt(e,t).map(n=>[n,e.state.env.get(`${t}_${n}`)??\"\"])}function be(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)?gt(e,t).length>0:mt(e,t).length>0}async function v(e,t,r=!0,s=!1){switch(t){case\"?\":return String(e.state.lastExitCode);case\"$\":return String(e.state.virtualPid);case\"#\":return e.state.env.get(\"#\")||\"0\";case\"@\":return e.state.env.get(\"@\")||\"\";case\"_\":return e.state.lastArg;case\"-\":{let i=\"\";return i+=\"h\",e.state.options.errexit&&(i+=\"e\"),e.state.options.noglob&&(i+=\"f\"),e.state.options.nounset&&(i+=\"u\"),e.state.options.verbose&&(i+=\"v\"),e.state.options.xtrace&&(i+=\"x\"),i+=\"B\",e.state.options.noclobber&&(i+=\"C\"),i+=\"s\",i}case\"*\":{let i=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);if(i===0)return\"\";let l=[];for(let o=1;o<=i;o++)l.push(e.state.env.get(String(o))||\"\");return l.join(N(e.state.env))}case\"0\":return e.state.env.get(\"0\")||\"bash\";case\"PWD\":return e.state.env.get(\"PWD\")??\"\";case\"OLDPWD\":return e.state.env.get(\"OLDPWD\")??\"\";case\"PPID\":return String(e.state.virtualPpid);case\"UID\":return String(e.state.virtualUid);case\"EUID\":return String(e.state.virtualUid);case\"RANDOM\":return String(Math.floor(Math.random()*32768));case\"SECONDS\":return String(Math.floor((Date.now()-e.state.startTime)/1e3));case\"BASH_VERSION\":return yn;case\"!\":return String(e.state.lastBackgroundPid);case\"BASHPID\":return String(e.state.bashPid);case\"LINENO\":return String(e.state.currentLine);case\"FUNCNAME\":{let i=e.state.funcNameStack?.[0];if(i!==void 0)return i;if(r&&e.state.options.nounset)throw new j(\"FUNCNAME\");return\"\"}case\"BASH_LINENO\":{let i=e.state.callLineStack?.[0];if(i!==void 0)return String(i);if(r&&e.state.options.nounset)throw new j(\"BASH_LINENO\");return\"\"}case\"BASH_SOURCE\":{let i=e.state.sourceStack?.[0];if(i!==void 0)return i;if(r&&e.state.options.nounset)throw new j(\"BASH_SOURCE\");return\"\"}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\\[\\]$/.test(t))throw new re(`\\${${t}}`);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(n){let i=n[1],l=n[2];if(W(e,i)){let f=he(e,i);if(f&&f!==i){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/))return\"\";i=f}}if(l===\"@\"||l===\"*\"){let f=P(e,i);if(f.length>0)return f.map(([,d])=>d).join(\" \");let h=e.state.env.get(i);return h!==void 0?h:\"\"}if(i===\"FUNCNAME\"){let f=Number.parseInt(l,10);return!Number.isNaN(f)&&f>=0?e.state.funcNameStack?.[f]??\"\":\"\"}if(i===\"BASH_LINENO\"){let f=Number.parseInt(l,10);if(!Number.isNaN(f)&&f>=0){let h=e.state.callLineStack?.[f];return h!==void 0?String(h):\"\"}return\"\"}if(i===\"BASH_SOURCE\"){let f=Number.parseInt(l,10);return!Number.isNaN(f)&&f>=0?e.state.sourceStack?.[f]??\"\":\"\"}if(e.state.associativeArrays?.has(i)){let f=$e(l);f=cs(e,f);let h=e.state.env.get(`${i}_${f}`);if(h===void 0&&r&&e.state.options.nounset)throw new j(`${i}[${l}]`);return h||\"\"}let c;if(/^-?\\d+$/.test(l))c=Number.parseInt(l,10);else try{let f=new V,h=M(f,l);c=await R(e,h.expression)}catch{let f=e.state.env.get(l);c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=P(e,i),h=e.state.currentLine;if(f.length===0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${h}: ${i}: bad array subscript\n`,\"\";let m=Math.max(...f.map(([E])=>typeof E==\"number\"?E:0))+1+c;return m<0?(e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${h}: ${i}: bad array subscript\n`,\"\"):e.state.env.get(`${i}_${m}`)||\"\"}let u=e.state.env.get(`${i}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(i);if(f!==void 0)return f}if(r&&e.state.options.nounset)throw new j(`${i}[${c}]`);return\"\"}if(/^[1-9][0-9]*$/.test(t)){let i=e.state.env.get(t);if(i===void 0&&r&&e.state.options.nounset)throw new j(t);return i||\"\"}if(W(e,t)){let i=he(e,t);if(i===void 0)return\"\";if(i!==t)return await v(e,i,r,s);let l=e.state.env.get(t);if((l===void 0||l===\"\")&&r&&e.state.options.nounset)throw new j(t);return l||\"\"}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(i=>i.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(be(e,t)){let i=e.state.env.get(`${t}_0`);return i!==void 0?i:\"\"}if(r&&e.state.options.nounset)throw new j(t);return\"\"}async function te(e,t){if(new Set([\"?\",\"$\",\"#\",\"_\",\"-\",\"0\",\"PPID\",\"UID\",\"EUID\",\"RANDOM\",\"SECONDS\",\"BASH_VERSION\",\"!\",\"BASHPID\",\"LINENO\"]).has(t))return!0;if(t===\"@\"||t===\"*\")return Number.parseInt(e.state.env.get(\"#\")||\"0\",10)>0;if(t===\"PWD\"||t===\"OLDPWD\")return e.state.env.has(t);let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(s){let n=s[1],a=s[2];if(W(e,n)){let o=he(e,n);if(o&&o!==n){if(o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/))return!1;n=o}}if(a===\"@\"||a===\"*\")return P(e,n).length>0?!0:e.state.env.has(n);if(e.state.associativeArrays?.has(n)){let o=$e(a);return e.state.env.has(`${n}_${o}`)}let l;if(/^-?\\d+$/.test(a))l=Number.parseInt(a,10);else try{let o=new V,c=M(o,a);l=await R(e,c.expression)}catch{let o=e.state.env.get(a);l=o?Number.parseInt(o,10):0,Number.isNaN(l)&&(l=0)}if(l<0){let o=P(e,n);if(o.length===0)return!1;let u=Math.max(...o.map(([f])=>typeof f==\"number\"?f:0))+1+l;return u<0?!1:e.state.env.has(`${n}_${u}`)}return e.state.env.has(`${n}_${l}`)}if(W(e,t)){let n=he(e,t);return n===void 0||n===t?e.state.env.has(t):te(e,n)}return!!(e.state.env.has(t)||be(e,t))}async function bn(e,t){let r=\"\",s=0;for(;s<t.length;){if(t[s]===\"$\"){if(t[s+1]===\"{\"){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]===\"{\"?n++:t[a]===\"}\"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(t[s+1]===\"(\"){let n=1,a=s+2;for(;a<t.length&&n>0;)t[a]===\"(\"?n++:t[a]===\")\"&&n--,a++;r+=t.slice(s,a),s=a;continue}if(/[a-zA-Z_]/.test(t[s+1]||\"\")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[0-9]/.test(t[s+1]||\"\")){let n=s+1;for(;n<t.length&&/[0-9]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n;continue}if(/[*@#?\\-!$]/.test(t[s+1]||\"\")){let n=t[s+1],a=await v(e,n);r+=a,s+=2;continue}}if(t[s]==='\"'){for(r+='\"',s++;s<t.length&&t[s]!=='\"';)if(t[s]===\"$\"&&/[a-zA-Z_]/.test(t[s+1]||\"\")){let n=s+1;for(;n<t.length&&/[a-zA-Z0-9_]/.test(t[n]);)n++;let a=t.slice(s+1,n),i=await v(e,a);r+=i,s=n}else t[s]===\"\\\\\"?(r+=t[s],s++,s<t.length&&(r+=t[s],s++)):(r+=t[s],s++);s<t.length&&(r+='\"',s++);continue}r+=t[s],s++}return r}async function Et(e,t){let r=t,s=t.startsWith('\"')&&t.endsWith('\"'),n=t.startsWith(\"'\")&&t.endsWith(\"'\");if((s||n)&&(r=t.slice(1,-1)),n)return r;let a=\"\",i=0;for(;i<r.length;)if(r[i]===\"$\")if(r[i+1]===\"(\"){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]===\"(\"&&r[o-1]===\"$\"||r[o]===\"(\"?l++:r[o]===\")\"&&l--,o++;let c=r.slice(i+2,o-1);if(e.execFn){let u=await e.execFn(c,{signal:e.state.signal});a+=u.stdout.replace(/\\n+$/,\"\"),u.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+u.stderr)}i=o}else if(r[i+1]===\"{\"){let l=1,o=i+2;for(;o<r.length&&l>0;)r[o]===\"{\"?l++:r[o]===\"}\"&&l--,o++;let c=r.slice(i+2,o-1),u=await v(e,c);a+=u,i=o}else if(/[a-zA-Z_]/.test(r[i+1]||\"\")){let l=i+1;for(;l<r.length&&/[a-zA-Z0-9_]/.test(r[l]);)l++;let o=r.slice(i+1,l),c=await v(e,o);a+=c,i=l}else a+=r[i],i++;else if(r[i]===\"`\"){let l=i+1;for(;l<r.length&&r[l]!==\"`\";)l++;let o=r.slice(i+1,l);if(e.execFn){let c=await e.execFn(o,{signal:e.state.signal});a+=c.stdout.replace(/\\n+$/,\"\"),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+c.stderr)}i=l+1}else a+=r[i],i++;return a}var Le=1e4;function fs(e,t,r,s,n){let a=r??1;a===0&&(a=1);let i=Math.abs(a),l=[],o=0;s?.match(/^-?0\\d/)&&(o=Math.max(o,s.replace(/^-/,\"\").length)),n?.match(/^-?0\\d/)&&(o=Math.max(o,n.replace(/^-/,\"\").length));let c=u=>{if(o>0){let f=u<0,h=String(Math.abs(u)).padStart(o,\"0\");return f?`-${h}`:h}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<Le;u+=i,f++)l.push(c(u));else for(let u=e,f=0;u>=t&&f<Le;u-=i,f++)l.push(c(u));return l}function hs(e,t,r){let s=r??1;s===0&&(s=1);let n=e.charCodeAt(0),a=t.charCodeAt(0),i=Math.abs(s),l=e>=\"A\"&&e<=\"Z\",o=e>=\"a\"&&e<=\"z\",c=t>=\"A\"&&t<=\"Z\",u=t>=\"a\"&&t<=\"z\";if(l&&u||o&&c){let h=r!==void 0?`..${r}`:\"\";throw new It(`{${e}..${t}${h}}: invalid sequence`)}let f=[];if(n<=a)for(let h=n,d=0;h<=a&&d<Le;h+=i,d++)f.push(String.fromCharCode(h));else for(let h=n,d=0;h>=a&&d<Le;h-=i,d++)f.push(String.fromCharCode(h));return f}function At(e,t,r,s,n){let a=r!==void 0?`..${r}`:\"\";return typeof e==\"number\"&&typeof t==\"number\"?{expanded:fs(e,t,r,s,n),literal:`{${e}..${t}${a}}`}:typeof e==\"string\"&&typeof t==\"string\"?{expanded:hs(e,t,r),literal:`{${e}..${t}${a}}`}:{expanded:null,literal:`{${e}..${t}${a}}`}}function wn(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 r=t.pipelines[0];if(r.negated||r.commands.length!==1)return null;let s=r.commands[0];if(s.type!==\"SimpleCommand\")return null;let n=s;if(n.name!==null||n.args.length!==0||n.assignments.length!==0||n.redirections.length!==1)return null;let a=n.redirections[0];return a.operator!==\"<\"||a.target.type!==\"Word\"?null:{target:a.target}}function ne(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\\(/.test(e))}function St(e){let t=\"\",r=0;for(;r<e.length;)e[r]===\"\\\\\"&&r+1<e.length?(t+=e[r+1],r+=2):(t+=e[r],r++);return t}function X(e){return e.replace(/([*?[\\]\\\\()|])/g,\"\\\\$1\")}function bt(e){return e.replace(/[\\\\^$.*+?()[\\]{}|]/g,\"\\\\$&\")}function I(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function k(e,t,r=!1){let s=\"\",n=0;for(;n<e.length;){let a=e[n];if(r&&(a===\"@\"||a===\"*\"||a===\"+\"||a===\"?\"||a===\"!\")&&n+1<e.length&&e[n+1]===\"(\"){let i=ps(e,n+1);if(i!==-1){let l=e.slice(n+2,i),c=ds(l).map(f=>k(f,t,r)),u=c.length>0?c.join(\"|\"):\"(?:)\";a===\"@\"?s+=`(?:${u})`:a===\"*\"?s+=`(?:${u})*`:a===\"+\"?s+=`(?:${u})+`:a===\"?\"?s+=`(?:${u})?`:a===\"!\"&&(s+=`(?!(?:${u})$).*`),n=i+1;continue}}if(a===\"\\\\\")if(n+1<e.length){let i=e[n+1];/[\\\\^$.|+(){}[\\]*?]/.test(i)?s+=`\\\\${i}`:s+=i,n+=2}else s+=\"\\\\\\\\\",n++;else if(a===\"*\")s+=t?\".*\":\".*?\",n++;else if(a===\"?\")s+=\".\",n++;else if(a===\"[\"){let i=ms(e,n);if(i===-1)s+=\"\\\\[\",n++;else{let l=e.slice(n+1,i);s+=gs(l),n=i+1}}else/[\\^$.|+(){}]/.test(a)?(s+=`\\\\${a}`,n++):(s+=a,n++)}return s}function ps(e,t){let r=1,s=t+1;for(;s<e.length&&r>0;){let n=e[s];if(n===\"\\\\\"){s+=2;continue}if(n===\"(\")r++;else if(n===\")\"&&(r--,r===0))return s;s++}return-1}function ds(e){let t=[],r=\"\",s=0,n=0;for(;n<e.length;){let a=e[n];if(a===\"\\\\\"){r+=a,n+1<e.length?(r+=e[n+1],n+=2):n++;continue}a===\"(\"?(s++,r+=a):a===\")\"?(s--,r+=a):a===\"|\"&&s===0?(t.push(r),r=\"\"):r+=a,n++}return t.push(r),t}function ms(e,t){let r=t+1;for(r<e.length&&e[r]===\"^\"&&r++,r<e.length&&e[r]===\"]\"&&r++;r<e.length;){if(e[r]===\"\\\\\"&&r+1<e.length){r+=2;continue}if(e[r]===\"]\")return r;if(e[r]===\"'\"){let s=e.indexOf(\"'\",r+1);if(s!==-1){r=s+1;continue}}if(e[r]===\"[\"&&r+1<e.length&&e[r+1]===\":\"){let s=e.indexOf(\":]\",r+2);if(s!==-1){r=s+2;continue}}r++}return-1}function gs(e){let t=\"[\",r=0;for((e[0]===\"^\"||e[0]===\"!\")&&(t+=\"^\",r++);r<e.length;){if(e[r]===\"'\"){let n=e.indexOf(\"'\",r+1);if(n!==-1){let a=e.slice(r+1,n);for(let i of a)i===\"\\\\\"?t+=\"\\\\\\\\\":i===\"]\"?t+=\"\\\\]\":i===\"^\"&&t===\"[\"?t+=\"\\\\^\":t+=i;r=n+1;continue}}if(e[r]===\"[\"&&r+1<e.length&&e[r+1]===\":\"){let n=e.indexOf(\":]\",r+2);if(n!==-1){let a=e.slice(r+2,n);t+=Es(a),r=n+2;continue}}let s=e[r];s===\"\\\\\"?r+1<e.length?(t+=`\\\\${e[r+1]}`,r+=2):(t+=\"\\\\\\\\\",r++):s===\"-\"&&r>0&&r<e.length-1?(t+=\"-\",r++):s===\"^\"&&r===0?(t+=\"^\",r++):(s===\"]\"&&r===0?t+=\"\\\\]\":t+=s,r++)}return t+=\"]\",t}var ys=new Map([[\"alnum\",\"a-zA-Z0-9\"],[\"alpha\",\"a-zA-Z\"],[\"ascii\",\"\\\\x00-\\\\x7F\"],[\"blank\",\" \\\\t\"],[\"cntrl\",\"\\\\x00-\\\\x1F\\\\x7F\"],[\"digit\",\"0-9\"],[\"graph\",\"!-~\"],[\"lower\",\"a-z\"],[\"print\",\" -~\"],[\"punct\",\"!-/:-@\\\\[-`{-~\"],[\"space\",\" \\\\t\\\\n\\\\r\\\\f\\\\v\"],[\"upper\",\"A-Z\"],[\"word\",\"a-zA-Z0-9_\"],[\"xdigit\",\"0-9A-Fa-f\"]]);function Es(e){return ys.get(e)??\"\"}function se(e,t,r,s){if(r===\"prefix\")return O(`^${t}`,\"s\").replace(e,\"\");let n=O(`${t}$`,\"s\");if(s)return n.replace(e,\"\");for(let a=e.length;a>=0;a--){let i=e.slice(a);if(n.test(i))return e.slice(0,a)}return e}function me(e,t){let r=Array.from(e.state.env.keys()),s=new Set,n=e.state.associativeArrays??new Set,a=new Set;for(let l of r){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\\d+$/);o&&a.add(o[1]);let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&a.add(c[1])}let i=l=>{for(let o of n){let c=`${o}_`;if(l.startsWith(c)&&l!==o)return!0}return!1};for(let l of r)if(l.startsWith(t))if(l.includes(\"__\")){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);o?.[1].startsWith(t)&&s.add(o[1])}else if(/_\\d+$/.test(l)){let o=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\\d+$/);o?.[1].startsWith(t)&&s.add(o[1])}else i(l)||s.add(l);return[...s].sort()}function As(e,t){let r=(a,i=2)=>String(a).padStart(i,\"0\");if(e===\"\"){let a=r(t.getHours()),i=r(t.getMinutes()),l=r(t.getSeconds());return`${a}:${i}:${l}`}let s=\"\",n=0;for(;n<e.length;)if(e[n]===\"%\"){if(n+1>=e.length){s+=\"%\",n++;continue}let a=e[n+1];switch(a){case\"H\":s+=r(t.getHours());break;case\"M\":s+=r(t.getMinutes());break;case\"S\":s+=r(t.getSeconds());break;case\"d\":s+=r(t.getDate());break;case\"m\":s+=r(t.getMonth()+1);break;case\"Y\":s+=t.getFullYear();break;case\"y\":s+=r(t.getFullYear()%100);break;case\"I\":{let i=t.getHours()%12;i===0&&(i=12),s+=r(i);break}case\"p\":s+=t.getHours()<12?\"AM\":\"PM\";break;case\"P\":s+=t.getHours()<12?\"am\":\"pm\";break;case\"%\":s+=\"%\";break;case\"a\":{s+=[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"][t.getDay()];break}case\"b\":{s+=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"][t.getMonth()];break}default:s+=`%${a}`}n+=2}else s+=e[n],n++;return s}function we(e,t){let r=\"\",s=0,n=e.state.env.get(\"USER\")||e.state.env.get(\"LOGNAME\")||\"user\",a=e.state.env.get(\"HOSTNAME\")||\"localhost\",i=a.split(\".\")[0],l=e.state.env.get(\"PWD\")||\"/\",o=e.state.env.get(\"HOME\")||\"/\",c=l.startsWith(o)?`~${l.slice(o.length)}`:l,u=l.split(\"/\").pop()||l,f=new Date,h=[\"Sun\",\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\",\"Sat\"],d=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"],m=e.state.env.get(\"__COMMAND_NUMBER\")||\"1\";for(;s<t.length;){let g=t[s];if(g===\"\\\\\"){if(s+1>=t.length){r+=\"\\\\\",s++;continue}let E=t[s+1];if(E>=\"0\"&&E<=\"7\"){let A=\"\",S=s+1;for(;S<t.length&&S<s+4&&t[S]>=\"0\"&&t[S]<=\"7\";)A+=t[S],S++;let y=Number.parseInt(A,8)%256;r+=String.fromCharCode(y),s=S;continue}switch(E){case\"\\\\\":r+=\"\\\\\",s+=2;break;case\"a\":r+=\"\\x07\",s+=2;break;case\"e\":r+=\"\\x1B\",s+=2;break;case\"n\":r+=`\n`,s+=2;break;case\"r\":r+=\"\\r\",s+=2;break;case\"$\":r+=\"$\",s+=2;break;case\"[\":case\"]\":s+=2;break;case\"u\":r+=n,s+=2;break;case\"h\":r+=i,s+=2;break;case\"H\":r+=a,s+=2;break;case\"w\":r+=c,s+=2;break;case\"W\":r+=u,s+=2;break;case\"d\":{let A=String(f.getDate()).padStart(2,\" \");r+=`${h[f.getDay()]} ${d[f.getMonth()]} ${A}`,s+=2;break}case\"t\":{let A=String(f.getHours()).padStart(2,\"0\"),S=String(f.getMinutes()).padStart(2,\"0\"),y=String(f.getSeconds()).padStart(2,\"0\");r+=`${A}:${S}:${y}`,s+=2;break}case\"T\":{let A=f.getHours()%12;A===0&&(A=12);let S=String(A).padStart(2,\"0\"),y=String(f.getMinutes()).padStart(2,\"0\"),b=String(f.getSeconds()).padStart(2,\"0\");r+=`${S}:${y}:${b}`,s+=2;break}case\"@\":{let A=f.getHours()%12;A===0&&(A=12);let S=String(A).padStart(2,\"0\"),y=String(f.getMinutes()).padStart(2,\"0\"),b=f.getHours()<12?\"AM\":\"PM\";r+=`${S}:${y} ${b}`,s+=2;break}case\"A\":{let A=String(f.getHours()).padStart(2,\"0\"),S=String(f.getMinutes()).padStart(2,\"0\");r+=`${A}:${S}`,s+=2;break}case\"D\":if(s+2<t.length&&t[s+2]===\"{\"){let A=t.indexOf(\"}\",s+3);if(A!==-1){let S=t.slice(s+3,A);r+=As(S,f),s=A+1}else r+=\"\\\\D\",s+=2}else r+=\"\\\\D\",s+=2;break;case\"s\":r+=\"bash\",s+=2;break;case\"v\":r+=\"5.0\",s+=2;break;case\"V\":r+=\"5.0.0\",s+=2;break;case\"j\":r+=\"0\",s+=2;break;case\"l\":r+=\"tty\",s+=2;break;case\"#\":r+=m,s+=2;break;case\"!\":r+=m,s+=2;break;case\"x\":r+=\"\\\\x\",s+=2;break;default:r+=`\\\\${E}`,s+=2}}else r+=g,s++}return r}function le(e){if(e===\"\")return\"''\";if(/[\\n\\r\\t\\x00-\\x1f\\x7f']/.test(e)){let r=\"$'\";for(let s of e)switch(s){case\"'\":r+=\"\\\\'\";break;case\"\\\\\":r+=\"\\\\\\\\\";break;case`\n`:r+=\"\\\\n\";break;case\"\\r\":r+=\"\\\\r\";break;case\"\t\":r+=\"\\\\t\";break;default:{let n=s.charCodeAt(0);n<32||n===127?r+=`\\\\${n.toString(8).padStart(3,\"0\")}`:r+=s}}return`${r}'`}return`'${e}'`}function pa(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function wt(e,t){return e.state.readonlyVars?.has(t)??!1}function da(e,t,r=\"bash\"){if(wt(e,t)){let s=`${r}: ${t}: readonly variable\n`;throw new K(1,\"\",s)}return null}function ma(e,t){let r=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)&&!r){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 ga(e,t){e.state.exportedVars?.delete(t)}function ue(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return\"\";let r=\"\",s=e.state.env.has(`${t}__length`)||Array.from(e.state.env.keys()).some(a=>a.startsWith(`${t}_`)&&/^[0-9]+$/.test(a.slice(t.length+1))),n=e.state.associativeArrays?.has(t)??!1;return s&&!n&&(r+=\"a\"),n&&(r+=\"A\"),e.state.integerVars?.has(t)&&(r+=\"i\"),W(e,t)&&(r+=\"n\"),wt(e,t)&&(r+=\"r\"),e.state.exportedVars?.has(t)&&(r+=\"x\"),r}async function Nn(e,t,r,s){return e.coverage?.hit(\"bash:expansion:default_value\"),(r.isUnset||t.checkEmpty&&r.isEmpty)&&t.word?s(e,t.word.parts,r.inDoubleQuotes):r.effectiveValue}async function kn(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:assign_default\"),(s.isUnset||r.checkEmpty&&s.isEmpty)&&r.word){let i=await n(e,r.word.parts,s.inDoubleQuotes),l=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(l){let[,o,c]=l,u;if(/^\\d+$/.test(c))u=Number.parseInt(c,10);else{try{let h=new V,d=M(h,c);u=await R(e,d.expression)}catch{let h=e.state.env.get(c);u=h?Number.parseInt(h,10):0}Number.isNaN(u)&&(u=0)}e.state.env.set(`${o}_${u}`,i);let f=Number.parseInt(e.state.env.get(`${o}__length`)||\"0\",10);u>=f&&e.state.env.set(`${o}__length`,String(u+1))}else e.state.env.set(t,i);return i}return s.effectiveValue}async function Pn(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:error_if_unset\"),s.isUnset||r.checkEmpty&&s.isEmpty){let i=r.word?await n(e,r.word.parts,s.inDoubleQuotes):`${t}: parameter null or not set`;throw new K(1,\"\",`bash: ${i}\n`)}return s.effectiveValue}async function Rn(e,t,r,s){return e.coverage?.hit(\"bash:expansion:use_alternative\"),!(r.isUnset||t.checkEmpty&&r.isEmpty)&&t.word?s(e,t.word.parts,r.inDoubleQuotes):\"\"}async function In(e,t,r,s,n){e.coverage?.hit(\"bash:expansion:pattern_removal\");let a=\"\",i=e.state.shoptOptions.extglob;if(r.pattern)for(let o of r.pattern.parts)if(o.type===\"Glob\")a+=k(o.pattern,r.greedy,i);else if(o.type===\"Literal\")a+=k(o.value,r.greedy,i);else if(o.type===\"SingleQuoted\"||o.type===\"Escaped\")a+=I(o.value);else if(o.type===\"DoubleQuoted\"){let c=await s(e,o.parts);a+=I(c)}else if(o.type===\"ParameterExpansion\"){let c=await n(e,o);a+=k(c,r.greedy,i)}else{let c=await n(e,o);a+=I(c)}if(r.side===\"prefix\")return O(`^${a}`,\"s\").replace(t,\"\");let l=O(`${a}$`,\"s\");if(r.greedy)return l.replace(t,\"\");for(let o=t.length;o>=0;o--){let c=t.slice(o);if(l.test(c))return t.slice(0,o)}return t}async function vn(e,t,r,s,n){e.coverage?.hit(\"bash:expansion:pattern_replacement\");let a=\"\",i=e.state.shoptOptions.extglob;if(r.pattern)for(let c of r.pattern.parts)if(c.type===\"Glob\")a+=k(c.pattern,!0,i);else if(c.type===\"Literal\")a+=k(c.value,!0,i);else if(c.type===\"SingleQuoted\"||c.type===\"Escaped\")a+=I(c.value);else if(c.type===\"DoubleQuoted\"){let u=await s(e,c.parts);a+=I(u)}else if(c.type===\"ParameterExpansion\"){let u=await n(e,c);a+=k(u,!0,i)}else{let u=await n(e,c);a+=I(u)}let l=r.replacement?await s(e,r.replacement.parts):\"\";if(r.anchor===\"start\"?a=`^${a}`:r.anchor===\"end\"&&(a=`${a}$`),a===\"\")return t;let o=r.all?\"gs\":\"s\";try{let c=O(a,o);if(r.all){let u=\"\",f=0,h=0,d=e.limits.maxStringLength,m=c.exec(t);for(;m!==null&&!(m[0].length===0&&m.index===t.length);){if(u+=t.slice(f,m.index)+l,f=m.index+m[0].length,m[0].length===0&&f++,h++,h%100===0&&u.length>d)throw new L(`pattern replacement: string length limit exceeded (${d} bytes)`,\"string_length\");m=c.exec(t)}return u+=t.slice(f),u}return c.replace(t,l)}catch(c){if(c instanceof L)throw c;return t}}function Dn(e,t,r){e.coverage?.hit(\"bash:expansion:length\");let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(s){let n=s[1],a=P(e,n);return a.length>0?String(a.length):e.state.env.get(n)!==void 0?\"1\":\"0\"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&be(e,t)){if(t===\"FUNCNAME\"){let a=e.state.funcNameStack?.[0]||\"\";return String([...a].length)}if(t===\"BASH_LINENO\"){let a=e.state.callLineStack?.[0];return String(a!==void 0?[...String(a)].length:0)}let n=e.state.env.get(`${t}_0`)||\"\";return String([...n].length)}return String([...r].length)}async function xn(e,t,r,s){e.coverage?.hit(\"bash:expansion:substring\");let n=await R(e,s.offset.expression),a=s.length?await R(e,s.length.expression):void 0;if(t===\"@\"||t===\"*\"){let c=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),u=[];for(let m=1;m<=c;m++)u.push(e.state.env.get(String(m))||\"\");let f=e.state.env.get(\"0\")||\"bash\",h,d;if(n<=0)if(h=[f,...u],n<0){if(d=h.length+n,d<0)return\"\"}else d=0;else h=u,d=n-1;if(d<0||d>=h.length)return\"\";if(a!==void 0){let m=a<0?h.length+a:d+a;return h.slice(d,Math.max(d,m)).join(\" \")}return h.slice(d).join(\" \")}let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(i){let c=i[1];if(e.state.associativeArrays?.has(c))throw new K(1,\"\",`bash: \\${${c}[@]: 0: 3}: bad substitution\n`);let u=P(e,c),f=0;if(n<0){if(u.length>0){let h=u[u.length-1][0],m=(typeof h==\"number\"?h:0)+1+n;if(m<0||(f=u.findIndex(([g])=>typeof g==\"number\"&&g>=m),f<0))return\"\"}}else if(f=u.findIndex(([h])=>typeof h==\"number\"&&h>=n),f<0)return\"\";if(a!==void 0){if(a<0)throw new C(`${i[1]}[@]: substring expression < 0`);return u.slice(f,f+a).map(([,h])=>h).join(\" \")}return u.slice(f).map(([,h])=>h).join(\" \")}let l=[...r],o=n;if(o<0&&(o=Math.max(0,l.length+o)),a!==void 0){if(a<0){let c=l.length+a;return l.slice(o,Math.max(o,c)).join(\"\")}return l.slice(o,o+a).join(\"\")}return l.slice(o).join(\"\")}async function _n(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:case_modification\"),r.pattern){let a=e.state.shoptOptions.extglob,i=\"\";for(let f of r.pattern.parts)if(f.type===\"Glob\")i+=k(f.pattern,!0,a);else if(f.type===\"Literal\")i+=k(f.value,!0,a);else if(f.type===\"SingleQuoted\"||f.type===\"Escaped\")i+=I(f.value);else if(f.type===\"DoubleQuoted\"){let h=await s(e,f.parts);i+=I(h)}else if(f.type===\"ParameterExpansion\"){let h=await n(e,f);i+=k(h,!0,a)}let l=O(`^(?:${i})$`),o=r.direction===\"upper\"?f=>f.toUpperCase():f=>f.toLowerCase(),c=\"\",u=!1;for(let f of t)!r.all&&u?c+=f:l.test(f)?(c+=o(f),u=!0):c+=f;return c}return r.direction===\"upper\"?r.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):r.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function $n(e,t,r,s,n){e.coverage?.hit(\"bash:expansion:transform\");let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[[@*]\\]$/);if(a&&n.operator===\"Q\")return P(e,a[1]).map(([,c])=>le(c)).join(\" \");if(a&&n.operator===\"a\")return ue(e,a[1]);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[.+\\]$/);if(i&&n.operator===\"a\")return ue(e,i[1]);switch(n.operator){case\"Q\":return s?\"\":le(r);case\"P\":return we(e,r);case\"a\":return ue(e,t);case\"A\":return s?\"\":`${t}=${le(r)}`;case\"E\":return r.replace(/\\\\([\\\\abefnrtv'\"?])/g,(l,o)=>{switch(o){case\"\\\\\":return\"\\\\\";case\"a\":return\"\\x07\";case\"b\":return\"\\b\";case\"e\":return\"\\x1B\";case\"f\":return\"\\f\";case\"n\":return`\n`;case\"r\":return\"\\r\";case\"t\":return\"\t\";case\"v\":return\"\\v\";case\"'\":return\"'\";case'\"':return'\"';case\"?\":return\"?\";default:return o}});case\"K\":case\"k\":return s?\"\":le(r);case\"u\":return r.charAt(0).toUpperCase()+r.slice(1);case\"U\":return r.toUpperCase();case\"L\":return r.toLowerCase();default:return r}}async function Cn(e,t,r,s,n,a,i=!1){if(e.coverage?.hit(\"bash:expansion:indirection\"),W(e,t))return Se(e,t)||\"\";let l=/^[a-zA-Z_][a-zA-Z0-9_]*\\[([@*])\\]$/.test(t);if(s){if(n.innerOp?.type===\"UseAlternative\")return\"\";throw new re(`\\${!${t}}`)}let o=r;if(l&&(o===\"\"||o.includes(\" \")))throw new re(`\\${!${t}}`);let c=o.match(/^[a-zA-Z_][a-zA-Z0-9_]*\\[(.+)\\]$/);if(c&&c[1].includes(\"~\"))throw new re(`\\${!${t}}`);if(n.innerOp){let u={type:\"ParameterExpansion\",parameter:o,operation:n.innerOp};return a(e,u,i)}return await v(e,o)}function On(e,t){e.coverage?.hit(\"bash:expansion:array_keys\");let s=P(e,t.array).map(([n])=>String(n));return t.star?s.join(N(e.state.env)):s.join(\" \")}function Ln(e,t){e.coverage?.hit(\"bash:expansion:var_name_prefix\");let r=me(e,t.prefix);return t.star?r.join(N(e.state.env)):r.join(\" \")}function Wn(e,t,r,s){let n=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(t===\"*\")return{isEmpty:n===0,effectiveValue:r};if(t===\"@\")return{isEmpty:n===0||n===1&&e.state.env.get(\"1\")===\"\",effectiveValue:r};if(a){let[,i,l]=a,o=P(e,i);if(o.length===0)return{isEmpty:!0,effectiveValue:\"\"};if(l===\"*\"){let c=N(e.state.env),u=o.map(([,f])=>f).join(c);return{isEmpty:s?u===\"\":!1,effectiveValue:u}}return{isEmpty:o.length===1&&o.every(([,c])=>c===\"\"),effectiveValue:o.map(([,c])=>c).join(\" \")}}return{isEmpty:r===\"\",effectiveValue:r}}function Tn(e){let t=0;for(;t<e.length;){let r=e[t];if(r===\"\\\\\"&&t+1<e.length){t+=2;continue}if(r===\"'\"){let s=e.indexOf(\"'\",t+1);if(s!==-1){t=s+1;continue}}if(r===\"$\"&&t+1<e.length&&e[t+1]===\"(\"||r===\"`\")return!0;t++}return!1}function Mn(e,t){let r=1,s=t,n=!1,a=!1;for(;s<e.length&&r>0;){let i=e[s];if(i===\"\\\\\"&&!n&&s+1<e.length){s+=2;continue}if(i===\"'\"&&!a){n=!n,s++;continue}if(i==='\"'&&!n){a=!a,s++;continue}if(!n&&!a){if(i===\"(\")r++;else if(i===\")\"&&(r--,r===0))return s}s++}return-1}async function We(e,t){let r=new V,s;try{s=r.parse(t)}catch{return\"\"}let n=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let a=new Map(e.state.env),i=e.state.cwd,l=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let o=await e.executeScript(s),c=o.exitCode;return e.state.env=a,e.state.cwd=i,e.state.suppressVerbose=l,e.state.lastExitCode=c,e.state.env.set(\"?\",String(c)),o.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+o.stderr),e.state.bashPid=n,o.stdout.replace(/\\n+$/,\"\")}catch(o){if(e.state.env=a,e.state.cwd=i,e.state.bashPid=n,e.state.suppressVerbose=l,o instanceof L)throw o;return o instanceof K?(e.state.lastExitCode=o.exitCode,e.state.env.set(\"?\",String(o.exitCode)),o.stdout?.replace(/\\n+$/,\"\")??\"\"):\"\"}}function Nt(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"'\"){let a=t.indexOf(\"'\",s+1);if(a!==-1){let i=t.slice(s+1,a);r+=X(i),s=a+1;continue}}if(n==='\"'){let a=-1,i=s+1;for(;i<t.length;){if(t[i]===\"\\\\\"){i+=2;continue}if(t[i]==='\"'){a=i;break}i++}if(a!==-1){let l=t.slice(s+1,a),o=Ss(e,l);r+=X(o),s=a+1;continue}}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}if(n===\"\\\\\"&&s+1<t.length){r+=n+t[s+1],s+=2;continue}r+=n,s++}return r}function Ss(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"\\\\\"&&s+1<t.length){let a=t[s+1];if(a===\"$\"||a===\"`\"||a===\"\\\\\"||a==='\"'){r+=a,s+=2;continue}r+=n,s++;continue}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}r+=n,s++}return r}async function Vn(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"'\"){let a=t.indexOf(\"'\",s+1);if(a!==-1){let i=t.slice(s+1,a);r+=X(i),s=a+1;continue}}if(n==='\"'){let a=-1,i=s+1;for(;i<t.length;){if(t[i]===\"\\\\\"){i+=2;continue}if(t[i]==='\"'){a=i;break}i++}if(a!==-1){let l=t.slice(s+1,a),o=await bs(e,l);r+=X(o),s=a+1;continue}}if(n===\"$\"&&s+1<t.length&&t[s+1]===\"(\"){let a=Mn(t,s+2);if(a!==-1){let i=t.slice(s+2,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"`\"){let a=t.indexOf(\"`\",s+1);if(a!==-1){let i=t.slice(s+1,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}if(n===\"\\\\\"&&s+1<t.length){r+=n+t[s+1],s+=2;continue}r+=n,s++}return r}async function bs(e,t){let r=\"\",s=0;for(;s<t.length;){let n=t[s];if(n===\"\\\\\"&&s+1<t.length){let a=t[s+1];if(a===\"$\"||a===\"`\"||a===\"\\\\\"||a==='\"'){r+=a,s+=2;continue}r+=n,s++;continue}if(n===\"$\"&&s+1<t.length&&t[s+1]===\"(\"){let a=Mn(t,s+2);if(a!==-1){let i=t.slice(s+2,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"`\"){let a=t.indexOf(\"`\",s+1);if(a!==-1){let i=t.slice(s+1,a),l=await We(e,i);r+=l,s=a+1;continue}}if(n===\"$\"&&s+1<t.length){let a=t[s+1];if(a===\"{\"){let i=t.indexOf(\"}\",s+2);if(i!==-1){let l=t.slice(s+2,i);r+=e.state.env.get(l)??\"\",s=i+1;continue}}else if(/[a-zA-Z_]/.test(a)){let i=s+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let l=t.slice(s+1,i);r+=e.state.env.get(l)??\"\",s=i;continue}}r+=n,s++}return r}function qn(e,t){if(!t.startsWith(\"~\"))return t;e.coverage?.hit(\"bash:expansion:tilde\");let r=e.state.env.get(\"HOME\")!==void 0?e.state.env.get(\"HOME\"):\"/home/user\";if(t===\"~\"||t.startsWith(\"~/\"))return r+t.slice(1);let s=1;for(;s<t.length&&/[a-zA-Z0-9_-]/.test(t[s]);)s++;let n=t.slice(1,s),a=t.slice(s);return a!==\"\"&&!a.startsWith(\"/\")?t:n===\"root\"?`/root${a}`:t}async function ws(e,t,r,s){let n=\"\";for(let a of t.parts)if(a.type===\"Glob\")n+=k(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===\"Literal\")n+=k(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===\"SingleQuoted\"||a.type===\"Escaped\")n+=I(a.value);else if(a.type===\"DoubleQuoted\"){let i=await r(e,a.parts);n+=I(i)}else if(a.type===\"ParameterExpansion\"){let i=await s(e,a);n+=k(i,!0,e.state.shoptOptions.extglob)}else{let i=await s(e,a);n+=I(i)}return n}async function Bn(e,t,r,s){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!==\"PatternReplacement\")return null;let a=n.parts[0],i=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!i)return null;let l=i[1],o=i[2]===\"*\",c=a.operation,u=P(e,l),f=u.map(([,E])=>E);if(u.length===0){let E=e.state.env.get(l);E!==void 0&&f.push(E)}if(f.length===0)return{values:[],quoted:!0};let h=\"\";c.pattern&&(h=await ws(e,c.pattern,r,s));let d=c.replacement?await r(e,c.replacement.parts):\"\",m=h;c.anchor===\"start\"?m=`^${h}`:c.anchor===\"end\"&&(m=`${h}$`);let g=[];try{let E=O(m,c.all?\"g\":\"\");for(let A of f)g.push(E.replace(A,d))}catch{g.push(...f)}if(o){let E=N(e.state.env);return{values:[g.join(E)],quoted:!0}}return{values:g,quoted:!0}}async function Fn(e,t,r,s){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!==\"PatternRemoval\")return null;let a=n.parts[0],i=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!i)return null;let l=i[1],o=i[2]===\"*\",c=a.operation,u=P(e,l),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env.get(l);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h=\"\",d=e.state.shoptOptions.extglob;if(c.pattern)for(let g of c.pattern.parts)if(g.type===\"Glob\")h+=k(g.pattern,c.greedy,d);else if(g.type===\"Literal\")h+=k(g.value,c.greedy,d);else if(g.type===\"SingleQuoted\"||g.type===\"Escaped\")h+=I(g.value);else if(g.type===\"DoubleQuoted\"){let E=await r(e,g.parts);h+=I(E)}else if(g.type===\"ParameterExpansion\"){let E=await s(e,g);h+=k(E,c.greedy,d)}else{let E=await s(e,g);h+=I(E)}let m=[];for(let g of f)m.push(se(g,h,c.side,c.greedy));if(o){let g=N(e.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}async function zn(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\"||r.parts[0].operation?.type!==\"DefaultValue\"&&r.parts[0].operation?.type!==\"UseAlternative\"&&r.parts[0].operation?.type!==\"AssignDefault\")return null;let s=r.parts[0],n=s.operation,a=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/),i,l=!1;if(a){let o=a[1];l=a[2]===\"*\";let c=P(e,o),u=c.length>0||e.state.env.has(o),f=c.length===0||c.length===1&&c.every(([,d])=>d===\"\"),h=n.checkEmpty??!1;if(n.type===\"UseAlternative\"?i=u&&!(h&&f):i=!u||h&&f,!i){if(c.length>0){let m=c.map(([,g])=>g);if(l){let g=N(e.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}let d=e.state.env.get(o);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let o=s.parameter,c=await te(e,o),u=await v(e,o),f=u===\"\",h=n.checkEmpty??!1;if(n.type===\"UseAlternative\"?i=c&&!(h&&f):i=!c||h&&f,!i)return{values:[u],quoted:!0}}if(i&&n.word){let o=n.word.parts,c=null,u=!1;for(let f of o)if(f.type===\"ParameterExpansion\"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(h){c=h[1],u=h[2]===\"*\";break}}if(c){let f=P(e,c);if(f.length>0){let d=f.map(([,m])=>m);if(u||l){let m=N(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}let h=e.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function Gn(e,t,r,s,n){if(!r||t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let a=t[0],i=-1,l=\"\",o=!1,c=null;for(let g=0;g<a.parts.length;g++){let E=a.parts[g];if(E.type===\"ParameterExpansion\"&&(E.operation?.type===\"PatternRemoval\"||E.operation?.type===\"PatternReplacement\")){let A=E.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(A){i=g,l=A[1],o=A[2]===\"*\",c=E.operation;break}}}if(i===-1||i===0&&i===a.parts.length-1)return null;let u=\"\";for(let g=0;g<i;g++)u+=await s(e,a.parts[g]);let f=\"\";for(let g=i+1;g<a.parts.length;g++)f+=await s(e,a.parts[g]);let h=P(e,l),d=h.map(([,g])=>g);if(h.length===0){let g=e.state.env.get(l);if(g!==void 0)d=[g];else{if(o)return{values:[u+f],quoted:!0};let E=u+f;return{values:E?[E]:[],quoted:!0}}}if(c?.type===\"PatternRemoval\"){let g=c,E=\"\",A=e.state.shoptOptions.extglob;if(g.pattern)for(let S of g.pattern.parts)if(S.type===\"Glob\")E+=k(S.pattern,g.greedy,A);else if(S.type===\"Literal\")E+=k(S.value,g.greedy,A);else if(S.type===\"SingleQuoted\"||S.type===\"Escaped\")E+=I(S.value);else if(S.type===\"DoubleQuoted\"){let y=await n(e,S.parts);E+=I(y)}else if(S.type===\"ParameterExpansion\"){let y=await s(e,S);E+=k(y,g.greedy,A)}else{let y=await s(e,S);E+=I(y)}d=d.map(S=>se(S,E,g.side,g.greedy))}else if(c?.type===\"PatternReplacement\"){let g=c,E=\"\";if(g.pattern)for(let y of g.pattern.parts)if(y.type===\"Glob\")E+=k(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type===\"Literal\")E+=k(y.value,!0,e.state.shoptOptions.extglob);else if(y.type===\"SingleQuoted\"||y.type===\"Escaped\")E+=I(y.value);else if(y.type===\"DoubleQuoted\"){let b=await n(e,y.parts);E+=I(b)}else if(y.type===\"ParameterExpansion\"){let b=await s(e,y);E+=k(b,!0,e.state.shoptOptions.extglob)}else{let b=await s(e,y);E+=I(b)}let A=g.replacement?await n(e,g.replacement.parts):\"\",S=E;g.anchor===\"start\"?S=`^${E}`:g.anchor===\"end\"&&(S=`${E}$`);try{let y=O(S,g.all?\"g\":\"\");d=d.map(b=>y.replace(b,A))}catch{}}if(o){let g=N(e.state.env);return{values:[u+d.join(g)+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 Qn(e,t,r,s){if(!r||t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=\"\",l=!1;for(let d=0;d<n.parts.length;d++){let m=n.parts[d];if(m.type===\"ParameterExpansion\"&&!m.operation){let g=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(g){a=d,i=g[1],l=g[2]===\"*\";break}}}if(a===-1)return null;let o=\"\";for(let d=0;d<a;d++)o+=await s(e,n.parts[d]);let c=\"\";for(let d=a+1;d<n.parts.length;d++)c+=await s(e,n.parts[d]);let u=P(e,i),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env.get(i);if(d!==void 0)return{values:[o+d+c],quoted:!0};if(l)return{values:[o+c],quoted:!0};let m=o+c;return{values:m?[m]:[],quoted:!0}}if(l){let d=N(e.state.env);return{values:[o+f.join(d)+c],quoted:!0}}return f.length===1?{values:[o+f[0]+c],quoted:!0}:{values:[o+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}async function Zn(e,t,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!==\"Substring\")return null;let n=s.parts[0],a=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!a)return null;let i=a[1],l=a[2]===\"*\",o=n.operation;if(e.state.associativeArrays?.has(i))throw new K(1,\"\",`bash: \\${${i}[@]: 0: 3}: bad substitution\n`);let c=o.offset?await r(e,o.offset.expression):0,u=o.length?await r(e,o.length.expression):void 0,f=P(e,i),h=0;if(c<0){if(f.length>0){let m=f[f.length-1][0],E=(typeof m==\"number\"?m:0)+1+c;if(E<0)return{values:[],quoted:!0};h=f.findIndex(([A])=>typeof A==\"number\"&&A>=E),h<0&&(h=f.length)}}else h=f.findIndex(([m])=>typeof m==\"number\"&&m>=c),h<0&&(h=f.length);let d;if(u!==void 0){if(u<0)throw new C(`${i}[@]: substring expression < 0`);d=f.slice(h,h+u).map(([,m])=>m)}else d=f.slice(h).map(([,m])=>m);if(d.length===0)return{values:[],quoted:!0};if(l){let m=N(e.state.env);return{values:[d.join(m)],quoted:!0}}return{values:d,quoted:!0}}function Un(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\"||r.parts[0].operation?.type!==\"Transform\")return null;let s=r.parts[0],n=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!n)return null;let a=n[1],i=n[2]===\"*\",l=s.operation,o=P(e,a);if(o.length===0){let f=e.state.env.get(a);if(f!==void 0){let h;switch(l.operator){case\"a\":h=\"\";break;case\"P\":h=we(e,f);break;case\"Q\":h=le(f);break;default:h=f}return{values:[h],quoted:!0}}return i?{values:[\"\"],quoted:!0}:{values:[],quoted:!0}}let c=ue(e,a),u;switch(l.operator){case\"a\":u=o.map(()=>c);break;case\"P\":u=o.map(([,f])=>we(e,f));break;case\"Q\":u=o.map(([,f])=>le(f));break;case\"u\":u=o.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case\"U\":u=o.map(([,f])=>f.toUpperCase());break;case\"L\":u=o.map(([,f])=>f.toLowerCase());break;default:u=o.map(([,f])=>f)}if(i){let f=N(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}function Hn(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\")return null;let s=r.parts[0];if(s.operation)return null;let n=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(@)\\]$/);if(!n)return null;let a=n[1];if(W(e,a)){let o=Se(e,a);if(o?.endsWith(\"[@]\")||o?.endsWith(\"[*]\"))return{values:[],quoted:!0}}let i=P(e,a);if(i.length>0)return{values:i.map(([,o])=>o),quoted:!0};let l=e.state.env.get(a);return l!==void 0?{values:[l],quoted:!0}:{values:[],quoted:!0}}function jn(e,t){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==\"ParameterExpansion\"||r.parts[0].operation)return null;let n=r.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||!W(e,n))return null;let a=Se(e,n);if(!a)return null;let i=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(@)\\]$/);if(!i)return null;let l=i[1],o=P(e,l);if(o.length>0)return{values:o.map(([,u])=>u),quoted:!0};let c=e.state.env.get(l);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}async function Kn(e,t,r,s,n){if(!r||t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==\"ParameterExpansion\"||a.parts[0].operation?.type!==\"Indirection\")return null;let i=a.parts[0],l=i.operation,o=await v(e,i.parameter),c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!c){if(!l.innerOp&&(o===\"@\"||o===\"*\")){let m=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),g=[];for(let E=1;E<=m;E++)g.push(e.state.env.get(String(E))||\"\");return o===\"*\"?{values:[g.join(N(e.state.env))],quoted:!0}:{values:g,quoted:!0}}return null}let u=c[1],f=c[2]===\"*\",h=P(e,u);if(l.innerOp){if(l.innerOp.type===\"Substring\")return Ns(e,h,u,f,l.innerOp);if(l.innerOp.type===\"DefaultValue\"||l.innerOp.type===\"UseAlternative\"||l.innerOp.type===\"AssignDefault\"||l.innerOp.type===\"ErrorIfUnset\")return ks(e,h,u,f,l.innerOp,n);if(l.innerOp.type===\"Transform\"&&l.innerOp.operator===\"a\"){let g=ue(e,u),E=h.map(()=>g);return f?{values:[E.join(N(e.state.env))],quoted:!0}:{values:E,quoted:!0}}let m=[];for(let[,g]of h){let E={type:\"ParameterExpansion\",parameter:\"_indirect_elem_\",operation:l.innerOp},A=e.state.env.get(\"_indirect_elem_\");e.state.env.set(\"_indirect_elem_\",g);try{let S=await s(e,E,!0);m.push(S)}finally{A!==void 0?e.state.env.set(\"_indirect_elem_\",A):e.state.env.delete(\"_indirect_elem_\")}}return f?{values:[m.join(N(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(h.length>0){let m=h.map(([,g])=>g);return f?{values:[m.join(N(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let d=e.state.env.get(u);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function Ns(e,t,r,s,n){let a=n.offset?await R(e,n.offset.expression):0,i=n.length?await R(e,n.length.expression):void 0,l=0;if(a<0){if(t.length>0){let u=t[t.length-1][0],h=(typeof u==\"number\"?u:0)+1+a;if(h<0)return{values:[],quoted:!0};if(l=t.findIndex(([d])=>typeof d==\"number\"&&d>=h),l<0)return{values:[],quoted:!0}}}else if(l=t.findIndex(([u])=>typeof u==\"number\"&&u>=a),l<0)return{values:[],quoted:!0};let o;if(i!==void 0){if(i<0)throw new C(`${r}[@]: substring expression < 0`);o=t.slice(l,l+i)}else o=t.slice(l);let c=o.map(([,u])=>u);return s?{values:[c.join(N(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function ks(e,t,r,s,n,a){let i=n.checkEmpty??!1,l=t.map(([,u])=>u),o=t.length===0,c=t.length===0;if(n.type===\"UseAlternative\")return!c&&!(i&&o)&&n.word?{values:[await a(e,n.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(n.type===\"DefaultValue\")return(c||i&&o)&&n.word?{values:[await a(e,n.word.parts,!0)],quoted:!0}:s?{values:[l.join(N(e.state.env))],quoted:!0}:{values:l,quoted:!0};if(n.type===\"AssignDefault\"){if((c||i&&o)&&n.word){let f=await a(e,n.word.parts,!0);return e.state.env.set(`${r}_0`,f),e.state.env.set(`${r}__length`,\"1\"),{values:[f],quoted:!0}}return s?{values:[l.join(N(e.state.env))],quoted:!0}:{values:l,quoted:!0}}return s?{values:[l.join(N(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function Xn(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"UseAlternative\"&&t[0].operation?.type!==\"DefaultValue\")return null;let r=t[0],s=r.operation,n=s?.word;if(!n||n.parts.length!==1||n.parts[0].type!==\"DoubleQuoted\")return null;let a=n.parts[0];if(a.parts.length!==1||a.parts[0].type!==\"ParameterExpansion\"||a.parts[0].operation?.type!==\"Indirection\")return null;let i=a.parts[0],o=(await v(e,i.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!o)return null;let c=await te(e,r.parameter),u=await v(e,r.parameter)===\"\",f=s.checkEmpty??!1,h;if(s.type===\"UseAlternative\"?h=c&&!(f&&u):h=!c||f&&u,h){let d=o[1],m=o[2]===\"*\",g=P(e,d);if(g.length>0){let A=g.map(([,S])=>S);return m?{values:[A.join(N(e.state.env))],quoted:!0}:{values:A,quoted:!0}}let E=e.state.env.get(d);return E!==void 0?{values:[E],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function Jn(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"Indirection\")return null;let r=t[0],n=r.operation.innerOp;if(!n||n.type!==\"UseAlternative\"&&n.type!==\"DefaultValue\")return null;let a=n.word;if(!a||a.parts.length!==1||a.parts[0].type!==\"DoubleQuoted\")return null;let i=a.parts[0];if(i.parts.length!==1||i.parts[0].type!==\"ParameterExpansion\"||i.parts[0].operation?.type!==\"Indirection\")return null;let l=i.parts[0],c=(await v(e,l.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!c)return null;let u=await v(e,r.parameter),f=await te(e,r.parameter),h=u===\"\",d=n.checkEmpty??!1,m;if(n.type===\"UseAlternative\"?m=f&&!(d&&h):m=!f||d&&h,m){let g=c[1],E=c[2]===\"*\",A=P(e,g);if(A.length>0){let y=A.map(([,b])=>b);return E?{values:[y.join(N(e.state.env))],quoted:!0}:{values:y,quoted:!0}}let S=e.state.env.get(g);return S!==void 0?{values:[S],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}function Yn(e){let t=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),r=[];for(let s=1;s<=t;s++)r.push(e.state.env.get(String(s))||\"\");return r}async function er(e,t,r,s){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=!1;for(let S=0;S<n.parts.length;S++){let y=n.parts[S];if(y.type===\"ParameterExpansion\"&&(y.parameter===\"@\"||y.parameter===\"*\")&&y.operation?.type===\"Substring\"){a=S,i=y.parameter===\"*\";break}}if(a===-1)return null;let o=n.parts[a].operation,c=o.offset?await r(e,o.offset.expression):0,u=o.length?await r(e,o.length.expression):void 0,f=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),h=[];for(let S=1;S<=f;S++)h.push(e.state.env.get(String(S))||\"\");let d=e.state.env.get(\"0\")||\"bash\",m;if(c<=0){let S=[d,...h],y=S.length+c;if(y<0)m=[];else{let b=c<0?y:0;if(u!==void 0){let D=u<0?S.length+u:b+u;m=S.slice(b,Math.max(b,D))}else m=S.slice(b)}}else{let S=c-1;if(S>=h.length)m=[];else if(u!==void 0){let y=u<0?h.length+u:S+u;m=h.slice(S,Math.max(S,y))}else m=h.slice(S)}let g=\"\";for(let S=0;S<a;S++)g+=await s(e,n.parts[S]);let E=\"\";for(let S=a+1;S<n.parts.length;S++)E+=await s(e,n.parts[S]);if(m.length===0){let S=g+E;return{values:S?[S]:[],quoted:!0}}if(i){let S=N(e.state.env);return{values:[g+m.join(S)+E],quoted:!0}}return m.length===1?{values:[g+m[0]+E],quoted:!0}:{values:[g+m[0],...m.slice(1,-1),m[m.length-1]+E],quoted:!0}}async function tr(e,t,r,s){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=!1;for(let A=0;A<n.parts.length;A++){let S=n.parts[A];if(S.type===\"ParameterExpansion\"&&(S.parameter===\"@\"||S.parameter===\"*\")&&S.operation?.type===\"PatternReplacement\"){a=A,i=S.parameter===\"*\";break}}if(a===-1)return null;let o=n.parts[a].operation,c=Yn(e),u=\"\";for(let A=0;A<a;A++)u+=await r(e,n.parts[A]);let f=\"\";for(let A=a+1;A<n.parts.length;A++)f+=await r(e,n.parts[A]);if(c.length===0){let A=u+f;return{values:A?[A]:[],quoted:!0}}let h=\"\";if(o.pattern)for(let A of o.pattern.parts)if(A.type===\"Glob\")h+=k(A.pattern,!0,e.state.shoptOptions.extglob);else if(A.type===\"Literal\")h+=k(A.value,!0,e.state.shoptOptions.extglob);else if(A.type===\"SingleQuoted\"||A.type===\"Escaped\")h+=I(A.value);else if(A.type===\"DoubleQuoted\"){let S=await s(e,A.parts);h+=I(S)}else if(A.type===\"ParameterExpansion\"){let S=await r(e,A);h+=k(S,!0,e.state.shoptOptions.extglob)}else{let S=await r(e,A);h+=I(S)}let d=o.replacement?await s(e,o.replacement.parts):\"\",m=h;o.anchor===\"start\"?m=`^${h}`:o.anchor===\"end\"&&(m=`${h}$`);let g=[];try{let A=O(m,o.all?\"g\":\"\");for(let S of c)g.push(A.replace(S,d))}catch{g.push(...c)}if(i){let A=N(e.state.env);return{values:[u+g.join(A)+f],quoted:!0}}return g.length===1?{values:[u+g[0]+f],quoted:!0}:{values:[u+g[0],...g.slice(1,-1),g[g.length-1]+f],quoted:!0}}async function nr(e,t,r,s){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let n=t[0],a=-1,i=!1;for(let E=0;E<n.parts.length;E++){let A=n.parts[E];if(A.type===\"ParameterExpansion\"&&(A.parameter===\"@\"||A.parameter===\"*\")&&A.operation?.type===\"PatternRemoval\"){a=E,i=A.parameter===\"*\";break}}if(a===-1)return null;let o=n.parts[a].operation,c=Yn(e),u=\"\";for(let E=0;E<a;E++)u+=await r(e,n.parts[E]);let f=\"\";for(let E=a+1;E<n.parts.length;E++)f+=await r(e,n.parts[E]);if(c.length===0){let E=u+f;return{values:E?[E]:[],quoted:!0}}let h=\"\",d=e.state.shoptOptions.extglob;if(o.pattern)for(let E of o.pattern.parts)if(E.type===\"Glob\")h+=k(E.pattern,o.greedy,d);else if(E.type===\"Literal\")h+=k(E.value,o.greedy,d);else if(E.type===\"SingleQuoted\"||E.type===\"Escaped\")h+=I(E.value);else if(E.type===\"DoubleQuoted\"){let A=await s(e,E.parts);h+=I(A)}else if(E.type===\"ParameterExpansion\"){let A=await r(e,E);h+=k(A,o.greedy,d)}else{let A=await r(e,E);h+=I(A)}let m=[];for(let E of c)m.push(se(E,h,o.side,o.greedy));if(i){let E=N(e.state.env);return{values:[u+m.join(E)+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 rr(e,t,r){if(t.length!==1||t[0].type!==\"DoubleQuoted\")return null;let s=t[0],n=-1,a=!1;for(let h=0;h<s.parts.length;h++){let d=s.parts[h];if(d.type===\"ParameterExpansion\"&&(d.parameter===\"@\"||d.parameter===\"*\")){n=h,a=d.parameter===\"*\";break}}if(n===-1)return null;let i=s.parts[n];if(i.type===\"ParameterExpansion\"&&i.operation)return null;let l=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),o=\"\";for(let h=0;h<n;h++)o+=await r(e,s.parts[h]);let c=\"\";for(let h=n+1;h<s.parts.length;h++)c+=await r(e,s.parts[h]);if(l===0){if(a)return{values:[o+c],quoted:!0};let h=o+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=l;h++)u.push(e.state.env.get(String(h))||\"\");if(a){let h=N(e.state.env);return{values:[o+u.join(h)+c],quoted:!0}}return u.length===1?{values:[o+u[0]+c],quoted:!0}:{values:[o+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}function Ps(e){return new oe(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations})}async function Te(e,t){if(e.state.options.noglob)return t;let r=Ps(e),s=[];for(let n of t)if(ne(n,e.state.shoptOptions.extglob)){let a=await r.expand(n);if(a.length>0)s.push(...a);else{if(r.hasFailglob())throw new Pe(n);r.hasNullglob()||s.push(n)}}else s.push(n);return s}async function sr(e,t,r,s){let n=-1,a=\"\",i=!1;for(let S=0;S<t.length;S++){let y=t[S];if(y.type===\"ParameterExpansion\"&&y.operation?.type===\"PatternReplacement\"){let b=y.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(b){n=S,a=b[1],i=b[2]===\"*\";break}}}if(n===-1)return null;let o=t[n].operation,c=P(e,a),u=c.map(([,S])=>S);if(c.length===0){let S=e.state.env.get(a);S!==void 0&&(u=[S])}if(u.length===0)return{values:[],quoted:!1};let f=\"\";if(o.pattern)for(let S of o.pattern.parts)if(S.type===\"Glob\")f+=k(S.pattern,!0,e.state.shoptOptions.extglob);else if(S.type===\"Literal\")f+=k(S.value,!0,e.state.shoptOptions.extglob);else if(S.type===\"SingleQuoted\"||S.type===\"Escaped\")f+=I(S.value);else if(S.type===\"DoubleQuoted\"){let y=await r(e,S.parts);f+=I(y)}else if(S.type===\"ParameterExpansion\"){let y=await s(e,S);f+=k(y,!0,e.state.shoptOptions.extglob)}else{let y=await s(e,S);f+=I(y)}let h=o.replacement?await r(e,o.replacement.parts):\"\",d=f;o.anchor===\"start\"?d=`^${f}`:o.anchor===\"end\"&&(d=`${f}$`);let m=[];try{let S=O(d,o.all?\"g\":\"\");for(let y of u)m.push(S.replace(y,h))}catch{m.push(...u)}let g=T(e.state.env),E=q(e.state.env);if(i){let S=N(e.state.env),y=m.join(S);return E?{values:y?[y]:[],quoted:!1}:{values:x(y,g),quoted:!1}}if(E)return{values:m,quoted:!1};let A=[];for(let S of m)S===\"\"?A.push(\"\"):A.push(...x(S,g));return{values:A,quoted:!1}}async function ir(e,t,r,s){let n=-1,a=\"\",i=!1;for(let A=0;A<t.length;A++){let S=t[A];if(S.type===\"ParameterExpansion\"&&S.operation?.type===\"PatternRemoval\"){let y=S.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(y){n=A,a=y[1],i=y[2]===\"*\";break}}}if(n===-1)return null;let o=t[n].operation,c=P(e,a),u=c.map(([,A])=>A);if(c.length===0){let A=e.state.env.get(a);A!==void 0&&(u=[A])}if(u.length===0)return{values:[],quoted:!1};let f=\"\",h=e.state.shoptOptions.extglob;if(o.pattern)for(let A of o.pattern.parts)if(A.type===\"Glob\")f+=k(A.pattern,o.greedy,h);else if(A.type===\"Literal\")f+=k(A.value,o.greedy,h);else if(A.type===\"SingleQuoted\"||A.type===\"Escaped\")f+=I(A.value);else if(A.type===\"DoubleQuoted\"){let S=await r(e,A.parts);f+=I(S)}else if(A.type===\"ParameterExpansion\"){let S=await s(e,A);f+=k(S,o.greedy,h)}else{let S=await s(e,A);f+=I(S)}let d=[];for(let A of u)d.push(se(A,f,o.side,o.greedy));let m=T(e.state.env),g=q(e.state.env);if(i){let A=N(e.state.env),S=d.join(A);return g?{values:S?[S]:[],quoted:!1}:{values:x(S,m),quoted:!1}}if(g)return{values:d,quoted:!1};let E=[];for(let A of d)A===\"\"?E.push(\"\"):E.push(...x(A,m));return{values:E,quoted:!1}}async function ar(e,t,r,s){let n=-1,a=!1;for(let E=0;E<t.length;E++){let A=t[E];if(A.type===\"ParameterExpansion\"&&(A.parameter===\"@\"||A.parameter===\"*\")&&A.operation?.type===\"PatternRemoval\"){n=E,a=A.parameter===\"*\";break}}if(n===-1)return null;let l=t[n].operation,o=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),c=[];for(let E=1;E<=o;E++)c.push(e.state.env.get(String(E))||\"\");if(c.length===0)return{values:[],quoted:!1};let u=\"\",f=e.state.shoptOptions.extglob;if(l.pattern)for(let E of l.pattern.parts)if(E.type===\"Glob\")u+=k(E.pattern,l.greedy,f);else if(E.type===\"Literal\")u+=k(E.value,l.greedy,f);else if(E.type===\"SingleQuoted\"||E.type===\"Escaped\")u+=I(E.value);else if(E.type===\"DoubleQuoted\"){let A=await r(e,E.parts);u+=I(A)}else if(E.type===\"ParameterExpansion\"){let A=await s(e,E);u+=k(A,l.greedy,f)}else{let A=await s(e,E);u+=I(A)}let h=[];for(let E of c)h.push(se(E,u,l.side,l.greedy));let d=T(e.state.env),m=q(e.state.env);if(a){let E=N(e.state.env),A=h.join(E);return m?{values:A?[A]:[],quoted:!1}:{values:x(A,d),quoted:!1}}if(m)return{values:h,quoted:!1};let g=[];for(let E of h)E===\"\"?g.push(\"\"):g.push(...x(E,d));return{values:g,quoted:!1}}async function or(e,t,r,s){let n=-1,a=!1;for(let y=0;y<t.length;y++){let b=t[y];if(b.type===\"ParameterExpansion\"&&(b.parameter===\"@\"||b.parameter===\"*\")&&b.operation?.type===\"Substring\"){n=y,a=b.parameter===\"*\";break}}if(n===-1)return null;let l=t[n].operation,o=l.offset?await r(e,l.offset.expression):0,c=l.length?await r(e,l.length.expression):void 0,u=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),f=[];for(let y=1;y<=u;y++)f.push(e.state.env.get(String(y))||\"\");let h=e.state.env.get(\"0\")||\"bash\",d;if(o<=0){let y=[h,...f],b=y.length+o;if(b<0)d=[];else{let D=o<0?b:0;if(c!==void 0){let Q=c<0?y.length+c:D+c;d=y.slice(D,Math.max(D,Q))}else d=y.slice(D)}}else{let y=o-1;if(y>=f.length)d=[];else if(c!==void 0){let b=c<0?f.length+c:y+c;d=f.slice(y,Math.max(y,b))}else d=f.slice(y)}let m=\"\";for(let y=0;y<n;y++)m+=await s(e,t[y]);let g=\"\";for(let y=n+1;y<t.length;y++)g+=await s(e,t[y]);let E=T(e.state.env),A=q(e.state.env);if(d.length===0){let y=m+g;return y?A?{values:[y],quoted:!1}:{values:x(y,E),quoted:!1}:{values:[],quoted:!1}}let S;if(a){let y=N(e.state.env),b=m+d.join(y)+g;A?S=b?[b]:[]:S=x(b,E)}else if(A)d.length===1?S=[m+d[0]+g]:S=[m+d[0],...d.slice(1,-1),d[d.length-1]+g];else{S=[];for(let y=0;y<d.length;y++){let b=d[y];if(y===0&&(b=m+b),y===d.length-1&&(b=b+g),b===\"\")S.push(\"\");else{let D=x(b,E);S.push(...D)}}}return{values:await Te(e,S),quoted:!1}}async function lr(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].parameter!==\"@\"&&t[0].parameter!==\"*\"||t[0].operation)return null;let r=t[0].parameter===\"*\",s=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);if(s===0)return{values:[],quoted:!1};let n=[];for(let c=1;c<=s;c++)n.push(e.state.env.get(String(c))||\"\");let a=T(e.state.env),i=q(e.state.env),l=Ce(e.state.env),o;if(r)if(i)o=n.filter(c=>c!==\"\");else{let c=N(e.state.env),u=n.join(c);o=x(u,a)}else if(i)o=n.filter(c=>c!==\"\");else if(l){o=[];for(let c of n){if(c===\"\")continue;let u=x(c,a);o.push(...u)}}else{o=[];for(let c of n)if(c===\"\")o.push(\"\");else{let u=x(c,a);o.push(...u)}for(;o.length>0&&o[o.length-1]===\"\";)o.pop()}return{values:await Te(e,o),quoted:!1}}async function ur(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation)return null;let r=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(!r)return null;let s=r[1],n=r[2]===\"*\",a=P(e,s),i;if(a.length===0){let f=e.state.env.get(s);if(f!==void 0)i=[f];else return{values:[],quoted:!1}}else i=a.map(([,f])=>f);let l=T(e.state.env),o=q(e.state.env),c=Ce(e.state.env),u;if(n)if(o)u=i.filter(f=>f!==\"\");else{let f=N(e.state.env),h=i.join(f);u=x(h,l)}else if(o)u=i.filter(f=>f!==\"\");else if(c){u=[];for(let f of i){if(f===\"\")continue;let h=x(f,l);u.push(...h)}}else{u=[];for(let f of i)if(f===\"\")u.push(\"\");else{let h=x(f,l);u.push(...h)}for(;u.length>0&&u[u.length-1]===\"\";)u.pop()}return{values:await Te(e,u),quoted:!1}}function cr(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"VarNamePrefix\")return null;let r=t[0].operation,s=me(e,r.prefix);if(s.length===0)return{values:[],quoted:!1};let n=T(e.state.env),a=q(e.state.env),i;if(r.star)if(a)i=s;else{let l=N(e.state.env),o=s.join(l);i=x(o,n)}else if(a)i=s;else{i=[];for(let l of s){let o=x(l,n);i.push(...o)}}return{values:i,quoted:!1}}function fr(e,t){if(t.length!==1||t[0].type!==\"ParameterExpansion\"||t[0].operation?.type!==\"ArrayKeys\")return null;let r=t[0].operation,n=P(e,r.array).map(([o])=>String(o));if(n.length===0)return{values:[],quoted:!1};let a=T(e.state.env),i=q(e.state.env),l;if(r.star)if(i)l=n;else{let o=N(e.state.env),c=n.join(o);l=x(c,a)}else if(i)l=n;else{l=[];for(let o of n){let c=x(o,a);l.push(...c)}}return{values:l,quoted:!1}}async function hr(e,t,r){let s=-1;for(let h=0;h<t.length;h++){let d=t[h];if(d.type===\"ParameterExpansion\"&&(d.parameter===\"@\"||d.parameter===\"*\")&&!d.operation){s=h;break}}if(s===-1||t.length<=1)return null;let n=Number.parseInt(e.state.env.get(\"#\")||\"0\",10),a=[];for(let h=1;h<=n;h++)a.push(e.state.env.get(String(h))||\"\");let i=\"\";for(let h=0;h<s;h++)i+=await r(e,t[h]);let l=\"\";for(let h=s+1;h<t.length;h++)l+=await r(e,t[h]);let o=T(e.state.env),c=q(e.state.env),u=Ce(e.state.env);if(n===0){let h=i+l;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let d=0;d<a.length;d++){let m=a[d];d===0&&(m=i+m),d===a.length-1&&(m=m+l),h.push(m)}if(c)f=h.filter(d=>d!==\"\");else if(u){f=[];for(let d of h){if(d===\"\")continue;let m=x(d,o);f.push(...m)}}else{f=[];for(let d of h)if(d===\"\")f.push(\"\");else{let m=x(d,o);f.push(...m)}for(;f.length>0&&f[f.length-1]===\"\";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await Te(e,f),quoted:!1}}async function mr(e,t,r){e.coverage?.hit(\"bash:expansion:word_glob\");let s=t.parts,{hasQuoted:n,hasCommandSub:a,hasArrayVar:i,hasArrayAtExpansion:l,hasParamExpansion:o,hasVarNamePrefixExpansion:c,hasIndirection:u}=Ae(s),h=r.hasBraceExpansion(s)?await r.expandWordWithBracesAsync(e,t):null;if(h&&h.length>1)return Rs(e,h,n);let d=await Is(e,s,l,c,u,r);if(d!==null)return d;let m=await Ds(e,s,r);if(m!==null)return m;let g=await xs(e,s,r);if(g!==null)return g;let E=await $s(e,s,r.expandPart);if(E!==null)return dr(e,E);if((a||i||o)&&!q(e.state.env)){let S=T(e.state.env),y=r.buildIfsCharClassPattern(S),b=await r.smartWordSplit(e,s,S,y,r.expandPart);return dr(e,b)}let A=await r.expandWordAsync(e,t);return Cs(e,t,s,A,n,r.expandWordForGlobbing)}async function Rs(e,t,r){let s=[];for(let n of t)if(!(!r&&n===\"\"))if(!r&&!e.state.options.noglob&&ne(n,e.state.shoptOptions.extglob)){let a=await Me(e,n);s.push(...a)}else s.push(n);return{values:s,quoted:!1}}async function Is(e,t,r,s,n,a){if(r){let i=Hn(e,t);if(i!==null)return i}{let i=jn(e,t);if(i!==null)return i}{let i=await zn(e,t);if(i!==null)return i}{let i=await Gn(e,t,r,a.expandPart,a.expandWordPartsAsync);if(i!==null)return i}{let i=await Qn(e,t,r,a.expandPart);if(i!==null)return i}{let i=await Zn(e,t,a.evaluateArithmetic);if(i!==null)return i}{let i=Un(e,t);if(i!==null)return i}{let i=await Bn(e,t,a.expandWordPartsAsync,a.expandPart);if(i!==null)return i}{let i=await Fn(e,t,a.expandWordPartsAsync,a.expandPart);if(i!==null)return i}if(s&&t.length===1&&t[0].type===\"DoubleQuoted\"){let i=vs(e,t);if(i!==null)return i}{let i=await Kn(e,t,n,a.expandParameterAsync,a.expandWordPartsAsync);if(i!==null)return i}{let i=await Xn(e,t);if(i!==null)return i}{let i=await Jn(e,t);if(i!==null)return i}return null}function vs(e,t){let r=t[0];if(r.type!==\"DoubleQuoted\")return null;if(r.parts.length===1&&r.parts[0].type===\"ParameterExpansion\"&&r.parts[0].operation?.type===\"VarNamePrefix\"){let s=r.parts[0].operation,n=me(e,s.prefix);return s.star?{values:[n.join(N(e.state.env))],quoted:!0}:{values:n,quoted:!0}}if(r.parts.length===1&&r.parts[0].type===\"ParameterExpansion\"&&r.parts[0].operation?.type===\"ArrayKeys\"){let s=r.parts[0].operation,a=P(e,s.array).map(([i])=>String(i));return s.star?{values:[a.join(N(e.state.env))],quoted:!0}:{values:a,quoted:!0}}return null}async function Ds(e,t,r){{let s=await er(e,t,r.evaluateArithmetic,r.expandPart);if(s!==null)return s}{let s=await tr(e,t,r.expandPart,r.expandWordPartsAsync);if(s!==null)return s}{let s=await nr(e,t,r.expandPart,r.expandWordPartsAsync);if(s!==null)return s}{let s=await rr(e,t,r.expandPart);if(s!==null)return s}return null}async function xs(e,t,r){{let s=await sr(e,t,r.expandWordPartsAsync,r.expandPart);if(s!==null)return s}{let s=await ir(e,t,r.expandWordPartsAsync,r.expandPart);if(s!==null)return s}{let s=await ar(e,t,r.expandWordPartsAsync,r.expandPart);if(s!==null)return s}{let s=await or(e,t,r.evaluateArithmetic,r.expandPart);if(s!==null)return s}{let s=await lr(e,t);if(s!==null)return s}{let s=await ur(e,t);if(s!==null)return s}{let s=cr(e,t);if(s!==null)return s}{let s=fr(e,t);if(s!==null)return s}{let s=await hr(e,t,r.expandPart);if(s!==null)return s}return null}function pr(e){if(e.type!==\"DoubleQuoted\")return null;for(let t=0;t<e.parts.length;t++){let r=e.parts[t];if(r.type!==\"ParameterExpansion\"||r.operation)continue;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([@*])\\]$/);if(s)return{type:\"array\",name:s[1],atIndex:t,isStar:s[2]===\"*\"};if(r.parameter===\"@\"||r.parameter===\"*\")return{type:\"positional\",atIndex:t,isStar:r.parameter===\"*\"}}return null}async function _s(e,t,r,s){let n=\"\";for(let l=0;l<r.atIndex;l++)n+=await s(e,t.parts[l]);let a=\"\";for(let l=r.atIndex+1;l<t.parts.length;l++)a+=await s(e,t.parts[l]);let i;if(r.type===\"array\"){if(i=P(e,r.name).map(([,o])=>o),i.length===0){let o=e.state.env.get(r.name);o!==void 0&&(i=[o])}}else{let l=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);i=[];for(let o=1;o<=l;o++)i.push(e.state.env.get(String(o))||\"\")}if(r.isStar){let l=N(e.state.env),o=i.join(l);return[n+o+a]}if(i.length===0){let l=n+a;return l?[l]:[]}return i.length===1?[n+i[0]+a]:[n+i[0],...i.slice(1,-1),i[i.length-1]+a]}async function $s(e,t,r){if(t.length<2)return null;let s=!1;for(let o of t)if(pr(o)){s=!0;break}if(!s)return null;let n=T(e.state.env),a=q(e.state.env),i=[];for(let o of t){let c=pr(o);if(c&&o.type===\"DoubleQuoted\"){let u=await _s(e,o,c,r);i.push(u)}else if(o.type===\"DoubleQuoted\"||o.type===\"SingleQuoted\"){let u=await r(e,o);i.push([u])}else if(o.type===\"Literal\")i.push([o.value]);else if(o.type===\"ParameterExpansion\"){let u=await r(e,o);if(a)i.push(u?[u]:[]);else{let f=x(u,n);i.push(f)}}else{let u=await r(e,o);if(a)i.push(u?[u]:[]);else{let f=x(u,n);i.push(f)}}}let l=[];for(let o of i)if(o.length!==0)if(l.length===0)l.push(...o);else{let c=l.length-1;l[c]=l[c]+o[0];for(let u=1;u<o.length;u++)l.push(o[u])}return l}async function dr(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let r=[];for(let s of t)if(ne(s,e.state.shoptOptions.extglob)){let n=await Me(e,s);r.push(...n)}else r.push(s);return{values:r,quoted:!1}}async function Me(e,t){let r=new oe(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),s=await r.expand(t);if(s.length>0)return s;if(r.hasFailglob())throw new Pe(t);return r.hasNullglob()?[]:[t]}async function Cs(e,t,r,s,n,a){let i=r.some(l=>l.type===\"Glob\");if(!e.state.options.noglob&&i){let l=await a(e,t);if(ne(l,e.state.shoptOptions.extglob)){let c=await Me(e,l);if(c.length>0&&c[0]!==l)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let o=St(s);if(!q(e.state.env)){let c=T(e.state.env);return{values:x(o,c),quoted:!1}}return{values:[o],quoted:!1}}if(!n&&!e.state.options.noglob&&ne(s,e.state.shoptOptions.extglob)){let l=await a(e,t);if(ne(l,e.state.shoptOptions.extglob)){let o=await Me(e,l);if(o.length>0&&o[0]!==l)return{values:o,quoted:!1}}}if(s===\"\"&&!n)return{values:[],quoted:!1};if(i&&!n){let l=St(s);if(!q(e.state.env)){let o=T(e.state.env);return{values:x(l,o),quoted:!1}}return{values:[l],quoted:!1}}return{values:[s],quoted:n}}async function yr(e,t){let r=t.operation;if(!r||r.type!==\"DefaultValue\"&&r.type!==\"AssignDefault\"&&r.type!==\"UseAlternative\")return null;let s=r.word;if(!s||s.parts.length===0)return null;let n=await te(e,t.parameter),i=await v(e,t.parameter,!1)===\"\",l=r.checkEmpty??!1,o;return r.type===\"UseAlternative\"?o=n&&!(l&&i):o=!n||l&&i,o?s.parts:null}function Os(e){return e.type===\"SingleQuoted\"?!0:e.type===\"DoubleQuoted\"?e.parts.every(r=>r.type===\"Literal\"):!1}async function Ls(e,t){if(t.type!==\"ParameterExpansion\")return null;let r=await yr(e,t);if(!r||r.length<=1)return null;let s=r.some(a=>Os(a)),n=r.some(a=>a.type===\"Literal\"||a.type===\"ParameterExpansion\"||a.type===\"CommandSubstitution\"||a.type===\"ArithmeticExpansion\");return s&&n?r:null}function Ws(e){return e.type===\"DoubleQuoted\"||e.type===\"SingleQuoted\"||e.type===\"Literal\"?!1:e.type===\"Glob\"?dt(e.pattern):!(!(e.type===\"ParameterExpansion\"||e.type===\"CommandSubstitution\"||e.type===\"ArithmeticExpansion\")||e.type===\"ParameterExpansion\"&&gn(e))}async function Er(e,t,r,s,n){if(e.coverage?.hit(\"bash:expansion:word_split\"),t.length===1&&t[0].type===\"ParameterExpansion\"){let h=t[0],d=await yr(e,h);if(d&&d.length>0&&d.length>1&&d.some(g=>g.type===\"DoubleQuoted\"||g.type===\"SingleQuoted\")&&d.some(g=>g.type===\"Literal\"||g.type===\"ParameterExpansion\"||g.type===\"CommandSubstitution\"||g.type===\"ArithmeticExpansion\"))return gr(e,d,r,s,n)}let a=[],i=!1;for(let h of t){let d=Ws(h),m=h.type===\"DoubleQuoted\"||h.type===\"SingleQuoted\",g=d?await Ls(e,h):null,E=await n(e,h);a.push({value:E,isSplittable:d,isQuoted:m,mixedDefaultParts:g??void 0}),d&&(i=!0)}if(!i){let h=a.map(d=>d.value).join(\"\");return h?[h]:[]}let l=[],o=\"\",c=!1,u=!1,f=!1;for(let h of a)if(!h.isSplittable)u?h.isQuoted&&h.value===\"\"?(o!==\"\"&&l.push(o),l.push(\"\"),c=!0,o=\"\",u=!1,f=!0):h.value!==\"\"?(o!==\"\"&&l.push(o),o=h.value,u=!1,f=!1):(o+=h.value,f=!1):(o+=h.value,f=h.isQuoted&&h.value===\"\");else if(h.mixedDefaultParts){let d=await gr(e,h.mixedDefaultParts,r,s,n);if(d.length!==0)if(d.length===1)o+=d[0],c=!0;else{o+=d[0],l.push(o),c=!0;for(let m=1;m<d.length-1;m++)l.push(d[m]);o=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:m,hadTrailingDelimiter:g}=Oe(h.value,r);if(f&&m&&o===\"\"&&(l.push(\"\"),c=!0),d.length===0)g&&(u=!0);else if(d.length===1)o+=d[0],c=!0,u=g;else{o+=d[0],l.push(o),c=!0;for(let E=1;E<d.length-1;E++)l.push(d[E]);o=d[d.length-1],u=g}f=!1}return o!==\"\"?l.push(o):l.length===0&&c&&l.push(\"\"),l}function Ts(e,t){return e.length>0&&t.includes(e[0])}async function gr(e,t,r,s,n){let a=[];for(let u of t){let h=!(u.type===\"DoubleQuoted\"||u.type===\"SingleQuoted\"),d=await n(e,u);a.push({value:d,isSplittable:h})}let i=[],l=\"\",o=!1,c=!1;for(let u of a)if(!u.isSplittable)c&&u.value!==\"\"?(l!==\"\"&&i.push(l),l=u.value,c=!1):l+=u.value;else{Ts(u.value,r)&&l!==\"\"&&(i.push(l),l=\"\",o=!0);let{words:h,hadTrailingDelimiter:d}=Oe(u.value,r);if(h.length===0)d&&(c=!0);else if(h.length===1)l+=h[0],o=!0,c=d;else{l+=h[0],i.push(l),o=!0;for(let m=1;m<h.length-1;m++)i.push(h[m]);l=h[h.length-1],c=d}}return l!==\"\"?i.push(l):i.length===0&&o&&i.push(\"\"),i}function Ar(e){switch(e.type){case\"Literal\":return e.value;case\"SingleQuoted\":return e.value;case\"Escaped\":return e.value;default:return null}}function Sr(e){switch(e.type){case\"SingleQuoted\":case\"Escaped\":case\"DoubleQuoted\":return!0;case\"Literal\":return e.value===\"\";default:return!1}}function ce(e,t,r){if(e.length>t)throw new L(`${r}: string length limit exceeded (${t} bytes)`,\"string_length\")}async function J(e,t,r=!1){let s=[];for(let n of t)s.push(await U(e,n,r));return s.join(\"\")}function Ms(e){return Sr(e)}function Al(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!Ms(t))return!1;return!0}function Vs(e,t,r=!1){let s=Ar(t);if(s!==null)return s;switch(t.type){case\"TildeExpansion\":return r?t.user===null?\"~\":`~${t.user}`:(e.coverage?.hit(\"bash:expansion:tilde\"),t.user===null?e.state.env.get(\"HOME\")??\"/home/user\":t.user===\"root\"?\"/root\":`~${t.user}`);case\"Glob\":return Nt(e,t.pattern);default:return null}}async function Pt(e,t){return Rt(e,t)}async function Sl(e,t){let r=[];for(let s of t.parts)if(s.type===\"Escaped\")r.push(`\\\\${s.value}`);else if(s.type===\"SingleQuoted\")r.push(s.value);else if(s.type===\"DoubleQuoted\"){let n=await J(e,s.parts);r.push(n)}else if(s.type===\"TildeExpansion\"){let n=await U(e,s);r.push(bt(n))}else r.push(await U(e,s));return r.join(\"\")}async function bl(e,t){let r=[];for(let s of t.parts)if(s.type===\"Escaped\"){let n=s.value;\"()|*?[]\".includes(n)?r.push(`\\\\${n}`):r.push(n)}else if(s.type===\"SingleQuoted\")r.push(X(s.value));else if(s.type===\"DoubleQuoted\"){let n=await J(e,s.parts);r.push(X(n))}else r.push(await U(e,s));return r.join(\"\")}async function br(e,t){let r=[];for(let s of t.parts)if(s.type===\"SingleQuoted\")r.push(X(s.value));else if(s.type===\"Escaped\"){let n=s.value;\"*?[]\\\\()|\".includes(n)?r.push(`\\\\${n}`):r.push(n)}else if(s.type===\"DoubleQuoted\"){let n=await J(e,s.parts);r.push(X(n))}else s.type===\"Glob\"?Tn(s.pattern)?r.push(await Vn(e,s.pattern)):r.push(Nt(e,s.pattern)):s.type===\"Literal\"?r.push(s.value):r.push(await U(e,s));return r.join(\"\")}function qe(e){for(let t of e)if(t.type===\"BraceExpansion\"||t.type===\"DoubleQuoted\"&&qe(t.parts))return!0;return!1}var kt=1e5;async function wr(e,t,r={count:0}){if(r.count>kt)return[[]];let s=[[]];for(let n of t)if(n.type===\"BraceExpansion\"){let a=[],i=!1,l=\"\";for(let u of n.items)if(u.type===\"Range\"){let f=At(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)r.count++,a.push(h);else{i=!0,l=f.literal;break}}else{let f=await wr(e,u.word.parts,r);for(let h of f){r.count++;let d=[];for(let m of h)typeof m==\"string\"?d.push(m):d.push(await U(e,m));a.push(d.join(\"\"))}}if(i){for(let u of s)r.count++,u.push(l);continue}if(s.length*a.length>e.limits.maxBraceExpansionResults||r.count>kt)return s;let c=[];for(let u of s)for(let f of a){if(r.count++,r.count>kt)return c.length>0?c:s;c.push([...u,f])}s=c}else for(let a of s)r.count++,a.push(n);return s}async function Nr(e,t){let r=t.parts;if(!qe(r))return[await Pt(e,t)];let s=await wr(e,r),n=[];for(let a of s){let i=[];for(let l of a)typeof l==\"string\"?i.push(l):i.push(await U(e,l));n.push(qn(e,i.join(\"\")))}return n}function qs(){return{expandWordAsync:Rt,expandWordForGlobbing:br,expandWordWithBracesAsync:Nr,expandWordPartsAsync:J,expandPart:U,expandParameterAsync:Ve,hasBraceExpansion:qe,evaluateArithmetic:R,buildIfsCharClassPattern:An,smartWordSplit:Er}}async function wl(e,t){return mr(e,t,qs())}function Bs(e){for(let t of e){if(t.type===\"ParameterExpansion\")return t.parameter;if(t.type===\"Literal\")return t.value}return\"\"}function Fs(e,t){if(Number.parseInt(e.state.env.get(\"#\")||\"0\",10)<2)return!1;function s(n){for(let a of n)if(a.type===\"DoubleQuoted\"){for(let i of a.parts)if(i.type===\"ParameterExpansion\"&&i.parameter===\"@\"&&!i.operation)return!0}return!1}return s(t.parts)}async function Nl(e,t){if(Fs(e,t))return{error:`bash: $@: ambiguous redirect\n`};let r=t.parts,{hasQuoted:s}=Ae(r);if(qe(r)&&(await Nr(e,t)).length>1)return{error:`bash: ${r.map(d=>d.type===\"Literal\"?d.value:d.type===\"BraceExpansion\"?`{${d.items.map(g=>{if(g.type===\"Range\"){let E=g.step?`..${g.step}`:\"\";return`${g.startStr??g.start}..${g.endStr??g.end}${E}`}return g.word.parts.map(E=>E.type===\"Literal\"?E.value:\"\").join(\"\")}).join(\",\")}}`:\"\").join(\"\")}: ambiguous redirect\n`};let n=await Rt(e,t),{hasParamExpansion:a,hasCommandSub:i}=Ae(r);if((a||i)&&!s&&!q(e.state.env)){let f=T(e.state.env);if(x(n,f).length>1)return{error:`bash: $${Bs(r)}: ambiguous redirect\n`}}if(s||e.state.options.noglob)return{target:n};let o=await br(e,t);if(!ne(o,e.state.shoptOptions.extglob))return{target:n};let c=new oe(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),u=await c.expand(o);return u.length===0?c.hasFailglob()?{error:`bash: no match: ${n}\n`}:{target:n}:u.length===1?{target:u[0]}:{error:`bash: ${n}: ambiguous redirect\n`}}async function Rt(e,t){let r=t.parts,s=r.length;if(s===1){let i=await U(e,r[0]);return ce(i,e.limits.maxStringLength,\"word expansion\"),i}let n=[];for(let i=0;i<s;i++)n.push(await U(e,r[i]));let a=n.join(\"\");return ce(a,e.limits.maxStringLength,\"word expansion\"),a}async function U(e,t,r=!1){if(t.type===\"ParameterExpansion\")return Ve(e,t,r);let s=Vs(e,t,r);if(s!==null)return s;switch(t.type){case\"DoubleQuoted\":{let n=[];for(let a of t.parts)n.push(await U(e,a,!0));return n.join(\"\")}case\"CommandSubstitution\":{let n=wn(t.body);if(n)try{let h=await Pt(e,n.target),d=h.startsWith(\"/\")?h:`${e.state.cwd}/${h}`,m=await e.fs.readFile(d);e.state.lastExitCode=0,e.state.env.set(\"?\",\"0\");let g=m.replace(/\\n+$/,\"\");return ce(g,e.limits.maxStringLength,\"command substitution\"),g}catch(h){if(h instanceof L)throw h;return e.state.lastExitCode=1,e.state.env.set(\"?\",\"1\"),\"\"}let a=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(a>=i)throw new L(`Command substitution nesting limit exceeded (${i})`,\"substitution_depth\");let l=e.substitutionDepth;e.substitutionDepth=a+1;let o=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let c=new Map(e.state.env),u=e.state.cwd,f=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let h=await e.executeScript(t.body),d=h.exitCode;e.state.env=c,e.state.cwd=u,e.state.suppressVerbose=f,e.state.lastExitCode=d,e.state.env.set(\"?\",String(d)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+h.stderr),e.state.bashPid=o,e.substitutionDepth=l;let m=h.stdout.replace(/\\n+$/,\"\");return ce(m,e.limits.maxStringLength,\"command substitution\"),m}catch(h){if(e.state.env=c,e.state.cwd=u,e.state.bashPid=o,e.substitutionDepth=l,e.state.suppressVerbose=f,h instanceof L)throw h;if(h instanceof K){e.state.lastExitCode=h.exitCode,e.state.env.set(\"?\",String(h.exitCode)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||\"\")+h.stderr);let d=h.stdout.replace(/\\n+$/,\"\");return ce(d,e.limits.maxStringLength,\"command substitution\"),d}throw h}}case\"ArithmeticExpansion\":{let n=t.expression.originalText;if(n&&/\\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(n)){let i=await bn(e,n),l=new V,o=M(l,i);return String(await R(e,o.expression,!0))}return String(await R(e,t.expression.expression,!0))}case\"BraceExpansion\":{let n=[];for(let a of t.items)if(a.type===\"Range\"){let i=At(a.start,a.end,a.step,a.startStr,a.endStr);if(i.expanded)n.push(...i.expanded);else return i.literal}else n.push(await Pt(e,a.word));return n.join(\" \")}default:return\"\"}}async function Ve(e,t,r=!1){let{parameter:s}=t,{operation:n}=t,a=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(a){let[,h,d]=a;if(e.state.associativeArrays?.has(h)||d.includes(\"$(\")||d.includes(\"`\")||d.includes(\"${\")){let g=await Et(e,d);s=`${h}[${g}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)&&W(e,s)){let h=he(e,s);if(h&&h!==s){let d=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(d){let[,m,g]=d;if(e.state.associativeArrays?.has(m)||g.includes(\"$(\")||g.includes(\"`\")||g.includes(\"${\")){let A=await Et(e,g);s=`${m}[${A}]`}}}}let i=n&&(n.type===\"DefaultValue\"||n.type===\"AssignDefault\"||n.type===\"UseAlternative\"||n.type===\"ErrorIfUnset\"),l=await v(e,s,!i);if(!n)return l;let o=!await te(e,s),{isEmpty:c,effectiveValue:u}=Wn(e,s,l,r),f={value:l,isUnset:o,isEmpty:c,effectiveValue:u,inDoubleQuotes:r};switch(n.type){case\"DefaultValue\":return Nn(e,n,f,J);case\"AssignDefault\":return kn(e,s,n,f,J);case\"ErrorIfUnset\":return Pn(e,s,n,f,J);case\"UseAlternative\":return Rn(e,n,f,J);case\"PatternRemoval\":{let h=await In(e,l,n,J,U);return ce(h,e.limits.maxStringLength,\"pattern removal\"),h}case\"PatternReplacement\":{let h=await vn(e,l,n,J,U);return ce(h,e.limits.maxStringLength,\"pattern replacement\"),h}case\"Length\":return Dn(e,s,l);case\"LengthSliceError\":throw new re(s);case\"BadSubstitution\":throw new re(n.text);case\"Substring\":return xn(e,s,l,n);case\"CaseModification\":{let h=await _n(e,l,n,J,Ve);return ce(h,e.limits.maxStringLength,\"case modification\"),h}case\"Transform\":return $n(e,s,l,o,n);case\"Indirection\":return Cn(e,s,l,o,n,Ve,r);case\"ArrayKeys\":return On(e,n);case\"VarNamePrefix\":return Ln(e,n);default:return l}}export{xi as a,_i as b,pe as c,G as d,M as e,V as f,di as g,mt as h,Ci as i,gt as j,Oi as k,En as l,T as m,Wi as n,Ti as o,W as p,Vi as q,qi as r,Bi as s,Fi as t,us as u,he as v,Se as w,zi as x,P as y,be as z,v as A,X as B,bt as C,pa as D,wt as E,da as F,ma as G,ga as H,Al as I,Pt as J,Sl as K,bl as L,wl as M,Fs as N,Nl as O,R as P};\n","import { join, relative, sep } from \"node:path\";\nimport { readdir, stat } from \"node:fs/promises\";\nimport { readFileSync } from \"node:fs\";\n//#region src/discovery/entry-from-file.ts\nconst SOURCE_EXT = /\\.(ts|mts|mjs|js)$/;\nconst DECLARATION_FILE$1 = /\\.d\\.(ts|mts|cts)$/;\nfunction entryIdFromFile(rootDir, filePath, options) {\n\tif (DECLARATION_FILE$1.test(filePath)) return null;\n\tconst baseName = filePath.split(sep).at(-1) ?? \"\";\n\tif (/\\.(int\\.)?test\\.(ts|mts)$/.test(baseName)) return null;\n\tconst segments = relative(rootDir, filePath).replace(SOURCE_EXT, \"\").split(sep).filter((segment) => segment.length > 0);\n\tif (segments.length === 1) return segments[0] ?? null;\n\tconst last = segments.at(-1);\n\tconst entryNames = new Set([options.nestedEntry]);\n\tif (options.allowIndex !== false) entryNames.add(\"index\");\n\tif (!last || !entryNames.has(last)) return null;\n\tconst id = segments.slice(0, -1).join(\"/\");\n\treturn id.length > 0 ? id : null;\n}\n//#endregion\n//#region src/discovery/walk-typescript-files.ts\nconst SOURCE_FILE = /\\.(ts|mts|mjs|js)$/;\nconst TEST_FILE = /\\.(int\\.)?test\\.(ts|mts)$/;\nconst DECLARATION_FILE = /\\.d\\.(ts|mts|cts)$/;\nconst JUNK_FILE = /^\\._|\\.DS_Store$/;\nasync function walkTypeScriptFiles(dir) {\n\tlet names;\n\ttry {\n\t\tnames = await readdir(dir);\n\t} catch (error) {\n\t\tif (error.code === \"ENOENT\") return [];\n\t\tthrow error;\n\t}\n\tconst files = [];\n\tfor (const name of names) {\n\t\tconst path = join(dir, name);\n\t\tif ((await stat(path)).isDirectory()) files.push(...await walkTypeScriptFiles(path));\n\t\telse if (!JUNK_FILE.test(name) && SOURCE_FILE.test(name) && !DECLARATION_FILE.test(name) && !TEST_FILE.test(name)) files.push(path);\n\t}\n\treturn files;\n}\n//#endregion\n//#region src/discovery/discover-entries.ts\nasync function discoverEntries(rootDir, options) {\n\tconst files = await walkTypeScriptFiles(rootDir);\n\tconst byKey = /* @__PURE__ */ new Map();\n\tfor (const filePath of files) {\n\t\tconst id = entryIdFromFile(rootDir, filePath, options);\n\t\tif (!id) continue;\n\t\tconst key = options.formatKey(id);\n\t\tconst moduleFile = relative(rootDir, filePath);\n\t\tconst existing = byKey.get(key);\n\t\tif (existing) throw new Error(`Duplicate ${options.duplicateLabel} ${key}: ${existing.filePath} and ${filePath}`);\n\t\tbyKey.set(key, {\n\t\t\tkey,\n\t\t\tfilePath,\n\t\t\tmoduleFile\n\t\t});\n\t}\n\treturn [...byKey.values()];\n}\n//#endregion\n//#region src/discovery/discover-module-entries.ts\nasync function discoverModuleFileEntries(rootDir, options) {\n\treturn (await discoverEntries(rootDir, {\n\t\tnestedEntry: options.nestedEntry,\n\t\tformatKey: (id) => id,\n\t\tduplicateLabel: options.duplicateLabel\n\t})).filter((entry) => options.shouldDiscoverFile?.(entry.filePath) ?? true).map(({ filePath, moduleFile }) => ({\n\t\tfilePath,\n\t\tmoduleFile\n\t}));\n}\nfunction moduleFileKeyFromPath(rootDir, filePath, nestedEntry) {\n\treturn entryIdFromFile(rootDir, filePath, { nestedEntry });\n}\n//#endregion\n//#region src/discovery/keystroke-ignore-directive.ts\nconst HEADER_BYTES = 2048;\nconst DIRECTIVE_RE = /@keystroke\\s+ignore(?::([a-z]+))?/;\n/** Parse `@keystroke ignore` directives from a file header snippet. */\nfunction parseKeystrokeIgnoreDirective(header) {\n\tfor (const line of header.slice(0, HEADER_BYTES).split(\"\\n\")) {\n\t\tconst trimmed = line.trim();\n\t\tif (trimmed.length === 0) continue;\n\t\tif (!isCommentLine(trimmed)) break;\n\t\tconst match = DIRECTIVE_RE.exec(trimmed);\n\t\tif (!match) continue;\n\t\tconst scope = match[1];\n\t\tif (!scope) return \"ignore\";\n\t\tif (scope === \"deploy\") return \"ignore:deploy\";\n\t\tthrow new Error(`Unknown @keystroke ignore target \"${scope}\" in directive \"@keystroke ignore:${scope}\"`);\n\t}\n\treturn null;\n}\n/** Read `@keystroke ignore` directives from the top of a module file. */\nfunction readKeystrokeIgnoreDirective(filePath) {\n\treturn parseKeystrokeIgnoreDirective(readFileSync(filePath, \"utf8\").slice(0, HEADER_BYTES));\n}\n/** Whether a discovered module file should be skipped for the given build phase. */\nfunction shouldSkipKeystrokeModuleFile(directive, phase) {\n\tif (!directive) return false;\n\tif (directive === \"ignore\") return true;\n\treturn phase === \"deploy\";\n}\nfunction isCommentLine(line) {\n\treturn line.startsWith(\"//\") || line.startsWith(\"/*\") || line.startsWith(\"*\");\n}\n//#endregion\n//#region src/discovery/validate-unique-module-keys.ts\nfunction validateUniqueModuleKeys(entries) {\n\tconst byKey = /* @__PURE__ */ new Map();\n\tfor (const entry of entries) {\n\t\tconst list = byKey.get(entry.key) ?? [];\n\t\tlist.push(entry);\n\t\tbyKey.set(entry.key, list);\n\t}\n\tfor (const [key, clashes] of byKey) {\n\t\tif (clashes.length <= 1) continue;\n\t\tconst detail = clashes.map((entry) => `${entry.kind} (${entry.filePath})`).join(\", \");\n\t\tthrow new Error(`Duplicate module key \"${key}\": ${detail}`);\n\t}\n}\n//#endregion\nexport { discoverModuleFileEntries as a, walkTypeScriptFiles as c, shouldSkipKeystrokeModuleFile as i, entryIdFromFile as l, parseKeystrokeIgnoreDirective as n, moduleFileKeyFromPath as o, readKeystrokeIgnoreDirective as r, discoverEntries as s, validateUniqueModuleKeys as t };\n\n//# sourceMappingURL=discovery-CWjr_liZ.mjs.map","import { a as writeWorkspaceFileIfAbsent, n as resolveAgentRoot, t as ensureWorkspaceDir } from \"./sandbox-dirs-DMDj1_61.mjs\";\nimport { createRequire } from \"node:module\";\nimport { basename, dirname, join, relative, resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { fileURLToPath } from \"node:url\";\n//#region src/files/schemas.ts\nconst SandboxModeSchema = z.enum([\"in-process\", \"vm\"]);\nconst SandboxFileContentSchema = z.object({\n\tpath: z.string(),\n\tfile: z.string()\n});\n/** Destination path under `/workspace`. For `dir`, used as a prefix. */\nconst SandboxFileSchema = z.object({\n\tpath: z.string(),\n\t/** Single file body — typically from a build-time import (`import doc from \"./doc.md\"`). */\n\tfile: z.string().optional(),\n\t/** Directory contents — each path is relative to `path`. */\n\tdir: z.array(SandboxFileContentSchema).optional()\n});\n/** Author-facing project file set reference under `src/files/`. */\nconst SandboxProjectFilesSchema = z.union([z.literal(true), z.string()]);\n/** Author-facing sandbox files: inline entries or a project file set. */\nconst SandboxFilesInputSchema = z.union([z.array(SandboxFileSchema), SandboxProjectFilesSchema]);\n/** Author-facing sandbox definition (`defineSandbox`, agent `sandbox`). */\nconst SandboxDefinitionInputSchema = z.object({\n\tkey: z.string().optional(),\n\t/** Sandbox execution mode. Defaults to in-process when omitted. */\n\tmode: SandboxModeSchema.optional(),\n\tfiles: SandboxFilesInputSchema.optional()\n});\n/** Normalized sandbox definition after project file sets are resolved. */\nconst SandboxDefinitionSchema = z.object({\n\tkey: z.string().optional(),\n\tmode: SandboxModeSchema.optional(),\n\tfiles: z.array(SandboxFileSchema).optional()\n});\n//#endregion\n//#region src/files/define-sandbox.ts\n/** Define a reusable sandbox file layout. */\nfunction defineSandbox(def) {\n\treturn def;\n}\n//#endregion\n//#region src/files/flatten-sandbox-files.ts\n/** Expand directory entries into flat `{ path, file }` records under `/workspace`. */\nfunction flattenSandboxFiles(files) {\n\tif (!files?.length) return [];\n\tconst flattened = [];\n\tfor (const entry of files) {\n\t\tif (entry.dir !== void 0) {\n\t\t\tconst prefix = entry.path.replace(/\\/+$/, \"\");\n\t\t\tfor (const child of entry.dir) flattened.push({\n\t\t\t\tpath: prefix ? `${prefix}/${child.path}` : child.path,\n\t\t\t\tfile: child.file\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.file === void 0) continue;\n\t\tflattened.push({\n\t\t\tpath: entry.path,\n\t\t\tfile: entry.file\n\t\t});\n\t}\n\treturn flattened;\n}\n//#endregion\n//#region src/files/materialize-sandbox.ts\nasync function materializeSandbox(options) {\n\tconst root = resolveAgentRoot(options.workspacesRoot, options.agentId);\n\tawait ensureWorkspaceDir(root);\n\tconst files = flattenSandboxFiles(options.definition?.files);\n\tif (files.length) await applySandboxFiles(root, files);\n\treturn {\n\t\troot,\n\t\tagentId: options.agentId,\n\t\t...options.definition !== void 0 ? { definition: options.definition } : {}\n\t};\n}\nasync function applySandboxFiles(root, files) {\n\tfor (const entry of files) await writeWorkspaceFileIfAbsent(resolve(root, entry.path), entry.file);\n}\n//#endregion\n//#region src/files/pack-dir.ts\nconst SKIP_DIRS$1 = new Set([\".git\", \"node_modules\"]);\n/** Recursively read a host file or directory into sandbox-relative `{ path, file }` entries. */\nfunction packDirFromDisk(rootPath) {\n\tconst stat = statSync(rootPath);\n\tif (stat.isFile()) return [{\n\t\tpath: basename(rootPath),\n\t\tfile: readFileSync(rootPath, \"utf8\")\n\t}];\n\tif (!stat.isDirectory()) throw new Error(`Expected a file or directory at ${rootPath}`);\n\tconst files = [];\n\twalkDir(rootPath, rootPath, files);\n\treturn files;\n}\nfunction walkDir(rootPath, currentPath, files) {\n\tfor (const name of readdirSync(currentPath)) {\n\t\tif (SKIP_DIRS$1.has(name)) continue;\n\t\tconst entryPath = join(currentPath, name);\n\t\tconst stat = statSync(entryPath);\n\t\tif (stat.isDirectory()) {\n\t\t\twalkDir(rootPath, entryPath, files);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stat.isFile()) continue;\n\t\tfiles.push({\n\t\t\tpath: relative(rootPath, entryPath),\n\t\t\tfile: readFileSync(entryPath, \"utf8\")\n\t\t});\n\t}\n}\n//#endregion\n//#region src/files/pack-asset-dirs.ts\nconst SKIP_DIRS = new Set([\".git\", \"node_modules\"]);\n/** Pack every subdir under `src/skills/` and `src/files/` into an asset manifest. */\nfunction packAssetDirs(appRoot, srcDir = \"src\") {\n\treturn {\n\t\tskills: packAssetRoot(join(appRoot, srcDir, \"skills\")),\n\t\tfiles: packAssetRoot(join(appRoot, srcDir, \"files\"))\n\t};\n}\nfunction packAssetRoot(rootPath) {\n\tif (!statSync(rootPath, { throwIfNoEntry: false })?.isDirectory()) return {};\n\tconst manifest = {};\n\tfor (const name of readdirSync(rootPath)) {\n\t\tif (SKIP_DIRS.has(name)) continue;\n\t\tconst entryPath = join(rootPath, name);\n\t\tif (!statSync(entryPath).isDirectory()) continue;\n\t\tmanifest[name] = packDirFromDisk(entryPath);\n\t}\n\treturn manifest;\n}\n//#endregion\n//#region src/files/app-root-scope.ts\nconst appRootStorage = new AsyncLocalStorage();\n/** Run with an explicit user-app root (parallel-safe alternative to mutating `KEYSTROKE_ROOT`). */\nfunction runWithAppRoot(appRoot, fn) {\n\treturn appRootStorage.run(appRoot, fn);\n}\nfunction getBoundAppRoot() {\n\treturn appRootStorage.getStore();\n}\n//#endregion\n//#region src/files/resolve-sandbox-definition.ts\nfunction parseAssetModule(source) {\n\tconst trimmed = source.trim();\n\tif (!trimmed.startsWith(\"export default \")) return null;\n\tconst json = trimmed.slice(15).replace(/;\\s*$/, \"\");\n\treturn JSON.parse(json);\n}\nfunction loadBuiltManifest(appRoot) {\n\tconst candidates = [\n\t\tjoin(appRoot, \"dist/.keystroke/assets.mjs\"),\n\t\tjoin(appRoot, \"dist/.agent/assets.mjs\"),\n\t\tjoin(appRoot, \".keystroke/assets.mjs\"),\n\t\tjoin(appRoot, \".agent/assets.mjs\")\n\t];\n\tfor (const candidate of candidates) {\n\t\tif (!existsSync(candidate)) continue;\n\t\ttry {\n\t\t\tconst fromSource = parseAssetModule(readFileSync(candidate, \"utf8\"));\n\t\t\tif (fromSource) return fromSource;\n\t\t} catch {}\n\t\ttry {\n\t\t\tconst mod = createRequire(join(appRoot, \"package.json\"))(candidate);\n\t\t\treturn mod.default ?? mod;\n\t\t} catch {}\n\t}\n\treturn null;\n}\nfunction loadAssetManifest(appRoot) {\n\treturn loadBuiltManifest(appRoot) ?? packAssetDirs(appRoot);\n}\nfunction resolveProjectSetKey(set, options) {\n\tif (set === true) {\n\t\tconst projectSlug = options.projectSlug?.trim();\n\t\tif (!projectSlug) throw new Error(\"sandbox files: true requires a project slug at resolve time (e.g. defineAgent({ slug: \\\"support\\\", sandbox: defineSandbox({ files: true }) }))\");\n\t\treturn projectSlug;\n\t}\n\treturn set;\n}\nfunction loadProjectFileSet(set, options) {\n\tconst setKey = resolveProjectSetKey(set, options);\n\tconst files = loadAssetManifest(options.appRoot ?? getBoundAppRoot() ?? process.env.KEYSTROKE_ROOT ?? process.cwd()).files[setKey];\n\tif (!files?.length) throw new Error(`Unknown file set \"${setKey}\" — expected src/files/${setKey}/`);\n\treturn files.map((entry) => ({\n\t\tpath: entry.path,\n\t\tfile: entry.file\n\t}));\n}\nfunction resolveSandboxFiles(files, options) {\n\tif (files === void 0) return;\n\tif (Array.isArray(files)) return files;\n\treturn loadProjectFileSet(files, options);\n}\n/** Resolve author sandbox input into a normalized definition for materialization/runtime. */\nfunction resolveSandboxDefinition(input, options = {}) {\n\tconst resolvedFiles = resolveSandboxFiles(input.files, options);\n\treturn {\n\t\t...input.key !== void 0 ? { key: input.key } : {},\n\t\t...input.mode !== void 0 ? { mode: input.mode } : {},\n\t\t...resolvedFiles !== void 0 ? { files: resolvedFiles } : {}\n\t};\n}\n//#endregion\n//#region src/files/resolve-app-root.ts\n/** Walk upward from a module file to find the user app root (`src/agents`, `src/skills`, etc.). */\nfunction resolveAppRoot(fromPath) {\n\tlet dir = statSync(fromPath).isDirectory() ? fromPath : dirname(fromPath);\n\twhile (dir !== dirname(dir)) {\n\t\tif (hasAppLayout(dir)) return dir;\n\t\tdir = dirname(dir);\n\t}\n\treturn process.env.KEYSTROKE_ROOT ?? process.cwd();\n}\n/** Resolve app root from an agent (or other) module URL. */\nfunction resolveAppRootFromModule(moduleUrl) {\n\treturn resolveAppRoot(fileURLToPath(moduleUrl));\n}\nfunction hasAppLayout(dir) {\n\tconst src = join(dir, \"src\");\n\tconst dist = join(dir, \"dist\");\n\treturn existsSync(join(src, \"agents\")) || existsSync(join(src, \"skills\")) || existsSync(join(src, \"files\")) || existsSync(join(dist, \"agents\")) || existsSync(join(dist, \".keystroke\", \"assets.mjs\"));\n}\n//#endregion\nexport { SandboxModeSchema as _, getBoundAppRoot as a, packDirFromDisk as c, defineSandbox as d, SandboxDefinitionInputSchema as f, SandboxFilesInputSchema as g, SandboxFileSchema as h, resolveSandboxDefinition as i, materializeSandbox as l, SandboxFileContentSchema as m, resolveAppRootFromModule as n, runWithAppRoot as o, SandboxDefinitionSchema as p, loadAssetManifest as r, packAssetDirs as s, resolveAppRoot as t, flattenSandboxFiles as u, SandboxProjectFilesSchema as v };\n\n//# sourceMappingURL=files-BOUCjfCQ.mjs.map","/** TypeBox instantiation metrics */\nexport const Metrics = {\n assign: 0,\n create: 0,\n clone: 0,\n discard: 0,\n update: 0\n};\n","import * as String from './string.mjs';\n// --------------------------------------------------------------------------\n// Guards\n// --------------------------------------------------------------------------\n/** Returns true if this value is an array */\nexport function IsArray(value) {\n return Array.isArray(value);\n}\n/** Returns true if this value is an async iterator */\nexport function IsAsyncIterator(value) {\n return IsObject(value) && Symbol.asyncIterator in value;\n}\n/** Returns true if this value is bigint */\nexport function IsBigInt(value) {\n return IsEqual(typeof value, 'bigint');\n}\n/** Returns true if this value is a boolean */\nexport function IsBoolean(value) {\n return IsEqual(typeof value, 'boolean');\n}\n/** Returns true if this value is a constructor */\nexport function IsConstructor(value) {\n if (IsUndefined(value) || !IsFunction(value))\n return false;\n const result = Function.prototype.toString.call(value);\n if (/^class\\s/.test(result))\n return true;\n if (/\\[native code\\]/.test(result))\n return true;\n return false;\n}\n/** Returns true if this value is a function */\nexport function IsFunction(value) {\n return IsEqual(typeof value, 'function');\n}\n/** Returns true if this value is integer */\nexport function IsInteger(value) {\n return Number.isInteger(value);\n}\n/** Returns true if this value is an iterator */\nexport function IsIterator(value) {\n return IsObject(value) && Symbol.iterator in value;\n}\n/** Returns true if this value is null */\nexport function IsNull(value) {\n return IsEqual(value, null);\n}\n/** Returns true if this value is number */\nexport function IsNumber(value) {\n return Number.isFinite(value);\n}\n/** Returns true if this value is an object but not an array */\nexport function IsObjectNotArray(value) {\n return IsObject(value) && !IsArray(value);\n}\n/** Returns true if this value is an object */\nexport function IsObject(value) {\n return IsEqual(typeof value, 'object') && !(IsNull(value));\n}\n/** Returns true if this value is string */\nexport function IsString(value) {\n return IsEqual(typeof value, 'string');\n}\n/** Returns true if this value is symbol */\nexport function IsSymbol(value) {\n return IsEqual(typeof value, 'symbol');\n}\n/** Returns true if this value is undefined */\nexport function IsUndefined(value) {\n return IsEqual(value, undefined);\n}\n// --------------------------------------------------------------------------\n// Relational\n// --------------------------------------------------------------------------\nexport function IsEqual(left, right) {\n return left === right;\n}\nexport function IsGreaterThan(left, right) {\n return left > right;\n}\nexport function IsLessThan(left, right) {\n return left < right;\n}\nexport function IsLessEqualThan(left, right) {\n return left <= right;\n}\nexport function IsGreaterEqualThan(left, right) {\n return left >= right;\n}\n// --------------------------------------------------------------------------\n// MultipleOf\n// --------------------------------------------------------------------------\nexport function IsMultipleOf(dividend, divisor) {\n if (IsBigInt(dividend) || IsBigInt(divisor)) {\n return BigInt(dividend) % BigInt(divisor) === 0n;\n }\n const tolerance = 1e-10;\n if (!IsNumber(dividend))\n return true;\n if (IsInteger(dividend) && (1 / divisor) % 1 === 0)\n return true;\n const mod = dividend % divisor;\n return Math.min(Math.abs(mod), Math.abs(mod - divisor)) < tolerance;\n}\n// ------------------------------------------------------------------\n// IsClassInstance\n// ------------------------------------------------------------------\n/** Returns true if the value appears to be an instance of a class. */\nexport function IsClassInstance(value) {\n if (!IsObject(value))\n return false;\n const proto = globalThis.Object.getPrototypeOf(value);\n if (IsNull(proto))\n return false;\n return IsEqual(typeof proto.constructor, 'function') &&\n !(IsEqual(proto.constructor, globalThis.Object) ||\n IsEqual(proto.constructor.name, 'Object'));\n}\n// ------------------------------------------------------------------\n// IsValueLike\n// ------------------------------------------------------------------\nexport function IsValueLike(value) {\n return IsBigInt(value) ||\n IsBoolean(value) ||\n IsNull(value) ||\n IsNumber(value) ||\n IsString(value) ||\n IsUndefined(value);\n}\n// --------------------------------------------------------------------------\n// String\n// --------------------------------------------------------------------------\n/** Returns the number of grapheme clusters in the string */\nexport function GraphemeCount(value) {\n return String.GraphemeCount(value);\n}\n/** Returns true if the string has at most the given number of graphemes */\nexport function IsMaxLength(value, length) {\n return String.IsMaxLengthFast(value, length);\n}\n/** Returns true if the string has at least the given number of graphemes */\nexport function IsMinLength(value, length) {\n return String.IsMinLengthFast(value, length);\n}\n// --------------------------------------------------------------------------\n// Array\n// --------------------------------------------------------------------------\n/** Returns true if all elements from offset satisfy the callback, short-circuiting on the first failure */\nexport function Every(value, offset, callback) {\n for (let index = offset; index < value.length; index++) {\n if (!callback(value[index], index))\n return false;\n }\n return true;\n}\n/** Returns true if all elements from offset satisfy the callback, visiting every element regardless of failure */\nexport function EveryAll(value, offset, callback) {\n let result = true;\n for (let index = offset; index < value.length; index++) {\n if (!callback(value[index], index))\n result = false;\n }\n return result;\n}\n/** Takes the left-most element from an array and dispatches to the true arm, or the false arm if empty */\nexport function TakeLeft(array, true_, false_) {\n return (IsEqual(array.length, 0) ? false_() : true_(array[0], array.slice(1)));\n}\n// --------------------------------------------------------------------------\n// Object\n// --------------------------------------------------------------------------\n/** Returns true if the PropertyKey is Unsafe (ref: prototype-pollution). */\nexport function IsUnsafePropertyKey(key) {\n return IsEqual(key, '__proto__') || IsEqual(key, 'constructor') || IsEqual(key, 'prototype');\n}\n/** Returns true if this value has this property key */\nexport function HasPropertyKey(value, key) {\n return IsUnsafePropertyKey(key) ? Object.prototype.hasOwnProperty.call(value, key) : key in value;\n}\n/** Returns object entries as `[RegExp, Value][]` */\nexport function EntriesRegExp(value) {\n return Keys(value).map((key) => [new RegExp(`^${key}$`), value[key]]);\n}\n/** Returns object entries as `[string, Value][]` */\nexport function Entries(value) {\n return Object.entries(value);\n}\n/** Returns property keys for this object via `Object.getOwnPropertyKeys({ ... })` */\nexport function Keys(value) {\n return Object.getOwnPropertyNames(value);\n}\n/** Returns the property keys for this object via `Object.getOwnPropertyKeys({ ... })` */\nexport function Symbols(value) {\n return Object.getOwnPropertySymbols(value);\n}\n/** Returns the property values for the given object via `Object.values()` */\nexport function Values(value) {\n return Object.values(value);\n}\n// ------------------------------------------------------------------\n// IsDeepEqual\n// ------------------------------------------------------------------\nfunction DeepEqualObject(left, right) {\n if (!IsObject(right))\n return false;\n const keys = Keys(left);\n return IsEqual(keys.length, Keys(right).length) &&\n keys.every((key) => IsDeepEqual(left[key], right[key]));\n}\nfunction DeepEqualArray(left, right) {\n return IsArray(right) && IsEqual(left.length, right.length) &&\n left.every((_, index) => IsDeepEqual(left[index], right[index]));\n}\n/** Tests values for deep equality */\nexport function IsDeepEqual(left, right) {\n return (IsArray(left) ? DeepEqualArray(left, right) : IsObject(left) ? DeepEqualObject(left, right) : IsEqual(left, right));\n}\n","// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\nimport { Metrics } from './metrics.mjs';\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\nfunction IsGuard(value) {\n return Guard.IsObject(value) && Guard.HasPropertyKey(value, '~guard');\n}\nfunction FromGuard(value) {\n return value; // non-clonable\n}\n// ------------------------------------------------------------------\n// Array\n// ------------------------------------------------------------------\nfunction FromArray(value) {\n return value.map((value) => FromValue(value));\n}\n// ------------------------------------------------------------------\n// Object\n// ------------------------------------------------------------------\nfunction FromObject(value) {\n const result = {};\n const descriptors = Object.getOwnPropertyDescriptors(value);\n for (const key of Object.keys(descriptors)) {\n const descriptor = descriptors[key];\n if (Guard.HasPropertyKey(descriptor, 'value')) {\n Object.defineProperty(result, key, { ...descriptor, value: FromValue(descriptor.value) });\n }\n }\n return result;\n}\n// ------------------------------------------------------------------\n// RegExp\n// ------------------------------------------------------------------\nfunction FromRegExp(value) {\n return new RegExp(value.source, value.flags);\n}\n// ------------------------------------------------------------------\n// RegExp\n// ------------------------------------------------------------------\nfunction FromUnknown(value) {\n return value;\n}\n// ------------------------------------------------------------------\n// Value\n// ------------------------------------------------------------------\nfunction FromValue(value) {\n return (value instanceof RegExp ? FromRegExp(value) :\n IsGuard(value) ? FromGuard(value) :\n Guard.IsArray(value) ? FromArray(value) :\n Guard.IsObject(value) ? FromObject(value) :\n FromUnknown(value));\n}\n/**\n * Clones a value using the TypeBox type cloning strategy. This function preserves non-enumerable\n * properties from the source value. This is to ensure cloned types retain discriminable\n * hidden properties.\n */\nexport function Clone(value) {\n Metrics.clone += 1;\n return FromValue(value);\n}\n","import { Guard } from '../../guard/index.mjs';\n// Internal mutable state\nconst settings = {\n immutableTypes: false,\n maxErrors: 8,\n useAcceleration: true,\n exactOptionalPropertyTypes: false,\n enumerableKind: false,\n correctiveParse: false\n};\n/** Resets system settings to defaults */\nexport function Reset() {\n settings.immutableTypes = false;\n settings.maxErrors = 8;\n settings.useAcceleration = true;\n settings.exactOptionalPropertyTypes = false;\n settings.enumerableKind = false;\n settings.correctiveParse = false;\n}\n/** Sets system settings */\nexport function Set(options) {\n for (const key of Guard.Keys(options)) {\n const value = options[key];\n if (value !== undefined) {\n Object.defineProperty(settings, key, { value });\n }\n }\n}\n/** Gets current system settings */\nexport function Get() {\n return settings;\n}\n","// deno-lint-ignore-file no-explicit-any\n// deno-fmt-ignore-file\nimport { Settings } from '../settings/index.mjs';\nimport { Metrics } from './metrics.mjs';\nfunction MergeHidden(left, right) {\n for (const key of Object.keys(right)) {\n Object.defineProperty(left, key, {\n configurable: true,\n writable: true,\n enumerable: false,\n value: right[key]\n });\n }\n return left;\n}\nfunction Merge(left, right) {\n return { ...left, ...right };\n}\n/**\n * Creates an object with hidden, enumerable, and optional property sets. This function\n * ensures types are instantiated according to configuration rules for enumerable and\n * non-enumerable properties.\n */\nexport function Create(hidden, enumerable, options = {}) {\n Metrics.create += 1;\n const settings = Settings.Get();\n const withOptions = Merge(enumerable, options);\n const withHidden = settings.enumerableKind ? Merge(withOptions, hidden) : MergeHidden(withOptions, hidden);\n return settings.immutableTypes ? Object.freeze(withHidden) : withHidden;\n}\n","// deno-fmt-ignore-file\nimport { Settings } from '../settings/index.mjs';\nimport { Metrics } from './metrics.mjs';\nimport { Clone } from './clone.mjs';\n/**\n * Updates a value with new properties while preserving property enumerability. Use this function to modify\n * existing types without altering their configuration.\n */\nexport function Update(current, hidden, enumerable) {\n Metrics.update += 1;\n const settings = Settings.Get();\n const result = Clone(current);\n // hidden\n for (const key of Object.keys(hidden)) {\n Object.defineProperty(result, key, {\n configurable: true,\n writable: true,\n enumerable: settings.enumerableKind,\n value: hidden[key]\n });\n }\n // enumerable\n for (const key of Object.keys(enumerable)) {\n Object.defineProperty(result, key, {\n configurable: true,\n enumerable: true,\n writable: true,\n value: enumerable[key]\n });\n }\n return result;\n}\n","// deno-lint-ignore-file\n// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\n// ------------------------------------------------------------------\n// Kind\n// ------------------------------------------------------------------\nexport function IsKind(value, kind) {\n return Guard.IsObject(value) && Guard.HasPropertyKey(value, '~kind') && Guard.IsEqual(value[\"~kind\"], kind);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\nexport function IsSchema(value) {\n return Guard.IsObject(value);\n}\n","// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsSchema } from './schema.mjs';\n/** Removes Optional from the given type. */\nexport function OptionalRemove(type) {\n const result = Memory.Discard(type, ['~optional']);\n return result;\n}\n/** Adds Optional to the given type. */\nexport function OptionalAdd(type) {\n return Memory.Update(type, { '~optional': true }, {});\n}\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Applies an Optional modifier to the given type. */\nexport function Optional(type) {\n return OptionalAdd(type);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TOptional */\nexport function IsOptional(value) {\n return IsSchema(value) && Guard.HasPropertyKey(value, '~optional');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates an Array type. */\nexport function _Array_(items, options) {\n return Memory.Create({ '~kind': 'Array' }, { type: 'array', items }, options);\n}\nexport { _Array_ as Array }; // Prevent Collision With Global Scope\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is a TArray. */\nexport function IsArray(value) {\n return IsKind(value, 'Array');\n}\n// ------------------------------------------------------------------\n// Options\n// ------------------------------------------------------------------\n/** Extracts options from a TArray. */\nexport function ArrayOptions(type) {\n return Memory.Discard(type, ['~kind', 'type', 'items']);\n}\n","// deno-fmt-ignore-file\nimport { Guard } from '../../guard/index.mjs';\nimport { IsOptional } from './_optional.mjs';\n/** Creates a RequiredArray derived from the given TProperties value. */\nexport function RequiredArray(properties) {\n return Guard.Keys(properties).filter((key) => !IsOptional(properties[key]));\n}\n/** Extracts a tuple of keys from a TProperties value. */\nexport function PropertyKeys(properties) {\n return Guard.Keys(properties);\n}\n/** Extracts a tuple of property values from a TProperties value. */\nexport function PropertyValues(properties) {\n return Guard.Values(properties);\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\nimport { RequiredArray } from './properties.mjs';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates an Object type. */\nexport function _Object_(properties, options = {}) {\n const requiredKeys = RequiredArray(properties);\n const required = requiredKeys.length > 0 ? { required: requiredKeys } : {};\n return Memory.Create({ '~kind': 'Object' }, { type: 'object', ...required, properties }, options);\n}\nexport { _Object_ as Object }; // Prevent Collision With Global Scope\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TObject. */\nexport function IsObject(value) {\n return IsKind(value, 'Object');\n}\n// ------------------------------------------------------------------\n// Options\n// ------------------------------------------------------------------\n/** Extracts options from a TObject. */\nexport function ObjectOptions(type) {\n return Memory.Discard(type, ['~kind', 'type', 'properties', 'required']);\n}\n","// deno-fmt-ignore-file\nimport { Unreachable } from '../unreachable/index.mjs';\nimport { Guard, GlobalsGuard } from '../../guard/index.mjs';\n// ------------------------------------------------------------------\n// InstanceKeys\n//\n// Retrieves all enumerable and non-enumerable own property keys \n// and inherited prototype keys (excluding symbols and the 'constructor') \n// from an object instance.\n//\n// This function is useful for differentiating between class instances \n// based on their structural keys rather than relying on the \n// constructor name. It provides a more reliable structural comparison \n// by capturing both own and prototype properties.\n//\n// ------------------------------------------------------------------\nfunction InstanceKeys(value) {\n const propertyKeys = new Set();\n let current = value;\n while (current && current !== Object.prototype) {\n for (const key of Reflect.ownKeys(current)) {\n if (key !== 'constructor' && typeof key !== 'symbol')\n propertyKeys.add(key);\n }\n current = Object.getPrototypeOf(current);\n }\n return [...propertyKeys];\n}\n// ------------------------------------------------------------------\n// IsIEEE754\n//\n// TypeBox guards do not consider +/- Infinity or NaN as valid\n// numbers, but they are valid IEEE754 numbers. We use a special\n// guard to ensure these numbers are considered for hashing.\n//\n// ------------------------------------------------------------------\nfunction IsIEEE754(value) {\n return typeof value === 'number';\n}\n// ------------------------------------------------------------------\n// ByteMarker\n// ------------------------------------------------------------------\nvar ByteMarker;\n(function (ByteMarker) {\n ByteMarker[ByteMarker[\"Array\"] = 0] = \"Array\";\n ByteMarker[ByteMarker[\"BigInt\"] = 1] = \"BigInt\";\n ByteMarker[ByteMarker[\"Boolean\"] = 2] = \"Boolean\";\n ByteMarker[ByteMarker[\"Date\"] = 3] = \"Date\";\n ByteMarker[ByteMarker[\"Constructor\"] = 4] = \"Constructor\";\n ByteMarker[ByteMarker[\"Function\"] = 5] = \"Function\";\n ByteMarker[ByteMarker[\"Null\"] = 6] = \"Null\";\n ByteMarker[ByteMarker[\"Number\"] = 7] = \"Number\";\n ByteMarker[ByteMarker[\"Object\"] = 8] = \"Object\";\n ByteMarker[ByteMarker[\"RegExp\"] = 9] = \"RegExp\";\n ByteMarker[ByteMarker[\"String\"] = 10] = \"String\";\n ByteMarker[ByteMarker[\"Symbol\"] = 11] = \"Symbol\";\n ByteMarker[ByteMarker[\"TypeArray\"] = 12] = \"TypeArray\";\n ByteMarker[ByteMarker[\"Undefined\"] = 13] = \"Undefined\";\n})(ByteMarker || (ByteMarker = {}));\n// ------------------------------------------------------------------\n// State\n// ------------------------------------------------------------------\nlet Accumulator = BigInt('14695981039346656037');\nconst [Prime, Size] = [BigInt('1099511628211'), BigInt('18446744073709551616' /* 2 ^ 64 */)];\nconst Bytes = Array.from({ length: 256 }).map((_, i) => BigInt(i));\nconst F64 = new Float64Array(1);\nconst F64In = new DataView(F64.buffer);\nconst F64Out = new Uint8Array(F64.buffer);\n// ------------------------------------------------------------------\n// Operation\n// ------------------------------------------------------------------\nfunction FNV1A64_OP(byte) {\n Accumulator = Accumulator ^ Bytes[byte];\n Accumulator = (Accumulator * Prime) % Size;\n}\n// ------------------------------------------------------------------\n// Array\n// ------------------------------------------------------------------\nfunction FromArray(value) {\n FNV1A64_OP(ByteMarker.Array);\n for (const item of value) {\n FromValue(item);\n }\n}\n// ------------------------------------------------------------------\n// BigInt\n// ------------------------------------------------------------------\nfunction FromBigInt(value) {\n FNV1A64_OP(ByteMarker.BigInt);\n F64In.setBigInt64(0, value);\n for (const byte of F64Out) {\n FNV1A64_OP(byte);\n }\n}\n// ------------------------------------------------------------------\n// Boolean\n// ------------------------------------------------------------------\nfunction FromBoolean(value) {\n FNV1A64_OP(ByteMarker.Boolean);\n FNV1A64_OP(value ? 1 : 0);\n}\n// ------------------------------------------------------------------\n// Constructor\n// ------------------------------------------------------------------\nfunction FromConstructor(value) {\n FNV1A64_OP(ByteMarker.Constructor);\n FromValue(value.toString());\n}\n// ------------------------------------------------------------------\n// Date\n// ------------------------------------------------------------------\nfunction FromDate(value) {\n FNV1A64_OP(ByteMarker.Date);\n FromValue(value.getTime());\n}\n// ------------------------------------------------------------------\n// Function\n// ------------------------------------------------------------------\nfunction FromFunction(value) {\n FNV1A64_OP(ByteMarker.Function);\n FromValue(value.toString());\n}\n// ------------------------------------------------------------------\n// Null\n// ------------------------------------------------------------------\nfunction FromNull(_value) {\n FNV1A64_OP(ByteMarker.Null);\n}\n// ------------------------------------------------------------------\n// Number | IEEE754\n// ------------------------------------------------------------------\nfunction FromNumber(value) {\n FNV1A64_OP(ByteMarker.Number);\n F64In.setFloat64(0, value, true /* little-endian */);\n for (const byte of F64Out) {\n FNV1A64_OP(byte);\n }\n}\n// ------------------------------------------------------------------\n// Object\n// ------------------------------------------------------------------\nfunction FromObject(value) {\n FNV1A64_OP(ByteMarker.Object);\n for (const key of InstanceKeys(value).sort()) {\n FromValue(key);\n FromValue(value[key]);\n }\n}\n// ------------------------------------------------------------------\n// RegExp\n// ------------------------------------------------------------------\nfunction FromRegExp(value) {\n FNV1A64_OP(ByteMarker.RegExp);\n FromString(value.toString());\n}\n// ------------------------------------------------------------------\n// String\n// ------------------------------------------------------------------\nconst encoder = new TextEncoder();\nfunction FromString(value) {\n FNV1A64_OP(ByteMarker.String);\n for (const byte of encoder.encode(value)) {\n FNV1A64_OP(byte);\n }\n}\n// ------------------------------------------------------------------\n// Symbol\n// ------------------------------------------------------------------\nfunction FromSymbol(value) {\n FNV1A64_OP(ByteMarker.Symbol);\n FromValue(value.toString());\n}\n// ------------------------------------------------------------------\n// TypeArray\n// ------------------------------------------------------------------\nfunction FromTypeArray(value) {\n FNV1A64_OP(ByteMarker.TypeArray);\n const buffer = new Uint8Array(value.buffer);\n for (let i = 0; i < buffer.length; i++) {\n FNV1A64_OP(buffer[i]);\n }\n}\n// ------------------------------------------------------------------\n// Undefined\n// ------------------------------------------------------------------\nfunction FromUndefined(_value) {\n return FNV1A64_OP(ByteMarker.Undefined);\n}\n// ------------------------------------------------------------------\n// Hash\n//\n// deno-coverage-ignore-start - unreachable\n//\n// This function should all JavaScript values so we can't reach the\n// fall-through. We use Unreachable to assert that no values pass\n// through. We will need to handle these should they arise.\n//\n// ------------------------------------------------------------------\nfunction FromValue(value) {\n return (GlobalsGuard.IsTypeArray(value) ? FromTypeArray(value) :\n GlobalsGuard.IsDate(value) ? FromDate(value) :\n GlobalsGuard.IsRegExp(value) ? FromRegExp(value) :\n GlobalsGuard.IsBoolean(value) ? FromBoolean(value.valueOf()) :\n GlobalsGuard.IsString(value) ? FromString(value.valueOf()) :\n GlobalsGuard.IsNumber(value) ? FromNumber(value.valueOf()) :\n IsIEEE754(value) ? FromNumber(value) :\n Guard.IsArray(value) ? FromArray(value) :\n Guard.IsBoolean(value) ? FromBoolean(value) :\n Guard.IsBigInt(value) ? FromBigInt(value) :\n Guard.IsConstructor(value) ? FromConstructor(value) :\n Guard.IsNull(value) ? FromNull(value) :\n Guard.IsObject(value) ? FromObject(value) :\n Guard.IsString(value) ? FromString(value) :\n Guard.IsSymbol(value) ? FromSymbol(value) :\n Guard.IsUndefined(value) ? FromUndefined(value) :\n Guard.IsFunction(value) ? FromFunction(value) :\n Unreachable());\n}\n// deno-coverage-ignore-stop\n// ------------------------------------------------------------------\n// Hash\n// ------------------------------------------------------------------\n/** Generates a FNV1A-64 non cryptographic hash of the given value */\nexport function HashCode(value) {\n Accumulator = BigInt('14695981039346656037');\n FromValue(value);\n return Accumulator;\n}\n/** Generates a FNV1A-64 non cryptographic hash of the given value */\nexport function Hash(value) {\n return HashCode(value).toString(16).padStart(16, '0');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// Pattern\n// ------------------------------------------------------------------\nexport const IntegerPattern = '-?(?:0|[1-9][0-9]*)';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates a Integer type. */\nexport function Integer(options) {\n return Memory.Create({ '~kind': 'Integer' }, { type: 'integer' }, options);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TInteger. */\nexport function IsInteger(value) {\n return IsKind(value, 'Integer');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// Pattern\n// ------------------------------------------------------------------\nexport const NumberPattern = '-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates a Number type. */\nexport function Number(options) {\n return Memory.Create({ '~kind': 'Number' }, { type: 'number' }, options);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is a TNumber. */\nexport function IsNumber(value) {\n return IsKind(value, 'Number');\n}\n","// deno-lint-ignore-file\n// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { IsKind } from './schema.mjs';\n// ------------------------------------------------------------------\n// StringPattern\n// ------------------------------------------------------------------\nexport const StringPattern = '.*';\n// ------------------------------------------------------------------\n// Factory\n// ------------------------------------------------------------------\n/** Creates a String type. */\nexport function String(options) {\n return Memory.Create({ '~kind': 'String' }, { type: 'string' }, options);\n}\n// ------------------------------------------------------------------\n// Guard\n// ------------------------------------------------------------------\n/** Returns true if the given value is TString. */\nexport function IsString(value) {\n return IsKind(value, 'String');\n}\n","// deno-fmt-ignore-file\nimport { Memory } from '../../system/memory/index.mjs';\nimport { Guard } from '../../guard/index.mjs';\nimport { IsKind } from './schema.mjs';\nimport { Integer, IntegerPattern } from './integer.mjs';\nimport { Number, NumberPattern } from './number.mjs';\nimport { String, StringPattern } from './string.mjs';\nimport { Deferred } from './deferred.mjs';\nimport { TemplateLiteralDecodeUnsafe } from '../engine/template_literal/decode.mjs';\nimport { CreateRecord } from '../engine/record/record_create.mjs';\nimport { RecordAction } from '../engine/record/instantiate.mjs';\nexport const IntegerKey = `^${IntegerPattern}$`;\nexport const NumberKey = `^${NumberPattern}$`;\nexport const StringKey = `^${StringPattern}$`;\n/** Represents a deferred Record action. */\nexport function RecordDeferred(key, value, options = {}) {\n return Deferred('Record', [key, value], options);\n}\n// -------------------------------------------------------------------\n// Factory\n// -------------------------------------------------------------------\n/** Creates a Record type. */\nexport function Record(key, value, options = {}) {\n return RecordAction(key, value, options);\n}\n// -------------------------------------------------------------------\n// FromPattern\n// -------------------------------------------------------------------\n/** Creates a Record type from regular expression pattern. */\nexport function RecordFromPattern(key, value) {\n return CreateRecord(key, value);\n}\n/** Returns the raw string pattern used for the Record key */\nexport function RecordPattern(type) {\n return Guard.Keys(type.patternProperties)[0];\n}\n/** Returns the Record key as a TypeBox type */\nexport function RecordKey(type) {\n const pattern = RecordPattern(type);\n const result = (Guard.IsEqual(pattern, StringKey) ? String() :\n Guard.IsEqual(pattern, IntegerKey) ? Integer() :\n Guard.IsEqual(pattern, NumberKey) ? Number() :\n TemplateLiteralDecodeUnsafe(pattern));\n return result;\n}\nexport function RecordValue(type) {\n return type.patternProperties[RecordPattern(type)];\n}\n// -------------------------------------------------------------------\n// Guard\n// -------------------------------------------------------------------\nexport function IsRecord(value) {\n return IsKind(value, 'Record');\n}\n// -------------------------------------------------------------------\n// Options\n// -------------------------------------------------------------------\nexport function RecordOptions(type) {\n return Memory.Discard(type, ['~kind', 'type', 'patternProperties']);\n}\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\n// ------------------------------------------------------------------\n// Range\n// ------------------------------------------------------------------\nfunction Range(start, end) {\n return Array.from({ length: end - start + 1 }, (_, i) => String.fromCharCode(start + i));\n}\nexport const Alpha = [\n ...Range(97, 122), // Lowercase\n ...Range(65, 90) // Uppercase\n];\nexport const Zero = '0';\nexport const NonZero = Range(49, 57); // 1 - 9\nexport const Digit = [Zero, ...NonZero];\n// ------------------------------------------------------------------\n// Characters\n// ------------------------------------------------------------------\nexport const WhiteSpace = ' ';\nexport const NewLine = '\\n';\nexport const TabSpace = '\\t';\nexport const UnderScore = '_';\nexport const Dot = '.';\nexport const DollarSign = '$';\nexport const Hyphen = '-';\n// deno-coverage-ignore-stop\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\nimport { Match } from './internal/match.mjs';\nimport { Trim } from './internal/trim.mjs';\nimport { Take } from './internal/take.mjs';\nimport { Many } from './internal/many.mjs';\nimport { Digit } from './internal/char.mjs';\nimport { Zero } from './internal/char.mjs';\nimport { NonZero } from './internal/char.mjs';\nimport { UnderScore } from './internal/char.mjs';\nfunction TakeNonZero(input) {\n return Take(NonZero, input);\n}\nconst AllowedDigits = [...Digit, UnderScore];\nfunction TakeDigits(input) {\n return Many(AllowedDigits, [UnderScore], input);\n}\nfunction TakeUnsignedInteger(input) {\n return Match(Take([Zero], input), (Zero, ZeroRest) => [Zero, ZeroRest], () => Match(TakeNonZero(input), (NonZero, NonZeroRest) => Match(TakeDigits(NonZeroRest), (Digits, DigitsRest) => [`${NonZero}${Digits}`, DigitsRest], () => []), // fail: did not match Digits\n () => [])); // fail: did not match NonZero\n}\n/** Matches if next is a UnsignedInteger */\nexport function UnsignedInteger(input) {\n return TakeUnsignedInteger(Trim(input));\n}\n// deno-coverage-ignore-stop\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\nimport { Match } from './internal/match.mjs';\nimport { Trim } from './internal/trim.mjs';\nimport { Take } from './internal/take.mjs';\nimport { Alpha } from './internal/char.mjs';\nimport { Digit } from './internal/char.mjs';\nimport { UnderScore } from './internal/char.mjs';\nimport { DollarSign } from './internal/char.mjs';\nconst Initial = [...Alpha, UnderScore, DollarSign];\nfunction TakeInitial(input) {\n return Take(Initial, input);\n}\nconst Remaining = [...Initial, ...Digit];\nfunction TakeRemaining(input, result = '') {\n return Match(Take(Remaining, input), (Remaining, RemainingRest) => TakeRemaining(RemainingRest, `${result}${Remaining}`), () => [result, input]);\n}\nfunction TakeIdent(input) {\n return Match(TakeInitial(input), (Initial, InitialRest) => Match(TakeRemaining(InitialRest), (Remaining, RemainingRest) => [`${Initial}${Remaining}`, RemainingRest], () => []), // fail: did not match Remaining\n () => []); // fail: did not match Initial\n}\n/** Matches if next is an Ident */\nexport function Ident(input) {\n return TakeIdent(Trim(input));\n}\n// deno-coverage-ignore-stop\n","// deno-coverage-ignore-start - parsebox tested\n// deno-fmt-ignore-file\nimport { IsEqual } from './internal/guard.mjs';\nimport { IsMatch, Match } from './internal/match.mjs';\nimport { Trim } from './internal/trim.mjs';\nimport { Take } from './internal/take.mjs';\nimport { Many } from './internal/many.mjs';\nimport { Digit, UnderScore } from './internal/char.mjs';\nimport { Dot } from './internal/char.mjs';\nimport { UnsignedInteger } from './unsigned_integer.mjs';\nconst AllowedDigits = [...Digit, UnderScore];\nfunction IsLeadingDot(input) {\n return IsMatch(Take([Dot], input));\n}\nfunction TakeFractional(input) {\n return Match(Many(AllowedDigits, [UnderScore], input), (Digits, DigitsRest) => IsEqual(Digits, '')\n ? [] // fail: no Digits\n : [Digits, DigitsRest], () => []); // fail: did not match Digits\n}\nfunction LeadingDot(input) {\n return Match(Take([Dot], input), (Dot, DotRest) => Match(TakeFractional(DotRest), (Fractional, FractionalRest) => [`0${Dot}${Fractional}`, FractionalRest], () => []), // fail: did not match Fractional\n () => []); // fail: did not match Dot\n}\nfunction LeadingInteger(input) {\n return Match(UnsignedInteger(input), (Integer, IntegerRest) => Match(Take([Dot], IntegerRest), (Dot, DotRest) => Match(TakeFractional(DotRest), (Fractional, FractionalRest) => [`${Integer}${Dot}${Fractional}`, FractionalRest], () => [`${Integer}`, DotRest]), // fail: did not match Fractional, use Integer\n () => [`${Integer}`, IntegerRest]), // fail: did not match Dot, use Integer\n () => []); // fail: did not match Integer\n}\nfunction TakeUnsignedNumber(input) {\n return (IsLeadingDot(input)\n ? LeadingDot(input)\n : LeadingInteger(input));\n}\n/** Matches if next is a UnsignedNumber */\nexport function UnsignedNumber(input) {\n return TakeUnsignedNumber(Trim(input));\n}\n// deno-coverage-ignore-stop\n","// deno-fmt-ignore-file\nimport { IsNumber } from '../../types/number.mjs';\nimport { Never } from '../../types/never.mjs';\nimport { PropertyKeys } from '../../types/properties.mjs';\nimport { EvaluateUnion } from '../evaluate/evaluate.mjs';\nimport { ToIndexableKeys } from '../indexable/to_indexable_keys.mjs';\nimport { IntegerKey } from '../../types/record.mjs';\nimport { ExpandThis } from '../this/expand_this.mjs';\nfunction IndexProperty(properties, key) {\n const selectedType = key in properties ? properties[key] : Never();\n const result = ExpandThis(properties, selectedType);\n return result;\n}\nfunction IndexProperties(properties, keys) {\n return keys.reduce((result, left) => {\n return [...result, IndexProperty(properties, left)];\n }, []);\n}\nfunction FromIndexer(properties, indexer) {\n const keys = ToIndexableKeys(indexer);\n const variants = IndexProperties(properties, keys);\n const result = EvaluateUnion(variants);\n return result;\n}\nconst NumericKeyPattern = new RegExp(IntegerKey);\nfunction NumericKeys(keys) {\n const result = keys.filter(key => NumericKeyPattern.test(key));\n return result;\n}\nfunction FromIndexerNumber(properties) {\n const keys = PropertyKeys(properties);\n const numericKeys = NumericKeys(keys);\n const variants = IndexProperties(properties, numericKeys);\n const result = EvaluateUnion(variants);\n return result;\n}\nexport function FromObject(properties, indexer) {\n const result = IsNumber(indexer) ? FromIndexerNumber(properties) : FromIndexer(properties, indexer);\n return result;\n}\n","import { posix } from \"node:path\";\nimport { Type } from \"typebox\";\n//#region src/tools/workspace-path.ts\nconst WORKSPACE_PREFIX = \"/workspace\";\n/** Guest parent directory for agent + session mounts. */\nconst WORKSPACE_MOUNT = WORKSPACE_PREFIX;\n/** Persistent per-agent files and skills. */\nconst AGENT_MOUNT = `${WORKSPACE_PREFIX}/agent`;\n/** Ephemeral per-session scratch space. */\nconst SESSION_MOUNT = `${WORKSPACE_PREFIX}/session`;\nfunction isAgentOrSessionRelative(relative) {\n\treturn relative === \"agent\" || relative.startsWith(\"agent/\") || relative === \"session\" || relative.startsWith(\"session/\");\n}\n/** Bare relative paths (no agent/ or session/ prefix) land in session scratch. */\nfunction withSessionDefault(relative) {\n\tif (relative === \"\" || isAgentOrSessionRelative(relative)) return relative;\n\treturn posix.join(\"session\", relative);\n}\n/**\n* Map a tool-supplied path to a canonical `/workspace/...` guest path.\n*\n* Unprefixed relative paths resolve under `/workspace/session`. Use an `agent/`\n* prefix for cross-session persistence. Absolute paths must stay under `/workspace`.\n*/\nfunction normalizeWorkspacePath(path) {\n\tconst normalized = path.replace(/\\\\/g, \"/\");\n\tlet relative;\n\tif (normalized === WORKSPACE_PREFIX || normalized === `${WORKSPACE_PREFIX}/`) relative = \"\";\n\telse if (normalized.startsWith(`${WORKSPACE_PREFIX}/`)) relative = normalized.slice(11);\n\telse if (normalized.startsWith(\"/\")) throw new Error(`Path must be under ${WORKSPACE_PREFIX} (e.g. /workspace/session/file.txt). For other paths use bash.`);\n\telse relative = normalized.replace(/^\\.\\//, \"\");\n\tconst beforeDefault = posix.join(WORKSPACE_PREFIX, relative);\n\tif (beforeDefault !== WORKSPACE_PREFIX && !beforeDefault.startsWith(`${WORKSPACE_PREFIX}/`)) throw new Error(`Path escapes workspace: ${path}`);\n\trelative = withSessionDefault(relative);\n\tconst resolved = posix.join(WORKSPACE_PREFIX, relative);\n\tif (resolved !== WORKSPACE_PREFIX && !resolved.startsWith(`${WORKSPACE_PREFIX}/`)) throw new Error(`Path escapes workspace: ${path}`);\n\tlet mount = \"parent\";\n\tif (resolved === AGENT_MOUNT || resolved.startsWith(`${AGENT_MOUNT}/`)) mount = \"agent\";\n\telse if (resolved === SESSION_MOUNT || resolved.startsWith(`${SESSION_MOUNT}/`)) mount = \"session\";\n\treturn {\n\t\tpath: resolved,\n\t\tdisplayPath: resolved,\n\t\tmount\n\t};\n}\n//#endregion\n//#region src/define-tool.ts\n/**\n* Identity helper for authoring agent tools. Generic over the parameter schema\n* so `execute`'s `params` is inferred as `Static<typeof parameters>` — no cast\n* needed inside `execute`.\n*/\nfunction defineTool(tool) {\n\treturn tool;\n}\n//#endregion\n//#region src/tools/helpers/format-exec.ts\nfunction formatExecResult(result) {\n\tconst parts = [];\n\tif (result.stdout) parts.push(result.stdout);\n\tif (result.stderr) parts.push(result.stderr);\n\tif (result.exitCode !== 0) parts.push(`[exit ${result.exitCode}]`);\n\treturn parts.join(\"\\n\").trim() || \"(no output)\";\n}\n//#endregion\n//#region src/tools/bash-tool.ts\nfunction createBashTool(runtime, options = {}) {\n\treturn defineTool({\n\t\tname: \"bash\",\n\t\tlabel: \"Bash\",\n\t\tdescription: [\n\t\t\t\"Run bash in the agent sandbox (cwd /workspace).\",\n\t\t\t\"Use session/ for session scratch and agent/ for persistent cross-session files.\",\n\t\t\t\"Prefer read, write, and edit for file operations.\",\n\t\t\t\"Use bash for grep, find, ls, jq, and shell pipelines.\",\n\t\t\toptions.codemode ?? true ? \"Use js-exec for JavaScript/TypeScript scripts; call host tools from scripts via tools.<toolName>(args).\" : \"Use node or python via bash for scripts when needed.\"\n\t\t].join(\" \"),\n\t\tparameters: Type.Object({ command: Type.String({ description: \"Bash script or command to run in the sandbox\" }) }, { additionalProperties: false }),\n\t\tasync execute(_id, params) {\n\t\t\tconst { command } = params;\n\t\t\tconst result = await runtime.exec(command);\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: formatExecResult(result)\n\t\t\t\t}],\n\t\t\t\tdetails: result\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/helpers/edit-apply.ts\nfunction applyEditsToOriginal(content, edits) {\n\tif (edits.length === 0) throw new Error(\"edits must contain at least one replacement\");\n\tconst ranges = [];\n\tfor (const edit of edits) {\n\t\tconst start = content.indexOf(edit.oldText);\n\t\tif (start === -1) throw new Error(\"oldText not found in file\");\n\t\tif (content.indexOf(edit.oldText, start + edit.oldText.length) !== -1) throw new Error(\"oldText must be unique in file\");\n\t\tranges.push({\n\t\t\tstart,\n\t\t\tend: start + edit.oldText.length,\n\t\t\tnewText: edit.newText\n\t\t});\n\t}\n\tconst sorted = [...ranges].sort((a, b) => a.start - b.start);\n\tfor (let i = 1; i < sorted.length; i++) {\n\t\tconst prev = sorted[i - 1];\n\t\tif (sorted[i].start < prev.end) throw new Error(\"edits must not overlap\");\n\t}\n\tlet result = \"\";\n\tlet cursor = 0;\n\tfor (const range of sorted) {\n\t\tresult += content.slice(cursor, range.start);\n\t\tresult += range.newText;\n\t\tcursor = range.end;\n\t}\n\tresult += content.slice(cursor);\n\treturn result;\n}\n//#endregion\n//#region src/tools/edit-tool.ts\nconst replaceEditSchema = Type.Object({\n\toldText: Type.String({ description: \"Exact text to replace. Must be unique in the file and must not overlap other edits in this call.\" }),\n\tnewText: Type.String({ description: \"Replacement text\" })\n}, { additionalProperties: false });\nconst editSchema = Type.Object({\n\tpath: Type.String({ description: \"Path under /workspace (e.g. session/out.txt or agent/data.json)\" }),\n\tedits: Type.Array(replaceEditSchema, { description: \"Replacements applied against the original file (not chained). Each oldText must be unique and non-overlapping.\" })\n}, { additionalProperties: false });\nfunction createEditTool(runtime) {\n\treturn defineTool({\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription: \"Edit a file under /workspace using exact text replacement. Unprefixed paths resolve under session/; prefix agent/ for cross-session files. Each edits[].oldText must match the original file uniquely. Merge nearby changes into one edit when possible.\",\n\t\tparameters: editSchema,\n\t\tasync execute(_id, params, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst { path, edits } = params;\n\t\t\tconst { path: filePath, displayPath } = normalizeWorkspacePath(path);\n\t\t\tconst updated = applyEditsToOriginal(await runtime.readFile(filePath), edits);\n\t\t\tawait runtime.writeFile(filePath, updated);\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Successfully replaced ${edits.length} block(s) in ${displayPath}`\n\t\t\t\t}],\n\t\t\t\tdetails: {\n\t\t\t\t\tpath: displayPath,\n\t\t\t\t\teditCount: edits.length\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/helpers/truncate.ts\nconst DEFAULT_MAX_LINES = 2e3;\nconst DEFAULT_MAX_BYTES = 256 * 1024;\nfunction truncateHead(text, maxLines = DEFAULT_MAX_LINES, maxBytes = DEFAULT_MAX_BYTES) {\n\tconst lines = text.split(\"\\n\");\n\tconst totalLines = lines.length;\n\tlet truncatedBy;\n\tlet sliceEnd = lines.length;\n\tif (lines.length > maxLines) {\n\t\tsliceEnd = maxLines;\n\t\ttruncatedBy = \"lines\";\n\t}\n\tlet content = lines.slice(0, sliceEnd).join(\"\\n\");\n\tconst buf = Buffer.from(content, \"utf-8\");\n\tif (buf.byteLength > maxBytes) {\n\t\tcontent = buf.subarray(0, maxBytes).toString(\"utf-8\");\n\t\ttruncatedBy = \"bytes\";\n\t}\n\tconst outputLines = content.split(\"\\n\").length;\n\treturn {\n\t\tcontent,\n\t\ttruncated: truncatedBy !== void 0,\n\t\toutputLines,\n\t\ttotalLines,\n\t\ttruncatedBy\n\t};\n}\n//#endregion\n//#region src/tools/read-tool.ts\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path under /workspace (e.g. session/out.txt or agent/data.json)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" }))\n});\nfunction createReadTool(runtime) {\n\treturn defineTool({\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read a file under /workspace. Unprefixed paths resolve under session/; prefix agent/ for cross-session files. Text is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB. Use offset/limit to continue. Prefer read over cat.`,\n\t\tparameters: readSchema,\n\t\tasync execute(_id, params, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst { path, offset, limit } = params;\n\t\t\tconst { path: filePath, displayPath } = normalizeWorkspacePath(path);\n\t\t\tconst allLines = (await runtime.readFile(filePath)).split(\"\\n\");\n\t\t\tconst startLine = offset ? Math.max(0, offset - 1) : 0;\n\t\t\tif (startLine >= allLines.length) throw new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);\n\t\t\tlet selected;\n\t\t\tif (limit !== void 0) {\n\t\t\t\tconst endLine = Math.min(startLine + limit, allLines.length);\n\t\t\t\tselected = allLines.slice(startLine, endLine).join(\"\\n\");\n\t\t\t} else selected = allLines.slice(startLine).join(\"\\n\");\n\t\t\tconst truncation = truncateHead(selected);\n\t\t\tlet output = truncation.content;\n\t\t\tconst startDisplay = startLine + 1;\n\t\t\tif (truncation.truncated) {\n\t\t\t\tconst nextOffset = startDisplay + truncation.outputLines;\n\t\t\t\toutput += `\\n\\n[Truncated. Use offset=${nextOffset} on ${displayPath} to continue.]`;\n\t\t\t} else if (limit !== void 0 && startLine + limit < allLines.length) {\n\t\t\t\tconst nextOffset = startLine + limit + 1;\n\t\t\t\toutput += `\\n\\n[More lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: output\n\t\t\t\t}],\n\t\t\t\tdetails: {\n\t\t\t\t\tpath: displayPath,\n\t\t\t\t\ttruncation\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/write-tool.ts\nconst writeSchema = Type.Object({\n\tpath: Type.String({ description: \"Path under /workspace (e.g. session/out.txt or agent/data.json)\" }),\n\tcontent: Type.String({ description: \"Content to write to the file\" })\n});\nfunction createWriteTool(runtime) {\n\treturn defineTool({\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription: \"Write content to a file under /workspace. Unprefixed paths go to session/; prefix agent/ for cross-session persistence. Creates parent directories if needed. Overwrites existing files. Use write for new files or full rewrites; use edit for partial changes.\",\n\t\tparameters: writeSchema,\n\t\tasync execute(_id, params, signal) {\n\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\tconst { path, content } = params;\n\t\t\tconst { path: filePath, displayPath } = normalizeWorkspacePath(path);\n\t\t\tawait runtime.writeFile(filePath, content);\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: `Successfully wrote ${content.length} bytes to ${displayPath}`\n\t\t\t\t}],\n\t\t\t\tdetails: { path: displayPath }\n\t\t\t};\n\t\t}\n\t});\n}\n//#endregion\n//#region src/tools/create-coding-tools.ts\nfunction createCodingTools(runtime, options = {}) {\n\tconst codemode = options.codemode ?? true;\n\treturn [\n\t\tcreateReadTool(runtime),\n\t\tcreateWriteTool(runtime),\n\t\tcreateEditTool(runtime),\n\t\tcreateBashTool(runtime, { codemode })\n\t];\n}\n//#endregion\nexport { WORKSPACE_MOUNT as a, SESSION_MOUNT as i, defineTool as n, AGENT_MOUNT as r, createCodingTools as t };\n\n//# sourceMappingURL=create-coding-tools-d9-WzxBW.mjs.map","import{createRequire} from\"node:module\";const require=createRequire(import.meta.url);\nimport{B as on,C as an,D as de,E as et,F as se,G as ke,H as Kt,I as ln,J as L,K as cn,L as un,M as xe,N as Us,O as Xt,P as H,a as Yr,b as Ms,c as Qr,d as qt,e as ee,f as B,g as fe,h as ne,i as Oe,j as He,k as Ws,l as Gt,m as Jr,n as zs,o as en,p as Ee,q as We,r as tn,s as sn,t as Vs,u as Bs,v as Ze,w as rn,x as nn,y as Ae,z as js}from\"./chunks/chunk-G5EVRAOO.js\";import{a as Fe,b as Me,c as be}from\"./chunks/chunk-WNH3HOQA.js\";import{c as Fs}from\"./chunks/chunk-HBVMHTO5.js\";import{a as Mt,b as Wt}from\"./chunks/chunk-XRFHFXFP.js\";import{a as Ls}from\"./chunks/chunk-L2UW7DWF.js\";import{a as Ue,b as ve,c as Ct}from\"./chunks/chunk-DLL7UR66.js\";import{a as _t,b as Xr}from\"./chunks/chunk-L64BMZUV.js\";import{a as Ve,b as me}from\"./chunks/chunk-TN7HHBQW.js\";import{a as kt}from\"./chunks/chunk-4RUAZWKT.js\";import{a as At,b as zt,c as io,d as Be,e as oo,f as Vt,g as ao,h as Bt,i as lo,j as co}from\"./chunks/chunk-NRSASXYY.js\";import{a as ye,b as ge,c as ue,d as we,e as Gr,f as j,g as Je,h as jt,i as Ut,j as Kr,k as J,l as Ht,m as je,n as Zt,o as Pe}from\"./chunks/chunk-SAI2SPQQ.js\";import\"./chunks/chunk-STHBFACM.js\";import{a as Le}from\"./chunks/chunk-FOCWZZDE.js\";import{a as Ie}from\"./chunks/chunk-W5DWRFSU.js\";import{a as Is}from\"./chunks/chunk-BZUGFHVS.js\";var tt=[{name:\"echo\",load:async()=>(await import(\"./chunks/echo-NDWZZHPO.js\")).echoCommand},{name:\"cat\",load:async()=>(await import(\"./chunks/cat-TSFMZVYS.js\")).catCommand},{name:\"printf\",load:async()=>(await import(\"./chunks/printf-TWGXF445.js\")).printfCommand},{name:\"ls\",load:async()=>(await import(\"./chunks/ls-ZJGQER7M.js\")).lsCommand},{name:\"mkdir\",load:async()=>(await import(\"./chunks/mkdir-MEPGZOB6.js\")).mkdirCommand},{name:\"rmdir\",load:async()=>(await import(\"./chunks/rmdir-OC4ZLPYA.js\")).rmdirCommand},{name:\"touch\",load:async()=>(await import(\"./chunks/touch-UA33VN3N.js\")).touchCommand},{name:\"rm\",load:async()=>(await import(\"./chunks/rm-SSGETQVQ.js\")).rmCommand},{name:\"cp\",load:async()=>(await import(\"./chunks/cp-BISAAS7A.js\")).cpCommand},{name:\"mv\",load:async()=>(await import(\"./chunks/mv-W5BIQ646.js\")).mvCommand},{name:\"ln\",load:async()=>(await import(\"./chunks/ln-4LGSXXGD.js\")).lnCommand},{name:\"chmod\",load:async()=>(await import(\"./chunks/chmod-TFEPA42X.js\")).chmodCommand},{name:\"pwd\",load:async()=>(await import(\"./chunks/pwd-WE6EN5AV.js\")).pwdCommand},{name:\"readlink\",load:async()=>(await import(\"./chunks/readlink-OPJF4DL5.js\")).readlinkCommand},{name:\"head\",load:async()=>(await import(\"./chunks/head-442HYESI.js\")).headCommand},{name:\"tail\",load:async()=>(await import(\"./chunks/tail-R4PCA2C4.js\")).tailCommand},{name:\"wc\",load:async()=>(await import(\"./chunks/wc-LF7NU4LA.js\")).wcCommand},{name:\"stat\",load:async()=>(await import(\"./chunks/stat-CD34IZ4P.js\")).statCommand},{name:\"grep\",load:async()=>(await import(\"./chunks/grep-V3LQVMRQ.js\")).grepCommand},{name:\"fgrep\",load:async()=>(await import(\"./chunks/grep-V3LQVMRQ.js\")).fgrepCommand},{name:\"egrep\",load:async()=>(await import(\"./chunks/grep-V3LQVMRQ.js\")).egrepCommand},{name:\"rg\",load:async()=>(await import(\"./chunks/rg-S4FXYXWB.js\")).rgCommand},{name:\"sed\",load:async()=>(await import(\"./chunks/sed-S5UIK574.js\")).sedCommand},{name:\"awk\",load:async()=>(await import(\"./chunks/awk2-LA3USKJP.js\")).awkCommand2},{name:\"sort\",load:async()=>(await import(\"./chunks/sort-SW2YEO5B.js\")).sortCommand},{name:\"uniq\",load:async()=>(await import(\"./chunks/uniq-XSIZR6PB.js\")).uniqCommand},{name:\"comm\",load:async()=>(await import(\"./chunks/comm-VV2LDX2J.js\")).commCommand},{name:\"cut\",load:async()=>(await import(\"./chunks/cut-OKARJCCV.js\")).cutCommand},{name:\"paste\",load:async()=>(await import(\"./chunks/paste-7JC6S4DX.js\")).pasteCommand},{name:\"tr\",load:async()=>(await import(\"./chunks/tr-36LHWFRQ.js\")).trCommand},{name:\"rev\",load:async()=>(await import(\"./chunks/rev-5EHFX4EJ.js\")).rev},{name:\"nl\",load:async()=>(await import(\"./chunks/nl-WSDW7I4O.js\")).nl},{name:\"fold\",load:async()=>(await import(\"./chunks/fold-4TQNYMSW.js\")).fold},{name:\"expand\",load:async()=>(await import(\"./chunks/expand-JSPG6VOP.js\")).expand},{name:\"unexpand\",load:async()=>(await import(\"./chunks/unexpand-CADSA4VO.js\")).unexpand},{name:\"strings\",load:async()=>(await import(\"./chunks/strings-6WDHLGMX.js\")).strings},{name:\"split\",load:async()=>(await import(\"./chunks/split-4KKZZXXE.js\")).split},{name:\"column\",load:async()=>(await import(\"./chunks/column-XT6UFXNQ.js\")).column},{name:\"join\",load:async()=>(await import(\"./chunks/join-TBRGI3LQ.js\")).join},{name:\"tee\",load:async()=>(await import(\"./chunks/tee-YUZ2FKCJ.js\")).teeCommand},{name:\"find\",load:async()=>(await import(\"./chunks/find-INTH3OLC.js\")).findCommand},{name:\"basename\",load:async()=>(await import(\"./chunks/basename-UB3CIYNI.js\")).basenameCommand},{name:\"dirname\",load:async()=>(await import(\"./chunks/dirname-MPHRFUTI.js\")).dirnameCommand},{name:\"tree\",load:async()=>(await import(\"./chunks/tree-YLD52CNT.js\")).treeCommand},{name:\"du\",load:async()=>(await import(\"./chunks/du-572XNP42.js\")).duCommand},{name:\"env\",load:async()=>(await import(\"./chunks/env-36M5BO7M.js\")).envCommand},{name:\"printenv\",load:async()=>(await import(\"./chunks/env-36M5BO7M.js\")).printenvCommand},{name:\"alias\",load:async()=>(await import(\"./chunks/alias-RTYYYW3D.js\")).aliasCommand},{name:\"unalias\",load:async()=>(await import(\"./chunks/alias-RTYYYW3D.js\")).unaliasCommand},{name:\"history\",load:async()=>(await import(\"./chunks/history-WYYKSLSZ.js\")).historyCommand},{name:\"xargs\",load:async()=>(await import(\"./chunks/xargs-MGZPH7AX.js\")).xargsCommand},{name:\"true\",load:async()=>(await import(\"./chunks/true-FHQXJXBE.js\")).trueCommand},{name:\"false\",load:async()=>(await import(\"./chunks/true-FHQXJXBE.js\")).falseCommand},{name:\"clear\",load:async()=>(await import(\"./chunks/clear-HKGFEOF6.js\")).clearCommand},{name:\"bash\",load:async()=>(await import(\"./chunks/bash-YZ33HQZQ.js\")).bashCommand},{name:\"sh\",load:async()=>(await import(\"./chunks/bash-YZ33HQZQ.js\")).shCommand},{name:\"jq\",load:async()=>(await import(\"./chunks/jq-4XLYLOS5.js\")).jqCommand},{name:\"base64\",load:async()=>(await import(\"./chunks/base64-C2AIWVNC.js\")).base64Command},{name:\"diff\",load:async()=>(await import(\"./chunks/diff-MWJFIG7X.js\")).diffCommand},{name:\"date\",load:async()=>(await import(\"./chunks/date-UUUPW43J.js\")).dateCommand},{name:\"sleep\",load:async()=>(await import(\"./chunks/sleep-X22JJINO.js\")).sleepCommand},{name:\"timeout\",load:async()=>(await import(\"./chunks/timeout-YDCRSLPQ.js\")).timeoutCommand},{name:\"time\",load:async()=>(await import(\"./chunks/time-D4LNBSWX.js\")).timeCommand},{name:\"seq\",load:async()=>(await import(\"./chunks/seq-M5EC7Q57.js\")).seqCommand},{name:\"expr\",load:async()=>(await import(\"./chunks/expr-5JAACS4X.js\")).exprCommand},{name:\"md5sum\",load:async()=>(await import(\"./chunks/md5sum-SPU24VSG.js\")).md5sumCommand},{name:\"sha1sum\",load:async()=>(await import(\"./chunks/sha1sum-2PTOAFR6.js\")).sha1sumCommand},{name:\"sha256sum\",load:async()=>(await import(\"./chunks/sha256sum-NS7D3IXX.js\")).sha256sumCommand},{name:\"file\",load:async()=>(await import(\"./chunks/file-IPZJC3FQ.js\")).fileCommand},{name:\"html-to-markdown\",load:async()=>(await import(\"./chunks/html-to-markdown-JW4MSQZO.js\")).htmlToMarkdownCommand},{name:\"help\",load:async()=>(await import(\"./chunks/help-HZ6M2CKN.js\")).helpCommand},{name:\"which\",load:async()=>(await import(\"./chunks/which-XEM24D5D.js\")).whichCommand},{name:\"tac\",load:async()=>(await import(\"./chunks/tac-2STMMJYW.js\")).tac},{name:\"hostname\",load:async()=>(await import(\"./chunks/hostname-C4HQXXUP.js\")).hostname},{name:\"whoami\",load:async()=>(await import(\"./chunks/whoami-XMTX52VE.js\")).whoami},{name:\"od\",load:async()=>(await import(\"./chunks/od-WOKFDJTP.js\")).od},{name:\"gzip\",load:async()=>(await import(\"./chunks/gzip-O5ASJAFY.js\")).gzipCommand},{name:\"gunzip\",load:async()=>(await import(\"./chunks/gzip-O5ASJAFY.js\")).gunzipCommand},{name:\"zcat\",load:async()=>(await import(\"./chunks/gzip-O5ASJAFY.js\")).zcatCommand}];(typeof __BROWSER__>\"u\"||!__BROWSER__)&&(tt.push({name:\"tar\",load:async()=>(await import(\"./chunks/tar-STHHZTZ6.js\")).tarCommand}),tt.push({name:\"yq\",load:async()=>(await import(\"./chunks/yq-4QJW3EQG.js\")).yqCommand}),tt.push({name:\"xan\",load:async()=>(await import(\"./chunks/xan-Y6WF3IRG.js\")).xanCommand}),tt.push({name:\"sqlite3\",load:async()=>(await import(\"./chunks/sqlite3-CGOEFJAO.js\")).sqlite3Command}));var Yt=[];(typeof __BROWSER__>\"u\"||!__BROWSER__)&&(Yt.push({name:\"python3\",load:async()=>(await import(\"./chunks/python3-POMOR4OA.js\")).python3Command}),Yt.push({name:\"python\",load:async()=>(await import(\"./chunks/python3-POMOR4OA.js\")).pythonCommand}));var Qt=[];(typeof __BROWSER__>\"u\"||!__BROWSER__)&&(Qt.push({name:\"js-exec\",load:async()=>(await import(\"./chunks/js-exec-N5KEZBH7.js\")).jsExecCommand}),Qt.push({name:\"node\",load:async()=>(await import(\"./chunks/js-exec-N5KEZBH7.js\")).nodeStubCommand}));var dn=[{name:\"curl\",load:async()=>(await import(\"./chunks/curl-LV5Y3AMS.js\")).curlCommand}],fn=new Map;function Jt(e){return{name:e.name,async execute(t,s){let r=fn.get(e.name);if(r||(r=await me.runTrustedAsync(()=>e.load()),fn.set(e.name,r)),s.coverage&&(typeof __BROWSER__>\"u\"||!__BROWSER__)){let{emitFlagCoverage:n}=await import(\"./chunks/flag-coverage-XWSYNE72.js\");n(s.coverage,e.name,t)}return r.execute(t,s)}}}function uo(){return tt.map(e=>e.name)}function fo(){return dn.map(e=>e.name)}function hn(e){return(e?tt.filter(s=>e.includes(s.name)):tt).map(Jt)}function pn(){return dn.map(Jt)}function ho(){return Yt.map(e=>e.name)}function mn(){return Yt.map(Jt)}function po(){return Qt.map(e=>e.name)}function yn(){return Qt.map(Jt)}function gn(e){return\"load\"in e&&typeof e.load==\"function\"}function mo(e,t){return{name:e,trusted:!0,execute:t}}function wn(e){let t=null;return{name:e.name,trusted:!0,async execute(s,r){return t||(t=await e.load()),t.execute(s,r)}}}function O(e){if(!e||e===\"/\")return\"/\";let t=e.endsWith(\"/\")&&e!==\"/\"?e.slice(0,-1):e;t.startsWith(\"/\")||(t=`/${t}`);let s=t.split(\"/\").filter(n=>n&&n!==\".\"),r=[];for(let n of s)n===\"..\"?r.pop():r.push(n);return`/${r.join(\"/\")}`||\"/\"}function x(e,t){if(e.includes(\"\\0\"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}function st(e){let t=O(e);if(t===\"/\")return\"/\";let s=t.lastIndexOf(\"/\");return s===0?\"/\":t.slice(0,s)}function qe(e,t){if(t.startsWith(\"/\"))return O(t);let s=e===\"/\"?`/${t}`:`${e}/${t}`;return O(s)}function Ge(e,t){return e===\"/\"?`/${t}`:`${e}/${t}`}function ct(e,t){if(t.startsWith(\"/\"))return O(t);let s=st(e);return O(Ge(s,t))}var ut=new TextEncoder;function yo(e){return typeof e==\"object\"&&e!==null&&!(e instanceof Uint8Array)&&\"content\"in e}var ze=class{data=new Map;constructor(t){if(this.data.set(\"/\",{type:\"directory\",mode:493,mtime:new Date}),t)for(let[s,r]of Object.entries(t))typeof r==\"function\"?this.writeFileLazy(s,r):yo(r)?this.writeFileSync(s,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(s,r)}ensureParentDirs(t){let s=st(t);s!==\"/\"&&(this.data.has(s)||(this.ensureParentDirs(s),this.data.set(s,{type:\"directory\",mode:493,mtime:new Date})))}writeFileSync(t,s,r,n){x(t,\"write\");let i=O(t);this.ensureParentDirs(i);let o=be(r),a=Fe(s,o);this.data.set(i,{type:\"file\",content:a,mode:n?.mode??420,mtime:n?.mtime??new Date})}writeFileLazy(t,s,r){x(t,\"write\");let n=O(t);this.ensureParentDirs(n),this.data.set(n,{type:\"file\",lazy:s,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,s){let r=await s.lazy(),i={type:\"file\",content:typeof r==\"string\"?ut.encode(r):r,mode:s.mode,mtime:s.mtime};return this.data.set(t,i),i}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,\"binary\")}async readFileBuffer(t){x(t,\"open\");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);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}'`);if(\"lazy\"in r){let n=await this.materializeLazy(s,r);return n.content instanceof Uint8Array?n.content:ut.encode(n.content)}return r.content instanceof Uint8Array?r.content:ut.encode(r.content)}async writeFile(t,s,r){this.writeFileSync(t,s,r)}async appendFile(t,s,r){x(t,\"append\");let n=O(t),i=this.data.get(n);if(i&&i.type===\"directory\")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=be(r),a=Fe(s,o);if(i?.type===\"file\"){let l=i;\"lazy\"in l&&(l=await this.materializeLazy(n,l));let c=\"content\"in l&&l.content instanceof Uint8Array?l.content:ut.encode(\"content\"in l?l.content:\"\"),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(n,{type:\"file\",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(t,s,r)}async exists(t){if(t.includes(\"\\0\"))return!1;try{let s=this.resolvePathWithSymlinks(t);return this.data.has(s)}catch{return!1}}async stat(t){x(t,\"stat\");let s=this.resolvePathWithSymlinks(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);r.type===\"file\"&&\"lazy\"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type===\"file\"&&\"content\"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type===\"file\",isDirectory:r.type===\"directory\",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}async lstat(t){x(t,\"lstat\");let s=this.resolveIntermediateSymlinks(t),r=this.data.get(s);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};r.type===\"file\"&&\"lazy\"in r&&(r=await this.materializeLazy(s,r));let n=0;return r.type===\"file\"&&\"content\"in r&&r.content&&(r.content instanceof Uint8Array?n=r.content.length:n=ut.encode(r.content).length),{isFile:r.type===\"file\",isDirectory:r.type===\"directory\",isSymbolicLink:!1,mode:r.mode,size:n,mtime:r.mtime||new Date}}resolveIntermediateSymlinks(t){let s=O(t);if(s===\"/\")return\"/\";let r=s.slice(1).split(\"/\");if(r.length<=1)return s;let n=\"\",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];n=`${n}/${a}`;let l=this.data.get(n),c=0,u=40;for(;l&&l.type===\"symlink\"&&c<u;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(n),n=ct(n,l.target),l=this.data.get(n),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${n}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let s=O(t);if(s===\"/\")return\"/\";let r=s.slice(1).split(\"/\"),n=\"\",i=new Set;for(let o of r){n=`${n}/${o}`;let a=this.data.get(n),l=0,c=40;for(;a&&a.type===\"symlink\"&&l<c;){if(i.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(n),n=ct(n,a.target),a=this.data.get(n),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return n}async mkdir(t,s){this.mkdirSync(t,s)}mkdirSync(t,s){x(t,\"mkdir\");let r=O(t);if(this.data.has(r)){if(this.data.get(r)?.type===\"file\")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!s?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let n=st(r);if(n!==\"/\"&&!this.data.has(n))if(s?.recursive)this.mkdirSync(n,{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){x(t,\"scandir\");let s=O(t),r=this.data.get(s);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let n=new Set;for(;r&&r.type===\"symlink\";){if(n.has(s))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(s),s=ct(s,r.target),r=this.data.get(s)}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=s===\"/\"?\"/\":`${s}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==s&&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,s){x(t,\"rm\");let r=O(t),n=this.data.get(r);if(!n){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(n.type===\"directory\"){let i=await this.readdir(r);if(i.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=Ge(r,o);await this.rm(a,s)}}}this.data.delete(r)}async cp(t,s,r){x(t,\"cp\"),x(s,\"cp\");let n=O(t),i=O(s),o=this.data.get(n);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type===\"file\")if(this.ensureParentDirs(i),\"content\"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type===\"symlink\")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(n);for(let l of a){let c=Ge(n,l),u=Ge(i,l);await this.cp(c,u,r)}}}async mv(t,s){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,s){return qe(t,s)}async chmod(t,s){x(t,\"chmod\");let r=O(t),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);n.mode=s}async symlink(t,s){x(s,\"symlink\");let r=O(s);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.data.set(r,{type:\"symlink\",target:t,mode:511,mtime:new Date})}async link(t,s){x(t,\"link\"),x(s,\"link\");let r=O(t),n=O(s),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(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let o=i;\"lazy\"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(n),this.data.set(n,{type:\"file\",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(t){x(t,\"readlink\");let s=O(t),r=this.data.get(s);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){x(t,\"realpath\");let s=this.resolvePathWithSymlinks(t);if(!this.data.has(s))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return s}async utimes(t,s,r){x(t,\"utimes\");let n=O(t),i=this.resolvePathWithSymlinks(n),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};function go(e){let t=e;return typeof t.mkdirSync==\"function\"&&typeof t.writeFileSync==\"function\"}function wo(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 vo(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 bo(e,t){e.mkdirSync(\"/proc/self/fd\",{recursive:!0}),e.writeFileSync(\"/proc/version\",`${Yr}\n`),e.writeFileSync(\"/proc/self/exe\",\"/bin/bash\"),e.writeFileSync(\"/proc/self/cmdline\",\"bash\\0\"),e.writeFileSync(\"/proc/self/comm\",`bash\n`),e.writeFileLazy?e.writeFileLazy(\"/proc/self/status\",()=>Ms(t)):e.writeFileSync(\"/proc/self/status\",Ms(t)),e.writeFileSync(\"/proc/self/fd/0\",\"/dev/stdin\"),e.writeFileSync(\"/proc/self/fd/1\",\"/dev/stdout\"),e.writeFileSync(\"/proc/self/fd/2\",\"/dev/stderr\")}function vn(e,t,s={pid:1,ppid:0,uid:1e3,gid:1e3}){go(e)&&(wo(e,t),vo(e),bo(e,s))}var Eo=[\"allexport\",\"errexit\",\"noglob\",\"noclobber\",\"noexec\",\"nounset\",\"pipefail\",\"posix\",\"verbose\",\"xtrace\"],$o=[\"braceexpand\",\"hashall\",\"interactive-comments\"];function Zs(e){let t=[],s=[...$o.map(r=>({name:r,enabled:!0})),...Eo.map(r=>({name:r,enabled:e[r]}))].sort((r,n)=>r.name.localeCompare(n.name));for(let r of s)r.enabled&&t.push(r.name);return t.join(\":\")}function dt(e){e.state.env.set(\"SHELLOPTS\",Zs(e.state.options))}var So=[\"dotglob\",\"expand_aliases\",\"extglob\",\"failglob\",\"globskipdots\",\"globstar\",\"lastpipe\",\"nocaseglob\",\"nocasematch\",\"nullglob\",\"xpg_echo\"];function qs(e){let t=[];for(let s of So)e[s]&&t.push(s);return t.join(\":\")}function Gs(e){e.state.env.set(\"BASHOPTS\",qs(e.state.shoptOptions))}var Po=\"BASH_ALIAS_\";function bn(e){return e.parts.length!==1?!1:e.parts[0].type===\"Literal\"}function En(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type===\"Literal\"?t.value:null}function $n(e,t){return e.env.get(`${Po}${t}`)}function Ks(e,t,s){if(!t.name||!bn(t.name))return t;let r=En(t.name);if(!r)return t;let n=$n(e,r);if(!n||s.has(r))return t;try{s.add(r);let i=new B,o=n,a=n.endsWith(\" \");if(!a)for(let f of t.args){let d=Pn(f);o+=` ${d}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof qt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Sn(t,n);let c=l.statements[0].pipelines[0].commands[0];if(c.type!==\"SimpleCommand\")return Sn(t,n);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(bn(f)){let d=En(f);if(d&&$n(e,d)){let p={type:\"SimpleCommand\",name:f,args:u.args.slice(1),assignments:[],redirections:[]},y=Ks(e,p,s);y!==p&&(u={...u,name:y.name,args:[...y.args]})}}}return u}catch(i){throw s.delete(r),i}}function Sn(e,t){let s=t;for(let o of e.args){let a=Pn(o);s+=` ${a}`}let r=new B,n=r.parseWordFromString(\"eval\",!1,!1),i=r.parseWordFromString(`'${s.replace(/'/g,\"'\\\\''\")}'`,!1,!1);return{type:\"SimpleCommand\",name:n,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Pn(e){let t=\"\";for(let s of e.parts)switch(s.type){case\"Literal\":t+=s.value.replace(/([\\s\"'$`\\\\*?[\\]{}()<>|&;#!])/g,\"\\\\$1\");break;case\"SingleQuoted\":t+=`'${s.value}'`;break;case\"DoubleQuoted\":t+=`\"${s.parts.map(r=>r.type===\"Literal\"?r.value:`$${r.type}`).join(\"\")}\"`;break;case\"ParameterExpansion\":t+=`\\${${s.parameter}}`;break;case\"CommandSubstitution\":t+=\"$(...)\";break;case\"ArithmeticExpansion\":t+=`$((${s.expression}))`;break;case\"Glob\":t+=s.pattern;break;default:break}return t}async function An(e,t){let s=t.parts.map(u=>u.type===\"Literal\"?u.value:\"\\0\").join(\"\"),r=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\(/);if(!r||!s.endsWith(\")\"))return null;let n=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 d=f.indexOf(\"=(\");d!==-1&&(o=!0,f=f.slice(d+2))}if(o){f.endsWith(\")\")&&(f=f.slice(0,-1));let d=f.split(/(\\s+)/);for(let p of d)/^\\s+$/.test(p)?(a||l)&&(i.push(a),a=\"\",l=!1):p&&(a+=p)}}else if(o)if(u.type===\"BraceExpansion\")if(/^\\[.+\\]=/.test(a))a+=Gt({type:\"Word\",parts:[u]});else{(a||l)&&(i.push(a),a=\"\",l=!1);let d=await xe(e,{type:\"Word\",parts:[u]});i.push(...d.values)}else{(u.type===\"SingleQuoted\"||u.type===\"DoubleQuoted\"||u.type===\"Escaped\")&&(l=!0);let f=await L(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`${n}=(${c.join(\" \")})`}async function kn(e,t){let s=-1,r=-1,n=!1;for(let h=0;h<t.parts.length;h++){let w=t.parts[h];if(w.type===\"Literal\"){let E=w.value.indexOf(\"+=\");if(E!==-1){let b=w.value.slice(0,E);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){s=h,r=E,n=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\\[[^\\]]+\\]$/.test(b)){s=h,r=E,n=!0;break}}let g=w.value.indexOf(\"=\");if(g!==-1&&(g===0||w.value[g-1]!==\"+\")){let b=w.value.slice(0,g);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\\[[^\\]]+\\]$/.test(b)){s=h,r=g;break}}}}if(s===-1)return null;let i=t.parts.slice(0,s),o=t.parts[s];if(o.type!==\"Literal\")return null;let a=n?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(s+1),f=\"\";for(let h of i)f+=await L(e,{type:\"Word\",parts:[h]});f+=l;let d={type:\"Word\",parts:c!==\"\"?[{type:\"Literal\",value:c},...u]:u},p=d.parts.length>0?await L(e,d):\"\";return`${f}${n?\"+=\":\"=\"}${p}`}var Ao=[\"tar\",\"yq\",\"xan\",\"sqlite3\",\"python3\",\"python\"];function _n(e){return Ao.includes(e)}var W=Object.freeze({stdout:\"\",stderr:\"\",exitCode:0});function z(e=\"\"){return{stdout:e,stderr:\"\",exitCode:0}}function A(e,t=1){return{stdout:\"\",stderr:e,exitCode:t}}function _(e,t,s){return{stdout:e,stderr:t,exitCode:s}}function Q(e){return{stdout:\"\",stderr:\"\",exitCode:e?0:1}}function Te(e,t,s=\"\",r=\"\"){throw new J(e,t,s,r)}function le(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new J(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,\"file_descriptors\")}function Xs(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new je;return W}if(t.length>1)throw new j(1,\"\",`bash: break: too many arguments\n`);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new j(128,\"\",`bash: break: ${t[0]}: numeric argument required\n`);s=r}throw new ye(s)}async function Ys(e,t){let s,r=!1,n=!1,i=0;for(;i<t.length;)if(t[i]===\"--\"){i++;break}else if(t[i]===\"-L\")n=!1,i++;else if(t[i]===\"-P\")n=!0,i++;else if(t[i].startsWith(\"-\")&&t[i]!==\"-\")i++;else break;let o=t.slice(i);if(o.length===0||o[0]===\"~\"?s=e.state.env.get(\"HOME\")||\"/\":o[0]===\"-\"?(s=e.state.previousDir,r=!0):s=o[0],!s.startsWith(\"/\")&&!s.startsWith(\"./\")&&!s.startsWith(\"../\")&&s!==\".\"&&s!==\"..\"){let f=e.state.env.get(\"CDPATH\");if(f){let d=f.split(\":\").filter(p=>p);for(let p of d){let y=p.startsWith(\"/\")?`${p}/${s}`:`${e.state.cwd}/${p}/${s}`;try{if((await e.fs.stat(y)).isDirectory){s=y,r=!0;break}}catch{}}}}let l=(s.startsWith(\"/\")?s:`${e.state.cwd}/${s}`).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 A(`bash: cd: ${s}: Not a directory\n`)}catch{return A(`bash: cd: ${s}: No such file or directory\n`)}}let u=c||\"/\";if(n)try{u=await e.fs.realpath(u)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=u,e.state.env.set(\"PWD\",e.state.cwd),e.state.env.set(\"OLDPWD\",e.state.previousDir),z(r?`${u}\n`:\"\")}function Qs(e,t){return e.fs.resolvePath(e.state.cwd,t)}var ko=[\"-e\",\"-a\",\"-f\",\"-d\",\"-r\",\"-w\",\"-x\",\"-s\",\"-L\",\"-h\",\"-k\",\"-g\",\"-u\",\"-G\",\"-O\",\"-b\",\"-c\",\"-p\",\"-S\",\"-t\",\"-N\"];function ts(e){return ko.includes(e)}async function ss(e,t,s){let r=Qs(e,s);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\"].includes(r);case\"-p\":return!1;case\"-S\":return!1;case\"-t\":return!1;case\"-N\":return e.fs.exists(r);default:return!1}}var _o=[\"-nt\",\"-ot\",\"-ef\"];function rs(e){return _o.includes(e)}async function ns(e,t,s,r){let n=Qs(e,s),i=Qs(e,r);switch(t){case\"-nt\":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case\"-ot\":try{let o=await e.fs.stat(n),a=await e.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case\"-ef\":try{if(!await e.fs.exists(n)||!await e.fs.exists(i))return!1;let o=e.fs.resolvePath(e.state.cwd,n),a=e.fs.resolvePath(e.state.cwd,i);return o===a}catch{return!1}default:return!1}}var Co=new Set([\"-eq\",\"-ne\",\"-lt\",\"-le\",\"-gt\",\"-ge\"]);function is(e){return Co.has(e)}function os(e,t,s){switch(e){case\"-eq\":return t===s;case\"-ne\":return t!==s;case\"-lt\":return t<s;case\"-le\":return t<=s;case\"-gt\":return t>s;case\"-ge\":return t>=s}}function Nt(e){return e===\"=\"||e===\"==\"||e===\"!=\"}function as(e,t,s,r=!1,n=!1,i=!1){if(r){let a=ht(t,s,n,i);return e===\"!=\"?!a:a}if(n){let a=t.toLowerCase()===s.toLowerCase();return e===\"!=\"?!a:a}let o=t===s;return e===\"!=\"?!o:o}var No=new Set([\"-z\",\"-n\"]);function ls(e){return No.has(e)}function cs(e,t){switch(e){case\"-z\":return t===\"\";case\"-n\":return t!==\"\"}}async function us(e,t){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(s){let r=s[1],n=s[2];if(e.state.associativeArrays?.has(r)){let a=n;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.get(c)||\"\"),e.state.env.has(`${r}_${a}`)}let o;try{let a=new B,l=ee(a,n);o=await H(e,l.expression)}catch{if(/^-?\\d+$/.test(n))o=Number.parseInt(n,10);else{let a=e.state.env.get(n);o=a?Number.parseInt(a,10):0}}if(o<0){let a=ne(e,r),l=e.state.currentLine;if(a.length===0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${l}: ${r}: bad array subscript\n`,!1;if(o=Math.max(...a)+1+o,o<0)return e.state.expansionStderr=(e.state.expansionStderr||\"\")+`bash: line ${l}: ${r}: bad array subscript\n`,!1}return e.state.env.has(`${r}_${o}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?He(e,t).length>0:ne(e,t).length>0}async function Ke(e,t){switch(t.type){case\"CondBinary\":{let s=await L(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!==\"=~\"),n;if(t.operator===\"=~\")if(r){let i=await L(e,t.right);n=an(i)}else n=await cn(e,t.right);else Nt(t.operator)&&!r?n=await un(e,t.right):n=await L(e,t.right);if(Nt(t.operator)){let i=e.state.shoptOptions.nocasematch;return as(t.operator,s,n,!r,i,!0)}if(is(t.operator))return os(t.operator,await Nn(e,s),await Nn(e,n));if(rs(t.operator))return ns(e,t.operator,s,n);switch(t.operator){case\"=~\":try{let i=e.state.shoptOptions.nocasematch,o=Do(n),l=kt(o,i?\"i\":\"\").match(s);if(Oe(e,\"BASH_REMATCH\"),l)for(let c=0;c<l.length;c++)e.state.env.set(`BASH_REMATCH_${c}`,l[c]||\"\");return l!==null}catch{throw new Error(\"syntax error in regular expression\")}case\"<\":return s<n;case\">\":return s>n;default:return!1}}case\"CondUnary\":{let s=await L(e,t.operand);return ts(t.operator)?ss(e,t.operator,s):ls(t.operator)?cs(t.operator,s):t.operator===\"-v\"?await us(e,s):t.operator===\"-o\"?er(e,s):!1}case\"CondNot\":return e.state.shoptOptions.extglob&&t.operand.type===\"CondGroup\"&&t.operand.expression.type===\"CondWord\"?`!(${await L(e,t.operand.expression.word)})`!==\"\":!await Ke(e,t.operand);case\"CondAnd\":return await Ke(e,t.left)?await Ke(e,t.right):!1;case\"CondOr\":return await Ke(e,t.left)?!0:await Ke(e,t.right);case\"CondGroup\":return await Ke(e,t.expression);case\"CondWord\":return await L(e,t.word)!==\"\";default:return!1}}async function Ot(e,t){if(t.length===0)return _(\"\",\"\",1);if(t.length===1)return Q(!!t[0]);if(t.length===2){let r=t[0],n=t[1];return r===\"(\"?A(`test: '(' without matching ')'\n`,2):ts(r)?Q(await ss(e,r,n)):ls(r)?Q(cs(r,n)):r===\"!\"?Q(!n):r===\"-v\"?Q(await us(e,n)):r===\"-o\"?Q(er(e,n)):r===\"=\"||r===\"==\"||r===\"!=\"||r===\"<\"||r===\">\"||r===\"-eq\"||r===\"-ne\"||r===\"-lt\"||r===\"-le\"||r===\"-gt\"||r===\"-ge\"||r===\"-nt\"||r===\"-ot\"||r===\"-ef\"?A(`test: ${r}: unary operator expected\n`,2):_(\"\",\"\",1)}if(t.length===3){let r=t[0],n=t[1],i=t[2];if(Nt(n))return Q(as(n,r,i));if(is(n)){let o=fs(r),a=fs(i);return!o.valid||!a.valid?_(\"\",\"\",2):Q(os(n,o.value,a.value))}if(rs(n))return Q(await ns(e,n,r,i));switch(n){case\"-a\":return Q(r!==\"\"&&i!==\"\");case\"-o\":return Q(r!==\"\"||i!==\"\");case\">\":return Q(r>i);case\"<\":return Q(r<i)}if(r===\"!\"){let o=await Ot(e,[n,i]);return _(\"\",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r===\"(\"&&i===\")\")return Q(n!==\"\")}if(t.length===4){if(t[0]===\"!\"){let r=await Ot(e,t.slice(1));return _(\"\",r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]===\"(\"&&t[3]===\")\")return Ot(e,[t[1],t[2]])}let s=await xn(e,t,0);return s.pos<t.length?A(`test: too many arguments\n`,2):Q(s.value)}async function xn(e,t,s){return Oo(e,t,s)}async function Oo(e,t,s){let{value:r,pos:n}=await Cn(e,t,s);for(;t[n]===\"-o\";){let i=await Cn(e,t,n+1);r=r||i.value,n=i.pos}return{value:r,pos:n}}async function Cn(e,t,s){let{value:r,pos:n}=await Js(e,t,s);for(;t[n]===\"-a\";){let i=await Js(e,t,n+1);r=r&&i.value,n=i.pos}return{value:r,pos:n}}async function Js(e,t,s){if(t[s]===\"!\"){let{value:r,pos:n}=await Js(e,t,s+1);return{value:!r,pos:n}}return xo(e,t,s)}async function xo(e,t,s){let r=t[s];if(r===\"(\"){let{value:i,pos:o}=await xn(e,t,s+1);return{value:i,pos:t[o]===\")\"?o+1:o}}let n=t[s+1];if(Nt(n)){let i=r,o=t[s+2]??\"\";return{value:as(n,i,o),pos:s+3}}if(is(n)){let i=fs(r),o=fs(t[s+2]??\"0\");return!i.valid||!o.valid?{value:!1,pos:s+3}:{value:os(n,i.value,o.value),pos:s+3}}if(rs(n)){let i=r,o=t[s+2]??\"\";return{value:await ns(e,n,i,o),pos:s+3}}if(ts(r)){let i=t[s+1]??\"\";return{value:await ss(e,r,i),pos:s+2}}if(ls(r)){let i=t[s+1]??\"\";return{value:cs(r,i),pos:s+2}}if(r===\"-v\"){let i=t[s+1]??\"\";return{value:await us(e,i),pos:s+2}}if(r===\"-o\"){let i=t[s+1]??\"\";return{value:er(e,i),pos:s+2}}return{value:r!==void 0&&r!==\"\",pos:s+1}}function ht(e,t,s=!1,r=!1){let n=`^${Tn(t,r)}$`;return kt(n,s?\"is\":\"s\").test(e)}function Tn(e,t){let s=\"\";for(let r=0;r<e.length;r++){let n=e[r];if(t&&(n===\"@\"||n===\"*\"||n===\"+\"||n===\"?\"||n===\"!\")&&r+1<e.length&&e[r+1]===\"(\"){let i=Dn(e,r+1);if(i!==-1){let o=e.slice(r+2,i),a=Rn(o),l=a.map(u=>Tn(u,t)),c=l.length>0?l.join(\"|\"):\"(?:)\";if(n===\"@\")s+=`(?:${c})`;else if(n===\"*\")s+=`(?:${c})*`;else if(n===\"+\")s+=`(?:${c})+`;else if(n===\"?\")s+=`(?:${c})?`;else if(n===\"!\")if(i<e.length-1){let f=a.map(p=>In(p,t));if(f.every(p=>p!==null)&&f.every(p=>p===f[0])&&f[0]!==null){let p=f[0];if(p===0)s+=\"(?:.+)\";else{let y=[];p>0&&y.push(`.{0,${p-1}}`),y.push(`.{${p+1},}`),y.push(`(?!(?:${c})).{${p}}`),s+=`(?:${y.join(\"|\")})`}}else s+=`(?:(?!(?:${c})).)*?`}else s+=`(?!(?:${c})$).*`;r=i;continue}}if(n===\"\\\\\")if(r+1<e.length){let i=e[r+1];/[\\\\^$.|+(){}[\\]*?]/.test(i)?s+=`\\\\${i}`:s+=i,r++}else s+=\"\\\\\\\\\";else if(n===\"*\")s+=\".*\";else if(n===\"?\")s+=\".\";else if(n===\"[\"){let i=e.indexOf(\"]\",r+1);i!==-1?(s+=e.slice(r,i+1),r=i):s+=\"\\\\[\"}else/[\\\\^$.|+(){}]/.test(n)?s+=`\\\\${n}`:s+=n}return s}function Dn(e,t){let s=1,r=t+1;for(;r<e.length&&s>0;){let n=e[r];if(n===\"\\\\\"){r+=2;continue}if(n===\"(\")s++;else if(n===\")\"&&(s--,s===0))return r;r++}return-1}function Rn(e){let t=[],s=\"\",r=0,n=0;for(;n<e.length;){let i=e[n];if(i===\"\\\\\"){s+=i,n+1<e.length?(s+=e[n+1],n+=2):n++;continue}i===\"(\"?(r++,s+=i):i===\")\"?(r--,s+=i):i===\"|\"&&r===0?(t.push(s),s=\"\"):s+=i,n++}return t.push(s),t}function In(e,t){let s=0,r=0;for(;r<e.length;){let n=e[r];if(t&&(n===\"@\"||n===\"*\"||n===\"+\"||n===\"?\"||n===\"!\")&&r+1<e.length&&e[r+1]===\"(\"){let i=Dn(e,r+1);if(i!==-1){if(n===\"@\"){let o=e.slice(r+2,i),l=Rn(o).map(c=>In(c,t));if(l.every(c=>c!==null)&&l.every(c=>c===l[0])){s+=l[0],r=i+1;continue}return null}return null}}if(n===\"*\")return null;if(n===\"?\"){s+=1,r++;continue}if(n===\"[\"){let i=e.indexOf(\"]\",r+1);if(i!==-1){s+=1,r=i+1;continue}s+=1,r++;continue}if(n===\"\\\\\"){s+=1,r+=2;continue}s+=1,r++}return s}function er(e,t){let r=new Map([[\"errexit\",()=>e.state.options.errexit===!0],[\"nounset\",()=>e.state.options.nounset===!0],[\"pipefail\",()=>e.state.options.pipefail===!0],[\"xtrace\",()=>e.state.options.xtrace===!0],[\"e\",()=>e.state.options.errexit===!0],[\"u\",()=>e.state.options.nounset===!0],[\"x\",()=>e.state.options.xtrace===!0]]).get(t);return r?r():!1}async function Nn(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 On(t);try{let s=new B,r=ee(s,t);return await H(e,r.expression)}catch{return On(t)}}function To(e,t){let s=0;for(let r of e){let n;if(r>=\"0\"&&r<=\"9\")n=r.charCodeAt(0)-48;else if(r>=\"a\"&&r<=\"z\")n=r.charCodeAt(0)-97+10;else if(r>=\"A\"&&r<=\"Z\")n=r.charCodeAt(0)-65+36;else if(r===\"@\")n=62;else if(r===\"_\")n=63;else return Number.NaN;if(n>=t)return Number.NaN;s=s*t+n}return s}function On(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 s,r=e.match(/^(\\d+)#([a-zA-Z0-9@_]+)$/);if(r){let n=Number.parseInt(r[1],10);n>=2&&n<=64?s=To(r[2],n):s=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?s=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?s=Number.parseInt(e,8):s=Number.parseInt(e,10);return Number.isNaN(s)&&(s=0),t?-s:s}function fs(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 s=Number.parseInt(e,10);return Number.isNaN(s)?{value:0,valid:!1}:{value:t?-s:s,valid:!0}}function Do(e){let t=\"\",s=0;for(;s<e.length;)if(e[s]===\"\\\\\"&&s+1<e.length)t+=e[s]+e[s+1],s+=2;else if(e[s]===\"[\"){let r=Ro(e,s);t+=r.converted,s=r.endIndex}else t+=e[s],s++;return t}function Ro(e,t){let s=t+1,r=\"[\";s<e.length&&(e[s]===\"^\"||e[s]===\"!\")&&(r+=\"^\",s++);let n=!1;s<e.length&&e[s]===\"]\"&&(n=!0,s++);let i=!1;s<e.length&&e[s]===\"[\"&&s+1<e.length&&e[s+1]!==\":\"&&(i=!0,s++);let o=\"\",a=!1;for(;s<e.length;){let l=e[s];if(l===\"]\"){a=!0,s++;break}if(l===\"[\"&&s+1<e.length&&e[s+1]===\":\"){let c=e.indexOf(\":]\",s+2);if(c!==-1){let u=e.slice(s+2,c);o+=Io(u),s=c+2;continue}}if(l===\"[\"&&s+1<e.length){let c=e[s+1];if(c===\".\"||c===\"=\"){let u=`${c}]`,f=e.indexOf(u,s+2);if(f!==-1){let d=e.slice(s+2,f);o+=d,s=f+2;continue}}}if(l===\"\\\\\"&&s+1<e.length){o+=l+e[s+1],s+=2;continue}o+=l,s++}return a?(n&&(r+=\"\\\\]\"),i&&(r+=\"\\\\[\"),r+=o,r+=\"]\",{converted:r,endIndex:s}):{converted:\"\\\\[\",endIndex:t+1}}function Io(e){return new Map([[\"alnum\",\"a-zA-Z0-9\"],[\"alpha\",\"a-zA-Z\"],[\"ascii\",\"\\\\x00-\\\\x7F\"],[\"blank\",\" \\\\t\"],[\"cntrl\",\"\\\\x00-\\\\x1F\\\\x7F\"],[\"digit\",\"0-9\"],[\"graph\",\"!-~\"],[\"lower\",\"a-z\"],[\"print\",\" -~\"],[\"punct\",\"!-/:-@\\\\[-`{-~\"],[\"space\",\" \\\\t\\\\n\\\\r\\\\f\\\\v\"],[\"upper\",\"A-Z\"],[\"word\",\"a-zA-Z0-9_\"],[\"xdigit\",\"0-9A-Fa-f\"]]).get(e)??\"\"}function De(e){let t=[],s=\"\",r=!1,n=!1,i=!1,o=!1;for(let a of e){if(i){s+=a,i=!1,o=!0;continue}if(a===\"\\\\\"){i=!0;continue}if(a===\"'\"&&!n){r||(o=!0),r=!r;continue}if(a==='\"'&&!r){n||(o=!0),n=!n;continue}if((a===\" \"||a===\"\t\"||a===`\n`)&&!r&&!n){o&&(t.push(s),s=\"\",o=!1);continue}s+=a,o=!0}return o&&t.push(s),t}function ds(e){let t=[],s=0;for(;s<e.length;){for(;s<e.length&&/\\s/.test(e[s]);)s++;if(s>=e.length)break;if(e[s]!==\"[\"){s++;continue}s++;let r=\"\";if(e[s]===\"'\"||e[s]==='\"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)r+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&e[s]!==\"]\"&&e[s]!==\"=\";)r+=e[s],s++;for(;s<e.length&&e[s]!==\"]\";)s++;if(e[s]===\"]\"&&s++,e[s]!==\"=\")continue;s++;let n=\"\";if(e[s]===\"'\"||e[s]==='\"'){let i=e[s];for(s++;s<e.length&&e[s]!==i;)e[s]===\"\\\\\"&&s+1<e.length&&s++,n+=e[s],s++;e[s]===i&&s++}else for(;s<e.length&&!/\\s/.test(e[s]);)n+=e[s],s++;t.push([r,n])}return t}function Ln(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\((.*)\\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:De(t[2])};let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([^\\]]+)\\]=(.*)$/s);if(s)return{name:s[1],isArray:!1,arrayIndex:s[2],value:s[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 Lo(e,t){try{let s=new B,r=ee(s,t);return await H(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}async function Fn(e,t,s={}){let{name:r,isArray:n,arrayElements:i,value:o,arrayIndex:a}=t,{makeReadonly:l=!1,checkReadonly:c=!0}=s;if(c){let u=se(e,r);if(u)return u}if(n&&i){for(let u=0;u<i.length;u++)e.state.env.set(`${r}_${u}`,i[u]);e.state.env.set(`${r}__length`,String(i.length))}else if(a!==void 0&&o!==void 0){let u=await Lo(e,a);e.state.env.set(`${r}_${u}`,o);let f=parseInt(e.state.env.get(`${r}__length`)??\"0\",10);u>=f&&e.state.env.set(`${r}__length`,String(u+1))}else o!==void 0&&e.state.env.set(r,o);return l&&de(e,r),null}function Xe(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function pt(e,t){return e.state.localVarDepth?.get(t)}function hs(e,t){e.state.localVarDepth?.delete(t)}function Mn(e,t,s){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:s,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function ps(e,t){let s=e.state.localVarStack?.get(t);if(!(!s||s.length===0))return s.pop()}function Wn(e,t){if(e.state.localVarStack)for(let[s,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(s)}}var tr=new Set([\":\",\".\",\"break\",\"continue\",\"eval\",\"exec\",\"exit\",\"export\",\"readonly\",\"return\",\"set\",\"shift\",\"trap\",\"unset\"]);function zn(e){return tr.has(e)}var sr=new Set([\"if\",\"then\",\"else\",\"elif\",\"fi\",\"case\",\"esac\",\"for\",\"select\",\"while\",\"until\",\"do\",\"done\",\"in\",\"function\",\"{\",\"}\",\"time\",\"[[\",\"]]\",\"!\"]),mt=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\"]);async function rt(e,t,s,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${s}: Is a directory\n`;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&s!==\"/dev/null\")return`bash: ${s}: cannot overwrite existing file\n`}catch{}return null}function Ye(e){let s=Math.min(e.length,8192);for(let r=0;r<s;r++)if(e.charCodeAt(r)>127)return\"utf8\";return\"binary\"}function Fo(e){if(!e.startsWith(\"__rw__:\"))return null;let t=e.slice(7),s=t.indexOf(\":\");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+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 Vn(e,t){let s=new Map;for(let r=0;r<t.length;r++){let n=t[r];if(n.target.type===\"HereDoc\")continue;if(n.operator===\">&\"||n.operator===\"<&\"){if(Us(e,n.target))return{targets:s,error:`bash: $@: ambiguous redirect\n`};s.set(r,await L(e,n.target))}else{let o=await Xt(e,n.target);if(\"error\"in o)return{targets:s,error:o.error};s.set(r,o.target)}}return{targets:s}}function Mo(e){e.state.nextFd===void 0&&(e.state.nextFd=10);let t=e.state.nextFd,s=e.limits.maxFileDescriptors;if(t>=s)throw new Error(`bash: cannot allocate file descriptor: too many open files (max ${s})`);return e.state.nextFd++,t}async function ms(e,t){for(let s of t){if(!s.fdVariable)continue;if(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),(s.operator===\">&\"||s.operator===\"<&\")&&s.target.type===\"Word\"&&await L(e,s.target)===\"-\"){let i=e.state.env.get(s.fdVariable);if(i!==void 0){let o=Number.parseInt(i,10);Number.isNaN(o)||e.state.fileDescriptors.delete(o)}continue}let r=Mo(e);if(e.state.env.set(s.fdVariable,String(r)),s.target.type===\"Word\"){let n=await L(e,s.target);if(s.operator===\">&\"||s.operator===\"<&\"){let i=Number.parseInt(n,10);if(!Number.isNaN(i)){let o=e.state.fileDescriptors.get(i);o!==void 0&&(le(e),e.state.fileDescriptors.set(r,o));continue}}if(s.operator===\">\"||s.operator===\">>\"||s.operator===\">|\"||s.operator===\"&>\"||s.operator===\"&>>\"){let i=e.fs.resolvePath(e.state.cwd,n);(s.operator===\">\"||s.operator===\">|\"||s.operator===\"&>\")&&await e.fs.writeFile(i,\"\",\"binary\"),le(e),e.state.fileDescriptors.set(r,`__file__:${i}`)}else if(s.operator===\"<<<\")le(e),e.state.fileDescriptors.set(r,`${n}\n`);else if(s.operator===\"<\"||s.operator===\"<>\")try{let i=e.fs.resolvePath(e.state.cwd,n),o=await e.fs.readFile(i);le(e),e.state.fileDescriptors.set(r,o)}catch{return _(\"\",`bash: ${n}: No such file or directory\n`,1)}}}return null}async function Re(e,t){for(let s of t){if(s.target.type===\"HereDoc\")continue;let r=s.operator===\">&\";if(s.operator!==\">\"&&s.operator!==\">|\"&&s.operator!==\"&>\"&&!r)continue;let n;if(r){if(n=await L(e,s.target),n===\"-\"||!Number.isNaN(Number.parseInt(n,10))||s.fd!=null)continue}else{let a=await Xt(e,s.target);if(\"error\"in a)return _(\"\",a.error,1);n=a.target}let i=e.fs.resolvePath(e.state.cwd,n),o=s.operator===\">|\";if(i.includes(\"\\0\"))return _(\"\",`bash: ${n}: No such file or directory\n`,1);try{let a=await e.fs.stat(i);if(a.isDirectory)return _(\"\",`bash: ${n}: Is a directory\n`,1);if(e.state.options.noclobber&&!o&&!a.isDirectory&&n!==\"/dev/null\")return _(\"\",`bash: ${n}: cannot overwrite existing file\n`,1)}catch{}if(n!==\"/dev/null\"&&n!==\"/dev/stdout\"&&n!==\"/dev/stderr\"&&n!==\"/dev/full\"&&await e.fs.writeFile(i,\"\",\"binary\"),n===\"/dev/full\")return _(\"\",`bash: /dev/full: No space left on device\n`,1)}return null}async function K(e,t,s,r){let{stdout:n,stderr:i,exitCode:o}=t,l=t.stdoutKind===\"bytes\"||t.stdoutKind===void 0&&t.stdoutEncoding===\"binary\"?\"binary\":\"utf8\",c=p=>l;for(let p=0;p<s.length;p++){let y=s[p];if(y.target.type===\"HereDoc\")continue;let h,w=r?.get(p);if(w!==void 0)h=w;else if(y.operator===\">&\"||y.operator===\"<&\"){if(Us(e,y.target)){i+=`bash: $@: ambiguous redirect\n`,o=1,n=\"\";continue}h=await L(e,y.target)}else{let g=await Xt(e,y.target);if(\"error\"in g){i+=g.error,o=1,n=\"\";continue}h=g.target}if(!y.fdVariable){if(h.includes(\"\\0\")){i+=`bash: ${h.replace(/\\0/g,\"\")}: No such file or directory\n`,o=1,n=\"\";continue}switch(y.operator){case\">\":case\">|\":{let E=y.fd??1,g=y.operator===\">|\";if(E===1){if(h===\"/dev/stdout\")break;if(h===\"/dev/stderr\"){i+=n,n=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let b=e.fs.resolvePath(e.state.cwd,h),m=await rt(e,b,h,{checkNoclobber:!0,isClobber:g});if(m){i+=m,o=1,n=\"\";break}await e.fs.writeFile(b,n,c(n)),n=\"\"}else if(E===2){if(h===\"/dev/stderr\")break;if(h===\"/dev/stdout\"){n+=i,i=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1;break}if(h===\"/dev/null\")i=\"\";else{let b=e.fs.resolvePath(e.state.cwd,h),m=await rt(e,b,h,{checkNoclobber:!0,isClobber:g});if(m){i+=m,o=1;break}await e.fs.writeFile(b,i,Ye(i)),i=\"\"}}break}case\">>\":{let E=y.fd??1;if(E===1){if(h===\"/dev/stdout\")break;if(h===\"/dev/stderr\"){i+=n,n=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let g=e.fs.resolvePath(e.state.cwd,h),b=await rt(e,g,h,{});if(b){i+=b,o=1,n=\"\";break}await e.fs.appendFile(g,n,c(n)),n=\"\"}else if(E===2){if(h===\"/dev/stderr\")break;if(h===\"/dev/stdout\"){n+=i,i=\"\";break}if(h===\"/dev/full\"){i+=`bash: echo: write error: No space left on device\n`,o=1;break}let g=e.fs.resolvePath(e.state.cwd,h),b=await rt(e,g,h,{});if(b){i+=b,o=1;break}await e.fs.appendFile(g,i,Ye(i)),i=\"\"}break}case\">&\":case\"<&\":{let E=y.fd??1;if(h===\"-\")break;if(h.endsWith(\"-\")){let g=h.slice(0,-1),b=Number.parseInt(g,10);if(!Number.isNaN(b)){let m=e.state.fileDescriptors?.get(b);m!==void 0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(E,m),b>=3&&e.state.fileDescriptors?.delete(b)):b===1||b===2?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(E,`__dupout__:${b}`)):b===0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(E,`__dupin__:${b}`)):b>=3&&(i+=`bash: ${b}: Bad file descriptor\n`,o=1)}break}if(h===\"2\"||h===\"&2\")E===1&&(i+=n,n=\"\");else if(h===\"1\"||h===\"&1\")n+=i,i=\"\";else{let g=Number.parseInt(h,10);if(Number.isNaN(g)){if(y.operator===\">&\"){let b=e.fs.resolvePath(e.state.cwd,h),m=await rt(e,b,h,{checkNoclobber:!0});if(m){i=m,o=1,n=\"\";break}if(y.fd==null){let v=n+i;await e.fs.writeFile(b,v,c(v)),n=\"\",i=\"\"}else E===1?(await e.fs.writeFile(b,n,c(n)),n=\"\"):E===2&&(await e.fs.writeFile(b,i,Ye(i)),i=\"\")}}else{let b=e.state.fileDescriptors?.get(g);if(b?.startsWith(\"__file__:\")){let m=b.slice(9);E===1?(await e.fs.appendFile(m,n,c(n)),n=\"\"):E===2&&(await e.fs.appendFile(m,i,Ye(i)),i=\"\")}else if(b?.startsWith(\"__rw__:\")){let m=Fo(b);m&&(E===1?(await e.fs.appendFile(m.path,n,c(n)),n=\"\"):E===2&&(await e.fs.appendFile(m.path,i,Ye(i)),i=\"\"))}else if(b?.startsWith(\"__dupout__:\")){let m=Number.parseInt(b.slice(11),10);if(m!==1)if(m===2)E===1&&(i+=n,n=\"\");else{let v=e.state.fileDescriptors?.get(m);if(v?.startsWith(\"__file__:\")){let $=v.slice(9);E===1?(await e.fs.appendFile($,n,c(n)),n=\"\"):E===2&&(await e.fs.appendFile($,i,Ye(i)),i=\"\")}}}else b?.startsWith(\"__dupin__:\")?(i+=`bash: ${g}: Bad file descriptor\n`,o=1,n=\"\"):g>=3&&(i+=`bash: ${g}: Bad file descriptor\n`,o=1,n=\"\")}}break}case\"&>\":{if(h===\"/dev/full\"){i=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let E=e.fs.resolvePath(e.state.cwd,h),g=await rt(e,E,h,{checkNoclobber:!0});if(g){i=g,o=1,n=\"\";break}let b=n+i;await e.fs.writeFile(E,b,c(b)),n=\"\",i=\"\";break}case\"&>>\":{if(h===\"/dev/full\"){i=`bash: echo: write error: No space left on device\n`,o=1,n=\"\";break}let E=e.fs.resolvePath(e.state.cwd,h),g=await rt(e,E,h,{});if(g){i=g,o=1,n=\"\";break}let b=n+i;await e.fs.appendFile(E,b,c(b)),n=\"\",i=\"\";break}}}}let u=e.state.fileDescriptors?.get(1);if(u){if(u===\"__dupout__:2\")i+=n,n=\"\";else if(u.startsWith(\"__file__:\")){let p=u.slice(9);await e.fs.appendFile(p,n,c(n)),n=\"\"}else if(u.startsWith(\"__file_append__:\")){let p=u.slice(16);await e.fs.appendFile(p,n,c(n)),n=\"\"}}let f=e.state.fileDescriptors?.get(2);if(f){if(f===\"__dupout__:1\")n+=i,i=\"\";else if(f.startsWith(\"__file__:\")){let p=f.slice(9);await e.fs.appendFile(p,i,Ye(i)),i=\"\"}else if(f.startsWith(\"__file_append__:\")){let p=f.slice(16);await e.fs.appendFile(p,i,Ye(i)),i=\"\"}}let d=_(n,i,o);return t.stdoutKind&&(d.stdoutKind=t.stdoutKind),t.stdoutEncoding===\"binary\"&&(d.stdoutEncoding=\"binary\"),d}function Bn(e,t){if(e.state.options.posix&&tr.has(t.name)){let r=`bash: line ${e.state.currentLine}: \\`${t.name}': is a special builtin\n`;throw new j(2,\"\",r)}let s={...t,sourceFile:t.sourceFile??e.state.currentSource??\"main\"};return e.state.functions.set(t.name,s),W}async function Wo(e,t){let s=\"\";for(let r of t)if((r.operator===\"<<\"||r.operator===\"<<-\")&&r.target.type===\"HereDoc\"){let n=r.target,i=await L(e,n.content);n.stripTabs&&(i=i.split(`\n`).map(a=>a.replace(/^\\t+/,\"\")).join(`\n`)),(r.fd??0)===0&&(s=i)}else if(r.operator===\"<<<\"&&r.target.type===\"Word\")s=`${await L(e,r.target)}\n`;else if(r.operator===\"<\"&&r.target.type===\"Word\"){let n=await L(e,r.target),i=e.fs.resolvePath(e.state.cwd,n);try{s=await e.fs.readFile(i)}catch{}}return s}async function ys(e,t,s,r=\"\",n){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,Te(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,\"recursion\")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(n??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??\"main\"),e.state.localScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let i=new Map;for(let c=0;c<s.length;c++)i.set(String(c+1),e.state.env.get(String(c+1))),e.state.env.set(String(c+1),s[c]);i.set(\"@\",e.state.env.get(\"@\")),i.set(\"#\",e.state.env.get(\"#\")),e.state.env.set(\"@\",s.join(\" \")),e.state.env.set(\"#\",String(s.length));let o=()=>{let c=e.state.localScopes.length-1,u=e.state.localScopes.pop();if(u)for(let[f,d]of u)d===void 0?e.state.env.delete(f):e.state.env.set(f,d);if(Wn(e,c),e.state.fullyUnsetLocals)for(let[f,d]of e.state.fullyUnsetLocals.entries())d===c&&e.state.fullyUnsetLocals.delete(f);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let f=e.state.localExportedVars.pop();if(f)for(let d of f)e.state.exportedVars?.delete(d)}for(let[f,d]of i)d===void 0?e.state.env.delete(f):e.state.env.set(f,d);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},{targets:a,error:l}=await Vn(e,t.redirections);if(l)return o(),_(\"\",l,1);try{let c=await Wo(e,t.redirections),u=r||c,f=await e.executeCommand(t.body,u);return o(),K(e,f,t.redirections,a)}catch(c){if(o(),c instanceof ue){let u=_(c.stdout,c.stderr,c.exitCode);return K(e,u,t.redirections,a)}throw c}}var Un=[\"!\",\"[[\",\"]]\",\"case\",\"do\",\"done\",\"elif\",\"else\",\"esac\",\"fi\",\"for\",\"function\",\"if\",\"in\",\"then\",\"time\",\"until\",\"while\",\"{\",\"}\"],nr=[\".\",\":\",\"[\",\"alias\",\"bg\",\"bind\",\"break\",\"builtin\",\"caller\",\"cd\",\"command\",\"compgen\",\"complete\",\"compopt\",\"continue\",\"declare\",\"dirs\",\"disown\",\"echo\",\"enable\",\"eval\",\"exec\",\"exit\",\"export\",\"false\",\"fc\",\"fg\",\"getopts\",\"hash\",\"help\",\"history\",\"jobs\",\"kill\",\"let\",\"local\",\"logout\",\"mapfile\",\"popd\",\"printf\",\"pushd\",\"pwd\",\"read\",\"readarray\",\"readonly\",\"return\",\"set\",\"shift\",\"shopt\",\"source\",\"suspend\",\"test\",\"times\",\"trap\",\"true\",\"type\",\"typeset\",\"ulimit\",\"umask\",\"unalias\",\"unset\",\"wait\"],zo=[\"autocd\",\"assoc_expand_once\",\"cdable_vars\",\"cdspell\",\"checkhash\",\"checkjobs\",\"checkwinsize\",\"cmdhist\",\"compat31\",\"compat32\",\"compat40\",\"compat41\",\"compat42\",\"compat43\",\"compat44\",\"complete_fullquote\",\"direxpand\",\"dirspell\",\"dotglob\",\"execfail\",\"expand_aliases\",\"extdebug\",\"extglob\",\"extquote\",\"failglob\",\"force_fignore\",\"globasciiranges\",\"globstar\",\"gnu_errfmt\",\"histappend\",\"histreedit\",\"histverify\",\"hostcomplete\",\"huponexit\",\"inherit_errexit\",\"interactive_comments\",\"lastpipe\",\"lithist\",\"localvar_inherit\",\"localvar_unset\",\"login_shell\",\"mailwarn\",\"no_empty_cmd_completion\",\"nocaseglob\",\"nocasematch\",\"nullglob\",\"progcomp\",\"progcomp_alias\",\"promptvars\",\"restricted_shell\",\"shift_verbose\",\"sourcepath\",\"xpg_echo\"],Vo=nr;async function ir(e,t){let s=[],r=null,n=\"\",i=\"\",o=null,a=!1,l=!1,c=!1,u=null,f=null,d=null,p=[],y=[\"alias\",\"arrayvar\",\"binding\",\"builtin\",\"command\",\"directory\",\"disabled\",\"enabled\",\"export\",\"file\",\"function\",\"group\",\"helptopic\",\"hostname\",\"job\",\"keyword\",\"running\",\"service\",\"setopt\",\"shopt\",\"signal\",\"stopped\",\"user\",\"variable\"];for(let m=0;m<t.length;m++){let v=t[m];if(v===\"-v\")s.push(\"variable\");else if(v===\"-e\")s.push(\"export\");else if(v===\"-f\")s.push(\"file\");else if(v===\"-d\")s.push(\"directory\");else if(v===\"-k\")s.push(\"keyword\");else if(v===\"-A\"){if(m++,m>=t.length)return A(`compgen: -A: option requires an argument\n`,2);let $=t[m];if(!y.includes($))return A(`compgen: ${$}: invalid action name\n`,2);s.push($)}else if(v===\"-W\"){if(m++,m>=t.length)return A(`compgen: -W: option requires an argument\n`,2);r=t[m]}else if(v===\"-P\"){if(m++,m>=t.length)return A(`compgen: -P: option requires an argument\n`,2);n=t[m]}else if(v===\"-S\"){if(m++,m>=t.length)return A(`compgen: -S: option requires an argument\n`,2);i=t[m]}else if(v===\"-o\"){if(m++,m>=t.length)return A(`compgen: -o: option requires an argument\n`,2);let $=t[m];if($===\"plusdirs\")a=!0;else if($===\"dirnames\")l=!0;else if($===\"default\")c=!0;else if(!($===\"filenames\"||$===\"nospace\"||$===\"bashdefault\"||$===\"noquote\"))return A(`compgen: ${$}: invalid option name\n`,2)}else if(v===\"-F\"){if(m++,m>=t.length)return A(`compgen: -F: option requires an argument\n`,2);f=t[m]}else if(v===\"-C\"){if(m++,m>=t.length)return A(`compgen: -C: option requires an argument\n`,2);d=t[m]}else if(v===\"-X\"){if(m++,m>=t.length)return A(`compgen: -X: option requires an argument\n`,2);u=t[m]}else if(v===\"-G\"){if(m++,m>=t.length)return A(`compgen: -G: option requires an argument\n`,2)}else if(v===\"--\"){p.push(...t.slice(m+1));break}else v.startsWith(\"-\")||p.push(v)}o=p[0]??null;let h=[];if(l){let m=await rr(e,o);h.push(...m)}if(c){let m=await jn(e,o);h.push(...m)}for(let m of s)if(m===\"variable\"){let v=Bo(e,o);h.push(...v)}else if(m===\"export\"){let v=jo(e,o);h.push(...v)}else if(m===\"function\"){let v=Uo(e,o);h.push(...v)}else if(m===\"builtin\"){let v=Ho(o);h.push(...v)}else if(m===\"keyword\"){let v=Zo(o);h.push(...v)}else if(m===\"alias\"){let v=qo(e,o);h.push(...v)}else if(m===\"shopt\"){let v=Go(o);h.push(...v)}else if(m===\"helptopic\"){let v=Ko(o);h.push(...v)}else if(m===\"directory\"){let v=await rr(e,o);h.push(...v)}else if(m===\"file\"){let v=await jn(e,o);h.push(...v)}else if(m===\"user\"){let v=Xo(o);h.push(...v)}else if(m===\"command\"){let v=await Yo(e,o);h.push(...v)}if(r!==null)try{let m=await Qo(e,r),v=Jo(e,m);for(let $ of v)(o===null||$.startsWith(o))&&h.push($)}catch{return _(\"\",\"\",1)}if(a){let m=await rr(e,o);for(let v of m)h.includes(v)||h.push(v)}let w=\"\";if(f!==null){let m=e.state.functions.get(f);if(m){let v=new Map;v.set(\"COMP_WORDS__length\",e.state.env.get(\"COMP_WORDS__length\")),e.state.env.set(\"COMP_WORDS__length\",\"0\"),v.set(\"COMP_CWORD\",e.state.env.get(\"COMP_CWORD\")),e.state.env.set(\"COMP_CWORD\",\"-1\"),v.set(\"COMP_LINE\",e.state.env.get(\"COMP_LINE\")),e.state.env.set(\"COMP_LINE\",\"\"),v.set(\"COMP_POINT\",e.state.env.get(\"COMP_POINT\")),e.state.env.set(\"COMP_POINT\",\"0\");let $=new Map;for(let T of e.state.env.keys())(T===\"COMPREPLY\"||T.startsWith(\"COMPREPLY_\")||T===\"COMPREPLY__length\")&&($.set(T,e.state.env.get(T)),e.state.env.delete(T));let S=[\"compgen\",p[0]??\"\",\"\"];try{let T=await ys(e,m,S,\"\");if(T.exitCode!==0)return yt(e,v),yt(e,$),_(\"\",T.stderr,1);w=T.stdout;let N=ea(e);h.push(...N)}catch{return yt(e,v),yt(e,$),_(\"\",\"\",1)}yt(e,v),yt(e,$)}}if(d!==null)try{let m=fe(d),v=await e.executeScript(m);if(v.exitCode!==0)return _(\"\",v.stderr,v.exitCode);if(v.stdout){let $=v.stdout.split(`\n`);for(let S of $)S.length>0&&h.push(S)}}catch(m){if(m.name===\"ParseException\")return A(`compgen: -C: ${m.message}\n`,2);throw m}let E=h;if(u!==null){let m=u.startsWith(\"!\"),v=m?u.slice(1):u;E=h.filter($=>{let S=ht($,v,!1,!0);return m?S:!S})}if(E.length===0&&o!==null)return _(w,\"\",1);let g=E.map(m=>`${n}${m}${i}`).join(`\n`),b=w+(g?`${g}\n`:\"\");return z(b)}function Bo(e,t){let s=new Set;for(let n of e.state.env.keys()){if(n.includes(\"_\")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\\d+$/.test(n)||n.endsWith(\"__length\"))continue;let i=n.split(\"_\")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?s.add(n):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&s.add(i)}let r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function jo(e,t){let s=e.state.exportedVars??new Set,r=Array.from(s);return t!==null&&(r=r.filter(n=>n.startsWith(t))),r=r.filter(n=>n.includes(\"_\")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\\d+$/.test(n)||n.endsWith(\"__length\")?!1:e.state.env.has(n)),r.sort()}function Uo(e,t){let s=Array.from(e.state.functions.keys());return t!==null&&(s=s.filter(r=>r.startsWith(t))),s.sort()}function Ho(e){let t=[...nr];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Zo(e){let t=[...Un];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function qo(e,t){let s=[];for(let n of e.state.env.keys())if(n.startsWith(\"BASH_ALIAS_\")){let i=n.slice(11);s.push(i)}let r=s;return t!==null&&(r=r.filter(n=>n.startsWith(t))),r.sort()}function Go(e){let t=[...zo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}function Ko(e){let t=[...Vo];return e!==null&&(t=t.filter(s=>s.startsWith(e))),t.sort()}async function rr(e,t){let s=[];try{let r=e.state.cwd,n=t??\"\";if(t){let o=t.lastIndexOf(\"/\");if(o!==-1){let a=t.slice(0,o)||\"/\";n=t.slice(o+1),a.startsWith(\"/\")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i){let a=`${r}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!n||o.startsWith(n)))if(t?.includes(\"/\")){let c=t.lastIndexOf(\"/\"),u=t.slice(0,c+1);s.push(u+o)}else s.push(o)}catch{}}}catch{}return s.sort()}async function jn(e,t){let s=[];try{let r=e.state.cwd,n=t??\"\";if(t){let o=t.lastIndexOf(\"/\");if(o!==-1){let a=t.slice(0,o)||\"/\";n=t.slice(o+1),a.startsWith(\"/\")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i)if(!n||o.startsWith(n))if(t?.includes(\"/\")){let a=t.lastIndexOf(\"/\"),l=t.slice(0,a+1);s.push(l+o)}else s.push(o)}catch{}return s.sort()}function Xo(e){return[\"root\",\"nobody\"]}async function Yo(e,t){let s=new Set;for(let i of nr)s.add(i);for(let i of e.state.functions.keys())s.add(i);for(let i of e.state.env.keys())i.startsWith(\"BASH_ALIAS_\")&&s.add(i.slice(11));for(let i of Un)s.add(i);let r=e.state.env.get(\"PATH\")??\"/usr/bin:/bin\";for(let i of r.split(\":\"))if(i)try{let o=await e.fs.readdir(i);for(let a of o)s.add(a)}catch{}let n=Array.from(s);return t!==null&&(n=n.filter(i=>i.startsWith(t))),n.sort()}async function Qo(e,t){let r=new B().parseWordFromString(t,!1,!1);return await L(e,r)}function Jo(e,t){let s=e.state.env.get(\"IFS\")??` \t\n`;if(s.length===0)return[t];let r=new Set(s.split(\"\")),n=[],i=\"\",o=0;for(;o<t.length;){let a=t[o];if(a===\"\\\\\"&&o+1<t.length){let l=t[o+1];i+=l,o+=2}else r.has(a)?(i.length>0&&(n.push(i),i=\"\"),o++):(i+=a,o++)}return i.length>0&&n.push(i),n}function yt(e,t){for(let[s,r]of t)r===void 0?e.state.env.delete(s):e.state.env.set(s,r)}function ea(e){let t=[];if(e.state.env.get(\"COMPREPLY__length\")!==void 0){let n=Ae(e,\"COMPREPLY\");for(let[,i]of n)t.push(i)}else{let n=e.state.env.get(\"COMPREPLY\");n!==void 0&&t.push(n)}return t}var ta=[\"bashdefault\",\"default\",\"dirnames\",\"filenames\",\"noquote\",\"nosort\",\"nospace\",\"plusdirs\"];function ar(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=!1,i,o,a,l=[],c=[],u=[];for(let f=0;f<t.length;f++){let d=t[f];if(d===\"-p\")s=!0;else if(d===\"-r\")r=!0;else if(d===\"-D\")n=!0;else if(d===\"-W\"){if(f++,f>=t.length)return A(`complete: -W: option requires an argument\n`,2);i=t[f]}else if(d===\"-F\"){if(f++,f>=t.length)return A(`complete: -F: option requires an argument\n`,2);o=t[f]}else if(d===\"-o\"){if(f++,f>=t.length)return A(`complete: -o: option requires an argument\n`,2);let p=t[f];if(!ta.includes(p))return A(`complete: ${p}: invalid option name\n`,2);l.push(p)}else if(d===\"-A\"){if(f++,f>=t.length)return A(`complete: -A: option requires an argument\n`,2);c.push(t[f])}else if(d===\"-C\"){if(f++,f>=t.length)return A(`complete: -C: option requires an argument\n`,2);a=t[f]}else if(d===\"-G\"){if(f++,f>=t.length)return A(`complete: -G: option requires an argument\n`,2)}else if(d===\"-P\"){if(f++,f>=t.length)return A(`complete: -P: option requires an argument\n`,2)}else if(d===\"-S\"){if(f++,f>=t.length)return A(`complete: -S: option requires an argument\n`,2)}else if(d===\"-X\"){if(f++,f>=t.length)return A(`complete: -X: option requires an argument\n`,2)}else if(d===\"--\"){u.push(...t.slice(f+1));break}else d.startsWith(\"-\")||u.push(d)}if(r){if(u.length===0)return e.state.completionSpecs.clear(),z(\"\");for(let f of u)e.state.completionSpecs.delete(f);return z(\"\")}if(s)return u.length===0?or(e):or(e,u);if(t.length===0||u.length===0&&!i&&!o&&!a&&l.length===0&&c.length===0&&!n)return or(e);if(o&&u.length===0&&!n)return A(`complete: -F: option requires a command name\n`,2);if(n){let f={isDefault:!0};return i!==void 0&&(f.wordlist=i),o!==void 0&&(f.function=o),a!==void 0&&(f.command=a),l.length>0&&(f.options=l),c.length>0&&(f.actions=c),e.state.completionSpecs.set(\"__default__\",f),z(\"\")}for(let f of u){let d=Object.create(null);i!==void 0&&(d.wordlist=i),o!==void 0&&(d.function=o),a!==void 0&&(d.command=a),l.length>0&&(d.options=l),c.length>0&&(d.actions=c),e.state.completionSpecs.set(f,d)}return z(\"\")}function or(e,t){let s=e.state.completionSpecs;if(!s||s.size===0){if(t&&t.length>0){let i=\"\";for(let o of t)i+=`complete: ${o}: no completion specification\n`;return _(\"\",i,1)}return z(\"\")}let r=[],n=t||Array.from(s.keys());for(let i of n){if(i===\"__default__\")continue;let o=s.get(i);if(!o){if(t)return _(r.join(`\n`)+(r.length>0?`\n`:\"\"),`complete: ${i}: no completion specification\n`,1);continue}let a=\"complete\";if(o.options)for(let l of o.options)a+=` -o ${l}`;if(o.actions)for(let l of o.actions)a+=` -A ${l}`;o.wordlist!==void 0&&(o.wordlist.includes(\" \")||o.wordlist.includes(\"'\")?a+=` -W '${o.wordlist}'`:a+=` -W ${o.wordlist}`),o.function!==void 0&&(a+=` -F ${o.function}`),o.isDefault&&(a+=\" -D\"),a+=` ${i}`,r.push(a)}return r.length===0?z(\"\"):z(`${r.join(`\n`)}\n`)}var Hn=[\"bashdefault\",\"default\",\"dirnames\",\"filenames\",\"noquote\",\"nosort\",\"nospace\",\"plusdirs\"];function lr(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let s=!1,r=!1,n=[],i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a];if(l===\"-D\")s=!0;else if(l===\"-E\")r=!0;else if(l===\"-o\"){if(a++,a>=t.length)return A(`compopt: -o: option requires an argument\n`,2);let c=t[a];if(!Hn.includes(c))return A(`compopt: ${c}: invalid option name\n`,2);n.push(c)}else if(l===\"+o\"){if(a++,a>=t.length)return A(`compopt: +o: option requires an argument\n`,2);let c=t[a];if(!Hn.includes(c))return A(`compopt: ${c}: invalid option name\n`,2);i.push(c)}else if(l===\"--\"){o.push(...t.slice(a+1));break}else!l.startsWith(\"-\")&&!l.startsWith(\"+\")&&o.push(l)}if(s){let a=e.state.completionSpecs.get(\"__default__\")??{isDefault:!0},l=new Set(a.options??[]);for(let c of n)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),z(\"\")}if(r){let a=e.state.completionSpecs.get(\"__empty__\")??{},l=new Set(a.options??[]);for(let c of n)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),z(\"\")}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 n)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 z(\"\")}return A(`compopt: not currently executing completion function\n`,1)}function cr(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new je;return W}if(t.length>1)throw new j(1,\"\",`bash: continue: too many arguments\n`);let s=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new j(1,\"\",`bash: continue: ${t[0]}: numeric argument required\n`);s=r}throw new ge(s)}function X(e,t){let s=e.state.env.get(\"HOME\")||\"/home/user\";return t.split(\":\").map(i=>i===\"~\"?s:i===\"~root\"?\"/root\":i.startsWith(\"~/\")?s+i.slice(1):i.startsWith(\"~root/\")?`/root${i.slice(5)}`:i).join(\":\")}function ur(e){for(let t=0;t<e.length;t++){let s=e.charCodeAt(t);if(s<32||s===127)return!0}return!1}function fr(e){let t=\"$'\";for(let s=0;s<e.length;s++){let r=e[s],n=e.charCodeAt(s);n===7?t+=\"\\\\a\":n===8?t+=\"\\\\b\":n===9?t+=\"\\\\t\":n===10?t+=\"\\\\n\":n===11?t+=\"\\\\v\":n===12?t+=\"\\\\f\":n===13?t+=\"\\\\r\":n===27?t+=\"\\\\e\":n===39?t+=\"\\\\'\":n===92?t+=\"\\\\\\\\\":n<32||n===127?t+=`\\\\${n.toString(8).padStart(3,\"0\")}`:t+=r}return t+=\"'\",t}function gs(e){return ur(e)?fr(e):/^[a-zA-Z0-9_/.:\\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,\"'\\\\''\")}'`}function nt(e){return ur(e)?fr(e):`\"${e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"')}\"`}function dr(e){return ur(e)?fr(e):`\"${e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"')}\"`}function Zn(e,t){let s=\"\";return e.state.integerVars?.has(t)&&(s+=\"i\"),e.state.lowercaseVars?.has(t)&&(s+=\"l\"),Ee(e,t)&&(s+=\"n\"),e.state.readonlyVars?.has(t)&&(s+=\"r\"),e.state.uppercaseVars?.has(t)&&(s+=\"u\"),e.state.exportedVars?.has(t)&&(s+=\"x\"),s===\"\"?\"--\":`-${s}`}function hr(e){return e===\"\"?\"''\":/[\\s'\\\\]/.test(e)?`'${e.replace(/'/g,\"'\\\\''\")}'`:e}function qn(e,t){let s=\"\",r=\"\",n=!1;for(let i of t){let o=Zn(e,i);if(e.state.associativeArrays?.has(i)){let u=He(e,i);if(u.length===0)s+=`declare -A ${i}=()\n`;else{let f=u.map(d=>{let p=e.state.env.get(`${i}_${d}`)??\"\",y=hr(p);return`['${d}']=${y}`});s+=`declare -A ${i}=(${f.join(\" \")})\n`}continue}let l=ne(e,i);if(l.length>0){let u=l.map(f=>{let d=e.state.env.get(`${i}_${f}`)??\"\";return`[${f}]=${nt(d)}`});s+=`declare -a ${i}=(${u.join(\" \")})\n`;continue}if(e.state.env.has(`${i}__length`)){s+=`declare -a ${i}=()\n`;continue}let c=e.state.env.get(i);if(c!==void 0)s+=`declare ${o} ${i}=${dr(c)}\n`;else{let u=e.state.declaredVars?.has(i),f=e.state.localVarDepth?.has(i);u||f?s+=`declare ${o} ${i}\n`:(r+=`bash: declare: ${i}: not found\n`,n=!0)}}return _(s,r,n?1:0)}function Gn(e,t){let{filterExport:s,filterReadonly:r,filterNameref:n,filterIndexedArray:i,filterAssocArray:o}=t,a=s||r||n||i||o,l=\"\",c=new Set;for(let f of e.state.env.keys()){if(f.startsWith(\"BASH_\"))continue;if(f.endsWith(\"__length\")){let p=f.slice(0,-8);c.add(p);continue}let d=f.lastIndexOf(\"_\");if(d>0){let p=f.slice(0,d),y=f.slice(d+1);if(/^\\d+$/.test(y)||e.state.associativeArrays?.has(p)){c.add(p);continue}}c.add(f)}if(e.state.localVarDepth)for(let f of e.state.localVarDepth.keys())c.add(f);if(e.state.associativeArrays)for(let f of e.state.associativeArrays)c.add(f);let u=Array.from(c).sort();for(let f of u){let d=Zn(e,f),p=e.state.associativeArrays?.has(f),y=ne(e,f),h=!p&&(y.length>0||e.state.env.has(`${f}__length`));if(a&&(o&&!p||i&&!h||s&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||n&&!Ee(e,f)))continue;if(p){let E=He(e,f);if(E.length===0)l+=`declare -A ${f}=()\n`;else{let g=E.map(b=>{let m=e.state.env.get(`${f}_${b}`)??\"\",v=hr(m);return`['${b}']=${v}`});l+=`declare -A ${f}=(${g.join(\" \")})\n`}continue}if(y.length>0){let E=y.map(g=>{let b=e.state.env.get(`${f}_${g}`)??\"\";return`[${g}]=${nt(b)}`});l+=`declare -a ${f}=(${E.join(\" \")})\n`;continue}if(e.state.env.has(`${f}__length`)){l+=`declare -a ${f}=()\n`;continue}let w=e.state.env.get(f);w!==void 0&&(l+=`declare ${d} ${f}=${dr(w)}\n`)}return z(l)}function Kn(e){let t=\"\",s=Array.from(e.state.associativeArrays??[]).sort();for(let r of s){let n=He(e,r);if(n.length===0)t+=`declare -A ${r}=()\n`;else{let i=n.map(o=>{let a=e.state.env.get(`${r}_${o}`)??\"\",l=hr(a);return`['${o}']=${l}`});t+=`declare -A ${r}=(${i.join(\" \")})\n`}}return z(t)}function Xn(e){let t=\"\",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith(\"BASH_\"))continue;if(n.endsWith(\"__length\")){let o=n.slice(0,-8);e.state.associativeArrays?.has(o)||s.add(o);continue}let i=n.lastIndexOf(\"_\");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);/^\\d+$/.test(a)&&(e.state.associativeArrays?.has(o)||s.add(o))}}let r=Array.from(s).sort();for(let n of r){let i=ne(e,n);if(i.length===0)t+=`declare -a ${n}=()\n`;else{let o=i.map(a=>{let l=e.state.env.get(`${n}_${a}`)??\"\";return`[${a}]=${nt(l)}`});t+=`declare -a ${n}=(${o.join(\" \")})\n`}}return z(t)}function Yn(e){let t=\"\",s=new Set;for(let n of e.state.env.keys()){if(n.startsWith(\"BASH_\"))continue;if(n.endsWith(\"__length\")){let o=n.slice(0,-8);s.add(o);continue}let i=n.lastIndexOf(\"_\");if(i>0){let o=n.slice(0,i),a=n.slice(i+1);if(/^\\d+$/.test(a)||e.state.associativeArrays?.has(o)){s.add(o);continue}}s.add(n)}let r=Array.from(s).sort();for(let n of r){if(e.state.associativeArrays?.has(n)||ne(e,n).length>0||e.state.env.has(`${n}__length`))continue;let a=e.state.env.get(n);a!==void 0&&(t+=`${n}=${gs(a)}\n`)}return z(t)}function pr(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function xt(e,t){return e.state.integerVars?.has(t)??!1}function mr(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function sa(e,t){return e.state.lowercaseVars?.has(t)??!1}function yr(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function ra(e,t){return e.state.uppercaseVars?.has(t)??!1}function gt(e,t,s){return sa(e,t)?s.toLowerCase():ra(e,t)?s.toUpperCase():s}async function Qn(e,t){try{let s=new B,r=ee(s,t),n=await H(e,r.expression);return String(n)}catch{return\"0\"}}function na(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let s=t[0],r=s.length;if(e[r]!==\"[\")return null;let n=0,i=r+1;for(;r<e.length;r++)if(e[r]===\"[\")n++;else if(e[r]===\"]\"&&(n--,n===0))break;if(n!==0)return null;let o=e.slice(i,r);if(r++,e[r]!==\"=\")return null;r++;let a=e.slice(r);return{name:s,indexExpr:o,value:a}}async function gr(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,d=!1,p=!1,y=!1,h=!1,w=!1,E=[];for(let N=0;N<t.length;N++){let F=t[N];if(F===\"-a\")s=!0;else if(F===\"-A\")r=!0;else if(F===\"-r\")n=!0;else if(F===\"-x\")i=!0;else if(F===\"-p\")o=!0;else if(F===\"-n\")a=!0;else if(F===\"+n\")l=!0;else if(F===\"+a\")c=!0;else if(F===\"+x\")u=!0;else if(F===\"--\"){E.push(...t.slice(N+1));break}else if(F.startsWith(\"+\")){for(let k of F.slice(1))if(k===\"n\")l=!0;else if(k===\"a\")c=!0;else if(k===\"x\")u=!0;else if(k!==\"r\"){if(k!==\"i\"){if(!(k===\"f\"||k===\"F\"))return _(\"\",`bash: typeset: +${k}: invalid option\n`,2)}}}else if(F===\"-i\")f=!0;else if(F===\"-l\")d=!0;else if(F===\"-u\")p=!0;else if(F===\"-f\")y=!0;else if(F===\"-F\")h=!0;else if(F===\"-g\")w=!0;else if(F.startsWith(\"-\"))for(let k of F.slice(1))if(k===\"a\")s=!0;else if(k===\"A\")r=!0;else if(k===\"r\")n=!0;else if(k===\"x\")i=!0;else if(k===\"p\")o=!0;else if(k===\"n\")a=!0;else if(k===\"i\")f=!0;else if(k===\"l\")d=!0;else if(k===\"u\")p=!0;else if(k===\"f\")y=!0;else if(k===\"F\")h=!0;else if(k===\"g\")w=!0;else return _(\"\",`bash: typeset: -${k}: invalid option\n`,2);else E.push(F)}let b=e.state.localScopes.length>0&&!w,m=N=>{if(!b)return;let F=e.state.localScopes[e.state.localScopes.length-1];F.has(N)||F.set(N,e.state.env.get(N))},v=N=>{if(!b)return;let F=e.state.localScopes[e.state.localScopes.length-1];F.has(N)||F.set(N,e.state.env.get(N));let k=`${N}_`;for(let D of e.state.env.keys())D.startsWith(k)&&!D.includes(\"__\")&&(F.has(D)||F.set(D,e.state.env.get(D)));let C=`${N}__length`;e.state.env.has(C)&&!F.has(C)&&F.set(C,e.state.env.get(C))},$=N=>{b&&Xe(e,N)};if(h){if(E.length===0){let k=Array.from(e.state.functions.keys()).sort(),C=\"\";for(let D of k)C+=`declare -f ${D}\n`;return z(C)}let N=!0,F=\"\";for(let k of E)e.state.functions.has(k)?F+=`${k}\n`:N=!1;return _(F,\"\",N?0:1)}if(y){if(E.length===0){let F=\"\",k=Array.from(e.state.functions.keys()).sort();for(let C of k)F+=`${C} ()\n{\n # function body\n}\n`;return z(F)}let N=!0;for(let F of E)e.state.functions.has(F)||(N=!1);return _(\"\",\"\",N?0:1)}if(o&&E.length>0)return qn(e,E);if(o&&E.length===0)return Gn(e,{filterExport:i,filterReadonly:n,filterNameref:a,filterIndexedArray:s,filterAssocArray:r});if(E.length===0&&r&&!o)return Kn(e);if(E.length===0&&s&&!o)return Xn(e);if(E.length===0&&!o)return Yn(e);let S=\"\",T=0;for(let N of E){let F=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\((.*)\\)$/s);if(F&&!c){let P=F[1],R=F[2];if(r&&ne(e,P).length>0){S+=`bash: declare: ${P}: cannot convert indexed to associative array\n`,T=1;continue}if((s||!r&&!s)&&e.state.associativeArrays?.has(P)){S+=`bash: declare: ${P}: cannot convert associative to indexed array\n`,T=1;continue}if(v(P),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(P)),Oe(e,P),e.state.env.delete(P),e.state.env.delete(`${P}__length`),r&&R.includes(\"[\")){let M=ds(R);for(let[te,V]of M){let Y=X(e,V);e.state.env.set(`${P}_${te}`,Y)}}else if(r){let M=De(R);for(let te=0;te<M.length;te+=2){let V=M[te],Y=te+1<M.length?X(e,M[te+1]):\"\";e.state.env.set(`${P}_${V}`,Y)}}else{let M=De(R);if(M.some(V=>/^\\[[^\\]]+\\]=/.test(V))){let V=0;for(let Y of M){let oe=Y.match(/^\\[([^\\]]+)\\]=(.*)$/);if(oe){let pe=oe[1],lt=oe[2],so=X(e,lt),Pt;if(/^-?\\d+$/.test(pe))Pt=Number.parseInt(pe,10);else try{let ro=new B,no=ee(ro,pe);Pt=await H(e,no.expression)}catch{Pt=0}e.state.env.set(`${P}_${Pt}`,so),V=Pt+1}else{let pe=X(e,Y);e.state.env.set(`${P}_${V}`,pe),V++}}}else{for(let V=0;V<M.length;V++)e.state.env.set(`${P}_${V}`,M[V]);e.state.env.set(`${P}__length`,String(M.length))}}$(P),n&&de(e,P),i&&ke(e,P);continue}if(l){let P=N.includes(\"=\")?N.slice(0,N.indexOf(\"=\")):N;if(tn(e,P),!N.includes(\"=\"))continue}if(u){let P=N.includes(\"=\")?N.slice(0,N.indexOf(\"=\")):N;if(Kt(e,P),!N.includes(\"=\"))continue}let k=na(N);if(k){let{name:P,indexExpr:R,value:M}=k,te=se(e,P);if(te)return te;v(P);let V;try{let oe=new B,pe=ee(oe,R);V=await H(e,pe.expression)}catch{let oe=parseInt(R,10);V=Number.isNaN(oe)?0:oe}e.state.env.set(`${P}_${V}`,M);let Y=parseInt(e.state.env.get(`${P}__length`)??\"0\",10);V>=Y&&e.state.env.set(`${P}__length`,String(V+1)),$(P),n&&de(e,P),i&&ke(e,P);continue}let C=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=\\((.*)\\)$/s);if(C&&!c){let P=C[1],R=C[2],M=se(e,P);if(M)return M;v(P);let te=De(R);if(e.state.associativeArrays?.has(P)){let V=ds(R);for(let[Y,oe]of V){let pe=X(e,oe);e.state.env.set(`${P}_${Y}`,pe)}}else{let V=ne(e,P),Y=0,oe=e.state.env.get(P);V.length===0&&oe!==void 0?(e.state.env.set(`${P}_0`,oe),e.state.env.delete(P),Y=1):V.length>0&&(Y=Math.max(...V)+1);for(let lt=0;lt<te.length;lt++)e.state.env.set(`${P}_${Y+lt}`,X(e,te[lt]));let pe=Y+te.length;e.state.env.set(`${P}__length`,String(pe))}$(P),n&&de(e,P),i&&ke(e,P);continue}let D=N.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=(.*)$/);if(D){let P=D[1],R=X(e,D[2]),M=se(e,P);if(M)return M;m(P),f&&pr(e,P),d&&mr(e,P),p&&yr(e,P);let V=ne(e,P).length>0||e.state.associativeArrays?.has(P);if(xt(e,P)){let Y=e.state.env.get(P)??\"0\",oe=parseInt(Y,10)||0,pe=parseInt(await Qn(e,R),10)||0;R=String(oe+pe),e.state.env.set(P,R)}else if(V){R=gt(e,P,R);let Y=`${P}_0`,oe=e.state.env.get(Y)??\"\";e.state.env.set(Y,oe+R)}else{R=gt(e,P,R);let Y=e.state.env.get(P)??\"\";e.state.env.set(P,Y+R)}$(P),n&&de(e,P),i&&ke(e,P),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(P));continue}if(N.includes(\"=\")){let P=N.indexOf(\"=\"),R=N.slice(0,P),M=N.slice(P+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(R)){S+=`bash: typeset: \\`${R}': not a valid identifier\n`,T=1;continue}let te=se(e,R);if(te)return te;if(m(R),a){if(M!==\"\"&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(M)){S+=`bash: declare: \\`${M}': invalid variable name for name reference\n`,T=1;continue}e.state.env.set(R,M),We(e,R),M!==\"\"&&Bs(e,M)&&Vs(e,R),$(R),n&&de(e,R),i&&ke(e,R);continue}if(f&&pr(e,R),d&&mr(e,R),p&&yr(e,R),xt(e,R)&&(M=await Qn(e,M)),M=gt(e,R,M),Ee(e,R)){let V=Ze(e,R);V&&V!==R?e.state.env.set(V,M):e.state.env.set(R,M)}else e.state.env.set(R,M);$(R),n&&de(e,R),i&&ke(e,R),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(R))}else{let P=N;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(P)){S+=`bash: typeset: \\`${P}': not a valid identifier\n`,T=1;continue}if(s||r?v(P):m(P),a){We(e,P);let M=e.state.env.get(P);M!==void 0&&M!==\"\"&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(M)?sn(e,P):M&&Bs(e,M)&&Vs(e,P),$(P),n&&de(e,P),i&&ke(e,P);continue}if(f&&pr(e,P),d&&mr(e,P),p&&yr(e,P),r){if(ne(e,P).length>0){S+=`bash: declare: ${P}: cannot convert indexed to associative array\n`,T=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(P)}let R=Array.from(e.state.env.keys()).some(M=>M.startsWith(`${P}_`)&&!M.startsWith(`${P}__length`));!e.state.env.has(P)&&!R&&(s||r?e.state.env.set(`${P}__length`,\"0\"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(P))),$(P),n&&de(e,P),i&&ke(e,P)}}return _(\"\",S,T)}async function wr(e,t){let s=!1,r=!1,n=!1,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a===\"-a\")s=!0;else if(a===\"-A\")r=!0;else if(a===\"-p\")n=!0;else if(a===\"--\"){i.push(...t.slice(o+1));break}else a.startsWith(\"-\")||i.push(a)}if(i.length===0){let o=\"\",a=Array.from(e.state.readonlyVars||[]).sort();for(let l of a){let c=e.state.env.get(l);if(c!==void 0){let u=c.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"');o+=`declare -r ${l}=\"${u}\"\n`}}return z(o)}for(let o of i){let a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=\\((.*)\\)$/s);if(a){let f=a[1],d=a[2],p=se(e,f);if(p)return p;let y=De(d);if(e.state.associativeArrays?.has(f)){let h=ds(d);for(let[w,E]of h){let g=X(e,E);e.state.env.set(`${f}_${w}`,g)}}else{let h=ne(e,f),w=0,E=e.state.env.get(f);h.length===0&&E!==void 0?(e.state.env.set(`${f}_0`,E),e.state.env.delete(f),w=1):h.length>0&&(w=Math.max(...h)+1);for(let b=0;b<y.length;b++)e.state.env.set(`${f}_${w+b}`,X(e,y[b]));let g=w+y.length;e.state.env.set(`${f}__length`,String(g))}de(e,f);continue}let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=(.*)$/);if(l){let f=l[1],d=X(e,l[2]),p=se(e,f);if(p)return p;let y=e.state.env.get(f)??\"\";e.state.env.set(f,y+d),de(e,f);continue}let c=Ln(o);if(c.value===void 0&&!c.isArray){de(e,c.name);continue}let u=await Fn(e,c,{makeReadonly:!0});if(u)return u}return W}function vr(e){return e.state.directoryStack??=[],e.state.directoryStack}function Tt(e,t){return t&&e===t?\"~\":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function ia(e){let t=e.split(\"/\").filter(r=>r&&r!==\".\"),s=[];for(let r of t)r===\"..\"?s.pop():s.push(r);return`/${s.join(\"/\")}`}async function br(e,t){let s=vr(e),r;for(let a=0;a<t.length;a++){let l=t[a];if(l===\"--\"){if(a+1<t.length){if(r!==void 0)return A(`bash: pushd: too many arguments\n`,2);r=t[a+1],a++}}else{if(l.startsWith(\"-\")&&l!==\"-\")return A(`bash: pushd: ${l}: invalid option\n`,2);if(r!==void 0)return A(`bash: pushd: too many arguments\n`,2);r=l}}if(r===void 0){if(s.length<2)return A(`bash: pushd: no other directory\n`,1);let a=s[0];s[0]=s[1],s[1]=a,r=s[0]}let n;if(r.startsWith(\"/\"))n=r;else if(r===\"..\"){let a=e.state.cwd.split(\"/\").filter(l=>l);a.pop(),n=`/${a.join(\"/\")}`}else r===\".\"?n=e.state.cwd:r.startsWith(\"~\")?n=(e.state.env.get(\"HOME\")||\"/\")+r.slice(1):n=`${e.state.cwd}/${r}`;n=ia(n);try{if(!(await e.fs.stat(n)).isDirectory)return A(`bash: pushd: ${r}: Not a directory\n`,1)}catch{return A(`bash: pushd: ${r}: No such file or directory\n`,1)}s.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=n,e.state.env.set(\"PWD\",n),e.state.env.set(\"OLDPWD\",e.state.previousDir);let i=e.state.env.get(\"HOME\")||\"\",o=`${[n,...s].map(a=>Tt(a,i)).join(\" \")}\n`;return z(o)}function Er(e,t){let s=vr(e);for(let o of t)if(o!==\"--\")return o.startsWith(\"-\")&&o!==\"-\"?A(`bash: popd: ${o}: invalid option\n`,2):A(`bash: popd: too many arguments\n`,2);if(s.length===0)return A(`bash: popd: directory stack empty\n`,1);let r=s.shift();if(!r)return A(`bash: popd: directory stack empty\n`,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,e.state.env.set(\"PWD\",r),e.state.env.set(\"OLDPWD\",e.state.previousDir);let n=e.state.env.get(\"HOME\")||\"\",i=`${[r,...s].map(o=>Tt(o,n)).join(\" \")}\n`;return z(i)}function $r(e,t){let s=vr(e),r=!1,n=!1,i=!1,o=!1;for(let u of t)if(u!==\"--\")if(u.startsWith(\"-\"))for(let f of u.slice(1))if(f===\"c\")r=!0;else if(f===\"l\")n=!0;else if(f===\"p\")i=!0;else if(f===\"v\")i=!0,o=!0;else return A(`bash: dirs: -${f}: invalid option\n`,2);else return A(`bash: dirs: too many arguments\n`,1);if(r)return e.state.directoryStack=[],W;let a=[e.state.cwd,...s],l=e.state.env.get(\"HOME\")||\"\",c;return o?(c=a.map((u,f)=>{let d=n?u:Tt(u,l);return` ${f} ${d}`}).join(`\n`),c+=`\n`):i?c=a.map(u=>n?u:Tt(u,l)).join(`\n`)+`\n`:c=a.map(u=>n?u:Tt(u,l)).join(\" \")+`\n`,z(c)}async function ws(e,t,s){let r=t;if(r.length>0){let a=r[0];if(a===\"--\")r=r.slice(1);else if(a.startsWith(\"-\")&&a!==\"-\"&&a.length>1)return A(`bash: eval: ${a}: invalid option\neval: usage: eval [arg ...]\n`,2)}if(r.length===0)return W;let n=r.join(\" \");if(n.trim()===\"\")return W;let i=e.state.groupStdin,o=s??e.state.groupStdin;o!==void 0&&(e.state.groupStdin=o);try{let a=fe(n);return await e.executeScript(a)}catch(a){if(a instanceof ye||a instanceof ge||a instanceof ue||a instanceof j)throw a;if(a.name===\"ParseException\")return A(`bash: eval: ${a.message}\n`);throw a}finally{e.state.groupStdin=i}}function Sr(e,t){let s,r=\"\";if(t.length===0)s=e.state.lastExitCode;else{let n=t[0],i=Number.parseInt(n,10);n===\"\"||Number.isNaN(i)||!/^-?\\d+$/.test(n)?(r=`bash: exit: ${n}: numeric argument required\n`,s=2):s=(i%256+256)%256}throw new j(s,\"\",r)}function Pr(e,t){let s=!1,r=[];for(let o of t)o===\"-n\"?s=!0:o===\"-p\"||o===\"--\"||r.push(o);if(r.length===0&&!s){let o=\"\",a=e.state.exportedVars??new Set,l=Array.from(a).sort();for(let c of l){let u=e.state.env.get(c);if(u!==void 0){let f=u.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"');o+=`declare -x ${c}=\"${f}\"\n`}}return z(o)}if(s){for(let o of r){let a,l;if(o.includes(\"=\")){let c=o.indexOf(\"=\");a=o.slice(0,c),l=X(e,o.slice(c+1)),e.state.env.set(a,l)}else a=o;Kt(e,a)}return W}let n=\"\",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=X(e,u[2]),c=!0;else if(o.includes(\"=\")){let f=o.indexOf(\"=\");a=o.slice(0,f),l=X(e,o.slice(f+1))}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){n+=`bash: export: \\`${o}': not a valid identifier\n`,i=1;continue}if(l!==void 0)if(c){let f=e.state.env.get(a)??\"\";e.state.env.set(a,f+l)}else e.state.env.set(a,l);else e.state.env.has(a)||e.state.env.set(a,\"\");ke(e,a)}return _(\"\",n,i)}function vs(e,t){if(t.length<2)return A(`bash: getopts: usage: getopts optstring name [arg ...]\n`);let s=t[0],r=t[1],n=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),i=s.startsWith(\":\"),o=i?s.slice(1):s,a;if(t.length>2)a=t.slice(2);else{let h=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);a=[];for(let w=1;w<=h;w++)a.push(e.state.env.get(String(w))||\"\")}let l=Number.parseInt(e.state.env.get(\"OPTIND\")||\"1\",10);l<1&&(l=1);let c=Number.parseInt(e.state.env.get(\"__GETOPTS_CHARINDEX\")||\"0\",10);if(e.state.env.set(\"OPTARG\",\"\"),l>a.length)return n||e.state.env.set(r,\"?\"),e.state.env.set(\"OPTIND\",String(a.length+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),{exitCode:n?2:1,stdout:\"\",stderr:\"\"};let u=a[l-1];if(!u||u===\"-\"||!u.startsWith(\"-\"))return n||e.state.env.set(r,\"?\"),{exitCode:n?2:1,stdout:\"\",stderr:\"\"};if(u===\"--\")return e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),n||e.state.env.set(r,\"?\"),{exitCode:n?2:1,stdout:\"\",stderr:\"\"};let f=c===0?1:c,d=u[f];if(!d)return e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),vs(e,t);let p=o.indexOf(d);if(p===-1){let h=\"\";return i?e.state.env.set(\"OPTARG\",d):h=`bash: illegal option -- ${d}\n`,n||e.state.env.set(r,\"?\"),f+1<u.length?(e.state.env.set(\"__GETOPTS_CHARINDEX\",String(f+1)),e.state.env.set(\"OPTIND\",String(l))):(e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\")),{exitCode:n?2:0,stdout:\"\",stderr:h}}if(p+1<o.length&&o[p+1]===\":\")if(f+1<u.length)e.state.env.set(\"OPTARG\",u.slice(f+1)),e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\");else{if(l>=a.length){let h=\"\";return i?(e.state.env.set(\"OPTARG\",d),n||e.state.env.set(r,\":\")):(h=`bash: option requires an argument -- ${d}\n`,n||e.state.env.set(r,\"?\")),e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"),{exitCode:n?2:0,stdout:\"\",stderr:h}}e.state.env.set(\"OPTARG\",a[l]),e.state.env.set(\"OPTIND\",String(l+2)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\")}else f+1<u.length?(e.state.env.set(\"__GETOPTS_CHARINDEX\",String(f+1)),e.state.env.set(\"OPTIND\",String(l))):(e.state.env.set(\"OPTIND\",String(l+1)),e.state.env.set(\"__GETOPTS_CHARINDEX\",\"0\"));return n||e.state.env.set(r,d),{exitCode:n?2:0,stdout:\"\",stderr:\"\"}}async function Ar(e,t){e.state.hashTable||(e.state.hashTable=new Map);let s=!1,r=!1,n=!1,i=!1,o=!1,a=\"\",l=[],c=0;for(;c<t.length;){let y=t[c];if(y===\"--\"){c++,l.push(...t.slice(c));break}if(y===\"-r\")s=!0,c++;else if(y===\"-d\")r=!0,c++;else if(y===\"-l\")n=!0,c++;else if(y===\"-t\")o=!0,c++;else if(y===\"-p\"){if(i=!0,c++,c>=t.length)return A(`bash: hash: -p: option requires an argument\n`,1);a=t[c],c++}else if(y.startsWith(\"-\")&&y.length>1){for(let h of y.slice(1))if(h===\"r\")s=!0;else if(h===\"d\")r=!0;else if(h===\"l\")n=!0;else if(h===\"t\")o=!0;else return h===\"p\"?A(`bash: hash: -p: option requires an argument\n`,1):A(`bash: hash: -${h}: invalid option\n`,1);c++}else l.push(y),c++}if(s)return e.state.hashTable.clear(),W;if(r){if(l.length===0)return A(`bash: hash: -d: option requires an argument\n`,1);let y=!1,h=\"\";for(let w of l)e.state.hashTable.has(w)?e.state.hashTable.delete(w):(h+=`bash: hash: ${w}: not found\n`,y=!0);return y?A(h,1):W}if(o){if(l.length===0)return A(`bash: hash: -t: option requires an argument\n`,1);let y=\"\",h=!1,w=\"\";for(let E of l){let g=e.state.hashTable.get(E);g?l.length>1?y+=`${E}\t${g}\n`:y+=`${g}\n`:(w+=`bash: hash: ${E}: not found\n`,h=!0)}return h?{exitCode:1,stdout:y,stderr:w}:z(y)}if(i){if(l.length===0)return A(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]\n`,1);let y=l[0];return e.state.hashTable.set(y,a),W}if(l.length===0){if(e.state.hashTable.size===0)return z(`hash: hash table empty\n`);let y=\"\";if(n)for(let[h,w]of e.state.hashTable)y+=`builtin hash -p ${w} ${h}\n`;else{y=`hits\tcommand\n`;for(let[,h]of e.state.hashTable)y+=` 1\t${h}\n`}return z(y)}let u=!1,f=\"\",p=(e.state.env.get(\"PATH\")||\"/usr/bin:/bin\").split(\":\");for(let y of l){if(y.includes(\"/\")){f+=`bash: hash: ${y}: cannot use / in name\n`,u=!0;continue}let h=!1;for(let w of p){if(!w)continue;let E=`${w}/${y}`;if(await e.fs.exists(E)){e.state.hashTable.set(y,E),h=!0;break}}h||(f+=`bash: hash: ${y}: not found\n`,u=!0)}return u?A(f,1):W}var Jn=new Map([[\":\",[\": [arguments]\",`Null command.\n No effect; the command does nothing.\n Exit Status:\n Always succeeds.`]],[\".\",[\". filename [arguments]\",`Execute commands from a file in the current shell.\n Read and execute commands from FILENAME in the current shell.\n The entries in $PATH are used to find the directory containing FILENAME.\n Exit Status:\n Returns the status of the last command executed in FILENAME.`]],[\"[\",[\"[ arg... ]\",`Evaluate conditional expression.\n This is a synonym for the \"test\" builtin, but the last argument must\n be a literal \\`]', to match the opening \\`['.`]],[\"alias\",[\"alias [-p] [name[=value] ... ]\",`Define or display aliases.\n Without arguments, \\`alias' prints the list of aliases in the reusable\n form \\`alias NAME=VALUE' on standard output.\n Exit Status:\n alias returns true unless a NAME is supplied for which no alias has been\n defined.`]],[\"bg\",[\"bg [job_spec ...]\",`Move jobs to the background.\n Place the jobs identified by each JOB_SPEC in the background, as if they\n had been started with \\`&'.`]],[\"break\",[\"break [n]\",`Exit for, while, or until loops.\n Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing\n loops.\n Exit Status:\n The exit status is 0 unless N is not greater than or equal to 1.`]],[\"builtin\",[\"builtin [shell-builtin [arg ...]]\",`Execute shell builtins.\n Execute SHELL-BUILTIN with arguments ARGs without performing command\n lookup. This is useful when you wish to reimplement a shell builtin\n as a shell function, but need to execute the builtin within the function.\n Exit Status:\n Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is\n not a shell builtin.`]],[\"caller\",[\"caller [expr]\",`Return the context of the current subroutine call.\n Without EXPR, returns \"$line $filename\". With EXPR, returns\n \"$line $subroutine $filename\"; this extra information can be used to\n provide a stack trace.\n Exit Status:\n Returns 0 unless the shell is not executing a subroutine call or\n EXPR is invalid.`]],[\"cd\",[\"cd [-L|-P] [dir]\",`Change the shell working directory.\n Change the current directory to DIR. The default DIR is the value of the\n HOME shell variable.\n\n The variable CDPATH defines the search path for the directory containing\n DIR. Alternative directory names in CDPATH are separated by a colon (:).\n A null directory name is the same as the current directory. If DIR begins\n with a slash (/), then CDPATH is not used.\n\n If the directory is not found, and the shell option \\`cdable_vars' is set,\n the word is assumed to be a variable name. If that variable has a value,\n its value is used for DIR.\n\n Options:\n -L\tforce symbolic links to be followed\n -P\tuse the physical directory structure without following symbolic\n \tlinks\n\n The default is to follow symbolic links, as if \\`-L' were specified.\n\n Exit Status:\n Returns 0 if the directory is changed; non-zero otherwise.`]],[\"command\",[\"command [-pVv] command [arg ...]\",`Execute a simple command or display information about commands.\n Runs COMMAND with ARGS suppressing shell function lookup, or display\n information about the specified COMMANDs.\n\n Options:\n -p\tuse a default value for PATH that is guaranteed to find all of\n \tthe standard utilities\n -v\tprint a description of COMMAND similar to the \\`type' builtin\n -V\tprint a more verbose description of each COMMAND\n\n Exit Status:\n Returns exit status of COMMAND, or failure if COMMAND is not found.`]],[\"compgen\",[\"compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]\",`Display possible completions depending on the options.\n Intended to be used from within a shell function generating possible\n completions. If the optional WORD argument is supplied, matches against\n WORD are generated.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"complete\",[\"complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]\",`Specify how arguments are to be completed.\n For each NAME, specify how arguments are to be completed.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"continue\",[\"continue [n]\",`Resume for, while, or until loops.\n Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.\n If N is specified, resumes the Nth enclosing loop.\n Exit Status:\n The exit status is 0 unless N is not greater than or equal to 1.`]],[\"declare\",[\"declare [-aAfFgilnrtux] [-p] [name[=value] ...]\",`Set variable values and attributes.\n Declare variables and give them attributes. If no NAMEs are given,\n display the attributes and values of all variables.\n\n Options:\n -a\tto make NAMEs indexed arrays (if supported)\n -A\tto make NAMEs associative arrays (if supported)\n -i\tto make NAMEs have the \\`integer' attribute\n -l\tto convert the value of each NAME to lower case on assignment\n -n\tmake NAME a reference to the variable named by its value\n -r\tto make NAMEs readonly\n -t\tto make NAMEs have the \\`trace' attribute\n -u\tto convert the value of each NAME to upper case on assignment\n -x\tto make NAMEs export\n\n Exit Status:\n Returns success unless an invalid option is supplied or a variable\n assignment error occurs.`]],[\"dirs\",[\"dirs [-clpv] [+N] [-N]\",`Display directory stack.\n Display the list of currently remembered directories. Directories\n find their way onto the list with the \\`pushd' command; you can get\n back up through the list with the \\`popd' command.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"disown\",[\"disown [-h] [-ar] [jobspec ...]\",`Remove jobs from current shell.\n Without any JOBSPECs, remove the current job.`]],[\"echo\",[\"echo [-neE] [arg ...]\",`Write arguments to the standard output.\n Display the ARGs, separated by a single space character and followed by a\n newline, on the standard output.\n\n Options:\n -n\tdo not append a newline\n -e\tenable interpretation of the following backslash escapes\n -E\texplicitly suppress interpretation of backslash escapes\n\n Exit Status:\n Returns success unless a write error occurs.`]],[\"enable\",[\"enable [-a] [-dnps] [-f filename] [name ...]\",`Enable and disable shell builtins.\n Enables and disables builtin shell commands.\n Exit Status:\n Returns success unless NAME is not a shell builtin or an error occurs.`]],[\"eval\",[\"eval [arg ...]\",`Execute arguments as a shell command.\n Combine ARGs into a single string, use the result as input to the shell,\n and execute the resulting commands.\n Exit Status:\n Returns exit status of command or success if command is null.`]],[\"exec\",[\"exec [-cl] [-a name] [command [arguments ...]] [redirection ...]\",`Replace the shell with the given command.\n Execute COMMAND, replacing this shell with the specified program.\n ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,\n any redirections take effect in the current shell.\n Exit Status:\n Returns success unless COMMAND is not found or a redirection error occurs.`]],[\"exit\",[\"exit [n]\",`Exit the shell.\n Exits the shell with a status of N. If N is omitted, the exit status\n is that of the last command executed.`]],[\"export\",[\"export [-fn] [name[=value] ...] or export -p\",`Set export attribute for shell variables.\n Marks each NAME for automatic export to the environment of subsequently\n executed commands. If VALUE is supplied, assign VALUE before exporting.\n\n Options:\n -f\trefer to shell functions\n -n\tremove the export property from each NAME\n -p\tdisplay a list of all exported variables and functions\n\n Exit Status:\n Returns success unless an invalid option is given or NAME is invalid.`]],[\"false\",[\"false\",`Return an unsuccessful result.\n Exit Status:\n Always fails.`]],[\"fc\",[\"fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]\",`Display or execute commands from the history list.\n Exit Status:\n Returns success or status of executed command.`]],[\"fg\",[\"fg [job_spec]\",`Move job to the foreground.\n Place the job identified by JOB_SPEC in the foreground, making it the\n current job.`]],[\"getopts\",[\"getopts optstring name [arg]\",`Parse option arguments.\n Getopts is used by shell procedures to parse positional parameters\n as options.\n\n OPTSTRING contains the option letters to be recognized; if a letter\n is followed by a colon, the option is expected to have an argument,\n which should be separated from it by white space.\n Exit Status:\n Returns success if an option is found; fails if the end of options is\n encountered or an error occurs.`]],[\"hash\",[\"hash [-lr] [-p pathname] [-dt] [name ...]\",`Remember or display program locations.\n Determine and remember the full pathname of each command NAME.\n Exit Status:\n Returns success unless NAME is not found or an invalid option is given.`]],[\"help\",[\"help [-s] [pattern ...]\",`Display information about builtin commands.\n Displays brief summaries of builtin commands. If PATTERN is\n specified, gives detailed help on all commands matching PATTERN,\n otherwise the list of help topics is printed.\n\n Options:\n -s\toutput only a short usage synopsis for each topic matching\n \tPATTERN\n\n Exit Status:\n Returns success unless PATTERN is not found.`]],[\"history\",[\"history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]\",`Display or manipulate the history list.\n Display the history list with line numbers, prefixing each modified\n entry with a \\`*'.\n Exit Status:\n Returns success unless an invalid option is given or an error occurs.`]],[\"jobs\",[\"jobs [-lnprs] [jobspec ...] or jobs -x command [args]\",`Display status of jobs.\n Lists the active jobs.\n Exit Status:\n Returns success unless an invalid option is given or an error occurs.`]],[\"kill\",[\"kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]\",`Send a signal to a job.\n Send the processes identified by PID or JOBSPEC the signal named by\n SIGSPEC or SIGNUM.\n Exit Status:\n Returns success unless an invalid option is given or an error occurs.`]],[\"let\",[\"let arg [arg ...]\",`Evaluate arithmetic expressions.\n Evaluate each ARG as an arithmetic expression. Evaluation is done in\n fixed-width integers with no check for overflow, though division by 0\n is trapped and flagged as an error.\n Exit Status:\n If the last ARG evaluates to 0, let returns 1; 0 is returned otherwise.`]],[\"local\",[\"local [option] name[=value] ...\",`Define local variables.\n Create a local variable called NAME, and give it VALUE. OPTION can\n be any option accepted by \\`declare'.\n\n Local can only be used within a function; it makes the variable NAME\n have a visible scope restricted to that function and its children.\n Exit Status:\n Returns success unless an invalid option is supplied, a variable\n assignment error occurs, or the shell is not executing a function.`]],[\"logout\",[\"logout [n]\",`Exit a login shell.\n Exits a login shell with exit status N. Returns an error if not executed\n in a login shell.`]],[\"mapfile\",[\"mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]\",`Read lines from the standard input into an indexed array variable.\n Read lines from the standard input into the indexed array variable ARRAY,\n or from file descriptor FD if the -u option is supplied.\n\n Options:\n -d delim\tUse DELIM to terminate lines, instead of newline\n -n count\tCopy at most COUNT lines\n -O origin\tBegin assigning to ARRAY at index ORIGIN\n -s count\tDiscard the first COUNT lines read\n -t\tRemove a trailing DELIM from each line read (default newline)\n -u fd\tRead lines from file descriptor FD instead of standard input\n\n Exit Status:\n Returns success unless an invalid option is given or ARRAY is readonly.`]],[\"popd\",[\"popd [-n] [+N | -N]\",`Remove directories from stack.\n Removes entries from the directory stack.\n Exit Status:\n Returns success unless an invalid argument is supplied or the directory\n change fails.`]],[\"printf\",[\"printf [-v var] format [arguments]\",`Formats and prints ARGUMENTS under control of the FORMAT.\n\n Options:\n -v var\tassign the output to shell variable VAR rather than\n \t\tdisplay it on the standard output\n\n FORMAT is a character string which contains three types of objects: plain\n characters, which are simply copied to standard output; character escape\n sequences, which are converted and copied to the standard output; and\n format specifications, each of which causes printing of the next successive\n argument.\n Exit Status:\n Returns success unless an invalid option is given or a write or assignment\n error occurs.`]],[\"pushd\",[\"pushd [-n] [+N | -N | dir]\",`Add directories to stack.\n Adds a directory to the top of the directory stack, or rotates\n the stack, making the new top of the stack the current working\n directory.\n Exit Status:\n Returns success unless an invalid argument is supplied or the directory\n change fails.`]],[\"pwd\",[\"pwd [-LP]\",`Print the name of the current working directory.\n\n Options:\n -L\tprint the value of $PWD if it names the current working\n \tdirectory\n -P\tprint the physical directory, without any symbolic links\n\n By default, \\`pwd' behaves as if \\`-L' were specified.\n Exit Status:\n Returns 0 unless an invalid option is given or the current directory\n cannot be read.`]],[\"read\",[\"read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]\",`Read a line from the standard input and split it into fields.\n Reads a single line from the standard input, or from file descriptor FD\n if the -u option is supplied. The line is split into fields as with word\n splitting, and the first word is assigned to the first NAME, the second\n word to the second NAME, and so on, with any leftover words assigned to\n the last NAME.\n Exit Status:\n The return code is zero, unless end-of-file is encountered, read times out,\n or an invalid file descriptor is supplied as the argument to -u.`]],[\"readarray\",[\"readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]\",\"Read lines from a file into an array variable.\\n A synonym for `mapfile'.\"]],[\"readonly\",[\"readonly [-aAf] [name[=value] ...] or readonly -p\",`Mark shell variables as unchangeable.\n Mark each NAME as read-only; the values of these NAMEs may not be\n changed by subsequent assignment.\n Exit Status:\n Returns success unless an invalid option is given or NAME is invalid.`]],[\"return\",[\"return [n]\",`Return from a shell function.\n Causes a function or sourced script to exit with the return value\n specified by N. If N is omitted, the return status is that of the\n last command executed within the function or script.\n Exit Status:\n Returns N, or failure if the shell is not executing a function or script.`]],[\"set\",[\"set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]\",`Set or unset values of shell options and positional parameters.\n Change the value of shell attributes and positional parameters, or\n display the names and values of shell variables.\n\n Options:\n -e Exit immediately if a command exits with a non-zero status.\n -u Treat unset variables as an error when substituting.\n -x Print commands and their arguments as they are executed.\n -o option-name\n Set the variable corresponding to option-name\n\n Exit Status:\n Returns success unless an invalid option is given.`]],[\"shift\",[\"shift [n]\",`Shift positional parameters.\n Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is\n not given, it is assumed to be 1.\n Exit Status:\n Returns success unless N is negative or greater than $#.`]],[\"shopt\",[\"shopt [-pqsu] [-o] [optname ...]\",`Set and unset shell options.\n Change the setting of each shell option OPTNAME. Without any option\n arguments, list each supplied OPTNAME, or all shell options if no\n OPTNAMEs are given, with an indication of whether or not each is set.\n\n Options:\n -o\trestrict OPTNAMEs to those defined for use with \\`set -o'\n -p\tprint each shell option with an indication of its status\n -q\tsuppress output\n -s\tenable (set) each OPTNAME\n -u\tdisable (unset) each OPTNAME\n\n Exit Status:\n Returns success if OPTNAME is enabled; fails if an invalid option is\n given or OPTNAME is disabled.`]],[\"source\",[\"source filename [arguments]\",`Execute commands from a file in the current shell.\n Read and execute commands from FILENAME in the current shell.\n The entries in $PATH are used to find the directory containing FILENAME.\n Exit Status:\n Returns the status of the last command executed in FILENAME.`]],[\"suspend\",[\"suspend [-f]\",`Suspend shell execution.\n Suspend the execution of this shell until it receives a SIGCONT signal.`]],[\"test\",[\"test [expr]\",`Evaluate conditional expression.\n Exits with a status of 0 (true) or 1 (false) depending on\n the evaluation of EXPR. Expressions may be unary or binary.\n Exit Status:\n Returns success if EXPR evaluates to true; fails if EXPR evaluates to\n false or an invalid argument is given.`]],[\"times\",[\"times\",`Display process times.\n Prints the accumulated user and system times for the shell and all of its\n child processes.\n Exit Status:\n Always succeeds.`]],[\"trap\",[\"trap [-lp] [[arg] signal_spec ...]\",`Trap signals and other events.\n Defines and activates handlers to be run when the shell receives signals\n or other conditions.\n Exit Status:\n Returns success unless a SIGSPEC is invalid or an invalid option is given.`]],[\"true\",[\"true\",`Return a successful result.\n Exit Status:\n Always succeeds.`]],[\"type\",[\"type [-afptP] name [name ...]\",`Display information about command type.\n For each NAME, indicate how it would be interpreted if used as a\n command name.\n\n Options:\n -a\tdisplay all locations containing an executable named NAME\n -f\tsuppress shell function lookup\n -P\tforce a PATH search for each NAME, even if it is an alias,\n \tbuiltin, or function, and returns the name of the disk file\n \tthat would be executed\n -p\treturns either the name of the disk file that would be executed,\n \tor nothing if \\`type -t NAME' would not return \\`file'\n -t\toutput a single word which is one of \\`alias', \\`keyword',\n \t\\`function', \\`builtin', \\`file' or \\`', if NAME is an alias,\n \tshell reserved word, shell function, shell builtin, disk file,\n \tor not found, respectively\n\n Exit Status:\n Returns success if all of the NAMEs are found; fails if any are not found.`]],[\"typeset\",[\"typeset [-aAfFgilnrtux] [-p] name[=value] ...\",\"Set variable values and attributes.\\n A synonym for `declare'.\"]],[\"ulimit\",[\"ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]\",`Modify shell resource limits.\n Provides control over the resources available to the shell and processes\n it creates, on systems that allow such control.\n Exit Status:\n Returns success unless an invalid option is supplied or an error occurs.`]],[\"umask\",[\"umask [-p] [-S] [mode]\",`Display or set file mode mask.\n Sets the user file-creation mask to MODE. If MODE is omitted, prints\n the current value of the mask.\n Exit Status:\n Returns success unless MODE is invalid or an invalid option is given.`]],[\"unalias\",[\"unalias [-a] name [name ...]\",`Remove each NAME from the list of defined aliases.\n Exit Status:\n Returns success unless a NAME is not an existing alias.`]],[\"unset\",[\"unset [-f] [-v] [-n] [name ...]\",`Unset values and attributes of shell variables and functions.\n For each NAME, remove the corresponding variable or function.\n\n Options:\n -f\ttreat each NAME as a shell function\n -v\ttreat each NAME as a shell variable\n -n\ttreat each NAME as a name reference and unset the variable itself\n \trather than the variable it references\n\n Without options, unset first tries to unset a variable, and if that fails,\n tries to unset a function.\n Exit Status:\n Returns success unless an invalid option is given or a NAME is read-only.`]],[\"wait\",[\"wait [-fn] [id ...]\",`Wait for job completion and return exit status.\n Waits for each process identified by an ID, which may be a process ID or a\n job specification, and reports its termination status.\n Exit Status:\n Returns the status of the last ID; fails if ID is invalid or an invalid\n option is given.`]]]),ei=[...Jn.keys()].sort();function kr(e,t){let s=!1,r=[],n=0;for(;n<t.length;){let l=t[n];if(l===\"--\"){for(n++;n<t.length;)r.push(t[n]),n++;break}if(l.startsWith(\"-\")&&l.length>1){for(let c=1;c<l.length;c++){let u=l[c];if(u===\"s\")s=!0;else return A(`bash: help: -${u}: invalid option\n`,2)}n++}else r.push(l),n++}if(r.length===0)return aa();let i=\"\",o=!1,a=\"\";for(let l of r){let c=oa(l);if(c.length===0){a+=`bash: help: no help topics match \\`${l}'. Try \\`help help' or \\`man -k ${l}' or \\`info ${l}'.\n`,o=!0;continue}for(let u of c){let f=Jn.get(u);if(!f)continue;let[d,p]=f;s?i+=`${u}: ${d}\n`:i+=`${u}: ${d}\n${p}\n`}}return{exitCode:o?1:0,stdout:i,stderr:a}}function oa(e){let t=e.replace(/[.+^${}()|[\\]\\\\]/g,\"\\\\$&\").replace(/\\*/g,\".*\").replace(/\\?/g,\".\"),s=kt(`^${t}$`);return ei.filter(r=>s.test(r))}function aa(){let e=[];e.push(\"just-bash shell builtins\"),e.push(\"These shell commands are defined internally. Type `help' to see this list.\"),e.push(\"Type `help name' to find out more about the function `name'.\"),e.push(\"\");let t=36,s=ei.slice(),r=Math.ceil(s.length/2);for(let n=0;n<r;n++){let i=s[n]||\"\",o=s[n+r]||\"\",a=i.padEnd(t);e.push(o?`${a}${o}`:i)}return z(`${e.join(`\n`)}\n`)}function la(e){let t=[],s=\"\",r=0;for(let n of e){for(let i of n)i===\"(\"?r++:i===\")\"&&r--;s?s+=` ${n}`:s=n,r===0&&(t.push(s),s=\"\")}return s&&t.push(s),t}async function _r(e,t){if(t.length===0)return A(`bash: let: expression expected\n`);let s=la(t),r=0;for(let n of s)try{let o=fe(`(( ${n} ))`).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 H(e,a.expression.expression))}}catch(i){return A(`bash: let: ${n}: ${i.message}\n`)}return _(\"\",\"\",r===0?1:0)}async function Cr(e,t){if(e.state.localScopes.length===0)return A(`bash: local: can only be used in a function\n`);let s=e.state.localScopes[e.state.localScopes.length-1],r=\"\",n=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(s.keys()).filter(f=>!f.includes(\"_\")||!f.match(/_\\d+$/)).filter(f=>!f.includes(\"__length\")).sort();for(let f of u){let d=e.state.env.get(f);d!==void 0&&(c+=`${f}=${d}\n`)}return _(c,\"\",0)}for(let c of l){let u,f,d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\((.*)\\)$/s);if(d){u=d[1];let E=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \\`${c}': not a valid identifier\n`,n=1;continue}if(se(e,u,\"bash\"),!s.has(u)){s.set(u,e.state.env.get(u));let m=`${u}_`;for(let v of e.state.env.keys())v.startsWith(m)&&!v.includes(\"__\")&&(s.has(v)||s.set(v,e.state.env.get(v)))}let g=`${u}_`;for(let m of e.state.env.keys())m.startsWith(g)&&!m.includes(\"__\")&&e.state.env.delete(m);let b=De(E);for(let m=0;m<b.length;m++)e.state.env.set(`${u}_${m}`,b[m]);e.state.env.set(`${u}__length`,String(b.length)),Xe(e,u),i&&We(e,u);continue}let p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=\\((.*)\\)$/s);if(p){u=p[1];let E=p[2];if(se(e,u,\"bash\"),!s.has(u)){s.set(u,e.state.env.get(u));let S=`${u}_`;for(let N of e.state.env.keys())N.startsWith(S)&&!N.includes(\"__\")&&(s.has(N)||s.set(N,e.state.env.get(N)));let T=`${u}__length`;e.state.env.has(T)&&!s.has(T)&&s.set(T,e.state.env.get(T))}let g=De(E),b=ne(e,u),m=0,v=e.state.env.get(u);b.length===0&&v!==void 0?(e.state.env.set(`${u}_0`,v),e.state.env.delete(u),m=1):b.length>0&&(m=Math.max(...b)+1);for(let S=0;S<g.length;S++)e.state.env.set(`${u}_${m+S}`,X(e,g[S]));let $=m+g.length;e.state.env.set(`${u}__length`,String($)),Xe(e,u),i&&We(e,u);continue}let y=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\+=(.*)$/);if(y){u=y[1];let E=X(e,y[2]);se(e,u,\"bash\"),s.has(u)||s.set(u,e.state.env.get(u));let g=e.state.env.get(u)??\"\";e.state.env.set(u,g+E),Xe(e,u),i&&We(e,u);continue}let h=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[([^\\]]+)\\]=(.*)$/s);if(h){u=h[1];let E=h[2],g=X(e,h[3]);if(se(e,u,\"bash\"),!s.has(u)){s.set(u,e.state.env.get(u));let v=`${u}_`;for(let S of e.state.env.keys())S.startsWith(v)&&!S.includes(\"__\")&&(s.has(S)||s.set(S,e.state.env.get(S)));let $=`${u}__length`;e.state.env.has($)&&!s.has($)&&s.set($,e.state.env.get($))}let b;try{let v=new B,$=ee(v,E);b=await H(e,$.expression)}catch{let v=parseInt(E,10);b=Number.isNaN(v)?0:v}e.state.env.set(`${u}_${b}`,g);let m=parseInt(e.state.env.get(`${u}__length`)??\"0\",10);b>=m&&e.state.env.set(`${u}__length`,String(b+1)),Xe(e,u),i&&We(e,u);continue}if(c.includes(\"=\")){let E=c.indexOf(\"=\");u=c.slice(0,E),f=X(e,c.slice(E+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \\`${c}': not a valid identifier\n`,n=1;continue}let w=s.has(u);if(f!==void 0){let E=e.state.env.get(u);if(e.state.tempEnvBindings){let g=e.state.accessedTempEnvVars?.has(u),b=e.state.mutatedTempEnvVars?.has(u);if(!g&&!b)for(let m=e.state.tempEnvBindings.length-1;m>=0;m--){let v=e.state.tempEnvBindings[m];if(v.has(u)){E=v.get(u);break}}}Mn(e,u,E)}if(!w){let E=e.state.env.get(u);if(e.state.tempEnvBindings)for(let g=e.state.tempEnvBindings.length-1;g>=0;g--){let b=e.state.tempEnvBindings[g];if(b.has(u)){E=b.get(u);break}}if(s.set(u,E),o){let g=`${u}_`;for(let m of e.state.env.keys())m.startsWith(g)&&!m.includes(\"__\")&&(s.has(m)||s.set(m,e.state.env.get(m)));let b=`${u}__length`;e.state.env.has(b)&&!s.has(b)&&s.set(b,e.state.env.get(b))}}if(o&&f===void 0){let E=`${u}_`;for(let g of e.state.env.keys())g.startsWith(E)&&!g.includes(\"__\")&&e.state.env.delete(g);e.state.env.set(`${u}__length`,\"0\")}else if(f!==void 0){if(se(e,u,\"bash\"),i&&f!==\"\"&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\\[.+\\])?$/.test(f)){r+=`bash: local: \\`${f}': invalid variable name for name reference\n`,n=1;continue}e.state.env.set(u,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(u))}else{let E=e.state.tempEnvBindings?.some(g=>g.has(u));!w&&!E&&e.state.env.delete(u)}Xe(e,u),i&&We(e,u)}return _(\"\",r,n)}function Nr(e,t,s){let r=`\n`,n=0,i=0,o=0,a=!1,l=\"MAPFILE\",c=0;for(;c<t.length;){let g=t[c];g===\"-d\"&&c+1<t.length?(r=t[c+1]===\"\"?\"\\0\":t[c+1]||`\n`,c+=2):g===\"-n\"&&c+1<t.length?(n=Number.parseInt(t[c+1],10)||0,c+=2):g===\"-O\"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):g===\"-s\"&&c+1<t.length?(o=Number.parseInt(t[c+1],10)||0,c+=2):g===\"-t\"?(a=!0,c++):g===\"-u\"||g===\"-C\"||g===\"-c\"?c+=2:(g.startsWith(\"-\")||(l=g),c++)}let u=s;!u&&e.state.groupStdin!==void 0&&(u=e.state.groupStdin);let f=[],d=u,p=0,y=0,h=e.limits?.maxArrayElements??1e5;for(;d.length>0;){let g=d.indexOf(r);if(g===-1){if(d.length>0){if(y<o)y++;else if(n===0||p<n){if(i+p>=h)return _(\"\",`mapfile: array element limit exceeded (${h})\n`,1);let v=d,$=v.indexOf(\"\\0\");$!==-1&&(v=v.substring(0,$)),f.push(v),p++}}break}let b=d.substring(0,g),m=b.indexOf(\"\\0\");if(m!==-1&&(b=b.substring(0,m)),!a&&r!==\"\\0\"&&(b+=r),d=d.substring(g+r.length),y<o){y++;continue}if(n>0&&p>=n)break;if(i+p>=h)return _(\"\",`mapfile: array element limit exceeded (${h})\n`,1);f.push(b),p++}i===0&&Oe(e,l);for(let g=0;g<f.length;g++)e.state.env.set(`${l}_${i+g}`,f[g]);let w=parseInt(e.state.env.get(`${l}__length`)||\"0\",10),E=i+f.length;return e.state.env.set(`${l}__length`,String(Math.max(w,E))),e.state.groupStdin!==void 0&&!s&&(e.state.groupStdin=\"\"),_(\"\",\"\",0)}function ca(e){if(!e.startsWith(\"__rw__:\"))return null;let t=e.slice(7),s=t.indexOf(\":\");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+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 ua(e,t,s){return`__rw__:${e.length}:${e}:${t}:${s}`}function Or(e,t,s,r=-1){let n=!1,i=`\n`,o=\"\",a=-1,l=-1,c=null,u=-1,f=-1,d=[],p=0,y=!1,h=(k,C)=>{let D=1;for(;D<k.length;){let P=k[D];if(P===\"r\")n=!0,D++;else if(P===\"s\")D++;else{if(P===\"d\")return D+1<k.length?(i=k.substring(D+1),{nextArgIndex:C+1}):C+1<t.length?(i=t[C+1],{nextArgIndex:C+2}):{nextArgIndex:C+1};if(P===\"n\"){if(D+1<k.length){let R=k.substring(D+1);return a=Number.parseInt(R,10),(Number.isNaN(a)||a<0)&&(y=!0,a=0),{nextArgIndex:C+1}}else if(C+1<t.length)return a=Number.parseInt(t[C+1],10),(Number.isNaN(a)||a<0)&&(y=!0,a=0),{nextArgIndex:C+2};return{nextArgIndex:C+1}}else if(P===\"N\"){if(D+1<k.length){let R=k.substring(D+1);return l=Number.parseInt(R,10),(Number.isNaN(l)||l<0)&&(y=!0,l=0),{nextArgIndex:C+1}}else if(C+1<t.length)return l=Number.parseInt(t[C+1],10),(Number.isNaN(l)||l<0)&&(y=!0,l=0),{nextArgIndex:C+2};return{nextArgIndex:C+1}}else{if(P===\"a\")return D+1<k.length?(c=k.substring(D+1),{nextArgIndex:C+1}):C+1<t.length?(c=t[C+1],{nextArgIndex:C+2}):{nextArgIndex:C+1};if(P===\"p\")return D+1<k.length?(o=k.substring(D+1),{nextArgIndex:C+1}):C+1<t.length?(o=t[C+1],{nextArgIndex:C+2}):{nextArgIndex:C+1};if(P===\"u\"){if(D+1<k.length){let R=k.substring(D+1);return u=Number.parseInt(R,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:C+1}}else if(C+1<t.length)return u=Number.parseInt(t[C+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:C+2};return{nextArgIndex:C+1}}else if(P===\"t\"){if(D+1<k.length){let R=k.substring(D+1);return f=Number.parseFloat(R),Number.isNaN(f)&&(f=0),{nextArgIndex:C+1}}else if(C+1<t.length)return f=Number.parseFloat(t[C+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:C+2};return{nextArgIndex:C+1}}else if(P===\"e\"||P===\"i\"||P===\"P\"){if(P===\"i\"&&C+1<t.length)return{nextArgIndex:C+2};D++}else D++}}}return{nextArgIndex:C+1}};for(;p<t.length;){let k=t[p];if(k.startsWith(\"-\")&&k.length>1&&k!==\"--\"){let C=h(k,p);if(C.nextArgIndex===-1)return{stdout:\"\",stderr:\"\",exitCode:2};if(C.nextArgIndex===-2)return{stdout:\"\",stderr:\"\",exitCode:1};p=C.nextArgIndex}else if(k===\"--\")for(p++;p<t.length;)d.push(t[p]),p++;else d.push(k),p++}if(y)return _(\"\",\"\",1);if(d.length===0&&c===null&&d.push(\"REPLY\"),f===0){if(c)Oe(e,c);else{for(let k of d)e.state.env.set(k,\"\");d.length===0&&e.state.env.set(\"REPLY\",\"\")}return _(\"\",\"\",0)}if(f<0&&f!==-1)return _(\"\",\"\",1);let w=s;u>=0?e.state.fileDescriptors?w=e.state.fileDescriptors.get(u)||\"\":w=\"\":!w&&e.state.groupStdin!==void 0&&(w=e.state.groupStdin);let E=i===\"\"?\"\\0\":i,g=\"\",b=0,m=!0,v=k=>{if(u>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(u,w.substring(k));else if(r>=0&&e.state.fileDescriptors){let C=e.state.fileDescriptors.get(r);if(C?.startsWith(\"__rw__:\")){let D=ca(C);if(D){let P=D.position+k;e.state.fileDescriptors.set(r,ua(D.path,P,D.content))}}}else e.state.groupStdin!==void 0&&!s&&(e.state.groupStdin=w.substring(k))};if(l>=0){let k=Math.min(l,w.length);g=w.substring(0,k),b=k,m=k>=l,v(b);let C=d[0]||\"REPLY\";e.state.env.set(C,g);for(let D=1;D<d.length;D++)e.state.env.set(d[D],\"\");return _(\"\",\"\",m?0:1)}else if(a>=0){let k=0,C=0,D=!1;for(;C<w.length&&k<a;){let P=w[C];if(P===E){b=C+1,D=!0;break}if(!n&&P===\"\\\\\"&&C+1<w.length){let R=w[C+1];if(R===E&&E===`\n`){C+=2,b=C;continue}if(R===E){C+=2,k++,g+=R,b=C;continue}g+=R,C+=2,k++,b=C}else g+=P,C++,k++,b=C}m=k>=a||D,v(b)}else{b=0;let k=0;for(;k<w.length;){let C=w[k];if(C===E){b=k+E.length,m=!0;break}if(!n&&C===\"\\\\\"&&k+1<w.length){let D=w[k+1];if(D===`\n`){k+=2;continue}if(D===E){g+=D,k+=2;continue}g+=C,g+=D,k+=2;continue}g+=C,k++}if(k>=w.length&&(m=!1,b=k,g.length===0&&w.length===0)){for(let C of d)e.state.env.set(C,\"\");return c&&Oe(e,c),_(\"\",\"\",1)}v(b)}E===`\n`&&g.endsWith(`\n`)&&(g=g.slice(0,-1));let $=k=>n?k:k.replace(/\\\\(.)/g,\"$1\");if(d.length===1&&d[0]===\"REPLY\")return e.state.env.set(\"REPLY\",$(g)),_(\"\",\"\",m?0:1);let S=Jr(e.state.env);if(c){let{words:k}=zs(g,S,void 0,n),C=e.limits?.maxArrayElements??1e5;if(k.length>C)return _(\"\",`read: array element limit exceeded (${C})\n`,1);Oe(e,c);for(let D=0;D<k.length;D++)e.state.env.set(`${c}_${D}`,$(k[D]));return _(\"\",\"\",m?0:1)}let T=d.length,{words:N,wordStarts:F}=zs(g,S,T,n);for(let k=0;k<d.length;k++){let C=d[k];if(k<d.length-1)e.state.env.set(C,$(N[k]??\"\"));else if(k<F.length){let D=g.substring(F[k]);D=en(D,S,n),D=$(D),e.state.env.set(C,D)}else e.state.env.set(C,\"\")}return _(\"\",\"\",m?0:1)}function xr(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return A(\"bash: return: can only `return' from a function or sourced script\\n\");let s=e.state.lastExitCode;if(t.length>0){let r=t[0],n=Number.parseInt(r,10);if(r===\"\"||Number.isNaN(n)||!/^-?\\d+$/.test(r))return A(`bash: return: ${r}: numeric argument required\n`,2);s=(n%256+256)%256}throw new ue(s)}var bs=`set: usage: set [-eux] [+eux] [-o option] [+o option]\nOptions:\n -e Exit immediately if a command exits with non-zero status\n +e Disable -e\n -u Treat unset variables as an error when substituting\n +u Disable -u\n -x Print commands and their arguments as they are executed\n +x Disable -x\n -o errexit Same as -e\n +o errexit Disable errexit\n -o nounset Same as -u\n +o nounset Disable nounset\n -o pipefail Return status of last failing command in pipeline\n +o pipefail Disable pipefail\n -o xtrace Same as -x\n +o xtrace Disable xtrace\n`,ti=new Map([[\"e\",\"errexit\"],[\"u\",\"nounset\"],[\"x\",\"xtrace\"],[\"v\",\"verbose\"],[\"f\",\"noglob\"],[\"C\",\"noclobber\"],[\"a\",\"allexport\"],[\"n\",\"noexec\"],[\"h\",null],[\"b\",null],[\"m\",null],[\"B\",null],[\"H\",null],[\"P\",null],[\"T\",null],[\"E\",null],[\"p\",null]]),si=new Map([[\"errexit\",\"errexit\"],[\"pipefail\",\"pipefail\"],[\"nounset\",\"nounset\"],[\"xtrace\",\"xtrace\"],[\"verbose\",\"verbose\"],[\"noclobber\",\"noclobber\"],[\"noglob\",\"noglob\"],[\"allexport\",\"allexport\"],[\"noexec\",\"noexec\"],[\"posix\",\"posix\"],[\"vi\",\"vi\"],[\"emacs\",\"emacs\"],[\"notify\",null],[\"monitor\",null],[\"braceexpand\",null],[\"histexpand\",null],[\"physical\",null],[\"functrace\",null],[\"errtrace\",null],[\"privileged\",null],[\"hashall\",null],[\"ignoreeof\",null],[\"interactive-comments\",null],[\"keyword\",null],[\"onecmd\",null]]),ri=[\"errexit\",\"nounset\",\"pipefail\",\"verbose\",\"xtrace\",\"posix\",\"allexport\",\"noclobber\",\"noglob\",\"noexec\",\"vi\",\"emacs\"],ni=[\"braceexpand\",\"errtrace\",\"functrace\",\"hashall\",\"histexpand\",\"history\",\"ignoreeof\",\"interactive-comments\",\"keyword\",\"monitor\",\"nolog\",\"notify\",\"onecmd\",\"physical\",\"privileged\"];function ii(e,t,s){t!==null&&(s&&(t===\"vi\"?e.state.options.emacs=!1:t===\"emacs\"&&(e.state.options.vi=!1)),e.state.options[t]=s,dt(e))}function fa(e,t){return t+1<e.length&&!e[t+1].startsWith(\"-\")&&!e[t+1].startsWith(\"+\")}function da(e,t){let s=ne(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=e.state.env.get(`${t}_${n}`)??\"\";return`[${n}]=${nt(i)}`});return`${t}=(${r.join(\" \")})`}function ha(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`\"${e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\"/g,'\\\\\"')}\"`}function pa(e,t){let s=He(e,t);if(s.length===0)return`${t}=()`;let r=s.map(n=>{let i=e.state.env.get(`${t}_${n}`)??\"\";return`[${ha(n)}]=${nt(i)}`});return`${t}=(${r.join(\" \")} )`}function ma(e){let t=new Set,s=e.state.associativeArrays??new Set;for(let r of e.state.env.keys()){let n=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\\d+)$/);if(n){let i=n[1];s.has(i)||t.add(i)}}return t}function ya(e){return e.state.associativeArrays??new Set}function Dr(e,t){if(t.includes(\"--help\"))return z(bs);if(t.length===0){let r=ma(e),n=ya(e),i=l=>{for(let c of n){let u=`${c}_`,f=`${c}__length`;if(l!==f&&l.startsWith(u)){if(l.slice(u.length).startsWith(\"_length\"))continue;return!0}}return!1},o=[];for(let[l,c]of e.state.env){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)||r.has(l)||n.has(l))continue;let u=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\\d+)$/);if(u&&r.has(u[1]))continue;let f=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&r.has(f[1])||i(l)||f&&n.has(f[1])||o.push([l,c])}let a=[];for(let[l,c]of o.sort(([u],[f])=>u<f?-1:u>f?1:0))a.push(`${l}=${gs(c)}`);for(let l of[...r].sort((c,u)=>c<u?-1:c>u?1:0))a.push(da(e,l));for(let l of[...n].sort((c,u)=>c<u?-1:c>u?1:0))a.push(pa(e,l));return a.sort((l,c)=>{let u=l.split(\"=\")[0],f=c.split(\"=\")[0];return u<f?-1:u>f?1:0}),z(a.length>0?`${a.join(`\n`)}\n`:\"\")}let s=0;for(;s<t.length;){let r=t[s];if((r===\"-o\"||r===\"+o\")&&fa(t,s)){let n=t[s+1];if(!si.has(n)){let i=`bash: set: ${n}: invalid option name\n${bs}`;if(e.state.options.posix)throw new Pe(1,\"\",i);return A(i)}ii(e,si.get(n)??null,r===\"-o\"),s+=2;continue}if(r===\"-o\"){let n=ri.map(a=>`${a.padEnd(16)}${e.state.options[a]?\"on\":\"off\"}`),i=ni.map(a=>`${a.padEnd(16)}off`),o=[...n,...i].sort();return z(`${o.join(`\n`)}\n`)}if(r===\"+o\"){let n=ri.map(a=>`set ${e.state.options[a]?\"-o\":\"+o\"} ${a}`),i=ni.map(a=>`set +o ${a}`),o=[...n,...i].sort();return z(`${o.join(`\n`)}\n`)}if(r.length>1&&(r[0]===\"-\"||r[0]===\"+\")&&r[1]!==\"-\"){let n=r[0]===\"-\";for(let i=1;i<r.length;i++){let o=r[i];if(!ti.has(o)){let a=`bash: set: ${r[0]}${o}: invalid option\n${bs}`;if(e.state.options.posix)throw new Pe(1,\"\",a);return A(a)}ii(e,ti.get(o)??null,n)}s++;continue}if(r===\"--\")return Tr(e,t.slice(s+1)),W;if(r===\"-\"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,dt(e),s+1<t.length)return Tr(e,t.slice(s+1)),W;s++;continue}if(r===\"+\"){s++;continue}if(r.startsWith(\"-\")||r.startsWith(\"+\")){let n=`bash: set: ${r}: invalid option\n${bs}`;if(e.state.options.posix)throw new Pe(1,\"\",n);return A(n)}return Tr(e,t.slice(s)),W}return W}function Tr(e,t){let s=1;for(;e.state.env.has(String(s));)e.state.env.delete(String(s)),s++;for(let r=0;r<t.length;r++)e.state.env.set(String(r+1),t[r]);e.state.env.set(\"#\",String(t.length)),e.state.env.set(\"@\",t.join(\" \")),e.state.env.set(\"*\",t.join(\" \"))}function Rr(e,t){let s=1;if(t.length>0){let o=Number.parseInt(t[0],10);if(Number.isNaN(o)||o<0){let a=`bash: shift: ${t[0]}: numeric argument required\n`;if(e.state.options.posix)throw new Pe(1,\"\",a);return A(a)}s=o}let r=Number.parseInt(e.state.env.get(\"#\")||\"0\",10);if(s>r){let o=`bash: shift: shift count out of range\n`;if(e.state.options.posix)throw new Pe(1,\"\",o);return A(o)}if(s===0)return W;let n=[];for(let o=1;o<=r;o++)n.push(e.state.env.get(String(o))||\"\");let i=n.slice(s);for(let o=1;o<=r;o++)e.state.env.delete(String(o));for(let o=0;o<i.length;o++)e.state.env.set(String(o+1),i[o]);return e.state.env.set(\"#\",String(i.length)),e.state.env.set(\"@\",i.join(\" \")),W}async function Ir(e,t){let s=t;if(s.length>0&&s[0]===\"--\"&&(s=s.slice(1)),s.length===0)return _(\"\",`bash: source: filename argument required\n`,2);let r=s[0],n=null,i=null;if(r.includes(\"/\")){let c=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(c),n=c}catch{}}else{let u=(e.state.env.get(\"PATH\")||\"\").split(\":\").filter(f=>f);for(let f of u){let d=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(d)).isDirectory)continue;i=await e.fs.readFile(d),n=d;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(f),n=f}catch{}}}if(i===null)return A(`bash: ${r}: No such file or directory\n`);let o=new Map;if(s.length>1){for(let u=1;u<=9;u++)o.set(String(u),e.state.env.get(String(u)));o.set(\"#\",e.state.env.get(\"#\")),o.set(\"@\",e.state.env.get(\"@\"));let c=s.slice(1);e.state.env.set(\"#\",String(c.length)),e.state.env.set(\"@\",c.join(\" \"));for(let u=0;u<c.length&&u<9;u++)e.state.env.set(String(u+1),c[u]);for(let u=c.length+1;u<=9;u++)e.state.env.delete(String(u))}let a=e.state.currentSource,l=()=>{if(e.state.sourceDepth--,e.state.currentSource=a,s.length>1)for(let[c,u]of o)u===void 0?e.state.env.delete(c):e.state.env.set(c,u)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new J(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,\"recursion\");e.state.currentSource=r;try{let c=fe(i),u=await e.executeScript(c);return l(),u}catch(c){if(l(),c instanceof j)throw c;if(c instanceof ue)return _(c.stdout,c.stderr,c.exitCode);if(c.name===\"ParseException\")return A(`bash: ${r}: ${c.message}\n`);throw c}}function oi(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function ga(e){return e.startsWith(\"'\")&&e.endsWith(\"'\")||e.startsWith('\"')&&e.endsWith('\"')}async function ai(e,t){if(ga(t))return null;try{let s=new B,r=ee(s,t);return await H(e,r.expression)}catch{let s=parseInt(t,10);return Number.isNaN(s)?0:s}}function li(e,t){if(e.state.localVarStack?.has(t)){let r=ps(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let n=e.state.localVarStack?.get(t);if(!n||n.length===0)hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),Lr(e,t);else{let i=n[n.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),hs(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let n=e.state.localScopes[r];if(n.has(t)){let i=n.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),n.delete(t);let 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||hs(e,t),!0}}return!1}function Lr(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let s=e.state.tempEnvBindings.length-1;s>=0;s--){let r=e.state.tempEnvBindings[s];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function ci(e,t){if(t.startsWith(\"'\")&&t.endsWith(\"'\"))return t.slice(1,-1);if(t.startsWith('\"')&&t.endsWith('\"')){let s=t.slice(1,-1),n=new B().parseWordFromString(s,!0,!1);return L(e,n)}if(t.includes(\"$\")){let r=new B().parseWordFromString(t,!1,!1);return L(e,r)}return t}async function Fr(e,t){let s=\"both\",r=\"\",n=0;for(let i of t){if(i===\"-v\"){s=\"variable\";continue}if(i===\"-f\"){s=\"function\";continue}if(s===\"function\"){e.state.functions.delete(i);continue}if(s===\"variable\"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(c){let d=c[1],p=c[2];if(p===\"@\"||p===\"*\"){let b=Ae(e,d);for(let[m]of b)e.state.env.delete(`${d}_${m}`);e.state.env.delete(d);continue}let y=e.state.associativeArrays?.has(d);if(y){let b=await ci(e,p);e.state.env.delete(`${d}_${b}`);continue}let h=js(e,d),w=e.state.declaredVars?.has(d);if((e.state.env.has(d)||w)&&!h&&!y){r+=`bash: unset: ${d}: not an array variable\n`,n=1;continue}let g=await ai(e,p);if(g===null&&h){r+=`bash: unset: ${p}: not a valid identifier\n`,n=1;continue}if(g===null)continue;if(g<0){let b=Ae(e,d),m=b.length,v=e.state.currentLine;if(m===0){r+=`bash: line ${v}: unset: [${g}]: bad array subscript\n`,n=1;continue}let $=m+g;if($<0){r+=`bash: line ${v}: unset: [${g}]: bad array subscript\n`,n=1;continue}let S=b[$][0];e.state.env.delete(`${d}_${S}`);continue}e.state.env.delete(`${d}_${g}`);continue}if(!oi(i)){r+=`bash: unset: \\`${i}': not a valid identifier\n`,n=1;continue}let u=i;if(Ee(e,i)){let d=Ze(e,i);d&&d!==i&&(u=d)}if(et(e,u)){r+=`bash: unset: ${u}: cannot unset: readonly variable\n`,n=1;continue}let f=pt(e,u);if(f!==void 0&&f!==e.state.callDepth)li(e,u);else if(e.state.fullyUnsetLocals?.has(u))e.state.env.delete(u);else if(f!==void 0){let d=e.state.accessedTempEnvVars?.has(u),p=e.state.mutatedTempEnvVars?.has(u);if((d||p)&&e.state.localVarStack?.has(u)){let y=ps(e,u);y?y.value===void 0?e.state.env.delete(u):e.state.env.set(u,y.value):e.state.env.delete(u)}else e.state.env.delete(u)}else Lr(e,u)||e.state.env.delete(u);e.state.exportedVars?.delete(u);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(o){let c=o[1],u=o[2];if(u===\"@\"||u===\"*\"){let h=Ae(e,c);for(let[w]of h)e.state.env.delete(`${c}_${w}`);e.state.env.delete(c);continue}let f=e.state.associativeArrays?.has(c);if(f){let h=await ci(e,u);e.state.env.delete(`${c}_${h}`);continue}let d=js(e,c);if(e.state.env.has(c)&&!d&&!f){r+=`bash: unset: ${c}: not an array variable\n`,n=1;continue}let y=await ai(e,u);if(y===null&&d){r+=`bash: unset: ${u}: not a valid identifier\n`,n=1;continue}if(y===null)continue;if(y<0){let h=Ae(e,c),w=h.length,E=e.state.currentLine;if(w===0){r+=`bash: line ${E}: unset: [${y}]: bad array subscript\n`,n=1;continue}let g=w+y;if(g<0){r+=`bash: line ${E}: unset: [${y}]: bad array subscript\n`,n=1;continue}let b=h[g][0];e.state.env.delete(`${c}_${b}`);continue}e.state.env.delete(`${c}_${y}`);continue}if(!oi(i)){r+=`bash: unset: \\`${i}': not a valid identifier\n`,n=1;continue}let a=i;if(Ee(e,i)){let c=Ze(e,i);c&&c!==i&&(a=c)}if(et(e,a)){r+=`bash: unset: ${a}: cannot unset: readonly variable\n`,n=1;continue}let l=pt(e,a);if(l!==void 0&&l!==e.state.callDepth)li(e,a);else if(e.state.fullyUnsetLocals?.has(a))e.state.env.delete(a);else if(l!==void 0){let c=e.state.accessedTempEnvVars?.has(a),u=e.state.mutatedTempEnvVars?.has(a);if((c||u)&&e.state.localVarStack?.has(a)){let f=ps(e,a);f?f.value===void 0?e.state.env.delete(a):e.state.env.set(a,f.value):e.state.env.delete(a)}else e.state.env.delete(a)}else Lr(e,a)||e.state.env.delete(a);e.state.exportedVars?.delete(a),e.state.functions.delete(i)}return _(\"\",r,n)}var Mr=[\"extglob\",\"dotglob\",\"nullglob\",\"failglob\",\"globstar\",\"globskipdots\",\"nocaseglob\",\"nocasematch\",\"expand_aliases\",\"lastpipe\",\"xpg_echo\"],wa=[\"autocd\",\"cdable_vars\",\"cdspell\",\"checkhash\",\"checkjobs\",\"checkwinsize\",\"cmdhist\",\"compat31\",\"compat32\",\"compat40\",\"compat41\",\"compat42\",\"compat43\",\"compat44\",\"complete_fullquote\",\"direxpand\",\"dirspell\",\"execfail\",\"extdebug\",\"extquote\",\"force_fignore\",\"globasciiranges\",\"gnu_errfmt\",\"histappend\",\"histreedit\",\"histverify\",\"hostcomplete\",\"huponexit\",\"inherit_errexit\",\"interactive_comments\",\"lithist\",\"localvar_inherit\",\"localvar_unset\",\"login_shell\",\"mailwarn\",\"no_empty_cmd_completion\",\"progcomp\",\"progcomp_alias\",\"promptvars\",\"restricted_shell\",\"shift_verbose\",\"sourcepath\"];function Es(e){return Mr.includes(e)}function va(e){return wa.includes(e)}function ui(e,t){let s=!1,r=!1,n=!1,i=!1,o=!1,a=[],l=0;for(;l<t.length;){let d=t[l];if(d===\"--\"){l++;break}if(d.startsWith(\"-\")&&d.length>1){for(let p=1;p<d.length;p++){let y=d[p];switch(y){case\"s\":s=!0;break;case\"u\":r=!0;break;case\"p\":n=!0;break;case\"q\":i=!0;break;case\"o\":o=!0;break;default:return{exitCode:2,stdout:\"\",stderr:`shopt: -${y}: invalid option\n`}}}l++}else break}for(;l<t.length;)a.push(t[l]),l++;if(o)return ba(e,a,s,r,n,i);if(s&&r)return{exitCode:1,stdout:\"\",stderr:`shopt: cannot set and unset shell options simultaneously\n`};if(a.length===0){if(s||r){let p=[];for(let y of Mr){let h=e.state.shoptOptions[y];s&&h?p.push(n?`shopt -s ${y}`:`${y}\t\ton`):r&&!h&&p.push(n?`shopt -u ${y}`:`${y}\t\toff`)}return{exitCode:0,stdout:p.length>0?`${p.join(`\n`)}\n`:\"\",stderr:\"\"}}let d=[];for(let p of Mr){let y=e.state.shoptOptions[p];d.push(n?`shopt ${y?\"-s\":\"-u\"} ${p}`:`${p}\t\t${y?\"on\":\"off\"}`)}return{exitCode:0,stdout:`${d.join(`\n`)}\n`,stderr:\"\"}}let c=!1,u=\"\",f=[];for(let d of a){if(!Es(d)&&!va(d)){u+=`shopt: ${d}: invalid shell option name\n`,c=!0;continue}if(s)Es(d)&&(e.state.shoptOptions[d]=!0,Gs(e));else if(r)Es(d)&&(e.state.shoptOptions[d]=!1,Gs(e));else if(Es(d)){let p=e.state.shoptOptions[d];i?p||(c=!0):n?(f.push(`shopt ${p?\"-s\":\"-u\"} ${d}`),p||(c=!0)):(f.push(`${d}\t\t${p?\"on\":\"off\"}`),p||(c=!0))}else i?c=!0:n?(f.push(`shopt -u ${d}`),c=!0):(f.push(`${d}\t\toff`),c=!0)}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`\n`)}\n`:\"\",stderr:u}}function ba(e,t,s,r,n,i){let o=new Map([[\"errexit\",\"errexit\"],[\"pipefail\",\"pipefail\"],[\"nounset\",\"nounset\"],[\"xtrace\",\"xtrace\"],[\"verbose\",\"verbose\"],[\"posix\",\"posix\"],[\"allexport\",\"allexport\"],[\"noclobber\",\"noclobber\"],[\"noglob\",\"noglob\"],[\"noexec\",\"noexec\"],[\"vi\",\"vi\"],[\"emacs\",\"emacs\"]]),a=[\"braceexpand\",\"errtrace\",\"functrace\",\"hashall\",\"histexpand\",\"history\",\"ignoreeof\",\"interactive-comments\",\"keyword\",\"monitor\",\"nolog\",\"notify\",\"onecmd\",\"physical\",\"privileged\"],l=[...o.keys(),...a].sort();if(t.length===0){let d=[];for(let p of l){let y=a.includes(p),h=o.get(p),w=y||!h?!1:e.state.options[h];s&&!w||r&&w||d.push(n?`set ${w?\"-o\":\"+o\"} ${p}`:`${p}\t\t${w?\"on\":\"off\"}`)}return{exitCode:0,stdout:d.length>0?`${d.join(`\n`)}\n`:\"\",stderr:\"\"}}let c=!1,u=\"\",f=[];for(let d of t){let p=o.has(d),y=a.includes(d);if(!p&&!y){u+=`shopt: ${d}: invalid option name\n`,c=!0;continue}if(y){s||r||(i?c=!0:n?(f.push(`set +o ${d}`),c=!0):(f.push(`${d}\t\toff`),c=!0));continue}let h=o.get(d);if(h)if(s)h===\"vi\"?e.state.options.emacs=!1:h===\"emacs\"&&(e.state.options.vi=!1),e.state.options[h]=!0,dt(e);else if(r)e.state.options[h]=!1,dt(e);else{let w=e.state.options[h];i?w||(c=!0):n?(f.push(`set ${w?\"-o\":\"+o\"} ${d}`),w||(c=!0)):(f.push(`${d}\t\t${w?\"on\":\"off\"}`),w||(c=!0))}}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`\n`)}\n`:\"\",stderr:u}}async function fi(e,t,s){if(t.includes(\"/\")){let o=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(o))return{error:\"not_found\",path:o};let a=o.split(\"/\").pop()||t,l=e.commands.get(a);try{let c=await e.fs.stat(o);return c.isDirectory?{error:\"permission_denied\",path:o}:l?{cmd:l,path:o}:(c.mode&73)!==0?{script:!0,path:o}:{error:\"permission_denied\",path:o}}catch{return{error:\"not_found\",path:o}}}if(!s&&e.state.hashTable){let o=e.state.hashTable.get(t);if(o)if(await e.fs.exists(o)){let a=e.commands.get(t);if(a)return{cmd:a,path:o};try{let l=await e.fs.stat(o);if(!l.isDirectory&&(l.mode&73)!==0)return{script:!0,path:o}}catch{}}else e.state.hashTable.delete(t)}let n=(s??e.state.env.get(\"PATH\")??\"/usr/bin:/bin\").split(\":\");for(let o of n){if(!o)continue;let l=`${o.startsWith(\"/\")?o:e.fs.resolvePath(e.state.cwd,o)}/${t}`;if(await e.fs.exists(l))try{let c=await e.fs.stat(l);if(c.isDirectory)continue;let u=(c.mode&73)!==0,f=e.commands.get(t),d=o===\"/bin\"||o===\"/usr/bin\";if(f&&d)return{cmd:f,path:l};if(u){if(f&&!d)return{script:!0,path:l};if(!f)return{script:!0,path:l}}}catch{}}if(!await e.fs.exists(\"/usr/bin\")){let o=e.commands.get(t);if(o)return{cmd:o,path:`/usr/bin/${t}`}}return null}async function $s(e,t){let s=[];if(t.includes(\"/\")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let o=await e.fs.stat(i);o.isDirectory||(o.mode&73)!==0&&s.push(t)}catch{}return s}let n=(e.state.env.get(\"PATH\")||\"/usr/bin:/bin\").split(\":\");for(let i of n){if(!i)continue;let a=`${i.startsWith(\"/\")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}s.push(i.startsWith(\"/\")?a:`${i}/${t}`)}}return s}function Ea(e){return e!==null&&typeof e==\"object\"&&\"then\"in e&&typeof e.then==\"function\"}function G(e,t,s,r){return((...n)=>{_t(t,s,`${r} call`);let i=e(...n);return Ea(i)?i.then(o=>(_t(t,s,`${r} post-await`),o),o=>{throw _t(t,s,`${r} post-await`),o}):(_t(t,s,`${r} return`),i)})}function $a(e,t,s){let r={readFile:G(e.readFile.bind(e),t,s,\"fs.readFile\"),...typeof e.readFileBytes==\"function\"?{readFileBytes:G(e.readFileBytes.bind(e),t,s,\"fs.readFileBytes\")}:Object.create(null),readFileBuffer:G(e.readFileBuffer.bind(e),t,s,\"fs.readFileBuffer\"),writeFile:G(e.writeFile.bind(e),t,s,\"fs.writeFile\"),appendFile:G(e.appendFile.bind(e),t,s,\"fs.appendFile\"),exists:G(e.exists.bind(e),t,s,\"fs.exists\"),stat:G(e.stat.bind(e),t,s,\"fs.stat\"),mkdir:G(e.mkdir.bind(e),t,s,\"fs.mkdir\"),readdir:G(e.readdir.bind(e),t,s,\"fs.readdir\"),rm:G(e.rm.bind(e),t,s,\"fs.rm\"),cp:G(e.cp.bind(e),t,s,\"fs.cp\"),mv:G(e.mv.bind(e),t,s,\"fs.mv\"),resolvePath:G(e.resolvePath.bind(e),t,s,\"fs.resolvePath\"),getAllPaths:G(e.getAllPaths.bind(e),t,s,\"fs.getAllPaths\"),chmod:G(e.chmod.bind(e),t,s,\"fs.chmod\"),symlink:G(e.symlink.bind(e),t,s,\"fs.symlink\"),link:G(e.link.bind(e),t,s,\"fs.link\"),readlink:G(e.readlink.bind(e),t,s,\"fs.readlink\"),lstat:G(e.lstat.bind(e),t,s,\"fs.lstat\"),realpath:G(e.realpath.bind(e),t,s,\"fs.realpath\"),utimes:G(e.utimes.bind(e),t,s,\"fs.utimes\")};return e.readdirWithFileTypes&&(r.readdirWithFileTypes=G(e.readdirWithFileTypes.bind(e),t,s,\"fs.readdirWithFileTypes\")),r}function di(e,t){if(!e.requireDefenseContext)return e;let s=`command:${t}`,r={...e,fs:$a(e.fs,e.requireDefenseContext,s)};return e.exec&&(r.exec=G(e.exec,e.requireDefenseContext,s,\"exec\")),e.fetch&&(r.fetch=G(e.fetch,e.requireDefenseContext,s,\"fetch\")),e.sleep&&(r.sleep=G(e.sleep,e.requireDefenseContext,s,\"sleep\")),e.getRegisteredCommands&&(r.getRegisteredCommands=G(e.getRegisteredCommands,e.requireDefenseContext,s,\"getRegisteredCommands\")),r}async function yi(e,t,s,r){let n=!1,i=!1,o=!1,a=!1,l=!1,c=[];for(let h of t)if(h.startsWith(\"-\")&&h.length>1)for(let w of h.slice(1))w===\"t\"?n=!0:w===\"p\"?i=!0:w===\"P\"?o=!0:w===\"a\"?a=!0:w===\"f\"&&(l=!0);else c.push(h);let u=\"\",f=\"\",d=0,p=!1,y=!1;for(let h of c){let w=!1;if(o){if(a){let $=await r(h);if($.length>0){for(let S of $)u+=`${S}\n`;p=!0,w=!0}}else{let $=await s(h);$&&(u+=`${$}\n`,p=!0,w=!0)}w||(y=!0);continue}let E=!l&&e.state.functions.has(h);if(a&&E){if(!i)if(n)u+=`function\n`;else{let $=e.state.functions.get(h),S=$?hi(h,$):`${h} is a function\n`;u+=S}w=!0}let g=e.state.env.get(`BASH_ALIAS_${h}`);if(g!==void 0&&(a||!w)&&(i||(n?u+=`alias\n`:u+=`${h} is aliased to \\`${g}'\n`),w=!0,!a)||sr.has(h)&&(a||!w)&&(i||(n?u+=`keyword\n`:u+=`${h} is a shell keyword\n`),w=!0,!a))continue;if(!a&&E&&!w){if(!i)if(n)u+=`function\n`;else{let $=e.state.functions.get(h),S=$?hi(h,$):`${h} is a function\n`;u+=S}w=!0;continue}if(!(mt.has(h)&&(a||!w)&&(i||(n?u+=`builtin\n`:u+=`${h} is a shell builtin\n`),w=!0,!a))){if(a){let $=await r(h);for(let S of $)i?u+=`${S}\n`:n?u+=`file\n`:u+=`${h} is ${S}\n`,p=!0,w=!0}else if(!w){let $=await s(h);$&&(i?u+=`${$}\n`:n?u+=`file\n`:u+=`${h} is ${$}\n`,p=!0,w=!0)}if(!w&&(y=!0,!n&&!i)){let $=!0;if(h.includes(\"/\")){let S=e.fs.resolvePath(e.state.cwd,h);await e.fs.exists(S)&&($=!1)}$&&(f+=`bash: type: ${h}: not found\n`)}}}return i?d=y&&!p?1:0:d=y?1:0,_(u,f,d)}function hi(e,t){let s;return t.body.type===\"Group\"?s=t.body.body.map(n=>Dt(n)).join(\"; \"):s=Dt(t.body),`${e} is a function\n${e} () \n{ \n ${s}\n}\n`}function Dt(e){if(Array.isArray(e))return e.map(t=>Dt(t)).join(\"; \");if(e.type===\"Statement\"){let t=[];for(let s=0;s<e.pipelines.length;s++){let r=e.pipelines[s];t.push(Sa(r)),e.operators[s]&&t.push(e.operators[s])}return t.join(\" \")}if(e.type===\"SimpleCommand\"){let t=e,s=[];t.name&&s.push(pi(t.name));for(let r of t.args)s.push(pi(r));return s.join(\" \")}return e.type===\"Group\"?`{ ${e.body.map(r=>Dt(r)).join(\"; \")}; }`:\"...\"}function Sa(e){let t=e.commands.map(s=>Dt(s));return(e.negated?\"! \":\"\")+t.join(\" | \")}function pi(e){let t=\"\";for(let s of e.parts)s.type===\"Literal\"?t+=s.value:s.type===\"DoubleQuoted\"?t+=`\"${s.parts.map(r=>mi(r)).join(\"\")}\"`:s.type===\"SingleQuoted\"?t+=`'${s.value}'`:t+=mi(s);return t}function mi(e){let t=e;return t.type===\"Literal\"?t.value??\"\":t.type===\"Variable\"?`$${t.name}`:\"\"}async function gi(e,t,s,r){let n=\"\",i=\"\",o=0;for(let a of t){if(!a){o=1;continue}let l=e.state.env.get(`BASH_ALIAS_${a}`);if(l!==void 0)r?n+=`${a} is an alias for \"${l}\"\n`:n+=`alias ${a}='${l}'\n`;else if(sr.has(a))r?n+=`${a} is a shell keyword\n`:n+=`${a}\n`;else if(mt.has(a))r?n+=`${a} is a shell builtin\n`:n+=`${a}\n`;else if(e.state.functions.has(a))r?n+=`${a} is a function\n`:n+=`${a}\n`;else if(a.includes(\"/\")){let c=e.fs.resolvePath(e.state.cwd,a),u=!1;if(await e.fs.exists(c))try{let f=await e.fs.stat(c);f.isDirectory||(f.mode&73)!==0&&(r?n+=`${a} is ${a}\n`:n+=`${a}\n`,u=!0)}catch{}u||(r&&(i+=`${a}: not found\n`),o=1)}else if(e.commands.has(a)){let u=(e.state.env.get(\"PATH\")??\"/usr/bin:/bin\").split(\":\"),f=null;for(let d of u){if(!d)continue;let p=`${d}/${a}`;try{let y=await e.fs.stat(p);if(!y.isDirectory&&(y.mode&73)!==0){f=p;break}}catch{}}f||(f=`/usr/bin/${a}`),r?n+=`${a} is ${f}\n`:n+=`${f}\n`}else r&&(i+=`${a}: not found\n`),o=1}return _(n,i,o)}async function wi(e,t){if(t.includes(\"/\")){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let i=await e.fs.stat(n);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=(e.state.env.get(\"PATH\")??\"/usr/bin:/bin\").split(\":\");for(let n of r){if(!n)continue;let o=`${n.startsWith(\"/\")?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${n}/${t}`}}if(e.commands.has(t)){for(let n of r)if(n===\"/usr/bin\"||n===\"/bin\")return`${n}/${t}`;return`/usr/bin/${t}`}return null}async function vi(e,t,s,r,n,i,o,a){let{ctx:l,runCommand:c}=e;if(l.coverage&&mt.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t===\"export\")return Pr(l,s);if(t===\"unset\")return Fr(l,s);if(t===\"exit\")return Sr(l,s);if(t===\"local\")return Cr(l,s);if(t===\"set\")return Dr(l,s);if(t===\"break\")return Xs(l,s);if(t===\"continue\")return cr(l,s);if(t===\"return\")return xr(l,s);if(t===\"eval\"&&l.state.options.posix)return ws(l,s,n);if(t===\"shift\")return Rr(l,s);if(t===\"getopts\")return vs(l,s);if(t===\"compgen\")return ir(l,s);if(t===\"complete\")return ar(l,s);if(t===\"compopt\")return lr(l,s);if(t===\"pushd\")return await br(l,s);if(t===\"popd\")return Er(l,s);if(t===\"dirs\")return $r(l,s);if(t===\"source\"||t===\".\")return Ir(l,s);if(t===\"read\")return Or(l,s,n,a);if(t===\"mapfile\"||t===\"readarray\")return Nr(l,s,n);if(t===\"declare\"||t===\"typeset\")return gr(l,s);if(t===\"readonly\")return wr(l,s);if(!i){let u=l.state.functions.get(t);if(u)return ys(l,u,s,n)}if(t===\"eval\")return ws(l,s,n);if(t===\"cd\")return await Ys(l,s);if(t===\":\"||t===\"true\")return W;if(t===\"false\")return Q(!1);if(t===\"let\")return _r(l,s);if(t===\"command\")return Pa(e,s,n);if(t===\"builtin\")return Aa(e,s,n);if(t===\"shopt\")return ui(l,s);if(t===\"exec\"){if(s.length===0)return W;let[u,...f]=s;return c(u,f,[],n,!1,!1,-1)}if(t===\"wait\")return W;if(t===\"type\")return await yi(l,s,u=>wi(l,u),u=>$s(l,u));if(t===\"hash\")return Ar(l,s);if(t===\"help\")return kr(l,s);if(t===\"[\"||t===\"test\"){let u=s;if(t===\"[\"){if(s[s.length-1]!==\"]\")return A(\"[: missing `]'\\n\",2);u=s.slice(0,-1)}return Ot(l,u)}return null}async function Pa(e,t,s){let{ctx:r,runCommand:n}=e;if(t.length===0)return W;let i=!1,o=!1,a=!1,l=t;for(;l.length>0&&l[0].startsWith(\"-\");){let f=l[0];if(f===\"--\"){l=l.slice(1);break}for(let d of f.slice(1))d===\"p\"?i=!0:d===\"V\"?o=!0:d===\"v\"&&(a=!0);l=l.slice(1)}if(l.length===0)return W;if(a||o)return await gi(r,l,a,o);let[c,...u]=l;return n(c,u,[],s,!0,i,-1)}async function Aa(e,t,s){let{runCommand:r}=e;if(t.length===0)return W;let n=t;if(n[0]===\"--\"&&(n=n.slice(1),n.length===0))return W;let i=n[0];if(!mt.has(i))return A(`bash: builtin: ${i}: not a shell builtin\n`);let[,...o]=n;return r(i,o,[],s,!0,!1,-1)}async function bi(e,t,s,r,n){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=e,c=await fi(i,t,n?\"/usr/bin:/bin\":void 0);if(!c)return _n(t)?A(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.\n`,127):A(`bash: ${t}: command not found\n`,127);if(\"error\"in c)return c.error===\"permission_denied\"?A(`bash: ${t}: Permission denied\n`,126):A(`bash: ${t}: No such file or directory\n`,127);if(\"script\"in c)return t.includes(\"/\")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,c.path)),await a(c.path,s,r);let{cmd:u,path:f}=c;t.includes(\"/\")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,f));let d=r||i.state.groupStdin||\"\",p=o(),y={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:p,stdin:d,limits:i.limits,exec:i.execFn,fetch:i.fetch,getRegisteredCommands:()=>Array.from(i.commands.keys()),sleep:i.sleep,trace:i.trace,fileDescriptors:i.state.fileDescriptors,xpgEcho:i.state.shoptOptions.xpg_echo,coverage:i.coverage,signal:i.state.signal,requireDefenseContext:i.requireDefenseContext,jsBootstrapCode:i.jsBootstrapCode,invokeTool:i.invokeTool},h=di(y,t);try{let w=()=>Xr(i.requireDefenseContext,\"command\",`${t} execution`,()=>u.execute(s,h));return u.trusted?await me.runTrustedAsync(()=>w()):await w()}catch(w){if(w instanceof J||w instanceof Ve)throw w;return A(`${t}: ${Le(Ie(w))}\n`)}}async function Wr(e,t){let s=e.state.inCondition;e.state.inCondition=!0;let r=\"\",n=\"\",i=0;try{for(let o of t){let a=await e.executeStatement(o);r+=a.stdout,n+=a.stderr,i=a.exitCode}}finally{e.state.inCondition=s}return{stdout:r,stderr:n,exitCode:i}}function Rt(e,t,s,r){if(e instanceof ye)return t+=e.stdout,s+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:\"rethrow\",stdout:t,stderr:s,error:e}):{action:\"break\",stdout:t,stderr:s};if(e instanceof ge)return t+=e.stdout,s+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=s,{action:\"rethrow\",stdout:t,stderr:s,error:e}):{action:\"continue\",stdout:t,stderr:s};if(e instanceof ue||e instanceof we||e instanceof j||e instanceof J)return e.prependOutput(t,s),{action:\"rethrow\",stdout:t,stderr:s,error:e};let n=Ie(e);return{action:\"error\",stdout:t,stderr:`${s}${n}\n`,exitCode:1}}async function Ss(e,t,s=\"\",r=\"\"){let n=s,i=r,o=0;try{for(let a of t){let l=await e.executeStatement(a);n+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(Zt(a)||a instanceof we||a instanceof j||a instanceof J||a instanceof je)throw a.prependOutput(n,i),a;return{stdout:n,stderr:`${i}${Ie(a)}\n`,exitCode:1}}return{stdout:n,stderr:i,exitCode:o}}async function Ei(e,t){let s=\"\",r=\"\";for(let n of t.clauses){let i=await Wr(e,n.condition);if(s+=i.stdout,r+=i.stderr,i.exitCode===0)return Ss(e,n.body,s,r)}return t.elseBody?Ss(e,t.elseBody,s,r):_(s,r,0)}async function $i(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=\"\",n=\"\",i=0,o=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return A(`bash: \\`${t.variable}': not a valid identifier\n`);let a=[];if(t.words===null)a=(e.state.env.get(\"@\")||\"\").split(\" \").filter(Boolean);else if(t.words.length===0)a=[];else try{for(let c of t.words){let u=await xe(e,c);a.push(...u.values)}}catch(c){if(c instanceof Ut)return{stdout:\"\",stderr:c.stderr,exitCode:1};throw c}e.state.loopDepth++;try{for(let c of a){o++,o>e.limits.maxLoopIterations&&Te(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",r,n),e.state.env.set(t.variable,c);try{for(let u of t.body){let f=await e.executeStatement(u);r+=f.stdout,n+=f.stderr,i=f.exitCode}}catch(u){let f=Rt(u,r,n,e.state.loopDepth);if(r=f.stdout,n=f.stderr,f.action===\"break\")break;if(f.action===\"continue\")continue;if(f.action===\"error\"){let d=_(r,n,f.exitCode??1);return K(e,d,t.redirections)}throw f.error}}}finally{e.state.loopDepth--}let l=_(r,n,i);return K(e,l,t.redirections)}async function Si(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=t.line;r!==void 0&&(e.state.currentLine=r);let n=\"\",i=\"\",o=0,a=0;t.init&&await H(e,t.init.expression),e.state.loopDepth++;try{for(;a++,a>e.limits.maxLoopIterations&&Te(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",n,i),!(t.condition&&(r!==void 0&&(e.state.currentLine=r),await H(e,t.condition.expression)===0));){try{for(let c of t.body){let u=await e.executeStatement(c);n+=u.stdout,i+=u.stderr,o=u.exitCode}}catch(c){let u=Rt(c,n,i,e.state.loopDepth);if(n=u.stdout,i=u.stderr,u.action===\"break\")break;if(u.action===\"continue\"){t.update&&await H(e,t.update.expression);continue}if(u.action===\"error\"){let f=_(n,i,u.exitCode??1);return K(e,f,t.redirections)}throw u.error}t.update&&await H(e,t.update.expression)}}finally{e.state.loopDepth--}let l=_(n,i,o);return K(e,l,t.redirections)}async function Pi(e,t,s=\"\"){let r=\"\",n=\"\",i=0,o=0,a=s;for(let c of t.redirections)if((c.operator===\"<<\"||c.operator===\"<<-\")&&c.target.type===\"HereDoc\"){let u=c.target,f=await L(e,u.content);u.stripTabs&&(f=f.split(`\n`).map(d=>d.replace(/^\\t+/,\"\")).join(`\n`)),a=f}else if(c.operator===\"<<<\"&&c.target.type===\"Word\")a=`${await L(e,c.target)}\n`;else if(c.operator===\"<\"&&c.target.type===\"Word\")try{let u=await L(e,c.target),f=e.fs.resolvePath(e.state.cwd,u);a=await e.fs.readFile(f)}catch{let u=await L(e,c.target);return A(`bash: ${u}: No such file or directory\n`)}let l=e.state.groupStdin;a&&(e.state.groupStdin=a),e.state.loopDepth++;try{for(;;){o++,o>e.limits.maxLoopIterations&&Te(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",r,n);let c=0,u=!1,f=!1,d=e.state.inCondition;e.state.inCondition=!0;try{for(let p of t.condition){let y=await e.executeStatement(p);r+=y.stdout,n+=y.stderr,c=y.exitCode}}catch(p){if(p instanceof ye){if(r+=p.stdout,n+=p.stderr,p.levels>1&&e.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=n,e.state.inCondition=d,p;u=!0}else if(p instanceof ge){if(r+=p.stdout,n+=p.stderr,p.levels>1&&e.state.loopDepth>1)throw p.levels--,p.stdout=r,p.stderr=n,e.state.inCondition=d,p;f=!0}else throw e.state.inCondition=d,p}finally{e.state.inCondition=d}if(u)break;if(!f){if(c!==0)break;try{for(let p of t.body){let y=await e.executeStatement(p);r+=y.stdout,n+=y.stderr,i=y.exitCode}}catch(p){let y=Rt(p,r,n,e.state.loopDepth);if(r=y.stdout,n=y.stderr,y.action===\"break\")break;if(y.action===\"continue\")continue;if(y.action===\"error\")return _(r,n,y.exitCode??1);throw y.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=l}return _(r,n,i)}async function Ai(e,t){let s=\"\",r=\"\",n=0,i=0;e.state.loopDepth++;try{for(;;){i++,i>e.limits.maxLoopIterations&&Te(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,\"iterations\",s,r);let o=await Wr(e,t.condition);if(s+=o.stdout,r+=o.stderr,o.exitCode===0)break;try{for(let a of t.body){let l=await e.executeStatement(a);s+=l.stdout,r+=l.stderr,n=l.exitCode}}catch(a){let l=Rt(a,s,r,e.state.loopDepth);if(s=l.stdout,r=l.stderr,l.action===\"break\")break;if(l.action===\"continue\")continue;if(l.action===\"error\")return _(s,r,l.exitCode??1);throw l.error}}}finally{e.state.loopDepth--}return _(s,r,n)}async function ki(e,t){let s=await Re(e,t.redirections);if(s)return s;let r=\"\",n=\"\",i=0,o=await L(e,t.word),a=!1;for(let c=0;c<t.items.length;c++){let u=t.items[c],f=a;if(!a)for(let d of u.patterns){let p=await L(e,d);ln(d)&&(p=on(p));let y=e.state.shoptOptions.nocasematch,h=e.state.shoptOptions.extglob;if(ht(o,p,y,h)){f=!0;break}}if(f){let d=await Ss(e,u.body,r,n);if(r=d.stdout,n=d.stderr,i=d.exitCode,u.terminator===\";;\")break;u.terminator===\";&\"?a=!0:a=!1}else a=!1}let l=_(r,n,i);return K(e,l,t.redirections)}function zr(e,t){if(e.parts.length!==1)return!1;let s=e.parts[0];return s.type!==\"Literal\"?!1:t.includes(s.value)}function _i(e){if(!e.startsWith(\"__rw__:\"))return null;let t=e.slice(7),s=t.indexOf(\":\");if(s===-1)return null;let r=Number.parseInt(t.slice(0,s),10);if(Number.isNaN(r)||r<0)return null;let n=s+1,i=t.slice(n,n+r),o=n+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}}var Ci=\"+ \";async function Ni(e){let t=e.state.env.get(\"PS4\");if(t===void 0)return Ci;if(t===\"\")return\"\";try{let r=new B().parseWordFromString(t,!1,!1);return await L(e,r)}catch{return e.state.expansionStderr=`${e.state.expansionStderr||\"\"}bash: ${t}: bad substitution\n`,t||Ci}}function ka(e){return e.map(t=>_a(t)).join(\" \")}function _a(e){if(e===\"\")return\"''\";if(!/[\\s'\"\\\\$`!*?[\\]{}|&;<>()~#\\n\\t]/.test(e))return e;let s=/[\\x00-\\x1f\\x7f]/.test(e),r=e.includes(`\n`),n=e.includes(\"\t\"),i=e.includes(\"\\\\\"),o=e.includes(\"'\");if(s||r||n||i){let l=\"\";for(let c of e){let u=c.charCodeAt(0);c===`\n`?l+=\"\\\\n\":c===\"\t\"?l+=\"\\\\t\":c===\"\\\\\"?l+=\"\\\\\\\\\":c===\"'\"?l+=\"'\":c==='\"'?l+='\"':u<32||u===127?u<256?l+=`\\\\x${u.toString(16).padStart(2,\"0\")}`:l+=`\\\\u${u.toString(16).padStart(4,\"0\")}`:l+=c}return`$'${l}'`}return o?`\"${e.replace(/([\\\\$`\"])/g,\"\\\\$1\")}\"`:`'${e}'`}async function Oi(e,t,s){if(!e.state.options.xtrace)return\"\";let r=await Ni(e),n=[t,...s],i=ka(n);return`${r}${i}\n`}async function xi(e,t,s){return e.state.options.xtrace?`${await Ni(e)}${t}=${s}\n`:\"\"}async function Ti(e,t,s){let r=t.timed?Fs():0,n=\"\",i=W,o=0,a=[],l=\"\",c=t.commands.length>1,u=e.state.lastArg;for(let d=0;d<t.commands.length;d++){let p=t.commands[d],y=d===t.commands.length-1,h=d===0;c&&(e.state.lastArg=\"\",h||(e.state.groupStdin=void 0));let E=c&&(!y||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,g;try{g=await s(p,n)}catch(b){if(b instanceof jt)g={stdout:b.stdout,stderr:b.stderr,exitCode:1};else if(b instanceof j&&t.commands.length>1)g={stdout:b.stdout,stderr:b.stderr,exitCode:b.exitCode};else if(b instanceof we&&t.commands.length>1)g={stdout:b.stdout,stderr:b.stderr,exitCode:b.exitCode};else throw E&&(e.state.env=E),b}E&&(e.state.env=E),a.push(g.exitCode),g.exitCode!==0&&(o=g.exitCode),y?i=g:(t.pipeStderr?.[d]??!1?n=Be(g.stderr)+Bt(g):(n=Bt(g),l+=g.stderr),i={stdout:\"\",stderr:\"\",exitCode:g.exitCode})}if(l&&(i={...i,stderr:l+i.stderr}),t.commands.length>1||t.commands.length===1&&t.commands[0].type===\"SimpleCommand\"){for(let d of e.state.env.keys())d.startsWith(\"PIPESTATUS_\")&&e.state.env.delete(d);for(let d=0;d<a.length;d++)e.state.env.set(`PIPESTATUS_${d}`,String(a[d]));e.state.env.set(\"PIPESTATUS__length\",String(a.length))}if(e.state.options.pipefail&&o!==0&&(i={...i,exitCode:o}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let p=(Fs()-r)/1e3,y=Math.floor(p/60),h=p%60,w;t.timePosix?w=`real ${p.toFixed(2)}\nuser 0.00\nsys 0.00\n`:w=`\nreal\t${`${y}m${h.toFixed(3)}s`}\nuser\t0m0.000s\nsys\t0m0.000s\n`,i={...i,stderr:i.stderr+w}}return c&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}async function Di(e,t){let s=new Map,r=\"\";for(let n of t.assignments){let i=n.name;if(n.array){let u=await Ca(e,t,i,n.array,n.append,s);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:u.error};if(r+=u.xtraceOutput,u.continueToNext)continue}let o=n.value?await L(e,n.value):\"\";if(i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[\\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:_(\"\",`bash: ${i}: bad array subscript\n`,1)};let l=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);if(l){let u=await Da(e,t,l[1],l[2],o,n.append,s);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:u.error};if(u.continueToNext)continue}let c=await Ia(e,t,i,o,n.append,s);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:s,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:s}}async function Ca(e,t,s,r,n,i){let o=\"\";if(/\\[.+\\]$/.test(s))return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: ${s}: cannot assign list to array member\n`,1)};if(Ee(e,s)){let u=rn(e,s);if(u===void 0||u===\"\")throw new j(1,\"\",\"\");let f=Ze(e,s);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\\[@\\]$/.test(f))return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: ${s}: cannot assign list to array member\n`,1)}}if(et(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable\n`,{continueToNext:!0,xtraceOutput:o};let u=se(e,s);if(u)return{continueToNext:!1,xtraceOutput:\"\",error:u}}let a=e.state.associativeArrays?.has(s),l=Na(r),c=()=>{let u=`${s}_`;for(let f of e.state.env.keys())f.startsWith(u)&&!f.includes(\"__\")&&e.state.env.delete(f);e.state.env.delete(s)};if(a&&l?await Oa(e,t,s,r,n,c,u=>{o+=u}):l?await xa(e,s,r,n,c):await Ta(e,s,r,n,c),t.name){i.set(s,e.state.env.get(s));let f=`(${r.map(d=>Gt(d)).join(\" \")})`;e.state.env.set(s,f)}return{continueToNext:!0,xtraceOutput:o}}function Na(e){return e.some(t=>{if(t.parts.length>=2){let s=t.parts[0],r=t.parts[1];if(s.type!==\"Glob\"||!s.pattern.startsWith(\"[\"))return!1;if(s.pattern===\"[\"&&(r.type===\"DoubleQuoted\"||r.type===\"SingleQuoted\")){if(t.parts.length<3)return!1;let n=t.parts[2];return n.type!==\"Literal\"?!1:n.value.startsWith(\"]=\")||n.value.startsWith(\"]+=\")}return r.type!==\"Literal\"?!1:r.value.startsWith(\"]\")?r.value.startsWith(\"]=\")||r.value.startsWith(\"]+=\"):s.pattern.endsWith(\"]\")?r.value.startsWith(\"=\")||r.value.startsWith(\"+=\"):!1}return!1})}async function Oa(e,t,s,r,n,i,o){let a=[];for(let l of r){let c=Ws(l);if(c){let{key:u,valueParts:f,append:d}=c,p;f.length>0?p=await L(e,{type:\"Word\",parts:f}):p=\"\",p=X(e,p),a.push({type:\"keyed\",key:u,value:p,append:d})}else{let u=await L(e,l);a.push({type:\"invalid\",expandedValue:u})}}n||i();for(let l of a)if(l.type===\"keyed\")if(l.append){let c=e.state.env.get(`${s}_${l.key}`)??\"\";e.state.env.set(`${s}_${l.key}`,c+l.value)}else e.state.env.set(`${s}_${l.key}`,l.value);else{let c=t.line??e.state.currentLine??1;o(`bash: line ${c}: ${s}: ${l.expandedValue}: must use subscript when assigning associative array\n`)}}async function xa(e,t,s,r,n){let i=[];for(let a of s){let l=Ws(a);if(l){let{key:c,valueParts:u,append:f}=l,d;u.length>0?d=await L(e,{type:\"Word\",parts:u}):d=\"\",d=X(e,d),i.push({type:\"keyed\",indexExpr:c,value:d,append:f})}else{let c=await xe(e,a);i.push({type:\"non-keyed\",values:c.values})}}r||n();let o=0;for(let a of i)if(a.type===\"keyed\"){let l;try{let c=new B,u=ee(c,a.indexExpr);l=await H(e,u.expression,!1)}catch{if(/^-?\\d+$/.test(a.indexExpr))l=Number.parseInt(a.indexExpr,10);else{let c=e.state.env.get(a.indexExpr);l=c?Number.parseInt(c,10):0,Number.isNaN(l)&&(l=0)}}if(a.append){let c=e.state.env.get(`${t}_${l}`)??\"\";e.state.env.set(`${t}_${l}`,c+a.value)}else e.state.env.set(`${t}_${l}`,a.value);o=l+1}else for(let l of a.values)e.state.env.set(`${t}_${o++}`,l)}async function Ta(e,t,s,r,n){let i=[];for(let a of s){let l=await xe(e,a);i.push(...l.values)}let o=0;if(r){let a=Ae(e,t);if(a.length>0)o=Math.max(...a.map(([c])=>typeof c==\"number\"?c:0))+1;else{let l=e.state.env.get(t);l!==void 0&&(e.state.env.set(`${t}_0`,l),e.state.env.delete(t),o=1)}}else n();for(let a=0;a<i.length;a++)e.state.env.set(`${t}_${o+a}`,i[a]);r||e.state.env.set(`${t}__length`,String(i.length))}async function Da(e,t,s,r,n,i,o){let a=s;if(Ee(e,s)){let f=Ze(e,s);if(f&&f!==s){if(f.includes(\"[\"))return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: \\`${f}': not a valid identifier\n`,1)};a=f}}if(et(e,a)){if(t.name)return{continueToNext:!0,xtraceOutput:\"\"};let f=se(e,a);if(f)return{continueToNext:!1,xtraceOutput:\"\",error:f}}let l=e.state.associativeArrays?.has(a),c;if(l)c=await Ri(e,a,r);else{let f=await Ra(e,a,r);if(f.error)return{continueToNext:!1,xtraceOutput:\"\",error:f.error};c=`${a}_${f.index}`}let u=i?(e.state.env.get(c)||\"\")+n:n;if(t.name)o.set(c,e.state.env.get(c)),e.state.env.set(c,u);else{let f=pt(e,a);if(f!==void 0&&f===e.state.callDepth&&e.state.localScopes.length>0){let d=e.state.localScopes[e.state.localScopes.length-1];d.has(c)||d.set(c,e.state.env.get(c))}e.state.env.set(c,u)}return{continueToNext:!0,xtraceOutput:\"\"}}async function Ri(e,t,s){let r;if(s.startsWith(\"'\")&&s.endsWith(\"'\"))r=s.slice(1,-1);else if(s.startsWith('\"')&&s.endsWith('\"')){let n=s.slice(1,-1),o=new B().parseWordFromString(n,!0,!1);r=await L(e,o)}else if(s.includes(\"$\")){let i=new B().parseWordFromString(s,!1,!1);r=await L(e,i)}else r=s;return`${t}_${r}`}async function Ra(e,t,s){let r=s;s.startsWith('\"')&&s.endsWith('\"')&&s.length>=2&&(r=s.slice(1,-1));let n;if(/^-?\\d+$/.test(r))n=Number.parseInt(r,10);else{try{let i=new B,o=ee(i,r);n=await H(e,o.expression,!1)}catch(i){if(i instanceof Je){let l=`bash: line ${e.state.currentLine}: ${s}: ${i.message}\n`;if(i.fatal)throw new j(1,\"\",l);return{index:0,error:_(\"\",l,1)}}let o=e.state.env.get(s);n=o?Number.parseInt(o,10):0}Number.isNaN(n)&&(n=0)}if(n<0){let i=Ae(e,t);if(i.length===0){let a=e.state.currentLine;return{index:0,error:_(\"\",`bash: line ${a}: ${t}[${s}]: bad array subscript\n`,1)}}if(n=Math.max(...i.map(([a])=>typeof a==\"number\"?a:0))+1+n,n<0){let a=e.state.currentLine;return{index:0,error:_(\"\",`bash: line ${a}: ${t}[${s}]: bad array subscript\n`,1)}}}return{index:n}}async function Ia(e,t,s,r,n,i){let o=\"\",a=s,l=null;if(Ee(e,s)){let f=nn(e,s,r);if(f===void 0)return{continueToNext:!1,xtraceOutput:\"\",error:_(\"\",`bash: ${s}: circular name reference\n`,1)};if(f===null)return{continueToNext:!0,xtraceOutput:\"\"};a=f;let d=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\\[(.+)\\]$/);d&&(l={arrayName:d[1],subscriptExpr:d[2]},a=d[1])}if(et(e,a)){if(t.name)return o+=`bash: ${a}: readonly variable\n`,{continueToNext:!0,xtraceOutput:o};let f=se(e,a);if(f)return{continueToNext:!1,xtraceOutput:\"\",error:f}}let c;if(xt(e,a))try{let f=new B;if(n){let p=`(${e.state.env.get(a)||\"0\"}) + (${r})`,y=ee(f,p);c=String(await H(e,y.expression))}else{let d=ee(f,r);c=String(await H(e,d.expression))}}catch{c=\"0\"}else{let{isArray:f}=await import(\"./chunks/expansion-R25BK4W3.js\"),d=f(e,a)?`${a}_0`:a;c=n?(e.state.env.get(d)||\"\")+r:r}c=gt(e,a,c),o+=await xi(e,a,c);let u=a;if(l)u=await La(e,l);else{let{isArray:f}=await import(\"./chunks/expansion-R25BK4W3.js\");f(e,a)&&(u=`${a}_0`)}return t.name?(i.set(u,e.state.env.get(u)),e.state.env.set(u,c)):(e.state.env.set(u,c),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(a)),e.state.tempEnvBindings?.some(f=>f.has(a))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function La(e,t){let{arrayName:s,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(s))return Ri(e,s,r);let i;if(/^-?\\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new B,a=ee(o,r);i=await H(e,a.expression,!1)}catch{let o=e.state.env.get(r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=Ae(e,s);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${s}_${i}`}async function Ii(e,t,s,r){let n=await Re(e,t.redirections);if(n)return n;let i=new Map(e.state.env),o=e.state.cwd,a={...e.state.options},l=new Map(e.state.functions),c=e.state.localScopes,u=e.state.localVarStack,f=e.state.localVarDepth,d=e.state.fullyUnsetLocals;if(e.state.localScopes=c.map(S=>new Map(S)),u){e.state.localVarStack=new Map;for(let[S,T]of u.entries())e.state.localVarStack.set(S,T.map(N=>({...N})))}f&&(e.state.localVarDepth=new Map(f)),d&&(e.state.fullyUnsetLocals=new Map(d));let p=e.state.loopDepth,y=e.state.parentHasLoopContext;e.state.parentHasLoopContext=p>0,e.state.loopDepth=0;let h=e.state.lastArg,w=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let E=e.state.groupStdin;s&&(e.state.groupStdin=s);let g=\"\",b=\"\",m=0,v=()=>{e.state.env=i,e.state.cwd=o,e.state.options=a,e.state.functions=l,e.state.localScopes=c,e.state.localVarStack=u,e.state.localVarDepth=f,e.state.fullyUnsetLocals=d,e.state.loopDepth=p,e.state.parentHasLoopContext=y,e.state.groupStdin=E,e.state.bashPid=w,e.state.lastArg=h};try{for(let S of t.body){let T=await r(S);g+=T.stdout,b+=T.stderr,m=T.exitCode}}catch(S){if(v(),S instanceof J)throw S;if(S instanceof je){g+=S.stdout,b+=S.stderr;let N=_(g,b,0);return K(e,N,t.redirections)}if(S instanceof ye||S instanceof ge){g+=S.stdout,b+=S.stderr;let N=_(g,b,0);return K(e,N,t.redirections)}if(S instanceof j){g+=S.stdout,b+=S.stderr;let N=_(g,b,S.exitCode);return K(e,N,t.redirections)}if(S instanceof ue){g+=S.stdout,b+=S.stderr;let N=_(g,b,S.exitCode);return K(e,N,t.redirections)}if(S instanceof we){let N=_(g+S.stdout,b+S.stderr,S.exitCode);return K(e,N,t.redirections)}let T=_(g,`${b}${Ie(S)}\n`,1);return K(e,T,t.redirections)}v();let $=_(g,b,m);return K(e,$,t.redirections)}async function Li(e,t,s,r){let n=\"\",i=\"\",o=0,a=await ms(e,t.redirections);if(a)return a;let l=s;for(let f of t.redirections)if((f.operator===\"<<\"||f.operator===\"<<-\")&&f.target.type===\"HereDoc\"){let d=f.target,p=await L(e,d.content);d.stripTabs&&(p=p.split(`\n`).map(h=>h.replace(/^\\t+/,\"\")).join(`\n`));let y=f.fd??0;y!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),le(e),e.state.fileDescriptors.set(y,p)):l=p}else if(f.operator===\"<<<\"&&f.target.type===\"Word\")l=`${await L(e,f.target)}\n`;else if(f.operator===\"<\"&&f.target.type===\"Word\")try{let d=await L(e,f.target),p=e.fs.resolvePath(e.state.cwd,d);l=await e.fs.readFile(p)}catch{let d=await L(e,f.target);return _(\"\",`bash: ${d}: No such file or directory\n`,1)}let c=e.state.groupStdin;l&&(e.state.groupStdin=l);try{for(let f of t.body){let d=await r(f);n+=d.stdout,i+=d.stderr,o=d.exitCode}}catch(f){if(e.state.groupStdin=c,f instanceof J)throw f;if(Zt(f)||f instanceof we||f instanceof j)throw f.prependOutput(n,i),f;return _(n,`${i}${Ie(f)}\n`,1)}e.state.groupStdin=c;let u=_(n,i,o);return K(e,u,t.redirections)}async function Fi(e,t,s,r,n){let i;try{i=await e.fs.readFile(t)}catch{return A(`bash: ${t}: No such file or directory\n`,127)}if(i.startsWith(\"#!\")){let w=i.indexOf(`\n`);w!==-1&&(i=i.slice(w+1))}let o=new Map(e.state.env),a=e.state.cwd,l={...e.state.options},c=e.state.loopDepth,u=e.state.parentHasLoopContext,f=e.state.lastArg,d=e.state.bashPid,p=e.state.groupStdin,y=e.state.currentSource;e.state.parentHasLoopContext=c>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,r&&(e.state.groupStdin=r),e.state.currentSource=t,e.state.env.set(\"0\",t),e.state.env.set(\"#\",String(s.length)),e.state.env.set(\"@\",s.join(\" \")),e.state.env.set(\"*\",s.join(\" \"));for(let w=0;w<s.length&&w<9;w++)e.state.env.set(String(w+1),s[w]);for(let w=s.length+1;w<=9;w++)e.state.env.delete(String(w));let h=()=>{e.state.env=o,e.state.cwd=a,e.state.options=l,e.state.loopDepth=c,e.state.parentHasLoopContext=u,e.state.lastArg=f,e.state.bashPid=d,e.state.groupStdin=p,e.state.currentSource=y};try{let E=new B().parse(i),g=await n(E);return h(),g}catch(w){if(h(),w instanceof j||w instanceof J)throw w;if(w.name===\"ParseException\")return A(`bash: ${t}: ${w.message}\n`);throw w}}var It=class{ctx;constructor(t,s){this.ctx={state:s,fs:t.fs,commands:t.commands,limits:t.limits,execFn:t.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:t.fetch,sleep:t.sleep,trace:t.trace,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext??!1,jsBootstrapCode:t.jsBootstrapCode,invokeTool:t.invokeTool}}assertDefenseContext(t){if(!this.ctx.requireDefenseContext||me.isInSandboxedContext())return;let s=`interpreter ${t} attempted outside defense context`;throw new Ve(s,{timestamp:Date.now(),type:\"missing_defense_context\",message:s,path:\"DefenseInDepthBox.context\",stack:new Error().stack,executionId:me.getCurrentExecutionId()})}buildExportedEnv(){let t=this.ctx.state.exportedVars,s=this.ctx.state.tempExportedVars,r=new Set;if(t)for(let i of t)r.add(i);if(s)for(let i of s)r.add(i);if(r.size===0)return Object.create(null);let n=Object.create(null);for(let i of r){let o=this.ctx.state.env.get(i);o!==void 0&&(n[i]=o)}return n}async executeScript(t){this.assertDefenseContext(\"execution\");let s=\"\",r=\"\",n=0,i=this.ctx.limits.maxOutputSize,o=(a,l)=>{s.length+r.length+a.length+l.length>i&&Te(`total output size exceeded (>${i} bytes), increase executionLimits.maxOutputSize`,\"output_size\"),s+=a,r+=l};for(let a of t.statements)try{let l=await this.executeStatement(a);o(l.stdout,l.stderr),n=l.exitCode,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n))}catch(l){if(l instanceof j)throw l.prependOutput(s,r),l;if(l instanceof Pe)return o(l.stdout,l.stderr),n=l.exitCode,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof J)throw l;if(l instanceof we)return o(l.stdout,l.stderr),n=l.exitCode,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof Gr)return o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof jt)return o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n)),{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)};if(l instanceof Je){o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n));continue}if(l instanceof Kr){o(l.stdout,l.stderr),n=1,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n));continue}if(l instanceof ye||l instanceof ge){if(this.ctx.state.loopDepth>0)throw l.prependOutput(s,r),l;o(l.stdout,l.stderr);continue}throw l instanceof ue&&l.prependOutput(s,r),l}return{stdout:s,stderr:r,exitCode:n,env:Ue(this.ctx.state.env)}}async executeUserScript(t,s,r=\"\"){return Fi(this.ctx,t,s,r,n=>this.executeScript(n))}async executeStatement(t){if(this.assertDefenseContext(\"statement\"),this.ctx.state.signal?.aborted)throw new Ht;if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Te(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,\"commands\"),t.deferredError)throw new qt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return W;this.ctx.state.errexitSafe=!1;let s=\"\",r=\"\";this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&(r+=`${t.sourceText}\n`);let n=0,i=-1,o=!1;for(let c=0;c<t.pipelines.length;c++){let u=t.pipelines[c],f=c>0?t.operators[c-1]:null;if(f===\"&&\"&&n!==0||f===\"||\"&&n===0)continue;let d=await this.executePipeline(u);s+=d.stdout,r+=d.stderr,n=d.exitCode,i=c,o=u.negated,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(\"?\",String(n))}let a=i<t.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||l,this.ctx.state.options.errexit&&n!==0&&i===t.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!l)throw new we(n,s,r);return _(s,r,n)}async executePipeline(t){return Ti(this.ctx,t,(s,r)=>this.executeCommand(s,r))}async executeCommand(t,s){switch(this.assertDefenseContext(\"command\"),this.ctx.coverage?.hit(`bash:cmd:${t.type}`),t.type){case\"SimpleCommand\":return this.executeSimpleCommand(t,s);case\"If\":return Ei(this.ctx,t);case\"For\":return $i(this.ctx,t);case\"CStyleFor\":return Si(this.ctx,t);case\"While\":return Pi(this.ctx,t,s);case\"Until\":return Ai(this.ctx,t);case\"Case\":return ki(this.ctx,t);case\"Subshell\":return this.executeSubshell(t,s);case\"Group\":return this.executeGroup(t,s);case\"FunctionDef\":return Bn(this.ctx,t);case\"ArithmeticCommand\":return this.executeArithmeticCommand(t);case\"ConditionalCommand\":return this.executeConditionalCommand(t);default:return W}}async executeSimpleCommand(t,s){try{return await this.executeSimpleCommandInner(t,s)}catch(r){if(r instanceof Ut)return A(r.stderr);throw r}}async executeSimpleCommandInner(t,s){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let m=t,v=100;for(;v>0;){let $=this.expandAlias(m);if($===m)break;m=$,v--}this.aliasExpansionStack.clear(),m!==t&&(t=m)}this.ctx.state.expansionStderr=\"\";let r=await Di(this.ctx,t);if(r.error)return r.error;let n=r.tempAssignments,i=r.xtraceOutput;if(!t.name){if(t.redirections.length>0){let v=await Re(this.ctx,t.redirections);if(v)return v;let $=_(\"\",i,0);return K(this.ctx,$,t.redirections)}this.ctx.state.lastArg=\"\";let m=(this.ctx.state.expansionStderr||\"\")+i;return this.ctx.state.expansionStderr=\"\",_(\"\",m,this.ctx.state.lastExitCode)}let o=t.name&&zr(t.name,[\"local\",\"declare\",\"typeset\",\"export\",\"readonly\"]),a=Array.from(n.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let m of a)this.ctx.state.tempExportedVars.add(m)}let l=await ms(this.ctx,t.redirections);if(l){for(let[m,v]of n)v===void 0?this.ctx.state.env.delete(m):this.ctx.state.env.set(m,v);return l}let c=-1;for(let m of t.redirections){if((m.operator===\"<<\"||m.operator===\"<<-\")&&m.target.type===\"HereDoc\"){let v=m.target,$=await L(this.ctx,v.content);v.stripTabs&&($=$.split(`\n`).map(T=>T.replace(/^\\t+/,\"\")).join(`\n`)),$=Be($);let S=m.fd??0;S!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),le(this.ctx),this.ctx.state.fileDescriptors.set(S,$)):s=$;continue}if(m.operator===\"<<<\"&&m.target.type===\"Word\"){s=Be(`${await L(this.ctx,m.target)}\n`);continue}if(m.operator===\"<\"&&m.target.type===\"Word\")try{let v=await L(this.ctx,m.target),$=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);s=await Vt(this.ctx.fs,$)}catch{let v=await L(this.ctx,m.target);for(let[$,S]of n)S===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,S);return A(`bash: ${v}: No such file or directory\n`)}if(m.operator===\"<&\"&&m.target.type===\"Word\"){let v=await L(this.ctx,m.target),$=Number.parseInt(v,10);if(!Number.isNaN($)&&this.ctx.state.fileDescriptors){let S=this.ctx.state.fileDescriptors.get($);if(S!==void 0)if(S.startsWith(\"__rw__:\")){let T=_i(S);T&&(s=T.content.slice(T.position),c=$)}else S.startsWith(\"__file__:\")||S.startsWith(\"__file_append__:\")||(s=S)}}}let u=await L(this.ctx,t.name),f=[],d=[];if(zr(t.name,[\"local\",\"declare\",\"typeset\",\"export\",\"readonly\"])&&(u===\"local\"||u===\"declare\"||u===\"typeset\"||u===\"export\"||u===\"readonly\"))for(let m of t.args){let v=await An(this.ctx,m);if(v)f.push(v),d.push(!0);else{let $=await kn(this.ctx,m);if($!==null)f.push($),d.push(!0);else{let S=await xe(this.ctx,m);for(let T of S.values)f.push(T),d.push(S.quoted)}}}else for(let m of t.args){let v=await xe(this.ctx,m);for(let $ of v.values)f.push($),d.push(v.quoted)}if(!u){if(t.name.parts.every(v=>v.type===\"CommandSubstitution\"||v.type===\"ParameterExpansion\"||v.type===\"ArithmeticExpansion\")){if(f.length>0){let v=f.shift();return d.shift(),await this.runCommand(v,f,d,s,!1,!1,c)}return _(\"\",\"\",this.ctx.state.lastExitCode)}return A(`bash: : command not found\n`,127)}if(u===\"exec\"&&(f.length===0||f[0]===\"--\")){for(let m of t.redirections){if(m.target.type===\"HereDoc\"||m.fdVariable)continue;let v=await L(this.ctx,m.target),$=m.fd??(m.operator===\"<\"||m.operator===\"<>\"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),m.operator){case\">\":case\">|\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);await this.ctx.fs.writeFile(S,\"\",\"utf8\"),le(this.ctx),this.ctx.state.fileDescriptors.set($,`__file__:${S}`);break}case\">>\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);le(this.ctx),this.ctx.state.fileDescriptors.set($,`__file_append__:${S}`);break}case\"<\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);try{let T=await this.ctx.fs.readFile(S);le(this.ctx),this.ctx.state.fileDescriptors.set($,T)}catch{return A(`bash: ${v}: No such file or directory\n`)}break}case\"<>\":{let S=this.ctx.fs.resolvePath(this.ctx.state.cwd,v);try{let T=await this.ctx.fs.readFile(S);le(this.ctx),this.ctx.state.fileDescriptors.set($,`__rw__:${S.length}:${S}:0:${T}`)}catch{await this.ctx.fs.writeFile(S,\"\",\"utf8\"),le(this.ctx),this.ctx.state.fileDescriptors.set($,`__rw__:${S.length}:${S}:0:`)}break}case\">&\":{if(v===\"-\")this.ctx.state.fileDescriptors.delete($);else if(v.endsWith(\"-\")){let S=v.slice(0,-1),T=Number.parseInt(S,10);if(!Number.isNaN(T)){let N=this.ctx.state.fileDescriptors.get(T);N!==void 0?this.ctx.state.fileDescriptors.set($,N):this.ctx.state.fileDescriptors.set($,`__dupout__:${T}`),this.ctx.state.fileDescriptors.delete(T)}}else{let S=Number.parseInt(v,10);Number.isNaN(S)||(le(this.ctx),this.ctx.state.fileDescriptors.set($,`__dupout__:${S}`))}break}case\"<&\":{if(v===\"-\")this.ctx.state.fileDescriptors.delete($);else if(v.endsWith(\"-\")){let S=v.slice(0,-1),T=Number.parseInt(S,10);if(!Number.isNaN(T)){let N=this.ctx.state.fileDescriptors.get(T);N!==void 0?this.ctx.state.fileDescriptors.set($,N):this.ctx.state.fileDescriptors.set($,`__dupin__:${T}`),this.ctx.state.fileDescriptors.delete(T)}}else{let S=Number.parseInt(v,10);Number.isNaN(S)||(le(this.ctx),this.ctx.state.fileDescriptors.set($,`__dupin__:${S}`))}break}}}for(let[m,v]of n)v===void 0?this.ctx.state.env.delete(m):this.ctx.state.env.set(m,v);if(this.ctx.state.tempExportedVars)for(let m of n.keys())this.ctx.state.tempExportedVars.delete(m);return W}if(this.ctx.state.extraArgs){f.push(...this.ctx.state.extraArgs);for(let m=0;m<this.ctx.state.extraArgs.length;m++)d.push(!0);this.ctx.state.extraArgs=void 0}let y=await Oi(this.ctx,u,f);n.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(n)));let h,w=null;try{h=await this.runCommand(u,f,d,s,!1,!1,c)}catch(m){if(m instanceof ye||m instanceof ge)w=m,h=W;else throw m}let E=i+y;if(E&&(h={...h,stderr:E+h.stderr}),h=await K(this.ctx,h,t.redirections),w)throw w;if(f.length>0){let m=f[f.length-1];if((u===\"declare\"||u===\"local\"||u===\"typeset\")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\\(/.test(m)){let v=m.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\\(/);v&&(m=v[1])}this.ctx.state.lastArg=m}else this.ctx.state.lastArg=u;let g=zn(u)&&u!==\"unset\"&&u!==\"eval\";if(!this.ctx.state.options.posix||!g)for(let[m,v]of n)this.ctx.state.fullyUnsetLocals?.has(m)||(v===void 0?this.ctx.state.env.delete(m):this.ctx.state.env.set(m,v));if(this.ctx.state.tempExportedVars)for(let m of n.keys())this.ctx.state.tempExportedVars.delete(m);return n.size>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,s,r,n,i=!1,o=!1,a=-1){let l={ctx:this.ctx,runCommand:(u,f,d,p,y,h,w)=>this.runCommand(u,f,d,p,y,h,w),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(u,f,d)=>this.executeUserScript(u,f,d)},c=await vi(l,t,s,r,n,i,o,a);return c!==null?c:bi(l,t,s,n,o)}aliasExpansionStack=new Set;expandAlias(t){return Ks(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return $s(this.ctx,t)}async executeSubshell(t,s=\"\"){return Ii(this.ctx,t,s,r=>this.executeStatement(r))}async executeGroup(t,s=\"\"){return Li(this.ctx,t,s,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Re(this.ctx,t.redirections);if(s)return s;try{let r=await H(this.ctx,t.expression.expression),n=Q(r!==0);return this.ctx.state.expansionStderr&&(n={...n,stderr:this.ctx.state.expansionStderr+n.stderr},this.ctx.state.expansionStderr=\"\"),K(this.ctx,n,t.redirections)}catch(r){let n=A(`bash: arithmetic expression: ${r.message}\n`);return K(this.ctx,n,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let s=await Re(this.ctx,t.redirections);if(s)return s;try{let r=await Ke(this.ctx,t.expression),n=Q(r);return this.ctx.state.expansionStderr&&(n={...n,stderr:this.ctx.state.expansionStderr+n.stderr},this.ctx.state.expansionStderr=\"\"),K(this.ctx,n,t.redirections)}catch(r){let n=r instanceof Je?1:2,i=A(`bash: conditional expression: ${r.message}\n`,n);return K(this.ctx,i,t.redirections)}}};var re={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxSubstitutionDepth:50,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxSourceDepth:100};function Mi(e){return e?{maxCallDepth:e.maxCallDepth??re.maxCallDepth,maxCommandCount:e.maxCommandCount??re.maxCommandCount,maxLoopIterations:e.maxLoopIterations??re.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??re.maxAwkIterations,maxSedIterations:e.maxSedIterations??re.maxSedIterations,maxJqIterations:e.maxJqIterations??re.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??re.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??re.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??re.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??re.maxGlobOperations,maxStringLength:e.maxStringLength??re.maxStringLength,maxArrayElements:e.maxArrayElements??re.maxArrayElements,maxHeredocSize:e.maxHeredocSize??re.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??re.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??re.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??re.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??re.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??re.maxSourceDepth}:{...re}}import{lookup as Za}from\"node:dns\";function Vr(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Fa(e){let t=Vr(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function Wi(e){if(e.includes(\"\\\\\"))return!0;let t=e.toLowerCase();return t.includes(\"%2f\")||t.includes(\"%5c\")}function Ma(e,t){return t===\"/\"||t===\"\"?!0:t.endsWith(\"/\")?e.startsWith(t):e===t||e.startsWith(`${t}/`)}function Br(e,t){let s=Vr(e);if(!s)return!1;let r=Fa(t);return!r||s.origin!==r.origin||r.pathPrefix!==\"/\"&&r.pathPrefix!==\"\"&&Wi(s.pathname)?!1:Ma(s.pathname,r.pathPrefix)}function zi(e){return typeof e==\"string\"?e:e.url}function Vi(e,t){return!t||t.length===0?!1:t.some(s=>Br(e,zi(s)))}function jr(e){let t=Wa(e);if(t===\"localhost\"||t.endsWith(\".localhost\"))return!0;let s=Bi(t);if(s)return Ps(s);let r=Va(t);return r?Ba(r):!1}function Wa(e){let t=e.trim().toLowerCase();return t.startsWith(\"[\")&&t.endsWith(\"]\")?t.slice(1,-1):t}function za(e){if(!e)return null;let t=10,s=e;if(s.startsWith(\"0x\")||s.startsWith(\"0X\")?(t=16,s=s.slice(2)):s.length>1&&s.startsWith(\"0\")&&(t=8),!s||t===16&&!/^[0-9a-fA-F]+$/.test(s)||t===10&&!/^\\d+$/.test(s)||t===8&&!/^[0-7]+$/.test(s))return null;let r=Number.parseInt(s,t);return!Number.isFinite(r)||r<0?null:r}function Bi(e){let t=e.split(\".\");if(t.length===0||t.length>4)return null;let s=t.map(l=>za(l));if(s.some(l=>l===null))return null;let r=s;if(t.length===1){let l=r[0];return l>4294967295?null:[l>>>24&255,l>>>16&255,l>>>8&255,l&255]}if(t.length===2){let[l,c]=r;return l>255||c>16777215?null:[l,c>>>16&255,c>>>8&255,c&255]}if(t.length===3){let[l,c,u]=r;return l>255||c>255||u>65535?null:[l,c,u>>>8&255,u&255]}let[n,i,o,a]=r;return n>255||i>255||o>255||a>255?null:[n,i,o,a]}function Va(e){let t=e,s=null;if(t.includes(\".\")){let h=t.lastIndexOf(\":\");if(h<0)return null;let w=t.slice(h+1),E=Bi(w);if(!E)return null;s=E,t=t.slice(0,h)}let r=t.includes(\"::\")?t.split(\"::\").length-1:0;if(r>1)return null;let[n,i]=t.split(\"::\"),o=n?n.split(\":\").filter(Boolean):[],a=i?i.split(\":\").filter(Boolean):[],l=h=>/^[0-9a-f]{1,4}$/i.test(h)?Number.parseInt(h,16):null,c=o.map(l),u=a.map(l);if(c.some(h=>h===null)||u.some(h=>h===null))return null;let f=s?2:0,d=c.length+u.length+f,p=0;if(r===1){if(p=8-d,p<0)return null}else if(d!==8)return null;let y=[...c,...new Array(p).fill(0),...u];return s&&(y.push(s[0]<<8|s[1]),y.push(s[2]<<8|s[3])),y.length===8?y:null}function Ps(e){let[t,s]=e;return t===127||t===10||t===172&&s>=16&&s<=31||t===192&&s===168||t===169&&s===254||t===0||t===100&&s>=64&&s<=127||t===198&&(s===18||s===19)||t===192&&s===0&&e[2]===0||t===192&&s===0&&e[2]===2||t===198&&s===51&&e[2]===100||t===203&&s===0&&e[2]===113||t>=240}function Ba(e){if(e.every(n=>n===0)||e.slice(0,7).every(n=>n===0)&&e[7]===1||(e[0]&65472)===65152||(e[0]&65024)===64512)return!0;if(e[0]===0&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===65535){let n=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Ps(n)}if(e[0]===8193&&e[1]===3512)return!0;if(e[0]===100&&e[1]===65435&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===0){let n=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Ps(n)}if(e[0]===100&&e[1]===65435&&e[2]===1)return!0;if(e[0]===8194){let n=[e[1]>>>8&255,e[1]&255,e[2]>>>8&255,e[2]&255];return Ps(n)}return!1}function ji(e){let t=[];for(let s of e){if(typeof s!=\"string\"&&(s===null||typeof s!=\"object\"||!(\"url\"in s)||typeof s.url!=\"string\")){t.push('Invalid allow-list entry: must be a string URL or an object with a \"url\" string property');continue}let r=zi(s);if(!Vr(r)){t.push(`Invalid URL in allow-list: \"${r}\" - must be a valid URL with scheme and host (e.g., \"https://example.com\")`);continue}let i=new URL(r);if(i.protocol!==\"http:\"&&i.protocol!==\"https:\"){t.push(`Only http and https URLs are allowed in allow-list: \"${r}\"`);continue}if(!i.hostname){t.push(`Allow-list entry must include a hostname: \"${r}\"`);continue}if(i.pathname!==\"/\"&&i.pathname!==\"\"&&Wi(i.pathname)){t.push(`Allow-list entry contains ambiguous path separators: \"${r}\"`);continue}(i.search||i.hash)&&t.push(`Query strings and fragments are ignored in allow-list entries: \"${r}\"`)}return t}var ja=typeof __BROWSER__<\"u\"&&__BROWSER__,wt=null,As=null,Ui=!1;function Ua(){if(wt===null&&!ja)try{let e=Is(\"node:async_hooks\");As=Is(\"node:dns\"),wt=new e.AsyncLocalStorage}catch{}}function Ha(){if(Ui||(Ua(),!wt||!As))return;Ui=!0;let e=wt,t=As.lookup;function s(...r){let n=r[0],i=e.getStore();if(typeof n!=\"string\"||!i||i.hostname.toLowerCase()!==n.toLowerCase())return t.apply(this,r);let o={},a;if(r.length===2)a=r[1];else if(r.length>=3){let c=r[1];typeof c==\"number\"?o={family:c}:c&&typeof c==\"object\"&&(o=c),a=r[2]}if(typeof a!=\"function\")return t.apply(this,r);let l=a;if(o.family!==void 0&&o.family!==0&&o.family!==i.family){let c=new Error(`ENOTFOUND ${n}`);c.code=\"ENOTFOUND\",c.errno=-3008,c.syscall=\"getaddrinfo\",c.hostname=n,process.nextTick(()=>l(c));return}process.nextTick(()=>{o.all?l(null,[{address:i.address,family:i.family}]):l(null,i.address,i.family)})}Object.defineProperty(As,\"lookup\",{value:s,writable:!0,configurable:!0})}function Hi(e,t){return Ha(),wt?wt.run(e,t):t()}var _e=class extends Error{constructor(t,s){let r=s??\"URL not in allow-list\";super(`Network access denied: ${r}: ${t}`),this.name=\"NetworkAccessDeniedError\"}},vt=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name=\"TooManyRedirectsError\"}},bt=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name=\"RedirectNotAllowedError\"}},ks=class extends Error{constructor(t,s){super(`HTTP method '${t}' not allowed. Allowed methods: ${s.join(\", \")}`),this.name=\"MethodNotAllowedError\"}},Et=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name=\"ResponseTooLargeError\"}};function qa(e){return new Promise((t,s)=>{Za(e,{all:!0},(r,n)=>{r?s(r):t(n)})})}var Ga=20,Ka=3e4,Xa=10485760,Ya=[\"GET\",\"HEAD\"],Qa=new Set([\"GET\",\"HEAD\",\"OPTIONS\"]),Ja=new Set([301,302,303,307,308]);function Ur(e){let t=e.allowedUrlPrefixes??[];if(!e.dangerouslyAllowFullInternetAccess){let p=ji(t);if(p.length>0)throw new Error(`Invalid network allow-list:\n${p.join(`\n`)}`)}let s=[];for(let p of t)typeof p==\"object\"&&p.transform&&p.transform.length>0&&s.push(p);function r(p){if(s.length===0)return null;let y=null;for(let h of s)if(Br(p,h.url)&&h.transform){y||(y=new Headers);for(let w of h.transform)for(let[E,g]of Object.entries(w.headers))y.set(E,g)}return y}let n=e.maxRedirects??Ga,i=e.timeoutMs??Ka,o=e.maxResponseSize??Xa,a=e.dangerouslyAllowFullInternetAccess?[\"GET\",\"HEAD\",\"POST\",\"PUT\",\"DELETE\",\"PATCH\",\"OPTIONS\"]:e.allowedMethods??Ya,l=e.denyPrivateRanges??(typeof process<\"u\"&&process.env?.NODE_ENV===\"production\"),c=e._dnsResolve??qa;async function u(p){if(!e.dangerouslyAllowFullInternetAccess&&!Vi(p,t))throw new _e(p);if(l)try{let y=new URL(p);if(jr(y.hostname))throw new _e(p,\"private/loopback IP address blocked\");let h=y.hostname;if(/[a-zA-Z]/.test(h))try{let E=await c(h);for(let{address:b}of E)if(jr(b))throw new _e(p,\"hostname resolves to private/loopback IP address\");let g=E[0];if(g)return{hostname:h,address:g.address,family:g.family===6?6:4}}catch(E){if(E instanceof _e)throw E;let g=E?.code;if(!(g===\"ENOTFOUND\"||g===\"ENODATA\"))throw new _e(p,\"DNS resolution failed for private IP check\")}}catch(y){if(y instanceof _e)throw y}return null}function f(p){if(e.dangerouslyAllowFullInternetAccess)return;let y=p.toUpperCase();if(!a.includes(y))throw new ks(y,a)}async function d(p,y={}){let h=y.method?.toUpperCase()??\"GET\",w=await u(p);f(h);let E=p,g=0,b=y.followRedirects??!0,m=y.timeoutMs!==void 0?Math.min(y.timeoutMs,i):i;for(;;){let v=new AbortController,$=Mt(()=>v.abort(),m);try{let S=await me.runTrustedAsync(()=>{let T=r(E),N=el(y.headers,T),F={method:h,headers:N,signal:v.signal,redirect:\"manual\"};return y.body&&!Qa.has(h)&&(F.body=y.body),w?Hi(w,()=>fetch(E,F)):fetch(E,F)});if(Ja.has(S.status)&&b){let T=S.headers.get(\"location\");if(!T)return await Zi(S,E,o);let N=new URL(T,E).href;try{w=await u(N)}catch{throw new bt(N)}if(g++,g>n)throw new vt(n);E=N;continue}return await Zi(S,E,o)}finally{Wt($)}}}return d}function el(e,t){if(!e&&!t)return;if(!t)return e;let s=e instanceof Headers?new Headers(e):new Headers(e);for(let[r,n]of t)s.set(r,n);return s}async function Zi(e,t,s){let r=Object.create(null);if(e.headers.forEach((i,o)=>{r[o.toLowerCase()]=i}),s>0){let i=e.headers.get(\"content-length\");if(i){let o=parseInt(i,10);if(!Number.isNaN(o)&&o>s)throw new Et(s)}}let n;if(s>0&&e.body){let i=e.body.getReader(),o=[],a=0;for(;;){let{done:c,value:u}=await i.read();if(c)break;if(u){if(a+=u.byteLength,a>s)throw i.cancel(),new Et(s);o.push(u)}}n=new Uint8Array(a);let l=0;for(let c of o)n.set(c,l),l+=c.byteLength}else{let i=await e.arrayBuffer();if(s>0&&i.byteLength>s)throw new Et(s);n=new Uint8Array(i)}return{status:e.status,statusText:e.statusText,headers:r,body:n,url:t}}function Lt(e){return ot(e)}function ot(e){return e.statements.map(qi).join(`\n`)}function qi(e){let t=[];for(let r=0;r<e.pipelines.length;r++)t.push(tl(e.pipelines[r])),r<e.operators.length&&t.push(e.operators[r]);let s=t.join(\" \");return e.background&&(s+=\" &\"),s}function tl(e){let t=[];e.timed&&t.push(e.timePosix?\"time -p\":\"time\"),e.negated&&t.push(\"!\");let s=[];for(let n=0;n<e.commands.length;n++)if(s.push(Gi(e.commands[n])),n<e.commands.length-1){let i=e.pipeStderr?.[n];s.push(i?\"|&\":\"|\")}return(t.length>0?`${t.join(\" \")} `:\"\")+s.join(\" \")}function Gi(e){switch(e.type){case\"SimpleCommand\":return sl(e);case\"If\":return fl(e);case\"For\":return dl(e);case\"CStyleFor\":return hl(e);case\"While\":return pl(e);case\"Until\":return ml(e);case\"Case\":return yl(e);case\"Subshell\":return wl(e);case\"Group\":return vl(e);case\"ArithmeticCommand\":return bl(e);case\"ConditionalCommand\":return El(e);case\"FunctionDef\":return $l(e);default:{let t=e;throw new Error(`Unsupported command type: ${t.type}`)}}}function sl(e){let t=[];for(let s of e.assignments)t.push(rl(s));e.name&&t.push(ie(e.name));for(let s of e.args)t.push(ie(s));for(let s of e.redirections)t.push(Yi(s));return t.join(\" \")}function rl(e){let t=e.append?\"+=\":\"=\";if(e.array){let s=e.array.map(ie).join(\" \");return`${e.name}${t}(${s})`}return e.value?`${e.name}${t}${ie(e.value)}`:`${e.name}${t}`}function ie(e){return e.parts.map(t=>_s(t,!1)).join(\"\")}function Qe(e){return e.parts.map(t=>_s(t,!0)).join(\"\")}function _s(e,t){switch(e.type){case\"Literal\":return t?il(e.value):nl(e.value);case\"SingleQuoted\":return`'${e.value}'`;case\"DoubleQuoted\":return`\"${e.parts.map(s=>_s(s,!0)).join(\"\")}\"`;case\"Escaped\":return`\\\\${e.value}`;case\"ParameterExpansion\":return Ki(e);case\"CommandSubstitution\":return e.legacy?`\\`${ot(e.body)}\\``:`$(${ot(e.body)})`;case\"ArithmeticExpansion\":return`$((${Z(e.expression.expression)}))`;case\"ProcessSubstitution\":return e.direction===\"input\"?`<(${ot(e.body)})`:`>(${ot(e.body)})`;case\"BraceExpansion\":return cl(e);case\"TildeExpansion\":return e.user!==null?`~${e.user}`:\"~\";case\"Glob\":return e.pattern;default:{let s=e;throw new Error(`Unsupported word part type: ${s.type}`)}}}function nl(e){return e.replace(/[\\s\\\\'\"`!|&;()<>{}[\\]*?~#]/g,\"\\\\$&\")}function il(e){return e.replace(/[$`\"\\\\]/g,\"\\\\$&\")}function ol(e,t){return e.parts.map(s=>al(s,t)).join(\"\")}function al(e,t){switch(e.type){case\"Literal\":return t?e.value:e.value.replace(/[$`]/g,\"\\\\$&\");case\"Escaped\":return`\\\\${e.value}`;case\"ParameterExpansion\":return Ki(e);case\"CommandSubstitution\":return e.legacy?`\\`${ot(e.body)}\\``:`$(${ot(e.body)})`;case\"ArithmeticExpansion\":return`$((${Z(e.expression.expression)}))`;default:return _s(e,!1)}}function Ki(e){return e.operation?`\\${${Xi(e.parameter,e.operation)}}`:ll(e.parameter)?`\\${${e.parameter}}`:`$${e.parameter}`}function ll(e){return!(/^[?#@*$!\\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function Xi(e,t){switch(t.type){case\"Length\":return`#${e}`;case\"LengthSliceError\":return`#${e}:`;case\"BadSubstitution\":return t.text;case\"DefaultValue\":return`${e}${t.checkEmpty?\":\":\"\"}-${Qe(t.word)}`;case\"AssignDefault\":return`${e}${t.checkEmpty?\":\":\"\"}=${Qe(t.word)}`;case\"ErrorIfUnset\":return`${e}${t.checkEmpty?\":\":\"\"}?${t.word?Qe(t.word):\"\"}`;case\"UseAlternative\":return`${e}${t.checkEmpty?\":\":\"\"}+${Qe(t.word)}`;case\"Substring\":{let s=Z(t.offset.expression);return t.length?`${e}:${s}:${Z(t.length.expression)}`:`${e}:${s}`}case\"PatternRemoval\":{let s=t.side===\"prefix\"?\"#\":\"%\",r=t.greedy?`${s}${s}`:s;return`${e}${r}${Qe(t.pattern)}`}case\"PatternReplacement\":{let s=\"/\";t.all?s=\"//\":t.anchor===\"start\"?s=\"/#\":t.anchor===\"end\"&&(s=\"/%\");let r=t.replacement?`/${Qe(t.replacement)}`:\"\";return`${e}${s}${Qe(t.pattern)}${r}`}case\"CaseModification\":{let s=t.direction===\"upper\"?\"^\":\",\",r=t.all?`${s}${s}`:s,n=t.pattern?Qe(t.pattern):\"\";return`${e}${r}${n}`}case\"Transform\":return`${e}@${t.operator}`;case\"Indirection\":return t.innerOp?`!${Xi(e,t.innerOp)}`:`!${e}`;case\"ArrayKeys\":return`!${t.array}[${t.star?\"*\":\"@\"}]`;case\"VarNamePrefix\":return`!${t.prefix}${t.star?\"*\":\"@\"}`;default:{let s=t;throw new Error(`Unsupported parameter operation type: ${s.type}`)}}}function cl(e){return`{${e.items.map(ul).join(\",\")}}`}function ul(e){if(e.type===\"Word\")return ie(e.word);let t=e.startStr??String(e.start),s=e.endStr??String(e.end);return e.step!==void 0?`${t}..${s}..${e.step}`:`${t}..${s}`}function Yi(e){let t=e.fdVariable?`{${e.fdVariable}}`:e.fd!==null?String(e.fd):\"\";if(e.operator===\"<<\"||e.operator===\"<<-\"){let s=e.target,r=s.quoted?`'${s.delimiter}'`:s.delimiter,n=ol(s.content,s.quoted);return`${t}${e.operator}${r}\n${n}${s.delimiter}`}return e.operator===\"<<<\"?`${t}<<< ${ie(e.target)}`:e.operator===\"&>\"||e.operator===\"&>>\"?`${e.operator} ${ie(e.target)}`:`${t}${e.operator} ${ie(e.target)}`}function Ce(e){return e.length===0?\"\":` ${e.map(Yi).join(\" \")}`}function $e(e){return e.map(qi).join(`\n`)}function fl(e){let t=[];for(let s=0;s<e.clauses.length;s++){let r=e.clauses[s],n=s===0?\"if\":\"elif\";t.push(`${n} ${$e(r.condition)}; then\n${$e(r.body)}`)}return e.elseBody&&t.push(`else\n${$e(e.elseBody)}`),`${t.join(`\n`)}\nfi${Ce(e.redirections)}`}function dl(e){let t;if(e.words===null)t=`for ${e.variable}`;else{let s=e.words.map(ie).join(\" \");t=`for ${e.variable} in ${s}`}return`${t}; do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function hl(e){let t=e.init?Z(e.init.expression):\"\",s=e.condition?Z(e.condition.expression):\"\",r=e.update?Z(e.update.expression):\"\";return`for ((${t}; ${s}; ${r})); do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function pl(e){return`while ${$e(e.condition)}; do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function ml(e){return`until ${$e(e.condition)}; do\n${$e(e.body)}\ndone${Ce(e.redirections)}`}function yl(e){let t=e.items.map(gl).join(`\n`);return`case ${ie(e.word)} in\n${t}\nesac${Ce(e.redirections)}`}function gl(e){let t=e.patterns.map(ie).join(\" | \"),s=$e(e.body);return s?`${t})\n${s}\n${e.terminator}`:`${t})\n${e.terminator}`}function wl(e){return`(${$e(e.body)})${Ce(e.redirections)}`}function vl(e){return`{ ${$e(e.body)}; }${Ce(e.redirections)}`}function bl(e){return`((${Z(e.expression.expression)}))${Ce(e.redirections)}`}function El(e){return`[[ ${it(e.expression)} ]]${Ce(e.redirections)}`}function $l(e){let t=Gi(e.body);return`${e.name}() ${t}${Ce(e.redirections)}`}function Z(e){switch(e.type){case\"ArithNumber\":return String(e.value);case\"ArithVariable\":return e.hasDollarPrefix?`$${e.name}`:e.name;case\"ArithSpecialVar\":return`$${e.name}`;case\"ArithBinary\":return`${Z(e.left)} ${e.operator} ${Z(e.right)}`;case\"ArithUnary\":return e.prefix?`${e.operator}${Z(e.operand)}`:`${Z(e.operand)}${e.operator}`;case\"ArithTernary\":return`${Z(e.condition)} ? ${Z(e.consequent)} : ${Z(e.alternate)}`;case\"ArithAssignment\":return`${e.subscript?`${e.variable}[${Z(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${Z(e.value)}`;case\"ArithDynamicAssignment\":return`${e.subscript?`${Z(e.target)}[${Z(e.subscript)}]`:Z(e.target)} ${e.operator} ${Z(e.value)}`;case\"ArithDynamicElement\":return`${Z(e.nameExpr)}[${Z(e.subscript)}]`;case\"ArithGroup\":return`(${Z(e.expression)})`;case\"ArithNested\":return`$((${Z(e.expression)}))`;case\"ArithCommandSubst\":return`$(${e.command})`;case\"ArithBracedExpansion\":return`\\${${e.content}}`;case\"ArithArrayElement\":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${Z(e.index)}]`:e.array;case\"ArithDynamicBase\":return`\\${${e.baseExpr}}#${e.value}`;case\"ArithDynamicNumber\":return`\\${${e.prefix}}${e.suffix}`;case\"ArithConcat\":return e.parts.map(Z).join(\"\");case\"ArithDoubleSubscript\":return`${e.array}[${Z(e.index)}]`;case\"ArithNumberSubscript\":return`${e.number}[${e.errorToken}]`;case\"ArithSyntaxError\":return e.errorToken;case\"ArithSingleQuote\":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function it(e){switch(e.type){case\"CondBinary\":return`${ie(e.left)} ${e.operator} ${ie(e.right)}`;case\"CondUnary\":return`${e.operator} ${ie(e.operand)}`;case\"CondNot\":return`! ${it(e.operand)}`;case\"CondAnd\":return`${it(e.left)} && ${it(e.right)}`;case\"CondOr\":return`${it(e.left)} || ${it(e.right)}`;case\"CondGroup\":return`( ${it(e.expression)} )`;case\"CondWord\":return ie(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var Ft=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let s=t.fs??new ze(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?\"/home/user\":\"/\"),n=new Map([[\"HOME\",this.useDefaultLayout?\"/home/user\":\"/\"],[\"PATH\",\"/usr/bin:/bin\"],[\"IFS\",` \t\n`],[\"OSTYPE\",\"linux-gnu\"],[\"MACHTYPE\",\"x86_64-pc-linux-gnu\"],[\"HOSTTYPE\",\"x86_64\"],[\"HOSTNAME\",\"localhost\"],[\"PWD\",r],[\"OLDPWD\",r],[\"OPTIND\",\"1\"],...Object.entries(t.env??{})]);if(this.limits=Mi({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Ur(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth??!0,this.coverageWriter=t.coverage,this.state={env:n,cwd:r,previousDir:\"/home/user\",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:\"\",startTime:Date.now(),lastBackgroundPid:0,virtualPid:t.processInfo?.pid??1,virtualPpid:t.processInfo?.ppid??0,virtualUid:t.processInfo?.uid??1e3,virtualGid:t.processInfo?.gid??1e3,bashPid:t.processInfo?.pid??1,nextVirtualPid:(t.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set([\"HOME\",\"PATH\",\"PWD\",\"OLDPWD\",...Object.keys(t.env||{})]),readonlyVars:new Set([\"SHELLOPTS\",\"BASHOPTS\"]),hashTable:new Map},this.state.env.set(\"SHELLOPTS\",Zs(this.state.options)),this.state.env.set(\"BASHOPTS\",qs(this.state.shoptOptions)),vn(s,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!==\"/\"&&s instanceof ze)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let o of hn(t.commands))this.registerCommand(o);if(t.fetch||t.network)for(let o of pn())this.registerCommand(o);if(t.python)for(let o of mn())this.registerCommand(o);let i=typeof t.javascript==\"object\"?t.javascript:Object.create(null);if(t.javascript||i.invokeTool){for(let o of yn())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(t.customCommands)for(let o of t.customCommands)gn(o)?this.registerCommand(wn(o)):this.registerCommand({...o,trusted:o.trusted??!0})}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync==\"function\"){let r=`#!/bin/bash\n# Built-in command: ${t.name}\n`;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.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.stdout=Ji(t.stdout),t.stderr=Ji(t.stderr),t}async exec(t,s){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.\n`,exitCode:1,env:ve(this.state.env,s?.env)};if(!t.trim())return{stdout:\"\",stderr:\"\",exitCode:0,env:ve(this.state.env,s?.env)};this.logger?.info(\"exec\",{command:t});let r=s?.cwd??this.state.cwd,n,i=r;if(s?.cwd)if(s.env&&\"PWD\"in s.env)n=s.env.PWD;else if(s?.env&&!(\"PWD\"in s.env))try{n=await this.fs.realpath(r),i=n}catch{n=r}else n=r;let o=s?.replaceEnv?new Map:new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);n!==void 0&&o.set(\"PWD\",n);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:Pl(s?.stdin,s?.stdinKind),signal:s?.signal,extraArgs:s?.args},l=t;s?.rawScript||(l=Qi(t));let c=this.defenseInDepthConfig?me.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let d=fe(l,{maxHeredocSize:this.limits.maxHeredocSize}),p;if(this.transformPlugins.length>0){let g=Object.create(null);for(let b of this.transformPlugins){let m=b.transform({ast:d,metadata:g});d=m.ast,m.metadata&&(g=Ct(g,m.metadata))}p=g}let y={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},E=await new It(y,a).executeScript(d);return p&&(E.metadata=p),this.logResult(E)};return u?await u.run(f):await f()}catch(f){if(f instanceof j)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof Pe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof Je)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:ve(this.state.env,s?.env)});if(f instanceof Ht)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:ve(this.state.env,s?.env)});if(f instanceof J)return this.logResult({stdout:f.stdout,stderr:Le(f.stderr),exitCode:J.EXIT_CODE,env:ve(this.state.env,s?.env)});if(f instanceof Ve)return this.logResult({stdout:\"\",stderr:`bash: security violation: ${Le(f.message)}\n`,exitCode:1,env:ve(this.state.env,s?.env)});if(f.name===\"ParseException\")return this.logResult({stdout:\"\",stderr:`bash: syntax error: ${Le(f.message)}\n`,exitCode:2,env:ve(this.state.env,s?.env)});if(f instanceof Qr)return this.logResult({stdout:\"\",stderr:`bash: ${Le(f.message)}\n`,exitCode:2,env:ve(this.state.env,s?.env)});if(f instanceof RangeError)return this.logResult({stdout:\"\",stderr:`bash: ${Le(f.message)}\n`,exitCode:1,env:ve(this.state.env,s?.env)});throw f}finally{u?.deactivate()}}async readFile(t){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,t))}async writeFile(t,s){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,t),s)}getCwd(){return this.state.cwd}getEnv(){return Ue(this.state.env)}registerTransformPlugin(t){this.transformPlugins.push(t)}transform(t){let s=Qi(t),r=fe(s,{maxHeredocSize:this.limits.maxHeredocSize}),n=Object.create(null);for(let i of this.transformPlugins){let o=i.transform({ast:r,metadata:n});r=o.ast,o.metadata&&(n=Ct(n,o.metadata))}return{script:Lt(r),ast:r,metadata:n}}};function Qi(e){let t=e.split(`\n`),s=[],r=[];for(let n=0;n<t.length;n++){let i=t[n];if(r.length>0){let l=r[r.length-1];if((l.stripTabs?i.replace(/^\\t+/,\"\"):i)===l.delimiter){s.push(i.trimStart()),r.pop();continue}s.push(i);continue}let o=i.trimStart();s.push(o);let a=/<<(-?)\\s*(['\"]?)([\\w-]+)\\2/g;for(let l of o.matchAll(a)){let c=l[1]===\"-\",u=l[3];r.push({delimiter:u,stripTabs:c})}}return s.join(`\n`)}var Sl=new TextDecoder(\"utf-8\",{fatal:!0});function Ji(e){if(!e)return e;let t=!1;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n>255)return e;n>127&&(t=!0)}if(!t)return e;let s=new Uint8Array(e.length);for(let r=0;r<e.length;r++)s[r]=e.charCodeAt(r);try{return Sl.decode(s)}catch{return e}}function Pl(e,t){if(e!==void 0)return t===\"bytes\"?e:Be(e)}var Cs=class{baseFs;mounts=new Map;constructor(t){if(this.baseFs=t?.base??new ze,t?.mounts)for(let{mountPoint:s,filesystem:r}of t.mounts)this.mount(s,r)}mount(t,s){this.validateMountPath(t);let r=O(t);this.validateMount(r),this.mounts.set(r,{mountPoint:r,filesystem:s})}unmount(t){let s=O(t);if(!this.mounts.has(s))throw new Error(`No filesystem mounted at '${t}'`);this.mounts.delete(s)}getMounts(){return Array.from(this.mounts.values()).map(t=>({mountPoint:t.mountPoint,filesystem:t.filesystem}))}isMountPoint(t){let s=O(t);return this.mounts.has(s)}validateMountPath(t){let s=t.split(\"/\");for(let r of s)if(r===\".\"||r===\"..\")throw new Error(`Invalid mount point '${t}': contains '.' or '..' segments`)}validateMount(t){if(t===\"/\")throw new Error(\"Cannot mount at root '/'\");for(let s of this.mounts.keys())if(s!==t){if(t.startsWith(`${s}/`))throw new Error(`Cannot mount at '${t}': inside existing mount '${s}'`);if(s.startsWith(`${t}/`))throw new Error(`Cannot mount at '${t}': would contain existing mount '${s}'`)}}routePath(t){x(t,\"access\");let s=O(t),r=null,n=0;for(let i of this.mounts.values()){let o=i.mountPoint;if(s===o)return{fs:i.filesystem,relativePath:\"/\"};s.startsWith(`${o}/`)&&o.length>n&&(r=i,n=o.length)}if(r){let i=s.slice(n);return{fs:r.filesystem,relativePath:i||\"/\"}}return{fs:this.baseFs,relativePath:s}}getChildMountPoints(t){let s=O(t),r=s===\"/\"?\"/\":`${s}/`,n=[];for(let i of this.mounts.keys())if(i.startsWith(r)){let a=i.slice(r.length).split(\"/\")[0];a&&!n.includes(a)&&n.push(a)}return n}async readFile(t,s){let{fs:r,relativePath:n}=this.routePath(t);return r.readFile(n,s)}async readFileBytes(t){let{fs:s,relativePath:r}=this.routePath(t);return Vt(s,r)}async readFileBuffer(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readFileBuffer(r)}async writeFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.writeFile(i,s,r)}async appendFile(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.appendFile(i,s,r)}async exists(t){let s=O(t);if(this.mounts.has(s)||this.getChildMountPoints(s).length>0)return!0;let{fs:n,relativePath:i}=this.routePath(t);return n.exists(i)}async stat(t){let s=O(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.stat(\"/\")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.stat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(t);return i.stat(o)}async lstat(t){let s=O(t),r=this.mounts.get(s);if(r)try{return await r.filesystem.lstat(\"/\")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(s).length>0)try{return await this.baseFs.lstat(s)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(t);return i.lstat(o)}async mkdir(t,s){let r=O(t);if(this.mounts.has(r)){if(s?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${t}'`)}if(this.getChildMountPoints(r).length>0&&s?.recursive)return;let{fs:i,relativePath:o}=this.routePath(t);return i.mkdir(o,s)}async readdir(t){let s=O(t),r=new Set,n=null,{fs:i,relativePath:o}=this.routePath(t);try{let l=await i.readdir(o);for(let c of l)r.add(c)}catch(l){let c=l.code,u=l.message||\"\";if(c!==\"ENOENT\"&&!u.includes(\"ENOENT\"))throw l;n=l}let a=this.getChildMountPoints(s);for(let l of a)r.add(l);if(r.size===0&&n&&!this.mounts.has(s))throw n;return Array.from(r).sort()}async rm(t,s){let r=O(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot remove '${t}'`);if(this.getChildMountPoints(r).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${t}'`);let{fs:i,relativePath:o}=this.routePath(t);return i.rm(o,s)}async cp(t,s,r){let n=this.routePath(t),i=this.routePath(s);return n.fs===i.fs?n.fs.cp(n.relativePath,i.relativePath,r):this.crossMountCopy(t,s,r)}async mv(t,s){let r=O(t);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot move '${t}'`);let n=this.routePath(t),i=this.routePath(s);if(n.fs===i.fs)return n.fs.mv(n.relativePath,i.relativePath);await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){return qe(t,s)}getAllPaths(){let t=new Set;for(let s of this.baseFs.getAllPaths())t.add(s);for(let s of this.mounts.keys()){let r=s.split(\"/\").filter(Boolean),n=\"\";for(let o of r)n=`${n}/${o}`,t.add(n);let i=this.mounts.get(s);if(i)for(let o of i.filesystem.getAllPaths())o===\"/\"?t.add(s):t.add(`${s}${o}`)}return Array.from(t).sort()}async chmod(t,s){let r=O(t),n=this.mounts.get(r);if(n)return n.filesystem.chmod(\"/\",s);let{fs:i,relativePath:o}=this.routePath(t);return i.chmod(o,s)}async symlink(t,s){let{fs:r,relativePath:n}=this.routePath(s);return r.symlink(t,n)}async link(t,s){let r=this.routePath(t),n=this.routePath(s);if(r.fs!==n.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${t}' -> '${s}'`);return r.fs.link(r.relativePath,n.relativePath)}async readlink(t){let{fs:s,relativePath:r}=this.routePath(t);return s.readlink(r)}async realpath(t){let s=O(t);if(this.mounts.get(s))return s;let{fs:n,relativePath:i}=this.routePath(t),o=await n.realpath(i);for(let[a,l]of this.mounts)if(s===a||s.startsWith(`${a}/`))return o===\"/\"?a:`${a}${o}`;return o}async crossMountCopy(t,s,r){let n=await this.lstat(t);if(n.isFile){let i=await this.readFileBuffer(t);await this.writeFile(s,i),await this.chmod(s,n.mode)}else if(n.isDirectory){if(!r?.recursive)throw new Error(`cp: ${t} is a directory (not copied)`);await this.mkdir(s,{recursive:!0});let i=await this.readdir(t);for(let o of i){let a=Ge(t,o),l=Ge(s,o);await this.crossMountCopy(a,l,r)}}else if(n.isSymbolicLink){let i=await this.readlink(t);await this.symlink(i,s)}}async utimes(t,s,r){let{fs:n,relativePath:i}=this.routePath(t);return n.utimes(i,s,r)}};import*as q from\"node:fs\";import*as ae from\"node:path\";import*as Se from\"node:fs\";import*as ce from\"node:path\";function Ne(e,t){if(e===t)return!0;let s=e[t.length];return(s===\"/\"||s===\"\\\\\")&&e.startsWith(t)}function at(e,t){try{let s=Se.realpathSync(e);return Ne(s,t)?s:null}catch(s){if(s.code===\"ENOENT\"){let r=ce.dirname(e);if(r===e)return null;let n=at(r,t);if(n===null)return null;try{if(Se.lstatSync(e).isSymbolicLink()){let o=Se.readlinkSync(e),a=ce.isAbsolute(o)?o:ce.resolve(ce.dirname(e),o);if(at(a,t)===null)return null}}catch{}return ce.join(n,ce.basename(e))}return null}}function Ns(e,t,s){let r=at(e,s);if(r===null)return null;let n=ce.resolve(e),i=n.slice(t.length),o=r.slice(s.length);if(i!==o)return null;try{if(Se.lstatSync(n).isSymbolicLink())return null}catch{}return r}function Os(e,t){if(!Se.existsSync(e))throw new Error(`${t} root does not exist`);if(!Se.statSync(e).isDirectory())throw new Error(`${t} root is not a directory`)}function eo(e,t){if(!ce.isAbsolute(e))return{withinRoot:!0,relativePath:e};let s;try{s=Se.realpathSync(e)}catch{s=ce.resolve(e)}return Ne(s,t)?{withinRoot:!0,relativePath:s.slice(t.length).replace(/\\\\/g,\"/\")||\"/\"}:{withinRoot:!1,safeName:ce.basename(e)}}function xs(e,t,s,r){let n=e;if(n.path===void 0){for(let o of r)if(n.message?.includes(o))throw e}let i=n.code||\"EIO\";throw new Error(`${i}: ${s} '${t}'`)}var Al=[\"ELOOP\",\"EFBIG\",\"EPERM\"],kl=\"/home/user/project\",$t=class{root;canonicalRoot;mountPoint;readOnly;maxFileReadSize;allowSymlinks;memory=new Map;deleted=new Set;constructor(t){this.root=ae.resolve(t.root);let s=t.mountPoint??kl;if(this.mountPoint=s===\"/\"?\"/\":s.replace(/\\/+$/,\"\"),!this.mountPoint.startsWith(\"/\"))throw new Error(`Mount point must be an absolute path: ${s}`);this.readOnly=t.readOnly??!1,this.maxFileReadSize=t.maxFileReadSize??10485760,this.allowSymlinks=t.allowSymlinks??!1,Os(this.root,\"OverlayFs\"),this.canonicalRoot=q.realpathSync(this.root),this.createMountPointDirs()}assertWritable(t){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${t}`)}createMountPointDirs(){let t=this.mountPoint.split(\"/\").filter(Boolean),s=\"\";for(let r of t)s+=`/${r}`,this.memory.has(s)||this.memory.set(s,{type:\"directory\",mode:493,mtime:new Date});this.memory.has(\"/\")||this.memory.set(\"/\",{type:\"directory\",mode:493,mtime:new Date})}getMountPoint(){return this.mountPoint}mkdirSync(t,s){let n=O(t).split(\"/\").filter(Boolean),i=\"\";for(let o of n)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:\"directory\",mode:493,mtime:new Date})}writeFileSync(t,s){let r=O(t),n=this.getDirname(r);n!==\"/\"&&this.mkdirSync(n);let i=s instanceof Uint8Array?s:new TextEncoder().encode(s);this.memory.set(r,{type:\"file\",content:i,mode:420,mtime:new Date})}getDirname(t){let s=t.lastIndexOf(\"/\");return s===0?\"/\":t.slice(0,s)}getRelativeToMount(t){return this.mountPoint===\"/\"?t:t===this.mountPoint?\"/\":t.startsWith(`${this.mountPoint}/`)?t.slice(this.mountPoint.length):null}toRealPath(t){let s=O(t),r=this.getRelativeToMount(s);if(r===null)return null;let n=ae.join(this.root,r),i=ae.resolve(n);return Ne(i,this.root)?i:null}resolveRealPath_(t){return t?this.allowSymlinks?at(t,this.canonicalRoot):Ns(t,this.root,this.canonicalRoot):null}resolveRealPathParent_(t){if(!t)return null;let s=ae.dirname(t),r=this.resolveRealPath_(s);return r===null?null:ae.join(r,ae.basename(t))}sanitizeError(t,s,r){xs(t,s,r,Al)}ensureParentDirs(t){let s=st(t);s!==\"/\"&&(this.memory.has(s)||(this.ensureParentDirs(s),this.memory.set(s,{type:\"directory\",mode:493,mtime:new Date})),this.deleted.delete(s))}async existsInOverlay(t){let s=O(t);if(this.deleted.has(s))return!1;if(this.memory.has(s))return!0;let r=this.resolveRealPathParent_(this.toRealPath(s));if(!r)return!1;try{return await q.promises.lstat(r),!0}catch{return!1}}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,\"binary\")}async readFileBuffer(t,s=new Set){x(t,\"open\");let r=O(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${t}'`);let n=this.memory.get(r);if(n){if(n.type===\"symlink\"){let o=this.resolveSymlink(r,n.target);return this.readFileBuffer(o,s)}if(n.type!==\"file\")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, open '${t}'`);try{let o=await q.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, open '${t}'`);let c=await q.promises.readlink(i),u=this.realTargetToVirtual(r,c),f=this.resolveSymlink(r,u);return this.readFileBuffer(f,s)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${o.size} bytes, max ${this.maxFileReadSize})`);let a=this.allowSymlinks?q.constants.O_RDONLY:q.constants.O_RDONLY|q.constants.O_NOFOLLOW,l=await q.promises.open(i,a);try{let c=await l.readFile();return new Uint8Array(c)}finally{await l.close()}}catch(o){let a=o.code;if(a===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(a===\"ELOOP\")throw new Error(`ENOENT: no such file or directory, open '${t}'`);this.sanitizeError(o,t,\"open\")}}async writeFile(t,s,r){x(t,\"write\"),this.assertWritable(`write '${t}'`);let n=O(t);this.ensureParentDirs(n);let i=be(r),o=Fe(s,i);this.memory.set(n,{type:\"file\",content:o,mode:420,mtime:new Date}),this.deleted.delete(n)}async appendFile(t,s,r){x(t,\"append\"),this.assertWritable(`append '${t}'`);let n=O(t),i=be(r),o=Fe(s,i),a;try{a=await this.readFileBuffer(n)}catch{a=new Uint8Array(0)}let l=new Uint8Array(a.length+o.length);l.set(a),l.set(o,a.length),this.ensureParentDirs(n),this.memory.set(n,{type:\"file\",content:l,mode:420,mtime:new Date}),this.deleted.delete(n)}async exists(t){return t.includes(\"\\0\")?!1:this.existsInOverlay(t)}async stat(t,s=new Set){x(t,\"stat\");let r=O(t);if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, stat '${t}'`);if(s.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let n=this.memory.get(r);if(n){if(n.type===\"symlink\"){let a=this.resolveSymlink(r,n.target);return this.stat(a,s)}let o=0;return n.type===\"file\"&&(o=n.content.length),{isFile:n.type===\"file\",isDirectory:n.type===\"directory\",isSymbolicLink:!1,mode:n.mode,size:o,mtime:n.mtime}}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);try{let o=await q.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let a=await q.promises.readlink(i),l=this.realTargetToVirtual(r,a),c=this.resolveSymlink(r,l);return this.stat(c,s)}return{isFile:o.isFile(),isDirectory:o.isDirectory(),isSymbolicLink:!1,mode:o.mode,size:o.size,mtime:o.mtime}}catch(o){if(o.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, stat '${t}'`);this.sanitizeError(o,t,\"stat\")}}async lstat(t){x(t,\"lstat\");let s=O(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);let r=this.memory.get(s);if(r){if(r.type===\"symlink\")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime};let i=0;return r.type===\"file\"&&(i=r.content.length),{isFile:r.type===\"file\",isDirectory:r.type===\"directory\",isSymbolicLink:!1,mode:r.mode,size:i,mtime:r.mtime}}let n=this.resolveRealPathParent_(this.toRealPath(s));if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);try{let i=await q.promises.lstat(n);return{isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink(),mode:i.mode,size:i.size,mtime:i.mtime}}catch(i){if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);this.sanitizeError(i,t,\"lstat\")}}resolveSymlink(t,s){return ct(t,s)}realTargetToVirtual(t,s){let r=eo(s,this.canonicalRoot);if(r.withinRoot){if(!ae.isAbsolute(s))return s;let n=r.relativePath;return this.mountPoint===\"/\"?n:`${this.mountPoint}${n}`}return r.safeName}async mkdir(t,s){x(t,\"mkdir\"),this.assertWritable(`mkdir '${t}'`);let r=O(t);if(await this.existsInOverlay(r)){if(!s?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${t}'`);return}let i=st(r);if(i!==\"/\"&&!await this.existsInOverlay(i))if(s?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.memory.set(r,{type:\"directory\",mode:493,mtime:new Date}),this.deleted.delete(r)}async readdirCore(t,s){if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let r=new Map,n=new Set,i=s===\"/\"?\"/\":`${s}/`;for(let a of this.deleted)if(a.startsWith(i)){let l=a.slice(i.length),c=l.split(\"/\")[0];c&&!l.includes(\"/\",c.length)&&n.add(c)}for(let[a,l]of this.memory)if(a!==s&&a.startsWith(i)){let c=a.slice(i.length),u=c.split(\"/\")[0];u&&!n.has(u)&&!c.includes(\"/\",1)&&r.set(u,{name:u,isFile:l.type===\"file\",isDirectory:l.type===\"directory\",isSymbolicLink:l.type===\"symlink\"})}let o=this.resolveRealPath_(this.toRealPath(s));if(o)try{if(!this.allowSymlinks&&(await q.promises.lstat(o)).isSymbolicLink()){if(!this.memory.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);return r}let a=await q.promises.readdir(o,{withFileTypes:!0});for(let l of a)!n.has(l.name)&&!r.has(l.name)&&r.set(l.name,{name:l.name,isFile:l.isFile(),isDirectory:l.isDirectory(),isSymbolicLink:l.isSymbolicLink()})}catch(a){if(a.code===\"ENOENT\"){if(!this.memory.has(s))throw new Error(`ENOENT: no such file or directory, scandir '${t}'`)}else a.code!==\"ENOTDIR\"&&this.sanitizeError(a,t,\"scandir\")}return r}async resolveForReaddir(t,s=!1){let r=O(t),n=new Set,i=s,o=this.memory.get(r);for(;o&&o.type===\"symlink\";){if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);n.add(r),i=!0,r=this.resolveSymlink(r,o.target),o=this.memory.get(r)}if(o)return{normalized:r,outsideOverlay:!1};if(this.getRelativeToMount(r)===null)return{normalized:r,outsideOverlay:!0};let l=this.resolveRealPath_(this.toRealPath(r));if(!l)return{normalized:r,outsideOverlay:!0};try{if((await q.promises.lstat(l)).isSymbolicLink()){if(!this.allowSymlinks)return{normalized:r,outsideOverlay:!0};let u=await q.promises.readlink(l),f=this.realTargetToVirtual(r,u),d=this.resolveSymlink(r,f);return this.resolveForReaddir(d,!0)}return{normalized:r,outsideOverlay:!1}}catch{return i?{normalized:r,outsideOverlay:!0}:{normalized:r,outsideOverlay:!1}}}async readdir(t){x(t,\"scandir\");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.keys()).sort((i,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(t){x(t,\"scandir\");let{normalized:s,outsideOverlay:r}=await this.resolveForReaddir(t);if(r)return[];let n=await this.readdirCore(t,s);return Array.from(n.values()).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(t,s){x(t,\"rm\"),this.assertWritable(`rm '${t}'`);let r=O(t);if(!await this.existsInOverlay(r)){if(s?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}try{if((await this.stat(r)).isDirectory){let o=await this.readdir(r);if(o.length>0){if(!s?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let a of o){let l=r===\"/\"?`/${a}`:`${r}/${a}`;await this.rm(l,s)}}}}catch(i){if(i instanceof Error&&(i.message.includes(\"ENOTEMPTY\")||i.message.includes(\"EISDIR\")))throw i}this.memory.delete(r),this.existsOnRealFs(r)&&this.deleted.add(r)}existsOnRealFs(t){let s=this.toRealPath(t),r=this.resolveRealPathParent_(s);if(!r)return!1;try{return q.lstatSync(r),!0}catch{return!1}}async cp(t,s,r){x(t,\"cp\"),x(s,\"cp\"),this.assertWritable(`cp '${s}'`);let n=O(t),i=O(s);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, cp '${t}'`);let a=await this.stat(n);if(a.isFile){let l=await this.readFileBuffer(n);await this.writeFile(i,l)}else if(a.isDirectory){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(n);for(let c of l){let u=n===\"/\"?`/${c}`:`${n}/${c}`,f=i===\"/\"?`/${c}`:`${i}/${c}`;await this.cp(u,f,r)}}}async mv(t,s){this.assertWritable(`mv '${s}'`),await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0})}resolvePath(t,s){return qe(t,s)}getAllPaths(){let t=new Set(this.memory.keys());for(let s of this.deleted)t.delete(s);return this.scanRealFs(\"/\",t),Array.from(t)}scanRealFs(t,s){if(this.deleted.has(t))return;let r=this.resolveRealPath_(this.toRealPath(t));if(r)try{let n=q.readdirSync(r);for(let i of n){let o=t===\"/\"?`/${i}`:`${t}/${i}`;if(this.deleted.has(o))continue;s.add(o);let a=ae.join(r,i);q.lstatSync(a).isDirectory()&&this.scanRealFs(o,s)}}catch{}}async chmod(t,s){x(t,\"chmod\"),this.assertWritable(`chmod '${t}'`);let r=O(t);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);let i=this.memory.get(r);if(i){i.mode=s;return}let o=await this.stat(r);if(o.isFile){let a=await this.readFileBuffer(r);this.memory.set(r,{type:\"file\",content:a,mode:s,mtime:new Date})}else o.isDirectory&&this.memory.set(r,{type:\"directory\",mode:s,mtime:new Date})}async symlink(t,s){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${s}'`);x(s,\"symlink\"),this.assertWritable(`symlink '${s}'`);let r=O(s);if(await this.existsInOverlay(r))throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.ensureParentDirs(r),this.memory.set(r,{type:\"symlink\",target:t,mode:511,mtime:new Date}),this.deleted.delete(r)}async link(t,s){x(t,\"link\"),x(s,\"link\"),this.assertWritable(`link '${s}'`);let r=O(t),n=O(s);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, link '${t}'`);let o=await this.stat(r);if(!o.isFile)throw new Error(`EPERM: operation not permitted, link '${t}'`);if(await this.existsInOverlay(n))throw new Error(`EEXIST: file already exists, link '${s}'`);let l=await this.readFileBuffer(r);this.ensureParentDirs(n),this.memory.set(n,{type:\"file\",content:l,mode:o.mode,mtime:new Date}),this.deleted.delete(n)}async readlink(t){x(t,\"readlink\");let s=O(t);if(this.deleted.has(s))throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);let r=this.memory.get(s);if(r){if(r.type!==\"symlink\")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}let n=this.resolveRealPathParent_(this.toRealPath(s));if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);try{let i=await q.promises.readlink(n);if(!ae.isAbsolute(i)){let o=ae.resolve(ae.dirname(n),i),a;try{a=q.realpathSync(o)}catch{a=o}if(!Ne(a,this.canonicalRoot))return ae.basename(i)}return this.realTargetToVirtual(s,i)}catch(i){if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(i.code===\"EINVAL\")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);this.sanitizeError(i,t,\"readlink\")}}async realpath(t){x(t,\"realpath\");let s=O(t),r=new Set,n=async a=>{let l=a===\"/\"?[]:a.slice(1).split(\"/\"),c=\"\";for(let u of l){if(c=`${c}/${u}`,r.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);let f=this.memory.get(c),d=0,p=40;for(;f&&f.type===\"symlink\"&&d<p;){if(r.add(c),c=this.resolveSymlink(c,f.target),d++,r.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);f=this.memory.get(c)}if(d>=p)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);if(!f){let y=this.toRealPath(c),h=this.resolveRealPath_(y);if(h)try{if((await q.promises.lstat(h)).isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);let E=await q.promises.readlink(h),g=this.realTargetToVirtual(c,E);return r.add(c),c=this.resolveSymlink(c,g),n(c)}}catch(w){if(w.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);this.sanitizeError(w,t,\"realpath\")}else if(!this.allowSymlinks){let w=this.resolveRealPathParent_(y);if(w)try{if((await q.promises.lstat(w)).isSymbolicLink())throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}catch(E){if(E.message?.includes(\"ENOENT\")||E.message?.includes(\"ELOOP\"))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);this.sanitizeError(E,t,\"realpath\")}}}}return c||\"/\"},i=await n(s);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return i}async utimes(t,s,r){x(t,\"utimes\"),this.assertWritable(`utimes '${t}'`);let n=O(t);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);let o=this.memory.get(n);if(o){o.mtime=r;return}let a=await this.stat(n);if(a.isFile){let l=await this.readFileBuffer(n);this.memory.set(n,{type:\"file\",content:l,mode:a.mode,mtime:r})}else a.isDirectory&&this.memory.set(n,{type:\"directory\",mode:a.mode,mtime:r})}};import*as I from\"node:fs\";import*as U from\"node:path\";var _l=[\"EACCES\",\"escaping sandbox\",\"EFBIG\"],Ts=class{root;canonicalRoot;maxFileReadSize;allowSymlinks;constructor(t){this.root=U.resolve(t.root),this.maxFileReadSize=t.maxFileReadSize??10485760,this.allowSymlinks=t.allowSymlinks??!1,Os(this.root,\"ReadWriteFs\"),this.canonicalRoot=I.realpathSync(this.root)}resolveAndValidate(t,s){let r=this.allowSymlinks?at(t,this.canonicalRoot):Ns(t,this.root,this.canonicalRoot);if(r===null)throw new Error(`EACCES: permission denied, '${s}' resolves outside sandbox`);return r}validateParent(t,s){let r=U.dirname(t),n=this.resolveAndValidate(r,s);return U.join(n,U.basename(t))}toRealPath(t){let s=O(t),r=U.join(this.root,s);return U.resolve(r)}async readFile(t,s){let r=await this.readFileBuffer(t),n=be(s);return Me(r,n)}async readFileBytes(t){let s=await this.readFileBuffer(t);return Me(s,\"binary\")}async readFileBuffer(t){x(t,\"open\");let s=this.toRealPath(t),r=this.resolveAndValidate(s,t);try{let n=this.allowSymlinks?I.constants.O_RDONLY:I.constants.O_RDONLY|I.constants.O_NOFOLLOW,i=await I.promises.open(r,n);try{if(this.maxFileReadSize>0){let a=await i.stat();if(a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${t}' (${a.size} bytes, max ${this.maxFileReadSize})`)}let o=await i.readFile();return new Uint8Array(o)}finally{await i.close()}}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(i.code===\"EISDIR\")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);if(i.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(n,t,\"open\")}}async writeFile(t,s,r){x(t,\"write\");let n=this.toRealPath(t),i=this.resolveAndValidate(n,t),o=be(r),a=Fe(s,o),l=U.dirname(i);try{await I.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(n,t);let c=this.allowSymlinks?0:I.constants.O_NOFOLLOW,u=I.constants.O_WRONLY|I.constants.O_CREAT|I.constants.O_TRUNC|c,f=await I.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(c,t,\"write\")}}async appendFile(t,s,r){x(t,\"append\");let n=this.toRealPath(t),i=this.resolveAndValidate(n,t),o=be(r),a=Fe(s,o),l=U.dirname(i);try{await I.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(n,t);let c=this.allowSymlinks?0:I.constants.O_NOFOLLOW,u=I.constants.O_WRONLY|I.constants.O_CREAT|I.constants.O_APPEND|c,f=await I.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(c,t,\"append\")}}async exists(t){if(t.includes(\"\\0\"))return!1;let s=this.toRealPath(t);try{let r=this.resolveAndValidate(s,t);return await I.promises.access(r),!0}catch{return!1}}async stat(t){x(t,\"stat\");let s=this.toRealPath(t),r=this.resolveAndValidate(s,t);try{let n=await I.promises.lstat(r);if(!this.allowSymlinks&&n.isSymbolicLink())throw new Error(`EACCES: permission denied, '${t}' is a symlink`);return{isFile:n.isFile(),isDirectory:n.isDirectory(),isSymbolicLink:n.isSymbolicLink(),mode:n.mode,size:n.size,mtime:n.mtime}}catch(n){if(n.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, stat '${t}'`);this.sanitizeError(n,t,\"stat\")}}async lstat(t){x(t,\"lstat\");let s=this.toRealPath(t),r=this.validateParent(s,t);try{let n=await I.promises.lstat(r);return{isFile:n.isFile(),isDirectory:n.isDirectory(),isSymbolicLink:n.isSymbolicLink(),mode:n.mode,size:n.size,mtime:n.mtime}}catch(n){if(n.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);this.sanitizeError(n,t,\"lstat\")}}async mkdir(t,s){x(t,\"mkdir\");let r=this.toRealPath(t),n=this.resolveAndValidate(r,t);try{await I.promises.mkdir(n,{recursive:s?.recursive})}catch(i){let o=i;if(o.code===\"EEXIST\")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(o.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.sanitizeError(i,t,\"mkdir\")}}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){x(t,\"scandir\");let s=this.toRealPath(t),r=this.resolveAndValidate(s,t);try{if(!this.allowSymlinks&&(await I.promises.lstat(r)).isSymbolicLink())throw new Error(`EACCES: permission denied, '${t}' is a symlink`);return(await I.promises.readdir(r,{withFileTypes:!0})).map(i=>({name:i.name,isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink()})).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(i.code===\"ENOTDIR\")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);this.sanitizeError(n,t,\"scandir\")}}async rm(t,s){x(t,\"rm\");let r=this.toRealPath(t),n=this.resolveAndValidate(r,t);try{await I.promises.rm(n,{recursive:s?.recursive??!1,force:s?.force??!1})}catch(i){let o=i;if(o.code===\"ENOENT\"&&!s?.force)throw new Error(`ENOENT: no such file or directory, rm '${t}'`);if(o.code===\"ENOTEMPTY\")throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);this.sanitizeError(i,t,\"rm\")}}async cp(t,s,r){x(t,\"cp\"),x(s,\"cp\");let n=this.toRealPath(t),i=this.toRealPath(s),o=this.resolveAndValidate(n,t),a=this.resolveAndValidate(i,s);try{await I.promises.cp(o,a,{recursive:r?.recursive??!1,filter:async l=>{try{if(I.lstatSync(l).isSymbolicLink()){let u=await I.promises.realpath(l).catch(()=>null);return u===null?!1:Ne(u,this.canonicalRoot)}return!0}catch(c){return c.code===\"ENOENT\"}}})}catch(l){let c=l;if(c.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(c.code===\"EISDIR\")throw new Error(`EISDIR: is a directory, cp '${t}'`);this.sanitizeError(l,t,\"cp\")}}async mv(t,s){x(t,\"mv\"),x(s,\"mv\");let r=this.toRealPath(t),n=this.toRealPath(s),i=this.validateParent(r,t),o=this.validateParent(n,s);try{if((await I.promises.lstat(i)).isSymbolicLink()){let c=await I.promises.readlink(i),u=U.resolve(U.dirname(o),c),f=await I.promises.realpath(u).catch(()=>u);if(!Ne(f,this.canonicalRoot))throw new Error(`EACCES: permission denied, mv '${t}' -> '${s}' would create symlink escaping sandbox`)}}catch(l){let c=l;if(c.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, mv '${t}'`);if(c.message?.includes(\"EACCES\")||c.message?.includes(\"escaping sandbox\"))throw l}let a=U.dirname(o);try{await I.promises.mkdir(a,{recursive:!0})}catch(l){this.sanitizeError(l,s,\"mv\")}try{await I.promises.rename(i,o)}catch(l){let c=l;if(c.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, mv '${t}'`);if(c.code===\"EXDEV\"){await this.cp(t,s,{recursive:!0}),await this.rm(t,{recursive:!0});return}this.sanitizeError(l,t,\"mv\")}try{if(I.lstatSync(o).isDirectory()&&this.findEscapingSymlinks(o).length>0)throw await I.promises.rename(o,i),new Error(`EACCES: permission denied, mv '${t}' -> '${s}' would create symlinks escaping sandbox`)}catch(l){if(l.message?.includes(\"EACCES\")||l.message?.includes(\"escaping sandbox\"))throw l}}resolvePath(t,s){return qe(t,s)}getAllPaths(){let t=[];return this.scanDir(\"/\",t),t}sanitizeError(t,s,r){xs(t,s,r,_l)}findEscapingSymlinks(t){let s=[];try{let r=I.readdirSync(t);for(let n of r){let i=U.join(t,n);try{let o=I.lstatSync(i);if(o.isSymbolicLink()){let a=I.readlinkSync(i),l=U.resolve(t,a),c;try{c=I.realpathSync(l)}catch{c=l}Ne(c,this.canonicalRoot)||s.push(i)}else o.isDirectory()&&s.push(...this.findEscapingSymlinks(i))}catch{}}}catch{}return s}scanDir(t,s){let r=this.toRealPath(t),n;try{n=this.resolveAndValidate(r,t)}catch{return}try{let i=I.readdirSync(n);for(let o of i){let a=t===\"/\"?`/${o}`:`${t}/${o}`;s.push(a);let l=U.join(n,o);I.lstatSync(l).isDirectory()&&this.scanDir(a,s)}}catch{}}async chmod(t,s){x(t,\"chmod\");let r=this.toRealPath(t),n=this.resolveAndValidate(r,t);try{let i=this.allowSymlinks?I.constants.O_RDONLY:I.constants.O_RDONLY|I.constants.O_NOFOLLOW,o=await I.promises.open(n,i);try{await o.chmod(s)}finally{await o.close()}}catch(i){let o=i;if(o.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);if(o.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(i,t,\"chmod\")}}async symlink(t,s){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${s}'`);x(s,\"symlink\");let r=this.toRealPath(s),n=this.validateParent(r,s),i=O(s),o=O(U.dirname(i)),a=t.startsWith(\"/\")?O(t):O(o===\"/\"?`/${t}`:`${o}/${t}`),l=U.join(this.canonicalRoot,a),c=U.dirname(n),u=t.startsWith(\"/\")?l:U.relative(c,l)||\".\";try{await I.promises.symlink(u,n)}catch(f){if(f.code===\"EEXIST\")throw new Error(`EEXIST: file already exists, symlink '${s}'`);this.sanitizeError(f,s,\"symlink\")}}async link(t,s){x(t,\"link\"),x(s,\"link\");let r=this.toRealPath(t),n=this.toRealPath(s),i=this.resolveAndValidate(r,t),o=this.resolveAndValidate(n,s);try{await I.promises.link(i,o)}catch(a){let l=a;if(l.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(l.code===\"EEXIST\")throw new Error(`EEXIST: file already exists, link '${s}'`);if(l.code===\"EPERM\")throw new Error(`EPERM: operation not permitted, link '${t}'`);this.sanitizeError(a,t,\"link\")}}async readlink(t){x(t,\"readlink\");let s=this.toRealPath(t),r=this.validateParent(s,t);try{let n=await I.promises.readlink(r),i=O(t),o=U.dirname(i),a=U.isAbsolute(n)?n:U.resolve(U.dirname(r),n),l=await I.promises.realpath(a).catch(()=>a);if(Ne(l,this.canonicalRoot)){let c=l.slice(this.canonicalRoot.length)||\"/\";return o===\"/\"?c.startsWith(\"/\")?c.slice(1)||\".\":c:U.relative(o,c)}return U.basename(n)}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(i.code===\"EINVAL\")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);this.sanitizeError(n,t,\"readlink\")}}async realpath(t){x(t,\"realpath\");let s=this.toRealPath(t);try{this.resolveAndValidate(s,t)}catch{throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}let r;try{r=await I.promises.realpath(s)}catch(n){let i=n;if(i.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);if(i.code===\"ELOOP\")throw new Error(`ELOOP: too many levels of symbolic links, realpath '${t}'`);this.sanitizeError(n,t,\"realpath\")}if(Ne(r,this.canonicalRoot))return r.slice(this.canonicalRoot.length)||\"/\";throw new Error(`ENOENT: no such file or directory, realpath '${t}'`)}async utimes(t,s,r){x(t,\"utimes\");let n=this.toRealPath(t),i=this.resolveAndValidate(n,t);try{let o=this.allowSymlinks?I.constants.O_RDONLY:I.constants.O_RDONLY|I.constants.O_NOFOLLOW,a=await I.promises.open(i,o);try{await a.utimes(s,r)}finally{await a.close()}}catch(o){let a=o;if(a.code===\"ENOENT\")throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);if(a.code===\"ELOOP\")throw new Error(`EACCES: permission denied, '${t}' is a symlink`);this.sanitizeError(o,t,\"utimes\")}}};var St=class{cmdId;cwd;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;signal;timeoutMs;abortController=new AbortController;timeoutId;externalAbortListener;resultPromise;constructor(t,s,r,n,i=!1,o,a){this.cmdId=crypto.randomUUID(),this.cwd=r,this.startedAt=new Date,this.bashEnv=t,this.cmdLine=s,this.env=n,this.explicitCwd=i,this.signal=o,this.timeoutMs=a,this.setupCancellation(),this.resultPromise=this.execute()}setupCancellation(){if(this.signal&&(this.signal.aborted?this.abortController.abort(this.signal.reason):(this.externalAbortListener=()=>{this.abortController.abort(this.signal?.reason)},this.signal.addEventListener(\"abort\",this.externalAbortListener,{once:!0}))),this.timeoutMs!==void 0){let t=Math.max(0,this.timeoutMs);this.timeoutId=Mt(()=>{this.abortController.abort(new Error(`sandbox command timeout after ${t}ms`))},t)}}cleanupCancellation(){this.timeoutId!==void 0&&(Wt(this.timeoutId),this.timeoutId=void 0),this.signal&&this.externalAbortListener&&(this.signal.removeEventListener(\"abort\",this.externalAbortListener),this.externalAbortListener=void 0)}async execute(){let t={cwd:this.explicitCwd?this.cwd:void 0,env:this.env,signal:this.abortController.signal};try{let s=await this.bashEnv.exec(this.cmdLine,t);return this.exitCode=s.exitCode,s}finally{this.cleanupCancellation()}}async*logs(){let t=await this.resultPromise;t.stdout&&(yield{type:\"stdout\",data:t.stdout,timestamp:new Date}),t.stderr&&(yield{type:\"stderr\",data:t.stderr,timestamp:new Date})}async wait(){return await this.resultPromise,this}async output(){let t=await this.resultPromise;return t.stdout+t.stderr}async stdout(){return(await this.resultPromise).stdout}async stderr(){return(await this.resultPromise).stderr}async kill(){this.abortController.abort(new Error(\"command killed\"))}};var Ds=class e{bashEnv;timeoutMs;constructor(t,s){this.bashEnv=t,this.timeoutMs=s}static async create(t){let s=t?.fs;if(t?.overlayRoot){if(t?.fs)throw new Error(\"Cannot specify both 'fs' and 'overlayRoot' options\");s=new $t({root:t.overlayRoot})}let r=new Ft({env:t?.env,cwd:t?.cwd,fs:s,maxCallDepth:t?.maxCallDepth,maxCommandCount:t?.maxCommandCount,maxLoopIterations:t?.maxLoopIterations,network:t?.network,defenseInDepth:t?.defenseInDepth});return new e(r,t?.timeoutMs)}async runCommand(t,s,r){let n,i,o,a,l=!1,c,u;if(typeof t==\"object\"){let h=t,w=[h.cmd,...h.args??[]];n=Ls(w),i=h.cwd,o=h.env,a=h.signal,l=h.detached??!1,c=h.stdout,u=h.stderr}else if(Array.isArray(s)){let h=r;n=Ls([t,...s]),a=h?.signal}else{n=t;let h=s;i=h?.cwd,o=h?.env}let f=i??this.bashEnv.getCwd(),d=i!==void 0,p=new St(this.bashEnv,n,f,o,d,a,this.timeoutMs);if(l)return p;let y=await p.wait();if(c){let h=await p.stdout();h&&c.write(h)}if(u){let h=await p.stderr();h&&u.write(h)}return y}async writeFiles(t){let s=this.bashEnv.getCwd();for(let[r,n]of Object.entries(t)){let i;typeof n==\"string\"?i=n:n.encoding===\"base64\"?i=Buffer.from(n.content,\"base64\").toString(\"utf-8\"):i=n.content;let o=this.bashEnv.fs.resolvePath(s,r),a=o.substring(0,o.lastIndexOf(\"/\"))||\"/\";a!==\"/\"&&await this.bashEnv.fs.mkdir(a,{recursive:!0}),await this.bashEnv.writeFile(o,i)}}async readFile(t,s){let r=await this.bashEnv.readFile(t);return s===\"base64\"?Buffer.from(r).toString(\"base64\"):r}async mkDir(t,s){let r=this.bashEnv.fs.resolvePath(this.bashEnv.getCwd(),t);await this.bashEnv.fs.mkdir(r,{recursive:s?.recursive??!1})}async stop(){}async extendTimeout(t){}get domain(){}get bashEnvInstance(){return this.bashEnv}};var Rs=class{violations=[];violationsByType=new Map;options;constructor(t={}){this.options={maxViolationsPerType:t.maxViolationsPerType??100,maxViolationsTotal:t.maxViolationsTotal??1e3,includeStackTraces:t.includeStackTraces??!0,onViolation:t.onViolation??(()=>{}),logToConsole:t.logToConsole??!1}}record(t){let s=this.options.includeStackTraces?t:{...t,stack:void 0};this.violations.unshift(s),this.violations.length>this.options.maxViolationsTotal&&(this.violations.length=this.options.maxViolationsTotal);let r=this.violationsByType.get(t.type);r||(r=[],this.violationsByType.set(t.type,r)),r.length<this.options.maxViolationsPerType&&r.push(s),this.options.logToConsole&&console.warn(`[SecurityViolation] ${t.type}: ${t.message}`,t.path),this.options.onViolation(s)}getViolations(){return[...this.violations]}getViolationsByType(t){return[...this.violationsByType.get(t)??[]]}getSummary(){let t=[];for(let[s,r]of this.violationsByType){if(r.length===0)continue;let n=new Set,i=Number.POSITIVE_INFINITY,o=0;for(let a of r)n.add(a.path),i=Math.min(i,a.timestamp),o=Math.max(o,a.timestamp);t.push({type:s,count:r.length,firstSeen:i,lastSeen:o,paths:Array.from(n)})}return t.sort((s,r)=>r.count-s.count),t}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return t=>this.record(t)}};function to(){return e=>{console.warn(\"[DefenseInDepth] Security violation detected:\",`\n Type: ${e.type}`,`\n Path: ${e.path}`,`\n Message: ${e.message}`,e.executionId?`\n ExecutionId: ${e.executionId}`:\"\")}}var Hr=class{plugins=[];use(t){return this.plugins.push(t),this}transform(t){let s=fe(t),r=Object.create(null);for(let n of this.plugins){let i=n.transform({ast:s,metadata:r});s=i.ast,i.metadata&&(r=Ct(r,i.metadata))}return{script:Lt(s),ast:s,metadata:r}}};var Zr=class{name=\"command-collector\";transform(t){let s=new Set;return this.walkScript(t.ast,s),{ast:t.ast,metadata:{commands:[...s].sort()}}}walkScript(t,s){for(let r of t.statements)this.walkStatement(r,s)}walkStatement(t,s){for(let r of t.pipelines)this.walkPipeline(r,s)}walkPipeline(t,s){for(let r of t.commands)this.walkCommand(r,s)}walkCommand(t,s){switch(t.type){case\"SimpleCommand\":if(t.name){let r=this.extractName(t.name);r&&s.add(r)}t.name&&this.walkWordParts(t.name.parts,s);for(let r of t.args)this.walkWordParts(r.parts,s);for(let r of t.assignments)if(r.value&&this.walkWordParts(r.value.parts,s),r.array)for(let n of r.array)this.walkWordParts(n.parts,s);break;case\"If\":for(let r of t.clauses){for(let n of r.condition)this.walkStatement(n,s);for(let n of r.body)this.walkStatement(n,s)}if(t.elseBody)for(let r of t.elseBody)this.walkStatement(r,s);break;case\"For\":if(t.words)for(let r of t.words)this.walkWordParts(r.parts,s);for(let r of t.body)this.walkStatement(r,s);break;case\"CStyleFor\":for(let r of t.body)this.walkStatement(r,s);break;case\"While\":case\"Until\":for(let r of t.condition)this.walkStatement(r,s);for(let r of t.body)this.walkStatement(r,s);break;case\"Case\":this.walkWordParts(t.word.parts,s);for(let r of t.items)for(let n of r.body)this.walkStatement(n,s);break;case\"Subshell\":case\"Group\":for(let r of t.body)this.walkStatement(r,s);break;case\"ArithmeticCommand\":case\"ConditionalCommand\":break;case\"FunctionDef\":this.walkCommand(t.body,s);break}}walkWordParts(t,s){for(let r of t)switch(r.type){case\"CommandSubstitution\":this.walkScript(r.body,s);break;case\"ProcessSubstitution\":this.walkScript(r.body,s);break;case\"DoubleQuoted\":this.walkWordParts(r.parts,s);break;case\"ParameterExpansion\":r.operation&&this.walkParameterOp(r.operation,s);break}}walkParameterOp(t,s){switch(t.type){case\"DefaultValue\":case\"AssignDefault\":case\"UseAlternative\":this.walkWordParts(t.word.parts,s);break;case\"ErrorIfUnset\":t.word&&this.walkWordParts(t.word.parts,s);break;case\"PatternRemoval\":this.walkWordParts(t.pattern.parts,s);break;case\"PatternReplacement\":this.walkWordParts(t.pattern.parts,s),t.replacement&&this.walkWordParts(t.replacement.parts,s);break;case\"CaseModification\":t.pattern&&this.walkWordParts(t.pattern.parts,s);break;case\"Indirection\":t.innerOp&&this.walkParameterOp(t.innerOp,s);break}}extractName(t){return t.parts.length===1&&t.parts[0].type===\"Literal\"?t.parts[0].value:null}};var qr=class{name=\"tee\";options;counter=0;constructor(t){this.options=t}transform(t){let s=[],r=this.options.timestamp??new Date;return{ast:this.transformScript(t.ast,s,r),metadata:{teeFiles:s}}}formatTimestamp(t){return t.toISOString().replace(/:/g,\"-\")}generateStdoutPath(t,s,r){let n=this.formatTimestamp(r),i=String(t).padStart(3,\"0\");return`${this.options.outputDir}/${n}-${i}-${s}.stdout.txt`}transformScript(t,s,r){return{...t,statements:t.statements.map(n=>this.transformStatement(n,s,r))}}transformStatement(t,s,r){let n=[],i=[];for(let o=0;o<t.pipelines.length;o++){let a=t.pipelines[o];o>0&&i.push(t.operators[o-1]);let l=this.transformPipeline(a,s,r);if(n.push(l.pipeline),l.origCmdNewIndices!==null){let c=l.origCmdNewIndices;i.push(\";\"),n.push(this.makePipestatusSave(c)),i.push(\";\"),n.push(this.makePipestatusRestore(c.length,l.negated))}}return{...t,pipelines:n,operators:i}}transformPipeline(t,s,r){if(t.commands.length<=1)return{pipeline:t,origCmdNewIndices:null,negated:!1};let n=[],i=[],o=[],a=!1;for(let l=0;l<t.commands.length;l++){let c=t.commands[l],u=l===t.commands.length-1;if(c.type!==\"SimpleCommand\"||!c.name||!this.shouldTarget(c)){o.push(n.length),n.push(c),u||i.push(t.pipeStderr?.[l]??!1);continue}let f=this.getCommandName(c.name)??\"unknown\",d=this.counter++,p=this.generateStdoutPath(d,f,r),y=this.makeTeeCommand(p),h=this.serializeCommand(c);s.push({commandIndex:d,commandName:f,command:h,stdoutFile:p}),o.push(n.length),n.push(c),i.push(t.pipeStderr?.[l]??!1),n.push(y),u||i.push(!1),a=!0}return a?{pipeline:{...t,negated:!1,commands:n,pipeStderr:i.length>0?i:void 0},origCmdNewIndices:o,negated:t.negated}:{pipeline:t,origCmdNewIndices:null,negated:!1}}makePipestatusSave(t){return{type:\"Pipeline\",commands:[{type:\"SimpleCommand\",assignments:t.map((s,r)=>({type:\"Assignment\",name:`__tps${r}`,value:{type:\"Word\",parts:[{type:\"ParameterExpansion\",parameter:`PIPESTATUS[${s}]`,operation:null}]},append:!1,array:null})),name:null,args:[],redirections:[]}],negated:!1}}makePipestatusRestore(t,s){let r=[];for(let n=0;n<t;n++)r.push({type:\"Subshell\",body:[{type:\"Statement\",pipelines:[{type:\"Pipeline\",commands:[{type:\"SimpleCommand\",assignments:[],name:{type:\"Word\",parts:[{type:\"Literal\",value:\"exit\"}]},args:[{type:\"Word\",parts:[{type:\"ParameterExpansion\",parameter:`__tps${n}`,operation:null}]}],redirections:[]}],negated:!1}],operators:[],background:!1}],redirections:[]});return{type:\"Pipeline\",commands:r,negated:s}}shouldTarget(t){if(!this.options.targetCommandPattern)return!0;let s=this.getCommandName(t.name);return s!==null&&this.options.targetCommandPattern.test(s)}getCommandName(t){return t&&t.parts.length===1&&t.parts[0].type===\"Literal\"?t.parts[0].value:null}serializeCommand(t){let s=[];t.name&&s.push(ie(t.name));for(let r of t.args)s.push(ie(r));return s.join(\" \")}makeTeeCommand(t){return{type:\"SimpleCommand\",assignments:[],name:{type:\"Word\",parts:[{type:\"Literal\",value:\"tee\"}]},args:[{type:\"Word\",parts:[{type:\"Literal\",value:t}]}],redirections:[]}}};export{Ft as Bash,Hr as BashTransformPipeline,Zr as CommandCollectorPlugin,me as DefenseInDepthBox,oo as EMPTY_BYTES,ze as InMemoryFs,Cs as MountableFs,_e as NetworkAccessDeniedError,$t as OverlayFs,Ts as ReadWriteFs,bt as RedirectNotAllowedError,Ds as Sandbox,St as SandboxCommand,Ve as SecurityViolationError,Rs as SecurityViolationLogger,qr as TeePlugin,vt as TooManyRedirectsError,co as bytesOutput,to as createConsoleViolationCallback,io as decodeBytesToUtf8,mo as defineCommand,Be as encodeUtf8ToBytes,uo as getCommandNames,po as getJavaScriptCommandNames,fo as getNetworkCommandNames,ho as getPythonCommandNames,zt as latin1FromBytes,fe as parse,Lt as serialize,Bt as stdoutAsBytes,ao as stdoutKind,lo as textOutput,At as unsafeBytesFromLatin1};\n","import { a as discoverModuleFileEntries, c as walkTypeScriptFiles, l as entryIdFromFile, o as moduleFileKeyFromPath, s as discoverEntries, t as validateUniqueModuleKeys } from \"./discovery-CWjr_liZ.mjs\";\nimport { pathToFileURL } from \"node:url\";\nimport { resolveAppRoot, runWithAppRoot } from \"@keystrokehq/sandbox\";\nimport { dirname, join, relative, sep } from \"node:path\";\nimport { PromptResponseSchema, ROUTE_MANIFEST_REL_PATH, normalizeCredentialList, parseStoredRouteManifest } from \"@keystrokehq/shared\";\nimport { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from \"node:fs\";\nimport { z } from \"zod\";\n//#region src/guards/agent.ts\nfunction isManifestAgent(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst agent = value;\n\treturn typeof agent.slug === \"string\" && agent.slug.trim().length > 0 && typeof agent.buildRuntime === \"function\" && typeof agent.model === \"string\" && typeof agent.systemPrompt === \"string\";\n}\nfunction validateManifestAgent(value, filePath) {\n\tif (!isManifestAgent(value)) throw new Error(`${filePath} must default-export defineAgent(...)`);\n\treturn value;\n}\n//#endregion\n//#region src/routes.ts\nfunction normalizeWebhookEndpoint(endpoint) {\n\treturn endpoint.replace(/^\\/+|\\/+$/g, \"\").replace(/^triggers\\/?/, \"\");\n}\nfunction agentRouteFromKey(key) {\n\treturn `/agents/${key}`;\n}\nfunction workflowRouteFromKey(key) {\n\treturn `/workflows/${key}`;\n}\nfunction pollRouteFromKey(attachmentKey) {\n\treturn `/triggers/${attachmentKey}/poll`;\n}\nfunction pollGroupRouteFromId(pollId) {\n\treturn `/triggers/polls/${pollId}/run`;\n}\nfunction webhookRouteFromEndpoint(endpoint) {\n\tconst normalized = normalizeWebhookEndpoint(endpoint);\n\tif (!normalized) throw new Error(\"Webhook endpoint must not be empty\");\n\treturn `/triggers/${normalized}`;\n}\n//#endregion\n//#region src/agents/discover.ts\nasync function discoverAgentEntries(agentsDir, options) {\n\tconst files = await discoverModuleFileEntries(agentsDir, {\n\t\tnestedEntry: \"agent\",\n\t\tduplicateLabel: \"agent module file\"\n\t});\n\tconst entries = [];\n\tfor (const { filePath, moduleFile } of files) {\n\t\tconst agent = await importAgentDefinition(filePath, options);\n\t\tentries.push({\n\t\t\tkey: agent.slug,\n\t\t\troute: agentRouteFromKey(agent.slug),\n\t\t\tfilePath,\n\t\t\tmoduleFile\n\t\t});\n\t}\n\treturn entries;\n}\nasync function importAgentDefinition(filePath, options) {\n\tconst appRoot = resolveAppRoot(filePath);\n\tconst href = pathToFileURL(filePath).href;\n\treturn runWithAppRoot(appRoot, async () => {\n\t\treturn validateManifestAgent((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);\n\t});\n}\n//#endregion\n//#region src/guards/action.ts\nconst ACTION = Symbol.for(\"keystroke.action\");\nfunction isManifestAction(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\treturn ACTION in value && value[ACTION] === true;\n}\nfunction getManifestActionCredentialRequirements(action) {\n\treturn Array.isArray(action.credentials) ? action.credentials : void 0;\n}\n//#endregion\n//#region src/agents/count-agent-credentials.ts\nfunction actionSlug(tool) {\n\tconst record = tool;\n\treturn typeof record.slug === \"string\" ? record.slug : void 0;\n}\n/** App-kind slugs required by the agent's tools (same as `credential_instances.app_slug`). */\nfunction collectAgentAppSlugs(agent) {\n\tconst slugs = /* @__PURE__ */ new Set();\n\tfor (const tool of agent.tools ?? []) {\n\t\tconst record = tool;\n\t\tconst requirements = isManifestAction(tool) ? getManifestActionCredentialRequirements(tool) : \"credentials\" in record && Array.isArray(record.credentials) ? record.credentials : void 0;\n\t\tif (!requirements?.length) continue;\n\t\tfor (const requirement of normalizeCredentialList(requirements)) slugs.add(requirement.key);\n\t}\n\treturn [...slugs].sort();\n}\nfunction collectAgentToolSlugs(agent) {\n\tconst slugs = [];\n\tfor (const tool of agent.tools ?? []) {\n\t\tconst slug = actionSlug(tool);\n\t\tif (slug) slugs.push(slug);\n\t}\n\treturn slugs;\n}\nfunction countAgentCredentials(agent) {\n\treturn collectAgentAppSlugs(agent).length;\n}\n//#endregion\n//#region src/agents/agent-manifest-entry.ts\n/** Single source of truth for the `kind: \"agent\"` route-manifest entry shape. */\nfunction agentManifestEntry(agent, options) {\n\treturn {\n\t\tkind: \"agent\",\n\t\tslug: agent.slug,\n\t\tmoduleFile: options.moduleFile,\n\t\tname: agent.name,\n\t\tdescription: agent.description,\n\t\tmodel: agent.model,\n\t\tsystemPrompt: agent.systemPrompt,\n\t\ttoolCount: agent.tools?.length ?? 0,\n\t\tcredentialCount: countAgentCredentials(agent),\n\t\tappSlugs: collectAgentAppSlugs(agent),\n\t\ttoolSlugs: collectAgentToolSlugs(agent)\n\t};\n}\n//#endregion\n//#region src/skills/discover-manifest-entries.ts\nconst SKIP_DIRS = new Set([\".git\", \"node_modules\"]);\nfunction toPosix$1(path) {\n\treturn path.split(sep).join(\"/\");\n}\nfunction parseSkillFrontmatter(raw) {\n\tconst match = raw.match(/^---\\s*\\n([\\s\\S]*?)\\n---/);\n\tif (!match) return {};\n\tconst out = {};\n\tfor (const line of match[1]?.split(\"\\n\") ?? []) {\n\t\tconst trimmed = line.trim();\n\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\t\tconst colon = trimmed.indexOf(\":\");\n\t\tif (colon < 0) continue;\n\t\tconst key = trimmed.slice(0, colon).trim();\n\t\tlet value = trimmed.slice(colon + 1).trim();\n\t\tif (value.startsWith(\"\\\"\") && value.endsWith(\"\\\"\") || value.startsWith(\"'\") && value.endsWith(\"'\")) value = value.slice(1, -1);\n\t\tif (key === \"name\") out.name = value;\n\t\telse if (key === \"description\") out.description = value;\n\t}\n\treturn out;\n}\nfunction walkSkillFiles(root, dir, out) {\n\tfor (const name of readdirSync(dir).sort()) {\n\t\tconst absolute = join(dir, name);\n\t\tconst stats = statSync(absolute);\n\t\tif (stats.isDirectory()) {\n\t\t\tif (SKIP_DIRS.has(name)) continue;\n\t\t\twalkSkillFiles(root, absolute, out);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!stats.isFile() || name !== \"SKILL.md\") continue;\n\t\tconst moduleFile = toPosix$1(relative(root, absolute));\n\t\tconst slug = toPosix$1(relative(join(root, \"src\", \"skills\"), absolute)).replace(/\\/?SKILL\\.md$/, \"\");\n\t\tif (!slug) continue;\n\t\tconst frontmatter = parseSkillFrontmatter(readFileSync(absolute, \"utf8\"));\n\t\tout.push({\n\t\t\tslug,\n\t\t\tname: frontmatter.name,\n\t\t\tdescription: frontmatter.description,\n\t\t\tmoduleFile\n\t\t});\n\t}\n}\n/** Discover skill metadata from src/skills SKILL.md files for the route manifest. */\nfunction discoverSkillManifestEntries(projectRoot) {\n\tconst skillsDir = join(projectRoot, \"src\", \"skills\");\n\tif (!statSync(skillsDir, { throwIfNoEntry: false })?.isDirectory()) return [];\n\tconst entries = [];\n\twalkSkillFiles(projectRoot, skillsDir, entries);\n\treturn entries;\n}\n//#endregion\n//#region src/openapi/schema-to-json.ts\nfunction schemaToJson(schema) {\n\treturn z.toJSONSchema(schema, { target: \"openapi-3.0\" });\n}\n//#endregion\n//#region src/openapi/serialize-manifest.ts\nfunction collectIntegrationKeys(integrations) {\n\treturn integrations.map((integration) => integration.key);\n}\nfunction serializeRouteManifest(manifest) {\n\tconst entries = [];\n\tfor (const entry of manifest) switch (entry.kind) {\n\t\tcase \"health\":\n\t\t\tentries.push(entry);\n\t\t\tbreak;\n\t\tcase \"agent\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tslug: entry.slug,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tname: entry.name,\n\t\t\t\tdescription: entry.description,\n\t\t\t\tmodel: entry.model,\n\t\t\t\tsystemPrompt: entry.systemPrompt,\n\t\t\t\ttoolCount: entry.toolCount,\n\t\t\t\tcredentialCount: entry.credentialCount,\n\t\t\t\tappSlugs: entry.appSlugs,\n\t\t\t\ttoolSlugs: entry.toolSlugs\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"workflow\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tslug: entry.slug,\n\t\t\t\tname: entry.name,\n\t\t\t\tdescription: entry.description,\n\t\t\t\tsubscribable: entry.subscribable,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\trequestSchema: schemaToJson(entry.request)\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"trigger-webhook\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tendpoint: entry.endpoint,\n\t\t\t\tattachmentIds: entry.attachmentIds,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tattachmentSchemas: Object.fromEntries(Object.entries(entry.attachmentSchemas).map(([attachmentKey, schemas]) => [attachmentKey, {\n\t\t\t\t\trequestSchema: schemaToJson(schemas.request),\n\t\t\t\t\t...schemas.filter ? { filterSchema: schemaToJson(schemas.filter) } : {}\n\t\t\t\t}]))\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"trigger-poll\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tattachmentId: entry.attachmentId,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tschedule: entry.schedule\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"trigger-poll-group\":\n\t\t\tentries.push({\n\t\t\t\tkind: entry.kind,\n\t\t\t\tpollId: entry.pollId,\n\t\t\t\tattachmentIds: entry.attachmentIds,\n\t\t\t\tmoduleFile: entry.moduleFile,\n\t\t\t\tschedule: entry.schedule\n\t\t\t});\n\t\t\tbreak;\n\t\tcase \"cron-schedule\":\n\t\t\tentries.push(entry);\n\t\t\tbreak;\n\t\tdefault: break;\n\t}\n\treturn entries;\n}\nfunction toStoredRouteManifest(manifest, options) {\n\treturn {\n\t\tversion: 2,\n\t\tentries: serializeRouteManifest(manifest),\n\t\tskills: options?.skills ?? [],\n\t\tintegrations: options?.integrations\n\t};\n}\nfunction buildStoredRouteManifestFromContext(ctx) {\n\tconst integrations = ctx.options?.integrations ?? ctx.options?.plugins?.map((plugin) => ({\n\t\tkey: plugin.name,\n\t\tmount: plugin.register\n\t})) ?? [];\n\treturn toStoredRouteManifest(ctx.manifest, {\n\t\tintegrations: collectIntegrationKeys(integrations),\n\t\tskills: ctx.skills ?? (ctx.projectRoot ? discoverSkillManifestEntries(ctx.projectRoot) : void 0) ?? []\n\t});\n}\nfunction findWorkflowManifestEntry(manifest, workflowSlug) {\n\treturn manifest.entries.find((entry) => entry.kind === \"workflow\" && entry.slug === workflowSlug);\n}\nfunction findWebhookManifestEntryByEndpoint(manifest, endpoint) {\n\treturn manifest.entries.find((entry) => entry.kind === \"trigger-webhook\" && entry.endpoint === endpoint);\n}\n/** @deprecated Use {@link findWebhookManifestEntryByEndpoint}. */\nfunction findWebhookManifestEntryByPath(manifest, route) {\n\treturn findWebhookManifestEntryByEndpoint(manifest, route.replace(/^\\/triggers\\//, \"\").replace(/^\\/+|\\/+$/g, \"\"));\n}\n//#endregion\n//#region src/persist.ts\nfunction persistStoredRouteManifest(projectRoot, manifest) {\n\tconst path = join(projectRoot, ROUTE_MANIFEST_REL_PATH);\n\tmkdirSync(dirname(path), { recursive: true });\n\twriteFileSync(path, `${JSON.stringify(manifest, null, 2)}\\n`);\n}\n//#endregion\n//#region src/guards/workflow.ts\nconst WORKFLOW = Symbol.for(\"keystroke.workflow\");\nfunction isManifestWorkflow(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(WORKFLOW in value) || value[WORKFLOW] !== true) return false;\n\tconst workflow = value;\n\treturn typeof workflow.slug === \"string\" && workflow.slug.trim().length > 0 && workflow.input instanceof Object && \"safeParse\" in workflow.input && workflow.output instanceof Object && \"safeParse\" in workflow.output;\n}\nfunction validateManifestWorkflow(value, filePath) {\n\tif (!isManifestWorkflow(value)) throw new Error(`${filePath} must default-export defineWorkflow(...)`);\n\treturn value;\n}\n//#endregion\n//#region src/guards/trigger.ts\nconst TRIGGER_ATTACHMENT = Symbol.for(\"keystroke.triggerAttachment\");\nconst zodSchema = z.custom((value) => value instanceof z.ZodType, \"must be a Zod schema\");\nconst cronScheduleSchema = z.string().trim().min(1, \"cron schedule must be a non-empty string\");\nconst workflowSchema = z.custom((value) => isManifestWorkflow(value), \"must be defineWorkflow(...)\");\nconst agentSchema = z.custom((value) => typeof value === \"object\" && value !== null && typeof value.slug === \"string\" && value.slug.trim().length > 0 && typeof value.prompt === \"function\", \"must be defineAgent(...)\");\nconst promptSchema = z.union([z.string(), z.function()]);\nconst baseSourceShape = {\n\tkey: z.string().trim().min(1),\n\tattach: z.function()\n};\nconst webhookSourceSchema = z.object({\n\tkind: z.literal(\"webhook\"),\n\t...baseSourceShape,\n\tendpoint: z.string().min(1),\n\trequest: zodSchema,\n\tfilter: zodSchema.optional(),\n\tpasses: z.function()\n});\nconst cronSourceSchema = z.object({\n\tkind: z.literal(\"cron\"),\n\t...baseSourceShape,\n\tschedule: cronScheduleSchema\n});\nconst pollSourceSchema = z.object({\n\tkind: z.literal(\"poll\"),\n\t...baseSourceShape,\n\tid: z.string().optional(),\n\tschedule: cronScheduleSchema,\n\trun: z.function(),\n\tfilters: z.array(z.function()),\n\tpasses: z.function()\n});\nconst triggerSourceSchema = z.discriminatedUnion(\"kind\", [\n\twebhookSourceSchema,\n\tcronSourceSchema,\n\tpollSourceSchema\n]);\nconst workflowAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"workflow\"),\n\tworkflow: workflowSchema,\n\ttransform: z.function().optional()\n});\nconst agentAttachmentSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tsource: triggerSourceSchema,\n\ttarget: z.literal(\"agent\"),\n\tagent: agentSchema,\n\tprompt: promptSchema\n});\nconst triggerAttachmentCoreSchema = z.discriminatedUnion(\"target\", [workflowAttachmentSchema, agentAttachmentSchema]);\nfunction isManifestTriggerAttachment(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(TRIGGER_ATTACHMENT in value) || value[TRIGGER_ATTACHMENT] !== true) return false;\n\treturn triggerAttachmentCoreSchema.safeParse(value).success;\n}\nfunction validateManifestTriggerAttachment(value, filePath) {\n\tif (!isManifestTriggerAttachment(value)) throw new Error(`${filePath} must default-export a trigger attachment from .attach({ workflow }) or .attach({ agent, prompt })`);\n\treturn value;\n}\n//#endregion\n//#region src/triggers/discover.ts\nfunction shouldDiscoverTriggerFile(triggersDir, filePath) {\n\treturn !relative(triggersDir, filePath).split(sep).includes(\"sources\");\n}\nasync function discoverTriggerAttachments(triggersDir, options) {\n\tconst files = await discoverModuleFileEntries(triggersDir, {\n\t\tnestedEntry: \"trigger\",\n\t\tduplicateLabel: \"trigger module file\",\n\t\tshouldDiscoverFile: (filePath) => shouldDiscoverTriggerFile(triggersDir, filePath)\n\t});\n\tconst attachments = [];\n\tfor (const { filePath, moduleFile } of files) {\n\t\tconst attachment = await importTriggerAttachment(filePath, options);\n\t\tattachments.push({\n\t\t\tkey: attachment.key,\n\t\t\tfilePath,\n\t\t\tmoduleFile,\n\t\t\tattachment\n\t\t});\n\t}\n\treturn attachments;\n}\nfunction validateImportedTriggerAttachment(def, filePath) {\n\treturn validateManifestTriggerAttachment(def, filePath);\n}\nasync function importTriggerAttachment(filePath, options) {\n\tconst href = pathToFileURL(filePath).href;\n\treturn validateImportedTriggerAttachment((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);\n}\n//#endregion\n//#region src/triggers/poll/groups.ts\nfunction pollGroupId(discovered) {\n\tconst source = discovered.attachment.source;\n\tif (source.kind !== \"poll\") throw new Error(`Attachment \"${discovered.key}\" is not a poll trigger`);\n\treturn source.id ?? source.key;\n}\nfunction buildPollGroups(attachments) {\n\tconst byId = /* @__PURE__ */ new Map();\n\tfor (const discovered of attachments) {\n\t\tif (discovered.attachment.source.kind !== \"poll\") continue;\n\t\tconst id = pollGroupId(discovered);\n\t\tconst group = byId.get(id) ?? [];\n\t\tgroup.push(discovered);\n\t\tbyId.set(id, group);\n\t}\n\treturn [...byId.entries()].map(([id, groupAttachments]) => ({\n\t\tid,\n\t\tattachments: groupAttachments\n\t}));\n}\nfunction validatePollGroups(groups) {\n\tfor (const group of groups) {\n\t\tif (group.attachments.length <= 1) continue;\n\t\tif (new Set(group.attachments.map((discovered) => {\n\t\t\tconst source = discovered.attachment.source;\n\t\t\tif (source.kind !== \"poll\") throw new Error(`Poll group \"${group.id}\" has non-poll attachment ${discovered.key}`);\n\t\t\treturn source.schedule;\n\t\t})).size > 1) {\n\t\t\tconst keys = group.attachments.map((discovered) => discovered.key).join(\", \");\n\t\t\tthrow new Error(`Poll group \"${group.id}\" has attachments with different schedules (${keys})`);\n\t\t}\n\t}\n}\nfunction matchesPollRunTarget(attachmentKey, workflowKey, target) {\n\tif (!target?.workflows?.length && !target?.attachments?.length) return true;\n\tif (target.attachments?.length && !target.attachments.includes(attachmentKey)) return false;\n\tif (target.workflows?.length && !target.workflows.includes(workflowKey)) return false;\n\treturn true;\n}\n//#endregion\n//#region src/triggers/webhook/build-webhook-bindings.ts\nfunction buildWebhookBindingsByRoute(attachments, handlerOptionsFor) {\n\tconst webhookBindingsByRoute = /* @__PURE__ */ new Map();\n\tfor (const discovered of attachments) {\n\t\tconst source = discovered.attachment.source;\n\t\tif (source.kind !== \"webhook\") continue;\n\t\tconst route = webhookRouteFromEndpoint(source.endpoint);\n\t\tconst bindings = webhookBindingsByRoute.get(route) ?? [];\n\t\tbindings.push({\n\t\t\tdiscovered,\n\t\t\toptions: handlerOptionsFor(discovered.key)\n\t\t});\n\t\twebhookBindingsByRoute.set(route, bindings);\n\t}\n\treturn webhookBindingsByRoute;\n}\n//#endregion\n//#region src/triggers/webhook/webhook-schemas.ts\nfunction webhookSchemaEntriesFromBindings(bindings) {\n\treturn bindings.flatMap((binding) => {\n\t\tconst source = binding.discovered.attachment.source;\n\t\tif (source.kind !== \"webhook\") return [];\n\t\treturn [{\n\t\t\tattachmentKey: binding.discovered.key,\n\t\t\trequest: source.request,\n\t\t\t...source.filter ? { filter: source.filter } : {}\n\t\t}];\n\t});\n}\nfunction webhookAttachmentSchemasFromBindings(bindings) {\n\treturn webhookSchemaEntriesFromBindings(bindings).map((entry) => ({\n\t\tattachmentKey: entry.attachmentKey,\n\t\trequestSchema: schemaToJson(entry.request),\n\t\t...entry.filter ? { filterSchema: schemaToJson(entry.filter) } : {}\n\t}));\n}\nfunction webhookMatchSchemaForBindings(bindings) {\n\tconst schemas = bindings.flatMap((binding) => {\n\t\tconst source = binding.discovered.attachment.source;\n\t\treturn source.kind === \"webhook\" ? [source.request] : [];\n\t});\n\tif (schemas.length === 0) throw new Error(\"Webhook bindings require at least one webhook source\");\n\tif (schemas.length === 1) return schemas[0];\n\treturn z.union(schemas);\n}\nfunction webhookManifestAttachmentSchemasFromBindings(bindings) {\n\treturn Object.fromEntries(webhookSchemaEntriesFromBindings(bindings).map((entry) => [entry.attachmentKey, {\n\t\trequest: entry.request,\n\t\t...entry.filter ? { filter: entry.filter } : {}\n\t}]));\n}\n//#endregion\n//#region src/workflows/discover.ts\nasync function discoverWorkflowEntries(workflowsDir, options) {\n\tconst files = await discoverModuleFileEntries(workflowsDir, {\n\t\tnestedEntry: \"workflow\",\n\t\tduplicateLabel: \"workflow module file\"\n\t});\n\tconst entries = [];\n\tfor (const { filePath, moduleFile } of files) {\n\t\tconst definition = await importWorkflowDefinition(filePath, options);\n\t\tentries.push({\n\t\t\tkey: definition.slug,\n\t\t\troute: workflowRouteFromKey(definition.slug),\n\t\t\tfilePath,\n\t\t\tmoduleFile\n\t\t});\n\t}\n\treturn entries;\n}\nfunction validateImportedWorkflowDefinition(def, filePath) {\n\treturn validateManifestWorkflow(def, filePath);\n}\nasync function importWorkflowDefinition(filePath, options) {\n\tconst href = pathToFileURL(filePath).href;\n\treturn validateImportedWorkflowDefinition((await (options?.reload ? import(`${href}?keystroke=${Date.now()}`) : import(href))).default, filePath);\n}\nasync function discoverWorkflows(workflowsDir, options) {\n\tconst entries = await discoverWorkflowEntries(workflowsDir, options);\n\tconst workflows = [];\n\tfor (const entry of entries) {\n\t\tconst definition = await importWorkflowDefinition(entry.filePath, options);\n\t\tworkflows.push({\n\t\t\tkey: definition.slug,\n\t\t\troute: workflowRouteFromKey(definition.slug),\n\t\t\tfilePath: entry.filePath,\n\t\t\tdefinition\n\t\t});\n\t}\n\treturn workflows;\n}\n//#endregion\n//#region src/build-stored-manifest.ts\nfunction resolveDistModuleDirs(projectRoot) {\n\tconst distBase = join(projectRoot, \"dist\");\n\tif (!existsSync(distBase)) throw new Error(`Build output missing at ${distBase}. Run keystroke build before emitting the route manifest.`);\n\treturn {\n\t\tagentsDir: join(distBase, \"agents\"),\n\t\tworkflowsDir: join(distBase, \"workflows\"),\n\t\ttriggersDir: join(distBase, \"triggers\")\n\t};\n}\nfunction toPosix(path) {\n\treturn path.split(sep).join(\"/\");\n}\n/**\n* Resolve manifest moduleFile values to project-root-relative source paths.\n*\n* Discovery runs over compiled `dist/` modules, so the raw moduleFile is a\n* dist-relative `.mjs` path. Dist entries are named by their source entry id\n* (`team/escalation.mjs` ← `src/agents/team/escalation/agent.ts`), so walking\n* the matching source dir by the same id rules recovers the source path. Falls\n* back to the dist-relative value when no source file matches (e.g. building\n* a dist-only artifact with no `src/`).\n*/\nvar SourceModuleFileResolver = class {\n\tprojectRoot;\n\tmapsByKind = /* @__PURE__ */ new Map();\n\tconstructor(projectRoot) {\n\t\tthis.projectRoot = projectRoot;\n\t}\n\tasync sourceMapFor(kindDir, nestedEntry) {\n\t\tconst existing = this.mapsByKind.get(kindDir);\n\t\tif (existing) return existing;\n\t\tconst map = /* @__PURE__ */ new Map();\n\t\tconst sourceDir = join(this.projectRoot, \"src\", kindDir);\n\t\tfor (const filePath of await walkTypeScriptFiles(sourceDir)) {\n\t\t\tconst id = entryIdFromFile(sourceDir, filePath, { nestedEntry });\n\t\t\tif (id) map.set(id, toPosix(relative(this.projectRoot, filePath)));\n\t\t}\n\t\tthis.mapsByKind.set(kindDir, map);\n\t\treturn map;\n\t}\n\tasync resolve(kindDir, nestedEntry, distDir, distFilePath) {\n\t\tconst fallback = toPosix(relative(distDir, distFilePath));\n\t\tconst id = entryIdFromFile(distDir, distFilePath, { nestedEntry });\n\t\tif (!id) return fallback;\n\t\treturn (await this.sourceMapFor(kindDir, nestedEntry)).get(id) ?? fallback;\n\t}\n};\n/** Build a stored route manifest from compiled dist/ modules without starting a server. */\nasync function buildStoredRouteManifestForProject(projectRoot, options) {\n\tconst previousRoot = process.env.KEYSTROKE_ROOT;\n\tprocess.env.KEYSTROKE_ROOT = projectRoot;\n\tconst reload = options?.reloadModules ? { reload: true } : void 0;\n\ttry {\n\t\tconst dirs = resolveDistModuleDirs(projectRoot);\n\t\tconst sourcePaths = new SourceModuleFileResolver(projectRoot);\n\t\tconst manifest = [{ kind: \"health\" }];\n\t\tconst agentEntries = await discoverAgentEntries(dirs.agentsDir, reload);\n\t\tfor (const entry of agentEntries) {\n\t\t\tconst agent = await importAgentDefinition(entry.filePath, reload);\n\t\t\tconst moduleFile = await sourcePaths.resolve(\"agents\", \"agent\", dirs.agentsDir, entry.filePath);\n\t\t\tmanifest.push(agentManifestEntry(agent, { moduleFile }));\n\t\t}\n\t\tconst workflows = await discoverWorkflows(dirs.workflowsDir, reload);\n\t\tfor (const workflow of workflows) {\n\t\t\tconst moduleFile = await sourcePaths.resolve(\"workflows\", \"workflow\", dirs.workflowsDir, workflow.filePath);\n\t\t\tmanifest.push({\n\t\t\t\tkind: \"workflow\",\n\t\t\t\tslug: workflow.definition.slug,\n\t\t\t\tname: workflow.definition.name,\n\t\t\t\tdescription: workflow.definition.description,\n\t\t\t\tsubscribable: workflow.definition.subscription?.mode === \"subscribable\",\n\t\t\t\tmoduleFile,\n\t\t\t\trequest: workflow.definition.input\n\t\t\t});\n\t\t}\n\t\tconst attachments = await discoverTriggerAttachments(dirs.triggersDir, reload);\n\t\tconst discoveredByKey = new Map(attachments.map((attachment) => [attachment.key, attachment]));\n\t\tconst pollGroups = buildPollGroups(attachments);\n\t\tfor (const discovered of discoveredByKey.values()) {\n\t\t\tconst source = discovered.attachment.source;\n\t\t\tconst moduleFile = await sourcePaths.resolve(\"triggers\", \"trigger\", dirs.triggersDir, discovered.filePath);\n\t\t\tif (source.kind === \"cron\") {\n\t\t\t\tmanifest.push({\n\t\t\t\t\tkind: \"cron-schedule\",\n\t\t\t\t\tattachmentId: discovered.key,\n\t\t\t\t\tmoduleFile,\n\t\t\t\t\tschedule: source.schedule\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (source.kind === \"poll\") {\n\t\t\t\tmanifest.push({\n\t\t\t\t\tkind: \"trigger-poll\",\n\t\t\t\t\tattachmentId: discovered.key,\n\t\t\t\t\tmoduleFile,\n\t\t\t\t\tschedule: source.schedule,\n\t\t\t\t\tresponse: PromptResponseSchema\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (source.kind === \"webhook\") {\n\t\t\t\tconst route = webhookRouteFromEndpoint(source.endpoint);\n\t\t\t\tconst bindings = buildWebhookBindingsByRoute(discoveredByKey.values(), () => ({\n\t\t\t\t\texecution: { attachmentKey: discovered.key },\n\t\t\t\t\tattachmentKey: discovered.key\n\t\t\t\t})).get(route) ?? [{\n\t\t\t\t\tdiscovered,\n\t\t\t\t\toptions: { attachmentKey: discovered.key }\n\t\t\t\t}];\n\t\t\t\tmanifest.push({\n\t\t\t\t\tkind: \"trigger-webhook\",\n\t\t\t\t\tendpoint: source.endpoint,\n\t\t\t\t\tattachmentIds: bindings.map(({ discovered: row }) => row.key),\n\t\t\t\t\tmoduleFile,\n\t\t\t\t\trequest: webhookMatchSchemaForBindings(bindings),\n\t\t\t\t\tattachmentSchemas: webhookManifestAttachmentSchemasFromBindings(bindings),\n\t\t\t\t\tresponse: PromptResponseSchema\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tfor (const group of pollGroups) {\n\t\t\tif (group.attachments.length <= 1) continue;\n\t\t\tconst first = group.attachments[0];\n\t\t\tconst source = first.attachment.source;\n\t\t\tmanifest.push({\n\t\t\t\tkind: \"trigger-poll-group\",\n\t\t\t\tpollId: group.id,\n\t\t\t\tattachmentIds: group.attachments.map((attachment) => attachment.key),\n\t\t\t\tmoduleFile: await sourcePaths.resolve(\"triggers\", \"trigger\", dirs.triggersDir, first.filePath),\n\t\t\t\tschedule: source.kind === \"poll\" ? source.schedule : \"\",\n\t\t\t\tresponse: PromptResponseSchema\n\t\t\t});\n\t\t}\n\t\treturn buildStoredRouteManifestFromContext({\n\t\t\tmanifest,\n\t\t\toptions: {},\n\t\t\tprojectRoot,\n\t\t\tskills: discoverSkillManifestEntries(projectRoot)\n\t\t});\n\t} finally {\n\t\tif (previousRoot === void 0) delete process.env.KEYSTROKE_ROOT;\n\t\telse process.env.KEYSTROKE_ROOT = previousRoot;\n\t}\n}\n/** Write `dist/.keystroke/route-manifest.json` for the project. */\nasync function emitStoredRouteManifestForProject(projectRoot) {\n\tpersistStoredRouteManifest(projectRoot, await buildStoredRouteManifestForProject(projectRoot));\n}\n//#endregion\n//#region src/openapi/manifest.ts\nfunction schedulesFromManifest(manifest) {\n\tconst schedules = [];\n\tfor (const entry of manifest) {\n\t\tif (entry.kind === \"cron-schedule\") {\n\t\t\tschedules.push({\n\t\t\t\tattachmentId: entry.attachmentId,\n\t\t\t\ttype: \"cron\",\n\t\t\t\tschedule: entry.schedule\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.kind === \"trigger-poll\") schedules.push({\n\t\t\tattachmentId: entry.attachmentId,\n\t\t\ttype: \"poll\",\n\t\t\tschedule: entry.schedule\n\t\t});\n\t}\n\treturn schedules;\n}\n//#endregion\n//#region src/load-route-manifest.ts\nfunction routeManifestPathForProjectRoot(projectRoot) {\n\treturn join(projectRoot, ROUTE_MANIFEST_REL_PATH);\n}\nfunction readRouteManifest(projectRoot) {\n\tconst path = routeManifestPathForProjectRoot(projectRoot);\n\tif (!existsSync(path)) throw new Error(`${ROUTE_MANIFEST_REL_PATH} not found — start the project server once to emit the manifest`);\n\tconst raw = readFileSync(path, \"utf8\");\n\treturn parseStoredRouteManifest(JSON.parse(raw));\n}\n//#endregion\nexport { agentManifestEntry, agentRouteFromKey, buildPollGroups, buildStoredRouteManifestForProject, buildStoredRouteManifestFromContext, buildWebhookBindingsByRoute, collectAgentAppSlugs, collectAgentToolSlugs, countAgentCredentials, discoverAgentEntries, discoverEntries, discoverModuleFileEntries, discoverSkillManifestEntries, discoverTriggerAttachments, discoverWorkflowEntries, discoverWorkflows, emitStoredRouteManifestForProject, entryIdFromFile, findWebhookManifestEntryByEndpoint, findWebhookManifestEntryByPath, findWorkflowManifestEntry, importAgentDefinition, importTriggerAttachment, importWorkflowDefinition, matchesPollRunTarget, moduleFileKeyFromPath, persistStoredRouteManifest, pollGroupId, pollGroupRouteFromId, pollRouteFromKey, readRouteManifest, routeManifestPathForProjectRoot, schedulesFromManifest, schemaToJson, serializeRouteManifest, toStoredRouteManifest, validateImportedTriggerAttachment, validateImportedWorkflowDefinition, validatePollGroups, validateUniqueModuleKeys, walkTypeScriptFiles, webhookAttachmentSchemasFromBindings, webhookManifestAttachmentSchemasFromBindings, webhookMatchSchemaForBindings, webhookRouteFromEndpoint, workflowRouteFromKey };\n\n//# sourceMappingURL=index.mjs.map"],"x_google_ignoreList":[0,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,25],"mappings":"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"}
|