@kitschpatrol/tldraw-cli 2.0.3 → 2.1.1
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 +36 -21
- package/dist/lib/index.js +20 -3
- package/dist/lib/tldraw-to-image.d.ts +7 -1
- package/package.json +3 -1
- package/readme.md +62 -17
package/bin/cli.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var _t=(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 fn="2.0.2";import dn from"node:path";import{fileURLToPath as Ai}from"node:url";import xi,{promises as Ei}from"fs";async function $e(s,t,e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);try{return(await Ei[s](e))[t]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function ve(s,t,e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);try{return xi[s](e)[t]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var Ts=$e.bind(null,"stat","isFile"),Hs=$e.bind(null,"stat","isDirectory"),Bs=$e.bind(null,"lstat","isSymbolicLink"),un=ve.bind(null,"statSync","isFile"),Ys=ve.bind(null,"statSync","isDirectory"),qs=ve.bind(null,"lstatSync","isSymbolicLink");import ji from"node:os";var hn=ji.homedir();function ie(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return hn?s.replace(/^~(?=$|\/|\\)/,hn):s}function Fe(s,t={}){let{requireFileExistence:e,validFileExtensions:n,validHostnames:i}=t;if(URL.canParse(s)){let m=new URL(s);if(m.protocol==="file:")return Fe(Ai(m),t);if(i&&!i.includes(m.hostname))throw new Error(`Bad input URL. Only ${i.join(", ")} URLs are supported.`);return m}let r=ie(s),a=dn.normalize(r);if(e&&!un(a))throw new Error("Input is not a file.");let l=dn.extname(a);if(n&&!n.includes(l))throw new Error(`Bad input file name. Only ${n.join(", ")} files are supported.`);return a}import gn from"express";import Pi from"node:net";import Si from"node:os";var he=class extends Error{constructor(t){super(`${t} is locked`)}},Jt={old:new Set,young:new Set},Mi=1e3*15;var se,Ii=()=>{let s=Si.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},pn=s=>new Promise((t,e)=>{let n=Pi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),mn=async(s,t)=>{if(s.host||s.port===0)return pn(s);for(let e of t)try{await pn({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},$i=function*(s){s&&(yield*s),yield 0};async function De(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)}se===void 0&&(se=setTimeout(()=>{se=void 0,Jt.old=Jt.young,Jt.young=new Set},Mi),se.unref&&se.unref());let n=Ii();for(let i of $i(t))try{if(e.has(i))continue;let r=await mn({...s,port:i},n);for(;Jt.old.has(r)||Jt.young.has(r);){if(i!==0)throw new he(i);r=await mn({...s,port:i},n)}return Jt.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 bn from"node:fs/promises";import wn from"node:os";import Zt from"node:path";import{dirname as vi}from"node:path";import{fileURLToPath as Fi}from"node:url";import Di from"puppeteer";var Ni={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!1};async function On(s,t={}){let e={...Ni,...zi(t)},{darkMode:n,format:i,output:r,transparent:a,verbose:l}=e,m=Fe(s,{requireFileExistence:!0,validFileExtensions:[".tldr"],validHostnames:["www.tldraw.com"]}),w=typeof m=="string";l&&console.log(w?"Local file detected":"tldraw URL detected");let p=0,h;if(w){l&&console.log("Starting tldraw server...");let T=vi(Fi(import.meta.url)),rt=Zt.join(T,T.endsWith("/src/lib")?"../../dist/tldraw":T.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");l&&console.log(`tldraw served from "${rt}"`),h=await Wi(rt),p=h.address().port,l&&console.log(`tldraw hosted at "http://localhost:${p}"`)}l&&console.log("Starting Puppeteer...");let g=await Di.launch({args:w?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),y=await g.newPage();Li(y,l);let E=await y.target().createCDPSession();if(await E.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:wn.tmpdir(),eventsEnabled:!0}),w){await y.setRequestInterception(!0),y.on("request",rt=>{rt.url().endsWith("favicon.ico")?rt.respond({status:200}):rt.continue()}),l&&console.log(`Loading tldr file "${m}"`);let T=await bn.readFile(m,"utf8");await y.evaluateOnNewDocument(rt=>{localStorage.clear(),localStorage.setItem("tldrData",rt)},T)}let _=w?`http://localhost:${p}`:m.href;l&&console.log(`Navigating to: ${_}`),await y.goto(_,{waitUntil:"networkidle0"}),l&&console.log(`Setting background transparency: ${a}`),await Bi(y,a),l&&console.log(`Setting dark mode: ${n}`);let d=await Hi(y);await yn(y,n),l&&console.log("Requesting download"),await Ti(y),await Ui(y,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${i}`]);let W=await Ri(E);l&&console.log("Download complete"),l&&console.log(`Restoring dark mode: ${d}`),await yn(y,d),await g.close(),l&&console.log("Stopped Puppeteer"),w&&h&&(h.close(),l&&console.log("Stopped tldraw server"));let R=w?Zt.basename(m,Zt.extname(m)):W,Y=Zt.join(wn.tmpdir(),W),U=ie(Zt.join(r,`${R}.${i}`));return await bn.rename(Y,U),l&&console.log(`Saved to "${U}"`),Zt.resolve(U)}function Li(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 Wi(s){let t=gn(),e=await De();return t.use(gn.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function Ri(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 Ui(s,t){for(let e of t)await s.waitForSelector(`[data-testid="${e}"]`),await s.click(`[data-testid="${e}"]`)}function zi(s){return Object.fromEntries(Object.entries(s).filter(([,t])=>t!==void 0))}async function Ti(s){await s.evaluate("app.clearOpenMenus()")}async function Hi(s){return!!await s.evaluate("editor.user.getUserPreferences().isDarkMode")}async function yn(s,t){await s.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${t}})`)}async function Bi(s,t){await s.evaluate(`editor.updateInstanceState(
|
|
3
|
-
|
|
2
|
+
var So=Object.create;var vr=Object.defineProperty;var Co=Object.getOwnPropertyDescriptor;var Ao=Object.getOwnPropertyNames;var jo=Object.getPrototypeOf,Po=Object.prototype.hasOwnProperty;var ze=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Io=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Fo=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ao(e))!Po.call(i,r)&&r!==t&&vr(i,r,{get:()=>e[r],enumerable:!(n=Co(e,r))||n.enumerable});return i};var Mo=(i,e,t)=>(t=i!=null?So(jo(i)):{},Fo(e||!i||!i.__esModule?vr(t,"default",{value:i,enumerable:!0}):t,i));var Pr=Io((pn,gn)=>{(function(i,e){typeof pn=="object"&&typeof gn<"u"?gn.exports=e():typeof define=="function"&&define.amd?define(e):(i=i||self,i.v=e())})(pn,function(){"use strict";function i(){return i=Object.assign||function(o){for(var u=1;u<arguments.length;u++){var l=arguments[u];for(var p in l)Object.prototype.hasOwnProperty.call(l,p)&&(o[p]=l[p])}return o},i.apply(this,arguments)}function e(o,u){return r(o)||c(o,u)||b()}function t(o){return n(o)||s(o)||d()}function n(o){if(Array.isArray(o)){for(var u=0,l=new Array(o.length);u<o.length;u++)l[u]=o[u];return l}}function r(o){if(Array.isArray(o))return o}function s(o){if(Symbol.iterator in Object(o)||Object.prototype.toString.call(o)==="[object Arguments]")return Array.from(o)}function c(o,u){if(Symbol.iterator in Object(o)||Object.prototype.toString.call(o)==="[object Arguments]"){var l=[],p=!0,v=!1,A=void 0;try{for(var $=o[Symbol.iterator](),te;!(p=(te=$.next()).done)&&(l.push(te.value),!(u&&l.length===u));p=!0);}catch(Z){v=!0,A=Z}finally{try{!p&&$.return!=null&&$.return()}finally{if(v)throw A}}return l}}function d(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function b(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function y(o){return o==null}function E(o){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return y(o)?u:!!o}function w(o){return typeof o=="string"}function f(o){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return y(o)?u:w(o)?o:String(o)}function _(o,u){var l=f(o),p=E(u);return l===""?"":(p&&(l=l.toLowerCase()),l.substr(0,1).toUpperCase()+l.substr(1))}function F(o){var u=f(o,"");return u.toLowerCase()}var S="\\d",x="\\s\\uFEFF\\xA0",B="\\uD800-\\uDBFF",G="\\uDC00-\\uDFFF",X="\\u0300-\\u036F\\u1AB0-\\u1AFF\\u1DC0-\\u1DFF\\u20D0-\\u20FF\\uFE20-\\uFE2F",K="\\0-\\u02FF\\u0370-\\u1AAF\\u1B00-\\u1DBF\\u1E00-\\u20CF\\u2100-\\uD7FF\\uE000-\\uFE1F\\uFE30-\\uFFFF",k=new RegExp("(["+K+"]|["+B+"]["+G+"]|["+B+"](?!["+G+"])|(?:[^"+B+"]|^)["+G+"])(["+X+"]+)","g"),de=new RegExp("(["+B+"])(["+G+"])","g"),ne=new RegExp("((?:["+K+"]|["+B+"]["+G+"]|["+B+"](?!["+G+"])|(?:[^"+B+"]|^)["+G+"])(?:["+X+"]+))|(["+B+"]["+G+"])|([\\n\\r\\u2028\\u2029])|(.)","g"),We=new RegExp("["+x+"]"),Ue=new RegExp("^["+x+"]+"),q=new RegExp("["+x+"]+$"),R=new RegExp("^"+S+"+$"),P=/[-[\]{}()*+!<=:?./\\^$|#,]/g,N=/[^A-Za-z0-9]/g,H=/[<>&"'`]/g,ee=/(%{1,2})(?:(\d+)\$)?(\+)?([ 0]|'.{1})?(-)?(\d+)?(?:\.(\d+))?([bcdiouxXeEfgGs])?/g,pe=/\.?0+$/g,Q=/<([A-Za-z0-9]+)>/g,ge="\\u2000-\\u206F",Ve="\\x00-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7b-\\xBF\\xD7\\xF7",ue="\\u2700-\\u27BF",Oe="a-z\\xB5\\xDF-\\xF6\\xF8-\\xFF\\u0101\\u0103\\u0105\\u0107\\u0109\\u010B\\u010D\\u010F\\u0111\\u0113\\u0115\\u0117\\u0119\\u011B\\u011D\\u011F\\u0121\\u0123\\u0125\\u0127\\u0129\\u012B\\u012D\\u012F\\u0131\\u0133\\u0135\\u0137\\u0138\\u013A\\u013C\\u013E\\u0140\\u0142\\u0144\\u0146\\u0148\\u0149\\u014B\\u014D\\u014F\\u0151\\u0153\\u0155\\u0157\\u0159\\u015B\\u015D\\u015F\\u0161\\u0163\\u0165\\u0167\\u0169\\u016B\\u016D\\u016F\\u0171\\u0173\\u0175\\u0177\\u017A\\u017C\\u017E-\\u0180\\u0183\\u0185\\u0188\\u018C\\u018D\\u0192\\u0195\\u0199-\\u019B\\u019E\\u01A1\\u01A3\\u01A5\\u01A8\\u01AA\\u01AB\\u01AD\\u01B0\\u01B4\\u01B6\\u01B9\\u01BA\\u01BD-\\u01BF\\u01C6\\u01C9\\u01CC\\u01CE\\u01D0\\u01D2\\u01D4\\u01D6\\u01D8\\u01DA\\u01DC\\u01DD\\u01DF\\u01E1\\u01E3\\u01E5\\u01E7\\u01E9\\u01EB\\u01ED\\u01EF\\u01F0\\u01F3\\u01F5\\u01F9\\u01FB\\u01FD\\u01FF\\u0201\\u0203\\u0205\\u0207\\u0209\\u020B\\u020D\\u020F\\u0211\\u0213\\u0215\\u0217\\u0219\\u021B\\u021D\\u021F\\u0221\\u0223\\u0225\\u0227\\u0229\\u022B\\u022D\\u022F\\u0231\\u0233-\\u0239\\u023C\\u023F\\u0240\\u0242\\u0247\\u0249\\u024B\\u024D\\u024F",_e="\\x41-\\x5a\\xc0-\\xd6\\xd8-\\xde\\u0100\\u0102\\u0104\\u0106\\u0108\\u010a\\u010c\\u010e\\u0110\\u0112\\u0114\\u0116\\u0118\\u011a\\u011c\\u011e\\u0120\\u0122\\u0124\\u0126\\u0128\\u012a\\u012c\\u012e\\u0130\\u0132\\u0134\\u0136\\u0139\\u013b\\u013d\\u013f\\u0141\\u0143\\u0145\\u0147\\u014a\\u014c\\u014e\\u0150\\u0152\\u0154\\u0156\\u0158\\u015a\\u015c\\u015e\\u0160\\u0162\\u0164\\u0166\\u0168\\u016a\\u016c\\u016e\\u0170\\u0172\\u0174\\u0176\\u0178\\u0179\\u017b\\u017d\\u0181\\u0182\\u0184\\u0186\\u0187\\u0189-\\u018b\\u018e-\\u0191\\u0193\\u0194\\u0196-\\u0198\\u019c\\u019d\\u019f\\u01a0\\u01a2\\u01a4\\u01a6\\u01a7\\u01a9\\u01ac\\u01ae\\u01af\\u01b1-\\u01b3\\u01b5\\u01b7\\u01b8\\u01bc\\u01c4\\u01c5\\u01c7\\u01c8\\u01ca\\u01cb\\u01cd\\u01cf\\u01d1\\u01d3\\u01d5\\u01d7\\u01d9\\u01db\\u01de\\u01e0\\u01e2\\u01e4\\u01e6\\u01e8\\u01ea\\u01ec\\u01ee\\u01f1\\u01f2\\u01f4\\u01f6-\\u01f8\\u01fa\\u01fc\\u01fe\\u0200\\u0202\\u0204\\u0206\\u0208\\u020a\\u020c\\u020e\\u0210\\u0212\\u0214\\u0216\\u0218\\u021a\\u021c\\u021e\\u0220\\u0222\\u0224\\u0226\\u0228\\u022a\\u022c\\u022e\\u0230\\u0232\\u023a\\u023b\\u023d\\u023e\\u0241\\u0243-\\u0246\\u0248\\u024a\\u024c\\u024e",Be=new RegExp("(?:["+_e+"]["+X+"]*)?(?:["+Oe+"]["+X+"]*)+|(?:["+_e+"]["+X+"]*)+(?!["+Oe+"])|["+S+"]+|["+ue+"]|[^"+Ve+ge+x+"]+","g"),W=/[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g,_t=new RegExp("^(?:["+Oe+_e+"]["+X+"]*)+$"),U=new RegExp("^((?:["+Oe+_e+"]["+X+"]*)|["+S+"])+$"),ie=/^[\x01-\xFF]*$/;function re(o,u){return o??u}function Y(o){return y(o)?null:w(o)?o:String(o)}function se(o,u,l){var p=f(o),v;if(y(u))v=ie.test(p)?W:Be;else if(u instanceof RegExp)v=u;else{var A=Y(re(l,""));v=new RegExp(Y(u),A)}return re(p.match(v),[])}function fe(o,u){return u===0?F(o):_(o,!0)}function Ae(o){var u=f(o);return u===""?"":se(u).map(fe).join("")}function je(o){var u=f(o);return u===""?"":u.substr(0,1).toLowerCase()+u.substr(1)}function tt(o){var u=f(o);return u===""?"":se(u).map(F).join("-")}function h(o){var u=f(o);return u===""?"":se(u).map(F).join("_")}function m(o){var u=f(o);return u.toUpperCase()}function C(o){var u=f(o);return u.split("").reduce(O,"")}function O(o,u){var l=u.toLowerCase(),p=u.toUpperCase();return o+(u===l?p:l)}function g(o,u){var l=f(o),p=Array.isArray(u)?u:[],v=ie.test(l)?W:Be;return l.replace(v,function(A,$){var te=$>0&&p.indexOf(l[$-1])>=0;return te?A.toLowerCase():_(A,!0)})}function I(o,u,l){return o<=u?u:o>=l?l:o}var j=9007199254740991;function M(o){return o===1/0?j:o===-1/0?-j:~~o}function me(o,u,l){var p=f(o),v=y(u)?p.length:I(M(u),0,j),A=f(l,"...");return v>=p.length?p:p.substr(0,u-A.length)+A}function ye(o,u){var l=f(o);return l.charAt(u)}var Yn=55296,$i=56319,Vn=56320,Li=57343;function Wi(o){return o>=Yn&&o<=$i}function Ui(o){return o>=Vn&&o<=Li}function Bi(o,u){return(o-Yn)*1024+u-Vn+65536}function qe(o){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return y(o)?u:typeof o=="number"?o:Number(o)}function qn(o,u){return o!==o?u:o}function Kn(o,u){var l=f(o),p=l.length,v=qe(u);if(v=qn(v,0),!(v<0||v>=p)){var A=l.charCodeAt(v),$;return Wi(A)&&p>v+1&&($=l.charCodeAt(v+1),Ui($))?Bi(A,$):A}}function Gi(o,u){var l=f(o),p=y(u)?1:I(M(u),0,j);return l.length<=p?l:l.substr(0,p)}function zi(o,u){var l=f(o),p=qe(u),v,A=0;for(p=qn(p,0);(v=ne.exec(l))!==null;){if(A===p)return ne.lastIndex=0,v[0];A++}return""}function Hi(o,u){var l=f(o),p=y(u)?1:I(M(u),0,j);return l.length<=p?l:l.substr(l.length-p,p)}function Yi(o,u,l){var p=f(o),v=y(u)?p.length:I(M(u),0,j),A=f(l,"...");if(v>=p.length)return p;var $=ie.test(p)?W:Be,te=0;return p.replace($,function(Z,be){var J=be+Z.length;J<=v-A.length&&(te=J)}),p.substr(0,te)+A}function Vi(o,u,l){return f(o).slice(u,l)}function qi(o,u,l){return f(o).substr(u,l)}function Ki(o,u,l){return f(o).substring(u,l)}function Xi(o){return f(o).length}function ki(o){return f(o).replace(k,"*").replace(de,"*").length}function Zi(o,u){var l=f(o),p=f(u),v=p.length,A=0,$=0;if(l===""||p==="")return A;do $=l.indexOf(p,$),$!==-1&&(A++,$+=v);while($!==-1);return A}var Ji=Array.prototype.reduce;function Qi(o,u,l){var p=f(o);if(p===""||typeof u!="function")return 0;var v=u.bind(l);return Ji.call(p,function(A,$,te){return v($,te,p)?A+1:A},0)}function es(o,u,l){return se(o,u,l).length}function Dt(){this.index=0}Dt.prototype.increment=function(){this.index++},Dt.prototype.incrementOnEmptyPosition=function(o){y(o)&&this.increment()},Dt.prototype.getIndexByPosition=function(o){return y(o)?this.index:o-1};var ts="i",Xn="b",kn="c",ns="d",Zn="o",rs="u",Jn="x",Qn="X",er="e",tr="E",nr="f",rr="g",nn="G",is="s",ss="'",ir="+",os="-",as="%%",us=2,cs=8,sr=16;function or(o,u){for(var l=f(o),p=y(u)?1:I(M(u),0,j),v="";p;)p&1&&(v+=l),p>1&&(l+=l),p>>=1;return v}function Tt(o,u){var l=M(u/o.length),p=u%o.length;return or(o,l+p).substr(0,u)}function ar(o,u,l){var p=f(o),v=y(u)?0:I(M(u),0,j),A=f(l," ");return v<=p.length?p:Tt(A,v-p.length)+p}function ur(o,u,l){var p=f(o),v=y(u)?0:I(M(u),0,j),A=f(l," ");return v<=p.length?p:p+Tt(A,v-p.length)}function ls(o,u){var l=u.width;if(y(l)||o.length>=l)return o;var p=u.alignmentSpecifier===os?ur:ar;return p(o,l,u.getPaddingCharacter())}function cr(o,u,l){return l.signSpecifier===ir&&o>=0&&(u=ir+u),u}function fs(o,u){var l=parseFloat(o),p;isNaN(l)&&(l=0);var v=qe(u.precision,6);switch(u.typeSpecifier){case nr:p=l.toFixed(v);break;case er:p=l.toExponential(v);break;case tr:p=l.toExponential(v).toUpperCase();break;case rr:case nn:p=hs(l,v,u);break}return p=cr(l,p,u),f(p)}function hs(o,u,l){if(o===0)return"0";var p=u===0?1:u,v=o.toPrecision(p).replace(pe,"");return l.typeSpecifier===nn&&(v=v.toUpperCase()),v}function ds(o,u){var l=parseInt(o);switch(isNaN(l)&&(l=0),l=l>>>0,u.typeSpecifier){case kn:l=String.fromCharCode(l);break;case Xn:l=l.toString(us);break;case Zn:l=l.toString(cs);break;case Jn:l=l.toString(sr);break;case Qn:l=l.toString(sr).toUpperCase();break}return f(l)}function ps(o,u){var l=parseInt(o);return isNaN(l)&&(l=0),cr(l,Y(l),u)}function gs(o,u){var l=o,p=u.precision;return!y(p)&&l.length>p&&(l=me(l,p,"")),l}function ms(o,u){var l;switch(u.typeSpecifier){case is:l=gs;break;case ns:case ts:l=ps;break;case kn:case Xn:case Zn:case Jn:case Qn:case rs:l=ds;break;case nr:case er:case tr:case rr:case nn:l=fs;break}var p=l(o,u);return ls(p,u)}function rn(o){this.percent=o.percent,this.signSpecifier=o.signSpecifier,this.paddingSpecifier=o.paddingSpecifier,this.alignmentSpecifier=o.alignmentSpecifier,this.width=o.width,this.precision=o.precision,this.typeSpecifier=o.typeSpecifier}rn.prototype.isPercentLiteral=function(){return as===this.percent},rn.prototype.getPaddingCharacter=function(){var o=re(this.paddingSpecifier," ");return o.length===2&&o[0]===ss&&(o=o[1]),o};function bs(o,u,l){if(y(l.typeSpecifier))throw new Error("sprintf(): Unknown type specifier");if(o>u-1)throw new Error("sprintf(): Too few arguments");if(o<0)throw new Error("sprintf(): Argument number must be greater than zero")}function ws(o,u,l,p,v,A,$,te,Z,be,J){var oe=new rn({percent:p,signSpecifier:A,paddingSpecifier:$,alignmentSpecifier:te,width:qe(Z,null),precision:qe(be,null),typeSpecifier:J});if(oe.isPercentLiteral())return l.slice(1);var ae=o.getIndexByPosition(v);return o.incrementOnEmptyPosition(v),bs(ae,u.length,oe),ms(u[ae],oe)}function lr(o){var u=f(o);if(u==="")return u;for(var l=arguments.length,p=new Array(l>1?l-1:0),v=1;v<l;v++)p[v-1]=arguments[v];var A=ws.bind(void 0,new Dt,p);return u.replace(ee,A)}function xs(o,u){return lr.apply(void 0,[o].concat(t(re(u,[]))))}var ys={"<":"<",">":">","&":"&",'"':""","'":"'","`":"`"};function Es(o){return ys[o]}function vs(o){return f(o).replace(H,Es)}function Os(o){return f(o).replace(P,"\\$&")}var fr={"<":/(<)|(�*3c;)|(�*60;)/gi,">":/(>)|(�*3e;)|(�*62;)/gi,"&":/(&)|(�*26;)|(�*38;)/gi,'"':/(")|(�*22;)|(�*34;)/gi,"'":/(�*27;)|(�*39;)/gi,"`":/(�*60;)|(�*96;)/gi},_s=Object.keys(fr);function Ss(o,u){return o.replace(fr[u],u)}function Cs(o){var u=f(o);return _s.reduce(Ss,u)}function As(o,u,l){var p=f(o);return p.indexOf(u,l)}function js(o,u,l){var p=f(o);return p.lastIndexOf(u,l)}function Ps(o,u,l){var p=f(o),v=y(l)?0:I(M(l),0,p.length),A=p.substr(v).search(u);return A!==-1&&!isNaN(v)&&(A+=v),A}function Is(o,u,l){var p=f(o),v=f(u),A=qe(l);return A<0||A>p.length||v===""?p:p.slice(0,A)+v+p.slice(A)}var hr={3:"\u039E\u03BE",8:"\u0398\u03B8",A:"A\xC0\xC1\xC2\xC3\xC4\xC5\u0100\u0102\u0104\u01CD\u01DE\u01E0\u01FA\u0200\u0202\u0226\u023A\u0386\u0391\u0410",B:"B\u0181\u0182\u0243\u0392\u0411",C:"C\xC7\u0106\u0108\u010A\u010C\u0187\u023B\u0426",D:"D\u010E\u0110\u0189\u018A\u018B\xD0\u0394\u0414",E:"E\xC8\xC9\xCA\xCB\u0112\u0114\u0116\u0118\u011A\u018E\u0190\u0204\u0206\u0228\u0388\u0395\u0415\u042D",F:"F\u0191\u03A6\u0424",G:"G\u011C\u011E\u0120\u0122\u0193\u01E4\u01E6\u01F4\u0393\u0413\u0490",H:"H\u0124\u0126\u021E\u0389\u0397\u0425",I:"I\xCC\xCD\xCE\xCF\u0128\u012A\u012C\u012E\u0130\u0197\u01CF\u0208\u020A\u038A\u0399\u03AA\u0406\u0418",J:"J\u0134\u0248\u0419",K:"K\u0136\u0198\u01E8\u039A\u041A",L:"L\u0139\u013B\u013D\u013F\u0141\u023D\u039B\u041B",M:"M\u019C\u039C\u041C",N:"N\xD1\u0143\u0145\u0147\u019D\u01F8\u0220\u039D\u041D",O:"O\xD2\xD3\xD4\xD5\xD6\xD8\u014C\u014E\u0150\u0186\u019F\u01A0\u01D1\u01EA\u01EC\u01FE\u020C\u020E\u022A\u022C\u022E\u0230\u038C\u039F\u041E",P:"P\u01A4\u03A0\u041F",Q:"Q\u024A",R:"R\u0154\u0156\u0158\u0210\u0212\u024C\u03A1\u0420",S:"S\u015A\u015C\u015E\u0160\u0218\u03A3\u0421",T:"T\u0162\u0164\u0166\u01AC\u01AE\u021A\u023E\u03A4\u0422",U:"U\xD9\xDA\xDB\xDC\u0168\u016A\u016C\u016E\u0170\u0172\u01AF\u01D3\u01D5\u01D7\u01D9\u01DB\u0214\u0216\u0244\u0423\u042A",V:"V\u01B2\u0245\u0412",W:"W\u0174\u038F\u03A9",X:"X\u03A7",Y:"Y\xDD\u0176\u0178\u01B3\u0232\u024E\u038E\u03A5\u03AB\u042B",Z:"Z\u0179\u017B\u017D\u01B5\u0224\u0396\u0417",a:"a\xE0\xE1\xE2\xE3\xE4\xE5\u0101\u0103\u0105\u01CE\u01DF\u01E1\u01FB\u0201\u0203\u0227\u0250\u03AC\u03B1\u0430",b:"b\u0180\u0183\u0253\u03B2\u0431",c:"c\xE7\u0107\u0109\u010B\u010D\u0188\u023C\u0446",d:"d\u010F\u0111\u018C\u0256\u0257\xF0\u03B4\u0434",e:"e\xE8\xE9\xEA\xEB\u0113\u0115\u0117\u0119\u011B\u01DD\u0205\u0207\u0229\u0247\u025B\u03AD\u03B5\u0435\u044D",f:"f\u0192\u03C6\u0444",g:"g\u011D\u011F\u0121\u0123\u01E5\u01E7\u01F5\u0260\u03B3\u0433\u0491",h:"h\u0125\u0127\u021F\u0265\u03AE\u03B7\u0445",i:"i\xEC\xED\xEE\xEF\u0129\u012B\u012D\u012F\u0131\u01D0\u0209\u020B\u0268\u0390\u03AF\u03B9\u03CA\u0438\u0456",j:"j\u0135\u01F0\u0249\u0439",k:"k\u0137\u0199\u01E9\u03BA\u043A",l:"l\u013A\u013C\u013E\u0140\u0142\u017F\u019A\u026B\u03BB\u043B",m:"m\u026F\u0271\u03BC\u043C",n:"n\xF1\u0144\u0146\u0148\u0149\u019E\u01F9\u0272\u03BD\u043D",o:"o\xF2\xF3\xF4\xF5\xF6\xF8\u014D\u014F\u0151\u01A1\u01D2\u01EB\u01ED\u01FF\u020D\u020F\u022B\u022D\u022F\u0231\u0254\u0275\u03BF\u03CC\u043E",p:"p\u01A5\u03C0\u043F",q:"q\u024B",r:"r\u0155\u0157\u0159\u0211\u0213\u024D\u027D\u03C1\u0440",s:"s\xDF\u015B\u015D\u015F\u0161\u0219\u023F\u03C2\u03C3\u0441",t:"t\u0163\u0165\u0167\u01AD\u021B\u0288\u03C4\u0442",u:"u\xF9\xFA\xFB\xFC\u0169\u016B\u016D\u016F\u0171\u0173\u01B0\u01D4\u01D6\u01D8\u01DA\u01DC\u0215\u0217\u0289\u0443\u044A",v:"v\u028B\u028C\u0432",w:"w\u0175\u03C9\u03CE",x:"x\u03C7",y:"y\xFD\xFF\u0177\u01B4\u0233\u024F\u03B0\u03C5\u03CB\u03CD\u044B",z:"z\u017A\u017C\u017E\u01B6\u0225\u0240\u03B6\u0437",OE:"\x8C\u0152",oe:"\x9C\u0153",AE:"\xC6\u01E2\u01FC",ae:"\xE6\u01E3\u01FD",hv:"\u0195",OI:"\u01A2",oi:"\u01A3",DZ:"\u01C4\u01F1",Dz:"\u01C5\u01F2",dz:"\u01C6\u01F3",LJ:"\u01C7",Lj:"\u01C8",lj:"\u01C9",NJ:"\u01CA",Nj:"\u01CB",nj:"\u01CC",OU:"\u0222",ou:"\u0223",TH:"\xDE",th:"\xFE",PS:"\u03A8",ps:"\u03C8",Yo:"\u0401",Ye:"\u0404",Yi:"\u0407",Zh:"\u0416",Ch:"\u0427",Sh:"\u0428\u0429","":"\u042A\u042C\u044C",Yu:"\u042E",Ya:"\u042F",zh:"\u0436",ch:"\u0447",sh:"\u0448\u0449",yu:"\u044E",ya:"\u044F",yo:"\u0451",ye:"\u0454",yi:"\u0457"},St=null;function Fs(){return St!==null||(St={},Object.keys(hr).forEach(function(o){for(var u=hr[o],l=0;l<u.length;l++){var p=u[l];St[p]=o}})),St}function Ms(o){var u=Fs()[o];return u||o}function Rs(o,u){return u}function dr(o){var u=f(o);return u===""?"":u.replace(N,Ms).replace(k,Rs)}function Ns(o,u,l){var p=f(o),v=y(u)?0:I(M(u),0,j),A=f(l," ");if(v<=p.length)return p;var $=v-p.length,te=M($/2),Z=$%2;return Tt(A,te)+p+Tt(A,te+Z)}function Ds(o,u,l){var p=f(o);return p.replace(u,l)}function pr(o,u,l){var p=f(o);if(u instanceof RegExp){if(u.flags.indexOf("g")===-1)throw new TypeError("search argument is a non-global regular expression");return p.replace(u,l)}var v=f(u),A=typeof l=="function";A||(l=f(l));var $=v.length;if($===0)return pr(o,/(?:)/g,l);for(var te=$>1?$:1,Z=[],be=p.indexOf(v,0);be!==-1;)Z.push(be),be=p.indexOf(v,be+te);for(var J=0,oe="",ae=0;ae<Z.length;ae++){var Ee=Z[ae],Se=l;A&&(Se=f(l.call(void 0,v,Ee,p))),oe+=p.slice(J,Ee)+Se,J=Ee+$}return J<p.length&&(oe+=p.slice(J)),oe}function Ts(o){var u=f(o);return u.split("").reverse().join("")}function gr(o){var u=f(o);u=u.replace(k,function(v,A,$){return gr($)+A}).replace(de,"$2$1");for(var l="",p=u.length;p--;)l+=u.charAt(p);return l}function $s(o){var u=f(o);if(u==="")return"";var l=dr(u).replace(N,"-");return tt(l)}function Ls(o,u,l,p){var v=f(o),A=f(p),$=qe(u);$<0?($=v.length+$,$<0&&($=0)):$>v.length&&($=v.length);var te=qe(l,v.length-$);return te<0&&(te=0),v.slice(0,$)+A+v.slice($+te)}function Ws(o,u,l){var p=f(o),v,A;if(w(u)&&w(l))v=u.split(""),A=l.split("");else{var $=Us(re(u,{})),te=e($,2);v=te[0],A=te[1]}var Z=v.length;if(Z===0)return p;for(var be="",J=A.length,oe=0;oe<p.length;oe++){for(var ae=!1,Ee=void 0,Se=0;Se<Z&&Se<J;Se++){var Ce=v[Se];if(p.substr(oe,Ce.length)===Ce){ae=!0,Ee=A[Se],oe=oe+Ce.length-1;break}}be+=ae?Ee:p[oe]}return be}function Us(o){var u=Object.keys(o),l=u.sort(Bs).map(function(p){return o[p]});return[u,l]}function Bs(o,u){return o.length===u.length?0:o.length<u.length?1:-1}function sn(o,u,l){var p=f(o),v=Y(u);return v===null?!1:v===""?!0:(l=y(l)?0:I(M(l),0,p.length),p.indexOf(v,l)!==-1)}var Gs=Array.prototype.reduce;function mr(o,u){var l=f(o);if(u===""||l==="")return l;var p=Y(u);if(y(p))return l.replace(Ue,"");var v=!0;return Gs.call(l,function(A,$){return v&&sn(p,$)?A:(v=!1,A+$)},"")}var zs=Array.prototype.reduceRight;function br(o,u){var l=f(o);if(u===""||l==="")return l;var p=Y(u);if(y(p))return l.replace(q,"");var v=!0;return zs.call(l,function(A,$){return v&&sn(p,$)?A:(v=!1,$+A)},"")}function Hs(o,u){var l=f(o);if(u===""||l==="")return l;var p=Y(u);return y(p)?l.trim():br(mr(l,p),p)}var Ys="width",Vs="newLine",qs="indent",Ks="cut";function Xs(o){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=f(o),p=ks(u),v=p.width,A=p.newLine,$=p.indent,te=p.cut;if(l===""||v<=0)return $;for(var Z=l.length,be=l.substring.bind(l),J=0,oe="";Z-J>v;){if(l[J]===" "){J++;continue}var ae=l.lastIndexOf(" ",v+J);ae>=J?(oe+=$+be(J,ae)+A,J=ae+1):te?(oe+=$+be(J,v+J)+A,J+=v):(ae=l.indexOf(" ",v+J),ae>=0?(oe+=$+be(J,ae)+A,J=ae+1):(oe+=$+be(J),J=Z))}return J<Z&&(oe+=$+be(J)),oe}function ks(o){return{width:qe(o[Ys],75),newLine:f(o[Vs],`
|
|
3
|
+
`),indent:f(o[qs],""),cut:E(o[Ks],!1)}}function Zs(o,u,l){if(y(u))return!1;var p=f(o),v=f(u);if(v==="")return!0;l=y(l)?p.length:I(M(l),0,p.length),l-=v.length;var A=p.indexOf(v,l);return A!==-1&&A===l}function on(o){var u=f(o);return _t.test(u)}function Js(o){var u=f(o);return U.test(u)}function Qs(o){var u=f(o);return u.trim().length===0}function eo(o){var u=f(o);return R.test(u)}function to(o){var u=f(o);return u.length===0}function no(o){var u=f(o);return on(u)&&u.toLowerCase()===u}function ro(o){var u=typeof o=="object"&&!y(o)?Number(o):o;return(typeof u=="number"||typeof u=="string")&&!isNaN(u-parseFloat(u))}function io(o){var u=f(o);return on(u)&&u.toUpperCase()===u}function so(o,u,l){var p=f(o),v=f(l),A;if(!(u instanceof RegExp)){if(A=Y(u),A===null)return!1;u=new RegExp(A,v)}return u.test(p)}function oo(o,u,l){var p=f(o),v=Y(u);return v===null?!1:v===""?!0:(l=y(l)?0:I(M(l),0,p.length),p.substr(l,v.length)===v)}function ao(o){var u=f(o);return u.split("")}function uo(o){for(var u=f(o),l=u.length,p=[],v=0,A;v<l;)A=Kn(u,v),p.push(A),v+=A>65535?2:1;return p}function co(o){var u=f(o);return re(u.match(ne),[])}function lo(o,u,l){var p=f(o);return p.split(u,l)}var fo="\uFEFF";function ho(o){var u=f(o);return u===""?"":u[0]===fo?u.substring(1):u}function po(o,u,l){var p=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,v=0;p&&(v=-u.length+1);var A=o.substr(l+v,u.length);return A.toLowerCase()===u}function go(o){for(var u=[],l;(l=Q.exec(o))!==null;)u.push(l[1]);return u}var wr=0,xr=1,an=2;function mo(o){for(var u=wr,l="",p=0;u!==an;){var v=o[p++].toLowerCase();switch(v){case"<":break;case">":u=an;break;default:We.test(v)?u===xr&&(u=an):(u===wr&&(u=xr),v!=="/"&&(l+=v));break}}return l}var Ct=0,nt=1,$t=2,yr=3;function bo(o,u,l){if(o=f(o),o==="")return"";if(!Array.isArray(u)){var p=f(u);u=p===""?[]:go(p)}for(var v=f(l),A=o.length,$=u.length>0,te=po.bind(null,o),Z=Ct,be=0,J="",oe="",ae=null,Ee=0;Ee<A;Ee++){var Se=o[Ee],Ce=!1;switch(Se){case"<":if(ae)break;if(te("< ",Ee,!1)){Ce=!0;break}if(Z===Ct){Ce=!0,Z=nt;break}if(Z===nt){be++;break}Ce=!0;break;case"!":if(Z===nt&&te("<!",Ee)){Z=$t;break}Ce=!0;break;case"-":if(Z===$t&&te("!--",Ee)){Z=yr;break}Ce=!0;break;case'"':case"'":Z===nt&&(ae===Se?ae=null:ae||(ae=Se)),Ce=!0;break;case"E":case"e":if(Z===$t&&te("doctype",Ee)){Z=nt;break}Ce=!0;break;case">":if(be>0){be--;break}if(ae)break;if(Z===nt){if(ae=null,Z=Ct,$){oe+=">";var _o=mo(oe);u.indexOf(_o.toLowerCase())!==-1?J+=oe:J+=v,oe=""}else J+=v;break}if(Z===$t||Z===yr&&te("-->",Ee)){ae=null,Z=Ct,oe="";break}Ce=!0;break;default:Ce=!0}if(Ce)switch(Z){case Ct:J+=Se;break;case nt:$&&(oe+=Se);break}}return J}var mt=null;function wo(){return mt!==null||(typeof global=="object"&&global.Object===Object?mt=global:typeof self=="object"&&self.Object===Object?mt=self:mt=new Function("return this")()),mt}var un=wo(),xo=un.v;function yo(){return this===un.v&&(un.v=xo),this}var Eo="1.4.0",cn={camelCase:Ae,capitalize:_,decapitalize:je,kebabCase:tt,lowerCase:F,snakeCase:h,swapCase:C,titleCase:g,upperCase:m,count:Xi,countGraphemes:ki,countSubstrings:Zi,countWhere:Qi,countWords:es,escapeHtml:vs,escapeRegExp:Os,unescapeHtml:Cs,sprintf:lr,vprintf:xs,indexOf:As,lastIndexOf:js,search:Ps,charAt:ye,codePointAt:Kn,first:Gi,graphemeAt:zi,last:Hi,prune:Yi,slice:Vi,substr:qi,substring:Ki,truncate:me,insert:Is,latinise:dr,pad:Ns,padLeft:ar,padRight:ur,repeat:or,replace:Ds,replaceAll:pr,reverse:Ts,reverseGrapheme:gr,slugify:$s,splice:Ls,tr:Ws,trim:Hs,trimLeft:mr,trimRight:br,wordWrap:Xs,endsWith:Zs,includes:sn,isAlpha:on,isAlphaDigit:Js,isBlank:Qs,isDigit:eo,isEmpty:to,isLowerCase:no,isNumeric:ro,isString:w,isUpperCase:io,matches:so,startsWith:oo,chars:ao,codePoints:uo,graphemes:co,split:lo,words:se,stripBom:ho,stripTags:bo,noConflict:yo,version:Eo};function Pe(o,u){this._wrappedValue=o,this._explicitChain=u}Pe.prototype.value=function(){return this._wrappedValue},Pe.prototype.valueOf=function(){return this.value()},Pe.prototype.toJSON=function(){return this.value()},Pe.prototype.toString=function(){return String(this.value())},Pe.prototype.chain=function(){return new Pe(this._wrappedValue,!0)},Pe.prototype.thru=function(o){return typeof o=="function"?new Pe(o(this._wrappedValue),this._explicitChain):this},Pe.prototype._explicitChain=!0;function vo(o){return function(){for(var u=arguments.length,l=new Array(u),p=0;p<u;p++)l[p]=arguments[p];var v=o.apply(void 0,[this._wrappedValue].concat(l));return this._explicitChain||typeof v=="string"?new Pe(v,this._explicitChain):v}}Object.keys(cn).forEach(function(o){Pe.prototype[o]=vo(cn[o])});function Oo(o){return new Pe(o,!0)}function Er(o){return new Pe(o,!1)}return i(Er,cn,{chain:Oo}),Er})});var Or="2.1.0";import Cr from"node:path";import{fileURLToPath as $o}from"node:url";import No,{promises as Do}from"fs";async function ln(i,e,t){if(typeof t!="string")throw new TypeError(`Expected a string, got ${typeof t}`);try{return(await Do[i](t))[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}function fn(i,e,t){if(typeof t!="string")throw new TypeError(`Expected a string, got ${typeof t}`);try{return No[i](t)[e]()}catch(n){if(n.code==="ENOENT")return!1;throw n}}var Ja=ln.bind(null,"stat","isFile"),Qa=ln.bind(null,"stat","isDirectory"),eu=ln.bind(null,"lstat","isSymbolicLink"),_r=fn.bind(null,"statSync","isFile"),tu=fn.bind(null,"statSync","isDirectory"),nu=fn.bind(null,"lstatSync","isSymbolicLink");import To from"node:os";var Sr=To.homedir();function At(i){if(typeof i!="string")throw new TypeError(`Expected a string, got ${typeof i}`);return Sr?i.replace(/^~(?=$|\/|\\)/,Sr):i}function hn(i,e={}){let{requireFileExistence:t,validFileExtensions:n,validHostnames:r}=e;if(URL.canParse(i)){let b=new URL(i);if(b.protocol==="file:")return hn($o(b),e);if(r&&!r.includes(b.hostname))throw new Error(`Bad input URL. Only ${r.join(", ")} URLs are supported.`);return b}let s=At(i),c=Cr.normalize(s);if(t&&!_r(c))throw new Error("Input is not a file.");let d=Cr.extname(c);if(n&&!n.includes(d))throw new Error(`Bad input file name. Only ${n.join(", ")} files are supported.`);return c}import Ir from"express";import Lo from"node:net";import Wo from"node:os";var Lt=class extends Error{constructor(e){super(`${e} is locked`)}},bt={old:new Set,young:new Set},Uo=1e3*15;var jt,Bo=()=>{let i=Wo.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let t of Object.values(i))for(let n of t)e.add(n.address);return e},Ar=i=>new Promise((e,t)=>{let n=Lo.createServer();n.unref(),n.on("error",t),n.listen(i,()=>{let{port:r}=n.address();n.close(()=>{e(r)})})}),jr=async(i,e)=>{if(i.host||i.port===0)return Ar(i);for(let t of e)try{await Ar({port:i.port,host:t})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return i.port},Go=function*(i){i&&(yield*i),yield 0};async function dn(i){let e,t=new Set;if(i&&(i.port&&(e=typeof i.port=="number"?[i.port]:i.port),i.exclude)){let r=i.exclude;if(typeof r[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let s of r){if(typeof s!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(s))throw new TypeError(`Number ${s} in the exclude option is not a safe integer and can't be used`)}t=new Set(r)}jt===void 0&&(jt=setTimeout(()=>{jt=void 0,bt.old=bt.young,bt.young=new Set},Uo),jt.unref&&jt.unref());let n=Bo();for(let r of Go(e))try{if(t.has(r))continue;let s=await jr({...i,port:r},n);for(;bt.old.has(s)||bt.young.has(s);){if(r!==0)throw new Lt(r);s=await jr({...i,port:r},n)}return bt.young.add(s),s}catch(s){if(!["EADDRINUSE","EACCES"].includes(s.code)&&!(s instanceof Lt))throw s}throw new Error("No available ports found")}import Rr from"node:fs/promises";import Nr from"node:os";import wt from"node:path";import{dirname as zo}from"node:path";import{fileURLToPath as Ho}from"node:url";import Yo from"puppeteer";var mn=Mo(Pr(),1),Vo={darkMode:!1,format:"svg",frames:!1,output:"./",transparent:!1,verbose:!1};async function Dr(i,e){let t={...Vo,...Zo(e??{})},{darkMode:n,format:r,frames:s,output:c,transparent:d,verbose:b}=t;b&&console.time("Export time");let y=hn(i,{requireFileExistence:!0,validFileExtensions:[".tldr"],validHostnames:["www.tldraw.com"]}),E=typeof y=="string";b&&console.log(E?"Local file detected":"tldraw URL detected");let w=E?wt.basename(y,wt.extname(y)):y.pathname.split("/").pop()??y.pathname,f=0,_;if(E){b&&console.log("Starting tldraw server...");let de=zo(Ho(import.meta.url)),ne=wt.join(de,de.endsWith("/src/lib")?"../../dist/tldraw":de.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");b&&console.log(`tldraw served from "${ne}"`),_=await Ko(ne),f=_.address().port,b&&console.log(`tldraw hosted at "http://localhost:${f}"`)}b&&console.log("Starting Puppeteer...");let F=await Yo.launch({args:E?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),S=await F.newPage();qo(S,b);let x=await S.target().createCDPSession();if(await x.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:Nr.tmpdir(),eventsEnabled:!0}),E){await S.setRequestInterception(!0),S.on("request",ne=>{ne.url().endsWith("favicon.ico")?ne.respond({status:200}):ne.continue()}),b&&console.log(`Loading tldr file "${y}"`);let de=await Rr.readFile(y,"utf8");await S.evaluateOnNewDocument(ne=>{localStorage.clear(),localStorage.setItem("tldrData",ne)},de)}let B=E?`http://localhost:${f}`:y.href;b&&console.log(`Navigating to: ${B}`),await S.goto(B,{waitUntil:"networkidle0"});let G=await S.evaluate("editor.getCurrentPageShapes().length");if(b&&console.log(`Shape count: ${G}`),G===0)throw new Error("The sketch is empty");b&&console.log(`Setting background transparency: ${d}`),await ea(S,d),b&&console.log(`Setting dark mode: ${n}`);let X=await Qo(S);await Mr(S,n);let K=[],k=s?await S.evaluate(`editor.getCurrentPageShapes().reduce((accumulator, shape) => {
|
|
4
|
+
if (shape.type === 'frame') {
|
|
5
|
+
accumulator.push({ id: shape.id, name: shape.props.name })
|
|
6
|
+
}
|
|
7
|
+
return accumulator
|
|
8
|
+
}, [])`):[];if(s&&k.length===0&&console.warn("No frames found in the sketch, exporting entire page instead."),s&&k.length>0){let de=!1,ne=[];if(typeof s=="boolean")ne=k;else if(Array.isArray(s))for(let q of s){let R=k.find(P=>P.name===q)??k.find(P=>P.id===(q.startsWith("shape:")?q:`shape:${q}`));if(!R)throw new Error(`No frame found matching: "${q}"`);ne.push(R)}if(ne.length===0)throw new Error("No frames found matching the specified frames");let We=ne.map(q=>(0,mn.slugify)(q.name)),Ue=[...new Set(We)];de=We.length!==Ue.length,b&&de&&console.warn("Frame names are not unique, including frame IDs in the output filenames to avoid collisions");for(let q of ne){b&&console.log(`Downloading sketch frame: "${q.name}"`),await S.evaluate("editor.selectNone()"),await S.evaluate(`editor.select('${q.id}')`);let R=(de?`-${q.id.replace("shape:","")}`:"")+`-${(0,mn.slugify)(q.name)}`,P=await Fr(S,x,c,w+R,r);b&&console.log(`Download complete, saved to: "${P}"`),K.push(P)}}else b&&console.log("Downloading sketch"),K=await Fr(S,x,c,w,r),b&&console.log(`Download complete, saved to: "${K}"`);return b&&console.log(`Restoring dark mode: ${X}`),await Mr(S,X),await F.close(),b&&console.log("Stopped Puppeteer"),E&&_&&(_.close(),b&&console.log("Stopped tldraw server")),b&&console.timeEnd("Export time"),K}async function Fr(i,e,t,n,r){let s=Xo(e);await Jo(i),await ko(i,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${r}`]);let c=await s;await i.waitForNetworkIdle();let d=wt.join(Nr.tmpdir(),c),b=wt.resolve(At(wt.join(t,`${n}.${r}`)));return await Rr.rename(d,b),b}function qo(i,e){i.on("console",t=>{let n=t.type(),r=t.text();n==="error"?console.error(`[Browser] ${r}`):n==="warning"?console.warn(`[Browser] ${r}`):e&&console.log(`[Browser] ${r}`)})}async function Ko(i){let e=Ir(),t=await dn();return e.use(Ir.static(i)),new Promise((n,r)=>{let s=e.listen(t,()=>{n(s)});s.on("error",c=>{r(c)})})}async function Xo(i){return new Promise((e,t)=>{i.on("Browser.downloadProgress",n=>{n.state==="completed"?e(n.guid):n.state==="canceled"&&t(new Error("Download was canceled"))})})}async function ko(i,e){for(let t of e)await i.waitForSelector(`[data-testid="${t}"]`),await i.click(`[data-testid="${t}"]`)}function Zo(i){return Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0))}async function Jo(i){await i.evaluate("app.clearOpenMenus()")}async function Qo(i){return!!await i.evaluate("editor.user.getUserPreferences().isDarkMode")}async function Mr(i,e){await i.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${e}})`)}async function ea(i,e){await i.evaluate(`editor.updateInstanceState(
|
|
9
|
+
{ exportBackground: ${!e} },
|
|
4
10
|
{ ephemeral: true },
|
|
5
|
-
)`)}import{notStrictEqual as
|
|
6
|
-
`).map(
|
|
7
|
-
`)}rowToString(t
|
|
8
|
-
`):
|
|
9
|
-
`),
|
|
10
|
-
`),i+=s.charAt(r);return e&&n&&(i=`${e}${i}${n}`),i}function We(s){return Cn(s,{stringWidth:t=>[...t].length,stripAnsi:Le,wrap:En})}import{dirname as jn,resolve as An}from"path";import{readdirSync as Zi,statSync as Xi}from"fs";function Pn(s,t){let e=An(".",s),n;for(Xi(e).isDirectory()||(e=jn(e));;){if(n=t(e,Zi(e)),n)return An(e,n);if(e=jn(n=e),n===e)break}}import{inspect as gs}from"util";import{readFileSync as bs}from"fs";import{fileURLToPath as ws}from"url";import{format as es}from"util";import{normalize as ns,resolve as is}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 me(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 ge(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 Sn(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,be=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=Sn(t),r=typeof t=="string",a=ki(Object.assign(Object.create(null),n.alias)),l=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,h=l["populate--"],g=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:[]},W=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,R=new RegExp("^--"+l["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(c){let u=typeof c=="object"?c.key:c,O=Object.keys(c).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(c){d.bools[c]=!0,d.keys.push(c)}),[].concat(n.string||[]).filter(Boolean).forEach(function(c){d.strings[c]=!0,d.keys.push(c)}),[].concat(n.number||[]).filter(Boolean).forEach(function(c){d.numbers[c]=!0,d.keys.push(c)}),[].concat(n.count||[]).filter(Boolean).forEach(function(c){d.counts[c]=!0,d.keys.push(c)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(c){d.normalize[c]=!0,d.keys.push(c)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([c,u])=>{typeof u=="number"&&(d.nargs[c]=u,d.keys.push(c))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([c,u])=>{typeof u=="function"&&(d.coercions[c]=u,d.keys.push(c))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(c){d.configs[c]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([c,u])=>{(typeof u=="boolean"||typeof u=="function")&&(d.configs[c]=u)})),Nt(n.key,a,n.default,d.arrays),Object.keys(m).forEach(function(c){(d.aliases[c]||[]).forEach(function(u){m[u]=m[c]})});let Y=null;ue();let U=[],T=Object.assign(Object.create(null),{_:[]}),rt={};for(let c=0;c<i.length;c++){let u=i[c],O=u.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(u!=="--"&&/^-/.test(u)&&J(u))bt(u);else if(O.match(/^---+(=|$)/)){bt(u);continue}else if(u.match(/^--.+=/)||!l["short-option-groups"]&&u.match(/^-.+=/))x=u.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(F(x[1],d.arrays)?c=Ft(c,x[1],i,x[2]):F(x[1],d.nargs)!==!1?c=Qt(c,x[1],i,x[2]):q(x[1],x[2],!0));else if(u.match(R)&&l["boolean-negation"])x=u.match(R),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],q(f,F(f,d.arrays)?[!1]:!1));else if(u.match(/^--.+/)||!l["short-option-groups"]&&u.match(/^-[^-]+/))x=u.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],F(f,d.arrays)?c=Ft(c,f,i):F(f,d.nargs)!==!1?c=Qt(c,f,i):($=i[c+1],$!==void 0&&(!$.match(/^-/)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(q(f,$),c++):q(f,Z(f))));else if(u.match(/^-.\..+=/))x=u.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&q(x[1],x[2]);else if(u.match(/^-.\..+/)&&!u.match(W))$=i[c+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)?(q(f,$),c++):q(f,Z(f)));else if(u.match(/^-[^-]+/)&&!u.match(W)){S=u.slice(1,-1).split(""),b=!1;for(let ot=0;ot<S.length;ot++){if($=u.slice(ot+2),S[ot+1]&&S[ot+1]==="="){it=u.slice(ot+3),f=S[ot],F(f,d.arrays)?c=Ft(c,f,i,it):F(f,d.nargs)!==!1?c=Qt(c,f,i,it):q(f,it),b=!0;break}if($==="-"){q(S[ot],$);continue}if(/[A-Za-z]/.test(S[ot])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&F($,d.bools)===!1){q(S[ot],$),b=!0;break}if(S[ot+1]&&S[ot+1].match(/\W/)){q(S[ot],$),b=!0;break}else q(S[ot],Z(S[ot]))}f=u.slice(-1)[0],!b&&f!=="-"&&(F(f,d.arrays)?c=Ft(c,f,i):F(f,d.nargs)!==!1?c=Qt(c,f,i):($=i[c+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(W))&&!F(f,d.bools)&&!F(f,d.counts)||/^(true|false)$/.test($)?(q(f,$),c++):q(f,Z(f))))}else if(u.match(/^-[0-9]$/)&&u.match(W)&&F(u.slice(1),d.bools))f=u.slice(1),q(f,Z(f));else if(u==="--"){U=i.slice(c+1);break}else if(l["halt-at-non-option"]){U=i.slice(c);break}else bt(u)}H(T,!0),H(T,!1),L(T),et(),Q(T,d.aliases,m,!0),nt(T),l["set-placeholder-key"]&&Dt(T),Object.keys(d.counts).forEach(function(c){Et(T,c.split("."))||q(c,0)}),h&&U.length&&(T[g]=[]),U.forEach(function(c){T[g].push(c)}),l["camel-case-expansion"]&&l["strip-dashed"]&&Object.keys(T).filter(c=>c!=="--"&&c.includes("-")).forEach(c=>{delete T[c]}),l["strip-aliased"]&&[].concat(...Object.keys(a).map(c=>a[c])).forEach(c=>{l["camel-case-expansion"]&&c.includes("-")&&delete T[c.split(".").map(u=>Lt(u)).join(".")],delete T[c]});function bt(c){let u=P("_",c);(typeof u=="string"||typeof u=="number")&&T._.push(u)}function Qt(c,u,O,b){let f,S=F(u,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return yt(b)||(Y=Error(_("Argument unexpected for: %s",u))),q(u,Z(u)),c;let x=yt(b)?0:1;if(l["nargs-eats-options"])O.length-(c+1)+x<S&&(Y=Error(_("Not enough arguments following: %s",u))),x=S;else{for(f=c+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",u)))}let $=Math.min(x,S);for(!yt(b)&&$>0&&(q(u,b),$--),f=c+1;f<$+c+1;f++)q(u,O[f]);return c+$}function Ft(c,u,O,b){let f=[],S=b||O[c+1],x=F(u,d.nargs);if(F(u,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(yt(S)||yt(b)&&/^-/.test(S)&&!W.test(S)&&!J(S)){if(m[u]!==void 0){let $=m[u];f=Array.isArray($)?$:[$]}}else{yt(b)||f.push(C(u,b,!0));for(let $=c+1;$<O.length&&!(!l["greedy-arrays"]&&f.length>0||x&&typeof x=="number"&&f.length>=x||(S=O[$],/^-/.test(S)&&!W.test(S)&&!J(S)));$++)c=$,f.push(C(u,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(Y=Error(_("Not enough arguments following: %s",u))),q(u,f),c}function q(c,u,O=r){if(/-/.test(c)&&l["camel-case-expansion"]){let S=c.split(".").map(function(x){return Lt(x)}).join(".");M(c,S)}let b=C(c,u,O),f=c.split(".");jt(T,f,b),d.aliases[c]&&d.aliases[c].forEach(function(S){let x=S.split(".");jt(T,x,b)}),f.length>1&&l["dot-notation"]&&(d.aliases[f[0]]||[]).forEach(function(S){let x=S.split("."),$=[].concat(f);$.shift(),x=x.concat($),(d.aliases[c]||[]).includes(x.join("."))||jt(T,x,b)}),F(c,d.normalize)&&!F(c,d.arrays)&&[c].concat(d.aliases[c]||[]).forEach(function(x){Object.defineProperty(rt,x,{enumerable:!0,get(){return u},set($){u=typeof $=="string"?At.normalize($):$}})})}function M(c,u){d.aliases[c]&&d.aliases[c].length||(d.aliases[c]=[u],y[u]=!0),d.aliases[u]&&d.aliases[u].length||M(u,c)}function C(c,u,O){O&&(u=ts(u)),(F(c,d.bools)||F(c,d.counts))&&typeof u=="string"&&(u=u==="true");let b=Array.isArray(u)?u.map(function(f){return P(c,f)}):P(c,u);return F(c,d.counts)&&(yt(b)||typeof b=="boolean")&&(b=Re()),F(c,d.normalize)&&F(c,d.arrays)&&(Array.isArray(u)?b=u.map(f=>At.normalize(f)):b=At.normalize(u)),b}function P(c,u){return!l["parse-positional-numbers"]&&c==="_"||!F(c,d.strings)&&!F(c,d.bools)&&!Array.isArray(u)&&(ge(u)&&l["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${u}`)))||!yt(u)&&F(c,d.numbers))&&(u=Number(u)),u}function L(c){let u=Object.create(null);Q(u,d.aliases,m),Object.keys(d.configs).forEach(function(O){let b=c[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){Y=f;return}}else f=At.require(S);B(f)}catch(f){f.name==="PermissionDenied"?Y=f:c[O]&&(Y=Error(_("Invalid JSON config file: %s",b)))}})}function B(c,u){Object.keys(c).forEach(function(O){let b=c[O],f=u?u+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&l["dot-notation"]?B(b,f):(!Et(T,f.split("."))||F(f,d.arrays)&&l["combine-arrays"])&&q(f,b)})}function et(){typeof w<"u"&&w.forEach(function(c){B(c)})}function H(c,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)&&!Et(c,S)&&q(S.join("."),b[f])}})}function nt(c){let u,O=new Set;Object.keys(c).forEach(function(b){if(!O.has(b)&&(u=F(b,d.coercions),typeof u=="function"))try{let f=P(b,u(c[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),c[S]=f})}catch(f){Y=f}})}function Dt(c){return d.keys.forEach(u=>{~u.indexOf(".")||typeof c[u]>"u"&&(c[u]=void 0)}),c}function Q(c,u,O,b=!1){Object.keys(O).forEach(function(f){Et(c,f.split("."))||(jt(c,f.split("."),O[f]),b&&(E[f]=!0),(u[f]||[]).forEach(function(S){Et(c,S.split("."))||jt(c,S.split("."),O[f])}))})}function Et(c,u){let O=c;l["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 jt(c,u,O){let b=c;l["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(it){it=Mn(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=Mn(u[u.length-1]),S=F(u.join("."),d.arrays),x=Array.isArray(O),$=l["duplicate-arguments-array"];!$&&F(f,d.nargs)&&($=!0,(!yt(b[f])&&d.nargs[f]===1||Array.isArray(b[f])&&b[f].length===d.nargs[f])&&(b[f]=void 0)),O===Re()?b[f]=Re(b[f]):Array.isArray(b[f])?$&&S&&x?b[f]=l["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 Nt(...c){c.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)&&l["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)&&l["camel-case-expansion"]){let f=me(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(c,u){let O=[].concat(d.aliases[c]||[],c),b=Object.keys(u),f=O.find(S=>b.includes(S));return f?u[f]:!1}function Ie(c){let u=Object.keys(d);return[].concat(u.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(c):b[c]})}function v(c,...u){return[].concat(...u).some(function(b){let f=c.match(b);return f&&Ie(f[1])})}function K(c){if(c.match(W)||!c.match(/^-[^-]+/))return!1;let u=!0,O,b=c.slice(1).split("");for(let f=0;f<b.length;f++){if(O=c.slice(f+2),!Ie(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(c){return l["unknown-options-as-args"]&&z(c)}function z(c){return c=c.replace(/^-{3,}/,"--"),c.match(W)||K(c)?!1:!v(c,/^-+([^=]+?)=[\s\S]*$/,R,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(c){return!F(c,d.bools)&&!F(c,d.counts)&&`${c}`in m?m[c]:k(wt(c))}function k(c){return{[ht.BOOLEAN]:!0,[ht.STRING]:"",[ht.NUMBER]:void 0,[ht.ARRAY]:[]}[c]}function wt(c){let u=ht.BOOLEAN;return F(c,d.strings)?u=ht.STRING:F(c,d.numbers)?u=ht.NUMBER:F(c,d.bools)?u=ht.BOOLEAN:F(c,d.arrays)&&(u=ht.ARRAY),u}function yt(c){return c===void 0}function ue(){Object.keys(d.counts).find(c=>F(c,d.arrays)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",c)),!0):F(c,d.nargs)?(Y=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",c)),!0):!1)}return{aliases:Object.assign({},d.aliases),argv:Object.assign(rt,T),configuration:l,defaulted:Object.assign({},E),error:Y,newAliases:Object.assign({},y)}}};function ki(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(l){return t[r].indexOf(l)!==-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,l,m){return m.indexOf(a)===l});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Re(s){return s!==void 0?s+1:1}function Mn(s){return s==="__proto__"?"___proto___":s}function ts(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 ss}from"fs";var Ue,ze,Te,In=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,$n=(ze=(Ue=process==null?void 0:process.versions)===null||Ue===void 0?void 0:Ue.node)!==null&&ze!==void 0?ze:(Te=process==null?void 0:process.version)===null||Te===void 0?void 0:Te.slice(1);if($n&&Number($n.match(/^([^.]+)/)[1])<In)throw Error(`yargs parser supports a minimum Node.js version of ${In}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var rs=process?process.env:{},vn=new be({cwd:process.cwd,env:()=>rs,format:es,normalize:ns,resolve:is,require:s=>{if(typeof _t<"u")return _t(s);if(s.match(/\.json$/))return JSON.parse(ss(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),re=function(t,e){return vn.parse(t.slice(),e).argv};re.detailed=function(s,t){return vn.parse(s.slice(),t)};re.camelCase=Lt;re.decamelize=me;re.looksLikeNumber=ge;var He=re;import{basename as ys,dirname as Os,extname as _s,relative as Cs,resolve as Rn}from"path";function Fn(){return os()?0:1}function os(){return as()&&!process.defaultApp}function as(){return!!process.versions.electron}function Be(s){return s.slice(Fn()+1)}function Dn(){return process.argv[Fn()]}var G=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as ls,statSync as cs,writeFile as fs}from"fs";import{format as us}from"util";import{resolve as hs}from"path";var Nn={fs:{readFileSync:ls,writeFile:fs},format:us,resolve:hs,exists:s=>{try{return cs(s).isFile()}catch{return!1}}};var Ot,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(),Ot.format.apply(Ot.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 l=[a];return~a.indexOf("%d")&&l.push(i),Ot.format.apply(Ot.format,l.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),l=JSON.stringify(this.cache[i],null,2);Ot.fs.writeFile(a,l,"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{Ot.fs.readFileSync&&(t=JSON.parse(Ot.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=Ot.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){let i=Ot.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(i)&&(n=i)}return n}_fileExistsSync(t){return Ot.exists(t)}};function Ln(s,t){Ot=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 ds=s=>Ln(s,Nn),Wn=ds;var xs="require is not supported by ESM",Un="loading a directory of commands is not supported yet for ESM",oe;try{oe=ws(import.meta.url)}catch{oe=process.cwd()}var Es=oe.substring(0,oe.lastIndexOf("node_modules")),qe={assert:{notStrictEqual:ps,strictEqual:ms},cliui:We,findUp:Pn,getEnv:s=>process.env[s],inspect:gs,getCallerFile:()=>{throw new G(Un)},getProcessArgvBin:Dn,mainFilename:Es||process.cwd(),Parser:He,path:{basename:ys,dirname:Os,extname:_s,relative:Cs,resolve:Rn},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:bs,require:()=>{throw new G(xs)},requireDirectory:()=>{throw new G(Un)},stringWidth:s=>[...s].length,y18n:Wn({directory:Rn(oe,"../../../locales"),updateFiles:!1})};function at(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 V(s){return!!s&&!!s.then&&typeof s.then=="function"}function Pt(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,l)=>{let m=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&l===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 js=["first","second","third","fourth","fifth","sixth"];function j(s,t,e){function n(){return typeof s=="object"?[{demanded:[],optional:[]},s,t]:[Pt(`cmd ${s}`),t,e]}try{let i=0,[r,a,l]=n(),m=[].slice.call(a);for(;m.length&&m[m.length-1]===void 0;)m.pop();let w=l||m.length;if(w<r.demanded.length)throw new G(`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 G(`Too many arguments provided. Expected max ${p} but received ${w}.`);r.demanded.forEach(h=>{let g=m.shift(),y=zn(g);h.cmd.filter(_=>_===y||_==="*").length===0&&Tn(y,h.cmd,i),i+=1}),r.optional.forEach(h=>{if(m.length===0)return;let g=m.shift(),y=zn(g);h.cmd.filter(_=>_===y||_==="*").length===0&&Tn(y,h.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function zn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Tn(s,t,e){throw new G(`Invalid ${js[e]||"manyith"} argument. Expected ${t.join(" or ")} but received ${s}.`)}var we=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 Hn(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function Wt(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(V(i))return i.then(a=>Promise.all([a,r(a,t)])).then(([a,l])=>Object.assign(a,l));{let a=r(i,t);return V(a)?a.then(l=>Object.assign(i,l)):Object.assign(i,a)}},s)}function Rt(s,t,e=n=>{throw n}){try{let n=As(s)?s():s;return V(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function As(s){return typeof s=="function"}function Ve(s){if(typeof _t>"u")return null;for(let t=0,e=Object.keys(_t.cache),n;t<e.length;t++)if(n=_t.cache[e[t]],n.exports===s)return n;return null}var kt=/(^\*)|(^\$0)/,Ke=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,l,m)=>{let w=r(a,l,m);if(w){if(this.requireCache.has(l))return w;this.requireCache.add(l),this.addHandler(w)}return w},this.shim.requireDirectory({require:e,filename:n},t,i)}addHandler(t,e,n,i,r,a){let l=[],m=Hn(r);if(i=i||(()=>{}),Array.isArray(t))if(Ps(t))[t,...l]=t;else for(let w of t)this.addHandler(w);else if(Ms(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(Bn(n)){this.addHandler([t].concat(l),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){let w=Pt(t);l=l.map(g=>Pt(g).cmd);let p=!1,h=[w.cmd].concat(l).filter(g=>kt.test(g)?(p=!0,!1):!0);h.length===0&&p&&h.push("$0"),p&&(w.cmd=h[0],l=h.slice(1),t=t.replace(kt,w.cmd)),l.forEach(g=>{this.aliasMap[g]=w.cmd}),e!==!1&&this.usage.command(t,e,p,l,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 l=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(l.original));let h=this.applyBuilderUpdateUsageAndParse(p,l,e,n.aliases,w,i,r,a);return V(h)?h.then(g=>this.applyMiddlewareAndGetResult(p,l,g.innerArgv,m,r,g.aliases,e)):this.applyMiddlewareAndGetResult(p,l,h.innerArgv,m,r,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,l,m){let w=e.builder,p=n;if(ye(w)){n.getInternalMethods().getUsageInstance().freeze();let h=w(n.getInternalMethods().reset(i),m);if(V(h))return h.then(g=>(p=qn(g)?g:n,this.parseAndUpdateUsage(t,e,p,r,a,l)))}else Ss(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,l)}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 l=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return V(l)?l.then(m=>({aliases:n.parsed.aliases,innerArgv:m})):{aliases:n.parsed.aliases,innerArgv:l}}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,l,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=Wt(n,a,l,!1),n=Rt(n,p=>{let h=e.handler(p);return V(h)?h.then(()=>p):p}),t||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),V(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,l){let m={};if(r)return n;l.getInternalMethods().getHasOutput()||(m=this.populatePositionals(e,n,i,l));let w=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),p=Wt(n,l,w,!0);return V(p)?p.then(h=>this.handleValidationAndGetResult(t,e,h,i,a,l,w,m)):this.handleValidationAndGetResult(t,e,p,i,a,l,w,m)}populatePositionals(t,e,n,i){e._=e._.slice(n.commands.length);let r=t.demanded.slice(0),a=t.optional.slice(0),l={};for(this.validation.positionalCount(r.length,e._.length);r.length;){let m=r.shift();this.populatePositional(m,e,l)}for(;a.length;){let m=a.shift();this.populatePositional(m,e,l)}return e._=n.commands.concat(e._.map(m=>""+m)),this.postProcessPositionals(e,l,this.cmdToParseOptions(t.original),i),l}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=Pt(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 l=Object.assign({},r.configuration,{"populate--":!1}),m=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:l}));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(ye(e))return e(t,!0);Bn(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;at(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();at(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 Yn(s,t,e,n){return new Ke(s,t,e,n)}function Bn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function Ps(s){return s.every(t=>typeof t=="string")}function ye(s){return typeof s=="function"}function Ss(s){return typeof s=="object"}function Ms(s){return typeof s=="object"&&!Array.isArray(s)}function St(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 Is(s){return typeof s=="boolean"}function Vn(s,t){let e=t.y18n.__,n={},i=[];n.failFn=function(C){i.push(C)};let r=null,a=null,l=!0;n.showHelpOnFail=function(C=!0,P){let[L,B]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=B),r=B,l=L,n};let m=!1;n.fail=function(C,P){let L=s.getInternalMethods().getLoggerInstance();if(i.length)for(let B=i.length-1;B>=0;--B){let et=i[B];if(Is(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&Mt(!0),!m){m=!0,l&&(s.showHelp("error"),L.error()),(C||P)&&L.error(C||P);let B=r||a;B&&((C||P)&&L.error(""),L.error(B))}if(P=P||new G(C),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,P);throw P}};let w=[],p=!1;n.usage=(M,C)=>M===null?(p=!0,w=[],n):(p=!1,w.push([M,C||""]),n),n.getUsage=()=>w,n.getUsageDisabled=()=>p,n.getPositionalGroupName=()=>e("Positionals:");let h=[];n.example=(M,C)=>{h.push([M,C||""])};let g=[];n.command=function(C,P,L,B,et=!1){L&&(g=g.map(H=>(H[2]=!1,H))),g.push([C,P||"",L,B,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=M=>{E.push(M)};let _=!1,d;n.wrap=M=>{_=!0,d=M},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Qt(),_=!0),d);let W="__yargsString__:";n.deferY18nLookup=M=>W+M,n.help=function(){if(U)return U;Y();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),L=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(L)),nt=nt.concat(Object.keys(H.default)),nt=nt.filter(rt),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")}>
|
|
11
|
-
`:
|
|
12
|
-
`,
|
|
13
|
-
`);
|
|
14
|
-
`)}return
|
|
11
|
+
)`)}import{notStrictEqual as Sa,strictEqual as Ca}from"assert";var ta={right:oa,center:aa},na=0,Wt=1,ra=2,Ut=3,bn=class{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]=="string")return this.applyLayoutDSL(e[0]);let t=e.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]=="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
12
|
+
`).map(r=>r.split(" ")),n=0;return t.forEach(r=>{r.length>1&&Ie.stringWidth(r[0])>n&&(n=Math.min(Math.floor(this.width*.5),Ie.stringWidth(r[0])))}),t.forEach(r=>{this.div(...r.map((s,c)=>({text:s.trim(),padding:this.measurePadding(s),width:c===0&&r.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=Ie.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach(t=>{this.rowToString(t,e)}),e.filter(t=>!t.hidden).map(t=>t.text).join(`
|
|
13
|
+
`)}rowToString(e,t){return this.rasterize(e).forEach((n,r)=>{let s="";n.forEach((c,d)=>{let{width:b}=e[d],y=this.negatePadding(e[d]),E=c;if(y>Ie.stringWidth(c)&&(E+=" ".repeat(y-Ie.stringWidth(c))),e[d].align&&e[d].align!=="left"&&this.wrap){let f=ta[e[d].align];E=f(E,y),Ie.stringWidth(E)<y&&(E+=" ".repeat((b||0)-Ie.stringWidth(E)-1))}let w=e[d].padding||[0,0,0,0];w[Ut]&&(s+=" ".repeat(w[Ut])),s+=Tr(e[d],E,"| "),s+=E,s+=Tr(e[d],E," |"),w[Wt]&&(s+=" ".repeat(w[Wt])),r===0&&t.length>0&&(s=this.renderInline(s,t[t.length-1]))}),t.push({text:s.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),r=n?n[0].length:0,s=t.text,c=Ie.stringWidth(s.trimRight());return t.span?this.wrap?r<c?e:(t.hidden=!0,s.trimRight()+" ".repeat(r-c)+e.trimLeft()):(t.hidden=!0,s+e):e}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((s,c)=>{s.width=n[c],this.wrap?r=Ie.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
|
|
14
|
+
`):r=s.text.split(`
|
|
15
|
+
`),s.border&&(r.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(s)+2)+"'")),s.padding&&(r.unshift(...new Array(s.padding[na]||0).fill("")),r.push(...new Array(s.padding[ra]||0).fill(""))),r.forEach((d,b)=>{t[b]||t.push([]);let y=t[b];for(let E=0;E<c;E++)y[E]===void 0&&y.push("");y.push(d)})}),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[Ut]||0)+(e.padding[Wt]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map(c=>c.width||Ie.stringWidth(c.text));let t=e.length,n=this.width,r=e.map(c=>{if(c.width)return t--,n-=c.width,c.width}),s=t?Math.floor(n/t):0;return r.map((c,d)=>c===void 0?Math.max(s,ia(e[d])):c)}};function Tr(i,e,t){return i.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?t:" ":""}function ia(i){let e=i.padding||[],t=1+(e[Ut]||0)+(e[Wt]||0);return i.border?t+4:t}function sa(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function oa(i,e){i=i.trim();let t=Ie.stringWidth(i);return t<e?" ".repeat(e-t)+i:i}function aa(i,e){i=i.trim();let t=Ie.stringWidth(i);return t>=e?i:" ".repeat(e-t>>1)+i}var Ie;function $r(i,e){return Ie=e,new bn({width:i?.width||sa(),wrap:i?.wrap})}var Lr=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function wn(i){return i.replace(Lr,"")}function Wr(i,e){let[t,n]=i.match(Lr)||["",""];i=wn(i);let r="";for(let s=0;s<i.length;s++)s!==0&&s%e===0&&(r+=`
|
|
16
|
+
`),r+=i.charAt(s);return t&&n&&(r=`${t}${r}${n}`),r}function xn(i){return $r(i,{stringWidth:e=>[...e].length,stripAnsi:wn,wrap:Wr})}import{dirname as Ur,resolve as Br}from"path";import{readdirSync as ua,statSync as ca}from"fs";function Gr(i,e){let t=Br(".",i),n;for(ca(t).isDirectory()||(t=Ur(t));;){if(n=e(t,ua(t)),n)return Br(t,n);if(t=Ur(n=t),n===t)break}}import{inspect as Aa}from"util";import{readFileSync as ja}from"fs";import{fileURLToPath as Pa}from"url";import{format as ha}from"util";import{normalize as da,resolve as pa}from"path";function rt(i){if(i!==i.toLowerCase()&&i!==i.toUpperCase()||(i=i.toLowerCase()),i.indexOf("-")===-1&&i.indexOf("_")===-1)return i;{let t="",n=!1,r=i.match(/^-+/);for(let s=r?r[0].length:0;s<i.length;s++){let c=i.charAt(s);n&&(n=!1,c=c.toUpperCase()),s!==0&&(c==="-"||c==="_")?n=!0:c!=="-"&&c!=="_"&&(t+=c)}return t}}function Bt(i,e){let t=i.toLowerCase();e=e||"-";let n="";for(let r=0;r<i.length;r++){let s=t.charAt(r),c=i.charAt(r);s!==c&&r>0?n+=`${e}${t.charAt(r)}`:n+=c}return n}function Gt(i){return i==null?!1:typeof i=="number"||/^0x[0-9a-f]+$/i.test(i)?!0:/^0[^.]/.test(i)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(i)}function zr(i){if(Array.isArray(i))return i.map(c=>typeof c!="string"?c+"":c);i=i.trim();let e=0,t=null,n=null,r=null,s=[];for(let c=0;c<i.length;c++){if(t=n,n=i.charAt(c),n===" "&&!r){t!==" "&&e++;continue}n===r?r=null:(n==="'"||n==='"')&&!r&&(r=n),s[e]||(s[e]=""),s[e]+=n}return s}var Ne;(function(i){i.BOOLEAN="boolean",i.STRING="string",i.NUMBER="number",i.ARRAY="array"})(Ne||(Ne={}));var Ke,zt=class{constructor(e){Ke=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),r=zr(e),s=typeof e=="string",c=la(Object.assign(Object.create(null),n.alias)),d=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),b=Object.assign(Object.create(null),n.default),y=n.configObjects||[],E=n.envPrefix,w=d["populate--"],f=w?"--":"_",_=Object.create(null),F=Object.create(null),S=n.__||Ke.format,x={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:[]},B=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,G=new RegExp("^--"+d["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(h){let m=typeof h=="object"?h.key:h,C=Object.keys(h).map(function(O){return{boolean:"bools",string:"strings",number:"numbers"}[O]}).filter(Boolean).pop();C&&(x[C][m]=!0),x.arrays[m]=!0,x.keys.push(m)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(h){x.bools[h]=!0,x.keys.push(h)}),[].concat(n.string||[]).filter(Boolean).forEach(function(h){x.strings[h]=!0,x.keys.push(h)}),[].concat(n.number||[]).filter(Boolean).forEach(function(h){x.numbers[h]=!0,x.keys.push(h)}),[].concat(n.count||[]).filter(Boolean).forEach(function(h){x.counts[h]=!0,x.keys.push(h)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(h){x.normalize[h]=!0,x.keys.push(h)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([h,m])=>{typeof m=="number"&&(x.nargs[h]=m,x.keys.push(h))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([h,m])=>{typeof m=="function"&&(x.coercions[h]=m,x.keys.push(h))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(h){x.configs[h]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([h,m])=>{(typeof m=="boolean"||typeof m=="function")&&(x.configs[h]=m)})),Be(n.key,c,n.default,x.arrays),Object.keys(b).forEach(function(h){(x.aliases[h]||[]).forEach(function(m){b[m]=b[h]})});let X=null;tt();let K=[],k=Object.assign(Object.create(null),{_:[]}),de={};for(let h=0;h<r.length;h++){let m=r[h],C=m.replace(/^-{3,}/,"---"),O,g,I,j,M,me;if(m!=="--"&&/^-/.test(m)&&re(m))ne(m);else if(C.match(/^---+(=|$)/)){ne(m);continue}else if(m.match(/^--.+=/)||!d["short-option-groups"]&&m.match(/^-.+=/))j=m.match(/^--?([^=]+)=([\s\S]*)$/),j!==null&&Array.isArray(j)&&j.length>=3&&(W(j[1],x.arrays)?h=Ue(h,j[1],r,j[2]):W(j[1],x.nargs)!==!1?h=We(h,j[1],r,j[2]):q(j[1],j[2],!0));else if(m.match(G)&&d["boolean-negation"])j=m.match(G),j!==null&&Array.isArray(j)&&j.length>=2&&(g=j[1],q(g,W(g,x.arrays)?[!1]:!1));else if(m.match(/^--.+/)||!d["short-option-groups"]&&m.match(/^-[^-]+/))j=m.match(/^--?(.+)/),j!==null&&Array.isArray(j)&&j.length>=2&&(g=j[1],W(g,x.arrays)?h=Ue(h,g,r):W(g,x.nargs)!==!1?h=We(h,g,r):(M=r[h+1],M!==void 0&&(!M.match(/^-/)||M.match(B))&&!W(g,x.bools)&&!W(g,x.counts)||/^(true|false)$/.test(M)?(q(g,M),h++):q(g,se(g))));else if(m.match(/^-.\..+=/))j=m.match(/^-([^=]+)=([\s\S]*)$/),j!==null&&Array.isArray(j)&&j.length>=3&&q(j[1],j[2]);else if(m.match(/^-.\..+/)&&!m.match(B))M=r[h+1],j=m.match(/^-(.\..+)/),j!==null&&Array.isArray(j)&&j.length>=2&&(g=j[1],M!==void 0&&!M.match(/^-/)&&!W(g,x.bools)&&!W(g,x.counts)?(q(g,M),h++):q(g,se(g)));else if(m.match(/^-[^-]+/)&&!m.match(B)){I=m.slice(1,-1).split(""),O=!1;for(let ye=0;ye<I.length;ye++){if(M=m.slice(ye+2),I[ye+1]&&I[ye+1]==="="){me=m.slice(ye+3),g=I[ye],W(g,x.arrays)?h=Ue(h,g,r,me):W(g,x.nargs)!==!1?h=We(h,g,r,me):q(g,me),O=!0;break}if(M==="-"){q(I[ye],M);continue}if(/[A-Za-z]/.test(I[ye])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(M)&&W(M,x.bools)===!1){q(I[ye],M),O=!0;break}if(I[ye+1]&&I[ye+1].match(/\W/)){q(I[ye],M),O=!0;break}else q(I[ye],se(I[ye]))}g=m.slice(-1)[0],!O&&g!=="-"&&(W(g,x.arrays)?h=Ue(h,g,r):W(g,x.nargs)!==!1?h=We(h,g,r):(M=r[h+1],M!==void 0&&(!/^(-|--)[^-]/.test(M)||M.match(B))&&!W(g,x.bools)&&!W(g,x.counts)||/^(true|false)$/.test(M)?(q(g,M),h++):q(g,se(g))))}else if(m.match(/^-[0-9]$/)&&m.match(B)&&W(m.slice(1),x.bools))g=m.slice(1),q(g,se(g));else if(m==="--"){K=r.slice(h+1);break}else if(d["halt-at-non-option"]){K=r.slice(h);break}else ne(m)}Q(k,!0),Q(k,!1),H(k),pe(),ue(k,x.aliases,b,!0),ge(k),d["set-placeholder-key"]&&Ve(k),Object.keys(x.counts).forEach(function(h){Oe(k,h.split("."))||q(h,0)}),w&&K.length&&(k[f]=[]),K.forEach(function(h){k[f].push(h)}),d["camel-case-expansion"]&&d["strip-dashed"]&&Object.keys(k).filter(h=>h!=="--"&&h.includes("-")).forEach(h=>{delete k[h]}),d["strip-aliased"]&&[].concat(...Object.keys(c).map(h=>c[h])).forEach(h=>{d["camel-case-expansion"]&&h.includes("-")&&delete k[h.split(".").map(m=>rt(m)).join(".")],delete k[h]});function ne(h){let m=N("_",h);(typeof m=="string"||typeof m=="number")&&k._.push(m)}function We(h,m,C,O){let g,I=W(m,x.nargs);if(I=typeof I!="number"||isNaN(I)?1:I,I===0)return je(O)||(X=Error(S("Argument unexpected for: %s",m))),q(m,se(m)),h;let j=je(O)?0:1;if(d["nargs-eats-options"])C.length-(h+1)+j<I&&(X=Error(S("Not enough arguments following: %s",m))),j=I;else{for(g=h+1;g<C.length&&(!C[g].match(/^-[^0-9]/)||C[g].match(B)||re(C[g]));g++)j++;j<I&&(X=Error(S("Not enough arguments following: %s",m)))}let M=Math.min(j,I);for(!je(O)&&M>0&&(q(m,O),M--),g=h+1;g<M+h+1;g++)q(m,C[g]);return h+M}function Ue(h,m,C,O){let g=[],I=O||C[h+1],j=W(m,x.nargs);if(W(m,x.bools)&&!/^(true|false)$/.test(I))g.push(!0);else if(je(I)||je(O)&&/^-/.test(I)&&!B.test(I)&&!re(I)){if(b[m]!==void 0){let M=b[m];g=Array.isArray(M)?M:[M]}}else{je(O)||g.push(P(m,O,!0));for(let M=h+1;M<C.length&&!(!d["greedy-arrays"]&&g.length>0||j&&typeof j=="number"&&g.length>=j||(I=C[M],/^-/.test(I)&&!B.test(I)&&!re(I)));M++)h=M,g.push(P(m,I,s))}return typeof j=="number"&&(j&&g.length<j||isNaN(j)&&g.length===0)&&(X=Error(S("Not enough arguments following: %s",m))),q(m,g),h}function q(h,m,C=s){if(/-/.test(h)&&d["camel-case-expansion"]){let I=h.split(".").map(function(j){return rt(j)}).join(".");R(h,I)}let O=P(h,m,C),g=h.split(".");_e(k,g,O),x.aliases[h]&&x.aliases[h].forEach(function(I){let j=I.split(".");_e(k,j,O)}),g.length>1&&d["dot-notation"]&&(x.aliases[g[0]]||[]).forEach(function(I){let j=I.split("."),M=[].concat(g);M.shift(),j=j.concat(M),(x.aliases[h]||[]).includes(j.join("."))||_e(k,j,O)}),W(h,x.normalize)&&!W(h,x.arrays)&&[h].concat(x.aliases[h]||[]).forEach(function(j){Object.defineProperty(de,j,{enumerable:!0,get(){return m},set(M){m=typeof M=="string"?Ke.normalize(M):M}})})}function R(h,m){x.aliases[h]&&x.aliases[h].length||(x.aliases[h]=[m],_[m]=!0),x.aliases[m]&&x.aliases[m].length||R(m,h)}function P(h,m,C){C&&(m=fa(m)),(W(h,x.bools)||W(h,x.counts))&&typeof m=="string"&&(m=m==="true");let O=Array.isArray(m)?m.map(function(g){return N(h,g)}):N(h,m);return W(h,x.counts)&&(je(O)||typeof O=="boolean")&&(O=yn()),W(h,x.normalize)&&W(h,x.arrays)&&(Array.isArray(m)?O=m.map(g=>Ke.normalize(g)):O=Ke.normalize(m)),O}function N(h,m){return!d["parse-positional-numbers"]&&h==="_"||!W(h,x.strings)&&!W(h,x.bools)&&!Array.isArray(m)&&(Gt(m)&&d["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${m}`)))||!je(m)&&W(h,x.numbers))&&(m=Number(m)),m}function H(h){let m=Object.create(null);ue(m,x.aliases,b),Object.keys(x.configs).forEach(function(C){let O=h[C]||m[C];if(O)try{let g=null,I=Ke.resolve(Ke.cwd(),O),j=x.configs[C];if(typeof j=="function"){try{g=j(I)}catch(M){g=M}if(g instanceof Error){X=g;return}}else g=Ke.require(I);ee(g)}catch(g){g.name==="PermissionDenied"?X=g:h[C]&&(X=Error(S("Invalid JSON config file: %s",O)))}})}function ee(h,m){Object.keys(h).forEach(function(C){let O=h[C],g=m?m+"."+C:C;typeof O=="object"&&O!==null&&!Array.isArray(O)&&d["dot-notation"]?ee(O,g):(!Oe(k,g.split("."))||W(g,x.arrays)&&d["combine-arrays"])&&q(g,O)})}function pe(){typeof y<"u"&&y.forEach(function(h){ee(h)})}function Q(h,m){if(typeof E>"u")return;let C=typeof E=="string"?E:"",O=Ke.env();Object.keys(O).forEach(function(g){if(C===""||g.lastIndexOf(C,0)===0){let I=g.split("__").map(function(j,M){return M===0&&(j=j.substring(C.length)),rt(j)});(m&&x.configs[I.join(".")]||!m)&&!Oe(h,I)&&q(I.join("."),O[g])}})}function ge(h){let m,C=new Set;Object.keys(h).forEach(function(O){if(!C.has(O)&&(m=W(O,x.coercions),typeof m=="function"))try{let g=N(O,m(h[O]));[].concat(x.aliases[O]||[],O).forEach(I=>{C.add(I),h[I]=g})}catch(g){X=g}})}function Ve(h){return x.keys.forEach(m=>{~m.indexOf(".")||typeof h[m]>"u"&&(h[m]=void 0)}),h}function ue(h,m,C,O=!1){Object.keys(C).forEach(function(g){Oe(h,g.split("."))||(_e(h,g.split("."),C[g]),O&&(F[g]=!0),(m[g]||[]).forEach(function(I){Oe(h,I.split("."))||_e(h,I.split("."),C[g])}))})}function Oe(h,m){let C=h;d["dot-notation"]||(m=[m.join(".")]),m.slice(0,-1).forEach(function(g){C=C[g]||{}});let O=m[m.length-1];return typeof C!="object"?!1:O in C}function _e(h,m,C){let O=h;d["dot-notation"]||(m=[m.join(".")]),m.slice(0,-1).forEach(function(me){me=Hr(me),typeof O=="object"&&O[me]===void 0&&(O[me]={}),typeof O[me]!="object"||Array.isArray(O[me])?(Array.isArray(O[me])?O[me].push({}):O[me]=[O[me],{}],O=O[me][O[me].length-1]):O=O[me]});let g=Hr(m[m.length-1]),I=W(m.join("."),x.arrays),j=Array.isArray(C),M=d["duplicate-arguments-array"];!M&&W(g,x.nargs)&&(M=!0,(!je(O[g])&&x.nargs[g]===1||Array.isArray(O[g])&&O[g].length===x.nargs[g])&&(O[g]=void 0)),C===yn()?O[g]=yn(O[g]):Array.isArray(O[g])?M&&I&&j?O[g]=d["flatten-duplicate-arrays"]?O[g].concat(C):(Array.isArray(O[g][0])?O[g]:[O[g]]).concat([C]):!M&&!!I==!!j?O[g]=C:O[g]=O[g].concat([C]):O[g]===void 0&&I?O[g]=j?C:[C]:M&&!(O[g]===void 0||W(g,x.counts)||W(g,x.bools))?O[g]=[O[g],C]:O[g]=C}function Be(...h){h.forEach(function(m){Object.keys(m||{}).forEach(function(C){x.aliases[C]||(x.aliases[C]=[].concat(c[C]||[]),x.aliases[C].concat(C).forEach(function(O){if(/-/.test(O)&&d["camel-case-expansion"]){let g=rt(O);g!==C&&x.aliases[C].indexOf(g)===-1&&(x.aliases[C].push(g),_[g]=!0)}}),x.aliases[C].concat(C).forEach(function(O){if(O.length>1&&/[A-Z]/.test(O)&&d["camel-case-expansion"]){let g=Bt(O,"-");g!==C&&x.aliases[C].indexOf(g)===-1&&(x.aliases[C].push(g),_[g]=!0)}}),x.aliases[C].forEach(function(O){x.aliases[O]=[C].concat(x.aliases[C].filter(function(g){return O!==g}))}))})})}function W(h,m){let C=[].concat(x.aliases[h]||[],h),O=Object.keys(m),g=C.find(I=>O.includes(I));return g?m[g]:!1}function _t(h){let m=Object.keys(x);return[].concat(m.map(O=>x[O])).some(function(O){return Array.isArray(O)?O.includes(h):O[h]})}function U(h,...m){return[].concat(...m).some(function(O){let g=h.match(O);return g&&_t(g[1])})}function ie(h){if(h.match(B)||!h.match(/^-[^-]+/))return!1;let m=!0,C,O=h.slice(1).split("");for(let g=0;g<O.length;g++){if(C=h.slice(g+2),!_t(O[g])){m=!1;break}if(O[g+1]&&O[g+1]==="="||C==="-"||/[A-Za-z]/.test(O[g])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(C)||O[g+1]&&O[g+1].match(/\W/))break}return m}function re(h){return d["unknown-options-as-args"]&&Y(h)}function Y(h){return h=h.replace(/^-{3,}/,"--"),h.match(B)||ie(h)?!1:!U(h,/^-+([^=]+?)=[\s\S]*$/,G,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function se(h){return!W(h,x.bools)&&!W(h,x.counts)&&`${h}`in b?b[h]:fe(Ae(h))}function fe(h){return{[Ne.BOOLEAN]:!0,[Ne.STRING]:"",[Ne.NUMBER]:void 0,[Ne.ARRAY]:[]}[h]}function Ae(h){let m=Ne.BOOLEAN;return W(h,x.strings)?m=Ne.STRING:W(h,x.numbers)?m=Ne.NUMBER:W(h,x.bools)?m=Ne.BOOLEAN:W(h,x.arrays)&&(m=Ne.ARRAY),m}function je(h){return h===void 0}function tt(){Object.keys(x.counts).find(h=>W(h,x.arrays)?(X=Error(S("Invalid configuration: %s, opts.count excludes opts.array.",h)),!0):W(h,x.nargs)?(X=Error(S("Invalid configuration: %s, opts.count excludes opts.narg.",h)),!0):!1)}return{aliases:Object.assign({},x.aliases),argv:Object.assign(de,k),configuration:d,defaulted:Object.assign({},F),error:X,newAliases:Object.assign({},_)}}};function la(i){let e=[],t=Object.create(null),n=!0;for(Object.keys(i).forEach(function(r){e.push([].concat(i[r],r))});n;){n=!1;for(let r=0;r<e.length;r++)for(let s=r+1;s<e.length;s++)if(e[r].filter(function(d){return e[s].indexOf(d)!==-1}).length){e[r]=e[r].concat(e[s]),e.splice(s,1),n=!0;break}}return e.forEach(function(r){r=r.filter(function(c,d,b){return b.indexOf(c)===d});let s=r.pop();s!==void 0&&typeof s=="string"&&(t[s]=r)}),t}function yn(i){return i!==void 0?i+1:1}function Hr(i){return i==="__proto__"?"___proto___":i}function fa(i){return typeof i=="string"&&(i[0]==="'"||i[0]==='"')&&i[i.length-1]===i[0]?i.substring(1,i.length-1):i}import{readFileSync as ga}from"fs";var En,vn,On,Yr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,Vr=(vn=(En=process==null?void 0:process.versions)===null||En===void 0?void 0:En.node)!==null&&vn!==void 0?vn:(On=process==null?void 0:process.version)===null||On===void 0?void 0:On.slice(1);if(Vr&&Number(Vr.match(/^([^.]+)/)[1])<Yr)throw Error(`yargs parser supports a minimum Node.js version of ${Yr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var ma=process?process.env:{},qr=new zt({cwd:process.cwd,env:()=>ma,format:ha,normalize:da,resolve:pa,require:i=>{if(typeof ze<"u")return ze(i);if(i.match(/\.json$/))return JSON.parse(ga(i,"utf8"));throw Error("only .json config files are supported in ESM")}}),Pt=function(e,t){return qr.parse(e.slice(),t).argv};Pt.detailed=function(i,e){return qr.parse(i.slice(),e)};Pt.camelCase=rt;Pt.decamelize=Bt;Pt.looksLikeNumber=Gt;var _n=Pt;import{basename as Ia,dirname as Fa,extname as Ma,relative as Ra,resolve as Qr}from"path";function Kr(){return ba()?0:1}function ba(){return wa()&&!process.defaultApp}function wa(){return!!process.versions.electron}function Sn(i){return i.slice(Kr()+1)}function Xr(){return process.argv[Kr()]}var ce=class i extends Error{constructor(e){super(e||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,i)}};import{readFileSync as xa,statSync as ya,writeFile as Ea}from"fs";import{format as va}from"util";import{resolve as Oa}from"path";var kr={fs:{readFileSync:xa,writeFile:Ea},format:va,resolve:Oa,exists:i=>{try{return ya(i).isFile()}catch{return!1}}};var Ge,Cn=class{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),Ge.format.apply(Ge.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),r=e.shift(),s=function(){};typeof e[e.length-1]=="function"&&(s=e.pop()),this.cache[this.locale]||this._readLocaleFile();let c=r===1?t:n;this.cache[this.locale][t]&&(c=this.cache[this.locale][t][r===1?"one":"other"]),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s})):s();let d=[c];return~c.indexOf("%d")&&d.push(r),Ge.format.apply(Ge.format,d.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n="";return e.forEach(function(r,s){let c=t[s+1];n+=r,typeof c<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,r=t.locale,s=t.cb,c=this._resolveLocaleFile(n,r),d=JSON.stringify(this.cache[r],null,2);Ge.fs.writeFile(c,d,"utf-8",function(b){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),s(b)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{Ge.fs.readFileSync&&(e=JSON.parse(Ge.fs.readFileSync(t,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+t),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=Ge.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let r=Ge.resolve(e,"./",t.split("_")[0]+".json");this._fileExistsSync(r)&&(n=r)}return n}_fileExistsSync(e){return Ge.exists(e)}};function Zr(i,e){Ge=e;let t=new Cn(i);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var _a=i=>Zr(i,kr),Jr=_a;var Na="require is not supported by ESM",ei="loading a directory of commands is not supported yet for ESM",It;try{It=Pa(import.meta.url)}catch{It=process.cwd()}var Da=It.substring(0,It.lastIndexOf("node_modules")),An={assert:{notStrictEqual:Sa,strictEqual:Ca},cliui:xn,findUp:Gr,getEnv:i=>process.env[i],inspect:Aa,getCallerFile:()=>{throw new ce(ei)},getProcessArgvBin:Xr,mainFilename:Da||process.cwd(),Parser:_n,path:{basename:Ia,dirname:Fa,extname:Ma,relative:Ra,resolve:Qr},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(i,e)=>process.emitWarning(i,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:ja,require:()=>{throw new ce(Na)},requireDirectory:()=>{throw new ce(ei)},stringWidth:i=>[...i].length,y18n:Jr({directory:Qr(It,"../../../locales"),updateFiles:!1})};function ve(i,e,t,n){t.assert.notStrictEqual(i,e,n)}function jn(i,e){e.assert.strictEqual(typeof i,"string")}function xt(i){return Object.keys(i)}function le(i){return!!i&&!!i.then&&typeof i.then=="function"}function Xe(i){let t=i.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,r=t.shift();if(!r)throw new Error(`No command found in: ${i}`);let s={cmd:r.replace(n,""),demanded:[],optional:[]};return t.forEach((c,d)=>{let b=!1;c=c.replace(/\s/g,""),/\.+[\]>]/.test(c)&&d===t.length-1&&(b=!0),/^\[/.test(c)?s.optional.push({cmd:c.replace(n,"").split("|"),variadic:b}):s.demanded.push({cmd:c.replace(n,"").split("|"),variadic:b})}),s}var Ta=["first","second","third","fourth","fifth","sixth"];function D(i,e,t){function n(){return typeof i=="object"?[{demanded:[],optional:[]},i,e]:[Xe(`cmd ${i}`),e,t]}try{let r=0,[s,c,d]=n(),b=[].slice.call(c);for(;b.length&&b[b.length-1]===void 0;)b.pop();let y=d||b.length;if(y<s.demanded.length)throw new ce(`Not enough arguments provided. Expected ${s.demanded.length} but received ${b.length}.`);let E=s.demanded.length+s.optional.length;if(y>E)throw new ce(`Too many arguments provided. Expected max ${E} but received ${y}.`);s.demanded.forEach(w=>{let f=b.shift(),_=ti(f);w.cmd.filter(S=>S===_||S==="*").length===0&&ni(_,w.cmd,r),r+=1}),s.optional.forEach(w=>{if(b.length===0)return;let f=b.shift(),_=ti(f);w.cmd.filter(S=>S===_||S==="*").length===0&&ni(_,w.cmd,r),r+=1})}catch(r){console.warn(r.stack)}}function ti(i){return Array.isArray(i)?"array":i===null?"null":typeof i}function ni(i,e,t){throw new ce(`Invalid ${Ta[t]||"manyith"} argument. Expected ${e.join(" or ")} but received ${i}.`)}var Ht=class{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(D("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let s=0;s<e.length;s++){if(typeof e[s]!="function")throw Error("middleware must be a function");let c=e[s];c.applyBeforeValidation=t,c.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e=="function"){let s=e;s.applyBeforeValidation=t,s.global=n,s.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(r=>{let s=[...n[t]||[],t];return r.option?!s.includes(r.option):!0}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();e!==void 0&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter(e=>e.global)}};function ri(i){return i?i.map(e=>(e.applyBeforeValidation=!1,e)):[]}function it(i,e,t,n){return t.reduce((r,s)=>{if(s.applyBeforeValidation!==n)return r;if(s.mutates){if(s.applied)return r;s.applied=!0}if(le(r))return r.then(c=>Promise.all([c,s(c,e)])).then(([c,d])=>Object.assign(c,d));{let c=s(r,e);return le(c)?c.then(d=>Object.assign(r,d)):Object.assign(r,c)}},i)}function st(i,e,t=n=>{throw n}){try{let n=$a(i)?i():i;return le(n)?n.then(r=>e(r)):e(n)}catch(n){return t(n)}}function $a(i){return typeof i=="function"}function Pn(i){if(typeof ze>"u")return null;for(let e=0,t=Object.keys(ze.cache),n;e<t.length;e++)if(n=ze.cache[t[e]],n.exports===i)return n;return null}var yt=/(^\*)|(^\$0)/,In=class{constructor(e,t,n,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,r){r=r||{},typeof r.recurse!="boolean"&&(r.recurse=!1),Array.isArray(r.extensions)||(r.extensions=["js"]);let s=typeof r.visit=="function"?r.visit:c=>c;r.visit=(c,d,b)=>{let y=s(c,d,b);if(y){if(this.requireCache.has(d))return y;this.requireCache.add(d),this.addHandler(y)}return y},this.shim.requireDirectory({require:t,filename:n},e,r)}addHandler(e,t,n,r,s,c){let d=[],b=ri(s);if(r=r||(()=>{}),Array.isArray(e))if(La(e))[e,...d]=e;else for(let y of e)this.addHandler(y);else if(Ua(e)){let y=Array.isArray(e.command)||typeof e.command=="string"?e.command:this.moduleName(e);e.aliases&&(y=[].concat(y).concat(e.aliases)),this.addHandler(y,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(ii(n)){this.addHandler([e].concat(d),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e=="string"){let y=Xe(e);d=d.map(f=>Xe(f).cmd);let E=!1,w=[y.cmd].concat(d).filter(f=>yt.test(f)?(E=!0,!1):!0);w.length===0&&E&&w.push("$0"),E&&(y.cmd=w[0],d=w.slice(1),e=e.replace(yt,y.cmd)),d.forEach(f=>{this.aliasMap[f]=y.cmd}),t!==!1&&this.usage.command(e,t,E,d,c),this.handlers[y.cmd]={original:e,description:t,handler:r,builder:n||{},middlewares:b,deprecated:c,demanded:y.demanded,optional:y.optional},E&&(this.defaultCommand=this.handlers[y.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,r,s,c){let d=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,b=t.getInternalMethods().getContext(),y=b.commands.slice(),E=!e;e&&(b.commands.push(e),b.fullCommands.push(d.original));let w=this.applyBuilderUpdateUsageAndParse(E,d,t,n.aliases,y,r,s,c);return le(w)?w.then(f=>this.applyMiddlewareAndGetResult(E,d,f.innerArgv,b,s,f.aliases,t)):this.applyMiddlewareAndGetResult(E,d,w.innerArgv,b,s,w.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,r,s,c,d,b){let y=t.builder,E=n;if(Yt(y)){n.getInternalMethods().getUsageInstance().freeze();let w=y(n.getInternalMethods().reset(r),b);if(le(w))return w.then(f=>(E=oi(f)?f:n,this.parseAndUpdateUsage(e,t,E,s,c,d)))}else Wa(y)&&(n.getInternalMethods().getUsageInstance().freeze(),E=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach(w=>{E.option(w,y[w])}));return this.parseAndUpdateUsage(e,t,E,s,c,d)}parseAndUpdateUsage(e,t,n,r,s,c){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,t),t.description);let d=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,s,c);return le(d)?d.then(b=>({aliases:n.parsed.aliases,innerArgv:b})):{aliases:n.parsed.aliases,innerArgv:d}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=yt.test(t.original)?t.original.replace(yt,"").trim():t.original,r=e.filter(s=>!yt.test(s));return r.push(n),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,t,n,r,s,c,d,b){if(!c.getInternalMethods().getHasOutput()){let y=c.getInternalMethods().runValidation(s,b,c.parsed.error,e);n=st(n,E=>(y(E),E))}if(t.handler&&!c.getInternalMethods().getHasOutput()){c.getInternalMethods().setHasOutput();let y=!!c.getOptions().configuration["populate--"];c.getInternalMethods().postProcess(n,y,!1,!1),n=it(n,c,d,!1),n=st(n,E=>{let w=t.handler(E);return le(w)?w.then(()=>E):E}),e||c.getInternalMethods().getUsageInstance().cacheHelpMessage(),le(n)&&!c.getInternalMethods().hasParseCallback()&&n.catch(E=>{try{c.getInternalMethods().getUsageInstance().fail(null,E)}catch{}})}return e||(r.commands.pop(),r.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,r,s,c,d){let b={};if(s)return n;d.getInternalMethods().getHasOutput()||(b=this.populatePositionals(t,n,r,d));let y=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),E=it(n,d,y,!0);return le(E)?E.then(w=>this.handleValidationAndGetResult(e,t,w,r,c,d,y,b)):this.handleValidationAndGetResult(e,t,E,r,c,d,y,b)}populatePositionals(e,t,n,r){t._=t._.slice(n.commands.length);let s=e.demanded.slice(0),c=e.optional.slice(0),d={};for(this.validation.positionalCount(s.length,t._.length);s.length;){let b=s.shift();this.populatePositional(b,t,d)}for(;c.length;){let b=c.shift();this.populatePositional(b,t,d)}return t._=n.commands.concat(t._.map(b=>""+b)),this.postProcessPositionals(t,d,this.cmdToParseOptions(e.original),r),d}populatePositional(e,t,n){let r=e.cmd[0];e.variadic?n[r]=t._.splice(0).map(String):t._.length&&(n[r]=[String(t._.shift())])}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Xe(e);return n.demanded.forEach(r=>{let[s,...c]=r.cmd;r.variadic&&(t.array.push(s),t.default[s]=[]),t.alias[s]=c,t.demand[s]=!0}),n.optional.forEach(r=>{let[s,...c]=r.cmd;r.variadic&&(t.array.push(s),t.default[s]=[]),t.alias[s]=c}),t}postProcessPositionals(e,t,n,r){let s=Object.assign({},r.getOptions());s.default=Object.assign(n.default,s.default);for(let y of Object.keys(n.alias))s.alias[y]=(s.alias[y]||[]).concat(n.alias[y]);s.array=s.array.concat(n.array),s.config={};let c=[];if(Object.keys(t).forEach(y=>{t[y].map(E=>{s.configuration["unknown-options-as-args"]&&(s.key[y]=!0),c.push(`--${y}`),c.push(E)})}),!c.length)return;let d=Object.assign({},s.configuration,{"populate--":!1}),b=this.shim.Parser.detailed(c,Object.assign({},s,{configuration:d}));if(b.error)r.getInternalMethods().getUsageInstance().fail(b.error.message,b.error);else{let y=Object.keys(t);Object.keys(t).forEach(E=>{y.push(...b.aliases[E])}),Object.keys(b.argv).forEach(E=>{y.includes(E)&&(t[E]||(t[E]=b.argv[E]),!this.isInConfigs(r,E)&&!this.isDefaulted(r,E)&&Object.prototype.hasOwnProperty.call(e,E)&&Object.prototype.hasOwnProperty.call(b.argv,E)&&(Array.isArray(e[E])||Array.isArray(b.argv[E]))?e[E]=[].concat(e[E],b.argv[E]):e[E]=b.argv[E])})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some(r=>Object.prototype.hasOwnProperty.call(r,t))||n.some(r=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=yt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Yt(t))return t(e,!0);ii(t)||Object.keys(t).forEach(n=>{e.option(n,t[n])})}moduleName(e){let t=Pn(e);if(!t)throw new Error(`No command name given for module: ${this.shim.inspect(e)}`);return this.commandFromFilename(t.filename)}commandFromFilename(e){return this.shim.path.basename(e,this.shim.path.extname(e))}extractDesc({describe:e,description:t,desc:n}){for(let r of[e,t,n]){if(typeof r=="string"||r===!1)return r;ve(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();ve(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function si(i,e,t,n){return new In(i,e,t,n)}function ii(i){return typeof i=="object"&&!!i.builder&&typeof i.handler=="function"}function La(i){return i.every(e=>typeof e=="string")}function Yt(i){return typeof i=="function"}function Wa(i){return typeof i=="object"}function Ua(i){return typeof i=="object"&&!Array.isArray(i)}function ke(i={},e=()=>!0){let t={};return xt(i).forEach(n=>{e(n,i[n])&&(t[n]=i[n])}),t}function Ze(i){typeof process>"u"||[process.stdout,process.stderr].forEach(e=>{let t=e;t._handle&&t.isTTY&&typeof t._handle.setBlocking=="function"&&t._handle.setBlocking(i)})}function Ba(i){return typeof i=="boolean"}function ui(i,e){let t=e.y18n.__,n={},r=[];n.failFn=function(P){r.push(P)};let s=null,c=null,d=!0;n.showHelpOnFail=function(P=!0,N){let[H,ee]=typeof P=="string"?[!0,P]:[P,N];return i.getInternalMethods().isGlobalContext()&&(c=ee),s=ee,d=H,n};let b=!1;n.fail=function(P,N){let H=i.getInternalMethods().getLoggerInstance();if(r.length)for(let ee=r.length-1;ee>=0;--ee){let pe=r[ee];if(Ba(pe)){if(N)throw N;if(P)throw Error(P)}else pe(P,N,n)}else{if(i.getExitProcess()&&Ze(!0),!b){b=!0,d&&(i.showHelp("error"),H.error()),(P||N)&&H.error(P||N);let ee=s||c;ee&&((P||N)&&H.error(""),H.error(ee))}if(N=N||new ce(P),i.getExitProcess())return i.exit(1);if(i.getInternalMethods().hasParseCallback())return i.exit(1,N);throw N}};let y=[],E=!1;n.usage=(R,P)=>R===null?(E=!0,y=[],n):(E=!1,y.push([R,P||""]),n),n.getUsage=()=>y,n.getUsageDisabled=()=>E,n.getPositionalGroupName=()=>t("Positionals:");let w=[];n.example=(R,P)=>{w.push([R,P||""])};let f=[];n.command=function(P,N,H,ee,pe=!1){H&&(f=f.map(Q=>(Q[2]=!1,Q))),f.push([P,N||"",H,ee,pe])},n.getCommands=()=>f;let _={};n.describe=function(P,N){Array.isArray(P)?P.forEach(H=>{n.describe(H,N)}):typeof P=="object"?Object.keys(P).forEach(H=>{n.describe(H,P[H])}):_[P]=N},n.getDescriptions=()=>_;let F=[];n.epilog=R=>{F.push(R)};let S=!1,x;n.wrap=R=>{S=!0,x=R},n.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(S||(x=We(),S=!0),x);let B="__yargsString__:";n.deferY18nLookup=R=>B+R,n.help=function(){if(K)return K;X();let P=i.customScriptName?i.$0:e.path.basename(i.$0),N=i.getDemandedOptions(),H=i.getDemandedCommands(),ee=i.getDeprecatedOptions(),pe=i.getGroups(),Q=i.getOptions(),ge=[];ge=ge.concat(Object.keys(_)),ge=ge.concat(Object.keys(N)),ge=ge.concat(Object.keys(H)),ge=ge.concat(Object.keys(Q.default)),ge=ge.filter(de),ge=Object.keys(ge.reduce((U,ie)=>(ie!=="_"&&(U[ie]=!0),U),{}));let Ve=n.getWrap(),ue=e.cliui({width:Ve,wrap:!!Ve});if(!E){if(y.length)y.forEach(U=>{ue.div({text:`${U[0].replace(/\$0/g,P)}`}),U[1]&&ue.div({text:`${U[1]}`,padding:[1,0,0,0]})}),ue.div();else if(f.length){let U=null;H._?U=`${P} <${t("command")}>
|
|
17
|
+
`:U=`${P} [${t("command")}]
|
|
18
|
+
`,ue.div(`${U}`)}}if(f.length>1||f.length===1&&!f[0][2]){ue.div(t("Commands:"));let U=i.getInternalMethods().getContext(),ie=U.commands.length?`${U.commands.join(" ")} `:"";i.getInternalMethods().getParserConfiguration()["sort-commands"]===!0&&(f=f.sort((Y,se)=>Y[0].localeCompare(se[0])));let re=P?`${P} `:"";f.forEach(Y=>{let se=`${re}${ie}${Y[0].replace(/^\$0 ?/,"")}`;ue.span({text:se,padding:[0,2,0,2],width:G(f,Ve,`${P}${ie}`)+4},{text:Y[1]});let fe=[];Y[2]&&fe.push(`[${t("default")}]`),Y[3]&&Y[3].length&&fe.push(`[${t("aliases:")} ${Y[3].join(", ")}]`),Y[4]&&(typeof Y[4]=="string"?fe.push(`[${t("deprecated: %s",Y[4])}]`):fe.push(`[${t("deprecated")}]`)),fe.length?ue.div({text:fe.join(" "),padding:[0,0,0,2],align:"right"}):ue.div()}),ue.div()}let Oe=(Object.keys(Q.alias)||[]).concat(Object.keys(i.parsed.newAliases)||[]);ge=ge.filter(U=>!i.parsed.newAliases[U]&&Oe.every(ie=>(Q.alias[ie]||[]).indexOf(U)===-1));let _e=t("Options:");pe[_e]||(pe[_e]=[]),k(ge,Q.alias,pe,_e);let Be=U=>/^--/.test(Vt(U)),W=Object.keys(pe).filter(U=>pe[U].length>0).map(U=>{let ie=pe[U].filter(de).map(re=>{if(Oe.includes(re))return re;for(let Y=0,se;(se=Oe[Y])!==void 0;Y++)if((Q.alias[se]||[]).includes(re))return se;return re});return{groupName:U,normalizedKeys:ie}}).filter(({normalizedKeys:U})=>U.length>0).map(({groupName:U,normalizedKeys:ie})=>{let re=ie.reduce((Y,se)=>(Y[se]=[se].concat(Q.alias[se]||[]).map(fe=>U===n.getPositionalGroupName()?fe:(/^[0-9]$/.test(fe)?Q.boolean.includes(se)?"-":"--":fe.length>1?"--":"-")+fe).sort((fe,Ae)=>Be(fe)===Be(Ae)?0:Be(fe)?1:-1).join(", "),Y),{});return{groupName:U,normalizedKeys:ie,switches:re}});if(W.filter(({groupName:U})=>U!==n.getPositionalGroupName()).some(({normalizedKeys:U,switches:ie})=>!U.every(re=>Be(ie[re])))&&W.filter(({groupName:U})=>U!==n.getPositionalGroupName()).forEach(({normalizedKeys:U,switches:ie})=>{U.forEach(re=>{Be(ie[re])&&(ie[re]=Ga(ie[re],4))})}),W.forEach(({groupName:U,normalizedKeys:ie,switches:re})=>{ue.div(U),ie.forEach(Y=>{let se=re[Y],fe=_[Y]||"",Ae=null;fe.includes(B)&&(fe=t(fe.substring(B.length))),Q.boolean.includes(Y)&&(Ae=`[${t("boolean")}]`),Q.count.includes(Y)&&(Ae=`[${t("count")}]`),Q.string.includes(Y)&&(Ae=`[${t("string")}]`),Q.normalize.includes(Y)&&(Ae=`[${t("string")}]`),Q.array.includes(Y)&&(Ae=`[${t("array")}]`),Q.number.includes(Y)&&(Ae=`[${t("number")}]`);let je=m=>typeof m=="string"?`[${t("deprecated: %s",m)}]`:`[${t("deprecated")}]`,tt=[Y in ee?je(ee[Y]):null,Ae,Y in N?`[${t("required")}]`:null,Q.choices&&Q.choices[Y]?`[${t("choices:")} ${n.stringifiedValues(Q.choices[Y])}]`:null,ne(Q.default[Y],Q.defaultDescription[Y])].filter(Boolean).join(" ");ue.span({text:Vt(se),padding:[0,2,0,2+ai(se)],width:G(re,Ve)+4},fe);let h=i.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;tt&&!h?ue.div({text:tt,padding:[0,0,0,2],align:"right"}):ue.div()}),ue.div()}),w.length&&(ue.div(t("Examples:")),w.forEach(U=>{U[0]=U[0].replace(/\$0/g,P)}),w.forEach(U=>{U[1]===""?ue.div({text:U[0],padding:[0,2,0,2]}):ue.div({text:U[0],padding:[0,2,0,2],width:G(w,Ve)+4},{text:U[1]})}),ue.div()),F.length>0){let U=F.map(ie=>ie.replace(/\$0/g,P)).join(`
|
|
19
|
+
`);ue.div(`${U}
|
|
20
|
+
`)}return ue.toString().replace(/\s*$/,"")};function G(R,P,N){let H=0;return Array.isArray(R)||(R=Object.values(R).map(ee=>[ee])),R.forEach(ee=>{H=Math.max(e.stringWidth(N?`${N} ${Vt(ee[0])}`:Vt(ee[0]))+ai(ee[0]),H)}),P&&(H=Math.min(H,parseInt((P*.5).toString(),10))),H}function X(){let R=i.getDemandedOptions(),P=i.getOptions();(Object.keys(P.alias)||[]).forEach(N=>{P.alias[N].forEach(H=>{_[H]&&n.describe(N,_[H]),H in R&&i.demandOption(N,R[H]),P.boolean.includes(H)&&i.boolean(N),P.count.includes(H)&&i.count(N),P.string.includes(H)&&i.string(N),P.normalize.includes(H)&&i.normalize(N),P.array.includes(H)&&i.array(N),P.number.includes(H)&&i.number(N)})})}let K;n.cacheHelpMessage=function(){K=this.help()},n.clearCachedHelpMessage=function(){K=void 0},n.hasCachedHelpMessage=function(){return!!K};function k(R,P,N,H){let ee=[],pe=null;return Object.keys(N).forEach(Q=>{ee=ee.concat(N[Q])}),R.forEach(Q=>{pe=[Q].concat(P[Q]),pe.some(ge=>ee.indexOf(ge)!==-1)||N[H].push(Q)}),ee}function de(R){return i.getOptions().hiddenOptions.indexOf(R)<0||i.parsed.argv[i.getOptions().showHiddenOpt]}n.showHelp=R=>{let P=i.getInternalMethods().getLoggerInstance();R||(R="error"),(typeof R=="function"?R:P[R])(n.help())},n.functionDescription=R=>["(",R.name?e.Parser.decamelize(R.name,"-"):t("generated-value"),")"].join(""),n.stringifiedValues=function(P,N){let H="",ee=N||", ",pe=[].concat(P);return!P||!pe.length||pe.forEach(Q=>{H.length&&(H+=ee),H+=JSON.stringify(Q)}),H};function ne(R,P){let N=`[${t("default:")} `;if(R===void 0&&!P)return null;if(P)N+=P;else switch(typeof R){case"string":N+=`"${R}"`;break;case"object":N+=JSON.stringify(R);break;default:N+=R}return`${N}]`}function We(){return e.process.stdColumns?Math.min(80,e.process.stdColumns):80}let Ue=null;n.version=R=>{Ue=R},n.showVersion=R=>{let P=i.getInternalMethods().getLoggerInstance();R||(R="error"),(typeof R=="function"?R:P[R])(Ue)},n.reset=function(P){return s=null,b=!1,y=[],E=!1,F=[],w=[],f=[],_=ke(_,N=>!P[N]),n};let q=[];return n.freeze=function(){q.push({failMessage:s,failureOutput:b,usages:y,usageDisabled:E,epilogs:F,examples:w,commands:f,descriptions:_})},n.unfreeze=function(P=!1){let N=q.pop();N&&(P?(_={...N.descriptions,..._},f=[...N.commands,...f],y=[...N.usages,...y],w=[...N.examples,...w],F=[...N.epilogs,...F]):{failMessage:s,failureOutput:b,usages:y,usageDisabled:E,epilogs:F,examples:w,commands:f,descriptions:_}=N)},n}function Fn(i){return typeof i=="object"}function Ga(i,e){return Fn(i)?{text:i.text,indentation:i.indentation+e}:{text:i,indentation:e}}function ai(i){return Fn(i)?i.indentation:0}function Vt(i){return Fn(i)?i.text:i}var ci=`###-begin-{{app_name}}-completions-###
|
|
15
21
|
#
|
|
16
22
|
# yargs command completion script
|
|
17
23
|
#
|
|
@@ -39,7 +45,7 @@ _{{app_name}}_yargs_completions()
|
|
|
39
45
|
}
|
|
40
46
|
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
|
41
47
|
###-end-{{app_name}}-completions-###
|
|
42
|
-
`,
|
|
48
|
+
`,li=`#compdef {{app_name}}
|
|
43
49
|
###-begin-{{app_name}}-completions-###
|
|
44
50
|
#
|
|
45
51
|
# yargs command completion script
|
|
@@ -58,16 +64,25 @@ _{{app_name}}_yargs_completions()
|
|
|
58
64
|
}
|
|
59
65
|
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
60
66
|
###-end-{{app_name}}-completions-###
|
|
61
|
-
`;var
|
|
62
|
-
${
|
|
63
|
-
`)}`:"";
|
|
64
|
-
${n("Argument: %s, Given: %s, Choices: %s",
|
|
65
|
-
`;g.forEach(E=>{y+=E}),t.fail(y)}};let m={};r.conflicts=function(h,g){j("<string|object> [array|string]",[h,g],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.conflicts(y,h[y])}):(s.global(h),m[h]||(m[h]=[]),Array.isArray(g)?g.forEach(y=>r.conflicts(h,y)):m[h].push(g))},r.getConflicting=()=>m,r.conflicting=function(h){Object.keys(h).forEach(g=>{m[g]&&m[g].forEach(y=>{y&&h[g]!==void 0&&h[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&&h[e.Parser.camelCase(g)]!==void 0&&h[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",g,y))})})},r.recommendCommands=function(h,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 R=Zn(h,W);R<=3&&R<_&&(_=R,E=W)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(h){return a=St(a,g=>!h[g]),m=St(m,g=>!h[g]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:m})},r.unfreeze=function(){let h=w.pop();at(h,void 0,e),{implied:a,conflicting:m}=h},r}var Ze=[],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=Ls(t,s.extends);else try{a=_t.resolve(s.extends)}catch{return s}Ns(a),Ze.push(a),i=r?JSON.parse(ae.readFileSync(a,"utf8")):_t(s.extends),delete s.extends,i=le(i,ae.path.dirname(a),e,ae)}return Ze=[],e?ti(i,s):Object.assign({},i,s)}function Ns(s){if(Ze.indexOf(s)>-1)throw new G(`Circular extended configurations: '${s}'.`)}function Ls(s,t){return ae.path.resolve(s,t)}function ti(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]=ti(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,Ut,ce,dt,ct,_e,It,zt,Ce,pt,xe,mt,Ct,ft,gt,Ee,te,st,I,je,Ae,ut,Tt,ee,Ht,$t,Pe,D,Bt,Yt,qt,N,Se,xt,X;function Oi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new cn(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var ei=Symbol("copyDoubleDash"),ni=Symbol("copyDoubleDash"),Xe=Symbol("deleteFromParserHintObject"),ii=Symbol("emitWarning"),si=Symbol("freeze"),ri=Symbol("getDollarZero"),Gt=Symbol("getParserConfiguration"),oi=Symbol("getUsageConfiguration"),ke=Symbol("guessLocale"),ai=Symbol("guessVersion"),li=Symbol("parsePositionalNumbers"),tn=Symbol("pkgUp"),vt=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),en=Symbol("populateParserHintArrayDictionary"),nn=Symbol("populateParserHintDictionary"),sn=Symbol("sanitizeKey"),rn=Symbol("setKey"),on=Symbol("unfreeze"),ci=Symbol("validateAsync"),fi=Symbol("getCommandInstance"),ui=Symbol("getContext"),hi=Symbol("getHasOutput"),di=Symbol("getLoggerInstance"),pi=Symbol("getParseContext"),mi=Symbol("getUsageInstance"),gi=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),bi=Symbol("isGlobalContext"),Vt=Symbol("postProcess"),wi=Symbol("rebase"),an=Symbol("reset"),fe=Symbol("runYargsParserAndExecuteCommands"),ln=Symbol("runValidation"),yi=Symbol("setHasOutput"),Kt=Symbol("kTrackManuallySetKeys"),cn=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Ut.set(this,void 0),ce.set(this,{commands:[],fullCommands:[]}),dt.set(this,null),ct.set(this,null),_e.set(this,"show-hidden"),It.set(this,null),zt.set(this,!0),Ce.set(this,{}),pt.set(this,!0),xe.set(this,[]),mt.set(this,void 0),Ct.set(this,{}),ft.set(this,!1),gt.set(this,null),Ee.set(this,!0),te.set(this,void 0),st.set(this,""),I.set(this,void 0),je.set(this,void 0),Ae.set(this,{}),ut.set(this,null),Tt.set(this,null),ee.set(this,{}),Ht.set(this,{}),$t.set(this,void 0),Pe.set(this,!1),D.set(this,void 0),Bt.set(this,!1),Yt.set(this,!1),qt.set(this,!1),N.set(this,void 0),Se.set(this,{}),xt.set(this,null),X.set(this,void 0),A(this,D,i,"f"),A(this,$t,t,"f"),A(this,Ut,e,"f"),A(this,je,n,"f"),A(this,mt,new we(this),"f"),this.$0=this[ri](),this[an](),A(this,tt,o(this,tt,"f"),"f"),A(this,N,o(this,N,"f"),"f"),A(this,X,o(this,X,"f"),"f"),A(this,I,o(this,I,"f"),"f"),o(this,I,"f").showHiddenOpt=o(this,_e,"f"),A(this,te,this[ni](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,gt,"f")&&(this[Xe](o(this,gt,"f")),A(this,gt,null,"f")),t===!1&&e===void 0?this:(A(this,gt,typeof t=="string"?t:n,"f"),this.boolean(o(this,gt,"f")),this.describe(o(this,gt,"f"),e||o(this,N,"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,_e,"f");return this.boolean(n),this.describe(n,e||o(this,N,"f").deferY18nLookup("Show hidden options")),o(this,I,"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[en](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[vt]("array",t),this[Kt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[vt]("boolean",t),this[Kt](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,N,"f").fail(r.toString(),r):o(this,N,"f").fail(o(this,D,"f").y18n.__("Argument check failed: %s",t.toString())),n),r=>(o(this,N,"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[en](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 G("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 G("coerce callback must be provided");return o(this,I,"f").key[t]=!0,o(this,mt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?Rt(()=>(r=i.getAliases(),e(n[t])),l=>{n[t]=l;let m=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&m!==!0)for(let w of r[t])n[w]=l;return n},l=>{throw new G(l.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,Ut,"f"),this[Gt]()["deep-merge-config"]||!1,o(this,D,"f")),o(this,I,"f").configObjects=(o(this,I,"f").configObjects||[]).concat(t),this):(typeof e=="function"&&(n=e,e=void 0),this.describe(t,e||o(this,N,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach(i=>{o(this,I,"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,ct,t||o(this,ct,"f")||"completion","f"),!e&&e!==!1&&(e="generate completion script"),this.command(o(this,ct,"f"),e),n&&o(this,dt,"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,je,"f")||o(this,D,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,D,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[vt]("count",t),this[Kt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ge(t,o(this,D,"f")),o(this,I,"f").defaultDescription[t]=n),typeof e=="function"&&(Ge(t,o(this,D,"f")),o(this,I,"f").defaultDescription[t]||(o(this,I,"f").defaultDescription[t]=o(this,N,"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,I,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:i},this}demand(t,e,n){return Array.isArray(e)?(e.forEach(i=>{at(n,!0,o(this,D,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(at(n,!0,o(this,D,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{at(n,!0,o(this,D,"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,I,"f").deprecatedOptions[t]=e,this}describe(t,e){return j("<object|string|array> [string]",[t,e],arguments.length),this[rn](t,!0),o(this,N,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,zt,t,"f"),this}env(t){return j("[string|boolean]",[t],arguments.length),t===!1?delete o(this,I,"f").envPrefix:o(this,I,"f").envPrefix=t||"",this}epilogue(t){return j("<string>",[t],arguments.length),o(this,N,"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,N,"f").example(t,e),this}exit(t,e){A(this,ft,!0,"f"),A(this,It,e,"f"),o(this,pt,"f")&&o(this,D,"f").process.exit(t)}exitProcess(t=!0){return j("[boolean]",[t],arguments.length),A(this,pt,t,"f"),this}fail(t){if(j("<function|boolean>",[t],arguments.length),typeof t=="boolean"&&t!==!1)throw new G("Invalid first argument. Expected function or boolean 'false'");return o(this,N,"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,dt,"f").getCompletion(t,e):new Promise((n,i)=>{o(this,dt,"f").getCompletion(t,(r,a)=>{r?i(r):n(a)})})}getDemandedOptions(){return j([],0),o(this,I,"f").demandedOptions}getDemandedCommands(){return j([],0),o(this,I,"f").demandedCommands}getDeprecatedOptions(){return j([],0),o(this,I,"f").deprecatedOptions}getDetectLocale(){return o(this,zt,"f")}getExitProcess(){return o(this,pt,"f")}getGroups(){return Object.assign({},o(this,Ct,"f"),o(this,Ht,"f"))}getHelp(){if(A(this,ft,!0,"f"),!o(this,N,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[fe](o(this,$t,"f"),void 0,void 0,0,!0);if(V(e))return e.then(()=>o(this,N,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(V(t))return t.then(()=>o(this,N,"f").help())}return Promise.resolve(o(this,N,"f").help())}getOptions(){return o(this,I,"f")}getStrict(){return o(this,Bt,"f")}getStrictCommands(){return o(this,Yt,"f")}getStrictOptions(){return o(this,qt,"f")}global(t,e){return j("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1?o(this,I,"f").local=o(this,I,"f").local.filter(n=>t.indexOf(n)===-1):t.forEach(n=>{o(this,I,"f").local.includes(n)||o(this,I,"f").local.push(n)}),this}group(t,e){j("<string|array> <string>",[t,e],arguments.length);let n=o(this,Ht,"f")[e]||o(this,Ct,"f")[e];o(this,Ht,"f")[e]&&delete o(this,Ht,"f")[e];let i={};return o(this,Ct,"f")[e]=(n||[]).concat(t).filter(r=>i[r]?!1:i[r]=!0),this}hide(t){return j("<string>",[t],arguments.length),o(this,I,"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[ke](),o(this,D,"f").y18n.getLocale()):(A(this,zt,!1,"f"),o(this,D,"f").y18n.setLocale(t),this)}middleware(t,e,n){return o(this,mt,"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[vt]("normalize",t),this}number(t){return j("<array|string>",[t],arguments.length),this[vt]("number",t),this[Kt](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[Kt](t),o(this,xt,"f")&&(t==="version"||e?.alias==="version")&&this[ii](['"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"),
|
|
67
|
-
`,"f"),
|
|
68
|
-
`,"f"),A(this,st,o(this,st,"f")+t.join(" "),"f")}}}[Xe](t){Xt(o(this,I,"f")).forEach(e=>{if((i=>i==="configObjects")(e))return;let n=o(this,I,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):typeof n=="object"&&delete n[t]}),delete o(this,N,"f").getDescriptions()[t]}[ii](t,e,n){o(this,Ce,"f")[n]||(o(this,D,"f").process.emitWarning(t,e),o(this,Ce,"f")[n]=!0)}[si](){o(this,xe,"f").push({options:o(this,I,"f"),configObjects:o(this,I,"f").configObjects.slice(0),exitProcess:o(this,pt,"f"),groups:o(this,Ct,"f"),strict:o(this,Bt,"f"),strictCommands:o(this,Yt,"f"),strictOptions:o(this,qt,"f"),completionCommand:o(this,ct,"f"),output:o(this,st,"f"),exitError:o(this,It,"f"),hasOutput:o(this,ft,"f"),parsed:this.parsed,parseFn:o(this,ut,"f"),parseContext:o(this,Tt,"f")}),o(this,N,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,mt,"f").freeze()}[ri](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,D,"f").process.argv()[0])?e=o(this,D,"f").process.argv().slice(1,2):e=o(this,D,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[wi](o(this,Ut,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,D,"f").getEnv("_")&&o(this,D,"f").getProcessArgvBin()===o(this,D,"f").getEnv("_")&&(t=o(this,D,"f").getEnv("_").replace(`${o(this,D,"f").path.dirname(o(this,D,"f").process.execPath())}/`,"")),t}[Gt](){return o(this,Ae,"f")}[oi](){return o(this,Se,"f")}[ke](){if(!o(this,zt,"f"))return;let t=o(this,D,"f").getEnv("LC_ALL")||o(this,D,"f").getEnv("LC_MESSAGES")||o(this,D,"f").getEnv("LANG")||o(this,D,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ai](){return this[tn]().version||"unknown"}[li](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,D,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[tn](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,D,"f").mainFilename;!t&&o(this,D,"f").path.extname(i)&&(i=o(this,D,"f").path.dirname(i));let r=o(this,D,"f").findUp(i,(a,l)=>{if(l.includes("package.json"))return"package.json"});at(r,void 0,o(this,D,"f")),n=JSON.parse(o(this,D,"f").readFileSync(r,"utf8"))}catch{}return o(this,ee,"f")[e]=n||{},o(this,ee,"f")[e]}[vt](t,e){e=[].concat(e),e.forEach(n=>{n=this[sn](n),o(this,I,"f")[t].push(n)})}[ne](t,e,n,i){this[nn](t,e,n,i,(r,a,l)=>{o(this,I,"f")[r][a]=l})}[en](t,e,n,i){this[nn](t,e,n,i,(r,a,l)=>{o(this,I,"f")[r][a]=(o(this,I,"f")[r][a]||[]).concat(l)})}[nn](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[sn](n),i)}[sn](t){return t==="__proto__"?"___proto___":t}[rn](t,e){return this[ne](this[rn].bind(this),"key",t,e),this}[on](){var t,e,n,i,r,a,l,m,w,p,h,g;let y=o(this,xe,"f").pop();at(y,void 0,o(this,D,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,l=this,m=this,w=this,p=this,h=this,g=this,{options:{set value(_){A(t,I,_,"f")}}.value,configObjects:E,exitProcess:{set value(_){A(e,pt,_,"f")}}.value,groups:{set value(_){A(n,Ct,_,"f")}}.value,output:{set value(_){A(i,st,_,"f")}}.value,exitError:{set value(_){A(r,It,_,"f")}}.value,hasOutput:{set value(_){A(a,ft,_,"f")}}.value,parsed:this.parsed,strict:{set value(_){A(l,Bt,_,"f")}}.value,strictCommands:{set value(_){A(m,Yt,_,"f")}}.value,strictOptions:{set value(_){A(w,qt,_,"f")}}.value,completionCommand:{set value(_){A(p,ct,_,"f")}}.value,parseFn:{set value(_){A(h,ut,_,"f")}}.value,parseContext:{set value(_){A(g,Tt,_,"f")}}.value}=y,o(this,I,"f").configObjects=E,o(this,N,"f").unfreeze(),o(this,X,"f").unfreeze(),o(this,tt,"f").unfreeze(),o(this,mt,"f").unfreeze()}[ci](t,e){return Rt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[fi].bind(this),getContext:this[ui].bind(this),getHasOutput:this[hi].bind(this),getLoggerInstance:this[di].bind(this),getParseContext:this[pi].bind(this),getParserConfiguration:this[Gt].bind(this),getUsageConfiguration:this[oi].bind(this),getUsageInstance:this[mi].bind(this),getValidationInstance:this[gi].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[bi].bind(this),postProcess:this[Vt].bind(this),reset:this[an].bind(this),runValidation:this[ln].bind(this),runYargsParserAndExecuteCommands:this[fe].bind(this),setHasOutput:this[yi].bind(this)}}[fi](){return o(this,tt,"f")}[ui](){return o(this,ce,"f")}[hi](){return o(this,ft,"f")}[di](){return o(this,te,"f")}[pi](){return o(this,Tt,"f")||{}}[mi](){return o(this,N,"f")}[gi](){return o(this,X,"f")}[Me](){return!!o(this,ut,"f")}[bi](){return o(this,Ee,"f")}[Vt](t,e,n,i){return n||V(t)||(e||(t=this[ei](t)),(this[Gt]()["parse-positional-numbers"]||this[Gt]()["parse-positional-numbers"]===void 0)&&(t=this[li](t)),i&&(t=Wt(t,this,o(this,mt,"f").getMiddleware(),!1))),t}[an](t={}){A(this,I,o(this,I,"f")||{},"f");let e={};e.local=o(this,I,"f").local||[],e.configObjects=o(this,I,"f").configObjects||[];let n={};e.local.forEach(a=>{n[a]=!0,(t[a]||[]).forEach(l=>{n[l]=!0})}),Object.assign(o(this,Ht,"f"),Object.keys(o(this,Ct,"f")).reduce((a,l)=>{let m=o(this,Ct,"f")[l].filter(w=>!(w in n));return m.length>0&&(a[l]=m),a},{})),A(this,Ct,{},"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,I,"f")[a]||[]).filter(l=>!n[l])}),r.forEach(a=>{e[a]=St(o(this,I,"f")[a],l=>!n[l])}),e.envPrefix=o(this,I,"f").envPrefix,A(this,I,e,"f"),A(this,N,o(this,N,"f")?o(this,N,"f").reset(n):Vn(this,o(this,D,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):kn(this,o(this,N,"f"),o(this,D,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():Yn(o(this,N,"f"),o(this,X,"f"),o(this,mt,"f"),o(this,D,"f")),"f"),o(this,dt,"f")||A(this,dt,Jn(this,o(this,N,"f"),o(this,tt,"f"),o(this,D,"f")),"f"),o(this,mt,"f").reset(),A(this,ct,null,"f"),A(this,st,"","f"),A(this,It,null,"f"),A(this,ft,!1,"f"),this.parsed=!1,this}[wi](t,e){return o(this,D,"f").path.relative(t,e)}[fe](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,$t,"f"),o(this,I,"f").__=o(this,D,"f").y18n.__,o(this,I,"f").configuration=this[Gt]();let l=!!o(this,I,"f").configuration["populate--"],m=Object.assign({},o(this,I,"f").configuration,{"populate--":!0}),w=o(this,D,"f").Parser.detailed(t,Object.assign({},o(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...m}})),p=Object.assign(w.argv,o(this,Tt,"f")),h,g=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,gt,"f")&&p[_]?y=!0:_===o(this,xt,"f")&&p[_]&&(E=!0)}),p.$0=this.$0,this.parsed=w,i===0&&o(this,N,"f").clearCachedHelpMessage();try{if(this[ke](),e)return this[Vt](p,l,!!n,!1);o(this,gt,"f")&&[o(this,gt,"f")].concat(g[o(this,gt,"f")]||[]).filter(Y=>Y.length>1).includes(""+p._[p._.length-1])&&(p._.pop(),y=!0),A(this,Ee,!1,"f");let _=o(this,tt,"f").getCommands(),d=o(this,dt,"f").completionKey in p,W=y||d||r;if(p._.length){if(_.length){let R;for(let Y=i||0,U;p._[Y]!==void 0;Y++)if(U=String(p._[Y]),_.includes(U)&&U!==o(this,ct,"f")){let T=o(this,tt,"f").runCommand(U,this,w,Y+1,r,y||E||r);return this[Vt](T,l,!!n,!1)}else if(!R&&U!==o(this,ct,"f")){R=U;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Pe,"f")&&R&&!W&&o(this,X,"f").recommendCommands(R,_)}o(this,ct,"f")&&p._.includes(o(this,ct,"f"))&&!d&&(o(this,pt,"f")&&Mt(!0),this.showCompletionScript(),this.exit(0))}if(o(this,tt,"f").hasDefaultCommand()&&!W){let R=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Vt](R,l,!!n,!1)}if(d){o(this,pt,"f")&&Mt(!0),t=[].concat(t);let R=t.slice(t.indexOf(`--${o(this,dt,"f").completionKey}`)+1);return o(this,dt,"f").getCompletion(R,(Y,U)=>{if(Y)throw new G(Y.message);(U||[]).forEach(T=>{o(this,te,"f").log(T)}),this.exit(0)}),this[Vt](p,!l,!!n,!1)}if(o(this,ft,"f")||(y?(o(this,pt,"f")&&Mt(!0),a=!0,this.showHelp("log"),this.exit(0)):E&&(o(this,pt,"f")&&Mt(!0),a=!0,o(this,N,"f").showVersion("log"),this.exit(0))),!a&&o(this,I,"f").skipValidation.length>0&&(a=Object.keys(p).some(R=>o(this,I,"f").skipValidation.indexOf(R)>=0&&p[R]===!0)),!a){if(w.error)throw new G(w.error.message);if(!d){let R=this[ln](g,{},w.error);n||(h=Wt(p,this,o(this,mt,"f").getMiddleware(),!0)),h=this[ci](R,h??p),V(h)&&!n&&(h=h.then(()=>Wt(p,this,o(this,mt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof G)o(this,N,"f").fail(_.message,_);else throw _}return this[Vt](h??p,l,!!n,!0)}[ln](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new G(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let l=!1;o(this,Yt,"f")&&(l=o(this,X,"f").unknownCommands(a)),o(this,Bt,"f")&&!l?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,qt,"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)}}[yi](){A(this,ft,!0,"f")}[Kt](t){if(typeof t=="string")o(this,I,"f").key[t]=!0;else for(let e of t)o(this,I,"f").key[e]=!0}};function qn(s){return!!s&&typeof s.getInternalMethods=="function"}var Ws=Oi(qe),_i=Ws;await _i(Be(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:!1,describe:"Output an image with a transparent background",type:"boolean"}).option("dark-mode",{alias:"d",default:!1,describe:"Output a dark theme version of the image",type:"boolean"}).option("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async s=>{let{darkMode:t,fileOrUrl:e,format:n,output:i,transparent:r,verbose:a}=s;try{await On(e,{darkMode:t,format:n,output:i,transparent:r,verbose:a}),process.exit(0)}catch(l){console.error("Error during conversion:",l),process.exit(1)}}).alias("h","help").version("version",fn).alias("v","version").help().parse();
|
|
67
|
+
`;var Mn=class{constructor(e,t,n,r){var s,c,d;this.yargs=e,this.usage=t,this.command=n,this.shim=r,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(d=((s=this.shim.getEnv("SHELL"))===null||s===void 0?void 0:s.includes("zsh"))||((c=this.shim.getEnv("ZSH_NAME"))===null||c===void 0?void 0:c.includes("zsh")))!==null&&d!==void 0?d:!1}defaultCompletion(e,t,n,r){let s=this.command.getCommandHandlers();for(let d=0,b=e.length;d<b;++d)if(s[e[d]]&&s[e[d]].builder){let y=s[e[d]].builder;if(Yt(y)){this.indexAfterLastReset=d+1;let E=this.yargs.getInternalMethods().reset();return y(E,!0),E.argv}}let c=[];this.commandCompletions(c,e,n),this.optionCompletions(c,e,t,n),this.choicesFromOptionsCompletions(c,e,t,n),this.choicesFromPositionalsCompletions(c,e,t,n),r(null,c)}commandCompletions(e,t,n){let r=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&r[r.length-1]!==n&&!this.previousArgHasChoices(t)&&this.usage.getCommands().forEach(s=>{let c=Xe(s[0]).cmd;if(t.indexOf(c)===-1)if(!this.zshShell)e.push(c);else{let d=s[1]||"";e.push(c.replace(/:/g,"\\:")+":"+d)}})}optionCompletions(e,t,n,r){if((r.match(/^-/)||r===""&&e.length===0)&&!this.previousArgHasChoices(t)){let s=this.yargs.getOptions(),c=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(s.key).forEach(d=>{let b=!!s.configuration["boolean-negation"]&&s.boolean.includes(d);!c.includes(d)&&!s.hiddenOptions.includes(d)&&!this.argsContainKey(t,d,b)&&this.completeOptionKey(d,e,r,b&&!!s.default[d])})}}choicesFromOptionsCompletions(e,t,n,r){if(this.previousArgHasChoices(t)){let s=this.getPreviousArgChoices(t);s&&s.length>0&&e.push(...s.map(c=>c.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,r){if(r===""&&e.length>0&&this.previousArgHasChoices(t))return;let s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],c=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),d=s[n._.length-c-1];if(!d)return;let b=this.yargs.getOptions().choices[d]||[];for(let y of b)y.startsWith(r)&&e.push(y.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1&&(n=t,t=e[e.length-2]),!t.startsWith("-"))return;let r=t.replace(/^-+/,""),s=this.yargs.getOptions(),c=[r,...this.yargs.getAliases()[r]||[]],d;for(let b of c)if(Object.prototype.hasOwnProperty.call(s.key,b)&&Array.isArray(s.choices[b])){d=s.choices[b];break}if(d)return d.filter(b=>!n||b.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let r=s=>e.indexOf((/^[^0-9]$/.test(s)?"-":"--")+s)!==-1;if(r(t)||n&&r(`no-${t}`))return!0;if(this.aliases){for(let s of this.aliases[t])if(r(s))return!0}return!1}completeOptionKey(e,t,n,r){var s,c,d,b;let y=e;if(this.zshShell){let _=this.usage.getDescriptions(),F=(c=(s=this===null||this===void 0?void 0:this.aliases)===null||s===void 0?void 0:s[e])===null||c===void 0?void 0:c.find(B=>{let G=_[B];return typeof G=="string"&&G.length>0}),S=F?_[F]:void 0,x=(b=(d=_[e])!==null&&d!==void 0?d:S)!==null&&b!==void 0?b:"";y=`${e.replace(/:/g,"\\:")}:${x.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let E=_=>/^--/.test(_),w=_=>/^[^0-9]$/.test(_),f=!E(n)&&w(e)?"-":"--";t.push(f+y),r&&t.push(f+"no-"+y)}customCompletion(e,t,n,r){if(ve(this.customCompletionFunction,null,this.shim),Ha(this.customCompletionFunction)){let s=this.customCompletionFunction(n,t);return le(s)?s.then(c=>{this.shim.process.nextTick(()=>{r(null,c)})}).catch(c=>{this.shim.process.nextTick(()=>{r(c,void 0)})}):r(null,s)}else return Ya(this.customCompletionFunction)?this.customCompletionFunction(n,t,(s=r)=>this.defaultCompletion(e,t,n,s),s=>{r(null,s)}):this.customCompletionFunction(n,t,s=>{r(null,s)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",r=this.yargs.parse(e,!0),s=this.customCompletionFunction?c=>this.customCompletion(e,c,n,t):c=>this.defaultCompletion(e,c,n,t);return le(r)?r.then(s):s(r)}generateCompletionScript(e,t){let n=this.zshShell?li:ci,r=this.shim.path.basename(e);return e.match(/\.js$/)&&(e=`./${e}`),n=n.replace(/{{app_name}}/g,r),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}};function fi(i,e,t,n){return new Mn(i,e,t,n)}function Ha(i){return i.length<3}function Ya(i){return i.length>3}function hi(i,e){if(i.length===0)return e.length;if(e.length===0)return i.length;let t=[],n;for(n=0;n<=e.length;n++)t[n]=[n];let r;for(r=0;r<=i.length;r++)t[0][r]=r;for(n=1;n<=e.length;n++)for(r=1;r<=i.length;r++)e.charAt(n-1)===i.charAt(r-1)?t[n][r]=t[n-1][r-1]:n>1&&r>1&&e.charAt(n-2)===i.charAt(r-1)&&e.charAt(n-1)===i.charAt(r-2)?t[n][r]=t[n-2][r-2]+1:t[n][r]=Math.min(t[n-1][r-1]+1,Math.min(t[n][r-1]+1,t[n-1][r]+1));return t[e.length][i.length]}var di=["$0","--","_"];function pi(i,e,t){let n=t.y18n.__,r=t.y18n.__n,s={};s.nonOptionCount=function(w){let f=i.getDemandedCommands(),F=w._.length+(w["--"]?w["--"].length:0)-i.getInternalMethods().getContext().commands.length;f._&&(F<f._.min||F>f._.max)&&(F<f._.min?f._.minMsg!==void 0?e.fail(f._.minMsg?f._.minMsg.replace(/\$0/g,F.toString()).replace(/\$1/,f._.min.toString()):null):e.fail(r("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",F,F.toString(),f._.min.toString())):F>f._.max&&(f._.maxMsg!==void 0?e.fail(f._.maxMsg?f._.maxMsg.replace(/\$0/g,F.toString()).replace(/\$1/,f._.max.toString()):null):e.fail(r("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",F,F.toString(),f._.max.toString()))))},s.positionalCount=function(w,f){f<w&&e.fail(r("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",f,f+"",w+""))},s.requiredArguments=function(w,f){let _=null;for(let F of Object.keys(f))(!Object.prototype.hasOwnProperty.call(w,F)||typeof w[F]>"u")&&(_=_||{},_[F]=f[F]);if(_){let F=[];for(let x of Object.keys(_)){let B=_[x];B&&F.indexOf(B)<0&&F.push(B)}let S=F.length?`
|
|
68
|
+
${F.join(`
|
|
69
|
+
`)}`:"";e.fail(r("Missing required argument: %s","Missing required arguments: %s",Object.keys(_).length,Object.keys(_).join(", ")+S))}},s.unknownArguments=function(w,f,_,F,S=!0){var x;let B=i.getInternalMethods().getCommandInstance().getCommands(),G=[],X=i.getInternalMethods().getContext();if(Object.keys(w).forEach(K=>{!di.includes(K)&&!Object.prototype.hasOwnProperty.call(_,K)&&!Object.prototype.hasOwnProperty.call(i.getInternalMethods().getParseContext(),K)&&!s.isValidAndSomeAliasIsNotNew(K,f)&&G.push(K)}),S&&(X.commands.length>0||B.length>0||F)&&w._.slice(X.commands.length).forEach(K=>{B.includes(""+K)||G.push(""+K)}),S){let k=((x=i.getDemandedCommands()._)===null||x===void 0?void 0:x.max)||0,de=X.commands.length+k;de<w._.length&&w._.slice(de).forEach(ne=>{ne=String(ne),!X.commands.includes(ne)&&!G.includes(ne)&&G.push(ne)})}G.length&&e.fail(r("Unknown argument: %s","Unknown arguments: %s",G.length,G.map(K=>K.trim()?K:`"${K}"`).join(", ")))},s.unknownCommands=function(w){let f=i.getInternalMethods().getCommandInstance().getCommands(),_=[],F=i.getInternalMethods().getContext();return(F.commands.length>0||f.length>0)&&w._.slice(F.commands.length).forEach(S=>{f.includes(""+S)||_.push(""+S)}),_.length>0?(e.fail(r("Unknown command: %s","Unknown commands: %s",_.length,_.join(", "))),!0):!1},s.isValidAndSomeAliasIsNotNew=function(w,f){if(!Object.prototype.hasOwnProperty.call(f,w))return!1;let _=i.parsed.newAliases;return[w,...f[w]].some(F=>!Object.prototype.hasOwnProperty.call(_,F)||!_[w])},s.limitedChoices=function(w){let f=i.getOptions(),_={};if(!Object.keys(f.choices).length)return;Object.keys(w).forEach(x=>{di.indexOf(x)===-1&&Object.prototype.hasOwnProperty.call(f.choices,x)&&[].concat(w[x]).forEach(B=>{f.choices[x].indexOf(B)===-1&&B!==void 0&&(_[x]=(_[x]||[]).concat(B))})});let F=Object.keys(_);if(!F.length)return;let S=n("Invalid values:");F.forEach(x=>{S+=`
|
|
70
|
+
${n("Argument: %s, Given: %s, Choices: %s",x,e.stringifiedValues(_[x]),e.stringifiedValues(f.choices[x]))}`}),e.fail(S)};let c={};s.implies=function(w,f){D("<string|object> [array|number|string]",[w,f],arguments.length),typeof w=="object"?Object.keys(w).forEach(_=>{s.implies(_,w[_])}):(i.global(w),c[w]||(c[w]=[]),Array.isArray(f)?f.forEach(_=>s.implies(w,_)):(ve(f,void 0,t),c[w].push(f)))},s.getImplied=function(){return c};function d(E,w){let f=Number(w);return w=isNaN(f)?w:f,typeof w=="number"?w=E._.length>=w:w.match(/^--no-.+/)?(w=w.match(/^--no-(.+)/)[1],w=!Object.prototype.hasOwnProperty.call(E,w)):w=Object.prototype.hasOwnProperty.call(E,w),w}s.implications=function(w){let f=[];if(Object.keys(c).forEach(_=>{let F=_;(c[_]||[]).forEach(S=>{let x=F,B=S;x=d(w,x),S=d(w,S),x&&!S&&f.push(` ${F} -> ${B}`)})}),f.length){let _=`${n("Implications failed:")}
|
|
71
|
+
`;f.forEach(F=>{_+=F}),e.fail(_)}};let b={};s.conflicts=function(w,f){D("<string|object> [array|string]",[w,f],arguments.length),typeof w=="object"?Object.keys(w).forEach(_=>{s.conflicts(_,w[_])}):(i.global(w),b[w]||(b[w]=[]),Array.isArray(f)?f.forEach(_=>s.conflicts(w,_)):b[w].push(f))},s.getConflicting=()=>b,s.conflicting=function(w){Object.keys(w).forEach(f=>{b[f]&&b[f].forEach(_=>{_&&w[f]!==void 0&&w[_]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",f,_))})}),i.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(b).forEach(f=>{b[f].forEach(_=>{_&&w[t.Parser.camelCase(f)]!==void 0&&w[t.Parser.camelCase(_)]!==void 0&&e.fail(n("Arguments %s and %s are mutually exclusive",f,_))})})},s.recommendCommands=function(w,f){f=f.sort((x,B)=>B.length-x.length);let F=null,S=1/0;for(let x=0,B;(B=f[x])!==void 0;x++){let G=hi(w,B);G<=3&&G<S&&(S=G,F=B)}F&&e.fail(n("Did you mean %s?",F))},s.reset=function(w){return c=ke(c,f=>!w[f]),b=ke(b,f=>!w[f]),s};let y=[];return s.freeze=function(){y.push({implied:c,conflicting:b})},s.unfreeze=function(){let w=y.pop();ve(w,void 0,t),{implied:c,conflicting:b}=w},s}var Rn=[],Ft;function Mt(i,e,t,n){Ft=n;let r={};if(Object.prototype.hasOwnProperty.call(i,"extends")){if(typeof i.extends!="string")return r;let s=/\.json|\..*rc$/.test(i.extends),c=null;if(s)c=qa(e,i.extends);else try{c=ze.resolve(i.extends)}catch{return i}Va(c),Rn.push(c),r=s?JSON.parse(Ft.readFileSync(c,"utf8")):ze(i.extends),delete i.extends,r=Mt(r,Ft.path.dirname(c),t,Ft)}return Rn=[],t?gi(r,i):Object.assign({},r,i)}function Va(i){if(Rn.indexOf(i)>-1)throw new ce(`Circular extended configurations: '${i}'.`)}function qa(i,e){return Ft.path.resolve(i,e)}function gi(i,e){let t={};function n(r){return r&&typeof r=="object"&&!Array.isArray(r)}Object.assign(t,i);for(let r of Object.keys(e))n(e[r])&&n(t[r])?t[r]=gi(i[r],e[r]):t[r]=e[r];return t}var T=function(i,e,t,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,t):r?r.value=t:e.set(i,t),t},a=function(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)},we,ot,Rt,De,Fe,qt,Je,at,Kt,Te,Xt,$e,He,Me,Le,kt,Et,xe,L,Zt,Jt,Re,ut,vt,ct,Qe,Qt,z,lt,ft,ht,V,en,Ye,he;function Di(i){return(e=[],t=i.process.cwd(),n)=>{let r=new Hn(e,t,n,i);return Object.defineProperty(r,"argv",{get:()=>r.parse(),enumerable:!0}),r.help(),r.version(),r}}var mi=Symbol("copyDoubleDash"),bi=Symbol("copyDoubleDash"),Nn=Symbol("deleteFromParserHintObject"),wi=Symbol("emitWarning"),xi=Symbol("freeze"),yi=Symbol("getDollarZero"),dt=Symbol("getParserConfiguration"),Ei=Symbol("getUsageConfiguration"),Dn=Symbol("guessLocale"),vi=Symbol("guessVersion"),Oi=Symbol("parsePositionalNumbers"),Tn=Symbol("pkgUp"),et=Symbol("populateParserHintArray"),Ot=Symbol("populateParserHintSingleValueDictionary"),$n=Symbol("populateParserHintArrayDictionary"),Ln=Symbol("populateParserHintDictionary"),Wn=Symbol("sanitizeKey"),Un=Symbol("setKey"),Bn=Symbol("unfreeze"),_i=Symbol("validateAsync"),Si=Symbol("getCommandInstance"),Ci=Symbol("getContext"),Ai=Symbol("getHasOutput"),ji=Symbol("getLoggerInstance"),Pi=Symbol("getParseContext"),Ii=Symbol("getUsageInstance"),Fi=Symbol("getValidationInstance"),tn=Symbol("hasParseCallback"),Mi=Symbol("isGlobalContext"),pt=Symbol("postProcess"),Ri=Symbol("rebase"),Gn=Symbol("reset"),Nt=Symbol("runYargsParserAndExecuteCommands"),zn=Symbol("runValidation"),Ni=Symbol("setHasOutput"),gt=Symbol("kTrackManuallySetKeys"),Hn=class{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,we.set(this,void 0),ot.set(this,void 0),Rt.set(this,{commands:[],fullCommands:[]}),De.set(this,null),Fe.set(this,null),qt.set(this,"show-hidden"),Je.set(this,null),at.set(this,!0),Kt.set(this,{}),Te.set(this,!0),Xt.set(this,[]),$e.set(this,void 0),He.set(this,{}),Me.set(this,!1),Le.set(this,null),kt.set(this,!0),Et.set(this,void 0),xe.set(this,""),L.set(this,void 0),Zt.set(this,void 0),Jt.set(this,{}),Re.set(this,null),ut.set(this,null),vt.set(this,{}),ct.set(this,{}),Qe.set(this,void 0),Qt.set(this,!1),z.set(this,void 0),lt.set(this,!1),ft.set(this,!1),ht.set(this,!1),V.set(this,void 0),en.set(this,{}),Ye.set(this,null),he.set(this,void 0),T(this,z,r,"f"),T(this,Qe,e,"f"),T(this,ot,t,"f"),T(this,Zt,n,"f"),T(this,$e,new Ht(this),"f"),this.$0=this[yi](),this[Gn](),T(this,we,a(this,we,"f"),"f"),T(this,V,a(this,V,"f"),"f"),T(this,he,a(this,he,"f"),"f"),T(this,L,a(this,L,"f"),"f"),a(this,L,"f").showHiddenOpt=a(this,qt,"f"),T(this,Et,this[bi](),"f")}addHelpOpt(e,t){let n="help";return D("[string|boolean] [string]",[e,t],arguments.length),a(this,Le,"f")&&(this[Nn](a(this,Le,"f")),T(this,Le,null,"f")),e===!1&&t===void 0?this:(T(this,Le,typeof e=="string"?e:n,"f"),this.boolean(a(this,Le,"f")),this.describe(a(this,Le,"f"),t||a(this,V,"f").deferY18nLookup("Show help")),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(D("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e=="string"?e:a(this,qt,"f");return this.boolean(n),this.describe(n,t||a(this,V,"f").deferY18nLookup("Show hidden options")),a(this,L,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return D("<object|string|array> [string|array]",[e,t],arguments.length),this[$n](this.alias.bind(this),"alias",e,t),this}array(e){return D("<array|string>",[e],arguments.length),this[et]("array",e),this[gt](e),this}boolean(e){return D("<array|string>",[e],arguments.length),this[et]("boolean",e),this[gt](e),this}check(e,t){return D("<function> [boolean]",[e,t],arguments.length),this.middleware((n,r)=>st(()=>e(n,r.getOptions()),s=>(s?(typeof s=="string"||s instanceof Error)&&a(this,V,"f").fail(s.toString(),s):a(this,V,"f").fail(a(this,z,"f").y18n.__("Argument check failed: %s",e.toString())),n),s=>(a(this,V,"f").fail(s.message?s.message:s.toString(),s),n)),!1,t),this}choices(e,t){return D("<object|string|array> [string|array]",[e,t],arguments.length),this[$n](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(D("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new ce("coerce callback must be provided");for(let n of e)this.coerce(n,t);return this}else if(typeof e=="object"){for(let n of Object.keys(e))this.coerce(n,e[n]);return this}if(!t)throw new ce("coerce callback must be provided");return a(this,L,"f").key[e]=!0,a(this,$e,"f").addCoerceMiddleware((n,r)=>{let s;return Object.prototype.hasOwnProperty.call(n,e)?st(()=>(s=r.getAliases(),t(n[e])),d=>{n[e]=d;let b=r.getInternalMethods().getParserConfiguration()["strip-aliased"];if(s[e]&&b!==!0)for(let y of s[e])n[y]=d;return n},d=>{throw new ce(d.message)}):n},e),this}conflicts(e,t){return D("<string|object> [string|array]",[e,t],arguments.length),a(this,he,"f").conflicts(e,t),this}config(e="config",t,n){return D("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e=="object"&&!Array.isArray(e)?(e=Mt(e,a(this,ot,"f"),this[dt]()["deep-merge-config"]||!1,a(this,z,"f")),a(this,L,"f").configObjects=(a(this,L,"f").configObjects||[]).concat(e),this):(typeof t=="function"&&(n=t,t=void 0),this.describe(e,t||a(this,V,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach(r=>{a(this,L,"f").config[r]=n||!0}),this)}completion(e,t,n){return D("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t=="function"&&(n=t,t=void 0),T(this,Fe,e||a(this,Fe,"f")||"completion","f"),!t&&t!==!1&&(t="generate completion script"),this.command(a(this,Fe,"f"),t),n&&a(this,De,"f").registerFunction(n),this}command(e,t,n,r,s,c){return D("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,r,s,c],arguments.length),a(this,we,"f").addHandler(e,t,n,r,s,c),this}commands(e,t,n,r,s,c){return this.command(e,t,n,r,s,c)}commandDir(e,t){D("<string> [object]",[e,t],arguments.length);let n=a(this,Zt,"f")||a(this,z,"f").require;return a(this,we,"f").addDirectory(e,n,a(this,z,"f").getCallerFile(),t),this}count(e){return D("<array|string>",[e],arguments.length),this[et]("count",e),this[gt](e),this}default(e,t,n){return D("<object|string|array> [*] [string]",[e,t,n],arguments.length),n&&(jn(e,a(this,z,"f")),a(this,L,"f").defaultDescription[e]=n),typeof t=="function"&&(jn(e,a(this,z,"f")),a(this,L,"f").defaultDescription[e]||(a(this,L,"f").defaultDescription[e]=a(this,V,"f").functionDescription(t)),t=t.call()),this[Ot](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){return D("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,r],arguments.length),typeof t!="number"&&(n=t,t=1/0),this.global("_",!1),a(this,L,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(r=>{ve(n,!0,a(this,z,"f")),this.demandOption(r,n)}),t=1/0):typeof t!="number"&&(n=t,t=1/0),typeof e=="number"?(ve(n,!0,a(this,z,"f")),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(r=>{ve(n,!0,a(this,z,"f")),this.demandOption(r,n)}):typeof n=="string"?this.demandOption(e,n):(n===!0||typeof n>"u")&&this.demandOption(e),this}demandOption(e,t){return D("<object|string|array> [string]",[e,t],arguments.length),this[Ot](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return D("<string> [string|boolean]",[e,t],arguments.length),a(this,L,"f").deprecatedOptions[e]=t,this}describe(e,t){return D("<object|string|array> [string]",[e,t],arguments.length),this[Un](e,!0),a(this,V,"f").describe(e,t),this}detectLocale(e){return D("<boolean>",[e],arguments.length),T(this,at,e,"f"),this}env(e){return D("[string|boolean]",[e],arguments.length),e===!1?delete a(this,L,"f").envPrefix:a(this,L,"f").envPrefix=e||"",this}epilogue(e){return D("<string>",[e],arguments.length),a(this,V,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return D("<string|array> [string]",[e,t],arguments.length),Array.isArray(e)?e.forEach(n=>this.example(...n)):a(this,V,"f").example(e,t),this}exit(e,t){T(this,Me,!0,"f"),T(this,Je,t,"f"),a(this,Te,"f")&&a(this,z,"f").process.exit(e)}exitProcess(e=!0){return D("[boolean]",[e],arguments.length),T(this,Te,e,"f"),this}fail(e){if(D("<function|boolean>",[e],arguments.length),typeof e=="boolean"&&e!==!1)throw new ce("Invalid first argument. Expected function or boolean 'false'");return a(this,V,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return D("<array> [function]",[e,t],arguments.length),t?a(this,De,"f").getCompletion(e,t):new Promise((n,r)=>{a(this,De,"f").getCompletion(e,(s,c)=>{s?r(s):n(c)})})}getDemandedOptions(){return D([],0),a(this,L,"f").demandedOptions}getDemandedCommands(){return D([],0),a(this,L,"f").demandedCommands}getDeprecatedOptions(){return D([],0),a(this,L,"f").deprecatedOptions}getDetectLocale(){return a(this,at,"f")}getExitProcess(){return a(this,Te,"f")}getGroups(){return Object.assign({},a(this,He,"f"),a(this,ct,"f"))}getHelp(){if(T(this,Me,!0,"f"),!a(this,V,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[Nt](a(this,Qe,"f"),void 0,void 0,0,!0);if(le(t))return t.then(()=>a(this,V,"f").help())}let e=a(this,we,"f").runDefaultBuilderOn(this);if(le(e))return e.then(()=>a(this,V,"f").help())}return Promise.resolve(a(this,V,"f").help())}getOptions(){return a(this,L,"f")}getStrict(){return a(this,lt,"f")}getStrictCommands(){return a(this,ft,"f")}getStrictOptions(){return a(this,ht,"f")}global(e,t){return D("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1?a(this,L,"f").local=a(this,L,"f").local.filter(n=>e.indexOf(n)===-1):e.forEach(n=>{a(this,L,"f").local.includes(n)||a(this,L,"f").local.push(n)}),this}group(e,t){D("<string|array> <string>",[e,t],arguments.length);let n=a(this,ct,"f")[t]||a(this,He,"f")[t];a(this,ct,"f")[t]&&delete a(this,ct,"f")[t];let r={};return a(this,He,"f")[t]=(n||[]).concat(e).filter(s=>r[s]?!1:r[s]=!0),this}hide(e){return D("<string>",[e],arguments.length),a(this,L,"f").hiddenOptions.push(e),this}implies(e,t){return D("<string|object> [number|string|array]",[e,t],arguments.length),a(this,he,"f").implies(e,t),this}locale(e){return D("[string]",[e],arguments.length),e===void 0?(this[Dn](),a(this,z,"f").y18n.getLocale()):(T(this,at,!1,"f"),a(this,z,"f").y18n.setLocale(e),this)}middleware(e,t,n){return a(this,$e,"f").addMiddleware(e,!!t,n)}nargs(e,t){return D("<string|object|array> [number]",[e,t],arguments.length),this[Ot](this.nargs.bind(this),"narg",e,t),this}normalize(e){return D("<array|string>",[e],arguments.length),this[et]("normalize",e),this}number(e){return D("<array|string>",[e],arguments.length),this[et]("number",e),this[gt](e),this}option(e,t){if(D("<string|object> [object]",[e,t],arguments.length),typeof e=="object")Object.keys(e).forEach(n=>{this.options(n,e[n])});else{typeof t!="object"&&(t={}),this[gt](e),a(this,Ye,"f")&&(e==="version"||t?.alias==="version")&&this[wi](['"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(`
|
|
72
|
+
`),void 0,"versionWarning"),a(this,L,"f").key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let r=t.demand||t.required||t.require;r&&this.demand(e,r),t.demandOption&&this.demandOption(e,typeof t.demandOption=="string"?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),"default"in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type==="boolean")&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type==="array")&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type==="number")&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type==="string")&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type==="count")&&this.count(e),typeof t.global=="boolean"&&this.global(e,t.global),t.defaultDescription&&(a(this,L,"f").defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let s=t.describe||t.description||t.desc,c=a(this,V,"f").getDescriptions();(!Object.prototype.hasOwnProperty.call(c,e)||typeof s=="string")&&this.describe(e,s),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){D("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[xi](),typeof e>"u"&&(e=a(this,Qe,"f")),typeof t=="object"&&(T(this,ut,t,"f"),t=n),typeof t=="function"&&(T(this,Re,t,"f"),t=!1),t||T(this,Qe,e,"f"),a(this,Re,"f")&&T(this,Te,!1,"f");let r=this[Nt](e,!!t),s=this.parsed;return a(this,De,"f").setParsed(this.parsed),le(r)?r.then(c=>(a(this,Re,"f")&&a(this,Re,"f").call(this,a(this,Je,"f"),c,a(this,xe,"f")),c)).catch(c=>{throw a(this,Re,"f")&&a(this,Re,"f")(c,this.parsed.argv,a(this,xe,"f")),c}).finally(()=>{this[Bn](),this.parsed=s}):(a(this,Re,"f")&&a(this,Re,"f").call(this,a(this,Je,"f"),r,a(this,xe,"f")),this[Bn](),this.parsed=s,r)}parseAsync(e,t,n){let r=this.parse(e,t,n);return le(r)?r:Promise.resolve(r)}parseSync(e,t,n){let r=this.parse(e,t,n);if(le(r))throw new ce(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return r}parserConfiguration(e){return D("<object>",[e],arguments.length),T(this,Jt,e,"f"),this}pkgConf(e,t){D("<string> [string]",[e,t],arguments.length);let n=null,r=this[Tn](t||a(this,ot,"f"));return r[e]&&typeof r[e]=="object"&&(n=Mt(r[e],t||a(this,ot,"f"),this[dt]()["deep-merge-config"]||!1,a(this,z,"f")),a(this,L,"f").configObjects=(a(this,L,"f").configObjects||[]).concat(n)),this}positional(e,t){D("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=ke(t,(c,d)=>c==="type"&&!["string","number","boolean"].includes(d)?!1:n.includes(c));let r=a(this,Rt,"f").fullCommands[a(this,Rt,"f").fullCommands.length-1],s=r?a(this,we,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return xt(s).forEach(c=>{let d=s[c];Array.isArray(d)?d.indexOf(e)!==-1&&(t[c]=!0):d[e]&&!(c in t)&&(t[c]=d[e])}),this.group(e,a(this,V,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return D("[boolean]",[e],arguments.length),T(this,Qt,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return D("<array|string|object> [number]",[e],arguments.length),typeof e=="string"&&a(this,L,"f").narg[e]?this:(this[Ot](this.requiresArg.bind(this),"narg",e,NaN),this)}showCompletionScript(e,t){return D("[string] [string]",[e,t],arguments.length),e=e||this.$0,a(this,Et,"f").log(a(this,De,"f").generateCompletionScript(e,t||a(this,Fe,"f")||"completion")),this}showHelp(e){if(D("[string|function]",[e],arguments.length),T(this,Me,!0,"f"),!a(this,V,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[Nt](a(this,Qe,"f"),void 0,void 0,0,!0);if(le(n))return n.then(()=>{a(this,V,"f").showHelp(e)}),this}let t=a(this,we,"f").runDefaultBuilderOn(this);if(le(t))return t.then(()=>{a(this,V,"f").showHelp(e)}),this}return a(this,V,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return D("[boolean|string] [string]",[e,t],arguments.length),a(this,V,"f").showHelpOnFail(e,t),this}showVersion(e){return D("[string|function]",[e],arguments.length),a(this,V,"f").showVersion(e),this}skipValidation(e){return D("<array|string>",[e],arguments.length),this[et]("skipValidation",e),this}strict(e){return D("[boolean]",[e],arguments.length),T(this,lt,e!==!1,"f"),this}strictCommands(e){return D("[boolean]",[e],arguments.length),T(this,ft,e!==!1,"f"),this}strictOptions(e){return D("[boolean]",[e],arguments.length),T(this,ht,e!==!1,"f"),this}string(e){return D("<array|string>",[e],arguments.length),this[et]("string",e),this[gt](e),this}terminalWidth(){return D([],0),a(this,z,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return D("<object>",[e],arguments.length),T(this,at,!1,"f"),a(this,z,"f").y18n.updateLocale(e),this}usage(e,t,n,r){if(D("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,r],arguments.length),t!==void 0){if(ve(e,null,a(this,z,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,r);throw new ce(".usage() description must start with $0 if being used as alias for .command()")}else return a(this,V,"f").usage(e),this}usageConfiguration(e){return D("<object>",[e],arguments.length),T(this,en,e,"f"),this}version(e,t,n){let r="version";if(D("[boolean|string] [string] [string]",[e,t,n],arguments.length),a(this,Ye,"f")&&(this[Nn](a(this,Ye,"f")),a(this,V,"f").version(void 0),T(this,Ye,null,"f")),arguments.length===0)n=this[vi](),e=r;else if(arguments.length===1){if(e===!1)return this;n=e,e=r}else arguments.length===2&&(n=t,t=void 0);return T(this,Ye,typeof e=="string"?e:r,"f"),t=t||a(this,V,"f").deferY18nLookup("Show version number"),a(this,V,"f").version(n||void 0),this.boolean(a(this,Ye,"f")),this.describe(a(this,Ye,"f"),t),this}wrap(e){return D("<number|null|undefined>",[e],arguments.length),a(this,V,"f").wrap(e),this}[(we=new WeakMap,ot=new WeakMap,Rt=new WeakMap,De=new WeakMap,Fe=new WeakMap,qt=new WeakMap,Je=new WeakMap,at=new WeakMap,Kt=new WeakMap,Te=new WeakMap,Xt=new WeakMap,$e=new WeakMap,He=new WeakMap,Me=new WeakMap,Le=new WeakMap,kt=new WeakMap,Et=new WeakMap,xe=new WeakMap,L=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Re=new WeakMap,ut=new WeakMap,vt=new WeakMap,ct=new WeakMap,Qe=new WeakMap,Qt=new WeakMap,z=new WeakMap,lt=new WeakMap,ft=new WeakMap,ht=new WeakMap,V=new WeakMap,en=new WeakMap,Ye=new WeakMap,he=new WeakMap,mi)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch{}return e}[bi](){return{log:(...e)=>{this[tn]()||console.log(...e),T(this,Me,!0,"f"),a(this,xe,"f").length&&T(this,xe,a(this,xe,"f")+`
|
|
73
|
+
`,"f"),T(this,xe,a(this,xe,"f")+e.join(" "),"f")},error:(...e)=>{this[tn]()||console.error(...e),T(this,Me,!0,"f"),a(this,xe,"f").length&&T(this,xe,a(this,xe,"f")+`
|
|
74
|
+
`,"f"),T(this,xe,a(this,xe,"f")+e.join(" "),"f")}}}[Nn](e){xt(a(this,L,"f")).forEach(t=>{if((r=>r==="configObjects")(t))return;let n=a(this,L,"f")[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n=="object"&&delete n[e]}),delete a(this,V,"f").getDescriptions()[e]}[wi](e,t,n){a(this,Kt,"f")[n]||(a(this,z,"f").process.emitWarning(e,t),a(this,Kt,"f")[n]=!0)}[xi](){a(this,Xt,"f").push({options:a(this,L,"f"),configObjects:a(this,L,"f").configObjects.slice(0),exitProcess:a(this,Te,"f"),groups:a(this,He,"f"),strict:a(this,lt,"f"),strictCommands:a(this,ft,"f"),strictOptions:a(this,ht,"f"),completionCommand:a(this,Fe,"f"),output:a(this,xe,"f"),exitError:a(this,Je,"f"),hasOutput:a(this,Me,"f"),parsed:this.parsed,parseFn:a(this,Re,"f"),parseContext:a(this,ut,"f")}),a(this,V,"f").freeze(),a(this,he,"f").freeze(),a(this,we,"f").freeze(),a(this,$e,"f").freeze()}[yi](){let e="",t;return/\b(node|iojs|electron)(\.exe)?$/.test(a(this,z,"f").process.argv()[0])?t=a(this,z,"f").process.argv().slice(1,2):t=a(this,z,"f").process.argv().slice(0,1),e=t.map(n=>{let r=this[Ri](a(this,ot,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<n.length?r:n}).join(" ").trim(),a(this,z,"f").getEnv("_")&&a(this,z,"f").getProcessArgvBin()===a(this,z,"f").getEnv("_")&&(e=a(this,z,"f").getEnv("_").replace(`${a(this,z,"f").path.dirname(a(this,z,"f").process.execPath())}/`,"")),e}[dt](){return a(this,Jt,"f")}[Ei](){return a(this,en,"f")}[Dn](){if(!a(this,at,"f"))return;let e=a(this,z,"f").getEnv("LC_ALL")||a(this,z,"f").getEnv("LC_MESSAGES")||a(this,z,"f").getEnv("LANG")||a(this,z,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[vi](){return this[Tn]().version||"unknown"}[Oi](e){let t=e["--"]?e["--"]:e._;for(let n=0,r;(r=t[n])!==void 0;n++)a(this,z,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`)))&&(t[n]=Number(r));return e}[Tn](e){let t=e||"*";if(a(this,vt,"f")[t])return a(this,vt,"f")[t];let n={};try{let r=e||a(this,z,"f").mainFilename;!e&&a(this,z,"f").path.extname(r)&&(r=a(this,z,"f").path.dirname(r));let s=a(this,z,"f").findUp(r,(c,d)=>{if(d.includes("package.json"))return"package.json"});ve(s,void 0,a(this,z,"f")),n=JSON.parse(a(this,z,"f").readFileSync(s,"utf8"))}catch{}return a(this,vt,"f")[t]=n||{},a(this,vt,"f")[t]}[et](e,t){t=[].concat(t),t.forEach(n=>{n=this[Wn](n),a(this,L,"f")[e].push(n)})}[Ot](e,t,n,r){this[Ln](e,t,n,r,(s,c,d)=>{a(this,L,"f")[s][c]=d})}[$n](e,t,n,r){this[Ln](e,t,n,r,(s,c,d)=>{a(this,L,"f")[s][c]=(a(this,L,"f")[s][c]||[]).concat(d)})}[Ln](e,t,n,r,s){if(Array.isArray(n))n.forEach(c=>{e(c,r)});else if((c=>typeof c=="object")(n))for(let c of xt(n))e(c,n[c]);else s(t,this[Wn](n),r)}[Wn](e){return e==="__proto__"?"___proto___":e}[Un](e,t){return this[Ot](this[Un].bind(this),"key",e,t),this}[Bn](){var e,t,n,r,s,c,d,b,y,E,w,f;let _=a(this,Xt,"f").pop();ve(_,void 0,a(this,z,"f"));let F;e=this,t=this,n=this,r=this,s=this,c=this,d=this,b=this,y=this,E=this,w=this,f=this,{options:{set value(S){T(e,L,S,"f")}}.value,configObjects:F,exitProcess:{set value(S){T(t,Te,S,"f")}}.value,groups:{set value(S){T(n,He,S,"f")}}.value,output:{set value(S){T(r,xe,S,"f")}}.value,exitError:{set value(S){T(s,Je,S,"f")}}.value,hasOutput:{set value(S){T(c,Me,S,"f")}}.value,parsed:this.parsed,strict:{set value(S){T(d,lt,S,"f")}}.value,strictCommands:{set value(S){T(b,ft,S,"f")}}.value,strictOptions:{set value(S){T(y,ht,S,"f")}}.value,completionCommand:{set value(S){T(E,Fe,S,"f")}}.value,parseFn:{set value(S){T(w,Re,S,"f")}}.value,parseContext:{set value(S){T(f,ut,S,"f")}}.value}=_,a(this,L,"f").configObjects=F,a(this,V,"f").unfreeze(),a(this,he,"f").unfreeze(),a(this,we,"f").unfreeze(),a(this,$e,"f").unfreeze()}[_i](e,t){return st(t,n=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[Si].bind(this),getContext:this[Ci].bind(this),getHasOutput:this[Ai].bind(this),getLoggerInstance:this[ji].bind(this),getParseContext:this[Pi].bind(this),getParserConfiguration:this[dt].bind(this),getUsageConfiguration:this[Ei].bind(this),getUsageInstance:this[Ii].bind(this),getValidationInstance:this[Fi].bind(this),hasParseCallback:this[tn].bind(this),isGlobalContext:this[Mi].bind(this),postProcess:this[pt].bind(this),reset:this[Gn].bind(this),runValidation:this[zn].bind(this),runYargsParserAndExecuteCommands:this[Nt].bind(this),setHasOutput:this[Ni].bind(this)}}[Si](){return a(this,we,"f")}[Ci](){return a(this,Rt,"f")}[Ai](){return a(this,Me,"f")}[ji](){return a(this,Et,"f")}[Pi](){return a(this,ut,"f")||{}}[Ii](){return a(this,V,"f")}[Fi](){return a(this,he,"f")}[tn](){return!!a(this,Re,"f")}[Mi](){return a(this,kt,"f")}[pt](e,t,n,r){return n||le(e)||(t||(e=this[mi](e)),(this[dt]()["parse-positional-numbers"]||this[dt]()["parse-positional-numbers"]===void 0)&&(e=this[Oi](e)),r&&(e=it(e,this,a(this,$e,"f").getMiddleware(),!1))),e}[Gn](e={}){T(this,L,a(this,L,"f")||{},"f");let t={};t.local=a(this,L,"f").local||[],t.configObjects=a(this,L,"f").configObjects||[];let n={};t.local.forEach(c=>{n[c]=!0,(e[c]||[]).forEach(d=>{n[d]=!0})}),Object.assign(a(this,ct,"f"),Object.keys(a(this,He,"f")).reduce((c,d)=>{let b=a(this,He,"f")[d].filter(y=>!(y in n));return b.length>0&&(c[d]=b),c},{})),T(this,He,{},"f");let r=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],s=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];return r.forEach(c=>{t[c]=(a(this,L,"f")[c]||[]).filter(d=>!n[d])}),s.forEach(c=>{t[c]=ke(a(this,L,"f")[c],d=>!n[d])}),t.envPrefix=a(this,L,"f").envPrefix,T(this,L,t,"f"),T(this,V,a(this,V,"f")?a(this,V,"f").reset(n):ui(this,a(this,z,"f")),"f"),T(this,he,a(this,he,"f")?a(this,he,"f").reset(n):pi(this,a(this,V,"f"),a(this,z,"f")),"f"),T(this,we,a(this,we,"f")?a(this,we,"f").reset():si(a(this,V,"f"),a(this,he,"f"),a(this,$e,"f"),a(this,z,"f")),"f"),a(this,De,"f")||T(this,De,fi(this,a(this,V,"f"),a(this,we,"f"),a(this,z,"f")),"f"),a(this,$e,"f").reset(),T(this,Fe,null,"f"),T(this,xe,"","f"),T(this,Je,null,"f"),T(this,Me,!1,"f"),this.parsed=!1,this}[Ri](e,t){return a(this,z,"f").path.relative(e,t)}[Nt](e,t,n,r=0,s=!1){let c=!!n||s;e=e||a(this,Qe,"f"),a(this,L,"f").__=a(this,z,"f").y18n.__,a(this,L,"f").configuration=this[dt]();let d=!!a(this,L,"f").configuration["populate--"],b=Object.assign({},a(this,L,"f").configuration,{"populate--":!0}),y=a(this,z,"f").Parser.detailed(e,Object.assign({},a(this,L,"f"),{configuration:{"parse-positional-numbers":!1,...b}})),E=Object.assign(y.argv,a(this,ut,"f")),w,f=y.aliases,_=!1,F=!1;Object.keys(E).forEach(S=>{S===a(this,Le,"f")&&E[S]?_=!0:S===a(this,Ye,"f")&&E[S]&&(F=!0)}),E.$0=this.$0,this.parsed=y,r===0&&a(this,V,"f").clearCachedHelpMessage();try{if(this[Dn](),t)return this[pt](E,d,!!n,!1);a(this,Le,"f")&&[a(this,Le,"f")].concat(f[a(this,Le,"f")]||[]).filter(X=>X.length>1).includes(""+E._[E._.length-1])&&(E._.pop(),_=!0),T(this,kt,!1,"f");let S=a(this,we,"f").getCommands(),x=a(this,De,"f").completionKey in E,B=_||x||s;if(E._.length){if(S.length){let G;for(let X=r||0,K;E._[X]!==void 0;X++)if(K=String(E._[X]),S.includes(K)&&K!==a(this,Fe,"f")){let k=a(this,we,"f").runCommand(K,this,y,X+1,s,_||F||s);return this[pt](k,d,!!n,!1)}else if(!G&&K!==a(this,Fe,"f")){G=K;break}!a(this,we,"f").hasDefaultCommand()&&a(this,Qt,"f")&&G&&!B&&a(this,he,"f").recommendCommands(G,S)}a(this,Fe,"f")&&E._.includes(a(this,Fe,"f"))&&!x&&(a(this,Te,"f")&&Ze(!0),this.showCompletionScript(),this.exit(0))}if(a(this,we,"f").hasDefaultCommand()&&!B){let G=a(this,we,"f").runCommand(null,this,y,0,s,_||F||s);return this[pt](G,d,!!n,!1)}if(x){a(this,Te,"f")&&Ze(!0),e=[].concat(e);let G=e.slice(e.indexOf(`--${a(this,De,"f").completionKey}`)+1);return a(this,De,"f").getCompletion(G,(X,K)=>{if(X)throw new ce(X.message);(K||[]).forEach(k=>{a(this,Et,"f").log(k)}),this.exit(0)}),this[pt](E,!d,!!n,!1)}if(a(this,Me,"f")||(_?(a(this,Te,"f")&&Ze(!0),c=!0,this.showHelp("log"),this.exit(0)):F&&(a(this,Te,"f")&&Ze(!0),c=!0,a(this,V,"f").showVersion("log"),this.exit(0))),!c&&a(this,L,"f").skipValidation.length>0&&(c=Object.keys(E).some(G=>a(this,L,"f").skipValidation.indexOf(G)>=0&&E[G]===!0)),!c){if(y.error)throw new ce(y.error.message);if(!x){let G=this[zn](f,{},y.error);n||(w=it(E,this,a(this,$e,"f").getMiddleware(),!0)),w=this[_i](G,w??E),le(w)&&!n&&(w=w.then(()=>it(E,this,a(this,$e,"f").getMiddleware(),!1)))}}}catch(S){if(S instanceof ce)a(this,V,"f").fail(S.message,S);else throw S}return this[pt](w??E,d,!!n,!0)}[zn](e,t,n,r){let s={...this.getDemandedOptions()};return c=>{if(n)throw new ce(n.message);a(this,he,"f").nonOptionCount(c),a(this,he,"f").requiredArguments(c,s);let d=!1;a(this,ft,"f")&&(d=a(this,he,"f").unknownCommands(c)),a(this,lt,"f")&&!d?a(this,he,"f").unknownArguments(c,e,t,!!r):a(this,ht,"f")&&a(this,he,"f").unknownArguments(c,e,{},!1,!1),a(this,he,"f").limitedChoices(c),a(this,he,"f").implications(c),a(this,he,"f").conflicting(c)}}[Ni](){T(this,Me,!0,"f")}[gt](e){if(typeof e=="string")a(this,L,"f").key[e]=!0;else for(let t of e)a(this,L,"f").key[t]=!0}};function oi(i){return!!i&&typeof i.getInternalMethods=="function"}var Ka=Di(An),Ti=Ka;await Ti(Sn(process.argv)).command("$0 <file-or-url>",'Convert a tldraw ".tldr" file or tldraw.com URL to an svg or png image',i=>i.scriptName("tldraw-cli").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:!1,describe:"Output an image with a transparent background",type:"boolean"}).option("dark-mode",{alias:"d",default:!1,describe:"Output a dark theme version of the image",type:"boolean"}).option("frames",{coerce(e){return e.length===0?!0:e},defaultDescription:"false",describe:'Export each sketch "frame" as a separate image, use the option flag alone to export all frames, or pass one or more frame names or IDs',type:"array"}).option("verbose",{default:!1,describe:"Enable verbose output",type:"boolean"}),async i=>{let{darkMode:e,fileOrUrl:t,format:n,frames:r,output:s,transparent:c,verbose:d}=i;try{await Dr(t,{darkMode:e,format:n,frames:r,output:s,transparent:c,verbose:d}),process.exit(0)}catch(b){console.error("Conversion failed:",b),process.exit(1)}}).alias("h","help").version("version",Or).alias("v","version").help().parse();
|
|
69
75
|
/*! Bundled license information:
|
|
70
76
|
|
|
77
|
+
voca/index.js:
|
|
78
|
+
(*!
|
|
79
|
+
* Voca string library 1.4.1
|
|
80
|
+
* https://vocajs.pages.dev
|
|
81
|
+
*
|
|
82
|
+
* Copyright Dmitri Pavlutin and other contributors
|
|
83
|
+
* Released under the MIT license
|
|
84
|
+
*)
|
|
85
|
+
|
|
71
86
|
yargs-parser/build/lib/string-utils.js:
|
|
72
87
|
(**
|
|
73
88
|
* @license
|
package/dist/lib/index.js
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import F from"node:path";import{fileURLToPath as V}from"node:url";import q,{promises as H}from"fs";async function P(e,o,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return(await H[e](r))[o]()}catch(t){if(t.code==="ENOENT")return!1;throw t}}function x(e,o,r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);try{return q[e](r)[o]()}catch(t){if(t.code==="ENOENT")return!1;throw t}}var de=P.bind(null,"stat","isFile"),fe=P.bind(null,"stat","isDirectory"),ue=P.bind(null,"lstat","isSymbolicLink"),R=x.bind(null,"statSync","isFile"),pe=x.bind(null,"statSync","isDirectory"),me=x.bind(null,"lstatSync","isSymbolicLink");import z from"node:os";var O=z.homedir();function w(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return O?e.replace(/^~(?=$|\/|\\)/,O):e}function S(e,o={}){let{requireFileExistence:r,validFileExtensions:t,validHostnames:n}=o;if(URL.canParse(e)){let l=new URL(e);if(l.protocol==="file:")return S(V(l),o);if(n&&!n.includes(l.hostname))throw new Error(`Bad input URL. Only ${n.join(", ")} URLs are supported.`);return l}let i=w(e),c=F.normalize(i);if(r&&!R(c))throw new Error("Input is not a file.");let s=F.extname(c);if(t&&!t.includes(s))throw new Error(`Bad input file name. Only ${t.join(", ")} files are supported.`);return c}import U from"express";import _ from"node:net";import G from"node:os";var b=class extends Error{constructor(o){super(`${o} is locked`)}},u={old:new Set,young:new Set},J=1e3*15;var g,K=()=>{let e=G.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},L=e=>new Promise((o,r)=>{let t=_.createServer();t.unref(),t.on("error",r),t.listen(e,()=>{let{port:n}=t.address();t.close(()=>{o(n)})})}),N=async(e,o)=>{if(e.host||e.port===0)return L(e);for(let r of o)try{await L({port:e.port,host:r})}catch(t){if(!["EADDRNOTAVAIL","EINVAL"].includes(t.code))throw t}return e.port},Q=function*(e){e&&(yield*e),yield 0};async function E(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 i of n){if(typeof i!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(i))throw new TypeError(`Number ${i} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}g===void 0&&(g=setTimeout(()=>{g=void 0,u.old=u.young,u.young=new Set},J),g.unref&&g.unref());let t=K();for(let n of Q(o))try{if(r.has(n))continue;let i=await N({...e,port:n},t);for(;u.old.has(i)||u.young.has(i);){if(n!==0)throw new b(n);i=await N({...e,port:n},t)}return u.young.add(i),i}catch(i){if(!["EADDRINUSE","EACCES"].includes(i.code)&&!(i instanceof b))throw i}throw new Error("No available ports found")}import M from"node:fs/promises";import A from"node:os";import p from"node:path";import{dirname as W}from"node:path";import{fileURLToPath as X}from"node:url";import Y from"puppeteer";var Z={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!1};async function ee(e,o={}){let r={...Z,...ie(o)},{darkMode:t,format:n,output:i,transparent:c,verbose:s}=r,l=S(e,{requireFileExistence:!0,validFileExtensions:[".tldr"],validHostnames:["www.tldraw.com"]}),f=typeof l=="string";s&&console.log(f?"Local file detected":"tldraw URL detected");let h=0,y;if(f){s&&console.log("Starting tldraw server...");let m=W(X(import.meta.url)),d=p.join(m,m.endsWith("/src/lib")?"../../dist/tldraw":m.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");s&&console.log(`tldraw served from "${d}"`),y=await oe(d),h=y.address().port,s&&console.log(`tldraw hosted at "http://localhost:${h}"`)}s&&console.log("Starting Puppeteer...");let $=await Y.launch({args:f?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),a=await $.newPage();te(a,s);let k=await a.target().createCDPSession();if(await k.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:A.tmpdir(),eventsEnabled:!0}),f){await a.setRequestInterception(!0),a.on("request",d=>{d.url().endsWith("favicon.ico")?d.respond({status:200}):d.continue()}),s&&console.log(`Loading tldr file "${l}"`);let m=await M.readFile(l,"utf8");await a.evaluateOnNewDocument(d=>{localStorage.clear(),localStorage.setItem("tldrData",d)},m)}let D=f?`http://localhost:${h}`:l.href;s&&console.log(`Navigating to: ${D}`),await a.goto(D,{waitUntil:"networkidle0"}),s&&console.log(`Setting background transparency: ${c}`),await le(a,c),s&&console.log(`Setting dark mode: ${t}`);let I=await ae(a);await B(a,t),s&&console.log("Requesting download"),await se(a),await ne(a,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${n}`]);let T=await re(k);s&&console.log("Download complete"),s&&console.log(`Restoring dark mode: ${I}`),await B(a,I),await $.close(),s&&console.log("Stopped Puppeteer"),f&&y&&(y.close(),s&&console.log("Stopped tldraw server"));let j=f?p.basename(l,p.extname(l)):T,C=p.join(A.tmpdir(),T),v=w(p.join(i,`${j}.${n}`));return await M.rename(C,v),s&&console.log(`Saved to "${v}"`),p.resolve(v)}function te(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 oe(e){let o=U(),r=await E();return o.use(U.static(e)),new Promise((t,n)=>{let i=o.listen(r,()=>{t(i)});i.on("error",c=>{n(c)})})}async function re(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 ne(e,o){for(let r of o)await e.waitForSelector(`[data-testid="${r}"]`),await e.click(`[data-testid="${r}"]`)}function ie(e){return Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0))}async function se(e){await e.evaluate("app.clearOpenMenus()")}async function ae(e){return!!await e.evaluate("editor.user.getUserPreferences().isDarkMode")}async function B(e,o){await e.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${o}})`)}async function le(e,o){await e.evaluate(`editor.updateInstanceState(
|
|
2
|
-
|
|
1
|
+
var Pu=Object.create;var fr=Object.defineProperty;var Ru=Object.getOwnPropertyDescriptor;var Iu=Object.getOwnPropertyNames;var Fu=Object.getPrototypeOf,_u=Object.prototype.hasOwnProperty;var Du=(o,c)=>()=>(c||o((c={exports:{}}).exports,c),c.exports);var Ou=(o,c,l,f)=>{if(c&&typeof c=="object"||typeof c=="function")for(let g of Iu(c))!_u.call(o,g)&&g!==l&&fr(o,g,{get:()=>c[g],enumerable:!(f=Ru(c,g))||f.enumerable});return o};var Nu=(o,c,l)=>(l=o!=null?Pu(Fu(o)):{},Ou(c||!o||!o.__esModule?fr(l,"default",{value:o,enumerable:!0}):l,o));var hr=Du((Pe,Re)=>{(function(o,c){typeof Pe=="object"&&typeof Re<"u"?Re.exports=c():typeof define=="function"&&define.amd?define(c):(o=o||self,o.v=c())})(Pe,function(){"use strict";function o(){return o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u])}return e},o.apply(this,arguments)}function c(e,r){return g(e)||F(e,r)||h()}function l(e){return f(e)||b(e)||U()}function f(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}function g(e){if(Array.isArray(e))return e}function b(e){if(Symbol.iterator in Object(e)||Object.prototype.toString.call(e)==="[object Arguments]")return Array.from(e)}function F(e,r){if(Symbol.iterator in Object(e)||Object.prototype.toString.call(e)==="[object Arguments]"){var t=[],u=!0,n=!1,i=void 0;try{for(var s=e[Symbol.iterator](),m;!(u=(m=s.next()).done)&&(t.push(m.value),!(r&&t.length===r));u=!0);}catch(p){n=!0,i=p}finally{try{!u&&s.return!=null&&s.return()}finally{if(n)throw i}}return t}}function U(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function h(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function d(e){return e==null}function L(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return d(e)?r:!!e}function M(e){return typeof e=="string"}function a(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return d(e)?r:M(e)?e:String(e)}function H(e,r){var t=a(e),u=L(r);return t===""?"":(u&&(t=t.toLowerCase()),t.substr(0,1).toUpperCase()+t.substr(1))}function W(e){var r=a(e,"");return r.toLowerCase()}var S="\\d",X="\\s\\uFEFF\\xA0",O="\\uD800-\\uDBFF",N="\\uDC00-\\uDFFF",j="\\u0300-\\u036F\\u1AB0-\\u1AFF\\u1DC0-\\u1DFF\\u20D0-\\u20FF\\uFE20-\\uFE2F",z="\\0-\\u02FF\\u0370-\\u1AAF\\u1B00-\\u1DBF\\u1E00-\\u20CF\\u2100-\\uD7FF\\uE000-\\uFE1F\\uFE30-\\uFFFF",B=new RegExp("(["+z+"]|["+O+"]["+N+"]|["+O+"](?!["+N+"])|(?:[^"+O+"]|^)["+N+"])(["+j+"]+)","g"),_=new RegExp("(["+O+"])(["+N+"])","g"),y=new RegExp("((?:["+z+"]|["+O+"]["+N+"]|["+O+"](?!["+N+"])|(?:[^"+O+"]|^)["+N+"])(?:["+j+"]+))|(["+O+"]["+N+"])|([\\n\\r\\u2028\\u2029])|(.)","g"),ae=new RegExp("["+X+"]"),de=new RegExp("^["+X+"]+"),C=new RegExp("["+X+"]+$"),V=new RegExp("^"+S+"+$"),Y=/[-[\]{}()*+!<=:?./\\^$|#,]/g,Fe=/[^A-Za-z0-9]/g,Sr=/[<>&"'`]/g,yr=/(%{1,2})(?:(\d+)\$)?(\+)?([ 0]|'.{1})?(-)?(\d+)?(?:\.(\d+))?([bcdiouxXeEfgGs])?/g,Ar=/\.?0+$/g,Cr=/<([A-Za-z0-9]+)>/g,Tr="\\u2000-\\u206F",Pr="\\x00-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7b-\\xBF\\xD7\\xF7",Rr="\\u2700-\\u27BF",ie="a-z\\xB5\\xDF-\\xF6\\xF8-\\xFF\\u0101\\u0103\\u0105\\u0107\\u0109\\u010B\\u010D\\u010F\\u0111\\u0113\\u0115\\u0117\\u0119\\u011B\\u011D\\u011F\\u0121\\u0123\\u0125\\u0127\\u0129\\u012B\\u012D\\u012F\\u0131\\u0133\\u0135\\u0137\\u0138\\u013A\\u013C\\u013E\\u0140\\u0142\\u0144\\u0146\\u0148\\u0149\\u014B\\u014D\\u014F\\u0151\\u0153\\u0155\\u0157\\u0159\\u015B\\u015D\\u015F\\u0161\\u0163\\u0165\\u0167\\u0169\\u016B\\u016D\\u016F\\u0171\\u0173\\u0175\\u0177\\u017A\\u017C\\u017E-\\u0180\\u0183\\u0185\\u0188\\u018C\\u018D\\u0192\\u0195\\u0199-\\u019B\\u019E\\u01A1\\u01A3\\u01A5\\u01A8\\u01AA\\u01AB\\u01AD\\u01B0\\u01B4\\u01B6\\u01B9\\u01BA\\u01BD-\\u01BF\\u01C6\\u01C9\\u01CC\\u01CE\\u01D0\\u01D2\\u01D4\\u01D6\\u01D8\\u01DA\\u01DC\\u01DD\\u01DF\\u01E1\\u01E3\\u01E5\\u01E7\\u01E9\\u01EB\\u01ED\\u01EF\\u01F0\\u01F3\\u01F5\\u01F9\\u01FB\\u01FD\\u01FF\\u0201\\u0203\\u0205\\u0207\\u0209\\u020B\\u020D\\u020F\\u0211\\u0213\\u0215\\u0217\\u0219\\u021B\\u021D\\u021F\\u0221\\u0223\\u0225\\u0227\\u0229\\u022B\\u022D\\u022F\\u0231\\u0233-\\u0239\\u023C\\u023F\\u0240\\u0242\\u0247\\u0249\\u024B\\u024D\\u024F",oe="\\x41-\\x5a\\xc0-\\xd6\\xd8-\\xde\\u0100\\u0102\\u0104\\u0106\\u0108\\u010a\\u010c\\u010e\\u0110\\u0112\\u0114\\u0116\\u0118\\u011a\\u011c\\u011e\\u0120\\u0122\\u0124\\u0126\\u0128\\u012a\\u012c\\u012e\\u0130\\u0132\\u0134\\u0136\\u0139\\u013b\\u013d\\u013f\\u0141\\u0143\\u0145\\u0147\\u014a\\u014c\\u014e\\u0150\\u0152\\u0154\\u0156\\u0158\\u015a\\u015c\\u015e\\u0160\\u0162\\u0164\\u0166\\u0168\\u016a\\u016c\\u016e\\u0170\\u0172\\u0174\\u0176\\u0178\\u0179\\u017b\\u017d\\u0181\\u0182\\u0184\\u0186\\u0187\\u0189-\\u018b\\u018e-\\u0191\\u0193\\u0194\\u0196-\\u0198\\u019c\\u019d\\u019f\\u01a0\\u01a2\\u01a4\\u01a6\\u01a7\\u01a9\\u01ac\\u01ae\\u01af\\u01b1-\\u01b3\\u01b5\\u01b7\\u01b8\\u01bc\\u01c4\\u01c5\\u01c7\\u01c8\\u01ca\\u01cb\\u01cd\\u01cf\\u01d1\\u01d3\\u01d5\\u01d7\\u01d9\\u01db\\u01de\\u01e0\\u01e2\\u01e4\\u01e6\\u01e8\\u01ea\\u01ec\\u01ee\\u01f1\\u01f2\\u01f4\\u01f6-\\u01f8\\u01fa\\u01fc\\u01fe\\u0200\\u0202\\u0204\\u0206\\u0208\\u020a\\u020c\\u020e\\u0210\\u0212\\u0214\\u0216\\u0218\\u021a\\u021c\\u021e\\u0220\\u0222\\u0224\\u0226\\u0228\\u022a\\u022c\\u022e\\u0230\\u0232\\u023a\\u023b\\u023d\\u023e\\u0241\\u0243-\\u0246\\u0248\\u024a\\u024c\\u024e",ge=new RegExp("(?:["+oe+"]["+j+"]*)?(?:["+ie+"]["+j+"]*)+|(?:["+oe+"]["+j+"]*)+(?!["+ie+"])|["+S+"]+|["+Rr+"]|[^"+Pr+Tr+X+"]+","g"),pe=/[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g,Ir=new RegExp("^(?:["+ie+oe+"]["+j+"]*)+$"),Fr=new RegExp("^((?:["+ie+oe+"]["+j+"]*)|["+S+"])+$"),ve=/^[\x01-\xFF]*$/;function Z(e,r){return e??r}function $(e){return d(e)?null:M(e)?e:String(e)}function ee(e,r,t){var u=a(e),n;if(d(r))n=ve.test(u)?pe:ge;else if(r instanceof RegExp)n=r;else{var i=$(Z(t,""));n=new RegExp($(r),i)}return Z(u.match(n),[])}function _r(e,r){return r===0?W(e):H(e,!0)}function Dr(e){var r=a(e);return r===""?"":ee(r).map(_r).join("")}function Or(e){var r=a(e);return r===""?"":r.substr(0,1).toLowerCase()+r.substr(1)}function _e(e){var r=a(e);return r===""?"":ee(r).map(W).join("-")}function Nr(e){var r=a(e);return r===""?"":ee(r).map(W).join("_")}function Lr(e){var r=a(e);return r.toUpperCase()}function jr(e){var r=a(e);return r.split("").reduce(kr,"")}function kr(e,r){var t=r.toLowerCase(),u=r.toUpperCase();return e+(r===t?u:t)}function Br(e,r){var t=a(e),u=Array.isArray(r)?r:[],n=ve.test(t)?pe:ge;return t.replace(n,function(i,s){var m=s>0&&u.indexOf(t[s-1])>=0;return m?i.toLowerCase():H(i,!0)})}function D(e,r,t){return e<=r?r:e>=t?t:e}var k=9007199254740991;function T(e){return e===1/0?k:e===-1/0?-k:~~e}function De(e,r,t){var u=a(e),n=d(r)?u.length:D(T(r),0,k),i=a(t,"...");return n>=u.length?u:u.substr(0,r-i.length)+i}function $r(e,r){var t=a(e);return t.charAt(r)}var Oe=55296,Gr=56319,Ne=56320,Ur=57343;function Mr(e){return e>=Oe&&e<=Gr}function Hr(e){return e>=Ne&&e<=Ur}function Xr(e,r){return(e-Oe)*1024+r-Ne+65536}function G(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return d(e)?r:typeof e=="number"?e:Number(e)}function Le(e,r){return e!==e?r:e}function je(e,r){var t=a(e),u=t.length,n=G(r);if(n=Le(n,0),!(n<0||n>=u)){var i=t.charCodeAt(n),s;return Mr(i)&&u>n+1&&(s=t.charCodeAt(n+1),Hr(s))?Xr(i,s):i}}function Yr(e,r){var t=a(e),u=d(r)?1:D(T(r),0,k);return t.length<=u?t:t.substr(0,u)}function Wr(e,r){var t=a(e),u=G(r),n,i=0;for(u=Le(u,0);(n=y.exec(t))!==null;){if(i===u)return y.lastIndex=0,n[0];i++}return""}function zr(e,r){var t=a(e),u=d(r)?1:D(T(r),0,k);return t.length<=u?t:t.substr(t.length-u,u)}function qr(e,r,t){var u=a(e),n=d(r)?u.length:D(T(r),0,k),i=a(t,"...");if(n>=u.length)return u;var s=ve.test(u)?pe:ge,m=0;return u.replace(s,function(p,E){var v=E+p.length;v<=n-i.length&&(m=v)}),u.substr(0,m)+i}function Vr(e,r,t){return a(e).slice(r,t)}function Zr(e,r,t){return a(e).substr(r,t)}function Jr(e,r,t){return a(e).substring(r,t)}function Kr(e){return a(e).length}function Qr(e){return a(e).replace(B,"*").replace(_,"*").length}function et(e,r){var t=a(e),u=a(r),n=u.length,i=0,s=0;if(t===""||u==="")return i;do s=t.indexOf(u,s),s!==-1&&(i++,s+=n);while(s!==-1);return i}var rt=Array.prototype.reduce;function tt(e,r,t){var u=a(e);if(u===""||typeof r!="function")return 0;var n=r.bind(t);return rt.call(u,function(i,s,m){return n(s,m,u)?i+1:i},0)}function ut(e,r,t){return ee(e,r,t).length}function se(){this.index=0}se.prototype.increment=function(){this.index++},se.prototype.incrementOnEmptyPosition=function(e){d(e)&&this.increment()},se.prototype.getIndexByPosition=function(e){return d(e)?this.index:e-1};var nt="i",ke="b",Be="c",at="d",$e="o",it="u",Ge="x",Ue="X",Me="e",He="E",Xe="f",Ye="g",he="G",ot="s",st="'",We="+",ct="-",ft="%%",lt=2,dt=8,ze=16;function qe(e,r){for(var t=a(e),u=d(r)?1:D(T(r),0,k),n="";u;)u&1&&(n+=t),u>1&&(t+=t),u>>=1;return n}function ce(e,r){var t=T(r/e.length),u=r%e.length;return qe(e,t+u).substr(0,r)}function Ve(e,r,t){var u=a(e),n=d(r)?0:D(T(r),0,k),i=a(t," ");return n<=u.length?u:ce(i,n-u.length)+u}function Ze(e,r,t){var u=a(e),n=d(r)?0:D(T(r),0,k),i=a(t," ");return n<=u.length?u:u+ce(i,n-u.length)}function gt(e,r){var t=r.width;if(d(t)||e.length>=t)return e;var u=r.alignmentSpecifier===ct?Ze:Ve;return u(e,t,r.getPaddingCharacter())}function Je(e,r,t){return t.signSpecifier===We&&e>=0&&(r=We+r),r}function pt(e,r){var t=parseFloat(e),u;isNaN(t)&&(t=0);var n=G(r.precision,6);switch(r.typeSpecifier){case Xe:u=t.toFixed(n);break;case Me:u=t.toExponential(n);break;case He:u=t.toExponential(n).toUpperCase();break;case Ye:case he:u=vt(t,n,r);break}return u=Je(t,u,r),a(u)}function vt(e,r,t){if(e===0)return"0";var u=r===0?1:r,n=e.toPrecision(u).replace(Ar,"");return t.typeSpecifier===he&&(n=n.toUpperCase()),n}function ht(e,r){var t=parseInt(e);switch(isNaN(t)&&(t=0),t=t>>>0,r.typeSpecifier){case Be:t=String.fromCharCode(t);break;case ke:t=t.toString(lt);break;case $e:t=t.toString(dt);break;case Ge:t=t.toString(ze);break;case Ue:t=t.toString(ze).toUpperCase();break}return a(t)}function mt(e,r){var t=parseInt(e);return isNaN(t)&&(t=0),Je(t,$(t),r)}function bt(e,r){var t=e,u=r.precision;return!d(u)&&t.length>u&&(t=De(t,u,"")),t}function xt(e,r){var t;switch(r.typeSpecifier){case ot:t=bt;break;case at:case nt:t=mt;break;case Be:case ke:case $e:case Ge:case Ue:case it:t=ht;break;case Xe:case Me:case He:case Ye:case he:t=pt;break}var u=t(e,r);return gt(u,r)}function me(e){this.percent=e.percent,this.signSpecifier=e.signSpecifier,this.paddingSpecifier=e.paddingSpecifier,this.alignmentSpecifier=e.alignmentSpecifier,this.width=e.width,this.precision=e.precision,this.typeSpecifier=e.typeSpecifier}me.prototype.isPercentLiteral=function(){return ft===this.percent},me.prototype.getPaddingCharacter=function(){var e=Z(this.paddingSpecifier," ");return e.length===2&&e[0]===st&&(e=e[1]),e};function wt(e,r,t){if(d(t.typeSpecifier))throw new Error("sprintf(): Unknown type specifier");if(e>r-1)throw new Error("sprintf(): Too few arguments");if(e<0)throw new Error("sprintf(): Argument number must be greater than zero")}function Et(e,r,t,u,n,i,s,m,p,E,v){var x=new me({percent:u,signSpecifier:i,paddingSpecifier:s,alignmentSpecifier:m,width:G(p,null),precision:G(E,null),typeSpecifier:v});if(x.isPercentLiteral())return t.slice(1);var w=e.getIndexByPosition(n);return e.incrementOnEmptyPosition(n),wt(w,r.length,x),xt(r[w],x)}function Ke(e){var r=a(e);if(r==="")return r;for(var t=arguments.length,u=new Array(t>1?t-1:0),n=1;n<t;n++)u[n-1]=arguments[n];var i=Et.bind(void 0,new se,u);return r.replace(yr,i)}function St(e,r){return Ke.apply(void 0,[e].concat(l(Z(r,[]))))}var yt={"<":"<",">":">","&":"&",'"':""","'":"'","`":"`"};function At(e){return yt[e]}function Ct(e){return a(e).replace(Sr,At)}function Tt(e){return a(e).replace(Y,"\\$&")}var Qe={"<":/(<)|(�*3c;)|(�*60;)/gi,">":/(>)|(�*3e;)|(�*62;)/gi,"&":/(&)|(�*26;)|(�*38;)/gi,'"':/(")|(�*22;)|(�*34;)/gi,"'":/(�*27;)|(�*39;)/gi,"`":/(�*60;)|(�*96;)/gi},Pt=Object.keys(Qe);function Rt(e,r){return e.replace(Qe[r],r)}function It(e){var r=a(e);return Pt.reduce(Rt,r)}function Ft(e,r,t){var u=a(e);return u.indexOf(r,t)}function _t(e,r,t){var u=a(e);return u.lastIndexOf(r,t)}function Dt(e,r,t){var u=a(e),n=d(t)?0:D(T(t),0,u.length),i=u.substr(n).search(r);return i!==-1&&!isNaN(n)&&(i+=n),i}function Ot(e,r,t){var u=a(e),n=a(r),i=G(t);return i<0||i>u.length||n===""?u:u.slice(0,i)+n+u.slice(i)}var er={3:"\u039E\u03BE",8:"\u0398\u03B8",A:"A\xC0\xC1\xC2\xC3\xC4\xC5\u0100\u0102\u0104\u01CD\u01DE\u01E0\u01FA\u0200\u0202\u0226\u023A\u0386\u0391\u0410",B:"B\u0181\u0182\u0243\u0392\u0411",C:"C\xC7\u0106\u0108\u010A\u010C\u0187\u023B\u0426",D:"D\u010E\u0110\u0189\u018A\u018B\xD0\u0394\u0414",E:"E\xC8\xC9\xCA\xCB\u0112\u0114\u0116\u0118\u011A\u018E\u0190\u0204\u0206\u0228\u0388\u0395\u0415\u042D",F:"F\u0191\u03A6\u0424",G:"G\u011C\u011E\u0120\u0122\u0193\u01E4\u01E6\u01F4\u0393\u0413\u0490",H:"H\u0124\u0126\u021E\u0389\u0397\u0425",I:"I\xCC\xCD\xCE\xCF\u0128\u012A\u012C\u012E\u0130\u0197\u01CF\u0208\u020A\u038A\u0399\u03AA\u0406\u0418",J:"J\u0134\u0248\u0419",K:"K\u0136\u0198\u01E8\u039A\u041A",L:"L\u0139\u013B\u013D\u013F\u0141\u023D\u039B\u041B",M:"M\u019C\u039C\u041C",N:"N\xD1\u0143\u0145\u0147\u019D\u01F8\u0220\u039D\u041D",O:"O\xD2\xD3\xD4\xD5\xD6\xD8\u014C\u014E\u0150\u0186\u019F\u01A0\u01D1\u01EA\u01EC\u01FE\u020C\u020E\u022A\u022C\u022E\u0230\u038C\u039F\u041E",P:"P\u01A4\u03A0\u041F",Q:"Q\u024A",R:"R\u0154\u0156\u0158\u0210\u0212\u024C\u03A1\u0420",S:"S\u015A\u015C\u015E\u0160\u0218\u03A3\u0421",T:"T\u0162\u0164\u0166\u01AC\u01AE\u021A\u023E\u03A4\u0422",U:"U\xD9\xDA\xDB\xDC\u0168\u016A\u016C\u016E\u0170\u0172\u01AF\u01D3\u01D5\u01D7\u01D9\u01DB\u0214\u0216\u0244\u0423\u042A",V:"V\u01B2\u0245\u0412",W:"W\u0174\u038F\u03A9",X:"X\u03A7",Y:"Y\xDD\u0176\u0178\u01B3\u0232\u024E\u038E\u03A5\u03AB\u042B",Z:"Z\u0179\u017B\u017D\u01B5\u0224\u0396\u0417",a:"a\xE0\xE1\xE2\xE3\xE4\xE5\u0101\u0103\u0105\u01CE\u01DF\u01E1\u01FB\u0201\u0203\u0227\u0250\u03AC\u03B1\u0430",b:"b\u0180\u0183\u0253\u03B2\u0431",c:"c\xE7\u0107\u0109\u010B\u010D\u0188\u023C\u0446",d:"d\u010F\u0111\u018C\u0256\u0257\xF0\u03B4\u0434",e:"e\xE8\xE9\xEA\xEB\u0113\u0115\u0117\u0119\u011B\u01DD\u0205\u0207\u0229\u0247\u025B\u03AD\u03B5\u0435\u044D",f:"f\u0192\u03C6\u0444",g:"g\u011D\u011F\u0121\u0123\u01E5\u01E7\u01F5\u0260\u03B3\u0433\u0491",h:"h\u0125\u0127\u021F\u0265\u03AE\u03B7\u0445",i:"i\xEC\xED\xEE\xEF\u0129\u012B\u012D\u012F\u0131\u01D0\u0209\u020B\u0268\u0390\u03AF\u03B9\u03CA\u0438\u0456",j:"j\u0135\u01F0\u0249\u0439",k:"k\u0137\u0199\u01E9\u03BA\u043A",l:"l\u013A\u013C\u013E\u0140\u0142\u017F\u019A\u026B\u03BB\u043B",m:"m\u026F\u0271\u03BC\u043C",n:"n\xF1\u0144\u0146\u0148\u0149\u019E\u01F9\u0272\u03BD\u043D",o:"o\xF2\xF3\xF4\xF5\xF6\xF8\u014D\u014F\u0151\u01A1\u01D2\u01EB\u01ED\u01FF\u020D\u020F\u022B\u022D\u022F\u0231\u0254\u0275\u03BF\u03CC\u043E",p:"p\u01A5\u03C0\u043F",q:"q\u024B",r:"r\u0155\u0157\u0159\u0211\u0213\u024D\u027D\u03C1\u0440",s:"s\xDF\u015B\u015D\u015F\u0161\u0219\u023F\u03C2\u03C3\u0441",t:"t\u0163\u0165\u0167\u01AD\u021B\u0288\u03C4\u0442",u:"u\xF9\xFA\xFB\xFC\u0169\u016B\u016D\u016F\u0171\u0173\u01B0\u01D4\u01D6\u01D8\u01DA\u01DC\u0215\u0217\u0289\u0443\u044A",v:"v\u028B\u028C\u0432",w:"w\u0175\u03C9\u03CE",x:"x\u03C7",y:"y\xFD\xFF\u0177\u01B4\u0233\u024F\u03B0\u03C5\u03CB\u03CD\u044B",z:"z\u017A\u017C\u017E\u01B6\u0225\u0240\u03B6\u0437",OE:"\x8C\u0152",oe:"\x9C\u0153",AE:"\xC6\u01E2\u01FC",ae:"\xE6\u01E3\u01FD",hv:"\u0195",OI:"\u01A2",oi:"\u01A3",DZ:"\u01C4\u01F1",Dz:"\u01C5\u01F2",dz:"\u01C6\u01F3",LJ:"\u01C7",Lj:"\u01C8",lj:"\u01C9",NJ:"\u01CA",Nj:"\u01CB",nj:"\u01CC",OU:"\u0222",ou:"\u0223",TH:"\xDE",th:"\xFE",PS:"\u03A8",ps:"\u03C8",Yo:"\u0401",Ye:"\u0404",Yi:"\u0407",Zh:"\u0416",Ch:"\u0427",Sh:"\u0428\u0429","":"\u042A\u042C\u044C",Yu:"\u042E",Ya:"\u042F",zh:"\u0436",ch:"\u0447",sh:"\u0448\u0449",yu:"\u044E",ya:"\u044F",yo:"\u0451",ye:"\u0454",yi:"\u0457"},re=null;function Nt(){return re!==null||(re={},Object.keys(er).forEach(function(e){for(var r=er[e],t=0;t<r.length;t++){var u=r[t];re[u]=e}})),re}function Lt(e){var r=Nt()[e];return r||e}function jt(e,r){return r}function rr(e){var r=a(e);return r===""?"":r.replace(Fe,Lt).replace(B,jt)}function kt(e,r,t){var u=a(e),n=d(r)?0:D(T(r),0,k),i=a(t," ");if(n<=u.length)return u;var s=n-u.length,m=T(s/2),p=s%2;return ce(i,m)+u+ce(i,m+p)}function Bt(e,r,t){var u=a(e);return u.replace(r,t)}function tr(e,r,t){var u=a(e);if(r instanceof RegExp){if(r.flags.indexOf("g")===-1)throw new TypeError("search argument is a non-global regular expression");return u.replace(r,t)}var n=a(r),i=typeof t=="function";i||(t=a(t));var s=n.length;if(s===0)return tr(e,/(?:)/g,t);for(var m=s>1?s:1,p=[],E=u.indexOf(n,0);E!==-1;)p.push(E),E=u.indexOf(n,E+m);for(var v=0,x="",w=0;w<p.length;w++){var A=p[w],P=t;i&&(P=a(t.call(void 0,n,A,u))),x+=u.slice(v,A)+P,v=A+s}return v<u.length&&(x+=u.slice(v)),x}function $t(e){var r=a(e);return r.split("").reverse().join("")}function ur(e){var r=a(e);r=r.replace(B,function(n,i,s){return ur(s)+i}).replace(_,"$2$1");for(var t="",u=r.length;u--;)t+=r.charAt(u);return t}function Gt(e){var r=a(e);if(r==="")return"";var t=rr(r).replace(Fe,"-");return _e(t)}function Ut(e,r,t,u){var n=a(e),i=a(u),s=G(r);s<0?(s=n.length+s,s<0&&(s=0)):s>n.length&&(s=n.length);var m=G(t,n.length-s);return m<0&&(m=0),n.slice(0,s)+i+n.slice(s+m)}function Mt(e,r,t){var u=a(e),n,i;if(M(r)&&M(t))n=r.split(""),i=t.split("");else{var s=Ht(Z(r,{})),m=c(s,2);n=m[0],i=m[1]}var p=n.length;if(p===0)return u;for(var E="",v=i.length,x=0;x<u.length;x++){for(var w=!1,A=void 0,P=0;P<p&&P<v;P++){var R=n[P];if(u.substr(x,R.length)===R){w=!0,A=i[P],x=x+R.length-1;break}}E+=w?A:u[x]}return E}function Ht(e){var r=Object.keys(e),t=r.sort(Xt).map(function(u){return e[u]});return[r,t]}function Xt(e,r){return e.length===r.length?0:e.length<r.length?1:-1}function be(e,r,t){var u=a(e),n=$(r);return n===null?!1:n===""?!0:(t=d(t)?0:D(T(t),0,u.length),u.indexOf(n,t)!==-1)}var Yt=Array.prototype.reduce;function nr(e,r){var t=a(e);if(r===""||t==="")return t;var u=$(r);if(d(u))return t.replace(de,"");var n=!0;return Yt.call(t,function(i,s){return n&&be(u,s)?i:(n=!1,i+s)},"")}var Wt=Array.prototype.reduceRight;function ar(e,r){var t=a(e);if(r===""||t==="")return t;var u=$(r);if(d(u))return t.replace(C,"");var n=!0;return Wt.call(t,function(i,s){return n&&be(u,s)?i:(n=!1,s+i)},"")}function zt(e,r){var t=a(e);if(r===""||t==="")return t;var u=$(r);return d(u)?t.trim():ar(nr(t,u),u)}var qt="width",Vt="newLine",Zt="indent",Jt="cut";function Kt(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=a(e),u=Qt(r),n=u.width,i=u.newLine,s=u.indent,m=u.cut;if(t===""||n<=0)return s;for(var p=t.length,E=t.substring.bind(t),v=0,x="";p-v>n;){if(t[v]===" "){v++;continue}var w=t.lastIndexOf(" ",n+v);w>=v?(x+=s+E(v,w)+i,v=w+1):m?(x+=s+E(v,n+v)+i,v+=n):(w=t.indexOf(" ",n+v),w>=0?(x+=s+E(v,w)+i,v=w+1):(x+=s+E(v),v=p))}return v<p&&(x+=s+E(v)),x}function Qt(e){return{width:G(e[qt],75),newLine:a(e[Vt],`
|
|
2
|
+
`),indent:a(e[Zt],""),cut:L(e[Jt],!1)}}function eu(e,r,t){if(d(r))return!1;var u=a(e),n=a(r);if(n==="")return!0;t=d(t)?u.length:D(T(t),0,u.length),t-=n.length;var i=u.indexOf(n,t);return i!==-1&&i===t}function xe(e){var r=a(e);return Ir.test(r)}function ru(e){var r=a(e);return Fr.test(r)}function tu(e){var r=a(e);return r.trim().length===0}function uu(e){var r=a(e);return V.test(r)}function nu(e){var r=a(e);return r.length===0}function au(e){var r=a(e);return xe(r)&&r.toLowerCase()===r}function iu(e){var r=typeof e=="object"&&!d(e)?Number(e):e;return(typeof r=="number"||typeof r=="string")&&!isNaN(r-parseFloat(r))}function ou(e){var r=a(e);return xe(r)&&r.toUpperCase()===r}function su(e,r,t){var u=a(e),n=a(t),i;if(!(r instanceof RegExp)){if(i=$(r),i===null)return!1;r=new RegExp(i,n)}return r.test(u)}function cu(e,r,t){var u=a(e),n=$(r);return n===null?!1:n===""?!0:(t=d(t)?0:D(T(t),0,u.length),u.substr(t,n.length)===n)}function fu(e){var r=a(e);return r.split("")}function lu(e){for(var r=a(e),t=r.length,u=[],n=0,i;n<t;)i=je(r,n),u.push(i),n+=i>65535?2:1;return u}function du(e){var r=a(e);return Z(r.match(y),[])}function gu(e,r,t){var u=a(e);return u.split(r,t)}var pu="\uFEFF";function vu(e){var r=a(e);return r===""?"":r[0]===pu?r.substring(1):r}function hu(e,r,t){var u=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,n=0;u&&(n=-r.length+1);var i=e.substr(t+n,r.length);return i.toLowerCase()===r}function mu(e){for(var r=[],t;(t=Cr.exec(e))!==null;)r.push(t[1]);return r}var ir=0,or=1,we=2;function bu(e){for(var r=ir,t="",u=0;r!==we;){var n=e[u++].toLowerCase();switch(n){case"<":break;case">":r=we;break;default:ae.test(n)?r===or&&(r=we):(r===ir&&(r=or),n!=="/"&&(t+=n));break}}return t}var te=0,q=1,fe=2,sr=3;function xu(e,r,t){if(e=a(e),e==="")return"";if(!Array.isArray(r)){var u=a(r);r=u===""?[]:mu(u)}for(var n=a(t),i=e.length,s=r.length>0,m=hu.bind(null,e),p=te,E=0,v="",x="",w=null,A=0;A<i;A++){var P=e[A],R=!1;switch(P){case"<":if(w)break;if(m("< ",A,!1)){R=!0;break}if(p===te){R=!0,p=q;break}if(p===q){E++;break}R=!0;break;case"!":if(p===q&&m("<!",A)){p=fe;break}R=!0;break;case"-":if(p===fe&&m("!--",A)){p=sr;break}R=!0;break;case'"':case"'":p===q&&(w===P?w=null:w||(w=P)),R=!0;break;case"E":case"e":if(p===fe&&m("doctype",A)){p=q;break}R=!0;break;case">":if(E>0){E--;break}if(w)break;if(p===q){if(w=null,p=te,s){x+=">";var Tu=bu(x);r.indexOf(Tu.toLowerCase())!==-1?v+=x:v+=n,x=""}else v+=n;break}if(p===fe||p===sr&&m("-->",A)){w=null,p=te,x="";break}R=!0;break;default:R=!0}if(R)switch(p){case te:v+=P;break;case q:s&&(x+=P);break}}return v}var J=null;function wu(){return J!==null||(typeof global=="object"&&global.Object===Object?J=global:typeof self=="object"&&self.Object===Object?J=self:J=new Function("return this")()),J}var Ee=wu(),Eu=Ee.v;function Su(){return this===Ee.v&&(Ee.v=Eu),this}var yu="1.4.0",Se={camelCase:Dr,capitalize:H,decapitalize:Or,kebabCase:_e,lowerCase:W,snakeCase:Nr,swapCase:jr,titleCase:Br,upperCase:Lr,count:Kr,countGraphemes:Qr,countSubstrings:et,countWhere:tt,countWords:ut,escapeHtml:Ct,escapeRegExp:Tt,unescapeHtml:It,sprintf:Ke,vprintf:St,indexOf:Ft,lastIndexOf:_t,search:Dt,charAt:$r,codePointAt:je,first:Yr,graphemeAt:Wr,last:zr,prune:qr,slice:Vr,substr:Zr,substring:Jr,truncate:De,insert:Ot,latinise:rr,pad:kt,padLeft:Ve,padRight:Ze,repeat:qe,replace:Bt,replaceAll:tr,reverse:$t,reverseGrapheme:ur,slugify:Gt,splice:Ut,tr:Mt,trim:zt,trimLeft:nr,trimRight:ar,wordWrap:Kt,endsWith:eu,includes:be,isAlpha:xe,isAlphaDigit:ru,isBlank:tu,isDigit:uu,isEmpty:nu,isLowerCase:au,isNumeric:iu,isString:M,isUpperCase:ou,matches:su,startsWith:cu,chars:fu,codePoints:lu,graphemes:du,split:gu,words:ee,stripBom:vu,stripTags:xu,noConflict:Su,version:yu};function I(e,r){this._wrappedValue=e,this._explicitChain=r}I.prototype.value=function(){return this._wrappedValue},I.prototype.valueOf=function(){return this.value()},I.prototype.toJSON=function(){return this.value()},I.prototype.toString=function(){return String(this.value())},I.prototype.chain=function(){return new I(this._wrappedValue,!0)},I.prototype.thru=function(e){return typeof e=="function"?new I(e(this._wrappedValue),this._explicitChain):this},I.prototype._explicitChain=!0;function Au(e){return function(){for(var r=arguments.length,t=new Array(r),u=0;u<r;u++)t[u]=arguments[u];var n=e.apply(void 0,[this._wrappedValue].concat(t));return this._explicitChain||typeof n=="string"?new I(n,this._explicitChain):n}}Object.keys(Se).forEach(function(e){I.prototype[e]=Au(Se[e])});function Cu(e){return new I(e,!0)}function cr(e){return new I(e,!1)}return o(cr,Se,{chain:Cu}),cr})});import gr from"node:path";import{fileURLToPath as Bu}from"node:url";import Lu,{promises as ju}from"fs";async function ye(o,c,l){if(typeof l!="string")throw new TypeError(`Expected a string, got ${typeof l}`);try{return(await ju[o](l))[c]()}catch(f){if(f.code==="ENOENT")return!1;throw f}}function Ae(o,c,l){if(typeof l!="string")throw new TypeError(`Expected a string, got ${typeof l}`);try{return Lu[o](l)[c]()}catch(f){if(f.code==="ENOENT")return!1;throw f}}var an=ye.bind(null,"stat","isFile"),on=ye.bind(null,"stat","isDirectory"),sn=ye.bind(null,"lstat","isSymbolicLink"),lr=Ae.bind(null,"statSync","isFile"),cn=Ae.bind(null,"statSync","isDirectory"),fn=Ae.bind(null,"lstatSync","isSymbolicLink");import ku from"node:os";var dr=ku.homedir();function ue(o){if(typeof o!="string")throw new TypeError(`Expected a string, got ${typeof o}`);return dr?o.replace(/^~(?=$|\/|\\)/,dr):o}function Ce(o,c={}){let{requireFileExistence:l,validFileExtensions:f,validHostnames:g}=c;if(URL.canParse(o)){let h=new URL(o);if(h.protocol==="file:")return Ce(Bu(h),c);if(g&&!g.includes(h.hostname))throw new Error(`Bad input URL. Only ${g.join(", ")} URLs are supported.`);return h}let b=ue(o),F=gr.normalize(b);if(l&&!lr(F))throw new Error("Input is not a file.");let U=gr.extname(F);if(f&&!f.includes(U))throw new Error(`Bad input file name. Only ${f.join(", ")} files are supported.`);return F}import mr from"express";import $u from"node:net";import Gu from"node:os";var le=class extends Error{constructor(c){super(`${c} is locked`)}},K={old:new Set,young:new Set},Uu=1e3*15;var ne,Mu=()=>{let o=Gu.networkInterfaces(),c=new Set([void 0,"0.0.0.0"]);for(let l of Object.values(o))for(let f of l)c.add(f.address);return c},pr=o=>new Promise((c,l)=>{let f=$u.createServer();f.unref(),f.on("error",l),f.listen(o,()=>{let{port:g}=f.address();f.close(()=>{c(g)})})}),vr=async(o,c)=>{if(o.host||o.port===0)return pr(o);for(let l of c)try{await pr({port:o.port,host:l})}catch(f){if(!["EADDRNOTAVAIL","EINVAL"].includes(f.code))throw f}return o.port},Hu=function*(o){o&&(yield*o),yield 0};async function Te(o){let c,l=new Set;if(o&&(o.port&&(c=typeof o.port=="number"?[o.port]:o.port),o.exclude)){let g=o.exclude;if(typeof g[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let b of g){if(typeof b!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(b))throw new TypeError(`Number ${b} in the exclude option is not a safe integer and can't be used`)}l=new Set(g)}ne===void 0&&(ne=setTimeout(()=>{ne=void 0,K.old=K.young,K.young=new Set},Uu),ne.unref&&ne.unref());let f=Mu();for(let g of Hu(c))try{if(l.has(g))continue;let b=await vr({...o,port:g},f);for(;K.old.has(b)||K.young.has(b);){if(g!==0)throw new le(g);b=await vr({...o,port:g},f)}return K.young.add(b),b}catch(b){if(!["EADDRINUSE","EACCES"].includes(b.code)&&!(b instanceof le))throw b}throw new Error("No available ports found")}import wr from"node:fs/promises";import Er from"node:os";import Q from"node:path";import{dirname as Xu}from"node:path";import{fileURLToPath as Yu}from"node:url";import Wu from"puppeteer";var Ie=Nu(hr(),1),zu={darkMode:!1,format:"svg",frames:!1,output:"./",transparent:!1,verbose:!1};async function qu(o,c){let l={...zu,...Qu(c??{})},{darkMode:f,format:g,frames:b,output:F,transparent:U,verbose:h}=l;h&&console.time("Export time");let d=Ce(o,{requireFileExistence:!0,validFileExtensions:[".tldr"],validHostnames:["www.tldraw.com"]}),L=typeof d=="string";h&&console.log(L?"Local file detected":"tldraw URL detected");let M=L?Q.basename(d,Q.extname(d)):d.pathname.split("/").pop()??d.pathname,a=0,H;if(L){h&&console.log("Starting tldraw server...");let _=Xu(Yu(import.meta.url)),y=Q.join(_,_.endsWith("/src/lib")?"../../dist/tldraw":_.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");h&&console.log(`tldraw served from "${y}"`),H=await Zu(y),a=H.address().port,h&&console.log(`tldraw hosted at "http://localhost:${a}"`)}h&&console.log("Starting Puppeteer...");let W=await Wu.launch({args:L?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),S=await W.newPage();Vu(S,h);let X=await S.target().createCDPSession();if(await X.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:Er.tmpdir(),eventsEnabled:!0}),L){await S.setRequestInterception(!0),S.on("request",y=>{y.url().endsWith("favicon.ico")?y.respond({status:200}):y.continue()}),h&&console.log(`Loading tldr file "${d}"`);let _=await wr.readFile(d,"utf8");await S.evaluateOnNewDocument(y=>{localStorage.clear(),localStorage.setItem("tldrData",y)},_)}let O=L?`http://localhost:${a}`:d.href;h&&console.log(`Navigating to: ${O}`),await S.goto(O,{waitUntil:"networkidle0"});let N=await S.evaluate("editor.getCurrentPageShapes().length");if(h&&console.log(`Shape count: ${N}`),N===0)throw new Error("The sketch is empty");h&&console.log(`Setting background transparency: ${U}`),await tn(S,U),h&&console.log(`Setting dark mode: ${f}`);let j=await rn(S);await xr(S,f);let z=[],B=b?await S.evaluate(`editor.getCurrentPageShapes().reduce((accumulator, shape) => {
|
|
3
|
+
if (shape.type === 'frame') {
|
|
4
|
+
accumulator.push({ id: shape.id, name: shape.props.name })
|
|
5
|
+
}
|
|
6
|
+
return accumulator
|
|
7
|
+
}, [])`):[];if(b&&B.length===0&&console.warn("No frames found in the sketch, exporting entire page instead."),b&&B.length>0){let _=!1,y=[];if(typeof b=="boolean")y=B;else if(Array.isArray(b))for(let C of b){let V=B.find(Y=>Y.name===C)??B.find(Y=>Y.id===(C.startsWith("shape:")?C:`shape:${C}`));if(!V)throw new Error(`No frame found matching: "${C}"`);y.push(V)}if(y.length===0)throw new Error("No frames found matching the specified frames");let ae=y.map(C=>(0,Ie.slugify)(C.name)),de=[...new Set(ae)];_=ae.length!==de.length,h&&_&&console.warn("Frame names are not unique, including frame IDs in the output filenames to avoid collisions");for(let C of y){h&&console.log(`Downloading sketch frame: "${C.name}"`),await S.evaluate("editor.selectNone()"),await S.evaluate(`editor.select('${C.id}')`);let V=(_?`-${C.id.replace("shape:","")}`:"")+`-${(0,Ie.slugify)(C.name)}`,Y=await br(S,X,F,M+V,g);h&&console.log(`Download complete, saved to: "${Y}"`),z.push(Y)}}else h&&console.log("Downloading sketch"),z=await br(S,X,F,M,g),h&&console.log(`Download complete, saved to: "${z}"`);return h&&console.log(`Restoring dark mode: ${j}`),await xr(S,j),await W.close(),h&&console.log("Stopped Puppeteer"),L&&H&&(H.close(),h&&console.log("Stopped tldraw server")),h&&console.timeEnd("Export time"),z}async function br(o,c,l,f,g){let b=Ju(c);await en(o),await Ku(o,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${g}`]);let F=await b;await o.waitForNetworkIdle();let U=Q.join(Er.tmpdir(),F),h=Q.resolve(ue(Q.join(l,`${f}.${g}`)));return await wr.rename(U,h),h}function Vu(o,c){o.on("console",l=>{let f=l.type(),g=l.text();f==="error"?console.error(`[Browser] ${g}`):f==="warning"?console.warn(`[Browser] ${g}`):c&&console.log(`[Browser] ${g}`)})}async function Zu(o){let c=mr(),l=await Te();return c.use(mr.static(o)),new Promise((f,g)=>{let b=c.listen(l,()=>{f(b)});b.on("error",F=>{g(F)})})}async function Ju(o){return new Promise((c,l)=>{o.on("Browser.downloadProgress",f=>{f.state==="completed"?c(f.guid):f.state==="canceled"&&l(new Error("Download was canceled"))})})}async function Ku(o,c){for(let l of c)await o.waitForSelector(`[data-testid="${l}"]`),await o.click(`[data-testid="${l}"]`)}function Qu(o){return Object.fromEntries(Object.entries(o).filter(([,c])=>c!==void 0))}async function en(o){await o.evaluate("app.clearOpenMenus()")}async function rn(o){return!!await o.evaluate("editor.user.getUserPreferences().isDarkMode")}async function xr(o,c){await o.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${c}})`)}async function tn(o,c){await o.evaluate(`editor.updateInstanceState(
|
|
8
|
+
{ exportBackground: ${!c} },
|
|
3
9
|
{ ephemeral: true },
|
|
4
|
-
)`)}export{
|
|
10
|
+
)`)}export{qu as tldrawToImage};
|
|
11
|
+
/*! Bundled license information:
|
|
12
|
+
|
|
13
|
+
voca/index.js:
|
|
14
|
+
(*!
|
|
15
|
+
* Voca string library 1.4.1
|
|
16
|
+
* https://vocajs.pages.dev
|
|
17
|
+
*
|
|
18
|
+
* Copyright Dmitri Pavlutin and other contributors
|
|
19
|
+
* Released under the MIT license
|
|
20
|
+
*)
|
|
21
|
+
*/
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export type TldrawImageOptions = {
|
|
2
2
|
darkMode?: boolean;
|
|
3
3
|
format?: 'png' | 'svg';
|
|
4
|
+
frames?: boolean | string[];
|
|
4
5
|
output?: string;
|
|
5
6
|
transparent?: boolean;
|
|
6
7
|
verbose?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export declare function tldrawToImage(tldrPathOrUrl: string, options?: TldrawImageOptions
|
|
9
|
+
export declare function tldrawToImage(tldrPathOrUrl: string, options?: TldrawImageOptions & {
|
|
10
|
+
frames?: false | undefined;
|
|
11
|
+
}): Promise<string>;
|
|
12
|
+
export declare function tldrawToImage(tldrPathOrUrl: string, options?: TldrawImageOptions & {
|
|
13
|
+
frames: string[] | true;
|
|
14
|
+
}): Promise<string[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/tldraw-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A tiny little CLI tool for rendering tldraw URLs and .tldr files into svg or png images.",
|
|
6
6
|
"repository": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@types/express": "^4.17.21",
|
|
53
53
|
"@types/react": "^18.2.48",
|
|
54
54
|
"@types/react-dom": "^18.2.18",
|
|
55
|
+
"@types/voca": "^1.4.5",
|
|
55
56
|
"@types/yargs": "^17.0.32",
|
|
56
57
|
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
57
58
|
"bumpp": "^9.2.1",
|
|
@@ -67,6 +68,7 @@
|
|
|
67
68
|
"untildify": "^5.0.0",
|
|
68
69
|
"vite": "^5.0.11",
|
|
69
70
|
"vitest": "^1.2.0",
|
|
71
|
+
"voca": "^1.4.1",
|
|
70
72
|
"yargs": "^17.7.2"
|
|
71
73
|
},
|
|
72
74
|
"publishConfig": {
|
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) URLs and `.tldr` files into
|
|
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
|
|
|
@@ -42,15 +42,16 @@ tldraw-cli file-or-url {options}
|
|
|
42
42
|
| ------------- | ------------------------------------------------------------------------------------------------------- |
|
|
43
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
|
|
46
|
-
|
|
|
47
|
-
| `--format
|
|
48
|
-
| `--dark-mode`
|
|
49
|
-
| `--transparent`
|
|
50
|
-
| `--output
|
|
51
|
-
| `--
|
|
52
|
-
| `--
|
|
53
|
-
| `--
|
|
45
|
+
| Option | Alias | Description Value | Default Value |
|
|
46
|
+
| --------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
|
|
47
|
+
| `--format <svg\|png>` | `-f` | Output image format, one of `svg` or `png` | `svg` |
|
|
48
|
+
| `--dark-mode ` | `-d` | Output a dark theme version of the image | `false` |
|
|
49
|
+
| `--transparent ` | `-t` | Output an image with a transparent background | `false` |
|
|
50
|
+
| `--output <string>` | `-o` | Output directory | `./` |
|
|
51
|
+
| `--frames <array?>` | | Export each sketch "frame" as a separate image, use the option flag alone to export all frames, or pass one or more frame names or IDs | `false` |
|
|
52
|
+
| `--help ` | `-h` | Show help | |
|
|
53
|
+
| `--version` | `-v` | Show version number | |
|
|
54
|
+
| `--verbose` | | Enable verbose output | `false` |
|
|
54
55
|
|
|
55
56
|
## Examples
|
|
56
57
|
|
|
@@ -62,12 +63,16 @@ To convert the file `your-drawing.tldr` to an svg named `your-drawing.svg` saved
|
|
|
62
63
|
npx @kitschpatrol/tldraw-cli your-drawing.tldr
|
|
63
64
|
```
|
|
64
65
|
|
|
66
|
+
The file will retain its original name, e.g. `your-drawing.svg`
|
|
67
|
+
|
|
65
68
|
### Basic tldraw\.com image download
|
|
66
69
|
|
|
67
70
|
```sh
|
|
68
71
|
npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4
|
|
69
72
|
```
|
|
70
73
|
|
|
74
|
+
The tldraw URL's id (e.g. `v2_c_JsxJk8dag6QsrqExukis4`) will be used for the file name.
|
|
75
|
+
|
|
71
76
|
### Export to a specific format
|
|
72
77
|
|
|
73
78
|
```sh
|
|
@@ -86,6 +91,22 @@ npx @kitschpatrol/tldraw-cli your-drawing.tldr --transparent --format png
|
|
|
86
91
|
npx @kitschpatrol/tldraw-cli your-drawing.tldr --output ~/Desktop
|
|
87
92
|
```
|
|
88
93
|
|
|
94
|
+
### Export all frames from a single tldraw URL
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The saved files will be suffixed with their frame name, e.g.: `v2_c_FI5RYWbdpAtjsy4OIKrKw-frame-1.png`
|
|
101
|
+
|
|
102
|
+
It's possible in tldraw to give multiple frames in a single sketch the same name. In these cases, the frame ID is used in addition to the name to ensure unique output file names.
|
|
103
|
+
|
|
104
|
+
### Export a specific frame from a tldraw URL
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
npx @kitschpatrol/tldraw-cli https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw --frames "Frame 1" "Frame 3"
|
|
108
|
+
```
|
|
109
|
+
|
|
89
110
|
## API usage
|
|
90
111
|
|
|
91
112
|
The conversion tool's functionality is also exposed as a module for use in TypeScript or JavaScript Node projects.
|
|
@@ -99,6 +120,7 @@ The library exports a single async function, `tldrawToImage`, which takes an opt
|
|
|
99
120
|
darkMode?: boolean
|
|
100
121
|
output?: string
|
|
101
122
|
format?: 'png' | 'svg'
|
|
123
|
+
frames?: boolean | string[]
|
|
102
124
|
transparent?: boolean
|
|
103
125
|
verbose?: boolean
|
|
104
126
|
}): Promise<string>;
|
|
@@ -113,14 +135,32 @@ Assuming you've installed `@kitschpatrol/tldraw-cli` locally in your project, it
|
|
|
113
135
|
|
|
114
136
|
import { tldrawToImage } from '@kitschpatrol/tldraw-cli'
|
|
115
137
|
|
|
116
|
-
//
|
|
117
|
-
const
|
|
138
|
+
// Convert a local file to PNG
|
|
139
|
+
const imagePath = await tldrawToImage('./some-file.tldr', { format: 'png', output: './' })
|
|
140
|
+
console.log(`Wrote image to: "${imagePath}"`)
|
|
118
141
|
|
|
119
|
-
//
|
|
120
|
-
console.log(`Image saved to: "${imagePathFromLocal}"`)
|
|
121
|
-
|
|
122
|
-
// Saving a remote tldraw url
|
|
142
|
+
// Convert a remote tldraw URL to SVG
|
|
123
143
|
await tldrawToImage('https://www.tldraw.com/s/v2_c_JsxJk8dag6QsrqExukis4')
|
|
144
|
+
|
|
145
|
+
// Convert all frames from a single tldraw URL to separate SVGs
|
|
146
|
+
// When the `frames` option is set, the function returns an array
|
|
147
|
+
// of resulting file paths, instead of a solitary string
|
|
148
|
+
const framePathsArray = await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
|
|
149
|
+
frames: true,
|
|
150
|
+
})
|
|
151
|
+
console.log(`Wrote frames to: "${framePathsArray}"`)
|
|
152
|
+
|
|
153
|
+
// Convert a specific frame from a tldraw URL to a PNG
|
|
154
|
+
await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
|
|
155
|
+
frames: ['Frame 3'],
|
|
156
|
+
format: 'png',
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
// You can also use the frame id instead of name, if you're into that sort of thing
|
|
160
|
+
// It will work with or without the `shape:` prefix
|
|
161
|
+
await tldrawToImage('https://www.tldraw.com/s/v2_c_FI5RYWbdpAtjsy4OIKrKw', {
|
|
162
|
+
frames: ['shape:x8z3Qf7Hgw4Qqp2AC-eet'],
|
|
163
|
+
})
|
|
124
164
|
```
|
|
125
165
|
|
|
126
166
|
_Note that the library provided is ESM only, and requires a Node-compatible runtime. TypeScript type definitions are included._
|
|
@@ -145,6 +185,10 @@ On Discord:
|
|
|
145
185
|
|
|
146
186
|
Due to the current implementation of tldraw, export depends on functionality provided by a web browser. So, behind the scenes, this app serves a local instance of tldraw, then loads a `.tldr` and invokes the export download via [Puppeteer](https://pptr.dev).
|
|
147
187
|
|
|
188
|
+
This can be a bit slow, (exporting seems to take a second or two), but in the context of a content pipeline it's not the end of the world.
|
|
189
|
+
|
|
190
|
+
In terms of Puppeteer vs. Playwright and other headless browser automation tools, it [looks like](https://www.checklyhq.com/blog/puppeteer-vs-selenium-vs-playwright-speed-comparison/) Puppeteer's performance likely compares favorably. (Though I have not tested and benchmarked the alternatives in the specific context of `tldraw-cli`.)
|
|
191
|
+
|
|
148
192
|
The local instance of tldraw includes its assets dependencies, so the tool should work correctly without internet access.
|
|
149
193
|
|
|
150
194
|
## The future
|
|
@@ -152,8 +196,9 @@ The local instance of tldraw includes its assets dependencies, so the tool shoul
|
|
|
152
196
|
This is a very minimal implementation. Current plans for future improvements include the following:
|
|
153
197
|
|
|
154
198
|
- Add CLI tests
|
|
155
|
-
- Implement the ability to export specific
|
|
199
|
+
- Implement the ability to export specific pages as separate image files
|
|
156
200
|
- Add an option flag to set dpi when exporting to a bitmap format
|
|
201
|
+
- Additional commands beyond sketch conversion / export?
|
|
157
202
|
|
|
158
203
|
Any other suggestions are welcome.
|
|
159
204
|
|