9remote 3.0.4 → 3.0.6
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/cli.cjs +2 -2
- package/dist/server.cjs +4 -4
- package/dist/ui/assets/index-CMq_mLzM.js +8 -0
- package/dist/ui/assets/index-NAPslvk3.css +1 -0
- package/dist/ui/index.html +2 -2
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +2 -2
- package/dist/web/__next._full.txt +3 -3
- package/dist/web/__next._head.txt +1 -1
- package/dist/web/__next._index.txt +2 -2
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/chunks/3973-919fa2e493564fcf.js +1 -0
- package/dist/web/_next/static/chunks/7738-2439d4a20b745ce1.js +1 -0
- package/dist/web/_next/static/chunks/9958-9952a61eb6e17812.js +1 -0
- package/dist/web/_next/static/chunks/app/admin/admins/{page-b68025e0c5fe453c.js → page-4dd3a5a797a983ab.js} +1 -1
- package/dist/web/_next/static/chunks/app/admin/login/{page-38d9b3d31ee14847.js → page-854bcdcb805c63c8.js} +1 -1
- package/dist/web/_next/static/chunks/app/admin/modes/{page-7ebdbd17bfde67fd.js → page-b0675a3cdae87688.js} +1 -1
- package/dist/web/_next/static/chunks/app/admin/ota/{page-b237f7c870eeade4.js → page-6de419e03b4822ef.js} +1 -1
- package/dist/web/_next/static/chunks/app/admin/{page-a197e50c2b5a08f4.js → page-ae83026dc795c35b.js} +1 -1
- package/dist/web/_next/static/chunks/app/admin/turn/{page-dc625ee476578675.js → page-8eb4a8792fca9bd9.js} +1 -1
- package/dist/web/_next/static/chunks/app/dev/question/page-a58ae088ccc40553.js +1 -0
- package/dist/web/_next/static/chunks/app/login/{page-e2c75b449a40fc02.js → page-d42b178c6f11f6d3.js} +1 -1
- package/dist/web/_next/static/chunks/app/{page-24d612a793ea7763.js → page-10772fa3d9560889.js} +2 -2
- package/dist/web/_next/static/chunks/app/workspace/layout-475b254e83019cb1.js +14 -0
- package/dist/web/_next/static/css/48ee7d57614b1421.css +1 -0
- package/dist/web/_not-found/__next._full.txt +2 -2
- package/dist/web/_not-found/__next._head.txt +1 -1
- package/dist/web/_not-found/__next._index.txt +2 -2
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/dist/web/_not-found/__next._not-found.txt +1 -1
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +2 -2
- package/dist/web/admin/__next._full.txt +3 -3
- package/dist/web/admin/__next._head.txt +1 -1
- package/dist/web/admin/__next._index.txt +2 -2
- package/dist/web/admin/__next._tree.txt +2 -2
- package/dist/web/admin/__next.admin.__PAGE__.txt +2 -2
- package/dist/web/admin/__next.admin.txt +1 -1
- package/dist/web/admin/admins/__next._full.txt +3 -3
- package/dist/web/admin/admins/__next._head.txt +1 -1
- package/dist/web/admin/admins/__next._index.txt +2 -2
- package/dist/web/admin/admins/__next._tree.txt +2 -2
- package/dist/web/admin/admins/__next.admin.admins.__PAGE__.txt +2 -2
- package/dist/web/admin/admins/__next.admin.admins.txt +1 -1
- package/dist/web/admin/admins/__next.admin.txt +1 -1
- package/dist/web/admin/admins.html +1 -1
- package/dist/web/admin/admins.txt +3 -3
- package/dist/web/admin/login/__next._full.txt +3 -3
- package/dist/web/admin/login/__next._head.txt +1 -1
- package/dist/web/admin/login/__next._index.txt +2 -2
- package/dist/web/admin/login/__next._tree.txt +2 -2
- package/dist/web/admin/login/__next.admin.login.__PAGE__.txt +2 -2
- package/dist/web/admin/login/__next.admin.login.txt +1 -1
- package/dist/web/admin/login/__next.admin.txt +1 -1
- package/dist/web/admin/login.html +1 -1
- package/dist/web/admin/login.txt +3 -3
- package/dist/web/admin/modes/__next._full.txt +3 -3
- package/dist/web/admin/modes/__next._head.txt +1 -1
- package/dist/web/admin/modes/__next._index.txt +2 -2
- package/dist/web/admin/modes/__next._tree.txt +2 -2
- package/dist/web/admin/modes/__next.admin.modes.__PAGE__.txt +2 -2
- package/dist/web/admin/modes/__next.admin.modes.txt +1 -1
- package/dist/web/admin/modes/__next.admin.txt +1 -1
- package/dist/web/admin/modes.html +1 -1
- package/dist/web/admin/modes.txt +3 -3
- package/dist/web/admin/ota/__next._full.txt +3 -3
- package/dist/web/admin/ota/__next._head.txt +1 -1
- package/dist/web/admin/ota/__next._index.txt +2 -2
- package/dist/web/admin/ota/__next._tree.txt +2 -2
- package/dist/web/admin/ota/__next.admin.ota.__PAGE__.txt +2 -2
- package/dist/web/admin/ota/__next.admin.ota.txt +1 -1
- package/dist/web/admin/ota/__next.admin.txt +1 -1
- package/dist/web/admin/ota.html +1 -1
- package/dist/web/admin/ota.txt +3 -3
- package/dist/web/admin/turn/__next._full.txt +3 -3
- package/dist/web/admin/turn/__next._head.txt +1 -1
- package/dist/web/admin/turn/__next._index.txt +2 -2
- package/dist/web/admin/turn/__next._tree.txt +2 -2
- package/dist/web/admin/turn/__next.admin.turn.__PAGE__.txt +2 -2
- package/dist/web/admin/turn/__next.admin.turn.txt +1 -1
- package/dist/web/admin/turn/__next.admin.txt +1 -1
- package/dist/web/admin/turn.html +1 -1
- package/dist/web/admin/turn.txt +3 -3
- package/dist/web/admin.html +1 -1
- package/dist/web/admin.txt +3 -3
- package/dist/web/dev/question/__next._full.txt +3 -3
- package/dist/web/dev/question/__next._head.txt +1 -1
- package/dist/web/dev/question/__next._index.txt +2 -2
- package/dist/web/dev/question/__next._tree.txt +2 -2
- package/dist/web/dev/question/__next.dev.question.__PAGE__.txt +2 -2
- package/dist/web/dev/question/__next.dev.question.txt +1 -1
- package/dist/web/dev/question/__next.dev.txt +1 -1
- package/dist/web/dev/question.html +1 -1
- package/dist/web/dev/question.txt +3 -3
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +3 -3
- package/dist/web/login/__next._full.txt +3 -3
- package/dist/web/login/__next._head.txt +1 -1
- package/dist/web/login/__next._index.txt +2 -2
- package/dist/web/login/__next._tree.txt +2 -2
- package/dist/web/login/__next.login.__PAGE__.txt +2 -2
- package/dist/web/login/__next.login.txt +1 -1
- package/dist/web/login.html +1 -1
- package/dist/web/login.txt +3 -3
- package/dist/web/workspace/__next._full.txt +3 -3
- package/dist/web/workspace/__next._head.txt +1 -1
- package/dist/web/workspace/__next._index.txt +2 -2
- package/dist/web/workspace/__next._tree.txt +2 -2
- package/dist/web/workspace/__next.workspace.__PAGE__.txt +1 -1
- package/dist/web/workspace/__next.workspace.txt +2 -2
- package/dist/web/workspace/browse/__next._full.txt +3 -3
- package/dist/web/workspace/browse/__next._head.txt +1 -1
- package/dist/web/workspace/browse/__next._index.txt +2 -2
- package/dist/web/workspace/browse/__next._tree.txt +2 -2
- package/dist/web/workspace/browse/__next.workspace.browse.__PAGE__.txt +1 -1
- package/dist/web/workspace/browse/__next.workspace.browse.txt +1 -1
- package/dist/web/workspace/browse/__next.workspace.txt +2 -2
- package/dist/web/workspace/browse.html +1 -1
- package/dist/web/workspace/browse.txt +3 -3
- package/dist/web/workspace/editor/__next._full.txt +3 -3
- package/dist/web/workspace/editor/__next._head.txt +1 -1
- package/dist/web/workspace/editor/__next._index.txt +2 -2
- package/dist/web/workspace/editor/__next._tree.txt +2 -2
- package/dist/web/workspace/editor/__next.workspace.editor.__PAGE__.txt +1 -1
- package/dist/web/workspace/editor/__next.workspace.editor.txt +1 -1
- package/dist/web/workspace/editor/__next.workspace.txt +2 -2
- package/dist/web/workspace/editor.html +1 -1
- package/dist/web/workspace/editor.txt +3 -3
- package/dist/web/workspace/files/__next._full.txt +3 -3
- package/dist/web/workspace/files/__next._head.txt +1 -1
- package/dist/web/workspace/files/__next._index.txt +2 -2
- package/dist/web/workspace/files/__next._tree.txt +2 -2
- package/dist/web/workspace/files/__next.workspace.files.__PAGE__.txt +1 -1
- package/dist/web/workspace/files/__next.workspace.files.txt +1 -1
- package/dist/web/workspace/files/__next.workspace.txt +2 -2
- package/dist/web/workspace/files.html +1 -1
- package/dist/web/workspace/files.txt +3 -3
- package/dist/web/workspace/git/__next._full.txt +3 -3
- package/dist/web/workspace/git/__next._head.txt +1 -1
- package/dist/web/workspace/git/__next._index.txt +2 -2
- package/dist/web/workspace/git/__next._tree.txt +2 -2
- package/dist/web/workspace/git/__next.workspace.git.__PAGE__.txt +1 -1
- package/dist/web/workspace/git/__next.workspace.git.txt +1 -1
- package/dist/web/workspace/git/__next.workspace.txt +2 -2
- package/dist/web/workspace/git.html +1 -1
- package/dist/web/workspace/git.txt +3 -3
- package/dist/web/workspace/mobile/__next._full.txt +3 -3
- package/dist/web/workspace/mobile/__next._head.txt +1 -1
- package/dist/web/workspace/mobile/__next._index.txt +2 -2
- package/dist/web/workspace/mobile/__next._tree.txt +2 -2
- package/dist/web/workspace/mobile/__next.workspace.mobile.__PAGE__.txt +1 -1
- package/dist/web/workspace/mobile/__next.workspace.mobile.txt +1 -1
- package/dist/web/workspace/mobile/__next.workspace.txt +2 -2
- package/dist/web/workspace/mobile.html +1 -1
- package/dist/web/workspace/mobile.txt +3 -3
- package/dist/web/workspace/remote/__next._full.txt +3 -3
- package/dist/web/workspace/remote/__next._head.txt +1 -1
- package/dist/web/workspace/remote/__next._index.txt +2 -2
- package/dist/web/workspace/remote/__next._tree.txt +2 -2
- package/dist/web/workspace/remote/__next.workspace.remote.__PAGE__.txt +1 -1
- package/dist/web/workspace/remote/__next.workspace.remote.txt +1 -1
- package/dist/web/workspace/remote/__next.workspace.txt +2 -2
- package/dist/web/workspace/remote.html +1 -1
- package/dist/web/workspace/remote.txt +3 -3
- package/dist/web/workspace/terminal/default/__next._full.txt +3 -3
- package/dist/web/workspace/terminal/default/__next._head.txt +1 -1
- package/dist/web/workspace/terminal/default/__next._index.txt +2 -2
- package/dist/web/workspace/terminal/default/__next._tree.txt +2 -2
- package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.__PAGE__.txt +1 -1
- package/dist/web/workspace/terminal/default/__next.workspace.terminal.$d$sessionId.txt +1 -1
- package/dist/web/workspace/terminal/default/__next.workspace.terminal.txt +1 -1
- package/dist/web/workspace/terminal/default/__next.workspace.txt +2 -2
- package/dist/web/workspace/terminal/default.html +1 -1
- package/dist/web/workspace/terminal/default.txt +3 -3
- package/dist/web/workspace/workspaces/__next._full.txt +3 -3
- package/dist/web/workspace/workspaces/__next._head.txt +1 -1
- package/dist/web/workspace/workspaces/__next._index.txt +2 -2
- package/dist/web/workspace/workspaces/__next._tree.txt +2 -2
- package/dist/web/workspace/workspaces/__next.workspace.txt +2 -2
- package/dist/web/workspace/workspaces/__next.workspace.workspaces.__PAGE__.txt +1 -1
- package/dist/web/workspace/workspaces/__next.workspace.workspaces.txt +1 -1
- package/dist/web/workspace/workspaces.html +1 -1
- package/dist/web/workspace/workspaces.txt +3 -3
- package/dist/web/workspace.html +1 -1
- package/dist/web/workspace.txt +3 -3
- package/package.json +1 -1
- package/dist/ui/assets/index-B3Etxg9r.js +0 -8
- package/dist/ui/assets/index-CAvf0VPf.css +0 -1
- package/dist/web/_next/static/chunks/3973-2b22a02354eb3d07.js +0 -1
- package/dist/web/_next/static/chunks/8529-dc6ec7164d23d48e.js +0 -1
- package/dist/web/_next/static/chunks/9958-4e13af15ce454c7a.js +0 -1
- package/dist/web/_next/static/chunks/app/dev/question/page-db919ed1d6babdb4.js +0 -1
- package/dist/web/_next/static/chunks/app/workspace/layout-f5d5ba72458fb2a7.js +0 -14
- package/dist/web/_next/static/css/3bb9c5823a043a03.css +0 -1
- /package/dist/web/_next/static/{-4kBSWRXKHPAs-s1ygA3F → 1Tr76v17cPEsysWpe5buJ}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{-4kBSWRXKHPAs-s1ygA3F → 1Tr76v17cPEsysWpe5buJ}/_ssgManifest.js +0 -0
package/dist/server.cjs
CHANGED
|
@@ -390,7 +390,7 @@ export default function (${e}) {
|
|
|
390
390
|
${e}.on(${JSON.stringify(n)}, async () => post("working"));
|
|
391
391
|
${e}.on(${JSON.stringify(r)}, async () => post("done"));
|
|
392
392
|
}
|
|
393
|
-
`}function Dje(t){let e=Mje[t];if(!e)return{success:!1,error:"Unknown tool"};try{return t==="codex"||t==="opencode"||t==="amp"||t==="pi"?e.enable():e.enable(Un[t]())}catch(n){return{success:!1,error:n.message}}}function Lje(t){let e=(process.env.PATH||"").split(Tr.default.delimiter).filter(Boolean),n=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT").split(";"):[""];return e.some(r=>n.some(i=>{try{return Je.default.existsSync(Tr.default.join(r,t+i))}catch{return!1}}))}function $ce(t){let e=Lce[t];if(e&&Lje(e))return!0;let n=uje[t]?.();return n?(Array.isArray(n)?n:[n]).some(r=>Je.default.existsSync(r)):!1}function Gce(){let t={};for(let e of Nje)if($ce(e))try{let n=Dje(e);t[e]=n.success&&!n.untrusted?.length}catch{t[e]=!1}return t}async function Hce(){if(!$ce("codex"))return null;try{let{missing:t}=await wje();return t.length&&console.warn(`\u26A0\uFE0F codex hooks written but not trusted: ${t.length} \u2014 run codex and trust them`),t.length?{untrusted:t.length}:{untrusted:0}}catch(t){return console.warn(`\u26A0\uFE0F codex hook trust failed: ${t.message}`),{error:t.message}}}function jce(){let t=Un.claude(),e=Ar(t);if(!e.hooks?.Stop&&!e.hooks?.Notification)return;let n=e.env||{};Object.keys(Tv).some(i=>n[i]!==Tv[i])&&(Uce(e),as(t,e))}var Mce,Je,Tr,Nce,Nq,Dce,lje,Di,gh,Un,Lce,yh,uje,Dq,mR,hR,fje,pR,Fce,CTt,Bce,yje,vje,xje,Pce,Tje,Rje,Ije,kje,Pje,Oje,Mje,Nje,Wce=ae(()=>{Mce=ce(require("os"),1),Je=ce(require("fs"),1),Tr=ce(require("path"),1),Nce=require("child_process");Lt();_o();Ic();Nq=`http://localhost:${vs}/api/notify`,Dce="nineRemoteNotify",lje=Tr.default.join(Oe.STATE,"claudeEnvBackup.json"),Di=(...t)=>Tr.default.join(Mce.default.homedir(),...t),gh=(t,...e)=>{let n=process.env[t];return n&&n.trim()?n.trim():Di(...e)},Un={claude:()=>Di(".claude","settings.json"),codex:()=>Di(".codex","config.toml"),codexHooks:()=>Di(".codex","hooks.json"),codexScript:()=>Di(".codex","9remote-notify.sh"),opencode:()=>Di(".config","opencode","plugin",`${Dce}.js`),grok:()=>Tr.default.join(gh("GROK_HOME",".grok"),"hooks","9remote.json"),cursor:()=>Di(".cursor","hooks.json"),antigravity:()=>Di(".gemini","config","hooks.json"),kiro:()=>Tr.default.join(gh("KIRO_HOME",".kiro"),"agents","9remote.json"),copilot:()=>Tr.default.join(gh("COPILOT_HOME",".copilot"),"config.json"),codebuddy:()=>Tr.default.join(gh("CODEBUDDY_CONFIG_DIR",".codebuddy"),"settings.json"),factory:()=>Di(".factory","settings.json"),qoder:()=>Tr.default.join(gh("QODER_CONFIG_DIR",".qoder"),"settings.json"),rovodev:()=>Di(".rovodev","config.yml"),hermes:()=>Tr.default.join(gh("HERMES_HOME",".hermes"),"config.yaml"),amp:()=>Di(".config","amp","plugins","9remote.ts"),pi:()=>Tr.default.join(gh("PI_CODING_AGENT_DIR",".pi","agent"),"extensions","9remote.ts")},Lce={claude:"claude",codex:"codex",opencode:"opencode",grok:"grok",cursor:"cursor-agent",antigravity:"agy",kiro:"kiro-cli",copilot:"copilot",codebuddy:"codebuddy",factory:"droid",qoder:"qodercli",rovodev:"acli",hermes:"hermes",amp:"amp",pi:"pi"},yh=(t,e,{sessionId:n=!1}={})=>{let r=n?ty(e)[0]:null;return`${r?`csid=$(cat 2>/dev/null | sed -n 's/.*"${r}" *: *"\\([^"]*\\)".*/\\1/p'); `:""}command -v curl >/dev/null 2>&1 && curl -s --connect-timeout 1 --max-time 2 "${Nq}?type=${t}&sessionId=$NINE_REMOTE_SESSION_ID${r?"&csid=$csid":""}&tool=${e}" > /dev/null 2>&1 & true`},uje={claude:()=>Di(".claude"),codex:()=>Di(".codex"),opencode:()=>[Di(".config","opencode"),Di(".opencode")]},Dq=t=>Math.ceil(t/1e3),mR=5e3,hR=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),fje=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;pR={UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked"},Fce=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase(),CTt=Object.fromEntries(Object.keys(pR).map(t=>[Fce(t),t])),Bce=/^\[hooks\.state\."(?<key>[^"]+)"\]$/m,yje=15e3;vje=t=>/^sha256:/.test(t)?t:`sha256:${t}`;xje=/# 9Remote notification\nnotify\s*=.*\n?/g,Pce=/^# 9Remote-saved: (notify\s*=.*)$/m;Tje={enable(){let t=Un.codexHooks(),e=Ar(t),n={...e.hooks||{}};for(let[r,i]of Object.entries(pR))n[r]=[...(n[r]||[]).filter(s=>!Mq(s)),Aje(i)];return e.hooks=n,as(t,e),bje(),{success:!0}},disable(){let t=Un.codexHooks(),e=new Set(qce(t).filter(n=>n.command.includes("&tool=codex")).map(n=>n.key));if(Je.default.existsSync(t)){let n=Ar(t);if(n.hooks){for(let r of Object.keys(pR))n.hooks[r]=(n.hooks[r]||[]).filter(i=>!Mq(i)),n.hooks[r].length===0&&delete n.hooks[r];Object.keys(n.hooks).length===0&&delete n.hooks}as(t,n)}return Sje(Un.codex(),e),{success:!0}},isEnabled(){let t=Ar(Un.codexHooks()).hooks||{};return Object.keys(pR).every(e=>(t[e]||[]).some(Mq))}};Rje={enable(){let t=Un.opencode(),e=Tr.default.dirname(t);return Je.default.existsSync(e)||Je.default.mkdirSync(e,{recursive:!0}),Je.default.writeFileSync(t,Cje(),"utf8"),{success:!0}},disable(){let t=Un.opencode();return Je.default.existsSync(t)&&Je.default.unlinkSync(t),{success:!0}},isEnabled(){let t=Un.opencode();return Je.default.existsSync(t)&&Je.default.readFileSync(t,"utf8").includes("&sessionID=")}};Ije="# 9remote hooks begin",kje="# 9remote hooks end",Pje=" # 9remote hooks begin",Oje=" # 9remote hooks end",Mje={claude:Uy("claude",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked",Notification:"blocked"},t=>t,{matchers:{Notification:"permission_prompt"},extra:Uce,sessionId:!0}),codex:Tje,opencode:Rje,grok:Uy("grok",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",Notification:"blocked"},Dq),cursor:hje("cursor",{stop:"done",beforeShellExecution:"blocked",beforeToolCall:"working"},{extra:t=>{t.version=t.version||1}}),antigravity:mje("antigravity","9remote",{UserPromptSubmit:"working",PreToolUse:"working",Stop:"done",Notification:"blocked"}),kiro:gje("kiro",{UserPromptSubmit:"working",PostToolUse:"working",preToolUse:"blocked",stop:"done"}),copilot:Uy("copilot",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),codebuddy:Uy("codebuddy",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),factory:Uy("factory",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),qoder:Uy("qoder",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),rovodev:kce("rovodev",{begin:Pje,end:Oje,items:[{event:"on_complete",type:"done"},{event:"on_error",type:"done"},{event:"on_tool_permission",type:"blocked"},{event:"on_message",type:"working"},{event:"on_tool_start",type:"working"}]}),hermes:(()=>{let t=kce("hermes",{begin:Ije,end:kje,items:[{event:"pre_llm_call",type:"working"},{event:"pre_tool_call",type:"working"},{event:"post_tool_call",type:"working"},{event:"pre_approval_request",type:"blocked"},{event:"post_llm_call",type:"done"}]}),e=()=>Tr.default.join(Tr.default.dirname(Un.hermes()),"shell-hooks-allowlist.json");return{enable:()=>{let n=t.enable(Un.hermes()),r=Ar(e()),i=(r.approvals||[]).filter(s=>!(typeof s.command=="string"&&s.command.includes("&tool=hermes")));return r.approvals=[...i,...[{event:"pre_llm_call",type:"working"},{event:"pre_tool_call",type:"working"},{event:"post_tool_call",type:"working"},{event:"pre_approval_request",type:"blocked"},{event:"post_llm_call",type:"done"}].map(({event:s,type:o})=>({event:s,command:yh(o,"hermes"),approved_at:"2020-01-01T00:00:00Z"}))],as(e(),r),n},disable:()=>{let n=t.disable(Un.hermes()),r=e();if(Je.default.existsSync(r)){let i=Ar(r);i.approvals=(i.approvals||[]).filter(s=>!(typeof s.command=="string"&&s.command.includes("&tool=hermes"))),i.approvals.length?as(r,i):Je.default.unlinkSync(r)}return n},isEnabled:()=>t.isEnabled(Un.hermes())}})(),amp:{enable(){let t=Un.amp(),e=Tr.default.dirname(t);return Je.default.existsSync(e)||Je.default.mkdirSync(e,{recursive:!0}),Je.default.writeFileSync(t,Oce("amp","amp","agent.start","agent.end"),"utf8"),{success:!0}},disable(){return Je.default.existsSync(Un.amp())&&Je.default.unlinkSync(Un.amp()),{success:!0}},isEnabled(){return Je.default.existsSync(Un.amp())}},pi:{enable(){let t=Un.pi(),e=Tr.default.dirname(t);return Je.default.existsSync(e)||Je.default.mkdirSync(e,{recursive:!0}),Je.default.writeFileSync(t,Oce("pi","pi","agent_start","agent_end"),"utf8"),{success:!0}},disable(){return Je.default.existsSync(Un.pi())&&Je.default.unlinkSync(Un.pi()),{success:!0}},isEnabled(){return Je.default.existsSync(Un.pi())}}},Nje=M8});var Lq=ae(()=>{Ms()});var Oq={};dr(Oq,{broadcastAiStatus:()=>BE,broadcastServerInfo:()=>$q,initializeTerminal:()=>qq,listSessionRoots:()=>cu,matchWorkspacePath:()=>Qce,registerManagedSession:()=>Bq,setConnectCheckHandler:()=>Gq,setupTerminalHandlers:()=>Hq,setupTerminalSocket:()=>Vf});async function qje(t,e){if(!cne(e))return;let r=(await vf().catch(()=>null))?.find(s=>s.id===e);ane(e,r?.foregroundProcess)?.state==="idle"&&(et(t,"statusChange",{sessionId:e,state:"idle",tool:null,conversationId:null}),et(t,"statusState",Pc()))}function $je(t,e){let n=(yR.get(t)||"")+e,r=null;Vce.lastIndex=0;for(let o;o=Vce.exec(n);)r=o[1];if(r){let o=Wte(r);o&&ns(t,o)}let i=n.lastIndexOf("\x1B]"),s=i===-1?"":n.slice(i);s&&s.length<=Fje&&!s.slice(3).includes("\x07")&&!s.includes("\x1B\\")?yR.set(t,s):yR.delete(t)}function Kce(){let t=(zce||Promise.resolve()).catch(()=>{}).then(()=>Gje());return zce=t.catch(()=>{}),t}async function Gje(){let t=await vf(),e=new Map(t.map(r=>[r.id,r])),n=kA();for(let r of t)if(!n[r.id])try{await Ef(r.id)}catch{}$r.clear();for(let[r,i]of Object.entries(n)){let s=e.get(r);$r.set(r,{daemon:!0,name:i.name,autoNamed:i.autoNamed!==!1,createdAt:i.createdAt,shellId:i.shellId,cwd:s?.cwd||i.cwd,workspacePath:i.workspacePath??UE[r]??null,lastCols:i.cols??null,lastRows:i.rows??null,needsRespawn:!s,agent:i.agent||null}),i.agent&&ns(r,i.agent),JU(r,i)}ei($r)}function Hje(t){!jf||!t||FE.has(t)||FE.set(t,setTimeout(()=>{FE.delete(t),vC(jf,$r,t).catch(()=>{})},fQ))}function Uq(){let{assignments:t,created:e}=Pne({sessions:$r,workspaces:[...Wf.values()],sessionWorkspaces:vh});if(Object.keys(t).length){for(let n of e)Wf.set(n.id,n);for(let[n,r]of Object.entries(t)){vh[n]=r;let i=$r.get(n);i&&!i.workspacePath&&(i.workspacePath=Wf.get(r)?.path||null)}sy(Wf,vh,_R),ei($r),console.log(Jce(`\u{1F4C1} Grouped ${Object.keys(t).length} loose terminal(s)`+(e.length?` into ${e.length} new workspace(s)`:"")))}}function cu(){return[...$r.entries()].map(([t,e])=>({id:t,name:e.name,workspacePath:e.workspacePath||null,cwd:e.cwd||null}))}function Qce(t,e){let n=e?(0,_h.resolve)(e):"";if(!n)return null;let r=null,i=null,s=null;for(let o of t||[]){if(!o?.path)continue;let a=(0,_h.resolve)(o.path);n===a?r=o:n.startsWith(a+"/")&&(!i||a.length>(0,_h.resolve)(i.path).length)?i=o:a.startsWith(n+"/")&&(!s||a.length<(0,_h.resolve)(s.path).length)&&(s=o)}return r||i||s||null}function Bq({sessionId:t,name:e,autoNamed:n=!0,cwd:r=null,workspacePath:i=null,shellId:s=null,shellLabel:o=null,agent:a=null}){let c=Qce([...Wf.values()],i||r)||null;return $r.set(t,{daemon:!0,name:e,autoNamed:n,createdAt:Date.now(),cwd:r||c?.path||null,workspacePath:c?.path||null,shellId:s,shellLabel:o,agent:a}),c&&(vh[t]=c.id,sy(Wf,vh,_R)),ei($r),et(null,"sessionsChanged"),{success:!0,sessionId:t,workspacePath:c?.path||null}}async function qq(){let t=Sne();if(!t){let r=kA(),i=wne();t=kne(i,r);let s=new Map(t.workspaces.map(c=>[c.id,c]));if(sy(s,t.sessionWorkspaces,t.sessionOrder),UE=t.sessionPaths||{},Object.keys(UE).length){for(let[c,l]of Object.entries(UE))r[c]&&(r[c].workspacePath=l);Ene(r)}let o=(i.groups||[]).filter(c=>t.workspaces.some(l=>l.id===c.id)).length,a=(i.groups||[]).length-o;(t.workspaces.length||a)&&console.log(Jce(`\u{1F4C1} Migrated ${t.workspaces.length} workspace(s) from terminal groups`+(a?`, dropped ${a} empty group(s)`:"")))}for(let r of t.workspaces)Wf.set(r.id,r);Object.assign(vh,t.sessionWorkspaces),_R.push(...t.sessionOrder),nne(()=>ei($r)),une(Hje);try{jce()}catch{}try{Gce()}catch{}Hce().catch(()=>{});try{Cce()}catch{}if(Fq==="daemon")if(!await OL())console.error("\u274C Failed to connect to PTY daemon, falling back to buffer mode");else{await Kce(),Uq(),Cp("connected",()=>{Kce().then(Uq).catch(()=>{})});return}console.log("\u{1F4E6} Buffer persistence mode - scrollback enabled");let e=vne(),n=kA();for(let r of e){let i=n[r]||{};$r.set(r,{pty:null,name:i.name||`Terminal ${$r.size+1}`,autoNamed:i.autoNamed!==!1,createdAt:i.createdAt||Date.now(),cwd:i.cwd,workspacePath:i.workspacePath??UE[r]??null,shellId:i.shellId,buffer:[],needsRestore:!0}),JU(r,i),console.log(`\u{1F504} Found saved session: ${r}`)}e.length>0&&console.log(`\u2705 Found ${e.length} saved session(s)`),Uq()}function Vf(t,e){jf=t,Fq==="daemon"&&(Cp("output",({sessionId:i,enc:s,data:o,replay:a})=>{a!==!0&&(TA(i),xA(i));let c=s==="b64"?Buffer.from(o,"base64"):Buffer.from(o||"");c.length>Aa&&(gR++,(gR===1||gR%500===0)&&Xce.info(`[slice] chunk ${c.length>>10}KB \u2192 ${Math.ceil(c.length/Aa)} events (total sliced: ${gR})`)),s==="b64"&&$je(i,c.toString("utf8"));for(let l=0;l<c.length||l===0;l+=Aa){let u=c.subarray(l,l+Aa),f=a===!0?mE(i):Bie(i);a!==!0&&qie(i,f,u),et(t,"output",{sessionId:i,enc:"bin",data:u,replay:a===!0,seq:f})}}),mne(i=>et(t,"statusState",Pc())),pne(()=>et(t,"statusState",Pc())),Cp("cwdChange",({sessionId:i,cwd:s})=>{let o=$r.get(i);o&&s&&o.cwd!==s&&(o.cwd=s,ei($r)),et(t,"cwdChange",{sessionId:i,cwd:s})}),Cp("processChange",({sessionId:i,process:s})=>{let o=one(i,s);if(o?.state==="pendingShell"){setTimeout(()=>qje(t,i),Bje);return}o?.state==="idle"&&(et(t,"statusChange",{sessionId:i,state:"idle",tool:null,conversationId:null}),et(t,"statusState",Pc()))}),Cp("sessionClosed",i=>{$r.delete(i),gy(i),ny(i),yR.delete(i);let s=FE.get(i);s&&(clearTimeout(s),FE.delete(i)),eF(i),et(t,"sessionClosed",i),et(t,"notificationCleared",i)}));let n=()=>({version:Uje,remoteAvailable:Sp(),mobileAvailable:Rte(),daemonMode:Fq==="daemon"&&In(),platform:process.platform,updateAvailable:KD(),canSelfUpdate:!0,caps:{joinSessionSize:!0,artifact:!0},artifactEnabled:LE(),voiceConfig:xa().voiceConfig||null,mcpClients:Ly,...Pte()}),r=()=>{let i=n();for(let s of t.sockets.sockets.values())s.data?.approved&&s.emit("serverInfo",i)};QD(r),Vf._buildServerInfo=n,Vf._emitServerInfo=r}function $q(){Vf._emitServerInfo?.()}function BE(t,e,n,r=null){if(!jf)return null;if(e==="done")return bA(t,()=>{let a=r?.sessionId||r?.threadId||ts(t)?.id||null,c=Mf(t),l=Wp({type:e,sessionId:t,tool:n});!l||l===c||(et(jf,"statusChange",{sessionId:t,state:e,tool:n,conversationId:a}),et(jf,"statusState",Pc()))}),Mf(t);let i=r?.sessionId||r?.threadId||ts(t)?.id||null,s=Mf(t),o=Wp({type:e,sessionId:t,tool:n});return!o||o===s||(et(jf,"statusChange",{sessionId:t,state:e,tool:n,conversationId:i}),et(jf,"statusState",Pc())),o}function Gq(t){Zce=t}async function Hq(t,e,n){Xce.info(`[diag] setupTerminalHandlers START id=${t.id} virtual=${!!t.defersWsAdapter}`),Ote(),Zce?.(),t.emit("srvCaps",{env2:1}),t.emit("serverInfo",Vf._buildServerInfo?.()),Vie(t,e,$r,Wf,vh,_R),Zie(t,$r),Rce(t,e),XT()&&await RZ(t,n).catch(r=>{console.error("\u274C Failed to setup remote handlers:",r.message)}),Ite(t),t.on("disconnect",()=>{_ae(t.id),Mte()})}var _h,Yce,Xce,sAt,Jce,Fq,Uje,Vce,Fje,Bje,yR,$r,Wf,vh,_R,UE,zce,FE,jf,gR,Zce,Da=ae(()=>{PO();_h=require("path"),Yce=require("url");di();JT();kte();Eo();fA();PA();One();wC();ese();Ice();Wce();dR();xg();QC();Lq();Ms();Ic();Ji();lB();Kl();st();Xce=be("terminal"),sAt=(0,_h.dirname)((0,Yce.fileURLToPath)(__importMetaUrl)),Jce=xv.rgb(230,138,110),Fq="daemon",Uje="3.0.4",Vce=/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/g,Fje=256,Bje=1500,yR=new Map;$r=new Map,Wf=new Map,vh={},_R=[],UE={},zce=null;FE=new Map,jf=null;gR=0;Zce=null});var qE=B((oAt,ile)=>{"use strict";var jje=require("path"),qc="\\\\/",ele=`[^${qc}]`,Wje=0,lu="\\.",Vje="\\+",zje="\\?",vR="\\/",Kje="(?=.)",tle="[^/]",jq=`(?:${vR}|$)`,nle=`(?:^|${vR})`,Wq=`${lu}{1,2}${jq}`,Yje=`(?!${lu})`,Xje=`(?!${nle}${Wq})`,Jje=`(?!${lu}{0,1}${jq})`,Qje=`(?!${Wq})`,Zje=`[^.${vR}]`,e3e=`${tle}*?`,rle={DOT_LITERAL:lu,PLUS_LITERAL:Vje,QMARK_LITERAL:zje,SLASH_LITERAL:vR,ONE_CHAR:Kje,QMARK:tle,END_ANCHOR:jq,DOTS_SLASH:Wq,NO_DOT:Yje,NO_DOTS:Xje,NO_DOT_SLASH:Jje,NO_DOTS_SLASH:Qje,QMARK_NO_DOT:Zje,STAR:e3e,START_ANCHOR:nle},t3e={...rle,SLASH_LITERAL:`[${qc}]`,QMARK:ele,STAR:`${ele}*?`,DOTS_SLASH:`${lu}{1,2}(?:[${qc}]|$)`,NO_DOT:`(?!${lu})`,NO_DOTS:`(?!(?:^|[${qc}])${lu}{1,2}(?:[${qc}]|$))`,NO_DOT_SLASH:`(?!${lu}{0,1}(?:[${qc}]|$))`,NO_DOTS_SLASH:`(?!${lu}{1,2}(?:[${qc}]|$))`,QMARK_NO_DOT:`[^.${qc}]`,START_ANCHOR:`(?:^|[${qc}])`,END_ANCHOR:`(?:[${qc}]|$)`},n3e={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};ile.exports={DEFAULT_MAX_EXTGLOB_RECURSION:Wje,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:n3e,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:jje.sep,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?t3e:rle}}});var ER=B(cs=>{"use strict";var r3e=require("path"),i3e=process.platform==="win32",{REGEX_BACKSLASH:s3e,REGEX_REMOVE_BACKSLASH:o3e,REGEX_SPECIAL_CHARS:a3e,REGEX_SPECIAL_CHARS_GLOBAL:c3e}=qE();cs.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);cs.hasRegexChars=t=>a3e.test(t);cs.isRegexChar=t=>t.length===1&&cs.hasRegexChars(t);cs.escapeRegex=t=>t.replace(c3e,"\\$1");cs.toPosixSlashes=t=>t.replace(s3e,"/");cs.removeBackslashes=t=>t.replace(o3e,e=>e==="\\"?"":e);cs.supportsLookbehinds=()=>{let t=process.version.slice(1).split(".").map(Number);return t.length===3&&t[0]>=9||t[0]===8&&t[1]>=10};cs.isWindows=t=>t&&typeof t.windows=="boolean"?t.windows:i3e===!0||r3e.sep==="\\";cs.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?cs.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};cs.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};cs.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",i=n.contains?"":"$",s=`${r}(?:${t})${i}`;return e.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var dle=B((cAt,fle)=>{"use strict";var sle=ER(),{CHAR_ASTERISK:Vq,CHAR_AT:l3e,CHAR_BACKWARD_SLASH:$E,CHAR_COMMA:u3e,CHAR_DOT:zq,CHAR_EXCLAMATION_MARK:Kq,CHAR_FORWARD_SLASH:ule,CHAR_LEFT_CURLY_BRACE:Yq,CHAR_LEFT_PARENTHESES:Xq,CHAR_LEFT_SQUARE_BRACKET:f3e,CHAR_PLUS:d3e,CHAR_QUESTION_MARK:ole,CHAR_RIGHT_CURLY_BRACE:p3e,CHAR_RIGHT_PARENTHESES:ale,CHAR_RIGHT_SQUARE_BRACKET:h3e}=qE(),cle=t=>t===ule||t===$E,lle=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},m3e=(t,e)=>{let n=e||{},r=t.length-1,i=n.parts===!0||n.scanToEnd===!0,s=[],o=[],a=[],c=t,l=-1,u=0,f=0,p=!1,m=!1,g=!1,y=!1,w=!1,S=!1,T=!1,R=!1,C=!1,D=!1,q=0,G,V,L={value:"",depth:0,isGlob:!1},k=()=>l>=r,E=()=>c.charCodeAt(l+1),A=()=>(G=V,c.charCodeAt(++l));for(;l<r;){V=A();let X;if(V===$E){T=L.backslashes=!0,V=A(),V===Yq&&(S=!0);continue}if(S===!0||V===Yq){for(q++;k()!==!0&&(V=A());){if(V===$E){T=L.backslashes=!0,A();continue}if(V===Yq){q++;continue}if(S!==!0&&V===zq&&(V=A())===zq){if(p=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(S!==!0&&V===u3e){if(p=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===p3e&&(q--,q===0)){S=!1,p=L.isBrace=!0,D=!0;break}}if(i===!0)continue;break}if(V===ule){if(s.push(l),o.push(L),L={value:"",depth:0,isGlob:!1},D===!0)continue;if(G===zq&&l===u+1){u+=2;continue}f=l+1;continue}if(n.noext!==!0&&(V===d3e||V===l3e||V===Vq||V===ole||V===Kq)===!0&&E()===Xq){if(g=L.isGlob=!0,y=L.isExtglob=!0,D=!0,V===Kq&&l===u&&(C=!0),i===!0){for(;k()!==!0&&(V=A());){if(V===$E){T=L.backslashes=!0,V=A();continue}if(V===ale){g=L.isGlob=!0,D=!0;break}}continue}break}if(V===Vq){if(G===Vq&&(w=L.isGlobstar=!0),g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===ole){if(g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===f3e){for(;k()!==!0&&(X=A());){if(X===$E){T=L.backslashes=!0,A();continue}if(X===h3e){m=L.isBracket=!0,g=L.isGlob=!0,D=!0;break}}if(i===!0)continue;break}if(n.nonegate!==!0&&V===Kq&&l===u){R=L.negated=!0,u++;continue}if(n.noparen!==!0&&V===Xq){if(g=L.isGlob=!0,i===!0){for(;k()!==!0&&(V=A());){if(V===Xq){T=L.backslashes=!0,V=A();continue}if(V===ale){D=!0;break}}continue}break}if(g===!0){if(D=!0,i===!0)continue;break}}n.noext===!0&&(y=!1,g=!1);let M=c,I="",P="";u>0&&(I=c.slice(0,u),c=c.slice(u),f-=u),M&&g===!0&&f>0?(M=c.slice(0,f),P=c.slice(f)):g===!0?(M="",P=c):M=c,M&&M!==""&&M!=="/"&&M!==c&&cle(M.charCodeAt(M.length-1))&&(M=M.slice(0,-1)),n.unescape===!0&&(P&&(P=sle.removeBackslashes(P)),M&&T===!0&&(M=sle.removeBackslashes(M)));let F={prefix:I,input:t,start:u,base:M,glob:P,isBrace:p,isBracket:m,isGlob:g,isExtglob:y,isGlobstar:w,negated:R,negatedExtglob:C};if(n.tokens===!0&&(F.maxDepth=0,cle(V)||o.push(L),F.tokens=o),n.parts===!0||n.tokens===!0){let X;for(let N=0;N<s.length;N++){let b=X?X+1:u,$=s[N],pe=t.slice(b,$);n.tokens&&(N===0&&u!==0?(o[N].isPrefix=!0,o[N].value=I):o[N].value=pe,lle(o[N]),F.maxDepth+=o[N].depth),(N!==0||pe!=="")&&a.push(pe),X=$}if(X&&X+1<t.length){let N=t.slice(X+1);a.push(N),n.tokens&&(o[o.length-1].value=N,lle(o[o.length-1]),F.maxDepth+=o[o.length-1].depth)}F.slashes=s,F.parts=a}return F};fle.exports=m3e});var yle=B((lAt,gle)=>{"use strict";var GE=qE(),gi=ER(),{MAX_LENGTH:wR,POSIX_REGEX_SOURCE:g3e,REGEX_NON_SPECIAL_CHARS:y3e,REGEX_SPECIAL_CHARS_BACKREF:_3e,REPLACEMENTS:ple}=GE,v3e=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let n=`[${t.join("-")}]`;try{new RegExp(n)}catch{return t.map(i=>gi.escapeRegex(i)).join("..")}return n},Fy=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,hle=t=>{let e=[],n=0,r=0,i=0,s="",o=!1;for(let a of t){if(o===!0){s+=a,o=!1;continue}if(a==="\\"){s+=a,o=!0;continue}if(a==='"'){i=i===1?0:1,s+=a;continue}if(i===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){e.push(s),s="";continue}}}s+=a}return e.push(s),e},E3e=t=>{let e=!1;for(let n of t){if(e===!0){e=!1;continue}if(n==="\\"){e=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},mle=t=>{let e=t.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=!0);if(E3e(e))return e.replace(/\\(.)/g,"$1")},w3e=t=>{let e=t.map(mle).filter(Boolean);for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let i=e[n],s=e[r],o=i[0];if(!(!o||i!==o.repeat(i.length)||s!==o.repeat(s.length))&&(i===s||i.startsWith(s)||s.startsWith(i)))return!0}return!1},Jq=(t,e=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let n=0,r=0,i=0,s=!1;for(let o=1;o<t.length;o++){let a=t[o];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){i=i===1?0:1;continue}if(i!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return e===!0&&o!==t.length-1?void 0:{type:t[0],body:t.slice(2,o),end:o}}}}},S3e=t=>{let e=0,n=[];for(;e<t.length;){let i=Jq(t.slice(e),!1);if(!i||i.type!=="*")return;let s=hle(i.body).map(a=>a.trim());if(s.length!==1)return;let o=mle(s[0]);if(!o||o.length!==1)return;n.push(o),e+=i.end+1}return n.length<1?void 0:`${n.length===1?gi.escapeRegex(n[0]):`[${n.map(i=>gi.escapeRegex(i)).join("")}]`}*`},x3e=t=>{let e=0,n=t.trim(),r=Jq(n);for(;r;)e++,n=r.body.trim(),r=Jq(n);return e},b3e=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:GE.DEFAULT_MAX_EXTGLOB_RECURSION,r=hle(t).map(i=>i.trim());if(r.length>1&&(r.some(i=>i==="")||r.some(i=>/^[*?]+$/.test(i))||w3e(r)))return{risky:!0};for(let i of r){let s=S3e(i);if(s)return{risky:!0,safeOutput:s};if(x3e(i)>n)return{risky:!0}}return{risky:!1}},Qq=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=ple[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(wR,n.maxLength):wR,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},o=[s],a=n.capture?"":"?:",c=gi.isWindows(e),l=GE.globChars(c),u=GE.extglobChars(l),{DOT_LITERAL:f,PLUS_LITERAL:p,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:y,NO_DOT:w,NO_DOT_SLASH:S,NO_DOTS_SLASH:T,QMARK:R,QMARK_NO_DOT:C,STAR:D,START_ANCHOR:q}=l,G=U=>`(${a}(?:(?!${q}${U.dot?y:f}).)*?)`,V=n.dot?"":w,L=n.dot?R:C,k=n.bash===!0?G(n):D;n.capture&&(k=`(${k})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let E={input:t,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:o};t=gi.removePrefix(t,E),i=t.length;let A=[],M=[],I=[],P=s,F,X=()=>E.index===i-1,N=E.peek=(U=1)=>t[E.index+U],b=E.advance=()=>t[++E.index]||"",$=()=>t.slice(E.index+1),pe=(U="",K=0)=>{E.consumed+=U,E.index+=K},oe=U=>{E.output+=U.output!=null?U.output:U.value,pe(U.value)},J=()=>{let U=1;for(;N()==="!"&&(N(2)!=="("||N(3)==="?");)b(),E.start++,U++;return U%2===0?!1:(E.negated=!0,E.start++,!0)},ve=U=>{E[U]++,I.push(U)},we=U=>{E[U]--,I.pop()},Se=U=>{if(P.type==="globstar"){let K=E.braces>0&&(U.type==="comma"||U.type==="brace"),j=U.extglob===!0||A.length&&(U.type==="pipe"||U.type==="paren");U.type!=="slash"&&U.type!=="paren"&&!K&&!j&&(E.output=E.output.slice(0,-P.output.length),P.type="star",P.value="*",P.output=k,E.output+=P.output)}if(A.length&&U.type!=="paren"&&(A[A.length-1].inner+=U.value),(U.value||U.output)&&oe(U),P&&P.type==="text"&&U.type==="text"){P.value+=U.value,P.output=(P.output||"")+U.value;return}U.prev=P,o.push(U),P=U},ct=(U,K)=>{let j={...u[K],conditions:1,inner:""};j.prev=P,j.parens=E.parens,j.output=E.output,j.startIndex=E.index,j.tokensIndex=o.length;let Q=(n.capture?"(":"")+j.open;ve("parens"),Se({type:U,value:K,output:E.output?"":g}),Se({type:"paren",extglob:!0,value:b(),output:Q}),A.push(j)},Ue=U=>{let K=t.slice(U.startIndex,E.index+1),j=t.slice(U.startIndex+2,E.index),Q=b3e(j,n);if((U.type==="plus"||U.type==="star")&&Q.risky){let ie=Q.safeOutput?(U.output?"":g)+(n.capture?`(${Q.safeOutput})`:Q.safeOutput):void 0,ne=o[U.tokensIndex];ne.type="text",ne.value=K,ne.output=ie||gi.escapeRegex(K);for(let re=U.tokensIndex+1;re<o.length;re++)o[re].value="",o[re].output="",delete o[re].suffix;E.output=U.output+ne.output,E.backtrack=!0,Se({type:"paren",extglob:!0,value:F,output:""}),we("parens");return}let Z=U.close+(n.capture?")":""),ee;if(U.type==="negate"){let ie=k;if(U.inner&&U.inner.length>1&&U.inner.includes("/")&&(ie=G(n)),(ie!==k||X()||/^\)+$/.test($()))&&(Z=U.close=`)$))${ie}`),U.inner.includes("*")&&(ee=$())&&/^\.[^\\/.]+$/.test(ee)){let ne=Qq(ee,{...e,fastpaths:!1}).output;Z=U.close=`)${ne})${ie})`}U.prev.type==="bos"&&(E.negatedExtglob=!0)}Se({type:"paren",extglob:!0,value:F,output:Z}),we("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let U=!1,K=t.replace(_3e,(j,Q,Z,ee,ie,ne)=>ee==="\\"?(U=!0,j):ee==="?"?Q?Q+ee+(ie?R.repeat(ie.length):""):ne===0?L+(ie?R.repeat(ie.length):""):R.repeat(Z.length):ee==="."?f.repeat(Z.length):ee==="*"?Q?Q+ee+(ie?k:""):k:Q?j:`\\${j}`);return U===!0&&(n.unescape===!0?K=K.replace(/\\/g,""):K=K.replace(/\\+/g,j=>j.length%2===0?"\\\\":j?"\\":"")),K===t&&n.contains===!0?(E.output=t,E):(E.output=gi.wrapOutput(K,E,e),E)}for(;!X();){if(F=b(),F==="\0")continue;if(F==="\\"){let j=N();if(j==="/"&&n.bash!==!0||j==="."||j===";")continue;if(!j){F+="\\",Se({type:"text",value:F});continue}let Q=/^\\+/.exec($()),Z=0;if(Q&&Q[0].length>2&&(Z=Q[0].length,E.index+=Z,Z%2!==0&&(F+="\\")),n.unescape===!0?F=b():F+=b(),E.brackets===0){Se({type:"text",value:F});continue}}if(E.brackets>0&&(F!=="]"||P.value==="["||P.value==="[^")){if(n.posix!==!1&&F===":"){let j=P.value.slice(1);if(j.includes("[")&&(P.posix=!0,j.includes(":"))){let Q=P.value.lastIndexOf("["),Z=P.value.slice(0,Q),ee=P.value.slice(Q+2),ie=g3e[ee];if(ie){P.value=Z+ie,E.backtrack=!0,b(),!s.output&&o.indexOf(P)===1&&(s.output=g);continue}}}(F==="["&&N()!==":"||F==="-"&&N()==="]")&&(F=`\\${F}`),F==="]"&&(P.value==="["||P.value==="[^")&&(F=`\\${F}`),n.posix===!0&&F==="!"&&P.value==="["&&(F="^"),P.value+=F,oe({value:F});continue}if(E.quotes===1&&F!=='"'){F=gi.escapeRegex(F),P.value+=F,oe({value:F});continue}if(F==='"'){E.quotes=E.quotes===1?0:1,n.keepQuotes===!0&&Se({type:"text",value:F});continue}if(F==="("){ve("parens"),Se({type:"paren",value:F});continue}if(F===")"){if(E.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Fy("opening","("));let j=A[A.length-1];if(j&&E.parens===j.parens+1){Ue(A.pop());continue}Se({type:"paren",value:F,output:E.parens?")":"\\)"}),we("parens");continue}if(F==="["){if(n.nobracket===!0||!$().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Fy("closing","]"));F=`\\${F}`}else ve("brackets");Se({type:"bracket",value:F});continue}if(F==="]"){if(n.nobracket===!0||P&&P.type==="bracket"&&P.value.length===1){Se({type:"text",value:F,output:`\\${F}`});continue}if(E.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Fy("opening","["));Se({type:"text",value:F,output:`\\${F}`});continue}we("brackets");let j=P.value.slice(1);if(P.posix!==!0&&j[0]==="^"&&!j.includes("/")&&(F=`/${F}`),P.value+=F,oe({value:F}),n.literalBrackets===!1||gi.hasRegexChars(j))continue;let Q=gi.escapeRegex(P.value);if(E.output=E.output.slice(0,-P.value.length),n.literalBrackets===!0){E.output+=Q,P.value=Q;continue}P.value=`(${a}${Q}|${P.value})`,E.output+=P.value;continue}if(F==="{"&&n.nobrace!==!0){ve("braces");let j={type:"brace",value:F,output:"(",outputIndex:E.output.length,tokensIndex:E.tokens.length};M.push(j),Se(j);continue}if(F==="}"){let j=M[M.length-1];if(n.nobrace===!0||!j){Se({type:"text",value:F,output:F});continue}let Q=")";if(j.dots===!0){let Z=o.slice(),ee=[];for(let ie=Z.length-1;ie>=0&&(o.pop(),Z[ie].type!=="brace");ie--)Z[ie].type!=="dots"&&ee.unshift(Z[ie].value);Q=v3e(ee,n),E.backtrack=!0}if(j.comma!==!0&&j.dots!==!0){let Z=E.output.slice(0,j.outputIndex),ee=E.tokens.slice(j.tokensIndex);j.value=j.output="\\{",F=Q="\\}",E.output=Z;for(let ie of ee)E.output+=ie.output||ie.value}Se({type:"brace",value:F,output:Q}),we("braces"),M.pop();continue}if(F==="|"){A.length>0&&A[A.length-1].conditions++,Se({type:"text",value:F});continue}if(F===","){let j=F,Q=M[M.length-1];Q&&I[I.length-1]==="braces"&&(Q.comma=!0,j="|"),Se({type:"comma",value:F,output:j});continue}if(F==="/"){if(P.type==="dot"&&E.index===E.start+1){E.start=E.index+1,E.consumed="",E.output="",o.pop(),P=s;continue}Se({type:"slash",value:F,output:m});continue}if(F==="."){if(E.braces>0&&P.type==="dot"){P.value==="."&&(P.output=f);let j=M[M.length-1];P.type="dots",P.output+=F,P.value+=F,j.dots=!0;continue}if(E.braces+E.parens===0&&P.type!=="bos"&&P.type!=="slash"){Se({type:"text",value:F,output:f});continue}Se({type:"dot",value:F,output:f});continue}if(F==="?"){if(!(P&&P.value==="(")&&n.noextglob!==!0&&N()==="("&&N(2)!=="?"){ct("qmark",F);continue}if(P&&P.type==="paren"){let Q=N(),Z=F;if(Q==="<"&&!gi.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(P.value==="("&&!/[!=<:]/.test(Q)||Q==="<"&&!/<([!=]|\w+>)/.test($()))&&(Z=`\\${F}`),Se({type:"text",value:F,output:Z});continue}if(n.dot!==!0&&(P.type==="slash"||P.type==="bos")){Se({type:"qmark",value:F,output:C});continue}Se({type:"qmark",value:F,output:R});continue}if(F==="!"){if(n.noextglob!==!0&&N()==="("&&(N(2)!=="?"||!/[!=<:]/.test(N(3)))){ct("negate",F);continue}if(n.nonegate!==!0&&E.index===0){J();continue}}if(F==="+"){if(n.noextglob!==!0&&N()==="("&&N(2)!=="?"){ct("plus",F);continue}if(P&&P.value==="("||n.regex===!1){Se({type:"plus",value:F,output:p});continue}if(P&&(P.type==="bracket"||P.type==="paren"||P.type==="brace")||E.parens>0){Se({type:"plus",value:F});continue}Se({type:"plus",value:p});continue}if(F==="@"){if(n.noextglob!==!0&&N()==="("&&N(2)!=="?"){Se({type:"at",extglob:!0,value:F,output:""});continue}Se({type:"text",value:F});continue}if(F!=="*"){(F==="$"||F==="^")&&(F=`\\${F}`);let j=y3e.exec($());j&&(F+=j[0],E.index+=j[0].length),Se({type:"text",value:F});continue}if(P&&(P.type==="globstar"||P.star===!0)){P.type="star",P.star=!0,P.value+=F,P.output=k,E.backtrack=!0,E.globstar=!0,pe(F);continue}let U=$();if(n.noextglob!==!0&&/^\([^?]/.test(U)){ct("star",F);continue}if(P.type==="star"){if(n.noglobstar===!0){pe(F);continue}let j=P.prev,Q=j.prev,Z=j.type==="slash"||j.type==="bos",ee=Q&&(Q.type==="star"||Q.type==="globstar");if(n.bash===!0&&(!Z||U[0]&&U[0]!=="/")){Se({type:"star",value:F,output:""});continue}let ie=E.braces>0&&(j.type==="comma"||j.type==="brace"),ne=A.length&&(j.type==="pipe"||j.type==="paren");if(!Z&&j.type!=="paren"&&!ie&&!ne){Se({type:"star",value:F,output:""});continue}for(;U.slice(0,3)==="/**";){let re=t[E.index+4];if(re&&re!=="/")break;U=U.slice(3),pe("/**",3)}if(j.type==="bos"&&X()){P.type="globstar",P.value+=F,P.output=G(n),E.output=P.output,E.globstar=!0,pe(F);continue}if(j.type==="slash"&&j.prev.type!=="bos"&&!ee&&X()){E.output=E.output.slice(0,-(j.output+P.output).length),j.output=`(?:${j.output}`,P.type="globstar",P.output=G(n)+(n.strictSlashes?")":"|$)"),P.value+=F,E.globstar=!0,E.output+=j.output+P.output,pe(F);continue}if(j.type==="slash"&&j.prev.type!=="bos"&&U[0]==="/"){let re=U[1]!==void 0?"|$":"";E.output=E.output.slice(0,-(j.output+P.output).length),j.output=`(?:${j.output}`,P.type="globstar",P.output=`${G(n)}${m}|${m}${re})`,P.value+=F,E.output+=j.output+P.output,E.globstar=!0,pe(F+b()),Se({type:"slash",value:"/",output:""});continue}if(j.type==="bos"&&U[0]==="/"){P.type="globstar",P.value+=F,P.output=`(?:^|${m}|${G(n)}${m})`,E.output=P.output,E.globstar=!0,pe(F+b()),Se({type:"slash",value:"/",output:""});continue}E.output=E.output.slice(0,-P.output.length),P.type="globstar",P.output=G(n),P.value+=F,E.output+=P.output,E.globstar=!0,pe(F);continue}let K={type:"star",value:F,output:k};if(n.bash===!0){K.output=".*?",(P.type==="bos"||P.type==="slash")&&(K.output=V+K.output),Se(K);continue}if(P&&(P.type==="bracket"||P.type==="paren")&&n.regex===!0){K.output=F,Se(K);continue}(E.index===E.start||P.type==="slash"||P.type==="dot")&&(P.type==="dot"?(E.output+=S,P.output+=S):n.dot===!0?(E.output+=T,P.output+=T):(E.output+=V,P.output+=V),N()!=="*"&&(E.output+=g,P.output+=g)),Se(K)}for(;E.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Fy("closing","]"));E.output=gi.escapeLast(E.output,"["),we("brackets")}for(;E.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Fy("closing",")"));E.output=gi.escapeLast(E.output,"("),we("parens")}for(;E.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Fy("closing","}"));E.output=gi.escapeLast(E.output,"{"),we("braces")}if(n.strictSlashes!==!0&&(P.type==="star"||P.type==="bracket")&&Se({type:"maybe_slash",value:"",output:`${m}?`}),E.backtrack===!0){E.output="";for(let U of E.tokens)E.output+=U.output!=null?U.output:U.value,U.suffix&&(E.output+=U.suffix)}return E};Qq.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(wR,n.maxLength):wR,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);t=ple[t]||t;let s=gi.isWindows(e),{DOT_LITERAL:o,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:f,NO_DOTS_SLASH:p,STAR:m,START_ANCHOR:g}=GE.globChars(s),y=n.dot?f:u,w=n.dot?p:u,S=n.capture?"":"?:",T={negated:!1,prefix:""},R=n.bash===!0?".*?":m;n.capture&&(R=`(${R})`);let C=V=>V.noglobstar===!0?R:`(${S}(?:(?!${g}${V.dot?l:o}).)*?)`,D=V=>{switch(V){case"*":return`${y}${c}${R}`;case".*":return`${o}${c}${R}`;case"*.*":return`${y}${R}${o}${c}${R}`;case"*/*":return`${y}${R}${a}${c}${w}${R}`;case"**":return y+C(n);case"**/*":return`(?:${y}${C(n)}${a})?${w}${c}${R}`;case"**/*.*":return`(?:${y}${C(n)}${a})?${w}${R}${o}${c}${R}`;case"**/.*":return`(?:${y}${C(n)}${a})?${o}${c}${R}`;default:{let L=/^(.*?)\.(\w+)$/.exec(V);if(!L)return;let k=D(L[1]);return k?k+o+L[2]:void 0}}},q=gi.removePrefix(t,T),G=D(q);return G&&n.strictSlashes!==!0&&(G+=`${a}?`),G};gle.exports=Qq});var vle=B((uAt,_le)=>{"use strict";var T3e=require("path"),A3e=dle(),Zq=yle(),e2=ER(),C3e=qE(),R3e=t=>t&&typeof t=="object"&&!Array.isArray(t),ur=(t,e,n=!1)=>{if(Array.isArray(t)){let u=t.map(p=>ur(p,e,n));return p=>{for(let m of u){let g=m(p);if(g)return g}return!1}}let r=R3e(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let i=e||{},s=e2.isWindows(e),o=r?ur.compileRe(t,e):ur.makeRe(t,e,!1,!0),a=o.state;delete o.state;let c=()=>!1;if(i.ignore){let u={...e,ignore:null,onMatch:null,onResult:null};c=ur(i.ignore,u,n)}let l=(u,f=!1)=>{let{isMatch:p,match:m,output:g}=ur.test(u,o,e,{glob:t,posix:s}),y={glob:t,state:a,regex:o,posix:s,input:u,output:g,match:m,isMatch:p};return typeof i.onResult=="function"&&i.onResult(y),p===!1?(y.isMatch=!1,f?y:!1):c(u)?(typeof i.onIgnore=="function"&&i.onIgnore(y),y.isMatch=!1,f?y:!1):(typeof i.onMatch=="function"&&i.onMatch(y),f?y:!0)};return n&&(l.state=a),l};ur.test=(t,e,n,{glob:r,posix:i}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let s=n||{},o=s.format||(i?e2.toPosixSlashes:null),a=t===r,c=a&&o?o(t):t;return a===!1&&(c=o?o(t):t,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=ur.matchBase(t,e,n,i):a=e.exec(c)),{isMatch:!!a,match:a,output:c}};ur.matchBase=(t,e,n,r=e2.isWindows(n))=>(e instanceof RegExp?e:ur.makeRe(e,n)).test(T3e.basename(t));ur.isMatch=(t,e,n)=>ur(e,n)(t);ur.parse=(t,e)=>Array.isArray(t)?t.map(n=>ur.parse(n,e)):Zq(t,{...e,fastpaths:!1});ur.scan=(t,e)=>A3e(t,e);ur.compileRe=(t,e,n=!1,r=!1)=>{if(n===!0)return t.output;let i=e||{},s=i.contains?"":"^",o=i.contains?"":"$",a=`${s}(?:${t.output})${o}`;t&&t.negated===!0&&(a=`^(?!${a}).*$`);let c=ur.toRegex(a,e);return r===!0&&(c.state=t),c};ur.makeRe=(t,e={},n=!1,r=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let i={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(i.output=Zq.fastpaths(t,e)),i.output||(i=Zq(t,e)),ur.compileRe(i,e,n,r)};ur.toRegex=(t,e)=>{try{let n=e||{};return new RegExp(t,n.flags||(n.nocase?"i":""))}catch(n){if(e&&e.debug===!0)throw n;return/$^/}};ur.constants=C3e;_le.exports=ur});var t2=B((fAt,Ele)=>{"use strict";Ele.exports=vle()});var Rle=B((dAt,Cle)=>{"use strict";var jE=require("fs"),{Readable:I3e}=require("stream"),HE=require("path"),{promisify:TR}=require("util"),n2=t2(),k3e=TR(jE.readdir),P3e=TR(jE.stat),wle=TR(jE.lstat),O3e=TR(jE.realpath),M3e="!",Tle="READDIRP_RECURSIVE_ERROR",N3e=new Set(["ENOENT","EPERM","EACCES","ELOOP",Tle]),r2="files",Ale="directories",xR="files_directories",SR="all",Sle=[r2,Ale,xR,SR],D3e=t=>N3e.has(t.code),[xle,L3e]=process.versions.node.split(".").slice(0,2).map(t=>Number.parseInt(t,10)),U3e=process.platform==="win32"&&(xle>10||xle===10&&L3e>=5),ble=t=>{if(t!==void 0){if(typeof t=="function")return t;if(typeof t=="string"){let e=n2(t.trim());return n=>e(n.basename)}if(Array.isArray(t)){let e=[],n=[];for(let r of t){let i=r.trim();i.charAt(0)===M3e?n.push(n2(i.slice(1))):e.push(n2(i))}return n.length>0?e.length>0?r=>e.some(i=>i(r.basename))&&!n.some(i=>i(r.basename)):r=>!n.some(i=>i(r.basename)):r=>e.some(i=>i(r.basename))}}},bR=class t extends I3e{static get defaultOptions(){return{root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:r2,lstat:!1,depth:2147483648,alwaysStat:!1}}constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark||4096});let n={...t.defaultOptions,...e},{root:r,type:i}=n;this._fileFilter=ble(n.fileFilter),this._directoryFilter=ble(n.directoryFilter);let s=n.lstat?wle:P3e;U3e?this._stat=o=>s(o,{bigint:!0}):this._stat=s,this._maxDepth=n.depth,this._wantsDir=[Ale,xR,SR].includes(i),this._wantsFile=[r2,xR,SR].includes(i),this._wantsEverything=i===SR,this._root=HE.resolve(r),this._isDirent="Dirent"in jE&&!n.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(r,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let{path:n,depth:r,files:i=[]}=this.parent||{};if(i.length>0){let s=i.splice(0,e).map(o=>this._formatEntry(o,n));for(let o of await Promise.all(s)){if(this.destroyed)return;let a=await this._getEntryType(o);a==="directory"&&this._directoryFilter(o)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(o.fullPath,r+1)),this._wantsDir&&(this.push(o),e--)):(a==="file"||this._includeAsFile(o))&&this._fileFilter(o)&&this._wantsFile&&(this.push(o),e--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(n){this.destroy(n)}finally{this.reading=!1}}}async _exploreDir(e,n){let r;try{r=await k3e(e,this._rdOptions)}catch(i){this._onError(i)}return{files:r,depth:n,path:e}}async _formatEntry(e,n){let r;try{let i=this._isDirent?e.name:e,s=HE.resolve(HE.join(n,i));r={path:HE.relative(this._root,s),fullPath:s,basename:i},r[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(i){this._onError(i)}return r}_onError(e){D3e(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){let n=e&&e[this._statsProp];if(n){if(n.isFile())return"file";if(n.isDirectory())return"directory";if(n&&n.isSymbolicLink()){let r=e.fullPath;try{let i=await O3e(r),s=await wle(i);if(s.isFile())return"file";if(s.isDirectory()){let o=i.length;if(r.startsWith(i)&&r.substr(o,1)===HE.sep){let a=new Error(`Circular symlink detected: "${r}" points to "${i}"`);return a.code=Tle,this._onError(a)}return"directory"}}catch(i){this._onError(i)}}}}_includeAsFile(e){let n=e&&e[this._statsProp];return n&&this._wantsEverything&&!n.isDirectory()}},By=(t,e={})=>{let n=e.entryType||e.type;if(n==="both"&&(n=xR),n&&(e.type=n),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(n&&!Sle.includes(n))throw new Error(`readdirp: Invalid type passed. Use one of ${Sle.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new bR(e)},F3e=(t,e={})=>new Promise((n,r)=>{let i=[];By(t,e).on("data",s=>i.push(s)).on("end",()=>n(i)).on("error",s=>r(s))});By.promise=F3e;By.ReaddirpStream=bR;By.default=By;Cle.exports=By});var qy=B((pAt,Ile)=>{Ile.exports=function(t,e){if(typeof t!="string")throw new TypeError("expected path to be a string");if(t==="\\"||t==="/")return"/";var n=t.length;if(n<=1)return t;var r="";if(n>4&&t[3]==="\\"){var i=t[2];(i==="?"||i===".")&&t.slice(0,2)==="\\\\"&&(t=t.slice(2),r="//")}var s=t.split(/[/\\]+/);return e!==!1&&s[s.length-1]===""&&s.pop(),r+s.join("/")}});var Dle=B((Mle,Nle)=>{"use strict";Object.defineProperty(Mle,"__esModule",{value:!0});var Ole=t2(),B3e=qy(),kle="!",q3e={returnIndex:!1},$3e=t=>Array.isArray(t)?t:[t],G3e=(t,e)=>{if(typeof t=="function")return t;if(typeof t=="string"){let n=Ole(t,e);return r=>t===r||n(r)}return t instanceof RegExp?n=>t.test(n):n=>!1},Ple=(t,e,n,r)=>{let i=Array.isArray(n),s=i?n[0]:n;if(!i&&typeof s!="string")throw new TypeError("anymatch: second argument must be a string: got "+Object.prototype.toString.call(s));let o=B3e(s,!1);for(let c=0;c<e.length;c++){let l=e[c];if(l(o))return r?-1:!1}let a=i&&[o].concat(n.slice(1));for(let c=0;c<t.length;c++){let l=t[c];if(i?l(...a):l(o))return r?c:!0}return r?-1:!1},i2=(t,e,n=q3e)=>{if(t==null)throw new TypeError("anymatch: specify first argument");let r=typeof n=="boolean"?{returnIndex:n}:n,i=r.returnIndex||!1,s=$3e(t),o=s.filter(c=>typeof c=="string"&&c.charAt(0)===kle).map(c=>c.slice(1)).map(c=>Ole(c,r)),a=s.filter(c=>typeof c!="string"||typeof c=="string"&&c.charAt(0)!==kle).map(c=>G3e(c,r));return e==null?(c,l=!1)=>Ple(a,o,c,typeof l=="boolean"?l:!1):Ple(a,o,e,i)};i2.default=i2;Nle.exports=i2});var Ule=B((hAt,Lle)=>{Lle.exports=function(e){if(typeof e!="string"||e==="")return!1;for(var n;n=/(\\).|([@?!+*]\(.*\))/g.exec(e);){if(n[2])return!0;e=e.slice(n.index+n[0].length)}return!1}});var s2=B((mAt,Ble)=>{var H3e=Ule(),Fle={"{":"}","(":")","[":"]"},j3e=function(t){if(t[0]==="!")return!0;for(var e=0,n=-2,r=-2,i=-2,s=-2,o=-2;e<t.length;){if(t[e]==="*"||t[e+1]==="?"&&/[\].+)]/.test(t[e])||r!==-1&&t[e]==="["&&t[e+1]!=="]"&&(r<e&&(r=t.indexOf("]",e)),r>e&&(o===-1||o>r||(o=t.indexOf("\\",e),o===-1||o>r)))||i!==-1&&t[e]==="{"&&t[e+1]!=="}"&&(i=t.indexOf("}",e),i>e&&(o=t.indexOf("\\",e),o===-1||o>i))||s!==-1&&t[e]==="("&&t[e+1]==="?"&&/[:!=]/.test(t[e+2])&&t[e+3]!==")"&&(s=t.indexOf(")",e),s>e&&(o=t.indexOf("\\",e),o===-1||o>s))||n!==-1&&t[e]==="("&&t[e+1]!=="|"&&(n<e&&(n=t.indexOf("|",e)),n!==-1&&t[n+1]!==")"&&(s=t.indexOf(")",n),s>n&&(o=t.indexOf("\\",n),o===-1||o>s))))return!0;if(t[e]==="\\"){var a=t[e+1];e+=2;var c=Fle[a];if(c){var l=t.indexOf(c,e);l!==-1&&(e=l+1)}if(t[e]==="!")return!0}else e++}return!1},W3e=function(t){if(t[0]==="!")return!0;for(var e=0;e<t.length;){if(/[*?{}()[\]]/.test(t[e]))return!0;if(t[e]==="\\"){var n=t[e+1];e+=2;var r=Fle[n];if(r){var i=t.indexOf(r,e);i!==-1&&(e=i+1)}if(t[e]==="!")return!0}else e++}return!1};Ble.exports=function(e,n){if(typeof e!="string"||e==="")return!1;if(H3e(e))return!0;var r=j3e;return n&&n.strict===!1&&(r=W3e),r(e)}});var $le=B((gAt,qle)=>{"use strict";var V3e=s2(),z3e=require("path").posix.dirname,K3e=require("os").platform()==="win32",o2="/",Y3e=/\\/g,X3e=/[\{\[].*[\}\]]$/,J3e=/(^|[^\\])([\{\[]|\([^\)]+$)/,Q3e=/\\([\!\*\?\|\[\]\(\)\{\}])/g;qle.exports=function(e,n){var r=Object.assign({flipBackslashes:!0},n);r.flipBackslashes&&K3e&&e.indexOf(o2)<0&&(e=e.replace(Y3e,o2)),X3e.test(e)&&(e+=o2),e+="a";do e=z3e(e);while(V3e(e)||J3e.test(e));return e.replace(Q3e,"$1")}});var AR=B(Uo=>{"use strict";Uo.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1;Uo.find=(t,e)=>t.nodes.find(n=>n.type===e);Uo.exceedsLimit=(t,e,n=1,r)=>r===!1||!Uo.isInteger(t)||!Uo.isInteger(e)?!1:(Number(e)-Number(t))/Number(n)>=r;Uo.escapeNode=(t,e=0,n)=>{let r=t.nodes[e];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Uo.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1;Uo.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1;Uo.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0;Uo.reduce=t=>t.reduce((e,n)=>(n.type==="text"&&e.push(n.value),n.type==="range"&&(n.type="text"),e),[]);Uo.flatten=(...t)=>{let e=[],n=r=>{for(let i=0;i<r.length;i++){let s=r[i];if(Array.isArray(s)){n(s);continue}s!==void 0&&e.push(s)}return e};return n(t),e}});var CR=B((_At,Hle)=>{"use strict";var Gle=AR();Hle.exports=(t,e={})=>{let n=(r,i={})=>{let s=e.escapeInvalid&&Gle.isInvalidBrace(i),o=r.invalid===!0&&e.escapeInvalid===!0,a="";if(r.value)return(s||o)&&Gle.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(t)}});var Wle=B((vAt,jle)=>{"use strict";jle.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var eue=B((EAt,Zle)=>{"use strict";var Vle=Wle(),Eh=(t,e,n)=>{if(Vle(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(Vle(e)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let i=String(r.relaxZeros),s=String(r.shorthand),o=String(r.capture),a=String(r.wrap),c=t+":"+e+"="+i+s+o+a;if(Eh.cache.hasOwnProperty(c))return Eh.cache[c].result;let l=Math.min(t,e),u=Math.max(t,e);if(Math.abs(l-u)===1){let y=t+"|"+e;return r.capture?`(${y})`:r.wrap===!1?y:`(?:${y})`}let f=Qle(t)||Qle(e),p={min:t,max:e,a:l,b:u},m=[],g=[];if(f&&(p.isPadded=f,p.maxLen=String(p.max).length),l<0){let y=u<0?Math.abs(u):1;g=zle(y,Math.abs(l),p,r),l=p.a=0}return u>=0&&(m=zle(l,u,p,r)),p.negatives=g,p.positives=m,p.result=Z3e(g,m,r),r.capture===!0?p.result=`(${p.result})`:r.wrap!==!1&&m.length+g.length>1&&(p.result=`(?:${p.result})`),Eh.cache[c]=p,p.result};function Z3e(t,e,n){let r=a2(t,e,"-",!1,n)||[],i=a2(e,t,"",!1,n)||[],s=a2(t,e,"-?",!0,n)||[];return r.concat(s).concat(i).join("|")}function eWe(t,e){let n=1,r=1,i=Yle(t,n),s=new Set([e]);for(;t<=i&&i<=e;)s.add(i),n+=1,i=Yle(t,n);for(i=Xle(e+1,r)-1;t<i&&i<=e;)s.add(i),r+=1,i=Xle(e+1,r)-1;return s=[...s],s.sort(rWe),s}function tWe(t,e,n){if(t===e)return{pattern:t,count:[],digits:0};let r=nWe(t,e),i=r.length,s="",o=0;for(let a=0;a<i;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=iWe(c,l,n):o++}return o&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[o],digits:i}}function zle(t,e,n,r){let i=eWe(t,e),s=[],o=t,a;for(let c=0;c<i.length;c++){let l=i[c],u=tWe(String(o),String(l),r),f="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Jle(a.count),o=l+1;continue}n.isPadded&&(f=sWe(l,n,r)),u.string=f+u.pattern+Jle(u.count),s.push(u),o=l+1,a=u}return s}function a2(t,e,n,r,i){let s=[];for(let o of t){let{string:a}=o;!r&&!Kle(e,"string",a)&&s.push(n+a),r&&Kle(e,"string",a)&&s.push(n+a)}return s}function nWe(t,e){let n=[];for(let r=0;r<t.length;r++)n.push([t[r],e[r]]);return n}function rWe(t,e){return t>e?1:e>t?-1:0}function Kle(t,e,n){return t.some(r=>r[e]===n)}function Yle(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function Xle(t,e){return t-t%Math.pow(10,e)}function Jle(t){let[e=0,n=""]=t;return n||e>1?`{${e+(n?","+n:"")}}`:""}function iWe(t,e,n){return`[${t}${e-t===1?"":"-"}${e}]`}function Qle(t){return/^-?(0+)\d/.test(t)}function sWe(t,e,n){if(!e.isPadded)return t;let r=Math.abs(e.maxLen-String(t).length),i=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return i?"0?":"0";case 2:return i?"0{0,2}":"00";default:return i?`0{0,${r}}`:`0{${r}}`}}Eh.cache={};Eh.clearCache=()=>Eh.cache={};Zle.exports=Eh});var u2=B((wAt,aue)=>{"use strict";var oWe=require("util"),nue=eue(),tue=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),aWe=t=>e=>t===!0?Number(e):String(e),c2=t=>typeof t=="number"||typeof t=="string"&&t!=="",WE=t=>Number.isInteger(+t),l2=t=>{let e=`${t}`,n=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++n]==="0";);return n>0},cWe=(t,e,n)=>typeof t=="string"||typeof e=="string"?!0:n.stringify===!0,lWe=(t,e,n)=>{if(e>0){let r=t[0]==="-"?"-":"";r&&(t=t.slice(1)),t=r+t.padStart(r?e-1:e,"0")}return n===!1?String(t):t},IR=(t,e)=>{let n=t[0]==="-"?"-":"";for(n&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return n?"-"+t:t},uWe=(t,e,n)=>{t.negatives.sort((a,c)=>a<c?-1:a>c?1:0),t.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=e.capture?"":"?:",i="",s="",o;return t.positives.length&&(i=t.positives.map(a=>IR(String(a),n)).join("|")),t.negatives.length&&(s=`-(${r}${t.negatives.map(a=>IR(String(a),n)).join("|")})`),i&&s?o=`${i}|${s}`:o=i||s,e.wrap?`(${r}${o})`:o},rue=(t,e,n,r)=>{if(n)return nue(t,e,{wrap:!1,...r});let i=String.fromCharCode(t);if(t===e)return i;let s=String.fromCharCode(e);return`[${i}-${s}]`},iue=(t,e,n)=>{if(Array.isArray(t)){let r=n.wrap===!0,i=n.capture?"":"?:";return r?`(${i}${t.join("|")})`:t.join("|")}return nue(t,e,n)},sue=(...t)=>new RangeError("Invalid range arguments: "+oWe.inspect(...t)),oue=(t,e,n)=>{if(n.strictRanges===!0)throw sue([t,e]);return[]},fWe=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},dWe=(t,e,n=1,r={})=>{let i=Number(t),s=Number(e);if(!Number.isInteger(i)||!Number.isInteger(s)){if(r.strictRanges===!0)throw sue([t,e]);return[]}i===0&&(i=0),s===0&&(s=0);let o=i>s,a=String(t),c=String(e),l=String(n);n=Math.max(Math.abs(n),1);let u=l2(a)||l2(c)||l2(l),f=u?Math.max(a.length,c.length,l.length):0,p=u===!1&&cWe(t,e,r)===!1,m=r.transform||aWe(p);if(r.toRegex&&n===1)return rue(IR(t,f),IR(e,f),!0,r);let g={negatives:[],positives:[]},y=T=>g[T<0?"negatives":"positives"].push(Math.abs(T)),w=[],S=0;for(;o?i>=s:i<=s;)r.toRegex===!0&&n>1?y(i):w.push(lWe(m(i,S),f,p)),i=o?i-n:i+n,S++;return r.toRegex===!0?n>1?uWe(g,r,f):iue(w,null,{wrap:!1,...r}):w},pWe=(t,e,n=1,r={})=>{if(!WE(t)&&t.length>1||!WE(e)&&e.length>1)return oue(t,e,r);let i=r.transform||(p=>String.fromCharCode(p)),s=`${t}`.charCodeAt(0),o=`${e}`.charCodeAt(0),a=s>o,c=Math.min(s,o),l=Math.max(s,o);if(r.toRegex&&n===1)return rue(c,l,!1,r);let u=[],f=0;for(;a?s>=o:s<=o;)u.push(i(s,f)),s=a?s-n:s+n,f++;return r.toRegex===!0?iue(u,null,{wrap:!1,options:r}):u},RR=(t,e,n,r={})=>{if(e==null&&c2(t))return[t];if(!c2(t)||!c2(e))return oue(t,e,r);if(typeof n=="function")return RR(t,e,1,{transform:n});if(tue(n))return RR(t,e,0,n);let i={...r};return i.capture===!0&&(i.wrap=!0),n=n||i.step||1,WE(n)?WE(t)&&WE(e)?dWe(t,e,n,i):pWe(t,e,Math.max(Math.abs(n),1),i):n!=null&&!tue(n)?fWe(n,i):RR(t,e,1,n)};aue.exports=RR});var uue=B((SAt,lue)=>{"use strict";var hWe=u2(),cue=AR(),mWe=(t,e={})=>{let n=(r,i={})=>{let s=cue.isInvalidBrace(i),o=r.invalid===!0&&e.escapeInvalid===!0,a=s===!0||o===!0,c=e.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=cue.reduce(r.nodes),f=hWe(...u,{...e,wrap:!1,toRegex:!0,strictZeros:!0});if(f.length!==0)return u.length>1&&f.length>1?`(${f})`:f}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(t)};lue.exports=mWe});var pue=B((xAt,due)=>{"use strict";var gWe=u2(),fue=CR(),$y=AR(),wh=(t="",e="",n=!1)=>{let r=[];if(t=[].concat(t),e=[].concat(e),!e.length)return t;if(!t.length)return n?$y.flatten(e).map(i=>`{${i}}`):e;for(let i of t)if(Array.isArray(i))for(let s of i)r.push(wh(s,e,n));else for(let s of e)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?wh(i,s,n):i+s);return $y.flatten(r)},yWe=(t,e={})=>{let n=e.rangeLimit===void 0?1e3:e.rangeLimit,r=(i,s={})=>{i.queue=[];let o=s,a=s.queue;for(;o.type!=="brace"&&o.type!=="root"&&o.parent;)o=o.parent,a=o.queue;if(i.invalid||i.dollar){a.push(wh(a.pop(),fue(i,e)));return}if(i.type==="brace"&&i.invalid!==!0&&i.nodes.length===2){a.push(wh(a.pop(),["{}"]));return}if(i.nodes&&i.ranges>0){let f=$y.reduce(i.nodes);if($y.exceedsLimit(...f,e.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let p=gWe(...f,e);p.length===0&&(p=fue(i,e)),a.push(wh(a.pop(),p)),i.nodes=[];return}let c=$y.encloseBrace(i),l=i.queue,u=i;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let f=0;f<i.nodes.length;f++){let p=i.nodes[f];if(p.type==="comma"&&i.type==="brace"){f===1&&l.push(""),l.push("");continue}if(p.type==="close"){a.push(wh(a.pop(),l,c));continue}if(p.value&&p.type!=="open"){l.push(wh(l.pop(),p.value));continue}p.nodes&&r(p,i)}return l};return $y.flatten(r(t))};due.exports=yWe});var mue=B((bAt,hue)=>{"use strict";hue.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
393
|
+
`}function Dje(t){let e=Mje[t];if(!e)return{success:!1,error:"Unknown tool"};try{return t==="codex"||t==="opencode"||t==="amp"||t==="pi"?e.enable():e.enable(Un[t]())}catch(n){return{success:!1,error:n.message}}}function Lje(t){let e=(process.env.PATH||"").split(Tr.default.delimiter).filter(Boolean),n=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT").split(";"):[""];return e.some(r=>n.some(i=>{try{return Je.default.existsSync(Tr.default.join(r,t+i))}catch{return!1}}))}function $ce(t){let e=Lce[t];if(e&&Lje(e))return!0;let n=uje[t]?.();return n?(Array.isArray(n)?n:[n]).some(r=>Je.default.existsSync(r)):!1}function Gce(){let t={};for(let e of Nje)if($ce(e))try{let n=Dje(e);t[e]=n.success&&!n.untrusted?.length}catch{t[e]=!1}return t}async function Hce(){if(!$ce("codex"))return null;try{let{missing:t}=await wje();return t.length&&console.warn(`\u26A0\uFE0F codex hooks written but not trusted: ${t.length} \u2014 run codex and trust them`),t.length?{untrusted:t.length}:{untrusted:0}}catch(t){return console.warn(`\u26A0\uFE0F codex hook trust failed: ${t.message}`),{error:t.message}}}function jce(){let t=Un.claude(),e=Ar(t);if(!e.hooks?.Stop&&!e.hooks?.Notification)return;let n=e.env||{};Object.keys(Tv).some(i=>n[i]!==Tv[i])&&(Uce(e),as(t,e))}var Mce,Je,Tr,Nce,Nq,Dce,lje,Di,gh,Un,Lce,yh,uje,Dq,mR,hR,fje,pR,Fce,CTt,Bce,yje,vje,xje,Pce,Tje,Rje,Ije,kje,Pje,Oje,Mje,Nje,Wce=ae(()=>{Mce=ce(require("os"),1),Je=ce(require("fs"),1),Tr=ce(require("path"),1),Nce=require("child_process");Lt();_o();Ic();Nq=`http://localhost:${vs}/api/notify`,Dce="nineRemoteNotify",lje=Tr.default.join(Oe.STATE,"claudeEnvBackup.json"),Di=(...t)=>Tr.default.join(Mce.default.homedir(),...t),gh=(t,...e)=>{let n=process.env[t];return n&&n.trim()?n.trim():Di(...e)},Un={claude:()=>Di(".claude","settings.json"),codex:()=>Di(".codex","config.toml"),codexHooks:()=>Di(".codex","hooks.json"),codexScript:()=>Di(".codex","9remote-notify.sh"),opencode:()=>Di(".config","opencode","plugin",`${Dce}.js`),grok:()=>Tr.default.join(gh("GROK_HOME",".grok"),"hooks","9remote.json"),cursor:()=>Di(".cursor","hooks.json"),antigravity:()=>Di(".gemini","config","hooks.json"),kiro:()=>Tr.default.join(gh("KIRO_HOME",".kiro"),"agents","9remote.json"),copilot:()=>Tr.default.join(gh("COPILOT_HOME",".copilot"),"config.json"),codebuddy:()=>Tr.default.join(gh("CODEBUDDY_CONFIG_DIR",".codebuddy"),"settings.json"),factory:()=>Di(".factory","settings.json"),qoder:()=>Tr.default.join(gh("QODER_CONFIG_DIR",".qoder"),"settings.json"),rovodev:()=>Di(".rovodev","config.yml"),hermes:()=>Tr.default.join(gh("HERMES_HOME",".hermes"),"config.yaml"),amp:()=>Di(".config","amp","plugins","9remote.ts"),pi:()=>Tr.default.join(gh("PI_CODING_AGENT_DIR",".pi","agent"),"extensions","9remote.ts")},Lce={claude:"claude",codex:"codex",opencode:"opencode",grok:"grok",cursor:"cursor-agent",antigravity:"agy",kiro:"kiro-cli",copilot:"copilot",codebuddy:"codebuddy",factory:"droid",qoder:"qodercli",rovodev:"acli",hermes:"hermes",amp:"amp",pi:"pi"},yh=(t,e,{sessionId:n=!1}={})=>{let r=n?ty(e)[0]:null;return`${r?`csid=$(cat 2>/dev/null | sed -n 's/.*"${r}" *: *"\\([^"]*\\)".*/\\1/p'); `:""}command -v curl >/dev/null 2>&1 && curl -s --connect-timeout 1 --max-time 2 "${Nq}?type=${t}&sessionId=$NINE_REMOTE_SESSION_ID${r?"&csid=$csid":""}&tool=${e}" > /dev/null 2>&1 & true`},uje={claude:()=>Di(".claude"),codex:()=>Di(".codex"),opencode:()=>[Di(".config","opencode"),Di(".opencode")]},Dq=t=>Math.ceil(t/1e3),mR=5e3,hR=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),fje=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;pR={UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked"},Fce=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase(),CTt=Object.fromEntries(Object.keys(pR).map(t=>[Fce(t),t])),Bce=/^\[hooks\.state\."(?<key>[^"]+)"\]$/m,yje=15e3;vje=t=>/^sha256:/.test(t)?t:`sha256:${t}`;xje=/# 9Remote notification\nnotify\s*=.*\n?/g,Pce=/^# 9Remote-saved: (notify\s*=.*)$/m;Tje={enable(){let t=Un.codexHooks(),e=Ar(t),n={...e.hooks||{}};for(let[r,i]of Object.entries(pR))n[r]=[...(n[r]||[]).filter(s=>!Mq(s)),Aje(i)];return e.hooks=n,as(t,e),bje(),{success:!0}},disable(){let t=Un.codexHooks(),e=new Set(qce(t).filter(n=>n.command.includes("&tool=codex")).map(n=>n.key));if(Je.default.existsSync(t)){let n=Ar(t);if(n.hooks){for(let r of Object.keys(pR))n.hooks[r]=(n.hooks[r]||[]).filter(i=>!Mq(i)),n.hooks[r].length===0&&delete n.hooks[r];Object.keys(n.hooks).length===0&&delete n.hooks}as(t,n)}return Sje(Un.codex(),e),{success:!0}},isEnabled(){let t=Ar(Un.codexHooks()).hooks||{};return Object.keys(pR).every(e=>(t[e]||[]).some(Mq))}};Rje={enable(){let t=Un.opencode(),e=Tr.default.dirname(t);return Je.default.existsSync(e)||Je.default.mkdirSync(e,{recursive:!0}),Je.default.writeFileSync(t,Cje(),"utf8"),{success:!0}},disable(){let t=Un.opencode();return Je.default.existsSync(t)&&Je.default.unlinkSync(t),{success:!0}},isEnabled(){let t=Un.opencode();return Je.default.existsSync(t)&&Je.default.readFileSync(t,"utf8").includes("&sessionID=")}};Ije="# 9remote hooks begin",kje="# 9remote hooks end",Pje=" # 9remote hooks begin",Oje=" # 9remote hooks end",Mje={claude:Uy("claude",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked",Notification:"blocked"},t=>t,{matchers:{Notification:"permission_prompt"},extra:Uce,sessionId:!0}),codex:Tje,opencode:Rje,grok:Uy("grok",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",Notification:"blocked"},Dq),cursor:hje("cursor",{stop:"done",beforeShellExecution:"blocked",beforeToolCall:"working"},{extra:t=>{t.version=t.version||1}}),antigravity:mje("antigravity","9remote",{UserPromptSubmit:"working",PreToolUse:"working",Stop:"done",Notification:"blocked"}),kiro:gje("kiro",{UserPromptSubmit:"working",PostToolUse:"working",preToolUse:"blocked",stop:"done"}),copilot:Uy("copilot",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),codebuddy:Uy("codebuddy",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),factory:Uy("factory",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),qoder:Uy("qoder",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),rovodev:kce("rovodev",{begin:Pje,end:Oje,items:[{event:"on_complete",type:"done"},{event:"on_error",type:"done"},{event:"on_tool_permission",type:"blocked"},{event:"on_message",type:"working"},{event:"on_tool_start",type:"working"}]}),hermes:(()=>{let t=kce("hermes",{begin:Ije,end:kje,items:[{event:"pre_llm_call",type:"working"},{event:"pre_tool_call",type:"working"},{event:"post_tool_call",type:"working"},{event:"pre_approval_request",type:"blocked"},{event:"post_llm_call",type:"done"}]}),e=()=>Tr.default.join(Tr.default.dirname(Un.hermes()),"shell-hooks-allowlist.json");return{enable:()=>{let n=t.enable(Un.hermes()),r=Ar(e()),i=(r.approvals||[]).filter(s=>!(typeof s.command=="string"&&s.command.includes("&tool=hermes")));return r.approvals=[...i,...[{event:"pre_llm_call",type:"working"},{event:"pre_tool_call",type:"working"},{event:"post_tool_call",type:"working"},{event:"pre_approval_request",type:"blocked"},{event:"post_llm_call",type:"done"}].map(({event:s,type:o})=>({event:s,command:yh(o,"hermes"),approved_at:"2020-01-01T00:00:00Z"}))],as(e(),r),n},disable:()=>{let n=t.disable(Un.hermes()),r=e();if(Je.default.existsSync(r)){let i=Ar(r);i.approvals=(i.approvals||[]).filter(s=>!(typeof s.command=="string"&&s.command.includes("&tool=hermes"))),i.approvals.length?as(r,i):Je.default.unlinkSync(r)}return n},isEnabled:()=>t.isEnabled(Un.hermes())}})(),amp:{enable(){let t=Un.amp(),e=Tr.default.dirname(t);return Je.default.existsSync(e)||Je.default.mkdirSync(e,{recursive:!0}),Je.default.writeFileSync(t,Oce("amp","amp","agent.start","agent.end"),"utf8"),{success:!0}},disable(){return Je.default.existsSync(Un.amp())&&Je.default.unlinkSync(Un.amp()),{success:!0}},isEnabled(){return Je.default.existsSync(Un.amp())}},pi:{enable(){let t=Un.pi(),e=Tr.default.dirname(t);return Je.default.existsSync(e)||Je.default.mkdirSync(e,{recursive:!0}),Je.default.writeFileSync(t,Oce("pi","pi","agent_start","agent_end"),"utf8"),{success:!0}},disable(){return Je.default.existsSync(Un.pi())&&Je.default.unlinkSync(Un.pi()),{success:!0}},isEnabled(){return Je.default.existsSync(Un.pi())}}},Nje=M8});var Lq=ae(()=>{Ms()});var Oq={};dr(Oq,{broadcastAiStatus:()=>BE,broadcastServerInfo:()=>$q,initializeTerminal:()=>qq,listSessionRoots:()=>cu,matchWorkspacePath:()=>Qce,registerManagedSession:()=>Bq,setConnectCheckHandler:()=>Gq,setupTerminalHandlers:()=>Hq,setupTerminalSocket:()=>Vf});async function qje(t,e){if(!cne(e))return;let r=(await vf().catch(()=>null))?.find(s=>s.id===e);ane(e,r?.foregroundProcess)?.state==="idle"&&(et(t,"statusChange",{sessionId:e,state:"idle",tool:null,conversationId:null}),et(t,"statusState",Pc()))}function $je(t,e){let n=(yR.get(t)||"")+e,r=null;Vce.lastIndex=0;for(let o;o=Vce.exec(n);)r=o[1];if(r){let o=Wte(r);o&&ns(t,o)}let i=n.lastIndexOf("\x1B]"),s=i===-1?"":n.slice(i);s&&s.length<=Fje&&!s.slice(3).includes("\x07")&&!s.includes("\x1B\\")?yR.set(t,s):yR.delete(t)}function Kce(){let t=(zce||Promise.resolve()).catch(()=>{}).then(()=>Gje());return zce=t.catch(()=>{}),t}async function Gje(){let t=await vf(),e=new Map(t.map(r=>[r.id,r])),n=kA();for(let r of t)if(!n[r.id])try{await Ef(r.id)}catch{}$r.clear();for(let[r,i]of Object.entries(n)){let s=e.get(r);$r.set(r,{daemon:!0,name:i.name,autoNamed:i.autoNamed!==!1,createdAt:i.createdAt,shellId:i.shellId,cwd:s?.cwd||i.cwd,workspacePath:i.workspacePath??UE[r]??null,lastCols:i.cols??null,lastRows:i.rows??null,needsRespawn:!s,agent:i.agent||null}),i.agent&&ns(r,i.agent),JU(r,i)}ei($r)}function Hje(t){!jf||!t||FE.has(t)||FE.set(t,setTimeout(()=>{FE.delete(t),vC(jf,$r,t).catch(()=>{})},fQ))}function Uq(){let{assignments:t,created:e}=Pne({sessions:$r,workspaces:[...Wf.values()],sessionWorkspaces:vh});if(Object.keys(t).length){for(let n of e)Wf.set(n.id,n);for(let[n,r]of Object.entries(t)){vh[n]=r;let i=$r.get(n);i&&!i.workspacePath&&(i.workspacePath=Wf.get(r)?.path||null)}sy(Wf,vh,_R),ei($r),console.log(Jce(`\u{1F4C1} Grouped ${Object.keys(t).length} loose terminal(s)`+(e.length?` into ${e.length} new workspace(s)`:"")))}}function cu(){return[...$r.entries()].map(([t,e])=>({id:t,name:e.name,workspacePath:e.workspacePath||null,cwd:e.cwd||null}))}function Qce(t,e){let n=e?(0,_h.resolve)(e):"";if(!n)return null;let r=null,i=null,s=null;for(let o of t||[]){if(!o?.path)continue;let a=(0,_h.resolve)(o.path);n===a?r=o:n.startsWith(a+"/")&&(!i||a.length>(0,_h.resolve)(i.path).length)?i=o:a.startsWith(n+"/")&&(!s||a.length<(0,_h.resolve)(s.path).length)&&(s=o)}return r||i||s||null}function Bq({sessionId:t,name:e,autoNamed:n=!0,cwd:r=null,workspacePath:i=null,shellId:s=null,shellLabel:o=null,agent:a=null}){let c=Qce([...Wf.values()],i||r)||null;return $r.set(t,{daemon:!0,name:e,autoNamed:n,createdAt:Date.now(),cwd:r||c?.path||null,workspacePath:c?.path||null,shellId:s,shellLabel:o,agent:a}),c&&(vh[t]=c.id,sy(Wf,vh,_R)),ei($r),et(null,"sessionsChanged"),{success:!0,sessionId:t,workspacePath:c?.path||null}}async function qq(){let t=Sne();if(!t){let r=kA(),i=wne();t=kne(i,r);let s=new Map(t.workspaces.map(c=>[c.id,c]));if(sy(s,t.sessionWorkspaces,t.sessionOrder),UE=t.sessionPaths||{},Object.keys(UE).length){for(let[c,l]of Object.entries(UE))r[c]&&(r[c].workspacePath=l);Ene(r)}let o=(i.groups||[]).filter(c=>t.workspaces.some(l=>l.id===c.id)).length,a=(i.groups||[]).length-o;(t.workspaces.length||a)&&console.log(Jce(`\u{1F4C1} Migrated ${t.workspaces.length} workspace(s) from terminal groups`+(a?`, dropped ${a} empty group(s)`:"")))}for(let r of t.workspaces)Wf.set(r.id,r);Object.assign(vh,t.sessionWorkspaces),_R.push(...t.sessionOrder),nne(()=>ei($r)),une(Hje);try{jce()}catch{}try{Gce()}catch{}Hce().catch(()=>{});try{Cce()}catch{}if(Fq==="daemon")if(!await OL())console.error("\u274C Failed to connect to PTY daemon, falling back to buffer mode");else{await Kce(),Uq(),Cp("connected",()=>{Kce().then(Uq).catch(()=>{})});return}console.log("\u{1F4E6} Buffer persistence mode - scrollback enabled");let e=vne(),n=kA();for(let r of e){let i=n[r]||{};$r.set(r,{pty:null,name:i.name||`Terminal ${$r.size+1}`,autoNamed:i.autoNamed!==!1,createdAt:i.createdAt||Date.now(),cwd:i.cwd,workspacePath:i.workspacePath??UE[r]??null,shellId:i.shellId,buffer:[],needsRestore:!0}),JU(r,i),console.log(`\u{1F504} Found saved session: ${r}`)}e.length>0&&console.log(`\u2705 Found ${e.length} saved session(s)`),Uq()}function Vf(t,e){jf=t,Fq==="daemon"&&(Cp("output",({sessionId:i,enc:s,data:o,replay:a})=>{a!==!0&&(TA(i),xA(i));let c=s==="b64"?Buffer.from(o,"base64"):Buffer.from(o||"");c.length>Aa&&(gR++,(gR===1||gR%500===0)&&Xce.info(`[slice] chunk ${c.length>>10}KB \u2192 ${Math.ceil(c.length/Aa)} events (total sliced: ${gR})`)),s==="b64"&&$je(i,c.toString("utf8"));for(let l=0;l<c.length||l===0;l+=Aa){let u=c.subarray(l,l+Aa),f=a===!0?mE(i):Bie(i);a!==!0&&qie(i,f,u),et(t,"output",{sessionId:i,enc:"bin",data:u,replay:a===!0,seq:f})}}),mne(i=>et(t,"statusState",Pc())),pne(()=>et(t,"statusState",Pc())),Cp("cwdChange",({sessionId:i,cwd:s})=>{let o=$r.get(i);o&&s&&o.cwd!==s&&(o.cwd=s,ei($r)),et(t,"cwdChange",{sessionId:i,cwd:s})}),Cp("processChange",({sessionId:i,process:s})=>{let o=one(i,s);if(o?.state==="pendingShell"){setTimeout(()=>qje(t,i),Bje);return}o?.state==="idle"&&(et(t,"statusChange",{sessionId:i,state:"idle",tool:null,conversationId:null}),et(t,"statusState",Pc()))}),Cp("sessionClosed",i=>{$r.delete(i),gy(i),ny(i),yR.delete(i);let s=FE.get(i);s&&(clearTimeout(s),FE.delete(i)),eF(i),et(t,"sessionClosed",i),et(t,"notificationCleared",i)}));let n=()=>({version:Uje,remoteAvailable:Sp(),mobileAvailable:Rte(),daemonMode:Fq==="daemon"&&In(),platform:process.platform,updateAvailable:KD(),canSelfUpdate:!0,caps:{joinSessionSize:!0,artifact:!0},artifactEnabled:LE(),voiceConfig:xa().voiceConfig||null,mcpClients:Ly,...Pte()}),r=()=>{let i=n();for(let s of t.sockets.sockets.values())s.data?.approved&&s.emit("serverInfo",i)};QD(r),Vf._buildServerInfo=n,Vf._emitServerInfo=r}function $q(){Vf._emitServerInfo?.()}function BE(t,e,n,r=null){if(!jf)return null;if(e==="done")return bA(t,()=>{let a=r?.sessionId||r?.threadId||ts(t)?.id||null,c=Mf(t),l=Wp({type:e,sessionId:t,tool:n});!l||l===c||(et(jf,"statusChange",{sessionId:t,state:e,tool:n,conversationId:a}),et(jf,"statusState",Pc()))}),Mf(t);let i=r?.sessionId||r?.threadId||ts(t)?.id||null,s=Mf(t),o=Wp({type:e,sessionId:t,tool:n});return!o||o===s||(et(jf,"statusChange",{sessionId:t,state:e,tool:n,conversationId:i}),et(jf,"statusState",Pc())),o}function Gq(t){Zce=t}async function Hq(t,e,n){Xce.info(`[diag] setupTerminalHandlers START id=${t.id} virtual=${!!t.defersWsAdapter}`),Ote(),Zce?.(),t.emit("srvCaps",{env2:1}),t.emit("serverInfo",Vf._buildServerInfo?.()),Vie(t,e,$r,Wf,vh,_R),Zie(t,$r),Rce(t,e),XT()&&await RZ(t,n).catch(r=>{console.error("\u274C Failed to setup remote handlers:",r.message)}),Ite(t),t.on("disconnect",()=>{_ae(t.id),Mte()})}var _h,Yce,Xce,sAt,Jce,Fq,Uje,Vce,Fje,Bje,yR,$r,Wf,vh,_R,UE,zce,FE,jf,gR,Zce,Da=ae(()=>{PO();_h=require("path"),Yce=require("url");di();JT();kte();Eo();fA();PA();One();wC();ese();Ice();Wce();dR();xg();QC();Lq();Ms();Ic();Ji();lB();Kl();st();Xce=be("terminal"),sAt=(0,_h.dirname)((0,Yce.fileURLToPath)(__importMetaUrl)),Jce=xv.rgb(230,138,110),Fq="daemon",Uje="3.0.6",Vce=/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/g,Fje=256,Bje=1500,yR=new Map;$r=new Map,Wf=new Map,vh={},_R=[],UE={},zce=null;FE=new Map,jf=null;gR=0;Zce=null});var qE=B((oAt,ile)=>{"use strict";var jje=require("path"),qc="\\\\/",ele=`[^${qc}]`,Wje=0,lu="\\.",Vje="\\+",zje="\\?",vR="\\/",Kje="(?=.)",tle="[^/]",jq=`(?:${vR}|$)`,nle=`(?:^|${vR})`,Wq=`${lu}{1,2}${jq}`,Yje=`(?!${lu})`,Xje=`(?!${nle}${Wq})`,Jje=`(?!${lu}{0,1}${jq})`,Qje=`(?!${Wq})`,Zje=`[^.${vR}]`,e3e=`${tle}*?`,rle={DOT_LITERAL:lu,PLUS_LITERAL:Vje,QMARK_LITERAL:zje,SLASH_LITERAL:vR,ONE_CHAR:Kje,QMARK:tle,END_ANCHOR:jq,DOTS_SLASH:Wq,NO_DOT:Yje,NO_DOTS:Xje,NO_DOT_SLASH:Jje,NO_DOTS_SLASH:Qje,QMARK_NO_DOT:Zje,STAR:e3e,START_ANCHOR:nle},t3e={...rle,SLASH_LITERAL:`[${qc}]`,QMARK:ele,STAR:`${ele}*?`,DOTS_SLASH:`${lu}{1,2}(?:[${qc}]|$)`,NO_DOT:`(?!${lu})`,NO_DOTS:`(?!(?:^|[${qc}])${lu}{1,2}(?:[${qc}]|$))`,NO_DOT_SLASH:`(?!${lu}{0,1}(?:[${qc}]|$))`,NO_DOTS_SLASH:`(?!${lu}{1,2}(?:[${qc}]|$))`,QMARK_NO_DOT:`[^.${qc}]`,START_ANCHOR:`(?:^|[${qc}])`,END_ANCHOR:`(?:[${qc}]|$)`},n3e={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};ile.exports={DEFAULT_MAX_EXTGLOB_RECURSION:Wje,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:n3e,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:jje.sep,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?t3e:rle}}});var ER=B(cs=>{"use strict";var r3e=require("path"),i3e=process.platform==="win32",{REGEX_BACKSLASH:s3e,REGEX_REMOVE_BACKSLASH:o3e,REGEX_SPECIAL_CHARS:a3e,REGEX_SPECIAL_CHARS_GLOBAL:c3e}=qE();cs.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);cs.hasRegexChars=t=>a3e.test(t);cs.isRegexChar=t=>t.length===1&&cs.hasRegexChars(t);cs.escapeRegex=t=>t.replace(c3e,"\\$1");cs.toPosixSlashes=t=>t.replace(s3e,"/");cs.removeBackslashes=t=>t.replace(o3e,e=>e==="\\"?"":e);cs.supportsLookbehinds=()=>{let t=process.version.slice(1).split(".").map(Number);return t.length===3&&t[0]>=9||t[0]===8&&t[1]>=10};cs.isWindows=t=>t&&typeof t.windows=="boolean"?t.windows:i3e===!0||r3e.sep==="\\";cs.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?cs.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};cs.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};cs.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",i=n.contains?"":"$",s=`${r}(?:${t})${i}`;return e.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var dle=B((cAt,fle)=>{"use strict";var sle=ER(),{CHAR_ASTERISK:Vq,CHAR_AT:l3e,CHAR_BACKWARD_SLASH:$E,CHAR_COMMA:u3e,CHAR_DOT:zq,CHAR_EXCLAMATION_MARK:Kq,CHAR_FORWARD_SLASH:ule,CHAR_LEFT_CURLY_BRACE:Yq,CHAR_LEFT_PARENTHESES:Xq,CHAR_LEFT_SQUARE_BRACKET:f3e,CHAR_PLUS:d3e,CHAR_QUESTION_MARK:ole,CHAR_RIGHT_CURLY_BRACE:p3e,CHAR_RIGHT_PARENTHESES:ale,CHAR_RIGHT_SQUARE_BRACKET:h3e}=qE(),cle=t=>t===ule||t===$E,lle=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},m3e=(t,e)=>{let n=e||{},r=t.length-1,i=n.parts===!0||n.scanToEnd===!0,s=[],o=[],a=[],c=t,l=-1,u=0,f=0,p=!1,m=!1,g=!1,y=!1,w=!1,S=!1,T=!1,R=!1,C=!1,D=!1,q=0,G,V,L={value:"",depth:0,isGlob:!1},k=()=>l>=r,E=()=>c.charCodeAt(l+1),A=()=>(G=V,c.charCodeAt(++l));for(;l<r;){V=A();let X;if(V===$E){T=L.backslashes=!0,V=A(),V===Yq&&(S=!0);continue}if(S===!0||V===Yq){for(q++;k()!==!0&&(V=A());){if(V===$E){T=L.backslashes=!0,A();continue}if(V===Yq){q++;continue}if(S!==!0&&V===zq&&(V=A())===zq){if(p=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(S!==!0&&V===u3e){if(p=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===p3e&&(q--,q===0)){S=!1,p=L.isBrace=!0,D=!0;break}}if(i===!0)continue;break}if(V===ule){if(s.push(l),o.push(L),L={value:"",depth:0,isGlob:!1},D===!0)continue;if(G===zq&&l===u+1){u+=2;continue}f=l+1;continue}if(n.noext!==!0&&(V===d3e||V===l3e||V===Vq||V===ole||V===Kq)===!0&&E()===Xq){if(g=L.isGlob=!0,y=L.isExtglob=!0,D=!0,V===Kq&&l===u&&(C=!0),i===!0){for(;k()!==!0&&(V=A());){if(V===$E){T=L.backslashes=!0,V=A();continue}if(V===ale){g=L.isGlob=!0,D=!0;break}}continue}break}if(V===Vq){if(G===Vq&&(w=L.isGlobstar=!0),g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===ole){if(g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===f3e){for(;k()!==!0&&(X=A());){if(X===$E){T=L.backslashes=!0,A();continue}if(X===h3e){m=L.isBracket=!0,g=L.isGlob=!0,D=!0;break}}if(i===!0)continue;break}if(n.nonegate!==!0&&V===Kq&&l===u){R=L.negated=!0,u++;continue}if(n.noparen!==!0&&V===Xq){if(g=L.isGlob=!0,i===!0){for(;k()!==!0&&(V=A());){if(V===Xq){T=L.backslashes=!0,V=A();continue}if(V===ale){D=!0;break}}continue}break}if(g===!0){if(D=!0,i===!0)continue;break}}n.noext===!0&&(y=!1,g=!1);let M=c,I="",P="";u>0&&(I=c.slice(0,u),c=c.slice(u),f-=u),M&&g===!0&&f>0?(M=c.slice(0,f),P=c.slice(f)):g===!0?(M="",P=c):M=c,M&&M!==""&&M!=="/"&&M!==c&&cle(M.charCodeAt(M.length-1))&&(M=M.slice(0,-1)),n.unescape===!0&&(P&&(P=sle.removeBackslashes(P)),M&&T===!0&&(M=sle.removeBackslashes(M)));let F={prefix:I,input:t,start:u,base:M,glob:P,isBrace:p,isBracket:m,isGlob:g,isExtglob:y,isGlobstar:w,negated:R,negatedExtglob:C};if(n.tokens===!0&&(F.maxDepth=0,cle(V)||o.push(L),F.tokens=o),n.parts===!0||n.tokens===!0){let X;for(let N=0;N<s.length;N++){let b=X?X+1:u,$=s[N],pe=t.slice(b,$);n.tokens&&(N===0&&u!==0?(o[N].isPrefix=!0,o[N].value=I):o[N].value=pe,lle(o[N]),F.maxDepth+=o[N].depth),(N!==0||pe!=="")&&a.push(pe),X=$}if(X&&X+1<t.length){let N=t.slice(X+1);a.push(N),n.tokens&&(o[o.length-1].value=N,lle(o[o.length-1]),F.maxDepth+=o[o.length-1].depth)}F.slashes=s,F.parts=a}return F};fle.exports=m3e});var yle=B((lAt,gle)=>{"use strict";var GE=qE(),gi=ER(),{MAX_LENGTH:wR,POSIX_REGEX_SOURCE:g3e,REGEX_NON_SPECIAL_CHARS:y3e,REGEX_SPECIAL_CHARS_BACKREF:_3e,REPLACEMENTS:ple}=GE,v3e=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let n=`[${t.join("-")}]`;try{new RegExp(n)}catch{return t.map(i=>gi.escapeRegex(i)).join("..")}return n},Fy=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,hle=t=>{let e=[],n=0,r=0,i=0,s="",o=!1;for(let a of t){if(o===!0){s+=a,o=!1;continue}if(a==="\\"){s+=a,o=!0;continue}if(a==='"'){i=i===1?0:1,s+=a;continue}if(i===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){e.push(s),s="";continue}}}s+=a}return e.push(s),e},E3e=t=>{let e=!1;for(let n of t){if(e===!0){e=!1;continue}if(n==="\\"){e=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},mle=t=>{let e=t.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=!0);if(E3e(e))return e.replace(/\\(.)/g,"$1")},w3e=t=>{let e=t.map(mle).filter(Boolean);for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let i=e[n],s=e[r],o=i[0];if(!(!o||i!==o.repeat(i.length)||s!==o.repeat(s.length))&&(i===s||i.startsWith(s)||s.startsWith(i)))return!0}return!1},Jq=(t,e=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let n=0,r=0,i=0,s=!1;for(let o=1;o<t.length;o++){let a=t[o];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){i=i===1?0:1;continue}if(i!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return e===!0&&o!==t.length-1?void 0:{type:t[0],body:t.slice(2,o),end:o}}}}},S3e=t=>{let e=0,n=[];for(;e<t.length;){let i=Jq(t.slice(e),!1);if(!i||i.type!=="*")return;let s=hle(i.body).map(a=>a.trim());if(s.length!==1)return;let o=mle(s[0]);if(!o||o.length!==1)return;n.push(o),e+=i.end+1}return n.length<1?void 0:`${n.length===1?gi.escapeRegex(n[0]):`[${n.map(i=>gi.escapeRegex(i)).join("")}]`}*`},x3e=t=>{let e=0,n=t.trim(),r=Jq(n);for(;r;)e++,n=r.body.trim(),r=Jq(n);return e},b3e=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:GE.DEFAULT_MAX_EXTGLOB_RECURSION,r=hle(t).map(i=>i.trim());if(r.length>1&&(r.some(i=>i==="")||r.some(i=>/^[*?]+$/.test(i))||w3e(r)))return{risky:!0};for(let i of r){let s=S3e(i);if(s)return{risky:!0,safeOutput:s};if(x3e(i)>n)return{risky:!0}}return{risky:!1}},Qq=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=ple[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(wR,n.maxLength):wR,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},o=[s],a=n.capture?"":"?:",c=gi.isWindows(e),l=GE.globChars(c),u=GE.extglobChars(l),{DOT_LITERAL:f,PLUS_LITERAL:p,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:y,NO_DOT:w,NO_DOT_SLASH:S,NO_DOTS_SLASH:T,QMARK:R,QMARK_NO_DOT:C,STAR:D,START_ANCHOR:q}=l,G=U=>`(${a}(?:(?!${q}${U.dot?y:f}).)*?)`,V=n.dot?"":w,L=n.dot?R:C,k=n.bash===!0?G(n):D;n.capture&&(k=`(${k})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let E={input:t,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:o};t=gi.removePrefix(t,E),i=t.length;let A=[],M=[],I=[],P=s,F,X=()=>E.index===i-1,N=E.peek=(U=1)=>t[E.index+U],b=E.advance=()=>t[++E.index]||"",$=()=>t.slice(E.index+1),pe=(U="",K=0)=>{E.consumed+=U,E.index+=K},oe=U=>{E.output+=U.output!=null?U.output:U.value,pe(U.value)},J=()=>{let U=1;for(;N()==="!"&&(N(2)!=="("||N(3)==="?");)b(),E.start++,U++;return U%2===0?!1:(E.negated=!0,E.start++,!0)},ve=U=>{E[U]++,I.push(U)},we=U=>{E[U]--,I.pop()},Se=U=>{if(P.type==="globstar"){let K=E.braces>0&&(U.type==="comma"||U.type==="brace"),j=U.extglob===!0||A.length&&(U.type==="pipe"||U.type==="paren");U.type!=="slash"&&U.type!=="paren"&&!K&&!j&&(E.output=E.output.slice(0,-P.output.length),P.type="star",P.value="*",P.output=k,E.output+=P.output)}if(A.length&&U.type!=="paren"&&(A[A.length-1].inner+=U.value),(U.value||U.output)&&oe(U),P&&P.type==="text"&&U.type==="text"){P.value+=U.value,P.output=(P.output||"")+U.value;return}U.prev=P,o.push(U),P=U},ct=(U,K)=>{let j={...u[K],conditions:1,inner:""};j.prev=P,j.parens=E.parens,j.output=E.output,j.startIndex=E.index,j.tokensIndex=o.length;let Q=(n.capture?"(":"")+j.open;ve("parens"),Se({type:U,value:K,output:E.output?"":g}),Se({type:"paren",extglob:!0,value:b(),output:Q}),A.push(j)},Ue=U=>{let K=t.slice(U.startIndex,E.index+1),j=t.slice(U.startIndex+2,E.index),Q=b3e(j,n);if((U.type==="plus"||U.type==="star")&&Q.risky){let ie=Q.safeOutput?(U.output?"":g)+(n.capture?`(${Q.safeOutput})`:Q.safeOutput):void 0,ne=o[U.tokensIndex];ne.type="text",ne.value=K,ne.output=ie||gi.escapeRegex(K);for(let re=U.tokensIndex+1;re<o.length;re++)o[re].value="",o[re].output="",delete o[re].suffix;E.output=U.output+ne.output,E.backtrack=!0,Se({type:"paren",extglob:!0,value:F,output:""}),we("parens");return}let Z=U.close+(n.capture?")":""),ee;if(U.type==="negate"){let ie=k;if(U.inner&&U.inner.length>1&&U.inner.includes("/")&&(ie=G(n)),(ie!==k||X()||/^\)+$/.test($()))&&(Z=U.close=`)$))${ie}`),U.inner.includes("*")&&(ee=$())&&/^\.[^\\/.]+$/.test(ee)){let ne=Qq(ee,{...e,fastpaths:!1}).output;Z=U.close=`)${ne})${ie})`}U.prev.type==="bos"&&(E.negatedExtglob=!0)}Se({type:"paren",extglob:!0,value:F,output:Z}),we("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let U=!1,K=t.replace(_3e,(j,Q,Z,ee,ie,ne)=>ee==="\\"?(U=!0,j):ee==="?"?Q?Q+ee+(ie?R.repeat(ie.length):""):ne===0?L+(ie?R.repeat(ie.length):""):R.repeat(Z.length):ee==="."?f.repeat(Z.length):ee==="*"?Q?Q+ee+(ie?k:""):k:Q?j:`\\${j}`);return U===!0&&(n.unescape===!0?K=K.replace(/\\/g,""):K=K.replace(/\\+/g,j=>j.length%2===0?"\\\\":j?"\\":"")),K===t&&n.contains===!0?(E.output=t,E):(E.output=gi.wrapOutput(K,E,e),E)}for(;!X();){if(F=b(),F==="\0")continue;if(F==="\\"){let j=N();if(j==="/"&&n.bash!==!0||j==="."||j===";")continue;if(!j){F+="\\",Se({type:"text",value:F});continue}let Q=/^\\+/.exec($()),Z=0;if(Q&&Q[0].length>2&&(Z=Q[0].length,E.index+=Z,Z%2!==0&&(F+="\\")),n.unescape===!0?F=b():F+=b(),E.brackets===0){Se({type:"text",value:F});continue}}if(E.brackets>0&&(F!=="]"||P.value==="["||P.value==="[^")){if(n.posix!==!1&&F===":"){let j=P.value.slice(1);if(j.includes("[")&&(P.posix=!0,j.includes(":"))){let Q=P.value.lastIndexOf("["),Z=P.value.slice(0,Q),ee=P.value.slice(Q+2),ie=g3e[ee];if(ie){P.value=Z+ie,E.backtrack=!0,b(),!s.output&&o.indexOf(P)===1&&(s.output=g);continue}}}(F==="["&&N()!==":"||F==="-"&&N()==="]")&&(F=`\\${F}`),F==="]"&&(P.value==="["||P.value==="[^")&&(F=`\\${F}`),n.posix===!0&&F==="!"&&P.value==="["&&(F="^"),P.value+=F,oe({value:F});continue}if(E.quotes===1&&F!=='"'){F=gi.escapeRegex(F),P.value+=F,oe({value:F});continue}if(F==='"'){E.quotes=E.quotes===1?0:1,n.keepQuotes===!0&&Se({type:"text",value:F});continue}if(F==="("){ve("parens"),Se({type:"paren",value:F});continue}if(F===")"){if(E.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Fy("opening","("));let j=A[A.length-1];if(j&&E.parens===j.parens+1){Ue(A.pop());continue}Se({type:"paren",value:F,output:E.parens?")":"\\)"}),we("parens");continue}if(F==="["){if(n.nobracket===!0||!$().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Fy("closing","]"));F=`\\${F}`}else ve("brackets");Se({type:"bracket",value:F});continue}if(F==="]"){if(n.nobracket===!0||P&&P.type==="bracket"&&P.value.length===1){Se({type:"text",value:F,output:`\\${F}`});continue}if(E.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Fy("opening","["));Se({type:"text",value:F,output:`\\${F}`});continue}we("brackets");let j=P.value.slice(1);if(P.posix!==!0&&j[0]==="^"&&!j.includes("/")&&(F=`/${F}`),P.value+=F,oe({value:F}),n.literalBrackets===!1||gi.hasRegexChars(j))continue;let Q=gi.escapeRegex(P.value);if(E.output=E.output.slice(0,-P.value.length),n.literalBrackets===!0){E.output+=Q,P.value=Q;continue}P.value=`(${a}${Q}|${P.value})`,E.output+=P.value;continue}if(F==="{"&&n.nobrace!==!0){ve("braces");let j={type:"brace",value:F,output:"(",outputIndex:E.output.length,tokensIndex:E.tokens.length};M.push(j),Se(j);continue}if(F==="}"){let j=M[M.length-1];if(n.nobrace===!0||!j){Se({type:"text",value:F,output:F});continue}let Q=")";if(j.dots===!0){let Z=o.slice(),ee=[];for(let ie=Z.length-1;ie>=0&&(o.pop(),Z[ie].type!=="brace");ie--)Z[ie].type!=="dots"&&ee.unshift(Z[ie].value);Q=v3e(ee,n),E.backtrack=!0}if(j.comma!==!0&&j.dots!==!0){let Z=E.output.slice(0,j.outputIndex),ee=E.tokens.slice(j.tokensIndex);j.value=j.output="\\{",F=Q="\\}",E.output=Z;for(let ie of ee)E.output+=ie.output||ie.value}Se({type:"brace",value:F,output:Q}),we("braces"),M.pop();continue}if(F==="|"){A.length>0&&A[A.length-1].conditions++,Se({type:"text",value:F});continue}if(F===","){let j=F,Q=M[M.length-1];Q&&I[I.length-1]==="braces"&&(Q.comma=!0,j="|"),Se({type:"comma",value:F,output:j});continue}if(F==="/"){if(P.type==="dot"&&E.index===E.start+1){E.start=E.index+1,E.consumed="",E.output="",o.pop(),P=s;continue}Se({type:"slash",value:F,output:m});continue}if(F==="."){if(E.braces>0&&P.type==="dot"){P.value==="."&&(P.output=f);let j=M[M.length-1];P.type="dots",P.output+=F,P.value+=F,j.dots=!0;continue}if(E.braces+E.parens===0&&P.type!=="bos"&&P.type!=="slash"){Se({type:"text",value:F,output:f});continue}Se({type:"dot",value:F,output:f});continue}if(F==="?"){if(!(P&&P.value==="(")&&n.noextglob!==!0&&N()==="("&&N(2)!=="?"){ct("qmark",F);continue}if(P&&P.type==="paren"){let Q=N(),Z=F;if(Q==="<"&&!gi.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(P.value==="("&&!/[!=<:]/.test(Q)||Q==="<"&&!/<([!=]|\w+>)/.test($()))&&(Z=`\\${F}`),Se({type:"text",value:F,output:Z});continue}if(n.dot!==!0&&(P.type==="slash"||P.type==="bos")){Se({type:"qmark",value:F,output:C});continue}Se({type:"qmark",value:F,output:R});continue}if(F==="!"){if(n.noextglob!==!0&&N()==="("&&(N(2)!=="?"||!/[!=<:]/.test(N(3)))){ct("negate",F);continue}if(n.nonegate!==!0&&E.index===0){J();continue}}if(F==="+"){if(n.noextglob!==!0&&N()==="("&&N(2)!=="?"){ct("plus",F);continue}if(P&&P.value==="("||n.regex===!1){Se({type:"plus",value:F,output:p});continue}if(P&&(P.type==="bracket"||P.type==="paren"||P.type==="brace")||E.parens>0){Se({type:"plus",value:F});continue}Se({type:"plus",value:p});continue}if(F==="@"){if(n.noextglob!==!0&&N()==="("&&N(2)!=="?"){Se({type:"at",extglob:!0,value:F,output:""});continue}Se({type:"text",value:F});continue}if(F!=="*"){(F==="$"||F==="^")&&(F=`\\${F}`);let j=y3e.exec($());j&&(F+=j[0],E.index+=j[0].length),Se({type:"text",value:F});continue}if(P&&(P.type==="globstar"||P.star===!0)){P.type="star",P.star=!0,P.value+=F,P.output=k,E.backtrack=!0,E.globstar=!0,pe(F);continue}let U=$();if(n.noextglob!==!0&&/^\([^?]/.test(U)){ct("star",F);continue}if(P.type==="star"){if(n.noglobstar===!0){pe(F);continue}let j=P.prev,Q=j.prev,Z=j.type==="slash"||j.type==="bos",ee=Q&&(Q.type==="star"||Q.type==="globstar");if(n.bash===!0&&(!Z||U[0]&&U[0]!=="/")){Se({type:"star",value:F,output:""});continue}let ie=E.braces>0&&(j.type==="comma"||j.type==="brace"),ne=A.length&&(j.type==="pipe"||j.type==="paren");if(!Z&&j.type!=="paren"&&!ie&&!ne){Se({type:"star",value:F,output:""});continue}for(;U.slice(0,3)==="/**";){let re=t[E.index+4];if(re&&re!=="/")break;U=U.slice(3),pe("/**",3)}if(j.type==="bos"&&X()){P.type="globstar",P.value+=F,P.output=G(n),E.output=P.output,E.globstar=!0,pe(F);continue}if(j.type==="slash"&&j.prev.type!=="bos"&&!ee&&X()){E.output=E.output.slice(0,-(j.output+P.output).length),j.output=`(?:${j.output}`,P.type="globstar",P.output=G(n)+(n.strictSlashes?")":"|$)"),P.value+=F,E.globstar=!0,E.output+=j.output+P.output,pe(F);continue}if(j.type==="slash"&&j.prev.type!=="bos"&&U[0]==="/"){let re=U[1]!==void 0?"|$":"";E.output=E.output.slice(0,-(j.output+P.output).length),j.output=`(?:${j.output}`,P.type="globstar",P.output=`${G(n)}${m}|${m}${re})`,P.value+=F,E.output+=j.output+P.output,E.globstar=!0,pe(F+b()),Se({type:"slash",value:"/",output:""});continue}if(j.type==="bos"&&U[0]==="/"){P.type="globstar",P.value+=F,P.output=`(?:^|${m}|${G(n)}${m})`,E.output=P.output,E.globstar=!0,pe(F+b()),Se({type:"slash",value:"/",output:""});continue}E.output=E.output.slice(0,-P.output.length),P.type="globstar",P.output=G(n),P.value+=F,E.output+=P.output,E.globstar=!0,pe(F);continue}let K={type:"star",value:F,output:k};if(n.bash===!0){K.output=".*?",(P.type==="bos"||P.type==="slash")&&(K.output=V+K.output),Se(K);continue}if(P&&(P.type==="bracket"||P.type==="paren")&&n.regex===!0){K.output=F,Se(K);continue}(E.index===E.start||P.type==="slash"||P.type==="dot")&&(P.type==="dot"?(E.output+=S,P.output+=S):n.dot===!0?(E.output+=T,P.output+=T):(E.output+=V,P.output+=V),N()!=="*"&&(E.output+=g,P.output+=g)),Se(K)}for(;E.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Fy("closing","]"));E.output=gi.escapeLast(E.output,"["),we("brackets")}for(;E.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Fy("closing",")"));E.output=gi.escapeLast(E.output,"("),we("parens")}for(;E.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Fy("closing","}"));E.output=gi.escapeLast(E.output,"{"),we("braces")}if(n.strictSlashes!==!0&&(P.type==="star"||P.type==="bracket")&&Se({type:"maybe_slash",value:"",output:`${m}?`}),E.backtrack===!0){E.output="";for(let U of E.tokens)E.output+=U.output!=null?U.output:U.value,U.suffix&&(E.output+=U.suffix)}return E};Qq.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(wR,n.maxLength):wR,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);t=ple[t]||t;let s=gi.isWindows(e),{DOT_LITERAL:o,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:f,NO_DOTS_SLASH:p,STAR:m,START_ANCHOR:g}=GE.globChars(s),y=n.dot?f:u,w=n.dot?p:u,S=n.capture?"":"?:",T={negated:!1,prefix:""},R=n.bash===!0?".*?":m;n.capture&&(R=`(${R})`);let C=V=>V.noglobstar===!0?R:`(${S}(?:(?!${g}${V.dot?l:o}).)*?)`,D=V=>{switch(V){case"*":return`${y}${c}${R}`;case".*":return`${o}${c}${R}`;case"*.*":return`${y}${R}${o}${c}${R}`;case"*/*":return`${y}${R}${a}${c}${w}${R}`;case"**":return y+C(n);case"**/*":return`(?:${y}${C(n)}${a})?${w}${c}${R}`;case"**/*.*":return`(?:${y}${C(n)}${a})?${w}${R}${o}${c}${R}`;case"**/.*":return`(?:${y}${C(n)}${a})?${o}${c}${R}`;default:{let L=/^(.*?)\.(\w+)$/.exec(V);if(!L)return;let k=D(L[1]);return k?k+o+L[2]:void 0}}},q=gi.removePrefix(t,T),G=D(q);return G&&n.strictSlashes!==!0&&(G+=`${a}?`),G};gle.exports=Qq});var vle=B((uAt,_le)=>{"use strict";var T3e=require("path"),A3e=dle(),Zq=yle(),e2=ER(),C3e=qE(),R3e=t=>t&&typeof t=="object"&&!Array.isArray(t),ur=(t,e,n=!1)=>{if(Array.isArray(t)){let u=t.map(p=>ur(p,e,n));return p=>{for(let m of u){let g=m(p);if(g)return g}return!1}}let r=R3e(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let i=e||{},s=e2.isWindows(e),o=r?ur.compileRe(t,e):ur.makeRe(t,e,!1,!0),a=o.state;delete o.state;let c=()=>!1;if(i.ignore){let u={...e,ignore:null,onMatch:null,onResult:null};c=ur(i.ignore,u,n)}let l=(u,f=!1)=>{let{isMatch:p,match:m,output:g}=ur.test(u,o,e,{glob:t,posix:s}),y={glob:t,state:a,regex:o,posix:s,input:u,output:g,match:m,isMatch:p};return typeof i.onResult=="function"&&i.onResult(y),p===!1?(y.isMatch=!1,f?y:!1):c(u)?(typeof i.onIgnore=="function"&&i.onIgnore(y),y.isMatch=!1,f?y:!1):(typeof i.onMatch=="function"&&i.onMatch(y),f?y:!0)};return n&&(l.state=a),l};ur.test=(t,e,n,{glob:r,posix:i}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let s=n||{},o=s.format||(i?e2.toPosixSlashes:null),a=t===r,c=a&&o?o(t):t;return a===!1&&(c=o?o(t):t,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=ur.matchBase(t,e,n,i):a=e.exec(c)),{isMatch:!!a,match:a,output:c}};ur.matchBase=(t,e,n,r=e2.isWindows(n))=>(e instanceof RegExp?e:ur.makeRe(e,n)).test(T3e.basename(t));ur.isMatch=(t,e,n)=>ur(e,n)(t);ur.parse=(t,e)=>Array.isArray(t)?t.map(n=>ur.parse(n,e)):Zq(t,{...e,fastpaths:!1});ur.scan=(t,e)=>A3e(t,e);ur.compileRe=(t,e,n=!1,r=!1)=>{if(n===!0)return t.output;let i=e||{},s=i.contains?"":"^",o=i.contains?"":"$",a=`${s}(?:${t.output})${o}`;t&&t.negated===!0&&(a=`^(?!${a}).*$`);let c=ur.toRegex(a,e);return r===!0&&(c.state=t),c};ur.makeRe=(t,e={},n=!1,r=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let i={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(i.output=Zq.fastpaths(t,e)),i.output||(i=Zq(t,e)),ur.compileRe(i,e,n,r)};ur.toRegex=(t,e)=>{try{let n=e||{};return new RegExp(t,n.flags||(n.nocase?"i":""))}catch(n){if(e&&e.debug===!0)throw n;return/$^/}};ur.constants=C3e;_le.exports=ur});var t2=B((fAt,Ele)=>{"use strict";Ele.exports=vle()});var Rle=B((dAt,Cle)=>{"use strict";var jE=require("fs"),{Readable:I3e}=require("stream"),HE=require("path"),{promisify:TR}=require("util"),n2=t2(),k3e=TR(jE.readdir),P3e=TR(jE.stat),wle=TR(jE.lstat),O3e=TR(jE.realpath),M3e="!",Tle="READDIRP_RECURSIVE_ERROR",N3e=new Set(["ENOENT","EPERM","EACCES","ELOOP",Tle]),r2="files",Ale="directories",xR="files_directories",SR="all",Sle=[r2,Ale,xR,SR],D3e=t=>N3e.has(t.code),[xle,L3e]=process.versions.node.split(".").slice(0,2).map(t=>Number.parseInt(t,10)),U3e=process.platform==="win32"&&(xle>10||xle===10&&L3e>=5),ble=t=>{if(t!==void 0){if(typeof t=="function")return t;if(typeof t=="string"){let e=n2(t.trim());return n=>e(n.basename)}if(Array.isArray(t)){let e=[],n=[];for(let r of t){let i=r.trim();i.charAt(0)===M3e?n.push(n2(i.slice(1))):e.push(n2(i))}return n.length>0?e.length>0?r=>e.some(i=>i(r.basename))&&!n.some(i=>i(r.basename)):r=>!n.some(i=>i(r.basename)):r=>e.some(i=>i(r.basename))}}},bR=class t extends I3e{static get defaultOptions(){return{root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:r2,lstat:!1,depth:2147483648,alwaysStat:!1}}constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark||4096});let n={...t.defaultOptions,...e},{root:r,type:i}=n;this._fileFilter=ble(n.fileFilter),this._directoryFilter=ble(n.directoryFilter);let s=n.lstat?wle:P3e;U3e?this._stat=o=>s(o,{bigint:!0}):this._stat=s,this._maxDepth=n.depth,this._wantsDir=[Ale,xR,SR].includes(i),this._wantsFile=[r2,xR,SR].includes(i),this._wantsEverything=i===SR,this._root=HE.resolve(r),this._isDirent="Dirent"in jE&&!n.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(r,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let{path:n,depth:r,files:i=[]}=this.parent||{};if(i.length>0){let s=i.splice(0,e).map(o=>this._formatEntry(o,n));for(let o of await Promise.all(s)){if(this.destroyed)return;let a=await this._getEntryType(o);a==="directory"&&this._directoryFilter(o)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(o.fullPath,r+1)),this._wantsDir&&(this.push(o),e--)):(a==="file"||this._includeAsFile(o))&&this._fileFilter(o)&&this._wantsFile&&(this.push(o),e--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(n){this.destroy(n)}finally{this.reading=!1}}}async _exploreDir(e,n){let r;try{r=await k3e(e,this._rdOptions)}catch(i){this._onError(i)}return{files:r,depth:n,path:e}}async _formatEntry(e,n){let r;try{let i=this._isDirent?e.name:e,s=HE.resolve(HE.join(n,i));r={path:HE.relative(this._root,s),fullPath:s,basename:i},r[this._statsProp]=this._isDirent?e:await this._stat(s)}catch(i){this._onError(i)}return r}_onError(e){D3e(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){let n=e&&e[this._statsProp];if(n){if(n.isFile())return"file";if(n.isDirectory())return"directory";if(n&&n.isSymbolicLink()){let r=e.fullPath;try{let i=await O3e(r),s=await wle(i);if(s.isFile())return"file";if(s.isDirectory()){let o=i.length;if(r.startsWith(i)&&r.substr(o,1)===HE.sep){let a=new Error(`Circular symlink detected: "${r}" points to "${i}"`);return a.code=Tle,this._onError(a)}return"directory"}}catch(i){this._onError(i)}}}}_includeAsFile(e){let n=e&&e[this._statsProp];return n&&this._wantsEverything&&!n.isDirectory()}},By=(t,e={})=>{let n=e.entryType||e.type;if(n==="both"&&(n=xR),n&&(e.type=n),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(n&&!Sle.includes(n))throw new Error(`readdirp: Invalid type passed. Use one of ${Sle.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new bR(e)},F3e=(t,e={})=>new Promise((n,r)=>{let i=[];By(t,e).on("data",s=>i.push(s)).on("end",()=>n(i)).on("error",s=>r(s))});By.promise=F3e;By.ReaddirpStream=bR;By.default=By;Cle.exports=By});var qy=B((pAt,Ile)=>{Ile.exports=function(t,e){if(typeof t!="string")throw new TypeError("expected path to be a string");if(t==="\\"||t==="/")return"/";var n=t.length;if(n<=1)return t;var r="";if(n>4&&t[3]==="\\"){var i=t[2];(i==="?"||i===".")&&t.slice(0,2)==="\\\\"&&(t=t.slice(2),r="//")}var s=t.split(/[/\\]+/);return e!==!1&&s[s.length-1]===""&&s.pop(),r+s.join("/")}});var Dle=B((Mle,Nle)=>{"use strict";Object.defineProperty(Mle,"__esModule",{value:!0});var Ole=t2(),B3e=qy(),kle="!",q3e={returnIndex:!1},$3e=t=>Array.isArray(t)?t:[t],G3e=(t,e)=>{if(typeof t=="function")return t;if(typeof t=="string"){let n=Ole(t,e);return r=>t===r||n(r)}return t instanceof RegExp?n=>t.test(n):n=>!1},Ple=(t,e,n,r)=>{let i=Array.isArray(n),s=i?n[0]:n;if(!i&&typeof s!="string")throw new TypeError("anymatch: second argument must be a string: got "+Object.prototype.toString.call(s));let o=B3e(s,!1);for(let c=0;c<e.length;c++){let l=e[c];if(l(o))return r?-1:!1}let a=i&&[o].concat(n.slice(1));for(let c=0;c<t.length;c++){let l=t[c];if(i?l(...a):l(o))return r?c:!0}return r?-1:!1},i2=(t,e,n=q3e)=>{if(t==null)throw new TypeError("anymatch: specify first argument");let r=typeof n=="boolean"?{returnIndex:n}:n,i=r.returnIndex||!1,s=$3e(t),o=s.filter(c=>typeof c=="string"&&c.charAt(0)===kle).map(c=>c.slice(1)).map(c=>Ole(c,r)),a=s.filter(c=>typeof c!="string"||typeof c=="string"&&c.charAt(0)!==kle).map(c=>G3e(c,r));return e==null?(c,l=!1)=>Ple(a,o,c,typeof l=="boolean"?l:!1):Ple(a,o,e,i)};i2.default=i2;Nle.exports=i2});var Ule=B((hAt,Lle)=>{Lle.exports=function(e){if(typeof e!="string"||e==="")return!1;for(var n;n=/(\\).|([@?!+*]\(.*\))/g.exec(e);){if(n[2])return!0;e=e.slice(n.index+n[0].length)}return!1}});var s2=B((mAt,Ble)=>{var H3e=Ule(),Fle={"{":"}","(":")","[":"]"},j3e=function(t){if(t[0]==="!")return!0;for(var e=0,n=-2,r=-2,i=-2,s=-2,o=-2;e<t.length;){if(t[e]==="*"||t[e+1]==="?"&&/[\].+)]/.test(t[e])||r!==-1&&t[e]==="["&&t[e+1]!=="]"&&(r<e&&(r=t.indexOf("]",e)),r>e&&(o===-1||o>r||(o=t.indexOf("\\",e),o===-1||o>r)))||i!==-1&&t[e]==="{"&&t[e+1]!=="}"&&(i=t.indexOf("}",e),i>e&&(o=t.indexOf("\\",e),o===-1||o>i))||s!==-1&&t[e]==="("&&t[e+1]==="?"&&/[:!=]/.test(t[e+2])&&t[e+3]!==")"&&(s=t.indexOf(")",e),s>e&&(o=t.indexOf("\\",e),o===-1||o>s))||n!==-1&&t[e]==="("&&t[e+1]!=="|"&&(n<e&&(n=t.indexOf("|",e)),n!==-1&&t[n+1]!==")"&&(s=t.indexOf(")",n),s>n&&(o=t.indexOf("\\",n),o===-1||o>s))))return!0;if(t[e]==="\\"){var a=t[e+1];e+=2;var c=Fle[a];if(c){var l=t.indexOf(c,e);l!==-1&&(e=l+1)}if(t[e]==="!")return!0}else e++}return!1},W3e=function(t){if(t[0]==="!")return!0;for(var e=0;e<t.length;){if(/[*?{}()[\]]/.test(t[e]))return!0;if(t[e]==="\\"){var n=t[e+1];e+=2;var r=Fle[n];if(r){var i=t.indexOf(r,e);i!==-1&&(e=i+1)}if(t[e]==="!")return!0}else e++}return!1};Ble.exports=function(e,n){if(typeof e!="string"||e==="")return!1;if(H3e(e))return!0;var r=j3e;return n&&n.strict===!1&&(r=W3e),r(e)}});var $le=B((gAt,qle)=>{"use strict";var V3e=s2(),z3e=require("path").posix.dirname,K3e=require("os").platform()==="win32",o2="/",Y3e=/\\/g,X3e=/[\{\[].*[\}\]]$/,J3e=/(^|[^\\])([\{\[]|\([^\)]+$)/,Q3e=/\\([\!\*\?\|\[\]\(\)\{\}])/g;qle.exports=function(e,n){var r=Object.assign({flipBackslashes:!0},n);r.flipBackslashes&&K3e&&e.indexOf(o2)<0&&(e=e.replace(Y3e,o2)),X3e.test(e)&&(e+=o2),e+="a";do e=z3e(e);while(V3e(e)||J3e.test(e));return e.replace(Q3e,"$1")}});var AR=B(Uo=>{"use strict";Uo.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1;Uo.find=(t,e)=>t.nodes.find(n=>n.type===e);Uo.exceedsLimit=(t,e,n=1,r)=>r===!1||!Uo.isInteger(t)||!Uo.isInteger(e)?!1:(Number(e)-Number(t))/Number(n)>=r;Uo.escapeNode=(t,e=0,n)=>{let r=t.nodes[e];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Uo.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1;Uo.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1;Uo.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0;Uo.reduce=t=>t.reduce((e,n)=>(n.type==="text"&&e.push(n.value),n.type==="range"&&(n.type="text"),e),[]);Uo.flatten=(...t)=>{let e=[],n=r=>{for(let i=0;i<r.length;i++){let s=r[i];if(Array.isArray(s)){n(s);continue}s!==void 0&&e.push(s)}return e};return n(t),e}});var CR=B((_At,Hle)=>{"use strict";var Gle=AR();Hle.exports=(t,e={})=>{let n=(r,i={})=>{let s=e.escapeInvalid&&Gle.isInvalidBrace(i),o=r.invalid===!0&&e.escapeInvalid===!0,a="";if(r.value)return(s||o)&&Gle.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(t)}});var Wle=B((vAt,jle)=>{"use strict";jle.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var eue=B((EAt,Zle)=>{"use strict";var Vle=Wle(),Eh=(t,e,n)=>{if(Vle(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(Vle(e)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let i=String(r.relaxZeros),s=String(r.shorthand),o=String(r.capture),a=String(r.wrap),c=t+":"+e+"="+i+s+o+a;if(Eh.cache.hasOwnProperty(c))return Eh.cache[c].result;let l=Math.min(t,e),u=Math.max(t,e);if(Math.abs(l-u)===1){let y=t+"|"+e;return r.capture?`(${y})`:r.wrap===!1?y:`(?:${y})`}let f=Qle(t)||Qle(e),p={min:t,max:e,a:l,b:u},m=[],g=[];if(f&&(p.isPadded=f,p.maxLen=String(p.max).length),l<0){let y=u<0?Math.abs(u):1;g=zle(y,Math.abs(l),p,r),l=p.a=0}return u>=0&&(m=zle(l,u,p,r)),p.negatives=g,p.positives=m,p.result=Z3e(g,m,r),r.capture===!0?p.result=`(${p.result})`:r.wrap!==!1&&m.length+g.length>1&&(p.result=`(?:${p.result})`),Eh.cache[c]=p,p.result};function Z3e(t,e,n){let r=a2(t,e,"-",!1,n)||[],i=a2(e,t,"",!1,n)||[],s=a2(t,e,"-?",!0,n)||[];return r.concat(s).concat(i).join("|")}function eWe(t,e){let n=1,r=1,i=Yle(t,n),s=new Set([e]);for(;t<=i&&i<=e;)s.add(i),n+=1,i=Yle(t,n);for(i=Xle(e+1,r)-1;t<i&&i<=e;)s.add(i),r+=1,i=Xle(e+1,r)-1;return s=[...s],s.sort(rWe),s}function tWe(t,e,n){if(t===e)return{pattern:t,count:[],digits:0};let r=nWe(t,e),i=r.length,s="",o=0;for(let a=0;a<i;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=iWe(c,l,n):o++}return o&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[o],digits:i}}function zle(t,e,n,r){let i=eWe(t,e),s=[],o=t,a;for(let c=0;c<i.length;c++){let l=i[c],u=tWe(String(o),String(l),r),f="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Jle(a.count),o=l+1;continue}n.isPadded&&(f=sWe(l,n,r)),u.string=f+u.pattern+Jle(u.count),s.push(u),o=l+1,a=u}return s}function a2(t,e,n,r,i){let s=[];for(let o of t){let{string:a}=o;!r&&!Kle(e,"string",a)&&s.push(n+a),r&&Kle(e,"string",a)&&s.push(n+a)}return s}function nWe(t,e){let n=[];for(let r=0;r<t.length;r++)n.push([t[r],e[r]]);return n}function rWe(t,e){return t>e?1:e>t?-1:0}function Kle(t,e,n){return t.some(r=>r[e]===n)}function Yle(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function Xle(t,e){return t-t%Math.pow(10,e)}function Jle(t){let[e=0,n=""]=t;return n||e>1?`{${e+(n?","+n:"")}}`:""}function iWe(t,e,n){return`[${t}${e-t===1?"":"-"}${e}]`}function Qle(t){return/^-?(0+)\d/.test(t)}function sWe(t,e,n){if(!e.isPadded)return t;let r=Math.abs(e.maxLen-String(t).length),i=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return i?"0?":"0";case 2:return i?"0{0,2}":"00";default:return i?`0{0,${r}}`:`0{${r}}`}}Eh.cache={};Eh.clearCache=()=>Eh.cache={};Zle.exports=Eh});var u2=B((wAt,aue)=>{"use strict";var oWe=require("util"),nue=eue(),tue=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),aWe=t=>e=>t===!0?Number(e):String(e),c2=t=>typeof t=="number"||typeof t=="string"&&t!=="",WE=t=>Number.isInteger(+t),l2=t=>{let e=`${t}`,n=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++n]==="0";);return n>0},cWe=(t,e,n)=>typeof t=="string"||typeof e=="string"?!0:n.stringify===!0,lWe=(t,e,n)=>{if(e>0){let r=t[0]==="-"?"-":"";r&&(t=t.slice(1)),t=r+t.padStart(r?e-1:e,"0")}return n===!1?String(t):t},IR=(t,e)=>{let n=t[0]==="-"?"-":"";for(n&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return n?"-"+t:t},uWe=(t,e,n)=>{t.negatives.sort((a,c)=>a<c?-1:a>c?1:0),t.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=e.capture?"":"?:",i="",s="",o;return t.positives.length&&(i=t.positives.map(a=>IR(String(a),n)).join("|")),t.negatives.length&&(s=`-(${r}${t.negatives.map(a=>IR(String(a),n)).join("|")})`),i&&s?o=`${i}|${s}`:o=i||s,e.wrap?`(${r}${o})`:o},rue=(t,e,n,r)=>{if(n)return nue(t,e,{wrap:!1,...r});let i=String.fromCharCode(t);if(t===e)return i;let s=String.fromCharCode(e);return`[${i}-${s}]`},iue=(t,e,n)=>{if(Array.isArray(t)){let r=n.wrap===!0,i=n.capture?"":"?:";return r?`(${i}${t.join("|")})`:t.join("|")}return nue(t,e,n)},sue=(...t)=>new RangeError("Invalid range arguments: "+oWe.inspect(...t)),oue=(t,e,n)=>{if(n.strictRanges===!0)throw sue([t,e]);return[]},fWe=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},dWe=(t,e,n=1,r={})=>{let i=Number(t),s=Number(e);if(!Number.isInteger(i)||!Number.isInteger(s)){if(r.strictRanges===!0)throw sue([t,e]);return[]}i===0&&(i=0),s===0&&(s=0);let o=i>s,a=String(t),c=String(e),l=String(n);n=Math.max(Math.abs(n),1);let u=l2(a)||l2(c)||l2(l),f=u?Math.max(a.length,c.length,l.length):0,p=u===!1&&cWe(t,e,r)===!1,m=r.transform||aWe(p);if(r.toRegex&&n===1)return rue(IR(t,f),IR(e,f),!0,r);let g={negatives:[],positives:[]},y=T=>g[T<0?"negatives":"positives"].push(Math.abs(T)),w=[],S=0;for(;o?i>=s:i<=s;)r.toRegex===!0&&n>1?y(i):w.push(lWe(m(i,S),f,p)),i=o?i-n:i+n,S++;return r.toRegex===!0?n>1?uWe(g,r,f):iue(w,null,{wrap:!1,...r}):w},pWe=(t,e,n=1,r={})=>{if(!WE(t)&&t.length>1||!WE(e)&&e.length>1)return oue(t,e,r);let i=r.transform||(p=>String.fromCharCode(p)),s=`${t}`.charCodeAt(0),o=`${e}`.charCodeAt(0),a=s>o,c=Math.min(s,o),l=Math.max(s,o);if(r.toRegex&&n===1)return rue(c,l,!1,r);let u=[],f=0;for(;a?s>=o:s<=o;)u.push(i(s,f)),s=a?s-n:s+n,f++;return r.toRegex===!0?iue(u,null,{wrap:!1,options:r}):u},RR=(t,e,n,r={})=>{if(e==null&&c2(t))return[t];if(!c2(t)||!c2(e))return oue(t,e,r);if(typeof n=="function")return RR(t,e,1,{transform:n});if(tue(n))return RR(t,e,0,n);let i={...r};return i.capture===!0&&(i.wrap=!0),n=n||i.step||1,WE(n)?WE(t)&&WE(e)?dWe(t,e,n,i):pWe(t,e,Math.max(Math.abs(n),1),i):n!=null&&!tue(n)?fWe(n,i):RR(t,e,1,n)};aue.exports=RR});var uue=B((SAt,lue)=>{"use strict";var hWe=u2(),cue=AR(),mWe=(t,e={})=>{let n=(r,i={})=>{let s=cue.isInvalidBrace(i),o=r.invalid===!0&&e.escapeInvalid===!0,a=s===!0||o===!0,c=e.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=cue.reduce(r.nodes),f=hWe(...u,{...e,wrap:!1,toRegex:!0,strictZeros:!0});if(f.length!==0)return u.length>1&&f.length>1?`(${f})`:f}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(t)};lue.exports=mWe});var pue=B((xAt,due)=>{"use strict";var gWe=u2(),fue=CR(),$y=AR(),wh=(t="",e="",n=!1)=>{let r=[];if(t=[].concat(t),e=[].concat(e),!e.length)return t;if(!t.length)return n?$y.flatten(e).map(i=>`{${i}}`):e;for(let i of t)if(Array.isArray(i))for(let s of i)r.push(wh(s,e,n));else for(let s of e)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?wh(i,s,n):i+s);return $y.flatten(r)},yWe=(t,e={})=>{let n=e.rangeLimit===void 0?1e3:e.rangeLimit,r=(i,s={})=>{i.queue=[];let o=s,a=s.queue;for(;o.type!=="brace"&&o.type!=="root"&&o.parent;)o=o.parent,a=o.queue;if(i.invalid||i.dollar){a.push(wh(a.pop(),fue(i,e)));return}if(i.type==="brace"&&i.invalid!==!0&&i.nodes.length===2){a.push(wh(a.pop(),["{}"]));return}if(i.nodes&&i.ranges>0){let f=$y.reduce(i.nodes);if($y.exceedsLimit(...f,e.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let p=gWe(...f,e);p.length===0&&(p=fue(i,e)),a.push(wh(a.pop(),p)),i.nodes=[];return}let c=$y.encloseBrace(i),l=i.queue,u=i;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let f=0;f<i.nodes.length;f++){let p=i.nodes[f];if(p.type==="comma"&&i.type==="brace"){f===1&&l.push(""),l.push("");continue}if(p.type==="close"){a.push(wh(a.pop(),l,c));continue}if(p.value&&p.type!=="open"){l.push(wh(l.pop(),p.value));continue}p.nodes&&r(p,i)}return l};return $y.flatten(r(t))};due.exports=yWe});var mue=B((bAt,hue)=>{"use strict";hue.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
394
394
|
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Eue=B((TAt,vue)=>{"use strict";var _We=CR(),{MAX_LENGTH:gue,CHAR_BACKSLASH:f2,CHAR_BACKTICK:vWe,CHAR_COMMA:EWe,CHAR_DOT:wWe,CHAR_LEFT_PARENTHESES:SWe,CHAR_RIGHT_PARENTHESES:xWe,CHAR_LEFT_CURLY_BRACE:bWe,CHAR_RIGHT_CURLY_BRACE:TWe,CHAR_LEFT_SQUARE_BRACKET:yue,CHAR_RIGHT_SQUARE_BRACKET:_ue,CHAR_DOUBLE_QUOTE:AWe,CHAR_SINGLE_QUOTE:CWe,CHAR_NO_BREAK_SPACE:RWe,CHAR_ZERO_WIDTH_NOBREAK_SPACE:IWe}=mue(),kWe=(t,e={})=>{if(typeof t!="string")throw new TypeError("Expected a string");let n=e||{},r=typeof n.maxLength=="number"?Math.min(gue,n.maxLength):gue;if(t.length>r)throw new SyntaxError(`Input length (${t.length}), exceeds max characters (${r})`);let i={type:"root",input:t,nodes:[]},s=[i],o=i,a=i,c=0,l=t.length,u=0,f=0,p,m=()=>t[u++],g=y=>{if(y.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&y.type==="text"){a.value+=y.value;return}return o.nodes.push(y),y.parent=o,y.prev=a,a=y,y};for(g({type:"bos"});u<l;)if(o=s[s.length-1],p=m(),!(p===IWe||p===RWe)){if(p===f2){g({type:"text",value:(e.keepEscaping?p:"")+m()});continue}if(p===_ue){g({type:"text",value:"\\"+p});continue}if(p===yue){c++;let y;for(;u<l&&(y=m());){if(p+=y,y===yue){c++;continue}if(y===f2){p+=m();continue}if(y===_ue&&(c--,c===0))break}g({type:"text",value:p});continue}if(p===SWe){o=g({type:"paren",nodes:[]}),s.push(o),g({type:"text",value:p});continue}if(p===xWe){if(o.type!=="paren"){g({type:"text",value:p});continue}o=s.pop(),g({type:"text",value:p}),o=s[s.length-1];continue}if(p===AWe||p===CWe||p===vWe){let y=p,w;for(e.keepQuotes!==!0&&(p="");u<l&&(w=m());){if(w===f2){p+=w+m();continue}if(w===y){e.keepQuotes===!0&&(p+=w);break}p+=w}g({type:"text",value:p});continue}if(p===bWe){f++;let w={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||o.dollar===!0,depth:f,commas:0,ranges:0,nodes:[]};o=g(w),s.push(o),g({type:"open",value:p});continue}if(p===TWe){if(o.type!=="brace"){g({type:"text",value:p});continue}let y="close";o=s.pop(),o.close=!0,g({type:y,value:p}),f--,o=s[s.length-1];continue}if(p===EWe&&f>0){if(o.ranges>0){o.ranges=0;let y=o.nodes.shift();o.nodes=[y,{type:"text",value:_We(o)}]}g({type:"comma",value:p}),o.commas++;continue}if(p===wWe&&f>0&&o.commas===0){let y=o.nodes;if(f===0||y.length===0){g({type:"text",value:p});continue}if(a.type==="dot"){if(o.range=[],a.value+=p,a.type="range",o.nodes.length!==3&&o.nodes.length!==5){o.invalid=!0,o.ranges=0,a.type="text";continue}o.ranges++,o.args=[];continue}if(a.type==="range"){y.pop();let w=y[y.length-1];w.value+=a.value+p,a=w,o.ranges--;continue}g({type:"dot",value:p});continue}g({type:"text",value:p})}do if(o=s.pop(),o.type!=="root"){o.nodes.forEach(S=>{S.nodes||(S.type==="open"&&(S.isOpen=!0),S.type==="close"&&(S.isClose=!0),S.nodes||(S.type="text"),S.invalid=!0)});let y=s[s.length-1],w=y.nodes.indexOf(o);y.nodes.splice(w,1,...o.nodes)}while(s.length>0);return g({type:"eos"}),i};vue.exports=kWe});var xue=B((AAt,Sue)=>{"use strict";var wue=CR(),PWe=uue(),OWe=pue(),MWe=Eue(),Bs=(t,e={})=>{let n=[];if(Array.isArray(t))for(let r of t){let i=Bs.create(r,e);Array.isArray(i)?n.push(...i):n.push(i)}else n=[].concat(Bs.create(t,e));return e&&e.expand===!0&&e.nodupes===!0&&(n=[...new Set(n)]),n};Bs.parse=(t,e={})=>MWe(t,e);Bs.stringify=(t,e={})=>wue(typeof t=="string"?Bs.parse(t,e):t,e);Bs.compile=(t,e={})=>(typeof t=="string"&&(t=Bs.parse(t,e)),PWe(t,e));Bs.expand=(t,e={})=>{typeof t=="string"&&(t=Bs.parse(t,e));let n=OWe(t,e);return e.noempty===!0&&(n=n.filter(Boolean)),e.nodupes===!0&&(n=[...new Set(n)]),n};Bs.create=(t,e={})=>t===""||t.length<3?[t]:e.expand!==!0?Bs.compile(t,e):Bs.expand(t,e);Sue.exports=Bs});var bue=B((CAt,NWe)=>{NWe.exports=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]});var Aue=B((RAt,Tue)=>{Tue.exports=bue()});var Rue=B((IAt,Cue)=>{"use strict";var DWe=require("path"),LWe=Aue(),UWe=new Set(LWe);Cue.exports=t=>UWe.has(DWe.extname(t).slice(1).toLowerCase())});var kR=B(qe=>{"use strict";var{sep:FWe}=require("path"),{platform:d2}=process,BWe=require("os");qe.EV_ALL="all";qe.EV_READY="ready";qe.EV_ADD="add";qe.EV_CHANGE="change";qe.EV_ADD_DIR="addDir";qe.EV_UNLINK="unlink";qe.EV_UNLINK_DIR="unlinkDir";qe.EV_RAW="raw";qe.EV_ERROR="error";qe.STR_DATA="data";qe.STR_END="end";qe.STR_CLOSE="close";qe.FSEVENT_CREATED="created";qe.FSEVENT_MODIFIED="modified";qe.FSEVENT_DELETED="deleted";qe.FSEVENT_MOVED="moved";qe.FSEVENT_CLONED="cloned";qe.FSEVENT_UNKNOWN="unknown";qe.FSEVENT_FLAG_MUST_SCAN_SUBDIRS=1;qe.FSEVENT_TYPE_FILE="file";qe.FSEVENT_TYPE_DIRECTORY="directory";qe.FSEVENT_TYPE_SYMLINK="symlink";qe.KEY_LISTENERS="listeners";qe.KEY_ERR="errHandlers";qe.KEY_RAW="rawEmitters";qe.HANDLER_KEYS=[qe.KEY_LISTENERS,qe.KEY_ERR,qe.KEY_RAW];qe.DOT_SLASH=`.${FWe}`;qe.BACK_SLASH_RE=/\\/g;qe.DOUBLE_SLASH_RE=/\/\//;qe.SLASH_OR_BACK_SLASH_RE=/[/\\]/;qe.DOT_RE=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/;qe.REPLACER_RE=/^\.[/\\]/;qe.SLASH="/";qe.SLASH_SLASH="//";qe.BRACE_START="{";qe.BANG="!";qe.ONE_DOT=".";qe.TWO_DOTS="..";qe.STAR="*";qe.GLOBSTAR="**";qe.ROOT_GLOBSTAR="/**/*";qe.SLASH_GLOBSTAR="/**";qe.DIR_SUFFIX="Dir";qe.ANYMATCH_OPTS={dot:!0};qe.STRING_TYPE="string";qe.FUNCTION_TYPE="function";qe.EMPTY_STR="";qe.EMPTY_FN=()=>{};qe.IDENTITY_FN=t=>t;qe.isWindows=d2==="win32";qe.isMacos=d2==="darwin";qe.isLinux=d2==="linux";qe.isIBMi=BWe.type()==="OS400"});var Nue=B((PAt,Mue)=>{"use strict";var uu=require("fs"),Gr=require("path"),{promisify:YE}=require("util"),qWe=Rue(),{isWindows:$We,isLinux:GWe,EMPTY_FN:HWe,EMPTY_STR:jWe,KEY_LISTENERS:Gy,KEY_ERR:p2,KEY_RAW:VE,HANDLER_KEYS:WWe,EV_CHANGE:OR,EV_ADD:PR,EV_ADD_DIR:VWe,EV_ERROR:kue,STR_DATA:zWe,STR_END:KWe,BRACE_START:YWe,STAR:XWe}=kR(),JWe="watch",QWe=YE(uu.open),Pue=YE(uu.stat),ZWe=YE(uu.lstat),e6e=YE(uu.close),h2=YE(uu.realpath),t6e={lstat:ZWe,stat:Pue},g2=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},zE=(t,e,n)=>{let r=t[e];r instanceof Set||(t[e]=r=new Set([r])),r.add(n)},n6e=t=>e=>{let n=t[e];n instanceof Set?n.clear():delete t[e]},KE=(t,e,n)=>{let r=t[e];r instanceof Set?r.delete(n):r===n&&delete t[e]},Oue=t=>t instanceof Set?t.size===0:!t,MR=new Map;function Iue(t,e,n,r,i){let s=(o,a)=>{n(t),i(o,a,{watchedPath:t}),a&&t!==a&&NR(Gr.resolve(t,a),Gy,Gr.join(t,a))};try{return uu.watch(t,e,s)}catch(o){r(o)}}var NR=(t,e,n,r,i)=>{let s=MR.get(t);s&&g2(s[e],o=>{o(n,r,i)})},r6e=(t,e,n,r)=>{let{listener:i,errHandler:s,rawEmitter:o}=r,a=MR.get(e),c;if(!n.persistent)return c=Iue(t,n,i,s,o),c.close.bind(c);if(a)zE(a,Gy,i),zE(a,p2,s),zE(a,VE,o);else{if(c=Iue(t,n,NR.bind(null,e,Gy),s,NR.bind(null,e,VE)),!c)return;c.on(kue,async l=>{let u=NR.bind(null,e,p2);if(a.watcherUnusable=!0,$We&&l.code==="EPERM")try{let f=await QWe(t,"r");await e6e(f),u(l)}catch{}else u(l)}),a={listeners:i,errHandlers:s,rawEmitters:o,watcher:c},MR.set(e,a)}return()=>{KE(a,Gy,i),KE(a,p2,s),KE(a,VE,o),Oue(a.listeners)&&(a.watcher.close(),MR.delete(e),WWe.forEach(n6e(a)),a.watcher=void 0,Object.freeze(a))}},m2=new Map,i6e=(t,e,n,r)=>{let{listener:i,rawEmitter:s}=r,o=m2.get(e),a=new Set,c=new Set,l=o&&o.options;return l&&(l.persistent<n.persistent||l.interval>n.interval)&&(a=o.listeners,c=o.rawEmitters,uu.unwatchFile(e),o=void 0),o?(zE(o,Gy,i),zE(o,VE,s)):(o={listeners:i,rawEmitters:s,options:n,watcher:uu.watchFile(e,n,(u,f)=>{g2(o.rawEmitters,m=>{m(OR,e,{curr:u,prev:f})});let p=u.mtimeMs;(u.size!==f.size||p>f.mtimeMs||p===0)&&g2(o.listeners,m=>m(t,u))})},m2.set(e,o)),()=>{KE(o,Gy,i),KE(o,VE,s),Oue(o.listeners)&&(m2.delete(e),uu.unwatchFile(e),o.options=o.watcher=void 0,Object.freeze(o))}},y2=class{constructor(e){this.fsw=e,this._boundHandleError=n=>e._handleError(n)}_watchWithNodeFs(e,n){let r=this.fsw.options,i=Gr.dirname(e),s=Gr.basename(e);this.fsw._getWatchedDir(i).add(s);let a=Gr.resolve(e),c={persistent:r.persistent};n||(n=HWe);let l;return r.usePolling?(c.interval=r.enableBinaryInterval&&qWe(s)?r.binaryInterval:r.interval,l=i6e(e,a,c,{listener:n,rawEmitter:this.fsw._emitRaw})):l=r6e(e,a,c,{listener:n,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),l}_handleFile(e,n,r){if(this.fsw.closed)return;let i=Gr.dirname(e),s=Gr.basename(e),o=this.fsw._getWatchedDir(i),a=n;if(o.has(s))return;let c=async(u,f)=>{if(this.fsw._throttle(JWe,e,5)){if(!f||f.mtimeMs===0)try{let p=await Pue(e);if(this.fsw.closed)return;let m=p.atimeMs,g=p.mtimeMs;(!m||m<=g||g!==a.mtimeMs)&&this.fsw._emit(OR,e,p),GWe&&a.ino!==p.ino?(this.fsw._closeFile(u),a=p,this.fsw._addPathCloser(u,this._watchWithNodeFs(e,c))):a=p}catch{this.fsw._remove(i,s)}else if(o.has(s)){let p=f.atimeMs,m=f.mtimeMs;(!p||p<=m||m!==a.mtimeMs)&&this.fsw._emit(OR,e,f),a=f}}},l=this._watchWithNodeFs(e,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(PR,e,0))return;this.fsw._emit(PR,e,n)}return l}async _handleSymlink(e,n,r,i){if(this.fsw.closed)return;let s=e.fullPath,o=this.fsw._getWatchedDir(n);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let a;try{a=await h2(r)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(o.has(i)?this.fsw._symlinkPaths.get(s)!==a&&(this.fsw._symlinkPaths.set(s,a),this.fsw._emit(OR,r,e.stats)):(o.add(i),this.fsw._symlinkPaths.set(s,a),this.fsw._emit(PR,r,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(s))return!0;this.fsw._symlinkPaths.set(s,!0)}_handleRead(e,n,r,i,s,o,a){if(e=Gr.join(e,jWe),!r.hasGlob&&(a=this.fsw._throttle("readdir",e,1e3),!a))return;let c=this.fsw._getWatchedDir(r.path),l=new Set,u=this.fsw._readdirp(e,{fileFilter:f=>r.filterPath(f),directoryFilter:f=>r.filterDir(f),depth:0}).on(zWe,async f=>{if(this.fsw.closed){u=void 0;return}let p=f.path,m=Gr.join(e,p);if(l.add(p),!(f.stats.isSymbolicLink()&&await this._handleSymlink(f,e,m,p))){if(this.fsw.closed){u=void 0;return}(p===i||!i&&!c.has(p))&&(this.fsw._incrReadyCount(),m=Gr.join(s,Gr.relative(s,m)),this._addToNodeFs(m,n,r,o+1))}}).on(kue,this._boundHandleError);return new Promise(f=>u.once(KWe,()=>{if(this.fsw.closed){u=void 0;return}let p=a?a.clear():!1;f(),c.getChildren().filter(m=>m!==e&&!l.has(m)&&(!r.hasGlob||r.filterPath({fullPath:Gr.resolve(e,m)}))).forEach(m=>{this.fsw._remove(e,m)}),u=void 0,p&&this._handleRead(e,!1,r,i,s,o,a)}))}async _handleDir(e,n,r,i,s,o,a){let c=this.fsw._getWatchedDir(Gr.dirname(e)),l=c.has(Gr.basename(e));!(r&&this.fsw.options.ignoreInitial)&&!s&&!l&&(!o.hasGlob||o.globFilter(e))&&this.fsw._emit(VWe,e,n),c.add(Gr.basename(e)),this.fsw._getWatchedDir(e);let u,f,p=this.fsw.options.depth;if((p==null||i<=p)&&!this.fsw._symlinkPaths.has(a)){if(!s&&(await this._handleRead(e,r,o,s,e,i,u),this.fsw.closed))return;f=this._watchWithNodeFs(e,(m,g)=>{g&&g.mtimeMs===0||this._handleRead(m,!1,o,s,e,i,u)})}return f}async _addToNodeFs(e,n,r,i,s){let o=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return o(),!1;let a=this.fsw._getWatchHelpers(e,i);!a.hasGlob&&r&&(a.hasGlob=r.hasGlob,a.globFilter=r.globFilter,a.filterPath=c=>r.filterPath(c),a.filterDir=c=>r.filterDir(c));try{let c=await t6e[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,c))return o(),!1;let l=this.fsw.options.followSymlinks&&!e.includes(XWe)&&!e.includes(YWe),u;if(c.isDirectory()){let f=Gr.resolve(e),p=l?await h2(e):e;if(this.fsw.closed||(u=await this._handleDir(a.watchPath,c,n,i,s,a,p),this.fsw.closed))return;f!==p&&p!==void 0&&this.fsw._symlinkPaths.set(f,p)}else if(c.isSymbolicLink()){let f=l?await h2(e):e;if(this.fsw.closed)return;let p=Gr.dirname(a.watchPath);if(this.fsw._getWatchedDir(p).add(a.watchPath),this.fsw._emit(PR,a.watchPath,c),u=await this._handleDir(p,c,n,i,e,a,f),this.fsw.closed)return;f!==void 0&&this.fsw._symlinkPaths.set(Gr.resolve(e),f)}else u=this._handleFile(a.watchPath,c,n);return o(),this.fsw._addPathCloser(e,u),!1}catch(c){if(this.fsw._handleError(c))return o(),e}}};Mue.exports=y2});var $ue=B((OAt,T2)=>{"use strict";var x2=require("fs"),Hr=require("path"),{promisify:b2}=require("util"),Hy;try{Hy=require("fsevents")}catch(t){process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR&&console.error(t)}if(Hy){let t=process.version.match(/v(\d+)\.(\d+)/);if(t&&t[1]&&t[2]){let e=Number.parseInt(t[1],10),n=Number.parseInt(t[2],10);e===8&&n<16&&(Hy=void 0)}}var{EV_ADD:_2,EV_CHANGE:s6e,EV_ADD_DIR:Due,EV_UNLINK:DR,EV_ERROR:o6e,STR_DATA:a6e,STR_END:c6e,FSEVENT_CREATED:l6e,FSEVENT_MODIFIED:u6e,FSEVENT_DELETED:f6e,FSEVENT_MOVED:d6e,FSEVENT_UNKNOWN:p6e,FSEVENT_FLAG_MUST_SCAN_SUBDIRS:h6e,FSEVENT_TYPE_FILE:m6e,FSEVENT_TYPE_DIRECTORY:XE,FSEVENT_TYPE_SYMLINK:que,ROOT_GLOBSTAR:Lue,DIR_SUFFIX:g6e,DOT_SLASH:Uue,FUNCTION_TYPE:v2,EMPTY_FN:y6e,IDENTITY_FN:_6e}=kR(),v6e=t=>isNaN(t)?{}:{depth:t},w2=b2(x2.stat),E6e=b2(x2.lstat),Fue=b2(x2.realpath),w6e={stat:w2,lstat:E6e},Sh=new Map,S6e=10,x6e=new Set([69888,70400,71424,72704,73472,131328,131840,262912]),b6e=(t,e)=>({stop:Hy.watch(t,e)});function T6e(t,e,n,r){let i=Hr.extname(e)?Hr.dirname(e):e,s=Hr.dirname(i),o=Sh.get(i);A6e(s)&&(i=s);let a=Hr.resolve(t),c=a!==e,l=(f,p,m)=>{c&&(f=f.replace(e,a)),(f===a||!f.indexOf(a+Hr.sep))&&n(f,p,m)},u=!1;for(let f of Sh.keys())if(e.indexOf(Hr.resolve(f)+Hr.sep)===0){i=f,o=Sh.get(i),u=!0;break}return o||u?o.listeners.add(l):(o={listeners:new Set([l]),rawEmitter:r,watcher:b6e(i,(f,p)=>{if(!o.listeners.size||p&h6e)return;let m=Hy.getInfo(f,p);o.listeners.forEach(g=>{g(f,p,m)}),o.rawEmitter(m.event,f,m)})},Sh.set(i,o)),()=>{let f=o.listeners;if(f.delete(l),!f.size&&(Sh.delete(i),o.watcher))return o.watcher.stop().then(()=>{o.rawEmitter=o.watcher=void 0,Object.freeze(o)})}}var A6e=t=>{let e=0;for(let n of Sh.keys())if(n.indexOf(t)===0&&(e++,e>=S6e))return!0;return!1},C6e=()=>Hy&&Sh.size<128,E2=(t,e)=>{let n=0;for(;!t.indexOf(e)&&(t=Hr.dirname(t))!==e;)n++;return n},Bue=(t,e)=>t.type===XE&&e.isDirectory()||t.type===que&&e.isSymbolicLink()||t.type===m6e&&e.isFile(),S2=class{constructor(e){this.fsw=e}checkIgnored(e,n){let r=this.fsw._ignoredPaths;if(this.fsw._isIgnored(e,n))return r.add(e),n&&n.isDirectory()&&r.add(e+Lue),!0;r.delete(e),r.delete(e+Lue)}addOrChange(e,n,r,i,s,o,a,c){let l=s.has(o)?s6e:_2;this.handleEvent(l,e,n,r,i,s,o,a,c)}async checkExists(e,n,r,i,s,o,a,c){try{let l=await w2(e);if(this.fsw.closed)return;Bue(a,l)?this.addOrChange(e,n,r,i,s,o,a,c):this.handleEvent(DR,e,n,r,i,s,o,a,c)}catch(l){l.code==="EACCES"?this.addOrChange(e,n,r,i,s,o,a,c):this.handleEvent(DR,e,n,r,i,s,o,a,c)}}handleEvent(e,n,r,i,s,o,a,c,l){if(!(this.fsw.closed||this.checkIgnored(n)))if(e===DR){let u=c.type===XE;(u||o.has(a))&&this.fsw._remove(s,a,u)}else{if(e===_2){if(c.type===XE&&this.fsw._getWatchedDir(n),c.type===que&&l.followSymlinks){let f=l.depth===void 0?void 0:E2(r,i)+1;return this._addToFsEvents(n,!1,!0,f)}this.fsw._getWatchedDir(s).add(a)}let u=c.type===XE?e+g6e:e;this.fsw._emit(u,n),u===Due&&this._addToFsEvents(n,!1,!0)}}_watchWithFsEvents(e,n,r,i){if(this.fsw.closed||this.fsw._isIgnored(e))return;let s=this.fsw.options,a=T6e(e,n,async(c,l,u)=>{if(this.fsw.closed||s.depth!==void 0&&E2(c,n)>s.depth)return;let f=r(Hr.join(e,Hr.relative(e,c)));if(i&&!i(f))return;let p=Hr.dirname(f),m=Hr.basename(f),g=this.fsw._getWatchedDir(u.type===XE?f:p);if(x6e.has(l)||u.event===p6e)if(typeof s.ignored===v2){let y;try{y=await w2(f)}catch{}if(this.fsw.closed||this.checkIgnored(f,y))return;Bue(u,y)?this.addOrChange(f,c,n,p,g,m,u,s):this.handleEvent(DR,f,c,n,p,g,m,u,s)}else this.checkExists(f,c,n,p,g,m,u,s);else switch(u.event){case l6e:case u6e:return this.addOrChange(f,c,n,p,g,m,u,s);case f6e:case d6e:return this.checkExists(f,c,n,p,g,m,u,s)}},this.fsw._emitRaw);return this.fsw._emitReady(),a}async _handleFsEventsSymlink(e,n,r,i){if(!(this.fsw.closed||this.fsw._symlinkPaths.has(n))){this.fsw._symlinkPaths.set(n,!0),this.fsw._incrReadyCount();try{let s=await Fue(e);if(this.fsw.closed)return;if(this.fsw._isIgnored(s))return this.fsw._emitReady();this.fsw._incrReadyCount(),this._addToFsEvents(s||e,o=>{let a=e;return s&&s!==Uue?a=o.replace(s,e):o!==Uue&&(a=Hr.join(e,o)),r(a)},!1,i)}catch(s){if(this.fsw._handleError(s))return this.fsw._emitReady()}}}emitAdd(e,n,r,i,s){let o=r(e),a=n.isDirectory(),c=this.fsw._getWatchedDir(Hr.dirname(o)),l=Hr.basename(o);a&&this.fsw._getWatchedDir(o),!c.has(l)&&(c.add(l),(!i.ignoreInitial||s===!0)&&this.fsw._emit(a?Due:_2,o,n))}initWatch(e,n,r,i){if(this.fsw.closed)return;let s=this._watchWithFsEvents(r.watchPath,Hr.resolve(e||r.watchPath),i,r.globFilter);this.fsw._addPathCloser(n,s)}async _addToFsEvents(e,n,r,i){if(this.fsw.closed)return;let s=this.fsw.options,o=typeof n===v2?n:_6e,a=this.fsw._getWatchHelpers(e);try{let c=await w6e[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,c))throw null;if(c.isDirectory()){if(a.globFilter||this.emitAdd(o(e),c,o,s,r),i&&i>s.depth)return;this.fsw._readdirp(a.watchPath,{fileFilter:l=>a.filterPath(l),directoryFilter:l=>a.filterDir(l),...v6e(s.depth-(i||0))}).on(a6e,l=>{if(this.fsw.closed||l.stats.isDirectory()&&!a.filterPath(l))return;let u=Hr.join(a.watchPath,l.path),{fullPath:f}=l;if(a.followSymlinks&&l.stats.isSymbolicLink()){let p=s.depth===void 0?void 0:E2(u,Hr.resolve(a.watchPath))+1;this._handleFsEventsSymlink(u,f,o,p)}else this.emitAdd(u,l.stats,o,s,r)}).on(o6e,y6e).on(c6e,()=>{this.fsw._emitReady()})}else this.emitAdd(a.watchPath,c,o,s,r),this.fsw._emitReady()}catch(c){(!c||this.fsw._handleError(c))&&(this.fsw._emitReady(),this.fsw._emitReady())}if(s.persistent&&r!==!0)if(typeof n===v2)this.initWatch(void 0,e,a,o);else{let c;try{c=await Fue(a.watchPath)}catch{}this.initWatch(c,e,a,o)}}};T2.exports=S2;T2.exports.canUse=C6e});var Que=B(q2=>{"use strict";var{EventEmitter:R6e}=require("events"),F2=require("fs"),dn=require("path"),{promisify:Kue}=require("util"),I6e=Rle(),P2=Dle().default,k6e=$le(),A2=s2(),P6e=xue(),O6e=qy(),M6e=Nue(),Gue=$ue(),{EV_ALL:C2,EV_READY:N6e,EV_ADD:LR,EV_CHANGE:JE,EV_UNLINK:Hue,EV_ADD_DIR:D6e,EV_UNLINK_DIR:L6e,EV_RAW:U6e,EV_ERROR:R2,STR_CLOSE:F6e,STR_END:B6e,BACK_SLASH_RE:q6e,DOUBLE_SLASH_RE:jue,SLASH_OR_BACK_SLASH_RE:$6e,DOT_RE:G6e,REPLACER_RE:H6e,SLASH:I2,SLASH_SLASH:j6e,BRACE_START:W6e,BANG:O2,ONE_DOT:Yue,TWO_DOTS:V6e,GLOBSTAR:z6e,SLASH_GLOBSTAR:k2,ANYMATCH_OPTS:M2,STRING_TYPE:B2,FUNCTION_TYPE:K6e,EMPTY_STR:N2,EMPTY_FN:Y6e,isWindows:X6e,isMacos:J6e,isIBMi:Q6e}=kR(),Z6e=Kue(F2.stat),eVe=Kue(F2.readdir),D2=(t=[])=>Array.isArray(t)?t:[t],Xue=(t,e=[])=>(t.forEach(n=>{Array.isArray(n)?Xue(n,e):e.push(n)}),e),Wue=t=>{let e=Xue(D2(t));if(!e.every(n=>typeof n===B2))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(Jue)},Vue=t=>{let e=t.replace(q6e,I2),n=!1;for(e.startsWith(j6e)&&(n=!0);e.match(jue);)e=e.replace(jue,I2);return n&&(e=I2+e),e},Jue=t=>Vue(dn.normalize(Vue(t))),zue=(t=N2)=>e=>typeof e!==B2?e:Jue(dn.isAbsolute(e)?e:dn.join(t,e)),tVe=(t,e)=>dn.isAbsolute(t)?t:t.startsWith(O2)?O2+dn.join(e,t.slice(1)):dn.join(e,t),La=(t,e)=>t[e]===void 0,L2=class{constructor(e,n){this.path=e,this._removeWatcher=n,this.items=new Set}add(e){let{items:n}=this;n&&e!==Yue&&e!==V6e&&n.add(e)}async remove(e){let{items:n}=this;if(!n||(n.delete(e),n.size>0))return;let r=this.path;try{await eVe(r)}catch{this._removeWatcher&&this._removeWatcher(dn.dirname(r),dn.basename(r))}}has(e){let{items:n}=this;if(n)return n.has(e)}getChildren(){let{items:e}=this;if(e)return[...e.values()]}dispose(){this.items.clear(),delete this.path,delete this._removeWatcher,delete this.items,Object.freeze(this)}},nVe="stat",rVe="lstat",U2=class{constructor(e,n,r,i){this.fsw=i,this.path=e=e.replace(H6e,N2),this.watchPath=n,this.fullWatchPath=dn.resolve(n),this.hasGlob=n!==e,e===N2&&(this.hasGlob=!1),this.globSymlink=this.hasGlob&&r?void 0:!1,this.globFilter=this.hasGlob?P2(e,void 0,M2):!1,this.dirParts=this.getDirParts(e),this.dirParts.forEach(s=>{s.length>1&&s.pop()}),this.followSymlinks=r,this.statMethod=r?nVe:rVe}checkGlobSymlink(e){return this.globSymlink===void 0&&(this.globSymlink=e.fullParentDir===this.fullWatchPath?!1:{realPath:e.fullParentDir,linkPath:this.fullWatchPath}),this.globSymlink?e.fullPath.replace(this.globSymlink.realPath,this.globSymlink.linkPath):e.fullPath}entryPath(e){return dn.join(this.watchPath,dn.relative(this.watchPath,this.checkGlobSymlink(e)))}filterPath(e){let{stats:n}=e;if(n&&n.isSymbolicLink())return this.filterDir(e);let r=this.entryPath(e);return(this.hasGlob&&typeof this.globFilter===K6e?this.globFilter(r):!0)&&this.fsw._isntIgnored(r,n)&&this.fsw._hasReadPermissions(n)}getDirParts(e){if(!this.hasGlob)return[];let n=[];return(e.includes(W6e)?P6e.expand(e):[e]).forEach(i=>{n.push(dn.relative(this.watchPath,i).split($6e))}),n}filterDir(e){if(this.hasGlob){let n=this.getDirParts(this.checkGlobSymlink(e)),r=!1;this.unmatchedGlob=!this.dirParts.some(i=>i.every((s,o)=>(s===z6e&&(r=!0),r||!n[0][o]||P2(s,n[0][o],M2))))}return!this.unmatchedGlob&&this.fsw._isntIgnored(this.entryPath(e),e.stats)}},UR=class extends R6e{constructor(e){super();let n={};e&&Object.assign(n,e),this._watched=new Map,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._symlinkPaths=new Map,this._streams=new Set,this.closed=!1,La(n,"persistent")&&(n.persistent=!0),La(n,"ignoreInitial")&&(n.ignoreInitial=!1),La(n,"ignorePermissionErrors")&&(n.ignorePermissionErrors=!1),La(n,"interval")&&(n.interval=100),La(n,"binaryInterval")&&(n.binaryInterval=300),La(n,"disableGlobbing")&&(n.disableGlobbing=!1),n.enableBinaryInterval=n.binaryInterval!==n.interval,La(n,"useFsEvents")&&(n.useFsEvents=!n.usePolling),Gue.canUse()||(n.useFsEvents=!1),La(n,"usePolling")&&!n.useFsEvents&&(n.usePolling=J6e),Q6e&&(n.usePolling=!0);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?n.usePolling=!1:c==="true"||c==="1"?n.usePolling=!0:n.usePolling=!!c}let s=process.env.CHOKIDAR_INTERVAL;s&&(n.interval=Number.parseInt(s,10)),La(n,"atomic")&&(n.atomic=!n.usePolling&&!n.useFsEvents),n.atomic&&(this._pendingUnlinks=new Map),La(n,"followSymlinks")&&(n.followSymlinks=!0),La(n,"awaitWriteFinish")&&(n.awaitWriteFinish=!1),n.awaitWriteFinish===!0&&(n.awaitWriteFinish={});let o=n.awaitWriteFinish;o&&(o.stabilityThreshold||(o.stabilityThreshold=2e3),o.pollInterval||(o.pollInterval=100),this._pendingWrites=new Map),n.ignored&&(n.ignored=D2(n.ignored));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=Y6e,this._readyEmitted=!0,process.nextTick(()=>this.emit(N6e)))},this._emitRaw=(...c)=>this.emit(U6e,...c),this._readyEmitted=!1,this.options=n,n.useFsEvents?this._fsEventsHandler=new Gue(this):this._nodeFsHandler=new M6e(this),Object.freeze(n)}add(e,n,r){let{cwd:i,disableGlobbing:s}=this.options;this.closed=!1;let o=Wue(e);return i&&(o=o.map(a=>{let c=tVe(a,i);return s||!A2(a)?c:O6e(c)})),o=o.filter(a=>a.startsWith(O2)?(this._ignoredPaths.add(a.slice(1)),!1):(this._ignoredPaths.delete(a),this._ignoredPaths.delete(a+k2),this._userIgnored=void 0,!0)),this.options.useFsEvents&&this._fsEventsHandler?(this._readyCount||(this._readyCount=o.length),this.options.persistent&&(this._readyCount+=o.length),o.forEach(a=>this._fsEventsHandler._addToFsEvents(a))):(this._readyCount||(this._readyCount=0),this._readyCount+=o.length,Promise.all(o.map(async a=>{let c=await this._nodeFsHandler._addToNodeFs(a,!r,0,0,n);return c&&this._emitReady(),c})).then(a=>{this.closed||a.filter(c=>c).forEach(c=>{this.add(dn.dirname(c),dn.basename(n||c))})})),this}unwatch(e){if(this.closed)return this;let n=Wue(e),{cwd:r}=this.options;return n.forEach(i=>{!dn.isAbsolute(i)&&!this._closers.has(i)&&(r&&(i=dn.join(r,i)),i=dn.resolve(i)),this._closePath(i),this._ignoredPaths.add(i),this._watched.has(i)&&this._ignoredPaths.add(i+k2),this._userIgnored=void 0}),this}close(){if(this.closed)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(n=>n.forEach(r=>{let i=r();i instanceof Promise&&e.push(i)})),this._streams.forEach(n=>n.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(n=>n.dispose()),["closers","watched","streams","symlinkPaths","throttled"].forEach(n=>{this[`_${n}`].clear()}),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((n,r)=>{let i=this.options.cwd?dn.relative(this.options.cwd,r):r;e[i||Yue]=n.getChildren().sort()}),e}emitWithAll(e,n){this.emit(...n),e!==R2&&this.emit(C2,...n)}async _emit(e,n,r,i,s){if(this.closed)return;let o=this.options;X6e&&(n=dn.normalize(n)),o.cwd&&(n=dn.relative(o.cwd,n));let a=[e,n];s!==void 0?a.push(r,i,s):i!==void 0?a.push(r,i):r!==void 0&&a.push(r);let c=o.awaitWriteFinish,l;if(c&&(l=this._pendingWrites.get(n)))return l.lastChange=new Date,this;if(o.atomic){if(e===Hue)return this._pendingUnlinks.set(n,a),setTimeout(()=>{this._pendingUnlinks.forEach((u,f)=>{this.emit(...u),this.emit(C2,...u),this._pendingUnlinks.delete(f)})},typeof o.atomic=="number"?o.atomic:100),this;e===LR&&this._pendingUnlinks.has(n)&&(e=a[0]=JE,this._pendingUnlinks.delete(n))}if(c&&(e===LR||e===JE)&&this._readyEmitted){let u=(f,p)=>{f?(e=a[0]=R2,a[1]=f,this.emitWithAll(e,a)):p&&(a.length>2?a[2]=p:a.push(p),this.emitWithAll(e,a))};return this._awaitWriteFinish(n,c.stabilityThreshold,e,u),this}if(e===JE&&!this._throttle(JE,n,50))return this;if(o.alwaysStat&&r===void 0&&(e===LR||e===D6e||e===JE)){let u=o.cwd?dn.join(o.cwd,n):n,f;try{f=await Z6e(u)}catch{}if(!f||this.closed)return;a.push(f)}return this.emitWithAll(e,a),this}_handleError(e){let n=e&&e.code;return e&&n!=="ENOENT"&&n!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||n!=="EPERM"&&n!=="EACCES")&&this.emit(R2,e),e||this.closed}_throttle(e,n,r){this._throttled.has(e)||this._throttled.set(e,new Map);let i=this._throttled.get(e),s=i.get(n);if(s)return s.count++,!1;let o,a=()=>{let l=i.get(n),u=l?l.count:0;return i.delete(n),clearTimeout(o),l&&clearTimeout(l.timeoutObject),u};o=setTimeout(a,r);let c={timeoutObject:o,clear:a,count:0};return i.set(n,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,n,r,i){let s,o=e;this.options.cwd&&!dn.isAbsolute(e)&&(o=dn.join(this.options.cwd,e));let a=new Date,c=l=>{F2.stat(o,(u,f)=>{if(u||!this._pendingWrites.has(e)){u&&u.code!=="ENOENT"&&i(u);return}let p=Number(new Date);l&&f.size!==l.size&&(this._pendingWrites.get(e).lastChange=p);let m=this._pendingWrites.get(e);p-m.lastChange>=n?(this._pendingWrites.delete(e),i(void 0,f)):s=setTimeout(c,this.options.awaitWriteFinish.pollInterval,f)})};this._pendingWrites.has(e)||(this._pendingWrites.set(e,{lastChange:a,cancelWait:()=>(this._pendingWrites.delete(e),clearTimeout(s),r)}),s=setTimeout(c,this.options.awaitWriteFinish.pollInterval))}_getGlobIgnored(){return[...this._ignoredPaths.values()]}_isIgnored(e,n){if(this.options.atomic&&G6e.test(e))return!0;if(!this._userIgnored){let{cwd:r}=this.options,i=this.options.ignored,s=i&&i.map(zue(r)),o=D2(s).filter(c=>typeof c===B2&&!A2(c)).map(c=>c+k2),a=this._getGlobIgnored().map(zue(r)).concat(s,o);this._userIgnored=P2(a,void 0,M2)}return this._userIgnored([e,n])}_isntIgnored(e,n){return!this._isIgnored(e,n)}_getWatchHelpers(e,n){let r=n||this.options.disableGlobbing||!A2(e)?e:k6e(e),i=this.options.followSymlinks;return new U2(e,r,i,this)}_getWatchedDir(e){this._boundRemove||(this._boundRemove=this._remove.bind(this));let n=dn.resolve(e);return this._watched.has(n)||this._watched.set(n,new L2(n,this._boundRemove)),this._watched.get(n)}_hasReadPermissions(e){if(this.options.ignorePermissionErrors)return!0;let r=(e&&Number.parseInt(e.mode,10))&511;return!!(4&Number.parseInt(r.toString(8)[0],10))}_remove(e,n,r){let i=dn.join(e,n),s=dn.resolve(i);if(r=r??(this._watched.has(i)||this._watched.has(s)),!this._throttle("remove",i,100))return;!r&&!this.options.useFsEvents&&this._watched.size===1&&this.add(e,n,!0),this._getWatchedDir(i).getChildren().forEach(p=>this._remove(i,p));let c=this._getWatchedDir(e),l=c.has(n);c.remove(n),this._symlinkPaths.has(s)&&this._symlinkPaths.delete(s);let u=i;if(this.options.cwd&&(u=dn.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===LR)return;this._watched.delete(i),this._watched.delete(s);let f=r?L6e:Hue;l&&!this._isIgnored(i)&&this._emit(f,i),this.options.useFsEvents||this._closePath(i)}_closePath(e){this._closeFile(e);let n=dn.dirname(e);this._getWatchedDir(n).remove(dn.basename(e))}_closeFile(e){let n=this._closers.get(e);n&&(n.forEach(r=>r()),this._closers.delete(e))}_addPathCloser(e,n){if(!n)return;let r=this._closers.get(e);r||(r=[],this._closers.set(e,r)),r.push(n)}_readdirp(e,n){if(this.closed)return;let r={type:C2,alwaysStat:!0,lstat:!0,...n},i=I6e(e,r);return this._streams.add(i),i.once(F6e,()=>{i=void 0}),i.once(B6e,()=>{i&&(this._streams.delete(i),i=void 0)}),i}};q2.FSWatcher=UR;var iVe=(t,e)=>{let n=new UR(e);return n.add(t),n};q2.watch=iVe});function ife(t){return oB.includes(t)}function Wy(t){return dC.includes(qs.default.extname(t).toLowerCase())}function pVe(t,e){return t.isDirectory()?"folder":Wy(e)?"binary":"file"}function zf(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}function hVe(t){if(!$2.has(t)){let e=process.platform==="win32"?"where":"which";$2.set(t,(0,fu.spawnSync)(e,[t],{stdio:"ignore"}).status===0)}return $2.get(t)}function mVe(t){let e=Pie.find(r=>hVe(r.cmd));if(!e)throw new Error("HEIC needs a system converter (macOS has sips; on Linux install libheif-examples or imagemagick)");let n=qs.default.join(Ua.default.tmpdir(),`9r-heic-${process.pid}-${Date.now()}.jpg`);try{let r=(0,fu.spawnSync)(e.cmd,e.args(t,n),{timeout:Oie});if(r.status!==0||!nt.default.existsSync(n))throw new Error(`HEIC decode failed (${e.cmd}): ${r.stderr?.toString().trim()||"unknown error"}`);return nt.default.readFileSync(n)}finally{try{nt.default.unlinkSync(n)}catch{}}}async function Vy(t,e){let n=pC(e)?mVe(e):t,r=await(0,FR.default)(n).metadata(),i=r.orientation>=5,s=(i?r.height:r.width)||0,o=(i?r.width:r.height)||0,a=[80,60,40],c=[1600,1200,800],l=n,u=s,f=o;for(let p of c)for(let m of a){l=await(0,FR.default)(n).rotate().resize({width:p,height:p,fit:"inside",withoutEnlargement:!0}).jpeg({quality:m,mozjpeg:!0}).toBuffer();let g=await(0,FR.default)(l).metadata();if(u=g.width||p,f=g.height||p,l.length<=3145728)return{buffer:l,width:u,height:f,originalWidth:s,originalHeight:o}}return{buffer:l,width:u,height:f,originalWidth:s,originalHeight:o}}function sfe(t,e,n,r=50){if(!(n.length>=r))try{for(let i of nt.default.readdirSync(t)){if(n.length>=r)return;if(i.startsWith(".")||ife(i))continue;let s=qs.default.join(t,i);try{let o=nt.default.statSync(s);o.isDirectory()?sfe(s,e,n,r):i.toLowerCase().includes(e.toLowerCase())&&n.push({name:i,path:s,type:Wy(i)?"binary":"file",size:o.size,sizeFormatted:zf(o.size)})}catch{}}}catch{}}function nfe(t){if(!t)return null;let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"::ANY::").replace(/\*/g,"[^/]*").replace(/::ANY::/g,".*").replace(/\?/g,".");return new RegExp(`^${e}$`)}function ofe(t,e,n,r,i,s){if(s.length>=200)return;let o;try{o=nt.default.readdirSync(t,{withFileTypes:!0})}catch{return}for(let a of o){if(s.length>=200)return;if(ife(a.name))continue;let c=qs.default.join(t,a.name),l=qs.default.relative(e,c);if(a.isDirectory()){ofe(c,e,n,r,i,s);continue}if(a.isFile()&&!Wy(a.name)&&!Et(c)&&!(i&&i.test(l))&&!(r&&!r.test(l)))try{if(nt.default.statSync(c).size>1048576)continue;let p=nt.default.readFileSync(c,"utf-8").split(`
|
|
395
395
|
`),m=[];for(let g=0;g<p.length&&m.length<10;g++){let y=p[g],w=n(y);for(let S of w){if(m.length>=10)break;m.push({line:g+1,column:S.column+1,lineText:y,matchLength:S.length})}}m.length&&s.push({path:c,matches:m})}catch{}}}function afe(t,e,n){let r;try{r=nt.default.readdirSync(t,{withFileTypes:!0})}catch{return[]}let i=[];for(let s of r){if(!n&&s.name.startsWith(".")&&s.name!==".env"&&s.name!==".env.example")continue;let o=qs.default.join(t,s.name);if(s.isDirectory()){let a={name:s.name,path:o,type:"folder"};e>0&&(a.children=afe(o,e-1,n)),i.push(a)}else s.isFile()&&i.push({name:s.name,path:o,type:Wy(s.name)?"binary":"file"})}return i.sort((s,o)=>s.type==="folder"&&o.type!=="folder"?-1:s.type!=="folder"&&o.type==="folder"?1:s.name.localeCompare(o.name)),i}function gVe(){if(process.platform!=="win32")return[];try{return(0,fu.execSync)("wmic logicaldisk get name",{encoding:"utf-8",stdio:["pipe","pipe","pipe"],windowsHide:!0}).split(/\r?\n/).map(e=>e.trim()).filter(e=>/^[A-Z]:$/.test(e)).map(e=>({letter:e[0],path:e+"\\"}))}catch{return"CDEFGHIJ".split("").map(t=>`${t}:\\`).filter(t=>nt.default.existsSync(t)).map(t=>({letter:t[0],path:t}))}}function cfe(t){t.on("getSystemInfo",n=>{let r=process.platform;n({success:!0,platform:r,isWindows:r==="win32",drives:r==="win32"?gVe():[],homedir:Ua.default.homedir()})}),t.on("getFiles",({dirPath:n,showHidden:r},i)=>{try{let s=n||Ua.default.homedir(),o=s.startsWith("~")?s.replace("~",Ua.default.homedir()):s;if(Et(o))return i({success:!1,error:"Access denied"});if(!nt.default.existsSync(o))return i({success:!1,error:"Directory not found"});let a;try{a=nt.default.readdirSync(o,{withFileTypes:!0})}catch(f){return i({success:!1,error:f.message})}r||(a=a.filter(f=>!(f.name.startsWith(".")&&f.name!==".env"&&f.name!==".env.example"))),a.sort((f,p)=>{let m=f.isDirectory(),g=p.isDirectory();return m&&!g?-1:!m&&g?1:f.name.localeCompare(p.name)});let c=a.length>300,l=c?a.slice(0,300):a,u=[];for(let f of l)try{let p=qs.default.join(o,f.name),m=nt.default.statSync(p);u.push({name:f.name,path:p,type:pVe(m,f.name),size:m.isFile()?m.size:null,sizeFormatted:m.isFile()?zf(m.size):null,modified:m.mtime.getTime()})}catch{}i({success:!0,files:u,currentPath:o,parentPath:qs.default.dirname(o),truncated:c})}catch(s){i({success:!1,error:s.message})}}),t.on("searchFiles",({workspace:n,query:r},i)=>{try{if(!r||r.length<2)return i({success:!0,files:[]});let s=(n||Ua.default.homedir()).replace(/^~/,Ua.default.homedir());if(!nt.default.existsSync(s))return i({success:!1,error:"Workspace not found"});let o=[];sfe(s,r,o,50),o.sort((a,c)=>{let l=a.name.toLowerCase()===r.toLowerCase(),u=c.name.toLowerCase()===r.toLowerCase();return l&&!u?-1:!l&&u?1:a.path.length-c.path.length}),i({success:!0,files:o})}catch(s){i({success:!1,error:s.message})}}),t.on("readFile",({filePath:n},r)=>{try{if(Et(n))return r({success:!1,error:"Access denied"});if(!nt.default.existsSync(n))return r({success:!1,error:"File not found"});let i=nt.default.statSync(n);if(i.size>1048576)return r({success:!1,error:`File too large (${zf(i.size)}). Max ${zf(1048576)}`});if(Wy(n))return r({success:!1,error:"Cannot open binary file"});if(i.size>e0)return r({success:!0,content:"",streamInstead:!0,size:i.size});r({success:!0,content:nt.default.readFileSync(n,"utf-8")})}catch(i){r({success:!1,error:i.message})}}),t.on("readMedia",async({filePath:n},r)=>{try{if(Et(n))return r({success:!1,error:"Access denied"});if(!nt.default.existsSync(n))return r({success:!1,error:"File not found"});let i=nt.default.statSync(n),s=qs.default.extname(n).toLowerCase().slice(1),o=ih[s]||"application/octet-stream",a=o.startsWith("image/"),c=a?20971520:5242880;if(i.size>c)return r({success:!1,error:`File too large (${zf(i.size)}). Max ${zf(c)}`});let l=nt.default.readFileSync(n);if(a){let u=await Vy(l,n),f=`data:image/jpeg;base64,${u.buffer.toString("base64")}`;r({success:!0,dataUrl:f,size:i.size,mime:o,originalSize:i.size,originalWidth:u.originalWidth,originalHeight:u.originalHeight,width:u.width,height:u.height,scaled:u.buffer.length<i.size})}else{let u=`data:${o};base64,${l.toString("base64")}`;r({success:!0,dataUrl:u,size:i.size,mime:o})}}catch(i){r({success:!1,error:i.message})}}),t.on("readImage",async({filePath:n},r)=>{try{if(Et(n))return r({success:!1,error:"Access denied"});if(!nt.default.existsSync(n))return r({success:!1,error:"File not found"});let i=nt.default.statSync(n);if(i.size>20971520)return r({success:!1,error:`Image too large (${zf(i.size)}). Max ${zf(20971520)}`});let s=nt.default.readFileSync(n),o=await Vy(s,n),a=`data:image/jpeg;base64,${o.buffer.toString("base64")}`;r({success:!0,dataUrl:a,size:i.size,mime:"image/jpeg",originalSize:i.size,originalWidth:o.originalWidth,originalHeight:o.originalHeight,width:o.width,height:o.height,scaled:o.buffer.length<i.size})}catch(i){r({success:!1,error:i.message})}}),t.on("writeFile",({filePath:n,content:r},i)=>{try{if(Et(n))return i({success:!1,error:"Access denied"});nt.default.writeFileSync(n,r,"utf-8"),i({success:!0})}catch(s){i({success:!1,error:s.message})}}),t.on("createItem",({itemPath:n,type:r},i)=>{try{if(Et(n))return i({success:!1,error:"Access denied"});if(nt.default.existsSync(n))return i({success:!1,error:"Item already exists"});r==="folder"?nt.default.mkdirSync(n,{recursive:!0}):nt.default.writeFileSync(n,"","utf-8"),i({success:!0})}catch(s){i({success:!1,error:s.message})}}),t.on("deleteItem",({itemPath:n},r)=>{try{if(Et(n))return r({success:!1,error:"Access denied"});if(!nt.default.existsSync(n))return r({success:!1,error:"Item not found"});nt.default.statSync(n).isDirectory()?nt.default.rmSync(n,{recursive:!0}):nt.default.unlinkSync(n),r({success:!0})}catch(i){r({success:!1,error:i.message})}}),t.on("copyItem",({srcPath:n,destPath:r},i)=>{try{if(Et(n)||Et(r))return i({success:!1,error:"Access denied"});if(!nt.default.existsSync(n))return i({success:!1,error:"Item not found"});if(nt.default.existsSync(r))return i({success:!1,error:"Target already exists"});if(r.startsWith(n+"/"))return i({success:!1,error:"Cannot copy into itself"});nt.default.cpSync(n,r,{recursive:!0}),i({success:!0})}catch(s){i({success:!1,error:s.message})}}),t.on("renameItem",({oldPath:n,newPath:r},i)=>{try{if(Et(n)||Et(r))return i({success:!1,error:"Access denied"});if(!nt.default.existsSync(n))return i({success:!1,error:"Item not found"});if(nt.default.existsSync(r))return i({success:!1,error:"Target already exists"});nt.default.renameSync(n,r),i({success:!0})}catch(s){i({success:!1,error:s.message})}}),t.on("searchInFiles",({workspace:n,query:r,caseSensitive:i,regex:s,includeGlob:o,excludeGlob:a},c)=>{try{if(!r)return c({success:!0,results:[]});let l=(n||Ua.default.homedir()).replace(/^~/,Ua.default.homedir());if(!nt.default.existsSync(l))return c({success:!1,error:"Workspace not found"});let u;if(s){let g;try{g=new RegExp(r,i?"g":"gi")}catch(y){return c({success:!1,error:`Invalid regex: ${y.message}`})}u=y=>{let w=[],S;for(g.lastIndex=0;(S=g.exec(y))!==null;)w.push({column:S.index,length:S[0].length}),S.index===g.lastIndex&&g.lastIndex++;return w}}else{let g=i?r:r.toLowerCase();u=y=>{let w=i?y:y.toLowerCase(),S=[],T=0;for(;(T=w.indexOf(g,T))!==-1;)S.push({column:T,length:g.length}),T+=g.length||1;return S}}let f=nfe(o),p=nfe(a),m=[];ofe(l,l,u,f,p,m),c({success:!0,results:m})}catch(l){c({success:!1,error:l.message})}}),t.on("replaceInFiles",({workspace:n,query:r,replacement:i,caseSensitive:s,regex:o,files:a},c)=>{try{if(!r||!Array.isArray(a)||!a.length)return c({success:!0,replacedCount:0,fileCount:0});let l;if(o){let p;try{p=new RegExp(r,s?"g":"gi")}catch(m){return c({success:!1,error:`Invalid regex: ${m.message}`})}l=m=>{let g=0;return{next:m.replace(p,w=>(g++,i)),count:g}}}else l=p=>{let m=0,g=s?"g":"gi",y=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),w=new RegExp(y,g);return{next:p.replace(w,()=>(m++,i)),count:m}};let u=0,f=0;for(let p of a)try{if(!nt.default.existsSync(p)||Wy(p)||Et(p))continue;let m=nt.default.statSync(p);if(!m.isFile()||m.size>1048576)continue;let g=nt.default.readFileSync(p,"utf-8"),{next:y,count:w}=l(g);w>0&&(nt.default.writeFileSync(p,y,"utf-8"),u+=w,f++)}catch{}c({success:!0,replacedCount:u,fileCount:f})}catch(l){c({success:!1,error:l.message})}});let e=new Map;t.on("watchDir",({dirPath:n},r)=>{try{if(!n||!nt.default.existsSync(n))return r({success:!1,error:"Directory not found"});let i=e.get(n);if(i)return i.count++,r({success:!0});if(e.size>=60)return r({success:!0,watching:!1});let s=rfe.default.watch(n,{depth:0,ignoreInitial:!0,persistent:!0,ignored:c=>oB.includes(qs.default.basename(c))}),o={w:s,count:1,burstStart:0,burstCount:0,mutedUntil:0},a=c=>l=>{let u=Date.now();if(!(u<o.mutedUntil)){if(u-o.burstStart>1e3&&(o.burstStart=u,o.burstCount=0),++o.burstCount>30)return o.mutedUntil=u+3e3,t.emit("fileChange",{type:"flooded",path:n});t.emit("fileChange",{type:c,path:l})}};s.on("add",a("add")).on("change",a("change")).on("unlink",a("unlink")).on("addDir",a("addDir")).on("unlinkDir",a("unlinkDir")),e.set(n,o),r({success:!0,watching:!0})}catch(i){r({success:!1,error:i.message})}}),t.on("unwatchDir",({dirPath:n},r)=>{try{let i=e.get(n);i&&--i.count<=0&&(i.w.close(),e.delete(n)),r({success:!0})}catch(i){r({success:!1,error:i.message})}}),t.once("disconnect",()=>{for(let{w:n}of e.values())try{n.close()}catch{}e.clear()}),t.on("revealInOS",({filePath:n},r)=>{try{if(!n)return r({success:!1,error:"No path"});let i=process.platform,s,o;i==="darwin"?(s="open",o=["-R",n]):i==="win32"?(s="explorer",o=[`/select,${n}`]):(s="xdg-open",o=[qs.default.dirname(n)]);let a=(0,fu.spawn)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0});a.on("error",c=>r({success:!1,error:c.message})),a.unref(),r({success:!0})}catch(i){r({success:!1,error:i.message})}}),t.on("openInTerminal",({dirPath:n},r)=>{try{if(!n||!nt.default.existsSync(n))return r({success:!1,error:"Directory not found"});let i=process.platform,s,o,a={detached:!0,stdio:"ignore",windowsHide:!0};i==="darwin"?(s="open",o=["-a","Terminal",n]):i==="win32"?(s="cmd",o=["/C","start",'"9Remote"',"cmd","/K"],a.shell=!1,a.cwd=n):(s="gnome-terminal",o=["--working-directory",n]);let c=(0,fu.spawn)(s,o,a);c.on("error",()=>{if(i==="linux"){let l=(0,fu.spawn)("xterm",["-e","bash"],{...a,cwd:n});l.on("error",u=>r({success:!1,error:u.message})),l.unref()}else r({success:!1,error:"Failed to open terminal"})}),c.unref(),r({success:!0})}catch(i){r({success:!1,error:i.message})}}),t.on("getFileTree",({dirPath:n,depth:r,showHidden:i},s)=>{try{let o=(n||Ua.default.homedir()).replace(/^~/,Ua.default.homedir());if(!nt.default.existsSync(o))return s({success:!1,error:"Directory not found"});let c=afe(o,typeof r=="number"?r:3,!!i);s({success:!0,tree:{name:qs.default.basename(o)||o,path:o,type:"folder",children:c}})}catch(o){s({success:!1,error:o.message})}})}var nt,qs,Ua,fu,rfe,FR,$2,BR=ae(()=>{nt=ce(require("fs"),1),qs=ce(require("path"),1),Ua=ce(require("os"),1),fu=require("child_process"),rfe=ce(Que(),1),FR=ce(require("sharp"),1);my();Ki();oh();$2=new Map});function vVe(t,{maxDepth:e=qR.maxDepth,timeoutMs:n=qR.timeoutMs,now:r=()=>Date.now(),io:i=G2.default}={}){if(!t)return[];let s=$c.default.resolve(t),o=r()+n,a=[],c=[{dir:s,depth:0}];for(;c.length&&!(r()>o);){let{dir:l,depth:u}=c.shift();if(_Ve(l,i)&&a.push({path:l,relPath:l===s?"":$c.default.relative(s,l),depth:u}),u>=e)continue;let f;try{f=i.readdirSync(l,{withFileTypes:!0})}catch{continue}for(let p of f)!p.isDirectory()||p.isSymbolicLink()||yVe.has(p.name)||c.push({dir:$c.default.join(l,p.name),depth:u+1})}return a}function H2(t,e={}){let n=e.now||(()=>Date.now()),r=e.cacheTtlMs??qR.cacheTtlMs,i=EVe(t,e.maxDepth),s=QE.get(i);if(s&&n()-s.ts<r)return s.repos;let o=vVe(t,e);return QE.set(i,{ts:n(),repos:o}),o}function $R(t){if(!t)return QE.clear();let e=`${$c.default.resolve(t)}::`;for(let n of QE.keys())n.startsWith(e)&&QE.delete(n)}function j2(t=""){let e=[],n=null;for(let r of t.split(`
|
|
396
396
|
`)){let i=r.trimEnd();if(!i){n&&(e.push(n),n=null);continue}let[s,...o]=i.split(" "),a=o.join(" ");if(s==="worktree")n={path:a,branch:null,head:null,detached:!1,locked:!1,bare:!1};else if(n)s==="HEAD"?n.head=a:s==="branch"?n.branch=a.replace(/^refs\/heads\//,""):s==="detached"?n.detached=!0:s==="locked"?n.locked=!0:s==="bare"&&(n.bare=!0);else continue}return n&&e.push(n),e.map((r,i)=>({...r,isMain:i===0}))}function lfe(t="",e=[]){let n=new Set(e.map(s=>s.branch).filter(Boolean)),r=new Set,i=[];for(let s of t.split(`
|
|
@@ -510,9 +510,9 @@ https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};var g3
|
|
|
510
510
|
`:". ";let s=i;if(i.length>1e4){let o=i.substring(0,1e4),a=i.length-1e4;s=`${o}...and ${a} more chars`}e+=`Body: ${s}`,e=e.trim(),super(e,n),this.name="GoogleGenAiDefaultError"}};dV=class extends ReadableStream{constructor(e,n,r){var i;let s=e.getReader(),o=new Uint8Array(4096),a=0,c=0,l={eventId:void 0},u=(i=r?.dataRequired)!==null&&i!==void 0?i:!0;super({async pull(f){try{for(;;){let p=mpt(o,a,c);if(!p){c=Math.max(0,a-hpt+1);let y=await s.read();if(y.done)return f.close();if(a+y.value.length>o.length){let w=new Uint8Array(Math.max(o.length*2,a+y.value.length));w.set(o.subarray(0,a)),o=w}o.set(y.value,a),a+=y.value.length;continue}let m=o.slice(0,p.index);if(o.copyWithin(0,p.index+p.length,a),a-=p.index+p.length,o.length>4096&&a<=o.length>>2){let y=new Uint8Array(Math.max(4096,a*2));y.set(o.subarray(0,a)),o=y}c=0;let g=gpt(m,n,l,u);if(g&&!g.done)return f.enqueue(g.value);if(g?.done)return await s.cancel("done"),f.close()}}catch(p){f.error(p),await s.cancel(p)}},cancel:f=>s.cancel(f)})}[Symbol.asyncIterator](e){let n=ReadableStream.prototype[Symbol.asyncIterator];if(typeof n=="function")return n.call(this,e);let r=this.getReader(),i={next:async()=>{let o=await r.read();return o.done?(r.releaseLock(),{done:!0,value:void 0}):{done:!1,value:o.value}},throw:async o=>(await r.cancel(o),r.releaseLock(),{done:!0,value:void 0}),return:async()=>(await r.cancel("done"),r.releaseLock(),{done:!0,value:void 0}),[Symbol.asyncIterator](){return this}},s=Symbol.asyncDispose;return s&&(i[s]=async()=>{var o;await((o=i.return)===null||o===void 0?void 0:o.call(i))}),i}values(e){return this[Symbol.asyncIterator](e)}},Xo=13,Jo=10,Xbe=[[Xo,Jo,Xo,Jo],[Xo,Jo,Xo],[Xo,Jo,Jo],[Xo,Xo,Jo],[Jo,Xo,Jo],[Xo,Xo],[Jo,Xo],[Jo,Jo]],hpt=Xbe.reduce((t,e)=>Math.max(t,e.length),0);ypt={jsonl:"application/jsonl",json:"application/json",text:"text/plain",bytes:"application/octet-stream",stream:"application/octet-stream",sse:"text/event-stream",nil:"*",fail:"*"};_pt=/, */;jxe={Incomplete:"incomplete",UnrecognisedSecurityType:"unrecognized_security_type"},pV=class t extends Error{constructor(e,n){super(n),this.code=e,this.name="SecurityError"}static incomplete(){return new t(jxe.Incomplete,"Security requirements not met in order to perform the operation")}static unrecognizedType(e){return new t(jxe.UnrecognisedSecurityType,`Unrecognised security type: ${e}`)}};Tt=class t{constructor(e,n){this[Zbe]="APIPromise",this._promise=e instanceof Promise?e:Promise.resolve(e),this._unwrapped=e instanceof Promise?null:Promise.resolve(e[0]),this._callSource=n??null}_getUnwrapped(){var e;return(e=this._unwrapped)!==null&&e!==void 0?e:this._unwrapped=this._promise.then(([n])=>n)}then(e,n){return this._promise.then(e?([r])=>e(r):void 0,n)}catch(e){return this._getUnwrapped().catch(e)}finally(e){return this._getUnwrapped().finally(e)}$inspect(){return this._promise}asResponse(){var e;return((e=this._callSource)!==null&&e!==void 0?e:this._callSource=this._promise.then(([,r])=>r)).then(r=>{if(!r.response)throw new Error("APIPromise.asResponse: response unavailable");return r.response})}async withResponse(){let[[e],n]=await Promise.all([this._promise,this.asResponse()]);return{data:e,response:n}}_thenUnwrap(e){var n;let r=this._promise.then(([i,s])=>[e(i),s]);return r.catch(()=>{}),new t(r,(n=this._callSource)!==null&&n!==void 0?n:void 0)}};Zbe=Symbol.toStringTag;hV=class extends Xa{list(e,n){return qt(rTe(this,e?.api_version,e?.page_size,e?.page_token,e?.parent,n))}create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return qt(eTe(this,i,r,n))}delete(e,n,r){return qt(tTe(this,e,n?.api_version,r))}get(e,n,r){return qt(nTe(this,e,n?.api_version,r))}};mV=class extends Xa{list(e,n){return qt(aTe(this,e?.api_version,e?.page_size,e?.page_token,n))}create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return qt(iTe(this,i,r,n))}delete(e,n,r){return qt(sTe(this,e,n?.api_version,r))}get(e,n,r){return qt(oTe(this,e,n?.api_version,r))}update(e,n,r){let{api_version:i,update_mask:s}=n,o=wr(n,["api_version","update_mask"]);return qt(cTe(this,e,o,i,s,r))}};gV=class extends Xa{list(e,n,r,i){return qt(pTe(this,e,n,r?.api_version,r?.page_size,r?.page_token,r?.recursive,i))}};yV=class extends Xa{startUpload(e,n,r,i){return qt(hTe(this,e,n,r["X-Goog-Upload-Command"],r["X-Goog-Upload-Header-Content-Length"],r["X-Goog-Upload-Header-Content-Type"],r["X-Goog-Upload-Protocol"],r.api_version,r.extract,r.overwrite,i))}};_V=class extends Xa{get internal(){var e;return(e=this._internal)!==null&&e!==void 0?e:this._internal=new yV(this._options)}get files(){var e;return(e=this._files)!==null&&e!==void 0?e:this._files=new gV(this._options)}listEnvironments(e,n){return qt(dTe(this,e?.api_version,e?.page_size,e?.page_token,n))}createEnvironment(e,n,r){return qt(lTe(this,e,n,r))}deleteEnvironment(e,n,r){return qt(uTe(this,e,n?.api_version,r))}getEnvironment(e,n,r){return qt(fTe(this,e,n?.api_version,r))}};vV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="CancelInteractionByIdServerError"}},EV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="CancelInteractionByIdClientError"}};wV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="CreateInteractionServerError"}},SV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="CreateInteractionClientError"}};xV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="DeleteInteractionServerError"}},bV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="DeleteInteractionClientError"}};TV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="GetInteractionByIdServerError"}},AV=class extends Qo{constructor(e,n){var r;let i=((r=e.error)===null||r===void 0?void 0:r.message)||`API error occurred: ${JSON.stringify(e)}`;super(i,n),this.data$=e,this.error=e.error,this.name="GetInteractionByIdClientError"}};CV=class extends Xa{create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return qt(gTe(this,i,r,n))}delete(e,n,r){return qt(Bpt(this,e,n?.api_version,r))}get(e,n,r){return qt(yTe(this,e,n?.api_version,n?.include_input,n?.last_event_id,n?.stream,r))}cancel(e,n,r){return qt(mTe(this,e,n?.api_version,r))}};RV=class extends Xa{list(e,n){return qt(STe(this,e?.api_version,e?.filter,e?.page_size,e?.page_token,n))}create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return qt(_Te(this,i,r,n))}delete(e,n,r){return qt(vTe(this,e,n?.api_version,r))}get(e,n,r){return qt(ETe(this,e,n?.api_version,r))}update(e,n,r){let{api_version:i}=n,s=wr(n,["api_version"]);return qt(bTe(this,e,s,i,r))}listExecutions(e,n,r){return qt(wTe(this,e,n?.api_version,n?.page_size,n?.page_token,r))}run(e,n,r){return qt(xTe(this,e,n?.api_version,r))}};IV=class extends Xa{list(e,n){return qt(RTe(this,e?.api_version,e?.page_size,e?.page_token,n))}create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return qt(TTe(this,i,r,n))}delete(e,n,r){return qt(ATe(this,e,n?.api_version,r))}get(e,n,r){return qt(CTe(this,e,n?.api_version,r))}update(e,n,r){let i=n??{},{api_version:s,update_mask:o}=i,a=wr(i,["api_version","update_mask"]),c=n===void 0||Object.keys(a).length===0?void 0:a;return qt(PTe(this,e,s,o,c,r))}ping(e,n,r,i){return qt(ITe(this,e,n,r,i))}rotateSigningSecret(e,n,r,i){return qt(kTe(this,e,n,r,i))}};nht=class extends Xa{get environments(){var e;return(e=this._environments)!==null&&e!==void 0?e:this._environments=new _V(this._options)}get agents(){var e;return(e=this._agents)!==null&&e!==void 0?e:this._agents=new hV(this._options)}get credentials(){var e;return(e=this._credentials)!==null&&e!==void 0?e:this._credentials=new mV(this._options)}get interactions(){var e;return(e=this._interactions)!==null&&e!==void 0?e:this._interactions=new CV(this._options)}get triggers(){var e;return(e=this._triggers)!==null&&e!==void 0?e:this._triggers=new RV(this._options)}get webhooks(){var e;return(e=this._webhooks)!==null&&e!==void 0?e:this._webhooks=new IV(this._options)}};rht=new Set(["lyria-3-pro-preview","lyria-3-clip-preview"]);kV=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);if(i.stream===!0){let o=await W3(()=>this.getClient(r).interactions.create(Object.assign(Object.assign({},i),{stream:!0,api_version:r}),Rt(n,!0)));return Vxe(o)}let s=await en(gTe(this.getClient(r),i,r,Rt(n)));return V3(s)}async get(e,n={},r){let{api_version:i,stream:s=!1,last_event_id:o,include_input:a}=n??{};if(s===!0){let l=await W3(()=>this.getClient(i).interactions.get(e,{stream:s,last_event_id:o,include_input:a,api_version:i},Rt(r,!0)));return Vxe(l)}let c=await en(yTe(this.getClient(i),e,i,a,o,s,Rt(r)));return V3(c)}async delete(e,n={},r){return W3(()=>this.getClient(n?.api_version).interactions.delete(e,{api_version:n?.api_version},Rt(r)))}async cancel(e,n={},r){return V3(await en(mTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r))))}getClient(e){var n;return e?Zo(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=Zo(this.parentClient)),this.sdk)}},PV=class{constructor(e){this.parentClient=e}async create(e={},n){let r=e??{},{api_version:i}=r,s=wr(r,["api_version"]);return en(eTe(this.getClient(i),s,i,Rt(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s,parent:o}=e??{};return en(rTe(this.getClient(r),r,i,s,o,Rt(n)))}async get(e,n={},r){return en(nTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}async delete(e,n={},r){return en(tTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}getClient(e){var n;return e?Zo(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=Zo(this.parentClient)),this.sdk)}},OV=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return en(TTe(this.getClient(),i,r,Rt(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s}=e??{};return en(RTe(this.getClient(),r,i,s,Rt(n)))}async get(e,n={},r){return en(CTe(this.getClient(),e,n?.api_version,Rt(r)))}async update(e,n={},r){let i=n??{},{api_version:s,update_mask:o}=i,a=wr(i,["api_version","update_mask"]);return en(PTe(this.getClient(),e,s,o,a,Rt(r)))}async delete(e,n={},r){return en(ATe(this.getClient(),e,n?.api_version,Rt(r)))}async rotateSigningSecret(e,n={},r){let i=n??{},{api_version:s}=i,o=wr(i,["api_version"]);return en(kTe(this.getClient(),e,s,o,Rt(r)))}async ping(e,n=void 0,r){let{api_version:i,body:s}=n??{};return en(ITe(this.getClient(),e,i,s,Rt(r)))}getClient(){var e;return(e=this.sdk)!==null&&e!==void 0||(this.sdk=Zo(this.parentClient)),this.sdk}},MV=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return en(_Te(this.getClient(r),i,r,Rt(n)))}async list(e={},n){let{api_version:r,filter:i,page_size:s,page_token:o}=e??{};return en(STe(this.getClient(r),r,i,s,o,Rt(n)))}async get(e,n={},r){return en(ETe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}async update(e,n,r){let{api_version:i}=n,s=wr(n,["api_version"]);return en(bTe(this.getClient(i),e,s,i,Rt(r)))}async delete(e,n={},r){return en(vTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}async run(e,n={},r){return en(xTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}async listExecutions(e,n={},r){let{api_version:i,page_size:s,page_token:o}=n??{};return en(wTe(this.getClient(i),e,i,s,o,Rt(r)))}getClient(e){var n;return e?Zo(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=Zo(this.parentClient)),this.sdk)}};NV=class{constructor(e,n){this.resolveClient=e,this.parentClient=n}async list(e,n){return en(pTe(this.resolveClient(e.api_version),e.environment,e.path,e.api_version,e.page_size,e.page_token,e.recursive,Rt(n)))}async download(e,n){var r,i;let s=e.environment;if(!s)throw new Error("environment is required.");let o=s.startsWith("environments/")?s:`environments/${s}`,a=e.path.replace(/^\/+/,""),c=`${o}/files/${a}`,l=this.parentClient;if(!l||typeof l.request!="function")throw new Error("apiClient is required to download files.");let u=await l.request({path:c,httpMethod:"GET",queryParams:{alt:"media"},httpOptions:Object.assign(Object.assign({},n?.httpOptions),{apiVersion:(r=e.api_version)!==null&&r!==void 0?r:(i=n?.httpOptions)===null||i===void 0?void 0:i.apiVersion})});if(u&&u.responseInternal&&typeof u.responseInternal.arrayBuffer=="function"){let f=await u.responseInternal.arrayBuffer();return new Uint8Array(f)}throw new Error("Unexpected response type from download")}async upload(e,n){var r,i,s,o,a,c,l,u;let f=e.environment;if(!f)throw new Error("environment is required.");f.startsWith("environments/")||`${f}`;let p=e.path.replace(/^\/+/,""),m=this.parentClient;if(!m||typeof m.request!="function")throw new Error("apiClient is required to upload files.");let g,y=0,w=e.mime_type;if(typeof e.file=="string"){let k;try{let E=globalThis.require;E&&(k=E("fs").readFileSync(e.file))}catch{}if(!k&&typeof globalThis.process<"u")try{let E=(i=(r=globalThis.process.mainModule)===null||r===void 0?void 0:r.require)!==null&&i!==void 0?i:globalThis.require;E&&(k=E("fs").readFileSync(e.file))}catch{}if(k)g=new Uint8Array(k.buffer,k.byteOffset,k.byteLength),y=g.byteLength;else throw new Error(`Unable to read file from path "${e.file}". File path string inputs are only supported in Node.js environments.`);w||(w=pht(e.file))}else if(typeof Blob<"u"&&e.file instanceof Blob)g=e.file,y=e.file.size,!w&&e.file.type&&(w=e.file.type);else if(e.file instanceof Uint8Array||e.file instanceof ArrayBuffer)g=e.file instanceof ArrayBuffer?new Uint8Array(e.file):e.file,y=g.byteLength;else if(typeof globalThis.Buffer<"u"&&typeof globalThis.Buffer.isBuffer=="function"&&globalThis.Buffer.isBuffer(e.file)){let k=e.file;g=new Uint8Array(k.buffer,k.byteOffset,k.byteLength),y=g.byteLength}else throw new Error("Unsupported file type for upload.");w||(w="application/octet-stream");let S=f.startsWith("environments/")?f.replace(/^environments\//,""):f,[T,R]=await hTe(this.resolveClient(e.api_version),S,p,"start",y,w,"resumable",e.api_version,e.extract,e.overwrite,Rt(n)).$inspect();if(!T.ok)throw om(T.error);let C=R.status==="complete"?(a=(o=(s=R.response)===null||s===void 0?void 0:s.headers)===null||o===void 0?void 0:o.get("x-goog-upload-url"))!==null&&a!==void 0?a:(l=(c=R.response)===null||c===void 0?void 0:c.headers)===null||l===void 0?void 0:l.get("X-Goog-Upload-URL"):void 0;if(!C)throw new Error("Failed to get upload URL from upload handshake response.");let D=8*1024*1024,q=0,G,V=g instanceof Blob?g:new Blob([g]);for(;q<y||y===0&&q===0;){let k=Math.min(q+D,y),E=V.slice(q,k),A=k>=y,M=A?"upload, finalize":"upload";if(G=await m.request({path:"",body:E,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},n?.httpOptions),{apiVersion:"",baseUrl:C,headers:Object.assign(Object.assign({},((u=n?.httpOptions)===null||u===void 0?void 0:u.headers)||{}),{"X-Goog-Upload-Command":M,"X-Goog-Upload-Offset":`${q}`})})}),q=k,A)break}let L;if(G&&typeof G.json=="function"?L=await G.json():G&&G.responseInternal&&typeof G.responseInternal.json=="function"&&(L=await G.responseInternal.json()),L&&typeof L=="object"){if(Array.isArray(L.files))return L;if(L.name||L.path)return{files:[L]};if(L.file&&typeof L.file=="object")return{files:[L.file]}}return L}},DV=class{constructor(e){this.parentClient=e,this.files=new NV(n=>this.getClient(n),this.parentClient)}async create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return en(lTe(this.getClient(r),i,r,Rt(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s}=e??{};return en(dTe(this.getClient(r),r,i,s,Rt(n)))}async get(e,n={},r){return en(fTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}async delete(e,n={},r){return en(uTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}getClient(e){var n;return e?Zo(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=Zo(this.parentClient)),this.sdk)}},LV=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=wr(e,["api_version"]);return en(iTe(this.getClient(r),i,r,Rt(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s}=e??{};return en(aTe(this.getClient(r),r,i,s,Rt(n)))}async get(e,n={},r){return en(oTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}async update(e,n,r){let{api_version:i,update_mask:s}=n,o=wr(n,["api_version","update_mask"]);return en(cTe(this.getClient(i),e,o,i,s,Rt(r)))}async delete(e,n={},r){return en(sTe(this.getClient(n?.api_version),e,n?.api_version,Rt(r)))}getClient(e){var n;return e?Zo(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=Zo(this.parentClient)),this.sdk)}};Kxe="x-goog-api-key",bS="https://www.googleapis.com/auth/cloud-platform",UV=class{constructor(e){if(e.apiKey!==void 0){this.apiKey=e.apiKey;return}let n=hht(e.googleAuthOptions);this.googleAuth=new Jxe.GoogleAuth(n)}async addAuthHeaders(e,n){if(this.apiKey!==void 0){if(this.apiKey.startsWith("auth_tokens/"))throw new Error("Ephemeral tokens are only supported by the live API.");this.addKeyHeader(e);return}return this.addGoogleAuthHeaders(e,n)}addKeyHeader(e){if(e.get(Kxe)===null){if(this.apiKey===void 0)throw new Error("Trying to set API key header but apiKey is not set");e.append(Kxe,this.apiKey)}}async addGoogleAuthHeaders(e,n){if(this.googleAuth===void 0)throw new Error("Trying to set google-auth headers but googleAuth is unset");let r=await this.googleAuth.getRequestHeaders(n);for(let[i,s]of r)e.get(i)===null&&e.append(i,s)}};FV=class{async download(e,n){if(e.downloadPath){let r=await mht(e,n);if(r instanceof Du){let i=(0,Qxe.createWriteStream)(e.downloadPath);ebe.Readable.fromWeb(r.responseInternal.body).pipe(i),await(0,tbe.finished)(i)}else try{await(0,Zxe.writeFile)(e.downloadPath,r,{encoding:"base64"})}catch(i){throw new Error(`Failed to write file to ${e.downloadPath}: ${i}`)}}}};BV=class{create(e,n,r){return new qV(e,n,r)}},qV=class{constructor(e,n,r){this.url=e,this.headers=n,this.callbacks=r}connect(){this.ws=new H3.default(this.url,{headers:this.headers}),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.send(e)}close(){if(this.ws===void 0)throw new Error("WebSocket is not connected");this.ws.close()}};HV=class extends Ya{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new sl(il.PAGED_ITEM_TUNING_JOBS,r=>this.listInternal(r),await this.listInternal(n),n),this.get=async n=>await this.getInternal(n),this.tune=async n=>{var r;if(this.apiClient.isVertexAI())if(n.baseModel.startsWith("projects/")){let i={tunedModelName:n.baseModel};!((r=n.config)===null||r===void 0)&&r.preTunedModelCheckpointId&&(i.checkpointId=n.config.preTunedModelCheckpointId);let s=Object.assign(Object.assign({},n),{preTunedModel:i});return s.baseModel=void 0,await this.tuneInternal(s)}else{let i=Object.assign({},n);return await this.tuneInternal(i)}else{let i=Object.assign({},n),s=await this.tuneMldevInternal(i),o="";return s.metadata!==void 0&&s.metadata.tunedModel!==void 0?o=s.metadata.tunedModel:s.name!==void 0&&s.name.includes("/operations/")&&(o=s.name.split("/operations/")[0]),{name:o,state:XP.JOB_STATE_QUEUED}}}}async getInternal(e){var n,r,i,s;let o,a="",c={};if(this.apiClient.isVertexAI()){let l=Rht(e);return a=Ce("{name}",l._url),c=l._query,delete l._url,delete l._query,o=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(l),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(u=>u.json().then(f=>{let p=f;return p.sdkHttpResponse={headers:u.headers},p})),o.then(u=>GV(u))}else{let l=Cht(e);return a=Ce("{name}",l._url),c=l._query,delete l._url,delete l._query,o=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(l),httpMethod:"GET",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(u=>u.json().then(f=>{let p=f;return p.sdkHttpResponse={headers:u.headers},p})),o.then(u=>Uht(u))}}async listInternal(e){var n,r;let i,s="",o={};if(this.apiClient.isVertexAI()){let a=kht(e);return s=Ce("tuningJobs",a._url),o=a._query,delete a._url,delete a._query,i=this.apiClient.request({path:s,queryParams:o,body:JSON.stringify(a),httpMethod:"GET",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(c=>c.json().then(l=>{let u=l;return u.sdkHttpResponse={headers:c.headers},u})),i.then(c=>{let l=Pht(c),u=new i1;return Object.assign(u,l),u})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async cancel(e){var n,r,i,s;let o,a="",c={};if(this.apiClient.isVertexAI()){let l=yht(e);return a=Ce("{name}:cancel",l._url),c=l._query,delete l._url,delete l._query,o=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(l),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(u=>u.json().then(f=>{let p=f;return p.sdkHttpResponse={headers:u.headers},p})),o.then(u=>{let f=vht(u),p=new MS;return Object.assign(p,f),p})}else{let l=ght(e);return a=Ce("{name}:cancel",l._url),c=l._query,delete l._url,delete l._query,o=this.apiClient.request({path:a,queryParams:c,body:JSON.stringify(l),httpMethod:"POST",httpOptions:(i=e.config)===null||i===void 0?void 0:i.httpOptions,abortSignal:(s=e.config)===null||s===void 0?void 0:s.abortSignal}).then(u=>u.json().then(f=>{let p=f;return p.sdkHttpResponse={headers:u.headers},p})),o.then(u=>{let f=_ht(u),p=new MS;return Object.assign(p,f),p})}}async tuneInternal(e){var n,r;let i,s="",o={};if(this.apiClient.isVertexAI()){let a=xht(e,e);return s=Ce("tuningJobs",a._url),o=a._query,delete a._url,delete a._query,i=this.apiClient.request({path:s,queryParams:o,body:JSON.stringify(a),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(c=>c.json().then(l=>{let u=l;return u.sdkHttpResponse={headers:c.headers},u})),i.then(c=>GV(c))}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}async tuneMldevInternal(e){var n,r;let i,s="",o={};if(this.apiClient.isVertexAI())throw new Error("This method is only supported by the Gemini Developer API.");{let a=Sht(e);return s=Ce("tunedModels",a._url),o=a._query,delete a._url,delete a._query,i=this.apiClient.request({path:s,queryParams:o,body:JSON.stringify(a),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(c=>c.json().then(l=>{let u=l;return u.sdkHttpResponse={headers:c.headers},u})),i.then(c=>Fht(c))}}async validateReward(e){var n,r;let i,s="",o={};if(this.apiClient.isVertexAI()){let a=Bht(e);return s=Ce("{parent}/tuningJobs:validateReinforcementTuningReward",a._url),o=a._query,delete a._url,delete a._query,i=this.apiClient.request({path:s,queryParams:o,body:JSON.stringify(a),httpMethod:"POST",httpOptions:(n=e.config)===null||n===void 0?void 0:n.httpOptions,abortSignal:(r=e.config)===null||r===void 0?void 0:r.abortSignal}).then(c=>c.json().then(l=>{let u=l;return u.sdkHttpResponse={headers:c.headers},u})),i.then(c=>{let l=qht(c),u=new s1;return Object.assign(u,l),u})}else throw new Error("This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).")}},MTe=1024*1024*8,NTe=3,DTe=1e3,LTe=2,kd="x-goog-upload-status";jV=class{async stat(e){let n={size:0,type:void 0};if(typeof e=="string"){let r=await M1.stat(e);return n.size=r.size,n.type=this.inferMimeType(e),n}else return await Hht(e)}async upload(e,n,r,i){return typeof e=="string"?await this.uploadFileFromPath(e,n,r,i):$ht(e,n,r,i)}async uploadToFileSearchStore(e,n,r,i){return typeof e=="string"?await this.uploadFileToFileSearchStoreFromPath(e,n,r,i):Ght(e,n,r,i)}inferMimeType(e){let n=e.slice(e.lastIndexOf(".")+1);return{aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",kml:"application/vnd.google-earth.kml+xml",kmz:"application/vnd.google-earth.kmz+xml",mjs:"text/javascript",mp3:"audio/mpeg",mp4:"video/mp4",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/x-httpd-php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3g2":"video/3gpp2","7z":"application/x-7z-compressed"}[n.toLowerCase()]}async uploadFileFromPath(e,n,r,i){var s;let o=await this.uploadFileFromPathInternal(e,n,r,i),a=await o?.json();if(((s=o?.headers)===null||s===void 0?void 0:s[kd])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");return a.file}async uploadFileToFileSearchStoreFromPath(e,n,r,i){var s;let o=await this.uploadFileFromPathInternal(e,n,r,i),a=await o?.json();if(((s=o?.headers)===null||s===void 0?void 0:s[kd])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");let c=KV(a),l=new US;return Object.assign(l,c),l}async uploadFileFromPathInternal(e,n,r,i){var s,o,a;let c=n,l=i?.baseUrl||((s=r.clientOptions.httpOptions)===null||s===void 0?void 0:s.baseUrl);if(l){let w=new URL(l),S=new URL(n);S.protocol=w.protocol,S.host=w.host,S.port=w.port,c=S.toString()}let u=0,f=0,p=new Du(new Response),m="upload",g,y=nbe.basename(e);try{if(g=await M1.open(e,"r"),!g)throw new Error("Failed to open file");for(u=(await g.stat()).size;f<u;){let w=Math.min(MTe,u-f);f+w>=u&&(m+=", finalize");let S=new Uint8Array(w),{bytesRead:T}=await g.read(S,0,w,f);if(T!==w)throw new Error(`Failed to read ${w} bytes from file at offset ${f}. bytes actually read: ${T}`);let R=new Blob([S]),C=0,D=DTe;for(;C<NTe;){let q=Object.assign(Object.assign({},i?.headers||{}),{"X-Goog-Upload-Command":m,"X-Goog-Upload-Offset":String(f),"X-Goog-Upload-File-Name":y});if(p=await r.request({path:"",body:R,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},i),{apiVersion:"",baseUrl:c,headers:q})}),!((o=p?.headers)===null||o===void 0)&&o[kd])break;C++,await FTe(D),D=D*LTe}if(f+=T,((a=p?.headers)===null||a===void 0?void 0:a[kd])!=="active")break;if(u<=f)throw new Error("All content has been uploaded, but the upload status is not finalized.")}return p}finally{g&&await g.close()}}};WV=class extends wbe{async registerFiles(e){if(typeof process>"u"||!process.versions||!process.versions.node)throw new Error("registerFiles is only supported in Node.js environments.");let r=await e.auth.getRequestHeaders(),i=e.config||{},s=i.httpOptions||{},o=Object.assign({},s.headers||{});if(r)if(typeof r[Symbol.iterator]=="function")for(let[a,c]of r)o[a]=c;else for(let[a,c]of Object.entries(r))o[a]=c;return this._registerFiles({uris:e.uris,config:Object.assign(Object.assign({},i),{httpOptions:Object.assign(Object.assign({},s),{headers:o})})})}};jht="gl-node/";VV=class{getNextGenClient(){let e=this.httpOptions;return this._nextGenClient===void 0&&(this._nextGenClient=Zo(this.apiClient,{timeout_ms:e?.timeout})),e?.extraBody&&console.warn("GoogleGenAI: Client level httpOptions.extraBody is not supported by the Gemini NextGen client and will be ignored."),this._nextGenClient}get interactions(){return this._interactions!==void 0?this._interactions:(this._interactions=new kV(this.apiClient),this._interactions)}get webhooks(){return this._webhooks!==void 0?this._webhooks:(this._webhooks=new OV(this.apiClient),this._webhooks)}get agents(){return this._agents!==void 0?this._agents:(console.warn("GoogleGenAI.agents: Agents usage is experimental and may change in future versions."),this._agents=new PV(this.apiClient),this._agents)}get triggers(){return this._triggers!==void 0?this._triggers:(console.warn("GoogleGenAI.triggers: Triggers usage is experimental and may change in future versions."),this._triggers=new MV(this.apiClient),this._triggers)}get environments(){return this._environments!==void 0?this._environments:(console.warn("GoogleGenAI.environments: Environments usage is experimental and may change in future versions."),this._environments=new DV(this.apiClient),this._environments)}get credentials(){return this._credentials!==void 0?this._credentials:(console.warn("GoogleGenAI.credentials: Credentials usage is experimental and may change in future versions."),this._credentials=new LV(this.apiClient),this._credentials)}constructor(e={}){var n,r,i,s;if(this.vertexai=Wht(e),(e.project||e.location)&&!this.vertexai)throw new Error("Project and location are not supported for Gemini API backend.");let o=Vht(),a=Pd("GOOGLE_CLOUD_PROJECT"),c=Pd("GOOGLE_CLOUD_LOCATION");this.apiKey=(n=e.apiKey)!==null&&n!==void 0?n:o,this.project=(r=e.project)!==null&&r!==void 0?r:a,this.location=(i=e.location)!==null&&i!==void 0?i:c,!this.vertexai&&!this.apiKey&&console.warn("API key should be set when using the Gemini API."),this.vertexai&&(!((s=e.googleAuthOptions)===null||s===void 0)&&s.credentials&&(console.debug("The user provided Google Cloud credentials will take precedence over the API key from the environment variable."),this.apiKey=void 0),!e.project&&!e.location&&(a||c)&&e.apiKey?(console.debug("The user provided Vertex AI API key will take precedence over the project/location from the environment variables."),this.project=void 0,this.location=void 0):(e.project||e.location)&&!e.apiKey&&o?(console.debug("The user provided project/location will take precedence over the API key from the environment variables."),this.apiKey=void 0):!e.project&&!e.location&&!e.apiKey&&(a||c)&&o&&(console.debug("The project/location from the environment variables will take precedence over the API key from the environment variables."),this.apiKey=void 0),!this.location&&!this.apiKey&&(this.location="global"));let l=bot(e.httpOptions,this.vertexai,Pd("GOOGLE_VERTEX_BASE_URL"),Pd("GOOGLE_GEMINI_BASE_URL"));l&&(e.httpOptions?e.httpOptions.baseUrl=l:e.httpOptions={baseUrl:l}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;let u=new UV({apiKey:this.apiKey,googleAuthOptions:e.googleAuthOptions});this.apiClient=new K6({auth:u,project:this.project,location:this.location,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:jht+process.version,uploader:new jV,downloader:new FV}),this.models=new am(this.apiClient),this.live=new w1(this.apiClient,u,new BV),this.batches=new y1(this.apiClient),this.chats=new v1(this.models,this.apiClient),this.caches=new _1(this.apiClient),this.files=new WV(this.apiClient),this.operations=new x1(this.apiClient),this.authTokens=new b1(this.apiClient),this.tunings=new HV(this.apiClient),this.fileSearchStores=new Q6(this.apiClient)}}});function zTe({provider:t,baseUrl:e,apiKey:n,model:r}={}){t&&Kht.includes(t)&&(Nt.provider=t),e!==void 0&&(Nt.baseUrl=String(e||"").replace(/\/+$/,"")),n!==void 0&&(Nt.apiKey=String(n||"")),r&&(Nt.model=String(r))}function KTe(t={}){zTe(t),U1.info(`config \u2190 web: provider=${Nt.provider} baseUrl="${Nt.baseUrl}" model=${Nt.model} key=${Nt.apiKey?Nt.apiKey.slice(0,7)+"\u2026":"(none)"}`),F1.set(HTe,{...Nt}).catch(()=>{})}async function YTe(){if($Te)return!0;$Te=!0;try{let t=await F1.get(HTe);t&&typeof t=="object"&&zTe(t),U1.info(`config \u2190 kv (restart restore): provider=${Nt.provider} baseUrl="${Nt.baseUrl}" model=${Nt.model} key=${Nt.apiKey?"kept":"(none)"}`)}catch{}return!0}function XTe(){return{...Nt,apiKey:void 0,ready:!!Nt.apiKey,busy:HS}}function Jht(t){if(!t||typeof t!="object")return null;if(t.role==="user"&&t.parts){let e=t.parts.filter(r=>typeof r?.text=="string"&&r.text).map(r=>r.text).join(""),n=t.parts.filter(r=>r?.functionResponse);return n.length?{role:"tool",results:n.map(r=>({name:r.functionResponse.name,output:r.functionResponse.response}))}:e?{role:"user",text:e}:null}if(t.role==="model"&&Array.isArray(t.parts)){let e=t.parts.filter(r=>typeof r?.text=="string"&&r.text).map(r=>r.text).join(""),n=t.parts.filter(r=>r?.functionCall).map((r,i)=>({id:`${r.functionCall.name}-${i}`,name:r.functionCall.name,args:r.functionCall.args||{}}));return{role:"assistant",text:e,calls:n}}return null}async function JTe(){if(ol)return ol;try{ol=await F1.get(GTe)||[]}catch{ol=[]}return Array.isArray(ol)||(ol=[]),ol=ol.map(t=>t&&!t.parts&&(t.role==="user"||t.role==="assistant"||t.role==="tool")?t:Jht(t)).filter(Boolean),ol}async function Qht(){try{await F1.set(GTe,ol.slice(-jTe))}catch{}}function nz(){return Sk().map(({name:t,description:e,inputSchema:n})=>({name:t,description:e,parameters:n}))}function Zht(t){return t.map(e=>e.role==="user"?{role:"user",parts:[{text:e.text}]}:e.role==="tool"?{role:"user",parts:e.results.map(n=>({functionResponse:{name:n.name,response:n.output}}))}:{role:"model",parts:[...e.text?[{text:e.text}]:[],...(e.calls||[]).map(n=>({functionCall:{name:n.name,args:n.args}}))]})}async function emt(t){let{GoogleGenAI:e}=await Promise.resolve().then(()=>(qTe(),BTe)),i=(await new e({...Nt.baseUrl?{httpOptions:{baseUrl:Nt.baseUrl}}:{},apiKey:Nt.apiKey}).models.generateContent({model:Nt.model,contents:Zht(t),config:{systemInstruction:tz,tools:[{functionDeclarations:nz()}]}}))?.candidates?.[0]?.content?.parts||[];return{text:i.filter(s=>typeof s?.text=="string"&&s.text).map(s=>s.text).join(""),calls:i.filter(s=>s?.functionCall).map((s,o)=>({id:`${s.functionCall.name}-${o}`,name:s.functionCall.name,args:s.functionCall.args||{}}))}}function tmt(t){let e=[{role:"system",content:tz}];for(let n of t)if(n.role==="user")e.push({role:"user",content:n.text});else if(n.role==="assistant")e.push({role:"assistant",content:n.text||null,...n.calls?.length?{tool_calls:n.calls.map(r=>({id:r.id,type:"function",function:{name:r.name,arguments:JSON.stringify(r.args||{})}}))}:{}});else if(n.role==="tool")for(let r of n.results)e.push({role:"tool",tool_call_id:r.callId||r.name,content:JSON.stringify(r.output)});return e}function nmt(){let t="",e=[];return{push(n){typeof n?.content=="string"&&(t+=n.content);for(let r of n?.tool_calls||[]){let i=r.index??0;e[i]=e[i]||{id:"",name:"",args:""},r.id&&(e[i].id=r.id),r.function?.name&&(e[i].name+=r.function.name),typeof r.function?.arguments=="string"&&(e[i].args+=r.function.arguments)}},result(){return{text:t,calls:e.filter(Boolean).map(n=>({id:n.id,name:n.name,args:QTe(n.args)}))}}}}async function rmt(t){let e=Nt.baseUrl||"https://openrouter.ai/api/v1",n=await fetch(`${e}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Nt.apiKey}`},body:JSON.stringify({model:Nt.model,stream:!0,messages:tmt(t),tools:nz().map(c=>({type:"function",function:c}))}),signal:AbortSignal.timeout(VTe)});if(!n.ok){let c=await n.json().catch(()=>null);throw new Error(c?.error?.message||`HTTP ${n.status}`)}if(!(n.headers.get("content-type")||"").includes("text/event-stream")){let c=(await n.json())?.choices?.[0]?.message||{};return{text:typeof c.content=="string"?c.content:"",calls:(c.tool_calls||[]).map(l=>({id:l.id,name:l.function?.name||"",args:QTe(l.function?.arguments)}))}}let i=nmt(),s=n.body.getReader(),o=new TextDecoder,a="";for(;;){let{done:c,value:l}=await s.read();if(c)break;a+=o.decode(l,{stream:!0});let u;for(;(u=a.indexOf(`
|
|
511
511
|
`))>=0;){let f=a.slice(0,u).trim();if(a=a.slice(u+1),!f.startsWith("data:"))continue;let p=f.slice(5).trim();if(p==="[DONE]")return i.result();let m;try{m=JSON.parse(p)}catch{continue}if(m.error)throw new Error(m.error?.message||"stream error");i.push(m.choices?.[0]?.delta)}}return i.result()}function imt(t){let e=[];for(let n of t)n.role==="user"?e.push({role:"user",content:n.text}):n.role==="assistant"?e.push({role:"assistant",content:[...n.text?[{type:"text",text:n.text}]:[],...(n.calls||[]).map(r=>({type:"tool_use",id:r.id,name:r.name,input:r.args}))]}):n.role==="tool"&&e.push({role:"user",content:n.results.map(r=>({type:"tool_result",tool_use_id:r.callId||r.name,content:JSON.stringify(r.output)}))});return e}async function smt(t){let e=Nt.baseUrl||"https://api.anthropic.com",n=await fetch(`${e}/v1/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":Nt.apiKey,"anthropic-version":"2023-06-01"},body:JSON.stringify({model:Nt.model,max_tokens:4096,system:tz,messages:imt(t),tools:nz()}),signal:AbortSignal.timeout(VTe)}),r=await n.json();if(!n.ok)throw new Error(r?.error?.message||`HTTP ${n.status}`);let i=r?.content||[];return{text:i.filter(s=>s.type==="text").map(s=>s.text).join(""),calls:i.filter(s=>s.type==="tool_use").map(s=>({id:s.id,name:s.name,args:s.input||{}}))}}function QTe(t){if(typeof t!="string")return t||{};try{return JSON.parse(t)}catch{return{}}}async function omt(t,e){let n=yd.find(r=>r.name===t);if(!n)return{error:`unknown tool: ${t}`};try{let r=await n.run(e||{},{sessionId:"jarvis-agent"});return r?.error?{error:r.error}:typeof r=="string"?{result:r.slice(0,WTe)}:r}catch(r){return{error:r.message}}}async function rz(t,e){if(HS)return{error:"a turn is already running \u2014 wait for it to finish"};if(!Nt.apiKey)return{error:"no API key \u2014 add one in Settings \u2192 Jarvis"};HS=!0;try{let n=e||(()=>{}),r=await JTe();r.push({role:"user",text:String(t||"")});let i=Xht||(Nt.provider==="openai"?rmt:Nt.provider==="anthropic"?smt:emt);U1.info(`turn: provider=${Nt.provider} baseUrl="${Nt.baseUrl}" model=${Nt.model} history=${r.length}`);let s="";for(let o=0;o<zht;o++){let{text:a,calls:c}=await i(r);if(r.push({role:"assistant",text:a,calls:c}),!c.length){s=a||"(no answer)";break}let l=[];for(let u of c){n("tool",{name:u.name,args:u.args||{}});let f=await omt(u.name,u.args),p=JSON.stringify(f).slice(0,WTe);n("toolResult",{name:u.name,result:p}),l.push({callId:u.id,name:u.name,output:f})}r.push({role:"tool",results:l})}return s||(s="tool-call loop limit reached \u2014 stopped for safety, ask me again to continue"),n("assistant",{text:s}),await Qht(),{text:s}}catch(n){return U1.error(`agent turn failed: ${n.message}`),{error:`${Nt.provider} error: ${n.message}`}}finally{HS=!1}}async function ZTe(t){return!Nt.apiKey||HS?{skipped:!0}:await rz(t,()=>{})}async function eAe(){return(await JTe()).slice(-jTe)}var U1,F1,GTe,HTe,jTe,zht,WTe,VTe,tz,Kht,Yht,Nt,HS,ol,Xht,$Te,iz=ae(()=>{di();xk();st();U1=be("jarvis"),F1={get:Ip,set:Rp},GTe="jarvis:chat",HTe="jarvis:agentConfig",jTe=60,zht=8,WTe=4e3,VTe=12e4,tz="You are Jarvis \u2014 the conductor coordinating worker sessions (AI CLIs and terminals) on this machine. The user chats to delegate work and ask about status. Convention: when the user asks to 'create a task/job in workspace X', OPEN a worker session in that workspace (create_session with the workspace taken from list_fleet's workspacePath, default engine claude), delegate via dispatch_prompt, and record a manage_kanban card for that workspace. When woken because a worker finished or awaits approval: check with list_fleet, update the board, report only what matters. When a worker is done and no longer needed, close_session to free its resources. Reply briefly, in the user's language.",Kht=["gemini","openai","anthropic"],Yht={provider:"gemini",baseUrl:"",model:"gemini-3.8-flash"},Nt={...Yht,apiKey:""},HS=!1,ol=null,Xht=null,$Te=!1});function cmt({wake:t=ZTe,refreshBoard:e=async()=>{await wk(await T_())},debounceMs:n=amt,enabled:r=!0}={}){let i=r,s=[],o=null;return{setWakeEnabled(a){i=!!a},onWorkerDone(a){!i||!a||(s.includes(a)||s.push(a),e(),o&&clearTimeout(o),o=setTimeout(()=>{o=null,this._flush()},n))},async _flush(){let a=s;if(s=[],!a.length)return;let c=a.length===1?`Worker ${a[0]}`:`Workers ${a.join(", ")}`;try{await t(`[9remote] ${c} changed state (finished or awaiting approval) \u2014 check with list_fleet, update the kanban board if needed, and only report back briefly when something matters.`)}catch{}}}}function rAe(t){nAe.setWakeEnabled(t)}function sz(t){nAe.onWorkerDone(t)}function iAe(){tAe||(tAe=!0,gr.onEvent((t,e)=>{e==="turn_complete"&&sz(t)}))}var amt,nAe,tAe,oz=ae(()=>{$f();_k();zw();iz();amt=3e3;nAe=cmt({enabled:!1}),tAe=!1});function oAe(t){lmt&&(iAe(),YTe(),t.on("jarvis:getState",async(e,n)=>{try{let r=await T_(),i=await wk(r);n?.({ok:!0,board:i,fleet:r})}catch(r){az.error(`getState failed: ${r.message}`),n?.({ok:!1,error:r.message})}}),t.on("jarvis:kanban",async({action:e}={},n)=>{try{let r=await A_(e,"web");n?.(r.error?{ok:!1,error:r.error}:{ok:!0,board:r.board})}catch(r){az.error(`kanban action failed: ${r.message}`),n?.({ok:!1,error:r.message})}}),t.on("jarvis:tools",(e,n)=>n?.({ok:!0,tools:Sk()})),t.on("jarvis:tool",async({name:e,args:n}={},r)=>{let i=yd.find(s=>s.name===e);if(!i)return r?.({ok:!1,error:`unknown tool: ${e}`});try{let s=await i.run(n||{},{sessionId:"jarvis-live"});r?.(s?.error?{ok:!1,error:s.error}:{ok:!0,result:typeof s=="string"?s:JSON.stringify(s)})}catch(s){az.error(`live tool ${e} failed: ${s.message}`),r?.({ok:!1,error:s.message})}}),t.on("jarvis:agentConfig",({apiKey:e,model:n,wake:r}={},i)=>{KTe({apiKey:e,model:n}),r!==void 0&&rAe(!!r),i?.({ok:!0,...XTe()})}),t.on("jarvis:chatHistory",async(e,n)=>{try{n?.({ok:!0,history:await eAe()})}catch(r){n?.({ok:!1,error:r.message})}}),t.on("jarvis:chat",async({text:e}={},n)=>{if(!e||typeof e!="string")return n?.({ok:!1,error:"text is required"});sAe("jarvis:chat:event",{type:"user",text:e.slice(0,2e3)});let r=await rz(e,(i,s)=>sAe("jarvis:chat:event",{type:i,...s}));n?.(r.error?{ok:!1,error:r.error}:{ok:!0,text:r.text})}))}var az,lmt,sAe,aAe=ae(()=>{_k();zw();oz();iz();xk();yf();Ji();st();az=be("jarvis"),lmt=!1,sAe=(t,e)=>{let n=qa();n&&et(n,t,e)}});function fAe(){let t="";for(let e=0;e<umt;e++)t+=cAe[cz.default.randomInt(cAe.length)];return t}function lz(){let t=QJ(uAe,null);return!t||Date.now()>t.expiresAt?null:t}function dAe(t){try{Sn(uAe,t)}catch(e){B1.error(`persist pairing state: ${e.message}`)}}function pAe(t,e,n,r=null){dAe({tempKey:t,tail:e,expiresAt:n,workerUrl:r})}function fmt(){dAe({tempKey:null,tail:null,expiresAt:0,workerUrl:null})}async function dmt(t,e){if(!(!t||!e))try{await ac(`${e}/api/temp-key/remove`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempKey:t})}),B1.info(`one-time code revoked at the Worker: ${t}`)}catch(n){B1.warn(`could not revoke the code at the Worker: ${n.message}`)}}function jS(){let t=lz();return t?{tempKey:t.tempKey,tail:t.tail,expiresAt:t.expiresAt}:null}function q1(t){let e=lz();if(!e?.tail||!t)return!1;let n=Buffer.from(String(t).toUpperCase(),"utf8"),r=Buffer.from(String(e.tail).toUpperCase(),"utf8");return n.length===r.length&&cz.default.timingSafeEqual(n,r)}function uz(t){if(q1(t))return!0;let e=lz();return!e||!t||(fmt(),B1.warn("pairing tail mismatch \u2014 code killed here and at the Worker"),dmt(e.tempKey,e.workerUrl)),!1}var cz,lAe,B1,uAe,cAe,umt,fz=ae(()=>{cz=ce(require("crypto"),1),lAe=require("path");Lt();st();_o();Lt();B1=be("pairing"),uAe=(0,lAe.join)(Oe.STATE,"pairing.json"),cAe="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789",umt=2});function mAe(){let t="";for(let e=0;e<pmt;e++)t+=hAe[dz.default.randomInt(hAe.length)];return t}function gAe(t){return`sk-${(t||"").slice(0,8).toLowerCase()}-${mAe()}-${mAe()}`}function yAe(t){return/^sk-[a-z0-9]{8}-[a-np-z1-9]{8}-[a-np-z1-9]{8}$/.test(t||"")}function $n(t){if(!yAe(t))return t||null;let e=t.split("-");return`${e[0]}-${e[1]}-${e[2]}`}function $1(t){return yAe(t)?t.split("-")[3]:null}function G1(t,e){if(typeof t!="string"||!t||typeof e!="string"||!e)return!1;let n=Buffer.from($n(t)||"","utf8"),r=Buffer.from($n(e)||"","utf8");return n.length>0&&n.length===r.length&&dz.default.timingSafeEqual(n,r)}var dz,uMt,hAe,pmt,Ld=ae(()=>{dz=ce(require("crypto"),1),uMt=process.env.API_KEY_SECRET||process.env.APP_SECRET,hAe="abcdefghijklmnpqrstuvwxyz123456789",pmt=8});var SAe={};dr(SAe,{PROOF_DEADLINE:()=>vz,admissionGate:()=>Ez,clearProofWaiters:()=>_z,finishTailRejection:()=>W1,handleTailProof:()=>wz,isProvingExpired:()=>vmt,isTailProofEnabled:()=>cv,noteTailFailure:()=>VS,onTailProven:()=>j1,presentedTailOf:()=>zS,submitTailProof:()=>H1,verdictStateOf:()=>WS,verifyKeyTail:()=>lv,verifyPresentedTail:()=>wmt});function wAe(){return $1(Xi()?.key||"")}function cv(){return!!wAe()}function yz(t,e){let n=t?mz.get(t):null;return!n||n.keyHead!==e?null:n}function vAe(t,e,n,r=null){if(!t)return;let i=mz.get(t);mz.set(t,{keyHead:e,state:n,reason:r,since:Date.now()}),n!==i?.state&&(n===yo.proven&&Emt(t),n===yo.rejected&&Uu.delete(t))}function H1(t,e,{pairing:n=!1}={}){let r=$n(Xi()?.key||"");if(!t||!cv()&&!n)return!1;if(n?uz(e):lv(e))return vAe(t,r,yo.proven),K7(t,r),hz.info(`[seal] proof accepted: device=${t.slice(0,8)}`),!0;let s=e===null?Jr.sealUnreadable:Jr.mismatch;return vAe(t,r,yo.rejected,s),hz.warn(`[seal] proof rejected (${s}): device=${t.slice(0,8)}`),!1}function vmt(t){let e=yz(t,$n(Xi()?.key||""));return!!e&&e.state===yo.proving&&Date.now()-e.since>gz}function WS(t){return yz(t,$n(Xi()?.key||""))?.state||null}function j1(t,e,n){if(!t||!cv()||WS(t)===yo.proven)return e();Uu.has(t)||Uu.set(t,new Set),Uu.get(t).add(e),n&&setTimeout(()=>{let r=Uu.get(t);r?.delete(e)&&(r.size||Uu.delete(t),n())},gz)}function Emt(t){let e=Uu.get(t);if(e){Uu.delete(t);for(let n of e)try{n()}catch{}}}function _z(t){Uu.delete(t)}function VS(t){let e=Date.now(),n=(_Ae.get(t)||[]).filter(i=>e-i<ymt);n.push(e),_Ae.set(t,n);let r=n.length-hmt;return r<=0?0:Math.min(mmt*2**(r-1),gmt)}function wmt({tail:t,tempKey:e}={}){let n=!!e;return!n&&!cv()?{ok:!0}:t?(n?uz(t):lv(t))?{ok:!0}:{ok:!1,reason:Jr.mismatch,penaltyMs:VS($n(Xi()?.key||""))}:{ok:!1,reason:Jr.mismatch,penaltyMs:0}}function Ez(t,e,{provenSocket:n=!1,tempKey:r=null}={}){let i=$n(Xi()?.key||""),s=_0(t);if(s===zi.rejected)return{step:"authz",decision:Sr.reject,reason:"device-rejected"};let o=!!r&&!RT(t);if(o){let a=jS();hz.info(`[pair] device=${t?.slice(0,8)} presented=${e===void 0?"none":String(e).length+"ch"} liveCode=${a?"yes":"no"} liveTail=${a?.tail?String(a.tail).length+"ch":"none"} match=${e===void 0?"n/a":q1(String(e))}`)}if(cv()||o){let a=yz(t,i);if(a?.state===yo.rejected&&e===void 0)return{step:"auth",decision:Sr.reject,reason:a.reason};let c=u=>o?q1(u):lv(u);if(!(n||a?.state===yo.proven||e!==void 0&&c(e)))return e!==void 0?{step:"auth",decision:Sr.reject,reason:e===null?Jr.sealUnreadable:Jr.mismatch}:{step:"auth",decision:Sr.hold,reason:"awaiting-proof"}}return s===zi.approved||s===zi.auto?{step:"authz",decision:Sr.admit}:{step:"authz",decision:Sr.hold,reason:"host-decides"}}function lv(t){let e=wAe();if(!e||!t)return!1;let n=Buffer.from(String(t),"utf8"),r=Buffer.from(e,"utf8");return n.length===r.length&&EAe.default.timingSafeEqual(n,r)}function zS(t,e){let n=t?.keyTailSealed;return n!==void 0?!n||typeof n!="object"||Array.isArray(n)?null:e(n)??null:t?.keyTail}function wz(t,e){let n=t?.data?.auth?.deviceId||t.handshake?.auth?.deviceId||t.deviceId||null,i=!!(t.handshake?.auth?.tempKey||e?.tempKey||null)&&!!jS();if(!n||!cv()&&!i)return!0;let s=zS(e,s0);return s===void 0||H1(n,s,{pairing:i})?!0:(t.data.tailReject={reason:s===null?Jr.sealUnreadable:Jr.mismatch,penaltyMs:VS($n(Xi()?.key||""))},!1)}function W1(t,e){if(t.data?.tailRejectFinished)return;t.data.tailRejectFinished=!0;let{reason:n,penaltyMs:r=0}=t.data?.tailReject||{},i=pz>=_mt,s=i?0:r;i||pz++,setTimeout(()=>{i||pz--;try{t.emit("device:tailRejected",{reason:n}),t.disconnect()}catch{}e?.()},s)}var EAe,hz,hmt,mmt,gmt,ymt,_mt,_Ae,pz,mz,gz,Uu,vz,Sz=ae(()=>{EAe=ce(require("crypto"),1);st();E0();fz();Ki();Ld();hf();o0();hz=be("deviceAuth");hmt=5,mmt=1e3,gmt=60*1e3,ymt=3600*1e3,_mt=20,_Ae=new Map,pz=0,mz=new Map,gz=2e4;Uu=new Map;vz=gz});var Yr,V1,KS=ae(()=>{Yr={authenticating:"authenticating",awaitingHost:"awaitingHost",active:"active",closed:"closed"},V1=new Set(["device:tailProof","device:clientReady","disconnect"])});var xAe,z1,bAe=ae(()=>{xAe=require("events");KS();z1=class extends xAe.EventEmitter{constructor({deviceId:e,peerId:n=null,apiKey:r=null}){super(),this.setMaxListeners(0),this.deviceId=e,this.peerId=n||e,this.apiKey=r,this.createdAt=Date.now(),this.data={},this._state=Yr.authenticating,this._carriers=new Map}get state(){return this._state}get active(){return this._state===Yr.active}get closed(){return this._state===Yr.closed}get carrierIds(){return[...this._carriers.keys()]}get connected(){for(let e of this._carriers.values())if(e?.ready)return!0;return!1}attach(e,n){if(this.closed)return!1;let r=this._carriers.get(e);return r&&r!==n&&this._detachOne(e,r),this._carriers.set(e,n),this.emit("carrierAttached",e,n),!0}detach(e){let n=this._carriers.get(e);return n?(this._detachOne(e,n),!0):!1}_detachOne(e,n){this._carriers.delete(e),this.emit("carrierDetached",e,n)}hasCarrier(e){return this._carriers.has(e)}carrier(e){return this._carriers.get(e)||null}allows(e){return this.active?!0:this.closed?!1:V1.has(e)}keyProven(){return this._state!==Yr.authenticating?!1:this._transition(Yr.awaitingHost,"key-proven")}hostAllowed(){return this._state!==Yr.awaitingHost?!1:this._transition(Yr.active,"host-allowed")}close(e="closed"){if(this.closed)return!1;for(let[n,r]of[...this._carriers])this._detachOne(n,r);return this._transition(Yr.closed,e)}_transition(e,n){let r=this._state;return this._state=e,this.emit("state",{from:r,to:e,reason:n,deviceId:this.deviceId}),!0}toJSON(){return{deviceId:this.deviceId,peerId:this.peerId,state:this._state,carriers:this.carrierIds,createdAt:this.createdAt}}}});var K1,TAe=ae(()=>{bAe();KS();K1=class{constructor(){this._byPeer=new Map,this._byDevice=new Map}open({deviceId:e,peerId:n,apiKey:r}){let i=n||e,s=this._byPeer.get(i);if(s&&!s.closed)return s;let o=new z1({deviceId:e,peerId:i,apiKey:r});return this._byPeer.set(i,o),this._byDevice.has(e)||this._byDevice.set(e,new Set),this._byDevice.get(e).add(i),o.on("state",a=>{a.to===Yr.closed&&this.delete(i)}),o}get(e){let n=this._byPeer.get(e);return n&&!n.closed?n:null}forDevice(e){let n=this._byDevice.get(e);if(!n)return[];let r=[];for(let i of n){let s=this._byPeer.get(i);s&&!s.closed&&r.push(s)}return r}closeDevice(e,n){let r=this.forDevice(e);for(let i of r)i.close(n);return r.length}delete(e){let n=this._byPeer.get(e);if(!n)return!1;this._byPeer.delete(e);let r=this._byDevice.get(n.deviceId);return r&&(r.delete(e),r.size||this._byDevice.delete(n.deviceId)),!0}get size(){return this._byPeer.size}all(){return[...this._byPeer.values()]}}});function AAe(t,e){return!t||t.closed?{effects:[]}:e.decision===Sr.reject?{effects:["refuse"],reason:e.reason||Jr.mismatch}:e.decision===Sr.hold&&e.step==="auth"?t.state===Yr.authenticating?{effects:["open-auth-channel"],reason:e.reason}:{effects:[],reason:e.reason}:(t.state===Yr.authenticating&&t.keyProven(),e.decision===Sr.hold?{effects:["ask-host"],reason:e.reason}:(t.state===Yr.awaitingHost&&t.hostAllowed(),{effects:t.active?["start-session"]:[]}))}var CAe=ae(()=>{KS();Ki()});function ec(){try{let t=(0,kAe.join)(Oe.ROOT,"keys.json");return JSON.parse((0,IAe.readFileSync)(t,"utf8")).key||null}catch{return null}}function qa(){return to}function YS(t){return t.carrier||{id:"ws",ip:t.handshake?.headers?.["x-forwarded-for"]||t.handshake?.address||"unknown",pendingId:t.id}}function er(t){return t?.data?.auth||t?.handshake?.auth||null}function bz(t,e){let n=t?zS(er(t),s0):void 0,r=Ez(e,n,{provenSocket:t?.data?.provenDevice===!0,tempKey:er(t)?.tempKey||null});Rr.info(`gate: device=${e?.slice(0,8)??"none"} step=${r.step} decision=${r.decision}${r.reason?` reason=${r.reason}`:""} carrier=${t?YS(t).id:"signaling"}`);let i=!!er(t)?.tempKey,s=r.step==="authz"&&!i;return t&&n!==void 0&&(s||r.step==="auth")&&H1(e,n,{pairing:i}),t&&r.decision===Sr.reject&&r.step==="auth"&&(t.data.tailReject=t.data.tailReject||{reason:r.reason,penaltyMs:VS($n(ec()||""))}),r}function xmt(t){t.data.authHandlersReady||(t.data.authHandlersReady=!0,t.on("device:tailProof",e=>{let n=er(t)?.deviceId;e?.tempKey&&t.data&&(t.data.auth||(t.data.auth={}),t.data.auth.tempKey=e.tempKey);try{let r=wz(t,e);Rr.info(`tailProof: device=${n?.slice(0,8)} carrier=${YS(t).id} accepted=${r}`),r||uv(t,n)}catch(r){Rr.warn(`tailProof handler failed: ${r.message}`)}}))}async function XS(t){if(er(t)?.tempKey&&(Rr.info("one-time key used \u2014 clearing from UI"),xT()),await Amt(t),xmt(t),!t.data.localUi){let e=er(t)?.deviceId||null,n=Cmt(t);if(!n)return;let{id:r}=YS(t);n.attach(r,t.data.protocol?._adapters?.get(r)||null);let i=bz(t,e),{effects:s,reason:o}=AAe(n,i);if(Rr.info(`flow: device=${e?.slice(0,8)} state=${n.state} effects=[${s.join(",")}]${o?` reason=${o}`:""}`),Xt(`[auth] ${e?.slice(0,8)}: ${n.state} \u2192 ${s.join(",")||"wait"}`),s.includes("refuse")){uv(t,e,o);return}if(s.includes("open-auth-channel")){t.data.awaitingProof||(t.data.awaitingProof=!0,j1(e,()=>{t.data.awaitingProof=!1,t.connected&&XS(t).catch(()=>{})},()=>uv(t,e,Jr.timeout)));return}if(s.includes("ask-host")){let a=YS(t);Iz(e,{socketId:a.pendingId,ip:a.ip,peerId:t.peerId,notify:()=>lm(t,"device:pendingApproval")});return}if(!s.includes("start-session"))return;_0(e)===zi.auto&&(IT(e),Og(e),Jn("deviceApproval",{action:"refresh"}))}await Tmt(t)}function bmt(t){if(!er(t)?.tempKey)return;let e=$1(ec()||"");e&&Rz(t,()=>{lm(t,"device:keyIssued",{tail:e}),Rr.info(`key issued to paired device=${er(t)?.deviceId?.slice(0,8)}`)})}function PAe(t){if(!t.connected||!t.data?.conn?.active&&!t.data?.localUi||!t.data?.clientReady)return;X1(t),bmt(t);let e=Vf._buildServerInfo?.();e&&t.emit("serverInfo",e),t.emit("srvCaps",{env2:1,fragCtl:1}),t.emit("tunnel:updated",ST())}async function Tmt(t){t.data.sessionReady||(t.data.sessionReady=!0,t.data.approved=!0,r_e(t),s_e(t),j_e(t),X_e(t),kve(t,to),oAe(t),await Hq(t,to,ec()),PAe(t),t.emit("terminal:ready"))}async function Amt(t){if(t.data.protocol)return;let{webrtc:e,streaming:n}=Te,r=new PT(t,{enableWebRTC:e.enableWebRTC,enableTurn:e.enableTurn??!1,apiKey:$n(ec()),turnApiUrl:e.turnApiUrl||null,turnRefreshInterval:e.turnRefreshInterval,dcMaxMessageSize:e.dcMaxMessageSize,dcChunkSize:e.dcChunkSize,dcMaxTilesPerFrame:e.dcMaxTilesPerFrame,answerTimeout:e.answerTimeout,maxControlBuffer:e.maxControlBuffer,wsChunkSize:n.chunkSize,signaling:{deviceId:t.peerId||er(t)?.peerId||er(t)?.deviceId||null,doUrl:e.signalingDoUrl,apiKey:ec()}});t.data.protocol=r,t.defersWsAdapter&&(r._onDead=()=>{Rr.debug(`[diag] _onDead fired peer=${(t.peerId||"").slice(0,12)} \u2014 rtc never returned in grace`),Ii(`RTC session closed: ${er(t)?.deviceId?.slice(0,8)}...`);try{r.close()}catch{}wp(r),t.disconnect()}),S7(r),r.attachAsBus(t);try{await r.init()}catch(i){console.error("[transport] pm init failed:",i.message)}}function Cmt(t){let e=er(t)?.deviceId||null;if(!e)return null;let n=t.peerId||er(t)?.peerId||e,r=t.data.conn;if(r&&!r.closed)return r;let i=Tz.open({deviceId:e,peerId:n,apiKey:ec()});return t.data.conn=i,i}function _L(){return Az}function F7(t){if(Az=t,!t){C7();return}T7();for(let e of[...eo.keys()])fv(e),Ii(`RTC test-disabled: killed session ${e?.slice(0,8)}`)}function Rz(t,e){t.data.clientReady?e():t.once("device:clientReady",e)}function OAe(t){t.data.clientReady=!1,t.on("device:clientReady",()=>{t.data.clientReady=!0,PAe(t)})}function Rmt(t){if(!t)return;if(Az){Y1(t,{type:"error",message:"rtc-disabled"});return}let e=t.split(":")[0],n=eo.get(t);if(n){if(!n.data.protocol?._closed)return;Ii(`Stale RTC session ${e.slice(0,8)} \u2014 rebuilding`),fv(t)}let r=Imt(t),i=bz(null,e);if(i.decision===Sr.hold&&i.step==="auth")return r?void 0:(Rr.info(`rtc-offer: building session so the TAIL proof has a road device=${e.slice(0,8)}`),void xz(t,e));switch(i.decision){case Sr.admit:return r?void 0:void xz(t,e);case Sr.reject:TL(e,RAe(t),"rtc"),Y1(t,{type:"error",message:fg.rejected}),Xb(t),Xt(`Rejected device via RTC: ${e.slice(0,8)} \u2014 waiting in Clients list`),Jn("deviceApproval",{action:"refresh"});return;default:Iz(e,{socketId:RAe(t),ip:"rtc",peerId:t,notify:()=>Y1(t,{type:"error",message:fg.pending})})}}function Iz(t,{socketId:e,ip:n,peerId:r,notify:i}){if(i(),X7(t)){Xt(`[auth] already pending, not asking twice: ${t?.slice(0,8)}`);return}SL(e,{deviceId:t,ip:n,...r?{peerId:r}:{}}),Rr.info(`asking host: device=${t?.slice(0,8)} via=${r?"rtc":"ws"}`),Xt(`[auth] ASKING HOST: ${t?.slice(0,8)} via=${r?"rtc":"ws"} socketId=${e}`),Xt(`Device needs approval: ${t?.slice(0,8)||"no-id"}`),Jn("deviceApproval",{socketId:e,deviceId:t,ip:n,action:"pending"})}function Imt(t){for(let e of to?.sockets.sockets.values()||[])if(e.connected&&er(e)?.peerId===t)return!0;return!1}function lm(t,e,...n){let r=t.data?.protocol;r&&!r._closed&&r.emitEverywhere(e,...n)||t.emit(e,...n)}function X1(t){let e=()=>{t.connected&&Rz(t,()=>lm(t,"device:approved"))};if(t.data.localUi)return e();let n=t.data.conn;if(n?.active)return e();if(n)return void n.on("state",function r(i){i.to===Yr.closed&&n.off("state",r),i.to===Yr.active&&(n.off("state",r),e())})}function MAe(t){return t.data.approved||t.data.unlocking?Promise.resolve():(t.data.unlocking=!0,X1(t),XS(t).catch(n=>Xt(`Feature setup failed: ${n.message}`)).finally(()=>{t.data.unlocking=!1}))}async function NAe(t){if(!t)return;let e=v0(t);e&&bp(e);let n=[];for(let r of to?.sockets.sockets.values()||[])er(r)?.deviceId!==t||r.data.approved||n.push(MAe(r));for(let r of eo.values())er(r)?.deviceId!==t||r.data.approved||n.push(XS(r).catch(i=>Xt(`Connection resume failed: ${i.message}`)));await Promise.allSettled(n);for(let r of iJ(t))xz(r,t)}function uv(t,e,n){Rr.debug(`[diag] rejectDeviceTail device=${e?.slice(0,8)} reason=${n}`),t.data.tailReject=t.data.tailReject||{reason:n,penaltyMs:0};let r=t.data.tailReject.reason;Rr.warn(`tail rejected (${r}): device=${e?.slice(0,8)??"none"} carrier=${YS(t).id}`),Xt(`Device refused (${r}): ${e?.slice(0,8)}`),er(t)?.tempKey&&r===Jr.mismatch&&(Rr.warn("one-time key burned (wrong TAIL) \u2014 clearing from UI"),xT()),W1(t,()=>{t.defersWsAdapter&&fv(t.peerId),DAe(e,r)})}function DAe(t,e){if(Rr.debug(`[diag] revokeDevice device=${t?.slice(0,8)} reason=${e}`),!!t){_z(t),bp(v0(t)||""),Tz.closeDevice(t,e);for(let n of to?.sockets.sockets.values()||[])er(n)?.deviceId===t&&(n.data.tailReject=n.data.tailReject||{reason:e,penaltyMs:0},W1(n));for(let[n,r]of eo)er(r)?.deviceId===t&&(r.data?.tailReject||fv(n))}}function LAe(t){let e=xL(t);if(e)return{key:t,...e};let n=Cz(t)?.split(":")[0]||er(to?.sockets.sockets.get(t)||null)?.deviceId||null,r=n?v0(n):null,i=r?xL(r):null;return i?{key:r,...i}:null}function fv(t){let e=t?eo.get(t):null;if(!e)return;let n=e.data?.protocol;eo.delete(t);try{e.disconnect()}catch{}if(n){try{n.close()}catch{}wp(n)}}function xz(t,e){kmt(t,e).catch(n=>{fv(t),Xt(`RTC session failed: ${n.message}`)})}async function kmt(t,e){if(eo.has(t))return;let n=new Jb({deviceId:e,peerId:t,apiKey:ec()});n.data.approved=!1,n.data.rtcSession=!0,n.data.conn=Tz.open({deviceId:e,peerId:t,apiKey:ec()}),OAe(n);let r;n.data.ready=new Promise(i=>{r=i}),eo.set(t,n),AT(n.id,"rtc",e,"rtc"),n.on("disconnect",()=>{Rr.debug(`[diag] AgentBus disconnect peer=${(t||"").slice(0,12)} \u2192 untrack + conn.close`),eo.get(t)===n&&eo.delete(t),CT(n.id),n.data.conn?.close("carrier-gone"),r()}),Ii(`RTC session: ${e.slice(0,8)}...`);try{await XS(n)}finally{r()}setTimeout(()=>{eo.get(t)===n&&WS(e)!==yo.proven&&(Xt(`Device never proved its TAIL: ${e.slice(0,8)} \u2014 dropping session`),uv(n,e,Jr.timeout))},vz+1e3),X1(n)}function UAe(t){if(!to)return!1;let e=LAe(t);return e?WS(e.deviceId)===yo.rejected?(Rr.warn(`approve refused \u2014 TAIL was rejected: device=${e.deviceId.slice(0,8)}`),Xt(`Cannot approve ${e.deviceId.slice(0,8)} \u2014 wrong access key`),bp(e.key),DAe(e.deviceId,Jr.mismatch),Jn("deviceApproval",{action:"refresh"}),!1):(IT(e.deviceId),Og(e.deviceId),Xt(`Device approved: ${e.deviceId.slice(0,8)}...`),NAe(e.deviceId),Jn("deviceApproval",{action:"refresh"}),!0):!1}function FAe(t){return!to||!t?!1:(IT(t),Og(t),Xt(`Device approved from pending: ${t.slice(0,8)}...`),NAe(t),Jn("deviceApproval",{action:"refresh"}),!0)}function J1(t){Rr.debug(`[diag] disconnectDeviceSockets device=${t?.slice(0,8)} \u2014 stack hint: ${new Error().stack.split(`
|
|
512
512
|
`)[2]?.trim()?.slice(0,90)}`);let e=to;if(!e||!t)return 0;let n=0;for(let r of e.sockets.sockets.values())er(r)?.deviceId===t&&(r.disconnect(!0),n++);for(let r of x7())r._closed||r._deviceId?.split(":")[0]===t&&(p0(r),n++);for(let[r,i]of eo)if(r.split(":")[0]===t){try{i.data.protocol?.close()}catch{}wp(i.data.protocol),Xb(r),i.disconnect(),n++}return n&&Ii(`Disconnected ${n} socket(s) for device ${t.slice(0,8)}...`),n}function BAe(t){if(!to)return!1;let e=LAe(t),n=to.sockets.sockets.get(t);bp(e?.key||t),e?.deviceId&&Q7(e.deviceId,{ip:e.ip,socketId:t}),n&&(lm(n,"device:rejected"),n.disconnect(!0));let r=e?.peerId||Cz(t);return r&&(Y1(r,{type:"error",message:fg.rejected}),Xb(r)),Jn("deviceApproval",{action:"refresh"}),Xt(`Device rejected: ${e?.deviceId?.slice(0,8)||"unknown"}...`),!0}async function qAe(t){H7(),eQ(),Jv($n(ec())),setInterval(()=>{let r=$n(ec());r&&Jv(r)},Smt),nJ(Rmt),Kb(()=>Ag());let e=new JX(t,{cors:{origin:"*",methods:["GET","POST"],credentials:!0,allowedHeaders:["*"]},allowRequest:(r,i)=>i(null,!Cx(r.headers.host)),transports:["websocket","polling"],allowEIO3:!0,allowUpgrades:!0,pingTimeout:3e4,pingInterval:12e3,maxHttpBufferSize:1e8,perMessageDeflate:{threshold:1024}}),n=await SZ();return XD(n),e.on("connection",r=>{sJ("client-connected");let i=r.handshake.headers["x-forwarded-for"]||r.handshake.address||"unknown",s=er(r)?.deviceId||null;OAe(r),r.data.approved=!1,r.use((p,m)=>{if(r.data.localUi)return m();let g=r.data.conn;return g?g.allows(p[0])?m():m(new Error("Device not approved")):V1.has(p[0])?m():m(new Error("Device not approved"))});let o=r.handshake.address||"",a=o==="127.0.0.1"||o==="::1"||o==="::ffff:127.0.0.1",c=!!r.handshake.headers["cf-connecting-ip"],l=r.handshake.headers.origin,u=!l||tp.includes(l);if(!c&&a&&u&&dJ(r.handshake.auth?.localToken)){r.data.approved=!0,r.data.localUi=!0,Ii("Local UI connected \u2014 trusted (token)"),XS(r).catch(p=>Xt(`Feature setup failed: ${p.message}`));return}if(s===ep){Xt(`Rejected untrusted local-ui socket from ${i}`),r.disconnect(!0);return}if(!c&&a&&u&&s&&!RT(s)){let p=zS(er(r),s0);p&&lv(p)&&_0(s)===zi.unknown&&(W7(s),Rr.info(`loopback workspace device admitted for this session (key TAIL verified): ${s.slice(0,8)}`),Ii(`Loopback workspace admitted (session): ${s.slice(0,8)} (key TAIL verified)`))}AT(r.id,i,s),Ii(`Client connected: ${i} (device: ${s?.slice(0,8)||"none"})`),r.on("disconnect",p=>{CT(r.id),bp(r.id);let m=r.data?.conn;m&&(m.detach("ws"),m.connected||m.close("carrier-gone"));let g=r.data?.protocol;Ii(`Client disconnected: ${i} (${p}) pm=${g?._deviceId?.slice(0,12)||"none"} remoteAttached=${!!r.data?.remoteAttached}`),g&&!r.data?.remoteAttached&&p0(g)});let f=()=>{if(!r.connected)return;let p=r.handshake.auth?.peerId||null,m=()=>{if(r.data.approved)return;let S=v0(s);if(S&&!Cz(S)){Ii(`Device ${s?.slice(0,8)} already pending, ignoring duplicate`),r.disconnect(!0);return}let T=!!S;S&&bp(S),Rz(r,()=>{if(!(r.data.approved||!r.connected)){if(T){SL(r.id,{deviceId:s,ip:i}),lm(r,"device:pendingApproval");return}Iz(s,{socketId:r.id,ip:i,notify:()=>lm(r,"device:pendingApproval")})}})},g=S=>{let T=S.data.conn;r.data.conn=T,r.data.approved=!!T?.active,r.data.rtcHost=S,Promise.resolve(S.data.ready).then(()=>S.data.protocol?.attachSocket(r)).then(()=>T?.attach("ws",S.data.protocol?._adapters?.get("ws")||null)).then(()=>{T?.active&&r.emit("terminal:ready")}).catch(R=>Xt(`RTC session attachSocket failed: ${R.message}`)),Ii(`Tunnel attached to RTC session: ${s.slice(0,8)}...`),X1(r)},y=p?eo.get(p):null;if(!y&&p&&!r.data._rtcWaited&&aJ(p)){r.data._rtcWaited=!0,Ii(`WS first, RTC offer pending \u2192 grace 500ms (device ${s.slice(0,8)})`),setTimeout(f,500);return}let w=bz(r,s);if(w.decision===Sr.hold&&w.step==="auth"){Rr.info(`route: awaiting TAIL proof device=${s?.slice(0,8)||"no-id"}`),j1(s,()=>f(),()=>{uv(r,s,Jr.timeout)});return}switch(w.decision){case Sr.admit:if(y)return void g(y);Ii(`Device admitted: ${s?.slice(0,8)}...`),MAe(r);return;case Sr.reject:{if(r.data?.tailReject)return void uv(r,s);TL(s,r.id,i),Xt(`Rejected device reconnected: ${s.slice(0,8)} \u2014 waiting in Clients list`),lm(r,"device:rejected"),Jn("deviceApproval",{action:"refresh"});return}default:Rr.info(`route: hold for approval device=${s?.slice(0,8)||"no-id"}`),Xt(`Device needs approval: ${s?.slice(0,8)||"no-id"}`),m()}};f()}),Vf(e,ec()),to=e,e}var IAe,kAe,Rr,Smt,to,eo,Tz,Az,RAe,Cz,Y1,yf=ae(()=>{QX();IAe=require("fs"),kAe=require("path");Qv();lJ();Lt();Qb();LO();nQ();Ki();Ji();Ur();Da();JT();i_e();o_e();W_e();J_e();Pve();aAe();Eo();E0();Sz();o0();Ki();Ld();st();TAe();CAe();KS();Rr=be("transport");Smt=5e3,to=null;eo=new Map,Tz=new K1;Az=!1;RAe=t=>`rtc-${t}`,Cz=t=>t.startsWith("rtc-")?t.slice(4):null,Y1=(t,e)=>Yb({...e,to:t});A7(fv)});var zAe=B((JS,kz)=>{(function(t,e){typeof JS=="object"&&typeof kz=="object"?kz.exports=e(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],e):typeof JS=="object"?JS["electron-machine-id"]=e(require("child_process"),require("crypto")):t["electron-machine-id"]=e(t.child_process,t.crypto)})(JS,function(t,e){return(function(n){function r(s){if(i[s])return i[s].exports;var o=i[s]={exports:{},id:s,loaded:!1};return n[s].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}var i={};return r.m=n,r.c=i,r.p="",r(0)})([function(n,r,i){n.exports=i(34)},function(n,r,i){var s=i(29)("wks"),o=i(33),a=i(2).Symbol,c=typeof a=="function",l=n.exports=function(u){return s[u]||(s[u]=c&&a[u]||(c?a:o)("Symbol."+u))};l.store=s},function(n,r){var i=n.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=i)},function(n,r,i){var s=i(9);n.exports=function(o){if(!s(o))throw TypeError(o+" is not an object!");return o}},function(n,r,i){n.exports=!i(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(n,r,i){var s=i(12),o=i(17);n.exports=i(4)?function(a,c,l){return s.f(a,c,o(1,l))}:function(a,c,l){return a[c]=l,a}},function(n,r){var i=n.exports={version:"2.4.0"};typeof __e=="number"&&(__e=i)},function(n,r,i){var s=i(14);n.exports=function(o,a,c){if(s(o),a===void 0)return o;switch(c){case 1:return function(l){return o.call(a,l)};case 2:return function(l,u){return o.call(a,l,u)};case 3:return function(l,u,f){return o.call(a,l,u,f)}}return function(){return o.apply(a,arguments)}}},function(n,r){var i={}.hasOwnProperty;n.exports=function(s,o){return i.call(s,o)}},function(n,r){n.exports=function(i){return typeof i=="object"?i!==null:typeof i=="function"}},function(n,r){n.exports={}},function(n,r){var i={}.toString;n.exports=function(s){return i.call(s).slice(8,-1)}},function(n,r,i){var s=i(3),o=i(26),a=i(32),c=Object.defineProperty;r.f=i(4)?Object.defineProperty:function(l,u,f){if(s(l),u=a(u,!0),s(f),o)try{return c(l,u,f)}catch{}if("get"in f||"set"in f)throw TypeError("Accessors not supported!");return"value"in f&&(l[u]=f.value),l}},function(n,r,i){var s=i(42),o=i(15);n.exports=function(a){return s(o(a))}},function(n,r){n.exports=function(i){if(typeof i!="function")throw TypeError(i+" is not a function!");return i}},function(n,r){n.exports=function(i){if(i==null)throw TypeError("Can't call method on "+i);return i}},function(n,r,i){var s=i(9),o=i(2).document,a=s(o)&&s(o.createElement);n.exports=function(c){return a?o.createElement(c):{}}},function(n,r){n.exports=function(i,s){return{enumerable:!(1&i),configurable:!(2&i),writable:!(4&i),value:s}}},function(n,r,i){var s=i(12).f,o=i(8),a=i(1)("toStringTag");n.exports=function(c,l,u){c&&!o(c=u?c:c.prototype,a)&&s(c,a,{configurable:!0,value:l})}},function(n,r,i){var s=i(29)("keys"),o=i(33);n.exports=function(a){return s[a]||(s[a]=o(a))}},function(n,r){var i=Math.ceil,s=Math.floor;n.exports=function(o){return isNaN(o=+o)?0:(o>0?s:i)(o)}},function(n,r,i){var s=i(11),o=i(1)("toStringTag"),a=s((function(){return arguments})())=="Arguments",c=function(l,u){try{return l[u]}catch{}};n.exports=function(l){var u,f,p;return l===void 0?"Undefined":l===null?"Null":typeof(f=c(u=Object(l),o))=="string"?f:a?s(u):(p=s(u))=="Object"&&typeof u.callee=="function"?"Arguments":p}},function(n,r){n.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(n,r,i){var s=i(2),o=i(6),a=i(7),c=i(5),l="prototype",u=function(f,p,m){var g,y,w,S=f&u.F,T=f&u.G,R=f&u.S,C=f&u.P,D=f&u.B,q=f&u.W,G=T?o:o[p]||(o[p]={}),V=G[l],L=T?s:R?s[p]:(s[p]||{})[l];T&&(m=p);for(g in m)y=!S&&L&&L[g]!==void 0,y&&g in G||(w=y?L[g]:m[g],G[g]=T&&typeof L[g]!="function"?m[g]:D&&y?a(w,s):q&&L[g]==w?(function(k){var E=function(A,M,I){if(this instanceof k){switch(arguments.length){case 0:return new k;case 1:return new k(A);case 2:return new k(A,M)}return new k(A,M,I)}return k.apply(this,arguments)};return E[l]=k[l],E})(w):C&&typeof w=="function"?a(Function.call,w):w,C&&((G.virtual||(G.virtual={}))[g]=w,f&u.R&&V&&!V[g]&&c(V,g,w)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,n.exports=u},function(n,r){n.exports=function(i){try{return!!i()}catch{return!0}}},function(n,r,i){n.exports=i(2).document&&document.documentElement},function(n,r,i){n.exports=!i(4)&&!i(24)(function(){return Object.defineProperty(i(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(n,r,i){"use strict";var s=i(28),o=i(23),a=i(57),c=i(5),l=i(8),u=i(10),f=i(45),p=i(18),m=i(52),g=i(1)("iterator"),y=!([].keys&&"next"in[].keys()),w="@@iterator",S="keys",T="values",R=function(){return this};n.exports=function(C,D,q,G,V,L,k){f(q,D,G);var E,A,M,I=function(J){if(!y&&J in N)return N[J];switch(J){case S:return function(){return new q(this,J)};case T:return function(){return new q(this,J)}}return function(){return new q(this,J)}},P=D+" Iterator",F=V==T,X=!1,N=C.prototype,b=N[g]||N[w]||V&&N[V],$=b||I(V),pe=V?F?I("entries"):$:void 0,oe=D=="Array"&&N.entries||b;if(oe&&(M=m(oe.call(new C)),M!==Object.prototype&&(p(M,P,!0),s||l(M,g)||c(M,g,R))),F&&b&&b.name!==T&&(X=!0,$=function(){return b.call(this)}),s&&!k||!y&&!X&&N[g]||c(N,g,$),u[D]=$,u[P]=R,V)if(E={values:F?$:I(T),keys:L?$:I(S),entries:pe},k)for(A in E)A in N||a(N,A,E[A]);else o(o.P+o.F*(y||X),D,E);return E}},function(n,r){n.exports=!0},function(n,r,i){var s=i(2),o="__core-js_shared__",a=s[o]||(s[o]={});n.exports=function(c){return a[c]||(a[c]={})}},function(n,r,i){var s,o,a,c=i(7),l=i(41),u=i(25),f=i(16),p=i(2),m=p.process,g=p.setImmediate,y=p.clearImmediate,w=p.MessageChannel,S=0,T={},R="onreadystatechange",C=function(){var q=+this;if(T.hasOwnProperty(q)){var G=T[q];delete T[q],G()}},D=function(q){C.call(q.data)};g&&y||(g=function(q){for(var G=[],V=1;arguments.length>V;)G.push(arguments[V++]);return T[++S]=function(){l(typeof q=="function"?q:Function(q),G)},s(S),S},y=function(q){delete T[q]},i(11)(m)=="process"?s=function(q){m.nextTick(c(C,q,1))}:w?(o=new w,a=o.port2,o.port1.onmessage=D,s=c(a.postMessage,a,1)):p.addEventListener&&typeof postMessage=="function"&&!p.importScripts?(s=function(q){p.postMessage(q+"","*")},p.addEventListener("message",D,!1)):s=R in f("script")?function(q){u.appendChild(f("script"))[R]=function(){u.removeChild(this),C.call(q)}}:function(q){setTimeout(c(C,q,1),0)}),n.exports={set:g,clear:y}},function(n,r,i){var s=i(20),o=Math.min;n.exports=function(a){return a>0?o(s(a),9007199254740991):0}},function(n,r,i){var s=i(9);n.exports=function(o,a){if(!s(o))return o;var c,l;if(a&&typeof(c=o.toString)=="function"&&!s(l=c.call(o))||typeof(c=o.valueOf)=="function"&&!s(l=c.call(o))||!a&&typeof(c=o.toString)=="function"&&!s(l=c.call(o)))return l;throw TypeError("Can't convert object to primitive value")}},function(n,r){var i=0,s=Math.random();n.exports=function(o){return"Symbol(".concat(o===void 0?"":o,")_",(++i+s).toString(36))}},function(n,r,i){"use strict";function s(R){return R&&R.__esModule?R:{default:R}}function o(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function a(R){return(0,g.createHash)("sha256").update(R).digest("hex")}function c(R){switch(w){case"darwin":return R.split("IOPlatformUUID")[1].split(`
|
|
513
|
-
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return R.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return R.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return R.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(R){var C=c((0,m.execSync)(T[w]).toString());return R?C:a(C)}function u(R){return new p.default(function(C,D){return(0,m.exec)(T[w],{},function(q,G,V){if(q)return D(new Error("Error while obtaining machine id: "+q.stack));var L=c(G.toString());return C(R?L:a(L))})})}Object.defineProperty(r,"__esModule",{value:!0});var f=i(35),p=s(f);r.machineIdSync=l,r.machineId=u;var m=i(70),g=i(71),y=process,w=y.platform,S={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},T={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:S[o()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(n,r,i){n.exports={default:i(36),__esModule:!0}},function(n,r,i){i(66),i(68),i(69),i(67),n.exports=i(6).Promise},function(n,r){n.exports=function(){}},function(n,r){n.exports=function(i,s,o,a){if(!(i instanceof s)||a!==void 0&&a in i)throw TypeError(o+": incorrect invocation!");return i}},function(n,r,i){var s=i(13),o=i(31),a=i(62);n.exports=function(c){return function(l,u,f){var p,m=s(l),g=o(m.length),y=a(f,g);if(c&&u!=u){for(;g>y;)if(p=m[y++],p!=p)return!0}else for(;g>y;y++)if((c||y in m)&&m[y]===u)return c||y||0;return!c&&-1}}},function(n,m,i){var s=i(7),o=i(44),a=i(43),c=i(3),l=i(31),u=i(64),f={},p={},m=n.exports=function(g,y,w,S,T){var R,C,D,q,G=T?function(){return g}:u(g),V=s(w,S,y?2:1),L=0;if(typeof G!="function")throw TypeError(g+" is not iterable!");if(a(G)){for(R=l(g.length);R>L;L++)if(q=y?V(c(C=g[L])[0],C[1]):V(g[L]),q===f||q===p)return q}else for(D=G.call(g);!(C=D.next()).done;)if(q=o(D,V,C.value,y),q===f||q===p)return q};m.BREAK=f,m.RETURN=p},function(n,r){n.exports=function(i,s,o){var a=o===void 0;switch(s.length){case 0:return a?i():i.call(o);case 1:return a?i(s[0]):i.call(o,s[0]);case 2:return a?i(s[0],s[1]):i.call(o,s[0],s[1]);case 3:return a?i(s[0],s[1],s[2]):i.call(o,s[0],s[1],s[2]);case 4:return a?i(s[0],s[1],s[2],s[3]):i.call(o,s[0],s[1],s[2],s[3])}return i.apply(o,s)}},function(n,r,i){var s=i(11);n.exports=Object("z").propertyIsEnumerable(0)?Object:function(o){return s(o)=="String"?o.split(""):Object(o)}},function(n,r,i){var s=i(10),o=i(1)("iterator"),a=Array.prototype;n.exports=function(c){return c!==void 0&&(s.Array===c||a[o]===c)}},function(n,r,i){var s=i(3);n.exports=function(o,a,c,l){try{return l?a(s(c)[0],c[1]):a(c)}catch(f){var u=o.return;throw u!==void 0&&s(u.call(o)),f}}},function(n,r,i){"use strict";var s=i(49),o=i(17),a=i(18),c={};i(5)(c,i(1)("iterator"),function(){return this}),n.exports=function(l,u,f){l.prototype=s(c,{next:o(1,f)}),a(l,u+" Iterator")}},function(n,r,i){var s=i(1)("iterator"),o=!1;try{var a=[7][s]();a.return=function(){o=!0},Array.from(a,function(){throw 2})}catch{}n.exports=function(c,l){if(!l&&!o)return!1;var u=!1;try{var f=[7],p=f[s]();p.next=function(){return{done:u=!0}},f[s]=function(){return p},c(f)}catch{}return u}},function(n,r){n.exports=function(i,s){return{value:s,done:!!i}}},function(n,r,i){var s=i(2),o=i(30).set,a=s.MutationObserver||s.WebKitMutationObserver,c=s.process,l=s.Promise,u=i(11)(c)=="process";n.exports=function(){var f,p,m,g=function(){var T,R;for(u&&(T=c.domain)&&T.exit();f;){R=f.fn,f=f.next;try{R()}catch(C){throw f?m():p=void 0,C}}p=void 0,T&&T.enter()};if(u)m=function(){c.nextTick(g)};else if(a){var y=!0,w=document.createTextNode("");new a(g).observe(w,{characterData:!0}),m=function(){w.data=y=!y}}else if(l&&l.resolve){var S=l.resolve();m=function(){S.then(g)}}else m=function(){o.call(s,g)};return function(T){var R={fn:T,next:void 0};p&&(p.next=R),f||(f=R,m()),p=R}}},function(n,r,i){var s=i(3),o=i(50),a=i(22),c=i(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,m=i(16)("iframe"),g=a.length,y=">";for(m.style.display="none",i(25).appendChild(m),m.src="javascript:",p=m.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+y),p.close(),f=p.F;g--;)delete f[u][a[g]];return f()};n.exports=Object.create||function(p,m){var g;return p!==null?(l[u]=s(p),g=new l,l[u]=null,g[c]=p):g=f(),m===void 0?g:o(g,m)}},function(n,r,i){var s=i(12),o=i(3),a=i(54);n.exports=i(4)?Object.defineProperties:function(c,l){o(c);for(var u,f=a(l),p=f.length,m=0;p>m;)s.f(c,u=f[m++],l[u]);return c}},function(n,r,i){var s=i(55),o=i(17),a=i(13),c=i(32),l=i(8),u=i(26),f=Object.getOwnPropertyDescriptor;r.f=i(4)?f:function(p,m){if(p=a(p),m=c(m,!0),u)try{return f(p,m)}catch{}if(l(p,m))return o(!s.f.call(p,m),p[m])}},function(n,r,i){var s=i(8),o=i(63),a=i(19)("IE_PROTO"),c=Object.prototype;n.exports=Object.getPrototypeOf||function(l){return l=o(l),s(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(n,r,i){var s=i(8),o=i(13),a=i(39)(!1),c=i(19)("IE_PROTO");n.exports=function(l,u){var f,p=o(l),m=0,g=[];for(f in p)f!=c&&s(p,f)&&g.push(f);for(;u.length>m;)s(p,f=u[m++])&&(~a(g,f)||g.push(f));return g}},function(n,r,i){var s=i(53),o=i(22);n.exports=Object.keys||function(a){return s(a,o)}},function(n,r){r.f={}.propertyIsEnumerable},function(n,r,i){var s=i(5);n.exports=function(o,a,c){for(var l in a)c&&o[l]?o[l]=a[l]:s(o,l,a[l]);return o}},function(n,r,i){n.exports=i(5)},function(n,r,i){var s=i(9),o=i(3),a=function(c,l){if(o(c),!s(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};n.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=i(7)(Function.call,i(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(n,r,i){"use strict";var s=i(2),o=i(6),a=i(12),c=i(4),l=i(1)("species");n.exports=function(u){var f=typeof o[u]=="function"?o[u]:s[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(n,r,i){var s=i(3),o=i(14),a=i(1)("species");n.exports=function(c,l){var u,f=s(c).constructor;return f===void 0||(u=s(f)[a])==null?l:o(u)}},function(n,r,i){var s=i(20),o=i(15);n.exports=function(a){return function(c,l){var u,f,p=String(o(c)),m=s(l),g=p.length;return m<0||m>=g?a?"":void 0:(u=p.charCodeAt(m),u<55296||u>56319||m+1===g||(f=p.charCodeAt(m+1))<56320||f>57343?a?p.charAt(m):u:a?p.slice(m,m+2):(u-55296<<10)+(f-56320)+65536)}}},function(n,r,i){var s=i(20),o=Math.max,a=Math.min;n.exports=function(c,l){return c=s(c),c<0?o(c+l,0):a(c,l)}},function(n,r,i){var s=i(15);n.exports=function(o){return Object(s(o))}},function(n,r,i){var s=i(21),o=i(1)("iterator"),a=i(10);n.exports=i(6).getIteratorMethod=function(c){if(c!=null)return c[o]||c["@@iterator"]||a[s(c)]}},function(n,r,i){"use strict";var s=i(37),o=i(47),a=i(10),c=i(13);n.exports=i(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,o(1)):u=="keys"?o(0,f):u=="values"?o(0,l[f]):o(0,[f,l[f]])},"values"),a.Arguments=a.Array,s("keys"),s("values"),s("entries")},function(n,r){},function(n,r,i){"use strict";var s,o,a,c=i(28),l=i(2),u=i(7),f=i(21),p=i(23),m=i(9),g=(i(3),i(14)),y=i(38),w=i(40),S=(i(58).set,i(60)),T=i(30).set,R=i(48)(),C="Promise",D=l.TypeError,G=l.process,q=l[C],G=l.process,V=f(G)=="process",L=function(){},k=!!(function(){try{var oe=q.resolve(1),J=(oe.constructor={})[i(1)("species")]=function(ve){ve(L,L)};return(V||typeof PromiseRejectionEvent=="function")&&oe.then(L)instanceof J}catch{}})(),E=function(oe,J){return oe===J||oe===q&&J===a},A=function(oe){var J;return!(!m(oe)||typeof(J=oe.then)!="function")&&J},M=function(oe){return E(q,oe)?new I(oe):new o(oe)},I=o=function(oe){var J,ve;this.promise=new oe(function(we,Se){if(J!==void 0||ve!==void 0)throw D("Bad Promise constructor");J=we,ve=Se}),this.resolve=g(J),this.reject=g(ve)},P=function(oe){try{oe()}catch(J){return{error:J}}},F=function(oe,J){if(!oe._n){oe._n=!0;var ve=oe._c;R(function(){for(var we=oe._v,Se=oe._s==1,ct=0,Ue=function(U){var K,j,Q=Se?U.ok:U.fail,Z=U.resolve,ee=U.reject,ie=U.domain;try{Q?(Se||(oe._h==2&&b(oe),oe._h=1),Q===!0?K=we:(ie&&ie.enter(),K=Q(we),ie&&ie.exit()),K===U.promise?ee(D("Promise-chain cycle")):(j=A(K))?j.call(K,Z,ee):Z(K)):ee(we)}catch(ne){ee(ne)}};ve.length>ct;)Ue(ve[ct++]);oe._c=[],oe._n=!1,J&&!oe._h&&X(oe)})}},X=function(oe){T.call(l,function(){var J,ve,we,Se=oe._v;if(N(oe)&&(J=P(function(){V?G.emit("unhandledRejection",Se,oe):(ve=l.onunhandledrejection)?ve({promise:oe,reason:Se}):(we=l.console)&&we.error&&we.error("Unhandled promise rejection",Se)}),oe._h=V||N(oe)?2:1),oe._a=void 0,J)throw J.error})},N=function(oe){if(oe._h==1)return!1;for(var J,ve=oe._a||oe._c,we=0;ve.length>we;)if(J=ve[we++],J.fail||!N(J.promise))return!1;return!0},b=function(oe){T.call(l,function(){var J;V?G.emit("rejectionHandled",oe):(J=l.onrejectionhandled)&&J({promise:oe,reason:oe._v})})},$=function(oe){var J=this;J._d||(J._d=!0,J=J._w||J,J._v=oe,J._s=2,J._a||(J._a=J._c.slice()),F(J,!0))},pe=function(oe){var J,ve=this;if(!ve._d){ve._d=!0,ve=ve._w||ve;try{if(ve===oe)throw D("Promise can't be resolved itself");(J=A(oe))?R(function(){var we={_w:ve,_d:!1};try{J.call(oe,u(pe,we,1),u($,we,1))}catch(Se){$.call(we,Se)}}):(ve._v=oe,ve._s=1,F(ve,!1))}catch(we){$.call({_w:ve,_d:!1},we)}}};k||(q=function(oe){y(this,q,C,"_h"),g(oe),s.call(this);try{oe(u(pe,this,1),u($,this,1))}catch(J){$.call(this,J)}},s=function(oe){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},s.prototype=i(56)(q.prototype,{then:function(oe,J){var ve=M(S(this,q));return ve.ok=typeof oe!="function"||oe,ve.fail=typeof J=="function"&&J,ve.domain=V?G.domain:void 0,this._c.push(ve),this._a&&this._a.push(ve),this._s&&F(this,!1),ve.promise},catch:function(oe){return this.then(void 0,oe)}}),I=function(){var oe=new s;this.promise=oe,this.resolve=u(pe,oe,1),this.reject=u($,oe,1)}),p(p.G+p.W+p.F*!k,{Promise:q}),i(18)(q,C),i(59)(C),a=i(6)[C],p(p.S+p.F*!k,C,{reject:function(oe){var J=M(this),ve=J.reject;return ve(oe),J.promise}}),p(p.S+p.F*(c||!k),C,{resolve:function(oe){if(oe instanceof q&&E(oe.constructor,this))return oe;var J=M(this),ve=J.resolve;return ve(oe),J.promise}}),p(p.S+p.F*!(k&&i(46)(function(oe){q.all(oe).catch(L)})),C,{all:function(oe){var J=this,ve=M(J),we=ve.resolve,Se=ve.reject,ct=P(function(){var Ue=[],U=0,K=1;w(oe,!1,function(j){var Q=U++,Z=!1;Ue.push(void 0),K++,J.resolve(j).then(function(ee){Z||(Z=!0,Ue[Q]=ee,--K||we(Ue))},Se)}),--K||we(Ue)});return ct&&Se(ct.error),ve.promise},race:function(oe){var J=this,ve=M(J),we=ve.reject,Se=P(function(){w(oe,!1,function(ct){J.resolve(ct).then(ve.resolve,we)})});return Se&&we(Se.error),ve.promise}})},function(n,r,i){"use strict";var s=i(61)(!0);i(27)(String,"String",function(o){this._t=String(o),this._i=0},function(){var o,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(o=s(a,c),this._i+=o.length,{value:o,done:!1})})},function(n,r,i){i(65);for(var s=i(2),o=i(5),a=i(10),c=i(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=s[f],m=p&&p.prototype;m&&!m[c]&&o(m,c,f),a[f]=a.Array}},function(n,r){n.exports=require("child_process")},function(n,r){n.exports=require("crypto")}])})});var agt={};dr(agt,{startServer:()=>KCe});module.exports=HRe(agt);var tO=require("http"),um=require("child_process"),$i=require("fs"),nn=require("path"),nO=require("url");kr();LO();Lt();st();yf();Aq();GH();Da();oq();Ld();hf();async function $Ae(t,e){let n=t.headers.authorization;if(!n||!n.startsWith("Bearer ")){e.setHeader("Content-Type","application/json"),e.writeHead(401),e.end(JSON.stringify({error:"Unauthorized: Missing API key"}));return}let r=n.slice(7);if(!G1(r,Xi()?.key)){e.setHeader("Content-Type","application/json"),e.writeHead(401),e.end(JSON.stringify({error:"Unauthorized: Invalid API key"}));return}let i=await eR();e.setHeader("Content-Type","application/json"),e.writeHead(200),e.end(JSON.stringify(i))}Ld();Qb();var jAe=require("url");var Q1=ce(require("path"),1),WAe=ce(require("os"),1);Lt();var GAe=ce(require("path"),1),HAe=ce(require("os"),1);var dNt=GAe.default.join(HAe.default.homedir(),".9remote","pids");LD();_p();var wNt=Q1.default.dirname((0,jAe.fileURLToPath)(__importMetaUrl));var SNt=Q1.default.join(WAe.default.homedir(),".9remote","cloudflared.pid");function VAe(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}var xNt=Q1.default.join(Oe.STATE,Yv.lockFile);Eo();Da();_p();kr();hf();Ld();var KAe=ce(zAe(),1),Pz=ce(require("crypto"),1),{machineIdSync:Pmt}=KAe.default;async function YAe(t=null){let e=t||process.env.MACHINE_ID_SALT||"9remote-salt";try{let n=Pmt();return Pz.default.createHash("sha256").update(n+e).digest("hex").substring(0,16)}catch(n){return console.error("Error getting machine ID:",n),Pz.default.randomUUID().replace(/-/g,"").substring(0,16)}}Eo();Lt();st();o0();Ld();fz();var XAe=be("session"),Omt=10;async function JAe(t,e){try{let n=await ac(`${e}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let s={apiKey:$n(t),expiryMinutes:Omt};return{...s,...aT(s)}})())});if(!n.ok){let s=await n.json().catch(()=>null);throw new Error(s?.error||`HTTP ${n.status}`)}let r=await n.json(),i=fAe();return pAe(r.tempKey,i,r.expiresAt,e),{...r,oneTimeKey:`${r.tempKey}${i}`}}catch(n){return XAe.error(`Temp key creation failed: ${n?.message||n}`),null}}function QAe(t,e){return e?.tempKey?`${t}/login?k=${e.tempKey}#${e.oneTimeKey}`:`${t}/login`}async function ZAe(t,e,n,r){try{let i=await ac(`${e}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:$n(t),hostPublicKey:sT(),hostX25519Key:oT(),tempKey:jS()?.tempKey||void 0})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return n&&await ac(`${e}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:$n(t),tunnelUrl:n,...aT({apiKey:$n(t),tunnelUrl:n})})}).catch(()=>{}),r&&$n(r)!==$n(t)&&await ac(`${e}/api/session/delete`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:$n(r),...aT({apiKey:$n(r)})})}).catch(()=>{}),!0}catch(i){return XAe.error(`Session registration failed: ${i?.message||i}`),!1}}Qv();Ld();_p();async function eCe(t,e){let n=wT(),r=n.workerUrl||pc;if(!n.permanentKey){it(e,400,"No permanent key set");return}let i=await JAe(n.permanentKey,r);if(!i){it(e,500,"Temp key creation failed");return}let s=QAe(r,i);wc({oneTimeKey:i.oneTimeKey,oneTimeKeyExpiresAt:i.expiresAt,qrUrl:s}),Le(e,{oneTimeKey:i.oneTimeKey,expiresAt:i.expiresAt,qrUrl:s})}async function tCe(t,e){try{let n=wT(),r=n.workerUrl||pc,i=await YAe(),s=gAe(i),o=Xi();if(!await ZAe(s,r,n.tunnelUrl,o?.key)){it(e,502,"Could not register the new key with the server");return}c7(i,s,o?.name||"Default"),Jv($n(s)),wc({permanentKey:s,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0}),Le(e,{ok:!0,permanentKey:s})}catch(n){it(e,500,n.message)}}kr();yf();E0();async function nCe(t,e){let n=await Ir(t,e);if(!n)return;let r=UAe(n.socketId);Le(e,{ok:r})}async function rCe(t,e){let n=await Ir(t,e);if(!n)return;let r=BAe(n.socketId);Le(e,{ok:r})}function iCe(t,e){Le(e,{pending:J7()})}function sCe(t,e){Le(e,{devices:Y7()})}function oCe(t,e){Le(e,{rejected:Z7()})}async function aCe(t,e){let n=await Ir(t,e);if(!n)return;let r=FAe(n.deviceId);Le(e,{ok:r})}async function cCe(t,e){let n=await Ir(t,e);n&&(J1(n.deviceId),Og(n.deviceId),Le(e))}async function lCe(t,e){let n=await Ir(t,e);n&&(J1(n.deviceId),V7(n.deviceId),Le(e))}async function uCe(t,e){let n=await Ir(t,e);if(!n)return;j7(n.deviceId);let r=J1(n.deviceId);Le(e,{disconnected:r})}function fCe(t,e){Le(e,{enabled:AL()})}async function dCe(t,e){let n=await Ir(t,e);if(!n)return;let r=z7(n.deviceId,n.label);Le(e,{ok:r})}async function pCe(t,e){let n=await Ir(t,e);if(!n)return;let r=tQ(!!n.enabled);Le(e,{enabled:r})}kr();yf();Ji();QC();Ms();Ic();Lq();oz();var hCe={},Mmt=1e4;function Nmt(t,e){let n=HU(t,e);return n||(ty(t).length?HU(t,{[ty(t)[0]]:e.csid}):null)}function gCe(t,e){if(e)return{type:e.type||"stop",sessionId:e.sessionId||"",tool:e.tool||"",csid:e.csid||"",...e};let n=JSON.parse(t||"{}");return{type:n.type||"stop",sessionId:n.sessionId||"",tool:n.tool||"",csid:n.csid||"",...n}}async function yCe(t,e){let n="";await new Promise(r=>{t.on("data",i=>n+=i),t.on("end",r)});try{vCe(gCe(n,null)),Le(e,{success:!0})}catch{it(e,400,"Invalid JSON")}}function _Ce(t,e,{query:n}){vCe(gCe(null,n)),Le(e,{success:!0})}function mCe(t,e,n){let{type:r,sessionId:i,tool:s}=t,o={type:r,sessionId:i,tool:s,timestamp:n},c=Wp({type:r,sessionId:i,tool:s})?.state||Jt.IDLE,l=ts(i);if(et(e,"statusChange",{sessionId:i,state:c,tool:s,since:n,...l?{conversationId:l.id}:{}}),QU(i,o),et(e,"chatNotification",o),(c===Jt.DONE||c===Jt.BLOCKED)&&SA(i),(c===Jt.DONE||c===Jt.BLOCKED)&&sz(i),c!==Jt.DONE&&c!==Jt.BLOCKED)return;let u=`${i}:${c}`;n-(hCe[u]||0)<Mmt||(hCe[u]=n,Eae({...o,state:c}))}function vCe(t){let{type:e,sessionId:n,tool:r}=t,i=Date.now(),s=qa();if(!s||!n)return;let o=Nmt(r,t);if(o&&ka(n,r,o,"hook"),EA[e]===Jt.DONE){bA(n,()=>mCe(t,s,Date.now()));return}mCe(t,s,i)}kr();Iq();dR();Lt();var Oz=ce(require("fs"),1),Z1=ce(require("path"),1);yf();Ji();oh();Da();var Dmt=process.platform==="darwin"||process.platform==="win32",ECe=t=>Dmt?t.toLowerCase():t,wCe=(t,e)=>{let n=ECe(t),r=ECe(e);return n===r||n.startsWith(r+Z1.default.sep)},SCe=t=>[t.cwd,t.workspacePath].filter(Boolean);function Lmt(t,e,n){if(e&&n.some(s=>s.id===e))return e;let r=null,i=-1;for(let s of n)for(let o of SCe(s))wCe(t,o)&&o.length>i&&(r=s.id,i=o.length);return r}function xCe({path:t,title:e},n=null){if(!t||typeof t!="string")return{error:"path is required"};let r=Z1.default.resolve(t);try{r=Oz.default.realpathSync(r)}catch{return{error:"File not found"}}if(Et(r))return{error:"Access denied"};if(!Oz.default.statSync(r).isFile())return{error:"Not a file"};let i=cu(),s=i.filter(c=>SCe(c).some(l=>wCe(r,l)));if(n&&i.some(c=>c.id===n)&&!s.some(c=>c.id===n))return{error:"File is outside this terminal's workspace"};if(!s.length)return{error:"File is outside every open terminal's workspace"};let o=qa();if(!o)return{error:"Server not ready"};let a=Lmt(r,n,s);return et(o,"artifactOpen",{path:r,title:e||Z1.default.basename(r),sessionId:a}),{path:r}}var Umt={name:"openArtifact",description:"Show a file you just created or edited in the 9Remote app, sliding it in beside the terminal. Use it for files worth looking at \u2014 html, markdown, svg, images, pdf, csv, diagrams, code. Skip files with nothing to see. The user closes it themselves.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Absolute path to the file."},title:{type:"string",description:"Optional label for the panel header."}},required:["path"]},run({path:t,title:e},n){let r=xCe({path:t,title:e},n?.sessionId);return r.error?r:`Opened ${r.path}`}},bCe=Umt;zw();u4();var Fmt=500;function Bmt(t={applyAction:A_}){return{name:"report_task",description:"Report what you just finished, in one or two sentences. It lands on this session's card on the kanban board the user watches, so progress is visible without reading your terminal. Call it when a chunk of work completes, and again with status when your own state changes (todo | in_progress | needs_input | done). While a turn of yours is actually running, the live state wins \u2014 the self-report takes effect when you go idle.",inputSchema:{type:"object",properties:{summary:{type:"string",description:"1-2 sentences of what was done or what changed"},status:{type:"string",enum:l4,description:"Optional self-reported status; live turn state still wins while running"}},required:["summary"]},async run({summary:e,status:n}={},r={}){let i=String(e||"").trim().slice(0,Fmt);if(!i)return{error:"summary is required"};let s=r?.sessionId;if(!s)return{error:"no session identity; cannot tell which card is yours"};let{error:o}=await t.applyAction({type:"report",sessionId:s,summary:i,...n?{status:n}:{}});return o?{error:o}:"reported"}}}var TCe=Bmt();xk();var ACe=[bCe,TCe],CCe=new Map([...ACe,...yd].map(t=>[t.name,t])),RCe=()=>ACe.map(({name:t,description:e,inputSchema:n})=>({name:t,description:e,inputSchema:n}));var eO=(t,e=!1)=>({content:[{type:"text",text:t}],isError:e});async function qmt(t,e,n){let r=CCe.get(t);if(!r)return eO(`Unknown tool: ${t}`,!0);try{let i=await r.run(e||{},n||{});return i?.error?eO(i.error,!0):eO(typeof i=="string"?i:JSON.stringify(i))}catch(i){return eO(i.message,!0)}}async function ICe(t,e){let{id:n,method:r,params:i}=t||{},s=o=>({jsonrpc:"2.0",id:n,result:o});return r==="initialize"?s({protocolVersion:i?.protocolVersion||Sl.PROTOCOL_VERSION,capabilities:{tools:{}},serverInfo:{name:Sl.SERVER_NAME,version:"3.0.4"}}):r==="tools/list"?s({tools:RCe()}):r==="tools/call"?s(await qmt(i?.name,i?.arguments,e)):r==="ping"?s({}):n==null?null:{jsonrpc:"2.0",id:n,error:{code:-32601,message:`Method not found: ${r}`}}}var Nz=ce(require("fs"),1),PCe=require("child_process");st();Cq();var $mt=be("artifact"),kCe=/(?:^|[\s\0])NINE_REMOTE_SESSION_ID=([^\s\0]+)/,Mz=new WeakMap,Dz=(t,e)=>(0,PCe.execFileSync)(t,e,{encoding:"utf8",timeout:Oy.PROBE_TIMEOUT_MS,stdio:["ignore","pipe","ignore"]});function Gmt(t,e){let n=Dz("lsof",["-nP",`-iTCP:${t}`,"-Fpn"]),r=null;for(let i of n.split(`
|
|
514
|
-
`))if(i[0]==="p")r=parseInt(i.slice(1),10);else if(i[0]==="n"&&r&&r!==e){let s=i.match(/^n(?:\[[^\]]+\]|[^:]+):(\d+)->/);if(s&&Number(s[1])===t)return r}return null}function Hmt(t){try{return process.platform==="linux"?Nz.default.readFileSync(`/proc/${t}/environ`,"utf8").match(kCe)?.[1]||null:Dz("ps",["-Eww","-o","command=","-p",String(t)]).match(kCe)?.[1]||null}catch{return null}}function jmt(t){try{if(process.platform==="linux"){let e=Nz.default.readFileSync(`/proc/${t}/stat`,"utf8");return parseInt(e.slice(e.lastIndexOf(")")+2).split(" ")[1],10)||null}return parseInt(Dz("ps",["-o","ppid=","-p",String(t)]).trim(),10)||null}catch{return null}}function Wmt(t){for(let e=0;t>1&&t!==process.pid&&e<Oy.MAX_PARENT_HOPS;e++){let n=Hmt(t);if(n)return n;if(t=jmt(t),!t)return null}return null}function OCe(t){let e=t?.headers?.[Oy.HEADER];if(e&&!/[${}]/.test(e))return e;let n=t?.socket;if(!n)return null;if(Mz.has(n))return Mz.get(n);let r=null;try{let i=Gmt(n.remotePort,process.pid);i&&(r=Wmt(i))}catch(i){$mt.warn(`caller probe failed: ${i.message}`)}return Mz.set(n,r),r}async function MCe(t,e){if(!Ece(t.headers.authorization))return it(e,401,"Unauthorized");if(!LE())return it(e,403,"MCP is turned off in 9Remote settings");let n=await Ir(t,e);if(n===null&&!e.writableEnded)return it(e,400,"Invalid request");if(e.writableEnded)return;let r;try{r=await ICe(n,{sessionId:OCe(t)})}catch(i){r={jsonrpc:"2.0",id:n?.id??null,error:{code:-32603,message:i.message}}}if(!r)return e.writeHead(202),e.end();e.setHeader("Content-Type","application/json"),e.writeHead(200),e.end(JSON.stringify(r))}kr();yT();hf();Ur();Eo();function NCe(){return{mode:GD(),active:$D(),presets:Object.keys(Te.sleepInhibit?.presets||{})}}function DCe(t,e){Le(e,NCe())}async function LCe(t,e){let n=await Ir(t,e);if(!n)return;let r=g0(n.mode);a7({sleepInhibitMode:r});let i=NCe();Jn("sleepInhibit",i),Le(e,i)}kr();HL();async function UCe(t,e){let n=await BT();Le(e,n)}async function FCe(t,e){let n=await NQ(),r=await BT();Le(e,{...n,...r})}async function BCe(t,e){let n=await Ir(t,e);if(!n)return;if(typeof n.text!="string"||!n.text){it(e,400,"Missing text");return}let r=await C0(n.text);Le(e,{ok:r.ok,reason:r.reason||null})}async function qCe(t,e){let n=await MQ(),r=await BT();Le(e,{...n,...r})}di();kr();async function $Ce(t,e){try{let n=await vf();Le(e,{sessions:n})}catch(n){it(e,500,n.message)}}async function GCe(t,e){let n=await Ir(t,e);if(n){if(!n.sessionId)return it(e,400,"sessionId required");try{await Ef(n.sessionId),Le(e)}catch(r){it(e,500,r.message)}}}var Fu=ce(require("os"),1);Ur();JT();kr();function Vmt(){let t=xZ();if(!t?.activeClients)return{total:0,streaming:0};let e=0;for(let n of t.activeClients.values())n.isStreaming&&e++;return{total:t.activeClients.size,streaming:e}}function zmt(){let t=process.memoryUsage(),e=Fu.default.cpus();return{agent:{pid:process.pid,version:"3.0.4",nodeVersion:process.version,platform:`${process.platform}/${process.arch}`,uptimeSec:Math.round(process.uptime()),memory:{heapUsedMB:Math.round(t.heapUsed/1048576*10)/10,heapTotalMB:Math.round(t.heapTotal/1048576*10)/10,rssMB:Math.round(t.rss/1048576*10)/10,externalMB:Math.round(t.external/1048576*10)/10}},os:{hostname:Fu.default.hostname(),platform:Fu.default.platform(),arch:Fu.default.arch(),uptimeSec:Math.round(Fu.default.uptime()),loadAvg:Fu.default.loadavg(),cpuModel:e?.[0]?.model||"unknown",cpuCount:e.length,totalMemMB:Math.round(Fu.default.totalmem()/1048576),freeMemMB:Math.round(Fu.default.freemem()/1048576)},remote:{available:XT(),...Vmt(),memoryWarningThresholdMB:Te.resourceManagement.memoryWarningThreshold},timestamp:Date.now()}}function HCe(t,e){try{Le(e,zmt())}catch(n){it(e,500,"stats error",n.message)}}yT();hf();Ur();I8();V8();var ea=be("server"),ta=(0,nO.fileURLToPath)(new URL(".",__importMetaUrl)),VCe=process.env.NODE_ENV==="development",Kmt=5173,Lz=[(0,nn.join)(ta,"dist","ui"),(0,nn.join)(ta,"ui","dist"),(0,nn.join)(ta,"ui")].find(t=>(0,$i.existsSync)(t))||(0,nn.join)(ta,"dist","ui"),tc=[(0,nn.join)(ta,"dist","web"),(0,nn.join)(ta,"web"),(0,nn.join)(ta,"..","web","out")].find(t=>(0,$i.existsSync)(t))||Lz,Ymt={".html":"text/html; charset=utf-8",".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif",".ico":"image/x-icon",".woff2":"font/woff2",".woff":"font/woff",".ttf":"font/ttf",".json":"application/json; charset=utf-8",".txt":"text/x-component; charset=utf-8",".webmanifest":"application/manifest+json"};function Xmt(t,e,n){let r=(0,tO.request)({hostname:"localhost",port:Kmt,path:t.url,method:t.method,headers:t.headers},i=>{e.writeHead(i.statusCode,i.headers),i.pipe(e)});r.on("error",()=>n?n():void(e.writeHead(502),e.end("Vite dev server not ready"))),t.pipe(r)}function Jmt(t,e){let n;try{n=(0,nO.parse)(t.url).pathname}catch{it(e,400,"Bad request");return}let r=H8(n,t.headers.host);if(!r){it(e,404,"Not found");return}for(let[i,s]of Object.entries(r.headers))e.setHeader(i,s);hs(e,(0,nn.join)(tc,r.path),{frameable:!0})||it(e,404,"Not found")}function hs(t,e,{frameable:n=!1}={}){if(!(0,$i.existsSync)(e))return!1;try{if((0,$i.statSync)(e).isDirectory()){let a=(0,nn.join)(e,"index.html");return(0,$i.existsSync)(a)?hs(t,a,{frameable:n}):!1}let i=(0,nn.extname)(e),s=Ymt[i]||"application/octet-stream";t.setHeader("Content-Type",s),i===".html"&&!n&&t.setHeader("X-Frame-Options","SAMEORIGIN");let o=e.includes(`${nn.sep}_next${nn.sep}static${nn.sep}`);return t.hasHeader("Cache-Control")||t.setHeader("Cache-Control",o?"public, max-age=31536000, immutable":"no-cache"),t.writeHead(200),t.end((0,$i.readFileSync)(e)),!0}catch{return!1}}async function Uz(t){try{let e=await ac(MO);if(!e.ok)return;let{version:n}=await e.json();n&&VAe(t,n)&&(YD({version:n}),Jn("updateAvailable",{version:n}),$q())}catch{}}var jCe=0;function Qmt(t){let e=Date.now();e-jCe<Yv.connectCheckDebounceMs||(jCe=e,Uz(t))}function Zmt(t,e){if(process.env.CODESPACES!=="true"){it(e,400,"Not running on Codespaces");return}let n=process.env.CODESPACE_NAME;if(!n){it(e,400,"Codespace name not found");return}let r=qa();r&&r.emit("codespace:stopping"),Le(e,{success:!0,message:"Stopping codespace..."}),setTimeout(()=>(0,um.execFile)("gh",["codespace","stop","-c",n],{windowsHide:!0}),500)}async function egt(t,e){let{parseJsonBody:n}=await Promise.resolve().then(()=>(kr(),Zu)),r=await n(t,e);if(!r)return;let{verifyPresentedTail:i}=await Promise.resolve().then(()=>(Sz(),SAe)),s=i({tail:r.tail,tempKey:r.tempKey});if(s.ok){Le(e,{ok:!0});return}let o=t.headers["x-forwarded-for"]||t.socket?.remoteAddress||"unknown";if(r.tempKey&&r.tail){ea.warn(`wrong one-time code TAIL (${o}) \u2014 code burned, clearing from UI`);let{clearOneTimeKey:a}=await Promise.resolve().then(()=>(Eo(),U7));a()}else r.tempKey?ea.warn(`wrong one-time code TAIL (${o}) \u2014 no TAIL presented, code still live`):ea.warn(`wrong API-key TAIL (${o}) \u2014 rejected`);setTimeout(()=>Le(e,{ok:!1,reason:s.reason}),s.penaltyMs||0)}var zCe;async function WCe(t,e,{pathname:n}){let r=t.headers.authorization;if(!r||!r.startsWith("Bearer ")||!G1(r.slice(7),Xi()?.key)){it(e,401,"Unauthorized");return}let{parseJsonBody:i}=await Promise.resolve().then(()=>(kr(),Zu)),s=await i(t,e);if(!s)return;if(!s.port){it(e,400,"Port required");return}if(!n.endsWith("start")){oR(s.port),Le(e,{success:!0});return}let o=sR(s.port);if(!o){it(e,400,"Invalid port");return}Le(e,{success:!0,sessionId:o})}function tgt(t,e,{pathname:n,search:r}){let i=n.match(/^\/proxy\/([0-9a-f-]{36})(\/.*)?$/);i?yce(zCe,t,e,i[1],i[2]||"/",r):it(e,404,"Not found")}function ngt(t,e,n){t_e(t,e,n)}var rgt=[{path:"/api/health",method:"GET",public:!0,handler:(t,e)=>Le(e,{status:"ok",timestamp:Date.now()})},{path:"/api/version",method:"GET",public:!0,handler:(t,e)=>{Le(e,{version:"3.0.4"})}},{path:"/api/notify",method:"POST",public:!0,handler:yCe},{path:"/api/notify",method:"GET",public:!0,handler:_Ce},{path:"/proxy/*",method:"*",public:!0,handler:tgt},{path:"/preview/*",method:"GET",public:!0,handler:ngt},{path:"/api/ui/events",method:"GET",handler:nL},{path:"/api/local-token",method:"GET",handler:ZD},{path:Sl.PATH,method:"POST",handler:MCe},{path:"/api/ui/state",method:"GET",handler:rL},{path:"/api/ui/state",method:"POST",handler:iL},{path:"/api/ui/stop",method:"POST",handler:sL},{path:"/api/ui/start",method:"POST",handler:oL},{path:"/api/ui/stop-tunnel",method:"POST",handler:aL},{path:"/api/ui/shutdown",method:"POST",handler:cL},{path:"/api/update",method:"POST",handler:lL},{path:"/api/system/stats",method:"GET",handler:HCe},{path:"/api/key/one-time",method:"POST",handler:eCe},{path:"/api/key/regenerate",method:"POST",handler:tCe},{path:"/api/device/approve",method:"POST",handler:nCe},{path:"/api/device/reject",method:"POST",handler:rCe},{path:"/api/device/pending",method:"GET",handler:iCe},{path:"/api/device/approved",method:"GET",handler:sCe},{path:"/api/device/rejected",method:"GET",handler:oCe},{path:"/api/device/approve-rejected",method:"POST",handler:aCe},{path:"/api/device/clear-rejected",method:"POST",handler:cCe},{path:"/api/device/remove",method:"POST",handler:lCe},{path:"/api/device/label",method:"POST",handler:dCe},{path:"/api/device/disconnect",method:"POST",handler:uCe},{path:"/api/device/auto-approve",method:"GET",handler:fCe},{path:"/api/device/auto-approve",method:"POST",handler:pCe},{path:"/api/connections",method:"GET",handler:uL},{path:"/api/logs",method:"GET",handler:fL},{path:"/api/logs/clear",method:"POST",handler:dL},{path:"/api/permissions",method:"GET",handler:hL},{path:"/api/permissions/request",method:"POST",handler:yL},{path:"/api/desktop/toggle",method:"POST",handler:pL},{path:"/api/ui/rtc-toggle",method:"POST",handler:eL},{path:"/api/autostart",method:"GET",handler:mL},{path:"/api/autostart",method:"POST",handler:gL},{path:"/api/sleep-inhibit",method:"GET",handler:DCe},{path:"/api/sleep-inhibit",method:"POST",handler:LCe},{path:"/api/desktop-unlock",method:"GET",handler:UCe},{path:"/api/desktop-unlock/install",method:"POST",handler:FCe},{path:"/api/desktop-unlock/uninstall",method:"POST",handler:qCe},{path:"/api/desktop-unlock/type",method:"POST",handler:BCe},{path:"/api/sessions",method:"GET",handler:$Ce},{path:"/api/sessions/delete",method:"POST",handler:GCe},{path:"/api/local-sites",method:"*",public:!0,handler:$Ae},{path:"/api/codespace/stop",method:"POST",handler:Zmt},{path:"/api/verify-key",method:"POST",public:!0,handler:egt},{path:"/api/proxy/start",method:"POST",public:!0,handler:WCe},{path:"/api/proxy/end",method:"POST",public:!0,handler:WCe}];var igt=parseInt(process.env.PORT||"2208",10),QS=null;function sgt(t){if(process.platform!=="win32")try{let e=(0,um.execSync)(`pgrep -f "vite --config ${t}"`,{encoding:"utf8"}).trim();for(let n of e.split(`
|
|
515
|
-
`).filter(Boolean))if((0,um.execSync)(`ps -o ppid= -p ${n}`,{encoding:"utf8"}).trim()==="1")try{process.kill(Number(n))}catch{}}catch{}}function ogt(){if(!VCe)return;let t=(0,nn.join)(ta,"vite.config.js");if(!(0,$i.existsSync)(t))return;sgt(t);let e=(0,$i.existsSync)((0,nn.join)(ta,"node_modules",".bin","vite"))?(0,nn.join)(ta,"node_modules",".bin","vite"):(0,nn.join)(ta,"..","node_modules",".bin","vite");QS=(0,um.spawn)("node",[e,"--config",t],{cwd:ta,stdio:"ignore",detached:!1}),QS.on("error",()=>{}),QS.unref()}async function KCe(){let t=MD(),e=t.sleepInhibitMode;e||(t.sleepInhibit===!1?e="never":e=Te.sleepInhibit?.defaultMode||"never"),g0(e),await qq(),zCe=gce(),ogt();let r=DO(rgt,{fallback:(c,l,{pathname:u})=>{if(u.startsWith("/api/")||u.startsWith("/socket.io")){it(l,404,"Not found");return}let f=u.replace(/^\//,"");if(f.split(/[\\/]/).includes("..")){it(l,400,"Bad request");return}if((0,$i.existsSync)(tc)&&f)try{let g=(0,nn.join)(tc,f);if((0,$i.existsSync)(g)&&!(0,$i.statSync)(g).isDirectory()&&hs(l,g))return}catch{}if((u==="/workspace"||u.startsWith("/workspace/")||u.startsWith("/_next/")||u==="/login"||u.startsWith("/login/"))&&(0,$i.existsSync)(tc)){let g=(0,nn.join)(tc,f);if(hs(l,g)||hs(l,`${g}.html`)||hs(l,(0,nn.join)(g,"index.html"))||(c.headers.rsc==="1"||f.endsWith(".txt"))&&(f.startsWith("workspace/terminal/")&&hs(l,(0,nn.join)(tc,"workspace","terminal","default.txt"))||hs(l,(0,nn.join)(tc,"workspace.txt")))||u.startsWith("/workspace")&&(hs(l,(0,nn.join)(tc,"workspace.html"))||hs(l,(0,nn.join)(tc,"workspace","index.html")))||u.startsWith("/login")&&(hs(l,(0,nn.join)(tc,"login.html"))||hs(l,(0,nn.join)(tc,"login","index.html"))))return;it(l,404,"Not found");return}let m=()=>{let g=f==="ui"||f===""?"index.html":f.replace(/^ui\/?/,""),y=(0,nn.join)(Lz,g);hs(l,y)||hs(l,(0,nn.join)(Lz,"index.html"))||it(l,404,"Not found")};if(VCe){Xmt(c,l,m);return}m()}}),i=(0,tO.createServer)(async(c,l)=>{if(Cx(c.headers.host)){Jmt(c,l);return}await r(c,l)});tD(),WD(),VD();let s=()=>bT().catch(c=>ea.error(`permission refresh failed: ${c?.message||c}`));s(),process.platform==="darwin"&&setInterval(s,k8),await qAe(i),i.on("error",c=>{ea.error(`HTTP server error: ${c?.message||c}`),c?.code==="EADDRINUSE"&&process.exit(1)}),i.listen(igt,c=>{if(c)throw c;let l="3.0.
|
|
513
|
+
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return R.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return R.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return R.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function l(R){var C=c((0,m.execSync)(T[w]).toString());return R?C:a(C)}function u(R){return new p.default(function(C,D){return(0,m.exec)(T[w],{},function(q,G,V){if(q)return D(new Error("Error while obtaining machine id: "+q.stack));var L=c(G.toString());return C(R?L:a(L))})})}Object.defineProperty(r,"__esModule",{value:!0});var f=i(35),p=s(f);r.machineIdSync=l,r.machineId=u;var m=i(70),g=i(71),y=process,w=y.platform,S={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},T={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:S[o()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(n,r,i){n.exports={default:i(36),__esModule:!0}},function(n,r,i){i(66),i(68),i(69),i(67),n.exports=i(6).Promise},function(n,r){n.exports=function(){}},function(n,r){n.exports=function(i,s,o,a){if(!(i instanceof s)||a!==void 0&&a in i)throw TypeError(o+": incorrect invocation!");return i}},function(n,r,i){var s=i(13),o=i(31),a=i(62);n.exports=function(c){return function(l,u,f){var p,m=s(l),g=o(m.length),y=a(f,g);if(c&&u!=u){for(;g>y;)if(p=m[y++],p!=p)return!0}else for(;g>y;y++)if((c||y in m)&&m[y]===u)return c||y||0;return!c&&-1}}},function(n,m,i){var s=i(7),o=i(44),a=i(43),c=i(3),l=i(31),u=i(64),f={},p={},m=n.exports=function(g,y,w,S,T){var R,C,D,q,G=T?function(){return g}:u(g),V=s(w,S,y?2:1),L=0;if(typeof G!="function")throw TypeError(g+" is not iterable!");if(a(G)){for(R=l(g.length);R>L;L++)if(q=y?V(c(C=g[L])[0],C[1]):V(g[L]),q===f||q===p)return q}else for(D=G.call(g);!(C=D.next()).done;)if(q=o(D,V,C.value,y),q===f||q===p)return q};m.BREAK=f,m.RETURN=p},function(n,r){n.exports=function(i,s,o){var a=o===void 0;switch(s.length){case 0:return a?i():i.call(o);case 1:return a?i(s[0]):i.call(o,s[0]);case 2:return a?i(s[0],s[1]):i.call(o,s[0],s[1]);case 3:return a?i(s[0],s[1],s[2]):i.call(o,s[0],s[1],s[2]);case 4:return a?i(s[0],s[1],s[2],s[3]):i.call(o,s[0],s[1],s[2],s[3])}return i.apply(o,s)}},function(n,r,i){var s=i(11);n.exports=Object("z").propertyIsEnumerable(0)?Object:function(o){return s(o)=="String"?o.split(""):Object(o)}},function(n,r,i){var s=i(10),o=i(1)("iterator"),a=Array.prototype;n.exports=function(c){return c!==void 0&&(s.Array===c||a[o]===c)}},function(n,r,i){var s=i(3);n.exports=function(o,a,c,l){try{return l?a(s(c)[0],c[1]):a(c)}catch(f){var u=o.return;throw u!==void 0&&s(u.call(o)),f}}},function(n,r,i){"use strict";var s=i(49),o=i(17),a=i(18),c={};i(5)(c,i(1)("iterator"),function(){return this}),n.exports=function(l,u,f){l.prototype=s(c,{next:o(1,f)}),a(l,u+" Iterator")}},function(n,r,i){var s=i(1)("iterator"),o=!1;try{var a=[7][s]();a.return=function(){o=!0},Array.from(a,function(){throw 2})}catch{}n.exports=function(c,l){if(!l&&!o)return!1;var u=!1;try{var f=[7],p=f[s]();p.next=function(){return{done:u=!0}},f[s]=function(){return p},c(f)}catch{}return u}},function(n,r){n.exports=function(i,s){return{value:s,done:!!i}}},function(n,r,i){var s=i(2),o=i(30).set,a=s.MutationObserver||s.WebKitMutationObserver,c=s.process,l=s.Promise,u=i(11)(c)=="process";n.exports=function(){var f,p,m,g=function(){var T,R;for(u&&(T=c.domain)&&T.exit();f;){R=f.fn,f=f.next;try{R()}catch(C){throw f?m():p=void 0,C}}p=void 0,T&&T.enter()};if(u)m=function(){c.nextTick(g)};else if(a){var y=!0,w=document.createTextNode("");new a(g).observe(w,{characterData:!0}),m=function(){w.data=y=!y}}else if(l&&l.resolve){var S=l.resolve();m=function(){S.then(g)}}else m=function(){o.call(s,g)};return function(T){var R={fn:T,next:void 0};p&&(p.next=R),f||(f=R,m()),p=R}}},function(n,r,i){var s=i(3),o=i(50),a=i(22),c=i(19)("IE_PROTO"),l=function(){},u="prototype",f=function(){var p,m=i(16)("iframe"),g=a.length,y=">";for(m.style.display="none",i(25).appendChild(m),m.src="javascript:",p=m.contentWindow.document,p.open(),p.write("<script>document.F=Object</script"+y),p.close(),f=p.F;g--;)delete f[u][a[g]];return f()};n.exports=Object.create||function(p,m){var g;return p!==null?(l[u]=s(p),g=new l,l[u]=null,g[c]=p):g=f(),m===void 0?g:o(g,m)}},function(n,r,i){var s=i(12),o=i(3),a=i(54);n.exports=i(4)?Object.defineProperties:function(c,l){o(c);for(var u,f=a(l),p=f.length,m=0;p>m;)s.f(c,u=f[m++],l[u]);return c}},function(n,r,i){var s=i(55),o=i(17),a=i(13),c=i(32),l=i(8),u=i(26),f=Object.getOwnPropertyDescriptor;r.f=i(4)?f:function(p,m){if(p=a(p),m=c(m,!0),u)try{return f(p,m)}catch{}if(l(p,m))return o(!s.f.call(p,m),p[m])}},function(n,r,i){var s=i(8),o=i(63),a=i(19)("IE_PROTO"),c=Object.prototype;n.exports=Object.getPrototypeOf||function(l){return l=o(l),s(l,a)?l[a]:typeof l.constructor=="function"&&l instanceof l.constructor?l.constructor.prototype:l instanceof Object?c:null}},function(n,r,i){var s=i(8),o=i(13),a=i(39)(!1),c=i(19)("IE_PROTO");n.exports=function(l,u){var f,p=o(l),m=0,g=[];for(f in p)f!=c&&s(p,f)&&g.push(f);for(;u.length>m;)s(p,f=u[m++])&&(~a(g,f)||g.push(f));return g}},function(n,r,i){var s=i(53),o=i(22);n.exports=Object.keys||function(a){return s(a,o)}},function(n,r){r.f={}.propertyIsEnumerable},function(n,r,i){var s=i(5);n.exports=function(o,a,c){for(var l in a)c&&o[l]?o[l]=a[l]:s(o,l,a[l]);return o}},function(n,r,i){n.exports=i(5)},function(n,r,i){var s=i(9),o=i(3),a=function(c,l){if(o(c),!s(l)&&l!==null)throw TypeError(l+": can't set as prototype!")};n.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(c,l,u){try{u=i(7)(Function.call,i(51).f(Object.prototype,"__proto__").set,2),u(c,[]),l=!(c instanceof Array)}catch{l=!0}return function(f,p){return a(f,p),l?f.__proto__=p:u(f,p),f}})({},!1):void 0),check:a}},function(n,r,i){"use strict";var s=i(2),o=i(6),a=i(12),c=i(4),l=i(1)("species");n.exports=function(u){var f=typeof o[u]=="function"?o[u]:s[u];c&&f&&!f[l]&&a.f(f,l,{configurable:!0,get:function(){return this}})}},function(n,r,i){var s=i(3),o=i(14),a=i(1)("species");n.exports=function(c,l){var u,f=s(c).constructor;return f===void 0||(u=s(f)[a])==null?l:o(u)}},function(n,r,i){var s=i(20),o=i(15);n.exports=function(a){return function(c,l){var u,f,p=String(o(c)),m=s(l),g=p.length;return m<0||m>=g?a?"":void 0:(u=p.charCodeAt(m),u<55296||u>56319||m+1===g||(f=p.charCodeAt(m+1))<56320||f>57343?a?p.charAt(m):u:a?p.slice(m,m+2):(u-55296<<10)+(f-56320)+65536)}}},function(n,r,i){var s=i(20),o=Math.max,a=Math.min;n.exports=function(c,l){return c=s(c),c<0?o(c+l,0):a(c,l)}},function(n,r,i){var s=i(15);n.exports=function(o){return Object(s(o))}},function(n,r,i){var s=i(21),o=i(1)("iterator"),a=i(10);n.exports=i(6).getIteratorMethod=function(c){if(c!=null)return c[o]||c["@@iterator"]||a[s(c)]}},function(n,r,i){"use strict";var s=i(37),o=i(47),a=i(10),c=i(13);n.exports=i(27)(Array,"Array",function(l,u){this._t=c(l),this._i=0,this._k=u},function(){var l=this._t,u=this._k,f=this._i++;return!l||f>=l.length?(this._t=void 0,o(1)):u=="keys"?o(0,f):u=="values"?o(0,l[f]):o(0,[f,l[f]])},"values"),a.Arguments=a.Array,s("keys"),s("values"),s("entries")},function(n,r){},function(n,r,i){"use strict";var s,o,a,c=i(28),l=i(2),u=i(7),f=i(21),p=i(23),m=i(9),g=(i(3),i(14)),y=i(38),w=i(40),S=(i(58).set,i(60)),T=i(30).set,R=i(48)(),C="Promise",D=l.TypeError,G=l.process,q=l[C],G=l.process,V=f(G)=="process",L=function(){},k=!!(function(){try{var oe=q.resolve(1),J=(oe.constructor={})[i(1)("species")]=function(ve){ve(L,L)};return(V||typeof PromiseRejectionEvent=="function")&&oe.then(L)instanceof J}catch{}})(),E=function(oe,J){return oe===J||oe===q&&J===a},A=function(oe){var J;return!(!m(oe)||typeof(J=oe.then)!="function")&&J},M=function(oe){return E(q,oe)?new I(oe):new o(oe)},I=o=function(oe){var J,ve;this.promise=new oe(function(we,Se){if(J!==void 0||ve!==void 0)throw D("Bad Promise constructor");J=we,ve=Se}),this.resolve=g(J),this.reject=g(ve)},P=function(oe){try{oe()}catch(J){return{error:J}}},F=function(oe,J){if(!oe._n){oe._n=!0;var ve=oe._c;R(function(){for(var we=oe._v,Se=oe._s==1,ct=0,Ue=function(U){var K,j,Q=Se?U.ok:U.fail,Z=U.resolve,ee=U.reject,ie=U.domain;try{Q?(Se||(oe._h==2&&b(oe),oe._h=1),Q===!0?K=we:(ie&&ie.enter(),K=Q(we),ie&&ie.exit()),K===U.promise?ee(D("Promise-chain cycle")):(j=A(K))?j.call(K,Z,ee):Z(K)):ee(we)}catch(ne){ee(ne)}};ve.length>ct;)Ue(ve[ct++]);oe._c=[],oe._n=!1,J&&!oe._h&&X(oe)})}},X=function(oe){T.call(l,function(){var J,ve,we,Se=oe._v;if(N(oe)&&(J=P(function(){V?G.emit("unhandledRejection",Se,oe):(ve=l.onunhandledrejection)?ve({promise:oe,reason:Se}):(we=l.console)&&we.error&&we.error("Unhandled promise rejection",Se)}),oe._h=V||N(oe)?2:1),oe._a=void 0,J)throw J.error})},N=function(oe){if(oe._h==1)return!1;for(var J,ve=oe._a||oe._c,we=0;ve.length>we;)if(J=ve[we++],J.fail||!N(J.promise))return!1;return!0},b=function(oe){T.call(l,function(){var J;V?G.emit("rejectionHandled",oe):(J=l.onrejectionhandled)&&J({promise:oe,reason:oe._v})})},$=function(oe){var J=this;J._d||(J._d=!0,J=J._w||J,J._v=oe,J._s=2,J._a||(J._a=J._c.slice()),F(J,!0))},pe=function(oe){var J,ve=this;if(!ve._d){ve._d=!0,ve=ve._w||ve;try{if(ve===oe)throw D("Promise can't be resolved itself");(J=A(oe))?R(function(){var we={_w:ve,_d:!1};try{J.call(oe,u(pe,we,1),u($,we,1))}catch(Se){$.call(we,Se)}}):(ve._v=oe,ve._s=1,F(ve,!1))}catch(we){$.call({_w:ve,_d:!1},we)}}};k||(q=function(oe){y(this,q,C,"_h"),g(oe),s.call(this);try{oe(u(pe,this,1),u($,this,1))}catch(J){$.call(this,J)}},s=function(oe){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},s.prototype=i(56)(q.prototype,{then:function(oe,J){var ve=M(S(this,q));return ve.ok=typeof oe!="function"||oe,ve.fail=typeof J=="function"&&J,ve.domain=V?G.domain:void 0,this._c.push(ve),this._a&&this._a.push(ve),this._s&&F(this,!1),ve.promise},catch:function(oe){return this.then(void 0,oe)}}),I=function(){var oe=new s;this.promise=oe,this.resolve=u(pe,oe,1),this.reject=u($,oe,1)}),p(p.G+p.W+p.F*!k,{Promise:q}),i(18)(q,C),i(59)(C),a=i(6)[C],p(p.S+p.F*!k,C,{reject:function(oe){var J=M(this),ve=J.reject;return ve(oe),J.promise}}),p(p.S+p.F*(c||!k),C,{resolve:function(oe){if(oe instanceof q&&E(oe.constructor,this))return oe;var J=M(this),ve=J.resolve;return ve(oe),J.promise}}),p(p.S+p.F*!(k&&i(46)(function(oe){q.all(oe).catch(L)})),C,{all:function(oe){var J=this,ve=M(J),we=ve.resolve,Se=ve.reject,ct=P(function(){var Ue=[],U=0,K=1;w(oe,!1,function(j){var Q=U++,Z=!1;Ue.push(void 0),K++,J.resolve(j).then(function(ee){Z||(Z=!0,Ue[Q]=ee,--K||we(Ue))},Se)}),--K||we(Ue)});return ct&&Se(ct.error),ve.promise},race:function(oe){var J=this,ve=M(J),we=ve.reject,Se=P(function(){w(oe,!1,function(ct){J.resolve(ct).then(ve.resolve,we)})});return Se&&we(Se.error),ve.promise}})},function(n,r,i){"use strict";var s=i(61)(!0);i(27)(String,"String",function(o){this._t=String(o),this._i=0},function(){var o,a=this._t,c=this._i;return c>=a.length?{value:void 0,done:!0}:(o=s(a,c),this._i+=o.length,{value:o,done:!1})})},function(n,r,i){i(65);for(var s=i(2),o=i(5),a=i(10),c=i(1)("toStringTag"),l=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],u=0;u<5;u++){var f=l[u],p=s[f],m=p&&p.prototype;m&&!m[c]&&o(m,c,f),a[f]=a.Array}},function(n,r){n.exports=require("child_process")},function(n,r){n.exports=require("crypto")}])})});var agt={};dr(agt,{startServer:()=>KCe});module.exports=HRe(agt);var tO=require("http"),um=require("child_process"),$i=require("fs"),nn=require("path"),nO=require("url");kr();LO();Lt();st();yf();Aq();GH();Da();oq();Ld();hf();async function $Ae(t,e){let n=t.headers.authorization;if(!n||!n.startsWith("Bearer ")){e.setHeader("Content-Type","application/json"),e.writeHead(401),e.end(JSON.stringify({error:"Unauthorized: Missing API key"}));return}let r=n.slice(7);if(!G1(r,Xi()?.key)){e.setHeader("Content-Type","application/json"),e.writeHead(401),e.end(JSON.stringify({error:"Unauthorized: Invalid API key"}));return}let i=await eR();e.setHeader("Content-Type","application/json"),e.writeHead(200),e.end(JSON.stringify(i))}Ld();Qb();var jAe=require("url");var Q1=ce(require("path"),1),WAe=ce(require("os"),1);Lt();var GAe=ce(require("path"),1),HAe=ce(require("os"),1);var dNt=GAe.default.join(HAe.default.homedir(),".9remote","pids");LD();_p();var wNt=Q1.default.dirname((0,jAe.fileURLToPath)(__importMetaUrl));var SNt=Q1.default.join(WAe.default.homedir(),".9remote","cloudflared.pid");function VAe(t,e){let n=t.split(".").map(Number),r=e.split(".").map(Number);for(let i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}var xNt=Q1.default.join(Oe.STATE,Yv.lockFile);Eo();Da();_p();kr();hf();Ld();var KAe=ce(zAe(),1),Pz=ce(require("crypto"),1),{machineIdSync:Pmt}=KAe.default;async function YAe(t=null){let e=t||process.env.MACHINE_ID_SALT||"9remote-salt";try{let n=Pmt();return Pz.default.createHash("sha256").update(n+e).digest("hex").substring(0,16)}catch(n){return console.error("Error getting machine ID:",n),Pz.default.randomUUID().replace(/-/g,"").substring(0,16)}}Eo();Lt();st();o0();Ld();fz();var XAe=be("session"),Omt=10;async function JAe(t,e){try{let n=await ac(`${e}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let s={apiKey:$n(t),expiryMinutes:Omt};return{...s,...aT(s)}})())});if(!n.ok){let s=await n.json().catch(()=>null);throw new Error(s?.error||`HTTP ${n.status}`)}let r=await n.json(),i=fAe();return pAe(r.tempKey,i,r.expiresAt,e),{...r,oneTimeKey:`${r.tempKey}${i}`}}catch(n){return XAe.error(`Temp key creation failed: ${n?.message||n}`),null}}function QAe(t,e){return e?.tempKey?`${t}/login?k=${e.tempKey}#${e.oneTimeKey}`:`${t}/login`}async function ZAe(t,e,n,r){try{let i=await ac(`${e}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:$n(t),hostPublicKey:sT(),hostX25519Key:oT(),tempKey:jS()?.tempKey||void 0})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return n&&await ac(`${e}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:$n(t),tunnelUrl:n,...aT({apiKey:$n(t),tunnelUrl:n})})}).catch(()=>{}),r&&$n(r)!==$n(t)&&await ac(`${e}/api/session/delete`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:$n(r),...aT({apiKey:$n(r)})})}).catch(()=>{}),!0}catch(i){return XAe.error(`Session registration failed: ${i?.message||i}`),!1}}Qv();Ld();_p();async function eCe(t,e){let n=wT(),r=n.workerUrl||pc;if(!n.permanentKey){it(e,400,"No permanent key set");return}let i=await JAe(n.permanentKey,r);if(!i){it(e,500,"Temp key creation failed");return}let s=QAe(r,i);wc({oneTimeKey:i.oneTimeKey,oneTimeKeyExpiresAt:i.expiresAt,qrUrl:s}),Le(e,{oneTimeKey:i.oneTimeKey,expiresAt:i.expiresAt,qrUrl:s})}async function tCe(t,e){try{let n=wT(),r=n.workerUrl||pc,i=await YAe(),s=gAe(i),o=Xi();if(!await ZAe(s,r,n.tunnelUrl,o?.key)){it(e,502,"Could not register the new key with the server");return}c7(i,s,o?.name||"Default"),Jv($n(s)),wc({permanentKey:s,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0}),Le(e,{ok:!0,permanentKey:s})}catch(n){it(e,500,n.message)}}kr();yf();E0();async function nCe(t,e){let n=await Ir(t,e);if(!n)return;let r=UAe(n.socketId);Le(e,{ok:r})}async function rCe(t,e){let n=await Ir(t,e);if(!n)return;let r=BAe(n.socketId);Le(e,{ok:r})}function iCe(t,e){Le(e,{pending:J7()})}function sCe(t,e){Le(e,{devices:Y7()})}function oCe(t,e){Le(e,{rejected:Z7()})}async function aCe(t,e){let n=await Ir(t,e);if(!n)return;let r=FAe(n.deviceId);Le(e,{ok:r})}async function cCe(t,e){let n=await Ir(t,e);n&&(J1(n.deviceId),Og(n.deviceId),Le(e))}async function lCe(t,e){let n=await Ir(t,e);n&&(J1(n.deviceId),V7(n.deviceId),Le(e))}async function uCe(t,e){let n=await Ir(t,e);if(!n)return;j7(n.deviceId);let r=J1(n.deviceId);Le(e,{disconnected:r})}function fCe(t,e){Le(e,{enabled:AL()})}async function dCe(t,e){let n=await Ir(t,e);if(!n)return;let r=z7(n.deviceId,n.label);Le(e,{ok:r})}async function pCe(t,e){let n=await Ir(t,e);if(!n)return;let r=tQ(!!n.enabled);Le(e,{enabled:r})}kr();yf();Ji();QC();Ms();Ic();Lq();oz();var hCe={},Mmt=1e4;function Nmt(t,e){let n=HU(t,e);return n||(ty(t).length?HU(t,{[ty(t)[0]]:e.csid}):null)}function gCe(t,e){if(e)return{type:e.type||"stop",sessionId:e.sessionId||"",tool:e.tool||"",csid:e.csid||"",...e};let n=JSON.parse(t||"{}");return{type:n.type||"stop",sessionId:n.sessionId||"",tool:n.tool||"",csid:n.csid||"",...n}}async function yCe(t,e){let n="";await new Promise(r=>{t.on("data",i=>n+=i),t.on("end",r)});try{vCe(gCe(n,null)),Le(e,{success:!0})}catch{it(e,400,"Invalid JSON")}}function _Ce(t,e,{query:n}){vCe(gCe(null,n)),Le(e,{success:!0})}function mCe(t,e,n){let{type:r,sessionId:i,tool:s}=t,o={type:r,sessionId:i,tool:s,timestamp:n},c=Wp({type:r,sessionId:i,tool:s})?.state||Jt.IDLE,l=ts(i);if(et(e,"statusChange",{sessionId:i,state:c,tool:s,since:n,...l?{conversationId:l.id}:{}}),QU(i,o),et(e,"chatNotification",o),(c===Jt.DONE||c===Jt.BLOCKED)&&SA(i),(c===Jt.DONE||c===Jt.BLOCKED)&&sz(i),c!==Jt.DONE&&c!==Jt.BLOCKED)return;let u=`${i}:${c}`;n-(hCe[u]||0)<Mmt||(hCe[u]=n,Eae({...o,state:c}))}function vCe(t){let{type:e,sessionId:n,tool:r}=t,i=Date.now(),s=qa();if(!s||!n)return;let o=Nmt(r,t);if(o&&ka(n,r,o,"hook"),EA[e]===Jt.DONE){bA(n,()=>mCe(t,s,Date.now()));return}mCe(t,s,i)}kr();Iq();dR();Lt();var Oz=ce(require("fs"),1),Z1=ce(require("path"),1);yf();Ji();oh();Da();var Dmt=process.platform==="darwin"||process.platform==="win32",ECe=t=>Dmt?t.toLowerCase():t,wCe=(t,e)=>{let n=ECe(t),r=ECe(e);return n===r||n.startsWith(r+Z1.default.sep)},SCe=t=>[t.cwd,t.workspacePath].filter(Boolean);function Lmt(t,e,n){if(e&&n.some(s=>s.id===e))return e;let r=null,i=-1;for(let s of n)for(let o of SCe(s))wCe(t,o)&&o.length>i&&(r=s.id,i=o.length);return r}function xCe({path:t,title:e},n=null){if(!t||typeof t!="string")return{error:"path is required"};let r=Z1.default.resolve(t);try{r=Oz.default.realpathSync(r)}catch{return{error:"File not found"}}if(Et(r))return{error:"Access denied"};if(!Oz.default.statSync(r).isFile())return{error:"Not a file"};let i=cu(),s=i.filter(c=>SCe(c).some(l=>wCe(r,l)));if(n&&i.some(c=>c.id===n)&&!s.some(c=>c.id===n))return{error:"File is outside this terminal's workspace"};if(!s.length)return{error:"File is outside every open terminal's workspace"};let o=qa();if(!o)return{error:"Server not ready"};let a=Lmt(r,n,s);return et(o,"artifactOpen",{path:r,title:e||Z1.default.basename(r),sessionId:a}),{path:r}}var Umt={name:"openArtifact",description:"Show a file you just created or edited in the 9Remote app, sliding it in beside the terminal. Use it for files worth looking at \u2014 html, markdown, svg, images, pdf, csv, diagrams, code. Skip files with nothing to see. The user closes it themselves.",inputSchema:{type:"object",properties:{path:{type:"string",description:"Absolute path to the file."},title:{type:"string",description:"Optional label for the panel header."}},required:["path"]},run({path:t,title:e},n){let r=xCe({path:t,title:e},n?.sessionId);return r.error?r:`Opened ${r.path}`}},bCe=Umt;zw();u4();var Fmt=500;function Bmt(t={applyAction:A_}){return{name:"report_task",description:"Report what you just finished, in one or two sentences. It lands on this session's card on the kanban board the user watches, so progress is visible without reading your terminal. Call it when a chunk of work completes, and again with status when your own state changes (todo | in_progress | needs_input | done). While a turn of yours is actually running, the live state wins \u2014 the self-report takes effect when you go idle.",inputSchema:{type:"object",properties:{summary:{type:"string",description:"1-2 sentences of what was done or what changed"},status:{type:"string",enum:l4,description:"Optional self-reported status; live turn state still wins while running"}},required:["summary"]},async run({summary:e,status:n}={},r={}){let i=String(e||"").trim().slice(0,Fmt);if(!i)return{error:"summary is required"};let s=r?.sessionId;if(!s)return{error:"no session identity; cannot tell which card is yours"};let{error:o}=await t.applyAction({type:"report",sessionId:s,summary:i,...n?{status:n}:{}});return o?{error:o}:"reported"}}}var TCe=Bmt();xk();var ACe=[bCe,TCe],CCe=new Map([...ACe,...yd].map(t=>[t.name,t])),RCe=()=>ACe.map(({name:t,description:e,inputSchema:n})=>({name:t,description:e,inputSchema:n}));var eO=(t,e=!1)=>({content:[{type:"text",text:t}],isError:e});async function qmt(t,e,n){let r=CCe.get(t);if(!r)return eO(`Unknown tool: ${t}`,!0);try{let i=await r.run(e||{},n||{});return i?.error?eO(i.error,!0):eO(typeof i=="string"?i:JSON.stringify(i))}catch(i){return eO(i.message,!0)}}async function ICe(t,e){let{id:n,method:r,params:i}=t||{},s=o=>({jsonrpc:"2.0",id:n,result:o});return r==="initialize"?s({protocolVersion:i?.protocolVersion||Sl.PROTOCOL_VERSION,capabilities:{tools:{}},serverInfo:{name:Sl.SERVER_NAME,version:"3.0.6"}}):r==="tools/list"?s({tools:RCe()}):r==="tools/call"?s(await qmt(i?.name,i?.arguments,e)):r==="ping"?s({}):n==null?null:{jsonrpc:"2.0",id:n,error:{code:-32601,message:`Method not found: ${r}`}}}var Nz=ce(require("fs"),1),PCe=require("child_process");st();Cq();var $mt=be("artifact"),kCe=/(?:^|[\s\0])NINE_REMOTE_SESSION_ID=([^\s\0]+)/,Mz=new WeakMap,Dz=(t,e)=>(0,PCe.execFileSync)(t,e,{encoding:"utf8",timeout:Oy.PROBE_TIMEOUT_MS,stdio:["ignore","pipe","ignore"]});function Gmt(t,e){let n=Dz("lsof",["-nP",`-iTCP:${t}`,"-Fpn"]),r=null;for(let i of n.split(`
|
|
514
|
+
`))if(i[0]==="p")r=parseInt(i.slice(1),10);else if(i[0]==="n"&&r&&r!==e){let s=i.match(/^n(?:\[[^\]]+\]|[^:]+):(\d+)->/);if(s&&Number(s[1])===t)return r}return null}function Hmt(t){try{return process.platform==="linux"?Nz.default.readFileSync(`/proc/${t}/environ`,"utf8").match(kCe)?.[1]||null:Dz("ps",["-Eww","-o","command=","-p",String(t)]).match(kCe)?.[1]||null}catch{return null}}function jmt(t){try{if(process.platform==="linux"){let e=Nz.default.readFileSync(`/proc/${t}/stat`,"utf8");return parseInt(e.slice(e.lastIndexOf(")")+2).split(" ")[1],10)||null}return parseInt(Dz("ps",["-o","ppid=","-p",String(t)]).trim(),10)||null}catch{return null}}function Wmt(t){for(let e=0;t>1&&t!==process.pid&&e<Oy.MAX_PARENT_HOPS;e++){let n=Hmt(t);if(n)return n;if(t=jmt(t),!t)return null}return null}function OCe(t){let e=t?.headers?.[Oy.HEADER];if(e&&!/[${}]/.test(e))return e;let n=t?.socket;if(!n)return null;if(Mz.has(n))return Mz.get(n);let r=null;try{let i=Gmt(n.remotePort,process.pid);i&&(r=Wmt(i))}catch(i){$mt.warn(`caller probe failed: ${i.message}`)}return Mz.set(n,r),r}async function MCe(t,e){if(!Ece(t.headers.authorization))return it(e,401,"Unauthorized");if(!LE())return it(e,403,"MCP is turned off in 9Remote settings");let n=await Ir(t,e);if(n===null&&!e.writableEnded)return it(e,400,"Invalid request");if(e.writableEnded)return;let r;try{r=await ICe(n,{sessionId:OCe(t)})}catch(i){r={jsonrpc:"2.0",id:n?.id??null,error:{code:-32603,message:i.message}}}if(!r)return e.writeHead(202),e.end();e.setHeader("Content-Type","application/json"),e.writeHead(200),e.end(JSON.stringify(r))}kr();yT();hf();Ur();Eo();function NCe(){return{mode:GD(),active:$D(),presets:Object.keys(Te.sleepInhibit?.presets||{})}}function DCe(t,e){Le(e,NCe())}async function LCe(t,e){let n=await Ir(t,e);if(!n)return;let r=g0(n.mode);a7({sleepInhibitMode:r});let i=NCe();Jn("sleepInhibit",i),Le(e,i)}kr();HL();async function UCe(t,e){let n=await BT();Le(e,n)}async function FCe(t,e){let n=await NQ(),r=await BT();Le(e,{...n,...r})}async function BCe(t,e){let n=await Ir(t,e);if(!n)return;if(typeof n.text!="string"||!n.text){it(e,400,"Missing text");return}let r=await C0(n.text);Le(e,{ok:r.ok,reason:r.reason||null})}async function qCe(t,e){let n=await MQ(),r=await BT();Le(e,{...n,...r})}di();kr();async function $Ce(t,e){try{let n=await vf();Le(e,{sessions:n})}catch(n){it(e,500,n.message)}}async function GCe(t,e){let n=await Ir(t,e);if(n){if(!n.sessionId)return it(e,400,"sessionId required");try{await Ef(n.sessionId),Le(e)}catch(r){it(e,500,r.message)}}}var Fu=ce(require("os"),1);Ur();JT();kr();function Vmt(){let t=xZ();if(!t?.activeClients)return{total:0,streaming:0};let e=0;for(let n of t.activeClients.values())n.isStreaming&&e++;return{total:t.activeClients.size,streaming:e}}function zmt(){let t=process.memoryUsage(),e=Fu.default.cpus();return{agent:{pid:process.pid,version:"3.0.6",nodeVersion:process.version,platform:`${process.platform}/${process.arch}`,uptimeSec:Math.round(process.uptime()),memory:{heapUsedMB:Math.round(t.heapUsed/1048576*10)/10,heapTotalMB:Math.round(t.heapTotal/1048576*10)/10,rssMB:Math.round(t.rss/1048576*10)/10,externalMB:Math.round(t.external/1048576*10)/10}},os:{hostname:Fu.default.hostname(),platform:Fu.default.platform(),arch:Fu.default.arch(),uptimeSec:Math.round(Fu.default.uptime()),loadAvg:Fu.default.loadavg(),cpuModel:e?.[0]?.model||"unknown",cpuCount:e.length,totalMemMB:Math.round(Fu.default.totalmem()/1048576),freeMemMB:Math.round(Fu.default.freemem()/1048576)},remote:{available:XT(),...Vmt(),memoryWarningThresholdMB:Te.resourceManagement.memoryWarningThreshold},timestamp:Date.now()}}function HCe(t,e){try{Le(e,zmt())}catch(n){it(e,500,"stats error",n.message)}}yT();hf();Ur();I8();V8();var ea=be("server"),ta=(0,nO.fileURLToPath)(new URL(".",__importMetaUrl)),VCe=process.env.NODE_ENV==="development",Kmt=5173,Lz=[(0,nn.join)(ta,"dist","ui"),(0,nn.join)(ta,"ui","dist"),(0,nn.join)(ta,"ui")].find(t=>(0,$i.existsSync)(t))||(0,nn.join)(ta,"dist","ui"),tc=[(0,nn.join)(ta,"dist","web"),(0,nn.join)(ta,"web"),(0,nn.join)(ta,"..","web","out")].find(t=>(0,$i.existsSync)(t))||Lz,Ymt={".html":"text/html; charset=utf-8",".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif",".ico":"image/x-icon",".woff2":"font/woff2",".woff":"font/woff",".ttf":"font/ttf",".json":"application/json; charset=utf-8",".txt":"text/x-component; charset=utf-8",".webmanifest":"application/manifest+json"};function Xmt(t,e,n){let r=(0,tO.request)({hostname:"localhost",port:Kmt,path:t.url,method:t.method,headers:t.headers},i=>{e.writeHead(i.statusCode,i.headers),i.pipe(e)});r.on("error",()=>n?n():void(e.writeHead(502),e.end("Vite dev server not ready"))),t.pipe(r)}function Jmt(t,e){let n;try{n=(0,nO.parse)(t.url).pathname}catch{it(e,400,"Bad request");return}let r=H8(n,t.headers.host);if(!r){it(e,404,"Not found");return}for(let[i,s]of Object.entries(r.headers))e.setHeader(i,s);hs(e,(0,nn.join)(tc,r.path),{frameable:!0})||it(e,404,"Not found")}function hs(t,e,{frameable:n=!1}={}){if(!(0,$i.existsSync)(e))return!1;try{if((0,$i.statSync)(e).isDirectory()){let a=(0,nn.join)(e,"index.html");return(0,$i.existsSync)(a)?hs(t,a,{frameable:n}):!1}let i=(0,nn.extname)(e),s=Ymt[i]||"application/octet-stream";t.setHeader("Content-Type",s),i===".html"&&!n&&t.setHeader("X-Frame-Options","SAMEORIGIN");let o=e.includes(`${nn.sep}_next${nn.sep}static${nn.sep}`);return t.hasHeader("Cache-Control")||t.setHeader("Cache-Control",o?"public, max-age=31536000, immutable":"no-cache"),t.writeHead(200),t.end((0,$i.readFileSync)(e)),!0}catch{return!1}}async function Uz(t){try{let e=await ac(MO);if(!e.ok)return;let{version:n}=await e.json();n&&VAe(t,n)&&(YD({version:n}),Jn("updateAvailable",{version:n}),$q())}catch{}}var jCe=0;function Qmt(t){let e=Date.now();e-jCe<Yv.connectCheckDebounceMs||(jCe=e,Uz(t))}function Zmt(t,e){if(process.env.CODESPACES!=="true"){it(e,400,"Not running on Codespaces");return}let n=process.env.CODESPACE_NAME;if(!n){it(e,400,"Codespace name not found");return}let r=qa();r&&r.emit("codespace:stopping"),Le(e,{success:!0,message:"Stopping codespace..."}),setTimeout(()=>(0,um.execFile)("gh",["codespace","stop","-c",n],{windowsHide:!0}),500)}async function egt(t,e){let{parseJsonBody:n}=await Promise.resolve().then(()=>(kr(),Zu)),r=await n(t,e);if(!r)return;let{verifyPresentedTail:i}=await Promise.resolve().then(()=>(Sz(),SAe)),s=i({tail:r.tail,tempKey:r.tempKey});if(s.ok){Le(e,{ok:!0});return}let o=t.headers["x-forwarded-for"]||t.socket?.remoteAddress||"unknown";if(r.tempKey&&r.tail){ea.warn(`wrong one-time code TAIL (${o}) \u2014 code burned, clearing from UI`);let{clearOneTimeKey:a}=await Promise.resolve().then(()=>(Eo(),U7));a()}else r.tempKey?ea.warn(`wrong one-time code TAIL (${o}) \u2014 no TAIL presented, code still live`):ea.warn(`wrong API-key TAIL (${o}) \u2014 rejected`);setTimeout(()=>Le(e,{ok:!1,reason:s.reason}),s.penaltyMs||0)}var zCe;async function WCe(t,e,{pathname:n}){let r=t.headers.authorization;if(!r||!r.startsWith("Bearer ")||!G1(r.slice(7),Xi()?.key)){it(e,401,"Unauthorized");return}let{parseJsonBody:i}=await Promise.resolve().then(()=>(kr(),Zu)),s=await i(t,e);if(!s)return;if(!s.port){it(e,400,"Port required");return}if(!n.endsWith("start")){oR(s.port),Le(e,{success:!0});return}let o=sR(s.port);if(!o){it(e,400,"Invalid port");return}Le(e,{success:!0,sessionId:o})}function tgt(t,e,{pathname:n,search:r}){let i=n.match(/^\/proxy\/([0-9a-f-]{36})(\/.*)?$/);i?yce(zCe,t,e,i[1],i[2]||"/",r):it(e,404,"Not found")}function ngt(t,e,n){t_e(t,e,n)}var rgt=[{path:"/api/health",method:"GET",public:!0,handler:(t,e)=>Le(e,{status:"ok",timestamp:Date.now()})},{path:"/api/version",method:"GET",public:!0,handler:(t,e)=>{let n="3.0.6";e.setHeader("Cache-Control","no-store"),Le(e,{version:n})}},{path:"/api/notify",method:"POST",public:!0,handler:yCe},{path:"/api/notify",method:"GET",public:!0,handler:_Ce},{path:"/proxy/*",method:"*",public:!0,handler:tgt},{path:"/preview/*",method:"GET",public:!0,handler:ngt},{path:"/api/ui/events",method:"GET",handler:nL},{path:"/api/local-token",method:"GET",handler:ZD},{path:Sl.PATH,method:"POST",handler:MCe},{path:"/api/ui/state",method:"GET",handler:rL},{path:"/api/ui/state",method:"POST",handler:iL},{path:"/api/ui/stop",method:"POST",handler:sL},{path:"/api/ui/start",method:"POST",handler:oL},{path:"/api/ui/stop-tunnel",method:"POST",handler:aL},{path:"/api/ui/shutdown",method:"POST",handler:cL},{path:"/api/update",method:"POST",handler:lL},{path:"/api/system/stats",method:"GET",handler:HCe},{path:"/api/key/one-time",method:"POST",handler:eCe},{path:"/api/key/regenerate",method:"POST",handler:tCe},{path:"/api/device/approve",method:"POST",handler:nCe},{path:"/api/device/reject",method:"POST",handler:rCe},{path:"/api/device/pending",method:"GET",handler:iCe},{path:"/api/device/approved",method:"GET",handler:sCe},{path:"/api/device/rejected",method:"GET",handler:oCe},{path:"/api/device/approve-rejected",method:"POST",handler:aCe},{path:"/api/device/clear-rejected",method:"POST",handler:cCe},{path:"/api/device/remove",method:"POST",handler:lCe},{path:"/api/device/label",method:"POST",handler:dCe},{path:"/api/device/disconnect",method:"POST",handler:uCe},{path:"/api/device/auto-approve",method:"GET",handler:fCe},{path:"/api/device/auto-approve",method:"POST",handler:pCe},{path:"/api/connections",method:"GET",handler:uL},{path:"/api/logs",method:"GET",handler:fL},{path:"/api/logs/clear",method:"POST",handler:dL},{path:"/api/permissions",method:"GET",handler:hL},{path:"/api/permissions/request",method:"POST",handler:yL},{path:"/api/desktop/toggle",method:"POST",handler:pL},{path:"/api/ui/rtc-toggle",method:"POST",handler:eL},{path:"/api/autostart",method:"GET",handler:mL},{path:"/api/autostart",method:"POST",handler:gL},{path:"/api/sleep-inhibit",method:"GET",handler:DCe},{path:"/api/sleep-inhibit",method:"POST",handler:LCe},{path:"/api/desktop-unlock",method:"GET",handler:UCe},{path:"/api/desktop-unlock/install",method:"POST",handler:FCe},{path:"/api/desktop-unlock/uninstall",method:"POST",handler:qCe},{path:"/api/desktop-unlock/type",method:"POST",handler:BCe},{path:"/api/sessions",method:"GET",handler:$Ce},{path:"/api/sessions/delete",method:"POST",handler:GCe},{path:"/api/local-sites",method:"*",public:!0,handler:$Ae},{path:"/api/codespace/stop",method:"POST",handler:Zmt},{path:"/api/verify-key",method:"POST",public:!0,handler:egt},{path:"/api/proxy/start",method:"POST",public:!0,handler:WCe},{path:"/api/proxy/end",method:"POST",public:!0,handler:WCe}];var igt=parseInt(process.env.PORT||"2208",10),QS=null;function sgt(t){if(process.platform!=="win32")try{let e=(0,um.execSync)(`pgrep -f "vite --config ${t}"`,{encoding:"utf8"}).trim();for(let n of e.split(`
|
|
515
|
+
`).filter(Boolean))if((0,um.execSync)(`ps -o ppid= -p ${n}`,{encoding:"utf8"}).trim()==="1")try{process.kill(Number(n))}catch{}}catch{}}function ogt(){if(!VCe)return;let t=(0,nn.join)(ta,"vite.config.js");if(!(0,$i.existsSync)(t))return;sgt(t);let e=(0,$i.existsSync)((0,nn.join)(ta,"node_modules",".bin","vite"))?(0,nn.join)(ta,"node_modules",".bin","vite"):(0,nn.join)(ta,"..","node_modules",".bin","vite");QS=(0,um.spawn)("node",[e,"--config",t],{cwd:ta,stdio:"ignore",detached:!1}),QS.on("error",()=>{}),QS.unref()}async function KCe(){let t=MD(),e=t.sleepInhibitMode;e||(t.sleepInhibit===!1?e="never":e=Te.sleepInhibit?.defaultMode||"never"),g0(e),await qq(),zCe=gce(),ogt();let r=DO(rgt,{fallback:(c,l,{pathname:u})=>{if(u.startsWith("/api/")||u.startsWith("/socket.io")){it(l,404,"Not found");return}let f=u.replace(/^\//,"");if(f.split(/[\\/]/).includes("..")){it(l,400,"Bad request");return}if((0,$i.existsSync)(tc)&&f)try{let g=(0,nn.join)(tc,f);if((0,$i.existsSync)(g)&&!(0,$i.statSync)(g).isDirectory()&&hs(l,g))return}catch{}if((u==="/workspace"||u.startsWith("/workspace/")||u.startsWith("/_next/")||u==="/login"||u.startsWith("/login/"))&&(0,$i.existsSync)(tc)){let g=(0,nn.join)(tc,f);if(hs(l,g)||hs(l,`${g}.html`)||hs(l,(0,nn.join)(g,"index.html"))||(c.headers.rsc==="1"||f.endsWith(".txt"))&&(f.startsWith("workspace/terminal/")&&hs(l,(0,nn.join)(tc,"workspace","terminal","default.txt"))||hs(l,(0,nn.join)(tc,"workspace.txt")))||u.startsWith("/workspace")&&(hs(l,(0,nn.join)(tc,"workspace.html"))||hs(l,(0,nn.join)(tc,"workspace","index.html")))||u.startsWith("/login")&&(hs(l,(0,nn.join)(tc,"login.html"))||hs(l,(0,nn.join)(tc,"login","index.html"))))return;it(l,404,"Not found");return}let m=()=>{let g=f==="ui"||f===""?"index.html":f.replace(/^ui\/?/,""),y=(0,nn.join)(Lz,g);hs(l,y)||hs(l,(0,nn.join)(Lz,"index.html"))||it(l,404,"Not found")};if(VCe){Xmt(c,l,m);return}m()}}),i=(0,tO.createServer)(async(c,l)=>{if(Cx(c.headers.host)){Jmt(c,l);return}await r(c,l)});tD(),WD(),VD();let s=()=>bT().catch(c=>ea.error(`permission refresh failed: ${c?.message||c}`));s(),process.platform==="darwin"&&setInterval(s,k8),await qAe(i),i.on("error",c=>{ea.error(`HTTP server error: ${c?.message||c}`),c?.code==="EADDRINUSE"&&process.exit(1)}),i.listen(igt,c=>{if(c)throw c;let l="3.0.6";Uz(l),setInterval(()=>Uz(l),Yv.checkIntervalMs),Gq(()=>Qmt(l))});let o=!1,a=async c=>{if(o)return;o=!0,qD(),ea.info(`\u{1F6D1} Received ${c}, shutting down gracefully...`);let l=setTimeout(()=>{ea.error("\u26A0\uFE0F Forced exit"),process.exit(1)},5e3);try{if(i.close(()=>ea.info("\u2713 HTTP server closed")),QS)try{QS.kill()}catch{}let u=qa();u&&(u.emit("server:shutdown"),u.close(()=>ea.info("\u2713 Socket.IO closed"))),await new Promise(f=>setTimeout(f,500)),clearTimeout(l),ea.info("\u2705 Server stopped cleanly"),process.exit(0)}catch(u){ea.error(`\u274C Error during shutdown: ${u?.message||u}`),clearTimeout(l),process.exit(1)}};return process.on("SIGINT",()=>a("SIGINT")),process.on("SIGTERM",()=>a("SIGTERM")),process.platform==="win32"&&process.on("SIGBREAK",()=>a("SIGBREAK")),i}KCe().catch(t=>{ea.error(`Server failed to start: ${t?.stack||t?.message||t}`),process.exit(1)});0&&(module.exports={startServer});
|
|
516
516
|
/*! Bundled license information:
|
|
517
517
|
|
|
518
518
|
negotiator/index.js:
|