vidup 1.0.0 → 1.0.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.
package/bin/cli.js CHANGED
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
- var Me=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var vn=(i=0)=>e=>`\x1B[${e+i}m`,$n=(i=0)=>e=>`\x1B[${38+i};5;${e}m`,Nn=(i=0)=>(e,t,n)=>`\x1B[${38+i};2;${e};${t};${n}m`,Q={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Nr=Object.keys(Q.modifier),ts=Object.keys(Q.color),ns=Object.keys(Q.bgColor),Fr=[...ts,...ns];function is(){let i=new Map;for(let[e,t]of Object.entries(Q)){for(let[n,s]of Object.entries(t))Q[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[n]=Q[n],i.set(s[0],s[1]);Object.defineProperty(Q,e,{value:t,enumerable:!1})}return Object.defineProperty(Q,"codes",{value:i,enumerable:!1}),Q.color.close="\x1B[39m",Q.bgColor.close="\x1B[49m",Q.color.ansi=vn(),Q.color.ansi256=$n(),Q.color.ansi16m=Nn(),Q.bgColor.ansi=vn(10),Q.bgColor.ansi256=$n(10),Q.bgColor.ansi16m=Nn(10),Object.defineProperties(Q,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(r=>r+r).join(""));let s=Number.parseInt(n,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>Q.rgbToAnsi256(...Q.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,s;if(e>=232)t=((e-232)*10+8)/255,n=t,s=t;else{e-=16;let c=e%36;t=Math.floor(e/36)/5,n=Math.floor(c/6)/5,s=c%6/5}let r=Math.max(t,n,s)*2;if(r===0)return 30;let a=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(t));return r===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>Q.ansi256ToAnsi(Q.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Q.ansi256ToAnsi(Q.hexToAnsi256(e)),enumerable:!1}}),Q}var ss=is(),Se=ss;import qt from"node:process";import rs from"node:os";import Fn from"node:tty";function ye(i,e=globalThis.Deno?globalThis.Deno.args:qt.argv){let t=i.startsWith("-")?"":i.length===1?"-":"--",n=e.indexOf(t+i),s=e.indexOf("--");return n!==-1&&(s===-1||n<s)}var{env:X}=qt,Ot;ye("no-color")||ye("no-colors")||ye("color=false")||ye("color=never")?Ot=0:(ye("color")||ye("colors")||ye("color=true")||ye("color=always"))&&(Ot=1);function os(){if("FORCE_COLOR"in X)return X.FORCE_COLOR==="true"?1:X.FORCE_COLOR==="false"?0:X.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(X.FORCE_COLOR,10),3)}function as(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function ls(i,{streamIsTTY:e,sniffFlags:t=!0}={}){let n=os();n!==void 0&&(Ot=n);let s=t?Ot:n;if(s===0)return 0;if(t){if(ye("color=16m")||ye("color=full")||ye("color=truecolor"))return 3;if(ye("color=256"))return 2}if("TF_BUILD"in X&&"AGENT_NAME"in X)return 1;if(i&&!e&&s===void 0)return 0;let r=s||0;if(X.TERM==="dumb")return r;if(qt.platform==="win32"){let a=rs.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in X)return"GITHUB_ACTIONS"in X||"GITEA_ACTIONS"in X?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(a=>a in X)||X.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in X)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(X.TEAMCITY_VERSION)?1:0;if(X.COLORTERM==="truecolor"||X.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in X){let a=Number.parseInt((X.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(X.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(X.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(X.TERM)||"COLORTERM"in X?1:r}function Rn(i,e={}){let t=ls(i,{streamIsTTY:i&&i.isTTY,...e});return as(t)}var cs={stdout:Rn({isTTY:Fn.isatty(1)}),stderr:Rn({isTTY:Fn.isatty(2)})},Dn=cs;function Tn(i,e,t){let n=i.indexOf(e);if(n===-1)return i;let s=e.length,r=0,a="";do a+=i.slice(r,n)+e+t,r=n+s,n=i.indexOf(e,r);while(n!==-1);return a+=i.slice(r),a}function Ln(i,e,t,n){let s=0,r="";do{let a=i[n-1]==="\r";r+=i.slice(s,a?n-1:n)+e+(a?`\r
2
+ var Se=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var $n=(i=0)=>e=>`\x1B[${e+i}m`,Nn=(i=0)=>e=>`\x1B[${38+i};5;${e}m`,Fn=(i=0)=>(e,t,n)=>`\x1B[${38+i};2;${e};${t};${n}m`,Q={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Rr=Object.keys(Q.modifier),ts=Object.keys(Q.color),ns=Object.keys(Q.bgColor),Dr=[...ts,...ns];function is(){let i=new Map;for(let[e,t]of Object.entries(Q)){for(let[n,s]of Object.entries(t))Q[n]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},t[n]=Q[n],i.set(s[0],s[1]);Object.defineProperty(Q,e,{value:t,enumerable:!1})}return Object.defineProperty(Q,"codes",{value:i,enumerable:!1}),Q.color.close="\x1B[39m",Q.bgColor.close="\x1B[49m",Q.color.ansi=$n(),Q.color.ansi256=Nn(),Q.color.ansi16m=Fn(),Q.bgColor.ansi=$n(10),Q.bgColor.ansi256=Nn(10),Q.bgColor.ansi16m=Fn(10),Object.defineProperties(Q,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(r=>r+r).join(""));let s=Number.parseInt(n,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:e=>Q.rgbToAnsi256(...Q.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,s;if(e>=232)t=((e-232)*10+8)/255,n=t,s=t;else{e-=16;let c=e%36;t=Math.floor(e/36)/5,n=Math.floor(c/6)/5,s=c%6/5}let r=Math.max(t,n,s)*2;if(r===0)return 30;let a=30+(Math.round(s)<<2|Math.round(n)<<1|Math.round(t));return r===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>Q.ansi256ToAnsi(Q.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Q.ansi256ToAnsi(Q.hexToAnsi256(e)),enumerable:!1}}),Q}var ss=is(),Ee=ss;import qt from"node:process";import rs from"node:os";import Rn from"node:tty";function ge(i,e=globalThis.Deno?globalThis.Deno.args:qt.argv){let t=i.startsWith("-")?"":i.length===1?"-":"--",n=e.indexOf(t+i),s=e.indexOf("--");return n!==-1&&(s===-1||n<s)}var{env:X}=qt,wt;ge("no-color")||ge("no-colors")||ge("color=false")||ge("color=never")?wt=0:(ge("color")||ge("colors")||ge("color=true")||ge("color=always"))&&(wt=1);function os(){if("FORCE_COLOR"in X)return X.FORCE_COLOR==="true"?1:X.FORCE_COLOR==="false"?0:X.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(X.FORCE_COLOR,10),3)}function as(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function ls(i,{streamIsTTY:e,sniffFlags:t=!0}={}){let n=os();n!==void 0&&(wt=n);let s=t?wt:n;if(s===0)return 0;if(t){if(ge("color=16m")||ge("color=full")||ge("color=truecolor"))return 3;if(ge("color=256"))return 2}if("TF_BUILD"in X&&"AGENT_NAME"in X)return 1;if(i&&!e&&s===void 0)return 0;let r=s||0;if(X.TERM==="dumb")return r;if(qt.platform==="win32"){let a=rs.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in X)return"GITHUB_ACTIONS"in X||"GITEA_ACTIONS"in X?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(a=>a in X)||X.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in X)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(X.TEAMCITY_VERSION)?1:0;if(X.COLORTERM==="truecolor"||X.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in X){let a=Number.parseInt((X.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(X.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(X.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(X.TERM)||"COLORTERM"in X?1:r}function Dn(i,e={}){let t=ls(i,{streamIsTTY:i&&i.isTTY,...e});return as(t)}var cs={stdout:Dn({isTTY:Rn.isatty(1)}),stderr:Dn({isTTY:Rn.isatty(2)})},Tn=cs;function Ln(i,e,t){let n=i.indexOf(e);if(n===-1)return i;let s=e.length,r=0,a="";do a+=i.slice(r,n)+e+t,r=n+s,n=i.indexOf(e,r);while(n!==-1);return a+=i.slice(r),a}function Wn(i,e,t,n){let s=0,r="";do{let a=i[n-1]==="\r";r+=i.slice(s,a?n-1:n)+e+(a?`\r
3
3
  `:`
4
4
  `)+t,s=n+1,n=i.indexOf(`
5
- `,s)}while(n!==-1);return r+=i.slice(s),r}var{stdout:Wn,stderr:Un}=Dn,Kt=Symbol("GENERATOR"),nt=Symbol("STYLER"),ft=Symbol("IS_EMPTY"),Bn=["ansi","ansi","ansi256","ansi16m"],it=Object.create(null),fs=(i,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Wn?Wn.level:0;i.level=e.level===void 0?t:e.level};var us=i=>{let e=(...t)=>t.join(" ");return fs(e,i),Object.setPrototypeOf(e,ut.prototype),e};function ut(i){return us(i)}Object.setPrototypeOf(ut.prototype,Function.prototype);for(let[i,e]of Object.entries(Se))it[i]={get(){let t=_t(this,Qt(e.open,e.close,this[nt]),this[ft]);return Object.defineProperty(this,i,{value:t}),t}};it.visible={get(){let i=_t(this,this[nt],!0);return Object.defineProperty(this,"visible",{value:i}),i}};var Jt=(i,e,t,...n)=>i==="rgb"?e==="ansi16m"?Se[t].ansi16m(...n):e==="ansi256"?Se[t].ansi256(Se.rgbToAnsi256(...n)):Se[t].ansi(Se.rgbToAnsi(...n)):i==="hex"?Jt("rgb",e,t,...Se.hexToRgb(...n)):Se[t][i](...n),hs=["rgb","hex","ansi256"];for(let i of hs){it[i]={get(){let{level:t}=this;return function(...n){let s=Qt(Jt(i,Bn[t],"color",...n),Se.color.close,this[nt]);return _t(this,s,this[ft])}}};let e="bg"+i[0].toUpperCase()+i.slice(1);it[e]={get(){let{level:t}=this;return function(...n){let s=Qt(Jt(i,Bn[t],"bgColor",...n),Se.bgColor.close,this[nt]);return _t(this,s,this[ft])}}}}var ds=Object.defineProperties(()=>{},{...it,level:{enumerable:!0,get(){return this[Kt].level},set(i){this[Kt].level=i}}}),Qt=(i,e,t)=>{let n,s;return t===void 0?(n=i,s=e):(n=t.openAll+i,s=e+t.closeAll),{open:i,close:e,openAll:n,closeAll:s,parent:t}},_t=(i,e,t)=>{let n=(...s)=>ps(n,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(n,ds),n[Kt]=i,n[nt]=e,n[ft]=t,n},ps=(i,e)=>{if(i.level<=0||!e)return i[ft]?"":e;let t=i[nt];if(t===void 0)return e;let{openAll:n,closeAll:s}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=Tn(e,t.close,t.open),t=t.parent;let r=e.indexOf(`
6
- `);return r!==-1&&(e=Ln(e,s,n,r)),n+e+s};Object.defineProperties(ut.prototype,it);var ms=ut(),Hr=ut({level:Un?Un.level:0});var Pe=ms;import{oraPromise as gs}from"ora";var zn,Vn=((zn=process==null?void 0:process.versions)==null?void 0:zn.node)!==void 0,bs={verbose:!1,log(...i){if(!this.verbose)return;let e=Pe.gray("[Log]");Vn?console.warn(e,...i):console.log(e,...i)},logPrefixed(i,...e){this.info(Pe.blue(`[${i}]`),...e)},info(...i){if(!this.verbose)return;let e=Pe.green("[Info]");Vn?console.warn(e,...i):console.info(e,...i)},infoPrefixed(i,...e){this.info(Pe.blue(`[${i}]`),...e)},async infoSpin(i,e){return gs(i,{prefixText:Pe.green("[Info]"),stream:process.stderr,text:e})},warn(...i){console.warn(Pe.yellow("[Warning]"),...i)},warnPrefixed(i,...e){this.warn(Pe.blue(`[${i}]`),...e)},error(...i){console.error(Pe.red("[Error]"),...i)},errorPrefixed(i,...e){this.error(Pe.blue(`[${i}]`),...e)}},G=bs;import{execa as Yn}from"execa";import Ct from"ffmpeg-static";import Gn from"node:fs/promises";import Zt from"node:path";import ys from"node:os";var Hn=ys.homedir();function st(i){if(typeof i!="string")throw new TypeError(`Expected a string, got ${typeof i}`);return Hn?i.replace(/^~(?=$|\/|\\)/,Hn):i}async function Xt(i){let e=st(i);return(await Gn.readdir(e)).filter(s=>{let r=Zt.extname(s);return[".mp4",".mov",".avi",".mkv"].includes(r)}).map(s=>Zt.join(e,s))}async function qn(i){if(Ct===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let{stderr:e,stdout:t}=await Yn(Ct,["-i",i,"-f","ffmetadata","-"]);return t.includes("creation_time")||e.includes("creation_time")}catch(e){throw new Error(`Failed to check metadata for: ${i}:
7
- ${String(e)}`)}}async function Kn(i){if(Ct===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let e=Zt.extname(i).slice(1),t=`${i.slice(0,Math.max(0,i.lastIndexOf(".")))}.temp.${e}`;await Yn(Ct,["-i",i,"-map_metadata","-1","-c:v","copy","-c:a","copy",t]),await Gn.rename(t,i)}catch(e){throw new Error(`Failed to strip metadata from: ${i}:
8
- ${String(e)}`)}}async function Jn(i,e={}){let{dryRun:t=!1,verbose:n=!1}=e,s=G.verbose;G.verbose=n;let r=[];for(let a of i)await qn(a)&&r.push(a);if(!t){G.info(`Found ${r.length} videos with metadata to strip`);for(let a of r)console.log(`Stripping metadata from: ${a}`),await Kn(a)}return G.verbose=s,r}import{BunnyCdnStream as Ps}from"bunnycdn-stream";import{hash as Is}from"hasha";import{readFile as js}from"node:fs/promises";import{rename as ws,writeFile as Os}from"node:fs/promises";import{basename as _s,dirname as Cs,join as xs}from"node:path";import{fileURLToPath as Es}from"node:url";function As(i){let e=i instanceof URL?Es(i):i.toString();return xs(Cs(e),`.${_s(e)}.tmp`)}async function Ss(i,e,t){for(let n=0;n<e;n++)try{return await i()}catch(s){if(n<e-1)await new Promise(r=>setTimeout(r,t));else throw s}}var xt=class{#e;#t;#n=!1;#s=null;#r=null;#o=null;#i=null;#a(e){return this.#i=e,this.#o||=new Promise((t,n)=>{this.#r=[t,n]}),new Promise((t,n)=>{var s;(s=this.#o)==null||s.then(t).catch(n)})}async#l(e){var t,n;this.#n=!0;try{await Os(this.#t,e,"utf-8"),await Ss(async()=>{await ws(this.#t,this.#e)},10,100),(t=this.#s)==null||t[0]()}catch(s){throw s instanceof Error&&((n=this.#s)==null||n[1](s)),s}finally{if(this.#n=!1,this.#s=this.#r,this.#r=this.#o=null,this.#i!==null){let s=this.#i;this.#i=null,await this.write(s)}}}constructor(e){this.#e=e,this.#t=As(e)}async write(e){return this.#n?this.#a(e):this.#l(e)}};var Et=class{#e;#t;constructor(e){this.#e=e,this.#t=new xt(e)}async read(){let e;try{e=await js(this.#e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}return e}write(e){return this.#t.write(e)}};var At=class{#e;#t;#n;constructor(e,{parse:t,stringify:n}){this.#e=new Et(e),this.#t=t,this.#n=n}async read(){let e=await this.#e.read();return e===null?null:this.#t(e)}write(e){return this.#e.write(this.#n(e))}};var St=class extends At{constructor(e){super(e,{parse:JSON.parse,stringify:t=>JSON.stringify(t,null,2)})}};var jt=class{#e=null;read(){return Promise.resolve(this.#e)}write(e){return this.#e=e,Promise.resolve()}};function Ms(i,e){if(i===void 0)throw new Error("lowdb: missing adapter");if(e===void 0)throw new Error("lowdb: missing default data")}var Mt=class{adapter;data;constructor(e,t){Ms(e,t),this.adapter=e,this.data=t}async read(){let e=await this.adapter.read();e&&(this.data=e)}async write(){this.data&&await this.adapter.write(this.data)}async update(e){e(this.data),await this.write()}};async function Qn(i,e){let t=process.env.NODE_ENV==="test"?new jt:new St(i),n=new Mt(t,e);return await n.read(),n}import{createReadStream as Zn}from"node:fs";import ht from"node:path";async function kt(i,e){let t=st(i),{credentials:n,dryRun:s=!1,service:r,stripMetadata:a=!0,verbose:c=!1}=e,g=G.verbose;G.verbose=c;let b=[],m=await Xt(t);G.info(`Found ${m.length} video files in directory "${i}"`);let h=a?await Jn(m,{dryRun:s,verbose:c}):[],d=await Qn(ht.join(t,".vidup-state.json"),{syncState:[]});d.data.syncState=d.data.syncState.filter(S=>m.includes(ht.join(t,S.filename)));for(let S of m){let A=ht.basename(S),T=await Is(S,{algorithm:"sha1"}),ce=d.data.syncState.find(oe=>oe.filename===A);ce?ce.localHash=T:d.data.syncState.push({filename:A,localHash:T,remoteHash:{}})}if(s||await d.write(),r!=="bunny")throw new Error(`Streaming service not yet implemented: ${r}`);let w=new Ps({apiKey:n.key,videoLibrary:n.library}),C=await w.listAllVideos();G.info(`Found ${C.length} video files on ${r} remote streaming service`);let _=C.filter(S=>{let A=d.data.syncState.find(T=>T.filename===S.title);return A!==void 0&&A.localHash===A.remoteHash[r]});for(let S of _)b.push({action:"Unchanged",localFile:S.title,remoteId:S.guid,stripMetadata:h.includes(S.title)});let p=d.data.syncState.filter(S=>!C.some(A=>A.title===S.filename));for(let S of p)b.push({action:"Created",localFile:S.filename,remoteId:"Not yet uploaded (Dry run)",stripMetadata:h.includes(S.filename)});let W=C.filter(S=>{let A=d.data.syncState.find(T=>T.filename===S.title);return A!==void 0&&A.localHash!==A.remoteHash[r]});for(let S of W)b.push({action:"Updated",localFile:S.title,remoteId:"Not yet uploaded (Dry run)",stripMetadata:h.includes(S.title)});let B=C.filter(S=>!d.data.syncState.some(A=>A.filename===S.title));for(let S of B)b.push({action:"Deleted",localFile:S.title,remoteId:S.guid,stripMetadata:h.includes(S.title)});if(!s){d.data.lastRun=new Date,await d.write(),G.info("Synchronizing...");for(let[S,A]of B.entries()){if(S===0&&G.info(`Deleting ${B.length} remote videos...`),!(await G.infoSpin(w.deleteVideo(A.guid),`Deleting remote video ${S+1}/${B.length}: ${A.title}`)).success)throw new Error(`Failed to delete remote video: ${A.title}`);d.data.lastUpdate=new Date,await d.write()}for(let[S,A]of p.entries()){S===0&&G.info(`Uploading ${p.length} new local videos...`);let T=Zn(ht.join(t,A.filename)),ce=await G.infoSpin(w.createAndUploadVideo(T,{title:A.filename}),`Uploading new video ${S+1}/${p.length}: ${A.filename}`);G.info(`Remote video ${S+1}/${p.length} created with GUID: ${ce.guid}`);let oe=d.data.syncState.find(he=>he.filename===A.filename);if(oe===void 0)throw new Error(`Failed to find state entry for: ${A.filename}`);oe.remoteHash[r]=A.localHash,d.data.lastUpdate=new Date,await d.write();let be=b.find(he=>he.localFile===A.filename);if(be===void 0)throw new Error(`Failed to find report entry for: ${A.filename}`);be.remoteId=ce.guid}for(let[S,A]of W.entries()){S===0&&(G.info(`Updating ${W.length} remote videos...`),G.warn("Bunny does not currently support updating videos in-place, so vidup will delete and re-uploading instead... this will change the video's GUID!"));let T=d.data.syncState.find(H=>H.filename===A.title);if(T===void 0)throw new Error(`Failed to find state entry for: ${A.title}`);if(!(await w.deleteVideo(A.guid)).success)throw new Error(`Failed to delete remote video before updating: ${A.title}`);let oe=Zn(ht.join(t,T.filename)),be=await G.infoSpin(w.createAndUploadVideo(oe,{title:T.filename}),`Updating remote video ${S+1}/${W.length}: ${A.title}`);G.info(`Updated remote video ${S+1}/${W.length} created with GUID: ${be.guid}`),T.remoteHash[r]=T.localHash,d.data.lastUpdate=new Date,await d.write();let he=b.find(H=>H.localFile===T.filename);if(he===void 0)throw new Error(`Failed to find report entry for: ${T.filename}`);he.remoteId=be.guid}G.info(`All ${m.length} videos are now in sync!`)}return G.verbose=g,b}var Xn=i=>Number.isFinite(i)?i:0;function vs(i){return{days:Math.trunc(i/864e5),hours:Math.trunc(i/36e5%24),minutes:Math.trunc(i/6e4%60),seconds:Math.trunc(i/1e3%60),milliseconds:Math.trunc(i%1e3),microseconds:Math.trunc(Xn(i*1e3)%1e3),nanoseconds:Math.trunc(Xn(i*1e6)%1e3)}}function $s(i){return{days:i/86400000n,hours:i/3600000n%24n,minutes:i/60000n%60n,seconds:i/1000n%60n,milliseconds:i%1000n,microseconds:0n,nanoseconds:0n}}function en(i){switch(typeof i){case"number":{if(Number.isFinite(i))return vs(i);break}case"bigint":return $s(i)}throw new TypeError("Expected a finite number or bigint")}var Ns=i=>i===0||i===0n,Fs=(i,e)=>e===1||e===1n?i:`${i}s`,Rs=1e-7,Ds=24n*60n*60n*1000n;function tn(i,e){let t=typeof i=="bigint";if(!t&&!Number.isFinite(i))throw new TypeError("Expected a finite number or bigint");e={...e},e.colonNotation&&(e.compact=!1,e.formatSubMilliseconds=!1,e.separateMilliseconds=!1,e.verbose=!1),e.compact&&(e.unitCount=1,e.secondsDecimalDigits=0,e.millisecondsDecimalDigits=0);let n=[],s=(b,m)=>{let h=Math.floor(b*10**m+Rs);return(Math.round(h)/10**m).toFixed(m)},r=(b,m,h,d)=>{if(!((n.length===0||!e.colonNotation)&&Ns(b)&&!(e.colonNotation&&h==="m"))){if(d=d??String(b),e.colonNotation){let w=d.includes(".")?d.split(".")[0].length:d.length,C=n.length>0?2:1;d="0".repeat(Math.max(0,C-w))+d}else d+=e.verbose?" "+Fs(m,b):h;n.push(d)}},a=en(i),c=BigInt(a.days);if(r(c/365n,"year","y"),r(c%365n,"day","d"),r(Number(a.hours),"hour","h"),r(Number(a.minutes),"minute","m"),e.separateMilliseconds||e.formatSubMilliseconds||!e.colonNotation&&i<1e3){let b=Number(a.seconds),m=Number(a.milliseconds),h=Number(a.microseconds),d=Number(a.nanoseconds);if(r(b,"second","s"),e.formatSubMilliseconds)r(m,"millisecond","ms"),r(h,"microsecond","\xB5s"),r(d,"nanosecond","ns");else{let w=m+h/1e3+d/1e6,C=typeof e.millisecondsDecimalDigits=="number"?e.millisecondsDecimalDigits:0,_=w>=1?Math.round(w):Math.ceil(w),p=C?w.toFixed(C):_;r(Number.parseFloat(p),"millisecond","ms",p)}}else{let b=(t?Number(i%Ds):i)/1e3%60,m=typeof e.secondsDecimalDigits=="number"?e.secondsDecimalDigits:1,h=s(b,m),d=e.keepDecimalsOnWholeSeconds?h:h.replace(/\.0+$/,"");r(Number.parseFloat(d),"second","s",d)}if(n.length===0)return"0"+(e.verbose?" milliseconds":"ms");let g=e.colonNotation?":":" ";return typeof e.unitCount=="number"&&(n=n.slice(0,Math.max(e.unitCount,1))),n.join(g)}import{notStrictEqual as ar,strictEqual as lr}from"assert";var Ts={right:Vs,center:zs},Ls=0,Pt=1,Ws=2,It=3,nn=class{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]=="string")return this.applyLayoutDSL(e[0]);let t=e.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]=="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
9
- `).map(s=>s.split(" ")),n=0;return t.forEach(s=>{s.length>1&&de.stringWidth(s[0])>n&&(n=Math.min(Math.floor(this.width*.5),de.stringWidth(s[0])))}),t.forEach(s=>{this.div(...s.map((r,a)=>({text:r.trim(),padding:this.measurePadding(r),width:a===0&&s.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=de.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach(t=>{this.rowToString(t,e)}),e.filter(t=>!t.hidden).map(t=>t.text).join(`
10
- `)}rowToString(e,t){return this.rasterize(e).forEach((n,s)=>{let r="";n.forEach((a,c)=>{let{width:g}=e[c],b=this.negatePadding(e[c]),m=a;if(b>de.stringWidth(a)&&(m+=" ".repeat(b-de.stringWidth(a))),e[c].align&&e[c].align!=="left"&&this.wrap){let d=Ts[e[c].align];m=d(m,b),de.stringWidth(m)<b&&(m+=" ".repeat((g||0)-de.stringWidth(m)-1))}let h=e[c].padding||[0,0,0,0];h[It]&&(r+=" ".repeat(h[It])),r+=kn(e[c],m,"| "),r+=m,r+=kn(e[c],m," |"),h[Pt]&&(r+=" ".repeat(h[Pt])),s===0&&t.length>0&&(r=this.renderInline(r,t[t.length-1]))}),t.push({text:r.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),s=n?n[0].length:0,r=t.text,a=de.stringWidth(r.trimRight());return t.span?this.wrap?s<a?e:(t.hidden=!0,r.trimRight()+" ".repeat(s-a)+e.trimLeft()):(t.hidden=!0,r+e):e}rasterize(e){let t=[],n=this.columnWidths(e),s;return e.forEach((r,a)=>{r.width=n[a],this.wrap?s=de.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
5
+ `,s)}while(n!==-1);return r+=i.slice(s),r}var{stdout:Un,stderr:Bn}=Tn,Kt=Symbol("GENERATOR"),nt=Symbol("STYLER"),ct=Symbol("IS_EMPTY"),zn=["ansi","ansi","ansi256","ansi16m"],it=Object.create(null),fs=(i,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=Un?Un.level:0;i.level=e.level===void 0?t:e.level};var us=i=>{let e=(...t)=>t.join(" ");return fs(e,i),Object.setPrototypeOf(e,ft.prototype),e};function ft(i){return us(i)}Object.setPrototypeOf(ft.prototype,Function.prototype);for(let[i,e]of Object.entries(Ee))it[i]={get(){let t=Ot(this,Qt(e.open,e.close,this[nt]),this[ct]);return Object.defineProperty(this,i,{value:t}),t}};it.visible={get(){let i=Ot(this,this[nt],!0);return Object.defineProperty(this,"visible",{value:i}),i}};var Jt=(i,e,t,...n)=>i==="rgb"?e==="ansi16m"?Ee[t].ansi16m(...n):e==="ansi256"?Ee[t].ansi256(Ee.rgbToAnsi256(...n)):Ee[t].ansi(Ee.rgbToAnsi(...n)):i==="hex"?Jt("rgb",e,t,...Ee.hexToRgb(...n)):Ee[t][i](...n),hs=["rgb","hex","ansi256"];for(let i of hs){it[i]={get(){let{level:t}=this;return function(...n){let s=Qt(Jt(i,zn[t],"color",...n),Ee.color.close,this[nt]);return Ot(this,s,this[ct])}}};let e="bg"+i[0].toUpperCase()+i.slice(1);it[e]={get(){let{level:t}=this;return function(...n){let s=Qt(Jt(i,zn[t],"bgColor",...n),Ee.bgColor.close,this[nt]);return Ot(this,s,this[ct])}}}}var ds=Object.defineProperties(()=>{},{...it,level:{enumerable:!0,get(){return this[Kt].level},set(i){this[Kt].level=i}}}),Qt=(i,e,t)=>{let n,s;return t===void 0?(n=i,s=e):(n=t.openAll+i,s=e+t.closeAll),{open:i,close:e,openAll:n,closeAll:s,parent:t}},Ot=(i,e,t)=>{let n=(...s)=>ps(n,s.length===1?""+s[0]:s.join(" "));return Object.setPrototypeOf(n,ds),n[Kt]=i,n[nt]=e,n[ct]=t,n},ps=(i,e)=>{if(i.level<=0||!e)return i[ct]?"":e;let t=i[nt];if(t===void 0)return e;let{openAll:n,closeAll:s}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=Ln(e,t.close,t.open),t=t.parent;let r=e.indexOf(`
6
+ `);return r!==-1&&(e=Wn(e,s,n,r)),n+e+s};Object.defineProperties(ft.prototype,it);var ms=ft(),Yr=ft({level:Bn?Bn.level:0});var je=ms;import{oraPromise as gs}from"ora";var Hn,Vn=((Hn=process==null?void 0:process.versions)==null?void 0:Hn.node)!==void 0,bs={verbose:!1,log(...i){if(!this.verbose)return;let e=je.gray("[Log]");Vn?console.warn(e,...i):console.log(e,...i)},logPrefixed(i,...e){this.info(je.blue(`[${i}]`),...e)},info(...i){if(!this.verbose)return;let e=je.green("[Info]");Vn?console.warn(e,...i):console.info(e,...i)},infoPrefixed(i,...e){this.info(je.blue(`[${i}]`),...e)},async infoSpin(i,e){return gs(i,{prefixText:je.green("[Info]"),stream:process.stderr,text:e})},warn(...i){console.warn(je.yellow("[Warning]"),...i)},warnPrefixed(i,...e){this.warn(je.blue(`[${i}]`),...e)},error(...i){console.error(je.red("[Error]"),...i)},errorPrefixed(i,...e){this.error(je.blue(`[${i}]`),...e)}},G=bs;import{execa as Gn}from"execa";import _t from"ffmpeg-static";import Yn from"node:fs/promises";import Zt from"node:path";async function Ct(i){return(await Yn.readdir(i)).filter(n=>{let s=Zt.extname(n);return[".mp4",".mov",".avi",".mkv"].includes(s)}).map(n=>Zt.join(i,n))}async function qn(i){if(_t===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let{stderr:e,stdout:t}=await Gn(_t,["-i",i,"-f","ffmetadata","-"]);return t.includes("creation_time")||e.includes("creation_time")}catch(e){throw new Error(`Failed to check metadata for: ${i}:
7
+ ${String(e)}`)}}async function Kn(i){if(_t===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let e=Zt.extname(i).slice(1),t=`${i.slice(0,Math.max(0,i.lastIndexOf(".")))}.temp.${e}`;await Gn(_t,["-i",i,"-map_metadata","-1","-c:v","copy","-c:a","copy",t]),await Yn.rename(t,i)}catch(e){throw new Error(`Failed to strip metadata from: ${i}:
8
+ ${String(e)}`)}}async function Xt(i,e={}){let{dryRun:t=!1,verbose:n=!1}=e,s=await Ct(i);return ys(s,{dryRun:t,verbose:n})}async function ys(i,e={}){let{dryRun:t=!1,verbose:n=!1}=e,s=G.verbose;G.verbose=n;let r=[];for(let a of i)await qn(a)&&r.push(a);if(!t){G.info(`Found ${r.length} videos with metadata to strip`);for(let a of r)console.log(`Stripping metadata from: ${a}`),await Kn(a)}return G.verbose=s,r}import{BunnyCdnStream as Ps}from"bunnycdn-stream";import{hash as Is}from"hasha";import{readFile as js}from"node:fs/promises";import{rename as ws,writeFile as Os}from"node:fs/promises";import{basename as _s,dirname as Cs,join as xs}from"node:path";import{fileURLToPath as Es}from"node:url";function As(i){let e=i instanceof URL?Es(i):i.toString();return xs(Cs(e),`.${_s(e)}.tmp`)}async function Ss(i,e,t){for(let n=0;n<e;n++)try{return await i()}catch(s){if(n<e-1)await new Promise(r=>setTimeout(r,t));else throw s}}var xt=class{#e;#t;#n=!1;#s=null;#r=null;#o=null;#i=null;#a(e){return this.#i=e,this.#o||=new Promise((t,n)=>{this.#r=[t,n]}),new Promise((t,n)=>{var s;(s=this.#o)==null||s.then(t).catch(n)})}async#l(e){var t,n;this.#n=!0;try{await Os(this.#t,e,"utf-8"),await Ss(async()=>{await ws(this.#t,this.#e)},10,100),(t=this.#s)==null||t[0]()}catch(s){throw s instanceof Error&&((n=this.#s)==null||n[1](s)),s}finally{if(this.#n=!1,this.#s=this.#r,this.#r=this.#o=null,this.#i!==null){let s=this.#i;this.#i=null,await this.write(s)}}}constructor(e){this.#e=e,this.#t=As(e)}async write(e){return this.#n?this.#a(e):this.#l(e)}};var Et=class{#e;#t;constructor(e){this.#e=e,this.#t=new xt(e)}async read(){let e;try{e=await js(this.#e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw t}return e}write(e){return this.#t.write(e)}};var At=class{#e;#t;#n;constructor(e,{parse:t,stringify:n}){this.#e=new Et(e),this.#t=t,this.#n=n}async read(){let e=await this.#e.read();return e===null?null:this.#t(e)}write(e){return this.#e.write(this.#n(e))}};var St=class extends At{constructor(e){super(e,{parse:JSON.parse,stringify:t=>JSON.stringify(t,null,2)})}};var jt=class{#e=null;read(){return Promise.resolve(this.#e)}write(e){return this.#e=e,Promise.resolve()}};function Ms(i,e){if(i===void 0)throw new Error("lowdb: missing adapter");if(e===void 0)throw new Error("lowdb: missing default data")}var Mt=class{adapter;data;constructor(e,t){Ms(e,t),this.adapter=e,this.data=t}async read(){let e=await this.adapter.read();e&&(this.data=e)}async write(){this.data&&await this.adapter.write(this.data)}async update(e){e(this.data),await this.write()}};async function Jn(i,e){let t=process.env.NODE_ENV==="test"?new jt:new St(i),n=new Mt(t,e);return await n.read(),n}import{createReadStream as Qn}from"node:fs";import ut from"node:path";async function kt(i,e){let{credentials:t,dryRun:n=!1,service:s,verbose:r=!1}=e,a=G.verbose;G.verbose=r;let c=[],b=await Ct(i);G.info(`Found ${b.length} video files in directory "${i}"`);let g=await Jn(ut.join(i,".vidup-state.json"),{syncState:[]});g.data.syncState=g.data.syncState.filter(f=>b.includes(ut.join(i,f.filename)));for(let f of b){let x=ut.basename(f),N=await Is(f,{algorithm:"sha1"}),U=g.data.syncState.find(W=>W.filename===x);U?U.localHash=N:g.data.syncState.push({filename:x,localHash:N,remoteHash:{}})}if(n||await g.write(),s!=="bunny")throw new Error(`Streaming service not yet implemented: ${s}`);let p=new Ps({apiKey:t.key,videoLibrary:t.library}),u=await p.listAllVideos();G.info(`Found ${u.length} video files on ${s} remote streaming service`);let m=u.filter(f=>{let x=g.data.syncState.find(N=>N.filename===f.title);return x!==void 0&&x.localHash===x.remoteHash[s]});for(let f of m)c.push({action:"None",localFile:f.title,remoteId:f.guid});let w=g.data.syncState.filter(f=>!u.some(x=>x.title===f.filename));for(let f of w)c.push({action:"Create",localFile:f.filename,remoteId:"Not yet uploaded (Dry run)"});let C=u.filter(f=>{let x=g.data.syncState.find(N=>N.filename===f.title);return x!==void 0&&x.localHash!==x.remoteHash[s]});for(let f of C)c.push({action:"Update",localFile:f.title,remoteId:"Not yet uploaded (Dry run)"});let O=u.filter(f=>!g.data.syncState.some(x=>x.filename===f.title));for(let f of O)c.push({action:"Delete",localFile:f.title,remoteId:f.guid});if(!n){g.data.lastRun=new Date,await g.write(),G.info("Synchronizing...");for(let[f,x]of O.entries()){if(f===0&&G.info(`Deleting ${O.length} remote videos...`),!(await G.infoSpin(p.deleteVideo(x.guid),`Deleting remote video ${f+1}/${O.length}: ${x.title}`)).success)throw new Error(`Failed to delete remote video: ${x.title}`);g.data.lastUpdate=new Date,await g.write()}for(let[f,x]of w.entries()){f===0&&G.info(`Uploading ${w.length} new local videos...`);let N=Qn(ut.join(i,x.filename)),U=await G.infoSpin(p.createAndUploadVideo(N,{title:x.filename}),`Uploading new video ${f+1}/${w.length}: ${x.filename}`);G.info(`Remote video ${f+1}/${w.length} created with GUID: ${U.guid}`);let W=g.data.syncState.find(le=>le.filename===x.filename);if(W===void 0)throw new Error(`Failed to find state entry for: ${x.filename}`);W.remoteHash[s]=x.localHash,g.data.lastUpdate=new Date,await g.write();let z=c.find(le=>le.localFile===x.filename);if(z===void 0)throw new Error(`Failed to find report entry for: ${x.filename}`);z.remoteId=U.guid}for(let[f,x]of C.entries()){f===0&&(G.info(`Updating ${C.length} remote videos...`),G.warn("Bunny does not currently support updating videos in-place, so vidup will delete and re-uploading instead... this will change the video's GUID!"));let N=g.data.syncState.find(ce=>ce.filename===x.title);if(N===void 0)throw new Error(`Failed to find state entry for: ${x.title}`);if(!(await p.deleteVideo(x.guid)).success)throw new Error(`Failed to delete remote video before updating: ${x.title}`);let W=Qn(ut.join(i,N.filename)),z=await G.infoSpin(p.createAndUploadVideo(W,{title:N.filename}),`Updating remote video ${f+1}/${C.length}: ${x.title}`);G.info(`Updated remote video ${f+1}/${C.length} created with GUID: ${z.guid}`),N.remoteHash[s]=N.localHash,g.data.lastUpdate=new Date,await g.write();let le=c.find(ce=>ce.localFile===N.filename);if(le===void 0)throw new Error(`Failed to find report entry for: ${N.filename}`);le.remoteId=z.guid}G.info(`All ${b.length} videos are now in sync!`)}return G.verbose=a,c}import $r from"node:path";var Zn=i=>Number.isFinite(i)?i:0;function vs(i){return{days:Math.trunc(i/864e5),hours:Math.trunc(i/36e5%24),minutes:Math.trunc(i/6e4%60),seconds:Math.trunc(i/1e3%60),milliseconds:Math.trunc(i%1e3),microseconds:Math.trunc(Zn(i*1e3)%1e3),nanoseconds:Math.trunc(Zn(i*1e6)%1e3)}}function $s(i){return{days:i/86400000n,hours:i/3600000n%24n,minutes:i/60000n%60n,seconds:i/1000n%60n,milliseconds:i%1000n,microseconds:0n,nanoseconds:0n}}function en(i){switch(typeof i){case"number":{if(Number.isFinite(i))return vs(i);break}case"bigint":return $s(i)}throw new TypeError("Expected a finite number or bigint")}var Ns=i=>i===0||i===0n,Fs=(i,e)=>e===1||e===1n?i:`${i}s`,Rs=1e-7,Ds=24n*60n*60n*1000n;function tn(i,e){let t=typeof i=="bigint";if(!t&&!Number.isFinite(i))throw new TypeError("Expected a finite number or bigint");e={...e},e.colonNotation&&(e.compact=!1,e.formatSubMilliseconds=!1,e.separateMilliseconds=!1,e.verbose=!1),e.compact&&(e.unitCount=1,e.secondsDecimalDigits=0,e.millisecondsDecimalDigits=0);let n=[],s=(g,p)=>{let u=Math.floor(g*10**p+Rs);return(Math.round(u)/10**p).toFixed(p)},r=(g,p,u,m)=>{if(!((n.length===0||!e.colonNotation)&&Ns(g)&&!(e.colonNotation&&u==="m"))){if(m=m??String(g),e.colonNotation){let w=m.includes(".")?m.split(".")[0].length:m.length,C=n.length>0?2:1;m="0".repeat(Math.max(0,C-w))+m}else m+=e.verbose?" "+Fs(p,g):u;n.push(m)}},a=en(i),c=BigInt(a.days);if(r(c/365n,"year","y"),r(c%365n,"day","d"),r(Number(a.hours),"hour","h"),r(Number(a.minutes),"minute","m"),e.separateMilliseconds||e.formatSubMilliseconds||!e.colonNotation&&i<1e3){let g=Number(a.seconds),p=Number(a.milliseconds),u=Number(a.microseconds),m=Number(a.nanoseconds);if(r(g,"second","s"),e.formatSubMilliseconds)r(p,"millisecond","ms"),r(u,"microsecond","\xB5s"),r(m,"nanosecond","ns");else{let w=p+u/1e3+m/1e6,C=typeof e.millisecondsDecimalDigits=="number"?e.millisecondsDecimalDigits:0,O=w>=1?Math.round(w):Math.ceil(w),f=C?w.toFixed(C):O;r(Number.parseFloat(f),"millisecond","ms",f)}}else{let g=(t?Number(i%Ds):i)/1e3%60,p=typeof e.secondsDecimalDigits=="number"?e.secondsDecimalDigits:1,u=s(g,p),m=e.keepDecimalsOnWholeSeconds?u:u.replace(/\.0+$/,"");r(Number.parseFloat(m),"second","s",m)}if(n.length===0)return"0"+(e.verbose?" milliseconds":"ms");let b=e.colonNotation?":":" ";return typeof e.unitCount=="number"&&(n=n.slice(0,Math.max(e.unitCount,1))),n.join(b)}import Ts from"node:os";var Xn=Ts.homedir();function nn(i){if(typeof i!="string")throw new TypeError(`Expected a string, got ${typeof i}`);return Xn?i.replace(/^~(?=$|\/|\\)/,Xn):i}import{notStrictEqual as lr,strictEqual as cr}from"assert";var Ls={right:Vs,center:Hs},Ws=0,Pt=1,Us=2,It=3,sn=class{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]=="string")return this.applyLayoutDSL(e[0]);let t=e.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]=="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
9
+ `).map(s=>s.split(" ")),n=0;return t.forEach(s=>{s.length>1&&he.stringWidth(s[0])>n&&(n=Math.min(Math.floor(this.width*.5),he.stringWidth(s[0])))}),t.forEach(s=>{this.div(...s.map((r,a)=>({text:r.trim(),padding:this.measurePadding(r),width:a===0&&s.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=he.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach(t=>{this.rowToString(t,e)}),e.filter(t=>!t.hidden).map(t=>t.text).join(`
10
+ `)}rowToString(e,t){return this.rasterize(e).forEach((n,s)=>{let r="";n.forEach((a,c)=>{let{width:b}=e[c],g=this.negatePadding(e[c]),p=a;if(g>he.stringWidth(a)&&(p+=" ".repeat(g-he.stringWidth(a))),e[c].align&&e[c].align!=="left"&&this.wrap){let m=Ls[e[c].align];p=m(p,g),he.stringWidth(p)<g&&(p+=" ".repeat((b||0)-he.stringWidth(p)-1))}let u=e[c].padding||[0,0,0,0];u[It]&&(r+=" ".repeat(u[It])),r+=kn(e[c],p,"| "),r+=p,r+=kn(e[c],p," |"),u[Pt]&&(r+=" ".repeat(u[Pt])),s===0&&t.length>0&&(r=this.renderInline(r,t[t.length-1]))}),t.push({text:r.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),s=n?n[0].length:0,r=t.text,a=he.stringWidth(r.trimRight());return t.span?this.wrap?s<a?e:(t.hidden=!0,r.trimRight()+" ".repeat(s-a)+e.trimLeft()):(t.hidden=!0,r+e):e}rasterize(e){let t=[],n=this.columnWidths(e),s;return e.forEach((r,a)=>{r.width=n[a],this.wrap?s=he.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
11
11
  `):s=r.text.split(`
12
- `),r.border&&(s.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(s.unshift(...new Array(r.padding[Ls]||0).fill("")),s.push(...new Array(r.padding[Ws]||0).fill(""))),s.forEach((c,g)=>{t[g]||t.push([]);let b=t[g];for(let m=0;m<a;m++)b[m]===void 0&&b.push("");b.push(c)})}),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[It]||0)+(e.padding[Pt]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map(a=>a.width||de.stringWidth(a.text));let t=e.length,n=this.width,s=e.map(a=>{if(a.width)return t--,n-=a.width,a.width}),r=t?Math.floor(n/t):0;return s.map((a,c)=>a===void 0?Math.max(r,Us(e[c])):a)}};function kn(i,e,t){return i.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?t:" ":""}function Us(i){let e=i.padding||[],t=1+(e[It]||0)+(e[Pt]||0);return i.border?t+4:t}function Bs(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Vs(i,e){i=i.trim();let t=de.stringWidth(i);return t<e?" ".repeat(e-t)+i:i}function zs(i,e){i=i.trim();let t=de.stringWidth(i);return t>=e?i:" ".repeat(e-t>>1)+i}var de;function ei(i,e){return de=e,new nn({width:(i==null?void 0:i.width)||Bs(),wrap:i==null?void 0:i.wrap})}var ti=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function sn(i){return i.replace(ti,"")}function ni(i,e){let[t,n]=i.match(ti)||["",""];i=sn(i);let s="";for(let r=0;r<i.length;r++)r!==0&&r%e===0&&(s+=`
13
- `),s+=i.charAt(r);return t&&n&&(s=`${t}${s}${n}`),s}function rn(i){return ei(i,{stringWidth:e=>[...e].length,stripAnsi:sn,wrap:ni})}import{dirname as ii,resolve as si}from"path";import{readdirSync as Hs,statSync as Ys}from"fs";function ri(i,e){let t=si(".",i),n;for(Ys(t).isDirectory()||(t=ii(t));;){if(n=e(t,Hs(t)),n)return si(t,n);if(t=ii(n=t),n===t)break}}import{inspect as cr}from"util";import{readFileSync as fr}from"fs";import{fileURLToPath as ur}from"url";import{format as Ks}from"util";import{normalize as Js,resolve as Qs}from"path";function ze(i){if(i!==i.toLowerCase()&&i!==i.toUpperCase()||(i=i.toLowerCase()),i.indexOf("-")===-1&&i.indexOf("_")===-1)return i;{let t="",n=!1,s=i.match(/^-+/);for(let r=s?s[0].length:0;r<i.length;r++){let a=i.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(t+=a)}return t}}function vt(i,e){let t=i.toLowerCase();e=e||"-";let n="";for(let s=0;s<i.length;s++){let r=t.charAt(s),a=i.charAt(s);r!==a&&s>0?n+=`${e}${t.charAt(s)}`:n+=a}return n}function $t(i){return i==null?!1:typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^0[^.]/.test(i)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}function oi(i){if(Array.isArray(i))return i.map(a=>typeof a!="string"?a+"":a);i=i.trim();let e=0,t=null,n=null,s=null,r=[];for(let a=0;a<i.length;a++){if(t=n,n=i.charAt(a),n===" "&&!s){t!==" "&&e++;continue}n===s?s=null:(n==="'"||n==='"')&&!s&&(s=n),r[e]||(r[e]=""),r[e]+=n}return r}var we;(function(i){i.BOOLEAN="boolean",i.STRING="string",i.NUMBER="number",i.ARRAY="array"})(we||(we={}));var Fe,Nt=class{constructor(e){Fe=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),s=oi(e),r=typeof e=="string",a=Gs(Object.assign(Object.create(null),n.alias)),c=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),g=Object.assign(Object.create(null),n.default),b=n.configObjects||[],m=n.envPrefix,h=c["populate--"],d=h?"--":"_",w=Object.create(null),C=Object.create(null),_=n.__||Fe.format,p={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},W=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,B=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let u=typeof l=="object"?l.key:l,O=Object.keys(l).map(function(y){return{boolean:"bools",string:"strings",number:"numbers"}[y]}).filter(Boolean).pop();O&&(p[O][u]=!0),p.arrays[u]=!0,p.keys.push(u)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){p.bools[l]=!0,p.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){p.strings[l]=!0,p.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){p.numbers[l]=!0,p.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){p.counts[l]=!0,p.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){p.normalize[l]=!0,p.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,u])=>{typeof u=="number"&&(p.nargs[l]=u,p.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,u])=>{typeof u=="function"&&(p.coercions[l]=u,p.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){p.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,u])=>{(typeof u=="boolean"||typeof u=="function")&&(p.configs[l]=u)})),Ve(n.key,a,n.default,p.arrays),Object.keys(g).forEach(function(l){(p.aliases[l]||[]).forEach(function(u){g[u]=g[l]})});let S=null;wt();let A=[],T=Object.assign(Object.create(null),{_:[]}),ce={};for(let l=0;l<s.length;l++){let u=s[l],O=u.replace(/^-{3,}/,"---"),y,f,I,E,N,ae;if(u!=="--"&&/^-/.test(u)&&k(u))oe(u);else if(O.match(/^---+(=|$)/)){oe(u);continue}else if(u.match(/^--.+=/)||!c["short-option-groups"]&&u.match(/^-.+=/))E=u.match(/^--?([^=]+)=([\s\S]*)$/),E!==null&&Array.isArray(E)&&E.length>=3&&(R(E[1],p.arrays)?l=he(l,E[1],s,E[2]):R(E[1],p.nargs)!==!1?l=be(l,E[1],s,E[2]):H(E[1],E[2],!0));else if(u.match(B)&&c["boolean-negation"])E=u.match(B),E!==null&&Array.isArray(E)&&E.length>=2&&(f=E[1],H(f,R(f,p.arrays)?[!1]:!1));else if(u.match(/^--.+/)||!c["short-option-groups"]&&u.match(/^-[^-]+/))E=u.match(/^--?(.+)/),E!==null&&Array.isArray(E)&&E.length>=2&&(f=E[1],R(f,p.arrays)?l=he(l,f,s):R(f,p.nargs)!==!1?l=be(l,f,s):(N=s[l+1],N!==void 0&&(!N.match(/^-/)||N.match(W))&&!R(f,p.bools)&&!R(f,p.counts)||/^(true|false)$/.test(N)?(H(f,N),l++):H(f,ee(f))));else if(u.match(/^-.\..+=/))E=u.match(/^-([^=]+)=([\s\S]*)$/),E!==null&&Array.isArray(E)&&E.length>=3&&H(E[1],E[2]);else if(u.match(/^-.\..+/)&&!u.match(W))N=s[l+1],E=u.match(/^-(.\..+)/),E!==null&&Array.isArray(E)&&E.length>=2&&(f=E[1],N!==void 0&&!N.match(/^-/)&&!R(f,p.bools)&&!R(f,p.counts)?(H(f,N),l++):H(f,ee(f)));else if(u.match(/^-[^-]+/)&&!u.match(W)){I=u.slice(1,-1).split(""),y=!1;for(let fe=0;fe<I.length;fe++){if(N=u.slice(fe+2),I[fe+1]&&I[fe+1]==="="){ae=u.slice(fe+3),f=I[fe],R(f,p.arrays)?l=he(l,f,s,ae):R(f,p.nargs)!==!1?l=be(l,f,s,ae):H(f,ae),y=!0;break}if(N==="-"){H(I[fe],N);continue}if(/[A-Za-z]/.test(I[fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(N)&&R(N,p.bools)===!1){H(I[fe],N),y=!0;break}if(I[fe+1]&&I[fe+1].match(/\W/)){H(I[fe],N),y=!0;break}else H(I[fe],ee(I[fe]))}f=u.slice(-1)[0],!y&&f!=="-"&&(R(f,p.arrays)?l=he(l,f,s):R(f,p.nargs)!==!1?l=be(l,f,s):(N=s[l+1],N!==void 0&&(!/^(-|--)[^-]/.test(N)||N.match(W))&&!R(f,p.bools)&&!R(f,p.counts)||/^(true|false)$/.test(N)?(H(f,N),l++):H(f,ee(f))))}else if(u.match(/^-[0-9]$/)&&u.match(W)&&R(u.slice(1),p.bools))f=u.slice(1),H(f,ee(f));else if(u==="--"){A=s.slice(l+1);break}else if(c["halt-at-non-option"]){A=s.slice(l);break}else oe(u)}z(T,!0),z(T,!1),U(T),se(),Z(T,p.aliases,g,!0),re(T),c["set-placeholder-key"]&&Be(T),Object.keys(p.counts).forEach(function(l){$e(T,l.split("."))||H(l,0)}),h&&A.length&&(T[d]=[]),A.forEach(function(l){T[d].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(T).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete T[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete T[l.split(".").map(u=>ze(u)).join(".")],delete T[l]});function oe(l){let u=P("_",l);(typeof u=="string"||typeof u=="number")&&T._.push(u)}function be(l,u,O,y){let f,I=R(u,p.nargs);if(I=typeof I!="number"||isNaN(I)?1:I,I===0)return Ae(y)||(S=Error(_("Argument unexpected for: %s",u))),H(u,ee(u)),l;let E=Ae(y)?0:1;if(c["nargs-eats-options"])O.length-(l+1)+E<I&&(S=Error(_("Not enough arguments following: %s",u))),E=I;else{for(f=l+1;f<O.length&&(!O[f].match(/^-[^0-9]/)||O[f].match(W)||k(O[f]));f++)E++;E<I&&(S=Error(_("Not enough arguments following: %s",u)))}let N=Math.min(E,I);for(!Ae(y)&&N>0&&(H(u,y),N--),f=l+1;f<N+l+1;f++)H(u,O[f]);return l+N}function he(l,u,O,y){let f=[],I=y||O[l+1],E=R(u,p.nargs);if(R(u,p.bools)&&!/^(true|false)$/.test(I))f.push(!0);else if(Ae(I)||Ae(y)&&/^-/.test(I)&&!W.test(I)&&!k(I)){if(g[u]!==void 0){let N=g[u];f=Array.isArray(N)?N:[N]}}else{Ae(y)||f.push(x(u,y,!0));for(let N=l+1;N<O.length&&!(!c["greedy-arrays"]&&f.length>0||E&&typeof E=="number"&&f.length>=E||(I=O[N],/^-/.test(I)&&!W.test(I)&&!k(I)));N++)l=N,f.push(x(u,I,r))}return typeof E=="number"&&(E&&f.length<E||isNaN(E)&&f.length===0)&&(S=Error(_("Not enough arguments following: %s",u))),H(u,f),l}function H(l,u,O=r){if(/-/.test(l)&&c["camel-case-expansion"]){let I=l.split(".").map(function(E){return ze(E)}).join(".");v(l,I)}let y=x(l,u,O),f=l.split(".");Ne(T,f,y),p.aliases[l]&&p.aliases[l].forEach(function(I){let E=I.split(".");Ne(T,E,y)}),f.length>1&&c["dot-notation"]&&(p.aliases[f[0]]||[]).forEach(function(I){let E=I.split("."),N=[].concat(f);N.shift(),E=E.concat(N),(p.aliases[l]||[]).includes(E.join("."))||Ne(T,E,y)}),R(l,p.normalize)&&!R(l,p.arrays)&&[l].concat(p.aliases[l]||[]).forEach(function(E){Object.defineProperty(ce,E,{enumerable:!0,get(){return u},set(N){u=typeof N=="string"?Fe.normalize(N):N}})})}function v(l,u){p.aliases[l]&&p.aliases[l].length||(p.aliases[l]=[u],w[u]=!0),p.aliases[u]&&p.aliases[u].length||v(u,l)}function x(l,u,O){O&&(u=qs(u)),(R(l,p.bools)||R(l,p.counts))&&typeof u=="string"&&(u=u==="true");let y=Array.isArray(u)?u.map(function(f){return P(l,f)}):P(l,u);return R(l,p.counts)&&(Ae(y)||typeof y=="boolean")&&(y=on()),R(l,p.normalize)&&R(l,p.arrays)&&(Array.isArray(u)?y=u.map(f=>Fe.normalize(f)):y=Fe.normalize(u)),y}function P(l,u){return!c["parse-positional-numbers"]&&l==="_"||!R(l,p.strings)&&!R(l,p.bools)&&!Array.isArray(u)&&($t(u)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${u}`)))||!Ae(u)&&R(l,p.numbers))&&(u=Number(u)),u}function U(l){let u=Object.create(null);Z(u,p.aliases,g),Object.keys(p.configs).forEach(function(O){let y=l[O]||u[O];if(y)try{let f=null,I=Fe.resolve(Fe.cwd(),y),E=p.configs[O];if(typeof E=="function"){try{f=E(I)}catch(N){f=N}if(f instanceof Error){S=f;return}}else f=Fe.require(I);Y(f)}catch(f){f.name==="PermissionDenied"?S=f:l[O]&&(S=Error(_("Invalid JSON config file: %s",y)))}})}function Y(l,u){Object.keys(l).forEach(function(O){let y=l[O],f=u?u+"."+O:O;typeof y=="object"&&y!==null&&!Array.isArray(y)&&c["dot-notation"]?Y(y,f):(!$e(T,f.split("."))||R(f,p.arrays)&&c["combine-arrays"])&&H(f,y)})}function se(){typeof b<"u"&&b.forEach(function(l){Y(l)})}function z(l,u){if(typeof m>"u")return;let O=typeof m=="string"?m:"",y=Fe.env();Object.keys(y).forEach(function(f){if(O===""||f.lastIndexOf(O,0)===0){let I=f.split("__").map(function(E,N){return N===0&&(E=E.substring(O.length)),ze(E)});(u&&p.configs[I.join(".")]||!u)&&!$e(l,I)&&H(I.join("."),y[f])}})}function re(l){let u,O=new Set;Object.keys(l).forEach(function(y){if(!O.has(y)&&(u=R(y,p.coercions),typeof u=="function"))try{let f=P(y,u(l[y]));[].concat(p.aliases[y]||[],y).forEach(I=>{O.add(I),l[I]=f})}catch(f){S=f}})}function Be(l){return p.keys.forEach(u=>{~u.indexOf(".")||typeof l[u]>"u"&&(l[u]=void 0)}),l}function Z(l,u,O,y=!1){Object.keys(O).forEach(function(f){$e(l,f.split("."))||(Ne(l,f.split("."),O[f]),y&&(C[f]=!0),(u[f]||[]).forEach(function(I){$e(l,I.split("."))||Ne(l,I.split("."),O[f])}))})}function $e(l,u){let O=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(f){O=O[f]||{}});let y=u[u.length-1];return typeof O!="object"?!1:y in O}function Ne(l,u,O){let y=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(ae){ae=ai(ae),typeof y=="object"&&y[ae]===void 0&&(y[ae]={}),typeof y[ae]!="object"||Array.isArray(y[ae])?(Array.isArray(y[ae])?y[ae].push({}):y[ae]=[y[ae],{}],y=y[ae][y[ae].length-1]):y=y[ae]});let f=ai(u[u.length-1]),I=R(u.join("."),p.arrays),E=Array.isArray(O),N=c["duplicate-arguments-array"];!N&&R(f,p.nargs)&&(N=!0,(!Ae(y[f])&&p.nargs[f]===1||Array.isArray(y[f])&&y[f].length===p.nargs[f])&&(y[f]=void 0)),O===on()?y[f]=on(y[f]):Array.isArray(y[f])?N&&I&&E?y[f]=c["flatten-duplicate-arrays"]?y[f].concat(O):(Array.isArray(y[f][0])?y[f]:[y[f]]).concat([O]):!N&&!!I==!!E?y[f]=O:y[f]=y[f].concat([O]):y[f]===void 0&&I?y[f]=E?O:[O]:N&&!(y[f]===void 0||R(f,p.counts)||R(f,p.bools))?y[f]=[y[f],O]:y[f]=O}function Ve(...l){l.forEach(function(u){Object.keys(u||{}).forEach(function(O){p.aliases[O]||(p.aliases[O]=[].concat(a[O]||[]),p.aliases[O].concat(O).forEach(function(y){if(/-/.test(y)&&c["camel-case-expansion"]){let f=ze(y);f!==O&&p.aliases[O].indexOf(f)===-1&&(p.aliases[O].push(f),w[f]=!0)}}),p.aliases[O].concat(O).forEach(function(y){if(y.length>1&&/[A-Z]/.test(y)&&c["camel-case-expansion"]){let f=vt(y,"-");f!==O&&p.aliases[O].indexOf(f)===-1&&(p.aliases[O].push(f),w[f]=!0)}}),p.aliases[O].forEach(function(y){p.aliases[y]=[O].concat(p.aliases[O].filter(function(f){return y!==f}))}))})})}function R(l,u){let O=[].concat(p.aliases[l]||[],l),y=Object.keys(u),f=O.find(I=>y.includes(I));return f?u[f]:!1}function Gt(l){let u=Object.keys(p);return[].concat(u.map(y=>p[y])).some(function(y){return Array.isArray(y)?y.includes(l):y[l]})}function F(l,...u){return[].concat(...u).some(function(y){let f=l.match(y);return f&&Gt(f[1])})}function J(l){if(l.match(W)||!l.match(/^-[^-]+/))return!1;let u=!0,O,y=l.slice(1).split("");for(let f=0;f<y.length;f++){if(O=l.slice(f+2),!Gt(y[f])){u=!1;break}if(y[f+1]&&y[f+1]==="="||O==="-"||/[A-Za-z]/.test(y[f])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)||y[f+1]&&y[f+1].match(/\W/))break}return u}function k(l){return c["unknown-options-as-args"]&&V(l)}function V(l){return l=l.replace(/^-{3,}/,"--"),l.match(W)||J(l)?!1:!F(l,/^-+([^=]+?)=[\s\S]*$/,B,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function ee(l){return!R(l,p.bools)&&!R(l,p.counts)&&`${l}`in g?g[l]:ne(Ee(l))}function ne(l){return{[we.BOOLEAN]:!0,[we.STRING]:"",[we.NUMBER]:void 0,[we.ARRAY]:[]}[l]}function Ee(l){let u=we.BOOLEAN;return R(l,p.strings)?u=we.STRING:R(l,p.numbers)?u=we.NUMBER:R(l,p.bools)?u=we.BOOLEAN:R(l,p.arrays)&&(u=we.ARRAY),u}function Ae(l){return l===void 0}function wt(){Object.keys(p.counts).find(l=>R(l,p.arrays)?(S=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):R(l,p.nargs)?(S=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},p.aliases),argv:Object.assign(ce,T),configuration:c,defaulted:Object.assign({},C),error:S,newAliases:Object.assign({},w)}}};function Gs(i){let e=[],t=Object.create(null),n=!0;for(Object.keys(i).forEach(function(s){e.push([].concat(i[s],s))});n;){n=!1;for(let s=0;s<e.length;s++)for(let r=s+1;r<e.length;r++)if(e[s].filter(function(c){return e[r].indexOf(c)!==-1}).length){e[s]=e[s].concat(e[r]),e.splice(r,1),n=!0;break}}return e.forEach(function(s){s=s.filter(function(a,c,g){return g.indexOf(a)===c});let r=s.pop();r!==void 0&&typeof r=="string"&&(t[r]=s)}),t}function on(i){return i!==void 0?i+1:1}function ai(i){return i==="__proto__"?"___proto___":i}function qs(i){return typeof i=="string"&&(i[0]==="'"||i[0]==='"')&&i[i.length-1]===i[0]?i.substring(1,i.length-1):i}import{readFileSync as Zs}from"fs";var an,ln,cn,li=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,ci=(ln=(an=process==null?void 0:process.versions)===null||an===void 0?void 0:an.node)!==null&&ln!==void 0?ln:(cn=process==null?void 0:process.version)===null||cn===void 0?void 0:cn.slice(1);if(ci&&Number(ci.match(/^([^.]+)/)[1])<li)throw Error(`yargs parser supports a minimum Node.js version of ${li}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var Xs=process?process.env:{},fi=new Nt({cwd:process.cwd,env:()=>Xs,format:Ks,normalize:Js,resolve:Qs,require:i=>{if(typeof Me<"u")return Me(i);if(i.match(/\.json$/))return JSON.parse(Zs(i,"utf8"));throw Error("only .json config files are supported in ESM")}}),dt=function(e,t){return fi.parse(e.slice(),t).argv};dt.detailed=function(i,e){return fi.parse(i.slice(),e)};dt.camelCase=ze;dt.decamelize=vt;dt.looksLikeNumber=$t;var fn=dt;import{basename as hr,dirname as dr,extname as pr,relative as mr,resolve as gi}from"path";function ui(){return ks()?0:1}function ks(){return er()&&!process.defaultApp}function er(){return!!process.versions.electron}function un(i){return i.slice(ui()+1)}function hi(){return process.argv[ui()]}var q=class i extends Error{constructor(e){super(e||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}};import{readFileSync as tr,statSync as nr,writeFile as ir}from"fs";import{format as sr}from"util";import{resolve as rr}from"path";var di={fs:{readFileSync:tr,writeFile:ir},format:sr,resolve:rr,exists:i=>{try{return nr(i).isFile()}catch{return!1}}};var je,hn=class{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),je.format.apply(je.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),s=e.shift(),r=function(){};typeof e[e.length-1]=="function"&&(r=e.pop()),this.cache[this.locale]||this._readLocaleFile();let a=s===1?t:n;this.cache[this.locale][t]&&(a=this.cache[this.locale][t][s===1?"one":"other"]),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r})):r();let c=[a];return~a.indexOf("%d")&&c.push(s),je.format.apply(je.format,c.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n="";return e.forEach(function(s,r){let a=t[r+1];n+=s,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,s=t.locale,r=t.cb,a=this._resolveLocaleFile(n,s),c=JSON.stringify(this.cache[s],null,2);je.fs.writeFile(a,c,"utf-8",function(g){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),r(g)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{je.fs.readFileSync&&(e=JSON.parse(je.fs.readFileSync(t,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+t),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=je.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let s=je.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(e){return je.exists(e)}};function pi(i,e){je=e;let t=new hn(i);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var or=i=>pi(i,di),mi=or;var gr="require is not supported by ESM",bi="loading a directory of commands is not supported yet for ESM",pt;try{pt=ur(import.meta.url)}catch{pt=process.cwd()}var br=pt.substring(0,pt.lastIndexOf("node_modules")),dn={assert:{notStrictEqual:ar,strictEqual:lr},cliui:rn,findUp:ri,getEnv:i=>process.env[i],inspect:cr,getCallerFile:()=>{throw new q(bi)},getProcessArgvBin:hi,mainFilename:br||process.cwd(),Parser:fn,path:{basename:hr,dirname:dr,extname:pr,relative:mr,resolve:gi},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(i,e)=>process.emitWarning(i,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:fr,require:()=>{throw new q(gr)},requireDirectory:()=>{throw new q(bi)},stringWidth:i=>[...i].length,y18n:mi({directory:gi(pt,"../../../locales"),updateFiles:!1})};function ue(i,e,t,n){t.assert.notStrictEqual(i,e,n)}function pn(i,e){e.assert.strictEqual(typeof i,"string")}function rt(i){return Object.keys(i)}function K(i){return!!i&&!!i.then&&typeof i.then=="function"}function Re(i){let t=i.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=t.shift();if(!s)throw new Error(`No command found in: ${i}`);let r={cmd:s.replace(n,""),demanded:[],optional:[]};return t.forEach((a,c)=>{let g=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===t.length-1&&(g=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:g}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:g})}),r}var yr=["first","second","third","fourth","fifth","sixth"];function j(i,e,t){function n(){return typeof i=="object"?[{demanded:[],optional:[]},i,e]:[Re(`cmd ${i}`),e,t]}try{let s=0,[r,a,c]=n(),g=[].slice.call(a);for(;g.length&&g[g.length-1]===void 0;)g.pop();let b=c||g.length;if(b<r.demanded.length)throw new q(`Not enough arguments provided. Expected ${r.demanded.length} but received ${g.length}.`);let m=r.demanded.length+r.optional.length;if(b>m)throw new q(`Too many arguments provided. Expected max ${m} but received ${b}.`);r.demanded.forEach(h=>{let d=g.shift(),w=yi(d);h.cmd.filter(_=>_===w||_==="*").length===0&&wi(w,h.cmd,s),s+=1}),r.optional.forEach(h=>{if(g.length===0)return;let d=g.shift(),w=yi(d);h.cmd.filter(_=>_===w||_==="*").length===0&&wi(w,h.cmd,s),s+=1})}catch(s){console.warn(s.stack)}}function yi(i){return Array.isArray(i)?"array":i===null?"null":typeof i}function wi(i,e,t){throw new q(`Invalid ${yr[t]||"manyith"} argument. Expected ${e.join(" or ")} but received ${i}.`)}var Ft=class{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,s=!1){if(j("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let r=0;r<e.length;r++){if(typeof e[r]!="function")throw Error("middleware must be a function");let a=e[r];a.applyBeforeValidation=t,a.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e=="function"){let r=e;r.applyBeforeValidation=t,r.global=n,r.mutates=s,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(s=>{let r=[...n[t]||[],t];return s.option?!r.includes(s.option):!0}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();e!==void 0&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter(e=>e.global)}};function Oi(i){return i?i.map(e=>(e.applyBeforeValidation=!1,e)):[]}function He(i,e,t,n){return t.reduce((s,r)=>{if(r.applyBeforeValidation!==n)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(K(s))return s.then(a=>Promise.all([a,r(a,e)])).then(([a,c])=>Object.assign(a,c));{let a=r(s,e);return K(a)?a.then(c=>Object.assign(s,c)):Object.assign(s,a)}},i)}function Ye(i,e,t=n=>{throw n}){try{let n=wr(i)?i():i;return K(n)?n.then(s=>e(s)):e(n)}catch(n){return t(n)}}function wr(i){return typeof i=="function"}function mn(i){if(typeof Me>"u")return null;for(let e=0,t=Object.keys(Me.cache),n;e<t.length;e++)if(n=Me.cache[t[e]],n.exports===i)return n;return null}var ot=/(^\*)|(^\$0)/,gn=class{constructor(e,t,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,s){s=s||{},typeof s.recurse!="boolean"&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);let r=typeof s.visit=="function"?s.visit:a=>a;s.visit=(a,c,g)=>{let b=r(a,c,g);if(b){if(this.requireCache.has(c))return b;this.requireCache.add(c),this.addHandler(b)}return b},this.shim.requireDirectory({require:t,filename:n},e,s)}addHandler(e,t,n,s,r,a){let c=[],g=Oi(r);if(s=s||(()=>{}),Array.isArray(e))if(Or(e))[e,...c]=e;else for(let b of e)this.addHandler(b);else if(Cr(e)){let b=Array.isArray(e.command)||typeof e.command=="string"?e.command:this.moduleName(e);e.aliases&&(b=[].concat(b).concat(e.aliases)),this.addHandler(b,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(_i(n)){this.addHandler([e].concat(c),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e=="string"){let b=Re(e);c=c.map(d=>Re(d).cmd);let m=!1,h=[b.cmd].concat(c).filter(d=>ot.test(d)?(m=!0,!1):!0);h.length===0&&m&&h.push("$0"),m&&(b.cmd=h[0],c=h.slice(1),e=e.replace(ot,b.cmd)),c.forEach(d=>{this.aliasMap[d]=b.cmd}),t!==!1&&this.usage.command(e,t,m,c,a),this.handlers[b.cmd]={original:e,description:t,handler:s,builder:n||{},middlewares:g,deprecated:a,demanded:b.demanded,optional:b.optional},m&&(this.defaultCommand=this.handlers[b.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,s,r,a){let c=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,g=t.getInternalMethods().getContext(),b=g.commands.slice(),m=!e;e&&(g.commands.push(e),g.fullCommands.push(c.original));let h=this.applyBuilderUpdateUsageAndParse(m,c,t,n.aliases,b,s,r,a);return K(h)?h.then(d=>this.applyMiddlewareAndGetResult(m,c,d.innerArgv,g,r,d.aliases,t)):this.applyMiddlewareAndGetResult(m,c,h.innerArgv,g,r,h.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,s,r,a,c,g){let b=t.builder,m=n;if(Rt(b)){n.getInternalMethods().getUsageInstance().freeze();let h=b(n.getInternalMethods().reset(s),g);if(K(h))return h.then(d=>(m=xi(d)?d:n,this.parseAndUpdateUsage(e,t,m,r,a,c)))}else _r(b)&&(n.getInternalMethods().getUsageInstance().freeze(),m=n.getInternalMethods().reset(s),Object.keys(t.builder).forEach(h=>{m.option(h,b[h])}));return this.parseAndUpdateUsage(e,t,m,r,a,c)}parseAndUpdateUsage(e,t,n,s,r,a){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,t),t.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return K(c)?c.then(g=>({aliases:n.parsed.aliases,innerArgv:g})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=ot.test(t.original)?t.original.replace(ot,"").trim():t.original,s=e.filter(r=>!ot.test(r));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(e,t,n,s,r,a,c,g){if(!a.getInternalMethods().getHasOutput()){let b=a.getInternalMethods().runValidation(r,g,a.parsed.error,e);n=Ye(n,m=>(b(m),m))}if(t.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let b=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,b,!1,!1),n=He(n,a,c,!1),n=Ye(n,m=>{let h=t.handler(m);return K(h)?h.then(()=>m):m}),e||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),K(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(m=>{try{a.getInternalMethods().getUsageInstance().fail(null,m)}catch{}})}return e||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,s,r,a,c){let g={};if(r)return n;c.getInternalMethods().getHasOutput()||(g=this.populatePositionals(t,n,s,c));let b=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),m=He(n,c,b,!0);return K(m)?m.then(h=>this.handleValidationAndGetResult(e,t,h,s,a,c,b,g)):this.handleValidationAndGetResult(e,t,m,s,a,c,b,g)}populatePositionals(e,t,n,s){t._=t._.slice(n.commands.length);let r=e.demanded.slice(0),a=e.optional.slice(0),c={};for(this.validation.positionalCount(r.length,t._.length);r.length;){let g=r.shift();this.populatePositional(g,t,c)}for(;a.length;){let g=a.shift();this.populatePositional(g,t,c)}return t._=n.commands.concat(t._.map(g=>""+g)),this.postProcessPositionals(t,c,this.cmdToParseOptions(e.original),s),c}populatePositional(e,t,n){let s=e.cmd[0];e.variadic?n[s]=t._.splice(0).map(String):t._.length&&(n[s]=[String(t._.shift())])}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Re(e);return n.demanded.forEach(s=>{let[r,...a]=s.cmd;s.variadic&&(t.array.push(r),t.default[r]=[]),t.alias[r]=a,t.demand[r]=!0}),n.optional.forEach(s=>{let[r,...a]=s.cmd;s.variadic&&(t.array.push(r),t.default[r]=[]),t.alias[r]=a}),t}postProcessPositionals(e,t,n,s){let r=Object.assign({},s.getOptions());r.default=Object.assign(n.default,r.default);for(let b of Object.keys(n.alias))r.alias[b]=(r.alias[b]||[]).concat(n.alias[b]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(t).forEach(b=>{t[b].map(m=>{r.configuration["unknown-options-as-args"]&&(r.key[b]=!0),a.push(`--${b}`),a.push(m)})}),!a.length)return;let c=Object.assign({},r.configuration,{"populate--":!1}),g=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:c}));if(g.error)s.getInternalMethods().getUsageInstance().fail(g.error.message,g.error);else{let b=Object.keys(t);Object.keys(t).forEach(m=>{b.push(...g.aliases[m])}),Object.keys(g.argv).forEach(m=>{b.includes(m)&&(t[m]||(t[m]=g.argv[m]),!this.isInConfigs(s,m)&&!this.isDefaulted(s,m)&&Object.prototype.hasOwnProperty.call(e,m)&&Object.prototype.hasOwnProperty.call(g.argv,m)&&(Array.isArray(e[m])||Array.isArray(g.argv[m]))?e[m]=[].concat(e[m],g.argv[m]):e[m]=g.argv[m])})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some(s=>Object.prototype.hasOwnProperty.call(s,t))||n.some(s=>Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=ot.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Rt(t))return t(e,!0);_i(t)||Object.keys(t).forEach(n=>{e.option(n,t[n])})}moduleName(e){let t=mn(e);if(!t)throw new Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(let s of[e,t,n]){if(typeof s=="string"||s===!1)return s;ue(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();ue(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Ci(i,e,t,n){return new gn(i,e,t,n)}function _i(i){return typeof i=="object"&&!!i.builder&&typeof i.handler=="function"}function Or(i){return i.every(e=>typeof e=="string")}function Rt(i){return typeof i=="function"}function _r(i){return typeof i=="object"}function Cr(i){return typeof i=="object"&&!Array.isArray(i)}function De(i={},e=()=>!0){let t={};return rt(i).forEach(n=>{e(n,i[n])&&(t[n]=i[n])}),t}function Te(i){typeof process>"u"||[process.stdout,process.stderr].forEach(e=>{let t=e;t._handle&&t.isTTY&&typeof t._handle.setBlocking=="function"&&t._handle.setBlocking(i)})}function xr(i){return typeof i=="boolean"}function Ai(i,e){let t=e.y18n.__,n={},s=[];n.failFn=function(x){s.push(x)};let r=null,a=null,c=!0;n.showHelpOnFail=function(x=!0,P){let[U,Y]=typeof x=="string"?[!0,x]:[x,P];return i.getInternalMethods().isGlobalContext()&&(a=Y),r=Y,c=U,n};let g=!1;n.fail=function(x,P){let U=i.getInternalMethods().getLoggerInstance();if(s.length)for(let Y=s.length-1;Y>=0;--Y){let se=s[Y];if(xr(se)){if(P)throw P;if(x)throw Error(x)}else se(x,P,n)}else{if(i.getExitProcess()&&Te(!0),!g){g=!0,c&&(i.showHelp("error"),U.error()),(x||P)&&U.error(x||P);let Y=r||a;Y&&((x||P)&&U.error(""),U.error(Y))}if(P=P||new q(x),i.getExitProcess())return i.exit(1);if(i.getInternalMethods().hasParseCallback())return i.exit(1,P);throw P}};let b=[],m=!1;n.usage=(v,x)=>v===null?(m=!0,b=[],n):(m=!1,b.push([v,x||""]),n),n.getUsage=()=>b,n.getUsageDisabled=()=>m,n.getPositionalGroupName=()=>t("Positionals:");let h=[];n.example=(v,x)=>{h.push([v,x||""])};let d=[];n.command=function(x,P,U,Y,se=!1){U&&(d=d.map(z=>(z[2]=!1,z))),d.push([x,P||"",U,Y,se])},n.getCommands=()=>d;let w={};n.describe=function(x,P){Array.isArray(x)?x.forEach(U=>{n.describe(U,P)}):typeof x=="object"?Object.keys(x).forEach(U=>{n.describe(U,x[U])}):w[x]=P},n.getDescriptions=()=>w;let C=[];n.epilog=v=>{C.push(v)};let _=!1,p;n.wrap=v=>{_=!0,p=v},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(_||(p=be(),_=!0),p);let W="__yargsString__:";n.deferY18nLookup=v=>W+v,n.help=function(){if(A)return A;S();let x=i.customScriptName?i.$0:e.path.basename(i.$0),P=i.getDemandedOptions(),U=i.getDemandedCommands(),Y=i.getDeprecatedOptions(),se=i.getGroups(),z=i.getOptions(),re=[];re=re.concat(Object.keys(w)),re=re.concat(Object.keys(P)),re=re.concat(Object.keys(U)),re=re.concat(Object.keys(z.default)),re=re.filter(ce),re=Object.keys(re.reduce((F,J)=>(J!=="_"&&(F[J]=!0),F),{}));let Be=n.getWrap(),Z=e.cliui({width:Be,wrap:!!Be});if(!m){if(b.length)b.forEach(F=>{Z.div({text:`${F[0].replace(/\$0/g,x)}`}),F[1]&&Z.div({text:`${F[1]}`,padding:[1,0,0,0]})}),Z.div();else if(d.length){let F=null;U._?F=`${x} <${t("command")}>
14
- `:F=`${x} [${t("command")}]
15
- `,Z.div(`${F}`)}}if(d.length>1||d.length===1&&!d[0][2]){Z.div(t("Commands:"));let F=i.getInternalMethods().getContext(),J=F.commands.length?`${F.commands.join(" ")} `:"";i.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(d=d.sort((V,ee)=>V[0].localeCompare(ee[0])));let k=x?`${x} `:"";d.forEach(V=>{let ee=`${k}${J}${V[0].replace(/^\$0 ?/,"")}`;Z.span({text:ee,padding:[0,2,0,2],width:B(d,Be,`${x}${J}`)+4},{text:V[1]});let ne=[];V[2]&&ne.push(`[${t("default")}]`),V[3]&&V[3].length&&ne.push(`[${t("aliases:")} ${V[3].join(", ")}]`),V[4]&&(typeof V[4]=="string"?ne.push(`[${t("deprecated: %s",V[4])}]`):ne.push(`[${t("deprecated")}]`)),ne.length?Z.div({text:ne.join(" "),padding:[0,0,0,2],align:"right"}):Z.div()}),Z.div()}let $e=(Object.keys(z.alias)||[]).concat(Object.keys(i.parsed.newAliases)||[]);re=re.filter(F=>!i.parsed.newAliases[F]&&$e.every(J=>(z.alias[J]||[]).indexOf(F)===-1));let Ne=t("Options:");se[Ne]||(se[Ne]=[]),T(re,z.alias,se,Ne);let Ve=F=>/^--/.test(Dt(F)),R=Object.keys(se).filter(F=>se[F].length>0).map(F=>{let J=se[F].filter(ce).map(k=>{if($e.includes(k))return k;for(let V=0,ee;(ee=$e[V])!==void 0;V++)if((z.alias[ee]||[]).includes(k))return ee;return k});return{groupName:F,normalizedKeys:J}}).filter(({normalizedKeys:F})=>F.length>0).map(({groupName:F,normalizedKeys:J})=>{let k=J.reduce((V,ee)=>(V[ee]=[ee].concat(z.alias[ee]||[]).map(ne=>F===n.getPositionalGroupName()?ne:(/^[0-9]$/.test(ne)?z.boolean.includes(ee)?"-":"--":ne.length>1?"--":"-")+ne).sort((ne,Ee)=>Ve(ne)===Ve(Ee)?0:Ve(ne)?1:-1).join(", "),V),{});return{groupName:F,normalizedKeys:J,switches:k}});if(R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).some(({normalizedKeys:F,switches:J})=>!F.every(k=>Ve(J[k])))&&R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).forEach(({normalizedKeys:F,switches:J})=>{F.forEach(k=>{Ve(J[k])&&(J[k]=Er(J[k],4))})}),R.forEach(({groupName:F,normalizedKeys:J,switches:k})=>{Z.div(F),J.forEach(V=>{let ee=k[V],ne=w[V]||"",Ee=null;ne.includes(W)&&(ne=t(ne.substring(W.length))),z.boolean.includes(V)&&(Ee=`[${t("boolean")}]`),z.count.includes(V)&&(Ee=`[${t("count")}]`),z.string.includes(V)&&(Ee=`[${t("string")}]`),z.normalize.includes(V)&&(Ee=`[${t("string")}]`),z.array.includes(V)&&(Ee=`[${t("array")}]`),z.number.includes(V)&&(Ee=`[${t("number")}]`);let Ae=u=>typeof u=="string"?`[${t("deprecated: %s",u)}]`:`[${t("deprecated")}]`,wt=[V in Y?Ae(Y[V]):null,Ee,V in P?`[${t("required")}]`:null,z.choices&&z.choices[V]?`[${t("choices:")} ${n.stringifiedValues(z.choices[V])}]`:null,oe(z.default[V],z.defaultDescription[V])].filter(Boolean).join(" ");Z.span({text:Dt(ee),padding:[0,2,0,2+Ei(ee)],width:B(k,Be)+4},ne);let l=i.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;wt&&!l?Z.div({text:wt,padding:[0,0,0,2],align:"right"}):Z.div()}),Z.div()}),h.length&&(Z.div(t("Examples:")),h.forEach(F=>{F[0]=F[0].replace(/\$0/g,x)}),h.forEach(F=>{F[1]===""?Z.div({text:F[0],padding:[0,2,0,2]}):Z.div({text:F[0],padding:[0,2,0,2],width:B(h,Be)+4},{text:F[1]})}),Z.div()),C.length>0){let F=C.map(J=>J.replace(/\$0/g,x)).join(`
12
+ `),r.border&&(s.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(s.unshift(...new Array(r.padding[Ws]||0).fill("")),s.push(...new Array(r.padding[Us]||0).fill(""))),s.forEach((c,b)=>{t[b]||t.push([]);let g=t[b];for(let p=0;p<a;p++)g[p]===void 0&&g.push("");g.push(c)})}),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[It]||0)+(e.padding[Pt]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map(a=>a.width||he.stringWidth(a.text));let t=e.length,n=this.width,s=e.map(a=>{if(a.width)return t--,n-=a.width,a.width}),r=t?Math.floor(n/t):0;return s.map((a,c)=>a===void 0?Math.max(r,Bs(e[c])):a)}};function kn(i,e,t){return i.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?t:" ":""}function Bs(i){let e=i.padding||[],t=1+(e[It]||0)+(e[Pt]||0);return i.border?t+4:t}function zs(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Vs(i,e){i=i.trim();let t=he.stringWidth(i);return t<e?" ".repeat(e-t)+i:i}function Hs(i,e){i=i.trim();let t=he.stringWidth(i);return t>=e?i:" ".repeat(e-t>>1)+i}var he;function ei(i,e){return he=e,new sn({width:(i==null?void 0:i.width)||zs(),wrap:i==null?void 0:i.wrap})}var ti=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function rn(i){return i.replace(ti,"")}function ni(i,e){let[t,n]=i.match(ti)||["",""];i=rn(i);let s="";for(let r=0;r<i.length;r++)r!==0&&r%e===0&&(s+=`
13
+ `),s+=i.charAt(r);return t&&n&&(s=`${t}${s}${n}`),s}function on(i){return ei(i,{stringWidth:e=>[...e].length,stripAnsi:rn,wrap:ni})}import{dirname as ii,resolve as si}from"path";import{readdirSync as Gs,statSync as Ys}from"fs";function ri(i,e){let t=si(".",i),n;for(Ys(t).isDirectory()||(t=ii(t));;){if(n=e(t,Gs(t)),n)return si(t,n);if(t=ii(n=t),n===t)break}}import{inspect as fr}from"util";import{readFileSync as ur}from"fs";import{fileURLToPath as hr}from"url";import{format as Js}from"util";import{normalize as Qs,resolve as Zs}from"path";function ze(i){if(i!==i.toLowerCase()&&i!==i.toUpperCase()||(i=i.toLowerCase()),i.indexOf("-")===-1&&i.indexOf("_")===-1)return i;{let t="",n=!1,s=i.match(/^-+/);for(let r=s?s[0].length:0;r<i.length;r++){let a=i.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(t+=a)}return t}}function vt(i,e){let t=i.toLowerCase();e=e||"-";let n="";for(let s=0;s<i.length;s++){let r=t.charAt(s),a=i.charAt(s);r!==a&&s>0?n+=`${e}${t.charAt(s)}`:n+=a}return n}function $t(i){return i==null?!1:typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^0[^.]/.test(i)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}function oi(i){if(Array.isArray(i))return i.map(a=>typeof a!="string"?a+"":a);i=i.trim();let e=0,t=null,n=null,s=null,r=[];for(let a=0;a<i.length;a++){if(t=n,n=i.charAt(a),n===" "&&!s){t!==" "&&e++;continue}n===s?s=null:(n==="'"||n==='"')&&!s&&(s=n),r[e]||(r[e]=""),r[e]+=n}return r}var be;(function(i){i.BOOLEAN="boolean",i.STRING="string",i.NUMBER="number",i.ARRAY="array"})(be||(be={}));var $e,Nt=class{constructor(e){$e=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),s=oi(e),r=typeof e=="string",a=qs(Object.assign(Object.create(null),n.alias)),c=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),b=Object.assign(Object.create(null),n.default),g=n.configObjects||[],p=n.envPrefix,u=c["populate--"],m=u?"--":"_",w=Object.create(null),C=Object.create(null),O=n.__||$e.format,f={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},x=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,N=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let d=typeof l=="object"?l.key:l,_=Object.keys(l).map(function(y){return{boolean:"bools",string:"strings",number:"numbers"}[y]}).filter(Boolean).pop();_&&(f[_][d]=!0),f.arrays[d]=!0,f.keys.push(d)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){f.bools[l]=!0,f.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){f.strings[l]=!0,f.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){f.numbers[l]=!0,f.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){f.counts[l]=!0,f.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){f.normalize[l]=!0,f.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,d])=>{typeof d=="number"&&(f.nargs[l]=d,f.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,d])=>{typeof d=="function"&&(f.coercions[l]=d,f.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){f.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,d])=>{(typeof d=="boolean"||typeof d=="function")&&(f.configs[l]=d)})),Be(n.key,a,n.default,f.arrays),Object.keys(b).forEach(function(l){(f.aliases[l]||[]).forEach(function(d){b[d]=b[l]})});let U=null;yt();let W=[],z=Object.assign(Object.create(null),{_:[]}),le={};for(let l=0;l<s.length;l++){let d=s[l],_=d.replace(/^-{3,}/,"---"),y,h,P,A,$,oe;if(d!=="--"&&/^-/.test(d)&&k(d))ce(d);else if(_.match(/^---+(=|$)/)){ce(d);continue}else if(d.match(/^--.+=/)||!c["short-option-groups"]&&d.match(/^-.+=/))A=d.match(/^--?([^=]+)=([\s\S]*)$/),A!==null&&Array.isArray(A)&&A.length>=3&&(R(A[1],f.arrays)?l=We(l,A[1],s,A[2]):R(A[1],f.nargs)!==!1?l=tt(l,A[1],s,A[2]):Y(A[1],A[2],!0));else if(d.match(N)&&c["boolean-negation"])A=d.match(N),A!==null&&Array.isArray(A)&&A.length>=2&&(h=A[1],Y(h,R(h,f.arrays)?[!1]:!1));else if(d.match(/^--.+/)||!c["short-option-groups"]&&d.match(/^-[^-]+/))A=d.match(/^--?(.+)/),A!==null&&Array.isArray(A)&&A.length>=2&&(h=A[1],R(h,f.arrays)?l=We(l,h,s):R(h,f.nargs)!==!1?l=tt(l,h,s):($=s[l+1],$!==void 0&&(!$.match(/^-/)||$.match(x))&&!R(h,f.bools)&&!R(h,f.counts)||/^(true|false)$/.test($)?(Y(h,$),l++):Y(h,ee(h))));else if(d.match(/^-.\..+=/))A=d.match(/^-([^=]+)=([\s\S]*)$/),A!==null&&Array.isArray(A)&&A.length>=3&&Y(A[1],A[2]);else if(d.match(/^-.\..+/)&&!d.match(x))$=s[l+1],A=d.match(/^-(.\..+)/),A!==null&&Array.isArray(A)&&A.length>=2&&(h=A[1],$!==void 0&&!$.match(/^-/)&&!R(h,f.bools)&&!R(h,f.counts)?(Y(h,$),l++):Y(h,ee(h)));else if(d.match(/^-[^-]+/)&&!d.match(x)){P=d.slice(1,-1).split(""),y=!1;for(let fe=0;fe<P.length;fe++){if($=d.slice(fe+2),P[fe+1]&&P[fe+1]==="="){oe=d.slice(fe+3),h=P[fe],R(h,f.arrays)?l=We(l,h,s,oe):R(h,f.nargs)!==!1?l=tt(l,h,s,oe):Y(h,oe),y=!0;break}if($==="-"){Y(P[fe],$);continue}if(/[A-Za-z]/.test(P[fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&R($,f.bools)===!1){Y(P[fe],$),y=!0;break}if(P[fe+1]&&P[fe+1].match(/\W/)){Y(P[fe],$),y=!0;break}else Y(P[fe],ee(P[fe]))}h=d.slice(-1)[0],!y&&h!=="-"&&(R(h,f.arrays)?l=We(l,h,s):R(h,f.nargs)!==!1?l=tt(l,h,s):($=s[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(x))&&!R(h,f.bools)&&!R(h,f.counts)||/^(true|false)$/.test($)?(Y(h,$),l++):Y(h,ee(h))))}else if(d.match(/^-[0-9]$/)&&d.match(x)&&R(d.slice(1),f.bools))h=d.slice(1),Y(h,ee(h));else if(d==="--"){W=s.slice(l+1);break}else if(c["halt-at-non-option"]){W=s.slice(l);break}else ce(d)}V(z,!0),V(z,!1),L(z),se(),Z(z,f.aliases,b,!0),re(z),c["set-placeholder-key"]&&Ue(z),Object.keys(f.counts).forEach(function(l){Ie(z,l.split("."))||Y(l,0)}),u&&W.length&&(z[m]=[]),W.forEach(function(l){z[m].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(z).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete z[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete z[l.split(".").map(d=>ze(d)).join(".")],delete z[l]});function ce(l){let d=M("_",l);(typeof d=="string"||typeof d=="number")&&z._.push(d)}function tt(l,d,_,y){let h,P=R(d,f.nargs);if(P=typeof P!="number"||isNaN(P)?1:P,P===0)return xe(y)||(U=Error(O("Argument unexpected for: %s",d))),Y(d,ee(d)),l;let A=xe(y)?0:1;if(c["nargs-eats-options"])_.length-(l+1)+A<P&&(U=Error(O("Not enough arguments following: %s",d))),A=P;else{for(h=l+1;h<_.length&&(!_[h].match(/^-[^0-9]/)||_[h].match(x)||k(_[h]));h++)A++;A<P&&(U=Error(O("Not enough arguments following: %s",d)))}let $=Math.min(A,P);for(!xe(y)&&$>0&&(Y(d,y),$--),h=l+1;h<$+l+1;h++)Y(d,_[h]);return l+$}function We(l,d,_,y){let h=[],P=y||_[l+1],A=R(d,f.nargs);if(R(d,f.bools)&&!/^(true|false)$/.test(P))h.push(!0);else if(xe(P)||xe(y)&&/^-/.test(P)&&!x.test(P)&&!k(P)){if(b[d]!==void 0){let $=b[d];h=Array.isArray($)?$:[$]}}else{xe(y)||h.push(E(d,y,!0));for(let $=l+1;$<_.length&&!(!c["greedy-arrays"]&&h.length>0||A&&typeof A=="number"&&h.length>=A||(P=_[$],/^-/.test(P)&&!x.test(P)&&!k(P)));$++)l=$,h.push(E(d,P,r))}return typeof A=="number"&&(A&&h.length<A||isNaN(A)&&h.length===0)&&(U=Error(O("Not enough arguments following: %s",d))),Y(d,h),l}function Y(l,d,_=r){if(/-/.test(l)&&c["camel-case-expansion"]){let P=l.split(".").map(function(A){return ze(A)}).join(".");I(l,P)}let y=E(l,d,_),h=l.split(".");ve(z,h,y),f.aliases[l]&&f.aliases[l].forEach(function(P){let A=P.split(".");ve(z,A,y)}),h.length>1&&c["dot-notation"]&&(f.aliases[h[0]]||[]).forEach(function(P){let A=P.split("."),$=[].concat(h);$.shift(),A=A.concat($),(f.aliases[l]||[]).includes(A.join("."))||ve(z,A,y)}),R(l,f.normalize)&&!R(l,f.arrays)&&[l].concat(f.aliases[l]||[]).forEach(function(A){Object.defineProperty(le,A,{enumerable:!0,get(){return d},set($){d=typeof $=="string"?$e.normalize($):$}})})}function I(l,d){f.aliases[l]&&f.aliases[l].length||(f.aliases[l]=[d],w[d]=!0),f.aliases[d]&&f.aliases[d].length||I(d,l)}function E(l,d,_){_&&(d=Ks(d)),(R(l,f.bools)||R(l,f.counts))&&typeof d=="string"&&(d=d==="true");let y=Array.isArray(d)?d.map(function(h){return M(l,h)}):M(l,d);return R(l,f.counts)&&(xe(y)||typeof y=="boolean")&&(y=an()),R(l,f.normalize)&&R(l,f.arrays)&&(Array.isArray(d)?y=d.map(h=>$e.normalize(h)):y=$e.normalize(d)),y}function M(l,d){return!c["parse-positional-numbers"]&&l==="_"||!R(l,f.strings)&&!R(l,f.bools)&&!Array.isArray(d)&&($t(d)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${d}`)))||!xe(d)&&R(l,f.numbers))&&(d=Number(d)),d}function L(l){let d=Object.create(null);Z(d,f.aliases,b),Object.keys(f.configs).forEach(function(_){let y=l[_]||d[_];if(y)try{let h=null,P=$e.resolve($e.cwd(),y),A=f.configs[_];if(typeof A=="function"){try{h=A(P)}catch($){h=$}if(h instanceof Error){U=h;return}}else h=$e.require(P);H(h)}catch(h){h.name==="PermissionDenied"?U=h:l[_]&&(U=Error(O("Invalid JSON config file: %s",y)))}})}function H(l,d){Object.keys(l).forEach(function(_){let y=l[_],h=d?d+"."+_:_;typeof y=="object"&&y!==null&&!Array.isArray(y)&&c["dot-notation"]?H(y,h):(!Ie(z,h.split("."))||R(h,f.arrays)&&c["combine-arrays"])&&Y(h,y)})}function se(){typeof g<"u"&&g.forEach(function(l){H(l)})}function V(l,d){if(typeof p>"u")return;let _=typeof p=="string"?p:"",y=$e.env();Object.keys(y).forEach(function(h){if(_===""||h.lastIndexOf(_,0)===0){let P=h.split("__").map(function(A,$){return $===0&&(A=A.substring(_.length)),ze(A)});(d&&f.configs[P.join(".")]||!d)&&!Ie(l,P)&&Y(P.join("."),y[h])}})}function re(l){let d,_=new Set;Object.keys(l).forEach(function(y){if(!_.has(y)&&(d=R(y,f.coercions),typeof d=="function"))try{let h=M(y,d(l[y]));[].concat(f.aliases[y]||[],y).forEach(P=>{_.add(P),l[P]=h})}catch(h){U=h}})}function Ue(l){return f.keys.forEach(d=>{~d.indexOf(".")||typeof l[d]>"u"&&(l[d]=void 0)}),l}function Z(l,d,_,y=!1){Object.keys(_).forEach(function(h){Ie(l,h.split("."))||(ve(l,h.split("."),_[h]),y&&(C[h]=!0),(d[h]||[]).forEach(function(P){Ie(l,P.split("."))||ve(l,P.split("."),_[h])}))})}function Ie(l,d){let _=l;c["dot-notation"]||(d=[d.join(".")]),d.slice(0,-1).forEach(function(h){_=_[h]||{}});let y=d[d.length-1];return typeof _!="object"?!1:y in _}function ve(l,d,_){let y=l;c["dot-notation"]||(d=[d.join(".")]),d.slice(0,-1).forEach(function(oe){oe=ai(oe),typeof y=="object"&&y[oe]===void 0&&(y[oe]={}),typeof y[oe]!="object"||Array.isArray(y[oe])?(Array.isArray(y[oe])?y[oe].push({}):y[oe]=[y[oe],{}],y=y[oe][y[oe].length-1]):y=y[oe]});let h=ai(d[d.length-1]),P=R(d.join("."),f.arrays),A=Array.isArray(_),$=c["duplicate-arguments-array"];!$&&R(h,f.nargs)&&($=!0,(!xe(y[h])&&f.nargs[h]===1||Array.isArray(y[h])&&y[h].length===f.nargs[h])&&(y[h]=void 0)),_===an()?y[h]=an(y[h]):Array.isArray(y[h])?$&&P&&A?y[h]=c["flatten-duplicate-arrays"]?y[h].concat(_):(Array.isArray(y[h][0])?y[h]:[y[h]]).concat([_]):!$&&!!P==!!A?y[h]=_:y[h]=y[h].concat([_]):y[h]===void 0&&P?y[h]=A?_:[_]:$&&!(y[h]===void 0||R(h,f.counts)||R(h,f.bools))?y[h]=[y[h],_]:y[h]=_}function Be(...l){l.forEach(function(d){Object.keys(d||{}).forEach(function(_){f.aliases[_]||(f.aliases[_]=[].concat(a[_]||[]),f.aliases[_].concat(_).forEach(function(y){if(/-/.test(y)&&c["camel-case-expansion"]){let h=ze(y);h!==_&&f.aliases[_].indexOf(h)===-1&&(f.aliases[_].push(h),w[h]=!0)}}),f.aliases[_].concat(_).forEach(function(y){if(y.length>1&&/[A-Z]/.test(y)&&c["camel-case-expansion"]){let h=vt(y,"-");h!==_&&f.aliases[_].indexOf(h)===-1&&(f.aliases[_].push(h),w[h]=!0)}}),f.aliases[_].forEach(function(y){f.aliases[y]=[_].concat(f.aliases[_].filter(function(h){return y!==h}))}))})})}function R(l,d){let _=[].concat(f.aliases[l]||[],l),y=Object.keys(d),h=_.find(P=>y.includes(P));return h?d[h]:!1}function Yt(l){let d=Object.keys(f);return[].concat(d.map(y=>f[y])).some(function(y){return Array.isArray(y)?y.includes(l):y[l]})}function F(l,...d){return[].concat(...d).some(function(y){let h=l.match(y);return h&&Yt(h[1])})}function J(l){if(l.match(x)||!l.match(/^-[^-]+/))return!1;let d=!0,_,y=l.slice(1).split("");for(let h=0;h<y.length;h++){if(_=l.slice(h+2),!Yt(y[h])){d=!1;break}if(y[h+1]&&y[h+1]==="="||_==="-"||/[A-Za-z]/.test(y[h])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(_)||y[h+1]&&y[h+1].match(/\W/))break}return d}function k(l){return c["unknown-options-as-args"]&&B(l)}function B(l){return l=l.replace(/^-{3,}/,"--"),l.match(x)||J(l)?!1:!F(l,/^-+([^=]+?)=[\s\S]*$/,N,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function ee(l){return!R(l,f.bools)&&!R(l,f.counts)&&`${l}`in b?b[l]:ne(Ce(l))}function ne(l){return{[be.BOOLEAN]:!0,[be.STRING]:"",[be.NUMBER]:void 0,[be.ARRAY]:[]}[l]}function Ce(l){let d=be.BOOLEAN;return R(l,f.strings)?d=be.STRING:R(l,f.numbers)?d=be.NUMBER:R(l,f.bools)?d=be.BOOLEAN:R(l,f.arrays)&&(d=be.ARRAY),d}function xe(l){return l===void 0}function yt(){Object.keys(f.counts).find(l=>R(l,f.arrays)?(U=Error(O("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):R(l,f.nargs)?(U=Error(O("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},f.aliases),argv:Object.assign(le,z),configuration:c,defaulted:Object.assign({},C),error:U,newAliases:Object.assign({},w)}}};function qs(i){let e=[],t=Object.create(null),n=!0;for(Object.keys(i).forEach(function(s){e.push([].concat(i[s],s))});n;){n=!1;for(let s=0;s<e.length;s++)for(let r=s+1;r<e.length;r++)if(e[s].filter(function(c){return e[r].indexOf(c)!==-1}).length){e[s]=e[s].concat(e[r]),e.splice(r,1),n=!0;break}}return e.forEach(function(s){s=s.filter(function(a,c,b){return b.indexOf(a)===c});let r=s.pop();r!==void 0&&typeof r=="string"&&(t[r]=s)}),t}function an(i){return i!==void 0?i+1:1}function ai(i){return i==="__proto__"?"___proto___":i}function Ks(i){return typeof i=="string"&&(i[0]==="'"||i[0]==='"')&&i[i.length-1]===i[0]?i.substring(1,i.length-1):i}import{readFileSync as Xs}from"fs";var ln,cn,fn,li=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,ci=(cn=(ln=process==null?void 0:process.versions)===null||ln===void 0?void 0:ln.node)!==null&&cn!==void 0?cn:(fn=process==null?void 0:process.version)===null||fn===void 0?void 0:fn.slice(1);if(ci&&Number(ci.match(/^([^.]+)/)[1])<li)throw Error(`yargs parser supports a minimum Node.js version of ${li}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var ks=process?process.env:{},fi=new Nt({cwd:process.cwd,env:()=>ks,format:Js,normalize:Qs,resolve:Zs,require:i=>{if(typeof Se<"u")return Se(i);if(i.match(/\.json$/))return JSON.parse(Xs(i,"utf8"));throw Error("only .json config files are supported in ESM")}}),ht=function(e,t){return fi.parse(e.slice(),t).argv};ht.detailed=function(i,e){return fi.parse(i.slice(),e)};ht.camelCase=ze;ht.decamelize=vt;ht.looksLikeNumber=$t;var un=ht;import{basename as dr,dirname as pr,extname as mr,relative as gr,resolve as gi}from"path";function ui(){return er()?0:1}function er(){return tr()&&!process.defaultApp}function tr(){return!!process.versions.electron}function hn(i){return i.slice(ui()+1)}function hi(){return process.argv[ui()]}var q=class i extends Error{constructor(e){super(e||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}};import{readFileSync as nr,statSync as ir,writeFile as sr}from"fs";import{format as rr}from"util";import{resolve as or}from"path";var di={fs:{readFileSync:nr,writeFile:sr},format:rr,resolve:or,exists:i=>{try{return ir(i).isFile()}catch{return!1}}};var Ae,dn=class{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Ae.format.apply(Ae.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),s=e.shift(),r=function(){};typeof e[e.length-1]=="function"&&(r=e.pop()),this.cache[this.locale]||this._readLocaleFile();let a=s===1?t:n;this.cache[this.locale][t]&&(a=this.cache[this.locale][t][s===1?"one":"other"]),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r})):r();let c=[a];return~a.indexOf("%d")&&c.push(s),Ae.format.apply(Ae.format,c.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n="";return e.forEach(function(s,r){let a=t[r+1];n+=s,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,s=t.locale,r=t.cb,a=this._resolveLocaleFile(n,s),c=JSON.stringify(this.cache[s],null,2);Ae.fs.writeFile(a,c,"utf-8",function(b){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),r(b)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{Ae.fs.readFileSync&&(e=JSON.parse(Ae.fs.readFileSync(t,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+t),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=Ae.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let s=Ae.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(e){return Ae.exists(e)}};function pi(i,e){Ae=e;let t=new dn(i);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var ar=i=>pi(i,di),mi=ar;var br="require is not supported by ESM",bi="loading a directory of commands is not supported yet for ESM",dt;try{dt=hr(import.meta.url)}catch{dt=process.cwd()}var yr=dt.substring(0,dt.lastIndexOf("node_modules")),pn={assert:{notStrictEqual:lr,strictEqual:cr},cliui:on,findUp:ri,getEnv:i=>process.env[i],inspect:fr,getCallerFile:()=>{throw new q(bi)},getProcessArgvBin:hi,mainFilename:yr||process.cwd(),Parser:un,path:{basename:dr,dirname:pr,extname:mr,relative:gr,resolve:gi},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(i,e)=>process.emitWarning(i,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:ur,require:()=>{throw new q(br)},requireDirectory:()=>{throw new q(bi)},stringWidth:i=>[...i].length,y18n:mi({directory:gi(dt,"../../../locales"),updateFiles:!1})};function ue(i,e,t,n){t.assert.notStrictEqual(i,e,n)}function mn(i,e){e.assert.strictEqual(typeof i,"string")}function st(i){return Object.keys(i)}function K(i){return!!i&&!!i.then&&typeof i.then=="function"}function Ne(i){let t=i.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=t.shift();if(!s)throw new Error(`No command found in: ${i}`);let r={cmd:s.replace(n,""),demanded:[],optional:[]};return t.forEach((a,c)=>{let b=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===t.length-1&&(b=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:b}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:b})}),r}var wr=["first","second","third","fourth","fifth","sixth"];function S(i,e,t){function n(){return typeof i=="object"?[{demanded:[],optional:[]},i,e]:[Ne(`cmd ${i}`),e,t]}try{let s=0,[r,a,c]=n(),b=[].slice.call(a);for(;b.length&&b[b.length-1]===void 0;)b.pop();let g=c||b.length;if(g<r.demanded.length)throw new q(`Not enough arguments provided. Expected ${r.demanded.length} but received ${b.length}.`);let p=r.demanded.length+r.optional.length;if(g>p)throw new q(`Too many arguments provided. Expected max ${p} but received ${g}.`);r.demanded.forEach(u=>{let m=b.shift(),w=yi(m);u.cmd.filter(O=>O===w||O==="*").length===0&&wi(w,u.cmd,s),s+=1}),r.optional.forEach(u=>{if(b.length===0)return;let m=b.shift(),w=yi(m);u.cmd.filter(O=>O===w||O==="*").length===0&&wi(w,u.cmd,s),s+=1})}catch(s){console.warn(s.stack)}}function yi(i){return Array.isArray(i)?"array":i===null?"null":typeof i}function wi(i,e,t){throw new q(`Invalid ${wr[t]||"manyith"} argument. Expected ${e.join(" or ")} but received ${i}.`)}var Ft=class{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,s=!1){if(S("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let r=0;r<e.length;r++){if(typeof e[r]!="function")throw Error("middleware must be a function");let a=e[r];a.applyBeforeValidation=t,a.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e=="function"){let r=e;r.applyBeforeValidation=t,r.global=n,r.mutates=s,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(s=>{let r=[...n[t]||[],t];return s.option?!r.includes(s.option):!0}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();e!==void 0&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter(e=>e.global)}};function Oi(i){return i?i.map(e=>(e.applyBeforeValidation=!1,e)):[]}function Ve(i,e,t,n){return t.reduce((s,r)=>{if(r.applyBeforeValidation!==n)return s;if(r.mutates){if(r.applied)return s;r.applied=!0}if(K(s))return s.then(a=>Promise.all([a,r(a,e)])).then(([a,c])=>Object.assign(a,c));{let a=r(s,e);return K(a)?a.then(c=>Object.assign(s,c)):Object.assign(s,a)}},i)}function He(i,e,t=n=>{throw n}){try{let n=Or(i)?i():i;return K(n)?n.then(s=>e(s)):e(n)}catch(n){return t(n)}}function Or(i){return typeof i=="function"}function gn(i){if(typeof Se>"u")return null;for(let e=0,t=Object.keys(Se.cache),n;e<t.length;e++)if(n=Se.cache[t[e]],n.exports===i)return n;return null}var rt=/(^\*)|(^\$0)/,bn=class{constructor(e,t,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,s){s=s||{},typeof s.recurse!="boolean"&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);let r=typeof s.visit=="function"?s.visit:a=>a;s.visit=(a,c,b)=>{let g=r(a,c,b);if(g){if(this.requireCache.has(c))return g;this.requireCache.add(c),this.addHandler(g)}return g},this.shim.requireDirectory({require:t,filename:n},e,s)}addHandler(e,t,n,s,r,a){let c=[],b=Oi(r);if(s=s||(()=>{}),Array.isArray(e))if(_r(e))[e,...c]=e;else for(let g of e)this.addHandler(g);else if(xr(e)){let g=Array.isArray(e.command)||typeof e.command=="string"?e.command:this.moduleName(e);e.aliases&&(g=[].concat(g).concat(e.aliases)),this.addHandler(g,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(_i(n)){this.addHandler([e].concat(c),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e=="string"){let g=Ne(e);c=c.map(m=>Ne(m).cmd);let p=!1,u=[g.cmd].concat(c).filter(m=>rt.test(m)?(p=!0,!1):!0);u.length===0&&p&&u.push("$0"),p&&(g.cmd=u[0],c=u.slice(1),e=e.replace(rt,g.cmd)),c.forEach(m=>{this.aliasMap[m]=g.cmd}),t!==!1&&this.usage.command(e,t,p,c,a),this.handlers[g.cmd]={original:e,description:t,handler:s,builder:n||{},middlewares:b,deprecated:a,demanded:g.demanded,optional:g.optional},p&&(this.defaultCommand=this.handlers[g.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,s,r,a){let c=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,b=t.getInternalMethods().getContext(),g=b.commands.slice(),p=!e;e&&(b.commands.push(e),b.fullCommands.push(c.original));let u=this.applyBuilderUpdateUsageAndParse(p,c,t,n.aliases,g,s,r,a);return K(u)?u.then(m=>this.applyMiddlewareAndGetResult(p,c,m.innerArgv,b,r,m.aliases,t)):this.applyMiddlewareAndGetResult(p,c,u.innerArgv,b,r,u.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,s,r,a,c,b){let g=t.builder,p=n;if(Rt(g)){n.getInternalMethods().getUsageInstance().freeze();let u=g(n.getInternalMethods().reset(s),b);if(K(u))return u.then(m=>(p=xi(m)?m:n,this.parseAndUpdateUsage(e,t,p,r,a,c)))}else Cr(g)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(s),Object.keys(t.builder).forEach(u=>{p.option(u,g[u])}));return this.parseAndUpdateUsage(e,t,p,r,a,c)}parseAndUpdateUsage(e,t,n,s,r,a){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,t),t.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return K(c)?c.then(b=>({aliases:n.parsed.aliases,innerArgv:b})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=rt.test(t.original)?t.original.replace(rt,"").trim():t.original,s=e.filter(r=>!rt.test(r));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(e,t,n,s,r,a,c,b){if(!a.getInternalMethods().getHasOutput()){let g=a.getInternalMethods().runValidation(r,b,a.parsed.error,e);n=He(n,p=>(g(p),p))}if(t.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let g=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,g,!1,!1),n=Ve(n,a,c,!1),n=He(n,p=>{let u=t.handler(p);return K(u)?u.then(()=>p):p}),e||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),K(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(p=>{try{a.getInternalMethods().getUsageInstance().fail(null,p)}catch{}})}return e||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,s,r,a,c){let b={};if(r)return n;c.getInternalMethods().getHasOutput()||(b=this.populatePositionals(t,n,s,c));let g=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),p=Ve(n,c,g,!0);return K(p)?p.then(u=>this.handleValidationAndGetResult(e,t,u,s,a,c,g,b)):this.handleValidationAndGetResult(e,t,p,s,a,c,g,b)}populatePositionals(e,t,n,s){t._=t._.slice(n.commands.length);let r=e.demanded.slice(0),a=e.optional.slice(0),c={};for(this.validation.positionalCount(r.length,t._.length);r.length;){let b=r.shift();this.populatePositional(b,t,c)}for(;a.length;){let b=a.shift();this.populatePositional(b,t,c)}return t._=n.commands.concat(t._.map(b=>""+b)),this.postProcessPositionals(t,c,this.cmdToParseOptions(e.original),s),c}populatePositional(e,t,n){let s=e.cmd[0];e.variadic?n[s]=t._.splice(0).map(String):t._.length&&(n[s]=[String(t._.shift())])}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Ne(e);return n.demanded.forEach(s=>{let[r,...a]=s.cmd;s.variadic&&(t.array.push(r),t.default[r]=[]),t.alias[r]=a,t.demand[r]=!0}),n.optional.forEach(s=>{let[r,...a]=s.cmd;s.variadic&&(t.array.push(r),t.default[r]=[]),t.alias[r]=a}),t}postProcessPositionals(e,t,n,s){let r=Object.assign({},s.getOptions());r.default=Object.assign(n.default,r.default);for(let g of Object.keys(n.alias))r.alias[g]=(r.alias[g]||[]).concat(n.alias[g]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(t).forEach(g=>{t[g].map(p=>{r.configuration["unknown-options-as-args"]&&(r.key[g]=!0),a.push(`--${g}`),a.push(p)})}),!a.length)return;let c=Object.assign({},r.configuration,{"populate--":!1}),b=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:c}));if(b.error)s.getInternalMethods().getUsageInstance().fail(b.error.message,b.error);else{let g=Object.keys(t);Object.keys(t).forEach(p=>{g.push(...b.aliases[p])}),Object.keys(b.argv).forEach(p=>{g.includes(p)&&(t[p]||(t[p]=b.argv[p]),!this.isInConfigs(s,p)&&!this.isDefaulted(s,p)&&Object.prototype.hasOwnProperty.call(e,p)&&Object.prototype.hasOwnProperty.call(b.argv,p)&&(Array.isArray(e[p])||Array.isArray(b.argv[p]))?e[p]=[].concat(e[p],b.argv[p]):e[p]=b.argv[p])})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some(s=>Object.prototype.hasOwnProperty.call(s,t))||n.some(s=>Object.prototype.hasOwnProperty.call(s,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=rt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Rt(t))return t(e,!0);_i(t)||Object.keys(t).forEach(n=>{e.option(n,t[n])})}moduleName(e){let t=gn(e);if(!t)throw new Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(let s of[e,t,n]){if(typeof s=="string"||s===!1)return s;ue(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();ue(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Ci(i,e,t,n){return new bn(i,e,t,n)}function _i(i){return typeof i=="object"&&!!i.builder&&typeof i.handler=="function"}function _r(i){return i.every(e=>typeof e=="string")}function Rt(i){return typeof i=="function"}function Cr(i){return typeof i=="object"}function xr(i){return typeof i=="object"&&!Array.isArray(i)}function Fe(i={},e=()=>!0){let t={};return st(i).forEach(n=>{e(n,i[n])&&(t[n]=i[n])}),t}function Re(i){typeof process>"u"||[process.stdout,process.stderr].forEach(e=>{let t=e;t._handle&&t.isTTY&&typeof t._handle.setBlocking=="function"&&t._handle.setBlocking(i)})}function Er(i){return typeof i=="boolean"}function Ai(i,e){let t=e.y18n.__,n={},s=[];n.failFn=function(E){s.push(E)};let r=null,a=null,c=!0;n.showHelpOnFail=function(E=!0,M){let[L,H]=typeof E=="string"?[!0,E]:[E,M];return i.getInternalMethods().isGlobalContext()&&(a=H),r=H,c=L,n};let b=!1;n.fail=function(E,M){let L=i.getInternalMethods().getLoggerInstance();if(s.length)for(let H=s.length-1;H>=0;--H){let se=s[H];if(Er(se)){if(M)throw M;if(E)throw Error(E)}else se(E,M,n)}else{if(i.getExitProcess()&&Re(!0),!b){b=!0,c&&(i.showHelp("error"),L.error()),(E||M)&&L.error(E||M);let H=r||a;H&&((E||M)&&L.error(""),L.error(H))}if(M=M||new q(E),i.getExitProcess())return i.exit(1);if(i.getInternalMethods().hasParseCallback())return i.exit(1,M);throw M}};let g=[],p=!1;n.usage=(I,E)=>I===null?(p=!0,g=[],n):(p=!1,g.push([I,E||""]),n),n.getUsage=()=>g,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>t("Positionals:");let u=[];n.example=(I,E)=>{u.push([I,E||""])};let m=[];n.command=function(E,M,L,H,se=!1){L&&(m=m.map(V=>(V[2]=!1,V))),m.push([E,M||"",L,H,se])},n.getCommands=()=>m;let w={};n.describe=function(E,M){Array.isArray(E)?E.forEach(L=>{n.describe(L,M)}):typeof E=="object"?Object.keys(E).forEach(L=>{n.describe(L,E[L])}):w[E]=M},n.getDescriptions=()=>w;let C=[];n.epilog=I=>{C.push(I)};let O=!1,f;n.wrap=I=>{O=!0,f=I},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(O||(f=tt(),O=!0),f);let x="__yargsString__:";n.deferY18nLookup=I=>x+I,n.help=function(){if(W)return W;U();let E=i.customScriptName?i.$0:e.path.basename(i.$0),M=i.getDemandedOptions(),L=i.getDemandedCommands(),H=i.getDeprecatedOptions(),se=i.getGroups(),V=i.getOptions(),re=[];re=re.concat(Object.keys(w)),re=re.concat(Object.keys(M)),re=re.concat(Object.keys(L)),re=re.concat(Object.keys(V.default)),re=re.filter(le),re=Object.keys(re.reduce((F,J)=>(J!=="_"&&(F[J]=!0),F),{}));let Ue=n.getWrap(),Z=e.cliui({width:Ue,wrap:!!Ue});if(!p){if(g.length)g.forEach(F=>{Z.div({text:`${F[0].replace(/\$0/g,E)}`}),F[1]&&Z.div({text:`${F[1]}`,padding:[1,0,0,0]})}),Z.div();else if(m.length){let F=null;L._?F=`${E} <${t("command")}>
14
+ `:F=`${E} [${t("command")}]
15
+ `,Z.div(`${F}`)}}if(m.length>1||m.length===1&&!m[0][2]){Z.div(t("Commands:"));let F=i.getInternalMethods().getContext(),J=F.commands.length?`${F.commands.join(" ")} `:"";i.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(m=m.sort((B,ee)=>B[0].localeCompare(ee[0])));let k=E?`${E} `:"";m.forEach(B=>{let ee=`${k}${J}${B[0].replace(/^\$0 ?/,"")}`;Z.span({text:ee,padding:[0,2,0,2],width:N(m,Ue,`${E}${J}`)+4},{text:B[1]});let ne=[];B[2]&&ne.push(`[${t("default")}]`),B[3]&&B[3].length&&ne.push(`[${t("aliases:")} ${B[3].join(", ")}]`),B[4]&&(typeof B[4]=="string"?ne.push(`[${t("deprecated: %s",B[4])}]`):ne.push(`[${t("deprecated")}]`)),ne.length?Z.div({text:ne.join(" "),padding:[0,0,0,2],align:"right"}):Z.div()}),Z.div()}let Ie=(Object.keys(V.alias)||[]).concat(Object.keys(i.parsed.newAliases)||[]);re=re.filter(F=>!i.parsed.newAliases[F]&&Ie.every(J=>(V.alias[J]||[]).indexOf(F)===-1));let ve=t("Options:");se[ve]||(se[ve]=[]),z(re,V.alias,se,ve);let Be=F=>/^--/.test(Dt(F)),R=Object.keys(se).filter(F=>se[F].length>0).map(F=>{let J=se[F].filter(le).map(k=>{if(Ie.includes(k))return k;for(let B=0,ee;(ee=Ie[B])!==void 0;B++)if((V.alias[ee]||[]).includes(k))return ee;return k});return{groupName:F,normalizedKeys:J}}).filter(({normalizedKeys:F})=>F.length>0).map(({groupName:F,normalizedKeys:J})=>{let k=J.reduce((B,ee)=>(B[ee]=[ee].concat(V.alias[ee]||[]).map(ne=>F===n.getPositionalGroupName()?ne:(/^[0-9]$/.test(ne)?V.boolean.includes(ee)?"-":"--":ne.length>1?"--":"-")+ne).sort((ne,Ce)=>Be(ne)===Be(Ce)?0:Be(ne)?1:-1).join(", "),B),{});return{groupName:F,normalizedKeys:J,switches:k}});if(R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).some(({normalizedKeys:F,switches:J})=>!F.every(k=>Be(J[k])))&&R.filter(({groupName:F})=>F!==n.getPositionalGroupName()).forEach(({normalizedKeys:F,switches:J})=>{F.forEach(k=>{Be(J[k])&&(J[k]=Ar(J[k],4))})}),R.forEach(({groupName:F,normalizedKeys:J,switches:k})=>{Z.div(F),J.forEach(B=>{let ee=k[B],ne=w[B]||"",Ce=null;ne.includes(x)&&(ne=t(ne.substring(x.length))),V.boolean.includes(B)&&(Ce=`[${t("boolean")}]`),V.count.includes(B)&&(Ce=`[${t("count")}]`),V.string.includes(B)&&(Ce=`[${t("string")}]`),V.normalize.includes(B)&&(Ce=`[${t("string")}]`),V.array.includes(B)&&(Ce=`[${t("array")}]`),V.number.includes(B)&&(Ce=`[${t("number")}]`);let xe=d=>typeof d=="string"?`[${t("deprecated: %s",d)}]`:`[${t("deprecated")}]`,yt=[B in H?xe(H[B]):null,Ce,B in M?`[${t("required")}]`:null,V.choices&&V.choices[B]?`[${t("choices:")} ${n.stringifiedValues(V.choices[B])}]`:null,ce(V.default[B],V.defaultDescription[B])].filter(Boolean).join(" ");Z.span({text:Dt(ee),padding:[0,2,0,2+Ei(ee)],width:N(k,Ue)+4},ne);let l=i.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;yt&&!l?Z.div({text:yt,padding:[0,0,0,2],align:"right"}):Z.div()}),Z.div()}),u.length&&(Z.div(t("Examples:")),u.forEach(F=>{F[0]=F[0].replace(/\$0/g,E)}),u.forEach(F=>{F[1]===""?Z.div({text:F[0],padding:[0,2,0,2]}):Z.div({text:F[0],padding:[0,2,0,2],width:N(u,Ue)+4},{text:F[1]})}),Z.div()),C.length>0){let F=C.map(J=>J.replace(/\$0/g,E)).join(`
16
16
  `);Z.div(`${F}
17
- `)}return Z.toString().replace(/\s*$/,"")};function B(v,x,P){let U=0;return Array.isArray(v)||(v=Object.values(v).map(Y=>[Y])),v.forEach(Y=>{U=Math.max(e.stringWidth(P?`${P} ${Dt(Y[0])}`:Dt(Y[0]))+Ei(Y[0]),U)}),x&&(U=Math.min(U,parseInt((x*.5).toString(),10))),U}function S(){let v=i.getDemandedOptions(),x=i.getOptions();(Object.keys(x.alias)||[]).forEach(P=>{x.alias[P].forEach(U=>{w[U]&&n.describe(P,w[U]),U in v&&i.demandOption(P,v[U]),x.boolean.includes(U)&&i.boolean(P),x.count.includes(U)&&i.count(P),x.string.includes(U)&&i.string(P),x.normalize.includes(U)&&i.normalize(P),x.array.includes(U)&&i.array(P),x.number.includes(U)&&i.number(P)})})}let A;n.cacheHelpMessage=function(){A=this.help()},n.clearCachedHelpMessage=function(){A=void 0},n.hasCachedHelpMessage=function(){return!!A};function T(v,x,P,U){let Y=[],se=null;return Object.keys(P).forEach(z=>{Y=Y.concat(P[z])}),v.forEach(z=>{se=[z].concat(x[z]),se.some(re=>Y.indexOf(re)!==-1)||P[U].push(z)}),Y}function ce(v){return i.getOptions().hiddenOptions.indexOf(v)<0||i.parsed.argv[i.getOptions().showHiddenOpt]}n.showHelp=v=>{let x=i.getInternalMethods().getLoggerInstance();v||(v="error"),(typeof v=="function"?v:x[v])(n.help())},n.functionDescription=v=>["(",v.name?e.Parser.decamelize(v.name,"-"):t("generated-value"),")"].join(""),n.stringifiedValues=function(x,P){let U="",Y=P||", ",se=[].concat(x);return!x||!se.length||se.forEach(z=>{U.length&&(U+=Y),U+=JSON.stringify(z)}),U};function oe(v,x){let P=`[${t("default:")} `;if(v===void 0&&!x)return null;if(x)P+=x;else switch(typeof v){case"string":P+=`"${v}"`;break;case"object":P+=JSON.stringify(v);break;default:P+=v}return`${P}]`}function be(){return e.process.stdColumns?Math.min(80,e.process.stdColumns):80}let he=null;n.version=v=>{he=v},n.showVersion=v=>{let x=i.getInternalMethods().getLoggerInstance();v||(v="error"),(typeof v=="function"?v:x[v])(he)},n.reset=function(x){return r=null,g=!1,b=[],m=!1,C=[],h=[],d=[],w=De(w,P=>!x[P]),n};let H=[];return n.freeze=function(){H.push({failMessage:r,failureOutput:g,usages:b,usageDisabled:m,epilogs:C,examples:h,commands:d,descriptions:w})},n.unfreeze=function(x=!1){let P=H.pop();P&&(x?(w={...P.descriptions,...w},d=[...P.commands,...d],b=[...P.usages,...b],h=[...P.examples,...h],C=[...P.epilogs,...C]):{failMessage:r,failureOutput:g,usages:b,usageDisabled:m,epilogs:C,examples:h,commands:d,descriptions:w}=P)},n}function bn(i){return typeof i=="object"}function Er(i,e){return bn(i)?{text:i.text,indentation:i.indentation+e}:{text:i,indentation:e}}function Ei(i){return bn(i)?i.indentation:0}function Dt(i){return bn(i)?i.text:i}var Si=`###-begin-{{app_name}}-completions-###
17
+ `)}return Z.toString().replace(/\s*$/,"")};function N(I,E,M){let L=0;return Array.isArray(I)||(I=Object.values(I).map(H=>[H])),I.forEach(H=>{L=Math.max(e.stringWidth(M?`${M} ${Dt(H[0])}`:Dt(H[0]))+Ei(H[0]),L)}),E&&(L=Math.min(L,parseInt((E*.5).toString(),10))),L}function U(){let I=i.getDemandedOptions(),E=i.getOptions();(Object.keys(E.alias)||[]).forEach(M=>{E.alias[M].forEach(L=>{w[L]&&n.describe(M,w[L]),L in I&&i.demandOption(M,I[L]),E.boolean.includes(L)&&i.boolean(M),E.count.includes(L)&&i.count(M),E.string.includes(L)&&i.string(M),E.normalize.includes(L)&&i.normalize(M),E.array.includes(L)&&i.array(M),E.number.includes(L)&&i.number(M)})})}let W;n.cacheHelpMessage=function(){W=this.help()},n.clearCachedHelpMessage=function(){W=void 0},n.hasCachedHelpMessage=function(){return!!W};function z(I,E,M,L){let H=[],se=null;return Object.keys(M).forEach(V=>{H=H.concat(M[V])}),I.forEach(V=>{se=[V].concat(E[V]),se.some(re=>H.indexOf(re)!==-1)||M[L].push(V)}),H}function le(I){return i.getOptions().hiddenOptions.indexOf(I)<0||i.parsed.argv[i.getOptions().showHiddenOpt]}n.showHelp=I=>{let E=i.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:E[I])(n.help())},n.functionDescription=I=>["(",I.name?e.Parser.decamelize(I.name,"-"):t("generated-value"),")"].join(""),n.stringifiedValues=function(E,M){let L="",H=M||", ",se=[].concat(E);return!E||!se.length||se.forEach(V=>{L.length&&(L+=H),L+=JSON.stringify(V)}),L};function ce(I,E){let M=`[${t("default:")} `;if(I===void 0&&!E)return null;if(E)M+=E;else switch(typeof I){case"string":M+=`"${I}"`;break;case"object":M+=JSON.stringify(I);break;default:M+=I}return`${M}]`}function tt(){return e.process.stdColumns?Math.min(80,e.process.stdColumns):80}let We=null;n.version=I=>{We=I},n.showVersion=I=>{let E=i.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:E[I])(We)},n.reset=function(E){return r=null,b=!1,g=[],p=!1,C=[],u=[],m=[],w=Fe(w,M=>!E[M]),n};let Y=[];return n.freeze=function(){Y.push({failMessage:r,failureOutput:b,usages:g,usageDisabled:p,epilogs:C,examples:u,commands:m,descriptions:w})},n.unfreeze=function(E=!1){let M=Y.pop();M&&(E?(w={...M.descriptions,...w},m=[...M.commands,...m],g=[...M.usages,...g],u=[...M.examples,...u],C=[...M.epilogs,...C]):{failMessage:r,failureOutput:b,usages:g,usageDisabled:p,epilogs:C,examples:u,commands:m,descriptions:w}=M)},n}function yn(i){return typeof i=="object"}function Ar(i,e){return yn(i)?{text:i.text,indentation:i.indentation+e}:{text:i,indentation:e}}function Ei(i){return yn(i)?i.indentation:0}function Dt(i){return yn(i)?i.text:i}var Si=`###-begin-{{app_name}}-completions-###
18
18
  #
19
19
  # yargs command completion script
20
20
  #
@@ -61,16 +61,17 @@ _{{app_name}}_yargs_completions()
61
61
  }
62
62
  compdef _{{app_name}}_yargs_completions {{app_name}}
63
63
  ###-end-{{app_name}}-completions-###
64
- `;var yn=class{constructor(e,t,n,s){var r,a,c;this.yargs=e,this.usage=t,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(c=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((a=this.shim.getEnv("ZSH_NAME"))===null||a===void 0?void 0:a.includes("zsh")))!==null&&c!==void 0?c:!1}defaultCompletion(e,t,n,s){let r=this.command.getCommandHandlers();for(let c=0,g=e.length;c<g;++c)if(r[e[c]]&&r[e[c]].builder){let b=r[e[c]].builder;if(Rt(b)){this.indexAfterLastReset=c+1;let m=this.yargs.getInternalMethods().reset();return b(m,!0),m.argv}}let a=[];this.commandCompletions(a,e,n),this.optionCompletions(a,e,t,n),this.choicesFromOptionsCompletions(a,e,t,n),this.choicesFromPositionalsCompletions(a,e,t,n),s(null,a)}commandCompletions(e,t,n){let s=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&s[s.length-1]!==n&&!this.previousArgHasChoices(t)&&this.usage.getCommands().forEach(r=>{let a=Re(r[0]).cmd;if(t.indexOf(a)===-1)if(!this.zshShell)e.push(a);else{let c=r[1]||"";e.push(a.replace(/:/g,"\\:")+":"+c)}})}optionCompletions(e,t,n,s){if((s.match(/^-/)||s===""&&e.length===0)&&!this.previousArgHasChoices(t)){let r=this.yargs.getOptions(),a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach(c=>{let g=!!r.configuration["boolean-negation"]&&r.boolean.includes(c);!a.includes(c)&&!r.hiddenOptions.includes(c)&&!this.argsContainKey(t,c,g)&&this.completeOptionKey(c,e,s,g&&!!r.default[c])})}}choicesFromOptionsCompletions(e,t,n,s){if(this.previousArgHasChoices(t)){let r=this.getPreviousArgChoices(t);r&&r.length>0&&e.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,s){if(s===""&&e.length>0&&this.previousArgHasChoices(t))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],a=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),c=r[n._.length-a-1];if(!c)return;let g=this.yargs.getOptions().choices[c]||[];for(let b of g)b.startsWith(s)&&e.push(b.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1&&(n=t,t=e[e.length-2]),!t.startsWith("-"))return;let s=t.replace(/^-+/,""),r=this.yargs.getOptions(),a=[s,...this.yargs.getAliases()[s]||[]],c;for(let g of a)if(Object.prototype.hasOwnProperty.call(r.key,g)&&Array.isArray(r.choices[g])){c=r.choices[g];break}if(c)return c.filter(g=>!n||g.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let s=r=>e.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(s(t)||n&&s(`no-${t}`))return!0;if(this.aliases){for(let r of this.aliases[t])if(s(r))return!0}return!1}completeOptionKey(e,t,n,s){var r,a,c,g;let b=e;if(this.zshShell){let w=this.usage.getDescriptions(),C=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[e])===null||a===void 0?void 0:a.find(W=>{let B=w[W];return typeof B=="string"&&B.length>0}),_=C?w[C]:void 0,p=(g=(c=w[e])!==null&&c!==void 0?c:_)!==null&&g!==void 0?g:"";b=`${e.replace(/:/g,"\\:")}:${p.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let m=w=>/^--/.test(w),h=w=>/^[^0-9]$/.test(w),d=!m(n)&&h(e)?"-":"--";t.push(d+b),s&&t.push(d+"no-"+b)}customCompletion(e,t,n,s){if(ue(this.customCompletionFunction,null,this.shim),Sr(this.customCompletionFunction)){let r=this.customCompletionFunction(n,t);return K(r)?r.then(a=>{this.shim.process.nextTick(()=>{s(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{s(a,void 0)})}):s(null,r)}else return jr(this.customCompletionFunction)?this.customCompletionFunction(n,t,(r=s)=>this.defaultCompletion(e,t,n,r),r=>{s(null,r)}):this.customCompletionFunction(n,t,r=>{s(null,r)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",s=this.yargs.parse(e,!0),r=this.customCompletionFunction?a=>this.customCompletion(e,a,n,t):a=>this.defaultCompletion(e,a,n,t);return K(s)?s.then(r):r(s)}generateCompletionScript(e,t){let n=this.zshShell?ji:Si,s=this.shim.path.basename(e);return e.match(/\.js$/)&&(e=`./${e}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}};function Mi(i,e,t,n){return new yn(i,e,t,n)}function Sr(i){return i.length<3}function jr(i){return i.length>3}function Pi(i,e){if(i.length===0)return e.length;if(e.length===0)return i.length;let t=[],n;for(n=0;n<=e.length;n++)t[n]=[n];let s;for(s=0;s<=i.length;s++)t[0][s]=s;for(n=1;n<=e.length;n++)for(s=1;s<=i.length;s++)e.charAt(n-1)===i.charAt(s-1)?t[n][s]=t[n-1][s-1]:n>1&&s>1&&e.charAt(n-2)===i.charAt(s-1)&&e.charAt(n-1)===i.charAt(s-2)?t[n][s]=t[n-2][s-2]+1:t[n][s]=Math.min(t[n-1][s-1]+1,Math.min(t[n][s-1]+1,t[n-1][s]+1));return t[e.length][i.length]}var Ii=["$0","--","_"];function vi(i,e,t){let n=t.y18n.__,s=t.y18n.__n,r={};r.nonOptionCount=function(h){let d=i.getDemandedCommands(),C=h._.length+(h["--"]?h["--"].length:0)-i.getInternalMethods().getContext().commands.length;d._&&(C<d._.min||C>d._.max)&&(C<d._.min?d._.minMsg!==void 0?e.fail(d._.minMsg?d._.minMsg.replace(/\$0/g,C.toString()).replace(/\$1/,d._.min.toString()):null):e.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",C,C.toString(),d._.min.toString())):C>d._.max&&(d._.maxMsg!==void 0?e.fail(d._.maxMsg?d._.maxMsg.replace(/\$0/g,C.toString()).replace(/\$1/,d._.max.toString()):null):e.fail(s("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",C,C.toString(),d._.max.toString()))))},r.positionalCount=function(h,d){d<h&&e.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",d,d+"",h+""))},r.requiredArguments=function(h,d){let w=null;for(let C of Object.keys(d))(!Object.prototype.hasOwnProperty.call(h,C)||typeof h[C]>"u")&&(w=w||{},w[C]=d[C]);if(w){let C=[];for(let p of Object.keys(w)){let W=w[p];W&&C.indexOf(W)<0&&C.push(W)}let _=C.length?`
64
+ `;var wn=class{constructor(e,t,n,s){var r,a,c;this.yargs=e,this.usage=t,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(c=((r=this.shim.getEnv("SHELL"))===null||r===void 0?void 0:r.includes("zsh"))||((a=this.shim.getEnv("ZSH_NAME"))===null||a===void 0?void 0:a.includes("zsh")))!==null&&c!==void 0?c:!1}defaultCompletion(e,t,n,s){let r=this.command.getCommandHandlers();for(let c=0,b=e.length;c<b;++c)if(r[e[c]]&&r[e[c]].builder){let g=r[e[c]].builder;if(Rt(g)){this.indexAfterLastReset=c+1;let p=this.yargs.getInternalMethods().reset();return g(p,!0),p.argv}}let a=[];this.commandCompletions(a,e,n),this.optionCompletions(a,e,t,n),this.choicesFromOptionsCompletions(a,e,t,n),this.choicesFromPositionalsCompletions(a,e,t,n),s(null,a)}commandCompletions(e,t,n){let s=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&s[s.length-1]!==n&&!this.previousArgHasChoices(t)&&this.usage.getCommands().forEach(r=>{let a=Ne(r[0]).cmd;if(t.indexOf(a)===-1)if(!this.zshShell)e.push(a);else{let c=r[1]||"";e.push(a.replace(/:/g,"\\:")+":"+c)}})}optionCompletions(e,t,n,s){if((s.match(/^-/)||s===""&&e.length===0)&&!this.previousArgHasChoices(t)){let r=this.yargs.getOptions(),a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach(c=>{let b=!!r.configuration["boolean-negation"]&&r.boolean.includes(c);!a.includes(c)&&!r.hiddenOptions.includes(c)&&!this.argsContainKey(t,c,b)&&this.completeOptionKey(c,e,s,b&&!!r.default[c])})}}choicesFromOptionsCompletions(e,t,n,s){if(this.previousArgHasChoices(t)){let r=this.getPreviousArgChoices(t);r&&r.length>0&&e.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,s){if(s===""&&e.length>0&&this.previousArgHasChoices(t))return;let r=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],a=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),c=r[n._.length-a-1];if(!c)return;let b=this.yargs.getOptions().choices[c]||[];for(let g of b)g.startsWith(s)&&e.push(g.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1&&(n=t,t=e[e.length-2]),!t.startsWith("-"))return;let s=t.replace(/^-+/,""),r=this.yargs.getOptions(),a=[s,...this.yargs.getAliases()[s]||[]],c;for(let b of a)if(Object.prototype.hasOwnProperty.call(r.key,b)&&Array.isArray(r.choices[b])){c=r.choices[b];break}if(c)return c.filter(b=>!n||b.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let s=r=>e.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(s(t)||n&&s(`no-${t}`))return!0;if(this.aliases){for(let r of this.aliases[t])if(s(r))return!0}return!1}completeOptionKey(e,t,n,s){var r,a,c,b;let g=e;if(this.zshShell){let w=this.usage.getDescriptions(),C=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[e])===null||a===void 0?void 0:a.find(x=>{let N=w[x];return typeof N=="string"&&N.length>0}),O=C?w[C]:void 0,f=(b=(c=w[e])!==null&&c!==void 0?c:O)!==null&&b!==void 0?b:"";g=`${e.replace(/:/g,"\\:")}:${f.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=w=>/^--/.test(w),u=w=>/^[^0-9]$/.test(w),m=!p(n)&&u(e)?"-":"--";t.push(m+g),s&&t.push(m+"no-"+g)}customCompletion(e,t,n,s){if(ue(this.customCompletionFunction,null,this.shim),jr(this.customCompletionFunction)){let r=this.customCompletionFunction(n,t);return K(r)?r.then(a=>{this.shim.process.nextTick(()=>{s(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{s(a,void 0)})}):s(null,r)}else return Mr(this.customCompletionFunction)?this.customCompletionFunction(n,t,(r=s)=>this.defaultCompletion(e,t,n,r),r=>{s(null,r)}):this.customCompletionFunction(n,t,r=>{s(null,r)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",s=this.yargs.parse(e,!0),r=this.customCompletionFunction?a=>this.customCompletion(e,a,n,t):a=>this.defaultCompletion(e,a,n,t);return K(s)?s.then(r):r(s)}generateCompletionScript(e,t){let n=this.zshShell?ji:Si,s=this.shim.path.basename(e);return e.match(/\.js$/)&&(e=`./${e}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}};function Mi(i,e,t,n){return new wn(i,e,t,n)}function jr(i){return i.length<3}function Mr(i){return i.length>3}function Pi(i,e){if(i.length===0)return e.length;if(e.length===0)return i.length;let t=[],n;for(n=0;n<=e.length;n++)t[n]=[n];let s;for(s=0;s<=i.length;s++)t[0][s]=s;for(n=1;n<=e.length;n++)for(s=1;s<=i.length;s++)e.charAt(n-1)===i.charAt(s-1)?t[n][s]=t[n-1][s-1]:n>1&&s>1&&e.charAt(n-2)===i.charAt(s-1)&&e.charAt(n-1)===i.charAt(s-2)?t[n][s]=t[n-2][s-2]+1:t[n][s]=Math.min(t[n-1][s-1]+1,Math.min(t[n][s-1]+1,t[n-1][s]+1));return t[e.length][i.length]}var Ii=["$0","--","_"];function vi(i,e,t){let n=t.y18n.__,s=t.y18n.__n,r={};r.nonOptionCount=function(u){let m=i.getDemandedCommands(),C=u._.length+(u["--"]?u["--"].length:0)-i.getInternalMethods().getContext().commands.length;m._&&(C<m._.min||C>m._.max)&&(C<m._.min?m._.minMsg!==void 0?e.fail(m._.minMsg?m._.minMsg.replace(/\$0/g,C.toString()).replace(/\$1/,m._.min.toString()):null):e.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",C,C.toString(),m._.min.toString())):C>m._.max&&(m._.maxMsg!==void 0?e.fail(m._.maxMsg?m._.maxMsg.replace(/\$0/g,C.toString()).replace(/\$1/,m._.max.toString()):null):e.fail(s("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",C,C.toString(),m._.max.toString()))))},r.positionalCount=function(u,m){m<u&&e.fail(s("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m+"",u+""))},r.requiredArguments=function(u,m){let w=null;for(let C of Object.keys(m))(!Object.prototype.hasOwnProperty.call(u,C)||typeof u[C]>"u")&&(w=w||{},w[C]=m[C]);if(w){let C=[];for(let f of Object.keys(w)){let x=w[f];x&&C.indexOf(x)<0&&C.push(x)}let O=C.length?`
65
65
  ${C.join(`
66
- `)}`:"";e.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(w).length,Object.keys(w).join(", ")+_))}},r.unknownArguments=function(h,d,w,C,_=!0){var p;let W=i.getInternalMethods().getCommandInstance().getCommands(),B=[],S=i.getInternalMethods().getContext();if(Object.keys(h).forEach(A=>{!Ii.includes(A)&&!Object.prototype.hasOwnProperty.call(w,A)&&!Object.prototype.hasOwnProperty.call(i.getInternalMethods().getParseContext(),A)&&!r.isValidAndSomeAliasIsNotNew(A,d)&&B.push(A)}),_&&(S.commands.length>0||W.length>0||C)&&h._.slice(S.commands.length).forEach(A=>{W.includes(""+A)||B.push(""+A)}),_){let T=((p=i.getDemandedCommands()._)===null||p===void 0?void 0:p.max)||0,ce=S.commands.length+T;ce<h._.length&&h._.slice(ce).forEach(oe=>{oe=String(oe),!S.commands.includes(oe)&&!B.includes(oe)&&B.push(oe)})}B.length&&e.fail(s("Unknown argument: %s","Unknown arguments: %s",B.length,B.map(A=>A.trim()?A:`"${A}"`).join(", ")))},r.unknownCommands=function(h){let d=i.getInternalMethods().getCommandInstance().getCommands(),w=[],C=i.getInternalMethods().getContext();return(C.commands.length>0||d.length>0)&&h._.slice(C.commands.length).forEach(_=>{d.includes(""+_)||w.push(""+_)}),w.length>0?(e.fail(s("Unknown command: %s","Unknown commands: %s",w.length,w.join(", "))),!0):!1},r.isValidAndSomeAliasIsNotNew=function(h,d){if(!Object.prototype.hasOwnProperty.call(d,h))return!1;let w=i.parsed.newAliases;return[h,...d[h]].some(C=>!Object.prototype.hasOwnProperty.call(w,C)||!w[h])},r.limitedChoices=function(h){let d=i.getOptions(),w={};if(!Object.keys(d.choices).length)return;Object.keys(h).forEach(p=>{Ii.indexOf(p)===-1&&Object.prototype.hasOwnProperty.call(d.choices,p)&&[].concat(h[p]).forEach(W=>{d.choices[p].indexOf(W)===-1&&W!==void 0&&(w[p]=(w[p]||[]).concat(W))})});let C=Object.keys(w);if(!C.length)return;let _=n("Invalid values:");C.forEach(p=>{_+=`
67
- ${n("Argument: %s, Given: %s, Choices: %s",p,e.stringifiedValues(w[p]),e.stringifiedValues(d.choices[p]))}`}),e.fail(_)};let a={};r.implies=function(h,d){j("<string|object> [array|number|string]",[h,d],arguments.length),typeof h=="object"?Object.keys(h).forEach(w=>{r.implies(w,h[w])}):(i.global(h),a[h]||(a[h]=[]),Array.isArray(d)?d.forEach(w=>r.implies(h,w)):(ue(d,void 0,t),a[h].push(d)))},r.getImplied=function(){return a};function c(m,h){let d=Number(h);return h=isNaN(d)?h:d,typeof h=="number"?h=m._.length>=h:h.match(/^--no-.+/)?(h=h.match(/^--no-(.+)/)[1],h=!Object.prototype.hasOwnProperty.call(m,h)):h=Object.prototype.hasOwnProperty.call(m,h),h}r.implications=function(h){let d=[];if(Object.keys(a).forEach(w=>{let C=w;(a[w]||[]).forEach(_=>{let p=C,W=_;p=c(h,p),_=c(h,_),p&&!_&&d.push(` ${C} -> ${W}`)})}),d.length){let w=`${n("Implications failed:")}
68
- `;d.forEach(C=>{w+=C}),e.fail(w)}};let g={};r.conflicts=function(h,d){j("<string|object> [array|string]",[h,d],arguments.length),typeof h=="object"?Object.keys(h).forEach(w=>{r.conflicts(w,h[w])}):(i.global(h),g[h]||(g[h]=[]),Array.isArray(d)?d.forEach(w=>r.conflicts(h,w)):g[h].push(d))},r.getConflicting=()=>g,r.conflicting=function(h){Object.keys(h).forEach(d=>{g[d]&&g[d].forEach(w=>{w&&h[d]!==void 0&&h[w]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",d,w))})}),i.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(g).forEach(d=>{g[d].forEach(w=>{w&&h[t.Parser.camelCase(d)]!==void 0&&h[t.Parser.camelCase(w)]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",d,w))})})},r.recommendCommands=function(h,d){d=d.sort((p,W)=>W.length-p.length);let C=null,_=1/0;for(let p=0,W;(W=d[p])!==void 0;p++){let B=Pi(h,W);B<=3&&B<_&&(_=B,C=W)}C&&e.fail(n("Did you mean %s?",C))},r.reset=function(h){return a=De(a,d=>!h[d]),g=De(g,d=>!h[d]),r};let b=[];return r.freeze=function(){b.push({implied:a,conflicting:g})},r.unfreeze=function(){let h=b.pop();ue(h,void 0,t),{implied:a,conflicting:g}=h},r}var wn=[],mt;function gt(i,e,t,n){mt=n;let s={};if(Object.prototype.hasOwnProperty.call(i,"extends")){if(typeof i.extends!="string")return s;let r=/\.json|\..*rc$/.test(i.extends),a=null;if(r)a=Pr(e,i.extends);else try{a=Me.resolve(i.extends)}catch{return i}Mr(a),wn.push(a),s=r?JSON.parse(mt.readFileSync(a,"utf8")):Me(i.extends),delete i.extends,s=gt(s,mt.path.dirname(a),t,mt)}return wn=[],t?$i(s,i):Object.assign({},s,i)}function Mr(i){if(wn.indexOf(i)>-1)throw new q(`Circular extended configurations: '${i}'.`)}function Pr(i,e){return mt.path.resolve(i,e)}function $i(i,e){let t={};function n(s){return s&&typeof s=="object"&&!Array.isArray(s)}Object.assign(t,i);for(let s of Object.keys(e))n(e[s])&&n(t[s])?t[s]=$i(i[s],e[s]):t[s]=e[s];return t}var M=function(i,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t},o=function(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)},ie,Ge,bt,Oe,pe,Tt,Le,qe,Lt,_e,Wt,Ce,Ie,me,xe,Ut,at,le,$,Bt,Vt,ge,Ke,lt,Je,We,zt,D,Qe,Ze,Xe,L,Ht,ve,te;function Xi(i){return(e=[],t=i.process.cwd(),n)=>{let s=new In(e,t,n,i);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var Ni=Symbol("copyDoubleDash"),Fi=Symbol("copyDoubleDash"),On=Symbol("deleteFromParserHintObject"),Ri=Symbol("emitWarning"),Di=Symbol("freeze"),Ti=Symbol("getDollarZero"),ke=Symbol("getParserConfiguration"),Li=Symbol("getUsageConfiguration"),_n=Symbol("guessLocale"),Wi=Symbol("guessVersion"),Ui=Symbol("parsePositionalNumbers"),Cn=Symbol("pkgUp"),Ue=Symbol("populateParserHintArray"),ct=Symbol("populateParserHintSingleValueDictionary"),xn=Symbol("populateParserHintArrayDictionary"),En=Symbol("populateParserHintDictionary"),An=Symbol("sanitizeKey"),Sn=Symbol("setKey"),jn=Symbol("unfreeze"),Bi=Symbol("validateAsync"),Vi=Symbol("getCommandInstance"),zi=Symbol("getContext"),Hi=Symbol("getHasOutput"),Yi=Symbol("getLoggerInstance"),Gi=Symbol("getParseContext"),qi=Symbol("getUsageInstance"),Ki=Symbol("getValidationInstance"),Yt=Symbol("hasParseCallback"),Ji=Symbol("isGlobalContext"),et=Symbol("postProcess"),Qi=Symbol("rebase"),Mn=Symbol("reset"),yt=Symbol("runYargsParserAndExecuteCommands"),Pn=Symbol("runValidation"),Zi=Symbol("setHasOutput"),tt=Symbol("kTrackManuallySetKeys"),In=class{constructor(e=[],t,n,s){this.customScriptName=!1,this.parsed=!1,ie.set(this,void 0),Ge.set(this,void 0),bt.set(this,{commands:[],fullCommands:[]}),Oe.set(this,null),pe.set(this,null),Tt.set(this,"show-hidden"),Le.set(this,null),qe.set(this,!0),Lt.set(this,{}),_e.set(this,!0),Wt.set(this,[]),Ce.set(this,void 0),Ie.set(this,{}),me.set(this,!1),xe.set(this,null),Ut.set(this,!0),at.set(this,void 0),le.set(this,""),$.set(this,void 0),Bt.set(this,void 0),Vt.set(this,{}),ge.set(this,null),Ke.set(this,null),lt.set(this,{}),Je.set(this,{}),We.set(this,void 0),zt.set(this,!1),D.set(this,void 0),Qe.set(this,!1),Ze.set(this,!1),Xe.set(this,!1),L.set(this,void 0),Ht.set(this,{}),ve.set(this,null),te.set(this,void 0),M(this,D,s,"f"),M(this,We,e,"f"),M(this,Ge,t,"f"),M(this,Bt,n,"f"),M(this,Ce,new Ft(this),"f"),this.$0=this[Ti](),this[Mn](),M(this,ie,o(this,ie,"f"),"f"),M(this,L,o(this,L,"f"),"f"),M(this,te,o(this,te,"f"),"f"),M(this,$,o(this,$,"f"),"f"),o(this,$,"f").showHiddenOpt=o(this,Tt,"f"),M(this,at,this[Fi](),"f")}addHelpOpt(e,t){let n="help";return j("[string|boolean] [string]",[e,t],arguments.length),o(this,xe,"f")&&(this[On](o(this,xe,"f")),M(this,xe,null,"f")),e===!1&&t===void 0?this:(M(this,xe,typeof e=="string"?e:n,"f"),this.boolean(o(this,xe,"f")),this.describe(o(this,xe,"f"),t||o(this,L,"f").deferY18nLookup("Show help")),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(j("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e=="string"?e:o(this,Tt,"f");return this.boolean(n),this.describe(n,t||o(this,L,"f").deferY18nLookup("Show hidden options")),o(this,$,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return j("<object|string|array> [string|array]",[e,t],arguments.length),this[xn](this.alias.bind(this),"alias",e,t),this}array(e){return j("<array|string>",[e],arguments.length),this[Ue]("array",e),this[tt](e),this}boolean(e){return j("<array|string>",[e],arguments.length),this[Ue]("boolean",e),this[tt](e),this}check(e,t){return j("<function> [boolean]",[e,t],arguments.length),this.middleware((n,s)=>Ye(()=>e(n,s.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,L,"f").fail(r.toString(),r):o(this,L,"f").fail(o(this,D,"f").y18n.__("Argument check failed: %s",e.toString())),n),r=>(o(this,L,"f").fail(r.message?r.message:r.toString(),r),n)),!1,t),this}choices(e,t){return j("<object|string|array> [string|array]",[e,t],arguments.length),this[xn](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(j("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new q("coerce callback must be provided");for(let n of e)this.coerce(n,t);return this}else if(typeof e=="object"){for(let n of Object.keys(e))this.coerce(n,e[n]);return this}if(!t)throw new q("coerce callback must be provided");return o(this,$,"f").key[e]=!0,o(this,Ce,"f").addCoerceMiddleware((n,s)=>{let r;return Object.prototype.hasOwnProperty.call(n,e)?Ye(()=>(r=s.getAliases(),t(n[e])),c=>{n[e]=c;let g=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[e]&&g!==!0)for(let b of r[e])n[b]=c;return n},c=>{throw new q(c.message)}):n},e),this}conflicts(e,t){return j("<string|object> [string|array]",[e,t],arguments.length),o(this,te,"f").conflicts(e,t),this}config(e="config",t,n){return j("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e=="object"&&!Array.isArray(e)?(e=gt(e,o(this,Ge,"f"),this[ke]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,$,"f").configObjects=(o(this,$,"f").configObjects||[]).concat(e),this):(typeof t=="function"&&(n=t,t=void 0),this.describe(e,t||o(this,L,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach(s=>{o(this,$,"f").config[s]=n||!0}),this)}completion(e,t,n){return j("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t=="function"&&(n=t,t=void 0),M(this,pe,e||o(this,pe,"f")||"completion","f"),!t&&t!==!1&&(t="generate completion script"),this.command(o(this,pe,"f"),t),n&&o(this,Oe,"f").registerFunction(n),this}command(e,t,n,s,r,a){return j("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,s,r,a],arguments.length),o(this,ie,"f").addHandler(e,t,n,s,r,a),this}commands(e,t,n,s,r,a){return this.command(e,t,n,s,r,a)}commandDir(e,t){j("<string> [object]",[e,t],arguments.length);let n=o(this,Bt,"f")||o(this,D,"f").require;return o(this,ie,"f").addDirectory(e,n,o(this,D,"f").getCallerFile(),t),this}count(e){return j("<array|string>",[e],arguments.length),this[Ue]("count",e),this[tt](e),this}default(e,t,n){return j("<object|string|array> [*] [string]",[e,t,n],arguments.length),n&&(pn(e,o(this,D,"f")),o(this,$,"f").defaultDescription[e]=n),typeof t=="function"&&(pn(e,o(this,D,"f")),o(this,$,"f").defaultDescription[e]||(o(this,$,"f").defaultDescription[e]=o(this,L,"f").functionDescription(t)),t=t.call()),this[ct](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,s){return j("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,s],arguments.length),typeof t!="number"&&(n=t,t=1/0),this.global("_",!1),o(this,$,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:s},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(s=>{ue(n,!0,o(this,D,"f")),this.demandOption(s,n)}),t=1/0):typeof t!="number"&&(n=t,t=1/0),typeof e=="number"?(ue(n,!0,o(this,D,"f")),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(s=>{ue(n,!0,o(this,D,"f")),this.demandOption(s,n)}):typeof n=="string"?this.demandOption(e,n):(n===!0||typeof n>"u")&&this.demandOption(e),this}demandOption(e,t){return j("<object|string|array> [string]",[e,t],arguments.length),this[ct](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return j("<string> [string|boolean]",[e,t],arguments.length),o(this,$,"f").deprecatedOptions[e]=t,this}describe(e,t){return j("<object|string|array> [string]",[e,t],arguments.length),this[Sn](e,!0),o(this,L,"f").describe(e,t),this}detectLocale(e){return j("<boolean>",[e],arguments.length),M(this,qe,e,"f"),this}env(e){return j("[string|boolean]",[e],arguments.length),e===!1?delete o(this,$,"f").envPrefix:o(this,$,"f").envPrefix=e||"",this}epilogue(e){return j("<string>",[e],arguments.length),o(this,L,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return j("<string|array> [string]",[e,t],arguments.length),Array.isArray(e)?e.forEach(n=>this.example(...n)):o(this,L,"f").example(e,t),this}exit(e,t){M(this,me,!0,"f"),M(this,Le,t,"f"),o(this,_e,"f")&&o(this,D,"f").process.exit(e)}exitProcess(e=!0){return j("[boolean]",[e],arguments.length),M(this,_e,e,"f"),this}fail(e){if(j("<function|boolean>",[e],arguments.length),typeof e=="boolean"&&e!==!1)throw new q("Invalid first argument. Expected function or boolean 'false'");return o(this,L,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return j("<array> [function]",[e,t],arguments.length),t?o(this,Oe,"f").getCompletion(e,t):new Promise((n,s)=>{o(this,Oe,"f").getCompletion(e,(r,a)=>{r?s(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,$,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,$,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,$,"f").deprecatedOptions}getDetectLocale(){return o(this,qe,"f")}getExitProcess(){return o(this,_e,"f")}getGroups(){return Object.assign({},o(this,Ie,"f"),o(this,Je,"f"))}getHelp(){if(M(this,me,!0,"f"),!o(this,L,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[yt](o(this,We,"f"),void 0,void 0,0,!0);if(K(t))return t.then(()=>o(this,L,"f").help())}let e=o(this,ie,"f").runDefaultBuilderOn(this);if(K(e))return e.then(()=>o(this,L,"f").help())}return Promise.resolve(o(this,L,"f").help())}getOptions(){return o(this,$,"f")}getStrict(){return o(this,Qe,"f")}getStrictCommands(){return o(this,Ze,"f")}getStrictOptions(){return o(this,Xe,"f")}global(e,t){return j("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1?o(this,$,"f").local=o(this,$,"f").local.filter(n=>e.indexOf(n)===-1):e.forEach(n=>{o(this,$,"f").local.includes(n)||o(this,$,"f").local.push(n)}),this}group(e,t){j("<string|array> <string>",[e,t],arguments.length);let n=o(this,Je,"f")[t]||o(this,Ie,"f")[t];o(this,Je,"f")[t]&&delete o(this,Je,"f")[t];let s={};return o(this,Ie,"f")[t]=(n||[]).concat(e).filter(r=>s[r]?!1:s[r]=!0),this}hide(e){return j("<string>",[e],arguments.length),o(this,$,"f").hiddenOptions.push(e),this}implies(e,t){return j("<string|object> [number|string|array]",[e,t],arguments.length),o(this,te,"f").implies(e,t),this}locale(e){return j("[string]",[e],arguments.length),e===void 0?(this[_n](),o(this,D,"f").y18n.getLocale()):(M(this,qe,!1,"f"),o(this,D,"f").y18n.setLocale(e),this)}middleware(e,t,n){return o(this,Ce,"f").addMiddleware(e,!!t,n)}nargs(e,t){return j("<string|object|array> [number]",[e,t],arguments.length),this[ct](this.nargs.bind(this),"narg",e,t),this}normalize(e){return j("<array|string>",[e],arguments.length),this[Ue]("normalize",e),this}number(e){return j("<array|string>",[e],arguments.length),this[Ue]("number",e),this[tt](e),this}option(e,t){if(j("<string|object> [object]",[e,t],arguments.length),typeof e=="object")Object.keys(e).forEach(n=>{this.options(n,e[n])});else{typeof t!="object"&&(t={}),this[tt](e),o(this,ve,"f")&&(e==="version"||(t==null?void 0:t.alias)==="version")&&this[Ri](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
69
- `),void 0,"versionWarning"),o(this,$,"f").key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let s=t.demand||t.required||t.require;s&&this.demand(e,s),t.demandOption&&this.demandOption(e,typeof t.demandOption=="string"?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),"default"in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type==="boolean")&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type==="array")&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type==="number")&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type==="string")&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type==="count")&&this.count(e),typeof t.global=="boolean"&&this.global(e,t.global),t.defaultDescription&&(o(this,$,"f").defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let r=t.describe||t.description||t.desc,a=o(this,L,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,e)||typeof r=="string")&&this.describe(e,r),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){j("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[Di](),typeof e>"u"&&(e=o(this,We,"f")),typeof t=="object"&&(M(this,Ke,t,"f"),t=n),typeof t=="function"&&(M(this,ge,t,"f"),t=!1),t||M(this,We,e,"f"),o(this,ge,"f")&&M(this,_e,!1,"f");let s=this[yt](e,!!t),r=this.parsed;return o(this,Oe,"f").setParsed(this.parsed),K(s)?s.then(a=>(o(this,ge,"f")&&o(this,ge,"f").call(this,o(this,Le,"f"),a,o(this,le,"f")),a)).catch(a=>{throw o(this,ge,"f")&&o(this,ge,"f")(a,this.parsed.argv,o(this,le,"f")),a}).finally(()=>{this[jn](),this.parsed=r}):(o(this,ge,"f")&&o(this,ge,"f").call(this,o(this,Le,"f"),s,o(this,le,"f")),this[jn](),this.parsed=r,s)}parseAsync(e,t,n){let s=this.parse(e,t,n);return K(s)?s:Promise.resolve(s)}parseSync(e,t,n){let s=this.parse(e,t,n);if(K(s))throw new q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(e){return j("<object>",[e],arguments.length),M(this,Vt,e,"f"),this}pkgConf(e,t){j("<string> [string]",[e,t],arguments.length);let n=null,s=this[Cn](t||o(this,Ge,"f"));return s[e]&&typeof s[e]=="object"&&(n=gt(s[e],t||o(this,Ge,"f"),this[ke]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,$,"f").configObjects=(o(this,$,"f").configObjects||[]).concat(n)),this}positional(e,t){j("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=De(t,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!1:n.includes(a));let s=o(this,bt,"f").fullCommands[o(this,bt,"f").fullCommands.length-1],r=s?o(this,ie,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return rt(r).forEach(a=>{let c=r[a];Array.isArray(c)?c.indexOf(e)!==-1&&(t[a]=!0):c[e]&&!(a in t)&&(t[a]=c[e])}),this.group(e,o(this,L,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return j("[boolean]",[e],arguments.length),M(this,zt,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return j("<array|string|object> [number]",[e],arguments.length),typeof e=="string"&&o(this,$,"f").narg[e]?this:(this[ct](this.requiresArg.bind(this),"narg",e,NaN),this)}showCompletionScript(e,t){return j("[string] [string]",[e,t],arguments.length),e=e||this.$0,o(this,at,"f").log(o(this,Oe,"f").generateCompletionScript(e,t||o(this,pe,"f")||"completion")),this}showHelp(e){if(j("[string|function]",[e],arguments.length),M(this,me,!0,"f"),!o(this,L,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[yt](o(this,We,"f"),void 0,void 0,0,!0);if(K(n))return n.then(()=>{o(this,L,"f").showHelp(e)}),this}let t=o(this,ie,"f").runDefaultBuilderOn(this);if(K(t))return t.then(()=>{o(this,L,"f").showHelp(e)}),this}return o(this,L,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return j("[boolean|string] [string]",[e,t],arguments.length),o(this,L,"f").showHelpOnFail(e,t),this}showVersion(e){return j("[string|function]",[e],arguments.length),o(this,L,"f").showVersion(e),this}skipValidation(e){return j("<array|string>",[e],arguments.length),this[Ue]("skipValidation",e),this}strict(e){return j("[boolean]",[e],arguments.length),M(this,Qe,e!==!1,"f"),this}strictCommands(e){return j("[boolean]",[e],arguments.length),M(this,Ze,e!==!1,"f"),this}strictOptions(e){return j("[boolean]",[e],arguments.length),M(this,Xe,e!==!1,"f"),this}string(e){return j("<array|string>",[e],arguments.length),this[Ue]("string",e),this[tt](e),this}terminalWidth(){return j([],0),o(this,D,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return j("<object>",[e],arguments.length),M(this,qe,!1,"f"),o(this,D,"f").y18n.updateLocale(e),this}usage(e,t,n,s){if(j("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,s],arguments.length),t!==void 0){if(ue(e,null,o(this,D,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,s);throw new q(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,L,"f").usage(e),this}usageConfiguration(e){return j("<object>",[e],arguments.length),M(this,Ht,e,"f"),this}version(e,t,n){let s="version";if(j("[boolean|string] [string] [string]",[e,t,n],arguments.length),o(this,ve,"f")&&(this[On](o(this,ve,"f")),o(this,L,"f").version(void 0),M(this,ve,null,"f")),arguments.length===0)n=this[Wi](),e=s;else if(arguments.length===1){if(e===!1)return this;n=e,e=s}else arguments.length===2&&(n=t,t=void 0);return M(this,ve,typeof e=="string"?e:s,"f"),t=t||o(this,L,"f").deferY18nLookup("Show version number"),o(this,L,"f").version(n||void 0),this.boolean(o(this,ve,"f")),this.describe(o(this,ve,"f"),t),this}wrap(e){return j("<number|null|undefined>",[e],arguments.length),o(this,L,"f").wrap(e),this}[(ie=new WeakMap,Ge=new WeakMap,bt=new WeakMap,Oe=new WeakMap,pe=new WeakMap,Tt=new WeakMap,Le=new WeakMap,qe=new WeakMap,Lt=new WeakMap,_e=new WeakMap,Wt=new WeakMap,Ce=new WeakMap,Ie=new WeakMap,me=new WeakMap,xe=new WeakMap,Ut=new WeakMap,at=new WeakMap,le=new WeakMap,$=new WeakMap,Bt=new WeakMap,Vt=new WeakMap,ge=new WeakMap,Ke=new WeakMap,lt=new WeakMap,Je=new WeakMap,We=new WeakMap,zt=new WeakMap,D=new WeakMap,Qe=new WeakMap,Ze=new WeakMap,Xe=new WeakMap,L=new WeakMap,Ht=new WeakMap,ve=new WeakMap,te=new WeakMap,Ni)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch{}return e}[Fi](){return{log:(...e)=>{this[Yt]()||console.log(...e),M(this,me,!0,"f"),o(this,le,"f").length&&M(this,le,o(this,le,"f")+`
70
- `,"f"),M(this,le,o(this,le,"f")+e.join(" "),"f")},error:(...e)=>{this[Yt]()||console.error(...e),M(this,me,!0,"f"),o(this,le,"f").length&&M(this,le,o(this,le,"f")+`
71
- `,"f"),M(this,le,o(this,le,"f")+e.join(" "),"f")}}}[On](e){rt(o(this,$,"f")).forEach(t=>{if((s=>s==="configObjects")(t))return;let n=o(this,$,"f")[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n=="object"&&delete n[e]}),delete o(this,L,"f").getDescriptions()[e]}[Ri](e,t,n){o(this,Lt,"f")[n]||(o(this,D,"f").process.emitWarning(e,t),o(this,Lt,"f")[n]=!0)}[Di](){o(this,Wt,"f").push({options:o(this,$,"f"),configObjects:o(this,$,"f").configObjects.slice(0),exitProcess:o(this,_e,"f"),groups:o(this,Ie,"f"),strict:o(this,Qe,"f"),strictCommands:o(this,Ze,"f"),strictOptions:o(this,Xe,"f"),completionCommand:o(this,pe,"f"),output:o(this,le,"f"),exitError:o(this,Le,"f"),hasOutput:o(this,me,"f"),parsed:this.parsed,parseFn:o(this,ge,"f"),parseContext:o(this,Ke,"f")}),o(this,L,"f").freeze(),o(this,te,"f").freeze(),o(this,ie,"f").freeze(),o(this,Ce,"f").freeze()}[Ti](){let e="",t;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,D,"f").process.argv()[0])?t=o(this,D,"f").process.argv().slice(1,2):t=o(this,D,"f").process.argv().slice(0,1),e=t.map(n=>{let s=this[Qi](o(this,Ge,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&s.length<n.length?s:n}).join(" ").trim(),o(this,D,"f").getEnv("_")&&o(this,D,"f").getProcessArgvBin()===o(this,D,"f").getEnv("_")&&(e=o(this,D,"f").getEnv("_").replace(`${o(this,D,"f").path.dirname(o(this,D,"f").process.execPath())}/`,"")),e}[ke](){return o(this,Vt,"f")}[Li](){return o(this,Ht,"f")}[_n](){if(!o(this,qe,"f"))return;let e=o(this,D,"f").getEnv("LC_ALL")||o(this,D,"f").getEnv("LC_MESSAGES")||o(this,D,"f").getEnv("LANG")||o(this,D,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Wi](){return this[Cn]().version||"unknown"}[Ui](e){let t=e["--"]?e["--"]:e._;for(let n=0,s;(s=t[n])!==void 0;n++)o(this,D,"f").Parser.looksLikeNumber(s)&&Number.isSafeInteger(Math.floor(parseFloat(`${s}`)))&&(t[n]=Number(s));return e}[Cn](e){let t=e||"*";if(o(this,lt,"f")[t])return o(this,lt,"f")[t];let n={};try{let s=e||o(this,D,"f").mainFilename;!e&&o(this,D,"f").path.extname(s)&&(s=o(this,D,"f").path.dirname(s));let r=o(this,D,"f").findUp(s,(a,c)=>{if(c.includes("package.json"))return"package.json"});ue(r,void 0,o(this,D,"f")),n=JSON.parse(o(this,D,"f").readFileSync(r,"utf8"))}catch{}return o(this,lt,"f")[t]=n||{},o(this,lt,"f")[t]}[Ue](e,t){t=[].concat(t),t.forEach(n=>{n=this[An](n),o(this,$,"f")[e].push(n)})}[ct](e,t,n,s){this[En](e,t,n,s,(r,a,c)=>{o(this,$,"f")[r][a]=c})}[xn](e,t,n,s){this[En](e,t,n,s,(r,a,c)=>{o(this,$,"f")[r][a]=(o(this,$,"f")[r][a]||[]).concat(c)})}[En](e,t,n,s,r){if(Array.isArray(n))n.forEach(a=>{e(a,s)});else if((a=>typeof a=="object")(n))for(let a of rt(n))e(a,n[a]);else r(t,this[An](n),s)}[An](e){return e==="__proto__"?"___proto___":e}[Sn](e,t){return this[ct](this[Sn].bind(this),"key",e,t),this}[jn](){var e,t,n,s,r,a,c,g,b,m,h,d;let w=o(this,Wt,"f").pop();ue(w,void 0,o(this,D,"f"));let C;e=this,t=this,n=this,s=this,r=this,a=this,c=this,g=this,b=this,m=this,h=this,d=this,{options:{set value(_){M(e,$,_,"f")}}.value,configObjects:C,exitProcess:{set value(_){M(t,_e,_,"f")}}.value,groups:{set value(_){M(n,Ie,_,"f")}}.value,output:{set value(_){M(s,le,_,"f")}}.value,exitError:{set value(_){M(r,Le,_,"f")}}.value,hasOutput:{set value(_){M(a,me,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){M(c,Qe,_,"f")}}.value,strictCommands:{set value(_){M(g,Ze,_,"f")}}.value,strictOptions:{set value(_){M(b,Xe,_,"f")}}.value,completionCommand:{set value(_){M(m,pe,_,"f")}}.value,parseFn:{set value(_){M(h,ge,_,"f")}}.value,parseContext:{set value(_){M(d,Ke,_,"f")}}.value}=w,o(this,$,"f").configObjects=C,o(this,L,"f").unfreeze(),o(this,te,"f").unfreeze(),o(this,ie,"f").unfreeze(),o(this,Ce,"f").unfreeze()}[Bi](e,t){return Ye(t,n=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[Vi].bind(this),getContext:this[zi].bind(this),getHasOutput:this[Hi].bind(this),getLoggerInstance:this[Yi].bind(this),getParseContext:this[Gi].bind(this),getParserConfiguration:this[ke].bind(this),getUsageConfiguration:this[Li].bind(this),getUsageInstance:this[qi].bind(this),getValidationInstance:this[Ki].bind(this),hasParseCallback:this[Yt].bind(this),isGlobalContext:this[Ji].bind(this),postProcess:this[et].bind(this),reset:this[Mn].bind(this),runValidation:this[Pn].bind(this),runYargsParserAndExecuteCommands:this[yt].bind(this),setHasOutput:this[Zi].bind(this)}}[Vi](){return o(this,ie,"f")}[zi](){return o(this,bt,"f")}[Hi](){return o(this,me,"f")}[Yi](){return o(this,at,"f")}[Gi](){return o(this,Ke,"f")||{}}[qi](){return o(this,L,"f")}[Ki](){return o(this,te,"f")}[Yt](){return!!o(this,ge,"f")}[Ji](){return o(this,Ut,"f")}[et](e,t,n,s){return n||K(e)||(t||(e=this[Ni](e)),(this[ke]()["parse-positional-numbers"]||this[ke]()["parse-positional-numbers"]===void 0)&&(e=this[Ui](e)),s&&(e=He(e,this,o(this,Ce,"f").getMiddleware(),!1))),e}[Mn](e={}){M(this,$,o(this,$,"f")||{},"f");let t={};t.local=o(this,$,"f").local||[],t.configObjects=o(this,$,"f").configObjects||[];let n={};t.local.forEach(a=>{n[a]=!0,(e[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Je,"f"),Object.keys(o(this,Ie,"f")).reduce((a,c)=>{let g=o(this,Ie,"f")[c].filter(b=>!(b in n));return g.length>0&&(a[c]=g),a},{})),M(this,Ie,{},"f");let s=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return s.forEach(a=>{t[a]=(o(this,$,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{t[a]=De(o(this,$,"f")[a],c=>!n[c])}),t.envPrefix=o(this,$,"f").envPrefix,M(this,$,t,"f"),M(this,L,o(this,L,"f")?o(this,L,"f").reset(n):Ai(this,o(this,D,"f")),"f"),M(this,te,o(this,te,"f")?o(this,te,"f").reset(n):vi(this,o(this,L,"f"),o(this,D,"f")),"f"),M(this,ie,o(this,ie,"f")?o(this,ie,"f").reset():Ci(o(this,L,"f"),o(this,te,"f"),o(this,Ce,"f"),o(this,D,"f")),"f"),o(this,Oe,"f")||M(this,Oe,Mi(this,o(this,L,"f"),o(this,ie,"f"),o(this,D,"f")),"f"),o(this,Ce,"f").reset(),M(this,pe,null,"f"),M(this,le,"","f"),M(this,Le,null,"f"),M(this,me,!1,"f"),this.parsed=!1,this}[Qi](e,t){return o(this,D,"f").path.relative(e,t)}[yt](e,t,n,s=0,r=!1){let a=!!n||r;e=e||o(this,We,"f"),o(this,$,"f").__=o(this,D,"f").y18n.__,o(this,$,"f").configuration=this[ke]();let c=!!o(this,$,"f").configuration["populate--"],g=Object.assign({},o(this,$,"f").configuration,{"populate--":!0}),b=o(this,D,"f").Parser.detailed(e,Object.assign({},o(this,$,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),m=Object.assign(b.argv,o(this,Ke,"f")),h,d=b.aliases,w=!1,C=!1;Object.keys(m).forEach(_=>{_===o(this,xe,"f")&&m[_]?w=!0:_===o(this,ve,"f")&&m[_]&&(C=!0)}),m.$0=this.$0,this.parsed=b,s===0&&o(this,L,"f").clearCachedHelpMessage();try{if(this[_n](),t)return this[et](m,c,!!n,!1);o(this,xe,"f")&&[o(this,xe,"f")].concat(d[o(this,xe,"f")]||[]).filter(S=>S.length>1).includes(""+m._[m._.length-1])&&(m._.pop(),w=!0),M(this,Ut,!1,"f");let _=o(this,ie,"f").getCommands(),p=o(this,Oe,"f").completionKey in m,W=w||p||r;if(m._.length){if(_.length){let B;for(let S=s||0,A;m._[S]!==void 0;S++)if(A=String(m._[S]),_.includes(A)&&A!==o(this,pe,"f")){let T=o(this,ie,"f").runCommand(A,this,b,S+1,r,w||C||r);return this[et](T,c,!!n,!1)}else if(!B&&A!==o(this,pe,"f")){B=A;break}!o(this,ie,"f").hasDefaultCommand()&&o(this,zt,"f")&&B&&!W&&o(this,te,"f").recommendCommands(B,_)}o(this,pe,"f")&&m._.includes(o(this,pe,"f"))&&!p&&(o(this,_e,"f")&&Te(!0),this.showCompletionScript(),this.exit(0))}if(o(this,ie,"f").hasDefaultCommand()&&!W){let B=o(this,ie,"f").runCommand(null,this,b,0,r,w||C||r);return this[et](B,c,!!n,!1)}if(p){o(this,_e,"f")&&Te(!0),e=[].concat(e);let B=e.slice(e.indexOf(`--${o(this,Oe,"f").completionKey}`)+1);return o(this,Oe,"f").getCompletion(B,(S,A)=>{if(S)throw new q(S.message);(A||[]).forEach(T=>{o(this,at,"f").log(T)}),this.exit(0)}),this[et](m,!c,!!n,!1)}if(o(this,me,"f")||(w?(o(this,_e,"f")&&Te(!0),a=!0,this.showHelp("log"),this.exit(0)):C&&(o(this,_e,"f")&&Te(!0),a=!0,o(this,L,"f").showVersion("log"),this.exit(0))),!a&&o(this,$,"f").skipValidation.length>0&&(a=Object.keys(m).some(B=>o(this,$,"f").skipValidation.indexOf(B)>=0&&m[B]===!0)),!a){if(b.error)throw new q(b.error.message);if(!p){let B=this[Pn](d,{},b.error);n||(h=He(m,this,o(this,Ce,"f").getMiddleware(),!0)),h=this[Bi](B,h??m),K(h)&&!n&&(h=h.then(()=>He(m,this,o(this,Ce,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof q)o(this,L,"f").fail(_.message,_);else throw _}return this[et](h??m,c,!!n,!0)}[Pn](e,t,n,s){let r={...this.getDemandedOptions()};return a=>{if(n)throw new q(n.message);o(this,te,"f").nonOptionCount(a),o(this,te,"f").requiredArguments(a,r);let c=!1;o(this,Ze,"f")&&(c=o(this,te,"f").unknownCommands(a)),o(this,Qe,"f")&&!c?o(this,te,"f").unknownArguments(a,e,t,!!s):o(this,Xe,"f")&&o(this,te,"f").unknownArguments(a,e,{},!1,!1),o(this,te,"f").limitedChoices(a),o(this,te,"f").implications(a),o(this,te,"f").conflicting(a)}}[Zi](){M(this,me,!0,"f")}[tt](e){if(typeof e=="string")o(this,$,"f").key[e]=!0;else for(let t of e)o(this,$,"f").key[t]=!0}};function xi(i){return!!i&&typeof i.getInternalMethods=="function"}var Ir=Xi(dn),ki=Ir;var vr=performance.now(),es=ki(un(process.argv));await es.scriptName("vidup").usage("$0 [command]","Run a vidup command.").command(["$0 <directory> [options]","sync <directory> [options]"],"Synchronize a remote video streaming service to mirror the contents of a local directory.",i=>i.positional("directory",{default:void 0,demandOption:!0,describe:"The path to the local directory of video files to sync.",type:"string"}).option("service",{alias:"s",choices:["bunny","mux","cloudflare"],demandOption:!0,describe:"Streaming service to sync to. Only the Bunny.net streaming CDN is supported at this time.",type:"string"}).option("key",{default:void 0,demandOption:!0,describe:"Streaming service API access key",type:"string"}).option("library",{default:void 0,demandOption:!0,describe:"Streaming service library ID",type:"string"}).option("strip-metadata",{default:!0,describe:"Remove all metadata from the video files before uploading them to the streaming service.",type:"boolean"}).option("dry-run",{alias:"d",default:!1,describe:"Perform a dry run without making any changes. Useful for testing and debugging.",type:"boolean"}).option("json",{default:!1,describe:"Output the sync report as JSON",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection.",type:"boolean"}).check(e=>{if(e.service==="bunny")return e;throw new Error(`Sorry, vidup doesn't yet implement synchronization support the ${e.service} streaming service. Only Bunny.net is supported at the moment. If you'd like to see support for another service, please open an issue or send a PR on GitHub: https://github.com/kitschpatrol/vidup/issues`)}),async({directory:i,dryRun:e,json:t,key:n,library:s,service:r,stripMetadata:a,verbose:c})=>{G.verbose=c,G.info("Starting video synchronization..."),e&&G.warn("Dry run enabled, not making any changes");let g=await kt(i,{credentials:{key:n,library:s},dryRun:e,service:r,stripMetadata:a,verbose:c});if(t)process.stdout.write(JSON.stringify(g,void 0,2)),process.stdout.write(`
72
- `);else for(let b of g)process.stdout.write(`${b.action}: ${b.localFile}
73
- `);G.info(`Synchronized video in ${tn(performance.now()-vr)}`),process.exitCode=0}).demandCommand(1).alias("h","help").version("version").alias("v","version").help().wrap(process.stdout.isTTY?Math.min(120,es.terminalWidth()):0).parse();
66
+ `)}`:"";e.fail(s("Missing required argument: %s","Missing required arguments: %s",Object.keys(w).length,Object.keys(w).join(", ")+O))}},r.unknownArguments=function(u,m,w,C,O=!0){var f;let x=i.getInternalMethods().getCommandInstance().getCommands(),N=[],U=i.getInternalMethods().getContext();if(Object.keys(u).forEach(W=>{!Ii.includes(W)&&!Object.prototype.hasOwnProperty.call(w,W)&&!Object.prototype.hasOwnProperty.call(i.getInternalMethods().getParseContext(),W)&&!r.isValidAndSomeAliasIsNotNew(W,m)&&N.push(W)}),O&&(U.commands.length>0||x.length>0||C)&&u._.slice(U.commands.length).forEach(W=>{x.includes(""+W)||N.push(""+W)}),O){let z=((f=i.getDemandedCommands()._)===null||f===void 0?void 0:f.max)||0,le=U.commands.length+z;le<u._.length&&u._.slice(le).forEach(ce=>{ce=String(ce),!U.commands.includes(ce)&&!N.includes(ce)&&N.push(ce)})}N.length&&e.fail(s("Unknown argument: %s","Unknown arguments: %s",N.length,N.map(W=>W.trim()?W:`"${W}"`).join(", ")))},r.unknownCommands=function(u){let m=i.getInternalMethods().getCommandInstance().getCommands(),w=[],C=i.getInternalMethods().getContext();return(C.commands.length>0||m.length>0)&&u._.slice(C.commands.length).forEach(O=>{m.includes(""+O)||w.push(""+O)}),w.length>0?(e.fail(s("Unknown command: %s","Unknown commands: %s",w.length,w.join(", "))),!0):!1},r.isValidAndSomeAliasIsNotNew=function(u,m){if(!Object.prototype.hasOwnProperty.call(m,u))return!1;let w=i.parsed.newAliases;return[u,...m[u]].some(C=>!Object.prototype.hasOwnProperty.call(w,C)||!w[u])},r.limitedChoices=function(u){let m=i.getOptions(),w={};if(!Object.keys(m.choices).length)return;Object.keys(u).forEach(f=>{Ii.indexOf(f)===-1&&Object.prototype.hasOwnProperty.call(m.choices,f)&&[].concat(u[f]).forEach(x=>{m.choices[f].indexOf(x)===-1&&x!==void 0&&(w[f]=(w[f]||[]).concat(x))})});let C=Object.keys(w);if(!C.length)return;let O=n("Invalid values:");C.forEach(f=>{O+=`
67
+ ${n("Argument: %s, Given: %s, Choices: %s",f,e.stringifiedValues(w[f]),e.stringifiedValues(m.choices[f]))}`}),e.fail(O)};let a={};r.implies=function(u,m){S("<string|object> [array|number|string]",[u,m],arguments.length),typeof u=="object"?Object.keys(u).forEach(w=>{r.implies(w,u[w])}):(i.global(u),a[u]||(a[u]=[]),Array.isArray(m)?m.forEach(w=>r.implies(u,w)):(ue(m,void 0,t),a[u].push(m)))},r.getImplied=function(){return a};function c(p,u){let m=Number(u);return u=isNaN(m)?u:m,typeof u=="number"?u=p._.length>=u:u.match(/^--no-.+/)?(u=u.match(/^--no-(.+)/)[1],u=!Object.prototype.hasOwnProperty.call(p,u)):u=Object.prototype.hasOwnProperty.call(p,u),u}r.implications=function(u){let m=[];if(Object.keys(a).forEach(w=>{let C=w;(a[w]||[]).forEach(O=>{let f=C,x=O;f=c(u,f),O=c(u,O),f&&!O&&m.push(` ${C} -> ${x}`)})}),m.length){let w=`${n("Implications failed:")}
68
+ `;m.forEach(C=>{w+=C}),e.fail(w)}};let b={};r.conflicts=function(u,m){S("<string|object> [array|string]",[u,m],arguments.length),typeof u=="object"?Object.keys(u).forEach(w=>{r.conflicts(w,u[w])}):(i.global(u),b[u]||(b[u]=[]),Array.isArray(m)?m.forEach(w=>r.conflicts(u,w)):b[u].push(m))},r.getConflicting=()=>b,r.conflicting=function(u){Object.keys(u).forEach(m=>{b[m]&&b[m].forEach(w=>{w&&u[m]!==void 0&&u[w]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",m,w))})}),i.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(b).forEach(m=>{b[m].forEach(w=>{w&&u[t.Parser.camelCase(m)]!==void 0&&u[t.Parser.camelCase(w)]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",m,w))})})},r.recommendCommands=function(u,m){m=m.sort((f,x)=>x.length-f.length);let C=null,O=1/0;for(let f=0,x;(x=m[f])!==void 0;f++){let N=Pi(u,x);N<=3&&N<O&&(O=N,C=x)}C&&e.fail(n("Did you mean %s?",C))},r.reset=function(u){return a=Fe(a,m=>!u[m]),b=Fe(b,m=>!u[m]),r};let g=[];return r.freeze=function(){g.push({implied:a,conflicting:b})},r.unfreeze=function(){let u=g.pop();ue(u,void 0,t),{implied:a,conflicting:b}=u},r}var On=[],pt;function mt(i,e,t,n){pt=n;let s={};if(Object.prototype.hasOwnProperty.call(i,"extends")){if(typeof i.extends!="string")return s;let r=/\.json|\..*rc$/.test(i.extends),a=null;if(r)a=Ir(e,i.extends);else try{a=Se.resolve(i.extends)}catch{return i}Pr(a),On.push(a),s=r?JSON.parse(pt.readFileSync(a,"utf8")):Se(i.extends),delete i.extends,s=mt(s,pt.path.dirname(a),t,pt)}return On=[],t?$i(s,i):Object.assign({},s,i)}function Pr(i){if(On.indexOf(i)>-1)throw new q(`Circular extended configurations: '${i}'.`)}function Ir(i,e){return pt.path.resolve(i,e)}function $i(i,e){let t={};function n(s){return s&&typeof s=="object"&&!Array.isArray(s)}Object.assign(t,i);for(let s of Object.keys(e))n(e[s])&&n(t[s])?t[s]=$i(i[s],e[s]):t[s]=e[s];return t}var j=function(i,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t},o=function(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)},ie,Ge,gt,ye,de,Tt,De,Ye,Lt,we,Wt,Oe,Me,pe,_e,Ut,ot,ae,v,Bt,zt,me,qe,at,Ke,Te,Vt,D,Je,Qe,Ze,T,Ht,Pe,te;function Xi(i){return(e=[],t=i.process.cwd(),n)=>{let s=new vn(e,t,n,i);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s}}var Ni=Symbol("copyDoubleDash"),Fi=Symbol("copyDoubleDash"),_n=Symbol("deleteFromParserHintObject"),Ri=Symbol("emitWarning"),Di=Symbol("freeze"),Ti=Symbol("getDollarZero"),Xe=Symbol("getParserConfiguration"),Li=Symbol("getUsageConfiguration"),Cn=Symbol("guessLocale"),Wi=Symbol("guessVersion"),Ui=Symbol("parsePositionalNumbers"),xn=Symbol("pkgUp"),Le=Symbol("populateParserHintArray"),lt=Symbol("populateParserHintSingleValueDictionary"),En=Symbol("populateParserHintArrayDictionary"),An=Symbol("populateParserHintDictionary"),Sn=Symbol("sanitizeKey"),jn=Symbol("setKey"),Mn=Symbol("unfreeze"),Bi=Symbol("validateAsync"),zi=Symbol("getCommandInstance"),Vi=Symbol("getContext"),Hi=Symbol("getHasOutput"),Gi=Symbol("getLoggerInstance"),Yi=Symbol("getParseContext"),qi=Symbol("getUsageInstance"),Ki=Symbol("getValidationInstance"),Gt=Symbol("hasParseCallback"),Ji=Symbol("isGlobalContext"),ke=Symbol("postProcess"),Qi=Symbol("rebase"),Pn=Symbol("reset"),bt=Symbol("runYargsParserAndExecuteCommands"),In=Symbol("runValidation"),Zi=Symbol("setHasOutput"),et=Symbol("kTrackManuallySetKeys"),vn=class{constructor(e=[],t,n,s){this.customScriptName=!1,this.parsed=!1,ie.set(this,void 0),Ge.set(this,void 0),gt.set(this,{commands:[],fullCommands:[]}),ye.set(this,null),de.set(this,null),Tt.set(this,"show-hidden"),De.set(this,null),Ye.set(this,!0),Lt.set(this,{}),we.set(this,!0),Wt.set(this,[]),Oe.set(this,void 0),Me.set(this,{}),pe.set(this,!1),_e.set(this,null),Ut.set(this,!0),ot.set(this,void 0),ae.set(this,""),v.set(this,void 0),Bt.set(this,void 0),zt.set(this,{}),me.set(this,null),qe.set(this,null),at.set(this,{}),Ke.set(this,{}),Te.set(this,void 0),Vt.set(this,!1),D.set(this,void 0),Je.set(this,!1),Qe.set(this,!1),Ze.set(this,!1),T.set(this,void 0),Ht.set(this,{}),Pe.set(this,null),te.set(this,void 0),j(this,D,s,"f"),j(this,Te,e,"f"),j(this,Ge,t,"f"),j(this,Bt,n,"f"),j(this,Oe,new Ft(this),"f"),this.$0=this[Ti](),this[Pn](),j(this,ie,o(this,ie,"f"),"f"),j(this,T,o(this,T,"f"),"f"),j(this,te,o(this,te,"f"),"f"),j(this,v,o(this,v,"f"),"f"),o(this,v,"f").showHiddenOpt=o(this,Tt,"f"),j(this,ot,this[Fi](),"f")}addHelpOpt(e,t){let n="help";return S("[string|boolean] [string]",[e,t],arguments.length),o(this,_e,"f")&&(this[_n](o(this,_e,"f")),j(this,_e,null,"f")),e===!1&&t===void 0?this:(j(this,_e,typeof e=="string"?e:n,"f"),this.boolean(o(this,_e,"f")),this.describe(o(this,_e,"f"),t||o(this,T,"f").deferY18nLookup("Show help")),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(S("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e=="string"?e:o(this,Tt,"f");return this.boolean(n),this.describe(n,t||o(this,T,"f").deferY18nLookup("Show hidden options")),o(this,v,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return S("<object|string|array> [string|array]",[e,t],arguments.length),this[En](this.alias.bind(this),"alias",e,t),this}array(e){return S("<array|string>",[e],arguments.length),this[Le]("array",e),this[et](e),this}boolean(e){return S("<array|string>",[e],arguments.length),this[Le]("boolean",e),this[et](e),this}check(e,t){return S("<function> [boolean]",[e,t],arguments.length),this.middleware((n,s)=>He(()=>e(n,s.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,T,"f").fail(r.toString(),r):o(this,T,"f").fail(o(this,D,"f").y18n.__("Argument check failed: %s",e.toString())),n),r=>(o(this,T,"f").fail(r.message?r.message:r.toString(),r),n)),!1,t),this}choices(e,t){return S("<object|string|array> [string|array]",[e,t],arguments.length),this[En](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(S("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new q("coerce callback must be provided");for(let n of e)this.coerce(n,t);return this}else if(typeof e=="object"){for(let n of Object.keys(e))this.coerce(n,e[n]);return this}if(!t)throw new q("coerce callback must be provided");return o(this,v,"f").key[e]=!0,o(this,Oe,"f").addCoerceMiddleware((n,s)=>{let r;return Object.prototype.hasOwnProperty.call(n,e)?He(()=>(r=s.getAliases(),t(n[e])),c=>{n[e]=c;let b=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[e]&&b!==!0)for(let g of r[e])n[g]=c;return n},c=>{throw new q(c.message)}):n},e),this}conflicts(e,t){return S("<string|object> [string|array]",[e,t],arguments.length),o(this,te,"f").conflicts(e,t),this}config(e="config",t,n){return S("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e=="object"&&!Array.isArray(e)?(e=mt(e,o(this,Ge,"f"),this[Xe]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,v,"f").configObjects=(o(this,v,"f").configObjects||[]).concat(e),this):(typeof t=="function"&&(n=t,t=void 0),this.describe(e,t||o(this,T,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach(s=>{o(this,v,"f").config[s]=n||!0}),this)}completion(e,t,n){return S("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t=="function"&&(n=t,t=void 0),j(this,de,e||o(this,de,"f")||"completion","f"),!t&&t!==!1&&(t="generate completion script"),this.command(o(this,de,"f"),t),n&&o(this,ye,"f").registerFunction(n),this}command(e,t,n,s,r,a){return S("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,s,r,a],arguments.length),o(this,ie,"f").addHandler(e,t,n,s,r,a),this}commands(e,t,n,s,r,a){return this.command(e,t,n,s,r,a)}commandDir(e,t){S("<string> [object]",[e,t],arguments.length);let n=o(this,Bt,"f")||o(this,D,"f").require;return o(this,ie,"f").addDirectory(e,n,o(this,D,"f").getCallerFile(),t),this}count(e){return S("<array|string>",[e],arguments.length),this[Le]("count",e),this[et](e),this}default(e,t,n){return S("<object|string|array> [*] [string]",[e,t,n],arguments.length),n&&(mn(e,o(this,D,"f")),o(this,v,"f").defaultDescription[e]=n),typeof t=="function"&&(mn(e,o(this,D,"f")),o(this,v,"f").defaultDescription[e]||(o(this,v,"f").defaultDescription[e]=o(this,T,"f").functionDescription(t)),t=t.call()),this[lt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,s){return S("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,s],arguments.length),typeof t!="number"&&(n=t,t=1/0),this.global("_",!1),o(this,v,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:s},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(s=>{ue(n,!0,o(this,D,"f")),this.demandOption(s,n)}),t=1/0):typeof t!="number"&&(n=t,t=1/0),typeof e=="number"?(ue(n,!0,o(this,D,"f")),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(s=>{ue(n,!0,o(this,D,"f")),this.demandOption(s,n)}):typeof n=="string"?this.demandOption(e,n):(n===!0||typeof n>"u")&&this.demandOption(e),this}demandOption(e,t){return S("<object|string|array> [string]",[e,t],arguments.length),this[lt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return S("<string> [string|boolean]",[e,t],arguments.length),o(this,v,"f").deprecatedOptions[e]=t,this}describe(e,t){return S("<object|string|array> [string]",[e,t],arguments.length),this[jn](e,!0),o(this,T,"f").describe(e,t),this}detectLocale(e){return S("<boolean>",[e],arguments.length),j(this,Ye,e,"f"),this}env(e){return S("[string|boolean]",[e],arguments.length),e===!1?delete o(this,v,"f").envPrefix:o(this,v,"f").envPrefix=e||"",this}epilogue(e){return S("<string>",[e],arguments.length),o(this,T,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return S("<string|array> [string]",[e,t],arguments.length),Array.isArray(e)?e.forEach(n=>this.example(...n)):o(this,T,"f").example(e,t),this}exit(e,t){j(this,pe,!0,"f"),j(this,De,t,"f"),o(this,we,"f")&&o(this,D,"f").process.exit(e)}exitProcess(e=!0){return S("[boolean]",[e],arguments.length),j(this,we,e,"f"),this}fail(e){if(S("<function|boolean>",[e],arguments.length),typeof e=="boolean"&&e!==!1)throw new q("Invalid first argument. Expected function or boolean 'false'");return o(this,T,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return S("<array> [function]",[e,t],arguments.length),t?o(this,ye,"f").getCompletion(e,t):new Promise((n,s)=>{o(this,ye,"f").getCompletion(e,(r,a)=>{r?s(r):n(a)})})}getDemandedOptions(){return S([],0),o(this,v,"f").demandedOptions}getDemandedCommands(){return S([],0),o(this,v,"f").demandedCommands}getDeprecatedOptions(){return S([],0),o(this,v,"f").deprecatedOptions}getDetectLocale(){return o(this,Ye,"f")}getExitProcess(){return o(this,we,"f")}getGroups(){return Object.assign({},o(this,Me,"f"),o(this,Ke,"f"))}getHelp(){if(j(this,pe,!0,"f"),!o(this,T,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[bt](o(this,Te,"f"),void 0,void 0,0,!0);if(K(t))return t.then(()=>o(this,T,"f").help())}let e=o(this,ie,"f").runDefaultBuilderOn(this);if(K(e))return e.then(()=>o(this,T,"f").help())}return Promise.resolve(o(this,T,"f").help())}getOptions(){return o(this,v,"f")}getStrict(){return o(this,Je,"f")}getStrictCommands(){return o(this,Qe,"f")}getStrictOptions(){return o(this,Ze,"f")}global(e,t){return S("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1?o(this,v,"f").local=o(this,v,"f").local.filter(n=>e.indexOf(n)===-1):e.forEach(n=>{o(this,v,"f").local.includes(n)||o(this,v,"f").local.push(n)}),this}group(e,t){S("<string|array> <string>",[e,t],arguments.length);let n=o(this,Ke,"f")[t]||o(this,Me,"f")[t];o(this,Ke,"f")[t]&&delete o(this,Ke,"f")[t];let s={};return o(this,Me,"f")[t]=(n||[]).concat(e).filter(r=>s[r]?!1:s[r]=!0),this}hide(e){return S("<string>",[e],arguments.length),o(this,v,"f").hiddenOptions.push(e),this}implies(e,t){return S("<string|object> [number|string|array]",[e,t],arguments.length),o(this,te,"f").implies(e,t),this}locale(e){return S("[string]",[e],arguments.length),e===void 0?(this[Cn](),o(this,D,"f").y18n.getLocale()):(j(this,Ye,!1,"f"),o(this,D,"f").y18n.setLocale(e),this)}middleware(e,t,n){return o(this,Oe,"f").addMiddleware(e,!!t,n)}nargs(e,t){return S("<string|object|array> [number]",[e,t],arguments.length),this[lt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return S("<array|string>",[e],arguments.length),this[Le]("normalize",e),this}number(e){return S("<array|string>",[e],arguments.length),this[Le]("number",e),this[et](e),this}option(e,t){if(S("<string|object> [object]",[e,t],arguments.length),typeof e=="object")Object.keys(e).forEach(n=>{this.options(n,e[n])});else{typeof t!="object"&&(t={}),this[et](e),o(this,Pe,"f")&&(e==="version"||(t==null?void 0:t.alias)==="version")&&this[Ri](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
69
+ `),void 0,"versionWarning"),o(this,v,"f").key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let s=t.demand||t.required||t.require;s&&this.demand(e,s),t.demandOption&&this.demandOption(e,typeof t.demandOption=="string"?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),"default"in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type==="boolean")&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type==="array")&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type==="number")&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type==="string")&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type==="count")&&this.count(e),typeof t.global=="boolean"&&this.global(e,t.global),t.defaultDescription&&(o(this,v,"f").defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let r=t.describe||t.description||t.desc,a=o(this,T,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,e)||typeof r=="string")&&this.describe(e,r),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){S("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[Di](),typeof e>"u"&&(e=o(this,Te,"f")),typeof t=="object"&&(j(this,qe,t,"f"),t=n),typeof t=="function"&&(j(this,me,t,"f"),t=!1),t||j(this,Te,e,"f"),o(this,me,"f")&&j(this,we,!1,"f");let s=this[bt](e,!!t),r=this.parsed;return o(this,ye,"f").setParsed(this.parsed),K(s)?s.then(a=>(o(this,me,"f")&&o(this,me,"f").call(this,o(this,De,"f"),a,o(this,ae,"f")),a)).catch(a=>{throw o(this,me,"f")&&o(this,me,"f")(a,this.parsed.argv,o(this,ae,"f")),a}).finally(()=>{this[Mn](),this.parsed=r}):(o(this,me,"f")&&o(this,me,"f").call(this,o(this,De,"f"),s,o(this,ae,"f")),this[Mn](),this.parsed=r,s)}parseAsync(e,t,n){let s=this.parse(e,t,n);return K(s)?s:Promise.resolve(s)}parseSync(e,t,n){let s=this.parse(e,t,n);if(K(s))throw new q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(e){return S("<object>",[e],arguments.length),j(this,zt,e,"f"),this}pkgConf(e,t){S("<string> [string]",[e,t],arguments.length);let n=null,s=this[xn](t||o(this,Ge,"f"));return s[e]&&typeof s[e]=="object"&&(n=mt(s[e],t||o(this,Ge,"f"),this[Xe]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,v,"f").configObjects=(o(this,v,"f").configObjects||[]).concat(n)),this}positional(e,t){S("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=Fe(t,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!1:n.includes(a));let s=o(this,gt,"f").fullCommands[o(this,gt,"f").fullCommands.length-1],r=s?o(this,ie,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return st(r).forEach(a=>{let c=r[a];Array.isArray(c)?c.indexOf(e)!==-1&&(t[a]=!0):c[e]&&!(a in t)&&(t[a]=c[e])}),this.group(e,o(this,T,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return S("[boolean]",[e],arguments.length),j(this,Vt,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return S("<array|string|object> [number]",[e],arguments.length),typeof e=="string"&&o(this,v,"f").narg[e]?this:(this[lt](this.requiresArg.bind(this),"narg",e,NaN),this)}showCompletionScript(e,t){return S("[string] [string]",[e,t],arguments.length),e=e||this.$0,o(this,ot,"f").log(o(this,ye,"f").generateCompletionScript(e,t||o(this,de,"f")||"completion")),this}showHelp(e){if(S("[string|function]",[e],arguments.length),j(this,pe,!0,"f"),!o(this,T,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[bt](o(this,Te,"f"),void 0,void 0,0,!0);if(K(n))return n.then(()=>{o(this,T,"f").showHelp(e)}),this}let t=o(this,ie,"f").runDefaultBuilderOn(this);if(K(t))return t.then(()=>{o(this,T,"f").showHelp(e)}),this}return o(this,T,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return S("[boolean|string] [string]",[e,t],arguments.length),o(this,T,"f").showHelpOnFail(e,t),this}showVersion(e){return S("[string|function]",[e],arguments.length),o(this,T,"f").showVersion(e),this}skipValidation(e){return S("<array|string>",[e],arguments.length),this[Le]("skipValidation",e),this}strict(e){return S("[boolean]",[e],arguments.length),j(this,Je,e!==!1,"f"),this}strictCommands(e){return S("[boolean]",[e],arguments.length),j(this,Qe,e!==!1,"f"),this}strictOptions(e){return S("[boolean]",[e],arguments.length),j(this,Ze,e!==!1,"f"),this}string(e){return S("<array|string>",[e],arguments.length),this[Le]("string",e),this[et](e),this}terminalWidth(){return S([],0),o(this,D,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return S("<object>",[e],arguments.length),j(this,Ye,!1,"f"),o(this,D,"f").y18n.updateLocale(e),this}usage(e,t,n,s){if(S("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,s],arguments.length),t!==void 0){if(ue(e,null,o(this,D,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,s);throw new q(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,T,"f").usage(e),this}usageConfiguration(e){return S("<object>",[e],arguments.length),j(this,Ht,e,"f"),this}version(e,t,n){let s="version";if(S("[boolean|string] [string] [string]",[e,t,n],arguments.length),o(this,Pe,"f")&&(this[_n](o(this,Pe,"f")),o(this,T,"f").version(void 0),j(this,Pe,null,"f")),arguments.length===0)n=this[Wi](),e=s;else if(arguments.length===1){if(e===!1)return this;n=e,e=s}else arguments.length===2&&(n=t,t=void 0);return j(this,Pe,typeof e=="string"?e:s,"f"),t=t||o(this,T,"f").deferY18nLookup("Show version number"),o(this,T,"f").version(n||void 0),this.boolean(o(this,Pe,"f")),this.describe(o(this,Pe,"f"),t),this}wrap(e){return S("<number|null|undefined>",[e],arguments.length),o(this,T,"f").wrap(e),this}[(ie=new WeakMap,Ge=new WeakMap,gt=new WeakMap,ye=new WeakMap,de=new WeakMap,Tt=new WeakMap,De=new WeakMap,Ye=new WeakMap,Lt=new WeakMap,we=new WeakMap,Wt=new WeakMap,Oe=new WeakMap,Me=new WeakMap,pe=new WeakMap,_e=new WeakMap,Ut=new WeakMap,ot=new WeakMap,ae=new WeakMap,v=new WeakMap,Bt=new WeakMap,zt=new WeakMap,me=new WeakMap,qe=new WeakMap,at=new WeakMap,Ke=new WeakMap,Te=new WeakMap,Vt=new WeakMap,D=new WeakMap,Je=new WeakMap,Qe=new WeakMap,Ze=new WeakMap,T=new WeakMap,Ht=new WeakMap,Pe=new WeakMap,te=new WeakMap,Ni)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch{}return e}[Fi](){return{log:(...e)=>{this[Gt]()||console.log(...e),j(this,pe,!0,"f"),o(this,ae,"f").length&&j(this,ae,o(this,ae,"f")+`
70
+ `,"f"),j(this,ae,o(this,ae,"f")+e.join(" "),"f")},error:(...e)=>{this[Gt]()||console.error(...e),j(this,pe,!0,"f"),o(this,ae,"f").length&&j(this,ae,o(this,ae,"f")+`
71
+ `,"f"),j(this,ae,o(this,ae,"f")+e.join(" "),"f")}}}[_n](e){st(o(this,v,"f")).forEach(t=>{if((s=>s==="configObjects")(t))return;let n=o(this,v,"f")[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n=="object"&&delete n[e]}),delete o(this,T,"f").getDescriptions()[e]}[Ri](e,t,n){o(this,Lt,"f")[n]||(o(this,D,"f").process.emitWarning(e,t),o(this,Lt,"f")[n]=!0)}[Di](){o(this,Wt,"f").push({options:o(this,v,"f"),configObjects:o(this,v,"f").configObjects.slice(0),exitProcess:o(this,we,"f"),groups:o(this,Me,"f"),strict:o(this,Je,"f"),strictCommands:o(this,Qe,"f"),strictOptions:o(this,Ze,"f"),completionCommand:o(this,de,"f"),output:o(this,ae,"f"),exitError:o(this,De,"f"),hasOutput:o(this,pe,"f"),parsed:this.parsed,parseFn:o(this,me,"f"),parseContext:o(this,qe,"f")}),o(this,T,"f").freeze(),o(this,te,"f").freeze(),o(this,ie,"f").freeze(),o(this,Oe,"f").freeze()}[Ti](){let e="",t;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,D,"f").process.argv()[0])?t=o(this,D,"f").process.argv().slice(1,2):t=o(this,D,"f").process.argv().slice(0,1),e=t.map(n=>{let s=this[Qi](o(this,Ge,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&s.length<n.length?s:n}).join(" ").trim(),o(this,D,"f").getEnv("_")&&o(this,D,"f").getProcessArgvBin()===o(this,D,"f").getEnv("_")&&(e=o(this,D,"f").getEnv("_").replace(`${o(this,D,"f").path.dirname(o(this,D,"f").process.execPath())}/`,"")),e}[Xe](){return o(this,zt,"f")}[Li](){return o(this,Ht,"f")}[Cn](){if(!o(this,Ye,"f"))return;let e=o(this,D,"f").getEnv("LC_ALL")||o(this,D,"f").getEnv("LC_MESSAGES")||o(this,D,"f").getEnv("LANG")||o(this,D,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Wi](){return this[xn]().version||"unknown"}[Ui](e){let t=e["--"]?e["--"]:e._;for(let n=0,s;(s=t[n])!==void 0;n++)o(this,D,"f").Parser.looksLikeNumber(s)&&Number.isSafeInteger(Math.floor(parseFloat(`${s}`)))&&(t[n]=Number(s));return e}[xn](e){let t=e||"*";if(o(this,at,"f")[t])return o(this,at,"f")[t];let n={};try{let s=e||o(this,D,"f").mainFilename;!e&&o(this,D,"f").path.extname(s)&&(s=o(this,D,"f").path.dirname(s));let r=o(this,D,"f").findUp(s,(a,c)=>{if(c.includes("package.json"))return"package.json"});ue(r,void 0,o(this,D,"f")),n=JSON.parse(o(this,D,"f").readFileSync(r,"utf8"))}catch{}return o(this,at,"f")[t]=n||{},o(this,at,"f")[t]}[Le](e,t){t=[].concat(t),t.forEach(n=>{n=this[Sn](n),o(this,v,"f")[e].push(n)})}[lt](e,t,n,s){this[An](e,t,n,s,(r,a,c)=>{o(this,v,"f")[r][a]=c})}[En](e,t,n,s){this[An](e,t,n,s,(r,a,c)=>{o(this,v,"f")[r][a]=(o(this,v,"f")[r][a]||[]).concat(c)})}[An](e,t,n,s,r){if(Array.isArray(n))n.forEach(a=>{e(a,s)});else if((a=>typeof a=="object")(n))for(let a of st(n))e(a,n[a]);else r(t,this[Sn](n),s)}[Sn](e){return e==="__proto__"?"___proto___":e}[jn](e,t){return this[lt](this[jn].bind(this),"key",e,t),this}[Mn](){var e,t,n,s,r,a,c,b,g,p,u,m;let w=o(this,Wt,"f").pop();ue(w,void 0,o(this,D,"f"));let C;e=this,t=this,n=this,s=this,r=this,a=this,c=this,b=this,g=this,p=this,u=this,m=this,{options:{set value(O){j(e,v,O,"f")}}.value,configObjects:C,exitProcess:{set value(O){j(t,we,O,"f")}}.value,groups:{set value(O){j(n,Me,O,"f")}}.value,output:{set value(O){j(s,ae,O,"f")}}.value,exitError:{set value(O){j(r,De,O,"f")}}.value,hasOutput:{set value(O){j(a,pe,O,"f")}}.value,parsed:this.parsed,strict:{set value(O){j(c,Je,O,"f")}}.value,strictCommands:{set value(O){j(b,Qe,O,"f")}}.value,strictOptions:{set value(O){j(g,Ze,O,"f")}}.value,completionCommand:{set value(O){j(p,de,O,"f")}}.value,parseFn:{set value(O){j(u,me,O,"f")}}.value,parseContext:{set value(O){j(m,qe,O,"f")}}.value}=w,o(this,v,"f").configObjects=C,o(this,T,"f").unfreeze(),o(this,te,"f").unfreeze(),o(this,ie,"f").unfreeze(),o(this,Oe,"f").unfreeze()}[Bi](e,t){return He(t,n=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[zi].bind(this),getContext:this[Vi].bind(this),getHasOutput:this[Hi].bind(this),getLoggerInstance:this[Gi].bind(this),getParseContext:this[Yi].bind(this),getParserConfiguration:this[Xe].bind(this),getUsageConfiguration:this[Li].bind(this),getUsageInstance:this[qi].bind(this),getValidationInstance:this[Ki].bind(this),hasParseCallback:this[Gt].bind(this),isGlobalContext:this[Ji].bind(this),postProcess:this[ke].bind(this),reset:this[Pn].bind(this),runValidation:this[In].bind(this),runYargsParserAndExecuteCommands:this[bt].bind(this),setHasOutput:this[Zi].bind(this)}}[zi](){return o(this,ie,"f")}[Vi](){return o(this,gt,"f")}[Hi](){return o(this,pe,"f")}[Gi](){return o(this,ot,"f")}[Yi](){return o(this,qe,"f")||{}}[qi](){return o(this,T,"f")}[Ki](){return o(this,te,"f")}[Gt](){return!!o(this,me,"f")}[Ji](){return o(this,Ut,"f")}[ke](e,t,n,s){return n||K(e)||(t||(e=this[Ni](e)),(this[Xe]()["parse-positional-numbers"]||this[Xe]()["parse-positional-numbers"]===void 0)&&(e=this[Ui](e)),s&&(e=Ve(e,this,o(this,Oe,"f").getMiddleware(),!1))),e}[Pn](e={}){j(this,v,o(this,v,"f")||{},"f");let t={};t.local=o(this,v,"f").local||[],t.configObjects=o(this,v,"f").configObjects||[];let n={};t.local.forEach(a=>{n[a]=!0,(e[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Ke,"f"),Object.keys(o(this,Me,"f")).reduce((a,c)=>{let b=o(this,Me,"f")[c].filter(g=>!(g in n));return b.length>0&&(a[c]=b),a},{})),j(this,Me,{},"f");let s=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return s.forEach(a=>{t[a]=(o(this,v,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{t[a]=Fe(o(this,v,"f")[a],c=>!n[c])}),t.envPrefix=o(this,v,"f").envPrefix,j(this,v,t,"f"),j(this,T,o(this,T,"f")?o(this,T,"f").reset(n):Ai(this,o(this,D,"f")),"f"),j(this,te,o(this,te,"f")?o(this,te,"f").reset(n):vi(this,o(this,T,"f"),o(this,D,"f")),"f"),j(this,ie,o(this,ie,"f")?o(this,ie,"f").reset():Ci(o(this,T,"f"),o(this,te,"f"),o(this,Oe,"f"),o(this,D,"f")),"f"),o(this,ye,"f")||j(this,ye,Mi(this,o(this,T,"f"),o(this,ie,"f"),o(this,D,"f")),"f"),o(this,Oe,"f").reset(),j(this,de,null,"f"),j(this,ae,"","f"),j(this,De,null,"f"),j(this,pe,!1,"f"),this.parsed=!1,this}[Qi](e,t){return o(this,D,"f").path.relative(e,t)}[bt](e,t,n,s=0,r=!1){let a=!!n||r;e=e||o(this,Te,"f"),o(this,v,"f").__=o(this,D,"f").y18n.__,o(this,v,"f").configuration=this[Xe]();let c=!!o(this,v,"f").configuration["populate--"],b=Object.assign({},o(this,v,"f").configuration,{"populate--":!0}),g=o(this,D,"f").Parser.detailed(e,Object.assign({},o(this,v,"f"),{configuration:{"parse-positional-numbers":!1,...b}})),p=Object.assign(g.argv,o(this,qe,"f")),u,m=g.aliases,w=!1,C=!1;Object.keys(p).forEach(O=>{O===o(this,_e,"f")&&p[O]?w=!0:O===o(this,Pe,"f")&&p[O]&&(C=!0)}),p.$0=this.$0,this.parsed=g,s===0&&o(this,T,"f").clearCachedHelpMessage();try{if(this[Cn](),t)return this[ke](p,c,!!n,!1);o(this,_e,"f")&&[o(this,_e,"f")].concat(m[o(this,_e,"f")]||[]).filter(U=>U.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),w=!0),j(this,Ut,!1,"f");let O=o(this,ie,"f").getCommands(),f=o(this,ye,"f").completionKey in p,x=w||f||r;if(p._.length){if(O.length){let N;for(let U=s||0,W;p._[U]!==void 0;U++)if(W=String(p._[U]),O.includes(W)&&W!==o(this,de,"f")){let z=o(this,ie,"f").runCommand(W,this,g,U+1,r,w||C||r);return this[ke](z,c,!!n,!1)}else if(!N&&W!==o(this,de,"f")){N=W;break}!o(this,ie,"f").hasDefaultCommand()&&o(this,Vt,"f")&&N&&!x&&o(this,te,"f").recommendCommands(N,O)}o(this,de,"f")&&p._.includes(o(this,de,"f"))&&!f&&(o(this,we,"f")&&Re(!0),this.showCompletionScript(),this.exit(0))}if(o(this,ie,"f").hasDefaultCommand()&&!x){let N=o(this,ie,"f").runCommand(null,this,g,0,r,w||C||r);return this[ke](N,c,!!n,!1)}if(f){o(this,we,"f")&&Re(!0),e=[].concat(e);let N=e.slice(e.indexOf(`--${o(this,ye,"f").completionKey}`)+1);return o(this,ye,"f").getCompletion(N,(U,W)=>{if(U)throw new q(U.message);(W||[]).forEach(z=>{o(this,ot,"f").log(z)}),this.exit(0)}),this[ke](p,!c,!!n,!1)}if(o(this,pe,"f")||(w?(o(this,we,"f")&&Re(!0),a=!0,this.showHelp("log"),this.exit(0)):C&&(o(this,we,"f")&&Re(!0),a=!0,o(this,T,"f").showVersion("log"),this.exit(0))),!a&&o(this,v,"f").skipValidation.length>0&&(a=Object.keys(p).some(N=>o(this,v,"f").skipValidation.indexOf(N)>=0&&p[N]===!0)),!a){if(g.error)throw new q(g.error.message);if(!f){let N=this[In](m,{},g.error);n||(u=Ve(p,this,o(this,Oe,"f").getMiddleware(),!0)),u=this[Bi](N,u??p),K(u)&&!n&&(u=u.then(()=>Ve(p,this,o(this,Oe,"f").getMiddleware(),!1)))}}}catch(O){if(O instanceof q)o(this,T,"f").fail(O.message,O);else throw O}return this[ke](u??p,c,!!n,!0)}[In](e,t,n,s){let r={...this.getDemandedOptions()};return a=>{if(n)throw new q(n.message);o(this,te,"f").nonOptionCount(a),o(this,te,"f").requiredArguments(a,r);let c=!1;o(this,Qe,"f")&&(c=o(this,te,"f").unknownCommands(a)),o(this,Je,"f")&&!c?o(this,te,"f").unknownArguments(a,e,t,!!s):o(this,Ze,"f")&&o(this,te,"f").unknownArguments(a,e,{},!1,!1),o(this,te,"f").limitedChoices(a),o(this,te,"f").implications(a),o(this,te,"f").conflicting(a)}}[Zi](){j(this,pe,!0,"f")}[et](e){if(typeof e=="string")o(this,v,"f").key[e]=!0;else for(let t of e)o(this,v,"f").key[t]=!0}};function xi(i){return!!i&&typeof i.getInternalMethods=="function"}var vr=Xi(pn),ki=vr;var Nr=performance.now(),es=ki(hn(process.argv));await es.scriptName("vidup").usage("$0 [command]","Run a vidup command.").command(["$0 <directory> [options]","sync <directory> [options]"],"Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory.",i=>i.positional("directory",{default:void 0,demandOption:!0,describe:"The path to the local directory of video files to sync.",type:"string"}).option("service",{alias:"s",choices:["bunny","mux","cloudflare"],demandOption:!0,describe:"Streaming service / platform to sync local video files to. Only the Bunny.net streaming CDN is supported at this time.",type:"string"}).option("key",{default:void 0,demandOption:!0,describe:"Streaming service API access key.",type:"string"}).option("library",{default:void 0,demandOption:!0,describe:"Streaming service library ID.",type:"string"}).option("strip-metadata",{default:!1,describe:"Remove all metadata from the video files before uploading them to the streaming service. Warning: This will modify local videos in-place.",type:"boolean"}).option("dry-run",{alias:"d",default:!1,describe:"Perform a dry run without making any changes. Useful for testing and debugging. Pairs well with the `--json` command.",type:"boolean"}).option("json",{default:!1,describe:"Output the sync report as JSON.",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection.",type:"boolean"}).check(e=>{if(e.service==="bunny")return e;throw new Error(`Sorry, vidup doesn't yet implement synchronization support the ${e.service} streaming service. Only Bunny.net is supported at the moment. If you'd like to see support for another service, please open an issue or send a PR on GitHub: https://github.com/kitschpatrol/vidup/issues`)}),async({directory:i,dryRun:e,json:t,key:n,library:s,service:r,stripMetadata:a,verbose:c})=>{G.verbose=c;let b=$r.resolve(nn(i));G.info("Starting video synchronization..."),e&&G.warn("Dry run enabled, not making any changes");let g=a?await Xt(b,{dryRun:e,verbose:c}):[],p=await kt(b,{credentials:{key:n,library:s},dryRun:e,service:r,verbose:c});if(t){for(let u of p)u.stripMetadata=u.localFile!==void 0&&g.includes(u.localFile);process.stdout.write(JSON.stringify(p,void 0,2)),process.stdout.write(`
72
+ `)}else{for(let u of g)process.stdout.write(`${e?"Found":"Stripped"} metadata: "${u}"
73
+ `);for(let u of p)process.stdout.write(`${u.action}: "${u.localFile}" Remote GUID: "${u.remoteId}"
74
+ `)}G.info(`Synchronized video in ${tn(performance.now()-Nr)}`),process.exitCode=0}).demandCommand(1).alias("h","help").version().alias("v","version").help().wrap(process.stdout.isTTY?Math.min(120,es.terminalWidth()):0).parse();
74
75
  /*! Bundled license information:
75
76
 
76
77
  yargs-parser/build/lib/string-utils.js:
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { type Service as VidupService, type SyncOptions as VidupSyncOptions, type SyncReport as VidupSyncReport, syncVideoInDirectory, } from './sync';
1
+ export { type StripOptions, stripVideoMetadataInDirectory } from './strip';
2
+ export { type Service, type SyncOptions, type SyncReport, syncVideoInDirectory } from './sync';
2
3
  export { default as log } from './utilities/log';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var X=(t=0)=>e=>`\x1B[${e+t}m`,Z=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,ee=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`,c={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Xe=Object.keys(c.modifier),xe=Object.keys(c.color),Se=Object.keys(c.bgColor),Ze=[...xe,...Se];function Oe(){let t=new Map;for(let[e,r]of Object.entries(c)){for(let[o,i]of Object.entries(r))c[o]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[o]=c[o],t.set(i[0],i[1]);Object.defineProperty(c,e,{value:r,enumerable:!1})}return Object.defineProperty(c,"codes",{value:t,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=X(),c.color.ansi256=Z(),c.color.ansi16m=ee(),c.bgColor.ansi=X(10),c.bgColor.ansi256=Z(10),c.bgColor.ansi16m=ee(10),Object.defineProperties(c,{rgbToAnsi256:{value(e,r,o){return e===r&&r===o?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(e){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(n=>n+n).join(""));let i=Number.parseInt(o,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>c.rgbToAnsi256(...c.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,o,i;if(e>=232)r=((e-232)*10+8)/255,o=r,i=r;else{e-=16;let R=e%36;r=Math.floor(e/36)/5,o=Math.floor(R/6)/5,i=R%6/5}let n=Math.max(r,o,i)*2;if(n===0)return 30;let l=30+(Math.round(i)<<2|Math.round(o)<<1|Math.round(r));return n===2&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,r,o)=>c.ansi256ToAnsi(c.rgbToAnsi256(e,r,o)),enumerable:!1},hexToAnsi:{value:e=>c.ansi256ToAnsi(c.hexToAnsi256(e)),enumerable:!1}}),c}var Re=Oe(),h=Re;import J from"node:process";import Ee from"node:os";import te from"node:tty";function m(t,e=globalThis.Deno?globalThis.Deno.args:J.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",o=e.indexOf(r+t),i=e.indexOf("--");return o!==-1&&(i===-1||o<i)}var{env:d}=J,V;m("no-color")||m("no-colors")||m("color=false")||m("color=never")?V=0:(m("color")||m("colors")||m("color=true")||m("color=always"))&&(V=1);function Te(){if("FORCE_COLOR"in d)return d.FORCE_COLOR==="true"?1:d.FORCE_COLOR==="false"?0:d.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(d.FORCE_COLOR,10),3)}function Fe(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function Ce(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let o=Te();o!==void 0&&(V=o);let i=r?V:o;if(i===0)return 0;if(r){if(m("color=16m")||m("color=full")||m("color=truecolor"))return 3;if(m("color=256"))return 2}if("TF_BUILD"in d&&"AGENT_NAME"in d)return 1;if(t&&!e&&i===void 0)return 0;let n=i||0;if(d.TERM==="dumb")return n;if(J.platform==="win32"){let l=Ee.release().split(".");return Number(l[0])>=10&&Number(l[2])>=10586?Number(l[2])>=14931?3:2:1}if("CI"in d)return"GITHUB_ACTIONS"in d||"GITEA_ACTIONS"in d?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(l=>l in d)||d.CI_NAME==="codeship"?1:n;if("TEAMCITY_VERSION"in d)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(d.TEAMCITY_VERSION)?1:0;if(d.COLORTERM==="truecolor"||d.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in d){let l=Number.parseInt((d.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(d.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(d.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(d.TERM)||"COLORTERM"in d?1:n}function re(t,e={}){let r=Ce(t,{streamIsTTY:t&&t.isTTY,...e});return Fe(r)}var Ne={stdout:re({isTTY:te.isatty(1)}),stderr:re({isTTY:te.isatty(2)})},oe=Ne;function ie(t,e,r){let o=t.indexOf(e);if(o===-1)return t;let i=e.length,n=0,l="";do l+=t.slice(n,o)+e+r,n=o+i,o=t.indexOf(e,n);while(o!==-1);return l+=t.slice(n),l}function ne(t,e,r,o){let i=0,n="";do{let l=t[o-1]==="\r";n+=t.slice(i,l?o-1:o)+e+(l?`\r
1
+ var z=(t=0)=>e=>`\x1B[${e+t}m`,q=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,Q=(t=0)=>(e,r,o)=>`\x1B[${38+t};2;${e};${r};${o}m`,c={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Ke=Object.keys(c.modifier),he=Object.keys(c.color),ge=Object.keys(c.bgColor),We=[...he,...ge];function ye(){let t=new Map;for(let[e,r]of Object.entries(c)){for(let[o,n]of Object.entries(r))c[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[o]=c[o],t.set(n[0],n[1]);Object.defineProperty(c,e,{value:r,enumerable:!1})}return Object.defineProperty(c,"codes",{value:t,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=z(),c.color.ansi256=q(),c.color.ansi16m=Q(),c.bgColor.ansi=z(10),c.bgColor.ansi256=q(10),c.bgColor.ansi16m=Q(10),Object.defineProperties(c,{rgbToAnsi256:{value(e,r,o){return e===r&&r===o?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(e){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[o]=r;o.length===3&&(o=[...o].map(a=>a+a).join(""));let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>c.rgbToAnsi256(...c.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,o,n;if(e>=232)r=((e-232)*10+8)/255,o=r,n=r;else{e-=16;let g=e%36;r=Math.floor(e/36)/5,o=Math.floor(g/6)/5,n=g%6/5}let a=Math.max(r,o,n)*2;if(a===0)return 30;let l=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(r));return a===2&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,r,o)=>c.ansi256ToAnsi(c.rgbToAnsi256(e,r,o)),enumerable:!1},hexToAnsi:{value:e=>c.ansi256ToAnsi(c.hexToAnsi256(e)),enumerable:!1}}),c}var we=ye(),h=we;import H from"node:process";import be from"node:os";import X from"node:tty";function m(t,e=globalThis.Deno?globalThis.Deno.args:H.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",o=e.indexOf(r+t),n=e.indexOf("--");return o!==-1&&(n===-1||o<n)}var{env:d}=H,M;m("no-color")||m("no-colors")||m("color=false")||m("color=never")?M=0:(m("color")||m("colors")||m("color=true")||m("color=always"))&&(M=1);function ve(){if("FORCE_COLOR"in d)return d.FORCE_COLOR==="true"?1:d.FORCE_COLOR==="false"?0:d.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(d.FORCE_COLOR,10),3)}function xe(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function Oe(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let o=ve();o!==void 0&&(M=o);let n=r?M:o;if(n===0)return 0;if(r){if(m("color=16m")||m("color=full")||m("color=truecolor"))return 3;if(m("color=256"))return 2}if("TF_BUILD"in d&&"AGENT_NAME"in d)return 1;if(t&&!e&&n===void 0)return 0;let a=n||0;if(d.TERM==="dumb")return a;if(H.platform==="win32"){let l=be.release().split(".");return Number(l[0])>=10&&Number(l[2])>=10586?Number(l[2])>=14931?3:2:1}if("CI"in d)return"GITHUB_ACTIONS"in d||"GITEA_ACTIONS"in d?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(l=>l in d)||d.CI_NAME==="codeship"?1:a;if("TEAMCITY_VERSION"in d)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(d.TEAMCITY_VERSION)?1:0;if(d.COLORTERM==="truecolor"||d.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in d){let l=Number.parseInt((d.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(d.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(d.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(d.TERM)||"COLORTERM"in d?1:a}function Z(t,e={}){let r=Oe(t,{streamIsTTY:t&&t.isTTY,...e});return xe(r)}var Se={stdout:Z({isTTY:X.isatty(1)}),stderr:Z({isTTY:X.isatty(2)})},ee=Se;function te(t,e,r){let o=t.indexOf(e);if(o===-1)return t;let n=e.length,a=0,l="";do l+=t.slice(a,o)+e+r,a=o+n,o=t.indexOf(e,a);while(o!==-1);return l+=t.slice(a),l}function re(t,e,r,o){let n=0,a="";do{let l=t[o-1]==="\r";a+=t.slice(n,l?o-1:o)+e+(l?`\r
2
2
  `:`
3
- `)+r,i=o+1,o=t.indexOf(`
4
- `,i)}while(o!==-1);return n+=t.slice(i),n}var{stdout:se,stderr:ae}=oe,K=Symbol("GENERATOR"),x=Symbol("STYLER"),I=Symbol("IS_EMPTY"),le=["ansi","ansi","ansi256","ansi16m"],S=Object.create(null),Ae=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=se?se.level:0;t.level=e.level===void 0?r:e.level};var Ie=t=>{let e=(...r)=>r.join(" ");return Ae(e,t),Object.setPrototypeOf(e,$.prototype),e};function $(t){return Ie(t)}Object.setPrototypeOf($.prototype,Function.prototype);for(let[t,e]of Object.entries(h))S[t]={get(){let r=D(this,z(e.open,e.close,this[x]),this[I]);return Object.defineProperty(this,t,{value:r}),r}};S.visible={get(){let t=D(this,this[x],!0);return Object.defineProperty(this,"visible",{value:t}),t}};var W=(t,e,r,...o)=>t==="rgb"?e==="ansi16m"?h[r].ansi16m(...o):e==="ansi256"?h[r].ansi256(h.rgbToAnsi256(...o)):h[r].ansi(h.rgbToAnsi(...o)):t==="hex"?W("rgb",e,r,...h.hexToRgb(...o)):h[r][t](...o),$e=["rgb","hex","ansi256"];for(let t of $e){S[t]={get(){let{level:r}=this;return function(...o){let i=z(W(t,le[r],"color",...o),h.color.close,this[x]);return D(this,i,this[I])}}};let e="bg"+t[0].toUpperCase()+t.slice(1);S[e]={get(){let{level:r}=this;return function(...o){let i=z(W(t,le[r],"bgColor",...o),h.bgColor.close,this[x]);return D(this,i,this[I])}}}}var Me=Object.defineProperties(()=>{},{...S,level:{enumerable:!0,get(){return this[K].level},set(t){this[K].level=t}}}),z=(t,e,r)=>{let o,i;return r===void 0?(o=t,i=e):(o=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:o,closeAll:i,parent:r}},D=(t,e,r)=>{let o=(...i)=>Pe(o,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(o,Me),o[K]=t,o[x]=e,o[I]=r,o},Pe=(t,e)=>{if(t.level<=0||!e)return t[I]?"":e;let r=t[x];if(r===void 0)return e;let{openAll:o,closeAll:i}=r;if(e.includes("\x1B"))for(;r!==void 0;)e=ie(e,r.close,r.open),r=r.parent;let n=e.indexOf(`
5
- `);return n!==-1&&(e=ne(e,i,o,n)),o+e+i};Object.defineProperties($.prototype,S);var Be=$(),ct=$({level:ae?ae.level:0});var y=Be;import{oraPromise as Ve}from"ora";var de,ce=((de=process==null?void 0:process.versions)==null?void 0:de.node)!==void 0,De={verbose:!1,log(...t){if(!this.verbose)return;let e=y.gray("[Log]");ce?console.warn(e,...t):console.log(e,...t)},logPrefixed(t,...e){this.info(y.blue(`[${t}]`),...e)},info(...t){if(!this.verbose)return;let e=y.green("[Info]");ce?console.warn(e,...t):console.info(e,...t)},infoPrefixed(t,...e){this.info(y.blue(`[${t}]`),...e)},async infoSpin(t,e){return Ve(t,{prefixText:y.green("[Info]"),stream:process.stderr,text:e})},warn(...t){console.warn(y.yellow("[Warning]"),...t)},warnPrefixed(t,...e){this.warn(y.blue(`[${t}]`),...e)},error(...t){console.error(y.red("[Error]"),...t)},errorPrefixed(t,...e){this.error(y.blue(`[${t}]`),...e)}},f=De;import{execa as ue}from"execa";import k from"ffmpeg-static";import pe from"node:fs/promises";import q from"node:path";import ke from"node:os";var fe=ke.homedir();function O(t){if(typeof t!="string")throw new TypeError(`Expected a string, got ${typeof t}`);return fe?t.replace(/^~(?=$|\/|\\)/,fe):t}async function Q(t){let e=O(t);return(await pe.readdir(e)).filter(i=>{let n=q.extname(i);return[".mp4",".mov",".avi",".mkv"].includes(n)}).map(i=>q.join(e,i))}async function me(t){if(k===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let{stderr:e,stdout:r}=await ue(k,["-i",t,"-f","ffmetadata","-"]);return r.includes("creation_time")||e.includes("creation_time")}catch(e){throw new Error(`Failed to check metadata for: ${t}:
6
- ${String(e)}`)}}async function he(t){if(k===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let e=q.extname(t).slice(1),r=`${t.slice(0,Math.max(0,t.lastIndexOf(".")))}.temp.${e}`;await ue(k,["-i",t,"-map_metadata","-1","-c:v","copy","-c:a","copy",r]),await pe.rename(r,t)}catch(e){throw new Error(`Failed to strip metadata from: ${t}:
7
- ${String(e)}`)}}async function ye(t,e={}){let{dryRun:r=!1,verbose:o=!1}=e,i=f.verbose;f.verbose=o;let n=[];for(let l of t)await me(l)&&n.push(l);if(!r){f.info(`Found ${n.length} videos with metadata to strip`);for(let l of n)console.log(`Stripping metadata from: ${l}`),await he(l)}return f.verbose=i,n}import{BunnyCdnStream as ze}from"bunnycdn-stream";import{hash as qe}from"hasha";import{readFile as Ke}from"node:fs/promises";import{rename as _e,writeFile as Ue}from"node:fs/promises";import{basename as je,dirname as Le,join as Ge}from"node:path";import{fileURLToPath as He}from"node:url";function Ye(t){let e=t instanceof URL?He(t):t.toString();return Ge(Le(e),`.${je(e)}.tmp`)}async function Je(t,e,r){for(let o=0;o<e;o++)try{return await t()}catch(i){if(o<e-1)await new Promise(n=>setTimeout(n,r));else throw i}}var _=class{#e;#t;#r=!1;#i=null;#n=null;#s=null;#o=null;#a(e){return this.#o=e,this.#s||=new Promise((r,o)=>{this.#n=[r,o]}),new Promise((r,o)=>{var i;(i=this.#s)==null||i.then(r).catch(o)})}async#l(e){var r,o;this.#r=!0;try{await Ue(this.#t,e,"utf-8"),await Je(async()=>{await _e(this.#t,this.#e)},10,100),(r=this.#i)==null||r[0]()}catch(i){throw i instanceof Error&&((o=this.#i)==null||o[1](i)),i}finally{if(this.#r=!1,this.#i=this.#n,this.#n=this.#s=null,this.#o!==null){let i=this.#o;this.#o=null,await this.write(i)}}}constructor(e){this.#e=e,this.#t=Ye(e)}async write(e){return this.#r?this.#a(e):this.#l(e)}};var U=class{#e;#t;constructor(e){this.#e=e,this.#t=new _(e)}async read(){let e;try{e=await Ke(this.#e,"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw r}return e}write(e){return this.#t.write(e)}};var j=class{#e;#t;#r;constructor(e,{parse:r,stringify:o}){this.#e=new U(e),this.#t=r,this.#r=o}async read(){let e=await this.#e.read();return e===null?null:this.#t(e)}write(e){return this.#e.write(this.#r(e))}};var L=class extends j{constructor(e){super(e,{parse:JSON.parse,stringify:r=>JSON.stringify(r,null,2)})}};var G=class{#e=null;read(){return Promise.resolve(this.#e)}write(e){return this.#e=e,Promise.resolve()}};function We(t,e){if(t===void 0)throw new Error("lowdb: missing adapter");if(e===void 0)throw new Error("lowdb: missing default data")}var H=class{adapter;data;constructor(e,r){We(e,r),this.adapter=e,this.data=r}async read(){let e=await this.adapter.read();e&&(this.data=e)}async write(){this.data&&await this.adapter.write(this.data)}async update(e){e(this.data),await this.write()}};async function ge(t,e){let r=process.env.NODE_ENV==="test"?new G:new L(t),o=new H(r,e);return await o.read(),o}import{createReadStream as we}from"node:fs";import M from"node:path";async function Qe(t,e){let r=O(t),{credentials:o,dryRun:i=!1,service:n,stripMetadata:l=!0,verbose:R=!1}=e,be=f.verbose;f.verbose=R;let g=[],E=await Q(r);f.info(`Found ${E.length} video files in directory "${t}"`);let P=l?await ye(E,{dryRun:i,verbose:R}):[],u=await ge(M.join(r,".vidup-state.json"),{syncState:[]});u.data.syncState=u.data.syncState.filter(s=>E.includes(M.join(r,s.filename)));for(let s of E){let a=M.basename(s),p=await qe(s,{algorithm:"sha1"}),w=u.data.syncState.find(b=>b.filename===a);w?w.localHash=p:u.data.syncState.push({filename:a,localHash:p,remoteHash:{}})}if(i||await u.write(),n!=="bunny")throw new Error(`Streaming service not yet implemented: ${n}`);let T=new ze({apiKey:o.key,videoLibrary:o.library}),F=await T.listAllVideos();f.info(`Found ${F.length} video files on ${n} remote streaming service`);let ve=F.filter(s=>{let a=u.data.syncState.find(p=>p.filename===s.title);return a!==void 0&&a.localHash===a.remoteHash[n]});for(let s of ve)g.push({action:"Unchanged",localFile:s.title,remoteId:s.guid,stripMetadata:P.includes(s.title)});let C=u.data.syncState.filter(s=>!F.some(a=>a.title===s.filename));for(let s of C)g.push({action:"Created",localFile:s.filename,remoteId:"Not yet uploaded (Dry run)",stripMetadata:P.includes(s.filename)});let N=F.filter(s=>{let a=u.data.syncState.find(p=>p.filename===s.title);return a!==void 0&&a.localHash!==a.remoteHash[n]});for(let s of N)g.push({action:"Updated",localFile:s.title,remoteId:"Not yet uploaded (Dry run)",stripMetadata:P.includes(s.title)});let B=F.filter(s=>!u.data.syncState.some(a=>a.filename===s.title));for(let s of B)g.push({action:"Deleted",localFile:s.title,remoteId:s.guid,stripMetadata:P.includes(s.title)});if(!i){u.data.lastRun=new Date,await u.write(),f.info("Synchronizing...");for(let[s,a]of B.entries()){if(s===0&&f.info(`Deleting ${B.length} remote videos...`),!(await f.infoSpin(T.deleteVideo(a.guid),`Deleting remote video ${s+1}/${B.length}: ${a.title}`)).success)throw new Error(`Failed to delete remote video: ${a.title}`);u.data.lastUpdate=new Date,await u.write()}for(let[s,a]of C.entries()){s===0&&f.info(`Uploading ${C.length} new local videos...`);let p=we(M.join(r,a.filename)),w=await f.infoSpin(T.createAndUploadVideo(p,{title:a.filename}),`Uploading new video ${s+1}/${C.length}: ${a.filename}`);f.info(`Remote video ${s+1}/${C.length} created with GUID: ${w.guid}`);let b=u.data.syncState.find(v=>v.filename===a.filename);if(b===void 0)throw new Error(`Failed to find state entry for: ${a.filename}`);b.remoteHash[n]=a.localHash,u.data.lastUpdate=new Date,await u.write();let A=g.find(v=>v.localFile===a.filename);if(A===void 0)throw new Error(`Failed to find report entry for: ${a.filename}`);A.remoteId=w.guid}for(let[s,a]of N.entries()){s===0&&(f.info(`Updating ${N.length} remote videos...`),f.warn("Bunny does not currently support updating videos in-place, so vidup will delete and re-uploading instead... this will change the video's GUID!"));let p=u.data.syncState.find(Y=>Y.filename===a.title);if(p===void 0)throw new Error(`Failed to find state entry for: ${a.title}`);if(!(await T.deleteVideo(a.guid)).success)throw new Error(`Failed to delete remote video before updating: ${a.title}`);let b=we(M.join(r,p.filename)),A=await f.infoSpin(T.createAndUploadVideo(b,{title:p.filename}),`Updating remote video ${s+1}/${N.length}: ${a.title}`);f.info(`Updated remote video ${s+1}/${N.length} created with GUID: ${A.guid}`),p.remoteHash[n]=p.localHash,u.data.lastUpdate=new Date,await u.write();let v=g.find(Y=>Y.localFile===p.filename);if(v===void 0)throw new Error(`Failed to find report entry for: ${p.filename}`);v.remoteId=A.guid}f.info(`All ${E.length} videos are now in sync!`)}return f.verbose=be,g}export{f as log,Qe as syncVideoInDirectory};
3
+ `)+r,n=o+1,o=t.indexOf(`
4
+ `,n)}while(o!==-1);return a+=t.slice(n),a}var{stdout:oe,stderr:ne}=ee,Y=Symbol("GENERATOR"),x=Symbol("STYLER"),C=Symbol("IS_EMPTY"),ie=["ansi","ansi","ansi256","ansi16m"],O=Object.create(null),Re=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=oe?oe.level:0;t.level=e.level===void 0?r:e.level};var Ee=t=>{let e=(...r)=>r.join(" ");return Re(e,t),Object.setPrototypeOf(e,N.prototype),e};function N(t){return Ee(t)}Object.setPrototypeOf(N.prototype,Function.prototype);for(let[t,e]of Object.entries(h))O[t]={get(){let r=P(this,K(e.open,e.close,this[x]),this[C]);return Object.defineProperty(this,t,{value:r}),r}};O.visible={get(){let t=P(this,this[x],!0);return Object.defineProperty(this,"visible",{value:t}),t}};var J=(t,e,r,...o)=>t==="rgb"?e==="ansi16m"?h[r].ansi16m(...o):e==="ansi256"?h[r].ansi256(h.rgbToAnsi256(...o)):h[r].ansi(h.rgbToAnsi(...o)):t==="hex"?J("rgb",e,r,...h.hexToRgb(...o)):h[r][t](...o),Te=["rgb","hex","ansi256"];for(let t of Te){O[t]={get(){let{level:r}=this;return function(...o){let n=K(J(t,ie[r],"color",...o),h.color.close,this[x]);return P(this,n,this[C])}}};let e="bg"+t[0].toUpperCase()+t.slice(1);O[e]={get(){let{level:r}=this;return function(...o){let n=K(J(t,ie[r],"bgColor",...o),h.bgColor.close,this[x]);return P(this,n,this[C])}}}}var Fe=Object.defineProperties(()=>{},{...O,level:{enumerable:!0,get(){return this[Y].level},set(t){this[Y].level=t}}}),K=(t,e,r)=>{let o,n;return r===void 0?(o=t,n=e):(o=r.openAll+t,n=e+r.closeAll),{open:t,close:e,openAll:o,closeAll:n,parent:r}},P=(t,e,r)=>{let o=(...n)=>Ce(o,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(o,Fe),o[Y]=t,o[x]=e,o[C]=r,o},Ce=(t,e)=>{if(t.level<=0||!e)return t[C]?"":e;let r=t[x];if(r===void 0)return e;let{openAll:o,closeAll:n}=r;if(e.includes("\x1B"))for(;r!==void 0;)e=te(e,r.close,r.open),r=r.parent;let a=e.indexOf(`
5
+ `);return a!==-1&&(e=re(e,n,o,a)),o+e+n};Object.defineProperties(N.prototype,O);var Ne=N(),nt=N({level:ne?ne.level:0});var y=Ne;import{oraPromise as Ae}from"ora";var ae,se=((ae=process==null?void 0:process.versions)==null?void 0:ae.node)!==void 0,Ie={verbose:!1,log(...t){if(!this.verbose)return;let e=y.gray("[Log]");se?console.warn(e,...t):console.log(e,...t)},logPrefixed(t,...e){this.info(y.blue(`[${t}]`),...e)},info(...t){if(!this.verbose)return;let e=y.green("[Info]");se?console.warn(e,...t):console.info(e,...t)},infoPrefixed(t,...e){this.info(y.blue(`[${t}]`),...e)},async infoSpin(t,e){return Ae(t,{prefixText:y.green("[Info]"),stream:process.stderr,text:e})},warn(...t){console.warn(y.yellow("[Warning]"),...t)},warnPrefixed(t,...e){this.warn(y.blue(`[${t}]`),...e)},error(...t){console.error(y.red("[Error]"),...t)},errorPrefixed(t,...e){this.error(y.blue(`[${t}]`),...e)}},f=Ie;import{execa as le}from"execa";import B from"ffmpeg-static";import ce from"node:fs/promises";import W from"node:path";async function V(t){return(await ce.readdir(t)).filter(o=>{let n=W.extname(o);return[".mp4",".mov",".avi",".mkv"].includes(n)}).map(o=>W.join(t,o))}async function de(t){if(B===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let{stderr:e,stdout:r}=await le(B,["-i",t,"-f","ffmetadata","-"]);return r.includes("creation_time")||e.includes("creation_time")}catch(e){throw new Error(`Failed to check metadata for: ${t}:
6
+ ${String(e)}`)}}async function fe(t){if(B===null)throw new Error("ffmpeg-static failed to locate ffmpeg binary");try{let e=W.extname(t).slice(1),r=`${t.slice(0,Math.max(0,t.lastIndexOf(".")))}.temp.${e}`;await le(B,["-i",t,"-map_metadata","-1","-c:v","copy","-c:a","copy",r]),await ce.rename(r,t)}catch(e){throw new Error(`Failed to strip metadata from: ${t}:
7
+ ${String(e)}`)}}async function $e(t,e={}){let{dryRun:r=!1,verbose:o=!1}=e,n=await V(t);return Me(n,{dryRun:r,verbose:o})}async function Me(t,e={}){let{dryRun:r=!1,verbose:o=!1}=e,n=f.verbose;f.verbose=o;let a=[];for(let l of t)await de(l)&&a.push(l);if(!r){f.info(`Found ${a.length} videos with metadata to strip`);for(let l of a)console.log(`Stripping metadata from: ${l}`),await fe(l)}return f.verbose=n,a}import{BunnyCdnStream as He}from"bunnycdn-stream";import{hash as Ye}from"hasha";import{readFile as Le}from"node:fs/promises";import{rename as Pe,writeFile as Be}from"node:fs/promises";import{basename as Ve,dirname as De,join as ke}from"node:path";import{fileURLToPath as _e}from"node:url";function je(t){let e=t instanceof URL?_e(t):t.toString();return ke(De(e),`.${Ve(e)}.tmp`)}async function Ue(t,e,r){for(let o=0;o<e;o++)try{return await t()}catch(n){if(o<e-1)await new Promise(a=>setTimeout(a,r));else throw n}}var D=class{#e;#t;#r=!1;#n=null;#i=null;#s=null;#o=null;#a(e){return this.#o=e,this.#s||=new Promise((r,o)=>{this.#i=[r,o]}),new Promise((r,o)=>{var n;(n=this.#s)==null||n.then(r).catch(o)})}async#l(e){var r,o;this.#r=!0;try{await Be(this.#t,e,"utf-8"),await Ue(async()=>{await Pe(this.#t,this.#e)},10,100),(r=this.#n)==null||r[0]()}catch(n){throw n instanceof Error&&((o=this.#n)==null||o[1](n)),n}finally{if(this.#r=!1,this.#n=this.#i,this.#i=this.#s=null,this.#o!==null){let n=this.#o;this.#o=null,await this.write(n)}}}constructor(e){this.#e=e,this.#t=je(e)}async write(e){return this.#r?this.#a(e):this.#l(e)}};var k=class{#e;#t;constructor(e){this.#e=e,this.#t=new D(e)}async read(){let e;try{e=await Le(this.#e,"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw r}return e}write(e){return this.#t.write(e)}};var _=class{#e;#t;#r;constructor(e,{parse:r,stringify:o}){this.#e=new k(e),this.#t=r,this.#r=o}async read(){let e=await this.#e.read();return e===null?null:this.#t(e)}write(e){return this.#e.write(this.#r(e))}};var j=class extends _{constructor(e){super(e,{parse:JSON.parse,stringify:r=>JSON.stringify(r,null,2)})}};var U=class{#e=null;read(){return Promise.resolve(this.#e)}write(e){return this.#e=e,Promise.resolve()}};function Ge(t,e){if(t===void 0)throw new Error("lowdb: missing adapter");if(e===void 0)throw new Error("lowdb: missing default data")}var L=class{adapter;data;constructor(e,r){Ge(e,r),this.adapter=e,this.data=r}async read(){let e=await this.adapter.read();e&&(this.data=e)}async write(){this.data&&await this.adapter.write(this.data)}async update(e){e(this.data),await this.write()}};async function ue(t,e){let r=process.env.NODE_ENV==="test"?new U:new j(t),o=new L(r,e);return await o.read(),o}import{createReadStream as pe}from"node:fs";import A from"node:path";async function Je(t,e){let{credentials:r,dryRun:o=!1,service:n,verbose:a=!1}=e,l=f.verbose;f.verbose=a;let g=[],I=await V(t);f.info(`Found ${I.length} video files in directory "${t}"`);let u=await ue(A.join(t,".vidup-state.json"),{syncState:[]});u.data.syncState=u.data.syncState.filter(i=>I.includes(A.join(t,i.filename)));for(let i of I){let s=A.basename(i),p=await Ye(i,{algorithm:"sha1"}),w=u.data.syncState.find(b=>b.filename===s);w?w.localHash=p:u.data.syncState.push({filename:s,localHash:p,remoteHash:{}})}if(o||await u.write(),n!=="bunny")throw new Error(`Streaming service not yet implemented: ${n}`);let S=new He({apiKey:r.key,videoLibrary:r.library}),R=await S.listAllVideos();f.info(`Found ${R.length} video files on ${n} remote streaming service`);let me=R.filter(i=>{let s=u.data.syncState.find(p=>p.filename===i.title);return s!==void 0&&s.localHash===s.remoteHash[n]});for(let i of me)g.push({action:"None",localFile:i.title,remoteId:i.guid});let E=u.data.syncState.filter(i=>!R.some(s=>s.title===i.filename));for(let i of E)g.push({action:"Create",localFile:i.filename,remoteId:"Not yet uploaded (Dry run)"});let T=R.filter(i=>{let s=u.data.syncState.find(p=>p.filename===i.title);return s!==void 0&&s.localHash!==s.remoteHash[n]});for(let i of T)g.push({action:"Update",localFile:i.title,remoteId:"Not yet uploaded (Dry run)"});let $=R.filter(i=>!u.data.syncState.some(s=>s.filename===i.title));for(let i of $)g.push({action:"Delete",localFile:i.title,remoteId:i.guid});if(!o){u.data.lastRun=new Date,await u.write(),f.info("Synchronizing...");for(let[i,s]of $.entries()){if(i===0&&f.info(`Deleting ${$.length} remote videos...`),!(await f.infoSpin(S.deleteVideo(s.guid),`Deleting remote video ${i+1}/${$.length}: ${s.title}`)).success)throw new Error(`Failed to delete remote video: ${s.title}`);u.data.lastUpdate=new Date,await u.write()}for(let[i,s]of E.entries()){i===0&&f.info(`Uploading ${E.length} new local videos...`);let p=pe(A.join(t,s.filename)),w=await f.infoSpin(S.createAndUploadVideo(p,{title:s.filename}),`Uploading new video ${i+1}/${E.length}: ${s.filename}`);f.info(`Remote video ${i+1}/${E.length} created with GUID: ${w.guid}`);let b=u.data.syncState.find(v=>v.filename===s.filename);if(b===void 0)throw new Error(`Failed to find state entry for: ${s.filename}`);b.remoteHash[n]=s.localHash,u.data.lastUpdate=new Date,await u.write();let F=g.find(v=>v.localFile===s.filename);if(F===void 0)throw new Error(`Failed to find report entry for: ${s.filename}`);F.remoteId=w.guid}for(let[i,s]of T.entries()){i===0&&(f.info(`Updating ${T.length} remote videos...`),f.warn("Bunny does not currently support updating videos in-place, so vidup will delete and re-uploading instead... this will change the video's GUID!"));let p=u.data.syncState.find(G=>G.filename===s.title);if(p===void 0)throw new Error(`Failed to find state entry for: ${s.title}`);if(!(await S.deleteVideo(s.guid)).success)throw new Error(`Failed to delete remote video before updating: ${s.title}`);let b=pe(A.join(t,p.filename)),F=await f.infoSpin(S.createAndUploadVideo(b,{title:p.filename}),`Updating remote video ${i+1}/${T.length}: ${s.title}`);f.info(`Updated remote video ${i+1}/${T.length} created with GUID: ${F.guid}`),p.remoteHash[n]=p.localHash,u.data.lastUpdate=new Date,await u.write();let v=g.find(G=>G.localFile===p.filename);if(v===void 0)throw new Error(`Failed to find report entry for: ${p.filename}`);v.remoteId=F.guid}f.info(`All ${I.length} videos are now in sync!`)}return f.verbose=l,g}export{f as log,$e as stripVideoMetadataInDirectory,Je as syncVideoInDirectory};
package/dist/sync.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export type Service = 'bunny' | 'cloudflare' | 'mux';
2
2
  export type SyncReport = Array<{
3
- action: 'Created' | 'Deleted' | 'Unchanged' | 'Updated';
3
+ action: 'Create' | 'Delete' | 'None' | 'Update';
4
4
  localFile?: string;
5
5
  remoteId: string;
6
- stripMetadata: boolean;
6
+ stripMetadata?: boolean;
7
7
  }>;
8
8
  export type SyncOptions = {
9
9
  credentials: {
@@ -12,7 +12,6 @@ export type SyncOptions = {
12
12
  };
13
13
  dryRun?: boolean;
14
14
  service: Service;
15
- stripMetadata?: boolean;
16
15
  verbose?: boolean;
17
16
  };
18
17
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidup",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Synchronize a local directory of video files to remote streaming services.",
6
6
  "repository": {
package/readme.md CHANGED
@@ -89,15 +89,15 @@ Usage:
89
89
  vidup [command]
90
90
  ```
91
91
 
92
- | Command | Argument | Description |
93
- | ------- | ------------------------- | -------------------------------------------------------------------------------------------------------------- |
94
- | `sync` | `<directory>` `[options]` | Synchronize a remote video streaming service to mirror the contents of a local directory. _(Default command.)_ |
92
+ | Command | Argument | Description |
93
+ | ------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
94
+ | `sync` | `<directory>` `[options]` | Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory. _(Default command.)_ |
95
95
 
96
96
  _See the sections below for more information on each subcommand._
97
97
 
98
98
  #### Subcommand: `vidup sync`
99
99
 
100
- Synchronize a remote video streaming service to mirror the contents of a local directory.
100
+ Synchronize a remote video streaming service to mirror the contents of a local directory. Warning: This command will irrevocably delete remote videos that are not present in the local directory.
101
101
 
102
102
  Usage:
103
103
 
@@ -109,17 +109,17 @@ vidup sync <directory> [options]
109
109
  | ------------------- | --------------------------------------------------------------------- | -------- |
110
110
  | `directory` | The path to the local directory of video files to sync. _(Required.)_ | `string` |
111
111
 
112
- | Option | Alias | Description | Type | Default |
113
- | ------------------ | ----- | ------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
114
- | `--service` | `-s` | Streaming service to sync to. Only the Bunny.net streaming CDN is supported at this time. | `string` | |
115
- | `--key` | | Streaming service API access key | `string` | |
116
- | `--library` | | Streaming service library ID | `string` | |
117
- | `--strip-metadata` | | Remove all metadata from the video files before uploading them to the streaming service. | `boolean` | `true` |
118
- | `--dry-run` | `-d` | Perform a dry run without making any changes. Useful for testing and debugging. | `boolean` | `false` |
119
- | `--json` | | Output the sync report as JSON | `boolean` | `false` |
120
- | `--verbose` | | Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection. | `boolean` | `false` |
121
- | `--help` | `-h` | Show help | `boolean` | |
122
- | `--version` | `-v` | Show version number | `boolean` | |
112
+ | Option | Alias | Description | Type | Default |
113
+ | ------------------ | ----- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------- |
114
+ | `--service` | `-s` | Streaming service / platform to sync local video files to. Only the Bunny.net streaming CDN is supported at this time. | `string` | |
115
+ | `--key` | | Streaming service API access key. | `string` | |
116
+ | `--library` | | Streaming service library ID. | `string` | |
117
+ | `--strip-metadata` | | Remove all metadata from the video files before uploading them to the streaming service. Warning: This will modify local videos in-place. | `boolean` | `false` |
118
+ | `--dry-run` | `-d` | Perform a dry run without making any changes. Useful for testing and debugging. Pairs well with the `--json` command. | `boolean` | `false` |
119
+ | `--json` | | Output the sync report as JSON. | `boolean` | `false` |
120
+ | `--verbose` | | Enable verbose logging. All verbose logs and prefixed with their log level and are printed to `stderr` for ease of redirection. | `boolean` | `false` |
121
+ | `--help` | `-h` | Show help | `boolean` | |
122
+ | `--version` | `-v` | Show version number | `boolean` | |
123
123
 
124
124
  <!-- /cli-help -->
125
125
 
@@ -134,16 +134,16 @@ vidup . --service bunny --key <BUNNY_API_KEY> --library <BUNNY_LIBRARY_ID>
134
134
  Large uploads can take some time. Upon completion, a report summarizing the actions taken is printed to stdout:
135
135
 
136
136
  ```sh
137
- Unchanged: an-already-uploaded-video.mov
138
- Created: a-new-video.mov
139
- Updated: a-changed-video.mp4
140
- Deleted: a-remote-only-video.mp4
137
+ None: an-already-uploaded-video.mov
138
+ Create: a-new-video.mov
139
+ Update: a-changed-video.mp4
140
+ Delete: a-remote-only-video.mp4
141
141
  ```
142
142
 
143
- **Perform a non-executive dry-run and get the snynchronization plan report as JSON:**
143
+ **Perform a non-executive dry run and get the synchronization plan report as JSON:**
144
144
 
145
145
  ```sh
146
- vidup . --service bunny --key --json < BUNNY_API_KEY > --library < BUNNY_LIBRARY_ID > --dry-run
146
+ vidup . --json --dry-run --service bunny --key <BUNNY_API_KEY> --library <BUNNY_LIBRARY_ID>
147
147
  ```
148
148
 
149
149
  The JSON version of the output provides some extra info.
@@ -154,7 +154,7 @@ The JSON version of the output provides some extra info.
154
154
 
155
155
  Vidup's functionality is also provided in module form for use in TypeScript or JavaScript Node projects.
156
156
 
157
- The library exports a single async function, `syncVideoInDirectory`, which takes an options argument mirroring the arguments available via the command line. The same default values apply:
157
+ The library exports `syncVideoInDirectory`, which takes an options argument mirroring the arguments available via the command line and returns an object reporting the synchronization steps performed:
158
158
 
159
159
  ```ts
160
160
  async function syncVideoInDirectory(
@@ -166,12 +166,23 @@ async function syncVideoInDirectory(
166
166
  library: string
167
167
  }
168
168
  dryRun?: boolean // defaults to false
169
- stripMetadata?: boolean // defaults to true
170
169
  verbose?: boolean // defaults to false
171
170
  },
172
171
  ): Promise<SyncReport>
173
172
  ```
174
173
 
174
+ A `stripVideoMetadataInDirectory` function is also exported, which will remove metadata from all videos in the target directory. It returns a list of video filepaths with metadata:
175
+
176
+ ```ts
177
+ export async function stripVideoMetadataInFiles(
178
+ directory: string,
179
+ options: {
180
+ dryRun?: boolean // defaults to false
181
+ verbose?: boolean // defaults to false
182
+ },
183
+ ): Promise<string[]>
184
+ ```
185
+
175
186
  #### Examples
176
187
 
177
188
  ```ts