@r5n/hydra 0.3.3 → 0.3.5
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/cli.js +54 -64
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
var Kt=Object.create;var{getPrototypeOf:Jt,defineProperty:Wn,getOwnPropertyNames:Yt}=Object;var Qt=Object.prototype.hasOwnProperty;var mn=(t,r,o)=>{o=t!=null?Kt(Jt(t)):{};let e=r||!t||!t.__esModule?Wn(o,"default",{value:t,enumerable:!0}):o;for(let s of Yt(t))if(!Qt.call(e,s))Wn(e,s,{get:()=>t[s],enumerable:!0});return e};var zn=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);var On=zn((No,Kn)=>{var Rn={to(t,r){if(!r)return`\x1B[${t+1}G`;return`\x1B[${r+1};${t+1}H`},move(t,r){let o="";if(t<0)o+=`\x1B[${-t}D`;else if(t>0)o+=`\x1B[${t}C`;if(r<0)o+=`\x1B[${-r}A`;else if(r>0)o+=`\x1B[${r}B`;return o},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Zt={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Vt={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let r="";for(let o=0;o<t;o++)r+=this.line+(o<t-1?Rn.up():"");if(t)r+=Rn.left;return r}};Kn.exports={cursor:Rn,scroll:Zt,erase:Vt,beep:"\x07"}});var Cn=zn((vo,Sn)=>{var gn=process||{},Jn=gn.argv||[],ln=gn.env||{},Ft=!(!!ln.NO_COLOR||Jn.includes("--no-color"))&&(!!ln.FORCE_COLOR||Jn.includes("--color")||gn.platform==="win32"||(gn.stdout||{}).isTTY&&ln.TERM!=="dumb"||!!ln.CI),Dt=(t,r,o=t)=>(e)=>{let s=""+e,i=s.indexOf(r,t.length);return~i?t+nr(s,r,o,i)+r:t+s+r},nr=(t,r,o,e)=>{let s="",i=0;do s+=t.substring(i,e)+o,i=e+r.length,e=t.indexOf(r,i);while(~e);return s+t.substring(i)},Yn=(t=Ft)=>{let r=t?Dt:()=>String;return{isColorSupported:t,reset:r("\x1B[0m","\x1B[0m"),bold:r("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:r("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:r("\x1B[3m","\x1B[23m"),underline:r("\x1B[4m","\x1B[24m"),inverse:r("\x1B[7m","\x1B[27m"),hidden:r("\x1B[8m","\x1B[28m"),strikethrough:r("\x1B[9m","\x1B[29m"),black:r("\x1B[30m","\x1B[39m"),red:r("\x1B[31m","\x1B[39m"),green:r("\x1B[32m","\x1B[39m"),yellow:r("\x1B[33m","\x1B[39m"),blue:r("\x1B[34m","\x1B[39m"),magenta:r("\x1B[35m","\x1B[39m"),cyan:r("\x1B[36m","\x1B[39m"),white:r("\x1B[37m","\x1B[39m"),gray:r("\x1B[90m","\x1B[39m"),bgBlack:r("\x1B[40m","\x1B[49m"),bgRed:r("\x1B[41m","\x1B[49m"),bgGreen:r("\x1B[42m","\x1B[49m"),bgYellow:r("\x1B[43m","\x1B[49m"),bgBlue:r("\x1B[44m","\x1B[49m"),bgMagenta:r("\x1B[45m","\x1B[49m"),bgCyan:r("\x1B[46m","\x1B[49m"),bgWhite:r("\x1B[47m","\x1B[49m"),blackBright:r("\x1B[90m","\x1B[39m"),redBright:r("\x1B[91m","\x1B[39m"),greenBright:r("\x1B[92m","\x1B[39m"),yellowBright:r("\x1B[93m","\x1B[39m"),blueBright:r("\x1B[94m","\x1B[39m"),magentaBright:r("\x1B[95m","\x1B[39m"),cyanBright:r("\x1B[96m","\x1B[39m"),whiteBright:r("\x1B[97m","\x1B[39m"),bgBlackBright:r("\x1B[100m","\x1B[49m"),bgRedBright:r("\x1B[101m","\x1B[49m"),bgGreenBright:r("\x1B[102m","\x1B[49m"),bgYellowBright:r("\x1B[103m","\x1B[49m"),bgBlueBright:r("\x1B[104m","\x1B[49m"),bgMagentaBright:r("\x1B[105m","\x1B[49m"),bgCyanBright:r("\x1B[106m","\x1B[49m"),bgWhiteBright:r("\x1B[107m","\x1B[49m")}};Sn.exports=Yn();Sn.exports.createColors=Yn});var O=mn(On(),1),et=mn(Cn(),1);import{stdin as rt,stdout as ot}from"process";import*as I from"readline";import Qn from"readline";import{Writable as tr}from"stream";function rr({onlyFirst:t=!1}={}){let r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,t?void 0:"g")}var or=rr();function st(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(or,"")}function it(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var at={exports:{}};(function(t){var r={};t.exports=r,r.eastAsianWidth=function(e){var s=e.charCodeAt(0),i=e.length==2?e.charCodeAt(1):0,n=s;return 55296<=s&&s<=56319&&56320<=i&&i<=57343&&(s&=1023,i&=1023,n=s<<10|i,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},r.characterLength=function(e){var s=this.eastAsianWidth(e);return s=="F"||s=="W"||s=="A"?2:1};function o(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}r.length=function(e){for(var s=o(e),i=0,n=0;n<s.length;n++)i=i+this.characterLength(s[n]);return i},r.slice=function(e,s,i){textLen=r.length(e),s=s||0,i=i||1,s<0&&(s=textLen+s),i<0&&(i=textLen+i);for(var n="",a=0,c=o(e),l=0;l<c.length;l++){var f=c[l],m=r.length(f);if(a>=s-(m==2?1:0))if(a+m<=i)n+=f;else break;a+=m}return n}})(at);var er=at.exports,sr=it(er),ir=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},ar=it(ir);function tn(t,r={}){if(typeof t!="string"||t.length===0||(r={ambiguousIsNarrow:!0,...r},t=st(t),t.length===0))return 0;t=t.replace(ar()," ");let o=r.ambiguousIsNarrow?1:2,e=0;for(let s of t){let i=s.codePointAt(0);if(i<=31||i>=127&&i<=159||i>=768&&i<=879)continue;switch(sr.eastAsianWidth(s)){case"F":case"W":e+=2;break;case"A":e+=o;break;default:e+=1}}return e}var Tn=10,Zn=(t=0)=>(r)=>`\x1B[${r+t}m`,Vn=(t=0)=>(r)=>`\x1B[${38+t};5;${r}m`,Fn=(t=0)=>(r,o,e)=>`\x1B[${38+t};2;${r};${o};${e}m`,x={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(x.modifier);var cr=Object.keys(x.color),fr=Object.keys(x.bgColor);[...cr];function mr(){let t=new Map;for(let[r,o]of Object.entries(x)){for(let[e,s]of Object.entries(o))x[e]={open:`\x1B[${s[0]}m`,close:`\x1B[${s[1]}m`},o[e]=x[e],t.set(s[0],s[1]);Object.defineProperty(x,r,{value:o,enumerable:!1})}return Object.defineProperty(x,"codes",{value:t,enumerable:!1}),x.color.close="\x1B[39m",x.bgColor.close="\x1B[49m",x.color.ansi=Zn(),x.color.ansi256=Vn(),x.color.ansi16m=Fn(),x.bgColor.ansi=Zn(Tn),x.bgColor.ansi256=Vn(Tn),x.bgColor.ansi16m=Fn(Tn),Object.defineProperties(x,{rgbToAnsi256:{value:(r,o,e)=>r===o&&o===e?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(o/255*5)+Math.round(e/255*5),enumerable:!1},hexToRgb:{value:(r)=>{let o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!o)return[0,0,0];let[e]=o;e.length===3&&(e=[...e].map((i)=>i+i).join(""));let s=Number.parseInt(e,16);return[s>>16&255,s>>8&255,s&255]},enumerable:!1},hexToAnsi256:{value:(r)=>x.rgbToAnsi256(...x.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:(r)=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let o,e,s;if(r>=232)o=((r-232)*10+8)/255,e=o,s=o;else{r-=16;let a=r%36;o=Math.floor(r/36)/5,e=Math.floor(a/6)/5,s=a%6/5}let i=Math.max(o,e,s)*2;if(i===0)return 30;let n=30+(Math.round(s)<<2|Math.round(e)<<1|Math.round(o));return i===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(r,o,e)=>x.ansi256ToAnsi(x.rgbToAnsi256(r,o,e)),enumerable:!1},hexToAnsi:{value:(r)=>x.ansi256ToAnsi(x.hexToAnsi256(r)),enumerable:!1}}),x}var lr=mr(),hn=new Set(["\x1B","\x9B"]),gr=39,vn="\x07",ct="[",pr="]",ft="m",Pn=`${pr}8;;`,Dn=(t)=>`${hn.values().next().value}${ct}${t}${ft}`,nt=(t)=>`${hn.values().next().value}${Pn}${t}${vn}`,ur=(t)=>t.split(" ").map((r)=>tn(r)),kn=(t,r,o)=>{let e=[...r],s=!1,i=!1,n=tn(st(t[t.length-1]));for(let[a,c]of e.entries()){let l=tn(c);if(n+l<=o?t[t.length-1]+=c:(t.push(c),n=0),hn.has(c)&&(s=!0,i=e.slice(a+1).join("").startsWith(Pn)),s){i?c===vn&&(s=!1,i=!1):c===ft&&(s=!1);continue}n+=l,n===o&&a<e.length-1&&(t.push(""),n=0)}!n&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},hr=(t)=>{let r=t.split(" "),o=r.length;for(;o>0&&!(tn(r[o-1])>0);)o--;return o===r.length?t:r.slice(0,o).join(" ")+r.slice(o).join("")},dr=(t,r,o={})=>{if(o.trim!==!1&&t.trim()==="")return"";let e="",s,i,n=ur(t),a=[""];for(let[l,f]of t.split(" ").entries()){o.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let m=tn(a[a.length-1]);if(l!==0&&(m>=r&&(o.wordWrap===!1||o.trim===!1)&&(a.push(""),m=0),(m>0||o.trim===!1)&&(a[a.length-1]+=" ",m++)),o.hard&&n[l]>r){let g=r-m,d=1+Math.floor((n[l]-g-1)/r);Math.floor((n[l]-1)/r)<d&&a.push(""),kn(a,f,r);continue}if(m+n[l]>r&&m>0&&n[l]>0){if(o.wordWrap===!1&&m<r){kn(a,f,r);continue}a.push("")}if(m+n[l]>r&&o.wordWrap===!1){kn(a,f,r);continue}a[a.length-1]+=f}o.trim!==!1&&(a=a.map((l)=>hr(l)));let c=[...a.join(`
|
|
3
|
-
`)];for(let[l,f]of c.entries()){if(e+=f,
|
|
4
|
-
`?(
|
|
5
|
-
`&&(
|
|
2
|
+
var Zt=Object.create;var{getPrototypeOf:Vt,defineProperty:Jn,getOwnPropertyNames:Ft}=Object;var Dt=Object.prototype.hasOwnProperty;var gn=(t,r,o)=>{o=t!=null?Zt(Vt(t)):{};let e=r||!t||!t.__esModule?Jn(o,"default",{value:t,enumerable:!0}):o;for(let i of Ft(t))if(!Dt.call(e,i))Jn(e,i,{get:()=>t[i],enumerable:!0});return e};var Yn=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports);var kn=Yn((Mo,Qn)=>{var Tn={to(t,r){if(!r)return`\x1B[${t+1}G`;return`\x1B[${r+1};${t+1}H`},move(t,r){let o="";if(t<0)o+=`\x1B[${-t}D`;else if(t>0)o+=`\x1B[${t}C`;if(r<0)o+=`\x1B[${-r}A`;else if(r>0)o+=`\x1B[${r}B`;return o},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},nr={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},tr={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let r="";for(let o=0;o<t;o++)r+=this.line+(o<t-1?Tn.up():"");if(t)r+=Tn.left;return r}};Qn.exports={cursor:Tn,scroll:nr,erase:tr,beep:"\x07"}});var vn=Yn((Xo,Nn)=>{var hn=process||{},Zn=hn.argv||[],un=hn.env||{},rr=!(!!un.NO_COLOR||Zn.includes("--no-color"))&&(!!un.FORCE_COLOR||Zn.includes("--color")||hn.platform==="win32"||(hn.stdout||{}).isTTY&&un.TERM!=="dumb"||!!un.CI),or=(t,r,o=t)=>(e)=>{let i=""+e,s=i.indexOf(r,t.length);return~s?t+er(i,r,o,s)+r:t+i+r},er=(t,r,o,e)=>{let i="",s=0;do i+=t.substring(s,e)+o,s=e+r.length,e=t.indexOf(r,s);while(~e);return i+t.substring(s)},Vn=(t=rr)=>{let r=t?or:()=>String;return{isColorSupported:t,reset:r("\x1B[0m","\x1B[0m"),bold:r("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:r("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:r("\x1B[3m","\x1B[23m"),underline:r("\x1B[4m","\x1B[24m"),inverse:r("\x1B[7m","\x1B[27m"),hidden:r("\x1B[8m","\x1B[28m"),strikethrough:r("\x1B[9m","\x1B[29m"),black:r("\x1B[30m","\x1B[39m"),red:r("\x1B[31m","\x1B[39m"),green:r("\x1B[32m","\x1B[39m"),yellow:r("\x1B[33m","\x1B[39m"),blue:r("\x1B[34m","\x1B[39m"),magenta:r("\x1B[35m","\x1B[39m"),cyan:r("\x1B[36m","\x1B[39m"),white:r("\x1B[37m","\x1B[39m"),gray:r("\x1B[90m","\x1B[39m"),bgBlack:r("\x1B[40m","\x1B[49m"),bgRed:r("\x1B[41m","\x1B[49m"),bgGreen:r("\x1B[42m","\x1B[49m"),bgYellow:r("\x1B[43m","\x1B[49m"),bgBlue:r("\x1B[44m","\x1B[49m"),bgMagenta:r("\x1B[45m","\x1B[49m"),bgCyan:r("\x1B[46m","\x1B[49m"),bgWhite:r("\x1B[47m","\x1B[49m"),blackBright:r("\x1B[90m","\x1B[39m"),redBright:r("\x1B[91m","\x1B[39m"),greenBright:r("\x1B[92m","\x1B[39m"),yellowBright:r("\x1B[93m","\x1B[39m"),blueBright:r("\x1B[94m","\x1B[39m"),magentaBright:r("\x1B[95m","\x1B[39m"),cyanBright:r("\x1B[96m","\x1B[39m"),whiteBright:r("\x1B[97m","\x1B[39m"),bgBlackBright:r("\x1B[100m","\x1B[49m"),bgRedBright:r("\x1B[101m","\x1B[49m"),bgGreenBright:r("\x1B[102m","\x1B[49m"),bgYellowBright:r("\x1B[103m","\x1B[49m"),bgBlueBright:r("\x1B[104m","\x1B[49m"),bgMagentaBright:r("\x1B[105m","\x1B[49m"),bgCyanBright:r("\x1B[106m","\x1B[49m"),bgWhiteBright:r("\x1B[107m","\x1B[49m")}};Nn.exports=Vn();Nn.exports.createColors=Vn});var S=gn(kn(),1),at=gn(vn(),1);import{stdin as it,stdout as st}from"process";import*as j from"readline";import Fn from"readline";import{Writable as ir}from"stream";function sr({onlyFirst:t=!1}={}){let r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,t?void 0:"g")}var ar=sr();function ct(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(ar,"")}function ft(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mt={exports:{}};(function(t){var r={};t.exports=r,r.eastAsianWidth=function(e){var i=e.charCodeAt(0),s=e.length==2?e.charCodeAt(1):0,n=i;return 55296<=i&&i<=56319&&56320<=s&&s<=57343&&(i&=1023,s&=1023,n=i<<10|s,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},r.characterLength=function(e){var i=this.eastAsianWidth(e);return i=="F"||i=="W"||i=="A"?2:1};function o(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}r.length=function(e){for(var i=o(e),s=0,n=0;n<i.length;n++)s=s+this.characterLength(i[n]);return s},r.slice=function(e,i,s){textLen=r.length(e),i=i||0,s=s||1,i<0&&(i=textLen+i),s<0&&(s=textLen+s);for(var n="",a=0,c=o(e),l=0;l<c.length;l++){var f=c[l],m=r.length(f);if(a>=i-(m==2?1:0))if(a+m<=s)n+=f;else break;a+=m}return n}})(mt);var cr=mt.exports,fr=ft(cr),mr=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},lr=ft(mr);function en(t,r={}){if(typeof t!="string"||t.length===0||(r={ambiguousIsNarrow:!0,...r},t=ct(t),t.length===0))return 0;t=t.replace(lr()," ");let o=r.ambiguousIsNarrow?1:2,e=0;for(let i of t){let s=i.codePointAt(0);if(s<=31||s>=127&&s<=159||s>=768&&s<=879)continue;switch(fr.eastAsianWidth(i)){case"F":case"W":e+=2;break;case"A":e+=o;break;default:e+=1}}return e}var Pn=10,Dn=(t=0)=>(r)=>`\x1B[${r+t}m`,nt=(t=0)=>(r)=>`\x1B[${38+t};5;${r}m`,tt=(t=0)=>(r,o,e)=>`\x1B[${38+t};2;${r};${o};${e}m`,x={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(x.modifier);var pr=Object.keys(x.color),gr=Object.keys(x.bgColor);[...pr];function ur(){let t=new Map;for(let[r,o]of Object.entries(x)){for(let[e,i]of Object.entries(o))x[e]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},o[e]=x[e],t.set(i[0],i[1]);Object.defineProperty(x,r,{value:o,enumerable:!1})}return Object.defineProperty(x,"codes",{value:t,enumerable:!1}),x.color.close="\x1B[39m",x.bgColor.close="\x1B[49m",x.color.ansi=Dn(),x.color.ansi256=nt(),x.color.ansi16m=tt(),x.bgColor.ansi=Dn(Pn),x.bgColor.ansi256=nt(Pn),x.bgColor.ansi16m=tt(Pn),Object.defineProperties(x,{rgbToAnsi256:{value:(r,o,e)=>r===o&&o===e?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(o/255*5)+Math.round(e/255*5),enumerable:!1},hexToRgb:{value:(r)=>{let o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!o)return[0,0,0];let[e]=o;e.length===3&&(e=[...e].map((s)=>s+s).join(""));let i=Number.parseInt(e,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:(r)=>x.rgbToAnsi256(...x.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:(r)=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let o,e,i;if(r>=232)o=((r-232)*10+8)/255,e=o,i=o;else{r-=16;let a=r%36;o=Math.floor(r/36)/5,e=Math.floor(a/6)/5,i=a%6/5}let s=Math.max(o,e,i)*2;if(s===0)return 30;let n=30+(Math.round(i)<<2|Math.round(e)<<1|Math.round(o));return s===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(r,o,e)=>x.ansi256ToAnsi(x.rgbToAnsi256(r,o,e)),enumerable:!1},hexToAnsi:{value:(r)=>x.ansi256ToAnsi(x.hexToAnsi256(r)),enumerable:!1}}),x}var hr=ur(),yn=new Set(["\x1B","\x9B"]),dr=39,Xn="\x07",lt="[",br="]",pt="m",_n=`${br}8;;`,rt=(t)=>`${yn.values().next().value}${lt}${t}${pt}`,ot=(t)=>`${yn.values().next().value}${_n}${t}${Xn}`,yr=(t)=>t.split(" ").map((r)=>en(r)),Gn=(t,r,o)=>{let e=[...r],i=!1,s=!1,n=en(ct(t[t.length-1]));for(let[a,c]of e.entries()){let l=en(c);if(n+l<=o?t[t.length-1]+=c:(t.push(c),n=0),yn.has(c)&&(i=!0,s=e.slice(a+1).join("").startsWith(_n)),i){s?c===Xn&&(i=!1,s=!1):c===pt&&(i=!1);continue}n+=l,n===o&&a<e.length-1&&(t.push(""),n=0)}!n&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},xr=(t)=>{let r=t.split(" "),o=r.length;for(;o>0&&!(en(r[o-1])>0);)o--;return o===r.length?t:r.slice(0,o).join(" ")+r.slice(o).join("")},$r=(t,r,o={})=>{if(o.trim!==!1&&t.trim()==="")return"";let e="",i,s,n=yr(t),a=[""];for(let[l,f]of t.split(" ").entries()){o.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let m=en(a[a.length-1]);if(l!==0&&(m>=r&&(o.wordWrap===!1||o.trim===!1)&&(a.push(""),m=0),(m>0||o.trim===!1)&&(a[a.length-1]+=" ",m++)),o.hard&&n[l]>r){let p=r-m,d=1+Math.floor((n[l]-p-1)/r);Math.floor((n[l]-1)/r)<d&&a.push(""),Gn(a,f,r);continue}if(m+n[l]>r&&m>0&&n[l]>0){if(o.wordWrap===!1&&m<r){Gn(a,f,r);continue}a.push("")}if(m+n[l]>r&&o.wordWrap===!1){Gn(a,f,r);continue}a[a.length-1]+=f}o.trim!==!1&&(a=a.map((l)=>xr(l)));let c=[...a.join(`
|
|
3
|
+
`)];for(let[l,f]of c.entries()){if(e+=f,yn.has(f)){let{groups:p}=new RegExp(`(?:\\${lt}(?<code>\\d+)m|\\${_n}(?<uri>.*)${Xn})`).exec(c.slice(l).join(""))||{groups:{}};if(p.code!==void 0){let d=Number.parseFloat(p.code);i=d===dr?void 0:d}else p.uri!==void 0&&(s=p.uri.length===0?void 0:p.uri)}let m=hr.codes.get(Number(i));c[l+1]===`
|
|
4
|
+
`?(s&&(e+=ot("")),i&&m&&(e+=rt(m))):f===`
|
|
5
|
+
`&&(i&&m&&(e+=rt(i)),s&&(e+=ot(s)))}return e};function et(t,r,o){return String(t).normalize().replace(/\r\n/g,`
|
|
6
6
|
`).split(`
|
|
7
|
-
`).map((e)
|
|
8
|
-
`)}var
|
|
7
|
+
`).map((e)=>$r(e,r,o)).join(`
|
|
8
|
+
`)}var wr=["up","down","left","right","space","enter","cancel"],bn={actions:new Set(wr),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};function An(t,r){if(typeof t=="string")return bn.aliases.get(t)===r;for(let o of t)if(o!==void 0&&An(o,r))return!0;return!1}function Er(t,r){if(t===r)return;let o=t.split(`
|
|
9
9
|
`),e=r.split(`
|
|
10
|
-
`),
|
|
11
|
-
`),
|
|
12
|
-
`).length-1;this.output.write(
|
|
13
|
-
`);this.output.write(e[o]),this._prevFrame=t,this.output.write(
|
|
10
|
+
`),i=[];for(let s=0;s<Math.max(o.length,e.length);s++)o[s]!==e[s]&&i.push(s);return i}var Rr=globalThis.process.platform.startsWith("win"),Mn=Symbol("clack:cancel");function C(t){return t===Mn}function dn(t,r){let o=t;o.isTTY&&o.setRawMode(r)}function gt({input:t=it,output:r=st,overwrite:o=!0,hideCursor:e=!0}={}){let i=j.createInterface({input:t,output:r,prompt:"",tabSize:1});j.emitKeypressEvents(t,i),t.isTTY&&t.setRawMode(!0);let s=(n,{name:a,sequence:c})=>{let l=String(n);if(An([l,a,c],"cancel")){e&&r.write(S.cursor.show),process.exit(0);return}if(!o)return;j.moveCursor(r,a==="return"?0:-1,a==="return"?-1:0,()=>{j.clearLine(r,1,()=>{t.once("keypress",s)})})};return e&&r.write(S.cursor.hide),t.once("keypress",s),()=>{t.off("keypress",s),e&&r.write(S.cursor.show),t.isTTY&&!Rr&&t.setRawMode(!1),i.terminal=!1,i.close()}}var Or=Object.defineProperty,Sr=(t,r,o)=>(r in t)?Or(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,N=(t,r,o)=>(Sr(t,typeof r!="symbol"?r+"":r,o),o);class Un{constructor(t,r=!0){N(this,"input"),N(this,"output"),N(this,"_abortSignal"),N(this,"rl"),N(this,"opts"),N(this,"_render"),N(this,"_track",!1),N(this,"_prevFrame",""),N(this,"_subscribers",new Map),N(this,"_cursor",0),N(this,"state","initial"),N(this,"error",""),N(this,"value");let{input:o=it,output:e=st,render:i,signal:s,...n}=t;this.opts=n,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=r,this._abortSignal=s,this.input=o,this.output=e}unsubscribe(){this._subscribers.clear()}setSubscriber(t,r){let o=this._subscribers.get(t)??[];o.push(r),this._subscribers.set(t,o)}on(t,r){this.setSubscriber(t,{cb:r})}once(t,r){this.setSubscriber(t,{cb:r,once:!0})}emit(t,...r){let o=this._subscribers.get(t)??[],e=[];for(let i of o)i.cb(...r),i.once&&e.push(()=>o.splice(o.indexOf(i),1));for(let i of e)i()}prompt(){return new Promise((t,r)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(Mn);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let o=new ir;o._write=(e,i,s)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),s()},this.input.pipe(o),this.rl=Fn.createInterface({input:this.input,output:o,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),Fn.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),dn(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),dn(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(S.cursor.show),this.output.off("resize",this.render),dn(this.input,!1),t(Mn)})})}onKeypress(t,r){if(this.state==="error"&&(this.state="active"),r?.name&&(!this._track&&bn.aliases.has(r.name)&&this.emit("cursor",bn.aliases.get(r.name)),bn.actions.has(r.name)&&this.emit("cursor",r.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),r?.name==="return"){if(this.opts.validate){let o=this.opts.validate(this.value);o&&(this.error=o instanceof Error?o.message:o,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}An([t,r?.name,r?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
11
|
+
`),dn(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=et(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
12
|
+
`).length-1;this.output.write(S.cursor.move(-999,t*-1))}render(){let t=et(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(S.cursor.hide);else{let r=Er(this._prevFrame,t);if(this.restoreCursor(),r&&r?.length===1){let o=r[0];this.output.write(S.cursor.move(0,o)),this.output.write(S.erase.lines(1));let e=t.split(`
|
|
13
|
+
`);this.output.write(e[o]),this._prevFrame=t,this.output.write(S.cursor.move(0,e.length-o-1));return}if(r&&r?.length>1){let o=r[0];this.output.write(S.cursor.move(0,o)),this.output.write(S.erase.down());let e=t.split(`
|
|
14
14
|
`).slice(o);this.output.write(e.join(`
|
|
15
|
-
`)),this._prevFrame=t;return}this.output.write(
|
|
16
|
-
${
|
|
17
|
-
`,o=t.placeholder?
|
|
18
|
-
${
|
|
19
|
-
${
|
|
20
|
-
`;case"submit":return`${r}${
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
`}}}).prompt();var
|
|
24
|
-
${
|
|
25
|
-
`,
|
|
26
|
-
${
|
|
27
|
-
${
|
|
28
|
-
`}}}).prompt()};var
|
|
29
|
-
|
|
30
|
-
`)},
|
|
31
|
-
`)}
|
|
32
|
-
${
|
|
33
|
-
|
|
34
|
-
`)},
|
|
35
|
-
`);o.push(`${r} ${e}`,...
|
|
15
|
+
`)),this._prevFrame=t;return}this.output.write(S.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}class qn extends Un{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(r)=>{this.output.write(S.cursor.move(0,-1)),this.value=r,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}var Cr;Cr=new WeakMap;class Hn extends Un{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let t=this.value.slice(0,this.cursor),[r,...o]=this.value.slice(this.cursor);return`${t}${at.default.inverse(r)}${o.join("")}`}get cursor(){return this._cursor}constructor(t){super(t),this.on("finalize",()=>{this.value||(this.value=t.defaultValue)})}}var g=gn(vn(),1),xn=gn(kn(),1);import _ from"process";function Tr(){return _.platform!=="win32"?_.env.TERM!=="linux":!!_.env.CI||!!_.env.WT_SESSION||!!_.env.TERMINUS_SUBLIME||_.env.ConEmuTask==="{cmd::Cmder}"||_.env.TERM_PROGRAM==="Terminus-Sublime"||_.env.TERM_PROGRAM==="vscode"||_.env.TERM==="xterm-256color"||_.env.TERM==="alacritty"||_.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Ln=Tr(),E=(t,r)=>Ln?t:r,kr=E("\u25C6","*"),dt=E("\u25A0","x"),bt=E("\u25B2","x"),Bn=E("\u25C7","o"),Nr=E("\u250C","T"),O=E("\u2502","|"),sn=E("\u2514","\u2014"),ut=E("\u25CF",">"),ht=E("\u25CB"," "),Jo=E("\u25FB","[\u2022]"),Yo=E("\u25FC","[+]"),Qo=E("\u25FB","[ ]"),Zo=E("\u25AA","\u2022"),Vo=E("\u2500","-"),Fo=E("\u256E","+"),Do=E("\u251C","+"),ne=E("\u256F","+"),vr=E("\u25CF","\u2022"),Pr=E("\u25C6","*"),Gr=E("\u25B2","!"),Mr=E("\u25A0","x"),yt=(t)=>{switch(t){case"initial":case"active":return g.default.cyan(kr);case"cancel":return g.default.red(dt);case"error":return g.default.yellow(bt);case"submit":return g.default.green(Bn)}};var v=(t)=>new Hn({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let r=`${g.default.gray(O)}
|
|
16
|
+
${yt(this.state)} ${t.message}
|
|
17
|
+
`,o=t.placeholder?g.default.inverse(t.placeholder[0])+g.default.dim(t.placeholder.slice(1)):g.default.inverse(g.default.hidden("_")),e=this.value?this.valueWithCursor:o;switch(this.state){case"error":return`${r.trim()}
|
|
18
|
+
${g.default.yellow(O)} ${e}
|
|
19
|
+
${g.default.yellow(sn)} ${g.default.yellow(this.error)}
|
|
20
|
+
`;case"submit":return`${r}${g.default.gray(O)} ${g.default.dim(this.value||t.placeholder)}`;case"cancel":return`${r}${g.default.gray(O)} ${g.default.strikethrough(g.default.dim(this.value??""))}${this.value?.trim()?`
|
|
21
|
+
${g.default.gray(O)}`:""}`;default:return`${r}${g.default.cyan(O)} ${e}
|
|
22
|
+
${g.default.cyan(sn)}
|
|
23
|
+
`}}}).prompt();var W=(t)=>{let r=t.active??"Yes",o=t.inactive??"No";return new qn({active:r,inactive:o,initialValue:t.initialValue??!0,render(){let e=`${g.default.gray(O)}
|
|
24
|
+
${yt(this.state)} ${t.message}
|
|
25
|
+
`,i=this.value?r:o;switch(this.state){case"submit":return`${e}${g.default.gray(O)} ${g.default.dim(i)}`;case"cancel":return`${e}${g.default.gray(O)} ${g.default.strikethrough(g.default.dim(i))}
|
|
26
|
+
${g.default.gray(O)}`;default:return`${e}${g.default.cyan(O)} ${this.value?`${g.default.green(ut)} ${r}`:`${g.default.dim(ht)} ${g.default.dim(r)}`} ${g.default.dim("/")} ${this.value?`${g.default.dim(ht)} ${g.default.dim(o)}`:`${g.default.green(ut)} ${o}`}
|
|
27
|
+
${g.default.cyan(sn)}
|
|
28
|
+
`}}}).prompt()};var In=(t="")=>{process.stdout.write(`${g.default.gray(sn)} ${g.default.red(t)}
|
|
29
|
+
|
|
30
|
+
`)},xt=(t="")=>{process.stdout.write(`${g.default.gray(Nr)} ${t}
|
|
31
|
+
`)},$t=(t="")=>{process.stdout.write(`${g.default.gray(O)}
|
|
32
|
+
${g.default.gray(sn)} ${t}
|
|
33
|
+
|
|
34
|
+
`)},A={message:(t="",{symbol:r=g.default.gray(O)}={})=>{let o=[`${g.default.gray(O)}`];if(t){let[e,...i]=t.split(`
|
|
35
|
+
`);o.push(`${r} ${e}`,...i.map((s)=>`${g.default.gray(O)} ${s}`))}process.stdout.write(`${o.join(`
|
|
36
36
|
`)}
|
|
37
|
-
`)},info:(t)=>{
|
|
37
|
+
`)},info:(t)=>{A.message(t,{symbol:g.default.blue(vr)})},success:(t)=>{A.message(t,{symbol:g.default.green(Pr)})},step:(t)=>{A.message(t,{symbol:g.default.green(Bn)})},warn:(t)=>{A.message(t,{symbol:g.default.yellow(Gr)})},warning:(t)=>{A.warn(t)},error:(t)=>{A.message(t,{symbol:g.default.red(Mr)})}},te=`${g.default.gray(O)} `;var wt=({indicator:t="dots"}={})=>{let r=Ln?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],o=Ln?80:120,e=process.env.CI==="true",i,s,n=!1,a="",c,l=performance.now(),f=(y)=>{let $=y>1?"Something went wrong":"Canceled";n&&L($,y)},m=()=>f(2),p=()=>f(1),d=()=>{process.on("uncaughtExceptionMonitor",m),process.on("unhandledRejection",m),process.on("SIGINT",p),process.on("SIGTERM",p),process.on("exit",f)},u=()=>{process.removeListener("uncaughtExceptionMonitor",m),process.removeListener("unhandledRejection",m),process.removeListener("SIGINT",p),process.removeListener("SIGTERM",p),process.removeListener("exit",f)},w=()=>{if(c===void 0)return;e&&process.stdout.write(`
|
|
38
38
|
`);let y=c.split(`
|
|
39
|
-
`);process.stdout.write(
|
|
40
|
-
`);let $=0,
|
|
41
|
-
`):process.stdout.write(`${
|
|
42
|
-
`),
|
|
43
|
-
${d}`});if(
|
|
39
|
+
`);process.stdout.write(xn.cursor.move(-999,y.length-1)),process.stdout.write(xn.erase.down(y.length))},T=(y)=>y.replace(/\.+$/,""),U=(y)=>{let $=(performance.now()-y)/1000,k=Math.floor($/60),B=Math.floor($%60);return k>0?`[${k}m ${B}s]`:`[${B}s]`},b=(y="")=>{n=!0,i=gt(),a=T(y),l=performance.now(),process.stdout.write(`${g.default.gray(O)}
|
|
40
|
+
`);let $=0,k=0;d(),s=setInterval(()=>{if(e&&a===c)return;w(),c=a;let B=g.default.magenta(r[$]);if(e)process.stdout.write(`${B} ${a}...`);else if(t==="timer")process.stdout.write(`${B} ${a} ${U(l)}`);else{let J=".".repeat(Math.floor(k)).slice(0,3);process.stdout.write(`${B} ${a}${J}`)}$=$+1<r.length?$+1:0,k=k<r.length?k+0.125:0},o)},L=(y="",$=0)=>{n=!1,clearInterval(s),w();let k=$===0?g.default.green(Bn):$===1?g.default.red(dt):g.default.red(bt);a=T(y??a),t==="timer"?process.stdout.write(`${k} ${a} ${U(l)}
|
|
41
|
+
`):process.stdout.write(`${k} ${a}
|
|
42
|
+
`),u(),i()};return{start:b,stop:L,message:(y="")=>{a=T(y??a)}}},Et=async(t,r)=>{let o={},e=Object.keys(t);for(let i of e){let s=t[i],n=await s({results:o})?.catch((a)=>{throw a});if(typeof r?.onCancel=="function"&&C(n)){o[i]="canceled",r.onCancel({results:o});continue}o[i]=n}return o};var Xr=!process.env.NO_COLOR&&(process.env.FORCE_COLOR||process.stdout.isTTY),_r=["blue","cyan","gray","green","magenta","red","white","yellow"],Ar=["bold","dim","italic","underline","reset"],Ot={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",reset:"\x1B[0m",underline:"\x1B[4m"},Ur={"\x1B[30m":"\x1B[90m","\x1B[31m":"\x1B[91m","\x1B[32m":"\x1B[92m","\x1B[33m":"\x1B[93m","\x1B[34m":"\x1B[94m","\x1B[35m":"\x1B[95m","\x1B[36m":"\x1B[96m","\x1B[37m":"\x1B[97m"};function jn(t){return(r)=>Xr?`${t}${r}${Ot.reset}`:r}function Rt({bright:t=!1,color:r}){let o=Bun.color(r,"ansi");if(!o)return"";return t?Ur[o]||o:o}var qr=_r.reduce((t,r)=>{return t[r]=jn(Rt({color:r})),t[`${r}Bright`]=jn(Rt({bright:!0,color:r})),t},{}),Hr=Ar.reduce((t,r)=>{return t[r]=jn(Ot[r]),t},{}),h={...qr,...Hr};var R=({prefix:t="",level:r=process.env.DEBUG?0:1}={})=>{function o(...a){if(r<=0){let c=a.join(" ");console.log($n({level:h.dim("DEBUG"),message:c,prefix:t}))}}function e(...a){if(r<=1){let c=a.join(" ");console.info($n({level:h.cyan("INFO "),message:c,prefix:t}))}}function i(...a){if(r<=2){let c=a.join(" ");console.warn($n({level:h.yellow("WARN "),message:c,prefix:t}))}}function s(...a){if(r<=3){let c=a.join(" ");console.error($n({level:h.red("ERROR"),message:c,prefix:t}))}}function n(a){return R({level:r,prefix:`${t}:${a}`})}return{child:n,debug:o,error:s,info:e,warn:i}},Wn=R();function $n({prefix:t,level:r,message:o}){let e=new Date().toISOString().split("T")[1]?.split(".")[0]||"",i=t?`[${t}] `:"";return`${h.dim(e||"")} ${r} ${i}${o}`}var de=R({prefix:"cli-core"}).child("error");var I=new Uint32Array(65536),Lr=(t,r)=>{let o=t.length,e=r.length,i=1<<o-1,s=-1,n=0,a=o,c=o;while(c--)I[t.charCodeAt(c)]|=1<<c;for(c=0;c<e;c++){let l=I[r.charCodeAt(c)],f=l|n;if(l|=(l&s)+s^s,n|=~(l|s),s&=l,n&i)a++;if(s&i)a--;n=n<<1|1,s=s<<1|~(f|n),n&=f}c=o;while(c--)I[t.charCodeAt(c)]=0;return a},Br=(t,r)=>{let o=r.length,e=t.length,i=[],s=[],n=Math.ceil(o/32),a=Math.ceil(e/32);for(let u=0;u<n;u++)s[u]=-1,i[u]=0;let c=0;for(;c<a-1;c++){let u=0,w=-1,T=c*32,U=Math.min(32,e)+T;for(let b=T;b<U;b++)I[t.charCodeAt(b)]|=1<<b;for(let b=0;b<o;b++){let L=I[r.charCodeAt(b)],y=s[b/32|0]>>>b&1,$=i[b/32|0]>>>b&1,k=L|u,B=((L|$)&w)+w^w|L|$,J=u|~(B|w),pn=w&B;if(J>>>31^y)s[b/32|0]^=1<<b;if(pn>>>31^$)i[b/32|0]^=1<<b;J=J<<1|y,pn=pn<<1|$,w=pn|~(k|J),u=J&k}for(let b=T;b<U;b++)I[t.charCodeAt(b)]=0}let l=0,f=-1,m=c*32,p=Math.min(32,e-m)+m;for(let u=m;u<p;u++)I[t.charCodeAt(u)]|=1<<u;let d=e;for(let u=0;u<o;u++){let w=I[r.charCodeAt(u)],T=s[u/32|0]>>>u&1,U=i[u/32|0]>>>u&1,b=w|l,L=((w|U)&f)+f^f|w|U,y=l|~(L|f),$=f&L;if(d+=y>>>e-1&1,d-=$>>>e-1&1,y>>>31^T)s[u/32|0]^=1<<u;if($>>>31^U)i[u/32|0]^=1<<u;y=y<<1|T,$=$<<1|U,f=$|~(b|y),l=y&b}for(let u=m;u<p;u++)I[t.charCodeAt(u)]=0;return d},St=(t,r)=>{if(t.length<r.length){let o=r;r=t,t=o}if(r.length===0)return t.length;if(t.length<=32)return Lr(t,r);return Br(t,r)};function Ct(t,r,o=3){return r.map((s)=>({distance:St(t.toLowerCase(),s.toLowerCase()),option:s})).filter(({distance:s})=>s<=Math.max(3,t.length/2)).sort((s,n)=>s.distance-n.distance).slice(0,o).map(({option:s})=>s)}function Tt(t,r){return r[t.toLowerCase()]||null}var kt=R({prefix:"cli-core"}).child("graceful");async function nn(t,r={}){let{fallback:o,logLevel:e="warn",message:i="Operation failed gracefully"}=r;try{return await t()}catch(s){let n=s instanceof Error?s.message:String(s);if(kt[e](`${i}: ${n}`),o)try{await o()}catch(a){kt.error(`Fallback also failed: ${a instanceof Error?a.message:String(a)}`)}return}}var Ir={backoffMultiplier:2,initialDelay:1000,maxAttempts:3,maxDelay:30000,onRetry:(t,r)=>{Wn.warn(`Retry attempt ${t}: ${r.message}`)},retryableErrors:["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","rate limit","429","503","502","504","npm ERR!","EPUBLISHCONFLICT"]};async function an(t,r={}){let o={...Ir,...r},e=new Error("Operation failed");for(let i=1;i<=o.maxAttempts;i++)try{return await t()}catch(s){if(e=s instanceof Error?s:new Error(String(s)),!o.retryableErrors.some((c)=>e.message.toLowerCase().includes(c.toLowerCase()))||i===o.maxAttempts)throw e;o.onRetry(i,e);let a=Math.min(o.initialDelay*o.backoffMultiplier**(i-1),o.maxDelay);await new Promise((c)=>setTimeout(c,a))}throw e}var q=(t)=>{return t.map=(r)=>q((o)=>r(t(o))),t.or=(r)=>q((o)=>{try{return t(o)}catch(e){return r(o)}}),t},wn=()=>"bad banditype"();var Nt=(t)=>q((r)=>t.includes(r)?r:wn()),En=(t)=>q((r)=>typeof r===typeof t?r:wn()),cn=()=>En(""),vt=()=>En(0),Pt=()=>En(!0);var Gt=()=>En();var Mt=(t)=>q((r)=>r instanceof t?r:wn()),zn=(t)=>Mt(Object).map((r)=>{let o={};for(let e in r){let i=t(r[e]);i!==void 0&&(o[e]=i)}return o}),tn=(t)=>Mt(Object).map((r)=>{let o={};for(let e in t){let i=t[e](r[e]);i!==void 0&&(o[e]=i)}return o});function jr(t,r){return q((o)=>{try{return t(o)}catch{try{return r(o)}catch{throw new Error("No matching schema in union")}}})}function Y(t,r){return(o)=>{if(o===void 0)return r;return t(o)}}function Xt(){return q((t)=>{let r=vt()(t);if(!Number.isInteger(r)||r<=0)throw new Error("Must be a positive integer");return r})}function _t(){return q((t)=>{let r=cn()(t);try{return new URL(r),r}catch{throw new Error("Must be a valid URL")}})}function At(t,r){return q((o)=>{let e=cn()(o);if(!t.test(e))throw new Error(r||`Must match pattern ${t}`);return e})}function fn(t){return{parse(r){try{return t(r)}catch(o){throw new Error(o instanceof Error?o.message:"Validation failed")}},safeParse(r){try{return{data:t(r),success:!0}}catch(o){return{error:o instanceof Error?o:new Error("Validation failed"),success:!1}}},validator:t}}function Q(){return jr(Gt(),cn())}function Z(t){return Y(cn(),t)}function rn(t){return Y(Pt(),t)}function Rn(t,r){return Y(Nt(t),r)}import{parseArgs as to}from"util";var{$:M}=globalThis.Bun;import{join as Lt}from"path";var{$:Ht}=globalThis.Bun;import{tmpdir as Wr}from"os";var Ut={MACHINES_DIR:"machines",TEMP_DIR:Wr()};var zr=tn({directory:Z("./gh-runners"),labels:Q(),name:Z("runner"),numberOfMachines:Y(Xt(),1),os:Rn(["osx","linux","windows"],"osx"),overwrite:rn(!1),run:rn(!1),runnerGroup:Q(),url:Q()}),Kr=fn(zr),qt=fn(tn({defaultProfile:Q(),profiles:zn(Kr.validator)}));var Jr=["hydra.json",".hydra.json","hydra.toml",".hydra.toml"];async function Yr(t=process.cwd()){for(let r of Jr){let o=Lt(t,r);if(await Bun.file(o).exists())return o}return null}async function z(t){let r=t?.configPath||await Yr();if(!r)return null;let o=Bun.file(r);if(!await o.exists())return null;try{let e=await o.text(),i=r.endsWith(".toml")?await Qr(e):JSON.parse(e);return qt.parse(i)}catch(e){if(e instanceof Error)throw new Error(`Invalid config file: ${e.message}`);throw e}}async function K(t,r){if(!t)return null;let o=r||t.defaultProfile;if(!o)return null;return t.profiles[o]||null}async function Qr(t){let r=Lt(Ut.TEMP_DIR,`hydra-config-${Date.now()}.toml`);await Bun.write(r,t);try{let o=await import(r);return await Ht`rm -f ${r}`.quiet(),o.default}catch(o){throw await Ht`rm -f ${r}`.quiet(),new Error(`Failed to parse TOML configuration: ${o}`)}}function mn(){let t=import.meta.path,r=t.substring(0,t.lastIndexOf("/"));return r.substring(0,r.lastIndexOf("/"))}var Zr=tn({directory:Z(`${process.cwd()}/gh-runners`),labels:Q(),name:Z("runner"),numberOfMachines:Y(At(/^\d+$/,"Number of machines must be a positive integer"),"1"),os:Rn(["osx","linux","windows"],"osx"),overwrite:rn(!1),run:rn(!1),token:Z(process.env.GITHUB_PERSONAL_ACCESS_TOKEN??""),url:_t()}),Ye=fn(Zr);var V=R({prefix:"WorkerManager"}),P=new Set,Bt=!1;function Vr(){if(Bt)return;Bt=!0;let t=()=>{if(P.size>0)V.info("Cleaning up workers...");It()};process.on("exit",t),process.on("SIGINT",t),process.on("SIGTERM",t),process.on("uncaughtException",(r)=>{V.error("Uncaught exception:",r),t(),process.exit(1)})}function Fr(t){P.add(t),V.debug(`Worker added. Total workers: ${P.size}`),t.addEventListener("exit",()=>{P.delete(t),V.debug(`Worker exited. Remaining workers: ${P.size}`)})}function Dr(t){if(P.has(t))t.terminate(),P.delete(t),V.debug(`Worker removed. Remaining workers: ${P.size}`)}function It(){if(P.size>0){V.info(`Terminating ${P.size} workers...`);for(let t of P)try{t.terminate()}catch(r){V.error("Failed to terminate worker:",r)}P.clear()}}function no(){return P.size}Vr();var On={add:Fr,remove:Dr,get size(){return no()},terminateAll:It};var G=R({prefix:"createMachines"});async function jt(){let t=await oo(),{overwrite:r,directory:o,numberOfMachines:e,os:i,run:s,name:n,labels:a,runnerGroup:c}=t,{token:l,url:f}=t;if(!f)throw new Error("URL (-u) parameter is required");if(!l){let d=ro(f),u=await W({message:`No token provided. Would you like to open GitHub to get a runner token?
|
|
43
|
+
${d}`});if(C(u)||!u)throw new Error("Token is required to create runners");G.info("Opening GitHub runner settings..."),await M`open ${d}`.quiet();let w=await v({message:"Enter the runner registration token:",placeholder:"AXXXXXXXXXXXXXXXXXXXXXXXXX",validate:(T)=>{if(!T||T.trim().length===0)return"Token is required";return}});if(C(w))throw new Error("Token is required to create runners");l=w.trim()}if(G.info(`Creating ${e} runners in ${o}`),G.debug(`OS: ${i}, Name: ${n}, Labels: ${a||"none"}`),await Bun.file(o).exists())if(r)G.warn(`Directory ${o} exists, removing...`),await M`rm -rf ${o}`;else throw new Error(`Directory ${o} already exists`);let p=await eo({directory:o,os:i});if(await io({directory:o,numberOfMachines:e,overwrite:r,runnerBase:p}),!s){G.info("Runners created but not started");return}so({directory:o,labels:a,name:n,numberOfMachines:e,runnerGroup:c,token:l,url:f})}function ro(t){try{let r=new URL(t),o=r.pathname.split("/").filter(Boolean);if(r.hostname==="github.com"||r.hostname==="www.github.com"){if(o[0]==="orgs"&&o[1])return`https://github.com/organizations/${o[1]}/settings/actions/runners/new`;else if(o.length>=2)return`https://github.com/${o[0]}/${o[1]}/settings/actions/runners/new`}else if(o[0]==="orgs"&&o[1])return`${r.origin}/organizations/${o[1]}/settings/actions/runners/new`;else if(o.length>=2)return`${r.origin}/${o[0]}/${o[1]}/settings/actions/runners/new`;return t}catch{return t}}async function oo(){let{values:t}=to({allowPositionals:!0,args:Bun.argv,options:{config:{short:"c",type:"string"},directory:{default:`${process.cwd()}/gh-runners`,short:"d",type:"string"},labels:{short:"l",type:"string"},name:{default:"runner",short:"n",type:"string"},numberOfMachines:{default:"1",short:"m",type:"string"},os:{default:"osx",short:"s",type:"string"},overwrite:{default:!1,short:"f",type:"boolean"},profile:{short:"p",type:"string"},run:{default:!1,short:"r",type:"boolean"},runnerGroup:{short:"g",type:"string"},token:{short:"t",type:"string"},url:{short:"u",type:"string"}},strict:!0}),r=await z({configPath:t.config}),o=await K(r,t.profile),e={directory:t.directory,labels:t.labels,name:t.name,numberOfMachines:t.numberOfMachines,os:t.os,overwrite:t.overwrite,run:t.run,runnerGroup:t.runnerGroup,token:t.token,url:t.url};if(o)return{directory:e.directory??o.directory??`${process.cwd()}/gh-runners`,labels:e.labels??o.labels,name:e.name??o.name??"runner",numberOfMachines:e.numberOfMachines??String(o.numberOfMachines)??"1",os:e.os??o.os??"osx",overwrite:e.overwrite??o.overwrite??!1,run:e.run??o.run??!1,runnerGroup:e.runnerGroup??o.runnerGroup,token:e.token,url:e.url??o.url};return{directory:e.directory,labels:e.labels,name:e.name,numberOfMachines:e.numberOfMachines,os:e.os,overwrite:e.overwrite,run:e.run,runnerGroup:e.runnerGroup,token:e.token,url:e.url}}async function eo({directory:t,os:r}){let o=G.child("download");o.info(`Fetching latest runner version for ${r}...`);let e=await an(async()=>(await M`curl -Ls -o /dev/null -w "%{url_effective}" https://github.com/actions/runner/releases/latest`).text(),{onRetry:(l,f)=>{o.warn(`Retrying GitHub API call (attempt ${l}): ${f.message}`)}}),s=(await M`basename ${e}`).text().trim().replace("v",""),n=`actions-runner-${r}-x64-${s}.tar.gz`,a=`https://github.com/actions/runner/releases/download/v${s}/${n}`;if(o.debug(`Runner version: ${s}`),o.debug(`Download URL: ${a}`),await M`mkdir -p ${t}`,await M`mkdir -p ${t}/machines`,!await Bun.file(`${t}/${n}`).exists())o.info("Downloading runner image..."),await an(async()=>await M`curl -o ${t}/${n} -L ${a}`,{maxAttempts:5,onRetry:(l,f)=>{o.warn(`Retrying runner download (attempt ${l}): ${f.message}`)}}),o.info("Download complete");else o.info("Runner image already exists, skipping download");return n}async function io({overwrite:t,numberOfMachines:r,directory:o,runnerBase:e}){let i=G.child("extract"),s=Number(r),n=(()=>{try{let f=Bun.spawnSync(["nproc"]);return Number.parseInt(f.stdout.toString().trim(),10)||4}catch{try{let f=Bun.spawnSync(["sysctl","-n","hw.ncpu"]);return Number.parseInt(f.stdout.toString().trim(),10)||4}catch{return 4}}})(),a=Math.min(Math.max(2,Math.floor(n/2)),s,8);i.info(`Extracting ${s} runners with concurrency of ${a}`);let c=Array.from({length:s},(f,m)=>m+1).map((f)=>({execute:async()=>{let m=`${o}/machines/${f}`;if(await Bun.file(m).exists())if(t)i.debug(`Machine ${f} already exists, removing...`),await M`rm -rf ${m}`;else{i.debug(`Machine ${f} already exists, skipping...`);return}await M`mkdir -p ${m}`,await M`tar xzf ${e} -C ${m.replace(`${o}/`,"")}`.cwd(o);let d=`${mn()}/src/runner`;await M`cp -R ${d}/hooks ${m}`,await M`cp -R ${d}/.runner-env ${m}/.runner-env`,i.debug(`Machine ${f} extracted successfully`)},runnerIndex:f})),l=[];for(let f=0;f<c.length;f+=a){let m=c.slice(f,f+a),p=await Promise.allSettled(m.map((d)=>d.execute()));for(let[d,u]of p.entries())if(u.status==="rejected")throw i.error(`Failed to extract runner ${m[d]?.runnerIndex}: ${u.reason}`),u.reason;l.push(...p)}i.info(`Successfully extracted ${s} runners`)}function so({directory:t,numberOfMachines:r,token:o,url:e,name:i,labels:s,runnerGroup:n}){G.info(`Starting ${r} runners...`);for(let a=1;a<=Number(r);a++){let c=`${mn()}/src/runner-worker.ts`,l=`${i}-${a}`,f=new Worker(c,{name:l,ref:!0});f.addEventListener("open",()=>{G.info(`Worker ${l} started`),f.postMessage({index:a,labels:s,machineCwd:`${t}/machines/${a}`,name:i,runnerGroup:n,token:o,url:e})}),f.addEventListener("message",({data:m})=>{let p=m.type==="error"?"error":"info";G[p](`${l}: ${m.message}`)}),f.addEventListener("error",(m)=>{G.error(`Worker ${l} error:`,m)}),f.addEventListener("exit",(m)=>{G.info(`Worker ${l} exited with code ${m}`)}),On.add(f)}G.info("All workers started. Press Ctrl+C to stop all machines")}var Wt="0.3.5";var zt={create:`
|
|
44
44
|
hydra create - Create and register new GitHub runner machines
|
|
45
45
|
|
|
46
46
|
USAGE
|
|
@@ -151,34 +151,24 @@ EXAMPLES
|
|
|
151
151
|
|
|
152
152
|
# Status using profile
|
|
153
153
|
hydra status -p production
|
|
154
|
-
`};function
|
|
155
|
-
`).map((e)=>{if(e.startsWith("hydra"))return
|
|
154
|
+
`};function ln(t){if(t&&zt[t]){let o=zt[t].split(`
|
|
155
|
+
`).map((e)=>{if(e.startsWith("hydra"))return h.bold(e);if(e==="USAGE"||e==="OPTIONS"||e==="EXAMPLES")return h.bold(e);if(e.startsWith(" -")){let i=e.match(/^(\s+-\w,\s--\w+)\s+(.+)$/);if(i){let[,s="",n=""]=i,a=n.replace("(required)",h.red("(required)")).replace(/\(default: ([^)]+)\)/g,(c,l)=>h.dim(`(default: ${l})`)).replace(/\[boolean\]/g,h.cyan("[boolean]")).replace(/\[string\]/g,h.green("[string]")).replace(/\[number\]/g,h.magenta("[number]"));return` ${h.yellow(s.padEnd(26))} ${a}`}}if(e.startsWith(" # "))return h.dim(e);if(e.startsWith(" hydra"))return` ${h.cyan(e.trim())}`;return e}).join(`
|
|
156
156
|
`);console.info(o);return}console.info(`
|
|
157
|
-
${
|
|
157
|
+
${h.bold(`Hydra@${Wt} - GitHub self-hosted runner manager`)}
|
|
158
158
|
|
|
159
|
-
${
|
|
159
|
+
${h.bold("USAGE")}
|
|
160
160
|
hydra <command> [options]
|
|
161
161
|
|
|
162
|
-
${
|
|
163
|
-
${
|
|
164
|
-
${
|
|
165
|
-
${
|
|
166
|
-
${
|
|
167
|
-
${
|
|
168
|
-
${
|
|
169
|
-
|
|
170
|
-
Use ${
|
|
171
|
-
`)}import{resolve as
|
|
172
|
-
`));
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
Opening GitHub settings: ${p.cyan(n)}`),await F(async()=>{await In`open ${n}`.quiet()},{fallback:async()=>{await F(async()=>{await In`xdg-open ${n}`.quiet()},{fallback:()=>{console.info(`
|
|
176
|
-
Please open the URL manually to add a new runner token.`)},logLevel:"info",message:"Alternative browser open method also failed"})},logLevel:"info",message:"Could not open browser automatically"})}function ao(){let{values:t}=so({allowPositionals:!0,args:Bun.argv,options:{toml:{default:!1,short:"t",type:"boolean"}},strict:!0});return t}import{parseArgs as co}from"util";var{$:V}=globalThis.Bun;var jn=_({prefix:"removeMachines"});async function jt(){let t=await fo(),{directory:r,numberOfMachines:o,force:e}=t,{token:s,url:i}=t,n=`${r}/machines`;if(!await Bun.file(n).exists())throw new Error(`Machines directory not found at ${n}. Nothing to remove.`);if(!s&&!e){if(!i)throw console.warn(p.yellow("\u26A0\uFE0F No token or URL provided. Runners will not be unregistered from GitHub.")),console.warn(p.yellow("Use --force to remove runners without unregistering them.")),new Error("Token (-t) and URL (-u) parameters are required or use --force");let c=go(i),l=await j({message:`No token provided. Would you like to open GitHub to get a runner token for unregistration?
|
|
177
|
-
${c}`});if(S(l)||!l)throw console.warn(p.yellow("Use --force to remove runners without unregistering them.")),new Error("Token is required to unregister runners (or use --force)");jn.info("Opening GitHub runner settings..."),await V`open ${c}`.quiet();let f=await N({message:"Enter the runner removal token:",placeholder:"AXXXXXXXXXXXXXXXXXXXXXXXXX",validate:(m)=>{if(!m||m.trim().length===0)return"Token is required";return}});if(S(f))throw console.warn(p.yellow("Use --force to remove runners without unregistering them.")),new Error("Token is required to unregister runners (or use --force)");s=f.trim()}if(s&&i)console.info(p.cyan("Unregistering runners from GitHub...")),await mo({directory:r,numberOfMachines:o,token:s});else if(!e)throw console.warn(p.yellow("\u26A0\uFE0F No token or URL provided. Runners will not be unregistered from GitHub.")),console.warn(p.yellow("Use --force to remove runners without unregistering them.")),new Error("Token (-t) and URL (-u) parameters are required or use --force");await lo({directory:r,numberOfMachines:o}),console.info(p.green("\u2713 Runners successfully removed"))}async function fo(){let{values:t}=co({allowPositionals:!0,args:Bun.argv,options:{config:{short:"c",type:"string"},directory:{default:`${process.cwd()}/gh-runners`,short:"d",type:"string"},force:{default:!1,short:"f",type:"boolean"},numberOfMachines:{default:"1",short:"m",type:"string"},profile:{short:"p",type:"string"},token:{short:"t",type:"string"},url:{short:"u",type:"string"}},strict:!0}),r=await W({configPath:t.config}),o=await z(r,t.profile),e={directory:t.directory,force:t.force,numberOfMachines:t.numberOfMachines,token:t.token,url:t.url};if(o)return{directory:e.directory??o.directory??`${process.cwd()}/gh-runners`,force:e.force,numberOfMachines:e.numberOfMachines??String(o.numberOfMachines)??"1",token:e.token,url:e.url??o.url};return e}async function mo({directory:t,numberOfMachines:r,token:o}){let e=jn.child("unregister"),s=Number(r),i=(()=>{try{let g=Bun.spawnSync(["nproc"]);return Number.parseInt(g.stdout.toString().trim(),10)||4}catch{try{let g=Bun.spawnSync(["sysctl","-n","hw.ncpu"]);return Number.parseInt(g.stdout.toString().trim(),10)||4}catch{return 4}}})(),n=Math.min(Math.max(2,Math.floor(i/2)),s,8);e.info(`Unregistering ${s} runners with concurrency of ${n}`);let a=Array.from({length:s},(g,d)=>d+1).map((g)=>({execute:async()=>{let d=`${t}/machines/${g}`;if(!await Bun.file(d).exists())return e.debug(`Machine ${g} doesn't exist, skipping...`),{runnerIndex:g,status:"skipped"};try{return e.debug(`Unregistering machine ${g}...`),await V`${d}/config.sh remove --token ${o}`.quiet(),e.info(`Successfully unregistered machine ${g} from GitHub`),{runnerIndex:g,status:"success"}}catch(w){return e.warn(`Unable to unregister machine ${g}: ${w}`),{error:w,runnerIndex:g,status:"failed"}}},runnerIndex:g})),c=[];for(let g=0;g<a.length;g+=n){let d=a.slice(g,g+n),h=await Promise.allSettled(d.map((w)=>w.execute()));c.push(...h)}let l=c.filter((g)=>g.status==="fulfilled"&&g.value?.status==="success").length,f=c.filter((g)=>g.status==="fulfilled"&&g.value?.status==="failed").length,m=c.filter((g)=>g.status==="fulfilled"&&g.value?.status==="skipped").length;e.info(`Unregistration complete: ${l} successful, ${f} failed, ${m} skipped`)}async function lo({directory:t,numberOfMachines:r}){let o=jn.child("removeDirectories"),e=Number(r),s=Array.from({length:e},(c,l)=>l+1).map((c)=>({execute:async()=>{let l=`${t}/machines/${c}`;if(!await Bun.file(l).exists())return{runnerIndex:c,status:"skipped"};try{return await V`rm -rf ${l}`.quiet(),o.debug(`Removed machine ${c} directory`),{runnerIndex:c,status:"success"}}catch(m){return o.error(`Error removing machine ${c} directory: ${m}`),{error:m,runnerIndex:c,status:"failed"}}},runnerIndex:c})),i=await Promise.allSettled(s.map((c)=>c.execute())),n=i.filter((c)=>c.status==="fulfilled"&&c.value?.status==="success").length,a=i.filter((c)=>c.status==="fulfilled"&&c.value?.status==="failed").length;if(o.info(`Directory removal complete: ${n} removed, ${a} failed`),a>0)throw new Error(`Failed to remove ${a} runner directories`);try{let c=`${t}/machines`;if(!(await V`ls -A ${c}`.text()).trim()){if(await V`rm -rf ${c}`.quiet(),!(await V`ls -A ${t}`.text()).trim())await V`rm -rf ${t}`.quiet();console.info(p.green("\u2713 Removed empty directories"))}}catch(c){}}function go(t){try{let r=new URL(t),o=r.pathname.split("/").filter(Boolean);if(r.hostname==="github.com"||r.hostname==="www.github.com"){if(o[0]==="orgs"&&o[1])return`https://github.com/organizations/${o[1]}/settings/actions/runners`;else if(o.length>=2)return`https://github.com/${o[0]}/${o[1]}/settings/actions/runners`}else if(o[0]==="orgs"&&o[1])return`${r.origin}/organizations/${o[1]}/settings/actions/runners`;else if(o.length>=2)return`${r.origin}/${o[0]}/${o[1]}/settings/actions/runners`;return t}catch{return t}}import{parseArgs as po}from"util";var{$:uo}=globalThis.Bun;var q=_({prefix:"runMachines"});async function Wt(){let t=await ho(),{directory:r,numberOfMachines:o,name:e,labels:s,runnerGroup:i}=t,{token:n,url:a}=t;if(!a)throw new Error("URL (-u) parameter is required");if(!n){let l=yo(a),f=await j({message:`No token provided. Would you like to open GitHub to get a runner token?
|
|
178
|
-
${l}`});if(S(f)||!f)throw new Error("Token is required to run machines");q.info("Opening GitHub runner settings..."),await uo`open ${l}`.quiet();let m=await N({message:"Enter the runner registration token:",placeholder:"AXXXXXXXXXXXXXXXXXXXXXXXXX",validate:(g)=>{if(!g||g.trim().length===0)return"Token is required";return}});if(S(m))throw new Error("Token is required to run machines");n=m.trim()}if(q.info(`Starting ${o} runners from ${r}`),q.debug(`Name: ${e}, Labels: ${s||"none"}`),!await Bun.file(`${r}/machines`).exists())throw new Error(`Machines directory not found at ${r}/machines. Run 'hydra create' first.`);await bo({directory:r,labels:s,name:e,numberOfMachines:o,runnerGroup:i,token:n,url:a})}async function ho(){let{values:t}=po({allowPositionals:!0,args:Bun.argv,options:{config:{short:"c",type:"string"},directory:{default:`${process.cwd()}/gh-runners`,short:"d",type:"string"},labels:{short:"l",type:"string"},name:{default:"runner",short:"n",type:"string"},numberOfMachines:{default:"1",short:"m",type:"string"},profile:{short:"p",type:"string"},runnerGroup:{short:"g",type:"string"},token:{short:"t",type:"string"},url:{short:"u",type:"string"}},strict:!0}),r=await W({configPath:t.config}),o=await z(r,t.profile),e={directory:t.directory,labels:t.labels,name:t.name,numberOfMachines:t.numberOfMachines,runnerGroup:t.runnerGroup,token:t.token,url:t.url};if(o)return{directory:e.directory??o.directory??`${process.cwd()}/gh-runners`,labels:e.labels??o.labels,name:e.name??o.name??"runner",numberOfMachines:e.numberOfMachines??String(o.numberOfMachines)??"1",runnerGroup:e.runnerGroup??o.runnerGroup,token:e.token,url:e.url??o.url};return e}async function bo({directory:t,numberOfMachines:r,token:o,url:e,name:s,labels:i,runnerGroup:n}){q.info(`Starting ${r} workers...`);for(let a=1;a<=Number(r);a++){let c=`${t}/machines/${a}`;if(!await Bun.file(c).exists()){q.warn(`Machine ${a} doesn't exist, skipping...`);continue}let f=`${an()}/src/runner-worker.ts`,m=`${s}-${a}`,g=new Worker(f,{name:m,ref:!0});g.addEventListener("message",({data:d})=>{let h=d.type==="error"?"error":"info";q[h](`${m}: ${d.message}`)}),g.addEventListener("error",(d)=>{q.error(`Worker ${m} error:`,d)}),g.addEventListener("exit",(d)=>{q.info(`Worker ${m} exited with code ${d}`)}),g.postMessage({index:a,labels:i,machineCwd:c,name:s,runnerGroup:n,token:o,url:e}),q.info(`Worker ${m} starting...`),wn.add(g)}q.info("All workers started. Press Ctrl+C to stop all machines")}function yo(t){try{let r=new URL(t),o=r.pathname.split("/").filter(Boolean);if(r.hostname==="github.com"||r.hostname==="www.github.com"){if(o[0]==="orgs"&&o[1])return`https://github.com/organizations/${o[1]}/settings/actions/runners/new`;else if(o.length>=2)return`https://github.com/${o[0]}/${o[1]}/settings/actions/runners/new`}else if(o[0]==="orgs"&&o[1])return`${r.origin}/organizations/${o[1]}/settings/actions/runners/new`;else if(o.length>=2)return`${r.origin}/${o[0]}/${o[1]}/settings/actions/runners/new`;return t}catch{return t}}import{parseArgs as xo}from"util";var{$:$o}=globalThis.Bun;async function zt(){let t=await wo(),{directory:r,token:o,url:e,json:s}=t;if(!o||!e)throw new Error("Token (-t) and URL (-u) parameters are required");let i=yt();i.start("Fetching runner status...");try{let n=await Eo(r),a=await Ro(e,o),c=Oo(n,a);if(i.stop("Runner status fetched"),s)console.log(JSON.stringify(c,null,2));else So(c)}catch(n){throw i.stop("Failed to fetch runner status"),n}}async function wo(){let{values:t}=xo({allowPositionals:!0,args:Bun.argv,options:{config:{short:"c",type:"string"},directory:{default:`${process.cwd()}/gh-runners`,short:"d",type:"string"},json:{default:!1,short:"j",type:"boolean"},profile:{short:"p",type:"string"},token:{short:"t",type:"string"},url:{short:"u",type:"string"}},strict:!0}),r=await W({configPath:t.config}),o=await z(r,t.profile);return{directory:t.directory||o?.directory||`${process.cwd()}/gh-runners`,json:t.json,token:t.token,url:t.url||o?.url}}async function Eo(t){let r=`${t}/machines`;return await F(async()=>{return(await $o`ls ${r} 2>/dev/null || true`.quiet()).stdout.toString().trim().split(`
|
|
179
|
-
`).filter(Boolean)},{fallback:()=>{},logLevel:"debug",message:"No local runners found"})||[]}async function Ro(t,r){let o=t.match(/github\.com[:/]([^/]+)(?:\/([^/.]+))?/);if(!o)throw new Error("Invalid GitHub URL");let[,e,s]=o,i=s?`https://api.github.com/repos/${e}/${s}/actions/runners`:`https://api.github.com/orgs/${e}/actions/runners`;return on(async()=>{let n={Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${r}`},a=await fetch(i,{headers:n});if(!a.ok)throw new Error(`GitHub API error: ${a.status} ${a.statusText}`);return await a.json()},{onRetry:(n,a)=>{X.warn(`Retrying GitHub API call (attempt ${n}): ${a.message}`)}})}function Oo(t,r){let o=[],e=new Map(r.runners.map((s)=>[s.name,s]));for(let s of t){let i=`runner-${s}`,n=e.get(i);if(n)o.push({busy:n.busy,labels:n.labels.map((a)=>a.name),name:i,os:n.os,status:n.busy?"busy":n.status==="online"?"online":"offline"});else o.push({busy:!1,labels:[],name:i,os:"unknown",status:"offline"})}return o}function So(t){if(t.length===0){X.info("No runners found");return}console.log(`
|
|
180
|
-
${p.bold("Runner Status:")}`),console.log("\u2500".repeat(80));let r={busy:p.yellow,offline:p.red,online:p.green};for(let e of t){let s=r[e.status],i=e.status.toUpperCase().padEnd(7);console.log(`${s("\u25CF")} ${s(i)} ${p.cyan(e.name.padEnd(20))} ${p.dim(`OS: ${e.os.padEnd(10)}`)} ${e.labels.length>0?p.dim(`Labels: ${e.labels.join(", ")}`):""}`)}console.log("\u2500".repeat(80));let o={busy:t.filter((e)=>e.status==="busy").length,offline:t.filter((e)=>e.status==="offline").length,online:t.filter((e)=>e.status==="online").length,total:t.length};console.log(`
|
|
181
|
-
${p.bold("Summary:")} Total: ${o.total} | ${p.green(`Online: ${o.online}`)} | ${p.yellow(`Busy: ${o.busy}`)} | ${p.red(`Offline: ${o.offline}`)}
|
|
182
|
-
`)}var En=["init","create","run","remove","status","help"],Co={c:"create",ceate:"create",craete:"create",cretae:"create",del:"remove",delete:"remove",h:"help",i:"init",info:"status",initialise:"init",inti:"init",intialize:"init",list:"status",ls:"status",new:"create",r:"run",remvoe:"remove",rm:"remove",rmove:"remove",rnu:"run",runn:"run",s:"status",start:"run",stat:"status",stop:"remove",sttaus:"status",t:"troubleshoot"};async function To(){try{let[,,t,...r]=process.argv;if(!t||t==="--help"||t==="-h")cn(),process.exit(0);let o=t;if(!En.includes(t)){let e=Ot(t,Co);if(e&&En.includes(e))o=e,console.log(p.yellow(`Assuming you meant '${e}'
|
|
183
|
-
`))}if(!En.includes(o)){console.error(p.red(`Unknown command: ${t}`));let e=Rt(t,En);if(e.length>0){console.error(`
|
|
184
|
-
Did you mean one of these?`);for(let s of e)console.error(` ${p.cyan(s)}`);console.error()}cn(),process.exit(1)}if(r.includes("--help")||r.includes("-h"))cn(o),process.exit(0);switch(o){case"init":await It();break;case"create":await Ht();break;case"run":await Wt();break;case"remove":await jt();break;case"status":await zt();break;case"help":{let e=r[0];cn(e);break}default:throw new Error(`Unknown command: ${o}`)}process.exit(0)}catch(t){let r=t instanceof Error?t:new Error(String(t));X.error(r.message),process.exit(1)}}await To();
|
|
162
|
+
${h.bold("COMMANDS")}
|
|
163
|
+
${h.green("init")} Initialize a new Hydra configuration file
|
|
164
|
+
${h.green("create")} Create and register new GitHub runner machines
|
|
165
|
+
${h.green("run")} Start existing GitHub runner machines
|
|
166
|
+
${h.green("remove")} Remove GitHub runner machines
|
|
167
|
+
${h.green("status")} Check the status of GitHub runner machines
|
|
168
|
+
${h.green("help")} Show this help message
|
|
169
|
+
|
|
170
|
+
Use ${h.cyan("hydra <command> --help")} for more information about a command.
|
|
171
|
+
`)}import{resolve as co}from"path";import{parseArgs as fo}from"util";var{$:Kn}=globalThis.Bun;var F=R({prefix:"hydra"}).child("init");async function Kt(){let{toml:t}=lo(),r=t?"hydra.toml":"hydra.json",o=co(process.cwd(),r);if(await Bun.file(o).exists()){let m=await W({initialValue:!1,message:`Configuration file ${r} already exists. Overwrite?`});if(C(m)||!m)In("Configuration cancelled"),process.exit(0)}xt(h.cyan("\uD83D\uDE80 Hydra Configuration Setup")),F.info("This will create a configuration file with your runner settings."),F.info("You can always edit the file later or create additional profiles.");let i=await Et({profileName:()=>v({message:"Profile name?",placeholder:"default"}),directory:()=>v({defaultValue:"./gh-runners",message:"Directory to store runners?",placeholder:"./gh-runners"}),name:()=>v({defaultValue:"runner",message:"Runner name prefix?",placeholder:"runner"}),labels:({results:m})=>{let p=m.name||"runner";return v({defaultValue:p,message:"Runner labels (comma-separated)?",placeholder:p})},numberOfMachines:()=>v({defaultValue:"1",message:"Number of runner machines?",placeholder:"1",validate:(m)=>{let p=Number.parseInt(m,10);if(Number.isNaN(p)||p<1)return"Please enter a valid number greater than 0";return}}),url:()=>v({message:"GitHub repository or organization URL? (optional)",placeholder:"https://github.com/org/repo"})},{onCancel:()=>{In("Configuration cancelled"),process.exit(0)}}),{profileName:s,labels:n,numberOfMachines:a,...c}=i,l={defaultProfile:s,profiles:{[s]:{...c,labels:n,numberOfMachines:Number.parseInt(a,10),os:"osx",overwrite:!1,run:!1}}},f=JSON.stringify(l,null,2);if(await Bun.write(o,f),await nn(async()=>{await Kn`chmod 600 ${o}`.quiet()},{logLevel:"warn",message:"Could not set secure file permissions"}),$t(h.green(`\u2713 Configuration saved to ${r}`)),F.info("Example usage:"),F.info(` hydra create -p ${s} --token YOUR_TOKEN${i.url?"":" --url REPO_URL"}`),F.info("You can add more profiles by editing the configuration file."),i.url)await mo(i.url)}async function mo(t){let r=/github\.com[:/]([^/]+)(?:\/([^/.]+))?/,o=t.match(r);if(!o)return;let[,e,i]=o,n=`https://github.com/${i?`${e}/${i}`:`organizations/${e}`}/settings/actions/runners`;F.info(`Opening GitHub settings: ${n}`),await nn(async()=>{await Kn`open ${n}`.quiet()},{fallback:async()=>{await nn(async()=>{await Kn`xdg-open ${n}`.quiet()},{fallback:()=>{F.info("Please open the URL manually to add a new runner token.")},logLevel:"info",message:"Alternative browser open method also failed"})},logLevel:"info",message:"Could not open browser automatically"})}function lo(){let{values:t}=fo({allowPositionals:!0,args:Bun.argv,options:{toml:{default:!1,short:"t",type:"boolean"}},strict:!0});return t}import{parseArgs as po}from"util";var{$:D}=globalThis.Bun;var X=R({prefix:"hydra"}).child("remove");async function Jt(){let t=await go(),{directory:r,numberOfMachines:o,force:e}=t,{token:i,url:s}=t,n=`${r}/machines`;if(!await Bun.file(n).exists())throw new Error(`Machines directory not found at ${n}. Nothing to remove.`);if(!i&&!e){if(!s)throw X.warn("No token or URL provided. Runners will not be unregistered from GitHub."),X.warn("Use --force to remove runners without unregistering them."),new Error("Token (-t) and URL (-u) parameters are required or use --force");let c=bo(s),l=await W({message:`No token provided. Would you like to open GitHub to get a runner token for unregistration?
|
|
172
|
+
${c}`});if(C(l)||!l)throw X.warn("Use --force to remove runners without unregistering them."),new Error("Token is required to unregister runners (or use --force)");X.info("Opening GitHub runner settings..."),await D`open ${c}`.quiet();let f=await v({message:"Enter the runner removal token:",placeholder:"AXXXXXXXXXXXXXXXXXXXXXXXXX",validate:(m)=>{if(!m||m.trim().length===0)return"Token is required";return}});if(C(f))throw X.warn("Use --force to remove runners without unregistering them."),new Error("Token is required to unregister runners (or use --force)");i=f.trim()}if(i&&s)X.info("Unregistering runners from GitHub..."),await uo({directory:r,numberOfMachines:o,token:i});else if(!e)throw X.warn("No token or URL provided. Runners will not be unregistered from GitHub."),X.warn("Use --force to remove runners without unregistering them."),new Error("Token (-t) and URL (-u) parameters are required or use --force");await ho({directory:r,numberOfMachines:o}),X.info("Runners successfully removed")}async function go(){let{values:t}=po({allowPositionals:!0,args:Bun.argv,options:{config:{short:"c",type:"string"},directory:{default:`${process.cwd()}/gh-runners`,short:"d",type:"string"},force:{default:!1,short:"f",type:"boolean"},numberOfMachines:{default:"1",short:"m",type:"string"},profile:{short:"p",type:"string"},token:{short:"t",type:"string"},url:{short:"u",type:"string"}},strict:!0}),r=await z({configPath:t.config}),o=await K(r,t.profile),e={directory:t.directory,force:t.force,numberOfMachines:t.numberOfMachines,token:t.token,url:t.url};if(o)return{directory:e.directory??o.directory??`${process.cwd()}/gh-runners`,force:e.force,numberOfMachines:e.numberOfMachines??String(o.numberOfMachines)??"1",token:e.token,url:e.url??o.url};return e}async function uo({directory:t,numberOfMachines:r,token:o}){let e=X.child("unregister"),i=Number(r),s=(()=>{try{let p=Bun.spawnSync(["nproc"]);return Number.parseInt(p.stdout.toString().trim(),10)||4}catch{try{let p=Bun.spawnSync(["sysctl","-n","hw.ncpu"]);return Number.parseInt(p.stdout.toString().trim(),10)||4}catch{return 4}}})(),n=Math.min(Math.max(2,Math.floor(s/2)),i,8);e.info(`Unregistering ${i} runners with concurrency of ${n}`);let a=Array.from({length:i},(p,d)=>d+1).map((p)=>({execute:async()=>{let d=`${t}/machines/${p}`;if(!await Bun.file(d).exists())return e.debug(`Machine ${p} doesn't exist, skipping...`),{runnerIndex:p,status:"skipped"};try{return e.debug(`Unregistering machine ${p}...`),await D`${d}/config.sh remove --token ${o}`.quiet(),e.info(`Successfully unregistered machine ${p} from GitHub`),{runnerIndex:p,status:"success"}}catch(w){return e.warn(`Unable to unregister machine ${p}: ${w}`),{error:w,runnerIndex:p,status:"failed"}}},runnerIndex:p})),c=[];for(let p=0;p<a.length;p+=n){let d=a.slice(p,p+n),u=await Promise.allSettled(d.map((w)=>w.execute()));c.push(...u)}let l=c.filter((p)=>p.status==="fulfilled"&&p.value?.status==="success").length,f=c.filter((p)=>p.status==="fulfilled"&&p.value?.status==="failed").length,m=c.filter((p)=>p.status==="fulfilled"&&p.value?.status==="skipped").length;e.info(`Unregistration complete: ${l} successful, ${f} failed, ${m} skipped`)}async function ho({directory:t,numberOfMachines:r}){let o=X.child("removeDirectories"),e=Number(r),i=Array.from({length:e},(c,l)=>l+1).map((c)=>({execute:async()=>{let l=`${t}/machines/${c}`;if(!await Bun.file(l).exists())return{runnerIndex:c,status:"skipped"};try{return await D`rm -rf ${l}`.quiet(),o.debug(`Removed machine ${c} directory`),{runnerIndex:c,status:"success"}}catch(m){return o.error(`Error removing machine ${c} directory: ${m}`),{error:m,runnerIndex:c,status:"failed"}}},runnerIndex:c})),s=await Promise.allSettled(i.map((c)=>c.execute())),n=s.filter((c)=>c.status==="fulfilled"&&c.value?.status==="success").length,a=s.filter((c)=>c.status==="fulfilled"&&c.value?.status==="failed").length;if(o.info(`Directory removal complete: ${n} removed, ${a} failed`),a>0)throw new Error(`Failed to remove ${a} runner directories`);try{let c=`${t}/machines`;if(!(await D`ls -A ${c}`.text()).trim()){if(await D`rm -rf ${c}`.quiet(),!(await D`ls -A ${t}`.text()).trim())await D`rm -rf ${t}`.quiet();X.info("Removed empty directories")}}catch(c){}}function bo(t){try{let r=new URL(t),o=r.pathname.split("/").filter(Boolean);if(r.hostname==="github.com"||r.hostname==="www.github.com"){if(o[0]==="orgs"&&o[1])return`https://github.com/organizations/${o[1]}/settings/actions/runners`;else if(o.length>=2)return`https://github.com/${o[0]}/${o[1]}/settings/actions/runners`}else if(o[0]==="orgs"&&o[1])return`${r.origin}/organizations/${o[1]}/settings/actions/runners`;else if(o.length>=2)return`${r.origin}/${o[0]}/${o[1]}/settings/actions/runners`;return t}catch{return t}}import{parseArgs as yo}from"util";var{$:xo}=globalThis.Bun;var H=R({prefix:"runMachines"});async function Yt(){let t=await $o(),{directory:r,numberOfMachines:o,name:e,labels:i,runnerGroup:s}=t,{token:n,url:a}=t;if(!a)throw new Error("URL (-u) parameter is required");if(!n){let l=Eo(a),f=await W({message:`No token provided. Would you like to open GitHub to get a runner token?
|
|
173
|
+
${l}`});if(C(f)||!f)throw new Error("Token is required to run machines");H.info("Opening GitHub runner settings..."),await xo`open ${l}`.quiet();let m=await v({message:"Enter the runner registration token:",placeholder:"AXXXXXXXXXXXXXXXXXXXXXXXXX",validate:(p)=>{if(!p||p.trim().length===0)return"Token is required";return}});if(C(m))throw new Error("Token is required to run machines");n=m.trim()}if(H.info(`Starting ${o} runners from ${r}`),H.debug(`Name: ${e}, Labels: ${i||"none"}`),!await Bun.file(`${r}/machines`).exists())throw new Error(`Machines directory not found at ${r}/machines. Run 'hydra create' first.`);await wo({directory:r,labels:i,name:e,numberOfMachines:o,runnerGroup:s,token:n,url:a})}async function $o(){let{values:t}=yo({allowPositionals:!0,args:Bun.argv,options:{config:{short:"c",type:"string"},directory:{default:`${process.cwd()}/gh-runners`,short:"d",type:"string"},labels:{short:"l",type:"string"},name:{default:"runner",short:"n",type:"string"},numberOfMachines:{default:"1",short:"m",type:"string"},profile:{short:"p",type:"string"},runnerGroup:{short:"g",type:"string"},token:{short:"t",type:"string"},url:{short:"u",type:"string"}},strict:!0}),r=await z({configPath:t.config}),o=await K(r,t.profile),e={directory:t.directory,labels:t.labels,name:t.name,numberOfMachines:t.numberOfMachines,runnerGroup:t.runnerGroup,token:t.token,url:t.url};if(o)return{directory:e.directory??o.directory??`${process.cwd()}/gh-runners`,labels:e.labels??o.labels,name:e.name??o.name??"runner",numberOfMachines:e.numberOfMachines??String(o.numberOfMachines)??"1",runnerGroup:e.runnerGroup??o.runnerGroup,token:e.token,url:e.url??o.url};return e}async function wo({directory:t,numberOfMachines:r,token:o,url:e,name:i,labels:s,runnerGroup:n}){H.info(`Starting ${r} workers...`);for(let a=1;a<=Number(r);a++){let c=`${t}/machines/${a}`;if(!await Bun.file(c).exists()){H.warn(`Machine ${a} doesn't exist, skipping...`);continue}let f=`${mn()}/src/runner-worker.ts`,m=`${i}-${a}`,p=new Worker(f,{name:m,ref:!0});p.addEventListener("message",({data:d})=>{let u=d.type==="error"?"error":"info";H[u](`${m}: ${d.message}`)}),p.addEventListener("error",(d)=>{H.error(`Worker ${m} error:`,d)}),p.addEventListener("exit",(d)=>{H.info(`Worker ${m} exited with code ${d}`)}),p.postMessage({index:a,labels:s,machineCwd:c,name:i,runnerGroup:n,token:o,url:e}),H.info(`Worker ${m} starting...`),On.add(p)}H.info("All workers started. Press Ctrl+C to stop all machines")}function Eo(t){try{let r=new URL(t),o=r.pathname.split("/").filter(Boolean);if(r.hostname==="github.com"||r.hostname==="www.github.com"){if(o[0]==="orgs"&&o[1])return`https://github.com/organizations/${o[1]}/settings/actions/runners/new`;else if(o.length>=2)return`https://github.com/${o[0]}/${o[1]}/settings/actions/runners/new`}else if(o[0]==="orgs"&&o[1])return`${r.origin}/organizations/${o[1]}/settings/actions/runners/new`;else if(o.length>=2)return`${r.origin}/${o[0]}/${o[1]}/settings/actions/runners/new`;return t}catch{return t}}import{parseArgs as Ro}from"util";var{$:Oo}=globalThis.Bun;var on=R({prefix:"hydra"}).child("status");async function Qt(){let t=await So(),{directory:r,token:o,url:e,json:i}=t;if(!o||!e)throw new Error("Token (-t) and URL (-u) parameters are required");let s=wt();s.start("Fetching runner status...");try{let n=await Co(r),a=await To(e,o),c=ko(n,a);if(s.stop("Runner status fetched"),i)on.info(JSON.stringify(c,null,2));else No(c)}catch(n){throw s.stop("Failed to fetch runner status"),n}}async function So(){let{values:t}=Ro({allowPositionals:!0,args:Bun.argv,options:{config:{short:"c",type:"string"},directory:{default:`${process.cwd()}/gh-runners`,short:"d",type:"string"},json:{default:!1,short:"j",type:"boolean"},profile:{short:"p",type:"string"},token:{short:"t",type:"string"},url:{short:"u",type:"string"}},strict:!0}),r=await z({configPath:t.config}),o=await K(r,t.profile);return{directory:t.directory||o?.directory||`${process.cwd()}/gh-runners`,json:t.json,token:t.token,url:t.url||o?.url}}async function Co(t){let r=`${t}/machines`;return await nn(async()=>{return(await Oo`ls ${r} 2>/dev/null || true`.quiet()).stdout.toString().trim().split(`
|
|
174
|
+
`).filter(Boolean)},{fallback:()=>{},logLevel:"debug",message:"No local runners found"})||[]}async function To(t,r){let o=t.match(/github\.com[:/]([^/]+)(?:\/([^/.]+))?/);if(!o)throw new Error("Invalid GitHub URL");let[,e,i]=o,s=i?`https://api.github.com/repos/${e}/${i}/actions/runners`:`https://api.github.com/orgs/${e}/actions/runners`;return an(async()=>{let n={Accept:"application/vnd.github.v3+json",Authorization:`Bearer ${r}`},a=await fetch(s,{headers:n});if(!a.ok)throw new Error(`GitHub API error: ${a.status} ${a.statusText}`);return await a.json()},{onRetry:(n,a)=>{A.warn(`Retrying GitHub API call (attempt ${n}): ${a.message}`)}})}function ko(t,r){let o=[],e=new Map(r.runners.map((i)=>[i.name,i]));for(let i of t){let s=`runner-${i}`,n=e.get(s);if(n)o.push({busy:n.busy,labels:n.labels.map((a)=>a.name),name:s,os:n.os,status:n.busy?"busy":n.status==="online"?"online":"offline"});else o.push({busy:!1,labels:[],name:s,os:"unknown",status:"offline"})}return o}function No(t){if(t.length===0){A.info("No runners found");return}on.info("Runner Status:"),on.info("\u2500".repeat(80));let r={busy:h.yellow,offline:h.red,online:h.green};for(let e of t){let i=r[e.status],s=e.status.toUpperCase().padEnd(7);on.info(`${i("\u25CF")} ${i(s)} ${h.cyan(e.name.padEnd(20))} ${h.dim(`OS: ${e.os.padEnd(10)}`)} ${e.labels.length>0?h.dim(`Labels: ${e.labels.join(", ")}`):""}`)}on.info("\u2500".repeat(80));let o={busy:t.filter((e)=>e.status==="busy").length,offline:t.filter((e)=>e.status==="offline").length,online:t.filter((e)=>e.status==="online").length,total:t.length};on.info(`Summary: Total: ${o.total} | ${h.green(`Online: ${o.online}`)} | ${h.yellow(`Busy: ${o.busy}`)} | ${h.red(`Offline: ${o.offline}`)}`)}var Sn=["init","create","run","remove","status","help"],Cn=R({prefix:"hydra"}),vo={c:"create",ceate:"create",craete:"create",cretae:"create",del:"remove",delete:"remove",h:"help",i:"init",info:"status",initialise:"init",inti:"init",intialize:"init",list:"status",ls:"status",new:"create",r:"run",remvoe:"remove",rm:"remove",rmove:"remove",rnu:"run",runn:"run",s:"status",start:"run",stat:"status",stop:"remove",sttaus:"status",t:"troubleshoot"};async function Po(){try{let[,,t,...r]=process.argv;if(!t||t==="--help"||t==="-h")ln(),process.exit(0);let o=t;if(!Sn.includes(t)){let e=Tt(t,vo);if(e&&Sn.includes(e))o=e,Cn.warn(`Assuming you meant '${e}'`)}if(!Sn.includes(o)){Cn.error(`Unknown command: ${t}`);let e=Ct(t,Sn);if(e.length>0){Cn.error("Did you mean one of these?");for(let i of e)Cn.error(` ${i}`)}ln(),process.exit(1)}if(r.includes("--help")||r.includes("-h"))ln(o),process.exit(0);switch(o){case"init":await Kt();break;case"create":await jt();break;case"run":await Yt();break;case"remove":await Jt();break;case"status":await Qt();break;case"help":{let e=r[0];ln(e);break}default:throw new Error(`Unknown command: ${o}`)}process.exit(0)}catch(t){let r=t instanceof Error?t:new Error(String(t));A.error(r.message),process.exit(1)}}await Po();
|
package/package.json
CHANGED