@capgo/cli 7.36.0 → 7.37.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/dist/index.js +99 -99
- package/dist/package.json +1 -1
- package/dist/src/build/credentials-command.d.ts.map +1 -1
- package/dist/src/build/request.d.ts.map +1 -1
- package/dist/src/sdk.js +27 -27
- package/package.json +1 -1
package/dist/src/sdk.js
CHANGED
|
@@ -98,15 +98,15 @@ ${n?" ":see.pointerSmall} ${gd.red().italic(r)}`,"")),this.out.write(nee.line+vc
|
|
|
98
98
|
`+aee(u.description,{margin:3,width:this.out.columns})))),this.outputText+=`${o} ${s}${ii.gray(a)}
|
|
99
99
|
`}}this.out.write(this.outputText)}};DP.exports=ow});var SP=_((Z0e,CP)=>{"use strict";var wd=dt(),fee=ni(),vP=cn(),EP=vP.style,hee=vP.clear,_P=Je(),bP=_P.cursor,dee=_P.erase,aw=class extends fee{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
100
100
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
101
|
-
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,r){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(bP.hide):this.out.write(hee(this.outputText,this.out.columns)),super.render(),this.outputText=[EP.symbol(this.done,this.aborted),wd.bold(this.msg),EP.delimiter(this.done),this.value?this.inactive:wd.cyan().underline(this.inactive),wd.gray("/"),this.value?wd.cyan().underline(this.active):this.active].join(" "),this.out.write(dee.line+bP.to(0)+this.outputText))}};CP.exports=aw});var xn=_((Q0e,AP)=>{"use strict";var uw=class t{constructor({token:e,date:r,parts:n,locales:i}){this.token=e,this.date=r||new Date,this.parts=n||[this],this.locales=i||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((r,n)=>n>e&&r instanceof t)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),r=e.indexOf(this);return e.find((n,i)=>i>r&&n instanceof t)}toString(){return String(this.date)}};AP.exports=uw});var xP=_((ewe,OP)=>{"use strict";var pee=xn(),cw=class extends pee{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};OP.exports=cw});var IP=_((twe,TP)=>{"use strict";var mee=xn(),gee=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th"),lw=class extends mee{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),r=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+gee(e):this.token==="d"?r+1:this.token==="ddd"?this.locales.weekdaysShort[r]:this.token==="dddd"?this.locales.weekdays[r]:e}};TP.exports=lw});var PP=_((rwe,FP)=>{"use strict";var yee=xn(),fw=class extends yee{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};FP.exports=fw});var kP=_((nwe,RP)=>{"use strict";var Dee=xn(),hw=class extends Dee{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};RP.exports=hw});var $P=_((iwe,NP)=>{"use strict";var wee=xn(),dw=class extends wee{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};NP.exports=dw});var jP=_((swe,LP)=>{"use strict";var Eee=xn(),pw=class extends Eee{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),r=this.token.length;return r===2?String(e+1).padStart(2,"0"):r===3?this.locales.monthsShort[e]:r===4?this.locales.months[e]:String(e+1)}};LP.exports=pw});var MP=_((owe,BP)=>{"use strict";var bee=xn(),mw=class extends bee{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};BP.exports=mw});var UP=_((awe,qP)=>{"use strict";var vee=xn(),gw=class extends vee{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};qP.exports=gw});var VP=_((uwe,HP)=>{"use strict";HP.exports={DatePart:xn(),Meridiem:xP(),Day:IP(),Hours:PP(),Milliseconds:kP(),Minutes:$P(),Month:jP(),Seconds:MP(),Year:UP()}});var
|
|
101
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,r){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(bP.hide):this.out.write(hee(this.outputText,this.out.columns)),super.render(),this.outputText=[EP.symbol(this.done,this.aborted),wd.bold(this.msg),EP.delimiter(this.done),this.value?this.inactive:wd.cyan().underline(this.inactive),wd.gray("/"),this.value?wd.cyan().underline(this.active):this.active].join(" "),this.out.write(dee.line+bP.to(0)+this.outputText))}};CP.exports=aw});var xn=_((Q0e,AP)=>{"use strict";var uw=class t{constructor({token:e,date:r,parts:n,locales:i}){this.token=e,this.date=r||new Date,this.parts=n||[this],this.locales=i||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((r,n)=>n>e&&r instanceof t)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),r=e.indexOf(this);return e.find((n,i)=>i>r&&n instanceof t)}toString(){return String(this.date)}};AP.exports=uw});var xP=_((ewe,OP)=>{"use strict";var pee=xn(),cw=class extends pee{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};OP.exports=cw});var IP=_((twe,TP)=>{"use strict";var mee=xn(),gee=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th"),lw=class extends mee{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),r=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+gee(e):this.token==="d"?r+1:this.token==="ddd"?this.locales.weekdaysShort[r]:this.token==="dddd"?this.locales.weekdays[r]:e}};TP.exports=lw});var PP=_((rwe,FP)=>{"use strict";var yee=xn(),fw=class extends yee{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};FP.exports=fw});var kP=_((nwe,RP)=>{"use strict";var Dee=xn(),hw=class extends Dee{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};RP.exports=hw});var $P=_((iwe,NP)=>{"use strict";var wee=xn(),dw=class extends wee{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};NP.exports=dw});var jP=_((swe,LP)=>{"use strict";var Eee=xn(),pw=class extends Eee{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),r=this.token.length;return r===2?String(e+1).padStart(2,"0"):r===3?this.locales.monthsShort[e]:r===4?this.locales.months[e]:String(e+1)}};LP.exports=pw});var MP=_((owe,BP)=>{"use strict";var bee=xn(),mw=class extends bee{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};BP.exports=mw});var UP=_((awe,qP)=>{"use strict";var vee=xn(),gw=class extends vee{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};qP.exports=gw});var VP=_((uwe,HP)=>{"use strict";HP.exports={DatePart:xn(),Meridiem:xP(),Day:IP(),Hours:PP(),Milliseconds:kP(),Minutes:$P(),Month:jP(),Seconds:MP(),Year:UP()}});var eR=_((cwe,QP)=>{"use strict";function zP(t,e,r,n,i,s,o){try{var a=t[s](o),u=a.value}catch(c){r(c);return}a.done?e(u):Promise.resolve(u).then(n,i)}function KP(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(u){zP(s,n,i,o,a,"next",u)}function a(u){zP(s,n,i,o,a,"throw",u)}o(void 0)})}}var yw=dt(),_ee=ni(),ww=cn(),GP=ww.style,WP=ww.clear,Cee=ww.figures,ZP=Je(),See=ZP.erase,XP=ZP.cursor,si=VP(),YP=si.DatePart,Aee=si.Meridiem,Oee=si.Day,xee=si.Hours,Tee=si.Milliseconds,Iee=si.Minutes,Fee=si.Month,Pee=si.Seconds,Ree=si.Year,kee=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,JP={1:({token:t})=>t.replace(/\\(.)/g,"$1"),2:t=>new Oee(t),3:t=>new Fee(t),4:t=>new Ree(t),5:t=>new Aee(t),6:t=>new xee(t),7:t=>new Iee(t),8:t=>new Pee(t),9:t=>new Tee(t)},Nee={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},Dw=class extends _ee{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(Nee,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=WP("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let r;for(this.parts=[];r=kee.exec(e);){let i=r.shift(),s=r.findIndex(o=>o!=null);this.parts.push(s in JP?JP[s]({token:r[s]||i,date:this.date,parts:this.parts,locales:this.locales}):r[s]||i)}let n=this.parts.reduce((i,s)=>(typeof s=="string"&&typeof i[i.length-1]=="string"?i[i.length-1]+=s:i.push(s),i),[]);this.parts.splice(0),this.parts.push(...n),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof YP)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
102
102
|
`),this.close()}validate(){var e=this;return KP(function*(){let r=yield e.validator(e.value);typeof r=="string"&&(e.errorMsg=r,r=!1),e.error=!r})()}submit(){var e=this;return KP(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
|
|
103
103
|
`),e.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(r=>r instanceof YP)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(XP.hide):this.out.write(WP(this.outputText,this.out.columns)),super.render(),this.outputText=[GP.symbol(this.done,this.aborted),yw.bold(this.msg),GP.delimiter(!1),this.parts.reduce((e,r,n)=>e.concat(n===this.cursor&&!this.done?yw.cyan().underline(r.toString()):r),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
104
104
|
`).reduce((e,r,n)=>e+`
|
|
105
|
-
${n?" ":Cee.pointerSmall} ${yw.red().italic(r)}`,"")),this.out.write(See.line+XP.to(0)+this.outputText))}};QP.exports=Dw});var
|
|
106
|
-
`),this.close()}validate(){var e=this;return
|
|
107
|
-
`),e.close()})()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,r){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=n,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(bd.down(Bee(this.outputError,this.out.columns)-1)+
|
|
105
|
+
${n?" ":Cee.pointerSmall} ${yw.red().italic(r)}`,"")),this.out.write(See.line+XP.to(0)+this.outputText))}};QP.exports=Dw});var aR=_((lwe,oR)=>{"use strict";function tR(t,e,r,n,i,s,o){try{var a=t[s](o),u=a.value}catch(c){r(c);return}a.done?e(u):Promise.resolve(u).then(n,i)}function rR(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(u){tR(s,n,i,o,a,"next",u)}function a(u){tR(s,n,i,o,a,"throw",u)}o(void 0)})}}var Ed=dt(),$ee=ni(),sR=Je(),bd=sR.cursor,Lee=sR.erase,vd=cn(),Ew=vd.style,jee=vd.figures,nR=vd.clear,Bee=vd.lines,Mee=/[0-9]/,bw=t=>t!==void 0,iR=(t,e)=>{let r=Math.pow(10,e);return Math.round(t*r)/r},vw=class extends $ee{constructor(e={}){super(e),this.transform=Ew.render(e.style),this.msg=e.message,this.initial=bw(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=bw(e.min)?e.min:-1/0,this.max=bw(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=Ed.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${iR(e,this.round)}`),this._value=iR(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||Mee.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
106
|
+
`),this.close()}validate(){var e=this;return rR(function*(){let r=yield e.validator(e.value);typeof r=="string"&&(e.errorMsg=r,r=!1),e.error=!r})()}submit(){var e=this;return rR(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}let r=e.value;e.value=r!==""?r:e.initial,e.done=!0,e.aborted=!1,e.error=!1,e.fire(),e.render(),e.out.write(`
|
|
107
|
+
`),e.close()})()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,r){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=n,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(bd.down(Bee(this.outputError,this.out.columns)-1)+nR(this.outputError,this.out.columns)),this.out.write(nR(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Ew.symbol(this.done,this.aborted),Ed.bold(this.msg),Ew.delimiter(this.done),!this.done||!this.done&&!this.placeholder?Ed[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
108
108
|
`).reduce((e,r,n)=>e+`
|
|
109
|
-
${n?" ":jee.pointerSmall} ${Ed.red().italic(r)}`,"")),this.out.write(Lee.line+bd.to(0)+this.outputText+bd.save+this.outputError+bd.restore))}};
|
|
109
|
+
${n?" ":jee.pointerSmall} ${Ed.red().italic(r)}`,"")),this.out.write(Lee.line+bd.to(0)+this.outputText+bd.save+this.outputError+bd.restore))}};oR.exports=vw});var Cw=_((fwe,lR)=>{"use strict";var Tn=dt(),qee=Je(),Uee=qee.cursor,Hee=ni(),Cc=cn(),uR=Cc.clear,Hi=Cc.figures,cR=Cc.style,Vee=Cc.wrap,zee=Cc.entriesToDisplay,_w=class extends Hee{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((r,n)=>(typeof r=="string"&&(r={title:r,value:n}),{title:r&&(r.title||r.value||r),description:r&&r.description,value:r&&(r.value===void 0?n:r.value),selected:r&&r.selected,disabled:r&&r.disabled})),this.clear=uR("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
110
110
|
`),this.close()}submit(){let e=this.value.filter(r=>r.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
111
111
|
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(r=>!r.disabled).forEach(r=>r.selected=e),this.render()}_(e,r){if(e===" ")this.handleSpaceToggle();else if(e==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
112
112
|
Instructions:
|
|
@@ -116,13 +116,13 @@ Instructions:
|
|
|
116
116
|
`:"")+" enter/return: Complete answer":""}renderOption(e,r,n,i){let s=(r.selected?Tn.green(Hi.radioOn):Hi.radioOff)+" "+i+" ",o,a;return r.disabled?o=e===n?Tn.gray().underline(r.title):Tn.strikethrough().gray(r.title):(o=e===n?Tn.cyan().underline(r.title):r.title,e===n&&r.description&&(a=` - ${r.description}`,(s.length+o.length+a.length>=this.out.columns||r.description.split(/\r?\n/).length>1)&&(a=`
|
|
117
117
|
`+Vee(r.description,{margin:s.length,width:this.out.columns})))),s+o+Tn.gray(a||"")}paginateOptions(e){if(e.length===0)return Tn.red("No matches for this query.");let r=zee(this.cursor,e.length,this.optionsPerPage),n=r.startIndex,i=r.endIndex,s,o=[];for(let a=n;a<i;a++)a===n&&n>0?s=Hi.arrowUp:a===i-1&&i<e.length?s=Hi.arrowDown:s=" ",o.push(this.renderOption(this.cursor,e[a],a,s));return`
|
|
118
118
|
`+o.join(`
|
|
119
|
-
`)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[Tn.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(Tn.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(Uee.hide),super.render();let e=[
|
|
119
|
+
`)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[Tn.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(Tn.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(Uee.hide),super.render();let e=[cR.symbol(this.done,this.aborted),Tn.bold(this.msg),cR.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=Tn.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=uR(e,this.out.columns)}};lR.exports=_w});var yR=_((hwe,gR)=>{"use strict";function fR(t,e,r,n,i,s,o){try{var a=t[s](o),u=a.value}catch(c){r(c);return}a.done?e(u):Promise.resolve(u).then(n,i)}function Kee(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(u){fR(s,n,i,o,a,"next",u)}function a(u){fR(s,n,i,o,a,"throw",u)}o(void 0)})}}var Sc=dt(),Gee=ni(),mR=Je(),Wee=mR.erase,hR=mR.cursor,Ac=cn(),Sw=Ac.style,dR=Ac.clear,Aw=Ac.figures,Xee=Ac.wrap,Yee=Ac.entriesToDisplay,pR=(t,e)=>t[e]&&(t[e].value||t[e].title||t[e]),Jee=(t,e)=>t[e]&&(t[e].title||t[e].value||t[e]),Zee=(t,e)=>{let r=t.findIndex(n=>n.value===e||n.title===e);return r>-1?r:void 0},Ow=class extends Gee{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:Zee(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=Sw.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=dR("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=pR(this.suggestions,e):this.value=this.fallback.value,this.fire()}complete(e){var r=this;return Kee(function*(){let n=r.completing=r.suggest(r.input,r.choices),i=yield n;if(r.completing!==n)return;r.suggestions=i.map((o,a,u)=>({title:Jee(u,a),value:pR(u,a),description:o.description})),r.completing=!1;let s=Math.max(i.length-1,0);r.moveSelect(Math.min(s,r.select)),e&&e()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
120
120
|
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
121
121
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
122
122
|
`),this.close()}_(e,r){let n=this.input.slice(0,this.cursor),i=this.input.slice(this.cursor);this.input=`${n}${e}${i}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),r=this.input.slice(this.cursor);this.input=`${e}${r}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor+1);this.input=`${e}${r}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,r,n,i){let s,o=n?Aw.arrowUp:i?Aw.arrowDown:" ",a=r?Sc.cyan().underline(e.title):e.title;return o=(r?Sc.cyan(Aw.pointer)+" ":" ")+o,e.description&&(s=` - ${e.description}`,(o.length+a.length+s.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(s=`
|
|
123
|
-
`+Xee(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Sc.gray(s||"")}render(){if(this.closed)return;this.firstRender?this.out.write(
|
|
123
|
+
`+Xee(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Sc.gray(s||"")}render(){if(this.closed)return;this.firstRender?this.out.write(hR.hide):this.out.write(dR(this.outputText,this.out.columns)),super.render();let e=Yee(this.select,this.choices.length,this.limit),r=e.startIndex,n=e.endIndex;if(this.outputText=[Sw.symbol(this.done,this.aborted,this.exited),Sc.bold(this.msg),Sw.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let i=this.suggestions.slice(r,n).map((s,o)=>this.renderOption(s,this.select===o+r,o===0&&r>0,o+r===n-1&&n<this.choices.length)).join(`
|
|
124
124
|
`);this.outputText+=`
|
|
125
|
-
`+(i||Sc.gray(this.fallback.title))}this.out.write(Wee.line+
|
|
125
|
+
`+(i||Sc.gray(this.fallback.title))}this.out.write(Wee.line+hR.to(0)+this.outputText)}};gR.exports=Ow});var bR=_((dwe,ER)=>{"use strict";var oi=dt(),Qee=Je(),ete=Qee.cursor,tte=Cw(),Tw=cn(),DR=Tw.clear,wR=Tw.style,Ia=Tw.figures,xw=class extends tte{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=DR("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(n=>this.inputValue?!!(typeof n.title=="string"&&n.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof n.value=="string"&&n.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let r=this.filteredOptions.findIndex(n=>n===e);this.cursor=r<0?0:r,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,r){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
126
126
|
Instructions:
|
|
127
127
|
${Ia.arrowUp}/${Ia.arrowDown}: Highlight option
|
|
128
128
|
${Ia.arrowLeft}/${Ia.arrowRight}/[space]: Toggle selection
|
|
@@ -130,31 +130,31 @@ Instructions:
|
|
|
130
130
|
enter/return: Complete answer
|
|
131
131
|
`:""}renderCurrentInput(){return`
|
|
132
132
|
Filtered results for: ${this.inputValue?this.inputValue:oi.gray("Enter something to filter")}
|
|
133
|
-
`}renderOption(e,r,n){let i;return r.disabled?i=e===n?oi.gray().underline(r.title):oi.strikethrough().gray(r.title):i=e===n?oi.cyan().underline(r.title):r.title,(r.selected?oi.green(Ia.radioOn):Ia.radioOff)+" "+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[oi.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(oi.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(ete.hide),super.render();let e=[
|
|
133
|
+
`}renderOption(e,r,n){let i;return r.disabled?i=e===n?oi.gray().underline(r.title):oi.strikethrough().gray(r.title):i=e===n?oi.cyan().underline(r.title):r.title,(r.selected?oi.green(Ia.radioOn):Ia.radioOff)+" "+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[oi.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(oi.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(ete.hide),super.render();let e=[wR.symbol(this.done,this.aborted),oi.bold(this.msg),wR.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=oi.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=DR(e,this.out.columns)}};ER.exports=xw});var xR=_((pwe,OR)=>{"use strict";var vR=dt(),rte=ni(),SR=cn(),_R=SR.style,nte=SR.clear,AR=Je(),ite=AR.erase,CR=AR.cursor,Iw=class extends rte{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
134
134
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
135
|
-
`),this.close()}_(e,r){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(
|
|
136
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(t)},n:function(){var c=r.next();return s=c.done,c},e:function(c){o=!0,a=c},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function cte(t,e){if(t){if(typeof t=="string")return
|
|
135
|
+
`),this.close()}_(e,r){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(CR.hide):this.out.write(nte(this.outputText,this.out.columns)),super.render(),this.outputText=[_R.symbol(this.done,this.aborted),vR.bold(this.msg),_R.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:vR.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(ite.line+CR.to(0)+this.outputText))}};OR.exports=Iw});var IR=_((mwe,TR)=>{"use strict";TR.exports={TextPrompt:mP(),SelectPrompt:wP(),TogglePrompt:SP(),DatePrompt:eR(),NumberPrompt:aR(),MultiselectPrompt:Cw(),AutocompletePrompt:yR(),AutocompleteMultiselectPrompt:bR(),ConfirmPrompt:xR()}});var PR=_(FR=>{"use strict";var vr=FR,ste=IR(),_d=t=>t;function In(t,e,r={}){return new Promise((n,i)=>{let s=new ste[t](e),o=r.onAbort||_d,a=r.onSubmit||_d,u=r.onExit||_d;s.on("state",e.onState||_d),s.on("submit",c=>n(a(c))),s.on("exit",c=>n(u(c))),s.on("abort",c=>i(o(c)))})}vr.text=t=>In("TextPrompt",t);vr.password=t=>(t.style="password",vr.text(t));vr.invisible=t=>(t.style="invisible",vr.text(t));vr.number=t=>In("NumberPrompt",t);vr.date=t=>In("DatePrompt",t);vr.confirm=t=>In("ConfirmPrompt",t);vr.list=t=>{let e=t.separator||",";return In("TextPrompt",t,{onSubmit:r=>r.split(e).map(n=>n.trim())})};vr.toggle=t=>In("TogglePrompt",t);vr.select=t=>In("SelectPrompt",t);vr.multiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return In("MultiselectPrompt",t,{onAbort:e,onSubmit:e})};vr.autocompleteMultiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return In("AutocompleteMultiselectPrompt",t,{onAbort:e,onSubmit:e})};var ote=(t,e)=>Promise.resolve(e.filter(r=>r.title.slice(0,t.length).toLowerCase()===t.toLowerCase()));vr.autocomplete=t=>(t.suggest=t.suggest||ote,t.choices=[].concat(t.choices||[]),In("AutocompletePrompt",t))});var MR=_((ywe,BR)=>{"use strict";function RR(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function kR(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?RR(Object(r),!0).forEach(function(n){ate(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):RR(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ate(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ute(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=cte(t))||e&&t&&typeof t.length=="number"){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
136
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(t)},n:function(){var c=r.next();return s=c.done,c},e:function(c){o=!0,a=c},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function cte(t,e){if(t){if(typeof t=="string")return NR(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return NR(t,e)}}function NR(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function $R(t,e,r,n,i,s,o){try{var a=t[s](o),u=a.value}catch(c){r(c);return}a.done?e(u):Promise.resolve(u).then(n,i)}function LR(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(u){$R(s,n,i,o,a,"next",u)}function a(u){$R(s,n,i,o,a,"throw",u)}o(void 0)})}}var Fw=PR(),lte=["suggest","format","onState","validate","onRender","type"],jR=()=>{};function Vi(){return Pw.apply(this,arguments)}function Pw(){return Pw=LR(function*(t=[],{onSubmit:e=jR,onCancel:r=jR}={}){let n={},i=Vi._override||{};t=[].concat(t);let s,o,a,u,c,l,h=(function(){var E=LR(function*(S,A,p=!1){if(!(!p&&S.validate&&S.validate(A)!==!0))return S.format?yield S.format(A,n):A});return function(A,p){return E.apply(this,arguments)}})();var d=ute(t),f;try{for(d.s();!(f=d.n()).done;){o=f.value;var m=o;if(u=m.name,c=m.type,typeof c=="function"&&(c=yield c(s,kR({},n),o),o.type=c),!!c){for(let E in o){if(lte.includes(E))continue;let S=o[E];o[E]=typeof S=="function"?yield S(s,kR({},n),l):S}if(l=o,typeof o.message!="string")throw new Error("prompt message is required");var y=o;if(u=y.name,c=y.type,Fw[c]===void 0)throw new Error(`prompt type (${c}) is not defined`);if(i[o.name]!==void 0&&(s=yield h(o,i[o.name]),s!==void 0)){n[u]=s;continue}try{s=Vi._injected?fte(Vi._injected,o.initial):yield Fw[c](o),n[u]=s=yield h(o,s,!0),a=yield e(o,s,n)}catch{a=!(yield r(o,n))}if(a)return n}}}catch(E){d.e(E)}finally{d.f()}return n}),Pw.apply(this,arguments)}function fte(t,e){let r=t.shift();if(r instanceof Error)throw r;return r===void 0?e:r}function hte(t){Vi._injected=(Vi._injected||[]).concat(t)}function dte(t){Vi._override=Object.assign({},t)}BR.exports=Object.assign(Vi,{prompt:Vi,prompts:Fw,inject:hte,override:dte})});var UR=_((Dwe,qR)=>{"use strict";qR.exports=(t,e)=>{if(!(t.meta&&t.name!=="escape")){if(t.ctrl){if(t.name==="a")return"first";if(t.name==="c"||t.name==="d")return"abort";if(t.name==="e")return"last";if(t.name==="g")return"reset"}if(e){if(t.name==="j")return"down";if(t.name==="k")return"up"}return t.name==="return"||t.name==="enter"?"submit":t.name==="backspace"?"delete":t.name==="delete"?"deleteForward":t.name==="abort"?"abort":t.name==="escape"?"exit":t.name==="tab"?"next":t.name==="pagedown"?"nextPage":t.name==="pageup"?"prevPage":t.name==="home"?"home":t.name==="end"?"end":t.name==="up"?"up":t.name==="down"?"down":t.name==="right"?"right":t.name==="left"?"left":!1}}});var Cd=_((wwe,HR)=>{"use strict";HR.exports=t=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),r=new RegExp(e,"g");return typeof t=="string"?t.replace(r,""):t}});var KR=_((Ewe,zR)=>{"use strict";var pte=Cd(),{erase:VR,cursor:mte}=Je(),gte=t=>[...pte(t)].length;zR.exports=function(t,e){if(!e)return VR.line+mte.to(0);let r=0,n=t.split(/\r?\n/);for(let i of n)r+=1+Math.floor(Math.max(gte(i)-1,0)/e);return VR.lines(r)}});var Rw=_((bwe,GR)=>{"use strict";var Oc={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},yte={arrowUp:Oc.arrowUp,arrowDown:Oc.arrowDown,arrowLeft:Oc.arrowLeft,arrowRight:Oc.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},Dte=process.platform==="win32"?yte:Oc;GR.exports=Dte});var XR=_((vwe,WR)=>{"use strict";var Fa=dt(),Xs=Rw(),kw=Object.freeze({password:{scale:1,render:t=>"*".repeat(t.length)},emoji:{scale:2,render:t=>"\u{1F603}".repeat(t.length)},invisible:{scale:0,render:t=>""},default:{scale:1,render:t=>`${t}`}}),wte=t=>kw[t]||kw.default,xc=Object.freeze({aborted:Fa.red(Xs.cross),done:Fa.green(Xs.tick),exited:Fa.yellow(Xs.cross),default:Fa.cyan("?")}),Ete=(t,e,r)=>e?xc.aborted:r?xc.exited:t?xc.done:xc.default,bte=t=>Fa.gray(t?Xs.ellipsis:Xs.pointerSmall),vte=(t,e)=>Fa.gray(t?e?Xs.pointerSmall:"+":Xs.line);WR.exports={styles:kw,render:wte,symbols:xc,symbol:Ete,delimiter:bte,item:vte}});var JR=_((_we,YR)=>{"use strict";var _te=Cd();YR.exports=function(t,e){let r=String(_te(t)||"").split(/\r?\n/);return e?r.map(n=>Math.ceil(n.length/e)).reduce((n,i)=>n+i):r.length}});var QR=_((Cwe,ZR)=>{"use strict";ZR.exports=(t,e={})=>{let r=Number.isSafeInteger(parseInt(e.margin))?new Array(parseInt(e.margin)).fill(" ").join(""):e.margin||"",n=e.width;return(t||"").split(/\r?\n/g).map(i=>i.split(/\s+/g).reduce((s,o)=>(o.length+r.length>=n||s[s.length-1].length+o.length+1<n?s[s.length-1]+=` ${o}`:s.push(`${r}${o}`),s),[r]).join(`
|
|
137
137
|
`)).join(`
|
|
138
|
-
`)}});var
|
|
138
|
+
`)}});var t2=_((Swe,e2)=>{"use strict";e2.exports=(t,e,r)=>{r=r||e;let n=Math.min(e-r,t-Math.floor(r/2));n<0&&(n=0);let i=Math.min(n+r,e);return{startIndex:n,endIndex:i}}});var ln=_((Awe,r2)=>{"use strict";r2.exports={action:UR(),clear:KR(),style:XR(),strip:Cd(),figures:Rw(),lines:JR(),wrap:QR(),entriesToDisplay:t2()}});var ai=_((Owe,i2)=>{"use strict";var n2=require("readline"),{action:Cte}=ln(),Ste=require("events"),{beep:Ate,cursor:Ote}=Je(),xte=dt(),Nw=class extends Ste{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>{})).bind(this);let r=n2.createInterface({input:this.in,escapeCodeTimeout:50});n2.emitKeypressEvents(this.in,r),this.in.isTTY&&this.in.setRawMode(!0);let n=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,i=(s,o)=>{let a=Cte(o,n);a===!1?this._&&this._(s,o):typeof this[a]=="function"?this[a](o):this.bell()};this.close=()=>{this.out.write(Ote.show),this.in.removeListener("keypress",i),this.in.isTTY&&this.in.setRawMode(!1),r.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",i)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(Ate)}render(){this.onRender(xte),this.firstRender&&(this.firstRender=!1)}};i2.exports=Nw});var o2=_((xwe,s2)=>{var Sd=dt(),Tte=ai(),{erase:Ite,cursor:Tc}=Je(),{style:$w,clear:Lw,lines:Fte,figures:Pte}=ln(),jw=class extends Tte{constructor(e={}){super(e),this.transform=$w.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.validator=e.validate||(()=>!0),this.value="",this.errorMsg=e.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=Lw("",this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=Sd.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
139
139
|
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
140
140
|
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e,this.cursorOffset+=e)}_(e,r){let n=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.value=`${n}${e}${i}`,this.red=!1,this.cursor=this.placeholder?0:n.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),r=this.value.slice(this.cursor);this.value=`${e}${r}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let e=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor+1);this.value=`${e}${r}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(Tc.down(Fte(this.outputError,this.out.columns)-1)+Lw(this.outputError,this.out.columns)),this.out.write(Lw(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[$w.symbol(this.done,this.aborted),Sd.bold(this.msg),$w.delimiter(this.done),this.red?Sd.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
141
141
|
`).reduce((e,r,n)=>e+`
|
|
142
|
-
${n?" ":Pte.pointerSmall} ${Sd.red().italic(r)}`,"")),this.out.write(Ite.line+Tc.to(0)+this.outputText+Tc.save+this.outputError+Tc.restore+Tc.move(this.cursorOffset,0)))}};
|
|
142
|
+
${n?" ":Pte.pointerSmall} ${Sd.red().italic(r)}`,"")),this.out.write(Ite.line+Tc.to(0)+this.outputText+Tc.save+this.outputError+Tc.restore+Tc.move(this.cursorOffset,0)))}};s2.exports=jw});var l2=_((Twe,c2)=>{"use strict";var ui=dt(),Rte=ai(),{style:a2,clear:u2,figures:Ad,wrap:kte,entriesToDisplay:Nte}=ln(),{cursor:$te}=Je(),Bw=class extends Rte{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.warn=e.warn||"- This option is disabled",this.cursor=e.initial||0,this.choices=e.choices.map((r,n)=>(typeof r=="string"&&(r={title:r,value:n}),{title:r&&(r.title||r.value||r),value:r&&(r.value===void 0?n:r.value),description:r&&r.description,selected:r&&r.selected,disabled:r&&r.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=u2("",this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
143
143
|
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
144
|
-
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(e,r){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write($te.hide):this.out.write(
|
|
144
|
+
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(e,r){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write($te.hide):this.out.write(u2(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:r}=Nte(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[a2.symbol(this.done,this.aborted),ui.bold(this.msg),a2.delimiter(!1),this.done?this.selection.title:this.selection.disabled?ui.yellow(this.warn):ui.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
145
145
|
`;for(let n=e;n<r;n++){let i,s,o="",a=this.choices[n];n===e&&e>0?s=Ad.arrowUp:n===r-1&&r<this.choices.length?s=Ad.arrowDown:s=" ",a.disabled?(i=this.cursor===n?ui.gray().underline(a.title):ui.strikethrough().gray(a.title),s=(this.cursor===n?ui.bold().gray(Ad.pointer)+" ":" ")+s):(i=this.cursor===n?ui.cyan().underline(a.title):a.title,s=(this.cursor===n?ui.cyan(Ad.pointer)+" ":" ")+s,a.description&&this.cursor===n&&(o=` - ${a.description}`,(s.length+i.length+o.length>=this.out.columns||a.description.split(/\r?\n/).length>1)&&(o=`
|
|
146
146
|
`+kte(a.description,{margin:3,width:this.out.columns})))),this.outputText+=`${s} ${i}${ui.gray(o)}
|
|
147
|
-
`}}this.out.write(this.outputText)}};
|
|
147
|
+
`}}this.out.write(this.outputText)}};c2.exports=Bw});var p2=_((Iwe,d2)=>{var Od=dt(),Lte=ai(),{style:f2,clear:jte}=ln(),{cursor:h2,erase:Bte}=Je(),Mw=class extends Lte{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
148
148
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
149
|
-
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,r){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(
|
|
149
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,r){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(h2.hide):this.out.write(jte(this.outputText,this.out.columns)),super.render(),this.outputText=[f2.symbol(this.done,this.aborted),Od.bold(this.msg),f2.delimiter(this.done),this.value?this.inactive:Od.cyan().underline(this.inactive),Od.gray("/"),this.value?Od.cyan().underline(this.active):this.active].join(" "),this.out.write(Bte.line+h2.to(0)+this.outputText))}};d2.exports=Mw});var Fn=_((Fwe,m2)=>{"use strict";var qw=class t{constructor({token:e,date:r,parts:n,locales:i}){this.token=e,this.date=r||new Date,this.parts=n||[this],this.locales=i||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((r,n)=>n>e&&r instanceof t)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),r=e.indexOf(this);return e.find((n,i)=>i>r&&n instanceof t)}toString(){return String(this.date)}};m2.exports=qw});var y2=_((Pwe,g2)=>{"use strict";var Mte=Fn(),Uw=class extends Mte{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};g2.exports=Uw});var w2=_((Rwe,D2)=>{"use strict";var qte=Fn(),Ute=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th"),Hw=class extends qte{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),r=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+Ute(e):this.token==="d"?r+1:this.token==="ddd"?this.locales.weekdaysShort[r]:this.token==="dddd"?this.locales.weekdays[r]:e}};D2.exports=Hw});var b2=_((kwe,E2)=>{"use strict";var Hte=Fn(),Vw=class extends Hte{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};E2.exports=Vw});var _2=_((Nwe,v2)=>{"use strict";var Vte=Fn(),zw=class extends Vte{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};v2.exports=zw});var S2=_(($we,C2)=>{"use strict";var zte=Fn(),Kw=class extends zte{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};C2.exports=Kw});var O2=_((Lwe,A2)=>{"use strict";var Kte=Fn(),Gw=class extends Kte{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),r=this.token.length;return r===2?String(e+1).padStart(2,"0"):r===3?this.locales.monthsShort[e]:r===4?this.locales.months[e]:String(e+1)}};A2.exports=Gw});var T2=_((jwe,x2)=>{"use strict";var Gte=Fn(),Ww=class extends Gte{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};x2.exports=Ww});var F2=_((Bwe,I2)=>{"use strict";var Wte=Fn(),Xw=class extends Wte{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};I2.exports=Xw});var R2=_((Mwe,P2)=>{"use strict";P2.exports={DatePart:Fn(),Meridiem:y2(),Day:w2(),Hours:b2(),Milliseconds:_2(),Minutes:S2(),Month:O2(),Seconds:T2(),Year:F2()}});var M2=_((qwe,B2)=>{"use strict";var Yw=dt(),Xte=ai(),{style:k2,clear:N2,figures:Yte}=ln(),{erase:Jte,cursor:$2}=Je(),{DatePart:L2,Meridiem:Zte,Day:Qte,Hours:ere,Milliseconds:tre,Minutes:rre,Month:nre,Seconds:ire,Year:sre}=R2(),ore=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,j2={1:({token:t})=>t.replace(/\\(.)/g,"$1"),2:t=>new Qte(t),3:t=>new nre(t),4:t=>new sre(t),5:t=>new Zte(t),6:t=>new ere(t),7:t=>new rre(t),8:t=>new ire(t),9:t=>new tre(t)},are={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},Jw=class extends Xte{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(are,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=N2("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let r;for(this.parts=[];r=ore.exec(e);){let i=r.shift(),s=r.findIndex(o=>o!=null);this.parts.push(s in j2?j2[s]({token:r[s]||i,date:this.date,parts:this.parts,locales:this.locales}):r[s]||i)}let n=this.parts.reduce((i,s)=>(typeof s=="string"&&typeof i[i.length-1]=="string"?i[i.length-1]+=s:i.push(s),i),[]);this.parts.splice(0),this.parts.push(...n),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof L2)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
150
150
|
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
151
|
-
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(r=>r instanceof
|
|
151
|
+
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(r=>r instanceof L2)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write($2.hide):this.out.write(N2(this.outputText,this.out.columns)),super.render(),this.outputText=[k2.symbol(this.done,this.aborted),Yw.bold(this.msg),k2.delimiter(!1),this.parts.reduce((e,r,n)=>e.concat(n===this.cursor&&!this.done?Yw.cyan().underline(r.toString()):r),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
152
152
|
`).reduce((e,r,n)=>e+`
|
|
153
|
-
${n?" ":Yte.pointerSmall} ${Yw.red().italic(r)}`,"")),this.out.write(Jte.line+$
|
|
153
|
+
${n?" ":Yte.pointerSmall} ${Yw.red().italic(r)}`,"")),this.out.write(Jte.line+$2.to(0)+this.outputText))}};B2.exports=Jw});var V2=_((Uwe,H2)=>{var xd=dt(),ure=ai(),{cursor:Td,erase:cre}=Je(),{style:Zw,figures:lre,clear:q2,lines:fre}=ln(),hre=/[0-9]/,Qw=t=>t!==void 0,U2=(t,e)=>{let r=Math.pow(10,e);return Math.round(t*r)/r},eE=class extends ure{constructor(e={}){super(e),this.transform=Zw.render(e.style),this.msg=e.message,this.initial=Qw(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=Qw(e.min)?e.min:-1/0,this.max=Qw(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=xd.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${U2(e,this.round)}`),this._value=U2(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||hre.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
154
154
|
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let e=this.value;this.value=e!==""?e:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
155
|
-
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,r){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=n,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(Td.down(fre(this.outputError,this.out.columns)-1)+
|
|
155
|
+
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,r){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=n,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(Td.down(fre(this.outputError,this.out.columns)-1)+q2(this.outputError,this.out.columns)),this.out.write(q2(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Zw.symbol(this.done,this.aborted),xd.bold(this.msg),Zw.delimiter(this.done),!this.done||!this.done&&!this.placeholder?xd[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
156
156
|
`).reduce((e,r,n)=>e+`
|
|
157
|
-
${n?" ":lre.pointerSmall} ${xd.red().italic(r)}`,"")),this.out.write(cre.line+Td.to(0)+this.outputText+Td.save+this.outputError+Td.restore))}};
|
|
157
|
+
${n?" ":lre.pointerSmall} ${xd.red().italic(r)}`,"")),this.out.write(cre.line+Td.to(0)+this.outputText+Td.save+this.outputError+Td.restore))}};H2.exports=eE});var rE=_((Hwe,G2)=>{"use strict";var Pn=dt(),{cursor:dre}=Je(),pre=ai(),{clear:z2,figures:zi,style:K2,wrap:mre,entriesToDisplay:gre}=ln(),tE=class extends pre{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((r,n)=>(typeof r=="string"&&(r={title:r,value:n}),{title:r&&(r.title||r.value||r),description:r&&r.description,value:r&&(r.value===void 0?n:r.value),selected:r&&r.selected,disabled:r&&r.disabled})),this.clear=z2("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
158
158
|
`),this.close()}submit(){let e=this.value.filter(r=>r.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
159
159
|
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(r=>!r.disabled).forEach(r=>r.selected=e),this.render()}_(e,r){if(e===" ")this.handleSpaceToggle();else if(e==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
160
160
|
Instructions:
|
|
@@ -164,13 +164,13 @@ Instructions:
|
|
|
164
164
|
`:"")+" enter/return: Complete answer":""}renderOption(e,r,n,i){let s=(r.selected?Pn.green(zi.radioOn):zi.radioOff)+" "+i+" ",o,a;return r.disabled?o=e===n?Pn.gray().underline(r.title):Pn.strikethrough().gray(r.title):(o=e===n?Pn.cyan().underline(r.title):r.title,e===n&&r.description&&(a=` - ${r.description}`,(s.length+o.length+a.length>=this.out.columns||r.description.split(/\r?\n/).length>1)&&(a=`
|
|
165
165
|
`+mre(r.description,{margin:s.length,width:this.out.columns})))),s+o+Pn.gray(a||"")}paginateOptions(e){if(e.length===0)return Pn.red("No matches for this query.");let{startIndex:r,endIndex:n}=gre(this.cursor,e.length,this.optionsPerPage),i,s=[];for(let o=r;o<n;o++)o===r&&r>0?i=zi.arrowUp:o===n-1&&n<e.length?i=zi.arrowDown:i=" ",s.push(this.renderOption(this.cursor,e[o],o,i));return`
|
|
166
166
|
`+s.join(`
|
|
167
|
-
`)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[Pn.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(Pn.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(dre.hide),super.render();let e=[
|
|
167
|
+
`)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[Pn.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(Pn.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(dre.hide),super.render();let e=[K2.symbol(this.done,this.aborted),Pn.bold(this.msg),K2.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=Pn.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=z2(e,this.out.columns)}};G2.exports=tE});var Z2=_((Vwe,J2)=>{"use strict";var Ic=dt(),yre=ai(),{erase:Dre,cursor:W2}=Je(),{style:nE,clear:X2,figures:iE,wrap:wre,entriesToDisplay:Ere}=ln(),Y2=(t,e)=>t[e]&&(t[e].value||t[e].title||t[e]),bre=(t,e)=>t[e]&&(t[e].title||t[e].value||t[e]),vre=(t,e)=>{let r=t.findIndex(n=>n.value===e||n.title===e);return r>-1?r:void 0},sE=class extends yre{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:vre(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=nE.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=X2("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=Y2(this.suggestions,e):this.value=this.fallback.value,this.fire()}async complete(e){let r=this.completing=this.suggest(this.input,this.choices),n=await r;if(this.completing!==r)return;this.suggestions=n.map((s,o,a)=>({title:bre(a,o),value:Y2(a,o),description:s.description})),this.completing=!1;let i=Math.max(n.length-1,0);this.moveSelect(Math.min(i,this.select)),e&&e()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
168
168
|
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
169
169
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
170
170
|
`),this.close()}_(e,r){let n=this.input.slice(0,this.cursor),i=this.input.slice(this.cursor);this.input=`${n}${e}${i}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),r=this.input.slice(this.cursor);this.input=`${e}${r}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor+1);this.input=`${e}${r}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,r,n,i){let s,o=n?iE.arrowUp:i?iE.arrowDown:" ",a=r?Ic.cyan().underline(e.title):e.title;return o=(r?Ic.cyan(iE.pointer)+" ":" ")+o,e.description&&(s=` - ${e.description}`,(o.length+a.length+s.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(s=`
|
|
171
|
-
`+wre(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Ic.gray(s||"")}render(){if(this.closed)return;this.firstRender?this.out.write(
|
|
171
|
+
`+wre(e.description,{margin:3,width:this.out.columns}))),o+" "+a+Ic.gray(s||"")}render(){if(this.closed)return;this.firstRender?this.out.write(W2.hide):this.out.write(X2(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:r}=Ere(this.select,this.choices.length,this.limit);if(this.outputText=[nE.symbol(this.done,this.aborted,this.exited),Ic.bold(this.msg),nE.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let n=this.suggestions.slice(e,r).map((i,s)=>this.renderOption(i,this.select===s+e,s===0&&e>0,s+e===r-1&&r<this.choices.length)).join(`
|
|
172
172
|
`);this.outputText+=`
|
|
173
|
-
`+(n||Ic.gray(this.fallback.title))}this.out.write(Dre.line+
|
|
173
|
+
`+(n||Ic.gray(this.fallback.title))}this.out.write(Dre.line+W2.to(0)+this.outputText)}};J2.exports=sE});var rk=_((zwe,tk)=>{"use strict";var ci=dt(),{cursor:_re}=Je(),Cre=rE(),{clear:Q2,style:ek,figures:Pa}=ln(),oE=class extends Cre{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=Q2("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(n=>this.inputValue?!!(typeof n.title=="string"&&n.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof n.value=="string"&&n.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let r=this.filteredOptions.findIndex(n=>n===e);this.cursor=r<0?0:r,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,r){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
174
174
|
Instructions:
|
|
175
175
|
${Pa.arrowUp}/${Pa.arrowDown}: Highlight option
|
|
176
176
|
${Pa.arrowLeft}/${Pa.arrowRight}/[space]: Toggle selection
|
|
@@ -178,9 +178,9 @@ Instructions:
|
|
|
178
178
|
enter/return: Complete answer
|
|
179
179
|
`:""}renderCurrentInput(){return`
|
|
180
180
|
Filtered results for: ${this.inputValue?this.inputValue:ci.gray("Enter something to filter")}
|
|
181
|
-
`}renderOption(e,r,n){let i;return r.disabled?i=e===n?ci.gray().underline(r.title):ci.strikethrough().gray(r.title):i=e===n?ci.cyan().underline(r.title):r.title,(r.selected?ci.green(Pa.radioOn):Pa.radioOff)+" "+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[ci.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(ci.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(_re.hide),super.render();let e=[ek.symbol(this.done,this.aborted),ci.bold(this.msg),ek.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=ci.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=
|
|
181
|
+
`}renderOption(e,r,n){let i;return r.disabled?i=e===n?ci.gray().underline(r.title):ci.strikethrough().gray(r.title):i=e===n?ci.cyan().underline(r.title):r.title,(r.selected?ci.green(Pa.radioOn):Pa.radioOff)+" "+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[ci.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(ci.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(_re.hide),super.render();let e=[ek.symbol(this.done,this.aborted),ci.bold(this.msg),ek.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=ci.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=Q2(e,this.out.columns)}};tk.exports=oE});var ak=_((Kwe,ok)=>{var nk=dt(),Sre=ai(),{style:ik,clear:Are}=ln(),{erase:Ore,cursor:sk}=Je(),aE=class extends Sre{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
182
182
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
183
|
-
`),this.close()}_(e,r){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(sk.hide):this.out.write(Are(this.outputText,this.out.columns)),super.render(),this.outputText=[ik.symbol(this.done,this.aborted),nk.bold(this.msg),ik.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:nk.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Ore.line+sk.to(0)+this.outputText))}};ok.exports=aE});var ck=_((Gwe,uk)=>{"use strict";uk.exports={TextPrompt:
|
|
183
|
+
`),this.close()}_(e,r){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(sk.hide):this.out.write(Are(this.outputText,this.out.columns)),super.render(),this.outputText=[ik.symbol(this.done,this.aborted),nk.bold(this.msg),ik.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:nk.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Ore.line+sk.to(0)+this.outputText))}};ok.exports=aE});var ck=_((Gwe,uk)=>{"use strict";uk.exports={TextPrompt:o2(),SelectPrompt:l2(),TogglePrompt:p2(),DatePrompt:M2(),NumberPrompt:V2(),MultiselectPrompt:rE(),AutocompletePrompt:Z2(),AutocompleteMultiselectPrompt:rk(),ConfirmPrompt:ak()}});var fk=_(lk=>{"use strict";var _r=lk,xre=ck(),Id=t=>t;function Rn(t,e,r={}){return new Promise((n,i)=>{let s=new xre[t](e),o=r.onAbort||Id,a=r.onSubmit||Id,u=r.onExit||Id;s.on("state",e.onState||Id),s.on("submit",c=>n(a(c))),s.on("exit",c=>n(u(c))),s.on("abort",c=>i(o(c)))})}_r.text=t=>Rn("TextPrompt",t);_r.password=t=>(t.style="password",_r.text(t));_r.invisible=t=>(t.style="invisible",_r.text(t));_r.number=t=>Rn("NumberPrompt",t);_r.date=t=>Rn("DatePrompt",t);_r.confirm=t=>Rn("ConfirmPrompt",t);_r.list=t=>{let e=t.separator||",";return Rn("TextPrompt",t,{onSubmit:r=>r.split(e).map(n=>n.trim())})};_r.toggle=t=>Rn("TogglePrompt",t);_r.select=t=>Rn("SelectPrompt",t);_r.multiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return Rn("MultiselectPrompt",t,{onAbort:e,onSubmit:e})};_r.autocompleteMultiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return Rn("AutocompleteMultiselectPrompt",t,{onAbort:e,onSubmit:e})};var Tre=(t,e)=>Promise.resolve(e.filter(r=>r.title.slice(0,t.length).toLowerCase()===t.toLowerCase()));_r.autocomplete=t=>(t.suggest=t.suggest||Tre,t.choices=[].concat(t.choices||[]),Rn("AutocompletePrompt",t))});var pk=_((Xwe,dk)=>{"use strict";var uE=fk(),Ire=["suggest","format","onState","validate","onRender","type"],hk=()=>{};async function Ki(t=[],{onSubmit:e=hk,onCancel:r=hk}={}){let n={},i=Ki._override||{};t=[].concat(t);let s,o,a,u,c,l,h=async(d,f,m=!1)=>{if(!(!m&&d.validate&&d.validate(f)!==!0))return d.format?await d.format(f,n):f};for(o of t)if({name:u,type:c}=o,typeof c=="function"&&(c=await c(s,{...n},o),o.type=c),!!c){for(let d in o){if(Ire.includes(d))continue;let f=o[d];o[d]=typeof f=="function"?await f(s,{...n},l):f}if(l=o,typeof o.message!="string")throw new Error("prompt message is required");if({name:u,type:c}=o,uE[c]===void 0)throw new Error(`prompt type (${c}) is not defined`);if(i[o.name]!==void 0&&(s=await h(o,i[o.name]),s!==void 0)){n[u]=s;continue}try{s=Ki._injected?Fre(Ki._injected,o.initial):await uE[c](o),n[u]=s=await h(o,s,!0),a=await e(o,s,n)}catch{a=!await r(o,n)}if(a)return n}return n}function Fre(t,e){let r=t.shift();if(r instanceof Error)throw r;return r===void 0?e:r}function Pre(t){Ki._injected=(Ki._injected||[]).concat(t)}function Rre(t){Ki._override=Object.assign({},t)}dk.exports=Object.assign(Ki,{prompt:Ki,prompts:uE,inject:Pre,override:Rre})});var Fd=_((Ywe,mk)=>{function kre(t){t=(Array.isArray(t)?t:t.split(".")).map(Number);let e=0,r=process.versions.node.split(".").map(Number);for(;e<t.length;e++){if(r[e]>t[e])return!1;if(t[e]>r[e])return!0}return!1}mk.exports=kre("8.6.0")?MR():pk()});var wc=_(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Cr.logSuccess=Cr.logPrompt=Cr.logger=Cr.output=void 0;var cE=(fe(),ue(le)),Ys=Q0(),Js=cE.__importDefault(va()),Nre=qF(),gk={colors:Js.default,stream:process.argv.includes("--json")?process.stderr:process.stdout};Cr.output=(0,Nre.isInteractive)()?new Ys.TTYOutputStrategy(gk):new Ys.StreamOutputStrategy(gk);Cr.logger=(0,Ys.createDefaultLogger)({output:Cr.output,formatterOptions:{titleize:!1,tags:new Map([[Ys.LOGGER_LEVELS.DEBUG,Js.default.log.DEBUG("[debug]")],[Ys.LOGGER_LEVELS.INFO,Js.default.log.INFO("[info]")],[Ys.LOGGER_LEVELS.WARN,Js.default.log.WARN("[warn]")],[Ys.LOGGER_LEVELS.ERROR,Js.default.log.ERROR("[error]")]])}});async function $re(t,e){let{wordWrap:r}=await Promise.resolve().then(()=>cE.__importStar(Q0())),{prompt:n}=await Promise.resolve().then(()=>cE.__importStar(Fd()));return Cr.logger.log({msg:`${Js.default.input("[?]")} ${r(t,{indentation:4})}`,logger:Cr.logger,format:!1}),n(e,{onCancel:()=>process.exit(1)})}Cr.logPrompt=$re;function Lre(t){Cr.logger.msg(`${Js.default.success("[success]")} ${t}`)}Cr.logSuccess=Lre});var Pd=_(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.resolveNode=Ra.requireTS=void 0;var jre=require("fs"),Bre=ba(),Mre=require("path"),qre=(t,e)=>{let r=(0,Mre.resolve)(e);delete require.cache[r],require.extensions[".ts"]=(i,s)=>{var o;let a=(0,Bre.readFileSync)(s,"utf8");s.endsWith(".ts")?a=t.transpileModule(a,{fileName:s,compilerOptions:{module:t.ModuleKind.CommonJS,moduleResolution:t.ModuleResolutionKind.NodeJs,esModuleInterop:!0,strict:!0,target:t.ScriptTarget.ES2017},reportDiagnostics:!0}).outputText:a=a.replace(/export\s+\w+\s+(\w+)/gm,"exports.$1"),(o=i._compile)===null||o===void 0||o.call(i,a,s)};let n=require(r);return delete require.extensions[".ts"],n};Ra.requireTS=qre;function Ure(t,...e){try{return require.resolve(e.join("/"),{paths:[t]})}catch{let n=[t,"node_modules",...e].join("/");return(0,jre.existsSync)(n)?n:null}}Ra.resolveNode=Ure});var Rd=_(lE=>{(function(){lE.defaults={"0.1":{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},"0.2":{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:`
|
|
184
184
|
`},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}).call(lE)});var kn=_((yk,Gi)=>{(function(){var t,e,r,n,i,s,o,a=[].slice,u={}.hasOwnProperty;t=function(){var c,l,h,d,f,m;if(m=arguments[0],f=2<=arguments.length?a.call(arguments,1):[],i(Object.assign))Object.assign.apply(null,arguments);else for(c=0,h=f.length;c<h;c++)if(d=f[c],d!=null)for(l in d)u.call(d,l)&&(m[l]=d[l]);return m},i=function(c){return!!c&&Object.prototype.toString.call(c)==="[object Function]"},s=function(c){var l;return!!c&&((l=typeof c)=="function"||l==="object")},r=function(c){return i(Array.isArray)?Array.isArray(c):Object.prototype.toString.call(c)==="[object Array]"},n=function(c){var l;if(r(c))return!c.length;for(l in c)if(u.call(c,l))return!1;return!0},o=function(c){var l,h;return s(c)&&(h=Object.getPrototypeOf(c))&&(l=h.constructor)&&typeof l=="function"&&l instanceof l&&Function.prototype.toString.call(l)===Function.prototype.toString.call(Object)},e=function(c){return i(c.valueOf)?c.valueOf():c},Gi.exports.assign=t,Gi.exports.isFunction=i,Gi.exports.isObject=s,Gi.exports.isArray=r,Gi.exports.isEmpty=n,Gi.exports.isPlainObject=o,Gi.exports.getValue=e}).call(yk)});var fE=_((Dk,wk)=>{(function(){var t;wk.exports=t=(function(){function e(){}return e.prototype.hasFeature=function(r,n){return!0},e.prototype.createDocumentType=function(r,n,i){throw new Error("This DOM method is not implemented.")},e.prototype.createDocument=function(r,n,i){throw new Error("This DOM method is not implemented.")},e.prototype.createHTMLDocument=function(r){throw new Error("This DOM method is not implemented.")},e.prototype.getFeature=function(r,n){throw new Error("This DOM method is not implemented.")},e})()}).call(Dk)});var vk=_((Ek,bk)=>{(function(){var t;bk.exports=t=(function(){function e(){}return e.prototype.handleError=function(r){throw new Error(r)},e})()}).call(Ek)});var Sk=_((_k,Ck)=>{(function(){var t;Ck.exports=t=(function(){function e(r){this.arr=r||[]}return Object.defineProperty(e.prototype,"length",{get:function(){return this.arr.length}}),e.prototype.item=function(r){return this.arr[r]||null},e.prototype.contains=function(r){return this.arr.indexOf(r)!==-1},e})()}).call(_k)});var xk=_((Ak,Ok)=>{(function(){var t,e,r;e=vk(),r=Sk(),Ok.exports=t=(function(){function n(){var i;this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new e,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=i=Object.create(this.defaultParams)}return Object.defineProperty(n.prototype,"parameterNames",{get:function(){return new r(Object.keys(this.defaultParams))}}),n.prototype.getParameter=function(i){return this.params.hasOwnProperty(i)?this.params[i]:null},n.prototype.canSetParameter=function(i,s){return!0},n.prototype.setParameter=function(i,s){return s!=null?this.params[i]=s:delete this.params[i]},n})()}).call(Ak)});var _t=_((Tk,Ik)=>{(function(){Ik.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}).call(Tk)});var hE=_((Fk,Pk)=>{(function(){var t,e,r;t=_t(),r=Pr(),Pk.exports=e=(function(){function n(i,s,o){if(this.parent=i,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),s==null)throw new Error("Missing attribute name. "+this.debugInfo(s));this.name=this.stringify.name(s),this.value=this.stringify.attValue(o),this.type=t.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(n.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(n.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(n.prototype,"textContent",{get:function(){return this.value},set:function(i){return this.value=i||""}}),Object.defineProperty(n.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(n.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(n.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(n.prototype,"specified",{get:function(){return!0}}),n.prototype.clone=function(){return Object.create(this)},n.prototype.toString=function(i){return this.options.writer.attribute(this,this.options.writer.filterOptions(i))},n.prototype.debugInfo=function(i){return i=i||this.name,i==null?"parent: <"+this.parent.name+">":"attribute: {"+i+"}, parent: <"+this.parent.name+">"},n.prototype.isEqualNode=function(i){return!(i.namespaceURI!==this.namespaceURI||i.prefix!==this.prefix||i.localName!==this.localName||i.value!==this.value)},n})()}).call(Fk)});var kd=_((Rk,kk)=>{(function(){var t;kk.exports=t=(function(){function e(r){this.nodes=r}return Object.defineProperty(e.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),e.prototype.clone=function(){return this.nodes=null},e.prototype.getNamedItem=function(r){return this.nodes[r]},e.prototype.setNamedItem=function(r){var n;return n=this.nodes[r.nodeName],this.nodes[r.nodeName]=r,n||null},e.prototype.removeNamedItem=function(r){var n;return n=this.nodes[r],delete this.nodes[r],n||null},e.prototype.item=function(r){return this.nodes[Object.keys(this.nodes)[r]]||null},e.prototype.getNamedItemNS=function(r,n){throw new Error("This DOM method is not implemented.")},e.prototype.setNamedItemNS=function(r){throw new Error("This DOM method is not implemented.")},e.prototype.removeNamedItemNS=function(r,n){throw new Error("This DOM method is not implemented.")},e})()}).call(Rk)});var Nd=_((Nk,$k)=>{(function(){var t,e,r,n,i,s,o,a,u,c=function(h,d){for(var f in d)l.call(d,f)&&(h[f]=d[f]);function m(){this.constructor=h}return m.prototype=d.prototype,h.prototype=new m,h.__super__=d.prototype,h},l={}.hasOwnProperty;u=kn(),a=u.isObject,o=u.isFunction,s=u.getValue,i=Pr(),t=_t(),e=hE(),n=kd(),$k.exports=r=(function(h){c(d,h);function d(f,m,y){var E,S,A,p;if(d.__super__.constructor.call(this,f),m==null)throw new Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(m),this.type=t.Element,this.attribs={},this.schemaTypeInfo=null,y!=null&&this.attribute(y),f.type===t.Document&&(this.isRoot=!0,this.documentObject=f,f.rootObject=this,f.children)){for(p=f.children,S=0,A=p.length;S<A;S++)if(E=p[S],E.type===t.DocType){E.name=this.name;break}}}return Object.defineProperty(d.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(d.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(d.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(d.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(d.prototype,"id",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(d.prototype,"className",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(d.prototype,"classList",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(d.prototype,"attributes",{get:function(){return(!this.attributeMap||!this.attributeMap.nodes)&&(this.attributeMap=new n(this.attribs)),this.attributeMap}}),d.prototype.clone=function(){var f,m,y,E;y=Object.create(this),y.isRoot&&(y.documentObject=null),y.attribs={},E=this.attribs;for(m in E)l.call(E,m)&&(f=E[m],y.attribs[m]=f.clone());return y.children=[],this.children.forEach(function(S){var A;return A=S.clone(),A.parent=y,y.children.push(A)}),y},d.prototype.attribute=function(f,m){var y,E;if(f!=null&&(f=s(f)),a(f))for(y in f)l.call(f,y)&&(E=f[y],this.attribute(y,E));else o(m)&&(m=m.apply()),this.options.keepNullAttributes&&m==null?this.attribs[f]=new e(this,f,""):m!=null&&(this.attribs[f]=new e(this,f,m));return this},d.prototype.removeAttribute=function(f){var m,y,E;if(f==null)throw new Error("Missing attribute name. "+this.debugInfo());if(f=s(f),Array.isArray(f))for(y=0,E=f.length;y<E;y++)m=f[y],delete this.attribs[m];else delete this.attribs[f];return this},d.prototype.toString=function(f){return this.options.writer.element(this,this.options.writer.filterOptions(f))},d.prototype.att=function(f,m){return this.attribute(f,m)},d.prototype.a=function(f,m){return this.attribute(f,m)},d.prototype.getAttribute=function(f){return this.attribs.hasOwnProperty(f)?this.attribs[f].value:null},d.prototype.setAttribute=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getAttributeNode=function(f){return this.attribs.hasOwnProperty(f)?this.attribs[f]:null},d.prototype.setAttributeNode=function(f){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.removeAttributeNode=function(f){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getElementsByTagName=function(f){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getAttributeNS=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.setAttributeNS=function(f,m,y){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.removeAttributeNS=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getAttributeNodeNS=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.setAttributeNodeNS=function(f){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getElementsByTagNameNS=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.hasAttribute=function(f){return this.attribs.hasOwnProperty(f)},d.prototype.hasAttributeNS=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.setIdAttribute=function(f,m){return this.attribs.hasOwnProperty(f)?this.attribs[f].isId:m},d.prototype.setIdAttributeNS=function(f,m,y){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.setIdAttributeNode=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getElementsByTagName=function(f){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getElementsByTagNameNS=function(f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.getElementsByClassName=function(f){throw new Error("This DOM method is not implemented."+this.debugInfo())},d.prototype.isEqualNode=function(f){var m,y,E;if(!d.__super__.isEqualNode.apply(this,arguments).isEqualNode(f)||f.namespaceURI!==this.namespaceURI||f.prefix!==this.prefix||f.localName!==this.localName||f.attribs.length!==this.attribs.length)return!1;for(m=y=0,E=this.attribs.length-1;0<=E?y<=E:y>=E;m=0<=E?++y:--y)if(!this.attribs[m].isEqualNode(f.attribs[m]))return!1;return!0},d})(i)}).call(Nk)});var Fc=_((Lk,jk)=>{(function(){var t,e,r=function(i,s){for(var o in s)n.call(s,o)&&(i[o]=s[o]);function a(){this.constructor=i}return a.prototype=s.prototype,i.prototype=new a,i.__super__=s.prototype,i},n={}.hasOwnProperty;e=Pr(),jk.exports=t=(function(i){r(s,i);function s(o){s.__super__.constructor.call(this,o),this.value=""}return Object.defineProperty(s.prototype,"data",{get:function(){return this.value},set:function(o){return this.value=o||""}}),Object.defineProperty(s.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(s.prototype,"textContent",{get:function(){return this.value},set:function(o){return this.value=o||""}}),s.prototype.clone=function(){return Object.create(this)},s.prototype.substringData=function(o,a){throw new Error("This DOM method is not implemented."+this.debugInfo())},s.prototype.appendData=function(o){throw new Error("This DOM method is not implemented."+this.debugInfo())},s.prototype.insertData=function(o,a){throw new Error("This DOM method is not implemented."+this.debugInfo())},s.prototype.deleteData=function(o,a){throw new Error("This DOM method is not implemented."+this.debugInfo())},s.prototype.replaceData=function(o,a,u){throw new Error("This DOM method is not implemented."+this.debugInfo())},s.prototype.isEqualNode=function(o){return!(!s.__super__.isEqualNode.apply(this,arguments).isEqualNode(o)||o.data!==this.data)},s})(e)}).call(Lk)});var $d=_((Bk,Mk)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;t=_t(),r=Fc(),Mk.exports=e=(function(s){n(o,s);function o(a,u){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=t.CData,this.value=this.stringify.cdata(u)}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(a){return this.options.writer.cdata(this,this.options.writer.filterOptions(a))},o})(r)}).call(Bk)});var Ld=_((qk,Uk)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;t=_t(),e=Fc(),Uk.exports=r=(function(s){n(o,s);function o(a,u){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=t.Comment,this.value=this.stringify.comment(u)}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(a){return this.options.writer.comment(this,this.options.writer.filterOptions(a))},o})(e)}).call(qk)});var jd=_((Hk,Vk)=>{(function(){var t,e,r,n,i=function(o,a){for(var u in a)s.call(a,u)&&(o[u]=a[u]);function c(){this.constructor=o}return c.prototype=a.prototype,o.prototype=new c,o.__super__=a.prototype,o},s={}.hasOwnProperty;n=kn().isObject,r=Pr(),t=_t(),Vk.exports=e=(function(o){i(a,o);function a(u,c,l,h){var d;a.__super__.constructor.call(this,u),n(c)&&(d=c,c=d.version,l=d.encoding,h=d.standalone),c||(c="1.0"),this.type=t.Declaration,this.version=this.stringify.xmlVersion(c),l!=null&&(this.encoding=this.stringify.xmlEncoding(l)),h!=null&&(this.standalone=this.stringify.xmlStandalone(h))}return a.prototype.toString=function(u){return this.options.writer.declaration(this,this.options.writer.filterOptions(u))},a})(r)}).call(Hk)});var Bd=_((zk,Kk)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;r=Pr(),t=_t(),Kk.exports=e=(function(s){n(o,s);function o(a,u,c,l,h,d){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing DTD element name. "+this.debugInfo());if(c==null)throw new Error("Missing DTD attribute name. "+this.debugInfo(u));if(!l)throw new Error("Missing DTD attribute type. "+this.debugInfo(u));if(!h)throw new Error("Missing DTD attribute default. "+this.debugInfo(u));if(h.indexOf("#")!==0&&(h="#"+h),!h.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(u));if(d&&!h.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(u));this.elementName=this.stringify.name(u),this.type=t.AttributeDeclaration,this.attributeName=this.stringify.name(c),this.attributeType=this.stringify.dtdAttType(l),d&&(this.defaultValue=this.stringify.dtdAttDefault(d)),this.defaultValueType=h}return o.prototype.toString=function(a){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(a))},o})(r)}).call(zk)});var Md=_((Gk,Wk)=>{(function(){var t,e,r,n,i=function(o,a){for(var u in a)s.call(a,u)&&(o[u]=a[u]);function c(){this.constructor=o}return c.prototype=a.prototype,o.prototype=new c,o.__super__=a.prototype,o},s={}.hasOwnProperty;n=kn().isObject,r=Pr(),t=_t(),Wk.exports=e=(function(o){i(a,o);function a(u,c,l,h){if(a.__super__.constructor.call(this,u),l==null)throw new Error("Missing DTD entity name. "+this.debugInfo(l));if(h==null)throw new Error("Missing DTD entity value. "+this.debugInfo(l));if(this.pe=!!c,this.name=this.stringify.name(l),this.type=t.EntityDeclaration,!n(h))this.value=this.stringify.dtdEntityValue(h),this.internal=!0;else{if(!h.pubID&&!h.sysID)throw new Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(l));if(h.pubID&&!h.sysID)throw new Error("System identifier is required for a public external entity. "+this.debugInfo(l));if(this.internal=!1,h.pubID!=null&&(this.pubID=this.stringify.dtdPubID(h.pubID)),h.sysID!=null&&(this.sysID=this.stringify.dtdSysID(h.sysID)),h.nData!=null&&(this.nData=this.stringify.dtdNData(h.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(l))}}return Object.defineProperty(a.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(a.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(a.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(a.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(a.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(a.prototype,"xmlVersion",{get:function(){return null}}),a.prototype.toString=function(u){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(u))},a})(r)}).call(Gk)});var qd=_((Xk,Yk)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;r=Pr(),t=_t(),Yk.exports=e=(function(s){n(o,s);function o(a,u,c){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing DTD element name. "+this.debugInfo());c||(c="(#PCDATA)"),Array.isArray(c)&&(c="("+c.join(",")+")"),this.name=this.stringify.name(u),this.type=t.ElementDeclaration,this.value=this.stringify.dtdElementValue(c)}return o.prototype.toString=function(a){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(a))},o})(r)}).call(Xk)});var Ud=_((Jk,Zk)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;r=Pr(),t=_t(),Zk.exports=e=(function(s){n(o,s);function o(a,u,c){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing DTD notation name. "+this.debugInfo(u));if(!c.pubID&&!c.sysID)throw new Error("Public or system identifiers are required for an external entity. "+this.debugInfo(u));this.name=this.stringify.name(u),this.type=t.NotationDeclaration,c.pubID!=null&&(this.pubID=this.stringify.dtdPubID(c.pubID)),c.sysID!=null&&(this.sysID=this.stringify.dtdSysID(c.sysID))}return Object.defineProperty(o.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(o.prototype,"systemId",{get:function(){return this.sysID}}),o.prototype.toString=function(a){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(a))},o})(r)}).call(Jk)});var Hd=_((Qk,eN)=>{(function(){var t,e,r,n,i,s,o,a,u,c=function(h,d){for(var f in d)l.call(d,f)&&(h[f]=d[f]);function m(){this.constructor=h}return m.prototype=d.prototype,h.prototype=new m,h.__super__=d.prototype,h},l={}.hasOwnProperty;u=kn().isObject,a=Pr(),t=_t(),e=Bd(),n=Md(),r=qd(),i=Ud(),o=kd(),eN.exports=s=(function(h){c(d,h);function d(f,m,y){var E,S,A,p,D,w;if(d.__super__.constructor.call(this,f),this.type=t.DocType,f.children){for(p=f.children,S=0,A=p.length;S<A;S++)if(E=p[S],E.type===t.Element){this.name=E.name;break}}this.documentObject=f,u(m)&&(D=m,m=D.pubID,y=D.sysID),y==null&&(w=[m,y],y=w[0],m=w[1]),m!=null&&(this.pubID=this.stringify.dtdPubID(m)),y!=null&&(this.sysID=this.stringify.dtdSysID(y))}return Object.defineProperty(d.prototype,"entities",{get:function(){var f,m,y,E,S;for(E={},S=this.children,m=0,y=S.length;m<y;m++)f=S[m],f.type===t.EntityDeclaration&&!f.pe&&(E[f.name]=f);return new o(E)}}),Object.defineProperty(d.prototype,"notations",{get:function(){var f,m,y,E,S;for(E={},S=this.children,m=0,y=S.length;m<y;m++)f=S[m],f.type===t.NotationDeclaration&&(E[f.name]=f);return new o(E)}}),Object.defineProperty(d.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(d.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(d.prototype,"internalSubset",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),d.prototype.element=function(f,m){var y;return y=new r(this,f,m),this.children.push(y),this},d.prototype.attList=function(f,m,y,E,S){var A;return A=new e(this,f,m,y,E,S),this.children.push(A),this},d.prototype.entity=function(f,m){var y;return y=new n(this,!1,f,m),this.children.push(y),this},d.prototype.pEntity=function(f,m){var y;return y=new n(this,!0,f,m),this.children.push(y),this},d.prototype.notation=function(f,m){var y;return y=new i(this,f,m),this.children.push(y),this},d.prototype.toString=function(f){return this.options.writer.docType(this,this.options.writer.filterOptions(f))},d.prototype.ele=function(f,m){return this.element(f,m)},d.prototype.att=function(f,m,y,E,S){return this.attList(f,m,y,E,S)},d.prototype.ent=function(f,m){return this.entity(f,m)},d.prototype.pent=function(f,m){return this.pEntity(f,m)},d.prototype.not=function(f,m){return this.notation(f,m)},d.prototype.up=function(){return this.root()||this.documentObject},d.prototype.isEqualNode=function(f){return!(!d.__super__.isEqualNode.apply(this,arguments).isEqualNode(f)||f.name!==this.name||f.publicId!==this.publicId||f.systemId!==this.systemId)},d})(a)}).call(Qk)});var Vd=_((tN,rN)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;t=_t(),e=Pr(),rN.exports=r=(function(s){n(o,s);function o(a,u){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing raw text. "+this.debugInfo());this.type=t.Raw,this.value=this.stringify.raw(u)}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(a){return this.options.writer.raw(this,this.options.writer.filterOptions(a))},o})(e)}).call(tN)});var zd=_((nN,iN)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;t=_t(),e=Fc(),iN.exports=r=(function(s){n(o,s);function o(a,u){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=t.Text,this.value=this.stringify.text(u)}return Object.defineProperty(o.prototype,"isElementContentWhitespace",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(o.prototype,"wholeText",{get:function(){var a,u,c;for(c="",u=this.previousSibling;u;)c=u.data+c,u=u.previousSibling;for(c+=this.data,a=this.nextSibling;a;)c=c+a.data,a=a.nextSibling;return c}}),o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(a){return this.options.writer.text(this,this.options.writer.filterOptions(a))},o.prototype.splitText=function(a){throw new Error("This DOM method is not implemented."+this.debugInfo())},o.prototype.replaceWholeText=function(a){throw new Error("This DOM method is not implemented."+this.debugInfo())},o})(e)}).call(nN)});var Kd=_((sN,oN)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;t=_t(),e=Fc(),oN.exports=r=(function(s){n(o,s);function o(a,u,c){if(o.__super__.constructor.call(this,a),u==null)throw new Error("Missing instruction target. "+this.debugInfo());this.type=t.ProcessingInstruction,this.target=this.stringify.insTarget(u),this.name=this.target,c&&(this.value=this.stringify.insValue(c))}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(a){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(a))},o.prototype.isEqualNode=function(a){return!(!o.__super__.isEqualNode.apply(this,arguments).isEqualNode(a)||a.target!==this.target)},o})(e)}).call(sN)});var dE=_((aN,uN)=>{(function(){var t,e,r,n=function(s,o){for(var a in o)i.call(o,a)&&(s[a]=o[a]);function u(){this.constructor=s}return u.prototype=o.prototype,s.prototype=new u,s.__super__=o.prototype,s},i={}.hasOwnProperty;r=Pr(),t=_t(),uN.exports=e=(function(s){n(o,s);function o(a){o.__super__.constructor.call(this,a),this.type=t.Dummy}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(a){return""},o})(r)}).call(aN)});var fN=_((cN,lN)=>{(function(){var t;lN.exports=t=(function(){function e(r){this.nodes=r}return Object.defineProperty(e.prototype,"length",{get:function(){return this.nodes.length||0}}),e.prototype.clone=function(){return this.nodes=null},e.prototype.item=function(r){return this.nodes[r]||null},e})()}).call(cN)});var pN=_((hN,dN)=>{(function(){dN.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}).call(hN)});var Pr=_((mN,gN)=>{(function(){var t,e,r,n,i,s,o,a,u,c,l,h,d,f,m,y,E,S,A,p={}.hasOwnProperty;A=kn(),S=A.isObject,E=A.isFunction,y=A.isEmpty,m=A.getValue,a=null,r=null,n=null,i=null,s=null,d=null,f=null,h=null,o=null,e=null,l=null,u=null,t=null,gN.exports=c=(function(){function D(w){this.parent=w,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),this.value=null,this.children=[],this.baseURI=null,a||(a=Nd(),r=$d(),n=Ld(),i=jd(),s=Hd(),d=Vd(),f=zd(),h=Kd(),o=dE(),e=_t(),l=fN(),u=kd(),t=pN())}return Object.defineProperty(D.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(D.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(D.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(D.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(D.prototype,"childNodes",{get:function(){return(!this.childNodeList||!this.childNodeList.nodes)&&(this.childNodeList=new l(this.children)),this.childNodeList}}),Object.defineProperty(D.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(D.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(D.prototype,"previousSibling",{get:function(){var w;return w=this.parent.children.indexOf(this),this.parent.children[w-1]||null}}),Object.defineProperty(D.prototype,"nextSibling",{get:function(){var w;return w=this.parent.children.indexOf(this),this.parent.children[w+1]||null}}),Object.defineProperty(D.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(D.prototype,"textContent",{get:function(){var w,b,P,v,k;if(this.nodeType===e.Element||this.nodeType===e.DocumentFragment){for(k="",v=this.children,b=0,P=v.length;b<P;b++)w=v[b],w.textContent&&(k+=w.textContent);return k}else return null},set:function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),D.prototype.setParent=function(w){var b,P,v,k,R;for(this.parent=w,w&&(this.options=w.options,this.stringify=w.stringify),k=this.children,R=[],P=0,v=k.length;P<v;P++)b=k[P],R.push(b.setParent(this));return R},D.prototype.element=function(w,b,P){var v,k,R,I,j,U,z,$,C,T,F;if(U=null,b===null&&P==null&&(C=[{},null],b=C[0],P=C[1]),b==null&&(b={}),b=m(b),S(b)||(T=[b,P],P=T[0],b=T[1]),w!=null&&(w=m(w)),Array.isArray(w))for(R=0,z=w.length;R<z;R++)k=w[R],U=this.element(k);else if(E(w))U=this.element(w.apply());else if(S(w)){for(j in w)if(p.call(w,j))if(F=w[j],E(F)&&(F=F.apply()),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&j.indexOf(this.stringify.convertAttKey)===0)U=this.attribute(j.substr(this.stringify.convertAttKey.length),F);else if(!this.options.separateArrayItems&&Array.isArray(F)&&y(F))U=this.dummy();else if(S(F)&&y(F))U=this.element(j);else if(!this.options.keepNullNodes&&F==null)U=this.dummy();else if(!this.options.separateArrayItems&&Array.isArray(F))for(I=0,$=F.length;I<$;I++)k=F[I],v={},v[j]=k,U=this.element(v);else S(F)?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&j.indexOf(this.stringify.convertTextKey)===0?U=this.element(F):(U=this.element(j),U.element(F)):U=this.element(j,F)}else!this.options.keepNullNodes&&P===null?U=this.dummy():!this.options.ignoreDecorators&&this.stringify.convertTextKey&&w.indexOf(this.stringify.convertTextKey)===0?U=this.text(P):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&w.indexOf(this.stringify.convertCDataKey)===0?U=this.cdata(P):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&w.indexOf(this.stringify.convertCommentKey)===0?U=this.comment(P):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&w.indexOf(this.stringify.convertRawKey)===0?U=this.raw(P):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&w.indexOf(this.stringify.convertPIKey)===0?U=this.instruction(w.substr(this.stringify.convertPIKey.length),P):U=this.node(w,b,P);if(U==null)throw new Error("Could not create any elements with: "+w+". "+this.debugInfo());return U},D.prototype.insertBefore=function(w,b,P){var v,k,R,I,j;if(w?.type)return R=w,I=b,R.setParent(this),I?(k=children.indexOf(I),j=children.splice(k),children.push(R),Array.prototype.push.apply(children,j)):children.push(R),R;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(w));return k=this.parent.children.indexOf(this),j=this.parent.children.splice(k),v=this.parent.element(w,b,P),Array.prototype.push.apply(this.parent.children,j),v},D.prototype.insertAfter=function(w,b,P){var v,k,R;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(w));return k=this.parent.children.indexOf(this),R=this.parent.children.splice(k+1),v=this.parent.element(w,b,P),Array.prototype.push.apply(this.parent.children,R),v},D.prototype.remove=function(){var w,b;if(this.isRoot)throw new Error("Cannot remove the root element. "+this.debugInfo());return w=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[w,w-w+1].concat(b=[])),this.parent},D.prototype.node=function(w,b,P){var v,k;return w!=null&&(w=m(w)),b||(b={}),b=m(b),S(b)||(k=[b,P],P=k[0],b=k[1]),v=new a(this,w,b),P!=null&&v.text(P),this.children.push(v),v},D.prototype.text=function(w){var b;return S(w)&&this.element(w),b=new f(this,w),this.children.push(b),this},D.prototype.cdata=function(w){var b;return b=new r(this,w),this.children.push(b),this},D.prototype.comment=function(w){var b;return b=new n(this,w),this.children.push(b),this},D.prototype.commentBefore=function(w){var b,P,v;return P=this.parent.children.indexOf(this),v=this.parent.children.splice(P),b=this.parent.comment(w),Array.prototype.push.apply(this.parent.children,v),this},D.prototype.commentAfter=function(w){var b,P,v;return P=this.parent.children.indexOf(this),v=this.parent.children.splice(P+1),b=this.parent.comment(w),Array.prototype.push.apply(this.parent.children,v),this},D.prototype.raw=function(w){var b;return b=new d(this,w),this.children.push(b),this},D.prototype.dummy=function(){var w;return w=new o(this),w},D.prototype.instruction=function(w,b){var P,v,k,R,I;if(w!=null&&(w=m(w)),b!=null&&(b=m(b)),Array.isArray(w))for(R=0,I=w.length;R<I;R++)P=w[R],this.instruction(P);else if(S(w))for(P in w)p.call(w,P)&&(v=w[P],this.instruction(P,v));else E(b)&&(b=b.apply()),k=new h(this,w,b),this.children.push(k);return this},D.prototype.instructionBefore=function(w,b){var P,v,k;return v=this.parent.children.indexOf(this),k=this.parent.children.splice(v),P=this.parent.instruction(w,b),Array.prototype.push.apply(this.parent.children,k),this},D.prototype.instructionAfter=function(w,b){var P,v,k;return v=this.parent.children.indexOf(this),k=this.parent.children.splice(v+1),P=this.parent.instruction(w,b),Array.prototype.push.apply(this.parent.children,k),this},D.prototype.declaration=function(w,b,P){var v,k;return v=this.document(),k=new i(v,w,b,P),v.children.length===0?v.children.unshift(k):v.children[0].type===e.Declaration?v.children[0]=k:v.children.unshift(k),v.root()||v},D.prototype.dtd=function(w,b){var P,v,k,R,I,j,U,z,$,C;for(v=this.document(),k=new s(v,w,b),$=v.children,R=I=0,U=$.length;I<U;R=++I)if(P=$[R],P.type===e.DocType)return v.children[R]=k,k;for(C=v.children,R=j=0,z=C.length;j<z;R=++j)if(P=C[R],P.isRoot)return v.children.splice(R,0,k),k;return v.children.push(k),k},D.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},D.prototype.root=function(){var w;for(w=this;w;){if(w.type===e.Document)return w.rootObject;if(w.isRoot)return w;w=w.parent}},D.prototype.document=function(){var w;for(w=this;w;){if(w.type===e.Document)return w;w=w.parent}},D.prototype.end=function(w){return this.document().end(w)},D.prototype.prev=function(){var w;if(w=this.parent.children.indexOf(this),w<1)throw new Error("Already at the first node. "+this.debugInfo());return this.parent.children[w-1]},D.prototype.next=function(){var w;if(w=this.parent.children.indexOf(this),w===-1||w===this.parent.children.length-1)throw new Error("Already at the last node. "+this.debugInfo());return this.parent.children[w+1]},D.prototype.importDocument=function(w){var b;return b=w.root().clone(),b.parent=this,b.isRoot=!1,this.children.push(b),this},D.prototype.debugInfo=function(w){var b,P;return w=w||this.name,w==null&&!((b=this.parent)!=null&&b.name)?"":w==null?"parent: <"+this.parent.name+">":(P=this.parent)!=null&&P.name?"node: <"+w+">, parent: <"+this.parent.name+">":"node: <"+w+">"},D.prototype.ele=function(w,b,P){return this.element(w,b,P)},D.prototype.nod=function(w,b,P){return this.node(w,b,P)},D.prototype.txt=function(w){return this.text(w)},D.prototype.dat=function(w){return this.cdata(w)},D.prototype.com=function(w){return this.comment(w)},D.prototype.ins=function(w,b){return this.instruction(w,b)},D.prototype.doc=function(){return this.document()},D.prototype.dec=function(w,b,P){return this.declaration(w,b,P)},D.prototype.e=function(w,b,P){return this.element(w,b,P)},D.prototype.n=function(w,b,P){return this.node(w,b,P)},D.prototype.t=function(w){return this.text(w)},D.prototype.d=function(w){return this.cdata(w)},D.prototype.c=function(w){return this.comment(w)},D.prototype.r=function(w){return this.raw(w)},D.prototype.i=function(w,b){return this.instruction(w,b)},D.prototype.u=function(){return this.up()},D.prototype.importXMLBuilder=function(w){return this.importDocument(w)},D.prototype.replaceChild=function(w,b){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.removeChild=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.appendChild=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.hasChildNodes=function(){return this.children.length!==0},D.prototype.cloneNode=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.normalize=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.isSupported=function(w,b){return!0},D.prototype.hasAttributes=function(){return this.attribs.length!==0},D.prototype.compareDocumentPosition=function(w){var b,P;return b=this,b===w?0:this.document()!==w.document()?(P=t.Disconnected|t.ImplementationSpecific,Math.random()<.5?P|=t.Preceding:P|=t.Following,P):b.isAncestor(w)?t.Contains|t.Preceding:b.isDescendant(w)?t.Contains|t.Following:b.isPreceding(w)?t.Preceding:t.Following},D.prototype.isSameNode=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.lookupPrefix=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.isDefaultNamespace=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.lookupNamespaceURI=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.isEqualNode=function(w){var b,P,v;if(w.nodeType!==this.nodeType||w.children.length!==this.children.length)return!1;for(b=P=0,v=this.children.length-1;0<=v?P<=v:P>=v;b=0<=v?++P:--P)if(!this.children[b].isEqualNode(w.children[b]))return!1;return!0},D.prototype.getFeature=function(w,b){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.setUserData=function(w,b,P){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.getUserData=function(w){throw new Error("This DOM method is not implemented."+this.debugInfo())},D.prototype.contains=function(w){return w?w===this||this.isDescendant(w):!1},D.prototype.isDescendant=function(w){var b,P,v,k,R;for(R=this.children,v=0,k=R.length;v<k;v++)if(b=R[v],w===b||(P=b.isDescendant(w),P))return!0;return!1},D.prototype.isAncestor=function(w){return w.isDescendant(this)},D.prototype.isPreceding=function(w){var b,P;return b=this.treePosition(w),P=this.treePosition(this),b===-1||P===-1?!1:b<P},D.prototype.isFollowing=function(w){var b,P;return b=this.treePosition(w),P=this.treePosition(this),b===-1||P===-1?!1:b>P},D.prototype.treePosition=function(w){var b,P;return P=0,b=!1,this.foreachTreeNode(this.document(),function(v){if(P++,!b&&v===w)return b=!0}),b?P:-1},D.prototype.foreachTreeNode=function(w,b){var P,v,k,R,I;for(w||(w=this.document()),R=w.children,v=0,k=R.length;v<k;v++){if(P=R[v],I=b(P))return I;if(I=this.foreachTreeNode(P,b),I)return I}},D})()}).call(mN)});var pE=_((yN,DN)=>{(function(){var t,e=function(n,i){return function(){return n.apply(i,arguments)}},r={}.hasOwnProperty;DN.exports=t=(function(){function n(i){this.assertLegalName=e(this.assertLegalName,this),this.assertLegalChar=e(this.assertLegalChar,this);var s,o,a;i||(i={}),this.options=i,this.options.version||(this.options.version="1.0"),o=i.stringify||{};for(s in o)r.call(o,s)&&(a=o[s],this[s]=a)}return n.prototype.name=function(i){return this.options.noValidation?i:this.assertLegalName(""+i||"")},n.prototype.text=function(i){return this.options.noValidation?i:this.assertLegalChar(this.textEscape(""+i||""))},n.prototype.cdata=function(i){return this.options.noValidation?i:(i=""+i||"",i=i.replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(i))},n.prototype.comment=function(i){if(this.options.noValidation)return i;if(i=""+i||"",i.match(/--/))throw new Error("Comment text cannot contain double-hypen: "+i);return this.assertLegalChar(i)},n.prototype.raw=function(i){return this.options.noValidation?i:""+i||""},n.prototype.attValue=function(i){return this.options.noValidation?i:this.assertLegalChar(this.attEscape(i=""+i||""))},n.prototype.insTarget=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.insValue=function(i){if(this.options.noValidation)return i;if(i=""+i||"",i.match(/\?>/))throw new Error("Invalid processing instruction value: "+i);return this.assertLegalChar(i)},n.prototype.xmlVersion=function(i){if(this.options.noValidation)return i;if(i=""+i||"",!i.match(/1\.[0-9]+/))throw new Error("Invalid version number: "+i);return i},n.prototype.xmlEncoding=function(i){if(this.options.noValidation)return i;if(i=""+i||"",!i.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw new Error("Invalid encoding: "+i);return this.assertLegalChar(i)},n.prototype.xmlStandalone=function(i){return this.options.noValidation?i:i?"yes":"no"},n.prototype.dtdPubID=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.dtdSysID=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.dtdElementValue=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.dtdAttType=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.dtdAttDefault=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.dtdEntityValue=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.dtdNData=function(i){return this.options.noValidation?i:this.assertLegalChar(""+i||"")},n.prototype.convertAttKey="@",n.prototype.convertPIKey="?",n.prototype.convertTextKey="#text",n.prototype.convertCDataKey="#cdata",n.prototype.convertCommentKey="#comment",n.prototype.convertRawKey="#raw",n.prototype.assertLegalChar=function(i){var s,o;if(this.options.noValidation)return i;if(s="",this.options.version==="1.0"){if(s=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,o=i.match(s))throw new Error("Invalid character in string: "+i+" at index "+o.index)}else if(this.options.version==="1.1"&&(s=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,o=i.match(s)))throw new Error("Invalid character in string: "+i+" at index "+o.index);return i},n.prototype.assertLegalName=function(i){var s;if(this.options.noValidation)return i;if(this.assertLegalChar(i),s=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!i.match(s))throw new Error("Invalid character in name");return i},n.prototype.textEscape=function(i){var s;return this.options.noValidation?i:(s=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,i.replace(s,"&").replace(/</g,"<").replace(/>/g,">").replace(/\r/g,"
"))},n.prototype.attEscape=function(i){var s;return this.options.noValidation?i:(s=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,i.replace(s,"&").replace(/</g,"<").replace(/"/g,""").replace(/\t/g,"	").replace(/\n/g,"
").replace(/\r/g,"
"))},n})()}).call(yN)});var Pc=_((wN,EN)=>{(function(){EN.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}).call(wN)});var mE=_((bN,vN)=>{(function(){var t,e,r,n,i,s,o,a,u,c,l,h,d,f,m,y,E,S={}.hasOwnProperty;E=kn().assign,t=_t(),u=jd(),c=Hd(),r=$d(),n=Ld(),h=Nd(),f=Vd(),m=zd(),d=Kd(),l=dE(),i=Bd(),s=qd(),o=Md(),a=Ud(),e=Pc(),vN.exports=y=(function(){function A(p){var D,w,b;p||(p={}),this.options=p,w=p.writer||{};for(D in w)S.call(w,D)&&(b=w[D],this["_"+D]=this[D],this[D]=b)}return A.prototype.filterOptions=function(p){var D,w,b,P,v,k,R,I;return p||(p={}),p=E({},this.options,p),D={writer:this},D.pretty=p.pretty||!1,D.allowEmpty=p.allowEmpty||!1,D.indent=(w=p.indent)!=null?w:" ",D.newline=(b=p.newline)!=null?b:`
|
|
185
185
|
`,D.offset=(P=p.offset)!=null?P:0,D.dontPrettyTextNodes=(v=(k=p.dontPrettyTextNodes)!=null?k:p.dontprettytextnodes)!=null?v:0,D.spaceBeforeSlash=(R=(I=p.spaceBeforeSlash)!=null?I:p.spacebeforeslash)!=null?R:"",D.spaceBeforeSlash===!0&&(D.spaceBeforeSlash=" "),D.suppressPrettyCount=0,D.user={},D.state=e.None,D},A.prototype.indent=function(p,D,w){var b;return!D.pretty||D.suppressPrettyCount?"":D.pretty&&(b=(w||0)+D.offset+1,b>0)?new Array(b).join(D.indent):""},A.prototype.endline=function(p,D,w){return!D.pretty||D.suppressPrettyCount?"":D.newline},A.prototype.attribute=function(p,D,w){var b;return this.openAttribute(p,D,w),b=" "+p.name+'="'+p.value+'"',this.closeAttribute(p,D,w),b},A.prototype.cdata=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<![CDATA[",D.state=e.InsideTag,b+=p.value,D.state=e.CloseTag,b+="]]>"+this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.comment=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<!-- ",D.state=e.InsideTag,b+=p.value,D.state=e.CloseTag,b+=" -->"+this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.declaration=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<?xml",D.state=e.InsideTag,b+=' version="'+p.version+'"',p.encoding!=null&&(b+=' encoding="'+p.encoding+'"'),p.standalone!=null&&(b+=' standalone="'+p.standalone+'"'),D.state=e.CloseTag,b+=D.spaceBeforeSlash+"?>",b+=this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.docType=function(p,D,w){var b,P,v,k,R;if(w||(w=0),this.openNode(p,D,w),D.state=e.OpenTag,k=this.indent(p,D,w),k+="<!DOCTYPE "+p.root().name,p.pubID&&p.sysID?k+=' PUBLIC "'+p.pubID+'" "'+p.sysID+'"':p.sysID&&(k+=' SYSTEM "'+p.sysID+'"'),p.children.length>0){for(k+=" [",k+=this.endline(p,D,w),D.state=e.InsideTag,R=p.children,P=0,v=R.length;P<v;P++)b=R[P],k+=this.writeChildNode(b,D,w+1);D.state=e.CloseTag,k+="]"}return D.state=e.CloseTag,k+=D.spaceBeforeSlash+">",k+=this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),k},A.prototype.element=function(p,D,w){var b,P,v,k,R,I,j,U,z,$,C,T,F,L;w||(w=0),$=!1,C="",this.openNode(p,D,w),D.state=e.OpenTag,C+=this.indent(p,D,w)+"<"+p.name,T=p.attribs;for(z in T)S.call(T,z)&&(b=T[z],C+=this.attribute(b,D,w));if(v=p.children.length,k=v===0?null:p.children[0],v===0||p.children.every(function(M){return(M.type===t.Text||M.type===t.Raw)&&M.value===""}))D.allowEmpty?(C+=">",D.state=e.CloseTag,C+="</"+p.name+">"+this.endline(p,D,w)):(D.state=e.CloseTag,C+=D.spaceBeforeSlash+"/>"+this.endline(p,D,w));else if(D.pretty&&v===1&&(k.type===t.Text||k.type===t.Raw)&&k.value!=null)C+=">",D.state=e.InsideTag,D.suppressPrettyCount++,$=!0,C+=this.writeChildNode(k,D,w+1),D.suppressPrettyCount--,$=!1,D.state=e.CloseTag,C+="</"+p.name+">"+this.endline(p,D,w);else{if(D.dontPrettyTextNodes){for(F=p.children,R=0,j=F.length;R<j;R++)if(P=F[R],(P.type===t.Text||P.type===t.Raw)&&P.value!=null){D.suppressPrettyCount++,$=!0;break}}for(C+=">"+this.endline(p,D,w),D.state=e.InsideTag,L=p.children,I=0,U=L.length;I<U;I++)P=L[I],C+=this.writeChildNode(P,D,w+1);D.state=e.CloseTag,C+=this.indent(p,D,w)+"</"+p.name+">",$&&D.suppressPrettyCount--,C+=this.endline(p,D,w),D.state=e.None}return this.closeNode(p,D,w),C},A.prototype.writeChildNode=function(p,D,w){switch(p.type){case t.CData:return this.cdata(p,D,w);case t.Comment:return this.comment(p,D,w);case t.Element:return this.element(p,D,w);case t.Raw:return this.raw(p,D,w);case t.Text:return this.text(p,D,w);case t.ProcessingInstruction:return this.processingInstruction(p,D,w);case t.Dummy:return"";case t.Declaration:return this.declaration(p,D,w);case t.DocType:return this.docType(p,D,w);case t.AttributeDeclaration:return this.dtdAttList(p,D,w);case t.ElementDeclaration:return this.dtdElement(p,D,w);case t.EntityDeclaration:return this.dtdEntity(p,D,w);case t.NotationDeclaration:return this.dtdNotation(p,D,w);default:throw new Error("Unknown XML node type: "+p.constructor.name)}},A.prototype.processingInstruction=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<?",D.state=e.InsideTag,b+=p.target,p.value&&(b+=" "+p.value),D.state=e.CloseTag,b+=D.spaceBeforeSlash+"?>",b+=this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.raw=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w),D.state=e.InsideTag,b+=p.value,D.state=e.CloseTag,b+=this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.text=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w),D.state=e.InsideTag,b+=p.value,D.state=e.CloseTag,b+=this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.dtdAttList=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<!ATTLIST",D.state=e.InsideTag,b+=" "+p.elementName+" "+p.attributeName+" "+p.attributeType,p.defaultValueType!=="#DEFAULT"&&(b+=" "+p.defaultValueType),p.defaultValue&&(b+=' "'+p.defaultValue+'"'),D.state=e.CloseTag,b+=D.spaceBeforeSlash+">"+this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.dtdElement=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<!ELEMENT",D.state=e.InsideTag,b+=" "+p.name+" "+p.value,D.state=e.CloseTag,b+=D.spaceBeforeSlash+">"+this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.dtdEntity=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<!ENTITY",D.state=e.InsideTag,p.pe&&(b+=" %"),b+=" "+p.name,p.value?b+=' "'+p.value+'"':(p.pubID&&p.sysID?b+=' PUBLIC "'+p.pubID+'" "'+p.sysID+'"':p.sysID&&(b+=' SYSTEM "'+p.sysID+'"'),p.nData&&(b+=" NDATA "+p.nData)),D.state=e.CloseTag,b+=D.spaceBeforeSlash+">"+this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.dtdNotation=function(p,D,w){var b;return this.openNode(p,D,w),D.state=e.OpenTag,b=this.indent(p,D,w)+"<!NOTATION",D.state=e.InsideTag,b+=" "+p.name,p.pubID&&p.sysID?b+=' PUBLIC "'+p.pubID+'" "'+p.sysID+'"':p.pubID?b+=' PUBLIC "'+p.pubID+'"':p.sysID&&(b+=' SYSTEM "'+p.sysID+'"'),D.state=e.CloseTag,b+=D.spaceBeforeSlash+">"+this.endline(p,D,w),D.state=e.None,this.closeNode(p,D,w),b},A.prototype.openNode=function(p,D,w){},A.prototype.closeNode=function(p,D,w){},A.prototype.openAttribute=function(p,D,w){},A.prototype.closeAttribute=function(p,D,w){},A})()}).call(bN)});var Gd=_((_N,CN)=>{(function(){var t,e,r=function(i,s){for(var o in s)n.call(s,o)&&(i[o]=s[o]);function a(){this.constructor=i}return a.prototype=s.prototype,i.prototype=new a,i.__super__=s.prototype,i},n={}.hasOwnProperty;e=mE(),CN.exports=t=(function(i){r(s,i);function s(o){s.__super__.constructor.call(this,o)}return s.prototype.document=function(o,a){var u,c,l,h,d;for(a=this.filterOptions(a),h="",d=o.children,c=0,l=d.length;c<l;c++)u=d[c],h+=this.writeChildNode(u,a,0);return a.pretty&&h.slice(-a.newline.length)===a.newline&&(h=h.slice(0,-a.newline.length)),h},s})(e)}).call(_N)});var gE=_((SN,AN)=>{(function(){var t,e,r,n,i,s,o,a,u=function(l,h){for(var d in h)c.call(h,d)&&(l[d]=h[d]);function f(){this.constructor=l}return f.prototype=h.prototype,l.prototype=new f,l.__super__=h.prototype,l},c={}.hasOwnProperty;a=kn().isPlainObject,r=fE(),e=xk(),i=Pr(),t=_t(),o=pE(),s=Gd(),AN.exports=n=(function(l){u(h,l);function h(d){h.__super__.constructor.call(this,null),this.name="#document",this.type=t.Document,this.documentURI=null,this.domConfig=new e,d||(d={}),d.writer||(d.writer=new s),this.options=d,this.stringify=new o(d)}return Object.defineProperty(h.prototype,"implementation",{value:new r}),Object.defineProperty(h.prototype,"doctype",{get:function(){var d,f,m,y;for(y=this.children,f=0,m=y.length;f<m;f++)if(d=y[f],d.type===t.DocType)return d;return null}}),Object.defineProperty(h.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(h.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(h.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(h.prototype,"xmlEncoding",{get:function(){return this.children.length!==0&&this.children[0].type===t.Declaration?this.children[0].encoding:null}}),Object.defineProperty(h.prototype,"xmlStandalone",{get:function(){return this.children.length!==0&&this.children[0].type===t.Declaration?this.children[0].standalone==="yes":!1}}),Object.defineProperty(h.prototype,"xmlVersion",{get:function(){return this.children.length!==0&&this.children[0].type===t.Declaration?this.children[0].version:"1.0"}}),Object.defineProperty(h.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(h.prototype,"origin",{get:function(){return null}}),Object.defineProperty(h.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(h.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(h.prototype,"contentType",{get:function(){return null}}),h.prototype.end=function(d){var f;return f={},d?a(d)&&(f=d,d=this.options.writer):d=this.options.writer,d.document(this,d.filterOptions(f))},h.prototype.toString=function(d){return this.options.writer.document(this,this.options.writer.filterOptions(d))},h.prototype.createElement=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createDocumentFragment=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createTextNode=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createComment=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createCDATASection=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createProcessingInstruction=function(d,f){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createAttribute=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createEntityReference=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.getElementsByTagName=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.importNode=function(d,f){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createElementNS=function(d,f){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createAttributeNS=function(d,f){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.getElementsByTagNameNS=function(d,f){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.getElementById=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.adoptNode=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.normalizeDocument=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.renameNode=function(d,f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.getElementsByClassName=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createEvent=function(d){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createRange=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createNodeIterator=function(d,f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},h.prototype.createTreeWalker=function(d,f,m){throw new Error("This DOM method is not implemented."+this.debugInfo())},h})(i)}).call(SN)});var TN=_((ON,xN)=>{(function(){var t,e,r,n,i,s,o,a,u,c,l,h,d,f,m,y,E,S,A,p,D,w,b,P,v={}.hasOwnProperty;P=kn(),w=P.isObject,D=P.isFunction,b=P.isPlainObject,p=P.getValue,t=_t(),h=gE(),f=Nd(),n=$d(),i=Ld(),y=Vd(),A=zd(),m=Kd(),c=jd(),l=Hd(),s=Bd(),a=Md(),o=qd(),u=Ud(),r=hE(),S=pE(),E=Gd(),e=Pc(),xN.exports=d=(function(){function k(R,I,j){var U;this.name="?xml",this.type=t.Document,R||(R={}),U={},R.writer?b(R.writer)&&(U=R.writer,R.writer=new E):R.writer=new E,this.options=R,this.writer=R.writer,this.writerOptions=this.writer.filterOptions(U),this.stringify=new S(R),this.onDataCallback=I||function(){},this.onEndCallback=j||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return k.prototype.createChildNode=function(R){var I,j,U,z,$,C,T,F;switch(R.type){case t.CData:this.cdata(R.value);break;case t.Comment:this.comment(R.value);break;case t.Element:U={},T=R.attribs;for(j in T)v.call(T,j)&&(I=T[j],U[j]=I.value);this.node(R.name,U);break;case t.Dummy:this.dummy();break;case t.Raw:this.raw(R.value);break;case t.Text:this.text(R.value);break;case t.ProcessingInstruction:this.instruction(R.target,R.value);break;default:throw new Error("This XML node type is not supported in a JS object: "+R.constructor.name)}for(F=R.children,$=0,C=F.length;$<C;$++)z=F[$],this.createChildNode(z),z.type===t.Element&&this.up();return this},k.prototype.dummy=function(){return this},k.prototype.node=function(R,I,j){var U;if(R==null)throw new Error("Missing node name.");if(this.root&&this.currentLevel===-1)throw new Error("Document can only have one root node. "+this.debugInfo(R));return this.openCurrent(),R=p(R),I==null&&(I={}),I=p(I),w(I)||(U=[I,j],j=U[0],I=U[1]),this.currentNode=new f(this,R,I),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,j!=null&&this.text(j),this},k.prototype.element=function(R,I,j){var U,z,$,C,T,F;if(this.currentNode&&this.currentNode.type===t.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(R)||w(R)||D(R))for(C=this.options.noValidation,this.options.noValidation=!0,F=new h(this.options).element("TEMP_ROOT"),F.element(R),this.options.noValidation=C,T=F.children,z=0,$=T.length;z<$;z++)U=T[z],this.createChildNode(U),U.type===t.Element&&this.up();else this.node(R,I,j);return this},k.prototype.attribute=function(R,I){var j,U;if(!this.currentNode||this.currentNode.children)throw new Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(R));if(R!=null&&(R=p(R)),w(R))for(j in R)v.call(R,j)&&(U=R[j],this.attribute(j,U));else D(I)&&(I=I.apply()),this.options.keepNullAttributes&&I==null?this.currentNode.attribs[R]=new r(this,R,""):I!=null&&(this.currentNode.attribs[R]=new r(this,R,I));return this},k.prototype.text=function(R){var I;return this.openCurrent(),I=new A(this,R),this.onData(this.writer.text(I,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.cdata=function(R){var I;return this.openCurrent(),I=new n(this,R),this.onData(this.writer.cdata(I,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.comment=function(R){var I;return this.openCurrent(),I=new i(this,R),this.onData(this.writer.comment(I,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.raw=function(R){var I;return this.openCurrent(),I=new y(this,R),this.onData(this.writer.raw(I,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.instruction=function(R,I){var j,U,z,$,C;if(this.openCurrent(),R!=null&&(R=p(R)),I!=null&&(I=p(I)),Array.isArray(R))for(j=0,$=R.length;j<$;j++)U=R[j],this.instruction(U);else if(w(R))for(U in R)v.call(R,U)&&(z=R[U],this.instruction(U,z));else D(I)&&(I=I.apply()),C=new m(this,R,I),this.onData(this.writer.processingInstruction(C,this.writerOptions,this.currentLevel+1),this.currentLevel+1);return this},k.prototype.declaration=function(R,I,j){var U;if(this.openCurrent(),this.documentStarted)throw new Error("declaration() must be the first node.");return U=new c(this,R,I,j),this.onData(this.writer.declaration(U,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.doctype=function(R,I,j){if(this.openCurrent(),R==null)throw new Error("Missing root node name.");if(this.root)throw new Error("dtd() must come before the root node.");return this.currentNode=new l(this,I,j),this.currentNode.rootNodeName=R,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},k.prototype.dtdElement=function(R,I){var j;return this.openCurrent(),j=new o(this,R,I),this.onData(this.writer.dtdElement(j,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.attList=function(R,I,j,U,z){var $;return this.openCurrent(),$=new s(this,R,I,j,U,z),this.onData(this.writer.dtdAttList($,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.entity=function(R,I){var j;return this.openCurrent(),j=new a(this,!1,R,I),this.onData(this.writer.dtdEntity(j,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.pEntity=function(R,I){var j;return this.openCurrent(),j=new a(this,!0,R,I),this.onData(this.writer.dtdEntity(j,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.notation=function(R,I){var j;return this.openCurrent(),j=new u(this,R,I),this.onData(this.writer.dtdNotation(j,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},k.prototype.up=function(){if(this.currentLevel<0)throw new Error("The document node has no parent.");return this.currentNode?(this.currentNode.children?this.closeNode(this.currentNode):this.openNode(this.currentNode),this.currentNode=null):this.closeNode(this.openTags[this.currentLevel]),delete this.openTags[this.currentLevel],this.currentLevel--,this},k.prototype.end=function(){for(;this.currentLevel>=0;)this.up();return this.onEnd()},k.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},k.prototype.openNode=function(R){var I,j,U,z;if(!R.isOpen){if(!this.root&&this.currentLevel===0&&R.type===t.Element&&(this.root=R),j="",R.type===t.Element){this.writerOptions.state=e.OpenTag,j=this.writer.indent(R,this.writerOptions,this.currentLevel)+"<"+R.name,z=R.attribs;for(U in z)v.call(z,U)&&(I=z[U],j+=this.writer.attribute(I,this.writerOptions,this.currentLevel));j+=(R.children?">":"/>")+this.writer.endline(R,this.writerOptions,this.currentLevel),this.writerOptions.state=e.InsideTag}else this.writerOptions.state=e.OpenTag,j=this.writer.indent(R,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+R.rootNodeName,R.pubID&&R.sysID?j+=' PUBLIC "'+R.pubID+'" "'+R.sysID+'"':R.sysID&&(j+=' SYSTEM "'+R.sysID+'"'),R.children?(j+=" [",this.writerOptions.state=e.InsideTag):(this.writerOptions.state=e.CloseTag,j+=">"),j+=this.writer.endline(R,this.writerOptions,this.currentLevel);return this.onData(j,this.currentLevel),R.isOpen=!0}},k.prototype.closeNode=function(R){var I;if(!R.isClosed)return I="",this.writerOptions.state=e.CloseTag,R.type===t.Element?I=this.writer.indent(R,this.writerOptions,this.currentLevel)+"</"+R.name+">"+this.writer.endline(R,this.writerOptions,this.currentLevel):I=this.writer.indent(R,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(R,this.writerOptions,this.currentLevel),this.writerOptions.state=e.None,this.onData(I,this.currentLevel),R.isClosed=!0},k.prototype.onData=function(R,I){return this.documentStarted=!0,this.onDataCallback(R,I+1)},k.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},k.prototype.debugInfo=function(R){return R==null?"":"node: <"+R+">"},k.prototype.ele=function(){return this.element.apply(this,arguments)},k.prototype.nod=function(R,I,j){return this.node(R,I,j)},k.prototype.txt=function(R){return this.text(R)},k.prototype.dat=function(R){return this.cdata(R)},k.prototype.com=function(R){return this.comment(R)},k.prototype.ins=function(R,I){return this.instruction(R,I)},k.prototype.dec=function(R,I,j){return this.declaration(R,I,j)},k.prototype.dtd=function(R,I,j){return this.doctype(R,I,j)},k.prototype.e=function(R,I,j){return this.element(R,I,j)},k.prototype.n=function(R,I,j){return this.node(R,I,j)},k.prototype.t=function(R){return this.text(R)},k.prototype.d=function(R){return this.cdata(R)},k.prototype.c=function(R){return this.comment(R)},k.prototype.r=function(R){return this.raw(R)},k.prototype.i=function(R,I){return this.instruction(R,I)},k.prototype.att=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},k.prototype.a=function(){return this.currentNode&&this.currentNode.type===t.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},k.prototype.ent=function(R,I){return this.entity(R,I)},k.prototype.pent=function(R,I){return this.pEntity(R,I)},k.prototype.not=function(R,I){return this.notation(R,I)},k})()}).call(ON)});var PN=_((IN,FN)=>{(function(){var t,e,r,n,i=function(o,a){for(var u in a)s.call(a,u)&&(o[u]=a[u]);function c(){this.constructor=o}return c.prototype=a.prototype,o.prototype=new c,o.__super__=a.prototype,o},s={}.hasOwnProperty;t=_t(),n=mE(),e=Pc(),FN.exports=r=(function(o){i(a,o);function a(u,c){this.stream=u,a.__super__.constructor.call(this,c)}return a.prototype.endline=function(u,c,l){return u.isLastRootNode&&c.state===e.CloseTag?"":a.__super__.endline.call(this,u,c,l)},a.prototype.document=function(u,c){var l,h,d,f,m,y,E,S,A;for(E=u.children,h=d=0,m=E.length;d<m;h=++d)l=E[h],l.isLastRootNode=h===u.children.length-1;for(c=this.filterOptions(c),S=u.children,A=[],f=0,y=S.length;f<y;f++)l=S[f],A.push(this.writeChildNode(l,c,0));return A},a.prototype.attribute=function(u,c,l){return this.stream.write(a.__super__.attribute.call(this,u,c,l))},a.prototype.cdata=function(u,c,l){return this.stream.write(a.__super__.cdata.call(this,u,c,l))},a.prototype.comment=function(u,c,l){return this.stream.write(a.__super__.comment.call(this,u,c,l))},a.prototype.declaration=function(u,c,l){return this.stream.write(a.__super__.declaration.call(this,u,c,l))},a.prototype.docType=function(u,c,l){var h,d,f,m;if(l||(l=0),this.openNode(u,c,l),c.state=e.OpenTag,this.stream.write(this.indent(u,c,l)),this.stream.write("<!DOCTYPE "+u.root().name),u.pubID&&u.sysID?this.stream.write(' PUBLIC "'+u.pubID+'" "'+u.sysID+'"'):u.sysID&&this.stream.write(' SYSTEM "'+u.sysID+'"'),u.children.length>0){for(this.stream.write(" ["),this.stream.write(this.endline(u,c,l)),c.state=e.InsideTag,m=u.children,d=0,f=m.length;d<f;d++)h=m[d],this.writeChildNode(h,c,l+1);c.state=e.CloseTag,this.stream.write("]")}return c.state=e.CloseTag,this.stream.write(c.spaceBeforeSlash+">"),this.stream.write(this.endline(u,c,l)),c.state=e.None,this.closeNode(u,c,l)},a.prototype.element=function(u,c,l){var h,d,f,m,y,E,S,A,p,D;l||(l=0),this.openNode(u,c,l),c.state=e.OpenTag,this.stream.write(this.indent(u,c,l)+"<"+u.name),p=u.attribs;for(S in p)s.call(p,S)&&(h=p[S],this.attribute(h,c,l));if(f=u.children.length,m=f===0?null:u.children[0],f===0||u.children.every(function(w){return(w.type===t.Text||w.type===t.Raw)&&w.value===""}))c.allowEmpty?(this.stream.write(">"),c.state=e.CloseTag,this.stream.write("</"+u.name+">")):(c.state=e.CloseTag,this.stream.write(c.spaceBeforeSlash+"/>"));else if(c.pretty&&f===1&&(m.type===t.Text||m.type===t.Raw)&&m.value!=null)this.stream.write(">"),c.state=e.InsideTag,c.suppressPrettyCount++,A=!0,this.writeChildNode(m,c,l+1),c.suppressPrettyCount--,A=!1,c.state=e.CloseTag,this.stream.write("</"+u.name+">");else{for(this.stream.write(">"+this.endline(u,c,l)),c.state=e.InsideTag,D=u.children,y=0,E=D.length;y<E;y++)d=D[y],this.writeChildNode(d,c,l+1);c.state=e.CloseTag,this.stream.write(this.indent(u,c,l)+"</"+u.name+">")}return this.stream.write(this.endline(u,c,l)),c.state=e.None,this.closeNode(u,c,l)},a.prototype.processingInstruction=function(u,c,l){return this.stream.write(a.__super__.processingInstruction.call(this,u,c,l))},a.prototype.raw=function(u,c,l){return this.stream.write(a.__super__.raw.call(this,u,c,l))},a.prototype.text=function(u,c,l){return this.stream.write(a.__super__.text.call(this,u,c,l))},a.prototype.dtdAttList=function(u,c,l){return this.stream.write(a.__super__.dtdAttList.call(this,u,c,l))},a.prototype.dtdElement=function(u,c,l){return this.stream.write(a.__super__.dtdElement.call(this,u,c,l))},a.prototype.dtdEntity=function(u,c,l){return this.stream.write(a.__super__.dtdEntity.call(this,u,c,l))},a.prototype.dtdNotation=function(u,c,l){return this.stream.write(a.__super__.dtdNotation.call(this,u,c,l))},a})(n)}).call(IN)});var kN=_((RN,Wi)=>{(function(){var t,e,r,n,i,s,o,a,u,c;c=kn(),a=c.assign,u=c.isFunction,r=fE(),n=gE(),i=TN(),o=Gd(),s=PN(),t=_t(),e=Pc(),Wi.exports.create=function(l,h,d,f){var m,y;if(l==null)throw new Error("Root element needs a name.");return f=a({},h,d,f),m=new n(f),y=m.element(l),f.headless||(m.declaration(f),(f.pubID!=null||f.sysID!=null)&&m.dtd(f)),y},Wi.exports.begin=function(l,h,d){var f;return u(l)&&(f=[l,h],h=f[0],d=f[1],l={}),h?new i(l,h,d):new n(l)},Wi.exports.stringWriter=function(l){return new o(l)},Wi.exports.streamWriter=function(l,h){return new s(l,h)},Wi.exports.implementation=new r,Wi.exports.nodeType=t,Wi.exports.writerState=e}).call(RN)});var NN=_(yE=>{(function(){"use strict";var t,e,r,n,i,s={}.hasOwnProperty;t=kN(),e=Rd().defaults,n=function(o){return typeof o=="string"&&(o.indexOf("&")>=0||o.indexOf(">")>=0||o.indexOf("<")>=0)},i=function(o){return"<![CDATA["+r(o)+"]]>"},r=function(o){return o.replace("]]>","]]]]><![CDATA[>")},yE.Builder=(function(){function o(a){var u,c,l;this.options={},c=e["0.2"];for(u in c)s.call(c,u)&&(l=c[u],this.options[u]=l);for(u in a)s.call(a,u)&&(l=a[u],this.options[u]=l)}return o.prototype.buildObject=function(a){var u,c,l,h,d;return u=this.options.attrkey,c=this.options.charkey,Object.keys(a).length===1&&this.options.rootName===e["0.2"].rootName?(d=Object.keys(a)[0],a=a[d]):d=this.options.rootName,l=(function(f){return function(m,y){var E,S,A,p,D,w;if(typeof y!="object")f.options.cdata&&n(y)?m.raw(i(y)):m.txt(y);else if(Array.isArray(y)){for(p in y)if(s.call(y,p)){S=y[p];for(D in S)A=S[D],m=l(m.ele(D),A).up()}}else for(D in y)if(s.call(y,D))if(S=y[D],D===u){if(typeof S=="object")for(E in S)w=S[E],m=m.att(E,w)}else if(D===c)f.options.cdata&&n(S)?m=m.raw(i(S)):m=m.txt(S);else if(Array.isArray(S))for(p in S)s.call(S,p)&&(A=S[p],typeof A=="string"?f.options.cdata&&n(A)?m=m.ele(D).raw(i(A)).up():m=m.ele(D,A).up():m=l(m.ele(D),A).up());else typeof S=="object"?m=l(m.ele(D),S).up():typeof S=="string"&&f.options.cdata&&n(S)?m=m.ele(D).raw(i(S)).up():(S==null&&(S=""),m=m.ele(D,S.toString()).up());return m}})(this),h=t.create(d,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),l(h,a).end(this.options.renderOpts)},o})()}).call(yE)});var $N=_(Wd=>{(function(t){t.parser=function(x,O){return new r(x,O)},t.SAXParser=r,t.SAXStream=c,t.createStream=u,t.MAX_BUFFER_LENGTH=64*1024;var e=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];t.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function r(x,O){if(!(this instanceof r))return new r(x,O);var H=this;i(H),H.q=H.c="",H.bufferCheckPosition=t.MAX_BUFFER_LENGTH,H.opt=O||{},H.opt.lowercase=H.opt.lowercase||H.opt.lowercasetags,H.looseCase=H.opt.lowercase?"toLowerCase":"toUpperCase",H.tags=[],H.closed=H.closedRoot=H.sawRoot=!1,H.tag=H.error=null,H.strict=!!x,H.noscript=!!(x||H.opt.noscript),H.state=v.BEGIN,H.strictEntities=H.opt.strictEntities,H.ENTITIES=H.strictEntities?Object.create(t.XML_ENTITIES):Object.create(t.ENTITIES),H.attribList=[],H.opt.xmlns&&(H.ns=Object.create(m)),H.opt.unquotedAttributeValues===void 0&&(H.opt.unquotedAttributeValues=!x),H.trackPosition=H.opt.position!==!1,H.trackPosition&&(H.position=H.line=H.column=0),R(H,"onready")}Object.create||(Object.create=function(x){function O(){}O.prototype=x;var H=new O;return H}),Object.keys||(Object.keys=function(x){var O=[];for(var H in x)x.hasOwnProperty(H)&&O.push(H);return O});function n(x){for(var O=Math.max(t.MAX_BUFFER_LENGTH,10),H=0,N=0,ne=e.length;N<ne;N++){var K=x[e[N]].length;if(K>O)switch(e[N]){case"textNode":j(x);break;case"cdata":I(x,"oncdata",x.cdata),x.cdata="";break;case"script":I(x,"onscript",x.script),x.script="";break;default:z(x,"Max buffer length exceeded: "+e[N])}H=Math.max(H,K)}var ie=t.MAX_BUFFER_LENGTH-H;x.bufferCheckPosition=ie+x.position}function i(x){for(var O=0,H=e.length;O<H;O++)x[e[O]]=""}function s(x){j(x),x.cdata!==""&&(I(x,"oncdata",x.cdata),x.cdata=""),x.script!==""&&(I(x,"onscript",x.script),x.script="")}r.prototype={end:function(){$(this)},write:ae,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){s(this)}};var o;try{o=require("stream").Stream}catch{o=function(){}}o||(o=function(){});var a=t.EVENTS.filter(function(x){return x!=="error"&&x!=="end"});function u(x,O){return new c(x,O)}function c(x,O){if(!(this instanceof c))return new c(x,O);o.apply(this),this._parser=new r(x,O),this.writable=!0,this.readable=!0;var H=this;this._parser.onend=function(){H.emit("end")},this._parser.onerror=function(N){H.emit("error",N),H._parser.error=null},this._decoder=null,a.forEach(function(N){Object.defineProperty(H,"on"+N,{get:function(){return H._parser["on"+N]},set:function(ne){if(!ne)return H.removeAllListeners(N),H._parser["on"+N]=ne,ne;H.on(N,ne)},enumerable:!0,configurable:!1})})}c.prototype=Object.create(o.prototype,{constructor:{value:c}}),c.prototype.write=function(x){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(x)){if(!this._decoder){var O=require("string_decoder").StringDecoder;this._decoder=new O("utf8")}x=this._decoder.write(x)}return this._parser.write(x.toString()),this.emit("data",x),!0},c.prototype.end=function(x){return x&&x.length&&this.write(x),this._parser.end(),!0},c.prototype.on=function(x,O){var H=this;return!H._parser["on"+x]&&a.indexOf(x)!==-1&&(H._parser["on"+x]=function(){var N=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);N.splice(0,0,x),H.emit.apply(H,N)}),o.prototype.on.call(H,x,O)};var l="[CDATA[",h="DOCTYPE",d="http://www.w3.org/XML/1998/namespace",f="http://www.w3.org/2000/xmlns/",m={xml:d,xmlns:f},y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,E=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,S=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,A=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function p(x){return x===" "||x===`
|
|
186
186
|
`||x==="\r"||x===" "}function D(x){return x==='"'||x==="'"}function w(x){return x===">"||p(x)}function b(x,O){return x.test(O)}function P(x,O){return!b(x,O)}var v=0;t.STATE={BEGIN:v++,BEGIN_WHITESPACE:v++,TEXT:v++,TEXT_ENTITY:v++,OPEN_WAKA:v++,SGML_DECL:v++,SGML_DECL_QUOTED:v++,DOCTYPE:v++,DOCTYPE_QUOTED:v++,DOCTYPE_DTD:v++,DOCTYPE_DTD_QUOTED:v++,COMMENT_STARTING:v++,COMMENT:v++,COMMENT_ENDING:v++,COMMENT_ENDED:v++,CDATA:v++,CDATA_ENDING:v++,CDATA_ENDING_2:v++,PROC_INST:v++,PROC_INST_BODY:v++,PROC_INST_ENDING:v++,OPEN_TAG:v++,OPEN_TAG_SLASH:v++,ATTRIB:v++,ATTRIB_NAME:v++,ATTRIB_NAME_SAW_WHITE:v++,ATTRIB_VALUE:v++,ATTRIB_VALUE_QUOTED:v++,ATTRIB_VALUE_CLOSED:v++,ATTRIB_VALUE_UNQUOTED:v++,ATTRIB_VALUE_ENTITY_Q:v++,ATTRIB_VALUE_ENTITY_U:v++,CLOSE_TAG:v++,CLOSE_TAG_SAW_WHITE:v++,SCRIPT:v++,SCRIPT_ENDING:v++},t.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},t.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(t.ENTITIES).forEach(function(x){var O=t.ENTITIES[x],H=typeof O=="number"?String.fromCharCode(O):O;t.ENTITIES[x]=H});for(var k in t.STATE)t.STATE[t.STATE[k]]=k;v=t.STATE;function R(x,O,H){x[O]&&x[O](H)}function I(x,O,H){x.textNode&&j(x),R(x,O,H)}function j(x){x.textNode=U(x.opt,x.textNode),x.textNode&&R(x,"ontext",x.textNode),x.textNode=""}function U(x,O){return x.trim&&(O=O.trim()),x.normalize&&(O=O.replace(/\s+/g," ")),O}function z(x,O){return j(x),x.trackPosition&&(O+=`
|
|
@@ -280,7 +280,7 @@ ${Y.default.gray(fu)} ${t}
|
|
|
280
280
|
`);let w=0,b=0;f(),s=setInterval(()=>{if(n&&a===u)return;y(),u=a;let P=Y.default.magenta(e[w]);if(n)process.stdout.write(`${P} ${a}...`);else if(t==="timer")process.stdout.write(`${P} ${a} ${S(c)}`);else{let v=".".repeat(Math.floor(b)).slice(0,3);process.stdout.write(`${P} ${a}${v}`)}w=w+1<e.length?w+1:0,b=b<e.length?b+.125:0},r)},p=(D="",w=0)=>{o=!1,clearInterval(s),y();let b=w===0?Y.default.green(Tm):w===1?Y.default.red(n_):Y.default.red(i_);a=E(D??a),t==="timer"?process.stdout.write(`${b} ${a} ${S(c)}
|
|
281
281
|
`):process.stdout.write(`${b} ${a}
|
|
282
282
|
`),m(),i()};return{start:A,stop:p,message:(D="")=>{a=E(D??a)}}};function s_(t,e){let n=["normal","bold","dim","italic","underline","strikethrough"].indexOf(t),i="\x1B[";return i+n+"m"+e+i+"0m"}var Vt=class t{title=null;headers=[];rows=[];static narrowTheme={top:["\u2554","\u2550","\u2564","\u2557"],row:["\u2551"," ","\u2502","\u2551"],div:["\u255F","\u2500","\u253C","\u2562"],bot:["\u255A","\u2550","\u2567","\u255D"]};static wideTheme={top:["\u2554\u2550","\u2550","\u2550\u2564\u2550","\u2550\u2557"],row:["\u2551 "," "," \u2502 "," \u2551"],div:["\u255F\u2500","\u2500","\u2500\u253C\u2500","\u2500\u2562"],bot:["\u255A\u2550","\u2550","\u2550\u2567\u2550","\u2550\u255D"]};static roundTheme={top:["\u256D\u2500","\u2500","\u2500\u252C\u2500","\u2500\u256E"],row:["\u2502 "," "," \u2502 "," \u2502"],div:["\u251C\u2500","\u2500","\u2500\u253C\u2500","\u2500\u2524"],bot:["\u2570\u2500","\u2500","\u2500\u2534\u2500","\u2500\u256F"]};theme=t.wideTheme;columnWidth(){let e=[this.headers,...this.rows].filter(n=>n.length>0),r=e[0].map(n=>this.cast(n).length);for(let n of e.slice(1))for(let i=0;i<r.length;i++){let s=this.cast(n[i]).length;s>r[i]&&(r[i]=s)}return r}cast(e){return typeof e=="object"?"obj":e!==void 0&&typeof e.toString=="function"?e.toString():""}renderTitle(){return"[ "+this.title+" ]"}renderLine(e){let r=this.columnWidth();return e[0]+r.map(n=>e[1].repeat(n)).join(e[2])+e[3]}renderCell(e,r,n=!1){let i=this.cast(e),s=n?s_("bold",i):i,o=r-i.length,a=this.theme.row[1];switch(typeof e){case"number":return a.repeat(o)+s;case"string":return s+a.repeat(o);case"boolean":case"object":return a.repeat(Math.ceil(o/2))+s_("italic",i)+a.repeat(Math.floor(o/2));default:return a.repeat(o)}}renderRow(e,r=!1){let n=this.theme.row,i=this.columnWidth();return n[0]+e.map((s,o)=>this.renderCell(s,i[o],r)).join(n[2])+n[3]}toString(){let e=this.theme,r=this.headers.length>0,n=this.rows.length>0;return[this.title?this.renderTitle():"",r||n?this.renderLine(e.top):"",r?this.renderRow(this.headers,!0):"",r&&n?this.renderLine(e.div):"",...this.rows.map(i=>this.renderRow(i)),r||n?this.renderLine(e.bot):""].filter(i=>i.length>0).join(`
|
|
283
|
-
`)}};var VM=require("node:child_process"),Ye=require("node:fs"),Lp=require("node:os"),Xe=Ce(require("node:path")),jn=require("node:process"),ss=Ce(Il());var Zt=require("fs"),du=(t=".",e="unknown")=>{let r=`${t}/bun.lockb`,n=`${t}/bun.lock`,i=`${t}/pnpm-lock.yaml`,s=`${t}/shrinkwrap.yaml`,o=`${t}/yarn.lock`,a=`${t}/package-lock.json`,u=`${t}/npm-shrinkwrap.json`;return(0,Zt.existsSync)(r)||(0,Zt.existsSync)(n)?"bun":(0,Zt.existsSync)(i)||(0,Zt.existsSync)(s)?"pnpm":(0,Zt.existsSync)(o)?"yarn":(0,Zt.existsSync)(a)||(0,Zt.existsSync)(u)?"npm":e},Fl=(t=du(),e=!1)=>{switch(t){case"bun":return e?"bun install":"install";case"pnpm":return e?"pnpm install":"install";case"yarn":return e?"yarn install":"install";case"npm":return e?"npm install":"install";case"unknown":return e?"unknown unknown":"unknown";default:return e?"npm install":"install"}},o_=(t=".",e="npx")=>{let r=`${t}/bun.lockb`,n=`${t}/bun.lock`,i=`${t}/pnpm-lock.yaml`,s=`${t}/shrinkwrap.yaml`,o=`${t}/yarn.lock`,a=`${t}/package-lock.json`,u=`${t}/npm-shrinkwrap.json`;return(0,Zt.existsSync)(r)||(0,Zt.existsSync)(n)?"bunx":(0,Zt.existsSync)(i)||(0,Zt.existsSync)(s)?"pnpm exec":(0,Zt.existsSync)(o)?"yarn dlx":(0,Zt.existsSync)(a)||(0,Zt.existsSync)(u)?"npx":e};function Pl(t,e){if(isNaN(t)||isNaN(e))throw new Error("Cannot compare against non-numbers");return t===e?0:t<e?-1:1}function c_(t=[],e=[]){return t.length&&!e.length?-1:!t.length&&e.length?1:0}function km(t=[],e=[]){let r=Math.max(t.length,e.length);for(let n=0;n<r;n++){let i=t[n],s=e[n];if(i===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(i===void 0)return-1;if(typeof i=="string"&&typeof s=="number")return 1;if(typeof i=="number"&&typeof s=="string"||i<s)return-1;if(i>s)return 1}return 0}var vo="0|[1-9]\\d*",IU="\\d*[a-zA-Z-][a-zA-Z0-9-]*",FU=`(?<major>${vo})\\.(?<minor>${vo})\\.(?<patch>${vo})`,a_=`(?:${vo}|${IU})`,l_=`(?:-(?<prerelease>${a_}(?:\\.${a_})*))`,u_="[0-9A-Za-z-]+",f_=`(?:\\+(?<buildmetadata>${u_}(?:\\.${u_})*))`,h_=`v?${FU}${l_}?${f_}?`,d_=new RegExp(`^${h_}$`),p_="(?:<|>)?=?",PU="x|X|\\*",Rm=`${vo}|${PU}`,Rl=`[v=\\s]*(?<major>${Rm})(?:\\.(?<minor>${Rm})(?:\\.(?<patch>${Rm})${l_}?${f_}?)?)?`,m_=new RegExp(`^(?<operator>~>?|\\^|${p_})\\s*${Rl}$`),g_=new RegExp(`^(?<operator>${p_})\\s*(${h_})$|^$`);function Nm(t){return typeof t=="number"&&!Number.isNaN(t)&&(!Number.isFinite(t)||0<=t&&t<=Number.MAX_SAFE_INTEGER)}var $m=256;var RU=new RegExp(`^${vo}$`);function Qt(t){return t.split(".").filter(Boolean).map(e=>{if(RU.test(e)){let r=Number(e);if(Nm(r))return r}return e})}function en(t){return t.split(".").filter(Boolean)}function Ci(t,e){let r=Number(t);if(!Nm(r))throw new TypeError(e);return r}function Vn(t){return Number.isNaN(t.major)&&Number.isNaN(t.minor)&&Number.isNaN(t.patch)&&(t.prerelease===void 0||t.prerelease.length===0)&&(t.build===void 0||t.build.length===0)}function er(t,e){return t===e?0:Pl(t.major,e.major)||Pl(t.minor,e.minor)||Pl(t.patch,e.patch)||c_(t.prerelease,e.prerelease)||km(t.prerelease,e.prerelease)}function Lm(t){return t.toFixed(0)}function Si(t){let e=Lm(t.major),r=Lm(t.minor),n=Lm(t.patch),i=t.prerelease?.join(".")??"",s=t.build?.join(".")??"";return[[`${e}.${r}.${n}`,i].filter(u=>u).join("-"),s].filter(u=>u).join("+")}function kU(t,e){if(Vn(e))return!0;let r=er(t,e);switch(e.operator){case"=":case void 0:return r===0;case"!=":return r!==0;case">":return r>0;case"<":return r<0;case">=":return r>=0;case"<=":return r<=0}}function kl(t,e){for(let r of e)if(!kU(t,r))return!1;if(t.prerelease&&t.prerelease.length>0){for(let r of e){if(Vn(r))continue;let{major:n,minor:i,patch:s,prerelease:o}=r;if(o&&o.length>0&&t.major===n&&t.minor===i&&t.patch===s)return!0}return!1}return!0}function pu(t,e){return e.some(r=>kl(t,r))}function NU(t=[]){let e=[...t],r=e.length;for(;r>=0;){let n=e[r];if(typeof n=="number"){e[r]=n+1;break}r-=1}return r===-1&&e.push(0),e}function mu(t=[],e){let r=NU(t);if(!e)return r;let n=Qt(e);if(n.every(i=>typeof i=="string")){if(n.every((i,s)=>i===r[s])&&typeof r[n.length]=="number")return r;n=[...n,0]}return n}function y_(t,e,r={}){let n=r.build!==void 0?en(r.build):t.build??[];switch(e){case"premajor":return{major:t.major+1,minor:0,patch:0,prerelease:mu(t.prerelease,r.prerelease),build:n};case"preminor":return{major:t.major,minor:t.minor+1,patch:0,prerelease:mu(t.prerelease,r.prerelease),build:n};case"prepatch":return{major:t.major,minor:t.minor,patch:t.patch+1,prerelease:mu(t.prerelease,r.prerelease),build:n};case"prerelease":{let s=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:s,prerelease:mu(t.prerelease,r.prerelease),build:n}}case"major":return{major:(t.prerelease??[]).length===0||t.minor!==0||t.patch!==0?t.major+1:t.major,minor:0,patch:0,prerelease:[],build:n};case"minor":{let s=(t.prerelease??[]).length===0||t.patch!==0?t.minor+1:t.minor;return{major:t.major,minor:s,patch:0,prerelease:[],build:n}}case"patch":{let s=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:s,prerelease:[],build:n}}case"pre":return{major:t.major,minor:t.minor,patch:t.patch,prerelease:mu(t.prerelease,r.prerelease),build:n};default:throw new TypeError(`Cannot increment version: invalid argument ${e}`)}}var Nl={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},_o={operator:void 0,...Nl};function jm(t,e){return er(t,e)>0}function Bm(t,e){return er(t,e)<0}function $U(t){let r=t.match(g_)?.groups;if(!r)return null;let{operator:n,prerelease:i,buildmetadata:s}=r,o=r.major?{major:Ci(r.major,`Cannot parse comparator ${t}: invalid major version`),minor:Ci(r.minor,`Cannot parse comparator ${t}: invalid minor version`),patch:Ci(r.patch,`Cannot parse comparator ${t}: invalid patch version`),prerelease:i?Qt(i):[],build:s?en(s):[]}:Nl;return{operator:n||void 0,...o}}function Ue(t){return!t||t.toLowerCase()==="x"||t==="*"}function LU(t){if(!Ue(t.major))return Ue(t.minor)?{operator:">=",major:+t.major,minor:0,patch:0,prerelease:[],build:[]}:Ue(t.patch)?{operator:">=",major:+t.major,minor:+t.minor,patch:0,prerelease:[],build:[]}:{operator:">=",major:+t.major,minor:+t.minor,patch:+t.patch,prerelease:t.prerelease?Qt(t.prerelease):[],build:[]}}function jU(t){if(!Ue(t.major))return Ue(t.minor)?{operator:"<",major:+t.major+1,minor:0,patch:0,prerelease:[],build:[]}:Ue(t.patch)?{operator:"<",major:+t.major,minor:+t.minor+1,patch:0,prerelease:[],build:[]}:t.prerelease?{operator:"<=",major:+t.major,minor:+t.minor,patch:+t.patch,prerelease:Qt(t.prerelease),build:[]}:{operator:"<=",major:+t.major,minor:+t.minor,patch:+t.patch,prerelease:[],build:[]}}function BU(t){let e=t.match(new RegExp(`^${Rl}`)),r=e?.groups;if(!r)return null;let n=e[0].length,i=t.slice(n).match(/^\s+-\s+/);if(!i)return null;let s=i[0].length,a=t.slice(n+s).match(new RegExp(`^${Rl}\\s*$`))?.groups;if(!a)return null;let u=LU(r),c=jU(a);return[u,c].filter(Boolean)}function MU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return[{operator:">=",major:i,minor:0,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];if(n)return i===0?[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i,minor:s+1,patch:0}]:[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];let a=Qt(t.prerelease??"");return i===0?s===0?[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i,minor:s,patch:o+1}]:[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i,minor:s+1,patch:0}]:[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i+1,minor:0,patch:0}]}function qU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return[{operator:">=",major:i,minor:0,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i,minor:s+1,patch:0}];let a=Qt(t.prerelease??"");return[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i,minor:s+1,patch:0}]}function UU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return n?[{operator:"<",major:i,minor:0,patch:0}]:[{operator:"<",major:i,minor:0,patch:0}];if(n)return[{operator:"<",major:i,minor:s,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:"<",major:i,minor:s,patch:o,prerelease:a,build:u}]}function HU(t){let e=Ue(t.minor),r=Ue(t.patch),n=+t.major,i=+t.minor,s=+t.patch;if(e)return r?[{operator:"<",major:n+1,minor:0,patch:0}]:[{operator:"<",major:n,minor:i+1,patch:0}];if(r)return[{operator:"<",major:n,minor:i+1,patch:0}];let o=Qt(t.prerelease??""),a=en(t.build??"");return[{operator:"<=",major:n,minor:i,patch:s,prerelease:o,build:a}]}function VU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:i+1,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s+1,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:">",major:i,minor:s,patch:o,prerelease:a,build:u}]}function zU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return n?[{operator:">=",major:i,minor:0,patch:0}]:[{operator:">=",major:i,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:">=",major:i,minor:s,patch:o,prerelease:a,build:u}]}function KU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return[{operator:">=",major:i,minor:0,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i,minor:s+1,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:void 0,major:i,minor:s,patch:o,prerelease:a,build:u}]}function GU(t){let e=t.match(m_)?.groups;if(!e)return $U(t);switch(e.operator){case"^":return MU(e);case"~":case"~>":return qU(e);case"<":return UU(e);case"<=":return HU(e);case">":return VU(e);case">=":return zU(e);case"=":case"":return KU(e);default:throw new Error(`Cannot parse version range: '${e.operator}' is not a valid operator`)}}function WU(t){return t.split(/\s+/).flatMap(GU)}function $l(t){let e=t.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>BU(r)||WU(r));if(e.some(r=>r.includes(null)))throw new TypeError(`Cannot parse version range: range "${t}" is invalid`);return e}function At(t){if(typeof t!="string")throw new TypeError(`Cannot parse version as version must be a string: received ${typeof t}`);if(t.length>$m)throw new TypeError(`Cannot parse version as version length is too long: length is ${t.length}, max length is ${$m}`);t=t.trim();let e=t.match(d_)?.groups;if(!e)throw new TypeError(`Cannot parse version: ${t}`);let r=Ci(e.major,`Cannot parse version ${t}: invalid major version`),n=Ci(e.minor,`Cannot parse version ${t}: invalid minor version`),i=Ci(e.patch,`Cannot parse version ${t}: invalid patch version`),s=e.prerelease?Qt(e.prerelease):[],o=e.buildmetadata?en(e.buildmetadata):[];return{major:r,minor:n,patch:i,prerelease:s,build:o}}function D_(t,e){let r=t.operator,n=e.operator;if(r===void 0)return Vn(t)?!0:pu(t,[[e]]);if(n===void 0)return Vn(e)?!0:pu(e,[[t]]);let i=er(t,e);return(r===">="||r===">")&&(n===">="||n===">")||(r==="<="||r==="<")&&(n==="<="||n==="<")||i===0&&((r===">="||r==="<=")&&(n===">="||n==="<="))||i===-1&&(r===">="||r===">")&&(n==="<="||n==="<")||i===1&&(r==="<="||r==="<")&&(n===">="||n===">")}function XU(t){return t.every(e=>e.some(r=>YU(r)))}function YU(t){for(let e=0;e<t.length-1;e++){let r=t[e];for(let n of t.slice(e+1))if(!D_(r,n))return!1}return!0}function w_(t,e){return XU([t,e])&&t.some(r=>e.some(n=>r.every(i=>n.every(s=>D_(i,s)))))}function E_(t){try{return At(t),!0}catch{return!1}}function Ai(t,e){return er(t,e)>=0}var Xa=Ce(yS()),nv=Ce(eD()),zM=Ce(AA()),jp=Ce(Bh());var $i={name:"@capgo/cli",version:"7.36.0",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLI#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js",require:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && node build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs",test:"bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation"},devDependencies:{"@antfu/eslint-config":"^6.1.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.4","@capacitor/cli":"^7.4.4","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^0.11.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.6","@supabase/supabase-js":"^2.79.0","@types/adm-zip":"^0.5.7","@types/node":"^24.9.1","@types/prettyjson":"^0.0.33","@types/tmp":"^0.2.6","@vercel/ncc":"^0.38.4","adm-zip":"^0.5.16","ci-info":"^4.3.1",commander:"^14.0.2",esbuild:"^0.25.11",eslint:"^9.38.0","git-format-staged":"3.1.1",husky:"^9.1.7","is-wsl":"^3.1.0",open:"^10.1.2",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3"}};async function Mh(t){try{let r=`https://registry.npmjs.org/${encodeURIComponent(t.toLowerCase())}`,n=await fetch(r,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});return n.ok&&(await n.json())["dist-tags"]?.latest||null}catch{return null}}async function Ke(){let t=await Mh("@capgo/cli")??"",e=t?.split(".")[0];t!==$i.version&&g.warning(`\u{1F6A8} You are using @capgo/cli@${$i.version} it's not the latest version.
|
|
283
|
+
`)}};var VM=require("node:child_process"),Ye=require("node:fs"),Lp=require("node:os"),Xe=Ce(require("node:path")),jn=require("node:process"),ss=Ce(Il());var Zt=require("fs"),du=(t=".",e="unknown")=>{let r=`${t}/bun.lockb`,n=`${t}/bun.lock`,i=`${t}/pnpm-lock.yaml`,s=`${t}/shrinkwrap.yaml`,o=`${t}/yarn.lock`,a=`${t}/package-lock.json`,u=`${t}/npm-shrinkwrap.json`;return(0,Zt.existsSync)(r)||(0,Zt.existsSync)(n)?"bun":(0,Zt.existsSync)(i)||(0,Zt.existsSync)(s)?"pnpm":(0,Zt.existsSync)(o)?"yarn":(0,Zt.existsSync)(a)||(0,Zt.existsSync)(u)?"npm":e},Fl=(t=du(),e=!1)=>{switch(t){case"bun":return e?"bun install":"install";case"pnpm":return e?"pnpm install":"install";case"yarn":return e?"yarn install":"install";case"npm":return e?"npm install":"install";case"unknown":return e?"unknown unknown":"unknown";default:return e?"npm install":"install"}},o_=(t=".",e="npx")=>{let r=`${t}/bun.lockb`,n=`${t}/bun.lock`,i=`${t}/pnpm-lock.yaml`,s=`${t}/shrinkwrap.yaml`,o=`${t}/yarn.lock`,a=`${t}/package-lock.json`,u=`${t}/npm-shrinkwrap.json`;return(0,Zt.existsSync)(r)||(0,Zt.existsSync)(n)?"bunx":(0,Zt.existsSync)(i)||(0,Zt.existsSync)(s)?"pnpm exec":(0,Zt.existsSync)(o)?"yarn dlx":(0,Zt.existsSync)(a)||(0,Zt.existsSync)(u)?"npx":e};function Pl(t,e){if(isNaN(t)||isNaN(e))throw new Error("Cannot compare against non-numbers");return t===e?0:t<e?-1:1}function c_(t=[],e=[]){return t.length&&!e.length?-1:!t.length&&e.length?1:0}function km(t=[],e=[]){let r=Math.max(t.length,e.length);for(let n=0;n<r;n++){let i=t[n],s=e[n];if(i===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(i===void 0)return-1;if(typeof i=="string"&&typeof s=="number")return 1;if(typeof i=="number"&&typeof s=="string"||i<s)return-1;if(i>s)return 1}return 0}var vo="0|[1-9]\\d*",IU="\\d*[a-zA-Z-][a-zA-Z0-9-]*",FU=`(?<major>${vo})\\.(?<minor>${vo})\\.(?<patch>${vo})`,a_=`(?:${vo}|${IU})`,l_=`(?:-(?<prerelease>${a_}(?:\\.${a_})*))`,u_="[0-9A-Za-z-]+",f_=`(?:\\+(?<buildmetadata>${u_}(?:\\.${u_})*))`,h_=`v?${FU}${l_}?${f_}?`,d_=new RegExp(`^${h_}$`),p_="(?:<|>)?=?",PU="x|X|\\*",Rm=`${vo}|${PU}`,Rl=`[v=\\s]*(?<major>${Rm})(?:\\.(?<minor>${Rm})(?:\\.(?<patch>${Rm})${l_}?${f_}?)?)?`,m_=new RegExp(`^(?<operator>~>?|\\^|${p_})\\s*${Rl}$`),g_=new RegExp(`^(?<operator>${p_})\\s*(${h_})$|^$`);function Nm(t){return typeof t=="number"&&!Number.isNaN(t)&&(!Number.isFinite(t)||0<=t&&t<=Number.MAX_SAFE_INTEGER)}var $m=256;var RU=new RegExp(`^${vo}$`);function Qt(t){return t.split(".").filter(Boolean).map(e=>{if(RU.test(e)){let r=Number(e);if(Nm(r))return r}return e})}function en(t){return t.split(".").filter(Boolean)}function Ci(t,e){let r=Number(t);if(!Nm(r))throw new TypeError(e);return r}function Vn(t){return Number.isNaN(t.major)&&Number.isNaN(t.minor)&&Number.isNaN(t.patch)&&(t.prerelease===void 0||t.prerelease.length===0)&&(t.build===void 0||t.build.length===0)}function er(t,e){return t===e?0:Pl(t.major,e.major)||Pl(t.minor,e.minor)||Pl(t.patch,e.patch)||c_(t.prerelease,e.prerelease)||km(t.prerelease,e.prerelease)}function Lm(t){return t.toFixed(0)}function Si(t){let e=Lm(t.major),r=Lm(t.minor),n=Lm(t.patch),i=t.prerelease?.join(".")??"",s=t.build?.join(".")??"";return[[`${e}.${r}.${n}`,i].filter(u=>u).join("-"),s].filter(u=>u).join("+")}function kU(t,e){if(Vn(e))return!0;let r=er(t,e);switch(e.operator){case"=":case void 0:return r===0;case"!=":return r!==0;case">":return r>0;case"<":return r<0;case">=":return r>=0;case"<=":return r<=0}}function kl(t,e){for(let r of e)if(!kU(t,r))return!1;if(t.prerelease&&t.prerelease.length>0){for(let r of e){if(Vn(r))continue;let{major:n,minor:i,patch:s,prerelease:o}=r;if(o&&o.length>0&&t.major===n&&t.minor===i&&t.patch===s)return!0}return!1}return!0}function pu(t,e){return e.some(r=>kl(t,r))}function NU(t=[]){let e=[...t],r=e.length;for(;r>=0;){let n=e[r];if(typeof n=="number"){e[r]=n+1;break}r-=1}return r===-1&&e.push(0),e}function mu(t=[],e){let r=NU(t);if(!e)return r;let n=Qt(e);if(n.every(i=>typeof i=="string")){if(n.every((i,s)=>i===r[s])&&typeof r[n.length]=="number")return r;n=[...n,0]}return n}function y_(t,e,r={}){let n=r.build!==void 0?en(r.build):t.build??[];switch(e){case"premajor":return{major:t.major+1,minor:0,patch:0,prerelease:mu(t.prerelease,r.prerelease),build:n};case"preminor":return{major:t.major,minor:t.minor+1,patch:0,prerelease:mu(t.prerelease,r.prerelease),build:n};case"prepatch":return{major:t.major,minor:t.minor,patch:t.patch+1,prerelease:mu(t.prerelease,r.prerelease),build:n};case"prerelease":{let s=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:s,prerelease:mu(t.prerelease,r.prerelease),build:n}}case"major":return{major:(t.prerelease??[]).length===0||t.minor!==0||t.patch!==0?t.major+1:t.major,minor:0,patch:0,prerelease:[],build:n};case"minor":{let s=(t.prerelease??[]).length===0||t.patch!==0?t.minor+1:t.minor;return{major:t.major,minor:s,patch:0,prerelease:[],build:n}}case"patch":{let s=(t.prerelease??[]).length===0?t.patch+1:t.patch;return{major:t.major,minor:t.minor,patch:s,prerelease:[],build:n}}case"pre":return{major:t.major,minor:t.minor,patch:t.patch,prerelease:mu(t.prerelease,r.prerelease),build:n};default:throw new TypeError(`Cannot increment version: invalid argument ${e}`)}}var Nl={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},_o={operator:void 0,...Nl};function jm(t,e){return er(t,e)>0}function Bm(t,e){return er(t,e)<0}function $U(t){let r=t.match(g_)?.groups;if(!r)return null;let{operator:n,prerelease:i,buildmetadata:s}=r,o=r.major?{major:Ci(r.major,`Cannot parse comparator ${t}: invalid major version`),minor:Ci(r.minor,`Cannot parse comparator ${t}: invalid minor version`),patch:Ci(r.patch,`Cannot parse comparator ${t}: invalid patch version`),prerelease:i?Qt(i):[],build:s?en(s):[]}:Nl;return{operator:n||void 0,...o}}function Ue(t){return!t||t.toLowerCase()==="x"||t==="*"}function LU(t){if(!Ue(t.major))return Ue(t.minor)?{operator:">=",major:+t.major,minor:0,patch:0,prerelease:[],build:[]}:Ue(t.patch)?{operator:">=",major:+t.major,minor:+t.minor,patch:0,prerelease:[],build:[]}:{operator:">=",major:+t.major,minor:+t.minor,patch:+t.patch,prerelease:t.prerelease?Qt(t.prerelease):[],build:[]}}function jU(t){if(!Ue(t.major))return Ue(t.minor)?{operator:"<",major:+t.major+1,minor:0,patch:0,prerelease:[],build:[]}:Ue(t.patch)?{operator:"<",major:+t.major,minor:+t.minor+1,patch:0,prerelease:[],build:[]}:t.prerelease?{operator:"<=",major:+t.major,minor:+t.minor,patch:+t.patch,prerelease:Qt(t.prerelease),build:[]}:{operator:"<=",major:+t.major,minor:+t.minor,patch:+t.patch,prerelease:[],build:[]}}function BU(t){let e=t.match(new RegExp(`^${Rl}`)),r=e?.groups;if(!r)return null;let n=e[0].length,i=t.slice(n).match(/^\s+-\s+/);if(!i)return null;let s=i[0].length,a=t.slice(n+s).match(new RegExp(`^${Rl}\\s*$`))?.groups;if(!a)return null;let u=LU(r),c=jU(a);return[u,c].filter(Boolean)}function MU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return[{operator:">=",major:i,minor:0,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];if(n)return i===0?[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i,minor:s+1,patch:0}]:[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];let a=Qt(t.prerelease??"");return i===0?s===0?[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i,minor:s,patch:o+1}]:[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i,minor:s+1,patch:0}]:[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i+1,minor:0,patch:0}]}function qU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return[{operator:">=",major:i,minor:0,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i,minor:s+1,patch:0}];let a=Qt(t.prerelease??"");return[{operator:">=",major:i,minor:s,patch:o,prerelease:a},{operator:"<",major:i,minor:s+1,patch:0}]}function UU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return n?[{operator:"<",major:i,minor:0,patch:0}]:[{operator:"<",major:i,minor:0,patch:0}];if(n)return[{operator:"<",major:i,minor:s,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:"<",major:i,minor:s,patch:o,prerelease:a,build:u}]}function HU(t){let e=Ue(t.minor),r=Ue(t.patch),n=+t.major,i=+t.minor,s=+t.patch;if(e)return r?[{operator:"<",major:n+1,minor:0,patch:0}]:[{operator:"<",major:n,minor:i+1,patch:0}];if(r)return[{operator:"<",major:n,minor:i+1,patch:0}];let o=Qt(t.prerelease??""),a=en(t.build??"");return[{operator:"<=",major:n,minor:i,patch:s,prerelease:o,build:a}]}function VU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:i+1,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s+1,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:">",major:i,minor:s,patch:o,prerelease:a,build:u}]}function zU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return n?[{operator:">=",major:i,minor:0,patch:0}]:[{operator:">=",major:i,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:">=",major:i,minor:s,patch:o,prerelease:a,build:u}]}function KU(t){let e=Ue(t.major),r=Ue(t.minor),n=Ue(t.patch),i=+t.major,s=+t.minor,o=+t.patch;if(e)return[_o];if(r)return[{operator:">=",major:i,minor:0,patch:0},{operator:"<",major:i+1,minor:0,patch:0}];if(n)return[{operator:">=",major:i,minor:s,patch:0},{operator:"<",major:i,minor:s+1,patch:0}];let a=Qt(t.prerelease??""),u=en(t.build??"");return[{operator:void 0,major:i,minor:s,patch:o,prerelease:a,build:u}]}function GU(t){let e=t.match(m_)?.groups;if(!e)return $U(t);switch(e.operator){case"^":return MU(e);case"~":case"~>":return qU(e);case"<":return UU(e);case"<=":return HU(e);case">":return VU(e);case">=":return zU(e);case"=":case"":return KU(e);default:throw new Error(`Cannot parse version range: '${e.operator}' is not a valid operator`)}}function WU(t){return t.split(/\s+/).flatMap(GU)}function $l(t){let e=t.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>BU(r)||WU(r));if(e.some(r=>r.includes(null)))throw new TypeError(`Cannot parse version range: range "${t}" is invalid`);return e}function At(t){if(typeof t!="string")throw new TypeError(`Cannot parse version as version must be a string: received ${typeof t}`);if(t.length>$m)throw new TypeError(`Cannot parse version as version length is too long: length is ${t.length}, max length is ${$m}`);t=t.trim();let e=t.match(d_)?.groups;if(!e)throw new TypeError(`Cannot parse version: ${t}`);let r=Ci(e.major,`Cannot parse version ${t}: invalid major version`),n=Ci(e.minor,`Cannot parse version ${t}: invalid minor version`),i=Ci(e.patch,`Cannot parse version ${t}: invalid patch version`),s=e.prerelease?Qt(e.prerelease):[],o=e.buildmetadata?en(e.buildmetadata):[];return{major:r,minor:n,patch:i,prerelease:s,build:o}}function D_(t,e){let r=t.operator,n=e.operator;if(r===void 0)return Vn(t)?!0:pu(t,[[e]]);if(n===void 0)return Vn(e)?!0:pu(e,[[t]]);let i=er(t,e);return(r===">="||r===">")&&(n===">="||n===">")||(r==="<="||r==="<")&&(n==="<="||n==="<")||i===0&&((r===">="||r==="<=")&&(n===">="||n==="<="))||i===-1&&(r===">="||r===">")&&(n==="<="||n==="<")||i===1&&(r==="<="||r==="<")&&(n===">="||n===">")}function XU(t){return t.every(e=>e.some(r=>YU(r)))}function YU(t){for(let e=0;e<t.length-1;e++){let r=t[e];for(let n of t.slice(e+1))if(!D_(r,n))return!1}return!0}function w_(t,e){return XU([t,e])&&t.some(r=>e.some(n=>r.every(i=>n.every(s=>D_(i,s)))))}function E_(t){try{return At(t),!0}catch{return!1}}function Ai(t,e){return er(t,e)>=0}var Xa=Ce(yS()),nv=Ce(eD()),zM=Ce(AA()),jp=Ce(Bh());var $i={name:"@capgo/cli",version:"7.37.0",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/CLI#readme",repository:{type:"git",url:"git+https://github.com/Cap-go/CLI.git"},bugs:{url:"https://github.com/Cap-go/CLI/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js",require:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && node build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",types:"npx --yes supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsc --noEmit",lint:'eslint "src/**/*.ts" --fix',"check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:bundle":"bun test/test-bundle.mjs","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs",test:"bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation"},devDependencies:{"@antfu/eslint-config":"^6.1.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.4","@capacitor/cli":"^7.4.4","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^0.11.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.6","@supabase/supabase-js":"^2.79.0","@types/adm-zip":"^0.5.7","@types/node":"^24.9.1","@types/prettyjson":"^0.0.33","@types/tmp":"^0.2.6","@vercel/ncc":"^0.38.4","adm-zip":"^0.5.16","ci-info":"^4.3.1",commander:"^14.0.2",esbuild:"^0.25.11",eslint:"^9.38.0","git-format-staged":"3.1.1",husky:"^9.1.7","is-wsl":"^3.1.0",open:"^10.1.2",prettyjson:"^1.2.5",tmp:"^0.2.5","tus-js-client":"^4.3.1",typescript:"^5.9.3"}};async function Mh(t){try{let r=`https://registry.npmjs.org/${encodeURIComponent(t.toLowerCase())}`,n=await fetch(r,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});return n.ok&&(await n.json())["dist-tags"]?.latest||null}catch{return null}}async function Ke(){let t=await Mh("@capgo/cli")??"",e=t?.split(".")[0];t!==$i.version&&g.warning(`\u{1F6A8} You are using @capgo/cli@${$i.version} it's not the latest version.
|
|
284
284
|
Please use @capgo/cli@${t}" or @capgo/cli@${e} to keep up to date with the latest features and bug fixes.`)}async function jT(t,e,r,n,i,s="\u2705"){await ve(r,{channel:t,event:n,icon:s,user_id:e,...i?{tags:{"app-id":i}}:{},notify:!1})}var d0=require("node:buffer"),BT=require("node:crypto"),sY=(()=>{let t=[];for(let e=0;e<256;e++){let r=e;for(let n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;t[e]=r}return t})();function oY(t){let e=4294967295;for(let r=0;r<t.length;r++){let n=t[r];e=sY[(e^n)&255]^e>>>8}return e=e^4294967295,(e>>>0).toString(16).padStart(8,"0")}async function Qn(t,e="sha256"){let r=d0.Buffer.isBuffer(t)?t:d0.Buffer.from(t);if(e==="crc32")return oY(r);let n=(0,BT.createHash)(e);return n.update(r),n.digest("hex")}var tl=Ce(uM());async function cM(){let t=await(0,tl.loadConfig)();return{config:t.app.extConfig,path:t.app.extConfigFilePath}}async function kb(t,e,r=!1){let n=await(0,tl.loadConfig)(),{extConfig:i}=n.app;i&&(i.plugins||(i.plugins={extConfig:{},[t]:{}}),i.plugins[t]||(i.plugins[t]={}),r?i=e.config:i.plugins[t]=e.config.plugins?.[t],(0,tl.writeConfig)(i,n.app.extConfigFilePath))}async function za(t,e=!1){await kb("CapacitorUpdater",t,e)}var Ya=".capgo_key",Rr=".capgo_key_v2",Bp=`${Ya}.pub`,mi=`${Rr}.pub`,jM="https://capgo.app",BM="https://files.capgo.app",MM="https://api.capgo.app",qM="https://console.capgo.app",iv=12e4,Cle=1024*1024*20,Sle=1024*1024*1024,Ale=1024*1024*99,Mp="package.json",Ja=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*))?(?:\+([0-9a-z-]+(?:\.[0-9a-z-]+)*))?$/i,W=t=>t?`
|
|
285
285
|
${zM.default.render(t)}`:"";function $p(t){return new Promise(e=>{setTimeout(e,t)})}function Jr(t){return(0,ss.isMonorepo)(t)?(0,ss.findMonorepoRoot)(t):(0,ss.isNXMonorepo)(t)?(0,ss.findNXMonorepoRoot)(t):t}function Ole(t=Jr((0,jn.cwd)()),e=void 0){let r=e?.split(",")[0];if(r&&!(0,Ye.existsSync)(r)){let i=`Package.json at ${r} does not exist`;throw g.error(i),new Error(i)}let n=(0,Ye.readFileSync)(r??(0,Xe.join)(t,Mp));return JSON.parse(n)}function os(t=Jr((0,jn.cwd)()),e=void 0){return Ole(t,e).version??""}function UM(t){let e=t.replace("^","").replace("~","");if(E_(e))try{let r=At(e);return Si(r)}catch{return e}return e}async function oo(t,e=(0,jn.cwd)(),r){if(t!=="@capgo/capacitor-updater")return null;if(r)try{let o=(await sl(e,r)).get(t);if(o)return o}catch{}let n=null,i=(0,Xe.join)(e,"ios","App","Podfile");if((0,Ye.existsSync)(i))try{let o=(0,Ye.readFileSync)(i,"utf-8").match(/pod\s+['"]CapgoCapacitorUpdater['"],\s*:path\s*=>\s*['"]([^'"]+)['"]/);o?.[1]&&(n=(0,Xe.resolve)((0,Xe.join)(e,"ios","App",o[1])))}catch{}if(!n){let s=(0,Xe.join)(e,"android","capacitor.settings.gradle");if((0,Ye.existsSync)(s))try{let a=(0,Ye.readFileSync)(s,"utf-8").match(/project\(':capgo-capacitor-updater'\)\.projectDir\s*=\s*new\s+File\(['"]([^'"]+)['"]/);a?.[1]&&(n=(0,Xe.resolve)((0,Xe.join)(e,"android",a[1])).replace(/\/android$/,""))}catch{}}if(n){let s=(0,Xe.join)(n,Mp);if((0,Ye.existsSync)(s))try{let o=JSON.parse((0,Ye.readFileSync)(s,"utf-8"));if(o.version)return o.version}catch{}}try{let o=(await sl(e)).get(t);if(o)return o}catch{}return null}async function sl(t=Jr((0,jn.cwd)()),e=void 0){let r=e?.split(",");if(r??=[(0,Xe.join)(t,Mp)],r){for(let i of r)if(!(0,Ye.existsSync)(i)){let s=`Package.json at ${i} does not exist`;throw g.error(s),new Error(s)}}let n=new Map;for(let i of r){let s=(0,Ye.readFileSync)(i),o=JSON.parse(s);for(let a in o.dependencies)n.set(a,UM(o.dependencies[a]));for(let a in o.devDependencies)n.set(a,UM(o.devDependencies[a]))}return n}async function de(){try{let t=await cM();if(!t){let e="No capacitor config file found, run `cap init` first";throw g.error(e),new Error(e)}return t}catch(t){let e=`No capacitor config file found, run \`cap init\` first ${W(t)}`;throw g.error(e),new Error(e)}}async function xle(t,e){let r=await de();return r?.config&&(r.config.plugins??={},r.config.plugins.extConfig??={},r.config.plugins[t]??={},r.config.plugins[t]={...r.config.plugins[t],...e},await kb(t,r)),r}async function KM(t){return xle("CapacitorUpdater",t)}async function vn(){try{let t=await de(),e={host:t?.config?.plugins?.CapacitorUpdater?.localHost||jM,hostWeb:t?.config?.plugins?.CapacitorUpdater?.localWebHost||qM,hostFilesApi:t?.config?.plugins?.CapacitorUpdater?.localApiFiles||BM,hostApi:t?.config?.plugins?.CapacitorUpdater?.localApi||MM};return t?.config?.plugins?.CapacitorUpdater?.localSupa&&t?.config?.plugins?.CapacitorUpdater?.localSupaAnon&&(g.info("Using custom supabase instance from capacitor.config.json"),e.supaKey=t?.config?.plugins?.CapacitorUpdater?.localSupaAnon,e.supaHost=t?.config?.plugins?.CapacitorUpdater?.localSupa),e}catch{return{host:jM,hostWeb:qM,hostFilesApi:BM,hostApi:MM}}}var Tle=/([A-Za-z0-9]+)\.(java|swift|kt|scala)$/;async function qp(){let t=await vn();try{let e=await fetch(`${t.hostApi}/private/config`);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return{...await e.json(),...t}}catch{return g.info(`Local config ${W(t)}`),t}}async function GM(){let t=await vn();try{let e=await fetch(`${t.hostFilesApi}/files/config`);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return await e.json()}catch{return{partialUpload:!1,TUSUpload:!1,partialUploadForced:!1,TUSUploadForced:!1,maxUploadLength:Sle,maxChunkSize:Ale,alertUploadSize:Cle}}}async function pe(t,e,r){let n=await qp();if(e&&r&&(g.info("Using custom supabase instance from provided options"),n.supaHost=e,n.supaKey=r),!n.supaHost||!n.supaKey)throw g.error("Cannot connect to server please try again later"),new Error("Cannot connect to server please try again later");return(0,Xa.createClient)(n.supaHost,n.supaKey,{auth:{persistSession:!1},global:{headers:{capgkey:t}}})}async function Ile(t,e,r){let{data:n}=await t.rpc("is_allowed_capgkey",{apikey:e,keymode:r}).single();if(!n){g.error("Invalid API key or insufficient permissions.");let s=`Your key should be: ${r.map((o,a)=>r.length===1?`"${o}"`:a===r.length-1?`or "${o}"`:`"${o}", `).join("")} mode.`;throw g.error(s),new Error("Invalid API key or insufficient permissions.")}}async function WM(t,e){let{data:r}=await t.rpc("is_paying_org",{orgid:e}).single();return r||!1}async function XM(t,e){let{data:r}=await t.rpc("is_trial_org",{orgid:e}).single();return r||0}async function Fle(t,e){let{data:r}=await t.rpc("is_allowed_action_org",{orgid:e}).single();return!!r}async function Ple(t,e,r){let{data:n}=await t.rpc("is_allowed_action",{apikey:r,appid:e}).single();return!!n}var hr=(o=>(o[o.none=0]="none",o[o.read=1]="read",o[o.upload=2]="upload",o[o.write=3]="write",o[o.admin=4]="admin",o[o.super_admin=5]="super_admin",o))(hr||{}),Za=(t,e)=>t>=e;async function YM(t,e,r){let{data:n,error:i}=await t.rpc("get_org_perm_for_apikey",{apikey:e,app_id:r}).single();if(i)throw g.error("Cannot get permissions for organization!"),console.error(i),new Error("Cannot get permissions for organization");if(n.includes("perm")){let a=null;switch(n){case"perm_none":{a=0;break}case"perm_read":{a=1;break}case"perm_upload":{a=2;break}case"perm_write":{a=3;break}case"perm_admin":{a=4;break}case"perm_owner":{a=5;break}default:throw n.includes("invite")?(g.info("Please accept/deny the organization invitation before trying to access the app"),new Error("Organization invitation pending")):(g.error(`Invalid output when fetching organization permission. Response: ${n}`),new Error(`Invalid output when fetching organization permission. Response: ${n}`))}return{okay:!0,data:a}}let o=null;switch(n){case"INVALID_APIKEY":{o="INVALID_APIKEY";break}case"NO_APP":{o="NO_APP";break}case"NO_ORG":{o="NO_ORG";break}default:throw g.error(`Invalid error when fetching organization permission. Response: ${n}`),new Error(`Invalid error when fetching organization permission. Response: ${n}`)}return{okay:!1,error:o}}async function JM(t,e,r){let{data:n,error:i}=await t.rpc("get_organization_cli_warnings",{orgid:e,cli_version:r});if(i){g.error(`Cannot get cli warnings: ${W(i)}`);return}if(n.length>0){g.warn(`Found ${n.length} cli warnings for your organization.`);let s=null;for(let o of n){if(typeof o!="object"||typeof o.message!="string"||typeof o.fatal!="boolean"){g.error(`Invalid cli warning: ${o}`);continue}let a=o;a.fatal?(g.error(`${a.message.replaceAll("\\n",`
|
|
286
286
|
`)}`),s=new Error(a.message)):g.warn(`${a.message.replaceAll("\\n",`
|
|
@@ -317,7 +317,7 @@ ${W(s)}`),new Error(`Cannot retrieve unknown version for app ${e}: ${W(s)}`)}fun
|
|
|
317
317
|
app_id,
|
|
318
318
|
version (id, name)
|
|
319
319
|
`).eq("app_id",e).order("created_at",{ascending:!1});if(i)throw r||g.error(`App ${e} not found in database`),new Error(`App ${e} not found in database: ${W(i)}`);return n}async function cv(t,e,r,n={}){let{silent:i=!1}=n,{error:s}=await t.from("app_versions").update({deleted:!0}).eq("app_id",e).eq("deleted",!1).eq("name",r);if(s){let o=`App version ${e}@${r} not found in database`;throw i||g.error(o),new Error(`${o}: ${W(s)}`)}}async function Kp(t,e,r,n={}){let{silent:i=!1,autoUnlink:s=!1}=n,o=await Lle(t,e,r,{silent:i});await c8(t,e,o,{silent:i,autoUnlink:s}),await cv(t,e,r,{silent:i})}function y8(t,e=!1){if(e)return;if(!t.length)throw new Error("No bundle found");let r=new Vt;r.theme=Vt.roundTheme,r.headers=["Version","Created","Keep"],r.rows=[];for(let n of t.toReversed())r.rows.push([n.name,eu(n.created_at),n.keep??""]);g.success("Bundles"),g.success(r.toString())}async function Gp(t,e,r={}){let{silent:n=!1}=r,{data:i,error:s}=await t.from("app_versions").select().eq("app_id",e).eq("deleted",!1).order("created_at",{ascending:!1});if(s){let o=`App ${e} not found in database`;throw n||g.error(o),new Error(`${o}: ${W(s)}`)}return i??[]}async function D8(t,e,r={}){let{silent:n=!1}=r,{data:i,error:s}=await t.from("channels").select("version").eq("app_id",e);if(s){let o=`App ${e} not found in database`;throw n||g.error(o),new Error(`${o}: ${W(s)}`)}return(i??[]).map(o=>o.version)}async function Lle(t,e,r,n={}){let{silent:i=!1}=n,{data:s,error:o}=await t.from("app_versions").select().eq("app_id",e).eq("name",r).eq("deleted",!1).single();if(!s||o){let a=`App version ${e}@${r} doesn't exist`;throw i||g.error(a),new Error(`${a}${o?`: ${W(o)}`:""}`)}return s}var tu=require("node:fs");async function w8(t,e){let{data:r}=await t.rpc("exist_app_v2",{appid:e}).single();return!!r}async function Dt(t,e,r,n,i=!1){let s=Bn(),o=await YM(t,e,r);if(!o.okay)switch(o.error){case"INVALID_APIKEY":{let c="Invalid apikey, such apikey does not exists!";throw i||g.error(c),new Error(c)}case"NO_APP":{let c=`App ${r} does not exist, run first \`${s.runner} @capgo/cli app add ${r}\` to create it`;throw i||g.error(c),new Error(c)}case"NO_ORG":{let c="Could not find organization, please contact support to resolve this!";throw i||g.error(c),new Error(c)}}let a=o.data;if(n>a){let c=`Insuficcent permissions for app ${r}. Current permission: ${hr[o.data]}, required for this action: ${hr[n]}.`;throw i||g.error(c),new Error(c)}return o.data}var Zr="assets/icon.png";var jle=/^[a-z0-9]+(\.[\w-]+)+$/i;function Ble(t,e,r){if(!e.apikey)throw r||g.error("Missing API key, you need to provide an API key to upload your bundle"),new Error("Missing API key");if(!t)throw r||g.error("Missing argument, you need to provide a appId, or be in a capacitor project"),new Error("Missing appId");if(t.includes("--"))throw r||g.error('The app id includes illegal symbols. You cannot use "--" in the app id'),new Error("App id includes illegal symbols");if(!jle.test(t))throw r||(g.error(`Invalid app ID format: "${t}"`),g.info("App ID must be in reverse domain notation (e.g., com.example.app)"),g.info("Valid format: lowercase letters, numbers, dots, hyphens, and underscores"),g.info("Examples: com.mycompany.myapp, io.capgo.app, com.example.my-app")),new Error("Invalid app ID format")}async function Mle(t,e,r){if(await w8(t,e))throw e==="io.ionic.starter"?(r||g.error(`This appId ${e} cannot be used it's reserved, please change it in your capacitor config.`),new Error("Reserved appId, please change it in capacitor config")):(r||g.error(`App ${e} already exist`),new Error(`App ${e} already exists`))}async function E8(t,e,r,n=!1){n||oe("Adding"),await Ke(),e.apikey=e.apikey||te();let i=await de(),s=Re(t,i?.config);Ble(s,e,n);let o=await pe(e.apikey,e.supaHost,e.supaAnon),a=await De(o,e.apikey,["write","all"]);await Mle(o,s,n),r||(r=await Vp(o,["admin","super_admin"]));let u=r.gid,{name:c,icon:l}=e;if(c=c||i.config?.appName||"Unknown",l=l||"resources/icon.png",!l||!c)throw n||g.error("Missing argument, you need to provide a appId and a name, or be in a capacitor project"),new Error("Missing app name or icon path");n||g.info(`Adding ${s} to Capgo`);let h=null,d=null;l&&(0,tu.existsSync)(l)?(h=(0,tu.readFileSync)(l),d=Qa(l)||"image/png",n||g.warn(`Found app icon ${l}`)):(0,tu.existsSync)(Zr)?(h=(0,tu.readFileSync)(Zr),d=Qa(Zr)||"image/png",n||g.warn(`Found app icon ${Zr}`)):n||g.warn(`Cannot find app icon in any of the following locations: ${l}, ${Zr}`);let f="icon",m="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(h&&d){let{error:E}=await o.storage.from(`images/org/${u}/${s}`).upload(f,h,{contentType:d});if(E)throw n||console.error(E),n||g.error(`Could not add app ${W(E)}`),new Error(`Could not add app ${W(E)}`);let{data:S}=await o.storage.from(`images/org/${u}/${s}`).getPublicUrl(f);m=S?.publicUrl||m}let{error:y}=await o.from("apps").insert({icon_url:m,owner_org:u,user_id:a,name:c,app_id:s});if(y)throw n||g.error(`Could not add app ${W(y)}`),new Error(`Could not add app ${W(y)}`);return n||(g.success(`App ${s} added to Capgo. You can upload a bundle now`),ce("Done \u2705")),{appId:s,organizationUid:u,userId:a,name:c,signedURL:m}}async function b8(t,e,r=!1,n=!1){r||oe("Deleting"),e.apikey=e.apikey||te();let i=await de(),s=Re(t,i?.config);if(!e.apikey)throw r||g.error("Missing API key, you need to provide an API key to upload your bundle"),new Error("Missing API key");if(!s)throw r||g.error("Missing argument, you need to provide a appId, or be in a capacitor project"),new Error("Missing appId");let o=await pe(e.apikey,e.supaHost,e.supaAnon),a=await De(o,e.apikey,["write","all"]);await Dt(o,e.apikey,s,5,r);let{data:u,error:c}=await o.from("apps").select("owner_org ( created_by, id )").eq("app_id",s).single(),l=u;if(!n&&!c&&(l?.owner_org.created_by??"")!==a){if(r)throw new Error("Cannot delete app: you are not the organization owner");{g.warn("Deleting the app is not recommended for users that are not the organization owner"),g.warn("You are invited as a super_admin but your are not the owner"),g.warn("It's strongly recommended that you do not continue!");let y=await bo({message:"Do you want to continue?",options:[{label:"Yes",value:"yes"},{label:"No",value:"no"}]});if(It(y)||y==="no")throw g.error("Canceled deleting the app, exiting"),new Error("App deletion cancelled")}}else c&&!r&&g.warn(`Cannot get the app owner ${W(c)}`);let{error:h}=await o.storage.from("images").remove([`org/${l?.owner_org.id}/${s}/icon`]);h&&!r&&g.error("Could not delete app logo");let{error:d}=await o.storage.from(`apps/${s}/${a}`).remove(["versions"]);d&&!r&&g.error("Could not delete app version");let{error:f}=await o.from("apps").delete().eq("app_id",s);if(f)throw r||g.error("Could not delete app"),new Error(`Could not delete app: ${W(f)}`);let m=await Fr(o,s);return await ve(e.apikey,{channel:"app",event:"App Deleted",icon:"\u{1F5D1}\uFE0F",user_id:m,tags:{"app-id":s},notify:!1}).catch(()=>{}),r||(g.success("App deleted in Capgo"),ce("Done \u2705")),!0}var Wp=require("node:os"),_8=require("node:process");async function v8(t){let e={},r=Object.keys(t);return(await Promise.all(r.map(i=>Mh(i)))).forEach((i,s)=>{i&&(e[r[s]]=i)}),e}async function qle(){let t=await sl(),e={"@capgo/cli":$i.version};for(let[r,n]of t)(r.startsWith("@capgo/")||r.startsWith("@capawesome/")||r.startsWith("capacitor"))&&(e[r]=n);return e}async function C8(t,e=!1){e||g.warn(" \u{1F48A} Capgo Doctor \u{1F48A}");let r=await de(),n=os("",t.packageJson),i=r?.config?.plugins?.CapacitorUpdater?.version||n,s=r?.config?.appName||"",o=Re("",r?.config),a=r?.config?.webDir||"";e||(g.info(` App Name: ${s}`),g.info(` App ID: ${o}`),g.info(` App Version: ${i}`),g.info(` Web Dir: ${a}`),g.info(` OS: ${(0,Wp.platform)()} ${(0,Wp.version)()}`),g.info(` Node: ${_8.version}`),g.info(" Installed Dependencies:"));let u=await qle();if(Object.keys(u).length===0)throw e||g.warning("\x1B[31m%s\x1B[0m \u{1F6A8} No dependencies found"),new Error("No dependencies found");if(!e)for(let l of Object.keys(u))g.info(` ${l}: ${u[l]}`);let c={};if(e)c=await v8(u);else{let l=St();l.start("Running: Loading latest dependencies"),c=await v8(u),l.stop("Latest Dependencies:");for(let h of Object.keys(c))g.info(` ${h}: ${c[h]}`)}if(JSON.stringify(u)!==JSON.stringify(c))throw e||g.warn("\x1B[31m\u{1F6A8} Some dependencies are not up to date\x1B[0m"),new Error("Some dependencies are not up to date");return e||g.success("\x1B[32m\u2705 All dependencies are up to date\x1B[0m"),{appName:s,appId:o,appVersion:i,webDir:a,installedDependencies:u,latestDependencies:c}}function Ule(t){let e=new Vt;e.headers=["Name","id","Created"],e.rows=[];for(let r of t.toReversed())e.rows.push([r.name??"",r.app_id,eu(r.created_at)]);g.success("Apps"),g.success(e.toString())}async function Hle(t,e){let{data:r,error:n}=await t.from("apps").select().order("created_at",{ascending:!1});if(n)throw e||g.error("Apps not found"),new Error("Apps not found");return r??[]}async function S8(t,e=!1){e||oe("List apps in Capgo"),await Ke(),t.apikey=t.apikey||te();let r=await pe(t.apikey,t.supaHost,t.supaAnon);await De(r,t.apikey,["write","all","read","upload"]),e||g.info("Getting active bundle in Capgo");let n=await Hle(r,e);if(!n.length)throw e||g.error("No apps found"),new Error("No apps found");return e||(g.info(`Active app in Capgo: ${n.length}`),Ule(n),ce("Done \u2705")),n}var A8=require("node:crypto"),ru=require("node:fs");async function O8(t,e,r=!1){r||oe("Set app"),e.apikey=e.apikey||te();let n=await de();if(t=Re(t,n?.config),!e.apikey)throw r||g.error("Missing API key, you need to provide an API key to upload your bundle"),new Error("Missing API key");if(!t)throw r||g.error("Missing argument, you need to provide a appId, or be in a capacitor project"),new Error("Missing appId");let i=await pe(e.apikey,e.supaHost,e.supaAnon),o=(await Vp(i,["admin","super_admin"])).gid,a=await De(i,e.apikey,["write","all"]);await Dt(i,e.apikey,t,4,r);let{name:u,icon:c,retention:l}=e;if(l&&Number.isNaN(Number(l)))throw r||g.error("retention value must be a number"),new Error("Retention value must be a number");if(l&&l<0)throw r||g.error("retention value cannot be less than 0"),new Error("Retention value cannot be less than 0");if(l&&l>=63113904)throw r||g.error("retention value cannot be greater than 63113904 seconds (2 years)"),new Error("Retention value cannot be greater than 63113904 seconds (2 years)");let h,d,f=`icon_${(0,A8.randomUUID)()}`,m="https://xvwzpoazmxkqosrdewyv.supabase.co/storage/v1/object/public/images/capgo.png";if(c&&(0,ru.existsSync)(c)?(h=(0,ru.readFileSync)(c),d=Qa(c)||"image/png",r||g.warn(`Found app icon ${c}`)):(0,ru.existsSync)(Zr)?(h=(0,ru.readFileSync)(Zr),d=Qa(Zr)||"image/png",r||g.warn(`Found app icon ${Zr}`)):r||g.warn(`Cannot find app icon in any of the following locations: ${c}, ${Zr}`),h&&d){let{error:E}=await i.storage.from(`images/org/${o}/${t}`).upload(f,h,{contentType:d});if(E)throw r||g.error(`Could not set app ${W(E)}`),new Error(`Could not set app: ${W(E)}`);let{data:S}=await i.storage.from(`images/org/${o}/${t}`).getPublicUrl(f);m=S?.publicUrl||m}let{error:y}=await i.from("apps").update({icon_url:m,name:u,retention:l?l*24*60*60:void 0}).eq("app_id",t).eq("user_id",a);if(y)throw r||g.error(`Could not set app ${W(y)}`),new Error(`Could not set app: ${W(y)}`);return r||ce("Done \u2705"),!0}async function x8(t,e,r=!1){if(r||oe("Set a specific setting in capacitor config"),e.bool&&e.string)throw r||g.error("Bool and string CANNOT be set at the same time"),new Error("Bool and string cannot both be provided");if(!e.bool&&!e.string)throw r||g.error("You MUST provide either bool or string as the value"),new Error("Either bool or string value is required");if(e.bool&&e.bool!=="true"&&e.bool!=="false")throw r||g.error("Invalid bool"),new Error("Invalid bool value; expected true or false");try{let n=await de(),i=n.config,s=t.split(".");if(s.length===0)throw r||g.error("Invalid path"),new Error("Invalid config path");for(let a of s.slice(0,-1))Object.prototype.hasOwnProperty.call(i,a)||(i[a]={}),i=i[a];let o=e.bool?e.bool==="true":e.string;i[s.at(-1)]=o,await za(n,!0),r||g.success(`Set "${t}" to "${o}"`)}catch(n){throw r||g.error(`Cannot set config in capacitor settings ${W(n)}`),new Error(`Cannot set capacitor config: ${W(n)}`)}r||ce("Done \u2705")}var gi=require("node:fs"),hn=require("node:fs/promises"),P8=require("node:os"),dn=require("node:path"),R8=Ce(require("node:process"));var k8=Ce(eD()),Yp=Ce(Bh());var Xp=require("node:fs/promises"),T8=require("node:os"),lv=require("node:path"),$e=require("node:process"),Vle=(0,lv.join)((0,T8.homedir)(),".capgo-credentials"),zle=(0,lv.join)(Vle,"credentials.json");async function Kle(){try{let t=await(0,Xp.readFile)(zle,"utf-8");return JSON.parse(t)}catch{return{}}}async function Gle(t){let e=await Kle();if(!t){let r=Object.keys(e);return r.length===0?null:e[r[0]]||null}return e[t]||null}function Wle(){let t={};return $e.env.BUILD_CERTIFICATE_BASE64&&(t.BUILD_CERTIFICATE_BASE64=$e.env.BUILD_CERTIFICATE_BASE64),$e.env.BUILD_PROVISION_PROFILE_BASE64&&(t.BUILD_PROVISION_PROFILE_BASE64=$e.env.BUILD_PROVISION_PROFILE_BASE64),$e.env.BUILD_PROVISION_PROFILE_BASE64_PROD&&(t.BUILD_PROVISION_PROFILE_BASE64_PROD=$e.env.BUILD_PROVISION_PROFILE_BASE64_PROD),$e.env.P12_PASSWORD&&(t.P12_PASSWORD=$e.env.P12_PASSWORD),$e.env.APPLE_KEY_ID&&(t.APPLE_KEY_ID=$e.env.APPLE_KEY_ID),$e.env.APPLE_ISSUER_ID&&(t.APPLE_ISSUER_ID=$e.env.APPLE_ISSUER_ID),$e.env.APPLE_KEY_CONTENT&&(t.APPLE_KEY_CONTENT=$e.env.APPLE_KEY_CONTENT),$e.env.APPLE_PROFILE_NAME&&(t.APPLE_PROFILE_NAME=$e.env.APPLE_PROFILE_NAME),$e.env.APP_STORE_CONNECT_TEAM_ID&&(t.APP_STORE_CONNECT_TEAM_ID=$e.env.APP_STORE_CONNECT_TEAM_ID),$e.env.ANDROID_KEYSTORE_FILE&&(t.ANDROID_KEYSTORE_FILE=$e.env.ANDROID_KEYSTORE_FILE),$e.env.KEYSTORE_KEY_ALIAS&&(t.KEYSTORE_KEY_ALIAS=$e.env.KEYSTORE_KEY_ALIAS),$e.env.KEYSTORE_KEY_PASSWORD&&(t.KEYSTORE_KEY_PASSWORD=$e.env.KEYSTORE_KEY_PASSWORD),$e.env.KEYSTORE_STORE_PASSWORD&&(t.KEYSTORE_STORE_PASSWORD=$e.env.KEYSTORE_STORE_PASSWORD),$e.env.PLAY_CONFIG_JSON&&(t.PLAY_CONFIG_JSON=$e.env.PLAY_CONFIG_JSON),t}async function I8(t,e,r){let n=await Gle(t),i=Wle(),s={...n?.[e]||{}};if(Object.assign(s,i),r&&Object.assign(s,r),e==="android"){let o=!!s.KEYSTORE_KEY_PASSWORD,a=!!s.KEYSTORE_STORE_PASSWORD;o&&!a?s.KEYSTORE_STORE_PASSWORD=s.KEYSTORE_KEY_PASSWORD:!o&&a&&(s.KEYSTORE_KEY_PASSWORD=s.KEYSTORE_STORE_PASSWORD)}return Object.keys(s).length>0?s:void 0}async function Xle(t,e,r,n,i){if(!i)try{let s=await fetch(`${t}/build/logs/${e}?app_id=${encodeURIComponent(r)}`,{headers:{authorization:n}});if(!s.ok){g.warn("Could not stream logs, continuing...");return}let o=s.body?.getReader();if(!o)return;let a=new TextDecoder;for(;;){let{done:u,value:c}=await o.read();if(u)break;let h=a.decode(c,{stream:!0}).split(`
|
|
320
|
-
`);for(let d of h)if(d.startsWith("data: ")){let f=d.slice(6);f.trim()&&g.error(f)}}}catch(s){i||g.warn(`Log streaming interrupted${s instanceof Error?`: ${s.message}`:""}`)}}async function Yle(t,e,r,n,i,s){let a=0;for(;a<120;)try{let u=await fetch(`${t}/build/status?job_id=${encodeURIComponent(e)}&app_id=${encodeURIComponent(r)}&platform=${n}`,{headers:{authorization:i}});if(!u.ok){s||g.warn(`Status check failed: ${u.status}`),await new Promise(l=>setTimeout(l,5e3)),a++;continue}let c=await u.json();if(c.status==="succeeded"||c.status==="failed")return c.status;await new Promise(l=>setTimeout(l,5e3)),a++}catch(u){s||g.warn(`Status check error: ${u}`),await new Promise(c=>setTimeout(c,5e3)),a++}return s||g.warn("Build status polling timed out"),"timeout"}async function Jle(t,e){let r=new Set;if(e==="ios"){let n=(0,dn.join)(t,"ios/App/Podfile");if((0,gi.existsSync)(n)){let s=(await(0,hn.readFile)(n,"utf-8")).matchAll(/pod\s+['"][^'"]+['"],\s*:path\s*=>\s*['"]\.\.\/\.\.\/node_modules\/([^'"]+)['"]/g);for(let o of s){let a=o[1];r.add(`node_modules/${a}/Package.swift`),r.add(`node_modules/${a}/*.podspec`),r.add(`node_modules/${a}/ios/`)}}}else if(e==="android"){let n=(0,dn.join)(t,"android/capacitor.settings.gradle");if((0,gi.existsSync)(n)){let s=(await(0,hn.readFile)(n,"utf-8")).matchAll(/new\s+File\s*\(\s*['"]\.\.\/node_modules\/([^'"]+)['"]\s*\)/g);for(let o of s){let u=o[1].replace(/\/android$/,"");r.add(`node_modules/${u}/android/`)}}}return r}function F8(t,e,r){let n=t.replace(/\\/g,"/");if(n.startsWith(`${e}/`)||n==="package.json"||n==="package-lock.json"||n.startsWith("capacitor.config.")||n.startsWith("resources/")||e==="ios"&&n.startsWith("node_modules/@capacitor/ios/")||e==="android"&&n.startsWith("node_modules/@capacitor/android/"))return!0;for(let i of r)if(n.startsWith(i))return!0;return!1}function ol(t,e,r,n,i){let s=(0,gi.readdirSync)(e);for(let o of s){let a=(0,dn.join)(e,o),u=r?`${r}/${o}`:o,c=(0,gi.statSync)(a);if(c.isDirectory()){if(o===".git"||o==="dist"||o==="build"||o===".angular"||o===".vite")continue;if(o===n){ol(t,a,u,n,i);continue}if(o==="node_modules"){ol(t,a,u,n,i);continue}if(o==="resources"){ol(t,a,u,n,i);continue}F8(u,n,i)&&ol(t,a,u,n,i)}else if(c.isFile()){if(o===".DS_Store"||o.endsWith(".log"))continue;F8(u,n,i)&&t.addLocalFile(a,r||void 0)}}}async function Zle(t,e,r){let n=await Jle(t,r),i=new k8.default;ol(i,t,"",r,n),await(0,hn.writeFile)(e,i.toBuffer())}async function N8(t,e,r=!1){let n=Date.now();try{e.apikey=e.apikey||te(r);let i=await de();if(t=t||i?.config.appId,!t)throw new Error("Missing argument, you need to provide a appId, or be in a capacitor project");if(!e.platform)throw new Error("Missing required argument: --platform <ios|android>");if(e.platform!=="ios"&&e.platform!=="android")throw new Error(`Invalid platform "${e.platform}". Must be "ios" or "android"`);let s=(0,dn.resolve)(e.path||R8.default.cwd()),o=e.supaHost||"https://api.capgo.app",a=await pe(e.apikey,e.supaHost,e.supaAnon);await De(a,e.apikey,["write","all"]);let u=await Fr(a,t);r||(g.info(`Requesting native build for ${t}`),g.info(`Platform: ${e.platform}`),g.info(`Project: ${s}`),g.info(`API host: ${o}`),g.info(`
|
|
320
|
+
`);for(let d of h)if(d.startsWith("data: ")){let f=d.slice(6);f.trim()&&g.error(f)}}}catch(s){i||g.warn(`Log streaming interrupted${s instanceof Error?`: ${s.message}`:""}`)}}async function Yle(t,e,r,n,i,s){let a=0;for(;a<120;)try{let u=await fetch(`${t}/build/status?job_id=${encodeURIComponent(e)}&app_id=${encodeURIComponent(r)}&platform=${n}`,{headers:{authorization:i}});if(!u.ok){s||g.warn(`Status check failed: ${u.status}`),await new Promise(l=>setTimeout(l,5e3)),a++;continue}let c=await u.json();if(c.status==="succeeded"||c.status==="failed")return c.status;await new Promise(l=>setTimeout(l,5e3)),a++}catch(u){s||g.warn(`Status check error: ${u}`),await new Promise(c=>setTimeout(c,5e3)),a++}return s||g.warn("Build status polling timed out"),"timeout"}async function Jle(t,e){let r=new Set;if(e==="ios"){let n=(0,dn.join)(t,"ios/App/Podfile");if((0,gi.existsSync)(n)){let s=(await(0,hn.readFile)(n,"utf-8")).matchAll(/pod\s+['"][^'"]+['"],\s*:path\s*=>\s*['"]\.\.\/\.\.\/node_modules\/([^'"]+)['"]/g);for(let o of s){let a=o[1];r.add(`node_modules/${a}/Package.swift`),r.add(`node_modules/${a}/*.podspec`),r.add(`node_modules/${a}/ios/`)}}}else if(e==="android"){let n=(0,dn.join)(t,"android/capacitor.settings.gradle");if((0,gi.existsSync)(n)){let s=(await(0,hn.readFile)(n,"utf-8")).matchAll(/new\s+File\s*\(\s*['"]\.\.\/node_modules\/([^'"]+)['"]\s*\)/g);for(let o of s){let u=o[1].replace(/\/android$/,"");r.add(`node_modules/${u}/android/`)}}}return r}function F8(t,e,r){let n=t.replace(/\\/g,"/");if(n.startsWith(`${e}/`)||n==="package.json"||n==="package-lock.json"||n.startsWith("capacitor.config.")||n.startsWith("resources/")||e==="ios"&&n.startsWith("node_modules/@capacitor/ios/")||e==="android"&&n.startsWith("node_modules/@capacitor/android/"))return!0;for(let i of r)if(n.startsWith(i))return!0;return!1}function ol(t,e,r,n,i){let s=(0,gi.readdirSync)(e);for(let o of s){let a=(0,dn.join)(e,o),u=r?`${r}/${o}`:o,c=(0,gi.statSync)(a);if(c.isDirectory()){if(o===".git"||o==="dist"||o==="build"||o===".angular"||o===".vite")continue;if(o===n){ol(t,a,u,n,i);continue}if(o==="node_modules"){ol(t,a,u,n,i);continue}if(o==="resources"){ol(t,a,u,n,i);continue}let l=u.replace(/\\/g,"/");(F8(u,n,i)||Array.from(i).some(d=>d.startsWith(`${l}/`)))&&ol(t,a,u,n,i)}else if(c.isFile()){if(o===".DS_Store"||o.endsWith(".log"))continue;F8(u,n,i)&&t.addLocalFile(a,r||void 0)}}}async function Zle(t,e,r){let n=await Jle(t,r),i=new k8.default;ol(i,t,"",r,n),await(0,hn.writeFile)(e,i.toBuffer())}async function N8(t,e,r=!1){let n=Date.now();try{e.apikey=e.apikey||te(r);let i=await de();if(t=t||i?.config.appId,!t)throw new Error("Missing argument, you need to provide a appId, or be in a capacitor project");if(!e.platform)throw new Error("Missing required argument: --platform <ios|android>");if(e.platform!=="ios"&&e.platform!=="android")throw new Error(`Invalid platform "${e.platform}". Must be "ios" or "android"`);let s=(0,dn.resolve)(e.path||R8.default.cwd()),o=e.supaHost||"https://api.capgo.app",a=await pe(e.apikey,e.supaHost,e.supaAnon);await De(a,e.apikey,["write","all"]);let u=await Fr(a,t);r||(g.info(`Requesting native build for ${t}`),g.info(`Platform: ${e.platform}`),g.info(`Project: ${s}`),g.info(`API host: ${o}`),g.info(`
|
|
321
321
|
\u{1F512} Security: Credentials are never stored on Capgo servers`),g.info(" They are used only during build and deleted after (max 24h)"),g.info(` Builds sent directly to app stores - Capgo keeps nothing
|
|
322
322
|
`));let c={};e.buildCertificateBase64&&(c.BUILD_CERTIFICATE_BASE64=e.buildCertificateBase64),e.buildProvisionProfileBase64&&(c.BUILD_PROVISION_PROFILE_BASE64=e.buildProvisionProfileBase64),e.buildProvisionProfileBase64Prod&&(c.BUILD_PROVISION_PROFILE_BASE64_PROD=e.buildProvisionProfileBase64Prod),e.p12Password&&(c.P12_PASSWORD=e.p12Password),e.appleKeyId&&(c.APPLE_KEY_ID=e.appleKeyId),e.appleIssuerId&&(c.APPLE_ISSUER_ID=e.appleIssuerId),e.appleKeyContent&&(c.APPLE_KEY_CONTENT=e.appleKeyContent),e.appleProfileName&&(c.APPLE_PROFILE_NAME=e.appleProfileName),e.appStoreConnectTeamId&&(c.APP_STORE_CONNECT_TEAM_ID=e.appStoreConnectTeamId),e.androidKeystoreFile&&(c.ANDROID_KEYSTORE_FILE=e.androidKeystoreFile),e.keystoreKeyAlias&&(c.KEYSTORE_KEY_ALIAS=e.keystoreKeyAlias);let l=!!e.keystoreKeyPassword,h=!!e.keystoreStorePassword;l&&!h?(c.KEYSTORE_KEY_PASSWORD=e.keystoreKeyPassword,c.KEYSTORE_STORE_PASSWORD=e.keystoreKeyPassword):!l&&h?(c.KEYSTORE_KEY_PASSWORD=e.keystoreStorePassword,c.KEYSTORE_STORE_PASSWORD=e.keystoreStorePassword):l&&h&&(c.KEYSTORE_KEY_PASSWORD=e.keystoreKeyPassword,c.KEYSTORE_STORE_PASSWORD=e.keystoreStorePassword),e.playConfigJson&&(c.PLAY_CONFIG_JSON=e.playConfigJson);let d=await I8(t,e.platform,Object.keys(c).length>0?c:void 0),f={app_id:t,platform:e.platform};if(!d)throw r||(g.error("\u274C No credentials found for this app and platform"),g.error(""),g.error("You must provide credentials via:"),g.error(" 1. CLI arguments (--apple-key-id, --p12-password, etc.)"),g.error(" 2. Environment variables (APPLE_KEY_ID, P12_PASSWORD, etc.)"),g.error(" 3. Saved credentials file:"),g.error(` npx @capgo/cli build credentials save --appId ${t} --platform ${e.platform}`),g.error(""),g.error("Documentation:"),g.error(" https://capgo.app/docs/cli/cloud-build/credentials/")),new Error("No credentials found. Please provide credentials before building.");let m=[];if(e.platform==="ios"?(d.BUILD_CERTIFICATE_BASE64||m.push("BUILD_CERTIFICATE_BASE64 (or --build-certificate-base64)"),!d.P12_PASSWORD&&!r&&(g.warn("\u26A0\uFE0F P12_PASSWORD not provided - assuming certificate has no password"),g.warn(" If your certificate requires a password, provide it with --p12-password")),d.BUILD_PROVISION_PROFILE_BASE64||m.push("BUILD_PROVISION_PROFILE_BASE64 (or --build-provision-profile-base64)"),d.APPLE_KEY_ID||m.push("APPLE_KEY_ID (or --apple-key-id)"),d.APPLE_ISSUER_ID||m.push("APPLE_ISSUER_ID (or --apple-issuer-id)"),d.APPLE_KEY_CONTENT||m.push("APPLE_KEY_CONTENT (or --apple-key-content)"),d.APP_STORE_CONNECT_TEAM_ID||m.push("APP_STORE_CONNECT_TEAM_ID (or --apple-team-id)")):e.platform==="android"&&(d.ANDROID_KEYSTORE_FILE||m.push("ANDROID_KEYSTORE_FILE (or --android-keystore-file)"),d.KEYSTORE_KEY_ALIAS||m.push("KEYSTORE_KEY_ALIAS (or --keystore-key-alias)"),!d.KEYSTORE_KEY_PASSWORD&&!d.KEYSTORE_STORE_PASSWORD&&m.push("KEYSTORE_KEY_PASSWORD or KEYSTORE_STORE_PASSWORD (at least one password required)"),!d.PLAY_CONFIG_JSON&&!r&&g.warn("\u26A0\uFE0F PLAY_CONFIG_JSON not provided - build will succeed but cannot auto-upload to Play Store")),m.length>0){if(!r){g.error(`\u274C Missing required credentials for ${e.platform}:`),g.error("");for(let p of m)g.error(` \u2022 ${p}`);g.error(""),g.error("Provide credentials via:"),g.error(' 1. CLI arguments: npx @capgo/cli build request --platform ios --apple-id "..." --p12-password "..."'),g.error(' 2. Environment variables: export APPLE_ID="..." P12_PASSWORD="..."'),g.error(" 3. Saved credentials: npx @capgo/cli build credentials save --platform ios ..."),g.error(""),g.error("Documentation:"),g.error(` https://capgo.app/docs/cli/cloud-build/${e.platform}/`)}throw new Error(`Missing required credentials for ${e.platform}: ${m.join(", ")}`)}f.credentials=d,r||g.info("\u2713 Using credentials (merged from CLI args, env vars, and saved file)"),r||g.info("Requesting build from Capgo...");let y=await fetch(`${o}/build/request`,{method:"POST",headers:{"Content-Type":"application/json",authorization:e.apikey},body:JSON.stringify(f)});if(!y.ok){let p=await y.text();throw new Error(`Failed to request build: ${y.status} - ${p}`)}let E=await y.json();r||(g.success(`Build job created: ${E.job_id}`),g.info(`Status: ${E.status}`),g.info(`Upload URL: ${E.upload_url}`),g.info(`Upload expires: ${E.upload_expires_at}`)),await ve(e.apikey,{channel:"native-builder",event:"Build requested",icon:"\u{1F3D7}\uFE0F",user_id:u,tags:{"app-id":t,platform:e.platform},notify:!1}).catch();let S=(0,dn.join)((0,P8.tmpdir)(),`capgo-build-${Date.now()}`);await(0,hn.mkdir)(S,{recursive:!0});let A=(0,dn.join)(S,`${(0,dn.basename)(s)}.zip`);try{r||g.info(`Zipping ${e.platform} project from ${s}...`),await Zle(s,A,e.platform);let D=((await(0,hn.stat)(A)).size/1024/1024).toFixed(2);r||g.success(`Created zip: ${A} (${D} MB)`),r||(g.info("Uploading to builder with TUS protocol..."),g.info(`Upload endpoint: ${E.upload_url}`),g.info(`File size: ${D} MB`),g.info(`Job ID: ${E.job_id}`));let w=(0,gi.readFileSync)(A),b=St();r||b.start("Uploading bundle"),await new Promise((I,j)=>{let U=new Yp.Upload(w,{endpoint:E.upload_url,chunkSize:5242880,metadata:{filename:(0,dn.basename)(A),filetype:"application/zip"},headers:{authorization:e.apikey},onBeforeRequest(z){if(!r){g.info(`[TUS] ${z.getMethod()} ${z.getURL()}`);let $=z.getHeader("authorization");g.info(`[TUS] Authorization header present: ${!!$}`)}},onAfterResponse(z,$){if(!r){g.info(`[TUS] Response status: ${$.getStatus()}`);let C=$.getHeader("upload-offset"),T=$.getHeader("tus-resumable");g.info(`[TUS] Upload-Offset: ${C}, Tus-Resumable: ${T}`)}},onError(z){if(r||(b.stop("Upload failed"),g.error(`[TUS] Upload error: ${z.message}`)),z instanceof Yp.DetailedError){let $=z.originalResponse?.getBody(),C=z.originalResponse?.getStatus(),T=z.originalRequest?.getURL();r||(g.error(`[TUS] Request URL: ${T}`),g.error(`[TUS] Response status: ${C}`),g.error(`[TUS] Response body: ${$}`));let F="Unknown error";try{let L=JSON.parse($||'{"error": "unknown error"}');F=L.status||L.error||L.message||"unknown error"}catch{F=$||z.message}j(new Error(`TUS upload failed: ${F}`))}else j(new Error(`TUS upload failed: ${z.message||z.toString()}`))},onProgress(z,$){let C=(z/$*100).toFixed(2);r||b.message(`Uploading ${C}%`)},onSuccess(){r||(b.stop("Upload complete!"),g.success("TUS upload completed successfully")),I()}});r||g.info("[TUS] Starting upload..."),U.start()}),r||g.info("Starting build job...");let P=await fetch(`${o}/build/start/${E.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:e.apikey},body:JSON.stringify({app_id:t})});if(!P.ok){let I=await P.text();throw new Error(`Failed to start build: ${P.status} - ${I}`)}let v=await P.json();r||(g.success("Build started successfully!"),g.info(`Job ID: ${E.job_id}`),g.info(`Streaming build logs...
|
|
323
323
|
`)),await Xle(o,E.job_id,t,e.apikey,r);let k=await Yle(o,E.job_id,t,e.platform,e.apikey,r);r||(k==="succeeded"?g.success("Build completed successfully!"):k==="failed"?g.error("Build failed"):g.warn(`Build finished with status: ${k}`));let R=((Date.now()-n)/1e3).toFixed(2);return await ve(e.apikey,{channel:"native-builder",event:k==="succeeded"?"Build succeeded":"Build failed",icon:k==="succeeded"?"\u2705":"\u274C",user_id:u,tags:{"app-id":t,platform:e.platform,status:k||"unknown",time:R},notify:!1}).catch(),{success:k==="succeeded",jobId:E.job_id,uploadUrl:E.upload_url,status:k||v.status||E.status}}finally{await(0,hn.rm)(S,{recursive:!0,force:!0})}}catch(i){let s=i instanceof Error?i.message:String(i);return r||g.error(s),{success:!1,error:s}}}async function Qle(t,e,r,n){for await(let i of t)n||g.warn(`Removing ${i.name} created on ${eu(i.created_at)}`),await Kp(e,r,i.name)}function efe(t,e,r){let n=[];for(let i of t??[]){let s=At(i.name);jm(s,e)&&Bm(s,r)&&n.push(i)}return n}async function $8(t,e,r=!1){r||oe("Cleanup versions in Capgo"),await Ke(),e.apikey=e.apikey||te();let{bundle:n,keep:i=4}=e,s=e.force||!1,o=e.ignoreChannel||!1,a=await de();if(t=Re(t,a?.config),!e.apikey)throw r||g.error("Missing API key, you need to provide an API key to delete your app"),new Error("Missing API key");if(!t)throw r||g.error("Missing argument, you need to provide a appid, or be in a capacitor project"),new Error("Missing appId");let u=await pe(e.apikey,e.supaHost,e.supaAnon);await De(u,e.apikey,["write","all"]),await Dt(u,e.apikey,t,3,r),r||g.info("Querying all available versions in Capgo");let c=await Gp(u,t),l=await D8(u,t);if(r||g.info(`Total active versions in Capgo: ${c?.length??0}`),!c?.length)throw r||g.error("No versions found, aborting cleanup"),new Error("No versions found");if(n){let f=At(n),m=y_(f,"major");r||g.info(`Querying available versions in Capgo between ${Si(f)} and ${Si(m)}`),c=efe(c,f,m),r||g.info(`Active versions in Capgo between ${Si(f)} and ${Si(m)}: ${c?.length??0}`)}let h=[],d=0;for(let f of c){let m=l.find(y=>y===f.id);d<i||m&&!o?(f.keep=m?"\u2705 (Linked to channel)":"\u2705",d+=1):(f.keep="\u274C",h.push(f))}if(!h.length)return r||g.warn("Nothing to be removed, aborting removal..."),{removed:0,kept:d};if(r||y8(c),!s){if(r)throw new Error("Cleanup requires force=true in SDK mode to prevent accidental deletions");{let f=await jr({message:"Do you want to continue removing the versions specified?"});if(It(f)||!f)throw g.warn("Not confirmed, aborting removal..."),new Error("Cleanup cancelled by user")}}return r||g.success("You have confirmed removal, removing versions now"),await Qle(h,u,t,r),r||ce("Done \u2705"),{removed:h.length,kept:d}}async function L8(t,e,r=!1){r||oe("Check compatibility");let n={...e,apikey:e.apikey||te()},i=await de(),s=Re(t,i?.config),o=n.channel;if(!o)throw r||g.error("Missing argument, you need to provide a channel"),new Error("Missing channel");if(!n.apikey)throw r||g.error("Missing API key, you need to provide an API key to upload your bundle"),new Error("Missing API key");if(!s)throw r||g.error("Missing argument, you need to provide an appId, or be in a capacitor project"),new Error("Missing appId");let a=await pe(n.apikey,n.supaHost,n.supaAnon);await De(a,n.apikey,["write","all","read","upload"]),await Dt(a,n.apikey,s,1,r);let u=await zp(a,s,o,n.packageJson,n.nodeModules);if(!r){let c=new Vt;c.headers=["Package","Local version","Remote version","Compatible"],c.theme=Vt.roundTheme,c.rows=[];let l=n.text?"Yes":"\u2705",h=n.text?"No":"\u274C";for(let d of u.finalCompatibility){let{name:f,localVersion:m,remoteVersion:y}=d,E=ao(d)?l:h;c.rows.push([f,m,y,E])}g.success("Compatibility"),g.success(c.toString())}return{finalCompatibility:u.finalCompatibility}}var Di=require("node:fs");var as=require("node:buffer"),Ut=require("node:crypto"),j8="aes-128-cbc",yi="base64",Jp=Ut.constants.RSA_PKCS1_PADDING;function Zp(t){let e=(0,Ut.randomBytes)(16),r=(0,Ut.randomBytes)(16),n=e.toString(yi),i=(0,Ut.privateEncrypt)({key:t,padding:Jp},r).toString(yi);return{sessionKey:r,ivSessionKey:`${n}:${i}`}}function nu(t,e,r){let[n]=r.split(":"),i=as.Buffer.from(n,yi),s=(0,Ut.createCipheriv)(j8,e,i);return s.setAutoPadding(!0),as.Buffer.concat([s.update(t),s.final()])}function B8(t,e,r){let[n,i]=e.split(":"),s=(0,Ut.publicDecrypt)({key:r,padding:Jp},as.Buffer.from(i,yi)),o=as.Buffer.from(n,yi),a=(0,Ut.createDecipheriv)(j8,s,o);return a.setAutoPadding(!0),as.Buffer.concat([a.update(t),a.final()])}function iu(t,e){return(0,Ut.privateEncrypt)({key:e,padding:Jp},as.Buffer.from(t,yi)).toString(yi)}function M8(t="pem",e=2048){let{publicKey:r,privateKey:n}=(0,Ut.generateKeyPairSync)("rsa",{modulusLength:e});return t==="pem"?{publicKey:r.export({type:"pkcs1",format:"pem"}),privateKey:n.export({type:"pkcs1",format:"pem"})}:{publicKey:r.export({type:"spki",format:"der"}).toString("base64"),privateKey:n.export({type:"pkcs1",format:"pem"}).toString("base64")}}function q8(t,e){return(0,Ut.publicDecrypt)({key:e,padding:Jp},as.Buffer.from(t,yi)).toString(yi)}function tfe(t,e){let r=t.key||mi,n=e.config.plugins?.CapacitorUpdater?.publicKey;return(0,Di.existsSync)(r)?n=(0,Di.readFileSync)(r,"utf8"):!n&&t.keyData&&(n=t.keyData),{publicKey:n,fallbackKeyPath:r}}async function U8(t,e,r,n=!1){n||oe("Decrypt zip file");try{if(await Ke(),!(0,Di.existsSync)(t)){let h=`Zip not found at the path ${t}`;throw n||g.error(h),new Error(h)}let i=await de();if(!r.key&&!(0,Di.existsSync)(mi)&&!i.config.plugins?.CapacitorUpdater?.privateKey){let h=`Private Key not found at the path ${mi} or in ${i.path}`;throw n||g.error(h),new Error(h)}let{publicKey:s,fallbackKeyPath:o}=tfe(r,i);if(!s){let h=`Cannot find public key ${o} or as keyData option or in ${i.path}`;throw n||g.error(h),new Error(h)}let a=(0,Di.readFileSync)(t),u=B8(a,e,r.keyData??s),c=`${t}_decrypted.zip`;(0,Di.writeFileSync)(c,u),n||g.info(`Decrypted zip file at ${c}`);let l;if(r.checksum){let h=await Qn(u,"sha256"),d=q8(r.checksum,r.keyData??s);if(l=h===d,!l){let f=`Checksum does not match ${h} !== ${d}`;throw n||g.error(f),new Error(f)}n||g.info("Checksum matches")}return n||ce("\u2705 done"),{outputPath:c,checksumMatches:l}}catch(i){throw n||g.error(`Error decrypting zip file ${W(i)}`),i instanceof Error?i:new Error(String(i))}}async function H8(t,e,r,n=!1){n||oe("Delete bundle"),r.apikey=r.apikey||te();let i=await de();if(e=Re(e,i?.config),!r.apikey)throw n||g.error("Missing API key, you need to provide an API key to upload your bundle"),new Error("Missing API key");if(!e)throw n||g.error("Missing argument, you need to provide a appId, or be in a capacitor project"),new Error("Missing appId");if(!t)throw n||g.error("Missing argument, you need to provide a bundleId, or be in a capacitor project"),new Error("Missing bundleId");let s=await pe(r.apikey,r.supaHost,r.supaAnon);return await De(s,r.apikey,["write","all"]),await Dt(s,r.apikey,e,3,n),n||(g.info(`Deleting bundle ${e}@${t} from Capgo`),g.info("Keep in mind that you will not be able to reuse this bundle version, it's gone forever")),await Kp(s,e,t),n||(g.success(`Bundle ${e}@${t} deleted in Capgo`),ce("Done")),!0}var wi=require("node:fs");function al(t){console.error(W(t))}async function V8(t,e,r,n=!1){let{json:i}=r,s=!i&&!n;s&&(oe("Encryption"),await Ke());try{let o=await de(),a=!!o.config.plugins?.CapacitorUpdater?.privateKey,u=!!o.config.plugins?.CapacitorUpdater?.publicKey;if(a&&s&&g.warning("There is still a privateKey in the config"),!(0,wi.existsSync)(t)){let S=`Zip not found at the path ${t}`;throw n||(i?al({error:"zip_not_found"}):g.error(`Error: ${S}`)),new Error(S)}if(!u)throw n||(i?al({error:"missing_public_key"}):g.warning("Warning: Missing Public Key in config")),new Error("Missing public key in config");let c=r.key||Rr,l=r.keyData||"";if(!(0,wi.existsSync)(c)&&!l)throw n||(i?al({error:"missing_key"}):(g.warning(`Cannot find a private key at ${c} or as a keyData option`),g.error("Error: Missing key"))),new Error("Missing private key");if((0,wi.existsSync)(c)&&(l=(0,wi.readFileSync)(c,"utf8")),l&&!l.startsWith("-----BEGIN RSA PRIVATE KEY-----"))throw n||(i?al({error:"invalid_private_key"}):g.error("The private key provided is not a valid RSA Private key")),new Error("Invalid private key format");let h=(0,wi.readFileSync)(t),{sessionKey:d,ivSessionKey:f}=Zp(l),m=nu(h,d,f),y=iu(e,l),E=`${t}_encrypted.zip`;return(0,wi.writeFileSync)(E,m),n||(i?console.log(JSON.stringify({checksum:y,filename:E,ivSessionKey:f},null,2)):(g.success(`Encoded Checksum: ${y}`),g.success(`ivSessionKey: ${f}`),g.success(`Encrypted zip saved at ${E}`),ce("Done \u2705"))),{checksum:y,filename:E,ivSessionKey:f}}catch(o){throw n||(r.json?al(o):g.error(`Error encrypting zip file ${W(o)}`)),o instanceof Error?o:new Error(String(o))}}var yq=require("node:crypto"),yo=require("node:fs"),Nv=require("node:process");var Qp=class extends TransformStream{outChunkSize;constructor(e){let r=new Uint8Array(e),n=0;super({transform(i,s){let o=0;for(;o<i.length;){let a=e-n,u=Math.min(a,i.length-o);r.set(i.subarray(o,o+u),n),o+=u,n+=u,n===e&&(s.enqueue(r),r=new Uint8Array(e),n=0)}},flush(i){n>0&&i.enqueue(r.subarray(0,n))}}),this.outChunkSize=e}};function us(t){return t=t.trim(),t=t.replace(/<!--[\s\S]*?-->/g,""),e();function e(){return{declaration:r(),root:n()}}function r(){if(!u(/^<\?xml\s*/))return;let d={attributes:{}};for(;!(c()||l("?>"));){let f=s();if(!f)return d;d.attributes[f.name]=f.value}return u(/\?>\s*/),d}function n(){let h=u(/^<([\w-:.]+)\s*/);if(!h)return;let d={name:h[1],attributes:{},children:[]};for(;!(c()||l(">")||l("?>")||l("/>"));){let m=s();if(!m)return d;d.attributes[m.name]=m.value}if(u(/^\s*\/>\s*/))return d;u(/\??>\s*/),d.content=i();let f;for(;f=n();)d.children.push(f);return u(/^<\/[\w-:.]+>\s*/),d}function i(){let h=u(/^([^<]*)/);return h?a(h[1]):""}function s(){let h=u(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(h)return{name:h[1],value:a(o(h[2]))}}function o(h){return h.replace(/^['"]|['"]$/g,"")}function a(h){return h.replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}function u(h){let d=t.match(h);if(d)return t=t.slice(d[0].length),d}function c(){return t.length===0}function l(h){return t.startsWith(h)}}var Mn=class extends Error{};var Jt=class extends Mn{},ul=class extends Mn{},em=class extends Mn{bucketName;constructor(e){super(`Invalid bucket name: ${e}`),this.bucketName=e}},qn=class extends Mn{objectName;constructor(e){super(`Invalid object name: ${e}`),this.objectName=e}},cs=class extends Mn{constructor(){super("accessKey is required")}},su=class extends Mn{constructor(){super("secretKey is required")}},cl=class extends Mn{constructor(){super("expirySeconds cannot be less than 1 second or more than 7 days")}},Ei=class extends Mn{statusCode;code;key;bucketName;resource;region;constructor(e,r,n,i={}){super(n),this.statusCode=e,this.code=r,this.key=i.key,this.bucketName=i.bucketName,this.resource=i.resource,this.region=i.region}};async function z8(t){try{let r=us(await t.text()).root;if(r?.name!=="Error")throw new Error("Invalid root, expected <Error>");let n=r.children.find(c=>c.name==="Code")?.content??"UnknownErrorCode",i=r.children.find(c=>c.name==="Message")?.content??"The error message could not be determined.",s=r.children.find(c=>c.name==="Key")?.content,o=r.children.find(c=>c.name==="BucketName")?.content,a=r.children.find(c=>c.name==="Resource")?.content,u=r.children.find(c=>c.name==="Region")?.content;return new Ei(t.status,n,i,{key:s,bucketName:o,resource:a,region:u})}catch{return new Ei(t.status,"UnrecognizedError",`Error: Unexpected response code ${t.status} ${t.statusText}. Unable to parse response as XML.`)}}function K8(t){return typeof t!="number"||isNaN(t)?!1:t>=1&&t<=65535}function G8(t){return typeof t!="string"||t.length<3||t.length>63||t.includes("..")||t.match(/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)?!1:!!t.match(/^[a-z0-9][a-z0-9.-]+[a-z0-9]$/)}function ls(t){return!(!rfe(t)||t.length===0)}function rfe(t){return!(typeof t!="string"||t.length>1024)}function ll(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function uo(t=""){let e={'"':"",""":"",""":"",""":"",""":""};return t.replace(/^("|"|")|("|"|")$/g,r=>e[r])}function hv(t){return t.get("x-amz-version-id")??null}function co(t){let e=t.toISOString();return e.slice(0,4)+e.slice(5,7)+e.slice(8,13)+e.slice(14,16)+e.slice(17,19)+"Z"}function dv(t){return co(t).slice(0,8)}function pv(t,e){return`${dv(e)}/${t}/s3/aws4_request`}async function tm(t){return t instanceof Uint8Array||(t=new TextEncoder().encode(t)),ll(new Uint8Array(await crypto.subtle.digest("SHA-256",t)))}var nfe=["x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5"],rm=class extends WritableStream{getResult;constructor({client:e,bucketName:r,objectName:n,partSize:i,metadata:s}){let o,a=1,u,c=[],l,h=[];super({start(){},async write(d,f){let y=a++;try{if(y==1&&d.length<i){let A=await e.makeRequest({method:"PUT",headers:new Headers({...s,"Content-Length":String(d.length)}),bucketName:r,objectName:n,payload:d});o={etag:uo(A.headers.get("etag")??void 0),versionId:hv(A.headers)};return}y===1&&(u=(await ife({client:e,bucketName:r,objectName:n,metadata:s})).uploadId);let E={"Content-Length":String(d.length)};for(let A of nfe){let p=s[A];p&&(E[A]=p)}let S=e.makeRequest({method:"PUT",query:{partNumber:y.toString(),uploadId:u},headers:new Headers(E),bucketName:r,objectName:n,payload:d}).then(A=>{let p=A.headers.get("etag")??"";return p&&(p=p.replace(/^"/,"").replace(/"$/,"")),c.push({part:y,etag:p}),A});h.push(S.catch(A=>{l||(l=A)}))}catch(E){throw E}},async close(){if(!o)if(u){if(await Promise.all(h),l)throw l;c.sort((d,f)=>d.part>f.part?1:-1),o=await sfe({client:e,bucketName:r,objectName:n,uploadId:u,etags:c})}else throw new Error("Stream was closed without uploading any data.")}}),this.getResult=()=>{if(o===void 0)throw new Error("Result is not ready. await the stream first.");return o}}};async function ife(t){let e="POST",r=new Headers(t.metadata),s=await(await t.client.makeRequest({method:e,bucketName:t.bucketName,objectName:t.objectName,query:"uploads",headers:r,returnBody:!0})).text(),o=us(s).root;if(!o||o.name!=="InitiateMultipartUploadResult")throw new Error(`Unexpected response: ${s}`);let a=o.children.find(u=>u.name==="UploadId")?.content;if(!a)throw new Error(`Unable to get UploadId from response: ${s}`);return{uploadId:a}}async function sfe({client:t,bucketName:e,objectName:r,uploadId:n,etags:i}){let s=`
|