@easbot/utils 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/chunk-6FROKXK6.mjs +1 -0
- package/dist/chunks/chunk-6WIM3NST.cjs +1 -0
- package/dist/chunks/filesystem-IEDC2UL2.mjs +1 -0
- package/dist/chunks/filesystem-NRWL3JOL.cjs +1 -0
- package/dist/index.cjs +42 -42
- package/dist/index.d.cts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.mjs +42 -42
- package/package.json +8 -3
- package/dist/chunks/chunk-C4GIW5KR.mjs +0 -1
- package/dist/chunks/chunk-FQQBYGFZ.cjs +0 -1
- package/dist/chunks/filesystem-6XGC2Y33.cjs +0 -1
- package/dist/chunks/filesystem-OR762OFU.mjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk6WIM3NST_cjs=require('./chunks/chunk-6WIM3NST.cjs'),chunkYW4ULP4O_cjs=require('./chunks/chunk-YW4ULP4O.cjs'),chunkBJFGGLWE_cjs=require('./chunks/chunk-BJFGGLWE.cjs'),chunkAHO55TRS_cjs=require('./chunks/chunk-AHO55TRS.cjs'),chunkYC4AEMOP_cjs=require('./chunks/chunk-YC4AEMOP.cjs'),chunkVRQQ33YH_cjs=require('./chunks/chunk-VRQQ33YH.cjs'),K=require('fs/promises'),ie=require('path'),Ce=require('zod'),crypto$1=require('crypto'),Ee=require('fs'),child_process=require('child_process'),module$1=require('module'),hono=require('hono'),nodeServer=require('@hono/node-server'),nodeWs=require('@hono/node-ws'),streaming=require('hono/streaming'),cors=require('hono/cors'),logger=require('hono/logger'),compress=require('hono/compress'),secureHeaders=require('hono/secure-headers'),timeout=require('hono/timeout'),httpException=require('hono/http-exception'),validator=require('hono/validator'),zodValidator=require('@hono/zod-validator'),minimatch=require('minimatch'),promises=require('timers/promises'),dotenv=require('dotenv'),url=require('url'),Yr=require('markdown-it'),Rn=require('yaml'),async_hooks=require('async_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var K__default=/*#__PURE__*/_interopDefault(K);var ie__default=/*#__PURE__*/_interopDefault(ie);var Ce__default=/*#__PURE__*/_interopDefault(Ce);var Ee__default=/*#__PURE__*/_interopDefault(Ee);var Yr__default=/*#__PURE__*/_interopDefault(Yr);var Rn__default=/*#__PURE__*/_interopDefault(Rn);chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function qn(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n!==void 0&&t(n,r,e))return n}}chunkVRQQ33YH_cjs.j();exports.Binary=void 0;(r=>{function e(n,o,s){let a=0,i=n.length-1;for(;a<=i;){let l=Math.floor((a+i)/2),d=n[l];if(d===void 0)break;let c=s(d);if(c===o)return {found:true,index:l};c<o?a=l+1:i=l-1;}return {found:false,index:a}}r.search=e;function t(n,o,s){let a=s(o),i=0,l=n.length;for(;i<l;){let d=Math.floor((i+l)/2),c=n[d];if(c===void 0)break;s(c)<a?i=d+1:l=d;}return n.splice(i,0,o),n}r.insert=t;})(exports.Binary||(exports.Binary={}));chunkVRQQ33YH_cjs.j();exports.Encode=void 0;(s=>{function e(a){let i=new TextEncoder().encode(a),l=Array.from(i,d=>String.fromCharCode(d)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}s.base64Encode=e;function t(a){let i=atob(a.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(i,d=>d.charCodeAt(0));return new TextDecoder().decode(l)}s.base64Decode=t;async function r(a,i="SHA-256"){let d=new TextEncoder().encode(a),c=await crypto.subtle.digest(i,d);return Array.from(new Uint8Array(c)).map(S=>S.toString(16).padStart(2,"0")).join("")}s.hash=r;function n(a){if(!a)return;let i=2166136261;for(let l=0;l<a.length;l++)i^=a.charCodeAt(l),i=Math.imul(i,16777619);return (i>>>0).toString(36)}s.checksum=n;function o(a,i=5e5){if(!a)return;if(a.length<=i)return n(a);let l=4096,c=[0,Math.floor(a.length*.25),Math.floor(a.length*.5),Math.floor(a.length*.75),a.length-l].map(u=>{let m=Math.max(0,Math.min(a.length-l,u-Math.floor(l/2)));return n(a.slice(m,m+l))??""}).join(":");return `${a.length}:${c}`}s.sampledChecksum=o;})(exports.Encode||(exports.Encode={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();exports.Identifier=void 0;(u=>{let e={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk",command:"cmd",task:"task",heartbeat:"hb",subagent:"sub",hook:"hok",compaction:"cmp",context:"ctx"};function t(m){return Ce__default.default.string().startsWith(e[m])}u.schema=t;let r=26,n=0,o=0;function s(m,S){return i(m,false,S)}u.ascending=s;function a(m,S){return i(m,true,S)}u.descending=a;function i(m,S,R){if(!R)return d(m,S);if(!R.startsWith(e[m]))throw new Error(`ID ${R} does not start with ${e[m]}`);return R}function l(m){let S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",R="",A=crypto$1.randomBytes(m);for(let L=0;L<m;L++){let N=A[L];N!==void 0&&(R+=S[N%62]);}return R}function d(m,S,R){let A=R??Date.now();A!==n&&(n=A,o=0),o++;let L=BigInt(A)*BigInt(4096)+BigInt(o);L=S?~L:L;let N=Buffer.alloc(6);for(let D=0;D<6;D++)N[D]=Number(L>>BigInt(40-8*D)&BigInt(255));return e[m]+"_"+N.toString("hex")+l(r-12)}u.create=d;function c(m){let S=m.split("_")[0];if(!S)return 0;let R=m.slice(S.length+1,S.length+13),A=BigInt("0x"+R);return Number(A/BigInt(4096))}u.timestamp=c;})(exports.Identifier||(exports.Identifier={}));exports.TruncateContent=void 0;(i=>{i.DIR=ie__default.default.join("data","context-truncate"),i.DEFAULT_MAX_CHARS=4e3,i.DIRECTION="head";function n(l,d,c){return c?`[Content truncated. Source: ${c}
|
|
2
2
|
Full ${d} saved to: ${l}
|
|
3
3
|
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${d} saved to: ${l}
|
|
4
|
-
Use Read tool with offset/limit parameters to view specific sections.]`}function o(l,d={}){let c=d.maxChars??i.DEFAULT_MAX_CHARS,u=d.direction??i.DIRECTION,m=d.label??"content",
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}function o(l,d={}){let c=d.maxChars??i.DEFAULT_MAX_CHARS,u=d.direction??i.DIRECTION,m=d.label??"content",S=d.sourcePath;if(l.length<=c)return {content:l,truncated:false};let R=l.length-c,A;u==="head"?A=l.slice(0,c):A=l.slice(-c);let L=n("[save-path]",m,S),N=u==="head"?`
|
|
5
5
|
|
|
6
6
|
...${R} characters truncated...
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${L}`:`
|
|
9
9
|
|
|
10
10
|
...${R} characters truncated...
|
|
11
11
|
|
|
12
|
-
${
|
|
12
|
+
${L}`;return {content:A+N,truncated:true,outputPath:"[save-path]",originalLength:l.length,removedLength:R,label:m}}i.truncate=o;async function s(l,d={}){let c=d.maxChars??i.DEFAULT_MAX_CHARS,u=d.direction??i.DIRECTION,m=d.label??"content",S=d.dir??i.DIR,R=d.sourcePath;if(l.length<=c)return {content:l,truncated:false};let A=exports.Identifier.ascending("context"),L=ie__default.default.join(S,A);await K__default.default.mkdir(S,{recursive:true}).catch(()=>{}),await K__default.default.writeFile(L,l,"utf-8");let N=l.length-c,D;u==="head"?D=l.slice(0,c):D=l.slice(-c);let fe=n(L,m,R),He=u==="head"?`
|
|
13
13
|
|
|
14
|
-
...${
|
|
14
|
+
...${N} characters truncated...
|
|
15
15
|
|
|
16
16
|
${fe}`:`
|
|
17
17
|
|
|
18
|
-
...${
|
|
18
|
+
...${N} characters truncated...
|
|
19
19
|
|
|
20
|
-
${fe}`;return {content:D+
|
|
21
|
-
${s.stderr}`),{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return a},o=n();return Object.defineProperty(o,"stdin",{get(){throw new Error("stdin is not yet supported in EasbotShell. Use PKG.spawn for interactive commands.")},enumerable:true}),o.cwd=function(s){return
|
|
22
|
-
`),
|
|
23
|
-
`),C=P.length>0?P[0]?.trim():null;if(C)return
|
|
24
|
-
`).filter(p=>p.trim()&&!p.startsWith("#")))):["/bin/bash","/bin/zsh","/bin/sh"]}function d(f,p){if(f&&(!p?.acceptable||o(f))){let x=a(f);if(x)return x}return process.platform==="win32"?i()[0]:
|
|
20
|
+
${fe}`;return {content:D+He,truncated:true,outputPath:L,originalLength:l.length,removedLength:N,label:m}}i.truncateAndSave=s;function a(l){return l.truncated?n(l.outputPath,l.label):""}i.formatHint=a;})(exports.TruncateContent||(exports.TruncateContent={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function $t(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var Te=$t;function At(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var Yn=At;exports.Lazy=void 0;(r=>(r.lazy=$t,r.lazyAsync=At))(exports.Lazy||(exports.Lazy={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();var J=chunkBJFGGLWE_cjs.a.create({service:"server"});function Q(e={}){let t=e.port??3e3,r=e.hostname??"0.0.0.0",n=new hono.Hono({strict:true,getPath:a=>{try{return new URL(a.url).pathname}catch{return a.url}}});if(e.onError?n.onError(e.onError):n.onError((a,i)=>(J.error("Server error",{error:a.message,stack:a.stack}),a instanceof httpException.HTTPException?a.getResponse():i.json({error:"Internal Server Error",message:a.message},500))),e.onNotFound?n.notFound(e.onNotFound):n.notFound(a=>a.json({error:"Not Found",path:a.req.path},404)),!e.websockets&&e.cors&&n.use(cors.cors(typeof e.cors=="boolean"?{origin:"*"}:e.cors)),n.use(logger.logger((a,...i)=>J.info(a,i))),!e.websockets&&e.secureHeaders&&n.use(secureHeaders.secureHeaders()),!e.websockets&&e.compression&&n.use(compress.compress({encoding:"gzip"})),!e.websockets&&e.timeout&&n.use(timeout.timeout(e.timeout)),e.middlewares)for(let a of e.middlewares)a.path?n.use(a.path,a.handler):n.use(a.handler);if(e.routes)for(let a of e.routes){let i=a.middlewares||[],l=a.method.toUpperCase();a.validation?n.on(l,a.path,zodValidator.zValidator("json",a.validation),...i,a.handler):n.on(l,a.path,...i,a.handler);}e.rpc&&n.post("/rpc/:method",async a=>{let i=a.req.param("method"),l=e.rpc?.[i];if(!l)return a.json({error:"RPC method not found"},404);try{let d=await a.req.json(),c=await l(d,a);return a.json({result:c})}catch(d){return J.error("RPC error",{method:i,error:d.message}),a.json({error:"RPC execution failed",message:d.message},500)}}),e.fetch&&n.all("*",async a=>await e.fetch(a.req.raw));let o=null,s={url:new URL(`http://${r}:${t}`),port:t,hostname:r,hono:n,async stop(a=false){return o?new Promise((i,l)=>{a&&o.closeAllConnections?.(),o.close(d=>{d?(J.error("Error closing server",{error:d.message}),l(d)):(o=null,J.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{J.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return J.debug("createServer: calling serve()",{port:t,hostname:r}),o=nodeServer.serve({fetch:n.fetch,port:t,hostname:r}),J.debug("createServer: serve() returned, server created"),J.info(`Server running on http://${r}:${t}`),s}function Ze(e){return Q({rpc:e,port:3e3})}function Xn(e,t=3e3,r="0.0.0.0"){return Q({fetch:e,port:t,hostname:r})}function Ke(e,t={}){return Q({...t,routes:e})}function Xe(e,t={}){return Q({...t,websockets:e})}function Qe(e,t={}){let r=Object.entries(e).map(([n,o])=>({method:"get",path:`/stream/${n}`,handler:s=>streaming.streamSSE(s,async a=>{for await(let i of o(s))await a.writeSSE(i);})}));return Q({...t,routes:r,streaming:true})}chunkVRQQ33YH_cjs.j();var ee=chunkBJFGGLWE_cjs.a.create({service:"build-api"});async function Yt(){try{return {available:!0,version:(await import('./chunks/main-RIJAJS2R.cjs')).version||"unknown"}}catch(e){return ee.warn("esbuild not available",{error:e.message}),{available:false}}}async function Re(){let e=await Yt();if(!e.available)throw new Error("esbuild is required but not installed. Please install it using: pnpm add -D esbuild");e.version&&e.version<"0.17.0"&&ee.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function nr(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function Jt(e){let t=nr(e.compile);t&&ee.warn("compile option is no longer supported (Bun runtime removed). The option will be ignored.");let r={entryPoints:e.entrypoints,outdir:e.outdir,bundle:e.bundle??true,conditions:e.conditions,external:e.external,format:e.format??"esm",platform:e.platform??(e.target==="browser"?"browser":"node"),minify:e.minify??false,treeShaking:true,splitting:e.splitting,sourcemap:rr(e.sourcemap),sourcesContent:true,define:e.define,inject:e.inject,legalComments:"eof",loader:e.loader,entryNames:e.entryNames,chunkNames:e.chunkNames,assetNames:e.assetNames,publicPath:e.publicPath,tsconfig:e.tsconfig,charset:"utf8",color:true,logLevel:"info",logLimit:50,plugins:e.plugins??[],metafile:true,write:e.write??true};return t?.outfile&&!e.outdir&&(r.outfile=t.outfile,delete r.outdir),e.target&&(r.target=or(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),sr(r)}function rr(e){return !e||e==="none"?false:e}function or(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function sr(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function Me(e){if(e!==void 0)return e.replace(/\\/g,"/")}function Ut(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:Me(s.path)||s.path,size:s.contents?.length||0});if(e.metafile?.outputs)for(let[s,a]of Object.entries(e.metafile.outputs)){let i=a;n.some(l=>l.path===s||l.path===Me(s))||n.push({path:Me(s)||s,size:i.bytes||0});}let o=[];if(e.errors?.length>0)for(let s of e.errors)o.push({level:"error",message:s.text||String(s),path:s.location?.file,position:s.location?{line:s.location.line,column:s.location.column}:void 0});if(e.warnings?.length>0)for(let s of e.warnings)o.push({level:"warning",message:s.text||String(s),path:s.location?.file,position:s.location?{line:s.location.line,column:s.location.column}:void 0});return {outputs:n,success:e.errors?.length===0,logs:o,metafile:e.metafile}}async function tt(e){ee.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await Re();let t=await import('./chunks/main-RIJAJS2R.cjs'),r=Date.now();try{let n=Jt(e);ee.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return ee.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),Ut(o,r,s)}catch(n){let o=Date.now(),s=n.message;return ee.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?Ut(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var dr={build:tt},Zt=dr;chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function Z(e){let t=[],r="",n=0;for(;n<e.length&&(e[n]===" "||e[n]===" ");)n++;for(;n<e.length;){let o=e[n];if(o===" "||o===" "){for(r.length>0&&(t.push(r),r="");n<e.length&&(e[n]===" "||e[n]===" ");)n++;continue}if(o==='"'){for(n++;n<e.length;){let s=e[n];if(s==="\\"&&n+1<e.length){let a=e[n+1];if(a==='"'||a==="\\"||a==="$"||a==="`"){r+=a,n+=2;continue}}if(s==='"'){n++;break}r+=s,n++;}continue}if(o==="'"){for(n++;n<e.length;){let s=e[n];if(s==="'"){n++;break}r+=s,n++;}continue}r+=o,n++;}return r.length>0&&t.push(r),t}function Kt(e){return /[|&;<>()$`!#]/.test(e)}function Xt(e){let t=Z(e);if(t.length===0)return {command:"",args:[]};let r={command:t[0],args:t.slice(1)};if(r.args.length>0){let n=r.args[r.args.length-1];try{let o=JSON.parse(n);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(r.options=o,r.args=r.args.slice(0,-1));}catch{}}return r}function nt(e,t=process.platform==="win32"?"windows":"unix"){return t==="windows"?e.includes(" ")||e.includes("&")||e.includes("|")||e.includes("<>")||e.includes("^")||e.includes('"')||e.includes("%")?`"${e.replace(/%/g,"%%").replace(/"/g,'^"')}"`:e:e.includes(" ")||e.includes("'")||e.includes('"')||e.includes("$")||e.includes("`")||e.includes("\\")||e.includes("!")||e.includes("#")||e.includes("&")||e.includes("*")||e.includes("?")||e.includes("|")||e.includes("<")||e.includes(">")||e.includes("(")||e.includes(")")||e.includes(";")?`'${e.replace(/'/g,"'\\''")}'`:e}var fr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>"]);function Qt(e,t=process.platform==="win32"?"windows":"unix"){return fr.has(e)?e:nt(e,t)}function en(){return process.platform==="win32"?"windows":"unix"}function oe(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>Qt(o,r));return [e,...n].join(" ")}function tn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>tn(t)).join(" ");if(e&&typeof e=="object"){if("raw"in e)return String(e.raw);if("toString"in e&&typeof e.toString=="function")return e.toString();if(e instanceof ReadableStream)throw new Error("ReadableStream expressions are not yet supported")}return String(e)}function pr(e,t,r){return {stdout:e,stderr:t,exitCode:r,text(n="utf-8"){return e.toString(n)},json(){let n=e.toString("utf-8");return JSON.parse(n)},arrayBuffer(){let n=e.buffer;if(n instanceof ArrayBuffer)return n.slice(e.byteOffset,e.byteOffset+e.byteLength);let o=new ArrayBuffer(e.byteLength),s=new Uint8Array(o),a=new Uint8Array(n,e.byteOffset,e.byteLength);return s.set(a),o},bytes(){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},blob(){let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return new Blob([n])}}}function se(e,t={}){let r=Z(e);if(r.length===0)throw new Error("Empty shell command");let n=async()=>{let s=await exports.PKG.run(r,{cwd:t.cwd,env:t.env}),a=pr(Buffer.from(s.stdout,"utf-8"),Buffer.from(s.stderr,"utf-8"),s.code);if(s.code!==0&&!t.nothrow)throw Object.assign(new Error(`Command failed with exit code ${s.code}: ${e}
|
|
21
|
+
${s.stderr}`),{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return a},o=n();return Object.defineProperty(o,"stdin",{get(){throw new Error("stdin is not yet supported in EasbotShell. Use PKG.spawn for interactive commands.")},enumerable:true}),o.cwd=function(s){return se(e,{...t,cwd:s})},o.env=function(s){return se(e,{...t,env:s})},o.quiet=function(){return se(e,{...t,quiet:true})},o.lines=async function*(){let i=(await n()).text().split(/\r?\n/);for(let l of i)l.trim()&&(yield l);},o.text=async function(s="utf-8"){return (await n()).text(s)},o.json=async function(){return (await n()).json()},o.arrayBuffer=async function(){return (await n()).arrayBuffer()},o.blob=async function(){return (await n()).blob()},o.nothrow=function(){return se(e,{...t,nothrow:true})},o.throws=function(s){return se(e,{...t,nothrow:!s})},o}var ge=class{constructor(t={}){chunkVRQQ33YH_cjs.c(this,"options");this.options=t;}call(t,...r){let n="";for(let o=0;o<t.length;o++)n+=t[o],o<r.length&&r[o]!==void 0&&(n+=tn(r[o]));return se(n,this.options)}braces(t){let r=t.match(/^(.*?)\{([^}]+)\}(.*)$/);if(!r)return [t];let[,n="",o="",s=""]=r,a=o.split(",").map(l=>l.trim()),i=[];for(let l of a){let d=`${n}${l}${s}`;d.includes("{")?i.push(...this.braces(d)):i.push(d);}return i}escape(t){return process.platform==="win32"?t.replace(/([&|<>^"%])/g,"^$1"):t.replace(/(["\s'$`\\!*?#&;()<>|])/g,"\\$1")}env(t){return te({...this.options,env:t})}cwd(t){return te({...this.options,cwd:t})}nothrow(){return te({...this.options,nothrow:true})}throws(t){return te({...this.options,nothrow:!t})}};function te(e={}){let t=new ge(e);return new Proxy(t,{apply(r,n,o){return t.call(o[0],...o.slice(1))}})}var nn=te();function rn(e){return e.replace(/\\/g,"/")}function on(e){return crypto$1.createHash("md5").update(e).digest("hex").slice(0,8)}var G=new Map;exports.PKG=void 0;(z=>{chunkBJFGGLWE_cjs.a.create({service:"pkg"});async function t(k){let g=k?[k]:["npm","pnpm","bun"];for(let f of g){let p=await z.which(f);if(p)return {name:f,path:p}}}z.packageManager=t;async function r(k,g){if(!k)return process.execPath;let f=g?.PATH||process.env.PATH||process.env.Path||"",p=process.env.EASBOT_BIN_PATH,x=p?f+ie__default.default.delimiter+p:f,w=on(x),b=`${k}:${w}`;if(G.has(b))return G.get(b);let E=process.platform==="win32"?"where":"which";try{let{spawn:v}=await import('child_process');return new Promise(P=>{let C=v(E,[k],{env:{...process.env,PATH:x},stdio:["pipe","pipe","ignore"],windowsHide:!0}),_="",B="";C.stdout?.on("data",j=>{_+=j.toString();}),C.stderr?.on("data",j=>{B+=j.toString();}),C.on("close",j=>{if(j===0&&_.trim()){let I=_.trim().split(`
|
|
22
|
+
`),O=I.length>0?I[0]?.trim():null;if(O){G.set(b,O),P(O);return}}G.set(b,null),P(null);}),setTimeout(()=>{C.kill(),G.set(b,null),P(null);},5e3);})}catch{return G.set(b,null),null}}z.which=r;function n(k,g){if(!k)return process.execPath;let f=g?.PATH||process.env.PATH||process.env.Path||"",p=process.env.EASBOT_BIN_PATH,x=p?f+ie__default.default.delimiter+p:f,w=on(x),b=`${k}:${w}`;if(G.has(b))return G.get(b);let E=process.platform==="win32"?"where":"which";try{let v=child_process.execSync(`${E} ${k}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"],env:{...process.env,PATH:x},timeout:5e3,windowsHide:!0});if(v.trim()){let P=v.trim().split(`
|
|
23
|
+
`),C=P.length>0?P[0]?.trim():null;if(C)return G.set(b,C),C}}catch{}return G.set(b,null),null}z.whichSync=n;function o(){G.clear();}z.clearWhichCache=o;let s=module$1.createRequire(chunkVRQQ33YH_cjs.i);async function a(k,g){try{return g?s.resolve(k,{paths:[g]}):s.resolve(k)}catch(f){throw new Error(`Cannot resolve module "${k}"${g?` from "${g}"`:""}: ${f instanceof Error?f.message:String(f)}`)}}z.resolve=a;function i(k){return {get name(){return ie__default.default.basename(k)},async exists(){try{return await K__default.default.access(k),!0}catch{return false}},async getSize(){try{return (await K__default.default.stat(k)).size}catch{return}},async text(){return await K__default.default.readFile(k,"utf-8")},textSync(){return Ee__default.default.readFileSync(k,"utf-8")},jsonSync(){let g=Ee__default.default.readFileSync(k,"utf-8");return JSON.parse(g)},async bytes(){let g=await K__default.default.readFile(k);return new Uint8Array(g.buffer,g.byteOffset,g.byteLength)},async arrayBuffer(){let g=await K__default.default.readFile(k);return g.buffer.slice(g.byteOffset,g.byteOffset+g.byteLength)},get type(){let g=ie__default.default.extname(k).toLowerCase();return {".txt":"text/plain",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".xml":"application/xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".pdf":"application/pdf",".zip":"application/zip",".wav":"audio/wav",".mp3":"audio/mpeg",".mp4":"video/mp4",".webm":"video/webm"}[g]||"application/octet-stream"},async write(g){let f;if(g instanceof Response){let p=await g.arrayBuffer();f=new Uint8Array(p);}else f=g;await K__default.default.writeFile(k,f);},async json(){let g=await K__default.default.readFile(k,"utf-8");return JSON.parse(g)},async stat(){return await K__default.default.stat(k)}}}z.file=i;async function l(k,g,f){let p;if(g instanceof Response){let x=await g.arrayBuffer();p=new Uint8Array(x);}else p=g;await K__default.default.writeFile(k,p,f?{mode:f.mode}:void 0);}z.write=l;function d(k,g,f){Ee__default.default.writeFileSync(k,g,f?{mode:f.mode}:void 0);}z.writeSync=d;function c(k,g="utf-8"){return Ee__default.default.readFileSync(k,g)}z.readSync=c;function u(k,g){let f,p;if(typeof k=="object"&&"cmd"in k){let v=k;f=v.cmd,p={cwd:v.cwd,env:v.env,stdout:v.stdout,stderr:v.stderr,stdin:v.stdin,signal:v.signal,windowsHide:v.windowsHide,shell:v.shell};}else f=Array.isArray(k)?k:[k],p=g||{};if(!f||f.length===0||!f[0])throw new Error("Spawn command cannot be empty");let x=[p.stdin==="inherit"?"inherit":p.stdin==="null"?"ignore":"pipe",p.stdout==="inherit"?"inherit":p.stdout==="null"?"ignore":"pipe",p.stderr==="inherit"?"inherit":p.stderr==="null"?"ignore":"pipe"],w={cwd:p.cwd,env:p.env?{...process.env,...p.env}:process.env,stdio:x};p.shell!==void 0&&(w.shell=p.shell),process.platform==="win32"&&(w.windowsHide=p.windowsHide??true);let b=child_process.spawn(f[0],f.slice(1),w),y;if(p.signal){y=()=>{b.kill();},p.signal.addEventListener("abort",y,{once:true});let v=()=>{y&&(p.signal?.removeEventListener("abort",y),y=void 0);};b.on("close",v),b.on("error",v);}let E=new Promise((v,P)=>{let C=false,_=()=>{C||(C=true,b.removeAllListeners());};if(b.on("close",B=>{_(),v(B??0);}),b.on("error",B=>{_(),P(B);}),p.timeout!==false){let B=p.timeout||3e5;setTimeout(()=>{C||(_(),b.kill("SIGTERM"),P(new Error(`Process timeout after ${B}ms: ${f.join(" ")}`)));},B);}});return {stdout:b.stdout,stderr:b.stderr,stdin:b.stdin,pid:b.pid,exited:E,exitCode:b.exitCode,kill:v=>b.kill(v)}}z.spawn=u;async function m(k,g){let f=g?.stdin??"null",p=g?.stdout??"pipe",x=g?.stderr??"pipe",w=u(k,{cwd:g?.cwd,env:g?.env,stdin:f,stdout:p,stderr:x,windowsHide:g?.windowsHide,shell:g?.shell}),b=[],y=[];p==="pipe"&&w.stdout?.on("data",v=>{b.push(v);}),x==="pipe"&&w.stderr?.on("data",v=>{y.push(v);});let E=g?.timeout&&g.timeout>0?setTimeout(()=>{w.kill("SIGTERM");},g.timeout):void 0;try{let v=await w.exited;return clearTimeout(E),p==="pipe"&&w.stdout?.destroy(),x==="pipe"&&w.stderr?.destroy(),f==="pipe"&&w.stdin?.end(),{code:v,stdout:Buffer.concat(b).toString("utf-8"),stderr:Buffer.concat(y).toString("utf-8")}}catch(v){return clearTimeout(E),p==="pipe"&&w.stdout?.destroy(),x==="pipe"&&w.stderr?.destroy(),f==="pipe"&&w.stdin?.end(),{code:-1,stdout:Buffer.concat(b).toString("utf-8"),stderr:Buffer.concat(y).toString("utf-8")||(v instanceof Error?v.message:String(v))}}}z.run=m;async function S(k,g={},f={}){let p=u(k,{cwd:g.cwd,env:g.env,stdout:"pipe",stderr:"pipe",stdin:"null"}),x="",w="";p.stdout?.on("data",y=>{let E=y.toString("utf-8");x+=E,f.onStdout?.(E);}),p.stderr?.on("data",y=>{let E=y.toString("utf-8");w+=E,f.onStderr?.(E);});let b=g.timeout&&g.timeout>0?setTimeout(()=>{p.kill("SIGTERM");},g.timeout):void 0;try{let y=await p.exited;return clearTimeout(b),f.onExit?.(y),{code:y,stdout:x,stderr:w}}catch(y){clearTimeout(b);let E=y instanceof Error?y.message:String(y);return {code:-1,stdout:x,stderr:w||E}}}z.runWithStream=S;async function R(k){if(typeof k.pipeThrough=="function")try{let x=new TextDecoderStream("utf-8"),b=k.pipeThrough(x).getReader(),y="";try{for(;;){let{done:E,value:v}=await b.read();if(E)break;y+=v;}return y}finally{b.releaseLock();}}catch{}let g=k.getReader(),f=new TextDecoder("utf-8"),p=[];try{for(;;){let{done:x,value:w}=await g.read();if(x)break;p.push(f.decode(w,{stream:!0}));}return p.push(f.decode()),p.join("")}finally{g.releaseLock();}}z.readableStreamToText=R;async function A(k){let g=[];return new Promise((f,p)=>{k.on("data",x=>{typeof x=="string"?g.push(Buffer.from(x)):g.push(x);}),k.on("end",()=>{try{let w=Buffer.concat(g).toString("utf-8");f(w);}catch(x){p(x);}}),k.on("error",x=>{p(x);});})}z.nodeReadableStreamToText=A;function L(k,g=0){let E=new TextEncoder().encode(k),v=E.length,P,C=0;if(v>=16){let I=v-16,O=g+2654435761+2246822519|0,q=g+2246822519|0,H=g+0|0,V=g-2654435761|0;for(;C<=I;)O=_(O,j(E,C)),C+=4,q=_(q,j(E,C)),C+=4,H=_(H,j(E,C)),C+=4,V=_(V,j(E,C)),C+=4;P=B(O,1)+B(q,7)+B(H,12)+B(V,18)|0;}else P=g+374761393|0;for(P=P+v|0;C+4<=v;)P=P+j(E,C)*3266489917|0,P=B(P,17)*668265263|0,C+=4;for(;C<v;)P=P+E[C]*374761393|0,P=B(P,11)*2654435761|0,C++;return P^=P>>>15,P=P*2246822519|0,P^=P>>>13,P=P*3266489917|0,P^=P>>>16,P>>>0;function _(I,O){return I=I+O*2246822519|0,I=B(I,13),I=I*2654435761|0,I}function B(I,O){return I<<O|I>>>32-O|0}function j(I,O){return (I[O]|I[O+1]<<8|I[O+2]<<16|I[O+3]<<24)>>>0}}z.xxHash32=L;function N(k){let g=0;for(let f of k){let p=f.codePointAt(0)||f.charCodeAt(0);p<127?g+=1:p>=4352&&p<=4447||p>=9001&&p<=9002||p>=11904&&p<=42191&&p!==12351||p>=44032&&p<=55203||p>=63744&&p<=64255||p>=65040&&p<=65049||p>=65072&&p<=65135||p>=65280&&p<=65376||p>=65504&&p<=65510?g+=2:g+=1;}return g}z.stringWidth=N;class D{constructor(g){chunkVRQQ33YH_cjs.c(this,"pattern");this.pattern=g;}async*scan(g){let f=chunkAHO55TRS_cjs.b.stream(this.pattern,{cwd:g?.cwd,absolute:g?.absolute,follow:g?.followSymlinks,dot:g?.dot,nodir:g?.onlyFiles});for await(let p of f)yield rn(p);}*scanSync(g){let f=chunkAHO55TRS_cjs.a(this.pattern,{cwd:g?.cwd,absolute:g?.absolute,follow:g?.followSymlinks,dot:g?.dot,nodir:g?.onlyFiles});for(let p of f)yield rn(p);}match(g){return minimatch.minimatch(g,this.pattern)}}z.Glob=D,z.stdin=process.stdin,z.stdout=process.stdout,z.stderr=process.stderr,z.sleep=k=>new Promise(g=>setTimeout(g,k)),z.color=(k,g)=>({black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",blink:"\x1B[5m",inverse:"\x1B[7m",hidden:"\x1B[8m",strikethrough:"\x1B[9m",reset:"\x1B[0m"})[k.toLowerCase()]||null,z.hash={xxHash32:z.xxHash32},z.build=Zt.build,z.server=Q,z.nodeWebSocket=nodeWs.createNodeWebSocket,z.restServer=Ke,z.rpcServer=Ze,z.streamingServer=Qe,z.webSocketServer=Xe;})(exports.PKG||(exports.PKG={}));var wr=exports.PKG.readableStreamToText;exports.PKG.nodeReadableStreamToText;exports.PKG.which;var yr=exports.PKG.whichSync;exports.PKG.spawn;exports.PKG.run;var an=200,ln={bash:{login:true,posix:true},dash:{login:true,posix:true},fish:{deny:true,login:true},ksh:{login:true,posix:true},nu:{deny:true},powershell:{ps:true},pwsh:{ps:true},sh:{login:true,posix:true},zsh:{login:true,posix:true}};exports.Shell=void 0;(g=>{let e=chunkBJFGGLWE_cjs.a.create({service:"shell"});async function t(f,p){let x=f.pid;if(!(!x||p?.exited?.())){if(process.platform==="win32"){await new Promise(w=>{let b=child_process.spawn("taskkill",["/pid",String(x),"/f","/t"],{stdio:"ignore",windowsHide:true});b.once("exit",()=>w()),b.once("error",()=>w());});return}try{process.kill(-x,"SIGTERM"),await promises.setTimeout(an),p?.exited?.()||process.kill(-x,"SIGKILL");}catch{f.kill("SIGTERM"),await promises.setTimeout(an),p?.exited?.()||f.kill("SIGKILL");}}}g.killTree=t;function r(f){if(process.platform!=="win32"||!f.includes("/")&&!f.includes("\\")&&!f.includes(":"))return f;let p=chunk6WIM3NST_cjs.c.normalize(f);return R(p)==="bash"&&m()||p}function n(f){return ln[R(f)]}function o(f){return n(f)?.deny!==true}function s(f){return chunk6WIM3NST_cjs.c.isAbsolute(f)}function a(f){let p=r(f);if(s(p))return chunk6WIM3NST_cjs.c.stat(p)?.isFile()?p:void 0;let x=exports.PKG.whichSync(p);return x?chunk6WIM3NST_cjs.c.normalize(x):void 0}function i(){return Array.from(new Set([exports.PKG.whichSync("pwsh"),exports.PKG.whichSync("powershell"),m(),process.env.COMSPEC||"cmd.exe"].filter(f=>!!f).map(r)))}async function l(){let f=await chunk6WIM3NST_cjs.c.readText("/etc/shells").catch(()=>"");return f?Array.from(new Set(f.split(`
|
|
24
|
+
`).filter(p=>p.trim()&&!p.startsWith("#")))):["/bin/bash","/bin/zsh","/bin/sh"]}function d(f,p){if(f&&(!p?.acceptable||o(f))){let x=a(f);if(x)return x}return process.platform==="win32"?i()[0]:S()}g.defaultPreferred=Te(()=>d(process.env.SHELL)),g.defaultAcceptable=Te(()=>d(process.env.SHELL,{acceptable:true}));function m(){if(process.platform!=="win32")return;if(process.env.EASBOT_GIT_BASH_PATH)return chunk6WIM3NST_cjs.c.normalize(process.env.EASBOT_GIT_BASH_PATH);let f=exports.PKG.whichSync("git");if(!f)return;let p=chunk6WIM3NST_cjs.c.normalize(ie__default.default.join(f,"..","..","bin","bash.exe"));if((chunk6WIM3NST_cjs.c.stat(p)?.size??0)>0)return p}g.gitbash=m;function S(){if(process.platform==="win32"){let p=m();return p||"/bin/sh"}if(process.platform==="darwin")return "/bin/zsh";let f=exports.PKG.whichSync("bash");return f?chunk6WIM3NST_cjs.c.normalize(f):"/bin/sh"}function R(f){return ie__default.default.posix.basename(chunk6WIM3NST_cjs.c.toUnixPath(f)).toLowerCase()}g.name=R;function A(f){return n(f)?.login===true}g.login=A;function L(f){return n(f)?.posix===true}g.posix=L;function N(f){return n(f)?.ps===true}g.ps=N;function D(f){let p=r(f),x=R(p);return {path:p,name:x,acceptable:o(x)}}function fe(f,p,x){let w=R(f),b=Z(p),y=oe(b[0]??p,b.slice(1));return w==="nu"||w==="fish"?["-c",y]:w==="zsh"?["-l","-c",`
|
|
25
25
|
[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
|
|
26
26
|
[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
|
|
27
27
|
cd -- "$1"
|
|
28
|
-
${
|
|
29
|
-
`,"easbot",x]:
|
|
28
|
+
${y}
|
|
29
|
+
`,"easbot",x]:w==="bash"?["-l","-c",`${process.platform==="win32"?`cmd /c chcp 65001 >nul 2>&1 || true
|
|
30
30
|
`:""}shopt -s expand_aliases
|
|
31
31
|
[[ -f ~/.bashrc ]] && source ~/.bashrc >/dev/null 2>&1 || true
|
|
32
32
|
cd -- "$1"
|
|
33
|
-
${
|
|
34
|
-
`,"easbot",x]:/^cmd(\.exe)?$/i.test(
|
|
35
|
-
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${
|
|
36
|
-
${
|
|
37
|
-
`).filter(E=>E.trim()),then:(
|
|
38
|
-
${
|
|
39
|
-
`).filter(
|
|
40
|
-
`):t;for(let n=0;n<r.length;n++){let o=r[n];this.parseRule(o,n+1);}return this}parseRule(t,r){let n=t;if(n.length===0||n.startsWith("#"))return;let s=n.startsWith("!");if(s&&(n=n.slice(1)),n=n.trimEnd(),n.length===0)return;if(n.startsWith("\\#")){n=n.slice(1);return}if(n.startsWith("#"))return;let i=n.endsWith("/");if(i&&(n=n.slice(0,-1)),n.length===0)return;let l=this.patternToRegex(n);l&&this.rules.push({pattern:n,regex:l,negative:s,isDirectory:i,original:t,lineNumber:r});}ignores(t,r){let n=this.normalizePath(t),o=r??t.endsWith("/"),s=this.checkIgnore(n,o);return this.debug&&console.log(`Ignore.ignores("${t}", isDirectory=${o}) => ${s}`),s}checkIgnore(t,r){let n=false;for(let o of this.rules)o.isDirectory&&!r||o.regex.test(t)&&(o.negative?n=false:n=true);return n}filter(t){return t.filter(r=>!this.ignores(r))}createFilter(){return t=>!this.ignores(t)}patternToRegex(t){let r=[],n=0,o=t.length;for(;n<o;){let d=t[n];if(d==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),n+=2;continue}else {r.push("\\\\"),n++;continue}if(d==="*")if(n+1<o&&t[n+1]==="*")if(n+2<o&&t[n+2]==="/")if(n===0||t[n-1]==="/")if(n+3>=o){r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else if(n===0||t[n-1]==="/")if(n+2>=o){r.push(".*"),n+=2;continue}else {r.push("(?:/.*)*"),n+=2;continue}else {r.push(".*"),n+=2;continue}else {r.push("[^/]*"),n++;continue}if(d==="?"){r.push("[^/]"),n++;continue}if(d==="["){let c=this.findMatchingBracket(t,n);if(c!==-1){let u=t.slice(n,c+1);(u.startsWith("[!")||u.startsWith("[^"))&&(u="[^"+u.slice(2)),this.ignorecase&&(u=u.toLowerCase()),r.push(u),n=c+1;continue}}if(d==="/"){r.push("/"),n++;continue}if(".+$^{}|()".includes(d)){r.push("\\"+d),n++;continue}if(this.ignorecase&&d>="A"&&d<="Z"){r.push("["+d.toLowerCase()+d+"]"),n++;continue}r.push(d),n++;}let s=r.join(""),a=s.startsWith("/"),i=s.endsWith("/")&&!s.endsWith("\\/");a||(s="(?:.*/)?"+s),i&&(s=s.slice(0,-1)),!i&&!s.endsWith("(?:/.*)*")&&(s="(?:"+s+")(?:/.*)?");let l=this.ignorecase?"i":"";try{return new RegExp("^"+s+"$",l)}catch(d){return this.debug&&console.error(`Failed to create regex for pattern "${t}":`,d),null}}escapeRegexChar(t){return "\\[]{}().+^$|".includes(t)?"\\"+t:t}findMatchingBracket(t,r){let n=r+1,o=t.length;for((n>=o||t[n]==="!"||t[n]==="^")&&n++;n<o;){let s=t[n];if(s==="\\"&&n+1<o){n+=2;continue}if(s==="]")return n;if(n+2<o&&t[n+1]==="-"&&t[n+2]!=="]"){n+=3;continue}n++;}return -1}normalizePath(t){let r=t.replace(/\\/g,"/");if(r==="/")return "";for(;r.startsWith("./");)r=r.slice(2);return r}};chunkVRQQ33YH_cjs.j();function
|
|
41
|
-
`?o=i:/\s/.test(l)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function
|
|
33
|
+
${y}
|
|
34
|
+
`,"easbot",x]:/^cmd(\.exe)?$/i.test(w)?["/c",`chcp 65001 >nul 2>&1 && ${y}`]:N(w)?["-NoProfile","-Command",`[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${y}`]:["-c",y]}g.args=fe;function He(f){return f?d(f):(0, g.defaultPreferred)()}g.preferred=He;function On(f){return f?d(f,{acceptable:true}):(0, g.defaultAcceptable)()}g.acceptable=On;function Bn(){g.defaultPreferred.reset(),g.defaultAcceptable.reset();}g.reset=Bn;async function Fn(){return (process.platform==="win32"?i():await l()).filter(p=>a(p)).map(D)}g.list=Fn;function We(f){return ln[R(f)]}g.metaInfo=We;function $n(f){return /[|&;<>()$`!#]/.test(f)}g.needsShell=$n;function An(){return process.platform==="win32"?i():["/bin/bash","/bin/zsh","/bin/sh"]}g.platformShells=An;function Ln(f){return f?!!a(f):false}g.isValid=Ln;async function _n(f){let p=a(f);if(!p)return;let x=R(p);if(!/^cmd(\.exe)?$/i.test(x))try{let w;N(x)?w=["-NoProfile","-Command","$PSVersionTable.PSVersion.ToString()"]:w=["--version"],e.debug(`\u83B7\u53D6 Shell \u7248\u672C: ${p}`,{shell:p,args:w});let b=await exports.PKG.run([p,...w]);if(b.code===0){let y=b.stdout.trim().split(`
|
|
35
|
+
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${y}`),y}e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${b.code}`,{stderr:b.stderr});}catch(w){e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5F02\u5E38: ${w}`);}}g.version=_n;class Ue extends Error{constructor(x,w,b,y){super(x);chunkVRQQ33YH_cjs.c(this,"message",x);chunkVRQQ33YH_cjs.c(this,"pkg",w);chunkVRQQ33YH_cjs.c(this,"version",b);chunkVRQQ33YH_cjs.c(this,"originalError",y);this.name="InstallFailedError";}}g.InstallFailedError=Ue;async function jn(f,p="latest",x){let{Lock:w}=await import('./chunks/lock-LMCPTUNU.cjs'),{Filesystem:b}=await import('./chunks/filesystem-NRWL3JOL.cjs'),{PackageRegistry:y}=await import('./chunks/registry-6UFUNZP4.cjs');x=x??process.env.EASBOT_CACHE_PATH??ie__default.default.join(".easbot","cache");let E=await w.write("pkg-install");try{let v=ie__default.default.posix.join(x,"node_modules",f),P=ie__default.default.posix.join(x,"package.json"),_=(await b.readJson(P).catch(async()=>{let W={dependencies:{}};return await b.writeJson(P,W),W})).dependencies??{},B=await b.exists(v),j=_[f],I=!1;if(!B||!j)I=!0;else {if(p!=="latest"&&j===p)return v;if(p==="latest"){if(!await y.isOutdated(f,j,x))return v;e.info("Cached version is outdated, proceeding with install",{pkg:f,cachedVersion:j}),I=!0;}}if(!I)return v;let O=g.acceptable(process.platform==="win32"?"cmd":void 0)??S(),q=`${f}@${p}`;e.info("installing package",{pkg:f,version:p,cache:x,shell:O});let H=await exports.PKG.packageManager();if(!H)throw new Ue("No package manager found (npm, pnpm, bun)",f,p,"No package manager available");let V=H.name,pe=V==="pnpm"?"add":"install",qe=`${H.name} ${pe} --save-exact ${q}`;e.info(`Using ${V} to install package`,{pkg:f,version:p,shell:O,pmPath:H.path});try{let W=await g.run(O,qe,{cwd:x,timeout:6e5,windowsHide:!0});if(W.code!==0)throw new Error(`Package manager exited with code ${W.code}: ${W.stderr}`);e.info(`Successfully installed ${f}@${p} with ${V}`);}catch(W){let Ct=W instanceof Error?W:new Error(String(W));if(!await b.exists(v))throw new Ue(`Failed to install ${f}@${p}`,f,p,Ct.message);e.warn("Package install failed but module exists, continuing",{error:Ct.message});}let Ve=p;p==="latest"&&(Ve=(await b.readJson(ie__default.default.join(v,"package.json")).catch(()=>({})))?.version??"unknown");let ve=await b.readJson(P);return ve.dependencies=ve.dependencies??{},ve.dependencies[f]=Ve,await b.writeJson(P,ve),e.info("Package installation completed",{pkg:f,version:Ve,path:v}),v}finally{E[Symbol.dispose]();}}g.install=jn;async function Nn(f,p,x){let w=f?g.acceptable(f)??S():g.acceptable()??S(),b=x?.cwd??process.cwd(),y=g.args(w,p,b);e.debug(`run shell process: ${w} ${y.join(" ")}`,{command:p,cwd:b});let{windowsHide:E,env:v,...P}=x??{},C={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...v};process.platform==="win32"&&(C.CHCP="65001");let{stdin:_,stdout:B,stderr:j,timeout:I,signal:O,...q}=P??{},H={...q,cwd:b,env:C,windowsHide:process.platform==="win32"?E??true:void 0,shell:q.shell},V=R(w),pe=/^cmd(\.exe)?$/i.test(V),qe=process.platform==="win32"&&pe?"cmd":w;return exports.PKG.run([qe,...y],H)}g.run=Nn;function z(f,p,x){let w=f?g.acceptable(f)??S():g.acceptable()??S(),b=x?.cwd??process.cwd(),y=g.args(w,p,b);e.debug(`Spawn shell process: ${w} ${y.join(" ")}`,{command:p,cwd:b});let{windowsHide:E,env:v,...P}=x??{},C={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...v};process.platform==="win32"&&(C.CHCP="65001");let{stdin:_,stdout:B,stderr:j,timeout:I,signal:O,...q}=P??{},H=R(w),V=/^cmd(\.exe)?$/i.test(H),pe={...q,cwd:b,env:C,windowsHide:process.platform==="win32"?E??true:void 0,shell:q.shell};return exports.PKG.spawn([V?"cmd":w,...y],pe)}g.spawn=z;function k(f,...p){let x=f.reduce((b,y,E)=>b+y+(p[E]??""),""),w=(b={})=>({quiet:()=>w({...b,quiet:true}),nothrow:()=>w({...b,nothrow:true}),cwd:y=>w({...b,cwd:y}),env:y=>w({...b,env:y}),stdin:y=>w({...b,stdin:y}),stdout:y=>w({...b,stdout:y}),stderr:y=>w({...b,stderr:y}),text:async()=>{let y=Z(x.trim());if(y.length===0)throw new Error("Empty command");let E=y[0]??"",v=R(E),P=/^cmd(\.exe)?$/i.test(v),C=process.platform==="win32"&&P?"cmd":We(E)?E:void 0,_=oe(E,y.slice(1)),B=await g.run(C,_,{cwd:b.cwd,env:b.env,stdin:b.stdin,stdout:b.stdout,stderr:b.stderr,windowsHide:process.platform==="win32"?b.windowsHide??true:void 0,shell:b.shell});if(B.code!==0&&!b.nothrow)throw new Error(`Command failed with exit code ${B.code}: ${x}
|
|
36
|
+
${B.stderr}`);return B.stdout},lines:async()=>(await w(b).text()).split(`
|
|
37
|
+
`).filter(E=>E.trim()),then:(y,E)=>{let v=Z(x.trim()),P=v[0]??"",C=R(P),_=/^cmd(\.exe)?$/i.test(C),B=process.platform==="win32"&&_?"cmd":We(P)?P:void 0,j=oe(P,v.slice(1));return g.run(B,j,{cwd:b.cwd,env:b.env,stdin:b.stdin,stdout:b.stdout,stderr:b.stderr,windowsHide:process.platform==="win32"?b.windowsHide??true:void 0,shell:b.shell}).then(I=>{if(I.code!==0&&!b.nothrow){let O=new Error(`Command failed with exit code ${I.code}: ${x}
|
|
38
|
+
${I.stderr}`);if(E){E(O);return}throw O}return y({exitCode:I.code,stdout:new TextEncoder().encode(I.stdout),stderr:new TextEncoder().encode(I.stderr),text:()=>I.stdout,lines:()=>I.stdout.split(`
|
|
39
|
+
`).filter(O=>O.trim())})},E)}});return w()}g.$=k;})(exports.Shell||(exports.Shell={}));var kr=exports.Shell.$;chunkVRQQ33YH_cjs.j();function rt(e,t=true){let r=typeof e=="number"?new Date(e):e,n=r.getTimezoneOffset(),o=Math.floor(Math.abs(n)/60),s=Math.abs(n)%60,i=`${n<=0?"+":"-"}${String(o).padStart(2,"0")}:${String(s).padStart(2,"0")}`,l=r.getFullYear(),d=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0"),u=String(r.getHours()).padStart(2,"0"),m=String(r.getMinutes()).padStart(2,"0"),S=String(r.getSeconds()).padStart(2,"0"),R=`${l}-${d}-${c}T${u}:${m}:${S}`;if(t){let A=String(r.getMilliseconds()).padStart(3,"0");R+=`.${A}`;}return R+=i,R}function vr(e){return rt(e,false)}function cn(){return Date.now()}function Tr(e=true){return rt(cn(),e)}function Mr(e){return e.includes("+")||e.includes("-")?new Date(e):new Date(e)}function Rr(e){let t=typeof e=="number"?new Date(e):e,r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return `${r}-${n}-${o}T${s}:${a}:${i}`}function Pr(e=new Date){let t=e.getTimezoneOffset(),r=Math.floor(Math.abs(t)/60),n=Math.abs(t)%60;return `${t<=0?"+":"-"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`}chunkVRQQ33YH_cjs.j();var he=class he extends Error{static create(t,r){var s;let n=Ce__default.default.object({name:Ce__default.default.literal(t),data:r}).meta({ref:t}),o=(s=class extends he{constructor(i,l){super(t,l);chunkVRQQ33YH_cjs.c(this,"data",i);chunkVRQQ33YH_cjs.c(this,"name",t);this.name=t;}static isInstance(i){return typeof i=="object"&&"name"in i&&i.name===t}schema(){return n}toObject(){return {name:t,data:this.data}}},chunkVRQQ33YH_cjs.c(s,"Schema",n),s);return Object.defineProperty(o,"name",{value:t}),o}};chunkVRQQ33YH_cjs.c(he,"Unknown",he.create("UnknownError",Ce__default.default.object({message:Ce__default.default.string()})));var ot=he;chunkVRQQ33YH_cjs.j();exports.Ignore=void 0;(t=>{function e(r){return new it(r)}t.create=e;})(exports.Ignore||(exports.Ignore={}));var it=class{constructor(t){chunkVRQQ33YH_cjs.c(this,"rules",[]);chunkVRQQ33YH_cjs.c(this,"ignorecase");chunkVRQQ33YH_cjs.c(this,"debug");this.ignorecase=t?.ignorecase??false,this.debug=t?.debug??false;}add(t){let r=typeof t=="string"?t.split(`
|
|
40
|
+
`):t;for(let n=0;n<r.length;n++){let o=r[n];this.parseRule(o,n+1);}return this}parseRule(t,r){let n=t;if(n.length===0||n.startsWith("#"))return;let s=n.startsWith("!");if(s&&(n=n.slice(1)),n=n.trimEnd(),n.length===0)return;if(n.startsWith("\\#")){n=n.slice(1);return}if(n.startsWith("#"))return;let i=n.endsWith("/");if(i&&(n=n.slice(0,-1)),n.length===0)return;let l=this.patternToRegex(n);l&&this.rules.push({pattern:n,regex:l,negative:s,isDirectory:i,original:t,lineNumber:r});}ignores(t,r){let n=this.normalizePath(t),o=r??t.endsWith("/"),s=this.checkIgnore(n,o);return this.debug&&console.log(`Ignore.ignores("${t}", isDirectory=${o}) => ${s}`),s}checkIgnore(t,r){let n=false;for(let o of this.rules)o.isDirectory&&!r||o.regex.test(t)&&(o.negative?n=false:n=true);return n}filter(t){return t.filter(r=>!this.ignores(r))}createFilter(){return t=>!this.ignores(t)}patternToRegex(t){let r=[],n=0,o=t.length;for(;n<o;){let d=t[n];if(d==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),n+=2;continue}else {r.push("\\\\"),n++;continue}if(d==="*")if(n+1<o&&t[n+1]==="*")if(n+2<o&&t[n+2]==="/")if(n===0||t[n-1]==="/")if(n+3>=o){r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else if(n===0||t[n-1]==="/")if(n+2>=o){r.push(".*"),n+=2;continue}else {r.push("(?:/.*)*"),n+=2;continue}else {r.push(".*"),n+=2;continue}else {r.push("[^/]*"),n++;continue}if(d==="?"){r.push("[^/]"),n++;continue}if(d==="["){let c=this.findMatchingBracket(t,n);if(c!==-1){let u=t.slice(n,c+1);(u.startsWith("[!")||u.startsWith("[^"))&&(u="[^"+u.slice(2)),this.ignorecase&&(u=u.toLowerCase()),r.push(u),n=c+1;continue}}if(d==="/"){r.push("/"),n++;continue}if(".+$^{}|()".includes(d)){r.push("\\"+d),n++;continue}if(this.ignorecase&&d>="A"&&d<="Z"){r.push("["+d.toLowerCase()+d+"]"),n++;continue}r.push(d),n++;}let s=r.join(""),a=s.startsWith("/"),i=s.endsWith("/")&&!s.endsWith("\\/");a||(s="(?:.*/)?"+s),i&&(s=s.slice(0,-1)),!i&&!s.endsWith("(?:/.*)*")&&(s="(?:"+s+")(?:/.*)?");let l=this.ignorecase?"i":"";try{return new RegExp("^"+s+"$",l)}catch(d){return this.debug&&console.error(`Failed to create regex for pattern "${t}":`,d),null}}escapeRegexChar(t){return "\\[]{}().+^$|".includes(t)?"\\"+t:t}findMatchingBracket(t,r){let n=r+1,o=t.length;for((n>=o||t[n]==="!"||t[n]==="^")&&n++;n<o;){let s=t[n];if(s==="\\"&&n+1<o){n+=2;continue}if(s==="]")return n;if(n+2<o&&t[n+1]==="-"&&t[n+2]!=="]"){n+=3;continue}n++;}return -1}normalizePath(t){let r=t.replace(/\\/g,"/");if(r==="/")return "";for(;r.startsWith("./");)r=r.slice(2);return r}};chunkVRQQ33YH_cjs.j();function un(e,t){let r=n=>{let o;try{o=e.parse(n);}catch(s){throw console.trace("schema validation failure stack trace:"),s instanceof Ce.z.ZodError&&console.error("schema validation issues:",JSON.stringify(s.issues,null,2)),s}return t(o)};return r.force=n=>t(n),r.schema=e,r}var Cr=un;exports.Fn=void 0;(t=>t.fn=un)(exports.Fn||(exports.Fn={}));chunkVRQQ33YH_cjs.j();function Fr(){let r=ie__default.default.join(process.cwd(),".env");Ee.existsSync(r)&&dotenv.config({path:r,override:true,debug:false,encoding:"utf-8",quiet:true});}chunkVRQQ33YH_cjs.j();async function $r(e,t){if(process.env.EASBOT_CLIENT==="acp")try{let s=process.platform==="win32"?"cmd":void 0,a=exports.Shell.spawn(s,`git ${e.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:t.cwd,env:t.env?{...process.env,...t.env}:process.env}),[i,l,d]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),u=Buffer.from(d);return {exitCode:i,text:()=>c.toString(),stdout:c,stderr:u}}catch(s){let a=Buffer.from(s instanceof Error?s.message:String(s));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:a}}let r=t.env?{...process.env,...t.env}:void 0,n=exports.Shell.$`git ${e.join(" ")}`.quiet().nothrow().cwd(t.cwd);r&&(n=n.env(r));let o=await n;return {exitCode:o.exitCode,text:()=>o.text(),stdout:o.stdout,stderr:o.stderr}}chunkVRQQ33YH_cjs.j();function fn(e){return e?ie.dirname(url.fileURLToPath(e)):typeof __dirname<"u"?__dirname:process.cwd()}function dn(e,t,r=3){function n(o,s){if(s>r||!Ee.existsSync(o))return null;try{let a=Ee.readdirSync(o);for(let i of a){let l=ie.join(o,i);try{let d=Ee.statSync(l);if(d.isFile()&&l.endsWith(t))return l;if(d.isDirectory()&&s<r){let c=n(l,s+1);if(c)return c}}catch{}}}catch{}return null}return n(e,0)}function pn(e,t){let r=ie.join(e,t);if(Ee.existsSync(r))return r;let n=t.split("/").pop()||t,o=e;for(let s=0;s<5;s++){let a=ie.join(o,"assets","txt");if(Ee.existsSync(a)){let d=dn(a,n,5);if(d)return d}let i=ie.join(o,"dist","assets","txt");if(Ee.existsSync(i)){let d=dn(i,n,5);if(d)return d}let l=ie.join(o,"..");if(l===o)break;o=l;}return r}function Nr(e,t){return exports.Lazy.lazy(()=>{try{let r=fn(t),n=pn(r,e);return exports.PKG.file(n).textSync()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}function Dr(e,t){return exports.Lazy.lazy(async()=>{try{let r=fn(t),n=pn(r,e);return await exports.PKG.file(n).text()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}chunkVRQQ33YH_cjs.j();function zr(e){return e()}chunkVRQQ33YH_cjs.j();function Hr(e){if(!e||typeof e!="string")return {provider:"",model:""};let t=e.indexOf("/");return t===-1?{provider:"",model:e}:{provider:e.substring(0,t),model:e.substring(t+1)}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function lt(e,t,r,n=()=>true){let o=-1,s=-1,a=0;for(let i=t;i<r;i++){if(!n(i))continue;let l=e[i];if(l){if(l==="("){a+=1;continue}if(l===")"&&a>0){a-=1;continue}a===0&&(l===`
|
|
41
|
+
`?o=i:/\s/.test(l)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function Wr(e,t){if(!e)return [];if(t<=0)return [e];if(e.length<=t)return [e]}function ae(e,t,r){try{let n=Ce.z.string().parse(e),o=Ce.z.number().int().parse(t),s=Wr(n,o);if(s)return s;let a=ct(n,o,i=>{let{lastNewline:l,lastWhitespace:d}=lt(i,0,i.length);return l>0?l:d});return r?.minLength&&r.minLength>0&&(a=gn(a,r.minLength)),a}catch(n){return console.warn("Invalid input for chunkText:",n),typeof e=="string"&&e.length>0?[e]:[]}}function gn(e,t){if(e.length<=1||t<=0)return e;let r=[],n=e[0]??"";for(let o=1;o<e.length;o++){let s=e[o]??"";n.length<t?n=n+`
|
|
42
42
|
|
|
43
43
|
`+s:(r.push(n),n=s);}if(n.length>0)if(n.length<t&&r.length>0){let o=r.pop();r.push(o+`
|
|
44
44
|
|
|
45
|
-
`+n);}else r.push(n);return r}function
|
|
45
|
+
`+n);}else r.push(n);return r}function ct(e,t,r){if(!e)return [];if(t<=0||e.length<=t)return [e];let n=[],o=e;for(;o.length>t;){let s=o.slice(0,t),a=r(s),i=Number.isFinite(a)&&a>0&&a<=t?a:t,d=o.slice(0,i).trimEnd();d.length>0&&n.push(d);let c=i<o.length&&o[i]!==void 0&&/\s/.test(o[i]),u=Math.min(o.length,i+(c?1:0));o=o.slice(u).trimStart();}return o.length>0&&n.push(o),n}chunkVRQQ33YH_cjs.j();var ut=Ce.z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),hn=Ce.z.object({start:Ce.z.number().int().min(0),end:Ce.z.number().int().min(0),style:ut}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),bn=Ce.z.object({start:Ce.z.number().int().min(0),end:Ce.z.number().int().min(0),href:Ce.z.string().min(1)}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),xe=Ce.z.object({text:Ce.z.string(),styles:Ce.z.array(hn),links:Ce.z.array(bn)}).strict(),we=Ce.z.enum(["off","bullets","code"]),Oe=Ce.z.object({linkify:Ce.z.boolean().default(true),enableSpoilers:Ce.z.boolean().default(false),headingStyle:Ce.z.enum(["none","bold"]).default("none"),blockquotePrefix:Ce.z.string().default(""),autolink:Ce.z.boolean().default(true),tableMode:we.default("off")}).partial().default({}),xn=Ce.z.object({open:Ce.z.string(),close:Ce.z.string()}).strict(),dt=Ce.z.object({styleMarkers:Ce.z.record(ut,xn).optional(),escapeText:Ce.z.any().optional(),buildLink:Ce.z.any().optional()}).strict();Ce.z.object({start:Ce.z.number().int().min(0),end:Ce.z.number().int().min(0),open:Ce.z.string(),close:Ce.z.string()}).strict();var ft=Ce.z.object({indentSize:Ce.z.number().int().min(1).default(2),listMarker:Ce.z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:Ce.z.enum(["```","~~~"]).default("```"),preserveFrontmatter:Ce.z.boolean().default(true)}).strict(),pt=Ce.z.record(Ce.z.string(),Ce.z.string()),Be=Ce.z.object({open:Ce.z.boolean(),ticks:Ce.z.number().int().min(0)}).strict();Ce.z.object({inlineState:Be,isInside:Ce.z.any()}).strict();Ce.z.object({start:Ce.z.number().int().min(0),end:Ce.z.number().int().min(0),openLine:Ce.z.string(),marker:Ce.z.string(),indent:Ce.z.string()}).strict();Ce.z.object({tables:we.optional()}).strict();function Jr(e){let t=new Yr__default.default({html:false,linkify:e.linkify??true,breaks:false,typographer:false});return t.enable("strikethrough"),e.tableMode&&e.tableMode!=="off"?t.enable("table"):t.disable("table"),e.autolink===false&&t.disable("autolink"),t}function wn(e,t){if(e.attrGet)return e.attrGet(t);if(e.attrs){for(let[r,n]of e.attrs)if(r===t)return n}return null}function mt(e,t){return {...e,type:"text",content:t,children:void 0}}function Zr(e){for(let t of e)t.children&&t.children.length>0&&(t.children=Kr(t.children));}function Kr(e){let t=0;for(let a of e){if(a.type!=="text")continue;let i=a.content??"",l=0;for(;l<i.length;){let d=i.indexOf("||",l);if(d===-1)break;t+=1,l=d+2;}}if(t<2)return e;let r=t-t%2,n=[],o={spoilerOpen:false},s=0;for(let a of e){if(a.type!=="text"){n.push(a);continue}let i=a.content??"";if(!i.includes("||")){n.push(a);continue}let l=0;for(;l<i.length;){let d=i.indexOf("||",l);if(d===-1){l<i.length&&n.push(mt(a,i.slice(l)));break}if(s>=r){n.push(mt(a,i.slice(l)));break}d>l&&n.push(mt(a,i.slice(l,d))),s+=1,o.spoilerOpen=!o.spoilerOpen,n.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=d+2;}}return n}function Xr(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function ne(e){return e.table?.currentCell??e}function Fe(e,t){if(!t)return;let r=ne(e);r.text+=t;}function le(e,t){let r=ne(e);r.openStyles.push({style:t,start:r.text.length});}function ce(e,t){let r=ne(e);for(let n=r.openStyles.length-1;n>=0;n-=1){let o=r.openStyles[n];if(o?.style===t){let s=o.start;r.openStyles.splice(n,1);let a=r.text.length;a>s&&r.styles.push({start:s,end:a,style:t});return}}}function yn(e){e.env.listStack.length>0||e.table||(e.text+=`
|
|
46
46
|
|
|
47
|
-
`);}function
|
|
48
|
-
`);}function
|
|
49
|
-
`;}for(let a=1;a<o.length;a++)
|
|
50
|
-
`;}else for(let o of r){for(let s=0;s<o.length;s++)
|
|
51
|
-
`;}}function
|
|
47
|
+
`);}function Qr(e){let t=e.env.listStack,r=t[t.length-1];if(!r)return;r.index+=1;let n=" ".repeat(Math.max(0,t.length-1)),o=r.type==="ordered"?`${r.index}. `:"\u2022 ";e.text+=`${n}${o}`;}function eo(e,t){if(!t)return;let r=ne(e),n=r.text.length;r.text+=t,r.styles.push({start:n,end:n+t.length,style:"code"});}function to(e,t){let r=t??"",n=ne(e),o=n.text.length;n.text+=r,n.styles.push({start:o,end:o+r.length,style:"code_block"});}function no(e){let t=ne(e),r=t.linkStack.pop();if(!r?.href)return;let n=r.href.trim();if(!n)return;let o=r.labelStart,s=t.text.length;if(s<=o){t.links.push({start:o,end:s,href:n});return}t.links.push({start:o,end:s,href:n});}function ro(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function oo(e){return kn(e),{text:e.text,styles:e.styles,links:e.links}}function $e(e){let t=e.text,r=0,n=t.length;for(;r<n&&/\s/.test(t[r]??"");)r+=1;for(;n>r&&/\s/.test(t[n-1]??"");)n-=1;if(r===0&&n===t.length)return e;let o=t.slice(r,n),s=o.length,a=[];for(let l of e.styles){let d=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>d&&a.push({start:d,end:c,style:l.style});}let i=[];for(let l of e.links){let d=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>d&&i.push({start:d,end:c,href:l.href});}return {text:o,styles:a,links:i}}function gt(e,t){if(!t.text)return;let r=e.text.length;e.text+=t.text;for(let n of t.styles)e.styles.push({start:r+n.start,end:r+n.end,style:n.style});for(let n of t.links)e.links.push({start:r+n.start,end:r+n.end,href:n.href});}function so(e,t){t.text&&(e.text+=t.text);}function Sn(e,t){let{header:r,value:n,columnIndex:o,includeColumnFallback:s}=t;n?.text&&(e.text+="\u2022 ",r?.text?(gt(e,r),e.text+=": "):s&&(e.text+=`Column ${o}: `),gt(e,n),e.text+=`
|
|
48
|
+
`);}function io(e){if(!e.table)return;let t=e.table.headers.map($e),r=e.table.rows.map(o=>o.map($e));if(t.length===0&&r.length===0)return;if(t.length>1&&r.length>0)for(let o of r){if(o.length===0)continue;let s=o[0];if(s?.text){let a=e.text.length;gt(e,s);let i=e.text.length;i>a&&e.styles.push({start:a,end:i,style:"bold"}),e.text+=`
|
|
49
|
+
`;}for(let a=1;a<o.length;a++)Sn(e,{header:t[a],value:o[a],columnIndex:a,includeColumnFallback:true});e.text+=`
|
|
50
|
+
`;}else for(let o of r){for(let s=0;s<o.length;s++)Sn(e,{header:t[s],value:o[s],columnIndex:s,includeColumnFallback:false});e.text+=`
|
|
51
|
+
`;}}function ao(e){if(!e.table)return;let t=e.table.headers.map($e),r=e.table.rows.map(c=>c.map($e)),n=Math.max(t.length,...r.map(c=>c.length));if(n===0)return;let o=Array.from({length:n},()=>0),s=c=>{for(let u=0;u<n;u+=1){let S=c[u]?.text.length??0;(o[u]??0)<S&&(o[u]=S);}};s(t);for(let c of r)s(c);let a=e.text.length,i=c=>{e.text+="|";for(let u=0;u<n;u+=1){e.text+=" ";let m=c[u];m&&so(e,m);let S=m?.text.length??0,A=(o[u]??0)-S;A>0&&(e.text+=" ".repeat(A)),e.text+=" |";}e.text+=`
|
|
52
52
|
`;},l=()=>{e.text+="|";for(let c=0;c<n;c+=1){let u=o[c]??0,m=Math.max(3,u);e.text+=` ${"-".repeat(m)} |`;}e.text+=`
|
|
53
|
-
`;};i(t),l();for(let c of r)i(c);let d=e.text.length;d>a&&e.styles.push({start:a,end:d,style:"code_block"});}function
|
|
54
|
-
`);break;case "paragraph_close":
|
|
53
|
+
`;};i(t),l();for(let c of r)i(c);let d=e.text.length;d>a&&e.styles.push({start:a,end:d,style:"code_block"});}function ht(e,t){for(let r of e)switch(r.type){case "inline":r.children&&ht(r.children,t);break;case "text":Fe(t,r.content??"");break;case "em_open":le(t,"italic");break;case "em_close":ce(t,"italic");break;case "strong_open":le(t,"bold");break;case "strong_close":ce(t,"bold");break;case "s_open":le(t,"strikethrough");break;case "s_close":ce(t,"strikethrough");break;case "code_inline":eo(t,r.content??"");break;case "spoiler_open":t.enableSpoilers&&le(t,"spoiler");break;case "spoiler_close":t.enableSpoilers&&ce(t,"spoiler");break;case "link_open":{let n=wn(r,"href")??"",o=ne(t);o.linkStack.push({href:n,labelStart:o.text.length});break}case "link_close":no(t);break;case "image":Fe(t,r.content??"");break;case "softbreak":case "hardbreak":Fe(t,`
|
|
54
|
+
`);break;case "paragraph_close":yn(t);break;case "heading_open":t.headingStyle==="bold"&&le(t,"bold");break;case "heading_close":t.headingStyle==="bold"&&ce(t,"bold"),yn(t);break;case "blockquote_open":t.blockquotePrefix&&(t.text+=t.blockquotePrefix),le(t,"blockquote");break;case "blockquote_close":ce(t,"blockquote");break;case "bullet_list_open":t.env.listStack.length>0&&(t.text+=`
|
|
55
55
|
`),t.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":t.env.listStack.pop(),t.env.listStack.length===0&&(t.text+=`
|
|
56
56
|
`);break;case "ordered_list_open":{t.env.listStack.length>0&&(t.text+=`
|
|
57
|
-
`);let n=Number(
|
|
58
|
-
`);break;case "list_item_open":
|
|
57
|
+
`);let n=Number(wn(r,"start")??"1");t.env.listStack.push({type:"ordered",index:n-1});break}case "ordered_list_close":t.env.listStack.pop(),t.env.listStack.length===0&&(t.text+=`
|
|
58
|
+
`);break;case "list_item_open":Qr(t);break;case "list_item_close":t.text.endsWith(`
|
|
59
59
|
`)||(t.text+=`
|
|
60
|
-
`);break;case "code_block":case "fence":
|
|
60
|
+
`);break;case "code_block":case "fence":to(t,r.content??"");break;case "html_block":case "html_inline":Fe(t,r.content??"");break;case "table_open":t.tableMode!=="off"&&(t.table=ro(),t.hasTables=true);break;case "table_close":t.table&&(t.tableMode==="bullets"?io(t):t.tableMode==="code"&&ao(t)),t.table=null;break;case "thead_open":t.table&&(t.table.inHeader=true);break;case "thead_close":t.table&&(t.table.inHeader=false);break;case "tbody_open":case "tbody_close":break;case "tr_open":t.table&&(t.table.currentRow=[]);break;case "tr_close":t.table&&(t.table.inHeader?t.table.headers=t.table.currentRow:t.table.rows.push(t.table.currentRow),t.table.currentRow=[]);break;case "th_open":case "td_open":t.table&&(t.table.currentCell=Xr());break;case "th_close":case "td_close":t.table?.currentCell&&(t.table.currentRow.push(oo(t.table.currentCell)),t.table.currentCell=null);break;case "hr":t.text+=`\u2500\u2500\u2500
|
|
61
61
|
|
|
62
|
-
`;break;default:r.children&&
|
|
63
|
-
`);let
|
|
62
|
+
`;break;default:r.children&&ht(r.children,t);break}}function kn(e){for(let t=e.openStyles.length-1;t>=0;t-=1){let r=e.openStyles[t];if(!r)continue;let n=e.text.length;n>r.start&&e.styles.push({start:r.start,end:n,style:r.style});}e.openStyles=[];}function lo(e,t){let r=[];for(let n of e){let o=Math.max(0,Math.min(n.start,t)),s=Math.max(o,Math.min(n.end,t));s>o&&r.push({start:o,end:s,style:n.style});}return r}function co(e,t){let r=[];for(let n of e){let o=Math.max(0,Math.min(n.start,t)),s=Math.max(o,Math.min(n.end,t));s>o&&r.push({start:o,end:s,href:n.href});}return r}function vn(e){let t=[...e].toSorted((n,o)=>n.start!==o.start?n.start-o.start:n.end!==o.end?n.end-o.end:n.style.localeCompare(o.style)),r=[];for(let n of t){let o=r[r.length-1];if(o&&o.style===n.style&&(n.start<o.end||n.start===o.end&&n.style!=="blockquote")){o.end=Math.max(o.end,n.end);continue}r.push({...n});}return r}function Tn(e,t,r){let n=Math.max(e.start,t),o=Math.min(e.end,r);return o<=n?null:{start:n,end:o}}function uo(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Tn(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,style:o.style});}return vn(n)}function fo(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Tn(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,href:o.href});}return n}function ue(e,t){try{let r=typeof e=="string"?e:"",n=Oe.parse(t??{});return ye(r,n).ir}catch(r){return console.error("Markdown parse error:",r),{text:"",styles:[],links:[]}}}function ye(e,t){try{let r=typeof e=="string"?e:"",n=Oe.parse(t),o={listStack:[]},a=Jr(n).parse(r||"",o);n.enableSpoilers&&Zr(a);let i=n.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:n.headingStyle??"none",blockquotePrefix:n.blockquotePrefix??"",enableSpoilers:n.enableSpoilers??!1,tableMode:i,table:null,hasTables:!1};ht(a,l),kn(l);let c=l.text.trimEnd().length,u=0;for(let R of l.styles)R.style==="code_block"&&R.end>u&&(u=R.end);let m=Math.max(c,u);return {ir:{text:m===l.text.length?l.text:l.text.slice(0,m),styles:vn(lo(l.styles,m)),links:co(l.links,m)},hasTables:l.hasTables}}catch(r){return console.error("Markdown parse error:",r),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function Mn(e,t){try{let r=xe.parse(e),n=typeof t=="number"&&t>0?t:0;if(!r.text)return [];if(n<=0||r.text.length<=n)return [r];let o=ae(r.text,n),s=[],a=0;return o.forEach((i,l)=>{if(!i)return;if(l>0)for(;a<r.text.length&&/\s/.test(r.text[a]??"");)a+=1;let d=a,c=Math.min(r.text.length,d+i.length);s.push({text:i,styles:uo(r.styles,d,c),links:fo(r.links,d,c)}),a=c;}),s}catch(r){return console.error("Chunk IR error:",r),[]}}chunkVRQQ33YH_cjs.j();var po={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Se(e,t){try{let r=xe.parse(e),n=dt.parse(t??{});if(!r.text)return "";let o=n.styleMarkers??po,s=n.escapeText??(u=>u),a=n.buildLink,i=[];for(let u=0;u<r.styles.length;u++){let m=r.styles[u];m&&(i.push({position:m.start,type:"open",style:m.style,spanIndex:u}),i.push({position:m.end,type:"close",style:m.style,spanIndex:u}));}for(let u=0;u<r.links.length;u++){let m=r.links[u];m&&(i.push({position:m.start,type:"link_open",spanIndex:u,href:m.href}),i.push({position:m.end,type:"link_close",spanIndex:u,href:m.href}));}i.sort((u,m)=>{if(u.position!==m.position)return u.position-m.position;let S=(D,fe)=>D==="link_open"?0:D==="open"?1:D==="close"?2:D==="link_close"?3:4,R=u.type==="close"||u.type==="link_close",A=m.type==="close"||m.type==="link_close",L=S(u.type,R),N=S(m.type,A);return L!==N?L-N:u.type==="open"&&m.type==="open"?u.spanIndex-m.spanIndex:u.type==="close"&&m.type==="close"?m.spanIndex-u.spanIndex:u.spanIndex-m.spanIndex});let l="",d=0,c=[];for(let u of i){if(u.position>d){let m=r.text.slice(d,u.position);l+=s?s(m):m;}if(u.type==="open"||u.type==="close"){let m=o[u.style];if(m)if(u.type==="open")l+=m.open,c.push(u);else {l+=m.close,u.style==="code_block"&&u.position<r.text.length&&(l+=`
|
|
63
|
+
`);let S=c.findIndex(R=>R.spanIndex===u.spanIndex&&R.type==="open");S!==-1&&c.splice(S,1);}}else if(u.type==="link_open")l+="[",c.push(u);else if(u.type==="link_close"){l+="]("+u.href+")";let m=c.findIndex(S=>S.spanIndex===u.spanIndex&&S.type==="link_open");m!==-1&&c.splice(m,1);}d=u.position;}if(d<r.text.length){let u=r.text.slice(d);l+=s?s(u):u;}return l}catch(r){return console.error("Markdown render error:",r),""}}function de(e,t){return Se(e,t)}chunkVRQQ33YH_cjs.j();function mo(e){let t=e.replace(/\r\n/g,`
|
|
64
64
|
`).replace(/\r/g,`
|
|
65
65
|
`);if(!t.startsWith("---"))return {frontmatter:"",content:e};let r=t.indexOf(`
|
|
66
|
-
---`,3);if(r===-1)return {frontmatter:"",content:e};let n=t.slice(0,r+4),o=t.slice(r+4).trimStart();return {frontmatter:n,content:o}}function
|
|
66
|
+
---`,3);if(r===-1)return {frontmatter:"",content:e};let n=t.slice(0,r+4),o=t.slice(r+4).trimStart();return {frontmatter:n,content:o}}function Ae(e,t){try{let r=typeof e=="string"?e:"",n=ft.parse(t??{});if(!r)return "";let{frontmatter:o,content:s}=mo(r),a=ue(s,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),i=de(a);return i=i.replace(/\n{3,}/g,`
|
|
67
67
|
|
|
68
68
|
`),i=i.trimEnd()+`
|
|
69
69
|
`,n.preserveFrontmatter&&o&&(i=o+`
|
|
70
|
-
`+i),i}catch(r){return console.error("Markdown format error:",r),e}}chunkVRQQ33YH_cjs.j();function
|
|
71
|
-
`).trim(),linesConsumed:n-t}}function
|
|
72
|
-
`),n=0;for(;n<r.length;){let o=r[n];if(!o){n+=1;continue}let s=o.match(/^([\w-]+):\s*(.*)$/);if(!s?.[1]||!s[2]){n+=1;continue}let a=s[1],i=s[2].trim();if(!a){n+=1;continue}if(!i&&n+1<r.length){let d=r[n+1];if(d&&(d.startsWith(" ")||d.startsWith(" "))){let{value:c,linesConsumed:u}=
|
|
70
|
+
`+i),i}catch(r){return console.error("Markdown format error:",r),e}}chunkVRQQ33YH_cjs.j();function go(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function ho(e){if(e!=null){if(typeof e=="string")return {value:e.trim(),kind:"scalar"};if(typeof e=="number"||typeof e=="boolean")return {value:String(e),kind:"scalar"};if(typeof e=="object")try{return {value:JSON.stringify(e),kind:"structured"}}catch{return}}}function bo(e){try{let t=Rn__default.default.parse(e,{schema:"core"});if(!t||typeof t!="object"||Array.isArray(t))return null;let r={};for(let[n,o]of Object.entries(t)){let s=n.trim();if(!s)continue;let a=ho(o);a&&(r[s]=a);}return r}catch{return null}}function xo(e,t){let r=[],n=t+1;for(;n<e.length;){let s=e[n];if(!s){n+=1;continue}if(s.length>0&&!s.startsWith(" ")&&!s.startsWith(" "))break;r.push(s),n+=1;}return {value:r.join(`
|
|
71
|
+
`).trim(),linesConsumed:n-t}}function wo(e){let t={},r=e.split(`
|
|
72
|
+
`),n=0;for(;n<r.length;){let o=r[n];if(!o){n+=1;continue}let s=o.match(/^([\w-]+):\s*(.*)$/);if(!s?.[1]||!s[2]){n+=1;continue}let a=s[1],i=s[2].trim();if(!a){n+=1;continue}if(!i&&n+1<r.length){let d=r[n+1];if(d&&(d.startsWith(" ")||d.startsWith(" "))){let{value:c,linesConsumed:u}=xo(r,n);c&&(t[a]={value:c,kind:"multiline",rawInline:i}),n+=u;continue}}let l=go(i);l&&(t[a]={value:l,kind:"inline",rawInline:i}),n+=1;}return t}function yo(e){let t={};for(let[r,n]of Object.entries(e))t[r]=n.value;return t}function So(e){return /^[|>][+-]?(\d+)?[+-]?$/.test(e)}function ko(e){let{lineEntry:t,yamlValue:r}=e;return r.kind!=="structured"||t.kind!=="inline"||So(t.rawInline)?false:t.value.includes(":")}function vo(e){let t=e.replace(/\r\n/g,`
|
|
73
73
|
`).replace(/\r/g,`
|
|
74
74
|
`);if(!t.startsWith("---"))return;let r=t.indexOf(`
|
|
75
|
-
---`,3);if(r!==-1)return t.slice(4,r)}function ke(e){try{if(typeof e!="string")return {};let t=
|
|
76
|
-
${
|
|
75
|
+
---`,3);if(r!==-1)return t.slice(4,r)}function ke(e){try{if(typeof e!="string")return {};let t=vo(e);if(!t)return {};let r=wo(t),n=bo(t);if(n===null)return yo(r);let o={};for(let[s,a]of Object.entries(n)){o[s]=a.value;let i=r[s];i&&ko({lineEntry:i,yamlValue:a})&&(o[s]=i.value);}for(let[s,a]of Object.entries(r))s in o||(o[s]=a.value);return o}catch(t){return console.warn("Failed to parse frontmatter:",t),{}}}function Le(e){try{let t=pt.parse(e);if(Object.keys(t).length===0)return "";let r={};for(let[o,s]of Object.entries(t))try{let a=JSON.parse(s);r[o]=a;}catch{r[o]=s;}return `---
|
|
76
|
+
${Rn__default.default.stringify(r,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
77
77
|
---`}catch(t){return console.warn("Failed to serialize frontmatter:",t),""}}function _e(e){try{if(typeof e!="string")return {frontmatter:{},content:""};let t=e.replace(/\r\n/g,`
|
|
78
78
|
`).replace(/\r/g,`
|
|
79
79
|
`);if(!t.startsWith("---"))return {frontmatter:{},content:e};let r=t.indexOf(`
|
|
80
80
|
---`,3);if(r===-1)return {frontmatter:{},content:e};let n=t.slice(4,r),o=t.slice(r+4).trimStart();return {frontmatter:ke(e),content:o}}catch(t){return console.warn("Failed to extract frontmatter:",t),{frontmatter:{},content:e}}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function je(e){try{let t=Ce.z.string().parse(e),r=[],n,o=0;for(;o<=t.length;){let s=t.indexOf(`
|
|
81
|
-
`,o),a=s===-1?t.length:s,i=t.slice(o,a),l=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let d=l[1],c=l[2];if(!d||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let m=c.length;if(!n)n={start:o,markerChar:u,markerLen:m,openLine:i,marker:c,indent:d};else if(n.markerChar===u&&m>=n.markerLen){let y=a;r.push({start:n.start,end:y,openLine:n.openLine,marker:n.marker,indent:n.indent}),n=void 0;}}if(s===-1)break;o=s+1;}return n&&r.push({start:n.start,end:t.length,openLine:n.openLine,marker:n.marker,indent:n.indent}),r}catch(t){return console.warn("Invalid input for parseFenceSpans:",t),[]}}function mt(e,t){let r=0,n=e.length-1;for(;r<=n;){let o=Math.floor((r+n)/2),s=e[o];if(!s)break;if(t<=s.start){n=o-1;continue}if(t>=s.end){r=o+1;continue}return s}}function Mn(e,t){return !mt(e,t)}function De(){return {open:false,ticks:0}}function Ne(e,t){try{let r=Ce.z.string().parse(e),n=t?Fe.parse(t):De(),o=je(r),s={open:n.open,ticks:n.ticks},{spans:a,state:i}=To(r,o,s);return {inlineState:i,isInside:l=>Ro(l,o)||Po(l,a)}}catch(r){return console.warn("Invalid input for buildCodeSpanIndex:",r),{inlineState:De(),isInside:()=>false}}}function To(e,t,r){let n=[],o=r.open,s=r.ticks,a=o?0:-1,i=0;for(;i<e.length;){let l=Mo(t,i);if(l){i=l.end;continue}if(e[i]!=="`"){i+=1;continue}let d=i,c=0;for(;i<e.length&&e[i]==="`";)c+=1,i+=1;if(!o){o=true,s=c,a=d;continue}c===s&&(n.push([a,i]),o=false,s=0,a=-1);}return o&&n.push([a,e.length]),{spans:n,state:{open:o,ticks:s}}}function Mo(e,t){return e.find(r=>t>=r.start&&t<r.end)}function Ro(e,t){return t.some(r=>e>=r.start&&e<r.end)}function Po(e,t){return t.some(([r,n])=>e>=r&&e<n)}chunkVRQQ33YH_cjs.j();var Co={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function ze(e,t){try{let r=Ce.z.string().parse(e),n=ye.parse(t);if(!r||n==="off")return r;let{ir:o,hasTables:s}=we(r,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:n});return s?Se(o,{styleMarkers:Co,escapeText:a=>a,buildLink:(a,i)=>{let l=a.href.trim();return !l||!i.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):r}catch(r){return console.warn("Invalid input for convertMarkdownTables:",r),typeof e=="string"?e:""}}exports.Markdown=void 0;(d=>{function e(c,u){try{return ue(c,u)}catch(m){return console.warn("Markdown.parse error:",m),{text:"",styles:[],links:[]}}}d.parse=e;function t(c,u){try{return de(c,u)}catch(m){return console.warn("Markdown.render error:",m),""}}d.render=t;function r(c,u){try{return Le(c,u)}catch(m){return console.warn("Markdown.format error:",m),typeof c=="string"?c:""}}d.format=r;function n(c){try{return ke(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}d.parseFrontmatter=n;function o(c){try{return Ae(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}d.serializeFrontmatter=o;function s(c){try{return _e(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}d.extractFrontmatter=s;function a(c,u,m){try{return ae(c,u,m)}catch(y){return console.warn("Markdown.chunk error:",y),typeof c=="string"&&c.length>0?[c]:[]}}d.chunk=a;function i(c,u){try{return Ne(c,u)}catch(m){return console.warn("Markdown.buildCodeIndex error:",m),{inlineState:{open:false,ticks:0},isInside:()=>false}}}d.buildCodeIndex=i;function l(c,u){try{return ze(c,u)}catch(m){return console.warn("Markdown.convertTables error:",m),typeof c=="string"?c:""}}d.convertTables=l;})(exports.Markdown||(exports.Markdown={}));chunkVRQQ33YH_cjs.j();function Rn(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r[r.length-1]??""}function Io(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r.slice(0,r.length-1).join("/")+"/"}function Oo(e){if(!e)return "";let t=e.split(".");return t[t.length-1]}function Fo(e,t=20){let r=Rn(e);if(r.length<=t)return r;let n=r.lastIndexOf("."),o=n<=0?"":r.slice(n),s=t-o.length-1;return s<=0?r.slice(0,t-1)+"\u2026":r.slice(0,s)+"\u2026"+o}function Bo(e,t=20){if(e.length<=t)return e;let r=t-1,n=Math.ceil(r/2),o=Math.floor(r/2);return e.slice(0,n)+"\u2026"+e.slice(-o)}chunkVRQQ33YH_cjs.j();var $o=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function Lo(e){if(!e)return false;let t=String(e instanceof Error?e.message:e).toLowerCase();return $o.some(r=>t.includes(r))}async function Ao(e,t={}){let{attempts:r=3,delay:n=500,factor:o=2,maxDelay:s=1e4,retryIf:a=Lo}=t,i;for(let l=0;l<r;l++)try{return await e()}catch(d){if(i=d,l===r-1||!a(d))throw d;let c=Math.min(n*o**l,s);await new Promise(u=>setTimeout(u,c));}throw i}chunkVRQQ33YH_cjs.j();exports.Slug=void 0;(n=>{let e=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],t=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function r(){return [e[Math.floor(Math.random()*e.length)],t[Math.floor(Math.random()*t.length)]].join("-")}n.create=r;})(exports.Slug||(exports.Slug={}));chunkVRQQ33YH_cjs.j();function Pn(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function _o(e,...t){let r=Pn(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}chunkVRQQ33YH_cjs.j();exports.Archive=void 0;(t=>{async function e(r,n){if(process.platform==="win32"){let o=X__default.default.resolve(r),s=X__default.default.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await exports.Shell.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${a}"`);if(i.code!==0)throw new Error(`PowerShell exited with code ${i.code}: ${i.stderr}`)}else {let o=`unzip -o -q ${r} -d ${n}`,s=await exports.Shell.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(exports.Archive||(exports.Archive={}));chunkVRQQ33YH_cjs.j();exports.Color=void 0;(n=>{function e(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}n.isValidHex=e;function t(o){let s=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),i=parseInt(o.slice(5,7),16);return {r:s,g:a,b:i}}n.hexToRgb=t;function r(o){if(!e(o))return;let{r:s,g:a,b:i}=t(o);return `\x1B[38;2;${s};${a};${i}m\x1B[1m`}n.hexToAnsiBold=r;})(exports.Color||(exports.Color={}));chunkVRQQ33YH_cjs.j();exports.Context=void 0;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);chunkVRQQ33YH_cjs.c(this,"name",s);}}r.NotFound=e;function t(n){let o=new async_hooks.AsyncLocalStorage;return {use(){let s=o.getStore();if(!s)throw new e(n);return s},provide(s,a){return o.run(s,a)}}}r.create=t;})(exports.Context||(exports.Context={}));chunkVRQQ33YH_cjs.j();function Do(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}chunkVRQQ33YH_cjs.j();exports.EventLoop=void 0;(t=>{async function e(){return new Promise(r=>{let n=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?r():setImmediate(n);};n();})}t.wait=e;})(exports.EventLoop||(exports.EventLoop={}));chunkVRQQ33YH_cjs.j();function No(e){if(e<=0)return "";if(e<60)return `${e}s`;if(e<3600){let r=Math.floor(e/60),n=e%60;return n>0?`${r}m ${n}s`:`${r}m`}if(e<86400){let r=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${r}h ${n}m`:`${r}h`}if(e<604800){let r=Math.floor(e/86400);return r===1?"~1 day":`~${r} days`}let t=Math.floor(e/604800);return t===1?"~1 week":`~${t} weeks`}chunkVRQQ33YH_cjs.j();exports.Keybind=void 0;(a=>{function e(i,l){if(i===l)return true;if(typeof i!="object"||typeof l!="object"||i===null||l===null)return false;let d=Object.keys(i),c=Object.keys(l);if(d.length!==c.length)return false;for(let u of d)if(!c.includes(u)||!e(i[u],l[u]))return false;return true}function t(i){return {...i,super:i.super??false}}function r(i,l){return i?e(t(i),t(l)):false}a.match=r;function n(i,l=false){return {name:i.name,ctrl:i.ctrl,meta:i.meta,shift:i.shift,super:i.super??false,leader:l}}a.fromParsedKey=n;function o(i){if(!i)return "";let l=[];i.ctrl&&l.push("ctrl"),i.meta&&l.push("alt"),i.super&&l.push("super"),i.shift&&l.push("shift"),i.name&&(i.name==="delete"?l.push("del"):l.push(i.name));let d=l.join("+");return i.leader&&(d=d?`<leader> ${d}`:"<leader>"),d}a.keyToString=o;function s(i){return i==="none"?[]:i.split(",").map(l=>{let c=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),u={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let m of c)switch(m){case "ctrl":u.ctrl=true;break;case "alt":case "meta":case "option":u.meta=true;break;case "super":u.super=true;break;case "shift":u.shift=true;break;case "leader":u.leader=true;break;case "esc":u.name="escape";break;default:u.name=m;break}return u})}a.parse=s;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(d=>{function e(c){return c.replace(/\b\w/g,u=>u.toUpperCase())}d.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=t;function r(c){let u=new Date(c),m=t(c),y=u.toLocaleDateString();return `${m} \xB7 ${y}`}d.datetime=r;function n(c){let u=new Date(c),m=new Date;return u.getFullYear()===m.getFullYear()&&u.getMonth()===m.getMonth()&&u.getDate()===m.getDate()?t(c):r(c)}d.todayTimeOrDateTime=n;function o(c){return c>=1e6?(c/1e6).toFixed(1)+"M":c>=1e3?(c/1e3).toFixed(1)+"K":c.toString()}d.number=o;function s(c){if(c<1e3)return `${c}ms`;if(c<6e4)return `${(c/1e3).toFixed(1)}s`;if(c<36e5){let y=Math.floor(c/6e4),R=Math.floor(c%6e4/1e3);return `${y}m ${R}s`}if(c<864e5){let y=Math.floor(c/36e5),R=Math.floor(c%36e5/6e4);return `${y}h ${R}m`}let u=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${u}h`}d.duration=s;function a(c,u){return c.length<=u?c:c.slice(0,u-1)+"\u2026"}d.truncate=a;function i(c,u=35){if(c.length<=u)return c;let m="\u2026",y=Math.ceil((u-m.length)/2),R=Math.floor((u-m.length)/2);return c.slice(0,y)+m+c.slice(-R)}d.truncateMiddle=i;function l(c,u,m){return (c===1?u:m).replace("{}",c.toString())}d.pluralize=l;})(exports.Locale||(exports.Locale={}));chunkVRQQ33YH_cjs.j();function zo(){return !!(process.env.HTTP_PROXY||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.https_proxy)}chunkVRQQ33YH_cjs.j();var vt=class{constructor(){chunkVRQQ33YH_cjs.c(this,"queue",[]);chunkVRQQ33YH_cjs.c(this,"resolvers",[]);}push(t){let r=this.resolvers.shift();r?r(t):this.queue.push(t);}async next(){return this.queue.length>0?this.queue.shift():new Promise(t=>this.resolvers.push(t))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function Wo(e,t,r){let n=[...t];await Promise.all(Array.from({length:e},async()=>{for(;;){let o=n.pop();if(o===void 0)return;await r(o);}}));}chunkVRQQ33YH_cjs.j();function Ho(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}chunkVRQQ33YH_cjs.j();function Uo(e,t){let r;return Promise.race([e.then(n=>(clearTimeout(r),n)),new Promise((n,o)=>{r=setTimeout(()=>{o(new Error(`Operation timed out after ${t}ms`));},t);})])}chunkVRQQ33YH_cjs.j();exports.Token=void 0;(a=>{let r=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function n(i){if(!i)return 0;let l=String(i),d=(l.match(r)||[]).length,c=l.length-d,u=Math.round(d/1.5),m=Math.round(c/4);return Math.max(0,u+m)}a.estimate=n;function o(i){if(i==null)return 0;try{let l=typeof i=="string"?i:JSON.stringify(i);return n(l)}catch{return 0}}a.estimateObject=o;function s(i){if(i.total!==void 0&&i.total>0)return i.total;let l=i.input??0,d=i.output??0,c=i.cache?.read??0,u=i.cache?.write??0;return l+d+c+u}a.total=s;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function Vo(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return Ce__default.default.object(t)}chunkVRQQ33YH_cjs.j();exports.Wildcard=void 0;(s=>{function e(a,i){let l=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return l.endsWith(" .*")&&(l=l.slice(0,-3)+"( .*)?"),new RegExp("^"+l+"$","s").test(a)}s.match=e;function t(a){return a.sort((i,l)=>{let d=i[0].length-l[0].length;return d!==0?d:i[0].localeCompare(l[0])})}function r(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d)e(a,u)&&(c=m);return c}s.all=r;function n(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d){let y=u.split(/\s+/);e(a.head,y[0])&&(y.length===1||o(a.tail,y.slice(1)))&&(c=m);}return c}s.allStructured=n;function o(a,i){if(i.length===0)return true;if(a.length<i.length)return false;for(let l=0;l<i.length;l++)if(!e(a[l],i[l]))return false;return true}})(exports.Wildcard||(exports.Wildcard={}));async function Jl(e){let{Log:t}=await import('./chunks/log-SYYXHGGF.cjs'),r=false;await t.init({logDir:e.logDir??process.env.EASBOT_LOG_PATH??process.cwd(),print:e.print??false,dev:e.dev??r,level:e.level??("INFO")});}Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunkFQQBYGFZ_cjs.b}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunkFQQBYGFZ_cjs.a}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkYW4ULP4O_cjs.b}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkYW4ULP4O_cjs.a}});Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkYC4AEMOP_cjs.a}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return hono.Hono}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return nodeWs.createNodeWebSocket}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return cors.cors}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return logger.logger}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return compress.compress}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return secureHeaders.secureHeaders}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return timeout.timeout}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return httpException.HTTPException}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return validator.validator}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return zodValidator.zValidator}});exports.$=wr;exports.AsyncQueue=vt;exports.NamedError=tt;exports.PkgShell=ge;exports.abortAfter=Pn;exports.abortAfterAny=_o;exports.buildCodeSpanIndex=Ne;exports.chunkMarkdownIR=vn;exports.chunkText=ae;exports.chunkTextByBreakResolver=it;exports.convertMarkdownTables=ze;exports.createInlineCodeState=De;exports.createPkgShell=te;exports.createRESTServer=Ye;exports.createRPCServer=Ge;exports.createServer=K;exports.createStreamingServer=Ze;exports.createWebSocketServer=Je;exports.defer=Do;exports.detectPlatform=Xt;exports.escapeCommandArg=Qe;exports.escapeCommandArgSafe=Kt;exports.extractFrontmatter=_e;exports.findFenceSpanAt=mt;exports.findLast=Hn;exports.fn=Pr;exports.formatDuration=No;exports.formatLocalISO=et;exports.formatLocalISOCompact=Sr;exports.formatLogTime=Tr;exports.formatMarkdown=Le;exports.getDirectory=Io;exports.getFileExtension=Oo;exports.getFilename=Rn;exports.getFilenameTruncated=Fo;exports.getTimezoneOffset=Mr;exports.git=Fr;exports.iife=Dr;exports.initLog=Jl;exports.isSafeFenceBreak=Mn;exports.joinCommandArgs=se;exports.lazy=Te;exports.lazyAsync=Vn;exports.loadEnv=Or;exports.loadTextFile=_r;exports.loadTextFileAsync=jr;exports.markdownToIR=ue;exports.markdownToIRWithMeta=we;exports.needsShellExecution=Jt;exports.now=an;exports.nowLocalISO=kr;exports.parseCommand=G;exports.parseCommandWithOptions=Zt;exports.parseFenceSpans=je;exports.parseFrontmatterBlock=ke;exports.parseLocalISO=vr;exports.parseModelId=Nr;exports.proxied=zo;exports.readableStreamToText=br;exports.renderMarkdown=de;exports.renderMarkdownWithMarkers=Se;exports.retry=Ao;exports.scanParenAwareBreakpoints=st;exports.serializeFrontmatter=Ae;exports.shell=en;exports.signal=Ho;exports.startServer=Zn;exports.truncateMiddle=Bo;exports.updateSchema=Vo;exports.whichSync=xr;exports.withTimeout=Uo;exports.work=Wo;
|
|
81
|
+
`,o),a=s===-1?t.length:s,i=t.slice(o,a),l=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let d=l[1],c=l[2];if(!d||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let m=c.length;if(!n)n={start:o,markerChar:u,markerLen:m,openLine:i,marker:c,indent:d};else if(n.markerChar===u&&m>=n.markerLen){let S=a;r.push({start:n.start,end:S,openLine:n.openLine,marker:n.marker,indent:n.indent}),n=void 0;}}if(s===-1)break;o=s+1;}return n&&r.push({start:n.start,end:t.length,openLine:n.openLine,marker:n.marker,indent:n.indent}),r}catch(t){return console.warn("Invalid input for parseFenceSpans:",t),[]}}function bt(e,t){let r=0,n=e.length-1;for(;r<=n;){let o=Math.floor((r+n)/2),s=e[o];if(!s)break;if(t<=s.start){n=o-1;continue}if(t>=s.end){r=o+1;continue}return s}}function Pn(e,t){return !bt(e,t)}function Ne(){return {open:false,ticks:0}}function De(e,t){try{let r=Ce.z.string().parse(e),n=t?Be.parse(t):Ne(),o=je(r),s={open:n.open,ticks:n.ticks},{spans:a,state:i}=Ro(r,o,s);return {inlineState:i,isInside:l=>Eo(l,o)||Co(l,a)}}catch(r){return console.warn("Invalid input for buildCodeSpanIndex:",r),{inlineState:Ne(),isInside:()=>false}}}function Ro(e,t,r){let n=[],o=r.open,s=r.ticks,a=o?0:-1,i=0;for(;i<e.length;){let l=Po(t,i);if(l){i=l.end;continue}if(e[i]!=="`"){i+=1;continue}let d=i,c=0;for(;i<e.length&&e[i]==="`";)c+=1,i+=1;if(!o){o=true,s=c,a=d;continue}c===s&&(n.push([a,i]),o=false,s=0,a=-1);}return o&&n.push([a,e.length]),{spans:n,state:{open:o,ticks:s}}}function Po(e,t){return e.find(r=>t>=r.start&&t<r.end)}function Eo(e,t){return t.some(r=>e>=r.start&&e<r.end)}function Co(e,t){return t.some(([r,n])=>e>=r&&e<n)}chunkVRQQ33YH_cjs.j();var Oo={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function ze(e,t){try{let r=Ce.z.string().parse(e),n=we.parse(t);if(!r||n==="off")return r;let{ir:o,hasTables:s}=ye(r,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:n});return s?Se(o,{styleMarkers:Oo,escapeText:a=>a,buildLink:(a,i)=>{let l=a.href.trim();return !l||!i.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):r}catch(r){return console.warn("Invalid input for convertMarkdownTables:",r),typeof e=="string"?e:""}}exports.Markdown=void 0;(d=>{function e(c,u){try{return ue(c,u)}catch(m){return console.warn("Markdown.parse error:",m),{text:"",styles:[],links:[]}}}d.parse=e;function t(c,u){try{return de(c,u)}catch(m){return console.warn("Markdown.render error:",m),""}}d.render=t;function r(c,u){try{return Ae(c,u)}catch(m){return console.warn("Markdown.format error:",m),typeof c=="string"?c:""}}d.format=r;function n(c){try{return ke(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}d.parseFrontmatter=n;function o(c){try{return Le(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}d.serializeFrontmatter=o;function s(c){try{return _e(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}d.extractFrontmatter=s;function a(c,u,m){try{return ae(c,u,m)}catch(S){return console.warn("Markdown.chunk error:",S),typeof c=="string"&&c.length>0?[c]:[]}}d.chunk=a;function i(c,u){try{return De(c,u)}catch(m){return console.warn("Markdown.buildCodeIndex error:",m),{inlineState:{open:false,ticks:0},isInside:()=>false}}}d.buildCodeIndex=i;function l(c,u){try{return ze(c,u)}catch(m){return console.warn("Markdown.convertTables error:",m),typeof c=="string"?c:""}}d.convertTables=l;})(exports.Markdown||(exports.Markdown={}));chunkVRQQ33YH_cjs.j();function En(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r[r.length-1]??""}function Bo(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r.slice(0,r.length-1).join("/")+"/"}function Fo(e){if(!e)return "";let t=e.split(".");return t[t.length-1]}function $o(e,t=20){let r=En(e);if(r.length<=t)return r;let n=r.lastIndexOf("."),o=n<=0?"":r.slice(n),s=t-o.length-1;return s<=0?r.slice(0,t-1)+"\u2026":r.slice(0,s)+"\u2026"+o}function Ao(e,t=20){if(e.length<=t)return e;let r=t-1,n=Math.ceil(r/2),o=Math.floor(r/2);return e.slice(0,n)+"\u2026"+e.slice(-o)}chunkVRQQ33YH_cjs.j();var Lo=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function _o(e){if(!e)return false;let t=String(e instanceof Error?e.message:e).toLowerCase();return Lo.some(r=>t.includes(r))}async function jo(e,t={}){let{attempts:r=3,delay:n=500,factor:o=2,maxDelay:s=1e4,retryIf:a=_o}=t,i;for(let l=0;l<r;l++)try{return await e()}catch(d){if(i=d,l===r-1||!a(d))throw d;let c=Math.min(n*o**l,s);await new Promise(u=>setTimeout(u,c));}throw i}chunkVRQQ33YH_cjs.j();exports.Slug=void 0;(n=>{let e=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],t=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function r(){return [e[Math.floor(Math.random()*e.length)],t[Math.floor(Math.random()*t.length)]].join("-")}n.create=r;})(exports.Slug||(exports.Slug={}));chunkVRQQ33YH_cjs.j();function Cn(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function No(e,...t){let r=Cn(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}chunkVRQQ33YH_cjs.j();exports.Archive=void 0;(t=>{async function e(r,n){if(process.platform==="win32"){let o=ie__default.default.resolve(r),s=ie__default.default.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await exports.Shell.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${a}"`);if(i.code!==0)throw new Error(`PowerShell exited with code ${i.code}: ${i.stderr}`)}else {let o=`unzip -o -q ${r} -d ${n}`,s=await exports.Shell.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(exports.Archive||(exports.Archive={}));chunkVRQQ33YH_cjs.j();exports.Color=void 0;(n=>{function e(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}n.isValidHex=e;function t(o){let s=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),i=parseInt(o.slice(5,7),16);return {r:s,g:a,b:i}}n.hexToRgb=t;function r(o){if(!e(o))return;let{r:s,g:a,b:i}=t(o);return `\x1B[38;2;${s};${a};${i}m\x1B[1m`}n.hexToAnsiBold=r;})(exports.Color||(exports.Color={}));chunkVRQQ33YH_cjs.j();exports.Context=void 0;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);chunkVRQQ33YH_cjs.c(this,"name",s);}}r.NotFound=e;function t(n){let o=new async_hooks.AsyncLocalStorage;return {use(){let s=o.getStore();if(!s)throw new e(n);return s},provide(s,a){return o.run(s,a)}}}r.create=t;})(exports.Context||(exports.Context={}));chunkVRQQ33YH_cjs.j();function zo(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}chunkVRQQ33YH_cjs.j();exports.EventLoop=void 0;(t=>{async function e(){return new Promise(r=>{let n=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?r():setImmediate(n);};n();})}t.wait=e;})(exports.EventLoop||(exports.EventLoop={}));chunkVRQQ33YH_cjs.j();function Ho(e){if(e<=0)return "";if(e<60)return `${e}s`;if(e<3600){let r=Math.floor(e/60),n=e%60;return n>0?`${r}m ${n}s`:`${r}m`}if(e<86400){let r=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${r}h ${n}m`:`${r}h`}if(e<604800){let r=Math.floor(e/86400);return r===1?"~1 day":`~${r} days`}let t=Math.floor(e/604800);return t===1?"~1 week":`~${t} weeks`}chunkVRQQ33YH_cjs.j();exports.Keybind=void 0;(a=>{function e(i,l){if(i===l)return true;if(typeof i!="object"||typeof l!="object"||i===null||l===null)return false;let d=Object.keys(i),c=Object.keys(l);if(d.length!==c.length)return false;for(let u of d)if(!c.includes(u)||!e(i[u],l[u]))return false;return true}function t(i){return {...i,super:i.super??false}}function r(i,l){return i?e(t(i),t(l)):false}a.match=r;function n(i,l=false){return {name:i.name,ctrl:i.ctrl,meta:i.meta,shift:i.shift,super:i.super??false,leader:l}}a.fromParsedKey=n;function o(i){if(!i)return "";let l=[];i.ctrl&&l.push("ctrl"),i.meta&&l.push("alt"),i.super&&l.push("super"),i.shift&&l.push("shift"),i.name&&(i.name==="delete"?l.push("del"):l.push(i.name));let d=l.join("+");return i.leader&&(d=d?`<leader> ${d}`:"<leader>"),d}a.keyToString=o;function s(i){return i==="none"?[]:i.split(",").map(l=>{let c=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),u={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let m of c)switch(m){case "ctrl":u.ctrl=true;break;case "alt":case "meta":case "option":u.meta=true;break;case "super":u.super=true;break;case "shift":u.shift=true;break;case "leader":u.leader=true;break;case "esc":u.name="escape";break;default:u.name=m;break}return u})}a.parse=s;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(d=>{function e(c){return c.replace(/\b\w/g,u=>u.toUpperCase())}d.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=t;function r(c){let u=new Date(c),m=t(c),S=u.toLocaleDateString();return `${m} \xB7 ${S}`}d.datetime=r;function n(c){let u=new Date(c),m=new Date;return u.getFullYear()===m.getFullYear()&&u.getMonth()===m.getMonth()&&u.getDate()===m.getDate()?t(c):r(c)}d.todayTimeOrDateTime=n;function o(c){return c>=1e6?(c/1e6).toFixed(1)+"M":c>=1e3?(c/1e3).toFixed(1)+"K":c.toString()}d.number=o;function s(c){if(c<1e3)return `${c}ms`;if(c<6e4)return `${(c/1e3).toFixed(1)}s`;if(c<36e5){let S=Math.floor(c/6e4),R=Math.floor(c%6e4/1e3);return `${S}m ${R}s`}if(c<864e5){let S=Math.floor(c/36e5),R=Math.floor(c%36e5/6e4);return `${S}h ${R}m`}let u=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${u}h`}d.duration=s;function a(c,u){return c.length<=u?c:c.slice(0,u-1)+"\u2026"}d.truncate=a;function i(c,u=35){if(c.length<=u)return c;let m="\u2026",S=Math.ceil((u-m.length)/2),R=Math.floor((u-m.length)/2);return c.slice(0,S)+m+c.slice(-R)}d.truncateMiddle=i;function l(c,u,m){return (c===1?u:m).replace("{}",c.toString())}d.pluralize=l;})(exports.Locale||(exports.Locale={}));chunkVRQQ33YH_cjs.j();function Wo(){return !!(process.env.HTTP_PROXY||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.https_proxy)}chunkVRQQ33YH_cjs.j();var Rt=class{constructor(){chunkVRQQ33YH_cjs.c(this,"queue",[]);chunkVRQQ33YH_cjs.c(this,"resolvers",[]);}push(t){let r=this.resolvers.shift();r?r(t):this.queue.push(t);}async next(){return this.queue.length>0?this.queue.shift():new Promise(t=>this.resolvers.push(t))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function Uo(e,t,r){let n=[...t];await Promise.all(Array.from({length:e},async()=>{for(;;){let o=n.pop();if(o===void 0)return;await r(o);}}));}chunkVRQQ33YH_cjs.j();function qo(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}chunkVRQQ33YH_cjs.j();function Vo(e,t){let r;return Promise.race([e.then(n=>(clearTimeout(r),n)),new Promise((n,o)=>{r=setTimeout(()=>{o(new Error(`Operation timed out after ${t}ms`));},t);})])}chunkVRQQ33YH_cjs.j();exports.Token=void 0;(a=>{let r=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function n(i){if(!i)return 0;let l=String(i),d=(l.match(r)||[]).length,c=l.length-d,u=Math.round(d/1.5),m=Math.round(c/4);return Math.max(0,u+m)}a.estimate=n;function o(i){if(i==null)return 0;try{let l=typeof i=="string"?i:JSON.stringify(i);return n(l)}catch{return 0}}a.estimateObject=o;function s(i){if(i.total!==void 0&&i.total>0)return i.total;let l=i.input??0,d=i.output??0,c=i.cache?.read??0,u=i.cache?.write??0;return l+d+c+u}a.total=s;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function Yo(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return Ce__default.default.object(t)}chunkVRQQ33YH_cjs.j();exports.Wildcard=void 0;(s=>{function e(a,i){let l=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return l.endsWith(" .*")&&(l=l.slice(0,-3)+"( .*)?"),new RegExp("^"+l+"$","s").test(a)}s.match=e;function t(a){return a.sort((i,l)=>{let d=i[0].length-l[0].length;return d!==0?d:i[0].localeCompare(l[0])})}function r(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d)e(a,u)&&(c=m);return c}s.all=r;function n(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d){let S=u.split(/\s+/);e(a.head,S[0])&&(S.length===1||o(a.tail,S.slice(1)))&&(c=m);}return c}s.allStructured=n;function o(a,i){if(i.length===0)return true;if(a.length<i.length)return false;for(let l=0;l<i.length;l++)if(!e(a[l],i[l]))return false;return true}})(exports.Wildcard||(exports.Wildcard={}));async function Kl(e){let{Log:t}=await import('./chunks/log-SYYXHGGF.cjs'),r=false;await t.init({logDir:e.logDir??process.env.EASBOT_LOG_PATH??process.cwd(),print:e.print??false,dev:e.dev??r,level:e.level??("INFO")});}Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunk6WIM3NST_cjs.c}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunk6WIM3NST_cjs.a}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunk6WIM3NST_cjs.b}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkYW4ULP4O_cjs.b}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkYW4ULP4O_cjs.a}});Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkYC4AEMOP_cjs.a}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return hono.Hono}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return nodeWs.createNodeWebSocket}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return cors.cors}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return logger.logger}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return compress.compress}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return secureHeaders.secureHeaders}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return timeout.timeout}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return httpException.HTTPException}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return validator.validator}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return zodValidator.zValidator}});exports.$=kr;exports.AsyncQueue=Rt;exports.NamedError=ot;exports.PkgShell=ge;exports.abortAfter=Cn;exports.abortAfterAny=No;exports.buildCodeSpanIndex=De;exports.chunkMarkdownIR=Mn;exports.chunkText=ae;exports.chunkTextByBreakResolver=ct;exports.convertMarkdownTables=ze;exports.createInlineCodeState=Ne;exports.createPkgShell=te;exports.createRESTServer=Ke;exports.createRPCServer=Ze;exports.createServer=Q;exports.createStreamingServer=Qe;exports.createWebSocketServer=Xe;exports.defer=zo;exports.detectPlatform=en;exports.escapeCommandArg=nt;exports.escapeCommandArgSafe=Qt;exports.extractFrontmatter=_e;exports.findFenceSpanAt=bt;exports.findLast=qn;exports.fn=Cr;exports.formatDuration=Ho;exports.formatLocalISO=rt;exports.formatLocalISOCompact=vr;exports.formatLogTime=Rr;exports.formatMarkdown=Ae;exports.getDirectory=Bo;exports.getFileExtension=Fo;exports.getFilename=En;exports.getFilenameTruncated=$o;exports.getTimezoneOffset=Pr;exports.git=$r;exports.iife=zr;exports.initLog=Kl;exports.isSafeFenceBreak=Pn;exports.joinCommandArgs=oe;exports.lazy=Te;exports.lazyAsync=Yn;exports.loadEnv=Fr;exports.loadTextFile=Nr;exports.loadTextFileAsync=Dr;exports.markdownToIR=ue;exports.markdownToIRWithMeta=ye;exports.needsShellExecution=Kt;exports.now=cn;exports.nowLocalISO=Tr;exports.parseCommand=Z;exports.parseCommandWithOptions=Xt;exports.parseFenceSpans=je;exports.parseFrontmatterBlock=ke;exports.parseLocalISO=Mr;exports.parseModelId=Hr;exports.proxied=Wo;exports.readableStreamToText=wr;exports.renderMarkdown=de;exports.renderMarkdownWithMarkers=Se;exports.retry=jo;exports.scanParenAwareBreakpoints=lt;exports.serializeFrontmatter=Le;exports.shell=nn;exports.signal=qo;exports.startServer=Xn;exports.truncateMiddle=Ao;exports.updateSchema=Yo;exports.whichSync=yr;exports.withTimeout=Vo;exports.work=Uo;
|