@kitschpatrol/tldraw-cli 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +36 -21
- package/dist/lib/index.js +20 -3
- package/dist/lib/tldraw-to-image.d.ts +7 -1
- package/dist/lib/validation.d.ts +5 -0
- package/package.json +4 -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 an="2.0.1";import un from"express";import wi from"node:net";import yi from"node:os";var ue=class extends Error{constructor(t){super(`${t} is locked`)}},Zt={old:new Set,young:new Set},Oi=1e3*15;var ie,_i=()=>{let s=yi.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},ln=s=>new Promise((t,e)=>{let n=wi.createServer();n.unref(),n.on("error",e),n.listen(s,()=>{let{port:i}=n.address();n.close(()=>{t(i)})})}),cn=async(s,t)=>{if(s.host||s.port===0)return ln(s);for(let e of t)try{await ln({port:s.port,host:e})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return s.port},Ci=function*(s){s&&(yield*s),yield 0};async function $e(s){let t,e=new Set;if(s&&(s.port&&(t=typeof s.port=="number"?[s.port]:s.port),s.exclude)){let i=s.exclude;if(typeof i[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let r of i){if(typeof r!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(r))throw new TypeError(`Number ${r} in the exclude option is not a safe integer and can't be used`)}e=new Set(i)}ie===void 0&&(ie=setTimeout(()=>{ie=void 0,Zt.old=Zt.young,Zt.young=new Set},Oi),ie.unref&&ie.unref());let n=_i();for(let i of Ci(t))try{if(e.has(i))continue;let r=await cn({...s,port:i},n);for(;Zt.old.has(r)||Zt.young.has(r);){if(i!==0)throw new ue(i);r=await cn({...s,port:i},n)}return Zt.young.add(r),r}catch(r){if(!["EADDRINUSE","EACCES"].includes(r.code)&&!(r instanceof ue))throw r}throw new Error("No available ports found")}import hn from"node:fs/promises";import dn from"node:os";import Wt from"node:path";import{dirname as Ei}from"node:path";import{fileURLToPath as ji}from"node:url";import Ai from"puppeteer";import xi from"node:os";var fn=xi.homedir();function he(s){if(typeof s!="string")throw new TypeError(`Expected a string, got ${typeof s}`);return fn?s.replace(/^~(?=$|\/|\\)/,fn):s}var Pi={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!0};async function mn(s,t={}){let e={...Pi,...vi(t)},{darkMode:n,format:i,output:r,transparent:a,verbose:c}=e,g=!s.startsWith("https://www.tldraw.com/");c&&console.log(g?"Local file detected":"tldraw URL detected");let w=0,p;if(g){c&&console.log("Starting tldraw server...");let R=Ei(ji(import.meta.url)),H=Wt.join(R,R.endsWith("/src/lib")?"../../dist/tldraw":R.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");c&&console.log(`tldraw served from "${H}"`),p=await Mi(H),w=p.address().port,c&&console.log(`tldraw hosted at "http://localhost:${w}"`)}c&&console.log("Starting Puppeteer...");let h=await Ai.launch({args:g?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),m=await h.newPage();Si(m,c);let y=await m.target().createCDPSession();if(await y.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:dn.tmpdir(),eventsEnabled:!0}),g){await m.setRequestInterception(!0),m.on("request",at=>{at.url().endsWith("favicon.ico")?at.respond({status:200}):at.continue()});let R=Wt.resolve(he(s));c&&console.log(`Loading tldr file "${R}"`);let H=await hn.readFile(R,"utf8");await m.evaluateOnNewDocument(at=>{localStorage.clear(),localStorage.setItem("tldrData",at)},H)}let E=g?`http://localhost:${w}`:s;c&&console.log(`Navigating to: ${E}`),await m.goto(E,{waitUntil:"networkidle0"}),c&&console.log(`Setting background transparency: ${a}`),await Ni(m,a),c&&console.log(`Setting dark mode: ${n}`);let _=await Fi(m);await pn(m,n),c&&console.log("Requesting download"),await Di(m),await $i(m,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${i}`]);let d=await Ii(y);c&&console.log("Download complete"),c&&console.log(`Restoring dark mode: ${_}`),await pn(m,_),await h.close(),c&&console.log("Stopped Puppeteer"),g&&p&&(p.close(),c&&console.log("Stopped tldraw server"));let L=g?Wt.basename(s,Wt.extname(s)):d,z=Wt.join(dn.tmpdir(),d),T=he(Wt.join(r,`${L}.${i}`));return await hn.rename(z,T),c&&console.log(`Saved to "${T}"`),Wt.resolve(T)}function Si(s,t){s.on("console",e=>{let n=e.type(),i=e.text();n==="error"?console.error(`[Browser] ${i}`):n==="warning"?console.warn(`[Browser] ${i}`):t&&console.log(`[Browser] ${i}`)})}async function Mi(s){let t=un(),e=await $e();return t.use(un.static(s)),new Promise((n,i)=>{let r=t.listen(e,()=>{n(r)});r.on("error",a=>{i(a)})})}async function Ii(s){return new Promise((t,e)=>{s.on("Browser.downloadProgress",n=>{n.state==="completed"?t(n.guid):n.state==="canceled"&&e(new Error("Download was canceled"))})})}async function $i(s,t){for(let e of t)await s.waitForSelector(`[data-testid="${e}"]`),await s.click(`[data-testid="${e}"]`)}function vi(s){return Object.fromEntries(Object.entries(s).filter(([,t])=>t!==void 0))}async function Di(s){await s.evaluate("app.clearOpenMenus()")}async function Fi(s){return!!await s.evaluate("editor.user.getUserPreferences().isDarkMode")}async function pn(s,t){await s.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${t}})`)}async function Ni(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.0.3";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 Fe(s){return bn(s,{stringWidth:t=>[...t].length,stripAnsi:De,wrap:yn})}import{dirname as On,resolve as _n}from"path";import{readdirSync as Yi,statSync as Bi}from"fs";function Cn(s,t){let e=_n(".",s),n;for(Bi(e).isDirectory()||(e=On(e));;){if(n=t(e,Yi(e)),n)return _n(e,n);if(e=On(n=e),n===e)break}}import{inspect as ls}from"util";import{readFileSync as cs}from"fs";import{fileURLToPath as fs}from"url";import{format as qi}from"util";import{normalize as Ki,resolve as Qi}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 xn(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=xn(t),r=typeof t=="string",a=Gi(Object.assign(Object.create(null),n.alias)),c=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),g=Object.assign(Object.create(null),n.default),w=n.configObjects||[],p=n.envPrefix,h=c["populate--"],m=h?"--":"_",y=Object.create(null),E=Object.create(null),_=n.__||At.format,d={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},L=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,z=new RegExp("^--"+c["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach(function(l){let u=typeof l=="object"?l.key:l,O=Object.keys(l).map(function(b){return{boolean:"bools",string:"strings",number:"numbers"}[b]}).filter(Boolean).pop();O&&(d[O][u]=!0),d.arrays[u]=!0,d.keys.push(u)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){d.bools[l]=!0,d.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){d.strings[l]=!0,d.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){d.numbers[l]=!0,d.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){d.counts[l]=!0,d.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){d.normalize[l]=!0,d.keys.push(l)}),typeof n.narg=="object"&&Object.entries(n.narg).forEach(([l,u])=>{typeof u=="number"&&(d.nargs[l]=u,d.keys.push(l))}),typeof n.coerce=="object"&&Object.entries(n.coerce).forEach(([l,u])=>{typeof u=="function"&&(d.coercions[l]=u,d.keys.push(l))}),typeof n.config<"u"&&(Array.isArray(n.config)||typeof n.config=="string"?[].concat(n.config).filter(Boolean).forEach(function(l){d.configs[l]=!0}):typeof n.config=="object"&&Object.entries(n.config).forEach(([l,u])=>{(typeof u=="boolean"||typeof u=="function")&&(d.configs[l]=u)})),Nt(n.key,a,n.default,d.arrays),Object.keys(g).forEach(function(l){(d.aliases[l]||[]).forEach(function(u){g[u]=g[l]})});let T=null;fe();let R=[],H=Object.assign(Object.create(null),{_:[]}),at={};for(let l=0;l<i.length;l++){let u=i[l],O=u.replace(/^-{3,}/,"---"),b,f,S,x,$,it;if(u!=="--"&&/^-/.test(u)&&J(u))bt(u);else if(O.match(/^---+(=|$)/)){bt(u);continue}else if(u.match(/^--.+=/)||!c["short-option-groups"]&&u.match(/^-.+=/))x=u.match(/^--?([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&(D(x[1],d.arrays)?l=Dt(l,x[1],i,x[2]):D(x[1],d.nargs)!==!1?l=Jt(l,x[1],i,x[2]):G(x[1],x[2],!0));else if(u.match(z)&&c["boolean-negation"])x=u.match(z),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],G(f,D(f,d.arrays)?[!1]:!1));else if(u.match(/^--.+/)||!c["short-option-groups"]&&u.match(/^-[^-]+/))x=u.match(/^--?(.+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],D(f,d.arrays)?l=Dt(l,f,i):D(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!$.match(/^-/)||$.match(L))&&!D(f,d.bools)&&!D(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))));else if(u.match(/^-.\..+=/))x=u.match(/^-([^=]+)=([\s\S]*)$/),x!==null&&Array.isArray(x)&&x.length>=3&&G(x[1],x[2]);else if(u.match(/^-.\..+/)&&!u.match(L))$=i[l+1],x=u.match(/^-(.\..+)/),x!==null&&Array.isArray(x)&&x.length>=2&&(f=x[1],$!==void 0&&!$.match(/^-/)&&!D(f,d.bools)&&!D(f,d.counts)?(G(f,$),l++):G(f,Z(f)));else if(u.match(/^-[^-]+/)&&!u.match(L)){S=u.slice(1,-1).split(""),b=!1;for(let rt=0;rt<S.length;rt++){if($=u.slice(rt+2),S[rt+1]&&S[rt+1]==="="){it=u.slice(rt+3),f=S[rt],D(f,d.arrays)?l=Dt(l,f,i,it):D(f,d.nargs)!==!1?l=Jt(l,f,i,it):G(f,it),b=!0;break}if($==="-"){G(S[rt],$);continue}if(/[A-Za-z]/.test(S[rt])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test($)&&D($,d.bools)===!1){G(S[rt],$),b=!0;break}if(S[rt+1]&&S[rt+1].match(/\W/)){G(S[rt],$),b=!0;break}else G(S[rt],Z(S[rt]))}f=u.slice(-1)[0],!b&&f!=="-"&&(D(f,d.arrays)?l=Dt(l,f,i):D(f,d.nargs)!==!1?l=Jt(l,f,i):($=i[l+1],$!==void 0&&(!/^(-|--)[^-]/.test($)||$.match(L))&&!D(f,d.bools)&&!D(f,d.counts)||/^(true|false)$/.test($)?(G(f,$),l++):G(f,Z(f))))}else if(u.match(/^-[0-9]$/)&&u.match(L)&&D(u.slice(1),d.bools))f=u.slice(1),G(f,Z(f));else if(u==="--"){R=i.slice(l+1);break}else if(c["halt-at-non-option"]){R=i.slice(l);break}else bt(u)}Y(H,!0),Y(H,!1),W(H),et(),Q(H,d.aliases,g,!0),nt(H),c["set-placeholder-key"]&&Ft(H),Object.keys(d.counts).forEach(function(l){Et(H,l.split("."))||G(l,0)}),h&&R.length&&(H[m]=[]),R.forEach(function(l){H[m].push(l)}),c["camel-case-expansion"]&&c["strip-dashed"]&&Object.keys(H).filter(l=>l!=="--"&&l.includes("-")).forEach(l=>{delete H[l]}),c["strip-aliased"]&&[].concat(...Object.keys(a).map(l=>a[l])).forEach(l=>{c["camel-case-expansion"]&&l.includes("-")&&delete H[l.split(".").map(u=>Lt(u)).join(".")],delete H[l]});function bt(l){let u=P("_",l);(typeof u=="string"||typeof u=="number")&&H._.push(u)}function Jt(l,u,O,b){let f,S=D(u,d.nargs);if(S=typeof S!="number"||isNaN(S)?1:S,S===0)return yt(b)||(T=Error(_("Argument unexpected for: %s",u))),G(u,Z(u)),l;let x=yt(b)?0:1;if(c["nargs-eats-options"])O.length-(l+1)+x<S&&(T=Error(_("Not enough arguments following: %s",u))),x=S;else{for(f=l+1;f<O.length&&(!O[f].match(/^-[^0-9]/)||O[f].match(L)||J(O[f]));f++)x++;x<S&&(T=Error(_("Not enough arguments following: %s",u)))}let $=Math.min(x,S);for(!yt(b)&&$>0&&(G(u,b),$--),f=l+1;f<$+l+1;f++)G(u,O[f]);return l+$}function Dt(l,u,O,b){let f=[],S=b||O[l+1],x=D(u,d.nargs);if(D(u,d.bools)&&!/^(true|false)$/.test(S))f.push(!0);else if(yt(S)||yt(b)&&/^-/.test(S)&&!L.test(S)&&!J(S)){if(g[u]!==void 0){let $=g[u];f=Array.isArray($)?$:[$]}}else{yt(b)||f.push(C(u,b,!0));for(let $=l+1;$<O.length&&!(!c["greedy-arrays"]&&f.length>0||x&&typeof x=="number"&&f.length>=x||(S=O[$],/^-/.test(S)&&!L.test(S)&&!J(S)));$++)l=$,f.push(C(u,S,r))}return typeof x=="number"&&(x&&f.length<x||isNaN(x)&&f.length===0)&&(T=Error(_("Not enough arguments following: %s",u))),G(u,f),l}function G(l,u,O=r){if(/-/.test(l)&&c["camel-case-expansion"]){let S=l.split(".").map(function(x){return Lt(x)}).join(".");M(l,S)}let b=C(l,u,O),f=l.split(".");jt(H,f,b),d.aliases[l]&&d.aliases[l].forEach(function(S){let x=S.split(".");jt(H,x,b)}),f.length>1&&c["dot-notation"]&&(d.aliases[f[0]]||[]).forEach(function(S){let x=S.split("."),$=[].concat(f);$.shift(),x=x.concat($),(d.aliases[l]||[]).includes(x.join("."))||jt(H,x,b)}),D(l,d.normalize)&&!D(l,d.arrays)&&[l].concat(d.aliases[l]||[]).forEach(function(x){Object.defineProperty(at,x,{enumerable:!0,get(){return u},set($){u=typeof $=="string"?At.normalize($):$}})})}function M(l,u){d.aliases[l]&&d.aliases[l].length||(d.aliases[l]=[u],y[u]=!0),d.aliases[u]&&d.aliases[u].length||M(u,l)}function C(l,u,O){O&&(u=Vi(u)),(D(l,d.bools)||D(l,d.counts))&&typeof u=="string"&&(u=u==="true");let b=Array.isArray(u)?u.map(function(f){return P(l,f)}):P(l,u);return D(l,d.counts)&&(yt(b)||typeof b=="boolean")&&(b=Ne()),D(l,d.normalize)&&D(l,d.arrays)&&(Array.isArray(u)?b=u.map(f=>At.normalize(f)):b=At.normalize(u)),b}function P(l,u){return!c["parse-positional-numbers"]&&l==="_"||!D(l,d.strings)&&!D(l,d.bools)&&!Array.isArray(u)&&(ge(u)&&c["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${u}`)))||!yt(u)&&D(l,d.numbers))&&(u=Number(u)),u}function W(l){let u=Object.create(null);Q(u,d.aliases,g),Object.keys(d.configs).forEach(function(O){let b=l[O]||u[O];if(b)try{let f=null,S=At.resolve(At.cwd(),b),x=d.configs[O];if(typeof x=="function"){try{f=x(S)}catch($){f=$}if(f instanceof Error){T=f;return}}else f=At.require(S);B(f)}catch(f){f.name==="PermissionDenied"?T=f:l[O]&&(T=Error(_("Invalid JSON config file: %s",b)))}})}function B(l,u){Object.keys(l).forEach(function(O){let b=l[O],f=u?u+"."+O:O;typeof b=="object"&&b!==null&&!Array.isArray(b)&&c["dot-notation"]?B(b,f):(!Et(H,f.split("."))||D(f,d.arrays)&&c["combine-arrays"])&&G(f,b)})}function et(){typeof w<"u"&&w.forEach(function(l){B(l)})}function Y(l,u){if(typeof p>"u")return;let O=typeof p=="string"?p:"",b=At.env();Object.keys(b).forEach(function(f){if(O===""||f.lastIndexOf(O,0)===0){let S=f.split("__").map(function(x,$){return $===0&&(x=x.substring(O.length)),Lt(x)});(u&&d.configs[S.join(".")]||!u)&&!Et(l,S)&&G(S.join("."),b[f])}})}function nt(l){let u,O=new Set;Object.keys(l).forEach(function(b){if(!O.has(b)&&(u=D(b,d.coercions),typeof u=="function"))try{let f=P(b,u(l[b]));[].concat(d.aliases[b]||[],b).forEach(S=>{O.add(S),l[S]=f})}catch(f){T=f}})}function Ft(l){return d.keys.forEach(u=>{~u.indexOf(".")||typeof l[u]>"u"&&(l[u]=void 0)}),l}function Q(l,u,O,b=!1){Object.keys(O).forEach(function(f){Et(l,f.split("."))||(jt(l,f.split("."),O[f]),b&&(E[f]=!0),(u[f]||[]).forEach(function(S){Et(l,S.split("."))||jt(l,S.split("."),O[f])}))})}function Et(l,u){let O=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(f){O=O[f]||{}});let b=u[u.length-1];return typeof O!="object"?!1:b in O}function jt(l,u,O){let b=l;c["dot-notation"]||(u=[u.join(".")]),u.slice(0,-1).forEach(function(it){it=En(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=En(u[u.length-1]),S=D(u.join("."),d.arrays),x=Array.isArray(O),$=c["duplicate-arguments-array"];!$&&D(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===Ne()?b[f]=Ne(b[f]):Array.isArray(b[f])?$&&S&&x?b[f]=c["flatten-duplicate-arrays"]?b[f].concat(O):(Array.isArray(b[f][0])?b[f]:[b[f]]).concat([O]):!$&&!!S==!!x?b[f]=O:b[f]=b[f].concat([O]):b[f]===void 0&&S?b[f]=x?O:[O]:$&&!(b[f]===void 0||D(f,d.counts)||D(f,d.bools))?b[f]=[b[f],O]:b[f]=O}function Nt(...l){l.forEach(function(u){Object.keys(u||{}).forEach(function(O){d.aliases[O]||(d.aliases[O]=[].concat(a[O]||[]),d.aliases[O].concat(O).forEach(function(b){if(/-/.test(b)&&c["camel-case-expansion"]){let f=Lt(b);f!==O&&d.aliases[O].indexOf(f)===-1&&(d.aliases[O].push(f),y[f]=!0)}}),d.aliases[O].concat(O).forEach(function(b){if(b.length>1&&/[A-Z]/.test(b)&&c["camel-case-expansion"]){let f=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 D(l,u){let O=[].concat(d.aliases[l]||[],l),b=Object.keys(u),f=O.find(S=>b.includes(S));return f?u[f]:!1}function Ie(l){let u=Object.keys(d);return[].concat(u.map(b=>d[b])).some(function(b){return Array.isArray(b)?b.includes(l):b[l]})}function v(l,...u){return[].concat(...u).some(function(b){let f=l.match(b);return f&&Ie(f[1])})}function K(l){if(l.match(L)||!l.match(/^-[^-]+/))return!1;let u=!0,O,b=l.slice(1).split("");for(let f=0;f<b.length;f++){if(O=l.slice(f+2),!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(l){return c["unknown-options-as-args"]&&U(l)}function U(l){return l=l.replace(/^-{3,}/,"--"),l.match(L)||K(l)?!1:!v(l,/^-+([^=]+?)=[\s\S]*$/,z,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function Z(l){return!D(l,d.bools)&&!D(l,d.counts)&&`${l}`in g?g[l]:k(wt(l))}function k(l){return{[ht.BOOLEAN]:!0,[ht.STRING]:"",[ht.NUMBER]:void 0,[ht.ARRAY]:[]}[l]}function wt(l){let u=ht.BOOLEAN;return D(l,d.strings)?u=ht.STRING:D(l,d.numbers)?u=ht.NUMBER:D(l,d.bools)?u=ht.BOOLEAN:D(l,d.arrays)&&(u=ht.ARRAY),u}function yt(l){return l===void 0}function fe(){Object.keys(d.counts).find(l=>D(l,d.arrays)?(T=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0):D(l,d.nargs)?(T=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0):!1)}return{aliases:Object.assign({},d.aliases),argv:Object.assign(at,H),configuration:c,defaulted:Object.assign({},E),error:T,newAliases:Object.assign({},y)}}};function Gi(s){let t=[],e=Object.create(null),n=!0;for(Object.keys(s).forEach(function(i){t.push([].concat(s[i],i))});n;){n=!1;for(let i=0;i<t.length;i++)for(let r=i+1;r<t.length;r++)if(t[i].filter(function(c){return t[r].indexOf(c)!==-1}).length){t[i]=t[i].concat(t[r]),t.splice(r,1),n=!0;break}}return t.forEach(function(i){i=i.filter(function(a,c,g){return g.indexOf(a)===c});let r=i.pop();r!==void 0&&typeof r=="string"&&(e[r]=i)}),e}function Ne(s){return s!==void 0?s+1:1}function En(s){return s==="__proto__"?"___proto___":s}function Vi(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 Ji}from"fs";var We,Le,Re,jn=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,An=(Le=(We=process==null?void 0:process.versions)===null||We===void 0?void 0:We.node)!==null&&Le!==void 0?Le:(Re=process==null?void 0:process.version)===null||Re===void 0?void 0:Re.slice(1);if(An&&Number(An.match(/^([^.]+)/)[1])<jn)throw Error(`yargs parser supports a minimum Node.js version of ${jn}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);var Zi=process?process.env:{},Pn=new be({cwd:process.cwd,env:()=>Zi,format:qi,normalize:Ki,resolve:Qi,require:s=>{if(typeof _t<"u")return _t(s);if(s.match(/\.json$/))return JSON.parse(Ji(s,"utf8"));throw Error("only .json config files are supported in ESM")}}),se=function(t,e){return Pn.parse(t.slice(),e).argv};se.detailed=function(s,t){return Pn.parse(s.slice(),t)};se.camelCase=Lt;se.decamelize=me;se.looksLikeNumber=ge;var ze=se;import{basename as us,dirname as hs,extname as ds,relative as ps,resolve as Dn}from"path";function Sn(){return Xi()?0:1}function Xi(){return ki()&&!process.defaultApp}function ki(){return!!process.versions.electron}function Ue(s){return s.slice(Sn()+1)}function Mn(){return process.argv[Sn()]}var V=class s extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,s)}};import{readFileSync as ts,statSync as es,writeFile as ns}from"fs";import{format as is}from"util";import{resolve as ss}from"path";var In={fs:{readFileSync:ts,writeFile:ns},format:is,resolve:ss,exists:s=>{try{return es(s).isFile()}catch{return!1}}};var Ot,Te=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 c=[a];return~a.indexOf("%d")&&c.push(i),Ot.format.apply(Ot.format,c.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach(function(i,r){let a=e[r+1];n+=i,typeof a<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let t=this,e=this.writeQueue[0],n=e.directory,i=e.locale,r=e.cb,a=this._resolveLocaleFile(n,i),c=JSON.stringify(this.cache[i],null,2);Ot.fs.writeFile(a,c,"utf-8",function(g){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),r(g)})}_readLocaleFile(){let t={},e=this._resolveLocaleFile(this.directory,this.locale);try{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 $n(s,t){Ot=t;let e=new Te(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 rs=s=>$n(s,In),vn=rs;var ms="require is not supported by ESM",Fn="loading a directory of commands is not supported yet for ESM",re;try{re=fs(import.meta.url)}catch{re=process.cwd()}var gs=re.substring(0,re.lastIndexOf("node_modules")),He={assert:{notStrictEqual:os,strictEqual:as},cliui:Fe,findUp:Cn,getEnv:s=>process.env[s],inspect:ls,getCallerFile:()=>{throw new V(Fn)},getProcessArgvBin:Mn,mainFilename:gs||process.cwd(),Parser:ze,path:{basename:us,dirname:hs,extname:ds,relative:ps,resolve:Dn},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:cs,require:()=>{throw new V(ms)},requireDirectory:()=>{throw new V(Fn)},stringWidth:s=>[...s].length,y18n:vn({directory:Dn(re,"../../../locales"),updateFiles:!1})};function ot(s,t,e,n){e.assert.notStrictEqual(s,t,n)}function Ye(s,t){t.assert.strictEqual(typeof s,"string")}function Xt(s){return Object.keys(s)}function q(s){return!!s&&!!s.then&&typeof s.then=="function"}function 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,c)=>{let g=!1;a=a.replace(/\s/g,""),/\.+[\]>]/.test(a)&&c===e.length-1&&(g=!0),/^\[/.test(a)?r.optional.push({cmd:a.replace(n,"").split("|"),variadic:g}):r.demanded.push({cmd:a.replace(n,"").split("|"),variadic:g})}),r}var bs=["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,c]=n(),g=[].slice.call(a);for(;g.length&&g[g.length-1]===void 0;)g.pop();let w=c||g.length;if(w<r.demanded.length)throw new V(`Not enough arguments provided. Expected ${r.demanded.length} but received ${g.length}.`);let p=r.demanded.length+r.optional.length;if(w>p)throw new V(`Too many arguments provided. Expected max ${p} but received ${w}.`);r.demanded.forEach(h=>{let m=g.shift(),y=Nn(m);h.cmd.filter(_=>_===y||_==="*").length===0&&Wn(y,h.cmd,i),i+=1}),r.optional.forEach(h=>{if(g.length===0)return;let m=g.shift(),y=Nn(m);h.cmd.filter(_=>_===y||_==="*").length===0&&Wn(y,h.cmd,i),i+=1})}catch(i){console.warn(i.stack)}}function Nn(s){return Array.isArray(s)?"array":s===null?"null":typeof s}function Wn(s,t,e){throw new V(`Invalid ${bs[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 Ln(s){return s?s.map(t=>(t.applyBeforeValidation=!1,t)):[]}function Rt(s,t,e,n){return e.reduce((i,r)=>{if(r.applyBeforeValidation!==n)return i;if(r.mutates){if(r.applied)return i;r.applied=!0}if(q(i))return i.then(a=>Promise.all([a,r(a,t)])).then(([a,c])=>Object.assign(a,c));{let a=r(i,t);return q(a)?a.then(c=>Object.assign(i,c)):Object.assign(i,a)}},s)}function zt(s,t,e=n=>{throw n}){try{let n=ws(s)?s():s;return q(n)?n.then(i=>t(i)):t(n)}catch(n){return e(n)}}function ws(s){return typeof s=="function"}function Be(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)/,Ge=class{constructor(t,e,n,i){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=i,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,i){i=i||{},typeof i.recurse!="boolean"&&(i.recurse=!1),Array.isArray(i.extensions)||(i.extensions=["js"]);let r=typeof i.visit=="function"?i.visit:a=>a;i.visit=(a,c,g)=>{let w=r(a,c,g);if(w){if(this.requireCache.has(c))return w;this.requireCache.add(c),this.addHandler(w)}return w},this.shim.requireDirectory({require:e,filename:n},t,i)}addHandler(t,e,n,i,r,a){let c=[],g=Ln(r);if(i=i||(()=>{}),Array.isArray(t))if(ys(t))[t,...c]=t;else for(let w of t)this.addHandler(w);else if(_s(t)){let w=Array.isArray(t.command)||typeof t.command=="string"?t.command:this.moduleName(t);t.aliases&&(w=[].concat(w).concat(t.aliases)),this.addHandler(w,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated);return}else if(Rn(n)){this.addHandler([t].concat(c),e,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof t=="string"){let w=Pt(t);c=c.map(m=>Pt(m).cmd);let p=!1,h=[w.cmd].concat(c).filter(m=>kt.test(m)?(p=!0,!1):!0);h.length===0&&p&&h.push("$0"),p&&(w.cmd=h[0],c=h.slice(1),t=t.replace(kt,w.cmd)),c.forEach(m=>{this.aliasMap[m]=w.cmd}),e!==!1&&this.usage.command(t,e,p,c,a),this.handlers[w.cmd]={original:t,description:e,handler:i,builder:n||{},middlewares:g,deprecated:a,demanded:w.demanded,optional:w.optional},p&&(this.defaultCommand=this.handlers[w.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,i,r,a){let c=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,g=e.getInternalMethods().getContext(),w=g.commands.slice(),p=!t;t&&(g.commands.push(t),g.fullCommands.push(c.original));let h=this.applyBuilderUpdateUsageAndParse(p,c,e,n.aliases,w,i,r,a);return q(h)?h.then(m=>this.applyMiddlewareAndGetResult(p,c,m.innerArgv,g,r,m.aliases,e)):this.applyMiddlewareAndGetResult(p,c,h.innerArgv,g,r,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,i,r,a,c,g){let w=e.builder,p=n;if(ye(w)){n.getInternalMethods().getUsageInstance().freeze();let h=w(n.getInternalMethods().reset(i),g);if(q(h))return h.then(m=>(p=Un(m)?m:n,this.parseAndUpdateUsage(t,e,p,r,a,c)))}else Os(w)&&(n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(i),Object.keys(e.builder).forEach(h=>{p.option(h,w[h])}));return this.parseAndUpdateUsage(t,e,p,r,a,c)}parseAndUpdateUsage(t,e,n,i,r,a){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(i,e),e.description);let c=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,r,a);return q(c)?c.then(g=>({aliases:n.parsed.aliases,innerArgv:g})):{aliases:n.parsed.aliases,innerArgv:c}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&t.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(t,e){let n=kt.test(e.original)?e.original.replace(kt,"").trim():e.original,i=t.filter(r=>!kt.test(r));return i.push(n),`$0 ${i.join(" ")}`}handleValidationAndGetResult(t,e,n,i,r,a,c,g){if(!a.getInternalMethods().getHasOutput()){let w=a.getInternalMethods().runValidation(r,g,a.parsed.error,t);n=zt(n,p=>(w(p),p))}if(e.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let w=!!a.getOptions().configuration["populate--"];a.getInternalMethods().postProcess(n,w,!1,!1),n=Rt(n,a,c,!1),n=zt(n,p=>{let h=e.handler(p);return q(h)?h.then(()=>p):p}),t||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),q(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(p=>{try{a.getInternalMethods().getUsageInstance().fail(null,p)}catch{}})}return t||(i.commands.pop(),i.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,i,r,a,c){let g={};if(r)return n;c.getInternalMethods().getHasOutput()||(g=this.populatePositionals(e,n,i,c));let w=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),p=Rt(n,c,w,!0);return q(p)?p.then(h=>this.handleValidationAndGetResult(t,e,h,i,a,c,w,g)):this.handleValidationAndGetResult(t,e,p,i,a,c,w,g)}populatePositionals(t,e,n,i){e._=e._.slice(n.commands.length);let r=t.demanded.slice(0),a=t.optional.slice(0),c={};for(this.validation.positionalCount(r.length,e._.length);r.length;){let g=r.shift();this.populatePositional(g,e,c)}for(;a.length;){let g=a.shift();this.populatePositional(g,e,c)}return e._=n.commands.concat(e._.map(g=>""+g)),this.postProcessPositionals(e,c,this.cmdToParseOptions(t.original),i),c}populatePositional(t,e,n){let i=t.cmd[0];t.variadic?n[i]=e._.splice(0).map(String):e._.length&&(n[i]=[String(e._.shift())])}cmdToParseOptions(t){let e={array:[],default:{},alias:{},demand:{}},n=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 c=Object.assign({},r.configuration,{"populate--":!1}),g=this.shim.Parser.detailed(a,Object.assign({},r,{configuration:c}));if(g.error)i.getInternalMethods().getUsageInstance().fail(g.error.message,g.error);else{let w=Object.keys(e);Object.keys(e).forEach(p=>{w.push(...g.aliases[p])}),Object.keys(g.argv).forEach(p=>{w.includes(p)&&(e[p]||(e[p]=g.argv[p]),!this.isInConfigs(i,p)&&!this.isDefaulted(i,p)&&Object.prototype.hasOwnProperty.call(t,p)&&Object.prototype.hasOwnProperty.call(g.argv,p)&&(Array.isArray(t[p])||Array.isArray(g.argv[p]))?t[p]=[].concat(t[p],g.argv[p]):t[p]=g.argv[p])})}}isDefaulted(t,e){let{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){let{configObjects:n}=t.getOptions();return n.some(i=>Object.prototype.hasOwnProperty.call(i,e))||n.some(i=>Object.prototype.hasOwnProperty.call(i,this.shim.Parser.camelCase(e)))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){let n=kt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let e=this.defaultCommand.builder;if(ye(e))return e(t,!0);Rn(e)||Object.keys(e).forEach(n=>{t.option(n,e[n])})}moduleName(t){let e=Be(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(let i of[t,e,n]){if(typeof i=="string"||i===!1)return i;ot(i,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let t=this.frozens.pop();ot(t,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function zn(s,t,e,n){return new Ge(s,t,e,n)}function Rn(s){return typeof s=="object"&&!!s.builder&&typeof s.handler=="function"}function ys(s){return s.every(t=>typeof t=="string")}function ye(s){return typeof s=="function"}function Os(s){return typeof s=="object"}function _s(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 Cs(s){return typeof s=="boolean"}function Hn(s,t){let e=t.y18n.__,n={},i=[];n.failFn=function(C){i.push(C)};let r=null,a=null,c=!0;n.showHelpOnFail=function(C=!0,P){let[W,B]=typeof C=="string"?[!0,C]:[C,P];return s.getInternalMethods().isGlobalContext()&&(a=B),r=B,c=W,n};let g=!1;n.fail=function(C,P){let W=s.getInternalMethods().getLoggerInstance();if(i.length)for(let B=i.length-1;B>=0;--B){let et=i[B];if(Cs(et)){if(P)throw P;if(C)throw Error(C)}else et(C,P,n)}else{if(s.getExitProcess()&&Mt(!0),!g){g=!0,c&&(s.showHelp("error"),W.error()),(C||P)&&W.error(C||P);let B=r||a;B&&((C||P)&&W.error(""),W.error(B))}if(P=P||new V(C),s.getExitProcess())return s.exit(1);if(s.getInternalMethods().hasParseCallback())return s.exit(1,P);throw P}};let w=[],p=!1;n.usage=(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 m=[];n.command=function(C,P,W,B,et=!1){W&&(m=m.map(Y=>(Y[2]=!1,Y))),m.push([C,P||"",W,B,et])},n.getCommands=()=>m;let y={};n.describe=function(C,P){Array.isArray(C)?C.forEach(W=>{n.describe(W,P)}):typeof C=="object"?Object.keys(C).forEach(W=>{n.describe(W,C[W])}):y[C]=P},n.getDescriptions=()=>y;let E=[];n.epilog=M=>{E.push(M)};let _=!1,d;n.wrap=M=>{_=!0,d=M},n.getWrap=()=>t.getEnv("YARGS_DISABLE_WRAP")?null:(_||(d=Jt(),_=!0),d);let L="__yargsString__:";n.deferY18nLookup=M=>L+M,n.help=function(){if(R)return R;T();let C=s.customScriptName?s.$0:t.path.basename(s.$0),P=s.getDemandedOptions(),W=s.getDemandedCommands(),B=s.getDeprecatedOptions(),et=s.getGroups(),Y=s.getOptions(),nt=[];nt=nt.concat(Object.keys(y)),nt=nt.concat(Object.keys(P)),nt=nt.concat(Object.keys(W)),nt=nt.concat(Object.keys(Y.default)),nt=nt.filter(at),nt=Object.keys(nt.reduce((v,K)=>(K!=="_"&&(v[K]=!0),v),{}));let Ft=n.getWrap(),Q=t.cliui({width:Ft,wrap:!!Ft});if(!p){if(w.length)w.forEach(v=>{Q.div({text:`${v[0].replace(/\$0/g,C)}`}),v[1]&&Q.div({text:`${v[1]}`,padding:[1,0,0,0]})}),Q.div();else if(m.length){let v=null;W._?v=`${C} <${e("command")}>
|
|
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
|
-
`;m.forEach(E=>{y+=E}),t.fail(y)}};let g={};r.conflicts=function(h,m){j("<string|object> [array|string]",[h,m],arguments.length),typeof h=="object"?Object.keys(h).forEach(y=>{r.conflicts(y,h[y])}):(s.global(h),g[h]||(g[h]=[]),Array.isArray(m)?m.forEach(y=>r.conflicts(h,y)):g[h].push(m))},r.getConflicting=()=>g,r.conflicting=function(h){Object.keys(h).forEach(m=>{g[m]&&g[m].forEach(y=>{y&&h[m]!==void 0&&h[y]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",m,y))})}),s.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(g).forEach(m=>{g[m].forEach(y=>{y&&h[e.Parser.camelCase(m)]!==void 0&&h[e.Parser.camelCase(y)]!==void 0&&t.fail(n("Arguments %s and %s are mutually exclusive",m,y))})})},r.recommendCommands=function(h,m){m=m.sort((d,L)=>L.length-d.length);let E=null,_=1/0;for(let d=0,L;(L=m[d])!==void 0;d++){let z=Vn(h,L);z<=3&&z<_&&(_=z,E=L)}E&&t.fail(n("Did you mean %s?",E))},r.reset=function(h){return a=St(a,m=>!h[m]),g=St(g,m=>!h[m]),r};let w=[];return r.freeze=function(){w.push({implied:a,conflicting:g})},r.unfreeze=function(){let h=w.pop();ot(h,void 0,e),{implied:a,conflicting:g}=h},r}var Ke=[],oe;function ae(s,t,e,n){oe=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=Ss(t,s.extends);else try{a=_t.resolve(s.extends)}catch{return s}Ps(a),Ke.push(a),i=r?JSON.parse(oe.readFileSync(a,"utf8")):_t(s.extends),delete s.extends,i=ae(i,oe.path.dirname(a),e,oe)}return Ke=[],e?Qn(i,s):Object.assign({},i,s)}function Ps(s){if(Ke.indexOf(s)>-1)throw new V(`Circular extended configurations: '${s}'.`)}function Ss(s,t){return oe.path.resolve(s,t)}function Qn(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]=Qn(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,le,dt,ct,_e,It,Tt,Ce,pt,xe,mt,Ct,ft,gt,Ee,te,st,I,je,Ae,ut,Ht,ee,Yt,$t,Pe,F,Bt,Gt,Vt,N,Se,xt,X;function mi(s){return(t=[],e=s.process.cwd(),n)=>{let i=new on(t,e,n,s);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Jn=Symbol("copyDoubleDash"),Zn=Symbol("copyDoubleDash"),Qe=Symbol("deleteFromParserHintObject"),Xn=Symbol("emitWarning"),kn=Symbol("freeze"),ti=Symbol("getDollarZero"),qt=Symbol("getParserConfiguration"),ei=Symbol("getUsageConfiguration"),Je=Symbol("guessLocale"),ni=Symbol("guessVersion"),ii=Symbol("parsePositionalNumbers"),Ze=Symbol("pkgUp"),vt=Symbol("populateParserHintArray"),ne=Symbol("populateParserHintSingleValueDictionary"),Xe=Symbol("populateParserHintArrayDictionary"),ke=Symbol("populateParserHintDictionary"),tn=Symbol("sanitizeKey"),en=Symbol("setKey"),nn=Symbol("unfreeze"),si=Symbol("validateAsync"),ri=Symbol("getCommandInstance"),oi=Symbol("getContext"),ai=Symbol("getHasOutput"),li=Symbol("getLoggerInstance"),ci=Symbol("getParseContext"),fi=Symbol("getUsageInstance"),ui=Symbol("getValidationInstance"),Me=Symbol("hasParseCallback"),hi=Symbol("isGlobalContext"),Kt=Symbol("postProcess"),di=Symbol("rebase"),sn=Symbol("reset"),ce=Symbol("runYargsParserAndExecuteCommands"),rn=Symbol("runValidation"),pi=Symbol("setHasOutput"),Qt=Symbol("kTrackManuallySetKeys"),on=class{constructor(t=[],e,n,i){this.customScriptName=!1,this.parsed=!1,tt.set(this,void 0),Ut.set(this,void 0),le.set(this,{commands:[],fullCommands:[]}),dt.set(this,null),ct.set(this,null),_e.set(this,"show-hidden"),It.set(this,null),Tt.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),Ht.set(this,null),ee.set(this,{}),Yt.set(this,{}),$t.set(this,void 0),Pe.set(this,!1),F.set(this,void 0),Bt.set(this,!1),Gt.set(this,!1),Vt.set(this,!1),N.set(this,void 0),Se.set(this,{}),xt.set(this,null),X.set(this,void 0),A(this,F,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[ti](),this[sn](),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[Zn](),"f")}addHelpOpt(t,e){let n="help";return j("[string|boolean] [string]",[t,e],arguments.length),o(this,gt,"f")&&(this[Qe](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[Xe](this.alias.bind(this),"alias",t,e),this}array(t){return j("<array|string>",[t],arguments.length),this[vt]("array",t),this[Qt](t),this}boolean(t){return j("<array|string>",[t],arguments.length),this[vt]("boolean",t),this[Qt](t),this}check(t,e){return j("<function> [boolean]",[t,e],arguments.length),this.middleware((n,i)=>zt(()=>t(n,i.getOptions()),r=>(r?(typeof r=="string"||r instanceof Error)&&o(this,N,"f").fail(r.toString(),r):o(this,N,"f").fail(o(this,F,"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[Xe](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(j("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new V("coerce callback must be provided");for(let n of t)this.coerce(n,e);return this}else if(typeof t=="object"){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!e)throw new V("coerce callback must be provided");return o(this,I,"f").key[t]=!0,o(this,mt,"f").addCoerceMiddleware((n,i)=>{let r;return Object.prototype.hasOwnProperty.call(n,t)?zt(()=>(r=i.getAliases(),e(n[t])),c=>{n[t]=c;let g=i.getInternalMethods().getParserConfiguration()["strip-aliased"];if(r[t]&&g!==!0)for(let w of r[t])n[w]=c;return n},c=>{throw new V(c.message)}):n},t),this}conflicts(t,e){return j("<string|object> [string|array]",[t,e],arguments.length),o(this,X,"f").conflicts(t,e),this}config(t="config",e,n){return j("[object|string] [string|function] [function]",[t,e,n],arguments.length),typeof t=="object"&&!Array.isArray(t)?(t=ae(t,o(this,Ut,"f"),this[qt]()["deep-merge-config"]||!1,o(this,F,"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,F,"f").require;return o(this,tt,"f").addDirectory(t,n,o(this,F,"f").getCallerFile(),e),this}count(t){return j("<array|string>",[t],arguments.length),this[vt]("count",t),this[Qt](t),this}default(t,e,n){return j("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(Ye(t,o(this,F,"f")),o(this,I,"f").defaultDescription[t]=n),typeof e=="function"&&(Ye(t,o(this,F,"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=>{ot(n,!0,o(this,F,"f")),this.demandOption(i,n)}),e=1/0):typeof e!="number"&&(n=e,e=1/0),typeof t=="number"?(ot(n,!0,o(this,F,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach(i=>{ot(n,!0,o(this,F,"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[en](t,!0),o(this,N,"f").describe(t,e),this}detectLocale(t){return j("<boolean>",[t],arguments.length),A(this,Tt,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,F,"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 V("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,Tt,"f")}getExitProcess(){return o(this,pt,"f")}getGroups(){return Object.assign({},o(this,Ct,"f"),o(this,Yt,"f"))}getHelp(){if(A(this,ft,!0,"f"),!o(this,N,"f").hasCachedHelpMessage()){if(!this.parsed){let e=this[ce](o(this,$t,"f"),void 0,void 0,0,!0);if(q(e))return e.then(()=>o(this,N,"f").help())}let t=o(this,tt,"f").runDefaultBuilderOn(this);if(q(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,Gt,"f")}getStrictOptions(){return o(this,Vt,"f")}global(t,e){return j("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),e!==!1?o(this,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,Yt,"f")[e]||o(this,Ct,"f")[e];o(this,Yt,"f")[e]&&delete o(this,Yt,"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[Je](),o(this,F,"f").y18n.getLocale()):(A(this,Tt,!1,"f"),o(this,F,"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[Qt](t),this}option(t,e){if(j("<string|object> [object]",[t,e],arguments.length),typeof t=="object")Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof e!="object"&&(e={}),this[Qt](t),o(this,xt,"f")&&(t==="version"||e?.alias==="version")&&this[Xn](['"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")}}}[Qe](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]}[Xn](t,e,n){o(this,Ce,"f")[n]||(o(this,F,"f").process.emitWarning(t,e),o(this,Ce,"f")[n]=!0)}[kn](){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,Gt,"f"),strictOptions:o(this,Vt,"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,Ht,"f")}),o(this,N,"f").freeze(),o(this,X,"f").freeze(),o(this,tt,"f").freeze(),o(this,mt,"f").freeze()}[ti](){let t="",e;return/\b(node|iojs|electron)(\.exe)?$/.test(o(this,F,"f").process.argv()[0])?e=o(this,F,"f").process.argv().slice(1,2):e=o(this,F,"f").process.argv().slice(0,1),t=e.map(n=>{let i=this[di](o(this,Ut,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&i.length<n.length?i:n}).join(" ").trim(),o(this,F,"f").getEnv("_")&&o(this,F,"f").getProcessArgvBin()===o(this,F,"f").getEnv("_")&&(t=o(this,F,"f").getEnv("_").replace(`${o(this,F,"f").path.dirname(o(this,F,"f").process.execPath())}/`,"")),t}[qt](){return o(this,Ae,"f")}[ei](){return o(this,Se,"f")}[Je](){if(!o(this,Tt,"f"))return;let t=o(this,F,"f").getEnv("LC_ALL")||o(this,F,"f").getEnv("LC_MESSAGES")||o(this,F,"f").getEnv("LANG")||o(this,F,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[ni](){return this[Ze]().version||"unknown"}[ii](t){let e=t["--"]?t["--"]:t._;for(let n=0,i;(i=e[n])!==void 0;n++)o(this,F,"f").Parser.looksLikeNumber(i)&&Number.isSafeInteger(Math.floor(parseFloat(`${i}`)))&&(e[n]=Number(i));return t}[Ze](t){let e=t||"*";if(o(this,ee,"f")[e])return o(this,ee,"f")[e];let n={};try{let i=t||o(this,F,"f").mainFilename;!t&&o(this,F,"f").path.extname(i)&&(i=o(this,F,"f").path.dirname(i));let r=o(this,F,"f").findUp(i,(a,c)=>{if(c.includes("package.json"))return"package.json"});ot(r,void 0,o(this,F,"f")),n=JSON.parse(o(this,F,"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[tn](n),o(this,I,"f")[t].push(n)})}[ne](t,e,n,i){this[ke](t,e,n,i,(r,a,c)=>{o(this,I,"f")[r][a]=c})}[Xe](t,e,n,i){this[ke](t,e,n,i,(r,a,c)=>{o(this,I,"f")[r][a]=(o(this,I,"f")[r][a]||[]).concat(c)})}[ke](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[tn](n),i)}[tn](t){return t==="__proto__"?"___proto___":t}[en](t,e){return this[ne](this[en].bind(this),"key",t,e),this}[nn](){var t,e,n,i,r,a,c,g,w,p,h,m;let y=o(this,xe,"f").pop();ot(y,void 0,o(this,F,"f"));let E;t=this,e=this,n=this,i=this,r=this,a=this,c=this,g=this,w=this,p=this,h=this,m=this,{options:{set value(_){A(t,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(c,Bt,_,"f")}}.value,strictCommands:{set value(_){A(g,Gt,_,"f")}}.value,strictOptions:{set value(_){A(w,Vt,_,"f")}}.value,completionCommand:{set value(_){A(p,ct,_,"f")}}.value,parseFn:{set value(_){A(h,ut,_,"f")}}.value,parseContext:{set value(_){A(m,Ht,_,"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()}[si](t,e){return zt(e,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[ri].bind(this),getContext:this[oi].bind(this),getHasOutput:this[ai].bind(this),getLoggerInstance:this[li].bind(this),getParseContext:this[ci].bind(this),getParserConfiguration:this[qt].bind(this),getUsageConfiguration:this[ei].bind(this),getUsageInstance:this[fi].bind(this),getValidationInstance:this[ui].bind(this),hasParseCallback:this[Me].bind(this),isGlobalContext:this[hi].bind(this),postProcess:this[Kt].bind(this),reset:this[sn].bind(this),runValidation:this[rn].bind(this),runYargsParserAndExecuteCommands:this[ce].bind(this),setHasOutput:this[pi].bind(this)}}[ri](){return o(this,tt,"f")}[oi](){return o(this,le,"f")}[ai](){return o(this,ft,"f")}[li](){return o(this,te,"f")}[ci](){return o(this,Ht,"f")||{}}[fi](){return o(this,N,"f")}[ui](){return o(this,X,"f")}[Me](){return!!o(this,ut,"f")}[hi](){return o(this,Ee,"f")}[Kt](t,e,n,i){return n||q(t)||(e||(t=this[Jn](t)),(this[qt]()["parse-positional-numbers"]||this[qt]()["parse-positional-numbers"]===void 0)&&(t=this[ii](t)),i&&(t=Rt(t,this,o(this,mt,"f").getMiddleware(),!1))),t}[sn](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(c=>{n[c]=!0})}),Object.assign(o(this,Yt,"f"),Object.keys(o(this,Ct,"f")).reduce((a,c)=>{let g=o(this,Ct,"f")[c].filter(w=>!(w in n));return g.length>0&&(a[c]=g),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(c=>!n[c])}),r.forEach(a=>{e[a]=St(o(this,I,"f")[a],c=>!n[c])}),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):Hn(this,o(this,F,"f")),"f"),A(this,X,o(this,X,"f")?o(this,X,"f").reset(n):Kn(this,o(this,N,"f"),o(this,F,"f")),"f"),A(this,tt,o(this,tt,"f")?o(this,tt,"f").reset():zn(o(this,N,"f"),o(this,X,"f"),o(this,mt,"f"),o(this,F,"f")),"f"),o(this,dt,"f")||A(this,dt,Gn(this,o(this,N,"f"),o(this,tt,"f"),o(this,F,"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}[di](t,e){return o(this,F,"f").path.relative(t,e)}[ce](t,e,n,i=0,r=!1){let a=!!n||r;t=t||o(this,$t,"f"),o(this,I,"f").__=o(this,F,"f").y18n.__,o(this,I,"f").configuration=this[qt]();let c=!!o(this,I,"f").configuration["populate--"],g=Object.assign({},o(this,I,"f").configuration,{"populate--":!0}),w=o(this,F,"f").Parser.detailed(t,Object.assign({},o(this,I,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),p=Object.assign(w.argv,o(this,Ht,"f")),h,m=w.aliases,y=!1,E=!1;Object.keys(p).forEach(_=>{_===o(this,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[Je](),e)return this[Kt](p,c,!!n,!1);o(this,gt,"f")&&[o(this,gt,"f")].concat(m[o(this,gt,"f")]||[]).filter(T=>T.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,L=y||d||r;if(p._.length){if(_.length){let z;for(let T=i||0,R;p._[T]!==void 0;T++)if(R=String(p._[T]),_.includes(R)&&R!==o(this,ct,"f")){let H=o(this,tt,"f").runCommand(R,this,w,T+1,r,y||E||r);return this[Kt](H,c,!!n,!1)}else if(!z&&R!==o(this,ct,"f")){z=R;break}!o(this,tt,"f").hasDefaultCommand()&&o(this,Pe,"f")&&z&&!L&&o(this,X,"f").recommendCommands(z,_)}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()&&!L){let z=o(this,tt,"f").runCommand(null,this,w,0,r,y||E||r);return this[Kt](z,c,!!n,!1)}if(d){o(this,pt,"f")&&Mt(!0),t=[].concat(t);let z=t.slice(t.indexOf(`--${o(this,dt,"f").completionKey}`)+1);return o(this,dt,"f").getCompletion(z,(T,R)=>{if(T)throw new V(T.message);(R||[]).forEach(H=>{o(this,te,"f").log(H)}),this.exit(0)}),this[Kt](p,!c,!!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(z=>o(this,I,"f").skipValidation.indexOf(z)>=0&&p[z]===!0)),!a){if(w.error)throw new V(w.error.message);if(!d){let z=this[rn](m,{},w.error);n||(h=Rt(p,this,o(this,mt,"f").getMiddleware(),!0)),h=this[si](z,h??p),q(h)&&!n&&(h=h.then(()=>Rt(p,this,o(this,mt,"f").getMiddleware(),!1)))}}}catch(_){if(_ instanceof V)o(this,N,"f").fail(_.message,_);else throw _}return this[Kt](h??p,c,!!n,!0)}[rn](t,e,n,i){let r={...this.getDemandedOptions()};return a=>{if(n)throw new V(n.message);o(this,X,"f").nonOptionCount(a),o(this,X,"f").requiredArguments(a,r);let c=!1;o(this,Gt,"f")&&(c=o(this,X,"f").unknownCommands(a)),o(this,Bt,"f")&&!c?o(this,X,"f").unknownArguments(a,t,e,!!i):o(this,Vt,"f")&&o(this,X,"f").unknownArguments(a,t,{},!1,!1),o(this,X,"f").limitedChoices(a),o(this,X,"f").implications(a),o(this,X,"f").conflicting(a)}}[pi](){A(this,ft,!0,"f")}[Qt](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 Un(s){return!!s&&typeof s.getInternalMethods=="function"}var Ms=mi(He),gi=Ms;await gi(Ue(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 mn(e,{darkMode:t,format:n,output:i,transparent:r,verbose:a}),process.exit(0)}catch(c){console.error("Error during conversion:",c),process.exit(1)}}).alias("h","help").version("version",an).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.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 R from"express";import L from"node:net";import O from"node:os";var b=class extends Error{constructor(t){super(`${t} is locked`)}},u={old:new Set,young:new Set},j=1e3*15;var w,F=()=>{let e=O.networkInterfaces(),t=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(e))for(let o of r)t.add(o.address);return t},I=e=>new Promise((t,r)=>{let o=L.createServer();o.unref(),o.on("error",r),o.listen(e,()=>{let{port:n}=o.address();o.close(()=>{t(n)})})}),D=async(e,t)=>{if(e.host||e.port===0)return I(e);for(let r of t)try{await I({port:e.port,host:r})}catch(o){if(!["EADDRNOTAVAIL","EINVAL"].includes(o.code))throw o}return e.port},q=function*(e){e&&(yield*e),yield 0};async function P(e){let t,r=new Set;if(e&&(e.port&&(t=typeof e.port=="number"?[e.port]:e.port),e.exclude)){let n=e.exclude;if(typeof n[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let a of n){if(typeof a!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(a))throw new TypeError(`Number ${a} in the exclude option is not a safe integer and can't be used`)}r=new Set(n)}w===void 0&&(w=setTimeout(()=>{w=void 0,u.old=u.young,u.young=new Set},j),w.unref&&w.unref());let o=F();for(let n of q(t))try{if(r.has(n))continue;let a=await D({...e,port:n},o);for(;u.old.has(a)||u.young.has(a);){if(n!==0)throw new b(n);a=await D({...e,port:n},o)}return u.young.add(a),a}catch(a){if(!["EADDRINUSE","EACCES"].includes(a.code)&&!(a instanceof b))throw a}throw new Error("No available ports found")}import M from"node:fs/promises";import N from"node:os";import l from"node:path";import{dirname as V}from"node:path";import{fileURLToPath as _}from"node:url";import G from"puppeteer";import U from"node:os";var T=U.homedir();function y(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return T?e.replace(/^~(?=$|\/|\\)/,T):e}var H={darkMode:!1,format:"svg",output:"./",transparent:!1,verbose:!0};async function W(e,t={}){let r={...H,...X(t)},{darkMode:o,format:n,output:a,transparent:p,verbose:s}=r,c=!e.startsWith("https://www.tldraw.com/");s&&console.log(c?"Local file detected":"tldraw URL detected");let h=0,m;if(c){s&&console.log("Starting tldraw server...");let d=V(_(import.meta.url)),g=l.join(d,d.endsWith("/src/lib")?"../../dist/tldraw":d.endsWith("/dist/lib")?"../tldraw":"../dist/tldraw");s&&console.log(`tldraw served from "${g}"`),m=await J(g),h=m.address().port,s&&console.log(`tldraw hosted at "http://localhost:${h}"`)}s&&console.log("Starting Puppeteer...");let S=await G.launch({args:c?["--no-sandbox","--disable-web-security"]:[],headless:"new"}),i=await S.newPage();z(i,s);let $=await i.target().createCDPSession();if(await $.send("Browser.setDownloadBehavior",{behavior:"allowAndName",downloadPath:N.tmpdir(),eventsEnabled:!0}),c){await i.setRequestInterception(!0),i.on("request",f=>{f.url().endsWith("favicon.ico")?f.respond({status:200}):f.continue()});let d=l.resolve(y(e));s&&console.log(`Loading tldr file "${d}"`);let g=await M.readFile(d,"utf8");await i.evaluateOnNewDocument(f=>{localStorage.clear(),localStorage.setItem("tldrData",f)},g)}let x=c?`http://localhost:${h}`:e;s&&console.log(`Navigating to: ${x}`),await i.goto(x,{waitUntil:"networkidle0"}),s&&console.log(`Setting background transparency: ${p}`),await ee(i,p),s&&console.log(`Setting dark mode: ${o}`);let k=await Z(i);await A(i,o),s&&console.log("Requesting download"),await Y(i),await Q(i,["main.menu","menu-item.edit","menu-item.export-as",`menu-item.export-as-${n}`]);let E=await K($);s&&console.log("Download complete"),s&&console.log(`Restoring dark mode: ${k}`),await A(i,k),await S.close(),s&&console.log("Stopped Puppeteer"),c&&m&&(m.close(),s&&console.log("Stopped tldraw server"));let B=c?l.basename(e,l.extname(e)):E,C=l.join(N.tmpdir(),E),v=y(l.join(a,`${B}.${n}`));return await M.rename(C,v),s&&console.log(`Saved to "${v}"`),l.resolve(v)}function z(e,t){e.on("console",r=>{let o=r.type(),n=r.text();o==="error"?console.error(`[Browser] ${n}`):o==="warning"?console.warn(`[Browser] ${n}`):t&&console.log(`[Browser] ${n}`)})}async function J(e){let t=R(),r=await P();return t.use(R.static(e)),new Promise((o,n)=>{let a=t.listen(r,()=>{o(a)});a.on("error",p=>{n(p)})})}async function K(e){return new Promise((t,r)=>{e.on("Browser.downloadProgress",o=>{o.state==="completed"?t(o.guid):o.state==="canceled"&&r(new Error("Download was canceled"))})})}async function Q(e,t){for(let r of t)await e.waitForSelector(`[data-testid="${r}"]`),await e.click(`[data-testid="${r}"]`)}function X(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}async function Y(e){await e.evaluate("app.clearOpenMenus()")}async function Z(e){return!!await e.evaluate("editor.user.getUserPreferences().isDarkMode")}async function A(e,t){await e.evaluate(`editor.user.updateUserPreferences({ isDarkMode: ${t}})`)}async function ee(e,t){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.0
|
|
3
|
+
"version": "2.1.0",
|
|
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",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
60
61
|
"eslint-plugin-react-refresh": "^0.4.5",
|
|
61
62
|
"get-port": "^7.0.0",
|
|
63
|
+
"path-type": "^5.0.0",
|
|
62
64
|
"react": "^18.2.0",
|
|
63
65
|
"react-dom": "^18.2.0",
|
|
64
66
|
"tsx": "^4.7.0",
|
|
@@ -66,6 +68,7 @@
|
|
|
66
68
|
"untildify": "^5.0.0",
|
|
67
69
|
"vite": "^5.0.11",
|
|
68
70
|
"vitest": "^1.2.0",
|
|
71
|
+
"voca": "^1.4.1",
|
|
69
72
|
"yargs": "^17.7.2"
|
|
70
73
|
},
|
|
71
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
|
|