@easbot/utils 0.3.4 → 0.3.7
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-6HZ7Q7NO.mjs +2 -0
- package/dist/chunks/chunk-6JM5F6FM.cjs +2 -0
- package/dist/chunks/chunk-A2TCSTSM.cjs +5 -0
- package/dist/chunks/chunk-JQNKLHWT.cjs +20 -0
- package/dist/chunks/chunk-LBWRSUJC.mjs +20 -0
- package/dist/chunks/chunk-T3MZ3YS3.mjs +5 -0
- package/dist/chunks/{filesystem-OYOMZ7F3.cjs → filesystem-HQDKXRWJ.cjs} +1 -1
- package/dist/chunks/filesystem-XE6UYBAE.mjs +1 -0
- package/dist/chunks/{registry-DPBQYUUX.cjs → registry-BGNK5LJC.cjs} +1 -1
- package/dist/chunks/registry-NQR4SFLJ.mjs +1 -0
- package/dist/chunks/shell-PXZK5BNW.mjs +1 -0
- package/dist/chunks/shell-RJBXISIH.cjs +1 -0
- package/dist/index.cjs +52 -69
- package/dist/index.d.cts +20 -9
- package/dist/index.d.ts +20 -9
- package/dist/index.mjs +52 -69
- package/package.json +4 -3
- package/dist/chunks/chunk-2ISW3RDH.mjs +0 -1
- package/dist/chunks/chunk-DJ7NLT2Q.mjs +0 -5
- package/dist/chunks/chunk-YPKMFQLR.cjs +0 -1
- package/dist/chunks/chunk-ZHSHEAQD.cjs +0 -5
- package/dist/chunks/filesystem-KGIAOOG5.mjs +0 -1
- package/dist/chunks/registry-36YLLEJU.mjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,82 +1,65 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
Full ${
|
|
3
|
-
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${
|
|
4
|
-
Use Read tool with offset/limit parameters to view specific sections.]`}async function a(c,
|
|
1
|
+
'use strict';var chunkYC4AEMOP_cjs=require('./chunks/chunk-YC4AEMOP.cjs'),chunkJQNKLHWT_cjs=require('./chunks/chunk-JQNKLHWT.cjs'),chunk6JM5F6FM_cjs=require('./chunks/chunk-6JM5F6FM.cjs'),chunkA2TCSTSM_cjs=require('./chunks/chunk-A2TCSTSM.cjs');require('./chunks/chunk-AHO55TRS.cjs');var chunkVRQQ33YH_cjs=require('./chunks/chunk-VRQQ33YH.cjs'),ue=require('fs/promises'),pe=require('zod'),crypto$1=require('crypto'),dotenv=require('dotenv'),De=require('path'),fs=require('fs'),xdgBasedir=require('xdg-basedir'),url=require('url'),Tn=require('markdown-it'),wt=require('yaml'),undici=require('undici'),async_hooks=require('async_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ue__default=/*#__PURE__*/_interopDefault(ue);var pe__default=/*#__PURE__*/_interopDefault(pe);var De__default=/*#__PURE__*/_interopDefault(De);var Tn__default=/*#__PURE__*/_interopDefault(Tn);var wt__default=/*#__PURE__*/_interopDefault(wt);chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function en(t,e){for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(r!==void 0&&e(r,n,t))return r}}chunkVRQQ33YH_cjs.j();exports.Binary=void 0;(n=>{function t(r,o,i){let a=0,s=r.length-1;for(;a<=s;){let l=Math.floor((a+s)/2),p=r[l];if(p===void 0)break;let c=i(p);if(c===o)return {found:true,index:l};c<o?a=l+1:s=l-1;}return {found:false,index:a}}n.search=t;function e(r,o,i){let a=i(o),s=0,l=r.length;for(;s<l;){let p=Math.floor((s+l)/2),c=r[p];if(c===void 0)break;i(c)<a?s=p+1:l=p;}return r.splice(s,0,o),r}n.insert=e;})(exports.Binary||(exports.Binary={}));chunkVRQQ33YH_cjs.j();exports.Encode=void 0;(i=>{function t(a){let s=new TextEncoder().encode(a),l=Array.from(s,p=>String.fromCharCode(p)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}i.base64Encode=t;function e(a){let s=atob(a.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(s,p=>p.charCodeAt(0));return new TextDecoder().decode(l)}i.base64Decode=e;async function n(a,s="SHA-256"){let p=new TextEncoder().encode(a),c=await crypto.subtle.digest(s,p);return Array.from(new Uint8Array(c)).map(m=>m.toString(16).padStart(2,"0")).join("")}i.hash=n;function r(a){if(!a)return;let s=2166136261;for(let l=0;l<a.length;l++)s^=a.charCodeAt(l),s=Math.imul(s,16777619);return (s>>>0).toString(36)}i.checksum=r;function o(a,s=5e5){if(!a)return;if(a.length<=s)return r(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 d=Math.max(0,Math.min(a.length-l,u-Math.floor(l/2)));return r(a.slice(d,d+l))??""}).join(":");return `${a.length}:${c}`}i.sampledChecksum=o;})(exports.Encode||(exports.Encode={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();exports.Identifier=void 0;(u=>{let t={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",agent:"ag",subagent:"sub",hook:"hok",compaction:"cmp",context:"ctx",experience:"exp",pattern:"pat",knowledge:"knw",evolution:"evo",result:"res"};function e(d){return pe__default.default.string().startsWith(t[d])}u.schema=e;let n=26,r=0,o=0;function i(d,m){return s(d,false,m)}u.ascending=i;function a(d,m){return s(d,true,m)}u.descending=a;function s(d,m,g){if(!g)return p(d,m);if(!g.startsWith(t[d]))throw new Error(`ID ${g} does not start with ${t[d]}`);return g}function l(d){let m="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",g="",k=crypto$1.randomBytes(d);for(let S=0;S<d;S++){let R=k[S];R!==void 0&&(g+=m[R%62]);}return g}function p(d,m,g){let k=g??Date.now();k!==r&&(r=k,o=0),o++;let S=BigInt(k)*BigInt(4096)+BigInt(o);S=m?~S:S;let R=Buffer.alloc(6);for(let P=0;P<6;P++)R[P]=Number(S>>BigInt(40-8*P)&BigInt(255));return t[d]+"_"+R.toString("hex")+l(n-12)}u.create=p;function c(d){let m=d.split("_")[0];if(!m)return 0;let g=d.slice(m.length+1,m.length+13),k=BigInt("0x"+g);return Number(k/BigInt(4096))}u.timestamp=c;})(exports.Identifier||(exports.Identifier={}));exports.TruncateContent=void 0;(p=>{p.DEFAULT_MAX_CHARS=4e3,p.DIRECTION="head",p.DIR=chunk6JM5F6FM_cjs.d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),p.GLOB=chunk6JM5F6FM_cjs.d.join(p.DIR,"*");let o=10080*60*1e3;function i(c,u,d){return d?`[Content truncated. Source: ${d}
|
|
2
|
+
Full ${u} saved to: ${c}
|
|
3
|
+
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${u} saved to: ${c}
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}async function a(c,u={}){let d=u.maxChars??4e3,m=u.direction??p.DIRECTION,g=u.label??"content",k=u.sourcePath,S=chunk6JM5F6FM_cjs.d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),R=u.dir??S;if(c.length<=d)return {content:c,truncated:false};let P=exports.Identifier.ascending("context"),O=chunk6JM5F6FM_cjs.d.join(R,P);await ue__default.default.mkdir(R,{recursive:true}).catch(()=>{}),await ue__default.default.writeFile(O,c,"utf-8");let ie=c.length-d,U;m==="head"?U=c.slice(0,d):U=c.slice(-d);let ae=i(O,g,k),Me=`${ie} characters truncated`;return {content:m==="head"?`${U}
|
|
5
5
|
|
|
6
|
-
...${
|
|
6
|
+
...${Me}...
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${ae}`:`...${Me}...
|
|
9
9
|
|
|
10
|
-
${
|
|
10
|
+
${ae}
|
|
11
11
|
|
|
12
|
-
${se}`,truncated:true,outputPath:G,originalLength:c.length,removedLength:de,label:E}}p.truncate=a;function i(c){return c.truncated?s(c.outputPath,c.label):""}p.formatHint=i;async function l(){let c=exports.Identifier.timestamp(exports.Identifier.create("context",false,Date.now()-o)),g=(await oe__default.default.readdir(p.DIR).catch(()=>[])).filter(k=>k.startsWith("context_"));for(let k of g)exports.Identifier.timestamp(k)>=c||await oe__default.default.unlink(chunkYPKMFQLR_cjs.c.join(p.DIR,k)).catch(()=>{});}p.cleanup=l;})(exports.TruncateContent||(exports.TruncateContent={}));chunkVRQQ33YH_cjs.j();exports.SessionTitle=void 0;(i=>{let e="New session - ",t="Child session - ";i.parentTitlePrefix=e,i.childTitlePrefix=t;function o(l=false){return (l?t:e)+chunkZHSHEAQD_cjs.b(new Date)}i.createDefault=o;function s(l){return new RegExp(`^(${e}|${t})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(l)}i.isDefault=s;function a(l){let p=l.match(/^(.+) \(fork #(\d+)\)$/);if(p){let c=p[1]??"",d=parseInt(p[2]??"0",10);return `${c} (fork #${d+1})`}return `${l} (fork #1)`}i.getForked=a;})(exports.SessionTitle||(exports.SessionTitle={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function qt(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var $e=qt;function Yt(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var ar=Yt;exports.Lazy=void 0;(r=>(r.lazy=qt,r.lazyAsync=Yt))(exports.Lazy||(exports.Lazy={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();var ne=chunkZHSHEAQD_cjs.m.create({service:"server"});function ae(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)=>(ne.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)=>ne.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 p=await a.req.json(),c=await l(p,a);return a.json({result:c})}catch(p){return ne.error("RPC error",{method:i,error:p.message}),a.json({error:"RPC execution failed",message:p.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(p=>{p?(ne.error("Error closing server",{error:p.message}),l(p)):(o=null,ne.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{ne.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return ne.debug("createServer: calling serve()",{port:t,hostname:r}),o=nodeServer.serve({fetch:n.fetch,port:t,hostname:r}),ne.debug("createServer: serve() returned, server created"),ne.info(`Server running on http://${r}:${t}`),s}function at(e){return ae({rpc:e,port:3e3})}function dr(e,t=3e3,r="0.0.0.0"){return ae({fetch:e,port:t,hostname:r})}function lt(e,t={}){return ae({...t,routes:e})}function ct(e,t={}){return ae({...t,websockets:e})}function ut(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 ae({...t,routes:r,streaming:true})}chunkVRQQ33YH_cjs.j();var le=chunkZHSHEAQD_cjs.m.create({service:"build-api"});async function sn(){try{return {available:!0,version:(await import('./chunks/main-RIJAJS2R.cjs')).version||"unknown"}}catch(e){return le.warn("esbuild not available",{error:e.message}),{available:false}}}async function je(){let e=await sn();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"&&le.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function gr(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function an(e){let t=gr(e.compile);t&&le.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:hr(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=br(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),yr(r)}function hr(e){return !e||e==="none"?false:e}function br(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function yr(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function _e(e){if(e!==void 0)return e.replace(/\\/g,"/")}function tn(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:_e(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===_e(s))||n.push({path:_e(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 ft(e){le.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await je();let t=await import('./chunks/main-RIJAJS2R.cjs'),r=Date.now();try{let n=an(e);le.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return le.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),tn(o,r,s)}catch(n){let o=Date.now(),s=n.message;return le.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?tn(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var vr={build:ft},ln=vr;chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function re(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 cn(e){return /[|&;<>()$`!#]/.test(e)}function un(e){let t=re(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 pt(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 Rr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>","2>&1","2>&2","1>&1","1>&2",">&","<&",">&1","<&1",">&2","<&2"]);function dn(e,t=process.platform==="win32"?"windows":"unix"){return Rr.has(e)?e:pt(e,t)}function fn(){return process.platform==="win32"?"windows":"unix"}function me(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>dn(o,r));return [e,...n].join(" ")}function pn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>pn(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 ge(e,t={}){let r=re(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}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`),I=T.length>0?T[0]?.trim():null;if(I)return Q.set(h,I),I}}catch{}return Q.set(h,null),null}_.whichSync=n;function o(){Q.clear();}_.clearWhichCache=o;let s=module$1.createRequire(chunkVRQQ33YH_cjs.i);async function a(S,m,f){try{let u=[];if(f?.extraPaths)for(let y of f.extraPaths){let x=he__default.default.join(y,"node_modules");u.push(x);}return m&&u.push(m),u.length>0?s.resolve(S,{paths:u}):s.resolve(S)}catch(u){throw new Error(`Cannot resolve module "${S}"${m?` from "${m}"`:""}: ${u instanceof Error?u.message:String(u)}`)}}_.resolve=a;function i(S){return {get name(){return he__default.default.basename(S)},async exists(){try{return await oe__default.default.access(S),!0}catch{return false}},async getSize(){try{return (await oe__default.default.stat(S)).size}catch{return}},async text(){return await oe__default.default.readFile(S,"utf-8")},textSync(){return Ne__default.default.readFileSync(S,"utf-8")},jsonSync(){let m=Ne__default.default.readFileSync(S,"utf-8");return JSON.parse(m)},async bytes(){e.debug("[PKG.file.bytes] reading file:",{filePath:S});let m=await oe__default.default.readFile(S);return e.debug("[PKG.file.bytes] read succeeded, size:",{size:m.length}),new Uint8Array(m.buffer,m.byteOffset,m.byteLength)},async arrayBuffer(){let m=await oe__default.default.readFile(S);return m.buffer.slice(m.byteOffset,m.byteOffset+m.byteLength)},get type(){let m=he__default.default.extname(S).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"}[m]||"application/octet-stream"},async write(m){let f;if(m instanceof Response){let u=await m.arrayBuffer();f=new Uint8Array(u);}else f=m;await oe__default.default.writeFile(S,f);},async json(){let m=await oe__default.default.readFile(S,"utf-8");return JSON.parse(m)},async stat(){return await oe__default.default.stat(S)}}}_.file=i;async function l(S,m,f){let u;if(m instanceof Response){let y=await m.arrayBuffer();u=new Uint8Array(y);}else u=m;await oe__default.default.writeFile(S,u,f?{mode:f.mode}:void 0);}_.write=l;function p(S,m,f){Ne__default.default.writeFileSync(S,m,f?{mode:f.mode}:void 0);}_.writeSync=p;function c(S,m="utf-8"){return Ne__default.default.readFileSync(S,m)}_.readSync=c;function d(S,m){let f,u;if(typeof S=="object"&&"cmd"in S){let v=S;f=v.cmd,u={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(S)?S:[S],u=m||{};if(!f||f.length===0||!f[0])throw new Error("Spawn command cannot be empty");let y=[u.stdin==="inherit"?"inherit":u.stdin==="null"?"ignore":"pipe",u.stdout==="inherit"?"inherit":u.stdout==="null"?"ignore":"pipe",u.stderr==="inherit"?"inherit":u.stderr==="null"?"ignore":"pipe"],x={cwd:u.cwd,env:u.env?{...process.env,...u.env}:process.env,stdio:y,timeout:u.timeout};u.shell!==void 0&&(x.shell=u.shell),process.platform==="win32"&&(x.windowsHide=u.windowsHide??true);let h=child_process.spawn(f[0],f.slice(1),x),w;if(u.signal){w=()=>{h.kill();},u.signal.addEventListener("abort",w,{once:true});let v=()=>{w&&(u.signal?.removeEventListener("abort",w),w=void 0);};h.on("close",v),h.on("error",v);}let R=new Promise((v,T)=>{let I=false,z=()=>{I||(I=true,h.removeAllListeners());};if(h.on("close",B=>{z(),v(B??0);}),h.on("error",B=>{z(),T(B);}),u.timeout!==false){let B=u.timeout||3e5;setTimeout(()=>{if(!I){e.debug(`Process timeout after ${B}ms, killing process`,{cmd:f.join(" ")}),z();try{h.kill("SIGKILL");}catch{}T(new Error(`Process timeout after ${B}ms: ${f.join(" ")}`));}},B);}});return {stdout:h.stdout,stderr:h.stderr,stdin:h.stdin,pid:h.pid,exited:R,exitCode:h.exitCode,kill:v=>h.kill(v)}}_.spawn=d;async function g(S,m){let f=m?.stdin??"null",u=m?.stdout??"pipe",y=m?.stderr??"pipe",x=d(S,{cwd:m?.cwd,env:m?.env,stdin:f,stdout:u,stderr:y,windowsHide:m?.windowsHide,shell:m?.shell,timeout:m?.timeout}),h=[],w=[];u==="pipe"&&x.stdout?.on("data",v=>{h.push(v);}),y==="pipe"&&x.stderr?.on("data",v=>{w.push(v);});let R=m?.timeout&&m.timeout>0?setTimeout(()=>{try{x.kill("SIGKILL");}catch{}x.stdout?.destroy(),x.stderr?.destroy(),x.stdin?.end();},m.timeout):void 0;try{let v=await x.exited;return clearTimeout(R),u==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:v,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(w).toString("utf-8")}}catch(v){return clearTimeout(R),u==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:-1,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(w).toString("utf-8")||(v instanceof Error?v.message:String(v))}}}_.run=g;async function k(S,m={},f={}){let u=d(S,{cwd:m.cwd,env:m.env,stdout:"pipe",stderr:"pipe",stdin:"null"}),y="",x="";u.stdout?.on("data",w=>{let R=w.toString("utf-8");y+=R,f.onStdout?.(R);}),u.stderr?.on("data",w=>{let R=w.toString("utf-8");x+=R,f.onStderr?.(R);});let h=m.timeout&&m.timeout>0?setTimeout(()=>{try{u.kill("SIGKILL");}catch{}u.stdout?.destroy(),u.stderr?.destroy();},m.timeout):void 0;try{let w=await u.exited;return clearTimeout(h),f.onExit?.(w),{code:w,stdout:y,stderr:x}}catch(w){clearTimeout(h);let R=w instanceof Error?w.message:String(w);return {code:-1,stdout:y,stderr:x||R}}}_.runWithStream=k;async function E(S){if(typeof S.pipeThrough=="function")try{let y=new TextDecoderStream("utf-8"),h=S.pipeThrough(y).getReader(),w="";try{for(;;){let{done:R,value:v}=await h.read();if(R)break;w+=v;}return w}finally{h.releaseLock();}}catch{}let m=S.getReader(),f=new TextDecoder("utf-8"),u=[];try{for(;;){let{done:y,value:x}=await m.read();if(y)break;u.push(f.decode(x,{stream:!0}));}return u.push(f.decode()),u.join("")}finally{m.releaseLock();}}_.readableStreamToText=E;async function H(S){let m=[];return new Promise((f,u)=>{S.on("data",y=>{typeof y=="string"?m.push(Buffer.from(y)):m.push(y);}),S.on("end",()=>{try{let x=Buffer.concat(m).toString("utf-8");f(x);}catch(y){u(y);}}),S.on("error",y=>{u(y);});})}_.nodeReadableStreamToText=H;function U(S,m=0){let R=new TextEncoder().encode(S),v=R.length,T,I=0;if(v>=16){let F=v-16,A=m+2654435761+2246822519|0,ee=m+2246822519|0,J=m+0|0,Z=m-2654435761|0;for(;I<=F;)A=z(A,N(R,I)),I+=4,ee=z(ee,N(R,I)),I+=4,J=z(J,N(R,I)),I+=4,Z=z(Z,N(R,I)),I+=4;T=B(A,1)+B(ee,7)+B(J,12)+B(Z,18)|0;}else T=m+374761393|0;for(T=T+v|0;I+4<=v;)T=T+N(R,I)*3266489917|0,T=B(T,17)*668265263|0,I+=4;for(;I<v;)T=T+R[I]*374761393|0,T=B(T,11)*2654435761|0,I++;return T^=T>>>15,T=T*2246822519|0,T^=T>>>13,T=T*3266489917|0,T^=T>>>16,T>>>0;function z(F,A){return F=F+A*2246822519|0,F=B(F,13),F=F*2654435761|0,F}function B(F,A){return F<<A|F>>>32-A|0}function N(F,A){return (F[A]|F[A+1]<<8|F[A+2]<<16|F[A+3]<<24)>>>0}}_.xxHash32=U;function q(S){let m=0;for(let f of S){let u=f.codePointAt(0)||f.charCodeAt(0);u<127?m+=1:u>=4352&&u<=4447||u>=9001&&u<=9002||u>=11904&&u<=42191&&u!==12351||u>=44032&&u<=55203||u>=63744&&u<=64255||u>=65040&&u<=65049||u>=65072&&u<=65135||u>=65280&&u<=65376||u>=65504&&u<=65510?m+=2:m+=1;}return m}_.stringWidth=q;class Y{constructor(m){chunkVRQQ33YH_cjs.c(this,"pattern");this.pattern=m;}async*scan(m){let f=chunkAHO55TRS_cjs.b.stream(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for await(let u of f)yield gn(u);}*scanSync(m){let f=chunkAHO55TRS_cjs.a(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for(let u of f)yield gn(u);}match(m){return minimatch.minimatch(m,this.pattern)}}_.Glob=Y,_.stdin=process.stdin,_.stdout=process.stdout,_.stderr=process.stderr,_.sleep=S=>new Promise(m=>setTimeout(m,S)),_.color=(S,m)=>({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"})[S.toLowerCase()]||null,_.hash={xxHash32:_.xxHash32},_.build=ln.build,_.server=ae,_.nodeWebSocket=nodeWs.createNodeWebSocket,_.restServer=lt,_.rpcServer=at,_.streamingServer=ut,_.webSocketServer=ct;})(exports.PKG||(exports.PKG={}));var Fr=exports.PKG.readableStreamToText;exports.PKG.nodeReadableStreamToText;exports.PKG.which;var Ar=exports.PKG.whichSync;exports.PKG.spawn;exports.PKG.run;var yn=200,xn={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;(m=>{let e=chunkZHSHEAQD_cjs.m.create({service:"shell"});async function t(f,u){let y=f.pid;if(!(!y||u?.exited?.())){if(process.platform==="win32"){await new Promise(x=>{let h=child_process.spawn("taskkill",["/pid",String(y),"/f","/t"],{stdio:"ignore",windowsHide:true});h.once("exit",()=>x()),h.once("error",()=>x());});return}try{process.kill(-y,"SIGTERM"),await promises.setTimeout(yn),u?.exited?.()||process.kill(-y,"SIGKILL");}catch{f.kill("SIGTERM"),await promises.setTimeout(yn),u?.exited?.()||f.kill("SIGKILL");}}}m.killTree=t;function r(f){if(process.platform!=="win32"||!f.includes("/")&&!f.includes("\\")&&!f.includes(":"))return f;let u=chunkYPKMFQLR_cjs.c.normalize(f);return E(u)==="bash"&&g()||u}function n(f){return xn[E(f)]}function o(f){return n(f)?.deny!==true}function s(f){return chunkYPKMFQLR_cjs.c.isAbsolute(f)}function a(f){let u=r(f);if(s(u))return chunkYPKMFQLR_cjs.c.stat(u)?.isFile()?u:void 0;let y=exports.PKG.whichSync(u);return y?chunkYPKMFQLR_cjs.c.normalize(y):void 0}function i(){return Array.from(new Set([exports.PKG.whichSync("pwsh"),exports.PKG.whichSync("powershell"),g(),process.env.COMSPEC||"cmd.exe"].filter(f=>!!f).map(r)))}async function l(){let f=await chunkYPKMFQLR_cjs.c.readText("/etc/shells").catch(()=>"");return f?Array.from(new Set(f.split(`
|
|
16
|
-
|
|
17
|
-
[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
|
|
18
|
-
[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
|
|
19
|
-
cd -- "$1"
|
|
20
|
-
${w}
|
|
21
|
-
`,"easbot",y]:x==="bash"?["-l","-c",`${process.platform==="win32"?`cmd /c chcp 65001 >nul 2>&1 || true
|
|
22
|
-
`:""}shopt -s expand_aliases
|
|
23
|
-
[[ -f ~/.bashrc ]] && source ~/.bashrc >/dev/null 2>&1 || true
|
|
24
|
-
cd -- "$1"
|
|
25
|
-
${w}
|
|
26
|
-
`,"easbot",y]:/^cmd(\.exe)?$/i.test(x)?["/c",`chcp 65001 >nul 2>&1 && ${w}`]:q(x)?["-NoProfile","-Command",`[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${w}`]:["-c",w]}m.args=G;function de(f){return f?p(f):(0, m.defaultPreferred)()}m.preferred=de;function se(f){return f?p(f,{acceptable:true}):(0, m.defaultAcceptable)()}m.acceptable=se;function fe(){m.defaultPreferred.reset(),m.defaultAcceptable.reset();}m.reset=fe;async function ke(){return (process.platform==="win32"?i():await l()).filter(u=>a(u)).map(Y)}m.list=ke;function Te(f){return xn[E(f)]}m.metaInfo=Te;function Dt(f){return /[|&;<>()$`!#]/.test(f)}m.needsShell=Dt;function O(){return process.platform==="win32"?i():["/bin/bash","/bin/zsh","/bin/sh"]}m.platformShells=O;function C(f){return f?!!a(f):false}m.isValid=C;async function L(f){let u=a(f);if(!u)return;let y=E(u);if(!/^cmd(\.exe)?$/i.test(y))try{let x;q(y)?x=["-NoProfile","-Command","$PSVersionTable.PSVersion.ToString()"]:x=["--version"],e.debug(`\u83B7\u53D6 Shell \u7248\u672C: ${u}`,{shell:u,args:x});let h=await exports.PKG.run([u,...x]);if(h.code===0){let w=h.stdout.trim().split(`
|
|
27
|
-
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${w}`),w}e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${h.code}`,{stderr:h.stderr});}catch(x){e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5F02\u5E38: ${x}`);}}m.version=L;class W extends Error{constructor(y,x,h,w){super(y);chunkVRQQ33YH_cjs.c(this,"message",y);chunkVRQQ33YH_cjs.c(this,"pkg",x);chunkVRQQ33YH_cjs.c(this,"version",h);chunkVRQQ33YH_cjs.c(this,"originalError",w);this.name="InstallFailedError";}}m.InstallFailedError=W;async function V(f,u="latest",y){let{Lock:x}=await import('./chunks/lock-LMCPTUNU.cjs'),{Filesystem:h}=await import('./chunks/filesystem-OYOMZ7F3.cjs'),{PackageRegistry:w}=await import('./chunks/registry-DPBQYUUX.cjs');y=y??process.env.EASBOT_CACHE_PATH??he__default.default.join(".easbot","cache");let R=await x.write("pkg-install");try{let v=he__default.default.posix.join(y,"node_modules",f),T=he__default.default.posix.join(y,"package.json"),z=(await h.readJson(T).catch(async()=>{let K={dependencies:{}};return await h.writeJson(T,K),K})).dependencies??{},B=await h.exists(v),N=z[f],F=!1;if(!B||!N)F=!0;else {if(u!=="latest"&&N===u)return v;if(u==="latest"){if(!await w.isOutdated(f,N,y))return v;e.info("Cached version is outdated, proceeding with install",{pkg:f,cachedVersion:N}),F=!0;}}if(!F)return v;let A=m.acceptable(process.platform==="win32"?"cmd":void 0)??k(),ee=`${f}@${u}`;e.info("installing package",{pkg:f,version:u,cache:y,shell:A});let J=await exports.PKG.packageManager();if(!J)throw new W("No package manager found (npm, pnpm, bun)",f,u,"No package manager available");let Z=J.name,Qe=Z==="pnpm"?"add":"install",et=`${J.name} ${Qe} --save-exact ${ee}`;e.info(`Using ${Z} to install package`,{pkg:f,version:u,shell:A,pmPath:J.path});try{let K=await m.run(A,et,{cwd:y,timeout:6e5,windowsHide:!0});if(K.code!==0)throw new Error(`Package manager exited with code ${K.code}: ${K.stderr}`);e.info(`Successfully installed ${f}@${u} with ${Z}`);}catch(K){let Ht=K instanceof Error?K:new Error(String(K));if(!await h.exists(v))throw new W(`Failed to install ${f}@${u}`,f,u,Ht.message);e.warn("Package install failed but module exists, continuing",{error:Ht.message});}let tt=u;u==="latest"&&(tt=(await h.readJson(he__default.default.join(v,"package.json")).catch(()=>({})))?.version??"unknown");let Le=await h.readJson(T);return Le.dependencies=Le.dependencies??{},Le.dependencies[f]=tt,await h.writeJson(T,Le),e.info("Package installation completed",{pkg:f,version:tt,path:v}),v}finally{R[Symbol.dispose]();}}m.install=V;async function ve(f,u,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),w=m.args(x,u,h);e.debug(`run shell process: ${x} ${w.join(" ")}`,{command:u,cwd:h});let{windowsHide:R,env:v,...T}=y??{},I={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...v};process.platform==="win32"&&(I.CHCP="65001");let{stdin:z,stdout:B,stderr:N,timeout:F,signal:A,...ee}=T??{},J={...ee,cwd:h,env:I,windowsHide:process.platform==="win32"?R??true:void 0,shell:ee.shell,timeout:F},Z=E(x),Qe=/^cmd(\.exe)?$/i.test(Z),et=process.platform==="win32"&&Qe?"cmd":x;return exports.PKG.run([et,...w],J)}m.run=ve;function _(f,u,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),w=m.args(x,u,h);e.debug(`Spawn shell process: ${x} ${w.join(" ")}`,{command:u,cwd:h});let{stdin:R,stdout:v,stderr:T,timeout:I,signal:z,windowsHide:B,env:N,...F}=y??{},A={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...N};process.platform==="win32"&&(A.CHCP="65001");let ee=E(x),J=/^cmd(\.exe)?$/i.test(ee),Z={...F,cwd:h,env:A,windowsHide:process.platform==="win32"?B??true:void 0,shell:F.shell,timeout:I};return exports.PKG.spawn([J?"cmd":x,...w],Z)}m.spawn=_;function S(f,...u){let y=f.reduce((h,w,R)=>h+w+(u[R]??""),""),x=(h={})=>({quiet:()=>x({...h,quiet:true}),nothrow:()=>x({...h,nothrow:true}),cwd:w=>x({...h,cwd:w}),env:w=>x({...h,env:w}),stdin:w=>x({...h,stdin:w}),stdout:w=>x({...h,stdout:w}),stderr:w=>x({...h,stderr:w}),text:async()=>{let w=re(y.trim());if(w.length===0)throw new Error("Empty command");let R=w[0]??"",v=E(R),T=/^cmd(\.exe)?$/i.test(v),I=process.platform==="win32"&&T?"cmd":Te(R)?R:void 0,z=me(R,w.slice(1)),B=await m.run(I,z,{cwd:h.cwd,env:h.env,stdin:h.stdin,stdout:h.stdout,stderr:h.stderr,timeout:h.timeout,windowsHide:process.platform==="win32"?h.windowsHide??true:void 0,shell:h.shell});if(B.code!==0&&!h.nothrow)throw new Error(`Command failed with exit code ${B.code}: ${y}
|
|
28
|
-
${B.stderr}`);return B.stdout},lines:async()=>(await x(h).text()).split(`
|
|
29
|
-
`).filter(R=>R.trim()),then:(w,R)=>{let v=re(y.trim()),T=v[0]??"",I=E(T),z=/^cmd(\.exe)?$/i.test(I),B=process.platform==="win32"&&z?"cmd":Te(T)?T:void 0,N=me(T,v.slice(1));return m.run(B,N,{cwd:h.cwd,env:h.env,stdin:h.stdin,stdout:h.stdout,stderr:h.stderr,timeout:h.timeout,windowsHide:process.platform==="win32"?h.windowsHide??true:void 0,shell:h.shell}).then(F=>{if(F.code!==0&&!h.nothrow){let A=new Error(`Command failed with exit code ${F.code}: ${y}
|
|
30
|
-
${F.stderr}`);if(R){R(A);return}throw A}return w({exitCode:F.code,stdout:new TextEncoder().encode(F.stdout),stderr:new TextEncoder().encode(F.stderr),text:()=>F.stdout,lines:()=>F.stdout.split(`
|
|
31
|
-
`).filter(A=>A.trim())})},R)}});return x()}m.$=S;})(exports.Shell||(exports.Shell={}));var Br=exports.Shell.$;chunkVRQQ33YH_cjs.j();var Me=class Me extends Error{static create(t,r){var s;let n=ze__default.default.object({name:ze__default.default.literal(t),data:r}).meta({ref:t}),o=(s=class extends Me{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(Me,"Unknown",Me.create("UnknownError",ze__default.default.object({message:ze__default.default.string()})));var mt=Me;chunkVRQQ33YH_cjs.j();exports.Ignore=void 0;(t=>{function e(r){return new ht(r)}t.create=e;})(exports.Ignore||(exports.Ignore={}));var ht=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(`
|
|
32
|
-
`):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 p=t[n];if(p==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),n+=2;continue}else {r.push("\\\\"),n++;continue}if(p==="*")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(p==="?"){r.push("[^/]"),n++;continue}if(p==="["){let c=this.findMatchingBracket(t,n);if(c!==-1){let d=t.slice(n,c+1);(d.startsWith("[!")||d.startsWith("[^"))&&(d="[^"+d.slice(2)),this.ignorecase&&(d=d.toLowerCase()),r.push(d),n=c+1;continue}}if(p==="/"){r.push("/"),n++;continue}if(".+$^{}|()".includes(p)){r.push("\\"+p),n++;continue}if(this.ignorecase&&p>="A"&&p<="Z"){r.push("["+p.toLowerCase()+p+"]"),n++;continue}r.push(p),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(p){return this.debug&&console.error(`Failed to create regex for pattern "${t}":`,p),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 wn(e,t){let r=n=>{let o;try{o=e.parse(n);}catch(s){throw console.trace("schema validation failure stack trace:"),s instanceof ze.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 _r=wn;exports.Fn=void 0;(t=>t.fn=wn)(exports.Fn||(exports.Fn={}));chunkVRQQ33YH_cjs.j();function Dr(){let r=he__default.default.join(process.cwd(),".env");Ne.existsSync(r)&&dotenv.config({path:r,override:true,debug:false,encoding:"utf-8",quiet:true});}chunkVRQQ33YH_cjs.j();async function Hr(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,p]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),d=Buffer.from(p);return {exitCode:i,text:()=>c.toString(),stdout:c,stderr:d}}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 kn(e){return e?he.dirname(url.fileURLToPath(e)):typeof __dirname<"u"?__dirname:process.cwd()}function Sn(e,t,r=3){function n(o,s){if(s>r||!Ne.existsSync(o))return null;try{let a=Ne.readdirSync(o);for(let i of a){let l=he.join(o,i);try{let p=Ne.statSync(l);if(p.isFile()&&l.endsWith(t))return l;if(p.isDirectory()&&s<r){let c=n(l,s+1);if(c)return c}}catch{}}}catch{}return null}return n(e,0)}function Tn(e,t){let r=he.join(e,t);if(Ne.existsSync(r))return r;let n=t.split("/").pop()||t,o=e;for(let s=0;s<5;s++){let a=he.join(o,"assets","txt");if(Ne.existsSync(a)){let p=Sn(a,n,5);if(p)return p}let i=he.join(o,"dist","assets","txt");if(Ne.existsSync(i)){let p=Sn(i,n,5);if(p)return p}let l=he.join(o,"..");if(l===o)break;o=l;}return r}function Vr(e,t){return exports.Lazy.lazy(()=>{try{let r=kn(t),n=Tn(r,e);return exports.PKG.file(n).textSync()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}function Gr(e,t){return exports.Lazy.lazy(async()=>{try{let r=kn(t),n=Tn(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 Jr(e){return e()}chunkVRQQ33YH_cjs.j();function Kr(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 yt(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===`
|
|
33
|
-
`?o=i:/\s/.test(l)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function Zr(e,t){if(!e)return [];if(t<=0)return [e];if(e.length<=t)return [e]}function be(e,t,r){try{let n=ze.z.string().parse(e),o=ze.z.number().int().parse(t),s=Zr(n,o);if(s)return s;let a=xt(n,o,i=>{let{lastNewline:l,lastWhitespace:p}=yt(i,0,i.length);return l>0?l:p});return r?.minLength&&r.minLength>0&&(a=Rn(a,r.minLength)),a}catch(n){return console.warn("Invalid input for chunkText:",n),typeof e=="string"&&e.length>0?[e]:[]}}function Rn(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+`
|
|
12
|
+
${U}`,truncated:true,outputPath:O,originalLength:c.length,removedLength:ie,label:g}}p.truncate=a;function s(c){return c.truncated?i(c.outputPath,c.label):""}p.formatHint=s;async function l(){let c=exports.Identifier.timestamp(exports.Identifier.create("context",false,Date.now()-o)),d=(await ue__default.default.readdir(p.DIR).catch(()=>[])).filter(m=>m.startsWith("context_"));for(let m of d)exports.Identifier.timestamp(m)>=c||await ue__default.default.unlink(chunk6JM5F6FM_cjs.d.join(p.DIR,m)).catch(()=>{});}p.cleanup=l;})(exports.TruncateContent||(exports.TruncateContent={}));chunkVRQQ33YH_cjs.j();exports.SessionTitle=void 0;(s=>{let t="New session - ",e="Child session - ";s.parentTitlePrefix=t,s.childTitlePrefix=e;function o(l=false){return (l?e:t)+chunkA2TCSTSM_cjs.b(new Date)}s.createDefault=o;function i(l){return new RegExp(`^(${t}|${e})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(l)}s.isDefault=i;function a(l){let p=l.match(/^(.+) \(fork #(\d+)\)$/);if(p){let c=p[1]??"",u=parseInt(p[2]??"0",10);return `${c} (fork #${u+1})`}return `${l} (fork #1)`}s.getForked=a;})(exports.SessionTitle||(exports.SessionTitle={}));chunkVRQQ33YH_cjs.j();var Q=class Q extends Error{static create(e,n){var i;let r=pe__default.default.object({name:pe__default.default.literal(e),data:n}).meta({ref:e}),o=(i=class extends Q{constructor(s,l){super(e,l);chunkVRQQ33YH_cjs.c(this,"data",s);chunkVRQQ33YH_cjs.c(this,"name",e);this.name=e;}static isInstance(s){return s!==null&&typeof s=="object"&&"name"in s&&s.name===e}schema(){return r}toObject(){return {name:e,data:this.data}}},chunkVRQQ33YH_cjs.c(i,"Schema",r),i);return Object.defineProperty(o,"name",{value:e}),o}};chunkVRQQ33YH_cjs.c(Q,"Unknown",Q.create("UnknownError",pe__default.default.object({message:pe__default.default.string()})));var Le=Q;chunkVRQQ33YH_cjs.j();exports.Ignore=void 0;(e=>{function t(n){return new Ae(n)}e.create=t;})(exports.Ignore||(exports.Ignore={}));var Ae=class{constructor(e){chunkVRQQ33YH_cjs.c(this,"rules",[]);chunkVRQQ33YH_cjs.c(this,"ignorecase");chunkVRQQ33YH_cjs.c(this,"debug");this.ignorecase=e?.ignorecase??false,this.debug=e?.debug??false;}add(e){let n=typeof e=="string"?e.split(`
|
|
13
|
+
`):e;for(let r=0;r<n.length;r++){let o=n[r];this.parseRule(o,r+1);}return this}parseRule(e,n){let r=e,o=e;if(r.length===0||r.startsWith("#"))return;let i=r.startsWith("!");if(i&&(r=r.slice(1)),r=r.trim(),r.length===0||(r.startsWith("\\#")&&(r=r.slice(1)),r.startsWith("#")))return;let a=r.startsWith("/");a&&(r=r.slice(1));let s=r.endsWith("/");s&&(r=r.slice(0,-1)),r.length!==0&&this.rules.push({pattern:r,negative:i,isDirectory:s,anchored:a,original:o,lineNumber:n});}ignores(e,n){let r=this.normalizePath(e),o=n??e.endsWith("/"),i=this.checkIgnore(r,o);return this.debug&&console.log(`Ignore.ignores("${e}", isDirectory=${o}) => ${i}`),i}checkIgnore(e,n){let r=false;for(let o of this.rules)o.isDirectory&&!n||this.matchPath(o,e)&&(o.negative?r=false:r=true);return r}matchPath(e,n){let r=this.ignorecase?n.toLowerCase():n,i=this.ignorecase?e.pattern.toLowerCase():e.pattern;if(e.anchored)return chunk6JM5F6FM_cjs.a.match(r,i);if(i.includes("/"))return chunk6JM5F6FM_cjs.a.match(r,i);let a=r.split("/");for(let s of a)if(chunk6JM5F6FM_cjs.a.match(s,i))return true;return false}filter(e){return e.filter(n=>!this.ignores(n))}createFilter(){return e=>!this.ignores(e)}normalizePath(e){let n=e.replace(/\\/g,"/");if(n==="/")return "";for(;n.startsWith("./");)n=n.slice(2);return n.endsWith("/")&&n.length>1&&(n=n.slice(0,-1)),n}};chunkVRQQ33YH_cjs.j();function st(t,e){let n=r=>{let o;try{o=t.parse(r);}catch(i){throw console.trace("schema validation failure stack trace:"),i instanceof pe.z.ZodError&&console.error("schema validation issues:",JSON.stringify(i.issues,null,2)),i}return e(o)};return n.force=r=>e(r),n.schema=t,n}var on=st;exports.Fn=void 0;(e=>e.fn=st)(exports.Fn||(exports.Fn={}));chunkVRQQ33YH_cjs.j();function ln(t={}){let e=t.isDevelopment??false,n=e?".env.dev":".env",r=t.globalConfigPath??(xdgBasedir.xdgConfig?De__default.default.join(xdgBasedir.xdgConfig,"easbot"):void 0),o=t.projectRoot??process.cwd(),i=o?De__default.default.join(o,".easbot"):void 0,a=[{root:r,label:"global"},{root:o,label:"project"},{root:i,label:"workspace"}];for(let{root:s}of a){if(!s)continue;let l=De__default.default.join(s,n);if(!fs.existsSync(l))continue;let p=dotenv.config({path:l,override:true,debug:e,encoding:"utf-8",quiet:!e});if(e&&p.parsed){let u=["XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_CACHE_HOME","XDG_STATE_HOME","XDG_RUNTIME_DIR","EASBOT_CONFIG_PATH","EASBOT_DATA_PATH","EASBOT_CACHE_PATH","EASBOT_STATE_PATH","EASBOT_LOG_PATH","EASBOT_BIN_PATH"].filter(d=>d in p.parsed);u.length>0&&console.warn(`[loadEnv] ${l} contains keys that have no effect: ${u.join(", ")}.
|
|
14
|
+
Reason: xdg-basedir caches XDG_* on import, so this .env file loads too late.
|
|
15
|
+
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}chunkVRQQ33YH_cjs.j();async function cn(t,e){if(process.env.EASBOT_CLIENT==="acp")try{let i=process.platform==="win32"?"cmd":void 0,a=chunkJQNKLHWT_cjs.G.spawn(i,`git ${t.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:e.cwd,env:e.env?{...process.env,...e.env}:process.env}),[s,l,p]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),u=Buffer.from(p);return {exitCode:s,text:()=>c.toString(),stdout:c,stderr:u}}catch(i){let a=Buffer.from(i instanceof Error?i.message:String(i));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:a}}let n=e.env?{...process.env,...e.env}:void 0,r=chunkJQNKLHWT_cjs.G.$`git ${t.join(" ")}`.quiet().nothrow().cwd(e.cwd);n&&(r=r.env(n));let o=await r;return {exitCode:o.exitCode,text:()=>o.text(),stdout:o.stdout,stderr:o.stderr}}chunkVRQQ33YH_cjs.j();function lt(t){return t?De.dirname(url.fileURLToPath(t)):typeof __dirname<"u"?__dirname:process.cwd()}function at(t,e,n=3){function r(o,i){if(i>n||!fs.existsSync(o))return null;try{let a=fs.readdirSync(o);for(let s of a){let l=De.join(o,s);try{let p=fs.statSync(l);if(p.isFile()&&l.endsWith(e))return l;if(p.isDirectory()&&i<n){let c=r(l,i+1);if(c)return c}}catch{}}}catch{}return null}return r(t,0)}function ct(t,e){let n=De.join(t,e);if(fs.existsSync(n))return n;let r=e.split("/").pop()||e,o=t;for(let i=0;i<5;i++){let a=De.join(o,"assets","txt");if(fs.existsSync(a)){let p=at(a,r,5);if(p)return p}let s=De.join(o,"dist","assets","txt");if(fs.existsSync(s)){let p=at(s,r,5);if(p)return p}let l=De.join(o,"..");if(l===o)break;o=l;}return n}function mn(t,e){return chunkJQNKLHWT_cjs.c.lazy(()=>{try{let n=lt(e),r=ct(n,t);return chunkJQNKLHWT_cjs.D.file(r).textSync()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}function hn(t,e){return chunkJQNKLHWT_cjs.c.lazy(async()=>{try{let n=lt(e),r=ct(n,t);return await chunkJQNKLHWT_cjs.D.file(r).text()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}chunkVRQQ33YH_cjs.j();function gn(t){return t()}chunkVRQQ33YH_cjs.j();function yn(t){if(!t||typeof t!="string")return {provider:"",model:""};let e=t.indexOf("/");return e===-1?{provider:"",model:t}:{provider:t.substring(0,e),model:t.substring(e+1)}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function ze(t,e,n,r=()=>true){let o=-1,i=-1,a=0;for(let s=e;s<n;s++){if(!r(s))continue;let l=t[s];if(l){if(l==="("){a+=1;continue}if(l===")"&&a>0){a-=1;continue}a===0&&(l===`
|
|
16
|
+
`?o=s:/\s/.test(l)&&(i=s));}}return {lastNewline:o,lastWhitespace:i}}function bn(t,e){if(!t)return [];if(e<=0)return [t];if(t.length<=e)return [t]}function q(t,e,n){try{let r=pe.z.string().parse(t),o=pe.z.number().int().parse(e),i=bn(r,o);if(i)return i;let a=Be(r,o,s=>{let{lastNewline:l,lastWhitespace:p}=ze(s,0,s.length);return l>0?l:p});return n?.minLength&&n.minLength>0&&(a=pt(a,n.minLength)),a}catch(r){return console.warn("Invalid input for chunkText:",r),typeof t=="string"&&t.length>0?[t]:[]}}function pt(t,e){if(t.length<=1||e<=0)return t;let n=[],r=t[0]??"";for(let o=1;o<t.length;o++){let i=t[o]??"";r.length<e?r=r+`
|
|
34
17
|
|
|
35
|
-
`+
|
|
18
|
+
`+i:(n.push(r),r=i);}if(r.length>0)if(r.length<e&&n.length>0){let o=n.pop();n.push(o+`
|
|
36
19
|
|
|
37
|
-
`+
|
|
20
|
+
`+r);}else n.push(r);return n}function Be(t,e,n){if(!t)return [];if(e<=0||t.length<=e)return [t];let r=[],o=t;for(;o.length>e;){let i=o.slice(0,e),a=n(i),s=Number.isFinite(a)&&a>0&&a<=e?a:e,p=o.slice(0,s).trimEnd();p.length>0&&r.push(p);let c=s<o.length&&o[s]!==void 0&&/\s/.test(o[s]),u=Math.min(o.length,s+(c?1:0));o=o.slice(u).trimStart();}return o.length>0&&r.push(o),r}chunkVRQQ33YH_cjs.j();var Ne=pe.z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),dt=pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),style:Ne}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),ft=pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),href:pe.z.string().min(1)}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),te=pe.z.object({text:pe.z.string(),styles:pe.z.array(dt),links:pe.z.array(ft)}).strict(),ne=pe.z.enum(["off","bullets","code"]),fe=pe.z.object({linkify:pe.z.boolean().default(true),enableSpoilers:pe.z.boolean().default(false),headingStyle:pe.z.enum(["none","bold"]).default("none"),blockquotePrefix:pe.z.string().default(""),autolink:pe.z.boolean().default(true),tableMode:ne.default("off")}).partial().default({}),mt=pe.z.object({open:pe.z.string(),close:pe.z.string()}).strict(),je=pe.z.object({styleMarkers:pe.z.record(Ne,mt).optional(),escapeText:pe.z.any().optional(),buildLink:pe.z.any().optional()}).strict();pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),open:pe.z.string(),close:pe.z.string()}).strict();var He=pe.z.object({indentSize:pe.z.number().int().min(1).default(2),listMarker:pe.z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:pe.z.enum(["```","~~~"]).default("```"),preserveFrontmatter:pe.z.boolean().default(true)}).strict(),Ue=pe.z.record(pe.z.string(),pe.z.string()),me=pe.z.object({open:pe.z.boolean(),ticks:pe.z.number().int().min(0)}).strict();pe.z.object({inlineState:me,isInside:pe.z.any()}).strict();pe.z.object({start:pe.z.number().int().min(0),end:pe.z.number().int().min(0),openLine:pe.z.string(),marker:pe.z.string(),indent:pe.z.string()}).strict();pe.z.object({tables:ne.optional()}).strict();function Mn(t){let e=new Tn__default.default({html:false,linkify:t.linkify??true,breaks:false,typographer:false});return e.enable("strikethrough"),t.tableMode&&t.tableMode!=="off"?e.enable("table"):e.disable("table"),t.autolink===false&&e.disable("autolink"),e}function ht(t,e){if(t.attrGet)return t.attrGet(e);if(t.attrs){for(let[n,r]of t.attrs)if(n===e)return r}return null}function We(t,e){return {...t,type:"text",content:e,children:void 0}}function Rn(t){for(let e of t)e.children&&e.children.length>0&&(e.children=vn(e.children));}function vn(t){let e=0;for(let a of t){if(a.type!=="text")continue;let s=a.content??"",l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1)break;e+=1,l=p+2;}}if(e<2)return t;let n=e-e%2,r=[],o={spoilerOpen:false},i=0;for(let a of t){if(a.type!=="text"){r.push(a);continue}let s=a.content??"";if(!s.includes("||")){r.push(a);continue}let l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1){l<s.length&&r.push(We(a,s.slice(l)));break}if(i>=n){r.push(We(a,s.slice(l)));break}p>l&&r.push(We(a,s.slice(l,p))),i+=1,o.spoilerOpen=!o.spoilerOpen,r.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=p+2;}}return r}function In(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function H(t){return t.table?.currentCell??t}function he(t,e){if(!e)return;let n=H(t);n.text+=e;}function G(t,e){let n=H(t);n.openStyles.push({style:e,start:n.text.length});}function Y(t,e){let n=H(t);for(let r=n.openStyles.length-1;r>=0;r-=1){let o=n.openStyles[r];if(o?.style===e){let i=o.start;n.openStyles.splice(r,1);let a=n.text.length;a>i&&n.styles.push({start:i,end:a,style:e});return}}}function gt(t){t.env.listStack.length>0||t.table||(t.text+=`
|
|
38
21
|
|
|
39
|
-
`);}function
|
|
40
|
-
`);}function
|
|
41
|
-
`;}for(let a=1;a<o.length;a++)
|
|
42
|
-
`;}else for(let o of
|
|
43
|
-
`;}}function
|
|
44
|
-
`;},l=()=>{
|
|
45
|
-
`;};
|
|
46
|
-
`);break;case "paragraph_close":
|
|
47
|
-
`),
|
|
48
|
-
`);break;case "ordered_list_open":{
|
|
49
|
-
`);let
|
|
50
|
-
`);break;case "list_item_open":
|
|
51
|
-
`)||(
|
|
52
|
-
`);break;case "code_block":case "fence":
|
|
22
|
+
`);}function Pn(t){let e=t.env.listStack,n=e[e.length-1];if(!n)return;n.index+=1;let r=" ".repeat(Math.max(0,e.length-1)),o=n.type==="ordered"?`${n.index}. `:"\u2022 ";t.text+=`${r}${o}`;}function Fn(t,e){if(!e)return;let n=H(t),r=n.text.length;n.text+=e,n.styles.push({start:r,end:r+e.length,style:"code"});}function _n(t,e){let n=e??"",r=H(t),o=r.text.length;r.text+=n,r.styles.push({start:o,end:o+n.length,style:"code_block"});}function Cn(t){let e=H(t),n=e.linkStack.pop();if(!n?.href)return;let r=n.href.trim();if(!r)return;let o=n.labelStart,i=e.text.length;if(i<=o){e.links.push({start:o,end:i,href:r});return}e.links.push({start:o,end:i,href:r});}function On(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function Ln(t){return bt(t),{text:t.text,styles:t.styles,links:t.links}}function ge(t){let e=t.text,n=0,r=e.length;for(;n<r&&/\s/.test(e[n]??"");)n+=1;for(;r>n&&/\s/.test(e[r-1]??"");)r-=1;if(n===0&&r===e.length)return t;let o=e.slice(n,r),i=o.length,a=[];for(let l of t.styles){let p=Math.max(0,l.start-n),c=Math.min(i,l.end-n);c>p&&a.push({start:p,end:c,style:l.style});}let s=[];for(let l of t.links){let p=Math.max(0,l.start-n),c=Math.min(i,l.end-n);c>p&&s.push({start:p,end:c,href:l.href});}return {text:o,styles:a,links:s}}function qe(t,e){if(!e.text)return;let n=t.text.length;t.text+=e.text;for(let r of e.styles)t.styles.push({start:n+r.start,end:n+r.end,style:r.style});for(let r of e.links)t.links.push({start:n+r.start,end:n+r.end,href:r.href});}function En(t,e){e.text&&(t.text+=e.text);}function yt(t,e){let{header:n,value:r,columnIndex:o,includeColumnFallback:i}=e;r?.text&&(t.text+="\u2022 ",n?.text?(qe(t,n),t.text+=": "):i&&(t.text+=`Column ${o}: `),qe(t,r),t.text+=`
|
|
23
|
+
`);}function An(t){if(!t.table)return;let e=t.table.headers.map(ge),n=t.table.rows.map(o=>o.map(ge));if(e.length===0&&n.length===0)return;if(e.length>1&&n.length>0)for(let o of n){if(o.length===0)continue;let i=o[0];if(i?.text){let a=t.text.length;qe(t,i);let s=t.text.length;s>a&&t.styles.push({start:a,end:s,style:"bold"}),t.text+=`
|
|
24
|
+
`;}for(let a=1;a<o.length;a++)yt(t,{header:e[a],value:o[a],columnIndex:a,includeColumnFallback:true});t.text+=`
|
|
25
|
+
`;}else for(let o of n){for(let i=0;i<o.length;i++)yt(t,{header:e[i],value:o[i],columnIndex:i,includeColumnFallback:false});t.text+=`
|
|
26
|
+
`;}}function $n(t){if(!t.table)return;let e=t.table.headers.map(ge),n=t.table.rows.map(c=>c.map(ge)),r=Math.max(e.length,...n.map(c=>c.length));if(r===0)return;let o=Array.from({length:r},()=>0),i=c=>{for(let u=0;u<r;u+=1){let m=c[u]?.text.length??0;(o[u]??0)<m&&(o[u]=m);}};i(e);for(let c of n)i(c);let a=t.text.length,s=c=>{t.text+="|";for(let u=0;u<r;u+=1){t.text+=" ";let d=c[u];d&&En(t,d);let m=d?.text.length??0,k=(o[u]??0)-m;k>0&&(t.text+=" ".repeat(k)),t.text+=" |";}t.text+=`
|
|
27
|
+
`;},l=()=>{t.text+="|";for(let c=0;c<r;c+=1){let u=o[c]??0,d=Math.max(3,u);t.text+=` ${"-".repeat(d)} |`;}t.text+=`
|
|
28
|
+
`;};s(e),l();for(let c of n)s(c);let p=t.text.length;p>a&&t.styles.push({start:a,end:p,style:"code_block"});}function Ge(t,e){for(let n of t)switch(n.type){case "inline":n.children&&Ge(n.children,e);break;case "text":he(e,n.content??"");break;case "em_open":G(e,"italic");break;case "em_close":Y(e,"italic");break;case "strong_open":G(e,"bold");break;case "strong_close":Y(e,"bold");break;case "s_open":G(e,"strikethrough");break;case "s_close":Y(e,"strikethrough");break;case "code_inline":Fn(e,n.content??"");break;case "spoiler_open":e.enableSpoilers&&G(e,"spoiler");break;case "spoiler_close":e.enableSpoilers&&Y(e,"spoiler");break;case "link_open":{let r=ht(n,"href")??"",o=H(e);o.linkStack.push({href:r,labelStart:o.text.length});break}case "link_close":Cn(e);break;case "image":he(e,n.content??"");break;case "softbreak":case "hardbreak":he(e,`
|
|
29
|
+
`);break;case "paragraph_close":gt(e);break;case "heading_open":e.headingStyle==="bold"&&G(e,"bold");break;case "heading_close":e.headingStyle==="bold"&&Y(e,"bold"),gt(e);break;case "blockquote_open":e.blockquotePrefix&&(e.text+=e.blockquotePrefix),G(e,"blockquote");break;case "blockquote_close":Y(e,"blockquote");break;case "bullet_list_open":e.env.listStack.length>0&&(e.text+=`
|
|
30
|
+
`),e.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
|
|
31
|
+
`);break;case "ordered_list_open":{e.env.listStack.length>0&&(e.text+=`
|
|
32
|
+
`);let r=Number(ht(n,"start")??"1");e.env.listStack.push({type:"ordered",index:r-1});break}case "ordered_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
|
|
33
|
+
`);break;case "list_item_open":Pn(e);break;case "list_item_close":e.text.endsWith(`
|
|
34
|
+
`)||(e.text+=`
|
|
35
|
+
`);break;case "code_block":case "fence":_n(e,n.content??"");break;case "html_block":case "html_inline":he(e,n.content??"");break;case "table_open":e.tableMode!=="off"&&(e.table=On(),e.hasTables=true);break;case "table_close":e.table&&(e.tableMode==="bullets"?An(e):e.tableMode==="code"&&$n(e)),e.table=null;break;case "thead_open":e.table&&(e.table.inHeader=true);break;case "thead_close":e.table&&(e.table.inHeader=false);break;case "tbody_open":case "tbody_close":break;case "tr_open":e.table&&(e.table.currentRow=[]);break;case "tr_close":e.table&&(e.table.inHeader?e.table.headers=e.table.currentRow:e.table.rows.push(e.table.currentRow),e.table.currentRow=[]);break;case "th_open":case "td_open":e.table&&(e.table.currentCell=In());break;case "th_close":case "td_close":e.table?.currentCell&&(e.table.currentRow.push(Ln(e.table.currentCell)),e.table.currentCell=null);break;case "hr":e.text+=`\u2500\u2500\u2500
|
|
53
36
|
|
|
54
|
-
`;break;default:
|
|
55
|
-
`);let
|
|
37
|
+
`;break;default:n.children&&Ge(n.children,e);break}}function bt(t){for(let e=t.openStyles.length-1;e>=0;e-=1){let n=t.openStyles[e];if(!n)continue;let r=t.text.length;r>n.start&&t.styles.push({start:n.start,end:r,style:n.style});}t.openStyles=[];}function Dn(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),i=Math.max(o,Math.min(r.end,e));i>o&&n.push({start:o,end:i,style:r.style});}return n}function zn(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),i=Math.max(o,Math.min(r.end,e));i>o&&n.push({start:o,end:i,href:r.href});}return n}function xt(t){let e=[...t].toSorted((r,o)=>r.start!==o.start?r.start-o.start:r.end!==o.end?r.end-o.end:r.style.localeCompare(o.style)),n=[];for(let r of e){let o=n[n.length-1];if(o&&o.style===r.style&&(r.start<o.end||r.start===o.end&&r.style!=="blockquote")){o.end=Math.max(o.end,r.end);continue}n.push({...r});}return n}function kt(t,e,n){let r=Math.max(t.start,e),o=Math.min(t.end,n);return o<=r?null:{start:r,end:o}}function Bn(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let i=kt(o,e,n);i&&r.push({start:i.start-e,end:i.end-e,style:o.style});}return xt(r)}function Nn(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let i=kt(o,e,n);i&&r.push({start:i.start-e,end:i.end-e,href:o.href});}return r}function X(t,e){try{let n=typeof t=="string"?t:"",r=fe.parse(e??{});return re(n,r).ir}catch(n){return console.error("Markdown parse error:",n),{text:"",styles:[],links:[]}}}function re(t,e){try{let n=typeof t=="string"?t:"",r=fe.parse(e),o={listStack:[]},a=Mn(r).parse(n||"",o);r.enableSpoilers&&Rn(a);let s=r.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:r.headingStyle??"none",blockquotePrefix:r.blockquotePrefix??"",enableSpoilers:r.enableSpoilers??!1,tableMode:s,table:null,hasTables:!1};Ge(a,l),bt(l);let c=l.text.trimEnd().length,u=0;for(let g of l.styles)g.style==="code_block"&&g.end>u&&(u=g.end);let d=Math.max(c,u);return {ir:{text:d===l.text.length?l.text:l.text.slice(0,d),styles:xt(Dn(l.styles,d)),links:zn(l.links,d)},hasTables:l.hasTables}}catch(n){return console.error("Markdown parse error:",n),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function St(t,e){try{let n=te.parse(t),r=typeof e=="number"&&e>0?e:0;if(!n.text)return [];if(r<=0||n.text.length<=r)return [n];let o=q(n.text,r),i=[],a=0;return o.forEach((s,l)=>{if(!s)return;if(l>0)for(;a<n.text.length&&/\s/.test(n.text[a]??"");)a+=1;let p=a,c=Math.min(n.text.length,p+s.length);i.push({text:s,styles:Bn(n.styles,p,c),links:Nn(n.links,p,c)}),a=c;}),i}catch(n){return console.error("Chunk IR error:",n),[]}}chunkVRQQ33YH_cjs.j();var jn={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function oe(t,e){try{let n=te.parse(t),r=je.parse(e??{});if(!n.text)return "";let o=r.styleMarkers??jn,i=r.escapeText??(u=>u),a=r.buildLink,s=[];for(let u=0;u<n.styles.length;u++){let d=n.styles[u];d&&(s.push({position:d.start,type:"open",style:d.style,spanIndex:u}),s.push({position:d.end,type:"close",style:d.style,spanIndex:u}));}for(let u=0;u<n.links.length;u++){let d=n.links[u];d&&(s.push({position:d.start,type:"link_open",spanIndex:u,href:d.href}),s.push({position:d.end,type:"link_close",spanIndex:u,href:d.href}));}s.sort((u,d)=>{if(u.position!==d.position)return u.position-d.position;let m=(P,O)=>P==="link_open"?0:P==="open"?1:P==="close"?2:P==="link_close"?3:4,g=u.type==="close"||u.type==="link_close",k=d.type==="close"||d.type==="link_close",S=m(u.type,g),R=m(d.type,k);return S!==R?S-R:u.type==="open"&&d.type==="open"?u.spanIndex-d.spanIndex:u.type==="close"&&d.type==="close"?d.spanIndex-u.spanIndex:u.spanIndex-d.spanIndex});let l="",p=0,c=[];for(let u of s){if(u.position>p){let d=n.text.slice(p,u.position);l+=i?i(d):d;}if(u.type==="open"||u.type==="close"){let d=o[u.style];if(d)if(u.type==="open")l+=d.open,c.push(u);else {l+=d.close,u.style==="code_block"&&u.position<n.text.length&&(l+=`
|
|
38
|
+
`);let m=c.findIndex(g=>g.spanIndex===u.spanIndex&&g.type==="open");m!==-1&&c.splice(m,1);}}else if(u.type==="link_open")l+="[",c.push(u);else if(u.type==="link_close"){l+="]("+u.href+")";let d=c.findIndex(m=>m.spanIndex===u.spanIndex&&m.type==="link_open");d!==-1&&c.splice(d,1);}p=u.position;}if(p<n.text.length){let u=n.text.slice(p);l+=i?i(u):u;}return l}catch(n){return console.error("Markdown render error:",n),""}}function V(t,e){return oe(t,e)}chunkVRQQ33YH_cjs.j();function Hn(t){let e=t.replace(/\r\n/g,`
|
|
56
39
|
`).replace(/\r/g,`
|
|
57
|
-
`);if(!
|
|
58
|
-
---`,3);if(
|
|
40
|
+
`);if(!e.startsWith("---"))return {frontmatter:"",content:t};let n=e.indexOf(`
|
|
41
|
+
---`,3);if(n===-1)return {frontmatter:"",content:t};let r=e.slice(0,n+4),o=e.slice(n+4).trimStart();return {frontmatter:r,content:o}}function ye(t,e){try{let n=typeof t=="string"?t:"",r=He.parse(e??{});if(!n)return "";let{frontmatter:o,content:i}=Hn(n),a=X(i,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),s=V(a);return s=s.replace(/\n{3,}/g,`
|
|
59
42
|
|
|
60
|
-
`),
|
|
61
|
-
`,
|
|
62
|
-
`+
|
|
63
|
-
`).trim(),linesConsumed:
|
|
64
|
-
`),
|
|
43
|
+
`),s=s.trimEnd()+`
|
|
44
|
+
`,r.preserveFrontmatter&&o&&(s=o+`
|
|
45
|
+
`+s),s}catch(n){return console.error("Markdown format error:",n),t}}chunkVRQQ33YH_cjs.j();function Un(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function Wn(t){if(t!=null){if(typeof t=="string")return {value:t.trim(),kind:"scalar"};if(typeof t=="number"||typeof t=="boolean")return {value:String(t),kind:"scalar"};if(typeof t=="object")try{return {value:JSON.stringify(t),kind:"structured"}}catch{return}}}function qn(t){try{let e=wt__default.default.parse(t,{schema:"core"});if(!e||typeof e!="object"||Array.isArray(e))return null;let n={};for(let[r,o]of Object.entries(e)){let i=r.trim();if(!i)continue;let a=Wn(o);a&&(n[i]=a);}return n}catch{return null}}function Gn(t,e){let n=[],r=e+1;for(;r<t.length;){let i=t[r];if(!i){r+=1;continue}if(i.length>0&&!i.startsWith(" ")&&!i.startsWith(" "))break;n.push(i),r+=1;}return {value:n.join(`
|
|
46
|
+
`).trim(),linesConsumed:r-e}}function Yn(t){let e={},n=t.split(`
|
|
47
|
+
`),r=0;for(;r<n.length;){let o=n[r];if(!o){r+=1;continue}let i=o.match(/^([\w-]+):\s*(.*)$/);if(!i?.[1]||!i[2]){r+=1;continue}let a=i[1],s=i[2].trim();if(!a){r+=1;continue}if(!s&&r+1<n.length){let p=n[r+1];if(p&&(p.startsWith(" ")||p.startsWith(" "))){let{value:c,linesConsumed:u}=Gn(n,r);c&&(e[a]={value:c,kind:"multiline",rawInline:s}),r+=u;continue}}let l=Un(s);l&&(e[a]={value:l,kind:"inline",rawInline:s}),r+=1;}return e}function Xn(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.value;return e}function Vn(t){return /^[|>][+-]?(\d+)?[+-]?$/.test(t)}function Kn(t){let{lineEntry:e,yamlValue:n}=t;return n.kind!=="structured"||e.kind!=="inline"||Vn(e.rawInline)?false:e.value.includes(":")}function Zn(t){let e=t.replace(/\r\n/g,`
|
|
65
48
|
`).replace(/\r/g,`
|
|
66
|
-
`);if(!
|
|
67
|
-
---`,3);if(
|
|
68
|
-
${
|
|
69
|
-
---`}catch(
|
|
49
|
+
`);if(!e.startsWith("---"))return;let n=e.indexOf(`
|
|
50
|
+
---`,3);if(n!==-1)return e.slice(4,n)}function se(t){try{if(typeof t!="string")return {};let e=Zn(t);if(!e)return {};let n=Yn(e),r=qn(e);if(r===null)return Xn(n);let o={};for(let[i,a]of Object.entries(r)){o[i]=a.value;let s=n[i];s&&Kn({lineEntry:s,yamlValue:a})&&(o[i]=s.value);}for(let[i,a]of Object.entries(n))i in o||(o[i]=a.value);return o}catch(e){return console.warn("Failed to parse frontmatter:",e),{}}}function be(t){try{let e=Ue.parse(t);if(Object.keys(e).length===0)return "";let n={};for(let[o,i]of Object.entries(e))try{let a=JSON.parse(i);n[o]=a;}catch{n[o]=i;}return `---
|
|
51
|
+
${wt__default.default.stringify(n,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
52
|
+
---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function xe(t){try{if(typeof t!="string")return {frontmatter:{},content:""};let e=t.replace(/\r\n/g,`
|
|
70
53
|
`).replace(/\r/g,`
|
|
71
|
-
`);if(!
|
|
72
|
-
---`,3);if(
|
|
73
|
-
`,o),a=
|
|
74
|
-
Content-Type: ${
|
|
54
|
+
`);if(!e.startsWith("---"))return {frontmatter:{},content:t};let n=e.indexOf(`
|
|
55
|
+
---`,3);if(n===-1)return {frontmatter:{},content:t};let r=e.slice(4,n),o=e.slice(n+4).trimStart();return {frontmatter:se(t),content:o}}catch(e){return console.warn("Failed to extract frontmatter:",e),{frontmatter:{},content:t}}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function ke(t){try{let e=pe.z.string().parse(t),n=[],r,o=0;for(;o<=e.length;){let i=e.indexOf(`
|
|
56
|
+
`,o),a=i===-1?e.length:i,s=e.slice(o,a),l=s.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let p=l[1],c=l[2];if(!p||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let d=c.length;if(!r)r={start:o,markerChar:u,markerLen:d,openLine:s,marker:c,indent:p};else if(r.markerChar===u&&d>=r.markerLen){let m=a;n.push({start:r.start,end:m,openLine:r.openLine,marker:r.marker,indent:r.indent}),r=void 0;}}if(i===-1)break;o=i+1;}return r&&n.push({start:r.start,end:e.length,openLine:r.openLine,marker:r.marker,indent:r.indent}),n}catch(e){return console.warn("Invalid input for parseFenceSpans:",e),[]}}function Ye(t,e){let n=0,r=t.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),i=t[o];if(!i)break;if(e<=i.start){r=o-1;continue}if(e>=i.end){n=o+1;continue}return i}}function Tt(t,e){return !Ye(t,e)}function Se(){return {open:false,ticks:0}}function we(t,e){try{let n=pe.z.string().parse(t),r=e?me.parse(e):Se(),o=ke(n),i={open:r.open,ticks:r.ticks},{spans:a,state:s}=er(n,o,i);return {inlineState:s,isInside:l=>nr(l,o)||rr(l,a)}}catch(n){return console.warn("Invalid input for buildCodeSpanIndex:",n),{inlineState:Se(),isInside:()=>false}}}function er(t,e,n){let r=[],o=n.open,i=n.ticks,a=o?0:-1,s=0;for(;s<t.length;){let l=tr(e,s);if(l){s=l.end;continue}if(t[s]!=="`"){s+=1;continue}let p=s,c=0;for(;s<t.length&&t[s]==="`";)c+=1,s+=1;if(!o){o=true,i=c,a=p;continue}c===i&&(r.push([a,s]),o=false,i=0,a=-1);}return o&&r.push([a,t.length]),{spans:r,state:{open:o,ticks:i}}}function tr(t,e){return t.find(n=>e>=n.start&&e<n.end)}function nr(t,e){return e.some(n=>t>=n.start&&t<n.end)}function rr(t,e){return e.some(([n,r])=>t>=n&&t<r)}chunkVRQQ33YH_cjs.j();var sr={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Te(t,e){try{let n=pe.z.string().parse(t),r=ne.parse(e);if(!n||r==="off")return n;let{ir:o,hasTables:i}=re(n,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:r});return i?oe(o,{styleMarkers:sr,escapeText:a=>a,buildLink:(a,s)=>{let l=a.href.trim();return !l||!s.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):n}catch(n){return console.warn("Invalid input for convertMarkdownTables:",n),typeof t=="string"?t:""}}exports.Markdown=void 0;(p=>{function t(c,u){try{return X(c,u)}catch(d){return console.warn("Markdown.parse error:",d),{text:"",styles:[],links:[]}}}p.parse=t;function e(c,u){try{return V(c,u)}catch(d){return console.warn("Markdown.render error:",d),""}}p.render=e;function n(c,u){try{return ye(c,u)}catch(d){return console.warn("Markdown.format error:",d),typeof c=="string"?c:""}}p.format=n;function r(c){try{return se(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}p.parseFrontmatter=r;function o(c){try{return be(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}p.serializeFrontmatter=o;function i(c){try{return xe(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}p.extractFrontmatter=i;function a(c,u,d){try{return q(c,u,d)}catch(m){return console.warn("Markdown.chunk error:",m),typeof c=="string"&&c.length>0?[c]:[]}}p.chunk=a;function s(c,u){try{return we(c,u)}catch(d){return console.warn("Markdown.buildCodeIndex error:",d),{inlineState:{open:false,ticks:0},isInside:()=>false}}}p.buildCodeIndex=s;function l(c,u){try{return Te(c,u)}catch(d){return console.warn("Markdown.convertTables error:",d),typeof c=="string"?c:""}}p.convertTables=l;})(exports.Markdown||(exports.Markdown={}));chunkVRQQ33YH_cjs.j();function Mt(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n[n.length-1]??""}function ir(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n.slice(0,n.length-1).join("/")+"/"}function ar(t){if(!t)return "";let e=t.split(".");return e[e.length-1]}function lr(t,e=20){let n=Mt(t);if(n.length<=e)return n;let r=n.lastIndexOf("."),o=r<=0?"":n.slice(r),i=e-o.length-1;return i<=0?n.slice(0,e-1)+"\u2026":n.slice(0,i)+"\u2026"+o}function cr(t,e=20){if(t.length<=e)return t;let n=e-1,r=Math.ceil(n/2),o=Math.floor(n/2);return t.slice(0,r)+"\u2026"+t.slice(-o)}chunkVRQQ33YH_cjs.j();var ur=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function pr(t){if(!t)return false;let e=String(t instanceof Error?t.message:t).toLowerCase();return ur.some(n=>e.includes(n))}async function Ve(t,e={}){let{attempts:n=3,delay:r=500,factor:o=2,maxDelay:i=1e4,retryIf:a=pr}=e,s;for(let l=0;l<n;l++)try{return await t()}catch(p){if(s=p,l===n-1||!a(p))throw p;let c=Math.min(r*o**l,i);await new Promise(u=>setTimeout(u,c));}throw s}chunkVRQQ33YH_cjs.j();exports.Fetch=void 0;(Cr=>{let t=chunkA2TCSTSM_cjs.m.create({service:"fetch"}),e=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],n=false,r=null;function o(){return e.some(x=>{let b=process.env[x];return typeof b=="string"&&b.trim().length>0})}Cr.hasProxyConfigured=o;function i(){let x=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||x}Cr.getProxyUrl=i;function a(x={}){let b=x.httpProxy||x.httpsProxy||i();if(!b){t.warn("[Fetch] No proxy configured, HTTP_PROXY/HTTPS_PROXY environment variables not set");return}let w=new undici.ProxyAgent({uri:b,connectTimeout:x.connectTimeout||1e4,keepAliveTimeout:x.keepAliveTimeout||3e4});r=undici.getGlobalDispatcher(),undici.setGlobalDispatcher(w),n=true,t.info(`[Fetch] Global proxy enabled: ${b}`);}Cr.enableProxy=a;function s(){!n||!r||(undici.setGlobalDispatcher(r),n=false,r=null,t.info("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}Cr.disableProxy=s;function l(){return n}Cr.isProxyEnabled=l;async function p(x,b){let w=b?.timeout||3e4,F=b?.responseType||"json",{timeout:_,responseType:Re,...L}=b||{},E=null,$=null;try{L.signal||(E=new AbortController,$=setTimeout(()=>E.abort(),w));let M=await fetch(x,{...L,signal:L.signal||E.signal});$&&clearTimeout($);let C;switch(F){case "arrayBuffer":C=await M.arrayBuffer();break;case "blob":C=await M.blob();break;case "buffer":{let z=await M.arrayBuffer();C=Buffer.from(z);break}case "text":C=await M.text();break;default:{let z=await M.text();try{C=JSON.parse(z);}catch{C=z;}break}}return {ok:M.ok,status:M.status,statusText:M.statusText,headers:M.headers,data:C,url:M.url}}catch(M){throw $&&clearTimeout($),M}}async function c(x,b){let w=b?.retries??0,F=b?.retryDelay??1e3,{retries:_,retryDelay:Re,responseType:L,...E}=b||{};return Ve(()=>p(x,{...E,responseType:b?.responseType}),{attempts:w+1,delay:F,maxDelay:F*2**(w+1)})}async function u(x,b){return c(x,{method:"GET",...b})}Cr.get=u;async function d(x,b,w){return c(x,{method:"POST",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.post=d;async function m(x,b,w){return c(x,{method:"PUT",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.put=m;async function g(x,b,w){return c(x,{method:"DELETE",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.del=g;async function k(x,b,w){return c(x,{method:"PATCH",headers:{"Content-Type":"application/json",...w?.headers},body:b?JSON.stringify(b):void 0,...w})}Cr.patch=k;async function S(x,b){return c(x,b)}Cr.request=S;function R(x={}){return o()?(a(x),true):false}Cr.autoProxy=R;let P=5*1024*1024;function O(x){return new TextEncoder().encode(x)}function ie(x){return chunk6JM5F6FM_cjs.d.mimeType(x)}function U(x){return x.startsWith("file://")}async function ae(x){let b=url.fileURLToPath(x);return await chunkJQNKLHWT_cjs.D.file(b).bytes()}async function Me(x,b,w){let F=`----FetchFormBoundary${Date.now()}`,_=[],L=b.some(T=>T.filename||T.value instanceof Uint8Array||Buffer.isBuffer(T.value))&&!w?.timeout?3e5:w?.timeout;for(let T of b){let A=T.maxSize??P,D=T.filename,W=`Content-Disposition: form-data; name="${T.name}"${D?`; filename="${D}"`:""}`;D&&(W+=`\r
|
|
57
|
+
Content-Type: ${ie(D)}`),W+=`\r
|
|
75
58
|
\r
|
|
76
|
-
`,
|
|
77
|
-
--${
|
|
78
|
-
--${
|
|
79
|
-
`),
|
|
80
|
-
`));for(let
|
|
81
|
-
`)));
|
|
82
|
-
`);u=w.pop()??"";for(let R of w)if(R.startsWith("data: ")){let v=R.slice(6);if(v==="[DONE]"){C.onComplete?.();return}C.onMessage?.(v);}}C.onComplete?.();}catch(_){_.name!=="AbortError"&&C.onError?.(_);}})(),()=>{W.abort();}}Dt.sse=Te;})(exports.Fetch||(exports.Fetch={}));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 zn(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function Jo(e,...t){let r=zn(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=he__default.default.resolve(r),s=he__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 Xo(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 p=Object.keys(i),c=Object.keys(l);if(p.length!==c.length)return false;for(let d of p)if(!c.includes(d)||!e(i[d],l[d]))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 p=l.join("+");return i.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}a.keyToString=o;function s(i){return i==="none"?[]:i.split(",").map(l=>{let c=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),d={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let g of c)switch(g){case "ctrl":d.ctrl=true;break;case "alt":case "meta":case "option":d.meta=true;break;case "super":d.super=true;break;case "shift":d.shift=true;break;case "leader":d.leader=true;break;case "esc":d.name="escape";break;default:d.name=g;break}return d})}a.parse=s;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(p=>{function e(c){return c.replace(/\b\w/g,d=>d.toUpperCase())}p.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}p.time=t;function r(c){let d=new Date(c),g=t(c),k=d.toLocaleDateString();return `${g} \xB7 ${k}`}p.datetime=r;function n(c){let d=new Date(c),g=new Date;return d.getFullYear()===g.getFullYear()&&d.getMonth()===g.getMonth()&&d.getDate()===g.getDate()?t(c):r(c)}p.todayTimeOrDateTime=n;function o(c){return c>=1e6?(c/1e6).toFixed(1)+"M":c>=1e3?(c/1e3).toFixed(1)+"K":c.toString()}p.number=o;function s(c){if(c<1e3)return `${c}ms`;if(c<6e4)return `${(c/1e3).toFixed(1)}s`;if(c<36e5){let k=Math.floor(c/6e4),E=Math.floor(c%6e4/1e3);return `${k}m ${E}s`}if(c<864e5){let k=Math.floor(c/36e5),E=Math.floor(c%36e5/6e4);return `${k}h ${E}m`}let d=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${d}h`}p.duration=s;function a(c,d){return c.length<=d?c:c.slice(0,d-1)+"\u2026"}p.truncate=a;function i(c,d=35){if(c.length<=d)return c;let g="\u2026",k=Math.ceil((d-g.length)/2),E=Math.floor((d-g.length)/2);return c.slice(0,k)+g+c.slice(-E)}p.truncateMiddle=i;function l(c,d,g){return (c===1?d:g).replace("{}",c.toString())}p.pluralize=l;})(exports.Locale||(exports.Locale={}));chunkVRQQ33YH_cjs.j();var Qo=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function es(){return Qo.some(e=>process.env[e])}function ts(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function ns(){let e=process.env.HTTP_PROXY||process.env.http_proxy,t=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:e,https:t,enabled:!!(e||t)}}chunkVRQQ33YH_cjs.j();var jt=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 rs(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 os(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}chunkVRQQ33YH_cjs.j();function ss(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),p=(l.match(r)||[]).length,c=l.length-p,d=Math.round(p/1.5),g=Math.round(c/4);return Math.max(0,d+g)}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,p=i.output??0,c=i.cache?.read??0,d=i.cache?.write??0;return l+p+c+d}a.total=s;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function as(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return ze__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 p=i[0].length-l[0].length;return p!==0?p:i[0].localeCompare(l[0])})}function r(a,i){let l=Object.entries(i),p=t(l),c;for(let[d,g]of p)e(a,d)&&(c=g);return c}s.all=r;function n(a,i){let l=Object.entries(i),p=t(l),c;for(let[d,g]of p){let k=d.split(/\s+/);e(a.head,k[0])&&(k.length===1||o(a.tail,k.slice(1)))&&(c=g);}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={}));Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.c}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.a}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.b}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.e}});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.$=Br;exports.AsyncQueue=jt;exports.NamedError=mt;exports.PkgShell=Re;exports.abortAfter=zn;exports.abortAfterAny=Jo;exports.buildCodeSpanIndex=Ze;exports.chunkMarkdownIR=Bn;exports.chunkText=be;exports.chunkTextByBreakResolver=xt;exports.convertMarkdownTables=Xe;exports.createInlineCodeState=Ke;exports.createPkgShell=ce;exports.createRESTServer=lt;exports.createRPCServer=at;exports.createServer=ae;exports.createStreamingServer=ut;exports.createWebSocketServer=ct;exports.defer=Zo;exports.detectPlatform=fn;exports.escapeCommandArg=pt;exports.escapeCommandArgSafe=dn;exports.extractFrontmatter=Ge;exports.findFenceSpanAt=Mt;exports.findLast=or;exports.fn=_r;exports.formatDuration=Xo;exports.formatMarkdown=Ye;exports.getDirectory=zo;exports.getFileExtension=Do;exports.getFilename=jn;exports.getFilenameTruncated=Ho;exports.getProxyConfig=ns;exports.getProxyUrl=ts;exports.git=Hr;exports.iife=Jr;exports.isSafeFenceBreak=_n;exports.joinCommandArgs=me;exports.lazy=$e;exports.lazyAsync=ar;exports.loadEnv=Dr;exports.loadTextFile=Vr;exports.loadTextFileAsync=Gr;exports.markdownToIR=we;exports.markdownToIRWithMeta=Oe;exports.needsShellExecution=cn;exports.parseCommand=re;exports.parseCommandWithOptions=un;exports.parseFenceSpans=Je;exports.parseFrontmatterBlock=Ae;exports.parseModelId=Kr;exports.proxied=es;exports.readableStreamToText=Fr;exports.renderMarkdown=Se;exports.renderMarkdownWithMarkers=Fe;exports.retry=Ct;exports.scanParenAwareBreakpoints=yt;exports.serializeFrontmatter=Ve;exports.shell=mn;exports.signal=os;exports.startServer=dr;exports.truncateMiddle=Wo;exports.updateSchema=as;exports.whichSync=Ar;exports.withTimeout=ss;exports.work=rs;
|
|
59
|
+
`,_.push(O(W));let v=T.value;if(typeof v=="string")if(U(v)){let ve=await ae(v);if(D||(D=v.split("/").pop()||"file"),ve.byteLength>A)throw new Error(`File size ${ve.byteLength} exceeds limit ${A} bytes: ${D}`);_.push(ve);}else _.push(O(v));else if(Buffer.isBuffer(v)){if(v.byteLength>A)throw new Error(`Buffer size ${v.byteLength} exceeds limit ${A} bytes: ${T.name}`);_.push(new Uint8Array(v.buffer,v.byteOffset,v.byteLength));}else if(v instanceof Uint8Array){if(v.byteLength>A)throw new Error(`File size ${v.byteLength} exceeds limit ${A} bytes: ${T.name}`);_.push(v);}}let E=O(`\r
|
|
60
|
+
--${F}--`),$=O(`\r
|
|
61
|
+
--${F}\r
|
|
62
|
+
`),M=[];M.push(O(`--${F}\r
|
|
63
|
+
`));for(let T=0;T<_.length;T++)M.push(_[T]),T%2===1&&T<_.length-1&&(M.push($),M.push(O(`--${F}\r
|
|
64
|
+
`)));M.push(E);let C=M.reduce((T,A)=>T+A.length,0),z=new Uint8Array(C),le=0;for(let T of M)z.set(T,le),le+=T.length;return c(x,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${F}`,...w?.headers},body:z,timeout:L,...w})}Cr.postForm=Me;function Pt(x,b,w){let F=new AbortController,_=F.signal;return (async()=>{try{let L={Accept:"text/event-stream",...w?.headers||{}},E=await fetch(x,{...w,headers:L,signal:_});if(!E.ok)throw new Error(`SSE connection failed: ${E.status}`);let $=E.body?.getReader();if(!$)throw new Error("SSE stream not available");let M=new TextDecoder("utf-8"),C="";for(;!_.aborted;){let{done:z,value:le}=await $.read();if(z)break;let T=M.decode(le,{stream:!0});C+=T;let A=C.split(`
|
|
65
|
+
`);C=A.pop()??"";for(let D of A)if(D.startsWith("data: ")){let W=D.slice(6);if(W==="[DONE]"){b.onComplete?.();return}b.onMessage?.(W);}}b.onComplete?.();}catch(L){L.name!=="AbortError"&&b.onError?.(L);}})(),()=>{F.abort();}}Cr.sse=Pt;})(exports.Fetch||(exports.Fetch={}));chunkVRQQ33YH_cjs.j();exports.Slug=void 0;(r=>{let t=["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"],e=["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 n(){return [t[Math.floor(Math.random()*t.length)],e[Math.floor(Math.random()*e.length)]].join("-")}r.create=n;})(exports.Slug||(exports.Slug={}));chunkVRQQ33YH_cjs.j();function vt(t){let e=new AbortController,n=setTimeout(e.abort.bind(e),t);return {controller:e,signal:e.signal,clearTimeout:()=>globalThis.clearTimeout(n)}}function hr(t,...e){let n=vt(t);return {signal:AbortSignal.any([n.signal,...e]),clearTimeout:n.clearTimeout}}chunkVRQQ33YH_cjs.j();exports.Archive=void 0;(e=>{async function t(n,r){if(process.platform==="win32"){let o=De__default.default.resolve(n),i=De__default.default.resolve(r),a=`Expand-Archive -Path '${o}' -DestinationPath '${i}' -Force`,s=await chunkJQNKLHWT_cjs.G.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${a}"`);if(s.code!==0)throw new Error(`PowerShell exited with code ${s.code}: ${s.stderr}`)}else {let o=`unzip -o -q ${n} -d ${r}`,i=await chunkJQNKLHWT_cjs.G.run(void 0,o);if(i.code!==0)throw new Error(`unzip exited with code ${i.code}: ${i.stderr}`)}}e.extractZip=t;})(exports.Archive||(exports.Archive={}));chunkVRQQ33YH_cjs.j();exports.Color=void 0;(r=>{function t(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}r.isValidHex=t;function e(o){let i=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),s=parseInt(o.slice(5,7),16);return {r:i,g:a,b:s}}r.hexToRgb=e;function n(o){if(!t(o))return;let{r:i,g:a,b:s}=e(o);return `\x1B[38;2;${i};${a};${s}m\x1B[1m`}r.hexToAnsiBold=n;})(exports.Color||(exports.Color={}));chunkVRQQ33YH_cjs.j();exports.Context=void 0;(n=>{class t extends Error{constructor(i){super(`No context found for ${i}`);chunkVRQQ33YH_cjs.c(this,"name",i);}}n.NotFound=t;function e(r){let o=new async_hooks.AsyncLocalStorage;return {use(){let i=o.getStore();if(!i)throw new t(r);return i},provide(i,a){return o.run(i,a)}}}n.create=e;})(exports.Context||(exports.Context={}));chunkVRQQ33YH_cjs.j();function yr(t){return {[Symbol.dispose](){t();},[Symbol.asyncDispose](){return Promise.resolve(t())}}}chunkVRQQ33YH_cjs.j();exports.EventLoop=void 0;(e=>{async function t(){return new Promise(n=>{let r=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?n():setImmediate(r);};r();})}e.wait=t;})(exports.EventLoop||(exports.EventLoop={}));chunkVRQQ33YH_cjs.j();function br(t){if(t<=0)return "";if(t<60)return `${t}s`;if(t<3600){let n=Math.floor(t/60),r=t%60;return r>0?`${n}m ${r}s`:`${n}m`}if(t<86400){let n=Math.floor(t/3600),r=Math.floor(t%3600/60);return r>0?`${n}h ${r}m`:`${n}h`}if(t<604800){let n=Math.floor(t/86400);return n===1?"~1 day":`~${n} days`}let e=Math.floor(t/604800);return e===1?"~1 week":`~${e} weeks`}chunkVRQQ33YH_cjs.j();exports.Keybind=void 0;(a=>{function t(s,l){if(s===l)return true;if(typeof s!="object"||typeof l!="object"||s===null||l===null)return false;let p=Object.keys(s),c=Object.keys(l);if(p.length!==c.length)return false;for(let u of p)if(!c.includes(u)||!t(s[u],l[u]))return false;return true}function e(s){return {...s,super:s.super??false}}function n(s,l){return s?t(e(s),e(l)):false}a.match=n;function r(s,l=false){return {name:s.name,ctrl:s.ctrl,meta:s.meta,shift:s.shift,super:s.super??false,leader:l}}a.fromParsedKey=r;function o(s){if(!s)return "";let l=[];s.ctrl&&l.push("ctrl"),s.meta&&l.push("alt"),s.super&&l.push("super"),s.shift&&l.push("shift"),s.name&&(s.name==="delete"?l.push("del"):l.push(s.name));let p=l.join("+");return s.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}a.keyToString=o;function i(s){return s==="none"?[]:s.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 d of c)switch(d){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=d;break}return u})}a.parse=i;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(d=>{d.SUPPORTED_LANGS=["zh-CN","en-US"],d.DEFAULT_LANG="zh-CN";function n(m,g="EASBOT_LANG"){let k=[m,process.env[g]?.trim()];for(let S of k)if(S&&d.SUPPORTED_LANGS.includes(S))return S;return d.DEFAULT_LANG}d.resolveLocaleLang=n;function r(m){return m.replace(/\b\w/g,g=>g.toUpperCase())}d.titlecase=r;function o(m){return new Date(m).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=o;function i(m){let g=new Date(m),k=o(m),S=g.toLocaleDateString();return `${k} \xB7 ${S}`}d.datetime=i;function a(m){let g=new Date(m),k=new Date;return g.getFullYear()===k.getFullYear()&&g.getMonth()===k.getMonth()&&g.getDate()===k.getDate()?o(m):i(m)}d.todayTimeOrDateTime=a;function s(m){return m>=1e6?(m/1e6).toFixed(1)+"M":m>=1e3?(m/1e3).toFixed(1)+"K":m.toString()}d.number=s;function l(m){if(m<1e3)return `${m}ms`;if(m<6e4)return `${(m/1e3).toFixed(1)}s`;if(m<36e5){let S=Math.floor(m/6e4),R=Math.floor(m%6e4/1e3);return `${S}m ${R}s`}if(m<864e5){let S=Math.floor(m/36e5),R=Math.floor(m%36e5/6e4);return `${S}h ${R}m`}let g=Math.floor(m/36e5);return `${Math.floor(m%36e5/864e5)}d ${g}h`}d.duration=l;function p(m,g){return m.length<=g?m:m.slice(0,g-1)+"\u2026"}d.truncate=p;function c(m,g=35){if(m.length<=g)return m;let k="\u2026",S=Math.ceil((g-k.length)/2),R=Math.floor((g-k.length)/2);return m.slice(0,S)+k+m.slice(-R)}d.truncateMiddle=c;function u(m,g,k){return (m===1?g:k).replace("{}",m.toString())}d.pluralize=u;})(exports.Locale||(exports.Locale={}));var xr=exports.Locale.resolveLocaleLang,kr=exports.Locale.SUPPORTED_LANGS,Sr=exports.Locale.DEFAULT_LANG;chunkVRQQ33YH_cjs.j();var wr=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function Tr(){return wr.some(t=>process.env[t])}function Mr(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function Rr(){let t=process.env.HTTP_PROXY||process.env.http_proxy,e=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:t,https:e,enabled:!!(t||e)}}chunkVRQQ33YH_cjs.j();var rt=class{constructor(){chunkVRQQ33YH_cjs.c(this,"queue",[]);chunkVRQQ33YH_cjs.c(this,"resolvers",[]);}push(e){let n=this.resolvers.shift();n?n(e):this.queue.push(e);}async next(){return this.queue.length>0?this.queue.shift():new Promise(e=>this.resolvers.push(e))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function vr(t,e,n){let r=[...e];await Promise.all(Array.from({length:t},async()=>{for(;;){let o=r.pop();if(o===void 0)return;await n(o);}}));}chunkVRQQ33YH_cjs.j();function Ir(){let t,e=new Promise(n=>t=n);return {trigger(){return t()},wait(){return e}}}chunkVRQQ33YH_cjs.j();function Pr(t,e){let n;return Promise.race([t.then(r=>(clearTimeout(n),r)),new Promise((r,o)=>{n=setTimeout(()=>{o(new Error(`Operation timed out after ${e}ms`));},e);})])}chunkVRQQ33YH_cjs.j();exports.Token=void 0;(a=>{let n=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function r(s){if(!s)return 0;let l=String(s),p=(l.match(n)||[]).length,c=l.length-p,u=Math.round(p/1.5),d=Math.round(c/4);return Math.max(0,u+d)}a.estimate=r;function o(s){if(s==null)return 0;try{let l=typeof s=="string"?s:JSON.stringify(s);return r(l)}catch{return 0}}a.estimateObject=o;function i(s){if(s.total!==void 0&&s.total>0)return s.total;let l=s.input??0,p=s.output??0,c=s.cache?.read??0,u=s.cache?.write??0;return l+p+c+u}a.total=i;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function _r(t){let e={},n=t.shape??t.required().shape;for(let[r,o]of Object.entries(n))e[r]=o.nullable().optional();return pe__default.default.object(e)}Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkYC4AEMOP_cjs.a}});Object.defineProperty(exports,"$",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.H}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.j}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.d}});Object.defineProperty(exports,"Lazy",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.c}});Object.defineProperty(exports,"PKG",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.D}});Object.defineProperty(exports,"PkgShell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.A}});Object.defineProperty(exports,"Shell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.G}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.g}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.e}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.s}});Object.defineProperty(exports,"createPkgShell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.B}});Object.defineProperty(exports,"createRESTServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.p}});Object.defineProperty(exports,"createRPCServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.n}});Object.defineProperty(exports,"createServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.m}});Object.defineProperty(exports,"createStreamingServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.r}});Object.defineProperty(exports,"createWebSocketServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.q}});Object.defineProperty(exports,"detectPlatform",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.y}});Object.defineProperty(exports,"escapeCommandArg",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.w}});Object.defineProperty(exports,"escapeCommandArgSafe",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.x}});Object.defineProperty(exports,"joinCommandArgs",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.z}});Object.defineProperty(exports,"lazy",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.a}});Object.defineProperty(exports,"lazyAsync",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.b}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.f}});Object.defineProperty(exports,"needsShellExecution",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.u}});Object.defineProperty(exports,"parseCommand",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.t}});Object.defineProperty(exports,"parseCommandWithOptions",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.v}});Object.defineProperty(exports,"readableStreamToText",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.E}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.h}});Object.defineProperty(exports,"shell",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.C}});Object.defineProperty(exports,"startServer",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.o}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.i}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.k}});Object.defineProperty(exports,"whichSync",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.F}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return chunkJQNKLHWT_cjs.l}});Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.d}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.b}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.c}});Object.defineProperty(exports,"Wildcard",{enumerable:true,get:function(){return chunk6JM5F6FM_cjs.a}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkA2TCSTSM_cjs.e}});exports.AsyncQueue=rt;exports.DEFAULT_LANG=Sr;exports.NamedError=Le;exports.SUPPORTED_LANGS=kr;exports.abortAfter=vt;exports.abortAfterAny=hr;exports.buildCodeSpanIndex=we;exports.chunkMarkdownIR=St;exports.chunkText=q;exports.chunkTextByBreakResolver=Be;exports.convertMarkdownTables=Te;exports.createInlineCodeState=Se;exports.defer=yr;exports.extractFrontmatter=xe;exports.findFenceSpanAt=Ye;exports.findLast=en;exports.fn=on;exports.formatDuration=br;exports.formatMarkdown=ye;exports.getDirectory=ir;exports.getFileExtension=ar;exports.getFilename=Mt;exports.getFilenameTruncated=lr;exports.getProxyConfig=Rr;exports.getProxyUrl=Mr;exports.git=cn;exports.iife=gn;exports.isSafeFenceBreak=Tt;exports.loadEnv=ln;exports.loadTextFile=mn;exports.loadTextFileAsync=hn;exports.markdownToIR=X;exports.markdownToIRWithMeta=re;exports.parseFenceSpans=ke;exports.parseFrontmatterBlock=se;exports.parseModelId=yn;exports.proxied=Tr;exports.renderMarkdown=V;exports.renderMarkdownWithMarkers=oe;exports.resolveLocaleLang=xr;exports.retry=Ve;exports.scanParenAwareBreakpoints=ze;exports.serializeFrontmatter=be;exports.signal=Ir;exports.truncateMiddle=cr;exports.updateSchema=_r;exports.withTimeout=Pr;exports.work=vr;
|