9remote 3.0.10 → 3.0.11
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-Dis7ADvo.js +8 -0
- package/dist/ui/index.html +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +2 -2
- package/dist/web/__next._full.txt +2 -2
- package/dist/web/__next._head.txt +1 -1
- package/dist/web/__next._index.txt +1 -1
- package/dist/web/__next._tree.txt +1 -1
- package/dist/web/_next/static/chunks/app/login/{page-0808c3505c028b76.js → page-1db3e14c6da784f1.js} +1 -1
- package/dist/web/_next/static/chunks/app/{page-713809a139d63806.js → page-7f6a2a71b53981dc.js} +2 -2
- package/dist/web/_next/static/chunks/app/workspace/{layout-a0c555254829e1bf.js → layout-1ca3e32492ef60bc.js} +3 -3
- package/dist/web/_not-found/__next._full.txt +1 -1
- package/dist/web/_not-found/__next._head.txt +1 -1
- package/dist/web/_not-found/__next._index.txt +1 -1
- 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 +1 -1
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +1 -1
- package/dist/web/admin/__next._full.txt +1 -1
- package/dist/web/admin/__next._head.txt +1 -1
- package/dist/web/admin/__next._index.txt +1 -1
- package/dist/web/admin/__next._tree.txt +1 -1
- package/dist/web/admin/__next.admin.__PAGE__.txt +1 -1
- package/dist/web/admin/__next.admin.txt +1 -1
- package/dist/web/admin/admins/__next._full.txt +1 -1
- package/dist/web/admin/admins/__next._head.txt +1 -1
- package/dist/web/admin/admins/__next._index.txt +1 -1
- package/dist/web/admin/admins/__next._tree.txt +1 -1
- package/dist/web/admin/admins/__next.admin.admins.__PAGE__.txt +1 -1
- 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 +1 -1
- package/dist/web/admin/login/__next._full.txt +1 -1
- package/dist/web/admin/login/__next._head.txt +1 -1
- package/dist/web/admin/login/__next._index.txt +1 -1
- package/dist/web/admin/login/__next._tree.txt +1 -1
- package/dist/web/admin/login/__next.admin.login.__PAGE__.txt +1 -1
- 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 +1 -1
- package/dist/web/admin/modes/__next._full.txt +1 -1
- package/dist/web/admin/modes/__next._head.txt +1 -1
- package/dist/web/admin/modes/__next._index.txt +1 -1
- package/dist/web/admin/modes/__next._tree.txt +1 -1
- package/dist/web/admin/modes/__next.admin.modes.__PAGE__.txt +1 -1
- 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 +1 -1
- package/dist/web/admin/ota/__next._full.txt +1 -1
- package/dist/web/admin/ota/__next._head.txt +1 -1
- package/dist/web/admin/ota/__next._index.txt +1 -1
- package/dist/web/admin/ota/__next._tree.txt +1 -1
- package/dist/web/admin/ota/__next.admin.ota.__PAGE__.txt +1 -1
- 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 +1 -1
- package/dist/web/admin/turn/__next._full.txt +1 -1
- package/dist/web/admin/turn/__next._head.txt +1 -1
- package/dist/web/admin/turn/__next._index.txt +1 -1
- package/dist/web/admin/turn/__next._tree.txt +1 -1
- package/dist/web/admin/turn/__next.admin.turn.__PAGE__.txt +1 -1
- 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 +1 -1
- package/dist/web/admin.html +1 -1
- package/dist/web/admin.txt +1 -1
- package/dist/web/dev/question/__next._full.txt +1 -1
- package/dist/web/dev/question/__next._head.txt +1 -1
- package/dist/web/dev/question/__next._index.txt +1 -1
- package/dist/web/dev/question/__next._tree.txt +1 -1
- package/dist/web/dev/question/__next.dev.question.__PAGE__.txt +1 -1
- 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 +1 -1
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +2 -2
- package/dist/web/login/__next._full.txt +2 -2
- package/dist/web/login/__next._head.txt +1 -1
- package/dist/web/login/__next._index.txt +1 -1
- package/dist/web/login/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/__next._full.txt +2 -2
- package/dist/web/workspace/__next._head.txt +1 -1
- package/dist/web/workspace/__next._index.txt +1 -1
- package/dist/web/workspace/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/browse/__next._head.txt +1 -1
- package/dist/web/workspace/browse/__next._index.txt +1 -1
- package/dist/web/workspace/browse/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/editor/__next._full.txt +2 -2
- package/dist/web/workspace/editor/__next._head.txt +1 -1
- package/dist/web/workspace/editor/__next._index.txt +1 -1
- package/dist/web/workspace/editor/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/files/__next._full.txt +2 -2
- package/dist/web/workspace/files/__next._head.txt +1 -1
- package/dist/web/workspace/files/__next._index.txt +1 -1
- package/dist/web/workspace/files/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/git/__next._full.txt +2 -2
- package/dist/web/workspace/git/__next._head.txt +1 -1
- package/dist/web/workspace/git/__next._index.txt +1 -1
- package/dist/web/workspace/git/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/mobile/__next._full.txt +2 -2
- package/dist/web/workspace/mobile/__next._head.txt +1 -1
- package/dist/web/workspace/mobile/__next._index.txt +1 -1
- package/dist/web/workspace/mobile/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/remote/__next._full.txt +2 -2
- package/dist/web/workspace/remote/__next._head.txt +1 -1
- package/dist/web/workspace/remote/__next._index.txt +1 -1
- package/dist/web/workspace/remote/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/terminal/default/__next._full.txt +2 -2
- package/dist/web/workspace/terminal/default/__next._head.txt +1 -1
- package/dist/web/workspace/terminal/default/__next._index.txt +1 -1
- package/dist/web/workspace/terminal/default/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace/workspaces/__next._full.txt +2 -2
- package/dist/web/workspace/workspaces/__next._head.txt +1 -1
- package/dist/web/workspace/workspaces/__next._index.txt +1 -1
- package/dist/web/workspace/workspaces/__next._tree.txt +1 -1
- 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 +2 -2
- package/dist/web/workspace.html +1 -1
- package/dist/web/workspace.txt +2 -2
- package/package.json +1 -1
- package/dist/ui/assets/index-D68zm5P3.js +0 -8
- /package/dist/web/_next/static/{WHp5d7WTHBHyfu2RWtrXR → LzU93v-WhDilDnQQPclsp}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{WHp5d7WTHBHyfu2RWtrXR → LzU93v-WhDilDnQQPclsp}/_ssgManifest.js +0 -0
package/dist/server.cjs
CHANGED
|
@@ -409,7 +409,7 @@ export default function (pi) {
|
|
|
409
409
|
pi.on("agent_start", async (_e, ctx) => { if (ctx?.hasUI) post("working", csidOf(ctx)); });
|
|
410
410
|
pi.on("agent_end", async (_e, ctx) => { if (ctx?.hasUI) post("done", csidOf(ctx)); });
|
|
411
411
|
}
|
|
412
|
-
`}function P3e(t){let e=I3e[t];if(!e)return{success:!1,error:"Unknown tool"};try{return t==="codex"||t==="opencode"||t==="amp"||t==="pi"||t==="omp"?e.enable():e.enable(fn[t]())}catch(n){return{success:!1,error:n.message}}}function O3e(t){let e=(process.env.PATH||"").split(pr.default.delimiter).filter(Boolean),n=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT").split(";"):[""];return e.some(r=>n.some(i=>{try{return He.default.existsSync(pr.default.join(r,t+i))}catch{return!1}}))}function xle(t){let e=_le[t];if(e&&O3e(e))return!0;let n=s3e[t]?.();return n?(Array.isArray(n)?n:[n]).some(r=>He.default.existsSync(r)):!1}function ble(){let t={};for(let e of k3e)if(xle(e))try{let n=P3e(e);t[e]=n.success&&!n.untrusted?.length}catch{t[e]=!1}return t}async function Tle(){if(!xle("codex"))return null;try{let{missing:t}=await g3e();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 Ale(){let t=fn.claude(),e=Ir(t);if(!e.hooks?.Stop&&!e.hooks?.Notification)return;let n=e.env||{};Object.keys(Nv).some(i=>n[i]!==Nv[i])&&(vle(e),us(t,e))}var mle,He,pr,gle,PR,yle,i3e,vi,Qd,fn,_le,Ah,s3e,t2,OR,kR,o3e,IR,Ele,zAt,wle,f3e,h3e,_3e,ple,E3e,x3e,T3e,A3e,C3e,R3e,I3e,k3e,Cle=ae(()=>{mle=ce(require("os"),1),He=ce(require("fs"),1),pr=ce(require("path"),1),gle=require("child_process");Lt();Eo();Lc();PR=`http://localhost:${Ss}/api/notify`,yle="nineRemoteNotify",i3e=pr.default.join(Oe.STATE,"claudeEnvBackup.json"),vi=(...t)=>pr.default.join(mle.default.homedir(),...t),Qd=(t,...e)=>{let n=process.env[t];return n&&n.trim()?n.trim():vi(...e)},fn={claude:()=>vi(".claude","settings.json"),codex:()=>vi(".codex","config.toml"),codexHooks:()=>vi(".codex","hooks.json"),codexScript:()=>vi(".codex","9remote-notify.sh"),opencode:()=>vi(".config","opencode","plugin",`${yle}.js`),grok:()=>pr.default.join(Qd("GROK_HOME",".grok"),"hooks","9remote.json"),cursor:()=>vi(".cursor","hooks.json"),antigravity:()=>vi(".gemini","config","hooks.json"),kiro:()=>pr.default.join(Qd("KIRO_HOME",".kiro"),"agents","9remote.json"),copilot:()=>pr.default.join(Qd("COPILOT_HOME",".copilot"),"config.json"),codebuddy:()=>pr.default.join(Qd("CODEBUDDY_CONFIG_DIR",".codebuddy"),"settings.json"),factory:()=>vi(".factory","settings.json"),qoder:()=>pr.default.join(Qd("QODER_CONFIG_DIR",".qoder"),"settings.json"),rovodev:()=>vi(".rovodev","config.yml"),hermes:()=>pr.default.join(Qd("HERMES_HOME",".hermes"),"config.yaml"),amp:()=>vi(".config","amp","plugins","9remote.ts"),devin:()=>vi(".config","devin","config.json"),pi:()=>pr.default.join(Qd("PI_CODING_AGENT_DIR",".pi","agent"),"extensions","9remote.ts"),omp:()=>pr.default.join(Qd("PI_CODING_AGENT_DIR",".omp","agent"),"extensions","9remote.ts")},_le={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",omp:"omp",devin:"devin"},Ah=(t,e,{sessionId:n=!1}={})=>{let r=n?oF(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 "${PR}?type=${t}&sessionId=$NINE_REMOTE_SESSION_ID${r?"&csid=$csid":""}&tool=${e}" > /dev/null 2>&1 & true`},s3e={claude:()=>vi(".claude"),codex:()=>vi(".codex"),opencode:()=>[vi(".config","opencode"),vi(".opencode")]},t2=t=>Math.ceil(t/1e3),OR=5e3,kR=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o3e=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;IR={UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked"},Ele=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase(),zAt=Object.fromEntries(Object.keys(IR).map(t=>[Ele(t),t])),wle=/^\[hooks\.state\."(?<key>[^"]+)"\]$/m,f3e=15e3;h3e=t=>/^sha256:/.test(t)?t:`sha256:${t}`;_3e=/# 9Remote notification\nnotify\s*=.*\n?/g,ple=/^# 9Remote-saved: (notify\s*=.*)$/m;E3e={enable(){let t=fn.codexHooks(),e=Ir(t),n={...e.hooks||{}};for(let[r,i]of Object.entries(IR))n[r]=[...(n[r]||[]).filter(s=>!e2(s)),w3e(i)];return e.hooks=n,us(t,e),v3e(),{success:!0}},disable(){let t=fn.codexHooks(),e=new Set(Sle(t).filter(n=>n.command.includes("&tool=codex")).map(n=>n.key));if(He.default.existsSync(t)){let n=Ir(t);if(n.hooks){for(let r of Object.keys(IR))n.hooks[r]=(n.hooks[r]||[]).filter(i=>!e2(i)),n.hooks[r].length===0&&delete n.hooks[r];Object.keys(n.hooks).length===0&&delete n.hooks}us(t,n)}return y3e(fn.codex(),e),{success:!0}},isEnabled(){let t=Ir(fn.codexHooks()).hooks||{};return Object.keys(IR).every(e=>(t[e]||[]).some(e2))}};x3e={enable(){let t=fn.opencode(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,S3e(),"utf8"),{success:!0}},disable(){let t=fn.opencode();return He.default.existsSync(t)&&He.default.unlinkSync(t),{success:!0}},isEnabled(){let t=fn.opencode();return He.default.existsSync(t)&&He.default.readFileSync(t,"utf8").includes("&sessionID=")}};T3e="# 9remote hooks begin",A3e="# 9remote hooks end",C3e=" # 9remote hooks begin",R3e=" # 9remote hooks end",I3e={claude:Th("claude",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked",Notification:"blocked"},t=>t,{matchers:{Notification:"permission_prompt"},extra:vle,sessionId:!0}),devin:Th("devin",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked"},t=>t,{sessionId:!0}),codex:E3e,opencode:x3e,grok:Th("grok",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",Notification:"blocked"},t2),cursor:l3e("cursor",{stop:"done",beforeShellExecution:"blocked",beforeToolCall:"working"},{extra:t=>{t.version=t.version||1}}),antigravity:u3e("antigravity","9remote",{UserPromptSubmit:"working",PreToolUse:"working",Stop:"done",Notification:"blocked"}),kiro:d3e("kiro",{UserPromptSubmit:"working",PostToolUse:"working",preToolUse:"blocked",stop:"done"}),copilot:Th("copilot",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),codebuddy:Th("codebuddy",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),factory:Th("factory",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),qoder:Th("qoder",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),rovodev:fle("rovodev",{begin:C3e,end:R3e,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=fle("hermes",{begin:T3e,end:A3e,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=()=>pr.default.join(pr.default.dirname(fn.hermes()),"shell-hooks-allowlist.json");return{enable:()=>{let n=t.enable(fn.hermes()),r=Ir(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:Ah(o,"hermes"),approved_at:"2020-01-01T00:00:00Z"}))],us(e(),r),n},disable:()=>{let n=t.disable(fn.hermes()),r=e();if(He.default.existsSync(r)){let i=Ir(r);i.approvals=(i.approvals||[]).filter(s=>!(typeof s.command=="string"&&s.command.includes("&tool=hermes"))),i.approvals.length?us(r,i):He.default.unlinkSync(r)}return n},isEnabled:()=>t.isEnabled(fn.hermes())}})(),amp:{enable(){let t=fn.amp(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,hle("amp","amp","agent.start","agent.end"),"utf8"),{success:!0}},disable(){return He.default.existsSync(fn.amp())&&He.default.unlinkSync(fn.amp()),{success:!0}},isEnabled(){return He.default.existsSync(fn.amp())}},pi:{enable(){let t=fn.pi(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,hle("pi","pi","agent_start","agent_end"),"utf8"),{success:!0}},disable(){return He.default.existsSync(fn.pi())&&He.default.unlinkSync(fn.pi()),{success:!0}},isEnabled(){return He.default.existsSync(fn.pi())}},omp:{enable(){let t=fn.omp(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,b3e(),"utf8"),{success:!0}},disable(){return He.default.existsSync(fn.omp())&&He.default.unlinkSync(fn.omp()),{success:!0}},isEnabled(){return He.default.existsSync(fn.omp())}}},k3e=Z8});var n2=ae(()=>{Ds()});var Zq={};gr(Zq,{broadcastAiStatus:()=>ZE,broadcastServerInfo:()=>a2,initializeTerminal:()=>o2,listSessionRoots:()=>gu,matchWorkspacePath:()=>Nle,registerManagedSession:()=>s2,setConnectCheckHandler:()=>c2,setupTerminalHandlers:()=>l2,setupTerminalSocket:()=>tf});async function L3e(t,e){if(!Cne(e))return;let r=(await Cd().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",Fc()))}function U3e(t,e){let n=(NR.get(t)||"")+e,r=null;Rle.lastIndex=0;for(let o;o=Rle.exec(n);)r=o[1];if(r){let o=une(r);o&&is(t,o)}let i=n.lastIndexOf("\x1B]"),s=i===-1?"":n.slice(i);s&&s.length<=N3e&&!s.slice(3).includes("\x07")&&!s.includes("\x1B\\")?NR.set(t,s):NR.delete(t)}function kle(){let t=(Ile||Promise.resolve()).catch(()=>{}).then(()=>F3e());return Ile=t.catch(()=>{}),t}async function F3e(){let t=await Cd(),e=new Map(t.map(r=>[r.id,r])),n=zA();for(let r of t)if(!n[r.id])try{await Rd(r.id)}catch{}Hr.clear();for(let[r,i]of Object.entries(n)){let s=e.get(r);Hr.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??JE[r]??null,lastCols:i.cols??null,lastRows:i.rows??null,needsRespawn:!s,agent:i.agent||null}),i.agent&&is(r,i.agent),hF(r,i)}ni(Hr)}function B3e(t){!Zd||!t||QE.has(t)||QE.set(t,setTimeout(()=>{QE.delete(t),DC(Zd,Hr,t).catch(()=>{})},IQ))}function r2(){let{assignments:t,created:e}=Xne({sessions:Hr,workspaces:[...ef.values()],sessionWorkspaces:Rh});if(Object.keys(t).length){for(let n of e)ef.set(n.id,n);for(let[n,r]of Object.entries(t)){Rh[n]=r;let i=Hr.get(n);i&&!i.workspacePath&&(i.workspacePath=ef.get(r)?.path||null)}fy(ef,Rh,DR),ni(Hr),console.log(Mle(`\u{1F4C1} Grouped ${Object.keys(t).length} loose terminal(s)`+(e.length?` into ${e.length} new workspace(s)`:"")))}}function gu(){return[...Hr.entries()].map(([t,e])=>({id:t,name:e.name,workspacePath:e.workspacePath||null,cwd:e.cwd||null}))}function Nle(t,e){let n=e?(0,Ch.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,Ch.resolve)(o.path);n===a?r=o:n.startsWith(a+"/")&&(!i||a.length>(0,Ch.resolve)(i.path).length)?i=o:a.startsWith(n+"/")&&(!s||a.length<(0,Ch.resolve)(s.path).length)&&(s=o)}return r||i||s||null}function s2({sessionId:t,name:e,autoNamed:n=!0,cwd:r=null,workspacePath:i=null,shellId:s=null,shellLabel:o=null,agent:a=null}){let c=Nle([...ef.values()],i||r)||null;return Hr.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&&(Rh[t]=c.id,fy(ef,Rh,DR)),ni(Hr),et(null,"sessionsChanged"),{success:!0,sessionId:t,workspacePath:c?.path||null}}async function o2(){let t=$ne();if(!t){let r=zA(),i=qne();t=Yne(i,r);let s=new Map(t.workspaces.map(c=>[c.id,c]));if(fy(s,t.sessionWorkspaces,t.sessionOrder),JE=t.sessionPaths||{},Object.keys(JE).length){for(let[c,l]of Object.entries(JE))r[c]&&(r[c].workspacePath=l);Bne(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(Mle(`\u{1F4C1} Migrated ${t.workspaces.length} workspace(s) from terminal groups`+(a?`, dropped ${a} empty group(s)`:"")))}for(let r of t.workspaces)ef.set(r.id,r);Object.assign(Rh,t.sessionWorkspaces),DR.push(...t.sessionOrder),wne(()=>ni(Hr)),Ine(B3e);try{Ale()}catch{}try{ble()}catch{}Tle().catch(()=>{});try{lle()}catch{}if(i2==="daemon")if(!await YL())console.error("\u274C Failed to connect to PTY daemon, falling back to buffer mode");else{await kle(),r2(),Lp("connected",()=>{kle().then(r2).catch(()=>{})});return}console.log("\u{1F4E6} Buffer persistence mode - scrollback enabled");let e=Fne(),n=zA();for(let r of e){let i=n[r]||{};Hr.set(r,{pty:null,name:i.name||`Terminal ${Hr.size+1}`,autoNamed:i.autoNamed!==!1,createdAt:i.createdAt||Date.now(),cwd:i.cwd,workspacePath:i.workspacePath??JE[r]??null,shellId:i.shellId,buffer:[],needsRestore:!0}),hF(r,i),console.log(`\u{1F504} Found saved session: ${r}`)}e.length>0&&console.log(`\u2705 Found ${e.length} saved session(s)`),r2()}function tf(t,e){Zd=t,i2==="daemon"&&(Lp("output",({sessionId:i,enc:s,data:o,replay:a})=>{a!==!0&&(GA(i),qA(i));let c=s==="b64"?Buffer.from(o,"base64"):Buffer.from(o||"");c.length>Ia&&(MR++,(MR===1||MR%500===0)&&Ole.info(`[slice] chunk ${c.length>>10}KB \u2192 ${Math.ceil(c.length/Ia)} events (total sliced: ${MR})`)),s==="b64"&&U3e(i,c.toString("utf8"));for(let l=0;l<c.length||l===0;l+=Ia){let u=c.subarray(l,l+Ia),d=a===!0?IE(i):wse(i);a!==!0&&Sse(i,d,u),et(t,"output",{sessionId:i,enc:"bin",data:u,replay:a===!0,seq:d})}}),Nne(i=>et(t,"statusState",Fc())),One(()=>et(t,"statusState",Fc())),Lp("cwdChange",({sessionId:i,cwd:s})=>{let o=Hr.get(i);o&&s&&o.cwd!==s&&(o.cwd=s,ni(Hr)),et(t,"cwdChange",{sessionId:i,cwd:s})}),Lp("processChange",({sessionId:i,process:s})=>{let o=Tne(i,s);if(o?.state==="pendingShell"){setTimeout(()=>L3e(t,i),D3e);return}o?.state==="idle"&&(et(t,"statusChange",{sessionId:i,state:"idle",tool:null,conversationId:null}),et(t,"statusState",Fc()))}),Lp("sessionClosed",i=>{Hr.delete(i),Ay(i),ly(i),NR.delete(i);let s=QE.get(i);s&&(clearTimeout(s),QE.delete(i)),yF(i),et(t,"sessionClosed",i),et(t,"notificationCleared",i)}));let n=()=>({version:M3e,remoteAvailable:Pp(),mobileAvailable:Vte(),daemonMode:i2==="daemon"&&kn(),platform:process.platform,updateAvailable:dL(),canSelfUpdate:!0,caps:{joinSessionSize:!0,artifact:!0},artifactEnabled:XE(),voiceConfig:Aa().voiceConfig||null,mcpClients:Vy,...Yte()}),r=()=>{let i=n();for(let s of t.sockets.sockets.values())s.data?.approved&&s.emit("serverInfo",i)};mL(r),tf._buildServerInfo=n,tf._emitServerInfo=r}function a2(){tf._emitServerInfo?.()}function ZE(t,e,n,r=null){if(!Zd)return null;if(e==="done")return $A(t,()=>{let a=r?.sessionId||r?.threadId||rs(t)?.id||null,c=Gd(t),l=eh({type:e,sessionId:t,tool:n});!l||l===c||(et(Zd,"statusChange",{sessionId:t,state:e,tool:n,conversationId:a}),et(Zd,"statusState",Fc()))}),Gd(t);let i=r?.sessionId||r?.threadId||rs(t)?.id||null,s=Gd(t),o=eh({type:e,sessionId:t,tool:n});return!o||o===s||(et(Zd,"statusChange",{sessionId:t,state:e,tool:n,conversationId:i}),et(Zd,"statusState",Fc())),o}function c2(t){Dle=t}async function l2(t,e,n){Ole.info(`[diag] setupTerminalHandlers START id=${t.id} virtual=${!!t.defersWsAdapter}`),Xte(),Dle?.(),t.emit("srvCaps",{env2:1}),t.emit("serverInfo",tf._buildServerInfo?.()),Rse(t,e,Hr,ef,Rh,DR),Dse(t,Hr),ule(t,e),pA()&&await VZ(t,n).catch(r=>{console.error("\u274C Failed to setup remote handlers:",r.message)}),zte(t),t.on("disconnect",()=>{ece(t.id),Jte()})}var Ch,Ple,Ole,TCt,Mle,i2,M3e,Rle,N3e,D3e,NR,Hr,ef,Rh,DR,JE,Ile,QE,Zd,MR,Dle,$a=ae(()=>{K1();Ch=require("path"),Ple=require("url");mi();hA();Kte();So();RA();KA();Jne();UC();Lse();dle();Cle();RR();Og();hR();n2();Ds();Lc();Zi();IB();tu();tt();Ole=xe("terminal"),TCt=(0,Ch.dirname)((0,Ple.fileURLToPath)(__importMetaUrl)),Mle=Ov.rgb(230,138,110),i2="daemon",M3e="3.0.10",Rle=/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/g,N3e=256,D3e=1500,NR=new Map;Hr=new Map,ef=new Map,Rh={},DR=[],JE={},Ile=null;QE=new Map,Zd=null;MR=0;Dle=null});var ew=B((ACt,qle)=>{"use strict";var q3e=require("path"),Kc="\\\\/",Lle=`[^${Kc}]`,$3e=0,yu="\\.",G3e="\\+",H3e="\\?",LR="\\/",j3e="(?=.)",Ule="[^/]",u2=`(?:${LR}|$)`,Fle=`(?:^|${LR})`,d2=`${yu}{1,2}${u2}`,W3e=`(?!${yu})`,V3e=`(?!${Fle}${d2})`,z3e=`(?!${yu}{0,1}${u2})`,K3e=`(?!${d2})`,Y3e=`[^.${LR}]`,X3e=`${Ule}*?`,Ble={DOT_LITERAL:yu,PLUS_LITERAL:G3e,QMARK_LITERAL:H3e,SLASH_LITERAL:LR,ONE_CHAR:j3e,QMARK:Ule,END_ANCHOR:u2,DOTS_SLASH:d2,NO_DOT:W3e,NO_DOTS:V3e,NO_DOT_SLASH:z3e,NO_DOTS_SLASH:K3e,QMARK_NO_DOT:Y3e,STAR:X3e,START_ANCHOR:Fle},J3e={...Ble,SLASH_LITERAL:`[${Kc}]`,QMARK:Lle,STAR:`${Lle}*?`,DOTS_SLASH:`${yu}{1,2}(?:[${Kc}]|$)`,NO_DOT:`(?!${yu})`,NO_DOTS:`(?!(?:^|[${Kc}])${yu}{1,2}(?:[${Kc}]|$))`,NO_DOT_SLASH:`(?!${yu}{0,1}(?:[${Kc}]|$))`,NO_DOTS_SLASH:`(?!${yu}{1,2}(?:[${Kc}]|$))`,QMARK_NO_DOT:`[^.${Kc}]`,START_ANCHOR:`(?:^|[${Kc}])`,END_ANCHOR:`(?:[${Kc}]|$)`},Q3e={__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"};qle.exports={DEFAULT_MAX_EXTGLOB_RECURSION:$3e,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Q3e,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:q3e.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?J3e:Ble}}});var UR=B(ds=>{"use strict";var Z3e=require("path"),eWe=process.platform==="win32",{REGEX_BACKSLASH:tWe,REGEX_REMOVE_BACKSLASH:nWe,REGEX_SPECIAL_CHARS:rWe,REGEX_SPECIAL_CHARS_GLOBAL:iWe}=ew();ds.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);ds.hasRegexChars=t=>rWe.test(t);ds.isRegexChar=t=>t.length===1&&ds.hasRegexChars(t);ds.escapeRegex=t=>t.replace(iWe,"\\$1");ds.toPosixSlashes=t=>t.replace(tWe,"/");ds.removeBackslashes=t=>t.replace(nWe,e=>e==="\\"?"":e);ds.supportsLookbehinds=()=>{let t=process.version.slice(1).split(".").map(Number);return t.length===3&&t[0]>=9||t[0]===8&&t[1]>=10};ds.isWindows=t=>t&&typeof t.windows=="boolean"?t.windows:eWe===!0||Z3e.sep==="\\";ds.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?ds.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};ds.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};ds.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",i=n.contains?"":"$",s=`${r}(?:${t})${i}`;return e.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var Kle=B((RCt,zle)=>{"use strict";var $le=UR(),{CHAR_ASTERISK:f2,CHAR_AT:sWe,CHAR_BACKWARD_SLASH:tw,CHAR_COMMA:oWe,CHAR_DOT:p2,CHAR_EXCLAMATION_MARK:h2,CHAR_FORWARD_SLASH:Vle,CHAR_LEFT_CURLY_BRACE:m2,CHAR_LEFT_PARENTHESES:g2,CHAR_LEFT_SQUARE_BRACKET:aWe,CHAR_PLUS:cWe,CHAR_QUESTION_MARK:Gle,CHAR_RIGHT_CURLY_BRACE:lWe,CHAR_RIGHT_PARENTHESES:Hle,CHAR_RIGHT_SQUARE_BRACKET:uWe}=ew(),jle=t=>t===Vle||t===tw,Wle=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},dWe=(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,d=0,f=!1,m=!1,g=!1,y=!1,w=!1,S=!1,T=!1,R=!1,C=!1,D=!1,$=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===tw){T=L.backslashes=!0,V=A(),V===m2&&(S=!0);continue}if(S===!0||V===m2){for($++;k()!==!0&&(V=A());){if(V===tw){T=L.backslashes=!0,A();continue}if(V===m2){$++;continue}if(S!==!0&&V===p2&&(V=A())===p2){if(f=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(S!==!0&&V===oWe){if(f=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===lWe&&($--,$===0)){S=!1,f=L.isBrace=!0,D=!0;break}}if(i===!0)continue;break}if(V===Vle){if(s.push(l),o.push(L),L={value:"",depth:0,isGlob:!1},D===!0)continue;if(G===p2&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(V===cWe||V===sWe||V===f2||V===Gle||V===h2)===!0&&E()===g2){if(g=L.isGlob=!0,y=L.isExtglob=!0,D=!0,V===h2&&l===u&&(C=!0),i===!0){for(;k()!==!0&&(V=A());){if(V===tw){T=L.backslashes=!0,V=A();continue}if(V===Hle){g=L.isGlob=!0,D=!0;break}}continue}break}if(V===f2){if(G===f2&&(w=L.isGlobstar=!0),g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===Gle){if(g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===aWe){for(;k()!==!0&&(X=A());){if(X===tw){T=L.backslashes=!0,A();continue}if(X===uWe){m=L.isBracket=!0,g=L.isGlob=!0,D=!0;break}}if(i===!0)continue;break}if(n.nonegate!==!0&&V===h2&&l===u){R=L.negated=!0,u++;continue}if(n.noparen!==!0&&V===g2){if(g=L.isGlob=!0,i===!0){for(;k()!==!0&&(V=A());){if(V===g2){T=L.backslashes=!0,V=A();continue}if(V===Hle){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),d-=u),M&&g===!0&&d>0?(M=c.slice(0,d),P=c.slice(d)):g===!0?(M="",P=c):M=c,M&&M!==""&&M!=="/"&&M!==c&&jle(M.charCodeAt(M.length-1))&&(M=M.slice(0,-1)),n.unescape===!0&&(P&&(P=$le.removeBackslashes(P)),M&&T===!0&&(M=$le.removeBackslashes(M)));let F={prefix:I,input:t,start:u,base:M,glob:P,isBrace:f,isBracket:m,isGlob:g,isExtglob:y,isGlobstar:w,negated:R,negatedExtglob:C};if(n.tokens===!0&&(F.maxDepth=0,jle(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,q=s[N],pe=t.slice(b,q);n.tokens&&(N===0&&u!==0?(o[N].isPrefix=!0,o[N].value=I):o[N].value=pe,Wle(o[N]),F.maxDepth+=o[N].depth),(N!==0||pe!=="")&&a.push(pe),X=q}if(X&&X+1<t.length){let N=t.slice(X+1);a.push(N),n.tokens&&(o[o.length-1].value=N,Wle(o[o.length-1]),F.maxDepth+=o[o.length-1].depth)}F.slashes=s,F.parts=a}return F};zle.exports=dWe});var Zle=B((ICt,Qle)=>{"use strict";var nw=ew(),Ei=UR(),{MAX_LENGTH:FR,POSIX_REGEX_SOURCE:fWe,REGEX_NON_SPECIAL_CHARS:pWe,REGEX_SPECIAL_CHARS_BACKREF:hWe,REPLACEMENTS:Yle}=nw,mWe=(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=>Ei.escapeRegex(i)).join("..")}return n},zy=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,Xle=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},gWe=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},Jle=t=>{let e=t.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=!0);if(gWe(e))return e.replace(/\\(.)/g,"$1")},yWe=t=>{let e=t.map(Jle).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},y2=(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}}}}},_We=t=>{let e=0,n=[];for(;e<t.length;){let i=y2(t.slice(e),!1);if(!i||i.type!=="*")return;let s=Xle(i.body).map(a=>a.trim());if(s.length!==1)return;let o=Jle(s[0]);if(!o||o.length!==1)return;n.push(o),e+=i.end+1}return n.length<1?void 0:`${n.length===1?Ei.escapeRegex(n[0]):`[${n.map(i=>Ei.escapeRegex(i)).join("")}]`}*`},vWe=t=>{let e=0,n=t.trim(),r=y2(n);for(;r;)e++,n=r.body.trim(),r=y2(n);return e},EWe=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:nw.DEFAULT_MAX_EXTGLOB_RECURSION,r=Xle(t).map(i=>i.trim());if(r.length>1&&(r.some(i=>i==="")||r.some(i=>/^[*?]+$/.test(i))||yWe(r)))return{risky:!0};for(let i of r){let s=_We(i);if(s)return{risky:!0,safeOutput:s};if(vWe(i)>n)return{risky:!0}}return{risky:!1}},_2=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=Yle[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(FR,n.maxLength):FR,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=Ei.isWindows(e),l=nw.globChars(c),u=nw.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,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:$}=l,G=U=>`(${a}(?:(?!${$}${U.dot?y:d}).)*?)`,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=Ei.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]||"",q=()=>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},lt=(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=EWe(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||Ei.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(q()))&&(Z=U.close=`)$))${ie}`),U.inner.includes("*")&&(ee=q())&&/^\.[^\\/.]+$/.test(ee)){let ne=_2(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(hWe,(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==="."?d.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=Ei.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(q()),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=fWe[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=Ei.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(zy("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||!q().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(zy("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(zy("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||Ei.hasRegexChars(j))continue;let Q=Ei.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=mWe(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=d);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:d});continue}Se({type:"dot",value:F,output:d});continue}if(F==="?"){if(!(P&&P.value==="(")&&n.noextglob!==!0&&N()==="("&&N(2)!=="?"){lt("qmark",F);continue}if(P&&P.type==="paren"){let Q=N(),Z=F;if(Q==="<"&&!Ei.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(P.value==="("&&!/[!=<:]/.test(Q)||Q==="<"&&!/<([!=]|\w+>)/.test(q()))&&(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)))){lt("negate",F);continue}if(n.nonegate!==!0&&E.index===0){J();continue}}if(F==="+"){if(n.noextglob!==!0&&N()==="("&&N(2)!=="?"){lt("plus",F);continue}if(P&&P.value==="("||n.regex===!1){Se({type:"plus",value:F,output:f});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:f});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=pWe.exec(q());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=q();if(n.noextglob!==!0&&/^\([^?]/.test(U)){lt("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(zy("closing","]"));E.output=Ei.escapeLast(E.output,"["),we("brackets")}for(;E.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(zy("closing",")"));E.output=Ei.escapeLast(E.output,"("),we("parens")}for(;E.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(zy("closing","}"));E.output=Ei.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};_2.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(FR,n.maxLength):FR,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);t=Yle[t]||t;let s=Ei.isWindows(e),{DOT_LITERAL:o,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:m,START_ANCHOR:g}=nw.globChars(s),y=n.dot?d:u,w=n.dot?f: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}}},$=Ei.removePrefix(t,T),G=D($);return G&&n.strictSlashes!==!0&&(G+=`${a}?`),G};Qle.exports=_2});var tue=B((kCt,eue)=>{"use strict";var wWe=require("path"),SWe=Kle(),v2=Zle(),E2=UR(),xWe=ew(),bWe=t=>t&&typeof t=="object"&&!Array.isArray(t),hr=(t,e,n=!1)=>{if(Array.isArray(t)){let u=t.map(f=>hr(f,e,n));return f=>{for(let m of u){let g=m(f);if(g)return g}return!1}}let r=bWe(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?hr.compileRe(t,e):hr.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=hr(i.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:m,output:g}=hr.test(u,o,e,{glob:t,posix:s}),y={glob:t,state:a,regex:o,posix:s,input:u,output:g,match:m,isMatch:f};return typeof i.onResult=="function"&&i.onResult(y),f===!1?(y.isMatch=!1,d?y:!1):c(u)?(typeof i.onIgnore=="function"&&i.onIgnore(y),y.isMatch=!1,d?y:!1):(typeof i.onMatch=="function"&&i.onMatch(y),d?y:!0)};return n&&(l.state=a),l};hr.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=hr.matchBase(t,e,n,i):a=e.exec(c)),{isMatch:!!a,match:a,output:c}};hr.matchBase=(t,e,n,r=E2.isWindows(n))=>(e instanceof RegExp?e:hr.makeRe(e,n)).test(wWe.basename(t));hr.isMatch=(t,e,n)=>hr(e,n)(t);hr.parse=(t,e)=>Array.isArray(t)?t.map(n=>hr.parse(n,e)):v2(t,{...e,fastpaths:!1});hr.scan=(t,e)=>SWe(t,e);hr.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=hr.toRegex(a,e);return r===!0&&(c.state=t),c};hr.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=v2.fastpaths(t,e)),i.output||(i=v2(t,e)),hr.compileRe(i,e,n,r)};hr.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/$^/}};hr.constants=xWe;eue.exports=hr});var w2=B((PCt,nue)=>{"use strict";nue.exports=tue()});var uue=B((OCt,lue)=>{"use strict";var iw=require("fs"),{Readable:TWe}=require("stream"),rw=require("path"),{promisify:GR}=require("util"),S2=w2(),AWe=GR(iw.readdir),CWe=GR(iw.stat),rue=GR(iw.lstat),RWe=GR(iw.realpath),IWe="!",aue="READDIRP_RECURSIVE_ERROR",kWe=new Set(["ENOENT","EPERM","EACCES","ELOOP",aue]),x2="files",cue="directories",qR="files_directories",BR="all",iue=[x2,cue,qR,BR],PWe=t=>kWe.has(t.code),[sue,OWe]=process.versions.node.split(".").slice(0,2).map(t=>Number.parseInt(t,10)),MWe=process.platform==="win32"&&(sue>10||sue===10&&OWe>=5),oue=t=>{if(t!==void 0){if(typeof t=="function")return t;if(typeof t=="string"){let e=S2(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)===IWe?n.push(S2(i.slice(1))):e.push(S2(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))}}},$R=class t extends TWe{static get defaultOptions(){return{root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:x2,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=oue(n.fileFilter),this._directoryFilter=oue(n.directoryFilter);let s=n.lstat?rue:CWe;MWe?this._stat=o=>s(o,{bigint:!0}):this._stat=s,this._maxDepth=n.depth,this._wantsDir=[cue,qR,BR].includes(i),this._wantsFile=[x2,qR,BR].includes(i),this._wantsEverything=i===BR,this._root=rw.resolve(r),this._isDirent="Dirent"in iw&&!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 AWe(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=rw.resolve(rw.join(n,i));r={path:rw.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){PWe(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 RWe(r),s=await rue(i);if(s.isFile())return"file";if(s.isDirectory()){let o=i.length;if(r.startsWith(i)&&r.substr(o,1)===rw.sep){let a=new Error(`Circular symlink detected: "${r}" points to "${i}"`);return a.code=aue,this._onError(a)}return"directory"}}catch(i){this._onError(i)}}}}_includeAsFile(e){let n=e&&e[this._statsProp];return n&&this._wantsEverything&&!n.isDirectory()}},Ky=(t,e={})=>{let n=e.entryType||e.type;if(n==="both"&&(n=qR),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&&!iue.includes(n))throw new Error(`readdirp: Invalid type passed. Use one of ${iue.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new $R(e)},NWe=(t,e={})=>new Promise((n,r)=>{let i=[];Ky(t,e).on("data",s=>i.push(s)).on("end",()=>n(i)).on("error",s=>r(s))});Ky.promise=NWe;Ky.ReaddirpStream=$R;Ky.default=Ky;lue.exports=Ky});var Yy=B((MCt,due)=>{due.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 yue=B((mue,gue)=>{"use strict";Object.defineProperty(mue,"__esModule",{value:!0});var hue=w2(),DWe=Yy(),fue="!",LWe={returnIndex:!1},UWe=t=>Array.isArray(t)?t:[t],FWe=(t,e)=>{if(typeof t=="function")return t;if(typeof t=="string"){let n=hue(t,e);return r=>t===r||n(r)}return t instanceof RegExp?n=>t.test(n):n=>!1},pue=(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=DWe(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},b2=(t,e,n=LWe)=>{if(t==null)throw new TypeError("anymatch: specify first argument");let r=typeof n=="boolean"?{returnIndex:n}:n,i=r.returnIndex||!1,s=UWe(t),o=s.filter(c=>typeof c=="string"&&c.charAt(0)===fue).map(c=>c.slice(1)).map(c=>hue(c,r)),a=s.filter(c=>typeof c!="string"||typeof c=="string"&&c.charAt(0)!==fue).map(c=>FWe(c,r));return e==null?(c,l=!1)=>pue(a,o,c,typeof l=="boolean"?l:!1):pue(a,o,e,i)};b2.default=b2;gue.exports=b2});var vue=B((NCt,_ue)=>{_ue.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 T2=B((DCt,wue)=>{var BWe=vue(),Eue={"{":"}","(":")","[":"]"},qWe=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=Eue[a];if(c){var l=t.indexOf(c,e);l!==-1&&(e=l+1)}if(t[e]==="!")return!0}else e++}return!1},$We=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=Eue[n];if(r){var i=t.indexOf(r,e);i!==-1&&(e=i+1)}if(t[e]==="!")return!0}else e++}return!1};wue.exports=function(e,n){if(typeof e!="string"||e==="")return!1;if(BWe(e))return!0;var r=qWe;return n&&n.strict===!1&&(r=$We),r(e)}});var xue=B((LCt,Sue)=>{"use strict";var GWe=T2(),HWe=require("path").posix.dirname,jWe=require("os").platform()==="win32",A2="/",WWe=/\\/g,VWe=/[\{\[].*[\}\]]$/,zWe=/(^|[^\\])([\{\[]|\([^\)]+$)/,KWe=/\\([\!\*\?\|\[\]\(\)\{\}])/g;Sue.exports=function(e,n){var r=Object.assign({flipBackslashes:!0},n);r.flipBackslashes&&jWe&&e.indexOf(A2)<0&&(e=e.replace(WWe,A2)),VWe.test(e)&&(e+=A2),e+="a";do e=HWe(e);while(GWe(e)||zWe.test(e));return e.replace(KWe,"$1")}});var HR=B(qo=>{"use strict";qo.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1;qo.find=(t,e)=>t.nodes.find(n=>n.type===e);qo.exceedsLimit=(t,e,n=1,r)=>r===!1||!qo.isInteger(t)||!qo.isInteger(e)?!1:(Number(e)-Number(t))/Number(n)>=r;qo.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)};qo.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1;qo.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;qo.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0;qo.reduce=t=>t.reduce((e,n)=>(n.type==="text"&&e.push(n.value),n.type==="range"&&(n.type="text"),e),[]);qo.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 jR=B((FCt,Tue)=>{"use strict";var bue=HR();Tue.exports=(t,e={})=>{let n=(r,i={})=>{let s=e.escapeInvalid&&bue.isInvalidBrace(i),o=r.invalid===!0&&e.escapeInvalid===!0,a="";if(r.value)return(s||o)&&bue.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 Cue=B((BCt,Aue)=>{"use strict";Aue.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var Lue=B((qCt,Due)=>{"use strict";var Rue=Cue(),Ih=(t,e,n)=>{if(Rue(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(Rue(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(Ih.cache.hasOwnProperty(c))return Ih.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 d=Nue(t)||Nue(e),f={min:t,max:e,a:l,b:u},m=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let y=u<0?Math.abs(u):1;g=Iue(y,Math.abs(l),f,r),l=f.a=0}return u>=0&&(m=Iue(l,u,f,r)),f.negatives=g,f.positives=m,f.result=YWe(g,m,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&m.length+g.length>1&&(f.result=`(?:${f.result})`),Ih.cache[c]=f,f.result};function YWe(t,e,n){let r=C2(t,e,"-",!1,n)||[],i=C2(e,t,"",!1,n)||[],s=C2(t,e,"-?",!0,n)||[];return r.concat(s).concat(i).join("|")}function XWe(t,e){let n=1,r=1,i=Pue(t,n),s=new Set([e]);for(;t<=i&&i<=e;)s.add(i),n+=1,i=Pue(t,n);for(i=Oue(e+1,r)-1;t<i&&i<=e;)s.add(i),r+=1,i=Oue(e+1,r)-1;return s=[...s],s.sort(ZWe),s}function JWe(t,e,n){if(t===e)return{pattern:t,count:[],digits:0};let r=QWe(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+=e6e(c,l,n):o++}return o&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[o],digits:i}}function Iue(t,e,n,r){let i=XWe(t,e),s=[],o=t,a;for(let c=0;c<i.length;c++){let l=i[c],u=JWe(String(o),String(l),r),d="";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+Mue(a.count),o=l+1;continue}n.isPadded&&(d=t6e(l,n,r)),u.string=d+u.pattern+Mue(u.count),s.push(u),o=l+1,a=u}return s}function C2(t,e,n,r,i){let s=[];for(let o of t){let{string:a}=o;!r&&!kue(e,"string",a)&&s.push(n+a),r&&kue(e,"string",a)&&s.push(n+a)}return s}function QWe(t,e){let n=[];for(let r=0;r<t.length;r++)n.push([t[r],e[r]]);return n}function ZWe(t,e){return t>e?1:e>t?-1:0}function kue(t,e,n){return t.some(r=>r[e]===n)}function Pue(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function Oue(t,e){return t-t%Math.pow(10,e)}function Mue(t){let[e=0,n=""]=t;return n||e>1?`{${e+(n?","+n:"")}}`:""}function e6e(t,e,n){return`[${t}${e-t===1?"":"-"}${e}]`}function Nue(t){return/^-?(0+)\d/.test(t)}function t6e(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}}`}}Ih.cache={};Ih.clearCache=()=>Ih.cache={};Due.exports=Ih});var k2=B(($Ct,Hue)=>{"use strict";var n6e=require("util"),Fue=Lue(),Uue=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),r6e=t=>e=>t===!0?Number(e):String(e),R2=t=>typeof t=="number"||typeof t=="string"&&t!=="",sw=t=>Number.isInteger(+t),I2=t=>{let e=`${t}`,n=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++n]==="0";);return n>0},i6e=(t,e,n)=>typeof t=="string"||typeof e=="string"?!0:n.stringify===!0,s6e=(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},VR=(t,e)=>{let n=t[0]==="-"?"-":"";for(n&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return n?"-"+t:t},o6e=(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=>VR(String(a),n)).join("|")),t.negatives.length&&(s=`-(${r}${t.negatives.map(a=>VR(String(a),n)).join("|")})`),i&&s?o=`${i}|${s}`:o=i||s,e.wrap?`(${r}${o})`:o},Bue=(t,e,n,r)=>{if(n)return Fue(t,e,{wrap:!1,...r});let i=String.fromCharCode(t);if(t===e)return i;let s=String.fromCharCode(e);return`[${i}-${s}]`},que=(t,e,n)=>{if(Array.isArray(t)){let r=n.wrap===!0,i=n.capture?"":"?:";return r?`(${i}${t.join("|")})`:t.join("|")}return Fue(t,e,n)},$ue=(...t)=>new RangeError("Invalid range arguments: "+n6e.inspect(...t)),Gue=(t,e,n)=>{if(n.strictRanges===!0)throw $ue([t,e]);return[]},a6e=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},c6e=(t,e,n=1,r={})=>{let i=Number(t),s=Number(e);if(!Number.isInteger(i)||!Number.isInteger(s)){if(r.strictRanges===!0)throw $ue([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=I2(a)||I2(c)||I2(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&i6e(t,e,r)===!1,m=r.transform||r6e(f);if(r.toRegex&&n===1)return Bue(VR(t,d),VR(e,d),!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(s6e(m(i,S),d,f)),i=o?i-n:i+n,S++;return r.toRegex===!0?n>1?o6e(g,r,d):que(w,null,{wrap:!1,...r}):w},l6e=(t,e,n=1,r={})=>{if(!sw(t)&&t.length>1||!sw(e)&&e.length>1)return Gue(t,e,r);let i=r.transform||(f=>String.fromCharCode(f)),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 Bue(c,l,!1,r);let u=[],d=0;for(;a?s>=o:s<=o;)u.push(i(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?que(u,null,{wrap:!1,options:r}):u},WR=(t,e,n,r={})=>{if(e==null&&R2(t))return[t];if(!R2(t)||!R2(e))return Gue(t,e,r);if(typeof n=="function")return WR(t,e,1,{transform:n});if(Uue(n))return WR(t,e,0,n);let i={...r};return i.capture===!0&&(i.wrap=!0),n=n||i.step||1,sw(n)?sw(t)&&sw(e)?c6e(t,e,n,i):l6e(t,e,Math.max(Math.abs(n),1),i):n!=null&&!Uue(n)?a6e(n,i):WR(t,e,1,n)};Hue.exports=WR});var Vue=B((GCt,Wue)=>{"use strict";var u6e=k2(),jue=HR(),d6e=(t,e={})=>{let n=(r,i={})=>{let s=jue.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=jue.reduce(r.nodes),d=u6e(...u,{...e,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(t)};Wue.exports=d6e});var Yue=B((HCt,Kue)=>{"use strict";var f6e=k2(),zue=jR(),Xy=HR(),kh=(t="",e="",n=!1)=>{let r=[];if(t=[].concat(t),e=[].concat(e),!e.length)return t;if(!t.length)return n?Xy.flatten(e).map(i=>`{${i}}`):e;for(let i of t)if(Array.isArray(i))for(let s of i)r.push(kh(s,e,n));else for(let s of e)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?kh(i,s,n):i+s);return Xy.flatten(r)},p6e=(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(kh(a.pop(),zue(i,e)));return}if(i.type==="brace"&&i.invalid!==!0&&i.nodes.length===2){a.push(kh(a.pop(),["{}"]));return}if(i.nodes&&i.ranges>0){let d=Xy.reduce(i.nodes);if(Xy.exceedsLimit(...d,e.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=f6e(...d,e);f.length===0&&(f=zue(i,e)),a.push(kh(a.pop(),f)),i.nodes=[];return}let c=Xy.encloseBrace(i),l=i.queue,u=i;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<i.nodes.length;d++){let f=i.nodes[d];if(f.type==="comma"&&i.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(kh(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(kh(l.pop(),f.value));continue}f.nodes&&r(f,i)}return l};return Xy.flatten(r(t))};Kue.exports=p6e});var Jue=B((jCt,Xue)=>{"use strict";Xue.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:`
|
|
412
|
+
`}function P3e(t){let e=I3e[t];if(!e)return{success:!1,error:"Unknown tool"};try{return t==="codex"||t==="opencode"||t==="amp"||t==="pi"||t==="omp"?e.enable():e.enable(fn[t]())}catch(n){return{success:!1,error:n.message}}}function O3e(t){let e=(process.env.PATH||"").split(pr.default.delimiter).filter(Boolean),n=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT").split(";"):[""];return e.some(r=>n.some(i=>{try{return He.default.existsSync(pr.default.join(r,t+i))}catch{return!1}}))}function xle(t){let e=_le[t];if(e&&O3e(e))return!0;let n=s3e[t]?.();return n?(Array.isArray(n)?n:[n]).some(r=>He.default.existsSync(r)):!1}function ble(){let t={};for(let e of k3e)if(xle(e))try{let n=P3e(e);t[e]=n.success&&!n.untrusted?.length}catch{t[e]=!1}return t}async function Tle(){if(!xle("codex"))return null;try{let{missing:t}=await g3e();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 Ale(){let t=fn.claude(),e=Ir(t);if(!e.hooks?.Stop&&!e.hooks?.Notification)return;let n=e.env||{};Object.keys(Nv).some(i=>n[i]!==Nv[i])&&(vle(e),us(t,e))}var mle,He,pr,gle,PR,yle,i3e,vi,Qd,fn,_le,Ah,s3e,t2,OR,kR,o3e,IR,Ele,zAt,wle,f3e,h3e,_3e,ple,E3e,x3e,T3e,A3e,C3e,R3e,I3e,k3e,Cle=ae(()=>{mle=ce(require("os"),1),He=ce(require("fs"),1),pr=ce(require("path"),1),gle=require("child_process");Lt();Eo();Lc();PR=`http://localhost:${Ss}/api/notify`,yle="nineRemoteNotify",i3e=pr.default.join(Oe.STATE,"claudeEnvBackup.json"),vi=(...t)=>pr.default.join(mle.default.homedir(),...t),Qd=(t,...e)=>{let n=process.env[t];return n&&n.trim()?n.trim():vi(...e)},fn={claude:()=>vi(".claude","settings.json"),codex:()=>vi(".codex","config.toml"),codexHooks:()=>vi(".codex","hooks.json"),codexScript:()=>vi(".codex","9remote-notify.sh"),opencode:()=>vi(".config","opencode","plugin",`${yle}.js`),grok:()=>pr.default.join(Qd("GROK_HOME",".grok"),"hooks","9remote.json"),cursor:()=>vi(".cursor","hooks.json"),antigravity:()=>vi(".gemini","config","hooks.json"),kiro:()=>pr.default.join(Qd("KIRO_HOME",".kiro"),"agents","9remote.json"),copilot:()=>pr.default.join(Qd("COPILOT_HOME",".copilot"),"config.json"),codebuddy:()=>pr.default.join(Qd("CODEBUDDY_CONFIG_DIR",".codebuddy"),"settings.json"),factory:()=>vi(".factory","settings.json"),qoder:()=>pr.default.join(Qd("QODER_CONFIG_DIR",".qoder"),"settings.json"),rovodev:()=>vi(".rovodev","config.yml"),hermes:()=>pr.default.join(Qd("HERMES_HOME",".hermes"),"config.yaml"),amp:()=>vi(".config","amp","plugins","9remote.ts"),devin:()=>vi(".config","devin","config.json"),pi:()=>pr.default.join(Qd("PI_CODING_AGENT_DIR",".pi","agent"),"extensions","9remote.ts"),omp:()=>pr.default.join(Qd("PI_CODING_AGENT_DIR",".omp","agent"),"extensions","9remote.ts")},_le={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",omp:"omp",devin:"devin"},Ah=(t,e,{sessionId:n=!1}={})=>{let r=n?oF(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 "${PR}?type=${t}&sessionId=$NINE_REMOTE_SESSION_ID${r?"&csid=$csid":""}&tool=${e}" > /dev/null 2>&1 & true`},s3e={claude:()=>vi(".claude"),codex:()=>vi(".codex"),opencode:()=>[vi(".config","opencode"),vi(".opencode")]},t2=t=>Math.ceil(t/1e3),OR=5e3,kR=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o3e=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`;IR={UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked"},Ele=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase(),zAt=Object.fromEntries(Object.keys(IR).map(t=>[Ele(t),t])),wle=/^\[hooks\.state\."(?<key>[^"]+)"\]$/m,f3e=15e3;h3e=t=>/^sha256:/.test(t)?t:`sha256:${t}`;_3e=/# 9Remote notification\nnotify\s*=.*\n?/g,ple=/^# 9Remote-saved: (notify\s*=.*)$/m;E3e={enable(){let t=fn.codexHooks(),e=Ir(t),n={...e.hooks||{}};for(let[r,i]of Object.entries(IR))n[r]=[...(n[r]||[]).filter(s=>!e2(s)),w3e(i)];return e.hooks=n,us(t,e),v3e(),{success:!0}},disable(){let t=fn.codexHooks(),e=new Set(Sle(t).filter(n=>n.command.includes("&tool=codex")).map(n=>n.key));if(He.default.existsSync(t)){let n=Ir(t);if(n.hooks){for(let r of Object.keys(IR))n.hooks[r]=(n.hooks[r]||[]).filter(i=>!e2(i)),n.hooks[r].length===0&&delete n.hooks[r];Object.keys(n.hooks).length===0&&delete n.hooks}us(t,n)}return y3e(fn.codex(),e),{success:!0}},isEnabled(){let t=Ir(fn.codexHooks()).hooks||{};return Object.keys(IR).every(e=>(t[e]||[]).some(e2))}};x3e={enable(){let t=fn.opencode(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,S3e(),"utf8"),{success:!0}},disable(){let t=fn.opencode();return He.default.existsSync(t)&&He.default.unlinkSync(t),{success:!0}},isEnabled(){let t=fn.opencode();return He.default.existsSync(t)&&He.default.readFileSync(t,"utf8").includes("&sessionID=")}};T3e="# 9remote hooks begin",A3e="# 9remote hooks end",C3e=" # 9remote hooks begin",R3e=" # 9remote hooks end",I3e={claude:Th("claude",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked",Notification:"blocked"},t=>t,{matchers:{Notification:"permission_prompt"},extra:vle,sessionId:!0}),devin:Th("devin",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",PermissionRequest:"blocked"},t=>t,{sessionId:!0}),codex:E3e,opencode:x3e,grok:Th("grok",{UserPromptSubmit:"working",PreToolUse:"working",PostToolUse:"working",Stop:"done",Notification:"blocked"},t2),cursor:l3e("cursor",{stop:"done",beforeShellExecution:"blocked",beforeToolCall:"working"},{extra:t=>{t.version=t.version||1}}),antigravity:u3e("antigravity","9remote",{UserPromptSubmit:"working",PreToolUse:"working",Stop:"done",Notification:"blocked"}),kiro:d3e("kiro",{UserPromptSubmit:"working",PostToolUse:"working",preToolUse:"blocked",stop:"done"}),copilot:Th("copilot",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),codebuddy:Th("codebuddy",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),factory:Th("factory",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),qoder:Th("qoder",{UserPromptSubmit:"working",PostToolUse:"working",PreToolUse:"blocked",Stop:"done"},t=>t),rovodev:fle("rovodev",{begin:C3e,end:R3e,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=fle("hermes",{begin:T3e,end:A3e,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=()=>pr.default.join(pr.default.dirname(fn.hermes()),"shell-hooks-allowlist.json");return{enable:()=>{let n=t.enable(fn.hermes()),r=Ir(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:Ah(o,"hermes"),approved_at:"2020-01-01T00:00:00Z"}))],us(e(),r),n},disable:()=>{let n=t.disable(fn.hermes()),r=e();if(He.default.existsSync(r)){let i=Ir(r);i.approvals=(i.approvals||[]).filter(s=>!(typeof s.command=="string"&&s.command.includes("&tool=hermes"))),i.approvals.length?us(r,i):He.default.unlinkSync(r)}return n},isEnabled:()=>t.isEnabled(fn.hermes())}})(),amp:{enable(){let t=fn.amp(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,hle("amp","amp","agent.start","agent.end"),"utf8"),{success:!0}},disable(){return He.default.existsSync(fn.amp())&&He.default.unlinkSync(fn.amp()),{success:!0}},isEnabled(){return He.default.existsSync(fn.amp())}},pi:{enable(){let t=fn.pi(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,hle("pi","pi","agent_start","agent_end"),"utf8"),{success:!0}},disable(){return He.default.existsSync(fn.pi())&&He.default.unlinkSync(fn.pi()),{success:!0}},isEnabled(){return He.default.existsSync(fn.pi())}},omp:{enable(){let t=fn.omp(),e=pr.default.dirname(t);return He.default.existsSync(e)||He.default.mkdirSync(e,{recursive:!0}),He.default.writeFileSync(t,b3e(),"utf8"),{success:!0}},disable(){return He.default.existsSync(fn.omp())&&He.default.unlinkSync(fn.omp()),{success:!0}},isEnabled(){return He.default.existsSync(fn.omp())}}},k3e=Z8});var n2=ae(()=>{Ds()});var Zq={};gr(Zq,{broadcastAiStatus:()=>ZE,broadcastServerInfo:()=>a2,initializeTerminal:()=>o2,listSessionRoots:()=>gu,matchWorkspacePath:()=>Nle,registerManagedSession:()=>s2,setConnectCheckHandler:()=>c2,setupTerminalHandlers:()=>l2,setupTerminalSocket:()=>tf});async function L3e(t,e){if(!Cne(e))return;let r=(await Cd().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",Fc()))}function U3e(t,e){let n=(NR.get(t)||"")+e,r=null;Rle.lastIndex=0;for(let o;o=Rle.exec(n);)r=o[1];if(r){let o=une(r);o&&is(t,o)}let i=n.lastIndexOf("\x1B]"),s=i===-1?"":n.slice(i);s&&s.length<=N3e&&!s.slice(3).includes("\x07")&&!s.includes("\x1B\\")?NR.set(t,s):NR.delete(t)}function kle(){let t=(Ile||Promise.resolve()).catch(()=>{}).then(()=>F3e());return Ile=t.catch(()=>{}),t}async function F3e(){let t=await Cd(),e=new Map(t.map(r=>[r.id,r])),n=zA();for(let r of t)if(!n[r.id])try{await Rd(r.id)}catch{}Hr.clear();for(let[r,i]of Object.entries(n)){let s=e.get(r);Hr.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??JE[r]??null,lastCols:i.cols??null,lastRows:i.rows??null,needsRespawn:!s,agent:i.agent||null}),i.agent&&is(r,i.agent),hF(r,i)}ni(Hr)}function B3e(t){!Zd||!t||QE.has(t)||QE.set(t,setTimeout(()=>{QE.delete(t),DC(Zd,Hr,t).catch(()=>{})},IQ))}function r2(){let{assignments:t,created:e}=Xne({sessions:Hr,workspaces:[...ef.values()],sessionWorkspaces:Rh});if(Object.keys(t).length){for(let n of e)ef.set(n.id,n);for(let[n,r]of Object.entries(t)){Rh[n]=r;let i=Hr.get(n);i&&!i.workspacePath&&(i.workspacePath=ef.get(r)?.path||null)}fy(ef,Rh,DR),ni(Hr),console.log(Mle(`\u{1F4C1} Grouped ${Object.keys(t).length} loose terminal(s)`+(e.length?` into ${e.length} new workspace(s)`:"")))}}function gu(){return[...Hr.entries()].map(([t,e])=>({id:t,name:e.name,workspacePath:e.workspacePath||null,cwd:e.cwd||null}))}function Nle(t,e){let n=e?(0,Ch.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,Ch.resolve)(o.path);n===a?r=o:n.startsWith(a+"/")&&(!i||a.length>(0,Ch.resolve)(i.path).length)?i=o:a.startsWith(n+"/")&&(!s||a.length<(0,Ch.resolve)(s.path).length)&&(s=o)}return r||i||s||null}function s2({sessionId:t,name:e,autoNamed:n=!0,cwd:r=null,workspacePath:i=null,shellId:s=null,shellLabel:o=null,agent:a=null}){let c=Nle([...ef.values()],i||r)||null;return Hr.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&&(Rh[t]=c.id,fy(ef,Rh,DR)),ni(Hr),et(null,"sessionsChanged"),{success:!0,sessionId:t,workspacePath:c?.path||null}}async function o2(){let t=$ne();if(!t){let r=zA(),i=qne();t=Yne(i,r);let s=new Map(t.workspaces.map(c=>[c.id,c]));if(fy(s,t.sessionWorkspaces,t.sessionOrder),JE=t.sessionPaths||{},Object.keys(JE).length){for(let[c,l]of Object.entries(JE))r[c]&&(r[c].workspacePath=l);Bne(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(Mle(`\u{1F4C1} Migrated ${t.workspaces.length} workspace(s) from terminal groups`+(a?`, dropped ${a} empty group(s)`:"")))}for(let r of t.workspaces)ef.set(r.id,r);Object.assign(Rh,t.sessionWorkspaces),DR.push(...t.sessionOrder),wne(()=>ni(Hr)),Ine(B3e);try{Ale()}catch{}try{ble()}catch{}Tle().catch(()=>{});try{lle()}catch{}if(i2==="daemon")if(!await YL())console.error("\u274C Failed to connect to PTY daemon, falling back to buffer mode");else{await kle(),r2(),Lp("connected",()=>{kle().then(r2).catch(()=>{})});return}console.log("\u{1F4E6} Buffer persistence mode - scrollback enabled");let e=Fne(),n=zA();for(let r of e){let i=n[r]||{};Hr.set(r,{pty:null,name:i.name||`Terminal ${Hr.size+1}`,autoNamed:i.autoNamed!==!1,createdAt:i.createdAt||Date.now(),cwd:i.cwd,workspacePath:i.workspacePath??JE[r]??null,shellId:i.shellId,buffer:[],needsRestore:!0}),hF(r,i),console.log(`\u{1F504} Found saved session: ${r}`)}e.length>0&&console.log(`\u2705 Found ${e.length} saved session(s)`),r2()}function tf(t,e){Zd=t,i2==="daemon"&&(Lp("output",({sessionId:i,enc:s,data:o,replay:a})=>{a!==!0&&(GA(i),qA(i));let c=s==="b64"?Buffer.from(o,"base64"):Buffer.from(o||"");c.length>Ia&&(MR++,(MR===1||MR%500===0)&&Ole.info(`[slice] chunk ${c.length>>10}KB \u2192 ${Math.ceil(c.length/Ia)} events (total sliced: ${MR})`)),s==="b64"&&U3e(i,c.toString("utf8"));for(let l=0;l<c.length||l===0;l+=Ia){let u=c.subarray(l,l+Ia),d=a===!0?IE(i):wse(i);a!==!0&&Sse(i,d,u),et(t,"output",{sessionId:i,enc:"bin",data:u,replay:a===!0,seq:d})}}),Nne(i=>et(t,"statusState",Fc())),One(()=>et(t,"statusState",Fc())),Lp("cwdChange",({sessionId:i,cwd:s})=>{let o=Hr.get(i);o&&s&&o.cwd!==s&&(o.cwd=s,ni(Hr)),et(t,"cwdChange",{sessionId:i,cwd:s})}),Lp("processChange",({sessionId:i,process:s})=>{let o=Tne(i,s);if(o?.state==="pendingShell"){setTimeout(()=>L3e(t,i),D3e);return}o?.state==="idle"&&(et(t,"statusChange",{sessionId:i,state:"idle",tool:null,conversationId:null}),et(t,"statusState",Fc()))}),Lp("sessionClosed",i=>{Hr.delete(i),Ay(i),ly(i),NR.delete(i);let s=QE.get(i);s&&(clearTimeout(s),QE.delete(i)),yF(i),et(t,"sessionClosed",i),et(t,"notificationCleared",i)}));let n=()=>({version:M3e,remoteAvailable:Pp(),mobileAvailable:Vte(),daemonMode:i2==="daemon"&&kn(),platform:process.platform,updateAvailable:dL(),canSelfUpdate:!0,caps:{joinSessionSize:!0,artifact:!0},artifactEnabled:XE(),voiceConfig:Aa().voiceConfig||null,mcpClients:Vy,...Yte()}),r=()=>{let i=n();for(let s of t.sockets.sockets.values())s.data?.approved&&s.emit("serverInfo",i)};mL(r),tf._buildServerInfo=n,tf._emitServerInfo=r}function a2(){tf._emitServerInfo?.()}function ZE(t,e,n,r=null){if(!Zd)return null;if(e==="done")return $A(t,()=>{let a=r?.sessionId||r?.threadId||rs(t)?.id||null,c=Gd(t),l=eh({type:e,sessionId:t,tool:n});!l||l===c||(et(Zd,"statusChange",{sessionId:t,state:e,tool:n,conversationId:a}),et(Zd,"statusState",Fc()))}),Gd(t);let i=r?.sessionId||r?.threadId||rs(t)?.id||null,s=Gd(t),o=eh({type:e,sessionId:t,tool:n});return!o||o===s||(et(Zd,"statusChange",{sessionId:t,state:e,tool:n,conversationId:i}),et(Zd,"statusState",Fc())),o}function c2(t){Dle=t}async function l2(t,e,n){Ole.info(`[diag] setupTerminalHandlers START id=${t.id} virtual=${!!t.defersWsAdapter}`),Xte(),Dle?.(),t.emit("srvCaps",{env2:1}),t.emit("serverInfo",tf._buildServerInfo?.()),Rse(t,e,Hr,ef,Rh,DR),Dse(t,Hr),ule(t,e),pA()&&await VZ(t,n).catch(r=>{console.error("\u274C Failed to setup remote handlers:",r.message)}),zte(t),t.on("disconnect",()=>{ece(t.id),Jte()})}var Ch,Ple,Ole,TCt,Mle,i2,M3e,Rle,N3e,D3e,NR,Hr,ef,Rh,DR,JE,Ile,QE,Zd,MR,Dle,$a=ae(()=>{K1();Ch=require("path"),Ple=require("url");mi();hA();Kte();So();RA();KA();Jne();UC();Lse();dle();Cle();RR();Og();hR();n2();Ds();Lc();Zi();IB();tu();tt();Ole=xe("terminal"),TCt=(0,Ch.dirname)((0,Ple.fileURLToPath)(__importMetaUrl)),Mle=Ov.rgb(230,138,110),i2="daemon",M3e="3.0.11",Rle=/\x1b\](?:0|2);([^\x07\x1b]*)(?:\x07|\x1b\\)/g,N3e=256,D3e=1500,NR=new Map;Hr=new Map,ef=new Map,Rh={},DR=[],JE={},Ile=null;QE=new Map,Zd=null;MR=0;Dle=null});var ew=B((ACt,qle)=>{"use strict";var q3e=require("path"),Kc="\\\\/",Lle=`[^${Kc}]`,$3e=0,yu="\\.",G3e="\\+",H3e="\\?",LR="\\/",j3e="(?=.)",Ule="[^/]",u2=`(?:${LR}|$)`,Fle=`(?:^|${LR})`,d2=`${yu}{1,2}${u2}`,W3e=`(?!${yu})`,V3e=`(?!${Fle}${d2})`,z3e=`(?!${yu}{0,1}${u2})`,K3e=`(?!${d2})`,Y3e=`[^.${LR}]`,X3e=`${Ule}*?`,Ble={DOT_LITERAL:yu,PLUS_LITERAL:G3e,QMARK_LITERAL:H3e,SLASH_LITERAL:LR,ONE_CHAR:j3e,QMARK:Ule,END_ANCHOR:u2,DOTS_SLASH:d2,NO_DOT:W3e,NO_DOTS:V3e,NO_DOT_SLASH:z3e,NO_DOTS_SLASH:K3e,QMARK_NO_DOT:Y3e,STAR:X3e,START_ANCHOR:Fle},J3e={...Ble,SLASH_LITERAL:`[${Kc}]`,QMARK:Lle,STAR:`${Lle}*?`,DOTS_SLASH:`${yu}{1,2}(?:[${Kc}]|$)`,NO_DOT:`(?!${yu})`,NO_DOTS:`(?!(?:^|[${Kc}])${yu}{1,2}(?:[${Kc}]|$))`,NO_DOT_SLASH:`(?!${yu}{0,1}(?:[${Kc}]|$))`,NO_DOTS_SLASH:`(?!${yu}{1,2}(?:[${Kc}]|$))`,QMARK_NO_DOT:`[^.${Kc}]`,START_ANCHOR:`(?:^|[${Kc}])`,END_ANCHOR:`(?:[${Kc}]|$)`},Q3e={__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"};qle.exports={DEFAULT_MAX_EXTGLOB_RECURSION:$3e,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Q3e,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:q3e.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?J3e:Ble}}});var UR=B(ds=>{"use strict";var Z3e=require("path"),eWe=process.platform==="win32",{REGEX_BACKSLASH:tWe,REGEX_REMOVE_BACKSLASH:nWe,REGEX_SPECIAL_CHARS:rWe,REGEX_SPECIAL_CHARS_GLOBAL:iWe}=ew();ds.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);ds.hasRegexChars=t=>rWe.test(t);ds.isRegexChar=t=>t.length===1&&ds.hasRegexChars(t);ds.escapeRegex=t=>t.replace(iWe,"\\$1");ds.toPosixSlashes=t=>t.replace(tWe,"/");ds.removeBackslashes=t=>t.replace(nWe,e=>e==="\\"?"":e);ds.supportsLookbehinds=()=>{let t=process.version.slice(1).split(".").map(Number);return t.length===3&&t[0]>=9||t[0]===8&&t[1]>=10};ds.isWindows=t=>t&&typeof t.windows=="boolean"?t.windows:eWe===!0||Z3e.sep==="\\";ds.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?ds.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};ds.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};ds.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",i=n.contains?"":"$",s=`${r}(?:${t})${i}`;return e.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var Kle=B((RCt,zle)=>{"use strict";var $le=UR(),{CHAR_ASTERISK:f2,CHAR_AT:sWe,CHAR_BACKWARD_SLASH:tw,CHAR_COMMA:oWe,CHAR_DOT:p2,CHAR_EXCLAMATION_MARK:h2,CHAR_FORWARD_SLASH:Vle,CHAR_LEFT_CURLY_BRACE:m2,CHAR_LEFT_PARENTHESES:g2,CHAR_LEFT_SQUARE_BRACKET:aWe,CHAR_PLUS:cWe,CHAR_QUESTION_MARK:Gle,CHAR_RIGHT_CURLY_BRACE:lWe,CHAR_RIGHT_PARENTHESES:Hle,CHAR_RIGHT_SQUARE_BRACKET:uWe}=ew(),jle=t=>t===Vle||t===tw,Wle=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},dWe=(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,d=0,f=!1,m=!1,g=!1,y=!1,w=!1,S=!1,T=!1,R=!1,C=!1,D=!1,$=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===tw){T=L.backslashes=!0,V=A(),V===m2&&(S=!0);continue}if(S===!0||V===m2){for($++;k()!==!0&&(V=A());){if(V===tw){T=L.backslashes=!0,A();continue}if(V===m2){$++;continue}if(S!==!0&&V===p2&&(V=A())===p2){if(f=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(S!==!0&&V===oWe){if(f=L.isBrace=!0,g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===lWe&&($--,$===0)){S=!1,f=L.isBrace=!0,D=!0;break}}if(i===!0)continue;break}if(V===Vle){if(s.push(l),o.push(L),L={value:"",depth:0,isGlob:!1},D===!0)continue;if(G===p2&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(V===cWe||V===sWe||V===f2||V===Gle||V===h2)===!0&&E()===g2){if(g=L.isGlob=!0,y=L.isExtglob=!0,D=!0,V===h2&&l===u&&(C=!0),i===!0){for(;k()!==!0&&(V=A());){if(V===tw){T=L.backslashes=!0,V=A();continue}if(V===Hle){g=L.isGlob=!0,D=!0;break}}continue}break}if(V===f2){if(G===f2&&(w=L.isGlobstar=!0),g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===Gle){if(g=L.isGlob=!0,D=!0,i===!0)continue;break}if(V===aWe){for(;k()!==!0&&(X=A());){if(X===tw){T=L.backslashes=!0,A();continue}if(X===uWe){m=L.isBracket=!0,g=L.isGlob=!0,D=!0;break}}if(i===!0)continue;break}if(n.nonegate!==!0&&V===h2&&l===u){R=L.negated=!0,u++;continue}if(n.noparen!==!0&&V===g2){if(g=L.isGlob=!0,i===!0){for(;k()!==!0&&(V=A());){if(V===g2){T=L.backslashes=!0,V=A();continue}if(V===Hle){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),d-=u),M&&g===!0&&d>0?(M=c.slice(0,d),P=c.slice(d)):g===!0?(M="",P=c):M=c,M&&M!==""&&M!=="/"&&M!==c&&jle(M.charCodeAt(M.length-1))&&(M=M.slice(0,-1)),n.unescape===!0&&(P&&(P=$le.removeBackslashes(P)),M&&T===!0&&(M=$le.removeBackslashes(M)));let F={prefix:I,input:t,start:u,base:M,glob:P,isBrace:f,isBracket:m,isGlob:g,isExtglob:y,isGlobstar:w,negated:R,negatedExtglob:C};if(n.tokens===!0&&(F.maxDepth=0,jle(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,q=s[N],pe=t.slice(b,q);n.tokens&&(N===0&&u!==0?(o[N].isPrefix=!0,o[N].value=I):o[N].value=pe,Wle(o[N]),F.maxDepth+=o[N].depth),(N!==0||pe!=="")&&a.push(pe),X=q}if(X&&X+1<t.length){let N=t.slice(X+1);a.push(N),n.tokens&&(o[o.length-1].value=N,Wle(o[o.length-1]),F.maxDepth+=o[o.length-1].depth)}F.slashes=s,F.parts=a}return F};zle.exports=dWe});var Zle=B((ICt,Qle)=>{"use strict";var nw=ew(),Ei=UR(),{MAX_LENGTH:FR,POSIX_REGEX_SOURCE:fWe,REGEX_NON_SPECIAL_CHARS:pWe,REGEX_SPECIAL_CHARS_BACKREF:hWe,REPLACEMENTS:Yle}=nw,mWe=(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=>Ei.escapeRegex(i)).join("..")}return n},zy=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,Xle=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},gWe=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},Jle=t=>{let e=t.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=!0);if(gWe(e))return e.replace(/\\(.)/g,"$1")},yWe=t=>{let e=t.map(Jle).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},y2=(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}}}}},_We=t=>{let e=0,n=[];for(;e<t.length;){let i=y2(t.slice(e),!1);if(!i||i.type!=="*")return;let s=Xle(i.body).map(a=>a.trim());if(s.length!==1)return;let o=Jle(s[0]);if(!o||o.length!==1)return;n.push(o),e+=i.end+1}return n.length<1?void 0:`${n.length===1?Ei.escapeRegex(n[0]):`[${n.map(i=>Ei.escapeRegex(i)).join("")}]`}*`},vWe=t=>{let e=0,n=t.trim(),r=y2(n);for(;r;)e++,n=r.body.trim(),r=y2(n);return e},EWe=(t,e)=>{if(e.maxExtglobRecursion===!1)return{risky:!1};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:nw.DEFAULT_MAX_EXTGLOB_RECURSION,r=Xle(t).map(i=>i.trim());if(r.length>1&&(r.some(i=>i==="")||r.some(i=>/^[*?]+$/.test(i))||yWe(r)))return{risky:!0};for(let i of r){let s=_We(i);if(s)return{risky:!0,safeOutput:s};if(vWe(i)>n)return{risky:!0}}return{risky:!1}},_2=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=Yle[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(FR,n.maxLength):FR,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=Ei.isWindows(e),l=nw.globChars(c),u=nw.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,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:$}=l,G=U=>`(${a}(?:(?!${$}${U.dot?y:d}).)*?)`,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=Ei.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]||"",q=()=>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},lt=(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=EWe(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||Ei.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(q()))&&(Z=U.close=`)$))${ie}`),U.inner.includes("*")&&(ee=q())&&/^\.[^\\/.]+$/.test(ee)){let ne=_2(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(hWe,(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==="."?d.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=Ei.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(q()),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=fWe[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=Ei.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(zy("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||!q().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(zy("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(zy("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||Ei.hasRegexChars(j))continue;let Q=Ei.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=mWe(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=d);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:d});continue}Se({type:"dot",value:F,output:d});continue}if(F==="?"){if(!(P&&P.value==="(")&&n.noextglob!==!0&&N()==="("&&N(2)!=="?"){lt("qmark",F);continue}if(P&&P.type==="paren"){let Q=N(),Z=F;if(Q==="<"&&!Ei.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(P.value==="("&&!/[!=<:]/.test(Q)||Q==="<"&&!/<([!=]|\w+>)/.test(q()))&&(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)))){lt("negate",F);continue}if(n.nonegate!==!0&&E.index===0){J();continue}}if(F==="+"){if(n.noextglob!==!0&&N()==="("&&N(2)!=="?"){lt("plus",F);continue}if(P&&P.value==="("||n.regex===!1){Se({type:"plus",value:F,output:f});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:f});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=pWe.exec(q());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=q();if(n.noextglob!==!0&&/^\([^?]/.test(U)){lt("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(zy("closing","]"));E.output=Ei.escapeLast(E.output,"["),we("brackets")}for(;E.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(zy("closing",")"));E.output=Ei.escapeLast(E.output,"("),we("parens")}for(;E.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(zy("closing","}"));E.output=Ei.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};_2.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(FR,n.maxLength):FR,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);t=Yle[t]||t;let s=Ei.isWindows(e),{DOT_LITERAL:o,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:m,START_ANCHOR:g}=nw.globChars(s),y=n.dot?d:u,w=n.dot?f: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}}},$=Ei.removePrefix(t,T),G=D($);return G&&n.strictSlashes!==!0&&(G+=`${a}?`),G};Qle.exports=_2});var tue=B((kCt,eue)=>{"use strict";var wWe=require("path"),SWe=Kle(),v2=Zle(),E2=UR(),xWe=ew(),bWe=t=>t&&typeof t=="object"&&!Array.isArray(t),hr=(t,e,n=!1)=>{if(Array.isArray(t)){let u=t.map(f=>hr(f,e,n));return f=>{for(let m of u){let g=m(f);if(g)return g}return!1}}let r=bWe(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?hr.compileRe(t,e):hr.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=hr(i.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:m,output:g}=hr.test(u,o,e,{glob:t,posix:s}),y={glob:t,state:a,regex:o,posix:s,input:u,output:g,match:m,isMatch:f};return typeof i.onResult=="function"&&i.onResult(y),f===!1?(y.isMatch=!1,d?y:!1):c(u)?(typeof i.onIgnore=="function"&&i.onIgnore(y),y.isMatch=!1,d?y:!1):(typeof i.onMatch=="function"&&i.onMatch(y),d?y:!0)};return n&&(l.state=a),l};hr.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=hr.matchBase(t,e,n,i):a=e.exec(c)),{isMatch:!!a,match:a,output:c}};hr.matchBase=(t,e,n,r=E2.isWindows(n))=>(e instanceof RegExp?e:hr.makeRe(e,n)).test(wWe.basename(t));hr.isMatch=(t,e,n)=>hr(e,n)(t);hr.parse=(t,e)=>Array.isArray(t)?t.map(n=>hr.parse(n,e)):v2(t,{...e,fastpaths:!1});hr.scan=(t,e)=>SWe(t,e);hr.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=hr.toRegex(a,e);return r===!0&&(c.state=t),c};hr.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=v2.fastpaths(t,e)),i.output||(i=v2(t,e)),hr.compileRe(i,e,n,r)};hr.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/$^/}};hr.constants=xWe;eue.exports=hr});var w2=B((PCt,nue)=>{"use strict";nue.exports=tue()});var uue=B((OCt,lue)=>{"use strict";var iw=require("fs"),{Readable:TWe}=require("stream"),rw=require("path"),{promisify:GR}=require("util"),S2=w2(),AWe=GR(iw.readdir),CWe=GR(iw.stat),rue=GR(iw.lstat),RWe=GR(iw.realpath),IWe="!",aue="READDIRP_RECURSIVE_ERROR",kWe=new Set(["ENOENT","EPERM","EACCES","ELOOP",aue]),x2="files",cue="directories",qR="files_directories",BR="all",iue=[x2,cue,qR,BR],PWe=t=>kWe.has(t.code),[sue,OWe]=process.versions.node.split(".").slice(0,2).map(t=>Number.parseInt(t,10)),MWe=process.platform==="win32"&&(sue>10||sue===10&&OWe>=5),oue=t=>{if(t!==void 0){if(typeof t=="function")return t;if(typeof t=="string"){let e=S2(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)===IWe?n.push(S2(i.slice(1))):e.push(S2(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))}}},$R=class t extends TWe{static get defaultOptions(){return{root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:x2,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=oue(n.fileFilter),this._directoryFilter=oue(n.directoryFilter);let s=n.lstat?rue:CWe;MWe?this._stat=o=>s(o,{bigint:!0}):this._stat=s,this._maxDepth=n.depth,this._wantsDir=[cue,qR,BR].includes(i),this._wantsFile=[x2,qR,BR].includes(i),this._wantsEverything=i===BR,this._root=rw.resolve(r),this._isDirent="Dirent"in iw&&!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 AWe(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=rw.resolve(rw.join(n,i));r={path:rw.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){PWe(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 RWe(r),s=await rue(i);if(s.isFile())return"file";if(s.isDirectory()){let o=i.length;if(r.startsWith(i)&&r.substr(o,1)===rw.sep){let a=new Error(`Circular symlink detected: "${r}" points to "${i}"`);return a.code=aue,this._onError(a)}return"directory"}}catch(i){this._onError(i)}}}}_includeAsFile(e){let n=e&&e[this._statsProp];return n&&this._wantsEverything&&!n.isDirectory()}},Ky=(t,e={})=>{let n=e.entryType||e.type;if(n==="both"&&(n=qR),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&&!iue.includes(n))throw new Error(`readdirp: Invalid type passed. Use one of ${iue.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new $R(e)},NWe=(t,e={})=>new Promise((n,r)=>{let i=[];Ky(t,e).on("data",s=>i.push(s)).on("end",()=>n(i)).on("error",s=>r(s))});Ky.promise=NWe;Ky.ReaddirpStream=$R;Ky.default=Ky;lue.exports=Ky});var Yy=B((MCt,due)=>{due.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 yue=B((mue,gue)=>{"use strict";Object.defineProperty(mue,"__esModule",{value:!0});var hue=w2(),DWe=Yy(),fue="!",LWe={returnIndex:!1},UWe=t=>Array.isArray(t)?t:[t],FWe=(t,e)=>{if(typeof t=="function")return t;if(typeof t=="string"){let n=hue(t,e);return r=>t===r||n(r)}return t instanceof RegExp?n=>t.test(n):n=>!1},pue=(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=DWe(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},b2=(t,e,n=LWe)=>{if(t==null)throw new TypeError("anymatch: specify first argument");let r=typeof n=="boolean"?{returnIndex:n}:n,i=r.returnIndex||!1,s=UWe(t),o=s.filter(c=>typeof c=="string"&&c.charAt(0)===fue).map(c=>c.slice(1)).map(c=>hue(c,r)),a=s.filter(c=>typeof c!="string"||typeof c=="string"&&c.charAt(0)!==fue).map(c=>FWe(c,r));return e==null?(c,l=!1)=>pue(a,o,c,typeof l=="boolean"?l:!1):pue(a,o,e,i)};b2.default=b2;gue.exports=b2});var vue=B((NCt,_ue)=>{_ue.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 T2=B((DCt,wue)=>{var BWe=vue(),Eue={"{":"}","(":")","[":"]"},qWe=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=Eue[a];if(c){var l=t.indexOf(c,e);l!==-1&&(e=l+1)}if(t[e]==="!")return!0}else e++}return!1},$We=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=Eue[n];if(r){var i=t.indexOf(r,e);i!==-1&&(e=i+1)}if(t[e]==="!")return!0}else e++}return!1};wue.exports=function(e,n){if(typeof e!="string"||e==="")return!1;if(BWe(e))return!0;var r=qWe;return n&&n.strict===!1&&(r=$We),r(e)}});var xue=B((LCt,Sue)=>{"use strict";var GWe=T2(),HWe=require("path").posix.dirname,jWe=require("os").platform()==="win32",A2="/",WWe=/\\/g,VWe=/[\{\[].*[\}\]]$/,zWe=/(^|[^\\])([\{\[]|\([^\)]+$)/,KWe=/\\([\!\*\?\|\[\]\(\)\{\}])/g;Sue.exports=function(e,n){var r=Object.assign({flipBackslashes:!0},n);r.flipBackslashes&&jWe&&e.indexOf(A2)<0&&(e=e.replace(WWe,A2)),VWe.test(e)&&(e+=A2),e+="a";do e=HWe(e);while(GWe(e)||zWe.test(e));return e.replace(KWe,"$1")}});var HR=B(qo=>{"use strict";qo.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1;qo.find=(t,e)=>t.nodes.find(n=>n.type===e);qo.exceedsLimit=(t,e,n=1,r)=>r===!1||!qo.isInteger(t)||!qo.isInteger(e)?!1:(Number(e)-Number(t))/Number(n)>=r;qo.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)};qo.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1;qo.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;qo.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0;qo.reduce=t=>t.reduce((e,n)=>(n.type==="text"&&e.push(n.value),n.type==="range"&&(n.type="text"),e),[]);qo.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 jR=B((FCt,Tue)=>{"use strict";var bue=HR();Tue.exports=(t,e={})=>{let n=(r,i={})=>{let s=e.escapeInvalid&&bue.isInvalidBrace(i),o=r.invalid===!0&&e.escapeInvalid===!0,a="";if(r.value)return(s||o)&&bue.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 Cue=B((BCt,Aue)=>{"use strict";Aue.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var Lue=B((qCt,Due)=>{"use strict";var Rue=Cue(),Ih=(t,e,n)=>{if(Rue(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(Rue(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(Ih.cache.hasOwnProperty(c))return Ih.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 d=Nue(t)||Nue(e),f={min:t,max:e,a:l,b:u},m=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let y=u<0?Math.abs(u):1;g=Iue(y,Math.abs(l),f,r),l=f.a=0}return u>=0&&(m=Iue(l,u,f,r)),f.negatives=g,f.positives=m,f.result=YWe(g,m,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&m.length+g.length>1&&(f.result=`(?:${f.result})`),Ih.cache[c]=f,f.result};function YWe(t,e,n){let r=C2(t,e,"-",!1,n)||[],i=C2(e,t,"",!1,n)||[],s=C2(t,e,"-?",!0,n)||[];return r.concat(s).concat(i).join("|")}function XWe(t,e){let n=1,r=1,i=Pue(t,n),s=new Set([e]);for(;t<=i&&i<=e;)s.add(i),n+=1,i=Pue(t,n);for(i=Oue(e+1,r)-1;t<i&&i<=e;)s.add(i),r+=1,i=Oue(e+1,r)-1;return s=[...s],s.sort(ZWe),s}function JWe(t,e,n){if(t===e)return{pattern:t,count:[],digits:0};let r=QWe(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+=e6e(c,l,n):o++}return o&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[o],digits:i}}function Iue(t,e,n,r){let i=XWe(t,e),s=[],o=t,a;for(let c=0;c<i.length;c++){let l=i[c],u=JWe(String(o),String(l),r),d="";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+Mue(a.count),o=l+1;continue}n.isPadded&&(d=t6e(l,n,r)),u.string=d+u.pattern+Mue(u.count),s.push(u),o=l+1,a=u}return s}function C2(t,e,n,r,i){let s=[];for(let o of t){let{string:a}=o;!r&&!kue(e,"string",a)&&s.push(n+a),r&&kue(e,"string",a)&&s.push(n+a)}return s}function QWe(t,e){let n=[];for(let r=0;r<t.length;r++)n.push([t[r],e[r]]);return n}function ZWe(t,e){return t>e?1:e>t?-1:0}function kue(t,e,n){return t.some(r=>r[e]===n)}function Pue(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function Oue(t,e){return t-t%Math.pow(10,e)}function Mue(t){let[e=0,n=""]=t;return n||e>1?`{${e+(n?","+n:"")}}`:""}function e6e(t,e,n){return`[${t}${e-t===1?"":"-"}${e}]`}function Nue(t){return/^-?(0+)\d/.test(t)}function t6e(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}}`}}Ih.cache={};Ih.clearCache=()=>Ih.cache={};Due.exports=Ih});var k2=B(($Ct,Hue)=>{"use strict";var n6e=require("util"),Fue=Lue(),Uue=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),r6e=t=>e=>t===!0?Number(e):String(e),R2=t=>typeof t=="number"||typeof t=="string"&&t!=="",sw=t=>Number.isInteger(+t),I2=t=>{let e=`${t}`,n=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++n]==="0";);return n>0},i6e=(t,e,n)=>typeof t=="string"||typeof e=="string"?!0:n.stringify===!0,s6e=(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},VR=(t,e)=>{let n=t[0]==="-"?"-":"";for(n&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return n?"-"+t:t},o6e=(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=>VR(String(a),n)).join("|")),t.negatives.length&&(s=`-(${r}${t.negatives.map(a=>VR(String(a),n)).join("|")})`),i&&s?o=`${i}|${s}`:o=i||s,e.wrap?`(${r}${o})`:o},Bue=(t,e,n,r)=>{if(n)return Fue(t,e,{wrap:!1,...r});let i=String.fromCharCode(t);if(t===e)return i;let s=String.fromCharCode(e);return`[${i}-${s}]`},que=(t,e,n)=>{if(Array.isArray(t)){let r=n.wrap===!0,i=n.capture?"":"?:";return r?`(${i}${t.join("|")})`:t.join("|")}return Fue(t,e,n)},$ue=(...t)=>new RangeError("Invalid range arguments: "+n6e.inspect(...t)),Gue=(t,e,n)=>{if(n.strictRanges===!0)throw $ue([t,e]);return[]},a6e=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},c6e=(t,e,n=1,r={})=>{let i=Number(t),s=Number(e);if(!Number.isInteger(i)||!Number.isInteger(s)){if(r.strictRanges===!0)throw $ue([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=I2(a)||I2(c)||I2(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&i6e(t,e,r)===!1,m=r.transform||r6e(f);if(r.toRegex&&n===1)return Bue(VR(t,d),VR(e,d),!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(s6e(m(i,S),d,f)),i=o?i-n:i+n,S++;return r.toRegex===!0?n>1?o6e(g,r,d):que(w,null,{wrap:!1,...r}):w},l6e=(t,e,n=1,r={})=>{if(!sw(t)&&t.length>1||!sw(e)&&e.length>1)return Gue(t,e,r);let i=r.transform||(f=>String.fromCharCode(f)),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 Bue(c,l,!1,r);let u=[],d=0;for(;a?s>=o:s<=o;)u.push(i(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?que(u,null,{wrap:!1,options:r}):u},WR=(t,e,n,r={})=>{if(e==null&&R2(t))return[t];if(!R2(t)||!R2(e))return Gue(t,e,r);if(typeof n=="function")return WR(t,e,1,{transform:n});if(Uue(n))return WR(t,e,0,n);let i={...r};return i.capture===!0&&(i.wrap=!0),n=n||i.step||1,sw(n)?sw(t)&&sw(e)?c6e(t,e,n,i):l6e(t,e,Math.max(Math.abs(n),1),i):n!=null&&!Uue(n)?a6e(n,i):WR(t,e,1,n)};Hue.exports=WR});var Vue=B((GCt,Wue)=>{"use strict";var u6e=k2(),jue=HR(),d6e=(t,e={})=>{let n=(r,i={})=>{let s=jue.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=jue.reduce(r.nodes),d=u6e(...u,{...e,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(t)};Wue.exports=d6e});var Yue=B((HCt,Kue)=>{"use strict";var f6e=k2(),zue=jR(),Xy=HR(),kh=(t="",e="",n=!1)=>{let r=[];if(t=[].concat(t),e=[].concat(e),!e.length)return t;if(!t.length)return n?Xy.flatten(e).map(i=>`{${i}}`):e;for(let i of t)if(Array.isArray(i))for(let s of i)r.push(kh(s,e,n));else for(let s of e)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?kh(i,s,n):i+s);return Xy.flatten(r)},p6e=(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(kh(a.pop(),zue(i,e)));return}if(i.type==="brace"&&i.invalid!==!0&&i.nodes.length===2){a.push(kh(a.pop(),["{}"]));return}if(i.nodes&&i.ranges>0){let d=Xy.reduce(i.nodes);if(Xy.exceedsLimit(...d,e.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=f6e(...d,e);f.length===0&&(f=zue(i,e)),a.push(kh(a.pop(),f)),i.nodes=[];return}let c=Xy.encloseBrace(i),l=i.queue,u=i;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<i.nodes.length;d++){let f=i.nodes[d];if(f.type==="comma"&&i.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(kh(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(kh(l.pop(),f.value));continue}f.nodes&&r(f,i)}return l};return Xy.flatten(r(t))};Kue.exports=p6e});var Jue=B((jCt,Xue)=>{"use strict";Xue.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:`
|
|
413
413
|
`,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 nde=B((WCt,tde)=>{"use strict";var h6e=jR(),{MAX_LENGTH:Que,CHAR_BACKSLASH:P2,CHAR_BACKTICK:m6e,CHAR_COMMA:g6e,CHAR_DOT:y6e,CHAR_LEFT_PARENTHESES:_6e,CHAR_RIGHT_PARENTHESES:v6e,CHAR_LEFT_CURLY_BRACE:E6e,CHAR_RIGHT_CURLY_BRACE:w6e,CHAR_LEFT_SQUARE_BRACKET:Zue,CHAR_RIGHT_SQUARE_BRACKET:ede,CHAR_DOUBLE_QUOTE:S6e,CHAR_SINGLE_QUOTE:x6e,CHAR_NO_BREAK_SPACE:b6e,CHAR_ZERO_WIDTH_NOBREAK_SPACE:T6e}=Jue(),A6e=(t,e={})=>{if(typeof t!="string")throw new TypeError("Expected a string");let n=e||{},r=typeof n.maxLength=="number"?Math.min(Que,n.maxLength):Que;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,d=0,f,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],f=m(),!(f===T6e||f===b6e)){if(f===P2){g({type:"text",value:(e.keepEscaping?f:"")+m()});continue}if(f===ede){g({type:"text",value:"\\"+f});continue}if(f===Zue){c++;let y;for(;u<l&&(y=m());){if(f+=y,y===Zue){c++;continue}if(y===P2){f+=m();continue}if(y===ede&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===_6e){o=g({type:"paren",nodes:[]}),s.push(o),g({type:"text",value:f});continue}if(f===v6e){if(o.type!=="paren"){g({type:"text",value:f});continue}o=s.pop(),g({type:"text",value:f}),o=s[s.length-1];continue}if(f===S6e||f===x6e||f===m6e){let y=f,w;for(e.keepQuotes!==!0&&(f="");u<l&&(w=m());){if(w===P2){f+=w+m();continue}if(w===y){e.keepQuotes===!0&&(f+=w);break}f+=w}g({type:"text",value:f});continue}if(f===E6e){d++;let w={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||o.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};o=g(w),s.push(o),g({type:"open",value:f});continue}if(f===w6e){if(o.type!=="brace"){g({type:"text",value:f});continue}let y="close";o=s.pop(),o.close=!0,g({type:y,value:f}),d--,o=s[s.length-1];continue}if(f===g6e&&d>0){if(o.ranges>0){o.ranges=0;let y=o.nodes.shift();o.nodes=[y,{type:"text",value:h6e(o)}]}g({type:"comma",value:f}),o.commas++;continue}if(f===y6e&&d>0&&o.commas===0){let y=o.nodes;if(d===0||y.length===0){g({type:"text",value:f});continue}if(a.type==="dot"){if(o.range=[],a.value+=f,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+f,a=w,o.ranges--;continue}g({type:"dot",value:f});continue}g({type:"text",value:f})}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};tde.exports=A6e});var sde=B((VCt,ide)=>{"use strict";var rde=jR(),C6e=Vue(),R6e=Yue(),I6e=nde(),$s=(t,e={})=>{let n=[];if(Array.isArray(t))for(let r of t){let i=$s.create(r,e);Array.isArray(i)?n.push(...i):n.push(i)}else n=[].concat($s.create(t,e));return e&&e.expand===!0&&e.nodupes===!0&&(n=[...new Set(n)]),n};$s.parse=(t,e={})=>I6e(t,e);$s.stringify=(t,e={})=>rde(typeof t=="string"?$s.parse(t,e):t,e);$s.compile=(t,e={})=>(typeof t=="string"&&(t=$s.parse(t,e)),C6e(t,e));$s.expand=(t,e={})=>{typeof t=="string"&&(t=$s.parse(t,e));let n=R6e(t,e);return e.noempty===!0&&(n=n.filter(Boolean)),e.nodupes===!0&&(n=[...new Set(n)]),n};$s.create=(t,e={})=>t===""||t.length<3?[t]:e.expand!==!0?$s.compile(t,e):$s.expand(t,e);ide.exports=$s});var ode=B((zCt,k6e)=>{k6e.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 cde=B((KCt,ade)=>{ade.exports=ode()});var ude=B((YCt,lde)=>{"use strict";var P6e=require("path"),O6e=cde(),M6e=new Set(O6e);lde.exports=t=>M6e.has(P6e.extname(t).slice(1).toLowerCase())});var zR=B(qe=>{"use strict";var{sep:N6e}=require("path"),{platform:O2}=process,D6e=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=`.${N6e}`;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=O2==="win32";qe.isMacos=O2==="darwin";qe.isLinux=O2==="linux";qe.isIBMi=D6e.type()==="OS400"});var gde=B((JCt,mde)=>{"use strict";var _u=require("fs"),jr=require("path"),{promisify:lw}=require("util"),L6e=ude(),{isWindows:U6e,isLinux:F6e,EMPTY_FN:B6e,EMPTY_STR:q6e,KEY_LISTENERS:Jy,KEY_ERR:M2,KEY_RAW:ow,HANDLER_KEYS:$6e,EV_CHANGE:YR,EV_ADD:KR,EV_ADD_DIR:G6e,EV_ERROR:fde,STR_DATA:H6e,STR_END:j6e,BRACE_START:W6e,STAR:V6e}=zR(),z6e="watch",K6e=lw(_u.open),pde=lw(_u.stat),Y6e=lw(_u.lstat),X6e=lw(_u.close),N2=lw(_u.realpath),J6e={lstat:Y6e,stat:pde},L2=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},aw=(t,e,n)=>{let r=t[e];r instanceof Set||(t[e]=r=new Set([r])),r.add(n)},Q6e=t=>e=>{let n=t[e];n instanceof Set?n.clear():delete t[e]},cw=(t,e,n)=>{let r=t[e];r instanceof Set?r.delete(n):r===n&&delete t[e]},hde=t=>t instanceof Set?t.size===0:!t,XR=new Map;function dde(t,e,n,r,i){let s=(o,a)=>{n(t),i(o,a,{watchedPath:t}),a&&t!==a&&JR(jr.resolve(t,a),Jy,jr.join(t,a))};try{return _u.watch(t,e,s)}catch(o){r(o)}}var JR=(t,e,n,r,i)=>{let s=XR.get(t);s&&L2(s[e],o=>{o(n,r,i)})},Z6e=(t,e,n,r)=>{let{listener:i,errHandler:s,rawEmitter:o}=r,a=XR.get(e),c;if(!n.persistent)return c=dde(t,n,i,s,o),c.close.bind(c);if(a)aw(a,Jy,i),aw(a,M2,s),aw(a,ow,o);else{if(c=dde(t,n,JR.bind(null,e,Jy),s,JR.bind(null,e,ow)),!c)return;c.on(fde,async l=>{let u=JR.bind(null,e,M2);if(a.watcherUnusable=!0,U6e&&l.code==="EPERM")try{let d=await K6e(t,"r");await X6e(d),u(l)}catch{}else u(l)}),a={listeners:i,errHandlers:s,rawEmitters:o,watcher:c},XR.set(e,a)}return()=>{cw(a,Jy,i),cw(a,M2,s),cw(a,ow,o),hde(a.listeners)&&(a.watcher.close(),XR.delete(e),$6e.forEach(Q6e(a)),a.watcher=void 0,Object.freeze(a))}},D2=new Map,eVe=(t,e,n,r)=>{let{listener:i,rawEmitter:s}=r,o=D2.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,_u.unwatchFile(e),o=void 0),o?(aw(o,Jy,i),aw(o,ow,s)):(o={listeners:i,rawEmitters:s,options:n,watcher:_u.watchFile(e,n,(u,d)=>{L2(o.rawEmitters,m=>{m(YR,e,{curr:u,prev:d})});let f=u.mtimeMs;(u.size!==d.size||f>d.mtimeMs||f===0)&&L2(o.listeners,m=>m(t,u))})},D2.set(e,o)),()=>{cw(o,Jy,i),cw(o,ow,s),hde(o.listeners)&&(D2.delete(e),_u.unwatchFile(e),o.options=o.watcher=void 0,Object.freeze(o))}},U2=class{constructor(e){this.fsw=e,this._boundHandleError=n=>e._handleError(n)}_watchWithNodeFs(e,n){let r=this.fsw.options,i=jr.dirname(e),s=jr.basename(e);this.fsw._getWatchedDir(i).add(s);let a=jr.resolve(e),c={persistent:r.persistent};n||(n=B6e);let l;return r.usePolling?(c.interval=r.enableBinaryInterval&&L6e(s)?r.binaryInterval:r.interval,l=eVe(e,a,c,{listener:n,rawEmitter:this.fsw._emitRaw})):l=Z6e(e,a,c,{listener:n,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),l}_handleFile(e,n,r){if(this.fsw.closed)return;let i=jr.dirname(e),s=jr.basename(e),o=this.fsw._getWatchedDir(i),a=n;if(o.has(s))return;let c=async(u,d)=>{if(this.fsw._throttle(z6e,e,5)){if(!d||d.mtimeMs===0)try{let f=await pde(e);if(this.fsw.closed)return;let m=f.atimeMs,g=f.mtimeMs;(!m||m<=g||g!==a.mtimeMs)&&this.fsw._emit(YR,e,f),F6e&&a.ino!==f.ino?(this.fsw._closeFile(u),a=f,this.fsw._addPathCloser(u,this._watchWithNodeFs(e,c))):a=f}catch{this.fsw._remove(i,s)}else if(o.has(s)){let f=d.atimeMs,m=d.mtimeMs;(!f||f<=m||m!==a.mtimeMs)&&this.fsw._emit(YR,e,d),a=d}}},l=this._watchWithNodeFs(e,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(KR,e,0))return;this.fsw._emit(KR,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 N2(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(YR,r,e.stats)):(o.add(i),this.fsw._symlinkPaths.set(s,a),this.fsw._emit(KR,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=jr.join(e,q6e),!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:d=>r.filterPath(d),directoryFilter:d=>r.filterDir(d),depth:0}).on(H6e,async d=>{if(this.fsw.closed){u=void 0;return}let f=d.path,m=jr.join(e,f);if(l.add(f),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,e,m,f))){if(this.fsw.closed){u=void 0;return}(f===i||!i&&!c.has(f))&&(this.fsw._incrReadyCount(),m=jr.join(s,jr.relative(s,m)),this._addToNodeFs(m,n,r,o+1))}}).on(fde,this._boundHandleError);return new Promise(d=>u.once(j6e,()=>{if(this.fsw.closed){u=void 0;return}let f=a?a.clear():!1;d(),c.getChildren().filter(m=>m!==e&&!l.has(m)&&(!r.hasGlob||r.filterPath({fullPath:jr.resolve(e,m)}))).forEach(m=>{this.fsw._remove(e,m)}),u=void 0,f&&this._handleRead(e,!1,r,i,s,o,a)}))}async _handleDir(e,n,r,i,s,o,a){let c=this.fsw._getWatchedDir(jr.dirname(e)),l=c.has(jr.basename(e));!(r&&this.fsw.options.ignoreInitial)&&!s&&!l&&(!o.hasGlob||o.globFilter(e))&&this.fsw._emit(G6e,e,n),c.add(jr.basename(e)),this.fsw._getWatchedDir(e);let u,d,f=this.fsw.options.depth;if((f==null||i<=f)&&!this.fsw._symlinkPaths.has(a)){if(!s&&(await this._handleRead(e,r,o,s,e,i,u),this.fsw.closed))return;d=this._watchWithNodeFs(e,(m,g)=>{g&&g.mtimeMs===0||this._handleRead(m,!1,o,s,e,i,u)})}return d}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 J6e[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(V6e)&&!e.includes(W6e),u;if(c.isDirectory()){let d=jr.resolve(e),f=l?await N2(e):e;if(this.fsw.closed||(u=await this._handleDir(a.watchPath,c,n,i,s,a,f),this.fsw.closed))return;d!==f&&f!==void 0&&this.fsw._symlinkPaths.set(d,f)}else if(c.isSymbolicLink()){let d=l?await N2(e):e;if(this.fsw.closed)return;let f=jr.dirname(a.watchPath);if(this.fsw._getWatchedDir(f).add(a.watchPath),this.fsw._emit(KR,a.watchPath,c),u=await this._handleDir(f,c,n,i,e,a,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(jr.resolve(e),d)}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}}};mde.exports=U2});var xde=B((QCt,W2)=>{"use strict";var H2=require("fs"),Wr=require("path"),{promisify:j2}=require("util"),Qy;try{Qy=require("fsevents")}catch(t){process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR&&console.error(t)}if(Qy){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&&(Qy=void 0)}}var{EV_ADD:F2,EV_CHANGE:tVe,EV_ADD_DIR:yde,EV_UNLINK:QR,EV_ERROR:nVe,STR_DATA:rVe,STR_END:iVe,FSEVENT_CREATED:sVe,FSEVENT_MODIFIED:oVe,FSEVENT_DELETED:aVe,FSEVENT_MOVED:cVe,FSEVENT_UNKNOWN:lVe,FSEVENT_FLAG_MUST_SCAN_SUBDIRS:uVe,FSEVENT_TYPE_FILE:dVe,FSEVENT_TYPE_DIRECTORY:uw,FSEVENT_TYPE_SYMLINK:Sde,ROOT_GLOBSTAR:_de,DIR_SUFFIX:fVe,DOT_SLASH:vde,FUNCTION_TYPE:B2,EMPTY_FN:pVe,IDENTITY_FN:hVe}=zR(),mVe=t=>isNaN(t)?{}:{depth:t},$2=j2(H2.stat),gVe=j2(H2.lstat),Ede=j2(H2.realpath),yVe={stat:$2,lstat:gVe},Ph=new Map,_Ve=10,vVe=new Set([69888,70400,71424,72704,73472,131328,131840,262912]),EVe=(t,e)=>({stop:Qy.watch(t,e)});function wVe(t,e,n,r){let i=Wr.extname(e)?Wr.dirname(e):e,s=Wr.dirname(i),o=Ph.get(i);SVe(s)&&(i=s);let a=Wr.resolve(t),c=a!==e,l=(d,f,m)=>{c&&(d=d.replace(e,a)),(d===a||!d.indexOf(a+Wr.sep))&&n(d,f,m)},u=!1;for(let d of Ph.keys())if(e.indexOf(Wr.resolve(d)+Wr.sep)===0){i=d,o=Ph.get(i),u=!0;break}return o||u?o.listeners.add(l):(o={listeners:new Set([l]),rawEmitter:r,watcher:EVe(i,(d,f)=>{if(!o.listeners.size||f&uVe)return;let m=Qy.getInfo(d,f);o.listeners.forEach(g=>{g(d,f,m)}),o.rawEmitter(m.event,d,m)})},Ph.set(i,o)),()=>{let d=o.listeners;if(d.delete(l),!d.size&&(Ph.delete(i),o.watcher))return o.watcher.stop().then(()=>{o.rawEmitter=o.watcher=void 0,Object.freeze(o)})}}var SVe=t=>{let e=0;for(let n of Ph.keys())if(n.indexOf(t)===0&&(e++,e>=_Ve))return!0;return!1},xVe=()=>Qy&&Ph.size<128,q2=(t,e)=>{let n=0;for(;!t.indexOf(e)&&(t=Wr.dirname(t))!==e;)n++;return n},wde=(t,e)=>t.type===uw&&e.isDirectory()||t.type===Sde&&e.isSymbolicLink()||t.type===dVe&&e.isFile(),G2=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+_de),!0;r.delete(e),r.delete(e+_de)}addOrChange(e,n,r,i,s,o,a,c){let l=s.has(o)?tVe:F2;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 $2(e);if(this.fsw.closed)return;wde(a,l)?this.addOrChange(e,n,r,i,s,o,a,c):this.handleEvent(QR,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(QR,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===QR){let u=c.type===uw;(u||o.has(a))&&this.fsw._remove(s,a,u)}else{if(e===F2){if(c.type===uw&&this.fsw._getWatchedDir(n),c.type===Sde&&l.followSymlinks){let d=l.depth===void 0?void 0:q2(r,i)+1;return this._addToFsEvents(n,!1,!0,d)}this.fsw._getWatchedDir(s).add(a)}let u=c.type===uw?e+fVe:e;this.fsw._emit(u,n),u===yde&&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=wVe(e,n,async(c,l,u)=>{if(this.fsw.closed||s.depth!==void 0&&q2(c,n)>s.depth)return;let d=r(Wr.join(e,Wr.relative(e,c)));if(i&&!i(d))return;let f=Wr.dirname(d),m=Wr.basename(d),g=this.fsw._getWatchedDir(u.type===uw?d:f);if(vVe.has(l)||u.event===lVe)if(typeof s.ignored===B2){let y;try{y=await $2(d)}catch{}if(this.fsw.closed||this.checkIgnored(d,y))return;wde(u,y)?this.addOrChange(d,c,n,f,g,m,u,s):this.handleEvent(QR,d,c,n,f,g,m,u,s)}else this.checkExists(d,c,n,f,g,m,u,s);else switch(u.event){case sVe:case oVe:return this.addOrChange(d,c,n,f,g,m,u,s);case aVe:case cVe:return this.checkExists(d,c,n,f,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 Ede(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!==vde?a=o.replace(s,e):o!==vde&&(a=Wr.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(Wr.dirname(o)),l=Wr.basename(o);a&&this.fsw._getWatchedDir(o),!c.has(l)&&(c.add(l),(!i.ignoreInitial||s===!0)&&this.fsw._emit(a?yde:F2,o,n))}initWatch(e,n,r,i){if(this.fsw.closed)return;let s=this._watchWithFsEvents(r.watchPath,Wr.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===B2?n:hVe,a=this.fsw._getWatchHelpers(e);try{let c=await yVe[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),...mVe(s.depth-(i||0))}).on(rVe,l=>{if(this.fsw.closed||l.stats.isDirectory()&&!a.filterPath(l))return;let u=Wr.join(a.watchPath,l.path),{fullPath:d}=l;if(a.followSymlinks&&l.stats.isSymbolicLink()){let f=s.depth===void 0?void 0:q2(u,Wr.resolve(a.watchPath))+1;this._handleFsEventsSymlink(u,d,o,f)}else this.emitAdd(u,l.stats,o,s,r)}).on(nVe,pVe).on(iVe,()=>{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===B2)this.initWatch(void 0,e,a,o);else{let c;try{c=await Ede(a.watchPath)}catch{}this.initWatch(c,e,a,o)}}};W2.exports=G2;W2.exports.canUse=xVe});var Nde=B(o$=>{"use strict";var{EventEmitter:bVe}=require("events"),i$=require("fs"),pn=require("path"),{promisify:kde}=require("util"),TVe=uue(),J2=yue().default,AVe=xue(),V2=T2(),CVe=sde(),RVe=Yy(),IVe=gde(),bde=xde(),{EV_ALL:z2,EV_READY:kVe,EV_ADD:ZR,EV_CHANGE:dw,EV_UNLINK:Tde,EV_ADD_DIR:PVe,EV_UNLINK_DIR:OVe,EV_RAW:MVe,EV_ERROR:K2,STR_CLOSE:NVe,STR_END:DVe,BACK_SLASH_RE:LVe,DOUBLE_SLASH_RE:Ade,SLASH_OR_BACK_SLASH_RE:UVe,DOT_RE:FVe,REPLACER_RE:BVe,SLASH:Y2,SLASH_SLASH:qVe,BRACE_START:$Ve,BANG:Q2,ONE_DOT:Pde,TWO_DOTS:GVe,GLOBSTAR:HVe,SLASH_GLOBSTAR:X2,ANYMATCH_OPTS:Z2,STRING_TYPE:s$,FUNCTION_TYPE:jVe,EMPTY_STR:e$,EMPTY_FN:WVe,isWindows:VVe,isMacos:zVe,isIBMi:KVe}=zR(),YVe=kde(i$.stat),XVe=kde(i$.readdir),t$=(t=[])=>Array.isArray(t)?t:[t],Ode=(t,e=[])=>(t.forEach(n=>{Array.isArray(n)?Ode(n,e):e.push(n)}),e),Cde=t=>{let e=Ode(t$(t));if(!e.every(n=>typeof n===s$))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(Mde)},Rde=t=>{let e=t.replace(LVe,Y2),n=!1;for(e.startsWith(qVe)&&(n=!0);e.match(Ade);)e=e.replace(Ade,Y2);return n&&(e=Y2+e),e},Mde=t=>Rde(pn.normalize(Rde(t))),Ide=(t=e$)=>e=>typeof e!==s$?e:Mde(pn.isAbsolute(e)?e:pn.join(t,e)),JVe=(t,e)=>pn.isAbsolute(t)?t:t.startsWith(Q2)?Q2+pn.join(e,t.slice(1)):pn.join(e,t),Ga=(t,e)=>t[e]===void 0,n$=class{constructor(e,n){this.path=e,this._removeWatcher=n,this.items=new Set}add(e){let{items:n}=this;n&&e!==Pde&&e!==GVe&&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 XVe(r)}catch{this._removeWatcher&&this._removeWatcher(pn.dirname(r),pn.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)}},QVe="stat",ZVe="lstat",r$=class{constructor(e,n,r,i){this.fsw=i,this.path=e=e.replace(BVe,e$),this.watchPath=n,this.fullWatchPath=pn.resolve(n),this.hasGlob=n!==e,e===e$&&(this.hasGlob=!1),this.globSymlink=this.hasGlob&&r?void 0:!1,this.globFilter=this.hasGlob?J2(e,void 0,Z2):!1,this.dirParts=this.getDirParts(e),this.dirParts.forEach(s=>{s.length>1&&s.pop()}),this.followSymlinks=r,this.statMethod=r?QVe:ZVe}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 pn.join(this.watchPath,pn.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===jVe?this.globFilter(r):!0)&&this.fsw._isntIgnored(r,n)&&this.fsw._hasReadPermissions(n)}getDirParts(e){if(!this.hasGlob)return[];let n=[];return(e.includes($Ve)?CVe.expand(e):[e]).forEach(i=>{n.push(pn.relative(this.watchPath,i).split(UVe))}),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===HVe&&(r=!0),r||!n[0][o]||J2(s,n[0][o],Z2))))}return!this.unmatchedGlob&&this.fsw._isntIgnored(this.entryPath(e),e.stats)}},eI=class extends bVe{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,Ga(n,"persistent")&&(n.persistent=!0),Ga(n,"ignoreInitial")&&(n.ignoreInitial=!1),Ga(n,"ignorePermissionErrors")&&(n.ignorePermissionErrors=!1),Ga(n,"interval")&&(n.interval=100),Ga(n,"binaryInterval")&&(n.binaryInterval=300),Ga(n,"disableGlobbing")&&(n.disableGlobbing=!1),n.enableBinaryInterval=n.binaryInterval!==n.interval,Ga(n,"useFsEvents")&&(n.useFsEvents=!n.usePolling),bde.canUse()||(n.useFsEvents=!1),Ga(n,"usePolling")&&!n.useFsEvents&&(n.usePolling=zVe),KVe&&(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)),Ga(n,"atomic")&&(n.atomic=!n.usePolling&&!n.useFsEvents),n.atomic&&(this._pendingUnlinks=new Map),Ga(n,"followSymlinks")&&(n.followSymlinks=!0),Ga(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=t$(n.ignored));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=WVe,this._readyEmitted=!0,process.nextTick(()=>this.emit(kVe)))},this._emitRaw=(...c)=>this.emit(MVe,...c),this._readyEmitted=!1,this.options=n,n.useFsEvents?this._fsEventsHandler=new bde(this):this._nodeFsHandler=new IVe(this),Object.freeze(n)}add(e,n,r){let{cwd:i,disableGlobbing:s}=this.options;this.closed=!1;let o=Cde(e);return i&&(o=o.map(a=>{let c=JVe(a,i);return s||!V2(a)?c:RVe(c)})),o=o.filter(a=>a.startsWith(Q2)?(this._ignoredPaths.add(a.slice(1)),!1):(this._ignoredPaths.delete(a),this._ignoredPaths.delete(a+X2),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(pn.dirname(c),pn.basename(n||c))})})),this}unwatch(e){if(this.closed)return this;let n=Cde(e),{cwd:r}=this.options;return n.forEach(i=>{!pn.isAbsolute(i)&&!this._closers.has(i)&&(r&&(i=pn.join(r,i)),i=pn.resolve(i)),this._closePath(i),this._ignoredPaths.add(i),this._watched.has(i)&&this._ignoredPaths.add(i+X2),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?pn.relative(this.options.cwd,r):r;e[i||Pde]=n.getChildren().sort()}),e}emitWithAll(e,n){this.emit(...n),e!==K2&&this.emit(z2,...n)}async _emit(e,n,r,i,s){if(this.closed)return;let o=this.options;VVe&&(n=pn.normalize(n)),o.cwd&&(n=pn.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===Tde)return this._pendingUnlinks.set(n,a),setTimeout(()=>{this._pendingUnlinks.forEach((u,d)=>{this.emit(...u),this.emit(z2,...u),this._pendingUnlinks.delete(d)})},typeof o.atomic=="number"?o.atomic:100),this;e===ZR&&this._pendingUnlinks.has(n)&&(e=a[0]=dw,this._pendingUnlinks.delete(n))}if(c&&(e===ZR||e===dw)&&this._readyEmitted){let u=(d,f)=>{d?(e=a[0]=K2,a[1]=d,this.emitWithAll(e,a)):f&&(a.length>2?a[2]=f:a.push(f),this.emitWithAll(e,a))};return this._awaitWriteFinish(n,c.stabilityThreshold,e,u),this}if(e===dw&&!this._throttle(dw,n,50))return this;if(o.alwaysStat&&r===void 0&&(e===ZR||e===PVe||e===dw)){let u=o.cwd?pn.join(o.cwd,n):n,d;try{d=await YVe(u)}catch{}if(!d||this.closed)return;a.push(d)}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(K2,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&&!pn.isAbsolute(e)&&(o=pn.join(this.options.cwd,e));let a=new Date,c=l=>{i$.stat(o,(u,d)=>{if(u||!this._pendingWrites.has(e)){u&&u.code!=="ENOENT"&&i(u);return}let f=Number(new Date);l&&d.size!==l.size&&(this._pendingWrites.get(e).lastChange=f);let m=this._pendingWrites.get(e);f-m.lastChange>=n?(this._pendingWrites.delete(e),i(void 0,d)):s=setTimeout(c,this.options.awaitWriteFinish.pollInterval,d)})};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&&FVe.test(e))return!0;if(!this._userIgnored){let{cwd:r}=this.options,i=this.options.ignored,s=i&&i.map(Ide(r)),o=t$(s).filter(c=>typeof c===s$&&!V2(c)).map(c=>c+X2),a=this._getGlobIgnored().map(Ide(r)).concat(s,o);this._userIgnored=J2(a,void 0,Z2)}return this._userIgnored([e,n])}_isntIgnored(e,n){return!this._isIgnored(e,n)}_getWatchHelpers(e,n){let r=n||this.options.disableGlobbing||!V2(e)?e:AVe(e),i=this.options.followSymlinks;return new r$(e,r,i,this)}_getWatchedDir(e){this._boundRemove||(this._boundRemove=this._remove.bind(this));let n=pn.resolve(e);return this._watched.has(n)||this._watched.set(n,new n$(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=pn.join(e,n),s=pn.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(f=>this._remove(i,f));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=pn.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===ZR)return;this._watched.delete(i),this._watched.delete(s);let d=r?OVe:Tde;l&&!this._isIgnored(i)&&this._emit(d,i),this.options.useFsEvents||this._closePath(i)}_closePath(e){this._closeFile(e);let n=pn.dirname(e);this._getWatchedDir(n).remove(pn.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:z2,alwaysStat:!0,lstat:!0,...n},i=TVe(e,r);return this._streams.add(i),i.once(NVe,()=>{i=void 0}),i.once(DVe,()=>{i&&(this._streams.delete(i),i=void 0)}),i}};o$.FSWatcher=eI;var eze=(t,e)=>{let n=new eI(e);return n.add(t),n};o$.watch=eze});function qde(t){return AB.includes(t)}function e_(t){return RC.includes(Gs.default.extname(t).toLowerCase())}function lze(t,e){return t.isDirectory()?"folder":e_(e)?"binary":"file"}function nf(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}function uze(t){if(!a$.has(t)){let e=process.platform==="win32"?"where":"which";a$.set(t,(0,vu.spawnSync)(e,[t],{stdio:"ignore"}).status===0)}return a$.get(t)}function dze(t){let e=pse.find(r=>uze(r.cmd));if(!e)throw new Error("HEIC needs a system converter (macOS has sips; on Linux install libheif-examples or imagemagick)");let n=Gs.default.join(Ha.default.tmpdir(),`9r-heic-${process.pid}-${Date.now()}.jpg`);try{let r=(0,vu.spawnSync)(e.cmd,e.args(t,n),{timeout:hse});if(r.status!==0||!it.default.existsSync(n))throw new Error(`HEIC decode failed (${e.cmd}): ${r.stderr?.toString().trim()||"unknown error"}`);return it.default.readFileSync(n)}finally{try{it.default.unlinkSync(n)}catch{}}}async function t_(t,e){let n=IC(e)?dze(e):t,r=await(0,tI.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,d=o;for(let f of c)for(let m of a){l=await(0,tI.default)(n).rotate().resize({width:f,height:f,fit:"inside",withoutEnlargement:!0}).jpeg({quality:m,mozjpeg:!0}).toBuffer();let g=await(0,tI.default)(l).metadata();if(u=g.width||f,d=g.height||f,l.length<=3145728)return{buffer:l,width:u,height:d,originalWidth:s,originalHeight:o}}return{buffer:l,width:u,height:d,originalWidth:s,originalHeight:o}}function $de(t,e,n,r=50){if(!(n.length>=r))try{for(let i of it.default.readdirSync(t)){if(n.length>=r)return;if(i.startsWith(".")||qde(i))continue;let s=Gs.default.join(t,i);try{let o=it.default.statSync(s);o.isDirectory()?$de(s,e,n,r):i.toLowerCase().includes(e.toLowerCase())&&n.push({name:i,path:s,type:e_(i)?"binary":"file",size:o.size,sizeFormatted:nf(o.size)})}catch{}}}catch{}}function Fde(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 Gde(t,e,n,r,i,s){if(s.length>=200)return;let o;try{o=it.default.readdirSync(t,{withFileTypes:!0})}catch{return}for(let a of o){if(s.length>=200)return;if(qde(a.name))continue;let c=Gs.default.join(t,a.name),l=Gs.default.relative(e,c);if(a.isDirectory()){Gde(c,e,n,r,i,s);continue}if(a.isFile()&&!e_(a.name)&&!wt(c)&&!(i&&i.test(l))&&!(r&&!r.test(l)))try{if(it.default.statSync(c).size>1048576)continue;let f=it.default.readFileSync(c,"utf-8").split(`
|
|
414
414
|
`),m=[];for(let g=0;g<f.length&&m.length<10;g++){let y=f[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 Hde(t,e,n){let r;try{r=it.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=Gs.default.join(t,s.name);if(s.isDirectory()){let a={name:s.name,path:o,type:"folder"};e>0&&(a.children=Hde(o,e-1,n)),i.push(a)}else s.isFile()&&i.push({name:s.name,path:o,type:e_(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 fze(){if(process.platform!=="win32")return[];try{return(0,vu.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=>it.default.existsSync(t)).map(t=>({letter:t[0],path:t}))}}function jde(t){t.on("getSystemInfo",n=>{let r=process.platform;n({success:!0,platform:r,isWindows:r==="win32",drives:r==="win32"?fze():[],homedir:Ha.default.homedir()})}),t.on("getFiles",({dirPath:n,showHidden:r},i)=>{try{let s=n||Ha.default.homedir(),o=s.startsWith("~")?s.replace("~",Ha.default.homedir()):s;if(wt(o))return i({success:!1,error:"Access denied"});if(!it.default.existsSync(o))return i({success:!1,error:"Directory not found"});let a;try{a=it.default.readdirSync(o,{withFileTypes:!0})}catch(d){return i({success:!1,error:d.message})}r||(a=a.filter(d=>!(d.name.startsWith(".")&&d.name!==".env"&&d.name!==".env.example"))),a.sort((d,f)=>{let m=d.isDirectory(),g=f.isDirectory();return m&&!g?-1:!m&&g?1:d.name.localeCompare(f.name)});let c=a.length>300,l=c?a.slice(0,300):a,u=[];for(let d of l)try{let f=Gs.default.join(o,d.name),m=it.default.statSync(f);u.push({name:d.name,path:f,type:lze(m,d.name),size:m.isFile()?m.size:null,sizeFormatted:m.isFile()?nf(m.size):null,modified:m.mtime.getTime()})}catch{}i({success:!0,files:u,currentPath:o,parentPath:Gs.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||Ha.default.homedir()).replace(/^~/,Ha.default.homedir());if(!it.default.existsSync(s))return i({success:!1,error:"Workspace not found"});let o=[];$de(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(wt(n))return r({success:!1,error:"Access denied"});if(!it.default.existsSync(n))return r({success:!1,error:"File not found"});let i=it.default.statSync(n);if(i.size>1048576)return r({success:!1,error:`File too large (${nf(i.size)}). Max ${nf(1048576)}`});if(e_(n))return r({success:!1,error:"Cannot open binary file"});if(i.size>l0)return r({success:!0,content:"",streamInstead:!0,size:i.size});r({success:!0,content:it.default.readFileSync(n,"utf-8")})}catch(i){r({success:!1,error:i.message})}}),t.on("readMedia",async({filePath:n},r)=>{try{if(wt(n))return r({success:!1,error:"Access denied"});if(!it.default.existsSync(n))return r({success:!1,error:"File not found"});let i=it.default.statSync(n),s=Gs.default.extname(n).toLowerCase().slice(1),o=ph[s]||"application/octet-stream",a=o.startsWith("image/"),c=a?20971520:5242880;if(i.size>c)return r({success:!1,error:`File too large (${nf(i.size)}). Max ${nf(c)}`});let l=it.default.readFileSync(n);if(a){let u=await t_(l,n),d=`data:image/jpeg;base64,${u.buffer.toString("base64")}`;r({success:!0,dataUrl:d,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(wt(n))return r({success:!1,error:"Access denied"});if(!it.default.existsSync(n))return r({success:!1,error:"File not found"});let i=it.default.statSync(n);if(i.size>20971520)return r({success:!1,error:`Image too large (${nf(i.size)}). Max ${nf(20971520)}`});let s=it.default.readFileSync(n),o=await t_(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(wt(n))return i({success:!1,error:"Access denied"});it.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(wt(n))return i({success:!1,error:"Access denied"});if(it.default.existsSync(n))return i({success:!1,error:"Item already exists"});r==="folder"?it.default.mkdirSync(n,{recursive:!0}):it.default.writeFileSync(n,"","utf-8"),i({success:!0})}catch(s){i({success:!1,error:s.message})}}),t.on("deleteItem",({itemPath:n},r)=>{try{if(wt(n))return r({success:!1,error:"Access denied"});if(!it.default.existsSync(n))return r({success:!1,error:"Item not found"});it.default.statSync(n).isDirectory()?it.default.rmSync(n,{recursive:!0}):it.default.unlinkSync(n),r({success:!0})}catch(i){r({success:!1,error:i.message})}}),t.on("copyItem",({srcPath:n,destPath:r},i)=>{try{if(wt(n)||wt(r))return i({success:!1,error:"Access denied"});if(!it.default.existsSync(n))return i({success:!1,error:"Item not found"});if(it.default.existsSync(r))return i({success:!1,error:"Target already exists"});if(r.startsWith(n+"/"))return i({success:!1,error:"Cannot copy into itself"});it.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(wt(n)||wt(r))return i({success:!1,error:"Access denied"});if(!it.default.existsSync(n))return i({success:!1,error:"Item not found"});if(it.default.existsSync(r))return i({success:!1,error:"Target already exists"});it.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||Ha.default.homedir()).replace(/^~/,Ha.default.homedir());if(!it.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 d=Fde(o),f=Fde(a),m=[];Gde(l,l,u,d,f,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 f;try{f=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(f,w=>(g++,i)),count:g}}}else l=f=>{let m=0,g=s?"g":"gi",y=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),w=new RegExp(y,g);return{next:f.replace(w,()=>(m++,i)),count:m}};let u=0,d=0;for(let f of a)try{if(!it.default.existsSync(f)||e_(f)||wt(f))continue;let m=it.default.statSync(f);if(!m.isFile()||m.size>1048576)continue;let g=it.default.readFileSync(f,"utf-8"),{next:y,count:w}=l(g);w>0&&(it.default.writeFileSync(f,y,"utf-8"),u+=w,d++)}catch{}c({success:!0,replacedCount:u,fileCount:d})}catch(l){c({success:!1,error:l.message})}});let e=new Map;t.on("watchDir",({dirPath:n},r)=>{try{if(!n||!it.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=Bde.default.watch(n,{depth:0,ignoreInitial:!0,persistent:!0,ignored:c=>AB.includes(Gs.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=[Gs.default.dirname(n)]);let a=(0,vu.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||!it.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,vu.spawn)(s,o,a);c.on("error",()=>{if(i==="linux"){let l=(0,vu.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||Ha.default.homedir()).replace(/^~/,Ha.default.homedir());if(!it.default.existsSync(o))return s({success:!1,error:"Directory not found"});let c=Hde(o,typeof r=="number"?r:3,!!i);s({success:!0,tree:{name:Gs.default.basename(o)||o,path:o,type:"folder",children:c}})}catch(o){s({success:!1,error:o.message})}})}var it,Gs,Ha,vu,Bde,tI,a$,nI=ae(()=>{it=ce(require("fs"),1),Gs=ce(require("path"),1),Ha=ce(require("os"),1),vu=require("child_process"),Bde=ce(Nde(),1),tI=ce(require("sharp"),1);Ty();Xi();mh();a$=new Map});function mze(t,{maxDepth:e=rI.maxDepth,timeoutMs:n=rI.timeoutMs,now:r=()=>Date.now(),io:i=c$.default}={}){if(!t)return[];let s=Yc.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(hze(l,i)&&a.push({path:l,relPath:l===s?"":Yc.default.relative(s,l),depth:u}),u>=e)continue;let d;try{d=i.readdirSync(l,{withFileTypes:!0})}catch{continue}for(let f of d)!f.isDirectory()||f.isSymbolicLink()||pze.has(f.name)||c.push({dir:Yc.default.join(l,f.name),depth:u+1})}return a}function l$(t,e={}){let n=e.now||(()=>Date.now()),r=e.cacheTtlMs??rI.cacheTtlMs,i=gze(t,e.maxDepth),s=fw.get(i);if(s&&n()-s.ts<r)return s.repos;let o=mze(t,e);return fw.set(i,{ts:n(),repos:o}),o}function iI(t){if(!t)return fw.clear();let e=`${Yc.default.resolve(t)}::`;for(let n of fw.keys())n.startsWith(e)&&fw.delete(n)}function u$(t=""){let e=[],n=null;for(let r of t.split(`
|
|
415
415
|
`)){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 Wde(t="",e=[]){let n=new Set(e.map(s=>s.branch).filter(Boolean)),r=new Set,i=[];for(let s of t.split(`
|
|
@@ -529,9 +529,9 @@ https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};var L3
|
|
|
529
529
|
`:". ";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"}};OV=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(d){try{for(;;){let f=fht(o,a,c);if(!f){c=Math.max(0,a-dht+1);let y=await s.read();if(y.done)return d.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,f.index);if(o.copyWithin(0,f.index+f.length,a),a-=f.index+f.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=pht(m,n,l,u);if(g&&!g.done)return d.enqueue(g.value);if(g?.done)return await s.cancel("done"),d.close()}}catch(f){d.error(f),await s.cancel(f)}},cancel:d=>s.cancel(d)})}[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)}},Zo=13,ea=10,NTe=[[Zo,ea,Zo,ea],[Zo,ea,Zo],[Zo,ea,ea],[Zo,Zo,ea],[ea,Zo,ea],[Zo,Zo],[ea,Zo],[ea,ea]],dht=NTe.reduce((t,e)=>Math.max(t,e.length),0);hht={jsonl:"application/jsonl",json:"application/json",text:"text/plain",bytes:"application/octet-stream",stream:"application/octet-stream",sse:"text/event-stream",nil:"*",fail:"*"};mht=/, */;Rbe={Incomplete:"incomplete",UnrecognisedSecurityType:"unrecognized_security_type"},MV=class t extends Error{constructor(e,n){super(n),this.code=e,this.name="SecurityError"}static incomplete(){return new t(Rbe.Incomplete,"Security requirements not met in order to perform the operation")}static unrecognizedType(e){return new t(Rbe.UnrecognisedSecurityType,`Unrecognised security type: ${e}`)}};At=class t{constructor(e,n){this[UTe]="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)}};UTe=Symbol.toStringTag;NV=class extends rc{list(e,n){return qt($Te(this,e?.api_version,e?.page_size,e?.page_token,e?.parent,n))}create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return qt(FTe(this,i,r,n))}delete(e,n,r){return qt(BTe(this,e,n?.api_version,r))}get(e,n,r){return qt(qTe(this,e,n?.api_version,r))}};DV=class extends rc{list(e,n){return qt(WTe(this,e?.api_version,e?.page_size,e?.page_token,n))}create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return qt(GTe(this,i,r,n))}delete(e,n,r){return qt(HTe(this,e,n?.api_version,r))}get(e,n,r){return qt(jTe(this,e,n?.api_version,r))}update(e,n,r){let{api_version:i,update_mask:s}=n,o=Tr(n,["api_version","update_mask"]);return qt(VTe(this,e,o,i,s,r))}};LV=class extends rc{list(e,n,r,i){return qt(JTe(this,e,n,r?.api_version,r?.page_size,r?.page_token,r?.recursive,i))}};UV=class extends rc{startUpload(e,n,r,i){return qt(QTe(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))}};FV=class extends rc{get internal(){var e;return(e=this._internal)!==null&&e!==void 0?e:this._internal=new UV(this._options)}get files(){var e;return(e=this._files)!==null&&e!==void 0?e:this._files=new LV(this._options)}listEnvironments(e,n){return qt(XTe(this,e?.api_version,e?.page_size,e?.page_token,n))}createEnvironment(e,n,r){return qt(zTe(this,e,n,r))}deleteEnvironment(e,n,r){return qt(KTe(this,e,n?.api_version,r))}getEnvironment(e,n,r){return qt(YTe(this,e,n?.api_version,r))}};BV=class extends ta{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"}},qV=class extends ta{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"}};$V=class extends ta{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"}},GV=class extends ta{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"}};HV=class extends ta{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"}},jV=class extends ta{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"}};WV=class extends ta{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"}},VV=class extends ta{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"}};zV=class extends rc{create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return qt(eAe(this,i,r,n))}delete(e,n,r){return qt(Lht(this,e,n?.api_version,r))}get(e,n,r){return qt(tAe(this,e,n?.api_version,n?.include_input,n?.last_event_id,n?.stream,r))}cancel(e,n,r){return qt(ZTe(this,e,n?.api_version,r))}};KV=class extends rc{list(e,n){return qt(oAe(this,e?.api_version,e?.filter,e?.page_size,e?.page_token,n))}create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return qt(nAe(this,i,r,n))}delete(e,n,r){return qt(rAe(this,e,n?.api_version,r))}get(e,n,r){return qt(iAe(this,e,n?.api_version,r))}update(e,n,r){let{api_version:i}=n,s=Tr(n,["api_version"]);return qt(cAe(this,e,s,i,r))}listExecutions(e,n,r){return qt(sAe(this,e,n?.api_version,n?.page_size,n?.page_token,r))}run(e,n,r){return qt(aAe(this,e,n?.api_version,r))}};YV=class extends rc{list(e,n){return qt(fAe(this,e?.api_version,e?.page_size,e?.page_token,n))}create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return qt(lAe(this,i,r,n))}delete(e,n,r){return qt(uAe(this,e,n?.api_version,r))}get(e,n,r){return qt(dAe(this,e,n?.api_version,r))}update(e,n,r){let i=n??{},{api_version:s,update_mask:o}=i,a=Tr(i,["api_version","update_mask"]),c=n===void 0||Object.keys(a).length===0?void 0:a;return qt(mAe(this,e,s,o,c,r))}ping(e,n,r,i){return qt(pAe(this,e,n,r,i))}rotateSigningSecret(e,n,r,i){return qt(hAe(this,e,n,r,i))}};Zht=class extends rc{get environments(){var e;return(e=this._environments)!==null&&e!==void 0?e:this._environments=new FV(this._options)}get agents(){var e;return(e=this._agents)!==null&&e!==void 0?e:this._agents=new NV(this._options)}get credentials(){var e;return(e=this._credentials)!==null&&e!==void 0?e:this._credentials=new DV(this._options)}get interactions(){var e;return(e=this._interactions)!==null&&e!==void 0?e:this._interactions=new zV(this._options)}get triggers(){var e;return(e=this._triggers)!==null&&e!==void 0?e:this._triggers=new KV(this._options)}get webhooks(){var e;return(e=this._webhooks)!==null&&e!==void 0?e:this._webhooks=new YV(this._options)}};emt=new Set(["lyria-3-pro-preview","lyria-3-clip-preview"]);XV=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);if(i.stream===!0){let o=await dW(()=>this.getClient(r).interactions.create(Object.assign(Object.assign({},i),{stream:!0,api_version:r}),It(n,!0)));return kbe(o)}let s=await en(eAe(this.getClient(r),i,r,It(n)));return fW(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 dW(()=>this.getClient(i).interactions.get(e,{stream:s,last_event_id:o,include_input:a,api_version:i},It(r,!0)));return kbe(l)}let c=await en(tAe(this.getClient(i),e,i,a,o,s,It(r)));return fW(c)}async delete(e,n={},r){return dW(()=>this.getClient(n?.api_version).interactions.delete(e,{api_version:n?.api_version},It(r)))}async cancel(e,n={},r){return fW(await en(ZTe(this.getClient(n?.api_version),e,n?.api_version,It(r))))}getClient(e){var n;return e?na(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=na(this.parentClient)),this.sdk)}},JV=class{constructor(e){this.parentClient=e}async create(e={},n){let r=e??{},{api_version:i}=r,s=Tr(r,["api_version"]);return en(FTe(this.getClient(i),s,i,It(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s,parent:o}=e??{};return en($Te(this.getClient(r),r,i,s,o,It(n)))}async get(e,n={},r){return en(qTe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}async delete(e,n={},r){return en(BTe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}getClient(e){var n;return e?na(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=na(this.parentClient)),this.sdk)}},QV=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return en(lAe(this.getClient(),i,r,It(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s}=e??{};return en(fAe(this.getClient(),r,i,s,It(n)))}async get(e,n={},r){return en(dAe(this.getClient(),e,n?.api_version,It(r)))}async update(e,n={},r){let i=n??{},{api_version:s,update_mask:o}=i,a=Tr(i,["api_version","update_mask"]);return en(mAe(this.getClient(),e,s,o,a,It(r)))}async delete(e,n={},r){return en(uAe(this.getClient(),e,n?.api_version,It(r)))}async rotateSigningSecret(e,n={},r){let i=n??{},{api_version:s}=i,o=Tr(i,["api_version"]);return en(hAe(this.getClient(),e,s,o,It(r)))}async ping(e,n=void 0,r){let{api_version:i,body:s}=n??{};return en(pAe(this.getClient(),e,i,s,It(r)))}getClient(){var e;return(e=this.sdk)!==null&&e!==void 0||(this.sdk=na(this.parentClient)),this.sdk}},ZV=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return en(nAe(this.getClient(r),i,r,It(n)))}async list(e={},n){let{api_version:r,filter:i,page_size:s,page_token:o}=e??{};return en(oAe(this.getClient(r),r,i,s,o,It(n)))}async get(e,n={},r){return en(iAe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}async update(e,n,r){let{api_version:i}=n,s=Tr(n,["api_version"]);return en(cAe(this.getClient(i),e,s,i,It(r)))}async delete(e,n={},r){return en(rAe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}async run(e,n={},r){return en(aAe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}async listExecutions(e,n={},r){let{api_version:i,page_size:s,page_token:o}=n??{};return en(sAe(this.getClient(i),e,i,s,o,It(r)))}getClient(e){var n;return e?na(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=na(this.parentClient)),this.sdk)}};ez=class{constructor(e,n){this.resolveClient=e,this.parentClient=n}async list(e,n){return en(JTe(this.resolveClient(e.api_version),e.environment,e.path,e.api_version,e.page_size,e.page_token,e.recursive,It(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 d=await u.responseInternal.arrayBuffer();return new Uint8Array(d)}throw new Error("Unexpected response type from download")}async upload(e,n){var r,i,s,o,a,c,l,u;let d=e.environment;if(!d)throw new Error("environment is required.");d.startsWith("environments/")||`${d}`;let f=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=umt(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=d.startsWith("environments/")?d.replace(/^environments\//,""):d,[T,R]=await QTe(this.resolveClient(e.api_version),S,f,"start",y,w,"resumable",e.api_version,e.extract,e.overwrite,It(n)).$inspect();if(!T.ok)throw mm(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,$=0,G,V=g instanceof Blob?g:new Blob([g]);for(;$<y||y===0&&$===0;){let k=Math.min($+D,y),E=V.slice($,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":`${$}`})})}),$=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}},tz=class{constructor(e){this.parentClient=e,this.files=new ez(n=>this.getClient(n),this.parentClient)}async create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return en(zTe(this.getClient(r),i,r,It(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s}=e??{};return en(XTe(this.getClient(r),r,i,s,It(n)))}async get(e,n={},r){return en(YTe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}async delete(e,n={},r){return en(KTe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}getClient(e){var n;return e?na(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=na(this.parentClient)),this.sdk)}},nz=class{constructor(e){this.parentClient=e}async create(e,n){let{api_version:r}=e,i=Tr(e,["api_version"]);return en(GTe(this.getClient(r),i,r,It(n)))}async list(e={},n){let{api_version:r,page_size:i,page_token:s}=e??{};return en(WTe(this.getClient(r),r,i,s,It(n)))}async get(e,n={},r){return en(jTe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}async update(e,n,r){let{api_version:i,update_mask:s}=n,o=Tr(n,["api_version","update_mask"]);return en(VTe(this.getClient(i),e,o,i,s,It(r)))}async delete(e,n={},r){return en(HTe(this.getClient(n?.api_version),e,n?.api_version,It(r)))}getClient(e){var n;return e?na(this.parentClient,{api_version:e}):((n=this.sdk)!==null&&n!==void 0||(this.sdk=na(this.parentClient)),this.sdk)}};Obe="x-goog-api-key",BS="https://www.googleapis.com/auth/cloud-platform",rz=class{constructor(e){if(e.apiKey!==void 0){this.apiKey=e.apiKey;return}let n=dmt(e.googleAuthOptions);this.googleAuth=new Dbe.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(Obe)===null){if(this.apiKey===void 0)throw new Error("Trying to set API key header but apiKey is not set");e.append(Obe,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)}};iz=class{async download(e,n){if(e.downloadPath){let r=await fmt(e,n);if(r instanceof ju){let i=(0,Lbe.createWriteStream)(e.downloadPath);Fbe.Readable.fromWeb(r.responseInternal.body).pipe(i),await(0,Bbe.finished)(i)}else try{await(0,Ube.writeFile)(e.downloadPath,r,{encoding:"base64"})}catch(i){throw new Error(`Failed to write file to ${e.downloadPath}: ${i}`)}}}};sz=class{create(e,n,r){return new oz(e,n,r)}},oz=class{constructor(e,n,r){this.url=e,this.headers=n,this.callbacks=r}connect(){this.ws=new lW.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()}};lz=class extends nc{constructor(e){super(),this.apiClient=e,this.list=async(n={})=>new fl(dl.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:pO.JOB_STATE_QUEUED}}}}async getInternal(e){var n,r,i,s;let o,a="",c={};if(this.apiClient.isVertexAI()){let l=Tmt(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(d=>{let f=d;return f.sdkHttpResponse={headers:u.headers},f})),o.then(u=>cz(u))}else{let l=bmt(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(d=>{let f=d;return f.sdkHttpResponse={headers:u.headers},f})),o.then(u=>Nmt(u))}}async listInternal(e){var n,r;let i,s="",o={};if(this.apiClient.isVertexAI()){let a=Cmt(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=Rmt(c),u=new wO;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=hmt(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(d=>{let f=d;return f.sdkHttpResponse={headers:u.headers},f})),o.then(u=>{let d=gmt(u),f=new KS;return Object.assign(f,d),f})}else{let l=pmt(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(d=>{let f=d;return f.sdkHttpResponse={headers:u.headers},f})),o.then(u=>{let d=mmt(u),f=new KS;return Object.assign(f,d),f})}}async tuneInternal(e){var n,r;let i,s="",o={};if(this.apiClient.isVertexAI()){let a=Emt(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=>cz(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=vmt(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=>Dmt(c))}}async validateReward(e){var n,r;let i,s="",o={};if(this.apiClient.isVertexAI()){let a=Lmt(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=Umt(c),u=new SO;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).")}},yAe=1024*1024*8,_Ae=3,vAe=1e3,EAe=2,Bf="x-goog-upload-status";uz=class{async stat(e){let n={size:0,type:void 0};if(typeof e=="string"){let r=await XO.stat(e);return n.size=r.size,n.type=this.inferMimeType(e),n}else return await qmt(e)}async upload(e,n,r,i){return typeof e=="string"?await this.uploadFileFromPath(e,n,r,i):Fmt(e,n,r,i)}async uploadToFileSearchStore(e,n,r,i){return typeof e=="string"?await this.uploadFileToFileSearchStoreFromPath(e,n,r,i):Bmt(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[Bf])!=="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[Bf])!=="final")throw new Error("Failed to upload file: Upload status is not finalized.");let c=hz(a),l=new QS;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,d=0,f=new ju(new Response),m="upload",g,y=qbe.basename(e);try{if(g=await XO.open(e,"r"),!g)throw new Error("Failed to open file");for(u=(await g.stat()).size;d<u;){let w=Math.min(yAe,u-d);d+w>=u&&(m+=", finalize");let S=new Uint8Array(w),{bytesRead:T}=await g.read(S,0,w,d);if(T!==w)throw new Error(`Failed to read ${w} bytes from file at offset ${d}. bytes actually read: ${T}`);let R=new Blob([S]),C=0,D=vAe;for(;C<_Ae;){let $=Object.assign(Object.assign({},i?.headers||{}),{"X-Goog-Upload-Command":m,"X-Goog-Upload-Offset":String(d),"X-Goog-Upload-File-Name":y});if(f=await r.request({path:"",body:R,httpMethod:"POST",httpOptions:Object.assign(Object.assign({},i),{apiVersion:"",baseUrl:c,headers:$})}),!((o=f?.headers)===null||o===void 0)&&o[Bf])break;C++,await SAe(D),D=D*EAe}if(d+=T,((a=f?.headers)===null||a===void 0?void 0:a[Bf])!=="active")break;if(u<=d)throw new Error("All content has been uploaded, but the upload status is not finalized.")}return f}finally{g&&await g.close()}}};dz=class extends sTe{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})})})}};$mt="gl-node/";fz=class{getNextGenClient(){let e=this.httpOptions;return this._nextGenClient===void 0&&(this._nextGenClient=na(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 XV(this.apiClient),this._interactions)}get webhooks(){return this._webhooks!==void 0?this._webhooks:(this._webhooks=new QV(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 JV(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 ZV(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 tz(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 nz(this.apiClient),this._credentials)}constructor(e={}){var n,r,i,s;if(this.vertexai=Gmt(e),(e.project||e.location)&&!this.vertexai)throw new Error("Project and location are not supported for Gemini API backend.");let o=Hmt(),a=qf("GOOGLE_CLOUD_PROJECT"),c=qf("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=wat(e.httpOptions,this.vertexai,qf("GOOGLE_VERTEX_BASE_URL"),qf("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 rz({apiKey:this.apiKey,googleAuthOptions:e.googleAuthOptions});this.apiClient=new hV({auth:u,project:this.project,location:this.location,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:$mt+process.version,uploader:new uz,downloader:new iz}),this.models=new gm(this.apiClient),this.live=new FO(this.apiClient,u,new sz),this.batches=new NO(this.apiClient),this.chats=new LO(this.models,this.apiClient),this.caches=new DO(this.apiClient),this.files=new dz(this.apiClient),this.operations=new qO(this.apiClient),this.authTokens=new $O(this.apiClient),this.tunings=new lz(this.apiClient),this.fileSearchStores=new _V(this.apiClient)}}});function PAe({provider:t,baseUrl:e,apiKey:n,model:r}={}){t&&Wmt.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 OAe(t={}){PAe(t),e1.info(`config \u2190 web: provider=${Nt.provider} baseUrl="${Nt.baseUrl}" model=${Nt.model} key=${Nt.apiKey?Nt.apiKey.slice(0,7)+"\u2026":"(none)"}`),t1.set(CAe,{...Nt}).catch(()=>{})}async function MAe(){if(TAe)return!0;TAe=!0;try{let t=await t1.get(CAe);t&&typeof t=="object"&&PAe(t),e1.info(`config \u2190 kv (restart restore): provider=${Nt.provider} baseUrl="${Nt.baseUrl}" model=${Nt.model} key=${Nt.apiKey?"kept":"(none)"}`)}catch{}return!0}function NAe(){return{...Nt,apiKey:void 0,ready:!!Nt.apiKey,busy:ix}}function Kmt(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 DAe(){if(pl)return pl;try{pl=await t1.get(AAe)||[]}catch{pl=[]}return Array.isArray(pl)||(pl=[]),pl=pl.map(t=>t&&!t.parts&&(t.role==="user"||t.role==="assistant"||t.role==="tool")?t:Kmt(t)).filter(Boolean),pl}async function Ymt(){try{await t1.set(AAe,pl.slice(-RAe))}catch{}}function Sz(){return Bk().map(({name:t,description:e,inputSchema:n})=>({name:t,description:e,parameters:n}))}function Xmt(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 Jmt(t){let{GoogleGenAI:e}=await Promise.resolve().then(()=>(bAe(),xAe)),i=(await new e({...Nt.baseUrl?{httpOptions:{baseUrl:Nt.baseUrl}}:{},apiKey:Nt.apiKey}).models.generateContent({model:Nt.model,contents:Xmt(t),config:{systemInstruction:wz,tools:[{functionDeclarations:Sz()}]}}))?.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 Qmt(t){let e=[{role:"system",content:wz}];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 Zmt(){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:LAe(n.args)}))}}}}async function egt(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:Qmt(t),tools:Sz().map(c=>({type:"function",function:c}))}),signal:AbortSignal.timeout(kAe)});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:LAe(l.function?.arguments)}))}}let i=Zmt(),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(`
|
|
530
530
|
`))>=0;){let d=a.slice(0,u).trim();if(a=a.slice(u+1),!d.startsWith("data:"))continue;let f=d.slice(5).trim();if(f==="[DONE]")return i.result();let m;try{m=JSON.parse(f)}catch{continue}if(m.error)throw new Error(m.error?.message||"stream error");i.push(m.choices?.[0]?.delta)}}return i.result()}function tgt(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 ngt(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:wz,messages:tgt(t),tools:Sz()}),signal:AbortSignal.timeout(kAe)}),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 LAe(t){if(typeof t!="string")return t||{};try{return JSON.parse(t)}catch{return{}}}async function rgt(t,e){let n=Af.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,IAe)}:r}catch(r){return{error:r.message}}}async function xz(t,e){if(ix)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"};ix=!0;try{let n=e||(()=>{}),r=await DAe();r.push({role:"user",text:String(t||"")});let i=zmt||(Nt.provider==="openai"?egt:Nt.provider==="anthropic"?ngt:Jmt);e1.info(`turn: provider=${Nt.provider} baseUrl="${Nt.baseUrl}" model=${Nt.model} history=${r.length}`);let s="";for(let o=0;o<jmt;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 d=await rgt(u.name,u.args),f=JSON.stringify(d).slice(0,IAe);n("toolResult",{name:u.name,result:f}),l.push({callId:u.id,name:u.name,output:d})}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 Ymt(),{text:s}}catch(n){return e1.error(`agent turn failed: ${n.message}`),{error:`${Nt.provider} error: ${n.message}`}}finally{ix=!1}}async function UAe(t){return!Nt.apiKey||ix?{skipped:!0}:await xz(t,()=>{})}async function FAe(){return(await DAe()).slice(-RAe)}var e1,t1,AAe,CAe,RAe,jmt,IAe,kAe,wz,Wmt,Vmt,Nt,ix,pl,zmt,TAe,bz=ae(()=>{mi();qk();tt();e1=xe("jarvis"),t1={get:Fp,set:Up},AAe="jarvis:chat",CAe="jarvis:agentConfig",RAe=60,jmt=8,IAe=4e3,kAe=12e4,wz="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.",Wmt=["gemini","openai","anthropic"],Vmt={provider:"gemini",baseUrl:"",model:"gemini-3.8-flash"},Nt={...Vmt,apiKey:""},ix=!1,pl=null,zmt=null,TAe=!1});function sgt({wake:t=UAe,refreshBoard:e=async()=>{await Fk(await N_())},debounceMs:n=igt,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 $Ae(t){qAe.setWakeEnabled(t)}function Tz(t){qAe.onWorkerDone(t)}function GAe(){BAe||(BAe=!0,Er.onEvent((t,e)=>{e==="turn_complete"&&Tz(t)}))}var igt,qAe,BAe,Az=ae(()=>{Yd();Dk();cS();bz();igt=3e3;qAe=sgt({enabled:!1}),BAe=!1});function jAe(t){ogt&&(GAe(),MAe(),t.on("jarvis:getState",async(e,n)=>{try{let r=await N_(),i=await Fk(r);n?.({ok:!0,board:i,fleet:r})}catch(r){Cz.error(`getState failed: ${r.message}`),n?.({ok:!1,error:r.message})}}),t.on("jarvis:kanban",async({action:e}={},n)=>{try{let r=await D_(e,"web");n?.(r.error?{ok:!1,error:r.error}:{ok:!0,board:r.board})}catch(r){Cz.error(`kanban action failed: ${r.message}`),n?.({ok:!1,error:r.message})}}),t.on("jarvis:tools",(e,n)=>n?.({ok:!0,tools:Bk()})),t.on("jarvis:tool",async({name:e,args:n}={},r)=>{let i=Af.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){Cz.error(`live tool ${e} failed: ${s.message}`),r?.({ok:!1,error:s.message})}}),t.on("jarvis:agentConfig",({apiKey:e,model:n,wake:r}={},i)=>{OAe({apiKey:e,model:n}),r!==void 0&&$Ae(!!r),i?.({ok:!0,...NAe()})}),t.on("jarvis:chatHistory",async(e,n)=>{try{n?.({ok:!0,history:await FAe()})}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"});HAe("jarvis:chat:event",{type:"user",text:e.slice(0,2e3)});let r=await xz(e,(i,s)=>HAe("jarvis:chat:event",{type:i,...s}));n?.(r.error?{ok:!1,error:r.error}:{ok:!0,text:r.text})}))}var Cz,ogt,HAe,WAe=ae(()=>{Dk();cS();Az();bz();qk();Td();Zi();tt();Cz=xe("jarvis"),ogt=!1,HAe=(t,e)=>{let n=za();n&&et(n,t,e)}});function YAe(){let t="";for(let e=0;e<agt;e++)t+=VAe[Rz.default.randomInt(VAe.length)];return t}function Iz(){let t=g7(KAe,null);return!t||Date.now()>t.expiresAt?null:t}function XAe(t){try{xn(KAe,t)}catch(e){n1.error(`persist pairing state: ${e.message}`)}}function JAe(t,e,n,r=null){XAe({tempKey:t,tail:e,expiresAt:n,workerUrl:r})}function cgt(){XAe({tempKey:null,tail:null,expiresAt:0,workerUrl:null})}async function lgt(t,e){if(!(!t||!e))try{await hc(`${e}/api/temp-key/remove`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempKey:t})}),n1.info(`one-time code revoked at the Worker: ${t}`)}catch(n){n1.warn(`could not revoke the code at the Worker: ${n.message}`)}}function sx(){let t=Iz();return t?{tempKey:t.tempKey,tail:t.tail,expiresAt:t.expiresAt}:null}function r1(t){let e=Iz();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&&Rz.default.timingSafeEqual(n,r)}function kz(t){if(r1(t))return!0;let e=Iz();return!e||!t||(cgt(),n1.warn("pairing tail mismatch \u2014 code killed here and at the Worker"),lgt(e.tempKey,e.workerUrl)),!1}var Rz,zAe,n1,KAe,VAe,agt,Pz=ae(()=>{Rz=ce(require("crypto"),1),zAe=require("path");Lt();tt();Eo();Lt();n1=xe("pairing"),KAe=(0,zAe.join)(Oe.STATE,"pairing.json"),VAe="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789",agt=2});function ZAe(){let t="";for(let e=0;e<ugt;e++)t+=QAe[Oz.default.randomInt(QAe.length)];return t}function eCe(t){return`sk-${(t||"").slice(0,8).toLowerCase()}-${ZAe()}-${ZAe()}`}function tCe(t){return/^sk-[a-z0-9]{8}-[a-np-z1-9]{8}-[a-np-z1-9]{8}$/.test(t||"")}function Gn(t){if(!tCe(t))return t||null;let e=t.split("-");return`${e[0]}-${e[1]}-${e[2]}`}function i1(t){return tCe(t)?t.split("-")[3]:null}function s1(t,e){if(typeof t!="string"||!t||typeof e!="string"||!e)return!1;let n=Buffer.from(Gn(t)||"","utf8"),r=Buffer.from(Gn(e)||"","utf8");return n.length>0&&n.length===r.length&&Oz.default.timingSafeEqual(n,r)}var Oz,kNt,QAe,ugt,Wf=ae(()=>{Oz=ce(require("crypto"),1),kNt=process.env.API_KEY_SECRET||process.env.APP_SECRET,QAe="abcdefghijklmnpqrstuvwxyz123456789",ugt=8});var oCe={};gr(oCe,{PROOF_DEADLINE:()=>Bz,admissionGate:()=>qz,clearProofWaiters:()=>Fz,finishTailRejection:()=>c1,handleTailProof:()=>$z,isProvingExpired:()=>ggt,isTailProofEnabled:()=>yv,noteTailFailure:()=>ax,onTailProven:()=>a1,presentedTailOf:()=>cx,submitTailProof:()=>o1,verdictStateOf:()=>ox,verifyKeyTail:()=>_v,verifyPresentedTail:()=>_gt});function sCe(){return i1(Qi()?.key||"")}function yv(){return!!sCe()}function Uz(t,e){let n=t?Dz.get(t):null;return!n||n.keyHead!==e?null:n}function rCe(t,e,n,r=null){if(!t)return;let i=Dz.get(t);Dz.set(t,{keyHead:e,state:n,reason:r,since:Date.now()}),n!==i?.state&&(n===vo.proven&&ygt(t),n===vo.rejected&&Vu.delete(t))}function o1(t,e,{pairing:n=!1}={}){let r=Gn(Qi()?.key||"");if(!t||!yv()&&!n)return!1;if(n?kz(e):_v(e))return rCe(t,r,vo.proven),fQ(t,r),Nz.info(`[seal] proof accepted: device=${t.slice(0,8)}`),!0;let s=e===null?Zr.sealUnreadable:Zr.mismatch;return rCe(t,r,vo.rejected,s),Nz.warn(`[seal] proof rejected (${s}): device=${t.slice(0,8)}`),!1}function ggt(t){let e=Uz(t,Gn(Qi()?.key||""));return!!e&&e.state===vo.proving&&Date.now()-e.since>Lz}function ox(t){return Uz(t,Gn(Qi()?.key||""))?.state||null}function a1(t,e,n){if(!t||!yv()||ox(t)===vo.proven)return e();Vu.has(t)||Vu.set(t,new Set),Vu.get(t).add(e),n&&setTimeout(()=>{let r=Vu.get(t);r?.delete(e)&&(r.size||Vu.delete(t),n())},Lz)}function ygt(t){let e=Vu.get(t);if(e){Vu.delete(t);for(let n of e)try{n()}catch{}}}function Fz(t){Vu.delete(t)}function ax(t){let e=Date.now(),n=(nCe.get(t)||[]).filter(i=>e-i<hgt);n.push(e),nCe.set(t,n);let r=n.length-dgt;return r<=0?0:Math.min(fgt*2**(r-1),pgt)}function _gt({tail:t,tempKey:e}={}){let n=!!e;return!n&&!yv()?{ok:!0}:t?(n?kz(t):_v(t))?{ok:!0}:{ok:!1,reason:Zr.mismatch,penaltyMs:ax(Gn(Qi()?.key||""))}:{ok:!1,reason:Zr.mismatch,penaltyMs:0}}function qz(t,e,{provenSocket:n=!1,tempKey:r=null}={}){let i=Gn(Qi()?.key||""),s=C0(t);if(s===Yi.rejected)return{step:"authz",decision:Ar.reject,reason:"device-rejected"};let o=!!r&&!WT(t);if(o){let a=sx();Nz.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":r1(String(e))}`)}if(yv()||o){let a=Uz(t,i);if(a?.state===vo.rejected&&e===void 0)return{step:"auth",decision:Ar.reject,reason:a.reason};let c=u=>o?r1(u):_v(u);if(!(n||a?.state===vo.proven||e!==void 0&&c(e)))return e!==void 0?{step:"auth",decision:Ar.reject,reason:e===null?Zr.sealUnreadable:Zr.mismatch}:{step:"auth",decision:Ar.hold,reason:"awaiting-proof"}}return s===Yi.approved||s===Yi.auto?{step:"authz",decision:Ar.admit}:{step:"authz",decision:Ar.hold,reason:"host-decides"}}function _v(t){let e=sCe();if(!e||!t)return!1;let n=Buffer.from(String(t),"utf8"),r=Buffer.from(e,"utf8");return n.length===r.length&&iCe.default.timingSafeEqual(n,r)}function cx(t,e){let n=t?.keyTailSealed;return n!==void 0?!n||typeof n!="object"||Array.isArray(n)?null:e(n)??null:t?.keyTail}function $z(t,e){let n=t?.data?.auth?.deviceId||t.handshake?.auth?.deviceId||t.deviceId||null,i=!!(t.handshake?.auth?.tempKey||e?.tempKey||null)&&!!sx();if(!n||!yv()&&!i)return!0;let s=cx(e,h0);return s===void 0||o1(n,s,{pairing:i})?!0:(t.data.tailReject={reason:s===null?Zr.sealUnreadable:Zr.mismatch,penaltyMs:ax(Gn(Qi()?.key||""))},!1)}function c1(t,e){if(t.data?.tailRejectFinished)return;t.data.tailRejectFinished=!0;let{reason:n,penaltyMs:r=0}=t.data?.tailReject||{},i=Mz>=mgt,s=i?0:r;i||Mz++,setTimeout(()=>{i||Mz--;try{t.emit("device:tailRejected",{reason:n}),t.disconnect()}catch{}e?.()},s)}var iCe,Nz,dgt,fgt,pgt,hgt,mgt,nCe,Mz,Dz,Lz,Vu,Bz,Gz=ae(()=>{iCe=ce(require("crypto"),1);tt();I0();Pz();Xi();Wf();Sd();m0();Nz=xe("deviceAuth");dgt=5,fgt=1e3,pgt=60*1e3,hgt=3600*1e3,mgt=20,nCe=new Map,Mz=0,Dz=new Map,Lz=2e4;Vu=new Map;Bz=Lz});var Jr,l1,lx=ae(()=>{Jr={authenticating:"authenticating",awaitingHost:"awaitingHost",active:"active",closed:"closed"},l1=new Set(["device:tailProof","device:clientReady","disconnect"])});var aCe,u1,cCe=ae(()=>{aCe=require("events");lx();u1=class extends aCe.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=Jr.authenticating,this._carriers=new Map}get state(){return this._state}get active(){return this._state===Jr.active}get closed(){return this._state===Jr.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:l1.has(e)}keyProven(){return this._state!==Jr.authenticating?!1:this._transition(Jr.awaitingHost,"key-proven")}hostAllowed(){return this._state!==Jr.awaitingHost?!1:this._transition(Jr.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(Jr.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 d1,lCe=ae(()=>{cCe();lx();d1=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 u1({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===Jr.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 uCe(t,e){return!t||t.closed?{effects:[]}:e.decision===Ar.reject?{effects:["refuse"],reason:e.reason||Zr.mismatch}:e.decision===Ar.hold&&e.step==="auth"?t.state===Jr.authenticating?{effects:["open-auth-channel"],reason:e.reason}:{effects:[],reason:e.reason}:(t.state===Jr.authenticating&&t.keyProven(),e.decision===Ar.hold?{effects:["ask-host"],reason:e.reason}:(t.state===Jr.awaitingHost&&t.hostAllowed(),{effects:t.active?["start-session"]:[]}))}var dCe=ae(()=>{lx();Xi()});function ac(){try{let t=(0,hCe.join)(Oe.ROOT,"keys.json");return JSON.parse((0,pCe.readFileSync)(t,"utf8")).key||null}catch{return null}}function za(){return ro}function ux(t){return t.carrier||{id:"ws",ip:t.handshake?.headers?.["x-forwarded-for"]||t.handshake?.address||"unknown",pendingId:t.id}}function nr(t){return t?.data?.auth||t?.handshake?.auth||null}function jz(t,e){let n=t?cx(nr(t),h0):void 0,r=qz(e,n,{provenSocket:t?.data?.provenDevice===!0,tempKey:nr(t)?.tempKey||null});Pr.info(`gate: device=${e?.slice(0,8)??"none"} step=${r.step} decision=${r.decision}${r.reason?` reason=${r.reason}`:""} carrier=${t?ux(t).id:"signaling"}`);let i=!!nr(t)?.tempKey,s=r.step==="authz"&&!i;return t&&n!==void 0&&(s||r.step==="auth")&&o1(e,n,{pairing:i}),t&&r.decision===Ar.reject&&r.step==="auth"&&(t.data.tailReject=t.data.tailReject||{reason:r.reason,penaltyMs:ax(Gn(ac()||""))}),r}function Egt(t){t.data.authHandlersReady||(t.data.authHandlersReady=!0,t.on("device:tailProof",e=>{let n=nr(t)?.deviceId;e?.tempKey&&t.data&&(t.data.auth||(t.data.auth={}),t.data.auth.tempKey=e.tempKey);try{let r=$z(t,e);Pr.info(`tailProof: device=${n?.slice(0,8)} carrier=${ux(t).id} accepted=${r}`),r||vv(t,n)}catch(r){Pr.warn(`tailProof handler failed: ${r.message}`)}}))}async function dx(t){if(nr(t)?.tempKey&&(Pr.info("one-time key used \u2014 clearing from UI"),qT()),await xgt(t),Egt(t),!t.data.localUi){let e=nr(t)?.deviceId||null,n=bgt(t);if(!n)return;let{id:r}=ux(t);n.attach(r,t.data.protocol?._adapters?.get(r)||null);let i=jz(t,e),{effects:s,reason:o}=uCe(n,i);if(Pr.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")){vv(t,e,o);return}if(s.includes("open-auth-channel")){t.data.awaitingProof||(t.data.awaitingProof=!0,a1(e,()=>{t.data.awaitingProof=!1,t.connected&&dx(t).catch(()=>{})},()=>vv(t,e,Zr.timeout)));return}if(s.includes("ask-host")){let a=ux(t);Yz(e,{socketId:a.pendingId,ip:a.ip,peerId:t.peerId,notify:()=>_m(t,"device:pendingApproval")});return}if(!s.includes("start-session"))return;C0(e)===Yi.auto&&(VT(e),$g(e),Qn("deviceApproval",{action:"refresh"}))}await Sgt(t)}function wgt(t){if(!nr(t)?.tempKey)return;let e=i1(ac()||"");e&&Kz(t,()=>{_m(t,"device:keyIssued",{tail:e}),Pr.info(`key issued to paired device=${nr(t)?.deviceId?.slice(0,8)}`)})}function mCe(t){if(!t.connected||!t.data?.conn?.active&&!t.data?.localUi||!t.data?.clientReady)return;p1(t),wgt(t);let e=tf._buildServerInfo?.();e&&t.emit("serverInfo",e),t.emit("srvCaps",{env2:1,fragCtl:1}),t.emit("tunnel:updated",BT())}async function Sgt(t){t.data.sessionReady||(t.data.sessionReady=!0,t.data.approved=!0,G_e(t),j_e(t),Rve(t),Nve(t),h0e(t,ro),jAe(t),await l2(t,ro,ac()),mCe(t),t.emit("terminal:ready"))}async function xgt(t){if(t.data.protocol)return;let{webrtc:e,streaming:n}=Te,r=new KT(t,{enableWebRTC:e.enableWebRTC,enableTurn:e.enableTurn??!1,apiKey:Gn(ac()),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||nr(t)?.peerId||nr(t)?.deviceId||null,doUrl:e.signalingDoUrl,apiKey:ac()}});t.data.protocol=r,t.defersWsAdapter&&(r._onDead=()=>{Pr.debug(`[diag] _onDead fired peer=${(t.peerId||"").slice(0,12)} \u2014 rtc never returned in grace`),Mi(`RTC session closed: ${nr(t)?.deviceId?.slice(0,8)}...`);try{r.close()}catch{}kp(r),t.disconnect()}),q7(r),r.attachAsBus(t);try{await r.init()}catch(i){console.error("[transport] pm init failed:",i.message)}}function bgt(t){let e=nr(t)?.deviceId||null;if(!e)return null;let n=t.peerId||nr(t)?.peerId||e,r=t.data.conn;if(r&&!r.closed)return r;let i=Wz.open({deviceId:e,peerId:n,apiKey:ac()});return t.data.conn=i,i}function DL(){return Vz}function nQ(t){if(Vz=t,!t){W7();return}H7();for(let e of[...no.keys()])Ev(e),Mi(`RTC test-disabled: killed session ${e?.slice(0,8)}`)}function Kz(t,e){t.data.clientReady?e():t.once("device:clientReady",e)}function gCe(t){t.data.clientReady=!1,t.on("device:clientReady",()=>{t.data.clientReady=!0,mCe(t)})}function Tgt(t){if(!t)return;if(Vz){f1(t,{type:"error",message:"rtc-disabled"});return}let e=t.split(":")[0],n=no.get(t);if(n){if(!n.data.protocol?._closed)return;Mi(`Stale RTC session ${e.slice(0,8)} \u2014 rebuilding`),Ev(t)}let r=Agt(t),i=jz(null,e);if(i.decision===Ar.hold&&i.step==="auth")return r?void 0:(Pr.info(`rtc-offer: building session so the TAIL proof has a road device=${e.slice(0,8)}`),void Hz(t,e));switch(i.decision){case Ar.admit:return r?void 0:void Hz(t,e);case Ar.reject:GL(e,fCe(t),"rtc"),f1(t,{type:"error",message:Eg.rejected}),dT(t),Xt(`Rejected device via RTC: ${e.slice(0,8)} \u2014 waiting in Clients list`),Qn("deviceApproval",{action:"refresh"});return;default:Yz(e,{socketId:fCe(t),ip:"rtc",peerId:t,notify:()=>f1(t,{type:"error",message:Eg.pending})})}}function Yz(t,{socketId:e,ip:n,peerId:r,notify:i}){if(i(),hQ(t)){Xt(`[auth] already pending, not asking twice: ${t?.slice(0,8)}`);return}BL(e,{deviceId:t,ip:n,...r?{peerId:r}:{}}),Pr.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"}`),Qn("deviceApproval",{socketId:e,deviceId:t,ip:n,action:"pending"})}function Agt(t){for(let e of ro?.sockets.sockets.values()||[])if(e.connected&&nr(e)?.peerId===t)return!0;return!1}function _m(t,e,...n){let r=t.data?.protocol;r&&!r._closed&&r.emitEverywhere(e,...n)||t.emit(e,...n)}function p1(t){let e=()=>{t.connected&&Kz(t,()=>_m(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===Jr.closed&&n.off("state",r),i.to===Jr.active&&(n.off("state",r),e())})}function yCe(t){return t.data.approved||t.data.unlocking?Promise.resolve():(t.data.unlocking=!0,p1(t),dx(t).catch(n=>Xt(`Feature setup failed: ${n.message}`)).finally(()=>{t.data.unlocking=!1}))}async function _Ce(t){if(!t)return;let e=R0(t);e&&Mp(e);let n=[];for(let r of ro?.sockets.sockets.values()||[])nr(r)?.deviceId!==t||r.data.approved||n.push(yCe(r));for(let r of no.values())nr(r)?.deviceId!==t||r.data.approved||n.push(dx(r).catch(i=>Xt(`Connection resume failed: ${i.message}`)));await Promise.allSettled(n);for(let r of bJ(t))Hz(r,t)}function vv(t,e,n){Pr.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;Pr.warn(`tail rejected (${r}): device=${e?.slice(0,8)??"none"} carrier=${ux(t).id}`),Xt(`Device refused (${r}): ${e?.slice(0,8)}`),nr(t)?.tempKey&&r===Zr.mismatch&&(Pr.warn("one-time key burned (wrong TAIL) \u2014 clearing from UI"),qT()),c1(t,()=>{t.defersWsAdapter&&Ev(t.peerId),vCe(e,r)})}function vCe(t,e){if(Pr.debug(`[diag] revokeDevice device=${t?.slice(0,8)} reason=${e}`),!!t){Fz(t),Mp(R0(t)||""),Wz.closeDevice(t,e);for(let n of ro?.sockets.sockets.values()||[])nr(n)?.deviceId===t&&(n.data.tailReject=n.data.tailReject||{reason:e,penaltyMs:0},c1(n));for(let[n,r]of no)nr(r)?.deviceId===t&&(r.data?.tailReject||Ev(n))}}function ECe(t){let e=qL(t);if(e)return{key:t,...e};let n=zz(t)?.split(":")[0]||nr(ro?.sockets.sockets.get(t)||null)?.deviceId||null,r=n?R0(n):null,i=r?qL(r):null;return i?{key:r,...i}:null}function Ev(t){let e=t?no.get(t):null;if(!e)return;let n=e.data?.protocol;no.delete(t);try{e.disconnect()}catch{}if(n){try{n.close()}catch{}kp(n)}}function Hz(t,e){Cgt(t,e).catch(n=>{Ev(t),Xt(`RTC session failed: ${n.message}`)})}async function Cgt(t,e){if(no.has(t))return;let n=new hT({deviceId:e,peerId:t,apiKey:ac()});n.data.approved=!1,n.data.rtcSession=!0,n.data.conn=Wz.open({deviceId:e,peerId:t,apiKey:ac()}),gCe(n);let r;n.data.ready=new Promise(i=>{r=i}),no.set(t,n),HT(n.id,"rtc",e,"rtc"),n.on("disconnect",()=>{Pr.debug(`[diag] AgentBus disconnect peer=${(t||"").slice(0,12)} \u2192 untrack + conn.close`),no.get(t)===n&&no.delete(t),jT(n.id),n.data.conn?.close("carrier-gone"),r()}),Mi(`RTC session: ${e.slice(0,8)}...`);try{await dx(n)}finally{r()}setTimeout(()=>{no.get(t)===n&&ox(e)!==vo.proven&&(Xt(`Device never proved its TAIL: ${e.slice(0,8)} \u2014 dropping session`),vv(n,e,Zr.timeout))},Bz+1e3),p1(n)}function wCe(t){if(!ro)return!1;let e=ECe(t);return e?ox(e.deviceId)===vo.rejected?(Pr.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`),Mp(e.key),vCe(e.deviceId,Zr.mismatch),Qn("deviceApproval",{action:"refresh"}),!1):(VT(e.deviceId),$g(e.deviceId),Xt(`Device approved: ${e.deviceId.slice(0,8)}...`),_Ce(e.deviceId),Qn("deviceApproval",{action:"refresh"}),!0):!1}function SCe(t){return!ro||!t?!1:(VT(t),$g(t),Xt(`Device approved from pending: ${t.slice(0,8)}...`),_Ce(t),Qn("deviceApproval",{action:"refresh"}),!0)}function h1(t){Pr.debug(`[diag] disconnectDeviceSockets device=${t?.slice(0,8)} \u2014 stack hint: ${new Error().stack.split(`
|
|
531
531
|
`)[2]?.trim()?.slice(0,90)}`);let e=ro;if(!e||!t)return 0;let n=0;for(let r of e.sockets.sockets.values())nr(r)?.deviceId===t&&(r.disconnect(!0),n++);for(let r of $7())r._closed||r._deviceId?.split(":")[0]===t&&(S0(r),n++);for(let[r,i]of no)if(r.split(":")[0]===t){try{i.data.protocol?.close()}catch{}kp(i.data.protocol),dT(r),i.disconnect(),n++}return n&&Mi(`Disconnected ${n} socket(s) for device ${t.slice(0,8)}...`),n}function xCe(t){if(!ro)return!1;let e=ECe(t),n=ro.sockets.sockets.get(t);Mp(e?.key||t),e?.deviceId&&gQ(e.deviceId,{ip:e.ip,socketId:t}),n&&(_m(n,"device:rejected"),n.disconnect(!0));let r=e?.peerId||zz(t);return r&&(f1(r,{type:"error",message:Eg.rejected}),dT(r)),Qn("deviceApproval",{action:"refresh"}),Xt(`Device rejected: ${e?.deviceId?.slice(0,8)||"unknown"}...`),!0}async function bCe(t){aQ(),_Q(),o0(Gn(ac())),setInterval(()=>{let r=Gn(ac());r&&o0(r)},vgt),SJ(Tgt),lT(()=>Dg());let e=new yJ(t,{cors:{origin:"*",methods:["GET","POST"],credentials:!0,allowedHeaders:["*"]},allowRequest:(r,i)=>i(null,!Gx(r.headers.host)),transports:["websocket","polling"],allowEIO3:!0,allowUpgrades:!0,pingTimeout:3e4,pingInterval:12e3,maxHttpBufferSize:1e8,perMessageDeflate:{threshold:1024}}),n=await qZ();return pL(n),e.on("connection",r=>{fT("client-connected");let i=r.handshake.headers["x-forwarded-for"]||r.handshake.address||"unknown",s=nr(r)?.deviceId||null;gCe(r),r.data.approved=!1,r.use((f,m)=>{if(r.data.localUi)return m();let g=r.data.conn;return g?g.allows(f[0])?m():m(new Error("Device not approved")):l1.has(f[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||up.includes(l);if(!c&&a&&u&&kJ(r.handshake.auth?.localToken)){r.data.approved=!0,r.data.localUi=!0,Mi("Local UI connected \u2014 trusted (token)"),dx(r).catch(f=>Xt(`Feature setup failed: ${f.message}`));return}if(s===lp){Xt(`Rejected untrusted local-ui socket from ${i}`),r.disconnect(!0);return}if(!c&&a&&u&&s&&!WT(s)){let f=cx(nr(r),h0);f&&_v(f)&&C0(s)===Yi.unknown&&(lQ(s),Pr.info(`loopback workspace device admitted for this session (key TAIL verified): ${s.slice(0,8)}`),Mi(`Loopback workspace admitted (session): ${s.slice(0,8)} (key TAIL verified)`))}HT(r.id,i,s),Mi(`Client connected: ${i} (device: ${s?.slice(0,8)||"none"})`),r.on("disconnect",f=>{jT(r.id),Mp(r.id);let m=r.data?.conn;m&&(m.detach("ws"),m.connected||m.close("carrier-gone"));let g=r.data?.protocol;Mi(`Client disconnected: ${i} (${f}) pm=${g?._deviceId?.slice(0,12)||"none"} remoteAttached=${!!r.data?.remoteAttached}`),g&&!r.data?.remoteAttached&&S0(g)});let d=()=>{if(!r.connected)return;let f=r.handshake.auth?.peerId||null,m=()=>{if(r.data.approved)return;let S=R0(s);if(S&&!zz(S)){Mi(`Device ${s?.slice(0,8)} already pending, ignoring duplicate`),r.disconnect(!0);return}let T=!!S;S&&Mp(S),Kz(r,()=>{if(!(r.data.approved||!r.connected)){if(T){BL(r.id,{deviceId:s,ip:i}),_m(r,"device:pendingApproval");return}Yz(s,{socketId:r.id,ip:i,notify:()=>_m(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}`)),Mi(`Tunnel attached to RTC session: ${s.slice(0,8)}...`),p1(r)},y=f?no.get(f):null;if(!y&&f&&!r.data._rtcWaited&&AJ(f)){r.data._rtcWaited=!0,Mi(`WS first, RTC offer pending \u2192 grace 500ms (device ${s.slice(0,8)})`),setTimeout(d,500);return}let w=jz(r,s);if(w.decision===Ar.hold&&w.step==="auth"){Pr.info(`route: awaiting TAIL proof device=${s?.slice(0,8)||"no-id"}`),a1(s,()=>d(),()=>{vv(r,s,Zr.timeout)});return}switch(w.decision){case Ar.admit:if(y)return void g(y);Mi(`Device admitted: ${s?.slice(0,8)}...`),yCe(r);return;case Ar.reject:{if(r.data?.tailReject)return void vv(r,s);GL(s,r.id,i),Xt(`Rejected device reconnected: ${s.slice(0,8)} \u2014 waiting in Clients list`),_m(r,"device:rejected"),Qn("deviceApproval",{action:"refresh"});return}default:Pr.info(`route: hold for approval device=${s?.slice(0,8)||"no-id"}`),Xt(`Device needs approval: ${s?.slice(0,8)||"no-id"}`),m()}};d()}),tf(e,ac()),ro=e,e}var pCe,hCe,Pr,vgt,ro,no,Wz,Vz,fCe,zz,f1,Td=ae(()=>{_J();pCe=require("fs"),hCe=require("path");a0();CJ();Lt();mT();Z1();EQ();Xi();Zi();qr();$a();hA();H_e();W_e();Ive();Dve();m0e();WAe();So();I0();Gz();m0();Xi();Wf();tt();lCe();dCe();lx();Pr=xe("transport");vgt=5e3,ro=null;no=new Map,Wz=new d1;Vz=!1;fCe=t=>`rtc-${t}`,zz=t=>t.startsWith("rtc-")?t.slice(4):null,f1=(t,e)=>uT({...e,to:t});j7(Ev)});var PCe=B((fx,Xz)=>{(function(t,e){typeof fx=="object"&&typeof Xz=="object"?Xz.exports=e(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],e):typeof fx=="object"?fx["electron-machine-id"]=e(require("child_process"),require("crypto")):t["electron-machine-id"]=e(t.child_process,t.crypto)})(fx,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,d){return o.call(a,l,u,d)}}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,d){if(s(l),u=a(u,!0),s(d),o)try{return c(l,u,d)}catch{}if("get"in d||"set"in d)throw TypeError("Accessors not supported!");return"value"in d&&(l[u]=d.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,d,f;return l===void 0?"Undefined":l===null?"Null":typeof(d=c(u=Object(l),o))=="string"?d:a?s(u):(f=s(u))=="Object"&&typeof u.callee=="function"?"Arguments":f}},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(d,f,m){var g,y,w,S=d&u.F,T=d&u.G,R=d&u.S,C=d&u.P,D=d&u.B,$=d&u.W,G=T?o:o[f]||(o[f]={}),V=G[l],L=T?s:R?s[f]:(s[f]||{})[l];T&&(m=f);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):$&&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,d&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),d=i(45),f=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,$,G,V,L,k){d($,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 $(this,J)};case T:return function(){return new $(this,J)}}return function(){return new $(this,J)}},P=D+" Iterator",F=V==T,X=!1,N=C.prototype,b=N[g]||N[w]||V&&N[V],q=b||I(V),pe=V?F?I("entries"):q:void 0,oe=D=="Array"&&N.entries||b;if(oe&&(M=m(oe.call(new C)),M!==Object.prototype&&(f(M,P,!0),s||l(M,g)||c(M,g,R))),F&&b&&b.name!==T&&(X=!0,q=function(){return b.call(this)}),s&&!k||!y&&!X&&N[g]||c(N,g,q),u[D]=q,u[P]=R,V)if(E={values:F?q:I(T),keys:L?q: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),d=i(16),f=i(2),m=f.process,g=f.setImmediate,y=f.clearImmediate,w=f.MessageChannel,S=0,T={},R="onreadystatechange",C=function(){var $=+this;if(T.hasOwnProperty($)){var G=T[$];delete T[$],G()}},D=function($){C.call($.data)};g&&y||(g=function($){for(var G=[],V=1;arguments.length>V;)G.push(arguments[V++]);return T[++S]=function(){l(typeof $=="function"?$:Function($),G)},s(S),S},y=function($){delete T[$]},i(11)(m)=="process"?s=function($){m.nextTick(c(C,$,1))}:w?(o=new w,a=o.port2,o.port1.onmessage=D,s=c(a.postMessage,a,1)):f.addEventListener&&typeof postMessage=="function"&&!f.importScripts?(s=function($){f.postMessage($+"","*")},f.addEventListener("message",D,!1)):s=R in d("script")?function($){u.appendChild(d("script"))[R]=function(){u.removeChild(this),C.call($)}}:function($){setTimeout(c(C,$,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(`
|
|
532
|
-
`)[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 f.default(function(C,D){return(0,m.exec)(T[w],{},function($,G,V){if($)return D(new Error("Error while obtaining machine id: "+$.stack));var L=c(G.toString());return C(R?L:a(L))})})}Object.defineProperty(r,"__esModule",{value:!0});var d=i(35),f=s(d);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,d){var f,m=s(l),g=o(m.length),y=a(d,g);if(c&&u!=u){for(;g>y;)if(f=m[y++],f!=f)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),d={},f={},m=n.exports=function(g,y,w,S,T){var R,C,D,$,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($=y?V(c(C=g[L])[0],C[1]):V(g[L]),$===d||$===f)return $}else for(D=G.call(g);!(C=D.next()).done;)if($=o(D,V,C.value,y),$===d||$===f)return $};m.BREAK=d,m.RETURN=f},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(d){var u=o.return;throw u!==void 0&&s(u.call(o)),d}}},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,d){l.prototype=s(c,{next:o(1,d)}),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 d=[7],f=d[s]();f.next=function(){return{done:u=!0}},d[s]=function(){return f},c(d)}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 d,f,m,g=function(){var T,R;for(u&&(T=c.domain)&&T.exit();d;){R=d.fn,d=d.next;try{R()}catch(C){throw d?m():f=void 0,C}}f=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};f&&(f.next=R),d||(d=R,m()),f=R}}},function(n,r,i){var s=i(3),o=i(50),a=i(22),c=i(19)("IE_PROTO"),l=function(){},u="prototype",d=function(){var f,m=i(16)("iframe"),g=a.length,y=">";for(m.style.display="none",i(25).appendChild(m),m.src="javascript:",f=m.contentWindow.document,f.open(),f.write("<script>document.F=Object</script"+y),f.close(),d=f.F;g--;)delete d[u][a[g]];return d()};n.exports=Object.create||function(f,m){var g;return f!==null?(l[u]=s(f),g=new l,l[u]=null,g[c]=f):g=d(),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,d=a(l),f=d.length,m=0;f>m;)s.f(c,u=d[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),d=Object.getOwnPropertyDescriptor;r.f=i(4)?d:function(f,m){if(f=a(f),m=c(m,!0),u)try{return d(f,m)}catch{}if(l(f,m))return o(!s.f.call(f,m),f[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 d,f=o(l),m=0,g=[];for(d in f)d!=c&&s(f,d)&&g.push(d);for(;u.length>m;)s(f,d=u[m++])&&(~a(g,d)||g.push(d));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(d,f){return a(d,f),l?d.__proto__=f:u(d,f),d}})({},!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 d=typeof o[u]=="function"?o[u]:s[u];c&&d&&!d[l]&&a.f(d,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,d=s(c).constructor;return d===void 0||(u=s(d)[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,d,f=String(o(c)),m=s(l),g=f.length;return m<0||m>=g?a?"":void 0:(u=f.charCodeAt(m),u<55296||u>56319||m+1===g||(d=f.charCodeAt(m+1))<56320||d>57343?a?f.charAt(m):u:a?f.slice(m,m+2):(u-55296<<10)+(d-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,d=this._i++;return!l||d>=l.length?(this._t=void 0,o(1)):u=="keys"?o(0,d):u=="values"?o(0,l[d]):o(0,[d,l[d]])},"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),d=i(21),f=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,$=l[C],G=l.process,V=d(G)=="process",L=function(){},k=!!(function(){try{var oe=$.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===$&&J===a},A=function(oe){var J;return!(!m(oe)||typeof(J=oe.then)!="function")&&J},M=function(oe){return E($,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,lt=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>lt;)Ue(ve[lt++]);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})})},q=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(q,we,1))}catch(Se){q.call(we,Se)}}):(ve._v=oe,ve._s=1,F(ve,!1))}catch(we){q.call({_w:ve,_d:!1},we)}}};k||($=function(oe){y(this,$,C,"_h"),g(oe),s.call(this);try{oe(u(pe,this,1),u(q,this,1))}catch(J){q.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)($.prototype,{then:function(oe,J){var ve=M(S(this,$));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(q,oe,1)}),f(f.G+f.W+f.F*!k,{Promise:$}),i(18)($,C),i(59)(C),a=i(6)[C],f(f.S+f.F*!k,C,{reject:function(oe){var J=M(this),ve=J.reject;return ve(oe),J.promise}}),f(f.S+f.F*(c||!k),C,{resolve:function(oe){if(oe instanceof $&&E(oe.constructor,this))return oe;var J=M(this),ve=J.resolve;return ve(oe),J.promise}}),f(f.S+f.F*!(k&&i(46)(function(oe){$.all(oe).catch(L)})),C,{all:function(oe){var J=this,ve=M(J),we=ve.resolve,Se=ve.reject,lt=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 lt&&Se(lt.error),ve.promise},race:function(oe){var J=this,ve=M(J),we=ve.reject,Se=P(function(){w(oe,!1,function(lt){J.resolve(lt).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 d=l[u],f=s[d],m=f&&f.prototype;m&&!m[c]&&o(m,c,d),a[d]=a.Array}},function(n,r){n.exports=require("child_process")},function(n,r){n.exports=require("crypto")}])})});var iyt={};gr(iyt,{startServer:()=>MRe});module.exports=RIe(iyt);var _1=require("http"),vm=require("child_process"),Hi=require("fs"),nn=require("path"),v1=require("url");Mr();Z1();Lt();tt();Td();zq();cj();$a();Cq();Wf();Sd();async function TCe(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(!s1(r,Qi()?.key)){e.setHeader("Content-Type","application/json"),e.writeHead(401),e.end(JSON.stringify({error:"Unauthorized: Invalid API key"}));return}let i=await gR();e.setHeader("Content-Type","application/json"),e.writeHead(200),e.end(JSON.stringify(i))}Wf();mT();var RCe=require("url");var m1=ce(require("path"),1),ICe=ce(require("os"),1);Lt();var ACe=ce(require("path"),1),CCe=ce(require("os"),1);var ODt=ACe.default.join(CCe.default.homedir(),".9remote","pids");ZD();Cp();var $Dt=m1.default.dirname((0,RCe.fileURLToPath)(__importMetaUrl));var GDt=m1.default.join(ICe.default.homedir(),".9remote","cloudflared.pid");function kCe(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 HDt=m1.default.join(Oe.STATE,i0.lockFile);So();$a();Cp();Mr();Sd();Wf();var OCe=ce(PCe(),1),Jz=ce(require("crypto"),1),{machineIdSync:Rgt}=OCe.default;async function MCe(t=null){let e=t||process.env.MACHINE_ID_SALT||"9remote-salt";try{let n=Rgt();return Jz.default.createHash("sha256").update(n+e).digest("hex").substring(0,16)}catch(n){return console.error("Error getting machine ID:",n),Jz.default.randomUUID().replace(/-/g,"").substring(0,16)}}So();Lt();tt();m0();Wf();Pz();var NCe=xe("session"),Igt=10;async function DCe(t,e){try{let n=await hc(`${e}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let s={apiKey:Gn(t),expiryMinutes:Igt};return{...s,...bT(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=YAe();return JAe(r.tempKey,i,r.expiresAt,e),{...r,oneTimeKey:`${r.tempKey}${i}`}}catch(n){return NCe.error(`Temp key creation failed: ${n?.message||n}`),null}}function LCe(t,e){return e?.tempKey?`${t}/login?k=${e.tempKey}#${e.oneTimeKey}`:`${t}/login`}async function UCe(t,e,n,r){try{let i=await hc(`${e}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Gn(t),hostPublicKey:ST(),hostX25519Key:xT(),tempKey:sx()?.tempKey||void 0})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return n&&await hc(`${e}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Gn(t),tunnelUrl:n,...bT({apiKey:Gn(t),tunnelUrl:n})})}).catch(()=>{}),r&&Gn(r)!==Gn(t)&&await hc(`${e}/api/session/delete`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Gn(r),...bT({apiKey:Gn(r)})})}).catch(()=>{}),!0}catch(i){return NCe.error(`Session registration failed: ${i?.message||i}`),!1}}a0();Wf();Cp();async function FCe(t,e){let n=FT(),r=n.workerUrl||Ec;if(!n.permanentKey){ot(e,400,"No permanent key set");return}let i=await DCe(n.permanentKey,r);if(!i){ot(e,500,"Temp key creation failed");return}let s=LCe(r,i);Rc({oneTimeKey:i.oneTimeKey,oneTimeKeyExpiresAt:i.expiresAt,qrUrl:s}),Ne(e,{oneTimeKey:i.oneTimeKey,expiresAt:i.expiresAt,qrUrl:s})}async function BCe(t,e){fT("session-registered"),Ne(e,pT())}async function qCe(t,e){try{let n=FT(),r=n.workerUrl||Ec,i=await MCe(),s=eCe(i),o=Qi();if(!await UCe(s,r,n.tunnelUrl,o?.key)){ot(e,502,"Could not register the new key with the server");return}A7(i,s,o?.name||"Default"),o0(Gn(s)),Rc({permanentKey:s,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0}),Ne(e,{ok:!0,permanentKey:s})}catch(n){ot(e,500,n.message)}}Mr();Td();I0();async function $Ce(t,e){let n=await Or(t,e);if(!n)return;let r=wCe(n.socketId);Ne(e,{ok:r})}async function GCe(t,e){let n=await Or(t,e);if(!n)return;let r=xCe(n.socketId);Ne(e,{ok:r})}function HCe(t,e){Ne(e,{pending:mQ()})}function jCe(t,e){Ne(e,{devices:pQ()})}function WCe(t,e){Ne(e,{rejected:yQ()})}async function VCe(t,e){let n=await Or(t,e);if(!n)return;let r=SCe(n.deviceId);Ne(e,{ok:r})}async function zCe(t,e){let n=await Or(t,e);n&&(h1(n.deviceId),$g(n.deviceId),Ne(e))}async function KCe(t,e){let n=await Or(t,e);n&&(h1(n.deviceId),uQ(n.deviceId),Ne(e))}async function YCe(t,e){let n=await Or(t,e);if(!n)return;cQ(n.deviceId);let r=h1(n.deviceId);Ne(e,{disconnected:r})}function XCe(t,e){Ne(e,{enabled:HL()})}async function JCe(t,e){let n=await Or(t,e);if(!n)return;let r=dQ(n.deviceId,n.label);Ne(e,{ok:r})}async function QCe(t,e){let n=await Or(t,e);if(!n)return;let r=vQ(!!n.enabled);Ne(e,{enabled:r})}Mr();Td();Zi();hR();Ds();Lc();n2();Az();var ZCe={},kgt=1e4;function Pgt(t,e){if(e?.csid&&Bd.test(e.csid))return e.csid;let{sessionId:n,...r}=e||{};return ine(t,r)}function tRe(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 nRe(t,e){let n="";await new Promise(r=>{t.on("data",i=>n+=i),t.on("end",r)});try{iRe(tRe(n,null)),Ne(e,{success:!0})}catch{ot(e,400,"Invalid JSON")}}function rRe(t,e,{query:n}){iRe(tRe(null,n)),Ne(e,{success:!0})}function eRe(t,e,n){let{type:r,sessionId:i,tool:s}=t,o={type:r,sessionId:i,tool:s,timestamp:n},c=eh({type:r,sessionId:i,tool:s})?.state||Jt.IDLE,l=rs(i);if(et(e,"statusChange",{sessionId:i,state:c,tool:s,since:n,...l?{conversationId:l.id}:{}}),mF(i,o),et(e,"chatNotification",o),(c===Jt.DONE||c===Jt.BLOCKED)&&BA(i),(c===Jt.DONE||c===Jt.BLOCKED)&&Tz(i),c!==Jt.DONE&&c!==Jt.BLOCKED)return;let u=`${i}:${c}`;n-(ZCe[u]||0)<kgt||(ZCe[u]=n,nce({...o,state:c}))}function iRe(t){let{type:e,sessionId:n,tool:r}=t,i=Date.now(),s=za();if(!s||!n)return;let o=Pgt(r,t);if(o&&Ma(n,r,o,"hook"),UA[e]===Jt.DONE){$A(n,()=>eRe(t,s,Date.now()));return}eRe(t,s,i)}Mr();Xq();RR();Lt();var Qz=ce(require("fs"),1),g1=ce(require("path"),1);Td();Zi();mh();$a();var Ogt=process.platform==="darwin"||process.platform==="win32",sRe=t=>Ogt?t.toLowerCase():t,oRe=(t,e)=>{let n=sRe(t),r=sRe(e);return n===r||n.startsWith(r+g1.default.sep)},aRe=t=>[t.cwd,t.workspacePath].filter(Boolean);function Mgt(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 aRe(s))oRe(t,o)&&o.length>i&&(r=s.id,i=o.length);return r}function cRe({path:t,title:e},n=null){if(!t||typeof t!="string")return{error:"path is required"};let r=g1.default.resolve(t);try{r=Qz.default.realpathSync(r)}catch{return{error:"File not found"}}if(wt(r))return{error:"Access denied"};if(!Qz.default.statSync(r).isFile())return{error:"Not a file"};let i=gu(),s=i.filter(c=>aRe(c).some(l=>oRe(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=za();if(!o)return{error:"Server not ready"};let a=Mgt(r,n,s);return et(o,"artifactOpen",{path:r,title:e||g1.default.basename(r),sessionId:a}),{path:r}}var Ngt={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=cRe({path:t,title:e},n?.sessionId);return r.error?r:`Opened ${r.path}`}},lRe=Ngt;cS();kj();var Dgt=500;function Lgt(t={applyAction:D_}){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:Ij,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,Dgt);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 uRe=Lgt();qk();var dRe=[lRe],fRe=new Map([...dRe,...Af,uRe].map(t=>[t.name,t])),pRe=()=>dRe.map(({name:t,description:e,inputSchema:n})=>({name:t,description:e,inputSchema:n}));var y1=(t,e=!1)=>({content:[{type:"text",text:t}],isError:e});async function Ugt(t,e,n){let r=fRe.get(t);if(!r)return y1(`Unknown tool: ${t}`,!0);try{let i=await r.run(e||{},n||{});return i?.error?y1(i.error,!0):y1(typeof i=="string"?i:JSON.stringify(i))}catch(i){return y1(i.message,!0)}}async function hRe(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||Il.PROTOCOL_VERSION,capabilities:{tools:{}},serverInfo:{name:Il.SERVER_NAME,version:"3.0.10"}}):r==="tools/list"?s({tools:pRe()}):r==="tools/call"?s(await Ugt(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 e8=ce(require("fs"),1),gRe=require("child_process");tt();Kq();var Fgt=xe("artifact"),mRe=/(?:^|[\s\0])NINE_REMOTE_SESSION_ID=([^\s\0]+)/,Zz=new WeakMap,t8=(t,e)=>(0,gRe.execFileSync)(t,e,{encoding:"utf8",timeout:Gy.PROBE_TIMEOUT_MS,stdio:["ignore","pipe","ignore"]});function Bgt(t,e){let n=t8("lsof",["-nP",`-iTCP:${t}`,"-Fpn"]),r=null;for(let i of n.split(`
|
|
533
|
-
`))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 qgt(t){try{return process.platform==="linux"?e8.default.readFileSync(`/proc/${t}/environ`,"utf8").match(mRe)?.[1]||null:t8("ps",["-Eww","-o","command=","-p",String(t)]).match(mRe)?.[1]||null}catch{return null}}function $gt(t){try{if(process.platform==="linux"){let e=e8.default.readFileSync(`/proc/${t}/stat`,"utf8");return parseInt(e.slice(e.lastIndexOf(")")+2).split(" ")[1],10)||null}return parseInt(t8("ps",["-o","ppid=","-p",String(t)]).trim(),10)||null}catch{return null}}function Ggt(t){for(let e=0;t>1&&t!==process.pid&&e<Gy.MAX_PARENT_HOPS;e++){let n=qgt(t);if(n)return n;if(t=$gt(t),!t)return null}return null}function yRe(t){let e=t?.headers?.[Gy.HEADER];if(e&&!/[${}]/.test(e))return e;let n=t?.socket;if(!n)return null;if(Zz.has(n))return Zz.get(n);let r=null;try{let i=Bgt(n.remotePort,process.pid);i&&(r=Ggt(i))}catch(i){Fgt.warn(`caller probe failed: ${i.message}`)}return Zz.set(n,r),r}async function _Re(t,e){if(!nle(t.headers.authorization))return ot(e,401,"Unauthorized");if(!XE())return ot(e,403,"MCP is turned off in 9Remote settings");let n=await Or(t,e);if(n===null&&!e.writableEnded)return ot(e,400,"Invalid request");if(e.writableEnded)return;let r;try{r=await hRe(n,{sessionId:yRe(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))}Mr();NT();Sd();qr();So();function vRe(){return{mode:sL(),active:iL(),presets:Object.keys(Te.sleepInhibit?.presets||{})}}function ERe(t,e){Ne(e,vRe())}async function wRe(t,e){let n=await Or(t,e);if(!n)return;let r=T0(n.mode);T7({sleepInhibitMode:r});let i=vRe();Qn("sleepInhibit",i),Ne(e,i)}Mr();oU();async function SRe(t,e){let n=await nA();Ne(e,n)}async function xRe(t,e){let n=await QQ(),r=await nA();Ne(e,{...n,...r})}async function bRe(t,e){let n=await Or(t,e);if(!n)return;if(typeof n.text!="string"||!n.text){ot(e,400,"Missing text");return}let r=await L0(n.text);Ne(e,{ok:r.ok,reason:r.reason||null})}async function TRe(t,e){let n=await JQ(),r=await nA();Ne(e,{...n,...r})}mi();Mr();async function ARe(t,e){try{let n=await Cd();Ne(e,{sessions:n})}catch(n){ot(e,500,n.message)}}async function CRe(t,e){let n=await Or(t,e);if(n){if(!n.sessionId)return ot(e,400,"sessionId required");try{await Rd(n.sessionId),Ne(e)}catch(r){ot(e,500,r.message)}}}var zu=ce(require("os"),1);qr();hA();Mr();function Hgt(){let t=$Z();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 jgt(){let t=process.memoryUsage(),e=zu.default.cpus();return{agent:{pid:process.pid,version:"3.0.10",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:zu.default.hostname(),platform:zu.default.platform(),arch:zu.default.arch(),uptimeSec:Math.round(zu.default.uptime()),loadAvg:zu.default.loadavg(),cpuModel:e?.[0]?.model||"unknown",cpuCount:e.length,totalMemMB:Math.round(zu.default.totalmem()/1048576),freeMemMB:Math.round(zu.default.freemem()/1048576)},remote:{available:pA(),...Hgt(),memoryWarningThresholdMB:Te.resourceManagement.memoryWarningThreshold},timestamp:Date.now()}}function RRe(t,e){try{Ne(e,jgt())}catch(n){ot(e,500,"stats error",n.message)}}NT();Sd();qr();Y8();fK();var ra=xe("server"),ia=(0,v1.fileURLToPath)(new URL(".",__importMetaUrl)),PRe=process.env.NODE_ENV==="development",Wgt=5173,n8=[(0,nn.join)(ia,"dist","ui"),(0,nn.join)(ia,"ui","dist"),(0,nn.join)(ia,"ui")].find(t=>(0,Hi.existsSync)(t))||(0,nn.join)(ia,"dist","ui"),cc=[(0,nn.join)(ia,"dist","web"),(0,nn.join)(ia,"web"),(0,nn.join)(ia,"..","web","out")].find(t=>(0,Hi.existsSync)(t))||n8,Vgt={".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 zgt(t,e,n){let r=(0,_1.request)({hostname:"localhost",port:Wgt,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 Kgt(t,e){let n;try{n=(0,v1.parse)(t.url).pathname}catch{ot(e,400,"Bad request");return}let r=lK(n,t.headers.host);if(!r){ot(e,404,"Not found");return}for(let[i,s]of Object.entries(r.headers))e.setHeader(i,s);ys(e,(0,nn.join)(cc,r.path),{frameable:!0})||ot(e,404,"Not found")}function ys(t,e,{frameable:n=!1}={}){if(!(0,Hi.existsSync)(e))return!1;try{if((0,Hi.statSync)(e).isDirectory()){let a=(0,nn.join)(e,"index.html");return(0,Hi.existsSync)(a)?ys(t,a,{frameable:n}):!1}let i=(0,nn.extname)(e),s=Vgt[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,Hi.readFileSync)(e)),!0}catch{return!1}}async function r8(t){try{let e=await hc(X1);if(!e.ok)return;let{version:n}=await e.json();n&&kCe(t,n)&&(fL({version:n}),Qn("updateAvailable",{version:n}),a2())}catch{}}var IRe=0;function Ygt(t){let e=Date.now();e-IRe<i0.connectCheckDebounceMs||(IRe=e,r8(t))}function Xgt(t,e){if(process.env.CODESPACES!=="true"){ot(e,400,"Not running on Codespaces");return}let n=process.env.CODESPACE_NAME;if(!n){ot(e,400,"Codespace name not found");return}let r=za();r&&r.emit("codespace:stopping"),Ne(e,{success:!0,message:"Stopping codespace..."}),setTimeout(()=>(0,vm.execFile)("gh",["codespace","stop","-c",n],{windowsHide:!0}),500)}async function Jgt(t,e){let{parseJsonBody:n}=await Promise.resolve().then(()=>(Mr(),cd)),r=await n(t,e);if(!r)return;let{verifyPresentedTail:i}=await Promise.resolve().then(()=>(Gz(),oCe)),s=i({tail:r.tail,tempKey:r.tempKey});if(s.ok){Ne(e,{ok:!0});return}let o=t.headers["x-forwarded-for"]||t.socket?.remoteAddress||"unknown";if(r.tempKey&&r.tail){ra.warn(`wrong one-time code TAIL (${o}) \u2014 code burned, clearing from UI`);let{clearOneTimeKey:a}=await Promise.resolve().then(()=>(So(),tQ));a()}else r.tempKey?ra.warn(`wrong one-time code TAIL (${o}) \u2014 no TAIL presented, code still live`):ra.warn(`wrong API-key TAIL (${o}) \u2014 rejected`);setTimeout(()=>Ne(e,{ok:!1,reason:s.reason}),s.penaltyMs||0)}var ORe;async function kRe(t,e,{pathname:n}){let r=t.headers.authorization;if(!r||!r.startsWith("Bearer ")||!s1(r.slice(7),Qi()?.key)){ot(e,401,"Unauthorized");return}let{parseJsonBody:i}=await Promise.resolve().then(()=>(Mr(),cd)),s=await i(t,e);if(!s)return;if(!s.port){ot(e,400,"Port required");return}if(!n.endsWith("start")){SR(s.port),Ne(e,{success:!0});return}let o=wR(s.port);if(!o){ot(e,400,"Invalid port");return}Ne(e,{success:!0,sessionId:o})}function Qgt(t,e,{pathname:n,search:r}){let i=n.match(/^\/proxy\/([0-9a-f-]{36})(\/.*)?$/);i?Zce(ORe,t,e,i[1],i[2]||"/",r):ot(e,404,"Not found")}function Zgt(t,e,n){q_e(t,e,n)}var eyt=[{path:"/api/health",method:"GET",public:!0,handler:(t,e)=>Ne(e,{status:"ok",timestamp:Date.now()})},{path:"/api/version",method:"GET",public:!0,handler:(t,e)=>{let n="3.0.10";e.setHeader("Cache-Control","no-store"),Ne(e,{version:n})}},{path:"/api/notify",method:"POST",public:!0,handler:nRe},{path:"/api/notify",method:"GET",public:!0,handler:rRe},{path:"/proxy/*",method:"*",public:!0,handler:Qgt},{path:"/preview/*",method:"GET",public:!0,handler:Zgt},{path:"/api/ui/events",method:"GET",handler:vL},{path:"/api/local-token",method:"GET",handler:gL},{path:Il.PATH,method:"POST",handler:_Re},{path:"/api/ui/state",method:"GET",handler:EL},{path:"/api/ui/state",method:"POST",handler:wL},{path:"/api/ui/stop",method:"POST",handler:SL},{path:"/api/ui/start",method:"POST",handler:xL},{path:"/api/ui/stop-tunnel",method:"POST",handler:bL},{path:"/api/ui/shutdown",method:"POST",handler:TL},{path:"/api/update",method:"POST",handler:AL},{path:"/api/system/stats",method:"GET",handler:RRe},{path:"/api/key/one-time",method:"POST",handler:FCe},{path:"/api/key/regenerate",method:"POST",handler:qCe},{path:"/api/signaling/retry",method:"POST",handler:BCe},{path:"/api/device/approve",method:"POST",handler:$Ce},{path:"/api/device/reject",method:"POST",handler:GCe},{path:"/api/device/pending",method:"GET",handler:HCe},{path:"/api/device/approved",method:"GET",handler:jCe},{path:"/api/device/rejected",method:"GET",handler:WCe},{path:"/api/device/approve-rejected",method:"POST",handler:VCe},{path:"/api/device/clear-rejected",method:"POST",handler:zCe},{path:"/api/device/remove",method:"POST",handler:KCe},{path:"/api/device/label",method:"POST",handler:JCe},{path:"/api/device/disconnect",method:"POST",handler:YCe},{path:"/api/device/auto-approve",method:"GET",handler:XCe},{path:"/api/device/auto-approve",method:"POST",handler:QCe},{path:"/api/connections",method:"GET",handler:CL},{path:"/api/logs",method:"GET",handler:RL},{path:"/api/logs/clear",method:"POST",handler:IL},{path:"/api/permissions",method:"GET",handler:PL},{path:"/api/permissions/request",method:"POST",handler:NL},{path:"/api/desktop/toggle",method:"POST",handler:kL},{path:"/api/ui/rtc-toggle",method:"POST",handler:yL},{path:"/api/autostart",method:"GET",handler:OL},{path:"/api/autostart",method:"POST",handler:ML},{path:"/api/sleep-inhibit",method:"GET",handler:ERe},{path:"/api/sleep-inhibit",method:"POST",handler:wRe},{path:"/api/desktop-unlock",method:"GET",handler:SRe},{path:"/api/desktop-unlock/install",method:"POST",handler:xRe},{path:"/api/desktop-unlock/uninstall",method:"POST",handler:TRe},{path:"/api/desktop-unlock/type",method:"POST",handler:bRe},{path:"/api/sessions",method:"GET",handler:ARe},{path:"/api/sessions/delete",method:"POST",handler:CRe},{path:"/api/local-sites",method:"*",public:!0,handler:TCe},{path:"/api/codespace/stop",method:"POST",handler:Xgt},{path:"/api/verify-key",method:"POST",public:!0,handler:Jgt},{path:"/api/proxy/start",method:"POST",public:!0,handler:kRe},{path:"/api/proxy/end",method:"POST",public:!0,handler:kRe}];var tyt=parseInt(process.env.PORT||"2208",10),px=null;function nyt(t){if(process.platform!=="win32")try{let e=(0,vm.execSync)(`pgrep -f "vite --config ${t}"`,{encoding:"utf8"}).trim();for(let n of e.split(`
|
|
534
|
-
`).filter(Boolean))if((0,vm.execSync)(`ps -o ppid= -p ${n}`,{encoding:"utf8"}).trim()==="1")try{process.kill(Number(n))}catch{}}catch{}}function ryt(){if(!PRe)return;let t=(0,nn.join)(ia,"vite.config.js");if(!(0,Hi.existsSync)(t))return;nyt(t);let e=(0,Hi.existsSync)((0,nn.join)(ia,"node_modules",".bin","vite"))?(0,nn.join)(ia,"node_modules",".bin","vite"):(0,nn.join)(ia,"..","node_modules",".bin","vite");px=(0,vm.spawn)("node",[e,"--config",t],{cwd:ia,stdio:"ignore",detached:!1}),px.on("error",()=>{}),px.unref()}async function MRe(){let t=XD(),e=t.sleepInhibitMode;e||(t.sleepInhibit===!1?e="never":e=Te.sleepInhibit?.defaultMode||"never"),T0(e),await o2(),ORe=Qce(),ryt();let r=Q1(eyt,{fallback:(c,l,{pathname:u})=>{if(u.startsWith("/api/")||u.startsWith("/socket.io")){ot(l,404,"Not found");return}let d=u.replace(/^\//,"");if(d.split(/[\\/]/).includes("..")){ot(l,400,"Bad request");return}if((0,Hi.existsSync)(cc)&&d)try{let g=(0,nn.join)(cc,d);if((0,Hi.existsSync)(g)&&!(0,Hi.statSync)(g).isDirectory()&&ys(l,g))return}catch{}if((u==="/workspace"||u.startsWith("/workspace/")||u.startsWith("/_next/")||u==="/login"||u.startsWith("/login/"))&&(0,Hi.existsSync)(cc)){let g=(0,nn.join)(cc,d);if(ys(l,g)||ys(l,`${g}.html`)||ys(l,(0,nn.join)(g,"index.html"))||(c.headers.rsc==="1"||d.endsWith(".txt"))&&(d.startsWith("workspace/terminal/")&&ys(l,(0,nn.join)(cc,"workspace","terminal","default.txt"))||ys(l,(0,nn.join)(cc,"workspace.txt")))||u.startsWith("/workspace")&&(ys(l,(0,nn.join)(cc,"workspace.html"))||ys(l,(0,nn.join)(cc,"workspace","index.html")))||u.startsWith("/login")&&(ys(l,(0,nn.join)(cc,"login.html"))||ys(l,(0,nn.join)(cc,"login","index.html"))))return;ot(l,404,"Not found");return}let m=()=>{let g=d==="ui"||d===""?"index.html":d.replace(/^ui\/?/,""),y=(0,nn.join)(n8,g);ys(l,y)||ys(l,(0,nn.join)(n8,"index.html"))||ot(l,404,"Not found")};if(PRe){zgt(c,l,m);return}m()}}),i=(0,_1.createServer)(async(c,l)=>{if(Gx(c.headers.host)){Kgt(c,l);return}await r(c,l)});_D(),cL(),lL();let s=()=>$T().catch(c=>ra.error(`permission refresh failed: ${c?.message||c}`));s(),process.platform==="darwin"&&setInterval(s,X8),await bCe(i),i.on("error",c=>{ra.error(`HTTP server error: ${c?.message||c}`),c?.code==="EADDRINUSE"&&process.exit(1)}),i.listen(tyt,c=>{if(c)throw c;let l="3.0.
|
|
532
|
+
`)[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 f.default(function(C,D){return(0,m.exec)(T[w],{},function($,G,V){if($)return D(new Error("Error while obtaining machine id: "+$.stack));var L=c(G.toString());return C(R?L:a(L))})})}Object.defineProperty(r,"__esModule",{value:!0});var d=i(35),f=s(d);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,d){var f,m=s(l),g=o(m.length),y=a(d,g);if(c&&u!=u){for(;g>y;)if(f=m[y++],f!=f)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),d={},f={},m=n.exports=function(g,y,w,S,T){var R,C,D,$,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($=y?V(c(C=g[L])[0],C[1]):V(g[L]),$===d||$===f)return $}else for(D=G.call(g);!(C=D.next()).done;)if($=o(D,V,C.value,y),$===d||$===f)return $};m.BREAK=d,m.RETURN=f},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(d){var u=o.return;throw u!==void 0&&s(u.call(o)),d}}},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,d){l.prototype=s(c,{next:o(1,d)}),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 d=[7],f=d[s]();f.next=function(){return{done:u=!0}},d[s]=function(){return f},c(d)}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 d,f,m,g=function(){var T,R;for(u&&(T=c.domain)&&T.exit();d;){R=d.fn,d=d.next;try{R()}catch(C){throw d?m():f=void 0,C}}f=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};f&&(f.next=R),d||(d=R,m()),f=R}}},function(n,r,i){var s=i(3),o=i(50),a=i(22),c=i(19)("IE_PROTO"),l=function(){},u="prototype",d=function(){var f,m=i(16)("iframe"),g=a.length,y=">";for(m.style.display="none",i(25).appendChild(m),m.src="javascript:",f=m.contentWindow.document,f.open(),f.write("<script>document.F=Object</script"+y),f.close(),d=f.F;g--;)delete d[u][a[g]];return d()};n.exports=Object.create||function(f,m){var g;return f!==null?(l[u]=s(f),g=new l,l[u]=null,g[c]=f):g=d(),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,d=a(l),f=d.length,m=0;f>m;)s.f(c,u=d[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),d=Object.getOwnPropertyDescriptor;r.f=i(4)?d:function(f,m){if(f=a(f),m=c(m,!0),u)try{return d(f,m)}catch{}if(l(f,m))return o(!s.f.call(f,m),f[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 d,f=o(l),m=0,g=[];for(d in f)d!=c&&s(f,d)&&g.push(d);for(;u.length>m;)s(f,d=u[m++])&&(~a(g,d)||g.push(d));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(d,f){return a(d,f),l?d.__proto__=f:u(d,f),d}})({},!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 d=typeof o[u]=="function"?o[u]:s[u];c&&d&&!d[l]&&a.f(d,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,d=s(c).constructor;return d===void 0||(u=s(d)[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,d,f=String(o(c)),m=s(l),g=f.length;return m<0||m>=g?a?"":void 0:(u=f.charCodeAt(m),u<55296||u>56319||m+1===g||(d=f.charCodeAt(m+1))<56320||d>57343?a?f.charAt(m):u:a?f.slice(m,m+2):(u-55296<<10)+(d-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,d=this._i++;return!l||d>=l.length?(this._t=void 0,o(1)):u=="keys"?o(0,d):u=="values"?o(0,l[d]):o(0,[d,l[d]])},"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),d=i(21),f=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,$=l[C],G=l.process,V=d(G)=="process",L=function(){},k=!!(function(){try{var oe=$.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===$&&J===a},A=function(oe){var J;return!(!m(oe)||typeof(J=oe.then)!="function")&&J},M=function(oe){return E($,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,lt=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>lt;)Ue(ve[lt++]);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})})},q=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(q,we,1))}catch(Se){q.call(we,Se)}}):(ve._v=oe,ve._s=1,F(ve,!1))}catch(we){q.call({_w:ve,_d:!1},we)}}};k||($=function(oe){y(this,$,C,"_h"),g(oe),s.call(this);try{oe(u(pe,this,1),u(q,this,1))}catch(J){q.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)($.prototype,{then:function(oe,J){var ve=M(S(this,$));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(q,oe,1)}),f(f.G+f.W+f.F*!k,{Promise:$}),i(18)($,C),i(59)(C),a=i(6)[C],f(f.S+f.F*!k,C,{reject:function(oe){var J=M(this),ve=J.reject;return ve(oe),J.promise}}),f(f.S+f.F*(c||!k),C,{resolve:function(oe){if(oe instanceof $&&E(oe.constructor,this))return oe;var J=M(this),ve=J.resolve;return ve(oe),J.promise}}),f(f.S+f.F*!(k&&i(46)(function(oe){$.all(oe).catch(L)})),C,{all:function(oe){var J=this,ve=M(J),we=ve.resolve,Se=ve.reject,lt=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 lt&&Se(lt.error),ve.promise},race:function(oe){var J=this,ve=M(J),we=ve.reject,Se=P(function(){w(oe,!1,function(lt){J.resolve(lt).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 d=l[u],f=s[d],m=f&&f.prototype;m&&!m[c]&&o(m,c,d),a[d]=a.Array}},function(n,r){n.exports=require("child_process")},function(n,r){n.exports=require("crypto")}])})});var iyt={};gr(iyt,{startServer:()=>MRe});module.exports=RIe(iyt);var _1=require("http"),vm=require("child_process"),Hi=require("fs"),nn=require("path"),v1=require("url");Mr();Z1();Lt();tt();Td();zq();cj();$a();Cq();Wf();Sd();async function TCe(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(!s1(r,Qi()?.key)){e.setHeader("Content-Type","application/json"),e.writeHead(401),e.end(JSON.stringify({error:"Unauthorized: Invalid API key"}));return}let i=await gR();e.setHeader("Content-Type","application/json"),e.writeHead(200),e.end(JSON.stringify(i))}Wf();mT();var RCe=require("url");var m1=ce(require("path"),1),ICe=ce(require("os"),1);Lt();var ACe=ce(require("path"),1),CCe=ce(require("os"),1);var ODt=ACe.default.join(CCe.default.homedir(),".9remote","pids");ZD();Cp();var $Dt=m1.default.dirname((0,RCe.fileURLToPath)(__importMetaUrl));var GDt=m1.default.join(ICe.default.homedir(),".9remote","cloudflared.pid");function kCe(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 HDt=m1.default.join(Oe.STATE,i0.lockFile);So();$a();Cp();Mr();Sd();Wf();var OCe=ce(PCe(),1),Jz=ce(require("crypto"),1),{machineIdSync:Rgt}=OCe.default;async function MCe(t=null){let e=t||process.env.MACHINE_ID_SALT||"9remote-salt";try{let n=Rgt();return Jz.default.createHash("sha256").update(n+e).digest("hex").substring(0,16)}catch(n){return console.error("Error getting machine ID:",n),Jz.default.randomUUID().replace(/-/g,"").substring(0,16)}}So();Lt();tt();m0();Wf();Pz();var NCe=xe("session"),Igt=10;async function DCe(t,e){try{let n=await hc(`${e}/api/temp-key/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((()=>{let s={apiKey:Gn(t),expiryMinutes:Igt};return{...s,...bT(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=YAe();return JAe(r.tempKey,i,r.expiresAt,e),{...r,oneTimeKey:`${r.tempKey}${i}`}}catch(n){return NCe.error(`Temp key creation failed: ${n?.message||n}`),null}}function LCe(t,e){return e?.tempKey?`${t}/login?k=${e.tempKey}#${e.oneTimeKey}`:`${t}/login`}async function UCe(t,e,n,r){try{let i=await hc(`${e}/api/session/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Gn(t),hostPublicKey:ST(),hostX25519Key:xT(),tempKey:sx()?.tempKey||void 0})});if(!i.ok)throw new Error(`HTTP ${i.status}`);return n&&await hc(`${e}/api/session/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Gn(t),tunnelUrl:n,...bT({apiKey:Gn(t),tunnelUrl:n})})}).catch(()=>{}),r&&Gn(r)!==Gn(t)&&await hc(`${e}/api/session/delete`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:Gn(r),...bT({apiKey:Gn(r)})})}).catch(()=>{}),!0}catch(i){return NCe.error(`Session registration failed: ${i?.message||i}`),!1}}a0();Wf();Cp();async function FCe(t,e){let n=FT(),r=n.workerUrl||Ec;if(!n.permanentKey){ot(e,400,"No permanent key set");return}let i=await DCe(n.permanentKey,r);if(!i){ot(e,500,"Temp key creation failed");return}let s=LCe(r,i);Rc({oneTimeKey:i.oneTimeKey,oneTimeKeyExpiresAt:i.expiresAt,qrUrl:s}),Ne(e,{oneTimeKey:i.oneTimeKey,expiresAt:i.expiresAt,qrUrl:s})}async function BCe(t,e){fT("session-registered"),Ne(e,pT())}async function qCe(t,e){try{let n=FT(),r=n.workerUrl||Ec,i=await MCe(),s=eCe(i),o=Qi();if(!await UCe(s,r,n.tunnelUrl,o?.key)){ot(e,502,"Could not register the new key with the server");return}A7(i,s,o?.name||"Default"),o0(Gn(s)),Rc({permanentKey:s,oneTimeKey:"",oneTimeKeyExpiresAt:null,qrUrl:"",pairingUsed:!0}),Ne(e,{ok:!0,permanentKey:s})}catch(n){ot(e,500,n.message)}}Mr();Td();I0();async function $Ce(t,e){let n=await Or(t,e);if(!n)return;let r=wCe(n.socketId);Ne(e,{ok:r})}async function GCe(t,e){let n=await Or(t,e);if(!n)return;let r=xCe(n.socketId);Ne(e,{ok:r})}function HCe(t,e){Ne(e,{pending:mQ()})}function jCe(t,e){Ne(e,{devices:pQ()})}function WCe(t,e){Ne(e,{rejected:yQ()})}async function VCe(t,e){let n=await Or(t,e);if(!n)return;let r=SCe(n.deviceId);Ne(e,{ok:r})}async function zCe(t,e){let n=await Or(t,e);n&&(h1(n.deviceId),$g(n.deviceId),Ne(e))}async function KCe(t,e){let n=await Or(t,e);n&&(h1(n.deviceId),uQ(n.deviceId),Ne(e))}async function YCe(t,e){let n=await Or(t,e);if(!n)return;cQ(n.deviceId);let r=h1(n.deviceId);Ne(e,{disconnected:r})}function XCe(t,e){Ne(e,{enabled:HL()})}async function JCe(t,e){let n=await Or(t,e);if(!n)return;let r=dQ(n.deviceId,n.label);Ne(e,{ok:r})}async function QCe(t,e){let n=await Or(t,e);if(!n)return;let r=vQ(!!n.enabled);Ne(e,{enabled:r})}Mr();Td();Zi();hR();Ds();Lc();n2();Az();var ZCe={},kgt=1e4;function Pgt(t,e){if(e?.csid&&Bd.test(e.csid))return e.csid;let{sessionId:n,...r}=e||{};return ine(t,r)}function tRe(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 nRe(t,e){let n="";await new Promise(r=>{t.on("data",i=>n+=i),t.on("end",r)});try{iRe(tRe(n,null)),Ne(e,{success:!0})}catch{ot(e,400,"Invalid JSON")}}function rRe(t,e,{query:n}){iRe(tRe(null,n)),Ne(e,{success:!0})}function eRe(t,e,n){let{type:r,sessionId:i,tool:s}=t,o={type:r,sessionId:i,tool:s,timestamp:n},c=eh({type:r,sessionId:i,tool:s})?.state||Jt.IDLE,l=rs(i);if(et(e,"statusChange",{sessionId:i,state:c,tool:s,since:n,...l?{conversationId:l.id}:{}}),mF(i,o),et(e,"chatNotification",o),(c===Jt.DONE||c===Jt.BLOCKED)&&BA(i),(c===Jt.DONE||c===Jt.BLOCKED)&&Tz(i),c!==Jt.DONE&&c!==Jt.BLOCKED)return;let u=`${i}:${c}`;n-(ZCe[u]||0)<kgt||(ZCe[u]=n,nce({...o,state:c}))}function iRe(t){let{type:e,sessionId:n,tool:r}=t,i=Date.now(),s=za();if(!s||!n)return;let o=Pgt(r,t);if(o&&Ma(n,r,o,"hook"),UA[e]===Jt.DONE){$A(n,()=>eRe(t,s,Date.now()));return}eRe(t,s,i)}Mr();Xq();RR();Lt();var Qz=ce(require("fs"),1),g1=ce(require("path"),1);Td();Zi();mh();$a();var Ogt=process.platform==="darwin"||process.platform==="win32",sRe=t=>Ogt?t.toLowerCase():t,oRe=(t,e)=>{let n=sRe(t),r=sRe(e);return n===r||n.startsWith(r+g1.default.sep)},aRe=t=>[t.cwd,t.workspacePath].filter(Boolean);function Mgt(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 aRe(s))oRe(t,o)&&o.length>i&&(r=s.id,i=o.length);return r}function cRe({path:t,title:e},n=null){if(!t||typeof t!="string")return{error:"path is required"};let r=g1.default.resolve(t);try{r=Qz.default.realpathSync(r)}catch{return{error:"File not found"}}if(wt(r))return{error:"Access denied"};if(!Qz.default.statSync(r).isFile())return{error:"Not a file"};let i=gu(),s=i.filter(c=>aRe(c).some(l=>oRe(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=za();if(!o)return{error:"Server not ready"};let a=Mgt(r,n,s);return et(o,"artifactOpen",{path:r,title:e||g1.default.basename(r),sessionId:a}),{path:r}}var Ngt={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=cRe({path:t,title:e},n?.sessionId);return r.error?r:`Opened ${r.path}`}},lRe=Ngt;cS();kj();var Dgt=500;function Lgt(t={applyAction:D_}){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:Ij,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,Dgt);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 uRe=Lgt();qk();var dRe=[lRe],fRe=new Map([...dRe,...Af,uRe].map(t=>[t.name,t])),pRe=()=>dRe.map(({name:t,description:e,inputSchema:n})=>({name:t,description:e,inputSchema:n}));var y1=(t,e=!1)=>({content:[{type:"text",text:t}],isError:e});async function Ugt(t,e,n){let r=fRe.get(t);if(!r)return y1(`Unknown tool: ${t}`,!0);try{let i=await r.run(e||{},n||{});return i?.error?y1(i.error,!0):y1(typeof i=="string"?i:JSON.stringify(i))}catch(i){return y1(i.message,!0)}}async function hRe(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||Il.PROTOCOL_VERSION,capabilities:{tools:{}},serverInfo:{name:Il.SERVER_NAME,version:"3.0.11"}}):r==="tools/list"?s({tools:pRe()}):r==="tools/call"?s(await Ugt(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 e8=ce(require("fs"),1),gRe=require("child_process");tt();Kq();var Fgt=xe("artifact"),mRe=/(?:^|[\s\0])NINE_REMOTE_SESSION_ID=([^\s\0]+)/,Zz=new WeakMap,t8=(t,e)=>(0,gRe.execFileSync)(t,e,{encoding:"utf8",timeout:Gy.PROBE_TIMEOUT_MS,stdio:["ignore","pipe","ignore"]});function Bgt(t,e){let n=t8("lsof",["-nP",`-iTCP:${t}`,"-Fpn"]),r=null;for(let i of n.split(`
|
|
533
|
+
`))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 qgt(t){try{return process.platform==="linux"?e8.default.readFileSync(`/proc/${t}/environ`,"utf8").match(mRe)?.[1]||null:t8("ps",["-Eww","-o","command=","-p",String(t)]).match(mRe)?.[1]||null}catch{return null}}function $gt(t){try{if(process.platform==="linux"){let e=e8.default.readFileSync(`/proc/${t}/stat`,"utf8");return parseInt(e.slice(e.lastIndexOf(")")+2).split(" ")[1],10)||null}return parseInt(t8("ps",["-o","ppid=","-p",String(t)]).trim(),10)||null}catch{return null}}function Ggt(t){for(let e=0;t>1&&t!==process.pid&&e<Gy.MAX_PARENT_HOPS;e++){let n=qgt(t);if(n)return n;if(t=$gt(t),!t)return null}return null}function yRe(t){let e=t?.headers?.[Gy.HEADER];if(e&&!/[${}]/.test(e))return e;let n=t?.socket;if(!n)return null;if(Zz.has(n))return Zz.get(n);let r=null;try{let i=Bgt(n.remotePort,process.pid);i&&(r=Ggt(i))}catch(i){Fgt.warn(`caller probe failed: ${i.message}`)}return Zz.set(n,r),r}async function _Re(t,e){if(!nle(t.headers.authorization))return ot(e,401,"Unauthorized");if(!XE())return ot(e,403,"MCP is turned off in 9Remote settings");let n=await Or(t,e);if(n===null&&!e.writableEnded)return ot(e,400,"Invalid request");if(e.writableEnded)return;let r;try{r=await hRe(n,{sessionId:yRe(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))}Mr();NT();Sd();qr();So();function vRe(){return{mode:sL(),active:iL(),presets:Object.keys(Te.sleepInhibit?.presets||{})}}function ERe(t,e){Ne(e,vRe())}async function wRe(t,e){let n=await Or(t,e);if(!n)return;let r=T0(n.mode);T7({sleepInhibitMode:r});let i=vRe();Qn("sleepInhibit",i),Ne(e,i)}Mr();oU();async function SRe(t,e){let n=await nA();Ne(e,n)}async function xRe(t,e){let n=await QQ(),r=await nA();Ne(e,{...n,...r})}async function bRe(t,e){let n=await Or(t,e);if(!n)return;if(typeof n.text!="string"||!n.text){ot(e,400,"Missing text");return}let r=await L0(n.text);Ne(e,{ok:r.ok,reason:r.reason||null})}async function TRe(t,e){let n=await JQ(),r=await nA();Ne(e,{...n,...r})}mi();Mr();async function ARe(t,e){try{let n=await Cd();Ne(e,{sessions:n})}catch(n){ot(e,500,n.message)}}async function CRe(t,e){let n=await Or(t,e);if(n){if(!n.sessionId)return ot(e,400,"sessionId required");try{await Rd(n.sessionId),Ne(e)}catch(r){ot(e,500,r.message)}}}var zu=ce(require("os"),1);qr();hA();Mr();function Hgt(){let t=$Z();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 jgt(){let t=process.memoryUsage(),e=zu.default.cpus();return{agent:{pid:process.pid,version:"3.0.11",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:zu.default.hostname(),platform:zu.default.platform(),arch:zu.default.arch(),uptimeSec:Math.round(zu.default.uptime()),loadAvg:zu.default.loadavg(),cpuModel:e?.[0]?.model||"unknown",cpuCount:e.length,totalMemMB:Math.round(zu.default.totalmem()/1048576),freeMemMB:Math.round(zu.default.freemem()/1048576)},remote:{available:pA(),...Hgt(),memoryWarningThresholdMB:Te.resourceManagement.memoryWarningThreshold},timestamp:Date.now()}}function RRe(t,e){try{Ne(e,jgt())}catch(n){ot(e,500,"stats error",n.message)}}NT();Sd();qr();Y8();fK();var ra=xe("server"),ia=(0,v1.fileURLToPath)(new URL(".",__importMetaUrl)),PRe=process.env.NODE_ENV==="development",Wgt=5173,n8=[(0,nn.join)(ia,"dist","ui"),(0,nn.join)(ia,"ui","dist"),(0,nn.join)(ia,"ui")].find(t=>(0,Hi.existsSync)(t))||(0,nn.join)(ia,"dist","ui"),cc=[(0,nn.join)(ia,"dist","web"),(0,nn.join)(ia,"web"),(0,nn.join)(ia,"..","web","out")].find(t=>(0,Hi.existsSync)(t))||n8,Vgt={".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 zgt(t,e,n){let r=(0,_1.request)({hostname:"localhost",port:Wgt,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 Kgt(t,e){let n;try{n=(0,v1.parse)(t.url).pathname}catch{ot(e,400,"Bad request");return}let r=lK(n,t.headers.host);if(!r){ot(e,404,"Not found");return}for(let[i,s]of Object.entries(r.headers))e.setHeader(i,s);ys(e,(0,nn.join)(cc,r.path),{frameable:!0})||ot(e,404,"Not found")}function ys(t,e,{frameable:n=!1}={}){if(!(0,Hi.existsSync)(e))return!1;try{if((0,Hi.statSync)(e).isDirectory()){let a=(0,nn.join)(e,"index.html");return(0,Hi.existsSync)(a)?ys(t,a,{frameable:n}):!1}let i=(0,nn.extname)(e),s=Vgt[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,Hi.readFileSync)(e)),!0}catch{return!1}}async function r8(t){try{let e=await hc(X1);if(!e.ok)return;let{version:n}=await e.json();n&&kCe(t,n)&&(fL({version:n}),Qn("updateAvailable",{version:n}),a2())}catch{}}var IRe=0;function Ygt(t){let e=Date.now();e-IRe<i0.connectCheckDebounceMs||(IRe=e,r8(t))}function Xgt(t,e){if(process.env.CODESPACES!=="true"){ot(e,400,"Not running on Codespaces");return}let n=process.env.CODESPACE_NAME;if(!n){ot(e,400,"Codespace name not found");return}let r=za();r&&r.emit("codespace:stopping"),Ne(e,{success:!0,message:"Stopping codespace..."}),setTimeout(()=>(0,vm.execFile)("gh",["codespace","stop","-c",n],{windowsHide:!0}),500)}async function Jgt(t,e){let{parseJsonBody:n}=await Promise.resolve().then(()=>(Mr(),cd)),r=await n(t,e);if(!r)return;let{verifyPresentedTail:i}=await Promise.resolve().then(()=>(Gz(),oCe)),s=i({tail:r.tail,tempKey:r.tempKey});if(s.ok){Ne(e,{ok:!0});return}let o=t.headers["x-forwarded-for"]||t.socket?.remoteAddress||"unknown";if(r.tempKey&&r.tail){ra.warn(`wrong one-time code TAIL (${o}) \u2014 code burned, clearing from UI`);let{clearOneTimeKey:a}=await Promise.resolve().then(()=>(So(),tQ));a()}else r.tempKey?ra.warn(`wrong one-time code TAIL (${o}) \u2014 no TAIL presented, code still live`):ra.warn(`wrong API-key TAIL (${o}) \u2014 rejected`);setTimeout(()=>Ne(e,{ok:!1,reason:s.reason}),s.penaltyMs||0)}var ORe;async function kRe(t,e,{pathname:n}){let r=t.headers.authorization;if(!r||!r.startsWith("Bearer ")||!s1(r.slice(7),Qi()?.key)){ot(e,401,"Unauthorized");return}let{parseJsonBody:i}=await Promise.resolve().then(()=>(Mr(),cd)),s=await i(t,e);if(!s)return;if(!s.port){ot(e,400,"Port required");return}if(!n.endsWith("start")){SR(s.port),Ne(e,{success:!0});return}let o=wR(s.port);if(!o){ot(e,400,"Invalid port");return}Ne(e,{success:!0,sessionId:o})}function Qgt(t,e,{pathname:n,search:r}){let i=n.match(/^\/proxy\/([0-9a-f-]{36})(\/.*)?$/);i?Zce(ORe,t,e,i[1],i[2]||"/",r):ot(e,404,"Not found")}function Zgt(t,e,n){q_e(t,e,n)}var eyt=[{path:"/api/health",method:"GET",public:!0,handler:(t,e)=>Ne(e,{status:"ok",timestamp:Date.now()})},{path:"/api/version",method:"GET",public:!0,handler:(t,e)=>{let n="3.0.11";e.setHeader("Cache-Control","no-store"),Ne(e,{version:n})}},{path:"/api/notify",method:"POST",public:!0,handler:nRe},{path:"/api/notify",method:"GET",public:!0,handler:rRe},{path:"/proxy/*",method:"*",public:!0,handler:Qgt},{path:"/preview/*",method:"GET",public:!0,handler:Zgt},{path:"/api/ui/events",method:"GET",handler:vL},{path:"/api/local-token",method:"GET",handler:gL},{path:Il.PATH,method:"POST",handler:_Re},{path:"/api/ui/state",method:"GET",handler:EL},{path:"/api/ui/state",method:"POST",handler:wL},{path:"/api/ui/stop",method:"POST",handler:SL},{path:"/api/ui/start",method:"POST",handler:xL},{path:"/api/ui/stop-tunnel",method:"POST",handler:bL},{path:"/api/ui/shutdown",method:"POST",handler:TL},{path:"/api/update",method:"POST",handler:AL},{path:"/api/system/stats",method:"GET",handler:RRe},{path:"/api/key/one-time",method:"POST",handler:FCe},{path:"/api/key/regenerate",method:"POST",handler:qCe},{path:"/api/signaling/retry",method:"POST",handler:BCe},{path:"/api/device/approve",method:"POST",handler:$Ce},{path:"/api/device/reject",method:"POST",handler:GCe},{path:"/api/device/pending",method:"GET",handler:HCe},{path:"/api/device/approved",method:"GET",handler:jCe},{path:"/api/device/rejected",method:"GET",handler:WCe},{path:"/api/device/approve-rejected",method:"POST",handler:VCe},{path:"/api/device/clear-rejected",method:"POST",handler:zCe},{path:"/api/device/remove",method:"POST",handler:KCe},{path:"/api/device/label",method:"POST",handler:JCe},{path:"/api/device/disconnect",method:"POST",handler:YCe},{path:"/api/device/auto-approve",method:"GET",handler:XCe},{path:"/api/device/auto-approve",method:"POST",handler:QCe},{path:"/api/connections",method:"GET",handler:CL},{path:"/api/logs",method:"GET",handler:RL},{path:"/api/logs/clear",method:"POST",handler:IL},{path:"/api/permissions",method:"GET",handler:PL},{path:"/api/permissions/request",method:"POST",handler:NL},{path:"/api/desktop/toggle",method:"POST",handler:kL},{path:"/api/ui/rtc-toggle",method:"POST",handler:yL},{path:"/api/autostart",method:"GET",handler:OL},{path:"/api/autostart",method:"POST",handler:ML},{path:"/api/sleep-inhibit",method:"GET",handler:ERe},{path:"/api/sleep-inhibit",method:"POST",handler:wRe},{path:"/api/desktop-unlock",method:"GET",handler:SRe},{path:"/api/desktop-unlock/install",method:"POST",handler:xRe},{path:"/api/desktop-unlock/uninstall",method:"POST",handler:TRe},{path:"/api/desktop-unlock/type",method:"POST",handler:bRe},{path:"/api/sessions",method:"GET",handler:ARe},{path:"/api/sessions/delete",method:"POST",handler:CRe},{path:"/api/local-sites",method:"*",public:!0,handler:TCe},{path:"/api/codespace/stop",method:"POST",handler:Xgt},{path:"/api/verify-key",method:"POST",public:!0,handler:Jgt},{path:"/api/proxy/start",method:"POST",public:!0,handler:kRe},{path:"/api/proxy/end",method:"POST",public:!0,handler:kRe}];var tyt=parseInt(process.env.PORT||"2208",10),px=null;function nyt(t){if(process.platform!=="win32")try{let e=(0,vm.execSync)(`pgrep -f "vite --config ${t}"`,{encoding:"utf8"}).trim();for(let n of e.split(`
|
|
534
|
+
`).filter(Boolean))if((0,vm.execSync)(`ps -o ppid= -p ${n}`,{encoding:"utf8"}).trim()==="1")try{process.kill(Number(n))}catch{}}catch{}}function ryt(){if(!PRe)return;let t=(0,nn.join)(ia,"vite.config.js");if(!(0,Hi.existsSync)(t))return;nyt(t);let e=(0,Hi.existsSync)((0,nn.join)(ia,"node_modules",".bin","vite"))?(0,nn.join)(ia,"node_modules",".bin","vite"):(0,nn.join)(ia,"..","node_modules",".bin","vite");px=(0,vm.spawn)("node",[e,"--config",t],{cwd:ia,stdio:"ignore",detached:!1}),px.on("error",()=>{}),px.unref()}async function MRe(){let t=XD(),e=t.sleepInhibitMode;e||(t.sleepInhibit===!1?e="never":e=Te.sleepInhibit?.defaultMode||"never"),T0(e),await o2(),ORe=Qce(),ryt();let r=Q1(eyt,{fallback:(c,l,{pathname:u})=>{if(u.startsWith("/api/")||u.startsWith("/socket.io")){ot(l,404,"Not found");return}let d=u.replace(/^\//,"");if(d.split(/[\\/]/).includes("..")){ot(l,400,"Bad request");return}if((0,Hi.existsSync)(cc)&&d)try{let g=(0,nn.join)(cc,d);if((0,Hi.existsSync)(g)&&!(0,Hi.statSync)(g).isDirectory()&&ys(l,g))return}catch{}if((u==="/workspace"||u.startsWith("/workspace/")||u.startsWith("/_next/")||u==="/login"||u.startsWith("/login/"))&&(0,Hi.existsSync)(cc)){let g=(0,nn.join)(cc,d);if(ys(l,g)||ys(l,`${g}.html`)||ys(l,(0,nn.join)(g,"index.html"))||(c.headers.rsc==="1"||d.endsWith(".txt"))&&(d.startsWith("workspace/terminal/")&&ys(l,(0,nn.join)(cc,"workspace","terminal","default.txt"))||ys(l,(0,nn.join)(cc,"workspace.txt")))||u.startsWith("/workspace")&&(ys(l,(0,nn.join)(cc,"workspace.html"))||ys(l,(0,nn.join)(cc,"workspace","index.html")))||u.startsWith("/login")&&(ys(l,(0,nn.join)(cc,"login.html"))||ys(l,(0,nn.join)(cc,"login","index.html"))))return;ot(l,404,"Not found");return}let m=()=>{let g=d==="ui"||d===""?"index.html":d.replace(/^ui\/?/,""),y=(0,nn.join)(n8,g);ys(l,y)||ys(l,(0,nn.join)(n8,"index.html"))||ot(l,404,"Not found")};if(PRe){zgt(c,l,m);return}m()}}),i=(0,_1.createServer)(async(c,l)=>{if(Gx(c.headers.host)){Kgt(c,l);return}await r(c,l)});_D(),cL(),lL();let s=()=>$T().catch(c=>ra.error(`permission refresh failed: ${c?.message||c}`));s(),process.platform==="darwin"&&setInterval(s,X8),await bCe(i),i.on("error",c=>{ra.error(`HTTP server error: ${c?.message||c}`),c?.code==="EADDRINUSE"&&process.exit(1)}),i.listen(tyt,c=>{if(c)throw c;let l="3.0.11";r8(l),setInterval(()=>r8(l),i0.checkIntervalMs),c2(()=>Ygt(l))});let o=!1,a=async c=>{if(o)return;o=!0,rL(),ra.info(`\u{1F6D1} Received ${c}, shutting down gracefully...`);let l=setTimeout(()=>{ra.error("\u26A0\uFE0F Forced exit"),process.exit(1)},5e3);try{if(i.close(()=>ra.info("\u2713 HTTP server closed")),px)try{px.kill()}catch{}let u=za();u&&(u.emit("server:shutdown"),u.close(()=>ra.info("\u2713 Socket.IO closed"))),await new Promise(d=>setTimeout(d,500)),clearTimeout(l),ra.info("\u2705 Server stopped cleanly"),process.exit(0)}catch(u){ra.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}MRe().catch(t=>{ra.error(`Server failed to start: ${t?.stack||t?.message||t}`),process.exit(1)});0&&(module.exports={startServer});
|
|
535
535
|
/*! Bundled license information:
|
|
536
536
|
|
|
537
537
|
negotiator/index.js:
|