@kitschpatrol/tldraw-cli 1.2.1 → 1.3.0

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,14 +1,17 @@
1
1
  #!/usr/bin/env node
2
- var Ot=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var cn="1.2.0";import dn from"express";import yi from"node:net";import Oi from"node:os";var ue=class extends Error{constructor(t){super(`${t} is locked`)}},Zt={old:new Set,young:new Set},_i=1e3*15;var ie,Ci=()=>{let s=Oi.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let e of Object.values(s))for(let n of e)t.add(n.address);return t},fn=s=>new Promise((t,e)=>{let n=yi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),hn=async(s,t)=>{if(s.host||s.port===0)return fn(s);for(let e of t)try{await fn({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},xi=function*(s){s&&(yield*s),yield 0};async function ve(s){let t,e=new Set;if(s&&(s.port&&(t=typeof s.port=="number"?[s.port]:s.port),s.exclude)){let i=s.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let r of i){if(typeof r!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(r))throw new TypeError(`Number ${r} in the exclude option is not a safe integer and can't be used`)}e=new Set(i)}ie===void 0&&(ie=setTimeout(()=>{ie=void 0,Zt.old=Zt.young,Zt.young=new Set},_i),ie.unref&&ie.unref());let n=Ci();for(let i of xi(t))try{if(e.has(i))continue;let r=await hn({...s,port:i},n);for(;Zt.old.has(r)||Zt.young.has(r);){if(i!==0)throw new ue(i);r=await hn({...s,port:i},n)}return Zt.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof ue))throw r}throw new Error("No available ports found")}import Fe from"node:fs/promises";import de from"node:os";import jt from"node:path";import{dirname as ji}from"node:path";import{fileURLToPath as Ai}from"node:url";import pn from"puppeteer";import Ei from"node:os";var un=Ei.homedir();function se(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return un?s.replace(/^~(?=$|\/|\\)/,un):s}async function mn(s,t="svg",e="./",n=!1){return s.startsWith("https://www.tldraw.com/")?(n&&console.log("tldraw URL detected"),Pi(s,t,e,n)):(n&&console.log("Local file detected"),Si(s,t,e,n))}async function Pi(s,t,e,n){n&&console.log("Starting Puppeteer...");let r=await(await pn.launch({headless:"new"})).newPage(),a=await r.target().createCDPSession();await a.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),n&&console.log(`Navigating to: ${s}`),await r.goto(s,{waitUntil:"networkidle0"}),n&&console.log("Requesting download"),await $i(r,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${t}`]);let c=await gn(a);n&&console.log("Download complete");let m=jt.join(de.tmpdir(),c),w=se(jt.join(e,`${c}.${t}`));return await Fe.rename(m,w),n&&console.log(`Saved to "${w}"`),w}async function Si(s,t,e,n){let i=ji(Ai(import.meta.url)),r=jt.resolve(se(s));n&&console.log(`Loading tldr file "${r}"`);let a=await Fe.readFile(r,"utf8");n&&console.log("Starting tldraw server...");let c=jt.join(i,i.endsWith("/src/lib")?"../../dist/tldraw":i.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");n&&console.log(`tldraw served from "${c}"`);let m=await Mi(c),{port:w}=m.address();n&&console.log(`tldraw hosted at "http://localhost:${w}"`),n&&console.log("Starting Puppeteer...");let p=await pn.launch({headless:"new"}),u=await p.newPage();await u.setRequestInterception(!0),u.on("request",W=>{W.url().endsWith("favicon.ico")?W.respond({status:200}):W.continue()}),Ii(u,n);let g=await u.target().createCDPSession();await g.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),await u.goto(`http://localhost:${w}`),await u.waitForFunction(()=>window.tldrawExportFile!==void 0),n&&console.log("Requesting download"),await u.evaluate((W,z)=>{window.tldrawExportFile(W,z)},a,t);let y=await gn(g);n&&console.log("Download complete"),await p.close(),n&&console.log("Stopped Puppeteer");let E=jt.basename(s,jt.extname(s)),_=jt.join(de.tmpdir(),y),d=se(jt.join(e,`${E}.${t}`));return await Fe.rename(_,d),n&&console.log(`Saved to "${d}"`),m.close(),n&&console.log("Stopped tldraw server"),jt.resolve(d)}function Ii(s,t){s.on("console",e=>{let n=e.type(),i=e.text();n==="error"?console.error(`[Browser] ${i}`):n==="warning"?console.warn(`[Browser] ${i}`):t&&console.log(`[Browser] ${i}`)})}async function Mi(s){let t=dn(),e=await ve();return t.use(dn.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function gn(s){return new Promise((t,e)=>{s.on("Browser.downloadProgress",n=>{n.state==="completed"?t(n.guid):n.state==="canceled"&&e(new Error("Download was canceled"))})})}async function $i(s,t){for(let e of t)await s.waitForSelector(`[data-testid="${e}"]`),await s.click(`[data-testid="${e}"]`)}import{notStrictEqual as ns,strictEqual as is}from"assert";var vi={right:Li,center:zi},Fi=0,pe=1,Ni=2,me=3,Ne=class{constructor(t){var e;this.width=t.width,this.wrap=(e=t.wrap)!==null&&e!==void 0?e:!0,this.rows=[]}span(...t){let e=this.div(...t);e.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]=="string")return this.applyLayoutDSL(t[0]);let e=t.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]=="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){let e=t.split(`
2
+ var Ot=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var cn="1.2.1";import dn from"express";import yi from"node:net";import Oi from"node:os";var he=class extends Error{constructor(t){super(`${t} is locked`)}},Zt={old:new Set,young:new Set},_i=1e3*15;var ie,Ci=()=>{let s=Oi.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let e of Object.values(s))for(let n of e)t.add(n.address);return t},fn=s=>new Promise((t,e)=>{let n=yi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),un=async(s,t)=>{if(s.host||s.port===0)return fn(s);for(let e of t)try{await fn({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},xi=function*(s){s&&(yield*s),yield 0};async function ve(s){let t,e=new Set;if(s&&(s.port&&(t=typeof s.port=="number"?[s.port]:s.port),s.exclude)){let i=s.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let r of i){if(typeof r!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(r))throw new TypeError(`Number ${r} in the exclude option is not a safe integer and can't be used`)}e=new Set(i)}ie===void 0&&(ie=setTimeout(()=>{ie=void 0,Zt.old=Zt.young,Zt.young=new Set},_i),ie.unref&&ie.unref());let n=Ci();for(let i of xi(t))try{if(e.has(i))continue;let r=await un({...s,port:i},n);for(;Zt.old.has(r)||Zt.young.has(r);){if(i!==0)throw new he(i);r=await un({...s,port:i},n)}return Zt.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof he))throw r}throw new Error("No available ports found")}import Fe from"node:fs/promises";import de from"node:os";import jt from"node:path";import{dirname as ji}from"node:path";import{fileURLToPath as Ai}from"node:url";import pn from"puppeteer";import Ei from"node:os";var hn=Ei.homedir();function se(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return hn?s.replace(/^~(?=$|\/|\\)/,hn):s}async function mn(s,t="svg",e="./",n=!1,i=void 0){return s.startsWith("https://www.tldraw.com/")?(n&&console.log("tldraw URL detected"),Mi(s,t,e,n,i)):(n&&console.log("Local file detected"),$i(s,t,e,n,i))}async function Pi(s){await s.evaluate("app.clearOpenMenus()")}async function Si(s){return!await s.evaluate("editor.getInstanceState().exportBackground")}async function Ii(s,t){await s.evaluate(`editor.updateInstanceState(
3
+ { exportBackground: ${!t} },
4
+ { ephemeral: true },
5
+ )`)}async function Mi(s,t,e,n,i){n&&console.log("Starting Puppeteer...");let r=await pn.launch({headless:"new"}),a=await r.newPage(),c=await a.target().createCDPSession();await c.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),n&&console.log(`Navigating to: ${s}`),await a.goto(s,{waitUntil:"networkidle0"}),i===void 0?n&&console.log("Using project transparency"):await Si(a)!==i&&(n&&console.log(`Setting background to transparent: ${i}`),await Ii(a,i)),n&&console.log("Requesting download"),await Pi(a),await Ni(a,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${t}`]);let g=await gn(c);n&&console.log("Download complete"),await r.close(),n&&console.log("Stopped Puppeteer");let w=jt.join(de.tmpdir(),g),p=se(jt.join(e,`${g}.${t}`));return await Fe.rename(w,p),n&&console.log(`Saved to "${p}"`),p}async function $i(s,t,e,n,i){let r=ji(Ai(import.meta.url)),a=jt.resolve(se(s));n&&console.log(`Loading tldr file "${a}"`);let c=await Fe.readFile(a,"utf8");n&&console.log("Starting tldraw server...");let g=jt.join(r,r.endsWith("/src/lib")?"../../dist/tldraw":r.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");n&&console.log(`tldraw served from "${g}"`);let w=await Fi(g),{port:p}=w.address();n&&console.log(`tldraw hosted at "http://localhost:${p}"`),n&&console.log("Starting Puppeteer...");let h=await pn.launch({headless:"new"}),m=await h.newPage();await m.setRequestInterception(!0),m.on("request",U=>{U.url().endsWith("favicon.ico")?U.respond({status:200}):U.continue()}),vi(m,n);let y=await m.target().createCDPSession();await y.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:de.tmpdir(),eventsEnabled:!0}),await m.goto(`http://localhost:${p}`),await m.waitForFunction(()=>window.tldrawExportFile!==void 0),n&&console.log("Requesting download");let E=i===void 0?null:i;await m.evaluate((U,z,Y)=>{window.tldrawExportFile(U,z,Y)},c,t,E);let _=await gn(y);n&&console.log("Download complete"),await h.close(),n&&console.log("Stopped Puppeteer");let d=jt.basename(s,jt.extname(s)),R=jt.join(de.tmpdir(),_),L=se(jt.join(e,`${d}.${t}`));return await Fe.rename(R,L),n&&console.log(`Saved to "${L}"`),w.close(),n&&console.log("Stopped tldraw server"),jt.resolve(L)}function vi(s,t){s.on("console",e=>{let n=e.type(),i=e.text();n==="error"?console.error(`[Browser] ${i}`):n==="warning"?console.warn(`[Browser] ${i}`):t&&console.log(`[Browser] ${i}`)})}async function Fi(s){let t=dn(),e=await ve();return t.use(dn.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function gn(s){return new Promise((t,e)=>{s.on("Browser.downloadProgress",n=>{n.state==="completed"?t(n.guid):n.state==="canceled"&&e(new Error("Download was canceled"))})})}async function Ni(s,t){for(let e of t)await s.waitForSelector(`[data-testid="${e}"]`),await s.click(`[data-testid="${e}"]`)}import{notStrictEqual as rs,strictEqual as os}from"assert";var Di={right:Ti,center:Ui},Wi=0,pe=1,Li=2,me=3,Ne=class{constructor(t){var e;this.width=t.width,this.wrap=(e=t.wrap)!==null&&e!==void 0?e:!0,this.rows=[]}span(...t){let e=this.div(...t);e.span=!0}resetOutput(){this.rows=[]}div(...t){if(t.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&typeof t[0]=="string")return this.applyLayoutDSL(t[0]);let e=t.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return t.length===1&&typeof t[0]=="string"&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){let e=t.split(`
3
6
  `).map(i=>i.split(" ")),n=0;return e.forEach(i=>{i.length>1&&at.stringWidth(i[0])>n&&(n=Math.min(Math.floor(this.width*.5),at.stringWidth(i[0])))}),e.forEach(i=>{this.div(...i.map((r,a)=>({text:r.trim(),padding:this.measurePadding(r),width:a===0&&i.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){let e=at.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){let t=[];return this.rows.forEach(e=>{this.rowToString(e,t)}),t.filter(e=>!e.hidden).map(e=>e.text).join(`
4
- `)}rowToString(t,e){return this.rasterize(t).forEach((n,i)=>{let r="";n.forEach((a,c)=>{let{width:m}=t[c],w=this.negatePadding(t[c]),p=a;if(w>at.stringWidth(a)&&(p+=" ".repeat(w-at.stringWidth(a))),t[c].align&&t[c].align!=="left"&&this.wrap){let g=vi[t[c].align];p=g(p,w),at.stringWidth(p)<w&&(p+=" ".repeat((m||0)-at.stringWidth(p)-1))}let u=t[c].padding||[0,0,0,0];u[me]&&(r+=" ".repeat(u[me])),r+=bn(t[c],p,"| "),r+=p,r+=bn(t[c],p," |"),u[pe]&&(r+=" ".repeat(u[pe])),i===0&&e.length>0&&(r=this.renderInline(r,e[e.length-1]))}),e.push({text:r.replace(/ +$/,""),span:t.span})}),e}renderInline(t,e){let n=t.match(/^ */),i=n?n[0].length:0,r=e.text,a=at.stringWidth(r.trimRight());return e.span?this.wrap?i<a?t:(e.hidden=!0,r.trimRight()+" ".repeat(i-a)+t.trimLeft()):(e.hidden=!0,r+t):t}rasterize(t){let e=[],n=this.columnWidths(t),i;return t.forEach((r,a)=>{r.width=n[a],this.wrap?i=at.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
7
+ `)}rowToString(t,e){return this.rasterize(t).forEach((n,i)=>{let r="";n.forEach((a,c)=>{let{width:g}=t[c],w=this.negatePadding(t[c]),p=a;if(w>at.stringWidth(a)&&(p+=" ".repeat(w-at.stringWidth(a))),t[c].align&&t[c].align!=="left"&&this.wrap){let m=Di[t[c].align];p=m(p,w),at.stringWidth(p)<w&&(p+=" ".repeat((g||0)-at.stringWidth(p)-1))}let h=t[c].padding||[0,0,0,0];h[me]&&(r+=" ".repeat(h[me])),r+=bn(t[c],p,"| "),r+=p,r+=bn(t[c],p," |"),h[pe]&&(r+=" ".repeat(h[pe])),i===0&&e.length>0&&(r=this.renderInline(r,e[e.length-1]))}),e.push({text:r.replace(/ +$/,""),span:t.span})}),e}renderInline(t,e){let n=t.match(/^ */),i=n?n[0].length:0,r=e.text,a=at.stringWidth(r.trimRight());return e.span?this.wrap?i<a?t:(e.hidden=!0,r.trimRight()+" ".repeat(i-a)+t.trimLeft()):(e.hidden=!0,r+t):t}rasterize(t){let e=[],n=this.columnWidths(t),i;return t.forEach((r,a)=>{r.width=n[a],this.wrap?i=at.wrap(r.text,this.negatePadding(r),{hard:!0}).split(`
5
8
  `):i=r.text.split(`
6
- `),r.border&&(i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(i.unshift(...new Array(r.padding[Fi]||0).fill("")),i.push(...new Array(r.padding[Ni]||0).fill(""))),i.forEach((c,m)=>{e[m]||e.push([]);let w=e[m];for(let p=0;p<a;p++)w[p]===void 0&&w.push("");w.push(c)})}),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[me]||0)+(t.padding[pe]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map(a=>a.width||at.stringWidth(a.text));let e=t.length,n=this.width,i=t.map(a=>{if(a.width)return e--,n-=a.width,a.width}),r=e?Math.floor(n/e):0;return i.map((a,c)=>a===void 0?Math.max(r,Di(t[c])):a)}};function bn(s,t,e){return s.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?e:" ":""}function Di(s){let t=s.padding||[],e=1+(t[me]||0)+(t[pe]||0);return s.border?e+4:e}function Wi(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Li(s,t){s=s.trim();let e=at.stringWidth(s);return e<t?" ".repeat(t-e)+s:s}function zi(s,t){s=s.trim();let e=at.stringWidth(s);return e>=t?s:" ".repeat(t-e>>1)+s}var at;function wn(s,t){return at=t,new Ne({width:s?.width||Wi(),wrap:s?.wrap})}var yn=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function De(s){return s.replace(yn,"")}function On(s,t){let[e,n]=s.match(yn)||["",""];s=De(s);let i="";for(let r=0;r<s.length;r++)r!==0&&r%t===0&&(i+=`
7
- `),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function We(s){return wn(s,{stringWidth:t=>[...t].length,stripAnsi:De,wrap:On})}import{dirname as _n,resolve as Cn}from"path";import{readdirSync as Ri,statSync as Ti}from"fs";function xn(s,t){let e=Cn(".",s),n;for(Ti(e).isDirectory()||(e=_n(e));;){if(n=t(e,Ri(e)),n)return Cn(e,n);if(e=_n(n=e),n===e)break}}import{inspect as ss}from"util";import{readFileSync as rs}from"fs";import{fileURLToPath as os}from"url";import{format as Yi}from"util";import{normalize as Bi,resolve as Gi}from"path";function Lt(s){if(s!==s.toLowerCase()&&s!==s.toUpperCase()||(s=s.toLowerCase()),s.indexOf("-")===-1&&s.indexOf("_")===-1)return s;{let e="",n=!1,i=s.match(/^-+/);for(let r=i?i[0].length:0;r<s.length;r++){let a=s.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(e+=a)}return e}}function ge(s,t){let e=s.toLowerCase();t=t||"-";let n="";for(let i=0;i<s.length;i++){let r=e.charAt(i),a=s.charAt(i);r!==a&&i>0?n+=`${t}${e.charAt(i)}`:n+=a}return n}function be(s){return s==null?!1:typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^0[^.]/.test(s)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function En(s){if(Array.isArray(s))return s.map(a=>typeof a!="string"?a+"":a);s=s.trim();let t=0,e=null,n=null,i=null,r=[];for(let a=0;a<s.length;a++){if(e=n,n=s.charAt(a),n===" "&&!i){e!==" "&&t++;continue}n===i?i=null:(n==="'"||n==='"')&&!i&&(i=n),r[t]||(r[t]=""),r[t]+=n}return r}var ht;(function(s){s.BOOLEAN="boolean",s.STRING="string",s.NUMBER="number",s.ARRAY="array"})(ht||(ht={}));var At,we=class{constructor(t){At=t}parse(t,e){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},e),i=En(t),r=typeof t=="string",a=Ui(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),m=Object.assign(Object.create(null),n.default),w=n.configObjects||[],p=n.envPrefix,u=c["populate--"],g=u?"--":"_",y=Object.create(null),E=Object.create(null),_=n.__||At.format,d={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]+)$/,z=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let h=typeof l=="object"?l.key:l,O=Object.keys(l).map(function(b){return{boolean:"bools",string:"strings",number:"numbers"}[b]}).filter(Boolean).pop();O&&(d[O][h]=!0),d.arrays[h]=!0,d.keys.push(h)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){d.bools[l]=!0,d.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){d.strings[l]=!0,d.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){d.numbers[l]=!0,d.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){d.counts[l]=!0,d.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){d.normalize[l]=!0,d.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,h])=>{typeof h=="number"&&(d.nargs[l]=h,d.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,h])=>{typeof h=="function"&&(d.coercions[l]=h,d.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){d.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,h])=>{(typeof h=="boolean"||typeof h=="function")&&(d.configs[l]=h)})),Wt(n.key,a,n.default,d.arrays),Object.keys(m).forEach(function(l){(d.aliases[l]||[]).forEach(function(h){m[h]=m[l]})});let Y=null;he();let T=[],B=Object.assign(Object.create(null),{_:[]}),Pt={};for(let l=0;l<i.length;l++){let h=i[l],O=h.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(h!=="--"&&/^-/.test(h)&&J(h))gt(h);else if(O.match(/^---+(=|$)/)){gt(h);continue}else if(h.match(/^--.+=/)||!c["short-option-groups"]&&h.match(/^-.+=/))x=h.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(F(x[1],d.arrays)?l=Nt(l,x[1],i,x[2]):F(x[1],d.nargs)!==!1?l=Jt(l,x[1],i,x[2]):G(x[1],x[2],!0));else if(h.match(z)&&c["boolean-negation"])x=h.match(z),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],G(f,F(f,d.arrays)?[!1]:!1));else if(h.match(/^--.+/)||!c["short-option-groups"]&&h.match(/^-[^-]+/))x=h.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],F(f,d.arrays)?l=Nt(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!$.match(/^-/)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))));else if(h.match(/^-.\..+=/))x=h.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&G(x[1],x[2]);else if(h.match(/^-.\..+/)&&!h.match(W))$=i[l+1],x=h.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],$!==void 0&&!$.match(/^-/)&&!F(f,d.bools)&&!F(f,d.counts)?(G(f,$),l++):G(f,Z(f)));else if(h.match(/^-[^-]+/)&&!h.match(W)){S=h.slice(1,-1).split(""),b=!1;for(let rt=0;rt<S.length;rt++){if($=h.slice(rt+2),S[rt+1]&&S[rt+1]==="="){it=h.slice(rt+3),f=S[rt],F(f,d.arrays)?l=Nt(l,f,i,it):F(f,d.nargs)!==!1?l=Jt(l,f,i,it):G(f,it),b=!0;break}if($==="-"){G(S[rt],$);continue}if(/[A-Za-z]/.test(S[rt])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&F($,d.bools)===!1){G(S[rt],$),b=!0;break}if(S[rt+1]&&S[rt+1].match(/\W/)){G(S[rt],$),b=!0;break}else G(S[rt],Z(S[rt]))}f=h.slice(-1)[0],!b&&f!=="-"&&(F(f,d.arrays)?l=Nt(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))))}else if(h.match(/^-[0-9]$/)&&h.match(W)&&F(h.slice(1),d.bools))f=h.slice(1),G(f,Z(f));else if(h==="--"){T=i.slice(l+1);break}else if(c["halt-at-non-option"]){T=i.slice(l);break}else gt(h)}U(B,!0),U(B,!1),L(B),et(),Q(B,d.aliases,m,!0),nt(B),c["set-placeholder-key"]&&Dt(B),Object.keys(d.counts).forEach(function(l){xt(B,l.split("."))||G(l,0)}),u&&T.length&&(B[g]=[]),T.forEach(function(l){B[g].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(B).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete B[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete B[l.split(".").map(h=>Lt(h)).join(".")],delete B[l]});function gt(l){let h=P("_",l);(typeof h=="string"||typeof h=="number")&&B._.push(h)}function Jt(l,h,O,b){let f,S=F(h,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return wt(b)||(Y=Error(_("Argument unexpected for: %s",h))),G(h,Z(h)),l;let x=wt(b)?0:1;if(c["nargs-eats-options"])O.length-(l+1)+x<S&&(Y=Error(_("Not enough arguments following: %s",h))),x=S;else{for(f=l+1;f<O.length&&(!O[f].match(/^-[^0-9]/)||O[f].match(W)||J(O[f]));f++)x++;x<S&&(Y=Error(_("Not enough arguments following: %s",h)))}let $=Math.min(x,S);for(!wt(b)&&$>0&&(G(h,b),$--),f=l+1;f<$+l+1;f++)G(h,O[f]);return l+$}function Nt(l,h,O,b){let f=[],S=b||O[l+1],x=F(h,d.nargs);if(F(h,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(wt(S)||wt(b)&&/^-/.test(S)&&!W.test(S)&&!J(S)){if(m[h]!==void 0){let $=m[h];f=Array.isArray($)?$:[$]}}else{wt(b)||f.push(C(h,b,!0));for(let $=l+1;$<O.length&&!(!c["greedy-arrays"]&&f.length>0||x&&typeof x=="number"&&f.length>=x||(S=O[$],/^-/.test(S)&&!W.test(S)&&!J(S)));$++)l=$,f.push(C(h,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(Y=Error(_("Not enough arguments following: %s",h))),G(h,f),l}function G(l,h,O=r){if(/-/.test(l)&&c["camel-case-expansion"]){let S=l.split(".").map(function(x){return Lt(x)}).join(".");I(l,S)}let b=C(l,h,O),f=l.split(".");Et(B,f,b),d.aliases[l]&&d.aliases[l].forEach(function(S){let x=S.split(".");Et(B,x,b)}),f.length>1&&c["dot-notation"]&&(d.aliases[f[0]]||[]).forEach(function(S){let x=S.split("."),$=[].concat(f);$.shift(),x=x.concat($),(d.aliases[l]||[]).includes(x.join("."))||Et(B,x,b)}),F(l,d.normalize)&&!F(l,d.arrays)&&[l].concat(d.aliases[l]||[]).forEach(function(x){Object.defineProperty(Pt,x,{enumerable:!0,get(){return h},set($){h=typeof $=="string"?At.normalize($):$}})})}function I(l,h){d.aliases[l]&&d.aliases[l].length||(d.aliases[l]=[h],y[h]=!0),d.aliases[h]&&d.aliases[h].length||I(h,l)}function C(l,h,O){O&&(h=Hi(h)),(F(l,d.bools)||F(l,d.counts))&&typeof h=="string"&&(h=h==="true");let b=Array.isArray(h)?h.map(function(f){return P(l,f)}):P(l,h);return F(l,d.counts)&&(wt(b)||typeof b=="boolean")&&(b=Le()),F(l,d.normalize)&&F(l,d.arrays)&&(Array.isArray(h)?b=h.map(f=>At.normalize(f)):b=At.normalize(h)),b}function P(l,h){return!c["parse-positional-numbers"]&&l==="_"||!F(l,d.strings)&&!F(l,d.bools)&&!Array.isArray(h)&&(be(h)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${h}`)))||!wt(h)&&F(l,d.numbers))&&(h=Number(h)),h}function L(l){let h=Object.create(null);Q(h,d.aliases,m),Object.keys(d.configs).forEach(function(O){let b=l[O]||h[O];if(b)try{let f=null,S=At.resolve(At.cwd(),b),x=d.configs[O];if(typeof x=="function"){try{f=x(S)}catch($){f=$}if(f instanceof Error){Y=f;return}}else f=At.require(S);H(f)}catch(f){f.name==="PermissionDenied"?Y=f:l[O]&&(Y=Error(_("Invalid JSON config file: %s",b)))}})}function H(l,h){Object.keys(l).forEach(function(O){let b=l[O],f=h?h+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&c["dot-notation"]?H(b,f):(!xt(B,f.split("."))||F(f,d.arrays)&&c["combine-arrays"])&&G(f,b)})}function et(){typeof w<"u"&&w.forEach(function(l){H(l)})}function U(l,h){if(typeof p>"u")return;let O=typeof p=="string"?p:"",b=At.env();Object.keys(b).forEach(function(f){if(O===""||f.lastIndexOf(O,0)===0){let S=f.split("__").map(function(x,$){return $===0&&(x=x.substring(O.length)),Lt(x)});(h&&d.configs[S.join(".")]||!h)&&!xt(l,S)&&G(S.join("."),b[f])}})}function nt(l){let h,O=new Set;Object.keys(l).forEach(function(b){if(!O.has(b)&&(h=F(b,d.coercions),typeof h=="function"))try{let f=P(b,h(l[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),l[S]=f})}catch(f){Y=f}})}function Dt(l){return d.keys.forEach(h=>{~h.indexOf(".")||typeof l[h]>"u"&&(l[h]=void 0)}),l}function Q(l,h,O,b=!1){Object.keys(O).forEach(function(f){xt(l,f.split("."))||(Et(l,f.split("."),O[f]),b&&(E[f]=!0),(h[f]||[]).forEach(function(S){xt(l,S.split("."))||Et(l,S.split("."),O[f])}))})}function xt(l,h){let O=l;c["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(f){O=O[f]||{}});let b=h[h.length-1];return typeof O!="object"?!1:b in O}function Et(l,h,O){let b=l;c["dot-notation"]||(h=[h.join(".")]),h.slice(0,-1).forEach(function(it){it=jn(it),typeof b=="object"&&b[it]===void 0&&(b[it]={}),typeof b[it]!="object"||Array.isArray(b[it])?(Array.isArray(b[it])?b[it].push({}):b[it]=[b[it],{}],b=b[it][b[it].length-1]):b=b[it]});let f=jn(h[h.length-1]),S=F(h.join("."),d.arrays),x=Array.isArray(O),$=c["duplicate-arguments-array"];!$&&F(f,d.nargs)&&($=!0,(!wt(b[f])&&d.nargs[f]===1||Array.isArray(b[f])&&b[f].length===d.nargs[f])&&(b[f]=void 0)),O===Le()?b[f]=Le(b[f]):Array.isArray(b[f])?$&&S&&x?b[f]=c["flatten-duplicate-arrays"]?b[f].concat(O):(Array.isArray(b[f][0])?b[f]:[b[f]]).concat([O]):!$&&!!S==!!x?b[f]=O:b[f]=b[f].concat([O]):b[f]===void 0&&S?b[f]=x?O:[O]:$&&!(b[f]===void 0||F(f,d.counts)||F(f,d.bools))?b[f]=[b[f],O]:b[f]=O}function Wt(...l){l.forEach(function(h){Object.keys(h||{}).forEach(function(O){d.aliases[O]||(d.aliases[O]=[].concat(a[O]||[]),d.aliases[O].concat(O).forEach(function(b){if(/-/.test(b)&&c["camel-case-expansion"]){let f=Lt(b);f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].concat(O).forEach(function(b){if(b.length>1&&/[A-Z]/.test(b)&&c["camel-case-expansion"]){let f=ge(b,"-");f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].forEach(function(b){d.aliases[b]=[O].concat(d.aliases[O].filter(function(f){return b!==f}))}))})})}function F(l,h){let O=[].concat(d.aliases[l]||[],l),b=Object.keys(h),f=O.find(S=>b.includes(S));return f?h[f]:!1}function $e(l){let h=Object.keys(d);return[].concat(h.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(l):b[l]})}function v(l,...h){return[].concat(...h).some(function(b){let f=l.match(b);return f&&$e(f[1])})}function K(l){if(l.match(W)||!l.match(/^-[^-]+/))return!1;let h=!0,O,b=l.slice(1).split("");for(let f=0;f<b.length;f++){if(O=l.slice(f+2),!$e(b[f])){h=!1;break}if(b[f+1]&&b[f+1]==="="||O==="-"||/[A-Za-z]/.test(b[f])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)||b[f+1]&&b[f+1].match(/\W/))break}return h}function J(l){return c["unknown-options-as-args"]&&R(l)}function R(l){return l=l.replace(/^-{3,}/,"--"),l.match(W)||K(l)?!1:!v(l,/^-+([^=]+?)=[\s\S]*$/,z,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(l){return!F(l,d.bools)&&!F(l,d.counts)&&`${l}`in m?m[l]:k(bt(l))}function k(l){return{[ht.BOOLEAN]:!0,[ht.STRING]:"",[ht.NUMBER]:void 0,[ht.ARRAY]:[]}[l]}function bt(l){let h=ht.BOOLEAN;return F(l,d.strings)?h=ht.STRING:F(l,d.numbers)?h=ht.NUMBER:F(l,d.bools)?h=ht.BOOLEAN:F(l,d.arrays)&&(h=ht.ARRAY),h}function wt(l){return l===void 0}function he(){Object.keys(d.counts).find(l=>F(l,d.arrays)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):F(l,d.nargs)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},d.aliases),argv:Object.assign(Pt,B),configuration:c,defaulted:Object.assign({},E),error:Y,newAliases:Object.assign({},y)}}};function Ui(s){let t=[],e=Object.create(null),n=!0;for(Object.keys(s).forEach(function(i){t.push([].concat(s[i],i))});n;){n=!1;for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++)if(t[i].filter(function(c){return t[r].indexOf(c)!==-1}).length){t[i]=t[i].concat(t[r]),t.splice(r,1),n=!0;break}}return t.forEach(function(i){i=i.filter(function(a,c,m){return m.indexOf(a)===c});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Le(s){return s!==void 0?s+1:1}function jn(s){return s==="__proto__"?"___proto___":s}function Hi(s){return typeof s=="string"&&(s[0]==="'"||s[0]==='"')&&s[s.length-1]===s[0]?s.substring(1,s.length-1):s}import{readFileSync as Vi}from"fs";var ze,Re,Te,An=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Pn=(Re=(ze=process==null?void 0:process.versions)===null||ze===void 0?void 0:ze.node)!==null&&Re!==void 0?Re:(Te=process==null?void 0:process.version)===null||Te===void 0?void 0:Te.slice(1);if(Pn&&Number(Pn.match(/^([^.]+)/)[1])<An)throw Error(`yargs parser supports a minimum Node.js version of ${An}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var qi=process?process.env:{},Sn=new we({cwd:process.cwd,env:()=>qi,format:Yi,normalize:Bi,resolve:Gi,require:s=>{if(typeof Ot<"u")return Ot(s);if(s.match(/\.json$/))return JSON.parse(Vi(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),re=function(t,e){return Sn.parse(t.slice(),e).argv};re.detailed=function(s,t){return Sn.parse(s.slice(),t)};re.camelCase=Lt;re.decamelize=ge;re.looksLikeNumber=be;var Ue=re;import{basename as as,dirname as ls,extname as cs,relative as fs,resolve as Nn}from"path";function In(){return Ki()?0:1}function Ki(){return Qi()&&!process.defaultApp}function Qi(){return!!process.versions.electron}function He(s){return s.slice(In()+1)}function Mn(){return process.argv[In()]}var V=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as Ji,statSync as Zi,writeFile as Xi}from"fs";import{format as ki}from"util";import{resolve as ts}from"path";var $n={fs:{readFileSync:Ji,writeFile:Xi},format:ki,resolve:ts,exists:s=>{try{return Zi(s).isFile()}catch{return!1}}};var yt,Ye=class{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let e=t.shift(),n=function(){};return typeof t[t.length-1]=="function"&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),yt.format.apply(yt.format,[this.cache[this.locale][e]||e].concat(t))}__n(){let t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),i=t.shift(),r=function(){};typeof t[t.length-1]=="function"&&(r=t.pop()),this.cache[this.locale]||this._readLocaleFile();let a=i===1?e:n;this.cache[this.locale][e]&&(a=this.cache[this.locale][e][i===1?"one":"other"]),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r})):r();let c=[a];return~a.indexOf("%d")&&c.push(i),yt.format.apply(yt.format,c.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach(function(i,r){let a=e[r+1];n+=i,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let t=this,e=this.writeQueue[0],n=e.directory,i=e.locale,r=e.cb,a=this._resolveLocaleFile(n,i),c=JSON.stringify(this.cache[i],null,2);yt.fs.writeFile(a,c,"utf-8",function(m){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),r(m)})}_readLocaleFile(){let t={},e=this._resolveLocaleFile(this.directory,this.locale);try{yt.fs.readFileSync&&(t=JSON.parse(yt.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=yt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=yt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return yt.exists(t)}};function vn(s,t){yt=t;let e=new Ye(s);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}var es=s=>vn(s,$n),Fn=es;var hs="require is not supported by ESM",Dn="loading a directory of commands is not supported yet for ESM",oe;try{oe=os(import.meta.url)}catch{oe=process.cwd()}var us=oe.substring(0,oe.lastIndexOf("node_modules")),Be={assert:{notStrictEqual:ns,strictEqual:is},cliui:We,findUp:xn,getEnv:s=>process.env[s],inspect:ss,getCallerFile:()=>{throw new V(Dn)},getProcessArgvBin:Mn,mainFilename:us||process.cwd(),Parser:Ue,path:{basename:as,dirname:ls,extname:cs,relative:fs,resolve:Nn},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(s,t)=>process.emitWarning(s,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:rs,require:()=>{throw new V(hs)},requireDirectory:()=>{throw new V(Dn)},stringWidth:s=>[...s].length,y18n:Fn({directory:Nn(oe,"../../../locales"),updateFiles:!1})};function ot(s,t,e,n){e.assert.notStrictEqual(s,t,n)}function Ge(s,t){t.assert.strictEqual(typeof s,"string")}function Xt(s){return Object.keys(s)}function q(s){return!!s&&!!s.then&&typeof s.then=="function"}function St(s){let e=s.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,i=e.shift();if(!i)throw new Error(`No command found in: ${s}`);let r={cmd:i.replace(n,""),demanded:[],optional:[]};return e.forEach((a,c)=>{let m=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===e.length-1&&(m=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:m}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:m})}),r}var ds=["first","second","third","fourth","fifth","sixth"];function j(s,t,e){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,t]:[St(`cmd ${s}`),t,e]}try{let i=0,[r,a,c]=n(),m=[].slice.call(a);for(;m.length&&m[m.length-1]===void 0;)m.pop();let w=c||m.length;if(w<r.demanded.length)throw new V(`Not enough arguments provided. Expected ${r.demanded.length} but received ${m.length}.`);let p=r.demanded.length+r.optional.length;if(w>p)throw new V(`Too many arguments provided. Expected max ${p} but received ${w}.`);r.demanded.forEach(u=>{let g=m.shift(),y=Wn(g);u.cmd.filter(_=>_===y||_==="*").length===0&&Ln(y,u.cmd,i),i+=1}),r.optional.forEach(u=>{if(m.length===0)return;let g=m.shift(),y=Wn(g);u.cmd.filter(_=>_===y||_==="*").length===0&&Ln(y,u.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function Wn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Ln(s,t,e){throw new V(`Invalid ${ds[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${s}.`)}var ye=class{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,i=!1){if(j("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let r=0;r<t.length;r++){if(typeof t[r]!="function")throw Error("middleware must be a function");let a=t[r];a.applyBeforeValidation=e,a.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){let r=t;r.applyBeforeValidation=e,r.global=n,r.mutates=i,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(i=>{let r=[...n[e]||[],e];return i.option?!r.includes(i.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}};function zn(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function zt(s,t,e,n){return e.reduce((i,r)=>{if(r.applyBeforeValidation!==n)return i;if(r.mutates){if(r.applied)return i;r.applied=!0}if(q(i))return i.then(a=>Promise.all([a,r(a,t)])).then(([a,c])=>Object.assign(a,c));{let a=r(i,t);return q(a)?a.then(c=>Object.assign(i,c)):Object.assign(i,a)}},s)}function Rt(s,t,e=n=>{throw n}){try{let n=ps(s)?s():s;return q(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function ps(s){return typeof s=="function"}function Ve(s){if(typeof Ot>"u")return null;for(let t=0,e=Object.keys(Ot.cache),n;t<e.length;t++)if(n=Ot.cache[e[t]],n.exports===s)return n;return null}var kt=/(^\*)|(^\$0)/,qe=class{constructor(t,e,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,i){i=i||{},typeof i.recurse!="boolean"&&(i.recurse=!1),Array.isArray(i.extensions)||(i.extensions=["js"]);let r=typeof i.visit=="function"?i.visit:a=>a;i.visit=(a,c,m)=>{let w=r(a,c,m);if(w){if(this.requireCache.has(c))return w;this.requireCache.add(c),this.addHandler(w)}return w},this.shim.requireDirectory({require:e,filename:n},t,i)}addHandler(t,e,n,i,r,a){let c=[],m=zn(r);if(i=i||(()=>{}),Array.isArray(t))if(ms(t))[t,...c]=t;else for(let w of t)this.addHandler(w);else if(bs(t)){let w=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(w=[].concat(w).concat(t.aliases)),this.addHandler(w,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Rn(n)){this.addHandler([t].concat(c),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){let w=St(t);c=c.map(g=>St(g).cmd);let p=!1,u=[w.cmd].concat(c).filter(g=>kt.test(g)?(p=!0,!1):!0);u.length===0&&p&&u.push("$0"),p&&(w.cmd=u[0],c=u.slice(1),t=t.replace(kt,w.cmd)),c.forEach(g=>{this.aliasMap[g]=w.cmd}),e!==!1&&this.usage.command(t,e,p,c,a),this.handlers[w.cmd]={original:t,description:e,handler:i,builder:n||{},middlewares:m,deprecated:a,demanded:w.demanded,optional:w.optional},p&&(this.defaultCommand=this.handlers[w.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,i,r,a){let c=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,m=e.getInternalMethods().getContext(),w=m.commands.slice(),p=!t;t&&(m.commands.push(t),m.fullCommands.push(c.original));let u=this.applyBuilderUpdateUsageAndParse(p,c,e,n.aliases,w,i,r,a);return q(u)?u.then(g=>this.applyMiddlewareAndGetResult(p,c,g.innerArgv,m,r,g.aliases,e)):this.applyMiddlewareAndGetResult(p,c,u.innerArgv,m,r,u.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,c,m){let w=e.builder,p=n;if(Oe(w)){n.getInternalMethods().getUsageInstance().freeze();let u=w(n.getInternalMethods().reset(i),m);if(q(u))return u.then(g=>(p=Un(g)?g:n,this.parseAndUpdateUsage(t,e,p,r,a,c)))}else gs(w)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(u=>{p.option(u,w[u])}));return this.parseAndUpdateUsage(t,e,p,r,a,c)}parseAndUpdateUsage(t,e,n,i,r,a){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,e),e.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return q(c)?c.then(m=>({aliases:n.parsed.aliases,innerArgv:m})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let n=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,i=t.filter(r=>!kt.test(r));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(t,e,n,i,r,a,c,m){if(!a.getInternalMethods().getHasOutput()){let w=a.getInternalMethods().runValidation(r,m,a.parsed.error,t);n=Rt(n,p=>(w(p),p))}if(e.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let w=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,w,!1,!1),n=zt(n,a,c,!1),n=Rt(n,p=>{let u=e.handler(p);return q(u)?u.then(()=>p):p}),t||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),q(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(p=>{try{a.getInternalMethods().getUsageInstance().fail(null,p)}catch{}})}return t||(i.commands.pop(),i.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,i,r,a,c){let m={};if(r)return n;c.getInternalMethods().getHasOutput()||(m=this.populatePositionals(e,n,i,c));let w=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),p=zt(n,c,w,!0);return q(p)?p.then(u=>this.handleValidationAndGetResult(t,e,u,i,a,c,w,m)):this.handleValidationAndGetResult(t,e,p,i,a,c,w,m)}populatePositionals(t,e,n,i){e._=e._.slice(n.commands.length);let r=t.demanded.slice(0),a=t.optional.slice(0),c={};for(this.validation.positionalCount(r.length,e._.length);r.length;){let m=r.shift();this.populatePositional(m,e,c)}for(;a.length;){let m=a.shift();this.populatePositional(m,e,c)}return e._=n.commands.concat(e._.map(m=>""+m)),this.postProcessPositionals(e,c,this.cmdToParseOptions(t.original),i),c}populatePositional(t,e,n){let i=t.cmd[0];t.variadic?n[i]=e._.splice(0).map(String):e._.length&&(n[i]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},n=St(t);return n.demanded.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a,e.demand[r]=!0}),n.optional.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a}),e}postProcessPositionals(t,e,n,i){let r=Object.assign({},i.getOptions());r.default=Object.assign(n.default,r.default);for(let w of Object.keys(n.alias))r.alias[w]=(r.alias[w]||[]).concat(n.alias[w]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(e).forEach(w=>{e[w].map(p=>{r.configuration["unknown-options-as-args"]&&(r.key[w]=!0),a.push(`--${w}`),a.push(p)})}),!a.length)return;let c=Object.assign({},r.configuration,{"populate--":!1}),m=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:c}));if(m.error)i.getInternalMethods().getUsageInstance().fail(m.error.message,m.error);else{let w=Object.keys(e);Object.keys(e).forEach(p=>{w.push(...m.aliases[p])}),Object.keys(m.argv).forEach(p=>{w.includes(p)&&(e[p]||(e[p]=m.argv[p]),!this.isInConfigs(i,p)&&!this.isDefaulted(i,p)&&Object.prototype.hasOwnProperty.call(t,p)&&Object.prototype.hasOwnProperty.call(m.argv,p)&&(Array.isArray(t[p])||Array.isArray(m.argv[p]))?t[p]=[].concat(t[p],m.argv[p]):t[p]=m.argv[p])})}}isDefaulted(t,e){let{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:n}=t.getOptions();return n.some(i=>Object.prototype.hasOwnProperty.call(i,e))||n.some(i=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let n=kt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(Oe(e))return e(t,!0);Rn(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){let e=Ve(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(let i of[t,e,n]){if(typeof i=="string"||i===!1)return i;ot(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();ot(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Tn(s,t,e,n){return new qe(s,t,e,n)}function Rn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function ms(s){return s.every(t=>typeof t=="string")}function Oe(s){return typeof s=="function"}function gs(s){return typeof s=="object"}function bs(s){return typeof s=="object"&&!Array.isArray(s)}function It(s={},t=()=>!0){let e={};return Xt(s).forEach(n=>{t(n,s[n])&&(e[n]=s[n])}),e}function Mt(s){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{let e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(s)})}function ws(s){return typeof s=="boolean"}function Yn(s,t){let e=t.y18n.__,n={},i=[];n.failFn=function(C){i.push(C)};let r=null,a=null,c=!0;n.showHelpOnFail=function(C=!0,P){let[L,H]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=H),r=H,c=L,n};let m=!1;n.fail=function(C,P){let L=s.getInternalMethods().getLoggerInstance();if(i.length)for(let H=i.length-1;H>=0;--H){let et=i[H];if(ws(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&Mt(!0),!m){m=!0,c&&(s.showHelp("error"),L.error()),(C||P)&&L.error(C||P);let H=r||a;H&&((C||P)&&L.error(""),L.error(H))}if(P=P||new V(C),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,P);throw P}};let w=[],p=!1;n.usage=(I,C)=>I===null?(p=!0,w=[],n):(p=!1,w.push([I,C||""]),n),n.getUsage=()=>w,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>e("Positionals:");let u=[];n.example=(I,C)=>{u.push([I,C||""])};let g=[];n.command=function(C,P,L,H,et=!1){L&&(g=g.map(U=>(U[2]=!1,U))),g.push([C,P||"",L,H,et])},n.getCommands=()=>g;let y={};n.describe=function(C,P){Array.isArray(C)?C.forEach(L=>{n.describe(L,P)}):typeof C=="object"?Object.keys(C).forEach(L=>{n.describe(L,C[L])}):y[C]=P},n.getDescriptions=()=>y;let E=[];n.epilog=I=>{E.push(I)};let _=!1,d;n.wrap=I=>{_=!0,d=I},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Jt(),_=!0),d);let W="__yargsString__:";n.deferY18nLookup=I=>W+I,n.help=function(){if(T)return T;Y();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),L=s.getDemandedCommands(),H=s.getDeprecatedOptions(),et=s.getGroups(),U=s.getOptions(),nt=[];nt=nt.concat(Object.keys(y)),nt=nt.concat(Object.keys(P)),nt=nt.concat(Object.keys(L)),nt=nt.concat(Object.keys(U.default)),nt=nt.filter(Pt),nt=Object.keys(nt.reduce((v,K)=>(K!=="_"&&(v[K]=!0),v),{}));let Dt=n.getWrap(),Q=t.cliui({width:Dt,wrap:!!Dt});if(!p){if(w.length)w.forEach(v=>{Q.div({text:`${v[0].replace(/\$0/g,C)}`}),v[1]&&Q.div({text:`${v[1]}`,padding:[1,0,0,0]})}),Q.div();else if(g.length){let v=null;L._?v=`${C} <${e("command")}>
9
+ `),r.border&&(i.unshift("."+"-".repeat(this.negatePadding(r)+2)+"."),i.push("'"+"-".repeat(this.negatePadding(r)+2)+"'")),r.padding&&(i.unshift(...new Array(r.padding[Wi]||0).fill("")),i.push(...new Array(r.padding[Li]||0).fill(""))),i.forEach((c,g)=>{e[g]||e.push([]);let w=e[g];for(let p=0;p<a;p++)w[p]===void 0&&w.push("");w.push(c)})}),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[me]||0)+(t.padding[pe]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map(a=>a.width||at.stringWidth(a.text));let e=t.length,n=this.width,i=t.map(a=>{if(a.width)return e--,n-=a.width,a.width}),r=e?Math.floor(n/e):0;return i.map((a,c)=>a===void 0?Math.max(r,Ri(t[c])):a)}};function bn(s,t,e){return s.border?/[.']-+[.']/.test(t)?"":t.trim().length!==0?e:" ":""}function Ri(s){let t=s.padding||[],e=1+(t[me]||0)+(t[pe]||0);return s.border?e+4:e}function zi(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Ti(s,t){s=s.trim();let e=at.stringWidth(s);return e<t?" ".repeat(t-e)+s:s}function Ui(s,t){s=s.trim();let e=at.stringWidth(s);return e>=t?s:" ".repeat(t-e>>1)+s}var at;function wn(s,t){return at=t,new Ne({width:s?.width||zi(),wrap:s?.wrap})}var yn=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function De(s){return s.replace(yn,"")}function On(s,t){let[e,n]=s.match(yn)||["",""];s=De(s);let i="";for(let r=0;r<s.length;r++)r!==0&&r%t===0&&(i+=`
10
+ `),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function We(s){return wn(s,{stringWidth:t=>[...t].length,stripAnsi:De,wrap:On})}import{dirname as _n,resolve as Cn}from"path";import{readdirSync as Hi,statSync as Bi}from"fs";function xn(s,t){let e=Cn(".",s),n;for(Bi(e).isDirectory()||(e=_n(e));;){if(n=t(e,Hi(e)),n)return Cn(e,n);if(e=_n(n=e),n===e)break}}import{inspect as as}from"util";import{readFileSync as ls}from"fs";import{fileURLToPath as cs}from"url";import{format as Vi}from"util";import{normalize as qi,resolve as Ki}from"path";function Lt(s){if(s!==s.toLowerCase()&&s!==s.toUpperCase()||(s=s.toLowerCase()),s.indexOf("-")===-1&&s.indexOf("_")===-1)return s;{let e="",n=!1,i=s.match(/^-+/);for(let r=i?i[0].length:0;r<s.length;r++){let a=s.charAt(r);n&&(n=!1,a=a.toUpperCase()),r!==0&&(a==="-"||a==="_")?n=!0:a!=="-"&&a!=="_"&&(e+=a)}return e}}function ge(s,t){let e=s.toLowerCase();t=t||"-";let n="";for(let i=0;i<s.length;i++){let r=e.charAt(i),a=s.charAt(i);r!==a&&i>0?n+=`${t}${e.charAt(i)}`:n+=a}return n}function be(s){return s==null?!1:typeof s=="number"||/^0x[0-9a-f]+$/i.test(s)?!0:/^0[^.]/.test(s)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(s)}function En(s){if(Array.isArray(s))return s.map(a=>typeof a!="string"?a+"":a);s=s.trim();let t=0,e=null,n=null,i=null,r=[];for(let a=0;a<s.length;a++){if(e=n,n=s.charAt(a),n===" "&&!i){e!==" "&&t++;continue}n===i?i=null:(n==="'"||n==='"')&&!i&&(i=n),r[t]||(r[t]=""),r[t]+=n}return r}var ut;(function(s){s.BOOLEAN="boolean",s.STRING="string",s.NUMBER="number",s.ARRAY="array"})(ut||(ut={}));var At,we=class{constructor(t){At=t}parse(t,e){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},e),i=En(t),r=typeof t=="string",a=Yi(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),w=n.configObjects||[],p=n.envPrefix,h=c["populate--"],m=h?"--":"_",y=Object.create(null),E=Object.create(null),_=n.__||At.format,d={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:[]},R=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,L=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(b){return{boolean:"bools",string:"strings",number:"numbers"}[b]}).filter(Boolean).pop();O&&(d[O][u]=!0),d.arrays[u]=!0,d.keys.push(u)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){d.bools[l]=!0,d.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){d.strings[l]=!0,d.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){d.numbers[l]=!0,d.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){d.counts[l]=!0,d.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){d.normalize[l]=!0,d.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,u])=>{typeof u=="number"&&(d.nargs[l]=u,d.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,u])=>{typeof u=="function"&&(d.coercions[l]=u,d.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){d.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,u])=>{(typeof u=="boolean"||typeof u=="function")&&(d.configs[l]=u)})),Wt(n.key,a,n.default,d.arrays),Object.keys(g).forEach(function(l){(d.aliases[l]||[]).forEach(function(u){g[u]=g[l]})});let U=null;ue();let z=[],Y=Object.assign(Object.create(null),{_:[]}),Pt={};for(let l=0;l<i.length;l++){let u=i[l],O=u.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(u!=="--"&&/^-/.test(u)&&J(u))gt(u);else if(O.match(/^---+(=|$)/)){gt(u);continue}else if(u.match(/^--.+=/)||!c["short-option-groups"]&&u.match(/^-.+=/))x=u.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(F(x[1],d.arrays)?l=Nt(l,x[1],i,x[2]):F(x[1],d.nargs)!==!1?l=Jt(l,x[1],i,x[2]):G(x[1],x[2],!0));else if(u.match(L)&&c["boolean-negation"])x=u.match(L),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],G(f,F(f,d.arrays)?[!1]:!1));else if(u.match(/^--.+/)||!c["short-option-groups"]&&u.match(/^-[^-]+/))x=u.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],F(f,d.arrays)?l=Nt(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!$.match(/^-/)||$.match(R))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))));else if(u.match(/^-.\..+=/))x=u.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&G(x[1],x[2]);else if(u.match(/^-.\..+/)&&!u.match(R))$=i[l+1],x=u.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],$!==void 0&&!$.match(/^-/)&&!F(f,d.bools)&&!F(f,d.counts)?(G(f,$),l++):G(f,Z(f)));else if(u.match(/^-[^-]+/)&&!u.match(R)){S=u.slice(1,-1).split(""),b=!1;for(let rt=0;rt<S.length;rt++){if($=u.slice(rt+2),S[rt+1]&&S[rt+1]==="="){it=u.slice(rt+3),f=S[rt],F(f,d.arrays)?l=Nt(l,f,i,it):F(f,d.nargs)!==!1?l=Jt(l,f,i,it):G(f,it),b=!0;break}if($==="-"){G(S[rt],$);continue}if(/[A-Za-z]/.test(S[rt])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&F($,d.bools)===!1){G(S[rt],$),b=!0;break}if(S[rt+1]&&S[rt+1].match(/\W/)){G(S[rt],$),b=!0;break}else G(S[rt],Z(S[rt]))}f=u.slice(-1)[0],!b&&f!=="-"&&(F(f,d.arrays)?l=Nt(l,f,i):F(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(R))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))))}else if(u.match(/^-[0-9]$/)&&u.match(R)&&F(u.slice(1),d.bools))f=u.slice(1),G(f,Z(f));else if(u==="--"){z=i.slice(l+1);break}else if(c["halt-at-non-option"]){z=i.slice(l);break}else gt(u)}H(Y,!0),H(Y,!1),W(Y),et(),Q(Y,d.aliases,g,!0),nt(Y),c["set-placeholder-key"]&&Dt(Y),Object.keys(d.counts).forEach(function(l){xt(Y,l.split("."))||G(l,0)}),h&&z.length&&(Y[m]=[]),z.forEach(function(l){Y[m].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(Y).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete Y[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete Y[l.split(".").map(u=>Lt(u)).join(".")],delete Y[l]});function gt(l){let u=P("_",l);(typeof u=="string"||typeof u=="number")&&Y._.push(u)}function Jt(l,u,O,b){let f,S=F(u,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return wt(b)||(U=Error(_("Argument unexpected for: %s",u))),G(u,Z(u)),l;let x=wt(b)?0:1;if(c["nargs-eats-options"])O.length-(l+1)+x<S&&(U=Error(_("Not enough arguments following: %s",u))),x=S;else{for(f=l+1;f<O.length&&(!O[f].match(/^-[^0-9]/)||O[f].match(R)||J(O[f]));f++)x++;x<S&&(U=Error(_("Not enough arguments following: %s",u)))}let $=Math.min(x,S);for(!wt(b)&&$>0&&(G(u,b),$--),f=l+1;f<$+l+1;f++)G(u,O[f]);return l+$}function Nt(l,u,O,b){let f=[],S=b||O[l+1],x=F(u,d.nargs);if(F(u,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(wt(S)||wt(b)&&/^-/.test(S)&&!R.test(S)&&!J(S)){if(g[u]!==void 0){let $=g[u];f=Array.isArray($)?$:[$]}}else{wt(b)||f.push(C(u,b,!0));for(let $=l+1;$<O.length&&!(!c["greedy-arrays"]&&f.length>0||x&&typeof x=="number"&&f.length>=x||(S=O[$],/^-/.test(S)&&!R.test(S)&&!J(S)));$++)l=$,f.push(C(u,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(U=Error(_("Not enough arguments following: %s",u))),G(u,f),l}function G(l,u,O=r){if(/-/.test(l)&&c["camel-case-expansion"]){let S=l.split(".").map(function(x){return Lt(x)}).join(".");I(l,S)}let b=C(l,u,O),f=l.split(".");Et(Y,f,b),d.aliases[l]&&d.aliases[l].forEach(function(S){let x=S.split(".");Et(Y,x,b)}),f.length>1&&c["dot-notation"]&&(d.aliases[f[0]]||[]).forEach(function(S){let x=S.split("."),$=[].concat(f);$.shift(),x=x.concat($),(d.aliases[l]||[]).includes(x.join("."))||Et(Y,x,b)}),F(l,d.normalize)&&!F(l,d.arrays)&&[l].concat(d.aliases[l]||[]).forEach(function(x){Object.defineProperty(Pt,x,{enumerable:!0,get(){return u},set($){u=typeof $=="string"?At.normalize($):$}})})}function I(l,u){d.aliases[l]&&d.aliases[l].length||(d.aliases[l]=[u],y[u]=!0),d.aliases[u]&&d.aliases[u].length||I(u,l)}function C(l,u,O){O&&(u=Gi(u)),(F(l,d.bools)||F(l,d.counts))&&typeof u=="string"&&(u=u==="true");let b=Array.isArray(u)?u.map(function(f){return P(l,f)}):P(l,u);return F(l,d.counts)&&(wt(b)||typeof b=="boolean")&&(b=Le()),F(l,d.normalize)&&F(l,d.arrays)&&(Array.isArray(u)?b=u.map(f=>At.normalize(f)):b=At.normalize(u)),b}function P(l,u){return!c["parse-positional-numbers"]&&l==="_"||!F(l,d.strings)&&!F(l,d.bools)&&!Array.isArray(u)&&(be(u)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${u}`)))||!wt(u)&&F(l,d.numbers))&&(u=Number(u)),u}function W(l){let u=Object.create(null);Q(u,d.aliases,g),Object.keys(d.configs).forEach(function(O){let b=l[O]||u[O];if(b)try{let f=null,S=At.resolve(At.cwd(),b),x=d.configs[O];if(typeof x=="function"){try{f=x(S)}catch($){f=$}if(f instanceof Error){U=f;return}}else f=At.require(S);B(f)}catch(f){f.name==="PermissionDenied"?U=f:l[O]&&(U=Error(_("Invalid JSON config file: %s",b)))}})}function B(l,u){Object.keys(l).forEach(function(O){let b=l[O],f=u?u+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&c["dot-notation"]?B(b,f):(!xt(Y,f.split("."))||F(f,d.arrays)&&c["combine-arrays"])&&G(f,b)})}function et(){typeof w<"u"&&w.forEach(function(l){B(l)})}function H(l,u){if(typeof p>"u")return;let O=typeof p=="string"?p:"",b=At.env();Object.keys(b).forEach(function(f){if(O===""||f.lastIndexOf(O,0)===0){let S=f.split("__").map(function(x,$){return $===0&&(x=x.substring(O.length)),Lt(x)});(u&&d.configs[S.join(".")]||!u)&&!xt(l,S)&&G(S.join("."),b[f])}})}function nt(l){let u,O=new Set;Object.keys(l).forEach(function(b){if(!O.has(b)&&(u=F(b,d.coercions),typeof u=="function"))try{let f=P(b,u(l[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),l[S]=f})}catch(f){U=f}})}function Dt(l){return d.keys.forEach(u=>{~u.indexOf(".")||typeof l[u]>"u"&&(l[u]=void 0)}),l}function Q(l,u,O,b=!1){Object.keys(O).forEach(function(f){xt(l,f.split("."))||(Et(l,f.split("."),O[f]),b&&(E[f]=!0),(u[f]||[]).forEach(function(S){xt(l,S.split("."))||Et(l,S.split("."),O[f])}))})}function xt(l,u){let O=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(f){O=O[f]||{}});let b=u[u.length-1];return typeof O!="object"?!1:b in O}function Et(l,u,O){let b=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(it){it=jn(it),typeof b=="object"&&b[it]===void 0&&(b[it]={}),typeof b[it]!="object"||Array.isArray(b[it])?(Array.isArray(b[it])?b[it].push({}):b[it]=[b[it],{}],b=b[it][b[it].length-1]):b=b[it]});let f=jn(u[u.length-1]),S=F(u.join("."),d.arrays),x=Array.isArray(O),$=c["duplicate-arguments-array"];!$&&F(f,d.nargs)&&($=!0,(!wt(b[f])&&d.nargs[f]===1||Array.isArray(b[f])&&b[f].length===d.nargs[f])&&(b[f]=void 0)),O===Le()?b[f]=Le(b[f]):Array.isArray(b[f])?$&&S&&x?b[f]=c["flatten-duplicate-arrays"]?b[f].concat(O):(Array.isArray(b[f][0])?b[f]:[b[f]]).concat([O]):!$&&!!S==!!x?b[f]=O:b[f]=b[f].concat([O]):b[f]===void 0&&S?b[f]=x?O:[O]:$&&!(b[f]===void 0||F(f,d.counts)||F(f,d.bools))?b[f]=[b[f],O]:b[f]=O}function Wt(...l){l.forEach(function(u){Object.keys(u||{}).forEach(function(O){d.aliases[O]||(d.aliases[O]=[].concat(a[O]||[]),d.aliases[O].concat(O).forEach(function(b){if(/-/.test(b)&&c["camel-case-expansion"]){let f=Lt(b);f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].concat(O).forEach(function(b){if(b.length>1&&/[A-Z]/.test(b)&&c["camel-case-expansion"]){let f=ge(b,"-");f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].forEach(function(b){d.aliases[b]=[O].concat(d.aliases[O].filter(function(f){return b!==f}))}))})})}function F(l,u){let O=[].concat(d.aliases[l]||[],l),b=Object.keys(u),f=O.find(S=>b.includes(S));return f?u[f]:!1}function $e(l){let u=Object.keys(d);return[].concat(u.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(l):b[l]})}function v(l,...u){return[].concat(...u).some(function(b){let f=l.match(b);return f&&$e(f[1])})}function K(l){if(l.match(R)||!l.match(/^-[^-]+/))return!1;let u=!0,O,b=l.slice(1).split("");for(let f=0;f<b.length;f++){if(O=l.slice(f+2),!$e(b[f])){u=!1;break}if(b[f+1]&&b[f+1]==="="||O==="-"||/[A-Za-z]/.test(b[f])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)||b[f+1]&&b[f+1].match(/\W/))break}return u}function J(l){return c["unknown-options-as-args"]&&T(l)}function T(l){return l=l.replace(/^-{3,}/,"--"),l.match(R)||K(l)?!1:!v(l,/^-+([^=]+?)=[\s\S]*$/,L,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(l){return!F(l,d.bools)&&!F(l,d.counts)&&`${l}`in g?g[l]:k(bt(l))}function k(l){return{[ut.BOOLEAN]:!0,[ut.STRING]:"",[ut.NUMBER]:void 0,[ut.ARRAY]:[]}[l]}function bt(l){let u=ut.BOOLEAN;return F(l,d.strings)?u=ut.STRING:F(l,d.numbers)?u=ut.NUMBER:F(l,d.bools)?u=ut.BOOLEAN:F(l,d.arrays)&&(u=ut.ARRAY),u}function wt(l){return l===void 0}function ue(){Object.keys(d.counts).find(l=>F(l,d.arrays)?(U=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):F(l,d.nargs)?(U=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},d.aliases),argv:Object.assign(Pt,Y),configuration:c,defaulted:Object.assign({},E),error:U,newAliases:Object.assign({},y)}}};function Yi(s){let t=[],e=Object.create(null),n=!0;for(Object.keys(s).forEach(function(i){t.push([].concat(s[i],i))});n;){n=!1;for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++)if(t[i].filter(function(c){return t[r].indexOf(c)!==-1}).length){t[i]=t[i].concat(t[r]),t.splice(r,1),n=!0;break}}return t.forEach(function(i){i=i.filter(function(a,c,g){return g.indexOf(a)===c});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Le(s){return s!==void 0?s+1:1}function jn(s){return s==="__proto__"?"___proto___":s}function Gi(s){return typeof s=="string"&&(s[0]==="'"||s[0]==='"')&&s[s.length-1]===s[0]?s.substring(1,s.length-1):s}import{readFileSync as Qi}from"fs";var Re,ze,Te,An=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Pn=(ze=(Re=process==null?void 0:process.versions)===null||Re===void 0?void 0:Re.node)!==null&&ze!==void 0?ze:(Te=process==null?void 0:process.version)===null||Te===void 0?void 0:Te.slice(1);if(Pn&&Number(Pn.match(/^([^.]+)/)[1])<An)throw Error(`yargs parser supports a minimum Node.js version of ${An}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var Ji=process?process.env:{},Sn=new we({cwd:process.cwd,env:()=>Ji,format:Vi,normalize:qi,resolve:Ki,require:s=>{if(typeof Ot<"u")return Ot(s);if(s.match(/\.json$/))return JSON.parse(Qi(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),re=function(t,e){return Sn.parse(t.slice(),e).argv};re.detailed=function(s,t){return Sn.parse(s.slice(),t)};re.camelCase=Lt;re.decamelize=ge;re.looksLikeNumber=be;var Ue=re;import{basename as fs,dirname as us,extname as hs,relative as ds,resolve as Nn}from"path";function In(){return Zi()?0:1}function Zi(){return Xi()&&!process.defaultApp}function Xi(){return!!process.versions.electron}function He(s){return s.slice(In()+1)}function Mn(){return process.argv[In()]}var V=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as ki,statSync as ts,writeFile as es}from"fs";import{format as ns}from"util";import{resolve as is}from"path";var $n={fs:{readFileSync:ki,writeFile:es},format:ns,resolve:is,exists:s=>{try{return ts(s).isFile()}catch{return!1}}};var yt,Be=class{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles=typeof t.updateFiles=="boolean"?t.updateFiles:!0,this.locale=t.locale||"en",this.fallbackToLanguage=typeof t.fallbackToLanguage=="boolean"?t.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let e=t.shift(),n=function(){};return typeof t[t.length-1]=="function"&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),yt.format.apply(yt.format,[this.cache[this.locale][e]||e].concat(t))}__n(){let t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),i=t.shift(),r=function(){};typeof t[t.length-1]=="function"&&(r=t.pop()),this.cache[this.locale]||this._readLocaleFile();let a=i===1?e:n;this.cache[this.locale][e]&&(a=this.cache[this.locale][e][i===1?"one":"other"]),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:r})):r();let c=[a];return~a.indexOf("%d")&&c.push(i),yt.format.apply(yt.format,c.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach(function(i,r){let a=e[r+1];n+=i,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let t=this,e=this.writeQueue[0],n=e.directory,i=e.locale,r=e.cb,a=this._resolveLocaleFile(n,i),c=JSON.stringify(this.cache[i],null,2);yt.fs.writeFile(a,c,"utf-8",function(g){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),r(g)})}_readLocaleFile(){let t={},e=this._resolveLocaleFile(this.directory,this.locale);try{yt.fs.readFileSync&&(t=JSON.parse(yt.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),n.code==="ENOENT")t={};else throw n}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=yt.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=yt.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return yt.exists(t)}};function vn(s,t){yt=t;let e=new Be(s);return{__:e.__.bind(e),__n:e.__n.bind(e),setLocale:e.setLocale.bind(e),getLocale:e.getLocale.bind(e),updateLocale:e.updateLocale.bind(e),locale:e.locale}}var ss=s=>vn(s,$n),Fn=ss;var ps="require is not supported by ESM",Dn="loading a directory of commands is not supported yet for ESM",oe;try{oe=cs(import.meta.url)}catch{oe=process.cwd()}var ms=oe.substring(0,oe.lastIndexOf("node_modules")),Ye={assert:{notStrictEqual:rs,strictEqual:os},cliui:We,findUp:xn,getEnv:s=>process.env[s],inspect:as,getCallerFile:()=>{throw new V(Dn)},getProcessArgvBin:Mn,mainFilename:ms||process.cwd(),Parser:Ue,path:{basename:fs,dirname:us,extname:hs,relative:ds,resolve:Nn},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(s,t)=>process.emitWarning(s,t),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:ls,require:()=>{throw new V(ps)},requireDirectory:()=>{throw new V(Dn)},stringWidth:s=>[...s].length,y18n:Fn({directory:Nn(oe,"../../../locales"),updateFiles:!1})};function ot(s,t,e,n){e.assert.notStrictEqual(s,t,n)}function Ge(s,t){t.assert.strictEqual(typeof s,"string")}function Xt(s){return Object.keys(s)}function q(s){return!!s&&!!s.then&&typeof s.then=="function"}function St(s){let e=s.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,i=e.shift();if(!i)throw new Error(`No command found in: ${s}`);let r={cmd:i.replace(n,""),demanded:[],optional:[]};return e.forEach((a,c)=>{let g=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===e.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 gs=["first","second","third","fourth","fifth","sixth"];function j(s,t,e){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,t]:[St(`cmd ${s}`),t,e]}try{let i=0,[r,a,c]=n(),g=[].slice.call(a);for(;g.length&&g[g.length-1]===void 0;)g.pop();let w=c||g.length;if(w<r.demanded.length)throw new V(`Not enough arguments provided. Expected ${r.demanded.length} but received ${g.length}.`);let p=r.demanded.length+r.optional.length;if(w>p)throw new V(`Too many arguments provided. Expected max ${p} but received ${w}.`);r.demanded.forEach(h=>{let m=g.shift(),y=Wn(m);h.cmd.filter(_=>_===y||_==="*").length===0&&Ln(y,h.cmd,i),i+=1}),r.optional.forEach(h=>{if(g.length===0)return;let m=g.shift(),y=Wn(m);h.cmd.filter(_=>_===y||_==="*").length===0&&Ln(y,h.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function Wn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Ln(s,t,e){throw new V(`Invalid ${gs[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${s}.`)}var ye=class{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,i=!1){if(j("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let r=0;r<t.length;r++){if(typeof t[r]!="function")throw Error("middleware must be a function");let a=t[r];a.applyBeforeValidation=e,a.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if(typeof t=="function"){let r=t;r.applyBeforeValidation=e,r.global=n,r.mutates=i,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(i=>{let r=[...n[e]||[],e];return i.option?!r.includes(i.option):!0}),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let t=this.frozens.pop();t!==void 0&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter(t=>t.global)}};function Rn(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function Rt(s,t,e,n){return e.reduce((i,r)=>{if(r.applyBeforeValidation!==n)return i;if(r.mutates){if(r.applied)return i;r.applied=!0}if(q(i))return i.then(a=>Promise.all([a,r(a,t)])).then(([a,c])=>Object.assign(a,c));{let a=r(i,t);return q(a)?a.then(c=>Object.assign(i,c)):Object.assign(i,a)}},s)}function zt(s,t,e=n=>{throw n}){try{let n=bs(s)?s():s;return q(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function bs(s){return typeof s=="function"}function Ve(s){if(typeof Ot>"u")return null;for(let t=0,e=Object.keys(Ot.cache),n;t<e.length;t++)if(n=Ot.cache[e[t]],n.exports===s)return n;return null}var kt=/(^\*)|(^\$0)/,qe=class{constructor(t,e,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,i){i=i||{},typeof i.recurse!="boolean"&&(i.recurse=!1),Array.isArray(i.extensions)||(i.extensions=["js"]);let r=typeof i.visit=="function"?i.visit:a=>a;i.visit=(a,c,g)=>{let w=r(a,c,g);if(w){if(this.requireCache.has(c))return w;this.requireCache.add(c),this.addHandler(w)}return w},this.shim.requireDirectory({require:e,filename:n},t,i)}addHandler(t,e,n,i,r,a){let c=[],g=Rn(r);if(i=i||(()=>{}),Array.isArray(t))if(ws(t))[t,...c]=t;else for(let w of t)this.addHandler(w);else if(Os(t)){let w=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(w=[].concat(w).concat(t.aliases)),this.addHandler(w,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(zn(n)){this.addHandler([t].concat(c),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){let w=St(t);c=c.map(m=>St(m).cmd);let p=!1,h=[w.cmd].concat(c).filter(m=>kt.test(m)?(p=!0,!1):!0);h.length===0&&p&&h.push("$0"),p&&(w.cmd=h[0],c=h.slice(1),t=t.replace(kt,w.cmd)),c.forEach(m=>{this.aliasMap[m]=w.cmd}),e!==!1&&this.usage.command(t,e,p,c,a),this.handlers[w.cmd]={original:t,description:e,handler:i,builder:n||{},middlewares:g,deprecated:a,demanded:w.demanded,optional:w.optional},p&&(this.defaultCommand=this.handlers[w.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,i,r,a){let c=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,g=e.getInternalMethods().getContext(),w=g.commands.slice(),p=!t;t&&(g.commands.push(t),g.fullCommands.push(c.original));let h=this.applyBuilderUpdateUsageAndParse(p,c,e,n.aliases,w,i,r,a);return q(h)?h.then(m=>this.applyMiddlewareAndGetResult(p,c,m.innerArgv,g,r,m.aliases,e)):this.applyMiddlewareAndGetResult(p,c,h.innerArgv,g,r,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,c,g){let w=e.builder,p=n;if(Oe(w)){n.getInternalMethods().getUsageInstance().freeze();let h=w(n.getInternalMethods().reset(i),g);if(q(h))return h.then(m=>(p=Un(m)?m:n,this.parseAndUpdateUsage(t,e,p,r,a,c)))}else ys(w)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(h=>{p.option(h,w[h])}));return this.parseAndUpdateUsage(t,e,p,r,a,c)}parseAndUpdateUsage(t,e,n,i,r,a){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,e),e.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return q(c)?c.then(g=>({aliases:n.parsed.aliases,innerArgv:g})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let n=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,i=t.filter(r=>!kt.test(r));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(t,e,n,i,r,a,c,g){if(!a.getInternalMethods().getHasOutput()){let w=a.getInternalMethods().runValidation(r,g,a.parsed.error,t);n=zt(n,p=>(w(p),p))}if(e.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let w=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,w,!1,!1),n=Rt(n,a,c,!1),n=zt(n,p=>{let h=e.handler(p);return q(h)?h.then(()=>p):p}),t||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),q(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(p=>{try{a.getInternalMethods().getUsageInstance().fail(null,p)}catch{}})}return t||(i.commands.pop(),i.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,i,r,a,c){let g={};if(r)return n;c.getInternalMethods().getHasOutput()||(g=this.populatePositionals(e,n,i,c));let w=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),p=Rt(n,c,w,!0);return q(p)?p.then(h=>this.handleValidationAndGetResult(t,e,h,i,a,c,w,g)):this.handleValidationAndGetResult(t,e,p,i,a,c,w,g)}populatePositionals(t,e,n,i){e._=e._.slice(n.commands.length);let r=t.demanded.slice(0),a=t.optional.slice(0),c={};for(this.validation.positionalCount(r.length,e._.length);r.length;){let g=r.shift();this.populatePositional(g,e,c)}for(;a.length;){let g=a.shift();this.populatePositional(g,e,c)}return e._=n.commands.concat(e._.map(g=>""+g)),this.postProcessPositionals(e,c,this.cmdToParseOptions(t.original),i),c}populatePositional(t,e,n){let i=t.cmd[0];t.variadic?n[i]=e._.splice(0).map(String):e._.length&&(n[i]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},n=St(t);return n.demanded.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a,e.demand[r]=!0}),n.optional.forEach(i=>{let[r,...a]=i.cmd;i.variadic&&(e.array.push(r),e.default[r]=[]),e.alias[r]=a}),e}postProcessPositionals(t,e,n,i){let r=Object.assign({},i.getOptions());r.default=Object.assign(n.default,r.default);for(let w of Object.keys(n.alias))r.alias[w]=(r.alias[w]||[]).concat(n.alias[w]);r.array=r.array.concat(n.array),r.config={};let a=[];if(Object.keys(e).forEach(w=>{e[w].map(p=>{r.configuration["unknown-options-as-args"]&&(r.key[w]=!0),a.push(`--${w}`),a.push(p)})}),!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)i.getInternalMethods().getUsageInstance().fail(g.error.message,g.error);else{let w=Object.keys(e);Object.keys(e).forEach(p=>{w.push(...g.aliases[p])}),Object.keys(g.argv).forEach(p=>{w.includes(p)&&(e[p]||(e[p]=g.argv[p]),!this.isInConfigs(i,p)&&!this.isDefaulted(i,p)&&Object.prototype.hasOwnProperty.call(t,p)&&Object.prototype.hasOwnProperty.call(g.argv,p)&&(Array.isArray(t[p])||Array.isArray(g.argv[p]))?t[p]=[].concat(t[p],g.argv[p]):t[p]=g.argv[p])})}}isDefaulted(t,e){let{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:n}=t.getOptions();return n.some(i=>Object.prototype.hasOwnProperty.call(i,e))||n.some(i=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let n=kt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(Oe(e))return e(t,!0);zn(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){let e=Ve(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(let i of[t,e,n]){if(typeof i=="string"||i===!1)return i;ot(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();ot(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Tn(s,t,e,n){return new qe(s,t,e,n)}function zn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function ws(s){return s.every(t=>typeof t=="string")}function Oe(s){return typeof s=="function"}function ys(s){return typeof s=="object"}function Os(s){return typeof s=="object"&&!Array.isArray(s)}function It(s={},t=()=>!0){let e={};return Xt(s).forEach(n=>{t(n,s[n])&&(e[n]=s[n])}),e}function Mt(s){typeof process>"u"||[process.stdout,process.stderr].forEach(t=>{let e=t;e._handle&&e.isTTY&&typeof e._handle.setBlocking=="function"&&e._handle.setBlocking(s)})}function _s(s){return typeof s=="boolean"}function Bn(s,t){let e=t.y18n.__,n={},i=[];n.failFn=function(C){i.push(C)};let r=null,a=null,c=!0;n.showHelpOnFail=function(C=!0,P){let[W,B]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=B),r=B,c=W,n};let g=!1;n.fail=function(C,P){let W=s.getInternalMethods().getLoggerInstance();if(i.length)for(let B=i.length-1;B>=0;--B){let et=i[B];if(_s(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&Mt(!0),!g){g=!0,c&&(s.showHelp("error"),W.error()),(C||P)&&W.error(C||P);let B=r||a;B&&((C||P)&&W.error(""),W.error(B))}if(P=P||new V(C),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,P);throw P}};let w=[],p=!1;n.usage=(I,C)=>I===null?(p=!0,w=[],n):(p=!1,w.push([I,C||""]),n),n.getUsage=()=>w,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>e("Positionals:");let h=[];n.example=(I,C)=>{h.push([I,C||""])};let m=[];n.command=function(C,P,W,B,et=!1){W&&(m=m.map(H=>(H[2]=!1,H))),m.push([C,P||"",W,B,et])},n.getCommands=()=>m;let y={};n.describe=function(C,P){Array.isArray(C)?C.forEach(W=>{n.describe(W,P)}):typeof C=="object"?Object.keys(C).forEach(W=>{n.describe(W,C[W])}):y[C]=P},n.getDescriptions=()=>y;let E=[];n.epilog=I=>{E.push(I)};let _=!1,d;n.wrap=I=>{_=!0,d=I},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Jt(),_=!0),d);let R="__yargsString__:";n.deferY18nLookup=I=>R+I,n.help=function(){if(z)return z;U();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),W=s.getDemandedCommands(),B=s.getDeprecatedOptions(),et=s.getGroups(),H=s.getOptions(),nt=[];nt=nt.concat(Object.keys(y)),nt=nt.concat(Object.keys(P)),nt=nt.concat(Object.keys(W)),nt=nt.concat(Object.keys(H.default)),nt=nt.filter(Pt),nt=Object.keys(nt.reduce((v,K)=>(K!=="_"&&(v[K]=!0),v),{}));let Dt=n.getWrap(),Q=t.cliui({width:Dt,wrap:!!Dt});if(!p){if(w.length)w.forEach(v=>{Q.div({text:`${v[0].replace(/\$0/g,C)}`}),v[1]&&Q.div({text:`${v[1]}`,padding:[1,0,0,0]})}),Q.div();else if(m.length){let v=null;W._?v=`${C} <${e("command")}>
8
11
  `:v=`${C} [${e("command")}]
9
- `,Q.div(`${v}`)}}if(g.length>1||g.length===1&&!g[0][2]){Q.div(e("Commands:"));let v=s.getInternalMethods().getContext(),K=v.commands.length?`${v.commands.join(" ")} `:"";s.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(g=g.sort((R,Z)=>R[0].localeCompare(Z[0])));let J=C?`${C} `:"";g.forEach(R=>{let Z=`${J}${K}${R[0].replace(/^\$0 ?/,"")}`;Q.span({text:Z,padding:[0,2,0,2],width:z(g,Dt,`${C}${K}`)+4},{text:R[1]});let k=[];R[2]&&k.push(`[${e("default")}]`),R[3]&&R[3].length&&k.push(`[${e("aliases:")} ${R[3].join(", ")}]`),R[4]&&(typeof R[4]=="string"?k.push(`[${e("deprecated: %s",R[4])}]`):k.push(`[${e("deprecated")}]`)),k.length?Q.div({text:k.join(" "),padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}let xt=(Object.keys(U.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);nt=nt.filter(v=>!s.parsed.newAliases[v]&&xt.every(K=>(U.alias[K]||[]).indexOf(v)===-1));let Et=e("Options:");et[Et]||(et[Et]=[]),B(nt,U.alias,et,Et);let Wt=v=>/^--/.test(_e(v)),F=Object.keys(et).filter(v=>et[v].length>0).map(v=>{let K=et[v].filter(Pt).map(J=>{if(xt.includes(J))return J;for(let R=0,Z;(Z=xt[R])!==void 0;R++)if((U.alias[Z]||[]).includes(J))return Z;return J});return{groupName:v,normalizedKeys:K}}).filter(({normalizedKeys:v})=>v.length>0).map(({groupName:v,normalizedKeys:K})=>{let J=K.reduce((R,Z)=>(R[Z]=[Z].concat(U.alias[Z]||[]).map(k=>v===n.getPositionalGroupName()?k:(/^[0-9]$/.test(k)?U.boolean.includes(Z)?"-":"--":k.length>1?"--":"-")+k).sort((k,bt)=>Wt(k)===Wt(bt)?0:Wt(k)?1:-1).join(", "),R),{});return{groupName:v,normalizedKeys:K,switches:J}});if(F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).some(({normalizedKeys:v,switches:K})=>!v.every(J=>Wt(K[J])))&&F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).forEach(({normalizedKeys:v,switches:K})=>{v.forEach(J=>{Wt(K[J])&&(K[J]=ys(K[J],4))})}),F.forEach(({groupName:v,normalizedKeys:K,switches:J})=>{Q.div(v),K.forEach(R=>{let Z=J[R],k=y[R]||"",bt=null;k.includes(W)&&(k=e(k.substring(W.length))),U.boolean.includes(R)&&(bt=`[${e("boolean")}]`),U.count.includes(R)&&(bt=`[${e("count")}]`),U.string.includes(R)&&(bt=`[${e("string")}]`),U.normalize.includes(R)&&(bt=`[${e("string")}]`),U.array.includes(R)&&(bt=`[${e("array")}]`),U.number.includes(R)&&(bt=`[${e("number")}]`);let wt=h=>typeof h=="string"?`[${e("deprecated: %s",h)}]`:`[${e("deprecated")}]`,he=[R in H?wt(H[R]):null,bt,R in P?`[${e("required")}]`:null,U.choices&&U.choices[R]?`[${e("choices:")} ${n.stringifiedValues(U.choices[R])}]`:null,gt(U.default[R],U.defaultDescription[R])].filter(Boolean).join(" ");Q.span({text:_e(Z),padding:[0,2,0,2+Hn(Z)],width:z(J,Dt)+4},k);let l=s.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;he&&!l?Q.div({text:he,padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}),u.length&&(Q.div(e("Examples:")),u.forEach(v=>{v[0]=v[0].replace(/\$0/g,C)}),u.forEach(v=>{v[1]===""?Q.div({text:v[0],padding:[0,2,0,2]}):Q.div({text:v[0],padding:[0,2,0,2],width:z(u,Dt)+4},{text:v[1]})}),Q.div()),E.length>0){let v=E.map(K=>K.replace(/\$0/g,C)).join(`
12
+ `,Q.div(`${v}`)}}if(m.length>1||m.length===1&&!m[0][2]){Q.div(e("Commands:"));let v=s.getInternalMethods().getContext(),K=v.commands.length?`${v.commands.join(" ")} `:"";s.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(m=m.sort((T,Z)=>T[0].localeCompare(Z[0])));let J=C?`${C} `:"";m.forEach(T=>{let Z=`${J}${K}${T[0].replace(/^\$0 ?/,"")}`;Q.span({text:Z,padding:[0,2,0,2],width:L(m,Dt,`${C}${K}`)+4},{text:T[1]});let k=[];T[2]&&k.push(`[${e("default")}]`),T[3]&&T[3].length&&k.push(`[${e("aliases:")} ${T[3].join(", ")}]`),T[4]&&(typeof T[4]=="string"?k.push(`[${e("deprecated: %s",T[4])}]`):k.push(`[${e("deprecated")}]`)),k.length?Q.div({text:k.join(" "),padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}let xt=(Object.keys(H.alias)||[]).concat(Object.keys(s.parsed.newAliases)||[]);nt=nt.filter(v=>!s.parsed.newAliases[v]&&xt.every(K=>(H.alias[K]||[]).indexOf(v)===-1));let Et=e("Options:");et[Et]||(et[Et]=[]),Y(nt,H.alias,et,Et);let Wt=v=>/^--/.test(_e(v)),F=Object.keys(et).filter(v=>et[v].length>0).map(v=>{let K=et[v].filter(Pt).map(J=>{if(xt.includes(J))return J;for(let T=0,Z;(Z=xt[T])!==void 0;T++)if((H.alias[Z]||[]).includes(J))return Z;return J});return{groupName:v,normalizedKeys:K}}).filter(({normalizedKeys:v})=>v.length>0).map(({groupName:v,normalizedKeys:K})=>{let J=K.reduce((T,Z)=>(T[Z]=[Z].concat(H.alias[Z]||[]).map(k=>v===n.getPositionalGroupName()?k:(/^[0-9]$/.test(k)?H.boolean.includes(Z)?"-":"--":k.length>1?"--":"-")+k).sort((k,bt)=>Wt(k)===Wt(bt)?0:Wt(k)?1:-1).join(", "),T),{});return{groupName:v,normalizedKeys:K,switches:J}});if(F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).some(({normalizedKeys:v,switches:K})=>!v.every(J=>Wt(K[J])))&&F.filter(({groupName:v})=>v!==n.getPositionalGroupName()).forEach(({normalizedKeys:v,switches:K})=>{v.forEach(J=>{Wt(K[J])&&(K[J]=Cs(K[J],4))})}),F.forEach(({groupName:v,normalizedKeys:K,switches:J})=>{Q.div(v),K.forEach(T=>{let Z=J[T],k=y[T]||"",bt=null;k.includes(R)&&(k=e(k.substring(R.length))),H.boolean.includes(T)&&(bt=`[${e("boolean")}]`),H.count.includes(T)&&(bt=`[${e("count")}]`),H.string.includes(T)&&(bt=`[${e("string")}]`),H.normalize.includes(T)&&(bt=`[${e("string")}]`),H.array.includes(T)&&(bt=`[${e("array")}]`),H.number.includes(T)&&(bt=`[${e("number")}]`);let wt=u=>typeof u=="string"?`[${e("deprecated: %s",u)}]`:`[${e("deprecated")}]`,ue=[T in B?wt(B[T]):null,bt,T in P?`[${e("required")}]`:null,H.choices&&H.choices[T]?`[${e("choices:")} ${n.stringifiedValues(H.choices[T])}]`:null,gt(H.default[T],H.defaultDescription[T])].filter(Boolean).join(" ");Q.span({text:_e(Z),padding:[0,2,0,2+Hn(Z)],width:L(J,Dt)+4},k);let l=s.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;ue&&!l?Q.div({text:ue,padding:[0,0,0,2],align:"right"}):Q.div()}),Q.div()}),h.length&&(Q.div(e("Examples:")),h.forEach(v=>{v[0]=v[0].replace(/\$0/g,C)}),h.forEach(v=>{v[1]===""?Q.div({text:v[0],padding:[0,2,0,2]}):Q.div({text:v[0],padding:[0,2,0,2],width:L(h,Dt)+4},{text:v[1]})}),Q.div()),E.length>0){let v=E.map(K=>K.replace(/\$0/g,C)).join(`
10
13
  `);Q.div(`${v}
11
- `)}return Q.toString().replace(/\s*$/,"")};function z(I,C,P){let L=0;return Array.isArray(I)||(I=Object.values(I).map(H=>[H])),I.forEach(H=>{L=Math.max(t.stringWidth(P?`${P} ${_e(H[0])}`:_e(H[0]))+Hn(H[0]),L)}),C&&(L=Math.min(L,parseInt((C*.5).toString(),10))),L}function Y(){let I=s.getDemandedOptions(),C=s.getOptions();(Object.keys(C.alias)||[]).forEach(P=>{C.alias[P].forEach(L=>{y[L]&&n.describe(P,y[L]),L in I&&s.demandOption(P,I[L]),C.boolean.includes(L)&&s.boolean(P),C.count.includes(L)&&s.count(P),C.string.includes(L)&&s.string(P),C.normalize.includes(L)&&s.normalize(P),C.array.includes(L)&&s.array(P),C.number.includes(L)&&s.number(P)})})}let T;n.cacheHelpMessage=function(){T=this.help()},n.clearCachedHelpMessage=function(){T=void 0},n.hasCachedHelpMessage=function(){return!!T};function B(I,C,P,L){let H=[],et=null;return Object.keys(P).forEach(U=>{H=H.concat(P[U])}),I.forEach(U=>{et=[U].concat(C[U]),et.some(nt=>H.indexOf(nt)!==-1)||P[L].push(U)}),H}function Pt(I){return s.getOptions().hiddenOptions.indexOf(I)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(n.help())},n.functionDescription=I=>["(",I.name?t.Parser.decamelize(I.name,"-"):e("generated-value"),")"].join(""),n.stringifiedValues=function(C,P){let L="",H=P||", ",et=[].concat(C);return!C||!et.length||et.forEach(U=>{L.length&&(L+=H),L+=JSON.stringify(U)}),L};function gt(I,C){let P=`[${e("default:")} `;if(I===void 0&&!C)return null;if(C)P+=C;else switch(typeof I){case"string":P+=`"${I}"`;break;case"object":P+=JSON.stringify(I);break;default:P+=I}return`${P}]`}function Jt(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let Nt=null;n.version=I=>{Nt=I},n.showVersion=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(Nt)},n.reset=function(C){return r=null,m=!1,w=[],p=!1,E=[],u=[],g=[],y=It(y,P=>!C[P]),n};let G=[];return n.freeze=function(){G.push({failMessage:r,failureOutput:m,usages:w,usageDisabled:p,epilogs:E,examples:u,commands:g,descriptions:y})},n.unfreeze=function(C=!1){let P=G.pop();P&&(C?(y={...P.descriptions,...y},g=[...P.commands,...g],w=[...P.usages,...w],u=[...P.examples,...u],E=[...P.epilogs,...E]):{failMessage:r,failureOutput:m,usages:w,usageDisabled:p,epilogs:E,examples:u,commands:g,descriptions:y}=P)},n}function Ke(s){return typeof s=="object"}function ys(s,t){return Ke(s)?{text:s.text,indentation:s.indentation+t}:{text:s,indentation:t}}function Hn(s){return Ke(s)?s.indentation:0}function _e(s){return Ke(s)?s.text:s}var Bn=`###-begin-{{app_name}}-completions-###
14
+ `)}return Q.toString().replace(/\s*$/,"")};function L(I,C,P){let W=0;return Array.isArray(I)||(I=Object.values(I).map(B=>[B])),I.forEach(B=>{W=Math.max(t.stringWidth(P?`${P} ${_e(B[0])}`:_e(B[0]))+Hn(B[0]),W)}),C&&(W=Math.min(W,parseInt((C*.5).toString(),10))),W}function U(){let I=s.getDemandedOptions(),C=s.getOptions();(Object.keys(C.alias)||[]).forEach(P=>{C.alias[P].forEach(W=>{y[W]&&n.describe(P,y[W]),W in I&&s.demandOption(P,I[W]),C.boolean.includes(W)&&s.boolean(P),C.count.includes(W)&&s.count(P),C.string.includes(W)&&s.string(P),C.normalize.includes(W)&&s.normalize(P),C.array.includes(W)&&s.array(P),C.number.includes(W)&&s.number(P)})})}let z;n.cacheHelpMessage=function(){z=this.help()},n.clearCachedHelpMessage=function(){z=void 0},n.hasCachedHelpMessage=function(){return!!z};function Y(I,C,P,W){let B=[],et=null;return Object.keys(P).forEach(H=>{B=B.concat(P[H])}),I.forEach(H=>{et=[H].concat(C[H]),et.some(nt=>B.indexOf(nt)!==-1)||P[W].push(H)}),B}function Pt(I){return s.getOptions().hiddenOptions.indexOf(I)<0||s.parsed.argv[s.getOptions().showHiddenOpt]}n.showHelp=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(n.help())},n.functionDescription=I=>["(",I.name?t.Parser.decamelize(I.name,"-"):e("generated-value"),")"].join(""),n.stringifiedValues=function(C,P){let W="",B=P||", ",et=[].concat(C);return!C||!et.length||et.forEach(H=>{W.length&&(W+=B),W+=JSON.stringify(H)}),W};function gt(I,C){let P=`[${e("default:")} `;if(I===void 0&&!C)return null;if(C)P+=C;else switch(typeof I){case"string":P+=`"${I}"`;break;case"object":P+=JSON.stringify(I);break;default:P+=I}return`${P}]`}function Jt(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let Nt=null;n.version=I=>{Nt=I},n.showVersion=I=>{let C=s.getInternalMethods().getLoggerInstance();I||(I="error"),(typeof I=="function"?I:C[I])(Nt)},n.reset=function(C){return r=null,g=!1,w=[],p=!1,E=[],h=[],m=[],y=It(y,P=>!C[P]),n};let G=[];return n.freeze=function(){G.push({failMessage:r,failureOutput:g,usages:w,usageDisabled:p,epilogs:E,examples:h,commands:m,descriptions:y})},n.unfreeze=function(C=!1){let P=G.pop();P&&(C?(y={...P.descriptions,...y},m=[...P.commands,...m],w=[...P.usages,...w],h=[...P.examples,...h],E=[...P.epilogs,...E]):{failMessage:r,failureOutput:g,usages:w,usageDisabled:p,epilogs:E,examples:h,commands:m,descriptions:y}=P)},n}function Ke(s){return typeof s=="object"}function Cs(s,t){return Ke(s)?{text:s.text,indentation:s.indentation+t}:{text:s,indentation:t}}function Hn(s){return Ke(s)?s.indentation:0}function _e(s){return Ke(s)?s.text:s}var Yn=`###-begin-{{app_name}}-completions-###
12
15
  #
13
16
  # yargs command completion script
14
17
  #
@@ -55,14 +58,14 @@ _{{app_name}}_yargs_completions()
55
58
  }
56
59
  compdef _{{app_name}}_yargs_completions {{app_name}}
57
60
  ###-end-{{app_name}}-completions-###
58
- `;var Qe=class{constructor(t,e,n,i){var r,a,c;this.yargs=t,this.usage=e,this.command=n,this.shim=i,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(t,e,n,i){let r=this.command.getCommandHandlers();for(let c=0,m=t.length;c<m;++c)if(r[t[c]]&&r[t[c]].builder){let w=r[t[c]].builder;if(Oe(w)){this.indexAfterLastReset=c+1;let p=this.yargs.getInternalMethods().reset();return w(p,!0),p.argv}}let a=[];this.commandCompletions(a,t,n),this.optionCompletions(a,t,e,n),this.choicesFromOptionsCompletions(a,t,e,n),this.choicesFromPositionalsCompletions(a,t,e,n),i(null,a)}commandCompletions(t,e,n){let i=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(e)&&this.usage.getCommands().forEach(r=>{let a=St(r[0]).cmd;if(e.indexOf(a)===-1)if(!this.zshShell)t.push(a);else{let c=r[1]||"";t.push(a.replace(/:/g,"\\:")+":"+c)}})}optionCompletions(t,e,n,i){if((i.match(/^-/)||i===""&&t.length===0)&&!this.previousArgHasChoices(e)){let r=this.yargs.getOptions(),a=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(r.key).forEach(c=>{let m=!!r.configuration["boolean-negation"]&&r.boolean.includes(c);!a.includes(c)&&!r.hiddenOptions.includes(c)&&!this.argsContainKey(e,c,m)&&this.completeOptionKey(c,t,i,m&&!!r.default[c])})}}choicesFromOptionsCompletions(t,e,n,i){if(this.previousArgHasChoices(e)){let r=this.getPreviousArgChoices(e);r&&r.length>0&&t.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(t,e,n,i){if(i===""&&t.length>0&&this.previousArgHasChoices(e))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 m=this.yargs.getOptions().choices[c]||[];for(let w of m)w.startsWith(i)&&t.push(w.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],n="";if(!e.startsWith("-")&&t.length>1&&(n=e,e=t[t.length-2]),!e.startsWith("-"))return;let i=e.replace(/^-+/,""),r=this.yargs.getOptions(),a=[i,...this.yargs.getAliases()[i]||[]],c;for(let m of a)if(Object.prototype.hasOwnProperty.call(r.key,m)&&Array.isArray(r.choices[m])){c=r.choices[m];break}if(c)return c.filter(m=>!n||m.startsWith(n))}previousArgHasChoices(t){let e=this.getPreviousArgChoices(t);return e!==void 0&&e.length>0}argsContainKey(t,e,n){let i=r=>t.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(i(e)||n&&i(`no-${e}`))return!0;if(this.aliases){for(let r of this.aliases[e])if(i(r))return!0}return!1}completeOptionKey(t,e,n,i){var r,a,c,m;let w=t;if(this.zshShell){let y=this.usage.getDescriptions(),E=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[t])===null||a===void 0?void 0:a.find(W=>{let z=y[W];return typeof z=="string"&&z.length>0}),_=E?y[E]:void 0,d=(m=(c=y[t])!==null&&c!==void 0?c:_)!==null&&m!==void 0?m:"";w=`${t.replace(/:/g,"\\:")}:${d.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=y=>/^--/.test(y),u=y=>/^[^0-9]$/.test(y),g=!p(n)&&u(t)?"-":"--";e.push(g+w),i&&e.push(g+"no-"+w)}customCompletion(t,e,n,i){if(ot(this.customCompletionFunction,null,this.shim),_s(this.customCompletionFunction)){let r=this.customCompletionFunction(n,e);return q(r)?r.then(a=>{this.shim.process.nextTick(()=>{i(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{i(a,void 0)})}):i(null,r)}else return Cs(this.customCompletionFunction)?this.customCompletionFunction(n,e,(r=i)=>this.defaultCompletion(t,e,n,r),r=>{i(null,r)}):this.customCompletionFunction(n,e,r=>{i(null,r)})}getCompletion(t,e){let n=t.length?t[t.length-1]:"",i=this.yargs.parse(t,!0),r=this.customCompletionFunction?a=>this.customCompletion(t,a,n,e):a=>this.defaultCompletion(t,a,n,e);return q(i)?i.then(r):r(i)}generateCompletionScript(t,e){let n=this.zshShell?Gn:Bn,i=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,i),n=n.replace(/{{completion_command}}/g,e),n.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}};function Vn(s,t,e,n){return new Qe(s,t,e,n)}function _s(s){return s.length<3}function Cs(s){return s.length>3}function qn(s,t){if(s.length===0)return t.length;if(t.length===0)return s.length;let e=[],n;for(n=0;n<=t.length;n++)e[n]=[n];let i;for(i=0;i<=s.length;i++)e[0][i]=i;for(n=1;n<=t.length;n++)for(i=1;i<=s.length;i++)t.charAt(n-1)===s.charAt(i-1)?e[n][i]=e[n-1][i-1]:n>1&&i>1&&t.charAt(n-2)===s.charAt(i-1)&&t.charAt(n-1)===s.charAt(i-2)?e[n][i]=e[n-2][i-2]+1:e[n][i]=Math.min(e[n-1][i-1]+1,Math.min(e[n][i-1]+1,e[n-1][i]+1));return e[t.length][s.length]}var Kn=["$0","--","_"];function Qn(s,t,e){let n=e.y18n.__,i=e.y18n.__n,r={};r.nonOptionCount=function(u){let g=s.getDemandedCommands(),E=u._.length+(u["--"]?u["--"].length:0)-s.getInternalMethods().getContext().commands.length;g._&&(E<g._.min||E>g._.max)&&(E<g._.min?g._.minMsg!==void 0?t.fail(g._.minMsg?g._.minMsg.replace(/\$0/g,E.toString()).replace(/\$1/,g._.min.toString()):null):t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",E,E.toString(),g._.min.toString())):E>g._.max&&(g._.maxMsg!==void 0?t.fail(g._.maxMsg?g._.maxMsg.replace(/\$0/g,E.toString()).replace(/\$1/,g._.max.toString()):null):t.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",E,E.toString(),g._.max.toString()))))},r.positionalCount=function(u,g){g<u&&t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",g,g+"",u+""))},r.requiredArguments=function(u,g){let y=null;for(let E of Object.keys(g))(!Object.prototype.hasOwnProperty.call(u,E)||typeof u[E]>"u")&&(y=y||{},y[E]=g[E]);if(y){let E=[];for(let d of Object.keys(y)){let W=y[d];W&&E.indexOf(W)<0&&E.push(W)}let _=E.length?`
61
+ `;var Qe=class{constructor(t,e,n,i){var r,a,c;this.yargs=t,this.usage=e,this.command=n,this.shim=i,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(t,e,n,i){let r=this.command.getCommandHandlers();for(let c=0,g=t.length;c<g;++c)if(r[t[c]]&&r[t[c]].builder){let w=r[t[c]].builder;if(Oe(w)){this.indexAfterLastReset=c+1;let p=this.yargs.getInternalMethods().reset();return w(p,!0),p.argv}}let a=[];this.commandCompletions(a,t,n),this.optionCompletions(a,t,e,n),this.choicesFromOptionsCompletions(a,t,e,n),this.choicesFromPositionalsCompletions(a,t,e,n),i(null,a)}commandCompletions(t,e,n){let i=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&i[i.length-1]!==n&&!this.previousArgHasChoices(e)&&this.usage.getCommands().forEach(r=>{let a=St(r[0]).cmd;if(e.indexOf(a)===-1)if(!this.zshShell)t.push(a);else{let c=r[1]||"";t.push(a.replace(/:/g,"\\:")+":"+c)}})}optionCompletions(t,e,n,i){if((i.match(/^-/)||i===""&&t.length===0)&&!this.previousArgHasChoices(e)){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(e,c,g)&&this.completeOptionKey(c,t,i,g&&!!r.default[c])})}}choicesFromOptionsCompletions(t,e,n,i){if(this.previousArgHasChoices(e)){let r=this.getPreviousArgChoices(e);r&&r.length>0&&t.push(...r.map(a=>a.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(t,e,n,i){if(i===""&&t.length>0&&this.previousArgHasChoices(e))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 w of g)w.startsWith(i)&&t.push(w.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],n="";if(!e.startsWith("-")&&t.length>1&&(n=e,e=t[t.length-2]),!e.startsWith("-"))return;let i=e.replace(/^-+/,""),r=this.yargs.getOptions(),a=[i,...this.yargs.getAliases()[i]||[]],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(t){let e=this.getPreviousArgChoices(t);return e!==void 0&&e.length>0}argsContainKey(t,e,n){let i=r=>t.indexOf((/^[^0-9]$/.test(r)?"-":"--")+r)!==-1;if(i(e)||n&&i(`no-${e}`))return!0;if(this.aliases){for(let r of this.aliases[e])if(i(r))return!0}return!1}completeOptionKey(t,e,n,i){var r,a,c,g;let w=t;if(this.zshShell){let y=this.usage.getDescriptions(),E=(a=(r=this===null||this===void 0?void 0:this.aliases)===null||r===void 0?void 0:r[t])===null||a===void 0?void 0:a.find(R=>{let L=y[R];return typeof L=="string"&&L.length>0}),_=E?y[E]:void 0,d=(g=(c=y[t])!==null&&c!==void 0?c:_)!==null&&g!==void 0?g:"";w=`${t.replace(/:/g,"\\:")}:${d.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=y=>/^--/.test(y),h=y=>/^[^0-9]$/.test(y),m=!p(n)&&h(t)?"-":"--";e.push(m+w),i&&e.push(m+"no-"+w)}customCompletion(t,e,n,i){if(ot(this.customCompletionFunction,null,this.shim),Es(this.customCompletionFunction)){let r=this.customCompletionFunction(n,e);return q(r)?r.then(a=>{this.shim.process.nextTick(()=>{i(null,a)})}).catch(a=>{this.shim.process.nextTick(()=>{i(a,void 0)})}):i(null,r)}else return js(this.customCompletionFunction)?this.customCompletionFunction(n,e,(r=i)=>this.defaultCompletion(t,e,n,r),r=>{i(null,r)}):this.customCompletionFunction(n,e,r=>{i(null,r)})}getCompletion(t,e){let n=t.length?t[t.length-1]:"",i=this.yargs.parse(t,!0),r=this.customCompletionFunction?a=>this.customCompletion(t,a,n,e):a=>this.defaultCompletion(t,a,n,e);return q(i)?i.then(r):r(i)}generateCompletionScript(t,e){let n=this.zshShell?Gn:Yn,i=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,i),n=n.replace(/{{completion_command}}/g,e),n.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}};function Vn(s,t,e,n){return new Qe(s,t,e,n)}function Es(s){return s.length<3}function js(s){return s.length>3}function qn(s,t){if(s.length===0)return t.length;if(t.length===0)return s.length;let e=[],n;for(n=0;n<=t.length;n++)e[n]=[n];let i;for(i=0;i<=s.length;i++)e[0][i]=i;for(n=1;n<=t.length;n++)for(i=1;i<=s.length;i++)t.charAt(n-1)===s.charAt(i-1)?e[n][i]=e[n-1][i-1]:n>1&&i>1&&t.charAt(n-2)===s.charAt(i-1)&&t.charAt(n-1)===s.charAt(i-2)?e[n][i]=e[n-2][i-2]+1:e[n][i]=Math.min(e[n-1][i-1]+1,Math.min(e[n][i-1]+1,e[n-1][i]+1));return e[t.length][s.length]}var Kn=["$0","--","_"];function Qn(s,t,e){let n=e.y18n.__,i=e.y18n.__n,r={};r.nonOptionCount=function(h){let m=s.getDemandedCommands(),E=h._.length+(h["--"]?h["--"].length:0)-s.getInternalMethods().getContext().commands.length;m._&&(E<m._.min||E>m._.max)&&(E<m._.min?m._.minMsg!==void 0?t.fail(m._.minMsg?m._.minMsg.replace(/\$0/g,E.toString()).replace(/\$1/,m._.min.toString()):null):t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",E,E.toString(),m._.min.toString())):E>m._.max&&(m._.maxMsg!==void 0?t.fail(m._.maxMsg?m._.maxMsg.replace(/\$0/g,E.toString()).replace(/\$1/,m._.max.toString()):null):t.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",E,E.toString(),m._.max.toString()))))},r.positionalCount=function(h,m){m<h&&t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",m,m+"",h+""))},r.requiredArguments=function(h,m){let y=null;for(let E of Object.keys(m))(!Object.prototype.hasOwnProperty.call(h,E)||typeof h[E]>"u")&&(y=y||{},y[E]=m[E]);if(y){let E=[];for(let d of Object.keys(y)){let R=y[d];R&&E.indexOf(R)<0&&E.push(R)}let _=E.length?`
59
62
  ${E.join(`
60
- `)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(y).length,Object.keys(y).join(", ")+_))}},r.unknownArguments=function(u,g,y,E,_=!0){var d;let W=s.getInternalMethods().getCommandInstance().getCommands(),z=[],Y=s.getInternalMethods().getContext();if(Object.keys(u).forEach(T=>{!Kn.includes(T)&&!Object.prototype.hasOwnProperty.call(y,T)&&!Object.prototype.hasOwnProperty.call(s.getInternalMethods().getParseContext(),T)&&!r.isValidAndSomeAliasIsNotNew(T,g)&&z.push(T)}),_&&(Y.commands.length>0||W.length>0||E)&&u._.slice(Y.commands.length).forEach(T=>{W.includes(""+T)||z.push(""+T)}),_){let B=((d=s.getDemandedCommands()._)===null||d===void 0?void 0:d.max)||0,Pt=Y.commands.length+B;Pt<u._.length&&u._.slice(Pt).forEach(gt=>{gt=String(gt),!Y.commands.includes(gt)&&!z.includes(gt)&&z.push(gt)})}z.length&&t.fail(i("Unknown argument: %s","Unknown arguments: %s",z.length,z.map(T=>T.trim()?T:`"${T}"`).join(", ")))},r.unknownCommands=function(u){let g=s.getInternalMethods().getCommandInstance().getCommands(),y=[],E=s.getInternalMethods().getContext();return(E.commands.length>0||g.length>0)&&u._.slice(E.commands.length).forEach(_=>{g.includes(""+_)||y.push(""+_)}),y.length>0?(t.fail(i("Unknown command: %s","Unknown commands: %s",y.length,y.join(", "))),!0):!1},r.isValidAndSomeAliasIsNotNew=function(u,g){if(!Object.prototype.hasOwnProperty.call(g,u))return!1;let y=s.parsed.newAliases;return[u,...g[u]].some(E=>!Object.prototype.hasOwnProperty.call(y,E)||!y[u])},r.limitedChoices=function(u){let g=s.getOptions(),y={};if(!Object.keys(g.choices).length)return;Object.keys(u).forEach(d=>{Kn.indexOf(d)===-1&&Object.prototype.hasOwnProperty.call(g.choices,d)&&[].concat(u[d]).forEach(W=>{g.choices[d].indexOf(W)===-1&&W!==void 0&&(y[d]=(y[d]||[]).concat(W))})});let E=Object.keys(y);if(!E.length)return;let _=n("Invalid values:");E.forEach(d=>{_+=`
61
- ${n("Argument: %s, Given: %s, Choices: %s",d,t.stringifiedValues(y[d]),t.stringifiedValues(g.choices[d]))}`}),t.fail(_)};let a={};r.implies=function(u,g){j("<string|object> [array|number|string]",[u,g],arguments.length),typeof u=="object"?Object.keys(u).forEach(y=>{r.implies(y,u[y])}):(s.global(u),a[u]||(a[u]=[]),Array.isArray(g)?g.forEach(y=>r.implies(u,y)):(ot(g,void 0,e),a[u].push(g)))},r.getImplied=function(){return a};function c(p,u){let g=Number(u);return u=isNaN(g)?u:g,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 g=[];if(Object.keys(a).forEach(y=>{let E=y;(a[y]||[]).forEach(_=>{let d=E,W=_;d=c(u,d),_=c(u,_),d&&!_&&g.push(` ${E} -> ${W}`)})}),g.length){let y=`${n("Implications failed:")}
62
- `;g.forEach(E=>{y+=E}),t.fail(y)}};let m={};r.conflicts=function(u,g){j("<string|object> [array|string]",[u,g],arguments.length),typeof u=="object"?Object.keys(u).forEach(y=>{r.conflicts(y,u[y])}):(s.global(u),m[u]||(m[u]=[]),Array.isArray(g)?g.forEach(y=>r.conflicts(u,y)):m[u].push(g))},r.getConflicting=()=>m,r.conflicting=function(u){Object.keys(u).forEach(g=>{m[g]&&m[g].forEach(y=>{y&&u[g]!==void 0&&u[y]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})}),s.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(m).forEach(g=>{m[g].forEach(y=>{y&&u[e.Parser.camelCase(g)]!==void 0&&u[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})})},r.recommendCommands=function(u,g){g=g.sort((d,W)=>W.length-d.length);let E=null,_=1/0;for(let d=0,W;(W=g[d])!==void 0;d++){let z=qn(u,W);z<=3&&z<_&&(_=z,E=W)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(u){return a=It(a,g=>!u[g]),m=It(m,g=>!u[g]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:m})},r.unfreeze=function(){let u=w.pop();ot(u,void 0,e),{implied:a,conflicting:m}=u},r}var Je=[],ae;function le(s,t,e,n){ae=n;let i={};if(Object.prototype.hasOwnProperty.call(s,"extends")){if(typeof s.extends!="string")return i;let r=/\.json|\..*rc$/.test(s.extends),a=null;if(r)a=Es(t,s.extends);else try{a=Ot.resolve(s.extends)}catch{return s}xs(a),Je.push(a),i=r?JSON.parse(ae.readFileSync(a,"utf8")):Ot(s.extends),delete s.extends,i=le(i,ae.path.dirname(a),e,ae)}return Je=[],e?Jn(i,s):Object.assign({},i,s)}function xs(s){if(Je.indexOf(s)>-1)throw new V(`Circular extended configurations: '${s}'.`)}function Es(s,t){return ae.path.resolve(s,t)}function Jn(s,t){let e={};function n(i){return i&&typeof i=="object"&&!Array.isArray(i)}Object.assign(e,s);for(let i of Object.keys(t))n(t[i])&&n(e[i])?e[i]=Jn(s[i],t[i]):e[i]=t[i];return e}var A=function(s,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?s!==t||!i:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(s,e):i?i.value=e:t.set(s,e),e},o=function(s,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?s!==t||!n:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(s):n?n.value:t.get(s)},tt,Tt,ce,ut,lt,Ce,$t,Ut,xe,dt,Ee,pt,_t,ct,mt,je,te,st,M,Ae,Pe,ft,Ht,ee,Yt,vt,Se,N,Bt,Gt,Vt,D,Ie,Ct,X;function gi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new ln(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Zn=Symbol("copyDoubleDash"),Xn=Symbol("copyDoubleDash"),Ze=Symbol("deleteFromParserHintObject"),kn=Symbol("emitWarning"),ti=Symbol("freeze"),ei=Symbol("getDollarZero"),qt=Symbol("getParserConfiguration"),ni=Symbol("getUsageConfiguration"),Xe=Symbol("guessLocale"),ii=Symbol("guessVersion"),si=Symbol("parsePositionalNumbers"),ke=Symbol("pkgUp"),Ft=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),tn=Symbol("populateParserHintArrayDictionary"),en=Symbol("populateParserHintDictionary"),nn=Symbol("sanitizeKey"),sn=Symbol("setKey"),rn=Symbol("unfreeze"),ri=Symbol("validateAsync"),oi=Symbol("getCommandInstance"),ai=Symbol("getContext"),li=Symbol("getHasOutput"),ci=Symbol("getLoggerInstance"),fi=Symbol("getParseContext"),hi=Symbol("getUsageInstance"),ui=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),di=Symbol("isGlobalContext"),Kt=Symbol("postProcess"),pi=Symbol("rebase"),on=Symbol("reset"),fe=Symbol("runYargsParserAndExecuteCommands"),an=Symbol("runValidation"),mi=Symbol("setHasOutput"),Qt=Symbol("kTrackManuallySetKeys"),ln=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Tt.set(this,void 0),ce.set(this,{commands:[],fullCommands:[]}),ut.set(this,null),lt.set(this,null),Ce.set(this,"show-hidden"),$t.set(this,null),Ut.set(this,!0),xe.set(this,{}),dt.set(this,!0),Ee.set(this,[]),pt.set(this,void 0),_t.set(this,{}),ct.set(this,!1),mt.set(this,null),je.set(this,!0),te.set(this,void 0),st.set(this,""),M.set(this,void 0),Ae.set(this,void 0),Pe.set(this,{}),ft.set(this,null),Ht.set(this,null),ee.set(this,{}),Yt.set(this,{}),vt.set(this,void 0),Se.set(this,!1),N.set(this,void 0),Bt.set(this,!1),Gt.set(this,!1),Vt.set(this,!1),D.set(this,void 0),Ie.set(this,{}),Ct.set(this,null),X.set(this,void 0),A(this,N,i,"f"),A(this,vt,t,"f"),A(this,Tt,e,"f"),A(this,Ae,n,"f"),A(this,pt,new ye(this),"f"),this.$0=this[ei](),this[on](),A(this,tt,o(this,tt,"f"),"f"),A(this,D,o(this,D,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,M,o(this,M,"f"),"f"),o(this,M,"f").showHiddenOpt=o(this,Ce,"f"),A(this,te,this[Xn](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,mt,"f")&&(this[Ze](o(this,mt,"f")),A(this,mt,null,"f")),t===!1&&e===void 0?this:(A(this,mt,typeof t=="string"?t:n,"f"),this.boolean(o(this,mt,"f")),this.describe(o(this,mt,"f"),e||o(this,D,"f").deferY18nLookup("Show help")),this)}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(j("[string|boolean] [string]",[t,e],arguments.length),t===!1&&e===void 0)return this;let n=typeof t=="string"?t:o(this,Ce,"f");return this.boolean(n),this.describe(n,e||o(this,D,"f").deferY18nLookup("Show hidden options")),o(this,M,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[tn](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[Ft]("array",t),this[Qt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[Ft]("boolean",t),this[Qt](t),this}check(t,e){return j("<function> [boolean]",[t,e],arguments.length),this.middleware((n,i)=>Rt(()=>t(n,i.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,D,"f").fail(r.toString(),r):o(this,D,"f").fail(o(this,N,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,D,"f").fail(r.message?r.message:r.toString(),r),n)),!1,e),this}choices(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[tn](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(j("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new V("coerce callback must be provided");for(let n of t)this.coerce(n,e);return this}else if(typeof t=="object"){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!e)throw new V("coerce callback must be provided");return o(this,M,"f").key[t]=!0,o(this,pt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?Rt(()=>(r=i.getAliases(),e(n[t])),c=>{n[t]=c;let m=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&m!==!0)for(let w of r[t])n[w]=c;return n},c=>{throw new V(c.message)}):n},t),this}conflicts(t,e){return j("<string|object> [string|array]",[t,e],arguments.length),o(this,X,"f").conflicts(t,e),this}config(t="config",e,n){return j("[object|string] [string|function] [function]",[t,e,n],arguments.length),typeof t=="object"&&!Array.isArray(t)?(t=le(t,o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,D,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,M,"f").config[i]=n||!0}),this)}completion(t,e,n){return j("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),typeof e=="function"&&(n=e,e=void 0),A(this,lt,t||o(this,lt,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,lt,"f"),e),n&&o(this,ut,"f").registerFunction(n),this}command(t,e,n,i,r,a){return j("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,i,r,a],arguments.length),o(this,tt,"f").addHandler(t,e,n,i,r,a),this}commands(t,e,n,i,r,a){return this.command(t,e,n,i,r,a)}commandDir(t,e){j("<string> [object]",[t,e],arguments.length);let n=o(this,Ae,"f")||o(this,N,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,N,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[Ft]("count",t),this[Qt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]=n),typeof e=="function"&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]||(o(this,M,"f").defaultDescription[t]=o(this,D,"f").functionDescription(e)),e=e.call()),this[ne](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,i){return j("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,i],arguments.length),typeof e!="number"&&(n=e,e=1/0),this.global("_",!1),o(this,M,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:i},this}demand(t,e,n){return Array.isArray(e)?(e.forEach(i=>{ot(n,!0,o(this,N,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(ot(n,!0,o(this,N,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{ot(n,!0,o(this,N,"f")),this.demandOption(i,n)}):typeof n=="string"?this.demandOption(t,n):(n===!0||typeof n>"u")&&this.demandOption(t),this}demandOption(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return j("<string> [string|boolean]",[t,e],arguments.length),o(this,M,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[sn](t,!0),o(this,D,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,Ut,t,"f"),this}env(t){return j("[string|boolean]",[t],arguments.length),t===!1?delete o(this,M,"f").envPrefix:o(this,M,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,D,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return j("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach(n=>this.example(...n)):o(this,D,"f").example(t,e),this}exit(t,e){A(this,ct,!0,"f"),A(this,$t,e,"f"),o(this,dt,"f")&&o(this,N,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,dt,t,"f"),this}fail(t){if(j("<function|boolean>",[t],arguments.length),typeof t=="boolean"&&t!==!1)throw new V("Invalid first argument. Expected function or boolean 'false'");return o(this,D,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return j("<array> [function]",[t,e],arguments.length),e?o(this,ut,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,ut,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,M,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,M,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,M,"f").deprecatedOptions}getDetectLocale(){return o(this,Ut,"f")}getExitProcess(){return o(this,dt,"f")}getGroups(){return Object.assign({},o(this,_t,"f"),o(this,Yt,"f"))}getHelp(){if(A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(e))return e.then(()=>o(this,D,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(q(t))return t.then(()=>o(this,D,"f").help())}return Promise.resolve(o(this,D,"f").help())}getOptions(){return o(this,M,"f")}getStrict(){return o(this,Bt,"f")}getStrictCommands(){return o(this,Gt,"f")}getStrictOptions(){return o(this,Vt,"f")}global(t,e){return j("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1?o(this,M,"f").local=o(this,M,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,M,"f").local.includes(n)||o(this,M,"f").local.push(n)}),this}group(t,e){j("<string|array> <string>",[t,e],arguments.length);let n=o(this,Yt,"f")[e]||o(this,_t,"f")[e];o(this,Yt,"f")[e]&&delete o(this,Yt,"f")[e];let i={};return o(this,_t,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,M,"f").hiddenOptions.push(t),this}implies(t,e){return j("<string|object> [number|string|array]",[t,e],arguments.length),o(this,X,"f").implies(t,e),this}locale(t){return j("[string]",[t],arguments.length),t===void 0?(this[Xe](),o(this,N,"f").y18n.getLocale()):(A(this,Ut,!1,"f"),o(this,N,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,pt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return j("<string|object|array> [number]",[t,e],arguments.length),this[ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return j("<array|string>",[t],arguments.length),this[Ft]("normalize",t),this}number(t){return j("<array|string>",[t],arguments.length),this[Ft]("number",t),this[Qt](t),this}option(t,e){if(j("<string|object> [object]",[t,e],arguments.length),typeof t=="object")Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof e!="object"&&(e={}),this[Qt](t),o(this,Ct,"f")&&(t==="version"||e?.alias==="version")&&this[kn](['"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(`
63
- `),void 0,"versionWarning"),o(this,M,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);let n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);let i=e.demand||e.required||e.require;i&&this.demand(t,i),e.demandOption&&this.demandOption(t,typeof e.demandOption=="string"?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),e.implies!==void 0&&this.implies(t,e.implies),e.nargs!==void 0&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||e.type==="boolean")&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||e.type==="array")&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||e.type==="number")&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||e.type==="string")&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||e.type==="count")&&this.count(t),typeof e.global=="boolean"&&this.global(t,e.global),e.defaultDescription&&(o(this,M,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);let r=e.describe||e.description||e.desc,a=o(this,D,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,t)||typeof r=="string")&&this.describe(t,r),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){j("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[ti](),typeof t>"u"&&(t=o(this,vt,"f")),typeof e=="object"&&(A(this,Ht,e,"f"),e=n),typeof e=="function"&&(A(this,ft,e,"f"),e=!1),e||A(this,vt,t,"f"),o(this,ft,"f")&&A(this,dt,!1,"f");let i=this[fe](t,!!e),r=this.parsed;return o(this,ut,"f").setParsed(this.parsed),q(i)?i.then(a=>(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),a,o(this,st,"f")),a)).catch(a=>{throw o(this,ft,"f")&&o(this,ft,"f")(a,this.parsed.argv,o(this,st,"f")),a}).finally(()=>{this[rn](),this.parsed=r}):(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),i,o(this,st,"f")),this[rn](),this.parsed=r,i)}parseAsync(t,e,n){let i=this.parse(t,e,n);return q(i)?i:Promise.resolve(i)}parseSync(t,e,n){let i=this.parse(t,e,n);if(q(i))throw new V(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(t){return j("<object>",[t],arguments.length),A(this,Pe,t,"f"),this}pkgConf(t,e){j("<string> [string]",[t,e],arguments.length);let n=null,i=this[ke](e||o(this,Tt,"f"));return i[t]&&typeof i[t]=="object"&&(n=le(i[t],e||o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(n)),this}positional(t,e){j("<string> <object>",[t,e],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=It(e,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!1:n.includes(a));let i=o(this,ce,"f").fullCommands[o(this,ce,"f").fullCommands.length-1],r=i?o(this,tt,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return Xt(r).forEach(a=>{let c=r[a];Array.isArray(c)?c.indexOf(t)!==-1&&(e[a]=!0):c[t]&&!(a in e)&&(e[a]=c[t])}),this.group(t,o(this,D,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return j("[boolean]",[t],arguments.length),A(this,Se,t,"f"),this}required(t,e,n){return this.demand(t,e,n)}require(t,e,n){return this.demand(t,e,n)}requiresArg(t){return j("<array|string|object> [number]",[t],arguments.length),typeof t=="string"&&o(this,M,"f").narg[t]?this:(this[ne](this.requiresArg.bind(this),"narg",t,NaN),this)}showCompletionScript(t,e){return j("[string] [string]",[t,e],arguments.length),t=t||this.$0,o(this,te,"f").log(o(this,ut,"f").generateCompletionScript(t,e||o(this,lt,"f")||"completion")),this}showHelp(t){if(j("[string|function]",[t],arguments.length),A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(n))return n.then(()=>{o(this,D,"f").showHelp(t)}),this}let e=o(this,tt,"f").runDefaultBuilderOn(this);if(q(e))return e.then(()=>{o(this,D,"f").showHelp(t)}),this}return o(this,D,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return j("[boolean|string] [string]",[t,e],arguments.length),o(this,D,"f").showHelpOnFail(t,e),this}showVersion(t){return j("[string|function]",[t],arguments.length),o(this,D,"f").showVersion(t),this}skipValidation(t){return j("<array|string>",[t],arguments.length),this[Ft]("skipValidation",t),this}strict(t){return j("[boolean]",[t],arguments.length),A(this,Bt,t!==!1,"f"),this}strictCommands(t){return j("[boolean]",[t],arguments.length),A(this,Gt,t!==!1,"f"),this}strictOptions(t){return j("[boolean]",[t],arguments.length),A(this,Vt,t!==!1,"f"),this}string(t){return j("<array|string>",[t],arguments.length),this[Ft]("string",t),this[Qt](t),this}terminalWidth(){return j([],0),o(this,N,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return j("<object>",[t],arguments.length),A(this,Ut,!1,"f"),o(this,N,"f").y18n.updateLocale(t),this}usage(t,e,n,i){if(j("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,i],arguments.length),e!==void 0){if(ot(t,null,o(this,N,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,i);throw new V(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,D,"f").usage(t),this}usageConfiguration(t){return j("<object>",[t],arguments.length),A(this,Ie,t,"f"),this}version(t,e,n){let i="version";if(j("[boolean|string] [string] [string]",[t,e,n],arguments.length),o(this,Ct,"f")&&(this[Ze](o(this,Ct,"f")),o(this,D,"f").version(void 0),A(this,Ct,null,"f")),arguments.length===0)n=this[ii](),t=i;else if(arguments.length===1){if(t===!1)return this;n=t,t=i}else arguments.length===2&&(n=e,e=void 0);return A(this,Ct,typeof t=="string"?t:i,"f"),e=e||o(this,D,"f").deferY18nLookup("Show version number"),o(this,D,"f").version(n||void 0),this.boolean(o(this,Ct,"f")),this.describe(o(this,Ct,"f"),e),this}wrap(t){return j("<number|null|undefined>",[t],arguments.length),o(this,D,"f").wrap(t),this}[(tt=new WeakMap,Tt=new WeakMap,ce=new WeakMap,ut=new WeakMap,lt=new WeakMap,Ce=new WeakMap,$t=new WeakMap,Ut=new WeakMap,xe=new WeakMap,dt=new WeakMap,Ee=new WeakMap,pt=new WeakMap,_t=new WeakMap,ct=new WeakMap,mt=new WeakMap,je=new WeakMap,te=new WeakMap,st=new WeakMap,M=new WeakMap,Ae=new WeakMap,Pe=new WeakMap,ft=new WeakMap,Ht=new WeakMap,ee=new WeakMap,Yt=new WeakMap,vt=new WeakMap,Se=new WeakMap,N=new WeakMap,Bt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,D=new WeakMap,Ie=new WeakMap,Ct=new WeakMap,X=new WeakMap,Zn)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch{}return t}[Xn](){return{log:(...t)=>{this[Me]()||console.log(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
63
+ `)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(y).length,Object.keys(y).join(", ")+_))}},r.unknownArguments=function(h,m,y,E,_=!0){var d;let R=s.getInternalMethods().getCommandInstance().getCommands(),L=[],U=s.getInternalMethods().getContext();if(Object.keys(h).forEach(z=>{!Kn.includes(z)&&!Object.prototype.hasOwnProperty.call(y,z)&&!Object.prototype.hasOwnProperty.call(s.getInternalMethods().getParseContext(),z)&&!r.isValidAndSomeAliasIsNotNew(z,m)&&L.push(z)}),_&&(U.commands.length>0||R.length>0||E)&&h._.slice(U.commands.length).forEach(z=>{R.includes(""+z)||L.push(""+z)}),_){let Y=((d=s.getDemandedCommands()._)===null||d===void 0?void 0:d.max)||0,Pt=U.commands.length+Y;Pt<h._.length&&h._.slice(Pt).forEach(gt=>{gt=String(gt),!U.commands.includes(gt)&&!L.includes(gt)&&L.push(gt)})}L.length&&t.fail(i("Unknown argument: %s","Unknown arguments: %s",L.length,L.map(z=>z.trim()?z:`"${z}"`).join(", ")))},r.unknownCommands=function(h){let m=s.getInternalMethods().getCommandInstance().getCommands(),y=[],E=s.getInternalMethods().getContext();return(E.commands.length>0||m.length>0)&&h._.slice(E.commands.length).forEach(_=>{m.includes(""+_)||y.push(""+_)}),y.length>0?(t.fail(i("Unknown command: %s","Unknown commands: %s",y.length,y.join(", "))),!0):!1},r.isValidAndSomeAliasIsNotNew=function(h,m){if(!Object.prototype.hasOwnProperty.call(m,h))return!1;let y=s.parsed.newAliases;return[h,...m[h]].some(E=>!Object.prototype.hasOwnProperty.call(y,E)||!y[h])},r.limitedChoices=function(h){let m=s.getOptions(),y={};if(!Object.keys(m.choices).length)return;Object.keys(h).forEach(d=>{Kn.indexOf(d)===-1&&Object.prototype.hasOwnProperty.call(m.choices,d)&&[].concat(h[d]).forEach(R=>{m.choices[d].indexOf(R)===-1&&R!==void 0&&(y[d]=(y[d]||[]).concat(R))})});let E=Object.keys(y);if(!E.length)return;let _=n("Invalid values:");E.forEach(d=>{_+=`
64
+ ${n("Argument: %s, Given: %s, Choices: %s",d,t.stringifiedValues(y[d]),t.stringifiedValues(m.choices[d]))}`}),t.fail(_)};let a={};r.implies=function(h,m){j("<string|object> [array|number|string]",[h,m],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.implies(y,h[y])}):(s.global(h),a[h]||(a[h]=[]),Array.isArray(m)?m.forEach(y=>r.implies(h,y)):(ot(m,void 0,e),a[h].push(m)))},r.getImplied=function(){return a};function c(p,h){let m=Number(h);return h=isNaN(m)?h:m,typeof h=="number"?h=p._.length>=h:h.match(/^--no-.+/)?(h=h.match(/^--no-(.+)/)[1],h=!Object.prototype.hasOwnProperty.call(p,h)):h=Object.prototype.hasOwnProperty.call(p,h),h}r.implications=function(h){let m=[];if(Object.keys(a).forEach(y=>{let E=y;(a[y]||[]).forEach(_=>{let d=E,R=_;d=c(h,d),_=c(h,_),d&&!_&&m.push(` ${E} -> ${R}`)})}),m.length){let y=`${n("Implications failed:")}
65
+ `;m.forEach(E=>{y+=E}),t.fail(y)}};let g={};r.conflicts=function(h,m){j("<string|object> [array|string]",[h,m],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.conflicts(y,h[y])}):(s.global(h),g[h]||(g[h]=[]),Array.isArray(m)?m.forEach(y=>r.conflicts(h,y)):g[h].push(m))},r.getConflicting=()=>g,r.conflicting=function(h){Object.keys(h).forEach(m=>{g[m]&&g[m].forEach(y=>{y&&h[m]!==void 0&&h[y]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",m,y))})}),s.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(g).forEach(m=>{g[m].forEach(y=>{y&&h[e.Parser.camelCase(m)]!==void 0&&h[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",m,y))})})},r.recommendCommands=function(h,m){m=m.sort((d,R)=>R.length-d.length);let E=null,_=1/0;for(let d=0,R;(R=m[d])!==void 0;d++){let L=qn(h,R);L<=3&&L<_&&(_=L,E=R)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(h){return a=It(a,m=>!h[m]),g=It(g,m=>!h[m]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:g})},r.unfreeze=function(){let h=w.pop();ot(h,void 0,e),{implied:a,conflicting:g}=h},r}var Je=[],ae;function le(s,t,e,n){ae=n;let i={};if(Object.prototype.hasOwnProperty.call(s,"extends")){if(typeof s.extends!="string")return i;let r=/\.json|\..*rc$/.test(s.extends),a=null;if(r)a=Ps(t,s.extends);else try{a=Ot.resolve(s.extends)}catch{return s}As(a),Je.push(a),i=r?JSON.parse(ae.readFileSync(a,"utf8")):Ot(s.extends),delete s.extends,i=le(i,ae.path.dirname(a),e,ae)}return Je=[],e?Jn(i,s):Object.assign({},i,s)}function As(s){if(Je.indexOf(s)>-1)throw new V(`Circular extended configurations: '${s}'.`)}function Ps(s,t){return ae.path.resolve(s,t)}function Jn(s,t){let e={};function n(i){return i&&typeof i=="object"&&!Array.isArray(i)}Object.assign(e,s);for(let i of Object.keys(t))n(t[i])&&n(e[i])?e[i]=Jn(s[i],t[i]):e[i]=t[i];return e}var A=function(s,t,e,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?s!==t||!i:!t.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(s,e):i?i.value=e:t.set(s,e),e},o=function(s,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?s!==t||!n:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(s):n?n.value:t.get(s)},tt,Tt,ce,ht,lt,Ce,$t,Ut,xe,dt,Ee,pt,_t,ct,mt,je,te,st,M,Ae,Pe,ft,Ht,ee,Bt,vt,Se,N,Yt,Gt,Vt,D,Ie,Ct,X;function gi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new ln(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Zn=Symbol("copyDoubleDash"),Xn=Symbol("copyDoubleDash"),Ze=Symbol("deleteFromParserHintObject"),kn=Symbol("emitWarning"),ti=Symbol("freeze"),ei=Symbol("getDollarZero"),qt=Symbol("getParserConfiguration"),ni=Symbol("getUsageConfiguration"),Xe=Symbol("guessLocale"),ii=Symbol("guessVersion"),si=Symbol("parsePositionalNumbers"),ke=Symbol("pkgUp"),Ft=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),tn=Symbol("populateParserHintArrayDictionary"),en=Symbol("populateParserHintDictionary"),nn=Symbol("sanitizeKey"),sn=Symbol("setKey"),rn=Symbol("unfreeze"),ri=Symbol("validateAsync"),oi=Symbol("getCommandInstance"),ai=Symbol("getContext"),li=Symbol("getHasOutput"),ci=Symbol("getLoggerInstance"),fi=Symbol("getParseContext"),ui=Symbol("getUsageInstance"),hi=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),di=Symbol("isGlobalContext"),Kt=Symbol("postProcess"),pi=Symbol("rebase"),on=Symbol("reset"),fe=Symbol("runYargsParserAndExecuteCommands"),an=Symbol("runValidation"),mi=Symbol("setHasOutput"),Qt=Symbol("kTrackManuallySetKeys"),ln=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Tt.set(this,void 0),ce.set(this,{commands:[],fullCommands:[]}),ht.set(this,null),lt.set(this,null),Ce.set(this,"show-hidden"),$t.set(this,null),Ut.set(this,!0),xe.set(this,{}),dt.set(this,!0),Ee.set(this,[]),pt.set(this,void 0),_t.set(this,{}),ct.set(this,!1),mt.set(this,null),je.set(this,!0),te.set(this,void 0),st.set(this,""),M.set(this,void 0),Ae.set(this,void 0),Pe.set(this,{}),ft.set(this,null),Ht.set(this,null),ee.set(this,{}),Bt.set(this,{}),vt.set(this,void 0),Se.set(this,!1),N.set(this,void 0),Yt.set(this,!1),Gt.set(this,!1),Vt.set(this,!1),D.set(this,void 0),Ie.set(this,{}),Ct.set(this,null),X.set(this,void 0),A(this,N,i,"f"),A(this,vt,t,"f"),A(this,Tt,e,"f"),A(this,Ae,n,"f"),A(this,pt,new ye(this),"f"),this.$0=this[ei](),this[on](),A(this,tt,o(this,tt,"f"),"f"),A(this,D,o(this,D,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,M,o(this,M,"f"),"f"),o(this,M,"f").showHiddenOpt=o(this,Ce,"f"),A(this,te,this[Xn](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,mt,"f")&&(this[Ze](o(this,mt,"f")),A(this,mt,null,"f")),t===!1&&e===void 0?this:(A(this,mt,typeof t=="string"?t:n,"f"),this.boolean(o(this,mt,"f")),this.describe(o(this,mt,"f"),e||o(this,D,"f").deferY18nLookup("Show help")),this)}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(j("[string|boolean] [string]",[t,e],arguments.length),t===!1&&e===void 0)return this;let n=typeof t=="string"?t:o(this,Ce,"f");return this.boolean(n),this.describe(n,e||o(this,D,"f").deferY18nLookup("Show hidden options")),o(this,M,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[tn](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[Ft]("array",t),this[Qt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[Ft]("boolean",t),this[Qt](t),this}check(t,e){return j("<function> [boolean]",[t,e],arguments.length),this.middleware((n,i)=>zt(()=>t(n,i.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,D,"f").fail(r.toString(),r):o(this,D,"f").fail(o(this,N,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,D,"f").fail(r.message?r.message:r.toString(),r),n)),!1,e),this}choices(t,e){return j("<object|string|array> [string|array]",[t,e],arguments.length),this[tn](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(j("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new V("coerce callback must be provided");for(let n of t)this.coerce(n,e);return this}else if(typeof t=="object"){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!e)throw new V("coerce callback must be provided");return o(this,M,"f").key[t]=!0,o(this,pt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?zt(()=>(r=i.getAliases(),e(n[t])),c=>{n[t]=c;let g=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&g!==!0)for(let w of r[t])n[w]=c;return n},c=>{throw new V(c.message)}):n},t),this}conflicts(t,e){return j("<string|object> [string|array]",[t,e],arguments.length),o(this,X,"f").conflicts(t,e),this}config(t="config",e,n){return j("[object|string] [string|function] [function]",[t,e,n],arguments.length),typeof t=="object"&&!Array.isArray(t)?(t=le(t,o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,D,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,M,"f").config[i]=n||!0}),this)}completion(t,e,n){return j("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),typeof e=="function"&&(n=e,e=void 0),A(this,lt,t||o(this,lt,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,lt,"f"),e),n&&o(this,ht,"f").registerFunction(n),this}command(t,e,n,i,r,a){return j("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,i,r,a],arguments.length),o(this,tt,"f").addHandler(t,e,n,i,r,a),this}commands(t,e,n,i,r,a){return this.command(t,e,n,i,r,a)}commandDir(t,e){j("<string> [object]",[t,e],arguments.length);let n=o(this,Ae,"f")||o(this,N,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,N,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[Ft]("count",t),this[Qt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]=n),typeof e=="function"&&(Ge(t,o(this,N,"f")),o(this,M,"f").defaultDescription[t]||(o(this,M,"f").defaultDescription[t]=o(this,D,"f").functionDescription(e)),e=e.call()),this[ne](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,i){return j("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,i],arguments.length),typeof e!="number"&&(n=e,e=1/0),this.global("_",!1),o(this,M,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:i},this}demand(t,e,n){return Array.isArray(e)?(e.forEach(i=>{ot(n,!0,o(this,N,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(ot(n,!0,o(this,N,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{ot(n,!0,o(this,N,"f")),this.demandOption(i,n)}):typeof n=="string"?this.demandOption(t,n):(n===!0||typeof n>"u")&&this.demandOption(t),this}demandOption(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[ne](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return j("<string> [string|boolean]",[t,e],arguments.length),o(this,M,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[sn](t,!0),o(this,D,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,Ut,t,"f"),this}env(t){return j("[string|boolean]",[t],arguments.length),t===!1?delete o(this,M,"f").envPrefix:o(this,M,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,D,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return j("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach(n=>this.example(...n)):o(this,D,"f").example(t,e),this}exit(t,e){A(this,ct,!0,"f"),A(this,$t,e,"f"),o(this,dt,"f")&&o(this,N,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,dt,t,"f"),this}fail(t){if(j("<function|boolean>",[t],arguments.length),typeof t=="boolean"&&t!==!1)throw new V("Invalid first argument. Expected function or boolean 'false'");return o(this,D,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return j("<array> [function]",[t,e],arguments.length),e?o(this,ht,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,ht,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,M,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,M,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,M,"f").deprecatedOptions}getDetectLocale(){return o(this,Ut,"f")}getExitProcess(){return o(this,dt,"f")}getGroups(){return Object.assign({},o(this,_t,"f"),o(this,Bt,"f"))}getHelp(){if(A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(e))return e.then(()=>o(this,D,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(q(t))return t.then(()=>o(this,D,"f").help())}return Promise.resolve(o(this,D,"f").help())}getOptions(){return o(this,M,"f")}getStrict(){return o(this,Yt,"f")}getStrictCommands(){return o(this,Gt,"f")}getStrictOptions(){return o(this,Vt,"f")}global(t,e){return j("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1?o(this,M,"f").local=o(this,M,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,M,"f").local.includes(n)||o(this,M,"f").local.push(n)}),this}group(t,e){j("<string|array> <string>",[t,e],arguments.length);let n=o(this,Bt,"f")[e]||o(this,_t,"f")[e];o(this,Bt,"f")[e]&&delete o(this,Bt,"f")[e];let i={};return o(this,_t,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,M,"f").hiddenOptions.push(t),this}implies(t,e){return j("<string|object> [number|string|array]",[t,e],arguments.length),o(this,X,"f").implies(t,e),this}locale(t){return j("[string]",[t],arguments.length),t===void 0?(this[Xe](),o(this,N,"f").y18n.getLocale()):(A(this,Ut,!1,"f"),o(this,N,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,pt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return j("<string|object|array> [number]",[t,e],arguments.length),this[ne](this.nargs.bind(this),"narg",t,e),this}normalize(t){return j("<array|string>",[t],arguments.length),this[Ft]("normalize",t),this}number(t){return j("<array|string>",[t],arguments.length),this[Ft]("number",t),this[Qt](t),this}option(t,e){if(j("<string|object> [object]",[t,e],arguments.length),typeof t=="object")Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof e!="object"&&(e={}),this[Qt](t),o(this,Ct,"f")&&(t==="version"||e?.alias==="version")&&this[kn](['"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(`
66
+ `),void 0,"versionWarning"),o(this,M,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);let n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);let i=e.demand||e.required||e.require;i&&this.demand(t,i),e.demandOption&&this.demandOption(t,typeof e.demandOption=="string"?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),e.implies!==void 0&&this.implies(t,e.implies),e.nargs!==void 0&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||e.type==="boolean")&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||e.type==="array")&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||e.type==="number")&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||e.type==="string")&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||e.type==="count")&&this.count(t),typeof e.global=="boolean"&&this.global(t,e.global),e.defaultDescription&&(o(this,M,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);let r=e.describe||e.description||e.desc,a=o(this,D,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(a,t)||typeof r=="string")&&this.describe(t,r),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){j("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[ti](),typeof t>"u"&&(t=o(this,vt,"f")),typeof e=="object"&&(A(this,Ht,e,"f"),e=n),typeof e=="function"&&(A(this,ft,e,"f"),e=!1),e||A(this,vt,t,"f"),o(this,ft,"f")&&A(this,dt,!1,"f");let i=this[fe](t,!!e),r=this.parsed;return o(this,ht,"f").setParsed(this.parsed),q(i)?i.then(a=>(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),a,o(this,st,"f")),a)).catch(a=>{throw o(this,ft,"f")&&o(this,ft,"f")(a,this.parsed.argv,o(this,st,"f")),a}).finally(()=>{this[rn](),this.parsed=r}):(o(this,ft,"f")&&o(this,ft,"f").call(this,o(this,$t,"f"),i,o(this,st,"f")),this[rn](),this.parsed=r,i)}parseAsync(t,e,n){let i=this.parse(t,e,n);return q(i)?i:Promise.resolve(i)}parseSync(t,e,n){let i=this.parse(t,e,n);if(q(i))throw new V(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return i}parserConfiguration(t){return j("<object>",[t],arguments.length),A(this,Pe,t,"f"),this}pkgConf(t,e){j("<string> [string]",[t,e],arguments.length);let n=null,i=this[ke](e||o(this,Tt,"f"));return i[t]&&typeof i[t]=="object"&&(n=le(i[t],e||o(this,Tt,"f"),this[qt]()["deep-merge-config"]||!1,o(this,N,"f")),o(this,M,"f").configObjects=(o(this,M,"f").configObjects||[]).concat(n)),this}positional(t,e){j("<string> <object>",[t,e],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=It(e,(a,c)=>a==="type"&&!["string","number","boolean"].includes(c)?!1:n.includes(a));let i=o(this,ce,"f").fullCommands[o(this,ce,"f").fullCommands.length-1],r=i?o(this,tt,"f").cmdToParseOptions(i):{array:[],alias:{},default:{},demand:{}};return Xt(r).forEach(a=>{let c=r[a];Array.isArray(c)?c.indexOf(t)!==-1&&(e[a]=!0):c[t]&&!(a in e)&&(e[a]=c[t])}),this.group(t,o(this,D,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return j("[boolean]",[t],arguments.length),A(this,Se,t,"f"),this}required(t,e,n){return this.demand(t,e,n)}require(t,e,n){return this.demand(t,e,n)}requiresArg(t){return j("<array|string|object> [number]",[t],arguments.length),typeof t=="string"&&o(this,M,"f").narg[t]?this:(this[ne](this.requiresArg.bind(this),"narg",t,NaN),this)}showCompletionScript(t,e){return j("[string] [string]",[t,e],arguments.length),t=t||this.$0,o(this,te,"f").log(o(this,ht,"f").generateCompletionScript(t,e||o(this,lt,"f")||"completion")),this}showHelp(t){if(j("[string|function]",[t],arguments.length),A(this,ct,!0,"f"),!o(this,D,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[fe](o(this,vt,"f"),void 0,void 0,0,!0);if(q(n))return n.then(()=>{o(this,D,"f").showHelp(t)}),this}let e=o(this,tt,"f").runDefaultBuilderOn(this);if(q(e))return e.then(()=>{o(this,D,"f").showHelp(t)}),this}return o(this,D,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return j("[boolean|string] [string]",[t,e],arguments.length),o(this,D,"f").showHelpOnFail(t,e),this}showVersion(t){return j("[string|function]",[t],arguments.length),o(this,D,"f").showVersion(t),this}skipValidation(t){return j("<array|string>",[t],arguments.length),this[Ft]("skipValidation",t),this}strict(t){return j("[boolean]",[t],arguments.length),A(this,Yt,t!==!1,"f"),this}strictCommands(t){return j("[boolean]",[t],arguments.length),A(this,Gt,t!==!1,"f"),this}strictOptions(t){return j("[boolean]",[t],arguments.length),A(this,Vt,t!==!1,"f"),this}string(t){return j("<array|string>",[t],arguments.length),this[Ft]("string",t),this[Qt](t),this}terminalWidth(){return j([],0),o(this,N,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return j("<object>",[t],arguments.length),A(this,Ut,!1,"f"),o(this,N,"f").y18n.updateLocale(t),this}usage(t,e,n,i){if(j("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,i],arguments.length),e!==void 0){if(ot(t,null,o(this,N,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,i);throw new V(".usage() description must start with $0 if being used as alias for .command()")}else return o(this,D,"f").usage(t),this}usageConfiguration(t){return j("<object>",[t],arguments.length),A(this,Ie,t,"f"),this}version(t,e,n){let i="version";if(j("[boolean|string] [string] [string]",[t,e,n],arguments.length),o(this,Ct,"f")&&(this[Ze](o(this,Ct,"f")),o(this,D,"f").version(void 0),A(this,Ct,null,"f")),arguments.length===0)n=this[ii](),t=i;else if(arguments.length===1){if(t===!1)return this;n=t,t=i}else arguments.length===2&&(n=e,e=void 0);return A(this,Ct,typeof t=="string"?t:i,"f"),e=e||o(this,D,"f").deferY18nLookup("Show version number"),o(this,D,"f").version(n||void 0),this.boolean(o(this,Ct,"f")),this.describe(o(this,Ct,"f"),e),this}wrap(t){return j("<number|null|undefined>",[t],arguments.length),o(this,D,"f").wrap(t),this}[(tt=new WeakMap,Tt=new WeakMap,ce=new WeakMap,ht=new WeakMap,lt=new WeakMap,Ce=new WeakMap,$t=new WeakMap,Ut=new WeakMap,xe=new WeakMap,dt=new WeakMap,Ee=new WeakMap,pt=new WeakMap,_t=new WeakMap,ct=new WeakMap,mt=new WeakMap,je=new WeakMap,te=new WeakMap,st=new WeakMap,M=new WeakMap,Ae=new WeakMap,Pe=new WeakMap,ft=new WeakMap,Ht=new WeakMap,ee=new WeakMap,Bt=new WeakMap,vt=new WeakMap,Se=new WeakMap,N=new WeakMap,Yt=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,D=new WeakMap,Ie=new WeakMap,Ct=new WeakMap,X=new WeakMap,Zn)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch{}return t}[Xn](){return{log:(...t)=>{this[Me]()||console.log(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
64
67
  `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")},error:(...t)=>{this[Me]()||console.error(...t),A(this,ct,!0,"f"),o(this,st,"f").length&&A(this,st,o(this,st,"f")+`
65
- `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Ze](t){Xt(o(this,M,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,M,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,D,"f").getDescriptions()[t]}[kn](t,e,n){o(this,xe,"f")[n]||(o(this,N,"f").process.emitWarning(t,e),o(this,xe,"f")[n]=!0)}[ti](){o(this,Ee,"f").push({options:o(this,M,"f"),configObjects:o(this,M,"f").configObjects.slice(0),exitProcess:o(this,dt,"f"),groups:o(this,_t,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Gt,"f"),strictOptions:o(this,Vt,"f"),completionCommand:o(this,lt,"f"),output:o(this,st,"f"),exitError:o(this,$t,"f"),hasOutput:o(this,ct,"f"),parsed:this.parsed,parseFn:o(this,ft,"f"),parseContext:o(this,Ht,"f")}),o(this,D,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,pt,"f").freeze()}[ei](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,N,"f").process.argv()[0])?e=o(this,N,"f").process.argv().slice(1,2):e=o(this,N,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[pi](o(this,Tt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,N,"f").getEnv("_")&&o(this,N,"f").getProcessArgvBin()===o(this,N,"f").getEnv("_")&&(t=o(this,N,"f").getEnv("_").replace(`${o(this,N,"f").path.dirname(o(this,N,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Pe,"f")}[ni](){return o(this,Ie,"f")}[Xe](){if(!o(this,Ut,"f"))return;let t=o(this,N,"f").getEnv("LC_ALL")||o(this,N,"f").getEnv("LC_MESSAGES")||o(this,N,"f").getEnv("LANG")||o(this,N,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ii](){return this[ke]().version||"unknown"}[si](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,N,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[ke](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,N,"f").mainFilename;!t&&o(this,N,"f").path.extname(i)&&(i=o(this,N,"f").path.dirname(i));let r=o(this,N,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,N,"f")),n=JSON.parse(o(this,N,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[Ft](t,e){e=[].concat(e),e.forEach(n=>{n=this[nn](n),o(this,M,"f")[t].push(n)})}[ne](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=c})}[tn](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=(o(this,M,"f")[r][a]||[]).concat(c)})}[en](t,e,n,i,r){if(Array.isArray(n))n.forEach(a=>{t(a,i)});else if((a=>typeof a=="object")(n))for(let a of Xt(n))t(a,n[a]);else r(e,this[nn](n),i)}[nn](t){return t==="__proto__"?"___proto___":t}[sn](t,e){return this[ne](this[sn].bind(this),"key",t,e),this}[rn](){var t,e,n,i,r,a,c,m,w,p,u,g;let y=o(this,Ee,"f").pop();ot(y,void 0,o(this,N,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,m=this,w=this,p=this,u=this,g=this,{options:{set value(_){A(t,M,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,dt,_,"f")}}.value,groups:{set value(_){A(n,_t,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,$t,_,"f")}}.value,hasOutput:{set value(_){A(a,ct,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(c,Bt,_,"f")}}.value,strictCommands:{set value(_){A(m,Gt,_,"f")}}.value,strictOptions:{set value(_){A(w,Vt,_,"f")}}.value,completionCommand:{set value(_){A(p,lt,_,"f")}}.value,parseFn:{set value(_){A(u,ft,_,"f")}}.value,parseContext:{set value(_){A(g,Ht,_,"f")}}.value}=y,o(this,M,"f").configObjects=E,o(this,D,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,pt,"f").unfreeze()}[ri](t,e){return Rt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[oi].bind(this),getContext:this[ai].bind(this),getHasOutput:this[li].bind(this),getLoggerInstance:this[ci].bind(this),getParseContext:this[fi].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ni].bind(this),getUsageInstance:this[hi].bind(this),getValidationInstance:this[ui].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[di].bind(this),postProcess:this[Kt].bind(this),reset:this[on].bind(this),runValidation:this[an].bind(this),runYargsParserAndExecuteCommands:this[fe].bind(this),setHasOutput:this[mi].bind(this)}}[oi](){return o(this,tt,"f")}[ai](){return o(this,ce,"f")}[li](){return o(this,ct,"f")}[ci](){return o(this,te,"f")}[fi](){return o(this,Ht,"f")||{}}[hi](){return o(this,D,"f")}[ui](){return o(this,X,"f")}[Me](){return!!o(this,ft,"f")}[di](){return o(this,je,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Zn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[si](t)),i&&(t=zt(t,this,o(this,pt,"f").getMiddleware(),!1))),t}[on](t={}){A(this,M,o(this,M,"f")||{},"f");let e={};e.local=o(this,M,"f").local||[],e.configObjects=o(this,M,"f").configObjects||[];let n={};e.local.forEach(a=>{n[a]=!0,(t[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Yt,"f"),Object.keys(o(this,_t,"f")).reduce((a,c)=>{let m=o(this,_t,"f")[c].filter(w=>!(w in n));return m.length>0&&(a[c]=m),a},{})),A(this,_t,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return i.forEach(a=>{e[a]=(o(this,M,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{e[a]=It(o(this,M,"f")[a],c=>!n[c])}),e.envPrefix=o(this,M,"f").envPrefix,A(this,M,e,"f"),A(this,D,o(this,D,"f")?o(this,D,"f").reset(n):Yn(this,o(this,N,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):Qn(this,o(this,D,"f"),o(this,N,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():Tn(o(this,D,"f"),o(this,X,"f"),o(this,pt,"f"),o(this,N,"f")),"f"),o(this,ut,"f")||A(this,ut,Vn(this,o(this,D,"f"),o(this,tt,"f"),o(this,N,"f")),"f"),o(this,pt,"f").reset(),A(this,lt,null,"f"),A(this,st,"","f"),A(this,$t,null,"f"),A(this,ct,!1,"f"),this.parsed=!1,this}[pi](t,e){return o(this,N,"f").path.relative(t,e)}[fe](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,vt,"f"),o(this,M,"f").__=o(this,N,"f").y18n.__,o(this,M,"f").configuration=this[qt]();let c=!!o(this,M,"f").configuration["populate--"],m=Object.assign({},o(this,M,"f").configuration,{"populate--":!0}),w=o(this,N,"f").Parser.detailed(t,Object.assign({},o(this,M,"f"),{configuration:{"parse-positional-numbers":!1,...m}})),p=Object.assign(w.argv,o(this,Ht,"f")),u,g=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,mt,"f")&&p[_]?y=!0:_===o(this,Ct,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,D,"f").clearCachedHelpMessage();try{if(this[Xe](),e)return this[Kt](p,c,!!n,!1);o(this,mt,"f")&&[o(this,mt,"f")].concat(g[o(this,mt,"f")]||[]).filter(Y=>Y.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,je,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,ut,"f").completionKey in p,W=y||d||r;if(p._.length){if(_.length){let z;for(let Y=i||0,T;p._[Y]!==void 0;Y++)if(T=String(p._[Y]),_.includes(T)&&T!==o(this,lt,"f")){let B=o(this,tt,"f").runCommand(T,this,w,Y+1,r,y||E||r);return this[Kt](B,c,!!n,!1)}else if(!z&&T!==o(this,lt,"f")){z=T;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Se,"f")&&z&&!W&&o(this,X,"f").recommendCommands(z,_)}o(this,lt,"f")&&p._.includes(o(this,lt,"f"))&&!d&&(o(this,dt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!W){let z=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Kt](z,c,!!n,!1)}if(d){o(this,dt,"f")&&Mt(!0),t=[].concat(t);let z=t.slice(t.indexOf(`--${o(this,ut,"f").completionKey}`)+1);return o(this,ut,"f").getCompletion(z,(Y,T)=>{if(Y)throw new V(Y.message);(T||[]).forEach(B=>{o(this,te,"f").log(B)}),this.exit(0)}),this[Kt](p,!c,!!n,!1)}if(o(this,ct,"f")||(y?(o(this,dt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,dt,"f")&&Mt(!0),a=!0,o(this,D,"f").showVersion("log"),this.exit(0))),!a&&o(this,M,"f").skipValidation.length>0&&(a=Object.keys(p).some(z=>o(this,M,"f").skipValidation.indexOf(z)>=0&&p[z]===!0)),!a){if(w.error)throw new V(w.error.message);if(!d){let z=this[an](g,{},w.error);n||(u=zt(p,this,o(this,pt,"f").getMiddleware(),!0)),u=this[ri](z,u??p),q(u)&&!n&&(u=u.then(()=>zt(p,this,o(this,pt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,D,"f").fail(_.message,_);else throw _}return this[Kt](u??p,c,!!n,!0)}[an](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new V(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let c=!1;o(this,Gt,"f")&&(c=o(this,X,"f").unknownCommands(a)),o(this,Bt,"f")&&!c?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,Vt,"f")&&o(this,X,"f").unknownArguments(a,t,{},!1,!1),o(this,X,"f").limitedChoices(a),o(this,X,"f").implications(a),o(this,X,"f").conflicting(a)}}[mi](){A(this,ct,!0,"f")}[Qt](t){if(typeof t=="string")o(this,M,"f").key[t]=!0;else for(let e of t)o(this,M,"f").key[e]=!0}};function Un(s){return!!s&&typeof s.getInternalMethods=="function"}var js=gi(Be),bi=js;await bi(He(process.argv)).command("$0 <file-or-url>",'Convert a tldraw ".tldr" file or tldraw.com URL to an svg or png image',s=>s.positional("file-or-url",{demandOption:!0,describe:'The sketch to convert to an image \u2014 either a path to a local ".tldr" file, or a tldraw.com sketch URL',type:"string"}).option("format",{alias:"f",choices:["png","svg"],default:"svg",describe:"Output image format",type:"string"}).option("output",{alias:"o",default:"./",describe:"Output image directory",type:"string"}).option("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async s=>{let{fileOrUrl:t,format:e,output:n,verbose:i}=s;try{await mn(t,e,n,i),process.exit(0)}catch(r){console.error("Error during conversion:",r),process.exit(1)}}).alias("h","help").version("version",cn).alias("v","version").help().parse();
68
+ `,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Ze](t){Xt(o(this,M,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,M,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,D,"f").getDescriptions()[t]}[kn](t,e,n){o(this,xe,"f")[n]||(o(this,N,"f").process.emitWarning(t,e),o(this,xe,"f")[n]=!0)}[ti](){o(this,Ee,"f").push({options:o(this,M,"f"),configObjects:o(this,M,"f").configObjects.slice(0),exitProcess:o(this,dt,"f"),groups:o(this,_t,"f"),strict:o(this,Yt,"f"),strictCommands:o(this,Gt,"f"),strictOptions:o(this,Vt,"f"),completionCommand:o(this,lt,"f"),output:o(this,st,"f"),exitError:o(this,$t,"f"),hasOutput:o(this,ct,"f"),parsed:this.parsed,parseFn:o(this,ft,"f"),parseContext:o(this,Ht,"f")}),o(this,D,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,pt,"f").freeze()}[ei](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,N,"f").process.argv()[0])?e=o(this,N,"f").process.argv().slice(1,2):e=o(this,N,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[pi](o(this,Tt,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,N,"f").getEnv("_")&&o(this,N,"f").getProcessArgvBin()===o(this,N,"f").getEnv("_")&&(t=o(this,N,"f").getEnv("_").replace(`${o(this,N,"f").path.dirname(o(this,N,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Pe,"f")}[ni](){return o(this,Ie,"f")}[Xe](){if(!o(this,Ut,"f"))return;let t=o(this,N,"f").getEnv("LC_ALL")||o(this,N,"f").getEnv("LC_MESSAGES")||o(this,N,"f").getEnv("LANG")||o(this,N,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ii](){return this[ke]().version||"unknown"}[si](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,N,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[ke](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,N,"f").mainFilename;!t&&o(this,N,"f").path.extname(i)&&(i=o(this,N,"f").path.dirname(i));let r=o(this,N,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,N,"f")),n=JSON.parse(o(this,N,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[Ft](t,e){e=[].concat(e),e.forEach(n=>{n=this[nn](n),o(this,M,"f")[t].push(n)})}[ne](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=c})}[tn](t,e,n,i){this[en](t,e,n,i,(r,a,c)=>{o(this,M,"f")[r][a]=(o(this,M,"f")[r][a]||[]).concat(c)})}[en](t,e,n,i,r){if(Array.isArray(n))n.forEach(a=>{t(a,i)});else if((a=>typeof a=="object")(n))for(let a of Xt(n))t(a,n[a]);else r(e,this[nn](n),i)}[nn](t){return t==="__proto__"?"___proto___":t}[sn](t,e){return this[ne](this[sn].bind(this),"key",t,e),this}[rn](){var t,e,n,i,r,a,c,g,w,p,h,m;let y=o(this,Ee,"f").pop();ot(y,void 0,o(this,N,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,g=this,w=this,p=this,h=this,m=this,{options:{set value(_){A(t,M,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,dt,_,"f")}}.value,groups:{set value(_){A(n,_t,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,$t,_,"f")}}.value,hasOutput:{set value(_){A(a,ct,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(c,Yt,_,"f")}}.value,strictCommands:{set value(_){A(g,Gt,_,"f")}}.value,strictOptions:{set value(_){A(w,Vt,_,"f")}}.value,completionCommand:{set value(_){A(p,lt,_,"f")}}.value,parseFn:{set value(_){A(h,ft,_,"f")}}.value,parseContext:{set value(_){A(m,Ht,_,"f")}}.value}=y,o(this,M,"f").configObjects=E,o(this,D,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,pt,"f").unfreeze()}[ri](t,e){return zt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[oi].bind(this),getContext:this[ai].bind(this),getHasOutput:this[li].bind(this),getLoggerInstance:this[ci].bind(this),getParseContext:this[fi].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ni].bind(this),getUsageInstance:this[ui].bind(this),getValidationInstance:this[hi].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[di].bind(this),postProcess:this[Kt].bind(this),reset:this[on].bind(this),runValidation:this[an].bind(this),runYargsParserAndExecuteCommands:this[fe].bind(this),setHasOutput:this[mi].bind(this)}}[oi](){return o(this,tt,"f")}[ai](){return o(this,ce,"f")}[li](){return o(this,ct,"f")}[ci](){return o(this,te,"f")}[fi](){return o(this,Ht,"f")||{}}[ui](){return o(this,D,"f")}[hi](){return o(this,X,"f")}[Me](){return!!o(this,ft,"f")}[di](){return o(this,je,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Zn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[si](t)),i&&(t=Rt(t,this,o(this,pt,"f").getMiddleware(),!1))),t}[on](t={}){A(this,M,o(this,M,"f")||{},"f");let e={};e.local=o(this,M,"f").local||[],e.configObjects=o(this,M,"f").configObjects||[];let n={};e.local.forEach(a=>{n[a]=!0,(t[a]||[]).forEach(c=>{n[c]=!0})}),Object.assign(o(this,Bt,"f"),Object.keys(o(this,_t,"f")).reduce((a,c)=>{let g=o(this,_t,"f")[c].filter(w=>!(w in n));return g.length>0&&(a[c]=g),a},{})),A(this,_t,{},"f");let i=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],r=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return i.forEach(a=>{e[a]=(o(this,M,"f")[a]||[]).filter(c=>!n[c])}),r.forEach(a=>{e[a]=It(o(this,M,"f")[a],c=>!n[c])}),e.envPrefix=o(this,M,"f").envPrefix,A(this,M,e,"f"),A(this,D,o(this,D,"f")?o(this,D,"f").reset(n):Bn(this,o(this,N,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):Qn(this,o(this,D,"f"),o(this,N,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():Tn(o(this,D,"f"),o(this,X,"f"),o(this,pt,"f"),o(this,N,"f")),"f"),o(this,ht,"f")||A(this,ht,Vn(this,o(this,D,"f"),o(this,tt,"f"),o(this,N,"f")),"f"),o(this,pt,"f").reset(),A(this,lt,null,"f"),A(this,st,"","f"),A(this,$t,null,"f"),A(this,ct,!1,"f"),this.parsed=!1,this}[pi](t,e){return o(this,N,"f").path.relative(t,e)}[fe](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,vt,"f"),o(this,M,"f").__=o(this,N,"f").y18n.__,o(this,M,"f").configuration=this[qt]();let c=!!o(this,M,"f").configuration["populate--"],g=Object.assign({},o(this,M,"f").configuration,{"populate--":!0}),w=o(this,N,"f").Parser.detailed(t,Object.assign({},o(this,M,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),p=Object.assign(w.argv,o(this,Ht,"f")),h,m=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,mt,"f")&&p[_]?y=!0:_===o(this,Ct,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,D,"f").clearCachedHelpMessage();try{if(this[Xe](),e)return this[Kt](p,c,!!n,!1);o(this,mt,"f")&&[o(this,mt,"f")].concat(m[o(this,mt,"f")]||[]).filter(U=>U.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,je,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,ht,"f").completionKey in p,R=y||d||r;if(p._.length){if(_.length){let L;for(let U=i||0,z;p._[U]!==void 0;U++)if(z=String(p._[U]),_.includes(z)&&z!==o(this,lt,"f")){let Y=o(this,tt,"f").runCommand(z,this,w,U+1,r,y||E||r);return this[Kt](Y,c,!!n,!1)}else if(!L&&z!==o(this,lt,"f")){L=z;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Se,"f")&&L&&!R&&o(this,X,"f").recommendCommands(L,_)}o(this,lt,"f")&&p._.includes(o(this,lt,"f"))&&!d&&(o(this,dt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!R){let L=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Kt](L,c,!!n,!1)}if(d){o(this,dt,"f")&&Mt(!0),t=[].concat(t);let L=t.slice(t.indexOf(`--${o(this,ht,"f").completionKey}`)+1);return o(this,ht,"f").getCompletion(L,(U,z)=>{if(U)throw new V(U.message);(z||[]).forEach(Y=>{o(this,te,"f").log(Y)}),this.exit(0)}),this[Kt](p,!c,!!n,!1)}if(o(this,ct,"f")||(y?(o(this,dt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,dt,"f")&&Mt(!0),a=!0,o(this,D,"f").showVersion("log"),this.exit(0))),!a&&o(this,M,"f").skipValidation.length>0&&(a=Object.keys(p).some(L=>o(this,M,"f").skipValidation.indexOf(L)>=0&&p[L]===!0)),!a){if(w.error)throw new V(w.error.message);if(!d){let L=this[an](m,{},w.error);n||(h=Rt(p,this,o(this,pt,"f").getMiddleware(),!0)),h=this[ri](L,h??p),q(h)&&!n&&(h=h.then(()=>Rt(p,this,o(this,pt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,D,"f").fail(_.message,_);else throw _}return this[Kt](h??p,c,!!n,!0)}[an](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new V(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let c=!1;o(this,Gt,"f")&&(c=o(this,X,"f").unknownCommands(a)),o(this,Yt,"f")&&!c?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,Vt,"f")&&o(this,X,"f").unknownArguments(a,t,{},!1,!1),o(this,X,"f").limitedChoices(a),o(this,X,"f").implications(a),o(this,X,"f").conflicting(a)}}[mi](){A(this,ct,!0,"f")}[Qt](t){if(typeof t=="string")o(this,M,"f").key[t]=!0;else for(let e of t)o(this,M,"f").key[e]=!0}};function Un(s){return!!s&&typeof s.getInternalMethods=="function"}var Ss=gi(Ye),bi=Ss;await bi(He(process.argv)).command("$0 <file-or-url>",'Convert a tldraw ".tldr" file or tldraw.com URL to an svg or png image',s=>s.positional("file-or-url",{demandOption:!0,describe:'The sketch to convert to an image \u2014 either a path to a local ".tldr" file, or a tldraw.com sketch URL.',type:"string"}).option("format",{alias:"f",choices:["png","svg"],default:"svg",describe:"Output image format.",type:"string"}).option("output",{alias:"o",default:"./",describe:"Output image directory.",type:"string"}).option("transparent",{alias:"t",default:void 0,describe:"When true, produces an image with a transparent background. If left undefined, project setting is used.",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose output.",type:"boolean"}),async s=>{let{fileOrUrl:t,format:e,output:n,transparent:i,verbose:r}=s;try{await mn(t,e,n,r,i),process.exit(0)}catch(a){console.error("Error during conversion:",a),process.exit(1)}}).alias("h","help").version("version",cn).alias("v","version").help().parse();
66
69
  /*! Bundled license information:
67
70
 
68
71
  yargs-parser/build/lib/string-utils.js:
package/dist/.DS_Store ADDED
Binary file
package/dist/lib/index.js CHANGED
@@ -1 +1,4 @@
1
- import D from"express";import B from"node:net";import C from"node:os";var g=class extends Error{constructor(o){super(`${o} is locked`)}},d={old:new Set,young:new Set},k=1e3*15;var u,L=()=>{let e=C.networkInterfaces(),o=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let t of r)o.add(t.address);return o},$=e=>new Promise((o,r)=>{let t=B.createServer();t.unref(),t.on("error",r),t.listen(e,()=>{let{port:a}=t.address();t.close(()=>{o(a)})})}),b=async(e,o)=>{if(e.host||e.port===0)return $(e);for(let r of o)try{await $({port:e.port,host:r})}catch(t){if(!["EADDRNOTAVAIL","EINVAL"].includes(t.code))throw t}return e.port},j=function*(e){e&&(yield*e),yield 0};async function P(e){let o,r=new Set;if(e&&(e.port&&(o=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let a=e.exclude;if(typeof a[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let n of a){if(typeof n!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(n))throw new TypeError(`Number ${n} in the exclude option is not a safe integer and can't be used`)}r=new Set(a)}u===void 0&&(u=setTimeout(()=>{u=void 0,d.old=d.young,d.young=new Set},k),u.unref&&u.unref());let t=L();for(let a of j(o))try{if(r.has(a))continue;let n=await b({...e,port:a},t);for(;d.old.has(n)||d.young.has(n);){if(a!==0)throw new g(a);n=await b({...e,port:a},t)}return d.young.add(n),n}catch(n){if(!["EADDRINUSE","EACCES"].includes(n.code)&&!(n instanceof g))throw n}throw new Error("No available ports found")}import x from"node:fs/promises";import h from"node:os";import i from"node:path";import{dirname as G}from"node:path";import{fileURLToPath as M}from"node:url";import F from"puppeteer";import q from"node:os";var I=q.homedir();function m(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return I?e.replace(/^~(?=$|\/|\\)/,I):e}async function U(e,o="svg",r="./",t=!1){return e.startsWith("https://www.tldraw.com/")?(t&&console.log("tldraw URL detected"),V(e,o,r,t)):(t&&console.log("Local file detected"),_(e,o,r,t))}async function V(e,o,r,t){t&&console.log("Starting Puppeteer...");let n=await(await F.launch({headless:"new"})).newPage(),l=await n.target().createCDPSession();await l.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:h.tmpdir(),eventsEnabled:!0}),t&&console.log(`Navigating to: ${e}`),await n.goto(e,{waitUntil:"networkidle0"}),t&&console.log("Requesting download"),await W(n,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${o}`]);let w=await v(l);t&&console.log("Download complete");let p=i.join(h.tmpdir(),w),c=m(i.join(r,`${w}.${o}`));return await x.rename(p,c),t&&console.log(`Saved to "${c}"`),c}async function _(e,o,r,t){let a=G(M(import.meta.url)),n=i.resolve(m(e));t&&console.log(`Loading tldr file "${n}"`);let l=await x.readFile(n,"utf8");t&&console.log("Starting tldraw server...");let w=i.join(a,a.endsWith("/src/lib")?"../../dist/tldraw":a.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");t&&console.log(`tldraw served from "${w}"`);let p=await O(w),{port:c}=p.address();t&&console.log(`tldraw hosted at "http://localhost:${c}"`),t&&console.log("Starting Puppeteer...");let E=await F.launch({headless:"new"}),s=await E.newPage();await s.setRequestInterception(!0),s.on("request",f=>{f.url().endsWith("favicon.ico")?f.respond({status:200}):f.continue()}),H(s,t);let S=await s.target().createCDPSession();await S.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:h.tmpdir(),eventsEnabled:!0}),await s.goto(`http://localhost:${c}`),await s.waitForFunction(()=>window.tldrawExportFile!==void 0),t&&console.log("Requesting download"),await s.evaluate((f,R)=>{window.tldrawExportFile(f,R)},l,o);let T=await v(S);t&&console.log("Download complete"),await E.close(),t&&console.log("Stopped Puppeteer");let A=i.basename(e,i.extname(e)),N=i.join(h.tmpdir(),T),y=m(i.join(r,`${A}.${o}`));return await x.rename(N,y),t&&console.log(`Saved to "${y}"`),p.close(),t&&console.log("Stopped tldraw server"),i.resolve(y)}function H(e,o){e.on("console",r=>{let t=r.type(),a=r.text();t==="error"?console.error(`[Browser] ${a}`):t==="warning"?console.warn(`[Browser] ${a}`):o&&console.log(`[Browser] ${a}`)})}async function O(e){let o=D(),r=await P();return o.use(D.static(e)),new Promise((t,a)=>{let n=o.listen(r,()=>{t(n)});n.on("error",l=>{a(l)})})}async function v(e){return new Promise((o,r)=>{e.on("Browser.downloadProgress",t=>{t.state==="completed"?o(t.guid):t.state==="canceled"&&r(new Error("Download was canceled"))})})}async function W(e,o){for(let r of o)await e.waitForSelector(`[data-testid="${r}"]`),await e.click(`[data-testid="${r}"]`)}export{U as tldrawToImage};
1
+ import v from"express";import C from"node:net";import L from"node:os";var h=class extends Error{constructor(o){super(`${o} is locked`)}},d={old:new Set,young:new Set},q=1e3*15;var u,M=()=>{let e=L.networkInterfaces(),o=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let t of r)o.add(t.address);return o},b=e=>new Promise((o,r)=>{let t=C.createServer();t.unref(),t.on("error",r),t.listen(e,()=>{let{port:n}=t.address();t.close(()=>{o(n)})})}),I=async(e,o)=>{if(e.host||e.port===0)return b(e);for(let r of o)try{await b({port:e.port,host:r})}catch(t){if(!["EADDRNOTAVAIL","EINVAL"].includes(t.code))throw t}return e.port},U=function*(e){e&&(yield*e),yield 0};async function S(e){let o,r=new Set;if(e&&(e.port&&(o=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let n=e.exclude;if(typeof n[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let a of n){if(typeof a!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(a))throw new TypeError(`Number ${a} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}u===void 0&&(u=setTimeout(()=>{u=void 0,d.old=d.young,d.young=new Set},q),u.unref&&u.unref());let t=M();for(let n of U(o))try{if(r.has(n))continue;let a=await I({...e,port:n},t);for(;d.old.has(a)||d.young.has(a);){if(n!==0)throw new h(n);a=await I({...e,port:n},t)}return d.young.add(a),a}catch(a){if(!["EADDRINUSE","EACCES"].includes(a.code)&&!(a instanceof h))throw a}throw new Error("No available ports found")}import E from"node:fs/promises";import y from"node:os";import s from"node:path";import{dirname as O}from"node:path";import{fileURLToPath as V}from"node:url";import D from"puppeteer";import G from"node:os";var T=G.homedir();function p(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return T?e.replace(/^~(?=$|\/|\\)/,T):e}async function _(e,o="svg",r="./",t=!1,n=void 0){return e.startsWith("https://www.tldraw.com/")?(t&&console.log("tldraw URL detected"),J(e,o,r,t,n)):(t&&console.log("Local file detected"),K(e,o,r,t,n))}async function H(e){await e.evaluate("app.clearOpenMenus()")}async function W(e){return!await e.evaluate("editor.getInstanceState().exportBackground")}async function z(e,o){await e.evaluate(`editor.updateInstanceState(
2
+ { exportBackground: ${!o} },
3
+ { ephemeral: true },
4
+ )`)}async function J(e,o,r,t,n){t&&console.log("Starting Puppeteer...");let a=await D.launch({headless:"new"}),i=await a.newPage(),m=await i.target().createCDPSession();await m.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:y.tmpdir(),eventsEnabled:!0}),t&&console.log(`Navigating to: ${e}`),await i.goto(e,{waitUntil:"networkidle0"}),n===void 0?t&&console.log("Using project transparency"):await W(i)!==n&&(t&&console.log(`Setting background to transparent: ${n}`),await z(i,n)),t&&console.log("Requesting download"),await H(i),await Y(i,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${o}`]);let f=await F(m);t&&console.log("Download complete"),await a.close(),t&&console.log("Stopped Puppeteer");let g=s.join(y.tmpdir(),f),c=p(s.join(r,`${f}.${o}`));return await E.rename(g,c),t&&console.log(`Saved to "${c}"`),c}async function K(e,o,r,t,n){let a=O(V(import.meta.url)),i=s.resolve(p(e));t&&console.log(`Loading tldr file "${i}"`);let m=await E.readFile(i,"utf8");t&&console.log("Starting tldraw server...");let f=s.join(a,a.endsWith("/src/lib")?"../../dist/tldraw":a.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");t&&console.log(`tldraw served from "${f}"`);let g=await X(f),{port:c}=g.address();t&&console.log(`tldraw hosted at "http://localhost:${c}"`),t&&console.log("Starting Puppeteer...");let P=await D.launch({headless:"new"}),l=await P.newPage();await l.setRequestInterception(!0),l.on("request",w=>{w.url().endsWith("favicon.ico")?w.respond({status:200}):w.continue()}),Q(l,t);let $=await l.target().createCDPSession();await $.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:y.tmpdir(),eventsEnabled:!0}),await l.goto(`http://localhost:${c}`),await l.waitForFunction(()=>window.tldrawExportFile!==void 0),t&&console.log("Requesting download");let N=n===void 0?null:n;await l.evaluate((w,R,j)=>{window.tldrawExportFile(w,R,j)},m,o,N);let A=await F($);t&&console.log("Download complete"),await P.close(),t&&console.log("Stopped Puppeteer");let k=s.basename(e,s.extname(e)),B=s.join(y.tmpdir(),A),x=p(s.join(r,`${k}.${o}`));return await E.rename(B,x),t&&console.log(`Saved to "${x}"`),g.close(),t&&console.log("Stopped tldraw server"),s.resolve(x)}function Q(e,o){e.on("console",r=>{let t=r.type(),n=r.text();t==="error"?console.error(`[Browser] ${n}`):t==="warning"?console.warn(`[Browser] ${n}`):o&&console.log(`[Browser] ${n}`)})}async function X(e){let o=v(),r=await S();return o.use(v.static(e)),new Promise((t,n)=>{let a=o.listen(r,()=>{t(a)});a.on("error",i=>{n(i)})})}async function F(e){return new Promise((o,r)=>{e.on("Browser.downloadProgress",t=>{t.state==="completed"?o(t.guid):t.state==="canceled"&&r(new Error("Download was canceled"))})})}async function Y(e,o){for(let r of o)await e.waitForSelector(`[data-testid="${r}"]`),await e.click(`[data-testid="${r}"]`)}export{_ as tldrawToImage};
@@ -1,2 +1,2 @@
1
1
  import type { ExportFormat } from '../types';
2
- export declare function tldrawToImage(tldrPathOrUrl: string, format?: ExportFormat, destination?: string, verbose?: boolean): Promise<string>;
2
+ export declare function tldrawToImage(tldrPathOrUrl: string, format?: ExportFormat, destination?: string, verbose?: boolean, transparent?: boolean | undefined): Promise<string>;
@@ -312,4 +312,4 @@ Error generating stack: `+s.message+`
312
312
  font-weight: ${y.weight};
313
313
  font-style: ${y.style};
314
314
  src: url("${o}") format("woff2")
315
- }`,()=>{document.fonts.delete(y),h=!0}},[e,n]),t};function Eee(e){return{draw:{url:e.fonts.draw},serif:{url:e.fonts.serif},sansSerif:{url:e.fonts.sansSerif},monospace:{url:e.fonts.monospace}}}function kee(e){const n=b.useMemo(()=>Eee(e),[e]),t=[zd("tldraw_draw",n.draw),zd("tldraw_serif",n.serif),zd("tldraw_sans",n.sansSerif),zd("tldraw_mono",n.monospace)];return{error:t.some(r=>r===1),done:!t.some(r=>r===2)}}function Iee(e){const{children:n,maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i,...a}=e,l=sL(a.components??{}),c=Cx(a.shapeUtils??[]),u=Cx(a.tools??[]),d={initialState:"select",...a,components:b.useMemo(()=>({Scribble:vb,CollaboratorScribble:vb,SelectionForeground:fU,SelectionBackground:hU,Handles:iU,HoveredShapeIndicator:aU,...l}),[l]),shapeUtils:b.useMemo(()=>[...IV,...c],[c]),tools:b.useMemo(()=>[...BV,...iH,...u],[u])},h=DG(a.assetUrls),{done:p,error:y}=kee(h);return y?g.jsx(tL,{children:"Could not load assets. Please refresh the page."}):p?g.jsx(Zj,{...d,children:g.jsxs(tee,{...d,children:[g.jsx(Cee,{children:g.jsx(Av,{})}),g.jsx(_ee,{maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i}),n]})}):g.jsx(wE,{children:"Loading assets..."})}function _ee({maxImageDimension:e=1e3,maxAssetSize:n=10*1024*1024,acceptedImageMimeTypes:t=["image/jpeg","image/png","image/gif","image/svg+xml"],acceptedVideoMimeTypes:r=["video/mp4","video/quicktime"],onMount:o}){const s=K(),i=Tee(a=>{const l=[];return l.push(..._V(a)),GU(a,{maxImageDimension:e,maxAssetSize:n,acceptedImageMimeTypes:t,acceptedVideoMimeTypes:r}),l.push(o==null?void 0:o(a)),()=>{l.forEach(c=>c==null?void 0:c())}});return b.useLayoutEffect(()=>{if(s)return i==null?void 0:i(s)},[s,i]),null}function Tee(e){const n=b.useRef();return b.useLayoutEffect(()=>{n.current=e}),b.useDebugValue(e),b.useCallback((...t)=>{const r=n.current;return oi(r,"fn does not exist"),r(...t)},[])}const $ee=1,Mee=Pe({tldrawFileFormatVersion:E5,schema:Pe({schemaVersion:Bu,storeVersion:Bu,recordVersions:Sy(me,Pe({version:Bu,subTypeVersions:Sy(me,Bu).optional(),subTypeKey:me.optional()}))}),records:ln(Pe({id:me,typeName:me}).allowUnknownProperties())});function Aee(e){var n;try{return!!((n=e.document)!=null&&n.version)}catch{return!1}}function Oee({json:e,schema:n}){let t;try{t=Mee.validate(JSON.parse(e))}catch(o){try{if(t=JSON.parse(e),Aee(t))return Ks.err({type:"v1File",data:t})}catch{}return Ks.err({type:"notATldrawFile",cause:o})}if(t.tldrawFileFormatVersion>$ee)return Ks.err({type:"fileFormatVersionTooNew",version:t.tldrawFileFormatVersion});let r;try{const o=Object.fromEntries(t.records.map(s=>[s.id,s]));r=n.migrateStoreSnapshot({store:o,schema:t.schema})}catch(o){return Ks.err({type:"invalidRecords",cause:o})}if(r.type==="error")return Ks.err({type:"migrationFailed",reason:r.reason});try{return Ks.ok(mE({initialData:r.value,schema:n}))}catch(o){return Ks.err({type:"invalidRecords",cause:o})}}function Ree(){const[e,n]=b.useState(null),[t,r]=b.useState(null),[o,s]=b.useState(null);b.useEffect(()=>{const a=(l,c)=>{n(c),r(l)};window.tldrawExportFile=a},[]),b.useEffect(()=>{if(o&&e&&t){console.log(`tldraw is exporting to ${e}`);try{Dee(o,t)}catch(a){console.error(`error parsing and loading data: ${String(a)}`)}f$(o,[],e,{}).then(()=>{console.log("exported data successfully")}).catch(a=>{console.error(`error exporting data: ${a}`)})}},[o,t,e]);const i=a=>{o||(console.log("tldraw is ready"),s(a))};return g.jsx("div",{style:{inset:0,position:"fixed"},children:g.jsx(Iee,{assetUrls:LA(),onMount:i})})}function Dee(e,n){const t=Oee({json:n,schema:e.store.schema});if(!t.ok)throw new Error(String(t.error));nr(()=>{const{isFocused:r}=e.getInstanceState();e.store.clear();const[o,s]=jee(t.value.allRecords(),a=>a.typeName==="shape");e.store.put(s,"initialize"),e.store.put(o,"initialize"),e.history.clear(),e.updateViewportScreenBounds();const i=e.getCurrentPageBounds();i&&e.zoomToBounds(i,1),e.updateInstanceState({isFocused:r})})}function jee(e,n){const t=[],r=[];for(const o of e)n(o)?t.push(o):r.push(o);return[t,r]}var av={},LC=il;av.createRoot=LC.createRoot,av.hydrateRoot=LC.hydrateRoot;av.createRoot(document.querySelector("#root")).render(g.jsx(ne.StrictMode,{children:g.jsx(Ree,{})}));
315
+ }`,()=>{document.fonts.delete(y),h=!0}},[e,n]),t};function Eee(e){return{draw:{url:e.fonts.draw},serif:{url:e.fonts.serif},sansSerif:{url:e.fonts.sansSerif},monospace:{url:e.fonts.monospace}}}function kee(e){const n=b.useMemo(()=>Eee(e),[e]),t=[zd("tldraw_draw",n.draw),zd("tldraw_serif",n.serif),zd("tldraw_sans",n.sansSerif),zd("tldraw_mono",n.monospace)];return{error:t.some(r=>r===1),done:!t.some(r=>r===2)}}function Iee(e){const{children:n,maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i,...a}=e,l=sL(a.components??{}),c=Cx(a.shapeUtils??[]),u=Cx(a.tools??[]),d={initialState:"select",...a,components:b.useMemo(()=>({Scribble:vb,CollaboratorScribble:vb,SelectionForeground:fU,SelectionBackground:hU,Handles:iU,HoveredShapeIndicator:aU,...l}),[l]),shapeUtils:b.useMemo(()=>[...IV,...c],[c]),tools:b.useMemo(()=>[...BV,...iH,...u],[u])},h=DG(a.assetUrls),{done:p,error:y}=kee(h);return y?g.jsx(tL,{children:"Could not load assets. Please refresh the page."}):p?g.jsx(Zj,{...d,children:g.jsxs(tee,{...d,children:[g.jsx(Cee,{children:g.jsx(Av,{})}),g.jsx(_ee,{maxImageDimension:t,maxAssetSize:r,acceptedImageMimeTypes:o,acceptedVideoMimeTypes:s,onMount:i}),n]})}):g.jsx(wE,{children:"Loading assets..."})}function _ee({maxImageDimension:e=1e3,maxAssetSize:n=10*1024*1024,acceptedImageMimeTypes:t=["image/jpeg","image/png","image/gif","image/svg+xml"],acceptedVideoMimeTypes:r=["video/mp4","video/quicktime"],onMount:o}){const s=K(),i=Tee(a=>{const l=[];return l.push(..._V(a)),GU(a,{maxImageDimension:e,maxAssetSize:n,acceptedImageMimeTypes:t,acceptedVideoMimeTypes:r}),l.push(o==null?void 0:o(a)),()=>{l.forEach(c=>c==null?void 0:c())}});return b.useLayoutEffect(()=>{if(s)return i==null?void 0:i(s)},[s,i]),null}function Tee(e){const n=b.useRef();return b.useLayoutEffect(()=>{n.current=e}),b.useDebugValue(e),b.useCallback((...t)=>{const r=n.current;return oi(r,"fn does not exist"),r(...t)},[])}const $ee=1,Mee=Pe({tldrawFileFormatVersion:E5,schema:Pe({schemaVersion:Bu,storeVersion:Bu,recordVersions:Sy(me,Pe({version:Bu,subTypeVersions:Sy(me,Bu).optional(),subTypeKey:me.optional()}))}),records:ln(Pe({id:me,typeName:me}).allowUnknownProperties())});function Aee(e){var n;try{return!!((n=e.document)!=null&&n.version)}catch{return!1}}function Oee({json:e,schema:n}){let t;try{t=Mee.validate(JSON.parse(e))}catch(o){try{if(t=JSON.parse(e),Aee(t))return Ks.err({type:"v1File",data:t})}catch{}return Ks.err({type:"notATldrawFile",cause:o})}if(t.tldrawFileFormatVersion>$ee)return Ks.err({type:"fileFormatVersionTooNew",version:t.tldrawFileFormatVersion});let r;try{const o=Object.fromEntries(t.records.map(s=>[s.id,s]));r=n.migrateStoreSnapshot({store:o,schema:t.schema})}catch(o){return Ks.err({type:"invalidRecords",cause:o})}if(r.type==="error")return Ks.err({type:"migrationFailed",reason:r.reason});try{return Ks.ok(mE({initialData:r.value,schema:n}))}catch(o){return Ks.err({type:"invalidRecords",cause:o})}}function Ree(){const[e,n]=b.useState(null),[t,r]=b.useState(),[o,s]=b.useState(null),[i,a]=b.useState(null);b.useEffect(()=>{const c=(u,d,h)=>{n(d),r(h),s(u)};window.tldrawExportFile=c},[]),b.useEffect(()=>{if(i&&e&&o&&t!==void 0){console.log(`tldraw is exporting to ${e}`);try{Dee(i,o)}catch(u){console.error(`error parsing and loading data: ${String(u)}`)}f$(i,[],e,t===null?{}:{background:!t}).then(()=>{console.log("exported data successfully")}).catch(u=>{console.error(`error exporting data: ${u}`)})}},[i,o,e]);const l=c=>{i||(console.log("tldraw is ready"),a(c))};return g.jsx("div",{style:{inset:0,position:"fixed"},children:g.jsx(Iee,{assetUrls:LA(),onMount:l})})}function Dee(e,n){const t=Oee({json:n,schema:e.store.schema});if(!t.ok)throw new Error(String(t.error));nr(()=>{const{isFocused:r}=e.getInstanceState();e.store.clear();const[o,s]=jee(t.value.allRecords(),a=>a.typeName==="shape");e.store.put(s,"initialize"),e.store.put(o,"initialize"),e.history.clear(),e.updateViewportScreenBounds();const i=e.getCurrentPageBounds();i&&e.zoomToBounds(i,1),e.updateInstanceState({isFocused:r})})}function jee(e,n){const t=[],r=[];for(const o of e)n(o)?t.push(o):r.push(o);return[t,r]}var av={},LC=il;av.createRoot=LC.createRoot,av.hydrateRoot=LC.hydrateRoot;av.createRoot(document.querySelector("#root")).render(g.jsx(ne.StrictMode,{children:g.jsx(Ree,{})}));
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>tldraw export helper</title>
7
- <script type="module" crossorigin src="/assets/index-a71XA0Xq.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-pvJwlX83.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-Go1mR3Ch.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kitschpatrol/tldraw-cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
- "description": "A tiny little CLI tool for converting tldraw .tldr files into svg or png images.",
5
+ "description": "A tiny little CLI tool for rendering tldraw URLs and .tldr files into svg or png images.",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/kitschpatrol/tldraw-cli.git"
@@ -51,7 +51,7 @@
51
51
  "@tldraw/editor": "2.0.0-beta.2",
52
52
  "@tldraw/tldraw": "2.0.0-beta.2",
53
53
  "@types/express": "^4.17.21",
54
- "@types/react": "^18.2.47",
54
+ "@types/react": "^18.2.48",
55
55
  "@types/react-dom": "^18.2.18",
56
56
  "@types/yargs": "^17.0.32",
57
57
  "@vitejs/plugin-react-swc": "^3.5.0",
@@ -66,6 +66,7 @@
66
66
  "typescript": "^5.3.3",
67
67
  "untildify": "^5.0.0",
68
68
  "vite": "^5.0.11",
69
+ "vitest": "^1.2.0",
69
70
  "yargs": "^17.7.2"
70
71
  },
71
72
  "publishConfig": {
@@ -77,12 +78,11 @@
77
78
  "build:lib": "tsx ./scripts/build-lib.ts && tsc -p tsconfig.lib.json",
78
79
  "build:tldraw": "pnpm run tldraw-copy-assets && vite build",
79
80
  "dev": "pnpm run tldraw-copy-assets && vite",
80
- "dev-cli": "pnpm run build:tldraw && tsx ./src/cli/tldraw-cli.ts ./test-assets/box.tldr --verbose",
81
- "dev-cli-url": "pnpm run build && tsx ./src/cli/tldraw-cli.ts https://www.tldraw.com/s/v2_c_cQCtLu41OH97xkTl2Mt-9 --format png --verbose",
82
81
  "fix": "shared-config --fix",
83
82
  "lint": "shared-config --lint",
84
83
  "preview": "vite preview",
85
84
  "release": "pnpm build && pnpm bumpp --commit 'Release: %s' && pnpm publish --otp $(op read 'op://Personal/Npmjs/one-time password?attribute=otp')",
85
+ "test": "vitest",
86
86
  "tldraw-copy-assets": "rsync -av --include='/*/' --exclude='/*' ./node_modules/@tldraw/assets/ ./src/tldraw/public/"
87
87
  }
88
88
  }
package/readme.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Overview
6
6
 
7
- **A minimal CLI app to automate conversion and export of [tldraw](https://tldraw.dev) `.tldr` files into svg or png image formats.**
7
+ **A minimal CLI app to automate conversion and export of [tldraw](https://tldraw.dev) URLs and `.tldr` files into svg or png image formats.**
8
8
 
9
9
  This could be useful in the context of a content publishing pipeline where you want to use a `.tldr` file (perhaps under version control) as the "source of truth" for assets to be embedded elsewhere, and you don't want to manage the export of that diagram manually.
10
10
 
@@ -38,17 +38,18 @@ npm --install --global @kitschpatrol/tldraw-cli
38
38
  tldraw-cli file-or-url {options}
39
39
  ```
40
40
 
41
- | Argument | Description |
42
- | ------------- | ------------------------------------------------------------------------------------------------------ |
43
- | `file-or-url` | The sketch to convert to an image — either a path to a local ".tldr" file, or a tldraw\.com sketch URL |
41
+ | Argument | Description |
42
+ | ------------- | ------------------------------------------------------------------------------------------------------- |
43
+ | `file-or-url` | The sketch to convert to an image — either a path to a local ".tldr" file, or a tldraw\.com sketch URL. |
44
44
 
45
- | Option | Description | Default |
46
- | ----------------- | ------------------------------------------- | ------- |
47
- | `-f`, `--format` | Output image format , one of "png" or "svg" | `svg` |
48
- | `-o`, `--output` | Output image directory | `./` |
49
- | `-h`, `--help` | Show help | |
50
- | `-v`, `--version` | Show version number | |
51
- | `--verbose` | Enable verbose output | `false` |
45
+ | Option | Description | Default |
46
+ | --------------------- | ------------------------------------------------------------------------------------------------------- | ----------- |
47
+ | `-f`, `--format` | Output image format , one of "png" or "svg". | `svg` |
48
+ | `-t`, `--transparent` | When true, produces an image with a transparent background. If left undefined, project setting is used. | `undefined` |
49
+ | `-o`, `--output` | Output image directory. | `./` |
50
+ | `-h`, `--help` | Show help. | |
51
+ | `-v`, `--version` | Show version number. | |
52
+ | `--verbose` | Enable verbose output. | `false` |
52
53
 
53
54
  ## Examples
54
55
 
@@ -72,6 +73,12 @@ npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
72
73
  npx @kitschpatrol/tldraw-cli your-drawing.tldr --format png
73
74
  ```
74
75
 
76
+ ### Export with a transparent background
77
+
78
+ ```sh
79
+ npx @kitschpatrol/tldraw-cli your-drawing.tldr --transparent --format png
80
+ ```
81
+
75
82
  ### Export to a specific destination
76
83
 
77
84
  ```sh
@@ -135,10 +142,10 @@ The local instance of tldraw includes its assets dependencies, so the tool shoul
135
142
 
136
143
  This is a very minimal implementation. Current plans for future improvements include the following:
137
144
 
138
- - Add automated tests
145
+ - Switch to options object in Node API for 2.0
146
+ - Add CLI tests
139
147
  - Implement the ability to export specific frames or pages as separate image files
140
148
  - Add an option flag to set dpi when exporting to a bitmap format
141
- - Add option flag for transparent background
142
149
 
143
150
  Any other suggestions are welcome.
144
151