@softdesignbrasil/productdock-cli 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/dist/productdock.js +79 -79
  2. package/package.json +2 -2
@@ -1,64 +1,64 @@
1
1
  #!/usr/bin/env node
2
- var D2=Object.create;var{getPrototypeOf:I2,defineProperty:z1,getOwnPropertyNames:N2}=Object;var V2=Object.prototype.hasOwnProperty;function E2($){return this[$]}var k2,P2,b3=($,J,Z)=>{var Q=$!=null&&typeof $==="object";if(Q){var Y=J?k2??=new WeakMap:P2??=new WeakMap,q=Y.get($);if(q)return q}Z=$!=null?D2(I2($)):{};let z=J||!$||!$.__esModule?z1(Z,"default",{value:$,enumerable:!0}):Z;for(let F of N2($))if(!V2.call(z,F))z1(z,F,{get:E2.bind($,F),enumerable:!0});if(Q)Y.set($,z);return z};var B2=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var b2=($)=>$;function R2($,J){this[$]=b2.bind(null,J)}var y0=($,J)=>{for(var Z in J)z1($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:R2.bind(J,Z)})};var S=($,J)=>()=>($&&(J=$($=0)),J);import f3 from"node:fs";function C2(){try{return f3.statSync("/.dockerenv"),!0}catch{return!1}}function A2(){try{return f3.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function K1(){if(H1===void 0)H1=C2()||A2();return H1}var H1;var v3=()=>{};import _2 from"node:fs";function z0(){if(W1===void 0)W1=T2()||K1();return W1}var W1,T2=()=>{try{return _2.statSync("/run/.containerenv"),!0}catch{return!1}};var L1=S(()=>{v3()});import C3 from"node:process";import y2 from"node:os";import U1 from"node:fs";var O3=()=>{if(C3.platform!=="linux")return!1;if(y2.release().toLowerCase().includes("microsoft")){if(z0())return!1;return!0}try{if(U1.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!z0()}catch{}if(U1.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||U1.existsSync("/run/WSL"))return!z0();return!1},o;var M1=S(()=>{L1();o=C3.env.__IS_WSL_TEST__?O3:O3()});import A3 from"node:process";import{Buffer as x2}from"node:buffer";import{promisify as h2}from"node:util";import u2 from"node:child_process";var g2,j1=()=>`${A3.env.SYSTEMROOT||A3.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,g=async($,J={})=>{let{powerShellPath:Z,...Q}=J,Y=g.encodeCommand($);return g2(Z??j1(),[...g.argumentsPrefix,Y],{encoding:"utf8",...Q})};var D1=S(()=>{g2=h2(u2.execFile);g.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];g.encodeCommand=($)=>x2.from($,"utf16le").toString("base64");g.escapeArgument=($)=>`'${String($).replaceAll("'","''")}'`});function _3($){for(let J of $.split(`
3
- `)){if(/^\s*#/.test(J))continue;let Z=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(J);if(!Z)continue;return Z.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}import{promisify as m2}from"node:util";import c2 from"node:child_process";import N1,{constants as y3}from"node:fs/promises";var d2,l2,p2=async()=>{return`${await l2()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},m0,T3,x3=async()=>{return T3??=(async()=>{try{let $=await m0();return await N1.access($,y3.X_OK),!0}catch{return!1}})(),T3},h3=async()=>{let $=await m0(),J=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:Z}=await g(J,{powerShellPath:$});return Z.trim()},u3=async($)=>{if(/^[a-z]+:\/\//i.test($))return $;try{let{stdout:J}=await d2("wslpath",["-aw",$],{encoding:"utf8"});return J.trim()}catch{return $}};var g3=S(()=>{M1();D1();M1();d2=m2(c2.execFile),l2=(()=>{let J;return async function(){if(J)return J;let Z="/etc/wsl.conf",Q=!1;try{await N1.access(Z,y3.F_OK),Q=!0}catch{}if(!Q)return"/mnt/";let Y=await N1.readFile(Z,{encoding:"utf8"}),q=_3(Y);if(q===void 0)return"/mnt/";return J=q,J=J.endsWith("/")?J:`${J}/`,J}})(),m0=o?p2:j1});function G0($,J,Z){let Q=(Y)=>Object.defineProperty($,J,{value:Y,enumerable:!0,writable:!0});return Object.defineProperty($,J,{configurable:!0,enumerable:!0,get(){let Y=Z();return Q(Y),Y},set(Y){Q(Y)}}),$}import{promisify as a2}from"node:util";import i2 from"node:process";import{execFile as n2}from"node:child_process";async function V1(){if(i2.platform!=="darwin")throw Error("macOS only");let{stdout:$}=await r2("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),Z=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec($)?.groups.id??"com.apple.Safari";if(Z==="com.apple.safari")return"com.apple.Safari";return Z}var r2;var m3=S(()=>{r2=a2(n2)});import o2 from"node:process";import{promisify as s2}from"node:util";import{execFile as t2,execFileSync as o4}from"node:child_process";async function c3($,{humanReadableOutput:J=!0,signal:Z}={}){if(o2.platform!=="darwin")throw Error("macOS only");let Q=J?[]:["-ss"],Y={};if(Z)Y.signal=Z;let{stdout:q}=await e2("osascript",["-e",$,Q],Y);return q.trim()}var e2;var d3=S(()=>{e2=s2(t2)});async function E1($){return c3(`tell application "Finder" to set app_path to application file id "${$}" as string
4
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var l3=S(()=>{d3()});import{promisify as $$}from"node:util";import{execFile as J$}from"node:child_process";async function k1($=Z$){let{stdout:J}=await $("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),Z=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(J);if(!Z)throw new p3(`Cannot find Windows browser in stdout: ${JSON.stringify(J)}`);let{id:Q}=Z.groups,Y=Q.lastIndexOf("."),q=Q.lastIndexOf("-"),z=Y===-1?void 0:Q.slice(0,Y),F=q===-1?void 0:Q.slice(0,q);return c0[Q]??c0[z]??c0[F]??{name:Q,id:Q}}var Z$,c0,d0,p3;var P1=S(()=>{Z$=$$(J$),c0={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},d0=new Map(Object.entries(c0));p3=class p3 extends Error{}});import{promisify as Q$}from"node:util";import B1 from"node:process";import{execFile as Y$}from"node:child_process";async function b1(){if(B1.platform==="darwin"){let $=await V1();return{name:await E1($),id:$}}if(B1.platform==="linux"){let{stdout:$}=await q$("xdg-mime",["query","default","x-scheme-handler/http"]),J=$.trim();return{name:z$(J.replace(/.desktop$/,"").replace("-"," ")),id:J}}if(B1.platform==="win32")return k1();throw Error("Only macOS, Linux, and Windows are supported")}var q$,z$=($)=>$.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(J)=>J.toUpperCase());var a3=S(()=>{m3();l3();P1();P1();q$=Q$(Y$)});import R1 from"node:process";var G$,i3;var n3=S(()=>{G$=Boolean(R1.env.SSH_CONNECTION||R1.env.SSH_CLIENT||R1.env.SSH_TTY),i3=G$});import S1 from"node:process";import e3 from"node:path";import{fileURLToPath as F$}from"node:url";import X$ from"node:child_process";import H$,{constants as K$}from"node:fs/promises";function t3($){if(typeof $==="string"||Array.isArray($))return $;let{[o3]:J}=$;if(!J)throw Error(`${o3} is not supported`);return J}function S0({[N0]:$},{wsl:J}={}){if(J&&o)return t3(J);if(!$)throw Error(`${N0} is not supported`);return t3($)}var l0,w1,r3,N0,o3,s3=async($,J)=>{if($.length===0)return;let Z=[];for(let Q of $)try{return await J(Q)}catch(Y){Z.push(Y)}throw AggregateError(Z,"Failed to open in all supported apps")},p0=async($)=>{$={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...$};let J=$[l0]===!0;if(delete $[l0],Array.isArray($.app))return s3($.app,(H)=>p0({...$,app:H,[l0]:!0}));let{name:Z,arguments:Q=[]}=$.app??{};if(Q=[...Q],Array.isArray(Z))return s3(Z,(H)=>p0({...$,app:{name:H,arguments:Q},[l0]:!0}));if(Z==="browser"||Z==="browserPrivate"){let H={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},K={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},W;if(o){let L=await h3();W=d0.get(L)??{}}else W=await b1();if(W.id in H){let L=H[W.id.toLowerCase()];if(Z==="browserPrivate"){if(L==="safari")throw Error("Safari doesn't support opening in private mode via command line");Q.push(K[L])}return p0({...$,app:{name:V0[L],arguments:Q}})}throw Error(`${W.name} is not supported as a default browser`)}let Y,q=[],z={},F=!1;if(o&&!z0()&&!i3&&!Z)F=await x3();if(N0==="darwin"){if(Y="open",$.wait)q.push("--wait-apps");if($.background)q.push("--background");if($.newInstance)q.push("--new");if(Z)q.push("-a",Z)}else if(N0==="win32"||F){if(Y=await m0(),q.push(...g.argumentsPrefix),!o)z.windowsVerbatimArguments=!0;if(o&&$.target)$.target=await u3($.target);let H=["$ProgressPreference = 'SilentlyContinue';","Start"];if($.wait)H.push("-Wait");if(Z){if(H.push(g.escapeArgument(Z)),$.target)Q.push($.target)}else if($.target)H.push(g.escapeArgument($.target));if(Q.length>0)Q=Q.map((K)=>g.escapeArgument(K)),H.push("-ArgumentList",Q.join(","));if($.target=g.encodeCommand(H.join(" ")),!$.wait)z.stdio="ignore"}else{if(Z)Y=Z;else{let H=!w1||w1==="/",K=!1;try{await H$.access(r3,K$.X_OK),K=!0}catch{}Y=S1.versions.electron??(N0==="android"||H||!K)?"xdg-open":r3}if(Q.length>0)q.push(...Q);if(!$.wait)z.stdio="ignore",z.detached=!0}if(N0==="darwin"&&Q.length>0)q.push("--args",...Q);if($.target)q.push($.target);let X=X$.spawn(Y,q,z);if($.wait)return new Promise((H,K)=>{X.once("error",K),X.once("close",(W)=>{if(!$.allowNonzeroExitCode&&W!==0){K(Error(`Exited with code ${W}`));return}H(X)})});if(J)return new Promise((H,K)=>{X.once("error",K),X.once("spawn",()=>{X.once("close",(W)=>{if(X.off("error",K),W!==0){K(Error(`Exited with code ${W}`));return}X.unref(),H(X)})})});return X.unref(),new Promise((H,K)=>{X.once("error",K),X.once("spawn",()=>{X.off("error",K),H(X)})})},W$=($,J)=>{if(typeof $!=="string")throw TypeError("Expected a `target`");return p0({...J,target:$})},V0,$9;var J9=S(()=>{g3();D1();a3();L1();n3();l0=Symbol("fallbackAttempt"),w1=import.meta.url?e3.dirname(F$(import.meta.url)):"",r3=e3.join(w1,"xdg-open"),{platform:N0,arch:o3}=S1;V0={browser:"browser",browserPrivate:"browserPrivate"};G0(V0,"chrome",()=>S0({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));G0(V0,"brave",()=>S0({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));G0(V0,"firefox",()=>S0({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));G0(V0,"edge",()=>S0({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));G0(V0,"safari",()=>S0({darwin:"Safari"}));$9=W$});var Q9;var Z9=S(()=>{Q9={name:"@softdesignbrasil/productdock-cli",version:"0.2.1",description:"ProductDock CLI — manage MCP setup, project linking, and skills",type:"module",engines:{node:">=18.0.0"},bin:{productdock:"dist/productdock.js"},files:["dist/"],scripts:{dev:"bun run bin/productdock.ts","build:npm":"bun build bin/productdock.ts --outfile dist/productdock.js --target=node --minify","build:binaries":"bun run build.ts",build:"bun run build:npm && bun run build:binaries",typecheck:"tsc --noEmit"},devDependencies:{"@types/bun":"latest","bun-types":"^1.3.14",typescript:"^6.0.3"},dependencies:{"@clack/prompts":"^1.5.1",commander:"^15.0.0",open:"^11.0.0"},publishConfig:{access:"public"}}});import U$ from"path";import Y9 from"fs";var q9,z9,M$,x,w0="productdock-cli";var F0=S(()=>{Z9();q9=U$.resolve(import.meta.dir,"..",".env");if(Y9.existsSync(q9)){let $=Y9.readFileSync(q9,"utf8").split(`
5
- `);for(let J of $){let Z=J.trim();if(!Z||Z.startsWith("#"))continue;let Q=Z.indexOf("=");if(Q===-1)continue;let Y=Z.slice(0,Q).trim(),q=Z.slice(Q+1).trim().replace(/^["']|["']$/g,"");if(Y&&!(Y in process.env))process.env[Y]=q}}z9=Q9.version,M$={mcpServerUrl:"https://productdock-api.softdesign.com.br/mcp"},x=process.env.PRODUCTDOCK_MCP_URL??M$.mcpServerUrl});var G9,F9=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},X9=($)=>{return $===8987||$===9001||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$>=131072&&$<=196605||$>=196608&&$<=262141};var H9=S(()=>{G9=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(J)=>{let Z=0;$.lastIndex=0;while($.test(J))Z+=1;return J.length-Z}})()});var j$,D$,K9,I$,W9,N$,V$,E$,L9=($,J={},Z={})=>{let Q=J.limit??1/0,Y=J.ellipsis??"",q=J?.ellipsisWidth??(Y?L9(Y,E$,Z).width:0),z=0,F=Z.controlWidth??0,X=Z.tabWidth??8,H=Z.emojiWidth??2,K=2,W=Z.regularWidth??1,L=Z.wideWidth??2,M=[[N$,W],[j$,0],[D$,F],[I$,X],[W9,H],[K9,L]],U=0,N=0,j=$.length,I=0,V=!1,P=j,B=Math.max(0,Q-q),k=0,O=0,w=0,C=0;$:while(!0){if(O>k||N>=j&&N>U){let A=$.slice(k,O)||$.slice(U,N);I=0;for(let h of A.replaceAll(V$,"")){let T=h.codePointAt(0)||0;if(F9(T))C=2;else if(X9(T))C=L;else C=W;if(w+C>B)P=Math.min(P,Math.max(k,U)+I);if(w+C>Q){V=!0;break $}I+=h.length,w+=C}k=O=0}if(N>=j)break $;for(let A=0,h=M.length;A<h;A++){let[T,D0]=M[A];if(T.lastIndex=N,T.test($)){if(I=T===K9?G9($.slice(N,T.lastIndex)):T===W9?1:T.lastIndex-N,C=I*D0,w+C>B)P=Math.min(P,N+Math.floor((B-w)/D0));if(w+C>Q){V=!0;break $}w+=C,k=U,O=N,N=U=T.lastIndex;continue $}}N+=1}return{width:V?B:w,index:V?P:j,truncated:V,ellipsed:V&&Q>=q}},U9;var M9=S(()=>{H9();j$=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,D$=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,K9=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,I$=/\t{1,1000}/y,W9=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,N$=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,V$=/\p{M}+/gu,E$={limit:1/0,ellipsis:""},U9=L9});var k$,P$=($,J={})=>{return U9($,k$,J).width},y;var f1=S(()=>{M9();k$={limit:1/0,ellipsis:"",ellipsisWidth:0},y=P$});function p($,J,Z){return String($).normalize().split(w$).map((Q)=>S$(Q,J,Z)).join(`
6
- `)}var a0="\x1B",V9="›",B$=39,O1="\x07",E9="[",b$="]",k9="m",C1,j9,D9=($)=>{if($>=30&&$<=37)return 39;if($>=90&&$<=97)return 39;if($>=40&&$<=47)return 49;if($>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0;return},I9=($)=>`${a0}${E9}${$}${k9}`,N9=($)=>`${a0}${C1}${$}${O1}`,v1=($,J,Z)=>{let Q=J[Symbol.iterator](),Y=!1,q=!1,z=$.at(-1),F=z===void 0?0:y(z),X=Q.next(),H=Q.next(),K=0;while(!X.done){let W=X.value,L=y(W);if(F+L<=Z)$[$.length-1]+=W;else $.push(W),F=0;if(W===a0||W===V9)Y=!0,q=J.startsWith(C1,K+1);if(Y){if(q){if(W===O1)Y=!1,q=!1}else if(W===k9)Y=!1}else if(F+=L,F===Z&&!H.done)$.push(""),F=0;X=H,H=Q.next(),K+=W.length}if(z=$.at(-1),!F&&z!==void 0&&z.length&&$.length>1)$[$.length-2]+=$.pop()},R$=($)=>{let J=$.split(" "),Z=J.length;while(Z){if(y(J[Z-1]))break;Z--}if(Z===J.length)return $;return J.slice(0,Z).join(" ")+J.slice(Z).join("")},S$=($,J,Z={})=>{if(Z.trim!==!1&&$.trim()==="")return"";let Q="",Y,q,z=$.split(" "),F=[""],X=0;for(let W=0;W<z.length;W++){let L=z[W];if(Z.trim!==!1){let U=F.at(-1)??"",N=U.trimStart();if(U.length!==N.length)F[F.length-1]=N,X=y(N)}if(W!==0){if(X>=J&&(Z.wordWrap===!1||Z.trim===!1))F.push(""),X=0;if(X||Z.trim===!1)F[F.length-1]+=" ",X++}let M=y(L);if(Z.hard&&M>J){let U=J-X,N=1+Math.floor((M-U-1)/J);if(Math.floor((M-1)/J)<N)F.push("");v1(F,L,J),X=y(F.at(-1)??"");continue}if(X+M>J&&X&&M){if(Z.wordWrap===!1&&X<J){v1(F,L,J),X=y(F.at(-1)??"");continue}F.push(""),X=0}if(X+M>J&&Z.wordWrap===!1){v1(F,L,J),X=y(F.at(-1)??"");continue}F[F.length-1]+=L,X+=M}if(Z.trim!==!1)F=F.map((W)=>R$(W));let H=F.join(`
7
- `),K=!1;for(let W=0;W<H.length;W++){let L=H[W];if(Q+=L,!K){if(K=L>="\uD800"&&L<="\uDBFF",K)continue}else K=!1;if(L===a0||L===V9){j9.lastIndex=W+1;let U=j9.exec(H)?.groups;if(U?.code!==void 0){let N=Number.parseFloat(U.code);Y=N===B$?void 0:N}else if(U?.uri!==void 0)q=U.uri.length===0?void 0:U.uri}if(H[W+1]===`
8
- `){if(q)Q+=N9("");let M=Y?D9(Y):void 0;if(Y&&M)Q+=I9(M)}else if(L===`
9
- `){if(Y&&D9(Y))Q+=I9(Y);if(q)Q+=N9(q)}}return Q},w$;var A1=S(()=>{f1();C1=`${b$}8;;`,j9=new RegExp(`(?:\\${E9}(?<code>\\d+)m|\\${C1}(?<uri>.*)${O1})`,"y"),w$=/\r?\n/});var T1=B2((x8,P9)=>{var _1={to($,J){if(!J)return`\x1B[${$+1}G`;return`\x1B[${J+1};${$+1}H`},move($,J){let Z="";if($<0)Z+=`\x1B[${-$}D`;else if($>0)Z+=`\x1B[${$}C`;if(J<0)Z+=`\x1B[${-J}A`;else if(J>0)Z+=`\x1B[${J}B`;return Z},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},f$={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},v$={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let J="";for(let Z=0;Z<$;Z++)J+=this.line+(Z<$-1?_1.up():"");if($)J+=_1.left;return J}};P9.exports={cursor:_1,scroll:f$,erase:v$,beep:"\x07"}});import{styleText as E0}from"node:util";import{stdout as u1,stdin as S9}from"node:process";import*as $0 from"node:readline";import O$ from"node:readline";import{ReadStream as B9}from"node:tty";function s($,J,Z){if(!Z.some((z)=>!z.disabled))return $;let Q=$+J,Y=Math.max(Z.length-1,0),q=Q<0?Y:Q>Y?0:Q;return Z[q].disabled?s(q,J<0?-1:1,Z):q}function i0($,J,Z,Q){let Y=Q.split(`
10
- `),q=0,z=$;for(let X of Y){if(z<=X.length)break;z-=X.length+1,q++}for(q=Math.max(0,Math.min(Y.length-1,q+Z)),z=Math.min(z,Y[q].length)+J;z<0&&q>0;)q--,z+=Y[q].length+1;for(;z>Y[q].length&&q<Y.length-1;)z-=Y[q].length+1,q++;z=Math.max(0,Math.min(Y[q].length,z));let F=0;for(let X=0;X<q;X++)F+=Y[X].length+1;return F+z}function w9($){if($.aliases!==void 0){let J=$.aliases;for(let Z in J){if(!Object.hasOwn(J,Z))continue;let Q=J[Z];E.actions.has(Q)&&(E.aliases.has(Z)||E.aliases.set(Z,Q))}}if($.messages!==void 0){let J=$.messages;J.cancel!==void 0&&(E.messages.cancel=J.cancel),J.error!==void 0&&(E.messages.error=J.error)}if($.withGuide!==void 0&&(E.withGuide=$.withGuide!==!1),$.date!==void 0){let J=$.date;J.monthNames!==void 0&&(E.date.monthNames=[...J.monthNames]),J.messages!==void 0&&(J.messages.required!==void 0&&(E.date.messages.required=J.messages.required),J.messages.invalidMonth!==void 0&&(E.date.messages.invalidMonth=J.messages.invalidMonth),J.messages.invalidDay!==void 0&&(E.date.messages.invalidDay=J.messages.invalidDay),J.messages.afterMin!==void 0&&(E.date.messages.afterMin=J.messages.afterMin),J.messages.beforeMax!==void 0&&(E.date.messages.beforeMax=J.messages.beforeMax))}}function g1($,J){if(typeof $=="string")return E.aliases.get($)===J;for(let Z of $)if(Z!==void 0&&g1(Z,J))return!0;return!1}function _$($,J){if($===J)return;let Z=$.split(`
2
+ var I2=Object.create;var{getPrototypeOf:N2,defineProperty:z1,getOwnPropertyNames:V2}=Object;var E2=Object.prototype.hasOwnProperty;function k2($){return this[$]}var P2,B2,b3=($,J,Z)=>{var Q=$!=null&&typeof $==="object";if(Q){var Y=J?P2??=new WeakMap:B2??=new WeakMap,q=Y.get($);if(q)return q}Z=$!=null?I2(N2($)):{};let z=J||!$||!$.__esModule?z1(Z,"default",{value:$,enumerable:!0}):Z;for(let F of V2($))if(!E2.call(z,F))z1(z,F,{get:k2.bind($,F),enumerable:!0});if(Q)Y.set($,z);return z};var b2=($,J)=>()=>(J||$((J={exports:{}}).exports,J),J.exports);var R2=($)=>$;function S2($,J){this[$]=R2.bind(null,J)}var y0=($,J)=>{for(var Z in J)z1($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:S2.bind(J,Z)})};var S=($,J)=>()=>($&&(J=$($=0)),J);import v3 from"node:fs";function A2(){try{return v3.statSync("/.dockerenv"),!0}catch{return!1}}function _2(){try{return v3.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function K1(){if(H1===void 0)H1=A2()||_2();return H1}var H1;var f3=()=>{};import T2 from"node:fs";function z0(){if(W1===void 0)W1=y2()||K1();return W1}var W1,y2=()=>{try{return T2.statSync("/run/.containerenv"),!0}catch{return!1}};var L1=S(()=>{f3()});import C3 from"node:process";import x2 from"node:os";import U1 from"node:fs";var O3=()=>{if(C3.platform!=="linux")return!1;if(x2.release().toLowerCase().includes("microsoft")){if(z0())return!1;return!0}try{if(U1.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!z0()}catch{}if(U1.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||U1.existsSync("/run/WSL"))return!z0();return!1},o;var M1=S(()=>{L1();o=C3.env.__IS_WSL_TEST__?O3:O3()});import A3 from"node:process";import{Buffer as h2}from"node:buffer";import{promisify as u2}from"node:util";import g2 from"node:child_process";var m2,j1=()=>`${A3.env.SYSTEMROOT||A3.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,g=async($,J={})=>{let{powerShellPath:Z,...Q}=J,Y=g.encodeCommand($);return m2(Z??j1(),[...g.argumentsPrefix,Y],{encoding:"utf8",...Q})};var D1=S(()=>{m2=u2(g2.execFile);g.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];g.encodeCommand=($)=>h2.from($,"utf16le").toString("base64");g.escapeArgument=($)=>`'${String($).replaceAll("'","''")}'`});function _3($){for(let J of $.split(`
3
+ `)){if(/^\s*#/.test(J))continue;let Z=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(J);if(!Z)continue;return Z.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}import{promisify as c2}from"node:util";import d2 from"node:child_process";import N1,{constants as y3}from"node:fs/promises";var l2,p2,a2=async()=>{return`${await p2()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},m0,T3,x3=async()=>{return T3??=(async()=>{try{let $=await m0();return await N1.access($,y3.X_OK),!0}catch{return!1}})(),T3},h3=async()=>{let $=await m0(),J=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:Z}=await g(J,{powerShellPath:$});return Z.trim()},u3=async($)=>{if(/^[a-z]+:\/\//i.test($))return $;try{let{stdout:J}=await l2("wslpath",["-aw",$],{encoding:"utf8"});return J.trim()}catch{return $}};var g3=S(()=>{M1();D1();M1();l2=c2(d2.execFile),p2=(()=>{let J;return async function(){if(J)return J;let Z="/etc/wsl.conf",Q=!1;try{await N1.access(Z,y3.F_OK),Q=!0}catch{}if(!Q)return"/mnt/";let Y=await N1.readFile(Z,{encoding:"utf8"}),q=_3(Y);if(q===void 0)return"/mnt/";return J=q,J=J.endsWith("/")?J:`${J}/`,J}})(),m0=o?a2:j1});function G0($,J,Z){let Q=(Y)=>Object.defineProperty($,J,{value:Y,enumerable:!0,writable:!0});return Object.defineProperty($,J,{configurable:!0,enumerable:!0,get(){let Y=Z();return Q(Y),Y},set(Y){Q(Y)}}),$}import{promisify as i2}from"node:util";import n2 from"node:process";import{execFile as r2}from"node:child_process";async function V1(){if(n2.platform!=="darwin")throw Error("macOS only");let{stdout:$}=await o2("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),Z=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec($)?.groups.id??"com.apple.Safari";if(Z==="com.apple.safari")return"com.apple.Safari";return Z}var o2;var m3=S(()=>{o2=i2(r2)});import s2 from"node:process";import{promisify as t2}from"node:util";import{execFile as e2,execFileSync as t4}from"node:child_process";async function c3($,{humanReadableOutput:J=!0,signal:Z}={}){if(s2.platform!=="darwin")throw Error("macOS only");let Q=J?[]:["-ss"],Y={};if(Z)Y.signal=Z;let{stdout:q}=await $$("osascript",["-e",$,Q],Y);return q.trim()}var $$;var d3=S(()=>{$$=t2(e2)});async function E1($){return c3(`tell application "Finder" to set app_path to application file id "${$}" as string
4
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var l3=S(()=>{d3()});import{promisify as J$}from"node:util";import{execFile as Z$}from"node:child_process";async function k1($=Q$){let{stdout:J}=await $("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),Z=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(J);if(!Z)throw new p3(`Cannot find Windows browser in stdout: ${JSON.stringify(J)}`);let{id:Q}=Z.groups,Y=Q.lastIndexOf("."),q=Q.lastIndexOf("-"),z=Y===-1?void 0:Q.slice(0,Y),F=q===-1?void 0:Q.slice(0,q);return c0[Q]??c0[z]??c0[F]??{name:Q,id:Q}}var Q$,c0,d0,p3;var P1=S(()=>{Q$=J$(Z$),c0={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},d0=new Map(Object.entries(c0));p3=class p3 extends Error{}});import{promisify as Y$}from"node:util";import B1 from"node:process";import{execFile as q$}from"node:child_process";async function b1(){if(B1.platform==="darwin"){let $=await V1();return{name:await E1($),id:$}}if(B1.platform==="linux"){let{stdout:$}=await z$("xdg-mime",["query","default","x-scheme-handler/http"]),J=$.trim();return{name:G$(J.replace(/.desktop$/,"").replace("-"," ")),id:J}}if(B1.platform==="win32")return k1();throw Error("Only macOS, Linux, and Windows are supported")}var z$,G$=($)=>$.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(J)=>J.toUpperCase());var a3=S(()=>{m3();l3();P1();P1();z$=Y$(q$)});import R1 from"node:process";var F$,i3;var n3=S(()=>{F$=Boolean(R1.env.SSH_CONNECTION||R1.env.SSH_CLIENT||R1.env.SSH_TTY),i3=F$});import S1 from"node:process";import e3 from"node:path";import{fileURLToPath as X$}from"node:url";import H$ from"node:child_process";import K$,{constants as W$}from"node:fs/promises";function t3($){if(typeof $==="string"||Array.isArray($))return $;let{[o3]:J}=$;if(!J)throw Error(`${o3} is not supported`);return J}function S0({[N0]:$},{wsl:J}={}){if(J&&o)return t3(J);if(!$)throw Error(`${N0} is not supported`);return t3($)}var l0,w1,r3,N0,o3,s3=async($,J)=>{if($.length===0)return;let Z=[];for(let Q of $)try{return await J(Q)}catch(Y){Z.push(Y)}throw AggregateError(Z,"Failed to open in all supported apps")},p0=async($)=>{$={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...$};let J=$[l0]===!0;if(delete $[l0],Array.isArray($.app))return s3($.app,(H)=>p0({...$,app:H,[l0]:!0}));let{name:Z,arguments:Q=[]}=$.app??{};if(Q=[...Q],Array.isArray(Z))return s3(Z,(H)=>p0({...$,app:{name:H,arguments:Q},[l0]:!0}));if(Z==="browser"||Z==="browserPrivate"){let H={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},K={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},W;if(o){let L=await h3();W=d0.get(L)??{}}else W=await b1();if(W.id in H){let L=H[W.id.toLowerCase()];if(Z==="browserPrivate"){if(L==="safari")throw Error("Safari doesn't support opening in private mode via command line");Q.push(K[L])}return p0({...$,app:{name:V0[L],arguments:Q}})}throw Error(`${W.name} is not supported as a default browser`)}let Y,q=[],z={},F=!1;if(o&&!z0()&&!i3&&!Z)F=await x3();if(N0==="darwin"){if(Y="open",$.wait)q.push("--wait-apps");if($.background)q.push("--background");if($.newInstance)q.push("--new");if(Z)q.push("-a",Z)}else if(N0==="win32"||F){if(Y=await m0(),q.push(...g.argumentsPrefix),!o)z.windowsVerbatimArguments=!0;if(o&&$.target)$.target=await u3($.target);let H=["$ProgressPreference = 'SilentlyContinue';","Start"];if($.wait)H.push("-Wait");if(Z){if(H.push(g.escapeArgument(Z)),$.target)Q.push($.target)}else if($.target)H.push(g.escapeArgument($.target));if(Q.length>0)Q=Q.map((K)=>g.escapeArgument(K)),H.push("-ArgumentList",Q.join(","));if($.target=g.encodeCommand(H.join(" ")),!$.wait)z.stdio="ignore"}else{if(Z)Y=Z;else{let H=!w1||w1==="/",K=!1;try{await K$.access(r3,W$.X_OK),K=!0}catch{}Y=S1.versions.electron??(N0==="android"||H||!K)?"xdg-open":r3}if(Q.length>0)q.push(...Q);if(!$.wait)z.stdio="ignore",z.detached=!0}if(N0==="darwin"&&Q.length>0)q.push("--args",...Q);if($.target)q.push($.target);let X=H$.spawn(Y,q,z);if($.wait)return new Promise((H,K)=>{X.once("error",K),X.once("close",(W)=>{if(!$.allowNonzeroExitCode&&W!==0){K(Error(`Exited with code ${W}`));return}H(X)})});if(J)return new Promise((H,K)=>{X.once("error",K),X.once("spawn",()=>{X.once("close",(W)=>{if(X.off("error",K),W!==0){K(Error(`Exited with code ${W}`));return}X.unref(),H(X)})})});return X.unref(),new Promise((H,K)=>{X.once("error",K),X.once("spawn",()=>{X.off("error",K),H(X)})})},L$=($,J)=>{if(typeof $!=="string")throw TypeError("Expected a `target`");return p0({...J,target:$})},V0,$9;var J9=S(()=>{g3();D1();a3();L1();n3();l0=Symbol("fallbackAttempt"),w1=import.meta.url?e3.dirname(X$(import.meta.url)):"",r3=e3.join(w1,"xdg-open"),{platform:N0,arch:o3}=S1;V0={browser:"browser",browserPrivate:"browserPrivate"};G0(V0,"chrome",()=>S0({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));G0(V0,"brave",()=>S0({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));G0(V0,"firefox",()=>S0({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));G0(V0,"edge",()=>S0({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));G0(V0,"safari",()=>S0({darwin:"Safari"}));$9=L$});var Q9;var Z9=S(()=>{Q9={name:"@softdesignbrasil/productdock-cli",version:"0.2.1",description:"ProductDock CLI — manage MCP setup, project linking, and skills",type:"module",engines:{node:">=18.0.0"},bin:{productdock:"dist/productdock.js"},files:["dist/"],scripts:{dev:"bun run bin/productdock.ts","build:npm":"bun build bin/productdock.ts --outfile dist/productdock.js --target=node --minify","build:binaries":"bun run build.ts",build:"bun run build:npm && bun run build:binaries",typecheck:"tsc --noEmit"},devDependencies:{"@types/bun":"latest","bun-types":"^1.3.14",typescript:"^6.0.3"},dependencies:{"@clack/prompts":"^1.5.1",commander:"^15.0.0",open:"^11.0.0"},publishConfig:{access:"public"}}});import z9 from"path";import Y9 from"fs";import{fileURLToPath as M$}from"url";var j$,q9,G9,D$,x,w0="productdock-cli";var F0=S(()=>{Z9();j$=z9.dirname(M$(import.meta.url)),q9=z9.resolve(j$,"..",".env");if(Y9.existsSync(q9)){let $=Y9.readFileSync(q9,"utf8").split(`
5
+ `);for(let J of $){let Z=J.trim();if(!Z||Z.startsWith("#"))continue;let Q=Z.indexOf("=");if(Q===-1)continue;let Y=Z.slice(0,Q).trim(),q=Z.slice(Q+1).trim().replace(/^["']|["']$/g,"");if(Y&&!(Y in process.env))process.env[Y]=q}}G9=Q9.version,D$={mcpServerUrl:"https://productdock-api.softdesign.com.br/mcp"},x=process.env.PRODUCTDOCK_MCP_URL??D$.mcpServerUrl});var F9,X9=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},H9=($)=>{return $===8987||$===9001||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$>=131072&&$<=196605||$>=196608&&$<=262141};var K9=S(()=>{F9=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(J)=>{let Z=0;$.lastIndex=0;while($.test(J))Z+=1;return J.length-Z}})()});var I$,N$,W9,V$,L9,E$,k$,P$,U9=($,J={},Z={})=>{let Q=J.limit??1/0,Y=J.ellipsis??"",q=J?.ellipsisWidth??(Y?U9(Y,P$,Z).width:0),z=0,F=Z.controlWidth??0,X=Z.tabWidth??8,H=Z.emojiWidth??2,K=2,W=Z.regularWidth??1,L=Z.wideWidth??2,M=[[E$,W],[I$,0],[N$,F],[V$,X],[L9,H],[W9,L]],U=0,N=0,j=$.length,I=0,V=!1,P=j,B=Math.max(0,Q-q),k=0,O=0,w=0,C=0;$:while(!0){if(O>k||N>=j&&N>U){let A=$.slice(k,O)||$.slice(U,N);I=0;for(let h of A.replaceAll(k$,"")){let T=h.codePointAt(0)||0;if(X9(T))C=2;else if(H9(T))C=L;else C=W;if(w+C>B)P=Math.min(P,Math.max(k,U)+I);if(w+C>Q){V=!0;break $}I+=h.length,w+=C}k=O=0}if(N>=j)break $;for(let A=0,h=M.length;A<h;A++){let[T,D0]=M[A];if(T.lastIndex=N,T.test($)){if(I=T===W9?F9($.slice(N,T.lastIndex)):T===L9?1:T.lastIndex-N,C=I*D0,w+C>B)P=Math.min(P,N+Math.floor((B-w)/D0));if(w+C>Q){V=!0;break $}w+=C,k=U,O=N,N=U=T.lastIndex;continue $}}N+=1}return{width:V?B:w,index:V?P:j,truncated:V,ellipsed:V&&Q>=q}},M9;var j9=S(()=>{K9();I$=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,N$=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,W9=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,V$=/\t{1,1000}/y,L9=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,E$=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,k$=/\p{M}+/gu,P$={limit:1/0,ellipsis:""},M9=U9});var B$,b$=($,J={})=>{return M9($,B$,J).width},y;var v1=S(()=>{j9();B$={limit:1/0,ellipsis:"",ellipsisWidth:0},y=b$});function p($,J,Z){return String($).normalize().split(f$).map((Q)=>v$(Q,J,Z)).join(`
6
+ `)}var a0="\x1B",E9="›",R$=39,O1="\x07",k9="[",S$="]",P9="m",C1,D9,I9=($)=>{if($>=30&&$<=37)return 39;if($>=90&&$<=97)return 39;if($>=40&&$<=47)return 49;if($>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0;return},N9=($)=>`${a0}${k9}${$}${P9}`,V9=($)=>`${a0}${C1}${$}${O1}`,f1=($,J,Z)=>{let Q=J[Symbol.iterator](),Y=!1,q=!1,z=$.at(-1),F=z===void 0?0:y(z),X=Q.next(),H=Q.next(),K=0;while(!X.done){let W=X.value,L=y(W);if(F+L<=Z)$[$.length-1]+=W;else $.push(W),F=0;if(W===a0||W===E9)Y=!0,q=J.startsWith(C1,K+1);if(Y){if(q){if(W===O1)Y=!1,q=!1}else if(W===P9)Y=!1}else if(F+=L,F===Z&&!H.done)$.push(""),F=0;X=H,H=Q.next(),K+=W.length}if(z=$.at(-1),!F&&z!==void 0&&z.length&&$.length>1)$[$.length-2]+=$.pop()},w$=($)=>{let J=$.split(" "),Z=J.length;while(Z){if(y(J[Z-1]))break;Z--}if(Z===J.length)return $;return J.slice(0,Z).join(" ")+J.slice(Z).join("")},v$=($,J,Z={})=>{if(Z.trim!==!1&&$.trim()==="")return"";let Q="",Y,q,z=$.split(" "),F=[""],X=0;for(let W=0;W<z.length;W++){let L=z[W];if(Z.trim!==!1){let U=F.at(-1)??"",N=U.trimStart();if(U.length!==N.length)F[F.length-1]=N,X=y(N)}if(W!==0){if(X>=J&&(Z.wordWrap===!1||Z.trim===!1))F.push(""),X=0;if(X||Z.trim===!1)F[F.length-1]+=" ",X++}let M=y(L);if(Z.hard&&M>J){let U=J-X,N=1+Math.floor((M-U-1)/J);if(Math.floor((M-1)/J)<N)F.push("");f1(F,L,J),X=y(F.at(-1)??"");continue}if(X+M>J&&X&&M){if(Z.wordWrap===!1&&X<J){f1(F,L,J),X=y(F.at(-1)??"");continue}F.push(""),X=0}if(X+M>J&&Z.wordWrap===!1){f1(F,L,J),X=y(F.at(-1)??"");continue}F[F.length-1]+=L,X+=M}if(Z.trim!==!1)F=F.map((W)=>w$(W));let H=F.join(`
7
+ `),K=!1;for(let W=0;W<H.length;W++){let L=H[W];if(Q+=L,!K){if(K=L>="\uD800"&&L<="\uDBFF",K)continue}else K=!1;if(L===a0||L===E9){D9.lastIndex=W+1;let U=D9.exec(H)?.groups;if(U?.code!==void 0){let N=Number.parseFloat(U.code);Y=N===R$?void 0:N}else if(U?.uri!==void 0)q=U.uri.length===0?void 0:U.uri}if(H[W+1]===`
8
+ `){if(q)Q+=V9("");let M=Y?I9(Y):void 0;if(Y&&M)Q+=N9(M)}else if(L===`
9
+ `){if(Y&&I9(Y))Q+=N9(Y);if(q)Q+=V9(q)}}return Q},f$;var A1=S(()=>{v1();C1=`${S$}8;;`,D9=new RegExp(`(?:\\${k9}(?<code>\\d+)m|\\${C1}(?<uri>.*)${O1})`,"y"),f$=/\r?\n/});var T1=b2((g8,B9)=>{var _1={to($,J){if(!J)return`\x1B[${$+1}G`;return`\x1B[${J+1};${$+1}H`},move($,J){let Z="";if($<0)Z+=`\x1B[${-$}D`;else if($>0)Z+=`\x1B[${$}C`;if(J<0)Z+=`\x1B[${-J}A`;else if(J>0)Z+=`\x1B[${J}B`;return Z},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},O$={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},C$={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let J="";for(let Z=0;Z<$;Z++)J+=this.line+(Z<$-1?_1.up():"");if($)J+=_1.left;return J}};B9.exports={cursor:_1,scroll:O$,erase:C$,beep:"\x07"}});import{styleText as E0}from"node:util";import{stdout as u1,stdin as w9}from"node:process";import*as $0 from"node:readline";import A$ from"node:readline";import{ReadStream as b9}from"node:tty";function s($,J,Z){if(!Z.some((z)=>!z.disabled))return $;let Q=$+J,Y=Math.max(Z.length-1,0),q=Q<0?Y:Q>Y?0:Q;return Z[q].disabled?s(q,J<0?-1:1,Z):q}function i0($,J,Z,Q){let Y=Q.split(`
10
+ `),q=0,z=$;for(let X of Y){if(z<=X.length)break;z-=X.length+1,q++}for(q=Math.max(0,Math.min(Y.length-1,q+Z)),z=Math.min(z,Y[q].length)+J;z<0&&q>0;)q--,z+=Y[q].length+1;for(;z>Y[q].length&&q<Y.length-1;)z-=Y[q].length+1,q++;z=Math.max(0,Math.min(Y[q].length,z));let F=0;for(let X=0;X<q;X++)F+=Y[X].length+1;return F+z}function v9($){if($.aliases!==void 0){let J=$.aliases;for(let Z in J){if(!Object.hasOwn(J,Z))continue;let Q=J[Z];E.actions.has(Q)&&(E.aliases.has(Z)||E.aliases.set(Z,Q))}}if($.messages!==void 0){let J=$.messages;J.cancel!==void 0&&(E.messages.cancel=J.cancel),J.error!==void 0&&(E.messages.error=J.error)}if($.withGuide!==void 0&&(E.withGuide=$.withGuide!==!1),$.date!==void 0){let J=$.date;J.monthNames!==void 0&&(E.date.monthNames=[...J.monthNames]),J.messages!==void 0&&(J.messages.required!==void 0&&(E.date.messages.required=J.messages.required),J.messages.invalidMonth!==void 0&&(E.date.messages.invalidMonth=J.messages.invalidMonth),J.messages.invalidDay!==void 0&&(E.date.messages.invalidDay=J.messages.invalidDay),J.messages.afterMin!==void 0&&(E.date.messages.afterMin=J.messages.afterMin),J.messages.beforeMax!==void 0&&(E.date.messages.beforeMax=J.messages.beforeMax))}}function g1($,J){if(typeof $=="string")return E.aliases.get($)===J;for(let Z of $)if(Z!==void 0&&g1(Z,J))return!0;return!1}function y$($,J){if($===J)return;let Z=$.split(`
11
11
  `),Q=J.split(`
12
- `),Y=Math.max(Z.length,Q.length),q=[];for(let z=0;z<Y;z++)Z[z]!==Q[z]&&q.push(z);return{lines:q,numLinesBefore:Z.length,numLinesAfter:Q.length,numLines:Y}}function o0($){return $===x1}function n0($,J){let Z=$;Z.isTTY&&Z.setRawMode(J)}function f9({input:$=S9,output:J=u1,overwrite:Z=!0,hideCursor:Q=!0}={}){let Y=$0.createInterface({input:$,output:J,prompt:"",tabSize:1});$0.emitKeypressEvents($,Y),$ instanceof B9&&$.isTTY&&$.setRawMode(!0);let q=(z,{name:F,sequence:X})=>{let H=String(z);if(g1([H,F,X],"cancel")){Q&&J.write(u.cursor.show),process.exit(0);return}if(!Z)return;$0.moveCursor(J,F==="return"?0:-1,F==="return"?-1:0,()=>{$0.clearLine(J,1,()=>{$.once("keypress",q)})})};return Q&&J.write(u.cursor.hide),$.once("keypress",q),()=>{$.off("keypress",q),Q&&J.write(u.cursor.show),$ instanceof B9&&$.isTTY&&!T$&&$.setRawMode(!1),Y.terminal=!1,Y.close()}}function _($,J,Z,Q=Z,Y=Z,q){let z=X0($??u1);return p(J,z-Z.length,{hard:!0,trim:!1}).split(`
12
+ `),Y=Math.max(Z.length,Q.length),q=[];for(let z=0;z<Y;z++)Z[z]!==Q[z]&&q.push(z);return{lines:q,numLinesBefore:Z.length,numLinesAfter:Q.length,numLines:Y}}function o0($){return $===x1}function n0($,J){let Z=$;Z.isTTY&&Z.setRawMode(J)}function f9({input:$=w9,output:J=u1,overwrite:Z=!0,hideCursor:Q=!0}={}){let Y=$0.createInterface({input:$,output:J,prompt:"",tabSize:1});$0.emitKeypressEvents($,Y),$ instanceof b9&&$.isTTY&&$.setRawMode(!0);let q=(z,{name:F,sequence:X})=>{let H=String(z);if(g1([H,F,X],"cancel")){Q&&J.write(u.cursor.show),process.exit(0);return}if(!Z)return;$0.moveCursor(J,F==="return"?0:-1,F==="return"?-1:0,()=>{$0.clearLine(J,1,()=>{$.once("keypress",q)})})};return Q&&J.write(u.cursor.hide),$.once("keypress",q),()=>{$.off("keypress",q),Q&&J.write(u.cursor.show),$ instanceof b9&&$.isTTY&&!x$&&$.setRawMode(!1),Y.terminal=!1,Y.close()}}function _($,J,Z,Q=Z,Y=Z,q){let z=X0($??u1);return p(J,z-Z.length,{hard:!0,trim:!1}).split(`
13
13
  `).map((F,X,H)=>{let K=q?q(F,X):F;return X===0?`${Q}${K}`:X===H.length-1?`${Y}${K}`:`${Z}${K}`}).join(`
14
- `)}function f0($,J){if("~standard"in $){let Z=$["~standard"].validate(J);if(Z instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return Z.issues?.at(0)?.message}return $(J)}class a{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,J=!0){let{input:Z=S9,output:Q=u1,render:Y,signal:q,...z}=$;this.opts=z,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=J,this._abortSignal=q,this.input=Z,this.output=Q}unsubscribe(){this._subscribers.clear()}setSubscriber($,J){let Z=this._subscribers.get($)??[];Z.push(J),this._subscribers.set($,Z)}on($,J){this.setSubscriber($,{cb:J})}once($,J){this.setSubscriber($,{cb:J,once:!0})}emit($,...J){let Z=this._subscribers.get($)??[],Q=[];for(let Y of Z)Y.cb(...J),Y.once&&Q.push(()=>Z.splice(Z.indexOf(Y),1));for(let Y of Q)Y()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(x1);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=O$.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),n0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(u.cursor.show),this.output.off("resize",this.render),n0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(u.cursor.show),this.output.off("resize",this.render),n0(this.input,!1),$(x1)})})}_isActionKey($,J){return $==="\t"}_shouldSubmit($,J){return!0}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,J){this.userInput=$??"",this.emit("userInput",this.userInput),J&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,J){if(this._track&&J.name!=="return"&&(J.name&&this._isActionKey($,J)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),J?.name&&(!this._track&&E.aliases.has(J.name)&&this.emit("cursor",E.aliases.get(J.name)),E.actions.has(J.name)&&this.emit("cursor",J.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$,J),J?.name==="return"&&this._shouldSubmit($,J)){if(this.opts.validate){let Z=f0(this.opts.validate,this.value);Z&&(this.error=Z instanceof Error?Z.message:Z,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}g1([$,J?.name,J?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
14
+ `)}function v0($,J){if("~standard"in $){let Z=$["~standard"].validate(J);if(Z instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return Z.issues?.at(0)?.message}return $(J)}class a{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor($,J=!0){let{input:Z=w9,output:Q=u1,render:Y,signal:q,...z}=$;this.opts=z,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Y.bind(this),this._track=J,this._abortSignal=q,this.input=Z,this.output=Q}unsubscribe(){this._subscribers.clear()}setSubscriber($,J){let Z=this._subscribers.get($)??[];Z.push(J),this._subscribers.set($,Z)}on($,J){this.setSubscriber($,{cb:J})}once($,J){this.setSubscriber($,{cb:J,once:!0})}emit($,...J){let Z=this._subscribers.get($)??[],Q=[];for(let Y of Z)Y.cb(...J),Y.once&&Q.push(()=>Z.splice(Z.indexOf(Y),1));for(let Y of Q)Y()}prompt(){return new Promise(($)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),$(x1);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=A$.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),n0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(u.cursor.show),this.output.off("resize",this.render),n0(this.input,!1),$(this.value)}),this.once("cancel",()=>{this.output.write(u.cursor.show),this.output.off("resize",this.render),n0(this.input,!1),$(x1)})})}_isActionKey($,J){return $==="\t"}_shouldSubmit($,J){return!0}_setValue($){this.value=$,this.emit("value",this.value)}_setUserInput($,J){this.userInput=$??"",this.emit("userInput",this.userInput),J&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress($,J){if(this._track&&J.name!=="return"&&(J.name&&this._isActionKey($,J)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),J?.name&&(!this._track&&E.aliases.has(J.name)&&this.emit("cursor",E.aliases.get(J.name)),E.actions.has(J.name)&&this.emit("cursor",J.name)),$&&($.toLowerCase()==="y"||$.toLowerCase()==="n")&&this.emit("confirm",$.toLowerCase()==="y"),this.emit("key",$,J),J?.name==="return"&&this._shouldSubmit($,J)){if(this.opts.validate){let Z=v0(this.opts.validate,this.value);Z&&(this.error=Z instanceof Error?Z.message:Z,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}g1([$,J?.name,J?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
15
15
  `),n0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let $=p(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
16
- `).length-1;this.output.write(u.cursor.move(-999,$*-1))}render(){let $=p(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(u.cursor.hide);else{let J=_$(this._prevFrame,$),Z=m1(this.output);if(this.restoreCursor(),J){let Q=Math.max(0,J.numLinesAfter-Z),Y=Math.max(0,J.numLinesBefore-Z),q=J.lines.find((z)=>z>=Q);if(q===void 0){this._prevFrame=$;return}if(J.lines.length===1){this.output.write(u.cursor.move(0,q-Y)),this.output.write(u.erase.lines(1));let z=$.split(`
16
+ `).length-1;this.output.write(u.cursor.move(-999,$*-1))}render(){let $=p(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if($!==this._prevFrame){if(this.state==="initial")this.output.write(u.cursor.hide);else{let J=y$(this._prevFrame,$),Z=m1(this.output);if(this.restoreCursor(),J){let Q=Math.max(0,J.numLinesAfter-Z),Y=Math.max(0,J.numLinesBefore-Z),q=J.lines.find((z)=>z>=Q);if(q===void 0){this._prevFrame=$;return}if(J.lines.length===1){this.output.write(u.cursor.move(0,q-Y)),this.output.write(u.erase.lines(1));let z=$.split(`
17
17
  `);this.output.write(z[q]),this._prevFrame=$,this.output.write(u.cursor.move(0,z.length-q-1));return}else if(J.lines.length>1){if(Q<Y)q=Q;else{let F=q-Y;F>0&&this.output.write(u.cursor.move(0,F))}this.output.write(u.erase.down());let z=$.split(`
18
18
  `).slice(q);this.output.write(z.join(`
19
- `)),this._prevFrame=$;return}}this.output.write(u.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function y$($,J){if($===void 0||J.length===0)return 0;let Z=J.findIndex((Q)=>Q.value===$);return Z!==-1?Z:0}function x$($,J){return(J.label??String(J.value)).toLowerCase().includes($.toLowerCase())}function h$($,J){if(J)return $?J:J[0]}function b9($){return[...$].map((J)=>u$[J])}function g$($){let J=new Intl.DateTimeFormat($,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),Z=[],Q="/";for(let Y of J)Y.type==="literal"?Q=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&Z.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:Z,separator:Q}}function y1($){return Number.parseInt(($||"0").replace(/_/g,"0"),10)||0}function r0($){return{year:y1($.year),month:y1($.month),day:y1($.day)}}function h1($,J){return new Date($||2001,J||1,0).getDate()}function v9($){let{year:J,month:Z,day:Q}=r0($);if(!J||J<0||J>9999||!Z||Z<1||Z>12||!Q||Q<1)return;let Y=new Date(Date.UTC(J,Z-1,Q));if(!(Y.getUTCFullYear()!==J||Y.getUTCMonth()!==Z-1||Y.getUTCDate()!==Q))return{year:J,month:Z,day:Q}}function R9($){let J=v9($);return J?new Date(Date.UTC(J.year,J.month-1,J.day)):void 0}function m$($,J,Z,Q){let Y=Z?{year:Z.getUTCFullYear(),month:Z.getUTCMonth()+1,day:Z.getUTCDate()}:null,q=Q?{year:Q.getUTCFullYear(),month:Q.getUTCMonth()+1,day:Q.getUTCDate()}:null;return $==="year"?{min:Y?.year??1,max:q?.year??9999}:$==="month"?{min:Y&&J.year===Y.year?Y.month:1,max:q&&J.year===q.year?q.month:12}:{min:Y&&J.year===Y.year&&J.month===Y.month?Y.day:1,max:q&&J.year===q.year&&J.month===q.month?q.day:h1(J.year,J.month)}}var u,C$,A$,E,T$,x1,X0=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,m1=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20,c1,d1,u$,l1,O9,c$,p1,C9,a1,i1,n1,r1;var o1=S(()=>{A1();u=b3(T1(),1);C$=["up","down","left","right","space","enter","cancel"],A$=["January","February","March","April","May","June","July","August","September","October","November","December"],E={actions:new Set(C$),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...A$],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:($,J)=>`There are only ${$} days in ${J}`,afterMin:($)=>`Date must be on or after ${$.toISOString().slice(0,10)}`,beforeMax:($)=>`Date must be on or before ${$.toISOString().slice(0,10)}`}}};T$=globalThis.process.platform.startsWith("win"),x1=Symbol("clack:cancel");c1=class extends a{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#J=0;#Y="";#$;#q;#G;get cursor(){return this.#J}get userInputWithCursor(){if(!this.userInput)return E0(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let J=this.userInput.slice(0,this._cursor),[Z,...Q]=this.userInput.slice(this._cursor);return`${J}${E0("inverse",Z)}${Q.join("")}`}get options(){return typeof this.#q=="function"?this.#q():this.#q}constructor(J){super(J),this.#q=J.options,this.#G=J.placeholder;let Z=this.options;this.filteredOptions=[...Z],this.multiple=J.multiple===!0,this.#$=typeof J.options=="function"?J.filter:J.filter??x$;let Q;if(J.initialValue&&Array.isArray(J.initialValue)?this.multiple?Q=J.initialValue:Q=J.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(Q=[this.options[0].value]),Q)for(let Y of Q){let q=Z.findIndex((z)=>z.value===Y);q!==-1&&(this.toggleSelected(Y),this.#J=q)}this.focusedValue=this.options[this.#J]?.value,this.on("key",(Y,q)=>this.#Z(Y,q)),this.on("userInput",(Y)=>this.#Q(Y))}_isActionKey(J,Z){return J==="\t"||this.multiple&&this.isNavigating&&Z.name==="space"&&J!==void 0&&J!==""}#Z(J,Z){let Q=Z.name==="up",Y=Z.name==="down",q=Z.name==="return",z=this.userInput===""||this.userInput==="\t",F=this.#G,X=this.options,H=F!==void 0&&F!==""&&X.some((K)=>!K.disabled&&(this.#$?this.#$(F,K):!0));if(Z.name==="tab"&&z&&H){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(F,!0),this.isNavigating=!1;return}Q||Y?(this.#J=s(this.#J,Q?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#J]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):q?this.value=h$(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(Z.name==="tab"||this.isNavigating&&Z.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(J){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(J)?this.selectedValues=this.selectedValues.filter((Z)=>Z!==J):this.selectedValues=[...this.selectedValues,J]:this.selectedValues=[J])}#Q(J){if(J!==this.#Y){this.#Y=J;let Z=this.options;J&&this.#$?this.filteredOptions=Z.filter((q)=>this.#$?.(J,q)):this.filteredOptions=[...Z];let Q=y$(this.focusedValue,this.filteredOptions);this.#J=s(Q,0,this.filteredOptions);let Y=this.filteredOptions[this.#J];Y&&!Y.disabled?this.focusedValue=Y.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};d1=class d1 extends a{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(J)=>{this.output.write(u.cursor.move(0,-1)),this.value=J,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};u$={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};l1=class l1 extends a{#J;#Y;#$;#q;#G;#Z={segmentIndex:0,positionInSegment:0};#Q=!0;#z=null;inlineError="";get segmentCursor(){return{...this.#Z}}get segmentValues(){return{...this.#$}}get segments(){return this.#J}get separator(){return this.#Y}get formattedValue(){return this.#K(this.#$)}#K($){return this.#J.map((J)=>$[J.type]).join(this.#Y)}#F(){this._setUserInput(this.#K(this.#$)),this._setValue(R9(this.#$)??void 0)}constructor($){let J=$.format?{segments:b9($.format),separator:$.separator??"/"}:g$($.locale),Z=$.separator??J.separator,Q=$.format?b9($.format):J.segments,Y=$.initialValue??$.defaultValue,q=Y?{year:String(Y.getUTCFullYear()).padStart(4,"0"),month:String(Y.getUTCMonth()+1).padStart(2,"0"),day:String(Y.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},z=Q.map((F)=>q[F.type]).join(Z);super({...$,initialUserInput:z},!1),this.#J=Q,this.#Y=Z,this.#$=q,this.#q=$.minDate,this.#G=$.maxDate,this.#F(),this.on("cursor",(F)=>this.#U(F)),this.on("key",(F,X)=>this.#M(F,X)),this.on("finalize",()=>this.#j($))}#X(){let $=Math.max(0,Math.min(this.#Z.segmentIndex,this.#J.length-1)),J=this.#J[$];if(J)return this.#Z.positionInSegment=Math.max(0,Math.min(this.#Z.positionInSegment,J.len-1)),{segment:J,index:$}}#H($){this.inlineError="",this.#z=null;let J=this.#X();J&&(this.#Z.segmentIndex=Math.max(0,Math.min(this.#J.length-1,J.index+$)),this.#Z.positionInSegment=0,this.#Q=!0)}#W($){let J=this.#X();if(!J)return;let{segment:Z}=J,Q=this.#$[Z.type],Y=!Q||Q.replace(/_/g,"")==="",q=Number.parseInt((Q||"0").replace(/_/g,"0"),10)||0,z=m$(Z.type,r0(this.#$),this.#q,this.#G),F;Y?F=$===1?z.min:z.max:F=Math.max(Math.min(z.max,q+$),z.min),this.#$={...this.#$,[Z.type]:F.toString().padStart(Z.len,"0")},this.#Q=!0,this.#z=null,this.#F()}#U($){if($)switch($){case"right":return this.#H(1);case"left":return this.#H(-1);case"up":return this.#W(1);case"down":return this.#W(-1)}}#M($,J){if(J?.name==="backspace"||J?.sequence===""||J?.sequence==="\b"||$===""||$==="\b"){this.inlineError="";let Z=this.#X();if(!Z)return;if(!this.#$[Z.segment.type].replace(/_/g,"")){this.#H(-1);return}this.#$[Z.segment.type]="_".repeat(Z.segment.len),this.#Q=!0,this.#Z.positionInSegment=0,this.#F();return}if(J?.name==="tab"){this.inlineError="";let Z=this.#X();if(!Z)return;let Q=J.shift?-1:1,Y=Z.index+Q;Y>=0&&Y<this.#J.length&&(this.#Z.segmentIndex=Y,this.#Z.positionInSegment=0,this.#Q=!0);return}if($&&/^[0-9]$/.test($)){let Z=this.#X();if(!Z)return;let{segment:Q}=Z,Y=!this.#$[Q.type].replace(/_/g,"");if(this.#Q&&this.#z!==null&&!Y){let L=this.#z+$,M={...this.#$,[Q.type]:L},U=this.#L(M,Q);if(U){this.inlineError=U,this.#z=null,this.#Q=!1;return}this.inlineError="",this.#$[Q.type]=L,this.#z=null,this.#Q=!1,this.#F(),Z.index<this.#J.length-1&&(this.#Z.segmentIndex=Z.index+1,this.#Z.positionInSegment=0,this.#Q=!0);return}this.#Q&&!Y&&(this.#$[Q.type]="_".repeat(Q.len),this.#Z.positionInSegment=0),this.#Q=!1,this.#z=null;let q=this.#$[Q.type],z=q.indexOf("_"),F=z>=0?z:Math.min(this.#Z.positionInSegment,Q.len-1);if(F<0||F>=Q.len)return;let X=q.slice(0,F)+$+q.slice(F+1),H=!1;if(F===0&&q==="__"&&(Q.type==="month"||Q.type==="day")){let L=Number.parseInt($,10);X=`0${$}`,H=L<=(Q.type==="month"?1:2)}if(Q.type==="year"&&(X=(q.replace(/_/g,"")+$).padStart(Q.len,"_")),!X.includes("_")){let L={...this.#$,[Q.type]:X},M=this.#L(L,Q);if(M){this.inlineError=M;return}}this.inlineError="",this.#$[Q.type]=X;let K=X.includes("_")?void 0:v9(this.#$);if(K){let{year:L,month:M}=K,U=h1(L,M);this.#$={year:String(Math.max(0,Math.min(9999,L))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,M))).padStart(2,"0"),day:String(Math.max(1,Math.min(U,K.day))).padStart(2,"0")}}this.#F();let W=X.indexOf("_");H?(this.#Q=!0,this.#z=$):W>=0?this.#Z.positionInSegment=W:z>=0&&Z.index<this.#J.length-1?(this.#Z.segmentIndex=Z.index+1,this.#Z.positionInSegment=0,this.#Q=!0):this.#Z.positionInSegment=Math.min(F+1,Q.len-1)}}#L($,J){let{month:Z,day:Q}=r0($);if(J.type==="month"&&(Z<0||Z>12))return E.date.messages.invalidMonth;if(J.type==="day"&&(Q<0||Q>31))return E.date.messages.invalidDay(31,"any month")}#j($){let{year:J,month:Z,day:Q}=r0(this.#$);if(J&&Z&&Q){let Y=h1(J,Z);this.#$={...this.#$,day:String(Math.min(Q,Y)).padStart(2,"0")}}this.value=R9(this.#$)??$.defaultValue??void 0}};O9=class extends a{options;cursor=0;#J;getGroupItems(J){return this.options.filter((Z)=>Z.group===J)}isGroupSelected(J){let Z=this.getGroupItems(J),Q=this.value;return Q===void 0?!1:Z.every((Y)=>Q.includes(Y.value))}toggleValue(){let J=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),J.group===!0){let Z=J.value,Q=this.getGroupItems(Z);this.isGroupSelected(Z)?this.value=this.value.filter((Y)=>Q.findIndex((q)=>q.value===Y)===-1):this.value=[...this.value,...Q.map((Y)=>Y.value)],this.value=Array.from(new Set(this.value))}else{let Z=this.value.includes(J.value);this.value=Z?this.value.filter((Q)=>Q!==J.value):[...this.value,J.value]}}constructor(J){super(J,!1);let{options:Z}=J;this.#J=J.selectableGroups!==!1,this.options=Object.entries(Z).flatMap(([Q,Y])=>[{value:Q,group:!0,label:Q},...Y.map((q)=>({...q,group:Q}))]),this.value=[...J.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Q})=>Q===J.cursorAt),this.#J?0:1),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Y=this.options[this.cursor]?.group===!0;!this.#J&&Y&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Y=this.options[this.cursor]?.group===!0;!this.#J&&Y&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},c$=new Set(["up","down","left","right"]);p1=class p1 extends a{#J=!1;#Y;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${$}█`;let J=$.slice(0,this.cursor),Z=$[this.cursor],Q=$.slice(this.cursor+1);return Z===`
19
+ `)),this._prevFrame=$;return}}this.output.write(u.erase.down())}this.output.write($),this.state==="initial"&&(this.state="active"),this._prevFrame=$}}}function h$($,J){if($===void 0||J.length===0)return 0;let Z=J.findIndex((Q)=>Q.value===$);return Z!==-1?Z:0}function u$($,J){return(J.label??String(J.value)).toLowerCase().includes($.toLowerCase())}function g$($,J){if(J)return $?J:J[0]}function R9($){return[...$].map((J)=>m$[J])}function c$($){let J=new Intl.DateTimeFormat($,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2000,0,15)),Z=[],Q="/";for(let Y of J)Y.type==="literal"?Q=Y.value.trim()||Y.value:(Y.type==="year"||Y.type==="month"||Y.type==="day")&&Z.push({type:Y.type,len:Y.type==="year"?4:2});return{segments:Z,separator:Q}}function y1($){return Number.parseInt(($||"0").replace(/_/g,"0"),10)||0}function r0($){return{year:y1($.year),month:y1($.month),day:y1($.day)}}function h1($,J){return new Date($||2001,J||1,0).getDate()}function O9($){let{year:J,month:Z,day:Q}=r0($);if(!J||J<0||J>9999||!Z||Z<1||Z>12||!Q||Q<1)return;let Y=new Date(Date.UTC(J,Z-1,Q));if(!(Y.getUTCFullYear()!==J||Y.getUTCMonth()!==Z-1||Y.getUTCDate()!==Q))return{year:J,month:Z,day:Q}}function S9($){let J=O9($);return J?new Date(Date.UTC(J.year,J.month-1,J.day)):void 0}function d$($,J,Z,Q){let Y=Z?{year:Z.getUTCFullYear(),month:Z.getUTCMonth()+1,day:Z.getUTCDate()}:null,q=Q?{year:Q.getUTCFullYear(),month:Q.getUTCMonth()+1,day:Q.getUTCDate()}:null;return $==="year"?{min:Y?.year??1,max:q?.year??9999}:$==="month"?{min:Y&&J.year===Y.year?Y.month:1,max:q&&J.year===q.year?q.month:12}:{min:Y&&J.year===Y.year&&J.month===Y.month?Y.day:1,max:q&&J.year===q.year&&J.month===q.month?q.day:h1(J.year,J.month)}}var u,_$,T$,E,x$,x1,X0=($)=>("columns"in $)&&typeof $.columns=="number"?$.columns:80,m1=($)=>("rows"in $)&&typeof $.rows=="number"?$.rows:20,c1,d1,m$,l1,C9,l$,p1,A9,a1,i1,n1,r1;var o1=S(()=>{A1();u=b3(T1(),1);_$=["up","down","left","right","space","enter","cancel"],T$=["January","February","March","April","May","June","July","August","September","October","November","December"],E={actions:new Set(_$),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...T$],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:($,J)=>`There are only ${$} days in ${J}`,afterMin:($)=>`Date must be on or after ${$.toISOString().slice(0,10)}`,beforeMax:($)=>`Date must be on or before ${$.toISOString().slice(0,10)}`}}};x$=globalThis.process.platform.startsWith("win"),x1=Symbol("clack:cancel");c1=class extends a{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#J=0;#Y="";#$;#q;#G;get cursor(){return this.#J}get userInputWithCursor(){if(!this.userInput)return E0(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}█`;let J=this.userInput.slice(0,this._cursor),[Z,...Q]=this.userInput.slice(this._cursor);return`${J}${E0("inverse",Z)}${Q.join("")}`}get options(){return typeof this.#q=="function"?this.#q():this.#q}constructor(J){super(J),this.#q=J.options,this.#G=J.placeholder;let Z=this.options;this.filteredOptions=[...Z],this.multiple=J.multiple===!0,this.#$=typeof J.options=="function"?J.filter:J.filter??u$;let Q;if(J.initialValue&&Array.isArray(J.initialValue)?this.multiple?Q=J.initialValue:Q=J.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(Q=[this.options[0].value]),Q)for(let Y of Q){let q=Z.findIndex((z)=>z.value===Y);q!==-1&&(this.toggleSelected(Y),this.#J=q)}this.focusedValue=this.options[this.#J]?.value,this.on("key",(Y,q)=>this.#Z(Y,q)),this.on("userInput",(Y)=>this.#Q(Y))}_isActionKey(J,Z){return J==="\t"||this.multiple&&this.isNavigating&&Z.name==="space"&&J!==void 0&&J!==""}#Z(J,Z){let Q=Z.name==="up",Y=Z.name==="down",q=Z.name==="return",z=this.userInput===""||this.userInput==="\t",F=this.#G,X=this.options,H=F!==void 0&&F!==""&&X.some((K)=>!K.disabled&&(this.#$?this.#$(F,K):!0));if(Z.name==="tab"&&z&&H){this.userInput==="\t"&&this._clearUserInput(),this._setUserInput(F,!0),this.isNavigating=!1;return}Q||Y?(this.#J=s(this.#J,Q?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#J]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):q?this.value=g$(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(Z.name==="tab"||this.isNavigating&&Z.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(J){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(J)?this.selectedValues=this.selectedValues.filter((Z)=>Z!==J):this.selectedValues=[...this.selectedValues,J]:this.selectedValues=[J])}#Q(J){if(J!==this.#Y){this.#Y=J;let Z=this.options;J&&this.#$?this.filteredOptions=Z.filter((q)=>this.#$?.(J,q)):this.filteredOptions=[...Z];let Q=h$(this.focusedValue,this.filteredOptions);this.#J=s(Q,0,this.filteredOptions);let Y=this.filteredOptions[this.#J];Y&&!Y.disabled?this.focusedValue=Y.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};d1=class d1 extends a{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor($){super($,!1),this.value=!!$.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(J)=>{this.output.write(u.cursor.move(0,-1)),this.value=J,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};m$={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};l1=class l1 extends a{#J;#Y;#$;#q;#G;#Z={segmentIndex:0,positionInSegment:0};#Q=!0;#z=null;inlineError="";get segmentCursor(){return{...this.#Z}}get segmentValues(){return{...this.#$}}get segments(){return this.#J}get separator(){return this.#Y}get formattedValue(){return this.#K(this.#$)}#K($){return this.#J.map((J)=>$[J.type]).join(this.#Y)}#F(){this._setUserInput(this.#K(this.#$)),this._setValue(S9(this.#$)??void 0)}constructor($){let J=$.format?{segments:R9($.format),separator:$.separator??"/"}:c$($.locale),Z=$.separator??J.separator,Q=$.format?R9($.format):J.segments,Y=$.initialValue??$.defaultValue,q=Y?{year:String(Y.getUTCFullYear()).padStart(4,"0"),month:String(Y.getUTCMonth()+1).padStart(2,"0"),day:String(Y.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},z=Q.map((F)=>q[F.type]).join(Z);super({...$,initialUserInput:z},!1),this.#J=Q,this.#Y=Z,this.#$=q,this.#q=$.minDate,this.#G=$.maxDate,this.#F(),this.on("cursor",(F)=>this.#U(F)),this.on("key",(F,X)=>this.#M(F,X)),this.on("finalize",()=>this.#j($))}#X(){let $=Math.max(0,Math.min(this.#Z.segmentIndex,this.#J.length-1)),J=this.#J[$];if(J)return this.#Z.positionInSegment=Math.max(0,Math.min(this.#Z.positionInSegment,J.len-1)),{segment:J,index:$}}#H($){this.inlineError="",this.#z=null;let J=this.#X();J&&(this.#Z.segmentIndex=Math.max(0,Math.min(this.#J.length-1,J.index+$)),this.#Z.positionInSegment=0,this.#Q=!0)}#W($){let J=this.#X();if(!J)return;let{segment:Z}=J,Q=this.#$[Z.type],Y=!Q||Q.replace(/_/g,"")==="",q=Number.parseInt((Q||"0").replace(/_/g,"0"),10)||0,z=d$(Z.type,r0(this.#$),this.#q,this.#G),F;Y?F=$===1?z.min:z.max:F=Math.max(Math.min(z.max,q+$),z.min),this.#$={...this.#$,[Z.type]:F.toString().padStart(Z.len,"0")},this.#Q=!0,this.#z=null,this.#F()}#U($){if($)switch($){case"right":return this.#H(1);case"left":return this.#H(-1);case"up":return this.#W(1);case"down":return this.#W(-1)}}#M($,J){if(J?.name==="backspace"||J?.sequence===""||J?.sequence==="\b"||$===""||$==="\b"){this.inlineError="";let Z=this.#X();if(!Z)return;if(!this.#$[Z.segment.type].replace(/_/g,"")){this.#H(-1);return}this.#$[Z.segment.type]="_".repeat(Z.segment.len),this.#Q=!0,this.#Z.positionInSegment=0,this.#F();return}if(J?.name==="tab"){this.inlineError="";let Z=this.#X();if(!Z)return;let Q=J.shift?-1:1,Y=Z.index+Q;Y>=0&&Y<this.#J.length&&(this.#Z.segmentIndex=Y,this.#Z.positionInSegment=0,this.#Q=!0);return}if($&&/^[0-9]$/.test($)){let Z=this.#X();if(!Z)return;let{segment:Q}=Z,Y=!this.#$[Q.type].replace(/_/g,"");if(this.#Q&&this.#z!==null&&!Y){let L=this.#z+$,M={...this.#$,[Q.type]:L},U=this.#L(M,Q);if(U){this.inlineError=U,this.#z=null,this.#Q=!1;return}this.inlineError="",this.#$[Q.type]=L,this.#z=null,this.#Q=!1,this.#F(),Z.index<this.#J.length-1&&(this.#Z.segmentIndex=Z.index+1,this.#Z.positionInSegment=0,this.#Q=!0);return}this.#Q&&!Y&&(this.#$[Q.type]="_".repeat(Q.len),this.#Z.positionInSegment=0),this.#Q=!1,this.#z=null;let q=this.#$[Q.type],z=q.indexOf("_"),F=z>=0?z:Math.min(this.#Z.positionInSegment,Q.len-1);if(F<0||F>=Q.len)return;let X=q.slice(0,F)+$+q.slice(F+1),H=!1;if(F===0&&q==="__"&&(Q.type==="month"||Q.type==="day")){let L=Number.parseInt($,10);X=`0${$}`,H=L<=(Q.type==="month"?1:2)}if(Q.type==="year"&&(X=(q.replace(/_/g,"")+$).padStart(Q.len,"_")),!X.includes("_")){let L={...this.#$,[Q.type]:X},M=this.#L(L,Q);if(M){this.inlineError=M;return}}this.inlineError="",this.#$[Q.type]=X;let K=X.includes("_")?void 0:O9(this.#$);if(K){let{year:L,month:M}=K,U=h1(L,M);this.#$={year:String(Math.max(0,Math.min(9999,L))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,M))).padStart(2,"0"),day:String(Math.max(1,Math.min(U,K.day))).padStart(2,"0")}}this.#F();let W=X.indexOf("_");H?(this.#Q=!0,this.#z=$):W>=0?this.#Z.positionInSegment=W:z>=0&&Z.index<this.#J.length-1?(this.#Z.segmentIndex=Z.index+1,this.#Z.positionInSegment=0,this.#Q=!0):this.#Z.positionInSegment=Math.min(F+1,Q.len-1)}}#L($,J){let{month:Z,day:Q}=r0($);if(J.type==="month"&&(Z<0||Z>12))return E.date.messages.invalidMonth;if(J.type==="day"&&(Q<0||Q>31))return E.date.messages.invalidDay(31,"any month")}#j($){let{year:J,month:Z,day:Q}=r0(this.#$);if(J&&Z&&Q){let Y=h1(J,Z);this.#$={...this.#$,day:String(Math.min(Q,Y)).padStart(2,"0")}}this.value=S9(this.#$)??$.defaultValue??void 0}};C9=class extends a{options;cursor=0;#J;getGroupItems(J){return this.options.filter((Z)=>Z.group===J)}isGroupSelected(J){let Z=this.getGroupItems(J),Q=this.value;return Q===void 0?!1:Z.every((Y)=>Q.includes(Y.value))}toggleValue(){let J=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),J.group===!0){let Z=J.value,Q=this.getGroupItems(Z);this.isGroupSelected(Z)?this.value=this.value.filter((Y)=>Q.findIndex((q)=>q.value===Y)===-1):this.value=[...this.value,...Q.map((Y)=>Y.value)],this.value=Array.from(new Set(this.value))}else{let Z=this.value.includes(J.value);this.value=Z?this.value.filter((Q)=>Q!==J.value):[...this.value,J.value]}}constructor(J){super(J,!1);let{options:Z}=J;this.#J=J.selectableGroups!==!1,this.options=Object.entries(Z).flatMap(([Q,Y])=>[{value:Q,group:!0,label:Q},...Y.map((q)=>({...q,group:Q}))]),this.value=[...J.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:Q})=>Q===J.cursorAt),this.#J?0:1),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Y=this.options[this.cursor]?.group===!0;!this.#J&&Y&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Y=this.options[this.cursor]?.group===!0;!this.#J&&Y&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}},l$=new Set(["up","down","left","right"]);p1=class p1 extends a{#J=!1;#Y;focused="editor";get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${$}█`;let J=$.slice(0,this.cursor),Z=$[this.cursor],Q=$.slice(this.cursor+1);return Z===`
20
20
  `?`${J}█
21
21
  ${Q}`:`${J}${E0("inverse",Z)}${Q}`}get cursor(){return this._cursor}#$($){if(this.userInput.length===0){this._setUserInput($);return}this._setUserInput(this.userInput.slice(0,this.cursor)+$+this.userInput.slice(this.cursor))}#q($){let J=this.value??"";switch($){case"up":this._cursor=i0(this._cursor,0,-1,J);return;case"down":this._cursor=i0(this._cursor,0,1,J);return;case"left":this._cursor=i0(this._cursor,-1,0,J);return;case"right":this._cursor=i0(this._cursor,1,0,J);return}}_shouldSubmit($,J){if(this.#Y)return this.focused==="submit"?!0:(this.#$(`
22
22
  `),this._cursor++,!1);let Z=this.#J;return this.#J=!0,Z?(this.userInput[this.cursor-1]===`
23
23
  `&&(this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--),!0):(this.#$(`
24
- `),this._cursor++,!1)}constructor($){super($,!1),this.#Y=$.showSubmit??!1,this.on("key",(J,Z)=>{if(Z?.name&&c$.has(Z.name)){this.#q(Z.name);return}if(J==="\t"&&this.#Y){this.focused=this.focused==="editor"?"submit":"editor";return}if(Z?.name!=="return"){if(this.#J=!1,Z?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(Z?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}J&&(this.#Y&&this.focused==="submit"&&(this.focused="editor"),this.#$(J??""),this._cursor++)}}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}};C9=class extends a{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter((J)=>J.disabled!==!0)}toggleAll(){let J=this._enabledOptions,Z=this.value!==void 0&&this.value.length===J.length;this.value=Z?[]:J.map((Q)=>Q.value)}toggleInvert(){let J=this.value;if(!J)return;let Z=this._enabledOptions.filter((Q)=>!J.includes(Q.value));this.value=Z.map((Q)=>Q.value)}toggleValue(){this.value===void 0&&(this.value=[]);let J=this.value.includes(this._value);this.value=J?this.value.filter((Z)=>Z!==this._value):[...this.value,this._value]}constructor(J){super(J,!1),this.options=J.options,this.value=[...J.initialValues??[]];let Z=Math.max(this.options.findIndex(({value:Q})=>Q===J.cursorAt),0);this.cursor=this.options[Z].disabled?s(Z,1,this.options):Z,this.on("key",(Q,Y)=>{Y.name==="a"&&this.toggleAll(),Y.name==="i"&&this.toggleInvert()}),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":this.cursor=s(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=s(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}};a1=class a1 extends a{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let $=this.userInput;if(this.cursor>=$.length)return`${this.masked}${E0(["inverse","hidden"],"_")}`;let J=this.masked,Z=J.slice(0,this.cursor),Q=J.slice(this.cursor);return`${Z}${E0("inverse",Q[0])}${Q.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:$,...J}){super(J),this._mask=$??"•",this.on("userInput",(Z)=>{this._setValue(Z)})}};i1=class i1 extends a{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let J=this.options.findIndex(({value:Q})=>Q===$.initialValue),Z=J===-1?0:J;this.cursor=this.options[Z].disabled?s(Z,1,this.options):Z,this.changeValue(),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":this.cursor=s(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=s(this.cursor,1,this.options);break}this.changeValue()})}};n1=class n1 extends a{options;cursor=0;constructor($){super($,!1),this.options=$.options;let J=$.caseSensitive===!0,Z=this.options.map(({value:[Q]})=>J?Q:Q?.toLowerCase());this.cursor=Math.max(Z.indexOf($.initialValue),0),this.on("key",(Q)=>{if(!Q)return;let Y=J?Q:Q.toLowerCase();if(!Z.includes(Y))return;let q=this.options.find(({value:[z]})=>J?z===Y:z?.toLowerCase()===Y);q&&(this.value=q.value,this.state="submit",this.emit("submit"))})}};r1=class r1 extends a{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let J=$.slice(0,this.cursor),[Z,...Q]=$.slice(this.cursor);return`${J}${E0("inverse",Z)}${Q.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}});var U0={};y0(U0,{updateSettings:()=>w9,unicodeOr:()=>R,unicode:()=>t0,text:()=>P7,tasks:()=>V7,taskLog:()=>k7,symbolBar:()=>X3,symbol:()=>c,stream:()=>H0,spinner:()=>H3,settings:()=>E,selectKey:()=>N7,select:()=>I7,progress:()=>D7,path:()=>M7,password:()=>U7,outro:()=>F7,note:()=>L7,multiselect:()=>H7,multiline:()=>X7,log:()=>m,limitOptions:()=>J0,isTTY:()=>g9,isCancel:()=>o0,isCI:()=>t1,intro:()=>G7,groupMultiselect:()=>q7,group:()=>Y7,date:()=>$7,confirm:()=>e$,cancel:()=>z7,box:()=>t$,autocompleteMultiselect:()=>n$,autocomplete:()=>n9,S_WARN:()=>G3,S_SUCCESS:()=>z3,S_STEP_SUBMIT:()=>L0,S_STEP_ERROR:()=>$3,S_STEP_CANCEL:()=>e1,S_STEP_ACTIVE:()=>m9,S_RADIO_INACTIVE:()=>W0,S_RADIO_ACTIVE:()=>O0,S_PASSWORD_MASK:()=>l9,S_INFO:()=>q3,S_ERROR:()=>F3,S_CORNER_TOP_RIGHT:()=>Z3,S_CORNER_TOP_LEFT:()=>a9,S_CORNER_BOTTOM_RIGHT:()=>Q3,S_CORNER_BOTTOM_LEFT:()=>Y3,S_CONNECT_LEFT:()=>p9,S_CHECKBOX_SELECTED:()=>K0,S_CHECKBOX_INACTIVE:()=>P0,S_CHECKBOX_ACTIVE:()=>e0,S_BAR_START_RIGHT:()=>c9,S_BAR_START:()=>J3,S_BAR_H:()=>$1,S_BAR_END_RIGHT:()=>d9,S_BAR_END:()=>v,S_BAR:()=>D});import{styleText as G,stripVTControlCharacters as s1}from"node:util";import l from"node:process";import{existsSync as d$,lstatSync as A9,readdirSync as l$}from"node:fs";import{dirname as _9,join as p$}from"node:path";function a$(){if(l.platform!=="win32")return l.env.TERM!=="linux";return Boolean(l.env.CI)||Boolean(l.env.WT_SESSION)||Boolean(l.env.TERMINUS_SUBLIME)||l.env.ConEmuTask==="{cmd::Cmder}"||l.env.TERM_PROGRAM==="Terminus-Sublime"||l.env.TERM_PROGRAM==="vscode"||l.env.TERM==="xterm-256color"||l.env.TERM==="alacritty"||l.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function y9($){return $.label??String($.value??"")}function i9($,J){if(!$)return!0;let Z=(J.label??String(J.value??"")).toLowerCase(),Q=(J.hint??"").toLowerCase(),Y=String(J.value).toLowerCase(),q=$.toLowerCase();return Z.includes(q)||Q.includes(q)||Y.includes(q)}function i$($,J){let Z=[];for(let Q of J)$.includes(Q.value)&&Z.push(Q);return Z}function x9($,J,Z,Q){let Y=Z,q=Z;return Q==="center"?Y=Math.floor((J-$)/2):Q==="right"&&(Y=J-$-Z),q=J-Y-$,[Y,q]}function J7($,J){let{segmentValues:Z,segmentCursor:Q}=$;if(J==="submit"||J==="cancel")return $.formattedValue;let Y=G("gray",$.separator);return $.segments.map((q,z)=>{let F=z===Q.segmentIndex&&!["submit","cancel"].includes(J),X=Q7[q.type];return Z7(Z[q.type],{isActive:F,label:X})}).join(Y)}function Z7($,J){let Z=!$||$.replace(/_/g,"")==="";return J.isActive?G("inverse",Z?J.label:$.replace(/_/g," ")):Z?G("dim",J.label):$.replace(/_/g,G("dim"," "))}function D7({style:$="heavy",max:J=100,size:Z=40,...Q}={}){let Y=H3(Q),q=0,z="",F=Math.max(1,J),X=Math.max(1,Z),H=(M)=>{switch(M){case"initial":case"active":return(U)=>G("magenta",U);case"error":case"cancel":return(U)=>G("red",U);case"submit":return(U)=>G("green",U);default:return(U)=>G("magenta",U)}},K=(M,U)=>{let N=Math.floor(q/F*X);return`${H(M)(h9[$].repeat(N))}${G("dim",h9[$].repeat(X-N))} ${U}`},W=(M="")=>{z=M,Y.start(K("initial",M))},L=(M=1,U)=>{q=Math.min(F,M+q),Y.message(K("active",U??z)),z=U??z};return{start:W,stop:Y.stop,cancel:Y.cancel,error:Y.error,clear:Y.clear,advance:L,isCancelled:Y.isCancelled,message:(M)=>L(0,M)}}var k0,t0,t1=()=>process.env.CI==="true",g9=($)=>$.isTTY===!0,R=($,J)=>t0?$:J,m9,e1,$3,L0,J3,D,v,c9,d9,O0,W0,e0,K0,P0,l9,$1,Z3,p9,Q3,Y3,a9,q3,z3,G3,F3,c=($)=>{switch($){case"initial":case"active":return G("cyan",m9);case"cancel":return G("red",e1);case"error":return G("yellow",$3);case"submit":return G("green",L0)}},X3=($)=>{switch($){case"initial":case"active":return G("cyan",D);case"cancel":return G("red",D);case"error":return G("yellow",D);case"submit":return G("green",D)}},T9=($,J,Z,Q,Y,q=!1)=>{let z=J,F=0;if(q)for(let X=Q-1;X>=Z&&(z-=$[X].length,F++,!(z<=Y));X--);else for(let X=Z;X<Q&&(z-=$[X].length,F++,!(z<=Y));X++);return{lineCount:z,removals:F}},J0=({cursor:$,options:J,style:Z,output:Q=process.stdout,maxItems:Y=Number.POSITIVE_INFINITY,columnPadding:q=0,rowPadding:z=4})=>{let F=X0(Q)-q,X=m1(Q),H=G("dim","..."),K=Math.max(X-z,0),W=Math.max(Math.min(Y,K),5),L=0;$>=W-3&&(L=Math.max(Math.min($-W+3,J.length-W),0));let M=W<J.length&&L>0,U=W<J.length&&L+W<J.length,N=Math.min(L+W,J.length),j=[],I=0;M&&I++,U&&I++;let V=L+(M?1:0),P=N-(U?1:0);for(let k=V;k<P;k++){let O=p(Z(J[k],k===$),F,{hard:!0,trim:!1}).split(`
25
- `);j.push(O),I+=O.length}if(I>K){let k=0,O=0,w=I,C=$-V,A=K,h=()=>T9(j,w,0,C,A),T=()=>T9(j,w,C+1,j.length,A,!0);M?({lineCount:w,removals:k}=h(),w>A&&(U||(A-=1),{lineCount:w,removals:O}=T())):(U||(A-=1),{lineCount:w,removals:O}=T(),w>A&&(A-=1,{lineCount:w,removals:k}=h())),k>0&&(M=!0,j.splice(0,k)),O>0&&(U=!0,j.splice(j.length-O,O))}let B=[];M&&B.push(H);for(let k of j)for(let O of k)B.push(O);return U&&B.push(H),B},n9=($)=>new c1({options:$.options,initialValue:$.initialValue?[$.initialValue]:void 0,initialUserInput:$.initialUserInput,placeholder:$.placeholder,filter:$.filter??((J,Z)=>i9(J,Z)),signal:$.signal,input:$.input,output:$.output,validate:$.validate,render(){let J=$.withGuide??E.withGuide,Z=J?[`${G("gray",D)}`,`${c(this.state)} ${$.message}`]:[`${c(this.state)} ${$.message}`],Q=this.userInput,Y=this.options,q=$.placeholder,z=Q===""&&q!==void 0,F=(X,H)=>{let K=y9(X),W=X.hint&&X.value===this.focusedValue?G("dim",` (${X.hint})`):"";switch(H){case"active":return`${G("green",O0)} ${K}${W}`;case"inactive":return`${G("dim",W0)} ${G("dim",K)}`;case"disabled":return`${G("gray",W0)} ${G(["strikethrough","gray"],K)}`}};switch(this.state){case"submit":{let X=i$(this.selectedValues,Y),H=X.length>0?` ${G("dim",X.map(y9).join(", "))}`:"",K=J?G("gray",D):"";return`${Z.join(`
24
+ `),this._cursor++,!1)}constructor($){super($,!1),this.#Y=$.showSubmit??!1,this.on("key",(J,Z)=>{if(Z?.name&&l$.has(Z.name)){this.#q(Z.name);return}if(J==="\t"&&this.#Y){this.focused=this.focused==="editor"?"submit":"editor";return}if(Z?.name!=="return"){if(this.#J=!1,Z?.name==="backspace"&&this.cursor>0){this._setUserInput(this.userInput.slice(0,this.cursor-1)+this.userInput.slice(this.cursor)),this._cursor--;return}if(Z?.name==="delete"&&this.cursor<this.userInput.length){this._setUserInput(this.userInput.slice(0,this.cursor)+this.userInput.slice(this.cursor+1));return}J&&(this.#Y&&this.focused==="submit"&&(this.focused="editor"),this.#$(J??""),this._cursor++)}}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}};A9=class extends a{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter((J)=>J.disabled!==!0)}toggleAll(){let J=this._enabledOptions,Z=this.value!==void 0&&this.value.length===J.length;this.value=Z?[]:J.map((Q)=>Q.value)}toggleInvert(){let J=this.value;if(!J)return;let Z=this._enabledOptions.filter((Q)=>!J.includes(Q.value));this.value=Z.map((Q)=>Q.value)}toggleValue(){this.value===void 0&&(this.value=[]);let J=this.value.includes(this._value);this.value=J?this.value.filter((Z)=>Z!==this._value):[...this.value,this._value]}constructor(J){super(J,!1),this.options=J.options,this.value=[...J.initialValues??[]];let Z=Math.max(this.options.findIndex(({value:Q})=>Q===J.cursorAt),0);this.cursor=this.options[Z].disabled?s(Z,1,this.options):Z,this.on("key",(Q,Y)=>{Y.name==="a"&&this.toggleAll(),Y.name==="i"&&this.toggleInvert()}),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":this.cursor=s(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=s(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}};a1=class a1 extends a{_mask="•";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;let $=this.userInput;if(this.cursor>=$.length)return`${this.masked}${E0(["inverse","hidden"],"_")}`;let J=this.masked,Z=J.slice(0,this.cursor),Q=J.slice(this.cursor);return`${Z}${E0("inverse",Q[0])}${Q.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:$,...J}){super(J),this._mask=$??"•",this.on("userInput",(Z)=>{this._setValue(Z)})}};i1=class i1 extends a{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor($){super($,!1),this.options=$.options;let J=this.options.findIndex(({value:Q})=>Q===$.initialValue),Z=J===-1?0:J;this.cursor=this.options[Z].disabled?s(Z,1,this.options):Z,this.changeValue(),this.on("cursor",(Q)=>{switch(Q){case"left":case"up":this.cursor=s(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=s(this.cursor,1,this.options);break}this.changeValue()})}};n1=class n1 extends a{options;cursor=0;constructor($){super($,!1),this.options=$.options;let J=$.caseSensitive===!0,Z=this.options.map(({value:[Q]})=>J?Q:Q?.toLowerCase());this.cursor=Math.max(Z.indexOf($.initialValue),0),this.on("key",(Q)=>{if(!Q)return;let Y=J?Q:Q.toLowerCase();if(!Z.includes(Y))return;let q=this.options.find(({value:[z]})=>J?z===Y:z?.toLowerCase()===Y);q&&(this.value=q.value,this.state="submit",this.emit("submit"))})}};r1=class r1 extends a{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let $=this.userInput;if(this.cursor>=$.length)return`${this.userInput}█`;let J=$.slice(0,this.cursor),[Z,...Q]=$.slice(this.cursor);return`${J}${E0("inverse",Z)}${Q.join("")}`}get cursor(){return this._cursor}constructor($){super({...$,initialUserInput:$.initialUserInput??$.initialValue}),this.on("userInput",(J)=>{this._setValue(J)}),this.on("finalize",()=>{this.value||(this.value=$.defaultValue),this.value===void 0&&(this.value="")})}}});var U0={};y0(U0,{updateSettings:()=>v9,unicodeOr:()=>R,unicode:()=>t0,text:()=>b7,tasks:()=>k7,taskLog:()=>B7,symbolBar:()=>X3,symbol:()=>c,stream:()=>H0,spinner:()=>H3,settings:()=>E,selectKey:()=>E7,select:()=>V7,progress:()=>N7,path:()=>D7,password:()=>j7,outro:()=>H7,note:()=>M7,multiselect:()=>W7,multiline:()=>K7,log:()=>m,limitOptions:()=>J0,isTTY:()=>m9,isCancel:()=>o0,isCI:()=>t1,intro:()=>X7,groupMultiselect:()=>G7,group:()=>z7,date:()=>Z7,confirm:()=>J7,cancel:()=>F7,box:()=>$7,autocompleteMultiselect:()=>o$,autocomplete:()=>r9,S_WARN:()=>G3,S_SUCCESS:()=>z3,S_STEP_SUBMIT:()=>L0,S_STEP_ERROR:()=>$3,S_STEP_CANCEL:()=>e1,S_STEP_ACTIVE:()=>c9,S_RADIO_INACTIVE:()=>W0,S_RADIO_ACTIVE:()=>O0,S_PASSWORD_MASK:()=>p9,S_INFO:()=>q3,S_ERROR:()=>F3,S_CORNER_TOP_RIGHT:()=>Z3,S_CORNER_TOP_LEFT:()=>i9,S_CORNER_BOTTOM_RIGHT:()=>Q3,S_CORNER_BOTTOM_LEFT:()=>Y3,S_CONNECT_LEFT:()=>a9,S_CHECKBOX_SELECTED:()=>K0,S_CHECKBOX_INACTIVE:()=>P0,S_CHECKBOX_ACTIVE:()=>e0,S_BAR_START_RIGHT:()=>d9,S_BAR_START:()=>J3,S_BAR_H:()=>$1,S_BAR_END_RIGHT:()=>l9,S_BAR_END:()=>f,S_BAR:()=>D});import{styleText as G,stripVTControlCharacters as s1}from"node:util";import l from"node:process";import{existsSync as p$,lstatSync as _9,readdirSync as a$}from"node:fs";import{dirname as T9,join as i$}from"node:path";function n$(){if(l.platform!=="win32")return l.env.TERM!=="linux";return Boolean(l.env.CI)||Boolean(l.env.WT_SESSION)||Boolean(l.env.TERMINUS_SUBLIME)||l.env.ConEmuTask==="{cmd::Cmder}"||l.env.TERM_PROGRAM==="Terminus-Sublime"||l.env.TERM_PROGRAM==="vscode"||l.env.TERM==="xterm-256color"||l.env.TERM==="alacritty"||l.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function x9($){return $.label??String($.value??"")}function n9($,J){if(!$)return!0;let Z=(J.label??String(J.value??"")).toLowerCase(),Q=(J.hint??"").toLowerCase(),Y=String(J.value).toLowerCase(),q=$.toLowerCase();return Z.includes(q)||Q.includes(q)||Y.includes(q)}function r$($,J){let Z=[];for(let Q of J)$.includes(Q.value)&&Z.push(Q);return Z}function h9($,J,Z,Q){let Y=Z,q=Z;return Q==="center"?Y=Math.floor((J-$)/2):Q==="right"&&(Y=J-$-Z),q=J-Y-$,[Y,q]}function Q7($,J){let{segmentValues:Z,segmentCursor:Q}=$;if(J==="submit"||J==="cancel")return $.formattedValue;let Y=G("gray",$.separator);return $.segments.map((q,z)=>{let F=z===Q.segmentIndex&&!["submit","cancel"].includes(J),X=q7[q.type];return Y7(Z[q.type],{isActive:F,label:X})}).join(Y)}function Y7($,J){let Z=!$||$.replace(/_/g,"")==="";return J.isActive?G("inverse",Z?J.label:$.replace(/_/g," ")):Z?G("dim",J.label):$.replace(/_/g,G("dim"," "))}function N7({style:$="heavy",max:J=100,size:Z=40,...Q}={}){let Y=H3(Q),q=0,z="",F=Math.max(1,J),X=Math.max(1,Z),H=(M)=>{switch(M){case"initial":case"active":return(U)=>G("magenta",U);case"error":case"cancel":return(U)=>G("red",U);case"submit":return(U)=>G("green",U);default:return(U)=>G("magenta",U)}},K=(M,U)=>{let N=Math.floor(q/F*X);return`${H(M)(u9[$].repeat(N))}${G("dim",u9[$].repeat(X-N))} ${U}`},W=(M="")=>{z=M,Y.start(K("initial",M))},L=(M=1,U)=>{q=Math.min(F,M+q),Y.message(K("active",U??z)),z=U??z};return{start:W,stop:Y.stop,cancel:Y.cancel,error:Y.error,clear:Y.clear,advance:L,isCancelled:Y.isCancelled,message:(M)=>L(0,M)}}var k0,t0,t1=()=>process.env.CI==="true",m9=($)=>$.isTTY===!0,R=($,J)=>t0?$:J,c9,e1,$3,L0,J3,D,f,d9,l9,O0,W0,e0,K0,P0,p9,$1,Z3,a9,Q3,Y3,i9,q3,z3,G3,F3,c=($)=>{switch($){case"initial":case"active":return G("cyan",c9);case"cancel":return G("red",e1);case"error":return G("yellow",$3);case"submit":return G("green",L0)}},X3=($)=>{switch($){case"initial":case"active":return G("cyan",D);case"cancel":return G("red",D);case"error":return G("yellow",D);case"submit":return G("green",D)}},y9=($,J,Z,Q,Y,q=!1)=>{let z=J,F=0;if(q)for(let X=Q-1;X>=Z&&(z-=$[X].length,F++,!(z<=Y));X--);else for(let X=Z;X<Q&&(z-=$[X].length,F++,!(z<=Y));X++);return{lineCount:z,removals:F}},J0=({cursor:$,options:J,style:Z,output:Q=process.stdout,maxItems:Y=Number.POSITIVE_INFINITY,columnPadding:q=0,rowPadding:z=4})=>{let F=X0(Q)-q,X=m1(Q),H=G("dim","..."),K=Math.max(X-z,0),W=Math.max(Math.min(Y,K),5),L=0;$>=W-3&&(L=Math.max(Math.min($-W+3,J.length-W),0));let M=W<J.length&&L>0,U=W<J.length&&L+W<J.length,N=Math.min(L+W,J.length),j=[],I=0;M&&I++,U&&I++;let V=L+(M?1:0),P=N-(U?1:0);for(let k=V;k<P;k++){let O=p(Z(J[k],k===$),F,{hard:!0,trim:!1}).split(`
25
+ `);j.push(O),I+=O.length}if(I>K){let k=0,O=0,w=I,C=$-V,A=K,h=()=>y9(j,w,0,C,A),T=()=>y9(j,w,C+1,j.length,A,!0);M?({lineCount:w,removals:k}=h(),w>A&&(U||(A-=1),{lineCount:w,removals:O}=T())):(U||(A-=1),{lineCount:w,removals:O}=T(),w>A&&(A-=1,{lineCount:w,removals:k}=h())),k>0&&(M=!0,j.splice(0,k)),O>0&&(U=!0,j.splice(j.length-O,O))}let B=[];M&&B.push(H);for(let k of j)for(let O of k)B.push(O);return U&&B.push(H),B},r9=($)=>new c1({options:$.options,initialValue:$.initialValue?[$.initialValue]:void 0,initialUserInput:$.initialUserInput,placeholder:$.placeholder,filter:$.filter??((J,Z)=>n9(J,Z)),signal:$.signal,input:$.input,output:$.output,validate:$.validate,render(){let J=$.withGuide??E.withGuide,Z=J?[`${G("gray",D)}`,`${c(this.state)} ${$.message}`]:[`${c(this.state)} ${$.message}`],Q=this.userInput,Y=this.options,q=$.placeholder,z=Q===""&&q!==void 0,F=(X,H)=>{let K=x9(X),W=X.hint&&X.value===this.focusedValue?G("dim",` (${X.hint})`):"";switch(H){case"active":return`${G("green",O0)} ${K}${W}`;case"inactive":return`${G("dim",W0)} ${G("dim",K)}`;case"disabled":return`${G("gray",W0)} ${G(["strikethrough","gray"],K)}`}};switch(this.state){case"submit":{let X=r$(this.selectedValues,Y),H=X.length>0?` ${G("dim",X.map(x9).join(", "))}`:"",K=J?G("gray",D):"";return`${Z.join(`
26
26
  `)}
27
27
  ${K}${H}`}case"cancel":{let X=Q?` ${G(["strikethrough","dim"],Q)}`:"",H=J?G("gray",D):"";return`${Z.join(`
28
28
  `)}
29
- ${H}${X}`}default:{let X=this.state==="error"?"yellow":"cyan",H=J?`${G(X,D)} `:"",K=J?G(X,v):"",W="";if(this.isNavigating||z){let V=z?q:Q;W=V!==""?` ${G("dim",V)}`:""}else W=` ${this.userInputWithCursor}`;let L=this.filteredOptions.length!==Y.length?G("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",M=this.filteredOptions.length===0&&Q?[`${H}${G("yellow","No matches found")}`]:[],U=this.state==="error"?[`${H}${G("yellow",this.error)}`]:[];J&&Z.push(`${H.trimEnd()}`),Z.push(`${H}${G("dim","Search:")}${W}${L}`,...M,...U);let N=[`${G("dim","↑/↓")} to select`,`${G("dim","Enter:")} confirm`,`${G("dim","Type:")} to search`],j=[`${H}${N.join(" • ")}`,K],I=this.filteredOptions.length===0?[]:J0({cursor:this.cursor,options:this.filteredOptions,columnPadding:J?3:0,rowPadding:Z.length+j.length,style:(V,P)=>F(V,V.disabled?"disabled":P?"active":"inactive"),maxItems:$.maxItems,output:$.output});return[...Z,...I.map((V)=>`${H}${V}`),...j].join(`
30
- `)}}}}).prompt(),n$=($)=>{let J=(Q,Y,q,z)=>{let F=q.includes(Q.value),X=Q.label??String(Q.value??""),H=Q.hint&&z!==void 0&&Q.value===z?G("dim",` (${Q.hint})`):"",K=F?G("green",K0):G("dim",P0);return Q.disabled?`${G("gray",P0)} ${G(["strikethrough","gray"],X)}`:Y?`${K} ${X}${H}`:`${K} ${G("dim",X)}`},Z=new c1({options:$.options,multiple:!0,placeholder:$.placeholder,filter:$.filter??((Q,Y)=>i9(Q,Y)),validate:()=>{if($.required&&Z.selectedValues.length===0)return"Please select at least one item"},initialValue:$.initialValues,signal:$.signal,input:$.input,output:$.output,render(){let Q=$.withGuide??E.withGuide,Y=`${Q?`${G("gray",D)}
29
+ ${H}${X}`}default:{let X=this.state==="error"?"yellow":"cyan",H=J?`${G(X,D)} `:"",K=J?G(X,f):"",W="";if(this.isNavigating||z){let V=z?q:Q;W=V!==""?` ${G("dim",V)}`:""}else W=` ${this.userInputWithCursor}`;let L=this.filteredOptions.length!==Y.length?G("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"",M=this.filteredOptions.length===0&&Q?[`${H}${G("yellow","No matches found")}`]:[],U=this.state==="error"?[`${H}${G("yellow",this.error)}`]:[];J&&Z.push(`${H.trimEnd()}`),Z.push(`${H}${G("dim","Search:")}${W}${L}`,...M,...U);let N=[`${G("dim","↑/↓")} to select`,`${G("dim","Enter:")} confirm`,`${G("dim","Type:")} to search`],j=[`${H}${N.join(" • ")}`,K],I=this.filteredOptions.length===0?[]:J0({cursor:this.cursor,options:this.filteredOptions,columnPadding:J?3:0,rowPadding:Z.length+j.length,style:(V,P)=>F(V,V.disabled?"disabled":P?"active":"inactive"),maxItems:$.maxItems,output:$.output});return[...Z,...I.map((V)=>`${H}${V}`),...j].join(`
30
+ `)}}}}).prompt(),o$=($)=>{let J=(Q,Y,q,z)=>{let F=q.includes(Q.value),X=Q.label??String(Q.value??""),H=Q.hint&&z!==void 0&&Q.value===z?G("dim",` (${Q.hint})`):"",K=F?G("green",K0):G("dim",P0);return Q.disabled?`${G("gray",P0)} ${G(["strikethrough","gray"],X)}`:Y?`${K} ${X}${H}`:`${K} ${G("dim",X)}`},Z=new c1({options:$.options,multiple:!0,placeholder:$.placeholder,filter:$.filter??((Q,Y)=>n9(Q,Y)),validate:()=>{if($.required&&Z.selectedValues.length===0)return"Please select at least one item"},initialValue:$.initialValues,signal:$.signal,input:$.input,output:$.output,render(){let Q=$.withGuide??E.withGuide,Y=`${Q?`${G("gray",D)}
31
31
  `:""}${c(this.state)} ${$.message}
32
- `,q=this.userInput,z=$.placeholder,F=q===""&&z!==void 0,X=this.isNavigating||F?G("dim",F?z:q):this.userInputWithCursor,H=this.options,K=this.filteredOptions.length!==H.length?G("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${Y}${Q?`${G("gray",D)} `:""}${G("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${Y}${Q?`${G("gray",D)} `:""}${G(["strikethrough","dim"],q)}`;default:{let W=this.state==="error"?"yellow":"cyan",L=Q?`${G(W,D)} `:"",M=Q?G(W,v):"",U=[`${G("dim","↑/↓")} to navigate`,`${G("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${G("dim","Enter:")} confirm`,`${G("dim","Type:")} to search`],N=this.filteredOptions.length===0&&q?[`${L}${G("yellow","No matches found")}`]:[],j=this.state==="error"?[`${L}${G("yellow",this.error)}`]:[],I=[...`${Y}${Q?G(W,D):""}`.split(`
32
+ `,q=this.userInput,z=$.placeholder,F=q===""&&z!==void 0,X=this.isNavigating||F?G("dim",F?z:q):this.userInputWithCursor,H=this.options,K=this.filteredOptions.length!==H.length?G("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${Y}${Q?`${G("gray",D)} `:""}${G("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${Y}${Q?`${G("gray",D)} `:""}${G(["strikethrough","dim"],q)}`;default:{let W=this.state==="error"?"yellow":"cyan",L=Q?`${G(W,D)} `:"",M=Q?G(W,f):"",U=[`${G("dim","↑/↓")} to navigate`,`${G("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${G("dim","Enter:")} confirm`,`${G("dim","Type:")} to search`],N=this.filteredOptions.length===0&&q?[`${L}${G("yellow","No matches found")}`]:[],j=this.state==="error"?[`${L}${G("yellow",this.error)}`]:[],I=[...`${Y}${Q?G(W,D):""}`.split(`
33
33
  `),`${L}${G("dim","Search:")} ${X}${K}`,...N,...j],V=[`${L}${U.join(" • ")}`,M],P=J0({cursor:this.cursor,options:this.filteredOptions,style:(B,k)=>J(B,k,this.selectedValues,this.focusedValue),maxItems:$.maxItems,output:$.output,rowPadding:I.length+V.length});return[...I,...P.map((B)=>`${L}${B}`),...V].join(`
34
- `)}}}});return Z.prompt()},r$,o$,s$=($)=>$,t$=($="",J="",Z)=>{let Q=Z?.output??process.stdout,Y=X0(Q),z=Z?.titlePadding??1,F=Z?.contentPadding??2,X=Z?.width===void 0||Z.width==="auto"?1:Math.min(1,Z.width),H=Z?.withGuide??E.withGuide?`${D} `:"",K=Z?.formatBorder??s$,W=((Z?.rounded)?r$:o$).map(K),L=K($1),M=K(D),U=y(H),N=y(J),j=Y-U,I=Math.floor(Y*X)-U;if(Z?.width==="auto"){let A=$.split(`
35
- `),h=N+z*2;for(let D0 of A){let e=y(D0)+F*2;e>h&&(h=e)}let T=h+2;T<I&&(I=T)}I%2!==0&&(I<j?I++:I--);let V=I-2,P=V-z*2,B=N>P?`${J.slice(0,P-3)}...`:J,[k,O]=x9(y(B),V,z,Z?.titleAlign),w=p($,V-F*2,{hard:!0,trim:!1});Q.write(`${H}${W[0]}${L.repeat(k)}${B}${L.repeat(O)}${W[1]}
34
+ `)}}}});return Z.prompt()},s$,t$,e$=($)=>$,$7=($="",J="",Z)=>{let Q=Z?.output??process.stdout,Y=X0(Q),z=Z?.titlePadding??1,F=Z?.contentPadding??2,X=Z?.width===void 0||Z.width==="auto"?1:Math.min(1,Z.width),H=Z?.withGuide??E.withGuide?`${D} `:"",K=Z?.formatBorder??e$,W=((Z?.rounded)?s$:t$).map(K),L=K($1),M=K(D),U=y(H),N=y(J),j=Y-U,I=Math.floor(Y*X)-U;if(Z?.width==="auto"){let A=$.split(`
35
+ `),h=N+z*2;for(let D0 of A){let e=y(D0)+F*2;e>h&&(h=e)}let T=h+2;T<I&&(I=T)}I%2!==0&&(I<j?I++:I--);let V=I-2,P=V-z*2,B=N>P?`${J.slice(0,P-3)}...`:J,[k,O]=h9(y(B),V,z,Z?.titleAlign),w=p($,V-F*2,{hard:!0,trim:!1});Q.write(`${H}${W[0]}${L.repeat(k)}${B}${L.repeat(O)}${W[1]}
36
36
  `);let C=w.split(`
37
- `);for(let A of C){let[h,T]=x9(y(A),V,F,Z?.contentAlign);Q.write(`${H}${M}${" ".repeat(h)}${A}${" ".repeat(T)}${M}
37
+ `);for(let A of C){let[h,T]=h9(y(A),V,F,Z?.contentAlign);Q.write(`${H}${M}${" ".repeat(h)}${A}${" ".repeat(T)}${M}
38
38
  `)}Q.write(`${H}${W[2]}${L.repeat(V)}${W[3]}
39
- `)},e$=($)=>{let J=$.active??"Yes",Z=$.inactive??"No";return new d1({active:J,inactive:Z,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let Q=$.withGuide??E.withGuide,Y=`${c(this.state)} `,q=Q?`${G("gray",D)} `:"",z=_($.output,$.message,q,Y),F=`${Q?`${G("gray",D)}
39
+ `)},J7=($)=>{let J=$.active??"Yes",Z=$.inactive??"No";return new d1({active:J,inactive:Z,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue??!0,render(){let Q=$.withGuide??E.withGuide,Y=`${c(this.state)} `,q=Q?`${G("gray",D)} `:"",z=_($.output,$.message,q,Y),F=`${Q?`${G("gray",D)}
40
40
  `:""}${z}
41
41
  `,X=this.value?J:Z;switch(this.state){case"submit":{let H=Q?`${G("gray",D)} `:"";return`${F}${H}${G("dim",X)}`}case"cancel":{let H=Q?`${G("gray",D)} `:"";return`${F}${H}${G(["strikethrough","dim"],X)}${Q?`
42
- ${G("gray",D)}`:""}`}default:{let H=Q?`${G("cyan",D)} `:"",K=Q?G("cyan",v):"";return`${F}${H}${this.value?`${G("green",O0)} ${J}`:`${G("dim",W0)} ${G("dim",J)}`}${$.vertical?Q?`
42
+ ${G("gray",D)}`:""}`}default:{let H=Q?`${G("cyan",D)} `:"",K=Q?G("cyan",f):"";return`${F}${H}${this.value?`${G("green",O0)} ${J}`:`${G("dim",W0)} ${G("dim",J)}`}${$.vertical?Q?`
43
43
  ${G("cyan",D)} `:`
44
44
  `:` ${G("dim","/")} `}${this.value?`${G("dim",W0)} ${G("dim",Z)}`:`${G("green",O0)} ${Z}`}
45
45
  ${K}
46
- `}}}}).prompt()},$7=($)=>{let J=$.validate;return new l1({...$,validate(Z){if(Z===void 0)return $.defaultValue!==void 0?void 0:J?f0(J,Z):E.date.messages.required;let Q=(Y)=>Y.toISOString().slice(0,10);if($.minDate&&Q(Z)<Q($.minDate))return E.date.messages.afterMin($.minDate);if($.maxDate&&Q(Z)>Q($.maxDate))return E.date.messages.beforeMax($.maxDate);if(J)return f0(J,Z)},render(){let Z=($?.withGuide??E.withGuide)!==!1,Q=`${`${Z?`${G("gray",D)}
46
+ `}}}}).prompt()},Z7=($)=>{let J=$.validate;return new l1({...$,validate(Z){if(Z===void 0)return $.defaultValue!==void 0?void 0:J?v0(J,Z):E.date.messages.required;let Q=(Y)=>Y.toISOString().slice(0,10);if($.minDate&&Q(Z)<Q($.minDate))return E.date.messages.afterMin($.minDate);if($.maxDate&&Q(Z)>Q($.maxDate))return E.date.messages.beforeMax($.maxDate);if(J)return v0(J,Z)},render(){let Z=($?.withGuide??E.withGuide)!==!1,Q=`${`${Z?`${G("gray",D)}
47
47
  `:""}${c(this.state)} `}${$.message}
48
- `,Y=this.state!=="initial"?this.state:"active",q=J7(this,Y),z=this.value instanceof Date?this.formattedValue:"";switch(this.state){case"error":{let F=this.error?` ${G("yellow",this.error)}`:"",X=Z?`${G("yellow",D)} `:"",H=Z?G("yellow",v):"";return`${Q.trim()}
48
+ `,Y=this.state!=="initial"?this.state:"active",q=Q7(this,Y),z=this.value instanceof Date?this.formattedValue:"";switch(this.state){case"error":{let F=this.error?` ${G("yellow",this.error)}`:"",X=Z?`${G("yellow",D)} `:"",H=Z?G("yellow",f):"";return`${Q.trim()}
49
49
  ${X}${q}
50
50
  ${H}${F}
51
51
  `}case"submit":{let F=z?` ${G("dim",z)}`:"",X=Z?G("gray",D):"";return`${Q}${X}${F}`}case"cancel":{let F=z?` ${G(["strikethrough","dim"],z)}`:"",X=Z?G("gray",D):"";return`${Q}${X}${F}${z.trim()?`
52
- ${X}`:""}`}default:{let F=Z?`${G("cyan",D)} `:"",X=Z?G("cyan",v):"",H=Z?`${G("cyan",D)} `:"",K=this.inlineError?`
52
+ ${X}`:""}`}default:{let F=Z?`${G("cyan",D)} `:"",X=Z?G("cyan",f):"",H=Z?`${G("cyan",D)} `:"",K=this.inlineError?`
53
53
  ${H}${G("yellow",this.inlineError)}`:"";return`${Q}${F}${q}${K}
54
54
  ${X}
55
- `}}}}).prompt()},Q7,Y7=async($,J)=>{let Z={},Q=Object.keys($);for(let Y of Q){let q=$[Y],z=await q({results:Z})?.catch((F)=>{throw F});if(typeof J?.onCancel=="function"&&o0(z)){Z[Y]="canceled",J.onCancel({results:Z});continue}Z[Y]=z}return Z},q7=($)=>{let{selectableGroups:J=!0,groupSpacing:Z=0}=$,Q=(q,z,F=[])=>{let X=q.label??String(q.value),H=typeof q.group=="string",K=H&&(F[F.indexOf(q)+1]??{group:!0}),W=H&&K&&K.group===!0,L="",M="";H&&(J?(L=W?`${v} `:`${D} `,M=W?" ":`${D} `):L=" ");let U="";if(Z>0&&!H&&(U=`
56
- `.repeat(Z)),z==="active")return _($.output,`${X}${q.hint?` ${G("dim",`(${q.hint})`)}`:""}`,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${G("cyan",e0)} `,`${U}${G("dim",M)} `);if(z==="group-active")return _($.output,X,`${U}${L} `,`${U}${L}${G("cyan",e0)} `,`${U}${M} `,(j)=>G("dim",j));if(z==="group-active-selected")return _($.output,X,`${U}${L} `,`${U}${L}${G("green",K0)} `,`${U}${M} `,(j)=>G("dim",j));if(z==="selected"){let j=H||J?G("green",K0):"";return _($.output,`${X}${q.hint?` (${q.hint})`:""}`,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${j} `,`${U}${G("dim",M)} `,(I)=>G("dim",I))}if(z==="cancelled")return`${G(["strikethrough","dim"],X)}`;if(z==="active-selected")return _($.output,`${X}${q.hint?` ${G("dim",`(${q.hint})`)}`:""}`,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${G("green",K0)} `,`${U}${G("dim",M)} `);if(z==="submitted")return`${G("dim",X)}`;let N=H||J?G("dim",P0):"";return _($.output,X,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${N} `,`${U}${G("dim",M)} `,(j)=>G("dim",j))},Y=$.required??!0;return new O9({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:Y,cursorAt:$.cursorAt,selectableGroups:J,validate(q){if(Y&&(q===void 0||q.length===0))return`Please select at least one option.
55
+ `}}}}).prompt()},q7,z7=async($,J)=>{let Z={},Q=Object.keys($);for(let Y of Q){let q=$[Y],z=await q({results:Z})?.catch((F)=>{throw F});if(typeof J?.onCancel=="function"&&o0(z)){Z[Y]="canceled",J.onCancel({results:Z});continue}Z[Y]=z}return Z},G7=($)=>{let{selectableGroups:J=!0,groupSpacing:Z=0}=$,Q=(q,z,F=[])=>{let X=q.label??String(q.value),H=typeof q.group=="string",K=H&&(F[F.indexOf(q)+1]??{group:!0}),W=H&&K&&K.group===!0,L="",M="";H&&(J?(L=W?`${f} `:`${D} `,M=W?" ":`${D} `):L=" ");let U="";if(Z>0&&!H&&(U=`
56
+ `.repeat(Z)),z==="active")return _($.output,`${X}${q.hint?` ${G("dim",`(${q.hint})`)}`:""}`,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${G("cyan",e0)} `,`${U}${G("dim",M)} `);if(z==="group-active")return _($.output,X,`${U}${L} `,`${U}${L}${G("cyan",e0)} `,`${U}${M} `,(j)=>G("dim",j));if(z==="group-active-selected")return _($.output,X,`${U}${L} `,`${U}${L}${G("green",K0)} `,`${U}${M} `,(j)=>G("dim",j));if(z==="selected"){let j=H||J?G("green",K0):"";return _($.output,`${X}${q.hint?` (${q.hint})`:""}`,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${j} `,`${U}${G("dim",M)} `,(I)=>G("dim",I))}if(z==="cancelled")return`${G(["strikethrough","dim"],X)}`;if(z==="active-selected")return _($.output,`${X}${q.hint?` ${G("dim",`(${q.hint})`)}`:""}`,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${G("green",K0)} `,`${U}${G("dim",M)} `);if(z==="submitted")return`${G("dim",X)}`;let N=H||J?G("dim",P0):"";return _($.output,X,`${U}${G("dim",L)} `,`${U}${G("dim",L)}${N} `,`${U}${G("dim",M)} `,(j)=>G("dim",j))},Y=$.required??!0;return new C9({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:Y,cursorAt:$.cursorAt,selectableGroups:J,validate(q){if(Y&&(q===void 0||q.length===0))return`Please select at least one option.
57
57
  ${G("reset",G("dim",`Press ${G(["gray","bgWhite","inverse"]," space ")} to select, ${G("gray",G(["bgWhite","inverse"]," enter "))} to submit`))}`},render(){let q=$.withGuide??E.withGuide,z=`${q?`${G("gray",D)}
58
58
  `:""}${c(this.state)} ${$.message}
59
59
  `,F=this.value??[],X=(H,K)=>{let W=this.options,L=F.includes(H.value)||H.group===!0&&this.isGroupSelected(`${H.value}`);return!K&&typeof H.group=="string"&&this.options[this.cursor].value===H.group?Q(H,L?"group-active-selected":"group-active",W):K&&L?Q(H,"active-selected",W):L?Q(H,"selected",W):Q(H,K?"active":"inactive",W)};switch(this.state){case"submit":{let H=this.options.filter(({value:W})=>F.includes(W)).map((W)=>Q(W,"submitted")),K=H.length===0?"":` ${H.join(G("dim",", "))}`;return`${z}${q?G("gray",D):""}${K}`}case"cancel":{let H=this.options.filter(({value:K})=>F.includes(K)).map((K)=>Q(K,"cancelled")).join(G("dim",", "));return`${z}${q?`${G("gray",D)} `:""}${H.trim()?`${H}${q?`
60
60
  ${G("gray",D)}`:""}`:""}`}case"error":{let H=q?`${G("yellow",D)} `:"",K=this.error.split(`
61
- `).map((U,N)=>N===0?`${q?`${G("yellow",v)} `:""}${G("yellow",U)}`:` ${U}`).join(`
61
+ `).map((U,N)=>N===0?`${q?`${G("yellow",f)} `:""}${G("yellow",U)}`:` ${U}`).join(`
62
62
  `),W=z.split(`
63
63
  `).length,L=K.split(`
64
64
  `).length+1,M=J0({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:H.length,rowPadding:W+L,style:X}).join(`
@@ -67,28 +67,28 @@ ${K}
67
67
  `}default:{let H=q?`${G("cyan",D)} `:"",K=z.split(`
68
68
  `).length,W=(q?1:0)+1,L=J0({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:H.length,rowPadding:K+W,style:X}).join(`
69
69
  ${H}`);return`${z}${H}${L}
70
- ${q?G("cyan",v):""}
71
- `}}}}).prompt()},m,z7=($="",J)=>{let Z=J?.output??process.stdout,Q=J?.withGuide??E.withGuide?`${G("gray",v)} `:"";Z.write(`${Q}${G("red",$)}
70
+ ${q?G("cyan",f):""}
71
+ `}}}}).prompt()},m,F7=($="",J)=>{let Z=J?.output??process.stdout,Q=J?.withGuide??E.withGuide?`${G("gray",f)} `:"";Z.write(`${Q}${G("red",$)}
72
72
 
73
- `)},G7=($="",J)=>{let Z=J?.output??process.stdout,Q=J?.withGuide??E.withGuide?`${G("gray",J3)} `:"";Z.write(`${Q}${$}
74
- `)},F7=($="",J)=>{let Z=J?.output??process.stdout,Q=J?.withGuide??E.withGuide?`${G("gray",D)}
75
- ${G("gray",v)} `:"";Z.write(`${Q}${$}
73
+ `)},X7=($="",J)=>{let Z=J?.output??process.stdout,Q=J?.withGuide??E.withGuide?`${G("gray",J3)} `:"";Z.write(`${Q}${$}
74
+ `)},H7=($="",J)=>{let Z=J?.output??process.stdout,Q=J?.withGuide??E.withGuide?`${G("gray",D)}
75
+ ${G("gray",f)} `:"";Z.write(`${Q}${$}
76
76
 
77
- `)},X7=($)=>new p1({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,showSubmit:$.showSubmit,output:$.output,signal:$.signal,input:$.input,render(){let J=$?.withGuide??E.withGuide,Z=`${`${J?`${G("gray",D)}
77
+ `)},K7=($)=>new p1({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,showSubmit:$.showSubmit,output:$.output,signal:$.signal,input:$.input,render(){let J=$?.withGuide??E.withGuide,Z=`${`${J?`${G("gray",D)}
78
78
  `:""}${c(this.state)} `}${$.message}
79
79
  `,Q=$.placeholder?G("inverse",$.placeholder[0])+G("dim",$.placeholder.slice(1)):G(["inverse","hidden"],"_"),Y=this.userInput?this.userInputWithCursor:Q,q=this.value??"",z=$.showSubmit?`
80
- ${G(this.focused==="submit"?"cyan":"dim","[ submit ]")}`:"";switch(this.state){case"error":{let F=`${G("yellow",D)} `,X=J?_($.output,Y,F,void 0):Y,H=G("yellow",v);return`${Z}${X}
80
+ ${G(this.focused==="submit"?"cyan":"dim","[ submit ]")}`:"";switch(this.state){case"error":{let F=`${G("yellow",D)} `,X=J?_($.output,Y,F,void 0):Y,H=G("yellow",f);return`${Z}${X}
81
81
  ${H} ${G("yellow",this.error)}${z}
82
- `}case"submit":{let F=`${G("gray",D)} `,X=J?_($.output,q,F,void 0,void 0,(H)=>G("dim",H)):q?G("dim",q):"";return`${Z}${X}`}case"cancel":{let F=`${G("gray",D)} `,X=J?_($.output,q,F,void 0,void 0,(H)=>G(["strikethrough","dim"],H)):q?G(["strikethrough","dim"],q):"";return`${Z}${X}`}default:{let F=J?`${G("cyan",D)} `:"",X=J?G("cyan",v):"",H=J?_($.output,Y,F):Y;return`${Z}${H}
82
+ `}case"submit":{let F=`${G("gray",D)} `,X=J?_($.output,q,F,void 0,void 0,(H)=>G("dim",H)):q?G("dim",q):"";return`${Z}${X}`}case"cancel":{let F=`${G("gray",D)} `,X=J?_($.output,q,F,void 0,void 0,(H)=>G(["strikethrough","dim"],H)):q?G(["strikethrough","dim"],q):"";return`${Z}${X}`}default:{let F=J?`${G("cyan",D)} `:"",X=J?G("cyan",f):"",H=J?_($.output,Y,F):Y;return`${Z}${H}
83
83
  ${X}${z}
84
- `}}}}).prompt(),v0=($,J)=>$.split(`
84
+ `}}}}).prompt(),f0=($,J)=>$.split(`
85
85
  `).map((Z)=>J(Z)).join(`
86
- `),H7=($)=>{let J=(Q,Y)=>{let q=Q.label??String(Q.value);return Y==="disabled"?`${G("gray",P0)} ${v0(q,(z)=>G(["strikethrough","gray"],z))}${Q.hint?` ${G("dim",`(${Q.hint??"disabled"})`)}`:""}`:Y==="active"?`${G("cyan",e0)} ${q}${Q.hint?` ${G("dim",`(${Q.hint})`)}`:""}`:Y==="selected"?`${G("green",K0)} ${v0(q,(z)=>G("dim",z))}${Q.hint?` ${G("dim",`(${Q.hint})`)}`:""}`:Y==="cancelled"?`${v0(q,(z)=>G(["strikethrough","dim"],z))}`:Y==="active-selected"?`${G("green",K0)} ${q}${Q.hint?` ${G("dim",`(${Q.hint})`)}`:""}`:Y==="submitted"?`${v0(q,(z)=>G("dim",z))}`:`${G("dim",P0)} ${v0(q,(z)=>G("dim",z))}`},Z=$.required??!0;return new C9({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:Z,cursorAt:$.cursorAt,validate(Q){if(Z&&(Q===void 0||Q.length===0))return`Please select at least one option.
86
+ `),W7=($)=>{let J=(Q,Y)=>{let q=Q.label??String(Q.value);return Y==="disabled"?`${G("gray",P0)} ${f0(q,(z)=>G(["strikethrough","gray"],z))}${Q.hint?` ${G("dim",`(${Q.hint??"disabled"})`)}`:""}`:Y==="active"?`${G("cyan",e0)} ${q}${Q.hint?` ${G("dim",`(${Q.hint})`)}`:""}`:Y==="selected"?`${G("green",K0)} ${f0(q,(z)=>G("dim",z))}${Q.hint?` ${G("dim",`(${Q.hint})`)}`:""}`:Y==="cancelled"?`${f0(q,(z)=>G(["strikethrough","dim"],z))}`:Y==="active-selected"?`${G("green",K0)} ${q}${Q.hint?` ${G("dim",`(${Q.hint})`)}`:""}`:Y==="submitted"?`${f0(q,(z)=>G("dim",z))}`:`${G("dim",P0)} ${f0(q,(z)=>G("dim",z))}`},Z=$.required??!0;return new A9({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValues:$.initialValues,required:Z,cursorAt:$.cursorAt,validate(Q){if(Z&&(Q===void 0||Q.length===0))return`Please select at least one option.
87
87
  ${G("reset",G("dim",`Press ${G(["gray","bgWhite","inverse"]," space ")} to select, ${G("gray",G("bgWhite",G("inverse"," enter ")))} to submit`))}`},render(){let Q=$.withGuide??E.withGuide,Y=_($.output,$.message,Q?`${X3(this.state)} `:"",`${c(this.state)} `),q=`${Q?`${G("gray",D)}
88
88
  `:""}${Y}
89
89
  `,z=this.value??[],F=(X,H)=>{if(X.disabled)return J(X,"disabled");let K=z.includes(X.value);return H&&K?J(X,"active-selected"):K?J(X,"selected"):J(X,H?"active":"inactive")};switch(this.state){case"submit":{let X=this.options.filter(({value:K})=>z.includes(K)).map((K)=>J(K,"submitted")).join(G("dim",", "))||G("dim","none"),H=_($.output,X,Q?`${G("gray",D)} `:"");return`${q}${H}`}case"cancel":{let X=this.options.filter(({value:K})=>z.includes(K)).map((K)=>J(K,"cancelled")).join(G("dim",", "));if(X.trim()==="")return`${q}${G("gray",D)}`;let H=_($.output,X,Q?`${G("gray",D)} `:"");return`${q}${H}${Q?`
90
90
  ${G("gray",D)}`:""}`}case"error":{let X=Q?`${G("yellow",D)} `:"",H=this.error.split(`
91
- `).map((L,M)=>M===0?`${Q?`${G("yellow",v)} `:""}${G("yellow",L)}`:` ${L}`).join(`
91
+ `).map((L,M)=>M===0?`${Q?`${G("yellow",f)} `:""}${G("yellow",L)}`:` ${L}`).join(`
92
92
  `),K=q.split(`
93
93
  `).length,W=H.split(`
94
94
  `).length+1;return`${q}${X}${J0({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:X.length,rowPadding:K+W,style:F}).join(`
@@ -97,44 +97,44 @@ ${H}
97
97
  `}default:{let X=Q?`${G("cyan",D)} `:"",H=q.split(`
98
98
  `).length,K=Q?2:1;return`${q}${X}${J0({output:$.output,options:this.options,cursor:this.cursor,maxItems:$.maxItems,columnPadding:X.length,rowPadding:H+K,style:F}).join(`
99
99
  ${X}`)}
100
- ${Q?G("cyan",v):""}
101
- `}}}}).prompt()},K7=($)=>G("dim",$),W7=($,J,Z)=>{let Q={hard:!0,trim:!1},Y=p($,J,Q).split(`
102
- `),q=Y.reduce((X,H)=>Math.max(y(H),X),0),z=Y.map(Z).reduce((X,H)=>Math.max(y(H),X),0),F=J-(z-q);return p($,F,Q)},L7=($="",J="",Z)=>{let Q=Z?.output??l.stdout,Y=Z?.withGuide??E.withGuide,q=Z?.format??K7,z=["",...W7($,X0(Q)-6,q).split(`
100
+ ${Q?G("cyan",f):""}
101
+ `}}}}).prompt()},L7=($)=>G("dim",$),U7=($,J,Z)=>{let Q={hard:!0,trim:!1},Y=p($,J,Q).split(`
102
+ `),q=Y.reduce((X,H)=>Math.max(y(H),X),0),z=Y.map(Z).reduce((X,H)=>Math.max(y(H),X),0),F=J-(z-q);return p($,F,Q)},M7=($="",J="",Z)=>{let Q=Z?.output??l.stdout,Y=Z?.withGuide??E.withGuide,q=Z?.format??L7,z=["",...U7($,X0(Q)-6,q).split(`
103
103
  `).map(q),""],F=y(J),X=Math.max(z.reduce((L,M)=>{let U=y(M);return U>L?U:L},0),F)+2,H=z.map((L)=>`${G("gray",D)} ${L}${" ".repeat(X-y(L))}${G("gray",D)}`).join(`
104
104
  `),K=Y?`${G("gray",D)}
105
- `:"",W=Y?p9:Y3;Q.write(`${K}${G("green",L0)} ${G("reset",J)} ${G("gray",$1.repeat(Math.max(X-F-1,1))+Z3)}
105
+ `:"",W=Y?a9:Y3;Q.write(`${K}${G("green",L0)} ${G("reset",J)} ${G("gray",$1.repeat(Math.max(X-F-1,1))+Z3)}
106
106
  ${H}
107
107
  ${G("gray",W+$1.repeat(X+2)+Q3)}
108
- `)},U7=($)=>new a1({validate:$.validate,mask:$.mask??l9,signal:$.signal,input:$.input,output:$.output,render(){let J=$.withGuide??E.withGuide,Z=`${J?`${G("gray",D)}
108
+ `)},j7=($)=>new a1({validate:$.validate,mask:$.mask??p9,signal:$.signal,input:$.input,output:$.output,render(){let J=$.withGuide??E.withGuide,Z=`${J?`${G("gray",D)}
109
109
  `:""}${c(this.state)} ${$.message}
110
- `,Q=this.userInputWithCursor,Y=this.masked;switch(this.state){case"error":{let q=J?`${G("yellow",D)} `:"",z=J?`${G("yellow",v)} `:"",F=Y??"";return $.clearOnError&&this.clear(),`${Z.trim()}
110
+ `,Q=this.userInputWithCursor,Y=this.masked;switch(this.state){case"error":{let q=J?`${G("yellow",D)} `:"",z=J?`${G("yellow",f)} `:"",F=Y??"";return $.clearOnError&&this.clear(),`${Z.trim()}
111
111
  ${q}${F}
112
112
  ${z}${G("yellow",this.error)}
113
113
  `}case"submit":{let q=J?`${G("gray",D)} `:"",z=Y?G("dim",Y):"";return`${Z}${q}${z}`}case"cancel":{let q=J?`${G("gray",D)} `:"",z=Y?G(["strikethrough","dim"],Y):"";return`${Z}${q}${z}${Y&&J?`
114
- ${G("gray",D)}`:""}`}default:{let q=J?`${G("cyan",D)} `:"",z=J?G("cyan",v):"";return`${Z}${q}${Q}
114
+ ${G("gray",D)}`:""}`}default:{let q=J?`${G("cyan",D)} `:"",z=J?G("cyan",f):"";return`${Z}${q}${Q}
115
115
  ${z}
116
- `}}}}).prompt(),M7=($)=>{let J=$.validate;return n9({...$,initialUserInput:$.initialValue??$.root??process.cwd(),maxItems:5,validate(Z){if(!Array.isArray(Z)){if(!Z)return"Please select a path";if(J)return f0(J,Z)}},options(){let Z=this.userInput;if(Z==="")return[];try{let Q;d$(Z)?A9(Z).isDirectory()&&(!$.directory||Z.endsWith("/"))?Q=Z:Q=_9(Z):Q=_9(Z);let Y=Z.length>1&&Z.endsWith("/")?Z.slice(0,-1):Z;return l$(Q).map((q)=>{let z=p$(Q,q),F=A9(z);return{name:q,path:z,isDirectory:F.isDirectory()}}).filter(({path:q,isDirectory:z})=>q.startsWith(Y)&&(z||!$.directory)).map((q)=>({value:q.path}))}catch{return[]}}})},j7=($)=>G("magenta",$),H3=({indicator:$="dots",onCancel:J,output:Z=process.stdout,cancelMessage:Q,errorMessage:Y,frames:q=t0?["◒","◐","◓","◑"]:["•","o","O","0"],delay:z=t0?80:120,signal:F,...X}={})=>{let H=t1(),K,W,L=!1,M=!1,U="",N,j=performance.now(),I=X0(Z),V=X?.styleFrame??j7,P=(f)=>{let d=f>1?Y??E.messages.error:Q??E.messages.cancel;M=f===1,L&&(e(d,f),M&&typeof J=="function"&&J())},B=()=>P(2),k=()=>P(1),O=()=>{process.on("uncaughtExceptionMonitor",B),process.on("unhandledRejection",B),process.on("SIGINT",k),process.on("SIGTERM",k),process.on("exit",P),F&&F.addEventListener("abort",k)},w=()=>{process.removeListener("uncaughtExceptionMonitor",B),process.removeListener("unhandledRejection",B),process.removeListener("SIGINT",k),process.removeListener("SIGTERM",k),process.removeListener("exit",P),F&&F.removeEventListener("abort",k)},C=()=>{if(N===void 0)return;H&&Z.write(`
117
- `);let f=p(N,I,{hard:!0,trim:!1}).split(`
118
- `);f.length>1&&Z.write(k0.cursor.up(f.length-1)),Z.write(k0.cursor.to(0)),Z.write(k0.erase.down())},A=(f)=>f.replace(/\.+$/,""),h=(f)=>{let d=(performance.now()-f)/1000,i=Math.floor(d/60),n=Math.floor(d%60);return i>0?`[${i}m ${n}s]`:`[${n}s]`},T=X.withGuide??E.withGuide,D0=(f="")=>{L=!0,K=f9({output:Z}),U=A(f),j=performance.now(),T&&Z.write(`${G("gray",D)}
119
- `);let d=0,i=0;O(),W=setInterval(()=>{if(H&&U===N)return;C(),N=U;let n=V(q[d]),T0;if(H)T0=`${n} ${U}...`;else if($==="timer")T0=`${n} ${U} ${h(j)}`;else{let j2=".".repeat(Math.floor(i)).slice(0,3);T0=`${n} ${U}${j2}`}let M2=p(T0,I,{hard:!0,trim:!1});Z.write(M2),d=d+1<q.length?d+1:0,i=i<4?i+0.125:0},z)},e=(f="",d=0,i=!1)=>{if(!L)return;L=!1,clearInterval(W),C();let n=d===0?G("green",L0):d===1?G("red",e1):G("red",$3);U=f??U,i||($==="timer"?Z.write(`${n} ${U} ${h(j)}
116
+ `}}}}).prompt(),D7=($)=>{let J=$.validate;return r9({...$,initialUserInput:$.initialValue??$.root??process.cwd(),maxItems:5,validate(Z){if(!Array.isArray(Z)){if(!Z)return"Please select a path";if(J)return v0(J,Z)}},options(){let Z=this.userInput;if(Z==="")return[];try{let Q;p$(Z)?_9(Z).isDirectory()&&(!$.directory||Z.endsWith("/"))?Q=Z:Q=T9(Z):Q=T9(Z);let Y=Z.length>1&&Z.endsWith("/")?Z.slice(0,-1):Z;return a$(Q).map((q)=>{let z=i$(Q,q),F=_9(z);return{name:q,path:z,isDirectory:F.isDirectory()}}).filter(({path:q,isDirectory:z})=>q.startsWith(Y)&&(z||!$.directory)).map((q)=>({value:q.path}))}catch{return[]}}})},I7=($)=>G("magenta",$),H3=({indicator:$="dots",onCancel:J,output:Z=process.stdout,cancelMessage:Q,errorMessage:Y,frames:q=t0?["◒","◐","◓","◑"]:["•","o","O","0"],delay:z=t0?80:120,signal:F,...X}={})=>{let H=t1(),K,W,L=!1,M=!1,U="",N,j=performance.now(),I=X0(Z),V=X?.styleFrame??I7,P=(v)=>{let d=v>1?Y??E.messages.error:Q??E.messages.cancel;M=v===1,L&&(e(d,v),M&&typeof J=="function"&&J())},B=()=>P(2),k=()=>P(1),O=()=>{process.on("uncaughtExceptionMonitor",B),process.on("unhandledRejection",B),process.on("SIGINT",k),process.on("SIGTERM",k),process.on("exit",P),F&&F.addEventListener("abort",k)},w=()=>{process.removeListener("uncaughtExceptionMonitor",B),process.removeListener("unhandledRejection",B),process.removeListener("SIGINT",k),process.removeListener("SIGTERM",k),process.removeListener("exit",P),F&&F.removeEventListener("abort",k)},C=()=>{if(N===void 0)return;H&&Z.write(`
117
+ `);let v=p(N,I,{hard:!0,trim:!1}).split(`
118
+ `);v.length>1&&Z.write(k0.cursor.up(v.length-1)),Z.write(k0.cursor.to(0)),Z.write(k0.erase.down())},A=(v)=>v.replace(/\.+$/,""),h=(v)=>{let d=(performance.now()-v)/1000,i=Math.floor(d/60),n=Math.floor(d%60);return i>0?`[${i}m ${n}s]`:`[${n}s]`},T=X.withGuide??E.withGuide,D0=(v="")=>{L=!0,K=f9({output:Z}),U=A(v),j=performance.now(),T&&Z.write(`${G("gray",D)}
119
+ `);let d=0,i=0;O(),W=setInterval(()=>{if(H&&U===N)return;C(),N=U;let n=V(q[d]),T0;if(H)T0=`${n} ${U}...`;else if($==="timer")T0=`${n} ${U} ${h(j)}`;else{let D2=".".repeat(Math.floor(i)).slice(0,3);T0=`${n} ${U}${D2}`}let j2=p(T0,I,{hard:!0,trim:!1});Z.write(j2),d=d+1<q.length?d+1:0,i=i<4?i+0.125:0},z)},e=(v="",d=0,i=!1)=>{if(!L)return;L=!1,clearInterval(W),C();let n=d===0?G("green",L0):d===1?G("red",e1):G("red",$3);U=v??U,i||($==="timer"?Z.write(`${n} ${U} ${h(j)}
120
120
  `):Z.write(`${n} ${U}
121
- `)),w(),K()};return{start:D0,stop:(f="")=>e(f,0),message:(f="")=>{U=A(f??U)},cancel:(f="")=>e(f,1),error:(f="")=>e(f,2),clear:()=>e("",0,!0),get isCancelled(){return M}}},h9,s0=($,J)=>$.includes(`
121
+ `)),w(),K()};return{start:D0,stop:(v="")=>e(v,0),message:(v="")=>{U=A(v??U)},cancel:(v="")=>e(v,1),error:(v="")=>e(v,2),clear:()=>e("",0,!0),get isCancelled(){return M}}},u9,s0=($,J)=>$.includes(`
122
122
  `)?$.split(`
123
123
  `).map((Z)=>J(Z)).join(`
124
- `):J($),I7=($)=>{let J=(Z,Q)=>{let Y=Z.label??String(Z.value);switch(Q){case"disabled":return`${G("gray",W0)} ${s0(Y,(q)=>G("gray",q))}${Z.hint?` ${G("dim",`(${Z.hint??"disabled"})`)}`:""}`;case"selected":return`${s0(Y,(q)=>G("dim",q))}`;case"active":return`${G("green",O0)} ${Y}${Z.hint?` ${G("dim",`(${Z.hint})`)}`:""}`;case"cancelled":return`${s0(Y,(q)=>G(["strikethrough","dim"],q))}`;default:return`${G("dim",W0)} ${s0(Y,(q)=>G("dim",q))}`}};return new i1({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let Z=$.withGuide??E.withGuide,Q=`${c(this.state)} `,Y=`${X3(this.state)} `,q=_($.output,$.message,Y,Q),z=`${Z?`${G("gray",D)}
124
+ `):J($),V7=($)=>{let J=(Z,Q)=>{let Y=Z.label??String(Z.value);switch(Q){case"disabled":return`${G("gray",W0)} ${s0(Y,(q)=>G("gray",q))}${Z.hint?` ${G("dim",`(${Z.hint??"disabled"})`)}`:""}`;case"selected":return`${s0(Y,(q)=>G("dim",q))}`;case"active":return`${G("green",O0)} ${Y}${Z.hint?` ${G("dim",`(${Z.hint})`)}`:""}`;case"cancelled":return`${s0(Y,(q)=>G(["strikethrough","dim"],q))}`;default:return`${G("dim",W0)} ${s0(Y,(q)=>G("dim",q))}`}};return new i1({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,render(){let Z=$.withGuide??E.withGuide,Q=`${c(this.state)} `,Y=`${X3(this.state)} `,q=_($.output,$.message,Y,Q),z=`${Z?`${G("gray",D)}
125
125
  `:""}${q}
126
126
  `;switch(this.state){case"submit":{let F=Z?`${G("gray",D)} `:"",X=_($.output,J(this.options[this.cursor],"selected"),F);return`${z}${X}`}case"cancel":{let F=Z?`${G("gray",D)} `:"",X=_($.output,J(this.options[this.cursor],"cancelled"),F);return`${z}${X}${Z?`
127
- ${G("gray",D)}`:""}`}default:{let F=Z?`${G("cyan",D)} `:"",X=Z?G("cyan",v):"",H=z.split(`
127
+ ${G("gray",D)}`:""}`}default:{let F=Z?`${G("cyan",D)} `:"",X=Z?G("cyan",f):"",H=z.split(`
128
128
  `).length,K=Z?2:1;return`${z}${F}${J0({output:$.output,cursor:this.cursor,options:this.options,maxItems:$.maxItems,columnPadding:F.length,rowPadding:H+K,style:(W,L)=>J(W,W.disabled?"disabled":L?"active":"inactive")}).join(`
129
129
  ${F}`)}
130
130
  ${X}
131
- `}}}}).prompt()},N7=($)=>{let J=(Z,Q="inactive")=>{let Y=Z.label??String(Z.value);return Q==="selected"?`${G("dim",Y)}`:Q==="cancelled"?`${G(["strikethrough","dim"],Y)}`:Q==="active"?`${G(["bgCyan","gray"],` ${Z.value} `)} ${Y}${Z.hint?` ${G("dim",`(${Z.hint})`)}`:""}`:`${G(["gray","bgWhite","inverse"],` ${Z.value} `)} ${Y}${Z.hint?` ${G("dim",`(${Z.hint})`)}`:""}`};return new n1({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,caseSensitive:$.caseSensitive,render(){let Z=$.withGuide??E.withGuide,Q=`${Z?`${G("gray",D)}
131
+ `}}}}).prompt()},E7=($)=>{let J=(Z,Q="inactive")=>{let Y=Z.label??String(Z.value);return Q==="selected"?`${G("dim",Y)}`:Q==="cancelled"?`${G(["strikethrough","dim"],Y)}`:Q==="active"?`${G(["bgCyan","gray"],` ${Z.value} `)} ${Y}${Z.hint?` ${G("dim",`(${Z.hint})`)}`:""}`:`${G(["gray","bgWhite","inverse"],` ${Z.value} `)} ${Y}${Z.hint?` ${G("dim",`(${Z.hint})`)}`:""}`};return new n1({options:$.options,signal:$.signal,input:$.input,output:$.output,initialValue:$.initialValue,caseSensitive:$.caseSensitive,render(){let Z=$.withGuide??E.withGuide,Q=`${Z?`${G("gray",D)}
132
132
  `:""}${c(this.state)} ${$.message}
133
133
  `;switch(this.state){case"submit":{let Y=Z?`${G("gray",D)} `:"",q=this.options.find((F)=>F.value===this.value)??$.options[0],z=_($.output,J(q,"selected"),Y);return`${Q}${z}`}case"cancel":{let Y=Z?`${G("gray",D)} `:"",q=_($.output,J(this.options[0],"cancelled"),Y);return`${Q}${q}${Z?`
134
- ${G("gray",D)}`:""}`}default:{let Y=Z?`${G("cyan",D)} `:"",q=Z?G("cyan",v):"",z=this.options.map((F,X)=>_($.output,J(F,X===this.cursor?"active":"inactive"),Y)).join(`
134
+ ${G("gray",D)}`:""}`}default:{let Y=Z?`${G("cyan",D)} `:"",q=Z?G("cyan",f):"",z=this.options.map((F,X)=>_($.output,J(F,X===this.cursor?"active":"inactive"),Y)).join(`
135
135
  `);return`${Q}${z}
136
136
  ${q}
137
- `}}}}).prompt()},u9,H0,V7=async($,J)=>{for(let Z of $){if(Z.enabled===!1)continue;let Q=H3(J);Q.start(Z.title);let Y=await Z.task(Q.message);Q.stop(Y||Z.title)}},E7=($)=>$.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),k7=($)=>{let J=$.output??process.stdout,Z=X0(J),Q=G("gray",D),Y=$.spacing??1,z=$.retainLog===!0,F=!t1()&&g9(J);J.write(`${Q}
137
+ `}}}}).prompt()},g9,H0,k7=async($,J)=>{for(let Z of $){if(Z.enabled===!1)continue;let Q=H3(J);Q.start(Z.title);let Y=await Z.task(Q.message);Q.stop(Y||Z.title)}},P7=($)=>$.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g,""),B7=($)=>{let J=$.output??process.stdout,Z=X0(J),Q=G("gray",D),Y=$.spacing??1,z=$.retainLog===!0,F=!t1()&&m9(J);J.write(`${Q}
138
138
  `),J.write(`${G("green",L0)} ${$.title}
139
139
  `);for(let j=0;j<Y;j++)J.write(`${Q}
140
140
  `);let X=[{value:"",full:""}],H=!1,K=(j)=>{if(X.length===0)return;let I=0;j&&(I+=Y+2);for(let V of X){let{value:P,result:B}=V,k=B?.message??P;if(k.length===0)continue;B===void 0&&V.header!==void 0&&V.header!==""&&(k+=`
@@ -143,41 +143,41 @@ ${V.header}`);let O=k.split(`
143
143
  ${j.value}`:j.value;j.header!==void 0&&j.header!==""&&m.message(j.header.split(`
144
144
  `).map((B)=>G("bold",B)),{output:J,secondarySymbol:Q,symbol:Q,spacing:0}),m.message(P.split(`
145
145
  `).map((B)=>G("dim",B)),{output:J,secondarySymbol:Q,symbol:Q,spacing:I??Y})},L=()=>{for(let j of X){let{header:I,value:V,full:P}=j;(I===void 0||I.length===0)&&V.length===0||W(j,void 0,z===!0&&P.length>0)}},M=(j,I,V)=>{if(K(!1),(V?.raw!==!0||!H)&&j.value!==""&&(j.value+=`
146
- `),j.value+=E7(I),H=V?.raw===!0,$.limit!==void 0){let P=j.value.split(`
146
+ `),j.value+=P7(I),H=V?.raw===!0,$.limit!==void 0){let P=j.value.split(`
147
147
  `),B=P.length-$.limit;if(B>0){let k=P.splice(0,B);z&&(j.full+=(j.full===""?"":`
148
148
  `)+k.join(`
149
149
  `))}j.value=P.join(`
150
- `)}F&&U()},U=()=>{for(let j of X)j.result?j.result.status==="error"?m.error(j.result.message,{output:J,secondarySymbol:Q,spacing:0}):m.success(j.result.message,{output:J,secondarySymbol:Q,spacing:0}):j.value!==""&&W(j,0)},N=(j,I)=>{K(!1),j.result=I,F&&U()};return{message(j,I){M(X[0],j,I)},group(j){let I={header:j,value:"",full:""};return X.push(I),{message(V,P){M(I,V,P)},error(V){N(I,{status:"error",message:V})},success(V){N(I,{status:"success",message:V})}}},error(j,I){K(!0),m.error(j,{output:J,secondarySymbol:Q,spacing:1}),I?.showLog!==!1&&L(),X.splice(1,X.length-1),X[0].value="",X[0].full=""},success(j,I){K(!0),m.success(j,{output:J,secondarySymbol:Q,spacing:1}),I?.showLog===!0&&L(),X.splice(1,X.length-1),X[0].value="",X[0].full=""}}},P7=($)=>new r1({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let J=$?.withGuide??E.withGuide,Z=`${`${J?`${G("gray",D)}
150
+ `)}F&&U()},U=()=>{for(let j of X)j.result?j.result.status==="error"?m.error(j.result.message,{output:J,secondarySymbol:Q,spacing:0}):m.success(j.result.message,{output:J,secondarySymbol:Q,spacing:0}):j.value!==""&&W(j,0)},N=(j,I)=>{K(!1),j.result=I,F&&U()};return{message(j,I){M(X[0],j,I)},group(j){let I={header:j,value:"",full:""};return X.push(I),{message(V,P){M(I,V,P)},error(V){N(I,{status:"error",message:V})},success(V){N(I,{status:"success",message:V})}}},error(j,I){K(!0),m.error(j,{output:J,secondarySymbol:Q,spacing:1}),I?.showLog!==!1&&L(),X.splice(1,X.length-1),X[0].value="",X[0].full=""},success(j,I){K(!0),m.success(j,{output:J,secondarySymbol:Q,spacing:1}),I?.showLog===!0&&L(),X.splice(1,X.length-1),X[0].value="",X[0].full=""}}},b7=($)=>new r1({validate:$.validate,placeholder:$.placeholder,defaultValue:$.defaultValue,initialValue:$.initialValue,output:$.output,signal:$.signal,input:$.input,render(){let J=$?.withGuide??E.withGuide,Z=`${`${J?`${G("gray",D)}
151
151
  `:""}${c(this.state)} `}${$.message}
152
- `,Q=$.placeholder?G("inverse",$.placeholder[0])+G("dim",$.placeholder.slice(1)):G(["inverse","hidden"],"_"),Y=this.userInput?this.userInputWithCursor:Q,q=this.value??"";switch(this.state){case"error":{let z=this.error?` ${G("yellow",this.error)}`:"",F=J?`${G("yellow",D)} `:"",X=J?G("yellow",v):"";return`${Z.trim()}
152
+ `,Q=$.placeholder?G("inverse",$.placeholder[0])+G("dim",$.placeholder.slice(1)):G(["inverse","hidden"],"_"),Y=this.userInput?this.userInputWithCursor:Q,q=this.value??"";switch(this.state){case"error":{let z=this.error?` ${G("yellow",this.error)}`:"",F=J?`${G("yellow",D)} `:"",X=J?G("yellow",f):"";return`${Z.trim()}
153
153
  ${F}${Y}
154
154
  ${X}${z}
155
155
  `}case"submit":{let z=q?` ${G("dim",q)}`:"",F=J?G("gray",D):"";return`${Z}${F}${z}`}case"cancel":{let z=q?` ${G(["strikethrough","dim"],q)}`:"",F=J?G("gray",D):"";return`${Z}${F}${z}${q.trim()?`
156
- ${F}`:""}`}default:{let z=J?`${G("cyan",D)} `:"",F=J?G("cyan",v):"";return`${Z}${z}${Y}
156
+ ${F}`:""}`}default:{let z=J?`${G("cyan",D)} `:"",F=J?G("cyan",f):"";return`${Z}${z}${Y}
157
157
  ${F}
158
- `}}}}).prompt();var M0=S(()=>{o1();o1();A1();f1();k0=b3(T1(),1);t0=a$(),m9=R("◆","*"),e1=R("■","x"),$3=R("▲","x"),L0=R("◇","o"),J3=R("┌","T"),D=R("│","|"),v=R("└","—"),c9=R("┐","T"),d9=R("┘","—"),O0=R("●",">"),W0=R("○"," "),e0=R("◻","[•]"),K0=R("◼","[+]"),P0=R("◻","[ ]"),l9=R("▪","•"),$1=R("─","-"),Z3=R("╮","+"),p9=R("├","+"),Q3=R("╯","+"),Y3=R("╰","+"),a9=R("╭","+"),q3=R("●","•"),z3=R("◆","*"),G3=R("▲","!"),F3=R("■","x");r$=[a9,Z3,Y3,Q3],o$=[J3,c9,v,d9];Q7={year:"yyyy",month:"mm",day:"dd"},m={message:($=[],{symbol:J=G("gray",D),secondarySymbol:Z=G("gray",D),output:Q=process.stdout,spacing:Y=1,withGuide:q}={})=>{let z=[],F=q??E.withGuide,X=F?Z:"",H=F?`${J} `:"",K=F?`${Z} `:"";for(let L=0;L<Y;L++)z.push(X);let W=Array.isArray($)?$:$.split(`
158
+ `}}}}).prompt();var M0=S(()=>{o1();o1();A1();v1();k0=b3(T1(),1);t0=n$(),c9=R("◆","*"),e1=R("■","x"),$3=R("▲","x"),L0=R("◇","o"),J3=R("┌","T"),D=R("│","|"),f=R("└","—"),d9=R("┐","T"),l9=R("┘","—"),O0=R("●",">"),W0=R("○"," "),e0=R("◻","[•]"),K0=R("◼","[+]"),P0=R("◻","[ ]"),p9=R("▪","•"),$1=R("─","-"),Z3=R("╮","+"),a9=R("├","+"),Q3=R("╯","+"),Y3=R("╰","+"),i9=R("╭","+"),q3=R("●","•"),z3=R("◆","*"),G3=R("▲","!"),F3=R("■","x");s$=[i9,Z3,Y3,Q3],t$=[J3,d9,f,l9];q7={year:"yyyy",month:"mm",day:"dd"},m={message:($=[],{symbol:J=G("gray",D),secondarySymbol:Z=G("gray",D),output:Q=process.stdout,spacing:Y=1,withGuide:q}={})=>{let z=[],F=q??E.withGuide,X=F?Z:"",H=F?`${J} `:"",K=F?`${Z} `:"";for(let L=0;L<Y;L++)z.push(X);let W=Array.isArray($)?$:$.split(`
159
159
  `);if(W.length>0){let[L,...M]=W;L.length>0?z.push(`${H}${L}`):z.push(F?J:"");for(let U of M)U.length>0?z.push(`${K}${U}`):z.push(F?Z:"")}Q.write(`${z.join(`
160
160
  `)}
161
- `)},info:($,J)=>{m.message($,{...J,symbol:G("blue",q3)})},success:($,J)=>{m.message($,{...J,symbol:G("green",z3)})},step:($,J)=>{m.message($,{...J,symbol:G("green",L0)})},warn:($,J)=>{m.message($,{...J,symbol:G("yellow",G3)})},warning:($,J)=>{m.warn($,J)},error:($,J)=>{m.message($,{...J,symbol:G("red",F3)})}},h9={light:R("─","-"),heavy:R("━","="),block:R("█","#")};u9=`${G("gray",D)} `,H0={message:async($,{symbol:J=G("gray",D)}={})=>{process.stdout.write(`${G("gray",D)}
161
+ `)},info:($,J)=>{m.message($,{...J,symbol:G("blue",q3)})},success:($,J)=>{m.message($,{...J,symbol:G("green",z3)})},step:($,J)=>{m.message($,{...J,symbol:G("green",L0)})},warn:($,J)=>{m.message($,{...J,symbol:G("yellow",G3)})},warning:($,J)=>{m.warn($,J)},error:($,J)=>{m.message($,{...J,symbol:G("red",F3)})}},u9={light:R("─","-"),heavy:R("━","="),block:R("█","#")};g9=`${G("gray",D)} `,H0={message:async($,{symbol:J=G("gray",D)}={})=>{process.stdout.write(`${G("gray",D)}
162
162
  ${J} `);let Z=3;for await(let Q of $){Q=Q.replace(/\n/g,`
163
- ${u9}`),Q.includes(`
163
+ ${g9}`),Q.includes(`
164
164
  `)&&(Z=3+s1(Q.slice(Q.lastIndexOf(`
165
165
  `))).length);let Y=s1(Q).length;Z+Y<process.stdout.columns?(Z+=Y,process.stdout.write(Q)):(process.stdout.write(`
166
- ${u9}${Q.trimStart()}`),Z=3+s1(Q.trimStart()).length)}process.stdout.write(`
167
- `)},info:($)=>H0.message($,{symbol:G("blue",q3)}),success:($)=>H0.message($,{symbol:G("green",z3)}),step:($)=>H0.message($,{symbol:G("green",L0)}),warn:($)=>H0.message($,{symbol:G("yellow",G3)}),warning:($)=>H0.warn($),error:($)=>H0.message($,{symbol:G("red",F3)})}});var e9={};y0(e9,{saveCredentials:()=>W3,logout:()=>t9,login:()=>s9,loadCredentials:()=>Z0,isAuthenticated:()=>b7,getValidAccessToken:()=>j0,deleteCredentials:()=>L3,cmdLogout:()=>M3,cmdLogin:()=>U3,NotLoggedInError:()=>B0});import K3 from"crypto";import r9 from"http";import J1 from"fs";import o9 from"path";import B7 from"os";function Z1(){return o9.join(B7.homedir(),".productdock","credentials.json")}function W3($){let J=o9.dirname(Z1());J1.mkdirSync(J,{recursive:!0}),J1.writeFileSync(Z1(),JSON.stringify($,null,2),{mode:384})}function Z0(){try{let $=J1.readFileSync(Z1(),"utf8");return JSON.parse($)}catch{return null}}function L3(){try{J1.unlinkSync(Z1())}catch{}}function b7(){return Z0()!==null}function R7(){return K3.randomBytes(32).toString("base64url")}function S7($){return K3.createHash("sha256").update($).digest("base64url")}function w7($){let J=$.split(".");if(J.length!==3)return{};try{let Z=J[1].replace(/-/g,"+").replace(/_/g,"/"),Q=Buffer.from(Z,"base64").toString("utf8");return JSON.parse(Q)}catch{return{}}}function f7($){let J=w7($),Z=J.sub;if(typeof Z!=="string")return null;return{id:Z,email:typeof J.email==="string"?J.email:void 0,user_metadata:J.user_metadata!=null&&typeof J.user_metadata==="object"?J.user_metadata:void 0}}function v7(){return new Promise(($,J)=>{let Z=r9.createServer();Z.listen(0,"127.0.0.1",()=>{let Q=Z.address(),Y=typeof Q==="object"&&Q?Q.port:0;Z.close(()=>$(Y))}),Z.on("error",J)})}function O7($,J){return new Promise((Z,Q)=>{let Y=setTimeout(()=>{q.close(),Q(Error("Autenticação expirou após 5 minutos. Tente novamente."))},300000),q=r9.createServer((z,F)=>{let X=new URL(z.url??"/",`http://127.0.0.1:${$}`),H=X.searchParams.get("code"),K=X.searchParams.get("state"),W=X.searchParams.get("error"),L=(M,U)=>`<!DOCTYPE html><html><head><meta charset="utf-8"><title>${M}</title><style>body{font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0}.box{text-align:center;max-width:400px}</style></head><body><div class="box">${U}</div></body></html>`;if(W){F.writeHead(400,{"Content-Type":"text/html"}),F.end(L("Autenticação falhou",`<h2>Autenticação falhou</h2><p>${W}</p><p>Você pode fechar esta aba.</p>`)),clearTimeout(Y),q.close(()=>Q(Error(`OAuth error: ${W}`)));return}if(!H||K!==J){F.writeHead(400,{"Content-Type":"text/html"}),F.end(L("Requisição inválida","<h2>Requisição inválida</h2><p>Você pode fechar esta aba.</p>")),clearTimeout(Y),q.close(()=>Q(Error("Parâmetro de estado inválido — possível ataque CSRF. Abortando.")));return}F.writeHead(200,{"Content-Type":"text/html"}),F.end(L("Autenticado — ProductDock","<h2>Você está autenticado!</h2><p>Você pode fechar esta aba e voltar ao terminal.</p>")),clearTimeout(Y),q.close(()=>Z(H))});q.listen($,"127.0.0.1"),q.on("error",(z)=>{clearTimeout(Y),Q(z)})})}async function s9(){let $=Z0();if($){let M=$.saved_at+($.expires_in-60)*1000;if(Date.now()<M){let U=$.user?.email??"unknown";throw Error(`Já autenticado como ${U}. Execute 'productdock logout' primeiro.`)}}let J=R7(),Z=S7(J),Q=K3.randomUUID(),Y=await v7(),q=`http://127.0.0.1:${Y}/`,z=new URL(`${x}/oauth/authorize`);z.searchParams.set("response_type","code"),z.searchParams.set("client_id",w0),z.searchParams.set("redirect_uri",q),z.searchParams.set("code_challenge",Z),z.searchParams.set("code_challenge_method","S256"),z.searchParams.set("state",Q);let F=O7(Y,Q);try{await $9(z.toString())}catch{console.error(`Não foi possível abrir o navegador automaticamente. Abra esta URL manualmente:
168
- ${z}`)}let X=await F,H=await fetch(`${x}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:w0,code:X,code_verifier:J,redirect_uri:q})});if(!H.ok)throw Error(`Falha na troca de token: ${await H.text()}`);let K=await H.json(),W=f7(K.access_token),L={...K,user:W,saved_at:Date.now()};return W3(L),{tokens:L,user:W}}async function j0(){let $=Z0();if(!$)throw new B0;let J=$.saved_at+($.expires_in-60)*1000;if(Date.now()<J)return $.access_token;let Z=await fetch(`${x}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",client_id:w0,refresh_token:$.refresh_token})});if(!Z.ok)throw L3(),new B0("Sessão expirada. Execute: productdock login");let Q=await Z.json(),Y={...$,...Q,saved_at:Date.now()};return W3(Y),Y.access_token}async function t9(){let $=Z0();if(!$)return;await fetch(`${x}/oauth/revoke`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({token:$.refresh_token,token_type_hint:"refresh_token",client_id:w0})}).catch(()=>{}),L3()}async function U3(){let{intro:$,outro:J,spinner:Z}=await Promise.resolve().then(() => (M0(),U0));$("ProductDock — Login");let Q=Z();Q.start("Abrindo navegador para autenticação...");try{let{user:Y}=await s9();Q.stop("Autenticação concluída.");let q=Y?.user_metadata?.full_name??Y?.user_metadata?.name??"",z=Y?.email??"unknown";J(`Autenticado como ${z}${q?` (${q})`:""}`)}catch(Y){Q.stop("Autenticação falhou.");let q=Y instanceof Error?Y.message:String(Y);console.error(`
169
- Erro: ${q}`),process.exit(1)}}async function M3(){let{outro:$}=await Promise.resolve().then(() => (M0(),U0));if(!Z0()){console.log("Não autenticado.");return}await t9(),$("Desconectado.")}var B0;var C0=S(()=>{J9();F0();B0=class B0 extends Error{constructor($="Não autenticado. Execute: productdock login"){super($);this.name="NotLoggedInError"}}});function $2(){return x.replace(/\/mcp$/,"")}async function j3(){let $=await j0(),J=await fetch(`${$2()}/cli/projects`,{headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"}});if(!J.ok)throw Error(`Failed to fetch projects: ${await J.text()}`);return J.json()}async function J2($){let J=await j0(),Z=await fetch(`${$2()}/cli/projects/${encodeURIComponent($)}/repositories`,{headers:{Authorization:`Bearer ${J}`,"Content-Type":"application/json"}});if(!Z.ok)throw Error(`Failed to fetch repositories: ${await Z.text()}`);return Z.json()}var Z2=S(()=>{C0();F0()});import{execSync as C7}from"child_process";function Q2($){try{return C7("git remote get-url origin",{cwd:$,encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function Y2($){let J=$.match(/^git@ssh\.dev\.azure\.com:v3\/([^/]+)\/([^/]+)\/([^/]+?)(?:\.git)?$/);if(J)return{organization:J[1],projectName:J[2],repositoryName:J[3]};let Z=$.match(/^https?:\/\/(?:[^@]+@)?dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+?)(?:\.git)?(?:\/.*)?$/);if(Z)return{organization:Z[1],projectName:Z[2],repositoryName:Z[3]};let Q=$.match(/^https?:\/\/([^.]+)\.visualstudio\.com\/([^/]+)\/_git\/([^/]+?)(?:\.git)?(?:\/.*)?$/);if(Q)return{organization:Q[1],projectName:Q[2],repositoryName:Q[3]};return null}var q2=()=>{};var V3={};y0(V3,{writeConfig:()=>G2,resolveRepository:()=>F2,readConfig:()=>Q1,cmdLink:()=>N3,CONFIG_FILENAME:()=>I3});import D3 from"fs";import z2 from"path";function Q1($=process.cwd()){let J=z2.join($,I3);if(!D3.existsSync(J))return null;try{return JSON.parse(D3.readFileSync(J,"utf8"))}catch{return null}}function G2($,J=process.cwd()){let Z=z2.join(J,I3);D3.writeFileSync(Z,JSON.stringify($,null,2)+`
170
- `,"utf8")}async function F2($,J){let{spinner:Z,select:Q,log:Y,isCancel:q}=await Promise.resolve().then(() => (M0(),U0)),z=Z();z.start("Buscando repositórios...");let F=await J2($).catch(()=>{return z.stop("Não foi possível buscar repositórios — pulando seleção de repositório."),[]});if(F.length===0){z.stop("Nenhum repositório encontrado para este projeto.");return}if(F.length===1)return z.stop(`Repositório selecionado automaticamente: ${F[0].repository_name}`),F[0];z.stop(`${F.length} repositório(s) encontrado(s).`);let X=Q2(J),H=X?Y2(X):null,K=H?F.filter((L)=>L.repository_name.toLowerCase()===H.repositoryName.toLowerCase()):[];if(K.length===1)return Y.info(`Repositório selecionado automaticamente: ${K[0].repository_name} (detectado via git remote)`),K[0];let W=await Q({message:"Selecione um repositório:",options:F.map((L)=>({value:L.id,label:L.repository_name,hint:`${L.organization}/${L.project_name}`}))});if(q(W))console.log("Cancelado."),process.exit(0);return F.find((L)=>L.id===W)}async function N3($){let{intro:J,outro:Z,spinner:Q,select:Y,multiselect:q,isCancel:z}=await Promise.resolve().then(() => (M0(),U0));J("ProductDock — Vincular projeto");let F;if($.projectId){let M=Q();M.start("Buscando projetos...");let U=await j3().catch((j)=>{M.stop("Falhou."),console.error(`
166
+ ${g9}${Q.trimStart()}`),Z=3+s1(Q.trimStart()).length)}process.stdout.write(`
167
+ `)},info:($)=>H0.message($,{symbol:G("blue",q3)}),success:($)=>H0.message($,{symbol:G("green",z3)}),step:($)=>H0.message($,{symbol:G("green",L0)}),warn:($)=>H0.message($,{symbol:G("yellow",G3)}),warning:($)=>H0.warn($),error:($)=>H0.message($,{symbol:G("red",F3)})}});var $2={};y0($2,{saveCredentials:()=>W3,logout:()=>e9,login:()=>t9,loadCredentials:()=>Z0,isAuthenticated:()=>S7,getValidAccessToken:()=>j0,deleteCredentials:()=>L3,cmdLogout:()=>M3,cmdLogin:()=>U3,NotLoggedInError:()=>B0});import K3 from"crypto";import o9 from"http";import J1 from"fs";import s9 from"path";import R7 from"os";function Z1(){return s9.join(R7.homedir(),".productdock","credentials.json")}function W3($){let J=s9.dirname(Z1());J1.mkdirSync(J,{recursive:!0}),J1.writeFileSync(Z1(),JSON.stringify($,null,2),{mode:384})}function Z0(){try{let $=J1.readFileSync(Z1(),"utf8");return JSON.parse($)}catch{return null}}function L3(){try{J1.unlinkSync(Z1())}catch{}}function S7(){return Z0()!==null}function w7(){return K3.randomBytes(32).toString("base64url")}function v7($){return K3.createHash("sha256").update($).digest("base64url")}function f7($){let J=$.split(".");if(J.length!==3)return{};try{let Z=J[1].replace(/-/g,"+").replace(/_/g,"/"),Q=Buffer.from(Z,"base64").toString("utf8");return JSON.parse(Q)}catch{return{}}}function O7($){let J=f7($),Z=J.sub;if(typeof Z!=="string")return null;return{id:Z,email:typeof J.email==="string"?J.email:void 0,user_metadata:J.user_metadata!=null&&typeof J.user_metadata==="object"?J.user_metadata:void 0}}function C7(){return new Promise(($,J)=>{let Z=o9.createServer();Z.listen(0,"127.0.0.1",()=>{let Q=Z.address(),Y=typeof Q==="object"&&Q?Q.port:0;Z.close(()=>$(Y))}),Z.on("error",J)})}function A7($,J){return new Promise((Z,Q)=>{let Y=setTimeout(()=>{q.close(),Q(Error("Autenticação expirou após 5 minutos. Tente novamente."))},300000),q=o9.createServer((z,F)=>{let X=new URL(z.url??"/",`http://127.0.0.1:${$}`),H=X.searchParams.get("code"),K=X.searchParams.get("state"),W=X.searchParams.get("error"),L=(M,U)=>`<!DOCTYPE html><html><head><meta charset="utf-8"><title>${M}</title><style>body{font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0}.box{text-align:center;max-width:400px}</style></head><body><div class="box">${U}</div></body></html>`;if(W){F.writeHead(400,{"Content-Type":"text/html"}),F.end(L("Autenticação falhou",`<h2>Autenticação falhou</h2><p>${W}</p><p>Você pode fechar esta aba.</p>`)),clearTimeout(Y),q.close(()=>Q(Error(`OAuth error: ${W}`)));return}if(!H||K!==J){F.writeHead(400,{"Content-Type":"text/html"}),F.end(L("Requisição inválida","<h2>Requisição inválida</h2><p>Você pode fechar esta aba.</p>")),clearTimeout(Y),q.close(()=>Q(Error("Parâmetro de estado inválido — possível ataque CSRF. Abortando.")));return}F.writeHead(200,{"Content-Type":"text/html"}),F.end(L("Autenticado — ProductDock","<h2>Você está autenticado!</h2><p>Você pode fechar esta aba e voltar ao terminal.</p>")),clearTimeout(Y),q.close(()=>Z(H))});q.listen($,"127.0.0.1"),q.on("error",(z)=>{clearTimeout(Y),Q(z)})})}async function t9(){let $=Z0();if($){let M=$.saved_at+($.expires_in-60)*1000;if(Date.now()<M){let U=$.user?.email??"unknown";throw Error(`Já autenticado como ${U}. Execute 'productdock logout' primeiro.`)}}let J=w7(),Z=v7(J),Q=K3.randomUUID(),Y=await C7(),q=`http://127.0.0.1:${Y}/`,z=new URL(`${x}/oauth/authorize`);z.searchParams.set("response_type","code"),z.searchParams.set("client_id",w0),z.searchParams.set("redirect_uri",q),z.searchParams.set("code_challenge",Z),z.searchParams.set("code_challenge_method","S256"),z.searchParams.set("state",Q);let F=A7(Y,Q);try{await $9(z.toString())}catch{console.error(`Não foi possível abrir o navegador automaticamente. Abra esta URL manualmente:
168
+ ${z}`)}let X=await F,H=await fetch(`${x}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:w0,code:X,code_verifier:J,redirect_uri:q})});if(!H.ok)throw Error(`Falha na troca de token: ${await H.text()}`);let K=await H.json(),W=O7(K.access_token),L={...K,user:W,saved_at:Date.now()};return W3(L),{tokens:L,user:W}}async function j0(){let $=Z0();if(!$)throw new B0;let J=$.saved_at+($.expires_in-60)*1000;if(Date.now()<J)return $.access_token;let Z=await fetch(`${x}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",client_id:w0,refresh_token:$.refresh_token})});if(!Z.ok)throw L3(),new B0("Sessão expirada. Execute: productdock login");let Q=await Z.json(),Y={...$,...Q,saved_at:Date.now()};return W3(Y),Y.access_token}async function e9(){let $=Z0();if(!$)return;await fetch(`${x}/oauth/revoke`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({token:$.refresh_token,token_type_hint:"refresh_token",client_id:w0})}).catch(()=>{}),L3()}async function U3(){let{intro:$,outro:J,spinner:Z}=await Promise.resolve().then(() => (M0(),U0));$("ProductDock — Login");let Q=Z();Q.start("Abrindo navegador para autenticação...");try{let{user:Y}=await t9();Q.stop("Autenticação concluída.");let q=Y?.user_metadata?.full_name??Y?.user_metadata?.name??"",z=Y?.email??"unknown";J(`Autenticado como ${z}${q?` (${q})`:""}`)}catch(Y){Q.stop("Autenticação falhou.");let q=Y instanceof Error?Y.message:String(Y);console.error(`
169
+ Erro: ${q}`),process.exit(1)}}async function M3(){let{outro:$}=await Promise.resolve().then(() => (M0(),U0));if(!Z0()){console.log("Não autenticado.");return}await e9(),$("Desconectado.")}var B0;var C0=S(()=>{J9();F0();B0=class B0 extends Error{constructor($="Não autenticado. Execute: productdock login"){super($);this.name="NotLoggedInError"}}});function J2(){return x.replace(/\/mcp$/,"")}async function j3(){let $=await j0(),J=await fetch(`${J2()}/cli/projects`,{headers:{Authorization:`Bearer ${$}`,"Content-Type":"application/json"}});if(!J.ok)throw Error(`Failed to fetch projects: ${await J.text()}`);return J.json()}async function Z2($){let J=await j0(),Z=await fetch(`${J2()}/cli/projects/${encodeURIComponent($)}/repositories`,{headers:{Authorization:`Bearer ${J}`,"Content-Type":"application/json"}});if(!Z.ok)throw Error(`Failed to fetch repositories: ${await Z.text()}`);return Z.json()}var Q2=S(()=>{C0();F0()});import{execSync as _7}from"child_process";function Y2($){try{return _7("git remote get-url origin",{cwd:$,encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim()||null}catch{return null}}function q2($){let J=$.match(/^git@ssh\.dev\.azure\.com:v3\/([^/]+)\/([^/]+)\/([^/]+?)(?:\.git)?$/);if(J)return{organization:J[1],projectName:J[2],repositoryName:J[3]};let Z=$.match(/^https?:\/\/(?:[^@]+@)?dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+?)(?:\.git)?(?:\/.*)?$/);if(Z)return{organization:Z[1],projectName:Z[2],repositoryName:Z[3]};let Q=$.match(/^https?:\/\/([^.]+)\.visualstudio\.com\/([^/]+)\/_git\/([^/]+?)(?:\.git)?(?:\/.*)?$/);if(Q)return{organization:Q[1],projectName:Q[2],repositoryName:Q[3]};return null}var z2=()=>{};var V3={};y0(V3,{writeConfig:()=>F2,resolveRepository:()=>X2,readConfig:()=>Q1,cmdLink:()=>N3,CONFIG_FILENAME:()=>I3});import D3 from"fs";import G2 from"path";function Q1($=process.cwd()){let J=G2.join($,I3);if(!D3.existsSync(J))return null;try{return JSON.parse(D3.readFileSync(J,"utf8"))}catch{return null}}function F2($,J=process.cwd()){let Z=G2.join(J,I3);D3.writeFileSync(Z,JSON.stringify($,null,2)+`
170
+ `,"utf8")}async function X2($,J){let{spinner:Z,select:Q,log:Y,isCancel:q}=await Promise.resolve().then(() => (M0(),U0)),z=Z();z.start("Buscando repositórios...");let F=await Z2($).catch(()=>{return z.stop("Não foi possível buscar repositórios — pulando seleção de repositório."),[]});if(F.length===0){z.stop("Nenhum repositório encontrado para este projeto.");return}if(F.length===1)return z.stop(`Repositório selecionado automaticamente: ${F[0].repository_name}`),F[0];z.stop(`${F.length} repositório(s) encontrado(s).`);let X=Y2(J),H=X?q2(X):null,K=H?F.filter((L)=>L.repository_name.toLowerCase()===H.repositoryName.toLowerCase()):[];if(K.length===1)return Y.info(`Repositório selecionado automaticamente: ${K[0].repository_name} (detectado via git remote)`),K[0];let W=await Q({message:"Selecione um repositório:",options:F.map((L)=>({value:L.id,label:L.repository_name,hint:`${L.organization}/${L.project_name}`}))});if(q(W))console.log("Cancelado."),process.exit(0);return F.find((L)=>L.id===W)}async function N3($){let{intro:J,outro:Z,spinner:Q,select:Y,multiselect:q,isCancel:z}=await Promise.resolve().then(() => (M0(),U0));J("ProductDock — Vincular projeto");let F;if($.projectId){let M=Q();M.start("Buscando projetos...");let U=await j3().catch((j)=>{M.stop("Falhou."),console.error(`
171
171
  Erro: ${j instanceof Error?j.message:String(j)}`),process.exit(1)});M.stop("Concluído.");let N=U.find((j)=>j.id===$.projectId);if(!N)console.error(`Projeto com id "${$.projectId}" não encontrado.`),process.exit(1);F=N}else{let M=Q();M.start("Buscando seus projetos...");let U=await j3().catch((j)=>{M.stop("Falhou."),console.error(`
172
- Erro: ${j instanceof Error?j.message:String(j)}`),process.exit(1)});if(M.stop(`${U.length} projeto(s) encontrado(s).`),U.length===0)console.error("Nenhum projeto encontrado. Certifique-se de ter acesso a pelo menos um projeto ProductDock."),process.exit(1);let N=await Y({message:"Selecione um projeto:",options:U.map((j)=>({value:j.id,label:j.name,hint:`slug: ${j.slug}`}))});if(z(N))console.log("Cancelado."),process.exit(0);F=U.find((j)=>j.id===N)}let X=[{value:"claude-code",label:"Claude Code"},{value:"cursor",label:"Cursor"},{value:"vscode",label:"VS Code / GitHub Copilot"},{value:"claude-desktop",label:"Claude Desktop"}],H;if($.ide)H=$.ide.split(",").map((M)=>M.trim());else{let M=await q({message:"Quais IDEs seu time usa?",options:X,required:!0});if(z(M))console.log("Cancelado."),process.exit(0);H=M}let K=process.cwd(),W=await F2(F.id,K),L={projectId:F.id,projectName:F.name,mcpServerUrl:x,ides:H,...W&&{repositoryId:W.id,repositoryName:W.repository_name}};G2(L),Z(`Vinculado a "${F.name}"
172
+ Erro: ${j instanceof Error?j.message:String(j)}`),process.exit(1)});if(M.stop(`${U.length} projeto(s) encontrado(s).`),U.length===0)console.error("Nenhum projeto encontrado. Certifique-se de ter acesso a pelo menos um projeto ProductDock."),process.exit(1);let N=await Y({message:"Selecione um projeto:",options:U.map((j)=>({value:j.id,label:j.name,hint:`slug: ${j.slug}`}))});if(z(N))console.log("Cancelado."),process.exit(0);F=U.find((j)=>j.id===N)}let X=[{value:"claude-code",label:"Claude Code"},{value:"cursor",label:"Cursor"},{value:"vscode",label:"VS Code / GitHub Copilot"},{value:"claude-desktop",label:"Claude Desktop"}],H;if($.ide)H=$.ide.split(",").map((M)=>M.trim());else{let M=await q({message:"Quais IDEs seu time usa?",options:X,required:!0});if(z(M))console.log("Cancelado."),process.exit(0);H=M}let K=process.cwd(),W=await X2(F.id,K),L={projectId:F.id,projectName:F.name,mcpServerUrl:x,ides:H,...W&&{repositoryId:W.id,repositoryName:W.repository_name}};F2(L),Z(`Vinculado a "${F.name}"
173
173
 
174
- Próximo passo: productdock mcp setup`)}var I3="productdock.json";var A0=S(()=>{Z2();q2();F0()});var L2={};y0(L2,{writeMcpConfig:()=>K2,readMcpConfig:()=>W2,isMcpConfigCorrect:()=>Y1,detectInstalledIdes:()=>A7,cmdMcpStatus:()=>P3,cmdMcpSetup:()=>k3});import Q0 from"fs";import t from"path";import _0 from"os";function A7($){let J=[];if(Q0.existsSync(t.join($,".claude")))J.push("claude-code");if(Q0.existsSync(t.join($,".cursor")))J.push("cursor");if(Q0.existsSync(t.join($,".vscode")))J.push("vscode");return J.push("claude-desktop"),[...new Set(J)]}function _7($,J){let Z=$+".tmp";Q0.mkdirSync(t.dirname($),{recursive:!0}),Q0.writeFileSync(Z,JSON.stringify(J,null,2)+`
175
- `,"utf8"),Q0.renameSync(Z,$)}function T7($,J,Z,Q){let Y={type:"http",url:x};if(Z||Q){if(Y.headers={},Z)Y.headers["x-productdock-project-id"]=Z;if(Q)Y.headers["x-productdock-repository-id"]=Q}if($==="vscode")return{...J,servers:{...J.servers??{},productdock:Y}};return{...J,mcpServers:{...J.mcpServers??{},productdock:Y}}}function H2($){try{return JSON.parse(Q0.readFileSync($,"utf8"))}catch{return{}}}function E3($,J){let Z=X2[$];if(Z.configPath)return t.join(J,Z.configPath);return Z.globalConfigPath()}function K2($,J,Z,Q){let Y=E3($,J),q=H2(Y),z=T7($,q,Z,Q);return _7(Y,z),{ide:$,configPath:Y,proxyUrl:x}}function W2($,J){let Z=E3($,J);if(!Q0.existsSync(Z))return null;return H2(Z)}function Y1($,J){let Z=W2($,J);if(!Z)return!1;return($==="vscode"?Z.servers?.productdock:Z.mcpServers?.productdock)?.url===x}async function k3($){let{intro:J,outro:Z,log:Q}=await Promise.resolve().then(() => (M0(),U0)),{readConfig:Y,writeConfig:q,resolveRepository:z}=await Promise.resolve().then(() => (A0(),V3));J("ProductDock — Configuração do MCP");let F=Y();if(!F)console.error("productdock.json não encontrado. Execute 'productdock link' primeiro."),process.exit(1);let X=$.ide?[$.ide]:F.ides,H=process.cwd(),K=F.repositoryId;if(!K){let W=await z(F.projectId,H);if(W)K=W.id,q({...F,repositoryId:K,repositoryName:W.repository_name},H)}for(let W of X){if(!X2[W]){Q.warn(`IDE desconhecida: ${W} — ignorando.`);continue}let M=E3(W,H),U=M.startsWith(_0.homedir())?M.replace(_0.homedir(),"~"):t.relative(H,M);if($.dryRun)Q.info(`[dry-run] ${W.padEnd(16)} → ${U} (url: ${x})`);else K2(W,H,F.projectId,K),Q.success(`${W.padEnd(16)} → ${U} (url: ${x})`)}Z($.dryRun?"Dry run concluído. Nenhum arquivo foi modificado.":"Configuração concluída.")}async function P3($){let{readConfig:J}=await Promise.resolve().then(() => (A0(),V3)),{loadCredentials:Z}=await Promise.resolve().then(() => (C0(),e9)),Q=J();if(!Q){console.log("productdock.json não encontrado. Execute 'productdock link' primeiro.");return}let Y=Z(),q=Date.now(),z=[`Project: ${Q.projectName} (${Q.projectId})`,`MCP server: ${Q.mcpServerUrl}`];if(!Y)z.push("Auth: ✖ Não autenticado");else{let H=Y.saved_at+Y.expires_in*1000,K=q<H,W=Math.round((q-Y.saved_at)/60000);z.push(`Auth: ${Y.user?.email??"unknown"} ${K?`✔ válido (atualizado há ${W}m)`:"✖ expirado"}`)}let F=process.cwd(),X=Q.ides.map((H)=>{let K=Y1(H,F);return`${H} ${K?"✔":"✖"}`});z.push(`IDEs: ${X.join(" ")}`),console.log(z.join(`
176
- `))}var X2;var q1=S(()=>{F0();X2={"claude-code":{label:"Claude Code",configPath:".mcp.json"},cursor:{label:"Cursor",configPath:".cursor/mcp.json"},vscode:{label:"VS Code / Copilot",configPath:".vscode/mcp.json"},"claude-desktop":{label:"Claude Desktop",configPath:null,globalConfigPath:()=>{if(process.platform==="darwin")return t.join(_0.homedir(),"Library","Application Support","Claude","claude_desktop_config.json");else if(process.platform==="win32")return t.join(process.env.APPDATA??_0.homedir(),"Claude","claude_desktop_config.json");return t.join(_0.homedir(),".config","Claude","claude_desktop_config.json")}}}});class Y0 extends Error{constructor($,J,Z){super(Z);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=J,this.exitCode=$,this.nestedError=void 0}}class I0 extends Y0{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}class x0{constructor($,J){switch(this.description=J||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.push($),J}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(J,Z)=>{if(!this.argChoices.includes(J))throw new I0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(J,Z);return J},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function h0($){let J=$.name()+($.variadic===!0?"...":"");return $.required?"<"+J+">":"["+J+"]"}import{EventEmitter as v2}from"node:events";import X1 from"node:child_process";import r from"node:path";import g0 from"node:fs";import b from"node:process";import{stripVTControlCharacters as O2}from"node:util";import{stripVTControlCharacters as S2}from"node:util";class u0{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let J=$.commands.filter((Q)=>!Q._hidden),Z=$._getHelpCommand();if(Z&&!Z._hidden)J.push(Z);if(this.sortSubcommands)J.sort((Q,Y)=>{return Q.name().localeCompare(Y.name())});return J}compareOptions($,J){let Z=(Q)=>{return Q.short?Q.short.replace(/^-/,""):Q.long.replace(/^--/,"")};return Z($).localeCompare(Z(J))}visibleOptions($){let J=$.options.filter((Q)=>!Q.hidden),Z=$._getHelpOption();if(Z&&!Z.hidden){let Q=Z.short&&$._findOption(Z.short),Y=Z.long&&$._findOption(Z.long);if(!Q&&!Y)J.push(Z);else if(Z.long&&!Y)J.push($.createOption(Z.long,Z.description));else if(Z.short&&!Q)J.push($.createOption(Z.short,Z.description))}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let J=[];for(let Z=$.parent;Z;Z=Z.parent){let Q=Z.options.filter((Y)=>!Y.hidden);J.push(...Q)}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((J)=>{J.description=J.description||$._argsDescription[J.name()]||""});if($.registeredArguments.find((J)=>J.description))return $.registeredArguments;return[]}subcommandTerm($){let J=$.registeredArguments.map((Z)=>h0(Z)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(J?" "+J:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,J){return J.visibleCommands($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleSubcommandTerm(J.subcommandTerm(Q))))},0)}longestOptionTermLength($,J){return J.visibleOptions($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleOptionTerm(J.optionTerm(Q))))},0)}longestGlobalOptionTermLength($,J){return J.visibleGlobalOptions($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleOptionTerm(J.optionTerm(Q))))},0)}longestArgumentTermLength($,J){return J.visibleArguments($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleArgumentTerm(J.argumentTerm(Q))))},0)}commandUsage($){let J=$._name;if($._aliases[0])J=J+"|"+$._aliases[0];let Z="";for(let Q=$.parent;Q;Q=Q.parent)Z=Q.name()+" "+Z;return Z+J+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)J.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)J.push(`env: ${$.envVar}`);if(J.length>0){let Z=`(${J.join(", ")})`;if($.description)return`${$.description} ${Z}`;return Z}return $.description}argumentDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if($.defaultValue!==void 0)J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(J.length>0){let Z=`(${J.join(", ")})`;if($.description)return`${$.description} ${Z}`;return Z}return $.description}formatItemList($,J,Z){if(J.length===0)return[];return[Z.styleTitle($),...J,""]}groupItems($,J,Z){let Q=new Map;return $.forEach((Y)=>{let q=Z(Y);if(!Q.has(q))Q.set(q,[])}),J.forEach((Y)=>{let q=Z(Y);if(!Q.has(q))Q.set(q,[]);Q.get(q).push(Y)}),Q}formatHelp($,J){let Z=J.padWidth($,J),Q=J.helpWidth??80;function Y(K,W){return J.formatItem(K,Z,W,J)}let q=[`${J.styleTitle("Usage:")} ${J.styleUsage(J.commandUsage($))}`,""],z=J.commandDescription($);if(z.length>0)q=q.concat([J.boxWrap(J.styleCommandDescription(z),Q),""]);let F=J.visibleArguments($).map((K)=>{return Y(J.styleArgumentTerm(J.argumentTerm(K)),J.styleArgumentDescription(J.argumentDescription(K)))});if(q=q.concat(this.formatItemList("Arguments:",F,J)),this.groupItems($.options,J.visibleOptions($),(K)=>K.helpGroupHeading??"Options:").forEach((K,W)=>{let L=K.map((M)=>{return Y(J.styleOptionTerm(J.optionTerm(M)),J.styleOptionDescription(J.optionDescription(M)))});q=q.concat(this.formatItemList(W,L,J))}),J.showGlobalOptions){let K=J.visibleGlobalOptions($).map((W)=>{return Y(J.styleOptionTerm(J.optionTerm(W)),J.styleOptionDescription(J.optionDescription(W)))});q=q.concat(this.formatItemList("Global Options:",K,J))}return this.groupItems($.commands,J.visibleCommands($),(K)=>K.helpGroup()||"Commands:").forEach((K,W)=>{let L=K.map((M)=>{return Y(J.styleSubcommandTerm(J.subcommandTerm(M)),J.styleSubcommandDescription(J.subcommandDescription(M)))});q=q.concat(this.formatItemList(W,L,J))}),q.join(`
177
- `)}displayWidth($){return S2($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((J)=>{if(J==="[options]")return this.styleOptionText(J);if(J==="[command]")return this.styleSubcommandText(J);if(J[0]==="["||J[0]==="<")return this.styleArgumentText(J);return this.styleCommandText(J)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((J)=>{if(J==="[options]")return this.styleOptionText(J);if(J[0]==="["||J[0]==="<")return this.styleArgumentText(J);return this.styleSubcommandText(J)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,J){return Math.max(J.longestOptionTermLength($,J),J.longestGlobalOptionTermLength($,J),J.longestSubcommandTermLength($,J),J.longestArgumentTermLength($,J))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,J,Z,Q){let q=" ".repeat(2);if(!Z)return q+$;let z=$.padEnd(J+$.length-Q.displayWidth($)),F=2,H=(this.helpWidth??80)-J-F-2,K;if(H<this.minWidthToWrap||Q.preformatted(Z))K=Z;else K=Q.boxWrap(Z,H).replace(/\n/g,`
174
+ Próximo passo: productdock mcp setup`)}var I3="productdock.json";var A0=S(()=>{Q2();z2();F0()});var U2={};y0(U2,{writeMcpConfig:()=>W2,readMcpConfig:()=>L2,isMcpConfigCorrect:()=>Y1,detectInstalledIdes:()=>T7,cmdMcpStatus:()=>P3,cmdMcpSetup:()=>k3});import Q0 from"fs";import t from"path";import _0 from"os";function T7($){let J=[];if(Q0.existsSync(t.join($,".claude")))J.push("claude-code");if(Q0.existsSync(t.join($,".cursor")))J.push("cursor");if(Q0.existsSync(t.join($,".vscode")))J.push("vscode");return J.push("claude-desktop"),[...new Set(J)]}function y7($,J){let Z=$+".tmp";Q0.mkdirSync(t.dirname($),{recursive:!0}),Q0.writeFileSync(Z,JSON.stringify(J,null,2)+`
175
+ `,"utf8"),Q0.renameSync(Z,$)}function x7($,J,Z,Q){let Y={type:"http",url:x};if(Z||Q){if(Y.headers={},Z)Y.headers["x-productdock-project-id"]=Z;if(Q)Y.headers["x-productdock-repository-id"]=Q}if($==="vscode")return{...J,servers:{...J.servers??{},productdock:Y}};return{...J,mcpServers:{...J.mcpServers??{},productdock:Y}}}function K2($){try{return JSON.parse(Q0.readFileSync($,"utf8"))}catch{return{}}}function E3($,J){let Z=H2[$];if(Z.configPath)return t.join(J,Z.configPath);return Z.globalConfigPath()}function W2($,J,Z,Q){let Y=E3($,J),q=K2(Y),z=x7($,q,Z,Q);return y7(Y,z),{ide:$,configPath:Y,proxyUrl:x}}function L2($,J){let Z=E3($,J);if(!Q0.existsSync(Z))return null;return K2(Z)}function Y1($,J){let Z=L2($,J);if(!Z)return!1;return($==="vscode"?Z.servers?.productdock:Z.mcpServers?.productdock)?.url===x}async function k3($){let{intro:J,outro:Z,log:Q}=await Promise.resolve().then(() => (M0(),U0)),{readConfig:Y,writeConfig:q,resolveRepository:z}=await Promise.resolve().then(() => (A0(),V3));J("ProductDock — Configuração do MCP");let F=Y();if(!F)console.error("productdock.json não encontrado. Execute 'productdock link' primeiro."),process.exit(1);let X=$.ide?[$.ide]:F.ides,H=process.cwd(),K=F.repositoryId;if(!K){let W=await z(F.projectId,H);if(W)K=W.id,q({...F,repositoryId:K,repositoryName:W.repository_name},H)}for(let W of X){if(!H2[W]){Q.warn(`IDE desconhecida: ${W} — ignorando.`);continue}let M=E3(W,H),U=M.startsWith(_0.homedir())?M.replace(_0.homedir(),"~"):t.relative(H,M);if($.dryRun)Q.info(`[dry-run] ${W.padEnd(16)} → ${U} (url: ${x})`);else W2(W,H,F.projectId,K),Q.success(`${W.padEnd(16)} → ${U} (url: ${x})`)}Z($.dryRun?"Dry run concluído. Nenhum arquivo foi modificado.":"Configuração concluída.")}async function P3($){let{readConfig:J}=await Promise.resolve().then(() => (A0(),V3)),{loadCredentials:Z}=await Promise.resolve().then(() => (C0(),$2)),Q=J();if(!Q){console.log("productdock.json não encontrado. Execute 'productdock link' primeiro.");return}let Y=Z(),q=Date.now(),z=[`Project: ${Q.projectName} (${Q.projectId})`,`MCP server: ${Q.mcpServerUrl}`];if(!Y)z.push("Auth: ✖ Não autenticado");else{let H=Y.saved_at+Y.expires_in*1000,K=q<H,W=Math.round((q-Y.saved_at)/60000);z.push(`Auth: ${Y.user?.email??"unknown"} ${K?`✔ válido (atualizado há ${W}m)`:"✖ expirado"}`)}let F=process.cwd(),X=Q.ides.map((H)=>{let K=Y1(H,F);return`${H} ${K?"✔":"✖"}`});z.push(`IDEs: ${X.join(" ")}`),console.log(z.join(`
176
+ `))}var H2;var q1=S(()=>{F0();H2={"claude-code":{label:"Claude Code",configPath:".mcp.json"},cursor:{label:"Cursor",configPath:".cursor/mcp.json"},vscode:{label:"VS Code / Copilot",configPath:".vscode/mcp.json"},"claude-desktop":{label:"Claude Desktop",configPath:null,globalConfigPath:()=>{if(process.platform==="darwin")return t.join(_0.homedir(),"Library","Application Support","Claude","claude_desktop_config.json");else if(process.platform==="win32")return t.join(process.env.APPDATA??_0.homedir(),"Claude","claude_desktop_config.json");return t.join(_0.homedir(),".config","Claude","claude_desktop_config.json")}}}});class Y0 extends Error{constructor($,J,Z){super(Z);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=J,this.exitCode=$,this.nestedError=void 0}}class I0 extends Y0{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}class x0{constructor($,J){switch(this.description=J||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.push($),J}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(J,Z)=>{if(!this.argChoices.includes(J))throw new I0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(J,Z);return J},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function h0($){let J=$.name()+($.variadic===!0?"...":"");return $.required?"<"+J+">":"["+J+"]"}import{EventEmitter as O2}from"node:events";import X1 from"node:child_process";import r from"node:path";import g0 from"node:fs";import b from"node:process";import{stripVTControlCharacters as C2}from"node:util";import{stripVTControlCharacters as w2}from"node:util";class u0{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let J=$.commands.filter((Q)=>!Q._hidden),Z=$._getHelpCommand();if(Z&&!Z._hidden)J.push(Z);if(this.sortSubcommands)J.sort((Q,Y)=>{return Q.name().localeCompare(Y.name())});return J}compareOptions($,J){let Z=(Q)=>{return Q.short?Q.short.replace(/^-/,""):Q.long.replace(/^--/,"")};return Z($).localeCompare(Z(J))}visibleOptions($){let J=$.options.filter((Q)=>!Q.hidden),Z=$._getHelpOption();if(Z&&!Z.hidden){let Q=Z.short&&$._findOption(Z.short),Y=Z.long&&$._findOption(Z.long);if(!Q&&!Y)J.push(Z);else if(Z.long&&!Y)J.push($.createOption(Z.long,Z.description));else if(Z.short&&!Q)J.push($.createOption(Z.short,Z.description))}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let J=[];for(let Z=$.parent;Z;Z=Z.parent){let Q=Z.options.filter((Y)=>!Y.hidden);J.push(...Q)}if(this.sortOptions)J.sort(this.compareOptions);return J}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((J)=>{J.description=J.description||$._argsDescription[J.name()]||""});if($.registeredArguments.find((J)=>J.description))return $.registeredArguments;return[]}subcommandTerm($){let J=$.registeredArguments.map((Z)=>h0(Z)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(J?" "+J:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,J){return J.visibleCommands($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleSubcommandTerm(J.subcommandTerm(Q))))},0)}longestOptionTermLength($,J){return J.visibleOptions($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleOptionTerm(J.optionTerm(Q))))},0)}longestGlobalOptionTermLength($,J){return J.visibleGlobalOptions($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleOptionTerm(J.optionTerm(Q))))},0)}longestArgumentTermLength($,J){return J.visibleArguments($).reduce((Z,Q)=>{return Math.max(Z,this.displayWidth(J.styleArgumentTerm(J.argumentTerm(Q))))},0)}commandUsage($){let J=$._name;if($._aliases[0])J=J+"|"+$._aliases[0];let Z="";for(let Q=$.parent;Q;Q=Q.parent)Z=Q.name()+" "+Z;return Z+J+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)J.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)J.push(`env: ${$.envVar}`);if(J.length>0){let Z=`(${J.join(", ")})`;if($.description)return`${$.description} ${Z}`;return Z}return $.description}argumentDescription($){let J=[];if($.argChoices)J.push(`choices: ${$.argChoices.map((Z)=>JSON.stringify(Z)).join(", ")}`);if($.defaultValue!==void 0)J.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(J.length>0){let Z=`(${J.join(", ")})`;if($.description)return`${$.description} ${Z}`;return Z}return $.description}formatItemList($,J,Z){if(J.length===0)return[];return[Z.styleTitle($),...J,""]}groupItems($,J,Z){let Q=new Map;return $.forEach((Y)=>{let q=Z(Y);if(!Q.has(q))Q.set(q,[])}),J.forEach((Y)=>{let q=Z(Y);if(!Q.has(q))Q.set(q,[]);Q.get(q).push(Y)}),Q}formatHelp($,J){let Z=J.padWidth($,J),Q=J.helpWidth??80;function Y(K,W){return J.formatItem(K,Z,W,J)}let q=[`${J.styleTitle("Usage:")} ${J.styleUsage(J.commandUsage($))}`,""],z=J.commandDescription($);if(z.length>0)q=q.concat([J.boxWrap(J.styleCommandDescription(z),Q),""]);let F=J.visibleArguments($).map((K)=>{return Y(J.styleArgumentTerm(J.argumentTerm(K)),J.styleArgumentDescription(J.argumentDescription(K)))});if(q=q.concat(this.formatItemList("Arguments:",F,J)),this.groupItems($.options,J.visibleOptions($),(K)=>K.helpGroupHeading??"Options:").forEach((K,W)=>{let L=K.map((M)=>{return Y(J.styleOptionTerm(J.optionTerm(M)),J.styleOptionDescription(J.optionDescription(M)))});q=q.concat(this.formatItemList(W,L,J))}),J.showGlobalOptions){let K=J.visibleGlobalOptions($).map((W)=>{return Y(J.styleOptionTerm(J.optionTerm(W)),J.styleOptionDescription(J.optionDescription(W)))});q=q.concat(this.formatItemList("Global Options:",K,J))}return this.groupItems($.commands,J.visibleCommands($),(K)=>K.helpGroup()||"Commands:").forEach((K,W)=>{let L=K.map((M)=>{return Y(J.styleSubcommandTerm(J.subcommandTerm(M)),J.styleSubcommandDescription(J.subcommandDescription(M)))});q=q.concat(this.formatItemList(W,L,J))}),q.join(`
177
+ `)}displayWidth($){return w2($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((J)=>{if(J==="[options]")return this.styleOptionText(J);if(J==="[command]")return this.styleSubcommandText(J);if(J[0]==="["||J[0]==="<")return this.styleArgumentText(J);return this.styleCommandText(J)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((J)=>{if(J==="[options]")return this.styleOptionText(J);if(J[0]==="["||J[0]==="<")return this.styleArgumentText(J);return this.styleSubcommandText(J)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,J){return Math.max(J.longestOptionTermLength($,J),J.longestGlobalOptionTermLength($,J),J.longestSubcommandTermLength($,J),J.longestArgumentTermLength($,J))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,J,Z,Q){let q=" ".repeat(2);if(!Z)return q+$;let z=$.padEnd(J+$.length-Q.displayWidth($)),F=2,H=(this.helpWidth??80)-J-F-2,K;if(H<this.minWidthToWrap||Q.preformatted(Z))K=Z;else K=Q.boxWrap(Z,H).replace(/\n/g,`
178
178
  `+" ".repeat(J+F));return q+z+" ".repeat(F)+K.replace(/\n/g,`
179
179
  ${q}`)}boxWrap($,J){if(J<this.minWidthToWrap)return $;let Z=$.split(/\r\n|\n/),Q=/[\s]*[^\s]+/g,Y=[];return Z.forEach((q)=>{let z=q.match(Q);if(z===null){Y.push("");return}let F=[z.shift()],X=this.displayWidth(F[0]);z.forEach((H)=>{let K=this.displayWidth(H);if(X+K<=J){F.push(H),X+=K;return}Y.push(F.join(""));let W=H.trimStart();F=[W],X=this.displayWidth(W)}),Y.push(F.join(""))}),Y.join(`
180
- `)}}class R0{constructor($,J){this.flags=$,this.description=J||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let Z=w2($);if(this.short=Z.shortFlag,this.long=Z.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let J=$;if(typeof $==="string")J={[$]:!0};return this.implied=Object.assign(this.implied||{},J),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.push($),J}choices($){return this.argChoices=$.slice(),this.parseArg=(J,Z)=>{if(!this.argChoices.includes(J))throw new I0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(J,Z);return J},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return R3(this.name().replace(/^no-/,""));return R3(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class G1{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((J)=>{if(J.negate)this.negativeOptions.set(J.attributeName(),J);else this.positiveOptions.set(J.attributeName(),J)}),this.negativeOptions.forEach((J,Z)=>{if(this.positiveOptions.has(Z))this.dualOptions.add(Z)})}valueFromOption($,J){let Z=J.attributeName();if(!this.dualOptions.has(Z))return!0;let Q=this.negativeOptions.get(Z).presetArg,Y=Q!==void 0?Q:!1;return J.negate===(Y===$)}}function R3($){return $.split("-").reduce((J,Z)=>{return J+Z[0].toUpperCase()+Z.slice(1)})}function w2($){let J,Z,Q=/^-[^-]$/,Y=/^--[^-]/,q=$.split(/[ |,]+/).concat("guard");if(Q.test(q[0]))J=q.shift();if(Y.test(q[0]))Z=q.shift();if(!J&&Q.test(q[0]))J=q.shift();if(!J&&Y.test(q[0]))J=Z,Z=q.shift();if(q[0].startsWith("-")){let z=q[0],F=`option creation failed due to '${z}' in option flags '${$}'`;if(/^-[^-][^-]/.test(z))throw Error(`${F}
180
+ `)}}class R0{constructor($,J){this.flags=$,this.description=J||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let Z=v2($);if(this.short=Z.shortFlag,this.long=Z.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,J){return this.defaultValue=$,this.defaultValueDescription=J,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let J=$;if(typeof $==="string")J={[$]:!0};return this.implied=Object.assign(this.implied||{},J),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,J){if(J===this.defaultValue||!Array.isArray(J))return[$];return J.push($),J}choices($){return this.argChoices=$.slice(),this.parseArg=(J,Z)=>{if(!this.argChoices.includes(J))throw new I0(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(J,Z);return J},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return R3(this.name().replace(/^no-/,""));return R3(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class G1{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((J)=>{if(J.negate)this.negativeOptions.set(J.attributeName(),J);else this.positiveOptions.set(J.attributeName(),J)}),this.negativeOptions.forEach((J,Z)=>{if(this.positiveOptions.has(Z))this.dualOptions.add(Z)})}valueFromOption($,J){let Z=J.attributeName();if(!this.dualOptions.has(Z))return!0;let Q=this.negativeOptions.get(Z).presetArg,Y=Q!==void 0?Q:!1;return J.negate===(Y===$)}}function R3($){return $.split("-").reduce((J,Z)=>{return J+Z[0].toUpperCase()+Z.slice(1)})}function v2($){let J,Z,Q=/^-[^-]$/,Y=/^--[^-]/,q=$.split(/[ |,]+/).concat("guard");if(Q.test(q[0]))J=q.shift();if(Y.test(q[0]))Z=q.shift();if(!J&&Q.test(q[0]))J=q.shift();if(!J&&Y.test(q[0]))J=Z,Z=q.shift();if(q[0].startsWith("-")){let z=q[0],F=`option creation failed due to '${z}' in option flags '${$}'`;if(/^-[^-][^-]/.test(z))throw Error(`${F}
181
181
  - a short flag is a single dash and a single character
182
182
  - either use a single dash and a single character (for a short flag)
183
183
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(Q.test(z))throw Error(`${F}
@@ -185,7 +185,7 @@ ${q}`)}boxWrap($,J){if(J<this.minWidthToWrap)return $;let Z=$.split(/\r\n|\n/),Q
185
185
  - too many long flags`);throw Error(`${F}
186
186
  - unrecognised flag format`)}if(J===void 0&&Z===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:J,longFlag:Z}}function f2($,J){if(Math.abs($.length-J.length)>3)return Math.max($.length,J.length);let Z=[];for(let Q=0;Q<=$.length;Q++)Z[Q]=[Q];for(let Q=0;Q<=J.length;Q++)Z[0][Q]=Q;for(let Q=1;Q<=J.length;Q++)for(let Y=1;Y<=$.length;Y++){let q;if($[Y-1]===J[Q-1])q=0;else q=1;if(Z[Y][Q]=Math.min(Z[Y-1][Q]+1,Z[Y][Q-1]+1,Z[Y-1][Q-1]+q),Y>1&&Q>1&&$[Y-1]===J[Q-2]&&$[Y-2]===J[Q-1])Z[Y][Q]=Math.min(Z[Y][Q],Z[Y-2][Q-2]+1)}return Z[$.length][J.length]}function F1($,J){if(!J||J.length===0)return"";J=Array.from(new Set(J));let Z=$.startsWith("--");if(Z)$=$.slice(2),J=J.map((z)=>z.slice(2));let Q=[],Y=3,q=0.4;if(J.forEach((z)=>{if(z.length<=1)return;let F=f2($,z),X=Math.max($.length,z.length);if((X-F)/X>q){if(F<Y)Y=F,Q=[z];else if(F===Y)Q.push(z)}}),Q.sort((z,F)=>z.localeCompare(F)),Z)Q=Q.map((z)=>`--${z}`);if(Q.length>1)return`
187
187
  (Did you mean one of ${Q.join(", ")}?)`;if(Q.length===1)return`
188
- (Did you mean ${Q[0]}?)`;return""}class q0 extends v2{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(J)=>b.stdout.write(J),writeErr:(J)=>b.stderr.write(J),outputError:(J,Z)=>Z(J),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,getOutHasColors:()=>w3()??(b.stdout.isTTY&&b.stdout.hasColors?.()),getErrHasColors:()=>w3()??(b.stderr.isTTY&&b.stderr.hasColors?.()),stripColor:(J)=>O2(J)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let J=this;J;J=J.parent)$.push(J);return $}command($,J,Z){let Q=J,Y=Z;if(typeof Q==="object"&&Q!==null)Y=Q,Q=null;Y=Y||{};let[,q,z]=$.match(/([^ ]+) *(.*)/),F=this.createCommand(q);if(Q)F.description(Q),F._executableHandler=!0;if(Y.isDefault)this._defaultCommandName=F._name;if(F._hidden=!!(Y.noHelp||Y.hidden),F._executableFile=Y.executableFile||null,z)F.arguments(z);if(this._registerCommand(F),F.parent=this,F.copyInheritedSettings(this),Q)return this;return F}createCommand($){return new q0($)}createHelp(){return Object.assign(new u0,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,J){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
188
+ (Did you mean ${Q[0]}?)`;return""}class q0 extends O2{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(J)=>b.stdout.write(J),writeErr:(J)=>b.stderr.write(J),outputError:(J,Z)=>Z(J),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,getOutHasColors:()=>w3()??(b.stdout.isTTY&&b.stdout.hasColors?.()),getErrHasColors:()=>w3()??(b.stderr.isTTY&&b.stderr.hasColors?.()),stripColor:(J)=>C2(J)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let J=this;J;J=J.parent)$.push(J);return $}command($,J,Z){let Q=J,Y=Z;if(typeof Q==="object"&&Q!==null)Y=Q,Q=null;Y=Y||{};let[,q,z]=$.match(/([^ ]+) *(.*)/),F=this.createCommand(q);if(Q)F.description(Q),F._executableHandler=!0;if(Y.isDefault)this._defaultCommandName=F._name;if(F._hidden=!!(Y.noHelp||Y.hidden),F._executableFile=Y.executableFile||null,z)F.arguments(z);if(this._registerCommand(F),F.parent=this,F.copyInheritedSettings(this),Q)return this;return F}createCommand($){return new q0($)}createHelp(){return Object.assign(new u0,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,J){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
189
189
  - specify the name in Command constructor or using .name()`);if(J=J||{},J.isDefault)this._defaultCommandName=$._name;if(J.noHelp||J.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,J){return new x0($,J)}argument($,J,Z,Q){let Y=this.createArgument($,J);if(typeof Z==="function")Y.default(Q).argParser(Z);else Y.default(Z);return this.addArgument(Y),this}arguments($){return $.trim().split(/ +/).forEach((J)=>{this.argument(J)}),this}addArgument($){let J=this.registeredArguments.slice(-1)[0];if(J?.variadic)throw Error(`only the last argument can be variadic '${J.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,J){if(typeof $==="boolean"){if(this._addImplicitHelpCommand=$,$&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let Z=$??"help [command]",[,Q,Y]=Z.match(/([^ ]+) *(.*)/),q=J??"display help for command",z=this.createCommand(Q);if(z.helpOption(!1),Y)z.arguments(Y);if(q)z.description(q);if(this._addImplicitHelpCommand=!0,this._helpCommand=z,$||J)this._initCommandGroup(z);return this}addHelpCommand($,J){if(typeof $!=="object")return this.helpCommand($,J),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this._initCommandGroup($),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,J){let Z=["preSubcommand","preAction","postAction"];if(!Z.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
190
190
  Expecting one of '${Z.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(J);else this._lifeCycleHooks[$]=[J];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(J)=>{if(J.code!=="commander.executeSubCommandAsync")throw J};return this}_exit($,J,Z){if(this._exitCallback)this._exitCallback(new Y0($,J,Z));b.exit($)}action($){let J=(Z)=>{let Q=this.registeredArguments.length,Y=Z.slice(0,Q);if(this._storeOptionsAsProperties)Y[Q]=this;else Y[Q]=this.opts();return Y.push(this),$.apply(this,Y)};return this._actionHandler=J,this}createOption($,J){return new R0($,J)}_callParseArg($,J,Z,Q){try{return $.parseArg(J,Z)}catch(Y){if(Y.code==="commander.invalidArgument"){let q=`${Q} ${Y.message}`;this.error(q,{exitCode:Y.exitCode,code:Y.code})}throw Y}}_registerOption($){let J=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(J){let Z=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${Z}'
191
191
  - already used by option '${J.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let J=(Q)=>{return[Q.name()].concat(Q.aliases())},Z=J($).find((Q)=>this._findCommand(Q));if(Z){let Q=J(this._findCommand(Z)).join("|"),Y=J($).join("|");throw Error(`cannot add command '${Y}' as already have command '${Q}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let J=$.name(),Z=$.attributeName();if($.defaultValue!==void 0)this.setOptionValueWithSource(Z,$.defaultValue,"default");let Q=(Y,q,z)=>{if(Y==null&&$.presetArg!==void 0)Y=$.presetArg;let F=this.getOptionValue(Z);if(Y!==null&&$.parseArg)Y=this._callParseArg($,Y,F,q);else if(Y!==null&&$.variadic)Y=$._collectValue(Y,F);if(Y==null)if($.negate)Y=!1;else if($.isBoolean()||$.optional)Y=!0;else Y="";this.setOptionValueWithSource(Z,Y,z)};if(this.on("option:"+J,(Y)=>{let q=`error: option '${$.flags}' argument '${Y}' is invalid.`;Q(Y,q,"cli")}),$.envVar)this.on("optionEnv:"+J,(Y)=>{let q=`error: option '${$.flags}' value '${Y}' from env '${$.envVar}' is invalid.`;Q(Y,q,"env")});return this}_optionEx($,J,Z,Q,Y){if(typeof J==="object"&&J instanceof R0)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let q=this.createOption(J,Z);if(q.makeOptionMandatory(!!$.mandatory),typeof Q==="function")q.default(Y).argParser(Q);else if(Q instanceof RegExp){let z=Q;Q=(F,X)=>{let H=z.exec(F);return H?H[0]:X},q.default(Y).argParser(Q)}else q.default(Q);return this.addOption(q)}option($,J,Z,Q){return this._optionEx({},$,J,Z,Q)}requiredOption($,J,Z,Q){return this._optionEx({mandatory:!0},$,J,Z,Q)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,J){return this.setOptionValueWithSource($,J,void 0)}setOptionValueWithSource($,J,Z){if(this._storeOptionsAsProperties)this[$]=J;else this._optionValues[$]=J;return this._optionValueSources[$]=Z,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let J;return this._getCommandAndAncestors().forEach((Z)=>{if(Z.getOptionValueSource($)!==void 0)J=Z.getOptionValueSource($)}),J}_prepareUserArgs($,J){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(J=J||{},$===void 0&&J.from===void 0){if(b.versions?.electron)J.from="electron";let Q=b.execArgv??[];if(Q.includes("-e")||Q.includes("--eval")||Q.includes("-p")||Q.includes("--print"))J.from="eval"}if($===void 0)$=b.argv;this.rawArgs=$.slice();let Z;switch(J.from){case void 0:case"node":this._scriptPath=$[1],Z=$.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=$[1],Z=$.slice(2);else Z=$.slice(1);break;case"user":Z=$.slice(0);break;case"eval":Z=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${J.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",Z}parse($,J){this._prepareForParse();let Z=this._prepareUserArgs($,J);return this._parseCommand([],Z),this}async parseAsync($,J){this._prepareForParse();let Z=this._prepareUserArgs($,J);return await this._parseCommand([],Z),this}_prepareForParse(){if(this._savedState===null)this.options.filter(($)=>$.negate&&$.defaultValue===void 0&&this.getOptionValue($.attributeName())===void 0).forEach(($)=>{let J=$.long.replace(/^--no-/,"--");if(!this._findOption(J))this.setOptionValueWithSource($.attributeName(),!0,"default")}),this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
@@ -198,6 +198,6 @@ Expecting one of '${Z.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycl
198
198
  `),this.outputHelp({error:!0});let Z=J||{},Q=Z.exitCode||1,Y=Z.code||"commander.error";this._exit(Q,Y,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let J=$.attributeName();if(this.getOptionValue(J)===void 0||["default","config","env"].includes(this.getOptionValueSource(J)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new G1(this.options),J=(Z)=>{return this.getOptionValue(Z)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(Z))};this.options.filter((Z)=>Z.implied!==void 0&&J(Z.attributeName())&&$.valueFromOption(this.getOptionValue(Z.attributeName()),Z)).forEach((Z)=>{Object.keys(Z.implied).filter((Q)=>!J(Q)).forEach((Q)=>{this.setOptionValueWithSource(Q,Z.implied[Q],"implied")})})}missingArgument($){let J=`error: missing required argument '${$}'`;this.error(J,{code:"commander.missingArgument"})}optionMissingArgument($){let J=`error: option '${$.flags}' argument missing`;this.error(J,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let J=`error: required option '${$.flags}' not specified`;this.error(J,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,J){let Z=(q)=>{let z=q.attributeName(),F=this.getOptionValue(z),X=this.options.find((K)=>K.negate&&z===K.attributeName()),H=this.options.find((K)=>!K.negate&&z===K.attributeName());if(X&&(X.presetArg===void 0&&F===!1||X.presetArg!==void 0&&F===X.presetArg))return X;return H||q},Q=(q)=>{let z=Z(q),F=z.attributeName();if(this.getOptionValueSource(F)==="env")return`environment variable '${z.envVar}'`;return`option '${z.flags}'`},Y=`error: ${Q($)} cannot be used with ${Q(J)}`;this.error(Y,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let J="";if($.startsWith("--")&&this._showSuggestionAfterError){let Q=[],Y=this;do{let q=Y.createHelp().visibleOptions(Y).filter((z)=>z.long).map((z)=>z.long);Q=Q.concat(q),Y=Y.parent}while(Y&&!Y._enablePositionalOptions);J=F1($,Q)}let Z=`error: unknown option '${$}'${J}`;this.error(Z,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let J=this.registeredArguments.length,Z=J===1?"":"s",Q=$.length,Y=this.parent?` for '${this.name()}'`:"",q=$.join(", "),z=`error: too many arguments${Y}. Expected ${J} argument${Z} but got ${Q}: ${q}.`;this.error(z,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],J="";if(this._showSuggestionAfterError){let Q=[];this.createHelp().visibleCommands(this).forEach((Y)=>{if(Q.push(Y.name()),Y.alias())Q.push(Y.alias())}),J=F1($,Q)}let Z=`error: unknown command '${$}'${J}`;this.error(Z,{code:"commander.unknownCommand"})}version($,J,Z){if($===void 0)return this._version;this._version=$,J=J||"-V, --version",Z=Z||"output the version number";let Q=this.createOption(J,Z);return this._versionOptionName=Q.attributeName(),this._registerOption(Q),this.on("option:"+Q.name(),()=>{this._outputConfiguration.writeOut(`${$}
199
199
  `),this._exit(0,"commander.version",$)}),this}description($,J){if($===void 0&&J===void 0)return this._description;if(this._description=$,J)this._argsDescription=J;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let J=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)J=this.commands[this.commands.length-1];if($===J._name)throw Error("Command alias can't be the same as its name");let Z=this.parent?._findCommand($);if(Z){let Q=[Z.name()].concat(Z.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${Q}'`)}return J._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((J)=>this.alias(J)),this}usage($){if($===void 0){if(this._usage)return this._usage;let J=this.registeredArguments.map((Z)=>{return h0(Z)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?J:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}helpGroup($){if($===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=$,this}commandsGroup($){if($===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=$,this}optionsGroup($){if($===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=$,this}_initOptionGroup($){if(this._defaultOptionGroup&&!$.helpGroupHeading)$.helpGroup(this._defaultOptionGroup)}_initCommandGroup($){if(this._defaultCommandGroup&&!$.helpGroup())$.helpGroup(this._defaultCommandGroup)}nameFromFilename($){return this._name=r.basename($,r.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let J=this.createHelp(),Z=this._getOutputContext($);J.prepareContext({error:Z.error,helpWidth:Z.helpWidth,outputHasColors:Z.hasColors});let Q=J.formatHelp(this,J);if(Z.hasColors)return Q;return this._outputConfiguration.stripColor(Q)}_getOutputContext($){$=$||{};let J=!!$.error,Z,Q,Y;if(J)Z=(z)=>this._outputConfiguration.writeErr(z),Q=this._outputConfiguration.getErrHasColors(),Y=this._outputConfiguration.getErrHelpWidth();else Z=(z)=>this._outputConfiguration.writeOut(z),Q=this._outputConfiguration.getOutHasColors(),Y=this._outputConfiguration.getOutHelpWidth();return{error:J,write:(z)=>{if(!Q)z=this._outputConfiguration.stripColor(z);return Z(z)},hasColors:Q,helpWidth:Y}}outputHelp($){let J;if(typeof $==="function")J=$,$=void 0;let Z=this._getOutputContext($),Q={error:Z.error,write:Z.write,command:this};this._getCommandAndAncestors().reverse().forEach((q)=>q.emit("beforeAllHelp",Q)),this.emit("beforeHelp",Q);let Y=this.helpInformation({error:Z.error});if(J){if(Y=J(Y),typeof Y!=="string"&&!Buffer.isBuffer(Y))throw Error("outputHelp callback must return a string or a Buffer")}if(Z.write(Y),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",Q),this._getCommandAndAncestors().forEach((q)=>q.emit("afterAllHelp",Q))}helpOption($,J){if(typeof $==="boolean"){if($){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption($??"-h, --help",J??"display help for command"),$||J)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this._initOptionGroup($),this}help($){this.outputHelp($);let J=Number(b.exitCode??0);if(J===0&&$&&typeof $!=="function"&&$.error)J=1;this._exit(J,"commander.help","(outputHelp)")}addHelpText($,J){let Z=["beforeAll","before","after","afterAll"];if(!Z.includes($))throw Error(`Unexpected value for position to addHelpText.
200
200
  Expecting one of '${Z.join("', '")}'`);let Q=`${$}Help`;return this.on(Q,(Y)=>{let q;if(typeof J==="function")q=J({error:Y.error,command:Y.command});else q=J;if(q)Y.write(`${q}
201
- `)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((Q)=>J.is(Q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function S3($){return $.map((J)=>{if(!J.startsWith("--inspect"))return J;let Z,Q="127.0.0.1",Y="9229",q;if((q=J.match(/^(--inspect(-brk)?)$/))!==null)Z=q[1];else if((q=J.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Z=q[1],/^\d+$/.test(q[3]))Y=q[3];else Q=q[3];else if((q=J.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Z=q[1],Q=q[3],Y=q[4];if(Z&&Y!=="0")return`${Z}=${Q}:${parseInt(Y)+1}`;return J})}function w3(){if(b.env.NO_COLOR||b.env.FORCE_COLOR==="0"||b.env.FORCE_COLOR==="false")return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0;return}var j4=new q0;C0();A0();q1();C0();A0();q1();F0();async function y7(){let $=Z0();if(!$)return{status:"error",label:"Autenticação",detail:"Não autenticado",fix:"productdock login"};return{status:"ok",label:"Autenticação",detail:`Credenciais encontradas (${$.user?.email??"desconhecido"})`}}async function x7(){try{return await j0(),{status:"ok",label:"Renovação do token",detail:"Token de acesso válido ou renovado com sucesso"}}catch($){return{status:"error",label:"Renovação do token",detail:$ instanceof B0?"Sessão expirada":`Falha na renovação: ${$ instanceof Error?$.message:String($)}`,fix:"productdock login"}}}async function h7(){let $=Q1();if(!$)return{status:"error",label:"Vínculo do projeto",detail:"productdock.json não encontrado no diretório atual",fix:"productdock link"};return{status:"ok",label:"Vínculo do projeto",detail:`Vinculado a "${$.projectName}" (${$.projectId})`}}async function u7(){try{let $=await j0().catch(()=>null);return{status:"ok",label:"Alcance do servidor MCP",detail:`Acessível (HTTP ${(await fetch(x,{signal:AbortSignal.timeout(5000),headers:$?{authorization:`Bearer ${$}`}:{}})).status})`}}catch{return{status:"warn",label:"Alcance do servidor MCP",detail:"Não foi possível alcançar o servidor MCP"}}}async function g7(){let $=Q1();if(!$)return[];let J=process.cwd();return $.ides.map((Z)=>{let Q=Y1(Z,J);return{status:Q?"ok":"warn",label:`Config de IDE (${Z})`,detail:Q?"Aponta para a URL do servidor MCP":"Config ausente ou apontando para URL incorreta",fix:Q?void 0:"productdock mcp setup"}})}function m7($){let J=$.status==="ok"?" ✔":$.status==="warn"?" !":" ✖";if(console.log(`${J} ${$.label}: ${$.detail}`),$.fix&&$.status!=="ok")console.log(` → run: ${$.fix}`)}async function c7(){let{cmdMcpSetup:$}=await Promise.resolve().then(() => (q1(),L2));await $({})}async function U2($){let{intro:J,outro:Z}=await Promise.resolve().then(() => (M0(),U0));J("ProductDock — Diagnóstico");let Q=await y7(),Y=Q.status!=="error"?await x7():{status:"error",label:"Renovação do token",detail:"Ignorado — não autenticado"},q=await h7(),z=await u7(),F=await g7(),X=[Q,Y,q,z,...F];for(let W of X)m7(W);let H=X.some((W)=>W.status==="error"),K=X.some((W)=>W.status==="warn");if(!H&&!K){Z("Todas as verificações passaram.");return}if(!$.fix){Z(H?"Problemas encontrados. Execute 'productdock doctor --fix' para corrigir automaticamente onde possível.":"Avisos encontrados. Execute 'productdock doctor --fix' para corrigir automaticamente onde possível.");return}for(let W of F)if(W.status!=="ok"){console.log(`
202
- Corrigindo: Gravando config do MCP...`),await c7();break}if(Q.status==="error"||Y.status==="error")console.log(`
203
- Não é possível corrigir automação. Execute: productdock login`);Z("Correção concluída. Execute 'productdock doctor' novamente para verificar.")}F0();var b0=new q0().name("productdock").description("ProductDock CLI — gerencie o setup do MCP, vinculação de projetos e skills").version(z9);b0.command("login").description("Autenticar com Azure AD (OAuth 2.1 + PKCE)").action(U3);b0.command("logout").description("Revogar tokens e limpar credenciais").action(M3);b0.command("link").description("Vincular este diretório a um projeto ProductDock").option("--project-id <uuid>","Pular seleção interativa de projeto").option("--ide <ides>","Lista de IDEs separadas por vírgula (claude-code,cursor,vscode,claude-desktop)").action(N3);var B3=new q0("mcp").description("Gerenciar configuração do servidor MCP");B3.command("setup").description("Gravar config do proxy MCP para as IDEs configuradas").option("--ide <ide>","Direcionar apenas uma IDE específica").option("--dry-run","Mostrar o que seria escrito sem fazer alterações").action(k3);B3.command("status").description("Verificar conectividade do MCP e validade do token").action(P3);b0.addCommand(B3);b0.command("doctor").description("Diagnosticar e opcionalmente corrigir problemas de configuração").option("--fix","Corrigir automaticamente os problemas detectados").action(U2);b0.parseAsync(process.argv);
201
+ `)}),this}_outputHelpIfRequested($){let J=this._getHelpOption();if(J&&$.find((Q)=>J.is(Q)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function S3($){return $.map((J)=>{if(!J.startsWith("--inspect"))return J;let Z,Q="127.0.0.1",Y="9229",q;if((q=J.match(/^(--inspect(-brk)?)$/))!==null)Z=q[1];else if((q=J.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(Z=q[1],/^\d+$/.test(q[3]))Y=q[3];else Q=q[3];else if((q=J.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)Z=q[1],Q=q[3],Y=q[4];if(Z&&Y!=="0")return`${Z}=${Q}:${parseInt(Y)+1}`;return J})}function w3(){if(b.env.NO_COLOR||b.env.FORCE_COLOR==="0"||b.env.FORCE_COLOR==="false")return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0;return}var I4=new q0;C0();A0();q1();C0();A0();q1();F0();async function h7(){let $=Z0();if(!$)return{status:"error",label:"Autenticação",detail:"Não autenticado",fix:"productdock login"};return{status:"ok",label:"Autenticação",detail:`Credenciais encontradas (${$.user?.email??"desconhecido"})`}}async function u7(){try{return await j0(),{status:"ok",label:"Renovação do token",detail:"Token de acesso válido ou renovado com sucesso"}}catch($){return{status:"error",label:"Renovação do token",detail:$ instanceof B0?"Sessão expirada":`Falha na renovação: ${$ instanceof Error?$.message:String($)}`,fix:"productdock login"}}}async function g7(){let $=Q1();if(!$)return{status:"error",label:"Vínculo do projeto",detail:"productdock.json não encontrado no diretório atual",fix:"productdock link"};return{status:"ok",label:"Vínculo do projeto",detail:`Vinculado a "${$.projectName}" (${$.projectId})`}}async function m7(){try{let $=await j0().catch(()=>null);return{status:"ok",label:"Alcance do servidor MCP",detail:`Acessível (HTTP ${(await fetch(x,{signal:AbortSignal.timeout(5000),headers:$?{authorization:`Bearer ${$}`}:{}})).status})`}}catch{return{status:"warn",label:"Alcance do servidor MCP",detail:"Não foi possível alcançar o servidor MCP"}}}async function c7(){let $=Q1();if(!$)return[];let J=process.cwd();return $.ides.map((Z)=>{let Q=Y1(Z,J);return{status:Q?"ok":"warn",label:`Config de IDE (${Z})`,detail:Q?"Aponta para a URL do servidor MCP":"Config ausente ou apontando para URL incorreta",fix:Q?void 0:"productdock mcp setup"}})}function d7($){let J=$.status==="ok"?" ✔":$.status==="warn"?" !":" ✖";if(console.log(`${J} ${$.label}: ${$.detail}`),$.fix&&$.status!=="ok")console.log(` → run: ${$.fix}`)}async function l7(){let{cmdMcpSetup:$}=await Promise.resolve().then(() => (q1(),U2));await $({})}async function M2($){let{intro:J,outro:Z}=await Promise.resolve().then(() => (M0(),U0));J("ProductDock — Diagnóstico");let Q=await h7(),Y=Q.status!=="error"?await u7():{status:"error",label:"Renovação do token",detail:"Ignorado — não autenticado"},q=await g7(),z=await m7(),F=await c7(),X=[Q,Y,q,z,...F];for(let W of X)d7(W);let H=X.some((W)=>W.status==="error"),K=X.some((W)=>W.status==="warn");if(!H&&!K){Z("Todas as verificações passaram.");return}if(!$.fix){Z(H?"Problemas encontrados. Execute 'productdock doctor --fix' para corrigir automaticamente onde possível.":"Avisos encontrados. Execute 'productdock doctor --fix' para corrigir automaticamente onde possível.");return}for(let W of F)if(W.status!=="ok"){console.log(`
202
+ Corrigindo: Gravando config do MCP...`),await l7();break}if(Q.status==="error"||Y.status==="error")console.log(`
203
+ Não é possível corrigir automação. Execute: productdock login`);Z("Correção concluída. Execute 'productdock doctor' novamente para verificar.")}F0();var b0=new q0().name("productdock").description("ProductDock CLI — gerencie o setup do MCP, vinculação de projetos e skills").version(G9);b0.command("login").description("Autenticar com Azure AD (OAuth 2.1 + PKCE)").action(U3);b0.command("logout").description("Revogar tokens e limpar credenciais").action(M3);b0.command("link").description("Vincular este diretório a um projeto ProductDock").option("--project-id <uuid>","Pular seleção interativa de projeto").option("--ide <ides>","Lista de IDEs separadas por vírgula (claude-code,cursor,vscode,claude-desktop)").action(N3);var B3=new q0("mcp").description("Gerenciar configuração do servidor MCP");B3.command("setup").description("Gravar config do proxy MCP para as IDEs configuradas").option("--ide <ide>","Direcionar apenas uma IDE específica").option("--dry-run","Mostrar o que seria escrito sem fazer alterações").action(k3);B3.command("status").description("Verificar conectividade do MCP e validade do token").action(P3);b0.addCommand(B3);b0.command("doctor").description("Diagnosticar e opcionalmente corrigir problemas de configuração").option("--fix","Corrigir automaticamente os problemas detectados").action(M2);b0.parseAsync(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softdesignbrasil/productdock-cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "ProductDock CLI — manage MCP setup, project linking, and skills",
5
5
  "type": "module",
6
6
  "engines": {
@@ -10,7 +10,7 @@
10
10
  "productdock": "dist/productdock.js"
11
11
  },
12
12
  "files": [
13
- "dist/"
13
+ "dist/productdock.js"
14
14
  ],
15
15
  "scripts": {
16
16
  "dev": "bun run bin/productdock.ts",