just-bash-nx 3.0.6 → 3.0.8

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.
@@ -1,9 +1,9 @@
1
1
  "use strict";var xT=Object.create;var gc=Object.defineProperty;var ST=Object.getOwnPropertyDescriptor;var AT=Object.getOwnPropertyNames;var vT=Object.getPrototypeOf,CT=Object.prototype.hasOwnProperty;var I=(t,e)=>()=>(t&&(e=t(t=0)),e);var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ee=(t,e)=>{for(var n in e)gc(t,n,{get:e[n],enumerable:!0})},nb=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of AT(e))!CT.call(t,s)&&s!==n&&gc(t,s,{get:()=>e[s],enumerable:!(r=ST(e,s))||r.enumerable});return t};var Jt=(t,e,n)=>(n=t!=null?xT(vT(t)):{},nb(e||!t||!t.__esModule?gc(n,"default",{value:t,enumerable:!0}):n,t)),rb=t=>nb(gc({},"__esModule",{value:!0}),t);function ud(){let t=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables",allowedKeys:new Set(["NODE_V8_COVERAGE","NODE_DEBUG","NODE_DEBUG_NATIVE","NODE_COMPILE_CACHE","WATCH_REPORT_DEPENDENCIES","FORCE_COLOR","DEBUG","UNDICI_NO_FG","JEST_WORKER_ID","__MINIMATCH_TESTING_PLATFORM__","LOG_TOKENS","LOG_STREAM"])},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"getBuiltinModule",target:process,violationType:"process_get_builtin_module",strategy:"throw",reason:"process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)"},{prop:"exit",target:process,violationType:"process_exit",strategy:"throw",reason:"process.exit could terminate the interpreter"},{prop:"abort",target:process,violationType:"process_exit",strategy:"throw",reason:"process.abort could crash the interpreter"},{prop:"kill",target:process,violationType:"process_kill",strategy:"throw",reason:"process.kill could signal other processes"},{prop:"setuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setuid could escalate privileges"},{prop:"setgid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgid could escalate privileges"},{prop:"seteuid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.seteuid could escalate effective user privileges"},{prop:"setegid",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setegid could escalate effective group privileges"},{prop:"initgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.initgroups could modify supplementary group IDs"},{prop:"setgroups",target:process,violationType:"process_setuid",strategy:"throw",reason:"process.setgroups could modify supplementary group IDs"},{prop:"umask",target:process,violationType:"process_umask",strategy:"throw",reason:"process.umask could modify file creation permissions"},{prop:"argv",target:process,violationType:"process_argv",strategy:"throw",reason:"process.argv may contain secrets in CLI arguments"},{prop:"cwd",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.cwd could disclose real host working directory path"},{prop:"chdir",target:process,violationType:"process_chdir",strategy:"throw",reason:"process.chdir could confuse the interpreter's CWD tracking"},{prop:"report",target:process,violationType:"process_report",strategy:"throw",reason:"process.report could disclose full environment, host paths, and system info"},{prop:"loadEnvFile",target:process,violationType:"process_env",strategy:"throw",reason:"process.loadEnvFile could load env files bypassing env proxy"},{prop:"setUncaughtExceptionCaptureCallback",target:process,violationType:"process_exception_handler",strategy:"throw",reason:"setUncaughtExceptionCaptureCallback could intercept security errors"},{prop:"send",target:process,violationType:"process_send",strategy:"throw",reason:"process.send could communicate with parent process in IPC contexts"},{prop:"channel",target:process,violationType:"process_channel",strategy:"throw",reason:"process.channel could access IPC channel to parent process"},{prop:"cpuUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.cpuUsage could enable timing side-channel attacks"},{prop:"memoryUsage",target:process,violationType:"process_timing",strategy:"throw",reason:"process.memoryUsage could enable timing side-channel attacks"},{prop:"hrtime",target:process,violationType:"process_timing",strategy:"throw",reason:"process.hrtime could enable timing side-channel attacks"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"},{prop:"performance",target:globalThis,violationType:"performance_timing",strategy:"throw",reason:"performance.now() provides sub-millisecond timing for side-channel attacks"},{prop:"stdout",target:process,violationType:"process_stdout",strategy:"throw",reason:"process.stdout could bypass interpreter output to write to host stdout"},{prop:"stderr",target:process,violationType:"process_stderr",strategy:"throw",reason:"process.stderr could bypass interpreter output to write to host stderr"},{prop:"__defineGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineGetter__ allows prototype pollution via getter injection"},{prop:"__defineSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__defineSetter__ allows prototype pollution via setter injection"},{prop:"__lookupGetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupGetter__ enables introspection for prototype pollution attacks"},{prop:"__lookupSetter__",target:Object.prototype,violationType:"prototype_mutation",strategy:"throw",reason:"__lookupSetter__ enables introspection for prototype pollution attacks"},{prop:"JSON",target:globalThis,violationType:"json_mutation",strategy:"freeze",reason:"Freeze JSON to prevent mutation of parsing/serialization"},{prop:"Math",target:globalThis,violationType:"math_mutation",strategy:"freeze",reason:"Freeze Math to prevent mutation of math utilities"}];try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&t.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&t.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let e=Object.getPrototypeOf(async function*(){}).constructor;e&&e!==Function&&e!==Object.getPrototypeOf(async()=>{}).constructor&&t.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return t.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var fd=I(()=>{"use strict"});function sb(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function TT(t,e,...n){return dt.run(t,()=>e(...n))}function OT(t){return t===void 0?{...hd,enabled:!1}:typeof t=="boolean"?{...hd,enabled:t}:{...hd,...t}}var Hs,dd,kT,Se,dt,NT,hd,tt,en=I(()=>{"use strict";fd();Hs=typeof __BROWSER__<"u"&&__BROWSER__;dd=null;if(!Hs)try{let{AsyncLocalStorage:t}=require("node:async_hooks");dd=t}catch{}kT=`
2
2
 
3
3
  This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,Se=class extends Error{violation;constructor(e,n){super(e+kT),this.violation=n,this.name="SecurityViolationError"}},dt=!Hs&&dd?new dd:null,NT=1e3;hd={enabled:!0,auditMode:!1};tt=class t{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let n=OT(e);if(!t.instance)t.instance=new t(n);else{let r=t.instance.config;if(n.enabled!==r.enabled||n.auditMode!==r.auditMode)throw new Error(`DefenseInDepthBox config conflict: requested {enabled: ${n.enabled}, auditMode: ${n.auditMode}} but singleton already has {enabled: ${r.enabled}, auditMode: ${r.auditMode}}. All Bash instances must use the same defense-in-depth security settings, or call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return t.instance}static resetInstance(){t.instance&&(t.instance.forceDeactivate(),t.instance=null),t.trustedExecutionDepth.clear()}static isInSandboxedContext(){return dt?dt?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(dt)return dt?.getStore()?.executionId}static enterTrustedScope(e){let n=t.trustedExecutionDepth.get(e)??0;t.trustedExecutionDepth.set(e,n+1)}static leaveTrustedScope(e){let n=t.trustedExecutionDepth.get(e);if(n){if(n===1){t.trustedExecutionDepth.delete(e);return}t.trustedExecutionDepth.set(e,n-1)}}static isTrustedScopeActive(e){return e?(t.trustedExecutionDepth.get(e)??0)>0:!1}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let n=this.contextCache.get(e);return n||(n={sandboxActive:!0,executionId:e},this.contextCache.set(e,n)),n}getPreferredActiveExecutionId(){if(this.activeExecutionIds.size!==0)for(let e of this.activeExecutionIds)return e}static bindCurrentContext(e){if(!dt)return e;let n=t.instance,r=dt.getStore(),s=r?.sandboxActive===!0?r.executionId:n?.getPreferredActiveExecutionId();if(!s)return e;let i=n?.getCachedContext(s)??{sandboxActive:!0,executionId:s};return((...o)=>{let a=t.instance;if(!(a&&!a.isExecutionIdActive(s)&&(a.recordViolation("bound_callback_after_deactivate","bound callback","Bound callback blocked after originating execution was deactivated"),!a.config.auditMode)))return TT(i,e,...o)})}isEnabled(){return this.config.enabled===!0&&dt!==null&&!Hs}updateConfig(e){this.config={...this.config,...e}}activate(){if(Hs||!this.config.enabled||!dt){let r=sb(),s=!1;return{run:i=>s?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):i(),deactivate:()=>{s=!0},executionId:r}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let e=sb(),n=!1;return{run:r=>n?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(e),dt.run({sandboxActive:!0,executionId:e},r)),deactivate:()=>{n||(n=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,n){return e===globalThis?`globalThis.${n}`:e===process?`process.${n}`:e===Error?`Error.${n}`:e===Function.prototype?`Function.prototype.${n}`:e===Object.prototype?`Object.prototype.${n}`:`<object>.${n}`}static runTrusted(e){if(!dt)return e();let n=dt.getStore();if(!n)return e();let{executionId:r}=n;return dt.run({...n,trusted:!0},()=>{t.enterTrustedScope(r);try{let s=e();return typeof s=="object"&&s!==null&&"finally"in s&&typeof s.finally=="function"?s.finally(()=>{t.leaveTrustedScope(r)}):(t.leaveTrustedScope(r),s)}catch(s){throw t.leaveTrustedScope(r),s}})}static async runTrustedAsync(e){if(!dt)return e();let n=dt.getStore();if(!n)return e();let{executionId:r}=n;return dt.run({...n,trusted:!0},async()=>{t.enterTrustedScope(r);try{return await e()}finally{t.leaveTrustedScope(r)}})}shouldBlock(){if(Hs||this.config.auditMode||!dt)return!1;let e=dt?.getStore();return!(e?.sandboxActive!==!0||e.trusted||t.isTrustedScopeActive(e.executionId))}recordViolation(e,n,r){let s={timestamp:Date.now(),type:e,message:r,path:n,stack:new Error().stack,executionId:dt?.getStore()?.executionId};if(this.violations.length<NT&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(i){console.debug("[DefenseInDepthBox] onViolation callback threw:",i instanceof Error?i.message:i)}return s}createBlockingProxy(e,n,r){let s=this;return new Proxy(e,{apply(i,o,a){if(s.shouldBlock()){let l=`${n} is blocked during script execution`,c=s.recordViolation(r,n,l);throw new Se(l,c)}return s.config.auditMode&&dt?.getStore()?.sandboxActive===!0&&s.recordViolation(r,n,`${n} called (audit mode)`),Reflect.apply(i,o,a)},construct(i,o,a){if(s.shouldBlock()){let l=`${n} constructor is blocked during script execution`,c=s.recordViolation(r,n,l);throw new Se(l,c)}return s.config.auditMode&&dt?.getStore()?.sandboxActive===!0&&s.recordViolation(r,n,`${n} constructor called (audit mode)`),Reflect.construct(i,o,a)}})}createBlockingObjectProxy(e,n,r,s){let i=this;return new Proxy(e,{get(o,a,l){if(i.shouldBlock()){if(s&&typeof a=="string"&&s.has(a))return Reflect.get(o,a,l);let c=`${n}.${String(a)}`,u=`${c} is blocked during script execution`,f=i.recordViolation(r,c,u);throw new Se(u,f)}if(i.config.auditMode&&dt?.getStore()?.sandboxActive===!0){let c=`${n}.${String(a)}`;i.recordViolation(r,c,`${c} accessed (audit mode)`)}return Reflect.get(o,a,l)},set(o,a,l,c){if(i.shouldBlock()){let u=`${n}.${String(a)}`,f=`${u} modification is blocked during script execution`,h=i.recordViolation(r,u,f);throw new Se(f,h)}return Reflect.set(o,a,l,c)},ownKeys(o){if(i.shouldBlock()){let a=`${n} enumeration is blocked during script execution`,l=i.recordViolation(r,n,a);throw new Se(a,l)}return Reflect.ownKeys(o)},getOwnPropertyDescriptor(o,a){if(i.shouldBlock()){let l=`${n}.${String(a)}`,c=`${l} descriptor access is blocked during script execution`,u=i.recordViolation(r,l,c);throw new Se(c,u)}return Reflect.getOwnPropertyDescriptor(o,a)},has(o,a){if(i.shouldBlock()){let l=`${n}.${String(a)}`,c=`${l} existence check is blocked during script execution`,u=i.recordViolation(r,l,c);throw new Se(c,u)}return Reflect.has(o,a)},deleteProperty(o,a){if(i.shouldBlock()){let l=`${n}.${String(a)}`,c=`${l} deletion is blocked during script execution`,u=i.recordViolation(r,l,c);throw new Se(c,u)}return Reflect.deleteProperty(o,a)},setPrototypeOf(o,a){if(i.shouldBlock()){let l=`${n} setPrototypeOf is blocked during script execution`,c=i.recordViolation(r,n,l);throw new Se(l,c)}return Reflect.setPrototypeOf(o,a)},defineProperty(o,a,l){if(i.shouldBlock()){let c=`${n}.${String(a)}`,u=`${c} defineProperty is blocked during script execution`,f=i.recordViolation(r,c,u);throw new Se(u,f)}return Reflect.defineProperty(o,a,l)}})}applyPatches(){this.patchFailures=[];let e=ud(),n=new Set(["process_send","process_channel","process_stdout","process_stderr"]);for(let i of e)n.has(i.violationType)||this.applyPatch(i);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.lockWellKnownSymbols(),this.protectProxyRevocable();let r=["Function.prototype.constructor","Module._load"],s=this.patchFailures.filter(i=>r.includes(i));if(s.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${s.join(", ")}`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,n=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==n&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let n=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:n});let r=n?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return r},set(s){if(e.shouldBlock()){let i="Error.prepareStackTrace modification is blocked during script execution",o=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",i);throw new Se(i,o)}e.config.auditMode&&dt?.getStore()?.sandboxActive===!0&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),r=s},configurable:!0})}catch(n){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",n instanceof Error?n.message:n)}}protectPromiseThen(){let e=this;try{let i=function(...o){return dt.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,o);if(this.kind==="fulfilled")return o[0];throw o[0]}return Reflect.apply(this.cb,void 0,o)})};var n=i;let r=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:r});let s=r?.value;if(typeof s!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(a,l){if(!dt)return Reflect.apply(s,this,[a,l]);let c=dt.getStore(),u=c?.sandboxActive===!0&&c.trusted!==!0?c.executionId:void 0;if(!u)return Reflect.apply(s,this,[a,l]);let f=e.getCachedContext(u),h=(d,p)=>typeof d!="function"?d:i.bind({box:e,executionId:u,captured:f,cb:d,kind:p});return Reflect.apply(s,this,[h(a,"fulfilled"),h(l,"rejected")])},writable:!0,configurable:!0})}catch(r){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",r instanceof Error?r.message:r)}}patchPrototypeConstructor(e,n,r){let s=this;try{let i=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:i});let o=i?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let a=`${n} access is blocked during script execution`,l=s.recordViolation(r,n,a);throw new Se(a,l)}return s.config.auditMode&&dt?.getStore()?.sandboxActive===!0&&s.recordViolation(r,n,`${n} accessed (audit mode)`),o},set(a){if(s.shouldBlock()){let l=`${n} modification is blocked during script execution`,c=s.recordViolation(r,n,l);throw new Se(l,c)}Object.defineProperty(this,"constructor",{value:a,writable:!0,configurable:!0})},configurable:!0})}catch(i){this.patchFailures.push(n),console.debug(`[DefenseInDepthBox] Could not patch ${n}:`,i instanceof Error?i.message:i)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let n=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:n});let r=n?.value;r!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",i=e.recordViolation("process_main_module","process.mainModule",s);throw new Se(s,i)}return e.config.auditMode&&dt?.getStore()?.sandboxActive===!0&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),r},set(s){if(e.shouldBlock()){let i="process.mainModule modification is blocked during script execution",o=e.recordViolation("process_main_module","process.mainModule",i);throw new Se(i,o)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(n){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",n instanceof Error?n.message:n)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let n=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:n});let r=n?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",i=e.recordViolation("process_exec_path","process.execPath",s);throw new Se(s,i)}return e.config.auditMode&&dt?.getStore()?.sandboxActive===!0&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),r},set(s){if(e.shouldBlock()){let i="process.execPath modification is blocked during script execution",o=e.recordViolation("process_exec_path","process.execPath",i);throw new Se(i,o)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(n){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",n instanceof Error?n.message:n)}}lockWellKnownSymbols(){let e=(n,r)=>{try{let s=Object.getOwnPropertyDescriptor(n,r);if(s?.configurable){if("value"in s){Object.defineProperty(n,r,{...s,configurable:!1,writable:!1});return}Object.defineProperty(n,r,{...s,configurable:!1})}}catch{}};for(let n of[Array,Map,Set,RegExp,Promise])e(n,Symbol.species);for(let n of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(n,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let n of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,n);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let n of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(n,Symbol.toStringTag);try{let n=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");this.originalDescriptors.push({target:Error,prop:"stackTraceLimit",descriptor:n}),Object.defineProperty(Error,"stackTraceLimit",{value:Error.stackTraceLimit,writable:!1,configurable:!0})}catch{}}protectProxyRevocable(){let e=this;try{let n=Proxy.revocable;if(typeof n!="function")return;let r=Object.getOwnPropertyDescriptor(Proxy,"revocable");this.originalDescriptors.push({target:Proxy,prop:"revocable",descriptor:r}),Object.defineProperty(Proxy,"revocable",{value:function(i,o){if(e.shouldBlock()){let a="Proxy.revocable is blocked during script execution",l=e.recordViolation("proxy","Proxy.revocable",a);throw new Se(a,l)}return e.config.auditMode&&dt?.getStore()?.sandboxActive===!0&&e.recordViolation("proxy","Proxy.revocable","Proxy.revocable called (audit mode)"),n(i,o)},writable:!1,configurable:!0})}catch(n){this.patchFailures.push("Proxy.revocable"),console.debug("[DefenseInDepthBox] Could not protect Proxy.revocable:",n instanceof Error?n.message:n)}}protectDynamicImport(){if(!(Hs||t.importHooksRegistered))try{let e=this,n=require("node:module"),r=new Set;for(let o of n.builtinModules??[]){let a=o.startsWith("node:")?o.slice(5):o;r.add(a);let l=a.indexOf("/");l>0&&r.add(a.slice(0,l))}let s=o=>{if(o.startsWith("./")||o.startsWith("../")||o.startsWith("/")||o.startsWith("file:")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("http:")||o.startsWith("https:"))return!1;let a=o.startsWith("node:")?o.slice(5):o;if(!a)return!1;if(typeof n.isBuiltin=="function"&&n.isBuiltin(a)||r.has(a))return!0;let l=a.indexOf("/");return l>0&&r.has(a.slice(0,l))},i=()=>{let o=dt?.getStore();return e.config.auditMode===!0&&o?.sandboxActive===!0&&o.trusted!==!0&&!t.isTrustedScopeActive(o.executionId)};if(typeof n.registerHooks=="function"){n.registerHooks({resolve(o,a,l){if(o.startsWith("data:")||o.startsWith("blob:"))throw new Error(`dynamic import of ${o.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`);if(s(o)){let c=`import(${o})`,u=`dynamic import of Node.js builtin '${o}' is blocked during script execution`;if(e.shouldBlock()){let f=e.recordViolation("dynamic_import_builtin",c,u);throw new Se(u,f)}i()&&e.recordViolation("dynamic_import_builtin",c,`dynamic import of Node.js builtin '${o}' called (audit mode)`)}return l(o,a)}}),t.importHooksRegistered=!0;return}if(typeof n.register=="function"){let o=["export async function resolve(specifier, context, nextResolve) {",' if (specifier.startsWith("data:") || specifier.startsWith("blob:")) {',' throw new Error("dynamic import of " + (specifier.startsWith("data:") ? "data:" : "blob:") + " URLs is blocked by defense-in-depth");'," }"," return nextResolve(specifier, context);","}"].join(`
4
- `);n.register(`data:text/javascript,${encodeURIComponent(o)}`),t.importHooksRegistered=!0}}catch(e){console.debug("[DefenseInDepthBox] Could not register import() hooks:",e instanceof Error?e.message:e)}}protectModuleLoad(){if(!Hs)try{let e=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(e=o.constructor)}if(!e&&typeof require<"u"&&typeof require.main<"u"&&(e=require.main.constructor),!e||typeof e._load!="function")return;let n=e._load,r=Object.getOwnPropertyDescriptor(e,"_load");this.originalDescriptors.push({target:e,prop:"_load",descriptor:r});let i=this.createBlockingProxy(n,"Module._load","module_load");Object.defineProperty(e,"_load",{value:i,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._load"),console.debug("[DefenseInDepthBox] Could not protect Module._load:",e instanceof Error?e.message:e)}}protectModuleResolveFilename(){if(!Hs)try{let e=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(e=o.constructor)}if(!e&&typeof require<"u"&&typeof require.main<"u"&&(e=require.main.constructor),!e||typeof e._resolveFilename!="function")return;let n=e._resolveFilename,r=Object.getOwnPropertyDescriptor(e,"_resolveFilename");this.originalDescriptors.push({target:e,prop:"_resolveFilename",descriptor:r});let i=this.createBlockingProxy(n,"Module._resolveFilename","module_resolve_filename");Object.defineProperty(e,"_resolveFilename",{value:i,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._resolveFilename"),console.debug("[DefenseInDepthBox] Could not protect Module._resolveFilename:",e instanceof Error?e.message:e)}}applyPatch(e){let{target:n,prop:r,violationType:s,strategy:i}=e;try{let o=n[r];if(o===void 0)return;let a=Object.getOwnPropertyDescriptor(n,r);if(this.originalDescriptors.push({target:n,prop:r,descriptor:a}),i==="freeze")typeof o=="object"&&o!==null&&Object.freeze(o);else{let l=this.getPathForTarget(n,r),c=typeof o=="function"?this.createBlockingProxy(o,l,s):this.createBlockingObjectProxy(o,l,s,e.allowedKeys);Object.defineProperty(n,r,{value:c,writable:!0,configurable:!0})}}catch(o){let a=this.getPathForTarget(n,r);this.patchFailures.push(a),console.debug(`[DefenseInDepthBox] Could not patch ${a}:`,o instanceof Error?o.message:o)}}restorePatches(){for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:n,prop:r,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(n,r,s):delete n[r]}catch(i){let o=this.getPathForTarget(n,r);console.debug(`[DefenseInDepthBox] Could not restore ${o}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}}});function RT(t){return typeof t!="function"?t:tt.bindCurrentContext(t)}var IT,PT,XG,JG,sn,Dt,is=I(()=>{"use strict";en();IT=globalThis.setTimeout.bind(globalThis),PT=globalThis.clearTimeout.bind(globalThis),XG=globalThis.setInterval.bind(globalThis),JG=globalThis.clearInterval.bind(globalThis);sn=((t,e,...n)=>IT(RT(t),e,...n)),Dt=PT});var ib={};ee(ib,{echoCommand:()=>FT,flagsForFuzzing:()=>pd});function $T(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"){if(n+1>=t.length){e+="\\";break}let r=t[n+1];switch(r){case"\\":e+="\\",n+=2;break;case"n":e+=`
4
+ `);n.register(`data:text/javascript,${encodeURIComponent(o)}`),t.importHooksRegistered=!0}}catch(e){console.debug("[DefenseInDepthBox] Could not register import() hooks:",e instanceof Error?e.message:e)}}protectModuleLoad(){if(!Hs)try{let e=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(e=o.constructor)}if(!e&&typeof require<"u"&&typeof require.main<"u"&&(e=require.main.constructor),!e||typeof e._load!="function")return;let n=e._load,r=Object.getOwnPropertyDescriptor(e,"_load");this.originalDescriptors.push({target:e,prop:"_load",descriptor:r});let i=this.createBlockingProxy(n,"Module._load","module_load");Object.defineProperty(e,"_load",{value:i,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._load"),console.debug("[DefenseInDepthBox] Could not protect Module._load:",e instanceof Error?e.message:e)}}protectModuleResolveFilename(){if(!Hs)try{let e=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(e=o.constructor)}if(!e&&typeof require<"u"&&typeof require.main<"u"&&(e=require.main.constructor),!e||typeof e._resolveFilename!="function")return;let n=e._resolveFilename,r=Object.getOwnPropertyDescriptor(e,"_resolveFilename");this.originalDescriptors.push({target:e,prop:"_resolveFilename",descriptor:r});let i=this.createBlockingProxy(n,"Module._resolveFilename","module_resolve_filename");Object.defineProperty(e,"_resolveFilename",{value:i,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._resolveFilename"),console.debug("[DefenseInDepthBox] Could not protect Module._resolveFilename:",e instanceof Error?e.message:e)}}applyPatch(e){let{target:n,prop:r,violationType:s,strategy:i}=e;try{let o=n[r];if(o===void 0)return;let a=Object.getOwnPropertyDescriptor(n,r);if(this.originalDescriptors.push({target:n,prop:r,descriptor:a}),i==="freeze")typeof o=="object"&&o!==null&&Object.freeze(o);else{let l=this.getPathForTarget(n,r),c=typeof o=="function"?this.createBlockingProxy(o,l,s):this.createBlockingObjectProxy(o,l,s,e.allowedKeys);Object.defineProperty(n,r,{value:c,writable:!0,configurable:!0})}}catch(o){let a=this.getPathForTarget(n,r);this.patchFailures.push(a),console.debug(`[DefenseInDepthBox] Could not patch ${a}:`,o instanceof Error?o.message:o)}}restorePatches(){for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:n,prop:r,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(n,r,s):delete n[r]}catch(i){let o=this.getPathForTarget(n,r);console.debug(`[DefenseInDepthBox] Could not restore ${o}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}}});function RT(t){return typeof t!="function"?t:tt.bindCurrentContext(t)}var IT,PT,XG,JG,sn,Dt,os=I(()=>{"use strict";en();IT=globalThis.setTimeout.bind(globalThis),PT=globalThis.clearTimeout.bind(globalThis),XG=globalThis.setInterval.bind(globalThis),JG=globalThis.clearInterval.bind(globalThis);sn=((t,e,...n)=>IT(RT(t),e,...n)),Dt=PT});var ib={};ee(ib,{echoCommand:()=>FT,flagsForFuzzing:()=>pd});function $T(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"){if(n+1>=t.length){e+="\\";break}let r=t[n+1];switch(r){case"\\":e+="\\",n+=2;break;case"n":e+=`
5
5
  `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"e":case"E":e+="\x1B",n+=2;break;case"c":return{output:e,stop:!0};case"0":{let s="",i=n+2;for(;i<t.length&&i<n+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\0";else{let o=parseInt(s,8)%256;e+=String.fromCharCode(o)}n=i;break}case"x":{let s="",i=n+2;for(;i<t.length&&i<n+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\x",n+=2;else{let o=parseInt(s,16);e+=String.fromCharCode(o),n=i}break}case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\u",n+=2;else{let o=parseInt(s,16);e+=String.fromCodePoint(o),n=i}break}case"U":{let s="",i=n+2;for(;i<t.length&&i<n+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\U",n+=2;else{let o=parseInt(s,16);try{e+=String.fromCodePoint(o)}catch{e+=`\\U${s}`}n=i}break}default:e+=`\\${r}`,n+=2}}else e+=t[n],n++;return{output:e,stop:!1}}var FT,pd,md=I(()=>{"use strict";FT={name:"echo",async execute(t,e){let n=!1,r=e.xpgEcho??!1,s=0;for(;s<t.length;){let o=t[s];if(o==="-n")n=!0,s++;else if(o==="-e")r=!0,s++;else if(o==="-E")r=!1,s++;else if(o==="-ne"||o==="-en")n=!0,r=!0,s++;else break}let i=t.slice(s).join(" ");if(r){let o=$T(i);if(i=o.output,o.stop)return{stdout:i,stderr:"",exitCode:0}}return n||(i+=`
6
- `),{stdout:i,stderr:"",exitCode:0}}},pd={name:"echo",flags:[{flag:"-n",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-E",type:"boolean"}],stdinType:"none",needsArgs:!0}});function Lr(t){return t}function Rt(t){return t}function te(t){let e=t;if(!e)return e;let n=!1;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);if(i>255)return e;i>127&&(n=!0)}if(!n)return e;let r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);try{return _T.decode(r)}catch{return e}}function Er(t){if(!t)return t;let e=DT.encode(t),n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return n}function LT(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e}async function os(t,e){return typeof t.readFileBytes=="function"?t.readFileBytes(e):LT(await t.readFileBuffer(e))}function gd(t){return t.stdoutKind?t.stdoutKind:t.stdoutEncoding==="binary"?"bytes":"text"}function Ra(t){return gd(t)==="bytes"?t.stdout:Er(t.stdout)}function ob(t){return{stdout:t,stdoutKind:"text"}}function ab(t){return{stdout:t,stdoutKind:"bytes",stdoutEncoding:"binary"}}var _T,DT,yc,pe=I(()=>{"use strict";_T=new TextDecoder("utf-8",{fatal:!0}),DT=new TextEncoder;yc=""});function B(t){let e=`${t.name} - ${t.summary}
6
+ `),{stdout:i,stderr:"",exitCode:0}}},pd={name:"echo",flags:[{flag:"-n",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-E",type:"boolean"}],stdinType:"none",needsArgs:!0}});function Lr(t){return t}function Rt(t){return t}function te(t){let e=t;if(!e)return e;let n=!1;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);if(i>255)return e;i>127&&(n=!0)}if(!n)return e;let r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);try{return _T.decode(r)}catch{return e}}function Er(t){if(!t)return t;let e=DT.encode(t),n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return n}function LT(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e}async function as(t,e){return typeof t.readFileBytes=="function"?t.readFileBytes(e):LT(await t.readFileBuffer(e))}function gd(t){return t.stdoutKind?t.stdoutKind:t.stdoutEncoding==="binary"?"bytes":"text"}function Ra(t){return gd(t)==="bytes"?t.stdout:Er(t.stdout)}function ob(t){return{stdout:t,stdoutKind:"text"}}function ab(t){return{stdout:t,stdoutKind:"bytes",stdoutEncoding:"binary"}}var _T,DT,yc,pe=I(()=>{"use strict";_T=new TextDecoder("utf-8",{fatal:!0}),DT=new TextEncoder;yc=""});function B(t){let e=`${t.name} - ${t.summary}
7
7
 
8
8
  `;if(e+=`Usage: ${t.usage}
9
9
  `,t.description){if(e+=`
@@ -26,18 +26,18 @@ Notes:
26
26
  `:`${t}: invalid option -- '${e.replace(/^-/,"")}'
27
27
  `,exitCode:1}}var ue=I(()=>{"use strict"});function je(t,e,n){let r=new Map,s=new Map;for(let[l,c]of Object.entries(n)){let u={name:l,type:c.type};c.short&&r.set(c.short,u),c.long&&s.set(c.long,u)}let i=Object.create(null);for(let[l,c]of Object.entries(n))c.default!==void 0?i[l]=c.default:c.type==="boolean"&&(i[l]=!1);let o=[],a=!1;for(let l=0;l<e.length;l++){let c=e[l];if(a||!c.startsWith("-")||c==="-"){o.push(c);continue}if(c==="--"){a=!0;continue}if(c.startsWith("--")){let u=c.indexOf("="),f,h;u!==-1?(f=c.slice(2,u),h=c.slice(u+1)):f=c.slice(2);let d=s.get(f);if(!d)return{ok:!1,error:Q(t,c)};let{name:p,type:m}=d;if(m==="boolean")i[p]=!0;else{if(h===void 0){if(l+1>=e.length)return{ok:!1,error:{stdout:"",stderr:`${t}: option '--${f}' requires an argument
28
28
  `,exitCode:1}};h=e[++l]}i[p]=m==="number"?parseInt(h,10):h}}else{let u=c.slice(1);for(let f=0;f<u.length;f++){let h=u[f],d=r.get(h);if(!d)return{ok:!1,error:Q(t,`-${h}`)};let{name:p,type:m}=d;if(m==="boolean")i[p]=!0;else{let g;if(f+1<u.length)g=u.slice(f+1);else if(l+1<e.length)g=e[++l];else return{ok:!1,error:{stdout:"",stderr:`${t}: option requires an argument -- '${h}'
29
- `,exitCode:1}};i[p]=m==="number"?parseInt(g,10):g;break}}}}return{ok:!0,result:{flags:i,positional:o}}}var jt=I(()=>{"use strict";ue()});var yo=I(()=>{"use strict"});async function Ts(t,e,n){let{cmdName:r,allowStdinMarker:s=!0,stopOnError:i=!1,batchSize:o=100}=n;if(e.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let a=[],l="",c=0;for(let u=0;u<e.length;u+=o){let f=e.slice(u,u+o),h=await Promise.all(f.map(async d=>{if(s&&d==="-")return{filename:"-",content:t.stdin,error:null};try{let p=t.fs.resolvePath(t.cwd,d),m=await os(t.fs,p);return{filename:d,content:m,error:null}}catch{return{filename:d,content:yc,error:`${r}: ${d}: No such file or directory
29
+ `,exitCode:1}};i[p]=m==="number"?parseInt(g,10):g;break}}}}return{ok:!0,result:{flags:i,positional:o}}}var jt=I(()=>{"use strict";ue()});var yo=I(()=>{"use strict"});async function Ts(t,e,n){let{cmdName:r,allowStdinMarker:s=!0,stopOnError:i=!1,batchSize:o=100}=n;if(e.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let a=[],l="",c=0;for(let u=0;u<e.length;u+=o){let f=e.slice(u,u+o),h=await Promise.all(f.map(async d=>{if(s&&d==="-")return{filename:"-",content:t.stdin,error:null};try{let p=t.fs.resolvePath(t.cwd,d),m=await as(t.fs,p);return{filename:d,content:m,error:null}}catch{return{filename:d,content:yc,error:`${r}: ${d}: No such file or directory
30
30
  `}}}));for(let d of h)if(d.error){if(l+=d.error,c=1,i)return{files:a,stderr:l,exitCode:c}}else a.push({filename:d.filename,content:d.content})}return{files:a,stderr:l,exitCode:c}}async function wo(t,e,n){let r=await Ts(t,e,{...n,stopOnError:!0});return r.exitCode!==0?{ok:!1,error:{stdout:"",stderr:r.stderr,exitCode:r.exitCode}}:{ok:!0,content:r.files.map(i=>i.content).join("")}}var Vs=I(()=>{"use strict";pe();yo()});var lb={};ee(lb,{catCommand:()=>UT,flagsForFuzzing:()=>yd});function zT(t,e){let n=t.split(`
31
31
  `),r=t.endsWith(`
32
32
  `),s=r?n.slice(0,-1):n;return{content:s.map((o,a)=>`${String(e+a).padStart(6," ")} ${o}`).join(`
33
33
  `)+(r?`
34
- `:""),nextLineNumber:e+s.length}}var MT,BT,UT,yd,wd=I(()=>{"use strict";pe();jt();Vs();ue();MT={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},BT={number:{short:"n",long:"number",type:"boolean"}},UT={name:"cat",async execute(t,e){if(U(t))return B(MT);let n=je("cat",t,BT);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await Ts(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files){let c=l;if(r){let u=zT(c,a);o+=u.content,a=u.nextLineNumber}else o+=c}return{stdout:o,stderr:i.stderr,exitCode:i.exitCode,stdoutEncoding:"binary"}}};yd={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0}});function wc(t){return t instanceof Nn||t instanceof Tn||t instanceof pn}var kn,Nn,Tn,pn,Hn,Pn,Re,lt,Rn,as,bo,ie,Eo,ls,ar,Me=I(()=>{"use strict";kn=class extends Error{stdout;stderr;constructor(e,n="",r=""){super(e),this.stdout=n,this.stderr=r}prependOutput(e,n){this.stdout=e+this.stdout,this.stderr=n+this.stderr}},Nn=class extends kn{levels;name="BreakError";constructor(e=1,n="",r=""){super("break",n,r),this.levels=e}},Tn=class extends kn{levels;name="ContinueError";constructor(e=1,n="",r=""){super("continue",n,r),this.levels=e}},pn=class extends kn{exitCode;name="ReturnError";constructor(e=0,n="",r=""){super("return",n,r),this.exitCode=e}},Hn=class extends kn{exitCode;name="ErrexitError";constructor(e,n="",r=""){super(`errexit: command exited with status ${e}`,n,r),this.exitCode=e}},Pn=class extends kn{varName;name="NounsetError";constructor(e,n=""){super(`${e}: unbound variable`,n,`bash: ${e}: unbound variable
34
+ `:""),nextLineNumber:e+s.length}}var MT,BT,UT,yd,wd=I(()=>{"use strict";pe();jt();Vs();ue();MT={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},BT={number:{short:"n",long:"number",type:"boolean"}},UT={name:"cat",async execute(t,e){if(U(t))return B(MT);let n=je("cat",t,BT);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await Ts(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files){let c=l;if(r){let u=zT(c,a);o+=u.content,a=u.nextLineNumber}else o+=c}return{stdout:o,stderr:i.stderr,exitCode:i.exitCode,stdoutEncoding:"binary"}}};yd={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0}});function wc(t){return t instanceof Nn||t instanceof Tn||t instanceof pn}var kn,Nn,Tn,pn,Hn,Pn,Re,lt,Rn,ls,bo,ie,Eo,cs,ar,Me=I(()=>{"use strict";kn=class extends Error{stdout;stderr;constructor(e,n="",r=""){super(e),this.stdout=n,this.stderr=r}prependOutput(e,n){this.stdout=e+this.stdout,this.stderr=n+this.stderr}},Nn=class extends kn{levels;name="BreakError";constructor(e=1,n="",r=""){super("break",n,r),this.levels=e}},Tn=class extends kn{levels;name="ContinueError";constructor(e=1,n="",r=""){super("continue",n,r),this.levels=e}},pn=class extends kn{exitCode;name="ReturnError";constructor(e=0,n="",r=""){super("return",n,r),this.exitCode=e}},Hn=class extends kn{exitCode;name="ErrexitError";constructor(e,n="",r=""){super(`errexit: command exited with status ${e}`,n,r),this.exitCode=e}},Pn=class extends kn{varName;name="NounsetError";constructor(e,n=""){super(`${e}: unbound variable`,n,`bash: ${e}: unbound variable
35
35
  `),this.varName=e}},Re=class extends kn{exitCode;stdoutKind;stdoutEncoding;name="ExitError";constructor(e,n="",r="",s,i){super("exit",n,r),this.exitCode=e,this.stdoutKind=s,this.stdoutEncoding=i}},lt=class extends kn{name="ArithmeticError";fatal;constructor(e,n="",r="",s=!1){super(e,n,r),this.stderr=r||`bash: ${e}
36
36
  `,this.fatal=s}},Rn=class extends kn{name="BadSubstitutionError";constructor(e,n="",r=""){super(e,n,r),this.stderr=r||`bash: ${e}: bad substitution
37
- `}},as=class extends kn{name="GlobError";constructor(e,n="",r=""){super(`no match: ${e}`,n,r),this.stderr=r||`bash: no match: ${e}
37
+ `}},ls=class extends kn{name="GlobError";constructor(e,n="",r=""){super(`no match: ${e}`,n,r),this.stderr=r||`bash: no match: ${e}
38
38
  `}},bo=class extends kn{name="BraceExpansionError";constructor(e,n="",r=""){super(e,n,r),this.stderr=r||`bash: ${e}
39
39
  `}},ie=class extends kn{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,n,r="",s=""){super(e,r,s),this.limitType=n,this.stderr=s||`bash: ${e}
40
- `}},Eo=class extends kn{name="ExecutionAbortedError";constructor(e="",n=""){super("execution aborted",e,n)}},ls=class extends kn{name="SubshellExitError";constructor(e="",n=""){super("subshell exit",e,n)}};ar=class extends kn{exitCode;name="PosixFatalError";constructor(e,n="",r=""){super("posix fatal error",n,r),this.exitCode=e}}});function ct(t){return t instanceof Error?t.message:String(t)}var $n=I(()=>{"use strict"});function bc(t,e,n){let r=t;n>=0&&r.length>n&&(r=r.slice(0,n));let s=Math.abs(e);return s>r.length&&(e<0?r=r.padEnd(s," "):r=r.padStart(s," ")),r}function cb(t,e){let n=e,r=0,s=-1,i=!1;for(n<t.length&&t[n]==="-"&&(i=!0,n++);n<t.length&&/\d/.test(t[n]);)r=r*10+parseInt(t[n],10),n++;if(n<t.length&&t[n]===".")for(n++,s=0;n<t.length&&/\d/.test(t[n]);)s=s*10+parseInt(t[n],10),n++;return i&&r>0&&(r=-r),[r,s,n-e]}function Ec(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)switch(t[n+1]){case"n":e+=`
40
+ `}},Eo=class extends kn{name="ExecutionAbortedError";constructor(e="",n=""){super("execution aborted",e,n)}},cs=class extends kn{name="SubshellExitError";constructor(e="",n=""){super("subshell exit",e,n)}};ar=class extends kn{exitCode;name="PosixFatalError";constructor(e,n="",r=""){super("posix fatal error",n,r),this.exitCode=e}}});function ct(t){return t instanceof Error?t.message:String(t)}var $n=I(()=>{"use strict"});function bc(t,e,n){let r=t;n>=0&&r.length>n&&(r=r.slice(0,n));let s=Math.abs(e);return s>r.length&&(e<0?r=r.padEnd(s," "):r=r.padStart(s," ")),r}function cb(t,e){let n=e,r=0,s=-1,i=!1;for(n<t.length&&t[n]==="-"&&(i=!0,n++);n<t.length&&/\d/.test(t[n]);)r=r*10+parseInt(t[n],10),n++;if(n<t.length&&t[n]===".")for(n++,s=0;n<t.length&&/\d/.test(t[n]);)s=s*10+parseInt(t[n],10),n++;return i&&r>0&&(r=-r),[r,s,n-e]}function Ec(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)switch(t[n+1]){case"n":e+=`
41
41
  `,n+=2;break;case"t":e+=" ",n+=2;break;case"r":e+="\r",n+=2;break;case"\\":e+="\\",n+=2;break;case"a":e+="\x07",n+=2;break;case"b":e+="\b",n+=2;break;case"f":e+="\f",n+=2;break;case"v":e+="\v",n+=2;break;case"e":case"E":e+="\x1B",n+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<t.length&&i<n+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),n=i;break}case"x":{let s=[],i=n;for(;i+3<t.length&&t[i]==="\\"&&t[i+1]==="x"&&/[0-9a-fA-F]{2}/.test(t.slice(i+2,i+4));)s.push(parseInt(t.slice(i+2,i+4),16)),i+=4;if(s.length>0){try{let o=new TextDecoder("utf-8",{fatal:!0});e+=o.decode(new Uint8Array(s))}catch{for(let o of s)e+=String.fromCharCode(o)}n=i}else e+=t[n],n++;break}case"u":{let s="",i=n+2;for(;i<t.length&&i<n+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\u",n+=2);break}case"U":{let s="",i=n+2;for(;i<t.length&&i<n+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),n=i):(e+="\\U",n+=2);break}default:e+=t[n],n++}else e+=t[n],n++;return e}var bd=I(()=>{"use strict"});function hb(t,e,n){let r=new Date(e*1e3),s="",i=0;for(;i<t.length;)if(t[i]==="%"&&i+1<t.length){let o=t[i+1],a=jT(r,o,n);a!==null?(s+=a,i+=2):(s+=t[i],i++)}else s+=t[i],i++;return s}function WT(t,e){let n={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",weekday:"short",hour12:!1,timeZone:e};try{let s=new Intl.DateTimeFormat("en-US",n).formatToParts(t),i=l=>s.find(c=>c.type===l)?.value??"",o=new Map([["Sun",0],["Mon",1],["Tue",2],["Wed",3],["Thu",4],["Fri",5],["Sat",6]]),a=i("weekday");return{year:Number.parseInt(i("year"),10)||t.getFullYear(),month:Number.parseInt(i("month"),10)||t.getMonth()+1,day:Number.parseInt(i("day"),10)||t.getDate(),hour:Number.parseInt(i("hour"),10)||t.getHours(),minute:Number.parseInt(i("minute"),10)||t.getMinutes(),second:Number.parseInt(i("second"),10)||t.getSeconds(),weekday:o.get(a)??t.getDay()}}catch{return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),weekday:t.getDay()}}}function jT(t,e,n){let r=WT(t,n),s=(l,c=2)=>String(l).padStart(c,"0"),i=db(r.year,r.month,r.day),o=ub(r.year,r.month,r.day,r.weekday,0),a=ub(r.year,r.month,r.day,r.weekday,1);switch(e){case"a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][r.weekday];case"A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][r.weekday];case"b":case"h":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.month-1];case"B":return["January","February","March","April","May","June","July","August","September","October","November","December"][r.month-1];case"c":return`${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][r.weekday]} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.month-1]} ${String(r.day).padStart(2," ")} ${s(r.hour)}:${s(r.minute)}:${s(r.second)} ${r.year}`;case"C":return s(Math.floor(r.year/100));case"d":return s(r.day);case"D":return`${s(r.month)}/${s(r.day)}/${s(r.year%100)}`;case"e":return String(r.day).padStart(2," ");case"F":return`${r.year}-${s(r.month)}-${s(r.day)}`;case"g":return s(fb(r.year,r.month,r.day)%100);case"G":return String(fb(r.year,r.month,r.day));case"H":return s(r.hour);case"I":return s(r.hour%12||12);case"j":return String(i).padStart(3,"0");case"k":return String(r.hour).padStart(2," ");case"l":return String(r.hour%12||12).padStart(2," ");case"m":return s(r.month);case"M":return s(r.minute);case"n":return`
42
42
  `;case"N":return"000000000";case"p":return r.hour<12?"AM":"PM";case"P":return r.hour<12?"am":"pm";case"r":return`${s(r.hour%12||12)}:${s(r.minute)}:${s(r.second)} ${r.hour<12?"AM":"PM"}`;case"R":return`${s(r.hour)}:${s(r.minute)}`;case"s":return String(Math.floor(t.getTime()/1e3));case"S":return s(r.second);case"t":return" ";case"T":return`${s(r.hour)}:${s(r.minute)}:${s(r.second)}`;case"u":return String(r.weekday===0?7:r.weekday);case"U":return s(o);case"V":return s(VT(r.year,r.month,r.day));case"w":return String(r.weekday);case"W":return s(a);case"x":return`${s(r.month)}/${s(r.day)}/${s(r.year%100)}`;case"X":return`${s(r.hour)}:${s(r.minute)}:${s(r.second)}`;case"y":return s(r.year%100);case"Y":return String(r.year);case"z":return qT(t,n);case"Z":return HT(t,n);case"%":return"%";default:return null}}function qT(t,e){if(!e){let o=-t.getTimezoneOffset(),a=o>=0?"+":"-",l=Math.floor(Math.abs(o)/60),c=Math.abs(o)%60;return`${a}${String(l).padStart(2,"0")}${String(c).padStart(2,"0")}`}try{let l=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t).find(c=>c.type==="timeZoneName");if(l){let c=l.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(c)return`${c[1]}${c[2]}${c[3]}`;if(l.value==="GMT"||l.value==="UTC")return"+0000"}}catch{}let n=-t.getTimezoneOffset(),r=n>=0?"+":"-",s=Math.floor(Math.abs(n)/60),i=Math.abs(n)%60;return`${r}${String(s).padStart(2,"0")}${String(i).padStart(2,"0")}`}function HT(t,e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"short"}).formatToParts(t).find(i=>i.type==="timeZoneName")?.value??"UTC"}catch{return"UTC"}}function db(t,e,n){let r=[31,28,31,30,31,30,31,31,30,31,30,31];(t%4===0&&t%100!==0||t%400===0)&&(r[1]=29);let i=n;for(let o=0;o<e-1;o++)i+=r[o];return i}function ub(t,e,n,r,s){let i=db(t,e,n),l=(new Date(t,0,1).getDay()-s+7)%7,c=(r-s+7)%7,u=i-1+l;return Math.floor((u-c+7)/7)}function VT(t,e,n){let r=new Date(t,e-1,n,12,0,0);r.setDate(r.getDate()+3-(r.getDay()+6)%7);let s=new Date(r.getFullYear(),0,4);s.setDate(s.getDate()+3-(s.getDay()+6)%7);let i=r.getTime()-s.getTime();return 1+Math.round(i/(10080*60*1e3))}function fb(t,e,n){let r=new Date(t,e-1,n,12,0,0);return r.setDate(r.getDate()+3-(r.getDay()+6)%7),r.getFullYear()}var pb=I(()=>{"use strict"});var gb={};ee(gb,{flagsForFuzzing:()=>Ed,printfCommand:()=>ZT});function GT(t){let e="",n=0;for(;n<t.length;){let r=t[n];if(r<128){e+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<t.length&&(t[n+1]&192)===128&&r>=194){let s=(r&31)<<6|t[n+1]&63;e+=String.fromCharCode(s),n+=2;continue}e+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<t.length&&(t[n+1]&192)===128&&(t[n+2]&192)===128){if(r===224&&t[n+1]<160){e+=String.fromCharCode(r),n++;continue}let s=(r&15)<<12|(t[n+1]&63)<<6|t[n+2]&63;if(s>=55296&&s<=57343){e+=String.fromCharCode(r),n++;continue}e+=String.fromCharCode(s),n+=3;continue}e+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<t.length&&(t[n+1]&192)===128&&(t[n+2]&192)===128&&(t[n+3]&192)===128){if(r===240&&t[n+1]<144){e+=String.fromCharCode(r),n++;continue}let s=(r&7)<<18|(t[n+1]&63)<<12|(t[n+2]&63)<<6|t[n+3]&63;if(s>1114111){e+=String.fromCharCode(r),n++;continue}e+=String.fromCodePoint(s),n+=4;continue}e+=String.fromCharCode(r),n++;continue}e+=String.fromCharCode(r),n++}return e}function YT(t,e,n,r){let s="",i=0,o=0,a=!1,l="";for(;i<t.length;)if(t[i]==="%"&&i+1<t.length){let c=i;if(i++,t[i]==="%"){s+="%",i++;continue}let u=t.slice(c).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(u){let A=u[1]?parseInt(u[1],10):0,C=u[2]?parseInt(u[2],10):-1,P=u[3],$=u[0],O=e[n+o]||"";o++;let R;O===""||O==="-1"||O==="-2"?R=Math.floor(Date.now()/1e3):R=parseInt(O,10)||0;let k=hb(P,R,r);if(C>=0&&k.length>C&&(k=k.slice(0,C)),A!==0){let S=Math.abs(A);k.length<S&&(A<0?k=k.padEnd(S," "):k=k.padStart(S," "))}s+=k,i=c+$.length;continue}for(;i<t.length&&"+-0 #'".includes(t[i]);)i++;let f=!1;if(t[i]==="*")f=!0,i++;else for(;i<t.length&&/\d/.test(t[i]);)i++;let h=!1;if(t[i]===".")if(i++,t[i]==="*")h=!0,i++;else for(;i<t.length&&/\d/.test(t[i]);)i++;i<t.length&&"hlL".includes(t[i])&&i++;let d=t[i]||"";i++;let m=t.slice(c,i);if(f){let A=parseInt(e[n+o]||"0",10);o++,m=m.replace("*",String(A))}if(h){let A=parseInt(e[n+o]||"0",10);o++,m=m.replace(".*",`.${A}`)}let g=e[n+o]||"";o++;let{value:y,parseError:w,parseErrMsg:b,stopped:E}=QT(m,d,g);if(s+=y,w&&(a=!0,b&&(l=b)),E)return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!0}}else s+=t[i],i++;return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!1}}function QT(t,e,n){let r=!1,s="";switch(e){case"d":case"i":{let i=xc(n);return r=Mr,r&&(s=`printf: ${n}: invalid number
43
43
  `),{value:mb(t,i),parseError:r,parseErrMsg:s}}case"o":{let i=xc(n);return r=Mr,r&&(s=`printf: ${n}: invalid number
@@ -159,22 +159,22 @@ Options:
159
159
  `,i+=`Access: (${f}/${h})
160
160
  `,i+=`Modify: ${u.mtime.toISOString()}
161
161
  `}}catch{o+=`stat: cannot stat '${l}': No such file or directory
162
- `,a=!0}}return{stdout:i,stderr:o,exitCode:a?1:0}}},ep={name:"stat",flags:[{flag:"-c",type:"value",valueHint:"format"},{flag:"-L",type:"boolean"}],needsArgs:!0}});var J,L,F,xr,Ce,Ye,i7,Gs,Nc,np,So,us,rp,sp,Tt,Ao,wt,ip,Br,op,Tc,Te,ap,Oc,$a,WO,jO,lp,cp,M,up,xo,fp,hp,Ze,Ub,zb,Wb,jb,qb,Hb,Vb,Gb,Kb,Zb,Yb,Qb,Xb,Jb,e7,t7,n7,r7,s7,cs,Fa,dp,pp,mp,gp,yp,Ks,o7=I(()=>{J=class t{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=t.CLASS_NL|t.DOT_NL;static PERL=t.CLASS_NL|t.ONE_LINE|t.PERL_X|t.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},L=class{static CODES=new Map([["\x07",7],["\b",8],[" ",9],[`
162
+ `,a=!0}}return{stdout:i,stderr:o,exitCode:a?1:0}}},ep={name:"stat",flags:[{flag:"-c",type:"value",valueHint:"format"},{flag:"-L",type:"boolean"}],needsArgs:!0}});var J,L,F,xr,Ce,Ye,i7,Gs,Nc,np,So,fs,rp,sp,Tt,Ao,wt,ip,Br,op,Tc,Te,ap,Oc,$a,WO,jO,lp,cp,M,up,xo,fp,hp,Ze,Ub,zb,Wb,jb,qb,Hb,Vb,Gb,Kb,Zb,Yb,Qb,Xb,Jb,e7,t7,n7,r7,s7,us,Fa,dp,pp,mp,gp,yp,Ks,o7=I(()=>{J=class t{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=t.CLASS_NL|t.DOT_NL;static PERL=t.CLASS_NL|t.ONE_LINE|t.PERL_X|t.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},L=class{static CODES=new Map([["\x07",7],["\b",8],[" ",9],[`
163
163
  `,10],["\v",11],["\f",12],["\r",13],[" ",32],['"',34],["$",36],["&",38],["(",40],[")",41],["*",42],["+",43],["-",45],[".",46],["0",48],["1",49],["2",50],["3",51],["4",52],["5",53],["6",54],["7",55],["8",56],["9",57],[":",58],["<",60],[">",62],["?",63],["A",65],["B",66],["C",67],["F",70],["P",80],["Q",81],["U",85],["Z",90],["[",91],["\\",92],["]",93],["^",94],["_",95],["a",97],["b",98],["f",102],["i",105],["m",109],["n",110],["r",114],["s",115],["t",116],["v",118],["x",120],["z",122],["{",123],["|",124],["}",125]]);static toUpperCase(e){let n=String.fromCodePoint(e).toUpperCase();if(n.length>1)return e;let r=String.fromCodePoint(n.codePointAt(0)).toLowerCase();return r.length>1||r.codePointAt(0)!==e?e:n.codePointAt(0)}static toLowerCase(e){let n=String.fromCodePoint(e).toLowerCase();if(n.length>1)return e;let r=String.fromCodePoint(n.codePointAt(0)).toUpperCase();return r.length>1||r.codePointAt(0)!==e?e:n.codePointAt(0)}},F=class{SIZE=3;constructor(e){this.data=e}getLo(e){return this.data[e*this.SIZE]}getHi(e){return this.data[e*this.SIZE+1]}getStride(e){return this.data[e*this.SIZE+2]}get(e){let n=e*this.SIZE;return[this.data[n],this.data[n+1],this.data[n+2]]}get length(){return this.data.length/this.SIZE}},xr=class t{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[68944,68976],[68976,68944],[68945,68977],[68977,68945],[68946,68978],[68978,68946],[68947,68979],[68979,68947],[68948,68980],[68980,68948],[68949,68981],[68981,68949],[68950,68982],[68982,68950],[68951,68983],[68983,68951],[68952,68984],[68984,68952],[68953,68985],[68985,68953],[68954,68986],[68986,68954],[68955,68987],[68987,68955],[68956,68988],[68988,68956],[68957,68989],[68989,68957],[68958,68990],[68990,68958],[68959,68991],[68991,68959],[68960,68992],[68992,68960],[68961,68993],[68993,68961],[68962,68994],[68994,68962],[68963,68995],[68995,68963],[68964,68996],[68996,68964],[68965,68997],[68997,68965],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[93771,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=new F(new Uint32Array([0,31,1,127,159,1,173,888,715,889,896,7,897,899,1,907,909,2,930,1328,398,1367,1368,1,1419,1420,1,1424,1480,56,1481,1487,1,1515,1518,1,1525,1541,1,1564,1757,193,1806,1807,1,1867,1868,1,1970,1983,1,2043,2044,1,2094,2095,1,2111,2140,29,2141,2143,2,2155,2159,1,2191,2198,1,2274,2436,162,2445,2446,1,2449,2450,1,2473,2481,8,2483,2485,1,2490,2491,1,2501,2502,1,2505,2506,1,2511,2518,1,2520,2523,1,2526,2532,6,2533,2559,26,2560,2564,4,2571,2574,1,2577,2578,1,2601,2609,8,2612,2618,3,2619,2621,2,2627,2630,1,2633,2634,1,2638,2640,1,2642,2648,1,2653,2655,2,2656,2661,1,2679,2688,1,2692,2702,10,2706,2729,23,2737,2740,3,2746,2747,1,2758,2766,4,2767,2769,2,2770,2783,1,2788,2789,1,2802,2808,1,2816,2820,4,2829,2830,1,2833,2834,1,2857,2865,8,2868,2874,6,2875,2885,10,2886,2889,3,2890,2894,4,2895,2900,1,2904,2907,1,2910,2916,6,2917,2936,19,2937,2945,1,2948,2955,7,2956,2957,1,2961,2966,5,2967,2968,1,2971,2973,2,2976,2978,1,2981,2983,1,2987,2989,1,3002,3005,1,3011,3013,1,3017,3022,5,3023,3025,2,3026,3030,1,3032,3045,1,3067,3071,1,3085,3089,4,3113,3130,17,3131,3141,10,3145,3150,5,3151,3156,1,3159,3163,4,3164,3166,2,3167,3172,5,3173,3184,11,3185,3190,1,3213,3217,4,3241,3252,11,3258,3259,1,3269,3273,4,3278,3284,1,3287,3292,1,3295,3300,5,3301,3312,11,3316,3327,1,3341,3345,4,3397,3401,4,3408,3411,1,3428,3429,1,3456,3460,4,3479,3481,1,3506,3516,10,3518,3519,1,3527,3529,1,3531,3534,1,3541,3543,2,3552,3557,1,3568,3569,1,3573,3584,1,3643,3646,1,3676,3712,1,3715,3717,2,3723,3748,25,3750,3774,24,3775,3781,6,3783,3791,8,3802,3803,1,3808,3839,1,3912,3949,37,3950,3952,1,3992,4029,37,4045,4059,14,4060,4095,1,4294,4296,2,4297,4300,1,4302,4303,1,4681,4686,5,4687,4695,8,4697,4702,5,4703,4745,42,4750,4751,1,4785,4790,5,4791,4799,8,4801,4806,5,4807,4823,16,4881,4886,5,4887,4955,68,4956,4989,33,4990,4991,1,5018,5023,1,5110,5111,1,5118,5119,1,5789,5791,1,5881,5887,1,5910,5918,1,5943,5951,1,5972,5983,1,5997,6001,4,6004,6015,1,6110,6111,1,6122,6127,1,6138,6143,1,6158,6170,12,6171,6175,1,6265,6271,1,6315,6319,1,6390,6399,1,6431,6444,13,6445,6447,1,6460,6463,1,6465,6467,1,6510,6511,1,6517,6527,1,6572,6575,1,6602,6607,1,6619,6621,1,6684,6685,1,6751,6781,30,6782,6794,12,6795,6799,1,6810,6815,1,6830,6831,1,6863,6911,1,6989,7156,167,7157,7163,1,7224,7226,1,7242,7244,1,7307,7311,1,7355,7356,1,7368,7375,1,7419,7423,1,7958,7959,1,7966,7967,1,8006,8007,1,8014,8015,1,8024,8030,2,8062,8063,1,8117,8133,16,8148,8149,1,8156,8176,20,8177,8181,4,8191,8203,12,8204,8207,1,8234,8238,1,8288,8303,1,8306,8307,1,8335,8349,14,8350,8351,1,8385,8399,1,8433,8447,1,8588,8591,1,9258,9279,1,9291,9311,1,11124,11125,1,11158,11508,350,11509,11512,1,11558,11560,2,11561,11564,1,11566,11567,1,11624,11630,1,11633,11646,1,11671,11679,1,11687,11743,8,11870,11903,1,11930,12020,90,12021,12031,1,12246,12271,1,12352,12439,87,12440,12544,104,12545,12548,1,12592,12687,95,12774,12782,1,12831,42125,29294,42126,42127,1,42183,42191,1,42540,42559,1,42744,42751,1,42958,42959,1,42962,42964,2,42973,42993,1,43053,43055,1,43066,43071,1,43128,43135,1,43206,43213,1,43226,43231,1,43348,43358,1,43389,43391,1,43470,43482,12,43483,43485,1,43519,43575,56,43576,43583,1,43598,43599,1,43610,43611,1,43715,43738,1,43767,43776,1,43783,43784,1,43791,43792,1,43799,43807,1,43815,43823,8,43884,43887,1,44014,44015,1,44026,44031,1,55204,55215,1,55239,55242,1,55292,63743,1,64110,64111,1,64218,64255,1,64263,64274,1,64280,64284,1,64311,64317,6,64319,64325,3,64451,64466,1,64912,64913,1,64968,64974,1,64976,65007,1,65050,65055,1,65107,65127,20,65132,65135,1,65141,65277,136,65278,65280,1,65471,65473,1,65480,65481,1,65488,65489,1,65496,65497,1,65501,65503,1,65511,65519,8,65520,65531,1,65534,65535,1,65548,65575,27,65595,65598,3,65614,65615,1,65630,65663,1,65787,65791,1,65795,65798,1,65844,65846,1,65935,65949,14,65950,65951,1,65953,65999,1,66046,66175,1,66205,66207,1,66257,66271,1,66300,66303,1,66340,66348,1,66379,66383,1,66427,66431,1,66462,66500,38,66501,66503,1,66518,66559,1,66718,66719,1,66730,66735,1,66772,66775,1,66812,66815,1,66856,66863,1,66916,66926,1,66939,66955,16,66963,66966,3,66978,66994,16,67002,67005,3,67006,67007,1,67060,67071,1,67383,67391,1,67414,67423,1,67432,67455,1,67462,67505,43,67515,67583,1,67590,67591,1,67593,67638,45,67641,67643,1,67645,67646,1,67670,67743,73,67744,67750,1,67760,67807,1,67827,67830,3,67831,67834,1,67868,67870,1,67898,67902,1,67904,67967,1,68024,68027,1,68048,68049,1,68100,68103,3,68104,68107,1,68116,68120,4,68150,68151,1,68155,68158,1,68169,68175,1,68185,68191,1,68256,68287,1,68327,68330,1,68343,68351,1,68406,68408,1,68438,68439,1,68467,68471,1,68498,68504,1,68509,68520,1,68528,68607,1,68681,68735,1,68787,68799,1,68851,68857,1,68904,68911,1,68922,68927,1,68966,68968,1,68998,69005,1,69008,69215,1,69247,69290,43,69294,69295,1,69298,69313,1,69317,69371,1,69416,69423,1,69466,69487,1,69514,69551,1,69580,69599,1,69623,69631,1,69710,69713,1,69750,69758,1,69821,69827,6,69828,69839,1,69865,69871,1,69882,69887,1,69941,69960,19,69961,69967,1,70007,70015,1,70112,70133,21,70134,70143,1,70162,70210,48,70211,70271,1,70279,70281,2,70286,70302,16,70314,70319,1,70379,70383,1,70394,70399,1,70404,70413,9,70414,70417,3,70418,70441,23,70449,70452,3,70458,70469,11,70470,70473,3,70474,70478,4,70479,70481,2,70482,70486,1,70488,70492,1,70500,70501,1,70509,70511,1,70517,70527,1,70538,70540,2,70541,70543,2,70582,70593,11,70595,70596,1,70598,70603,5,70614,70617,3,70618,70624,1,70627,70655,1,70748,70754,6,70755,70783,1,70856,70863,1,70874,71039,1,71094,71095,1,71134,71167,1,71237,71247,1,71258,71263,1,71277,71295,1,71354,71359,1,71370,71375,1,71396,71423,1,71451,71452,1,71468,71471,1,71495,71679,1,71740,71839,1,71923,71934,1,71943,71944,1,71946,71947,1,71956,71959,3,71990,71993,3,71994,72007,13,72008,72015,1,72026,72095,1,72104,72105,1,72152,72153,1,72165,72191,1,72264,72271,1,72355,72367,1,72441,72447,1,72458,72639,1,72674,72687,1,72698,72703,1,72713,72759,46,72774,72783,1,72813,72815,1,72848,72849,1,72872,72887,15,72888,72959,1,72967,72970,3,73015,73017,1,73019,73022,3,73032,73039,1,73050,73055,1,73062,73065,3,73103,73106,3,73113,73119,1,73130,73439,1,73465,73471,1,73489,73531,42,73532,73533,1,73563,73647,1,73649,73663,1,73714,73726,1,74650,74751,1,74863,74869,6,74870,74879,1,75076,77711,1,77811,77823,1,78896,78911,1,78934,78943,1,82939,82943,1,83527,90367,1,90426,92159,1,92729,92735,1,92767,92778,11,92779,92781,1,92863,92874,11,92875,92879,1,92910,92911,1,92918,92927,1,92998,93007,1,93018,93026,8,93048,93052,1,93072,93503,1,93562,93759,1,93851,93951,1,94027,94030,1,94088,94094,1,94112,94175,1,94181,94191,1,94194,94207,1,100344,100351,1,101590,101630,1,101641,110575,1,110580,110588,8,110591,110883,292,110884,110897,1,110899,110927,1,110931,110932,1,110934,110947,1,110952,110959,1,111356,113663,1,113771,113775,1,113789,113791,1,113801,113807,1,113818,113819,1,113824,117759,1,118010,118015,1,118452,118527,1,118574,118575,1,118599,118607,1,118724,118783,1,119030,119039,1,119079,119080,1,119155,119162,1,119275,119295,1,119366,119487,1,119508,119519,1,119540,119551,1,119639,119647,1,119673,119807,1,119893,119965,72,119968,119969,1,119971,119972,1,119975,119976,1,119981,119994,13,119996,120004,8,120070,120075,5,120076,120085,9,120093,120122,29,120127,120133,6,120135,120137,1,120145,120486,341,120487,120780,293,120781,121484,703,121485,121498,1,121504,121520,16,121521,122623,1,122655,122660,1,122667,122879,1,122887,122905,18,122906,122914,8,122917,122923,6,122924,122927,1,122990,123022,1,123024,123135,1,123181,123183,1,123198,123199,1,123210,123213,1,123216,123535,1,123567,123583,1,123642,123646,1,123648,124111,1,124154,124367,1,124411,124414,1,124416,124895,1,124903,124908,5,124911,124927,16,125125,125126,1,125143,125183,1,125260,125263,1,125274,125277,1,125280,126064,1,126133,126208,1,126270,126463,1,126468,126496,28,126499,126501,2,126502,126504,2,126515,126520,5,126522,126524,2,126525,126529,1,126531,126534,1,126536,126540,2,126544,126547,3,126549,126550,1,126552,126560,2,126563,126565,2,126566,126571,5,126579,126589,5,126591,126602,11,126620,126624,1,126628,126634,6,126652,126703,1,126706,126975,1,127020,127023,1,127124,127135,1,127151,127152,1,127168,127184,16,127222,127231,1,127406,127461,1,127491,127503,1,127548,127551,1,127561,127567,1,127570,127583,1,127590,127743,1,128728,128731,1,128749,128751,1,128765,128767,1,128887,128890,1,128986,128991,1,129004,129007,1,129009,129023,1,129036,129039,1,129096,129103,1,129114,129119,1,129160,129167,1,129198,129199,1,129212,129215,1,129218,129279,1,129620,129631,1,129646,129647,1,129661,129663,1,129674,129678,1,129735,129741,1,129757,129758,1,129770,129775,1,129785,129791,1,129939,130042,103,130043,131071,1,173792,173823,1,177978,177983,1,178206,178207,1,183970,183983,1,191457,191471,1,192094,194559,1,195102,196607,1,201547,201551,1,205744,917759,1,918e3,1114111,1]));static Cc=new F(new Uint32Array([0,31,1,127,159,1]));static Cf=new F(new Uint32Array([173,1536,1363,1537,1541,1,1564,1757,193,1807,2192,385,2193,2274,81,6158,8203,2045,8204,8207,1,8234,8238,1,8288,8292,1,8294,8303,1,65279,65529,250,65530,65531,1,69821,69837,16,78896,78911,1,113824,113827,1,119155,119162,1,917505,917536,31,917537,917631,1]));static Co=new F(new Uint32Array([57344,63743,1,983040,1048573,1,1048576,1114109,1]));static Cs=new F(new Uint32Array([55296,57343,1]));static L=new F(new Uint32Array([65,90,1,97,122,1,170,181,11,186,192,6,193,214,1,216,246,1,248,705,1,710,721,1,736,740,1,748,750,2,880,884,1,886,887,1,890,893,1,895,902,7,904,906,1,908,910,2,911,929,1,931,1013,1,1015,1153,1,1162,1327,1,1329,1366,1,1369,1376,7,1377,1416,1,1488,1514,1,1519,1522,1,1568,1610,1,1646,1647,1,1649,1747,1,1749,1765,16,1766,1774,8,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2036,2037,1,2042,2048,6,2049,2069,1,2074,2084,10,2088,2112,24,2113,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2249,1,2308,2361,1,2365,2384,19,2392,2401,1,2417,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3654,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3782,3804,22,3805,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4256,18,4257,4293,1,4295,4301,6,4304,4346,1,4348,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5024,5109,1,5112,5117,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6103,6108,5,6176,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6823,6917,94,6918,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7293,1,7296,7306,1,7312,7354,1,7357,7359,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,7424,6,7425,7615,1,7680,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8124,1,8126,8130,4,8131,8132,1,8134,8140,1,8144,8147,1,8150,8155,1,8160,8172,1,8178,8180,1,8182,8188,1,8305,8319,14,8336,8348,1,8450,8455,5,8458,8467,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8495,8505,1,8508,8511,1,8517,8521,1,8526,8579,53,8580,11264,2684,11265,11492,1,11499,11502,1,11506,11507,1,11520,11557,1,11559,11565,6,11568,11623,1,11631,11648,17,11649,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11823,12293,470,12294,12337,43,12338,12341,1,12347,12348,1,12353,12438,1,12445,12447,1,12449,12538,1,12540,12543,1,12549,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,42124,1,42192,42237,1,42240,42508,1,42512,42527,1,42538,42539,1,42560,42606,1,42623,42653,1,42656,42725,1,42775,42783,1,42786,42888,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43471,43488,17,43489,43492,1,43494,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43741,1,43744,43754,1,43762,43764,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43866,1,43868,43881,1,43888,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65313,65338,1,65345,65370,1,65382,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66560,66717,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68736,68786,1,68800,68850,1,68864,68899,1,68938,68965,1,68975,68997,1,69248,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71840,71903,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,92992,92995,1,93027,93047,1,93053,93071,1,93504,93548,1,93760,93823,1,93952,94026,1,94032,94099,67,94100,94111,1,94176,94177,1,94179,94208,29,94209,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120512,1,120514,120538,1,120540,120570,1,120572,120596,1,120598,120628,1,120630,120654,1,120656,120686,1,120688,120712,1,120714,120744,1,120746,120770,1,120772,120779,1,122624,122654,1,122661,122666,1,122928,122989,1,123136,123180,1,123191,123197,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124139,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125184,125251,1,125259,126464,1205,126465,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static foldL=new F(new Uint32Array([837,837,1]));static Ll=new F(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,311,2,312,328,2,329,375,2,378,382,2,383,384,1,387,389,2,392,396,4,397,402,5,405,409,4,410,411,1,414,417,3,419,421,2,424,426,2,427,429,2,432,436,4,438,441,3,442,445,3,446,447,1,454,460,3,462,476,2,477,495,2,496,499,3,501,505,4,507,563,2,564,569,1,572,575,3,576,578,2,583,591,2,592,659,1,661,687,1,881,883,2,887,891,4,892,893,1,912,940,28,941,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1020,1072,52,1073,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1376,1416,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7424,118,7425,7467,1,7531,7543,1,7545,7578,1,7681,7829,2,7830,7837,1,7839,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8016,8023,1,8032,8039,1,8048,8061,1,8064,8071,1,8080,8087,1,8096,8103,1,8112,8116,1,8118,8119,1,8126,8130,4,8131,8132,1,8134,8135,1,8144,8147,1,8150,8151,1,8160,8167,1,8178,8180,1,8182,8183,1,8458,8462,4,8463,8467,4,8495,8505,5,8508,8509,1,8518,8521,1,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11377,11379,2,11380,11382,2,11383,11387,1,11393,11491,2,11492,11500,8,11502,11507,5,11520,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42800,42801,1,42803,42865,2,42866,42872,1,42874,42876,2,42879,42887,2,42892,42894,2,42897,42899,2,42900,42901,1,42903,42921,2,42927,42933,6,42935,42947,2,42952,42954,2,42957,42961,4,42963,42971,2,42998,43002,4,43824,43866,1,43872,43880,1,43888,43967,1,64256,64262,1,64275,64279,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,119834,119859,1,119886,119892,1,119894,119911,1,119938,119963,1,119990,119993,1,119995,119997,2,119998,120003,1,120005,120015,1,120042,120067,1,120094,120119,1,120146,120171,1,120198,120223,1,120250,120275,1,120302,120327,1,120354,120379,1,120406,120431,1,120458,120485,1,120514,120538,1,120540,120545,1,120572,120596,1,120598,120603,1,120630,120654,1,120656,120661,1,120688,120712,1,120714,120719,1,120746,120770,1,120772,120777,1,120779,122624,1845,122625,122633,1,122635,122654,1,122661,122666,1,125218,125251,1]));static foldLl=new F(new Uint32Array([65,90,1,192,214,1,216,222,1,256,302,2,306,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,453,1,455,456,1,458,459,1,461,475,2,478,494,2,497,498,1,500,502,2,503,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,837,880,43,882,886,4,895,902,7,904,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,984,9,986,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8072,8079,1,8088,8095,1,8104,8111,1,8120,8124,1,8136,8140,1,8152,8155,1,8168,8172,1,8184,8188,1,8486,8490,4,8491,8498,7,8579,11264,2685,11265,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,125184,125217,1]));static Lm=new F(new Uint32Array([688,705,1,710,721,1,736,740,1,748,750,2,884,890,6,1369,1600,231,1765,1766,1,2036,2037,1,2042,2074,32,2084,2088,4,2249,2417,168,3654,3782,128,4348,6103,1755,6211,6823,612,7288,7293,1,7468,7530,1,7544,7579,35,7580,7615,1,8305,8319,14,8336,8348,1,11388,11389,1,11631,11823,192,12293,12337,44,12338,12341,1,12347,12445,98,12446,12540,94,12541,12542,1,40981,42232,1251,42233,42237,1,42508,42623,115,42652,42653,1,42775,42783,1,42864,42888,24,42994,42996,1,43e3,43001,1,43471,43494,23,43632,43741,109,43763,43764,1,43868,43871,1,43881,65392,21511,65438,65439,1,67456,67461,1,67463,67504,1,67506,67514,1,68942,68975,33,92992,92995,1,93504,93506,1,93547,93548,1,94099,94111,1,94176,94177,1,94179,110576,16397,110577,110579,1,110581,110587,1,110589,110590,1,122928,122989,1,123191,123197,1,124139,125259,1120]));static Lo=new F(new Uint32Array([170,186,16,443,448,5,449,451,1,660,1488,828,1489,1514,1,1519,1522,1,1568,1599,1,1601,1610,1,1646,1647,1,1649,1747,1,1749,1774,25,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2048,2069,1,2112,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2248,1,2308,2361,1,2365,2384,19,2392,2401,1,2418,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3653,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3804,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4352,114,4353,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6108,6176,68,6177,6210,1,6212,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6917,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7287,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,8501,1083,8502,8504,1,11568,11623,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,12294,12348,54,12353,12438,1,12447,12449,2,12450,12538,1,12543,12549,6,12550,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,40980,1,40982,42124,1,42192,42231,1,42240,42507,1,42512,42527,1,42538,42539,1,42606,42656,50,42657,42725,1,42895,42999,104,43003,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43488,43492,1,43495,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43631,1,43633,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43740,1,43744,43754,1,43762,43777,15,43778,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43968,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65382,65391,1,65393,65437,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66640,66717,1,66816,66855,1,66864,66915,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68864,68899,1,68938,68941,1,68943,69248,305,69249,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,93027,93047,1,93053,93071,1,93507,93546,1,93952,94026,1,94032,94208,176,94209,100343,1,100352,101589,1,101631,101640,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,122634,123136,502,123137,123180,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124138,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Lt=new F(new Uint32Array([453,459,3,498,8072,7574,8073,8079,1,8088,8095,1,8104,8111,1,8124,8140,16,8188,8188,1]));static foldLt=new F(new Uint32Array([452,454,2,455,457,2,458,460,2,497,499,2,8064,8071,1,8080,8087,1,8096,8103,1,8115,8131,16,8179,8179,1]));static Lu=new F(new Uint32Array([65,90,1,192,214,1,216,222,1,256,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,461,3,463,475,2,478,494,2,497,500,3,502,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,880,882,2,886,895,9,902,904,2,905,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,978,3,979,980,1,984,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8120,8123,1,8136,8139,1,8152,8155,1,8168,8172,1,8184,8187,1,8450,8455,5,8459,8461,1,8464,8466,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8496,8499,1,8510,8511,1,8517,8579,62,11264,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,119808,119833,1,119860,119885,1,119912,119937,1,119964,119966,2,119967,119973,3,119974,119977,3,119978,119980,1,119982,119989,1,120016,120041,1,120068,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120120,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120172,120197,1,120224,120249,1,120276,120301,1,120328,120353,1,120380,120405,1,120432,120457,1,120488,120512,1,120546,120570,1,120604,120628,1,120662,120686,1,120720,120744,1,120778,125184,4406,125185,125217,1]));static Upper=this.Lu;static foldLu=new F(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,303,2,307,311,2,314,328,2,331,375,2,378,382,2,383,384,1,387,389,2,392,396,4,402,405,3,409,411,1,414,417,3,419,421,2,424,429,5,432,436,4,438,441,3,445,447,2,453,454,1,456,457,1,459,460,1,462,476,2,477,495,2,498,499,1,501,505,4,507,543,2,547,563,2,572,575,3,576,578,2,583,591,2,592,596,1,598,599,1,601,603,2,604,608,4,609,611,2,612,614,1,616,620,1,623,625,2,626,629,3,637,640,3,642,643,1,647,652,1,658,669,11,670,837,167,881,883,2,887,891,4,892,893,1,940,943,1,945,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1072,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1377,1414,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7545,239,7549,7566,17,7681,7829,2,7835,7841,6,7843,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8017,8023,2,8032,8039,1,8048,8061,1,8112,8113,1,8126,8144,18,8145,8160,15,8161,8165,4,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11379,11382,3,11393,11491,2,11500,11502,2,11507,11520,13,11521,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42803,42863,2,42874,42876,2,42879,42887,2,42892,42897,5,42899,42900,1,42903,42921,2,42933,42947,2,42952,42954,2,42957,42961,4,42967,42971,2,42998,43859,861,43888,43967,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,125218,125251,1]));static M=new F(new Uint32Array([768,879,1,1155,1161,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2307,1,2362,2364,1,2366,2383,1,2385,2391,1,2402,2403,1,2433,2435,1,2492,2494,2,2495,2500,1,2503,2504,1,2507,2509,1,2519,2530,11,2531,2558,27,2561,2563,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2672,31,2673,2677,4,2689,2691,1,2748,2750,2,2751,2757,1,2759,2761,1,2763,2765,1,2786,2787,1,2810,2815,1,2817,2819,1,2876,2878,2,2879,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2914,2915,1,2946,3006,60,3007,3010,1,3014,3016,1,3018,3021,1,3031,3072,41,3073,3076,1,3132,3134,2,3135,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3203,1,3260,3262,2,3263,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3298,3299,1,3315,3328,13,3329,3331,1,3387,3388,1,3390,3396,1,3398,3400,1,3402,3405,1,3415,3426,11,3427,3457,30,3458,3459,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3570,3571,1,3633,3636,3,3637,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3902,3903,1,3953,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4139,101,4140,4158,1,4182,4185,1,4190,4192,1,4194,4196,1,4199,4205,1,4209,4212,1,4226,4237,1,4239,4250,11,4251,4253,1,4957,4959,1,5906,5909,1,5938,5940,1,5970,5971,1,6002,6003,1,6068,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6443,1,6448,6459,1,6679,6683,1,6741,6750,1,6752,6780,1,6783,6832,49,6833,6862,1,6912,6916,1,6964,6980,1,7019,7027,1,7040,7042,1,7073,7085,1,7142,7155,1,7204,7223,1,7376,7378,1,7380,7400,1,7405,7412,7,7415,7417,1,7616,7679,1,8400,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12335,1,12441,12442,1,42607,42610,1,42612,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43043,24,43044,43047,1,43052,43136,84,43137,43188,51,43189,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43347,1,43392,43395,1,43443,43456,1,43493,43561,68,43562,43574,1,43587,43596,9,43597,43643,46,43644,43645,1,43696,43698,2,43699,43700,1,43703,43704,1,43710,43711,1,43713,43755,42,43756,43759,1,43765,43766,1,44003,44010,1,44012,44013,1,64286,65024,738,65025,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69632,69634,1,69688,69702,1,69744,69747,3,69748,69759,11,69760,69762,1,69808,69818,1,69826,69888,62,69889,69890,1,69927,69940,1,69957,69958,1,70003,70016,13,70017,70018,1,70067,70080,1,70089,70092,1,70094,70095,1,70188,70199,1,70206,70209,3,70367,70378,1,70400,70403,1,70459,70460,1,70462,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70502,3,70503,70508,1,70512,70516,1,70584,70592,1,70594,70597,3,70599,70602,1,70604,70608,1,70610,70625,15,70626,70709,83,70710,70726,1,70750,70832,82,70833,70851,1,71087,71093,1,71096,71104,1,71132,71133,1,71216,71232,1,71339,71351,1,71453,71467,1,71724,71738,1,71984,71989,1,71991,71992,1,71995,71998,1,72e3,72002,2,72003,72145,142,72146,72151,1,72154,72160,1,72164,72193,29,72194,72202,1,72243,72249,1,72251,72254,1,72263,72273,10,72274,72283,1,72330,72345,1,72751,72758,1,72760,72767,1,72850,72871,1,72873,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73098,67,73099,73102,1,73104,73105,1,73107,73111,1,73459,73462,1,73472,73473,1,73475,73524,49,73525,73530,1,73534,73538,1,73562,78912,5350,78919,78933,1,90398,90415,1,92912,92916,1,92976,92982,1,94031,94033,2,94034,94087,1,94095,94098,1,94180,94192,12,94193,113821,19628,113822,118528,4706,118529,118573,1,118576,118598,1,119141,119145,1,119149,119154,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldM=new F(new Uint32Array([921,953,32,8126,8126,1]));static Mc=new F(new Uint32Array([2307,2363,56,2366,2368,1,2377,2380,1,2382,2383,1,2434,2435,1,2494,2496,1,2503,2504,1,2507,2508,1,2519,2563,44,2622,2624,1,2691,2750,59,2751,2752,1,2761,2763,2,2764,2818,54,2819,2878,59,2880,2887,7,2888,2891,3,2892,2903,11,3006,3007,1,3009,3010,1,3014,3016,1,3018,3020,1,3031,3073,42,3074,3075,1,3137,3140,1,3202,3203,1,3262,3264,2,3265,3268,1,3271,3272,1,3274,3275,1,3285,3286,1,3315,3330,15,3331,3390,59,3391,3392,1,3398,3400,1,3402,3404,1,3415,3458,43,3459,3535,76,3536,3537,1,3544,3551,1,3570,3571,1,3902,3903,1,3967,4139,172,4140,4145,5,4152,4155,3,4156,4182,26,4183,4194,11,4195,4196,1,4199,4205,1,4227,4228,1,4231,4236,1,4239,4250,11,4251,4252,1,5909,5940,31,6070,6078,8,6079,6085,1,6087,6088,1,6435,6438,1,6441,6443,1,6448,6449,1,6451,6456,1,6681,6682,1,6741,6743,2,6753,6755,2,6756,6765,9,6766,6770,1,6916,6965,49,6971,6973,2,6974,6977,1,6979,6980,1,7042,7073,31,7078,7079,1,7082,7143,61,7146,7148,1,7150,7154,4,7155,7204,49,7205,7211,1,7220,7221,1,7393,7415,22,12334,12335,1,43043,43044,1,43047,43136,89,43137,43188,51,43189,43203,1,43346,43347,1,43395,43444,49,43445,43450,5,43451,43454,3,43455,43456,1,43567,43568,1,43571,43572,1,43597,43643,46,43645,43755,110,43758,43759,1,43765,44003,238,44004,44006,2,44007,44009,2,44010,44012,2,69632,69634,2,69762,69808,46,69809,69810,1,69815,69816,1,69932,69957,25,69958,70018,60,70067,70069,1,70079,70080,1,70094,70188,94,70189,70190,1,70194,70195,1,70197,70368,171,70369,70370,1,70402,70403,1,70462,70463,1,70465,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70584,85,70585,70586,1,70594,70597,3,70599,70602,1,70604,70605,1,70607,70709,102,70710,70711,1,70720,70721,1,70725,70832,107,70833,70834,1,70841,70843,2,70844,70846,1,70849,71087,238,71088,71089,1,71096,71099,1,71102,71216,114,71217,71218,1,71227,71228,1,71230,71340,110,71342,71343,1,71350,71454,104,71456,71457,1,71462,71724,262,71725,71726,1,71736,71984,248,71985,71989,1,71991,71992,1,71997,72e3,3,72002,72145,143,72146,72147,1,72156,72159,1,72164,72249,85,72279,72280,1,72343,72751,408,72766,72873,107,72881,72884,3,73098,73102,1,73107,73108,1,73110,73461,351,73462,73475,13,73524,73525,1,73534,73535,1,73537,90410,16873,90411,90412,1,94033,94087,1,94192,94193,1,119141,119142,1,119149,119154,1]));static Me=new F(new Uint32Array([1160,1161,1,6846,8413,1567,8414,8416,1,8418,8420,1,42608,42610,1]));static Mn=new F(new Uint32Array([768,879,1,1155,1159,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2306,1,2362,2364,2,2369,2376,1,2381,2385,4,2386,2391,1,2402,2403,1,2433,2492,59,2497,2500,1,2509,2530,21,2531,2558,27,2561,2562,1,2620,2625,5,2626,2631,5,2632,2635,3,2636,2637,1,2641,2672,31,2673,2677,4,2689,2690,1,2748,2753,5,2754,2757,1,2759,2760,1,2765,2786,21,2787,2810,23,2811,2815,1,2817,2876,59,2879,2881,2,2882,2884,1,2893,2901,8,2902,2914,12,2915,2946,31,3008,3021,13,3072,3076,4,3132,3134,2,3135,3136,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3260,59,3263,3270,7,3276,3277,1,3298,3299,1,3328,3329,1,3387,3388,1,3393,3396,1,3405,3426,21,3427,3457,30,3530,3538,8,3539,3540,1,3542,3633,91,3636,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3953,3966,1,3968,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4141,103,4142,4144,1,4146,4151,1,4153,4154,1,4157,4158,1,4184,4185,1,4190,4192,1,4209,4212,1,4226,4229,3,4230,4237,7,4253,4957,704,4958,4959,1,5906,5908,1,5938,5939,1,5970,5971,1,6002,6003,1,6068,6069,1,6071,6077,1,6086,6089,3,6090,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6434,1,6439,6440,1,6450,6457,7,6458,6459,1,6679,6680,1,6683,6742,59,6744,6750,1,6752,6754,2,6757,6764,1,6771,6780,1,6783,6832,49,6833,6845,1,6847,6862,1,6912,6915,1,6964,6966,2,6967,6970,1,6972,6978,6,7019,7027,1,7040,7041,1,7074,7077,1,7080,7081,1,7083,7085,1,7142,7144,2,7145,7149,4,7151,7153,1,7212,7219,1,7222,7223,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8400,8412,1,8417,8421,4,8422,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12333,1,12441,12442,1,42607,42612,5,42613,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43045,26,43046,43052,6,43204,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43345,1,43392,43394,1,43443,43446,3,43447,43449,1,43452,43453,1,43493,43561,68,43562,43566,1,43569,43570,1,43573,43574,1,43587,43596,9,43644,43696,52,43698,43700,1,43703,43704,1,43710,43711,1,43713,43756,43,43757,43766,9,44005,44008,3,44013,64286,20273,65024,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69633,69688,55,69689,69702,1,69744,69747,3,69748,69759,11,69760,69761,1,69811,69814,1,69817,69818,1,69826,69888,62,69889,69890,1,69927,69931,1,69933,69940,1,70003,70016,13,70017,70070,53,70071,70078,1,70089,70092,1,70095,70191,96,70192,70193,1,70196,70198,2,70199,70206,7,70209,70367,158,70371,70378,1,70400,70401,1,70459,70460,1,70464,70502,38,70503,70508,1,70512,70516,1,70587,70592,1,70606,70610,2,70625,70626,1,70712,70719,1,70722,70724,1,70726,70750,24,70835,70840,1,70842,70847,5,70848,70850,2,70851,71090,239,71091,71093,1,71100,71101,1,71103,71104,1,71132,71133,1,71219,71226,1,71229,71231,2,71232,71339,107,71341,71344,3,71345,71349,1,71351,71453,102,71455,71458,3,71459,71461,1,71463,71467,1,71727,71735,1,71737,71738,1,71995,71996,1,71998,72003,5,72148,72151,1,72154,72155,1,72160,72193,33,72194,72202,1,72243,72248,1,72251,72254,1,72263,72273,10,72274,72278,1,72281,72283,1,72330,72342,1,72344,72345,1,72752,72758,1,72760,72765,1,72767,72850,83,72851,72871,1,72874,72880,1,72882,72883,1,72885,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73104,73,73105,73109,4,73111,73459,348,73460,73472,12,73473,73526,53,73527,73530,1,73536,73538,2,73562,78912,5350,78919,78933,1,90398,90409,1,90413,90415,1,92912,92916,1,92976,92982,1,94031,94095,64,94096,94098,1,94180,113821,19641,113822,118528,4706,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldMn=new F(new Uint32Array([921,953,32,8126,8126,1]));static N=new F(new Uint32Array([48,57,1,178,179,1,185,188,3,189,190,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2548,2553,1,2662,2671,1,2790,2799,1,2918,2927,1,2930,2935,1,3046,3058,1,3174,3183,1,3192,3198,1,3302,3311,1,3416,3422,1,3430,3448,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3891,1,4160,4169,1,4240,4249,1,4969,4988,1,5870,5872,1,6112,6121,1,6128,6137,1,6160,6169,1,6470,6479,1,6608,6618,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,8304,8308,4,8309,8313,1,8320,8329,1,8528,8578,1,8581,8585,1,9312,9371,1,9450,9471,1,10102,10131,1,11517,12295,778,12321,12329,1,12344,12346,1,12690,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,42528,42537,1,42726,42735,1,43056,43061,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,65799,65843,1,65856,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,66369,66378,9,66513,66517,1,66720,66729,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,68912,68921,1,68928,68937,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70113,70132,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71483,1,71904,71922,1,72016,72025,1,72688,72697,1,72784,72812,1,73040,73049,1,73120,73129,1,73552,73561,1,73664,73684,1,74752,74862,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93019,93025,1,93552,93561,1,93824,93846,1,118e3,118009,1,119488,119507,1,119520,119539,1,119648,119672,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125127,125135,1,125264,125273,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1,130032,130041,1]));static Nd=new F(new Uint32Array([48,57,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2662,2671,1,2790,2799,1,2918,2927,1,3046,3055,1,3174,3183,1,3302,3311,1,3430,3439,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3881,1,4160,4169,1,4240,4249,1,6112,6121,1,6160,6169,1,6470,6479,1,6608,6617,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,42528,42537,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,66720,66729,1,68912,68921,1,68928,68937,1,69734,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71481,1,71904,71913,1,72016,72025,1,72688,72697,1,72784,72793,1,73040,73049,1,73120,73129,1,73552,73561,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93552,93561,1,118e3,118009,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125264,125273,1,130032,130041,1]));static Nl=new F(new Uint32Array([5870,5872,1,8544,8578,1,8581,8584,1,12295,12321,26,12322,12329,1,12344,12346,1,42726,42735,1,65856,65908,1,66369,66378,9,66513,66517,1,74752,74862,1]));static No=new F(new Uint32Array([178,179,1,185,188,3,189,190,1,2548,2553,1,2930,2935,1,3056,3058,1,3192,3198,1,3416,3422,1,3440,3448,1,3882,3891,1,4969,4988,1,6128,6137,1,6618,8304,1686,8308,8313,1,8320,8329,1,8528,8543,1,8585,9312,727,9313,9371,1,9450,9471,1,10102,10131,1,11517,12690,1173,12691,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,43056,43061,1,65799,65843,1,65909,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69733,1,70113,70132,1,71482,71483,1,71914,71922,1,72794,72812,1,73664,73684,1,93019,93025,1,93824,93846,1,119488,119507,1,119520,119539,1,119648,119672,1,125127,125135,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1]));static P=new F(new Uint32Array([33,35,1,37,42,1,44,47,1,58,59,1,63,64,1,91,93,1,95,123,28,125,161,36,167,171,4,182,183,1,187,191,4,894,903,9,1370,1375,1,1417,1418,1,1470,1472,2,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3898,38,3899,3901,1,3973,4048,75,4049,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5120,5742,622,5787,5788,1,5867,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8208,829,8209,8231,1,8240,8259,1,8261,8273,1,8275,8286,1,8317,8318,1,8333,8334,1,8968,8971,1,9001,9002,1,10088,10101,1,10181,10182,1,10214,10223,1,10627,10648,1,10712,10715,1,10748,10749,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11822,1,11824,11855,1,11858,11869,1,12289,12291,1,12296,12305,1,12308,12319,1,12336,12349,13,12448,12539,91,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,64830,20819,64831,65040,209,65041,65049,1,65072,65106,1,65108,65121,1,65123,65128,5,65130,65131,1,65281,65283,1,65285,65290,1,65292,65295,1,65306,65307,1,65311,65312,1,65339,65341,1,65343,65371,28,65373,65375,2,65376,65381,1,65792,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,68974,69293,319,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Pc=new F(new Uint32Array([95,8255,8160,8256,8276,20,65075,65076,1,65101,65103,1,65343,65343,1]));static Pd=new F(new Uint32Array([45,1418,1373,1470,5120,3650,6150,8208,2058,8209,8213,1,11799,11802,3,11834,11835,1,11840,11869,29,12316,12336,20,12448,65073,52625,65074,65112,38,65123,65293,170,68974,69293,319]));static Pe=new F(new Uint32Array([41,93,52,125,3899,3774,3901,5788,1887,8262,8318,56,8334,8969,635,8971,9002,31,10089,10101,2,10182,10215,33,10217,10223,2,10628,10648,2,10713,10715,2,10749,11811,1062,11813,11817,2,11862,11868,2,12297,12305,2,12309,12315,2,12318,12319,1,64830,65048,218,65078,65092,2,65096,65114,18,65116,65118,2,65289,65341,52,65373,65379,3]));static Pf=new F(new Uint32Array([187,8217,8030,8221,8250,29,11779,11781,2,11786,11789,3,11805,11809,4]));static Pi=new F(new Uint32Array([171,8216,8045,8219,8220,1,8223,8249,26,11778,11780,2,11785,11788,3,11804,11808,4]));static Po=new F(new Uint32Array([33,35,1,37,39,1,42,46,2,47,58,11,59,63,4,64,92,28,161,167,6,182,183,1,191,894,703,903,1370,467,1371,1375,1,1417,1472,55,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3973,113,4048,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5742,5867,125,5868,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6149,1,6151,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8214,835,8215,8224,9,8225,8231,1,8240,8248,1,8251,8254,1,8257,8259,1,8263,8273,1,8275,8277,2,8278,8286,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11782,5,11783,11784,1,11787,11790,3,11791,11798,1,11800,11801,1,11803,11806,3,11807,11818,11,11819,11822,1,11824,11833,1,11836,11839,1,11841,11843,2,11844,11855,1,11858,11860,1,12289,12291,1,12349,12539,190,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,65040,21029,65041,65046,1,65049,65072,23,65093,65094,1,65097,65100,1,65104,65106,1,65108,65111,1,65119,65121,1,65128,65130,2,65131,65281,150,65282,65283,1,65285,65287,1,65290,65294,2,65295,65306,11,65307,65311,4,65312,65340,28,65377,65380,3,65381,65792,411,65793,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Ps=new F(new Uint32Array([40,91,51,123,3898,3775,3900,5787,1887,8218,8222,4,8261,8317,56,8333,8968,635,8970,9001,31,10088,10100,2,10181,10214,33,10216,10222,2,10627,10647,2,10712,10714,2,10748,11810,1062,11812,11816,2,11842,11861,19,11863,11867,2,12296,12304,2,12308,12314,2,12317,64831,52514,65047,65077,30,65079,65091,2,65095,65113,18,65115,65117,2,65288,65339,51,65371,65375,4,65378,65378,1]));static S=new F(new Uint32Array([36,43,7,60,62,1,94,96,2,124,126,2,162,166,1,168,169,1,172,174,2,175,177,1,180,184,4,215,247,32,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,1014,113,1154,1421,267,1422,1423,1,1542,1544,1,1547,1550,3,1551,1758,207,1769,1789,20,1790,2038,248,2046,2047,1,2184,2546,362,2547,2554,7,2555,2801,246,2928,3059,131,3060,3066,1,3199,3407,208,3449,3647,198,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6107,366,6464,6622,158,6623,6655,1,7009,7018,1,7028,7036,1,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,8260,8274,14,8314,8316,1,8330,8332,1,8352,8384,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8472,1,8478,8483,1,8485,8489,2,8494,8506,12,8507,8512,5,8513,8516,1,8522,8525,1,8527,8586,59,8587,8592,5,8593,8967,1,8972,9e3,1,9003,9257,1,9280,9290,1,9372,9449,1,9472,10087,1,10132,10180,1,10183,10213,1,10224,10626,1,10649,10711,1,10716,10747,1,10750,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12443,12444,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,42752,42774,1,42784,42785,1,42889,42890,1,43048,43051,1,43062,43065,1,43639,43641,1,43867,43882,15,43883,64297,20414,64434,64450,1,64832,64847,1,64975,65020,45,65021,65023,1,65122,65124,2,65125,65126,1,65129,65284,155,65291,65308,17,65309,65310,1,65342,65344,2,65372,65374,2,65504,65510,1,65512,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,69006,710,69007,71487,2480,73685,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,123647,432,126124,126128,4,126254,126704,450,126705,126976,271,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Sc=new F(new Uint32Array([36,162,126,163,165,1,1423,1547,124,2046,2047,1,2546,2547,1,2555,2801,246,3065,3647,582,6107,8352,2245,8353,8384,1,43064,65020,21956,65129,65284,155,65504,65505,1,65509,65510,1,73693,73696,1,123647,126128,2481]));static Sk=new F(new Uint32Array([94,96,2,168,175,7,180,184,4,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,2184,1283,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,12443,12444,1,42752,42774,1,42784,42785,1,42889,42890,1,43867,43882,15,43883,64434,20551,64435,64450,1,65342,65344,2,65507,127995,62488,127996,127999,1]));static Sm=new F(new Uint32Array([43,60,17,61,62,1,124,126,2,172,177,5,215,247,32,1014,1542,528,1543,1544,1,8260,8274,14,8314,8316,1,8330,8332,1,8472,8512,40,8513,8516,1,8523,8592,69,8593,8596,1,8602,8603,1,8608,8614,3,8622,8654,32,8655,8658,3,8660,8692,32,8693,8959,1,8992,8993,1,9084,9115,31,9116,9139,1,9180,9185,1,9655,9665,10,9720,9727,1,9839,10176,337,10177,10180,1,10183,10213,1,10224,10239,1,10496,10626,1,10649,10711,1,10716,10747,1,10750,11007,1,11056,11076,1,11079,11084,1,64297,65122,825,65124,65126,1,65291,65308,17,65309,65310,1,65372,65374,2,65506,65513,7,65514,65516,1,69006,69007,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,126704,126705,1]));static So=new F(new Uint32Array([166,169,3,174,176,2,1154,1421,267,1422,1550,128,1551,1758,207,1769,1789,20,1790,2038,248,2554,2928,374,3059,3064,1,3066,3199,133,3407,3449,42,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6464,723,6622,6655,1,7009,7018,1,7028,7036,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8478,7,8479,8483,1,8485,8489,2,8494,8506,12,8507,8522,15,8524,8525,1,8527,8586,59,8587,8597,10,8598,8601,1,8604,8607,1,8609,8610,1,8612,8613,1,8615,8621,1,8623,8653,1,8656,8657,1,8659,8661,2,8662,8691,1,8960,8967,1,8972,8991,1,8994,9e3,1,9003,9083,1,9085,9114,1,9140,9179,1,9186,9257,1,9280,9290,1,9372,9449,1,9472,9654,1,9656,9664,1,9666,9719,1,9728,9838,1,9840,10087,1,10132,10175,1,10240,10495,1,11008,11055,1,11077,11078,1,11085,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,43048,43051,1,43062,43063,1,43065,43639,574,43640,43641,1,64832,64847,1,64975,65021,46,65022,65023,1,65508,65512,4,65517,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,71487,3191,73685,73692,1,73697,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,126124,2909,126254,126976,722,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,127994,1,128e3,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Z=new F(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8232,8233,1,8239,8287,48,12288,12288,1]));static Zl=new F(new Uint32Array([8232,8232,1]));static Zp=new F(new Uint32Array([8233,8233,1]));static Zs=new F(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8239,8287,48,12288,12288,1]));static Adlam=new F(new Uint32Array([125184,125259,1,125264,125273,1,125278,125279,1]));static Ahom=new F(new Uint32Array([71424,71450,1,71453,71467,1,71472,71494,1]));static Anatolian_Hieroglyphs=new F(new Uint32Array([82944,83526,1]));static Arabic=new F(new Uint32Array([1536,1540,1,1542,1547,1,1549,1562,1,1564,1566,1,1568,1599,1,1601,1610,1,1622,1647,1,1649,1756,1,1758,1791,1,1872,1919,1,2160,2190,1,2192,2193,1,2199,2273,1,2275,2303,1,64336,64450,1,64467,64829,1,64832,64911,1,64914,64967,1,64975,65008,33,65009,65023,1,65136,65140,1,65142,65276,1,69216,69246,1,69314,69316,1,69372,69375,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1]));static Armenian=new F(new Uint32Array([1329,1366,1,1369,1418,1,1421,1423,1,64275,64279,1]));static Avestan=new F(new Uint32Array([68352,68405,1,68409,68415,1]));static Balinese=new F(new Uint32Array([6912,6988,1,6990,7039,1]));static Bamum=new F(new Uint32Array([42656,42743,1,92160,92728,1]));static Bassa_Vah=new F(new Uint32Array([92880,92909,1,92912,92917,1]));static Batak=new F(new Uint32Array([7104,7155,1,7164,7167,1]));static Bengali=new F(new Uint32Array([2432,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1]));static Bhaiksuki=new F(new Uint32Array([72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1]));static Bopomofo=new F(new Uint32Array([746,747,1,12549,12591,1,12704,12735,1]));static Brahmi=new F(new Uint32Array([69632,69709,1,69714,69749,1,69759,69759,1]));static Braille=new F(new Uint32Array([10240,10495,1]));static Buginese=new F(new Uint32Array([6656,6683,1,6686,6687,1]));static Buhid=new F(new Uint32Array([5952,5971,1]));static Canadian_Aboriginal=new F(new Uint32Array([5120,5759,1,6320,6389,1,72368,72383,1]));static Carian=new F(new Uint32Array([66208,66256,1]));static Caucasian_Albanian=new F(new Uint32Array([66864,66915,1,66927,66927,1]));static Chakma=new F(new Uint32Array([69888,69940,1,69942,69959,1]));static Cham=new F(new Uint32Array([43520,43574,1,43584,43597,1,43600,43609,1,43612,43615,1]));static Cherokee=new F(new Uint32Array([5024,5109,1,5112,5117,1,43888,43967,1]));static Chorasmian=new F(new Uint32Array([69552,69579,1]));static Common=new F(new Uint32Array([0,64,1,91,96,1,123,169,1,171,185,1,187,191,1,215,247,32,697,735,1,741,745,1,748,767,1,884,894,10,901,903,2,1541,1548,7,1563,1567,4,1600,1757,157,2274,2404,130,2405,3647,1242,4053,4056,1,4347,5867,1520,5868,5869,1,5941,5942,1,6146,6147,1,6149,7379,1230,7393,7401,8,7402,7404,1,7406,7411,1,7413,7415,1,7418,8192,774,8193,8203,1,8206,8292,1,8294,8304,1,8308,8318,1,8320,8334,1,8352,8384,1,8448,8485,1,8487,8489,1,8492,8497,1,8499,8525,1,8527,8543,1,8585,8587,1,8592,9257,1,9280,9290,1,9312,10239,1,10496,11123,1,11126,11157,1,11159,11263,1,11776,11869,1,12272,12292,1,12294,12296,2,12297,12320,1,12336,12343,1,12348,12351,1,12443,12444,1,12448,12539,91,12540,12688,148,12689,12703,1,12736,12773,1,12783,12832,49,12833,12895,1,12927,13007,1,13055,13144,89,13145,13311,1,19904,19967,1,42752,42785,1,42888,42890,1,43056,43065,1,43310,43471,161,43867,43882,15,43883,64830,20947,64831,65040,209,65041,65049,1,65072,65106,1,65108,65126,1,65128,65131,1,65279,65281,2,65282,65312,1,65339,65344,1,65371,65381,1,65392,65438,46,65439,65504,65,65505,65510,1,65512,65518,1,65529,65533,1,65792,65794,1,65799,65843,1,65847,65855,1,65936,65948,1,66e3,66044,1,66273,66299,1,113824,113827,1,117760,118009,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119142,1,119146,119162,1,119171,119172,1,119180,119209,1,119214,119274,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,120831,1,126065,126132,1,126209,126269,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127487,1,127489,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,917505,917536,31,917537,917631,1]));static foldCommon=new F(new Uint32Array([924,956,32]));static Coptic=new F(new Uint32Array([994,1007,1,11392,11507,1,11513,11519,1]));static Cuneiform=new F(new Uint32Array([73728,74649,1,74752,74862,1,74864,74868,1,74880,75075,1]));static Cypriot=new F(new Uint32Array([67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3]));static Cypro_Minoan=new F(new Uint32Array([77712,77810,1]));static Cyrillic=new F(new Uint32Array([1024,1156,1,1159,1327,1,7296,7306,1,7467,7544,77,11744,11775,1,42560,42655,1,65070,65071,1,122928,122989,1,123023,123023,1]));static Deseret=new F(new Uint32Array([66560,66639,1]));static Devanagari=new F(new Uint32Array([2304,2384,1,2389,2403,1,2406,2431,1,43232,43263,1,72448,72457,1]));static Dives_Akuru=new F(new Uint32Array([71936,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1]));static Dogra=new F(new Uint32Array([71680,71739,1]));static Duployan=new F(new Uint32Array([113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1]));static Egyptian_Hieroglyphs=new F(new Uint32Array([77824,78933,1,78944,82938,1]));static Elbasan=new F(new Uint32Array([66816,66855,1]));static Elymaic=new F(new Uint32Array([69600,69622,1]));static Ethiopic=new F(new Uint32Array([4608,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,124896,124902,1,124904,124907,1,124909,124910,1,124912,124926,1]));static Garay=new F(new Uint32Array([68928,68965,1,68969,68997,1,69006,69007,1]));static Georgian=new F(new Uint32Array([4256,4293,1,4295,4301,6,4304,4346,1,4348,4351,1,7312,7354,1,7357,7359,1,11520,11557,1,11559,11565,6]));static Glagolitic=new F(new Uint32Array([11264,11359,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1]));static Gothic=new F(new Uint32Array([66352,66378,1]));static Grantha=new F(new Uint32Array([70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70460,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1]));static Greek=new F(new Uint32Array([880,883,1,885,887,1,890,893,1,895,900,5,902,904,2,905,906,1,908,910,2,911,929,1,931,993,1,1008,1023,1,7462,7466,1,7517,7521,1,7526,7530,1,7615,7936,321,7937,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8486,43877,35391,65856,65934,1,65952,119296,53344,119297,119365,1]));static foldGreek=new F(new Uint32Array([181,837,656]));static Gujarati=new F(new Uint32Array([2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1]));static Gunjala_Gondi=new F(new Uint32Array([73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1]));static Gurmukhi=new F(new Uint32Array([2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1]));static Gurung_Khema=new F(new Uint32Array([90368,90425,1]));static Han=new F(new Uint32Array([11904,11929,1,11931,12019,1,12032,12245,1,12293,12295,2,12321,12329,1,12344,12347,1,13312,19903,1,19968,40959,1,63744,64109,1,64112,64217,1,94178,94179,1,94192,94193,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Hangul=new F(new Uint32Array([4352,4607,1,12334,12335,1,12593,12686,1,12800,12830,1,12896,12926,1,43360,43388,1,44032,55203,1,55216,55238,1,55243,55291,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1]));static Hanifi_Rohingya=new F(new Uint32Array([68864,68903,1,68912,68921,1]));static Hanunoo=new F(new Uint32Array([5920,5940,1]));static Hatran=new F(new Uint32Array([67808,67826,1,67828,67829,1,67835,67839,1]));static Hebrew=new F(new Uint32Array([1425,1479,1,1488,1514,1,1519,1524,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64335,1]));static Hiragana=new F(new Uint32Array([12353,12438,1,12445,12447,1,110593,110879,1,110898,110928,30,110929,110930,1,127488,127488,1]));static Imperial_Aramaic=new F(new Uint32Array([67648,67669,1,67671,67679,1]));static Inherited=new F(new Uint32Array([768,879,1,1157,1158,1,1611,1621,1,1648,2385,737,2386,2388,1,6832,6862,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8204,8205,1,8400,8432,1,12330,12333,1,12441,12442,1,65024,65039,1,65056,65069,1,66045,66272,227,70459,118528,48069,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,917760,917999,1]));static foldInherited=new F(new Uint32Array([921,953,32,8126,8126,1]));static Inscriptional_Pahlavi=new F(new Uint32Array([68448,68466,1,68472,68479,1]));static Inscriptional_Parthian=new F(new Uint32Array([68416,68437,1,68440,68447,1]));static Javanese=new F(new Uint32Array([43392,43469,1,43472,43481,1,43486,43487,1]));static Kaithi=new F(new Uint32Array([69760,69826,1,69837,69837,1]));static Kannada=new F(new Uint32Array([3200,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1]));static Katakana=new F(new Uint32Array([12449,12538,1,12541,12543,1,12784,12799,1,13008,13054,1,13056,13143,1,65382,65391,1,65393,65437,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110880,288,110881,110882,1,110933,110948,15,110949,110951,1]));static Kawi=new F(new Uint32Array([73472,73488,1,73490,73530,1,73534,73562,1]));static Kayah_Li=new F(new Uint32Array([43264,43309,1,43311,43311,1]));static Kharoshthi=new F(new Uint32Array([68096,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1]));static Khitan_Small_Script=new F(new Uint32Array([94180,101120,6940,101121,101589,1,101631,101631,1]));static Khmer=new F(new Uint32Array([6016,6109,1,6112,6121,1,6128,6137,1,6624,6655,1]));static Khojki=new F(new Uint32Array([70144,70161,1,70163,70209,1]));static Khudawadi=new F(new Uint32Array([70320,70378,1,70384,70393,1]));static Kirat_Rai=new F(new Uint32Array([93504,93561,1]));static Lao=new F(new Uint32Array([3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1]));static Latin=new F(new Uint32Array([65,90,1,97,122,1,170,186,16,192,214,1,216,246,1,248,696,1,736,740,1,7424,7461,1,7468,7516,1,7522,7525,1,7531,7543,1,7545,7614,1,7680,7935,1,8305,8319,14,8336,8348,1,8490,8491,1,8498,8526,28,8544,8584,1,11360,11391,1,42786,42887,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43007,1,43824,43866,1,43868,43876,1,43878,43881,1,64256,64262,1,65313,65338,1,65345,65370,1,67456,67461,1,67463,67504,1,67506,67514,1,122624,122654,1,122661,122666,1]));static Lepcha=new F(new Uint32Array([7168,7223,1,7227,7241,1,7245,7247,1]));static Limbu=new F(new Uint32Array([6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6479,1]));static Linear_A=new F(new Uint32Array([67072,67382,1,67392,67413,1,67424,67431,1]));static Linear_B=new F(new Uint32Array([65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1]));static Lisu=new F(new Uint32Array([42192,42239,1,73648,73648,1]));static Lycian=new F(new Uint32Array([66176,66204,1]));static Lydian=new F(new Uint32Array([67872,67897,1,67903,67903,1]));static Mahajani=new F(new Uint32Array([69968,70006,1]));static Makasar=new F(new Uint32Array([73440,73464,1]));static Malayalam=new F(new Uint32Array([3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1]));static Mandaic=new F(new Uint32Array([2112,2139,1,2142,2142,1]));static Manichaean=new F(new Uint32Array([68288,68326,1,68331,68342,1]));static Marchen=new F(new Uint32Array([72816,72847,1,72850,72871,1,72873,72886,1]));static Masaram_Gondi=new F(new Uint32Array([72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1]));static Medefaidrin=new F(new Uint32Array([93760,93850,1]));static Meetei_Mayek=new F(new Uint32Array([43744,43766,1,43968,44013,1,44016,44025,1]));static Mende_Kikakui=new F(new Uint32Array([124928,125124,1,125127,125142,1]));static Meroitic_Cursive=new F(new Uint32Array([68e3,68023,1,68028,68047,1,68050,68095,1]));static Meroitic_Hieroglyphs=new F(new Uint32Array([67968,67999,1]));static Miao=new F(new Uint32Array([93952,94026,1,94031,94087,1,94095,94111,1]));static Modi=new F(new Uint32Array([71168,71236,1,71248,71257,1]));static Mongolian=new F(new Uint32Array([6144,6145,1,6148,6150,2,6151,6169,1,6176,6264,1,6272,6314,1,71264,71276,1]));static Mro=new F(new Uint32Array([92736,92766,1,92768,92777,1,92782,92783,1]));static Multani=new F(new Uint32Array([70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1]));static Myanmar=new F(new Uint32Array([4096,4255,1,43488,43518,1,43616,43647,1,71376,71395,1]));static Nabataean=new F(new Uint32Array([67712,67742,1,67751,67759,1]));static Nag_Mundari=new F(new Uint32Array([124112,124153,1]));static Nandinagari=new F(new Uint32Array([72096,72103,1,72106,72151,1,72154,72164,1]));static New_Tai_Lue=new F(new Uint32Array([6528,6571,1,6576,6601,1,6608,6618,1,6622,6623,1]));static Newa=new F(new Uint32Array([70656,70747,1,70749,70753,1]));static Nko=new F(new Uint32Array([1984,2042,1,2045,2047,1]));static Nushu=new F(new Uint32Array([94177,110960,16783,110961,111355,1]));static Nyiakeng_Puachue_Hmong=new F(new Uint32Array([123136,123180,1,123184,123197,1,123200,123209,1,123214,123215,1]));static Ogham=new F(new Uint32Array([5760,5788,1]));static Ol_Chiki=new F(new Uint32Array([7248,7295,1]));static Ol_Onal=new F(new Uint32Array([124368,124410,1,124415,124415,1]));static Old_Hungarian=new F(new Uint32Array([68736,68786,1,68800,68850,1,68858,68863,1]));static Old_Italic=new F(new Uint32Array([66304,66339,1,66349,66351,1]));static Old_North_Arabian=new F(new Uint32Array([68224,68255,1]));static Old_Permic=new F(new Uint32Array([66384,66426,1]));static Old_Persian=new F(new Uint32Array([66464,66499,1,66504,66517,1]));static Old_Sogdian=new F(new Uint32Array([69376,69415,1]));static Old_South_Arabian=new F(new Uint32Array([68192,68223,1]));static Old_Turkic=new F(new Uint32Array([68608,68680,1]));static Old_Uyghur=new F(new Uint32Array([69488,69513,1]));static Oriya=new F(new Uint32Array([2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1]));static Osage=new F(new Uint32Array([66736,66771,1,66776,66811,1]));static Osmanya=new F(new Uint32Array([66688,66717,1,66720,66729,1]));static Pahawh_Hmong=new F(new Uint32Array([92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1]));static Palmyrene=new F(new Uint32Array([67680,67711,1]));static Pau_Cin_Hau=new F(new Uint32Array([72384,72440,1]));static Phags_Pa=new F(new Uint32Array([43072,43127,1]));static Phoenician=new F(new Uint32Array([67840,67867,1,67871,67871,1]));static Psalter_Pahlavi=new F(new Uint32Array([68480,68497,1,68505,68508,1,68521,68527,1]));static Rejang=new F(new Uint32Array([43312,43347,1,43359,43359,1]));static Runic=new F(new Uint32Array([5792,5866,1,5870,5880,1]));static Samaritan=new F(new Uint32Array([2048,2093,1,2096,2110,1]));static Saurashtra=new F(new Uint32Array([43136,43205,1,43214,43225,1]));static Sharada=new F(new Uint32Array([70016,70111,1]));static Shavian=new F(new Uint32Array([66640,66687,1]));static Siddham=new F(new Uint32Array([71040,71093,1,71096,71133,1]));static SignWriting=new F(new Uint32Array([120832,121483,1,121499,121503,1,121505,121519,1]));static Sinhala=new F(new Uint32Array([3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,70113,70132,1]));static Sogdian=new F(new Uint32Array([69424,69465,1]));static Sora_Sompeng=new F(new Uint32Array([69840,69864,1,69872,69881,1]));static Soyombo=new F(new Uint32Array([72272,72354,1]));static Sundanese=new F(new Uint32Array([7040,7103,1,7360,7367,1]));static Sunuwar=new F(new Uint32Array([72640,72673,1,72688,72697,1]));static Syloti_Nagri=new F(new Uint32Array([43008,43052,1]));static Syriac=new F(new Uint32Array([1792,1805,1,1807,1866,1,1869,1871,1,2144,2154,1]));static Tagalog=new F(new Uint32Array([5888,5909,1,5919,5919,1]));static Tagbanwa=new F(new Uint32Array([5984,5996,1,5998,6e3,1,6002,6003,1]));static Tai_Le=new F(new Uint32Array([6480,6509,1,6512,6516,1]));static Tai_Tham=new F(new Uint32Array([6688,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1]));static Tai_Viet=new F(new Uint32Array([43648,43714,1,43739,43743,1]));static Takri=new F(new Uint32Array([71296,71353,1,71360,71369,1]));static Tamil=new F(new Uint32Array([2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,73664,73713,1,73727,73727,1]));static Tangsa=new F(new Uint32Array([92784,92862,1,92864,92873,1]));static Tangut=new F(new Uint32Array([94176,94208,32,94209,100343,1,100352,101119,1,101632,101640,1]));static Telugu=new F(new Uint32Array([3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3199,1]));static Thaana=new F(new Uint32Array([1920,1969,1]));static Thai=new F(new Uint32Array([3585,3642,1,3648,3675,1]));static Tibetan=new F(new Uint32Array([3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4052,1,4057,4058,1]));static Tifinagh=new F(new Uint32Array([11568,11623,1,11631,11632,1,11647,11647,1]));static Tirhuta=new F(new Uint32Array([70784,70855,1,70864,70873,1]));static Todhri=new F(new Uint32Array([67008,67059,1]));static Toto=new F(new Uint32Array([123536,123566,1]));static Tulu_Tigalari=new F(new Uint32Array([70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1]));static Ugaritic=new F(new Uint32Array([66432,66461,1,66463,66463,1]));static Vai=new F(new Uint32Array([42240,42539,1]));static Vithkuqi=new F(new Uint32Array([66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1]));static Wancho=new F(new Uint32Array([123584,123641,1,123647,123647,1]));static Warang_Citi=new F(new Uint32Array([71840,71922,1,71935,71935,1]));static Yezidi=new F(new Uint32Array([69248,69289,1,69291,69293,1,69296,69297,1]));static Yi=new F(new Uint32Array([40960,42124,1,42128,42182,1]));static Zanabazar_Square=new F(new Uint32Array([72192,72263,1]));static CATEGORIES=new Map([["C",t.C],["Cc",t.Cc],["Cf",t.Cf],["Co",t.Co],["Cs",t.Cs],["L",t.L],["Ll",t.Ll],["Lm",t.Lm],["Lo",t.Lo],["Lt",t.Lt],["Lu",t.Lu],["M",t.M],["Mc",t.Mc],["Me",t.Me],["Mn",t.Mn],["N",t.N],["Nd",t.Nd],["Nl",t.Nl],["No",t.No],["P",t.P],["Pc",t.Pc],["Pd",t.Pd],["Pe",t.Pe],["Pf",t.Pf],["Pi",t.Pi],["Po",t.Po],["Ps",t.Ps],["S",t.S],["Sc",t.Sc],["Sk",t.Sk],["Sm",t.Sm],["So",t.So],["Z",t.Z],["Zl",t.Zl],["Zp",t.Zp],["Zs",t.Zs]]);static SCRIPTS=new Map([["Adlam",t.Adlam],["Ahom",t.Ahom],["Anatolian_Hieroglyphs",t.Anatolian_Hieroglyphs],["Arabic",t.Arabic],["Armenian",t.Armenian],["Avestan",t.Avestan],["Balinese",t.Balinese],["Bamum",t.Bamum],["Bassa_Vah",t.Bassa_Vah],["Batak",t.Batak],["Bengali",t.Bengali],["Bhaiksuki",t.Bhaiksuki],["Bopomofo",t.Bopomofo],["Brahmi",t.Brahmi],["Braille",t.Braille],["Buginese",t.Buginese],["Buhid",t.Buhid],["Canadian_Aboriginal",t.Canadian_Aboriginal],["Carian",t.Carian],["Caucasian_Albanian",t.Caucasian_Albanian],["Chakma",t.Chakma],["Cham",t.Cham],["Cherokee",t.Cherokee],["Chorasmian",t.Chorasmian],["Common",t.Common],["Coptic",t.Coptic],["Cuneiform",t.Cuneiform],["Cypriot",t.Cypriot],["Cypro_Minoan",t.Cypro_Minoan],["Cyrillic",t.Cyrillic],["Deseret",t.Deseret],["Devanagari",t.Devanagari],["Dives_Akuru",t.Dives_Akuru],["Dogra",t.Dogra],["Duployan",t.Duployan],["Egyptian_Hieroglyphs",t.Egyptian_Hieroglyphs],["Elbasan",t.Elbasan],["Elymaic",t.Elymaic],["Ethiopic",t.Ethiopic],["Garay",t.Garay],["Georgian",t.Georgian],["Glagolitic",t.Glagolitic],["Gothic",t.Gothic],["Grantha",t.Grantha],["Greek",t.Greek],["Gujarati",t.Gujarati],["Gunjala_Gondi",t.Gunjala_Gondi],["Gurmukhi",t.Gurmukhi],["Gurung_Khema",t.Gurung_Khema],["Han",t.Han],["Hangul",t.Hangul],["Hanifi_Rohingya",t.Hanifi_Rohingya],["Hanunoo",t.Hanunoo],["Hatran",t.Hatran],["Hebrew",t.Hebrew],["Hiragana",t.Hiragana],["Imperial_Aramaic",t.Imperial_Aramaic],["Inherited",t.Inherited],["Inscriptional_Pahlavi",t.Inscriptional_Pahlavi],["Inscriptional_Parthian",t.Inscriptional_Parthian],["Javanese",t.Javanese],["Kaithi",t.Kaithi],["Kannada",t.Kannada],["Katakana",t.Katakana],["Kawi",t.Kawi],["Kayah_Li",t.Kayah_Li],["Kharoshthi",t.Kharoshthi],["Khitan_Small_Script",t.Khitan_Small_Script],["Khmer",t.Khmer],["Khojki",t.Khojki],["Khudawadi",t.Khudawadi],["Kirat_Rai",t.Kirat_Rai],["Lao",t.Lao],["Latin",t.Latin],["Lepcha",t.Lepcha],["Limbu",t.Limbu],["Linear_A",t.Linear_A],["Linear_B",t.Linear_B],["Lisu",t.Lisu],["Lycian",t.Lycian],["Lydian",t.Lydian],["Mahajani",t.Mahajani],["Makasar",t.Makasar],["Malayalam",t.Malayalam],["Mandaic",t.Mandaic],["Manichaean",t.Manichaean],["Marchen",t.Marchen],["Masaram_Gondi",t.Masaram_Gondi],["Medefaidrin",t.Medefaidrin],["Meetei_Mayek",t.Meetei_Mayek],["Mende_Kikakui",t.Mende_Kikakui],["Meroitic_Cursive",t.Meroitic_Cursive],["Meroitic_Hieroglyphs",t.Meroitic_Hieroglyphs],["Miao",t.Miao],["Modi",t.Modi],["Mongolian",t.Mongolian],["Mro",t.Mro],["Multani",t.Multani],["Myanmar",t.Myanmar],["Nabataean",t.Nabataean],["Nag_Mundari",t.Nag_Mundari],["Nandinagari",t.Nandinagari],["New_Tai_Lue",t.New_Tai_Lue],["Newa",t.Newa],["Nko",t.Nko],["Nushu",t.Nushu],["Nyiakeng_Puachue_Hmong",t.Nyiakeng_Puachue_Hmong],["Ogham",t.Ogham],["Ol_Chiki",t.Ol_Chiki],["Ol_Onal",t.Ol_Onal],["Old_Hungarian",t.Old_Hungarian],["Old_Italic",t.Old_Italic],["Old_North_Arabian",t.Old_North_Arabian],["Old_Permic",t.Old_Permic],["Old_Persian",t.Old_Persian],["Old_Sogdian",t.Old_Sogdian],["Old_South_Arabian",t.Old_South_Arabian],["Old_Turkic",t.Old_Turkic],["Old_Uyghur",t.Old_Uyghur],["Oriya",t.Oriya],["Osage",t.Osage],["Osmanya",t.Osmanya],["Pahawh_Hmong",t.Pahawh_Hmong],["Palmyrene",t.Palmyrene],["Pau_Cin_Hau",t.Pau_Cin_Hau],["Phags_Pa",t.Phags_Pa],["Phoenician",t.Phoenician],["Psalter_Pahlavi",t.Psalter_Pahlavi],["Rejang",t.Rejang],["Runic",t.Runic],["Samaritan",t.Samaritan],["Saurashtra",t.Saurashtra],["Sharada",t.Sharada],["Shavian",t.Shavian],["Siddham",t.Siddham],["SignWriting",t.SignWriting],["Sinhala",t.Sinhala],["Sogdian",t.Sogdian],["Sora_Sompeng",t.Sora_Sompeng],["Soyombo",t.Soyombo],["Sundanese",t.Sundanese],["Sunuwar",t.Sunuwar],["Syloti_Nagri",t.Syloti_Nagri],["Syriac",t.Syriac],["Tagalog",t.Tagalog],["Tagbanwa",t.Tagbanwa],["Tai_Le",t.Tai_Le],["Tai_Tham",t.Tai_Tham],["Tai_Viet",t.Tai_Viet],["Takri",t.Takri],["Tamil",t.Tamil],["Tangsa",t.Tangsa],["Tangut",t.Tangut],["Telugu",t.Telugu],["Thaana",t.Thaana],["Thai",t.Thai],["Tibetan",t.Tibetan],["Tifinagh",t.Tifinagh],["Tirhuta",t.Tirhuta],["Todhri",t.Todhri],["Toto",t.Toto],["Tulu_Tigalari",t.Tulu_Tigalari],["Ugaritic",t.Ugaritic],["Vai",t.Vai],["Vithkuqi",t.Vithkuqi],["Wancho",t.Wancho],["Warang_Citi",t.Warang_Citi],["Yezidi",t.Yezidi],["Yi",t.Yi],["Zanabazar_Square",t.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([["L",t.foldL],["Ll",t.foldLl],["Lt",t.foldLt],["Lu",t.foldLu],["M",t.foldM],["Mn",t.foldMn]]);static FOLD_SCRIPT=new Map([["Common",t.foldCommon],["Greek",t.foldGreek],["Inherited",t.foldInherited]]);static Print=new F(new Uint32Array([33,126,1,161,172,1,174,887,1,890,895,1,900,906,1,908,910,2,911,929,1,931,1327,1,1329,1366,1,1369,1418,1,1421,1423,1,1425,1479,1,1488,1514,1,1519,1524,1,1542,1563,1,1565,1756,1,1758,1805,1,1808,1866,1,1869,1969,1,1984,2042,1,2045,2093,1,2096,2110,1,2112,2139,1,2142,2144,2,2145,2154,1,2160,2190,1,2199,2273,1,2275,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1,2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1,2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1,2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1,2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1,3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1,3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,3585,3642,1,3647,3675,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1,3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4058,1,4096,4293,1,4295,4301,6,4304,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,5024,5109,1,5112,5117,1,5120,5759,1,5761,5788,1,5792,5880,1,5888,5909,1,5919,5942,1,5952,5971,1,5984,5996,1,5998,6e3,1,6002,6003,1,6016,6109,1,6112,6121,1,6128,6137,1,6144,6157,1,6159,6169,1,6176,6264,1,6272,6314,1,6320,6389,1,6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6608,6618,1,6622,6683,1,6686,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1,6832,6862,1,6912,6988,1,6990,7155,1,7164,7223,1,7227,7241,1,7245,7306,1,7312,7354,1,7357,7367,1,7376,7418,1,7424,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8208,8231,1,8240,8286,1,8304,8305,1,8308,8334,1,8336,8348,1,8352,8384,1,8400,8432,1,8448,8587,1,8592,9257,1,9280,9290,1,9312,11123,1,11126,11157,1,11159,11507,1,11513,11557,1,11559,11565,6,11568,11623,1,11631,11632,1,11647,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11744,11869,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12289,12351,1,12353,12438,1,12441,12543,1,12549,12591,1,12593,12686,1,12688,12773,1,12783,12830,1,12832,42124,1,42128,42182,1,42192,42539,1,42560,42743,1,42752,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43052,1,43056,43065,1,43072,43127,1,43136,43205,1,43214,43225,1,43232,43347,1,43359,43388,1,43392,43469,1,43471,43481,1,43486,43518,1,43520,43574,1,43584,43597,1,43600,43609,1,43612,43714,1,43739,43766,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43883,1,43888,44013,1,44016,44025,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64450,1,64467,64911,1,64914,64967,1,64975,65008,33,65009,65049,1,65056,65106,1,65108,65126,1,65128,65131,1,65136,65140,1,65142,65276,1,65281,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65504,65510,1,65512,65518,1,65532,65533,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,65792,65794,1,65799,65843,1,65847,65934,1,65936,65948,1,65952,66e3,48,66001,66045,1,66176,66204,1,66208,66256,1,66272,66299,1,66304,66339,1,66349,66378,1,66384,66426,1,66432,66461,1,66463,66499,1,66504,66517,1,66560,66717,1,66720,66729,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66927,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67671,67742,1,67751,67759,1,67808,67826,1,67828,67829,1,67835,67867,1,67871,67897,1,67903,67968,65,67969,68023,1,68028,68047,1,68050,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1,68192,68255,1,68288,68326,1,68331,68342,1,68352,68405,1,68409,68437,1,68440,68466,1,68472,68497,1,68505,68508,1,68521,68527,1,68608,68680,1,68736,68786,1,68800,68850,1,68858,68903,1,68912,68921,1,68928,68965,1,68969,68997,1,69006,69007,1,69216,69246,1,69248,69289,1,69291,69293,1,69296,69297,1,69314,69316,1,69372,69415,1,69424,69465,1,69488,69513,1,69552,69579,1,69600,69622,1,69632,69709,1,69714,69749,1,69759,69820,1,69822,69826,1,69840,69864,1,69872,69881,1,69888,69940,1,69942,69959,1,69968,70006,1,70016,70111,1,70113,70132,1,70144,70161,1,70163,70209,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1,70320,70378,1,70384,70393,1,70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70459,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1,70656,70747,1,70749,70753,1,70784,70855,1,70864,70873,1,71040,71093,1,71096,71133,1,71168,71236,1,71248,71257,1,71264,71276,1,71296,71353,1,71360,71369,1,71376,71395,1,71424,71450,1,71453,71467,1,71472,71494,1,71680,71739,1,71840,71922,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1,72096,72103,1,72106,72151,1,72154,72164,1,72192,72263,1,72272,72354,1,72368,72440,1,72448,72457,1,72640,72673,1,72688,72697,1,72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1,72816,72847,1,72850,72871,1,72873,72886,1,72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1,73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1,73440,73464,1,73472,73488,1,73490,73530,1,73534,73562,1,73648,73664,16,73665,73713,1,73727,74649,1,74752,74862,1,74864,74868,1,74880,75075,1,77712,77810,1,77824,78895,1,78912,78933,1,78944,82938,1,82944,83526,1,90368,90425,1,92160,92728,1,92736,92766,1,92768,92777,1,92782,92862,1,92864,92873,1,92880,92909,1,92912,92917,1,92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1,93504,93561,1,93760,93850,1,93952,94026,1,94031,94087,1,94095,94111,1,94176,94180,1,94192,94193,1,94208,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1,117760,118009,1,118016,118451,1,118528,118573,1,118576,118598,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119154,1,119163,119274,1,119296,119365,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,121483,1,121499,121503,1,121505,121519,1,122624,122654,1,122661,122666,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,122928,122989,1,123023,123136,113,123137,123180,1,123184,123197,1,123200,123209,1,123214,123215,1,123536,123566,1,123584,123641,1,123647,124112,465,124113,124153,1,124368,124410,1,124415,124896,481,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125127,125142,1,125184,125259,1,125264,125273,1,125278,125279,1,126065,126132,1,126209,126269,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1,917760,917999,1]))},Ce=class{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,n){let r=0,s=e.length;for(;r<s;){let i=r+Math.floor((s-r)/2),o=e.getLo(i),a=e.getHi(i);if(o<=n&&n<=a){let l=e.getStride(i);return(n-o)%l===0}n<o?s=i:r=i+1}return!1}static is(e,n){if(n<=this.MAX_LATIN1){for(let r=0;r<e.length;r++){let s=e.getHi(r);if(n>s)continue;let i=e.getLo(r);if(n<i)return!1;let o=e.getStride(r);return(n-i)%o===0}return!1}return e.length>0&&n>=e.getLo(0)&&this.is32(e,n)}static isUpper(e){if(e<=this.MAX_LATIN1){let n=String.fromCodePoint(e);return n.toUpperCase()===n&&n.toLowerCase()!==n}return this.is(xr.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?e>=32&&e<this.MAX_ASCII||e>=161&&e!==173:this.is(xr.Print,e)}static simpleFold(e){if(xr.CASE_ORBIT.has(e))return xr.CASE_ORBIT.get(e);let n=L.toLowerCase(e);return n!==e?n:L.toUpperCase(e)}static equalsIgnoreCase(e,n){if(e<0||n<0||e===n)return!0;if(e<=this.MAX_ASCII&&n<=this.MAX_ASCII)return L.CODES.get("A")<=e&&e<=L.CODES.get("Z")&&(e|=32),L.CODES.get("A")<=n&&n<=L.CODES.get("Z")&&(n|=32),e===n;for(let r=this.simpleFold(e);r!==e;r=this.simpleFold(r))if(r===n)return!0;return!1}},Ye=class{static METACHARACTERS="\\.+*?()|[]{}^$";static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return L.CODES.get("0")<=e&&e<=L.CODES.get("9")||L.CODES.get("a")<=e&&e<=L.CODES.get("z")||L.CODES.get("A")<=e&&e<=L.CODES.get("Z")}static unhex(e){return L.CODES.get("0")<=e&&e<=L.CODES.get("9")?e-L.CODES.get("0"):L.CODES.get("a")<=e&&e<=L.CODES.get("f")?e-L.CODES.get("a")+10:L.CODES.get("A")<=e&&e<=L.CODES.get("F")?e-L.CODES.get("A")+10:-1}static escapeRune(e){let n="";if(Ce.isPrint(e))this.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(n+="\\"),n+=String.fromCodePoint(e);else switch(e){case L.CODES.get('"'):n+='\\"';break;case L.CODES.get("\\"):n+="\\\\";break;case L.CODES.get(" "):n+="\\t";break;case L.CODES.get(`
164
164
  `):n+="\\n";break;case L.CODES.get("\r"):n+="\\r";break;case L.CODES.get("\b"):n+="\\b";break;case L.CODES.get("\f"):n+="\\f";break;default:{let r=e.toString(16);e<256?(n+="\\x",r.length===1&&(n+="0"),n+=r):n+=`\\x{${r}}`;break}}return n}static stringToRunes(e){return String(e).split("").map(n=>n.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return L.CODES.get("a")<=e&&e<=L.CODES.get("z")||L.CODES.get("A")<=e&&e<=L.CODES.get("Z")||L.CODES.get("0")<=e&&e<=L.CODES.get("9")||e===L.CODES.get("_")}static emptyOpContext(e,n){let r=0;return e<0&&(r|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===L.CODES.get(`
165
165
  `)&&(r|=this.EMPTY_BEGIN_LINE),n<0&&(r|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),n===L.CODES.get(`
166
- `)&&(r|=this.EMPTY_END_LINE),this.isWordRune(e)!==this.isWordRune(n)?r|=this.EMPTY_WORD_BOUNDARY:r|=this.EMPTY_NO_WORD_BOUNDARY,r}static quoteMeta(e){return e.split("").map(n=>this.METACHARACTERS.indexOf(n)>=0?`\\${n}`:n).join("")}static charCount(e){return e>Ce.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let n=[],r=0;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);i<128?n[r++]=i:i<2048?(n[r++]=i>>6|192,n[r++]=i&63|128):(i&64512)===55296&&s+1<e.length&&(e.charCodeAt(s+1)&64512)===56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++s)&1023),n[r++]=i>>18|240,n[r++]=i>>12&63|128,n[r++]=i>>6&63|128,n[r++]=i&63|128):(n[r++]=i>>12|224,n[r++]=i>>6&63|128,n[r++]=i&63|128)}return n}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder("utf-8").decode(new Uint8Array(e));{let n=[],r=0,s=0;for(;r<e.length;){let i=e[r++];if(i<128)n[s++]=String.fromCharCode(i);else if(i>191&&i<224){let o=e[r++];n[s++]=String.fromCharCode((i&31)<<6|o&63)}else if(i>239&&i<365){let o=e[r++],a=e[r++],l=e[r++],c=((i&7)<<18|(o&63)<<12|(a&63)<<6|l&63)-65536;n[s++]=String.fromCharCode(55296+(c>>10)),n[s++]=String.fromCharCode(56320+(c&1023))}else{let o=e[r++],a=e[r++];n[s++]=String.fromCharCode((i&15)<<12|(o&63)<<6|a&63)}}return n.join("")}}},i7=(t=[],e=0)=>{let n={};for(let r=0;r<t.length;r++){let s=t[r],i=e+r;n[s]=i,n[i]=s}return Object.freeze(n)},Gs=class t{static Encoding=i7(["UTF_16","UTF_8"]);getEncoding(){throw Error("not implemented")}isUTF8Encoding(){return this.getEncoding()===t.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===t.Encoding.UTF_16}},Nc=class extends Gs{constructor(e=null){super(),this.bytes=e}getEncoding(){return Gs.Encoding.UTF_8}asCharSequence(){return Ye.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},np=class extends Gs{constructor(e=null){super(),this.charSequence=e}getEncoding(){return Gs.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split("").map(e=>e.codePointAt(0))}length(){return this.charSequence.length}},So=class{static utf16(e){return new np(e)}static utf8(e){return Array.isArray(e)?new Nc(e):new Nc(Ye.stringToUtf8ByteArray(e))}},us=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},rp=class extends us{constructor(e,n=0,r=e.length){super(),this.bytes=e,this.start=n,this.end=r}step(e){if(e+=this.start,e>=this.end)return us.EOF();let n=this.bytes[e++]&255;return(n&128)===0?n<<3|1:(n&224)===192?(n=n&31,e>=this.end?us.EOF():(n=n<<6|this.bytes[e++]&63,n<<3|2)):(n&240)===224?(n=n&15,e+1>=this.end?us.EOF():(n=n<<6|this.bytes[e++]&63,n=n<<6|this.bytes[e++]&63,n<<3|3)):(n=n&7,e+2>=this.end?us.EOF():(n=n<<6|this.bytes[e++]&63,n=n<<6|this.bytes[e++]&63,n=n<<6|this.bytes[e++]&63,n<<3|4))}index(e,n){n+=this.start;let r=this.indexOf(this.bytes,e.prefixUTF8,n);return r<0?r:r-n}context(e){e+=this.start;let n=-1;if(e>this.start&&e<=this.end){let s=e-1;if(n=this.bytes[s--],n>=128){let i=e-4;for(i<this.start&&(i=this.start);s>=i&&(this.bytes[s]&192)===128;)s--;s<this.start&&(s=this.start),n=this.step(s)>>3}}let r=e<this.end?this.step(e)>>3:-1;return Ye.emptyOpContext(n,r)}indexOf(e,n,r=0){let s=n.length;if(s===0)return-1;let i=e.length;for(let o=r;o<=i-s;o++)for(let a=0;a<s&&e[o+a]===n[a];a++)if(a===s-1)return o;return-1}},sp=class extends us{constructor(e,n=0,r=e.length){super(),this.charSequence=e,this.start=n,this.end=r}step(e){if(e+=this.start,e<this.end){let n=this.charSequence.codePointAt(e);return n<<3|Ye.charCount(n)}else return us.EOF()}index(e,n){n+=this.start;let r=this.charSequence.indexOf(e.prefix,n);return r<0?r:r-n}context(e){e+=this.start;let n=e>0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,r=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return Ye.emptyOpContext(n,r)}},Tt=class{static fromUTF8(e,n=0,r=e.length){return new rp(e,n,r)}static fromUTF16(e,n=0,r=e.length){return new sp(e,n,r)}},Ao=class extends Error{constructor(e){super(e),this.name="RE2JSException"}},wt=class extends Ao{constructor(e,n=null){let r=`error parsing regexp: ${e}`;n&&(r+=`: \`${n}\``),super(r),this.name="RE2JSSyntaxException",this.message=r,this.error=e,this.input=n}getDescription(){return this.error}getPattern(){return this.input}},ip=class extends Ao{constructor(e){super(e),this.name="RE2JSCompileException"}},Br=class extends Ao{constructor(e){super(e),this.name="RE2JSGroupException"}},op=class extends Ao{constructor(e){super(e),this.name="RE2JSFlagsException"}},Tc=class{static quoteReplacement(e,n=!1){return n?e.indexOf("\\")<0&&e.indexOf("$")<0?e:e.split("").map(r=>{let s=r.codePointAt(0);return s===L.CODES.get("\\")||s===L.CODES.get("$")?`\\${r}`:r}).join(""):e.indexOf("$")<0?e:e.split("").map(r=>r.codePointAt(0)===L.CODES.get("$")?"$$":r).join("")}constructor(e,n){if(e===null)throw new Error("pattern is null");this.patternInput=e;let r=this.patternInput.re2();this.patternGroupCount=r.numberOfCapturingGroups(),this.groups=[],this.namedGroups=r.namedGroups,this.numberOfInstructions=r.numberOfInstructions(),n instanceof Gs?this.resetMatcherInput(n):Array.isArray(n)?this.resetMatcherInput(So.utf8(n)):this.resetMatcherInput(So.utf16(n))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw new Error("input is null");return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e=="string"){let n=this.namedGroups[e];if(!Number.isFinite(n))throw new Br(`group '${e}' not found`);e=n}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e=="string"){let n=this.namedGroups[e];if(!Number.isFinite(n))throw new Br(`group '${e}' not found`);e=n}return this.loadGroup(e),this.groups[2*e+1]}programSize(){return this.numberOfInstructions}group(e=0){if(typeof e=="string"){let s=this.namedGroups[e];if(!Number.isFinite(s))throw new Br(`group '${e}' not found`);e=s}let n=this.start(e),r=this.end(e);return n<0&&r<0?null:this.substring(n,r)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new Br(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new Br("perhaps no match attempted");if(e===0||this.hasGroups)return;let n=this.groups[1]+1;n>this.matcherInputLength&&(n=this.matcherInputLength);let r=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],n,this.anchorFlag,1+this.patternGroupCount);if(!r[0])throw new Br("inconsistency in matching group data");this.groups=r[1],this.hasGroups=!0}matches(){return this.genMatch(0,J.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,J.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new Br(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,J.UNANCHORED)}genMatch(e,n){let r=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,n,1);return r[0]?(this.groups=r[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=n,!0):!1}substring(e,n){return this.matcherInput.isUTF8Encoding()?Ye.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,n)):this.matcherInput.asCharSequence().substring(e,n).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,n=!1){let r="",s=this.start(),i=this.end();return this.appendPos<s&&(r+=this.substring(this.appendPos,s)),this.appendPos=i,r+=n?this.appendReplacementInternalJava(e):this.appendReplacementInternalJs(e),r}appendReplacementInternalJava(e){let n="",r=0,s=e.length;for(let i=0;i<s-1;i++){if(e.codePointAt(i)===L.CODES.get("\\")){r<i&&(n+=e.substring(r,i)),i++,r=i;continue}if(e.codePointAt(i)===L.CODES.get("$")){let o=e.codePointAt(i+1);if(L.CODES.get("0")<=o&&o<=L.CODES.get("9")){let a=o-L.CODES.get("0");for(r<i&&(n+=e.substring(r,i)),i+=2;i<s&&(o=e.codePointAt(i),!(o<L.CODES.get("0")||o>L.CODES.get("9")||a*10+o-L.CODES.get("0")>this.patternGroupCount));i++)a=a*10+o-L.CODES.get("0");if(a>this.patternGroupCount)throw new Br(`n > number of groups: ${a}`);let l=this.group(a);l!==null&&(n+=l),r=i,i--;continue}else if(o===L.CODES.get("{")){r<i&&(n+=e.substring(r,i)),i++;let a=i+1;for(;a<e.length&&e.codePointAt(a)!==L.CODES.get("}")&&e.codePointAt(a)!==L.CODES.get(" ");)a++;if(a===e.length||e.codePointAt(a)!==L.CODES.get("}"))throw new Br("named capture group is missing trailing '}'");let l=e.substring(i+1,a);n+=this.group(l),r=a+1}}}return r<s&&(n+=e.substring(r,s)),n}appendReplacementInternalJs(e){let n="",r=0,s=e.length;for(let i=0;i<s-1;i++)if(e.codePointAt(i)===L.CODES.get("$")){let o=e.codePointAt(i+1);if(L.CODES.get("$")===o){r<i&&(n+=e.substring(r,i)),n+="$",i++,r=i+1;continue}else if(L.CODES.get("&")===o){r<i&&(n+=e.substring(r,i));let a=this.group(0);a!==null?n+=a:n+="$&",i++,r=i+1;continue}else if(L.CODES.get("1")<=o&&o<=L.CODES.get("9")){let a=o-L.CODES.get("0");for(r<i&&(n+=e.substring(r,i)),i+=2;i<s&&(o=e.codePointAt(i),!(o<L.CODES.get("0")||o>L.CODES.get("9")||a*10+o-L.CODES.get("0")>this.patternGroupCount));i++)a=a*10+o-L.CODES.get("0");if(a>this.patternGroupCount){n+=`$${a}`,r=i,i--;continue}let l=this.group(a);l!==null&&(n+=l),r=i,i--;continue}else if(o===L.CODES.get("<")){r<i&&(n+=e.substring(r,i)),i++;let a=i+1;for(;a<e.length&&e.codePointAt(a)!==L.CODES.get(">")&&e.codePointAt(a)!==L.CODES.get(" ");)a++;if(a===e.length||e.codePointAt(a)!==L.CODES.get(">")){n+=e.substring(i-1,a+1),r=a+1;continue}let l=e.substring(i+1,a);Object.prototype.hasOwnProperty.call(this.namedGroups,l)?n+=this.group(l):n+=`$<${l}>`,r=a+1}}return r<s&&(n+=e.substring(r,s)),n}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,n=!1){return this.replace(e,!0,n)}replaceFirst(e,n=!1){return this.replace(e,!1,n)}replace(e,n=!0,r=!1){let s="";for(this.reset();this.find()&&(s+=this.appendReplacement(e,r),!!n););return s+=this.appendTail(),s}},Te=class t{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(e){return t.RUNE<=e&&e<=t.RUNE_ANY_NOT_NL}static escapeRunes(e){let n='"';for(let r of e)n+=Ye.escapeRune(r);return n+='"',n}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=[]}matchRune(e){if(this.runes.length===1){let s=this.runes[0];return(this.arg&J.FOLD_CASE)!==0?Ce.equalsIgnoreCase(s,e):e===s}for(let s=0;s<this.runes.length&&s<=8;s+=2){if(e<this.runes[s])return!1;if(e<=this.runes[s+1])return!0}let n=0,r=this.runes.length/2|0;for(;n<r;){let s=n+((r-n)/2|0);if(this.runes[2*s]<=e){if(e<=this.runes[2*s+1])return!0;n=s+1}else r=s}return!1}toString(){switch(this.op){case t.ALT:return`alt -> ${this.out}, ${this.arg}`;case t.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case t.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case t.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case t.MATCH:return"match";case t.FAIL:return"fail";case t.NOP:return`nop -> ${this.out}`;case t.RUNE:return this.runes===null?"rune <null>":["rune ",t.escapeRunes(this.runes),(this.arg&J.FOLD_CASE)!==0?"/i":""," -> ",this.out].join("");case t.RUNE1:return`rune1 ${t.escapeRunes(this.runes)} -> ${this.out}`;case t.RUNE_ANY:return`any -> ${this.out}`;case t.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw new Error("unhandled case in Inst.toString")}}},ap=class{constructor(){this.inst=null,this.cap=[]}},Oc=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let n=this.sparse[e];return n<this.size&&this.densePcs[n]===e}isEmpty(){return this.size===0}add(e){let n=this.size++;return this.sparse[e]=n,this.denseThreads[n]=null,this.densePcs[n]=e,n}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e="{";for(let n=0;n<this.size;n++)n!==0&&(e+=", "),e+=this.densePcs[n];return e+="}",e}},$a=class t{static fromRE2(e){let n=new t;return n.prog=e.prog,n.re2=e,n.q0=new Oc(n.prog.numInst()),n.q1=new Oc(n.prog.numInst()),n.pool=[],n.poolSize=0,n.matched=!1,n.matchcap=Array(n.prog.numCap<2?2:n.prog.numCap).fill(0),n.ncap=0,n}static fromMachine(e){let n=new t;return n.re2=e.re2,n.prog=e.prog,n.q0=e.q0,n.q1=e.q1,n.pool=e.pool,n.poolSize=e.poolSize,n.matched=e.matched,n.matchcap=e.matchcap,n.ncap=e.ncap,n}init(e){this.ncap=e,e>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let n=0;n<this.poolSize;n++){let r=this.pool[n];r.cap=Array(e).fill(0)}}initNewCap(e){for(let n=0;n<this.poolSize;n++){let r=this.pool[n];r.cap=Array(e).fill(0)}this.matchcap=Array(e).fill(0)}submatches(){return this.ncap===0?Ye.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let n;return this.poolSize>0?(this.poolSize--,n=this.pool[this.poolSize]):n=new ap,n.inst=e,n}freeQueue(e,n=0){let r=e.size-n,s=this.poolSize+r;this.pool.length<s&&(this.pool=this.pool.slice(0,Math.max(this.pool.length*2,s)));for(let i=n;i<e.size;i++){let o=e.denseThreads[i];o!==null&&(this.pool[this.poolSize]=o,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,this.pool.length*2)),this.pool[this.poolSize]=e,this.poolSize++}match(e,n,r){let s=this.re2.cond;if(s===Ye.EMPTY_ALL||(r===J.ANCHOR_START||r===J.ANCHOR_BOTH)&&n!==0)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,o=this.q1,a=e.step(n),l=a>>3,c=a&7,u=-1,f=0;a!==us.EOF()&&(a=e.step(n+c),u=a>>3,f=a&7);let h;for(n===0?h=Ye.emptyOpContext(-1,l):h=e.context(n);;){if(i.isEmpty()){if((s&Ye.EMPTY_BEGIN_TEXT)!==0&&n!==0||this.matched)break;if(this.re2.prefix.length!==0&&u!==this.re2.prefixRune&&e.canCheckPrefix()){let m=e.index(this.re2,n);if(m<0)break;n+=m,a=e.step(n),l=a>>3,c=a&7,a=e.step(n+c),u=a>>3,f=a&7}}!this.matched&&(n===0||r===J.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=n),this.add(i,this.prog.start,n,this.matchcap,h,null));let d=n+c;if(h=e.context(d),this.step(i,o,n,d,l,h,r,n===e.endPos()),c===0||this.ncap===0&&this.matched)break;n+=c,l=u,c=f,l!==-1&&(a=e.step(n+c),u=a>>3,f=a&7);let p=i;i=o,o=p}return this.freeQueue(o),this.matched}step(e,n,r,s,i,o,a,l){let c=this.re2.longest;for(let u=0;u<e.size;u++){let f=e.denseThreads[u];if(f===null)continue;if(c&&this.matched&&this.ncap>0&&this.matchcap[0]<f.cap[0]){this.freeThread(f);continue}let h=f.inst,d=!1;switch(h.op){case Te.MATCH:if(a===J.ANCHOR_BOTH&&!l)break;this.ncap>0&&(!c||!this.matched||this.matchcap[1]<r)&&(f.cap[1]=r,this.matchcap=f.cap.slice(0,this.ncap)),c||this.freeQueue(e,u+1),this.matched=!0;break;case Te.RUNE:d=h.matchRune(i);break;case Te.RUNE1:d=i===h.runes[0];break;case Te.RUNE_ANY:d=!0;break;case Te.RUNE_ANY_NOT_NL:d=i!==L.CODES.get(`
166
+ `)&&(r|=this.EMPTY_END_LINE),this.isWordRune(e)!==this.isWordRune(n)?r|=this.EMPTY_WORD_BOUNDARY:r|=this.EMPTY_NO_WORD_BOUNDARY,r}static quoteMeta(e){return e.split("").map(n=>this.METACHARACTERS.indexOf(n)>=0?`\\${n}`:n).join("")}static charCount(e){return e>Ce.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let n=[],r=0;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);i<128?n[r++]=i:i<2048?(n[r++]=i>>6|192,n[r++]=i&63|128):(i&64512)===55296&&s+1<e.length&&(e.charCodeAt(s+1)&64512)===56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++s)&1023),n[r++]=i>>18|240,n[r++]=i>>12&63|128,n[r++]=i>>6&63|128,n[r++]=i&63|128):(n[r++]=i>>12|224,n[r++]=i>>6&63|128,n[r++]=i&63|128)}return n}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder("utf-8").decode(new Uint8Array(e));{let n=[],r=0,s=0;for(;r<e.length;){let i=e[r++];if(i<128)n[s++]=String.fromCharCode(i);else if(i>191&&i<224){let o=e[r++];n[s++]=String.fromCharCode((i&31)<<6|o&63)}else if(i>239&&i<365){let o=e[r++],a=e[r++],l=e[r++],c=((i&7)<<18|(o&63)<<12|(a&63)<<6|l&63)-65536;n[s++]=String.fromCharCode(55296+(c>>10)),n[s++]=String.fromCharCode(56320+(c&1023))}else{let o=e[r++],a=e[r++];n[s++]=String.fromCharCode((i&15)<<12|(o&63)<<6|a&63)}}return n.join("")}}},i7=(t=[],e=0)=>{let n={};for(let r=0;r<t.length;r++){let s=t[r],i=e+r;n[s]=i,n[i]=s}return Object.freeze(n)},Gs=class t{static Encoding=i7(["UTF_16","UTF_8"]);getEncoding(){throw Error("not implemented")}isUTF8Encoding(){return this.getEncoding()===t.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===t.Encoding.UTF_16}},Nc=class extends Gs{constructor(e=null){super(),this.bytes=e}getEncoding(){return Gs.Encoding.UTF_8}asCharSequence(){return Ye.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},np=class extends Gs{constructor(e=null){super(),this.charSequence=e}getEncoding(){return Gs.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split("").map(e=>e.codePointAt(0))}length(){return this.charSequence.length}},So=class{static utf16(e){return new np(e)}static utf8(e){return Array.isArray(e)?new Nc(e):new Nc(Ye.stringToUtf8ByteArray(e))}},fs=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},rp=class extends fs{constructor(e,n=0,r=e.length){super(),this.bytes=e,this.start=n,this.end=r}step(e){if(e+=this.start,e>=this.end)return fs.EOF();let n=this.bytes[e++]&255;return(n&128)===0?n<<3|1:(n&224)===192?(n=n&31,e>=this.end?fs.EOF():(n=n<<6|this.bytes[e++]&63,n<<3|2)):(n&240)===224?(n=n&15,e+1>=this.end?fs.EOF():(n=n<<6|this.bytes[e++]&63,n=n<<6|this.bytes[e++]&63,n<<3|3)):(n=n&7,e+2>=this.end?fs.EOF():(n=n<<6|this.bytes[e++]&63,n=n<<6|this.bytes[e++]&63,n=n<<6|this.bytes[e++]&63,n<<3|4))}index(e,n){n+=this.start;let r=this.indexOf(this.bytes,e.prefixUTF8,n);return r<0?r:r-n}context(e){e+=this.start;let n=-1;if(e>this.start&&e<=this.end){let s=e-1;if(n=this.bytes[s--],n>=128){let i=e-4;for(i<this.start&&(i=this.start);s>=i&&(this.bytes[s]&192)===128;)s--;s<this.start&&(s=this.start),n=this.step(s)>>3}}let r=e<this.end?this.step(e)>>3:-1;return Ye.emptyOpContext(n,r)}indexOf(e,n,r=0){let s=n.length;if(s===0)return-1;let i=e.length;for(let o=r;o<=i-s;o++)for(let a=0;a<s&&e[o+a]===n[a];a++)if(a===s-1)return o;return-1}},sp=class extends fs{constructor(e,n=0,r=e.length){super(),this.charSequence=e,this.start=n,this.end=r}step(e){if(e+=this.start,e<this.end){let n=this.charSequence.codePointAt(e);return n<<3|Ye.charCount(n)}else return fs.EOF()}index(e,n){n+=this.start;let r=this.charSequence.indexOf(e.prefix,n);return r<0?r:r-n}context(e){e+=this.start;let n=e>0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,r=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return Ye.emptyOpContext(n,r)}},Tt=class{static fromUTF8(e,n=0,r=e.length){return new rp(e,n,r)}static fromUTF16(e,n=0,r=e.length){return new sp(e,n,r)}},Ao=class extends Error{constructor(e){super(e),this.name="RE2JSException"}},wt=class extends Ao{constructor(e,n=null){let r=`error parsing regexp: ${e}`;n&&(r+=`: \`${n}\``),super(r),this.name="RE2JSSyntaxException",this.message=r,this.error=e,this.input=n}getDescription(){return this.error}getPattern(){return this.input}},ip=class extends Ao{constructor(e){super(e),this.name="RE2JSCompileException"}},Br=class extends Ao{constructor(e){super(e),this.name="RE2JSGroupException"}},op=class extends Ao{constructor(e){super(e),this.name="RE2JSFlagsException"}},Tc=class{static quoteReplacement(e,n=!1){return n?e.indexOf("\\")<0&&e.indexOf("$")<0?e:e.split("").map(r=>{let s=r.codePointAt(0);return s===L.CODES.get("\\")||s===L.CODES.get("$")?`\\${r}`:r}).join(""):e.indexOf("$")<0?e:e.split("").map(r=>r.codePointAt(0)===L.CODES.get("$")?"$$":r).join("")}constructor(e,n){if(e===null)throw new Error("pattern is null");this.patternInput=e;let r=this.patternInput.re2();this.patternGroupCount=r.numberOfCapturingGroups(),this.groups=[],this.namedGroups=r.namedGroups,this.numberOfInstructions=r.numberOfInstructions(),n instanceof Gs?this.resetMatcherInput(n):Array.isArray(n)?this.resetMatcherInput(So.utf8(n)):this.resetMatcherInput(So.utf16(n))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw new Error("input is null");return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e=="string"){let n=this.namedGroups[e];if(!Number.isFinite(n))throw new Br(`group '${e}' not found`);e=n}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e=="string"){let n=this.namedGroups[e];if(!Number.isFinite(n))throw new Br(`group '${e}' not found`);e=n}return this.loadGroup(e),this.groups[2*e+1]}programSize(){return this.numberOfInstructions}group(e=0){if(typeof e=="string"){let s=this.namedGroups[e];if(!Number.isFinite(s))throw new Br(`group '${e}' not found`);e=s}let n=this.start(e),r=this.end(e);return n<0&&r<0?null:this.substring(n,r)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new Br(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new Br("perhaps no match attempted");if(e===0||this.hasGroups)return;let n=this.groups[1]+1;n>this.matcherInputLength&&(n=this.matcherInputLength);let r=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],n,this.anchorFlag,1+this.patternGroupCount);if(!r[0])throw new Br("inconsistency in matching group data");this.groups=r[1],this.hasGroups=!0}matches(){return this.genMatch(0,J.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,J.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new Br(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,J.UNANCHORED)}genMatch(e,n){let r=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,n,1);return r[0]?(this.groups=r[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=n,!0):!1}substring(e,n){return this.matcherInput.isUTF8Encoding()?Ye.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,n)):this.matcherInput.asCharSequence().substring(e,n).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,n=!1){let r="",s=this.start(),i=this.end();return this.appendPos<s&&(r+=this.substring(this.appendPos,s)),this.appendPos=i,r+=n?this.appendReplacementInternalJava(e):this.appendReplacementInternalJs(e),r}appendReplacementInternalJava(e){let n="",r=0,s=e.length;for(let i=0;i<s-1;i++){if(e.codePointAt(i)===L.CODES.get("\\")){r<i&&(n+=e.substring(r,i)),i++,r=i;continue}if(e.codePointAt(i)===L.CODES.get("$")){let o=e.codePointAt(i+1);if(L.CODES.get("0")<=o&&o<=L.CODES.get("9")){let a=o-L.CODES.get("0");for(r<i&&(n+=e.substring(r,i)),i+=2;i<s&&(o=e.codePointAt(i),!(o<L.CODES.get("0")||o>L.CODES.get("9")||a*10+o-L.CODES.get("0")>this.patternGroupCount));i++)a=a*10+o-L.CODES.get("0");if(a>this.patternGroupCount)throw new Br(`n > number of groups: ${a}`);let l=this.group(a);l!==null&&(n+=l),r=i,i--;continue}else if(o===L.CODES.get("{")){r<i&&(n+=e.substring(r,i)),i++;let a=i+1;for(;a<e.length&&e.codePointAt(a)!==L.CODES.get("}")&&e.codePointAt(a)!==L.CODES.get(" ");)a++;if(a===e.length||e.codePointAt(a)!==L.CODES.get("}"))throw new Br("named capture group is missing trailing '}'");let l=e.substring(i+1,a);n+=this.group(l),r=a+1}}}return r<s&&(n+=e.substring(r,s)),n}appendReplacementInternalJs(e){let n="",r=0,s=e.length;for(let i=0;i<s-1;i++)if(e.codePointAt(i)===L.CODES.get("$")){let o=e.codePointAt(i+1);if(L.CODES.get("$")===o){r<i&&(n+=e.substring(r,i)),n+="$",i++,r=i+1;continue}else if(L.CODES.get("&")===o){r<i&&(n+=e.substring(r,i));let a=this.group(0);a!==null?n+=a:n+="$&",i++,r=i+1;continue}else if(L.CODES.get("1")<=o&&o<=L.CODES.get("9")){let a=o-L.CODES.get("0");for(r<i&&(n+=e.substring(r,i)),i+=2;i<s&&(o=e.codePointAt(i),!(o<L.CODES.get("0")||o>L.CODES.get("9")||a*10+o-L.CODES.get("0")>this.patternGroupCount));i++)a=a*10+o-L.CODES.get("0");if(a>this.patternGroupCount){n+=`$${a}`,r=i,i--;continue}let l=this.group(a);l!==null&&(n+=l),r=i,i--;continue}else if(o===L.CODES.get("<")){r<i&&(n+=e.substring(r,i)),i++;let a=i+1;for(;a<e.length&&e.codePointAt(a)!==L.CODES.get(">")&&e.codePointAt(a)!==L.CODES.get(" ");)a++;if(a===e.length||e.codePointAt(a)!==L.CODES.get(">")){n+=e.substring(i-1,a+1),r=a+1;continue}let l=e.substring(i+1,a);Object.prototype.hasOwnProperty.call(this.namedGroups,l)?n+=this.group(l):n+=`$<${l}>`,r=a+1}}return r<s&&(n+=e.substring(r,s)),n}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,n=!1){return this.replace(e,!0,n)}replaceFirst(e,n=!1){return this.replace(e,!1,n)}replace(e,n=!0,r=!1){let s="";for(this.reset();this.find()&&(s+=this.appendReplacement(e,r),!!n););return s+=this.appendTail(),s}},Te=class t{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(e){return t.RUNE<=e&&e<=t.RUNE_ANY_NOT_NL}static escapeRunes(e){let n='"';for(let r of e)n+=Ye.escapeRune(r);return n+='"',n}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=[]}matchRune(e){if(this.runes.length===1){let s=this.runes[0];return(this.arg&J.FOLD_CASE)!==0?Ce.equalsIgnoreCase(s,e):e===s}for(let s=0;s<this.runes.length&&s<=8;s+=2){if(e<this.runes[s])return!1;if(e<=this.runes[s+1])return!0}let n=0,r=this.runes.length/2|0;for(;n<r;){let s=n+((r-n)/2|0);if(this.runes[2*s]<=e){if(e<=this.runes[2*s+1])return!0;n=s+1}else r=s}return!1}toString(){switch(this.op){case t.ALT:return`alt -> ${this.out}, ${this.arg}`;case t.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case t.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case t.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case t.MATCH:return"match";case t.FAIL:return"fail";case t.NOP:return`nop -> ${this.out}`;case t.RUNE:return this.runes===null?"rune <null>":["rune ",t.escapeRunes(this.runes),(this.arg&J.FOLD_CASE)!==0?"/i":""," -> ",this.out].join("");case t.RUNE1:return`rune1 ${t.escapeRunes(this.runes)} -> ${this.out}`;case t.RUNE_ANY:return`any -> ${this.out}`;case t.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw new Error("unhandled case in Inst.toString")}}},ap=class{constructor(){this.inst=null,this.cap=[]}},Oc=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let n=this.sparse[e];return n<this.size&&this.densePcs[n]===e}isEmpty(){return this.size===0}add(e){let n=this.size++;return this.sparse[e]=n,this.denseThreads[n]=null,this.densePcs[n]=e,n}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e="{";for(let n=0;n<this.size;n++)n!==0&&(e+=", "),e+=this.densePcs[n];return e+="}",e}},$a=class t{static fromRE2(e){let n=new t;return n.prog=e.prog,n.re2=e,n.q0=new Oc(n.prog.numInst()),n.q1=new Oc(n.prog.numInst()),n.pool=[],n.poolSize=0,n.matched=!1,n.matchcap=Array(n.prog.numCap<2?2:n.prog.numCap).fill(0),n.ncap=0,n}static fromMachine(e){let n=new t;return n.re2=e.re2,n.prog=e.prog,n.q0=e.q0,n.q1=e.q1,n.pool=e.pool,n.poolSize=e.poolSize,n.matched=e.matched,n.matchcap=e.matchcap,n.ncap=e.ncap,n}init(e){this.ncap=e,e>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let n=0;n<this.poolSize;n++){let r=this.pool[n];r.cap=Array(e).fill(0)}}initNewCap(e){for(let n=0;n<this.poolSize;n++){let r=this.pool[n];r.cap=Array(e).fill(0)}this.matchcap=Array(e).fill(0)}submatches(){return this.ncap===0?Ye.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let n;return this.poolSize>0?(this.poolSize--,n=this.pool[this.poolSize]):n=new ap,n.inst=e,n}freeQueue(e,n=0){let r=e.size-n,s=this.poolSize+r;this.pool.length<s&&(this.pool=this.pool.slice(0,Math.max(this.pool.length*2,s)));for(let i=n;i<e.size;i++){let o=e.denseThreads[i];o!==null&&(this.pool[this.poolSize]=o,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,this.pool.length*2)),this.pool[this.poolSize]=e,this.poolSize++}match(e,n,r){let s=this.re2.cond;if(s===Ye.EMPTY_ALL||(r===J.ANCHOR_START||r===J.ANCHOR_BOTH)&&n!==0)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,o=this.q1,a=e.step(n),l=a>>3,c=a&7,u=-1,f=0;a!==fs.EOF()&&(a=e.step(n+c),u=a>>3,f=a&7);let h;for(n===0?h=Ye.emptyOpContext(-1,l):h=e.context(n);;){if(i.isEmpty()){if((s&Ye.EMPTY_BEGIN_TEXT)!==0&&n!==0||this.matched)break;if(this.re2.prefix.length!==0&&u!==this.re2.prefixRune&&e.canCheckPrefix()){let m=e.index(this.re2,n);if(m<0)break;n+=m,a=e.step(n),l=a>>3,c=a&7,a=e.step(n+c),u=a>>3,f=a&7}}!this.matched&&(n===0||r===J.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=n),this.add(i,this.prog.start,n,this.matchcap,h,null));let d=n+c;if(h=e.context(d),this.step(i,o,n,d,l,h,r,n===e.endPos()),c===0||this.ncap===0&&this.matched)break;n+=c,l=u,c=f,l!==-1&&(a=e.step(n+c),u=a>>3,f=a&7);let p=i;i=o,o=p}return this.freeQueue(o),this.matched}step(e,n,r,s,i,o,a,l){let c=this.re2.longest;for(let u=0;u<e.size;u++){let f=e.denseThreads[u];if(f===null)continue;if(c&&this.matched&&this.ncap>0&&this.matchcap[0]<f.cap[0]){this.freeThread(f);continue}let h=f.inst,d=!1;switch(h.op){case Te.MATCH:if(a===J.ANCHOR_BOTH&&!l)break;this.ncap>0&&(!c||!this.matched||this.matchcap[1]<r)&&(f.cap[1]=r,this.matchcap=f.cap.slice(0,this.ncap)),c||this.freeQueue(e,u+1),this.matched=!0;break;case Te.RUNE:d=h.matchRune(i);break;case Te.RUNE1:d=i===h.runes[0];break;case Te.RUNE_ANY:d=!0;break;case Te.RUNE_ANY_NOT_NL:d=i!==L.CODES.get(`
167
167
  `);break;default:throw new Error("bad inst")}d&&(f=this.add(n,h.out,s,f.cap,o,f)),f!==null&&(this.freeThread(f),e.denseThreads[u]=null)}e.clear()}add(e,n,r,s,i,o){if(n===0||e.contains(n))return o;let a=e.add(n),l=this.prog.inst[n];switch(l.op){case Te.FAIL:break;case Te.ALT:case Te.ALT_MATCH:o=this.add(e,l.out,r,s,i,o),o=this.add(e,l.arg,r,s,i,o);break;case Te.EMPTY_WIDTH:(l.arg&~i)===0&&(o=this.add(e,l.out,r,s,i,o));break;case Te.NOP:o=this.add(e,l.out,r,s,i,o);break;case Te.CAPTURE:if(l.arg<this.ncap){let c=s[l.arg];s[l.arg]=r,this.add(e,l.out,r,s,i,null),s[l.arg]=c}else o=this.add(e,l.out,r,s,i,o);break;case Te.MATCH:case Te.RUNE:case Te.RUNE1:case Te.RUNE_ANY:case Te.RUNE_ANY_NOT_NL:o===null?o=this.alloc(l):o.inst=l,this.ncap>0&&o.cap!==s&&(o.cap=s.slice(0,this.ncap)),e.denseThreads[a]=o,o=null;break;default:throw new Error("unhandled")}return o}},WO=t=>{let e=-2128831035;for(let n=0;n<t.length;n++)e^=t[n],e=Math.imul(e,16777619);return e},jO=(t,e)=>{if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0},lp=class{constructor(e,n){this.nfaStates=e,this.isMatch=n,this.nextAscii=new Array(Ce.MAX_ASCII+1).fill(null),this.nextMap=new Map}},cp=class{constructor(e){this.prog=e,this.stateCache=new Map,this.stateCount=0,this.startState=null,this.stateLimit=1e4}computeClosure(e){let n=new Set,r=[...e],s=!1;for(;r.length>0;){let o=r.pop();if(n.has(o))continue;n.add(o);let a=this.prog.getInst(o);switch(a.op){case Te.MATCH:s=!0;break;case Te.ALT:case Te.ALT_MATCH:r.push(a.out),r.push(a.arg);break;case Te.NOP:case Te.CAPTURE:r.push(a.out);break;case Te.EMPTY_WIDTH:return null}}return{pcs:Int32Array.from(n).sort(),isMatch:s}}getState(e){let n=this.computeClosure(e);if(!n)return null;let r=n.pcs,s=WO(r),i=this.stateCache.get(s);if(i)for(let a=0;a<i.length;a++){let l=i[a];if(jO(l.nfaStates,r))return l}else i=[],this.stateCache.set(s,i);if(this.stateCount>=this.stateLimit)return this.stateCache.clear(),this.stateCount=0,this.startState=null,null;let o=new lp(r,n.isMatch);return i.push(o),this.stateCount++,o}step(e,n,r){if(r===J.UNANCHORED&&n<=Ce.MAX_ASCII){let o=e.nextAscii[n];if(o!==null)return o}else{let o=n+(r===J.UNANCHORED?0:Ce.MAX_RUNE+1);if(e.nextMap.has(o))return e.nextMap.get(o)}let s=[];for(let o=0;o<e.nfaStates.length;o++){let a=e.nfaStates[o],l=this.prog.getInst(a);Te.isRuneOp(l.op)&&l.matchRune(n)&&s.push(l.out)}r===J.UNANCHORED&&s.push(this.prog.start);let i=this.getState(s);if(r===J.UNANCHORED&&n<=Ce.MAX_ASCII)e.nextAscii[n]=i;else{let o=n+(r===J.UNANCHORED?0:Ce.MAX_RUNE+1);e.nextMap.set(o,i)}return i}match(e,n,r){if((r===J.ANCHOR_START||r===J.ANCHOR_BOTH)&&n!==0)return!1;if(!this.startState&&(this.startState=this.getState([this.prog.start]),!this.startState))return null;let s=e.endPos(),i=this.startState;if(i.isMatch)if(r===J.ANCHOR_BOTH){if(n===s)return!0}else return!0;let o=n;for(;o<s;){let a=e.step(o),l=a>>3,c=a&7;if(c===0)break;if(i=this.step(i,l,r),i===null)return null;if(i.isMatch)if(r===J.ANCHOR_BOTH){if(o+c===s)return!0}else return!0;if(i.nfaStates.length===0&&r!==J.UNANCHORED)return!1;o+=c}return!1}},M=class t{static Op=i7(["NO_MATCH","EMPTY_MATCH","LITERAL","CHAR_CLASS","ANY_CHAR_NOT_NL","ANY_CHAR","BEGIN_LINE","END_LINE","BEGIN_TEXT","END_TEXT","WORD_BOUNDARY","NO_WORD_BOUNDARY","CAPTURE","STAR","PLUS","QUEST","REPEAT","CONCAT","ALTERNATE","LEFT_PAREN","VERTICAL_BAR"]);static isPseudoOp(e){return e>=t.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===L.CODES.get("-")?"\\":""}static fromRegexp(e){let n=new t(e.op);return n.flags=e.flags,n.subs=e.subs,n.runes=e.runes,n.cap=e.cap,n.min=e.min,n.max=e.max,n.name=e.name,n.namedGroups=e.namedGroups,n}constructor(e){this.op=e,this.flags=0,this.subs=t.emptySubs(),this.runes=[],this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=t.emptySubs(),this.runes=[],this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let e="";switch(this.op){case t.Op.NO_MATCH:e+="[^\\x00-\\x{10FFFF}]";break;case t.Op.EMPTY_MATCH:e+="(?:)";break;case t.Op.STAR:case t.Op.PLUS:case t.Op.QUEST:case t.Op.REPEAT:{let n=this.subs[0];switch(n.op>t.Op.CAPTURE||n.op===t.Op.LITERAL&&n.runes.length>1?e+=`(?:${n.appendTo()})`:e+=n.appendTo(),this.op){case t.Op.STAR:e+="*";break;case t.Op.PLUS:e+="+";break;case t.Op.QUEST:e+="?";break;case t.Op.REPEAT:e+=`{${this.min}`,this.min!==this.max&&(e+=",",this.max>=0&&(e+=this.max)),e+="}";break}(this.flags&J.NON_GREEDY)!==0&&(e+="?");break}case t.Op.CONCAT:{for(let n of this.subs)n.op===t.Op.ALTERNATE?e+=`(?:${n.appendTo()})`:e+=n.appendTo();break}case t.Op.ALTERNATE:{let n="";for(let r of this.subs)e+=n,n="|",e+=r.appendTo();break}case t.Op.LITERAL:(this.flags&J.FOLD_CASE)!==0&&(e+="(?i:");for(let n of this.runes)e+=Ye.escapeRune(n);(this.flags&J.FOLD_CASE)!==0&&(e+=")");break;case t.Op.ANY_CHAR_NOT_NL:e+="(?-s:.)";break;case t.Op.ANY_CHAR:e+="(?s:.)";break;case t.Op.CAPTURE:this.name===null||this.name.length===0?e+="(":e+=`(?P<${this.name}>`,this.subs[0].op!==t.Op.EMPTY_MATCH&&(e+=this.subs[0].appendTo()),e+=")";break;case t.Op.BEGIN_TEXT:e+="\\A";break;case t.Op.END_TEXT:(this.flags&J.WAS_DOLLAR)!==0?e+="(?-m:$)":e+="\\z";break;case t.Op.BEGIN_LINE:e+="^";break;case t.Op.END_LINE:e+="$";break;case t.Op.WORD_BOUNDARY:e+="\\b";break;case t.Op.NO_WORD_BOUNDARY:e+="\\B";break;case t.Op.CHAR_CLASS:if(this.runes.length%2!==0){e+="[invalid char class]";break}if(e+="[",this.runes.length===0)e+="^\\x00-\\x{10FFFF}";else if(this.runes[0]===0&&this.runes[this.runes.length-1]===Ce.MAX_RUNE){e+="^";for(let n=1;n<this.runes.length-1;n+=2){let r=this.runes[n]+1,s=this.runes[n+1]-1;e+=t.quoteIfHyphen(r),e+=Ye.escapeRune(r),r!==s&&(e+="-",e+=t.quoteIfHyphen(s),e+=Ye.escapeRune(s))}}else for(let n=0;n<this.runes.length;n+=2){let r=this.runes[n],s=this.runes[n+1];e+=t.quoteIfHyphen(r),e+=Ye.escapeRune(r),r!==s&&(e+="-",e+=t.quoteIfHyphen(s),e+=Ye.escapeRune(s))}e+="]";break;default:e+=this.op;break}return e}maxCap(){let e=0;if(this.op===t.Op.CAPTURE&&(e=this.cap),this.subs!==null)for(let n of this.subs){let r=n.maxCap();e<r&&(e=r)}return e}equals(e){if(!(e!==null&&e instanceof t)||this.op!==e.op)return!1;switch(this.op){case t.Op.END_TEXT:{if((this.flags&J.WAS_DOLLAR)!==(e.flags&J.WAS_DOLLAR))return!1;break}case t.Op.LITERAL:case t.Op.CHAR_CLASS:{if(this.runes===null&&e.runes===null)break;if(this.runes===null||e.runes===null||this.runes.length!==e.runes.length)return!1;for(let n=0;n<this.runes.length;n++)if(this.runes[n]!==e.runes[n])return!1;break}case t.Op.ALTERNATE:case t.Op.CONCAT:{if(this.subs.length!==e.subs.length)return!1;for(let n=0;n<this.subs.length;++n)if(!this.subs[n].equals(e.subs[n]))return!1;break}case t.Op.STAR:case t.Op.PLUS:case t.Op.QUEST:{if((this.flags&J.NON_GREEDY)!==(e.flags&J.NON_GREEDY)||!this.subs[0].equals(e.subs[0]))return!1;break}case t.Op.REPEAT:{if((this.flags&J.NON_GREEDY)!==(e.flags&J.NON_GREEDY)||this.min!==e.min||this.max!==e.max||!this.subs[0].equals(e.subs[0]))return!1;break}case t.Op.CAPTURE:{if(this.cap!==e.cap||(this.name===null?e.name!==null:this.name!==e.name)||!this.subs[0].equals(e.subs[0]))return!1;break}}return!0}},up=class{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new Te(e))}skipNop(e){let n=this.inst[e];for(;n.op===Te.NOP||n.op===Te.CAPTURE;)n=this.inst[e],e=n.out;return n}prefix(){let e="",n=this.skipNop(this.start);if(!Te.isRuneOp(n.op)||n.runes.length!==1)return[n.op===Te.MATCH,e];for(;Te.isRuneOp(n.op)&&n.runes.length===1&&(n.arg&J.FOLD_CASE)===0;)e+=String.fromCodePoint(n.runes[0]),n=this.skipNop(n.out);return[n.op===Te.MATCH,e]}startCond(){let e=0,n=this.start;e:for(;;){let r=this.inst[n];switch(r.op){case Te.EMPTY_WIDTH:e|=r.arg;break;case Te.FAIL:return-1;case Te.CAPTURE:case Te.NOP:break;default:break e}n=r.out}return e}next(e){let n=this.inst[e>>1];return(e&1)===0?n.out:n.arg}patch(e,n){for(;e!==0;){let r=this.inst[e>>1];(e&1)===0?(e=r.out,r.out=n):(e=r.arg,r.arg=n)}}append(e,n){if(e===0)return n;if(n===0)return e;let r=e;for(;;){let i=this.next(r);if(i===0)break;r=i}let s=this.inst[r>>1];return(r&1)===0?s.out=n:s.arg=n,e}toString(){let e="";for(let n=0;n<this.inst.length;n++){let r=e.length;e+=n,n===this.start&&(e+="*"),e+=" ".substring(e.length-r),e+=this.inst[n],e+=`
168
168
  `}return e}},xo=class{constructor(e=0,n=0,r=!1){this.i=e,this.out=n,this.nullable=r}},fp=class t{static ANY_RUNE_NOT_NL(){return[0,L.CODES.get(`
169
169
  `)-1,L.CODES.get(`
170
170
  `)+1,Ce.MAX_RUNE]}static ANY_RUNE(){return[0,Ce.MAX_RUNE]}static compileRegexp(e){let n=new t,r=n.compile(e);return n.prog.patch(r.out,n.newInst(Te.MATCH).i),n.prog.start=r.i,n.prog}constructor(){this.prog=new up,this.newInst(Te.FAIL)}newInst(e){return this.prog.addInst(e),new xo(this.prog.numInst()-1,0,!0)}nop(){let e=this.newInst(Te.NOP);return e.out=e.i<<1,e}fail(){return new xo}cap(e){let n=this.newInst(Te.CAPTURE);return n.out=n.i<<1,this.prog.getInst(n.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),n}cat(e,n){return e.i===0||n.i===0?this.fail():(this.prog.patch(e.out,n.i),new xo(e.i,n.out,e.nullable&&n.nullable))}alt(e,n){if(e.i===0)return n;if(n.i===0)return e;let r=this.newInst(Te.ALT),s=this.prog.getInst(r.i);return s.out=e.i,s.arg=n.i,r.out=this.prog.append(e.out,n.out),r.nullable=e.nullable||n.nullable,r}loop(e,n){let r=this.newInst(Te.ALT),s=this.prog.getInst(r.i);return n?(s.arg=e.i,r.out=r.i<<1):(s.out=e.i,r.out=r.i<<1|1),this.prog.patch(e.out,r.i),r}quest(e,n){let r=this.newInst(Te.ALT),s=this.prog.getInst(r.i);return n?(s.arg=e.i,r.out=r.i<<1):(s.out=e.i,r.out=r.i<<1|1),r.out=this.prog.append(r.out,e.out),r}star(e,n){return e.nullable?this.quest(this.plus(e,n),n):this.loop(e,n)}plus(e,n){return new xo(e.i,this.loop(e,n).out,e.nullable)}empty(e){let n=this.newInst(Te.EMPTY_WIDTH);return this.prog.getInst(n.i).arg=e,n.out=n.i<<1,n}rune(e,n){let r=this.newInst(Te.RUNE);r.nullable=!1;let s=this.prog.getInst(r.i);return s.runes=e,n&=J.FOLD_CASE,(e.length!==1||Ce.simpleFold(e[0])===e[0])&&(n&=-2),s.arg=n,r.out=r.i<<1,(n&J.FOLD_CASE)===0&&e.length===1||e.length===2&&e[0]===e[1]?s.op=Te.RUNE1:e.length===2&&e[0]===0&&e[1]===Ce.MAX_RUNE?s.op=Te.RUNE_ANY:e.length===4&&e[0]===0&&e[1]===L.CODES.get(`
171
171
  `)-1&&e[2]===L.CODES.get(`
172
- `)+1&&e[3]===Ce.MAX_RUNE&&(s.op=Te.RUNE_ANY_NOT_NL),r}compile(e){switch(e.op){case M.Op.NO_MATCH:return this.fail();case M.Op.EMPTY_MATCH:return this.nop();case M.Op.LITERAL:if(e.runes.length===0)return this.nop();{let n=null;for(let r of e.runes){let s=this.rune([r],e.flags);n=n===null?s:this.cat(n,s)}return n}case M.Op.CHAR_CLASS:return this.rune(e.runes,e.flags);case M.Op.ANY_CHAR_NOT_NL:return this.rune(t.ANY_RUNE_NOT_NL(),0);case M.Op.ANY_CHAR:return this.rune(t.ANY_RUNE(),0);case M.Op.BEGIN_LINE:return this.empty(Ye.EMPTY_BEGIN_LINE);case M.Op.END_LINE:return this.empty(Ye.EMPTY_END_LINE);case M.Op.BEGIN_TEXT:return this.empty(Ye.EMPTY_BEGIN_TEXT);case M.Op.END_TEXT:return this.empty(Ye.EMPTY_END_TEXT);case M.Op.WORD_BOUNDARY:return this.empty(Ye.EMPTY_WORD_BOUNDARY);case M.Op.NO_WORD_BOUNDARY:return this.empty(Ye.EMPTY_NO_WORD_BOUNDARY);case M.Op.CAPTURE:{let n=this.cap(e.cap<<1),r=this.compile(e.subs[0]),s=this.cap(e.cap<<1|1);return this.cat(this.cat(n,r),s)}case M.Op.STAR:return this.star(this.compile(e.subs[0]),(e.flags&J.NON_GREEDY)!==0);case M.Op.PLUS:return this.plus(this.compile(e.subs[0]),(e.flags&J.NON_GREEDY)!==0);case M.Op.QUEST:return this.quest(this.compile(e.subs[0]),(e.flags&J.NON_GREEDY)!==0);case M.Op.CONCAT:{if(e.subs.length===0)return this.nop();{let n=null;for(let r of e.subs){let s=this.compile(r);n=n===null?s:this.cat(n,s)}return n}}case M.Op.ALTERNATE:{if(e.subs.length===0)return this.nop();{let n=null;for(let r of e.subs){let s=this.compile(r);n=n===null?s:this.alt(n,s)}return n}}default:throw new ip("regexp: unhandled case in compile")}}},hp=class t{static simplify(e){if(e===null)return null;switch(e.op){case M.Op.CAPTURE:case M.Op.CONCAT:case M.Op.ALTERNATE:{let n=e;for(let r=0;r<e.subs.length;r++){let s=e.subs[r],i=t.simplify(s);n===e&&i!==s&&(n=M.fromRegexp(e),n.runes=[],n.subs=e.subs.slice(0,e.subs.length)),n!==e&&(n.subs[r]=i)}return n}case M.Op.STAR:case M.Op.PLUS:case M.Op.QUEST:{let n=t.simplify(e.subs[0]);return t.simplify1(e.op,e.flags,n,e)}case M.Op.REPEAT:{if(e.min===0&&e.max===0)return new M(M.Op.EMPTY_MATCH);let n=t.simplify(e.subs[0]);if(e.max===-1){if(e.min===0)return t.simplify1(M.Op.STAR,e.flags,n,null);if(e.min===1)return t.simplify1(M.Op.PLUS,e.flags,n,null);let s=new M(M.Op.CONCAT),i=[];for(let o=0;o<e.min-1;o++)i.push(n);return i.push(t.simplify1(M.Op.PLUS,e.flags,n,null)),s.subs=i.slice(0),s}if(e.min===1&&e.max===1)return n;let r=null;if(e.min>0){r=[];for(let s=0;s<e.min;s++)r.push(n)}if(e.max>e.min){let s=t.simplify1(M.Op.QUEST,e.flags,n,null);for(let i=e.min+1;i<e.max;i++){let o=new M(M.Op.CONCAT);o.subs=[n,s],s=t.simplify1(M.Op.QUEST,e.flags,o,null)}if(r===null)return s;r.push(s)}if(r!==null){let s=new M(M.Op.CONCAT);return s.subs=r.slice(0),s}return new M(M.Op.NO_MATCH)}}return e}static simplify1(e,n,r,s){return r.op===M.Op.EMPTY_MATCH||e===r.op&&(n&J.NON_GREEDY)===(r.flags&J.NON_GREEDY)?r:(s!==null&&s.op===e&&(s.flags&J.NON_GREEDY)===(n&J.NON_GREEDY)&&r===s.subs[0]||(s=new M(e),s.flags=n,s.subs=[r]),s)}},Ze=class{constructor(e,n){this.sign=e,this.cls=n}},Ub=[48,57],zb=[9,10,12,13,32,32],Wb=[48,57,65,90,95,95,97,122],jb=new Map([["\\d",new Ze(1,Ub)],["\\D",new Ze(-1,Ub)],["\\s",new Ze(1,zb)],["\\S",new Ze(-1,zb)],["\\w",new Ze(1,Wb)],["\\W",new Ze(-1,Wb)]]),qb=[48,57,65,90,97,122],Hb=[65,90,97,122],Vb=[0,127],Gb=[9,9,32,32],Kb=[0,31,127,127],Zb=[48,57],Yb=[33,126],Qb=[97,122],Xb=[32,126],Jb=[33,47,58,64,91,96,123,126],e7=[9,13,32,32],t7=[65,90],n7=[48,57,65,90,95,95,97,122],r7=[48,57,65,70,97,102],s7=new Map([["[:alnum:]",new Ze(1,qb)],["[:^alnum:]",new Ze(-1,qb)],["[:alpha:]",new Ze(1,Hb)],["[:^alpha:]",new Ze(-1,Hb)],["[:ascii:]",new Ze(1,Vb)],["[:^ascii:]",new Ze(-1,Vb)],["[:blank:]",new Ze(1,Gb)],["[:^blank:]",new Ze(-1,Gb)],["[:cntrl:]",new Ze(1,Kb)],["[:^cntrl:]",new Ze(-1,Kb)],["[:digit:]",new Ze(1,Zb)],["[:^digit:]",new Ze(-1,Zb)],["[:graph:]",new Ze(1,Yb)],["[:^graph:]",new Ze(-1,Yb)],["[:lower:]",new Ze(1,Qb)],["[:^lower:]",new Ze(-1,Qb)],["[:print:]",new Ze(1,Xb)],["[:^print:]",new Ze(-1,Xb)],["[:punct:]",new Ze(1,Jb)],["[:^punct:]",new Ze(-1,Jb)],["[:space:]",new Ze(1,e7)],["[:^space:]",new Ze(-1,e7)],["[:upper:]",new Ze(1,t7)],["[:^upper:]",new Ze(-1,t7)],["[:word:]",new Ze(1,n7)],["[:^word:]",new Ze(-1,n7)],["[:xdigit:]",new Ze(1,r7)],["[:^xdigit:]",new Ze(-1,r7)]]),cs=class t{static charClassToString(e,n){let r="[";for(let s=0;s<n;s+=2){s>0&&(r+=" ");let i=e[s],o=e[s+1];i===o?r+=`0x${i.toString(16)}`:r+=`0x${i.toString(16)}-0x${o.toString(16)}`}return r+="]",r}static cmp(e,n,r,s){let i=e[n]-r;return i!==0?i:s-e[n+1]}static qsortIntPair(e,n,r){let s=((n+r)/2|0)&-2,i=e[s],o=e[s+1],a=n,l=r;for(;a<=l;){for(;a<r&&t.cmp(e,a,i,o)<0;)a+=2;for(;l>n&&t.cmp(e,l,i,o)>0;)l-=2;if(a<=l){if(a!==l){let c=e[a];e[a]=e[l],e[l]=c,c=e[a+1],e[a+1]=e[l+1],e[l+1]=c}a+=2,l-=2}}n<l&&t.qsortIntPair(e,n,l),a<r&&t.qsortIntPair(e,a,r)}constructor(e=Ye.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;t.qsortIntPair(this.r,0,this.len-2);let e=2;for(let n=2;n<this.len;n+=2){let r=this.r[n],s=this.r[n+1];if(r<=this.r[e-1]+1){s>this.r[e-1]&&(this.r[e-1]=s);continue}this.r[e]=r,this.r[e+1]=s,e+=2}return this.len=e,this}appendLiteral(e,n){return(n&J.FOLD_CASE)!==0?this.appendFoldedRange(e,e):this.appendRange(e,e)}appendRange(e,n){if(this.len>0){for(let r=2;r<=4;r+=2)if(this.len>=r){let s=this.r[this.len-r],i=this.r[this.len-r+1];if(e<=i+1&&s<=n+1)return e<s&&(this.r[this.len-r]=e),n>i&&(this.r[this.len-r+1]=n),this}}return this.r[this.len++]=e,this.r[this.len++]=n,this}appendFoldedRange(e,n){if(e<=Ce.MIN_FOLD&&n>=Ce.MAX_FOLD)return this.appendRange(e,n);if(n<Ce.MIN_FOLD||e>Ce.MAX_FOLD)return this.appendRange(e,n);e<Ce.MIN_FOLD&&(this.appendRange(e,Ce.MIN_FOLD-1),e=Ce.MIN_FOLD),n>Ce.MAX_FOLD&&(this.appendRange(Ce.MAX_FOLD+1,n),n=Ce.MAX_FOLD);for(let r=e;r<=n;r++){this.appendRange(r,r);for(let s=Ce.simpleFold(r);s!==r;s=Ce.simpleFold(s))this.appendRange(s,s)}return this}appendClass(e){for(let n=0;n<e.length;n+=2)this.appendRange(e[n],e[n+1]);return this}appendFoldedClass(e){for(let n=0;n<e.length;n+=2)this.appendFoldedRange(e[n],e[n+1]);return this}appendNegatedClass(e){let n=0;for(let r=0;r<e.length;r+=2){let s=e[r],i=e[r+1];n<=s-1&&this.appendRange(n,s-1),n=i+1}return n<=Ce.MAX_RUNE&&this.appendRange(n,Ce.MAX_RUNE),this}appendTable(e){for(let n=0;n<e.length;++n){let r=e.getLo(n),s=e.getHi(n),i=e.getStride(n);if(i===1){this.appendRange(r,s);continue}for(let o=r;o<=s;o+=i)this.appendRange(o,o)}return this}appendNegatedTable(e){let n=0;for(let r=0;r<e.length;++r){let s=e.getLo(r),i=e.getHi(r),o=e.getStride(r);if(o===1){n<=s-1&&this.appendRange(n,s-1),n=i+1;continue}for(let a=s;a<=i;a+=o)n<=a-1&&this.appendRange(n,a-1),n=a+1}return n<=Ce.MAX_RUNE&&this.appendRange(n,Ce.MAX_RUNE),this}appendTableWithSign(e,n){return n<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,n=0;for(let r=0;r<this.len;r+=2){let s=this.r[r],i=this.r[r+1];e<=s-1&&(this.r[n]=e,this.r[n+1]=s-1,n+=2),e=i+1}return this.len=n,e<=Ce.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=Ce.MAX_RUNE),this}appendClassWithSign(e,n){return n<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(e,n){let r=e.cls;return n&&(r=new t().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,e.sign)}toString(){return t.charClassToString(this.r,this.len)}},Fa=class t{static of(e,n){return new t(e,n)}constructor(e,n){this.first=e,this.second=n}},dp=class{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){let e=this.str.codePointAt(this.position);return this.position+=Ye.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}},pp=class t{static ERR_INTERNAL_ERROR="regexp/syntax: internal error";static ERR_INVALID_CHAR_RANGE="invalid character class range";static ERR_INVALID_ESCAPE="invalid escape sequence";static ERR_INVALID_NAMED_CAPTURE="invalid named capture";static ERR_INVALID_PERL_OP="invalid or unsupported Perl syntax";static ERR_INVALID_REPEAT_OP="invalid nested repetition operator";static ERR_INVALID_REPEAT_SIZE="invalid repeat count";static ERR_MISSING_BRACKET="missing closing ]";static ERR_MISSING_PAREN="missing closing )";static ERR_MISSING_REPEAT_ARGUMENT="missing argument to repetition operator";static ERR_TRAILING_BACKSLASH="trailing backslash at end of expression";static ERR_DUPLICATE_NAMED_CAPTURE="duplicate capture group name";static ERR_UNEXPECTED_PAREN="unexpected )";static ERR_NESTING_DEPTH="expression nests too deeply";static ERR_LARGE="expression too large";static MAX_HEIGHT=1e3;static MAX_SIZE=3355443;static MAX_RUNES=33554432;static ANY_TABLE=new F(new Uint32Array([0,Ce.MAX_RUNE,1]));static unicodeTable(e){return e==="Any"?Fa.of(t.ANY_TABLE,t.ANY_TABLE):xr.CATEGORIES.has(e)?Fa.of(xr.CATEGORIES.get(e),xr.FOLD_CATEGORIES.get(e)):xr.SCRIPTS.has(e)?Fa.of(xr.SCRIPTS.get(e),xr.FOLD_SCRIPT.get(e)):null}static minFoldRune(e){if(e<Ce.MIN_FOLD||e>Ce.MAX_FOLD)return e;let n=e,r=e;for(e=Ce.simpleFold(e);e!==r;e=Ce.simpleFold(e))n>e&&(n=e);return n}static leadingRegexp(e){if(e.op===M.Op.EMPTY_MATCH)return null;if(e.op===M.Op.CONCAT&&e.subs.length>0){let n=e.subs[0];return n.op===M.Op.EMPTY_MATCH?null:n}return e}static literalRegexp(e,n){let r=new M(M.Op.LITERAL);return r.flags=n,r.runes=Ye.stringToRunes(e),r}static parse(e,n){return new t(e,n).parseInternal()}static parseRepeat(e){let n=e.pos();if(!e.more()||!e.lookingAt("{"))return-1;e.skip(1);let r=t.parseInt(e);if(r===-1||!e.more())return-1;let s;if(!e.lookingAt(","))s=r;else{if(e.skip(1),!e.more())return-1;if(e.lookingAt("}"))s=-1;else if((s=t.parseInt(e))===-1)return-1}if(!e.more()||!e.lookingAt("}"))return-1;if(e.skip(1),r<0||r>1e3||s===-2||s>1e3||s>=0&&r>s)throw new wt(t.ERR_INVALID_REPEAT_SIZE,e.from(n));return r<<16|s&Ce.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r!==L.CODES.get("_")&&!Ye.isalnum(r))return!1}return!0}static parseInt(e){let n=e.pos();for(;e.more()&&e.peek()>=L.CODES.get("0")&&e.peek()<=L.CODES.get("9");)e.skip(1);let r=e.from(n);return r.length===0||r.length>1&&r.codePointAt(0)===L.CODES.get("0")?-1:r.length>8?-2:parseFloat(r,10)}static isCharClass(e){return e.op===M.Op.LITERAL&&e.runes.length===1||e.op===M.Op.CHAR_CLASS||e.op===M.Op.ANY_CHAR_NOT_NL||e.op===M.Op.ANY_CHAR}static matchRune(e,n){switch(e.op){case M.Op.LITERAL:return e.runes.length===1&&e.runes[0]===n;case M.Op.CHAR_CLASS:for(let r=0;r<e.runes.length;r+=2)if(e.runes[r]<=n&&n<=e.runes[r+1])return!0;return!1;case M.Op.ANY_CHAR_NOT_NL:return n!==L.CODES.get(`
172
+ `)+1&&e[3]===Ce.MAX_RUNE&&(s.op=Te.RUNE_ANY_NOT_NL),r}compile(e){switch(e.op){case M.Op.NO_MATCH:return this.fail();case M.Op.EMPTY_MATCH:return this.nop();case M.Op.LITERAL:if(e.runes.length===0)return this.nop();{let n=null;for(let r of e.runes){let s=this.rune([r],e.flags);n=n===null?s:this.cat(n,s)}return n}case M.Op.CHAR_CLASS:return this.rune(e.runes,e.flags);case M.Op.ANY_CHAR_NOT_NL:return this.rune(t.ANY_RUNE_NOT_NL(),0);case M.Op.ANY_CHAR:return this.rune(t.ANY_RUNE(),0);case M.Op.BEGIN_LINE:return this.empty(Ye.EMPTY_BEGIN_LINE);case M.Op.END_LINE:return this.empty(Ye.EMPTY_END_LINE);case M.Op.BEGIN_TEXT:return this.empty(Ye.EMPTY_BEGIN_TEXT);case M.Op.END_TEXT:return this.empty(Ye.EMPTY_END_TEXT);case M.Op.WORD_BOUNDARY:return this.empty(Ye.EMPTY_WORD_BOUNDARY);case M.Op.NO_WORD_BOUNDARY:return this.empty(Ye.EMPTY_NO_WORD_BOUNDARY);case M.Op.CAPTURE:{let n=this.cap(e.cap<<1),r=this.compile(e.subs[0]),s=this.cap(e.cap<<1|1);return this.cat(this.cat(n,r),s)}case M.Op.STAR:return this.star(this.compile(e.subs[0]),(e.flags&J.NON_GREEDY)!==0);case M.Op.PLUS:return this.plus(this.compile(e.subs[0]),(e.flags&J.NON_GREEDY)!==0);case M.Op.QUEST:return this.quest(this.compile(e.subs[0]),(e.flags&J.NON_GREEDY)!==0);case M.Op.CONCAT:{if(e.subs.length===0)return this.nop();{let n=null;for(let r of e.subs){let s=this.compile(r);n=n===null?s:this.cat(n,s)}return n}}case M.Op.ALTERNATE:{if(e.subs.length===0)return this.nop();{let n=null;for(let r of e.subs){let s=this.compile(r);n=n===null?s:this.alt(n,s)}return n}}default:throw new ip("regexp: unhandled case in compile")}}},hp=class t{static simplify(e){if(e===null)return null;switch(e.op){case M.Op.CAPTURE:case M.Op.CONCAT:case M.Op.ALTERNATE:{let n=e;for(let r=0;r<e.subs.length;r++){let s=e.subs[r],i=t.simplify(s);n===e&&i!==s&&(n=M.fromRegexp(e),n.runes=[],n.subs=e.subs.slice(0,e.subs.length)),n!==e&&(n.subs[r]=i)}return n}case M.Op.STAR:case M.Op.PLUS:case M.Op.QUEST:{let n=t.simplify(e.subs[0]);return t.simplify1(e.op,e.flags,n,e)}case M.Op.REPEAT:{if(e.min===0&&e.max===0)return new M(M.Op.EMPTY_MATCH);let n=t.simplify(e.subs[0]);if(e.max===-1){if(e.min===0)return t.simplify1(M.Op.STAR,e.flags,n,null);if(e.min===1)return t.simplify1(M.Op.PLUS,e.flags,n,null);let s=new M(M.Op.CONCAT),i=[];for(let o=0;o<e.min-1;o++)i.push(n);return i.push(t.simplify1(M.Op.PLUS,e.flags,n,null)),s.subs=i.slice(0),s}if(e.min===1&&e.max===1)return n;let r=null;if(e.min>0){r=[];for(let s=0;s<e.min;s++)r.push(n)}if(e.max>e.min){let s=t.simplify1(M.Op.QUEST,e.flags,n,null);for(let i=e.min+1;i<e.max;i++){let o=new M(M.Op.CONCAT);o.subs=[n,s],s=t.simplify1(M.Op.QUEST,e.flags,o,null)}if(r===null)return s;r.push(s)}if(r!==null){let s=new M(M.Op.CONCAT);return s.subs=r.slice(0),s}return new M(M.Op.NO_MATCH)}}return e}static simplify1(e,n,r,s){return r.op===M.Op.EMPTY_MATCH||e===r.op&&(n&J.NON_GREEDY)===(r.flags&J.NON_GREEDY)?r:(s!==null&&s.op===e&&(s.flags&J.NON_GREEDY)===(n&J.NON_GREEDY)&&r===s.subs[0]||(s=new M(e),s.flags=n,s.subs=[r]),s)}},Ze=class{constructor(e,n){this.sign=e,this.cls=n}},Ub=[48,57],zb=[9,10,12,13,32,32],Wb=[48,57,65,90,95,95,97,122],jb=new Map([["\\d",new Ze(1,Ub)],["\\D",new Ze(-1,Ub)],["\\s",new Ze(1,zb)],["\\S",new Ze(-1,zb)],["\\w",new Ze(1,Wb)],["\\W",new Ze(-1,Wb)]]),qb=[48,57,65,90,97,122],Hb=[65,90,97,122],Vb=[0,127],Gb=[9,9,32,32],Kb=[0,31,127,127],Zb=[48,57],Yb=[33,126],Qb=[97,122],Xb=[32,126],Jb=[33,47,58,64,91,96,123,126],e7=[9,13,32,32],t7=[65,90],n7=[48,57,65,90,95,95,97,122],r7=[48,57,65,70,97,102],s7=new Map([["[:alnum:]",new Ze(1,qb)],["[:^alnum:]",new Ze(-1,qb)],["[:alpha:]",new Ze(1,Hb)],["[:^alpha:]",new Ze(-1,Hb)],["[:ascii:]",new Ze(1,Vb)],["[:^ascii:]",new Ze(-1,Vb)],["[:blank:]",new Ze(1,Gb)],["[:^blank:]",new Ze(-1,Gb)],["[:cntrl:]",new Ze(1,Kb)],["[:^cntrl:]",new Ze(-1,Kb)],["[:digit:]",new Ze(1,Zb)],["[:^digit:]",new Ze(-1,Zb)],["[:graph:]",new Ze(1,Yb)],["[:^graph:]",new Ze(-1,Yb)],["[:lower:]",new Ze(1,Qb)],["[:^lower:]",new Ze(-1,Qb)],["[:print:]",new Ze(1,Xb)],["[:^print:]",new Ze(-1,Xb)],["[:punct:]",new Ze(1,Jb)],["[:^punct:]",new Ze(-1,Jb)],["[:space:]",new Ze(1,e7)],["[:^space:]",new Ze(-1,e7)],["[:upper:]",new Ze(1,t7)],["[:^upper:]",new Ze(-1,t7)],["[:word:]",new Ze(1,n7)],["[:^word:]",new Ze(-1,n7)],["[:xdigit:]",new Ze(1,r7)],["[:^xdigit:]",new Ze(-1,r7)]]),us=class t{static charClassToString(e,n){let r="[";for(let s=0;s<n;s+=2){s>0&&(r+=" ");let i=e[s],o=e[s+1];i===o?r+=`0x${i.toString(16)}`:r+=`0x${i.toString(16)}-0x${o.toString(16)}`}return r+="]",r}static cmp(e,n,r,s){let i=e[n]-r;return i!==0?i:s-e[n+1]}static qsortIntPair(e,n,r){let s=((n+r)/2|0)&-2,i=e[s],o=e[s+1],a=n,l=r;for(;a<=l;){for(;a<r&&t.cmp(e,a,i,o)<0;)a+=2;for(;l>n&&t.cmp(e,l,i,o)>0;)l-=2;if(a<=l){if(a!==l){let c=e[a];e[a]=e[l],e[l]=c,c=e[a+1],e[a+1]=e[l+1],e[l+1]=c}a+=2,l-=2}}n<l&&t.qsortIntPair(e,n,l),a<r&&t.qsortIntPair(e,a,r)}constructor(e=Ye.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;t.qsortIntPair(this.r,0,this.len-2);let e=2;for(let n=2;n<this.len;n+=2){let r=this.r[n],s=this.r[n+1];if(r<=this.r[e-1]+1){s>this.r[e-1]&&(this.r[e-1]=s);continue}this.r[e]=r,this.r[e+1]=s,e+=2}return this.len=e,this}appendLiteral(e,n){return(n&J.FOLD_CASE)!==0?this.appendFoldedRange(e,e):this.appendRange(e,e)}appendRange(e,n){if(this.len>0){for(let r=2;r<=4;r+=2)if(this.len>=r){let s=this.r[this.len-r],i=this.r[this.len-r+1];if(e<=i+1&&s<=n+1)return e<s&&(this.r[this.len-r]=e),n>i&&(this.r[this.len-r+1]=n),this}}return this.r[this.len++]=e,this.r[this.len++]=n,this}appendFoldedRange(e,n){if(e<=Ce.MIN_FOLD&&n>=Ce.MAX_FOLD)return this.appendRange(e,n);if(n<Ce.MIN_FOLD||e>Ce.MAX_FOLD)return this.appendRange(e,n);e<Ce.MIN_FOLD&&(this.appendRange(e,Ce.MIN_FOLD-1),e=Ce.MIN_FOLD),n>Ce.MAX_FOLD&&(this.appendRange(Ce.MAX_FOLD+1,n),n=Ce.MAX_FOLD);for(let r=e;r<=n;r++){this.appendRange(r,r);for(let s=Ce.simpleFold(r);s!==r;s=Ce.simpleFold(s))this.appendRange(s,s)}return this}appendClass(e){for(let n=0;n<e.length;n+=2)this.appendRange(e[n],e[n+1]);return this}appendFoldedClass(e){for(let n=0;n<e.length;n+=2)this.appendFoldedRange(e[n],e[n+1]);return this}appendNegatedClass(e){let n=0;for(let r=0;r<e.length;r+=2){let s=e[r],i=e[r+1];n<=s-1&&this.appendRange(n,s-1),n=i+1}return n<=Ce.MAX_RUNE&&this.appendRange(n,Ce.MAX_RUNE),this}appendTable(e){for(let n=0;n<e.length;++n){let r=e.getLo(n),s=e.getHi(n),i=e.getStride(n);if(i===1){this.appendRange(r,s);continue}for(let o=r;o<=s;o+=i)this.appendRange(o,o)}return this}appendNegatedTable(e){let n=0;for(let r=0;r<e.length;++r){let s=e.getLo(r),i=e.getHi(r),o=e.getStride(r);if(o===1){n<=s-1&&this.appendRange(n,s-1),n=i+1;continue}for(let a=s;a<=i;a+=o)n<=a-1&&this.appendRange(n,a-1),n=a+1}return n<=Ce.MAX_RUNE&&this.appendRange(n,Ce.MAX_RUNE),this}appendTableWithSign(e,n){return n<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,n=0;for(let r=0;r<this.len;r+=2){let s=this.r[r],i=this.r[r+1];e<=s-1&&(this.r[n]=e,this.r[n+1]=s-1,n+=2),e=i+1}return this.len=n,e<=Ce.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=Ce.MAX_RUNE),this}appendClassWithSign(e,n){return n<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(e,n){let r=e.cls;return n&&(r=new t().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,e.sign)}toString(){return t.charClassToString(this.r,this.len)}},Fa=class t{static of(e,n){return new t(e,n)}constructor(e,n){this.first=e,this.second=n}},dp=class{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){let e=this.str.codePointAt(this.position);return this.position+=Ye.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}},pp=class t{static ERR_INTERNAL_ERROR="regexp/syntax: internal error";static ERR_INVALID_CHAR_RANGE="invalid character class range";static ERR_INVALID_ESCAPE="invalid escape sequence";static ERR_INVALID_NAMED_CAPTURE="invalid named capture";static ERR_INVALID_PERL_OP="invalid or unsupported Perl syntax";static ERR_INVALID_REPEAT_OP="invalid nested repetition operator";static ERR_INVALID_REPEAT_SIZE="invalid repeat count";static ERR_MISSING_BRACKET="missing closing ]";static ERR_MISSING_PAREN="missing closing )";static ERR_MISSING_REPEAT_ARGUMENT="missing argument to repetition operator";static ERR_TRAILING_BACKSLASH="trailing backslash at end of expression";static ERR_DUPLICATE_NAMED_CAPTURE="duplicate capture group name";static ERR_UNEXPECTED_PAREN="unexpected )";static ERR_NESTING_DEPTH="expression nests too deeply";static ERR_LARGE="expression too large";static MAX_HEIGHT=1e3;static MAX_SIZE=3355443;static MAX_RUNES=33554432;static ANY_TABLE=new F(new Uint32Array([0,Ce.MAX_RUNE,1]));static unicodeTable(e){return e==="Any"?Fa.of(t.ANY_TABLE,t.ANY_TABLE):xr.CATEGORIES.has(e)?Fa.of(xr.CATEGORIES.get(e),xr.FOLD_CATEGORIES.get(e)):xr.SCRIPTS.has(e)?Fa.of(xr.SCRIPTS.get(e),xr.FOLD_SCRIPT.get(e)):null}static minFoldRune(e){if(e<Ce.MIN_FOLD||e>Ce.MAX_FOLD)return e;let n=e,r=e;for(e=Ce.simpleFold(e);e!==r;e=Ce.simpleFold(e))n>e&&(n=e);return n}static leadingRegexp(e){if(e.op===M.Op.EMPTY_MATCH)return null;if(e.op===M.Op.CONCAT&&e.subs.length>0){let n=e.subs[0];return n.op===M.Op.EMPTY_MATCH?null:n}return e}static literalRegexp(e,n){let r=new M(M.Op.LITERAL);return r.flags=n,r.runes=Ye.stringToRunes(e),r}static parse(e,n){return new t(e,n).parseInternal()}static parseRepeat(e){let n=e.pos();if(!e.more()||!e.lookingAt("{"))return-1;e.skip(1);let r=t.parseInt(e);if(r===-1||!e.more())return-1;let s;if(!e.lookingAt(","))s=r;else{if(e.skip(1),!e.more())return-1;if(e.lookingAt("}"))s=-1;else if((s=t.parseInt(e))===-1)return-1}if(!e.more()||!e.lookingAt("}"))return-1;if(e.skip(1),r<0||r>1e3||s===-2||s>1e3||s>=0&&r>s)throw new wt(t.ERR_INVALID_REPEAT_SIZE,e.from(n));return r<<16|s&Ce.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r!==L.CODES.get("_")&&!Ye.isalnum(r))return!1}return!0}static parseInt(e){let n=e.pos();for(;e.more()&&e.peek()>=L.CODES.get("0")&&e.peek()<=L.CODES.get("9");)e.skip(1);let r=e.from(n);return r.length===0||r.length>1&&r.codePointAt(0)===L.CODES.get("0")?-1:r.length>8?-2:parseFloat(r,10)}static isCharClass(e){return e.op===M.Op.LITERAL&&e.runes.length===1||e.op===M.Op.CHAR_CLASS||e.op===M.Op.ANY_CHAR_NOT_NL||e.op===M.Op.ANY_CHAR}static matchRune(e,n){switch(e.op){case M.Op.LITERAL:return e.runes.length===1&&e.runes[0]===n;case M.Op.CHAR_CLASS:for(let r=0;r<e.runes.length;r+=2)if(e.runes[r]<=n&&n<=e.runes[r+1])return!0;return!1;case M.Op.ANY_CHAR_NOT_NL:return n!==L.CODES.get(`
173
173
  `);case M.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(e,n){switch(e.op){case M.Op.ANY_CHAR:break;case M.Op.ANY_CHAR_NOT_NL:t.matchRune(n,L.CODES.get(`
174
- `))&&(e.op=M.Op.ANY_CHAR);break;case M.Op.CHAR_CLASS:n.op===M.Op.LITERAL?e.runes=new cs(e.runes).appendLiteral(n.runes[0],n.flags).toArray():e.runes=new cs(e.runes).appendClass(n.runes).toArray();break;case M.Op.LITERAL:if(n.runes[0]===e.runes[0]&&n.flags===e.flags)break;e.op=M.Op.CHAR_CLASS,e.runes=new cs().appendLiteral(e.runes[0],e.flags).appendLiteral(n.runes[0],n.flags).toArray();break}}static parseEscape(e){let n=e.pos();if(e.skip(1),!e.more())throw new wt(t.ERR_TRAILING_BACKSLASH);let r=e.pop();e:switch(r){case L.CODES.get("1"):case L.CODES.get("2"):case L.CODES.get("3"):case L.CODES.get("4"):case L.CODES.get("5"):case L.CODES.get("6"):case L.CODES.get("7"):if(!e.more()||e.peek()<L.CODES.get("0")||e.peek()>L.CODES.get("7"))break;case L.CODES.get("0"):{let s=r-L.CODES.get("0");for(let i=1;i<3&&!(!e.more()||e.peek()<L.CODES.get("0")||e.peek()>L.CODES.get("7"));i++)s=s*8+e.peek()-L.CODES.get("0"),e.skip(1);return s}case L.CODES.get("x"):{if(!e.more())break;if(r=e.pop(),r===L.CODES.get("{")){let o=0,a=0;for(;;){if(!e.more())break e;if(r=e.pop(),r===L.CODES.get("}"))break;let l=Ye.unhex(r);if(l<0||(a=a*16+l,a>Ce.MAX_RUNE))break e;o++}if(o===0)break e;return a}let s=Ye.unhex(r);if(!e.more())break;r=e.pop();let i=Ye.unhex(r);if(s<0||i<0)break;return s*16+i}case L.CODES.get("a"):return L.CODES.get("\x07");case L.CODES.get("f"):return L.CODES.get("\f");case L.CODES.get("n"):return L.CODES.get(`
175
- `);case L.CODES.get("r"):return L.CODES.get("\r");case L.CODES.get("t"):return L.CODES.get(" ");case L.CODES.get("v"):return L.CODES.get("\v");default:if(r<=Ce.MAX_ASCII&&!Ye.isalnum(r))return r;break}throw new wt(t.ERR_INVALID_ESCAPE,e.from(n))}static parseClassChar(e,n){if(!e.more())throw new wt(t.ERR_MISSING_BRACKET,e.from(n));return e.lookingAt("\\")?t.parseEscape(e):e.pop()}static concatRunes(e,n){return[...e,...n]}constructor(e,n=0){this.wholeRegexp=e,this.flags=n,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(e){let n=this.free;return n!==null&&n.subs!==null&&n.subs.length>0?(this.free=n.subs[0],n.reinit(),n.op=e):(n=new M(e),this.numRegexp+=1),n}reuse(e){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,e)&&delete this.height[e],e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}checkLimits(e){if(this.numRunes>t.MAX_RUNES)throw new wt(t.ERR_LARGE);this.checkSize(e),this.checkHeight(e)}checkSize(e){if(this.size===null){if(this.repeats===0&&(this.repeats=1),e.op===M.Op.REPEAT){let n=e.max;n===-1&&(n=e.min),n<=0&&(n=1),n>t.MAX_SIZE/this.repeats?this.repeats=t.MAX_SIZE:this.repeats*=n}if(this.numRegexp<t.MAX_SIZE/this.repeats)return;this.size={};for(let n of this.stack)this.checkSize(n)}if(this.calcSize(e,!0)>t.MAX_SIZE)throw new wt(t.ERR_LARGE)}calcSize(e,n=!1){if(!n&&Object.prototype.hasOwnProperty.call(this.size,e))return this.size[e];let r=0;switch(e.op){case M.Op.LITERAL:{r=e.runes.length;break}case M.Op.CAPTURE:case M.Op.STAR:{r=2+this.calcSize(e.subs[0]);break}case M.Op.PLUS:case M.Op.QUEST:{r=1+this.calcSize(e.subs[0]);break}case M.Op.CONCAT:{for(let s of e.subs)r=r+this.calcSize(s);break}case M.Op.ALTERNATE:{for(let s of e.subs)r=r+this.calcSize(s);e.subs.length>1&&(r=r+e.subs.length-1);break}case M.Op.REPEAT:{let s=this.calcSize(e.subs[0]);if(e.max===-1){e.min===0?r=2+s:r=1+e.min*s;break}r=e.max*s+(e.max-e.min);break}}return r=Math.max(1,r),this.size[e]=r,r}checkHeight(e){if(!(this.numRegexp<t.MAX_HEIGHT)){if(this.height===null){this.height={};for(let n of this.stack)this.checkHeight(n)}if(this.calcHeight(e,!0)>t.MAX_HEIGHT)throw new wt(t.ERR_NESTING_DEPTH)}}calcHeight(e,n=!1){if(!n&&Object.prototype.hasOwnProperty.call(this.height,e))return this.height[e];let r=1;for(let s of e.subs){let i=this.calcHeight(s);r<1+i&&(r=1+i)}return this.height[e]=r,r}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,n=e;for(;n>0&&!M.isPseudoOp(this.stack[n-1].op);)n--;let r=this.stack.slice(n,e);return this.stack=this.stack.slice(0,n),r}push(e){if(this.numRunes+=e.runes.length,e.op===M.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=M.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===M.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&Ce.simpleFold(e.runes[0])===e.runes[2]&&Ce.simpleFold(e.runes[2])===e.runes[0]||e.op===M.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&Ce.simpleFold(e.runes[0])===e.runes[1]&&Ce.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|J.FOLD_CASE))return null;e.op=M.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|J.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),this.checkLimits(e),e}maybeConcat(e,n){let r=this.stack.length;if(r<2)return!1;let s=this.stack[r-1],i=this.stack[r-2];return s.op!==M.Op.LITERAL||i.op!==M.Op.LITERAL||(s.flags&J.FOLD_CASE)!==(i.flags&J.FOLD_CASE)?!1:(i.runes=t.concatRunes(i.runes,s.runes),e>=0?(s.runes=[e],s.flags=n,!0):(this.pop(),this.reuse(s),!1))}newLiteral(e,n){let r=this.newRegexp(M.Op.LITERAL);return r.flags=n,(n&J.FOLD_CASE)!==0&&(e=t.minFoldRune(e)),r.runes=[e],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let n=this.newRegexp(e);return n.flags=this.flags,this.push(n)}repeat(e,n,r,s,i,o){let a=this.flags;if((a&J.PERL_X)!==0&&(i.more()&&i.lookingAt("?")&&(i.skip(1),a^=J.NON_GREEDY),o!==-1))throw new wt(t.ERR_INVALID_REPEAT_OP,i.from(o));let l=this.stack.length;if(l===0)throw new wt(t.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));let c=this.stack[l-1];if(M.isPseudoOp(c.op))throw new wt(t.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));let u=this.newRegexp(e);if(u.min=n,u.max=r,u.flags=a,u.subs=[c],this.stack[l-1]=u,this.checkLimits(u),e===M.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new wt(t.ERR_INVALID_REPEAT_SIZE,i.from(s))}repeatIsValid(e,n){if(e.op===M.Op.REPEAT){let r=e.max;if(r===0)return!0;if(r<0&&(r=e.min),r>n)return!1;r>0&&(n=Math.trunc(n/r))}for(let r of e.subs)if(!this.repeatIsValid(r,n))return!1;return!0}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(M.Op.EMPTY_MATCH)):this.push(this.collapse(e,M.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(M.Op.NO_MATCH)):this.push(this.collapse(e,M.Op.ALTERNATE))}cleanAlt(e){e.op===M.Op.CHAR_CLASS&&(e.runes=new cs(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===Ce.MAX_RUNE?(e.runes=[],e.op=M.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===L.CODES.get(`
174
+ `))&&(e.op=M.Op.ANY_CHAR);break;case M.Op.CHAR_CLASS:n.op===M.Op.LITERAL?e.runes=new us(e.runes).appendLiteral(n.runes[0],n.flags).toArray():e.runes=new us(e.runes).appendClass(n.runes).toArray();break;case M.Op.LITERAL:if(n.runes[0]===e.runes[0]&&n.flags===e.flags)break;e.op=M.Op.CHAR_CLASS,e.runes=new us().appendLiteral(e.runes[0],e.flags).appendLiteral(n.runes[0],n.flags).toArray();break}}static parseEscape(e){let n=e.pos();if(e.skip(1),!e.more())throw new wt(t.ERR_TRAILING_BACKSLASH);let r=e.pop();e:switch(r){case L.CODES.get("1"):case L.CODES.get("2"):case L.CODES.get("3"):case L.CODES.get("4"):case L.CODES.get("5"):case L.CODES.get("6"):case L.CODES.get("7"):if(!e.more()||e.peek()<L.CODES.get("0")||e.peek()>L.CODES.get("7"))break;case L.CODES.get("0"):{let s=r-L.CODES.get("0");for(let i=1;i<3&&!(!e.more()||e.peek()<L.CODES.get("0")||e.peek()>L.CODES.get("7"));i++)s=s*8+e.peek()-L.CODES.get("0"),e.skip(1);return s}case L.CODES.get("x"):{if(!e.more())break;if(r=e.pop(),r===L.CODES.get("{")){let o=0,a=0;for(;;){if(!e.more())break e;if(r=e.pop(),r===L.CODES.get("}"))break;let l=Ye.unhex(r);if(l<0||(a=a*16+l,a>Ce.MAX_RUNE))break e;o++}if(o===0)break e;return a}let s=Ye.unhex(r);if(!e.more())break;r=e.pop();let i=Ye.unhex(r);if(s<0||i<0)break;return s*16+i}case L.CODES.get("a"):return L.CODES.get("\x07");case L.CODES.get("f"):return L.CODES.get("\f");case L.CODES.get("n"):return L.CODES.get(`
175
+ `);case L.CODES.get("r"):return L.CODES.get("\r");case L.CODES.get("t"):return L.CODES.get(" ");case L.CODES.get("v"):return L.CODES.get("\v");default:if(r<=Ce.MAX_ASCII&&!Ye.isalnum(r))return r;break}throw new wt(t.ERR_INVALID_ESCAPE,e.from(n))}static parseClassChar(e,n){if(!e.more())throw new wt(t.ERR_MISSING_BRACKET,e.from(n));return e.lookingAt("\\")?t.parseEscape(e):e.pop()}static concatRunes(e,n){return[...e,...n]}constructor(e,n=0){this.wholeRegexp=e,this.flags=n,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(e){let n=this.free;return n!==null&&n.subs!==null&&n.subs.length>0?(this.free=n.subs[0],n.reinit(),n.op=e):(n=new M(e),this.numRegexp+=1),n}reuse(e){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,e)&&delete this.height[e],e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}checkLimits(e){if(this.numRunes>t.MAX_RUNES)throw new wt(t.ERR_LARGE);this.checkSize(e),this.checkHeight(e)}checkSize(e){if(this.size===null){if(this.repeats===0&&(this.repeats=1),e.op===M.Op.REPEAT){let n=e.max;n===-1&&(n=e.min),n<=0&&(n=1),n>t.MAX_SIZE/this.repeats?this.repeats=t.MAX_SIZE:this.repeats*=n}if(this.numRegexp<t.MAX_SIZE/this.repeats)return;this.size={};for(let n of this.stack)this.checkSize(n)}if(this.calcSize(e,!0)>t.MAX_SIZE)throw new wt(t.ERR_LARGE)}calcSize(e,n=!1){if(!n&&Object.prototype.hasOwnProperty.call(this.size,e))return this.size[e];let r=0;switch(e.op){case M.Op.LITERAL:{r=e.runes.length;break}case M.Op.CAPTURE:case M.Op.STAR:{r=2+this.calcSize(e.subs[0]);break}case M.Op.PLUS:case M.Op.QUEST:{r=1+this.calcSize(e.subs[0]);break}case M.Op.CONCAT:{for(let s of e.subs)r=r+this.calcSize(s);break}case M.Op.ALTERNATE:{for(let s of e.subs)r=r+this.calcSize(s);e.subs.length>1&&(r=r+e.subs.length-1);break}case M.Op.REPEAT:{let s=this.calcSize(e.subs[0]);if(e.max===-1){e.min===0?r=2+s:r=1+e.min*s;break}r=e.max*s+(e.max-e.min);break}}return r=Math.max(1,r),this.size[e]=r,r}checkHeight(e){if(!(this.numRegexp<t.MAX_HEIGHT)){if(this.height===null){this.height={};for(let n of this.stack)this.checkHeight(n)}if(this.calcHeight(e,!0)>t.MAX_HEIGHT)throw new wt(t.ERR_NESTING_DEPTH)}}calcHeight(e,n=!1){if(!n&&Object.prototype.hasOwnProperty.call(this.height,e))return this.height[e];let r=1;for(let s of e.subs){let i=this.calcHeight(s);r<1+i&&(r=1+i)}return this.height[e]=r,r}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,n=e;for(;n>0&&!M.isPseudoOp(this.stack[n-1].op);)n--;let r=this.stack.slice(n,e);return this.stack=this.stack.slice(0,n),r}push(e){if(this.numRunes+=e.runes.length,e.op===M.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=M.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===M.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&Ce.simpleFold(e.runes[0])===e.runes[2]&&Ce.simpleFold(e.runes[2])===e.runes[0]||e.op===M.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&Ce.simpleFold(e.runes[0])===e.runes[1]&&Ce.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|J.FOLD_CASE))return null;e.op=M.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|J.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),this.checkLimits(e),e}maybeConcat(e,n){let r=this.stack.length;if(r<2)return!1;let s=this.stack[r-1],i=this.stack[r-2];return s.op!==M.Op.LITERAL||i.op!==M.Op.LITERAL||(s.flags&J.FOLD_CASE)!==(i.flags&J.FOLD_CASE)?!1:(i.runes=t.concatRunes(i.runes,s.runes),e>=0?(s.runes=[e],s.flags=n,!0):(this.pop(),this.reuse(s),!1))}newLiteral(e,n){let r=this.newRegexp(M.Op.LITERAL);return r.flags=n,(n&J.FOLD_CASE)!==0&&(e=t.minFoldRune(e)),r.runes=[e],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let n=this.newRegexp(e);return n.flags=this.flags,this.push(n)}repeat(e,n,r,s,i,o){let a=this.flags;if((a&J.PERL_X)!==0&&(i.more()&&i.lookingAt("?")&&(i.skip(1),a^=J.NON_GREEDY),o!==-1))throw new wt(t.ERR_INVALID_REPEAT_OP,i.from(o));let l=this.stack.length;if(l===0)throw new wt(t.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));let c=this.stack[l-1];if(M.isPseudoOp(c.op))throw new wt(t.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));let u=this.newRegexp(e);if(u.min=n,u.max=r,u.flags=a,u.subs=[c],this.stack[l-1]=u,this.checkLimits(u),e===M.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new wt(t.ERR_INVALID_REPEAT_SIZE,i.from(s))}repeatIsValid(e,n){if(e.op===M.Op.REPEAT){let r=e.max;if(r===0)return!0;if(r<0&&(r=e.min),r>n)return!1;r>0&&(n=Math.trunc(n/r))}for(let r of e.subs)if(!this.repeatIsValid(r,n))return!1;return!0}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(M.Op.EMPTY_MATCH)):this.push(this.collapse(e,M.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(M.Op.NO_MATCH)):this.push(this.collapse(e,M.Op.ALTERNATE))}cleanAlt(e){e.op===M.Op.CHAR_CLASS&&(e.runes=new us(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===Ce.MAX_RUNE?(e.runes=[],e.op=M.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===L.CODES.get(`
176
176
  `)-1&&e.runes[2]===L.CODES.get(`
177
- `)+1&&e.runes[3]===Ce.MAX_RUNE&&(e.runes=[],e.op=M.Op.ANY_CHAR_NOT_NL))}collapse(e,n){if(e.length===1)return e[0];let r=0;for(let a of e)r+=a.op===n?a.subs.length:1;let s=new Array(r).fill(null),i=0;for(let a of e)a.op===n?(s.splice(i,a.subs.length,...a.subs),i+=a.subs.length,this.reuse(a)):s[i++]=a;let o=this.newRegexp(n);if(o.subs=s,n===M.Op.ALTERNATE&&(o.subs=this.factor(o.subs),o.subs.length===1)){let a=o;o=o.subs[0],this.reuse(a)}return o}factor(e){if(e.length<2)return e;let n=0,r=e.length,s=0,i=null,o=0,a=0,l=0;for(let u=0;u<=r;u++){let f=null,h=0,d=0;if(u<r){let p=e[n+u];if(p.op===M.Op.CONCAT&&p.subs.length>0&&(p=p.subs[0]),p.op===M.Op.LITERAL&&(f=p.runes,h=p.runes.length,d=p.flags&J.FOLD_CASE),d===a){let m=0;for(;m<o&&m<h&&i[m]===f[m];)m++;if(m>0){o=m;continue}}}if(u!==l)if(u===l+1)e[s++]=e[n+l];else{let p=this.newRegexp(M.Op.LITERAL);p.flags=a,p.runes=i.slice(0,o);for(let y=l;y<u;y++)e[n+y]=this.removeLeadingString(e[n+y],o),this.checkLimits(e[n+y]);let m=this.collapse(e.slice(n+l,n+u),M.Op.ALTERNATE),g=this.newRegexp(M.Op.CONCAT);g.subs=[p,m],e[s++]=g}l=u,i=f,o=h,a=d}r=s,n=0,l=0,s=0;let c=null;for(let u=0;u<=r;u++){let f=null;if(!(u<r&&(f=t.leadingRegexp(e[n+u]),c!==null&&c.equals(f)&&(t.isCharClass(c)||c.op===M.Op.REPEAT&&c.min===c.max&&t.isCharClass(c.subs[0]))))){if(u!==l)if(u===l+1)e[s++]=e[n+l];else{let h=c;for(let m=l;m<u;m++){let g=m!==l;e[n+m]=this.removeLeadingRegexp(e[n+m],g),this.checkLimits(e[n+m])}let d=this.collapse(e.slice(n+l,n+u),M.Op.ALTERNATE),p=this.newRegexp(M.Op.CONCAT);p.subs=[h,d],e[s++]=p}l=u,c=f}}r=s,n=0,l=0,s=0;for(let u=0;u<=r;u++)if(!(u<r&&t.isCharClass(e[n+u]))){if(u!==l)if(u===l+1)e[s++]=e[n+l];else{let f=l;for(let d=l+1;d<u;d++){let p=e[n+f],m=e[n+d];(p.op<m.op||p.op===m.op&&(p.runes!==null?p.runes.length:0)<(m.runes!==null?m.runes.length:0))&&(f=d)}let h=e[n+l];e[n+l]=e[n+f],e[n+f]=h;for(let d=l+1;d<u;d++)t.mergeCharClass(e[n+l],e[n+d]),this.reuse(e[n+d]);this.cleanAlt(e[n+l]),e[s++]=e[n+l]}u<r&&(e[s++]=e[n+u]),l=u+1}r=s,n=0,l=0,s=0;for(let u=0;u<r;++u)u+1<r&&e[n+u].op===M.Op.EMPTY_MATCH&&e[n+u+1].op===M.Op.EMPTY_MATCH||(e[s++]=e[n+u]);return r=s,n=0,e.slice(n,r)}removeLeadingString(e,n){if(e.op===M.Op.CONCAT&&e.subs.length>0){let r=this.removeLeadingString(e.subs[0],n);if(e.subs[0]=r,r.op===M.Op.EMPTY_MATCH)switch(this.reuse(r),e.subs.length){case 0:case 1:e.op=M.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let s=e;e=e.subs[1],this.reuse(s);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===M.Op.LITERAL&&(e.runes=e.runes.slice(n,e.runes.length),e.runes.length===0&&(e.op=M.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,n){if(e.op===M.Op.CONCAT&&e.subs.length>0){switch(n&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:{e.op=M.Op.EMPTY_MATCH,e.subs=M.emptySubs();break}case 1:{let r=e;e=e.subs[0],this.reuse(r);break}}return e}return n&&this.reuse(e),this.newRegexp(M.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&J.LITERAL)!==0)return t.literalRegexp(this.wholeRegexp,this.flags);let e=-1,n=-1,r=-1,s=new dp(this.wholeRegexp);for(;s.more();){let o=-1;e:switch(s.peek()){case L.CODES.get("("):if((this.flags&J.PERL_X)!==0&&s.lookingAt("(?")){this.parsePerlFlags(s);break}this.op(M.Op.LEFT_PAREN).cap=++this.numCap,s.skip(1);break;case L.CODES.get("|"):this.parseVerticalBar(),s.skip(1);break;case L.CODES.get(")"):this.parseRightParen(),s.skip(1);break;case L.CODES.get("^"):(this.flags&J.ONE_LINE)!==0?this.op(M.Op.BEGIN_TEXT):this.op(M.Op.BEGIN_LINE),s.skip(1);break;case L.CODES.get("$"):(this.flags&J.ONE_LINE)!==0?this.op(M.Op.END_TEXT).flags|=J.WAS_DOLLAR:this.op(M.Op.END_LINE),s.skip(1);break;case L.CODES.get("."):(this.flags&J.DOT_NL)!==0?this.op(M.Op.ANY_CHAR):this.op(M.Op.ANY_CHAR_NOT_NL),s.skip(1);break;case L.CODES.get("["):this.parseClass(s);break;case L.CODES.get("*"):case L.CODES.get("+"):case L.CODES.get("?"):{o=s.pos();let a=null;switch(s.pop()){case L.CODES.get("*"):a=M.Op.STAR;break;case L.CODES.get("+"):a=M.Op.PLUS;break;case L.CODES.get("?"):a=M.Op.QUEST;break}this.repeat(a,n,r,o,s,e);break}case L.CODES.get("{"):{o=s.pos();let a=t.parseRepeat(s);if(a<0){s.rewindTo(o),this.literal(s.pop());break}n=a>>16,r=(a&Ce.MAX_BMP)<<16>>16,this.repeat(M.Op.REPEAT,n,r,o,s,e);break}case L.CODES.get("\\"):{let a=s.pos();if(s.skip(1),(this.flags&J.PERL_X)!==0&&s.more())switch(s.pop()){case L.CODES.get("A"):this.op(M.Op.BEGIN_TEXT);break e;case L.CODES.get("b"):this.op(M.Op.WORD_BOUNDARY);break e;case L.CODES.get("B"):this.op(M.Op.NO_WORD_BOUNDARY);break e;case L.CODES.get("C"):throw new wt(t.ERR_INVALID_ESCAPE,"\\C");case L.CODES.get("Q"):{let f=s.rest(),h=f.indexOf("\\E");h>=0&&(f=f.substring(0,h)),s.skipString(f),s.skipString("\\E");let d=0;for(;d<f.length;){let p=f.codePointAt(d);this.literal(p),d+=Ye.charCount(p)}break e}case L.CODES.get("z"):this.op(M.Op.END_TEXT);break e;default:s.rewindTo(a);break}let l=this.newRegexp(M.Op.CHAR_CLASS);if(l.flags=this.flags,s.lookingAt("\\p")||s.lookingAt("\\P")){let u=new cs;if(this.parseUnicodeClass(s,u)){l.runes=u.toArray(),this.push(l);break e}}let c=new cs;if(this.parsePerlClassEscape(s,c)){l.runes=c.toArray(),this.push(l);break e}s.rewindTo(a),this.reuse(l),this.literal(t.parseEscape(s));break}default:this.literal(s.pop());break}e=o}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new wt(t.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(e){let n=e.pos(),r=e.rest();if(r.startsWith("(?P<")||r.startsWith("(?<")){let a=r.charAt(2)==="P"?4:3,l=r.indexOf(">");if(l<0)throw new wt(t.ERR_INVALID_NAMED_CAPTURE,r);let c=r.substring(a,l);if(e.skipString(c),e.skip(a+1),!t.isValidCaptureName(c))throw new wt(t.ERR_INVALID_NAMED_CAPTURE,r.substring(0,l+1));let u=this.op(M.Op.LEFT_PAREN);if(u.cap=++this.numCap,this.namedGroups[c])throw new wt(t.ERR_DUPLICATE_NAMED_CAPTURE,c);this.namedGroups[c]=this.numCap,u.name=c;return}e.skip(2);let s=this.flags,i=1,o=!1;e:for(;e.more();){let a=e.pop();switch(a){case L.CODES.get("i"):s|=J.FOLD_CASE,o=!0;break;case L.CODES.get("m"):s&=-17,o=!0;break;case L.CODES.get("s"):s|=J.DOT_NL,o=!0;break;case L.CODES.get("U"):s|=J.NON_GREEDY,o=!0;break;case L.CODES.get("-"):if(i<0)break e;i=-1,s=~s,o=!1;break;case L.CODES.get(":"):case L.CODES.get(")"):if(i<0){if(!o)break e;s=~s}a===L.CODES.get(":")&&this.op(M.Op.LEFT_PAREN),this.flags=s;return;default:break e}}throw new wt(t.ERR_INVALID_PERL_OP,e.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(M.Op.VERTICAL_BAR)}swapVerticalBar(){let e=this.stack.length;if(e>=3&&this.stack[e-2].op===M.Op.VERTICAL_BAR&&t.isCharClass(this.stack[e-1])&&t.isCharClass(this.stack[e-3])){let n=this.stack[e-1],r=this.stack[e-3];if(n.op>r.op){let s=r;r=n,n=s,this.stack[e-3]=r}return t.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(e>=2){let n=this.stack[e-1],r=this.stack[e-2];if(r.op===M.Op.VERTICAL_BAR)return e>=3&&this.cleanAlt(this.stack[e-3]),this.stack[e-2]=n,this.stack[e-1]=r,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new wt(t.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let n=this.pop(),r=this.pop();if(r.op!==M.Op.LEFT_PAREN)throw new wt(t.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=r.flags,r.cap===0?this.push(n):(r.op=M.Op.CAPTURE,r.subs=[n],this.push(r))}parsePerlClassEscape(e,n){let r=e.pos();if((this.flags&J.PERL_X)===0||!e.more()||e.pop()!==L.CODES.get("\\")||!e.more())return!1;e.pop();let s=e.from(r),i=jb.has(s)?jb.get(s):null;return i===null?!1:(n.appendGroup(i,(this.flags&J.FOLD_CASE)!==0),!0)}parseNamedClass(e,n){let r=e.rest(),s=r.indexOf(":]");if(s<0)return!1;let i=r.substring(0,s+2);e.skipString(i);let o=s7.has(i)?s7.get(i):null;if(o===null)throw new wt(t.ERR_INVALID_CHAR_RANGE,i);return n.appendGroup(o,(this.flags&J.FOLD_CASE)!==0),!0}parseUnicodeClass(e,n){let r=e.pos();if((this.flags&J.UNICODE_GROUPS)===0||!e.lookingAt("\\p")&&!e.lookingAt("\\P"))return!1;e.skip(1);let s=1,i=e.pop();if(i===L.CODES.get("P")&&(s=-1),!e.more())throw e.rewindTo(r),new wt(t.ERR_INVALID_CHAR_RANGE,e.rest());i=e.pop();let o;if(i!==L.CODES.get("{"))o=Ye.runeToString(i);else{let u=e.rest(),f=u.indexOf("}");if(f<0)throw e.rewindTo(r),new wt(t.ERR_INVALID_CHAR_RANGE,e.rest());o=u.substring(0,f),e.skipString(o),e.skip(1)}o.length!==0&&o.codePointAt(0)===L.CODES.get("^")&&(s=0-s,o=o.substring(1));let a=t.unicodeTable(o);if(a===null)throw new wt(t.ERR_INVALID_CHAR_RANGE,e.from(r));let l=a.first,c=a.second;if((this.flags&J.FOLD_CASE)===0||c===null)n.appendTableWithSign(l,s);else{let u=new cs().appendTable(l).appendTable(c).cleanClass().toArray();n.appendClassWithSign(u,s)}return!0}parseClass(e){let n=e.pos();e.skip(1);let r=this.newRegexp(M.Op.CHAR_CLASS);r.flags=this.flags;let s=new cs,i=1;e.more()&&e.lookingAt("^")&&(i=-1,e.skip(1),(this.flags&J.CLASS_NL)===0&&s.appendRange(L.CODES.get(`
177
+ `)+1&&e.runes[3]===Ce.MAX_RUNE&&(e.runes=[],e.op=M.Op.ANY_CHAR_NOT_NL))}collapse(e,n){if(e.length===1)return e[0];let r=0;for(let a of e)r+=a.op===n?a.subs.length:1;let s=new Array(r).fill(null),i=0;for(let a of e)a.op===n?(s.splice(i,a.subs.length,...a.subs),i+=a.subs.length,this.reuse(a)):s[i++]=a;let o=this.newRegexp(n);if(o.subs=s,n===M.Op.ALTERNATE&&(o.subs=this.factor(o.subs),o.subs.length===1)){let a=o;o=o.subs[0],this.reuse(a)}return o}factor(e){if(e.length<2)return e;let n=0,r=e.length,s=0,i=null,o=0,a=0,l=0;for(let u=0;u<=r;u++){let f=null,h=0,d=0;if(u<r){let p=e[n+u];if(p.op===M.Op.CONCAT&&p.subs.length>0&&(p=p.subs[0]),p.op===M.Op.LITERAL&&(f=p.runes,h=p.runes.length,d=p.flags&J.FOLD_CASE),d===a){let m=0;for(;m<o&&m<h&&i[m]===f[m];)m++;if(m>0){o=m;continue}}}if(u!==l)if(u===l+1)e[s++]=e[n+l];else{let p=this.newRegexp(M.Op.LITERAL);p.flags=a,p.runes=i.slice(0,o);for(let y=l;y<u;y++)e[n+y]=this.removeLeadingString(e[n+y],o),this.checkLimits(e[n+y]);let m=this.collapse(e.slice(n+l,n+u),M.Op.ALTERNATE),g=this.newRegexp(M.Op.CONCAT);g.subs=[p,m],e[s++]=g}l=u,i=f,o=h,a=d}r=s,n=0,l=0,s=0;let c=null;for(let u=0;u<=r;u++){let f=null;if(!(u<r&&(f=t.leadingRegexp(e[n+u]),c!==null&&c.equals(f)&&(t.isCharClass(c)||c.op===M.Op.REPEAT&&c.min===c.max&&t.isCharClass(c.subs[0]))))){if(u!==l)if(u===l+1)e[s++]=e[n+l];else{let h=c;for(let m=l;m<u;m++){let g=m!==l;e[n+m]=this.removeLeadingRegexp(e[n+m],g),this.checkLimits(e[n+m])}let d=this.collapse(e.slice(n+l,n+u),M.Op.ALTERNATE),p=this.newRegexp(M.Op.CONCAT);p.subs=[h,d],e[s++]=p}l=u,c=f}}r=s,n=0,l=0,s=0;for(let u=0;u<=r;u++)if(!(u<r&&t.isCharClass(e[n+u]))){if(u!==l)if(u===l+1)e[s++]=e[n+l];else{let f=l;for(let d=l+1;d<u;d++){let p=e[n+f],m=e[n+d];(p.op<m.op||p.op===m.op&&(p.runes!==null?p.runes.length:0)<(m.runes!==null?m.runes.length:0))&&(f=d)}let h=e[n+l];e[n+l]=e[n+f],e[n+f]=h;for(let d=l+1;d<u;d++)t.mergeCharClass(e[n+l],e[n+d]),this.reuse(e[n+d]);this.cleanAlt(e[n+l]),e[s++]=e[n+l]}u<r&&(e[s++]=e[n+u]),l=u+1}r=s,n=0,l=0,s=0;for(let u=0;u<r;++u)u+1<r&&e[n+u].op===M.Op.EMPTY_MATCH&&e[n+u+1].op===M.Op.EMPTY_MATCH||(e[s++]=e[n+u]);return r=s,n=0,e.slice(n,r)}removeLeadingString(e,n){if(e.op===M.Op.CONCAT&&e.subs.length>0){let r=this.removeLeadingString(e.subs[0],n);if(e.subs[0]=r,r.op===M.Op.EMPTY_MATCH)switch(this.reuse(r),e.subs.length){case 0:case 1:e.op=M.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let s=e;e=e.subs[1],this.reuse(s);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===M.Op.LITERAL&&(e.runes=e.runes.slice(n,e.runes.length),e.runes.length===0&&(e.op=M.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,n){if(e.op===M.Op.CONCAT&&e.subs.length>0){switch(n&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:{e.op=M.Op.EMPTY_MATCH,e.subs=M.emptySubs();break}case 1:{let r=e;e=e.subs[0],this.reuse(r);break}}return e}return n&&this.reuse(e),this.newRegexp(M.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&J.LITERAL)!==0)return t.literalRegexp(this.wholeRegexp,this.flags);let e=-1,n=-1,r=-1,s=new dp(this.wholeRegexp);for(;s.more();){let o=-1;e:switch(s.peek()){case L.CODES.get("("):if((this.flags&J.PERL_X)!==0&&s.lookingAt("(?")){this.parsePerlFlags(s);break}this.op(M.Op.LEFT_PAREN).cap=++this.numCap,s.skip(1);break;case L.CODES.get("|"):this.parseVerticalBar(),s.skip(1);break;case L.CODES.get(")"):this.parseRightParen(),s.skip(1);break;case L.CODES.get("^"):(this.flags&J.ONE_LINE)!==0?this.op(M.Op.BEGIN_TEXT):this.op(M.Op.BEGIN_LINE),s.skip(1);break;case L.CODES.get("$"):(this.flags&J.ONE_LINE)!==0?this.op(M.Op.END_TEXT).flags|=J.WAS_DOLLAR:this.op(M.Op.END_LINE),s.skip(1);break;case L.CODES.get("."):(this.flags&J.DOT_NL)!==0?this.op(M.Op.ANY_CHAR):this.op(M.Op.ANY_CHAR_NOT_NL),s.skip(1);break;case L.CODES.get("["):this.parseClass(s);break;case L.CODES.get("*"):case L.CODES.get("+"):case L.CODES.get("?"):{o=s.pos();let a=null;switch(s.pop()){case L.CODES.get("*"):a=M.Op.STAR;break;case L.CODES.get("+"):a=M.Op.PLUS;break;case L.CODES.get("?"):a=M.Op.QUEST;break}this.repeat(a,n,r,o,s,e);break}case L.CODES.get("{"):{o=s.pos();let a=t.parseRepeat(s);if(a<0){s.rewindTo(o),this.literal(s.pop());break}n=a>>16,r=(a&Ce.MAX_BMP)<<16>>16,this.repeat(M.Op.REPEAT,n,r,o,s,e);break}case L.CODES.get("\\"):{let a=s.pos();if(s.skip(1),(this.flags&J.PERL_X)!==0&&s.more())switch(s.pop()){case L.CODES.get("A"):this.op(M.Op.BEGIN_TEXT);break e;case L.CODES.get("b"):this.op(M.Op.WORD_BOUNDARY);break e;case L.CODES.get("B"):this.op(M.Op.NO_WORD_BOUNDARY);break e;case L.CODES.get("C"):throw new wt(t.ERR_INVALID_ESCAPE,"\\C");case L.CODES.get("Q"):{let f=s.rest(),h=f.indexOf("\\E");h>=0&&(f=f.substring(0,h)),s.skipString(f),s.skipString("\\E");let d=0;for(;d<f.length;){let p=f.codePointAt(d);this.literal(p),d+=Ye.charCount(p)}break e}case L.CODES.get("z"):this.op(M.Op.END_TEXT);break e;default:s.rewindTo(a);break}let l=this.newRegexp(M.Op.CHAR_CLASS);if(l.flags=this.flags,s.lookingAt("\\p")||s.lookingAt("\\P")){let u=new us;if(this.parseUnicodeClass(s,u)){l.runes=u.toArray(),this.push(l);break e}}let c=new us;if(this.parsePerlClassEscape(s,c)){l.runes=c.toArray(),this.push(l);break e}s.rewindTo(a),this.reuse(l),this.literal(t.parseEscape(s));break}default:this.literal(s.pop());break}e=o}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new wt(t.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(e){let n=e.pos(),r=e.rest();if(r.startsWith("(?P<")||r.startsWith("(?<")){let a=r.charAt(2)==="P"?4:3,l=r.indexOf(">");if(l<0)throw new wt(t.ERR_INVALID_NAMED_CAPTURE,r);let c=r.substring(a,l);if(e.skipString(c),e.skip(a+1),!t.isValidCaptureName(c))throw new wt(t.ERR_INVALID_NAMED_CAPTURE,r.substring(0,l+1));let u=this.op(M.Op.LEFT_PAREN);if(u.cap=++this.numCap,this.namedGroups[c])throw new wt(t.ERR_DUPLICATE_NAMED_CAPTURE,c);this.namedGroups[c]=this.numCap,u.name=c;return}e.skip(2);let s=this.flags,i=1,o=!1;e:for(;e.more();){let a=e.pop();switch(a){case L.CODES.get("i"):s|=J.FOLD_CASE,o=!0;break;case L.CODES.get("m"):s&=-17,o=!0;break;case L.CODES.get("s"):s|=J.DOT_NL,o=!0;break;case L.CODES.get("U"):s|=J.NON_GREEDY,o=!0;break;case L.CODES.get("-"):if(i<0)break e;i=-1,s=~s,o=!1;break;case L.CODES.get(":"):case L.CODES.get(")"):if(i<0){if(!o)break e;s=~s}a===L.CODES.get(":")&&this.op(M.Op.LEFT_PAREN),this.flags=s;return;default:break e}}throw new wt(t.ERR_INVALID_PERL_OP,e.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(M.Op.VERTICAL_BAR)}swapVerticalBar(){let e=this.stack.length;if(e>=3&&this.stack[e-2].op===M.Op.VERTICAL_BAR&&t.isCharClass(this.stack[e-1])&&t.isCharClass(this.stack[e-3])){let n=this.stack[e-1],r=this.stack[e-3];if(n.op>r.op){let s=r;r=n,n=s,this.stack[e-3]=r}return t.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(e>=2){let n=this.stack[e-1],r=this.stack[e-2];if(r.op===M.Op.VERTICAL_BAR)return e>=3&&this.cleanAlt(this.stack[e-3]),this.stack[e-2]=n,this.stack[e-1]=r,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new wt(t.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let n=this.pop(),r=this.pop();if(r.op!==M.Op.LEFT_PAREN)throw new wt(t.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=r.flags,r.cap===0?this.push(n):(r.op=M.Op.CAPTURE,r.subs=[n],this.push(r))}parsePerlClassEscape(e,n){let r=e.pos();if((this.flags&J.PERL_X)===0||!e.more()||e.pop()!==L.CODES.get("\\")||!e.more())return!1;e.pop();let s=e.from(r),i=jb.has(s)?jb.get(s):null;return i===null?!1:(n.appendGroup(i,(this.flags&J.FOLD_CASE)!==0),!0)}parseNamedClass(e,n){let r=e.rest(),s=r.indexOf(":]");if(s<0)return!1;let i=r.substring(0,s+2);e.skipString(i);let o=s7.has(i)?s7.get(i):null;if(o===null)throw new wt(t.ERR_INVALID_CHAR_RANGE,i);return n.appendGroup(o,(this.flags&J.FOLD_CASE)!==0),!0}parseUnicodeClass(e,n){let r=e.pos();if((this.flags&J.UNICODE_GROUPS)===0||!e.lookingAt("\\p")&&!e.lookingAt("\\P"))return!1;e.skip(1);let s=1,i=e.pop();if(i===L.CODES.get("P")&&(s=-1),!e.more())throw e.rewindTo(r),new wt(t.ERR_INVALID_CHAR_RANGE,e.rest());i=e.pop();let o;if(i!==L.CODES.get("{"))o=Ye.runeToString(i);else{let u=e.rest(),f=u.indexOf("}");if(f<0)throw e.rewindTo(r),new wt(t.ERR_INVALID_CHAR_RANGE,e.rest());o=u.substring(0,f),e.skipString(o),e.skip(1)}o.length!==0&&o.codePointAt(0)===L.CODES.get("^")&&(s=0-s,o=o.substring(1));let a=t.unicodeTable(o);if(a===null)throw new wt(t.ERR_INVALID_CHAR_RANGE,e.from(r));let l=a.first,c=a.second;if((this.flags&J.FOLD_CASE)===0||c===null)n.appendTableWithSign(l,s);else{let u=new us().appendTable(l).appendTable(c).cleanClass().toArray();n.appendClassWithSign(u,s)}return!0}parseClass(e){let n=e.pos();e.skip(1);let r=this.newRegexp(M.Op.CHAR_CLASS);r.flags=this.flags;let s=new us,i=1;e.more()&&e.lookingAt("^")&&(i=-1,e.skip(1),(this.flags&J.CLASS_NL)===0&&s.appendRange(L.CODES.get(`
178
178
  `),L.CODES.get(`
179
179
  `)));let o=!0;for(;!e.more()||e.peek()!==L.CODES.get("]")||o;){if(e.more()&&e.lookingAt("-")&&(this.flags&J.PERL_X)===0&&!o){let u=e.rest();if(u==="-"||!u.startsWith("-]"))throw e.rewindTo(n),new wt(t.ERR_INVALID_CHAR_RANGE,e.rest())}o=!1;let a=e.pos();if(e.lookingAt("[:")){if(this.parseNamedClass(e,s))continue;e.rewindTo(a)}if(this.parseUnicodeClass(e,s)||this.parsePerlClassEscape(e,s))continue;e.rewindTo(a);let l=t.parseClassChar(e,n),c=l;if(e.more()&&e.lookingAt("-")){if(e.skip(1),e.more()&&e.lookingAt("]"))e.skip(-1);else if(c=t.parseClassChar(e,n),c<l)throw new wt(t.ERR_INVALID_CHAR_RANGE,e.from(a))}(this.flags&J.FOLD_CASE)===0?s.appendRange(l,c):s.appendFoldedRange(l,c)}e.skip(1),s.cleanClass(),i<0&&s.negateClass(),r.runes=s.toArray(),this.push(r)}},mp=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,n){return this.value===e?(this.value=n,!0):!1}},gp=class t{static initTest(e){let n=t.compile(e),r=new t(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(e){return t.compileImpl(e,J.PERL,!1)}static compilePOSIX(e){return t.compileImpl(e,J.POSIX,!0)}static compileImpl(e,n,r){let s=pp.parse(e,n),i=s.maxCap();s=hp.simplify(s);let o=fp.compileRegexp(s),a=new t(e,o,i,r),[l,c]=o.prefix();return a.prefixComplete=l,a.prefix=c,a.prefixUTF8=Ye.stringToUtf8ByteArray(a.prefix),a.prefix.length>0&&(a.prefixRune=a.prefix.codePointAt(0)),a.namedGroups=s.namedGroups,a}static match(e,n){return t.compile(e).match(n)}constructor(e,n,r=0,s=0){this.expr=e,this.prog=n,this.numSubexp=r,this.longest=s,this.cond=n.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new mp,this.dfa=new cp(n)}executeEngine(e,n,r,s){if(s>0)return this.doExecuteNFA(e,n,r,s);let i=this.dfa.match(e,n,r);return i!==null?i?[]:null:this.doExecuteNFA(e,n,r,s)}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,n){let r=this.pooled.get();do r=this.pooled.get(),!n&&r&&(e=$a.fromMachine(e),n=!0),e.next!==r&&(e.next=r);while(!this.pooled.compareAndSet(r,e))}toString(){return this.expr}doExecuteNFA(e,n,r,s){let i=this.get(),o=!1;i?i.next!==null&&(i=$a.fromMachine(i),o=!0):(i=$a.fromRE2(this),o=!0),i.init(s);let a=i.match(e,n,r)?i.submatches():null;return this.put(i,o),a}match(e){return this.executeEngine(Tt.fromUTF16(e),0,J.UNANCHORED,0)!==null}matchWithGroup(e,n,r,s,i){return e instanceof Gs||(e=So.utf16(e)),this.matchMachineInput(e,n,r,s,i)}matchMachineInput(e,n,r,s,i){if(n>r)return[!1,null];let o=e.isUTF16Encoding()?Tt.fromUTF16(e.asCharSequence(),0,r):Tt.fromUTF8(e.asBytes(),0,r),a=this.executeEngine(o,n,s,2*i);return a===null?[!1,null]:[!0,a]}matchUTF8(e){return this.executeEngine(Tt.fromUTF8(e),0,J.UNANCHORED,0)!==null}replaceAll(e,n){return this.replaceAllFunc(e,()=>n,2*e.length+1)}replaceFirst(e,n){return this.replaceAllFunc(e,()=>n,1)}replaceAllFunc(e,n,r){let s=0,i=0,o="",a=Tt.fromUTF16(e),l=0;for(;i<=e.length;){let c=this.executeEngine(a,i,J.UNANCHORED,2);if(c===null||c.length===0)break;o+=e.substring(s,c[0]),(c[1]>s||c[0]===0)&&(o+=n(e.substring(c[0],c[1])),l++),s=c[1];let u=a.step(i)&7;if(i+u>c[1]?i+=u:i+1>c[1]?i++:i=c[1],l>=r)break}return o+=e.substring(s),o}pad(e){if(e===null)return null;let n=(1+this.numSubexp)*2;if(e.length<n){let r=new Array(n).fill(-1);for(let s=0;s<e.length;s++)r[s]=e[s];e=r}return e}allMatches(e,n,r=s=>s){let s=[],i=e.endPos();n<0&&(n=i+1);let o=0,a=0,l=-1;for(;a<n&&o<=i;){let c=this.executeEngine(e,o,J.UNANCHORED,this.prog.numCap);if(c===null||c.length===0)break;let u=!0;if(c[1]===o){c[0]===l&&(u=!1);let f=e.step(o);f<0?o=i+1:o+=f&7}else o=c[1];l=c[1],u&&(s.push(r(this.pad(c))),a++)}return s}findUTF8(e){let n=this.executeEngine(Tt.fromUTF8(e),0,J.UNANCHORED,2);return n===null?null:e.slice(n[0],n[1])}findUTF8Index(e){let n=this.executeEngine(Tt.fromUTF8(e),0,J.UNANCHORED,2);return n===null?null:n.slice(0,2)}find(e){let n=this.executeEngine(Tt.fromUTF16(e),0,J.UNANCHORED,2);return n===null?"":e.substring(n[0],n[1])}findIndex(e){return this.executeEngine(Tt.fromUTF16(e),0,J.UNANCHORED,2)}findUTF8Submatch(e){let n=this.executeEngine(Tt.fromUTF8(e),0,J.UNANCHORED,this.prog.numCap);if(n===null)return null;let r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<n.length&&n[2*s]>=0&&(r[s]=e.slice(n[2*s],n[2*s+1]));return r}findUTF8SubmatchIndex(e){return this.pad(this.executeEngine(Tt.fromUTF8(e),0,J.UNANCHORED,this.prog.numCap))}findSubmatch(e){let n=this.executeEngine(Tt.fromUTF16(e),0,J.UNANCHORED,this.prog.numCap);if(n===null)return null;let r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<n.length&&n[2*s]>=0&&(r[s]=e.substring(n[2*s],n[2*s+1]));return r}findSubmatchIndex(e){return this.pad(this.executeEngine(Tt.fromUTF16(e),0,J.UNANCHORED,this.prog.numCap))}findAllUTF8(e,n){let r=this.allMatches(Tt.fromUTF8(e),n,s=>e.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(e,n){let r=this.allMatches(Tt.fromUTF8(e),n,s=>s.slice(0,2));return r.length===0?null:r}findAll(e,n){let r=this.allMatches(Tt.fromUTF16(e),n,s=>e.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(e,n){let r=this.allMatches(Tt.fromUTF16(e),n,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(e,n){let r=this.allMatches(Tt.fromUTF8(e),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let o=0;o<i.length;o++)s[2*o]>=0&&(i[o]=e.slice(s[2*o],s[2*o+1]));return i});return r.length===0?null:r}findAllUTF8SubmatchIndex(e,n){let r=this.allMatches(Tt.fromUTF8(e),n);return r.length===0?null:r}findAllSubmatch(e,n){let r=this.allMatches(Tt.fromUTF16(e),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let o=0;o<i.length;o++)s[2*o]>=0&&(i[o]=e.substring(s[2*o],s[2*o+1]));return i});return r.length===0?null:r}findAllSubmatchIndex(e,n){let r=this.allMatches(Tt.fromUTF16(e),n);return r.length===0?null:r}},yp=class t{static isUpperCaseAlpha(e){return"A"<=e&&e<="Z"}static isHexadecimal(e){return"0"<=e&&e<="9"||"A"<=e&&e<="F"||"a"<=e&&e<="f"}static getUtf8CharSize(e){let n=e.charCodeAt(0);return n<128?1:n<2048?2:n<65536?3:4}static translate(e){if(typeof e!="string")return e;let n="",r=!1,s=e.length;s===0&&(n="(?:)",r=!0);let i=0;for(;i<s;){let o=e[i];if(o==="\\"){if(i+1<s)switch(o=e[i+1],o){case"\\":{n+="\\\\",i+=2;continue}case"c":{if(i+2<s){let l=e[i+2];if(t.isUpperCaseAlpha(l)){n+="\\x",n+=(l.charCodeAt(0)-64>>4).toString(16).toUpperCase(),n+=(l.charCodeAt(0)-64&15).toString(16).toUpperCase(),i+=3,r=!0;continue}}n+="\\c",i+=2;continue}case"u":{if(i+2<s){let l=e[i+2];if(t.isHexadecimal(l)){n+="\\x{"+l,i+=3;for(let c=0;c<3&&i<s&&(l=e[i],!!t.isHexadecimal(l));++i,++c)n+=l;n+="}",r=!0;continue}else if(l==="{"){n+="\\x",i+=2,r=!0;continue}}n+="\\u",i+=2;continue}default:{n+="\\";let l=t.getUtf8CharSize(o);n+=e.substring(i+1,i+1+l),i+=l+1;continue}}}else if(o==="/"){n+="\\/",i+=1,r=!0;continue}else if(o==="("&&i+2<s&&e[i+1]==="?"&&e[i+2]==="<"&&(i+3>=s||e[i+3]!=="="&&e[i+3]!=="!")){n+="(?P<",i+=3,r=!0;continue}let a=t.getUtf8CharSize(o);n+=e.substring(i,i+a),i+=a}return r?n:e}},Ks=class t{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return Ye.quoteMeta(e)}static quoteReplacement(e,n=!1){return Tc.quoteReplacement(e,n)}static translateRegExp(e){return yp.translate(e)}static compile(e,n=0){let r=e;if((n&t.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&t.DOTALL)!==0&&(r=`(?s)${r}`),(n&t.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(t.MULTILINE|t.DOTALL|t.CASE_INSENSITIVE|t.DISABLE_UNICODE_GROUPS|t.LONGEST_MATCH))!==0)throw new op("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH");let s=J.PERL;(n&t.DISABLE_UNICODE_GROUPS)!==0&&(s&=-129);let i=new t(e,n);return i.re2Input=gp.compileImpl(r,s,(n&t.LONGEST_MATCH)!==0),i}static matches(e,n){return t.compile(e).testExact(n)}static initTest(e,n,r){if(e==null)throw new Error("pattern is null");if(r==null)throw new Error("re2 is null");let s=new t(e,n);return s.re2Input=r,s}constructor(e,n){this.patternInput=e,this.flagsInput=n}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.testExact(e)}matcher(e){return Array.isArray(e)&&(e=So.utf8(e)),new Tc(this,e)}test(e){return Array.isArray(e)?this.re2Input.matchUTF8(e):this.re2Input.match(e)}testExact(e){let n=Array.isArray(e)?Tt.fromUTF8(e):Tt.fromUTF16(e);return this.re2Input.executeEngine(n,0,J.ANCHOR_BOTH,0)!==null}split(e,n=0){let r=this.matcher(e),s=[],i=0,o=0;for(;r.find();){if(o===0&&r.end()===0){o=r.end();continue}if(n>0&&s.length===n-1)break;if(o===r.start()){if(n===0){i+=1,o=r.end();continue}}else for(;i>0;)s.push(""),i-=1;s.push(r.substring(o,r.start())),o=r.end()}if(n===0&&o!==r.inputLength()){for(;i>0;)s.push(""),i-=1;s.push(r.substring(o,r.inputLength()))}return(n!==0||s.length===0)&&s.push(r.substring(o,r.inputLength())),s}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}});function qO(t){let e=0;return t.includes("i")&&(e|=Ks.CASE_INSENSITIVE),t.includes("m")&&(e|=Ks.MULTILINE),t.includes("s")&&(e|=Ks.DOTALL),e}function HO(t){return Ks.translateRegExp(t)}function X(t,e=""){return new Ic(t,e)}var Ic,Os,a7=I(()=>{"use strict";o7();Ic=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;_matcher=null;_matcherInput=null;acquireMatcher(e){return this._matcher===null?(this._matcher=this._re2.matcher(e),this._matcherInput=e,this._matcher):(this._matcherInput!==e&&(this._matcher.matcherInput.charSequence=e,this._matcherInput=e),this._matcher.reset(),this._matcher)}constructor(e,n=""){this._pattern=e,this._flags=n,this._global=n.includes("g"),this._ignoreCase=n.includes("i"),this._multiline=n.includes("m");try{let r=HO(e),s=qO(n);this._re2=Ks.compile(r,s)}catch(r){if(r instanceof wt){let s=r.message||"",i="";throw s.includes("(?=")||s.includes("(?!")||s.includes("(?<")||s.includes("(?<!")||e.includes("(?=")||e.includes("(?!")||e.includes("(?<=")||e.includes("(?<!")?i=" Lookahead (?=, ?!) and lookbehind (?<=, ?<!) assertions are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support these features.":(s.includes("backreference")||/\\[1-9]/.test(e))&&(i=" Backreferences (\\1, \\2, etc.) are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support backreferences."),new SyntaxError(`Invalid regular expression: /${e}/: ${s}${i}`)}throw r}}test(e){return this._global&&(this._lastIndex=0),this.acquireMatcher(e).find()}exec(e){let n=this.acquireMatcher(e),r=this._global?this._lastIndex:0;if(!n.find(r))return this._global&&(this._lastIndex=0),null;let s=this._re2.groupCount(),i=[];i.push(n.group(0)??"");for(let l=1;l<=s;l++){let c=n.group(l);i.push(c)}let o=i;o.index=n.start(0),o.input=e;let a=this._re2.namedGroups();if(a&&Object.keys(a).length>0){let l=Object.create(null);for(let[c,u]of Object.entries(a)){let f=n.group(u);f!==null&&(l[c]=f)}o.groups=l}return this._global&&(this._lastIndex=n.end(0),n.start(0)===n.end(0)&&this._lastIndex++),o}match(e){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(e);let n=[],r=this._re2.matcher(e),s=0;for(;r.find(s);){let i=r.group(0)??"";if(n.push(i),s=r.end(0),r.start(0)===r.end(0)&&s++,s>e.length)break}return n.length>0?n:null}replace(e,n){if(this._global&&(this._lastIndex=0),typeof n=="string"){let c=this._re2.matcher(e);return this._global?c.replaceAll(n,!0):c.replaceFirst(n,!0)}let r=[],s=this._re2.matcher(e),i=0,o=0,a=this._re2.groupCount(),l=this._re2.namedGroups();for(;s.find(o);){r.push(e.slice(i,s.start(0)));let c=[],u=s.group(0)??"";for(let f=1;f<=a;f++)c.push(s.group(f));if(c.push(s.start(0)),c.push(e),l&&Object.keys(l).length>0){let f=Object.create(null);for(let[h,d]of Object.entries(l))f[h]=s.group(d)??"";c.push(f)}if(r.push(n(u,...c)),i=s.end(0),o=i,s.start(0)===s.end(0)&&o++,!this._global||o>e.length)break}return r.push(e.slice(i)),r.join("")}split(e,n){return n===void 0||n<0?this._re2.split(e,-1):n===0?[]:this._re2.split(e,-1).slice(0,n)}search(e){let n=this._re2.matcher(e);return n.find()?n.start(0):-1}*matchAll(e){if(!this._global)throw new Error("matchAll requires global flag");this._lastIndex=0;let n=this._re2.matcher(e),r=this._re2.groupCount(),s=this._re2.namedGroups(),i=0;for(;n.find(i);){let o=[];o.push(n.group(0)??"");for(let l=1;l<=r;l++)o.push(n.group(l));let a=o;if(a.index=n.start(0),a.input=e,s&&Object.keys(s).length>0){let l=Object.create(null);for(let[c,u]of Object.entries(s)){let f=n.group(u);f!==null&&(l[c]=f)}a.groups=l}if(yield a,i=n.end(0),n.start(0)===n.end(0)&&i++,i>e.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=new RegExp("",this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(e){this._lastIndex=e}};Os=class{_regex;constructor(e){this._regex=e}test(e){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(e)}exec(e){return this._regex.exec(e)}match(e){return this._regex.global&&(this._regex.lastIndex=0),e.match(this._regex)}replace(e,n){return this._regex.global&&(this._regex.lastIndex=0),e.replace(this._regex,n)}split(e,n){return e.split(this._regex,n)}search(e){return e.search(this._regex)}*matchAll(e){if(!this._regex.global)throw new Error("matchAll requires global flag");this._regex.lastIndex=0;let n=this._regex.exec(e);for(;n!==null;)yield n,n[0].length===0&&this._regex.lastIndex++,n=this._regex.exec(e)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(e){this._regex.lastIndex=e}}});var bt=I(()=>{"use strict";a7()});function Fn(t,e,n){let r=typeof n=="boolean"?{ignoreCase:n}:n??{},s=e;r.stripQuotes&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1));let i=r.ignoreCase?`i:${s}`:s,o=_a.get(i);if(!o){if(o=GO(s,r.ignoreCase),_a.size>=VO){let a=_a.keys().next().value;a!==void 0&&_a.delete(a)}_a.set(i,o)}return o.test(t)}function GO(t,e){let n="^";for(let r=0;r<t.length;r++){let s=t[r];if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=r+1;for(;i<t.length&&t[i]!=="]";)i++;n+=t.slice(r,i+1),r=i}else s==="."||s==="+"||s==="^"||s==="$"||s==="{"||s==="}"||s==="("||s===")"||s==="|"||s==="\\"?n+=`\\${s}`:n+=s}return n+="$",X(n,e?"i":"")}var VO,_a,wp=I(()=>{"use strict";bt();VO=2048,_a=new Map});function Pc(t,e){let n=t.ignoreCase?e.toLowerCase():e,r=t.needles;for(let s=0;s<r.length;s++)if(n.indexOf(r[s])!==-1)return!0;return!1}function l7(t,e){return t.replace(/\$(&|\d+|<([^>]+)>)/g,(n,r,s)=>{if(r==="&")return e[0];if(s!==void 0)return e.groups?.[s]??"";let i=parseInt(r,10);return e[i]??""})}function vo(t,e,n={}){let{invertMatch:r=!1,showLineNumbers:s=!1,countOnly:i=!1,countMatches:o=!1,filename:a="",onlyMatching:l=!1,beforeContext:c=0,afterContext:u=0,maxCount:f=0,contextSeparator:h="--",showColumn:d=!1,vimgrep:p=!1,showByteOffset:m=!1,replace:g=null,passthru:y=!1,multiline:w=!1,kResetGroup:b,preFilter:E}=n;if(w)return KO(t,e,{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:h,showColumn:d,showByteOffset:m,replace:g,kResetGroup:b});let A=t.split(`
180
180
  `),C=A.length,P=C>0&&A[C-1]===""?C-1:C;if(i||o){let v=0,T=(o||l)&&!r;for(let D=0;D<P;D++){let W=A[D];if(!(E&&!r&&!Pc(E,W)))if(e.lastIndex=0,T)for(let H=e.exec(W);H!==null;H=e.exec(W))v++,H[0].length===0&&e.lastIndex++;else e.test(W)!==r&&v++}return{output:`${a?`${a}:${v}`:String(v)}
@@ -199,7 +199,7 @@ Options:
199
199
  `};let ve=await e.fs.readFile(Le),$e=vo(ve,R,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:H?ne:"",onlyMatching:p,beforeContext:w,afterContext:b,maxCount:y,kResetGroup:k,preFilter:S});return{file:ne,result:$e}}catch{return{error:`grep: ${ne}: No such file or directory
200
200
  `}}}));for(let oe of se){if(oe===null)continue;if("error"in oe&&oe.error){T+=oe.error,oe.error.includes("Is a directory")||(D=!0);continue}if(!("file"in oe)||!oe.result)continue;let{file:ne,result:z}=oe;if(z.matched){if(_=!0,g)return{stdout:"",stderr:"",exitCode:0};o?v+=`${ne}
201
201
  `:a||(v+=z.output)}else a?v+=`${ne}
202
- `:i&&!o&&(v+=z.output)}}let j;return D?j=2:a?j=v.length>0?0:1:j=_?0:1,g?{stdout:"",stderr:"",exitCode:j}:{stdout:v,stderr:T,exitCode:j}}},h7=256;fI={name:"fgrep",async execute(t,e){return xp.execute(["-F",...t],e)}},hI={name:"egrep",async execute(t,e){return xp.execute(["-E",...t],e)}},Sp={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"}],stdinType:"text",needsArgs:!0},Ap={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},vp={name:"egrep",flags:[],stdinType:"text",needsArgs:!0}});function m7(t,e){if(Array.isArray(t))throw new TypeError(`${e}: expected object, got array`);if(Object.getPrototypeOf(t)!==null)throw new TypeError(`${e}: expected null-prototype object, got prototypal object`)}function it(t){return!p7.has(t)}function mt(t,e,n){m7(t,"safeSet"),it(e)&&(t[e]=n)}function fs(t,e){return m7(t,"safeHasOwn"),Object.hasOwn(t,e)}function gn(t){let e=new WeakMap,n=r=>{if(r===null||typeof r!="object"||r instanceof Date)return r;let s=e.get(r);if(s!==void 0)return s;if(Array.isArray(r)){let o=[];e.set(r,o);for(let a of r)o.push(n(a));return o}let i=Object.create(null);e.set(r,i);for(let o of Object.keys(r))i[o]=n(r[o]);return i};return n(t)}function Et(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null}function Fc(t){return Object.assign(Object.create(null),t)}function zt(t){return Object.assign(Object.create(null),t)}function Cp(...t){return Object.assign(Object.create(null),...t)}var p7,vZ,Vn=I(()=>{"use strict";p7=new Set(["__proto__","constructor","prototype"]),vZ=new Set([...p7,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function y7(){let t=[];for(let[e,n]of Object.entries(g7).sort()){let r=[];for(let s of n.extensions)r.push(`*${s}`);for(let s of n.globs)r.push(s);t.push(`${e}: ${r.join(", ")}`)}return`${t.join(`
202
+ `:i&&!o&&(v+=z.output)}}let j;return D?j=2:a?j=v.length>0?0:1:j=_?0:1,g?{stdout:"",stderr:"",exitCode:j}:{stdout:v,stderr:T,exitCode:j}}},h7=256;fI={name:"fgrep",async execute(t,e){return xp.execute(["-F",...t],e)}},hI={name:"egrep",async execute(t,e){return xp.execute(["-E",...t],e)}},Sp={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"}],stdinType:"text",needsArgs:!0},Ap={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},vp={name:"egrep",flags:[],stdinType:"text",needsArgs:!0}});function m7(t,e){if(Array.isArray(t))throw new TypeError(`${e}: expected object, got array`);if(Object.getPrototypeOf(t)!==null)throw new TypeError(`${e}: expected null-prototype object, got prototypal object`)}function it(t){return!p7.has(t)}function mt(t,e,n){m7(t,"safeSet"),it(e)&&(t[e]=n)}function hs(t,e){return m7(t,"safeHasOwn"),Object.hasOwn(t,e)}function gn(t){let e=new WeakMap,n=r=>{if(r===null||typeof r!="object"||r instanceof Date)return r;let s=e.get(r);if(s!==void 0)return s;if(Array.isArray(r)){let o=[];e.set(r,o);for(let a of r)o.push(n(a));return o}let i=Object.create(null);e.set(r,i);for(let o of Object.keys(r))i[o]=n(r[o]);return i};return n(t)}function Et(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null}function Fc(t){return Object.assign(Object.create(null),t)}function zt(t){return Object.assign(Object.create(null),t)}function Cp(...t){return Object.assign(Object.create(null),...t)}var p7,vZ,Vn=I(()=>{"use strict";p7=new Set(["__proto__","constructor","prototype"]),vZ=new Set([...p7,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function y7(){let t=[];for(let[e,n]of Object.entries(g7).sort()){let r=[];for(let s of n.extensions)r.push(`*${s}`);for(let s of n.globs)r.push(s);t.push(`${e}: ${r.join(", ")}`)}return`${t.join(`
203
203
  `)}
204
204
  `}var g7,Ma,kp=I(()=>{"use strict";bt();Vn();g7=Fc({js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}}),Ma=class{types;constructor(){this.types=new Map(Object.entries(g7).map(([e,n])=>[e,{extensions:[...n.extensions],globs:[...n.globs]}]))}addType(e){let n=e.indexOf(":");if(n===-1)return;let r=e.slice(0,n),s=e.slice(n+1);if(s.startsWith("include:")){let i=s.slice(8),o=this.types.get(i);if(o){let a=this.types.get(r)||{extensions:[],globs:[]};a.extensions.push(...o.extensions),a.globs.push(...o.globs),this.types.set(r,a)}}else{let i=this.types.get(r)||{extensions:[],globs:[]};if(s.startsWith("*.")&&!s.slice(2).includes("*")){let o=s.slice(1);i.extensions.includes(o)||i.extensions.push(o)}else i.globs.includes(s)||i.globs.push(s);this.types.set(r,i)}}clearType(e){let n=this.types.get(e);n&&(n.extensions=[],n.globs=[])}getType(e){return this.types.get(e)}getAllTypes(){return this.types}matchesType(e,n){let r=e.toLowerCase();for(let s of n){if(s==="all"){if(this.matchesAnyType(e))return!0;continue}let i=this.types.get(s);if(i){for(let o of i.extensions)if(r.endsWith(o))return!0;for(let o of i.globs)if(o.includes("*")){let a=o.replace(/\./g,"\\.").replace(/\*/g,".*");if(X(`^${a}$`,"i").test(e))return!0}else if(r===o.toLowerCase())return!0}}return!1}matchesAnyType(e){let n=e.toLowerCase();for(let r of this.types.values()){for(let s of r.extensions)if(n.endsWith(s))return!0;for(let s of r.globs)if(s.includes("*")){let i=s.replace(/\./g,"\\.").replace(/\*/g,".*");if(X(`^${i}$`,"i").test(e))return!0}else if(n===s.toLowerCase())return!0}return!1}}});function w7(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:256,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var b7=I(()=>{"use strict"});function dI(t){let e=t.match(/^(\d+)([KMG])?$/i);if(!e)return 0;let n=parseInt(e[1],10);switch((e[2]||"").toUpperCase()){case"K":return n*1024;case"M":return n*1024*1024;case"G":return n*1024*1024*1024;default:return n}}function pI(t){return/^\d+[KMG]?$/i.test(t)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${t}
205
205
  `,exitCode:1}}function E7(t){return null}function yI(t){t.hidden?t.searchBinary=!0:t.noIgnore?t.hidden=!0:t.noIgnore=!0}function wI(t,e,n){let r=t[e];for(let s of x7){if(r.startsWith(`--${s.long}=`)){let i=r.slice(`--${s.long}=`.length),o=_c(n,s,i);return o?{newIndex:e,error:o}:{newIndex:e}}if(s.short&&r.startsWith(`-${s.short}`)&&r.length>2){let i=r.slice(2),o=_c(n,s,i);return o?{newIndex:e,error:o}:{newIndex:e}}if(s.short&&r===`-${s.short}`||r===`--${s.long}`){if(e+1>=t.length)return null;let i=t[e+1],o=_c(n,s,i);return o?{newIndex:e+1,error:o}:{newIndex:e+1}}}return null}function bI(t){return x7.find(e=>e.short===t)}function _c(t,e,n){if(e.validate){let s=e.validate(n);if(s)return s}if(e.ignored||!e.target)return;let r=e.parse?e.parse(n):n;e.multi?t[e.target].push(r):t[e.target]=r}function EI(t,e){let n=t[e];if(n==="--sort"&&e+1<t.length){let r=t[e+1];if(r==="path"||r==="none")return{value:r,newIndex:e+1}}if(n.startsWith("--sort=")){let r=n.slice(7);if(r==="path"||r==="none")return{value:r,newIndex:e}}return null}function xI(t,e){let n=t[e],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:e}:(n==="-A"||n==="-B"||n==="-C")&&e+1<t.length?{flag:n[1],value:parseInt(t[e+1],10),newIndex:e+1}:null}function SI(t){let e=t.match(/^-m(\d+)$/);return e?parseInt(e[1],10):null}function S7(t){let e=w7(),n=null,r=[],s=-1,i=-1,o=-1,a=!1;for(let l=0;l<t.length;l++){let c=t[l];if(c.startsWith("-")&&c!=="-"){let u=xI(t,l);if(u){let{flag:g,value:y,newIndex:w}=u;g==="A"?s=Math.max(s,y):g==="B"?i=Math.max(i,y):o=y,l=w;continue}let f=SI(c);if(f!==null){e.maxCount=f;continue}let h=wI(t,l,e);if(h){if(h.error)return{success:!1,error:h.error};l=h.newIndex;continue}let d=EI(t,l);if(d){e.sort=d.value,l=d.newIndex;continue}let p=c.startsWith("--")?[c]:c.slice(1).split(""),m=!1;for(let g of p){if(gI.has(g)){e.lineNumber=!0,a=!0;continue}if(g==="u"||g==="--unrestricted"){yI(e);continue}if(g==="P"||g==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
@@ -230,7 +230,7 @@ EXAMPLES:
230
230
  rg -t js foo Search only JavaScript files
231
231
  rg -g '*.ts' foo Search files matching glob
232
232
  rg --hidden foo Include hidden files
233
- rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},$I={name:"rg",async execute(t,e){if(U(t))return B(RI);if(t.includes("--type-list"))return{stdout:y7(),stderr:"",exitCode:0};let n=S7(t);return n.success?k7({ctx:e,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}},Tp={name:"rg",flags:[{flag:"-i",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-N",type:"boolean"},{flag:"--hidden",type:"boolean"},{flag:"--no-ignore",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-g",type:"value",valueHint:"pattern"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-T",type:"value",valueHint:"string"}],needsArgs:!0}});function Ot(t,e,n){if(!t||tt.isInSandboxedContext())return;let r=`${e} ${n} attempted outside defense context`;throw new Se(r,{timestamp:Date.now(),type:"missing_defense_context",message:r,path:"DefenseInDepthBox.context",stack:new Error().stack,executionId:tt.getCurrentExecutionId()})}async function yn(t,e,n,r){Ot(t,e,`${n} (pre-await)`);let s=await r();return Ot(t,e,`${n} (post-await)`),s}function hs(t,e,n,r){let s=((...i)=>(Ot(t,e,n),r(...i)));return t?tt.bindCurrentContext(s):s}var lr=I(()=>{"use strict";en()});function Pp(t){let e="",n=0,r=!1;for(;n<t.length;){if(t[n]==="["&&!r){if(t[n+1]==="["&&t[n+2]===":"){let s=t.indexOf(":]]",n+3);if(s!==-1){let i=t.slice(n+3,s),o=Ip.get(i);if(o){e+=`[${o}]`,n=s+3;continue}}}if(t[n+1]==="^"&&t[n+2]==="["&&t[n+3]===":"){let s=t.indexOf(":]]",n+4);if(s!==-1){let i=t.slice(n+4,s),o=Ip.get(i);if(o){e+=`[^${o}]`,n=s+3;continue}}}e+="[",n++,r=!0,n<t.length&&t[n]==="^"&&(e+="^",n++),n<t.length&&t[n]==="]"&&(e+="\\]",n++);continue}if(r){if(t[n]==="]"){e+="]",n++,r=!1;continue}if(t[n]==="["&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){let i=t.slice(n+2,s),o=Ip.get(i);if(o){e+=o,n=s+2;continue}}}if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}e+=t[n],n++;continue}if(t[n]==="\\"&&n+1<t.length){let s=t[n+1];if(s==="+"||s==="?"||s==="|"){e+=s,n+=2;continue}if(s==="("||s===")"){e+=s,n+=2;continue}if(s==="{"||s==="}"){e+=s,n+=2;continue}if(s==="t"){e+=" ",n+=2;continue}if(s==="n"){e+=`
233
+ rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},$I={name:"rg",async execute(t,e){if(U(t))return B(RI);if(t.includes("--type-list"))return{stdout:y7(),stderr:"",exitCode:0};let n=S7(t);return n.success?k7({ctx:e,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}},Tp={name:"rg",flags:[{flag:"-i",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-N",type:"boolean"},{flag:"--hidden",type:"boolean"},{flag:"--no-ignore",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-g",type:"value",valueHint:"pattern"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-T",type:"value",valueHint:"string"}],needsArgs:!0}});function Ot(t,e,n){if(!t||tt.isInSandboxedContext())return;let r=`${e} ${n} attempted outside defense context`;throw new Se(r,{timestamp:Date.now(),type:"missing_defense_context",message:r,path:"DefenseInDepthBox.context",stack:new Error().stack,executionId:tt.getCurrentExecutionId()})}async function yn(t,e,n,r){Ot(t,e,`${n} (pre-await)`);let s=await r();return Ot(t,e,`${n} (post-await)`),s}function ds(t,e,n,r){let s=((...i)=>(Ot(t,e,n),r(...i)));return t?tt.bindCurrentContext(s):s}var lr=I(()=>{"use strict";en()});function Pp(t){let e="",n=0,r=!1;for(;n<t.length;){if(t[n]==="["&&!r){if(t[n+1]==="["&&t[n+2]===":"){let s=t.indexOf(":]]",n+3);if(s!==-1){let i=t.slice(n+3,s),o=Ip.get(i);if(o){e+=`[${o}]`,n=s+3;continue}}}if(t[n+1]==="^"&&t[n+2]==="["&&t[n+3]===":"){let s=t.indexOf(":]]",n+4);if(s!==-1){let i=t.slice(n+4,s),o=Ip.get(i);if(o){e+=`[^${o}]`,n=s+3;continue}}}e+="[",n++,r=!0,n<t.length&&t[n]==="^"&&(e+="^",n++),n<t.length&&t[n]==="]"&&(e+="\\]",n++);continue}if(r){if(t[n]==="]"){e+="]",n++,r=!1;continue}if(t[n]==="["&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){let i=t.slice(n+2,s),o=Ip.get(i);if(o){e+=o,n=s+2;continue}}}if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}e+=t[n],n++;continue}if(t[n]==="\\"&&n+1<t.length){let s=t[n+1];if(s==="+"||s==="?"||s==="|"){e+=s,n+=2;continue}if(s==="("||s===")"){e+=s,n+=2;continue}if(s==="{"||s==="}"){e+=s,n+=2;continue}if(s==="t"){e+=" ",n+=2;continue}if(s==="n"){e+=`
234
234
  `,n+=2;continue}if(s==="r"){e+="\r",n+=2;continue}e+=t[n]+s,n+=2;continue}if(t[n]==="+"||t[n]==="?"||t[n]==="|"||t[n]==="("||t[n]===")"){e+=`\\${t[n]}`,n++;continue}if(t[n]==="^"&&!(e===""||e.endsWith("("))){e+="\\^",n++;continue}if(t[n]==="$"){let s=n===t.length-1,i=n+2<t.length&&t[n+1]==="\\"&&t[n+2]===")";if(!s&&!i){e+="\\$",n++;continue}}e+=t[n],n++}return e}function Rp(t){let e="",n=!1;for(let r=0;r<t.length;r++)t[r]==="["&&!n?(n=!0,e+="[",r++,r<t.length&&t[r]==="^"&&(e+="^",r++),r<t.length&&t[r]==="]"&&(e+="]",r++),r--):t[r]==="]"&&n?(n=!1,e+="]"):!n&&t[r]==="{"&&t[r+1]===","?(e+="{0,",r++):e+=t[r];return e}function R7(t){let e="";for(let n=0;n<t.length;n++){let r=t[n],s=r.charCodeAt(0);r==="\\"?e+="\\\\":r===" "?e+="\\t":r===`
235
235
  `?e+=`$
236
236
  `:r==="\r"?e+="\\r":r==="\x07"?e+="\\a":r==="\b"?e+="\\b":r==="\f"?e+="\\f":r==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=r}return`${e}$`}var Ip,$7=I(()=>{"use strict";Ip=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 _7(t,e,n){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:t,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],rangeStates:n||new Map,linesConsumedInCycle:0}}function _I(t){return typeof t=="object"&&"first"in t&&"step"in t}function DI(t){return typeof t=="object"&&"offset"in t}function Co(t,e,n,r,s){if(t==="$")return e===n;if(typeof t=="number")return e===t;if(_I(t)){let{first:i,step:o}=t;return o===0?e===i:(e-i)%o===0&&e>=i}if(typeof t=="object"&&"pattern"in t)try{let i=t.pattern;i===""&&s?.lastPattern?i=s.lastPattern:i!==""&&s&&(s.lastPattern=i);let o=Rp(Pp(i));return X(o).test(r)}catch{return!1}return!1}function $p(t){let e=n=>n===void 0?"undefined":n==="$"?"$":typeof n=="number"?String(n):"pattern"in n?`/${n.pattern}/`:"first"in n?`${n.first}~${n.step}`:"unknown";return`${e(t.start)},${e(t.end)}`}function LI(t,e,n,r,s,i){if(!t||!t.start&&!t.end)return!0;let o=t.start,a=t.end;if(o!==void 0&&a===void 0)return Co(o,e,n,r,i);if(o!==void 0&&a!==void 0){let l=typeof o=="object"&&"pattern"in o,c=typeof a=="object"&&"pattern"in a,u=DI(a);if(u&&s){let h=$p(t),d=s.get(h);if(d||(d={active:!1},s.set(h,d)),d.active){let p=d.startLine||e;return e>=p+a.offset&&(d.active=!1,s.set(h,d)),!0}else return Co(o,e,n,r,i)?(d.active=!0,d.startLine=e,s.set(h,d),a.offset===0&&(d.active=!1,s.set(h,d)),!0):!1}if(!l&&!c&&!u){let h=typeof o=="number"?o:o==="$"?n:1,d=typeof a=="number"?a:n;if(h<=d)return e>=h&&e<=d;if(s){let p=$p(t),m=s.get(p);return m||(m={active:!1},s.set(p,m)),!m.completed&&e>=h?(m.completed=!0,s.set(p,m),!0):!1}return!1}if(s){let h=$p(t),d=s.get(h);if(d||(d={active:!1},s.set(h,d)),d.active)return Co(a,e,n,r,i)&&(d.active=!1,typeof o=="number"&&(d.completed=!0),s.set(h,d)),!0;{if(d.completed)return!1;let p=!1;return typeof o=="number"?p=e>=o:p=Co(o,e,n,r,i),p?(d.active=!0,d.startLine=e,s.set(h,d),Co(a,e,n,r,i)&&(d.active=!1,typeof o=="number"&&(d.completed=!0),s.set(h,d)),!0):!1}}return Co(o,e,n,r,i)}return!0}function Ri(t,e,n,r,s,i){let o=LI(t,e,n,r,s,i);return t?.negated?!o:o}function MI(t,e,n,r){let s="",i=0,o=!1;for(;i<=t.length;){e.lastIndex=i;let a=e.exec(t);if(!a){s+=t.slice(i);break}if(a.index!==i){s+=t.slice(i,a.index),i=a.index,o=!1;continue}let l=a[0],c=a.slice(1);if(o&&l.length===0){if(i<t.length)s+=t[i],i++;else break;o=!1;continue}if(s+=r(l,c),o=!1,l.length===0)if(i<t.length)s+=t[i],i++;else break;else i+=l.length,o=!0}return s}function Fp(t,e,n){let r="",s=0;for(;s<t.length;){if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&"){r+="&",s+=2;continue}if(i==="n"){r+=`
@@ -477,7 +477,7 @@ Try 'comm --help' for more information.
477
477
  `};n.mode="chunks",n.chunks=u,s+=2}else if(c.match(/^-n\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of chunks: '${c.slice(2)}'
478
478
  `};n.mode="chunks",n.chunks=u,s++}else if(c==="-a"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${t[s+1]}'
479
479
  `};n.suffixLength=u,s+=2}else if(c.match(/^-a\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${c.slice(2)}'
480
- `};n.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")n.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))n.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<t.length)n.additionalSuffix=t[s+1],s+=2;else if(c==="--"){r.push(...t.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return Q("split",c);r.push(c),s++}}let i="-",o="x";r.length>=1&&(i=r[0]),r.length>=2&&(o=r[1]);let a;if(i==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,i);try{let u=await os(e.fs,c);a=u}catch{return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
480
+ `};n.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")n.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))n.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<t.length)n.additionalSuffix=t[s+1],s+=2;else if(c==="--"){r.push(...t.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return Q("split",c);r.push(c),s++}}let i="-",o="x";r.length>=1&&(i=r[0]),r.length>=2&&(o=r[1]);let a;if(i==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,i);try{let u=await as(e.fs,c);a=u}catch{return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
481
481
  `}}}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(n.mode){case"lines":l=zR(a,n.lines);break;case"bytes":l=WR(a,n.bytes);break;case"chunks":l=jR(a,n.chunks);break;default:return n.mode}if(l.length>Y3)return{exitCode:1,stdout:"",stderr:`split: too many output files (${l.length}), limit is ${Y3}
482
482
  `};for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=UR(c,n.useNumericSuffix,n.suffixLength),h=`${o}${f}${n.additionalSuffix}`,d=e.fs.resolvePath(e.cwd,h);await e.fs.writeFile(d,u.content,"binary")}return{exitCode:0,stdout:"",stderr:""}}},v1={name:"split",flags:[{flag:"-l",type:"value",valueHint:"number"},{flag:"-b",type:"value",valueHint:"string"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-d",type:"boolean"},{flag:"-a",type:"value",valueHint:"number"}],needsFiles:!0}});var e4={};ee(e4,{column:()=>YR,flagsForFuzzing:()=>k1});function J3(t,e,n){return e?n?t.split(e):t.split(e).filter(r=>r.length>0):n?t.split(/[ \t]/):t.split(/[ \t]+/).filter(r=>r.length>0)}function GR(t){let e=[];for(let n of t)for(let r=0;r<n.length;r++){let s=n[r].length;(e[r]===void 0||s>e[r])&&(e[r]=s)}return e}function KR(t,e){if(t.length===0)return"";let n=GR(t),r=[];for(let s of t){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(n[o]));r.push(i.join(e))}return r.join(`
483
483
  `)}function ZR(t,e,n){if(t.length===0)return"";let r=Math.max(...t.map(c=>c.length)),s=n.length,i=r+s,o=Math.max(1,Math.floor((e+s)/i)),a=Math.ceil(t.length/o),l=[];for(let c=0;c<a;c++){let u=[];for(let f=0;f<o;f++){let h=f*a+c;h<t.length&&(f===o-1||(f+1)*a+c>=t.length?u.push(t[h]):u.push(t[h].padEnd(r)))}l.push(u.join(n))}return l.join(`
@@ -550,8 +550,8 @@ ${a} director${a===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"
550
550
  `,exitCode:1};let s=Ps(r.exportedEnv||{},{0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")});n.forEach((a,l)=>{s[String(l+1)]=a});let i=t;if(i.startsWith("#!")){let a=i.indexOf(`
551
551
  `);a!==-1&&(i=i.slice(a+1))}return await r.exec(i,{env:s,cwd:r.cwd,stdin:r.stdin,stdinKind:"bytes",signal:r.signal})}var x4,j$,q$,im,om,eu=I(()=>{"use strict";pe();Ar();ue();x4={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},j$={name:"bash",async execute(t,e){if(U(t))return B(x4);if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"bash",o=t.slice(3);return Po(s,i,o,e)}if(t.length===0){let s=te(e.stdin);return s.trim()?Po(s,"bash",[],e):{stdout:"",stderr:"",exitCode:0}}let n=t[0],r=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,n),i=await e.fs.readFile(s);return Po(i,n,r,e)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
552
552
  `,exitCode:127}}}},q$={name:"sh",async execute(t,e){if(U(t))return B({...x4,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"sh",o=t.slice(3);return Po(s,i,o,e)}if(t.length===0){let s=te(e.stdin);return s.trim()?Po(s,"sh",[],e):{stdout:"",stderr:"",exitCode:0}}let n=t[0],r=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,n),i=await e.fs.readFile(s);return Po(i,n,r,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
553
- `,exitCode:127}}}};im={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},om={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function lm(t,e,n,r,s,i,o,a,l,c){switch(e){case"sort":return Array.isArray(t)?[[...t].sort(o)]:[null];case"sort_by":return!Array.isArray(t)||n.length===0?[null]:[[...t].sort((f,h)=>{let d=s(f,n[0],r)[0],p=s(h,n[0],r)[0];return o(d,p)})];case"bsearch":{if(!Array.isArray(t)){let f=t===null?"null":typeof t=="object"?"object":typeof t;throw new Error(`${f} (${JSON.stringify(t)}) cannot be searched from`)}return n.length===0?[null]:s(t,n[0],r).map(f=>{let h=0,d=t.length;for(;h<d;){let p=h+d>>>1;o(t[p],f)<0?h=p+1:d=p}return h<t.length&&o(t[h],f)===0?h:-h-1})}case"unique_by":{if(!Array.isArray(t)||n.length===0)return[null];let u=new Map;for(let h of t){let d=s(h,n[0],r)[0],p=JSON.stringify(d);u.has(p)||u.set(p,{item:h,key:d})}let f=[...u.values()];return f.sort((h,d)=>o(h.key,d.key)),[f.map(h=>h.item)]}case"group_by":{if(!Array.isArray(t)||n.length===0)return[null];let u=new Map;for(let f of t){let h=JSON.stringify(s(f,n[0],r)[0]);u.has(h)||u.set(h,[]),u.get(h)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((u,f)=>o(u,f)>0?u:f)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((u,f)=>{let h=s(u,n[0],r)[0],d=s(f,n[0],r)[0];return o(h,d)>0?u:f})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((u,f)=>o(u,f)<0?u:f)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((u,f)=>{let h=s(u,n[0],r)[0],d=s(f,n[0],r)[0];return o(h,d)<0?u:f})];case"add":{let u=f=>{let h=f.filter(d=>d!==null);return h.length===0?null:h.every(d=>typeof d=="number")?h.reduce((d,p)=>d+p,0):h.every(d=>typeof d=="string")?h.join(""):h.every(d=>Array.isArray(d))?h.flat():h.every(d=>d&&typeof d=="object"&&!Array.isArray(d))?Ps(...h):null};if(n.length>=1){let f=s(t,n[0],r);return[u(f)]}return Array.isArray(t)?[u(t)]:[null]}case"any":{if(n.length>=2){try{let u=i(t,n[0],r);for(let f of u)if(s(f,n[1],r).some(a))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(t)?[t.some(u=>a(s(u,n[0],r)[0]))]:[!1]:Array.isArray(t)?[t.some(a)]:[!1]}case"all":{if(n.length>=2){try{let u=i(t,n[0],r);for(let f of u)if(!s(f,n[1],r).some(a))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(t)?[t.every(u=>a(s(u,n[0],r)[0]))]:[!0]:Array.isArray(t)?[t.every(a)]:[!0]}case"select":return n.length===0?[t]:s(t,n[0],r).some(a)?[t]:[];case"map":return n.length===0||!Array.isArray(t)?[null]:[t.flatMap(f=>s(f,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(t))return[t.flatMap(u=>s(u,n[0],r))];if(t&&typeof t=="object"){let u=Object.create(null);for(let[f,h]of Object.entries(t)){if(!it(f))continue;let d=s(h,n[0],r);d.length>0&&mt(u,f,d[0])}return[u]}return[null]}case"has":{if(n.length===0)return[!1];let f=s(t,n[0],r)[0];return Array.isArray(t)&&typeof f=="number"?[f>=0&&f<t.length]:t&&typeof t=="object"&&typeof f=="string"?[fs(t,f)]:[!1]}case"in":{if(n.length===0)return[!1];let f=s(t,n[0],r)[0];return Array.isArray(f)&&typeof t=="number"?[t>=0&&t<f.length]:f&&typeof f=="object"&&typeof t=="string"?[fs(f,t)]:[!1]}case"contains":{if(n.length===0)return[!1];let u=s(t,n[0],r);return[l(t,u[0])]}case"inside":{if(n.length===0)return[!1];let u=s(t,n[0],r);return[l(u[0],t)]}default:return null}}var S4=I(()=>{"use strict";Ar();Vn()});function cm(t,e,n,r,s,i,o,a){switch(e){case"first":if(n.length>0)try{let l=i(t,n[0],r);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof a)throw l;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(n.length>0){let l=s(t,n[0],r);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(n.length<1)return[null];let l=s(t,n[0],r);if(n.length>1){for(let u of l)if(u<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(t,n[1],r)}catch(u){if(u instanceof a)throw u;c=[]}return l.flatMap(u=>{let f=u;return f<c.length?[c[f]]:[]})}return Array.isArray(t)?l.flatMap(c=>{let u=c;if(u<0)throw new Error("nth doesn't support negative indices");return u<t.length?[t[u]]:[null]}):[null]}case"range":{if(n.length===0)return[];let l=Math.max(r.limits.maxIterations*100,1e6),c=p=>p.length>=l,u=s(t,n[0],r);if(n.length===1){let p=[];for(let m of u){let g=m;for(let y=0;y<g;y++)if(p.push(y),c(p))return p}return p}let f=s(t,n[1],r);if(n.length===2){let p=[];for(let m of u)for(let g of f){let y=m,w=g;for(let b=y;b<w;b++)if(p.push(b),c(p))return p}return p}let h=s(t,n[2],r),d=[];for(let p of u)for(let m of f)for(let g of h){let y=p,w=m,b=g;if(b!==0){if(b>0){for(let E=y;E<w;E+=b)if(d.push(E),c(d))return d}else for(let E=y;E>w;E+=b)if(d.push(E),c(d))return d}}return d}case"limit":return n.length<2?[]:s(t,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(t,n[1],r)}catch(h){if(h instanceof a)throw h;f=[]}return f.slice(0,u)});case"isempty":{if(n.length<1)return[!0];try{return[i(t,n[0],r).length===0]}catch(l){if(l instanceof a)throw l;return[!0]}}case"isvalid":{if(n.length<1)return[!0];try{return[s(t,n[0],r).length>0]}catch(l){if(l instanceof a)throw l;return[!1]}}case"skip":return n.length<2?[]:s(t,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("skip doesn't support negative count");return s(t,n[1],r).slice(u)});case"until":{if(n.length<2)return[t];let l=t,c=r.limits.maxIterations;for(let u=0;u<c;u++){if(s(l,n[0],r).some(o))return[l];let h=s(l,n[1],r);if(h.length===0)return[l];l=h[0]}throw new a(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[t];let l=[],c=t,u=r.limits.maxIterations;for(let f=0;f<u&&s(c,n[0],r).some(o);f++){l.push(c);let d=s(c,n[1],r);if(d.length===0)break;c=d[0]}if(l.length>=u)throw new a(`jq while: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(n.length===0)return[t];let l=[],c=t,u=r.limits.maxIterations;for(let f=0;f<u;f++){l.push(c);let h=s(c,n[0],r);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new a(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var A4=I(()=>{"use strict"});function um(t,e,n,r,s){switch(e){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let i=new Date(t*1e3),o=i.getUTCFullYear(),a=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),h=i.getUTCDay(),d=Date.UTC(o,0,1),p=Math.floor((i.getTime()-d)/(1440*60*1e3));return[[o,a,l,c,u,f,h,p]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[i,o,a,l=0,c=0,u=0]=t;if(typeof i!="number"||typeof o!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,o,a??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let o=s(t,n[0],r)[0];if(typeof o!="string")throw new Error("strftime/1 requires a string format");let a;if(typeof t=="number")a=new Date(t*1e3);else if(Array.isArray(t)){let[h,d,p,m=0,g=0,y=0]=t;if(typeof h!="number"||typeof d!="number")throw new Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(h,d,p??1,m??0,g??0,y??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(h,d=2)=>String(h).padStart(d,"0");return[o.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,u(a.getUTCMonth()+1)).replace(/%d/g,u(a.getUTCDate())).replace(/%H/g,u(a.getUTCHours())).replace(/%M/g,u(a.getUTCMinutes())).replace(/%S/g,u(a.getUTCSeconds())).replace(/%A/g,l[a.getUTCDay()]).replace(/%B/g,c[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(n.length===0)return[null];if(typeof t!="string")throw new Error("strptime/1 requires a string input");let o=s(t,n[0],r)[0];if(typeof o!="string")throw new Error("strptime/1 requires a string format");if(o==="%Y-%m-%dT%H:%M:%SZ"){let l=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(l){let[,c,u,f,h,d,p]=l.map(Number),m=new Date(Date.UTC(c,u-1,f,h,d,p)),g=m.getUTCDay(),y=Date.UTC(c,0,1),w=Math.floor((m.getTime()-y)/(1440*60*1e3));return[[c,u-1,f,h,d,p,g,w]]}}let a=new Date(t);if(!Number.isNaN(a.getTime())){let l=a.getUTCFullYear(),c=a.getUTCMonth(),u=a.getUTCDate(),f=a.getUTCHours(),h=a.getUTCMinutes(),d=a.getUTCSeconds(),p=a.getUTCDay(),m=Date.UTC(l,0,1),g=Math.floor((a.getTime()-m)/(1440*60*1e3));return[[l,c,u,f,h,d,p,g]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let i=new Date(t);if(Number.isNaN(i.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof t!="number")throw new Error("todate requires a number input");return[new Date(t*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}var v4=I(()=>{"use strict"});function kr(t){return t!==!1&&t!==null}function Ro(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Ka(t,e){return typeof t=="number"&&typeof e=="number"?t-e:typeof t=="string"&&typeof e=="string"?t.localeCompare(e):0}function fm(t,e){let n=zt(t);for(let r of Object.keys(e)){if(!it(r))continue;let s=fs(n,r)?Et(n[r]):null,i=Et(e[r]);s&&i?mt(n,r,fm(s,i)):mt(n,r,e[r])}return n}function $o(t,e=3e3){let n=0,r=t;for(;n<e;)if(Array.isArray(r)){if(r.length===0)return n+1;r=r[0],n++}else if(r!==null&&typeof r=="object"){let s=Object.keys(r);if(s.length===0)return n+1;r=r[s[0]],n++}else return n;return n}function tu(t,e){let n=a=>a===null?0:typeof a=="boolean"?1:typeof a=="number"?2:typeof a=="string"?3:Array.isArray(a)?4:typeof a=="object"?5:6,r=n(t),s=n(e);if(r!==s)return r-s;if(typeof t=="number"&&typeof e=="number")return t-e;if(typeof t=="string"&&typeof e=="string")return t.localeCompare(e);if(typeof t=="boolean"&&typeof e=="boolean")return(t?1:0)-(e?1:0);if(Array.isArray(t)&&Array.isArray(e)){for(let a=0;a<Math.min(t.length,e.length);a++){let l=tu(t[a],e[a]);if(l!==0)return l}return t.length-e.length}let i=Et(t),o=Et(e);if(i&&o){let a=Object.keys(i).sort(),l=Object.keys(o).sort();for(let c=0;c<Math.min(a.length,l.length);c++){let u=a[c].localeCompare(l[c]);if(u!==0)return u}if(a.length!==l.length)return a.length-l.length;for(let c of a){let u=tu(i[c],o[c]);if(u!==0)return u}}return 0}function nu(t,e){if(Ro(t,e))return!0;if(typeof t=="string"&&typeof e=="string")return t.includes(e);if(Array.isArray(t)&&Array.isArray(e))return e.every(s=>t.some(i=>nu(i,s)));let n=Et(t),r=Et(e);return n&&r?Object.keys(r).every(s=>fs(n,s)&&nu(n[s],r[s])):!1}var ru=I(()=>{"use strict";Vn()});function hm(t,e,n){switch(e){case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof t=="string"?[decodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(s=>{if(s===null)return"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="number")return String(s);let i=String(s);return i.includes(",")||i.includes('"')||i.includes(`
554
- `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(r=>String(r??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let r=n??H$;return $o(t,r+1)>r?[null]:[JSON.stringify(t)]}case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];default:return null}}var H$,C4=I(()=>{"use strict";ru();H$=2e3});function dm(t,e,n,r,s,i){switch(e){case"index":return n.length===0?[null]:s(t,n[0],r).map(a=>{if(typeof t=="string"&&typeof a=="string"){if(a===""&&t==="")return null;let l=t.indexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let c=0;c<=t.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(t[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=t.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(t,n[0],r).map(a=>{if(typeof t=="string"&&typeof a=="string"){let l=t.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let l=t.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(t[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=t.length-1;l>=0;l--)if(i(t[l],a))return l;return null}return null});case"indices":return n.length===0?[[]]:s(t,n[0],r).map(a=>{let l=[];if(typeof t=="string"&&typeof a=="string"){let c=t.indexOf(a);for(;c!==-1;)l.push(c),c=t.indexOf(a,c+1)}else if(Array.isArray(t))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=t.length;u++)l.push(u);else for(let u=0;u<=t.length-c;u++){let f=!0;for(let h=0;h<c;h++)if(!i(t[u+h],a[h])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<t.length;c++)i(t[c],a)&&l.push(c);return l});default:return null}}var k4=I(()=>{"use strict"});function pm(t,e,n,r,s){switch(e){case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:typeof t=="string"?[t]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.hypot(t,i)]}case"fma":{if(typeof t!="number"||n.length<2)return[null];let i=s(t,n[0],r)[0],o=s(t,n[1],r)[0];return[t*i+o]}case"copysign":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.sign(i)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[t-Math.round(t/i)*i]}case"fdim":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.max(0,t-i)]}case"fmax":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.max(t,i)]}case"fmin":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.min(t,i)]}case"ldexp":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[t*2**i]}case"scalbn":case"scalbln":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[t*2**i]}case"nearbyint":return typeof t=="number"?[Math.round(t)]:[null];case"logb":return typeof t=="number"?[Math.floor(Math.log2(Math.abs(t)))]:[null];case"significand":if(typeof t=="number"){let i=Math.floor(Math.log2(Math.abs(t)));return[t/2**i]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**i,i]]}return[null];case"modf":if(typeof t=="number"){let i=Math.trunc(t);return[[t-i,i]]}return[null];default:return null}}var N4=I(()=>{"use strict"});function mm(t,e,n,r,s,i,o,a){switch(e){case"recurse":{if(n.length===0){let d=[],p=m=>{if(d.push(m),Array.isArray(m))for(let g of m)p(g);else if(m&&typeof m=="object")for(let g of Object.keys(m))p(m[g])};return p(t),d}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,h=d=>{if(f++>u||c&&!s(d,c,r).some(i))return;l.push(d);let p=s(d,n[0],r);for(let m of p)m!=null&&h(m)};return h(t),l}case"recurse_down":return a(t,"recurse",n,r);case"walk":{if(n.length===0)return[t];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(u))it(p)&&mt(d,p,c(m));f=d}else f=u;return s(f,n[0],r)[0]};return[c(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let l=Math.max(...t.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(t.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(n.length>0){let f=s(t,n[0],r)[0];if(!Array.isArray(t)||f<0)return[];if(f===0)return[[]];let h=[],d=(p,m)=>{if(m===f){h.push([...p]);return}for(let g of t)p.push(g),d(p,m+1),p.pop()};return d([],0),h}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let u of t)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===t.length){l.push([...f]);return}let h=t[u];for(let d of h)f.push(d),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let l=r.currentPath;if(l.length===0)return[];let c=n.length>0?s(t,n[0],r)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[t];let f=l.slice(0,u);return[o(r.root,f)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let l=r.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var T4=I(()=>{"use strict";Vn()});function gm(t,e,n,r,s){switch(e){case"keys":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:typeof t=="number"?[Math.abs(t)]:[null];case"utf8bytelength":{if(typeof t=="string")return[new TextEncoder().encode(t).length];let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":{let i=Et(t);return i?[Object.entries(i).map(([o,a])=>({key:o,value:a}))]:[null]}case"from_entries":if(Array.isArray(t)){let i=Object.create(null);for(let o of t){let a=Et(o);if(a){let l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;if(l!==void 0){let u=String(l);it(u)&&mt(i,u,c)}}}return[i]}return[null];case"with_entries":{if(n.length===0)return[t];let i=Et(t);if(i){let a=Object.entries(i).map(([c,u])=>({key:c,value:u})).flatMap(c=>s(c,n[0],r)),l=Object.create(null);for(let c of a){let u=Et(c);if(u){let f=u.key??u.name??u.k,h=u.value??u.v;if(f!==void 0){let d=String(f);it(d)&&mt(l,d,h)}}}return[l]}return[null]}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(t)?(n.length>0?s(t,n[0],r):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return t.flat(a)}):[null];case"unique":if(Array.isArray(t)){let i=new Set,o=[];for(let a of t){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??V$;return $o(t,i+1)>i?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let i=t.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[gn(JSON.parse(t))]}catch{throw new Error(`Invalid JSON: ${t}`)}}return[t]}case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let i=Number(t);if(Number.isNaN(i))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof t} cannot be parsed as a number`);case"toboolean":{if(typeof t=="boolean")return[t];if(typeof t=="string"){if(t==="true")return[!0];if(t==="false")return[!1];throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`)}let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,Object.create(null)]);else for(let u of c)o(a[u],[...l,u])}};return o(t,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[t];let i=s(t,n[0],r),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:Object.create(null));let u=o;for(let h=0;h<l.length-1;h++){let d=l[h],p=l[h+1];if(Array.isArray(u)&&typeof d=="number"){for(;u.length<=d;)u.push(null);u[d]===null&&(u[d]=typeof p=="number"?[]:Object.create(null)),u=u[d]}else{let m=Et(u);if(m){let g=String(d);if(!it(g))continue;(m[g]===null||m[g]===void 0)&&mt(m,g,typeof p=="number"?[]:Object.create(null)),u=m[g]}}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else{let h=Et(u);if(h){let d=String(f);it(d)&&mt(h,d,c)}}}return[o]}case"truncate_stream":{let i=typeof t=="number"?Math.floor(t):0;if(n.length===0)return[];let o=[],a=s(t,n[0],r);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var V$,O4=I(()=>{"use strict";Vn();ru();V$=2e3});function ym(t,e,n,r,s,i,o,a,l,c){switch(e){case"getpath":{if(n.length===0)return[null];let u=s(t,n[0],r),f=[];for(let h of u){let d=h,p=t;for(let m of d){if(p==null){p=null;break}if(Array.isArray(p)&&typeof m=="number")p=p[m];else if(typeof m=="string"){let g=Et(p);if(!g||!Object.hasOwn(g,m)){p=null;break}p=g[m]}else{p=null;break}}f.push(p)}return f}case"setpath":{if(n.length<2)return[null];let f=s(t,n[0],r)[0],d=s(t,n[1],r)[0];return[o(t,f,d)]}case"delpaths":{if(n.length===0)return[t];let f=s(t,n[0],r)[0],h=t;for(let d of f.sort((p,m)=>m.length-p.length))h=a(h,d);return[h]}case"path":{if(n.length===0)return[[]];let u=[];return c(t,n[0],r,[],u),u}case"del":return n.length===0?[t]:[l(t,n[0],r)];case"pick":{if(n.length===0)return[null];let u=[];for(let h of n)c(t,h,r,[],u);let f=null;for(let h of u){for(let p of h)if(typeof p=="number"&&p<0)throw new Error("Out of bounds negative array index");let d=t;for(let p of h){if(d==null)break;if(Array.isArray(d)&&typeof p=="number")d=d[p];else if(typeof p=="string"){let m=Et(d);if(!m||!Object.hasOwn(m,p)){d=null;break}d=m[p]}else{d=null;break}}f=o(f,h,d)}return[f]}case"paths":{let u=[],f=(h,d)=>{if(h&&typeof h=="object")if(Array.isArray(h))for(let p=0;p<h.length;p++)u.push([...d,p]),f(h[p],[...d,p]);else for(let p of Object.keys(h))u.push([...d,p]),f(h[p],[...d,p])};return f(t,[]),n.length>0?u.filter(h=>{let d=t;for(let m of h)if(Array.isArray(d)&&typeof m=="number")d=d[m];else if(typeof m=="string"){let g=Et(d);if(!g||!Object.hasOwn(g,m))return!1;d=g[m]}else return!1;return s(d,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(h,d)=>{if(h===null||typeof h!="object")u.push(d);else if(Array.isArray(h))for(let p=0;p<h.length;p++)f(h[p],[...d,p]);else for(let p of Object.keys(h))f(h[p],[...d,p])};return f(t,[]),u}default:return null}}var I4=I(()=>{"use strict";Vn()});function wm(t,e,n,r,s,i){switch(e){case"IN":{if(n.length===0)return[!1];if(n.length===1){let c=s(t,n[0],r);for(let u of c)if(i(t,u))return[!0];return[!1]}let o=s(t,n[0],r),a=s(t,n[1],r),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(n.length===0)return[Object.create(null)];if(n.length===1){let l=s(t,n[0],r),c=Object.create(null);for(let u of l){let f=String(u);it(f)&&mt(c,f,u)}return[c]}if(n.length===2){let l=s(t,n[0],r),c=Object.create(null);for(let u of l){let f=s(u,n[1],r);if(f.length>0){let h=String(f[0]);it(h)&&mt(c,h,u)}}return[c]}let o=s(t,n[0],r),a=Object.create(null);for(let l of o){let c=s(l,n[1],r),u=s(l,n[2],r);if(c.length>0&&u.length>0){let f=String(c[0]);it(f)&&mt(a,f,u[0])}}return[a]}case"JOIN":{if(n.length<2)return[null];let o=Et(s(t,n[0],r)[0]);if(!o)return[null];if(!Array.isArray(t))return[null];let a=[];for(let l of t){let c=s(l,n[1],r),u=c.length>0?String(c[0]):"",f=fs(o,u)?o[u]:null;a.push([l,f])}return[a]}default:return null}}var P4=I(()=>{"use strict";Vn()});function bm(t,e,n,r,s){switch(e){case"join":{if(!Array.isArray(t))return[null];let i=n.length>0?s(t,n[0],r):[""];for(let o of t)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>t.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof t!="string"||n.length===0)return[null];let i=s(t,n[0],r),o=String(i[0]);return[t.split(o)]}case"splits":{if(typeof t!="string"||n.length===0)return[];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"g";return X(o,a.includes("g")?a:`${a}g`).split(t)}catch{return[]}}case"scan":{if(typeof t!="string"||n.length===0)return[];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"";return[...X(o,a.includes("g")?a:`${a}g`).matchAll(t)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof t!="string"||n.length===0)return[!1];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"";return[X(o,a).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||n.length===0)return[null];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"",c=X(o,`${a}d`).exec(t);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,h)=>({offset:u?.[h+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||n.length===0)return[null];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"",c=X(o,a).match(t);return!c||!c.groups?[Object.create(null)]:[c.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(t,n[2],r)[0]):"";return[X(a,c).replace(t,l)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(t,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[X(a,u).replace(t,l)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||n.length===0)return[t];let i=s(t,n[0],r),o=String(i[0]);return[t.startsWith(o)?t.slice(o.length):t]}case"rtrimstr":{if(typeof t!="string"||n.length===0)return[t];let i=s(t,n[0],r),o=String(i[0]);return o===""?[t]:[t.endsWith(o)?t.slice(0,-o.length):t]}case"trimstr":{if(typeof t!="string"||n.length===0)return[t];let i=s(t,n[0],r),o=String(i[0]);if(o==="")return[t];let a=t;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof t=="string")return[t.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof t=="string")return[t.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof t=="string")return[t.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof t!="string"||n.length===0)return[!1];let i=s(t,n[0],r);return[t.startsWith(String(i[0]))]}case"endswith":{if(typeof t!="string"||n.length===0)return[!1];let i=s(t,n[0],r);return[t.endsWith(String(i[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var R4=I(()=>{"use strict";bt()});function Em(t,e){switch(e){case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"values":return t===null?[]:[t];case"not":return t===!1||t===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var $4=I(()=>{"use strict"});var F4=I(()=>{"use strict";S4();A4();v4();C4();k4();N4();T4();O4();I4();P4();R4();$4()});function su(t,e,n){if(e.length===0)return n;let[r,...s]=e;if(typeof r=="number"){if(t&&typeof t=="object"&&!Array.isArray(t))throw new Error("Cannot index object with number");if(r>536870911)throw new Error("Array index too large");if(r<0)throw new Error("Out of bounds negative array index");let c=Array.isArray(t)?[...t]:[];for(;c.length<=r;)c.push(null);return c[r]=su(c[r],s,n),c}if(Array.isArray(t))throw new Error("Cannot index array with string");if(!it(r))return t??Object.create(null);let i=Et(t),o=i?zt(i):Object.create(null),a=Object.hasOwn(o,r)?o[r]:void 0;return mt(o,r,su(a,s,n)),o}function iu(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i=String(s);if(!it(i))return t;let o=zt(t);return delete o[i],o}return t}let[n,...r]=e;if(Array.isArray(t)&&typeof n=="number"){let s=[...t];return s[n]=iu(s[n],r),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s=String(n);if(!it(s))return t;let i=zt(t);return Object.hasOwn(i,s)&&mt(i,s,iu(i[s],r)),i}return t}var _4=I(()=>{"use strict";Vn()});function Z$(t){return{vars:t?.vars?new Map(t.vars):new Map,limits:{maxIterations:t?.limits?.maxIterations??G$,maxDepth:t?.limits?.maxDepth??M4},env:t?.env,coverage:t?.coverage,requireDefenseContext:t?.requireDefenseContext,defenseContextChecked:!1}}function lu(t,e,n){let r=new Map(t.vars);return r.set(e,n),{vars:r,limits:t.limits,env:t.env,requireDefenseContext:t.requireDefenseContext,defenseContextChecked:t.defenseContextChecked,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels,coverage:t.coverage}}function Za(t,e,n){switch(e.type){case"var":return lu(t,e.name,n);case"array":{if(!Array.isArray(n))return null;let r=t;for(let s=0;s<e.elements.length;s++){let i=e.elements[s],o=s<n.length?n[s]:null,a=Za(r,i,o);if(a===null)return null;r=a}return r}case"object":{let r=Et(n);if(!r)return null;let s=t;for(let i of e.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=Z(n,i.key,t);if(c.length===0)return null;o=String(c[0])}let a=fs(r,o)?r[o]:null;i.keyVar&&(s=lu(s,i.keyVar,a));let l=Za(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function Y$(t,e){let n=t;for(let r of e)if(n&&typeof n=="object")if(Array.isArray(n))if(typeof r=="number")n=n[r];else return;else{let s=Et(n);if(s&&typeof r=="string"&&Object.hasOwn(s,r))n=s[r];else return}else return;return n}function Ys(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?Ys(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?Ys(t.base):[];if(e===null)return null;let n=t.index.value;return typeof n=="number"||typeof n=="string"?[...e,n]:null}if(t.type==="Pipe"){let e=Ys(t.left);return e===null?null:xm(e,t.right)}if(t.type==="Call"){if(t.name==="parent"||t.name==="root")return null;if(t.name==="first"&&t.args.length===0)return[0];if(t.name==="last"&&t.args.length===0)return[-1]}return null}function xm(t,e){if(e.type==="Call"){if(e.name==="parent"){let n=1;if(e.args.length>0&&e.args[0].type==="Literal"){let r=e.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return t.slice(0,Math.max(0,t.length-n));{let r=-n-1;return t.slice(0,Math.min(r,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let n=Ys(e);if(n!==null)return[...t,...n]}if(e.type==="Index"&&e.index.type==="Literal"){let n=Ys(e);if(n!==null)return[...t,...n]}if(e.type==="Pipe"){let n=xm(t,e.left);return n===null?null:xm(n,e.right)}return e.type==="Identity"?t:null}function Q$(t){return t!==void 0&&t.vars instanceof Map&&"defenseContextChecked"in t}function D4(t,e,n){if(e.type==="Comma"){let r=[];try{r.push(...Z(t,e.left,n))}catch(s){if(s instanceof ie)throw s;if(r.length>0)return r;throw new Error("evaluation failed")}try{r.push(...Z(t,e.right,n))}catch(s){if(s instanceof ie)throw s;return r}return r}return Z(t,e,n)}function Z(t,e,n){let r=Q$(n)?n:Z$(n);switch(r.defenseContextChecked||(Ot(r.requireDefenseContext,"query-engine","evaluation"),r={...r,defenseContextChecked:!0}),r.root===void 0&&(r={...r,root:t,currentPath:[]}),r.coverage?.hit(`jq:node:${e.type}`),e.type){case"Identity":return[t];case"Field":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>{let o=Et(i);if(o){if(!Object.hasOwn(o,e.name))return[null];let l=o[e.name];return[l===void 0?null:l]}if(i===null)return[null];let a=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${a} with string "${e.name}"`)});case"Index":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>Z(i,e.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof a=="string"){let l=Et(i);return!l||!Object.hasOwn(l,a)?[null]:[l[a]]}return[null]}));case"Slice":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=e.start?Z(t,e.start,r):[0],l=e.end?Z(t,e.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=c,h=u,d=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),p=Number.isNaN(h)?o:Number.isInteger(h)?h:Math.ceil(h),m=L4(d,o),g=L4(p,o);return Array.isArray(i),i.slice(m,g)}))});case"Iterate":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=Z(t,e.left,r),i=Ys(e.left),o=[];for(let a of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};o.push(...Z(a,e.right,l))}else o.push(...Z(a,e.right,r))}catch(l){throw l instanceof Fo?l.withPrependedResults(o):l}return o}case"Comma":{let s=Z(t,e.left,r),i=Z(t,e.right,r);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[Z(t,e.elements,r)]:[[]];case"Object":{let s=[Object.create(null)];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:Z(t,i.key,r),a=Z(t,i.value,r),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}if(!it(u)){for(let f of a)l.push(zt(c));continue}for(let f of a){let h=zt(c);mt(h,u,f),l.push(h)}}s.length=0,s.push(...l)}return s}case"Paren":return Z(t,e.expr,r);case"BinaryOp":return eF(t,e.op,e.left,e.right,r);case"UnaryOp":return Z(t,e.operand,r).map(i=>{if(e.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return e.op==="not"?!kr(i):null});case"Cond":return Z(t,e.cond,r).flatMap(i=>{if(kr(i))return Z(t,e.then,r);for(let o of e.elifs)if(Z(t,o.cond,r).some(kr))return Z(t,o.then,r);return e.else?Z(t,e.else,r):[t]});case"Try":try{return Z(t,e.body,r)}catch(s){if(e.catch){let i=s instanceof au?s.value:s instanceof Error?s.message:String(s);return Z(i,e.catch,r)}return[]}case"Call":return B4(t,e.name,e.args,r);case"VarBind":return Z(t,e.value,r).flatMap(i=>{let o=null,a=[];e.pattern?a.push(e.pattern):e.name&&a.push({type:"var",name:e.name}),e.alternatives&&a.push(...e.alternatives);for(let l of a)if(o=Za(r,l,i),o!==null)break;return o===null?[]:Z(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[r.env?qt(r.env):Object.create(null)];let s=r.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return Z(t,e.expr,r)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:Z(t,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[X$(t,e.path,e.op,e.value,r)];case"Reduce":{let s=Z(t,e.expr,r),i=Z(t,e.init,r)[0],o=r.limits.maxDepth??M4;for(let a of s){let l;if(e.pattern){if(l=Za(r,e.pattern,a),l===null)continue}else l=lu(r,e.varName,a);if(i=Z(i,e.update,l)[0],$o(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=Z(t,e.expr,r),i=Z(t,e.init,r)[0],o=[];for(let a of s)try{let l;if(e.pattern){if(l=Za(r,e.pattern,a),l===null)continue}else l=lu(r,e.varName,a);if(i=Z(i,e.update,l)[0],e.extract){let c=Z(i,e.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof Fo?l.withPrependedResults(o):l}return o}case"Label":try{return Z(t,e.body,{...r,labels:new Set([...r.labels??[],e.name])})}catch(s){if(s instanceof Fo&&s.label===e.name)return s.partialResults;throw s}case"Break":throw new Fo(e.name);case"Def":{let s=new Map(r.funcs??[]),i=`${e.name}/${e.params.length}`;s.set(i,{params:e.params,body:e.funcBody,closure:new Map(r.funcs??[])});let o={...r,funcs:s};return Z(t,e.body,o)}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function L4(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function X$(t,e,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return Z(l,r,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?Cp(l,c):c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(!it(c.name))return l;if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let h=zt(f),d=Object.hasOwn(h,c.name)?h[c.name]:void 0;return mt(h,c.name,u(d)),h}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f=zt(l),h=Object.hasOwn(f,c.name)?f[c.name]:void 0;return mt(f,c.name,u(h)),f}return l}case"Index":{let h=Z(t,c.index,s)[0];if(typeof h=="number"&&Number.isNaN(h))throw new Error("Cannot set array element at NaN index");if(typeof h=="number"&&!Number.isInteger(h)&&(h=Math.trunc(h)),c.base)return o(l,c.base,d=>{if(typeof h=="number"&&Array.isArray(d)){let p=[...d],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(typeof h=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!it(h))return d;let p=zt(d),m=Object.hasOwn(p,h)?p[h]:void 0;return mt(p,h,u(m)),p}return d});if(typeof h=="number"){if(h>536870911)throw new Error("Array index too large");if(h<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let p=[...l],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(l==null){let p=[];for(;p.length<=h;)p.push(null);return p[h]=u(null),p}return l}if(typeof h=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!it(h))return l;let d=zt(l),p=Object.hasOwn(d,h)?d[h]:void 0;return mt(d,h,u(p)),d}return l}case"Iterate":{let f=h=>{if(Array.isArray(h))return h.map(d=>u(d));if(h&&typeof h=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(h))it(p)&&mt(d,p,u(m));return d}return h};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,h=>h);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(n==="|=")return i(l,l);let c=Z(t,r,s);return i(l,c[0]??null)})}function J$(t,e,n){function r(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(!it(o.name))return i;if(o.base){let l=Z(i,o.base,n)[0],c=r(l,{type:"Field",name:o.name},a);return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l=zt(i);return mt(l,o.name,a),l}return i}case"Index":{if(o.base){let u=Z(i,o.base,n)[0],f=r(u,{type:"Index",index:o.index},a);return r(i,o.base,f)}let c=Z(t,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!it(c))return i;let u=zt(i);return mt(u,c,a),u}return i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(!it(o.name))return i;if(o.base){let l=Z(i,o.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!it(o.name))return i;let l=zt(i);return delete l[o.name],l}return i}case"Index":{if(o.base){let u=Z(i,o.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return r(i,o.base,f)}let c=Z(t,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!it(c))return i;let u=zt(i);return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let u=function(d,p,m){switch(p.type){case"Identity":return m;case"Field":{if(!it(p.name))return d;if(d&&typeof d=="object"&&!Array.isArray(d)){let g=zt(d);return mt(g,p.name,m),g}return d}case"Index":{let y=Z(t,p.index,n)[0];if(typeof y=="number"&&Array.isArray(d)){let w=[...d],b=y<0?w.length+y:y;return b>=0&&b<w.length&&(w[b]=m),w}if(typeof y=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!it(y))return d;let w=zt(d);return mt(w,y,m),w}return d}case"Pipe":{let g=Z(d,p.left,n)[0],y=u(g,p.right,m);return u(d,p.left,y)}default:return d}};var a=u;let l=o.left,c=o.right,f=Z(i,l,n)[0];if(f==null)return i;let h=s(f,c);return u(i,l,h)}default:return i}}return s(t,e)}function eF(t,e,n,r,s){if(e==="and")return Z(t,n,s).flatMap(l=>kr(l)?Z(t,r,s).map(u=>kr(u)):[!1]);if(e==="or")return Z(t,n,s).flatMap(l=>kr(l)?[!0]:Z(t,r,s).map(u=>kr(u)));if(e==="//"){let l=Z(t,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:Z(t,r,s)}let i=Z(t,n,s),o=Z(t,r,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return a===null?l:l===null?a:typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?Cp(a,l):null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":if(typeof a=="number"&&typeof l=="number")return a*l;if(typeof a=="string"&&typeof l=="number")return a.repeat(l);{let c=Et(a),u=Et(l);if(c&&u)return fm(c,u)}return null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return Ro(a,l);case"!=":return!Ro(a,l);case"<":return Ka(a,l)<0;case"<=":return Ka(a,l)<=0;case">":return Ka(a,l)>0;case">=":return Ka(a,l)>=0;default:return null}}))}function B4(t,e,n,r){let s=K$.get(e);if(s)return typeof t=="number"?[s(t)]:[null];let i=pm(t,e,n,r,Z);if(i!==null)return i;let o=bm(t,e,n,r,Z);if(o!==null)return o;let a=um(t,e,n,r,Z);if(a!==null)return a;let l=hm(t,e,r.limits.maxDepth);if(l!==null)return l;let c=Em(t,e);if(c!==null)return c;let u=gm(t,e,n,r,Z);if(u!==null)return u;let f=lm(t,e,n,r,Z,D4,tu,kr,nu,ie);if(f!==null)return f;let h=ym(t,e,n,r,Z,kr,su,iu,J$,ou);if(h!==null)return h;let d=dm(t,e,n,r,Z,Ro);if(d!==null)return d;let p=cm(t,e,n,r,Z,D4,kr,ie);if(p!==null)return p;let m=mm(t,e,n,r,Z,kr,Y$,B4);if(m!==null)return m;let g=wm(t,e,n,r,Z,Ro);if(g!==null)return g;switch(e){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let y=n.length>0?Z(t,n[0],r)[0]:t;throw new au(y)}case"env":return[r.env?qt(r.env):Object.create(null)];case"debug":return[t];case"input_line_number":return[1];default:{let y=`${e}/${n.length}`,w=r.funcs?.get(y);if(w){let b=w.closure??r.funcs??new Map,E=new Map(b);E.set(y,w);for(let C=0;C<w.params.length;C++){let P=w.params[C],$=n[C];if($){let O=Z(t,$,r),R;if(O.length===0)R={type:"Call",name:"empty",args:[]};else if(O.length===1)R={type:"Literal",value:O[0]};else{R={type:"Literal",value:O[O.length-1]};for(let k=O.length-2;k>=0;k--)R={type:"Comma",left:{type:"Literal",value:O[k]},right:R}}E.set(`${P}/0`,{params:[],body:R})}}let A={...r,funcs:E};return Z(t,w.body,A)}throw new Error(`Unknown function: ${e}`)}}}function ou(t,e,n,r,s){if(e.type==="Comma"){let a=e;ou(t,a.left,n,r,s),ou(t,a.right,n,r,s);return}let i=Ys(e);if(i!==null){s.push([...r,...i]);return}if(e.type==="Iterate"){if(Array.isArray(t))for(let a=0;a<t.length;a++)s.push([...r,a]);else if(t&&typeof t=="object")for(let a of Object.keys(t))s.push([...r,a]);return}if(e.type==="Recurse"){let a=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(t,[]);return}if(e.type==="Pipe"){let a=Ys(e.left);if(a!==null){let l=Z(t,e.left,n);for(let c of l)ou(c,e.right,n,[...r,...a],s);return}}Z(t,e,n).length>0&&s.push(r)}var Fo,au,G$,M4,K$,U4=I(()=>{"use strict";Ar();Me();lr();F4();_4();Vn();ru();Fo=class t extends Error{label;partialResults;constructor(e,n=[]){super(`break ${e}`),this.label=e,this.partialResults=n,this.name="BreakError"}withPrependedResults(e){return new t(this.label,[...e,...this.partialResults])}},au=class extends Error{value;constructor(e){super(typeof e=="string"?e:JSON.stringify(e)),this.value=e,this.name="JqError"}},G$=1e4,M4=2e3,K$=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function W4(t){let e=[],n=0,r=(c=0)=>t[n+c],s=()=>t[n++],i=()=>n>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
553
+ `,exitCode:127}}}};im={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},om={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function lm(t,e,n,r,s,i,o,a,l,c){switch(e){case"sort":return Array.isArray(t)?[[...t].sort(o)]:[null];case"sort_by":return!Array.isArray(t)||n.length===0?[null]:[[...t].sort((f,h)=>{let d=s(f,n[0],r)[0],p=s(h,n[0],r)[0];return o(d,p)})];case"bsearch":{if(!Array.isArray(t)){let f=t===null?"null":typeof t=="object"?"object":typeof t;throw new Error(`${f} (${JSON.stringify(t)}) cannot be searched from`)}return n.length===0?[null]:s(t,n[0],r).map(f=>{let h=0,d=t.length;for(;h<d;){let p=h+d>>>1;o(t[p],f)<0?h=p+1:d=p}return h<t.length&&o(t[h],f)===0?h:-h-1})}case"unique_by":{if(!Array.isArray(t)||n.length===0)return[null];let u=new Map;for(let h of t){let d=s(h,n[0],r)[0],p=JSON.stringify(d);u.has(p)||u.set(p,{item:h,key:d})}let f=[...u.values()];return f.sort((h,d)=>o(h.key,d.key)),[f.map(h=>h.item)]}case"group_by":{if(!Array.isArray(t)||n.length===0)return[null];let u=new Map;for(let f of t){let h=JSON.stringify(s(f,n[0],r)[0]);u.has(h)||u.set(h,[]),u.get(h)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((u,f)=>o(u,f)>0?u:f)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((u,f)=>{let h=s(u,n[0],r)[0],d=s(f,n[0],r)[0];return o(h,d)>0?u:f})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((u,f)=>o(u,f)<0?u:f)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||n.length===0?[null]:[t.reduce((u,f)=>{let h=s(u,n[0],r)[0],d=s(f,n[0],r)[0];return o(h,d)<0?u:f})];case"add":{let u=f=>{let h=f.filter(d=>d!==null);return h.length===0?null:h.every(d=>typeof d=="number")?h.reduce((d,p)=>d+p,0):h.every(d=>typeof d=="string")?h.join(""):h.every(d=>Array.isArray(d))?h.flat():h.every(d=>d&&typeof d=="object"&&!Array.isArray(d))?Ps(...h):null};if(n.length>=1){let f=s(t,n[0],r);return[u(f)]}return Array.isArray(t)?[u(t)]:[null]}case"any":{if(n.length>=2){try{let u=i(t,n[0],r);for(let f of u)if(s(f,n[1],r).some(a))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(t)?[t.some(u=>a(s(u,n[0],r)[0]))]:[!1]:Array.isArray(t)?[t.some(a)]:[!1]}case"all":{if(n.length>=2){try{let u=i(t,n[0],r);for(let f of u)if(!s(f,n[1],r).some(a))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(t)?[t.every(u=>a(s(u,n[0],r)[0]))]:[!0]:Array.isArray(t)?[t.every(a)]:[!0]}case"select":return n.length===0?[t]:s(t,n[0],r).some(a)?[t]:[];case"map":return n.length===0||!Array.isArray(t)?[null]:[t.flatMap(f=>s(f,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(t))return[t.flatMap(u=>s(u,n[0],r))];if(t&&typeof t=="object"){let u=Object.create(null);for(let[f,h]of Object.entries(t)){if(!it(f))continue;let d=s(h,n[0],r);d.length>0&&mt(u,f,d[0])}return[u]}return[null]}case"has":{if(n.length===0)return[!1];let f=s(t,n[0],r)[0];return Array.isArray(t)&&typeof f=="number"?[f>=0&&f<t.length]:t&&typeof t=="object"&&typeof f=="string"?[hs(t,f)]:[!1]}case"in":{if(n.length===0)return[!1];let f=s(t,n[0],r)[0];return Array.isArray(f)&&typeof t=="number"?[t>=0&&t<f.length]:f&&typeof f=="object"&&typeof t=="string"?[hs(f,t)]:[!1]}case"contains":{if(n.length===0)return[!1];let u=s(t,n[0],r);return[l(t,u[0])]}case"inside":{if(n.length===0)return[!1];let u=s(t,n[0],r);return[l(u[0],t)]}default:return null}}var S4=I(()=>{"use strict";Ar();Vn()});function cm(t,e,n,r,s,i,o,a){switch(e){case"first":if(n.length>0)try{let l=i(t,n[0],r);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof a)throw l;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(n.length>0){let l=s(t,n[0],r);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(n.length<1)return[null];let l=s(t,n[0],r);if(n.length>1){for(let u of l)if(u<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(t,n[1],r)}catch(u){if(u instanceof a)throw u;c=[]}return l.flatMap(u=>{let f=u;return f<c.length?[c[f]]:[]})}return Array.isArray(t)?l.flatMap(c=>{let u=c;if(u<0)throw new Error("nth doesn't support negative indices");return u<t.length?[t[u]]:[null]}):[null]}case"range":{if(n.length===0)return[];let l=Math.max(r.limits.maxIterations*100,1e6),c=p=>p.length>=l,u=s(t,n[0],r);if(n.length===1){let p=[];for(let m of u){let g=m;for(let y=0;y<g;y++)if(p.push(y),c(p))return p}return p}let f=s(t,n[1],r);if(n.length===2){let p=[];for(let m of u)for(let g of f){let y=m,w=g;for(let b=y;b<w;b++)if(p.push(b),c(p))return p}return p}let h=s(t,n[2],r),d=[];for(let p of u)for(let m of f)for(let g of h){let y=p,w=m,b=g;if(b!==0){if(b>0){for(let E=y;E<w;E+=b)if(d.push(E),c(d))return d}else for(let E=y;E>w;E+=b)if(d.push(E),c(d))return d}}return d}case"limit":return n.length<2?[]:s(t,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(t,n[1],r)}catch(h){if(h instanceof a)throw h;f=[]}return f.slice(0,u)});case"isempty":{if(n.length<1)return[!0];try{return[i(t,n[0],r).length===0]}catch(l){if(l instanceof a)throw l;return[!0]}}case"isvalid":{if(n.length<1)return[!0];try{return[s(t,n[0],r).length>0]}catch(l){if(l instanceof a)throw l;return[!1]}}case"skip":return n.length<2?[]:s(t,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("skip doesn't support negative count");return s(t,n[1],r).slice(u)});case"until":{if(n.length<2)return[t];let l=t,c=r.limits.maxIterations;for(let u=0;u<c;u++){if(s(l,n[0],r).some(o))return[l];let h=s(l,n[1],r);if(h.length===0)return[l];l=h[0]}throw new a(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[t];let l=[],c=t,u=r.limits.maxIterations;for(let f=0;f<u&&s(c,n[0],r).some(o);f++){l.push(c);let d=s(c,n[1],r);if(d.length===0)break;c=d[0]}if(l.length>=u)throw new a(`jq while: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(n.length===0)return[t];let l=[],c=t,u=r.limits.maxIterations;for(let f=0;f<u;f++){l.push(c);let h=s(c,n[0],r);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new a(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var A4=I(()=>{"use strict"});function um(t,e,n,r,s){switch(e){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let i=new Date(t*1e3),o=i.getUTCFullYear(),a=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),h=i.getUTCDay(),d=Date.UTC(o,0,1),p=Math.floor((i.getTime()-d)/(1440*60*1e3));return[[o,a,l,c,u,f,h,p]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[i,o,a,l=0,c=0,u=0]=t;if(typeof i!="number"||typeof o!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,o,a??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let o=s(t,n[0],r)[0];if(typeof o!="string")throw new Error("strftime/1 requires a string format");let a;if(typeof t=="number")a=new Date(t*1e3);else if(Array.isArray(t)){let[h,d,p,m=0,g=0,y=0]=t;if(typeof h!="number"||typeof d!="number")throw new Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(h,d,p??1,m??0,g??0,y??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(h,d=2)=>String(h).padStart(d,"0");return[o.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,u(a.getUTCMonth()+1)).replace(/%d/g,u(a.getUTCDate())).replace(/%H/g,u(a.getUTCHours())).replace(/%M/g,u(a.getUTCMinutes())).replace(/%S/g,u(a.getUTCSeconds())).replace(/%A/g,l[a.getUTCDay()]).replace(/%B/g,c[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(n.length===0)return[null];if(typeof t!="string")throw new Error("strptime/1 requires a string input");let o=s(t,n[0],r)[0];if(typeof o!="string")throw new Error("strptime/1 requires a string format");if(o==="%Y-%m-%dT%H:%M:%SZ"){let l=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(l){let[,c,u,f,h,d,p]=l.map(Number),m=new Date(Date.UTC(c,u-1,f,h,d,p)),g=m.getUTCDay(),y=Date.UTC(c,0,1),w=Math.floor((m.getTime()-y)/(1440*60*1e3));return[[c,u-1,f,h,d,p,g,w]]}}let a=new Date(t);if(!Number.isNaN(a.getTime())){let l=a.getUTCFullYear(),c=a.getUTCMonth(),u=a.getUTCDate(),f=a.getUTCHours(),h=a.getUTCMinutes(),d=a.getUTCSeconds(),p=a.getUTCDay(),m=Date.UTC(l,0,1),g=Math.floor((a.getTime()-m)/(1440*60*1e3));return[[l,c,u,f,h,d,p,g]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let i=new Date(t);if(Number.isNaN(i.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof t!="number")throw new Error("todate requires a number input");return[new Date(t*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}var v4=I(()=>{"use strict"});function kr(t){return t!==!1&&t!==null}function Ro(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Ka(t,e){return typeof t=="number"&&typeof e=="number"?t-e:typeof t=="string"&&typeof e=="string"?t.localeCompare(e):0}function fm(t,e){let n=zt(t);for(let r of Object.keys(e)){if(!it(r))continue;let s=hs(n,r)?Et(n[r]):null,i=Et(e[r]);s&&i?mt(n,r,fm(s,i)):mt(n,r,e[r])}return n}function $o(t,e=3e3){let n=0,r=t;for(;n<e;)if(Array.isArray(r)){if(r.length===0)return n+1;r=r[0],n++}else if(r!==null&&typeof r=="object"){let s=Object.keys(r);if(s.length===0)return n+1;r=r[s[0]],n++}else return n;return n}function tu(t,e){let n=a=>a===null?0:typeof a=="boolean"?1:typeof a=="number"?2:typeof a=="string"?3:Array.isArray(a)?4:typeof a=="object"?5:6,r=n(t),s=n(e);if(r!==s)return r-s;if(typeof t=="number"&&typeof e=="number")return t-e;if(typeof t=="string"&&typeof e=="string")return t.localeCompare(e);if(typeof t=="boolean"&&typeof e=="boolean")return(t?1:0)-(e?1:0);if(Array.isArray(t)&&Array.isArray(e)){for(let a=0;a<Math.min(t.length,e.length);a++){let l=tu(t[a],e[a]);if(l!==0)return l}return t.length-e.length}let i=Et(t),o=Et(e);if(i&&o){let a=Object.keys(i).sort(),l=Object.keys(o).sort();for(let c=0;c<Math.min(a.length,l.length);c++){let u=a[c].localeCompare(l[c]);if(u!==0)return u}if(a.length!==l.length)return a.length-l.length;for(let c of a){let u=tu(i[c],o[c]);if(u!==0)return u}}return 0}function nu(t,e){if(Ro(t,e))return!0;if(typeof t=="string"&&typeof e=="string")return t.includes(e);if(Array.isArray(t)&&Array.isArray(e))return e.every(s=>t.some(i=>nu(i,s)));let n=Et(t),r=Et(e);return n&&r?Object.keys(r).every(s=>hs(n,s)&&nu(n[s],r[s])):!1}var ru=I(()=>{"use strict";Vn()});function hm(t,e,n){switch(e){case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof t=="string"?[decodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(s=>{if(s===null)return"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="number")return String(s);let i=String(s);return i.includes(",")||i.includes('"')||i.includes(`
554
+ `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(r=>String(r??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let r=n??H$;return $o(t,r+1)>r?[null]:[JSON.stringify(t)]}case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];default:return null}}var H$,C4=I(()=>{"use strict";ru();H$=2e3});function dm(t,e,n,r,s,i){switch(e){case"index":return n.length===0?[null]:s(t,n[0],r).map(a=>{if(typeof t=="string"&&typeof a=="string"){if(a===""&&t==="")return null;let l=t.indexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let c=0;c<=t.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(t[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=t.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(t,n[0],r).map(a=>{if(typeof t=="string"&&typeof a=="string"){let l=t.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let l=t.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(t[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=t.length-1;l>=0;l--)if(i(t[l],a))return l;return null}return null});case"indices":return n.length===0?[[]]:s(t,n[0],r).map(a=>{let l=[];if(typeof t=="string"&&typeof a=="string"){let c=t.indexOf(a);for(;c!==-1;)l.push(c),c=t.indexOf(a,c+1)}else if(Array.isArray(t))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=t.length;u++)l.push(u);else for(let u=0;u<=t.length-c;u++){let f=!0;for(let h=0;h<c;h++)if(!i(t[u+h],a[h])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<t.length;c++)i(t[c],a)&&l.push(c);return l});default:return null}}var k4=I(()=>{"use strict"});function pm(t,e,n,r,s){switch(e){case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:typeof t=="string"?[t]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.hypot(t,i)]}case"fma":{if(typeof t!="number"||n.length<2)return[null];let i=s(t,n[0],r)[0],o=s(t,n[1],r)[0];return[t*i+o]}case"copysign":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.sign(i)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[t-Math.round(t/i)*i]}case"fdim":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.max(0,t-i)]}case"fmax":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.max(t,i)]}case"fmin":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[Math.min(t,i)]}case"ldexp":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[t*2**i]}case"scalbn":case"scalbln":{if(typeof t!="number"||n.length===0)return[null];let i=s(t,n[0],r)[0];return[t*2**i]}case"nearbyint":return typeof t=="number"?[Math.round(t)]:[null];case"logb":return typeof t=="number"?[Math.floor(Math.log2(Math.abs(t)))]:[null];case"significand":if(typeof t=="number"){let i=Math.floor(Math.log2(Math.abs(t)));return[t/2**i]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**i,i]]}return[null];case"modf":if(typeof t=="number"){let i=Math.trunc(t);return[[t-i,i]]}return[null];default:return null}}var N4=I(()=>{"use strict"});function mm(t,e,n,r,s,i,o,a){switch(e){case"recurse":{if(n.length===0){let d=[],p=m=>{if(d.push(m),Array.isArray(m))for(let g of m)p(g);else if(m&&typeof m=="object")for(let g of Object.keys(m))p(m[g])};return p(t),d}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,h=d=>{if(f++>u||c&&!s(d,c,r).some(i))return;l.push(d);let p=s(d,n[0],r);for(let m of p)m!=null&&h(m)};return h(t),l}case"recurse_down":return a(t,"recurse",n,r);case"walk":{if(n.length===0)return[t];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(u))it(p)&&mt(d,p,c(m));f=d}else f=u;return s(f,n[0],r)[0]};return[c(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let l=Math.max(...t.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(t.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(n.length>0){let f=s(t,n[0],r)[0];if(!Array.isArray(t)||f<0)return[];if(f===0)return[[]];let h=[],d=(p,m)=>{if(m===f){h.push([...p]);return}for(let g of t)p.push(g),d(p,m+1),p.pop()};return d([],0),h}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let u of t)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===t.length){l.push([...f]);return}let h=t[u];for(let d of h)f.push(d),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let l=r.currentPath;if(l.length===0)return[];let c=n.length>0?s(t,n[0],r)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[t];let f=l.slice(0,u);return[o(r.root,f)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let l=r.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var T4=I(()=>{"use strict";Vn()});function gm(t,e,n,r,s){switch(e){case"keys":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:typeof t=="number"?[Math.abs(t)]:[null];case"utf8bytelength":{if(typeof t=="string")return[new TextEncoder().encode(t).length];let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":{let i=Et(t);return i?[Object.entries(i).map(([o,a])=>({key:o,value:a}))]:[null]}case"from_entries":if(Array.isArray(t)){let i=Object.create(null);for(let o of t){let a=Et(o);if(a){let l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;if(l!==void 0){let u=String(l);it(u)&&mt(i,u,c)}}}return[i]}return[null];case"with_entries":{if(n.length===0)return[t];let i=Et(t);if(i){let a=Object.entries(i).map(([c,u])=>({key:c,value:u})).flatMap(c=>s(c,n[0],r)),l=Object.create(null);for(let c of a){let u=Et(c);if(u){let f=u.key??u.name??u.k,h=u.value??u.v;if(f!==void 0){let d=String(f);it(d)&&mt(l,d,h)}}}return[l]}return[null]}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(t)?(n.length>0?s(t,n[0],r):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return t.flat(a)}):[null];case"unique":if(Array.isArray(t)){let i=new Set,o=[];for(let a of t){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??V$;return $o(t,i+1)>i?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let i=t.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[gn(JSON.parse(t))]}catch{throw new Error(`Invalid JSON: ${t}`)}}return[t]}case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let i=Number(t);if(Number.isNaN(i))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof t} cannot be parsed as a number`);case"toboolean":{if(typeof t=="boolean")return[t];if(typeof t=="string"){if(t==="true")return[!0];if(t==="false")return[!1];throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`)}let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,Object.create(null)]);else for(let u of c)o(a[u],[...l,u])}};return o(t,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[t];let i=s(t,n[0],r),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:Object.create(null));let u=o;for(let h=0;h<l.length-1;h++){let d=l[h],p=l[h+1];if(Array.isArray(u)&&typeof d=="number"){for(;u.length<=d;)u.push(null);u[d]===null&&(u[d]=typeof p=="number"?[]:Object.create(null)),u=u[d]}else{let m=Et(u);if(m){let g=String(d);if(!it(g))continue;(m[g]===null||m[g]===void 0)&&mt(m,g,typeof p=="number"?[]:Object.create(null)),u=m[g]}}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else{let h=Et(u);if(h){let d=String(f);it(d)&&mt(h,d,c)}}}return[o]}case"truncate_stream":{let i=typeof t=="number"?Math.floor(t):0;if(n.length===0)return[];let o=[],a=s(t,n[0],r);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var V$,O4=I(()=>{"use strict";Vn();ru();V$=2e3});function ym(t,e,n,r,s,i,o,a,l,c){switch(e){case"getpath":{if(n.length===0)return[null];let u=s(t,n[0],r),f=[];for(let h of u){let d=h,p=t;for(let m of d){if(p==null){p=null;break}if(Array.isArray(p)&&typeof m=="number")p=p[m];else if(typeof m=="string"){let g=Et(p);if(!g||!Object.hasOwn(g,m)){p=null;break}p=g[m]}else{p=null;break}}f.push(p)}return f}case"setpath":{if(n.length<2)return[null];let f=s(t,n[0],r)[0],d=s(t,n[1],r)[0];return[o(t,f,d)]}case"delpaths":{if(n.length===0)return[t];let f=s(t,n[0],r)[0],h=t;for(let d of f.sort((p,m)=>m.length-p.length))h=a(h,d);return[h]}case"path":{if(n.length===0)return[[]];let u=[];return c(t,n[0],r,[],u),u}case"del":return n.length===0?[t]:[l(t,n[0],r)];case"pick":{if(n.length===0)return[null];let u=[];for(let h of n)c(t,h,r,[],u);let f=null;for(let h of u){for(let p of h)if(typeof p=="number"&&p<0)throw new Error("Out of bounds negative array index");let d=t;for(let p of h){if(d==null)break;if(Array.isArray(d)&&typeof p=="number")d=d[p];else if(typeof p=="string"){let m=Et(d);if(!m||!Object.hasOwn(m,p)){d=null;break}d=m[p]}else{d=null;break}}f=o(f,h,d)}return[f]}case"paths":{let u=[],f=(h,d)=>{if(h&&typeof h=="object")if(Array.isArray(h))for(let p=0;p<h.length;p++)u.push([...d,p]),f(h[p],[...d,p]);else for(let p of Object.keys(h))u.push([...d,p]),f(h[p],[...d,p])};return f(t,[]),n.length>0?u.filter(h=>{let d=t;for(let m of h)if(Array.isArray(d)&&typeof m=="number")d=d[m];else if(typeof m=="string"){let g=Et(d);if(!g||!Object.hasOwn(g,m))return!1;d=g[m]}else return!1;return s(d,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(h,d)=>{if(h===null||typeof h!="object")u.push(d);else if(Array.isArray(h))for(let p=0;p<h.length;p++)f(h[p],[...d,p]);else for(let p of Object.keys(h))f(h[p],[...d,p])};return f(t,[]),u}default:return null}}var I4=I(()=>{"use strict";Vn()});function wm(t,e,n,r,s,i){switch(e){case"IN":{if(n.length===0)return[!1];if(n.length===1){let c=s(t,n[0],r);for(let u of c)if(i(t,u))return[!0];return[!1]}let o=s(t,n[0],r),a=s(t,n[1],r),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(n.length===0)return[Object.create(null)];if(n.length===1){let l=s(t,n[0],r),c=Object.create(null);for(let u of l){let f=String(u);it(f)&&mt(c,f,u)}return[c]}if(n.length===2){let l=s(t,n[0],r),c=Object.create(null);for(let u of l){let f=s(u,n[1],r);if(f.length>0){let h=String(f[0]);it(h)&&mt(c,h,u)}}return[c]}let o=s(t,n[0],r),a=Object.create(null);for(let l of o){let c=s(l,n[1],r),u=s(l,n[2],r);if(c.length>0&&u.length>0){let f=String(c[0]);it(f)&&mt(a,f,u[0])}}return[a]}case"JOIN":{if(n.length<2)return[null];let o=Et(s(t,n[0],r)[0]);if(!o)return[null];if(!Array.isArray(t))return[null];let a=[];for(let l of t){let c=s(l,n[1],r),u=c.length>0?String(c[0]):"",f=hs(o,u)?o[u]:null;a.push([l,f])}return[a]}default:return null}}var P4=I(()=>{"use strict";Vn()});function bm(t,e,n,r,s){switch(e){case"join":{if(!Array.isArray(t))return[null];let i=n.length>0?s(t,n[0],r):[""];for(let o of t)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>t.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof t!="string"||n.length===0)return[null];let i=s(t,n[0],r),o=String(i[0]);return[t.split(o)]}case"splits":{if(typeof t!="string"||n.length===0)return[];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"g";return X(o,a.includes("g")?a:`${a}g`).split(t)}catch{return[]}}case"scan":{if(typeof t!="string"||n.length===0)return[];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"";return[...X(o,a.includes("g")?a:`${a}g`).matchAll(t)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof t!="string"||n.length===0)return[!1];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"";return[X(o,a).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||n.length===0)return[null];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"",c=X(o,`${a}d`).exec(t);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,h)=>({offset:u?.[h+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||n.length===0)return[null];let i=s(t,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(t,n[1],r)[0]):"",c=X(o,a).match(t);return!c||!c.groups?[Object.create(null)]:[c.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(t,n[2],r)[0]):"";return[X(a,c).replace(t,l)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||n.length<2)return[null];let i=s(t,n[0],r),o=s(t,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(t,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[X(a,u).replace(t,l)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||n.length===0)return[t];let i=s(t,n[0],r),o=String(i[0]);return[t.startsWith(o)?t.slice(o.length):t]}case"rtrimstr":{if(typeof t!="string"||n.length===0)return[t];let i=s(t,n[0],r),o=String(i[0]);return o===""?[t]:[t.endsWith(o)?t.slice(0,-o.length):t]}case"trimstr":{if(typeof t!="string"||n.length===0)return[t];let i=s(t,n[0],r),o=String(i[0]);if(o==="")return[t];let a=t;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof t=="string")return[t.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof t=="string")return[t.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof t=="string")return[t.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof t!="string"||n.length===0)return[!1];let i=s(t,n[0],r);return[t.startsWith(String(i[0]))]}case"endswith":{if(typeof t!="string"||n.length===0)return[!1];let i=s(t,n[0],r);return[t.endsWith(String(i[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var R4=I(()=>{"use strict";bt()});function Em(t,e){switch(e){case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"values":return t===null?[]:[t];case"not":return t===!1||t===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var $4=I(()=>{"use strict"});var F4=I(()=>{"use strict";S4();A4();v4();C4();k4();N4();T4();O4();I4();P4();R4();$4()});function su(t,e,n){if(e.length===0)return n;let[r,...s]=e;if(typeof r=="number"){if(t&&typeof t=="object"&&!Array.isArray(t))throw new Error("Cannot index object with number");if(r>536870911)throw new Error("Array index too large");if(r<0)throw new Error("Out of bounds negative array index");let c=Array.isArray(t)?[...t]:[];for(;c.length<=r;)c.push(null);return c[r]=su(c[r],s,n),c}if(Array.isArray(t))throw new Error("Cannot index array with string");if(!it(r))return t??Object.create(null);let i=Et(t),o=i?zt(i):Object.create(null),a=Object.hasOwn(o,r)?o[r]:void 0;return mt(o,r,su(a,s,n)),o}function iu(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i=String(s);if(!it(i))return t;let o=zt(t);return delete o[i],o}return t}let[n,...r]=e;if(Array.isArray(t)&&typeof n=="number"){let s=[...t];return s[n]=iu(s[n],r),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s=String(n);if(!it(s))return t;let i=zt(t);return Object.hasOwn(i,s)&&mt(i,s,iu(i[s],r)),i}return t}var _4=I(()=>{"use strict";Vn()});function Z$(t){return{vars:t?.vars?new Map(t.vars):new Map,limits:{maxIterations:t?.limits?.maxIterations??G$,maxDepth:t?.limits?.maxDepth??M4},env:t?.env,coverage:t?.coverage,requireDefenseContext:t?.requireDefenseContext,defenseContextChecked:!1}}function lu(t,e,n){let r=new Map(t.vars);return r.set(e,n),{vars:r,limits:t.limits,env:t.env,requireDefenseContext:t.requireDefenseContext,defenseContextChecked:t.defenseContextChecked,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels,coverage:t.coverage}}function Za(t,e,n){switch(e.type){case"var":return lu(t,e.name,n);case"array":{if(!Array.isArray(n))return null;let r=t;for(let s=0;s<e.elements.length;s++){let i=e.elements[s],o=s<n.length?n[s]:null,a=Za(r,i,o);if(a===null)return null;r=a}return r}case"object":{let r=Et(n);if(!r)return null;let s=t;for(let i of e.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=Z(n,i.key,t);if(c.length===0)return null;o=String(c[0])}let a=hs(r,o)?r[o]:null;i.keyVar&&(s=lu(s,i.keyVar,a));let l=Za(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function Y$(t,e){let n=t;for(let r of e)if(n&&typeof n=="object")if(Array.isArray(n))if(typeof r=="number")n=n[r];else return;else{let s=Et(n);if(s&&typeof r=="string"&&Object.hasOwn(s,r))n=s[r];else return}else return;return n}function Ys(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?Ys(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?Ys(t.base):[];if(e===null)return null;let n=t.index.value;return typeof n=="number"||typeof n=="string"?[...e,n]:null}if(t.type==="Pipe"){let e=Ys(t.left);return e===null?null:xm(e,t.right)}if(t.type==="Call"){if(t.name==="parent"||t.name==="root")return null;if(t.name==="first"&&t.args.length===0)return[0];if(t.name==="last"&&t.args.length===0)return[-1]}return null}function xm(t,e){if(e.type==="Call"){if(e.name==="parent"){let n=1;if(e.args.length>0&&e.args[0].type==="Literal"){let r=e.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return t.slice(0,Math.max(0,t.length-n));{let r=-n-1;return t.slice(0,Math.min(r,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let n=Ys(e);if(n!==null)return[...t,...n]}if(e.type==="Index"&&e.index.type==="Literal"){let n=Ys(e);if(n!==null)return[...t,...n]}if(e.type==="Pipe"){let n=xm(t,e.left);return n===null?null:xm(n,e.right)}return e.type==="Identity"?t:null}function Q$(t){return t!==void 0&&t.vars instanceof Map&&"defenseContextChecked"in t}function D4(t,e,n){if(e.type==="Comma"){let r=[];try{r.push(...Z(t,e.left,n))}catch(s){if(s instanceof ie)throw s;if(r.length>0)return r;throw new Error("evaluation failed")}try{r.push(...Z(t,e.right,n))}catch(s){if(s instanceof ie)throw s;return r}return r}return Z(t,e,n)}function Z(t,e,n){let r=Q$(n)?n:Z$(n);switch(r.defenseContextChecked||(Ot(r.requireDefenseContext,"query-engine","evaluation"),r={...r,defenseContextChecked:!0}),r.root===void 0&&(r={...r,root:t,currentPath:[]}),r.coverage?.hit(`jq:node:${e.type}`),e.type){case"Identity":return[t];case"Field":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>{let o=Et(i);if(o){if(!Object.hasOwn(o,e.name))return[null];let l=o[e.name];return[l===void 0?null:l]}if(i===null)return[null];let a=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${a} with string "${e.name}"`)});case"Index":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>Z(i,e.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof a=="string"){let l=Et(i);return!l||!Object.hasOwn(l,a)?[null]:[l[a]]}return[null]}));case"Slice":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=e.start?Z(t,e.start,r):[0],l=e.end?Z(t,e.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=c,h=u,d=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),p=Number.isNaN(h)?o:Number.isInteger(h)?h:Math.ceil(h),m=L4(d,o),g=L4(p,o);return Array.isArray(i),i.slice(m,g)}))});case"Iterate":return(e.base?Z(t,e.base,r):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=Z(t,e.left,r),i=Ys(e.left),o=[];for(let a of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};o.push(...Z(a,e.right,l))}else o.push(...Z(a,e.right,r))}catch(l){throw l instanceof Fo?l.withPrependedResults(o):l}return o}case"Comma":{let s=Z(t,e.left,r),i=Z(t,e.right,r);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[Z(t,e.elements,r)]:[[]];case"Object":{let s=[Object.create(null)];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:Z(t,i.key,r),a=Z(t,i.value,r),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}if(!it(u)){for(let f of a)l.push(zt(c));continue}for(let f of a){let h=zt(c);mt(h,u,f),l.push(h)}}s.length=0,s.push(...l)}return s}case"Paren":return Z(t,e.expr,r);case"BinaryOp":return eF(t,e.op,e.left,e.right,r);case"UnaryOp":return Z(t,e.operand,r).map(i=>{if(e.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return e.op==="not"?!kr(i):null});case"Cond":return Z(t,e.cond,r).flatMap(i=>{if(kr(i))return Z(t,e.then,r);for(let o of e.elifs)if(Z(t,o.cond,r).some(kr))return Z(t,o.then,r);return e.else?Z(t,e.else,r):[t]});case"Try":try{return Z(t,e.body,r)}catch(s){if(e.catch){let i=s instanceof au?s.value:s instanceof Error?s.message:String(s);return Z(i,e.catch,r)}return[]}case"Call":return B4(t,e.name,e.args,r);case"VarBind":return Z(t,e.value,r).flatMap(i=>{let o=null,a=[];e.pattern?a.push(e.pattern):e.name&&a.push({type:"var",name:e.name}),e.alternatives&&a.push(...e.alternatives);for(let l of a)if(o=Za(r,l,i),o!==null)break;return o===null?[]:Z(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[r.env?qt(r.env):Object.create(null)];let s=r.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return Z(t,e.expr,r)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:Z(t,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[X$(t,e.path,e.op,e.value,r)];case"Reduce":{let s=Z(t,e.expr,r),i=Z(t,e.init,r)[0],o=r.limits.maxDepth??M4;for(let a of s){let l;if(e.pattern){if(l=Za(r,e.pattern,a),l===null)continue}else l=lu(r,e.varName,a);if(i=Z(i,e.update,l)[0],$o(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=Z(t,e.expr,r),i=Z(t,e.init,r)[0],o=[];for(let a of s)try{let l;if(e.pattern){if(l=Za(r,e.pattern,a),l===null)continue}else l=lu(r,e.varName,a);if(i=Z(i,e.update,l)[0],e.extract){let c=Z(i,e.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof Fo?l.withPrependedResults(o):l}return o}case"Label":try{return Z(t,e.body,{...r,labels:new Set([...r.labels??[],e.name])})}catch(s){if(s instanceof Fo&&s.label===e.name)return s.partialResults;throw s}case"Break":throw new Fo(e.name);case"Def":{let s=new Map(r.funcs??[]),i=`${e.name}/${e.params.length}`;s.set(i,{params:e.params,body:e.funcBody,closure:new Map(r.funcs??[])});let o={...r,funcs:s};return Z(t,e.body,o)}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function L4(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function X$(t,e,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return Z(l,r,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?Cp(l,c):c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(!it(c.name))return l;if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let h=zt(f),d=Object.hasOwn(h,c.name)?h[c.name]:void 0;return mt(h,c.name,u(d)),h}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f=zt(l),h=Object.hasOwn(f,c.name)?f[c.name]:void 0;return mt(f,c.name,u(h)),f}return l}case"Index":{let h=Z(t,c.index,s)[0];if(typeof h=="number"&&Number.isNaN(h))throw new Error("Cannot set array element at NaN index");if(typeof h=="number"&&!Number.isInteger(h)&&(h=Math.trunc(h)),c.base)return o(l,c.base,d=>{if(typeof h=="number"&&Array.isArray(d)){let p=[...d],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(typeof h=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!it(h))return d;let p=zt(d),m=Object.hasOwn(p,h)?p[h]:void 0;return mt(p,h,u(m)),p}return d});if(typeof h=="number"){if(h>536870911)throw new Error("Array index too large");if(h<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let p=[...l],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(l==null){let p=[];for(;p.length<=h;)p.push(null);return p[h]=u(null),p}return l}if(typeof h=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!it(h))return l;let d=zt(l),p=Object.hasOwn(d,h)?d[h]:void 0;return mt(d,h,u(p)),d}return l}case"Iterate":{let f=h=>{if(Array.isArray(h))return h.map(d=>u(d));if(h&&typeof h=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(h))it(p)&&mt(d,p,u(m));return d}return h};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,h=>h);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(n==="|=")return i(l,l);let c=Z(t,r,s);return i(l,c[0]??null)})}function J$(t,e,n){function r(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(!it(o.name))return i;if(o.base){let l=Z(i,o.base,n)[0],c=r(l,{type:"Field",name:o.name},a);return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l=zt(i);return mt(l,o.name,a),l}return i}case"Index":{if(o.base){let u=Z(i,o.base,n)[0],f=r(u,{type:"Index",index:o.index},a);return r(i,o.base,f)}let c=Z(t,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!it(c))return i;let u=zt(i);return mt(u,c,a),u}return i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(!it(o.name))return i;if(o.base){let l=Z(i,o.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!it(o.name))return i;let l=zt(i);return delete l[o.name],l}return i}case"Index":{if(o.base){let u=Z(i,o.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return r(i,o.base,f)}let c=Z(t,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!it(c))return i;let u=zt(i);return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let u=function(d,p,m){switch(p.type){case"Identity":return m;case"Field":{if(!it(p.name))return d;if(d&&typeof d=="object"&&!Array.isArray(d)){let g=zt(d);return mt(g,p.name,m),g}return d}case"Index":{let y=Z(t,p.index,n)[0];if(typeof y=="number"&&Array.isArray(d)){let w=[...d],b=y<0?w.length+y:y;return b>=0&&b<w.length&&(w[b]=m),w}if(typeof y=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!it(y))return d;let w=zt(d);return mt(w,y,m),w}return d}case"Pipe":{let g=Z(d,p.left,n)[0],y=u(g,p.right,m);return u(d,p.left,y)}default:return d}};var a=u;let l=o.left,c=o.right,f=Z(i,l,n)[0];if(f==null)return i;let h=s(f,c);return u(i,l,h)}default:return i}}return s(t,e)}function eF(t,e,n,r,s){if(e==="and")return Z(t,n,s).flatMap(l=>kr(l)?Z(t,r,s).map(u=>kr(u)):[!1]);if(e==="or")return Z(t,n,s).flatMap(l=>kr(l)?[!0]:Z(t,r,s).map(u=>kr(u)));if(e==="//"){let l=Z(t,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:Z(t,r,s)}let i=Z(t,n,s),o=Z(t,r,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return a===null?l:l===null?a:typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?Cp(a,l):null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":if(typeof a=="number"&&typeof l=="number")return a*l;if(typeof a=="string"&&typeof l=="number")return a.repeat(l);{let c=Et(a),u=Et(l);if(c&&u)return fm(c,u)}return null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return Ro(a,l);case"!=":return!Ro(a,l);case"<":return Ka(a,l)<0;case"<=":return Ka(a,l)<=0;case">":return Ka(a,l)>0;case">=":return Ka(a,l)>=0;default:return null}}))}function B4(t,e,n,r){let s=K$.get(e);if(s)return typeof t=="number"?[s(t)]:[null];let i=pm(t,e,n,r,Z);if(i!==null)return i;let o=bm(t,e,n,r,Z);if(o!==null)return o;let a=um(t,e,n,r,Z);if(a!==null)return a;let l=hm(t,e,r.limits.maxDepth);if(l!==null)return l;let c=Em(t,e);if(c!==null)return c;let u=gm(t,e,n,r,Z);if(u!==null)return u;let f=lm(t,e,n,r,Z,D4,tu,kr,nu,ie);if(f!==null)return f;let h=ym(t,e,n,r,Z,kr,su,iu,J$,ou);if(h!==null)return h;let d=dm(t,e,n,r,Z,Ro);if(d!==null)return d;let p=cm(t,e,n,r,Z,D4,kr,ie);if(p!==null)return p;let m=mm(t,e,n,r,Z,kr,Y$,B4);if(m!==null)return m;let g=wm(t,e,n,r,Z,Ro);if(g!==null)return g;switch(e){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let y=n.length>0?Z(t,n[0],r)[0]:t;throw new au(y)}case"env":return[r.env?qt(r.env):Object.create(null)];case"debug":return[t];case"input_line_number":return[1];default:{let y=`${e}/${n.length}`,w=r.funcs?.get(y);if(w){let b=w.closure??r.funcs??new Map,E=new Map(b);E.set(y,w);for(let C=0;C<w.params.length;C++){let P=w.params[C],$=n[C];if($){let O=Z(t,$,r),R;if(O.length===0)R={type:"Call",name:"empty",args:[]};else if(O.length===1)R={type:"Literal",value:O[0]};else{R={type:"Literal",value:O[O.length-1]};for(let k=O.length-2;k>=0;k--)R={type:"Comma",left:{type:"Literal",value:O[k]},right:R}}E.set(`${P}/0`,{params:[],body:R})}}let A={...r,funcs:E};return Z(t,w.body,A)}throw new Error(`Unknown function: ${e}`)}}}function ou(t,e,n,r,s){if(e.type==="Comma"){let a=e;ou(t,a.left,n,r,s),ou(t,a.right,n,r,s);return}let i=Ys(e);if(i!==null){s.push([...r,...i]);return}if(e.type==="Iterate"){if(Array.isArray(t))for(let a=0;a<t.length;a++)s.push([...r,a]);else if(t&&typeof t=="object")for(let a of Object.keys(t))s.push([...r,a]);return}if(e.type==="Recurse"){let a=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(t,[]);return}if(e.type==="Pipe"){let a=Ys(e.left);if(a!==null){let l=Z(t,e.left,n);for(let c of l)ou(c,e.right,n,[...r,...a],s);return}}Z(t,e,n).length>0&&s.push(r)}var Fo,au,G$,M4,K$,U4=I(()=>{"use strict";Ar();Me();lr();F4();_4();Vn();ru();Fo=class t extends Error{label;partialResults;constructor(e,n=[]){super(`break ${e}`),this.label=e,this.partialResults=n,this.name="BreakError"}withPrependedResults(e){return new t(this.label,[...e,...this.partialResults])}},au=class extends Error{value;constructor(e){super(typeof e=="string"?e:JSON.stringify(e)),this.value=e,this.name="JqError"}},G$=1e4,M4=2e3,K$=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function W4(t){let e=[],n=0,r=(c=0)=>t[n+c],s=()=>t[n++],i=()=>n>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
555
555
  `||u==="\r")){if(u==="#"){for(;!i()&&r()!==`
556
556
  `;)s();continue}if(u==="."&&r()==="."){s(),e.push({type:"DOTDOT",pos:c});continue}if(u==="="&&r()==="="){s(),e.push({type:"EQ",pos:c});continue}if(u==="!"&&r()==="="){s(),e.push({type:"NE",pos:c});continue}if(u==="<"&&r()==="="){s(),e.push({type:"LE",pos:c});continue}if(u===">"&&r()==="="){s(),e.push({type:"GE",pos:c});continue}if(u==="/"&&r()==="/"){s(),r()==="="?(s(),e.push({type:"UPDATE_ALT",pos:c})):e.push({type:"ALT",pos:c});continue}if(u==="+"&&r()==="="){s(),e.push({type:"UPDATE_ADD",pos:c});continue}if(u==="-"&&r()==="="){s(),e.push({type:"UPDATE_SUB",pos:c});continue}if(u==="*"&&r()==="="){s(),e.push({type:"UPDATE_MUL",pos:c});continue}if(u==="/"&&r()==="="){s(),e.push({type:"UPDATE_DIV",pos:c});continue}if(u==="%"&&r()==="="){s(),e.push({type:"UPDATE_MOD",pos:c});continue}if(u==="="&&r()!=="="){e.push({type:"ASSIGN",pos:c});continue}if(u==="."){e.push({type:"DOT",pos:c});continue}if(u==="|"){r()==="="?(s(),e.push({type:"UPDATE_PIPE",pos:c})):e.push({type:"PIPE",pos:c});continue}if(u===","){e.push({type:"COMMA",pos:c});continue}if(u===":"){e.push({type:"COLON",pos:c});continue}if(u===";"){e.push({type:"SEMICOLON",pos:c});continue}if(u==="("){e.push({type:"LPAREN",pos:c});continue}if(u===")"){e.push({type:"RPAREN",pos:c});continue}if(u==="["){e.push({type:"LBRACKET",pos:c});continue}if(u==="]"){e.push({type:"RBRACKET",pos:c});continue}if(u==="{"){e.push({type:"LBRACE",pos:c});continue}if(u==="}"){e.push({type:"RBRACE",pos:c});continue}if(u==="?"){e.push({type:"QUESTION",pos:c});continue}if(u==="+"){e.push({type:"PLUS",pos:c});continue}if(u==="-"){e.push({type:"MINUS",pos:c});continue}if(u==="*"){e.push({type:"STAR",pos:c});continue}if(u==="/"){e.push({type:"SLASH",pos:c});continue}if(u==="%"){e.push({type:"PERCENT",pos:c});continue}if(u==="<"){e.push({type:"LT",pos:c});continue}if(u===">"){e.push({type:"GT",pos:c});continue}if(o(u)){let f=u;for(;!i()&&(o(r())||r()==="."||r()==="e"||r()==="E");)(r()==="e"||r()==="E")&&(t[n+1]==="+"||t[n+1]==="-")&&(f+=s()),f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}if(u==='"'){let f="";for(;!i()&&r()!=='"';)if(r()==="\\"){if(s(),i())break;let h=s();switch(h){case"n":f+=`
557
557
  `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=h}}else f+=s();i()||s(),e.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(r());)f+=s();let h=z4.get(f);h?e.push({type:h,value:f,pos:c}):e.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return e.push({type:"EOF",pos:n}),e}function uu(t){let e=W4(t);return new Sm(e).parse()}var z4,cu,Sm,j4=I(()=>{"use strict";z4=new Map([["and","AND"],["or","OR"],["not","NOT"],["if","IF"],["then","THEN"],["elif","ELIF"],["else","ELSE"],["end","END"],["as","AS"],["try","TRY"],["catch","CATCH"],["true","TRUE"],["false","FALSE"],["null","NULL"],["reduce","REDUCE"],["foreach","FOREACH"],["label","LABEL"],["break","BREAK"],["def","DEF"]]),cu=new Set(z4.values());Sm=class t{tokens;pos=0;constructor(e){this.tokens=e}peek(e=0){return this.tokens[this.pos+e]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let n of e)if(this.check(n))return this.advance();return null}expect(e,n){if(!this.check(e))throw new Error(`${n} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}isFieldNameAfterDot(e=0){let n=this.peek(e),r=this.peek(e+1);return r.type==="STRING"?!0:r.type==="IDENT"||cu.has(r.type)?r.pos===n.pos+1:!1}isIdentLike(){let e=this.peek().type;return e==="IDENT"||cu.has(e)}consumeFieldNameAfterDot(e){let n=this.peek();return n.type==="STRING"?this.advance().value:(n.type==="IDENT"||cu.has(n.type))&&n.pos===e.pos+1?this.advance().value:null}parse(){let e=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){return this.parsePipe()}parsePattern(){if(this.match("LBRACKET")){let r=[];if(!this.check("RBRACKET"))for(r.push(this.parsePattern());this.match("COMMA")&&!this.check("RBRACKET");)r.push(this.parsePattern());return this.expect("RBRACKET","Expected ']' after array pattern"),{type:"array",elements:r}}if(this.match("LBRACE")){let r=[];if(!this.check("RBRACE"))for(r.push(this.parsePatternField());this.match("COMMA")&&!this.check("RBRACE");)r.push(this.parsePatternField());return this.expect("RBRACE","Expected '}' after object pattern"),{type:"object",fields:r}}let e=this.expect("IDENT","Expected variable name in pattern"),n=e.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${e.pos}`);return{type:"var",name:n}}parsePatternField(){if(this.match("LPAREN")){let n=this.parseExpr();this.expect("RPAREN","Expected ')' after computed key"),this.expect("COLON","Expected ':' after computed key");let r=this.parsePattern();return{key:n,pattern:r}}let e=this.peek();if(e.type==="IDENT"||cu.has(e.type)){let n=e.value;if(n.startsWith("$")){if(this.advance(),this.match("COLON")){let r=this.parsePattern();return{key:n.slice(1),pattern:r,keyVar:n}}return{key:n.slice(1),pattern:{type:"var",name:n}}}if(this.advance(),this.match("COLON")){let r=this.parsePattern();return{key:n,pattern:r}}return{key:n,pattern:{type:"var",name:`$${n}`}}}throw new Error(`Expected field name in object pattern at position ${e.pos}`)}parsePipe(){let e=this.parseComma();for(;this.match("PIPE");){let n=this.parseComma();e={type:"Pipe",left:e,right:n}}return e}parseComma(){let e=this.parseVarBind();for(;this.match("COMMA");){let n=this.parseVarBind();e={type:"Comma",left:e,right:n}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match("AS")){let n=this.parsePattern(),r=[];for(;this.check("QUESTION")&&this.peekAhead(1)?.type==="ALT";)this.advance(),this.advance(),r.push(this.parsePattern());this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return n.type==="var"&&r.length===0?{type:"VarBind",name:n.name,value:e,body:s}:{type:"VarBind",name:n.type==="var"?n.name:"",value:e,body:s,pattern:n.type!=="var"?n:void 0,alternatives:r.length>0?r:void 0}}return e}peekAhead(e){let n=this.pos+e;return n<this.tokens.length?this.tokens[n]:void 0}parseUpdate(){let e=this.parseAlt(),n=new Map([["ASSIGN","="],["UPDATE_ADD","+="],["UPDATE_SUB","-="],["UPDATE_MUL","*="],["UPDATE_DIV","/="],["UPDATE_MOD","%="],["UPDATE_ALT","//="],["UPDATE_PIPE","|="]]),r=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(r){let s=this.parseVarBind(),i=n.get(r.type);if(i)return{type:"UpdateOp",op:i,path:e,value:s}}return e}parseAlt(){let e=this.parseOr();for(;this.match("ALT");){let n=this.parseOr();e={type:"BinaryOp",op:"//",left:e,right:n}}return e}parseOr(){let e=this.parseAnd();for(;this.match("OR");){let n=this.parseAnd();e={type:"BinaryOp",op:"or",left:e,right:n}}return e}parseAnd(){let e=this.parseNot();for(;this.match("AND");){let n=this.parseNot();e={type:"BinaryOp",op:"and",left:e,right:n}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),n=new Map([["EQ","=="],["NE","!="],["LT","<"],["LE","<="],["GT",">"],["GE",">="]]),r=this.match("EQ","NE","LT","LE","GT","GE");if(r){let s=n.get(r.type);if(s){let i=this.parseAddSub();e={type:"BinaryOp",op:s,left:e,right:i}}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match("PLUS")){let n=this.parseMulDiv();e={type:"BinaryOp",op:"+",left:e,right:n}}else if(this.match("MINUS")){let n=this.parseMulDiv();e={type:"BinaryOp",op:"-",left:e,right:n}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match("STAR")){let n=this.parseUnary();e={type:"BinaryOp",op:"*",left:e,right:n}}else if(this.match("SLASH")){let n=this.parseUnary();e={type:"BinaryOp",op:"/",left:e,right:n}}else if(this.match("PERCENT")){let n=this.parseUnary();e={type:"BinaryOp",op:"%",left:e,right:n}}else break;return e}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("QUESTION"))e={type:"Optional",expr:e};else if(this.check("DOT")&&this.isFieldNameAfterDot())this.advance(),e={type:"Field",name:this.advance().value,base:e};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))e={type:"Iterate",base:e};else if(this.check("COLON")){this.advance();let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",end:n,base:e}}else{let n=this.parseExpr();if(this.match("COLON")){let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",start:n,end:r,base:e}}else this.expect("RBRACKET","Expected ']'"),e={type:"Index",index:n,base:e}}else break;return e}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.check("DOT")){let e=this.advance();if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:s}}let r=this.parseExpr();if(this.match("COLON")){let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:r,end:s}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:r}}let n=this.consumeFieldNameAfterDot(e);return n!==null?{type:"Field",name:n}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let n=this.advance().value;return n.includes("\\(")?this.parseStringInterpolation(n):{type:"Literal",value:n}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let e=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:e}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let e=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:e}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let e=this.parsePostfix(),n;return this.match("CATCH")&&(n=this.parsePostfix()),{type:"Try",body:e,catch:n}}if(this.match("REDUCE")){let e=this.parseAddSub();this.expect("AS","Expected 'as' after reduce expression");let n=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let r=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr();this.expect("RPAREN","Expected ')' after update expression");let i=n.type==="var"?n.name:"";return{type:"Reduce",expr:e,varName:i,init:r,update:s,pattern:n.type!=="var"?n:void 0}}if(this.match("FOREACH")){let e=this.parseAddSub();this.expect("AS","Expected 'as' after foreach expression");let n=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let r=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr(),i;this.match("SEMICOLON")&&(i=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions");let o=n.type==="var"?n.name:"";return{type:"Foreach",expr:e,varName:o,init:r,update:s,extract:i,pattern:n.type!=="var"?n:void 0}}if(this.match("LABEL")){let e=this.expect("IDENT","Expected label name (e.g., $out)"),n=e.value;if(!n.startsWith("$"))throw new Error(`Label name must start with $ at position ${e.pos}`);this.expect("PIPE","Expected '|' after label name");let r=this.parseExpr();return{type:"Label",name:n,body:r}}if(this.match("BREAK")){let e=this.expect("IDENT","Expected label name to break to"),n=e.value;if(!n.startsWith("$"))throw new Error(`Break label must start with $ at position ${e.pos}`);return{type:"Break",name:n}}if(this.match("DEF")){let n=this.expect("IDENT","Expected function name after def").value,r=[];if(this.match("LPAREN")){if(!this.check("RPAREN")){let o=this.expect("IDENT","Expected parameter name");for(r.push(o.value);this.match("SEMICOLON");){let a=this.expect("IDENT","Expected parameter name");r.push(a.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after function body");let i=this.parseExpr();return{type:"Def",name:n,params:r,funcBody:s,body:i}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let n=this.advance().value;if(n.startsWith("$"))return{type:"VarRef",name:n};if(this.match("LPAREN")){let r=[];if(!this.check("RPAREN"))for(r.push(this.parseExpr());this.match("SEMICOLON");)r.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:n,args:r}}return{type:"Call",name:n,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let e=[];if(!this.check("RBRACE"))do{let n,r;if(this.match("LPAREN"))n=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else if(this.isIdentLike()){let s=this.advance().value;this.match("COLON")?(n=s,r=this.parseObjectValue()):(n=s,r={type:"Field",name:s})}else if(this.check("STRING"))n=this.advance().value,this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);e.push({key:n,value:r})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match("PIPE");){let n=this.parseVarBind();e={type:"Pipe",left:e,right:n}}return e}parseIf(){let e=this.parseExpr();this.expect("THEN","Expected 'then'");let n=this.parseExpr(),r=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();r.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:e,then:n,elifs:r,else:s}}parseStringInterpolation(e){let n=[],r="",s=0;for(;s<e.length;)if(e[s]==="\\"&&e[s+1]==="("){r&&(n.push(r),r=""),s+=2;let i=1,o="";for(;s<e.length&&i>0;)e[s]==="("?i++:e[s]===")"&&i--,i>0&&(o+=e[s]),s++;let a=W4(o),l=new t(a);n.push(l.parse())}else r+=e[s],s++;return r&&n.push(r),{type:"StringInterp",parts:n}}}});var Di=I(()=>{"use strict";U4();j4()});var H4={};ee(H4,{flagsForFuzzing:()=>vm,jqCommand:()=>sF});function tF(t){switch(t){case"\b":return"\\b";case"\f":return"\\f";case`
@@ -580,7 +580,7 @@ ${o.repeat(i)}}`}return String(t)}var rF,sF,vm,Cm=I(()=>{"use strict";pe();mn();
580
580
  `,stderr:"",exitCode:1}:{stdout:K4.createTwoFilesPatch(c,u,a,l,"","",{context:3}),stderr:"",exitCode:1}}},Tm={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2}});var Y4={};ee(Y4,{dateCommand:()=>mF,flagsForFuzzing:()=>Im});function Kn(t,e=2){return String(t).padStart(e,"0")}function fu(t,e,n){let r={Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()},s="",i=0;for(;i<e.length;){if(e[i]==="%"&&i+1<e.length){let o=e[++i];switch(o){case"%":s+="%";break;case"a":s+=hF[r.w];break;case"b":case"h":s+=dF[r.m];break;case"d":s+=Kn(r.D);break;case"e":s+=String(r.D).padStart(2," ");break;case"F":s+=`${r.Y}-${Kn(r.m+1)}-${Kn(r.D)}`;break;case"H":s+=Kn(r.H);break;case"I":s+=Kn(r.H%12||12);break;case"m":s+=Kn(r.m+1);break;case"M":s+=Kn(r.M);break;case"n":s+=`
581
581
  `;break;case"p":s+=r.H<12?"AM":"PM";break;case"P":s+=r.H<12?"am":"pm";break;case"R":s+=`${Kn(r.H)}:${Kn(r.M)}`;break;case"s":s+=Math.floor(t.getTime()/1e3);break;case"S":s+=Kn(r.S);break;case"t":s+=" ";break;case"T":s+=`${Kn(r.H)}:${Kn(r.M)}:${Kn(r.S)}`;break;case"u":s+=r.w||7;break;case"w":s+=r.w;break;case"y":s+=Kn(r.Y%100);break;case"Y":s+=r.Y;break;case"z":s+="+0000";break;case"Z":s+="UTC";break;default:s+=`%${o}`}}else s+=e[i];i++}return s}function pF(t){let e=new Date(t);if(!Number.isNaN(e.getTime()))return e;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let n=t.toLowerCase();return n==="now"||n==="today"?new Date:n==="yesterday"?new Date(Date.now()-864e5):n==="tomorrow"?new Date(Date.now()+864e5):null}var fF,hF,dF,mF,Im,Pm=I(()=>{"use strict";ue();fF={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},hF=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dF=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];mF={name:"date",async execute(t,e){if(U(t))return B(fF);let n=!1,r=null,s=null,i=!1,o=!1;for(let c=0;c<t.length;c++){let u=t[c];if(u==="-u"||u==="--utc")n=!0;else if(u==="-d"||u==="--date")r=t[++c]??"";else if(u.startsWith("--date="))r=u.slice(7);else if(u==="-I"||u==="--iso-8601")i=!0;else if(u==="-R"||u==="--rfc-email")o=!0;else if(u.startsWith("+"))s=u.slice(1);else{if(u.startsWith("--"))return Q("date",u);if(u.startsWith("-"))for(let f of u.slice(1))if(f==="u")n=!0;else if(f==="I")i=!0;else if(f==="R")o=!0;else return Q("date",`-${f}`)}}let a=r!==null?pF(r):new Date;if(!a)return{stdout:"",stderr:`date: invalid date '${r}'
582
582
  `,exitCode:1};let l;return s?l=fu(a,s,n):i?l=fu(a,"%Y-%m-%dT%H:%M:%S%z",n):o?l=fu(a,"%a, %d %b %Y %H:%M:%S %z",n):l=fu(a,"%a %b %e %H:%M:%S %Z %Y",n),{stdout:`${l}
583
- `,stderr:"",exitCode:0}}},Im={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"}]}});function hu(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let n=parseFloat(e[1]);switch(e[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var Rm=I(()=>{"use strict"});var X4={};ee(X4,{flagsForFuzzing:()=>$m,sleepCommand:()=>yF});var gF,Q4,yF,$m,Fm=I(()=>{"use strict";is();Rm();ue();gF={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
583
+ `,stderr:"",exitCode:0}}},Im={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"}]}});function hu(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let n=parseFloat(e[1]);switch(e[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var Rm=I(()=>{"use strict"});var X4={};ee(X4,{flagsForFuzzing:()=>$m,sleepCommand:()=>yF});var gF,Q4,yF,$m,Fm=I(()=>{"use strict";os();Rm();ue();gF={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
584
584
  s - seconds (default)
585
585
  m - minutes
586
586
  h - hours
@@ -588,7 +588,7 @@ ${o.repeat(i)}}`}return String(t)}var rF,sF,vm,Cm=I(()=>{"use strict";pe();mn();
588
588
 
589
589
  NUMBER may be a decimal number.`,options:[" --help display this help and exit"]},Q4=36e5,yF={name:"sleep",async execute(t,e){if(U(t))return B(gF);if(t.length===0)return{stdout:"",stderr:`sleep: missing operand
590
590
  `,exitCode:1};let n=0;for(let r of t){let s=hu(r);if(s===null)return{stdout:"",stderr:`sleep: invalid time interval '${r}'
591
- `,exitCode:1};n+=s}return n>Q4&&(n=Q4),e.signal?.aborted?{stdout:"",stderr:"",exitCode:0}:(e.sleep?await e.sleep(n):e.signal?await new Promise(r=>{let s=()=>{Dt(i),r()},i=sn(()=>{e.signal?.removeEventListener("abort",s),r()},n);e.signal?.addEventListener("abort",s,{once:!0})}):await new Promise(r=>sn(r,n)),{stdout:"",stderr:"",exitCode:0})}},$m={name:"sleep",flags:[],needsArgs:!0}});var J4={};ee(J4,{flagsForFuzzing:()=>_m,timeoutCommand:()=>bF});var wF,bF,_m,Dm=I(()=>{"use strict";pe();Is();is();Rm();ue();wF={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
591
+ `,exitCode:1};n+=s}return n>Q4&&(n=Q4),e.signal?.aborted?{stdout:"",stderr:"",exitCode:0}:(e.sleep?await e.sleep(n):e.signal?await new Promise(r=>{let s=()=>{Dt(i),r()},i=sn(()=>{e.signal?.removeEventListener("abort",s),r()},n);e.signal?.addEventListener("abort",s,{once:!0})}):await new Promise(r=>sn(r,n)),{stdout:"",stderr:"",exitCode:0})}},$m={name:"sleep",flags:[],needsArgs:!0}});var J4={};ee(J4,{flagsForFuzzing:()=>_m,timeoutCommand:()=>bF});var wF,bF,_m,Dm=I(()=>{"use strict";pe();Is();os();Rm();ue();wF={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
592
592
 
593
593
  DURATION is a number with optional suffix:
594
594
  s - seconds (default)
@@ -629,9 +629,9 @@ sys 0.00
629
629
  `).join(`
630
630
  `+i),t.push(s+"m+"+Cu.exports.humanize(this.diff)+"\x1B[0m")}else t[0]=a_()+e+" "+t[0]}function a_(){return ln.inspectOpts.hideDate?"":new Date().toISOString()+" "}function l_(...t){return process.stderr.write(vu.formatWithOptions(ln.inspectOpts,...t)+`
631
631
  `)}function c_(t){t?process.env.DEBUG=t:delete process.env.DEBUG}function u_(){return process.env.DEBUG}function f_(t){t.inspectOpts={};let e=Object.keys(ln.inspectOpts);for(let n=0;n<e.length;n++)t.inspectOpts[e[n]]=ln.inspectOpts[e[n]]}Cu.exports=n0()(ln);var{formatters:L8}=Cu.exports;L8.o=function(t){return this.inspectOpts.colors=this.useColors,vu.inspect(t,this.inspectOpts).split(`
632
- `).map(e=>e.trim()).join(" ")};L8.O=function(t){return this.inspectOpts.colors=this.useColors,vu.inspect(t,this.inspectOpts)}});var B8=re((wte,i0)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?i0.exports=P8():i0.exports=M8()});var zi,o0,U8,z8,W8,j8=I(()=>{Ja();zi={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},o0={get(t){return{signature:_t.get(t,0),compressedSize:_t.get(t,8),uncompressedSize:_t.get(t,12)}},len:16},U8={get(t){let e=Lt.get(t,6);return{signature:_t.get(t,0),minVersion:Lt.get(t,4),dataDescriptor:!!(e&8),compressedMethod:Lt.get(t,8),compressedSize:_t.get(t,18),uncompressedSize:_t.get(t,22),filenameLength:Lt.get(t,26),extraFieldLength:Lt.get(t,28),filename:null}},len:30},z8={get(t){return{signature:_t.get(t,0),nrOfThisDisk:Lt.get(t,4),nrOfThisDiskWithTheStart:Lt.get(t,6),nrOfEntriesOnThisDisk:Lt.get(t,8),nrOfEntriesOfSize:Lt.get(t,10),sizeOfCd:_t.get(t,12),offsetOfStartOfCd:_t.get(t,16),zipFileCommentLength:Lt.get(t,20)}},len:22},W8={get(t){let e=Lt.get(t,8);return{signature:_t.get(t,0),minVersion:Lt.get(t,6),dataDescriptor:!!(e&8),compressedMethod:Lt.get(t,10),compressedSize:_t.get(t,20),uncompressedSize:_t.get(t,24),filenameLength:Lt.get(t,28),extraFieldLength:Lt.get(t,30),fileCommentLength:Lt.get(t,32),relativeOffsetOfLocalHeader:_t.get(t,42),filename:null}},len:46}});function H8(t){let e=new Uint8Array(_t.len);return _t.put(e,0,t),e}function d_(t,e){let n=t.length,r=e.length;if(r>n)return-1;for(let s=0;s<=n-r;s++){let i=!0;for(let o=0;o<r;o++)if(t[s+o]!==e[o]){i=!1;break}if(i)return s}return-1}function p_(t){let e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}var q8,ds,a0,h_,ku,Wi,V8=I(()=>{Ja();q8=Jt(B8(),1);j8();ds=(0,q8.default)("tokenizer:inflate"),a0=256*1024,h_=H8(zi.DataDescriptor),ku=H8(zi.EndOfCentralDirectory),Wi=class t{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(a0)}async isZip(){return await this.peekSignature()===zi.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(_t)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,n=Math.min(16*1024,e.fileInfo.size),r=this.syncBuffer.subarray(0,n);await this.tokenizer.readBuffer(r,{position:e.fileInfo.size-n});for(let s=r.length-4;s>=0;s--)if(r[s]===ku[0]&&r[s+1]===ku[1]&&r[s+2]===ku[2]&&r[s+3]===ku[3])return e.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){ds("Cannot reading central-directory without random-read support");return}ds("Reading central-directory...");let e=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){ds("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(z8,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken(W8);if(o.signature!==zi.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Yn(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),ds(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(e),s}this.tokenizer.setPosition(e)}async unzip(e){let n=await this.readCentralDirectory();if(n)return this.iterateOverCentralDirectory(n,e);let r=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=e(s);r=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=a0;ds("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===a0;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=d_(this.syncBuffer.subarray(0,l),h_);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),a.push(f)}else await this.tokenizer.ignore(u)}ds(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,p_(a),i.handler)}else i.handler?(ds(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(ds(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(ds(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(o0)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-o0.len}`)}while(!r)}async iterateOverCentralDirectory(e,n){for(let r of e){let s=n(r);if(s.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(e,n,r){if(e.compressedMethod===0)return r(n);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);ds(`Decompress filename=${e.filename}, compressed-size=${n.length}`);let s=await t.decompressDeflateRaw(n);return r(s)}static async decompressDeflateRaw(e){let n=new ReadableStream({start(i){i.enqueue(e),i.close()}}),r=new DecompressionStream("deflate-raw"),s=n.pipeThrough(r);try{let o=await new Response(s).arrayBuffer();return new Uint8Array(o)}catch(i){let o=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(_t);if(e===zi.LocalFileHeader){let n=await this.tokenizer.readToken(U8);return n.filename=await this.tokenizer.readToken(new Yn(n.filenameLength,"utf-8")),n}if(e===zi.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var el,G8=I(()=>{el=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(n){let r=new Uint8Array(1024),s=await e.readBuffer(r,{mayBeLess:!0});if(s===0){n.close();return}n.enqueue(r.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var K8=I(()=>{V8();G8()});function l0(t){let{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}var Tte,Ote,Ite,Z8=I(()=>{Tte={utf8:new globalThis.TextDecoder("utf8")},Ote=new globalThis.TextEncoder,Ite=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"))});function Y8(t,e){if(e==="utf-16le"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s&255,s>>8&255)}return n}if(e==="utf-16be"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s>>8&255,s&255)}return n}return[...t].map(n=>n.charCodeAt(0))}function Q8(t,e=0){let n=Number.parseInt(new Yn(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let s=e;s<e+148;s++)r+=t[s];for(let s=e+156;s<e+512;s++)r+=t[s];return n===r}var X8,J8=I(()=>{Ja();X8={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4}});var eE,tE,nE=I(()=>{eE=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],tE=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"]});function T_(t){let e=t?.streamReader;if(e?.constructor?.name!=="WebStreamByobReader")return t;let{reader:n}=e,r=async()=>{await n.cancel(),n.releaseLock()};return e.close=r,e.abort=async()=>{e.interrupted=!0,await r()},t}function h0(t,e,n){if(!Number.isFinite(t)||t<0||t>e)throw new Rs(`${n} has invalid size ${t} (maximum ${e} bytes)`);return t}async function Js(t,e,{maximumLength:n=Tr,reason:r="skip"}={}){let s=h0(e,n,r);await t.ignore(s)}async function u0(t,e,n,{maximumLength:r=e.length,reason:s="read"}={}){let i=n?.length??e.length,o=h0(i,r,s);return t.readBuffer(e,{...n,length:o})}async function O_(t,{maximumLength:e=ms}={}){let s=new ReadableStream({start(c){c.enqueue(t),c.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),i=[],o=0;try{for(;;){let{done:c,value:u}=await s.read();if(c)break;if(o+=u.length,o>e)throw await s.cancel(),new Error(`ZIP entry decompressed data exceeds ${e} bytes`);i.push(u)}}finally{s.releaseLock()}let a=new Uint8Array(o),l=0;for(let c of i)a.set(c,l),l+=c.length;return a}function P_(t,e){if(t.length<Nu)return-1;let n=t.length-Nu;for(let r=0;r<=n;r++)if(_t.get(t,r)===mE&&_t.get(t,r+8)===e+r)return r;return-1}function R_(t){return(t.codePointAt(0)&32)!==0}function $_(t,e){let n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}async function F_(t,{shouldBuffer:e,maximumLength:n=ms}={}){let{syncBuffer:r}=t,{length:s}=r,i=[],o=0;for(;;){let a=await t.tokenizer.peekBuffer(r,{mayBeLess:!0}),l=P_(r.subarray(0,a),o),c=l>=0?0:a===s?Math.min(I_,a-1):0,u=l>=0?l:a-c;if(u===0)break;if(o+=u,o>n)throw new Error(`ZIP entry compressed data exceeds ${n} bytes`);if(e){let f=new Uint8Array(u);await t.tokenizer.readBuffer(f),i.push(f)}else await t.tokenizer.ignore(u);if(l>=0)break}if(Dn(t.tokenizer)||(t.knownSizeDescriptorScannedBytes+=o),!!e)return $_(i,o)}function __(t,e){return Dn(t.tokenizer)?Math.max(0,Tr-(t.tokenizer.position-e)):Math.max(0,ms-t.knownSizeDescriptorScannedBytes)}async function D_(t,e,{shouldBuffer:n,maximumDescriptorLength:r=ms}={}){if(e.dataDescriptor&&e.compressedSize===0)return F_(t,{shouldBuffer:n,maximumLength:r});if(!n){await Js(t.tokenizer,e.compressedSize,{maximumLength:Dn(t.tokenizer)?ms:t.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}let s=W_(t.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>s)throw new Error(`ZIP entry compressed data exceeds ${s} bytes`);let i=new Uint8Array(e.compressedSize);return await t.tokenizer.readBuffer(i),i}function L_(t,e){let n=t.getReader(),r=0,s=!1,i=!1,o=async a=>{s||i||(i=!0,await n.cancel(a))};return new ReadableStream({async pull(a){if(r>=e){a.close(),await o();return}let{done:l,value:c}=await n.read();if(l||!c){s=!0,a.close();return}let u=e-r;if(c.length>u){a.enqueue(c.subarray(0,u)),r+=u,a.close(),await o();return}a.enqueue(c),r+=c.length},async cancel(a){await o(a)}})}async function d0(t,e){return new f0(e).fromBuffer(t)}function hE(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function ps(t,e,n){n={offset:0,...n};for(let[r,s]of e.entries())if(n.mask){if(s!==(n.mask[r]&t[r+n.offset]))return!1}else if(s!==t[r+n.offset])return!1;return!0}function M_(t){return Number.isFinite(t)?Math.max(1,Math.trunc(t)):tl}function B_(t,e,n){return n===void 0?t.read(e):(n.throwIfAborted(),new Promise((r,s)=>{let i=()=>{n.removeEventListener("abort",o)},o=()=>{let a=n.reason;i(),(async()=>{try{await t.cancel(a)}catch{}})(),s(a)};n.addEventListener("abort",o,{once:!0}),(async()=>{try{let a=await t.read(e);i(),r(a)}catch(a){i(),s(a)}})()}))}function U_(t){return Number.isFinite(t)?Math.max(0,Math.min(m_,Math.trunc(t))):0}function z_(t){return Number.isFinite(t)?Math.max(0,t):Number.MAX_SAFE_INTEGER}function Dn(t){let e=t.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function nl(t,e,n){return Dn(t)&&t.position-e>n}function W_(t){let e=t.fileInfo.size,n=Number.isFinite(e)?Math.max(0,e-t.position):Number.MAX_SAFE_INTEGER;return Math.min(n,g_)}function j_(t){if(t instanceof Xe||t instanceof Rs)return!0;if(!(t instanceof Error))return!1;if(C_.has(t.message)||N_.has(t.code))return!0;for(let e of k_)if(t.message.startsWith(e))return!0;return!1}function dE(t,e=ms){let n=[t.compressedSize,t.uncompressedSize];for(let r of n)if(!Number.isFinite(r)||r<0||r>e)return!1;return!0}function q_(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function H_(t,e){e.startsWith("word/")&&(t.hasWordDirectory=!0),e.startsWith("ppt/")&&(t.hasPresentationDirectory=!0),e.startsWith("xl/")&&(t.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(t.hasThreeDimensionalModelEntry=!0)}function pE(t){if(!(!t.hasContentTypesEntry||t.hasUnparseableContentTypes||t.isParsingContentTypes||t.hasParsedContentTypesEntry)){if(t.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(t.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(t.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(t.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function V_(t){let e=t.indexOf('.main+xml"');if(e===-1){let s="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return t.includes(`ContentType="${s}"`)?s:void 0}let n=t.slice(0,e),r=n.lastIndexOf('"');return n.slice(r+1)}var tl,m_,ms,rE,g_,Tr,Tu,sE,y_,w_,iE,c0,oE,aE,b_,E_,x_,S_,A_,lE,cE,uE,v_,fE,C_,k_,N_,Rs,mE,Nu,I_,f0,G_,K_,gE=I(()=>{Ja();Eu();K8();Z8();J8();nE();tl=4100,m_=tl-2,ms=1024*1024,rE=1024,g_=2**31-1,Tr=16*1024*1024,Tu=ms,sE=ms,y_=Tr,w_=1,iE=100,c0=Tr,oE=64,aE=Tu,b_=256,E_=512,x_=Tr,S_=512,A_=512,lE=256,cE=Tu,uE=Tu,v_=Tu,fE=Tr,C_=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),k_=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],N_=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]),Rs=class extends Error{};mE=134695760,Nu=16,I_=Nu-1;Wi.prototype.inflate=async function(t,e,n){if(t.compressedMethod===0)return n(e);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);let r=await O_(e,{maximumLength:ms});return n(r)};Wi.prototype.unzip=async function(t){let e=!1,n=0,r=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(nl(this.tokenizer,r,Tr))throw new Rs(`ZIP stream probing exceeds ${Tr} bytes`);let s=await this.readLocalFileHeader();if(!s)break;if(n++,n>rE)throw new Error(`ZIP entry count exceeds ${rE}`);let i=t(s);e=!!i.stop,await this.tokenizer.ignore(s.extraFieldLength);let o=await D_(this,s,{shouldBuffer:!!i.handler,maximumDescriptorLength:Math.min(ms,__(this,r))});if(i.handler&&await this.inflate(s,o,i.handler),s.dataDescriptor){let a=new Uint8Array(Nu);if(await this.tokenizer.readBuffer(a),_t.get(a,0)!==mE)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-a.length}`)}if(nl(this.tokenizer,r,Tr))throw new Rs(`ZIP stream probing exceeds ${Tr} bytes`)}while(!e)};f0=class t{constructor(e){let n=U_(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:n},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return T_(m8(e,this.getTokenizerOptions()))}async parseTokenizer(e,n=0){this.detectionReentryCount=n;let r=e.position;for(let s of this.detectors){let i;try{i=await s.detect(e)}catch(o){if(o instanceof Xe||o instanceof Rs)return;throw o}if(i)return i;if(r!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let n=e instanceof Uint8Array?e:new Uint8Array(e);if(n?.length>1)return this.fromTokenizer(g8(n,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let n=y8(e,this.getTokenizerOptions());return this.fromTokenizer(n)}async fromStream(e){this.options.signal?.throwIfAborted();let n=this.createTokenizerFromWebStream(e);return this.fromTokenizer(n)}async toDetectionStream(e,n){let r=M_(n?.sampleSize??tl),s,i,o=e.getReader({mode:"byob"});try{let{value:c,done:u}=await B_(o,new Uint8Array(r),this.options.signal);if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof Xe))throw f;s=void 0}i=c}finally{o.releaseLock()}let a=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=e.pipeThrough(a);return l.fileType=s,l}async detectGzip(e){if(this.gzipProbeDepth>=w_)return{ext:"gz",mime:"application/gzip"};let n=new el(e),r=L_(n.inflate(),y_),s=Dn(e),i,o,a,l;if(s){let c=new AbortController;i=setTimeout(()=>{c.abort(new DOMException(`Operation timed out after ${iE} ms`,"TimeoutError"))},iE),o=this.options.signal===void 0?c.signal:AbortSignal.any([this.options.signal,c.signal]),a=new t({...this.options,signal:o}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{l=await(a??this).fromStream(r)}catch(c){if(c?.name==="AbortError"&&o?.reason?.name!=="TimeoutError")throw c}finally{clearTimeout(i),s||this.gzipProbeDepth--}return l?.ext==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,n){return ps(this.buffer,e,n)}checkString(e,n){return this.check(Y8(e,n?.encoding),n)}detectConfident=async e=>{if(this.buffer=new Uint8Array(tl),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,Dn(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=lE?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Js(e,6,{maximumLength:6,reason:"ID3 header prefix"});let n=await e.readToken(X8),r=Dn(e);if(!Number.isFinite(n)||n<0||r&&(n>c0||e.position+n>c0))return;if(e.position+n>e.fileInfo.size)return r?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Js(e,n,{maximumLength:r?c0:e.fileInfo.size,reason:"ID3 payload"})}catch(s){if(s instanceof Xe)return;throw s}return this.detectionReentryCount>=lE?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let n,r=q_();try{await new Wi(e).unzip(s=>{H_(r,s.filename);let i=s.filename==="[Content_Types].xml",o=pE(r);if(!i&&o)return n=o,{stop:!0};switch(s.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return dE(s,sE)?{async handler(a){let l=new TextDecoder("utf-8").decode(a).trim();n=hE(l)},stop:!0}:{};case"[Content_Types].xml":return r.hasContentTypesEntry=!0,dE(s,sE)?(r.isParsingContentTypes=!0,{async handler(a){let l=new TextDecoder("utf-8").decode(a),c=V_(l);c&&(n=hE(c)),r.hasParsedContentTypesEntry=!0,r.isParsingContentTypes=!1},stop:!0}):(r.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(s.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(s){if(!j_(s))throw s;r.isParsingContentTypes&&(r.isParsingContentTypes=!1,r.hasUnparseableContentTypes=!0)}return n??pE(r)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let n=new Uint8Array(8);return await e.readBuffer(n),ps(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ps(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ps(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ps(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ps(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ps(n,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let n=await this.readTiffHeader(!1);if(n)return n}if(this.check([77,77])){let n=await this.readTiffHeader(!0);if(n)return n}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function n(){let l=await e.peekNumber(C8),c=128,u=0;for(;(l&c)===0&&c!==0;)++u,c>>=1;let f=new Uint8Array(u+1);return await u0(e,f,void 0,{maximumLength:f.length,reason:"EBML field"}),f}async function r(){let l=await n(),c=await n();c[0]^=128>>c.length-1;let u=Math.min(6,c.length),f=new DataView(l.buffer),h=new DataView(c.buffer,c.length-u,u);return{id:l0(f),len:l0(h)}}async function s(l){let c=0;for(;l>0;){if(c++,c>b_||nl(e,o,Tr))return;let u=e.position,f=await r();if(f.id===17026){if(f.len>oE)return;let h=h0(f.len,oE,"EBML DocType");return(await e.readToken(new Yn(h))).replaceAll(/\00.*$/g,"")}if(Dn(e)&&(!Number.isFinite(f.len)||f.len<0||f.len>aE)||(await Js(e,f.len,{maximumLength:Dn(e)?aE:e.fileInfo.size,reason:"EBML payload"}),--l,e.position<=u))return}}let i=await r(),o=e.position;switch(await s(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){let n=t0.get(this.buffer,4),r=Bi.get(this.buffer,6);if(n>0&&n<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(r>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let n=new Yn(4,"latin1").get(this.buffer,2);if(n.match("^d*")&&n>=1e3&&n<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new Yn(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
632
+ `).map(e=>e.trim()).join(" ")};L8.O=function(t){return this.inspectOpts.colors=this.useColors,vu.inspect(t,this.inspectOpts)}});var B8=re((wte,i0)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?i0.exports=P8():i0.exports=M8()});var zi,o0,U8,z8,W8,j8=I(()=>{Ja();zi={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},o0={get(t){return{signature:_t.get(t,0),compressedSize:_t.get(t,8),uncompressedSize:_t.get(t,12)}},len:16},U8={get(t){let e=Lt.get(t,6);return{signature:_t.get(t,0),minVersion:Lt.get(t,4),dataDescriptor:!!(e&8),compressedMethod:Lt.get(t,8),compressedSize:_t.get(t,18),uncompressedSize:_t.get(t,22),filenameLength:Lt.get(t,26),extraFieldLength:Lt.get(t,28),filename:null}},len:30},z8={get(t){return{signature:_t.get(t,0),nrOfThisDisk:Lt.get(t,4),nrOfThisDiskWithTheStart:Lt.get(t,6),nrOfEntriesOnThisDisk:Lt.get(t,8),nrOfEntriesOfSize:Lt.get(t,10),sizeOfCd:_t.get(t,12),offsetOfStartOfCd:_t.get(t,16),zipFileCommentLength:Lt.get(t,20)}},len:22},W8={get(t){let e=Lt.get(t,8);return{signature:_t.get(t,0),minVersion:Lt.get(t,6),dataDescriptor:!!(e&8),compressedMethod:Lt.get(t,10),compressedSize:_t.get(t,20),uncompressedSize:_t.get(t,24),filenameLength:Lt.get(t,28),extraFieldLength:Lt.get(t,30),fileCommentLength:Lt.get(t,32),relativeOffsetOfLocalHeader:_t.get(t,42),filename:null}},len:46}});function H8(t){let e=new Uint8Array(_t.len);return _t.put(e,0,t),e}function d_(t,e){let n=t.length,r=e.length;if(r>n)return-1;for(let s=0;s<=n-r;s++){let i=!0;for(let o=0;o<r;o++)if(t[s+o]!==e[o]){i=!1;break}if(i)return s}return-1}function p_(t){let e=t.reduce((s,i)=>s+i.length,0),n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}var q8,ps,a0,h_,ku,Wi,V8=I(()=>{Ja();q8=Jt(B8(),1);j8();ps=(0,q8.default)("tokenizer:inflate"),a0=256*1024,h_=H8(zi.DataDescriptor),ku=H8(zi.EndOfCentralDirectory),Wi=class t{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(a0)}async isZip(){return await this.peekSignature()===zi.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(_t)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,n=Math.min(16*1024,e.fileInfo.size),r=this.syncBuffer.subarray(0,n);await this.tokenizer.readBuffer(r,{position:e.fileInfo.size-n});for(let s=r.length-4;s>=0;s--)if(r[s]===ku[0]&&r[s+1]===ku[1]&&r[s+2]===ku[2]&&r[s+3]===ku[3])return e.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){ps("Cannot reading central-directory without random-read support");return}ps("Reading central-directory...");let e=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){ps("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(z8,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken(W8);if(o.signature!==zi.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Yn(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),ps(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(e),s}this.tokenizer.setPosition(e)}async unzip(e){let n=await this.readCentralDirectory();if(n)return this.iterateOverCentralDirectory(n,e);let r=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=e(s);r=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=a0;ps("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===a0;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=d_(this.syncBuffer.subarray(0,l),h_);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),a.push(f)}else await this.tokenizer.ignore(u)}ps(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,p_(a),i.handler)}else i.handler?(ps(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(ps(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(ps(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(o0)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-o0.len}`)}while(!r)}async iterateOverCentralDirectory(e,n){for(let r of e){let s=n(r);if(s.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(e,n,r){if(e.compressedMethod===0)return r(n);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);ps(`Decompress filename=${e.filename}, compressed-size=${n.length}`);let s=await t.decompressDeflateRaw(n);return r(s)}static async decompressDeflateRaw(e){let n=new ReadableStream({start(i){i.enqueue(e),i.close()}}),r=new DecompressionStream("deflate-raw"),s=n.pipeThrough(r);try{let o=await new Response(s).arrayBuffer();return new Uint8Array(o)}catch(i){let o=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(_t);if(e===zi.LocalFileHeader){let n=await this.tokenizer.readToken(U8);return n.filename=await this.tokenizer.readToken(new Yn(n.filenameLength,"utf-8")),n}if(e===zi.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var el,G8=I(()=>{el=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(n){let r=new Uint8Array(1024),s=await e.readBuffer(r,{mayBeLess:!0});if(s===0){n.close();return}n.enqueue(r.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var K8=I(()=>{V8();G8()});function l0(t){let{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}var Tte,Ote,Ite,Z8=I(()=>{Tte={utf8:new globalThis.TextDecoder("utf8")},Ote=new globalThis.TextEncoder,Ite=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"))});function Y8(t,e){if(e==="utf-16le"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s&255,s>>8&255)}return n}if(e==="utf-16be"){let n=[];for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);n.push(s>>8&255,s&255)}return n}return[...t].map(n=>n.charCodeAt(0))}function Q8(t,e=0){let n=Number.parseInt(new Yn(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let s=e;s<e+148;s++)r+=t[s];for(let s=e+156;s<e+512;s++)r+=t[s];return n===r}var X8,J8=I(()=>{Ja();X8={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4}});var eE,tE,nE=I(()=>{eE=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],tE=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"]});function T_(t){let e=t?.streamReader;if(e?.constructor?.name!=="WebStreamByobReader")return t;let{reader:n}=e,r=async()=>{await n.cancel(),n.releaseLock()};return e.close=r,e.abort=async()=>{e.interrupted=!0,await r()},t}function h0(t,e,n){if(!Number.isFinite(t)||t<0||t>e)throw new Rs(`${n} has invalid size ${t} (maximum ${e} bytes)`);return t}async function Js(t,e,{maximumLength:n=Tr,reason:r="skip"}={}){let s=h0(e,n,r);await t.ignore(s)}async function u0(t,e,n,{maximumLength:r=e.length,reason:s="read"}={}){let i=n?.length??e.length,o=h0(i,r,s);return t.readBuffer(e,{...n,length:o})}async function O_(t,{maximumLength:e=gs}={}){let s=new ReadableStream({start(c){c.enqueue(t),c.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),i=[],o=0;try{for(;;){let{done:c,value:u}=await s.read();if(c)break;if(o+=u.length,o>e)throw await s.cancel(),new Error(`ZIP entry decompressed data exceeds ${e} bytes`);i.push(u)}}finally{s.releaseLock()}let a=new Uint8Array(o),l=0;for(let c of i)a.set(c,l),l+=c.length;return a}function P_(t,e){if(t.length<Nu)return-1;let n=t.length-Nu;for(let r=0;r<=n;r++)if(_t.get(t,r)===mE&&_t.get(t,r+8)===e+r)return r;return-1}function R_(t){return(t.codePointAt(0)&32)!==0}function $_(t,e){let n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}async function F_(t,{shouldBuffer:e,maximumLength:n=gs}={}){let{syncBuffer:r}=t,{length:s}=r,i=[],o=0;for(;;){let a=await t.tokenizer.peekBuffer(r,{mayBeLess:!0}),l=P_(r.subarray(0,a),o),c=l>=0?0:a===s?Math.min(I_,a-1):0,u=l>=0?l:a-c;if(u===0)break;if(o+=u,o>n)throw new Error(`ZIP entry compressed data exceeds ${n} bytes`);if(e){let f=new Uint8Array(u);await t.tokenizer.readBuffer(f),i.push(f)}else await t.tokenizer.ignore(u);if(l>=0)break}if(Dn(t.tokenizer)||(t.knownSizeDescriptorScannedBytes+=o),!!e)return $_(i,o)}function __(t,e){return Dn(t.tokenizer)?Math.max(0,Tr-(t.tokenizer.position-e)):Math.max(0,gs-t.knownSizeDescriptorScannedBytes)}async function D_(t,e,{shouldBuffer:n,maximumDescriptorLength:r=gs}={}){if(e.dataDescriptor&&e.compressedSize===0)return F_(t,{shouldBuffer:n,maximumLength:r});if(!n){await Js(t.tokenizer,e.compressedSize,{maximumLength:Dn(t.tokenizer)?gs:t.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}let s=W_(t.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>s)throw new Error(`ZIP entry compressed data exceeds ${s} bytes`);let i=new Uint8Array(e.compressedSize);return await t.tokenizer.readBuffer(i),i}function L_(t,e){let n=t.getReader(),r=0,s=!1,i=!1,o=async a=>{s||i||(i=!0,await n.cancel(a))};return new ReadableStream({async pull(a){if(r>=e){a.close(),await o();return}let{done:l,value:c}=await n.read();if(l||!c){s=!0,a.close();return}let u=e-r;if(c.length>u){a.enqueue(c.subarray(0,u)),r+=u,a.close(),await o();return}a.enqueue(c),r+=c.length},async cancel(a){await o(a)}})}async function d0(t,e){return new f0(e).fromBuffer(t)}function hE(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function ms(t,e,n){n={offset:0,...n};for(let[r,s]of e.entries())if(n.mask){if(s!==(n.mask[r]&t[r+n.offset]))return!1}else if(s!==t[r+n.offset])return!1;return!0}function M_(t){return Number.isFinite(t)?Math.max(1,Math.trunc(t)):tl}function B_(t,e,n){return n===void 0?t.read(e):(n.throwIfAborted(),new Promise((r,s)=>{let i=()=>{n.removeEventListener("abort",o)},o=()=>{let a=n.reason;i(),(async()=>{try{await t.cancel(a)}catch{}})(),s(a)};n.addEventListener("abort",o,{once:!0}),(async()=>{try{let a=await t.read(e);i(),r(a)}catch(a){i(),s(a)}})()}))}function U_(t){return Number.isFinite(t)?Math.max(0,Math.min(m_,Math.trunc(t))):0}function z_(t){return Number.isFinite(t)?Math.max(0,t):Number.MAX_SAFE_INTEGER}function Dn(t){let e=t.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function nl(t,e,n){return Dn(t)&&t.position-e>n}function W_(t){let e=t.fileInfo.size,n=Number.isFinite(e)?Math.max(0,e-t.position):Number.MAX_SAFE_INTEGER;return Math.min(n,g_)}function j_(t){if(t instanceof Xe||t instanceof Rs)return!0;if(!(t instanceof Error))return!1;if(C_.has(t.message)||N_.has(t.code))return!0;for(let e of k_)if(t.message.startsWith(e))return!0;return!1}function dE(t,e=gs){let n=[t.compressedSize,t.uncompressedSize];for(let r of n)if(!Number.isFinite(r)||r<0||r>e)return!1;return!0}function q_(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function H_(t,e){e.startsWith("word/")&&(t.hasWordDirectory=!0),e.startsWith("ppt/")&&(t.hasPresentationDirectory=!0),e.startsWith("xl/")&&(t.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(t.hasThreeDimensionalModelEntry=!0)}function pE(t){if(!(!t.hasContentTypesEntry||t.hasUnparseableContentTypes||t.isParsingContentTypes||t.hasParsedContentTypesEntry)){if(t.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(t.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(t.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(t.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function V_(t){let e=t.indexOf('.main+xml"');if(e===-1){let s="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return t.includes(`ContentType="${s}"`)?s:void 0}let n=t.slice(0,e),r=n.lastIndexOf('"');return n.slice(r+1)}var tl,m_,gs,rE,g_,Tr,Tu,sE,y_,w_,iE,c0,oE,aE,b_,E_,x_,S_,A_,lE,cE,uE,v_,fE,C_,k_,N_,Rs,mE,Nu,I_,f0,G_,K_,gE=I(()=>{Ja();Eu();K8();Z8();J8();nE();tl=4100,m_=tl-2,gs=1024*1024,rE=1024,g_=2**31-1,Tr=16*1024*1024,Tu=gs,sE=gs,y_=Tr,w_=1,iE=100,c0=Tr,oE=64,aE=Tu,b_=256,E_=512,x_=Tr,S_=512,A_=512,lE=256,cE=Tu,uE=Tu,v_=Tu,fE=Tr,C_=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),k_=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],N_=new Set(["Z_BUF_ERROR","Z_DATA_ERROR","ERR_INVALID_STATE"]),Rs=class extends Error{};mE=134695760,Nu=16,I_=Nu-1;Wi.prototype.inflate=async function(t,e,n){if(t.compressedMethod===0)return n(e);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);let r=await O_(e,{maximumLength:gs});return n(r)};Wi.prototype.unzip=async function(t){let e=!1,n=0,r=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(nl(this.tokenizer,r,Tr))throw new Rs(`ZIP stream probing exceeds ${Tr} bytes`);let s=await this.readLocalFileHeader();if(!s)break;if(n++,n>rE)throw new Error(`ZIP entry count exceeds ${rE}`);let i=t(s);e=!!i.stop,await this.tokenizer.ignore(s.extraFieldLength);let o=await D_(this,s,{shouldBuffer:!!i.handler,maximumDescriptorLength:Math.min(gs,__(this,r))});if(i.handler&&await this.inflate(s,o,i.handler),s.dataDescriptor){let a=new Uint8Array(Nu);if(await this.tokenizer.readBuffer(a),_t.get(a,0)!==mE)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-a.length}`)}if(nl(this.tokenizer,r,Tr))throw new Rs(`ZIP stream probing exceeds ${Tr} bytes`)}while(!e)};f0=class t{constructor(e){let n=U_(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:n},this.detectors=[...this.options.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return T_(m8(e,this.getTokenizerOptions()))}async parseTokenizer(e,n=0){this.detectionReentryCount=n;let r=e.position;for(let s of this.detectors){let i;try{i=await s.detect(e)}catch(o){if(o instanceof Xe||o instanceof Rs)return;throw o}if(i)return i;if(r!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let n=e instanceof Uint8Array?e:new Uint8Array(e);if(n?.length>1)return this.fromTokenizer(g8(n,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let n=y8(e,this.getTokenizerOptions());return this.fromTokenizer(n)}async fromStream(e){this.options.signal?.throwIfAborted();let n=this.createTokenizerFromWebStream(e);return this.fromTokenizer(n)}async toDetectionStream(e,n){let r=M_(n?.sampleSize??tl),s,i,o=e.getReader({mode:"byob"});try{let{value:c,done:u}=await B_(o,new Uint8Array(r),this.options.signal);if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof Xe))throw f;s=void 0}i=c}finally{o.releaseLock()}let a=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=e.pipeThrough(a);return l.fileType=s,l}async detectGzip(e){if(this.gzipProbeDepth>=w_)return{ext:"gz",mime:"application/gzip"};let n=new el(e),r=L_(n.inflate(),y_),s=Dn(e),i,o,a,l;if(s){let c=new AbortController;i=setTimeout(()=>{c.abort(new DOMException(`Operation timed out after ${iE} ms`,"TimeoutError"))},iE),o=this.options.signal===void 0?c.signal:AbortSignal.any([this.options.signal,c.signal]),a=new t({...this.options,signal:o}),a.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{l=await(a??this).fromStream(r)}catch(c){if(c?.name==="AbortError"&&o?.reason?.name!=="TimeoutError")throw c}finally{clearTimeout(i),s||this.gzipProbeDepth--}return l?.ext==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,n){return ms(this.buffer,e,n)}checkString(e,n){return this.check(Y8(e,n?.encoding),n)}detectConfident=async e=>{if(this.buffer=new Uint8Array(tl),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,Dn(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=lE?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await Js(e,6,{maximumLength:6,reason:"ID3 header prefix"});let n=await e.readToken(X8),r=Dn(e);if(!Number.isFinite(n)||n<0||r&&(n>c0||e.position+n>c0))return;if(e.position+n>e.fileInfo.size)return r?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await Js(e,n,{maximumLength:r?c0:e.fileInfo.size,reason:"ID3 payload"})}catch(s){if(s instanceof Xe)return;throw s}return this.detectionReentryCount>=lE?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let n,r=q_();try{await new Wi(e).unzip(s=>{H_(r,s.filename);let i=s.filename==="[Content_Types].xml",o=pE(r);if(!i&&o)return n=o,{stop:!0};switch(s.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return dE(s,sE)?{async handler(a){let l=new TextDecoder("utf-8").decode(a).trim();n=hE(l)},stop:!0}:{};case"[Content_Types].xml":return r.hasContentTypesEntry=!0,dE(s,sE)?(r.isParsingContentTypes=!0,{async handler(a){let l=new TextDecoder("utf-8").decode(a),c=V_(l);c&&(n=hE(c)),r.hasParsedContentTypesEntry=!0,r.isParsingContentTypes=!1},stop:!0}):(r.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(s.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(s){if(!j_(s))throw s;r.isParsingContentTypes&&(r.isParsingContentTypes=!1,r.hasUnparseableContentTypes=!0)}return n??pE(r)??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let n=new Uint8Array(8);return await e.readBuffer(n),ms(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ms(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ms(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ms(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ms(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ms(n,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let n=await this.readTiffHeader(!1);if(n)return n}if(this.check([77,77])){let n=await this.readTiffHeader(!0);if(n)return n}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function n(){let l=await e.peekNumber(C8),c=128,u=0;for(;(l&c)===0&&c!==0;)++u,c>>=1;let f=new Uint8Array(u+1);return await u0(e,f,void 0,{maximumLength:f.length,reason:"EBML field"}),f}async function r(){let l=await n(),c=await n();c[0]^=128>>c.length-1;let u=Math.min(6,c.length),f=new DataView(l.buffer),h=new DataView(c.buffer,c.length-u,u);return{id:l0(f),len:l0(h)}}async function s(l){let c=0;for(;l>0;){if(c++,c>b_||nl(e,o,Tr))return;let u=e.position,f=await r();if(f.id===17026){if(f.len>oE)return;let h=h0(f.len,oE,"EBML DocType");return(await e.readToken(new Yn(h))).replaceAll(/\00.*$/g,"")}if(Dn(e)&&(!Number.isFinite(f.len)||f.len<0||f.len>aE)||(await Js(e,f.len,{maximumLength:Dn(e)?aE:e.fileInfo.size,reason:"EBML payload"}),--l,e.position<=u))return}}let i=await r(),o=e.position;switch(await s(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){let n=t0.get(this.buffer,4),r=Bi.get(this.buffer,6);if(n>0&&n<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(r>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let n=new Yn(4,"latin1").get(this.buffer,2);if(n.match("^d*")&&n>=1e3&&n<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new Yn(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
633
633
  `,"\r"," "," ","\0"].some(n=>this.checkString(n,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){let n={ext:"png",mime:"image/png"},r={ext:"apng",mime:"image/apng"};await e.ignore(8);async function s(){return{length:await e.readToken(k8),type:await e.readToken(new Yn(4,"latin1"))}}let i=Dn(e),o=e.position,a=0,l=!1;do{if(a++,a>E_||nl(e,o,x_))break;let c=e.position,u=await s();if(u.length<0)return;if(u.type==="IHDR"){if(u.length!==13)return;l=!0}switch(u.type){case"IDAT":return n;case"acTL":return r;default:if(!l&&u.type!=="CgBI")return;if(i&&u.length>cE)return l&&R_(u.type)?n:void 0;try{await Js(e,u.length+4,{maximumLength:i?cE+4:e.fileInfo.size,reason:"PNG chunk payload"})}catch(f){if(!i&&(f instanceof Rs||f instanceof Xe))return n;throw f}}if(e.position<=c)break}while(e.position+8<e.fileInfo.size);return n}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let n=new Yn(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(n){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return n.startsWith("3g")?n.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
634
- `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let n=!1;try{async function r(){let a=new Uint8Array(16);return await u0(e,a,void 0,{maximumLength:a.length,reason:"ASF header GUID"}),{id:a,size:Number(await e.readToken(N8))}}await Js(e,30,{maximumLength:30,reason:"ASF header prelude"});let s=Dn(e),i=e.position,o=0;for(;e.position+24<e.fileInfo.size&&(o++,!(o>S_||nl(e,i,Tr)));){let a=e.position,l=await r(),c=l.size-24;if(!Number.isFinite(c)||c<0){n=!0;break}if(ps(l.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let u=new Uint8Array(16);if(c-=await u0(e,u,void 0,{maximumLength:u.length,reason:"ASF stream type GUID"}),ps(u,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(ps(u,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(s&&c>uE){n=!0;break}if(await Js(e,c,{maximumLength:s?uE:e.fileInfo.size,reason:"ASF header payload"}),e.position<=a){n=!0;break}}}catch(r){if(r instanceof Xe||r instanceof Rs)Dn(e)&&(n=!0);else throw r}return n?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Yn(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let n=new DataView(this.buffer.buffer).getUint32(12,!0);if(n>12&&this.buffer.length>=n+16)try{let r=new TextDecoder().decode(this.buffer.subarray(16,n+16));if(JSON.parse(r).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Q8(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let n="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:n})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:n})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
634
+ `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let n=!1;try{async function r(){let a=new Uint8Array(16);return await u0(e,a,void 0,{maximumLength:a.length,reason:"ASF header GUID"}),{id:a,size:Number(await e.readToken(N8))}}await Js(e,30,{maximumLength:30,reason:"ASF header prelude"});let s=Dn(e),i=e.position,o=0;for(;e.position+24<e.fileInfo.size&&(o++,!(o>S_||nl(e,i,Tr)));){let a=e.position,l=await r(),c=l.size-24;if(!Number.isFinite(c)||c<0){n=!0;break}if(ms(l.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let u=new Uint8Array(16);if(c-=await u0(e,u,void 0,{maximumLength:u.length,reason:"ASF stream type GUID"}),ms(u,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(ms(u,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(s&&c>uE){n=!0;break}if(await Js(e,c,{maximumLength:s?uE:e.fileInfo.size,reason:"ASF header payload"}),e.position<=a){n=!0;break}}}catch(r){if(r instanceof Xe||r instanceof Rs)Dn(e)&&(n=!0);else throw r}return n?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Yn(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let n=new DataView(this.buffer.buffer).getUint32(12,!0);if(n>12&&this.buffer.length>=n+16)try{let r=new TextDecoder().decode(this.buffer.subarray(16,n+16));if(JSON.parse(r).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Q8(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let n="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:n})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:n})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
635
635
  `,{offset:2,encoding:n})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{this.buffer=new Uint8Array(tl);let n=z_(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,n),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,n),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let r=0;r<=this.options.mpegOffsetTolerance;++r){let s=this.scanMpeg(r);if(s)return s}};async readTiffTag(e){let n=await this.tokenizer.readToken(e?Bi:Lt);switch(await this.tokenizer.ignore(10),n){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let n=await this.tokenizer.readToken(e?Bi:Lt);if(!(n>A_)&&!(Dn(this.tokenizer)&&2+n*12>fE))for(let r=0;r<n;++r){let s=await this.readTiffTag(e);if(s)return s}}async readTiffHeader(e){let n={ext:"tif",mime:"image/tiff"},r=(e?Bi:Lt).get(this.buffer,2),s=(e?t0:_t).get(this.buffer,4);if(r===42){if(s>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(s>=8){let a=(e?Bi:Lt).get(this.buffer,8),l=(e?Bi:Lt).get(this.buffer,10);if(a===28&&l===254||a===31&&l===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(Dn(this.tokenizer)&&s>v_)return n;let i=Dn(this.tokenizer)?fE:this.tokenizer.fileInfo.size;try{await Js(this.tokenizer,s,{maximumLength:i,reason:"TIFF IFD offset"})}catch(a){if(a instanceof Xe)return;throw a}let o;try{o=await this.readTiffIFD(e)}catch(a){if(a instanceof Xe)return;throw a}return o??n}if(r===43)return n}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},G_=new Set(eE),K_=new Set(tE)});var yE=I(()=>{b8();gE()});var wE={};ee(wE,{fileCommand:()=>nD,flagsForFuzzing:()=>p0});function X_(t,e){let n=Q_.get(t);if(n)return n;let[r,s]=e.split("/"),i=s?.split("+")[0]?.replace(/-/g," ")||t;switch(r){case"image":return`${i.toUpperCase()} image data`;case"audio":return`${i.toUpperCase()} audio`;case"video":return`${i.toUpperCase()} video`;case"font":return`${i} font`;case"model":return`${i} 3D model`;case"application":return s?.includes("zip")||s?.includes("compressed")?`${i} archive data`:s?.includes("executable")?`${i} executable`:`${t.toUpperCase()} data`;default:return`${t.toUpperCase()} data`}}function J_(t){let e=t.split("/").pop()||t;if(e.startsWith(".")&&!e.includes(".",1))return e;let n=e.lastIndexOf(".");return n===-1||n===0?"":e.slice(n).toLowerCase()}function eD(t,e){if(t.startsWith("#!")){let c=t.split(`
636
636
  `)[0];return c.includes("python")?{description:"Python script, ASCII text executable",mime:"text/x-python"}:c.includes("node")||c.includes("bun")||c.includes("deno")?{description:"JavaScript script, ASCII text executable",mime:"text/javascript"}:c.includes("bash")?{description:"Bourne-Again shell script, ASCII text executable",mime:"text/x-shellscript"}:c.includes("sh")?{description:"POSIX shell script, ASCII text executable",mime:"text/x-shellscript"}:c.includes("ruby")?{description:"Ruby script, ASCII text executable",mime:"text/x-ruby"}:c.includes("perl")?{description:"Perl script, ASCII text executable",mime:"text/x-perl"}:{description:"script, ASCII text executable",mime:"text/plain"}}let n=t.trimStart();if(n.startsWith("<?xml"))return{description:"XML document",mime:"application/xml"};if(n.startsWith("<!DOCTYPE html")||n.toLowerCase().startsWith("<html"))return{description:"HTML document",mime:"text/html"};let r=t.includes(`\r
637
637
  `),s=t.includes("\r")&&!r,i="";r?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let o=J_(e),a=o?Y_.get(o):void 0;if(a)return a.mime.startsWith("text/")&&i?{description:`${a.description}${i}`,mime:a.mime}:a;let l=!1;for(let c=0;c<Math.min(t.length,8192);c++)if(t.charCodeAt(c)>127){l=!0;break}return l?{description:`UTF-8 Unicode text${i}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${i}`,mime:"text/plain"}}async function tD(t,e){if(e.length===0)return{description:"empty",mime:"inode/x-empty"};let n=await d0(e);if(n)return{description:X_(n.ext,n.mime),mime:n.mime};let r=new TextDecoder("utf-8",{fatal:!1}).decode(e);return eD(r,t)}var Z_,Y_,Q_,nD,p0,m0=I(()=>{"use strict";yE();ue();Z_={name:"file",summary:"determine file type",usage:"file [OPTION]... FILE...",options:["-b, --brief do not prepend filenames to output","-i, --mime output MIME type strings","-L, --dereference follow symlinks"," --help display this help and exit"]},Y_=new Map([[".js",{description:"JavaScript source",mime:"text/javascript"}],[".mjs",{description:"JavaScript module",mime:"text/javascript"}],[".cjs",{description:"CommonJS module",mime:"text/javascript"}],[".ts",{description:"TypeScript source",mime:"text/typescript"}],[".tsx",{description:"TypeScript JSX source",mime:"text/typescript"}],[".jsx",{description:"JavaScript JSX source",mime:"text/javascript"}],[".py",{description:"Python script",mime:"text/x-python"}],[".rb",{description:"Ruby script",mime:"text/x-ruby"}],[".go",{description:"Go source",mime:"text/x-go"}],[".rs",{description:"Rust source",mime:"text/x-rust"}],[".c",{description:"C source",mime:"text/x-c"}],[".h",{description:"C header",mime:"text/x-c"}],[".cpp",{description:"C++ source",mime:"text/x-c++"}],[".hpp",{description:"C++ header",mime:"text/x-c++"}],[".java",{description:"Java source",mime:"text/x-java"}],[".sh",{description:"Bourne-Again shell script",mime:"text/x-shellscript"}],[".bash",{description:"Bourne-Again shell script",mime:"text/x-shellscript"}],[".zsh",{description:"Zsh shell script",mime:"text/x-shellscript"}],[".json",{description:"JSON data",mime:"application/json"}],[".yaml",{description:"YAML data",mime:"text/yaml"}],[".yml",{description:"YAML data",mime:"text/yaml"}],[".xml",{description:"XML document",mime:"application/xml"}],[".csv",{description:"CSV text",mime:"text/csv"}],[".toml",{description:"TOML data",mime:"text/toml"}],[".html",{description:"HTML document",mime:"text/html"}],[".htm",{description:"HTML document",mime:"text/html"}],[".css",{description:"CSS stylesheet",mime:"text/css"}],[".svg",{description:"SVG image",mime:"image/svg+xml"}],[".md",{description:"Markdown document",mime:"text/markdown"}],[".markdown",{description:"Markdown document",mime:"text/markdown"}],[".txt",{description:"ASCII text",mime:"text/plain"}],[".rst",{description:"reStructuredText",mime:"text/x-rst"}],[".env",{description:"ASCII text",mime:"text/plain"}],[".gitignore",{description:"ASCII text",mime:"text/plain"}],[".dockerignore",{description:"ASCII text",mime:"text/plain"}]]),Q_=new Map([["jpg","JPEG image data"],["jpeg","JPEG image data"],["png","PNG image data"],["gif","GIF image data"],["webp","WebP image data"],["bmp","PC bitmap"],["ico","MS Windows icon resource"],["tif","TIFF image data"],["tiff","TIFF image data"],["psd","Adobe Photoshop Document"],["avif","AVIF image"],["heic","HEIC image"],["heif","HEIF image"],["jxl","JPEG XL image"],["icns","Mac OS X icon"],["svg","SVG Scalable Vector Graphics image"],["pdf","PDF document"],["epub","EPUB document"],["mobi","Mobipocket E-book"],["djvu","DjVu document"],["zip","Zip archive data"],["gz","gzip compressed data"],["gzip","gzip compressed data"],["bz2","bzip2 compressed data"],["xz","XZ compressed data"],["tar","POSIX tar archive"],["rar","RAR archive data"],["7z","7-zip archive data"],["lz","lzip compressed data"],["lzma","LZMA compressed data"],["zst","Zstandard compressed data"],["cab","Microsoft Cabinet archive"],["ar","Unix ar archive"],["rpm","RPM package"],["deb","Debian binary package"],["apk","Android Package"],["dmg","Apple disk image"],["iso","ISO 9660 CD-ROM filesystem data"],["vhd","Microsoft Virtual Hard Disk"],["vhdx","Microsoft Virtual Hard Disk (new format)"],["qcow2","QEMU QCOW Image"],["mp3","Audio file with ID3"],["m4a","MPEG-4 audio"],["aac","AAC audio"],["wav","RIFF (little-endian) data, WAVE audio"],["flac","FLAC audio bitstream data"],["ogg","Ogg data"],["oga","Ogg audio"],["opus","Ogg Opus audio"],["aiff","AIFF audio"],["wma","Windows Media Audio"],["amr","AMR audio"],["mid","MIDI audio"],["midi","MIDI audio"],["ape","Monkey's Audio"],["mp4","ISO Media, MPEG-4"],["m4v","MPEG-4 video"],["webm","WebM"],["avi","RIFF (little-endian) data, AVI"],["mov","ISO Media, Apple QuickTime movie"],["mkv","Matroska data"],["wmv","Windows Media Video"],["flv","Flash Video"],["3gp","3GPP multimedia"],["3g2","3GPP2 multimedia"],["ogv","Ogg video"],["mts","MPEG transport stream"],["m2ts","MPEG transport stream"],["ts","MPEG transport stream"],["mpg","MPEG video"],["mpeg","MPEG video"],["exe","PE32 executable"],["dll","PE32 DLL"],["elf","ELF executable"],["mach","Mach-O executable"],["wasm","WebAssembly (wasm) binary module"],["dex","Android Dalvik executable"],["class","Java class file"],["swf","Adobe Flash"],["doc","Microsoft Word Document"],["docx","Microsoft Word 2007+ Document"],["xls","Microsoft Excel Spreadsheet"],["xlsx","Microsoft Excel 2007+ Spreadsheet"],["ppt","Microsoft PowerPoint Presentation"],["pptx","Microsoft PowerPoint 2007+ Presentation"],["odt","OpenDocument Text"],["ods","OpenDocument Spreadsheet"],["odp","OpenDocument Presentation"],["ttf","TrueType Font"],["otf","OpenType Font"],["woff","Web Open Font Format"],["woff2","Web Open Font Format 2"],["eot","Embedded OpenType font"],["stl","Stereolithography CAD"],["obj","Wavefront 3D Object"],["gltf","GL Transmission Format"],["glb","GL Transmission Format (binary)"],["sqlite","SQLite 3.x database"],["mdb","Microsoft Access Database"],["xml","XML document"],["json","JSON data"],["macho","Mach-O binary"],["ics","iCalendar data"],["vcf","vCard data"],["msi","Microsoft Installer"],["ps","PostScript"],["ai","Adobe Illustrator"],["indd","Adobe InDesign"],["sketch","Sketch design file"],["fig","Figma design file"],["xd","Adobe XD"],["blend","Blender"],["fbx","Autodesk FBX"],["lnk","MS Windows shortcut"],["alias","Mac OS alias"],["torrent","BitTorrent file"],["pcap","pcap capture file"],["arrow","Apache Arrow"],["parquet","Apache Parquet"]]);nD={name:"file",async execute(t,e){if(U(t))return B(Z_);let n=!1,r=!1,s=[];for(let a of t)if(a.startsWith("--")){if(a==="--brief")n=!0;else if(a==="--mime"||a==="--mime-type")r=!0;else if(a!=="--dereference")return Q("file",a)}else if(a.startsWith("-")&&a!=="-"){for(let l of a.slice(1))if(l==="b")n=!0;else if(l==="i")r=!0;else if(l!=="L")return Q("file",`-${l}`)}else s.push(a);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
@@ -669,12 +669,12 @@ Otherwise, lists all available commands.
669
669
  `)}
670
670
  `:"",stderr:"",exitCode:0}}var hD,S0,A0=I(()=>{"use strict";pe();hD={name:"tac",execute:fD},S0={name:"tac",flags:[],stdinType:"text",needsFiles:!0}});var vE={};ee(vE,{flagsForFuzzing:()=>v0,hostname:()=>pD});async function dD(t,e){return{stdout:`localhost
671
671
  `,stderr:"",exitCode:0}}var pD,v0,C0=I(()=>{"use strict";pD={name:"hostname",execute:dD},v0={name:"hostname",flags:[]}});var CE={};ee(CE,{flagsForFuzzing:()=>k0,whoami:()=>gD});async function mD(t,e){return{stdout:`user
672
- `,stderr:"",exitCode:0}}var gD,k0,N0=I(()=>{"use strict";gD={name:"whoami",execute:mD},k0={name:"whoami",flags:[]}});var kE={};ee(kE,{flagsForFuzzing:()=>T0,od:()=>wD});async function yD(t,e){let n="octal",r=[],s=[];for(let d=0;d<t.length;d++){let p=t[d];if(p==="-c")r.push("char");else if(p==="-An"||p==="-A"&&t[d+1]==="n")n="none",p==="-A"&&d++;else if(p==="-t"&&t[d+1]){let m=t[++d];m==="x1"?r.push("hex"):m==="c"?r.push("char"):m.startsWith("o")&&r.push("octal")}else(!p.startsWith("-")||p==="-")&&s.push(p)}r.length===0&&r.push("octal");let i=e.stdin;if(s.length>0&&s[0]!=="-"){let d=s[0].startsWith("/")?s[0]:`${e.cwd}/${s[0]}`;try{i=await os(e.fs,d)}catch{return{stdout:"",stderr:`od: ${s[0]}: No such file or directory
672
+ `,stderr:"",exitCode:0}}var gD,k0,N0=I(()=>{"use strict";gD={name:"whoami",execute:mD},k0={name:"whoami",flags:[]}});var kE={};ee(kE,{flagsForFuzzing:()=>T0,od:()=>wD});async function yD(t,e){let n="octal",r=[],s=[];for(let d=0;d<t.length;d++){let p=t[d];if(p==="-c")r.push("char");else if(p==="-An"||p==="-A"&&t[d+1]==="n")n="none",p==="-A"&&d++;else if(p==="-t"&&t[d+1]){let m=t[++d];m==="x1"?r.push("hex"):m==="c"?r.push("char"):m.startsWith("o")&&r.push("octal")}else(!p.startsWith("-")||p==="-")&&s.push(p)}r.length===0&&r.push("octal");let i=e.stdin;if(s.length>0&&s[0]!=="-"){let d=s[0].startsWith("/")?s[0]:`${e.cwd}/${s[0]}`;try{i=await as(e.fs,d)}catch{return{stdout:"",stderr:`od: ${s[0]}: No such file or directory
673
673
  `,exitCode:1}}}let o=r.includes("char");function a(d){return d===0?" \\0":d===7?" \\a":d===8?" \\b":d===9?" \\t":d===10?" \\n":d===11?" \\v":d===12?" \\f":d===13?" \\r":d>=32&&d<127?` ${String.fromCharCode(d)}`:` ${d.toString(8).padStart(3,"0")}`}function l(d){return o?` ${d.toString(16).padStart(2,"0")}`:` ${d.toString(16).padStart(2,"0")}`}function c(d){return` ${d.toString(8).padStart(3,"0")}`}let u=[];for(let d of i)u.push(d.charCodeAt(0));let f=16,h=[];for(let d=0;d<u.length;d+=f){let p=u.slice(d,d+f);for(let m=0;m<r.length;m++){let g=r[m],y;g==="char"?y=p.map(a):g==="hex"?y=p.map(l):y=p.map(c);let w="";m===0&&n!=="none"?w=`${d.toString(8).padStart(7,"0")} `:(m>0||n==="none")&&(w=n==="none"?"":" "),h.push(w+y.join(""))}}return n!=="none"&&u.length>0&&h.push(u.length.toString(8).padStart(7,"0")),{stdout:h.length>0?`${h.join(`
674
674
  `)}
675
- `:"",stderr:"",exitCode:0}}var wD,T0,O0=I(()=>{"use strict";pe();wD={name:"od",execute:yD},T0={name:"od",flags:[{flag:"-c",type:"boolean"},{flag:"-A",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-N",type:"value",valueHint:"number"}],stdinType:"text",needsFiles:!0}});var Pu={};ee(Pu,{flagsForFuzzing:()=>R0,gunzipCommand:()=>kD,gunzipFlagsForFuzzing:()=>$0,gzipCommand:()=>CD,zcatCommand:()=>ND,zcatFlagsForFuzzing:()=>F0});function NE(t){return t.best?gs.constants.Z_BEST_COMPRESSION:t.level8?8:t.level7?7:t.level6?6:t.level5?5:t.level4?4:t.level3?3:t.level2?2:t.fast?gs.constants.Z_BEST_SPEED:gs.constants.Z_DEFAULT_COMPRESSION}function TE(t){if(t.length<10)return{originalName:null,mtime:null,headerSize:0};if(t[0]!==31||t[1]!==139)return{originalName:null,mtime:null,headerSize:0};let e=t[3],n=t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r=10;if(e&4){if(r+2>t.length)return{originalName:null,mtime:null,headerSize:0};let i=t[r]|t[r+1]<<8;r+=2+i}let s=null;if(e&8){let i=r;for(;r<t.length&&t[r]!==0;)r++;r<t.length&&(s=new TextDecoder().decode(t.slice(i,r)),r++)}if(e&16){for(;r<t.length&&t[r]!==0;)r++;r++}return e&2&&(r+=2),{originalName:s,mtime:n>0?new Date(n*1e3):null,headerSize:r}}function OE(t){if(t.length<4)return 0;let e=t.length;return t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24}function Iu(t){return t.length>=2&&t[0]===31&&t[1]===139}function Ou(t){return Buffer.from(t).toString("latin1")}function IE(t){return t.limits?.maxOutputSize??0}function I0(t,e){if(e>0){if(OE(t)>e)throw new Error(`decompressed data exceeds limit (${e} bytes)`);return(0,gs.gunzipSync)(t,{maxOutputLength:e})}return(0,gs.gunzipSync)(t)}async function PE(t,e,n,r,s,i){let o=n.suffix,a,l,c,u=IE(t);if(e==="-"||e==="")if(c=Uint8Array.from(t.stdin,f=>f.charCodeAt(0)),s){if(!Iu(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
675
+ `:"",stderr:"",exitCode:0}}var wD,T0,O0=I(()=>{"use strict";pe();wD={name:"od",execute:yD},T0={name:"od",flags:[{flag:"-c",type:"boolean"},{flag:"-A",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-N",type:"value",valueHint:"number"}],stdinType:"text",needsFiles:!0}});var Pu={};ee(Pu,{flagsForFuzzing:()=>R0,gunzipCommand:()=>kD,gunzipFlagsForFuzzing:()=>$0,gzipCommand:()=>CD,zcatCommand:()=>ND,zcatFlagsForFuzzing:()=>F0});function NE(t){return t.best?ys.constants.Z_BEST_COMPRESSION:t.level8?8:t.level7?7:t.level6?6:t.level5?5:t.level4?4:t.level3?3:t.level2?2:t.fast?ys.constants.Z_BEST_SPEED:ys.constants.Z_DEFAULT_COMPRESSION}function TE(t){if(t.length<10)return{originalName:null,mtime:null,headerSize:0};if(t[0]!==31||t[1]!==139)return{originalName:null,mtime:null,headerSize:0};let e=t[3],n=t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r=10;if(e&4){if(r+2>t.length)return{originalName:null,mtime:null,headerSize:0};let i=t[r]|t[r+1]<<8;r+=2+i}let s=null;if(e&8){let i=r;for(;r<t.length&&t[r]!==0;)r++;r<t.length&&(s=new TextDecoder().decode(t.slice(i,r)),r++)}if(e&16){for(;r<t.length&&t[r]!==0;)r++;r++}return e&2&&(r+=2),{originalName:s,mtime:n>0?new Date(n*1e3):null,headerSize:r}}function OE(t){if(t.length<4)return 0;let e=t.length;return t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24}function Iu(t){return t.length>=2&&t[0]===31&&t[1]===139}function Ou(t){return Buffer.from(t).toString("latin1")}function IE(t){return t.limits?.maxOutputSize??0}function I0(t,e){if(e>0){if(OE(t)>e)throw new Error(`decompressed data exceeds limit (${e} bytes)`);return(0,ys.gunzipSync)(t,{maxOutputLength:e})}return(0,ys.gunzipSync)(t)}async function PE(t,e,n,r,s,i){let o=n.suffix,a,l,c,u=IE(t);if(e==="-"||e==="")if(c=Uint8Array.from(t.stdin,f=>f.charCodeAt(0)),s){if(!Iu(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
676
676
  `,exitCode:1};try{let f=I0(c,u);return{stdout:Ou(f),stderr:"",exitCode:0}}catch(f){let h=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`${r}: stdin: ${h}
677
- `,exitCode:1}}}else{let f=NE(n),h=(0,gs.gzipSync)(c,{level:f});return{stdout:Ou(h),stderr:"",exitCode:0}}a=t.fs.resolvePath(t.cwd,e);try{if((await t.fs.stat(a)).isDirectory)return n.recursive?await RE(t,a,n,r,s,i):n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: is a directory -- ignored
677
+ `,exitCode:1}}}else{let f=NE(n),h=(0,ys.gzipSync)(c,{level:f});return{stdout:Ou(h),stderr:"",exitCode:0}}a=t.fs.resolvePath(t.cwd,e);try{if((await t.fs.stat(a)).isDirectory)return n.recursive?await RE(t,a,n,r,s,i):n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: is a directory -- ignored
678
678
  `,exitCode:1}}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
679
679
  `,exitCode:1}}try{c=await t.fs.readFileBuffer(a)}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
680
680
  `,exitCode:1}}if(s){if(!e.endsWith(o))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e}: unknown suffix -- ignored
@@ -683,7 +683,7 @@ Otherwise, lists all available commands.
683
683
  `,exitCode:1}}if(i)return{stdout:Ou(f),stderr:"",exitCode:0};if(n.name){let h=TE(c);h.originalName?l=t.fs.resolvePath(t.cwd,h.originalName):l=a.slice(0,-o.length)}else l=a.slice(0,-o.length);if(!n.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${r}: ${l} already exists; not overwritten
684
684
  `,exitCode:1}}catch{}if(await t.fs.writeFile(l,f),!n.keep&&!i&&await t.fs.rm(a),n.verbose){let h=c.length>0?((1-c.length/f.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${e}: ${h}% -- replaced with ${l.split("/").pop()}
685
685
  `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}else{if(e.endsWith(o))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${e} already has ${o} suffix -- unchanged
686
- `,exitCode:1};let f=NE(n),h;try{h=(0,gs.gzipSync)(c,{level:f})}catch(d){let p=d instanceof Error?d.message:"unknown error";return{stdout:"",stderr:`${r}: ${e}: ${p}
686
+ `,exitCode:1};let f=NE(n),h;try{h=(0,ys.gzipSync)(c,{level:f})}catch(d){let p=d instanceof Error?d.message:"unknown error";return{stdout:"",stderr:`${r}: ${e}: ${p}
687
687
  `,exitCode:1}}if(i)return{stdout:Ou(h),stderr:"",exitCode:0};if(l=a+o,!n.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${r}: ${l} already exists; not overwritten
688
688
  `,exitCode:1}}catch{}if(await t.fs.writeFile(l,h),!n.keep&&!i&&await t.fs.rm(a),n.verbose){let d=c.length>0?((1-h.length/c.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${e}: ${d}% -- replaced with ${l.split("/").pop()}
689
689
  `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function RE(t,e,n,r,s,i){let o=await t.fs.readdir(e),a="",l="",c=0;for(let u of o){let f=t.fs.resolvePath(e,u),h=await t.fs.stat(f);if(h.isDirectory){let d=await RE(t,f,n,r,s,i);a+=d.stdout,l+=d.stderr,d.exitCode!==0&&(c=d.exitCode)}else if(h.isFile){let d=n.suffix;if(s&&!u.endsWith(d)||!s&&u.endsWith(d))continue;let p=f.startsWith(`${t.cwd}/`)?f.slice(t.cwd.length+1):f,m=await PE(t,p,n,r,s,i);a+=m.stdout,l+=m.stderr,m.exitCode!==0&&(c=m.exitCode)}}return{stdout:a,stderr:l,exitCode:c}}async function AD(t,e,n,r){let s;if(e==="-"||e==="")s=Uint8Array.from(t.stdin,f=>f.charCodeAt(0));else{let f=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${r}: ${e}: No such file or directory
@@ -694,7 +694,7 @@ Otherwise, lists all available commands.
694
694
  `,exitCode:1};try{return I0(s,IE(t)),n.verbose?{stdout:"",stderr:`${e}: OK
695
695
  `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(i){let o=i instanceof Error?i.message:"invalid";return{stdout:"",stderr:`${r}: ${e}: ${o}
696
696
  `,exitCode:1}}}async function P0(t,e,n){let r=n==="zcat"?xD:n==="gunzip"?ED:bD;if(U(t))return B(r);let s=je(n,t,SD);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,o=s.result.positional,a=n==="gunzip"||n==="zcat"||i.decompress||i.uncompress,l=n==="zcat"||i.stdout||i.toStdout;if(i.list){o.length===0&&(o=["-"]);let h=` compressed uncompressed ratio uncompressed_name
697
- `,d="",p=0;for(let m of o){let g=await AD(e,m,i,n);h+=g.stdout,d+=g.stderr,g.exitCode!==0&&(p=g.exitCode)}return{stdout:h,stderr:d,exitCode:p}}if(i.test){o.length===0&&(o=["-"]);let h="",d="",p=0;for(let m of o){let g=await vD(e,m,i,n);h+=g.stdout,d+=g.stderr,g.exitCode!==0&&(p=g.exitCode)}return{stdout:h,stderr:d,exitCode:p}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let h of o){let d=await PE(e,h,i,n,a,l);c+=d.stdout,u+=d.stderr,d.exitCode!==0&&(f=d.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var gs,bD,ED,xD,SD,CD,kD,ND,R0,$0,F0,rl=I(()=>{"use strict";gs=require("node:zlib");pe();jt();ue();bD={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
697
+ `,d="",p=0;for(let m of o){let g=await AD(e,m,i,n);h+=g.stdout,d+=g.stderr,g.exitCode!==0&&(p=g.exitCode)}return{stdout:h,stderr:d,exitCode:p}}if(i.test){o.length===0&&(o=["-"]);let h="",d="",p=0;for(let m of o){let g=await vD(e,m,i,n);h+=g.stdout,d+=g.stderr,g.exitCode!==0&&(p=g.exitCode)}return{stdout:h,stderr:d,exitCode:p}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let h of o){let d=await PE(e,h,i,n,a,l);c+=d.stdout,u+=d.stderr,d.exitCode!==0&&(f=d.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var ys,bD,ED,xD,SD,CD,kD,ND,R0,$0,F0,rl=I(()=>{"use strict";ys=require("node:zlib");pe();jt();ue();bD={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
698
698
 
699
699
  When no FILE is given, or when FILE is -, read from standard input.
700
700
 
@@ -777,10 +777,10 @@ When no FILE is given, or when FILE is -, read from standard input.`,options:["-
777
777
  `),Nt=Ee.length>1&&Ee[0].length<Ke[0].length;if(Ke.length===1||Nt)return`
778
778
  `;for(var hn=0,Kt=0;Kt<Ke.length;Kt++)Ke[Kt][0]===`
779
779
  `&&hn++;return hn>=Ke.length/2?`\r
780
- `:"\r"};function ye(we){return S.skipEmptyLines==="greedy"?we.join("").trim()==="":we.length===1&&we[0].length===0}function ve(we){if(_.test(we)){var be=parseFloat(we);if(be>T&&be<v)return!0}return!1}function $e(){return z&&oe&&(vn("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),oe=!1),S.skipEmptyLines&&(z.data=z.data.filter(function(we){return!ye(we)})),Pe()&&Je(),et()}function Pe(){return S.header&&ne.length===0}function Je(){if(!z)return;function we(Ae,Ke){k(S.transformHeader)&&(Ae=S.transformHeader(Ae,Ke)),ne.push(Ae)}if(Array.isArray(z.data[0])){for(var be=0;Pe()&&be<z.data.length;be++)z.data[be].forEach(we);z.data.splice(0,1)}else z.data.forEach(we)}function ht(we){return S.dynamicTypingFunction&&S.dynamicTyping[we]===void 0&&(S.dynamicTyping[we]=S.dynamicTypingFunction(we)),(S.dynamicTyping[we]||S.dynamicTyping)===!0}function Ct(we,be){return ht(we)?be==="true"||be==="TRUE"?!0:be==="false"||be==="FALSE"?!1:ve(be)?parseFloat(be):D.test(be)?new Date(be):be===""?null:be:be}function et(){if(!z||!S.header&&!S.dynamicTyping&&!S.transform)return z;function we(Ae,Ke){var Ee=S.header?{}:[],Nt;for(Nt=0;Nt<Ae.length;Nt++){var hn=Nt,Kt=Ae[Nt];S.header&&(hn=Nt>=ne.length?"__parsed_extra":ne[Nt]),S.transform&&(Kt=S.transform(Kt,hn)),Kt=Ct(hn,Kt),hn==="__parsed_extra"?(Ee[hn]=Ee[hn]||[],Ee[hn].push(Kt)):Ee[hn]=Kt}return S.header&&(Nt>ne.length?vn("FieldMismatch","TooManyFields","Too many fields: expected "+ne.length+" fields but parsed "+Nt,G+Ke):Nt<ne.length&&vn("FieldMismatch","TooFewFields","Too few fields: expected "+ne.length+" fields but parsed "+Nt,G+Ke)),Ee}var be=1;return!z.data.length||Array.isArray(z.data[0])?(z.data=z.data.map(we),be=z.data.length):z.data=we(z.data,0),S.header&&z.meta&&(z.meta.fields=ne),G+=be,z}function br(we,be,Ae,Ke,Ee){var Nt,hn,Kt,Ni;Ee=Ee||[","," ","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var Ws=0;Ws<Ee.length;Ws++){var Ia=Ee[Ws],Ti=0,js=0,Cn=0;Kt=void 0;for(var rs=new b({comments:Ke,delimiter:Ia,newline:be,preview:10}).parse(we),dn=0;dn<rs.data.length;dn++){if(Ae&&ye(rs.data[dn])){Cn++;continue}var qn=rs.data[dn].length;if(js+=qn,typeof Kt>"u"){Kt=qn;continue}else qn>0&&(Ti+=Math.abs(qn-Kt),Kt=qn)}rs.data.length>0&&(js/=rs.data.length-Cn),(typeof hn>"u"||Ti<=hn)&&(typeof Ni>"u"||js>Ni)&&js>1.99&&(hn=Ti,Nt=Ia,Ni=js)}return S.delimiter=Nt,{successful:!!Nt,bestDelimiter:Nt}}function vn(we,be,Ae,Ke){var Ee={type:we,code:be,message:Ae};Ke!==void 0&&(Ee.row=Ke),z.errors.push(Ee)}}function w(S){return S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(S){S=S||{};var v=S.delimiter,T=S.newline,_=S.comments,D=S.step,W=S.preview,H=S.fastMode,G,j=null,q=!1;S.quoteChar===void 0||S.quoteChar===null?G='"':G=S.quoteChar;var Y=G;if(S.escapeChar!==void 0&&(Y=S.escapeChar),(typeof v!="string"||a.BAD_DELIMITERS.indexOf(v)>-1)&&(v=","),_===v)throw new Error("Comment character same as delimiter");_===!0?_="#":(typeof _!="string"||a.BAD_DELIMITERS.indexOf(_)>-1)&&(_=!1),T!==`
780
+ `:"\r"};function ye(we){return S.skipEmptyLines==="greedy"?we.join("").trim()==="":we.length===1&&we[0].length===0}function ve(we){if(_.test(we)){var be=parseFloat(we);if(be>T&&be<v)return!0}return!1}function $e(){return z&&oe&&(vn("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),oe=!1),S.skipEmptyLines&&(z.data=z.data.filter(function(we){return!ye(we)})),Pe()&&Je(),et()}function Pe(){return S.header&&ne.length===0}function Je(){if(!z)return;function we(Ae,Ke){k(S.transformHeader)&&(Ae=S.transformHeader(Ae,Ke)),ne.push(Ae)}if(Array.isArray(z.data[0])){for(var be=0;Pe()&&be<z.data.length;be++)z.data[be].forEach(we);z.data.splice(0,1)}else z.data.forEach(we)}function ht(we){return S.dynamicTypingFunction&&S.dynamicTyping[we]===void 0&&(S.dynamicTyping[we]=S.dynamicTypingFunction(we)),(S.dynamicTyping[we]||S.dynamicTyping)===!0}function Ct(we,be){return ht(we)?be==="true"||be==="TRUE"?!0:be==="false"||be==="FALSE"?!1:ve(be)?parseFloat(be):D.test(be)?new Date(be):be===""?null:be:be}function et(){if(!z||!S.header&&!S.dynamicTyping&&!S.transform)return z;function we(Ae,Ke){var Ee=S.header?{}:[],Nt;for(Nt=0;Nt<Ae.length;Nt++){var hn=Nt,Kt=Ae[Nt];S.header&&(hn=Nt>=ne.length?"__parsed_extra":ne[Nt]),S.transform&&(Kt=S.transform(Kt,hn)),Kt=Ct(hn,Kt),hn==="__parsed_extra"?(Ee[hn]=Ee[hn]||[],Ee[hn].push(Kt)):Ee[hn]=Kt}return S.header&&(Nt>ne.length?vn("FieldMismatch","TooManyFields","Too many fields: expected "+ne.length+" fields but parsed "+Nt,G+Ke):Nt<ne.length&&vn("FieldMismatch","TooFewFields","Too few fields: expected "+ne.length+" fields but parsed "+Nt,G+Ke)),Ee}var be=1;return!z.data.length||Array.isArray(z.data[0])?(z.data=z.data.map(we),be=z.data.length):z.data=we(z.data,0),S.header&&z.meta&&(z.meta.fields=ne),G+=be,z}function br(we,be,Ae,Ke,Ee){var Nt,hn,Kt,Ni;Ee=Ee||[","," ","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var Ws=0;Ws<Ee.length;Ws++){var Ia=Ee[Ws],Ti=0,js=0,Cn=0;Kt=void 0;for(var ss=new b({comments:Ke,delimiter:Ia,newline:be,preview:10}).parse(we),dn=0;dn<ss.data.length;dn++){if(Ae&&ye(ss.data[dn])){Cn++;continue}var qn=ss.data[dn].length;if(js+=qn,typeof Kt>"u"){Kt=qn;continue}else qn>0&&(Ti+=Math.abs(qn-Kt),Kt=qn)}ss.data.length>0&&(js/=ss.data.length-Cn),(typeof hn>"u"||Ti<=hn)&&(typeof Ni>"u"||js>Ni)&&js>1.99&&(hn=Ti,Nt=Ia,Ni=js)}return S.delimiter=Nt,{successful:!!Nt,bestDelimiter:Nt}}function vn(we,be,Ae,Ke){var Ee={type:we,code:be,message:Ae};Ke!==void 0&&(Ee.row=Ke),z.errors.push(Ee)}}function w(S){return S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(S){S=S||{};var v=S.delimiter,T=S.newline,_=S.comments,D=S.step,W=S.preview,H=S.fastMode,G,j=null,q=!1;S.quoteChar===void 0||S.quoteChar===null?G='"':G=S.quoteChar;var Y=G;if(S.escapeChar!==void 0&&(Y=S.escapeChar),(typeof v!="string"||a.BAD_DELIMITERS.indexOf(v)>-1)&&(v=","),_===v)throw new Error("Comment character same as delimiter");_===!0?_="#":(typeof _!="string"||a.BAD_DELIMITERS.indexOf(_)>-1)&&(_=!1),T!==`
781
781
  `&&T!=="\r"&&T!==`\r
782
782
  `&&(T=`
783
- `);var se=0,oe=!1;this.parse=function(ne,z,Le){if(typeof ne!="string")throw new Error("Input must be a string");var ye=ne.length,ve=v.length,$e=T.length,Pe=_.length,Je=k(D);se=0;var ht=[],Ct=[],et=[],br=0;if(!ne)return Cn();if(H||H!==!1&&ne.indexOf(G)===-1){for(var vn=ne.split(T),we=0;we<vn.length;we++){if(et=vn[we],se+=et.length,we!==vn.length-1)se+=T.length;else if(Le)return Cn();if(!(_&&et.substring(0,Pe)===_)){if(Je){if(ht=[],Ws(et.split(v)),rs(),oe)return Cn()}else Ws(et.split(v));if(W&&we>=W)return ht=ht.slice(0,W),Cn(!0)}}return Cn()}for(var be=ne.indexOf(v,se),Ae=ne.indexOf(T,se),Ke=new RegExp(w(Y)+w(G),"g"),Ee=ne.indexOf(G,se);;){if(ne[se]===G){for(Ee=se,se++;;){if(Ee=ne.indexOf(G,Ee+1),Ee===-1)return Le||Ct.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:ht.length,index:se}),Ti();if(Ee===ye-1){var Nt=ne.substring(se,Ee).replace(Ke,G);return Ti(Nt)}if(G===Y&&ne[Ee+1]===Y){Ee++;continue}if(!(G!==Y&&Ee!==0&&ne[Ee-1]===Y)){be!==-1&&be<Ee+1&&(be=ne.indexOf(v,Ee+1)),Ae!==-1&&Ae<Ee+1&&(Ae=ne.indexOf(T,Ee+1));var hn=Ae===-1?be:Math.min(be,Ae),Kt=Ia(hn);if(ne.substr(Ee+1+Kt,ve)===v){et.push(ne.substring(se,Ee).replace(Ke,G)),se=Ee+1+Kt+ve,ne[Ee+1+Kt+ve]!==G&&(Ee=ne.indexOf(G,se)),be=ne.indexOf(v,se),Ae=ne.indexOf(T,se);break}var Ni=Ia(Ae);if(ne.substring(Ee+1+Ni,Ee+1+Ni+$e)===T){if(et.push(ne.substring(se,Ee).replace(Ke,G)),js(Ee+1+Ni+$e),be=ne.indexOf(v,se),Ee=ne.indexOf(G,se),Je&&(rs(),oe))return Cn();if(W&&ht.length>=W)return Cn(!0);break}Ct.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:ht.length,index:se}),Ee++}}continue}if(_&&et.length===0&&ne.substring(se,se+Pe)===_){if(Ae===-1)return Cn();se=Ae+$e,Ae=ne.indexOf(T,se),be=ne.indexOf(v,se);continue}if(be!==-1&&(be<Ae||Ae===-1)){et.push(ne.substring(se,be)),se=be+ve,be=ne.indexOf(v,se);continue}if(Ae!==-1){if(et.push(ne.substring(se,Ae)),js(Ae+$e),Je&&(rs(),oe))return Cn();if(W&&ht.length>=W)return Cn(!0);continue}break}return Ti();function Ws(dn){ht.push(dn),br=se}function Ia(dn){var qn=0;if(dn!==-1){var qs=ne.substring(Ee+1,dn);qs&&qs.trim()===""&&(qn=qs.length)}return qn}function Ti(dn){return Le||(typeof dn>"u"&&(dn=ne.substring(se)),et.push(dn),se=ye,Ws(et),Je&&rs()),Cn()}function js(dn){se=dn,Ws(et),et=[],Ae=ne.indexOf(T,se)}function Cn(dn){if(S.header&&!z&&ht.length&&!q){let qn=ht[0],qs=Object.create(null),cd=new Set(qn),eb=!1;for(let go=0;go<qn.length;go++){let ss=qn[go];if(k(S.transformHeader)&&(ss=S.transformHeader(ss,go)),!qs[ss])qs[ss]=1,qn[go]=ss;else{let Pa,tb=qs[ss];do Pa=`${ss}_${tb}`,tb++;while(cd.has(Pa));cd.add(Pa),qn[go]=Pa,qs[ss]++,eb=!0,j===null&&(j={}),j[Pa]=ss}cd.add(ss)}eb&&console.warn("Duplicate headers found and renamed."),q=!0}return{data:ht,errors:Ct,meta:{delimiter:v,linebreak:T,aborted:oe,truncated:!!dn,cursor:br+(z||0),renamedHeaders:j}}}function rs(){D(Cn()),ht=[],Ct=[]}},this.abort=function(){oe=!0},this.getCharIndex=function(){return se}}function E(){if(!a.WORKERS_SUPPORTED)return!1;var S=n(),v=new e.Worker(S);return v.onmessage=A,v.id=o++,i[v.id]=v,v}function A(S){var v=S.data,T=i[v.workerId],_=!1;if(v.error)T.userError(v.error,v.file);else if(v.results&&v.results.data){var D=function(){_=!0,C(v.workerId,{data:[],errors:[],meta:{aborted:!0}})},W={abort:D,pause:P,resume:P};if(k(T.userStep)){for(var H=0;H<v.results.data.length&&(T.userStep({data:v.results.data[H],errors:v.results.errors,meta:v.results.meta},W),!_);H++);delete v.results}else k(T.userChunk)&&(T.userChunk(v.results,W,v.file),delete v.results)}v.finished&&!_&&C(v.workerId,v.results)}function C(S,v){var T=i[S];k(T.userComplete)&&T.userComplete(v),T.terminate(),delete i[S]}function P(){throw new Error("Not implemented.")}function $(S){var v=S.data;if(typeof a.WORKER_ID>"u"&&v&&(a.WORKER_ID=v.workerId),typeof v.input=="string")e.postMessage({workerId:a.WORKER_ID,results:a.parse(v.input,v.config),finished:!0});else if(e.File&&v.input instanceof File||v.input instanceof Object){var T=a.parse(v.input,v.config);T&&e.postMessage({workerId:a.WORKER_ID,results:T,finished:!0})}}function O(S){if(typeof S!="object"||S===null)return S;var v=Array.isArray(S)?[]:{};for(var T in S)v[T]=O(S[T]);return v}function R(S,v){return function(){S.apply(v,arguments)}}function k(S){return typeof S=="function"}return a})});function aM(t,e){let n=t.slice(0,e).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function lM(t,e,n){let r=t.split(/\r\n|\n|\r/g),s="",i=(Math.log10(e+1)|0)+1;for(let o=e-1;o<=e+1;o++){let a=r[o-1];a&&(s+=o.toString().padEnd(i," "),s+=": ",s+=a,s+=`
783
+ `);var se=0,oe=!1;this.parse=function(ne,z,Le){if(typeof ne!="string")throw new Error("Input must be a string");var ye=ne.length,ve=v.length,$e=T.length,Pe=_.length,Je=k(D);se=0;var ht=[],Ct=[],et=[],br=0;if(!ne)return Cn();if(H||H!==!1&&ne.indexOf(G)===-1){for(var vn=ne.split(T),we=0;we<vn.length;we++){if(et=vn[we],se+=et.length,we!==vn.length-1)se+=T.length;else if(Le)return Cn();if(!(_&&et.substring(0,Pe)===_)){if(Je){if(ht=[],Ws(et.split(v)),ss(),oe)return Cn()}else Ws(et.split(v));if(W&&we>=W)return ht=ht.slice(0,W),Cn(!0)}}return Cn()}for(var be=ne.indexOf(v,se),Ae=ne.indexOf(T,se),Ke=new RegExp(w(Y)+w(G),"g"),Ee=ne.indexOf(G,se);;){if(ne[se]===G){for(Ee=se,se++;;){if(Ee=ne.indexOf(G,Ee+1),Ee===-1)return Le||Ct.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:ht.length,index:se}),Ti();if(Ee===ye-1){var Nt=ne.substring(se,Ee).replace(Ke,G);return Ti(Nt)}if(G===Y&&ne[Ee+1]===Y){Ee++;continue}if(!(G!==Y&&Ee!==0&&ne[Ee-1]===Y)){be!==-1&&be<Ee+1&&(be=ne.indexOf(v,Ee+1)),Ae!==-1&&Ae<Ee+1&&(Ae=ne.indexOf(T,Ee+1));var hn=Ae===-1?be:Math.min(be,Ae),Kt=Ia(hn);if(ne.substr(Ee+1+Kt,ve)===v){et.push(ne.substring(se,Ee).replace(Ke,G)),se=Ee+1+Kt+ve,ne[Ee+1+Kt+ve]!==G&&(Ee=ne.indexOf(G,se)),be=ne.indexOf(v,se),Ae=ne.indexOf(T,se);break}var Ni=Ia(Ae);if(ne.substring(Ee+1+Ni,Ee+1+Ni+$e)===T){if(et.push(ne.substring(se,Ee).replace(Ke,G)),js(Ee+1+Ni+$e),be=ne.indexOf(v,se),Ee=ne.indexOf(G,se),Je&&(ss(),oe))return Cn();if(W&&ht.length>=W)return Cn(!0);break}Ct.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:ht.length,index:se}),Ee++}}continue}if(_&&et.length===0&&ne.substring(se,se+Pe)===_){if(Ae===-1)return Cn();se=Ae+$e,Ae=ne.indexOf(T,se),be=ne.indexOf(v,se);continue}if(be!==-1&&(be<Ae||Ae===-1)){et.push(ne.substring(se,be)),se=be+ve,be=ne.indexOf(v,se);continue}if(Ae!==-1){if(et.push(ne.substring(se,Ae)),js(Ae+$e),Je&&(ss(),oe))return Cn();if(W&&ht.length>=W)return Cn(!0);continue}break}return Ti();function Ws(dn){ht.push(dn),br=se}function Ia(dn){var qn=0;if(dn!==-1){var qs=ne.substring(Ee+1,dn);qs&&qs.trim()===""&&(qn=qs.length)}return qn}function Ti(dn){return Le||(typeof dn>"u"&&(dn=ne.substring(se)),et.push(dn),se=ye,Ws(et),Je&&ss()),Cn()}function js(dn){se=dn,Ws(et),et=[],Ae=ne.indexOf(T,se)}function Cn(dn){if(S.header&&!z&&ht.length&&!q){let qn=ht[0],qs=Object.create(null),cd=new Set(qn),eb=!1;for(let go=0;go<qn.length;go++){let is=qn[go];if(k(S.transformHeader)&&(is=S.transformHeader(is,go)),!qs[is])qs[is]=1,qn[go]=is;else{let Pa,tb=qs[is];do Pa=`${is}_${tb}`,tb++;while(cd.has(Pa));cd.add(Pa),qn[go]=Pa,qs[is]++,eb=!0,j===null&&(j={}),j[Pa]=is}cd.add(is)}eb&&console.warn("Duplicate headers found and renamed."),q=!0}return{data:ht,errors:Ct,meta:{delimiter:v,linebreak:T,aborted:oe,truncated:!!dn,cursor:br+(z||0),renamedHeaders:j}}}function ss(){D(Cn()),ht=[],Ct=[]}},this.abort=function(){oe=!0},this.getCharIndex=function(){return se}}function E(){if(!a.WORKERS_SUPPORTED)return!1;var S=n(),v=new e.Worker(S);return v.onmessage=A,v.id=o++,i[v.id]=v,v}function A(S){var v=S.data,T=i[v.workerId],_=!1;if(v.error)T.userError(v.error,v.file);else if(v.results&&v.results.data){var D=function(){_=!0,C(v.workerId,{data:[],errors:[],meta:{aborted:!0}})},W={abort:D,pause:P,resume:P};if(k(T.userStep)){for(var H=0;H<v.results.data.length&&(T.userStep({data:v.results.data[H],errors:v.results.errors,meta:v.results.meta},W),!_);H++);delete v.results}else k(T.userChunk)&&(T.userChunk(v.results,W,v.file),delete v.results)}v.finished&&!_&&C(v.workerId,v.results)}function C(S,v){var T=i[S];k(T.userComplete)&&T.userComplete(v),T.terminate(),delete i[S]}function P(){throw new Error("Not implemented.")}function $(S){var v=S.data;if(typeof a.WORKER_ID>"u"&&v&&(a.WORKER_ID=v.workerId),typeof v.input=="string")e.postMessage({workerId:a.WORKER_ID,results:a.parse(v.input,v.config),finished:!0});else if(e.File&&v.input instanceof File||v.input instanceof Object){var T=a.parse(v.input,v.config);T&&e.postMessage({workerId:a.WORKER_ID,results:T,finished:!0})}}function O(S){if(typeof S!="object"||S===null)return S;var v=Array.isArray(S)?[]:{};for(var T in S)v[T]=O(S[T]);return v}function R(S,v){return function(){S.apply(v,arguments)}}function k(S){return typeof S=="function"}return a})});function aM(t,e){let n=t.slice(0,e).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function lM(t,e,n){let r=t.split(/\r\n|\n|\r/g),s="",i=(Math.log10(e+1)|0)+1;for(let o=e-1;o<=e+1;o++){let a=r[o-1];a&&(s+=o.toString().padEnd(i," "),s+=": ",s+=a,s+=`
784
784
  `,o===e&&(s+=" ".repeat(i+n+2),s+=`^
785
785
  `))}return s}var We,Hi=I(()=>{We=class extends Error{line;column;codeblock;constructor(e,n){let[r,s]=aM(n.toml,n.ptr),i=lM(n.toml,r,s);super(`Invalid TOML document: ${e}
786
786
 
@@ -810,8 +810,8 @@ ${i}`,n),this.line=r,this.column=s,this.codeblock=i}}});function cM(t,e){let n=0
810
810
  ${i}`:`[${t}]`),i&&o?`${i}
811
811
  ${o}`:i||o}function pg(t,{maxDepth:e=1e3,numbersAsFloat:n=!1}={}){if(pl(t)!=="object")throw new TypeError("stringify can only be called with an object");let r=dg(0,t,"",e,n);return r[r.length-1]!==`
812
812
  `?r+`
813
- `:r}var Xx,Jx=I(()=>{Xx=/^[a-z0-9-_]+$/i});var e9=I(()=>{Qx();Jx();ag();Hi();});var nt=re(bn=>{"use strict";var mg=Symbol.for("yaml.alias"),t9=Symbol.for("yaml.document"),Ju=Symbol.for("yaml.map"),n9=Symbol.for("yaml.pair"),gg=Symbol.for("yaml.scalar"),ef=Symbol.for("yaml.seq"),Ds=Symbol.for("yaml.node.type"),SM=t=>!!t&&typeof t=="object"&&t[Ds]===mg,AM=t=>!!t&&typeof t=="object"&&t[Ds]===t9,vM=t=>!!t&&typeof t=="object"&&t[Ds]===Ju,CM=t=>!!t&&typeof t=="object"&&t[Ds]===n9,r9=t=>!!t&&typeof t=="object"&&t[Ds]===gg,kM=t=>!!t&&typeof t=="object"&&t[Ds]===ef;function s9(t){if(t&&typeof t=="object")switch(t[Ds]){case Ju:case ef:return!0}return!1}function NM(t){if(t&&typeof t=="object")switch(t[Ds]){case mg:case Ju:case gg:case ef:return!0}return!1}var TM=t=>(r9(t)||s9(t))&&!!t.anchor;bn.ALIAS=mg;bn.DOC=t9;bn.MAP=Ju;bn.NODE_TYPE=Ds;bn.PAIR=n9;bn.SCALAR=gg;bn.SEQ=ef;bn.hasAnchor=TM;bn.isAlias=SM;bn.isCollection=s9;bn.isDocument=AM;bn.isMap=vM;bn.isNode=NM;bn.isPair=CM;bn.isScalar=r9;bn.isSeq=kM});var ml=re(yg=>{"use strict";var tn=nt(),Jn=Symbol("break visit"),i9=Symbol("skip children"),ys=Symbol("remove node");function tf(t,e){let n=o9(e);tn.isDocument(t)?Zo(null,t.contents,n,Object.freeze([t]))===ys&&(t.contents=null):Zo(null,t,n,Object.freeze([]))}tf.BREAK=Jn;tf.SKIP=i9;tf.REMOVE=ys;function Zo(t,e,n,r){let s=a9(t,e,n,r);if(tn.isNode(s)||tn.isPair(s))return l9(t,r,s),Zo(t,s,n,r);if(typeof s!="symbol"){if(tn.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Zo(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Jn)return Jn;o===ys&&(e.items.splice(i,1),i-=1)}}}else if(tn.isPair(e)){r=Object.freeze(r.concat(e));let i=Zo("key",e.key,n,r);if(i===Jn)return Jn;i===ys&&(e.key=null);let o=Zo("value",e.value,n,r);if(o===Jn)return Jn;o===ys&&(e.value=null)}}return s}async function nf(t,e){let n=o9(e);tn.isDocument(t)?await Yo(null,t.contents,n,Object.freeze([t]))===ys&&(t.contents=null):await Yo(null,t,n,Object.freeze([]))}nf.BREAK=Jn;nf.SKIP=i9;nf.REMOVE=ys;async function Yo(t,e,n,r){let s=await a9(t,e,n,r);if(tn.isNode(s)||tn.isPair(s))return l9(t,r,s),Yo(t,s,n,r);if(typeof s!="symbol"){if(tn.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Yo(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Jn)return Jn;o===ys&&(e.items.splice(i,1),i-=1)}}}else if(tn.isPair(e)){r=Object.freeze(r.concat(e));let i=await Yo("key",e.key,n,r);if(i===Jn)return Jn;i===ys&&(e.key=null);let o=await Yo("value",e.value,n,r);if(o===Jn)return Jn;o===ys&&(e.value=null)}}return s}function o9(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function a9(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(tn.isMap(e))return n.Map?.(t,e,r);if(tn.isSeq(e))return n.Seq?.(t,e,r);if(tn.isPair(e))return n.Pair?.(t,e,r);if(tn.isScalar(e))return n.Scalar?.(t,e,r);if(tn.isAlias(e))return n.Alias?.(t,e,r)}function l9(t,e,n){let r=e[e.length-1];if(tn.isCollection(r))r.items[t]=n;else if(tn.isPair(r))t==="key"?r.key=n:r.value=n;else if(tn.isDocument(r))r.contents=n;else{let s=tn.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}yg.visit=tf;yg.visitAsync=nf});var wg=re(u9=>{"use strict";var c9=nt(),OM=ml(),IM={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},PM=t=>t.replace(/[!,[\]{}]/g,e=>IM[e]),gl=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||n(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+PM(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&c9.isNode(e.contents)){let i={};OM.visit(e.contents,(o,a)=>{c9.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&n.push(`%TAG ${i} ${o}`);return n.join(`
814
- `)}};gl.defaultYaml={explicit:!1,version:"1.2"};gl.defaultTags={"!!":"tag:yaml.org,2002:"};u9.Directives=gl});var rf=re(yl=>{"use strict";var f9=nt(),RM=ml();function $M(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function h9(t){let e=new Set;return RM.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function d9(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function FM(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=h9(t));let o=d9(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(f9.isScalar(o.node)||f9.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}yl.anchorIsValid=$M;yl.anchorNames=h9;yl.createNodeAnchors=FM;yl.findNewAnchor=d9});var bg=re(p9=>{"use strict";function wl(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=wl(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=wl(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=wl(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=wl(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}p9.applyReviver=wl});var ni=re(g9=>{"use strict";var _M=nt();function m9(t,e,n){if(Array.isArray(t))return t.map((r,s)=>m9(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!_M.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}g9.toJS=m9});var sf=re(w9=>{"use strict";var DM=bg(),y9=nt(),LM=ni(),Eg=class{constructor(e){Object.defineProperty(this,y9.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!y9.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=LM.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?DM.applyReviver(i,{"":a},"",a):a}};w9.NodeBase=Eg});var bl=re(b9=>{"use strict";var MM=rf(),BM=ml(),Qo=nt(),UM=sf(),zM=ni(),xg=class extends UM.NodeBase{constructor(e){super(Qo.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],BM.visit(e,{Node:(i,o)=>{(Qo.isAlias(o)||Qo.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||(zM.toJS(o,null,n),a=r.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=of(s,o,r)),a.count*a.aliasCount>i)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,n,r){let s=`*${this.source}`;if(e){if(MM.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function of(t,e,n){if(Qo.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(Qo.isCollection(e)){let r=0;for(let s of e.items){let i=of(t,s,n);i>r&&(r=i)}return r}else if(Qo.isPair(e)){let r=of(t,e.key,n),s=of(t,e.value,n);return Math.max(r,s)}return 1}b9.Alias=xg});var Yt=re(Sg=>{"use strict";var WM=nt(),jM=sf(),qM=ni(),HM=t=>!t||typeof t!="function"&&typeof t!="object",ri=class extends jM.NodeBase{constructor(e){super(WM.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:qM.toJS(this.value,e,n)}toString(){return String(this.value)}};ri.BLOCK_FOLDED="BLOCK_FOLDED";ri.BLOCK_LITERAL="BLOCK_LITERAL";ri.PLAIN="PLAIN";ri.QUOTE_DOUBLE="QUOTE_DOUBLE";ri.QUOTE_SINGLE="QUOTE_SINGLE";Sg.Scalar=ri;Sg.isScalarValue=HM});var El=re(x9=>{"use strict";var VM=bl(),Vi=nt(),E9=Yt(),GM="tag:yaml.org,2002:";function KM(t,e,n){if(e){let r=n.filter(i=>i.tag===e),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>r.identify?.(t)&&!r.format)}function ZM(t,e,n){if(Vi.isDocument(t)&&(t=t.contents),Vi.isNode(t))return t;if(Vi.isPair(t)){let f=n.schema[Vi.MAP].createNode?.(n.schema,null,n);return f.items.push(t),f}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=n,l;if(r&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=s(t)),new VM.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=GM+e.slice(2));let c=KM(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new E9.Scalar(t);return l&&(l.node=f),f}c=t instanceof Map?o[Vi.MAP]:Symbol.iterator in Object(t)?o[Vi.SEQ]:o[Vi.MAP]}i&&(i(c),delete n.onTagObj);let u=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new E9.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}x9.createNode=ZM});var lf=re(af=>{"use strict";var YM=El(),ws=nt(),QM=sf();function Ag(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return YM.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var S9=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,vg=class extends QM.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>ws.isNode(r)||ws.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(S9(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(ws.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,Ag(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(ws.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!n&&ws.isScalar(i)?i.value:i:ws.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!ws.isPair(n))return!1;let r=n.value;return r==null||e&&ws.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let s=this.get(n,!0);return ws.isCollection(s)?s.hasIn(r):!1}setIn(e,n){let[r,...s]=e;if(s.length===0)this.set(r,n);else{let i=this.get(r,!0);if(ws.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,Ag(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};af.Collection=vg;af.collectionFromPath=Ag;af.isEmptyPath=S9});var xl=re(cf=>{"use strict";var XM=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Cg(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var JM=(t,e,n)=>t.endsWith(`
813
+ `:r}var Xx,Jx=I(()=>{Xx=/^[a-z0-9-_]+$/i});var e9=I(()=>{Qx();Jx();ag();Hi();});var nt=re(bn=>{"use strict";var mg=Symbol.for("yaml.alias"),t9=Symbol.for("yaml.document"),Ju=Symbol.for("yaml.map"),n9=Symbol.for("yaml.pair"),gg=Symbol.for("yaml.scalar"),ef=Symbol.for("yaml.seq"),Ds=Symbol.for("yaml.node.type"),SM=t=>!!t&&typeof t=="object"&&t[Ds]===mg,AM=t=>!!t&&typeof t=="object"&&t[Ds]===t9,vM=t=>!!t&&typeof t=="object"&&t[Ds]===Ju,CM=t=>!!t&&typeof t=="object"&&t[Ds]===n9,r9=t=>!!t&&typeof t=="object"&&t[Ds]===gg,kM=t=>!!t&&typeof t=="object"&&t[Ds]===ef;function s9(t){if(t&&typeof t=="object")switch(t[Ds]){case Ju:case ef:return!0}return!1}function NM(t){if(t&&typeof t=="object")switch(t[Ds]){case mg:case Ju:case gg:case ef:return!0}return!1}var TM=t=>(r9(t)||s9(t))&&!!t.anchor;bn.ALIAS=mg;bn.DOC=t9;bn.MAP=Ju;bn.NODE_TYPE=Ds;bn.PAIR=n9;bn.SCALAR=gg;bn.SEQ=ef;bn.hasAnchor=TM;bn.isAlias=SM;bn.isCollection=s9;bn.isDocument=AM;bn.isMap=vM;bn.isNode=NM;bn.isPair=CM;bn.isScalar=r9;bn.isSeq=kM});var ml=re(yg=>{"use strict";var tn=nt(),Jn=Symbol("break visit"),i9=Symbol("skip children"),ws=Symbol("remove node");function tf(t,e){let n=o9(e);tn.isDocument(t)?Zo(null,t.contents,n,Object.freeze([t]))===ws&&(t.contents=null):Zo(null,t,n,Object.freeze([]))}tf.BREAK=Jn;tf.SKIP=i9;tf.REMOVE=ws;function Zo(t,e,n,r){let s=a9(t,e,n,r);if(tn.isNode(s)||tn.isPair(s))return l9(t,r,s),Zo(t,s,n,r);if(typeof s!="symbol"){if(tn.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Zo(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Jn)return Jn;o===ws&&(e.items.splice(i,1),i-=1)}}}else if(tn.isPair(e)){r=Object.freeze(r.concat(e));let i=Zo("key",e.key,n,r);if(i===Jn)return Jn;i===ws&&(e.key=null);let o=Zo("value",e.value,n,r);if(o===Jn)return Jn;o===ws&&(e.value=null)}}return s}async function nf(t,e){let n=o9(e);tn.isDocument(t)?await Yo(null,t.contents,n,Object.freeze([t]))===ws&&(t.contents=null):await Yo(null,t,n,Object.freeze([]))}nf.BREAK=Jn;nf.SKIP=i9;nf.REMOVE=ws;async function Yo(t,e,n,r){let s=await a9(t,e,n,r);if(tn.isNode(s)||tn.isPair(s))return l9(t,r,s),Yo(t,s,n,r);if(typeof s!="symbol"){if(tn.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Yo(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===Jn)return Jn;o===ws&&(e.items.splice(i,1),i-=1)}}}else if(tn.isPair(e)){r=Object.freeze(r.concat(e));let i=await Yo("key",e.key,n,r);if(i===Jn)return Jn;i===ws&&(e.key=null);let o=await Yo("value",e.value,n,r);if(o===Jn)return Jn;o===ws&&(e.value=null)}}return s}function o9(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function a9(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(tn.isMap(e))return n.Map?.(t,e,r);if(tn.isSeq(e))return n.Seq?.(t,e,r);if(tn.isPair(e))return n.Pair?.(t,e,r);if(tn.isScalar(e))return n.Scalar?.(t,e,r);if(tn.isAlias(e))return n.Alias?.(t,e,r)}function l9(t,e,n){let r=e[e.length-1];if(tn.isCollection(r))r.items[t]=n;else if(tn.isPair(r))t==="key"?r.key=n:r.value=n;else if(tn.isDocument(r))r.contents=n;else{let s=tn.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}yg.visit=tf;yg.visitAsync=nf});var wg=re(u9=>{"use strict";var c9=nt(),OM=ml(),IM={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},PM=t=>t.replace(/[!,[\]{}]/g,e=>IM[e]),gl=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||n(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+PM(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&c9.isNode(e.contents)){let i={};OM.visit(e.contents,(o,a)=>{c9.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&n.push(`%TAG ${i} ${o}`);return n.join(`
814
+ `)}};gl.defaultYaml={explicit:!1,version:"1.2"};gl.defaultTags={"!!":"tag:yaml.org,2002:"};u9.Directives=gl});var rf=re(yl=>{"use strict";var f9=nt(),RM=ml();function $M(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function h9(t){let e=new Set;return RM.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function d9(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function FM(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=h9(t));let o=d9(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(f9.isScalar(o.node)||f9.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}yl.anchorIsValid=$M;yl.anchorNames=h9;yl.createNodeAnchors=FM;yl.findNewAnchor=d9});var bg=re(p9=>{"use strict";function wl(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=wl(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=wl(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=wl(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=wl(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}p9.applyReviver=wl});var ni=re(g9=>{"use strict";var _M=nt();function m9(t,e,n){if(Array.isArray(t))return t.map((r,s)=>m9(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!_M.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}g9.toJS=m9});var sf=re(w9=>{"use strict";var DM=bg(),y9=nt(),LM=ni(),Eg=class{constructor(e){Object.defineProperty(this,y9.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!y9.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=LM.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?DM.applyReviver(i,{"":a},"",a):a}};w9.NodeBase=Eg});var bl=re(b9=>{"use strict";var MM=rf(),BM=ml(),Qo=nt(),UM=sf(),zM=ni(),xg=class extends UM.NodeBase{constructor(e){super(Qo.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],BM.visit(e,{Node:(i,o)=>{(Qo.isAlias(o)||Qo.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||(zM.toJS(o,null,n),a=r.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=of(s,o,r)),a.count*a.aliasCount>i)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,n,r){let s=`*${this.source}`;if(e){if(MM.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function of(t,e,n){if(Qo.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(Qo.isCollection(e)){let r=0;for(let s of e.items){let i=of(t,s,n);i>r&&(r=i)}return r}else if(Qo.isPair(e)){let r=of(t,e.key,n),s=of(t,e.value,n);return Math.max(r,s)}return 1}b9.Alias=xg});var Yt=re(Sg=>{"use strict";var WM=nt(),jM=sf(),qM=ni(),HM=t=>!t||typeof t!="function"&&typeof t!="object",ri=class extends jM.NodeBase{constructor(e){super(WM.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:qM.toJS(this.value,e,n)}toString(){return String(this.value)}};ri.BLOCK_FOLDED="BLOCK_FOLDED";ri.BLOCK_LITERAL="BLOCK_LITERAL";ri.PLAIN="PLAIN";ri.QUOTE_DOUBLE="QUOTE_DOUBLE";ri.QUOTE_SINGLE="QUOTE_SINGLE";Sg.Scalar=ri;Sg.isScalarValue=HM});var El=re(x9=>{"use strict";var VM=bl(),Vi=nt(),E9=Yt(),GM="tag:yaml.org,2002:";function KM(t,e,n){if(e){let r=n.filter(i=>i.tag===e),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>r.identify?.(t)&&!r.format)}function ZM(t,e,n){if(Vi.isDocument(t)&&(t=t.contents),Vi.isNode(t))return t;if(Vi.isPair(t)){let f=n.schema[Vi.MAP].createNode?.(n.schema,null,n);return f.items.push(t),f}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=n,l;if(r&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=s(t)),new VM.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=GM+e.slice(2));let c=KM(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new E9.Scalar(t);return l&&(l.node=f),f}c=t instanceof Map?o[Vi.MAP]:Symbol.iterator in Object(t)?o[Vi.SEQ]:o[Vi.MAP]}i&&(i(c),delete n.onTagObj);let u=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new E9.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}x9.createNode=ZM});var lf=re(af=>{"use strict";var YM=El(),bs=nt(),QM=sf();function Ag(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return YM.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var S9=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,vg=class extends QM.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>bs.isNode(r)||bs.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(S9(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(bs.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,Ag(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(bs.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!n&&bs.isScalar(i)?i.value:i:bs.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!bs.isPair(n))return!1;let r=n.value;return r==null||e&&bs.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let s=this.get(n,!0);return bs.isCollection(s)?s.hasIn(r):!1}setIn(e,n){let[r,...s]=e;if(s.length===0)this.set(r,n);else{let i=this.get(r,!0);if(bs.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,Ag(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};af.Collection=vg;af.collectionFromPath=Ag;af.isEmptyPath=S9});var xl=re(cf=>{"use strict";var XM=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Cg(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var JM=(t,e,n)=>t.endsWith(`
815
815
  `)?Cg(n,e):n.includes(`
816
816
  `)?`
817
817
  `+Cg(n,e):(t.endsWith(" ")?"":" ")+n;cf.indentComment=Cg;cf.lineComment=JM;cf.stringifyComment=XM});var v9=re(Sl=>{"use strict";var eB="flow",kg="block",uf="quoted";function tB(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],u={},f=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):f=s-r);let h,d,p=!1,m=-1,g=-1,y=-1;n===kg&&(m=A9(t,m,e.length),m!==-1&&(f=m+l));for(let b;b=t[m+=1];){if(n===uf&&b==="\\"){switch(g=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if(b===`
@@ -1188,7 +1188,7 @@ Run 'xan --help' for usage.
1188
1188
  `,exitCode:1};e.nullValue=t[++o]}else if(a==="-cmd"){if(o+1>=t.length)return{stdout:"",stderr:`sqlite3: Error: missing argument to -cmd
1189
1189
  `,exitCode:1};e.cmd=t[++o]}else{if(a.startsWith("-"))return{stdout:"",stderr:`sqlite3: Error: unknown option: ${a.startsWith("--")?a.slice(1):a}
1190
1190
  Use -help for a list of options.
1191
- `,exitCode:1};n===null?n=a:r===null&&(r=a)}}return{options:e,database:n,sql:r,showVersion:s}}async function Oj(){let t=await tt.runTrustedAsync(()=>(0,k5.default)()),e=new t.Database;try{let n=e.exec("SELECT sqlite_version()");return n.length>0&&n[0].values.length>0?String(n[0].values[0][0]):"unknown"}finally{e.close()}}function N5(t=(0,bs.dirname)((0,v5.fileURLToPath)(Fj.url))){let e=[(0,bs.join)(t,"sqlite3-worker.js"),(0,bs.join)(t,"../../commands/sqlite3/worker.js")];(t.endsWith(`${bs.sep}commands${bs.sep}sqlite3`)||t.endsWith("/commands/sqlite3"))&&e.push((0,bs.join)(t,"worker.js")),e.push((0,bs.join)(t,"../../../dist/commands/sqlite3/worker.js"));for(let n of e)if((0,A5.existsSync)(n))return n;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}function Ij(){return(0,S5.randomBytes)(16).toString("hex")}function Pj(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let n=t;return typeof n.protocolToken!="string"||n.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:n.type==="security-violation"?{success:!1,error:`Security violation: ${typeof n.violation?.type=="string"?n.violation.type:"unknown"}`}:typeof n.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:n.success?Array.isArray(n.results)?typeof n.hasModifications!="boolean"?{success:!1,error:"Malformed worker response: missing hasModifications flag"}:n.dbBuffer!==null&&n.dbBuffer!==void 0&&!(n.dbBuffer instanceof Uint8Array)?{success:!1,error:"Malformed worker response: invalid dbBuffer"}:{success:!0,results:n.results,hasModifications:n.hasModifications,dbBuffer:n.dbBuffer===void 0?null:n.dbBuffer,defenseStats:n.defenseStats}:{success:!1,error:"Malformed worker response: missing results array"}:{success:!1,error:typeof n.error=="string"&&n.error.length>0?n.error:"Worker execution failed"}}async function Rj(t,e,n){try{let r=N5();return await new Promise((s,i)=>{let o=tt.runTrusted(()=>T5.createWorker(r,t)),a=hs(n,"sqlite3","worker timeout callback",()=>{o.terminate(),s({success:!1,error:`Query timeout: execution exceeded ${e}ms limit`})}),c=sn(()=>{try{a()}catch(g){let y=g instanceof Error?g.message:String(g);s({success:!1,error:$t(y)})}},e),u=hs(n,"sqlite3","worker message callback",g=>{Dt(c),s(Pj(g,t.protocolToken))}),f=hs(n,"sqlite3","worker error callback",g=>{Dt(c),i(g)}),h=hs(n,"sqlite3","worker exit callback",g=>{Dt(c),g!==0&&s({success:!1,error:`Worker exited with code ${g}`})}),d=g=>{try{u(g)}catch(y){Dt(c);let w=y instanceof Error?y.message:String(y);s({success:!1,error:$t(w)})}},p=g=>{try{f(g)}catch(y){Dt(c);let w=y instanceof Error?y.message:String(y);i(new Error($t(w)))}},m=g=>{try{h(g)}catch(y){Dt(c);let w=y instanceof Error?y.message:String(y);s({success:!1,error:$t(w)})}};o.on("message",d),o.on("error",p),o.on("exit",m)})}catch(r){let s=$t(r.message);throw new Error(`sqlite3 worker failed to load: ${s}`)}}var S5,A5,bs,v5,C5,k5,Fj,kj,Nj,T5,$j,Z2,Y2=I(()=>{"use strict";S5=require("node:crypto"),A5=require("node:fs"),bs=require("node:path"),v5=require("node:url"),C5=require("node:worker_threads"),k5=Jt(require("sql.js"),1);pe();mn();lr();en();is();ue();x5();Fj={},kj=5e3,Nj={name:"sqlite3",summary:"SQLite database CLI",usage:"sqlite3 [OPTIONS] DATABASE [SQL]",options:["-list output in list mode (default)","-csv output in CSV mode","-json output in JSON mode","-line output in line mode","-column output in column mode","-table output as ASCII table","-markdown output as markdown table","-tabs output in tab-separated mode","-box output in Unicode box mode","-quote output in SQL quote mode","-html output as HTML table","-ascii output in ASCII mode (control chars)","-header show column headers","-noheader hide column headers","-separator SEP field separator for list mode (default: |)","-newline SEP row separator (default: \\n)","-nullvalue TEXT text for NULL values (default: empty)","-readonly open database read-only (no writeback)","-bail stop on first error","-echo print SQL before execution","-cmd COMMAND run SQL command before main SQL","-version show SQLite version","-- end of options","--help show this help"],examples:['sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"','sqlite3 -json data.db "SELECT * FROM users"','sqlite3 -csv -header data.db "SELECT id, name FROM products"','sqlite3 -box data.db "SELECT * FROM users"']};T5={createWorker(t,e){return new C5.Worker(t,{workerData:e})},findWorkerPath:N5};$j={name:"sqlite3",async execute(t,e){if(U(t)||t.includes("-help"))return B(Nj);let n=Tj(t);if("exitCode"in n)return n;let{options:r,database:s,sql:i,showVersion:o}=n;if(o)return{stdout:`${await Oj()}
1191
+ `,exitCode:1};n===null?n=a:r===null&&(r=a)}}return{options:e,database:n,sql:r,showVersion:s}}async function Oj(){let t=await tt.runTrustedAsync(()=>(0,k5.default)()),e=new t.Database;try{let n=e.exec("SELECT sqlite_version()");return n.length>0&&n[0].values.length>0?String(n[0].values[0][0]):"unknown"}finally{e.close()}}function N5(t=(0,Es.dirname)((0,v5.fileURLToPath)(Fj.url))){let e=[(0,Es.join)(t,"sqlite3-worker.js"),(0,Es.join)(t,"../../commands/sqlite3/worker.js")];(t.endsWith(`${Es.sep}commands${Es.sep}sqlite3`)||t.endsWith("/commands/sqlite3"))&&e.push((0,Es.join)(t,"worker.js")),e.push((0,Es.join)(t,"../../../dist/commands/sqlite3/worker.js"));for(let n of e)if((0,A5.existsSync)(n))return n;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}function Ij(){return(0,S5.randomBytes)(16).toString("hex")}function Pj(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let n=t;return typeof n.protocolToken!="string"||n.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:n.type==="security-violation"?{success:!1,error:`Security violation: ${typeof n.violation?.type=="string"?n.violation.type:"unknown"}`}:typeof n.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:n.success?Array.isArray(n.results)?typeof n.hasModifications!="boolean"?{success:!1,error:"Malformed worker response: missing hasModifications flag"}:n.dbBuffer!==null&&n.dbBuffer!==void 0&&!(n.dbBuffer instanceof Uint8Array)?{success:!1,error:"Malformed worker response: invalid dbBuffer"}:{success:!0,results:n.results,hasModifications:n.hasModifications,dbBuffer:n.dbBuffer===void 0?null:n.dbBuffer,defenseStats:n.defenseStats}:{success:!1,error:"Malformed worker response: missing results array"}:{success:!1,error:typeof n.error=="string"&&n.error.length>0?n.error:"Worker execution failed"}}async function Rj(t,e,n){try{let r=N5();return await new Promise((s,i)=>{let o=tt.runTrusted(()=>T5.createWorker(r,t)),a=ds(n,"sqlite3","worker timeout callback",()=>{o.terminate(),s({success:!1,error:`Query timeout: execution exceeded ${e}ms limit`})}),c=sn(()=>{try{a()}catch(g){let y=g instanceof Error?g.message:String(g);s({success:!1,error:$t(y)})}},e),u=ds(n,"sqlite3","worker message callback",g=>{Dt(c),s(Pj(g,t.protocolToken))}),f=ds(n,"sqlite3","worker error callback",g=>{Dt(c),i(g)}),h=ds(n,"sqlite3","worker exit callback",g=>{Dt(c),g!==0&&s({success:!1,error:`Worker exited with code ${g}`})}),d=g=>{try{u(g)}catch(y){Dt(c);let w=y instanceof Error?y.message:String(y);s({success:!1,error:$t(w)})}},p=g=>{try{f(g)}catch(y){Dt(c);let w=y instanceof Error?y.message:String(y);i(new Error($t(w)))}},m=g=>{try{h(g)}catch(y){Dt(c);let w=y instanceof Error?y.message:String(y);s({success:!1,error:$t(w)})}};o.on("message",d),o.on("error",p),o.on("exit",m)})}catch(r){let s=$t(r.message);throw new Error(`sqlite3 worker failed to load: ${s}`)}}var S5,A5,Es,v5,C5,k5,Fj,kj,Nj,T5,$j,Z2,Y2=I(()=>{"use strict";S5=require("node:crypto"),A5=require("node:fs"),Es=require("node:path"),v5=require("node:url"),C5=require("node:worker_threads"),k5=Jt(require("sql.js"),1);pe();mn();lr();en();os();ue();x5();Fj={},kj=5e3,Nj={name:"sqlite3",summary:"SQLite database CLI",usage:"sqlite3 [OPTIONS] DATABASE [SQL]",options:["-list output in list mode (default)","-csv output in CSV mode","-json output in JSON mode","-line output in line mode","-column output in column mode","-table output as ASCII table","-markdown output as markdown table","-tabs output in tab-separated mode","-box output in Unicode box mode","-quote output in SQL quote mode","-html output as HTML table","-ascii output in ASCII mode (control chars)","-header show column headers","-noheader hide column headers","-separator SEP field separator for list mode (default: |)","-newline SEP row separator (default: \\n)","-nullvalue TEXT text for NULL values (default: empty)","-readonly open database read-only (no writeback)","-bail stop on first error","-echo print SQL before execution","-cmd COMMAND run SQL command before main SQL","-version show SQLite version","-- end of options","--help show this help"],examples:['sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"','sqlite3 -json data.db "SELECT * FROM users"','sqlite3 -csv -header data.db "SELECT id, name FROM products"','sqlite3 -box data.db "SELECT * FROM users"']};T5={createWorker(t,e){return new C5.Worker(t,{workerData:e})},findWorkerPath:N5};$j={name:"sqlite3",async execute(t,e){if(U(t)||t.includes("-help"))return B(Nj);let n=Tj(t);if("exitCode"in n)return n;let{options:r,database:s,sql:i,showVersion:o}=n;if(o)return{stdout:`${await Oj()}
1192
1192
  `,stderr:"",exitCode:0};if(!s)return{stdout:"",stderr:`sqlite3: missing database argument
1193
1193
  `,exitCode:1};let a=i||te(e.stdin).trim();if(r.cmd&&(a=r.cmd+(a?`; ${a}`:"")),!a)return{stdout:"",stderr:`sqlite3: no SQL provided
1194
1194
  `,exitCode:1};let l=s===":memory:",c="",u=null;try{l||(c=e.fs.resolvePath(e.cwd,s),await e.fs.exists(c)&&(u=await e.fs.readFileBuffer(c)))}catch(y){let w=Fe(y.message);return{stdout:"",stderr:`sqlite3: unable to open database "${s}": ${w}
@@ -1198,7 +1198,7 @@ Use -help for a list of options.
1198
1198
  `);let g=!1;for(let y of d.results)if(y.type==="error"){if(r.bail)return{stdout:m,stderr:`Error: ${y.error}
1199
1199
  `,exitCode:1};m+=`Error: ${y.error}
1200
1200
  `,g=!0}else y.columns&&y.rows&&(y.rows.length>0||r.header)&&(m+=b5(y.columns,y.rows,p));if(d.hasModifications&&!r.readonly&&!l&&c&&d.dbBuffer)try{await e.fs.writeFile(c,d.dbBuffer)}catch(y){let w=Fe(y.message);return{stdout:m,stderr:`sqlite3: failed to write database: ${w}
1201
- `,exitCode:1}}return{stdout:m,stderr:"",exitCode:g&&r.bail?1:0}}},Z2={name:"sqlite3",flags:[],needsArgs:!0}});function Ms(t,e){if(t instanceof Uint8Array)return t;if(e==="base64")return Uint8Array.from(atob(t),n=>n.charCodeAt(0));if(e==="hex"){let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}if(e==="binary"||e==="latin1"){if(t.length<=65536)return Uint8Array.from(t,s=>s.charCodeAt(0));let r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}return _j.encode(t)}function dr(t,e){if(e==="base64"){if(typeof Buffer<"u")return Buffer.from(t).toString("base64");let n=65536,r="";for(let s=0;s<t.length;s+=n){let i=t.subarray(s,s+n);r+=String.fromCharCode(...i)}return btoa(r)}if(e==="hex")return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");if(e==="binary"||e==="latin1"){if(typeof Buffer<"u")return Buffer.from(t).toString(e);let n=65536;if(t.length<=n)return String.fromCharCode(...t);let r="";for(let s=0;s<t.length;s+=n){let i=t.subarray(s,s+n);r+=String.fromCharCode(...i)}return r}return Dj.decode(t)}function Pr(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var _j,Dj,la=I(()=>{"use strict";_j=new TextEncoder,Dj=new TextDecoder});function rh(){return new e8(Xi.TOTAL)}var Mt,He,En,Be,Xi,Yl,pr,nh,sh=I(()=>{"use strict";Do();Mt={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,RENAME:14,COPY_FILE:15,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200,EXEC_COMMAND:300,INVOKE_TOOL:400},He={PENDING:0,READY:1,SUCCESS:2,ERROR:3},En={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,TIMEOUT:8,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10},Be={OP_CODE:0,STATUS:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,PATH_BUFFER:32,DATA_BUFFER:4128},Xi={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:8388608,TOTAL:8392736},Yl={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},pr={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};nh=class{int32View;uint8View;dataView;constructor(e){this.int32View=new Int32Array(e),this.uint8View=new Uint8Array(e),this.dataView=new DataView(e)}getOpCode(){return Wt.load(this.int32View,Be.OP_CODE/4)}setOpCode(e){Wt.store(this.int32View,Be.OP_CODE/4,e)}getStatus(){return Wt.load(this.int32View,Be.STATUS/4)}setStatus(e){Wt.store(this.int32View,Be.STATUS/4,e)}getPathLength(){return Wt.load(this.int32View,Be.PATH_LENGTH/4)}setPathLength(e){Wt.store(this.int32View,Be.PATH_LENGTH/4,e)}getDataLength(){return Wt.load(this.int32View,Be.DATA_LENGTH/4)}setDataLength(e){Wt.store(this.int32View,Be.DATA_LENGTH/4,e)}getResultLength(){return Wt.load(this.int32View,Be.RESULT_LENGTH/4)}setResultLength(e){Wt.store(this.int32View,Be.RESULT_LENGTH/4,e)}getErrorCode(){return Wt.load(this.int32View,Be.ERROR_CODE/4)}setErrorCode(e){Wt.store(this.int32View,Be.ERROR_CODE/4,e)}getFlags(){return Wt.load(this.int32View,Be.FLAGS/4)}setFlags(e){Wt.store(this.int32View,Be.FLAGS/4,e)}getMode(){return Wt.load(this.int32View,Be.MODE/4)}setMode(e){Wt.store(this.int32View,Be.MODE/4,e)}getPath(){let e=this.getPathLength(),n=this.uint8View.slice(Be.PATH_BUFFER,Be.PATH_BUFFER+e);return new TextDecoder().decode(n)}setPath(e){let n=new TextEncoder().encode(e);if(n.length>Xi.PATH_BUFFER)throw new Error(`Path too long: ${n.length} > ${Xi.PATH_BUFFER}`);this.uint8View.set(n,Be.PATH_BUFFER),this.setPathLength(n.length)}getData(){let e=this.getDataLength();return this.uint8View.slice(Be.DATA_BUFFER,Be.DATA_BUFFER+e)}setData(e){if(e.length>Xi.DATA_BUFFER)throw new Error(`Data too large: ${e.length} > ${Xi.DATA_BUFFER}`);this.uint8View.set(e,Be.DATA_BUFFER),this.setDataLength(e.length)}getDataAsString(){let e=this.getData();return new TextDecoder().decode(e)}setDataFromString(e){let n=new TextEncoder().encode(e);this.setData(n)}getResult(){let e=this.getResultLength();return this.uint8View.slice(Be.DATA_BUFFER,Be.DATA_BUFFER+e)}setResult(e){if(e.length>Xi.DATA_BUFFER)throw new Error(`Result too large: ${e.length} > ${Xi.DATA_BUFFER}`);this.uint8View.set(e,Be.DATA_BUFFER),this.setResultLength(e.length)}getResultAsString(){let e=this.getResult();return new TextDecoder().decode(e)}setResultFromString(e){let n=new TextEncoder().encode(e);this.setResult(n)}encodeStat(e){this.uint8View[Be.DATA_BUFFER+pr.IS_FILE]=e.isFile?1:0,this.uint8View[Be.DATA_BUFFER+pr.IS_DIRECTORY]=e.isDirectory?1:0,this.uint8View[Be.DATA_BUFFER+pr.IS_SYMLINK]=e.isSymbolicLink?1:0,this.dataView.setInt32(Be.DATA_BUFFER+pr.MODE,e.mode,!0);let n=Math.min(e.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(Be.DATA_BUFFER+pr.SIZE,n,!0),this.dataView.setFloat64(Be.DATA_BUFFER+pr.MTIME,e.mtime.getTime(),!0),this.setResultLength(pr.TOTAL)}decodeStat(){return{isFile:this.uint8View[Be.DATA_BUFFER+pr.IS_FILE]===1,isDirectory:this.uint8View[Be.DATA_BUFFER+pr.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[Be.DATA_BUFFER+pr.IS_SYMLINK]===1,mode:this.dataView.getInt32(Be.DATA_BUFFER+pr.MODE,!0),size:this.dataView.getFloat64(Be.DATA_BUFFER+pr.SIZE,!0),mtime:new Date(this.dataView.getFloat64(Be.DATA_BUFFER+pr.MTIME,!0))}}waitForReady(e){return Wt.wait(this.int32View,Be.STATUS/4,He.PENDING,e)}waitForReadyAsync(e){return Wt.waitAsync(this.int32View,Be.STATUS/4,He.PENDING,e)}async waitUntilReady(e){let n=Date.now();for(;;){let r=this.getStatus();if(r===He.READY)return!0;let s=Date.now()-n;if(s>=e)return!1;let i=e-s,o=Wt.waitAsync(this.int32View,Be.STATUS/4,r,i);if(o.async&&await o.value==="timed-out")return!1}}waitForResult(e){return Wt.wait(this.int32View,Be.STATUS/4,He.READY,e)}notify(){return Wt.notify(this.int32View,Be.STATUS/4)}reset(){this.setOpCode(Mt.NOOP),this.setStatus(He.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(En.NONE),this.setFlags(Yl.NONE),this.setMode(0)}}});var ca,Q2=I(()=>{"use strict";la();mn();Is();en();is();sh();ca=class{fs;cwd;commandName;secureFetch;maxOutputSize;exec;invokeTool;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;startTime=0;timeoutMs=0;constructor(e,n,r,s,i=void 0,o=0,a=void 0,l=void 0){this.fs=n,this.cwd=r,this.commandName=s,this.secureFetch=i,this.maxOutputSize=o,this.exec=a,this.invokeTool=l,this.protocol=new nh(e)}remainingMs(){return Math.max(0,this.timeoutMs-(Date.now()-this.startTime))}raceDeadline(e){let n=this.remainingMs();if(n<=0)return this.running=!1,this.output.exitCode=124,this.output.stderr+=`
1201
+ `,exitCode:1}}return{stdout:m,stderr:"",exitCode:g&&r.bail?1:0}}},Z2={name:"sqlite3",flags:[],needsArgs:!0}});function Ms(t,e){if(t instanceof Uint8Array)return t;if(e==="base64")return Uint8Array.from(atob(t),n=>n.charCodeAt(0));if(e==="hex"){let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}if(e==="binary"||e==="latin1"){if(t.length<=65536)return Uint8Array.from(t,s=>s.charCodeAt(0));let r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}return _j.encode(t)}function dr(t,e){if(e==="base64"){if(typeof Buffer<"u")return Buffer.from(t).toString("base64");let n=65536,r="";for(let s=0;s<t.length;s+=n){let i=t.subarray(s,s+n);r+=String.fromCharCode(...i)}return btoa(r)}if(e==="hex")return Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join("");if(e==="binary"||e==="latin1"){if(typeof Buffer<"u")return Buffer.from(t).toString(e);let n=65536;if(t.length<=n)return String.fromCharCode(...t);let r="";for(let s=0;s<t.length;s+=n){let i=t.subarray(s,s+n);r+=String.fromCharCode(...i)}return r}return Dj.decode(t)}function Pr(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var _j,Dj,la=I(()=>{"use strict";_j=new TextEncoder,Dj=new TextDecoder});function rh(){return new e8(Xi.TOTAL)}var Mt,Ve,En,Be,Xi,Yl,pr,nh,sh=I(()=>{"use strict";Do();Mt={NOOP:0,READ_FILE:1,WRITE_FILE:2,STAT:3,READDIR:4,MKDIR:5,RM:6,EXISTS:7,APPEND_FILE:8,SYMLINK:9,READLINK:10,LSTAT:11,CHMOD:12,REALPATH:13,RENAME:14,COPY_FILE:15,WRITE_STDOUT:100,WRITE_STDERR:101,EXIT:102,HTTP_REQUEST:200,EXEC_COMMAND:300,INVOKE_TOOL:400},Ve={PENDING:0,READY:1,SUCCESS:2,ERROR:3},En={NONE:0,NOT_FOUND:1,IS_DIRECTORY:2,NOT_DIRECTORY:3,EXISTS:4,PERMISSION_DENIED:5,INVALID_PATH:6,IO_ERROR:7,TIMEOUT:8,NETWORK_ERROR:9,NETWORK_NOT_CONFIGURED:10},Be={OP_CODE:0,STATUS:4,PATH_LENGTH:8,DATA_LENGTH:12,RESULT_LENGTH:16,ERROR_CODE:20,FLAGS:24,MODE:28,PATH_BUFFER:32,DATA_BUFFER:4128},Xi={CONTROL_REGION:32,PATH_BUFFER:4096,DATA_BUFFER:8388608,TOTAL:8392736},Yl={NONE:0,RECURSIVE:1,FORCE:2,MKDIR_RECURSIVE:1},pr={IS_FILE:0,IS_DIRECTORY:1,IS_SYMLINK:2,MODE:4,SIZE:8,MTIME:16,TOTAL:24};nh=class{int32View;uint8View;dataView;constructor(e){this.int32View=new Int32Array(e),this.uint8View=new Uint8Array(e),this.dataView=new DataView(e)}getOpCode(){return Wt.load(this.int32View,Be.OP_CODE/4)}setOpCode(e){Wt.store(this.int32View,Be.OP_CODE/4,e)}getStatus(){return Wt.load(this.int32View,Be.STATUS/4)}setStatus(e){Wt.store(this.int32View,Be.STATUS/4,e)}getPathLength(){return Wt.load(this.int32View,Be.PATH_LENGTH/4)}setPathLength(e){Wt.store(this.int32View,Be.PATH_LENGTH/4,e)}getDataLength(){return Wt.load(this.int32View,Be.DATA_LENGTH/4)}setDataLength(e){Wt.store(this.int32View,Be.DATA_LENGTH/4,e)}getResultLength(){return Wt.load(this.int32View,Be.RESULT_LENGTH/4)}setResultLength(e){Wt.store(this.int32View,Be.RESULT_LENGTH/4,e)}getErrorCode(){return Wt.load(this.int32View,Be.ERROR_CODE/4)}setErrorCode(e){Wt.store(this.int32View,Be.ERROR_CODE/4,e)}getFlags(){return Wt.load(this.int32View,Be.FLAGS/4)}setFlags(e){Wt.store(this.int32View,Be.FLAGS/4,e)}getMode(){return Wt.load(this.int32View,Be.MODE/4)}setMode(e){Wt.store(this.int32View,Be.MODE/4,e)}getPath(){let e=this.getPathLength(),n=this.uint8View.slice(Be.PATH_BUFFER,Be.PATH_BUFFER+e);return new TextDecoder().decode(n)}setPath(e){let n=new TextEncoder().encode(e);if(n.length>Xi.PATH_BUFFER)throw new Error(`Path too long: ${n.length} > ${Xi.PATH_BUFFER}`);this.uint8View.set(n,Be.PATH_BUFFER),this.setPathLength(n.length)}getData(){let e=this.getDataLength();return this.uint8View.slice(Be.DATA_BUFFER,Be.DATA_BUFFER+e)}setData(e){if(e.length>Xi.DATA_BUFFER)throw new Error(`Data too large: ${e.length} > ${Xi.DATA_BUFFER}`);this.uint8View.set(e,Be.DATA_BUFFER),this.setDataLength(e.length)}getDataAsString(){let e=this.getData();return new TextDecoder().decode(e)}setDataFromString(e){let n=new TextEncoder().encode(e);this.setData(n)}getResult(){let e=this.getResultLength();return this.uint8View.slice(Be.DATA_BUFFER,Be.DATA_BUFFER+e)}setResult(e){if(e.length>Xi.DATA_BUFFER)throw new Error(`Result too large: ${e.length} > ${Xi.DATA_BUFFER}`);this.uint8View.set(e,Be.DATA_BUFFER),this.setResultLength(e.length)}getResultAsString(){let e=this.getResult();return new TextDecoder().decode(e)}setResultFromString(e){let n=new TextEncoder().encode(e);this.setResult(n)}encodeStat(e){this.uint8View[Be.DATA_BUFFER+pr.IS_FILE]=e.isFile?1:0,this.uint8View[Be.DATA_BUFFER+pr.IS_DIRECTORY]=e.isDirectory?1:0,this.uint8View[Be.DATA_BUFFER+pr.IS_SYMLINK]=e.isSymbolicLink?1:0,this.dataView.setInt32(Be.DATA_BUFFER+pr.MODE,e.mode,!0);let n=Math.min(e.size,Number.MAX_SAFE_INTEGER);this.dataView.setFloat64(Be.DATA_BUFFER+pr.SIZE,n,!0),this.dataView.setFloat64(Be.DATA_BUFFER+pr.MTIME,e.mtime.getTime(),!0),this.setResultLength(pr.TOTAL)}decodeStat(){return{isFile:this.uint8View[Be.DATA_BUFFER+pr.IS_FILE]===1,isDirectory:this.uint8View[Be.DATA_BUFFER+pr.IS_DIRECTORY]===1,isSymbolicLink:this.uint8View[Be.DATA_BUFFER+pr.IS_SYMLINK]===1,mode:this.dataView.getInt32(Be.DATA_BUFFER+pr.MODE,!0),size:this.dataView.getFloat64(Be.DATA_BUFFER+pr.SIZE,!0),mtime:new Date(this.dataView.getFloat64(Be.DATA_BUFFER+pr.MTIME,!0))}}waitForReady(e){return Wt.wait(this.int32View,Be.STATUS/4,Ve.PENDING,e)}waitForReadyAsync(e){return Wt.waitAsync(this.int32View,Be.STATUS/4,Ve.PENDING,e)}async waitUntilReady(e){let n=Date.now();for(;;){let r=this.getStatus();if(r===Ve.READY)return!0;let s=Date.now()-n;if(s>=e)return!1;let i=e-s,o=Wt.waitAsync(this.int32View,Be.STATUS/4,r,i);if(o.async&&await o.value==="timed-out")return!1}}waitForResult(e){return Wt.wait(this.int32View,Be.STATUS/4,Ve.READY,e)}notify(){return Wt.notify(this.int32View,Be.STATUS/4)}reset(){this.setOpCode(Mt.NOOP),this.setStatus(Ve.PENDING),this.setPathLength(0),this.setDataLength(0),this.setResultLength(0),this.setErrorCode(En.NONE),this.setFlags(Yl.NONE),this.setMode(0)}}});var ca,Q2=I(()=>{"use strict";la();mn();Is();en();os();sh();ca=class{fs;cwd;commandName;secureFetch;maxOutputSize;exec;invokeTool;protocol;running=!1;output={stdout:"",stderr:"",exitCode:0};outputLimitExceeded=!1;startTime=0;timeoutMs=0;constructor(e,n,r,s,i=void 0,o=0,a=void 0,l=void 0){this.fs=n,this.cwd=r,this.commandName=s,this.secureFetch=i,this.maxOutputSize=o,this.exec=a,this.invokeTool=l,this.protocol=new nh(e)}remainingMs(){return Math.max(0,this.timeoutMs-(Date.now()-this.startTime))}raceDeadline(e){let n=this.remainingMs();if(n<=0)return this.running=!1,this.output.exitCode=124,this.output.stderr+=`
1202
1202
  ${this.commandName}: execution timeout exceeded
1203
1203
  `,Promise.reject(new Error("Operation timed out"));let r=e();return new Promise((s,i)=>{let o=sn(()=>{this.running=!1,this.output.exitCode=124,this.output.stderr+=`
1204
1204
  ${this.commandName}: execution timeout exceeded
@@ -1206,13 +1206,13 @@ ${this.commandName}: execution timeout exceeded
1206
1206
  ${this.commandName}: execution timeout exceeded
1207
1207
  `,this.output.exitCode=124;break}let r=this.remainingMs();if(!await this.protocol.waitUntilReady(r)){this.output.stderr+=`
1208
1208
  ${this.commandName}: execution timeout exceeded
1209
- `,this.output.exitCode=124;break}let i=this.protocol.getOpCode();await this.handleOperation(i),this.protocol.notify()}return this.output}stop(){this.running=!1}async handleOperation(e){try{switch(e){case Mt.READ_FILE:await this.handleReadFile();break;case Mt.WRITE_FILE:await this.handleWriteFile();break;case Mt.STAT:await this.handleStat();break;case Mt.LSTAT:await this.handleLstat();break;case Mt.READDIR:await this.handleReaddir();break;case Mt.MKDIR:await this.handleMkdir();break;case Mt.RM:await this.handleRm();break;case Mt.EXISTS:await this.handleExists();break;case Mt.APPEND_FILE:await this.handleAppendFile();break;case Mt.SYMLINK:await this.handleSymlink();break;case Mt.READLINK:await this.handleReadlink();break;case Mt.CHMOD:await this.handleChmod();break;case Mt.REALPATH:await this.handleRealpath();break;case Mt.RENAME:await this.handleRename();break;case Mt.COPY_FILE:await this.handleCopyFile();break;case Mt.WRITE_STDOUT:this.handleWriteStdout();break;case Mt.WRITE_STDERR:this.handleWriteStderr();break;case Mt.EXIT:this.handleExit();break;case Mt.HTTP_REQUEST:await this.handleHttpRequest();break;case Mt.EXEC_COMMAND:await this.handleExecCommand();break;case Mt.INVOKE_TOOL:await this.handleInvokeTool();break;default:this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setStatus(He.ERROR)}}catch(n){this.setErrorFromException(n)}}resolvePath(e){return this.fs.resolvePath(this.cwd,e)}async handleReadFile(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.readFileBuffer(e);this.protocol.setResult(n),this.protocol.setStatus(He.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleWriteFile(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getData();try{await this.fs.writeFile(e,n),this.protocol.setStatus(He.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleStat(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.stat(e);this.protocol.encodeStat(n),this.protocol.setStatus(He.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleLstat(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.lstat(e);this.protocol.encodeStat(n),this.protocol.setStatus(He.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleReaddir(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.readdir(e);this.protocol.setResultFromString(JSON.stringify(n)),this.protocol.setStatus(He.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleMkdir(){let e=this.resolvePath(this.protocol.getPath()),r=(this.protocol.getFlags()&Yl.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(e,{recursive:r}),this.protocol.setStatus(He.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRm(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getFlags(),r=(n&Yl.RECURSIVE)!==0,s=(n&Yl.FORCE)!==0;try{await this.fs.rm(e,{recursive:r,force:s}),this.protocol.setStatus(He.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleExists(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.exists(e);this.protocol.setResult(new Uint8Array([n?1:0])),this.protocol.setStatus(He.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleAppendFile(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getData();try{await this.fs.appendFile(e,n),this.protocol.setStatus(He.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleSymlink(){let e=this.protocol.getPath(),n=this.protocol.getDataAsString(),r=this.resolvePath(e);try{await this.fs.symlink(n,r),this.protocol.setStatus(He.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleReadlink(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.readlink(e);this.protocol.setResultFromString(n),this.protocol.setStatus(He.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleChmod(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getMode();try{await this.fs.chmod(e,n),this.protocol.setStatus(He.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleRealpath(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.realpath(e);this.protocol.setResultFromString(n),this.protocol.setStatus(He.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleRename(){let e=this.resolvePath(this.protocol.getPath()),n=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.mv(e,n),this.protocol.setStatus(He.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleCopyFile(){let e=this.resolvePath(this.protocol.getPath()),n=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.cp(e,n),this.protocol.setStatus(He.SUCCESS)}catch(r){this.setErrorFromException(r)}}handleWriteStdout(){let e=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",e)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(He.ERROR);return}this.protocol.setStatus(He.SUCCESS)}handleWriteStderr(){let e=this.protocol.getDataAsString();if(!this.tryAppendOutput("stderr",e)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(He.ERROR);return}this.protocol.setStatus(He.SUCCESS)}handleExit(){let e=this.protocol.getFlags();this.outputLimitExceeded?this.output.exitCode===0&&(this.output.exitCode=1):this.output.exitCode=e,this.protocol.setStatus(He.SUCCESS),this.running=!1}tryAppendOutput(e,n){return this.outputLimitExceeded?!1:this.maxOutputSize<=0?(e==="stdout"?this.output.stdout+=n:this.output.stderr+=n,!0):this.output.stdout.length+this.output.stderr.length+n.length>this.maxOutputSize?!1:(e==="stdout"?this.output.stdout+=n:this.output.stderr+=n,!0)}appendOutputLimitError(){if(this.maxOutputSize<=0)return;let e=`${this.commandName}: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
1210
- `,n=e.length>this.maxOutputSize?e.slice(0,this.maxOutputSize):e;if(this.output.stderr.includes("total output size exceeded"))return;let s=this.output.stdout.length+this.output.stderr.length+n.length-this.maxOutputSize;if(s>0)if(this.output.stdout.length>=s)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-s);else{let i=s-this.output.stdout.length;this.output.stdout="",i>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-i)}this.output.stderr+=n}async handleHttpRequest(){let e=this.secureFetch;if(!e){this.protocol.setErrorCode(En.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(He.ERROR);return}let n=this.protocol.getPath(),r=this.protocol.getDataAsString();try{let s=r?JSON.parse(r):{},i=this.remainingMs(),o=await this.raceDeadline(()=>e(n,{method:s.method,headers:s.headers,body:s.body,timeoutMs:i})),a=JSON.stringify({status:o.status,statusText:o.statusText,headers:o.headers,bodyBase64:dr(o.body,"base64"),url:o.url});this.protocol.setResultFromString(a),this.protocol.setStatus(He.SUCCESS)}catch(s){let i=Fe(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(En.NETWORK_ERROR),this.protocol.setResultFromString(i),this.protocol.setStatus(He.ERROR)}}async handleExecCommand(){let e=this.exec;if(!e){this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Command execution not available in this context."),this.protocol.setStatus(He.ERROR);return}let n=this.protocol.getPath(),r=this.protocol.getDataAsString(),s=new AbortController;try{let i={cwd:this.cwd,signal:s.signal};if(r){let l=JSON.parse(r);l.stdin&&(i.stdin=l.stdin),l.args&&Array.isArray(l.args)&&(i.args=l.args.map(c=>String(c)),n=on([n]))}let o=await this.raceDeadline(()=>e(n,i)),a=JSON.stringify({stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode});this.protocol.setResultFromString(a),this.protocol.setStatus(He.SUCCESS)}catch(i){s.abort();let o=i instanceof Error?i.message:String(i);this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString(o),this.protocol.setStatus(He.ERROR)}}async handleInvokeTool(){let e=this.invokeTool;if(!e){this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Tool invocation not available in this context."),this.protocol.setStatus(He.ERROR);return}let n=this.protocol.getPath(),r=this.protocol.getDataAsString();try{let s=await this.raceDeadline(()=>tt.runTrustedAsync(()=>e(n,r)));this.protocol.setResultFromString(s),this.protocol.setStatus(He.SUCCESS)}catch(s){let i=$t(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString(i),this.protocol.setStatus(He.ERROR)}}setErrorFromException(e){let n=e instanceof Error?e.message:String(e),r=Fe(n),s=En.IO_ERROR,i=n.toLowerCase();i.includes("no such file")||i.includes("not found")||i.includes("enoent")?s=En.NOT_FOUND:i.includes("is a directory")||i.includes("eisdir")?s=En.IS_DIRECTORY:i.includes("not a directory")||i.includes("enotdir")?s=En.NOT_DIRECTORY:i.includes("already exists")||i.includes("eexist")?s=En.EXISTS:(i.includes("permission")||i.includes("eperm")||i.includes("eacces"))&&(s=En.PERMISSION_DENIED),this.protocol.setErrorCode(s),this.protocol.setResultFromString(r),this.protocol.setStatus(He.ERROR)}}});var J2={};ee(J2,{_resetExecutionQueue:()=>Wj,python3Command:()=>$5,pythonCommand:()=>Gj});function Uj(t){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(t.length===0)return e;let n=t.findIndex(r=>!r.startsWith("-")||r==="-"||r==="--");for(let r=0;r<(n===-1?t.length:n);r++){let s=t[r];if(s==="-c")return r+1>=t.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
1209
+ `,this.output.exitCode=124;break}let i=this.protocol.getOpCode();await this.handleOperation(i),this.protocol.notify()}return this.output}stop(){this.running=!1}async handleOperation(e){try{switch(e){case Mt.READ_FILE:await this.handleReadFile();break;case Mt.WRITE_FILE:await this.handleWriteFile();break;case Mt.STAT:await this.handleStat();break;case Mt.LSTAT:await this.handleLstat();break;case Mt.READDIR:await this.handleReaddir();break;case Mt.MKDIR:await this.handleMkdir();break;case Mt.RM:await this.handleRm();break;case Mt.EXISTS:await this.handleExists();break;case Mt.APPEND_FILE:await this.handleAppendFile();break;case Mt.SYMLINK:await this.handleSymlink();break;case Mt.READLINK:await this.handleReadlink();break;case Mt.CHMOD:await this.handleChmod();break;case Mt.REALPATH:await this.handleRealpath();break;case Mt.RENAME:await this.handleRename();break;case Mt.COPY_FILE:await this.handleCopyFile();break;case Mt.WRITE_STDOUT:this.handleWriteStdout();break;case Mt.WRITE_STDERR:this.handleWriteStderr();break;case Mt.EXIT:this.handleExit();break;case Mt.HTTP_REQUEST:await this.handleHttpRequest();break;case Mt.EXEC_COMMAND:await this.handleExecCommand();break;case Mt.INVOKE_TOOL:await this.handleInvokeTool();break;default:this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setStatus(Ve.ERROR)}}catch(n){this.setErrorFromException(n)}}resolvePath(e){return this.fs.resolvePath(this.cwd,e)}async handleReadFile(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.readFileBuffer(e);this.protocol.setResult(n),this.protocol.setStatus(Ve.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleWriteFile(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getData();try{await this.fs.writeFile(e,n),this.protocol.setStatus(Ve.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleStat(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.stat(e);this.protocol.encodeStat(n),this.protocol.setStatus(Ve.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleLstat(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.lstat(e);this.protocol.encodeStat(n),this.protocol.setStatus(Ve.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleReaddir(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.readdir(e);this.protocol.setResultFromString(JSON.stringify(n)),this.protocol.setStatus(Ve.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleMkdir(){let e=this.resolvePath(this.protocol.getPath()),r=(this.protocol.getFlags()&Yl.MKDIR_RECURSIVE)!==0;try{await this.fs.mkdir(e,{recursive:r}),this.protocol.setStatus(Ve.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleRm(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getFlags(),r=(n&Yl.RECURSIVE)!==0,s=(n&Yl.FORCE)!==0;try{await this.fs.rm(e,{recursive:r,force:s}),this.protocol.setStatus(Ve.SUCCESS)}catch(i){this.setErrorFromException(i)}}async handleExists(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.exists(e);this.protocol.setResult(new Uint8Array([n?1:0])),this.protocol.setStatus(Ve.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleAppendFile(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getData();try{await this.fs.appendFile(e,n),this.protocol.setStatus(Ve.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleSymlink(){let e=this.protocol.getPath(),n=this.protocol.getDataAsString(),r=this.resolvePath(e);try{await this.fs.symlink(n,r),this.protocol.setStatus(Ve.SUCCESS)}catch(s){this.setErrorFromException(s)}}async handleReadlink(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.readlink(e);this.protocol.setResultFromString(n),this.protocol.setStatus(Ve.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleChmod(){let e=this.resolvePath(this.protocol.getPath()),n=this.protocol.getMode();try{await this.fs.chmod(e,n),this.protocol.setStatus(Ve.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleRealpath(){let e=this.resolvePath(this.protocol.getPath());try{let n=await this.fs.realpath(e);this.protocol.setResultFromString(n),this.protocol.setStatus(Ve.SUCCESS)}catch(n){this.setErrorFromException(n)}}async handleRename(){let e=this.resolvePath(this.protocol.getPath()),n=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.mv(e,n),this.protocol.setStatus(Ve.SUCCESS)}catch(r){this.setErrorFromException(r)}}async handleCopyFile(){let e=this.resolvePath(this.protocol.getPath()),n=this.resolvePath(this.protocol.getDataAsString());try{await this.fs.cp(e,n),this.protocol.setStatus(Ve.SUCCESS)}catch(r){this.setErrorFromException(r)}}handleWriteStdout(){let e=this.protocol.getDataAsString();if(!this.tryAppendOutput("stdout",e)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(Ve.ERROR);return}this.protocol.setStatus(Ve.SUCCESS)}handleWriteStderr(){let e=this.protocol.getDataAsString();if(!this.tryAppendOutput("stderr",e)){this.outputLimitExceeded=!0,this.output.exitCode=1,this.appendOutputLimitError(),this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Output size limit exceeded"),this.protocol.setStatus(Ve.ERROR);return}this.protocol.setStatus(Ve.SUCCESS)}handleExit(){let e=this.protocol.getFlags();this.outputLimitExceeded?this.output.exitCode===0&&(this.output.exitCode=1):this.output.exitCode=e,this.protocol.setStatus(Ve.SUCCESS),this.running=!1}tryAppendOutput(e,n){return this.outputLimitExceeded?!1:this.maxOutputSize<=0?(e==="stdout"?this.output.stdout+=n:this.output.stderr+=n,!0):this.output.stdout.length+this.output.stderr.length+n.length>this.maxOutputSize?!1:(e==="stdout"?this.output.stdout+=n:this.output.stderr+=n,!0)}appendOutputLimitError(){if(this.maxOutputSize<=0)return;let e=`${this.commandName}: total output size exceeded (>${this.maxOutputSize} bytes), increase executionLimits.maxOutputSize
1210
+ `,n=e.length>this.maxOutputSize?e.slice(0,this.maxOutputSize):e;if(this.output.stderr.includes("total output size exceeded"))return;let s=this.output.stdout.length+this.output.stderr.length+n.length-this.maxOutputSize;if(s>0)if(this.output.stdout.length>=s)this.output.stdout=this.output.stdout.slice(0,this.output.stdout.length-s);else{let i=s-this.output.stdout.length;this.output.stdout="",i>=this.output.stderr.length?this.output.stderr="":this.output.stderr=this.output.stderr.slice(0,this.output.stderr.length-i)}this.output.stderr+=n}async handleHttpRequest(){let e=this.secureFetch;if(!e){this.protocol.setErrorCode(En.NETWORK_NOT_CONFIGURED),this.protocol.setResultFromString("Network access not configured. Enable network in Bash options."),this.protocol.setStatus(Ve.ERROR);return}let n=this.protocol.getPath(),r=this.protocol.getDataAsString();try{let s=r?JSON.parse(r):{},i=this.remainingMs(),o=await this.raceDeadline(()=>e(n,{method:s.method,headers:s.headers,body:s.body,timeoutMs:i})),a=JSON.stringify({status:o.status,statusText:o.statusText,headers:o.headers,bodyBase64:dr(o.body,"base64"),url:o.url});this.protocol.setResultFromString(a),this.protocol.setStatus(Ve.SUCCESS)}catch(s){let i=Fe(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(En.NETWORK_ERROR),this.protocol.setResultFromString(i),this.protocol.setStatus(Ve.ERROR)}}async handleExecCommand(){let e=this.exec;if(!e){this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Command execution not available in this context."),this.protocol.setStatus(Ve.ERROR);return}let n=this.protocol.getPath(),r=this.protocol.getDataAsString(),s=new AbortController;try{let i={cwd:this.cwd,signal:s.signal};if(r){let l=JSON.parse(r);l.stdin&&(i.stdin=l.stdin),l.args&&Array.isArray(l.args)&&(i.args=l.args.map(c=>String(c)),n=on([n]))}let o=await this.raceDeadline(()=>e(n,i)),a=JSON.stringify({stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode});this.protocol.setResultFromString(a),this.protocol.setStatus(Ve.SUCCESS)}catch(i){s.abort();let o=i instanceof Error?i.message:String(i);this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString(o),this.protocol.setStatus(Ve.ERROR)}}async handleInvokeTool(){let e=this.invokeTool;if(!e){this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString("Tool invocation not available in this context."),this.protocol.setStatus(Ve.ERROR);return}let n=this.protocol.getPath(),r=this.protocol.getDataAsString();try{let s=await this.raceDeadline(()=>tt.runTrustedAsync(()=>e(n,r)));this.protocol.setResultFromString(s),this.protocol.setStatus(Ve.SUCCESS)}catch(s){let i=$t(s instanceof Error?s.message:String(s));this.protocol.setErrorCode(En.IO_ERROR),this.protocol.setResultFromString(i),this.protocol.setStatus(Ve.ERROR)}}setErrorFromException(e){let n=e instanceof Error?e.message:String(e),r=Fe(n),s=En.IO_ERROR,i=n.toLowerCase();i.includes("no such file")||i.includes("not found")||i.includes("enoent")?s=En.NOT_FOUND:i.includes("is a directory")||i.includes("eisdir")?s=En.IS_DIRECTORY:i.includes("not a directory")||i.includes("enotdir")?s=En.NOT_DIRECTORY:i.includes("already exists")||i.includes("eexist")?s=En.EXISTS:(i.includes("permission")||i.includes("eperm")||i.includes("eacces"))&&(s=En.PERMISSION_DENIED),this.protocol.setErrorCode(s),this.protocol.setResultFromString(r),this.protocol.setStatus(Ve.ERROR)}}});var J2={};ee(J2,{_resetExecutionQueue:()=>Wj,python3Command:()=>$5,pythonCommand:()=>Gj});function Uj(t){let e={code:null,module:null,scriptFile:null,showVersion:!1,scriptArgs:[]};if(t.length===0)return e;let n=t.findIndex(r=>!r.startsWith("-")||r==="-"||r==="--");for(let r=0;r<(n===-1?t.length:n);r++){let s=t[r];if(s==="-c")return r+1>=t.length?{stdout:"",stderr:`python3: option requires an argument -- 'c'
1211
1211
  `,exitCode:2}:(e.code=t[r+1],e.scriptArgs=t.slice(r+2),e);if(s==="-m")return r+1>=t.length?{stdout:"",stderr:`python3: option requires an argument -- 'm'
1212
1212
  `,exitCode:2}:(e.module=t[r+1],e.scriptArgs=t.slice(r+2),e);if(s==="--version"||s==="-V")return e.showVersion=!0,e;if(s.startsWith("-")&&s!=="-")return{stdout:"",stderr:`python3: unrecognized option '${s}'
1213
- `,exitCode:2}}if(n!==-1){let r=t[n];r==="--"?n+1<t.length&&(e.scriptFile=t[n+1],e.scriptArgs=t.slice(n+2)):(e.scriptFile=r,e.scriptArgs=t.slice(n+1))}return e}function zj(t){let e=X2.get(t);return e||(e={executionQueue:[],isExecuting:!1},X2.set(t,e)),e}function Wj(){X2=new WeakMap}function qj(){return(0,I5.randomBytes)(16).toString("hex")}function Hj(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let n=t;return typeof n.protocolToken!="string"||n.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:n.type==="security-violation"?{success:!1,error:`Security violation: ${typeof n.violation?.type=="string"?n.violation.type:"unknown"}`}:typeof n.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:n.success?{success:!0}:{success:!1,error:typeof n.error=="string"&&n.error.length>0?n.error:"Worker execution failed"}}function hi(t){if(t.isExecuting||t.executionQueue.length===0)return;for(;t.executionQueue.length>0&&t.executionQueue[0].canceled;)t.executionQueue.shift();if(t.executionQueue.length===0)return;let e=t.executionQueue.shift();if(!e)return;t.isExecuting=!0;let n;try{n=tt.runTrusted(()=>new R5.Worker(jj,{workerData:e.input}))}catch(c){let u=c instanceof Error?c.message:String(c);e.resolve({success:!1,error:$t(u)}),t.isExecuting=!1,hi(t);return}e.workerRef&&(e.workerRef.current=n);let r=hs(e.requireDefenseContext,"python3","worker message callback",c=>{e.resolve(Hj(c,e.input.protocolToken)),t.isExecuting=!1,n.terminate(),hi(t)}),s=hs(e.requireDefenseContext,"python3","worker error callback",c=>{let u=$t(ct(c));e.resolve({success:!1,error:u}),t.isExecuting=!1,hi(t)}),i=hs(e.requireDefenseContext,"python3","worker exit callback",()=>{t.isExecuting&&(e.resolve({success:!1,error:"Worker exited unexpectedly"}),t.isExecuting=!1,hi(t))}),o=c=>{try{r(c)}catch(u){let f=u instanceof Error?u.message:String(u);e.resolve({success:!1,error:$t(f)}),t.isExecuting=!1,n.terminate(),hi(t)}},a=c=>{try{s(c)}catch(u){let f=u instanceof Error?u.message:String(u);e.resolve({success:!1,error:$t(f)}),t.isExecuting=!1,hi(t)}},l=()=>{try{i()}catch(c){let u=c instanceof Error?c.message:String(c);e.resolve({success:!1,error:$t(u)}),t.isExecuting=!1,hi(t)}};n.on("message",o),n.on("error",a),n.on("exit",l)}async function Vj(t,e,n,r=[]){let s=rh(),i=new ca(s,e.fs,e.cwd,"python3",e.fetch,e.limits?.maxOutputSize??0),o=e.limits?.maxPythonTimeoutMs??Lj,a=e.fetch?Math.max(o,Mj):o,l=zj(e.fs),c={protocolToken:qj(),sharedBuffer:s,pythonCode:t,cwd:e.cwd,env:qt(e.env),args:r,scriptPath:n,timeoutMs:a},u={current:null},f=new Promise(p=>{let m={input:c,resolve:()=>{},workerRef:u,requireDefenseContext:e.requireDefenseContext},g=hs(e.requireDefenseContext,"python3","worker timeout callback",()=>{u.current?u.current.terminate():m.canceled=!0,p({success:!1,error:`Execution timeout: exceeded ${a}ms limit`})}),w=sn(()=>{try{g()}catch(b){let E=b instanceof Error?b.message:String(b);p({success:!1,error:$t(E)})}},a);m.resolve=b=>{Dt(w),p(b)},l.executionQueue.push(m),hi(l)}),[h,d]=await Promise.all([i.run(a).catch(p=>({stdout:"",stderr:`python3: bridge error: ${$t(ct(p))}
1213
+ `,exitCode:2}}if(n!==-1){let r=t[n];r==="--"?n+1<t.length&&(e.scriptFile=t[n+1],e.scriptArgs=t.slice(n+2)):(e.scriptFile=r,e.scriptArgs=t.slice(n+1))}return e}function zj(t){let e=X2.get(t);return e||(e={executionQueue:[],isExecuting:!1},X2.set(t,e)),e}function Wj(){X2=new WeakMap}function qj(){return(0,I5.randomBytes)(16).toString("hex")}function Hj(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let n=t;return typeof n.protocolToken!="string"||n.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:n.type==="security-violation"?{success:!1,error:`Security violation: ${typeof n.violation?.type=="string"?n.violation.type:"unknown"}`}:typeof n.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:n.success?{success:!0}:{success:!1,error:typeof n.error=="string"&&n.error.length>0?n.error:"Worker execution failed"}}function hi(t){if(t.isExecuting||t.executionQueue.length===0)return;for(;t.executionQueue.length>0&&t.executionQueue[0].canceled;)t.executionQueue.shift();if(t.executionQueue.length===0)return;let e=t.executionQueue.shift();if(!e)return;t.isExecuting=!0;let n;try{n=tt.runTrusted(()=>new R5.Worker(jj,{workerData:e.input}))}catch(c){let u=c instanceof Error?c.message:String(c);e.resolve({success:!1,error:$t(u)}),t.isExecuting=!1,hi(t);return}e.workerRef&&(e.workerRef.current=n);let r=ds(e.requireDefenseContext,"python3","worker message callback",c=>{e.resolve(Hj(c,e.input.protocolToken)),t.isExecuting=!1,n.terminate(),hi(t)}),s=ds(e.requireDefenseContext,"python3","worker error callback",c=>{let u=$t(ct(c));e.resolve({success:!1,error:u}),t.isExecuting=!1,hi(t)}),i=ds(e.requireDefenseContext,"python3","worker exit callback",()=>{t.isExecuting&&(e.resolve({success:!1,error:"Worker exited unexpectedly"}),t.isExecuting=!1,hi(t))}),o=c=>{try{r(c)}catch(u){let f=u instanceof Error?u.message:String(u);e.resolve({success:!1,error:$t(f)}),t.isExecuting=!1,n.terminate(),hi(t)}},a=c=>{try{s(c)}catch(u){let f=u instanceof Error?u.message:String(u);e.resolve({success:!1,error:$t(f)}),t.isExecuting=!1,hi(t)}},l=()=>{try{i()}catch(c){let u=c instanceof Error?c.message:String(c);e.resolve({success:!1,error:$t(u)}),t.isExecuting=!1,hi(t)}};n.on("message",o),n.on("error",a),n.on("exit",l)}async function Vj(t,e,n,r=[]){let s=rh(),i=new ca(s,e.fs,e.cwd,"python3",e.fetch,e.limits?.maxOutputSize??0),o=e.limits?.maxPythonTimeoutMs??Lj,a=e.fetch?Math.max(o,Mj):o,l=zj(e.fs),c={protocolToken:qj(),sharedBuffer:s,pythonCode:t,cwd:e.cwd,env:qt(e.env),args:r,scriptPath:n,timeoutMs:a},u={current:null},f=new Promise(p=>{let m={input:c,resolve:()=>{},workerRef:u,requireDefenseContext:e.requireDefenseContext},g=ds(e.requireDefenseContext,"python3","worker timeout callback",()=>{u.current?u.current.terminate():m.canceled=!0,p({success:!1,error:`Execution timeout: exceeded ${a}ms limit`})}),w=sn(()=>{try{g()}catch(b){let E=b instanceof Error?b.message:String(b);p({success:!1,error:$t(E)})}},a);m.resolve=b=>{Dt(w),p(b)},l.executionQueue.push(m),hi(l)}),[h,d]=await Promise.all([i.run(a).catch(p=>({stdout:"",stderr:`python3: bridge error: ${$t(ct(p))}
1214
1214
  `,exitCode:1})),f.catch(p=>({success:!1,error:$t(ct(p))}))]);if(!d.success&&d.error){let p=$t(d.error);return{stdout:h.stdout,stderr:`${h.stderr}python3: ${p}
1215
- `,exitCode:h.exitCode||1}}return{...h}}var I5,P5,R5,Kj,Lj,Mj,Bj,X2,jj,$5,Gj,e6=I(()=>{"use strict";I5=require("node:crypto"),P5=require("node:url"),R5=require("node:worker_threads");pe();mn();Ar();$n();lr();en();is();ue();Q2();sh();Kj={},Lj=1e4,Mj=6e4,Bj={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};X2=new WeakMap;jj=(0,P5.fileURLToPath)(new URL("./worker.js",Kj.url));$5={name:"python3",async execute(t,e){if(U(t))return B(Bj);let n=Uj(t);if("exitCode"in n)return n;if(n.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
1215
+ `,exitCode:h.exitCode||1}}return{...h}}var I5,P5,R5,Kj,Lj,Mj,Bj,X2,jj,$5,Gj,e6=I(()=>{"use strict";I5=require("node:crypto"),P5=require("node:url"),R5=require("node:worker_threads");pe();mn();Ar();$n();lr();en();os();ue();Q2();sh();Kj={},Lj=1e4,Mj=6e4,Bj={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};X2=new WeakMap;jj=(0,P5.fileURLToPath)(new URL("./worker.js",Kj.url));$5={name:"python3",async execute(t,e){if(U(t))return B(Bj);let n=Uj(t);if("exitCode"in n)return n;if(n.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
1216
1216
  `,stderr:"",exitCode:0};let r,s;if(n.code!==null)r=n.code,s="-c";else if(n.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(n.module))return{stdout:"",stderr:`python3: No module named '${n.module.slice(0,200)}'
1217
1217
  `,exitCode:1};r=`import runpy; runpy.run_module('${n.module}', run_name='__main__')`,s=n.module}else if(n.scriptFile==="-")r=te(e.stdin),s="-";else if(n.scriptFile!==null){let i=e.fs.resolvePath(e.cwd,n.scriptFile);if(!await e.fs.exists(i))return{stdout:"",stderr:`python3: can't open file '${n.scriptFile}': [Errno 2] No such file or directory
1218
1218
  `,exitCode:2};try{r=await e.fs.readFile(i),s=n.scriptFile}catch(o){let a=Fe(o.message);return{stdout:"",stderr:`python3: can't open file '${n.scriptFile}': ${a}
@@ -1221,7 +1221,7 @@ ${this.commandName}: execution timeout exceeded
1221
1221
  `,exitCode:2}:(e.code=t[n+1],e.scriptArgs=t.slice(n+2),e);if(r==="--version"||r==="-V")return e.showVersion=!0,e;if(r.startsWith("-")&&r!=="-"&&r!=="--")return{stdout:"",stderr:`js-exec: unrecognized option '${r}'
1222
1222
  `,exitCode:2};if(r==="--")return n+1<t.length&&(e.scriptFile=t[n+1],e.scriptArgs=t.slice(n+2)),e;if(!r.startsWith("-"))return e.scriptFile=r,e.scriptArgs=t.slice(n+1),e}return e}function Ql(){for(;Yr.length>0&&Yr[0].canceled;)Yr.shift();if(xn||Yr.length===0)return;let t=Yr.shift();if(!t)return;xn=t,eq().postMessage(xn.input)}function Jj(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let n=t;return typeof n.protocolToken!="string"||n.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:typeof n.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:n.success?{success:!0}:{success:!1,error:typeof n.error=="string"&&n.error.length>0?n.error:"Worker execution failed"}}function eq(){if(ih&&(Dt(ih),ih=null),mr)return mr;let t=tt.runTrusted(()=>new L5.Worker(Xj));return mr=t,t.on("message",e=>{if(mr===t){if(xn){let n=Jj(e,xn.input.protocolToken);xn.resolve(n),xn=null}Yr.length>0?Ql():tq()}}),t.on("error",e=>{if(mr===t){if(xn){let n=$t(ct(e));xn.resolve({success:!1,error:n}),xn=null}for(let n of Yr)n.resolve({success:!1,error:"Worker crashed"});Yr.length=0,mr=null}}),t.on("exit",()=>{mr===t&&(mr=null,xn&&(xn.resolve({success:!1,error:"Worker exited unexpectedly"}),xn=null),Yr.length>0&&Ql())}),t}function tq(){ih=sn(()=>{mr&&!xn&&Yr.length===0&&(mr.terminate(),mr=null)},5e3)}async function nq(t,e,n,r=[],s,i,o){return M5.getStore()?{stdout:"",stderr:`js-exec: recursive invocation is not supported
1223
1223
  `,exitCode:1}:iq(t,e,n,r,s,i,o)}async function rq(t,e,n){let r,s=new Promise(c=>{r=c}),i={input:t,resolve:()=>{}},o=sn(()=>{if(xn===i){let c=mr;c&&(mr=null,c.terminate()),xn=null,Ql()}else i.canceled=!0,xn||Ql();i.resolve({success:!1,error:`Execution timeout: exceeded ${n}ms limit`})},n);i.resolve=c=>{Dt(o),r(c)},Yr.push(i),Ql();let[a,l]=await Promise.all([e.run(n),s.catch(c=>({success:!1,error:$t(ct(c))}))]);return{bridgeOutput:a,workerResult:l}}function sq(t){let e=t.limits?.maxJsTimeoutMs??Zj;return t.fetch?Math.max(e,Yj):e}async function iq(t,e,n,r=[],s,i,o){let a=rh(),l=e.exec,c=l?(g,y)=>M5.run(!0,()=>l(g,y)):void 0,u=new ca(a,e.fs,e.cwd,"js-exec",e.fetch,e.limits?.maxOutputSize??0,c,e.invokeTool),f=sq(e),d={protocolToken:(0,_5.randomBytes)(16).toString("hex"),sharedBuffer:a,jsCode:t,cwd:e.cwd,env:qt(e.env),args:r,scriptPath:n,bootstrapCode:s,isModule:i,stripTypes:o,timeoutMs:f,hasInvokeTool:e.invokeTool!==void 0},{bridgeOutput:p,workerResult:m}=await rq(d,u,f);return!m.success&&m.error?{stdout:p.stdout,stderr:`${p.stderr}js-exec: ${$t(m.error)}
1224
- `,exitCode:p.exitCode||1}:{...p}}var F5,_5,D5,L5,lq,Zj,Yj,M5,B5,mr,ih,Yr,xn,Xj,oq,aq,n6=I(()=>{"use strict";F5=require("node:async_hooks"),_5=require("node:crypto"),D5=require("node:url"),L5=require("node:worker_threads");pe();mn();Ar();$n();en();is();ue();Q2();sh();lq={},Zj=1e4,Yj=6e4,M5=new F5.AsyncLocalStorage,B5=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
1224
+ `,exitCode:p.exitCode||1}:{...p}}var F5,_5,D5,L5,lq,Zj,Yj,M5,B5,mr,ih,Yr,xn,Xj,oq,aq,n6=I(()=>{"use strict";F5=require("node:async_hooks"),_5=require("node:crypto"),D5=require("node:url"),L5=require("node:worker_threads");pe();mn();Ar();$n();en();os();ue();Q2();sh();lq={},Zj=1e4,Yj=6e4,M5=new F5.AsyncLocalStorage,B5=`js-exec - Sandboxed JavaScript/TypeScript runtime with Node.js-compatible APIs
1225
1225
 
1226
1226
  Usage: js-exec [OPTIONS] [-c CODE | FILE] [ARGS...]
1227
1227
 
@@ -1382,46 +1382,46 @@ Gid: ${s} ${s} ${s} ${s}
1382
1382
  `);)h=!0,f++;if(h&&f<r&&n[f]===")"||l)return!0}if(i===0)return!1;s++;continue}s++}return!1}dparenClosesWithSpacedParens(e){let n=this.input,r=n.length,s=e,i=2,o=!1,a=!1;for(;s<r&&i>0;){let l=n[s];if(o){l==="'"&&(o=!1),s++;continue}if(a){if(l==="\\"){s+=2;continue}l==='"'&&(a=!1),s++;continue}if(l==="'"){o=!0,s++;continue}if(l==='"'){a=!0,s++;continue}if(l==="\\"){s+=2;continue}if(l==="("){i++,s++;continue}if(l===")"){if(i--,i===1){let c=s+1;if(c<r&&n[c]===")")return!1;let u=c,f=!1;for(;u<r&&(n[u]===" "||n[u]===" "||n[u]===`
1383
1383
  `);)f=!0,u++;if(f&&u<r&&n[u]===")")return!0}if(i===0)return!1;s++;continue}if(i===1&&(l==="|"&&s+1<r&&n[s+1]==="|"||l==="&"&&s+1<r&&n[s+1]==="&"||l==="|"&&s+1<r&&n[s+1]!=="|"))return!0;s++}return!1}}});var p6,m6,Ev,g6,xv,Sv,Av,un,to=I(()=>{"use strict";gi();p6=1e6,m6=1e5,Ev=1e6,g6=200,xv=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS,x.AND_GREAT,x.AND_DGREAT]),Sv=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS]),Av=new Set([x.LESS,x.GREAT,x.DLESS,x.DGREAT,x.LESSAND,x.GREATAND,x.LESSGREAT,x.DLESSDASH,x.CLOBBER,x.TLESS,x.AND_GREAT,x.AND_DGREAT]),un=class extends Error{line;column;token;constructor(e,n,r,s=void 0){super(`Parse error at ${n}:${r}: ${e}`),this.line=n,this.column=r,this.token=s,this.name="ParseException"}}});var le,no=I(()=>{"use strict";le={script(t){return{type:"Script",statements:t}},statement(t,e=[],n=!1,r,s){let i={type:"Statement",pipelines:t,operators:e,background:n};return r&&(i.deferredError=r),s!==void 0&&(i.sourceText=s),i},pipeline(t,e=!1,n=!1,r=!1,s){return{type:"Pipeline",commands:t,negated:e,timed:n,timePosix:r,pipeStderr:s}},simpleCommand(t,e=[],n=[],r=[]){return{type:"SimpleCommand",name:t,args:e,assignments:n,redirections:r}},word(t){return{type:"Word",parts:t}},literal(t){return{type:"Literal",value:t}},singleQuoted(t){return{type:"SingleQuoted",value:t}},doubleQuoted(t){return{type:"DoubleQuoted",parts:t}},escaped(t){return{type:"Escaped",value:t}},parameterExpansion(t,e=null){return{type:"ParameterExpansion",parameter:t,operation:e}},commandSubstitution(t,e=!1){return{type:"CommandSubstitution",body:t,legacy:e}},arithmeticExpansion(t){return{type:"ArithmeticExpansion",expression:t}},assignment(t,e,n=!1,r=null){return{type:"Assignment",name:t,value:e,append:n,array:r}},redirection(t,e,n=null,r){let s={type:"Redirection",fd:n,operator:t,target:e};return r&&(s.fdVariable=r),s},hereDoc(t,e,n=!1,r=!1){return{type:"HereDoc",delimiter:t,content:e,stripTabs:n,quoted:r}},ifNode(t,e=null,n=[]){return{type:"If",clauses:t,elseBody:e,redirections:n}},forNode(t,e,n,r=[]){return{type:"For",variable:t,words:e,body:n,redirections:r}},whileNode(t,e,n=[]){return{type:"While",condition:t,body:e,redirections:n}},untilNode(t,e,n=[]){return{type:"Until",condition:t,body:e,redirections:n}},caseNode(t,e,n=[]){return{type:"Case",word:t,items:e,redirections:n}},caseItem(t,e,n=";;"){return{type:"CaseItem",patterns:t,body:e,terminator:n}},subshell(t,e=[]){return{type:"Subshell",body:t,redirections:e}},group(t,e=[]){return{type:"Group",body:t,redirections:e}},functionDef(t,e,n=[],r){return{type:"FunctionDef",name:t,body:e,redirections:n,sourceFile:r}},conditionalCommand(t,e=[],n){return{type:"ConditionalCommand",expression:t,redirections:e,line:n}},arithmeticCommand(t,e=[],n){return{type:"ArithmeticCommand",expression:t,redirections:e,line:n}}}});function It(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
1384
1384
  `){e+=2;continue}if(/\s/.test(t[e])){e++;continue}break}return e}function Xl(t){if(t.includes("#")){let[n,r]=t.split("#"),s=Number.parseInt(n,10);if(s<2||s>64)return Number.NaN;if(s<=36){let o=Number.parseInt(r,s);return o>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:o}let i=0;for(let o of r){let a;if(/[0-9]/.test(o))a=o.charCodeAt(0)-48;else if(/[a-z]/.test(o))a=o.charCodeAt(0)-97+10;else if(/[A-Z]/.test(o))a=o.charCodeAt(0)-65+36;else if(o==="@")a=62;else if(o==="_")a=63;else return Number.NaN;if(a>=s)return Number.NaN;if(i=i*s+a,i>Number.MAX_SAFE_INTEGER)return Number.MAX_SAFE_INTEGER}return i}if(t.startsWith("0x")||t.startsWith("0X")){let n=Number.parseInt(t.slice(2),16);return n>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:n}if(t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)){if(/[89]/.test(t))return Number.NaN;let n=Number.parseInt(t,8);return n>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:n}let e=Number.parseInt(t,10);return e>Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e}function vv(t,e,n,r){if(n.slice(r,r+3)!=="$((")return null;let s=r+3,i=1,o=s;for(;s<n.length-1&&i>0;)n[s]==="("&&n[s+1]==="("?(i++,s+=2):n[s]===")"&&n[s+1]===")"?(i--,i>0&&(s+=2)):s++;let a=n.slice(o,s),{expr:l}=t(e,a,0);return s+=2,{expr:{type:"ArithNested",expression:l},pos:s}}function Cv(t,e){if(t.slice(e,e+2)!=="$'")return null;let n=e+2,r="";for(;n<t.length&&t[n]!=="'";)if(t[n]==="\\"&&n+1<t.length){let i=t[n+1];switch(i){case"n":r+=`
1385
- `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case"'":r+="'";break;default:r+=i}n+=2}else r+=t[n],n++;t[n]==="'"&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}function kv(t,e){if(t.slice(e,e+2)!=='$"')return null;let n=e+2,r="";for(;n<t.length&&t[n]!=='"';)t[n]==="\\"&&n+1<t.length?(r+=t[n+1],n+=2):(r+=t[n],n++);t[n]==='"'&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}var fh,Nv=I(()=>{"use strict";fh=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function Oq(t){let e="",n=0;for(;n<t.length;)if(t[n]==='"'){for(n++;n<t.length&&t[n]!=='"';)t[n]==="\\"&&n+1<t.length?(e+=t[n+1],n+=2):(e+=t[n],n++);n<t.length&&n++}else e+=t[n],n++;return e}function Ve(t,e){let n=Oq(e),{expr:r,pos:s}=gr(t,n,0),i=It(n,s);if(i<n.length){let o=e.slice(i).trim();if(o)return{type:"ArithmeticExpression",originalText:e,expression:{type:"ArithSyntaxError",errorToken:o,message:`${o}: syntax error: invalid arithmetic operator (error token is "${o}")`}}}return{type:"ArithmeticExpression",expression:r,originalText:e}}function nr(t,e){return{expr:{type:"ArithSyntaxError",errorToken:t,message:`syntax error: operand expected (error token is "${t}")`},pos:e}}function rr(t,e){return It(t,e)>=t.length}function gr(t,e,n){return Iq(t,e,n)}function Iq(t,e,n){let{expr:r,pos:s}=Jl(t,e,n);for(s=It(e,s);e[s]===",";){if(s++,rr(e,s))return nr(",",s);let{expr:o,pos:a}=Jl(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=It(e,a)}return{expr:r,pos:s}}function Jl(t,e,n){let{expr:r,pos:s}=Pq(t,e,n);if(s=It(e,s),e[s]==="?"){s++;let{expr:i,pos:o}=gr(t,e,s);if(s=It(e,o),e[s]===":"){s++;let{expr:a,pos:l}=gr(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:a},pos:l}}}return{expr:r,pos:s}}function Pq(t,e,n){let{expr:r,pos:s}=Tv(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="||";){if(s+=2,rr(e,s))return nr("||",s);let{expr:o,pos:a}=Tv(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=a}return{expr:r,pos:s}}function Tv(t,e,n){let{expr:r,pos:s}=Ov(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="&&";){if(s+=2,rr(e,s))return nr("&&",s);let{expr:o,pos:a}=Ov(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=a}return{expr:r,pos:s}}function Ov(t,e,n){let{expr:r,pos:s}=Iv(t,e,n);for(;s=It(e,s),e[s]==="|"&&e[s+1]!=="|";){if(s++,rr(e,s))return nr("|",s);let{expr:o,pos:a}=Iv(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=a}return{expr:r,pos:s}}function Iv(t,e,n){let{expr:r,pos:s}=Pv(t,e,n);for(;s=It(e,s),e[s]==="^";){if(s++,rr(e,s))return nr("^",s);let{expr:o,pos:a}=Pv(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=a}return{expr:r,pos:s}}function Pv(t,e,n){let{expr:r,pos:s}=Rv(t,e,n);for(;s=It(e,s),e[s]==="&"&&e[s+1]!=="&";){if(s++,rr(e,s))return nr("&",s);let{expr:o,pos:a}=Rv(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=a}return{expr:r,pos:s}}function Rv(t,e,n){let{expr:r,pos:s}=$v(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let i=e.slice(s,s+2);if(s+=2,rr(e,s))return nr(i,s);let{expr:o,pos:a}=$v(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function $v(t,e,n){let{expr:r,pos:s}=y6(t,e,n);for(;;)if(s=It(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let i=e.slice(s,s+2);if(s+=2,rr(e,s))return nr(i,s);let{expr:o,pos:a}=y6(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else if(e[s]==="<"||e[s]===">"){let i=e[s];if(s++,rr(e,s))return nr(i,s);let{expr:o,pos:a}=y6(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function y6(t,e,n){let{expr:r,pos:s}=Fv(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let i=e.slice(s,s+2);if(s+=2,rr(e,s))return nr(i,s);let{expr:o,pos:a}=Fv(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Fv(t,e,n){let{expr:r,pos:s}=_v(t,e,n);for(;s=It(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let i=e[s];if(s++,rr(e,s))return nr(i,s);let{expr:o,pos:a}=_v(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function _v(t,e,n){let{expr:r,pos:s}=hh(t,e,n);for(;;)if(s=It(e,s),e[s]==="*"&&e[s+1]!=="*"){if(s++,rr(e,s))return nr("*",s);let{expr:o,pos:a}=hh(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=a}else if(e[s]==="/"||e[s]==="%"){let i=e[s];if(s++,rr(e,s))return nr(i,s);let{expr:o,pos:a}=hh(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function hh(t,e,n){let{expr:r,pos:s}=w6(t,e,n),i=It(e,s);if(e.slice(i,i+2)==="**"){if(i+=2,rr(e,i))return nr("**",i);let{expr:a,pos:l}=hh(t,e,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:a},pos:l}}return{expr:r,pos:s}}function w6(t,e,n){let r=It(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:i,pos:o}=w6(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:i,pos:o}=w6(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return $q(t,e,r)}function Rq(t,e){let n=t[e];return n==="$"||n==="`"}function $q(t,e,n){let{expr:r,pos:s}=Dv(t,e,n,!1),i=[r];for(;Rq(e,s);){let{expr:a,pos:l}=Dv(t,e,s,!0);i.push(a),s=l}i.length>1&&(r={type:"ArithConcat",parts:i});let o;if(e[s]==="["&&r.type==="ArithConcat"){s++;let{expr:a,pos:l}=gr(t,e,s);o=a,s=l,e[s]==="]"&&s++}if(o&&r.type==="ArithConcat"&&(r={type:"ArithDynamicElement",nameExpr:r,subscript:o},o=void 0),s=It(e,s),r.type==="ArithConcat"||r.type==="ArithVariable"||r.type==="ArithDynamicElement"){for(let a of fh)if(e.slice(s,s+a.length)===a&&e.slice(s,s+a.length+1)!=="=="){s+=a.length;let{expr:l,pos:c}=Jl(t,e,s);return r.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r.nameExpr,subscript:r.subscript,value:l},pos:c}:r.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r,value:l},pos:c}:{expr:{type:"ArithAssignment",operator:a,variable:r.name,value:l},pos:c}}}if(e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let a=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:a,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function Dv(t,e,n,r=!1){let s=It(e,n),i=vv(gr,t,e,s);if(i)return i;let o=Cv(e,s);if(o)return o;let a=kv(e,s);if(a)return a;if(e.slice(s,s+2)==="$("&&e[s+2]!=="("){s+=2;let c=1,u=s;for(;s<e.length&&c>0;)e[s]==="("?c++:e[s]===")"&&c--,c>0&&s++;let f=e.slice(u,s);return s++,{expr:{type:"ArithCommandSubst",command:f},pos:s}}if(e[s]==="`"){s++;let c=s;for(;s<e.length&&e[s]!=="`";)s++;let u=e.slice(c,s);return e[s]==="`"&&s++,{expr:{type:"ArithCommandSubst",command:u},pos:s}}if(e[s]==="("){s++;let{expr:c,pos:u}=gr(t,e,s);return s=It(e,u),e[s]===")"&&s++,{expr:{type:"ArithGroup",expression:c},pos:s}}if(e[s]==="'"){s++;let c="";for(;s<e.length&&e[s]!=="'";)c+=e[s],s++;e[s]==="'"&&s++;let u=Number.parseInt(c,10);return{expr:{type:"ArithSingleQuote",content:c,value:Number.isNaN(u)?0:u},pos:s}}if(e[s]==='"'){s++;let c="";for(;s<e.length&&e[s]!=='"';)e[s]==="\\"&&s+1<e.length?(c+=e[s+1],s+=2):(c+=e[s],s++);e[s]==='"'&&s++;let u=c.trim();if(!u)return{expr:{type:"ArithNumber",value:0},pos:s};let{expr:f}=gr(t,u,0);return{expr:f,pos:s}}if(/[0-9]/.test(e[s])){let c="",u=!1,f=!1;for(;s<e.length;){let d=e[s];if(u)if(/[0-9a-zA-Z@_]/.test(d))c+=d,s++;else break;else if(d==="#")u=!0,c+=d,s++;else if(c==="0"&&(d==="x"||d==="X")&&s+1<e.length&&/[0-9a-fA-F]/.test(e[s+1]))f=!0,c+=d,s++;else if(f&&/[0-9a-fA-F]/.test(d))c+=d,s++;else if(!f&&/[0-9]/.test(d))c+=d,s++;else break}if(s<e.length&&/[a-zA-Z_]/.test(e[s])){let d=c;for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)d+=e[s],s++;return{expr:{type:"ArithSyntaxError",errorToken:d,message:`${d}: value too great for base (error token is "${d}")`},pos:s}}if(e[s]==="."&&/[0-9]/.test(e[s+1]))throw new lt(`${c}.${e[s+1]}...: syntax error: invalid arithmetic operator`);if(e[s]==="["){let d=e.slice(s).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:d},pos:e.length}}return{expr:{type:"ArithNumber",value:Xl(c)},pos:s}}if(e[s]==="$"&&e[s+1]==="{"){let c=s+2,u=1,f=c;for(;f<e.length&&u>0;)e[f]==="{"?u++:e[f]==="}"&&u--,u>0&&f++;let h=e.slice(c,f),d=f+1;if(e[d]==="#"){let p=d+1;for(;p<e.length&&/[0-9a-zA-Z@_]/.test(e[p]);)p++;let m=e.slice(d+1,p);return{expr:{type:"ArithDynamicBase",baseExpr:h,value:m},pos:p}}if(/[0-9]/.test(e[d])||e[d]==="x"||e[d]==="X"){let p=d;if(e[d]==="x"||e[d]==="X")for(p++;p<e.length&&/[0-9a-fA-F]/.test(e[p]);)p++;else for(;p<e.length&&/[0-9]/.test(e[p]);)p++;let m=e.slice(d,p);return{expr:{type:"ArithDynamicNumber",prefix:h,suffix:m},pos:p}}return s=d,{expr:{type:"ArithBracedExpansion",content:h},pos:s}}if(e[s]==="$"&&s+1<e.length&&/[0-9]/.test(e[s+1])){s++;let c="";for(;s<e.length&&/[0-9]/.test(e[s]);)c+=e[s],s++;return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:!0},pos:s}}if(e[s]==="$"&&s+1<e.length&&/[*@#?\-!$]/.test(e[s+1])){let c=e[s+1];return s+=2,{expr:{type:"ArithSpecialVar",name:c},pos:s}}let l=!1;if(e[s]==="$"&&s+1<e.length&&/[a-zA-Z_]/.test(e[s+1])&&(l=!0,s++),s<e.length&&/[a-zA-Z_]/.test(e[s])){let c="";for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)c+=e[s],s++;if(e[s]==="["&&!r){s++;let u;if(e[s]==="'"||e[s]==='"'){let h=e[s];for(s++,u="";s<e.length&&e[s]!==h;)u+=e[s],s++;e[s]===h&&s++,s=It(e,s),e[s]==="]"&&s++}let f;if(u===void 0){let{expr:h,pos:d}=gr(t,e,s);f=h,s=d,e[s]==="]"&&s++}if(s=It(e,s),e[s]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:s};if(!r){for(let h of fh)if(e.slice(s,s+h.length)===h&&e.slice(s,s+h.length+1)!=="=="){s+=h.length;let{expr:d,pos:p}=Jl(t,e,s);return{expr:{type:"ArithAssignment",operator:h,variable:c,subscript:f,stringKey:u,value:d},pos:p}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:s}}if(s=It(e,s),!r){for(let u of fh)if(e.slice(s,s+u.length)===u&&e.slice(s,s+u.length+1)!=="=="){s+=u.length;let{expr:f,pos:h}=Jl(t,e,s);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:h}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:l},pos:s}}if(e[s]==="#"){let c=s+1;for(;c<e.length&&e[c]!==`
1385
+ `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case"'":r+="'";break;default:r+=i}n+=2}else r+=t[n],n++;t[n]==="'"&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}function kv(t,e){if(t.slice(e,e+2)!=='$"')return null;let n=e+2,r="";for(;n<t.length&&t[n]!=='"';)t[n]==="\\"&&n+1<t.length?(r+=t[n+1],n+=2):(r+=t[n],n++);t[n]==='"'&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}var fh,Nv=I(()=>{"use strict";fh=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function Oq(t){let e="",n=0;for(;n<t.length;)if(t[n]==='"'){for(n++;n<t.length&&t[n]!=='"';)t[n]==="\\"&&n+1<t.length?(e+=t[n+1],n+=2):(e+=t[n],n++);n<t.length&&n++}else e+=t[n],n++;return e}function Ge(t,e){let n=Oq(e),{expr:r,pos:s}=gr(t,n,0),i=It(n,s);if(i<n.length){let o=e.slice(i).trim();if(o)return{type:"ArithmeticExpression",originalText:e,expression:{type:"ArithSyntaxError",errorToken:o,message:`${o}: syntax error: invalid arithmetic operator (error token is "${o}")`}}}return{type:"ArithmeticExpression",expression:r,originalText:e}}function nr(t,e){return{expr:{type:"ArithSyntaxError",errorToken:t,message:`syntax error: operand expected (error token is "${t}")`},pos:e}}function rr(t,e){return It(t,e)>=t.length}function gr(t,e,n){return Iq(t,e,n)}function Iq(t,e,n){let{expr:r,pos:s}=Jl(t,e,n);for(s=It(e,s);e[s]===",";){if(s++,rr(e,s))return nr(",",s);let{expr:o,pos:a}=Jl(t,e,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=It(e,a)}return{expr:r,pos:s}}function Jl(t,e,n){let{expr:r,pos:s}=Pq(t,e,n);if(s=It(e,s),e[s]==="?"){s++;let{expr:i,pos:o}=gr(t,e,s);if(s=It(e,o),e[s]===":"){s++;let{expr:a,pos:l}=gr(t,e,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:a},pos:l}}}return{expr:r,pos:s}}function Pq(t,e,n){let{expr:r,pos:s}=Tv(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="||";){if(s+=2,rr(e,s))return nr("||",s);let{expr:o,pos:a}=Tv(t,e,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=a}return{expr:r,pos:s}}function Tv(t,e,n){let{expr:r,pos:s}=Ov(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="&&";){if(s+=2,rr(e,s))return nr("&&",s);let{expr:o,pos:a}=Ov(t,e,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=a}return{expr:r,pos:s}}function Ov(t,e,n){let{expr:r,pos:s}=Iv(t,e,n);for(;s=It(e,s),e[s]==="|"&&e[s+1]!=="|";){if(s++,rr(e,s))return nr("|",s);let{expr:o,pos:a}=Iv(t,e,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=a}return{expr:r,pos:s}}function Iv(t,e,n){let{expr:r,pos:s}=Pv(t,e,n);for(;s=It(e,s),e[s]==="^";){if(s++,rr(e,s))return nr("^",s);let{expr:o,pos:a}=Pv(t,e,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=a}return{expr:r,pos:s}}function Pv(t,e,n){let{expr:r,pos:s}=Rv(t,e,n);for(;s=It(e,s),e[s]==="&"&&e[s+1]!=="&";){if(s++,rr(e,s))return nr("&",s);let{expr:o,pos:a}=Rv(t,e,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=a}return{expr:r,pos:s}}function Rv(t,e,n){let{expr:r,pos:s}=$v(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let i=e.slice(s,s+2);if(s+=2,rr(e,s))return nr(i,s);let{expr:o,pos:a}=$v(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function $v(t,e,n){let{expr:r,pos:s}=y6(t,e,n);for(;;)if(s=It(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let i=e.slice(s,s+2);if(s+=2,rr(e,s))return nr(i,s);let{expr:o,pos:a}=y6(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else if(e[s]==="<"||e[s]===">"){let i=e[s];if(s++,rr(e,s))return nr(i,s);let{expr:o,pos:a}=y6(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function y6(t,e,n){let{expr:r,pos:s}=Fv(t,e,n);for(;s=It(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let i=e.slice(s,s+2);if(s+=2,rr(e,s))return nr(i,s);let{expr:o,pos:a}=Fv(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Fv(t,e,n){let{expr:r,pos:s}=_v(t,e,n);for(;s=It(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let i=e[s];if(s++,rr(e,s))return nr(i,s);let{expr:o,pos:a}=_v(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function _v(t,e,n){let{expr:r,pos:s}=hh(t,e,n);for(;;)if(s=It(e,s),e[s]==="*"&&e[s+1]!=="*"){if(s++,rr(e,s))return nr("*",s);let{expr:o,pos:a}=hh(t,e,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=a}else if(e[s]==="/"||e[s]==="%"){let i=e[s];if(s++,rr(e,s))return nr(i,s);let{expr:o,pos:a}=hh(t,e,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function hh(t,e,n){let{expr:r,pos:s}=w6(t,e,n),i=It(e,s);if(e.slice(i,i+2)==="**"){if(i+=2,rr(e,i))return nr("**",i);let{expr:a,pos:l}=hh(t,e,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:a},pos:l}}return{expr:r,pos:s}}function w6(t,e,n){let r=It(e,n);if(e.slice(r,r+2)==="++"||e.slice(r,r+2)==="--"){let s=e.slice(r,r+2);r+=2;let{expr:i,pos:o}=w6(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(e[r]==="+"||e[r]==="-"||e[r]==="!"||e[r]==="~"){let s=e[r];r++;let{expr:i,pos:o}=w6(t,e,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return $q(t,e,r)}function Rq(t,e){let n=t[e];return n==="$"||n==="`"}function $q(t,e,n){let{expr:r,pos:s}=Dv(t,e,n,!1),i=[r];for(;Rq(e,s);){let{expr:a,pos:l}=Dv(t,e,s,!0);i.push(a),s=l}i.length>1&&(r={type:"ArithConcat",parts:i});let o;if(e[s]==="["&&r.type==="ArithConcat"){s++;let{expr:a,pos:l}=gr(t,e,s);o=a,s=l,e[s]==="]"&&s++}if(o&&r.type==="ArithConcat"&&(r={type:"ArithDynamicElement",nameExpr:r,subscript:o},o=void 0),s=It(e,s),r.type==="ArithConcat"||r.type==="ArithVariable"||r.type==="ArithDynamicElement"){for(let a of fh)if(e.slice(s,s+a.length)===a&&e.slice(s,s+a.length+1)!=="=="){s+=a.length;let{expr:l,pos:c}=Jl(t,e,s);return r.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r.nameExpr,subscript:r.subscript,value:l},pos:c}:r.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r,value:l},pos:c}:{expr:{type:"ArithAssignment",operator:a,variable:r.name,value:l},pos:c}}}if(e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let a=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:a,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function Dv(t,e,n,r=!1){let s=It(e,n),i=vv(gr,t,e,s);if(i)return i;let o=Cv(e,s);if(o)return o;let a=kv(e,s);if(a)return a;if(e.slice(s,s+2)==="$("&&e[s+2]!=="("){s+=2;let c=1,u=s;for(;s<e.length&&c>0;)e[s]==="("?c++:e[s]===")"&&c--,c>0&&s++;let f=e.slice(u,s);return s++,{expr:{type:"ArithCommandSubst",command:f},pos:s}}if(e[s]==="`"){s++;let c=s;for(;s<e.length&&e[s]!=="`";)s++;let u=e.slice(c,s);return e[s]==="`"&&s++,{expr:{type:"ArithCommandSubst",command:u},pos:s}}if(e[s]==="("){s++;let{expr:c,pos:u}=gr(t,e,s);return s=It(e,u),e[s]===")"&&s++,{expr:{type:"ArithGroup",expression:c},pos:s}}if(e[s]==="'"){s++;let c="";for(;s<e.length&&e[s]!=="'";)c+=e[s],s++;e[s]==="'"&&s++;let u=Number.parseInt(c,10);return{expr:{type:"ArithSingleQuote",content:c,value:Number.isNaN(u)?0:u},pos:s}}if(e[s]==='"'){s++;let c="";for(;s<e.length&&e[s]!=='"';)e[s]==="\\"&&s+1<e.length?(c+=e[s+1],s+=2):(c+=e[s],s++);e[s]==='"'&&s++;let u=c.trim();if(!u)return{expr:{type:"ArithNumber",value:0},pos:s};let{expr:f}=gr(t,u,0);return{expr:f,pos:s}}if(/[0-9]/.test(e[s])){let c="",u=!1,f=!1;for(;s<e.length;){let d=e[s];if(u)if(/[0-9a-zA-Z@_]/.test(d))c+=d,s++;else break;else if(d==="#")u=!0,c+=d,s++;else if(c==="0"&&(d==="x"||d==="X")&&s+1<e.length&&/[0-9a-fA-F]/.test(e[s+1]))f=!0,c+=d,s++;else if(f&&/[0-9a-fA-F]/.test(d))c+=d,s++;else if(!f&&/[0-9]/.test(d))c+=d,s++;else break}if(s<e.length&&/[a-zA-Z_]/.test(e[s])){let d=c;for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)d+=e[s],s++;return{expr:{type:"ArithSyntaxError",errorToken:d,message:`${d}: value too great for base (error token is "${d}")`},pos:s}}if(e[s]==="."&&/[0-9]/.test(e[s+1]))throw new lt(`${c}.${e[s+1]}...: syntax error: invalid arithmetic operator`);if(e[s]==="["){let d=e.slice(s).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:d},pos:e.length}}return{expr:{type:"ArithNumber",value:Xl(c)},pos:s}}if(e[s]==="$"&&e[s+1]==="{"){let c=s+2,u=1,f=c;for(;f<e.length&&u>0;)e[f]==="{"?u++:e[f]==="}"&&u--,u>0&&f++;let h=e.slice(c,f),d=f+1;if(e[d]==="#"){let p=d+1;for(;p<e.length&&/[0-9a-zA-Z@_]/.test(e[p]);)p++;let m=e.slice(d+1,p);return{expr:{type:"ArithDynamicBase",baseExpr:h,value:m},pos:p}}if(/[0-9]/.test(e[d])||e[d]==="x"||e[d]==="X"){let p=d;if(e[d]==="x"||e[d]==="X")for(p++;p<e.length&&/[0-9a-fA-F]/.test(e[p]);)p++;else for(;p<e.length&&/[0-9]/.test(e[p]);)p++;let m=e.slice(d,p);return{expr:{type:"ArithDynamicNumber",prefix:h,suffix:m},pos:p}}return s=d,{expr:{type:"ArithBracedExpansion",content:h},pos:s}}if(e[s]==="$"&&s+1<e.length&&/[0-9]/.test(e[s+1])){s++;let c="";for(;s<e.length&&/[0-9]/.test(e[s]);)c+=e[s],s++;return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:!0},pos:s}}if(e[s]==="$"&&s+1<e.length&&/[*@#?\-!$]/.test(e[s+1])){let c=e[s+1];return s+=2,{expr:{type:"ArithSpecialVar",name:c},pos:s}}let l=!1;if(e[s]==="$"&&s+1<e.length&&/[a-zA-Z_]/.test(e[s+1])&&(l=!0,s++),s<e.length&&/[a-zA-Z_]/.test(e[s])){let c="";for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)c+=e[s],s++;if(e[s]==="["&&!r){s++;let u;if(e[s]==="'"||e[s]==='"'){let h=e[s];for(s++,u="";s<e.length&&e[s]!==h;)u+=e[s],s++;e[s]===h&&s++,s=It(e,s),e[s]==="]"&&s++}let f;if(u===void 0){let{expr:h,pos:d}=gr(t,e,s);f=h,s=d,e[s]==="]"&&s++}if(s=It(e,s),e[s]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:s};if(!r){for(let h of fh)if(e.slice(s,s+h.length)===h&&e.slice(s,s+h.length+1)!=="=="){s+=h.length;let{expr:d,pos:p}=Jl(t,e,s);return{expr:{type:"ArithAssignment",operator:h,variable:c,subscript:f,stringKey:u,value:d},pos:p}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:s}}if(s=It(e,s),!r){for(let u of fh)if(e.slice(s,s+u.length)===u&&e.slice(s,s+u.length+1)!=="=="){s+=u.length;let{expr:f,pos:h}=Jl(t,e,s);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:h}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:l},pos:s}}if(e[s]==="#"){let c=s+1;for(;c<e.length&&e[c]!==`
1386
1386
  `;)c++;let u=e.slice(s,c).trim()||"#";return{expr:{type:"ArithSyntaxError",errorToken:u,message:`${u}: syntax error: invalid arithmetic operator (error token is "${u}")`},pos:e.length}}return{expr:{type:"ArithNumber",value:0},pos:s}}var On=I(()=>{"use strict";Me();Nv()});function Fq(t){let e="",n=0;for(;n<t.length;){let r=t[n];if(r<128){e+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<t.length&&(t[n+1]&192)===128&&r>=194){let s=(r&31)<<6|t[n+1]&63;e+=String.fromCharCode(s),n+=2;continue}e+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<t.length&&(t[n+1]&192)===128&&(t[n+2]&192)===128){if(r===224&&t[n+1]<160){e+=String.fromCharCode(r),n++;continue}let s=(r&15)<<12|(t[n+1]&63)<<6|t[n+2]&63;if(s>=55296&&s<=57343){e+=String.fromCharCode(r),n++;continue}e+=String.fromCharCode(s),n+=3;continue}e+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<t.length&&(t[n+1]&192)===128&&(t[n+2]&192)===128&&(t[n+3]&192)===128){if(r===240&&t[n+1]<144){e+=String.fromCharCode(r),n++;continue}let s=(r&7)<<18|(t[n+1]&63)<<12|(t[n+2]&63)<<6|t[n+3]&63;if(s>1114111){e+=String.fromCharCode(r),n++;continue}e+=String.fromCodePoint(s),n+=4;continue}e+=String.fromCharCode(r),n++;continue}e+=String.fromCharCode(r),n++}return e}function Bv(t,e,n){let r=n+1;for(;r<e.length&&/[a-zA-Z0-9_-]/.test(e[r]);)r++;return r}function b6(t,e,n,r,s){let i=1,o=n+1;for(;o<e.length&&i>0;)e[o]===r?i++:e[o]===s&&i--,i>0&&o++;return i===0?o:-1}function ro(t,e,n){let r=n,s=1;for(;r<e.length&&s>0;){let i=e[r];if(i==="\\"&&r+1<e.length){r+=2;continue}if(i==="'"){let o=e.indexOf("'",r+1);if(o!==-1){r=o+1;continue}}if(i==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++;continue}i==="{"?s++:i==="}"&&s--,s>0&&r++}return r}function Uv(t,e,n){let r=n,s=!1;for(;r<e.length;){let i=e[r];if(i==="/"&&s||i==="}")break;if(i==="'"){let o=e.indexOf("'",r+1);if(o!==-1){r=o+1,s=!0;continue}}if(i==='"'){for(r++;r<e.length&&e[r]!=='"';)e[r]==="\\"&&r+1<e.length?r+=2:r++;r<e.length&&r++,s=!0;continue}i==="\\"?(r+=2,s=!0):(r++,s=!0)}return r}function zv(t,e,n){let r=n,s="";for(;r<e.length;){let i=e[r];if(i==="*"||i==="?")s+=i,r++;else if(i==="["){let o=_q(e,r);o===-1?(s+=i,r++):(s+=e.slice(r,o+1),r=o+1)}else break}return{pattern:s,endIndex:r}}function _q(t,e){let n=e+1;for(n<t.length&&t[n]==="^"&&n++,n<t.length&&t[n]==="]"&&n++;n<t.length;){let r=t[n];if(r==="\\"&&n+1<t.length){let s=t[n+1];if(s==='"'||s==="'")return-1;n+=2;continue}if(r==="]")return n;if(r==='"'||r==="$"||r==="`")return-1;if(r==="'"){let s=t.indexOf("'",n+1);if(s!==-1){n=s+1;continue}}if(r==="["&&n+1<t.length&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){n=s+2;continue}}if(r==="["&&n+1<t.length&&(t[n+1]==="."||t[n+1]==="=")){let i=`${t[n+1]}]`,o=t.indexOf(i,n+2);if(o!==-1){n=o+2;continue}}n++}return-1}function Wv(t,e,n){let r="",s=n;for(;s<e.length&&e[s]!=="'";){let i=e[s];if(i==="\\"&&s+1<e.length)switch(e[s+1]){case"n":r+=`
1387
- `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=[],l=s;for(;l+1<e.length&&e[l]==="\\"&&e[l+1]==="x";){let c=e.slice(l+2,l+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)a.push(u),l+=2+c.length;else break}a.length>0?(r+=Fq(a),s=l):(r+="\\x",s+=2);break}case"u":{let a=e.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"c":{if(s+2<e.length){let l=e[s+2].charCodeAt(0)&31;r+=String.fromCharCode(l),s+=3}else r+="\\c",s+=2;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<e.length&&l<s+4&&/[0-7]/.test(e[l]);)a+=e[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<e.length&&e[s]==="'"&&s++,{part:le.literal(r),endIndex:s}}function E6(t,e){let n=e.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ve(t,n)}function Mv(t){let e=[],n="",r=0;for(let s=0;s<t.length;s++){let i=t[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(e.push(n),n=""):n+=i}return e.push(n),e}function jv(t,e,n,r){let s=b6(t,e,n,"{","}");if(s===-1)return null;let i=e.slice(n+1,s),o=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:Mv(i).map(u=>({type:"Word",word:le.word(r(t,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:Mv(i).map(u=>({type:"Word",word:le.word([le.literal(u)])}))},endIndex:s+1}:null}function x6(t,e){let n="";for(let r of e.parts)switch(r.type){case"Literal":n+=r.value;break;case"SingleQuoted":n+=`'${r.value}'`;break;case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;case"TildeExpansion":n+="~",r.user&&(n+=r.user);break;case"BraceExpansion":{n+="{";let s=[];for(let i of r.items)if(i.type==="Range"){let o=i.startStr??String(i.start),a=i.endStr??String(i.end);i.step!==void 0?s.push(`${o}..${a}..${i.step}`):s.push(`${o}..${a}`)}else s.push(x6(t,i.word));s.length===1&&r.items[0].type==="Range"?n+=s[0]:n+=s.join(","),n+="}";break}default:n+=r.type}return n}function qv(t,e){return{[x.LESS]:"<",[x.GREAT]:">",[x.DGREAT]:">>",[x.LESSAND]:"<&",[x.GREATAND]:">&",[x.LESSGREAT]:"<>",[x.CLOBBER]:">|",[x.TLESS]:"<<<",[x.AND_GREAT]:"&>",[x.AND_DGREAT]:"&>>",[x.DLESS]:"<",[x.DLESSDASH]:"<"}[e]||">"}var S6=I(()=>{"use strict";no();On();gi()});function dh(t){let e=t.current(),n=e.type;if(n===x.NUMBER){let r=t.peek(1);return e.end!==r.start?!1:Sv.has(r.type)}if(n===x.FD_VARIABLE){let r=t.peek(1);return Av.has(r.type)}return xv.has(n)}function ph(t){let e=null,n;t.check(x.NUMBER)?e=Number.parseInt(t.advance().value,10):t.check(x.FD_VARIABLE)&&(n=t.advance().value);let r=t.advance(),s=qv(t,r.type);if(r.type===x.DLESS||r.type===x.DLESSDASH)return Dq(t,s,e,r.type===x.DLESSDASH);t.isWord()||t.error("Expected redirection target");let i=t.parseWord();return le.redirection(s,i,e,n)}function Dq(t,e,n,r){t.isWord()||t.error("Expected here-document delimiter");let s=t.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=le.redirection(r?"<<-":"<<",le.hereDoc(i,le.word([]),r,o),n);return t.addPendingHeredoc(a,i,r,o),a}function Vv(t){let e=t.current().line,n=[],r=null,s=[],i=[];for(;t.check(x.ASSIGNMENT_WORD)||dh(t);)t.checkIterationLimit(),t.check(x.ASSIGNMENT_WORD)?n.push(Lq(t)):i.push(ph(t));if(t.isWord())r=t.parseWord();else if(n.length>0&&(t.check(x.DBRACK_START)||t.check(x.DPAREN_START))){let a=t.advance();r=le.word([le.literal(a.value)])}for(;(!t.isStatementEnd()||t.check(x.RBRACE))&&!t.check(x.PIPE,x.PIPE_AMP);)if(t.checkIterationLimit(),dh(t))i.push(ph(t));else if(t.check(x.RBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.check(x.LBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.check(x.DBRACK_END)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.isWord())s.push(t.parseWord());else if(t.check(x.ASSIGNMENT_WORD)){let a=t.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||t.check(x.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||t.expect(x.LPAREN);let h=A6(t);t.expect(x.RPAREN);let d=h.map(m=>x6(t,m)),p=`${f}=(${d.join(" ")})`;s.push(t.parseWordFromString(p,!1,!1))}else s.push(t.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(t.check(x.LPAREN))t.error("syntax error near unexpected token `('");else break;let o=le.simpleCommand(r,s,n,i);return o.line=e,o}function Lq(t){let e=t.expect(x.ASSIGNMENT_WORD),n=e.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||t.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,h=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&t.error(`Invalid assignment: ${n}`),i=n.slice(h,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&t.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=A6(t);t.expect(x.RPAREN);let h=i!==void 0?`${s}[${i}]`:s;return le.assignment(h,null,a,f)}if(l===""&&t.check(x.LPAREN)){let f=t.current();if(e.end===f.start){t.advance();let h=A6(t);t.expect(x.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return le.assignment(d,null,a,h)}}let c=l?t.parseWordFromString(l,e.quoted,e.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return le.assignment(u,c,a,null)}function A6(t){let e=[];for(t.skipNewlines();!t.check(x.RPAREN,x.EOF);)t.checkIterationLimit(),t.isWord()?e.push(t.parseWord()):Mq.has(t.current().type)?t.error(`syntax error near unexpected token \`${t.current().value}'`):t.advance(),t.skipNewlines();return e}var Mq,Gv=I(()=>{"use strict";no();gi();to();S6();Mq=new Set([x.AMP,x.PIPE,x.PIPE_AMP,x.SEMICOLON,x.AND_AND,x.OR_OR,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND])});function v6(t,e){t.expect(x.IF);let n=[],r=t.parseCompoundList();t.expect(x.THEN);let s=t.parseCompoundList();if(s.length===0){let a=t.check(x.FI)?"fi":t.check(x.ELSE)?"else":t.check(x.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${a}'`)}for(n.push({condition:r,body:s});t.check(x.ELIF);){t.advance();let a=t.parseCompoundList();t.expect(x.THEN);let l=t.parseCompoundList();if(l.length===0){let c=t.check(x.FI)?"fi":t.check(x.ELSE)?"else":t.check(x.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${c}'`)}n.push({condition:a,body:l})}let i=null;t.check(x.ELSE)&&(t.advance(),i=t.parseCompoundList(),i.length===0&&t.error("syntax error near unexpected token `fi'")),t.expect(x.FI);let o=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.ifNode(n,i,o)}function C6(t,e){let n=t.expect(x.FOR);if(t.check(x.DPAREN_START))return Uq(t,e,n.line);t.isWord()||t.error("Expected variable name in for loop");let s=t.advance().value,i=null;if(t.skipNewlines(),t.check(x.IN))for(t.advance(),i=[];!t.check(x.SEMICOLON,x.NEWLINE,x.DO,x.EOF)&&t.isWord();)i.push(t.parseWord());t.check(x.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(x.DO);let o=t.parseCompoundList();t.expect(x.DONE);let a=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.forNode(s,i,o,a)}function Uq(t,e,n){t.expect(x.DPAREN_START);let r=null,s=null,i=null,o=["","",""],a=0,l=0;for(;!t.check(x.DPAREN_END,x.EOF);){let f=t.advance();if(f.type===x.SEMICOLON&&l===0){if(a++,a>2)break}else f.value==="("&&l++,f.value===")"&&l--,o[a]+=f.value}t.expect(x.DPAREN_END),o[0].trim()&&(r=Ve(t,o[0].trim())),o[1].trim()&&(s=Ve(t,o[1].trim())),o[2].trim()&&(i=Ve(t,o[2].trim())),t.skipNewlines(),t.check(x.SEMICOLON)&&t.advance(),t.skipNewlines();let c;t.check(x.LBRACE)?(t.advance(),c=t.parseCompoundList(),t.expect(x.RBRACE)):(t.expect(x.DO),c=t.parseCompoundList(),t.expect(x.DONE));let u=e?.skipRedirections?[]:t.parseOptionalRedirections();return{type:"CStyleFor",init:r,condition:s,update:i,body:c,redirections:u,line:n}}function k6(t,e){t.expect(x.WHILE);let n=t.parseCompoundList();t.expect(x.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(x.DONE);let s=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.whileNode(n,r,s)}function N6(t,e){t.expect(x.UNTIL);let n=t.parseCompoundList();t.expect(x.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(x.DONE);let s=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.untilNode(n,r,s)}function T6(t,e){t.expect(x.CASE),t.isWord()||t.error("Expected word after 'case'");let n=t.parseWord();t.skipNewlines(),t.expect(x.IN),t.skipNewlines();let r=[];for(;!t.check(x.ESAC,x.EOF);){t.checkIterationLimit();let i=t.getPos(),o=zq(t);if(o&&r.push(o),t.skipNewlines(),t.getPos()===i&&!o)break}t.expect(x.ESAC);let s=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.caseNode(n,r,s)}function zq(t){t.check(x.LPAREN)&&t.advance();let e=[];for(;t.isWord()&&(e.push(t.parseWord()),t.check(x.PIPE));)t.advance();if(e.length===0)return null;t.expect(x.RPAREN),t.skipNewlines();let n=[];for(;!t.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND,x.ESAC,x.EOF);){t.checkIterationLimit(),t.isWord()&&t.peek(1).type===x.RPAREN&&t.error("syntax error near unexpected token `)'"),t.check(x.LPAREN)&&t.peek(1).type===x.WORD&&t.error(`syntax error near unexpected token \`${t.peek(1).value}'`);let s=t.getPos(),i=t.parseStatement();if(i&&n.push(i),t.skipSeparators(!1),t.getPos()===s&&!i)break}let r=";;";return t.check(x.DSEMI)?(t.advance(),r=";;"):t.check(x.SEMI_AND)?(t.advance(),r=";&"):t.check(x.SEMI_SEMI_AND)&&(t.advance(),r=";;&"),le.caseItem(e,n,r)}function O6(t,e){t.expect(x.LPAREN);let n=t.parseCompoundList();t.expect(x.RPAREN);let r=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.subshell(n,r)}function I6(t,e){t.expect(x.LBRACE);let n=t.parseCompoundList();t.expect(x.RBRACE);let r=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.group(n,r)}var Kv=I(()=>{"use strict";no();On();gi()});function Zv(t){return t.isWord()||t.check(x.LBRACE)||t.check(x.RBRACE)||t.check(x.ASSIGNMENT_WORD)}function Yv(t){if(t.check(x.BANG)&&t.peek(1).type===x.LPAREN){t.advance(),t.advance();let e=1,n="!(";for(;e>0&&!t.check(x.EOF);)if(t.check(x.LPAREN))e++,n+="(",t.advance();else if(t.check(x.RPAREN))e--,e>0&&(n+=")"),t.advance();else if(t.isWord())n+=t.advance().value;else if(t.check(x.PIPE))n+="|",t.advance();else break;return n+=")",t.parseWordFromString(n,!1,!1,!1,!1,!0)}return t.parseWordNoBraceExpansion()}function R6(t){return t.skipNewlines(),Hq(t)}function Hq(t){let e=Qv(t);for(t.skipNewlines();t.check(x.OR_OR);){t.advance(),t.skipNewlines();let n=Qv(t);e={type:"CondOr",left:e,right:n},t.skipNewlines()}return e}function Qv(t){let e=P6(t);for(t.skipNewlines();t.check(x.AND_AND);){t.advance(),t.skipNewlines();let n=P6(t);e={type:"CondAnd",left:e,right:n},t.skipNewlines()}return e}function P6(t){return t.skipNewlines(),t.check(x.BANG)?(t.advance(),t.skipNewlines(),{type:"CondNot",operand:P6(t)}):Vq(t)}function Vq(t){if(t.check(x.LPAREN)){t.advance();let e=R6(t);return t.expect(x.RPAREN),{type:"CondGroup",expression:e}}if(Zv(t)){let e=t.current(),n=e.value;if(jq.includes(n)&&!e.quoted){if(t.advance(),t.check(x.DBRACK_END)&&t.error(`Expected operand after ${n}`),Zv(t)){let i=t.parseWordNoBraceExpansion();return{type:"CondUnary",operator:n,operand:i}}let s=t.current();t.error(`unexpected argument \`${s.value}' to conditional unary operator`)}let r=t.parseWordNoBraceExpansion();if(t.isWord()&&qq.includes(t.current().value)){let s=t.advance().value,i;return s==="=~"?i=Gq(t):s==="=="||s==="!="?i=Yv(t):i=t.parseWordNoBraceExpansion(),{type:"CondBinary",operator:s,left:r,right:i}}if(t.check(x.LESS)){t.advance();let s=t.parseWordNoBraceExpansion();return{type:"CondBinary",operator:"<",left:r,right:s}}if(t.check(x.GREAT)){t.advance();let s=t.parseWordNoBraceExpansion();return{type:"CondBinary",operator:">",left:r,right:s}}if(t.isWord()&&t.current().value==="="){t.advance();let s=Yv(t);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}t.error("Expected conditional expression")}function Gq(t){let e=[],n=0,r=-1,s=t.getInput(),i=()=>t.check(x.DBRACK_END)||t.check(x.AND_AND)||t.check(x.OR_OR)||t.check(x.NEWLINE)||t.check(x.EOF);for(;!i();){let o=t.current(),a=r>=0&&o.start>r;if(n===0&&a)break;if(n>0&&a){let l=s.slice(r,o.start);e.push({type:"Literal",value:l})}if(t.isWord()||t.check(x.ASSIGNMENT_WORD)){let l=t.parseWordForRegex();e.push(...l.parts),r=t.peek(-1).end}else if(t.check(x.LPAREN)){let l=t.advance();e.push({type:"Literal",value:"("}),n++,r=l.end}else if(t.check(x.DPAREN_START)){let l=t.advance();e.push({type:"Literal",value:"(("}),n+=2,r=l.end}else if(t.check(x.DPAREN_END))if(n>=2){let l=t.advance();e.push({type:"Literal",value:"))"}),n-=2,r=l.end}else{if(n===1)break;break}else if(t.check(x.RPAREN))if(n>0){let l=t.advance();e.push({type:"Literal",value:")"}),n--,r=l.end}else break;else if(t.check(x.PIPE)){let l=t.advance();e.push({type:"Literal",value:"|"}),r=l.end}else if(t.check(x.SEMICOLON))if(n>0){let l=t.advance();e.push({type:"Literal",value:";"}),r=l.end}else break;else if(n>0&&t.check(x.LESS)){let l=t.advance();e.push({type:"Literal",value:"<"}),r=l.end}else if(n>0&&t.check(x.GREAT)){let l=t.advance();e.push({type:"Literal",value:">"}),r=l.end}else if(n>0&&t.check(x.DGREAT)){let l=t.advance();e.push({type:"Literal",value:">>"}),r=l.end}else if(n>0&&t.check(x.DLESS)){let l=t.advance();e.push({type:"Literal",value:"<<"}),r=l.end}else if(n>0&&t.check(x.LESSAND)){let l=t.advance();e.push({type:"Literal",value:"<&"}),r=l.end}else if(n>0&&t.check(x.GREATAND)){let l=t.advance();e.push({type:"Literal",value:">&"}),r=l.end}else if(n>0&&t.check(x.LESSGREAT)){let l=t.advance();e.push({type:"Literal",value:"<>"}),r=l.end}else if(n>0&&t.check(x.CLOBBER)){let l=t.advance();e.push({type:"Literal",value:">|"}),r=l.end}else if(n>0&&t.check(x.TLESS)){let l=t.advance();e.push({type:"Literal",value:"<<<"}),r=l.end}else if(n>0&&t.check(x.AMP)){let l=t.advance();e.push({type:"Literal",value:"&"}),r=l.end}else if(n>0&&t.check(x.LBRACE)){let l=t.advance();e.push({type:"Literal",value:"{"}),r=l.end}else if(n>0&&t.check(x.RBRACE)){let l=t.advance();e.push({type:"Literal",value:"}"}),r=l.end}else break}return e.length===0&&t.error("Expected regex pattern after =~"),{type:"Word",parts:e}}var jq,qq,Xv=I(()=>{"use strict";gi();jq=["-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"],qq=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function ec(t){return t.length>0?t:[le.literal("")]}function Zq(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if("@*+?!".includes(s)&&r+1<t.length&&t[r+1]==="("){r++,n++,r++;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function Yq(t,e,n){let r=n+1,s=e[r];if("@*#?$!-0123456789".includes(s))return{part:le.parameterExpansion(s),endIndex:r+1};let i="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)i+=e[r],r++;return{part:le.parameterExpansion(i),endIndex:r}}function Qq(t,e,n,r=!1){let s=n+2,i=!1;e[s]==="!"&&(i=!0,s++);let o=!1;e[s]==="#"&&!/[}:#%/^,]/.test(e[s+1]||"}")&&(o=!0,s++);let a="",l=e[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(e[s+1]||""))a=l,s++;else for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)a+=e[s],s++;if(e[s]==="["){let u=b6(t,e,s,"[","]");if(a+=e.slice(s,u+1),s=u+1,e[s]==="["){let f=1,h=s;for(;h<e.length&&f>0;)e[h]==="{"?f++:e[h]==="}"&&f--,f>0&&h++;let d=e.slice(n+2,h);return{part:le.parameterExpansion("",{type:"BadSubstitution",text:d}),endIndex:h+1}}}if(a===""&&!i&&!o&&e[s]!=="}"){let u=1,f=s;for(;f<e.length&&u>0;)e[f]==="{"?u++:e[f]==="}"&&u--,u>0&&f++;if(u>0)throw new un("unexpected EOF while looking for matching '}'",0,0);let h=e.slice(n+2,f);return{part:le.parameterExpansion("",{type:"BadSubstitution",text:h}),endIndex:f+1}}let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<e.length&&e[s]!=="}"&&/[:=\-+?#%/^,@]/.test(e[s])){let f=$6(t,e,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(e[s]==="*"||e[s]==="@"&&!/[QPaAEKkuUL]/.test(e[s+1]||"")){let f=e[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else if(s<e.length&&e[s]!=="}"&&/[:=\-+?#%/^,@]/.test(e[s])){let f=$6(t,e,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(o)if(e[s]===":")for(c={type:"LengthSliceError"};s<e.length&&e[s]!=="}";)s++;else e[s]!=="}"&&/[-+=?]/.test(e[s])?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):e[s]==="/"?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<e.length&&e[s]!=="}"){let u=$6(t,e,s,a,r);c=u.operation,s=u.endIndex}if(s<e.length&&e[s]!=="}"){let u=e[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<e.length&&e[f]!=="}";)f++;let h=e.slice(n,f+1);t.error(`\${${h.slice(2,-1)}}: bad substitution`)}}for(;s<e.length&&e[s]!=="}";)s++;if(s>=e.length)throw new un("unexpected EOF while looking for matching '}'",0,0);return{part:le.parameterExpansion(a,c),endIndex:s+1}}function $6(t,e,n,r,s=!1){let i=n,o=e[i],a=e[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let y=ro(t,e,i),w=e.slice(i,y),b=yi(t,w,!1,!1,!0,!1,s,!1,!1,!0),E=le.word(ec(b));if(l==="-")return{operation:{type:"DefaultValue",word:E,checkEmpty:!0},endIndex:y};if(l==="=")return{operation:{type:"AssignDefault",word:E,checkEmpty:!0},endIndex:y};if(l==="?")return{operation:{type:"ErrorIfUnset",word:E,checkEmpty:!0},endIndex:y};if(l==="+")return{operation:{type:"UseAlternative",word:E,checkEmpty:!0},endIndex:y}}i++;let c=ro(t,e,i),u=e.slice(i,c),f=-1,h=0,d=0;for(let g=0;g<u.length;g++){let y=u[g];if(y==="("||y==="[")h++;else if(y===")"||y==="]")h--;else if(y==="?"&&h===0)d++;else if(y===":"&&h===0)if(d>0)d--;else{f=g;break}}let p=f>=0?u.slice(0,f):u,m=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:E6(t,p),length:m!==null?E6(t,m):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=ro(t,e,i),c=e.slice(i,l),u=yi(t,c,!1,!1,!0,!1,s,!1,!1,!0),f=le.word(ec(u));if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=ro(t,e,i),f=e.slice(i,u),h=yi(t,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:le.word(ec(h)),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;e[i]==="#"?(c="start",i++):e[i]==="%"&&(c="end",i++);let u;c!==null&&(e[i]==="/"||e[i]==="}")?u=i:u=Uv(t,e,i);let f=e.slice(i,u),h=yi(t,f,!1,!1,!1),d=le.word(ec(h)),p=null,m=u;if(e[u]==="/"){let g=u+1,y=ro(t,e,g),w=e.slice(g,y),b=yi(t,w,!1,!1,!1);p=le.word(ec(b)),m=y}return{operation:{type:"PatternReplacement",pattern:d,replacement:p,all:l,anchor:c},endIndex:m}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=ro(t,e,i),f=e.slice(i,u),h=f?le.word([le.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:h},endIndex:u}}return o==="@"&&/[QPaAEKkuUL]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function F6(t,e,n,r=!1){let s=n+1;if(s>=e.length)return{part:le.literal("$"),endIndex:s};let i=e[s];if(i==="("&&e[s+1]==="(")return t.isDollarDparenSubshell(e,n)?t.parseCommandSubstitution(e,n):t.parseArithmeticExpansion(e,n);if(i==="["){let o=1,a=s+1;for(;a<e.length&&o>0;)e[a]==="["?o++:e[a]==="]"&&o--,o>0&&a++;if(o===0){let l=e.slice(s+1,a),c=Ve(t,l);return{part:le.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?t.parseCommandSubstitution(e,n):i==="{"?Qq(t,e,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?Yq(t,e,n):{part:le.literal("$"),endIndex:s}}function Jv(t,e){let n=[],r=0,s="",i=()=>{s&&(n.push(le.literal(s)),s="")};for(;r<e.length;){let o=e[r];if(o==="\\"&&r+1<e.length){let a=e[r+1];if(a==="$"||a==="`"||a==='"'||a==="\\"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=F6(t,e,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=t.parseBacktickSubstitution(e,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function Xq(t,e,n){let r=[],s=n,i="",o=()=>{i&&(r.push(le.literal(i)),i="")};for(;s<e.length&&e[s]!=='"';){let a=e[s];if(a==="\\"&&s+1<e.length){let l=e[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=F6(t,e,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=t.parseBacktickSubstitution(e,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:le.doubleQuoted(r),endIndex:s}}function yi(t,e,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1){if(r)return[le.singleQuoted(e)];if(n){let p=Jv(t,e);return[le.doubleQuoted(p)]}if(e.length>=2&&e[0]==='"'&&e[e.length-1]==='"'){let p=e.slice(1,-1),m=!1;for(let g=0;g<p.length;g++){if(p[g]==='"'){m=!0;break}p[g]==="\\"&&g+1<p.length&&g++}if(!m){let g=Jv(t,p);return[le.doubleQuoted(g)]}}let u=[],f=0,h="",d=()=>{h&&(u.push(le.literal(h)),h="")};for(;f<e.length;){let p=e[f];if(p==="\\"&&f+1<e.length){let m=e[f+1];if(l){d(),u.push(le.escaped(m)),f+=2;continue}let g=i?m==="$"||m==="`"||m===`
1387
+ `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=[],l=s;for(;l+1<e.length&&e[l]==="\\"&&e[l+1]==="x";){let c=e.slice(l+2,l+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)a.push(u),l+=2+c.length;else break}a.length>0?(r+=Fq(a),s=l):(r+="\\x",s+=2);break}case"u":{let a=e.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"c":{if(s+2<e.length){let l=e[s+2].charCodeAt(0)&31;r+=String.fromCharCode(l),s+=3}else r+="\\c",s+=2;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<e.length&&l<s+4&&/[0-7]/.test(e[l]);)a+=e[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<e.length&&e[s]==="'"&&s++,{part:le.literal(r),endIndex:s}}function E6(t,e){let n=e.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ge(t,n)}function Mv(t){let e=[],n="",r=0;for(let s=0;s<t.length;s++){let i=t[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(e.push(n),n=""):n+=i}return e.push(n),e}function jv(t,e,n,r){let s=b6(t,e,n,"{","}");if(s===-1)return null;let i=e.slice(n+1,s),o=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:Mv(i).map(u=>({type:"Word",word:le.word(r(t,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:Mv(i).map(u=>({type:"Word",word:le.word([le.literal(u)])}))},endIndex:s+1}:null}function x6(t,e){let n="";for(let r of e.parts)switch(r.type){case"Literal":n+=r.value;break;case"SingleQuoted":n+=`'${r.value}'`;break;case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;case"TildeExpansion":n+="~",r.user&&(n+=r.user);break;case"BraceExpansion":{n+="{";let s=[];for(let i of r.items)if(i.type==="Range"){let o=i.startStr??String(i.start),a=i.endStr??String(i.end);i.step!==void 0?s.push(`${o}..${a}..${i.step}`):s.push(`${o}..${a}`)}else s.push(x6(t,i.word));s.length===1&&r.items[0].type==="Range"?n+=s[0]:n+=s.join(","),n+="}";break}default:n+=r.type}return n}function qv(t,e){return{[x.LESS]:"<",[x.GREAT]:">",[x.DGREAT]:">>",[x.LESSAND]:"<&",[x.GREATAND]:">&",[x.LESSGREAT]:"<>",[x.CLOBBER]:">|",[x.TLESS]:"<<<",[x.AND_GREAT]:"&>",[x.AND_DGREAT]:"&>>",[x.DLESS]:"<",[x.DLESSDASH]:"<"}[e]||">"}var S6=I(()=>{"use strict";no();On();gi()});function dh(t){let e=t.current(),n=e.type;if(n===x.NUMBER){let r=t.peek(1);return e.end!==r.start?!1:Sv.has(r.type)}if(n===x.FD_VARIABLE){let r=t.peek(1);return Av.has(r.type)}return xv.has(n)}function ph(t){let e=null,n;t.check(x.NUMBER)?e=Number.parseInt(t.advance().value,10):t.check(x.FD_VARIABLE)&&(n=t.advance().value);let r=t.advance(),s=qv(t,r.type);if(r.type===x.DLESS||r.type===x.DLESSDASH)return Dq(t,s,e,r.type===x.DLESSDASH);t.isWord()||t.error("Expected redirection target");let i=t.parseWord();return le.redirection(s,i,e,n)}function Dq(t,e,n,r){t.isWord()||t.error("Expected here-document delimiter");let s=t.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=le.redirection(r?"<<-":"<<",le.hereDoc(i,le.word([]),r,o),n);return t.addPendingHeredoc(a,i,r,o),a}function Vv(t){let e=t.current().line,n=[],r=null,s=[],i=[];for(;t.check(x.ASSIGNMENT_WORD)||dh(t);)t.checkIterationLimit(),t.check(x.ASSIGNMENT_WORD)?n.push(Lq(t)):i.push(ph(t));if(t.isWord())r=t.parseWord();else if(n.length>0&&(t.check(x.DBRACK_START)||t.check(x.DPAREN_START))){let a=t.advance();r=le.word([le.literal(a.value)])}for(;(!t.isStatementEnd()||t.check(x.RBRACE))&&!t.check(x.PIPE,x.PIPE_AMP);)if(t.checkIterationLimit(),dh(t))i.push(ph(t));else if(t.check(x.RBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.check(x.LBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.check(x.DBRACK_END)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.isWord())s.push(t.parseWord());else if(t.check(x.ASSIGNMENT_WORD)){let a=t.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||t.check(x.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||t.expect(x.LPAREN);let h=A6(t);t.expect(x.RPAREN);let d=h.map(m=>x6(t,m)),p=`${f}=(${d.join(" ")})`;s.push(t.parseWordFromString(p,!1,!1))}else s.push(t.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(t.check(x.LPAREN))t.error("syntax error near unexpected token `('");else break;let o=le.simpleCommand(r,s,n,i);return o.line=e,o}function Lq(t){let e=t.expect(x.ASSIGNMENT_WORD),n=e.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||t.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,h=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&t.error(`Invalid assignment: ${n}`),i=n.slice(h,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&t.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=A6(t);t.expect(x.RPAREN);let h=i!==void 0?`${s}[${i}]`:s;return le.assignment(h,null,a,f)}if(l===""&&t.check(x.LPAREN)){let f=t.current();if(e.end===f.start){t.advance();let h=A6(t);t.expect(x.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return le.assignment(d,null,a,h)}}let c=l?t.parseWordFromString(l,e.quoted,e.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return le.assignment(u,c,a,null)}function A6(t){let e=[];for(t.skipNewlines();!t.check(x.RPAREN,x.EOF);)t.checkIterationLimit(),t.isWord()?e.push(t.parseWord()):Mq.has(t.current().type)?t.error(`syntax error near unexpected token \`${t.current().value}'`):t.advance(),t.skipNewlines();return e}var Mq,Gv=I(()=>{"use strict";no();gi();to();S6();Mq=new Set([x.AMP,x.PIPE,x.PIPE_AMP,x.SEMICOLON,x.AND_AND,x.OR_OR,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND])});function v6(t,e){t.expect(x.IF);let n=[],r=t.parseCompoundList();t.expect(x.THEN);let s=t.parseCompoundList();if(s.length===0){let a=t.check(x.FI)?"fi":t.check(x.ELSE)?"else":t.check(x.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${a}'`)}for(n.push({condition:r,body:s});t.check(x.ELIF);){t.advance();let a=t.parseCompoundList();t.expect(x.THEN);let l=t.parseCompoundList();if(l.length===0){let c=t.check(x.FI)?"fi":t.check(x.ELSE)?"else":t.check(x.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${c}'`)}n.push({condition:a,body:l})}let i=null;t.check(x.ELSE)&&(t.advance(),i=t.parseCompoundList(),i.length===0&&t.error("syntax error near unexpected token `fi'")),t.expect(x.FI);let o=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.ifNode(n,i,o)}function C6(t,e){let n=t.expect(x.FOR);if(t.check(x.DPAREN_START))return Uq(t,e,n.line);t.isWord()||t.error("Expected variable name in for loop");let s=t.advance().value,i=null;if(t.skipNewlines(),t.check(x.IN))for(t.advance(),i=[];!t.check(x.SEMICOLON,x.NEWLINE,x.DO,x.EOF)&&t.isWord();)i.push(t.parseWord());t.check(x.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(x.DO);let o=t.parseCompoundList();t.expect(x.DONE);let a=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.forNode(s,i,o,a)}function Uq(t,e,n){t.expect(x.DPAREN_START);let r=null,s=null,i=null,o=["","",""],a=0,l=0;for(;!t.check(x.DPAREN_END,x.EOF);){let f=t.advance();if(f.type===x.SEMICOLON&&l===0){if(a++,a>2)break}else f.value==="("&&l++,f.value===")"&&l--,o[a]+=f.value}t.expect(x.DPAREN_END),o[0].trim()&&(r=Ge(t,o[0].trim())),o[1].trim()&&(s=Ge(t,o[1].trim())),o[2].trim()&&(i=Ge(t,o[2].trim())),t.skipNewlines(),t.check(x.SEMICOLON)&&t.advance(),t.skipNewlines();let c;t.check(x.LBRACE)?(t.advance(),c=t.parseCompoundList(),t.expect(x.RBRACE)):(t.expect(x.DO),c=t.parseCompoundList(),t.expect(x.DONE));let u=e?.skipRedirections?[]:t.parseOptionalRedirections();return{type:"CStyleFor",init:r,condition:s,update:i,body:c,redirections:u,line:n}}function k6(t,e){t.expect(x.WHILE);let n=t.parseCompoundList();t.expect(x.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(x.DONE);let s=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.whileNode(n,r,s)}function N6(t,e){t.expect(x.UNTIL);let n=t.parseCompoundList();t.expect(x.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(x.DONE);let s=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.untilNode(n,r,s)}function T6(t,e){t.expect(x.CASE),t.isWord()||t.error("Expected word after 'case'");let n=t.parseWord();t.skipNewlines(),t.expect(x.IN),t.skipNewlines();let r=[];for(;!t.check(x.ESAC,x.EOF);){t.checkIterationLimit();let i=t.getPos(),o=zq(t);if(o&&r.push(o),t.skipNewlines(),t.getPos()===i&&!o)break}t.expect(x.ESAC);let s=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.caseNode(n,r,s)}function zq(t){t.check(x.LPAREN)&&t.advance();let e=[];for(;t.isWord()&&(e.push(t.parseWord()),t.check(x.PIPE));)t.advance();if(e.length===0)return null;t.expect(x.RPAREN),t.skipNewlines();let n=[];for(;!t.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND,x.ESAC,x.EOF);){t.checkIterationLimit(),t.isWord()&&t.peek(1).type===x.RPAREN&&t.error("syntax error near unexpected token `)'"),t.check(x.LPAREN)&&t.peek(1).type===x.WORD&&t.error(`syntax error near unexpected token \`${t.peek(1).value}'`);let s=t.getPos(),i=t.parseStatement();if(i&&n.push(i),t.skipSeparators(!1),t.getPos()===s&&!i)break}let r=";;";return t.check(x.DSEMI)?(t.advance(),r=";;"):t.check(x.SEMI_AND)?(t.advance(),r=";&"):t.check(x.SEMI_SEMI_AND)&&(t.advance(),r=";;&"),le.caseItem(e,n,r)}function O6(t,e){t.expect(x.LPAREN);let n=t.parseCompoundList();t.expect(x.RPAREN);let r=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.subshell(n,r)}function I6(t,e){t.expect(x.LBRACE);let n=t.parseCompoundList();t.expect(x.RBRACE);let r=e?.skipRedirections?[]:t.parseOptionalRedirections();return le.group(n,r)}var Kv=I(()=>{"use strict";no();On();gi()});function Zv(t){return t.isWord()||t.check(x.LBRACE)||t.check(x.RBRACE)||t.check(x.ASSIGNMENT_WORD)}function Yv(t){if(t.check(x.BANG)&&t.peek(1).type===x.LPAREN){t.advance(),t.advance();let e=1,n="!(";for(;e>0&&!t.check(x.EOF);)if(t.check(x.LPAREN))e++,n+="(",t.advance();else if(t.check(x.RPAREN))e--,e>0&&(n+=")"),t.advance();else if(t.isWord())n+=t.advance().value;else if(t.check(x.PIPE))n+="|",t.advance();else break;return n+=")",t.parseWordFromString(n,!1,!1,!1,!1,!0)}return t.parseWordNoBraceExpansion()}function R6(t){return t.skipNewlines(),Hq(t)}function Hq(t){let e=Qv(t);for(t.skipNewlines();t.check(x.OR_OR);){t.advance(),t.skipNewlines();let n=Qv(t);e={type:"CondOr",left:e,right:n},t.skipNewlines()}return e}function Qv(t){let e=P6(t);for(t.skipNewlines();t.check(x.AND_AND);){t.advance(),t.skipNewlines();let n=P6(t);e={type:"CondAnd",left:e,right:n},t.skipNewlines()}return e}function P6(t){return t.skipNewlines(),t.check(x.BANG)?(t.advance(),t.skipNewlines(),{type:"CondNot",operand:P6(t)}):Vq(t)}function Vq(t){if(t.check(x.LPAREN)){t.advance();let e=R6(t);return t.expect(x.RPAREN),{type:"CondGroup",expression:e}}if(Zv(t)){let e=t.current(),n=e.value;if(jq.includes(n)&&!e.quoted){if(t.advance(),t.check(x.DBRACK_END)&&t.error(`Expected operand after ${n}`),Zv(t)){let i=t.parseWordNoBraceExpansion();return{type:"CondUnary",operator:n,operand:i}}let s=t.current();t.error(`unexpected argument \`${s.value}' to conditional unary operator`)}let r=t.parseWordNoBraceExpansion();if(t.isWord()&&qq.includes(t.current().value)){let s=t.advance().value,i;return s==="=~"?i=Gq(t):s==="=="||s==="!="?i=Yv(t):i=t.parseWordNoBraceExpansion(),{type:"CondBinary",operator:s,left:r,right:i}}if(t.check(x.LESS)){t.advance();let s=t.parseWordNoBraceExpansion();return{type:"CondBinary",operator:"<",left:r,right:s}}if(t.check(x.GREAT)){t.advance();let s=t.parseWordNoBraceExpansion();return{type:"CondBinary",operator:">",left:r,right:s}}if(t.isWord()&&t.current().value==="="){t.advance();let s=Yv(t);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}t.error("Expected conditional expression")}function Gq(t){let e=[],n=0,r=-1,s=t.getInput(),i=()=>t.check(x.DBRACK_END)||t.check(x.AND_AND)||t.check(x.OR_OR)||t.check(x.NEWLINE)||t.check(x.EOF);for(;!i();){let o=t.current(),a=r>=0&&o.start>r;if(n===0&&a)break;if(n>0&&a){let l=s.slice(r,o.start);e.push({type:"Literal",value:l})}if(t.isWord()||t.check(x.ASSIGNMENT_WORD)){let l=t.parseWordForRegex();e.push(...l.parts),r=t.peek(-1).end}else if(t.check(x.LPAREN)){let l=t.advance();e.push({type:"Literal",value:"("}),n++,r=l.end}else if(t.check(x.DPAREN_START)){let l=t.advance();e.push({type:"Literal",value:"(("}),n+=2,r=l.end}else if(t.check(x.DPAREN_END))if(n>=2){let l=t.advance();e.push({type:"Literal",value:"))"}),n-=2,r=l.end}else{if(n===1)break;break}else if(t.check(x.RPAREN))if(n>0){let l=t.advance();e.push({type:"Literal",value:")"}),n--,r=l.end}else break;else if(t.check(x.PIPE)){let l=t.advance();e.push({type:"Literal",value:"|"}),r=l.end}else if(t.check(x.SEMICOLON))if(n>0){let l=t.advance();e.push({type:"Literal",value:";"}),r=l.end}else break;else if(n>0&&t.check(x.LESS)){let l=t.advance();e.push({type:"Literal",value:"<"}),r=l.end}else if(n>0&&t.check(x.GREAT)){let l=t.advance();e.push({type:"Literal",value:">"}),r=l.end}else if(n>0&&t.check(x.DGREAT)){let l=t.advance();e.push({type:"Literal",value:">>"}),r=l.end}else if(n>0&&t.check(x.DLESS)){let l=t.advance();e.push({type:"Literal",value:"<<"}),r=l.end}else if(n>0&&t.check(x.LESSAND)){let l=t.advance();e.push({type:"Literal",value:"<&"}),r=l.end}else if(n>0&&t.check(x.GREATAND)){let l=t.advance();e.push({type:"Literal",value:">&"}),r=l.end}else if(n>0&&t.check(x.LESSGREAT)){let l=t.advance();e.push({type:"Literal",value:"<>"}),r=l.end}else if(n>0&&t.check(x.CLOBBER)){let l=t.advance();e.push({type:"Literal",value:">|"}),r=l.end}else if(n>0&&t.check(x.TLESS)){let l=t.advance();e.push({type:"Literal",value:"<<<"}),r=l.end}else if(n>0&&t.check(x.AMP)){let l=t.advance();e.push({type:"Literal",value:"&"}),r=l.end}else if(n>0&&t.check(x.LBRACE)){let l=t.advance();e.push({type:"Literal",value:"{"}),r=l.end}else if(n>0&&t.check(x.RBRACE)){let l=t.advance();e.push({type:"Literal",value:"}"}),r=l.end}else break}return e.length===0&&t.error("Expected regex pattern after =~"),{type:"Word",parts:e}}var jq,qq,Xv=I(()=>{"use strict";gi();jq=["-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"],qq=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function ec(t){return t.length>0?t:[le.literal("")]}function Zq(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if("@*+?!".includes(s)&&r+1<t.length&&t[r+1]==="("){r++,n++,r++;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function Yq(t,e,n){let r=n+1,s=e[r];if("@*#?$!-0123456789".includes(s))return{part:le.parameterExpansion(s),endIndex:r+1};let i="";for(;r<e.length&&/[a-zA-Z0-9_]/.test(e[r]);)i+=e[r],r++;return{part:le.parameterExpansion(i),endIndex:r}}function Qq(t,e,n,r=!1){let s=n+2,i=!1;e[s]==="!"&&(i=!0,s++);let o=!1;e[s]==="#"&&!/[}:#%/^,]/.test(e[s+1]||"}")&&(o=!0,s++);let a="",l=e[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(e[s+1]||""))a=l,s++;else for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)a+=e[s],s++;if(e[s]==="["){let u=b6(t,e,s,"[","]");if(a+=e.slice(s,u+1),s=u+1,e[s]==="["){let f=1,h=s;for(;h<e.length&&f>0;)e[h]==="{"?f++:e[h]==="}"&&f--,f>0&&h++;let d=e.slice(n+2,h);return{part:le.parameterExpansion("",{type:"BadSubstitution",text:d}),endIndex:h+1}}}if(a===""&&!i&&!o&&e[s]!=="}"){let u=1,f=s;for(;f<e.length&&u>0;)e[f]==="{"?u++:e[f]==="}"&&u--,u>0&&f++;if(u>0)throw new un("unexpected EOF while looking for matching '}'",0,0);let h=e.slice(n+2,f);return{part:le.parameterExpansion("",{type:"BadSubstitution",text:h}),endIndex:f+1}}let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<e.length&&e[s]!=="}"&&/[:=\-+?#%/^,@]/.test(e[s])){let f=$6(t,e,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(e[s]==="*"||e[s]==="@"&&!/[QPaAEKkuUL]/.test(e[s+1]||"")){let f=e[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else if(s<e.length&&e[s]!=="}"&&/[:=\-+?#%/^,@]/.test(e[s])){let f=$6(t,e,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(o)if(e[s]===":")for(c={type:"LengthSliceError"};s<e.length&&e[s]!=="}";)s++;else e[s]!=="}"&&/[-+=?]/.test(e[s])?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):e[s]==="/"?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<e.length&&e[s]!=="}"){let u=$6(t,e,s,a,r);c=u.operation,s=u.endIndex}if(s<e.length&&e[s]!=="}"){let u=e[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<e.length&&e[f]!=="}";)f++;let h=e.slice(n,f+1);t.error(`\${${h.slice(2,-1)}}: bad substitution`)}}for(;s<e.length&&e[s]!=="}";)s++;if(s>=e.length)throw new un("unexpected EOF while looking for matching '}'",0,0);return{part:le.parameterExpansion(a,c),endIndex:s+1}}function $6(t,e,n,r,s=!1){let i=n,o=e[i],a=e[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let y=ro(t,e,i),w=e.slice(i,y),b=yi(t,w,!1,!1,!0,!1,s,!1,!1,!0),E=le.word(ec(b));if(l==="-")return{operation:{type:"DefaultValue",word:E,checkEmpty:!0},endIndex:y};if(l==="=")return{operation:{type:"AssignDefault",word:E,checkEmpty:!0},endIndex:y};if(l==="?")return{operation:{type:"ErrorIfUnset",word:E,checkEmpty:!0},endIndex:y};if(l==="+")return{operation:{type:"UseAlternative",word:E,checkEmpty:!0},endIndex:y}}i++;let c=ro(t,e,i),u=e.slice(i,c),f=-1,h=0,d=0;for(let g=0;g<u.length;g++){let y=u[g];if(y==="("||y==="[")h++;else if(y===")"||y==="]")h--;else if(y==="?"&&h===0)d++;else if(y===":"&&h===0)if(d>0)d--;else{f=g;break}}let p=f>=0?u.slice(0,f):u,m=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:E6(t,p),length:m!==null?E6(t,m):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=ro(t,e,i),c=e.slice(i,l),u=yi(t,c,!1,!1,!0,!1,s,!1,!1,!0),f=le.word(ec(u));if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=ro(t,e,i),f=e.slice(i,u),h=yi(t,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:le.word(ec(h)),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;e[i]==="#"?(c="start",i++):e[i]==="%"&&(c="end",i++);let u;c!==null&&(e[i]==="/"||e[i]==="}")?u=i:u=Uv(t,e,i);let f=e.slice(i,u),h=yi(t,f,!1,!1,!1),d=le.word(ec(h)),p=null,m=u;if(e[u]==="/"){let g=u+1,y=ro(t,e,g),w=e.slice(g,y),b=yi(t,w,!1,!1,!1);p=le.word(ec(b)),m=y}return{operation:{type:"PatternReplacement",pattern:d,replacement:p,all:l,anchor:c},endIndex:m}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=ro(t,e,i),f=e.slice(i,u),h=f?le.word([le.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:h},endIndex:u}}return o==="@"&&/[QPaAEKkuUL]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function F6(t,e,n,r=!1){let s=n+1;if(s>=e.length)return{part:le.literal("$"),endIndex:s};let i=e[s];if(i==="("&&e[s+1]==="(")return t.isDollarDparenSubshell(e,n)?t.parseCommandSubstitution(e,n):t.parseArithmeticExpansion(e,n);if(i==="["){let o=1,a=s+1;for(;a<e.length&&o>0;)e[a]==="["?o++:e[a]==="]"&&o--,o>0&&a++;if(o===0){let l=e.slice(s+1,a),c=Ge(t,l);return{part:le.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?t.parseCommandSubstitution(e,n):i==="{"?Qq(t,e,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?Yq(t,e,n):{part:le.literal("$"),endIndex:s}}function Jv(t,e){let n=[],r=0,s="",i=()=>{s&&(n.push(le.literal(s)),s="")};for(;r<e.length;){let o=e[r];if(o==="\\"&&r+1<e.length){let a=e[r+1];if(a==="$"||a==="`"||a==='"'||a==="\\"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=F6(t,e,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=t.parseBacktickSubstitution(e,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function Xq(t,e,n){let r=[],s=n,i="",o=()=>{i&&(r.push(le.literal(i)),i="")};for(;s<e.length&&e[s]!=='"';){let a=e[s];if(a==="\\"&&s+1<e.length){let l=e[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=F6(t,e,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=t.parseBacktickSubstitution(e,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:le.doubleQuoted(r),endIndex:s}}function yi(t,e,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1){if(r)return[le.singleQuoted(e)];if(n){let p=Jv(t,e);return[le.doubleQuoted(p)]}if(e.length>=2&&e[0]==='"'&&e[e.length-1]==='"'){let p=e.slice(1,-1),m=!1;for(let g=0;g<p.length;g++){if(p[g]==='"'){m=!0;break}p[g]==="\\"&&g+1<p.length&&g++}if(!m){let g=Jv(t,p);return[le.doubleQuoted(g)]}}let u=[],f=0,h="",d=()=>{h&&(u.push(le.literal(h)),h="")};for(;f<e.length;){let p=e[f];if(p==="\\"&&f+1<e.length){let m=e[f+1];if(l){d(),u.push(le.escaped(m)),f+=2;continue}let g=i?m==="$"||m==="`"||m===`
1388
1388
  `:m==="$"||m==="`"||m==='"'||m==="'"||m===`
1389
1389
  `||c&&m==="}",y=o?"*?[]\\".includes(m):"*?[]\\(){}.^+".includes(m);g?h+=m:y?(d(),u.push(le.escaped(m))):h+=`\\${m}`,f+=2;continue}if(p==="'"&&!o&&!i){d();let m=e.indexOf("'",f+1);if(m===-1){h+=e.slice(f);break}u.push(le.singleQuoted(e.slice(f+1,m))),f=m+1;continue}if(p==='"'&&!i){d();let{part:m,endIndex:g}=Xq(t,e,f+1);u.push(m),f=g+1;continue}if(p==="$"&&e[f+1]==="'"){d();let{part:m,endIndex:g}=Wv(t,e,f+2);u.push(m),f=g;continue}if(p==="$"){d();let{part:m,endIndex:g}=F6(t,e,f);m&&u.push(m),f=g;continue}if(p==="`"){d();let{part:m,endIndex:g}=t.parseBacktickSubstitution(e,f);u.push(m),f=g;continue}if(p==="~"){let m=f>0?e[f-1]:"";if(f===0||m==="="||s&&m===":"){let y=Bv(t,e,f),w=e[y];if(w===void 0||w==="/"||w===":"){d();let b=e.slice(f+1,y)||null;u.push({type:"TildeExpansion",user:b}),f=y;continue}}}if("@*+?!".includes(p)&&f+1<e.length&&e[f+1]==="("){let m=Zq(e,f+1);if(m!==-1){d();let g=e.slice(f,m+1);u.push({type:"Glob",pattern:g}),f=m+1;continue}}if(p==="*"||p==="?"||p==="["){d();let{pattern:m,endIndex:g}=zv(t,e,f);u.push({type:"Glob",pattern:m}),f=g;continue}if(p==="{"&&!s&&!a&&!i){let m=jv(t,e,f,yi);if(m){d(),u.push(m.part),f=m.endIndex;continue}}h+=p,f++}return d(),u}var eC=I(()=>{"use strict";no();On();to();S6()});function tC(t,e){let n=t.length,r=e+3,s=2,i=!1,o=!1;for(;r<n&&s>0;){let a=t[r];if(i){a==="'"&&(i=!1),r++;continue}if(o){if(a==="\\"){r+=2;continue}a==='"'&&(o=!1),r++;continue}if(a==="'"){i=!0,r++;continue}if(a==='"'){o=!0,r++;continue}if(a==="\\"){r+=2;continue}if(a==="("){s++,r++;continue}if(a===")"){if(s--,s===1){let l=r+1;return!(l<n&&t[l]===")")}if(s===0)return!1;r++;continue}if(s===1&&(a==="|"&&r+1<n&&t[r+1]==="|"||a==="&"&&r+1<n&&t[r+1]==="&"||a==="|"&&r+1<n&&t[r+1]!=="|"))return!0;r++}return!1}function nC(t,e,n,r){let s=e+2,i=1,o=s,a=!1,l=!1,c=0,u=!1,f="";for(;o<t.length&&i>0;){let m=t[o];a?m==="'"&&(a=!1):l?m==="\\"&&o+1<t.length?o++:m==='"'&&(l=!1):m==="'"?(a=!0,f=""):m==='"'?(l=!0,f=""):m==="\\"&&o+1<t.length?(o++,f=""):/[a-zA-Z_]/.test(m)?f+=m:(f==="case"?(c++,u=!1):f==="in"&&c>0?u=!0:f==="esac"&&c>0&&(c--,u=!1),f="",m==="("?o>0&&t[o-1]==="$"?i++:u||i++:m===")"?u?u=!1:i--:m===";"&&c>0&&o+1<t.length&&t[o+1]===";"&&(u=!0)),i>0&&o++}i>0&&r("unexpected EOF while looking for matching `)'");let h=t.slice(s,o),p=n().parse(h);return{part:le.commandSubstitution(p,!1),endIndex:o+1}}function rC(t,e,n,r,s){let o=e+1,a="";for(;o<t.length&&t[o]!=="`";)if(t[o]==="\\"){let u=t[o+1];u==="$"||u==="`"||u==="\\"||u===`
1390
1390
  `||n&&u==='"'?(u!==`
1391
- `&&(a+=u),o+=2):(a+=t[o],o++)}else a+=t[o],o++;o>=t.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(a);return{part:le.commandSubstitution(c,!0),endIndex:o+1}}var sC=I(()=>{"use strict";no()});function Bn(t,e){return new Ne().parse(t,e)}var Ne,Bt=I(()=>{"use strict";no();On();Gv();Kv();Xv();eC();gi();sC();to();to();Ne=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Ev)throw new un("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>g6)throw new un(`Maximum parser nesting depth exceeded (${g6})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(e,n){if(e.length>p6)throw new un(`Input too large: ${e.length} bytes exceeds limit of ${p6}`,1,1);this._input=e;let r=new uh(e,n);if(this.tokens=r.tokenize(),this.tokens.length>m6)throw new un(`Too many tokens: ${this.tokens.length} exceeds limit of ${m6}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(e){return this.tokens=e,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(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===e||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,n){if(this.check(e))return this.advance();let r=this.current();throw new un(n||`Expected ${e}, got ${r.type}`,r.line,r.column,r)}error(e){let n=this.current();throw new un(e,n.line,n.column,n)}skipNewlines(){for(;this.check(x.NEWLINE,x.COMMENT);)this.check(x.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(x.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(x.SEMICOLON,x.COMMENT)){this.advance();continue}if(e&&this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,n,r,s){this.pendingHeredocs.push({redirect:e,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(x.HEREDOC_CONTENT)){let n=this.advance(),r;e.quoted?r=le.word([le.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),e.redirect.target=le.hereDoc(e.delimiter,r,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(x.EOF,x.NEWLINE,x.SEMICOLON,x.AMP,x.AND_AND,x.OR_OR,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===x.WORD||e===x.NAME||e===x.NUMBER||e===x.ASSIGNMENT_WORD||e===x.IF||e===x.FOR||e===x.WHILE||e===x.UNTIL||e===x.CASE||e===x.LPAREN||e===x.LBRACE||e===x.DPAREN_START||e===x.DBRACK_START||e===x.FUNCTION||e===x.BANG||e===x.TIME||e===x.IN||e===x.LESS||e===x.GREAT||e===x.DLESS||e===x.DGREAT||e===x.LESSAND||e===x.GREATAND||e===x.LESSGREAT||e===x.DLESSDASH||e===x.CLOBBER||e===x.TLESS||e===x.AND_GREAT||e===x.AND_DGREAT}parseScript(){let e=[],r=0;for(this.skipNewlines();!this.check(x.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){e.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&e.push(o),this.skipSeparators(!1),this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(x.EOF)&&this.advance()}return le.script(e)}checkUnexpectedToken(){let e=this.current().type,n=this.current().value;if((e===x.DO||e===x.DONE||e===x.THEN||e===x.ELSE||e===x.ELIF||e===x.FI||e===x.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),e===x.RBRACE||e===x.RPAREN){let r=`syntax error near unexpected token \`${n}'`;return this.advance(),le.statement([le.pipeline([le.simpleCommand(null,[],[],[])])],[],!1,{message:r,token:n})}return(e===x.DSEMI||e===x.SEMI_AND||e===x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),e===x.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`),(e===x.PIPE||e===x.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${n}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,n=[],r=[],s=!1,i=this.parsePipeline();for(n.push(i);this.check(x.AND_AND,x.OR_OR);){let l=this.advance();r.push(l.type===x.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();n.push(c)}this.check(x.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:e,a=this._input.slice(e,o);return le.statement(n,r,s,void 0,a)}parsePipeline(){let e=!1,n=!1;this.check(x.TIME)&&(this.advance(),e=!0,this.check(x.WORD,x.NAME)&&this.current().value==="-p"&&(this.advance(),n=!0));let r=0;for(;this.check(x.BANG);)this.advance(),r++;let s=r%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(x.PIPE,x.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===x.PIPE_AMP);let c=this.parseCommand();i.push(c)}return le.pipeline(i,s,e,n,o.length>0?o:void 0)}parseCommand(){return this.check(x.IF)?v6(this):this.check(x.FOR)?C6(this):this.check(x.WHILE)?k6(this):this.check(x.UNTIL)?N6(this):this.check(x.CASE)?T6(this):this.check(x.LPAREN)?O6(this):this.check(x.LBRACE)?I6(this):this.check(x.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(x.DBRACK_START)?this.parseConditionalCommand():this.check(x.FUNCTION)?this.parseFunctionDef():this.check(x.NAME,x.WORD)&&this.peek(1).type===x.LPAREN&&this.peek(2).type===x.RPAREN?this.parseFunctionDef():Vv(this)}dparenClosesWithSpacedParens(){let e=1,n=1;for(;n<this.tokens.length-this.pos;){let r=this.peek(n);if(r.type===x.EOF)return!1;if(r.type===x.DPAREN_START||r.type===x.LPAREN)e++;else if(r.type===x.DPAREN_END){if(e-=2,e<=0)return!1}else if(r.type===x.RPAREN&&(e--,e===0&&this.peek(n+1).type===x.RPAREN))return!0;n++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(x.RPAREN),this.expect(x.RPAREN);let n=this.parseOptionalRedirections(),r=le.subshell(e,[]);return le.subshell([le.statement([le.pipeline([r],!1,!1,!1)])],n)}isWord(){let e=this.current().type;return e===x.WORD||e===x.NAME||e===x.NUMBER||e===x.IF||e===x.FOR||e===x.WHILE||e===x.UNTIL||e===x.CASE||e===x.FUNCTION||e===x.ELSE||e===x.ELIF||e===x.FI||e===x.THEN||e===x.DO||e===x.DONE||e===x.ESAC||e===x.IN||e===x.SELECT||e===x.TIME||e===x.COPROC||e===x.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordNoBraceExpansion(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0)}parseWordForRegex(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0,!0)}parseWordFromString(e,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1){let l=yi(this,e,n,r,s,i,!1,o,a);return le.word(l)}parseCommandSubstitution(e,n){return nC(e,n,()=>new t,r=>this.error(r))}parseBacktickSubstitution(e,n,r=!1){return rC(e,n,r,()=>new t,s=>this.error(s))}isDollarDparenSubshell(e,n){return tC(e,n)}parseArithmeticExpansion(e,n){let r=n+3,s=1,i=0,o=r;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(r,o),l=this.parseArithmeticExpression(a);return{part:le.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let e=this.expect(x.DPAREN_START),n="",r=1,s=0,i=!1,o=!1;for(;r>0&&!this.check(x.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(x.RPAREN)){r--,o=!0,this.advance();continue}if(this.check(x.DPAREN_END)){r--,o=!0;continue}n+=")";continue}if(this.check(x.DPAREN_START))r++,n+="((",this.advance();else if(this.check(x.DPAREN_END))s>=2?(s-=2,n+="))",this.advance()):s===1?(s--,n+=")",i=!0,this.advance()):(r--,o=!0,r>0&&(n+="))"),this.advance());else if(this.check(x.LPAREN))s++,n+="(",this.advance();else if(this.check(x.RPAREN))s>0&&s--,n+=")",this.advance();else{let c=this.current().value,u=n.length>0?n[n.length-1]:"";n.length>0&&!n.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(n))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(n+=" "),n+=c,this.advance()}}o||this.expect(x.DPAREN_END);let a=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return le.arithmeticCommand(a,l,e.line)}parseConditionalCommand(){let e=this.expect(x.DBRACK_START),n=R6(this);this.expect(x.DBRACK_END);let r=this.parseOptionalRedirections();return le.conditionalCommand(n,r,e.line)}parseFunctionDef(){let e;if(this.check(x.FUNCTION)){if(this.advance(),this.check(x.NAME)||this.check(x.WORD))e=this.advance().value;else{let s=this.current();throw new un("Expected function name",s.line,s.column,s)}this.check(x.LPAREN)&&(this.advance(),this.expect(x.RPAREN))}else e=this.advance().value,e.includes("$")&&this.error(`\`${e}': not a valid identifier`),this.expect(x.LPAREN),this.expect(x.RPAREN);this.skipNewlines();let n=this.parseCompoundCommandBody({forFunctionBody:!0}),r=this.parseOptionalRedirections();return le.functionDef(e,n,r)}parseCompoundCommandBody(e){let n=e?.forFunctionBody;if(this.check(x.LBRACE))return I6(this,{skipRedirections:n});if(this.check(x.LPAREN))return O6(this,{skipRedirections:n});if(this.check(x.IF))return v6(this,{skipRedirections:n});if(this.check(x.FOR))return C6(this,{skipRedirections:n});if(this.check(x.WHILE))return k6(this,{skipRedirections:n});if(this.check(x.UNTIL))return N6(this,{skipRedirections:n});if(this.check(x.CASE))return T6(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let e=this.enterDepth(),n=[];for(this.skipNewlines();!this.check(x.EOF,x.FI,x.ELSE,x.ELIF,x.THEN,x.DO,x.DONE,x.ESAC,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let r=this.pos,s=this.parseStatement();if(s&&n.push(s),this.skipSeparators(),this.pos===r&&!s)break}return e(),n}parseOptionalRedirections(){let e=[];for(;dh(this);){this.checkIterationLimit();let n=this.pos;if(e.push(ph(this)),this.pos===n)break}return e}parseArithmeticExpression(e){return Ve(this,e)}}});function D6(t){return tH.get(t)??""}function uC(t){let e=[],n="",r=0;for(;r<t.length;){let s=t[r];if(s==="["){for(n+=s,r++,r<t.length&&(t[r]==="!"||t[r]==="^")&&(n+=t[r],r++),r<t.length&&t[r]==="]"&&(n+=t[r],r++);r<t.length&&t[r]!=="]";){if(t[r]==="["&&r+1<t.length&&t[r+1]===":"){let i=t.indexOf(":]",r+2);if(i!==-1){n+=t.slice(r,i+2),r=i+2;continue}}if(t[r]==="\\"&&r+1<t.length){n+=t[r]+t[r+1],r+=2;continue}n+=t[r],r++}r<t.length&&t[r]==="]"&&(n+=t[r],r++)}else s===":"?(n!==""&&e.push(n),n="",r++):s==="\\"&&r+1<t.length?(n+=s+t[r+1],r+=2):(n+=s,r++)}return n!==""&&e.push(n),e}function fC(t){let e="^";for(let n=0;n<t.length;n++){let r=t[n];if(r==="*")e+="[^/]*";else if(r==="?")e+="[^/]";else if(r==="["){let s=n+1,i="[";s<t.length&&(t[s]==="^"||t[s]==="!")&&(i+="^",s++),s<t.length&&t[s]==="]"&&(i+="\\]",s++);let o=s;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 l=t.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(t[o]==="]")break;o++}let a=s;for(;s<t.length&&t[s]!=="]";){if(t[s]==="["&&s+1<t.length&&t[s+1]===":"){let l=t.indexOf(":]",s+2);if(l!==-1){let c=t.slice(s+2,l),u=D6(c);i+=u,s=l+2;continue}}if(t[s]==="\\"&&s+1<t.length){i+=`\\${t[s+1]}`,s+=2;continue}if(t[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=t[s];s++}i+="]",e+=i,n=s}else if(r==="\\"&&n+1<t.length){let s=t[n+1];/[.+^${}()|\\*?[\]]/.test(s)?e+=`\\${s}`:e+=s,n++}else/[.+^${}()|]/.test(r)?e+=`\\${r}`:e+=r}return e+="$",X(e)}function L6(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function M6(t){let e=[],n="",r=0,s=!1,i=0;for(;i<t.length;){let o=t[i];if(o==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=o,i++;continue}if(o==="\\"){n+=o,i+1<t.length?(n+=t[i+1],i+=2):i++;continue}o==="("?(r++,n+=o):o===")"?(r--,n+=o):o==="|"&&r===0?(e.push(n),n=""):n+=o,i++}return e.push(n),e}var tH,hC=I(()=>{"use strict";bt();tH=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"]])});var dC,wi,mh=I(()=>{"use strict";Me();bt();yo();hC();dC=5,wi=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(e,n,r,s){this.fs=e,this.cwd=n,typeof s=="boolean"?(this.globstar=s,this.maxOps=1e5):s?(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0,this.maxOps=s.maxGlobOperations??1e5):this.maxOps=1e5;let i=r?.get("GLOBIGNORE");i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=uC(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new ie(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(n=>{let r=n.split("/").pop()||n;if((this.hasGlobignore||this.globskipdots)&&(r==="."||r===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(n,s))return!1}return!0})}matchGlobignorePattern(e,n){return fC(n).test(e)}isGlobPattern(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,n){let r=e.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<e.length;o++){let a=s[o];a===null?i.push(e[o]):a.length>0?i.push(...a):i.push(e[o])}return i}async expand(e){if(this.globstar){let r=e.split("/"),s=0;for(let i of r)if(i==="**"&&(s++,s>dC))throw new ie(`Glob pattern has too many ** segments (max ${dC})`,"glob_operations")}let n;if(e.includes("**")&&this.globstar&&this.isGlobstarValid(e))n=await this.expandRecursive(e);else{let r=e.replace(/\*\*+/g,"*");n=await this.expandSimple(r)}return this.filterGlobignore(n)}isGlobstarValid(e){let n=e.split("/");for(let r of n)if(r.includes("**")&&r!=="**")return!1;return!0}hasGlobChars(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let n=e.startsWith("/"),r=e.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<r.length;c++)if(this.hasGlobChars(r[c])){s=c;break}if(s===-1)return[e];let i,o;if(s===0)n?(i="/",o="/"):(i=this.cwd,o="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=r.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(e,n,r){if(this.checkOpsLimit(),r.length===0)return[n];let[s,...i]=r,o=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let h=a.some(p=>p.name==="."),d=a.some(p=>p.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(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h.name,s)){let d=e==="/"?`/${h.name}`:`${e}/${h.name}`,p;n===""?p=h.name:n==="/"?p=`/${h.name}`:p=`${n}/${h.name}`,i.length===0?l.push(Promise.resolve([p])):h.isDirectory&&l.push(this.expandSegments(d,p,i))}let f=await Promise.all(l);for(let h of f)o.push(...h)}else{this.checkOpsLimit();let a=await this.fs.readdir(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h,s)){let d=e==="/"?`/${h}`:`${e}/${h}`,p;n===""?p=h:n==="/"?p=`/${h}`:p=`${n}/${h}`,i.length===0?l.push(Promise.resolve([p])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,p,i)}catch(m){if(m instanceof ie)throw m}return[]})())}let f=await Promise.all(l);for(let h of f)o.push(...h)}}catch(a){if(a instanceof ie)throw a}return o}async expandRecursive(e){let n=[],r=e.indexOf("**"),s=e.slice(0,r).replace(/\/$/,"")||".",o=e.slice(r+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,n),[...new Set(n)].sort()):(await this.walkDirectory(s,o,n),n.sort())}async walkDirectoryMultiGlobstar(e,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=e==="."?c.name:`${e}/${c.name}`;c.isDirectory&&o.push(u)}let a=e==="."?n:`${e}/${n}`,l=await this.expandRecursive(a);r.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{this.checkOpsLimit();let o=await this.fs.readdir(s),a=[];for(let u of o){let f=e==="."?u:`${e}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&a.push(f)}catch(d){if(d instanceof ie)throw d}}let l=e==="."?n:`${e}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,n,r)))}}}catch(i){if(i instanceof ie)throw i}}async walkDirectory(e,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=e==="."?l.name:`${e}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,n,r)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let h=e==="."?f:`${e}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let p=await this.fs.stat(d);return{name:f,path:h,isDirectory:p.isDirectory}}catch(p){if(p instanceof ie)throw p;return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch(i){if(i instanceof ie)throw i}}matchPattern(e,n){return this.patternToRegex(n).test(e)}patternToRegex(e){let n=this.patternToRegexStr(e);return X(`^${n}$`)}patternToRegexStr(e){let n="",r=!1;for(let s=0;s<e.length;s++){if(e.slice(s,s+13)==="\0QUOTE_START\0"){r=!0,s+=12;continue}if(e.slice(s,s+11)==="\0QUOTE_END\0"){r=!1,s+=10;continue}let i=e[s];if(r){/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<e.length&&e[s+1]==="("){let o=L6(e,s+1);if(o!==-1){let a=e.slice(s+2,o),l=M6(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")n+=`(?:${u})`;else if(i==="*")n+=`(?:${u})*`;else if(i==="+")n+=`(?:${u})+`;else if(i==="?")n+=`(?:${u})?`;else if(i==="!")if(o<e.length-1){let h=l.map(p=>this.computePatternLength(p));if(h.every(p=>p!==null)&&h.every(p=>p===h[0])&&h[0]!==null){let p=h[0];if(p===0)n+="(?:.+)";else{let m=[];p>0&&m.push(`.{0,${p-1}}`),m.push(`.{${p+1},}`),m.push(`(?!(?:${u})).{${p}}`),n+=`(?:${m.join("|")})`}}else n+=`(?:(?!(?:${u})).)*?`}else n+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let o=s+1,a="[";o<e.length&&(e[o]==="^"||e[o]==="!")&&(a+="^",o++),o<e.length&&e[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<e.length;){if(e[l]==="\\"&&l+1<e.length){l+=2;continue}if(e[l]==="["&&l+1<e.length&&e[l+1]===":"){let u=e.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(e[l]==="]")break;l++}let c=o;for(;o<e.length&&e[o]!=="]";){if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let u=e.indexOf(":]",o+2);if(u!==-1){let f=e.slice(o+2,u),h=D6(f);a+=h,o=u+2;continue}}if(e[o]==="\\"&&o+1<e.length){a+=`\\${e[o+1]}`,o+=2;continue}if(e[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=e[o];o++}a+="]",n+=a,s=o}else if(i==="\\"&&s+1<e.length){let o=e[s+1];/[.+^${}()|\\*?[\]]/.test(o)?n+=`\\${o}`:n+=o,s++}else/[.+^${}()|]/.test(i)?n+=`\\${i}`:n+=i}return n}computePatternLength(e){let n=0,r=0,s=!1;for(;r<e.length;){if(e.slice(r,r+13)==="\0QUOTE_START\0"){s=!0,r+=13;continue}if(e.slice(r,r+11)==="\0QUOTE_END\0"){s=!1,r+=11;continue}let i=e[r];if(s){n+=1,r++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&r+1<e.length&&e[r+1]==="("){let o=L6(e,r+1);if(o!==-1){if(i==="@"){let a=e.slice(r+2,o),c=M6(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let o=e.indexOf("]",r+1);if(o!==-1){n+=1,r=o+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function B6(t){for(let e=0;e<t.length;e++){if(t[e]==="\\"){e++;continue}if(t[e]==="$"){let n=t[e+1];if(n==="{"||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function nH(t){if(!t.operation)return!1;let e=t.operation,n;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(n=e.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function pC(t){if(!t.operation)return!1;let e=t.operation,n;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(n=e.word?.parts),!n||n.length===0)return!1;for(let r of n)if(r.type!=="DoubleQuoted"&&r.type!=="SingleQuoted")return!1;return!0}function tc(t){let e=!1,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1;for(let l of t){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(e=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),nH(l)&&(e=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&B6(l.pattern)&&(i=!0)}return{hasQuoted:e,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var gh=I(()=>{"use strict"});function Vt(t,e){let n=`${e}_`,r=[];for(let s of t.state.env.keys())if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function xs(t,e){let n=`${e}_`;for(let r of t.state.env.keys())r.startsWith(n)&&t.state.env.delete(r)}function Qr(t,e){let n=`${e}_`,r=`${e}__length`,s=[];for(let i of t.state.env.keys())if(i!==r&&i.startsWith(n)){let o=i.slice(n.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function yh(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function U6(t){if(t.parts.length<2)return null;let e=t.parts[0],n=t.parts[1];if(e.type!=="Glob"||!e.pattern.startsWith("["))return null;let r,s=n,i=1;if(n.type==="Literal"&&n.value.startsWith("]")){let f=n.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))r=e.pattern.slice(1);else if(f===""){if(t.parts.length<3)return null;let h=t.parts[2];if(h.type!=="Literal"||!h.value.startsWith("=")&&!h.value.startsWith("+="))return null;r=e.pattern.slice(1),s=h,i=2}else return null}else if(e.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(t.parts.length<3)return null;let f=t.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(n.type==="SingleQuoted")r=n.value;else{r="";for(let h of n.parts)(h.type==="Literal"||h.type==="Escaped")&&(r+=h.value)}s=f,i=2}else if(e.pattern.endsWith("]")){if(n.type!=="Literal"||!n.value.startsWith("=")&&!n.value.startsWith("+="))return null;r=e.pattern.slice(1,-1)}else return null;r=yh(r);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<t.parts.length;f++){let h=t.parts[f];h.type==="BraceExpansion"?l.push({type:"Literal",value:rH(h)}):l.push(h)}return{key:r,valueParts:l,append:a}}function rH(t){return`{${t.items.map(n=>{if(n.type==="Range"){let r=n.startStr??String(n.start),s=n.endStr??String(n.end),i=`${r}..${s}`;return n.step&&(i+=`..${n.step}`),i}return pa(n.word)}).join(",")}}`}function pa(t){let e="";for(let n of t.parts)switch(n.type){case"Literal":e+=n.value;break;case"Glob":e+=n.pattern;break;case"SingleQuoted":e+=n.value;break;case"DoubleQuoted":for(let r of n.parts)(r.type==="Literal"||r.type==="Escaped")&&(e+=r.value);break;case"Escaped":e+=n.value;break;case"BraceExpansion":e+="{",e+=n.items.map(r=>r.type==="Range"?`${r.startStr}..${r.endStr}${r.step?`..${r.step}`:""}`:pa(r.word)).join(","),e+="}";break;case"TildeExpansion":e+="~",n.user&&(e+=n.user);break}return e}var Rr=I(()=>{"use strict"});function Xt(t){return t.get("IFS")??`
1391
+ `&&(a+=u),o+=2):(a+=t[o],o++)}else a+=t[o],o++;o>=t.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(a);return{part:le.commandSubstitution(c,!0),endIndex:o+1}}var sC=I(()=>{"use strict";no()});function Bn(t,e){return new Ne().parse(t,e)}var Ne,Bt=I(()=>{"use strict";no();On();Gv();Kv();Xv();eC();gi();sC();to();to();Ne=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Ev)throw new un("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>g6)throw new un(`Maximum parser nesting depth exceeded (${g6})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(e,n){if(e.length>p6)throw new un(`Input too large: ${e.length} bytes exceeds limit of ${p6}`,1,1);this._input=e;let r=new uh(e,n);if(this.tokens=r.tokenize(),this.tokens.length>m6)throw new un(`Too many tokens: ${this.tokens.length} exceeds limit of ${m6}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(e){return this.tokens=e,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(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===e||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,n){if(this.check(e))return this.advance();let r=this.current();throw new un(n||`Expected ${e}, got ${r.type}`,r.line,r.column,r)}error(e){let n=this.current();throw new un(e,n.line,n.column,n)}skipNewlines(){for(;this.check(x.NEWLINE,x.COMMENT);)this.check(x.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(x.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(x.SEMICOLON,x.COMMENT)){this.advance();continue}if(e&&this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,n,r,s){this.pendingHeredocs.push({redirect:e,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(x.HEREDOC_CONTENT)){let n=this.advance(),r;e.quoted?r=le.word([le.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),e.redirect.target=le.hereDoc(e.delimiter,r,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(x.EOF,x.NEWLINE,x.SEMICOLON,x.AMP,x.AND_AND,x.OR_OR,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===x.WORD||e===x.NAME||e===x.NUMBER||e===x.ASSIGNMENT_WORD||e===x.IF||e===x.FOR||e===x.WHILE||e===x.UNTIL||e===x.CASE||e===x.LPAREN||e===x.LBRACE||e===x.DPAREN_START||e===x.DBRACK_START||e===x.FUNCTION||e===x.BANG||e===x.TIME||e===x.IN||e===x.LESS||e===x.GREAT||e===x.DLESS||e===x.DGREAT||e===x.LESSAND||e===x.GREATAND||e===x.LESSGREAT||e===x.DLESSDASH||e===x.CLOBBER||e===x.TLESS||e===x.AND_GREAT||e===x.AND_DGREAT}parseScript(){let e=[],r=0;for(this.skipNewlines();!this.check(x.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){e.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&e.push(o),this.skipSeparators(!1),this.check(x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(x.EOF)&&this.advance()}return le.script(e)}checkUnexpectedToken(){let e=this.current().type,n=this.current().value;if((e===x.DO||e===x.DONE||e===x.THEN||e===x.ELSE||e===x.ELIF||e===x.FI||e===x.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),e===x.RBRACE||e===x.RPAREN){let r=`syntax error near unexpected token \`${n}'`;return this.advance(),le.statement([le.pipeline([le.simpleCommand(null,[],[],[])])],[],!1,{message:r,token:n})}return(e===x.DSEMI||e===x.SEMI_AND||e===x.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),e===x.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`),(e===x.PIPE||e===x.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${n}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,n=[],r=[],s=!1,i=this.parsePipeline();for(n.push(i);this.check(x.AND_AND,x.OR_OR);){let l=this.advance();r.push(l.type===x.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();n.push(c)}this.check(x.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:e,a=this._input.slice(e,o);return le.statement(n,r,s,void 0,a)}parsePipeline(){let e=!1,n=!1;this.check(x.TIME)&&(this.advance(),e=!0,this.check(x.WORD,x.NAME)&&this.current().value==="-p"&&(this.advance(),n=!0));let r=0;for(;this.check(x.BANG);)this.advance(),r++;let s=r%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(x.PIPE,x.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===x.PIPE_AMP);let c=this.parseCommand();i.push(c)}return le.pipeline(i,s,e,n,o.length>0?o:void 0)}parseCommand(){return this.check(x.IF)?v6(this):this.check(x.FOR)?C6(this):this.check(x.WHILE)?k6(this):this.check(x.UNTIL)?N6(this):this.check(x.CASE)?T6(this):this.check(x.LPAREN)?O6(this):this.check(x.LBRACE)?I6(this):this.check(x.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(x.DBRACK_START)?this.parseConditionalCommand():this.check(x.FUNCTION)?this.parseFunctionDef():this.check(x.NAME,x.WORD)&&this.peek(1).type===x.LPAREN&&this.peek(2).type===x.RPAREN?this.parseFunctionDef():Vv(this)}dparenClosesWithSpacedParens(){let e=1,n=1;for(;n<this.tokens.length-this.pos;){let r=this.peek(n);if(r.type===x.EOF)return!1;if(r.type===x.DPAREN_START||r.type===x.LPAREN)e++;else if(r.type===x.DPAREN_END){if(e-=2,e<=0)return!1}else if(r.type===x.RPAREN&&(e--,e===0&&this.peek(n+1).type===x.RPAREN))return!0;n++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(x.RPAREN),this.expect(x.RPAREN);let n=this.parseOptionalRedirections(),r=le.subshell(e,[]);return le.subshell([le.statement([le.pipeline([r],!1,!1,!1)])],n)}isWord(){let e=this.current().type;return e===x.WORD||e===x.NAME||e===x.NUMBER||e===x.IF||e===x.FOR||e===x.WHILE||e===x.UNTIL||e===x.CASE||e===x.FUNCTION||e===x.ELSE||e===x.ELIF||e===x.FI||e===x.THEN||e===x.DO||e===x.DONE||e===x.ESAC||e===x.IN||e===x.SELECT||e===x.TIME||e===x.COPROC||e===x.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordNoBraceExpansion(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0)}parseWordForRegex(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0,!0)}parseWordFromString(e,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1){let l=yi(this,e,n,r,s,i,!1,o,a);return le.word(l)}parseCommandSubstitution(e,n){return nC(e,n,()=>new t,r=>this.error(r))}parseBacktickSubstitution(e,n,r=!1){return rC(e,n,r,()=>new t,s=>this.error(s))}isDollarDparenSubshell(e,n){return tC(e,n)}parseArithmeticExpansion(e,n){let r=n+3,s=1,i=0,o=r;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(r,o),l=this.parseArithmeticExpression(a);return{part:le.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let e=this.expect(x.DPAREN_START),n="",r=1,s=0,i=!1,o=!1;for(;r>0&&!this.check(x.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(x.RPAREN)){r--,o=!0,this.advance();continue}if(this.check(x.DPAREN_END)){r--,o=!0;continue}n+=")";continue}if(this.check(x.DPAREN_START))r++,n+="((",this.advance();else if(this.check(x.DPAREN_END))s>=2?(s-=2,n+="))",this.advance()):s===1?(s--,n+=")",i=!0,this.advance()):(r--,o=!0,r>0&&(n+="))"),this.advance());else if(this.check(x.LPAREN))s++,n+="(",this.advance();else if(this.check(x.RPAREN))s>0&&s--,n+=")",this.advance();else{let c=this.current().value,u=n.length>0?n[n.length-1]:"";n.length>0&&!n.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(n))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(n+=" "),n+=c,this.advance()}}o||this.expect(x.DPAREN_END);let a=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return le.arithmeticCommand(a,l,e.line)}parseConditionalCommand(){let e=this.expect(x.DBRACK_START),n=R6(this);this.expect(x.DBRACK_END);let r=this.parseOptionalRedirections();return le.conditionalCommand(n,r,e.line)}parseFunctionDef(){let e;if(this.check(x.FUNCTION)){if(this.advance(),this.check(x.NAME)||this.check(x.WORD))e=this.advance().value;else{let s=this.current();throw new un("Expected function name",s.line,s.column,s)}this.check(x.LPAREN)&&(this.advance(),this.expect(x.RPAREN))}else e=this.advance().value,e.includes("$")&&this.error(`\`${e}': not a valid identifier`),this.expect(x.LPAREN),this.expect(x.RPAREN);this.skipNewlines();let n=this.parseCompoundCommandBody({forFunctionBody:!0}),r=this.parseOptionalRedirections();return le.functionDef(e,n,r)}parseCompoundCommandBody(e){let n=e?.forFunctionBody;if(this.check(x.LBRACE))return I6(this,{skipRedirections:n});if(this.check(x.LPAREN))return O6(this,{skipRedirections:n});if(this.check(x.IF))return v6(this,{skipRedirections:n});if(this.check(x.FOR))return C6(this,{skipRedirections:n});if(this.check(x.WHILE))return k6(this,{skipRedirections:n});if(this.check(x.UNTIL))return N6(this,{skipRedirections:n});if(this.check(x.CASE))return T6(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let e=this.enterDepth(),n=[];for(this.skipNewlines();!this.check(x.EOF,x.FI,x.ELSE,x.ELIF,x.THEN,x.DO,x.DONE,x.ESAC,x.RPAREN,x.RBRACE,x.DSEMI,x.SEMI_AND,x.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let r=this.pos,s=this.parseStatement();if(s&&n.push(s),this.skipSeparators(),this.pos===r&&!s)break}return e(),n}parseOptionalRedirections(){let e=[];for(;dh(this);){this.checkIterationLimit();let n=this.pos;if(e.push(ph(this)),this.pos===n)break}return e}parseArithmeticExpression(e){return Ge(this,e)}}});function D6(t){return tH.get(t)??""}function uC(t){let e=[],n="",r=0;for(;r<t.length;){let s=t[r];if(s==="["){for(n+=s,r++,r<t.length&&(t[r]==="!"||t[r]==="^")&&(n+=t[r],r++),r<t.length&&t[r]==="]"&&(n+=t[r],r++);r<t.length&&t[r]!=="]";){if(t[r]==="["&&r+1<t.length&&t[r+1]===":"){let i=t.indexOf(":]",r+2);if(i!==-1){n+=t.slice(r,i+2),r=i+2;continue}}if(t[r]==="\\"&&r+1<t.length){n+=t[r]+t[r+1],r+=2;continue}n+=t[r],r++}r<t.length&&t[r]==="]"&&(n+=t[r],r++)}else s===":"?(n!==""&&e.push(n),n="",r++):s==="\\"&&r+1<t.length?(n+=s+t[r+1],r+=2):(n+=s,r++)}return n!==""&&e.push(n),e}function fC(t){let e="^";for(let n=0;n<t.length;n++){let r=t[n];if(r==="*")e+="[^/]*";else if(r==="?")e+="[^/]";else if(r==="["){let s=n+1,i="[";s<t.length&&(t[s]==="^"||t[s]==="!")&&(i+="^",s++),s<t.length&&t[s]==="]"&&(i+="\\]",s++);let o=s;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 l=t.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(t[o]==="]")break;o++}let a=s;for(;s<t.length&&t[s]!=="]";){if(t[s]==="["&&s+1<t.length&&t[s+1]===":"){let l=t.indexOf(":]",s+2);if(l!==-1){let c=t.slice(s+2,l),u=D6(c);i+=u,s=l+2;continue}}if(t[s]==="\\"&&s+1<t.length){i+=`\\${t[s+1]}`,s+=2;continue}if(t[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=t[s];s++}i+="]",e+=i,n=s}else if(r==="\\"&&n+1<t.length){let s=t[n+1];/[.+^${}()|\\*?[\]]/.test(s)?e+=`\\${s}`:e+=s,n++}else/[.+^${}()|]/.test(r)?e+=`\\${r}`:e+=r}return e+="$",X(e)}function L6(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function M6(t){let e=[],n="",r=0,s=!1,i=0;for(;i<t.length;){let o=t[i];if(o==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=o,i++;continue}if(o==="\\"){n+=o,i+1<t.length?(n+=t[i+1],i+=2):i++;continue}o==="("?(r++,n+=o):o===")"?(r--,n+=o):o==="|"&&r===0?(e.push(n),n=""):n+=o,i++}return e.push(n),e}var tH,hC=I(()=>{"use strict";bt();tH=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"]])});var dC,wi,mh=I(()=>{"use strict";Me();bt();yo();hC();dC=5,wi=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(e,n,r,s){this.fs=e,this.cwd=n,typeof s=="boolean"?(this.globstar=s,this.maxOps=1e5):s?(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0,this.maxOps=s.maxGlobOperations??1e5):this.maxOps=1e5;let i=r?.get("GLOBIGNORE");i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=uC(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new ie(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(n=>{let r=n.split("/").pop()||n;if((this.hasGlobignore||this.globskipdots)&&(r==="."||r===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(n,s))return!1}return!0})}matchGlobignorePattern(e,n){return fC(n).test(e)}isGlobPattern(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,n){let r=e.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<e.length;o++){let a=s[o];a===null?i.push(e[o]):a.length>0?i.push(...a):i.push(e[o])}return i}async expand(e){if(this.globstar){let r=e.split("/"),s=0;for(let i of r)if(i==="**"&&(s++,s>dC))throw new ie(`Glob pattern has too many ** segments (max ${dC})`,"glob_operations")}let n;if(e.includes("**")&&this.globstar&&this.isGlobstarValid(e))n=await this.expandRecursive(e);else{let r=e.replace(/\*\*+/g,"*");n=await this.expandSimple(r)}return this.filterGlobignore(n)}isGlobstarValid(e){let n=e.split("/");for(let r of n)if(r.includes("**")&&r!=="**")return!1;return!0}hasGlobChars(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let n=e.startsWith("/"),r=e.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<r.length;c++)if(this.hasGlobChars(r[c])){s=c;break}if(s===-1)return[e];let i,o;if(s===0)n?(i="/",o="/"):(i=this.cwd,o="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=r.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(e,n,r){if(this.checkOpsLimit(),r.length===0)return[n];let[s,...i]=r,o=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let h=a.some(p=>p.name==="."),d=a.some(p=>p.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(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h.name,s)){let d=e==="/"?`/${h.name}`:`${e}/${h.name}`,p;n===""?p=h.name:n==="/"?p=`/${h.name}`:p=`${n}/${h.name}`,i.length===0?l.push(Promise.resolve([p])):h.isDirectory&&l.push(this.expandSegments(d,p,i))}let f=await Promise.all(l);for(let h of f)o.push(...h)}else{this.checkOpsLimit();let a=await this.fs.readdir(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h,s)){let d=e==="/"?`/${h}`:`${e}/${h}`,p;n===""?p=h:n==="/"?p=`/${h}`:p=`${n}/${h}`,i.length===0?l.push(Promise.resolve([p])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,p,i)}catch(m){if(m instanceof ie)throw m}return[]})())}let f=await Promise.all(l);for(let h of f)o.push(...h)}}catch(a){if(a instanceof ie)throw a}return o}async expandRecursive(e){let n=[],r=e.indexOf("**"),s=e.slice(0,r).replace(/\/$/,"")||".",o=e.slice(r+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,n),[...new Set(n)].sort()):(await this.walkDirectory(s,o,n),n.sort())}async walkDirectoryMultiGlobstar(e,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=e==="."?c.name:`${e}/${c.name}`;c.isDirectory&&o.push(u)}let a=e==="."?n:`${e}/${n}`,l=await this.expandRecursive(a);r.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{this.checkOpsLimit();let o=await this.fs.readdir(s),a=[];for(let u of o){let f=e==="."?u:`${e}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&a.push(f)}catch(d){if(d instanceof ie)throw d}}let l=e==="."?n:`${e}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,n,r)))}}}catch(i){if(i instanceof ie)throw i}}async walkDirectory(e,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=e==="."?l.name:`${e}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,n,r)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let h=e==="."?f:`${e}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let p=await this.fs.stat(d);return{name:f,path:h,isDirectory:p.isDirectory}}catch(p){if(p instanceof ie)throw p;return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch(i){if(i instanceof ie)throw i}}matchPattern(e,n){return this.patternToRegex(n).test(e)}patternToRegex(e){let n=this.patternToRegexStr(e);return X(`^${n}$`)}patternToRegexStr(e){let n="",r=!1;for(let s=0;s<e.length;s++){if(e.slice(s,s+13)==="\0QUOTE_START\0"){r=!0,s+=12;continue}if(e.slice(s,s+11)==="\0QUOTE_END\0"){r=!1,s+=10;continue}let i=e[s];if(r){/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<e.length&&e[s+1]==="("){let o=L6(e,s+1);if(o!==-1){let a=e.slice(s+2,o),l=M6(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")n+=`(?:${u})`;else if(i==="*")n+=`(?:${u})*`;else if(i==="+")n+=`(?:${u})+`;else if(i==="?")n+=`(?:${u})?`;else if(i==="!")if(o<e.length-1){let h=l.map(p=>this.computePatternLength(p));if(h.every(p=>p!==null)&&h.every(p=>p===h[0])&&h[0]!==null){let p=h[0];if(p===0)n+="(?:.+)";else{let m=[];p>0&&m.push(`.{0,${p-1}}`),m.push(`.{${p+1},}`),m.push(`(?!(?:${u})).{${p}}`),n+=`(?:${m.join("|")})`}}else n+=`(?:(?!(?:${u})).)*?`}else n+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let o=s+1,a="[";o<e.length&&(e[o]==="^"||e[o]==="!")&&(a+="^",o++),o<e.length&&e[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<e.length;){if(e[l]==="\\"&&l+1<e.length){l+=2;continue}if(e[l]==="["&&l+1<e.length&&e[l+1]===":"){let u=e.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(e[l]==="]")break;l++}let c=o;for(;o<e.length&&e[o]!=="]";){if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let u=e.indexOf(":]",o+2);if(u!==-1){let f=e.slice(o+2,u),h=D6(f);a+=h,o=u+2;continue}}if(e[o]==="\\"&&o+1<e.length){a+=`\\${e[o+1]}`,o+=2;continue}if(e[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=e[o];o++}a+="]",n+=a,s=o}else if(i==="\\"&&s+1<e.length){let o=e[s+1];/[.+^${}()|\\*?[\]]/.test(o)?n+=`\\${o}`:n+=o,s++}else/[.+^${}()|]/.test(i)?n+=`\\${i}`:n+=i}return n}computePatternLength(e){let n=0,r=0,s=!1;for(;r<e.length;){if(e.slice(r,r+13)==="\0QUOTE_START\0"){s=!0,r+=13;continue}if(e.slice(r,r+11)==="\0QUOTE_END\0"){s=!1,r+=11;continue}let i=e[r];if(s){n+=1,r++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&r+1<e.length&&e[r+1]==="("){let o=L6(e,r+1);if(o!==-1){if(i==="@"){let a=e.slice(r+2,o),c=M6(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let o=e.indexOf("]",r+1);if(o!==-1){n+=1,r=o+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function B6(t){for(let e=0;e<t.length;e++){if(t[e]==="\\"){e++;continue}if(t[e]==="$"){let n=t[e+1];if(n==="{"||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function nH(t){if(!t.operation)return!1;let e=t.operation,n;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(n=e.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function pC(t){if(!t.operation)return!1;let e=t.operation,n;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(n=e.word?.parts),!n||n.length===0)return!1;for(let r of n)if(r.type!=="DoubleQuoted"&&r.type!=="SingleQuoted")return!1;return!0}function tc(t){let e=!1,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1;for(let l of t){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(e=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),nH(l)&&(e=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&B6(l.pattern)&&(i=!0)}return{hasQuoted:e,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var gh=I(()=>{"use strict"});function Vt(t,e){let n=`${e}_`,r=[];for(let s of t.state.env.keys())if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function Ss(t,e){let n=`${e}_`;for(let r of t.state.env.keys())r.startsWith(n)&&t.state.env.delete(r)}function Qr(t,e){let n=`${e}_`,r=`${e}__length`,s=[];for(let i of t.state.env.keys())if(i!==r&&i.startsWith(n)){let o=i.slice(n.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function yh(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function U6(t){if(t.parts.length<2)return null;let e=t.parts[0],n=t.parts[1];if(e.type!=="Glob"||!e.pattern.startsWith("["))return null;let r,s=n,i=1;if(n.type==="Literal"&&n.value.startsWith("]")){let f=n.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))r=e.pattern.slice(1);else if(f===""){if(t.parts.length<3)return null;let h=t.parts[2];if(h.type!=="Literal"||!h.value.startsWith("=")&&!h.value.startsWith("+="))return null;r=e.pattern.slice(1),s=h,i=2}else return null}else if(e.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(t.parts.length<3)return null;let f=t.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(n.type==="SingleQuoted")r=n.value;else{r="";for(let h of n.parts)(h.type==="Literal"||h.type==="Escaped")&&(r+=h.value)}s=f,i=2}else if(e.pattern.endsWith("]")){if(n.type!=="Literal"||!n.value.startsWith("=")&&!n.value.startsWith("+="))return null;r=e.pattern.slice(1,-1)}else return null;r=yh(r);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<t.parts.length;f++){let h=t.parts[f];h.type==="BraceExpansion"?l.push({type:"Literal",value:rH(h)}):l.push(h)}return{key:r,valueParts:l,append:a}}function rH(t){return`{${t.items.map(n=>{if(n.type==="Range"){let r=n.startStr??String(n.start),s=n.endStr??String(n.end),i=`${r}..${s}`;return n.step&&(i+=`..${n.step}`),i}return pa(n.word)}).join(",")}}`}function pa(t){let e="";for(let n of t.parts)switch(n.type){case"Literal":e+=n.value;break;case"Glob":e+=n.pattern;break;case"SingleQuoted":e+=n.value;break;case"DoubleQuoted":for(let r of n.parts)(r.type==="Literal"||r.type==="Escaped")&&(e+=r.value);break;case"Escaped":e+=n.value;break;case"BraceExpansion":e+="{",e+=n.items.map(r=>r.type==="Range"?`${r.startStr}..${r.endStr}${r.step?`..${r.step}`:""}`:pa(r.word)).join(","),e+="}";break;case"TildeExpansion":e+="~",n.user&&(e+=n.user);break}return e}var Rr=I(()=>{"use strict"});function Xt(t){return t.get("IFS")??`
1392
1392
  `}function Sn(t){return t.get("IFS")===""}function wh(t){let e=Xt(t);if(e==="")return!0;for(let n of e)if(n!==" "&&n!==" "&&n!==`
1393
1393
  `)return!1;return!0}function mC(t){let e=!1,n=[];for(let r of t.split(""))r==="-"?e=!0:/[\\^$.*+?()[\]{}|]/.test(r)?n.push(`\\${r}`):r===" "?n.push("\\t"):r===`
1394
1394
  `?n.push("\\n"):n.push(r);return e&&n.push("\\-"),n.join("")}function Ie(t){let e=t.get("IFS");return e===void 0?" ":e[0]||""}function iH(t){return sH.includes(t)}function z6(t){let e=new Set,n=new Set;for(let r of t)iH(r)?e.add(r):n.add(r);return{whitespace:e,nonWhitespace:n}}function W6(t,e,n,r){if(e==="")return t===""?{words:[],wordStarts:[]}:{words:[t],wordStarts:[0]};let{whitespace:s,nonWhitespace:i}=z6(e),o=[],a=[],l=0;for(;l<t.length&&s.has(t[l]);)l++;if(l>=t.length)return{words:[],wordStarts:[]};if(i.has(t[l]))for(o.push(""),a.push(l),l++;l<t.length&&s.has(t[l]);)l++;for(;l<t.length&&!(n!==void 0&&o.length>=n);){let c=l;for(a.push(c);l<t.length;){let u=t[l];if(!r&&u==="\\"){l++,l<t.length&&l++;continue}if(s.has(u)||i.has(u))break;l++}if(o.push(t.substring(c,l)),l>=t.length)break;for(;l<t.length&&s.has(t[l]);)l++;if(l<t.length&&i.has(t[l])){for(l++;l<t.length&&s.has(t[l]);)l++;for(;l<t.length&&i.has(t[l])&&!(n!==void 0&&o.length>=n);)for(o.push(""),a.push(l),l++;l<t.length&&s.has(t[l]);)l++}}return{words:o,wordStarts:a}}function bh(t,e){if(e==="")return{words:t?[t]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(t==="")return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:n,nonWhitespace:r}=z6(e),s=[],i=0,o=!1,a=!1,l=i;for(;i<t.length&&n.has(t[i]);)i++;if(i>l&&(o=!0),i>=t.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(r.has(t[i]))for(s.push(""),i++;i<t.length&&n.has(t[i]);)i++;for(;i<t.length;){let c=i;for(;i<t.length;){let f=t[i];if(n.has(f)||r.has(f))break;i++}if(s.push(t.substring(c,i)),i>=t.length){a=!1;break}let u=i;for(;i<t.length&&n.has(t[i]);)i++;if(i<t.length&&r.has(t[i])){for(i++;i<t.length&&n.has(t[i]);)i++;for(;i<t.length&&r.has(t[i]);)for(s.push(""),i++;i<t.length&&n.has(t[i]);)i++}i>=t.length&&i>u&&(a=!0)}return{words:s,hadLeadingDelimiter:o,hadTrailingDelimiter:a}}function St(t,e){return bh(t,e).words}function oH(t,e){for(let n of t)if(e.has(n))return!0;return!1}function gC(t,e,n){if(e==="")return t;let{whitespace:r,nonWhitespace:s}=z6(e),i=t.length;for(;i>0&&r.has(t[i-1]);){if(!n&&i>=2){let a=0,l=i-2;for(;l>=0&&t[l]==="\\";)a++,l--;if(a%2===1)break}i--}let o=t.substring(0,i);if(o.length>=1&&s.has(o[o.length-1])){if(!n&&o.length>=2){let l=0,c=o.length-2;for(;c>=0&&o[c]==="\\";)l++,c--;if(l%2===1)return o}let a=o.substring(0,o.length-1);if(!oH(a,s))return a}return o}var sH,yr=I(()=>{"use strict";sH=`
1395
- `});function pt(t,e){return t.state.namerefs?.has(e)??!1}function Bs(t,e){t.state.namerefs??=new Set,t.state.namerefs.add(e)}function yC(t,e){t.state.namerefs?.delete(e),t.state.boundNamerefs?.delete(e),t.state.invalidNamerefs?.delete(e)}function wC(t,e){t.state.invalidNamerefs??=new Set,t.state.invalidNamerefs.add(e)}function bC(t,e){return t.state.invalidNamerefs?.has(e)??!1}function j6(t,e){t.state.boundNamerefs??=new Set,t.state.boundNamerefs.add(e)}function Eh(t,e){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let s=n[1],i=Array.from(t.state.env.keys()).some(a=>a.startsWith(`${s}_`)&&!a.includes("__")),o=t.state.associativeArrays?.has(s)??!1;return i||o}return Array.from(t.state.env.keys()).some(s=>s.startsWith(`${e}_`)&&!s.includes("__"))?!0:t.state.env.has(e)}function Un(t,e,n=100){if(!pt(t,e)||bC(t,e))return e;let r=new Set,s=e;for(;n-- >0;){if(r.has(s))return;if(r.add(s),!pt(t,s))return s;let i=t.state.env.get(s);if(i===void 0||i===""||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i))return s;s=i}}function so(t,e){if(pt(t,e))return t.state.env.get(e)}function EC(t,e,n,r=100){if(!pt(t,e)||bC(t,e))return e;let s=new Set,i=e;for(;r-- >0;){if(s.has(i))return;if(s.add(i),!pt(t,i))return i;let o=t.state.env.get(i);if(o===void 0||o==="")return n!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&Eh(t,n)?i:null:i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(o))return i;i=o}}var Xr=I(()=>{"use strict"});function aH(t,e){let n=e.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(r,s)=>t.state.env.get(s)??"");return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(r,s)=>t.state.env.get(s)??""),n}function xe(t,e){return e==="FUNCNAME"?(t.state.funcNameStack??[]).map((i,o)=>[o,i]):e==="BASH_LINENO"?(t.state.callLineStack??[]).map((i,o)=>[o,String(i)]):e==="BASH_SOURCE"?(t.state.sourceStack??[]).map((i,o)=>[o,i]):t.state.associativeArrays?.has(e)?Qr(t,e).map(i=>[i,t.state.env.get(`${e}_${i}`)??""]):Vt(t,e).map(s=>[s,t.state.env.get(`${e}_${s}`)??""])}function Us(t,e){return e==="FUNCNAME"?(t.state.funcNameStack?.length??0)>0:e==="BASH_LINENO"?(t.state.callLineStack?.length??0)>0:e==="BASH_SOURCE"?(t.state.sourceStack?.length??0)>0:t.state.associativeArrays?.has(e)?Qr(t,e).length>0:Vt(t,e).length>0}async function Ge(t,e,n=!0,r=!1){switch(e){case"?":return String(t.state.lastExitCode);case"$":return String(t.state.virtualPid);case"#":return t.state.env.get("#")||"0";case"@":return t.state.env.get("@")||"";case"_":return t.state.lastArg;case"-":{let o="";return o+="h",t.state.options.errexit&&(o+="e"),t.state.options.noglob&&(o+="f"),t.state.options.nounset&&(o+="u"),t.state.options.verbose&&(o+="v"),t.state.options.xtrace&&(o+="x"),o+="B",t.state.options.noclobber&&(o+="C"),o+="s",o}case"*":{let o=Number.parseInt(t.state.env.get("#")||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(t.state.env.get(String(l))||"");return a.join(Ie(t.state.env))}case"0":return t.state.env.get("0")||"bash";case"PWD":return t.state.env.get("PWD")??"";case"OLDPWD":return t.state.env.get("OLDPWD")??"";case"PPID":return String(t.state.virtualPpid);case"UID":return String(t.state.virtualUid);case"EUID":return String(t.state.virtualUid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-t.state.startTime)/1e3));case"BASH_VERSION":return dv;case"!":return String(t.state.lastBackgroundPid);case"BASHPID":return String(t.state.bashPid);case"LINENO":return String(t.state.currentLine);case"FUNCNAME":{let o=t.state.funcNameStack?.[0];if(o!==void 0)return o;if(n&&t.state.options.nounset)throw new Pn("FUNCNAME");return""}case"BASH_LINENO":{let o=t.state.callLineStack?.[0];if(o!==void 0)return String(o);if(n&&t.state.options.nounset)throw new Pn("BASH_LINENO");return""}case"BASH_SOURCE":{let o=t.state.sourceStack?.[0];if(o!==void 0)return o;if(n&&t.state.options.nounset)throw new Pn("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(e))throw new Rn(`\${${e}}`);let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(pt(t,o)){let f=Un(t,o);if(f&&f!==o){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return"";o=f}}if(a==="@"||a==="*"){let f=xe(t,o);if(f.length>0)return f.map(([,d])=>d).join(" ");let h=t.state.env.get(o);return h!==void 0?h:""}if(o==="FUNCNAME"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?t.state.funcNameStack?.[f]??"":""}if(o==="BASH_LINENO"){let f=Number.parseInt(a,10);if(!Number.isNaN(f)&&f>=0){let h=t.state.callLineStack?.[f];return h!==void 0?String(h):""}return""}if(o==="BASH_SOURCE"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?t.state.sourceStack?.[f]??"":""}if(t.state.associativeArrays?.has(o)){let f=yh(a);f=aH(t,f);let h=t.state.env.get(`${o}_${f}`);if(h===void 0&&n&&t.state.options.nounset)throw new Pn(`${o}[${a}]`);return h||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new Ne,h=Ve(f,a);c=await fe(t,h.expression)}catch{let f=t.state.env.get(a);c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=xe(t,o),h=t.state.currentLine;if(f.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${h}: ${o}: bad array subscript
1395
+ `});function pt(t,e){return t.state.namerefs?.has(e)??!1}function Bs(t,e){t.state.namerefs??=new Set,t.state.namerefs.add(e)}function yC(t,e){t.state.namerefs?.delete(e),t.state.boundNamerefs?.delete(e),t.state.invalidNamerefs?.delete(e)}function wC(t,e){t.state.invalidNamerefs??=new Set,t.state.invalidNamerefs.add(e)}function bC(t,e){return t.state.invalidNamerefs?.has(e)??!1}function j6(t,e){t.state.boundNamerefs??=new Set,t.state.boundNamerefs.add(e)}function Eh(t,e){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let s=n[1],i=Array.from(t.state.env.keys()).some(a=>a.startsWith(`${s}_`)&&!a.includes("__")),o=t.state.associativeArrays?.has(s)??!1;return i||o}return Array.from(t.state.env.keys()).some(s=>s.startsWith(`${e}_`)&&!s.includes("__"))?!0:t.state.env.has(e)}function Un(t,e,n=100){if(!pt(t,e)||bC(t,e))return e;let r=new Set,s=e;for(;n-- >0;){if(r.has(s))return;if(r.add(s),!pt(t,s))return s;let i=t.state.env.get(s);if(i===void 0||i===""||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i))return s;s=i}}function so(t,e){if(pt(t,e))return t.state.env.get(e)}function EC(t,e,n,r=100){if(!pt(t,e)||bC(t,e))return e;let s=new Set,i=e;for(;r-- >0;){if(s.has(i))return;if(s.add(i),!pt(t,i))return i;let o=t.state.env.get(i);if(o===void 0||o==="")return n!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&Eh(t,n)?i:null:i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(o))return i;i=o}}var Xr=I(()=>{"use strict"});function aH(t,e){let n=e.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(r,s)=>t.state.env.get(s)??"");return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(r,s)=>t.state.env.get(s)??""),n}function xe(t,e){return e==="FUNCNAME"?(t.state.funcNameStack??[]).map((i,o)=>[o,i]):e==="BASH_LINENO"?(t.state.callLineStack??[]).map((i,o)=>[o,String(i)]):e==="BASH_SOURCE"?(t.state.sourceStack??[]).map((i,o)=>[o,i]):t.state.associativeArrays?.has(e)?Qr(t,e).map(i=>[i,t.state.env.get(`${e}_${i}`)??""]):Vt(t,e).map(s=>[s,t.state.env.get(`${e}_${s}`)??""])}function Us(t,e){return e==="FUNCNAME"?(t.state.funcNameStack?.length??0)>0:e==="BASH_LINENO"?(t.state.callLineStack?.length??0)>0:e==="BASH_SOURCE"?(t.state.sourceStack?.length??0)>0:t.state.associativeArrays?.has(e)?Qr(t,e).length>0:Vt(t,e).length>0}async function He(t,e,n=!0,r=!1){switch(e){case"?":return String(t.state.lastExitCode);case"$":return String(t.state.virtualPid);case"#":return t.state.env.get("#")||"0";case"@":return t.state.env.get("@")||"";case"_":return t.state.lastArg;case"-":{let o="";return o+="h",t.state.options.errexit&&(o+="e"),t.state.options.noglob&&(o+="f"),t.state.options.nounset&&(o+="u"),t.state.options.verbose&&(o+="v"),t.state.options.xtrace&&(o+="x"),o+="B",t.state.options.noclobber&&(o+="C"),o+="s",o}case"*":{let o=Number.parseInt(t.state.env.get("#")||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(t.state.env.get(String(l))||"");return a.join(Ie(t.state.env))}case"0":return t.state.env.get("0")||"bash";case"PWD":return t.state.env.get("PWD")??"";case"OLDPWD":return t.state.env.get("OLDPWD")??"";case"PPID":return String(t.state.virtualPpid);case"UID":return String(t.state.virtualUid);case"EUID":return String(t.state.virtualUid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-t.state.startTime)/1e3));case"BASH_VERSION":return dv;case"!":return String(t.state.lastBackgroundPid);case"BASHPID":return String(t.state.bashPid);case"LINENO":return String(t.state.currentLine);case"FUNCNAME":{let o=t.state.funcNameStack?.[0];if(o!==void 0)return o;if(n&&t.state.options.nounset)throw new Pn("FUNCNAME");return""}case"BASH_LINENO":{let o=t.state.callLineStack?.[0];if(o!==void 0)return String(o);if(n&&t.state.options.nounset)throw new Pn("BASH_LINENO");return""}case"BASH_SOURCE":{let o=t.state.sourceStack?.[0];if(o!==void 0)return o;if(n&&t.state.options.nounset)throw new Pn("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(e))throw new Rn(`\${${e}}`);let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(pt(t,o)){let f=Un(t,o);if(f&&f!==o){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return"";o=f}}if(a==="@"||a==="*"){let f=xe(t,o);if(f.length>0)return f.map(([,d])=>d).join(" ");let h=t.state.env.get(o);return h!==void 0?h:""}if(o==="FUNCNAME"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?t.state.funcNameStack?.[f]??"":""}if(o==="BASH_LINENO"){let f=Number.parseInt(a,10);if(!Number.isNaN(f)&&f>=0){let h=t.state.callLineStack?.[f];return h!==void 0?String(h):""}return""}if(o==="BASH_SOURCE"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?t.state.sourceStack?.[f]??"":""}if(t.state.associativeArrays?.has(o)){let f=yh(a);f=aH(t,f);let h=t.state.env.get(`${o}_${f}`);if(h===void 0&&n&&t.state.options.nounset)throw new Pn(`${o}[${a}]`);return h||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new Ne,h=Ge(f,a);c=await fe(t,h.expression)}catch{let f=t.state.env.get(a);c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=xe(t,o),h=t.state.currentLine;if(f.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${h}: ${o}: bad array subscript
1396
1396
  `,"";let p=Math.max(...f.map(([g])=>typeof g=="number"?g:0))+1+c;return p<0?(t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${h}: ${o}: bad array subscript
1397
- `,""):t.state.env.get(`${o}_${p}`)||""}let u=t.state.env.get(`${o}_${c}`);if(u!==void 0)return u;if(c===0){let f=t.state.env.get(o);if(f!==void 0)return f}if(n&&t.state.options.nounset)throw new Pn(`${o}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(e)){let o=t.state.env.get(e);if(o===void 0&&n&&t.state.options.nounset)throw new Pn(e);return o||""}if(pt(t,e)){let o=Un(t,e);if(o===void 0)return"";if(o!==e)return await Ge(t,o,n,r);let a=t.state.env.get(e);if((a===void 0||a==="")&&n&&t.state.options.nounset)throw new Pn(e);return a||""}let i=t.state.env.get(e);if(i!==void 0)return t.state.tempEnvBindings?.some(o=>o.has(e))&&(t.state.accessedTempEnvVars=t.state.accessedTempEnvVars||new Set,t.state.accessedTempEnvVars.add(e)),i;if(Us(t,e)){let o=t.state.env.get(`${e}_0`);return o!==void 0?o:""}if(n&&t.state.options.nounset)throw new Pn(e);return""}async function Ss(t,e){if(new Set(["?","$","#","_","-","0","PPID","UID","EUID","RANDOM","SECONDS","BASH_VERSION","!","BASHPID","LINENO"]).has(e))return!0;if(e==="@"||e==="*")return Number.parseInt(t.state.env.get("#")||"0",10)>0;if(e==="PWD"||e==="OLDPWD")return t.state.env.has(e);let r=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let s=r[1],i=r[2];if(pt(t,s)){let l=Un(t,s);if(l&&l!==s){if(l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;s=l}}if(i==="@"||i==="*")return xe(t,s).length>0?!0:t.state.env.has(s);if(t.state.associativeArrays?.has(s)){let l=yh(i);return t.state.env.has(`${s}_${l}`)}let a;if(/^-?\d+$/.test(i))a=Number.parseInt(i,10);else try{let l=new Ne,c=Ve(l,i);a=await fe(t,c.expression)}catch{let l=t.state.env.get(i);a=l?Number.parseInt(l,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let l=xe(t,s);if(l.length===0)return!1;let u=Math.max(...l.map(([f])=>typeof f=="number"?f:0))+1+a;return u<0?!1:t.state.env.has(`${s}_${u}`)}return t.state.env.has(`${s}_${a}`)}if(pt(t,e)){let s=Un(t,e);return s===void 0||s===e?t.state.env.has(e):Ss(t,s)}return!!(t.state.env.has(e)||Us(t,e))}var sr=I(()=>{"use strict";On();Bt();u6();zn();Me();Rr();yr();Xr()});function xC(t){return te(t.stdout)}async function SC(t,e){let n="",r=0;for(;r<e.length;){if(e[r]==="$"){if(e[r+1]==="{"){let s=1,i=r+2;for(;i<e.length&&s>0;)e[i]==="{"?s++:e[i]==="}"&&s--,i++;n+=e.slice(r,i),r=i;continue}if(e[r+1]==="("){let s=1,i=r+2;for(;i<e.length&&s>0;)e[i]==="("?s++:e[i]===")"&&s--,i++;n+=e.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(e[r+1]||"")){let s=r+1;for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)s++;let i=e.slice(r+1,s),o=await Ge(t,i);n+=o,r=s;continue}if(/[0-9]/.test(e[r+1]||"")){let s=r+1;for(;s<e.length&&/[0-9]/.test(e[s]);)s++;let i=e.slice(r+1,s),o=await Ge(t,i);n+=o,r=s;continue}if(/[*@#?\-!$]/.test(e[r+1]||"")){let s=e[r+1],i=await Ge(t,s);n+=i,r+=2;continue}}if(e[r]==='"'){for(n+='"',r++;r<e.length&&e[r]!=='"';)if(e[r]==="$"&&/[a-zA-Z_]/.test(e[r+1]||"")){let s=r+1;for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)s++;let i=e.slice(r+1,s),o=await Ge(t,i);n+=o,r=s}else e[r]==="\\"?(n+=e[r],r++,r<e.length&&(n+=e[r],r++)):(n+=e[r],r++);r<e.length&&(n+='"',r++);continue}n+=e[r],r++}return n}async function q6(t,e){let n=e,r=e.startsWith('"')&&e.endsWith('"'),s=e.startsWith("'")&&e.endsWith("'");if((r||s)&&(n=e.slice(1,-1)),s)return n;let i="",o=0;for(;o<n.length;)if(n[o]==="$")if(n[o+1]==="("){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="("&&n[l-1]==="$"||n[l]==="("?a++:n[l]===")"&&a--,l++;let c=n.slice(o+2,l-1);if(t.execFn){let u=await t.execFn(c,{signal:t.state.signal});i+=xC(u).replace(/\n+$/,""),u.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+u.stderr)}o=l}else if(n[o+1]==="{"){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="{"?a++:n[l]==="}"&&a--,l++;let c=n.slice(o+2,l-1),u=await Ge(t,c);i+=u,o=l}else if(/[a-zA-Z_]/.test(n[o+1]||"")){let a=o+1;for(;a<n.length&&/[a-zA-Z0-9_]/.test(n[a]);)a++;let l=n.slice(o+1,a),c=await Ge(t,l);i+=c,o=a}else i+=n[o],o++;else if(n[o]==="`"){let a=o+1;for(;a<n.length&&n[a]!=="`";)a++;let l=n.slice(o+1,a);if(t.execFn){let c=await t.execFn(l,{signal:t.state.signal});i+=xC(c).replace(/\n+$/,""),c.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+c.stderr)}o=a+1}else i+=n[o],o++;return i}var AC=I(()=>{"use strict";pe();sr()});function lH(t,e,n,r,s){let i=n??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,h=String(Math.abs(u)).padStart(l,"0");return f?`-${h}`:h}return String(u)};if(t<=e)for(let u=t,f=0;u<=e&&f<xh;u+=o,f++)a.push(c(u));else for(let u=t,f=0;u>=e&&f<xh;u-=o,f++)a.push(c(u));return a}function cH(t,e,n){let r=n??1;r===0&&(r=1);let s=t.charCodeAt(0),i=e.charCodeAt(0),o=Math.abs(r),a=t>="A"&&t<="Z",l=t>="a"&&t<="z",c=e>="A"&&e<="Z",u=e>="a"&&e<="z";if(a&&u||l&&c){let h=n!==void 0?`..${n}`:"";throw new bo(`{${t}..${e}${h}}: invalid sequence`)}let f=[];if(s<=i)for(let h=s,d=0;h<=i&&d<xh;h+=o,d++)f.push(String.fromCharCode(h));else for(let h=s,d=0;h>=i&&d<xh;h-=o,d++)f.push(String.fromCharCode(h));return f}function H6(t,e,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof t=="number"&&typeof e=="number"?{expanded:lH(t,e,n,r,s),literal:`{${t}..${e}${i}}`}:typeof t=="string"&&typeof e=="string"?{expanded:cH(t,e,n),literal:`{${t}..${e}${i}}`}:{expanded:null,literal:`{${t}..${e}${i}}`}}var xh,vC=I(()=>{"use strict";Me();xh=1e4});function CC(t){if(t.statements.length!==1)return null;let e=t.statements[0];if(e.operators.length!==0||e.pipelines.length!==1)return null;let n=e.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!=="SimpleCommand")return null;let s=r;if(s.name!==null||s.args.length!==0||s.assignments.length!==0||s.redirections.length!==1)return null;let i=s.redirections[0];return i.operator!=="<"||i.target.type!=="Word"?null:{target:i.target}}var kC=I(()=>{"use strict"});function As(t,e){return!!(/[*?[]/.test(t)||e&&/[@*+?!]\(/.test(t))}function V6(t){let e="",n=0;for(;n<t.length;)t[n]==="\\"&&n+1<t.length?(e+=t[n+1],n+=2):(e+=t[n],n++);return e}function ir(t){return t.replace(/([*?[\]\\()|])/g,"\\$1")}function ma(t){return t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}var ga=I(()=>{"use strict"});function qe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ya=I(()=>{"use strict"});function Ue(t,e,n=!1){let r="",s=0;for(;s<t.length;){let i=t[s];if(n&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<t.length&&t[s+1]==="("){let o=uH(t,s+1);if(o!==-1){let a=t.slice(s+2,o),c=fH(a).map(f=>Ue(f,e,n)),u=c.length>0?c.join("|"):"(?:)";i==="@"?r+=`(?:${u})`:i==="*"?r+=`(?:${u})*`:i==="+"?r+=`(?:${u})+`:i==="?"?r+=`(?:${u})?`:i==="!"&&(r+=`(?!(?:${u})$).*`),s=o+1;continue}}if(i==="\\")if(s+1<t.length){let o=t[s+1];/[\\^$.|+(){}[\]*?]/.test(o)?r+=`\\${o}`:r+=o,s+=2}else r+="\\\\",s++;else if(i==="*")r+=e?".*":".*?",s++;else if(i==="?")r+=".",s++;else if(i==="["){let o=hH(t,s);if(o===-1)r+="\\[",s++;else{let a=t.slice(s+1,o);r+=dH(a),s=o+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function uH(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function fH(t){let e=[],n="",r=0,s=0;for(;s<t.length;){let i=t[s];if(i==="\\"){n+=i,s+1<t.length?(n+=t[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(e.push(n),n=""):n+=i,s++}return e.push(n),e}function hH(t,e){let n=e+1;for(n<t.length&&t[n]==="^"&&n++,n<t.length&&t[n]==="]"&&n++;n<t.length;){if(t[n]==="\\"&&n+1<t.length){n+=2;continue}if(t[n]==="]")return n;if(t[n]==="'"){let r=t.indexOf("'",n+1);if(r!==-1){n=r+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let r=t.indexOf(":]",n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function dH(t){let e="[",n=0;for((t[0]==="^"||t[0]==="!")&&(e+="^",n++);n<t.length;){if(t[n]==="'"){let s=t.indexOf("'",n+1);if(s!==-1){let i=t.slice(n+1,s);for(let o of i)o==="\\"?e+="\\\\":o==="]"?e+="\\]":o==="^"&&e==="["?e+="\\^":e+=o;n=s+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){let i=t.slice(n+2,s);e+=mH(i),n=s+2;continue}}let r=t[n];r==="\\"?n+1<t.length?(e+=`\\${t[n+1]}`,n+=2):(e+="\\\\",n++):r==="-"&&n>0&&n<t.length-1?(e+="-",n++):r==="^"&&n===0?(e+="^",n++):(r==="]"&&n===0?e+="\\]":e+=r,n++)}return e+="]",e}function mH(t){return pH.get(t)??""}var pH,wa=I(()=>{"use strict";pH=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 zs(t,e,n,r){if(n==="prefix")return X(`^${e}`,"s").replace(t,"");let s=X(`${e}$`,"s");if(r)return s.replace(t,"");for(let i=t.length;i>=0;i--){let o=t.slice(i);if(s.test(o))return t.slice(0,i)}return t}function ba(t,e){let n=Array.from(t.state.env.keys()),r=new Set,s=t.state.associativeArrays??new Set,i=new Set;for(let a of n){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l&&i.add(l[1]);let c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&i.add(c[1])}let o=a=>{for(let l of s){let c=`${l}_`;if(a.startsWith(c)&&a!==l)return!0}return!1};for(let a of n)if(a.startsWith(e))if(a.includes("__")){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);l?.[1].startsWith(e)&&r.add(l[1])}else if(/_\d+$/.test(a)){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l?.[1].startsWith(e)&&r.add(l[1])}else o(a)||r.add(a);return[...r].sort()}var io=I(()=>{"use strict";bt()});function gH(t,e){let n=(i,o=2)=>String(i).padStart(o,"0");if(t===""){let i=n(e.getHours()),o=n(e.getMinutes()),a=n(e.getSeconds());return`${i}:${o}:${a}`}let r="",s=0;for(;s<t.length;)if(t[s]==="%"){if(s+1>=t.length){r+="%",s++;continue}let i=t[s+1];switch(i){case"H":r+=n(e.getHours());break;case"M":r+=n(e.getMinutes());break;case"S":r+=n(e.getSeconds());break;case"d":r+=n(e.getDate());break;case"m":r+=n(e.getMonth()+1);break;case"Y":r+=e.getFullYear();break;case"y":r+=n(e.getFullYear()%100);break;case"I":{let o=e.getHours()%12;o===0&&(o=12),r+=n(o);break}case"p":r+=e.getHours()<12?"AM":"PM";break;case"P":r+=e.getHours()<12?"am":"pm";break;case"%":r+="%";break;case"a":{r+=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.getDay()];break}case"b":{r+=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()];break}default:r+=`%${i}`}s+=2}else r+=t[s],s++;return r}function nc(t,e){let n="",r=0,s=t.state.env.get("USER")||t.state.env.get("LOGNAME")||"user",i=t.state.env.get("HOSTNAME")||"localhost",o=i.split(".")[0],a=t.state.env.get("PWD")||"/",l=t.state.env.get("HOME")||"/",c=a.startsWith(l)?`~${a.slice(l.length)}`:a,u=a.split("/").pop()||a,f=new Date,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],p=t.state.env.get("__COMMAND_NUMBER")||"1";for(;r<e.length;){let m=e[r];if(m==="\\"){if(r+1>=e.length){n+="\\",r++;continue}let g=e[r+1];if(g>="0"&&g<="7"){let y="",w=r+1;for(;w<e.length&&w<r+4&&e[w]>="0"&&e[w]<="7";)y+=e[w],w++;let b=Number.parseInt(y,8)%256;n+=String.fromCharCode(b),r=w;continue}switch(g){case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"e":n+="\x1B",r+=2;break;case"n":n+=`
1397
+ `,""):t.state.env.get(`${o}_${p}`)||""}let u=t.state.env.get(`${o}_${c}`);if(u!==void 0)return u;if(c===0){let f=t.state.env.get(o);if(f!==void 0)return f}if(n&&t.state.options.nounset)throw new Pn(`${o}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(e)){let o=t.state.env.get(e);if(o===void 0&&n&&t.state.options.nounset)throw new Pn(e);return o||""}if(pt(t,e)){let o=Un(t,e);if(o===void 0)return"";if(o!==e)return await He(t,o,n,r);let a=t.state.env.get(e);if((a===void 0||a==="")&&n&&t.state.options.nounset)throw new Pn(e);return a||""}let i=t.state.env.get(e);if(i!==void 0)return t.state.tempEnvBindings?.some(o=>o.has(e))&&(t.state.accessedTempEnvVars=t.state.accessedTempEnvVars||new Set,t.state.accessedTempEnvVars.add(e)),i;if(Us(t,e)){let o=t.state.env.get(`${e}_0`);return o!==void 0?o:""}if(n&&t.state.options.nounset)throw new Pn(e);return""}async function Jr(t,e){if(new Set(["?","$","#","_","-","0","PPID","UID","EUID","RANDOM","SECONDS","BASH_VERSION","!","BASHPID","LINENO"]).has(e))return!0;if(e==="@"||e==="*")return Number.parseInt(t.state.env.get("#")||"0",10)>0;if(e==="PWD"||e==="OLDPWD")return t.state.env.has(e);let r=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let s=r[1],i=r[2];if(pt(t,s)){let l=Un(t,s);if(l&&l!==s){if(l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;s=l}}if(i==="@"||i==="*")return xe(t,s).length>0?!0:t.state.env.has(s);if(t.state.associativeArrays?.has(s)){let l=yh(i);return t.state.env.has(`${s}_${l}`)}let a;if(/^-?\d+$/.test(i))a=Number.parseInt(i,10);else try{let l=new Ne,c=Ge(l,i);a=await fe(t,c.expression)}catch{let l=t.state.env.get(i);a=l?Number.parseInt(l,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let l=xe(t,s);if(l.length===0)return!1;let u=Math.max(...l.map(([f])=>typeof f=="number"?f:0))+1+a;return u<0?!1:t.state.env.has(`${s}_${u}`)}return t.state.env.has(`${s}_${a}`)}if(pt(t,e)){let s=Un(t,e);return s===void 0||s===e?t.state.env.has(e):Jr(t,s)}return!!(t.state.env.has(e)||Us(t,e))}var sr=I(()=>{"use strict";On();Bt();u6();zn();Me();Rr();yr();Xr()});function xC(t){return te(t.stdout)}async function SC(t,e){let n="",r=0;for(;r<e.length;){if(e[r]==="$"){if(e[r+1]==="{"){let s=1,i=r+2;for(;i<e.length&&s>0;)e[i]==="{"?s++:e[i]==="}"&&s--,i++;n+=e.slice(r,i),r=i;continue}if(e[r+1]==="("){let s=1,i=r+2;for(;i<e.length&&s>0;)e[i]==="("?s++:e[i]===")"&&s--,i++;n+=e.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(e[r+1]||"")){let s=r+1;for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)s++;let i=e.slice(r+1,s),o=await He(t,i);n+=o,r=s;continue}if(/[0-9]/.test(e[r+1]||"")){let s=r+1;for(;s<e.length&&/[0-9]/.test(e[s]);)s++;let i=e.slice(r+1,s),o=await He(t,i);n+=o,r=s;continue}if(/[*@#?\-!$]/.test(e[r+1]||"")){let s=e[r+1],i=await He(t,s);n+=i,r+=2;continue}}if(e[r]==='"'){for(n+='"',r++;r<e.length&&e[r]!=='"';)if(e[r]==="$"&&/[a-zA-Z_]/.test(e[r+1]||"")){let s=r+1;for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)s++;let i=e.slice(r+1,s),o=await He(t,i);n+=o,r=s}else e[r]==="\\"?(n+=e[r],r++,r<e.length&&(n+=e[r],r++)):(n+=e[r],r++);r<e.length&&(n+='"',r++);continue}n+=e[r],r++}return n}async function q6(t,e){let n=e,r=e.startsWith('"')&&e.endsWith('"'),s=e.startsWith("'")&&e.endsWith("'");if((r||s)&&(n=e.slice(1,-1)),s)return n;let i="",o=0;for(;o<n.length;)if(n[o]==="$")if(n[o+1]==="("){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="("&&n[l-1]==="$"||n[l]==="("?a++:n[l]===")"&&a--,l++;let c=n.slice(o+2,l-1);if(t.execFn){let u=await t.execFn(c,{signal:t.state.signal});i+=xC(u).replace(/\n+$/,""),u.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+u.stderr)}o=l}else if(n[o+1]==="{"){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="{"?a++:n[l]==="}"&&a--,l++;let c=n.slice(o+2,l-1),u=await He(t,c);i+=u,o=l}else if(/[a-zA-Z_]/.test(n[o+1]||"")){let a=o+1;for(;a<n.length&&/[a-zA-Z0-9_]/.test(n[a]);)a++;let l=n.slice(o+1,a),c=await He(t,l);i+=c,o=a}else i+=n[o],o++;else if(n[o]==="`"){let a=o+1;for(;a<n.length&&n[a]!=="`";)a++;let l=n.slice(o+1,a);if(t.execFn){let c=await t.execFn(l,{signal:t.state.signal});i+=xC(c).replace(/\n+$/,""),c.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+c.stderr)}o=a+1}else i+=n[o],o++;return i}var AC=I(()=>{"use strict";pe();sr()});function lH(t,e,n,r,s){let i=n??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,h=String(Math.abs(u)).padStart(l,"0");return f?`-${h}`:h}return String(u)};if(t<=e)for(let u=t,f=0;u<=e&&f<xh;u+=o,f++)a.push(c(u));else for(let u=t,f=0;u>=e&&f<xh;u-=o,f++)a.push(c(u));return a}function cH(t,e,n){let r=n??1;r===0&&(r=1);let s=t.charCodeAt(0),i=e.charCodeAt(0),o=Math.abs(r),a=t>="A"&&t<="Z",l=t>="a"&&t<="z",c=e>="A"&&e<="Z",u=e>="a"&&e<="z";if(a&&u||l&&c){let h=n!==void 0?`..${n}`:"";throw new bo(`{${t}..${e}${h}}: invalid sequence`)}let f=[];if(s<=i)for(let h=s,d=0;h<=i&&d<xh;h+=o,d++)f.push(String.fromCharCode(h));else for(let h=s,d=0;h>=i&&d<xh;h-=o,d++)f.push(String.fromCharCode(h));return f}function H6(t,e,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof t=="number"&&typeof e=="number"?{expanded:lH(t,e,n,r,s),literal:`{${t}..${e}${i}}`}:typeof t=="string"&&typeof e=="string"?{expanded:cH(t,e,n),literal:`{${t}..${e}${i}}`}:{expanded:null,literal:`{${t}..${e}${i}}`}}var xh,vC=I(()=>{"use strict";Me();xh=1e4});function CC(t){if(t.statements.length!==1)return null;let e=t.statements[0];if(e.operators.length!==0||e.pipelines.length!==1)return null;let n=e.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!=="SimpleCommand")return null;let s=r;if(s.name!==null||s.args.length!==0||s.assignments.length!==0||s.redirections.length!==1)return null;let i=s.redirections[0];return i.operator!=="<"||i.target.type!=="Word"?null:{target:i.target}}var kC=I(()=>{"use strict"});function As(t,e){return!!(/[*?[]/.test(t)||e&&/[@*+?!]\(/.test(t))}function V6(t){let e="",n=0;for(;n<t.length;)t[n]==="\\"&&n+1<t.length?(e+=t[n+1],n+=2):(e+=t[n],n++);return e}function ir(t){return t.replace(/([*?[\]\\()|])/g,"\\$1")}function ma(t){return t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}var ga=I(()=>{"use strict"});function qe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ya=I(()=>{"use strict"});function Ue(t,e,n=!1){let r="",s=0;for(;s<t.length;){let i=t[s];if(n&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<t.length&&t[s+1]==="("){let o=uH(t,s+1);if(o!==-1){let a=t.slice(s+2,o),c=fH(a).map(f=>Ue(f,e,n)),u=c.length>0?c.join("|"):"(?:)";i==="@"?r+=`(?:${u})`:i==="*"?r+=`(?:${u})*`:i==="+"?r+=`(?:${u})+`:i==="?"?r+=`(?:${u})?`:i==="!"&&(r+=`(?!(?:${u})$).*`),s=o+1;continue}}if(i==="\\")if(s+1<t.length){let o=t[s+1];/[\\^$.|+(){}[\]*?]/.test(o)?r+=`\\${o}`:r+=o,s+=2}else r+="\\\\",s++;else if(i==="*")r+=e?".*":".*?",s++;else if(i==="?")r+=".",s++;else if(i==="["){let o=hH(t,s);if(o===-1)r+="\\[",s++;else{let a=t.slice(s+1,o);r+=dH(a),s=o+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function uH(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function fH(t){let e=[],n="",r=0,s=0;for(;s<t.length;){let i=t[s];if(i==="\\"){n+=i,s+1<t.length?(n+=t[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(e.push(n),n=""):n+=i,s++}return e.push(n),e}function hH(t,e){let n=e+1;for(n<t.length&&t[n]==="^"&&n++,n<t.length&&t[n]==="]"&&n++;n<t.length;){if(t[n]==="\\"&&n+1<t.length){n+=2;continue}if(t[n]==="]")return n;if(t[n]==="'"){let r=t.indexOf("'",n+1);if(r!==-1){n=r+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let r=t.indexOf(":]",n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function dH(t){let e="[",n=0;for((t[0]==="^"||t[0]==="!")&&(e+="^",n++);n<t.length;){if(t[n]==="'"){let s=t.indexOf("'",n+1);if(s!==-1){let i=t.slice(n+1,s);for(let o of i)o==="\\"?e+="\\\\":o==="]"?e+="\\]":o==="^"&&e==="["?e+="\\^":e+=o;n=s+1;continue}}if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let s=t.indexOf(":]",n+2);if(s!==-1){let i=t.slice(n+2,s);e+=mH(i),n=s+2;continue}}let r=t[n];r==="\\"?n+1<t.length?(e+=`\\${t[n+1]}`,n+=2):(e+="\\\\",n++):r==="-"&&n>0&&n<t.length-1?(e+="-",n++):r==="^"&&n===0?(e+="^",n++):(r==="]"&&n===0?e+="\\]":e+=r,n++)}return e+="]",e}function mH(t){return pH.get(t)??""}var pH,wa=I(()=>{"use strict";pH=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 zs(t,e,n,r){if(n==="prefix")return X(`^${e}`,"s").replace(t,"");let s=X(`${e}$`,"s");if(r)return s.replace(t,"");for(let i=t.length;i>=0;i--){let o=t.slice(i);if(s.test(o))return t.slice(0,i)}return t}function ba(t,e){let n=Array.from(t.state.env.keys()),r=new Set,s=t.state.associativeArrays??new Set,i=new Set;for(let a of n){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l&&i.add(l[1]);let c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&i.add(c[1])}let o=a=>{for(let l of s){let c=`${l}_`;if(a.startsWith(c)&&a!==l)return!0}return!1};for(let a of n)if(a.startsWith(e))if(a.includes("__")){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);l?.[1].startsWith(e)&&r.add(l[1])}else if(/_\d+$/.test(a)){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l?.[1].startsWith(e)&&r.add(l[1])}else o(a)||r.add(a);return[...r].sort()}var io=I(()=>{"use strict";bt()});function gH(t,e){let n=(i,o=2)=>String(i).padStart(o,"0");if(t===""){let i=n(e.getHours()),o=n(e.getMinutes()),a=n(e.getSeconds());return`${i}:${o}:${a}`}let r="",s=0;for(;s<t.length;)if(t[s]==="%"){if(s+1>=t.length){r+="%",s++;continue}let i=t[s+1];switch(i){case"H":r+=n(e.getHours());break;case"M":r+=n(e.getMinutes());break;case"S":r+=n(e.getSeconds());break;case"d":r+=n(e.getDate());break;case"m":r+=n(e.getMonth()+1);break;case"Y":r+=e.getFullYear();break;case"y":r+=n(e.getFullYear()%100);break;case"I":{let o=e.getHours()%12;o===0&&(o=12),r+=n(o);break}case"p":r+=e.getHours()<12?"AM":"PM";break;case"P":r+=e.getHours()<12?"am":"pm";break;case"%":r+="%";break;case"a":{r+=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.getDay()];break}case"b":{r+=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()];break}default:r+=`%${i}`}s+=2}else r+=t[s],s++;return r}function nc(t,e){let n="",r=0,s=t.state.env.get("USER")||t.state.env.get("LOGNAME")||"user",i=t.state.env.get("HOSTNAME")||"localhost",o=i.split(".")[0],a=t.state.env.get("PWD")||"/",l=t.state.env.get("HOME")||"/",c=a.startsWith(l)?`~${a.slice(l.length)}`:a,u=a.split("/").pop()||a,f=new Date,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],p=t.state.env.get("__COMMAND_NUMBER")||"1";for(;r<e.length;){let m=e[r];if(m==="\\"){if(r+1>=e.length){n+="\\",r++;continue}let g=e[r+1];if(g>="0"&&g<="7"){let y="",w=r+1;for(;w<e.length&&w<r+4&&e[w]>="0"&&e[w]<="7";)y+=e[w],w++;let b=Number.parseInt(y,8)%256;n+=String.fromCharCode(b),r=w;continue}switch(g){case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"e":n+="\x1B",r+=2;break;case"n":n+=`
1398
1398
  `,r+=2;break;case"r":n+="\r",r+=2;break;case"$":n+="$",r+=2;break;case"[":case"]":r+=2;break;case"u":n+=s,r+=2;break;case"h":n+=o,r+=2;break;case"H":n+=i,r+=2;break;case"w":n+=c,r+=2;break;case"W":n+=u,r+=2;break;case"d":{let y=String(f.getDate()).padStart(2," ");n+=`${h[f.getDay()]} ${d[f.getMonth()]} ${y}`,r+=2;break}case"t":{let y=String(f.getHours()).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0"),b=String(f.getSeconds()).padStart(2,"0");n+=`${y}:${w}:${b}`,r+=2;break}case"T":{let y=f.getHours()%12;y===0&&(y=12);let w=String(y).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),E=String(f.getSeconds()).padStart(2,"0");n+=`${w}:${b}:${E}`,r+=2;break}case"@":{let y=f.getHours()%12;y===0&&(y=12);let w=String(y).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),E=f.getHours()<12?"AM":"PM";n+=`${w}:${b} ${E}`,r+=2;break}case"A":{let y=String(f.getHours()).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0");n+=`${y}:${w}`,r+=2;break}case"D":if(r+2<e.length&&e[r+2]==="{"){let y=e.indexOf("}",r+3);if(y!==-1){let w=e.slice(r+3,y);n+=gH(w,f),r=y+1}else n+="\\D",r+=2}else n+="\\D",r+=2;break;case"s":n+="bash",r+=2;break;case"v":n+="5.0",r+=2;break;case"V":n+="5.0.0",r+=2;break;case"j":n+="0",r+=2;break;case"l":n+="tty",r+=2;break;case"#":n+=p,r+=2;break;case"!":n+=p,r+=2;break;case"x":n+="\\x",r+=2;break;default:n+=`\\${g}`,r+=2}}else n+=m,r++}return n}var G6=I(()=>{"use strict"});function bi(t){if(t==="")return"''";if(/[\n\r\t\x00-\x1f\x7f']/.test(t)){let n="$'";for(let r of t)switch(r){case"'":n+="\\'";break;case"\\":n+="\\\\";break;case`
1399
1399
  `:n+="\\n";break;case"\r":n+="\\r";break;case" ":n+="\\t";break;default:{let s=r.charCodeAt(0);s<32||s===127?n+=`\\${s.toString(8).padStart(3,"0")}`:n+=r}}return`${n}'`}return`'${t}'`}var K6=I(()=>{"use strict"});function or(t,e){t.state.readonlyVars=t.state.readonlyVars||new Set,t.state.readonlyVars.add(e)}function vs(t,e){return t.state.readonlyVars?.has(e)??!1}function nn(t,e,n="bash"){if(vs(t,e)){let r=`${n}: ${e}: readonly variable
1400
- `;throw new Re(1,"",r)}return null}function Jr(t,e){let n=t.state.exportedVars?.has(e)??!1;if(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(e),t.state.localScopes.length>0&&t.state.localScopes[t.state.localScopes.length-1].has(e)&&!n){for(t.state.localExportedVars||(t.state.localExportedVars=[]);t.state.localExportedVars.length<t.state.localScopes.length;)t.state.localExportedVars.push(new Set);t.state.localExportedVars[t.state.localExportedVars.length-1].add(e)}}function Sh(t,e){t.state.exportedVars?.delete(e)}var Ei=I(()=>{"use strict";Me()});function xi(t,e){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))return"";let n="",r=t.state.env.has(`${e}__length`)||Array.from(t.state.env.keys()).some(i=>i.startsWith(`${e}_`)&&/^[0-9]+$/.test(i.slice(e.length+1))),s=t.state.associativeArrays?.has(e)??!1;return r&&!s&&(n+="a"),s&&(n+="A"),t.state.integerVars?.has(e)&&(n+="i"),pt(t,e)&&(n+="n"),vs(t,e)&&(n+="r"),t.state.exportedVars?.has(e)&&(n+="x"),n}var Ah=I(()=>{"use strict";Xr();Ei()});async function NC(t,e,n,r){return t.coverage?.hit("bash:expansion:default_value"),(n.isUnset||e.checkEmpty&&n.isEmpty)&&e.word?r(t,e.word.parts,n.inDoubleQuotes):n.effectiveValue}async function TC(t,e,n,r,s){if(t.coverage?.hit("bash:expansion:assign_default"),(r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let o=await s(t,n.word.parts,r.inDoubleQuotes),a=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,l,c]=a,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let h=new Ne,d=Ve(h,c);u=await fe(t,d.expression)}catch{let h=t.state.env.get(c);u=h?Number.parseInt(h,10):0}Number.isNaN(u)&&(u=0)}t.state.env.set(`${l}_${u}`,o);let f=Number.parseInt(t.state.env.get(`${l}__length`)||"0",10);u>=f&&t.state.env.set(`${l}__length`,String(u+1))}else t.state.env.set(e,o);return o}return r.effectiveValue}async function OC(t,e,n,r,s){if(t.coverage?.hit("bash:expansion:error_if_unset"),r.isUnset||n.checkEmpty&&r.isEmpty){let o=n.word?await s(t,n.word.parts,r.inDoubleQuotes):`${e}: parameter null or not set`;throw new Re(1,"",`bash: ${o}
1400
+ `;throw new Re(1,"",r)}return null}function es(t,e){let n=t.state.exportedVars?.has(e)??!1;if(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(e),t.state.localScopes.length>0&&t.state.localScopes[t.state.localScopes.length-1].has(e)&&!n){for(t.state.localExportedVars||(t.state.localExportedVars=[]);t.state.localExportedVars.length<t.state.localScopes.length;)t.state.localExportedVars.push(new Set);t.state.localExportedVars[t.state.localExportedVars.length-1].add(e)}}function Sh(t,e){t.state.exportedVars?.delete(e)}var Ei=I(()=>{"use strict";Me()});function xi(t,e){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))return"";let n="",r=t.state.env.has(`${e}__length`)||Array.from(t.state.env.keys()).some(i=>i.startsWith(`${e}_`)&&/^[0-9]+$/.test(i.slice(e.length+1))),s=t.state.associativeArrays?.has(e)??!1;return r&&!s&&(n+="a"),s&&(n+="A"),t.state.integerVars?.has(e)&&(n+="i"),pt(t,e)&&(n+="n"),vs(t,e)&&(n+="r"),t.state.exportedVars?.has(e)&&(n+="x"),n}var Ah=I(()=>{"use strict";Xr();Ei()});async function NC(t,e,n,r){return t.coverage?.hit("bash:expansion:default_value"),(n.isUnset||e.checkEmpty&&n.isEmpty)&&e.word?r(t,e.word.parts,n.inDoubleQuotes):n.effectiveValue}async function TC(t,e,n,r,s){if(t.coverage?.hit("bash:expansion:assign_default"),(r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let o=await s(t,n.word.parts,r.inDoubleQuotes),a=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,l,c]=a,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let h=new Ne,d=Ge(h,c);u=await fe(t,d.expression)}catch{let h=t.state.env.get(c);u=h?Number.parseInt(h,10):0}Number.isNaN(u)&&(u=0)}t.state.env.set(`${l}_${u}`,o);let f=Number.parseInt(t.state.env.get(`${l}__length`)||"0",10);u>=f&&t.state.env.set(`${l}__length`,String(u+1))}else t.state.env.set(e,o);return o}return r.effectiveValue}async function OC(t,e,n,r,s){if(t.coverage?.hit("bash:expansion:error_if_unset"),r.isUnset||n.checkEmpty&&r.isEmpty){let o=n.word?await s(t,n.word.parts,r.inDoubleQuotes):`${e}: parameter null or not set`;throw new Re(1,"",`bash: ${o}
1401
1401
  `)}return r.effectiveValue}async function IC(t,e,n,r){return t.coverage?.hit("bash:expansion:use_alternative"),!(n.isUnset||e.checkEmpty&&n.isEmpty)&&e.word?r(t,e.word.parts,n.inDoubleQuotes):""}async function PC(t,e,n,r,s){t.coverage?.hit("bash:expansion:pattern_removal");let i="",o=t.state.shoptOptions.extglob;if(n.pattern)for(let l of n.pattern.parts)if(l.type==="Glob")i+=Ue(l.pattern,n.greedy,o);else if(l.type==="Literal")i+=Ue(l.value,n.greedy,o);else if(l.type==="SingleQuoted"||l.type==="Escaped")i+=qe(l.value);else if(l.type==="DoubleQuoted"){let c=await r(t,l.parts);i+=qe(c)}else if(l.type==="ParameterExpansion"){let c=await s(t,l);i+=Ue(c,n.greedy,o)}else{let c=await s(t,l);i+=qe(c)}if(n.side==="prefix")return X(`^${i}`,"s").replace(e,"");let a=X(`${i}$`,"s");if(n.greedy)return a.replace(e,"");for(let l=e.length;l>=0;l--){let c=e.slice(l);if(a.test(c))return e.slice(0,l)}return e}async function RC(t,e,n,r,s){t.coverage?.hit("bash:expansion:pattern_replacement");let i="",o=t.state.shoptOptions.extglob;if(n.pattern)for(let c of n.pattern.parts)if(c.type==="Glob")i+=Ue(c.pattern,!0,o);else if(c.type==="Literal")i+=Ue(c.value,!0,o);else if(c.type==="SingleQuoted"||c.type==="Escaped")i+=qe(c.value);else if(c.type==="DoubleQuoted"){let u=await r(t,c.parts);i+=qe(u)}else if(c.type==="ParameterExpansion"){let u=await s(t,c);i+=Ue(u,!0,o)}else{let u=await s(t,c);i+=qe(u)}let a=n.replacement?await r(t,n.replacement.parts):"";if(n.anchor==="start"?i=`^${i}`:n.anchor==="end"&&(i=`${i}$`),i==="")return e;let l=n.all?"gs":"s";try{let c=X(i,l);if(n.all){let u="",f=0,h=0,d=t.limits.maxStringLength,p=c.exec(e);for(;p!==null&&!(p[0].length===0&&p.index===e.length);){if(u+=e.slice(f,p.index)+a,f=p.index+p[0].length,p[0].length===0&&f++,h++,h%100===0&&u.length>d)throw new ie(`pattern replacement: string length limit exceeded (${d} bytes)`,"string_length");p=c.exec(e)}return u+=e.slice(f),u}return c.replace(e,a)}catch(c){if(c instanceof ie)throw c;return e}}function $C(t,e,n){t.coverage?.hit("bash:expansion:length");let r=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let s=r[1],i=xe(t,s);return i.length>0?String(i.length):t.state.env.get(s)!==void 0?"1":"0"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)&&Us(t,e)){if(e==="FUNCNAME"){let i=t.state.funcNameStack?.[0]||"";return String([...i].length)}if(e==="BASH_LINENO"){let i=t.state.callLineStack?.[0];return String(i!==void 0?[...String(i)].length:0)}let s=t.state.env.get(`${e}_0`)||"";return String([...s].length)}return String([...n].length)}async function FC(t,e,n,r){t.coverage?.hit("bash:expansion:substring");let s=await fe(t,r.offset.expression),i=r.length?await fe(t,r.length.expression):void 0;if(e==="@"||e==="*"){let c=Number.parseInt(t.state.env.get("#")||"0",10),u=[];for(let p=1;p<=c;p++)u.push(t.state.env.get(String(p))||"");let f=t.state.env.get("0")||"bash",h,d;if(s<=0)if(h=[f,...u],s<0){if(d=h.length+s,d<0)return""}else d=0;else h=u,d=s-1;if(d<0||d>=h.length)return"";if(i!==void 0){let p=i<0?h.length+i:d+i;return h.slice(d,Math.max(d,p)).join(" ")}return h.slice(d).join(" ")}let o=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let c=o[1];if(t.state.associativeArrays?.has(c))throw new Re(1,"",`bash: \${${c}[@]: 0: 3}: bad substitution
1402
1402
  `);let u=xe(t,c),f=0;if(s<0){if(u.length>0){let h=u[u.length-1][0],p=(typeof h=="number"?h:0)+1+s;if(p<0||(f=u.findIndex(([m])=>typeof m=="number"&&m>=p),f<0))return""}}else if(f=u.findIndex(([h])=>typeof h=="number"&&h>=s),f<0)return"";if(i!==void 0){if(i<0)throw new lt(`${o[1]}[@]: substring expression < 0`);return u.slice(f,f+i).map(([,h])=>h).join(" ")}return u.slice(f).map(([,h])=>h).join(" ")}let a=[...n],l=s;if(l<0&&(l=Math.max(0,a.length+l)),i!==void 0){if(i<0){let c=a.length+i;return a.slice(l,Math.max(l,c)).join("")}return a.slice(l,l+i).join("")}return a.slice(l).join("")}async function _C(t,e,n,r,s){if(t.coverage?.hit("bash:expansion:case_modification"),n.pattern){let i=t.state.shoptOptions.extglob,o="";for(let f of n.pattern.parts)if(f.type==="Glob")o+=Ue(f.pattern,!0,i);else if(f.type==="Literal")o+=Ue(f.value,!0,i);else if(f.type==="SingleQuoted"||f.type==="Escaped")o+=qe(f.value);else if(f.type==="DoubleQuoted"){let h=await r(t,f.parts);o+=qe(h)}else if(f.type==="ParameterExpansion"){let h=await s(t,f);o+=Ue(h,!0,i)}let a=X(`^(?:${o})$`),l=n.direction==="upper"?f=>f.toUpperCase():f=>f.toLowerCase(),c="",u=!1;for(let f of e)!n.all&&u?c+=f:a.test(f)?(c+=l(f),u=!0):c+=f;return c}return n.direction==="upper"?n.all?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1):n.all?e.toLowerCase():e.charAt(0).toLowerCase()+e.slice(1)}function DC(t,e,n,r,s){t.coverage?.hit("bash:expansion:transform");let i=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(i&&s.operator==="Q")return xe(t,i[1]).map(([,c])=>bi(c)).join(" ");if(i&&s.operator==="a")return xi(t,i[1]);let o=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&s.operator==="a")return xi(t,o[1]);switch(s.operator){case"Q":return r?"":bi(n);case"P":return nc(t,n);case"a":return xi(t,e);case"A":return r?"":`${e}=${bi(n)}`;case"E":return n.replace(/\\([\\abefnrtv'"?])/g,(a,l)=>{switch(l){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
1403
- `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return l}});case"K":case"k":return r?"":bi(n);case"u":return n.charAt(0).toUpperCase()+n.slice(1);case"U":return n.toUpperCase();case"L":return n.toLowerCase();default:return n}}async function LC(t,e,n,r,s,i,o=!1){if(t.coverage?.hit("bash:expansion:indirection"),pt(t,e))return so(t,e)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(e);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new Rn(`\${!${e}}`)}let l=n;if(a&&(l===""||l.includes(" ")))throw new Rn(`\${!${e}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new Rn(`\${!${e}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(t,u,o)}return await Ge(t,l)}function MC(t,e){t.coverage?.hit("bash:expansion:array_keys");let r=xe(t,e.array).map(([s])=>String(s));return e.star?r.join(Ie(t.state.env)):r.join(" ")}function BC(t,e){t.coverage?.hit("bash:expansion:var_name_prefix");let n=ba(t,e.prefix);return e.star?n.join(Ie(t.state.env)):n.join(" ")}function UC(t,e,n,r){let s=Number.parseInt(t.state.env.get("#")||"0",10),i=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(e==="*")return{isEmpty:s===0,effectiveValue:n};if(e==="@")return{isEmpty:s===0||s===1&&t.state.env.get("1")==="",effectiveValue:n};if(i){let[,o,a]=i,l=xe(t,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=Ie(t.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:r?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:n==="",effectiveValue:n}}var zC=I(()=>{"use strict";On();Bt();bt();zn();Me();yr();Xr();ya();wa();io();G6();K6();sr();Ah()});function WC(t){return te(t.stdout)}function jC(t){let e=0;for(;e<t.length;){let n=t[e];if(n==="\\"&&e+1<t.length){e+=2;continue}if(n==="'"){let r=t.indexOf("'",e+1);if(r!==-1){e=r+1;continue}}if(n==="$"&&e+1<t.length&&t[e+1]==="("||n==="`")return!0;e++}return!1}function qC(t,e){let n=1,r=e,s=!1,i=!1;for(;r<t.length&&n>0;){let o=t[r];if(o==="\\"&&!s&&r+1<t.length){r+=2;continue}if(o==="'"&&!i){s=!s,r++;continue}if(o==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(o==="(")n++;else if(o===")"&&(n--,n===0))return r}r++}return-1}async function vh(t,e){let n=new Ne,r;try{r=n.parse(e)}catch{return""}let s=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let i=new Map(t.state.env),o=t.state.cwd,a=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let l=await t.executeScript(r),c=l.exitCode;return t.state.env=i,t.state.cwd=o,t.state.suppressVerbose=a,t.state.lastExitCode=c,t.state.env.set("?",String(c)),l.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+l.stderr),t.state.bashPid=s,WC(l).replace(/\n+$/,"")}catch(l){if(t.state.env=i,t.state.cwd=o,t.state.bashPid=s,t.state.suppressVerbose=a,l instanceof ie)throw l;return l instanceof Re?(t.state.lastExitCode=l.exitCode,t.state.env.set("?",String(l.exitCode)),WC({stdout:l.stdout??"",stdoutKind:l.stdoutKind,stdoutEncoding:l.stdoutEncoding}).replace(/\n+$/,"")):""}}function Z6(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="'"){let i=e.indexOf("'",r+1);if(i!==-1){let o=e.slice(r+1,i);n+=ir(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(r+1,i),l=yH(t,a);n+=ir(l),r=i+1;continue}}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<e.length){n+=s+e[r+1],r+=2;continue}n+=s,r++}return n}function yH(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="\\"&&r+1<e.length){let i=e[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}async function HC(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="'"){let i=e.indexOf("'",r+1);if(i!==-1){let o=e.slice(r+1,i);n+=ir(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(r+1,i),l=await wH(t,a);n+=ir(l),r=i+1;continue}}if(s==="$"&&r+1<e.length&&e[r+1]==="("){let i=qC(e,r+2);if(i!==-1){let o=e.slice(r+2,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="`"){let i=e.indexOf("`",r+1);if(i!==-1){let o=e.slice(r+1,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<e.length){n+=s+e[r+1],r+=2;continue}n+=s,r++}return n}async function wH(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="\\"&&r+1<e.length){let i=e[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<e.length&&e[r+1]==="("){let i=qC(e,r+2);if(i!==-1){let o=e.slice(r+2,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="`"){let i=e.indexOf("`",r+1);if(i!==-1){let o=e.slice(r+1,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}var VC=I(()=>{"use strict";pe();Bt();Me();ga()});function GC(t,e){if(!e.startsWith("~"))return e;t.coverage?.hit("bash:expansion:tilde");let n=t.state.env.get("HOME")!==void 0?t.state.env.get("HOME"):"/home/user";if(e==="~"||e.startsWith("~/"))return n+e.slice(1);let r=1;for(;r<e.length&&/[a-zA-Z0-9_-]/.test(e[r]);)r++;let s=e.slice(1,r),i=e.slice(r);return i!==""&&!i.startsWith("/")?e:s==="root"?`/root${i}`:e}var KC=I(()=>{"use strict"});async function bH(t,e,n,r){let s="";for(let i of e.parts)if(i.type==="Glob")s+=Ue(i.pattern,!0,t.state.shoptOptions.extglob);else if(i.type==="Literal")s+=Ue(i.value,!0,t.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=qe(i.value);else if(i.type==="DoubleQuoted"){let o=await n(t,i.parts);s+=qe(o)}else if(i.type==="ParameterExpansion"){let o=await r(t,i);s+=Ue(o,!0,t.state.shoptOptions.extglob)}else{let o=await r(t,i);s+=qe(o)}return s}async function ZC(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=xe(t,a),f=u.map(([,g])=>g);if(u.length===0){let g=t.state.env.get(a);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h="";c.pattern&&(h=await bH(t,c.pattern,n,r));let d=c.replacement?await n(t,c.replacement.parts):"",p=h;c.anchor==="start"?p=`^${h}`:c.anchor==="end"&&(p=`${h}$`);let m=[];try{let g=X(p,c.all?"g":"");for(let y of f)m.push(g.replace(y,d))}catch{m.push(...f)}if(l){let g=Ie(t.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}async function YC(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=xe(t,a),f=u.map(([,m])=>m);if(u.length===0){let m=t.state.env.get(a);m!==void 0&&f.push(m)}if(f.length===0)return{values:[],quoted:!0};let h="",d=t.state.shoptOptions.extglob;if(c.pattern)for(let m of c.pattern.parts)if(m.type==="Glob")h+=Ue(m.pattern,c.greedy,d);else if(m.type==="Literal")h+=Ue(m.value,c.greedy,d);else if(m.type==="SingleQuoted"||m.type==="Escaped")h+=qe(m.value);else if(m.type==="DoubleQuoted"){let g=await n(t,m.parts);h+=qe(g)}else if(m.type==="ParameterExpansion"){let g=await r(t,m);h+=Ue(g,c.greedy,d)}else{let g=await r(t,m);h+=qe(g)}let p=[];for(let m of f)p.push(zs(m,h,c.side,c.greedy));if(l){let m=Ie(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}var QC=I(()=>{"use strict";bt();yr();ya();wa();io();sr()});async function XC(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="DefaultValue"&&n.parts[0].operation?.type!=="UseAlternative"&&n.parts[0].operation?.type!=="AssignDefault")return null;let r=n.parts[0],s=r.operation,i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=xe(t,l),u=c.length>0||t.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,d])=>d===""),h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(h&&f):o=!u||h&&f,!o){if(c.length>0){let p=c.map(([,m])=>m);if(a){let m=Ie(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}let d=t.state.env.get(l);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await Ss(t,l),u=await Ge(t,l),f=u==="",h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(h&&f):o=!c||h&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){c=h[1],u=h[2]==="*";break}}if(c){let f=xe(t,c);if(f.length>0){let d=f.map(([,p])=>p);if(u||a){let p=Ie(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}let h=t.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function JC(t,e,n,r,s){if(!n||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0],o=-1,a="",l=!1,c=null;for(let m=0;m<i.parts.length;m++){let g=i.parts[m];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let y=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(y){o=m,a=y[1],l=y[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let m=0;m<o;m++)u+=await r(t,i.parts[m]);let f="";for(let m=o+1;m<i.parts.length;m++)f+=await r(t,i.parts[m]);let h=xe(t,a),d=h.map(([,m])=>m);if(h.length===0){let m=t.state.env.get(a);if(m!==void 0)d=[m];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let m=c,g="",y=t.state.shoptOptions.extglob;if(m.pattern)for(let w of m.pattern.parts)if(w.type==="Glob")g+=Ue(w.pattern,m.greedy,y);else if(w.type==="Literal")g+=Ue(w.value,m.greedy,y);else if(w.type==="SingleQuoted"||w.type==="Escaped")g+=qe(w.value);else if(w.type==="DoubleQuoted"){let b=await s(t,w.parts);g+=qe(b)}else if(w.type==="ParameterExpansion"){let b=await r(t,w);g+=Ue(b,m.greedy,y)}else{let b=await r(t,w);g+=qe(b)}d=d.map(w=>zs(w,g,m.side,m.greedy))}else if(c?.type==="PatternReplacement"){let m=c,g="";if(m.pattern)for(let b of m.pattern.parts)if(b.type==="Glob")g+=Ue(b.pattern,!0,t.state.shoptOptions.extglob);else if(b.type==="Literal")g+=Ue(b.value,!0,t.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")g+=qe(b.value);else if(b.type==="DoubleQuoted"){let E=await s(t,b.parts);g+=qe(E)}else if(b.type==="ParameterExpansion"){let E=await r(t,b);g+=Ue(E,!0,t.state.shoptOptions.extglob)}else{let E=await r(t,b);g+=qe(E)}let y=m.replacement?await s(t,m.replacement.parts):"",w=g;m.anchor==="start"?w=`^${g}`:m.anchor==="end"&&(w=`${g}$`);try{let b=X(w,m.all?"g":"");d=d.map(E=>b.replace(E,y))}catch{}}if(l){let m=Ie(t.state.env);return{values:[u+d.join(m)+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 ek(t,e,n,r){if(!n||e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o="",a=!1;for(let d=0;d<s.parts.length;d++){let p=s.parts[d];if(p.type==="ParameterExpansion"&&!p.operation){let m=p.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(m){i=d,o=m[1],a=m[2]==="*";break}}}if(i===-1)return null;let l="";for(let d=0;d<i;d++)l+=await r(t,s.parts[d]);let c="";for(let d=i+1;d<s.parts.length;d++)c+=await r(t,s.parts[d]);let u=xe(t,o),f=u.map(([,d])=>d);if(u.length===0){let d=t.state.env.get(o);if(d!==void 0)return{values:[l+d+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}if(a){let d=Ie(t.state.env);return{values:[l+f.join(d)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var tk=I(()=>{"use strict";bt();yr();ya();wa();io();sr()});async function nk(t,e,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="Substring")return null;let s=r.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(t.state.associativeArrays?.has(o))throw new Re(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
1404
- `);let c=l.offset?await n(t,l.offset.expression):0,u=l.length?await n(t,l.length.expression):void 0,f=xe(t,o),h=0;if(c<0){if(f.length>0){let p=f[f.length-1][0],g=(typeof p=="number"?p:0)+1+c;if(g<0)return{values:[],quoted:!0};h=f.findIndex(([y])=>typeof y=="number"&&y>=g),h<0&&(h=f.length)}}else h=f.findIndex(([p])=>typeof p=="number"&&p>=c),h<0&&(h=f.length);let d;if(u!==void 0){if(u<0)throw new lt(`${o}[@]: substring expression < 0`);d=f.slice(h,h+u).map(([,p])=>p)}else d=f.slice(h).map(([,p])=>p);if(d.length===0)return{values:[],quoted:!0};if(a){let p=Ie(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}function rk(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="Transform")return null;let r=n.parts[0],s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=r.operation,l=xe(t,i);if(l.length===0){let f=t.state.env.get(i);if(f!==void 0){let h;switch(a.operator){case"a":h="";break;case"P":h=nc(t,f);break;case"Q":h=bi(f);break;default:h=f}return{values:[h],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=xi(t,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>nc(t,f));break;case"Q":u=l.map(([,f])=>bi(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=Ie(t.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var sk=I(()=>{"use strict";Me();yr();G6();K6();sr();Ah()});function ik(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion")return null;let r=n.parts[0];if(r.operation)return null;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(pt(t,i)){let l=so(t,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=xe(t,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=t.state.env.get(i);return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function ok(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation)return null;let s=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!pt(t,s))return null;let i=so(t,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=xe(t,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=t.state.env.get(a);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var ak=I(()=>{"use strict";Xr();sr()});async function lk(t,e,n,r,s){if(!n||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await Ge(t,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let p=Number.parseInt(t.state.env.get("#")||"0",10),m=[];for(let g=1;g<=p;g++)m.push(t.state.env.get(String(g))||"");return l==="*"?{values:[m.join(Ie(t.state.env))],quoted:!0}:{values:m,quoted:!0}}return null}let u=c[1],f=c[2]==="*",h=xe(t,u);if(a.innerOp){if(a.innerOp.type==="Substring")return EH(t,h,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return xH(t,h,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let m=xi(t,u),g=h.map(()=>m);return f?{values:[g.join(Ie(t.state.env))],quoted:!0}:{values:g,quoted:!0}}let p=[];for(let[,m]of h){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},y=t.state.env.get("_indirect_elem_");t.state.env.set("_indirect_elem_",m);try{let w=await r(t,g,!0);p.push(w)}finally{y!==void 0?t.state.env.set("_indirect_elem_",y):t.state.env.delete("_indirect_elem_")}}return f?{values:[p.join(Ie(t.state.env))],quoted:!0}:{values:p,quoted:!0}}if(h.length>0){let p=h.map(([,m])=>m);return f?{values:[p.join(Ie(t.state.env))],quoted:!0}:{values:p,quoted:!0}}let d=t.state.env.get(u);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function EH(t,e,n,r,s){let i=s.offset?await fe(t,s.offset.expression):0,o=s.length?await fe(t,s.length.expression):void 0,a=0;if(i<0){if(e.length>0){let u=e[e.length-1][0],h=(typeof u=="number"?u:0)+1+i;if(h<0)return{values:[],quoted:!0};if(a=e.findIndex(([d])=>typeof d=="number"&&d>=h),a<0)return{values:[],quoted:!0}}}else if(a=e.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new lt(`${n}[@]: substring expression < 0`);l=e.slice(a,a+o)}else l=e.slice(a);let c=l.map(([,u])=>u);return r?{values:[c.join(Ie(t.state.env))],quoted:!0}:{values:c,quoted:!0}}async function xH(t,e,n,r,s,i){let o=s.checkEmpty??!1,a=e.map(([,u])=>u),l=e.length===0,c=e.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:r?{values:[a.join(Ie(t.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(t,s.word.parts,!0);return t.state.env.set(`${n}_0`,f),t.state.env.set(`${n}__length`,"1"),{values:[f],quoted:!0}}return r?{values:[a.join(Ie(t.state.env))],quoted:!0}:{values:a,quoted:!0}}return r?{values:[a.join(Ie(t.state.env))],quoted:!0}:{values:a,quoted:!0}}async function ck(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="UseAlternative"&&e[0].operation?.type!=="DefaultValue")return null;let n=e[0],r=n.operation,s=r?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await Ge(t,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await Ss(t,n.parameter),u=await Ge(t,n.parameter)==="",f=r.checkEmpty??!1,h;if(r.type==="UseAlternative"?h=c&&!(f&&u):h=!c||f&&u,h){let d=l[1],p=l[2]==="*",m=xe(t,d);if(m.length>0){let y=m.map(([,w])=>w);return p?{values:[y.join(Ie(t.state.env))],quoted:!0}:{values:y,quoted:!0}}let g=t.state.env.get(d);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function uk(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="Indirection")return null;let n=e[0],s=n.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await Ge(t,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await Ge(t,n.parameter),f=await Ss(t,n.parameter),h=u==="",d=s.checkEmpty??!1,p;if(s.type==="UseAlternative"?p=f&&!(d&&h):p=!f||d&&h,p){let m=c[1],g=c[2]==="*",y=xe(t,m);if(y.length>0){let b=y.map(([,E])=>E);return g?{values:[b.join(Ie(t.state.env))],quoted:!0}:{values:b,quoted:!0}}let w=t.state.env.get(m);return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var fk=I(()=>{"use strict";zn();Me();yr();sr();Ah()});function hk(t){let e=Number.parseInt(t.state.env.get("#")||"0",10),n=[];for(let r=1;r<=e;r++)n.push(t.state.env.get(String(r))||"");return n}async function dk(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let w=0;w<s.parts.length;w++){let b=s.parts[w];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=w,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await n(t,l.offset.expression):0,u=l.length?await n(t,l.length.expression):void 0,f=Number.parseInt(t.state.env.get("#")||"0",10),h=[];for(let w=1;w<=f;w++)h.push(t.state.env.get(String(w))||"");let d=t.state.env.get("0")||"bash",p;if(c<=0){let w=[d,...h],b=w.length+c;if(b<0)p=[];else{let E=c<0?b:0;if(u!==void 0){let A=u<0?w.length+u:E+u;p=w.slice(E,Math.max(E,A))}else p=w.slice(E)}}else{let w=c-1;if(w>=h.length)p=[];else if(u!==void 0){let b=u<0?h.length+u:w+u;p=h.slice(w,Math.max(w,b))}else p=h.slice(w)}let m="";for(let w=0;w<i;w++)m+=await r(t,s.parts[w]);let g="";for(let w=i+1;w<s.parts.length;w++)g+=await r(t,s.parts[w]);if(p.length===0){let w=m+g;return{values:w?[w]:[],quoted:!0}}if(o){let w=Ie(t.state.env);return{values:[m+p.join(w)+g],quoted:!0}}return p.length===1?{values:[m+p[0]+g],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+g],quoted:!0}}async function pk(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let w=s.parts[y];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternReplacement"){i=y,o=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=hk(t),u="";for(let y=0;y<i;y++)u+=await n(t,s.parts[y]);let f="";for(let y=i+1;y<s.parts.length;y++)f+=await n(t,s.parts[y]);if(c.length===0){let y=u+f;return{values:y?[y]:[],quoted:!0}}let h="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")h+=Ue(y.pattern,!0,t.state.shoptOptions.extglob);else if(y.type==="Literal")h+=Ue(y.value,!0,t.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")h+=qe(y.value);else if(y.type==="DoubleQuoted"){let w=await r(t,y.parts);h+=qe(w)}else if(y.type==="ParameterExpansion"){let w=await n(t,y);h+=Ue(w,!0,t.state.shoptOptions.extglob)}else{let w=await n(t,y);h+=qe(w)}let d=l.replacement?await r(t,l.replacement.parts):"",p=h;l.anchor==="start"?p=`^${h}`:l.anchor==="end"&&(p=`${h}$`);let m=[];try{let y=X(p,l.all?"g":"");for(let w of c)m.push(y.replace(w,d))}catch{m.push(...c)}if(o){let y=Ie(t.state.env);return{values:[u+m.join(y)+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 mk(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let y=s.parts[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){i=g,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=hk(t),u="";for(let g=0;g<i;g++)u+=await n(t,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await n(t,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let h="",d=t.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")h+=Ue(g.pattern,l.greedy,d);else if(g.type==="Literal")h+=Ue(g.value,l.greedy,d);else if(g.type==="SingleQuoted"||g.type==="Escaped")h+=qe(g.value);else if(g.type==="DoubleQuoted"){let y=await r(t,g.parts);h+=qe(y)}else if(g.type==="ParameterExpansion"){let y=await n(t,g);h+=Ue(y,l.greedy,d)}else{let y=await n(t,g);h+=qe(y)}let p=[];for(let g of c)p.push(zs(g,h,l.side,l.greedy));if(o){let g=Ie(t.state.env);return{values:[u+p.join(g)+f],quoted:!0}}return p.length===1?{values:[u+p[0]+f],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+f],quoted:!0}}async function gk(t,e,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0],s=-1,i=!1;for(let h=0;h<r.parts.length;h++){let d=r.parts[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")){s=h,i=d.parameter==="*";break}}if(s===-1)return null;let o=r.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(t.state.env.get("#")||"0",10),l="";for(let h=0;h<s;h++)l+=await n(t,r.parts[h]);let c="";for(let h=s+1;h<r.parts.length;h++)c+=await n(t,r.parts[h]);if(a===0){if(i)return{values:[l+c],quoted:!0};let h=l+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=a;h++)u.push(t.state.env.get(String(h))||"");if(i){let h=Ie(t.state.env);return{values:[l+u.join(h)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var yk=I(()=>{"use strict";bt();yr();ya();wa();io()});function SH(t){return new wi(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations})}async function Ch(t,e){if(t.state.options.noglob)return e;let n=SH(t),r=[];for(let s of e)if(As(s,t.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new as(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function wk(t,e,n,r){let s=-1,i="",o=!1;for(let w=0;w<e.length;w++){let b=e[w];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let E=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(E){s=w,i=E[1],o=E[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=xe(t,i),u=c.map(([,w])=>w);if(c.length===0){let w=t.state.env.get(i);w!==void 0&&(u=[w])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")f+=Ue(w.pattern,!0,t.state.shoptOptions.extglob);else if(w.type==="Literal")f+=Ue(w.value,!0,t.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")f+=qe(w.value);else if(w.type==="DoubleQuoted"){let b=await n(t,w.parts);f+=qe(b)}else if(w.type==="ParameterExpansion"){let b=await r(t,w);f+=Ue(b,!0,t.state.shoptOptions.extglob)}else{let b=await r(t,w);f+=qe(b)}let h=l.replacement?await n(t,l.replacement.parts):"",d=f;l.anchor==="start"?d=`^${f}`:l.anchor==="end"&&(d=`${f}$`);let p=[];try{let w=X(d,l.all?"g":"");for(let b of u)p.push(w.replace(b,h))}catch{p.push(...u)}let m=Xt(t.state.env),g=Sn(t.state.env);if(o){let w=Ie(t.state.env),b=p.join(w);return g?{values:b?[b]:[],quoted:!1}:{values:St(b,m),quoted:!1}}if(g)return{values:p,quoted:!1};let y=[];for(let w of p)w===""?y.push(""):y.push(...St(w,m));return{values:y,quoted:!1}}async function bk(t,e,n,r){let s=-1,i="",o=!1;for(let y=0;y<e.length;y++){let w=e[y];if(w.type==="ParameterExpansion"&&w.operation?.type==="PatternRemoval"){let b=w.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=y,i=b[1],o=b[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=xe(t,i),u=c.map(([,y])=>y);if(c.length===0){let y=t.state.env.get(i);y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="",h=t.state.shoptOptions.extglob;if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=Ue(y.pattern,l.greedy,h);else if(y.type==="Literal")f+=Ue(y.value,l.greedy,h);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=qe(y.value);else if(y.type==="DoubleQuoted"){let w=await n(t,y.parts);f+=qe(w)}else if(y.type==="ParameterExpansion"){let w=await r(t,y);f+=Ue(w,l.greedy,h)}else{let w=await r(t,y);f+=qe(w)}let d=[];for(let y of u)d.push(zs(y,f,l.side,l.greedy));let p=Xt(t.state.env),m=Sn(t.state.env);if(o){let y=Ie(t.state.env),w=d.join(y);return m?{values:w?[w]:[],quoted:!1}:{values:St(w,p),quoted:!1}}if(m)return{values:d,quoted:!1};let g=[];for(let y of d)y===""?g.push(""):g.push(...St(y,p));return{values:g,quoted:!1}}async function Ek(t,e,n,r){let s=-1,i=!1;for(let g=0;g<e.length;g++){let y=e[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){s=g,i=y.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=Number.parseInt(t.state.env.get("#")||"0",10),c=[];for(let g=1;g<=l;g++)c.push(t.state.env.get(String(g))||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=t.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=Ue(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=Ue(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=qe(g.value);else if(g.type==="DoubleQuoted"){let y=await n(t,g.parts);u+=qe(y)}else if(g.type==="ParameterExpansion"){let y=await r(t,g);u+=Ue(y,a.greedy,f)}else{let y=await r(t,g);u+=qe(y)}let h=[];for(let g of c)h.push(zs(g,u,a.side,a.greedy));let d=Xt(t.state.env),p=Sn(t.state.env);if(i){let g=Ie(t.state.env),y=h.join(g);return p?{values:y?[y]:[],quoted:!1}:{values:St(y,d),quoted:!1}}if(p)return{values:h,quoted:!1};let m=[];for(let g of h)g===""?m.push(""):m.push(...St(g,d));return{values:m,quoted:!1}}async function xk(t,e,n,r){let s=-1,i=!1;for(let b=0;b<e.length;b++){let E=e[b];if(E.type==="ParameterExpansion"&&(E.parameter==="@"||E.parameter==="*")&&E.operation?.type==="Substring"){s=b,i=E.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=a.offset?await n(t,a.offset.expression):0,c=a.length?await n(t,a.length.expression):void 0,u=Number.parseInt(t.state.env.get("#")||"0",10),f=[];for(let b=1;b<=u;b++)f.push(t.state.env.get(String(b))||"");let h=t.state.env.get("0")||"bash",d;if(l<=0){let b=[h,...f],E=b.length+l;if(E<0)d=[];else{let A=l<0?E:0;if(c!==void 0){let C=c<0?b.length+c:A+c;d=b.slice(A,Math.max(A,C))}else d=b.slice(A)}}else{let b=l-1;if(b>=f.length)d=[];else if(c!==void 0){let E=c<0?f.length+c:b+c;d=f.slice(b,Math.max(b,E))}else d=f.slice(b)}let p="";for(let b=0;b<s;b++)p+=await r(t,e[b]);let m="";for(let b=s+1;b<e.length;b++)m+=await r(t,e[b]);let g=Xt(t.state.env),y=Sn(t.state.env);if(d.length===0){let b=p+m;return b?y?{values:[b],quoted:!1}:{values:St(b,g),quoted:!1}:{values:[],quoted:!1}}let w;if(i){let b=Ie(t.state.env),E=p+d.join(b)+m;y?w=E?[E]:[]:w=St(E,g)}else if(y)d.length===1?w=[p+d[0]+m]:w=[p+d[0],...d.slice(1,-1),d[d.length-1]+m];else{w=[];for(let b=0;b<d.length;b++){let E=d[b];if(b===0&&(E=p+E),b===d.length-1&&(E=E+m),E==="")w.push("");else{let A=St(E,g);w.push(...A)}}}return{values:await Ch(t,w),quoted:!1}}async function Sk(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].parameter!=="@"&&e[0].parameter!=="*"||e[0].operation)return null;let n=e[0].parameter==="*",r=Number.parseInt(t.state.env.get("#")||"0",10);if(r===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=r;c++)s.push(t.state.env.get(String(c))||"");let i=Xt(t.state.env),o=Sn(t.state.env),a=wh(t.state.env),l;if(n)if(o)l=s.filter(c=>c!=="");else{let c=Ie(t.state.env),u=s.join(c);l=St(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=St(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=St(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await Ch(t,l),quoted:!1}}async function Ak(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation)return null;let n=e[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],s=n[2]==="*",i=xe(t,r),o;if(i.length===0){let f=t.state.env.get(r);if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=Xt(t.state.env),l=Sn(t.state.env),c=wh(t.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=Ie(t.state.env),h=o.join(f);u=St(h,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let h=St(f,a);u.push(...h)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let h=St(f,a);u.push(...h)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await Ch(t,u),quoted:!1}}function vk(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="VarNamePrefix")return null;let n=e[0].operation,r=ba(t,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=Xt(t.state.env),i=Sn(t.state.env),o;if(n.star)if(i)o=r;else{let a=Ie(t.state.env),l=r.join(a);o=St(l,s)}else if(i)o=r;else{o=[];for(let a of r){let l=St(a,s);o.push(...l)}}return{values:o,quoted:!1}}function Ck(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="ArrayKeys")return null;let n=e[0].operation,s=xe(t,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=Xt(t.state.env),o=Sn(t.state.env),a;if(n.star)if(o)a=s;else{let l=Ie(t.state.env),c=s.join(l);a=St(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=St(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function kk(t,e,n){let r=-1;for(let h=0;h<e.length;h++){let d=e[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")&&!d.operation){r=h;break}}if(r===-1||e.length<=1)return null;let s=Number.parseInt(t.state.env.get("#")||"0",10),i=[];for(let h=1;h<=s;h++)i.push(t.state.env.get(String(h))||"");let o="";for(let h=0;h<r;h++)o+=await n(t,e[h]);let a="";for(let h=r+1;h<e.length;h++)a+=await n(t,e[h]);let l=Xt(t.state.env),c=Sn(t.state.env),u=wh(t.state.env);if(s===0){let h=o+a;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let d=0;d<i.length;d++){let p=i[d];d===0&&(p=o+p),d===i.length-1&&(p=p+a),h.push(p)}if(c)f=h.filter(d=>d!=="");else if(u){f=[];for(let d of h){if(d==="")continue;let p=St(d,l);f.push(...p)}}else{f=[];for(let d of h)if(d==="")f.push("");else{let p=St(d,l);f.push(...p)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await Ch(t,f),quoted:!1}}var Nk=I(()=>{"use strict";bt();mh();Me();yr();ya();ga();wa();io();sr()});async function Ik(t,e,n){t.coverage?.hit("bash:expansion:word_glob");let r=e.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=tc(r),h=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(t,e):null;if(h&&h.length>1)return AH(t,h,s);let d=await vH(t,r,a,c,u,n);if(d!==null)return d;let p=await kH(t,r,n);if(p!==null)return p;let m=await NH(t,r,n);if(m!==null)return m;let g=await OH(t,r,n.expandPart);if(g!==null)return Ok(t,g);if((i||o||l)&&!Sn(t.state.env)){let w=Xt(t.state.env),b=n.buildIfsCharClassPattern(w),E=await n.smartWordSplit(t,r,w,b,n.expandPart);return Ok(t,E)}let y=await n.expandWordAsync(t,e);return IH(t,e,r,y,s,n.expandWordForGlobbing)}async function AH(t,e,n){let r=[];for(let s of e)if(!(!n&&s===""))if(!n&&!t.state.options.noglob&&As(s,t.state.shoptOptions.extglob)){let i=await kh(t,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function vH(t,e,n,r,s,i){if(n){let o=ik(t,e);if(o!==null)return o}{let o=ok(t,e);if(o!==null)return o}{let o=await XC(t,e);if(o!==null)return o}{let o=await JC(t,e,n,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await ek(t,e,n,i.expandPart);if(o!==null)return o}{let o=await nk(t,e,i.evaluateArithmetic);if(o!==null)return o}{let o=rk(t,e);if(o!==null)return o}{let o=await ZC(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await YC(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(r&&e.length===1&&e[0].type==="DoubleQuoted"){let o=CH(t,e);if(o!==null)return o}{let o=await lk(t,e,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await ck(t,e);if(o!==null)return o}{let o=await uk(t,e);if(o!==null)return o}return null}function CH(t,e){let n=e[0];if(n.type!=="DoubleQuoted")return null;if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="VarNamePrefix"){let r=n.parts[0].operation,s=ba(t,r.prefix);return r.star?{values:[s.join(Ie(t.state.env))],quoted:!0}:{values:s,quoted:!0}}if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="ArrayKeys"){let r=n.parts[0].operation,i=xe(t,r.array).map(([o])=>String(o));return r.star?{values:[i.join(Ie(t.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function kH(t,e,n){{let r=await dk(t,e,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await pk(t,e,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await mk(t,e,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await gk(t,e,n.expandPart);if(r!==null)return r}return null}async function NH(t,e,n){{let r=await wk(t,e,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await bk(t,e,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Ek(t,e,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await xk(t,e,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await Sk(t,e);if(r!==null)return r}{let r=await Ak(t,e);if(r!==null)return r}{let r=vk(t,e);if(r!==null)return r}{let r=Ck(t,e);if(r!==null)return r}{let r=await kk(t,e,n.expandPart);if(r!==null)return r}return null}function Tk(t){if(t.type!=="DoubleQuoted")return null;for(let e=0;e<t.parts.length;e++){let n=t.parts[e];if(n.type!=="ParameterExpansion"||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:"array",name:r[1],atIndex:e,isStar:r[2]==="*"};if(n.parameter==="@"||n.parameter==="*")return{type:"positional",atIndex:e,isStar:n.parameter==="*"}}return null}async function TH(t,e,n,r){let s="";for(let a=0;a<n.atIndex;a++)s+=await r(t,e.parts[a]);let i="";for(let a=n.atIndex+1;a<e.parts.length;a++)i+=await r(t,e.parts[a]);let o;if(n.type==="array"){if(o=xe(t,n.name).map(([,l])=>l),o.length===0){let l=t.state.env.get(n.name);l!==void 0&&(o=[l])}}else{let a=Number.parseInt(t.state.env.get("#")||"0",10);o=[];for(let l=1;l<=a;l++)o.push(t.state.env.get(String(l))||"")}if(n.isStar){let a=Ie(t.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function OH(t,e,n){if(e.length<2)return null;let r=!1;for(let l of e)if(Tk(l)){r=!0;break}if(!r)return null;let s=Xt(t.state.env),i=Sn(t.state.env),o=[];for(let l of e){let c=Tk(l);if(c&&l.type==="DoubleQuoted"){let u=await TH(t,l,c,n);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(t,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(t,l);if(i)o.push(u?[u]:[]);else{let f=St(u,s);o.push(f)}}else{let u=await n(t,l);if(i)o.push(u?[u]:[]);else{let f=St(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function Ok(t,e){if(t.state.options.noglob)return{values:e,quoted:!1};let n=[];for(let r of e)if(As(r,t.state.shoptOptions.extglob)){let s=await kh(t,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function kh(t,e){let n=new wi(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations}),r=await n.expand(e);if(r.length>0)return r;if(n.hasFailglob())throw new as(e);return n.hasNullglob()?[]:[e]}async function IH(t,e,n,r,s,i){let o=n.some(a=>a.type==="Glob");if(!t.state.options.noglob&&o){let a=await i(t,e);if(As(a,t.state.shoptOptions.extglob)){let c=await kh(t,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=V6(r);if(!Sn(t.state.env)){let c=Xt(t.state.env);return{values:St(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!t.state.options.noglob&&As(r,t.state.shoptOptions.extglob)){let a=await i(t,e);if(As(a,t.state.shoptOptions.extglob)){let l=await kh(t,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=V6(r);if(!Sn(t.state.env)){let l=Xt(t.state.env);return{values:St(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[r],quoted:s}}var Pk=I(()=>{"use strict";mh();Me();yr();gh();QC();tk();sk();ak();ga();fk();io();yk();Nk();sr()});async function $k(t,e){let n=e.operation;if(!n||n.type!=="DefaultValue"&&n.type!=="AssignDefault"&&n.type!=="UseAlternative")return null;let r=n.word;if(!r||r.parts.length===0)return null;let s=await Ss(t,e.parameter),o=await Ge(t,e.parameter,!1)==="",a=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?r.parts:null}function PH(t){return t.type==="SingleQuoted"?!0:t.type==="DoubleQuoted"?t.parts.every(n=>n.type==="Literal"):!1}async function RH(t,e){if(e.type!=="ParameterExpansion")return null;let n=await $k(t,e);if(!n||n.length<=1)return null;let r=n.some(i=>PH(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function $H(t){return t.type==="DoubleQuoted"||t.type==="SingleQuoted"||t.type==="Literal"?!1:t.type==="Glob"?B6(t.pattern):!(!(t.type==="ParameterExpansion"||t.type==="CommandSubstitution"||t.type==="ArithmeticExpansion")||t.type==="ParameterExpansion"&&pC(t))}async function Fk(t,e,n,r,s){if(t.coverage?.hit("bash:expansion:word_split"),e.length===1&&e[0].type==="ParameterExpansion"){let h=e[0],d=await $k(t,h);if(d&&d.length>0&&d.length>1&&d.some(m=>m.type==="DoubleQuoted"||m.type==="SingleQuoted")&&d.some(m=>m.type==="Literal"||m.type==="ParameterExpansion"||m.type==="CommandSubstitution"||m.type==="ArithmeticExpansion"))return Rk(t,d,n,r,s)}let i=[],o=!1;for(let h of e){let d=$H(h),p=h.type==="DoubleQuoted"||h.type==="SingleQuoted",m=d?await RH(t,h):null,g=await s(t,h);i.push({value:g,isSplittable:d,isQuoted:p,mixedDefaultParts:m??void 0}),d&&(o=!0)}if(!o){let h=i.map(d=>d.value).join("");return h?[h]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let h of i)if(!h.isSplittable)u?h.isQuoted&&h.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):h.value!==""?(l!==""&&a.push(l),l=h.value,u=!1,f=!1):(l+=h.value,f=!1):(l+=h.value,f=h.isQuoted&&h.value==="");else if(h.mixedDefaultParts){let d=await Rk(t,h.mixedDefaultParts,n,r,s);if(d.length!==0)if(d.length===1)l+=d[0],c=!0;else{l+=d[0],a.push(l),c=!0;for(let p=1;p<d.length-1;p++)a.push(d[p]);l=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:p,hadTrailingDelimiter:m}=bh(h.value,n);if(f&&p&&l===""&&(a.push(""),c=!0),d.length===0)m&&(u=!0);else if(d.length===1)l+=d[0],c=!0,u=m;else{l+=d[0],a.push(l),c=!0;for(let g=1;g<d.length-1;g++)a.push(d[g]);l=d[d.length-1],u=m}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function FH(t,e){return t.length>0&&e.includes(t[0])}async function Rk(t,e,n,r,s){let i=[];for(let u of e){let h=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),d=await s(t,u);i.push({value:d,isSplittable:h})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{FH(u.value,n)&&a!==""&&(o.push(a),a="",l=!0);let{words:h,hadTrailingDelimiter:d}=bh(u.value,n);if(h.length===0)d&&(c=!0);else if(h.length===1)a+=h[0],l=!0,c=d;else{a+=h[0],o.push(a),l=!0;for(let p=1;p<h.length-1;p++)o.push(h[p]);a=h[h.length-1],c=d}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var _k=I(()=>{"use strict";sr();yr();gh()});function Dk(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function Lk(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}var Mk=I(()=>{"use strict"});var tw={};ee(tw,{escapeGlobChars:()=>ir,escapeRegexChars:()=>ma,expandRedirectTarget:()=>sc,expandWord:()=>ge,expandWordForPattern:()=>J6,expandWordForRegex:()=>X6,expandWordWithGlob:()=>$r,getArrayElements:()=>xe,getVariable:()=>Ge,hasQuotedMultiValueAt:()=>rc,isArray:()=>Us,isWordFullyQuoted:()=>Q6});function Si(t,e,n){if(t.length>e)throw new ie(`${n}: string length limit exceeded (${e} bytes)`,"string_length")}function Bk(t){return te(t.stdout)}async function es(t,e,n=!1){let r=[];for(let s of e)r.push(await wr(t,s,n));return r.join("")}function _H(t){return Lk(t)}function Q6(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!_H(e))return!1;return!0}function DH(t,e,n=!1){let r=Dk(e);if(r!==null)return r;switch(e.type){case"TildeExpansion":return n?e.user===null?"~":`~${e.user}`:(t.coverage?.hit("bash:expansion:tilde"),e.user===null?t.state.env.get("HOME")??"/home/user":e.user==="root"?"/root":`~${e.user}`);case"Glob":return Z6(t,e.pattern);default:return null}}async function ge(t,e){return ew(t,e)}async function X6(t,e){let n=[];for(let r of e.parts)if(r.type==="Escaped")n.push(`\\${r.value}`);else if(r.type==="SingleQuoted")n.push(r.value);else if(r.type==="DoubleQuoted"){let s=await es(t,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await wr(t,r);n.push(ma(s))}else n.push(await wr(t,r));return n.join("")}async function J6(t,e){let n=[];for(let r of e.parts)if(r.type==="Escaped"){let s=r.value;"()|*?[]".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="SingleQuoted")n.push(ir(r.value));else if(r.type==="DoubleQuoted"){let s=await es(t,r.parts);n.push(ir(s))}else n.push(await wr(t,r));return n.join("")}async function Uk(t,e){let n=[];for(let r of e.parts)if(r.type==="SingleQuoted")n.push(ir(r.value));else if(r.type==="Escaped"){let s=r.value;"*?[]\\()|".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="DoubleQuoted"){let s=await es(t,r.parts);n.push(ir(s))}else r.type==="Glob"?jC(r.pattern)?n.push(await HC(t,r.pattern)):n.push(Z6(t,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await wr(t,r));return n.join("")}function Th(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&Th(e.parts))return!0;return!1}async function zk(t,e,n={count:0}){if(n.count>Y6)return[[]];let r=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=H6(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)n.count++,i.push(h);else{o=!0,a=f.literal;break}}else{let f=await zk(t,u.word.parts,n);for(let h of f){n.count++;let d=[];for(let p of h)typeof p=="string"?d.push(p):d.push(await wr(t,p));i.push(d.join(""))}}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>t.limits.maxBraceExpansionResults||n.count>Y6)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>Y6)return c.length>0?c:r;c.push([...u,f])}r=c}else for(let i of r)n.count++,i.push(s);return r}async function Wk(t,e){let n=e.parts;if(!Th(n))return[await ge(t,e)];let r=await zk(t,n),s=[];for(let i of r){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await wr(t,a));s.push(GC(t,o.join("")))}return s}function LH(){return{expandWordAsync:ew,expandWordForGlobbing:Uk,expandWordWithBracesAsync:Wk,expandWordPartsAsync:es,expandPart:wr,expandParameterAsync:Nh,hasBraceExpansion:Th,evaluateArithmetic:fe,buildIfsCharClassPattern:mC,smartWordSplit:Fk}}async function $r(t,e){return Ik(t,e,LH())}function MH(t){for(let e of t){if(e.type==="ParameterExpansion")return e.parameter;if(e.type==="Literal")return e.value}return""}function rc(t,e){if(Number.parseInt(t.state.env.get("#")||"0",10)<2)return!1;function r(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return r(e.parts)}async function sc(t,e){if(rc(t,e))return{error:`bash: $@: ambiguous redirect
1403
+ `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return l}});case"K":case"k":return r?"":bi(n);case"u":return n.charAt(0).toUpperCase()+n.slice(1);case"U":return n.toUpperCase();case"L":return n.toLowerCase();default:return n}}async function LC(t,e,n,r,s,i,o=!1){if(t.coverage?.hit("bash:expansion:indirection"),pt(t,e))return so(t,e)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(e);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new Rn(`\${!${e}}`)}let l=n;if(a&&(l===""||l.includes(" ")))throw new Rn(`\${!${e}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new Rn(`\${!${e}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(t,u,o)}return await He(t,l)}function MC(t,e){t.coverage?.hit("bash:expansion:array_keys");let r=xe(t,e.array).map(([s])=>String(s));return e.star?r.join(Ie(t.state.env)):r.join(" ")}function BC(t,e){t.coverage?.hit("bash:expansion:var_name_prefix");let n=ba(t,e.prefix);return e.star?n.join(Ie(t.state.env)):n.join(" ")}function UC(t,e,n,r){let s=Number.parseInt(t.state.env.get("#")||"0",10),i=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(e==="*")return{isEmpty:s===0,effectiveValue:n};if(e==="@")return{isEmpty:s===0||s===1&&t.state.env.get("1")==="",effectiveValue:n};if(i){let[,o,a]=i,l=xe(t,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=Ie(t.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:r?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:n==="",effectiveValue:n}}var zC=I(()=>{"use strict";On();Bt();bt();zn();Me();yr();Xr();ya();wa();io();G6();K6();sr();Ah()});function WC(t){return te(t.stdout)}function jC(t){let e=0;for(;e<t.length;){let n=t[e];if(n==="\\"&&e+1<t.length){e+=2;continue}if(n==="'"){let r=t.indexOf("'",e+1);if(r!==-1){e=r+1;continue}}if(n==="$"&&e+1<t.length&&t[e+1]==="("||n==="`")return!0;e++}return!1}function qC(t,e){let n=1,r=e,s=!1,i=!1;for(;r<t.length&&n>0;){let o=t[r];if(o==="\\"&&!s&&r+1<t.length){r+=2;continue}if(o==="'"&&!i){s=!s,r++;continue}if(o==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(o==="(")n++;else if(o===")"&&(n--,n===0))return r}r++}return-1}async function vh(t,e){let n=new Ne,r;try{r=n.parse(e)}catch{return""}let s=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let i=new Map(t.state.env),o=t.state.cwd,a=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let l=await t.executeScript(r),c=l.exitCode;return t.state.env=i,t.state.cwd=o,t.state.suppressVerbose=a,t.state.lastExitCode=c,t.state.env.set("?",String(c)),l.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+l.stderr),t.state.bashPid=s,WC(l).replace(/\n+$/,"")}catch(l){if(t.state.env=i,t.state.cwd=o,t.state.bashPid=s,t.state.suppressVerbose=a,l instanceof ie)throw l;return l instanceof Re?(t.state.lastExitCode=l.exitCode,t.state.env.set("?",String(l.exitCode)),WC({stdout:l.stdout??"",stdoutKind:l.stdoutKind,stdoutEncoding:l.stdoutEncoding}).replace(/\n+$/,"")):""}}function Z6(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="'"){let i=e.indexOf("'",r+1);if(i!==-1){let o=e.slice(r+1,i);n+=ir(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(r+1,i),l=yH(t,a);n+=ir(l),r=i+1;continue}}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<e.length){n+=s+e[r+1],r+=2;continue}n+=s,r++}return n}function yH(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="\\"&&r+1<e.length){let i=e[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}async function HC(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="'"){let i=e.indexOf("'",r+1);if(i!==-1){let o=e.slice(r+1,i);n+=ir(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(r+1,i),l=await wH(t,a);n+=ir(l),r=i+1;continue}}if(s==="$"&&r+1<e.length&&e[r+1]==="("){let i=qC(e,r+2);if(i!==-1){let o=e.slice(r+2,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="`"){let i=e.indexOf("`",r+1);if(i!==-1){let o=e.slice(r+1,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<e.length){n+=s+e[r+1],r+=2;continue}n+=s,r++}return n}async function wH(t,e){let n="",r=0;for(;r<e.length;){let s=e[r];if(s==="\\"&&r+1<e.length){let i=e[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<e.length&&e[r+1]==="("){let i=qC(e,r+2);if(i!==-1){let o=e.slice(r+2,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="`"){let i=e.indexOf("`",r+1);if(i!==-1){let o=e.slice(r+1,i),a=await vh(t,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<e.length){let i=e[r+1];if(i==="{"){let o=e.indexOf("}",r+2);if(o!==-1){let a=e.slice(r+2,o);n+=t.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(r+1,o);n+=t.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}var VC=I(()=>{"use strict";pe();Bt();Me();ga()});function GC(t,e){if(!e.startsWith("~"))return e;t.coverage?.hit("bash:expansion:tilde");let n=t.state.env.get("HOME")!==void 0?t.state.env.get("HOME"):"/home/user";if(e==="~"||e.startsWith("~/"))return n+e.slice(1);let r=1;for(;r<e.length&&/[a-zA-Z0-9_-]/.test(e[r]);)r++;let s=e.slice(1,r),i=e.slice(r);return i!==""&&!i.startsWith("/")?e:s==="root"?`/root${i}`:e}var KC=I(()=>{"use strict"});async function bH(t,e,n,r){let s="";for(let i of e.parts)if(i.type==="Glob")s+=Ue(i.pattern,!0,t.state.shoptOptions.extglob);else if(i.type==="Literal")s+=Ue(i.value,!0,t.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=qe(i.value);else if(i.type==="DoubleQuoted"){let o=await n(t,i.parts);s+=qe(o)}else if(i.type==="ParameterExpansion"){let o=await r(t,i);s+=Ue(o,!0,t.state.shoptOptions.extglob)}else{let o=await r(t,i);s+=qe(o)}return s}async function ZC(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=xe(t,a),f=u.map(([,g])=>g);if(u.length===0){let g=t.state.env.get(a);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h="";c.pattern&&(h=await bH(t,c.pattern,n,r));let d=c.replacement?await n(t,c.replacement.parts):"",p=h;c.anchor==="start"?p=`^${h}`:c.anchor==="end"&&(p=`${h}$`);let m=[];try{let g=X(p,c.all?"g":"");for(let y of f)m.push(g.replace(y,d))}catch{m.push(...f)}if(l){let g=Ie(t.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}async function YC(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=xe(t,a),f=u.map(([,m])=>m);if(u.length===0){let m=t.state.env.get(a);m!==void 0&&f.push(m)}if(f.length===0)return{values:[],quoted:!0};let h="",d=t.state.shoptOptions.extglob;if(c.pattern)for(let m of c.pattern.parts)if(m.type==="Glob")h+=Ue(m.pattern,c.greedy,d);else if(m.type==="Literal")h+=Ue(m.value,c.greedy,d);else if(m.type==="SingleQuoted"||m.type==="Escaped")h+=qe(m.value);else if(m.type==="DoubleQuoted"){let g=await n(t,m.parts);h+=qe(g)}else if(m.type==="ParameterExpansion"){let g=await r(t,m);h+=Ue(g,c.greedy,d)}else{let g=await r(t,m);h+=qe(g)}let p=[];for(let m of f)p.push(zs(m,h,c.side,c.greedy));if(l){let m=Ie(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}var QC=I(()=>{"use strict";bt();yr();ya();wa();io();sr()});async function XC(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="DefaultValue"&&n.parts[0].operation?.type!=="UseAlternative"&&n.parts[0].operation?.type!=="AssignDefault")return null;let r=n.parts[0],s=r.operation,i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=xe(t,l),u=c.length>0||t.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,d])=>d===""),h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(h&&f):o=!u||h&&f,!o){if(c.length>0){let p=c.map(([,m])=>m);if(a){let m=Ie(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}let d=t.state.env.get(l);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await Jr(t,l),u=await He(t,l,!1),f=u==="",h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(h&&f):o=!c||h&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){c=h[1],u=h[2]==="*";break}}if(c){let f=xe(t,c);if(f.length>0){let d=f.map(([,p])=>p);if(u||a){let p=Ie(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}let h=t.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function JC(t,e,n,r,s){if(!n||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0],o=-1,a="",l=!1,c=null;for(let m=0;m<i.parts.length;m++){let g=i.parts[m];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let y=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(y){o=m,a=y[1],l=y[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let m=0;m<o;m++)u+=await r(t,i.parts[m]);let f="";for(let m=o+1;m<i.parts.length;m++)f+=await r(t,i.parts[m]);let h=xe(t,a),d=h.map(([,m])=>m);if(h.length===0){let m=t.state.env.get(a);if(m!==void 0)d=[m];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let m=c,g="",y=t.state.shoptOptions.extglob;if(m.pattern)for(let w of m.pattern.parts)if(w.type==="Glob")g+=Ue(w.pattern,m.greedy,y);else if(w.type==="Literal")g+=Ue(w.value,m.greedy,y);else if(w.type==="SingleQuoted"||w.type==="Escaped")g+=qe(w.value);else if(w.type==="DoubleQuoted"){let b=await s(t,w.parts);g+=qe(b)}else if(w.type==="ParameterExpansion"){let b=await r(t,w);g+=Ue(b,m.greedy,y)}else{let b=await r(t,w);g+=qe(b)}d=d.map(w=>zs(w,g,m.side,m.greedy))}else if(c?.type==="PatternReplacement"){let m=c,g="";if(m.pattern)for(let b of m.pattern.parts)if(b.type==="Glob")g+=Ue(b.pattern,!0,t.state.shoptOptions.extglob);else if(b.type==="Literal")g+=Ue(b.value,!0,t.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")g+=qe(b.value);else if(b.type==="DoubleQuoted"){let E=await s(t,b.parts);g+=qe(E)}else if(b.type==="ParameterExpansion"){let E=await r(t,b);g+=Ue(E,!0,t.state.shoptOptions.extglob)}else{let E=await r(t,b);g+=qe(E)}let y=m.replacement?await s(t,m.replacement.parts):"",w=g;m.anchor==="start"?w=`^${g}`:m.anchor==="end"&&(w=`${g}$`);try{let b=X(w,m.all?"g":"");d=d.map(E=>b.replace(E,y))}catch{}}if(l){let m=Ie(t.state.env);return{values:[u+d.join(m)+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 ek(t,e,n,r){if(!n||e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o="",a=!1;for(let d=0;d<s.parts.length;d++){let p=s.parts[d];if(p.type==="ParameterExpansion"&&!p.operation){let m=p.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(m){i=d,o=m[1],a=m[2]==="*";break}}}if(i===-1)return null;let l="";for(let d=0;d<i;d++)l+=await r(t,s.parts[d]);let c="";for(let d=i+1;d<s.parts.length;d++)c+=await r(t,s.parts[d]);let u=xe(t,o),f=u.map(([,d])=>d);if(u.length===0){let d=t.state.env.get(o);if(d!==void 0)return{values:[l+d+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}if(a){let d=Ie(t.state.env);return{values:[l+f.join(d)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var tk=I(()=>{"use strict";bt();yr();ya();wa();io();sr()});async function nk(t,e,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="Substring")return null;let s=r.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(t.state.associativeArrays?.has(o))throw new Re(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
1404
+ `);let c=l.offset?await n(t,l.offset.expression):0,u=l.length?await n(t,l.length.expression):void 0,f=xe(t,o),h=0;if(c<0){if(f.length>0){let p=f[f.length-1][0],g=(typeof p=="number"?p:0)+1+c;if(g<0)return{values:[],quoted:!0};h=f.findIndex(([y])=>typeof y=="number"&&y>=g),h<0&&(h=f.length)}}else h=f.findIndex(([p])=>typeof p=="number"&&p>=c),h<0&&(h=f.length);let d;if(u!==void 0){if(u<0)throw new lt(`${o}[@]: substring expression < 0`);d=f.slice(h,h+u).map(([,p])=>p)}else d=f.slice(h).map(([,p])=>p);if(d.length===0)return{values:[],quoted:!0};if(a){let p=Ie(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}function rk(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="Transform")return null;let r=n.parts[0],s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=r.operation,l=xe(t,i);if(l.length===0){let f=t.state.env.get(i);if(f!==void 0){let h;switch(a.operator){case"a":h="";break;case"P":h=nc(t,f);break;case"Q":h=bi(f);break;default:h=f}return{values:[h],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=xi(t,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>nc(t,f));break;case"Q":u=l.map(([,f])=>bi(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=Ie(t.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var sk=I(()=>{"use strict";Me();yr();G6();K6();sr();Ah()});function ik(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion")return null;let r=n.parts[0];if(r.operation)return null;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(pt(t,i)){let l=so(t,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=xe(t,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=t.state.env.get(i);return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function ok(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation)return null;let s=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!pt(t,s))return null;let i=so(t,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=xe(t,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=t.state.env.get(a);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var ak=I(()=>{"use strict";Xr();sr()});async function lk(t,e,n,r,s){if(!n||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await He(t,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let p=Number.parseInt(t.state.env.get("#")||"0",10),m=[];for(let g=1;g<=p;g++)m.push(t.state.env.get(String(g))||"");return l==="*"?{values:[m.join(Ie(t.state.env))],quoted:!0}:{values:m,quoted:!0}}return null}let u=c[1],f=c[2]==="*",h=xe(t,u);if(a.innerOp){if(a.innerOp.type==="Substring")return EH(t,h,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return xH(t,h,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let m=xi(t,u),g=h.map(()=>m);return f?{values:[g.join(Ie(t.state.env))],quoted:!0}:{values:g,quoted:!0}}let p=[];for(let[,m]of h){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},y=t.state.env.get("_indirect_elem_");t.state.env.set("_indirect_elem_",m);try{let w=await r(t,g,!0);p.push(w)}finally{y!==void 0?t.state.env.set("_indirect_elem_",y):t.state.env.delete("_indirect_elem_")}}return f?{values:[p.join(Ie(t.state.env))],quoted:!0}:{values:p,quoted:!0}}if(h.length>0){let p=h.map(([,m])=>m);return f?{values:[p.join(Ie(t.state.env))],quoted:!0}:{values:p,quoted:!0}}let d=t.state.env.get(u);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function EH(t,e,n,r,s){let i=s.offset?await fe(t,s.offset.expression):0,o=s.length?await fe(t,s.length.expression):void 0,a=0;if(i<0){if(e.length>0){let u=e[e.length-1][0],h=(typeof u=="number"?u:0)+1+i;if(h<0)return{values:[],quoted:!0};if(a=e.findIndex(([d])=>typeof d=="number"&&d>=h),a<0)return{values:[],quoted:!0}}}else if(a=e.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new lt(`${n}[@]: substring expression < 0`);l=e.slice(a,a+o)}else l=e.slice(a);let c=l.map(([,u])=>u);return r?{values:[c.join(Ie(t.state.env))],quoted:!0}:{values:c,quoted:!0}}async function xH(t,e,n,r,s,i){let o=s.checkEmpty??!1,a=e.map(([,u])=>u),l=e.length===0,c=e.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:r?{values:[a.join(Ie(t.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(t,s.word.parts,!0);return t.state.env.set(`${n}_0`,f),t.state.env.set(`${n}__length`,"1"),{values:[f],quoted:!0}}return r?{values:[a.join(Ie(t.state.env))],quoted:!0}:{values:a,quoted:!0}}return r?{values:[a.join(Ie(t.state.env))],quoted:!0}:{values:a,quoted:!0}}async function ck(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="UseAlternative"&&e[0].operation?.type!=="DefaultValue")return null;let n=e[0],r=n.operation,s=r?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await He(t,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await Jr(t,n.parameter),u=await He(t,n.parameter)==="",f=r.checkEmpty??!1,h;if(r.type==="UseAlternative"?h=c&&!(f&&u):h=!c||f&&u,h){let d=l[1],p=l[2]==="*",m=xe(t,d);if(m.length>0){let y=m.map(([,w])=>w);return p?{values:[y.join(Ie(t.state.env))],quoted:!0}:{values:y,quoted:!0}}let g=t.state.env.get(d);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function uk(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="Indirection")return null;let n=e[0],s=n.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await He(t,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await He(t,n.parameter),f=await Jr(t,n.parameter),h=u==="",d=s.checkEmpty??!1,p;if(s.type==="UseAlternative"?p=f&&!(d&&h):p=!f||d&&h,p){let m=c[1],g=c[2]==="*",y=xe(t,m);if(y.length>0){let b=y.map(([,E])=>E);return g?{values:[b.join(Ie(t.state.env))],quoted:!0}:{values:b,quoted:!0}}let w=t.state.env.get(m);return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var fk=I(()=>{"use strict";zn();Me();yr();sr();Ah()});function hk(t){let e=Number.parseInt(t.state.env.get("#")||"0",10),n=[];for(let r=1;r<=e;r++)n.push(t.state.env.get(String(r))||"");return n}async function dk(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let w=0;w<s.parts.length;w++){let b=s.parts[w];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=w,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await n(t,l.offset.expression):0,u=l.length?await n(t,l.length.expression):void 0,f=Number.parseInt(t.state.env.get("#")||"0",10),h=[];for(let w=1;w<=f;w++)h.push(t.state.env.get(String(w))||"");let d=t.state.env.get("0")||"bash",p;if(c<=0){let w=[d,...h],b=w.length+c;if(b<0)p=[];else{let E=c<0?b:0;if(u!==void 0){let A=u<0?w.length+u:E+u;p=w.slice(E,Math.max(E,A))}else p=w.slice(E)}}else{let w=c-1;if(w>=h.length)p=[];else if(u!==void 0){let b=u<0?h.length+u:w+u;p=h.slice(w,Math.max(w,b))}else p=h.slice(w)}let m="";for(let w=0;w<i;w++)m+=await r(t,s.parts[w]);let g="";for(let w=i+1;w<s.parts.length;w++)g+=await r(t,s.parts[w]);if(p.length===0){let w=m+g;return{values:w?[w]:[],quoted:!0}}if(o){let w=Ie(t.state.env);return{values:[m+p.join(w)+g],quoted:!0}}return p.length===1?{values:[m+p[0]+g],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+g],quoted:!0}}async function pk(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let w=s.parts[y];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternReplacement"){i=y,o=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=hk(t),u="";for(let y=0;y<i;y++)u+=await n(t,s.parts[y]);let f="";for(let y=i+1;y<s.parts.length;y++)f+=await n(t,s.parts[y]);if(c.length===0){let y=u+f;return{values:y?[y]:[],quoted:!0}}let h="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")h+=Ue(y.pattern,!0,t.state.shoptOptions.extglob);else if(y.type==="Literal")h+=Ue(y.value,!0,t.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")h+=qe(y.value);else if(y.type==="DoubleQuoted"){let w=await r(t,y.parts);h+=qe(w)}else if(y.type==="ParameterExpansion"){let w=await n(t,y);h+=Ue(w,!0,t.state.shoptOptions.extglob)}else{let w=await n(t,y);h+=qe(w)}let d=l.replacement?await r(t,l.replacement.parts):"",p=h;l.anchor==="start"?p=`^${h}`:l.anchor==="end"&&(p=`${h}$`);let m=[];try{let y=X(p,l.all?"g":"");for(let w of c)m.push(y.replace(w,d))}catch{m.push(...c)}if(o){let y=Ie(t.state.env);return{values:[u+m.join(y)+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 mk(t,e,n,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let y=s.parts[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){i=g,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=hk(t),u="";for(let g=0;g<i;g++)u+=await n(t,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await n(t,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let h="",d=t.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")h+=Ue(g.pattern,l.greedy,d);else if(g.type==="Literal")h+=Ue(g.value,l.greedy,d);else if(g.type==="SingleQuoted"||g.type==="Escaped")h+=qe(g.value);else if(g.type==="DoubleQuoted"){let y=await r(t,g.parts);h+=qe(y)}else if(g.type==="ParameterExpansion"){let y=await n(t,g);h+=Ue(y,l.greedy,d)}else{let y=await n(t,g);h+=qe(y)}let p=[];for(let g of c)p.push(zs(g,h,l.side,l.greedy));if(o){let g=Ie(t.state.env);return{values:[u+p.join(g)+f],quoted:!0}}return p.length===1?{values:[u+p[0]+f],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+f],quoted:!0}}async function gk(t,e,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0],s=-1,i=!1;for(let h=0;h<r.parts.length;h++){let d=r.parts[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")){s=h,i=d.parameter==="*";break}}if(s===-1)return null;let o=r.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(t.state.env.get("#")||"0",10),l="";for(let h=0;h<s;h++)l+=await n(t,r.parts[h]);let c="";for(let h=s+1;h<r.parts.length;h++)c+=await n(t,r.parts[h]);if(a===0){if(i)return{values:[l+c],quoted:!0};let h=l+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=a;h++)u.push(t.state.env.get(String(h))||"");if(i){let h=Ie(t.state.env);return{values:[l+u.join(h)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var yk=I(()=>{"use strict";bt();yr();ya();wa();io()});function SH(t){return new wi(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations})}async function Ch(t,e){if(t.state.options.noglob)return e;let n=SH(t),r=[];for(let s of e)if(As(s,t.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new ls(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function wk(t,e,n,r){let s=-1,i="",o=!1;for(let w=0;w<e.length;w++){let b=e[w];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let E=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(E){s=w,i=E[1],o=E[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=xe(t,i),u=c.map(([,w])=>w);if(c.length===0){let w=t.state.env.get(i);w!==void 0&&(u=[w])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")f+=Ue(w.pattern,!0,t.state.shoptOptions.extglob);else if(w.type==="Literal")f+=Ue(w.value,!0,t.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")f+=qe(w.value);else if(w.type==="DoubleQuoted"){let b=await n(t,w.parts);f+=qe(b)}else if(w.type==="ParameterExpansion"){let b=await r(t,w);f+=Ue(b,!0,t.state.shoptOptions.extglob)}else{let b=await r(t,w);f+=qe(b)}let h=l.replacement?await n(t,l.replacement.parts):"",d=f;l.anchor==="start"?d=`^${f}`:l.anchor==="end"&&(d=`${f}$`);let p=[];try{let w=X(d,l.all?"g":"");for(let b of u)p.push(w.replace(b,h))}catch{p.push(...u)}let m=Xt(t.state.env),g=Sn(t.state.env);if(o){let w=Ie(t.state.env),b=p.join(w);return g?{values:b?[b]:[],quoted:!1}:{values:St(b,m),quoted:!1}}if(g)return{values:p,quoted:!1};let y=[];for(let w of p)w===""?y.push(""):y.push(...St(w,m));return{values:y,quoted:!1}}async function bk(t,e,n,r){let s=-1,i="",o=!1;for(let y=0;y<e.length;y++){let w=e[y];if(w.type==="ParameterExpansion"&&w.operation?.type==="PatternRemoval"){let b=w.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=y,i=b[1],o=b[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=xe(t,i),u=c.map(([,y])=>y);if(c.length===0){let y=t.state.env.get(i);y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="",h=t.state.shoptOptions.extglob;if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=Ue(y.pattern,l.greedy,h);else if(y.type==="Literal")f+=Ue(y.value,l.greedy,h);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=qe(y.value);else if(y.type==="DoubleQuoted"){let w=await n(t,y.parts);f+=qe(w)}else if(y.type==="ParameterExpansion"){let w=await r(t,y);f+=Ue(w,l.greedy,h)}else{let w=await r(t,y);f+=qe(w)}let d=[];for(let y of u)d.push(zs(y,f,l.side,l.greedy));let p=Xt(t.state.env),m=Sn(t.state.env);if(o){let y=Ie(t.state.env),w=d.join(y);return m?{values:w?[w]:[],quoted:!1}:{values:St(w,p),quoted:!1}}if(m)return{values:d,quoted:!1};let g=[];for(let y of d)y===""?g.push(""):g.push(...St(y,p));return{values:g,quoted:!1}}async function Ek(t,e,n,r){let s=-1,i=!1;for(let g=0;g<e.length;g++){let y=e[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){s=g,i=y.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=Number.parseInt(t.state.env.get("#")||"0",10),c=[];for(let g=1;g<=l;g++)c.push(t.state.env.get(String(g))||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=t.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=Ue(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=Ue(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=qe(g.value);else if(g.type==="DoubleQuoted"){let y=await n(t,g.parts);u+=qe(y)}else if(g.type==="ParameterExpansion"){let y=await r(t,g);u+=Ue(y,a.greedy,f)}else{let y=await r(t,g);u+=qe(y)}let h=[];for(let g of c)h.push(zs(g,u,a.side,a.greedy));let d=Xt(t.state.env),p=Sn(t.state.env);if(i){let g=Ie(t.state.env),y=h.join(g);return p?{values:y?[y]:[],quoted:!1}:{values:St(y,d),quoted:!1}}if(p)return{values:h,quoted:!1};let m=[];for(let g of h)g===""?m.push(""):m.push(...St(g,d));return{values:m,quoted:!1}}async function xk(t,e,n,r){let s=-1,i=!1;for(let b=0;b<e.length;b++){let E=e[b];if(E.type==="ParameterExpansion"&&(E.parameter==="@"||E.parameter==="*")&&E.operation?.type==="Substring"){s=b,i=E.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=a.offset?await n(t,a.offset.expression):0,c=a.length?await n(t,a.length.expression):void 0,u=Number.parseInt(t.state.env.get("#")||"0",10),f=[];for(let b=1;b<=u;b++)f.push(t.state.env.get(String(b))||"");let h=t.state.env.get("0")||"bash",d;if(l<=0){let b=[h,...f],E=b.length+l;if(E<0)d=[];else{let A=l<0?E:0;if(c!==void 0){let C=c<0?b.length+c:A+c;d=b.slice(A,Math.max(A,C))}else d=b.slice(A)}}else{let b=l-1;if(b>=f.length)d=[];else if(c!==void 0){let E=c<0?f.length+c:b+c;d=f.slice(b,Math.max(b,E))}else d=f.slice(b)}let p="";for(let b=0;b<s;b++)p+=await r(t,e[b]);let m="";for(let b=s+1;b<e.length;b++)m+=await r(t,e[b]);let g=Xt(t.state.env),y=Sn(t.state.env);if(d.length===0){let b=p+m;return b?y?{values:[b],quoted:!1}:{values:St(b,g),quoted:!1}:{values:[],quoted:!1}}let w;if(i){let b=Ie(t.state.env),E=p+d.join(b)+m;y?w=E?[E]:[]:w=St(E,g)}else if(y)d.length===1?w=[p+d[0]+m]:w=[p+d[0],...d.slice(1,-1),d[d.length-1]+m];else{w=[];for(let b=0;b<d.length;b++){let E=d[b];if(b===0&&(E=p+E),b===d.length-1&&(E=E+m),E==="")w.push("");else{let A=St(E,g);w.push(...A)}}}return{values:await Ch(t,w),quoted:!1}}async function Sk(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].parameter!=="@"&&e[0].parameter!=="*"||e[0].operation)return null;let n=e[0].parameter==="*",r=Number.parseInt(t.state.env.get("#")||"0",10);if(r===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=r;c++)s.push(t.state.env.get(String(c))||"");let i=Xt(t.state.env),o=Sn(t.state.env),a=wh(t.state.env),l;if(n)if(o)l=s.filter(c=>c!=="");else{let c=Ie(t.state.env),u=s.join(c);l=St(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=St(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=St(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await Ch(t,l),quoted:!1}}async function Ak(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation)return null;let n=e[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],s=n[2]==="*",i=xe(t,r),o;if(i.length===0){let f=t.state.env.get(r);if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=Xt(t.state.env),l=Sn(t.state.env),c=wh(t.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=Ie(t.state.env),h=o.join(f);u=St(h,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let h=St(f,a);u.push(...h)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let h=St(f,a);u.push(...h)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await Ch(t,u),quoted:!1}}function vk(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="VarNamePrefix")return null;let n=e[0].operation,r=ba(t,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=Xt(t.state.env),i=Sn(t.state.env),o;if(n.star)if(i)o=r;else{let a=Ie(t.state.env),l=r.join(a);o=St(l,s)}else if(i)o=r;else{o=[];for(let a of r){let l=St(a,s);o.push(...l)}}return{values:o,quoted:!1}}function Ck(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="ArrayKeys")return null;let n=e[0].operation,s=xe(t,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=Xt(t.state.env),o=Sn(t.state.env),a;if(n.star)if(o)a=s;else{let l=Ie(t.state.env),c=s.join(l);a=St(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=St(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function kk(t,e,n){let r=-1;for(let h=0;h<e.length;h++){let d=e[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")&&!d.operation){r=h;break}}if(r===-1||e.length<=1)return null;let s=Number.parseInt(t.state.env.get("#")||"0",10),i=[];for(let h=1;h<=s;h++)i.push(t.state.env.get(String(h))||"");let o="";for(let h=0;h<r;h++)o+=await n(t,e[h]);let a="";for(let h=r+1;h<e.length;h++)a+=await n(t,e[h]);let l=Xt(t.state.env),c=Sn(t.state.env),u=wh(t.state.env);if(s===0){let h=o+a;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let d=0;d<i.length;d++){let p=i[d];d===0&&(p=o+p),d===i.length-1&&(p=p+a),h.push(p)}if(c)f=h.filter(d=>d!=="");else if(u){f=[];for(let d of h){if(d==="")continue;let p=St(d,l);f.push(...p)}}else{f=[];for(let d of h)if(d==="")f.push("");else{let p=St(d,l);f.push(...p)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await Ch(t,f),quoted:!1}}var Nk=I(()=>{"use strict";bt();mh();Me();yr();ya();ga();wa();io();sr()});async function Ik(t,e,n){t.coverage?.hit("bash:expansion:word_glob");let r=e.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=tc(r),h=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(t,e):null;if(h&&h.length>1)return AH(t,h,s);let d=await vH(t,r,a,c,u,n);if(d!==null)return d;let p=await kH(t,r,n);if(p!==null)return p;let m=await NH(t,r,n);if(m!==null)return m;let g=await OH(t,r,n.expandPart);if(g!==null)return Ok(t,g);if((i||o||l)&&!Sn(t.state.env)){let w=Xt(t.state.env),b=n.buildIfsCharClassPattern(w),E=await n.smartWordSplit(t,r,w,b,n.expandPart);return Ok(t,E)}let y=await n.expandWordAsync(t,e);return IH(t,e,r,y,s,n.expandWordForGlobbing)}async function AH(t,e,n){let r=[];for(let s of e)if(!(!n&&s===""))if(!n&&!t.state.options.noglob&&As(s,t.state.shoptOptions.extglob)){let i=await kh(t,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function vH(t,e,n,r,s,i){if(n){let o=ik(t,e);if(o!==null)return o}{let o=ok(t,e);if(o!==null)return o}{let o=await XC(t,e);if(o!==null)return o}{let o=await JC(t,e,n,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await ek(t,e,n,i.expandPart);if(o!==null)return o}{let o=await nk(t,e,i.evaluateArithmetic);if(o!==null)return o}{let o=rk(t,e);if(o!==null)return o}{let o=await ZC(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await YC(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(r&&e.length===1&&e[0].type==="DoubleQuoted"){let o=CH(t,e);if(o!==null)return o}{let o=await lk(t,e,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await ck(t,e);if(o!==null)return o}{let o=await uk(t,e);if(o!==null)return o}return null}function CH(t,e){let n=e[0];if(n.type!=="DoubleQuoted")return null;if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="VarNamePrefix"){let r=n.parts[0].operation,s=ba(t,r.prefix);return r.star?{values:[s.join(Ie(t.state.env))],quoted:!0}:{values:s,quoted:!0}}if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="ArrayKeys"){let r=n.parts[0].operation,i=xe(t,r.array).map(([o])=>String(o));return r.star?{values:[i.join(Ie(t.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function kH(t,e,n){{let r=await dk(t,e,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await pk(t,e,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await mk(t,e,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await gk(t,e,n.expandPart);if(r!==null)return r}return null}async function NH(t,e,n){{let r=await wk(t,e,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await bk(t,e,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Ek(t,e,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await xk(t,e,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await Sk(t,e);if(r!==null)return r}{let r=await Ak(t,e);if(r!==null)return r}{let r=vk(t,e);if(r!==null)return r}{let r=Ck(t,e);if(r!==null)return r}{let r=await kk(t,e,n.expandPart);if(r!==null)return r}return null}function Tk(t){if(t.type!=="DoubleQuoted")return null;for(let e=0;e<t.parts.length;e++){let n=t.parts[e];if(n.type!=="ParameterExpansion"||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:"array",name:r[1],atIndex:e,isStar:r[2]==="*"};if(n.parameter==="@"||n.parameter==="*")return{type:"positional",atIndex:e,isStar:n.parameter==="*"}}return null}async function TH(t,e,n,r){let s="";for(let a=0;a<n.atIndex;a++)s+=await r(t,e.parts[a]);let i="";for(let a=n.atIndex+1;a<e.parts.length;a++)i+=await r(t,e.parts[a]);let o;if(n.type==="array"){if(o=xe(t,n.name).map(([,l])=>l),o.length===0){let l=t.state.env.get(n.name);l!==void 0&&(o=[l])}}else{let a=Number.parseInt(t.state.env.get("#")||"0",10);o=[];for(let l=1;l<=a;l++)o.push(t.state.env.get(String(l))||"")}if(n.isStar){let a=Ie(t.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function OH(t,e,n){if(e.length<2)return null;let r=!1;for(let l of e)if(Tk(l)){r=!0;break}if(!r)return null;let s=Xt(t.state.env),i=Sn(t.state.env),o=[];for(let l of e){let c=Tk(l);if(c&&l.type==="DoubleQuoted"){let u=await TH(t,l,c,n);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(t,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(t,l);if(i)o.push(u?[u]:[]);else{let f=St(u,s);o.push(f)}}else{let u=await n(t,l);if(i)o.push(u?[u]:[]);else{let f=St(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function Ok(t,e){if(t.state.options.noglob)return{values:e,quoted:!1};let n=[];for(let r of e)if(As(r,t.state.shoptOptions.extglob)){let s=await kh(t,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function kh(t,e){let n=new wi(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations}),r=await n.expand(e);if(r.length>0)return r;if(n.hasFailglob())throw new ls(e);return n.hasNullglob()?[]:[e]}async function IH(t,e,n,r,s,i){let o=n.some(a=>a.type==="Glob");if(!t.state.options.noglob&&o){let a=await i(t,e);if(As(a,t.state.shoptOptions.extglob)){let c=await kh(t,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=V6(r);if(!Sn(t.state.env)){let c=Xt(t.state.env);return{values:St(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!t.state.options.noglob&&As(r,t.state.shoptOptions.extglob)){let a=await i(t,e);if(As(a,t.state.shoptOptions.extglob)){let l=await kh(t,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=V6(r);if(!Sn(t.state.env)){let l=Xt(t.state.env);return{values:St(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[r],quoted:s}}var Pk=I(()=>{"use strict";mh();Me();yr();gh();QC();tk();sk();ak();ga();fk();io();yk();Nk();sr()});async function $k(t,e){let n=e.operation;if(!n||n.type!=="DefaultValue"&&n.type!=="AssignDefault"&&n.type!=="UseAlternative")return null;let r=n.word;if(!r||r.parts.length===0)return null;let s=await Jr(t,e.parameter),o=await He(t,e.parameter,!1)==="",a=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?r.parts:null}function PH(t){return t.type==="SingleQuoted"?!0:t.type==="DoubleQuoted"?t.parts.every(n=>n.type==="Literal"):!1}async function RH(t,e){if(e.type!=="ParameterExpansion")return null;let n=await $k(t,e);if(!n||n.length<=1)return null;let r=n.some(i=>PH(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function $H(t){return t.type==="DoubleQuoted"||t.type==="SingleQuoted"||t.type==="Literal"?!1:t.type==="Glob"?B6(t.pattern):!(!(t.type==="ParameterExpansion"||t.type==="CommandSubstitution"||t.type==="ArithmeticExpansion")||t.type==="ParameterExpansion"&&pC(t))}async function Fk(t,e,n,r,s){if(t.coverage?.hit("bash:expansion:word_split"),e.length===1&&e[0].type==="ParameterExpansion"){let h=e[0],d=await $k(t,h);if(d&&d.length>0&&d.length>1&&d.some(m=>m.type==="DoubleQuoted"||m.type==="SingleQuoted")&&d.some(m=>m.type==="Literal"||m.type==="ParameterExpansion"||m.type==="CommandSubstitution"||m.type==="ArithmeticExpansion"))return Rk(t,d,n,r,s)}let i=[],o=!1;for(let h of e){let d=$H(h),p=h.type==="DoubleQuoted"||h.type==="SingleQuoted",m=d?await RH(t,h):null,g=await s(t,h);i.push({value:g,isSplittable:d,isQuoted:p,mixedDefaultParts:m??void 0}),d&&(o=!0)}if(!o){let h=i.map(d=>d.value).join("");return h?[h]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let h of i)if(!h.isSplittable)u?h.isQuoted&&h.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):h.value!==""?(l!==""&&a.push(l),l=h.value,u=!1,f=!1):(l+=h.value,f=!1):(l+=h.value,f=h.isQuoted&&h.value==="");else if(h.mixedDefaultParts){let d=await Rk(t,h.mixedDefaultParts,n,r,s);if(d.length!==0)if(d.length===1)l+=d[0],c=!0;else{l+=d[0],a.push(l),c=!0;for(let p=1;p<d.length-1;p++)a.push(d[p]);l=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:p,hadTrailingDelimiter:m}=bh(h.value,n);if(f&&p&&l===""&&(a.push(""),c=!0),d.length===0)m&&(u=!0);else if(d.length===1)l+=d[0],c=!0,u=m;else{l+=d[0],a.push(l),c=!0;for(let g=1;g<d.length-1;g++)a.push(d[g]);l=d[d.length-1],u=m}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function FH(t,e){return t.length>0&&e.includes(t[0])}async function Rk(t,e,n,r,s){let i=[];for(let u of e){let h=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),d=await s(t,u);i.push({value:d,isSplittable:h})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{FH(u.value,n)&&a!==""&&(o.push(a),a="",l=!0);let{words:h,hadTrailingDelimiter:d}=bh(u.value,n);if(h.length===0)d&&(c=!0);else if(h.length===1)a+=h[0],l=!0,c=d;else{a+=h[0],o.push(a),l=!0;for(let p=1;p<h.length-1;p++)o.push(h[p]);a=h[h.length-1],c=d}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var _k=I(()=>{"use strict";sr();yr();gh()});function Dk(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function Lk(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}var Mk=I(()=>{"use strict"});var tw={};ee(tw,{escapeGlobChars:()=>ir,escapeRegexChars:()=>ma,expandRedirectTarget:()=>sc,expandWord:()=>ge,expandWordForPattern:()=>J6,expandWordForRegex:()=>X6,expandWordWithGlob:()=>$r,getArrayElements:()=>xe,getVariable:()=>He,hasQuotedMultiValueAt:()=>rc,isArray:()=>Us,isWordFullyQuoted:()=>Q6});function Si(t,e,n){if(t.length>e)throw new ie(`${n}: string length limit exceeded (${e} bytes)`,"string_length")}function Bk(t){return te(t.stdout)}async function ts(t,e,n=!1){let r=[];for(let s of e)r.push(await wr(t,s,n));return r.join("")}function _H(t){return Lk(t)}function Q6(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!_H(e))return!1;return!0}function DH(t,e,n=!1){let r=Dk(e);if(r!==null)return r;switch(e.type){case"TildeExpansion":return n?e.user===null?"~":`~${e.user}`:(t.coverage?.hit("bash:expansion:tilde"),e.user===null?t.state.env.get("HOME")??"/home/user":e.user==="root"?"/root":`~${e.user}`);case"Glob":return Z6(t,e.pattern);default:return null}}async function ge(t,e){return ew(t,e)}async function X6(t,e){let n=[];for(let r of e.parts)if(r.type==="Escaped")n.push(`\\${r.value}`);else if(r.type==="SingleQuoted")n.push(r.value);else if(r.type==="DoubleQuoted"){let s=await ts(t,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await wr(t,r);n.push(ma(s))}else n.push(await wr(t,r));return n.join("")}async function J6(t,e){let n=[];for(let r of e.parts)if(r.type==="Escaped"){let s=r.value;"()|*?[]".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="SingleQuoted")n.push(ir(r.value));else if(r.type==="DoubleQuoted"){let s=await ts(t,r.parts);n.push(ir(s))}else n.push(await wr(t,r));return n.join("")}async function Uk(t,e){let n=[];for(let r of e.parts)if(r.type==="SingleQuoted")n.push(ir(r.value));else if(r.type==="Escaped"){let s=r.value;"*?[]\\()|".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="DoubleQuoted"){let s=await ts(t,r.parts);n.push(ir(s))}else r.type==="Glob"?jC(r.pattern)?n.push(await HC(t,r.pattern)):n.push(Z6(t,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await wr(t,r));return n.join("")}function Th(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&Th(e.parts))return!0;return!1}async function zk(t,e,n={count:0}){if(n.count>Y6)return[[]];let r=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=H6(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)n.count++,i.push(h);else{o=!0,a=f.literal;break}}else{let f=await zk(t,u.word.parts,n);for(let h of f){n.count++;let d=[];for(let p of h)typeof p=="string"?d.push(p):d.push(await wr(t,p));i.push(d.join(""))}}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>t.limits.maxBraceExpansionResults||n.count>Y6)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>Y6)return c.length>0?c:r;c.push([...u,f])}r=c}else for(let i of r)n.count++,i.push(s);return r}async function Wk(t,e){let n=e.parts;if(!Th(n))return[await ge(t,e)];let r=await zk(t,n),s=[];for(let i of r){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await wr(t,a));s.push(GC(t,o.join("")))}return s}function LH(){return{expandWordAsync:ew,expandWordForGlobbing:Uk,expandWordWithBracesAsync:Wk,expandWordPartsAsync:ts,expandPart:wr,expandParameterAsync:Nh,hasBraceExpansion:Th,evaluateArithmetic:fe,buildIfsCharClassPattern:mC,smartWordSplit:Fk}}async function $r(t,e){return Ik(t,e,LH())}function MH(t){for(let e of t){if(e.type==="ParameterExpansion")return e.parameter;if(e.type==="Literal")return e.value}return""}function rc(t,e){if(Number.parseInt(t.state.env.get("#")||"0",10)<2)return!1;function r(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return r(e.parts)}async function sc(t,e){if(rc(t,e))return{error:`bash: $@: ambiguous redirect
1405
1405
  `};let n=e.parts,{hasQuoted:r}=tc(n);if(Th(n)&&(await Wk(t,e)).length>1)return{error:`bash: ${n.map(d=>d.type==="Literal"?d.value:d.type==="BraceExpansion"?`{${d.items.map(m=>{if(m.type==="Range"){let g=m.step?`..${m.step}`:"";return`${m.startStr??m.start}..${m.endStr??m.end}${g}`}return m.word.parts.map(g=>g.type==="Literal"?g.value:"").join("")}).join(",")}}`:"").join("")}: ambiguous redirect
1406
1406
  `};let s=await ew(t,e),{hasParamExpansion:i,hasCommandSub:o}=tc(n);if((i||o)&&!r&&!Sn(t.state.env)){let f=Xt(t.state.env);if(St(s,f).length>1)return{error:`bash: $${MH(n)}: ambiguous redirect
1407
1407
  `}}if(r||t.state.options.noglob)return{target:s};let l=await Uk(t,e);if(!As(l,t.state.shoptOptions.extglob))return{target:s};let c=new wi(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations}),u=await c.expand(l);return u.length===0?c.hasFailglob()?{error:`bash: no match: ${s}
1408
1408
  `}:{target:s}:u.length===1?{target:u[0]}:{error:`bash: ${s}: ambiguous redirect
1409
- `}}async function ew(t,e){let n=e.parts,r=n.length;if(r===1){let o=await wr(t,n[0]);return Si(o,t.limits.maxStringLength,"word expansion"),o}let s=[];for(let o=0;o<r;o++)s.push(await wr(t,n[o]));let i=s.join("");return Si(i,t.limits.maxStringLength,"word expansion"),i}async function wr(t,e,n=!1){if(e.type==="ParameterExpansion")return Nh(t,e,n);let r=DH(t,e,n);if(r!==null)return r;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(await wr(t,i,!0));return s.join("")}case"CommandSubstitution":{let s=CC(e.body);if(s)try{let h=await ge(t,s.target),d=h.startsWith("/")?h:`${t.state.cwd}/${h}`,p=await t.fs.readFile(d);t.state.lastExitCode=0,t.state.env.set("?","0");let m=p.replace(/\n+$/,"");return Si(m,t.limits.maxStringLength,"command substitution"),m}catch(h){if(h instanceof ie)throw h;return t.state.lastExitCode=1,t.state.env.set("?","1"),""}let i=t.substitutionDepth??0,o=t.limits.maxSubstitutionDepth;if(i>=o)throw new ie(`Command substitution nesting limit exceeded (${o})`,"substitution_depth");let a=t.substitutionDepth;t.substitutionDepth=i+1;let l=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let c=new Map(t.state.env),u=t.state.cwd,f=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let h=await t.executeScript(e.body),d=h.exitCode;t.state.env=c,t.state.cwd=u,t.state.suppressVerbose=f,t.state.lastExitCode=d,t.state.env.set("?",String(d)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr),t.state.bashPid=l,t.substitutionDepth=a;let p=Bk(h).replace(/\n+$/,"");return Si(p,t.limits.maxStringLength,"command substitution"),p}catch(h){if(t.state.env=c,t.state.cwd=u,t.state.bashPid=l,t.substitutionDepth=a,t.state.suppressVerbose=f,h instanceof ie)throw h;if(h instanceof Re){t.state.lastExitCode=h.exitCode,t.state.env.set("?",String(h.exitCode)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr);let d=Bk({stdout:h.stdout,stdoutKind:h.stdoutKind,stdoutEncoding:h.stdoutEncoding}).replace(/\n+$/,"");return Si(d,t.limits.maxStringLength,"command substitution"),d}throw h}}case"ArithmeticExpansion":{let s=e.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let o=await SC(t,s),a=new Ne,l=Ve(a,o);return String(await fe(t,l.expression,!0))}return String(await fe(t,e.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=H6(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(await ge(t,i.word));return s.join(" ")}default:return""}}async function Nh(t,e,n=!1){let{parameter:r}=e,{operation:s}=e,i=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,h,d]=i;if(t.state.associativeArrays?.has(h)||d.includes("$(")||d.includes("`")||d.includes("${")){let m=await q6(t,d);r=`${h}[${m}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&pt(t,r)){let h=Un(t,r);if(h&&h!==r){let d=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let[,p,m]=d;if(t.state.associativeArrays?.has(p)||m.includes("$(")||m.includes("`")||m.includes("${")){let y=await q6(t,m);r=`${p}[${y}]`}}}}let o=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),a=await Ge(t,r,!o);if(!s)return a;let l=!await Ss(t,r),{isEmpty:c,effectiveValue:u}=UC(t,r,a,n),f={value:a,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:n};switch(s.type){case"DefaultValue":return NC(t,s,f,es);case"AssignDefault":return TC(t,r,s,f,es);case"ErrorIfUnset":return OC(t,r,s,f,es);case"UseAlternative":return IC(t,s,f,es);case"PatternRemoval":{let h=await PC(t,a,s,es,wr);return Si(h,t.limits.maxStringLength,"pattern removal"),h}case"PatternReplacement":{let h=await RC(t,a,s,es,wr);return Si(h,t.limits.maxStringLength,"pattern replacement"),h}case"Length":return $C(t,r,a);case"LengthSliceError":throw new Rn(r);case"BadSubstitution":throw new Rn(s.text);case"Substring":return FC(t,r,a,s);case"CaseModification":{let h=await _C(t,a,s,es,Nh);return Si(h,t.limits.maxStringLength,"case modification"),h}case"Transform":return DC(t,r,a,l,s);case"Indirection":return LC(t,r,a,l,s,Nh,n);case"ArrayKeys":return MC(t,s);case"VarNamePrefix":return BC(t,s);default:return a}}var Y6,Wn=I(()=>{"use strict";On();Bt();mh();pe();zn();Me();gh();AC();vC();kC();ga();zC();VC();KC();sr();Pk();_k();yr();Xr();Mk();ga();sr();Y6=1e5});function BH(t,e,n){switch(n){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":if(e===0)throw new lt("division by 0");return Math.trunc(t/e);case"%":if(e===0)throw new lt("division by 0");return t%e;case"**":if(e<0)throw new lt("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function jk(t,e,n){switch(n){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function UH(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}async function zH(t,e){let n=t.state.env.get(e);if(n!==void 0)return n;let r=t.state.env.get(`${e}_0`);return r!==void 0?r:await Ge(t,e)}function WH(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let n=t.trim();if(!n)return 0;try{let r=new Ne,{expr:s,pos:i}=gr(r,n,0);if(i<n.length){let o=n.slice(i).trim().split(/\s+/)[0];throw new lt(`${n}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(r){if(r instanceof lt)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new lt(`${n}: syntax error in expression (error token is "${s}")`)}}async function nw(t,e){if(!e)return 0;let n=Number.parseInt(e,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(e.trim()))return n;let r=e.trim();if(!r)return 0;let s=new Ne,{expr:i,pos:o}=gr(s,r,0);if(o<r.length){let a=r.slice(o).trim(),l=a.split(/\s+/)[0]||a;throw new lt(`syntax error in expression (error token is "${l}")`,"","")}return await fe(t,i)}async function rw(t,e,n=new Set,r=0){if(r>100)throw new lt("maximum variable indirection depth exceeded");if(n.has(e))return 0;n.add(e);let s=await zH(t,e);if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s.trim()))return i;let o=s.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o))return await rw(t,o,n,r+1);let a=new Ne,{expr:l,pos:c}=gr(a,o,0);if(c<o.length){let u=o.slice(c).trim(),f=u.split(/\s+/)[0]||u;throw new lt(`${o}: syntax error in expression (error token is "${f}")`)}return await fe(t,l)}async function Oh(t,e){if(e.startsWith("#")){let f=e.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let p=h[1],m=xe(t,p);return String(m.length)}let d=t.state.env.get(f)||"";return String(d.length)}if(e.startsWith("!")){let f=e.slice(1),h=t.state.env.get(f)||"";return t.state.env.get(h)||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let h=e.indexOf(f);h>0&&(r===-1||h<r)&&(r=h,s=f)}if(r===-1)return await Ge(t,e);let i=e.slice(0,r),o=e.slice(r+s.length),a=t.state.env.get(i),l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env.set(i,o),o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}async function fe(t,e,n=!1){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new lt("value too great for base");return e.value;case"ArithVariable":return await rw(t,e.name);case"ArithSpecialVar":{let s=(await Ge(t,e.name)).trim();if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s))return i;let o=new Ne,{expr:a}=gr(o,s,0);return await fe(t,a)}case"ArithNested":return await fe(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let r=await t.execFn(e.command,{signal:t.state.signal});r.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+r.stderr);let s=r.stdout.trim();return Number.parseInt(s,10)||0}return 0}case"ArithBracedExpansion":{let r=await Oh(t,e.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=await Oh(t,e.baseExpr),s=Number.parseInt(r,10);if(s<2||s>64)return 0;let i=`${s}#${e.value}`;return Xl(i)}case"ArithDynamicNumber":{let s=await Oh(t,e.prefix)+e.suffix;return Xl(s)}case"ArithArrayElement":{let r=t.state.associativeArrays?.has(e.array),s=async i=>{let o=t.state.env.get(i);return o!==void 0?await nw(t,o):0};if(e.stringKey!==void 0)return await s(`${e.array}_${e.stringKey}`);if(r&&e.index?.type==="ArithVariable"&&!e.index.hasDollarPrefix)return await s(`${e.array}_${e.index.name}`);if(r&&e.index?.type==="ArithVariable"&&e.index.hasDollarPrefix){let i=await Ge(t,e.index.name);return await s(`${e.array}_${i}`)}if(e.index){let i=await fe(t,e.index,n);if(i<0){let l=xe(t,e.array),c=t.state.currentLine;if(l.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${c}: ${e.array}: bad array subscript
1409
+ `}}async function ew(t,e){let n=e.parts,r=n.length;if(r===1){let o=await wr(t,n[0]);return Si(o,t.limits.maxStringLength,"word expansion"),o}let s=[];for(let o=0;o<r;o++)s.push(await wr(t,n[o]));let i=s.join("");return Si(i,t.limits.maxStringLength,"word expansion"),i}async function wr(t,e,n=!1){if(e.type==="ParameterExpansion")return Nh(t,e,n);let r=DH(t,e,n);if(r!==null)return r;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(await wr(t,i,!0));return s.join("")}case"CommandSubstitution":{let s=CC(e.body);if(s)try{let h=await ge(t,s.target),d=h.startsWith("/")?h:`${t.state.cwd}/${h}`,p=await t.fs.readFile(d);t.state.lastExitCode=0,t.state.env.set("?","0");let m=p.replace(/\n+$/,"");return Si(m,t.limits.maxStringLength,"command substitution"),m}catch(h){if(h instanceof ie)throw h;return t.state.lastExitCode=1,t.state.env.set("?","1"),""}let i=t.substitutionDepth??0,o=t.limits.maxSubstitutionDepth;if(i>=o)throw new ie(`Command substitution nesting limit exceeded (${o})`,"substitution_depth");let a=t.substitutionDepth;t.substitutionDepth=i+1;let l=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let c=new Map(t.state.env),u=t.state.cwd,f=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let h=await t.executeScript(e.body),d=h.exitCode;t.state.env=c,t.state.cwd=u,t.state.suppressVerbose=f,t.state.lastExitCode=d,t.state.env.set("?",String(d)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr),t.state.bashPid=l,t.substitutionDepth=a;let p=Bk(h).replace(/\n+$/,"");return Si(p,t.limits.maxStringLength,"command substitution"),p}catch(h){if(t.state.env=c,t.state.cwd=u,t.state.bashPid=l,t.substitutionDepth=a,t.state.suppressVerbose=f,h instanceof ie)throw h;if(h instanceof Re){t.state.lastExitCode=h.exitCode,t.state.env.set("?",String(h.exitCode)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr);let d=Bk({stdout:h.stdout,stdoutKind:h.stdoutKind,stdoutEncoding:h.stdoutEncoding}).replace(/\n+$/,"");return Si(d,t.limits.maxStringLength,"command substitution"),d}throw h}}case"ArithmeticExpansion":{let s=e.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let o=await SC(t,s),a=new Ne,l=Ge(a,o);return String(await fe(t,l.expression,!0))}return String(await fe(t,e.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=H6(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(await ge(t,i.word));return s.join(" ")}default:return""}}async function Nh(t,e,n=!1){let{parameter:r}=e,{operation:s}=e,i=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,h,d]=i;if(t.state.associativeArrays?.has(h)||d.includes("$(")||d.includes("`")||d.includes("${")){let m=await q6(t,d);r=`${h}[${m}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&pt(t,r)){let h=Un(t,r);if(h&&h!==r){let d=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let[,p,m]=d;if(t.state.associativeArrays?.has(p)||m.includes("$(")||m.includes("`")||m.includes("${")){let y=await q6(t,m);r=`${p}[${y}]`}}}}let o=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),a=!1;o&&(a=!await Jr(t,r));let l=o?a?"":await He(t,r,!1):await He(t,r,!0);if(!s)return l;o||(a=!await Jr(t,r));let{isEmpty:c,effectiveValue:u}=UC(t,r,l,n),f={value:l,isUnset:a,isEmpty:c,effectiveValue:u,inDoubleQuotes:n};switch(s.type){case"DefaultValue":return NC(t,s,f,ts);case"AssignDefault":return TC(t,r,s,f,ts);case"ErrorIfUnset":return OC(t,r,s,f,ts);case"UseAlternative":return IC(t,s,f,ts);case"PatternRemoval":{let h=await PC(t,l,s,ts,wr);return Si(h,t.limits.maxStringLength,"pattern removal"),h}case"PatternReplacement":{let h=await RC(t,l,s,ts,wr);return Si(h,t.limits.maxStringLength,"pattern replacement"),h}case"Length":return $C(t,r,l);case"LengthSliceError":throw new Rn(r);case"BadSubstitution":throw new Rn(s.text);case"Substring":return FC(t,r,l,s);case"CaseModification":{let h=await _C(t,l,s,ts,Nh);return Si(h,t.limits.maxStringLength,"case modification"),h}case"Transform":return DC(t,r,l,a,s);case"Indirection":return LC(t,r,l,a,s,Nh,n);case"ArrayKeys":return MC(t,s);case"VarNamePrefix":return BC(t,s);default:return l}}var Y6,Wn=I(()=>{"use strict";pe();On();Bt();mh();zn();Me();gh();AC();vC();kC();ga();zC();VC();KC();sr();Pk();_k();yr();Xr();Mk();ga();sr();Y6=1e5});function BH(t,e,n){switch(n){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":if(e===0)throw new lt("division by 0");return Math.trunc(t/e);case"%":if(e===0)throw new lt("division by 0");return t%e;case"**":if(e<0)throw new lt("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function jk(t,e,n){switch(n){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function UH(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}async function zH(t,e){let n=t.state.env.get(e);if(n!==void 0)return n;let r=t.state.env.get(`${e}_0`);return r!==void 0?r:await He(t,e)}function WH(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let n=t.trim();if(!n)return 0;try{let r=new Ne,{expr:s,pos:i}=gr(r,n,0);if(i<n.length){let o=n.slice(i).trim().split(/\s+/)[0];throw new lt(`${n}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(r){if(r instanceof lt)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new lt(`${n}: syntax error in expression (error token is "${s}")`)}}async function nw(t,e){if(!e)return 0;let n=Number.parseInt(e,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(e.trim()))return n;let r=e.trim();if(!r)return 0;let s=new Ne,{expr:i,pos:o}=gr(s,r,0);if(o<r.length){let a=r.slice(o).trim(),l=a.split(/\s+/)[0]||a;throw new lt(`syntax error in expression (error token is "${l}")`,"","")}return await fe(t,i)}async function rw(t,e,n=new Set,r=0){if(r>100)throw new lt("maximum variable indirection depth exceeded");if(n.has(e))return 0;n.add(e);let s=await zH(t,e);if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s.trim()))return i;let o=s.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o))return await rw(t,o,n,r+1);let a=new Ne,{expr:l,pos:c}=gr(a,o,0);if(c<o.length){let u=o.slice(c).trim(),f=u.split(/\s+/)[0]||u;throw new lt(`${o}: syntax error in expression (error token is "${f}")`)}return await fe(t,l)}async function Oh(t,e){if(e.startsWith("#")){let f=e.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let p=h[1],m=xe(t,p);return String(m.length)}let d=t.state.env.get(f)||"";return String(d.length)}if(e.startsWith("!")){let f=e.slice(1),h=t.state.env.get(f)||"";return t.state.env.get(h)||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let h=e.indexOf(f);h>0&&(r===-1||h<r)&&(r=h,s=f)}if(r===-1)return await He(t,e);let i=e.slice(0,r),o=e.slice(r+s.length),a=t.state.env.get(i),l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env.set(i,o),o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}async function fe(t,e,n=!1){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new lt("value too great for base");return e.value;case"ArithVariable":return await rw(t,e.name);case"ArithSpecialVar":{let s=(await He(t,e.name)).trim();if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s))return i;let o=new Ne,{expr:a}=gr(o,s,0);return await fe(t,a)}case"ArithNested":return await fe(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let r=await t.execFn(e.command,{signal:t.state.signal});r.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+r.stderr);let s=r.stdout.trim();return Number.parseInt(s,10)||0}return 0}case"ArithBracedExpansion":{let r=await Oh(t,e.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=await Oh(t,e.baseExpr),s=Number.parseInt(r,10);if(s<2||s>64)return 0;let i=`${s}#${e.value}`;return Xl(i)}case"ArithDynamicNumber":{let s=await Oh(t,e.prefix)+e.suffix;return Xl(s)}case"ArithArrayElement":{let r=t.state.associativeArrays?.has(e.array),s=async i=>{let o=t.state.env.get(i);return o!==void 0?await nw(t,o):0};if(e.stringKey!==void 0)return await s(`${e.array}_${e.stringKey}`);if(r&&e.index?.type==="ArithVariable"&&!e.index.hasDollarPrefix)return await s(`${e.array}_${e.index.name}`);if(r&&e.index?.type==="ArithVariable"&&e.index.hasDollarPrefix){let i=await He(t,e.index.name);return await s(`${e.array}_${i}`)}if(e.index){let i=await fe(t,e.index,n);if(i<0){let l=xe(t,e.array),c=t.state.currentLine;if(l.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${c}: ${e.array}: bad array subscript
1410
1410
  `,0;let f=Math.max(...l.map(([h])=>typeof h=="number"?h:0))+1+i;if(f<0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${c}: ${e.array}: bad array subscript
1411
- `,0;i=f}let o=`${e.array}_${i}`,a=t.state.env.get(o);if(a!==void 0)return nw(t,a);if(i===0){let l=t.state.env.get(e.array);if(l!==void 0)return nw(t,l)}if(t.state.options.nounset&&!Array.from(t.state.env.keys()).some(c=>c===e.array||c.startsWith(`${e.array}_`)))throw new Pn(`${e.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new lt("double subscript","","");case"ArithNumberSubscript":throw new lt(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithSyntaxError":throw new lt(e.message,"","",!0);case"ArithSingleQuote":{if(n)throw new lt(`syntax error: operand expected (error token is "'${e.content}'")`);return e.value}case"ArithBinary":{if(e.operator==="||")return await fe(t,e.left,n)||await fe(t,e.right,n)?1:0;if(e.operator==="&&")return await fe(t,e.left,n)&&await fe(t,e.right,n)?1:0;let r=await fe(t,e.left,n),s=await fe(t,e.right,n);return BH(r,s,e.operator)}case"ArithUnary":{let r=await fe(t,e.operand,n);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let s=e.operand.name,i=Number.parseInt(await Ge(t,s),10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}if(e.operand.type==="ArithArrayElement"){let s=e.operand.array,i=t.state.associativeArrays?.has(s),o;if(e.operand.stringKey!==void 0)o=`${s}_${e.operand.stringKey}`;else if(i&&e.operand.index?.type==="ArithVariable"&&!e.operand.index.hasDollarPrefix)o=`${s}_${e.operand.index.name}`;else if(i&&e.operand.index?.type==="ArithVariable"&&e.operand.index.hasDollarPrefix){let c=await Ge(t,e.operand.index.name);o=`${s}_${c}`}else if(e.operand.index){let c=await fe(t,e.operand.index,n);o=`${s}_${c}`}else return r;let a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}if(e.operand.type==="ArithConcat"){let s="";for(let i of e.operand.parts)s+=await Ea(t,i,n);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}}if(e.operand.type==="ArithDynamicElement"){let s="";if(e.operand.nameExpr.type==="ArithConcat")for(let i of e.operand.nameExpr.parts)s+=await Ea(t,i,n);else e.operand.nameExpr.type==="ArithVariable"&&(s=e.operand.nameExpr.hasDollarPrefix?await Ge(t,e.operand.nameExpr.name):e.operand.nameExpr.name);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=await fe(t,e.operand.subscript,n),o=`${s}_${i}`,a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}}return r}return UH(r,e.operator)}case"ArithTernary":return await fe(t,e.condition,n)?await fe(t,e.consequent,n):await fe(t,e.alternate,n);case"ArithAssignment":{let r=e.variable,s=r;if(e.stringKey!==void 0)s=`${r}_${e.stringKey}`;else if(e.subscript){let l=t.state.associativeArrays?.has(r);if(l&&e.subscript.type==="ArithVariable"&&!e.subscript.hasDollarPrefix)s=`${r}_${e.subscript.name}`;else if(l&&e.subscript.type==="ArithVariable"&&e.subscript.hasDollarPrefix){let c=await Ge(t,e.subscript.name);s=`${r}_${c||"\\"}`}else if(l){let c=await fe(t,e.subscript,n);s=`${r}_${c}`}else{let c=await fe(t,e.subscript,n);if(c<0){let u=xe(t,r);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}s=`${r}_${c}`}}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await fe(t,e.value,n),a=jk(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithGroup":return await fe(t,e.expression,n);case"ArithConcat":{let r="";for(let s of e.parts)r+=await Ea(t,s,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await rw(t,r):Number.parseInt(r,10)||0}case"ArithDynamicAssignment":{let r="";if(e.target.type==="ArithConcat")for(let l of e.target.parts)r+=await Ea(t,l,n);else e.target.type==="ArithVariable"&&(r=e.target.hasDollarPrefix?await Ge(t,e.target.name):e.target.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=r;if(e.subscript){let l=await fe(t,e.subscript,n);s=`${r}_${l}`}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await fe(t,e.value,n),a=jk(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithDynamicElement":{let r="";if(e.nameExpr.type==="ArithConcat")for(let a of e.nameExpr.parts)r+=await Ea(t,a,n);else e.nameExpr.type==="ArithVariable"&&(r=e.nameExpr.hasDollarPrefix?await Ge(t,e.nameExpr.name):e.nameExpr.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=await fe(t,e.subscript,n),i=`${r}_${s}`,o=t.state.env.get(i);return o!==void 0?WH(o):0}default:return 0}}async function Ea(t,e,n=!1){switch(e.type){case"ArithNumber":return String(e.value);case"ArithSingleQuote":return String(await fe(t,e,n));case"ArithVariable":return e.hasDollarPrefix?await Ge(t,e.name):e.name;case"ArithSpecialVar":return await Ge(t,e.name);case"ArithBracedExpansion":return await Oh(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command,{signal:t.state.signal})).stdout.trim():"0";case"ArithConcat":{let r="";for(let s of e.parts)r+=await Ea(t,s,n);return r}default:return String(await fe(t,e,n))}}var zn=I(()=>{"use strict";On();Bt();Me();Wn()});var VG={};ee(VG,{Bash:()=>Oa,BashTransformPipeline:()=>od,CommandCollectorPlugin:()=>ad,DefenseInDepthBox:()=>tt,EMPTY_BYTES:()=>yc,InMemoryFs:()=>Es,MountableFs:()=>hc,NetworkAccessDeniedError:()=>Fr,OverlayFs:()=>po,ReadWriteFs:()=>dc,RedirectNotAllowedError:()=>co,Sandbox:()=>pc,SandboxCommand:()=>mo,SecurityViolationError:()=>Se,SecurityViolationLogger:()=>mc,TeePlugin:()=>ld,TooManyRedirectsError:()=>lo,bytesOutput:()=>ab,createConsoleViolationCallback:()=>Jw,decodeBytesToUtf8:()=>te,defineCommand:()=>fv,encodeUtf8ToBytes:()=>Er,getCommandNames:()=>nv,getJavaScriptCommandNames:()=>lv,getNetworkCommandNames:()=>rv,getPythonCommandNames:()=>ov,latin1FromBytes:()=>Rt,parse:()=>Bn,serialize:()=>Ta,stdoutAsBytes:()=>Ra,stdoutKind:()=>gd,textOutput:()=>ob,unsafeBytesFromLatin1:()=>Lr});module.exports=rb(VG);is();en();var Ji=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(md(),ib))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(wd(),lb))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(xd(),gb))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(vd(),wb))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(kd(),Eb))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(Td(),Ab))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Id(),vb))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(Rd(),Cb))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Fd(),kb))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(Dd(),Nb))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Md(),Tb))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(zd(),Ib))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(jd(),Pb))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(Hd(),Rb))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(Kd(),_b))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(Yd(),Db))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(Jd(),Mb))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(tp(),Bb))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(La(),$c))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(La(),$c))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(La(),$c))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(Op(),P7))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(Bp(),W7))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(Xp(),E3))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(t1(),O3))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(r1(),I3))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(i1(),P3))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(a1(),R3))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(c1(),F3))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(f1(),D3))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(d1(),L3))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(m1(),B3))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(y1(),z3))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(b1(),j3))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(x1(),V3))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(A1(),Z3))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(C1(),X3))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(N1(),e4))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(I1(),t4))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(R1(),n4))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(_1(),u4))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(L1(),f4))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(B1(),h4))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(z1(),p4))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(j1(),g4))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Qc(),V1))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Qc(),V1))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Xc(),Z1))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Xc(),Z1))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(Q1(),w4))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(J1(),b4))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Jc(),nm))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Jc(),nm))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(sm(),E4))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(eu(),am))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(eu(),am))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Cm(),H4))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Nm(),G4))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Om(),Z4))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Pm(),Y4))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(Fm(),X4))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(Dm(),J4))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(Mm(),t8))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Um(),n8))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(Wm(),r8))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(qm(),i8))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(Vm(),o8))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(Km(),a8))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(m0(),wE))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(y0(),EE))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(b0(),xE))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(x0(),SE))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(A0(),AE))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(C0(),vE))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(N0(),CE))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(O0(),kE))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(rl(),Pu))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(rl(),Pu))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(rl(),Pu))).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ji.push({name:"tar",load:async()=>(await Promise.resolve().then(()=>(Z0(),yx))).tarCommand}),Ji.push({name:"yq",load:async()=>(await Promise.resolve().then(()=>(e2(),ZA))).yqCommand}),Ji.push({name:"xan",load:async()=>(await Promise.resolve().then(()=>(K2(),g5))).xanCommand}),Ji.push({name:"sqlite3",load:async()=>(await Promise.resolve().then(()=>(Y2(),O5))).sqlite3Command}));var oh=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(oh.push({name:"python3",load:async()=>(await Promise.resolve().then(()=>(e6(),J2))).python3Command}),oh.push({name:"python",load:async()=>(await Promise.resolve().then(()=>(e6(),J2))).pythonCommand}));var ah=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ah.push({name:"js-exec",load:async()=>(await Promise.resolve().then(()=>(n6(),t6))).jsExecCommand}),ah.push({name:"node",load:async()=>(await Promise.resolve().then(()=>(n6(),t6))).nodeStubCommand}));var tv=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(K5(),G5))).curlCommand}],ev=new Map;function lh(t){return{name:t.name,async execute(e,n){let r=ev.get(t.name);if(r||(r=await tt.runTrustedAsync(()=>t.load()),ev.set(t.name,r)),n.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await Promise.resolve().then(()=>(J5(),X5));s(n.coverage,t.name,e)}return r.execute(e,n)}}}function nv(){return Ji.map(t=>t.name)}function rv(){return tv.map(t=>t.name)}function sv(t){return(t?Ji.filter(n=>t.includes(n.name)):Ji).map(lh)}function iv(){return tv.map(lh)}function ov(){return oh.map(t=>t.name)}function av(){return oh.map(lh)}function lv(){return ah.map(t=>t.name)}function cv(){return ah.map(lh)}function uv(t){return"load"in t&&typeof t.load=="function"}function fv(t,e){return{name:t,trusted:!0,execute:e}}function hv(t){let e=null;return{name:t.name,trusted:!0,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}pe();pe();la();function he(t){if(!t||t==="/")return"/";let e=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;e.startsWith("/")||(e=`/${e}`);let n=e.split("/").filter(s=>s&&s!=="."),r=[];for(let s of n)s===".."?r.pop():r.push(s);return`/${r.join("/")}`||"/"}function de(t,e){if(t.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${e} '${t}'`)}function eo(t){let e=he(t);if(e==="/")return"/";let n=e.lastIndexOf("/");return n===0?"/":e.slice(0,n)}function di(t,e){if(e.startsWith("/"))return he(e);let n=t==="/"?`/${e}`:`${t}/${e}`;return he(n)}function pi(t,e){return t==="/"?`/${e}`:`${t}/${e}`}function ua(t,e){if(e.startsWith("/"))return he(e);let n=eo(t);return he(pi(n,e))}var fa=new TextEncoder;function yq(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var Es=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))typeof r=="function"?this.writeFileLazy(n,r):yq(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}ensureParentDirs(e){let n=eo(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){de(e,"write");let i=he(e);this.ensureParentDirs(i);let o=Pr(r),a=Ms(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}writeFileLazy(e,n,r){de(e,"write");let s=he(e);this.ensureParentDirs(s),this.data.set(s,{type:"file",lazy:n,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(e,n){let r=await n.lazy(),i={type:"file",content:typeof r=="string"?fa.encode(r):r,mode:n.mode,mtime:n.mtime};return this.data.set(e,i),i}async readFile(e,n){let r=await this.readFileBuffer(e),s=Pr(n);return dr(r,s)}async readFileBytes(e){let n=await this.readFileBuffer(e);return dr(n,"binary")}async readFileBuffer(e){de(e,"open");let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if("lazy"in r){let s=await this.materializeLazy(n,r);return s.content instanceof Uint8Array?s.content:fa.encode(s.content)}return r.content instanceof Uint8Array?r.content:fa.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){de(e,"append");let s=he(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=Pr(r),a=Ms(n,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(s,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:fa.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(s,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){if(e.includes("\0"))return!1;try{let n=this.resolvePathWithSymlinks(e);return this.data.has(n)}catch{return!1}}async stat(e){de(e,"stat");let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=fa.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){de(e,"lstat");let n=this.resolveIntermediateSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=fa.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveIntermediateSymlinks(e){let n=he(e);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=ua(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(e){let n=he(e);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=ua(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){de(e,"mkdir");let r=he(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=eo(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){de(e,"scandir");let n=he(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),n=ua(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(e,n){de(e,"rm");let r=he(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=pi(r,o);await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){de(e,"cp"),de(n,"cp");let s=he(e),i=he(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);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 '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=pi(s,l),u=pi(i,l);await this.cp(c,u,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){return di(e,n)}async chmod(e,n){de(e,"chmod");let r=he(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){de(n,"symlink");let r=he(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){de(e,"link"),de(n,"link");let r=he(e),s=he(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){de(e,"readlink");let n=he(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}async realpath(e){de(e,"realpath");let n=this.resolvePathWithSymlinks(e);if(!this.data.has(n))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return n}async utimes(e,n,r){de(e,"utimes");let s=he(e),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);o.mtime=r}};u6();function wq(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function bq(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function Eq(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function xq(t,e){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${pv}
1411
+ `,0;i=f}let o=`${e.array}_${i}`,a=t.state.env.get(o);if(a!==void 0)return nw(t,a);if(i===0){let l=t.state.env.get(e.array);if(l!==void 0)return nw(t,l)}if(t.state.options.nounset&&!Array.from(t.state.env.keys()).some(c=>c===e.array||c.startsWith(`${e.array}_`)))throw new Pn(`${e.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new lt("double subscript","","");case"ArithNumberSubscript":throw new lt(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithSyntaxError":throw new lt(e.message,"","",!0);case"ArithSingleQuote":{if(n)throw new lt(`syntax error: operand expected (error token is "'${e.content}'")`);return e.value}case"ArithBinary":{if(e.operator==="||")return await fe(t,e.left,n)||await fe(t,e.right,n)?1:0;if(e.operator==="&&")return await fe(t,e.left,n)&&await fe(t,e.right,n)?1:0;let r=await fe(t,e.left,n),s=await fe(t,e.right,n);return BH(r,s,e.operator)}case"ArithUnary":{let r=await fe(t,e.operand,n);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let s=e.operand.name,i=Number.parseInt(await He(t,s),10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}if(e.operand.type==="ArithArrayElement"){let s=e.operand.array,i=t.state.associativeArrays?.has(s),o;if(e.operand.stringKey!==void 0)o=`${s}_${e.operand.stringKey}`;else if(i&&e.operand.index?.type==="ArithVariable"&&!e.operand.index.hasDollarPrefix)o=`${s}_${e.operand.index.name}`;else if(i&&e.operand.index?.type==="ArithVariable"&&e.operand.index.hasDollarPrefix){let c=await He(t,e.operand.index.name);o=`${s}_${c}`}else if(e.operand.index){let c=await fe(t,e.operand.index,n);o=`${s}_${c}`}else return r;let a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}if(e.operand.type==="ArithConcat"){let s="";for(let i of e.operand.parts)s+=await Ea(t,i,n);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}}if(e.operand.type==="ArithDynamicElement"){let s="";if(e.operand.nameExpr.type==="ArithConcat")for(let i of e.operand.nameExpr.parts)s+=await Ea(t,i,n);else e.operand.nameExpr.type==="ArithVariable"&&(s=e.operand.nameExpr.hasDollarPrefix?await He(t,e.operand.nameExpr.name):e.operand.nameExpr.name);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=await fe(t,e.operand.subscript,n),o=`${s}_${i}`,a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}}return r}return UH(r,e.operator)}case"ArithTernary":return await fe(t,e.condition,n)?await fe(t,e.consequent,n):await fe(t,e.alternate,n);case"ArithAssignment":{let r=e.variable,s=r;if(e.stringKey!==void 0)s=`${r}_${e.stringKey}`;else if(e.subscript){let l=t.state.associativeArrays?.has(r);if(l&&e.subscript.type==="ArithVariable"&&!e.subscript.hasDollarPrefix)s=`${r}_${e.subscript.name}`;else if(l&&e.subscript.type==="ArithVariable"&&e.subscript.hasDollarPrefix){let c=await He(t,e.subscript.name);s=`${r}_${c||"\\"}`}else if(l){let c=await fe(t,e.subscript,n);s=`${r}_${c}`}else{let c=await fe(t,e.subscript,n);if(c<0){let u=xe(t,r);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}s=`${r}_${c}`}}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await fe(t,e.value,n),a=jk(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithGroup":return await fe(t,e.expression,n);case"ArithConcat":{let r="";for(let s of e.parts)r+=await Ea(t,s,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await rw(t,r):Number.parseInt(r,10)||0}case"ArithDynamicAssignment":{let r="";if(e.target.type==="ArithConcat")for(let l of e.target.parts)r+=await Ea(t,l,n);else e.target.type==="ArithVariable"&&(r=e.target.hasDollarPrefix?await He(t,e.target.name):e.target.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=r;if(e.subscript){let l=await fe(t,e.subscript,n);s=`${r}_${l}`}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await fe(t,e.value,n),a=jk(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithDynamicElement":{let r="";if(e.nameExpr.type==="ArithConcat")for(let a of e.nameExpr.parts)r+=await Ea(t,a,n);else e.nameExpr.type==="ArithVariable"&&(r=e.nameExpr.hasDollarPrefix?await He(t,e.nameExpr.name):e.nameExpr.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=await fe(t,e.subscript,n),i=`${r}_${s}`,o=t.state.env.get(i);return o!==void 0?WH(o):0}default:return 0}}async function Ea(t,e,n=!1){switch(e.type){case"ArithNumber":return String(e.value);case"ArithSingleQuote":return String(await fe(t,e,n));case"ArithVariable":return e.hasDollarPrefix?await He(t,e.name):e.name;case"ArithSpecialVar":return await He(t,e.name);case"ArithBracedExpansion":return await Oh(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command,{signal:t.state.signal})).stdout.trim():"0";case"ArithConcat":{let r="";for(let s of e.parts)r+=await Ea(t,s,n);return r}default:return String(await fe(t,e,n))}}var zn=I(()=>{"use strict";On();Bt();Me();Wn()});var VG={};ee(VG,{Bash:()=>Oa,BashTransformPipeline:()=>od,CommandCollectorPlugin:()=>ad,DefenseInDepthBox:()=>tt,EMPTY_BYTES:()=>yc,InMemoryFs:()=>xs,MountableFs:()=>hc,NetworkAccessDeniedError:()=>Fr,OverlayFs:()=>po,ReadWriteFs:()=>dc,RedirectNotAllowedError:()=>co,Sandbox:()=>pc,SandboxCommand:()=>mo,SecurityViolationError:()=>Se,SecurityViolationLogger:()=>mc,TeePlugin:()=>ld,TooManyRedirectsError:()=>lo,bytesOutput:()=>ab,createConsoleViolationCallback:()=>Jw,decodeBytesToUtf8:()=>te,defineCommand:()=>fv,encodeUtf8ToBytes:()=>Er,getCommandNames:()=>nv,getJavaScriptCommandNames:()=>lv,getNetworkCommandNames:()=>rv,getPythonCommandNames:()=>ov,latin1FromBytes:()=>Rt,parse:()=>Bn,serialize:()=>Ta,stdoutAsBytes:()=>Ra,stdoutKind:()=>gd,textOutput:()=>ob,unsafeBytesFromLatin1:()=>Lr});module.exports=rb(VG);os();en();var Ji=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(md(),ib))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(wd(),lb))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(xd(),gb))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(vd(),wb))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(kd(),Eb))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(Td(),Ab))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Id(),vb))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(Rd(),Cb))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Fd(),kb))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(Dd(),Nb))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Md(),Tb))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(zd(),Ib))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(jd(),Pb))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(Hd(),Rb))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(Kd(),_b))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(Yd(),Db))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(Jd(),Mb))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(tp(),Bb))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(La(),$c))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(La(),$c))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(La(),$c))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(Op(),P7))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(Bp(),W7))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(Xp(),E3))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(t1(),O3))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(r1(),I3))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(i1(),P3))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(a1(),R3))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(c1(),F3))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(f1(),D3))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(d1(),L3))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(m1(),B3))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(y1(),z3))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(b1(),j3))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(x1(),V3))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(A1(),Z3))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(C1(),X3))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(N1(),e4))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(I1(),t4))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(R1(),n4))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(_1(),u4))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(L1(),f4))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(B1(),h4))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(z1(),p4))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(j1(),g4))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Qc(),V1))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Qc(),V1))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Xc(),Z1))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Xc(),Z1))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(Q1(),w4))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(J1(),b4))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Jc(),nm))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Jc(),nm))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(sm(),E4))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(eu(),am))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(eu(),am))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Cm(),H4))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Nm(),G4))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Om(),Z4))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Pm(),Y4))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(Fm(),X4))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(Dm(),J4))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(Mm(),t8))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Um(),n8))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(Wm(),r8))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(qm(),i8))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(Vm(),o8))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(Km(),a8))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(m0(),wE))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(y0(),EE))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(b0(),xE))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(x0(),SE))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(A0(),AE))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(C0(),vE))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(N0(),CE))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(O0(),kE))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(rl(),Pu))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(rl(),Pu))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(rl(),Pu))).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ji.push({name:"tar",load:async()=>(await Promise.resolve().then(()=>(Z0(),yx))).tarCommand}),Ji.push({name:"yq",load:async()=>(await Promise.resolve().then(()=>(e2(),ZA))).yqCommand}),Ji.push({name:"xan",load:async()=>(await Promise.resolve().then(()=>(K2(),g5))).xanCommand}),Ji.push({name:"sqlite3",load:async()=>(await Promise.resolve().then(()=>(Y2(),O5))).sqlite3Command}));var oh=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(oh.push({name:"python3",load:async()=>(await Promise.resolve().then(()=>(e6(),J2))).python3Command}),oh.push({name:"python",load:async()=>(await Promise.resolve().then(()=>(e6(),J2))).pythonCommand}));var ah=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ah.push({name:"js-exec",load:async()=>(await Promise.resolve().then(()=>(n6(),t6))).jsExecCommand}),ah.push({name:"node",load:async()=>(await Promise.resolve().then(()=>(n6(),t6))).nodeStubCommand}));var tv=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(K5(),G5))).curlCommand}],ev=new Map;function lh(t){return{name:t.name,async execute(e,n){let r=ev.get(t.name);if(r||(r=await tt.runTrustedAsync(()=>t.load()),ev.set(t.name,r)),n.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await Promise.resolve().then(()=>(J5(),X5));s(n.coverage,t.name,e)}return r.execute(e,n)}}}function nv(){return Ji.map(t=>t.name)}function rv(){return tv.map(t=>t.name)}function sv(t){return(t?Ji.filter(n=>t.includes(n.name)):Ji).map(lh)}function iv(){return tv.map(lh)}function ov(){return oh.map(t=>t.name)}function av(){return oh.map(lh)}function lv(){return ah.map(t=>t.name)}function cv(){return ah.map(lh)}function uv(t){return"load"in t&&typeof t.load=="function"}function fv(t,e){return{name:t,trusted:!0,execute:e}}function hv(t){let e=null;return{name:t.name,trusted:!0,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}pe();pe();la();function he(t){if(!t||t==="/")return"/";let e=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;e.startsWith("/")||(e=`/${e}`);let n=e.split("/").filter(s=>s&&s!=="."),r=[];for(let s of n)s===".."?r.pop():r.push(s);return`/${r.join("/")}`||"/"}function de(t,e){if(t.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${e} '${t}'`)}function eo(t){let e=he(t);if(e==="/")return"/";let n=e.lastIndexOf("/");return n===0?"/":e.slice(0,n)}function di(t,e){if(e.startsWith("/"))return he(e);let n=t==="/"?`/${e}`:`${t}/${e}`;return he(n)}function pi(t,e){return t==="/"?`/${e}`:`${t}/${e}`}function ua(t,e){if(e.startsWith("/"))return he(e);let n=eo(t);return he(pi(n,e))}var fa=new TextEncoder;function yq(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var xs=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))typeof r=="function"?this.writeFileLazy(n,r):yq(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}ensureParentDirs(e){let n=eo(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){de(e,"write");let i=he(e);this.ensureParentDirs(i);let o=Pr(r),a=Ms(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}writeFileLazy(e,n,r){de(e,"write");let s=he(e);this.ensureParentDirs(s),this.data.set(s,{type:"file",lazy:n,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(e,n){let r=await n.lazy(),i={type:"file",content:typeof r=="string"?fa.encode(r):r,mode:n.mode,mtime:n.mtime};return this.data.set(e,i),i}async readFile(e,n){let r=await this.readFileBuffer(e),s=Pr(n);return dr(r,s)}async readFileBytes(e){let n=await this.readFileBuffer(e);return dr(n,"binary")}async readFileBuffer(e){de(e,"open");let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if("lazy"in r){let s=await this.materializeLazy(n,r);return s.content instanceof Uint8Array?s.content:fa.encode(s.content)}return r.content instanceof Uint8Array?r.content:fa.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){de(e,"append");let s=he(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=Pr(r),a=Ms(n,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(s,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:fa.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(s,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){if(e.includes("\0"))return!1;try{let n=this.resolvePathWithSymlinks(e);return this.data.has(n)}catch{return!1}}async stat(e){de(e,"stat");let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=fa.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){de(e,"lstat");let n=this.resolveIntermediateSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=fa.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveIntermediateSymlinks(e){let n=he(e);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=ua(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(e){let n=he(e);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=ua(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){de(e,"mkdir");let r=he(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=eo(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){de(e,"scandir");let n=he(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),n=ua(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(e,n){de(e,"rm");let r=he(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=pi(r,o);await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){de(e,"cp"),de(n,"cp");let s=he(e),i=he(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);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 '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=pi(s,l),u=pi(i,l);await this.cp(c,u,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){return di(e,n)}async chmod(e,n){de(e,"chmod");let r=he(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){de(n,"symlink");let r=he(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){de(e,"link"),de(n,"link");let r=he(e),s=he(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(r,o)),this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){de(e,"readlink");let n=he(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}async realpath(e){de(e,"realpath");let n=this.resolvePathWithSymlinks(e);if(!this.data.has(n))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return n}async utimes(e,n,r){de(e,"utimes");let s=he(e),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);o.mtime=r}};u6();function wq(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function bq(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function Eq(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function xq(t,e){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${pv}
1412
1412
  `),t.writeFileSync("/proc/self/exe","/bin/bash"),t.writeFileSync("/proc/self/cmdline","bash\0"),t.writeFileSync("/proc/self/comm",`bash
1413
- `),t.writeFileLazy?t.writeFileLazy("/proc/self/status",()=>c6(e)):t.writeFileSync("/proc/self/status",c6(e)),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function mv(t,e,n={pid:1,ppid:0,uid:1e3,gid:1e3}){wq(t)&&(bq(t,e),Eq(t),xq(t,n))}mn();Ar();Me();var Sq=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Aq=["braceexpand","hashall","interactive-comments"];function f6(t){let e=[],n=[...Aq.map(r=>({name:r,enabled:!0})),...Sq.map(r=>({name:r,enabled:t[r]}))].sort((r,s)=>r.name.localeCompare(s.name));for(let r of n)r.enabled&&e.push(r.name);return e.join(":")}function da(t){t.state.env.set("SHELLOPTS",f6(t.state.options))}var vq=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function h6(t){let e=[];for(let n of vq)t[n]&&e.push(n);return e.join(":")}function d6(t){t.state.env.set("BASHOPTS",h6(t.state.shoptOptions))}pe();Ar();to();en();Bt();to();var eH="BASH_ALIAS_";function iC(t){return t.parts.length!==1?!1:t.parts[0].type==="Literal"}function oC(t){if(t.parts.length!==1)return null;let e=t.parts[0];return e.type==="Literal"?e.value:null}function aC(t,e){return t.env.get(`${eH}${e}`)}function _6(t,e,n){if(!e.name||!iC(e.name))return e;let r=oC(e.name);if(!r)return e;let s=aC(t,r);if(!s||n.has(r))return e;try{n.add(r);let i=new Ne,o=s,a=s.endsWith(" ");if(!a)for(let f of e.args){let h=cC(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof un)throw f;return e}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return lC(e,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return lC(e,s);let u={...c,assignments:[...e.assignments,...c.assignments],redirections:[...c.redirections,...e.redirections],line:e.line};if(a&&e.args.length>0&&(u={...u,args:[...u.args,...e.args]},u.args.length>0)){let f=u.args[0];if(iC(f)){let h=oC(f);if(h&&aC(t,h)){let d={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},p=_6(t,d,n);p!==d&&(u={...u,name:p.name,args:[...p.args]})}}}return u}catch(i){throw n.delete(r),i}}function lC(t,e){let n=e;for(let o of t.args){let a=cC(o);n+=` ${a}`}let r=new Ne,s=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${n.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:t.assignments,redirections:t.redirections,line:t.line}}function cC(t){let e="";for(let n of t.parts)switch(n.type){case"Literal":e+=n.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":e+=`'${n.value}'`;break;case"DoubleQuoted":e+=`"${n.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":e+=`\${${n.parameter}}`;break;case"CommandSubstitution":e+="$(...)";break;case"ArithmeticExpansion":e+=`$((${n.expression}))`;break;case"Glob":e+=n.pattern;break;default:break}return e}zn();Wn();Rr();async function qk(t,e){let n=e.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!n.endsWith(")"))return null;let s=r[1],i=[],o=!1,a="",l=!1;for(let u of e.parts)if(u.type==="Literal"){let f=u.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let d of h)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=pa({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await $r(t,{type:"Word",parts:[u]});i.push(...h.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await ge(t,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function Hk(t,e){let n=-1,r=-1,s=!1;for(let m=0;m<e.parts.length;m++){let g=e.parts[m];if(g.type==="Literal"){let y=g.value.indexOf("+=");if(y!==-1){let b=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){n=m,r=y,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=m,r=y,s=!0;break}}let w=g.value.indexOf("=");if(w!==-1&&(w===0||g.value[w-1]!=="+")){let b=g.value.slice(0,w);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=m,r=w;break}}}}if(n===-1)return null;let i=e.parts.slice(0,n),o=e.parts[n];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=e.parts.slice(n+1),f="";for(let m of i)f+=await ge(t,{type:"Word",parts:[m]});f+=l;let h={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},d=h.parts.length>0?await ge(t,h):"";return`${f}${s?"+=":"="}${d}`}var jH=["tar","yq","xan","sqlite3","python3","python"];function Vk(t){return jH.includes(t)}pe();mn();lr();en();Me();Me();var De=Object.freeze({stdout:"",stderr:"",exitCode:0});function ze(t=""){return{stdout:t,stderr:"",exitCode:0}}function V(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function K(t,e,n){return{stdout:t,stderr:e,exitCode:n}}function Gt(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function Cs(t,e,n="",r=""){throw new ie(t,e,n,r)}function In(t){let e=t.state.fileDescriptors;if(e&&e.size>=t.limits.maxFileDescriptors)throw new ie(`too many open file descriptors (max ${t.limits.maxFileDescriptors})`,"file_descriptors")}function sw(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new ls;return De}if(e.length>1)throw new Re(1,"",`bash: break: too many arguments
1413
+ `),t.writeFileLazy?t.writeFileLazy("/proc/self/status",()=>c6(e)):t.writeFileSync("/proc/self/status",c6(e)),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function mv(t,e,n={pid:1,ppid:0,uid:1e3,gid:1e3}){wq(t)&&(bq(t,e),Eq(t),xq(t,n))}mn();Ar();Me();var Sq=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Aq=["braceexpand","hashall","interactive-comments"];function f6(t){let e=[],n=[...Aq.map(r=>({name:r,enabled:!0})),...Sq.map(r=>({name:r,enabled:t[r]}))].sort((r,s)=>r.name.localeCompare(s.name));for(let r of n)r.enabled&&e.push(r.name);return e.join(":")}function da(t){t.state.env.set("SHELLOPTS",f6(t.state.options))}var vq=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function h6(t){let e=[];for(let n of vq)t[n]&&e.push(n);return e.join(":")}function d6(t){t.state.env.set("BASHOPTS",h6(t.state.shoptOptions))}pe();Ar();to();en();Bt();to();var eH="BASH_ALIAS_";function iC(t){return t.parts.length!==1?!1:t.parts[0].type==="Literal"}function oC(t){if(t.parts.length!==1)return null;let e=t.parts[0];return e.type==="Literal"?e.value:null}function aC(t,e){return t.env.get(`${eH}${e}`)}function _6(t,e,n){if(!e.name||!iC(e.name))return e;let r=oC(e.name);if(!r)return e;let s=aC(t,r);if(!s||n.has(r))return e;try{n.add(r);let i=new Ne,o=s,a=s.endsWith(" ");if(!a)for(let f of e.args){let h=cC(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof un)throw f;return e}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return lC(e,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return lC(e,s);let u={...c,assignments:[...e.assignments,...c.assignments],redirections:[...c.redirections,...e.redirections],line:e.line};if(a&&e.args.length>0&&(u={...u,args:[...u.args,...e.args]},u.args.length>0)){let f=u.args[0];if(iC(f)){let h=oC(f);if(h&&aC(t,h)){let d={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},p=_6(t,d,n);p!==d&&(u={...u,name:p.name,args:[...p.args]})}}}return u}catch(i){throw n.delete(r),i}}function lC(t,e){let n=e;for(let o of t.args){let a=cC(o);n+=` ${a}`}let r=new Ne,s=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${n.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:t.assignments,redirections:t.redirections,line:t.line}}function cC(t){let e="";for(let n of t.parts)switch(n.type){case"Literal":e+=n.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":e+=`'${n.value}'`;break;case"DoubleQuoted":e+=`"${n.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":e+=`\${${n.parameter}}`;break;case"CommandSubstitution":e+="$(...)";break;case"ArithmeticExpansion":e+=`$((${n.expression}))`;break;case"Glob":e+=n.pattern;break;default:break}return e}zn();Wn();Rr();async function qk(t,e){let n=e.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!n.endsWith(")"))return null;let s=r[1],i=[],o=!1,a="",l=!1;for(let u of e.parts)if(u.type==="Literal"){let f=u.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let d of h)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=pa({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await $r(t,{type:"Word",parts:[u]});i.push(...h.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await ge(t,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function Hk(t,e){let n=-1,r=-1,s=!1;for(let m=0;m<e.parts.length;m++){let g=e.parts[m];if(g.type==="Literal"){let y=g.value.indexOf("+=");if(y!==-1){let b=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){n=m,r=y,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=m,r=y,s=!0;break}}let w=g.value.indexOf("=");if(w!==-1&&(w===0||g.value[w-1]!=="+")){let b=g.value.slice(0,w);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=m,r=w;break}}}}if(n===-1)return null;let i=e.parts.slice(0,n),o=e.parts[n];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=e.parts.slice(n+1),f="";for(let m of i)f+=await ge(t,{type:"Word",parts:[m]});f+=l;let h={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},d=h.parts.length>0?await ge(t,h):"";return`${f}${s?"+=":"="}${d}`}var jH=["tar","yq","xan","sqlite3","python3","python"];function Vk(t){return jH.includes(t)}pe();mn();lr();en();Me();Me();var De=Object.freeze({stdout:"",stderr:"",exitCode:0});function ze(t=""){return{stdout:t,stderr:"",exitCode:0}}function V(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function K(t,e,n){return{stdout:t,stderr:e,exitCode:n}}function Gt(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function Cs(t,e,n="",r=""){throw new ie(t,e,n,r)}function In(t){let e=t.state.fileDescriptors;if(e&&e.size>=t.limits.maxFileDescriptors)throw new ie(`too many open file descriptors (max ${t.limits.maxFileDescriptors})`,"file_descriptors")}function sw(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new cs;return De}if(e.length>1)throw new Re(1,"",`bash: break: too many arguments
1414
1414
  `);let n=1;if(e.length>0){let r=Number.parseInt(e[0],10);if(Number.isNaN(r)||r<1)throw new Re(128,"",`bash: break: ${e[0]}: numeric argument required
1415
1415
  `);n=r}throw new Nn(n)}async function iw(t,e){let n,r=!1,s=!1,i=0;for(;i<e.length;)if(e[i]==="--"){i++;break}else if(e[i]==="-L")s=!1,i++;else if(e[i]==="-P")s=!0,i++;else if(e[i].startsWith("-")&&e[i]!=="-")i++;else break;let o=e.slice(i);if(o.length===0||o[0]==="~"?n=t.state.env.get("HOME")||"/":o[0]==="-"?(n=t.state.previousDir,r=!0):n=o[0],!n.startsWith("/")&&!n.startsWith("./")&&!n.startsWith("../")&&n!=="."&&n!==".."){let f=t.state.env.get("CDPATH");if(f){let h=f.split(":").filter(d=>d);for(let d of h){let p=d.startsWith("/")?`${d}/${n}`:`${t.state.cwd}/${d}/${n}`;try{if((await t.fs.stat(p)).isDirectory){n=p,r=!0;break}}catch{}}}}let l=(n.startsWith("/")?n:`${t.state.cwd}/${n}`).split("/").filter(f=>f&&f!=="."),c="";for(let f of l)if(f==="..")c=c.split("/").slice(0,-1).join("/")||"/";else{c=c?`${c}/${f}`:`/${f}`;try{if(!(await t.fs.stat(c)).isDirectory)return V(`bash: cd: ${n}: Not a directory
1416
1416
  `)}catch{return V(`bash: cd: ${n}: No such file or directory
1417
1417
  `)}}let u=c||"/";if(s)try{u=await t.fs.realpath(u)}catch{}return t.state.previousDir=t.state.cwd,t.state.cwd=u,t.state.env.set("PWD",t.state.cwd),t.state.env.set("OLDPWD",t.state.previousDir),ze(r?`${u}
1418
- `:"")}Bt();On();Bt();bt();zn();Wn();Rr();function ow(t,e){return t.fs.resolvePath(t.state.cwd,e)}var qH=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function Ih(t){return qH.includes(t)}async function Ph(t,e,n){let r=ow(t,n);switch(e){case"-e":case"-a":return t.fs.exists(r);case"-f":return await t.fs.exists(r)?(await t.fs.stat(r)).isFile:!1;case"-d":return await t.fs.exists(r)?(await t.fs.stat(r)).isDirectory:!1;case"-r":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&256)!==0:!1;case"-w":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&128)!==0:!1;case"-x":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&64)!==0:!1;case"-s":return await t.fs.exists(r)?(await t.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await t.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&512)!==0:!1;case"-g":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return t.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 t.fs.exists(r);default:return!1}}var HH=["-nt","-ot","-ef"];function Rh(t){return HH.includes(t)}async function $h(t,e,n,r){let s=ow(t,n),i=ow(t,r);switch(e){case"-nt":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await t.fs.exists(s)||!await t.fs.exists(i))return!1;let o=t.fs.resolvePath(t.state.cwd,s),a=t.fs.resolvePath(t.state.cwd,i);return o===a}catch{return!1}default:return!1}}var VH=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function Fh(t){return VH.has(t)}function _h(t,e,n){switch(t){case"-eq":return e===n;case"-ne":return e!==n;case"-lt":return e<n;case"-le":return e<=n;case"-gt":return e>n;case"-ge":return e>=n}}function ic(t){return t==="="||t==="=="||t==="!="}function Dh(t,e,n,r=!1,s=!1,i=!1){if(r){let a=xa(e,n,s,i);return t==="!="?!a:a}if(s){let a=e.toLowerCase()===n.toLowerCase();return t==="!="?!a:a}let o=e===n;return t==="!="?!o:o}var GH=new Set(["-z","-n"]);function Lh(t){return GH.has(t)}function Mh(t,e){switch(t){case"-z":return e==="";case"-n":return e!==""}}On();Bt();zn();Rr();async function Bh(t,e){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let r=n[1],s=n[2];if(t.state.associativeArrays?.has(r)){let a=s;return(a.startsWith("'")&&a.endsWith("'")||a.startsWith('"')&&a.endsWith('"'))&&(a=a.slice(1,-1)),a=a.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(l,c)=>t.state.env.get(c)||""),t.state.env.has(`${r}_${a}`)}let o;try{let a=new Ne,l=Ve(a,s);o=await fe(t,l.expression)}catch{if(/^-?\d+$/.test(s))o=Number.parseInt(s,10);else{let a=t.state.env.get(s);o=a?Number.parseInt(a,10):0}}if(o<0){let a=Vt(t,r),l=t.state.currentLine;if(a.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
1418
+ `:"")}Bt();On();Bt();bt();zn();Wn();Rr();function ow(t,e){return t.fs.resolvePath(t.state.cwd,e)}var qH=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function Ih(t){return qH.includes(t)}async function Ph(t,e,n){let r=ow(t,n);switch(e){case"-e":case"-a":return t.fs.exists(r);case"-f":return await t.fs.exists(r)?(await t.fs.stat(r)).isFile:!1;case"-d":return await t.fs.exists(r)?(await t.fs.stat(r)).isDirectory:!1;case"-r":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&256)!==0:!1;case"-w":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&128)!==0:!1;case"-x":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&64)!==0:!1;case"-s":return await t.fs.exists(r)?(await t.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await t.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&512)!==0:!1;case"-g":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await t.fs.exists(r)?((await t.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return t.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 t.fs.exists(r);default:return!1}}var HH=["-nt","-ot","-ef"];function Rh(t){return HH.includes(t)}async function $h(t,e,n,r){let s=ow(t,n),i=ow(t,r);switch(e){case"-nt":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await t.fs.exists(s)||!await t.fs.exists(i))return!1;let o=t.fs.resolvePath(t.state.cwd,s),a=t.fs.resolvePath(t.state.cwd,i);return o===a}catch{return!1}default:return!1}}var VH=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function Fh(t){return VH.has(t)}function _h(t,e,n){switch(t){case"-eq":return e===n;case"-ne":return e!==n;case"-lt":return e<n;case"-le":return e<=n;case"-gt":return e>n;case"-ge":return e>=n}}function ic(t){return t==="="||t==="=="||t==="!="}function Dh(t,e,n,r=!1,s=!1,i=!1){if(r){let a=xa(e,n,s,i);return t==="!="?!a:a}if(s){let a=e.toLowerCase()===n.toLowerCase();return t==="!="?!a:a}let o=e===n;return t==="!="?!o:o}var GH=new Set(["-z","-n"]);function Lh(t){return GH.has(t)}function Mh(t,e){switch(t){case"-z":return e==="";case"-n":return e!==""}}On();Bt();zn();Rr();async function Bh(t,e){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let r=n[1],s=n[2];if(t.state.associativeArrays?.has(r)){let a=s;return(a.startsWith("'")&&a.endsWith("'")||a.startsWith('"')&&a.endsWith('"'))&&(a=a.slice(1,-1)),a=a.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(l,c)=>t.state.env.get(c)||""),t.state.env.has(`${r}_${a}`)}let o;try{let a=new Ne,l=Ge(a,s);o=await fe(t,l.expression)}catch{if(/^-?\d+$/.test(s))o=Number.parseInt(s,10);else{let a=t.state.env.get(s);o=a?Number.parseInt(a,10):0}}if(o<0){let a=Vt(t,r),l=t.state.currentLine;if(a.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
1419
1419
  `,!1;if(o=Math.max(...a)+1+o,o<0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
1420
- `,!1}return t.state.env.has(`${r}_${o}`)}return t.state.env.has(e)?!0:t.state.associativeArrays?.has(e)?Qr(t,e).length>0:Vt(t,e).length>0}async function Ai(t,e){switch(e.type){case"CondBinary":{let n=await ge(t,e.left),r=e.right.parts.length>0&&e.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&e.operator!=="=~"),s;if(e.operator==="=~")if(r){let i=await ge(t,e.right);s=ma(i)}else s=await X6(t,e.right);else ic(e.operator)&&!r?s=await J6(t,e.right):s=await ge(t,e.right);if(ic(e.operator)){let i=t.state.shoptOptions.nocasematch;return Dh(e.operator,n,s,!r,i,!0)}if(Fh(e.operator))return _h(e.operator,await Kk(t,n),await Kk(t,s));if(Rh(e.operator))return $h(t,e.operator,n,s);switch(e.operator){case"=~":try{let i=t.state.shoptOptions.nocasematch,o=QH(s),l=X(o,i?"i":"").match(n);if(xs(t,"BASH_REMATCH"),l)for(let c=0;c<l.length;c++)t.state.env.set(`BASH_REMATCH_${c}`,l[c]||"");return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return n<s;case">":return n>s;default:return!1}}case"CondUnary":{let n=await ge(t,e.operand);return Ih(e.operator)?Ph(t,e.operator,n):Lh(e.operator)?Mh(e.operator,n):e.operator==="-v"?await Bh(t,n):e.operator==="-o"?lw(t,n):!1}case"CondNot":return t.state.shoptOptions.extglob&&e.operand.type==="CondGroup"&&e.operand.expression.type==="CondWord"?`!(${await ge(t,e.operand.expression.word)})`!=="":!await Ai(t,e.operand);case"CondAnd":return await Ai(t,e.left)?await Ai(t,e.right):!1;case"CondOr":return await Ai(t,e.left)?!0:await Ai(t,e.right);case"CondGroup":return await Ai(t,e.expression);case"CondWord":return await ge(t,e.word)!=="";default:return!1}}async function oc(t,e){if(e.length===0)return K("","",1);if(e.length===1)return Gt(!!e[0]);if(e.length===2){let r=e[0],s=e[1];return r==="("?V(`test: '(' without matching ')'
1420
+ `,!1}return t.state.env.has(`${r}_${o}`)}return t.state.env.has(e)?!0:t.state.associativeArrays?.has(e)?Qr(t,e).length>0:Vt(t,e).length>0}async function Ai(t,e){switch(e.type){case"CondBinary":{let n=await ge(t,e.left),r=e.right.parts.length>0&&e.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&e.operator!=="=~"),s;if(e.operator==="=~")if(r){let i=await ge(t,e.right);s=ma(i)}else s=await X6(t,e.right);else ic(e.operator)&&!r?s=await J6(t,e.right):s=await ge(t,e.right);if(ic(e.operator)){let i=t.state.shoptOptions.nocasematch;return Dh(e.operator,n,s,!r,i,!0)}if(Fh(e.operator))return _h(e.operator,await Kk(t,n),await Kk(t,s));if(Rh(e.operator))return $h(t,e.operator,n,s);switch(e.operator){case"=~":try{let i=t.state.shoptOptions.nocasematch,o=QH(s),l=X(o,i?"i":"").match(n);if(Ss(t,"BASH_REMATCH"),l)for(let c=0;c<l.length;c++)t.state.env.set(`BASH_REMATCH_${c}`,l[c]||"");return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return n<s;case">":return n>s;default:return!1}}case"CondUnary":{let n=await ge(t,e.operand);return Ih(e.operator)?Ph(t,e.operator,n):Lh(e.operator)?Mh(e.operator,n):e.operator==="-v"?await Bh(t,n):e.operator==="-o"?lw(t,n):!1}case"CondNot":return t.state.shoptOptions.extglob&&e.operand.type==="CondGroup"&&e.operand.expression.type==="CondWord"?`!(${await ge(t,e.operand.expression.word)})`!=="":!await Ai(t,e.operand);case"CondAnd":return await Ai(t,e.left)?await Ai(t,e.right):!1;case"CondOr":return await Ai(t,e.left)?!0:await Ai(t,e.right);case"CondGroup":return await Ai(t,e.expression);case"CondWord":return await ge(t,e.word)!=="";default:return!1}}async function oc(t,e){if(e.length===0)return K("","",1);if(e.length===1)return Gt(!!e[0]);if(e.length===2){let r=e[0],s=e[1];return r==="("?V(`test: '(' without matching ')'
1421
1421
  `,2):Ih(r)?Gt(await Ph(t,r,s)):Lh(r)?Gt(Mh(r,s)):r==="!"?Gt(!s):r==="-v"?Gt(await Bh(t,s)):r==="-o"?Gt(lw(t,s)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?V(`test: ${r}: unary operator expected
1422
1422
  `,2):K("","",1)}if(e.length===3){let r=e[0],s=e[1],i=e[2];if(ic(s))return Gt(Dh(s,r,i));if(Fh(s)){let o=Uh(r),a=Uh(i);return!o.valid||!a.valid?K("","",2):Gt(_h(s,o.value,a.value))}if(Rh(s))return Gt(await $h(t,s,r,i));switch(s){case"-a":return Gt(r!==""&&i!=="");case"-o":return Gt(r!==""||i!=="");case">":return Gt(r>i);case"<":return Gt(r<i)}if(r==="!"){let o=await oc(t,[s,i]);return K("",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(r==="("&&i===")")return Gt(s!=="")}if(e.length===4){if(e[0]==="!"){let r=await oc(t,e.slice(1));return K("",r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(e[0]==="("&&e[3]===")")return oc(t,[e[1],e[2]])}let n=await Yk(t,e,0);return n.pos<e.length?V(`test: too many arguments
1423
- `,2):Gt(n.value)}async function Yk(t,e,n){return KH(t,e,n)}async function KH(t,e,n){let{value:r,pos:s}=await Gk(t,e,n);for(;e[s]==="-o";){let i=await Gk(t,e,s+1);r=r||i.value,s=i.pos}return{value:r,pos:s}}async function Gk(t,e,n){let{value:r,pos:s}=await aw(t,e,n);for(;e[s]==="-a";){let i=await aw(t,e,s+1);r=r&&i.value,s=i.pos}return{value:r,pos:s}}async function aw(t,e,n){if(e[n]==="!"){let{value:r,pos:s}=await aw(t,e,n+1);return{value:!r,pos:s}}return ZH(t,e,n)}async function ZH(t,e,n){let r=e[n];if(r==="("){let{value:i,pos:o}=await Yk(t,e,n+1);return{value:i,pos:e[o]===")"?o+1:o}}let s=e[n+1];if(ic(s)){let i=r,o=e[n+2]??"";return{value:Dh(s,i,o),pos:n+3}}if(Fh(s)){let i=Uh(r),o=Uh(e[n+2]??"0");return!i.valid||!o.valid?{value:!1,pos:n+3}:{value:_h(s,i.value,o.value),pos:n+3}}if(Rh(s)){let i=r,o=e[n+2]??"";return{value:await $h(t,s,i,o),pos:n+3}}if(Ih(r)){let i=e[n+1]??"";return{value:await Ph(t,r,i),pos:n+2}}if(Lh(r)){let i=e[n+1]??"";return{value:Mh(r,i),pos:n+2}}if(r==="-v"){let i=e[n+1]??"";return{value:await Bh(t,i),pos:n+2}}if(r==="-o"){let i=e[n+1]??"";return{value:lw(t,i),pos:n+2}}return{value:r!==void 0&&r!=="",pos:n+1}}function xa(t,e,n=!1,r=!1){let s=`^${Qk(e,r)}$`;return X(s,n?"is":"s").test(t)}function Qk(t,e){let n="";for(let r=0;r<t.length;r++){let s=t[r];if(e&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<t.length&&t[r+1]==="("){let i=Xk(t,r+1);if(i!==-1){let o=t.slice(r+2,i),a=Jk(o),l=a.map(u=>Qk(u,e)),c=l.length>0?l.join("|"):"(?:)";if(s==="@")n+=`(?:${c})`;else if(s==="*")n+=`(?:${c})*`;else if(s==="+")n+=`(?:${c})+`;else if(s==="?")n+=`(?:${c})?`;else if(s==="!")if(i<t.length-1){let f=a.map(d=>eN(d,e));if(f.every(d=>d!==null)&&f.every(d=>d===f[0])&&f[0]!==null){let d=f[0];if(d===0)n+="(?:.+)";else{let p=[];d>0&&p.push(`.{0,${d-1}}`),p.push(`.{${d+1},}`),p.push(`(?!(?:${c})).{${d}}`),n+=`(?:${p.join("|")})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`;r=i;continue}}if(s==="\\")if(r+1<t.length){let i=t[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r++}else n+="\\\\";else if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=t.indexOf("]",r+1);i!==-1?(n+=t.slice(r,i+1),r=i):n+="\\["}else/[\\^$.|+(){}]/.test(s)?n+=`\\${s}`:n+=s}return n}function Xk(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function Jk(t){let e=[],n="",r=0,s=0;for(;s<t.length;){let i=t[s];if(i==="\\"){n+=i,s+1<t.length?(n+=t[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(e.push(n),n=""):n+=i,s++}return e.push(n),e}function eN(t,e){let n=0,r=0;for(;r<t.length;){let s=t[r];if(e&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<t.length&&t[r+1]==="("){let i=Xk(t,r+1);if(i!==-1){if(s==="@"){let o=t.slice(r+2,i),l=Jk(o).map(c=>eN(c,e));if(l.every(c=>c!==null)&&l.every(c=>c===l[0])){n+=l[0],r=i+1;continue}return null}return null}}if(s==="*")return null;if(s==="?"){n+=1,r++;continue}if(s==="["){let i=t.indexOf("]",r+1);if(i!==-1){n+=1,r=i+1;continue}n+=1,r++;continue}if(s==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}function lw(t,e){let r=new Map([["errexit",()=>t.state.options.errexit===!0],["nounset",()=>t.state.options.nounset===!0],["pipefail",()=>t.state.options.pipefail===!0],["xtrace",()=>t.state.options.xtrace===!0],["e",()=>t.state.options.errexit===!0],["u",()=>t.state.options.nounset===!0],["x",()=>t.state.options.xtrace===!0]]).get(e);return r?r():!1}async function Kk(t,e){if(e=e.trim(),e==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(e))return Zk(e);try{let n=new Ne,r=Ve(n,e);return await fe(t,r.expression)}catch{return Zk(e)}}function YH(t,e){let n=0;for(let r of t){let s;if(r>="0"&&r<="9")s=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")s=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")s=r.charCodeAt(0)-65+36;else if(r==="@")s=62;else if(r==="_")s=63;else return Number.NaN;if(s>=e)return Number.NaN;n=n*e+s}return n}function Zk(t){if(t=t.trim(),t==="")return 0;let e=!1;t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1));let n,r=t.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let s=Number.parseInt(r[1],10);s>=2&&s<=64?n=YH(r[2],s):n=0}else/^0[xX][0-9a-fA-F]+$/.test(t)?n=Number.parseInt(t,16):/^0[0-7]+$/.test(t)?n=Number.parseInt(t,8):n=Number.parseInt(t,10);return Number.isNaN(n)&&(n=0),e?-n:n}function Uh(t){if(t=t.trim(),t==="")return{value:0,valid:!0};let e=!1;if(t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1)),!/^\d+$/.test(t))return{value:0,valid:!1};let n=Number.parseInt(t,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:e?-n:n,valid:!0}}function QH(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)e+=t[n]+t[n+1],n+=2;else if(t[n]==="["){let r=XH(t,n);e+=r.converted,n=r.endIndex}else e+=t[n],n++;return e}function XH(t,e){let n=e+1,r="[";n<t.length&&(t[n]==="^"||t[n]==="!")&&(r+="^",n++);let s=!1;n<t.length&&t[n]==="]"&&(s=!0,n++);let i=!1;n<t.length&&t[n]==="["&&n+1<t.length&&t[n+1]!==":"&&(i=!0,n++);let o="",a=!1;for(;n<t.length;){let l=t[n];if(l==="]"){a=!0,n++;break}if(l==="["&&n+1<t.length&&t[n+1]===":"){let c=t.indexOf(":]",n+2);if(c!==-1){let u=t.slice(n+2,c);o+=JH(u),n=c+2;continue}}if(l==="["&&n+1<t.length){let c=t[n+1];if(c==="."||c==="="){let u=`${c}]`,f=t.indexOf(u,n+2);if(f!==-1){let h=t.slice(n+2,f);o+=h,n=f+2;continue}}}if(l==="\\"&&n+1<t.length){o+=l+t[n+1],n+=2;continue}o+=l,n++}return a?(s&&(r+="\\]"),i&&(r+="\\["),r+=o,r+="]",{converted:r,endIndex:n}):{converted:"\\[",endIndex:e+1}}function JH(t){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(t)??""}Wn();On();Bt();zn();Ei();function ks(t){let e=[],n="",r=!1,s=!1,i=!1,o=!1;for(let a of t){if(i){n+=a,i=!1,o=!0;continue}if(a==="\\"){i=!0;continue}if(a==="'"&&!s){r||(o=!0),r=!r;continue}if(a==='"'&&!r){s||(o=!0),s=!s;continue}if((a===" "||a===" "||a===`
1424
- `)&&!r&&!s){o&&(e.push(n),n="",o=!1);continue}n+=a,o=!0}return o&&e.push(n),e}function zh(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&/\s/.test(t[n]);)n++;if(n>=t.length)break;if(t[n]!=="["){n++;continue}n++;let r="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)r+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&t[n]!=="]"&&t[n]!=="=";)r+=t[n],n++;for(;n<t.length&&t[n]!=="]";)n++;if(t[n]==="]"&&n++,t[n]!=="=")continue;n++;let s="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)t[n]==="\\"&&n+1<t.length&&n++,s+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&!/\s/.test(t[n]);)s+=t[n],n++;e.push([r,s])}return e}function tN(t){let e=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(e)return{name:e[1],isArray:!0,arrayElements:ks(e[2])};let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(n)return{name:n[1],isArray:!1,arrayIndex:n[2],value:n[3]};if(t.includes("=")){let r=t.indexOf("=");return{name:t.slice(0,r),isArray:!1,value:t.slice(r+1)}}return{name:t,isArray:!1}}async function eV(t,e){try{let n=new Ne,r=Ve(n,e);return await fe(t,r.expression)}catch{let n=parseInt(e,10);return Number.isNaN(n)?0:n}}async function nN(t,e,n={}){let{name:r,isArray:s,arrayElements:i,value:o,arrayIndex:a}=e,{makeReadonly:l=!1,checkReadonly:c=!0}=n;if(c){let u=nn(t,r);if(u)return u}if(s&&i){for(let u=0;u<i.length;u++)t.state.env.set(`${r}_${u}`,i[u]);t.state.env.set(`${r}__length`,String(i.length))}else if(a!==void 0&&o!==void 0){let u=await eV(t,a);t.state.env.set(`${r}_${u}`,o);let f=parseInt(t.state.env.get(`${r}__length`)??"0",10);u>=f&&t.state.env.set(`${r}__length`,String(u+1))}else o!==void 0&&t.state.env.set(r,o);return l&&or(t,r),null}function vi(t,e){t.state.localVarDepth=t.state.localVarDepth||new Map,t.state.localVarDepth.set(e,t.state.callDepth)}function Sa(t,e){return t.state.localVarDepth?.get(e)}function Wh(t,e){t.state.localVarDepth?.delete(e)}function rN(t,e,n){t.state.localVarStack=t.state.localVarStack||new Map;let r=t.state.localVarStack.get(e)||[];r.push({value:n,scopeIndex:t.state.localScopes.length-1}),t.state.localVarStack.set(e,r)}function jh(t,e){let n=t.state.localVarStack?.get(e);if(!(!n||n.length===0))return n.pop()}function sN(t,e){if(t.state.localVarStack)for(let[n,r]of t.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===e;)r.pop();r.length===0&&t.state.localVarStack.delete(n)}}Me();Wn();var cw=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function iN(t){return cw.has(t)}var uw=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),Aa=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"]);Wn();async function oo(t,e,n,r){try{if((await t.fs.stat(e)).isDirectory)return`bash: ${n}: Is a directory
1423
+ `,2):Gt(n.value)}async function Yk(t,e,n){return KH(t,e,n)}async function KH(t,e,n){let{value:r,pos:s}=await Gk(t,e,n);for(;e[s]==="-o";){let i=await Gk(t,e,s+1);r=r||i.value,s=i.pos}return{value:r,pos:s}}async function Gk(t,e,n){let{value:r,pos:s}=await aw(t,e,n);for(;e[s]==="-a";){let i=await aw(t,e,s+1);r=r&&i.value,s=i.pos}return{value:r,pos:s}}async function aw(t,e,n){if(e[n]==="!"){let{value:r,pos:s}=await aw(t,e,n+1);return{value:!r,pos:s}}return ZH(t,e,n)}async function ZH(t,e,n){let r=e[n];if(r==="("){let{value:i,pos:o}=await Yk(t,e,n+1);return{value:i,pos:e[o]===")"?o+1:o}}let s=e[n+1];if(ic(s)){let i=r,o=e[n+2]??"";return{value:Dh(s,i,o),pos:n+3}}if(Fh(s)){let i=Uh(r),o=Uh(e[n+2]??"0");return!i.valid||!o.valid?{value:!1,pos:n+3}:{value:_h(s,i.value,o.value),pos:n+3}}if(Rh(s)){let i=r,o=e[n+2]??"";return{value:await $h(t,s,i,o),pos:n+3}}if(Ih(r)){let i=e[n+1]??"";return{value:await Ph(t,r,i),pos:n+2}}if(Lh(r)){let i=e[n+1]??"";return{value:Mh(r,i),pos:n+2}}if(r==="-v"){let i=e[n+1]??"";return{value:await Bh(t,i),pos:n+2}}if(r==="-o"){let i=e[n+1]??"";return{value:lw(t,i),pos:n+2}}return{value:r!==void 0&&r!=="",pos:n+1}}function xa(t,e,n=!1,r=!1){let s=`^${Qk(e,r)}$`;return X(s,n?"is":"s").test(t)}function Qk(t,e){let n="";for(let r=0;r<t.length;r++){let s=t[r];if(e&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<t.length&&t[r+1]==="("){let i=Xk(t,r+1);if(i!==-1){let o=t.slice(r+2,i),a=Jk(o),l=a.map(u=>Qk(u,e)),c=l.length>0?l.join("|"):"(?:)";if(s==="@")n+=`(?:${c})`;else if(s==="*")n+=`(?:${c})*`;else if(s==="+")n+=`(?:${c})+`;else if(s==="?")n+=`(?:${c})?`;else if(s==="!")if(i<t.length-1){let f=a.map(d=>eN(d,e));if(f.every(d=>d!==null)&&f.every(d=>d===f[0])&&f[0]!==null){let d=f[0];if(d===0)n+="(?:.+)";else{let p=[];d>0&&p.push(`.{0,${d-1}}`),p.push(`.{${d+1},}`),p.push(`(?!(?:${c})).{${d}}`),n+=`(?:${p.join("|")})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`;r=i;continue}}if(s==="\\")if(r+1<t.length){let i=t[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r++}else n+="\\\\";else if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=t.indexOf("]",r+1);i!==-1?(n+=t.slice(r,i+1),r=i):n+="\\["}else/[\\^$.|+(){}]/.test(s)?n+=`\\${s}`:n+=s}return n}function Xk(t,e){let n=1,r=e+1;for(;r<t.length&&n>0;){let s=t[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function Jk(t){let e=[],n="",r=0,s=0;for(;s<t.length;){let i=t[s];if(i==="\\"){n+=i,s+1<t.length?(n+=t[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(e.push(n),n=""):n+=i,s++}return e.push(n),e}function eN(t,e){let n=0,r=0;for(;r<t.length;){let s=t[r];if(e&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<t.length&&t[r+1]==="("){let i=Xk(t,r+1);if(i!==-1){if(s==="@"){let o=t.slice(r+2,i),l=Jk(o).map(c=>eN(c,e));if(l.every(c=>c!==null)&&l.every(c=>c===l[0])){n+=l[0],r=i+1;continue}return null}return null}}if(s==="*")return null;if(s==="?"){n+=1,r++;continue}if(s==="["){let i=t.indexOf("]",r+1);if(i!==-1){n+=1,r=i+1;continue}n+=1,r++;continue}if(s==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}function lw(t,e){let r=new Map([["errexit",()=>t.state.options.errexit===!0],["nounset",()=>t.state.options.nounset===!0],["pipefail",()=>t.state.options.pipefail===!0],["xtrace",()=>t.state.options.xtrace===!0],["e",()=>t.state.options.errexit===!0],["u",()=>t.state.options.nounset===!0],["x",()=>t.state.options.xtrace===!0]]).get(e);return r?r():!1}async function Kk(t,e){if(e=e.trim(),e==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(e))return Zk(e);try{let n=new Ne,r=Ge(n,e);return await fe(t,r.expression)}catch{return Zk(e)}}function YH(t,e){let n=0;for(let r of t){let s;if(r>="0"&&r<="9")s=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")s=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")s=r.charCodeAt(0)-65+36;else if(r==="@")s=62;else if(r==="_")s=63;else return Number.NaN;if(s>=e)return Number.NaN;n=n*e+s}return n}function Zk(t){if(t=t.trim(),t==="")return 0;let e=!1;t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1));let n,r=t.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let s=Number.parseInt(r[1],10);s>=2&&s<=64?n=YH(r[2],s):n=0}else/^0[xX][0-9a-fA-F]+$/.test(t)?n=Number.parseInt(t,16):/^0[0-7]+$/.test(t)?n=Number.parseInt(t,8):n=Number.parseInt(t,10);return Number.isNaN(n)&&(n=0),e?-n:n}function Uh(t){if(t=t.trim(),t==="")return{value:0,valid:!0};let e=!1;if(t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1)),!/^\d+$/.test(t))return{value:0,valid:!1};let n=Number.parseInt(t,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:e?-n:n,valid:!0}}function QH(t){let e="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length)e+=t[n]+t[n+1],n+=2;else if(t[n]==="["){let r=XH(t,n);e+=r.converted,n=r.endIndex}else e+=t[n],n++;return e}function XH(t,e){let n=e+1,r="[";n<t.length&&(t[n]==="^"||t[n]==="!")&&(r+="^",n++);let s=!1;n<t.length&&t[n]==="]"&&(s=!0,n++);let i=!1;n<t.length&&t[n]==="["&&n+1<t.length&&t[n+1]!==":"&&(i=!0,n++);let o="",a=!1;for(;n<t.length;){let l=t[n];if(l==="]"){a=!0,n++;break}if(l==="["&&n+1<t.length&&t[n+1]===":"){let c=t.indexOf(":]",n+2);if(c!==-1){let u=t.slice(n+2,c);o+=JH(u),n=c+2;continue}}if(l==="["&&n+1<t.length){let c=t[n+1];if(c==="."||c==="="){let u=`${c}]`,f=t.indexOf(u,n+2);if(f!==-1){let h=t.slice(n+2,f);o+=h,n=f+2;continue}}}if(l==="\\"&&n+1<t.length){o+=l+t[n+1],n+=2;continue}o+=l,n++}return a?(s&&(r+="\\]"),i&&(r+="\\["),r+=o,r+="]",{converted:r,endIndex:n}):{converted:"\\[",endIndex:e+1}}function JH(t){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(t)??""}Wn();On();Bt();zn();Ei();function ks(t){let e=[],n="",r=!1,s=!1,i=!1,o=!1;for(let a of t){if(i){n+=a,i=!1,o=!0;continue}if(a==="\\"){i=!0;continue}if(a==="'"&&!s){r||(o=!0),r=!r;continue}if(a==='"'&&!r){s||(o=!0),s=!s;continue}if((a===" "||a===" "||a===`
1424
+ `)&&!r&&!s){o&&(e.push(n),n="",o=!1);continue}n+=a,o=!0}return o&&e.push(n),e}function zh(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&/\s/.test(t[n]);)n++;if(n>=t.length)break;if(t[n]!=="["){n++;continue}n++;let r="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)r+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&t[n]!=="]"&&t[n]!=="=";)r+=t[n],n++;for(;n<t.length&&t[n]!=="]";)n++;if(t[n]==="]"&&n++,t[n]!=="=")continue;n++;let s="";if(t[n]==="'"||t[n]==='"'){let i=t[n];for(n++;n<t.length&&t[n]!==i;)t[n]==="\\"&&n+1<t.length&&n++,s+=t[n],n++;t[n]===i&&n++}else for(;n<t.length&&!/\s/.test(t[n]);)s+=t[n],n++;e.push([r,s])}return e}function tN(t){let e=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(e)return{name:e[1],isArray:!0,arrayElements:ks(e[2])};let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(n)return{name:n[1],isArray:!1,arrayIndex:n[2],value:n[3]};if(t.includes("=")){let r=t.indexOf("=");return{name:t.slice(0,r),isArray:!1,value:t.slice(r+1)}}return{name:t,isArray:!1}}async function eV(t,e){try{let n=new Ne,r=Ge(n,e);return await fe(t,r.expression)}catch{let n=parseInt(e,10);return Number.isNaN(n)?0:n}}async function nN(t,e,n={}){let{name:r,isArray:s,arrayElements:i,value:o,arrayIndex:a}=e,{makeReadonly:l=!1,checkReadonly:c=!0}=n;if(c){let u=nn(t,r);if(u)return u}if(s&&i){for(let u=0;u<i.length;u++)t.state.env.set(`${r}_${u}`,i[u]);t.state.env.set(`${r}__length`,String(i.length))}else if(a!==void 0&&o!==void 0){let u=await eV(t,a);t.state.env.set(`${r}_${u}`,o);let f=parseInt(t.state.env.get(`${r}__length`)??"0",10);u>=f&&t.state.env.set(`${r}__length`,String(u+1))}else o!==void 0&&t.state.env.set(r,o);return l&&or(t,r),null}function vi(t,e){t.state.localVarDepth=t.state.localVarDepth||new Map,t.state.localVarDepth.set(e,t.state.callDepth)}function Sa(t,e){return t.state.localVarDepth?.get(e)}function Wh(t,e){t.state.localVarDepth?.delete(e)}function rN(t,e,n){t.state.localVarStack=t.state.localVarStack||new Map;let r=t.state.localVarStack.get(e)||[];r.push({value:n,scopeIndex:t.state.localScopes.length-1}),t.state.localVarStack.set(e,r)}function jh(t,e){let n=t.state.localVarStack?.get(e);if(!(!n||n.length===0))return n.pop()}function sN(t,e){if(t.state.localVarStack)for(let[n,r]of t.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===e;)r.pop();r.length===0&&t.state.localVarStack.delete(n)}}Me();Wn();var cw=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function iN(t){return cw.has(t)}var uw=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),Aa=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"]);Wn();async function oo(t,e,n,r){try{if((await t.fs.stat(e)).isDirectory)return`bash: ${n}: Is a directory
1425
1425
  `;if(r.checkNoclobber&&t.state.options.noclobber&&!r.isClobber&&n!=="/dev/null")return`bash: ${n}: cannot overwrite existing file
1426
1426
  `}catch{}return null}function Ci(t){let n=Math.min(t.length,8192);for(let r=0;r<n;r++)if(t.charCodeAt(r)>127)return"utf8";return"binary"}function tV(t){if(!t.startsWith("__rw__:"))return null;let e=t.slice(7),n=e.indexOf(":");if(n===-1)return null;let r=Number.parseInt(e.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let s=n+1,i=e.slice(s,s+r),o=s+r+1,a=e.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 oN(t,e){let n=new Map;for(let r=0;r<e.length;r++){let s=e[r];if(s.target.type==="HereDoc")continue;if(s.operator===">&"||s.operator==="<&"){if(rc(t,s.target))return{targets:n,error:`bash: $@: ambiguous redirect
1427
1427
  `};n.set(r,await ge(t,s.target))}else{let o=await sc(t,s.target);if("error"in o)return{targets:n,error:o.error};n.set(r,o.target)}}return{targets:n}}function nV(t){t.state.nextFd===void 0&&(t.state.nextFd=10);let e=t.state.nextFd,n=t.limits.maxFileDescriptors;if(e>=n)throw new Error(`bash: cannot allocate file descriptor: too many open files (max ${n})`);return t.state.nextFd++,e}async function qh(t,e){for(let n of e){if(!n.fdVariable)continue;if(t.state.fileDescriptors||(t.state.fileDescriptors=new Map),(n.operator===">&"||n.operator==="<&")&&n.target.type==="Word"&&await ge(t,n.target)==="-"){let i=t.state.env.get(n.fdVariable);if(i!==void 0){let o=Number.parseInt(i,10);Number.isNaN(o)||t.state.fileDescriptors.delete(o)}continue}let r=nV(t);if(t.state.env.set(n.fdVariable,String(r)),n.target.type==="Word"){let s=await ge(t,n.target);if(n.operator===">&"||n.operator==="<&"){let i=Number.parseInt(s,10);if(!Number.isNaN(i)){let o=t.state.fileDescriptors.get(i);o!==void 0&&(In(t),t.state.fileDescriptors.set(r,o));continue}}if(n.operator===">"||n.operator===">>"||n.operator===">|"||n.operator==="&>"||n.operator==="&>>"){let i=t.fs.resolvePath(t.state.cwd,s);(n.operator===">"||n.operator===">|"||n.operator==="&>")&&await t.fs.writeFile(i,"","binary"),In(t),t.state.fileDescriptors.set(r,`__file__:${i}`)}else if(n.operator==="<<<")In(t),t.state.fileDescriptors.set(r,`${s}
@@ -1483,7 +1483,7 @@ Gid: ${s} ${s} ${s} ${s}
1483
1483
  `,2);s.push(c)}else if(l==="+o"){if(a++,a>=e.length)return V(`compopt: +o: option requires an argument
1484
1484
  `,2);let c=e[a];if(!uN.includes(c))return V(`compopt: ${c}: invalid option name
1485
1485
  `,2);i.push(c)}else if(l==="--"){o.push(...e.slice(a+1));break}else!l.startsWith("-")&&!l.startsWith("+")&&o.push(l)}if(n){let a=t.state.completionSpecs.get("__default__")??{isDefault:!0},l=new Set(a.options??[]);for(let c of s)l.add(c);for(let c of i)l.delete(c);return a.options=l.size>0?Array.from(l):void 0,t.state.completionSpecs.set("__default__",a),ze("")}if(r){let a=t.state.completionSpecs.get("__empty__")??{},l=new Set(a.options??[]);for(let c of s)l.add(c);for(let c of i)l.delete(c);return a.options=l.size>0?Array.from(l):void 0,t.state.completionSpecs.set("__empty__",a),ze("")}if(o.length>0){for(let a of o){let l=t.state.completionSpecs.get(a)??{},c=new Set(l.options??[]);for(let u of s)c.add(u);for(let u of i)c.delete(u);l.options=c.size>0?Array.from(c):void 0,t.state.completionSpecs.set(a,l)}return ze("")}return V(`compopt: not currently executing completion function
1486
- `,1)}Me();function yw(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new ls;return De}if(e.length>1)throw new Re(1,"",`bash: continue: too many arguments
1486
+ `,1)}Me();function yw(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new cs;return De}if(e.length>1)throw new Re(1,"",`bash: continue: too many arguments
1487
1487
  `);let n=1;if(e.length>0){let r=Number.parseInt(e[0],10);if(Number.isNaN(r)||r<1)throw new Re(1,"",`bash: continue: ${e[0]}: numeric argument required
1488
1488
  `);n=r}throw new Tn(n)}On();Bt();zn();Rr();Xr();Ei();function Ut(t,e){let n=t.state.env.get("HOME")||"/home/user";return e.split(":").map(i=>i==="~"?n:i==="~root"?"/root":i.startsWith("~/")?n+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}Rr();Xr();function ww(t){for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);if(n<32||n===127)return!0}return!1}function bw(t){let e="$'";for(let n=0;n<t.length;n++){let r=t[n],s=t.charCodeAt(n);s===7?e+="\\a":s===8?e+="\\b":s===9?e+="\\t":s===10?e+="\\n":s===11?e+="\\v":s===12?e+="\\f":s===13?e+="\\r":s===27?e+="\\e":s===39?e+="\\'":s===92?e+="\\\\":s<32||s===127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=r}return e+="'",e}function Vh(t){return ww(t)?bw(t):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function ao(t){return ww(t)?bw(t):`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ew(t){return ww(t)?bw(t):`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function fN(t,e){let n="";return t.state.integerVars?.has(e)&&(n+="i"),t.state.lowercaseVars?.has(e)&&(n+="l"),pt(t,e)&&(n+="n"),t.state.readonlyVars?.has(e)&&(n+="r"),t.state.uppercaseVars?.has(e)&&(n+="u"),t.state.exportedVars?.has(e)&&(n+="x"),n===""?"--":`-${n}`}function xw(t){return t===""?"''":/[\s'\\]/.test(t)?`'${t.replace(/'/g,"'\\''")}'`:t}function hN(t,e){let n="",r="",s=!1;for(let i of e){let o=fN(t,i);if(t.state.associativeArrays?.has(i)){let u=Qr(t,i);if(u.length===0)n+=`declare -A ${i}=()
1489
1489
  `;else{let f=u.map(h=>{let d=t.state.env.get(`${i}_${h}`)??"",p=xw(d);return`['${h}']=${p}`});n+=`declare -A ${i}=(${f.join(" ")})
@@ -1502,7 +1502,7 @@ Gid: ${s} ${s} ${s} ${s}
1502
1502
  `}}return ze(e)}function mN(t){let e="",n=new Set;for(let s of t.state.env.keys()){if(s.startsWith("BASH_"))continue;if(s.endsWith("__length")){let o=s.slice(0,-8);t.state.associativeArrays?.has(o)||n.add(o);continue}let i=s.lastIndexOf("_");if(i>0){let o=s.slice(0,i),a=s.slice(i+1);/^\d+$/.test(a)&&(t.state.associativeArrays?.has(o)||n.add(o))}}let r=Array.from(n).sort();for(let s of r){let i=Vt(t,s);if(i.length===0)e+=`declare -a ${s}=()
1503
1503
  `;else{let o=i.map(a=>{let l=t.state.env.get(`${s}_${a}`)??"";return`[${a}]=${ao(l)}`});e+=`declare -a ${s}=(${o.join(" ")})
1504
1504
  `}}return ze(e)}function gN(t){let e="",n=new Set;for(let s of t.state.env.keys()){if(s.startsWith("BASH_"))continue;if(s.endsWith("__length")){let o=s.slice(0,-8);n.add(o);continue}let i=s.lastIndexOf("_");if(i>0){let o=s.slice(0,i),a=s.slice(i+1);if(/^\d+$/.test(a)||t.state.associativeArrays?.has(o)){n.add(o);continue}}n.add(s)}let r=Array.from(n).sort();for(let s of r){if(t.state.associativeArrays?.has(s)||Vt(t,s).length>0||t.state.env.has(`${s}__length`))continue;let a=t.state.env.get(s);a!==void 0&&(e+=`${s}=${Vh(a)}
1505
- `)}return ze(e)}function Sw(t,e){t.state.integerVars??=new Set,t.state.integerVars.add(e)}function ac(t,e){return t.state.integerVars?.has(e)??!1}function Aw(t,e){t.state.lowercaseVars??=new Set,t.state.lowercaseVars.add(e),t.state.uppercaseVars?.delete(e)}function EV(t,e){return t.state.lowercaseVars?.has(e)??!1}function vw(t,e){t.state.uppercaseVars??=new Set,t.state.uppercaseVars.add(e),t.state.lowercaseVars?.delete(e)}function xV(t,e){return t.state.uppercaseVars?.has(e)??!1}function Ca(t,e,n){return EV(t,e)?n.toLowerCase():xV(t,e)?n.toUpperCase():n}async function yN(t,e){try{let n=new Ne,r=Ve(n,e),s=await fe(t,r.expression);return String(s)}catch{return"0"}}function SV(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return null;let n=e[0],r=n.length;if(t[r]!=="[")return null;let s=0,i=r+1;for(;r<t.length;r++)if(t[r]==="[")s++;else if(t[r]==="]"&&(s--,s===0))break;if(s!==0)return null;let o=t.slice(i,r);if(r++,t[r]!=="=")return null;r++;let a=t.slice(r);return{name:n,indexExpr:o,value:a}}async function Cw(t,e){let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,h=!1,d=!1,p=!1,m=!1,g=!1,y=[];for(let O=0;O<e.length;O++){let R=e[O];if(R==="-a")n=!0;else if(R==="-A")r=!0;else if(R==="-r")s=!0;else if(R==="-x")i=!0;else if(R==="-p")o=!0;else if(R==="-n")a=!0;else if(R==="+n")l=!0;else if(R==="+a")c=!0;else if(R==="+x")u=!0;else if(R==="--"){y.push(...e.slice(O+1));break}else if(R.startsWith("+")){for(let k of R.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 K("",`bash: typeset: +${k}: invalid option
1505
+ `)}return ze(e)}function Sw(t,e){t.state.integerVars??=new Set,t.state.integerVars.add(e)}function ac(t,e){return t.state.integerVars?.has(e)??!1}function Aw(t,e){t.state.lowercaseVars??=new Set,t.state.lowercaseVars.add(e),t.state.uppercaseVars?.delete(e)}function EV(t,e){return t.state.lowercaseVars?.has(e)??!1}function vw(t,e){t.state.uppercaseVars??=new Set,t.state.uppercaseVars.add(e),t.state.lowercaseVars?.delete(e)}function xV(t,e){return t.state.uppercaseVars?.has(e)??!1}function Ca(t,e,n){return EV(t,e)?n.toLowerCase():xV(t,e)?n.toUpperCase():n}async function yN(t,e){try{let n=new Ne,r=Ge(n,e),s=await fe(t,r.expression);return String(s)}catch{return"0"}}function SV(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return null;let n=e[0],r=n.length;if(t[r]!=="[")return null;let s=0,i=r+1;for(;r<t.length;r++)if(t[r]==="[")s++;else if(t[r]==="]"&&(s--,s===0))break;if(s!==0)return null;let o=t.slice(i,r);if(r++,t[r]!=="=")return null;r++;let a=t.slice(r);return{name:n,indexExpr:o,value:a}}async function Cw(t,e){let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,h=!1,d=!1,p=!1,m=!1,g=!1,y=[];for(let O=0;O<e.length;O++){let R=e[O];if(R==="-a")n=!0;else if(R==="-A")r=!0;else if(R==="-r")s=!0;else if(R==="-x")i=!0;else if(R==="-p")o=!0;else if(R==="-n")a=!0;else if(R==="+n")l=!0;else if(R==="+a")c=!0;else if(R==="+x")u=!0;else if(R==="--"){y.push(...e.slice(O+1));break}else if(R.startsWith("+")){for(let k of R.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 K("",`bash: typeset: +${k}: invalid option
1506
1506
  `,2)}}}else if(R==="-i")f=!0;else if(R==="-l")h=!0;else if(R==="-u")d=!0;else if(R==="-f")p=!0;else if(R==="-F")m=!0;else if(R==="-g")g=!0;else if(R.startsWith("-"))for(let k of R.slice(1))if(k==="a")n=!0;else if(k==="A")r=!0;else if(k==="r")s=!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")h=!0;else if(k==="u")d=!0;else if(k==="f")p=!0;else if(k==="F")m=!0;else if(k==="g")g=!0;else return K("",`bash: typeset: -${k}: invalid option
1507
1507
  `,2);else y.push(R)}let b=t.state.localScopes.length>0&&!g,E=O=>{if(!b)return;let R=t.state.localScopes[t.state.localScopes.length-1];R.has(O)||R.set(O,t.state.env.get(O))},A=O=>{if(!b)return;let R=t.state.localScopes[t.state.localScopes.length-1];R.has(O)||R.set(O,t.state.env.get(O));let k=`${O}_`;for(let v of t.state.env.keys())v.startsWith(k)&&!v.includes("__")&&(R.has(v)||R.set(v,t.state.env.get(v)));let S=`${O}__length`;t.state.env.has(S)&&!R.has(S)&&R.set(S,t.state.env.get(S))},C=O=>{b&&vi(t,O)};if(m){if(y.length===0){let k=Array.from(t.state.functions.keys()).sort(),S="";for(let v of k)S+=`declare -f ${v}
1508
1508
  `;return ze(S)}let O=!0,R="";for(let k of y)t.state.functions.has(k)?R+=`${k}
@@ -1512,11 +1512,11 @@ Gid: ${s} ${s} ${s} ${s}
1512
1512
  }
1513
1513
  `;return ze(R)}let O=!0;for(let R of y)t.state.functions.has(R)||(O=!1);return K("","",O?0:1)}if(o&&y.length>0)return hN(t,y);if(o&&y.length===0)return dN(t,{filterExport:i,filterReadonly:s,filterNameref:a,filterIndexedArray:n,filterAssocArray:r});if(y.length===0&&r&&!o)return pN(t);if(y.length===0&&n&&!o)return mN(t);if(y.length===0&&!o)return gN(t);let P="",$=0;for(let O of y){let R=O.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(R&&!c){let T=R[1],_=R[2];if(r&&Vt(t,T).length>0){P+=`bash: declare: ${T}: cannot convert indexed to associative array
1514
1514
  `,$=1;continue}if((n||!r&&!n)&&t.state.associativeArrays?.has(T)){P+=`bash: declare: ${T}: cannot convert associative to indexed array
1515
- `,$=1;continue}if(A(T),r&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(T)),xs(t,T),t.state.env.delete(T),t.state.env.delete(`${T}__length`),r&&_.includes("[")){let D=zh(_);for(let[W,H]of D){let G=Ut(t,H);t.state.env.set(`${T}_${W}`,G)}}else if(r){let D=ks(_);for(let W=0;W<D.length;W+=2){let H=D[W],G=W+1<D.length?Ut(t,D[W+1]):"";t.state.env.set(`${T}_${H}`,G)}}else{let D=ks(_);if(D.some(H=>/^\[[^\]]+\]=/.test(H))){let H=0;for(let G of D){let j=G.match(/^\[([^\]]+)\]=(.*)$/);if(j){let q=j[1],Y=j[2],se=Ut(t,Y),oe;if(/^-?\d+$/.test(q))oe=Number.parseInt(q,10);else try{let ne=new Ne,z=Ve(ne,q);oe=await fe(t,z.expression)}catch{oe=0}t.state.env.set(`${T}_${oe}`,se),H=oe+1}else{let q=Ut(t,G);t.state.env.set(`${T}_${H}`,q),H++}}}else{for(let H=0;H<D.length;H++)t.state.env.set(`${T}_${H}`,D[H]);t.state.env.set(`${T}__length`,String(D.length))}}C(T),s&&or(t,T),i&&Jr(t,T);continue}if(l){let T=O.includes("=")?O.slice(0,O.indexOf("=")):O;if(yC(t,T),!O.includes("="))continue}if(u){let T=O.includes("=")?O.slice(0,O.indexOf("=")):O;if(Sh(t,T),!O.includes("="))continue}let k=SV(O);if(k){let{name:T,indexExpr:_,value:D}=k,W=nn(t,T);if(W)return W;A(T);let H;try{let j=new Ne,q=Ve(j,_);H=await fe(t,q.expression)}catch{let j=parseInt(_,10);H=Number.isNaN(j)?0:j}t.state.env.set(`${T}_${H}`,D);let G=parseInt(t.state.env.get(`${T}__length`)??"0",10);H>=G&&t.state.env.set(`${T}__length`,String(H+1)),C(T),s&&or(t,T),i&&Jr(t,T);continue}let S=O.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(S&&!c){let T=S[1],_=S[2],D=nn(t,T);if(D)return D;A(T);let W=ks(_);if(t.state.associativeArrays?.has(T)){let H=zh(_);for(let[G,j]of H){let q=Ut(t,j);t.state.env.set(`${T}_${G}`,q)}}else{let H=Vt(t,T),G=0,j=t.state.env.get(T);H.length===0&&j!==void 0?(t.state.env.set(`${T}_0`,j),t.state.env.delete(T),G=1):H.length>0&&(G=Math.max(...H)+1);for(let Y=0;Y<W.length;Y++)t.state.env.set(`${T}_${G+Y}`,Ut(t,W[Y]));let q=G+W.length;t.state.env.set(`${T}__length`,String(q))}C(T),s&&or(t,T),i&&Jr(t,T);continue}let v=O.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(v){let T=v[1],_=Ut(t,v[2]),D=nn(t,T);if(D)return D;E(T),f&&Sw(t,T),h&&Aw(t,T),d&&vw(t,T);let H=Vt(t,T).length>0||t.state.associativeArrays?.has(T);if(ac(t,T)){let G=t.state.env.get(T)??"0",j=parseInt(G,10)||0,q=parseInt(await yN(t,_),10)||0;_=String(j+q),t.state.env.set(T,_)}else if(H){_=Ca(t,T,_);let G=`${T}_0`,j=t.state.env.get(G)??"";t.state.env.set(G,j+_)}else{_=Ca(t,T,_);let G=t.state.env.get(T)??"";t.state.env.set(T,G+_)}C(T),s&&or(t,T),i&&Jr(t,T),t.state.options.allexport&&!u&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(T));continue}if(O.includes("=")){let T=O.indexOf("="),_=O.slice(0,T),D=O.slice(T+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_)){P+=`bash: typeset: \`${_}': not a valid identifier
1515
+ `,$=1;continue}if(A(T),r&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(T)),Ss(t,T),t.state.env.delete(T),t.state.env.delete(`${T}__length`),r&&_.includes("[")){let D=zh(_);for(let[W,H]of D){let G=Ut(t,H);t.state.env.set(`${T}_${W}`,G)}}else if(r){let D=ks(_);for(let W=0;W<D.length;W+=2){let H=D[W],G=W+1<D.length?Ut(t,D[W+1]):"";t.state.env.set(`${T}_${H}`,G)}}else{let D=ks(_);if(D.some(H=>/^\[[^\]]+\]=/.test(H))){let H=0;for(let G of D){let j=G.match(/^\[([^\]]+)\]=(.*)$/);if(j){let q=j[1],Y=j[2],se=Ut(t,Y),oe;if(/^-?\d+$/.test(q))oe=Number.parseInt(q,10);else try{let ne=new Ne,z=Ge(ne,q);oe=await fe(t,z.expression)}catch{oe=0}t.state.env.set(`${T}_${oe}`,se),H=oe+1}else{let q=Ut(t,G);t.state.env.set(`${T}_${H}`,q),H++}}}else{for(let H=0;H<D.length;H++)t.state.env.set(`${T}_${H}`,D[H]);t.state.env.set(`${T}__length`,String(D.length))}}C(T),s&&or(t,T),i&&es(t,T);continue}if(l){let T=O.includes("=")?O.slice(0,O.indexOf("=")):O;if(yC(t,T),!O.includes("="))continue}if(u){let T=O.includes("=")?O.slice(0,O.indexOf("=")):O;if(Sh(t,T),!O.includes("="))continue}let k=SV(O);if(k){let{name:T,indexExpr:_,value:D}=k,W=nn(t,T);if(W)return W;A(T);let H;try{let j=new Ne,q=Ge(j,_);H=await fe(t,q.expression)}catch{let j=parseInt(_,10);H=Number.isNaN(j)?0:j}t.state.env.set(`${T}_${H}`,D);let G=parseInt(t.state.env.get(`${T}__length`)??"0",10);H>=G&&t.state.env.set(`${T}__length`,String(H+1)),C(T),s&&or(t,T),i&&es(t,T);continue}let S=O.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(S&&!c){let T=S[1],_=S[2],D=nn(t,T);if(D)return D;A(T);let W=ks(_);if(t.state.associativeArrays?.has(T)){let H=zh(_);for(let[G,j]of H){let q=Ut(t,j);t.state.env.set(`${T}_${G}`,q)}}else{let H=Vt(t,T),G=0,j=t.state.env.get(T);H.length===0&&j!==void 0?(t.state.env.set(`${T}_0`,j),t.state.env.delete(T),G=1):H.length>0&&(G=Math.max(...H)+1);for(let Y=0;Y<W.length;Y++)t.state.env.set(`${T}_${G+Y}`,Ut(t,W[Y]));let q=G+W.length;t.state.env.set(`${T}__length`,String(q))}C(T),s&&or(t,T),i&&es(t,T);continue}let v=O.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(v){let T=v[1],_=Ut(t,v[2]),D=nn(t,T);if(D)return D;E(T),f&&Sw(t,T),h&&Aw(t,T),d&&vw(t,T);let H=Vt(t,T).length>0||t.state.associativeArrays?.has(T);if(ac(t,T)){let G=t.state.env.get(T)??"0",j=parseInt(G,10)||0,q=parseInt(await yN(t,_),10)||0;_=String(j+q),t.state.env.set(T,_)}else if(H){_=Ca(t,T,_);let G=`${T}_0`,j=t.state.env.get(G)??"";t.state.env.set(G,j+_)}else{_=Ca(t,T,_);let G=t.state.env.get(T)??"";t.state.env.set(T,G+_)}C(T),s&&or(t,T),i&&es(t,T),t.state.options.allexport&&!u&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(T));continue}if(O.includes("=")){let T=O.indexOf("="),_=O.slice(0,T),D=O.slice(T+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_)){P+=`bash: typeset: \`${_}': not a valid identifier
1516
1516
  `,$=1;continue}let W=nn(t,_);if(W)return W;if(E(_),a){if(D!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(D)){P+=`bash: declare: \`${D}': invalid variable name for name reference
1517
- `,$=1;continue}t.state.env.set(_,D),Bs(t,_),D!==""&&Eh(t,D)&&j6(t,_),C(_),s&&or(t,_),i&&Jr(t,_);continue}if(f&&Sw(t,_),h&&Aw(t,_),d&&vw(t,_),ac(t,_)&&(D=await yN(t,D)),D=Ca(t,_,D),pt(t,_)){let H=Un(t,_);H&&H!==_?t.state.env.set(H,D):t.state.env.set(_,D)}else t.state.env.set(_,D);C(_),s&&or(t,_),i&&Jr(t,_),t.state.options.allexport&&!u&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(_))}else{let T=O;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(T)){P+=`bash: typeset: \`${T}': not a valid identifier
1518
- `,$=1;continue}if(n||r?A(T):E(T),a){Bs(t,T);let D=t.state.env.get(T);D!==void 0&&D!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(D)?wC(t,T):D&&Eh(t,D)&&j6(t,T),C(T),s&&or(t,T),i&&Jr(t,T);continue}if(f&&Sw(t,T),h&&Aw(t,T),d&&vw(t,T),r){if(Vt(t,T).length>0){P+=`bash: declare: ${T}: cannot convert indexed to associative array
1519
- `,$=1;continue}t.state.associativeArrays??=new Set,t.state.associativeArrays.add(T)}let _=Array.from(t.state.env.keys()).some(D=>D.startsWith(`${T}_`)&&!D.startsWith(`${T}__length`));!t.state.env.has(T)&&!_&&(n||r?t.state.env.set(`${T}__length`,"0"):(t.state.declaredVars??=new Set,t.state.declaredVars.add(T))),C(T),s&&or(t,T),i&&Jr(t,T)}}return K("",P,$)}async function kw(t,e){let n=!1,r=!1,s=!1,i=[];for(let o=0;o<e.length;o++){let a=e[o];if(a==="-a")n=!0;else if(a==="-A")r=!0;else if(a==="-p")s=!0;else if(a==="--"){i.push(...e.slice(o+1));break}else a.startsWith("-")||i.push(a)}if(i.length===0){let o="",a=Array.from(t.state.readonlyVars||[]).sort();for(let l of a){let c=t.state.env.get(l);if(c!==void 0){let u=c.replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -r ${l}="${u}"
1517
+ `,$=1;continue}t.state.env.set(_,D),Bs(t,_),D!==""&&Eh(t,D)&&j6(t,_),C(_),s&&or(t,_),i&&es(t,_);continue}if(f&&Sw(t,_),h&&Aw(t,_),d&&vw(t,_),ac(t,_)&&(D=await yN(t,D)),D=Ca(t,_,D),pt(t,_)){let H=Un(t,_);H&&H!==_?t.state.env.set(H,D):t.state.env.set(_,D)}else t.state.env.set(_,D);C(_),s&&or(t,_),i&&es(t,_),t.state.options.allexport&&!u&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(_))}else{let T=O;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(T)){P+=`bash: typeset: \`${T}': not a valid identifier
1518
+ `,$=1;continue}if(n||r?A(T):E(T),a){Bs(t,T);let D=t.state.env.get(T);D!==void 0&&D!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(D)?wC(t,T):D&&Eh(t,D)&&j6(t,T),C(T),s&&or(t,T),i&&es(t,T);continue}if(f&&Sw(t,T),h&&Aw(t,T),d&&vw(t,T),r){if(Vt(t,T).length>0){P+=`bash: declare: ${T}: cannot convert indexed to associative array
1519
+ `,$=1;continue}t.state.associativeArrays??=new Set,t.state.associativeArrays.add(T)}let _=Array.from(t.state.env.keys()).some(D=>D.startsWith(`${T}_`)&&!D.startsWith(`${T}__length`));!t.state.env.has(T)&&!_&&(n||r?t.state.env.set(`${T}__length`,"0"):(t.state.declaredVars??=new Set,t.state.declaredVars.add(T))),C(T),s&&or(t,T),i&&es(t,T)}}return K("",P,$)}async function kw(t,e){let n=!1,r=!1,s=!1,i=[];for(let o=0;o<e.length;o++){let a=e[o];if(a==="-a")n=!0;else if(a==="-A")r=!0;else if(a==="-p")s=!0;else if(a==="--"){i.push(...e.slice(o+1));break}else a.startsWith("-")||i.push(a)}if(i.length===0){let o="",a=Array.from(t.state.readonlyVars||[]).sort();for(let l of a){let c=t.state.env.get(l);if(c!==void 0){let u=c.replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -r ${l}="${u}"
1520
1520
  `}}return ze(o)}for(let o of i){let a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(a){let f=a[1],h=a[2],d=nn(t,f);if(d)return d;let p=ks(h);if(t.state.associativeArrays?.has(f)){let m=zh(h);for(let[g,y]of m){let w=Ut(t,y);t.state.env.set(`${f}_${g}`,w)}}else{let m=Vt(t,f),g=0,y=t.state.env.get(f);m.length===0&&y!==void 0?(t.state.env.set(`${f}_0`,y),t.state.env.delete(f),g=1):m.length>0&&(g=Math.max(...m)+1);for(let b=0;b<p.length;b++)t.state.env.set(`${f}_${g+b}`,Ut(t,p[b]));let w=g+p.length;t.state.env.set(`${f}__length`,String(w))}or(t,f);continue}let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(l){let f=l[1],h=Ut(t,l[2]),d=nn(t,f);if(d)return d;let p=t.state.env.get(f)??"";t.state.env.set(f,p+h),or(t,f);continue}let c=tN(o);if(c.value===void 0&&!c.isArray){or(t,c.name);continue}let u=await nN(t,c,{makeReadonly:!0});if(u)return u}return De}function Nw(t){return t.state.directoryStack??=[],t.state.directoryStack}function lc(t,e){return e&&t===e?"~":e&&t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t}function AV(t){let e=t.split("/").filter(r=>r&&r!=="."),n=[];for(let r of e)r===".."?n.pop():n.push(r);return`/${n.join("/")}`}async function Tw(t,e){let n=Nw(t),r;for(let a=0;a<e.length;a++){let l=e[a];if(l==="--"){if(a+1<e.length){if(r!==void 0)return V(`bash: pushd: too many arguments
1521
1521
  `,2);r=e[a+1],a++}}else{if(l.startsWith("-")&&l!=="-")return V(`bash: pushd: ${l}: invalid option
1522
1522
  `,2);if(r!==void 0)return V(`bash: pushd: too many arguments
@@ -1542,7 +1542,7 @@ eval: usage: eval [arg ...]
1542
1542
  `);throw a}finally{t.state.groupStdin=i}}Me();function Pw(t,e){let n,r="";if(e.length===0)n=t.state.lastExitCode;else{let s=e[0],i=Number.parseInt(s,10);s===""||Number.isNaN(i)||!/^-?\d+$/.test(s)?(r=`bash: exit: ${s}: numeric argument required
1543
1543
  `,n=2):n=(i%256+256)%256}throw new Re(n,"",r)}Ei();function Rw(t,e){let n=!1,r=[];for(let o of e)o==="-n"?n=!0:o==="-p"||o==="--"||r.push(o);if(r.length===0&&!n){let o="",a=t.state.exportedVars??new Set,l=Array.from(a).sort();for(let c of l){let u=t.state.env.get(c);if(u!==void 0){let f=u.replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -x ${c}="${f}"
1544
1544
  `}}return ze(o)}if(n){for(let o of r){let a,l;if(o.includes("=")){let c=o.indexOf("=");a=o.slice(0,c),l=Ut(t,o.slice(c+1)),t.state.env.set(a,l)}else a=o;Sh(t,a)}return De}let s="",i=0;for(let o of r){let a,l,c=!1,u=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(u)a=u[1],l=Ut(t,u[2]),c=!0;else if(o.includes("=")){let f=o.indexOf("=");a=o.slice(0,f),l=Ut(t,o.slice(f+1))}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){s+=`bash: export: \`${o}': not a valid identifier
1545
- `,i=1;continue}if(l!==void 0)if(c){let f=t.state.env.get(a)??"";t.state.env.set(a,f+l)}else t.state.env.set(a,l);else t.state.env.has(a)||t.state.env.set(a,"");Jr(t,a)}return K("",s,i)}function Kh(t,e){if(e.length<2)return V(`bash: getopts: usage: getopts optstring name [arg ...]
1545
+ `,i=1;continue}if(l!==void 0)if(c){let f=t.state.env.get(a)??"";t.state.env.set(a,f+l)}else t.state.env.set(a,l);else t.state.env.has(a)||t.state.env.set(a,"");es(t,a)}return K("",s,i)}function Kh(t,e){if(e.length<2)return V(`bash: getopts: usage: getopts optstring name [arg ...]
1546
1546
  `);let n=e[0],r=e[1],s=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),i=n.startsWith(":"),o=i?n.slice(1):n,a;if(e.length>2)a=e.slice(2);else{let m=Number.parseInt(t.state.env.get("#")||"0",10);a=[];for(let g=1;g<=m;g++)a.push(t.state.env.get(String(g))||"")}let l=Number.parseInt(t.state.env.get("OPTIND")||"1",10);l<1&&(l=1);let c=Number.parseInt(t.state.env.get("__GETOPTS_CHARINDEX")||"0",10);if(t.state.env.set("OPTARG",""),l>a.length)return s||t.state.env.set(r,"?"),t.state.env.set("OPTIND",String(a.length+1)),t.state.env.set("__GETOPTS_CHARINDEX","0"),{exitCode:s?2:1,stdout:"",stderr:""};let u=a[l-1];if(!u||u==="-"||!u.startsWith("-"))return s||t.state.env.set(r,"?"),{exitCode:s?2:1,stdout:"",stderr:""};if(u==="--")return t.state.env.set("OPTIND",String(l+1)),t.state.env.set("__GETOPTS_CHARINDEX","0"),s||t.state.env.set(r,"?"),{exitCode:s?2:1,stdout:"",stderr:""};let f=c===0?1:c,h=u[f];if(!h)return t.state.env.set("OPTIND",String(l+1)),t.state.env.set("__GETOPTS_CHARINDEX","0"),Kh(t,e);let d=o.indexOf(h);if(d===-1){let m="";return i?t.state.env.set("OPTARG",h):m=`bash: illegal option -- ${h}
1547
1547
  `,s||t.state.env.set(r,"?"),f+1<u.length?(t.state.env.set("__GETOPTS_CHARINDEX",String(f+1)),t.state.env.set("OPTIND",String(l))):(t.state.env.set("OPTIND",String(l+1)),t.state.env.set("__GETOPTS_CHARINDEX","0")),{exitCode:s?2:0,stdout:"",stderr:m}}if(d+1<o.length&&o[d+1]===":")if(f+1<u.length)t.state.env.set("OPTARG",u.slice(f+1)),t.state.env.set("OPTIND",String(l+1)),t.state.env.set("__GETOPTS_CHARINDEX","0");else{if(l>=a.length){let m="";return i?(t.state.env.set("OPTARG",h),s||t.state.env.set(r,":")):(m=`bash: option requires an argument -- ${h}
1548
1548
  `,s||t.state.env.set(r,"?")),t.state.env.set("OPTIND",String(l+1)),t.state.env.set("__GETOPTS_CHARINDEX","0"),{exitCode:s?2:0,stdout:"",stderr:m}}t.state.env.set("OPTARG",a[l]),t.state.env.set("OPTIND",String(l+2)),t.state.env.set("__GETOPTS_CHARINDEX","0")}else f+1<u.length?(t.state.env.set("__GETOPTS_CHARINDEX",String(f+1)),t.state.env.set("OPTIND",String(l))):(t.state.env.set("OPTIND",String(l+1)),t.state.env.set("__GETOPTS_CHARINDEX","0"));return s||t.state.env.set(r,h),{exitCode:s?2:0,stdout:"",stderr:""}}async function $w(t,e){t.state.hashTable||(t.state.hashTable=new Map);let n=!1,r=!1,s=!1,i=!1,o=!1,a="",l=[],c=0;for(;c<e.length;){let p=e[c];if(p==="--"){c++,l.push(...e.slice(c));break}if(p==="-r")n=!0,c++;else if(p==="-d")r=!0,c++;else if(p==="-l")s=!0,c++;else if(p==="-t")o=!0,c++;else if(p==="-p"){if(i=!0,c++,c>=e.length)return V(`bash: hash: -p: option requires an argument
@@ -1918,19 +1918,19 @@ ${d}
1918
1918
  `)}return K("","",r===0?1:0)}On();Bt();zn();Rr();Xr();Ei();async function Dw(t,e){if(t.state.localScopes.length===0)return V(`bash: local: can only be used in a function
1919
1919
  `);let n=t.state.localScopes[t.state.localScopes.length-1],r="",s=0,i=!1,o=!1,a=!1,l=[];for(let c of e)if(c==="-n")i=!0;else if(c==="-a")o=!0;else if(c==="-p")a=!0;else if(c.startsWith("-")&&!c.includes("="))for(let u of c.slice(1))u==="n"?i=!0:u==="a"?o=!0:u==="p"&&(a=!0);else l.push(c);if(l.length===0){let c="",u=Array.from(n.keys()).filter(f=>!f.includes("_")||!f.match(/_\d+$/)).filter(f=>!f.includes("__length")).sort();for(let f of u){let h=t.state.env.get(f);h!==void 0&&(c+=`${f}=${h}
1920
1920
  `)}return K(c,"",0)}for(let c of l){let u,f,h=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(h){u=h[1];let y=h[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1921
- `,s=1;continue}if(nn(t,u,"bash"),!n.has(u)){n.set(u,t.state.env.get(u));let E=`${u}_`;for(let A of t.state.env.keys())A.startsWith(E)&&!A.includes("__")&&(n.has(A)||n.set(A,t.state.env.get(A)))}let w=`${u}_`;for(let E of t.state.env.keys())E.startsWith(w)&&!E.includes("__")&&t.state.env.delete(E);let b=ks(y);for(let E=0;E<b.length;E++)t.state.env.set(`${u}_${E}`,b[E]);t.state.env.set(`${u}__length`,String(b.length)),vi(t,u),i&&Bs(t,u);continue}let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(d){u=d[1];let y=d[2];if(nn(t,u,"bash"),!n.has(u)){n.set(u,t.state.env.get(u));let P=`${u}_`;for(let O of t.state.env.keys())O.startsWith(P)&&!O.includes("__")&&(n.has(O)||n.set(O,t.state.env.get(O)));let $=`${u}__length`;t.state.env.has($)&&!n.has($)&&n.set($,t.state.env.get($))}let w=ks(y),b=Vt(t,u),E=0,A=t.state.env.get(u);b.length===0&&A!==void 0?(t.state.env.set(`${u}_0`,A),t.state.env.delete(u),E=1):b.length>0&&(E=Math.max(...b)+1);for(let P=0;P<w.length;P++)t.state.env.set(`${u}_${E+P}`,Ut(t,w[P]));let C=E+w.length;t.state.env.set(`${u}__length`,String(C)),vi(t,u),i&&Bs(t,u);continue}let p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(p){u=p[1];let y=Ut(t,p[2]);nn(t,u,"bash"),n.has(u)||n.set(u,t.state.env.get(u));let w=t.state.env.get(u)??"";t.state.env.set(u,w+y),vi(t,u),i&&Bs(t,u);continue}let m=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(m){u=m[1];let y=m[2],w=Ut(t,m[3]);if(nn(t,u,"bash"),!n.has(u)){n.set(u,t.state.env.get(u));let A=`${u}_`;for(let P of t.state.env.keys())P.startsWith(A)&&!P.includes("__")&&(n.has(P)||n.set(P,t.state.env.get(P)));let C=`${u}__length`;t.state.env.has(C)&&!n.has(C)&&n.set(C,t.state.env.get(C))}let b;try{let A=new Ne,C=Ve(A,y);b=await fe(t,C.expression)}catch{let A=parseInt(y,10);b=Number.isNaN(A)?0:A}t.state.env.set(`${u}_${b}`,w);let E=parseInt(t.state.env.get(`${u}__length`)??"0",10);b>=E&&t.state.env.set(`${u}__length`,String(b+1)),vi(t,u),i&&Bs(t,u);continue}if(c.includes("=")){let y=c.indexOf("=");u=c.slice(0,y),f=Ut(t,c.slice(y+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1921
+ `,s=1;continue}if(nn(t,u,"bash"),!n.has(u)){n.set(u,t.state.env.get(u));let E=`${u}_`;for(let A of t.state.env.keys())A.startsWith(E)&&!A.includes("__")&&(n.has(A)||n.set(A,t.state.env.get(A)))}let w=`${u}_`;for(let E of t.state.env.keys())E.startsWith(w)&&!E.includes("__")&&t.state.env.delete(E);let b=ks(y);for(let E=0;E<b.length;E++)t.state.env.set(`${u}_${E}`,b[E]);t.state.env.set(`${u}__length`,String(b.length)),vi(t,u),i&&Bs(t,u);continue}let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(d){u=d[1];let y=d[2];if(nn(t,u,"bash"),!n.has(u)){n.set(u,t.state.env.get(u));let P=`${u}_`;for(let O of t.state.env.keys())O.startsWith(P)&&!O.includes("__")&&(n.has(O)||n.set(O,t.state.env.get(O)));let $=`${u}__length`;t.state.env.has($)&&!n.has($)&&n.set($,t.state.env.get($))}let w=ks(y),b=Vt(t,u),E=0,A=t.state.env.get(u);b.length===0&&A!==void 0?(t.state.env.set(`${u}_0`,A),t.state.env.delete(u),E=1):b.length>0&&(E=Math.max(...b)+1);for(let P=0;P<w.length;P++)t.state.env.set(`${u}_${E+P}`,Ut(t,w[P]));let C=E+w.length;t.state.env.set(`${u}__length`,String(C)),vi(t,u),i&&Bs(t,u);continue}let p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(p){u=p[1];let y=Ut(t,p[2]);nn(t,u,"bash"),n.has(u)||n.set(u,t.state.env.get(u));let w=t.state.env.get(u)??"";t.state.env.set(u,w+y),vi(t,u),i&&Bs(t,u);continue}let m=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(m){u=m[1];let y=m[2],w=Ut(t,m[3]);if(nn(t,u,"bash"),!n.has(u)){n.set(u,t.state.env.get(u));let A=`${u}_`;for(let P of t.state.env.keys())P.startsWith(A)&&!P.includes("__")&&(n.has(P)||n.set(P,t.state.env.get(P)));let C=`${u}__length`;t.state.env.has(C)&&!n.has(C)&&n.set(C,t.state.env.get(C))}let b;try{let A=new Ne,C=Ge(A,y);b=await fe(t,C.expression)}catch{let A=parseInt(y,10);b=Number.isNaN(A)?0:A}t.state.env.set(`${u}_${b}`,w);let E=parseInt(t.state.env.get(`${u}__length`)??"0",10);b>=E&&t.state.env.set(`${u}__length`,String(b+1)),vi(t,u),i&&Bs(t,u);continue}if(c.includes("=")){let y=c.indexOf("=");u=c.slice(0,y),f=Ut(t,c.slice(y+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1922
1922
  `,s=1;continue}let g=n.has(u);if(f!==void 0){let y=t.state.env.get(u);if(t.state.tempEnvBindings){let w=t.state.accessedTempEnvVars?.has(u),b=t.state.mutatedTempEnvVars?.has(u);if(!w&&!b)for(let E=t.state.tempEnvBindings.length-1;E>=0;E--){let A=t.state.tempEnvBindings[E];if(A.has(u)){y=A.get(u);break}}}rN(t,u,y)}if(!g){let y=t.state.env.get(u);if(t.state.tempEnvBindings)for(let w=t.state.tempEnvBindings.length-1;w>=0;w--){let b=t.state.tempEnvBindings[w];if(b.has(u)){y=b.get(u);break}}if(n.set(u,y),o){let w=`${u}_`;for(let E of t.state.env.keys())E.startsWith(w)&&!E.includes("__")&&(n.has(E)||n.set(E,t.state.env.get(E)));let b=`${u}__length`;t.state.env.has(b)&&!n.has(b)&&n.set(b,t.state.env.get(b))}}if(o&&f===void 0){let y=`${u}_`;for(let w of t.state.env.keys())w.startsWith(y)&&!w.includes("__")&&t.state.env.delete(w);t.state.env.set(`${u}__length`,"0")}else if(f!==void 0){if(nn(t,u,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){r+=`bash: local: \`${f}': invalid variable name for name reference
1923
1923
  `,s=1;continue}t.state.env.set(u,f),t.state.options.allexport&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(u))}else{let y=t.state.tempEnvBindings?.some(w=>w.has(u));!g&&!y&&t.state.env.delete(u)}vi(t,u),i&&Bs(t,u)}return K("",r,s)}Rr();function Lw(t,e,n){let r=`
1924
1924
  `,s=0,i=0,o=0,a=!1,l="MAPFILE",c=0;for(;c<e.length;){let w=e[c];w==="-d"&&c+1<e.length?(r=e[c+1]===""?"\0":e[c+1]||`
1925
1925
  `,c+=2):w==="-n"&&c+1<e.length?(s=Number.parseInt(e[c+1],10)||0,c+=2):w==="-O"&&c+1<e.length?(i=Number.parseInt(e[c+1],10)||0,c+=2):w==="-s"&&c+1<e.length?(o=Number.parseInt(e[c+1],10)||0,c+=2):w==="-t"?(a=!0,c++):w==="-u"||w==="-C"||w==="-c"?c+=2:(w.startsWith("-")||(l=w),c++)}let u=n;!u&&t.state.groupStdin!==void 0&&(u=t.state.groupStdin);let f=[],h=u,d=0,p=0,m=t.limits?.maxArrayElements??1e5;for(;h.length>0;){let w=h.indexOf(r);if(w===-1){if(h.length>0){if(p<o)p++;else if(s===0||d<s){if(i+d>=m)return K("",`mapfile: array element limit exceeded (${m})
1926
1926
  `,1);let A=h,C=A.indexOf("\0");C!==-1&&(A=A.substring(0,C)),f.push(A),d++}}break}let b=h.substring(0,w),E=b.indexOf("\0");if(E!==-1&&(b=b.substring(0,E)),!a&&r!=="\0"&&(b+=r),h=h.substring(w+r.length),p<o){p++;continue}if(s>0&&d>=s)break;if(i+d>=m)return K("",`mapfile: array element limit exceeded (${m})
1927
- `,1);f.push(b),d++}i===0&&xs(t,l);for(let w=0;w<f.length;w++)t.state.env.set(`${l}_${i+w}`,f[w]);let g=parseInt(t.state.env.get(`${l}__length`)||"0",10),y=i+f.length;return t.state.env.set(`${l}__length`,String(Math.max(g,y))),t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=""),K("","",0)}Rr();yr();function NV(t){if(!t.startsWith("__rw__:"))return null;let e=t.slice(7),n=e.indexOf(":");if(n===-1)return null;let r=Number.parseInt(e.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let s=n+1,i=e.slice(s,s+r),o=s+r+1,a=e.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 TV(t,e,n){return`__rw__:${t.length}:${t}:${e}:${n}`}function Mw(t,e,n,r=-1){let s=!1,i=`
1928
- `,o="",a=-1,l=-1,c=null,u=-1,f=-1,h=[],d=0,p=!1,m=(k,S)=>{let v=1;for(;v<k.length;){let T=k[v];if(T==="r")s=!0,v++;else if(T==="s")v++;else{if(T==="d")return v+1<k.length?(i=k.substring(v+1),{nextArgIndex:S+1}):S+1<e.length?(i=e[S+1],{nextArgIndex:S+2}):{nextArgIndex:S+1};if(T==="n"){if(v+1<k.length){let _=k.substring(v+1);return a=Number.parseInt(_,10),(Number.isNaN(a)||a<0)&&(p=!0,a=0),{nextArgIndex:S+1}}else if(S+1<e.length)return a=Number.parseInt(e[S+1],10),(Number.isNaN(a)||a<0)&&(p=!0,a=0),{nextArgIndex:S+2};return{nextArgIndex:S+1}}else if(T==="N"){if(v+1<k.length){let _=k.substring(v+1);return l=Number.parseInt(_,10),(Number.isNaN(l)||l<0)&&(p=!0,l=0),{nextArgIndex:S+1}}else if(S+1<e.length)return l=Number.parseInt(e[S+1],10),(Number.isNaN(l)||l<0)&&(p=!0,l=0),{nextArgIndex:S+2};return{nextArgIndex:S+1}}else{if(T==="a")return v+1<k.length?(c=k.substring(v+1),{nextArgIndex:S+1}):S+1<e.length?(c=e[S+1],{nextArgIndex:S+2}):{nextArgIndex:S+1};if(T==="p")return v+1<k.length?(o=k.substring(v+1),{nextArgIndex:S+1}):S+1<e.length?(o=e[S+1],{nextArgIndex:S+2}):{nextArgIndex:S+1};if(T==="u"){if(v+1<k.length){let _=k.substring(v+1);return u=Number.parseInt(_,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:S+1}}else if(S+1<e.length)return u=Number.parseInt(e[S+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:S+2};return{nextArgIndex:S+1}}else if(T==="t"){if(v+1<k.length){let _=k.substring(v+1);return f=Number.parseFloat(_),Number.isNaN(f)&&(f=0),{nextArgIndex:S+1}}else if(S+1<e.length)return f=Number.parseFloat(e[S+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:S+2};return{nextArgIndex:S+1}}else if(T==="e"||T==="i"||T==="P"){if(T==="i"&&S+1<e.length)return{nextArgIndex:S+2};v++}else v++}}}return{nextArgIndex:S+1}};for(;d<e.length;){let k=e[d];if(k.startsWith("-")&&k.length>1&&k!=="--"){let S=m(k,d);if(S.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(S.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};d=S.nextArgIndex}else if(k==="--")for(d++;d<e.length;)h.push(e[d]),d++;else h.push(k),d++}if(p)return K("","",1);if(h.length===0&&c===null&&h.push("REPLY"),f===0){if(c)xs(t,c);else{for(let k of h)t.state.env.set(k,"");h.length===0&&t.state.env.set("REPLY","")}return K("","",0)}if(f<0&&f!==-1)return K("","",1);let g=n;u>=0?t.state.fileDescriptors?g=t.state.fileDescriptors.get(u)||"":g="":!g&&t.state.groupStdin!==void 0&&(g=t.state.groupStdin);let y=i===""?"\0":i,w="",b=0,E=!0,A=k=>{if(u>=0&&t.state.fileDescriptors)t.state.fileDescriptors.set(u,g.substring(k));else if(r>=0&&t.state.fileDescriptors){let S=t.state.fileDescriptors.get(r);if(S?.startsWith("__rw__:")){let v=NV(S);if(v){let T=v.position+k;t.state.fileDescriptors.set(r,TV(v.path,T,v.content))}}}else t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=g.substring(k))};if(l>=0){let k=Math.min(l,g.length);w=g.substring(0,k),b=k,E=k>=l,A(b);let S=h[0]||"REPLY";t.state.env.set(S,w);for(let v=1;v<h.length;v++)t.state.env.set(h[v],"");return K("","",E?0:1)}else if(a>=0){let k=0,S=0,v=!1;for(;S<g.length&&k<a;){let T=g[S];if(T===y){b=S+1,v=!0;break}if(!s&&T==="\\"&&S+1<g.length){let _=g[S+1];if(_===y&&y===`
1927
+ `,1);f.push(b),d++}i===0&&Ss(t,l);for(let w=0;w<f.length;w++)t.state.env.set(`${l}_${i+w}`,f[w]);let g=parseInt(t.state.env.get(`${l}__length`)||"0",10),y=i+f.length;return t.state.env.set(`${l}__length`,String(Math.max(g,y))),t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=""),K("","",0)}Rr();yr();function NV(t){if(!t.startsWith("__rw__:"))return null;let e=t.slice(7),n=e.indexOf(":");if(n===-1)return null;let r=Number.parseInt(e.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let s=n+1,i=e.slice(s,s+r),o=s+r+1,a=e.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 TV(t,e,n){return`__rw__:${t.length}:${t}:${e}:${n}`}function Mw(t,e,n,r=-1){let s=!1,i=`
1928
+ `,o="",a=-1,l=-1,c=null,u=-1,f=-1,h=[],d=0,p=!1,m=(k,S)=>{let v=1;for(;v<k.length;){let T=k[v];if(T==="r")s=!0,v++;else if(T==="s")v++;else{if(T==="d")return v+1<k.length?(i=k.substring(v+1),{nextArgIndex:S+1}):S+1<e.length?(i=e[S+1],{nextArgIndex:S+2}):{nextArgIndex:S+1};if(T==="n"){if(v+1<k.length){let _=k.substring(v+1);return a=Number.parseInt(_,10),(Number.isNaN(a)||a<0)&&(p=!0,a=0),{nextArgIndex:S+1}}else if(S+1<e.length)return a=Number.parseInt(e[S+1],10),(Number.isNaN(a)||a<0)&&(p=!0,a=0),{nextArgIndex:S+2};return{nextArgIndex:S+1}}else if(T==="N"){if(v+1<k.length){let _=k.substring(v+1);return l=Number.parseInt(_,10),(Number.isNaN(l)||l<0)&&(p=!0,l=0),{nextArgIndex:S+1}}else if(S+1<e.length)return l=Number.parseInt(e[S+1],10),(Number.isNaN(l)||l<0)&&(p=!0,l=0),{nextArgIndex:S+2};return{nextArgIndex:S+1}}else{if(T==="a")return v+1<k.length?(c=k.substring(v+1),{nextArgIndex:S+1}):S+1<e.length?(c=e[S+1],{nextArgIndex:S+2}):{nextArgIndex:S+1};if(T==="p")return v+1<k.length?(o=k.substring(v+1),{nextArgIndex:S+1}):S+1<e.length?(o=e[S+1],{nextArgIndex:S+2}):{nextArgIndex:S+1};if(T==="u"){if(v+1<k.length){let _=k.substring(v+1);return u=Number.parseInt(_,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:S+1}}else if(S+1<e.length)return u=Number.parseInt(e[S+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:S+2};return{nextArgIndex:S+1}}else if(T==="t"){if(v+1<k.length){let _=k.substring(v+1);return f=Number.parseFloat(_),Number.isNaN(f)&&(f=0),{nextArgIndex:S+1}}else if(S+1<e.length)return f=Number.parseFloat(e[S+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:S+2};return{nextArgIndex:S+1}}else if(T==="e"||T==="i"||T==="P"){if(T==="i"&&S+1<e.length)return{nextArgIndex:S+2};v++}else v++}}}return{nextArgIndex:S+1}};for(;d<e.length;){let k=e[d];if(k.startsWith("-")&&k.length>1&&k!=="--"){let S=m(k,d);if(S.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(S.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};d=S.nextArgIndex}else if(k==="--")for(d++;d<e.length;)h.push(e[d]),d++;else h.push(k),d++}if(p)return K("","",1);if(h.length===0&&c===null&&h.push("REPLY"),f===0){if(c)Ss(t,c);else{for(let k of h)t.state.env.set(k,"");h.length===0&&t.state.env.set("REPLY","")}return K("","",0)}if(f<0&&f!==-1)return K("","",1);let g=n;u>=0?t.state.fileDescriptors?g=t.state.fileDescriptors.get(u)||"":g="":!g&&t.state.groupStdin!==void 0&&(g=t.state.groupStdin);let y=i===""?"\0":i,w="",b=0,E=!0,A=k=>{if(u>=0&&t.state.fileDescriptors)t.state.fileDescriptors.set(u,g.substring(k));else if(r>=0&&t.state.fileDescriptors){let S=t.state.fileDescriptors.get(r);if(S?.startsWith("__rw__:")){let v=NV(S);if(v){let T=v.position+k;t.state.fileDescriptors.set(r,TV(v.path,T,v.content))}}}else t.state.groupStdin!==void 0&&!n&&(t.state.groupStdin=g.substring(k))};if(l>=0){let k=Math.min(l,g.length);w=g.substring(0,k),b=k,E=k>=l,A(b);let S=h[0]||"REPLY";t.state.env.set(S,w);for(let v=1;v<h.length;v++)t.state.env.set(h[v],"");return K("","",E?0:1)}else if(a>=0){let k=0,S=0,v=!1;for(;S<g.length&&k<a;){let T=g[S];if(T===y){b=S+1,v=!0;break}if(!s&&T==="\\"&&S+1<g.length){let _=g[S+1];if(_===y&&y===`
1929
1929
  `){S+=2,b=S;continue}if(_===y){S+=2,k++,w+=_,b=S;continue}w+=_,S+=2,k++,b=S}else w+=T,S++,k++,b=S}E=k>=a||v,A(b)}else{b=0;let k=0;for(;k<g.length;){let S=g[k];if(S===y){b=k+y.length,E=!0;break}if(!s&&S==="\\"&&k+1<g.length){let v=g[k+1];if(v===`
1930
- `){k+=2;continue}if(v===y){w+=v,k+=2;continue}w+=S,w+=v,k+=2;continue}w+=S,k++}if(k>=g.length&&(E=!1,b=k,w.length===0&&g.length===0)){for(let S of h)t.state.env.set(S,"");return c&&xs(t,c),K("","",1)}A(b)}y===`
1930
+ `){k+=2;continue}if(v===y){w+=v,k+=2;continue}w+=S,w+=v,k+=2;continue}w+=S,k++}if(k>=g.length&&(E=!1,b=k,w.length===0&&g.length===0)){for(let S of h)t.state.env.set(S,"");return c&&Ss(t,c),K("","",1)}A(b)}y===`
1931
1931
  `&&w.endsWith(`
1932
1932
  `)&&(w=w.slice(0,-1));let C=k=>s?k:k.replace(/\\(.)/g,"$1");if(h.length===1&&h[0]==="REPLY")return t.state.env.set("REPLY",C(w)),K("","",E?0:1);let P=Xt(t.state.env);if(c){let{words:k}=W6(w,P,void 0,s),S=t.limits?.maxArrayElements??1e5;if(k.length>S)return K("",`read: array element limit exceeded (${S})
1933
- `,1);xs(t,c);for(let v=0;v<k.length;v++)t.state.env.set(`${c}_${v}`,C(k[v]));return K("","",E?0:1)}let $=h.length,{words:O,wordStarts:R}=W6(w,P,$,s);for(let k=0;k<h.length;k++){let S=h[k];if(k<h.length-1)t.state.env.set(S,C(O[k]??""));else if(k<R.length){let v=w.substring(R[k]);v=gC(v,P,s),v=C(v),t.state.env.set(S,v)}else t.state.env.set(S,"")}return K("","",E?0:1)}Me();function Bw(t,e){if(t.state.callDepth===0&&t.state.sourceDepth===0)return V("bash: return: can only `return' from a function or sourced script\n");let n=t.state.lastExitCode;if(e.length>0){let r=e[0],s=Number.parseInt(r,10);if(r===""||Number.isNaN(s)||!/^-?\d+$/.test(r))return V(`bash: return: ${r}: numeric argument required
1933
+ `,1);Ss(t,c);for(let v=0;v<k.length;v++)t.state.env.set(`${c}_${v}`,C(k[v]));return K("","",E?0:1)}let $=h.length,{words:O,wordStarts:R}=W6(w,P,$,s);for(let k=0;k<h.length;k++){let S=h[k];if(k<h.length-1)t.state.env.set(S,C(O[k]??""));else if(k<R.length){let v=w.substring(R[k]);v=gC(v,P,s),v=C(v),t.state.env.set(S,v)}else t.state.env.set(S,"")}return K("","",E?0:1)}Me();function Bw(t,e){if(t.state.callDepth===0&&t.state.sourceDepth===0)return V("bash: return: can only `return' from a function or sourced script\n");let n=t.state.lastExitCode;if(e.length>0){let r=e[0],s=Number.parseInt(r,10);if(r===""||Number.isNaN(s)||!/^-?\d+$/.test(r))return V(`bash: return: ${r}: numeric argument required
1934
1934
  `,2);n=(s%256+256)%256}throw new pn(n)}Me();Rr();var Zh=`set: usage: set [-eux] [+eux] [-o option] [+o option]
1935
1935
  Options:
1936
1936
  -e Exit immediately if a command exits with non-zero status
@@ -1958,10 +1958,10 @@ ${Zh}`;if(t.state.options.posix)throw new ar(1,"",i);return V(i)}vN(t,xN.get(s)?
1958
1958
  ${Zh}`;if(t.state.options.posix)throw new ar(1,"",a);return V(a)}vN(t,EN.get(o)??null,s)}n++;continue}if(r==="--")return Uw(t,e.slice(n+1)),De;if(r==="-"){if(t.state.options.xtrace=!1,t.state.options.verbose=!1,da(t),n+1<e.length)return Uw(t,e.slice(n+1)),De;n++;continue}if(r==="+"){n++;continue}if(r.startsWith("-")||r.startsWith("+")){let s=`bash: set: ${r}: invalid option
1959
1959
  ${Zh}`;if(t.state.options.posix)throw new ar(1,"",s);return V(s)}return Uw(t,e.slice(n)),De}return De}function Uw(t,e){let n=1;for(;t.state.env.has(String(n));)t.state.env.delete(String(n)),n++;for(let r=0;r<e.length;r++)t.state.env.set(String(r+1),e[r]);t.state.env.set("#",String(e.length)),t.state.env.set("@",e.join(" ")),t.state.env.set("*",e.join(" "))}Me();function Ww(t,e){let n=1;if(e.length>0){let o=Number.parseInt(e[0],10);if(Number.isNaN(o)||o<0){let a=`bash: shift: ${e[0]}: numeric argument required
1960
1960
  `;if(t.state.options.posix)throw new ar(1,"",a);return V(a)}n=o}let r=Number.parseInt(t.state.env.get("#")||"0",10);if(n>r){let o=`bash: shift: shift count out of range
1961
- `;if(t.state.options.posix)throw new ar(1,"",o);return V(o)}if(n===0)return De;let s=[];for(let o=1;o<=r;o++)s.push(t.state.env.get(String(o))||"");let i=s.slice(n);for(let o=1;o<=r;o++)t.state.env.delete(String(o));for(let o=0;o<i.length;o++)t.state.env.set(String(o+1),i[o]);return t.state.env.set("#",String(i.length)),t.state.env.set("@",i.join(" ")),De}Bt();Me();async function jw(t,e){let n=e;if(n.length>0&&n[0]==="--"&&(n=n.slice(1)),n.length===0)return K("",`bash: source: filename argument required
1962
- `,2);let r=n[0],s=null,i=null;if(r.includes("/")){let c=t.fs.resolvePath(t.state.cwd,r);try{i=await t.fs.readFile(c),s=c}catch{}}else{let u=(t.state.env.get("PATH")||"").split(":").filter(f=>f);for(let f of u){let h=t.fs.resolvePath(t.state.cwd,`${f}/${r}`);try{if((await t.fs.stat(h)).isDirectory)continue;i=await t.fs.readFile(h),s=h;break}catch{}}if(i===null){let f=t.fs.resolvePath(t.state.cwd,r);try{i=await t.fs.readFile(f),s=f}catch{}}}if(i===null)return V(`bash: ${r}: No such file or directory
1963
- `);let o=new Map;if(n.length>1){for(let u=1;u<=9;u++)o.set(String(u),t.state.env.get(String(u)));o.set("#",t.state.env.get("#")),o.set("@",t.state.env.get("@"));let c=n.slice(1);t.state.env.set("#",String(c.length)),t.state.env.set("@",c.join(" "));for(let u=0;u<c.length&&u<9;u++)t.state.env.set(String(u+1),c[u]);for(let u=c.length+1;u<=9;u++)t.state.env.delete(String(u))}let a=t.state.currentSource,l=()=>{if(t.state.sourceDepth--,t.state.currentSource=a,n.length>1)for(let[c,u]of o)u===void 0?t.state.env.delete(c):t.state.env.set(c,u)};if(t.state.sourceDepth++,t.state.sourceDepth>t.limits.maxSourceDepth)throw t.state.sourceDepth--,new ie(`source: maximum nesting depth (${t.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,"recursion");t.state.currentSource=r;try{let c=Bn(i),u=await t.executeScript(c);return l(),u}catch(c){if(l(),c instanceof Re)throw c;if(c instanceof pn)return K(c.stdout,c.stderr,c.exitCode);if(c.name==="ParseException")return V(`bash: ${r}: ${c.message}
1964
- `);throw c}}On();Bt();zn();sr();Wn();Xr();Ei();function CN(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}function _V(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')}async function kN(t,e){if(_V(e))return null;try{let n=new Ne,r=Ve(n,e);return await fe(t,r.expression)}catch{let n=parseInt(e,10);return Number.isNaN(n)?0:n}}function NN(t,e){if(t.state.localVarStack?.has(e)){let r=jh(t,e);if(r){r.value===void 0?t.state.env.delete(e):t.state.env.set(e,r.value);let s=t.state.localVarStack?.get(e);if(!s||s.length===0)Wh(t,e),t.state.localVarStack?.delete(e),t.state.fullyUnsetLocals=t.state.fullyUnsetLocals||new Map,t.state.fullyUnsetLocals.set(e,r.scopeIndex),qw(t,e);else{let i=s[s.length-1];t.state.localVarDepth=t.state.localVarDepth||new Map,t.state.localVarDepth.set(e,i.scopeIndex+1)}return!0}return t.state.env.delete(e),Wh(t,e),t.state.localVarStack?.delete(e),t.state.fullyUnsetLocals=t.state.fullyUnsetLocals||new Map,t.state.fullyUnsetLocals.set(e,0),!0}for(let r=t.state.localScopes.length-1;r>=0;r--){let s=t.state.localScopes[r];if(s.has(e)){let i=s.get(e);i===void 0?t.state.env.delete(e):t.state.env.set(e,i),s.delete(e);let o=!1;for(let a=r-1;a>=0;a--)if(t.state.localScopes[a].has(e)){t.state.localVarDepth&&t.state.localVarDepth.set(e,a+1),o=!0;break}return o||Wh(t,e),!0}}return!1}function qw(t,e){if(!t.state.tempEnvBindings||t.state.tempEnvBindings.length===0)return!1;for(let n=t.state.tempEnvBindings.length-1;n>=0;n--){let r=t.state.tempEnvBindings[n];if(r.has(e)){let s=r.get(e);return s===void 0?t.state.env.delete(e):t.state.env.set(e,s),r.delete(e),!0}}return!1}async function TN(t,e){if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.startsWith('"')&&e.endsWith('"')){let n=e.slice(1,-1),s=new Ne().parseWordFromString(n,!0,!1);return ge(t,s)}if(e.includes("$")){let r=new Ne().parseWordFromString(e,!1,!1);return ge(t,r)}return e}async function Hw(t,e){let n="both",r="",s=0;for(let i of e){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){t.state.functions.delete(i);continue}if(n==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let h=c[1],d=c[2];if(d==="@"||d==="*"){let b=xe(t,h);for(let[E]of b)t.state.env.delete(`${h}_${E}`);t.state.env.delete(h);continue}let p=t.state.associativeArrays?.has(h);if(p){let b=await TN(t,d);t.state.env.delete(`${h}_${b}`);continue}let m=Us(t,h),g=t.state.declaredVars?.has(h);if((t.state.env.has(h)||g)&&!m&&!p){r+=`bash: unset: ${h}: not an array variable
1961
+ `;if(t.state.options.posix)throw new ar(1,"",o);return V(o)}if(n===0)return De;let s=[];for(let o=1;o<=r;o++)s.push(t.state.env.get(String(o))||"");let i=s.slice(n);for(let o=1;o<=r;o++)t.state.env.delete(String(o));for(let o=0;o<i.length;o++)t.state.env.set(String(o+1),i[o]);return t.state.env.set("#",String(i.length)),t.state.env.set("@",i.join(" ")),De}Bt();Me();async function jw(t,e,n){let r=e;if(r.length>0&&r[0]==="--"&&(r=r.slice(1)),r.length===0)return K("",`bash: source: filename argument required
1962
+ `,2);let s=r[0],i=null,o=null;if(s.includes("/")){let h=t.fs.resolvePath(t.state.cwd,s);try{o=await t.fs.readFile(h),i=h}catch{}}else{let d=(t.state.env.get("PATH")||"").split(":").filter(p=>p);for(let p of d){let m=t.fs.resolvePath(t.state.cwd,`${p}/${s}`);try{if((await t.fs.stat(m)).isDirectory)continue;o=await t.fs.readFile(m),i=m;break}catch{}}if(o===null){let p=t.fs.resolvePath(t.state.cwd,s);try{o=await t.fs.readFile(p),i=p}catch{}}}if(o===null)return V(`bash: ${s}: No such file or directory
1963
+ `);let a=new Map;if(r.length>1){for(let d=1;d<=9;d++)a.set(String(d),t.state.env.get(String(d)));a.set("#",t.state.env.get("#")),a.set("@",t.state.env.get("@"));let h=r.slice(1);t.state.env.set("#",String(h.length)),t.state.env.set("@",h.join(" "));for(let d=0;d<h.length&&d<9;d++)t.state.env.set(String(d+1),h[d]);for(let d=h.length+1;d<=9;d++)t.state.env.delete(String(d))}let l=t.state.currentSource,c=()=>{if(t.state.sourceDepth--,t.state.currentSource=l,r.length>1)for(let[h,d]of a)d===void 0?t.state.env.delete(h):t.state.env.set(h,d)};if(t.state.sourceDepth++,t.state.sourceDepth>t.limits.maxSourceDepth)throw t.state.sourceDepth--,new ie(`source: maximum nesting depth (${t.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,"recursion");t.state.currentSource=s;let u=t.state.groupStdin,f=n??t.state.groupStdin;f!==void 0&&(t.state.groupStdin=f);try{let h=Bn(o),d=await t.executeScript(h);return c(),d}catch(h){if(c(),h instanceof Re)throw h;if(h instanceof pn)return K(h.stdout,h.stderr,h.exitCode);if(h.name==="ParseException")return V(`bash: ${s}: ${h.message}
1964
+ `);throw h}finally{t.state.groupStdin=u}}On();Bt();zn();sr();Wn();Xr();Ei();function CN(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}function _V(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')}async function kN(t,e){if(_V(e))return null;try{let n=new Ne,r=Ge(n,e);return await fe(t,r.expression)}catch{let n=parseInt(e,10);return Number.isNaN(n)?0:n}}function NN(t,e){if(t.state.localVarStack?.has(e)){let r=jh(t,e);if(r){r.value===void 0?t.state.env.delete(e):t.state.env.set(e,r.value);let s=t.state.localVarStack?.get(e);if(!s||s.length===0)Wh(t,e),t.state.localVarStack?.delete(e),t.state.fullyUnsetLocals=t.state.fullyUnsetLocals||new Map,t.state.fullyUnsetLocals.set(e,r.scopeIndex),qw(t,e);else{let i=s[s.length-1];t.state.localVarDepth=t.state.localVarDepth||new Map,t.state.localVarDepth.set(e,i.scopeIndex+1)}return!0}return t.state.env.delete(e),Wh(t,e),t.state.localVarStack?.delete(e),t.state.fullyUnsetLocals=t.state.fullyUnsetLocals||new Map,t.state.fullyUnsetLocals.set(e,0),!0}for(let r=t.state.localScopes.length-1;r>=0;r--){let s=t.state.localScopes[r];if(s.has(e)){let i=s.get(e);i===void 0?t.state.env.delete(e):t.state.env.set(e,i),s.delete(e);let o=!1;for(let a=r-1;a>=0;a--)if(t.state.localScopes[a].has(e)){t.state.localVarDepth&&t.state.localVarDepth.set(e,a+1),o=!0;break}return o||Wh(t,e),!0}}return!1}function qw(t,e){if(!t.state.tempEnvBindings||t.state.tempEnvBindings.length===0)return!1;for(let n=t.state.tempEnvBindings.length-1;n>=0;n--){let r=t.state.tempEnvBindings[n];if(r.has(e)){let s=r.get(e);return s===void 0?t.state.env.delete(e):t.state.env.set(e,s),r.delete(e),!0}}return!1}async function TN(t,e){if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.startsWith('"')&&e.endsWith('"')){let n=e.slice(1,-1),s=new Ne().parseWordFromString(n,!0,!1);return ge(t,s)}if(e.includes("$")){let r=new Ne().parseWordFromString(e,!1,!1);return ge(t,r)}return e}async function Hw(t,e){let n="both",r="",s=0;for(let i of e){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){t.state.functions.delete(i);continue}if(n==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let h=c[1],d=c[2];if(d==="@"||d==="*"){let b=xe(t,h);for(let[E]of b)t.state.env.delete(`${h}_${E}`);t.state.env.delete(h);continue}let p=t.state.associativeArrays?.has(h);if(p){let b=await TN(t,d);t.state.env.delete(`${h}_${b}`);continue}let m=Us(t,h),g=t.state.declaredVars?.has(h);if((t.state.env.has(h)||g)&&!m&&!p){r+=`bash: unset: ${h}: not an array variable
1965
1965
  `,s=1;continue}let w=await kN(t,d);if(w===null&&m){r+=`bash: unset: ${d}: not a valid identifier
1966
1966
  `,s=1;continue}if(w===null)continue;if(w<0){let b=xe(t,h),E=b.length,A=t.state.currentLine;if(E===0){r+=`bash: line ${A}: unset: [${w}]: bad array subscript
1967
1967
  `,s=1;continue}let C=E+w;if(C<0){r+=`bash: line ${A}: unset: [${w}]: bad array subscript
@@ -2025,16 +2025,16 @@ ${t} ()
2025
2025
  `),o=1)}else if(t.commands.has(a)){let u=(t.state.env.get("PATH")??"/usr/bin:/bin").split(":"),f=null;for(let h of u){if(!h)continue;let d=`${h}/${a}`;try{let p=await t.fs.stat(d);if(!p.isDirectory&&(p.mode&73)!==0){f=d;break}}catch{}}f||(f=`/usr/bin/${a}`),r?s+=`${a} is ${f}
2026
2026
  `:s+=`${f}
2027
2027
  `}else r&&(i+=`${a}: not found
2028
- `),o=1}return K(s,i,o)}async function LN(t,e){if(e.includes("/")){let s=t.fs.resolvePath(t.state.cwd,e);if(await t.fs.exists(s)){try{let i=await t.fs.stat(s);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return e}return null}let r=(t.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let s of r){if(!s)continue;let o=`${s.startsWith("/")?s:t.fs.resolvePath(t.state.cwd,s)}/${e}`;if(await t.fs.exists(o)){try{if((await t.fs.stat(o)).isDirectory)continue}catch{continue}return`${s}/${e}`}}if(t.commands.has(e)){for(let s of r)if(s==="/usr/bin"||s==="/bin")return`${s}/${e}`;return`/usr/bin/${e}`}return null}async function MN(t,e,n,r,s,i,o,a){let{ctx:l,runCommand:c}=t;if(l.coverage&&Aa.has(e)&&l.coverage.hit(`bash:builtin:${e}`),e==="export")return Rw(l,n);if(e==="unset")return Hw(l,n);if(e==="exit")return Pw(l,n);if(e==="local")return Dw(l,n);if(e==="set")return zw(l,n);if(e==="break")return sw(l,n);if(e==="continue")return yw(l,n);if(e==="return")return Bw(l,n);if(e==="eval"&&l.state.options.posix)return Gh(l,n,s);if(e==="shift")return Ww(l,n);if(e==="getopts")return Kh(l,n);if(e==="compgen")return dw(l,n);if(e==="complete")return mw(l,n);if(e==="compopt")return gw(l,n);if(e==="pushd")return await Tw(l,n);if(e==="popd")return Ow(l,n);if(e==="dirs")return Iw(l,n);if(e==="source"||e===".")return jw(l,n);if(e==="read")return Mw(l,n,s,a);if(e==="mapfile"||e==="readarray")return Lw(l,n,s);if(e==="declare"||e==="typeset")return Cw(l,n);if(e==="readonly")return kw(l,n);if(!i){let u=l.state.functions.get(e);if(u)return Hh(l,u,n,s)}if(e==="eval")return Gh(l,n,s);if(e==="cd")return await iw(l,n);if(e===":"||e==="true")return De;if(e==="false")return Gt(!1);if(e==="let")return _w(l,n);if(e==="command")return WV(t,n,s);if(e==="builtin")return jV(t,n,s);if(e==="shopt")return ON(l,n);if(e==="exec"){if(n.length===0)return De;let[u,...f]=n;return c(u,f,[],s,!1,!1,-1)}if(e==="wait")return De;if(e==="type")return await _N(l,n,u=>LN(l,u),u=>Qh(l,u));if(e==="hash")return $w(l,n);if(e==="help")return Fw(l,n);if(e==="["||e==="test"){let u=n;if(e==="["){if(n[n.length-1]!=="]")return V("[: missing `]'\n",2);u=n.slice(0,-1)}return oc(l,u)}return null}async function WV(t,e,n){let{ctx:r,runCommand:s}=t;if(e.length===0)return De;let i=!1,o=!1,a=!1,l=e;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let h of f.slice(1))h==="p"?i=!0:h==="V"?o=!0:h==="v"&&(a=!0);l=l.slice(1)}if(l.length===0)return De;if(a||o)return await DN(r,l,a,o);let[c,...u]=l;return s(c,u,[],n,!0,i,-1)}async function jV(t,e,n){let{runCommand:r}=t;if(e.length===0)return De;let s=e;if(s[0]==="--"&&(s=s.slice(1),s.length===0))return De;let i=s[0];if(!Aa.has(i))return V(`bash: builtin: ${i}: not a shell builtin
2028
+ `),o=1}return K(s,i,o)}async function LN(t,e){if(e.includes("/")){let s=t.fs.resolvePath(t.state.cwd,e);if(await t.fs.exists(s)){try{let i=await t.fs.stat(s);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return e}return null}let r=(t.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let s of r){if(!s)continue;let o=`${s.startsWith("/")?s:t.fs.resolvePath(t.state.cwd,s)}/${e}`;if(await t.fs.exists(o)){try{if((await t.fs.stat(o)).isDirectory)continue}catch{continue}return`${s}/${e}`}}if(t.commands.has(e)){for(let s of r)if(s==="/usr/bin"||s==="/bin")return`${s}/${e}`;return`/usr/bin/${e}`}return null}async function MN(t,e,n,r,s,i,o,a){let{ctx:l,runCommand:c}=t;if(l.coverage&&Aa.has(e)&&l.coverage.hit(`bash:builtin:${e}`),e==="export")return Rw(l,n);if(e==="unset")return Hw(l,n);if(e==="exit")return Pw(l,n);if(e==="local")return Dw(l,n);if(e==="set")return zw(l,n);if(e==="break")return sw(l,n);if(e==="continue")return yw(l,n);if(e==="return")return Bw(l,n);if(e==="eval"&&l.state.options.posix)return Gh(l,n,s);if(e==="shift")return Ww(l,n);if(e==="getopts")return Kh(l,n);if(e==="compgen")return dw(l,n);if(e==="complete")return mw(l,n);if(e==="compopt")return gw(l,n);if(e==="pushd")return await Tw(l,n);if(e==="popd")return Ow(l,n);if(e==="dirs")return Iw(l,n);if(e==="source"||e===".")return jw(l,n,s);if(e==="read")return Mw(l,n,s,a);if(e==="mapfile"||e==="readarray")return Lw(l,n,s);if(e==="declare"||e==="typeset")return Cw(l,n);if(e==="readonly")return kw(l,n);if(!i){let u=l.state.functions.get(e);if(u)return Hh(l,u,n,s)}if(e==="eval")return Gh(l,n,s);if(e==="cd")return await iw(l,n);if(e===":"||e==="true")return De;if(e==="false")return Gt(!1);if(e==="let")return _w(l,n);if(e==="command")return WV(t,n,s);if(e==="builtin")return jV(t,n,s);if(e==="shopt")return ON(l,n);if(e==="exec"){if(n.length===0)return De;let[u,...f]=n;return c(u,f,[],s,!1,!1,-1)}if(e==="wait")return De;if(e==="type")return await _N(l,n,u=>LN(l,u),u=>Qh(l,u));if(e==="hash")return $w(l,n);if(e==="help")return Fw(l,n);if(e==="["||e==="test"){let u=n;if(e==="["){if(n[n.length-1]!=="]")return V("[: missing `]'\n",2);u=n.slice(0,-1)}return oc(l,u)}return null}async function WV(t,e,n){let{ctx:r,runCommand:s}=t;if(e.length===0)return De;let i=!1,o=!1,a=!1,l=e;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let h of f.slice(1))h==="p"?i=!0:h==="V"?o=!0:h==="v"&&(a=!0);l=l.slice(1)}if(l.length===0)return De;if(a||o)return await DN(r,l,a,o);let[c,...u]=l;return s(c,u,[],n,!0,i,-1)}async function jV(t,e,n){let{runCommand:r}=t;if(e.length===0)return De;let s=e;if(s[0]==="--"&&(s=s.slice(1),s.length===0))return De;let i=s[0];if(!Aa.has(i))return V(`bash: builtin: ${i}: not a shell builtin
2029
2029
  `);let[,...o]=s;return r(i,o,[],n,!0,!1,-1)}async function BN(t,e,n,r,s){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=t,c=await IN(i,e,s?"/usr/bin:/bin":void 0);if(!c)return Vk(e)?V(`bash: ${e}: command not available in browser environments. Exclude '${e}' from your commands or use the Node.js bundle.
2030
2030
  `,127):V(`bash: ${e}: command not found
2031
2031
  `,127);if("error"in c)return c.error==="permission_denied"?V(`bash: ${e}: Permission denied
2032
2032
  `,126):V(`bash: ${e}: No such file or directory
2033
2033
  `,127);if("script"in c)return e.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(e,c.path)),await a(c.path,n,r);let{cmd:u,path:f}=c;e.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(e,f));let h=r||i.state.groupStdin||"",d=o(),p={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:d,stdin:h,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},m=PN(p,e);try{let g=()=>yn(i.requireDefenseContext,"command",`${e} execution`,()=>u.execute(n,m));return u.trusted?await tt.runTrustedAsync(()=>g()):await g()}catch(g){if(g instanceof ie||g instanceof Se)throw g;return V(`${e}: ${Fe(ct(g))}
2034
2034
  `)}}zn();Me();Wn();async function Gw(t,e){let n=t.state.inCondition;t.state.inCondition=!0;let r="",s="",i=0;try{for(let o of e){let a=await t.executeStatement(o);r+=a.stdout,s+=a.stderr,i=a.exitCode}}finally{t.state.inCondition=n}return{stdout:r,stderr:s,exitCode:i}}Me();$n();function uc(t,e,n,r){if(t instanceof Nn)return e+=t.stdout,n+=t.stderr,t.levels>1&&r>1?(t.levels--,t.stdout=e,t.stderr=n,{action:"rethrow",stdout:e,stderr:n,error:t}):{action:"break",stdout:e,stderr:n};if(t instanceof Tn)return e+=t.stdout,n+=t.stderr,t.levels>1&&r>1?(t.levels--,t.stdout=e,t.stderr=n,{action:"rethrow",stdout:e,stderr:n,error:t}):{action:"continue",stdout:e,stderr:n};if(t instanceof pn||t instanceof Hn||t instanceof Re||t instanceof ie)return t.prependOutput(e,n),{action:"rethrow",stdout:e,stderr:n,error:t};let s=ct(t);return{action:"error",stdout:e,stderr:`${n}${s}
2035
- `,exitCode:1}}Me();$n();async function Xh(t,e,n="",r=""){let s=n,i=r,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(wc(a)||a instanceof Hn||a instanceof Re||a instanceof ie||a instanceof ls)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${ct(a)}
2035
+ `,exitCode:1}}Me();$n();async function Xh(t,e,n="",r=""){let s=n,i=r,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(wc(a)||a instanceof Hn||a instanceof Re||a instanceof ie||a instanceof cs)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${ct(a)}
2036
2036
  `,exitCode:1}}return{stdout:s,stderr:i,exitCode:o}}async function UN(t,e){let n="",r="";for(let s of e.clauses){let i=await Gw(t,s.condition);if(n+=i.stdout,r+=i.stderr,i.exitCode===0)return Xh(t,s.body,n,r)}return e.elseBody?Xh(t,e.elseBody,n,r):K(n,r,0)}async function zN(t,e){let n=await Ns(t,e.redirections);if(n)return n;let r="",s="",i=0,o=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.variable))return V(`bash: \`${e.variable}': not a valid identifier
2037
- `);let a=[];if(e.words===null)a=(t.state.env.get("@")||"").split(" ").filter(Boolean);else if(e.words.length===0)a=[];else try{for(let c of e.words){let u=await $r(t,c);a.push(...u.values)}}catch(c){if(c instanceof as)return{stdout:"",stderr:c.stderr,exitCode:1};throw c}t.state.loopDepth++;try{for(let c of a){o++,o>t.limits.maxLoopIterations&&Cs(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,s),t.state.env.set(e.variable,c);try{for(let u of e.body){let f=await t.executeStatement(u);r+=f.stdout,s+=f.stderr,i=f.exitCode}}catch(u){let f=uc(u,r,s,t.state.loopDepth);if(r=f.stdout,s=f.stderr,f.action==="break")break;if(f.action==="continue")continue;if(f.action==="error"){let h=K(r,s,f.exitCode??1);return Pt(t,h,e.redirections)}throw f.error}}}finally{t.state.loopDepth--}let l=K(r,s,i);return Pt(t,l,e.redirections)}async function WN(t,e){let n=await Ns(t,e.redirections);if(n)return n;let r=e.line;r!==void 0&&(t.state.currentLine=r);let s="",i="",o=0,a=0;e.init&&await fe(t,e.init.expression),t.state.loopDepth++;try{for(;a++,a>t.limits.maxLoopIterations&&Cs(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",s,i),!(e.condition&&(r!==void 0&&(t.state.currentLine=r),await fe(t,e.condition.expression)===0));){try{for(let c of e.body){let u=await t.executeStatement(c);s+=u.stdout,i+=u.stderr,o=u.exitCode}}catch(c){let u=uc(c,s,i,t.state.loopDepth);if(s=u.stdout,i=u.stderr,u.action==="break")break;if(u.action==="continue"){e.update&&await fe(t,e.update.expression);continue}if(u.action==="error"){let f=K(s,i,u.exitCode??1);return Pt(t,f,e.redirections)}throw u.error}e.update&&await fe(t,e.update.expression)}}finally{t.state.loopDepth--}let l=K(s,i,o);return Pt(t,l,e.redirections)}async function jN(t,e,n=""){let r="",s="",i=0,o=0,a=n;for(let c of e.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await ge(t,u.content);u.stripTabs&&(f=f.split(`
2037
+ `);let a=[];if(e.words===null)a=(t.state.env.get("@")||"").split(" ").filter(Boolean);else if(e.words.length===0)a=[];else try{for(let c of e.words){let u=await $r(t,c);a.push(...u.values)}}catch(c){if(c instanceof ls)return{stdout:"",stderr:c.stderr,exitCode:1};throw c}t.state.loopDepth++;try{for(let c of a){o++,o>t.limits.maxLoopIterations&&Cs(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,s),t.state.env.set(e.variable,c);try{for(let u of e.body){let f=await t.executeStatement(u);r+=f.stdout,s+=f.stderr,i=f.exitCode}}catch(u){let f=uc(u,r,s,t.state.loopDepth);if(r=f.stdout,s=f.stderr,f.action==="break")break;if(f.action==="continue")continue;if(f.action==="error"){let h=K(r,s,f.exitCode??1);return Pt(t,h,e.redirections)}throw f.error}}}finally{t.state.loopDepth--}let l=K(r,s,i);return Pt(t,l,e.redirections)}async function WN(t,e){let n=await Ns(t,e.redirections);if(n)return n;let r=e.line;r!==void 0&&(t.state.currentLine=r);let s="",i="",o=0,a=0;e.init&&await fe(t,e.init.expression),t.state.loopDepth++;try{for(;a++,a>t.limits.maxLoopIterations&&Cs(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",s,i),!(e.condition&&(r!==void 0&&(t.state.currentLine=r),await fe(t,e.condition.expression)===0));){try{for(let c of e.body){let u=await t.executeStatement(c);s+=u.stdout,i+=u.stderr,o=u.exitCode}}catch(c){let u=uc(c,s,i,t.state.loopDepth);if(s=u.stdout,i=u.stderr,u.action==="break")break;if(u.action==="continue"){e.update&&await fe(t,e.update.expression);continue}if(u.action==="error"){let f=K(s,i,u.exitCode??1);return Pt(t,f,e.redirections)}throw u.error}e.update&&await fe(t,e.update.expression)}}finally{t.state.loopDepth--}let l=K(s,i,o);return Pt(t,l,e.redirections)}async function jN(t,e,n=""){let r="",s="",i=0,o=0,a=n;for(let c of e.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await ge(t,u.content);u.stripTabs&&(f=f.split(`
2038
2038
  `).map(h=>h.replace(/^\t+/,"")).join(`
2039
2039
  `)),a=f}else if(c.operator==="<<<"&&c.target.type==="Word")a=`${await ge(t,c.target)}
2040
2040
  `;else if(c.operator==="<"&&c.target.type==="Word")try{let u=await ge(t,c.target),f=t.fs.resolvePath(t.state.cwd,u);a=await t.fs.readFile(f)}catch{let u=await ge(t,c.target);return V(`bash: ${u}: No such file or directory
@@ -2055,13 +2055,13 @@ sys 0m0.000s
2055
2055
  `,1)};if(pt(t,n)){let u=so(t,n);if(u===void 0||u==="")throw new Re(1,"","");let f=Un(t,n);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:K("",`bash: ${n}: cannot assign list to array member
2056
2056
  `,1)}}if(vs(t,n)){if(e.name)return o+=`bash: ${n}: readonly variable
2057
2057
  `,{continueToNext:!0,xtraceOutput:o};let u=nn(t,n);if(u)return{continueToNext:!1,xtraceOutput:"",error:u}}let a=t.state.associativeArrays?.has(n),l=GV(r),c=()=>{let u=`${n}_`;for(let f of t.state.env.keys())f.startsWith(u)&&!f.includes("__")&&t.state.env.delete(f);t.state.env.delete(n)};if(a&&l?await KV(t,e,n,r,s,c,u=>{o+=u}):l?await ZV(t,n,r,s,c):await YV(t,n,r,s,c),e.name){i.set(n,t.state.env.get(n));let f=`(${r.map(h=>pa(h)).join(" ")})`;t.state.env.set(n,f)}return{continueToNext:!0,xtraceOutput:o}}function GV(t){return t.some(e=>{if(e.parts.length>=2){let n=e.parts[0],r=e.parts[1];if(n.type!=="Glob"||!n.pattern.startsWith("["))return!1;if(n.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(e.parts.length<3)return!1;let s=e.parts[2];return s.type!=="Literal"?!1:s.value.startsWith("]=")||s.value.startsWith("]+=")}return r.type!=="Literal"?!1:r.value.startsWith("]")?r.value.startsWith("]=")||r.value.startsWith("]+="):n.pattern.endsWith("]")?r.value.startsWith("=")||r.value.startsWith("+="):!1}return!1})}async function KV(t,e,n,r,s,i,o){let a=[];for(let l of r){let c=U6(l);if(c){let{key:u,valueParts:f,append:h}=c,d;f.length>0?d=await ge(t,{type:"Word",parts:f}):d="",d=Ut(t,d),a.push({type:"keyed",key:u,value:d,append:h})}else{let u=await ge(t,l);a.push({type:"invalid",expandedValue:u})}}s||i();for(let l of a)if(l.type==="keyed")if(l.append){let c=t.state.env.get(`${n}_${l.key}`)??"";t.state.env.set(`${n}_${l.key}`,c+l.value)}else t.state.env.set(`${n}_${l.key}`,l.value);else{let c=e.line??t.state.currentLine??1;o(`bash: line ${c}: ${n}: ${l.expandedValue}: must use subscript when assigning associative array
2058
- `)}}async function ZV(t,e,n,r,s){let i=[];for(let a of n){let l=U6(a);if(l){let{key:c,valueParts:u,append:f}=l,h;u.length>0?h=await ge(t,{type:"Word",parts:u}):h="",h=Ut(t,h),i.push({type:"keyed",indexExpr:c,value:h,append:f})}else{let c=await $r(t,a);i.push({type:"non-keyed",values:c.values})}}r||s();let o=0;for(let a of i)if(a.type==="keyed"){let l;try{let c=new Ne,u=Ve(c,a.indexExpr);l=await fe(t,u.expression,!1)}catch{if(/^-?\d+$/.test(a.indexExpr))l=Number.parseInt(a.indexExpr,10);else{let c=t.state.env.get(a.indexExpr);l=c?Number.parseInt(c,10):0,Number.isNaN(l)&&(l=0)}}if(a.append){let c=t.state.env.get(`${e}_${l}`)??"";t.state.env.set(`${e}_${l}`,c+a.value)}else t.state.env.set(`${e}_${l}`,a.value);o=l+1}else for(let l of a.values)t.state.env.set(`${e}_${o++}`,l)}async function YV(t,e,n,r,s){let i=[];for(let a of n){let l=await $r(t,a);i.push(...l.values)}let o=0;if(r){let a=xe(t,e);if(a.length>0)o=Math.max(...a.map(([c])=>typeof c=="number"?c:0))+1;else{let l=t.state.env.get(e);l!==void 0&&(t.state.env.set(`${e}_0`,l),t.state.env.delete(e),o=1)}}else s();for(let a=0;a<i.length;a++)t.state.env.set(`${e}_${o+a}`,i[a]);r||t.state.env.set(`${e}__length`,String(i.length))}async function QV(t,e,n,r,s,i,o){let a=n;if(pt(t,n)){let f=Un(t,n);if(f&&f!==n){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:K("",`bash: \`${f}': not a valid identifier
2059
- `,1)};a=f}}if(vs(t,a)){if(e.name)return{continueToNext:!0,xtraceOutput:""};let f=nn(t,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let l=t.state.associativeArrays?.has(a),c;if(l)c=await JN(t,a,r);else{let f=await XV(t,a,r);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};c=`${a}_${f.index}`}let u=i?(t.state.env.get(c)||"")+s:s;if(e.name)o.set(c,t.state.env.get(c)),t.state.env.set(c,u);else{let f=Sa(t,a);if(f!==void 0&&f===t.state.callDepth&&t.state.localScopes.length>0){let h=t.state.localScopes[t.state.localScopes.length-1];h.has(c)||h.set(c,t.state.env.get(c))}t.state.env.set(c,u)}return{continueToNext:!0,xtraceOutput:""}}async function JN(t,e,n){let r;if(n.startsWith("'")&&n.endsWith("'"))r=n.slice(1,-1);else if(n.startsWith('"')&&n.endsWith('"')){let s=n.slice(1,-1),o=new Ne().parseWordFromString(s,!0,!1);r=await ge(t,o)}else if(n.includes("$")){let i=new Ne().parseWordFromString(n,!1,!1);r=await ge(t,i)}else r=n;return`${e}_${r}`}async function XV(t,e,n){let r=n;n.startsWith('"')&&n.endsWith('"')&&n.length>=2&&(r=n.slice(1,-1));let s;if(/^-?\d+$/.test(r))s=Number.parseInt(r,10);else{try{let i=new Ne,o=Ve(i,r);s=await fe(t,o.expression,!1)}catch(i){if(i instanceof lt){let l=`bash: line ${t.state.currentLine}: ${n}: ${i.message}
2058
+ `)}}async function ZV(t,e,n,r,s){let i=[];for(let a of n){let l=U6(a);if(l){let{key:c,valueParts:u,append:f}=l,h;u.length>0?h=await ge(t,{type:"Word",parts:u}):h="",h=Ut(t,h),i.push({type:"keyed",indexExpr:c,value:h,append:f})}else{let c=await $r(t,a);i.push({type:"non-keyed",values:c.values})}}r||s();let o=0;for(let a of i)if(a.type==="keyed"){let l;try{let c=new Ne,u=Ge(c,a.indexExpr);l=await fe(t,u.expression,!1)}catch{if(/^-?\d+$/.test(a.indexExpr))l=Number.parseInt(a.indexExpr,10);else{let c=t.state.env.get(a.indexExpr);l=c?Number.parseInt(c,10):0,Number.isNaN(l)&&(l=0)}}if(a.append){let c=t.state.env.get(`${e}_${l}`)??"";t.state.env.set(`${e}_${l}`,c+a.value)}else t.state.env.set(`${e}_${l}`,a.value);o=l+1}else for(let l of a.values)t.state.env.set(`${e}_${o++}`,l)}async function YV(t,e,n,r,s){let i=[];for(let a of n){let l=await $r(t,a);i.push(...l.values)}let o=0;if(r){let a=xe(t,e);if(a.length>0)o=Math.max(...a.map(([c])=>typeof c=="number"?c:0))+1;else{let l=t.state.env.get(e);l!==void 0&&(t.state.env.set(`${e}_0`,l),t.state.env.delete(e),o=1)}}else s();for(let a=0;a<i.length;a++)t.state.env.set(`${e}_${o+a}`,i[a]);r||t.state.env.set(`${e}__length`,String(i.length))}async function QV(t,e,n,r,s,i,o){let a=n;if(pt(t,n)){let f=Un(t,n);if(f&&f!==n){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:K("",`bash: \`${f}': not a valid identifier
2059
+ `,1)};a=f}}if(vs(t,a)){if(e.name)return{continueToNext:!0,xtraceOutput:""};let f=nn(t,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let l=t.state.associativeArrays?.has(a),c;if(l)c=await JN(t,a,r);else{let f=await XV(t,a,r);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};c=`${a}_${f.index}`}let u=i?(t.state.env.get(c)||"")+s:s;if(e.name)o.set(c,t.state.env.get(c)),t.state.env.set(c,u);else{let f=Sa(t,a);if(f!==void 0&&f===t.state.callDepth&&t.state.localScopes.length>0){let h=t.state.localScopes[t.state.localScopes.length-1];h.has(c)||h.set(c,t.state.env.get(c))}t.state.env.set(c,u)}return{continueToNext:!0,xtraceOutput:""}}async function JN(t,e,n){let r;if(n.startsWith("'")&&n.endsWith("'"))r=n.slice(1,-1);else if(n.startsWith('"')&&n.endsWith('"')){let s=n.slice(1,-1),o=new Ne().parseWordFromString(s,!0,!1);r=await ge(t,o)}else if(n.includes("$")){let i=new Ne().parseWordFromString(n,!1,!1);r=await ge(t,i)}else r=n;return`${e}_${r}`}async function XV(t,e,n){let r=n;n.startsWith('"')&&n.endsWith('"')&&n.length>=2&&(r=n.slice(1,-1));let s;if(/^-?\d+$/.test(r))s=Number.parseInt(r,10);else{try{let i=new Ne,o=Ge(i,r);s=await fe(t,o.expression,!1)}catch(i){if(i instanceof lt){let l=`bash: line ${t.state.currentLine}: ${n}: ${i.message}
2060
2060
  `;if(i.fatal)throw new Re(1,"",l);return{index:0,error:K("",l,1)}}let o=t.state.env.get(n);s=o?Number.parseInt(o,10):0}Number.isNaN(s)&&(s=0)}if(s<0){let i=xe(t,e);if(i.length===0){let a=t.state.currentLine;return{index:0,error:K("",`bash: line ${a}: ${e}[${n}]: bad array subscript
2061
2061
  `,1)}}if(s=Math.max(...i.map(([a])=>typeof a=="number"?a:0))+1+s,s<0){let a=t.state.currentLine;return{index:0,error:K("",`bash: line ${a}: ${e}[${n}]: bad array subscript
2062
2062
  `,1)}}}return{index:s}}async function JV(t,e,n,r,s,i){let o="",a=n,l=null;if(pt(t,n)){let f=EC(t,n,r);if(f===void 0)return{continueToNext:!1,xtraceOutput:"",error:K("",`bash: ${n}: circular name reference
2063
2063
  `,1)};if(f===null)return{continueToNext:!0,xtraceOutput:""};a=f;let h=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);h&&(l={arrayName:h[1],subscriptExpr:h[2]},a=h[1])}if(vs(t,a)){if(e.name)return o+=`bash: ${a}: readonly variable
2064
- `,{continueToNext:!0,xtraceOutput:o};let f=nn(t,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(ac(t,a))try{let f=new Ne;if(s){let d=`(${t.state.env.get(a)||"0"}) + (${r})`,p=Ve(f,d);c=String(await fe(t,p.expression))}else{let h=Ve(f,r);c=String(await fe(t,h.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(Wn(),tw)),h=f(t,a)?`${a}_0`:a;c=s?(t.state.env.get(h)||"")+r:r}c=Ca(t,a,c),o+=await YN(t,a,c);let u=a;if(l)u=await eG(t,l);else{let{isArray:f}=await Promise.resolve().then(()=>(Wn(),tw));f(t,a)&&(u=`${a}_0`)}return e.name?(i.set(u,t.state.env.get(u)),t.state.env.set(u,c)):(t.state.env.set(u,c),t.state.options.allexport&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(a)),t.state.tempEnvBindings?.some(f=>f.has(a))&&(t.state.mutatedTempEnvVars=t.state.mutatedTempEnvVars||new Set,t.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function eG(t,e){let{arrayName:n,subscriptExpr:r}=e;if(t.state.associativeArrays?.has(n))return JN(t,n,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new Ne,a=Ve(o,r);i=await fe(t,a.expression,!1)}catch{let o=t.state.env.get(r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=xe(t,n);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${n}_${i}`}Bt();Me();Wn();$n();async function eT(t,e,n,r){let s=await Ns(t,e.redirections);if(s)return s;let i=new Map(t.state.env),o=t.state.cwd,a={...t.state.options},l=new Map(t.state.functions),c=t.state.localScopes,u=t.state.localVarStack,f=t.state.localVarDepth,h=t.state.fullyUnsetLocals;if(t.state.localScopes=c.map(P=>new Map(P)),u){t.state.localVarStack=new Map;for(let[P,$]of u.entries())t.state.localVarStack.set(P,$.map(O=>({...O})))}f&&(t.state.localVarDepth=new Map(f)),h&&(t.state.fullyUnsetLocals=new Map(h));let d=t.state.loopDepth,p=t.state.parentHasLoopContext;t.state.parentHasLoopContext=d>0,t.state.loopDepth=0;let m=t.state.lastArg,g=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let y=t.state.groupStdin;n&&(t.state.groupStdin=n);let w="",b="",E=0,A=()=>{t.state.env=i,t.state.cwd=o,t.state.options=a,t.state.functions=l,t.state.localScopes=c,t.state.localVarStack=u,t.state.localVarDepth=f,t.state.fullyUnsetLocals=h,t.state.loopDepth=d,t.state.parentHasLoopContext=p,t.state.groupStdin=y,t.state.bashPid=g,t.state.lastArg=m};try{for(let P of e.body){let $=await r(P);w+=$.stdout,b+=$.stderr,E=$.exitCode}}catch(P){if(A(),P instanceof ie)throw P;if(P instanceof ls){w+=P.stdout,b+=P.stderr;let O=K(w,b,0);return Pt(t,O,e.redirections)}if(P instanceof Nn||P instanceof Tn){w+=P.stdout,b+=P.stderr;let O=K(w,b,0);return Pt(t,O,e.redirections)}if(P instanceof Re){w+=P.stdout,b+=P.stderr;let O=K(w,b,P.exitCode);return Pt(t,O,e.redirections)}if(P instanceof pn){w+=P.stdout,b+=P.stderr;let O=K(w,b,P.exitCode);return Pt(t,O,e.redirections)}if(P instanceof Hn){let O=K(w+P.stdout,b+P.stderr,P.exitCode);return Pt(t,O,e.redirections)}let $=K(w,`${b}${ct(P)}
2064
+ `,{continueToNext:!0,xtraceOutput:o};let f=nn(t,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(ac(t,a))try{let f=new Ne;if(s){let d=`(${t.state.env.get(a)||"0"}) + (${r})`,p=Ge(f,d);c=String(await fe(t,p.expression))}else{let h=Ge(f,r);c=String(await fe(t,h.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(Wn(),tw)),h=f(t,a)?`${a}_0`:a;c=s?(t.state.env.get(h)||"")+r:r}c=Ca(t,a,c),o+=await YN(t,a,c);let u=a;if(l)u=await eG(t,l);else{let{isArray:f}=await Promise.resolve().then(()=>(Wn(),tw));f(t,a)&&(u=`${a}_0`)}return e.name?(i.set(u,t.state.env.get(u)),t.state.env.set(u,c)):(t.state.env.set(u,c),t.state.options.allexport&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(a)),t.state.tempEnvBindings?.some(f=>f.has(a))&&(t.state.mutatedTempEnvVars=t.state.mutatedTempEnvVars||new Set,t.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function eG(t,e){let{arrayName:n,subscriptExpr:r}=e;if(t.state.associativeArrays?.has(n))return JN(t,n,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new Ne,a=Ge(o,r);i=await fe(t,a.expression,!1)}catch{let o=t.state.env.get(r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=xe(t,n);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${n}_${i}`}Bt();Me();Wn();$n();async function eT(t,e,n,r){let s=await Ns(t,e.redirections);if(s)return s;let i=new Map(t.state.env),o=t.state.cwd,a={...t.state.options},l=new Map(t.state.functions),c=t.state.localScopes,u=t.state.localVarStack,f=t.state.localVarDepth,h=t.state.fullyUnsetLocals;if(t.state.localScopes=c.map(P=>new Map(P)),u){t.state.localVarStack=new Map;for(let[P,$]of u.entries())t.state.localVarStack.set(P,$.map(O=>({...O})))}f&&(t.state.localVarDepth=new Map(f)),h&&(t.state.fullyUnsetLocals=new Map(h));let d=t.state.loopDepth,p=t.state.parentHasLoopContext;t.state.parentHasLoopContext=d>0,t.state.loopDepth=0;let m=t.state.lastArg,g=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let y=t.state.groupStdin;n&&(t.state.groupStdin=n);let w="",b="",E=0,A=()=>{t.state.env=i,t.state.cwd=o,t.state.options=a,t.state.functions=l,t.state.localScopes=c,t.state.localVarStack=u,t.state.localVarDepth=f,t.state.fullyUnsetLocals=h,t.state.loopDepth=d,t.state.parentHasLoopContext=p,t.state.groupStdin=y,t.state.bashPid=g,t.state.lastArg=m};try{for(let P of e.body){let $=await r(P);w+=$.stdout,b+=$.stderr,E=$.exitCode}}catch(P){if(A(),P instanceof ie)throw P;if(P instanceof cs){w+=P.stdout,b+=P.stderr;let O=K(w,b,0);return Pt(t,O,e.redirections)}if(P instanceof Nn||P instanceof Tn){w+=P.stdout,b+=P.stderr;let O=K(w,b,0);return Pt(t,O,e.redirections)}if(P instanceof Re){w+=P.stdout,b+=P.stderr;let O=K(w,b,P.exitCode);return Pt(t,O,e.redirections)}if(P instanceof pn){w+=P.stdout,b+=P.stderr;let O=K(w,b,P.exitCode);return Pt(t,O,e.redirections)}if(P instanceof Hn){let O=K(w+P.stdout,b+P.stderr,P.exitCode);return Pt(t,O,e.redirections)}let $=K(w,`${b}${ct(P)}
2065
2065
  `,1);return Pt(t,$,e.redirections)}A();let C=K(w,b,E);return Pt(t,C,e.redirections)}async function tT(t,e,n,r){let s="",i="",o=0,a=await qh(t,e.redirections);if(a)return a;let l=n;for(let f of e.redirections)if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let h=f.target,d=await ge(t,h.content);h.stripTabs&&(d=d.split(`
2066
2066
  `).map(m=>m.replace(/^\t+/,"")).join(`
2067
2067
  `));let p=f.fd??0;p!==0?(t.state.fileDescriptors||(t.state.fileDescriptors=new Map),In(t),t.state.fileDescriptors.set(p,d)):l=d}else if(f.operator==="<<<"&&f.target.type==="Word")l=`${await ge(t,f.target)}
@@ -2071,39 +2071,39 @@ sys 0m0.000s
2071
2071
  `,127)}if(i.startsWith("#!")){let g=i.indexOf(`
2072
2072
  `);g!==-1&&(i=i.slice(g+1))}let o=new Map(t.state.env),a=t.state.cwd,l={...t.state.options},c=t.state.loopDepth,u=t.state.parentHasLoopContext,f=t.state.lastArg,h=t.state.bashPid,d=t.state.groupStdin,p=t.state.currentSource;t.state.parentHasLoopContext=c>0,t.state.loopDepth=0,t.state.bashPid=t.state.nextVirtualPid++,r&&(t.state.groupStdin=r),t.state.currentSource=e,t.state.env.set("0",e),t.state.env.set("#",String(n.length)),t.state.env.set("@",n.join(" ")),t.state.env.set("*",n.join(" "));for(let g=0;g<n.length&&g<9;g++)t.state.env.set(String(g+1),n[g]);for(let g=n.length+1;g<=9;g++)t.state.env.delete(String(g));let m=()=>{t.state.env=o,t.state.cwd=a,t.state.options=l,t.state.loopDepth=c,t.state.parentHasLoopContext=u,t.state.lastArg=f,t.state.bashPid=h,t.state.groupStdin=d,t.state.currentSource=p};try{let y=new Ne().parse(i),w=await s(y);return m(),w}catch(g){if(m(),g instanceof Re||g instanceof ie)throw g;if(g.name==="ParseException")return V(`bash: ${e}: ${g.message}
2073
2073
  `);throw g}}function tG(t){let e=n=>{for(let r of n){if(r.type==="CommandSubstitution"||r.type==="DoubleQuoted"&&e(r.parts))return!0;if(r.type==="BraceExpansion"){for(let s of r.items)if(s.type==="Word"&&e(s.word.parts))return!0}}return!1};return e(t.parts)}var fc=class{ctx;constructor(e,n){this.ctx={state:n,fs:e.fs,commands:e.commands,limits:e.limits,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep,trace:e.trace,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext??!1,jsBootstrapCode:e.jsBootstrapCode,invokeTool:e.invokeTool}}assertDefenseContext(e){if(!this.ctx.requireDefenseContext||tt.isInSandboxedContext())return;let n=`interpreter ${e} attempted outside defense context`;throw new Se(n,{timestamp:Date.now(),type:"missing_defense_context",message:n,path:"DefenseInDepthBox.context",stack:new Error().stack,executionId:tt.getCurrentExecutionId()})}buildExportedEnv(){let e=this.ctx.state.exportedVars,n=this.ctx.state.tempExportedVars,r=new Set;if(e)for(let i of e)r.add(i);if(n)for(let i of n)r.add(i);if(r.size===0)return Object.create(null);let s=Object.create(null);for(let i of r){let o=this.ctx.state.env.get(i);o!==void 0&&(s[i]=o)}return s}async executeScript(e){this.assertDefenseContext("execution");let n="",r="",s=0,i=this.ctx.limits.maxOutputSize,o=(a,l)=>{n.length+r.length+a.length+l.length>i&&Cs(`total output size exceeded (>${i} bytes), increase executionLimits.maxOutputSize`,"output_size"),n+=a,r+=l};for(let a of e.statements)try{let l=await this.executeStatement(a);o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}catch(l){if(l instanceof Re)throw l.prependOutput(n,r),l;if(l instanceof ar)return o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:qt(this.ctx.state.env)};if(l instanceof ie)throw l;if(l instanceof Hn)return o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:qt(this.ctx.state.env)};if(l instanceof Pn)return o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:qt(this.ctx.state.env)};if(l instanceof Rn)return o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:qt(this.ctx.state.env)};if(l instanceof lt){o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(l instanceof bo){o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(l instanceof Nn||l instanceof Tn){if(this.ctx.state.loopDepth>0)throw l.prependOutput(n,r),l;o(l.stdout,l.stderr);continue}throw l instanceof pn&&l.prependOutput(n,r),l}return{stdout:n,stderr:r,exitCode:s,env:qt(this.ctx.state.env)}}async executeUserScript(e,n,r=""){return nT(this.ctx,e,n,r,s=>this.executeScript(s))}async executeStatement(e){if(this.assertDefenseContext("statement"),this.ctx.state.signal?.aborted)throw new Eo;if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Cs(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),e.deferredError)throw new un(e.deferredError.message,e.line??1,1);if(this.ctx.state.options.noexec)return De;this.ctx.state.errexitSafe=!1;let n="",r="";this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&e.sourceText&&(r+=`${e.sourceText}
2074
- `);let s=0,i=-1,o=!1;for(let c=0;c<e.pipelines.length;c++){let u=e.pipelines[c],f=c>0?e.operators[c-1]:null;if(f==="&&"&&s!==0||f==="||"&&s===0)continue;let h=await this.executePipeline(u);n+=h.stdout,r+=h.stderr,s=h.exitCode,i=c,o=u.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}let a=i<e.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||l,this.ctx.state.options.errexit&&s!==0&&i===e.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!l)throw new Hn(s,n,r);return K(n,r,s)}async executePipeline(e){return QN(this.ctx,e,(n,r)=>this.executeCommand(n,r))}async executeCommand(e,n){switch(this.assertDefenseContext("command"),this.ctx.coverage?.hit(`bash:cmd:${e.type}`),e.type){case"SimpleCommand":return this.executeSimpleCommand(e,n);case"If":return UN(this.ctx,e);case"For":return zN(this.ctx,e);case"CStyleFor":return WN(this.ctx,e);case"While":return jN(this.ctx,e,n);case"Until":return qN(this.ctx,e);case"Case":return HN(this.ctx,e);case"Subshell":return this.executeSubshell(e,n);case"Group":return this.executeGroup(e,n);case"FunctionDef":return aN(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return De}}async executeSimpleCommand(e,n){try{return await this.executeSimpleCommandInner(e,n)}catch(r){if(r instanceof as)return V(r.stderr);throw r}}async executeSimpleCommandInner(e,n){if(e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.shoptOptions.expand_aliases&&e.name){let C=e,P=100;for(;P>0;){let $=this.expandAlias(C);if($===C)break;C=$,P--}this.aliasExpansionStack.clear(),C!==e&&(e=C)}this.ctx.state.expansionStderr="";let r=await XN(this.ctx,e);if(r.error)return r.error;let s=r.tempAssignments,i=r.xtraceOutput;if(!e.name){if(e.redirections.length>0){let P=await Ns(this.ctx,e.redirections);if(P)return P;let $=K("",i,0);return Pt(this.ctx,$,e.redirections)}this.ctx.state.lastArg="";let C=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",K("",C,this.ctx.state.lastExitCode)}let o=e.name&&Kw(e.name,["local","declare","typeset","export","readonly"]),a=Array.from(s.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let C of a)this.ctx.state.tempExportedVars.add(C)}let l=await qh(this.ctx,e.redirections);if(l){for(let[C,P]of s)P===void 0?this.ctx.state.env.delete(C):this.ctx.state.env.set(C,P);return l}let c=-1;for(let C of e.redirections){if((C.operator==="<<"||C.operator==="<<-")&&C.target.type==="HereDoc"){let P=C.target,$=await ge(this.ctx,P.content);P.stripTabs&&($=$.split(`
2074
+ `);let s=0,i=-1,o=!1;for(let c=0;c<e.pipelines.length;c++){let u=e.pipelines[c],f=c>0?e.operators[c-1]:null;if(f==="&&"&&s!==0||f==="||"&&s===0)continue;let h=await this.executePipeline(u);n+=h.stdout,r+=h.stderr,s=h.exitCode,i=c,o=u.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}let a=i<e.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||l,this.ctx.state.options.errexit&&s!==0&&i===e.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!l)throw new Hn(s,n,r);return K(n,r,s)}async executePipeline(e){return QN(this.ctx,e,(n,r)=>this.executeCommand(n,r))}async executeCommand(e,n){switch(this.assertDefenseContext("command"),this.ctx.coverage?.hit(`bash:cmd:${e.type}`),e.type){case"SimpleCommand":return this.executeSimpleCommand(e,n);case"If":return UN(this.ctx,e);case"For":return zN(this.ctx,e);case"CStyleFor":return WN(this.ctx,e);case"While":return jN(this.ctx,e,n);case"Until":return qN(this.ctx,e);case"Case":return HN(this.ctx,e);case"Subshell":return this.executeSubshell(e,n);case"Group":return this.executeGroup(e,n);case"FunctionDef":return aN(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return De}}async executeSimpleCommand(e,n){try{return await this.executeSimpleCommandInner(e,n)}catch(r){if(r instanceof ls)return V(r.stderr);throw r}}async executeSimpleCommandInner(e,n){if(e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.shoptOptions.expand_aliases&&e.name){let C=e,P=100;for(;P>0;){let $=this.expandAlias(C);if($===C)break;C=$,P--}this.aliasExpansionStack.clear(),C!==e&&(e=C)}this.ctx.state.expansionStderr="";let r=await XN(this.ctx,e);if(r.error)return r.error;let s=r.tempAssignments,i=r.xtraceOutput;if(!e.name){if(e.redirections.length>0){let P=await Ns(this.ctx,e.redirections);if(P)return P;let $=K("",i,0);return Pt(this.ctx,$,e.redirections)}this.ctx.state.lastArg="";let C=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",K("",C,this.ctx.state.lastExitCode)}let o=e.name&&Kw(e.name,["local","declare","typeset","export","readonly"]),a=Array.from(s.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let C of a)this.ctx.state.tempExportedVars.add(C)}let l=await qh(this.ctx,e.redirections);if(l){for(let[C,P]of s)P===void 0?this.ctx.state.env.delete(C):this.ctx.state.env.set(C,P);return l}let c=-1;for(let C of e.redirections){if((C.operator==="<<"||C.operator==="<<-")&&C.target.type==="HereDoc"){let P=C.target,$=await ge(this.ctx,P.content);P.stripTabs&&($=$.split(`
2075
2075
  `).map(R=>R.replace(/^\t+/,"")).join(`
2076
2076
  `)),$=Er($);let O=C.fd??0;O!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),In(this.ctx),this.ctx.state.fileDescriptors.set(O,$)):n=$;continue}if(C.operator==="<<<"&&C.target.type==="Word"){n=Er(`${await ge(this.ctx,C.target)}
2077
- `);continue}if(C.operator==="<"&&C.target.type==="Word")try{let P=await ge(this.ctx,C.target),$=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);n=await os(this.ctx.fs,$)}catch{let P=await ge(this.ctx,C.target);for(let[$,O]of s)O===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,O);return V(`bash: ${P}: No such file or directory
2077
+ `);continue}if(C.operator==="<"&&C.target.type==="Word")try{let P=await ge(this.ctx,C.target),$=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);n=await as(this.ctx.fs,$)}catch{let P=await ge(this.ctx,C.target);for(let[$,O]of s)O===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,O);return V(`bash: ${P}: No such file or directory
2078
2078
  `)}if(C.operator==="<&"&&C.target.type==="Word"){let P=await ge(this.ctx,C.target),$=Number.parseInt(P,10);if(!Number.isNaN($)&&this.ctx.state.fileDescriptors){let O=this.ctx.state.fileDescriptors.get($);if(O!==void 0)if(O.startsWith("__rw__:")){let R=VN(O);R&&(n=R.content.slice(R.position),c=$)}else O.startsWith("__file__:")||O.startsWith("__file_append__:")||(n=O)}}}let u=await $r(this.ctx,e.name),f=u.values.length===0,h=u.values[0]??"",d=u.values.slice(1),p=d.map(()=>u.quoted);if(Kw(e.name,["local","declare","typeset","export","readonly"])&&(h==="local"||h==="declare"||h==="typeset"||h==="export"||h==="readonly"))for(let C of e.args){let P=await qk(this.ctx,C);if(P)d.push(P),p.push(!0);else{let $=await Hk(this.ctx,C);if($!==null)d.push($),p.push(!0);else{let O=await $r(this.ctx,C);for(let R of O.values)d.push(R),p.push(O.quoted)}}}else for(let C of e.args){let P=await $r(this.ctx,C);for(let $ of P.values)d.push($),p.push(P.quoted)}if(!h){if(f){if(d.length>0){let P=d.shift();return p.shift(),await this.runCommand(P,d,p,n,!1,!1,c)}let C=tG(e.name)?this.ctx.state.lastExitCode:0;return K("","",C)}return V(`bash: : command not found
2079
2079
  `,127)}if(h==="exec"&&(d.length===0||d[0]==="--")){for(let C of e.redirections){if(C.target.type==="HereDoc"||C.fdVariable)continue;let P=await ge(this.ctx,C.target),$=C.fd??(C.operator==="<"||C.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),C.operator){case">":case">|":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);await this.ctx.fs.writeFile(O,"","utf8"),In(this.ctx),this.ctx.state.fileDescriptors.set($,`__file__:${O}`);break}case">>":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);In(this.ctx),this.ctx.state.fileDescriptors.set($,`__file_append__:${O}`);break}case"<":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);try{let R=await this.ctx.fs.readFile(O);In(this.ctx),this.ctx.state.fileDescriptors.set($,R)}catch{return V(`bash: ${P}: No such file or directory
2080
2080
  `)}break}case"<>":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,P);try{let R=await this.ctx.fs.readFile(O);In(this.ctx),this.ctx.state.fileDescriptors.set($,`__rw__:${O.length}:${O}:0:${R}`)}catch{await this.ctx.fs.writeFile(O,"","utf8"),In(this.ctx),this.ctx.state.fileDescriptors.set($,`__rw__:${O.length}:${O}:0:`)}break}case">&":{if(P==="-")this.ctx.state.fileDescriptors.delete($);else if(P.endsWith("-")){let O=P.slice(0,-1),R=Number.parseInt(O,10);if(!Number.isNaN(R)){let k=this.ctx.state.fileDescriptors.get(R);k!==void 0?this.ctx.state.fileDescriptors.set($,k):this.ctx.state.fileDescriptors.set($,`__dupout__:${R}`),this.ctx.state.fileDescriptors.delete(R)}}else{let O=Number.parseInt(P,10);Number.isNaN(O)||(In(this.ctx),this.ctx.state.fileDescriptors.set($,`__dupout__:${O}`))}break}case"<&":{if(P==="-")this.ctx.state.fileDescriptors.delete($);else if(P.endsWith("-")){let O=P.slice(0,-1),R=Number.parseInt(O,10);if(!Number.isNaN(R)){let k=this.ctx.state.fileDescriptors.get(R);k!==void 0?this.ctx.state.fileDescriptors.set($,k):this.ctx.state.fileDescriptors.set($,`__dupin__:${R}`),this.ctx.state.fileDescriptors.delete(R)}}else{let O=Number.parseInt(P,10);Number.isNaN(O)||(In(this.ctx),this.ctx.state.fileDescriptors.set($,`__dupin__:${O}`))}break}}}for(let[C,P]of s)P===void 0?this.ctx.state.env.delete(C):this.ctx.state.env.set(C,P);if(this.ctx.state.tempExportedVars)for(let C of s.keys())this.ctx.state.tempExportedVars.delete(C);return De}if(this.ctx.state.extraArgs){d.push(...this.ctx.state.extraArgs);for(let C=0;C<this.ctx.state.extraArgs.length;C++)p.push(!0);this.ctx.state.extraArgs=void 0}let g=await ZN(this.ctx,h,d);s.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(s)));let y,w=null;try{y=await this.runCommand(h,d,p,n,!1,!1,c)}catch(C){if(C instanceof Nn||C instanceof Tn)w=C,y=De;else throw C}let b=i+g;if(b&&(y={...y,stderr:b+y.stderr}),y=await Pt(this.ctx,y,e.redirections),w)throw w;if(d.length>0){let C=d[d.length-1];if((h==="declare"||h==="local"||h==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(C)){let P=C.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);P&&(C=P[1])}this.ctx.state.lastArg=C}else this.ctx.state.lastArg=h;let E=iN(h)&&h!=="unset"&&h!=="eval";if(!this.ctx.state.options.posix||!E)for(let[C,P]of s)this.ctx.state.fullyUnsetLocals?.has(C)||(P===void 0?this.ctx.state.env.delete(C):this.ctx.state.env.set(C,P));if(this.ctx.state.tempExportedVars)for(let C of s.keys())this.ctx.state.tempExportedVars.delete(C);return s.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(y={...y,stderr:this.ctx.state.expansionStderr+y.stderr},this.ctx.state.expansionStderr=""),y}async runCommand(e,n,r,s,i=!1,o=!1,a=-1){let l={ctx:this.ctx,runCommand:(u,f,h,d,p,m,g)=>this.runCommand(u,f,h,d,p,m,g),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(u,f,h)=>this.executeUserScript(u,f,h)},c=await MN(l,e,n,r,s,i,o,a);return c!==null?c:BN(l,e,n,s,o)}aliasExpansionStack=new Set;expandAlias(e){return _6(this.ctx.state,e,this.aliasExpansionStack)}async findCommandInPath(e){return Qh(this.ctx,e)}async executeSubshell(e,n=""){return eT(this.ctx,e,n,r=>this.executeStatement(r))}async executeGroup(e,n=""){return tT(this.ctx,e,n,r=>this.executeStatement(r))}async executeArithmeticCommand(e){e.line!==void 0&&(this.ctx.state.currentLine=e.line);let n=await Ns(this.ctx,e.redirections);if(n)return n;try{let r=await fe(this.ctx,e.expression.expression),s=Gt(r!==0);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),Pt(this.ctx,s,e.redirections)}catch(r){let s=V(`bash: arithmetic expression: ${r.message}
2081
2081
  `);return Pt(this.ctx,s,e.redirections)}}async executeConditionalCommand(e){e.line!==void 0&&(this.ctx.state.currentLine=e.line);let n=await Ns(this.ctx,e.redirections);if(n)return n;try{let r=await Ai(this.ctx,e.expression),s=Gt(r);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),Pt(this.ctx,s,e.redirections)}catch(r){let s=r instanceof lt?1:2,i=V(`bash: conditional expression: ${r.message}
2082
- `,s);return Pt(this.ctx,i,e.redirections)}}};var rn={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 rT(t){return t?{maxCallDepth:t.maxCallDepth??rn.maxCallDepth,maxCommandCount:t.maxCommandCount??rn.maxCommandCount,maxLoopIterations:t.maxLoopIterations??rn.maxLoopIterations,maxAwkIterations:t.maxAwkIterations??rn.maxAwkIterations,maxSedIterations:t.maxSedIterations??rn.maxSedIterations,maxJqIterations:t.maxJqIterations??rn.maxJqIterations,maxSqliteTimeoutMs:t.maxSqliteTimeoutMs??rn.maxSqliteTimeoutMs,maxPythonTimeoutMs:t.maxPythonTimeoutMs??rn.maxPythonTimeoutMs,maxJsTimeoutMs:t.maxJsTimeoutMs??rn.maxJsTimeoutMs,maxGlobOperations:t.maxGlobOperations??rn.maxGlobOperations,maxStringLength:t.maxStringLength??rn.maxStringLength,maxArrayElements:t.maxArrayElements??rn.maxArrayElements,maxHeredocSize:t.maxHeredocSize??rn.maxHeredocSize,maxSubstitutionDepth:t.maxSubstitutionDepth??rn.maxSubstitutionDepth,maxBraceExpansionResults:t.maxBraceExpansionResults??rn.maxBraceExpansionResults,maxOutputSize:t.maxOutputSize??rn.maxOutputSize,maxFileDescriptors:t.maxFileDescriptors??rn.maxFileDescriptors,maxSourceDepth:t.maxSourceDepth??rn.maxSourceDepth}:{...rn}}var hT=require("node:dns");en();is();function Zw(t){try{let e=new URL(t);return{origin:e.origin,pathname:e.pathname,href:e.href}}catch{return null}}function nG(t){let e=Zw(t);return e?{origin:e.origin,pathPrefix:e.pathname}:null}function sT(t){if(t.includes("\\"))return!0;let e=t.toLowerCase();return e.includes("%2f")||e.includes("%5c")}function rG(t,e){return e==="/"||e===""?!0:e.endsWith("/")?t.startsWith(e):t===e||t.startsWith(`${e}/`)}function Yw(t,e){let n=Zw(t);if(!n)return!1;let r=nG(e);return!r||n.origin!==r.origin||r.pathPrefix!=="/"&&r.pathPrefix!==""&&sT(n.pathname)?!1:rG(n.pathname,r.pathPrefix)}function iT(t){return typeof t=="string"?t:t.url}function oT(t,e){return!e||e.length===0?!1:e.some(n=>Yw(t,iT(n)))}function Qw(t){let e=sG(t);if(e==="localhost"||e.endsWith(".localhost"))return!0;let n=aT(e);if(n)return Jh(n);let r=oG(e);return r?aG(r):!1}function sG(t){let e=t.trim().toLowerCase();return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}function iG(t){if(!t)return null;let e=10,n=t;if(n.startsWith("0x")||n.startsWith("0X")?(e=16,n=n.slice(2)):n.length>1&&n.startsWith("0")&&(e=8),!n||e===16&&!/^[0-9a-fA-F]+$/.test(n)||e===10&&!/^\d+$/.test(n)||e===8&&!/^[0-7]+$/.test(n))return null;let r=Number.parseInt(n,e);return!Number.isFinite(r)||r<0?null:r}function aT(t){let e=t.split(".");if(e.length===0||e.length>4)return null;let n=e.map(l=>iG(l));if(n.some(l=>l===null))return null;let r=n;if(e.length===1){let l=r[0];return l>4294967295?null:[l>>>24&255,l>>>16&255,l>>>8&255,l&255]}if(e.length===2){let[l,c]=r;return l>255||c>16777215?null:[l,c>>>16&255,c>>>8&255,c&255]}if(e.length===3){let[l,c,u]=r;return l>255||c>255||u>65535?null:[l,c,u>>>8&255,u&255]}let[s,i,o,a]=r;return s>255||i>255||o>255||a>255?null:[s,i,o,a]}function oG(t){let e=t,n=null;if(e.includes(".")){let m=e.lastIndexOf(":");if(m<0)return null;let g=e.slice(m+1),y=aT(g);if(!y)return null;n=y,e=e.slice(0,m)}let r=e.includes("::")?e.split("::").length-1:0;if(r>1)return null;let[s,i]=e.split("::"),o=s?s.split(":").filter(Boolean):[],a=i?i.split(":").filter(Boolean):[],l=m=>/^[0-9a-f]{1,4}$/i.test(m)?Number.parseInt(m,16):null,c=o.map(l),u=a.map(l);if(c.some(m=>m===null)||u.some(m=>m===null))return null;let f=n?2:0,h=c.length+u.length+f,d=0;if(r===1){if(d=8-h,d<0)return null}else if(h!==8)return null;let p=[...c,...new Array(d).fill(0),...u];return n&&(p.push(n[0]<<8|n[1]),p.push(n[2]<<8|n[3])),p.length===8?p:null}function Jh(t){let[e,n]=t;return e===127||e===10||e===172&&n>=16&&n<=31||e===192&&n===168||e===169&&n===254||e===0||e===100&&n>=64&&n<=127||e===198&&(n===18||n===19)||e===192&&n===0&&t[2]===0||e===192&&n===0&&t[2]===2||e===198&&n===51&&t[2]===100||e===203&&n===0&&t[2]===113||e>=240}function aG(t){if(t.every(s=>s===0)||t.slice(0,7).every(s=>s===0)&&t[7]===1||(t[0]&65472)===65152||(t[0]&65024)===64512)return!0;if(t[0]===0&&t[1]===0&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===65535){let s=[t[6]>>>8&255,t[6]&255,t[7]>>>8&255,t[7]&255];return Jh(s)}if(t[0]===8193&&t[1]===3512)return!0;if(t[0]===100&&t[1]===65435&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===0){let s=[t[6]>>>8&255,t[6]&255,t[7]>>>8&255,t[7]&255];return Jh(s)}if(t[0]===100&&t[1]===65435&&t[2]===1)return!0;if(t[0]===8194){let s=[t[1]>>>8&255,t[1]&255,t[2]>>>8&255,t[2]&255];return Jh(s)}return!1}function lT(t){let e=[];for(let n of t){if(typeof n!="string"&&(n===null||typeof n!="object"||!("url"in n)||typeof n.url!="string")){e.push('Invalid allow-list entry: must be a string URL or an object with a "url" string property');continue}let r=iT(n);if(!Zw(r)){e.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:"){e.push(`Only http and https URLs are allowed in allow-list: "${r}"`);continue}if(!i.hostname){e.push(`Allow-list entry must include a hostname: "${r}"`);continue}if(i.pathname!=="/"&&i.pathname!==""&&sT(i.pathname)){e.push(`Allow-list entry contains ambiguous path separators: "${r}"`);continue}(i.search||i.hash)&&e.push(`Query strings and fragments are ignored in allow-list entries: "${r}"`)}return e}var lG=typeof __BROWSER__<"u"&&__BROWSER__,ka=null,ed=null,cT=!1;function cG(){if(ka===null&&!lG)try{let t=require("node:async_hooks");ed=require("node:dns"),ka=new t.AsyncLocalStorage}catch{}}function uG(){if(cT||(cG(),!ka||!ed))return;cT=!0;let t=ka,e=ed.lookup;function n(...r){let s=r[0],i=t.getStore();if(typeof s!="string"||!i||i.hostname.toLowerCase()!==s.toLowerCase())return e.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 e.apply(this,r);let l=a;if(o.family!==void 0&&o.family!==0&&o.family!==i.family){let c=new Error(`ENOTFOUND ${s}`);c.code="ENOTFOUND",c.errno=-3008,c.syscall="getaddrinfo",c.hostname=s,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(ed,"lookup",{value:n,writable:!0,configurable:!0})}function uT(t,e){return uG(),ka?ka.run(t,e):e()}var Fr=class extends Error{constructor(e,n){let r=n??"URL not in allow-list";super(`Network access denied: ${r}: ${e}`),this.name="NetworkAccessDeniedError"}},lo=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name="TooManyRedirectsError"}},co=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name="RedirectNotAllowedError"}},td=class extends Error{constructor(e,n){super(`HTTP method '${e}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}},Na=class extends Error{constructor(e){super(`Response body too large (max: ${e} bytes)`),this.name="ResponseTooLargeError"}};function fG(t){return new Promise((e,n)=>{(0,hT.lookup)(t,{all:!0},(r,s)=>{r?n(r):e(s)})})}var hG=20,dG=3e4,pG=10485760,mG=["GET","HEAD"],gG=new Set(["GET","HEAD","OPTIONS"]),yG=new Set([301,302,303,307,308]);function Xw(t){let e=t.allowedUrlPrefixes??[];if(!t.dangerouslyAllowFullInternetAccess){let d=lT(e);if(d.length>0)throw new Error(`Invalid network allow-list:
2082
+ `,s);return Pt(this.ctx,i,e.redirections)}}};var rn={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 rT(t){return t?{maxCallDepth:t.maxCallDepth??rn.maxCallDepth,maxCommandCount:t.maxCommandCount??rn.maxCommandCount,maxLoopIterations:t.maxLoopIterations??rn.maxLoopIterations,maxAwkIterations:t.maxAwkIterations??rn.maxAwkIterations,maxSedIterations:t.maxSedIterations??rn.maxSedIterations,maxJqIterations:t.maxJqIterations??rn.maxJqIterations,maxSqliteTimeoutMs:t.maxSqliteTimeoutMs??rn.maxSqliteTimeoutMs,maxPythonTimeoutMs:t.maxPythonTimeoutMs??rn.maxPythonTimeoutMs,maxJsTimeoutMs:t.maxJsTimeoutMs??rn.maxJsTimeoutMs,maxGlobOperations:t.maxGlobOperations??rn.maxGlobOperations,maxStringLength:t.maxStringLength??rn.maxStringLength,maxArrayElements:t.maxArrayElements??rn.maxArrayElements,maxHeredocSize:t.maxHeredocSize??rn.maxHeredocSize,maxSubstitutionDepth:t.maxSubstitutionDepth??rn.maxSubstitutionDepth,maxBraceExpansionResults:t.maxBraceExpansionResults??rn.maxBraceExpansionResults,maxOutputSize:t.maxOutputSize??rn.maxOutputSize,maxFileDescriptors:t.maxFileDescriptors??rn.maxFileDescriptors,maxSourceDepth:t.maxSourceDepth??rn.maxSourceDepth}:{...rn}}var hT=require("node:dns");en();os();function Zw(t){try{let e=new URL(t);return{origin:e.origin,pathname:e.pathname,href:e.href}}catch{return null}}function nG(t){let e=Zw(t);return e?{origin:e.origin,pathPrefix:e.pathname}:null}function sT(t){if(t.includes("\\"))return!0;let e=t.toLowerCase();return e.includes("%2f")||e.includes("%5c")}function rG(t,e){return e==="/"||e===""?!0:e.endsWith("/")?t.startsWith(e):t===e||t.startsWith(`${e}/`)}function Yw(t,e){let n=Zw(t);if(!n)return!1;let r=nG(e);return!r||n.origin!==r.origin||r.pathPrefix!=="/"&&r.pathPrefix!==""&&sT(n.pathname)?!1:rG(n.pathname,r.pathPrefix)}function iT(t){return typeof t=="string"?t:t.url}function oT(t,e){return!e||e.length===0?!1:e.some(n=>Yw(t,iT(n)))}function Qw(t){let e=sG(t);if(e==="localhost"||e.endsWith(".localhost"))return!0;let n=aT(e);if(n)return Jh(n);let r=oG(e);return r?aG(r):!1}function sG(t){let e=t.trim().toLowerCase();return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}function iG(t){if(!t)return null;let e=10,n=t;if(n.startsWith("0x")||n.startsWith("0X")?(e=16,n=n.slice(2)):n.length>1&&n.startsWith("0")&&(e=8),!n||e===16&&!/^[0-9a-fA-F]+$/.test(n)||e===10&&!/^\d+$/.test(n)||e===8&&!/^[0-7]+$/.test(n))return null;let r=Number.parseInt(n,e);return!Number.isFinite(r)||r<0?null:r}function aT(t){let e=t.split(".");if(e.length===0||e.length>4)return null;let n=e.map(l=>iG(l));if(n.some(l=>l===null))return null;let r=n;if(e.length===1){let l=r[0];return l>4294967295?null:[l>>>24&255,l>>>16&255,l>>>8&255,l&255]}if(e.length===2){let[l,c]=r;return l>255||c>16777215?null:[l,c>>>16&255,c>>>8&255,c&255]}if(e.length===3){let[l,c,u]=r;return l>255||c>255||u>65535?null:[l,c,u>>>8&255,u&255]}let[s,i,o,a]=r;return s>255||i>255||o>255||a>255?null:[s,i,o,a]}function oG(t){let e=t,n=null;if(e.includes(".")){let m=e.lastIndexOf(":");if(m<0)return null;let g=e.slice(m+1),y=aT(g);if(!y)return null;n=y,e=e.slice(0,m)}let r=e.includes("::")?e.split("::").length-1:0;if(r>1)return null;let[s,i]=e.split("::"),o=s?s.split(":").filter(Boolean):[],a=i?i.split(":").filter(Boolean):[],l=m=>/^[0-9a-f]{1,4}$/i.test(m)?Number.parseInt(m,16):null,c=o.map(l),u=a.map(l);if(c.some(m=>m===null)||u.some(m=>m===null))return null;let f=n?2:0,h=c.length+u.length+f,d=0;if(r===1){if(d=8-h,d<0)return null}else if(h!==8)return null;let p=[...c,...new Array(d).fill(0),...u];return n&&(p.push(n[0]<<8|n[1]),p.push(n[2]<<8|n[3])),p.length===8?p:null}function Jh(t){let[e,n]=t;return e===127||e===10||e===172&&n>=16&&n<=31||e===192&&n===168||e===169&&n===254||e===0||e===100&&n>=64&&n<=127||e===198&&(n===18||n===19)||e===192&&n===0&&t[2]===0||e===192&&n===0&&t[2]===2||e===198&&n===51&&t[2]===100||e===203&&n===0&&t[2]===113||e>=240}function aG(t){if(t.every(s=>s===0)||t.slice(0,7).every(s=>s===0)&&t[7]===1||(t[0]&65472)===65152||(t[0]&65024)===64512)return!0;if(t[0]===0&&t[1]===0&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===65535){let s=[t[6]>>>8&255,t[6]&255,t[7]>>>8&255,t[7]&255];return Jh(s)}if(t[0]===8193&&t[1]===3512)return!0;if(t[0]===100&&t[1]===65435&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===0){let s=[t[6]>>>8&255,t[6]&255,t[7]>>>8&255,t[7]&255];return Jh(s)}if(t[0]===100&&t[1]===65435&&t[2]===1)return!0;if(t[0]===8194){let s=[t[1]>>>8&255,t[1]&255,t[2]>>>8&255,t[2]&255];return Jh(s)}return!1}function lT(t){let e=[];for(let n of t){if(typeof n!="string"&&(n===null||typeof n!="object"||!("url"in n)||typeof n.url!="string")){e.push('Invalid allow-list entry: must be a string URL or an object with a "url" string property');continue}let r=iT(n);if(!Zw(r)){e.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:"){e.push(`Only http and https URLs are allowed in allow-list: "${r}"`);continue}if(!i.hostname){e.push(`Allow-list entry must include a hostname: "${r}"`);continue}if(i.pathname!=="/"&&i.pathname!==""&&sT(i.pathname)){e.push(`Allow-list entry contains ambiguous path separators: "${r}"`);continue}(i.search||i.hash)&&e.push(`Query strings and fragments are ignored in allow-list entries: "${r}"`)}return e}var lG=typeof __BROWSER__<"u"&&__BROWSER__,ka=null,ed=null,cT=!1;function cG(){if(ka===null&&!lG)try{let t=require("node:async_hooks");ed=require("node:dns"),ka=new t.AsyncLocalStorage}catch{}}function uG(){if(cT||(cG(),!ka||!ed))return;cT=!0;let t=ka,e=ed.lookup;function n(...r){let s=r[0],i=t.getStore();if(typeof s!="string"||!i||i.hostname.toLowerCase()!==s.toLowerCase())return e.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 e.apply(this,r);let l=a;if(o.family!==void 0&&o.family!==0&&o.family!==i.family){let c=new Error(`ENOTFOUND ${s}`);c.code="ENOTFOUND",c.errno=-3008,c.syscall="getaddrinfo",c.hostname=s,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(ed,"lookup",{value:n,writable:!0,configurable:!0})}function uT(t,e){return uG(),ka?ka.run(t,e):e()}var Fr=class extends Error{constructor(e,n){let r=n??"URL not in allow-list";super(`Network access denied: ${r}: ${e}`),this.name="NetworkAccessDeniedError"}},lo=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name="TooManyRedirectsError"}},co=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name="RedirectNotAllowedError"}},td=class extends Error{constructor(e,n){super(`HTTP method '${e}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}},Na=class extends Error{constructor(e){super(`Response body too large (max: ${e} bytes)`),this.name="ResponseTooLargeError"}};function fG(t){return new Promise((e,n)=>{(0,hT.lookup)(t,{all:!0},(r,s)=>{r?n(r):e(s)})})}var hG=20,dG=3e4,pG=10485760,mG=["GET","HEAD"],gG=new Set(["GET","HEAD","OPTIONS"]),yG=new Set([301,302,303,307,308]);function Xw(t){let e=t.allowedUrlPrefixes??[];if(!t.dangerouslyAllowFullInternetAccess){let d=lT(e);if(d.length>0)throw new Error(`Invalid network allow-list:
2083
2083
  ${d.join(`
2084
2084
  `)}`)}let n=[];for(let d of e)typeof d=="object"&&d.transform&&d.transform.length>0&&n.push(d);function r(d){if(n.length===0)return null;let p=null;for(let m of n)if(Yw(d,m.url)&&m.transform){p||(p=new Headers);for(let g of m.transform)for(let[y,w]of Object.entries(g.headers))p.set(y,w)}return p}let s=t.maxRedirects??hG,i=t.timeoutMs??dG,o=t.maxResponseSize??pG,a=t.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:t.allowedMethods??mG,l=t.denyPrivateRanges??(typeof process<"u"&&process.env?.NODE_ENV==="production"),c=t._dnsResolve??fG;async function u(d){if(!t.dangerouslyAllowFullInternetAccess&&!oT(d,e))throw new Fr(d);if(l)try{let p=new URL(d);if(Qw(p.hostname))throw new Fr(d,"private/loopback IP address blocked");let m=p.hostname;if(/[a-zA-Z]/.test(m))try{let y=await c(m);for(let{address:b}of y)if(Qw(b))throw new Fr(d,"hostname resolves to private/loopback IP address");let w=y[0];if(w)return{hostname:m,address:w.address,family:w.family===6?6:4}}catch(y){if(y instanceof Fr)throw y;let w=y?.code;if(!(w==="ENOTFOUND"||w==="ENODATA"))throw new Fr(d,"DNS resolution failed for private IP check")}}catch(p){if(p instanceof Fr)throw p}return null}function f(d){if(t.dangerouslyAllowFullInternetAccess)return;let p=d.toUpperCase();if(!a.includes(p))throw new td(p,a)}async function h(d,p={}){let m=p.method?.toUpperCase()??"GET",g=await u(d);f(m);let y=d,w=0,b=p.followRedirects??!0,E=p.timeoutMs!==void 0?Math.min(p.timeoutMs,i):i;for(;;){let A=new AbortController,C=sn(()=>A.abort(),E);try{let P=await tt.runTrustedAsync(()=>{let $=r(y),O=wG(p.headers,$),R={method:m,headers:O,signal:A.signal,redirect:"manual"};return p.body&&!gG.has(m)&&(R.body=p.body),g?uT(g,()=>fetch(y,R)):fetch(y,R)});if(yG.has(P.status)&&b){let $=P.headers.get("location");if(!$)return await fT(P,y,o);let O=new URL($,y).href;try{g=await u(O)}catch{throw new co(O)}if(w++,w>s)throw new lo(s);y=O;continue}return await fT(P,y,o)}finally{Dt(C)}}}return h}function wG(t,e){if(!t&&!e)return;if(!e)return t;let n=t instanceof Headers?new Headers(t):new Headers(t);for(let[r,s]of e)n.set(r,s);return n}async function fT(t,e,n){let r=Object.create(null);if(t.headers.forEach((i,o)=>{r[o.toLowerCase()]=i}),n>0){let i=t.headers.get("content-length");if(i){let o=parseInt(i,10);if(!Number.isNaN(o)&&o>n)throw new Na(n)}}let s;if(n>0&&t.body){let i=t.body.getReader(),o=[],a=0;for(;;){let{done:c,value:u}=await i.read();if(c)break;if(u){if(a+=u.byteLength,a>n)throw i.cancel(),new Na(n);o.push(u)}}s=new Uint8Array(a);let l=0;for(let c of o)s.set(c,l),l+=c.byteLength}else{let i=await t.arrayBuffer();if(n>0&&i.byteLength>n)throw new Na(n);s=new Uint8Array(i)}return{status:t.status,statusText:t.statusText,headers:r,body:s,url:e}}gi();Bt();en();function Ta(t){return fo(t)}function fo(t){return t.statements.map(dT).join(`
2085
2085
  `)}function dT(t){let e=[];for(let r=0;r<t.pipelines.length;r++)e.push(bG(t.pipelines[r])),r<t.operators.length&&e.push(t.operators[r]);let n=e.join(" ");return t.background&&(n+=" &"),n}function bG(t){let e=[];t.timed&&e.push(t.timePosix?"time -p":"time"),t.negated&&e.push("!");let n=[];for(let s=0;s<t.commands.length;s++)if(n.push(pT(t.commands[s])),s<t.commands.length-1){let i=t.pipeStderr?.[s];n.push(i?"|&":"|")}return(e.length>0?`${e.join(" ")} `:"")+n.join(" ")}function pT(t){switch(t.type){case"SimpleCommand":return EG(t);case"If":return OG(t);case"For":return IG(t);case"CStyleFor":return PG(t);case"While":return RG(t);case"Until":return $G(t);case"Case":return FG(t);case"Subshell":return DG(t);case"Group":return LG(t);case"ArithmeticCommand":return MG(t);case"ConditionalCommand":return BG(t);case"FunctionDef":return UG(t);default:{let e=t;throw new Error(`Unsupported command type: ${e.type}`)}}}function EG(t){let e=[];for(let n of t.assignments)e.push(xG(n));t.name&&e.push(fn(t.name));for(let n of t.args)e.push(fn(n));for(let n of t.redirections)e.push(yT(n));return e.join(" ")}function xG(t){let e=t.append?"+=":"=";if(t.array){let n=t.array.map(fn).join(" ");return`${t.name}${e}(${n})`}return t.value?`${t.name}${e}${fn(t.value)}`:`${t.name}${e}`}function fn(t){return t.parts.map(e=>nd(e,!1)).join("")}function ki(t){return t.parts.map(e=>nd(e,!0)).join("")}function nd(t,e){switch(t.type){case"Literal":return e?AG(t.value):SG(t.value);case"SingleQuoted":return`'${t.value}'`;case"DoubleQuoted":return`"${t.parts.map(n=>nd(n,!0)).join("")}"`;case"Escaped":return`\\${t.value}`;case"ParameterExpansion":return mT(t);case"CommandSubstitution":return t.legacy?`\`${fo(t.body)}\``:`$(${fo(t.body)})`;case"ArithmeticExpansion":return`$((${At(t.expression.expression)}))`;case"ProcessSubstitution":return t.direction==="input"?`<(${fo(t.body)})`:`>(${fo(t.body)})`;case"BraceExpansion":return NG(t);case"TildeExpansion":return t.user!==null?`~${t.user}`:"~";case"Glob":return t.pattern;default:{let n=t;throw new Error(`Unsupported word part type: ${n.type}`)}}}function SG(t){return t.replace(/[\s\\'"`!|&;()<>{}[\]*?~#]/g,"\\$&")}function AG(t){return t.replace(/[$`"\\]/g,"\\$&")}function vG(t,e){return t.parts.map(n=>CG(n,e)).join("")}function CG(t,e){switch(t.type){case"Literal":return e?t.value:t.value.replace(/[$`]/g,"\\$&");case"Escaped":return`\\${t.value}`;case"ParameterExpansion":return mT(t);case"CommandSubstitution":return t.legacy?`\`${fo(t.body)}\``:`$(${fo(t.body)})`;case"ArithmeticExpansion":return`$((${At(t.expression.expression)}))`;default:return nd(t,!1)}}function mT(t){return t.operation?`\${${gT(t.parameter,t.operation)}}`:kG(t.parameter)?`\${${t.parameter}}`:`$${t.parameter}`}function kG(t){return!(/^[?#@*$!\-0-9]$/.test(t)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))}function gT(t,e){switch(e.type){case"Length":return`#${t}`;case"LengthSliceError":return`#${t}:`;case"BadSubstitution":return e.text;case"DefaultValue":return`${t}${e.checkEmpty?":":""}-${ki(e.word)}`;case"AssignDefault":return`${t}${e.checkEmpty?":":""}=${ki(e.word)}`;case"ErrorIfUnset":return`${t}${e.checkEmpty?":":""}?${e.word?ki(e.word):""}`;case"UseAlternative":return`${t}${e.checkEmpty?":":""}+${ki(e.word)}`;case"Substring":{let n=At(e.offset.expression);return e.length?`${t}:${n}:${At(e.length.expression)}`:`${t}:${n}`}case"PatternRemoval":{let n=e.side==="prefix"?"#":"%",r=e.greedy?`${n}${n}`:n;return`${t}${r}${ki(e.pattern)}`}case"PatternReplacement":{let n="/";e.all?n="//":e.anchor==="start"?n="/#":e.anchor==="end"&&(n="/%");let r=e.replacement?`/${ki(e.replacement)}`:"";return`${t}${n}${ki(e.pattern)}${r}`}case"CaseModification":{let n=e.direction==="upper"?"^":",",r=e.all?`${n}${n}`:n,s=e.pattern?ki(e.pattern):"";return`${t}${r}${s}`}case"Transform":return`${t}@${e.operator}`;case"Indirection":return e.innerOp?`!${gT(t,e.innerOp)}`:`!${t}`;case"ArrayKeys":return`!${e.array}[${e.star?"*":"@"}]`;case"VarNamePrefix":return`!${e.prefix}${e.star?"*":"@"}`;default:{let n=e;throw new Error(`Unsupported parameter operation type: ${n.type}`)}}}function NG(t){return`{${t.items.map(TG).join(",")}}`}function TG(t){if(t.type==="Word")return fn(t.word);let e=t.startStr??String(t.start),n=t.endStr??String(t.end);return t.step!==void 0?`${e}..${n}..${t.step}`:`${e}..${n}`}function yT(t){let e=t.fdVariable?`{${t.fdVariable}}`:t.fd!==null?String(t.fd):"";if(t.operator==="<<"||t.operator==="<<-"){let n=t.target,r=n.quoted?`'${n.delimiter}'`:n.delimiter,s=vG(n.content,n.quoted);return`${e}${t.operator}${r}
2086
- ${s}${n.delimiter}`}return t.operator==="<<<"?`${e}<<< ${fn(t.target)}`:t.operator==="&>"||t.operator==="&>>"?`${t.operator} ${fn(t.target)}`:`${e}${t.operator} ${fn(t.target)}`}function ts(t){return t.length===0?"":` ${t.map(yT).join(" ")}`}function _r(t){return t.map(dT).join(`
2086
+ ${s}${n.delimiter}`}return t.operator==="<<<"?`${e}<<< ${fn(t.target)}`:t.operator==="&>"||t.operator==="&>>"?`${t.operator} ${fn(t.target)}`:`${e}${t.operator} ${fn(t.target)}`}function ns(t){return t.length===0?"":` ${t.map(yT).join(" ")}`}function _r(t){return t.map(dT).join(`
2087
2087
  `)}function OG(t){let e=[];for(let n=0;n<t.clauses.length;n++){let r=t.clauses[n],s=n===0?"if":"elif";e.push(`${s} ${_r(r.condition)}; then
2088
2088
  ${_r(r.body)}`)}return t.elseBody&&e.push(`else
2089
2089
  ${_r(t.elseBody)}`),`${e.join(`
2090
2090
  `)}
2091
- fi${ts(t.redirections)}`}function IG(t){let e;if(t.words===null)e=`for ${t.variable}`;else{let n=t.words.map(fn).join(" ");e=`for ${t.variable} in ${n}`}return`${e}; do
2091
+ fi${ns(t.redirections)}`}function IG(t){let e;if(t.words===null)e=`for ${t.variable}`;else{let n=t.words.map(fn).join(" ");e=`for ${t.variable} in ${n}`}return`${e}; do
2092
2092
  ${_r(t.body)}
2093
- done${ts(t.redirections)}`}function PG(t){let e=t.init?At(t.init.expression):"",n=t.condition?At(t.condition.expression):"",r=t.update?At(t.update.expression):"";return`for ((${e}; ${n}; ${r})); do
2093
+ done${ns(t.redirections)}`}function PG(t){let e=t.init?At(t.init.expression):"",n=t.condition?At(t.condition.expression):"",r=t.update?At(t.update.expression):"";return`for ((${e}; ${n}; ${r})); do
2094
2094
  ${_r(t.body)}
2095
- done${ts(t.redirections)}`}function RG(t){return`while ${_r(t.condition)}; do
2095
+ done${ns(t.redirections)}`}function RG(t){return`while ${_r(t.condition)}; do
2096
2096
  ${_r(t.body)}
2097
- done${ts(t.redirections)}`}function $G(t){return`until ${_r(t.condition)}; do
2097
+ done${ns(t.redirections)}`}function $G(t){return`until ${_r(t.condition)}; do
2098
2098
  ${_r(t.body)}
2099
- done${ts(t.redirections)}`}function FG(t){let e=t.items.map(_G).join(`
2099
+ done${ns(t.redirections)}`}function FG(t){let e=t.items.map(_G).join(`
2100
2100
  `);return`case ${fn(t.word)} in
2101
2101
  ${e}
2102
- esac${ts(t.redirections)}`}function _G(t){let e=t.patterns.map(fn).join(" | "),n=_r(t.body);return n?`${e})
2102
+ esac${ns(t.redirections)}`}function _G(t){let e=t.patterns.map(fn).join(" | "),n=_r(t.body);return n?`${e})
2103
2103
  ${n}
2104
2104
  ${t.terminator}`:`${e})
2105
- ${t.terminator}`}function DG(t){return`(${_r(t.body)})${ts(t.redirections)}`}function LG(t){return`{ ${_r(t.body)}; }${ts(t.redirections)}`}function MG(t){return`((${At(t.expression.expression)}))${ts(t.redirections)}`}function BG(t){return`[[ ${uo(t.expression)} ]]${ts(t.redirections)}`}function UG(t){let e=pT(t.body);return`${t.name}() ${e}${ts(t.redirections)}`}function At(t){switch(t.type){case"ArithNumber":return String(t.value);case"ArithVariable":return t.hasDollarPrefix?`$${t.name}`:t.name;case"ArithSpecialVar":return`$${t.name}`;case"ArithBinary":return`${At(t.left)} ${t.operator} ${At(t.right)}`;case"ArithUnary":return t.prefix?`${t.operator}${At(t.operand)}`:`${At(t.operand)}${t.operator}`;case"ArithTernary":return`${At(t.condition)} ? ${At(t.consequent)} : ${At(t.alternate)}`;case"ArithAssignment":return`${t.subscript?`${t.variable}[${At(t.subscript)}]`:t.stringKey!==void 0?`${t.variable}[${t.stringKey}]`:t.variable} ${t.operator} ${At(t.value)}`;case"ArithDynamicAssignment":return`${t.subscript?`${At(t.target)}[${At(t.subscript)}]`:At(t.target)} ${t.operator} ${At(t.value)}`;case"ArithDynamicElement":return`${At(t.nameExpr)}[${At(t.subscript)}]`;case"ArithGroup":return`(${At(t.expression)})`;case"ArithNested":return`$((${At(t.expression)}))`;case"ArithCommandSubst":return`$(${t.command})`;case"ArithBracedExpansion":return`\${${t.content}}`;case"ArithArrayElement":return t.stringKey!==void 0?`${t.array}[${t.stringKey}]`:t.index?`${t.array}[${At(t.index)}]`:t.array;case"ArithDynamicBase":return`\${${t.baseExpr}}#${t.value}`;case"ArithDynamicNumber":return`\${${t.prefix}}${t.suffix}`;case"ArithConcat":return t.parts.map(At).join("");case"ArithDoubleSubscript":return`${t.array}[${At(t.index)}]`;case"ArithNumberSubscript":return`${t.number}[${t.errorToken}]`;case"ArithSyntaxError":return t.errorToken;case"ArithSingleQuote":return`'${t.content}'`;default:{let e=t;throw new Error(`Unsupported arithmetic expression type: ${e.type}`)}}}function uo(t){switch(t.type){case"CondBinary":return`${fn(t.left)} ${t.operator} ${fn(t.right)}`;case"CondUnary":return`${t.operator} ${fn(t.operand)}`;case"CondNot":return`! ${uo(t.operand)}`;case"CondAnd":return`${uo(t.left)} && ${uo(t.right)}`;case"CondOr":return`${uo(t.left)} || ${uo(t.right)}`;case"CondGroup":return`( ${uo(t.expression)} )`;case"CondWord":return fn(t.word);default:{let e=t;throw new Error(`Unsupported conditional expression type: ${e.type}`)}}}var Oa=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(e={}){let n=e.fs??new Es(e.files);this.fs=n,this.useDefaultLayout=!e.cwd&&!e.files;let r=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
2106
- `],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(e.env??{})]);if(this.limits=rT({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=Xw(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(e.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",f6(this.state.options)),this.state.env.set("BASHOPTS",h6(this.state.shoptOptions)),mv(n,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&n instanceof Es)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let o of sv(e.commands))this.registerCommand(o);if(e.fetch||e.network)for(let o of iv())this.registerCommand(o);if(e.python)for(let o of av())this.registerCommand(o);let i=typeof e.javascript=="object"?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let o of cv())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let o of e.customCommands)uv(o)?this.registerCommand(hv(o)):this.registerCommand({...o,trusted:o.trusted??!0})}registerCommand(e){this.commands.set(e.name,e);let n=this.fs;if(typeof n.writeFileSync=="function"){let r=`#!/bin/bash
2105
+ ${t.terminator}`}function DG(t){return`(${_r(t.body)})${ns(t.redirections)}`}function LG(t){return`{ ${_r(t.body)}; }${ns(t.redirections)}`}function MG(t){return`((${At(t.expression.expression)}))${ns(t.redirections)}`}function BG(t){return`[[ ${uo(t.expression)} ]]${ns(t.redirections)}`}function UG(t){let e=pT(t.body);return`${t.name}() ${e}${ns(t.redirections)}`}function At(t){switch(t.type){case"ArithNumber":return String(t.value);case"ArithVariable":return t.hasDollarPrefix?`$${t.name}`:t.name;case"ArithSpecialVar":return`$${t.name}`;case"ArithBinary":return`${At(t.left)} ${t.operator} ${At(t.right)}`;case"ArithUnary":return t.prefix?`${t.operator}${At(t.operand)}`:`${At(t.operand)}${t.operator}`;case"ArithTernary":return`${At(t.condition)} ? ${At(t.consequent)} : ${At(t.alternate)}`;case"ArithAssignment":return`${t.subscript?`${t.variable}[${At(t.subscript)}]`:t.stringKey!==void 0?`${t.variable}[${t.stringKey}]`:t.variable} ${t.operator} ${At(t.value)}`;case"ArithDynamicAssignment":return`${t.subscript?`${At(t.target)}[${At(t.subscript)}]`:At(t.target)} ${t.operator} ${At(t.value)}`;case"ArithDynamicElement":return`${At(t.nameExpr)}[${At(t.subscript)}]`;case"ArithGroup":return`(${At(t.expression)})`;case"ArithNested":return`$((${At(t.expression)}))`;case"ArithCommandSubst":return`$(${t.command})`;case"ArithBracedExpansion":return`\${${t.content}}`;case"ArithArrayElement":return t.stringKey!==void 0?`${t.array}[${t.stringKey}]`:t.index?`${t.array}[${At(t.index)}]`:t.array;case"ArithDynamicBase":return`\${${t.baseExpr}}#${t.value}`;case"ArithDynamicNumber":return`\${${t.prefix}}${t.suffix}`;case"ArithConcat":return t.parts.map(At).join("");case"ArithDoubleSubscript":return`${t.array}[${At(t.index)}]`;case"ArithNumberSubscript":return`${t.number}[${t.errorToken}]`;case"ArithSyntaxError":return t.errorToken;case"ArithSingleQuote":return`'${t.content}'`;default:{let e=t;throw new Error(`Unsupported arithmetic expression type: ${e.type}`)}}}function uo(t){switch(t.type){case"CondBinary":return`${fn(t.left)} ${t.operator} ${fn(t.right)}`;case"CondUnary":return`${t.operator} ${fn(t.operand)}`;case"CondNot":return`! ${uo(t.operand)}`;case"CondAnd":return`${uo(t.left)} && ${uo(t.right)}`;case"CondOr":return`${uo(t.left)} || ${uo(t.right)}`;case"CondGroup":return`( ${uo(t.expression)} )`;case"CondWord":return fn(t.word);default:{let e=t;throw new Error(`Unsupported conditional expression type: ${e.type}`)}}}var Oa=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(e={}){let n=e.fs??new xs(e.files);this.fs=n,this.useDefaultLayout=!e.cwd&&!e.files;let r=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
2106
+ `],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(e.env??{})]);if(this.limits=rT({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=Xw(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(e.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",f6(this.state.options)),this.state.env.set("BASHOPTS",h6(this.state.shoptOptions)),mv(n,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&n instanceof xs)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let o of sv(e.commands))this.registerCommand(o);if(e.fetch||e.network)for(let o of iv())this.registerCommand(o);if(e.python)for(let o of av())this.registerCommand(o);let i=typeof e.javascript=="object"?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let o of cv())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let o of e.customCommands)uv(o)?this.registerCommand(hv(o)):this.registerCommand({...o,trusted:o.trusted??!0})}registerCommand(e){this.commands.set(e.name,e);let n=this.fs;if(typeof n.writeFileSync=="function"){let r=`#!/bin/bash
2107
2107
  # Built-in command: ${e.name}
2108
2108
  `;try{n.writeFileSync(`/bin/${e.name}`,r)}catch{}try{n.writeFileSync(`/usr/bin/${e.name}`,r)}catch{}}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug("stdout",{output:e.stdout}),e.stderr&&this.logger.info("stderr",{output:e.stderr}),this.logger.info("exit",{exitCode:e.exitCode})),e.stdout=bT(e.stdout),e.stderr=bT(e.stderr),e}async exec(e,n){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
2109
2109
  `,exitCode:1,env:Sr(this.state.env,n?.env)};if(!e.trim())return{stdout:"",stderr:"",exitCode:0,env:Sr(this.state.env,n?.env)};this.logger?.info("exec",{command:e});let r=n?.cwd??this.state.cwd,s,i=r;if(n?.cwd)if(n.env&&"PWD"in n.env)s=n.env.PWD;else if(n?.env&&!("PWD"in n.env))try{s=await this.fs.realpath(r),i=s}catch{s=r}else s=r;let o=n?.replaceEnv?new Map:new Map(this.state.env);if(n?.env)for(let[f,h]of Object.entries(n.env))o.set(f,h);s!==void 0&&o.set("PWD",s);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:WG(n?.stdin,n?.stdinKind),signal:n?.signal,extraArgs:n?.args},l=e;n?.rawScript||(l=wT(e));let c=this.defenseInDepthConfig?tt.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let h=Bn(l,{maxHeredocSize:this.limits.maxHeredocSize}),d;if(this.transformPlugins.length>0){let w=Object.create(null);for(let b of this.transformPlugins){let E=b.transform({ast:h,metadata:w});h=E.ast,E.metadata&&(w=Ps(w,E.metadata))}d=w}let p={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},y=await new fc(p,a).executeScript(h);return d&&(y.metadata=d),this.logResult(y)};return u?await u.run(f):await f()}catch(f){if(f instanceof Re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Sr(this.state.env,n?.env)});if(f instanceof ar)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Sr(this.state.env,n?.env)});if(f instanceof lt)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Sr(this.state.env,n?.env)});if(f instanceof Eo)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:Sr(this.state.env,n?.env)});if(f instanceof ie)return this.logResult({stdout:f.stdout,stderr:Fe(f.stderr),exitCode:ie.EXIT_CODE,env:Sr(this.state.env,n?.env)});if(f instanceof Se)return this.logResult({stdout:"",stderr:`bash: security violation: ${Fe(f.message)}
@@ -2112,7 +2112,7 @@ ${t.terminator}`}function DG(t){return`(${_r(t.body)})${ts(t.redirections)}`}fun
2112
2112
  `,exitCode:2,env:Sr(this.state.env,n?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${Fe(f.message)}
2113
2113
  `,exitCode:1,env:Sr(this.state.env,n?.env)});throw f}finally{u?.deactivate()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,n){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),n)}getCwd(){return this.state.cwd}getEnv(){return qt(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){let n=wT(e),r=Bn(n,{maxHeredocSize:this.limits.maxHeredocSize}),s=Object.create(null);for(let i of this.transformPlugins){let o=i.transform({ast:r,metadata:s});r=o.ast,o.metadata&&(s=Ps(s,o.metadata))}return{script:Ta(r),ast:r,metadata:s}}};function wT(t){let e=t.split(`
2114
2114
  `),n=[],r=[];for(let s=0;s<e.length;s++){let i=e[s];if(r.length>0){let l=r[r.length-1];if((l.stripTabs?i.replace(/^\t+/,""):i)===l.delimiter){n.push(i.trimStart()),r.pop();continue}n.push(i);continue}let o=i.trimStart();n.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 n.join(`
2115
- `)}var zG=new TextDecoder("utf-8",{fatal:!0});function bT(t){if(!t)return t;let e=!1;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);if(s>255)return t;s>127&&(e=!0)}if(!e)return t;let n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);try{return zG.decode(n)}catch{return t}}function WG(t,e){if(t!==void 0)return e==="bytes"?t:Er(t)}pe();pe();var hc=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new Es,e?.mounts)for(let{mountPoint:n,filesystem:r}of e.mounts)this.mount(n,r)}mount(e,n){this.validateMountPath(e);let r=he(e);this.validateMount(r),this.mounts.set(r,{mountPoint:r,filesystem:n})}unmount(e){let n=he(e);if(!this.mounts.has(n))throw new Error(`No filesystem mounted at '${e}'`);this.mounts.delete(n)}getMounts(){return Array.from(this.mounts.values()).map(e=>({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let n=he(e);return this.mounts.has(n)}validateMountPath(e){let n=e.split("/");for(let r of n)if(r==="."||r==="..")throw new Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e==="/")throw new Error("Cannot mount at root '/'");for(let n of this.mounts.keys())if(n!==e){if(e.startsWith(`${n}/`))throw new Error(`Cannot mount at '${e}': inside existing mount '${n}'`);if(n.startsWith(`${e}/`))throw new Error(`Cannot mount at '${e}': would contain existing mount '${n}'`)}}routePath(e){de(e,"access");let n=he(e),r=null,s=0;for(let i of this.mounts.values()){let o=i.mountPoint;if(n===o)return{fs:i.filesystem,relativePath:"/"};n.startsWith(`${o}/`)&&o.length>s&&(r=i,s=o.length)}if(r){let i=n.slice(s);return{fs:r.filesystem,relativePath:i||"/"}}return{fs:this.baseFs,relativePath:n}}getChildMountPoints(e){let n=he(e),r=n==="/"?"/":`${n}/`,s=[];for(let i of this.mounts.keys())if(i.startsWith(r)){let a=i.slice(r.length).split("/")[0];a&&!s.includes(a)&&s.push(a)}return s}async readFile(e,n){let{fs:r,relativePath:s}=this.routePath(e);return r.readFile(s,n)}async readFileBytes(e){let{fs:n,relativePath:r}=this.routePath(e);return os(n,r)}async readFileBuffer(e){let{fs:n,relativePath:r}=this.routePath(e);return n.readFileBuffer(r)}async writeFile(e,n,r){let{fs:s,relativePath:i}=this.routePath(e);return s.writeFile(i,n,r)}async appendFile(e,n,r){let{fs:s,relativePath:i}=this.routePath(e);return s.appendFile(i,n,r)}async exists(e){let n=he(e);if(this.mounts.has(n)||this.getChildMountPoints(n).length>0)return!0;let{fs:s,relativePath:i}=this.routePath(e);return s.exists(i)}async stat(e){let n=he(e),r=this.mounts.get(n);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(n).length>0)try{return await this.baseFs.stat(n)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.stat(o)}async lstat(e){let n=he(e),r=this.mounts.get(n);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(n).length>0)try{return await this.baseFs.lstat(n)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.lstat(o)}async mkdir(e,n){let r=he(e);if(this.mounts.has(r)){if(n?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(r).length>0&&n?.recursive)return;let{fs:i,relativePath:o}=this.routePath(e);return i.mkdir(o,n)}async readdir(e){let n=he(e),r=new Set,s=null,{fs:i,relativePath:o}=this.routePath(e);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;s=l}let a=this.getChildMountPoints(n);for(let l of a)r.add(l);if(r.size===0&&s&&!this.mounts.has(n))throw s;return Array.from(r).sort()}async rm(e,n){let r=he(e);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(r).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:i,relativePath:o}=this.routePath(e);return i.rm(o,n)}async cp(e,n,r){let s=this.routePath(e),i=this.routePath(n);return s.fs===i.fs?s.fs.cp(s.relativePath,i.relativePath,r):this.crossMountCopy(e,n,r)}async mv(e,n){let r=he(e);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot move '${e}'`);let s=this.routePath(e),i=this.routePath(n);if(s.fs===i.fs)return s.fs.mv(s.relativePath,i.relativePath);await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,n){return di(e,n)}getAllPaths(){let e=new Set;for(let n of this.baseFs.getAllPaths())e.add(n);for(let n of this.mounts.keys()){let r=n.split("/").filter(Boolean),s="";for(let o of r)s=`${s}/${o}`,e.add(s);let i=this.mounts.get(n);if(i)for(let o of i.filesystem.getAllPaths())o==="/"?e.add(n):e.add(`${n}${o}`)}return Array.from(e).sort()}async chmod(e,n){let r=he(e),s=this.mounts.get(r);if(s)return s.filesystem.chmod("/",n);let{fs:i,relativePath:o}=this.routePath(e);return i.chmod(o,n)}async symlink(e,n){let{fs:r,relativePath:s}=this.routePath(n);return r.symlink(e,s)}async link(e,n){let r=this.routePath(e),s=this.routePath(n);if(r.fs!==s.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${n}'`);return r.fs.link(r.relativePath,s.relativePath)}async readlink(e){let{fs:n,relativePath:r}=this.routePath(e);return n.readlink(r)}async realpath(e){let n=he(e);if(this.mounts.get(n))return n;let{fs:s,relativePath:i}=this.routePath(e),o=await s.realpath(i);for(let[a,l]of this.mounts)if(n===a||n.startsWith(`${a}/`))return o==="/"?a:`${a}${o}`;return o}async crossMountCopy(e,n,r){let s=await this.lstat(e);if(s.isFile){let i=await this.readFileBuffer(e);await this.writeFile(n,i),await this.chmod(n,s.mode)}else if(s.isDirectory){if(!r?.recursive)throw new Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(n,{recursive:!0});let i=await this.readdir(e);for(let o of i){let a=pi(e,o),l=pi(n,o);await this.crossMountCopy(a,l,r)}}else if(s.isSymbolicLink){let i=await this.readlink(e);await this.symlink(i,n)}}async utimes(e,n,r){let{fs:s,relativePath:i}=this.routePath(e);return s.utimes(i,n,r)}};var vt=Jt(require("node:fs"),1),An=Jt(require("node:path"),1);pe();la();var Dr=Jt(require("node:fs"),1),jn=Jt(require("node:path"),1);mn();function ns(t,e){if(t===e)return!0;let n=t[e.length];return(n==="/"||n==="\\")&&t.startsWith(e)}function ho(t,e){try{let n=Dr.realpathSync(t);return ns(n,e)?n:null}catch(n){if(n.code==="ENOENT"){let r=jn.dirname(t);if(r===t)return null;let s=ho(r,e);if(s===null)return null;try{if(Dr.lstatSync(t).isSymbolicLink()){let o=Dr.readlinkSync(t),a=jn.isAbsolute(o)?o:jn.resolve(jn.dirname(t),o);if(ho(a,e)===null)return null}}catch{}return jn.join(s,jn.basename(t))}return null}}function rd(t,e,n){let r=ho(t,n);if(r===null)return null;let s=jn.resolve(t),i=s.slice(e.length),o=r.slice(n.length);if(i!==o)return null;try{if(Dr.lstatSync(s).isSymbolicLink())return null}catch{}return r}function sd(t,e){if(!Dr.existsSync(t))throw new Error(`${e} root does not exist`);if(!Dr.statSync(t).isDirectory())throw new Error(`${e} root is not a directory`)}function ET(t,e){if(!jn.isAbsolute(t))return{withinRoot:!0,relativePath:t};let n;try{n=Dr.realpathSync(t)}catch{n=jn.resolve(t)}return ns(n,e)?{withinRoot:!0,relativePath:n.slice(e.length).replace(/\\/g,"/")||"/"}:{withinRoot:!1,safeName:jn.basename(t)}}function id(t,e,n,r){let s=t;if(s.path===void 0){for(let o of r)if(s.message?.includes(o))throw t}let i=s.code||"EIO";throw new Error(`${i}: ${n} '${e}'`)}var jG=["ELOOP","EFBIG","EPERM"],qG="/home/user/project",po=class{root;canonicalRoot;mountPoint;readOnly;maxFileReadSize;allowSymlinks;memory=new Map;deleted=new Set;constructor(e){this.root=An.resolve(e.root);let n=e.mountPoint??qG;if(this.mountPoint=n==="/"?"/":n.replace(/\/+$/,""),!this.mountPoint.startsWith("/"))throw new Error(`Mount point must be an absolute path: ${n}`);this.readOnly=e.readOnly??!1,this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,sd(this.root,"OverlayFs"),this.canonicalRoot=vt.realpathSync(this.root),this.createMountPointDirs()}assertWritable(e){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${e}`)}createMountPointDirs(){let e=this.mountPoint.split("/").filter(Boolean),n="";for(let r of e)n+=`/${r}`,this.memory.has(n)||this.memory.set(n,{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(e,n){let s=he(e).split("/").filter(Boolean),i="";for(let o of s)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(e,n){let r=he(e),s=this.getDirname(r);s!=="/"&&this.mkdirSync(s);let i=n instanceof Uint8Array?n:new TextEncoder().encode(n);this.memory.set(r,{type:"file",content:i,mode:420,mtime:new Date})}getDirname(e){let n=e.lastIndexOf("/");return n===0?"/":e.slice(0,n)}getRelativeToMount(e){return this.mountPoint==="/"?e:e===this.mountPoint?"/":e.startsWith(`${this.mountPoint}/`)?e.slice(this.mountPoint.length):null}toRealPath(e){let n=he(e),r=this.getRelativeToMount(n);if(r===null)return null;let s=An.join(this.root,r),i=An.resolve(s);return ns(i,this.root)?i:null}resolveRealPath_(e){return e?this.allowSymlinks?ho(e,this.canonicalRoot):rd(e,this.root,this.canonicalRoot):null}resolveRealPathParent_(e){if(!e)return null;let n=An.dirname(e),r=this.resolveRealPath_(n);return r===null?null:An.join(r,An.basename(e))}sanitizeError(e,n,r){id(e,n,r,jG)}ensureParentDirs(e){let n=eo(e);n!=="/"&&(this.memory.has(n)||(this.ensureParentDirs(n),this.memory.set(n,{type:"directory",mode:493,mtime:new Date})),this.deleted.delete(n))}async existsInOverlay(e){let n=he(e);if(this.deleted.has(n))return!1;if(this.memory.has(n))return!0;let r=this.resolveRealPathParent_(this.toRealPath(n));if(!r)return!1;try{return await vt.promises.lstat(r),!0}catch{return!1}}async readFile(e,n){let r=await this.readFileBuffer(e),s=Pr(n);return dr(r,s)}async readFileBytes(e){let n=await this.readFileBuffer(e);return dr(n,"binary")}async readFileBuffer(e,n=new Set){de(e,"open");let r=he(e);if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);if(n.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${e}'`);let s=this.memory.get(r);if(s){if(s.type==="symlink"){let o=this.resolveSymlink(r,s.target);return this.readFileBuffer(o,n)}if(s.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return s.content}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, open '${e}'`);try{let o=await vt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let c=await vt.promises.readlink(i),u=this.realTargetToVirtual(r,c),f=this.resolveSymlink(r,u);return this.readFileBuffer(f,n)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${o.size} bytes, max ${this.maxFileReadSize})`);let a=this.allowSymlinks?vt.constants.O_RDONLY:vt.constants.O_RDONLY|vt.constants.O_NOFOLLOW,l=await vt.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 '${e}'`);if(a==="ELOOP")throw new Error(`ENOENT: no such file or directory, open '${e}'`);this.sanitizeError(o,e,"open")}}async writeFile(e,n,r){de(e,"write"),this.assertWritable(`write '${e}'`);let s=he(e);this.ensureParentDirs(s);let i=Pr(r),o=Ms(n,i);this.memory.set(s,{type:"file",content:o,mode:420,mtime:new Date}),this.deleted.delete(s)}async appendFile(e,n,r){de(e,"append"),this.assertWritable(`append '${e}'`);let s=he(e),i=Pr(r),o=Ms(n,i),a;try{a=await this.readFileBuffer(s)}catch{a=new Uint8Array(0)}let l=new Uint8Array(a.length+o.length);l.set(a),l.set(o,a.length),this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:420,mtime:new Date}),this.deleted.delete(s)}async exists(e){return e.includes("\0")?!1:this.existsInOverlay(e)}async stat(e,n=new Set){de(e,"stat");let r=he(e);if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, stat '${e}'`);if(n.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=this.memory.get(r);if(s){if(s.type==="symlink"){let a=this.resolveSymlink(r,s.target);return this.stat(a,n)}let o=0;return s.type==="file"&&(o=s.content.length),{isFile:s.type==="file",isDirectory:s.type==="directory",isSymbolicLink:!1,mode:s.mode,size:o,mtime:s.mtime}}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);try{let o=await vt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let a=await vt.promises.readlink(i),l=this.realTargetToVirtual(r,a),c=this.resolveSymlink(r,l);return this.stat(c,n)}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 '${e}'`);this.sanitizeError(o,e,"stat")}}async lstat(e){de(e,"lstat");let n=he(e);if(this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let r=this.memory.get(n);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 s=this.resolveRealPathParent_(this.toRealPath(n));if(!s)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);try{let i=await vt.promises.lstat(s);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 '${e}'`);this.sanitizeError(i,e,"lstat")}}resolveSymlink(e,n){return ua(e,n)}realTargetToVirtual(e,n){let r=ET(n,this.canonicalRoot);if(r.withinRoot){if(!An.isAbsolute(n))return n;let s=r.relativePath;return this.mountPoint==="/"?s:`${this.mountPoint}${s}`}return r.safeName}async mkdir(e,n){de(e,"mkdir"),this.assertWritable(`mkdir '${e}'`);let r=he(e);if(await this.existsInOverlay(r)){if(!n?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${e}'`);return}let i=eo(r);if(i!=="/"&&!await this.existsInOverlay(i))if(n?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.memory.set(r,{type:"directory",mode:493,mtime:new Date}),this.deleted.delete(r)}async readdirCore(e,n){if(this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Map,s=new Set,i=n==="/"?"/":`${n}/`;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)&&s.add(c)}for(let[a,l]of this.memory)if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!s.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(n));if(o)try{if(!this.allowSymlinks&&(await vt.promises.lstat(o)).isSymbolicLink()){if(!this.memory.has(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);return r}let a=await vt.promises.readdir(o,{withFileTypes:!0});for(let l of a)!s.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(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`)}else a.code!=="ENOTDIR"&&this.sanitizeError(a,e,"scandir")}return r}async resolveForReaddir(e,n=!1){let r=he(e),s=new Set,i=n,o=this.memory.get(r);for(;o&&o.type==="symlink";){if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.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 vt.promises.lstat(l)).isSymbolicLink()){if(!this.allowSymlinks)return{normalized:r,outsideOverlay:!0};let u=await vt.promises.readlink(l),f=this.realTargetToVirtual(r,u),h=this.resolveSymlink(r,f);return this.resolveForReaddir(h,!0)}return{normalized:r,outsideOverlay:!1}}catch{return i?{normalized:r,outsideOverlay:!0}:{normalized:r,outsideOverlay:!1}}}async readdir(e){de(e,"scandir");let{normalized:n,outsideOverlay:r}=await this.resolveForReaddir(e);if(r)return[];let s=await this.readdirCore(e,n);return Array.from(s.keys()).sort((i,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(e){de(e,"scandir");let{normalized:n,outsideOverlay:r}=await this.resolveForReaddir(e);if(r)return[];let s=await this.readdirCore(e,n);return Array.from(s.values()).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(e,n){de(e,"rm"),this.assertWritable(`rm '${e}'`);let r=he(e);if(!await this.existsInOverlay(r)){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}try{if((await this.stat(r)).isDirectory){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let a of o){let l=r==="/"?`/${a}`:`${r}/${a}`;await this.rm(l,n)}}}}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(e){let n=this.toRealPath(e),r=this.resolveRealPathParent_(n);if(!r)return!1;try{return vt.lstatSync(r),!0}catch{return!1}}async cp(e,n,r){de(e,"cp"),de(n,"cp"),this.assertWritable(`cp '${n}'`);let s=he(e),i=he(n);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, cp '${e}'`);let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);await this.writeFile(i,l)}else if(a.isDirectory){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(s);for(let c of l){let u=s==="/"?`/${c}`:`${s}/${c}`,f=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(u,f,r)}}}async mv(e,n){this.assertWritable(`mv '${n}'`),await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,n){return di(e,n)}getAllPaths(){let e=new Set(this.memory.keys());for(let n of this.deleted)e.delete(n);return this.scanRealFs("/",e),Array.from(e)}scanRealFs(e,n){if(this.deleted.has(e))return;let r=this.resolveRealPath_(this.toRealPath(e));if(r)try{let s=vt.readdirSync(r);for(let i of s){let o=e==="/"?`/${i}`:`${e}/${i}`;if(this.deleted.has(o))continue;n.add(o);let a=An.join(r,i);vt.lstatSync(a).isDirectory()&&this.scanRealFs(o,n)}}catch{}}async chmod(e,n){de(e,"chmod"),this.assertWritable(`chmod '${e}'`);let r=he(e);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);let i=this.memory.get(r);if(i){i.mode=n;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:n,mtime:new Date})}else o.isDirectory&&this.memory.set(r,{type:"directory",mode:n,mtime:new Date})}async symlink(e,n){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${n}'`);de(n,"symlink"),this.assertWritable(`symlink '${n}'`);let r=he(n);if(await this.existsInOverlay(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.memory.set(r,{type:"symlink",target:e,mode:511,mtime:new Date}),this.deleted.delete(r)}async link(e,n){de(e,"link"),de(n,"link"),this.assertWritable(`link '${n}'`);let r=he(e),s=he(n);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, link '${e}'`);let o=await this.stat(r);if(!o.isFile)throw new Error(`EPERM: operation not permitted, link '${e}'`);if(await this.existsInOverlay(s))throw new Error(`EEXIST: file already exists, link '${n}'`);let l=await this.readFileBuffer(r);this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:o.mode,mtime:new Date}),this.deleted.delete(s)}async readlink(e){de(e,"readlink");let n=he(e);if(this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);let r=this.memory.get(n);if(r){if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}let s=this.resolveRealPathParent_(this.toRealPath(n));if(!s)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);try{let i=await vt.promises.readlink(s);if(!An.isAbsolute(i)){let o=An.resolve(An.dirname(s),i),a;try{a=vt.realpathSync(o)}catch{a=o}if(!ns(a,this.canonicalRoot))return An.basename(i)}return this.realTargetToVirtual(n,i)}catch(i){if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(i,e,"readlink")}}async realpath(e){de(e,"realpath");let n=he(e),r=new Set,s=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 '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let f=this.memory.get(c),h=0,d=40;for(;f&&f.type==="symlink"&&h<d;){if(r.add(c),c=this.resolveSymlink(c,f.target),h++,r.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);f=this.memory.get(c)}if(h>=d)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(!f){let p=this.toRealPath(c),m=this.resolveRealPath_(p);if(m)try{if((await vt.promises.lstat(m)).isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let y=await vt.promises.readlink(m),w=this.realTargetToVirtual(c,y);return r.add(c),c=this.resolveSymlink(c,w),s(c)}}catch(g){if(g.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(g,e,"realpath")}else if(!this.allowSymlinks){let g=this.resolveRealPathParent_(p);if(g)try{if((await vt.promises.lstat(g)).isSymbolicLink())throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}catch(y){if(y.message?.includes("ENOENT")||y.message?.includes("ELOOP"))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(y,e,"realpath")}}}}return c||"/"},i=await s(n);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return i}async utimes(e,n,r){de(e,"utimes"),this.assertWritable(`utimes '${e}'`);let s=he(e);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);let o=this.memory.get(s);if(o){o.mtime=r;return}let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);this.memory.set(s,{type:"file",content:l,mode:a.mode,mtime:r})}else a.isDirectory&&this.memory.set(s,{type:"directory",mode:a.mode,mtime:r})}};var me=Jt(require("node:fs"),1),yt=Jt(require("node:path"),1);pe();la();var HG=["EACCES","escaping sandbox","EFBIG"],dc=class{root;canonicalRoot;maxFileReadSize;allowSymlinks;constructor(e){this.root=yt.resolve(e.root),this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,sd(this.root,"ReadWriteFs"),this.canonicalRoot=me.realpathSync(this.root)}resolveAndValidate(e,n){let r=this.allowSymlinks?ho(e,this.canonicalRoot):rd(e,this.root,this.canonicalRoot);if(r===null)throw new Error(`EACCES: permission denied, '${n}' resolves outside sandbox`);return r}validateParent(e,n){let r=yt.dirname(e),s=this.resolveAndValidate(r,n);return yt.join(s,yt.basename(e))}toRealPath(e){let n=he(e),r=yt.join(this.root,n);return yt.resolve(r)}async readFile(e,n){let r=await this.readFileBuffer(e),s=Pr(n);return dr(r,s)}async readFileBytes(e){let n=await this.readFileBuffer(e);return dr(n,"binary")}async readFileBuffer(e){de(e,"open");let n=this.toRealPath(e),r=this.resolveAndValidate(n,e);try{let s=this.allowSymlinks?me.constants.O_RDONLY:me.constants.O_RDONLY|me.constants.O_NOFOLLOW,i=await me.promises.open(r,s);try{if(this.maxFileReadSize>0){let a=await i.stat();if(a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${a.size} bytes, max ${this.maxFileReadSize})`)}let o=await i.readFile();return new Uint8Array(o)}finally{await i.close()}}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(i.code==="EISDIR")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(i.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(s,e,"open")}}async writeFile(e,n,r){de(e,"write");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=Pr(r),a=Ms(n,o),l=yt.dirname(i);try{await me.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:me.constants.O_NOFOLLOW,u=me.constants.O_WRONLY|me.constants.O_CREAT|me.constants.O_TRUNC|c,f=await me.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, '${e}' is a symlink`);this.sanitizeError(c,e,"write")}}async appendFile(e,n,r){de(e,"append");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=Pr(r),a=Ms(n,o),l=yt.dirname(i);try{await me.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:me.constants.O_NOFOLLOW,u=me.constants.O_WRONLY|me.constants.O_CREAT|me.constants.O_APPEND|c,f=await me.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, '${e}' is a symlink`);this.sanitizeError(c,e,"append")}}async exists(e){if(e.includes("\0"))return!1;let n=this.toRealPath(e);try{let r=this.resolveAndValidate(n,e);return await me.promises.access(r),!0}catch{return!1}}async stat(e){de(e,"stat");let n=this.toRealPath(e),r=this.resolveAndValidate(n,e);try{let s=await me.promises.lstat(r);if(!this.allowSymlinks&&s.isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, stat '${e}'`);this.sanitizeError(s,e,"stat")}}async lstat(e){de(e,"lstat");let n=this.toRealPath(e),r=this.validateParent(n,e);try{let s=await me.promises.lstat(r);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);this.sanitizeError(s,e,"lstat")}}async mkdir(e,n){de(e,"mkdir");let r=this.toRealPath(e),s=this.resolveAndValidate(r,e);try{await me.promises.mkdir(s,{recursive:n?.recursive})}catch(i){let o=i;if(o.code==="EEXIST")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.sanitizeError(i,e,"mkdir")}}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){de(e,"scandir");let n=this.toRealPath(e),r=this.resolveAndValidate(n,e);try{if(!this.allowSymlinks&&(await me.promises.lstat(r)).isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return(await me.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(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(i.code==="ENOTDIR")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);this.sanitizeError(s,e,"scandir")}}async rm(e,n){de(e,"rm");let r=this.toRealPath(e),s=this.resolveAndValidate(r,e);try{await me.promises.rm(s,{recursive:n?.recursive??!1,force:n?.force??!1})}catch(i){let o=i;if(o.code==="ENOENT"&&!n?.force)throw new Error(`ENOENT: no such file or directory, rm '${e}'`);if(o.code==="ENOTEMPTY")throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);this.sanitizeError(i,e,"rm")}}async cp(e,n,r){de(e,"cp"),de(n,"cp");let s=this.toRealPath(e),i=this.toRealPath(n),o=this.resolveAndValidate(s,e),a=this.resolveAndValidate(i,n);try{await me.promises.cp(o,a,{recursive:r?.recursive??!1,filter:async l=>{try{if(me.lstatSync(l).isSymbolicLink()){let u=await me.promises.realpath(l).catch(()=>null);return u===null?!1:ns(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 '${e}'`);if(c.code==="EISDIR")throw new Error(`EISDIR: is a directory, cp '${e}'`);this.sanitizeError(l,e,"cp")}}async mv(e,n){de(e,"mv"),de(n,"mv");let r=this.toRealPath(e),s=this.toRealPath(n),i=this.validateParent(r,e),o=this.validateParent(s,n);try{if((await me.promises.lstat(i)).isSymbolicLink()){let c=await me.promises.readlink(i),u=yt.resolve(yt.dirname(o),c),f=await me.promises.realpath(u).catch(()=>u);if(!ns(f,this.canonicalRoot))throw new Error(`EACCES: permission denied, mv '${e}' -> '${n}' would create symlink escaping sandbox`)}}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.message?.includes("EACCES")||c.message?.includes("escaping sandbox"))throw l}let a=yt.dirname(o);try{await me.promises.mkdir(a,{recursive:!0})}catch(l){this.sanitizeError(l,n,"mv")}try{await me.promises.rename(i,o)}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.code==="EXDEV"){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0});return}this.sanitizeError(l,e,"mv")}try{if(me.lstatSync(o).isDirectory()&&this.findEscapingSymlinks(o).length>0)throw await me.promises.rename(o,i),new Error(`EACCES: permission denied, mv '${e}' -> '${n}' would create symlinks escaping sandbox`)}catch(l){if(l.message?.includes("EACCES")||l.message?.includes("escaping sandbox"))throw l}}resolvePath(e,n){return di(e,n)}getAllPaths(){let e=[];return this.scanDir("/",e),e}sanitizeError(e,n,r){id(e,n,r,HG)}findEscapingSymlinks(e){let n=[];try{let r=me.readdirSync(e);for(let s of r){let i=yt.join(e,s);try{let o=me.lstatSync(i);if(o.isSymbolicLink()){let a=me.readlinkSync(i),l=yt.resolve(e,a),c;try{c=me.realpathSync(l)}catch{c=l}ns(c,this.canonicalRoot)||n.push(i)}else o.isDirectory()&&n.push(...this.findEscapingSymlinks(i))}catch{}}}catch{}return n}scanDir(e,n){let r=this.toRealPath(e),s;try{s=this.resolveAndValidate(r,e)}catch{return}try{let i=me.readdirSync(s);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;n.push(a);let l=yt.join(s,o);me.lstatSync(l).isDirectory()&&this.scanDir(a,n)}}catch{}}async chmod(e,n){de(e,"chmod");let r=this.toRealPath(e),s=this.resolveAndValidate(r,e);try{let i=this.allowSymlinks?me.constants.O_RDONLY:me.constants.O_RDONLY|me.constants.O_NOFOLLOW,o=await me.promises.open(s,i);try{await o.chmod(n)}finally{await o.close()}}catch(i){let o=i;if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);if(o.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(i,e,"chmod")}}async symlink(e,n){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${n}'`);de(n,"symlink");let r=this.toRealPath(n),s=this.validateParent(r,n),i=he(n),o=he(yt.dirname(i)),a=e.startsWith("/")?he(e):he(o==="/"?`/${e}`:`${o}/${e}`),l=yt.join(this.canonicalRoot,a),c=yt.dirname(s),u=e.startsWith("/")?l:yt.relative(c,l)||".";try{await me.promises.symlink(u,s)}catch(f){if(f.code==="EEXIST")throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.sanitizeError(f,n,"symlink")}}async link(e,n){de(e,"link"),de(n,"link");let r=this.toRealPath(e),s=this.toRealPath(n),i=this.resolveAndValidate(r,e),o=this.resolveAndValidate(s,n);try{await me.promises.link(i,o)}catch(a){let l=a;if(l.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(l.code==="EEXIST")throw new Error(`EEXIST: file already exists, link '${n}'`);if(l.code==="EPERM")throw new Error(`EPERM: operation not permitted, link '${e}'`);this.sanitizeError(a,e,"link")}}async readlink(e){de(e,"readlink");let n=this.toRealPath(e),r=this.validateParent(n,e);try{let s=await me.promises.readlink(r),i=he(e),o=yt.dirname(i),a=yt.isAbsolute(s)?s:yt.resolve(yt.dirname(r),s),l=await me.promises.realpath(a).catch(()=>a);if(ns(l,this.canonicalRoot)){let c=l.slice(this.canonicalRoot.length)||"/";return o==="/"?c.startsWith("/")?c.slice(1)||".":c:yt.relative(o,c)}return yt.basename(s)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(s,e,"readlink")}}async realpath(e){de(e,"realpath");let n=this.toRealPath(e);try{this.resolveAndValidate(n,e)}catch{throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}let r;try{r=await me.promises.realpath(n)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);if(i.code==="ELOOP")throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);this.sanitizeError(s,e,"realpath")}if(ns(r,this.canonicalRoot))return r.slice(this.canonicalRoot.length)||"/";throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}async utimes(e,n,r){de(e,"utimes");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e);try{let o=this.allowSymlinks?me.constants.O_RDONLY:me.constants.O_RDONLY|me.constants.O_NOFOLLOW,a=await me.promises.open(i,o);try{await a.utimes(n,r)}finally{await a.close()}}catch(o){let a=o;if(a.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);if(a.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(o,e,"utimes")}}};Bt();Is();is();var mo=class{cmdId;cwd;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;signal;timeoutMs;abortController=new AbortController;timeoutId;externalAbortListener;resultPromise;constructor(e,n,r,s,i=!1,o,a){this.cmdId=crypto.randomUUID(),this.cwd=r,this.startedAt=new Date,this.bashEnv=e,this.cmdLine=n,this.env=s,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 e=Math.max(0,this.timeoutMs);this.timeoutId=sn(()=>{this.abortController.abort(new Error(`sandbox command timeout after ${e}ms`))},e)}}cleanupCancellation(){this.timeoutId!==void 0&&(Dt(this.timeoutId),this.timeoutId=void 0),this.signal&&this.externalAbortListener&&(this.signal.removeEventListener("abort",this.externalAbortListener),this.externalAbortListener=void 0)}async execute(){let e={cwd:this.explicitCwd?this.cwd:void 0,env:this.env,signal:this.abortController.signal};try{let n=await this.bashEnv.exec(this.cmdLine,e);return this.exitCode=n.exitCode,n}finally{this.cleanupCancellation()}}async*logs(){let e=await this.resultPromise;e.stdout&&(yield{type:"stdout",data:e.stdout,timestamp:new Date}),e.stderr&&(yield{type:"stderr",data:e.stderr,timestamp:new Date})}async wait(){return await this.resultPromise,this}async output(){let e=await this.resultPromise;return e.stdout+e.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 pc=class t{bashEnv;timeoutMs;constructor(e,n){this.bashEnv=e,this.timeoutMs=n}static async create(e){let n=e?.fs;if(e?.overlayRoot){if(e?.fs)throw new Error("Cannot specify both 'fs' and 'overlayRoot' options");n=new po({root:e.overlayRoot})}let r=new Oa({env:e?.env,cwd:e?.cwd,fs:n,maxCallDepth:e?.maxCallDepth,maxCommandCount:e?.maxCommandCount,maxLoopIterations:e?.maxLoopIterations,network:e?.network,defenseInDepth:e?.defenseInDepth});return new t(r,e?.timeoutMs)}async runCommand(e,n,r){let s,i,o,a,l=!1,c,u;if(typeof e=="object"){let m=e,g=[m.cmd,...m.args??[]];s=on(g),i=m.cwd,o=m.env,a=m.signal,l=m.detached??!1,c=m.stdout,u=m.stderr}else if(Array.isArray(n)){let m=r;s=on([e,...n]),a=m?.signal}else{s=e;let m=n;i=m?.cwd,o=m?.env}let f=i??this.bashEnv.getCwd(),h=i!==void 0,d=new mo(this.bashEnv,s,f,o,h,a,this.timeoutMs);if(l)return d;let p=await d.wait();if(c){let m=await d.stdout();m&&c.write(m)}if(u){let m=await d.stderr();m&&u.write(m)}return p}async writeFiles(e){let n=this.bashEnv.getCwd();for(let[r,s]of Object.entries(e)){let i;typeof s=="string"?i=s:s.encoding==="base64"?i=Buffer.from(s.content,"base64").toString("utf-8"):i=s.content;let o=this.bashEnv.fs.resolvePath(n,r),a=o.substring(0,o.lastIndexOf("/"))||"/";a!=="/"&&await this.bashEnv.fs.mkdir(a,{recursive:!0}),await this.bashEnv.writeFile(o,i)}}async readFile(e,n){let r=await this.bashEnv.readFile(e);return n==="base64"?Buffer.from(r).toString("base64"):r}async mkDir(e,n){let r=this.bashEnv.fs.resolvePath(this.bashEnv.getCwd(),e);await this.bashEnv.fs.mkdir(r,{recursive:n?.recursive??!1})}async stop(){}async extendTimeout(e){}get domain(){}get bashEnvInstance(){return this.bashEnv}};en();var mc=class{violations=[];violationsByType=new Map;options;constructor(e={}){this.options={maxViolationsPerType:e.maxViolationsPerType??100,maxViolationsTotal:e.maxViolationsTotal??1e3,includeStackTraces:e.includeStackTraces??!0,onViolation:e.onViolation??(()=>{}),logToConsole:e.logToConsole??!1}}record(e){let n=this.options.includeStackTraces?e:{...e,stack:void 0};this.violations.unshift(n),this.violations.length>this.options.maxViolationsTotal&&(this.violations.length=this.options.maxViolationsTotal);let r=this.violationsByType.get(e.type);r||(r=[],this.violationsByType.set(e.type,r)),r.length<this.options.maxViolationsPerType&&r.push(n),this.options.logToConsole&&console.warn(`[SecurityViolation] ${e.type}: ${e.message}`,e.path),this.options.onViolation(n)}getViolations(){return[...this.violations]}getViolationsByType(e){return[...this.violationsByType.get(e)??[]]}getSummary(){let e=[];for(let[n,r]of this.violationsByType){if(r.length===0)continue;let s=new Set,i=Number.POSITIVE_INFINITY,o=0;for(let a of r)s.add(a.path),i=Math.min(i,a.timestamp),o=Math.max(o,a.timestamp);e.push({type:n,count:r.length,firstSeen:i,lastSeen:o,paths:Array.from(s)})}return e.sort((n,r)=>r.count-n.count),e}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return e=>this.record(e)}};function Jw(){return t=>{console.warn("[DefenseInDepth] Security violation detected:",`
2115
+ `)}var zG=new TextDecoder("utf-8",{fatal:!0});function bT(t){if(!t)return t;let e=!1;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);if(s>255)return t;s>127&&(e=!0)}if(!e)return t;let n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);try{return zG.decode(n)}catch{return t}}function WG(t,e){if(t!==void 0)return e==="bytes"?t:Er(t)}pe();pe();var hc=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new xs,e?.mounts)for(let{mountPoint:n,filesystem:r}of e.mounts)this.mount(n,r)}mount(e,n){this.validateMountPath(e);let r=he(e);this.validateMount(r),this.mounts.set(r,{mountPoint:r,filesystem:n})}unmount(e){let n=he(e);if(!this.mounts.has(n))throw new Error(`No filesystem mounted at '${e}'`);this.mounts.delete(n)}getMounts(){return Array.from(this.mounts.values()).map(e=>({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let n=he(e);return this.mounts.has(n)}validateMountPath(e){let n=e.split("/");for(let r of n)if(r==="."||r==="..")throw new Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e==="/")throw new Error("Cannot mount at root '/'");for(let n of this.mounts.keys())if(n!==e){if(e.startsWith(`${n}/`))throw new Error(`Cannot mount at '${e}': inside existing mount '${n}'`);if(n.startsWith(`${e}/`))throw new Error(`Cannot mount at '${e}': would contain existing mount '${n}'`)}}routePath(e){de(e,"access");let n=he(e),r=null,s=0;for(let i of this.mounts.values()){let o=i.mountPoint;if(n===o)return{fs:i.filesystem,relativePath:"/"};n.startsWith(`${o}/`)&&o.length>s&&(r=i,s=o.length)}if(r){let i=n.slice(s);return{fs:r.filesystem,relativePath:i||"/"}}return{fs:this.baseFs,relativePath:n}}getChildMountPoints(e){let n=he(e),r=n==="/"?"/":`${n}/`,s=[];for(let i of this.mounts.keys())if(i.startsWith(r)){let a=i.slice(r.length).split("/")[0];a&&!s.includes(a)&&s.push(a)}return s}async readFile(e,n){let{fs:r,relativePath:s}=this.routePath(e);return r.readFile(s,n)}async readFileBytes(e){let{fs:n,relativePath:r}=this.routePath(e);return as(n,r)}async readFileBuffer(e){let{fs:n,relativePath:r}=this.routePath(e);return n.readFileBuffer(r)}async writeFile(e,n,r){let{fs:s,relativePath:i}=this.routePath(e);return s.writeFile(i,n,r)}async appendFile(e,n,r){let{fs:s,relativePath:i}=this.routePath(e);return s.appendFile(i,n,r)}async exists(e){let n=he(e);if(this.mounts.has(n)||this.getChildMountPoints(n).length>0)return!0;let{fs:s,relativePath:i}=this.routePath(e);return s.exists(i)}async stat(e){let n=he(e),r=this.mounts.get(n);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(n).length>0)try{return await this.baseFs.stat(n)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.stat(o)}async lstat(e){let n=he(e),r=this.mounts.get(n);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(n).length>0)try{return await this.baseFs.lstat(n)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.lstat(o)}async mkdir(e,n){let r=he(e);if(this.mounts.has(r)){if(n?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(r).length>0&&n?.recursive)return;let{fs:i,relativePath:o}=this.routePath(e);return i.mkdir(o,n)}async readdir(e){let n=he(e),r=new Set,s=null,{fs:i,relativePath:o}=this.routePath(e);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;s=l}let a=this.getChildMountPoints(n);for(let l of a)r.add(l);if(r.size===0&&s&&!this.mounts.has(n))throw s;return Array.from(r).sort()}async rm(e,n){let r=he(e);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(r).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:i,relativePath:o}=this.routePath(e);return i.rm(o,n)}async cp(e,n,r){let s=this.routePath(e),i=this.routePath(n);return s.fs===i.fs?s.fs.cp(s.relativePath,i.relativePath,r):this.crossMountCopy(e,n,r)}async mv(e,n){let r=he(e);if(this.mounts.has(r))throw new Error(`EBUSY: mount point, cannot move '${e}'`);let s=this.routePath(e),i=this.routePath(n);if(s.fs===i.fs)return s.fs.mv(s.relativePath,i.relativePath);await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,n){return di(e,n)}getAllPaths(){let e=new Set;for(let n of this.baseFs.getAllPaths())e.add(n);for(let n of this.mounts.keys()){let r=n.split("/").filter(Boolean),s="";for(let o of r)s=`${s}/${o}`,e.add(s);let i=this.mounts.get(n);if(i)for(let o of i.filesystem.getAllPaths())o==="/"?e.add(n):e.add(`${n}${o}`)}return Array.from(e).sort()}async chmod(e,n){let r=he(e),s=this.mounts.get(r);if(s)return s.filesystem.chmod("/",n);let{fs:i,relativePath:o}=this.routePath(e);return i.chmod(o,n)}async symlink(e,n){let{fs:r,relativePath:s}=this.routePath(n);return r.symlink(e,s)}async link(e,n){let r=this.routePath(e),s=this.routePath(n);if(r.fs!==s.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${n}'`);return r.fs.link(r.relativePath,s.relativePath)}async readlink(e){let{fs:n,relativePath:r}=this.routePath(e);return n.readlink(r)}async realpath(e){let n=he(e);if(this.mounts.get(n))return n;let{fs:s,relativePath:i}=this.routePath(e),o=await s.realpath(i);for(let[a,l]of this.mounts)if(n===a||n.startsWith(`${a}/`))return o==="/"?a:`${a}${o}`;return o}async crossMountCopy(e,n,r){let s=await this.lstat(e);if(s.isFile){let i=await this.readFileBuffer(e);await this.writeFile(n,i),await this.chmod(n,s.mode)}else if(s.isDirectory){if(!r?.recursive)throw new Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(n,{recursive:!0});let i=await this.readdir(e);for(let o of i){let a=pi(e,o),l=pi(n,o);await this.crossMountCopy(a,l,r)}}else if(s.isSymbolicLink){let i=await this.readlink(e);await this.symlink(i,n)}}async utimes(e,n,r){let{fs:s,relativePath:i}=this.routePath(e);return s.utimes(i,n,r)}};var vt=Jt(require("node:fs"),1),An=Jt(require("node:path"),1);pe();la();var Dr=Jt(require("node:fs"),1),jn=Jt(require("node:path"),1);mn();function rs(t,e){if(t===e)return!0;let n=t[e.length];return(n==="/"||n==="\\")&&t.startsWith(e)}function ho(t,e){try{let n=Dr.realpathSync(t);return rs(n,e)?n:null}catch(n){if(n.code==="ENOENT"){let r=jn.dirname(t);if(r===t)return null;let s=ho(r,e);if(s===null)return null;try{if(Dr.lstatSync(t).isSymbolicLink()){let o=Dr.readlinkSync(t),a=jn.isAbsolute(o)?o:jn.resolve(jn.dirname(t),o);if(ho(a,e)===null)return null}}catch{}return jn.join(s,jn.basename(t))}return null}}function rd(t,e,n){let r=ho(t,n);if(r===null)return null;let s=jn.resolve(t),i=s.slice(e.length),o=r.slice(n.length);if(i!==o)return null;try{if(Dr.lstatSync(s).isSymbolicLink())return null}catch{}return r}function sd(t,e){if(!Dr.existsSync(t))throw new Error(`${e} root does not exist`);if(!Dr.statSync(t).isDirectory())throw new Error(`${e} root is not a directory`)}function ET(t,e){if(!jn.isAbsolute(t))return{withinRoot:!0,relativePath:t};let n;try{n=Dr.realpathSync(t)}catch{n=jn.resolve(t)}return rs(n,e)?{withinRoot:!0,relativePath:n.slice(e.length).replace(/\\/g,"/")||"/"}:{withinRoot:!1,safeName:jn.basename(t)}}function id(t,e,n,r){let s=t;if(s.path===void 0){for(let o of r)if(s.message?.includes(o))throw t}let i=s.code||"EIO";throw new Error(`${i}: ${n} '${e}'`)}var jG=["ELOOP","EFBIG","EPERM"],qG="/home/user/project",po=class{root;canonicalRoot;mountPoint;readOnly;maxFileReadSize;allowSymlinks;memory=new Map;deleted=new Set;constructor(e){this.root=An.resolve(e.root);let n=e.mountPoint??qG;if(this.mountPoint=n==="/"?"/":n.replace(/\/+$/,""),!this.mountPoint.startsWith("/"))throw new Error(`Mount point must be an absolute path: ${n}`);this.readOnly=e.readOnly??!1,this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,sd(this.root,"OverlayFs"),this.canonicalRoot=vt.realpathSync(this.root),this.createMountPointDirs()}assertWritable(e){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${e}`)}createMountPointDirs(){let e=this.mountPoint.split("/").filter(Boolean),n="";for(let r of e)n+=`/${r}`,this.memory.has(n)||this.memory.set(n,{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(e,n){let s=he(e).split("/").filter(Boolean),i="";for(let o of s)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(e,n){let r=he(e),s=this.getDirname(r);s!=="/"&&this.mkdirSync(s);let i=n instanceof Uint8Array?n:new TextEncoder().encode(n);this.memory.set(r,{type:"file",content:i,mode:420,mtime:new Date})}getDirname(e){let n=e.lastIndexOf("/");return n===0?"/":e.slice(0,n)}getRelativeToMount(e){return this.mountPoint==="/"?e:e===this.mountPoint?"/":e.startsWith(`${this.mountPoint}/`)?e.slice(this.mountPoint.length):null}toRealPath(e){let n=he(e),r=this.getRelativeToMount(n);if(r===null)return null;let s=An.join(this.root,r),i=An.resolve(s);return rs(i,this.root)?i:null}resolveRealPath_(e){return e?this.allowSymlinks?ho(e,this.canonicalRoot):rd(e,this.root,this.canonicalRoot):null}resolveRealPathParent_(e){if(!e)return null;let n=An.dirname(e),r=this.resolveRealPath_(n);return r===null?null:An.join(r,An.basename(e))}sanitizeError(e,n,r){id(e,n,r,jG)}ensureParentDirs(e){let n=eo(e);n!=="/"&&(this.memory.has(n)||(this.ensureParentDirs(n),this.memory.set(n,{type:"directory",mode:493,mtime:new Date})),this.deleted.delete(n))}async existsInOverlay(e){let n=he(e);if(this.deleted.has(n))return!1;if(this.memory.has(n))return!0;let r=this.resolveRealPathParent_(this.toRealPath(n));if(!r)return!1;try{return await vt.promises.lstat(r),!0}catch{return!1}}async readFile(e,n){let r=await this.readFileBuffer(e),s=Pr(n);return dr(r,s)}async readFileBytes(e){let n=await this.readFileBuffer(e);return dr(n,"binary")}async readFileBuffer(e,n=new Set){de(e,"open");let r=he(e);if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);if(n.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, open '${e}'`);let s=this.memory.get(r);if(s){if(s.type==="symlink"){let o=this.resolveSymlink(r,s.target);return this.readFileBuffer(o,n)}if(s.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return s.content}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, open '${e}'`);try{let o=await vt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let c=await vt.promises.readlink(i),u=this.realTargetToVirtual(r,c),f=this.resolveSymlink(r,u);return this.readFileBuffer(f,n)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${o.size} bytes, max ${this.maxFileReadSize})`);let a=this.allowSymlinks?vt.constants.O_RDONLY:vt.constants.O_RDONLY|vt.constants.O_NOFOLLOW,l=await vt.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 '${e}'`);if(a==="ELOOP")throw new Error(`ENOENT: no such file or directory, open '${e}'`);this.sanitizeError(o,e,"open")}}async writeFile(e,n,r){de(e,"write"),this.assertWritable(`write '${e}'`);let s=he(e);this.ensureParentDirs(s);let i=Pr(r),o=Ms(n,i);this.memory.set(s,{type:"file",content:o,mode:420,mtime:new Date}),this.deleted.delete(s)}async appendFile(e,n,r){de(e,"append"),this.assertWritable(`append '${e}'`);let s=he(e),i=Pr(r),o=Ms(n,i),a;try{a=await this.readFileBuffer(s)}catch{a=new Uint8Array(0)}let l=new Uint8Array(a.length+o.length);l.set(a),l.set(o,a.length),this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:420,mtime:new Date}),this.deleted.delete(s)}async exists(e){return e.includes("\0")?!1:this.existsInOverlay(e)}async stat(e,n=new Set){de(e,"stat");let r=he(e);if(n.has(r))throw new Error(`ELOOP: too many levels of symbolic links, stat '${e}'`);if(n.add(r),this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=this.memory.get(r);if(s){if(s.type==="symlink"){let a=this.resolveSymlink(r,s.target);return this.stat(a,n)}let o=0;return s.type==="file"&&(o=s.content.length),{isFile:s.type==="file",isDirectory:s.type==="directory",isSymbolicLink:!1,mode:s.mode,size:o,mtime:s.mtime}}let i=this.resolveRealPath_(this.toRealPath(r));if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);try{let o=await vt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let a=await vt.promises.readlink(i),l=this.realTargetToVirtual(r,a),c=this.resolveSymlink(r,l);return this.stat(c,n)}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 '${e}'`);this.sanitizeError(o,e,"stat")}}async lstat(e){de(e,"lstat");let n=he(e);if(this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let r=this.memory.get(n);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 s=this.resolveRealPathParent_(this.toRealPath(n));if(!s)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);try{let i=await vt.promises.lstat(s);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 '${e}'`);this.sanitizeError(i,e,"lstat")}}resolveSymlink(e,n){return ua(e,n)}realTargetToVirtual(e,n){let r=ET(n,this.canonicalRoot);if(r.withinRoot){if(!An.isAbsolute(n))return n;let s=r.relativePath;return this.mountPoint==="/"?s:`${this.mountPoint}${s}`}return r.safeName}async mkdir(e,n){de(e,"mkdir"),this.assertWritable(`mkdir '${e}'`);let r=he(e);if(await this.existsInOverlay(r)){if(!n?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${e}'`);return}let i=eo(r);if(i!=="/"&&!await this.existsInOverlay(i))if(n?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.memory.set(r,{type:"directory",mode:493,mtime:new Date}),this.deleted.delete(r)}async readdirCore(e,n){if(this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Map,s=new Set,i=n==="/"?"/":`${n}/`;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)&&s.add(c)}for(let[a,l]of this.memory)if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!s.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(n));if(o)try{if(!this.allowSymlinks&&(await vt.promises.lstat(o)).isSymbolicLink()){if(!this.memory.has(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);return r}let a=await vt.promises.readdir(o,{withFileTypes:!0});for(let l of a)!s.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(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`)}else a.code!=="ENOTDIR"&&this.sanitizeError(a,e,"scandir")}return r}async resolveForReaddir(e,n=!1){let r=he(e),s=new Set,i=n,o=this.memory.get(r);for(;o&&o.type==="symlink";){if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.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 vt.promises.lstat(l)).isSymbolicLink()){if(!this.allowSymlinks)return{normalized:r,outsideOverlay:!0};let u=await vt.promises.readlink(l),f=this.realTargetToVirtual(r,u),h=this.resolveSymlink(r,f);return this.resolveForReaddir(h,!0)}return{normalized:r,outsideOverlay:!1}}catch{return i?{normalized:r,outsideOverlay:!0}:{normalized:r,outsideOverlay:!1}}}async readdir(e){de(e,"scandir");let{normalized:n,outsideOverlay:r}=await this.resolveForReaddir(e);if(r)return[];let s=await this.readdirCore(e,n);return Array.from(s.keys()).sort((i,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(e){de(e,"scandir");let{normalized:n,outsideOverlay:r}=await this.resolveForReaddir(e);if(r)return[];let s=await this.readdirCore(e,n);return Array.from(s.values()).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(e,n){de(e,"rm"),this.assertWritable(`rm '${e}'`);let r=he(e);if(!await this.existsInOverlay(r)){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}try{if((await this.stat(r)).isDirectory){let o=await this.readdir(r);if(o.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let a of o){let l=r==="/"?`/${a}`:`${r}/${a}`;await this.rm(l,n)}}}}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(e){let n=this.toRealPath(e),r=this.resolveRealPathParent_(n);if(!r)return!1;try{return vt.lstatSync(r),!0}catch{return!1}}async cp(e,n,r){de(e,"cp"),de(n,"cp"),this.assertWritable(`cp '${n}'`);let s=he(e),i=he(n);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, cp '${e}'`);let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);await this.writeFile(i,l)}else if(a.isDirectory){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(s);for(let c of l){let u=s==="/"?`/${c}`:`${s}/${c}`,f=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(u,f,r)}}}async mv(e,n){this.assertWritable(`mv '${n}'`),await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,n){return di(e,n)}getAllPaths(){let e=new Set(this.memory.keys());for(let n of this.deleted)e.delete(n);return this.scanRealFs("/",e),Array.from(e)}scanRealFs(e,n){if(this.deleted.has(e))return;let r=this.resolveRealPath_(this.toRealPath(e));if(r)try{let s=vt.readdirSync(r);for(let i of s){let o=e==="/"?`/${i}`:`${e}/${i}`;if(this.deleted.has(o))continue;n.add(o);let a=An.join(r,i);vt.lstatSync(a).isDirectory()&&this.scanRealFs(o,n)}}catch{}}async chmod(e,n){de(e,"chmod"),this.assertWritable(`chmod '${e}'`);let r=he(e);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);let i=this.memory.get(r);if(i){i.mode=n;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:n,mtime:new Date})}else o.isDirectory&&this.memory.set(r,{type:"directory",mode:n,mtime:new Date})}async symlink(e,n){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${n}'`);de(n,"symlink"),this.assertWritable(`symlink '${n}'`);let r=he(n);if(await this.existsInOverlay(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.memory.set(r,{type:"symlink",target:e,mode:511,mtime:new Date}),this.deleted.delete(r)}async link(e,n){de(e,"link"),de(n,"link"),this.assertWritable(`link '${n}'`);let r=he(e),s=he(n);if(!await this.existsInOverlay(r))throw new Error(`ENOENT: no such file or directory, link '${e}'`);let o=await this.stat(r);if(!o.isFile)throw new Error(`EPERM: operation not permitted, link '${e}'`);if(await this.existsInOverlay(s))throw new Error(`EEXIST: file already exists, link '${n}'`);let l=await this.readFileBuffer(r);this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:o.mode,mtime:new Date}),this.deleted.delete(s)}async readlink(e){de(e,"readlink");let n=he(e);if(this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);let r=this.memory.get(n);if(r){if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}let s=this.resolveRealPathParent_(this.toRealPath(n));if(!s)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);try{let i=await vt.promises.readlink(s);if(!An.isAbsolute(i)){let o=An.resolve(An.dirname(s),i),a;try{a=vt.realpathSync(o)}catch{a=o}if(!rs(a,this.canonicalRoot))return An.basename(i)}return this.realTargetToVirtual(n,i)}catch(i){if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(i,e,"readlink")}}async realpath(e){de(e,"realpath");let n=he(e),r=new Set,s=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 '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let f=this.memory.get(c),h=0,d=40;for(;f&&f.type==="symlink"&&h<d;){if(r.add(c),c=this.resolveSymlink(c,f.target),h++,r.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);f=this.memory.get(c)}if(h>=d)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(!f){let p=this.toRealPath(c),m=this.resolveRealPath_(p);if(m)try{if((await vt.promises.lstat(m)).isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let y=await vt.promises.readlink(m),w=this.realTargetToVirtual(c,y);return r.add(c),c=this.resolveSymlink(c,w),s(c)}}catch(g){if(g.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(g,e,"realpath")}else if(!this.allowSymlinks){let g=this.resolveRealPathParent_(p);if(g)try{if((await vt.promises.lstat(g)).isSymbolicLink())throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}catch(y){if(y.message?.includes("ENOENT")||y.message?.includes("ELOOP"))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(y,e,"realpath")}}}}return c||"/"},i=await s(n);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return i}async utimes(e,n,r){de(e,"utimes"),this.assertWritable(`utimes '${e}'`);let s=he(e);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);let o=this.memory.get(s);if(o){o.mtime=r;return}let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);this.memory.set(s,{type:"file",content:l,mode:a.mode,mtime:r})}else a.isDirectory&&this.memory.set(s,{type:"directory",mode:a.mode,mtime:r})}};var me=Jt(require("node:fs"),1),yt=Jt(require("node:path"),1);pe();la();var HG=["EACCES","escaping sandbox","EFBIG"],dc=class{root;canonicalRoot;maxFileReadSize;allowSymlinks;constructor(e){this.root=yt.resolve(e.root),this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,sd(this.root,"ReadWriteFs"),this.canonicalRoot=me.realpathSync(this.root)}resolveAndValidate(e,n){let r=this.allowSymlinks?ho(e,this.canonicalRoot):rd(e,this.root,this.canonicalRoot);if(r===null)throw new Error(`EACCES: permission denied, '${n}' resolves outside sandbox`);return r}validateParent(e,n){let r=yt.dirname(e),s=this.resolveAndValidate(r,n);return yt.join(s,yt.basename(e))}toRealPath(e){let n=he(e),r=yt.join(this.root,n);return yt.resolve(r)}async readFile(e,n){let r=await this.readFileBuffer(e),s=Pr(n);return dr(r,s)}async readFileBytes(e){let n=await this.readFileBuffer(e);return dr(n,"binary")}async readFileBuffer(e){de(e,"open");let n=this.toRealPath(e),r=this.resolveAndValidate(n,e);try{let s=this.allowSymlinks?me.constants.O_RDONLY:me.constants.O_RDONLY|me.constants.O_NOFOLLOW,i=await me.promises.open(r,s);try{if(this.maxFileReadSize>0){let a=await i.stat();if(a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${a.size} bytes, max ${this.maxFileReadSize})`)}let o=await i.readFile();return new Uint8Array(o)}finally{await i.close()}}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(i.code==="EISDIR")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(i.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(s,e,"open")}}async writeFile(e,n,r){de(e,"write");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=Pr(r),a=Ms(n,o),l=yt.dirname(i);try{await me.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:me.constants.O_NOFOLLOW,u=me.constants.O_WRONLY|me.constants.O_CREAT|me.constants.O_TRUNC|c,f=await me.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, '${e}' is a symlink`);this.sanitizeError(c,e,"write")}}async appendFile(e,n,r){de(e,"append");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=Pr(r),a=Ms(n,o),l=yt.dirname(i);try{await me.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:me.constants.O_NOFOLLOW,u=me.constants.O_WRONLY|me.constants.O_CREAT|me.constants.O_APPEND|c,f=await me.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, '${e}' is a symlink`);this.sanitizeError(c,e,"append")}}async exists(e){if(e.includes("\0"))return!1;let n=this.toRealPath(e);try{let r=this.resolveAndValidate(n,e);return await me.promises.access(r),!0}catch{return!1}}async stat(e){de(e,"stat");let n=this.toRealPath(e),r=this.resolveAndValidate(n,e);try{let s=await me.promises.lstat(r);if(!this.allowSymlinks&&s.isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, stat '${e}'`);this.sanitizeError(s,e,"stat")}}async lstat(e){de(e,"lstat");let n=this.toRealPath(e),r=this.validateParent(n,e);try{let s=await me.promises.lstat(r);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);this.sanitizeError(s,e,"lstat")}}async mkdir(e,n){de(e,"mkdir");let r=this.toRealPath(e),s=this.resolveAndValidate(r,e);try{await me.promises.mkdir(s,{recursive:n?.recursive})}catch(i){let o=i;if(o.code==="EEXIST")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.sanitizeError(i,e,"mkdir")}}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){de(e,"scandir");let n=this.toRealPath(e),r=this.resolveAndValidate(n,e);try{if(!this.allowSymlinks&&(await me.promises.lstat(r)).isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return(await me.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(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(i.code==="ENOTDIR")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);this.sanitizeError(s,e,"scandir")}}async rm(e,n){de(e,"rm");let r=this.toRealPath(e),s=this.resolveAndValidate(r,e);try{await me.promises.rm(s,{recursive:n?.recursive??!1,force:n?.force??!1})}catch(i){let o=i;if(o.code==="ENOENT"&&!n?.force)throw new Error(`ENOENT: no such file or directory, rm '${e}'`);if(o.code==="ENOTEMPTY")throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);this.sanitizeError(i,e,"rm")}}async cp(e,n,r){de(e,"cp"),de(n,"cp");let s=this.toRealPath(e),i=this.toRealPath(n),o=this.resolveAndValidate(s,e),a=this.resolveAndValidate(i,n);try{await me.promises.cp(o,a,{recursive:r?.recursive??!1,filter:async l=>{try{if(me.lstatSync(l).isSymbolicLink()){let u=await me.promises.realpath(l).catch(()=>null);return u===null?!1:rs(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 '${e}'`);if(c.code==="EISDIR")throw new Error(`EISDIR: is a directory, cp '${e}'`);this.sanitizeError(l,e,"cp")}}async mv(e,n){de(e,"mv"),de(n,"mv");let r=this.toRealPath(e),s=this.toRealPath(n),i=this.validateParent(r,e),o=this.validateParent(s,n);try{if((await me.promises.lstat(i)).isSymbolicLink()){let c=await me.promises.readlink(i),u=yt.resolve(yt.dirname(o),c),f=await me.promises.realpath(u).catch(()=>u);if(!rs(f,this.canonicalRoot))throw new Error(`EACCES: permission denied, mv '${e}' -> '${n}' would create symlink escaping sandbox`)}}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.message?.includes("EACCES")||c.message?.includes("escaping sandbox"))throw l}let a=yt.dirname(o);try{await me.promises.mkdir(a,{recursive:!0})}catch(l){this.sanitizeError(l,n,"mv")}try{await me.promises.rename(i,o)}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.code==="EXDEV"){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0});return}this.sanitizeError(l,e,"mv")}try{if(me.lstatSync(o).isDirectory()&&this.findEscapingSymlinks(o).length>0)throw await me.promises.rename(o,i),new Error(`EACCES: permission denied, mv '${e}' -> '${n}' would create symlinks escaping sandbox`)}catch(l){if(l.message?.includes("EACCES")||l.message?.includes("escaping sandbox"))throw l}}resolvePath(e,n){return di(e,n)}getAllPaths(){let e=[];return this.scanDir("/",e),e}sanitizeError(e,n,r){id(e,n,r,HG)}findEscapingSymlinks(e){let n=[];try{let r=me.readdirSync(e);for(let s of r){let i=yt.join(e,s);try{let o=me.lstatSync(i);if(o.isSymbolicLink()){let a=me.readlinkSync(i),l=yt.resolve(e,a),c;try{c=me.realpathSync(l)}catch{c=l}rs(c,this.canonicalRoot)||n.push(i)}else o.isDirectory()&&n.push(...this.findEscapingSymlinks(i))}catch{}}}catch{}return n}scanDir(e,n){let r=this.toRealPath(e),s;try{s=this.resolveAndValidate(r,e)}catch{return}try{let i=me.readdirSync(s);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;n.push(a);let l=yt.join(s,o);me.lstatSync(l).isDirectory()&&this.scanDir(a,n)}}catch{}}async chmod(e,n){de(e,"chmod");let r=this.toRealPath(e),s=this.resolveAndValidate(r,e);try{let i=this.allowSymlinks?me.constants.O_RDONLY:me.constants.O_RDONLY|me.constants.O_NOFOLLOW,o=await me.promises.open(s,i);try{await o.chmod(n)}finally{await o.close()}}catch(i){let o=i;if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);if(o.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(i,e,"chmod")}}async symlink(e,n){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${n}'`);de(n,"symlink");let r=this.toRealPath(n),s=this.validateParent(r,n),i=he(n),o=he(yt.dirname(i)),a=e.startsWith("/")?he(e):he(o==="/"?`/${e}`:`${o}/${e}`),l=yt.join(this.canonicalRoot,a),c=yt.dirname(s),u=e.startsWith("/")?l:yt.relative(c,l)||".";try{await me.promises.symlink(u,s)}catch(f){if(f.code==="EEXIST")throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.sanitizeError(f,n,"symlink")}}async link(e,n){de(e,"link"),de(n,"link");let r=this.toRealPath(e),s=this.toRealPath(n),i=this.resolveAndValidate(r,e),o=this.resolveAndValidate(s,n);try{await me.promises.link(i,o)}catch(a){let l=a;if(l.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(l.code==="EEXIST")throw new Error(`EEXIST: file already exists, link '${n}'`);if(l.code==="EPERM")throw new Error(`EPERM: operation not permitted, link '${e}'`);this.sanitizeError(a,e,"link")}}async readlink(e){de(e,"readlink");let n=this.toRealPath(e),r=this.validateParent(n,e);try{let s=await me.promises.readlink(r),i=he(e),o=yt.dirname(i),a=yt.isAbsolute(s)?s:yt.resolve(yt.dirname(r),s),l=await me.promises.realpath(a).catch(()=>a);if(rs(l,this.canonicalRoot)){let c=l.slice(this.canonicalRoot.length)||"/";return o==="/"?c.startsWith("/")?c.slice(1)||".":c:yt.relative(o,c)}return yt.basename(s)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(s,e,"readlink")}}async realpath(e){de(e,"realpath");let n=this.toRealPath(e);try{this.resolveAndValidate(n,e)}catch{throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}let r;try{r=await me.promises.realpath(n)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);if(i.code==="ELOOP")throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);this.sanitizeError(s,e,"realpath")}if(rs(r,this.canonicalRoot))return r.slice(this.canonicalRoot.length)||"/";throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}async utimes(e,n,r){de(e,"utimes");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e);try{let o=this.allowSymlinks?me.constants.O_RDONLY:me.constants.O_RDONLY|me.constants.O_NOFOLLOW,a=await me.promises.open(i,o);try{await a.utimes(n,r)}finally{await a.close()}}catch(o){let a=o;if(a.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);if(a.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(o,e,"utimes")}}};Bt();Is();os();var mo=class{cmdId;cwd;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;signal;timeoutMs;abortController=new AbortController;timeoutId;externalAbortListener;resultPromise;constructor(e,n,r,s,i=!1,o,a){this.cmdId=crypto.randomUUID(),this.cwd=r,this.startedAt=new Date,this.bashEnv=e,this.cmdLine=n,this.env=s,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 e=Math.max(0,this.timeoutMs);this.timeoutId=sn(()=>{this.abortController.abort(new Error(`sandbox command timeout after ${e}ms`))},e)}}cleanupCancellation(){this.timeoutId!==void 0&&(Dt(this.timeoutId),this.timeoutId=void 0),this.signal&&this.externalAbortListener&&(this.signal.removeEventListener("abort",this.externalAbortListener),this.externalAbortListener=void 0)}async execute(){let e={cwd:this.explicitCwd?this.cwd:void 0,env:this.env,signal:this.abortController.signal};try{let n=await this.bashEnv.exec(this.cmdLine,e);return this.exitCode=n.exitCode,n}finally{this.cleanupCancellation()}}async*logs(){let e=await this.resultPromise;e.stdout&&(yield{type:"stdout",data:e.stdout,timestamp:new Date}),e.stderr&&(yield{type:"stderr",data:e.stderr,timestamp:new Date})}async wait(){return await this.resultPromise,this}async output(){let e=await this.resultPromise;return e.stdout+e.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 pc=class t{bashEnv;timeoutMs;constructor(e,n){this.bashEnv=e,this.timeoutMs=n}static async create(e){let n=e?.fs;if(e?.overlayRoot){if(e?.fs)throw new Error("Cannot specify both 'fs' and 'overlayRoot' options");n=new po({root:e.overlayRoot})}let r=new Oa({env:e?.env,cwd:e?.cwd,fs:n,maxCallDepth:e?.maxCallDepth,maxCommandCount:e?.maxCommandCount,maxLoopIterations:e?.maxLoopIterations,network:e?.network,defenseInDepth:e?.defenseInDepth});return new t(r,e?.timeoutMs)}async runCommand(e,n,r){let s,i,o,a,l=!1,c,u;if(typeof e=="object"){let m=e,g=[m.cmd,...m.args??[]];s=on(g),i=m.cwd,o=m.env,a=m.signal,l=m.detached??!1,c=m.stdout,u=m.stderr}else if(Array.isArray(n)){let m=r;s=on([e,...n]),a=m?.signal}else{s=e;let m=n;i=m?.cwd,o=m?.env}let f=i??this.bashEnv.getCwd(),h=i!==void 0,d=new mo(this.bashEnv,s,f,o,h,a,this.timeoutMs);if(l)return d;let p=await d.wait();if(c){let m=await d.stdout();m&&c.write(m)}if(u){let m=await d.stderr();m&&u.write(m)}return p}async writeFiles(e){let n=this.bashEnv.getCwd();for(let[r,s]of Object.entries(e)){let i;typeof s=="string"?i=s:s.encoding==="base64"?i=Buffer.from(s.content,"base64").toString("utf-8"):i=s.content;let o=this.bashEnv.fs.resolvePath(n,r),a=o.substring(0,o.lastIndexOf("/"))||"/";a!=="/"&&await this.bashEnv.fs.mkdir(a,{recursive:!0}),await this.bashEnv.writeFile(o,i)}}async readFile(e,n){let r=await this.bashEnv.readFile(e);return n==="base64"?Buffer.from(r).toString("base64"):r}async mkDir(e,n){let r=this.bashEnv.fs.resolvePath(this.bashEnv.getCwd(),e);await this.bashEnv.fs.mkdir(r,{recursive:n?.recursive??!1})}async stop(){}async extendTimeout(e){}get domain(){}get bashEnvInstance(){return this.bashEnv}};en();var mc=class{violations=[];violationsByType=new Map;options;constructor(e={}){this.options={maxViolationsPerType:e.maxViolationsPerType??100,maxViolationsTotal:e.maxViolationsTotal??1e3,includeStackTraces:e.includeStackTraces??!0,onViolation:e.onViolation??(()=>{}),logToConsole:e.logToConsole??!1}}record(e){let n=this.options.includeStackTraces?e:{...e,stack:void 0};this.violations.unshift(n),this.violations.length>this.options.maxViolationsTotal&&(this.violations.length=this.options.maxViolationsTotal);let r=this.violationsByType.get(e.type);r||(r=[],this.violationsByType.set(e.type,r)),r.length<this.options.maxViolationsPerType&&r.push(n),this.options.logToConsole&&console.warn(`[SecurityViolation] ${e.type}: ${e.message}`,e.path),this.options.onViolation(n)}getViolations(){return[...this.violations]}getViolationsByType(e){return[...this.violationsByType.get(e)??[]]}getSummary(){let e=[];for(let[n,r]of this.violationsByType){if(r.length===0)continue;let s=new Set,i=Number.POSITIVE_INFINITY,o=0;for(let a of r)s.add(a.path),i=Math.min(i,a.timestamp),o=Math.max(o,a.timestamp);e.push({type:n,count:r.length,firstSeen:i,lastSeen:o,paths:Array.from(s)})}return e.sort((n,r)=>r.count-n.count),e}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return e=>this.record(e)}};function Jw(){return t=>{console.warn("[DefenseInDepth] Security violation detected:",`
2116
2116
  Type: ${t.type}`,`
2117
2117
  Path: ${t.path}`,`
2118
2118
  Message: ${t.message}`,t.executionId?`