gdx 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +300 -295
- package/dist/index.js +473 -412
- package/package.json +79 -76
package/dist/index.js
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import{createRequire as BF}from"node:module";var GF=Object.create;var{getPrototypeOf:$F,defineProperty:w5,getOwnPropertyNames:qF}=Object;var UF=Object.prototype.hasOwnProperty;var OZ=(Y,Z,Q)=>{Q=Y!=null?GF($F(Y)):{};let J=Z||!Y||!Y.__esModule?w5(Q,"default",{value:Y,enumerable:!0}):Q;for(let z of qF(Y))if(!UF.call(J,z))w5(J,z,{get:()=>Y[z],enumerable:!0});return J};var p0=(Y,Z)=>()=>(Z||Y((Z={exports:{}}).exports,Z),Z.exports);var L5=(Y,Z)=>{for(var Q in Z)w5(Y,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:(J)=>Z[Q]=()=>J})};var R=(Y,Z)=>()=>(Y&&(Z=Y(Y=0)),Z);var $Y=BF(import.meta.url);import{createRequire as VF}from"module";class xz{value;start;end;constructor(Y,Z,Q){this.value=Y,this.start=Z,this.end=Q}}class I5{TF;IDF;TF_IDF;constructor(Y){this.TF=Y}}class Ez{x;y;z;r;t;get unit(){return this.#Z}get dimension(){return this.#Q}#Z;#Q=0;constructor(Y,Z,Q=null){if(this.x=Y,this.y=Z,this.z=Q,Q)this.#Q=3;else if(Z)this.#Q=2;else if(Y)this.#Q=1}toPolarCoords(Y="r"){this.#Z=Y;let{r:Z,t:Q}=M.MathKit.toPolarCoords(this.x,this.y,Y);return this.r=Z,this.t=Q,this}toCartesianCoords(){if(!this.#Z&&this.x)return this;let{x:Y,y:Z}=M.MathKit.toCartesianCoords(this.r,this.t,this.#Z);return this.x=Y,this.y=Z,this}setUnit(Y){if(!Y||Y!="d"&&Y!="r")throw Error("unit must be 'r' or 'd', given: "+Y);if(this.#Z==Y)return;if(Y=="r")this.#Z=Y,this.t=M.MathKit.radians(this.t);else this.#Z=Y,this.t=M.MathKit.degrees(this.t)}}class Pz{constructor(Y,Z,Q,J,z,X,H){this.x=Y,this.y=Z,this.f=Q,this.ymid=J,this.iterations=z,this.events=H,this.msg=X}_at(Y,Z){function Q(F){return F*F}let J,z,X,H,W,K,$,G,U,B;return J=this.x[Z],z=this.x[Z+1],H=this.y[Z],W=this.y[Z+1],$=z-J,X=J+0.5*$,K=this.ymid[Z],G=this.f[Z]-H*(1/(J-X)+2/(J-z)),U=this.f[Z+1]-W*(1/(z-X)+2/(z-J)),B=[Q(Y-z)*(Y-X)/Q(J-z)/(J-X),Q(Y-J)*Q(Y-z)/Q(J-X)/Q(z-X),Q(Y-J)*(Y-X)/Q(z-J)/(z-X),(Y-J)*Q(Y-z)*(Y-X)/Q(J-z)/(J-X),(Y-z)*Q(Y-J)*(Y-X)/Q(J-z)/(z-X)],H*B[0]+K*B[1]+W*B[2]+G*B[3]+U*B[4]}at(Y){let Z,Q,J;if(typeof Y!=="number"){let X=Y.length,H=Array(X);for(Z=X-1;Z!==-1;--Z)H[Z]=this.at(Y[Z]);return H}let z=this.x;Z=0,Q=z.length-1;while(Q-Z>1)if(J=Math.floor(0.5*(Z+Q)),z[J]<=Y)Z=J;else Q=J;return this._at(Y,Z)}}class yY{value;index;type;constructor(Y,Z,Q=-1){this.value=Y,this.type=Z,this.index=Q}valueOf(){return this.value}toString(){return this.value.toString()}}class C1{type;UPID=null;callback;constructor(Y,Z,Q=null){if(Q)this.type=1,this.UPID=Q;else this.type=Y;this.callback=Z}}function MF(Y){return Y==null||typeof Y=="number"||typeof Y=="string"||typeof Y=="boolean"||Y instanceof ArrayBuffer||Y instanceof MessagePort||Y instanceof ReadableStream||Y instanceof WritableStream||Y instanceof TransformStream}var FF,T1,RF,vY,_5="[#*0-9]\\uFE0F?\\u20E3|©\\uFE0F?|[®\\u203C\\u2049\\u2122\\u2139\\u2194-\\u2199\\u21A9\\u21AA]\\uFE0F?|[\\u231A\\u231B]|[\\u2328\\u23CF]\\uFE0F?|[\\u23E9-\\u23EC]|[\\u23ED-\\u23EF]\\uFE0F?|\\u23F0|[\\u23F1\\u23F2]\\uFE0F?|\\u23F3|[\\u23F8-\\u23FA\\u24C2\\u25AA\\u25AB\\u25B6\\u25C0\\u25FB\\u25FC]\\uFE0F?|[\\u25FD\\u25FE]|[\\u2600-\\u2604\\u260E\\u2611]\\uFE0F?|[\\u2614\\u2615]|\\u2618\\uFE0F?|\\u261D(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|[\\u2620\\u2622\\u2623\\u2626\\u262A\\u262E\\u262F\\u2638-\\u263A\\u2640\\u2642]\\uFE0F?|[\\u2648-\\u2653]|[\\u265F\\u2660\\u2663\\u2665\\u2666\\u2668\\u267B\\u267E]\\uFE0F?|\\u267F|\\u2692\\uFE0F?|\\u2693|[\\u2694-\\u2697\\u2699\\u269B\\u269C\\u26A0]\\uFE0F?|\\u26A1|\\u26A7\\uFE0F?|[\\u26AA\\u26AB]|[\\u26B0\\u26B1]\\uFE0F?|[\\u26BD\\u26BE\\u26C4\\u26C5]|\\u26C8\\uFE0F?|\\u26CE|[\\u26CF\\u26D1\\u26D3]\\uFE0F?|\\u26D4|\\u26E9\\uFE0F?|\\u26EA|[\\u26F0\\u26F1]\\uFE0F?|[\\u26F2\\u26F3]|\\u26F4\\uFE0F?|\\u26F5|[\\u26F7\\u26F8]\\uFE0F?|\\u26F9(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\u26FA\\u26FD]|\\u2702\\uFE0F?|\\u2705|[\\u2708\\u2709]\\uFE0F?|[\\u270A\\u270B](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\u270C\\u270D](?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|\\u270F\\uFE0F?|[\\u2712\\u2714\\u2716\\u271D\\u2721]\\uFE0F?|\\u2728|[\\u2733\\u2734\\u2744\\u2747]\\uFE0F?|[\\u274C\\u274E\\u2753-\\u2755\\u2757]|\\u2763\\uFE0F?|\\u2764(?:\\u200D(?:\\uD83D\\uDD25|\\uD83E\\uDE79)|\\uFE0F(?:\\u200D(?:\\uD83D\\uDD25|\\uD83E\\uDE79))?)?|[\\u2795-\\u2797]|\\u27A1\\uFE0F?|[\\u27B0\\u27BF]|[\\u2934\\u2935\\u2B05-\\u2B07]\\uFE0F?|[\\u2B1B\\u2B1C\\u2B50\\u2B55]|[\\u3030\\u303D\\u3297\\u3299]\\uFE0F?|\\uD83C(?:[\\uDC04\\uDCCF]|[\\uDD70\\uDD71\\uDD7E\\uDD7F]\\uFE0F?|[\\uDD8E\\uDD91-\\uDD9A]|\\uDDE6\\uD83C[\\uDDE8-\\uDDEC\\uDDEE\\uDDF1\\uDDF2\\uDDF4\\uDDF6-\\uDDFA\\uDDFC\\uDDFD\\uDDFF]|\\uDDE7\\uD83C[\\uDDE6\\uDDE7\\uDDE9-\\uDDEF\\uDDF1-\\uDDF4\\uDDF6-\\uDDF9\\uDDFB\\uDDFC\\uDDFE\\uDDFF]|\\uDDE8\\uD83C[\\uDDE6\\uDDE8\\uDDE9\\uDDEB-\\uDDEE\\uDDF0-\\uDDF5\\uDDF7\\uDDFA-\\uDDFF]|\\uDDE9\\uD83C[\\uDDEA\\uDDEC\\uDDEF\\uDDF0\\uDDF2\\uDDF4\\uDDFF]|\\uDDEA\\uD83C[\\uDDE6\\uDDE8\\uDDEA\\uDDEC\\uDDED\\uDDF7-\\uDDFA]|\\uDDEB\\uD83C[\\uDDEE-\\uDDF0\\uDDF2\\uDDF4\\uDDF7]|\\uDDEC\\uD83C[\\uDDE6\\uDDE7\\uDDE9-\\uDDEE\\uDDF1-\\uDDF3\\uDDF5-\\uDDFA\\uDDFC\\uDDFE]|\\uDDED\\uD83C[\\uDDF0\\uDDF2\\uDDF3\\uDDF7\\uDDF9\\uDDFA]|\\uDDEE\\uD83C[\\uDDE8-\\uDDEA\\uDDF1-\\uDDF4\\uDDF6-\\uDDF9]|\\uDDEF\\uD83C[\\uDDEA\\uDDF2\\uDDF4\\uDDF5]|\\uDDF0\\uD83C[\\uDDEA\\uDDEC-\\uDDEE\\uDDF2\\uDDF3\\uDDF5\\uDDF7\\uDDFC\\uDDFE\\uDDFF]|\\uDDF1\\uD83C[\\uDDE6-\\uDDE8\\uDDEE\\uDDF0\\uDDF7-\\uDDFB\\uDDFE]|\\uDDF2\\uD83C[\\uDDE6\\uDDE8-\\uDDED\\uDDF0-\\uDDFF]|\\uDDF3\\uD83C[\\uDDE6\\uDDE8\\uDDEA-\\uDDEC\\uDDEE\\uDDF1\\uDDF4\\uDDF5\\uDDF7\\uDDFA\\uDDFF]|\\uDDF4\\uD83C\\uDDF2|\\uDDF5\\uD83C[\\uDDE6\\uDDEA-\\uDDED\\uDDF0-\\uDDF3\\uDDF7-\\uDDF9\\uDDFC\\uDDFE]|\\uDDF6\\uD83C\\uDDE6|\\uDDF7\\uD83C[\\uDDEA\\uDDF4\\uDDF8\\uDDFA\\uDDFC]|\\uDDF8\\uD83C[\\uDDE6-\\uDDEA\\uDDEC-\\uDDF4\\uDDF7-\\uDDF9\\uDDFB\\uDDFD-\\uDDFF]|\\uDDF9\\uD83C[\\uDDE6\\uDDE8\\uDDE9\\uDDEB-\\uDDED\\uDDEF-\\uDDF4\\uDDF7\\uDDF9\\uDDFB\\uDDFC\\uDDFF]|\\uDDFA\\uD83C[\\uDDE6\\uDDEC\\uDDF2\\uDDF3\\uDDF8\\uDDFE\\uDDFF]|\\uDDFB\\uD83C[\\uDDE6\\uDDE8\\uDDEA\\uDDEC\\uDDEE\\uDDF3\\uDDFA]|\\uDDFC\\uD83C[\\uDDEB\\uDDF8]|\\uDDFD\\uD83C\\uDDF0|\\uDDFE\\uD83C[\\uDDEA\\uDDF9]|\\uDDFF\\uD83C[\\uDDE6\\uDDF2\\uDDFC]|\\uDE01|\\uDE02\\uFE0F?|[\\uDE1A\\uDE2F\\uDE32-\\uDE36]|\\uDE37\\uFE0F?|[\\uDE38-\\uDE3A\\uDE50\\uDE51\\uDF00-\\uDF20]|[\\uDF21\\uDF24-\\uDF2C]\\uFE0F?|[\\uDF2D-\\uDF35]|\\uDF36\\uFE0F?|[\\uDF37-\\uDF7C]|\\uDF7D\\uFE0F?|[\\uDF7E-\\uDF84]|\\uDF85(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDF86-\\uDF93]|[\\uDF96\\uDF97\\uDF99-\\uDF9B\\uDF9E\\uDF9F]\\uFE0F?|[\\uDFA0-\\uDFC1]|\\uDFC2(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDFC3\\uDFC4](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFC5\\uDFC6]|\\uDFC7(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDFC8\\uDFC9]|\\uDFCA(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFCB\\uDFCC](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFCD\\uDFCE]\\uFE0F?|[\\uDFCF-\\uDFD3]|[\\uDFD4-\\uDFDF]\\uFE0F?|[\\uDFE0-\\uDFF0]|\\uDFF3(?:\\u200D(?:\\u26A7\\uFE0F?|\\uD83C\\uDF08)|\\uFE0F(?:\\u200D(?:\\u26A7\\uFE0F?|\\uD83C\\uDF08))?)?|\\uDFF4(?:\\u200D\\u2620\\uFE0F?|\\uDB40\\uDC67\\uDB40\\uDC62\\uDB40(?:\\uDC65\\uDB40\\uDC6E\\uDB40\\uDC67|\\uDC73\\uDB40\\uDC63\\uDB40\\uDC74|\\uDC77\\uDB40\\uDC6C\\uDB40\\uDC73)\\uDB40\\uDC7F)?|[\\uDFF5\\uDFF7]\\uFE0F?|[\\uDFF8-\\uDFFF])|\\uD83D(?:[\\uDC00-\\uDC07]|\\uDC08(?:\\u200D\\u2B1B)?|[\\uDC09-\\uDC14]|\\uDC15(?:\\u200D\\uD83E\\uDDBA)?|[\\uDC16-\\uDC3A]|\\uDC3B(?:\\u200D\\u2744\\uFE0F?)?|[\\uDC3C-\\uDC3E]|\\uDC3F\\uFE0F?|\\uDC40|\\uDC41(?:\\u200D\\uD83D\\uDDE8\\uFE0F?|\\uFE0F(?:\\u200D\\uD83D\\uDDE8\\uFE0F?)?)?|[\\uDC42\\uDC43](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC44\\uDC45]|[\\uDC46-\\uDC50](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC51-\\uDC65]|[\\uDC66\\uDC67](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC68(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?|[\\uDC68\\uDC69]\\u200D\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?)|[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92])|\\uD83E[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFC-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB-\\uDFFE]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|\\uDC69(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?[\\uDC68\\uDC69]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?|\\uDC69\\u200D\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?)|[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92])|\\uD83E[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFC-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFE]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|\\uDC6A|[\\uDC6B-\\uDC6D](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC6E(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC6F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDC70\\uDC71](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC72(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC73(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDC74-\\uDC76](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC77(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC78(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC79-\\uDC7B]|\\uDC7C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC7D-\\uDC80]|[\\uDC81\\uDC82](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC83(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC84|\\uDC85(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC86\\uDC87](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDC88-\\uDC8E]|\\uDC8F(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC90|\\uDC91(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC92-\\uDCA9]|\\uDCAA(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDCAB-\\uDCFC]|\\uDCFD\\uFE0F?|[\\uDCFF-\\uDD3D]|[\\uDD49\\uDD4A]\\uFE0F?|[\\uDD4B-\\uDD4E\\uDD50-\\uDD67]|[\\uDD6F\\uDD70\\uDD73]\\uFE0F?|\\uDD74(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|\\uDD75(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD76-\\uDD79]\\uFE0F?|\\uDD7A(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD87\\uDD8A-\\uDD8D]\\uFE0F?|\\uDD90(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|[\\uDD95\\uDD96](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDA4|[\\uDDA5\\uDDA8\\uDDB1\\uDDB2\\uDDBC\\uDDC2-\\uDDC4\\uDDD1-\\uDDD3\\uDDDC-\\uDDDE\\uDDE1\\uDDE3\\uDDE8\\uDDEF\\uDDF3\\uDDFA]\\uFE0F?|[\\uDDFB-\\uDE2D]|\\uDE2E(?:\\u200D\\uD83D\\uDCA8)?|[\\uDE2F-\\uDE34]|\\uDE35(?:\\u200D\\uD83D\\uDCAB)?|\\uDE36(?:\\u200D\\uD83C\\uDF2B\\uFE0F?)?|[\\uDE37-\\uDE44]|[\\uDE45-\\uDE47](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDE48-\\uDE4A]|\\uDE4B(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDE4C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDE4D\\uDE4E](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDE4F(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDE80-\\uDEA2]|\\uDEA3(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDEA4-\\uDEB3]|[\\uDEB4-\\uDEB6](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDEB7-\\uDEBF]|\\uDEC0(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDEC1-\\uDEC5]|\\uDECB\\uFE0F?|\\uDECC(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDECD-\\uDECF]\\uFE0F?|[\\uDED0-\\uDED2\\uDED5-\\uDED7]|[\\uDEE0-\\uDEE5\\uDEE9]\\uFE0F?|[\\uDEEB\\uDEEC]|[\\uDEF0\\uDEF3]\\uFE0F?|[\\uDEF4-\\uDEFC\\uDFE0-\\uDFEB])|\\uD83E(?:\\uDD0C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD0D\\uDD0E]|\\uDD0F(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD10-\\uDD17]|[\\uDD18-\\uDD1C](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDD1D|[\\uDD1E\\uDD1F](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD20-\\uDD25]|\\uDD26(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD27-\\uDD2F]|[\\uDD30-\\uDD34](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDD35(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDD36(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD37-\\uDD39](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDD3A|\\uDD3C(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDD3D\\uDD3E](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD3F-\\uDD45\\uDD47-\\uDD76]|\\uDD77(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD78\\uDD7A-\\uDDB4]|[\\uDDB5\\uDDB6](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDB7|[\\uDDB8\\uDDB9](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDBA|\\uDDBB(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDDBC-\\uDDCB]|[\\uDDCD-\\uDDCF](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDD0|\\uDDD1(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD]))|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFC-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFE]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|[\\uDDD2\\uDDD3](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDD4(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDD5(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDDD6-\\uDDDD](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDDDE\\uDDDF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDDE0-\\uDDFF\\uDE70-\\uDE74\\uDE78-\\uDE7A\\uDE80-\\uDE86\\uDE90-\\uDEA8\\uDEB0-\\uDEB6\\uDEC0-\\uDEC2\\uDED0-\\uDED6])",M,xT,Sz,ET,PT,ST,vz,vT,yT,qY,fT,bT,yz,hT,gT,mT,uT,dT,pT,cT,lT,iT,n,nT,aT,oT,sT,rT,tT,eT,YC,ZC,QC,h6,JC,zC,XC,HC,WC,KC,GC,$C,qC,UC,fz,BC,VC,FC,k1,RC,bz,v0,DZ,q,MC,OC,DC,NC,wC,hz,LC,_C,IC,jC,TC,CC,kC,AC,xC,EC,PC,SC,vC,yC,fC,bC,A1,hC,fY,T8,gC,mC,uC,a,dC,pC,cC,lC,iC,bY,nC,aC,d;var z0=R(()=>{FF=VF(import.meta.url),T1=typeof window>"u"||typeof process<"u",RF={dgram:null,worker_threads:null,os:null,fs:null,mathjs:null},vY={consoleTimeInstances:null};M={_modules:RF,arrFindLast(Y,Z){for(let Q=Y.length-1;Q>=0;Q--)if(Z(Y[Q],Q,Y))return Y[Q];return},arrToString(Y,Z={}){let{maxDepth:Q=4,indent:J=3,maxRow:z=10,maxCol:X=20,color:H=!1,defColor:W=void 0,noHeader:K=!1}=Z;if(Q<1)Q=1;let $={color:H,defColor:W},G=M.getDimensions(Y,"max"),U=G.length*0.4,B=typeof J=="number"?" ".repeat(J):J,F=null;if(H)F={magenta:M.ncc(11550650),gray:M.ncc(4802889),_default:M.ncc(W)};if(!K&&(!(Y instanceof Array)||G.length>2||Math.max(...G)>5))return N(Y)+V(Y,0);else return V(Y,0);function V(w,L,I=0){let T="";if(L>Q-1)if(H)return F.gray+`... [${O(w)||"Array"}]`+F._default;else return`... [${O(w)||"Array"}]`;if(!M.isArrayLike(w))return T+M.yuString(w,$);let y;if(L>U)y=M.getDimensions(w,"max");else y=G.slice(L);let E=G[L+1]!=null&&(y[2]!=null||y[1]>2)&&L<Q-1,P=I?B.repeat(I):"",m=P+B,g=E?`[
|
|
2
|
-
`+
|
|
3
|
-
`+
|
|
4
|
-
`+
|
|
5
|
-
`+
|
|
6
|
-
`);else Z=
|
|
7
|
-
`),Z=
|
|
8
|
-
`),
|
|
9
|
-
expected length: ${
|
|
10
|
-
actual length: ${G[
|
|
11
|
-
Name: `,J)
|
|
12
|
-
Code: `,J)
|
|
13
|
-
Stack: `,J)X+=M.ncc(5592405)+Z.stack+M.ncc(z);else X+=Z.stack;return X}},escapeRegExp(Y){return Y.replace(/[[\]{}.*$^|\-?+,:\\]/g,"\\$&")},ex_length(Y,Z=0){if(typeof Y!=="string")throw TypeError("argument must be a string");if(Z<0)return Y.length;Y=M.cleanString(Y);let Q=Y.length;if(Z<1)return Q;let J=Y;for(let W of M.CONSTS.UNICODES_RANGE_TABLE){if(!W.type.endsWith("full"))continue;J=J.replace(W.regex,"")}let z=Q+(Q-J.length);if(Z<2)return z;let X=Y.match(M.REGEXP.EmojiEach)??[],H=X.reduce((W,K)=>W+K.length,0);return X.length*2+(z-H)},fileNameCleaner(Y,Z="_"){if(!Y||typeof Y!="string")throw Error("the given `rawName` isn't a string");return Y.trim().replace(/[|/*\\<>"?:]/g,Z)},fixFilePath(Y,Z="_"){if(!Y||!Y?.length)throw"path is either falsy or empty!";return Y.replace(/[:?"<>|*]/g,Z)},fixYTurl(Y){if(Y=Y||void 0,!Y)throw"url can't be falsy!!";if(Y.includes("youtu.be"))Y=Y.replace("https://youtu.be/","https://www.youtube.com/watch?v=");if(Y.includes("&list="))Y=Y.split("&list=")[0];if(Y.includes("?si="))Y=Y.split("?si=")[0];if(Y.includes("https")==!1)Y="https://www."+Y;return Y},fileTypeOf(Y){let Z=Y.slice(Y.lastIndexOf(".")+1).toLowerCase(),Q=Z=="jpg"||Z=="png"||Z=="svg"||Z=="jfif"||Z=="pbm"||Z=="pgm"||Z=="jpeg",J=Z=="txt"||Z=="bat"||Z=="text"||Z=="md"||Z=="json"||Z=="step"||Z=="js"||Z=="cs"||Z=="cpp"||Z=="gitignore"||Z=="java"||Z=="py"||Z=="config"||Z=="cfg"||Z=="ts"||Z=="env",z=Z=="exe"||Z=="vpk"||Z=="qc"||Z=="smd"||Z=="vmt"||Z=="vtf"||Z=="zip"||Z=="7z"||Z=="bin"||Z=="ipynb"||Z=="pyc"||Z=="jar",X=Z=="aiff"||Z=="aif"||Z=="aifc"||Z=="flac"||Z=="mp3"||Z=="mp4"||Z=="mp4a"||Z=="m4a"||Z=="mkv"||Z=="mov"||Z=="wav"||Z=="gif"||Z=="webm";if(Q)return"image";else if(J)return"text";else if(z)return"binary";else if(X)return"media";return null},getMatchAllIndexes(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(Q.index);return Z},getMatchAllResults(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(new xz(Q[0],Q.index,Q.index+Q[0].length));return Z},getRandomInt(Y,Z){return Math.round(Math.random()*(Z-Y)+Y)},getProcessTime(){let Y=process.hrtime();return Y[0]*1000+Y[1]/1e6},hyperLink(Y,Z){if(Z=encodeURI(Z.replace(/\\/g,"/")),!M.CheckCache.supportsHyperlink)return Z;return`\x1B]8;;${Z}\x07${Y}\x1B]8;;\x07`},IDGenerator(Y=null,Z="CCNNNN"){let Q=!1,J=Z.length,z=new M.SafeTrue;while(z.True){let X=Array(J);for(let H=0;H<J;H++)switch(Z[H]){case"C":{let W=M.getRandomInt(65,116);if(W>90)W+=6;X[H]=String.fromCharCode(W);continue}case"N":X[H]=M.getRandomInt(0,9).toString();continue;case"B":{let W=M.getRandomInt(48,109);if(W>57&&W<84)W+=7;else if(W>83)W+=13;X[H]=String.fromCharCode(W);continue}default:X[H]=Z[H];break}if(Y){if(Y instanceof Set)Q=Y.has(X);else Q=Y.includes(X);if(!Q)return X.join("")}else return X.join("")}return null},includesWord(Y,Z,Q=!1){if(!Q)Z=Z.toLowerCase(),Y=Y.toLowerCase();Z=Z.padStart(Z.length+1," ").padEnd(Z.length+2," ");let J=Z.search(Y);if(J!==-1){let z=Z.substring(J-1),X=Z.substring(J+Y.length);if(z.search(M.REGEXP.Seperators)==0&&X.search(M.REGEXP.Seperators)==0)return!0}return!1},IPC:class Y{static Listener=C1;#Z;#Q=new Map;#Y;#J=!1;#z=new Set;peersAddress="localhost";peersPort;listenPort;get protocol(){return this.#Y}constructor(Z="udp4",Q={}){if(!T1)throw Error("IPC is only available on JSRuntime, due to the use of Node modules");let{peersPort:J=null,peersAddress:z=null,listenPort:X=null}=typeof Q=="number"?{listenPort:Q}:Q;if(Z!="nodeworker"&&Z!="udp4"&&Z!="udp6")throw Error(`protocol must be 'nodeworker', 'udp4' or 'udp6' instead given '${Z}'`);if(this.#Y=Z,!M._modules.dgram&&Z!="nodeworker")throw Error(`module 'dgram' not loaded use 'Tools._modules.dgram = require("dgram")' to load it`);if(Z=="nodeworker"){if(!M._modules.worker_threads)throw Error(`module 'worker_threads' not loaded use 'Tools._modules.worker_threads = require("worker_threads")' to load it`);if(!X){if(M._modules.worker_threads.isMainThread)throw Error("when using `nodeworker` protocol, `port` must be provided if on the main thread");this.#Z=M._modules.worker_threads.parentPort,this.#X();return}if(!(X instanceof M._modules.worker_threads.Worker)&&X!==M._modules.worker_threads.parentPort&&X!=null)throw Error(`port must be a type of 'Worker' or a 'parentPort' instead given '${typeof X}'`);this.#Z=X,this.#X();return}if(!J)throw Error("peersPort must be provided for `udp4` or `udp6` protocol");this.listenPort=X,this.peersAddress=z,this.peersPort=J,this.#Z=M._modules.dgram.createSocket(Z),this.#X()}async#X(){if(this.#Z.on("message",this.#H),this.protocol=="nodeworker")return;if(!this.listenPort)return;try{this.#Z.bind(this.listenPort),this.#J=!0}catch(Z){switch(Z.code){case"ERR_SOCKET_BAD_PORT":throw new M.Err(`Tools.IPC: port ${this.listenPort} is not valid`,"IPC_ERR_SOCKET_BAD_PORT",Z.code,Z.stack);case"EADDRINUSE":throw new M.Err(`Tools.IPC: port ${this.listenPort} is already in use`,"IPC_EADDRINUSE",Z.code,Z.stack);default:throw M.Err.from(Z,"IPC_BIND_ERROR").message=`Tools.IPC: failed to bind port ${this.listenPort} `+Z.message}}}bind(Z,Q){if(this.protocol=="nodeworker")return;if(this.peersAddress=Z,this.listenPort=Q,!this.#J)this.#X();return this}close(){if(this.protocol=="nodeworker")return;this.#Z.close()}async advSend(Z,Q){return new Promise((J,z)=>{if(!Z)throw Error("channel must be provided");if(typeof Z!="string")throw Error(`channel must be a type of 'string' instead given '${typeof Z}'`);let{contents:X,UPID:H}=Q;if(!(X instanceof Array))X=[X];let W;try{W=this.protocol=="nodeworker"?{channel:Z,UPID:H,contents:X.map((K)=>{if(MF(K))return K;return"@JSON:"+JSON.stringify(K,M.JSONReplacer)})}:Buffer.from(JSON.stringify({channel:Z,UPID:H,contents:X},M.JSONReplacer))}catch(K){z(M.Err.from(K,"IPC_SERIALIZE_ERROR").message="Tools.IPC: failed to serialize payload,"+K.message);return}if(this.protocol=="nodeworker"){this.#Z.postMessage(W),J();return}this.#Z.send(W,this.peersPort,this.peersAddress,(K)=>{if(K)z(K);J()})})}async send(Z,...Q){return this.advSend(Z,{contents:Q})}on(Z,Q){let J=this.#Q.get(Z);if(!J){this.#Q.set(Z,[new C1(0,Q)]);return}return J.push(new C1(0,Q)),this}once(Z,Q,J=null){let z=this.#Q.get(Z);if(!z){this.#Q.set(Z,[new C1(1,Q,J)]);return}return z.push(new C1(1,Q,J)),this}remove(Z){if(typeof Z=="string")return this.#Q.delete(Z),!0;if(typeof Z!="function")throw Error(`listener must be a type of 'string' or 'function' instead given '${typeof Z}'`);for(let[Q,J]of this.#Q){let z=J.find((H)=>H.callback==Z);if(!z)continue;if(!J.filter((H)=>H.callback!=Z))return this.#Q.delete(Q),!0;return this.#Q.set(Q,J.filter((H)=>H.callback!=z)),!0}return!1}async ask(Z,Q,...J){return new Promise((z,X)=>{let H;if(Q)H=setTimeout(()=>{X(new M.Err(`Tools.IPC: ask timeout on channel: ${Z}`,"IPCAskTimeout"))},Q);let W=this.#W();this.once(Z,(K)=>{if(Q)clearTimeout(H);z(K)},W),this.advSend(Z,{contents:J,UPID:W})})}onAsk(Z,Q){let J=this,z=async function(...X){J.#z.add(this.UPID);let H=await Q(...X);J.advSend(Z,{contents:[H],UPID:this.UPID}),J.#z.delete(this.UPID)};return this.on(Z,z),this}#H=(Z)=>{let Q;try{Q=this.protocol=="nodeworker"?{channel:Z.channel,UPID:Z.UPID,contents:Z.contents.map((z)=>{if(typeof z=="string"&&z.startsWith("@JSON:"))return JSON.parse(z.slice(6),M.JSONReviver);return z})}:JSON.parse(Z.toString(),M.JSONReviver)}catch(z){throw M.Err.from(z,"IPC_DESERIALIZE_ERROR").message="Tools.IPC: failed to deserialize payload,"+z.message}let J=this.#Q.get(Q.channel);if(!J)return;for(let z of J){if(z.UPID){if(z.UPID!=Q.UPID)continue;this.#z.delete(z.UPID)}if(z.callback.call(Q,...Q.contents),z.type==1||z.UPID)this.remove(z.callback)}};#W(){let Z=M.IDGenerator(this.#z,"BBBBBBBB");return this.#z.add(Z),Z}},isArrayLike(Y){let Z=Y?.length;return Array.isArray(Y)||!!Y&&Z!=null&&typeof Y==="object"&&typeof Z==="number"&&(Z===0||Z>0&&(Z-1 in Y))},isArrowFunction(Y){if(typeof Y!=="function")return!1;if(Object.hasOwnProperty.call(Y,"prototype"))return!1;try{return Y.arguments,!1}catch{}return Y.toString().slice(0,20).includes("=>")},isAsyncFunction(Y){if(typeof Y!=="function")return!1;if(Y.constructor?.name==="AsyncFunction")return!0;return(Y instanceof M.CONSTS.AsyncFunction&&M.CONSTS.AsyncFunction!==Function&&M.CONSTS.AsyncFunction!==M.CONSTS.GeneratorFunction)===!0},isClass:(Y)=>{if(typeof Y!=="function")return!1;return Y.toString().startsWith("class")},isNumber:(Y)=>{return/^[0-9]+$|^[0-9]+\\.[0-9]+$/.test(Y)},isEmptyArray:(Y)=>M.isArrayLike(Y)&&!Y.length,isEmptyObject:(Y)=>!M.isArrayLike(Y)&&Y instanceof Object&&!M.propertiesCount(Y),isError(Y){return M.Err.isError(Y)},isValidFilePath(Y){if(!Y||!Y?.length)return!1;if(/[:?"<>|*]/g.test(Y))return!1;return!0},JSONReplacer(Y,Z){if(Z instanceof Map)return{"@dataType":"Map","@value":Array.from(Z.entries())};if(Z instanceof Set)return{"@dataType":"Set","@value":Array.from(Z.values())};switch(typeof Z){case"function":return{"@dataType":"function","@value":Z.toString().replace(/\n* {2,}|\n/g,"")};case"bigint":return{"@dataType":"BigInt","@value":Z.toString()};case"object":for(let Q in Z)if(Z[Q]instanceof Date)Z[Q]={"@dataType":"Date","@value":Z[Q].valueOf()};return Z}return Z},JSONReviver(Y,Z){if(!Z||!Z["@dataType"])return Z;switch(Z["@dataType"]){case"function":return Function("return "+Z["@value"])();case"BigInt":return BigInt(Z["@value"]);case"Map":return new Map(Z["@value"]);case"Set":return new Set(Z["@value"]);case"Date":return new Date(Z["@value"])}return Z},jsTime:{howLong(Y,Z=new Date){let Q=Z.getTime()-Y.getTime();return M.jsTime.getTimeFromMS(Q).modern()},getTimeFromMS(Y){let Z=0,Q=0,J=0,z=0,X=0,H=0,W=Y>262800200;while(Y>=1000)Y-=1000,H++;while(H>=60)H-=60,X++;while(X>=60)X-=60,z++;if(W){while(z>=24)z-=24,J++;while(J>=30.4167)J-=30.4167,Q++;J=Math.round(J);while(Q>=12)Q-=12,Z++}if(W)return{year:Z,month:Q,days:J,hr:z,min:X,sec:H,ms:Y,toString(){return`${Z}:${Q}:${J}|${z}:${X}:${H}.${Math.round(Y).toString().padStart(3,"0")}`},modern(){if(Z+Q+J+H+X+z==0)return`${M.maxFraction(Y,4)}ms`;else if(Z+Q+J+X+z==0)return`${H}.${Math.round(Y).toString().padStart(3,"0")}s`;else if(Z+Q+J+z==0)return`${X}min ${H}s`;else if(Z+Q+J==0)return`${z}hr ${X}min`;else if(Z+Q==0)return`${J}days ${z}hr`;else if(Z==0)return`${Q}months ${J}days`;else return`${Z}year ${Q}months`}};return{year:Z,month:Q,days:J,hr:z,min:X,sec:H,ms:Y,toString(){return`${z}:${X}:${H}.${Math.round(Y).toString().padStart(3,"0")}`},modern(){if(H+X+z==0)return`${M.maxFraction(Y,4)}ms`;else if(X+z==0)return`${H}.${Math.round(Y).toString().padStart(3,"0")}s`;else if(z==0)return`${X}min ${H}s`;else return`${z}hr ${X}min`}}}},lazySplit:function*(Y,Z){if(Z===""){for(let z of Y)yield z;return}let Q=0,J;while((J=Y.indexOf(Z,Q))!==-1)yield Y.substring(Q,J),Q=J+Z.length;yield Q?Y.substring(Q):Y},remap(Y,Z){if(Y instanceof Map){let J=new Map;for(let[z,X]of Y){let H=Z(z,X,J);if(H===void 0)continue;if(H===null)J.set(z,X);if(H.key===void 0)J.set(z,H);if(J.set(H.key,H.value),H.key!==z&&J.has(z))J.delete(z)}return J}let Q={};for(let J in Y){let z=Z(J,Y[J],Q);if(z===void 0)continue;if(z===null){Q[J]=Y[J];continue}if(z.key===void 0){Q[J]=z;continue}if(Q[z.key]=z.value,z.key!==J&&Q[J]!==void 0)delete Q[J]}return Q},MathKit:{clamp(Y,Z,Q){return Math.min(Math.max(Y,Z),Q)},degrees(Y){return Y*180/Math.PI},distanceFrom(Y,Z){let Q=Z.x-Y.x,J=Z.y-Y.y,z=Z.z-Y.z;return Math.sqrt(Q**2+(isNaN(J)?0:J**2)+(isNaN(z)?0:z**2))},dopri(Y,Z,Q,J,z=0.000001,X=1000,H){let W=[Y],K=[Q],$=[J(Y,Q)],G,U,B,F,V,O,N=[],w=0.2,L=[0.075,0.225],I=[0.9777777777777777,-3.7333333333333334,3.5555555555555554],T=[2.9525986892242035,-11.595793324188385,9.822892851699436,-0.2908093278463649],y=[2.8462752525252526,-10.757575757575758,8.906422717743473,0.2784090909090909,-0.2735313036020583],E=[0.09114583333333333,0,0.44923629829290207,0.6510416666666666,-0.322376179245283,0.13095238095238096],P=[0.10013431883002395,0,0.3918321794184259,-0.02982460176594817,0.05893268337240795,-0.04497888809104361,0.023904308236133973],m=[0.2,0.3,0.8,0.8888888888888888,1,1],g=[-0.0012326388888888888,0,0.0042527702905061394,-0.03697916666666667,0.05086379716981132,-0.0419047619047619,0.025],b=0,c,Y0,f=(Z-Y)/10,N0=0,w0,P6,E0,b0,S6,P0=new Pz(W,K,$,N,-1,"");if(typeof H==="function")E0=H(Y,Q);while(Y<Z&&N0<X){if(++N0,Y+f>Z)f=Z-Y;if(G=J(Y+m[0]*f,Q+w*f*$[b]),U=J(Y+m[1]*f,Q+L[0]*f*$[b]+L[1]*f*G),B=J(Y+m[2]*f,Q+I[0]*f*$[b]+I[1]*f*G+I[2]*f*U),F=J(Y+m[3]*f,Q+T[0]*f*$[b]+T[1]*f*G+T[2]*f*U+T[3]*f*B),V=J(Y+m[4]*f,Q+y[0]*f*$[b]+y[1]*f*G+y[2]*f*U+y[3]*f*B+y[4]*f*F),w0=Q+$[b]*f*E[0]+U*f*E[2]+B*f*E[3]+F*f*E[4]+V*f*E[5],O=J(Y+f,w0),c=$[b]*f*g[0]+U*f*g[2]+B*f*g[3]+F*f*g[4]+V*f*g[5]+O*f*g[6],P6=Math.abs(c),P6>z){if(f=0.2*f*Math.pow(z/P6,0.25),Y+f===Y){P0.msg="Step size became too small";break}continue}if(N[b]=Q+$[b]*f*P[0]+U*f*P[2]+B*f*P[3]+F*f*P[4]+V*f*P[5]+O*f*P[6],++b,W[b]=Y+f,K[b]=w0,$[b]=O,typeof H==="function"){let v6,y6=Y,GY=Y+0.5*f,V0;if(b0=H(GY,N[b-1]),S6=E0<0&&0<b0,S6){let S0,RZ,MZ=0,f6=1,b6=1;while(!0){if(typeof E0==="number")V0=(b6*b0*y6-f6*E0*GY)/(b6*b0-f6*E0);else{V0=GY;for(Y0=E0.length-1;Y0!==-1;--Y0)if(E0[Y0]<0&&b0[Y0]>0)V0=Math.min(V0,(b6*b0[Y0]*y6-f6*E0[Y0]*GY)/(b6*b0[Y0]-f6*E0[Y0]))}if(V0<=y6||V0>=GY)break;if(v6=P0._at(V0,b-1),RZ=H(V0,v6),S0=E0<0&&0<RZ,S0){if(GY=V0,b0=RZ,S6=S0,b6=1,MZ===-1)f6*=0.5;else f6=1;MZ=-1}else{if(y6=V0,E0=RZ,f6=1,MZ===1)b6*=0.5;else b6=1;MZ=1}}return w0=P0._at(0.5*(Y+V0),b-1),P0.f[b]=J(V0,v6),P0.x[b]=V0,P0.y[b]=v6,P0.ymid[b-1]=w0,P0.events=S6,P0.iterations=N0,P0}y6=GY,GY=Y+f,E0=b0,b0=H(GY,w0),S6=E0<0&&0<b0}Y+=f,Q=w0,E0=b0,f=Math.min(0.8*f*Math.pow(z/P6,0.25),4*f)}return P0.iterations=N0,P0},integral(Y,Z,Q){if(Q>Z)throw Error("lower bound must be less than upper bound");if(Q==Z)return 0;if(!M._modules.mathjs)throw Error(`module 'mathjs' not loaded use 'Tools._modules.mathjs = require("mathjs")' to load it`);let J;if(typeof Y=="string")J=M._modules.mathjs.compile(Y);else J=Y;if(typeof Q=="string")Q=M._modules.mathjs.evaluate(Q);if(typeof Z=="string")Z=M._modules.mathjs.evaluate(Z);let z=(X)=>J.evaluate({x:X});return M.MathKit.dopri(Q,Z,0,z).at(Z)},lerp(Y,Z,Q){return Y+(Z-Y)*Q},Lsh_us(Y,Z){return Y*2**Z},not_us16(Y){return Y^65535},not_us32(Y){return Y^4294967295},not_us8(Y){return Y^255},map(Y,Z,Q,J,z){return Y=M.MathKit.clamp(Y,Z,Q),(Y-Z)/(Q-Z)*(z-J)+J},Point:Ez,radians(Y){return Y*Math.PI/180},Rsh_us(Y,Z){return Math.floor(Y/2**Z)},sum:(...Y)=>{return Y.flat(5).reduce((Z,Q)=>Z+Q,0)},toPolarCoords(Y,Z,Q="r"){if(!Q||Q!="d"&&Q!="r")throw Error("unit must be 'r' or 'd', given: "+Q);let J=Math.atan(Z/Y);if(Z<0&&Y<0)J+=360;else if(Y<0)J+=180;return{r:Math.sqrt(Y**2+Z**2),t:Q=="d"?J:M.MathKit.radians(J)}},toCartesianCoords(Y,Z,Q=null,J="r"){if(!J||J!="d"&&J!="r")throw Error("unit must be 'r' or 'd', given: "+J);if(Q!==null&&typeof Q!="number")throw Error("polar must be a number");if(J=="d"){if(Z=M.MathKit.radians(Z),Q!==null)Q=M.MathKit.radians(Q)}if(Q===null)return{x:Y*Math.cos(Z),y:Y*Math.sin(Z)};else return{x:Y*Math.sin(Q)*Math.cos(Z),y:Y*Math.sin(Q)*Math.sin(Z),z:Y*Math.cos(Q)}}},maxFraction(Y,Z,Q=!1){let J=Y.toString();if(!J.includes("."))return J;let z=10**Z;return Y=(Q?Math.floor(Y*z):Math.round(Y*z))/z,Y.toString()},ncc(Y=null,Z=null,Q=null){if(M.CheckCache.supportsColor===0)return"";if(Y==null)return"\x1B[0m";if(typeof Y=="number"){let z=M.Convert.decimalColorToRGB(Y);switch(Q?1:M.CheckCache.supportsColor){default:return"";case 1:Y=(Z=="bg"?"bg":"")+M.Convert.basicColorFromRgb(z);case 2:{let H=M.Convert._8bitColorFromRgb(z);return`\x1B[${Z=="bg"?"4":"3"}8;5;${H}m`}case 3:return`\x1B[${Z=="bg"?"4":"3"}8;2;${z.r};${z.g};${z.b}m`}}return Y=Y.toLowerCase(),{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",blink:"\x1B[5m",invert:"\x1B[7m",hidden:"\x1B[8m",normal:"\x1B[22m",bgblack:"\x1B[40m",bgred:"\x1B[41m",bggreen:"\x1B[42m",bgyellow:"\x1B[43m",bgblue:"\x1B[44m",bgmagenta:"\x1B[45m",bgcyan:"\x1B[46m",bgwhite:"\x1B[47m"}[Y]||"\x1B[37m"},nearestNumber(Y,Z){let Q=1/0,J=null;for(let z=0,X=Y[z];z<Y.length;){let H=Math.abs(Z-X);if(!H)return z;if(H<Q)Q=H,J=z;X=Y[++z]}return J},objectMap(Y,Z){return M.remap(Y,Z)},objValueAt(Y,Z){return Y[Object.keys(Y).at(Z)]},objToString(Y,Z={}){let{maxDepth:Q=4,indent:J=3,maxKeys:z=20,color:X=!1,defColor:H=void 0,noHeader:W=!1}=Z;if(Q<1)Q=1;let K={color:X,defColor:H},$=typeof J=="number"?" ".repeat(J):J,G=null;if(X)G={cyan:M.ncc(4764610),magenta:M.ncc(11550650),gray:M.ncc(4802889),yellow:M.ncc(12754962),_default:M.ncc(H)};if(Y==null||typeof Y!=="object")return M.yuString(Y,K);if(M.isArrayLike(Y))return M.arrToString(Y,{color:X,defColor:H,maxDepth:Q,indent:J});if(Y instanceof Map||Y instanceof Set||Y instanceof Promise||Y instanceof Date||Y instanceof RegExp)return M.yuString(Y,K);if(M.isError(Y))return M.Err.toString(Y,{color:X,defColor:H});let U=Y.constructor?.name||"Object",B=U!=="Object",V=Object.keys(Y).length,O="";if(!W&&(B||V>5))if(X)O=G.magenta+`${U}(${V}) `+G._default;else O=`${U}(${V}) `;return O+N(Y,0);function N(w,L,I=0){if(L>Q-1)if(X)return G.gray+"... {Object}"+G._default;else return"... {Object}";if(w==null)return M.yuString(w,K);if(typeof w!=="object"||w instanceof Date||w instanceof RegExp)return M.yuString(w,K);if(M.isArrayLike(w))return M.arrToString(w,{color:X,defColor:H,maxDepth:Q-L,indent:J,noHeader:!0});if(w instanceof Map||w instanceof Set)return M.yuString(w,K);let T=Object.keys(w),y=T.length;if(y===0)return"{}";let E=y>3||L>0,P=I?$.repeat(I):"",m=P+$,g=E?`{
|
|
14
|
-
`+
|
|
15
|
-
`+
|
|
16
|
-
`+
|
|
17
|
-
`+
|
|
18
|
-
`+
|
|
19
|
-
`),["","\r"]),
|
|
20
|
-
at \`${
|
|
21
|
-
`+"".padStart(
|
|
22
|
-
at \`${
|
|
23
|
-
`+" ".padStart(
|
|
24
|
-
`),this.reset()}reset(){this.progress=0,this.#Z=0,this.spd=0,this.lastCheck=Date.now(),this.#Q=!0}setPrintTemplate(Z){Z=Z.replace(/%total%/g,"${this.total}"),Z=Z.replace(/%spd%/g,"${this.spd.toFixed(1)}"),Z=Z.replace(/%prog%/g,"${this.progress}"),this.#Y=Function("this.stdout.write(`"+Z+"`);").bind(this)}},proximate(Y,Z,Q){if(Y<Z+Q&&Y>Z-Q)return Z;else return Y},randomPick(Y){if(Y.length<=1)return Y[0];return Y[Math.floor(Math.random()*Y.length)]},redexOf(Y,Z,Q=0){let J=typeof this!=="string";if(!Y&&J)return-1;if(!J)Y=this;if(!Y.length)return-1;if(!(Z instanceof RegExp))if(Q>=0)return Y.indexOf(Z,Q);else return Y.lastIndexOf(Z,Y.length+Q);let z,
|
|
25
|
-
`;else if(typeof
|
|
26
|
-
|
|
27
|
-
[${
|
|
28
|
-
`;if(I==-1){let
|
|
29
|
-
`:`${
|
|
30
|
-
`;if(
|
|
31
|
-
`;else{let
|
|
32
|
-
$`,"m"),
|
|
33
|
-
`?
|
|
34
|
-
`,
|
|
35
|
-
Reason: loop limit reached`);return
|
|
36
|
-
`);for(let
|
|
37
|
-
`),
|
|
38
|
-
`:"")}return
|
|
39
|
-
`,J.liveLog)console.log(
|
|
40
|
-
`){if(
|
|
41
|
-
`)
|
|
42
|
-
`]),
|
|
1
|
+
import{createRequire as wR}from"node:module";var BR=Object.create;var{getPrototypeOf:VR,defineProperty:a5,getOwnPropertyNames:FR}=Object;var RR=Object.prototype.hasOwnProperty;function OR(Y){return this[Y]}var MR,DR,NR=(Y,Z,Q)=>{var J=Y!=null&&typeof Y==="object";if(J){var z=Z?MR??=new WeakMap:DR??=new WeakMap,K=z.get(Y);if(K)return K}Q=Y!=null?BR(VR(Y)):{};let X=Z||!Y||!Y.__esModule?a5(Q,"default",{value:Y,enumerable:!0}):Q;for(let H of FR(Y))if(!RR.call(X,H))a5(X,H,{get:OR.bind(Y,H),enumerable:!0});if(J)z.set(Y,X);return X};var X1=(Y,Z)=>()=>(Z||Y((Z={exports:{}}).exports,Z),Z.exports);var _R=(Y)=>Y;function LR(Y,Z){this[Y]=_R.bind(null,Z)}var o5=(Y,Z)=>{for(var Q in Z)a5(Y,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:LR.bind(Z,Q)})};var O=(Y,Z)=>()=>(Y&&(Z=Y(Y=0)),Z);var A1=wR(import.meta.url);import{createRequire as jR}from"module";class UK{value;start;end;constructor(Y,Z,Q){this.value=Y,this.start=Z,this.end=Q}}class r5{TF;IDF;TF_IDF;constructor(Y){this.TF=Y}}class $K{x;y;z;r;t;get unit(){return this.#Z}get dimension(){return this.#Q}#Z;#Q=0;constructor(Y,Z,Q=null){if(this.x=Y,this.y=Z,this.z=Q,Q)this.#Q=3;else if(Z)this.#Q=2;else if(Y)this.#Q=1}toPolarCoords(Y="r"){this.#Z=Y;let{r:Z,t:Q}=D.MathKit.toPolarCoords(this.x,this.y,Y);return this.r=Z,this.t=Q,this}toCartesianCoords(){if(!this.#Z&&this.x)return this;let{x:Y,y:Z}=D.MathKit.toCartesianCoords(this.r,this.t,this.#Z);return this.x=Y,this.y=Z,this}setUnit(Y){if(!Y||Y!="d"&&Y!="r")throw Error("unit must be 'r' or 'd', given: "+Y);if(this.#Z==Y)return;if(Y=="r")this.#Z=Y,this.t=D.MathKit.radians(this.t);else this.#Z=Y,this.t=D.MathKit.degrees(this.t)}}class BK{constructor(Y,Z,Q,J,z,K,X){this.x=Y,this.y=Z,this.f=Q,this.ymid=J,this.iterations=z,this.events=X,this.msg=K}_at(Y,Z){function Q(V){return V*V}let J,z,K,X,H,W,q,G,$,B;return J=this.x[Z],z=this.x[Z+1],X=this.y[Z],H=this.y[Z+1],q=z-J,K=J+0.5*q,W=this.ymid[Z],G=this.f[Z]-X*(1/(J-K)+2/(J-z)),$=this.f[Z+1]-H*(1/(z-K)+2/(z-J)),B=[Q(Y-z)*(Y-K)/Q(J-z)/(J-K),Q(Y-J)*Q(Y-z)/Q(J-K)/Q(z-K),Q(Y-J)*(Y-K)/Q(z-J)/(z-K),(Y-J)*Q(Y-z)*(Y-K)/Q(J-z)/(J-K),(Y-z)*Q(Y-J)*(Y-K)/Q(J-z)/(z-K)],X*B[0]+W*B[1]+H*B[2]+G*B[3]+$*B[4]}at(Y){let Z,Q,J;if(typeof Y!=="number"){let K=Y.length,X=Array(K);for(Z=K-1;Z!==-1;--Z)X[Z]=this.at(Y[Z]);return X}let z=this.x;Z=0,Q=z.length-1;while(Q-Z>1)if(J=Math.floor(0.5*(Z+Q)),z[J]<=Y)Z=J;else Q=J;return this._at(Y,Z)}}class e1{value;index;type;constructor(Y,Z,Q=-1){this.value=Y,this.type=Z,this.index=Q}valueOf(){return this.value}toString(){return this.value.toString()}}class dY{type;UPID=null;callback;constructor(Y,Z,Q=null){if(Q)this.type=1,this.UPID=Q;else this.type=Y;this.callback=Z}}function CR(Y){return Y==null||typeof Y=="number"||typeof Y=="string"||typeof Y=="boolean"||Y instanceof ArrayBuffer||Y instanceof MessagePort||Y instanceof ReadableStream||Y instanceof WritableStream||Y instanceof TransformStream}var TR,uY,IR,t1,s5="[#*0-9]\\uFE0F?\\u20E3|©\\uFE0F?|[®\\u203C\\u2049\\u2122\\u2139\\u2194-\\u2199\\u21A9\\u21AA]\\uFE0F?|[\\u231A\\u231B]|[\\u2328\\u23CF]\\uFE0F?|[\\u23E9-\\u23EC]|[\\u23ED-\\u23EF]\\uFE0F?|\\u23F0|[\\u23F1\\u23F2]\\uFE0F?|\\u23F3|[\\u23F8-\\u23FA\\u24C2\\u25AA\\u25AB\\u25B6\\u25C0\\u25FB\\u25FC]\\uFE0F?|[\\u25FD\\u25FE]|[\\u2600-\\u2604\\u260E\\u2611]\\uFE0F?|[\\u2614\\u2615]|\\u2618\\uFE0F?|\\u261D(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|[\\u2620\\u2622\\u2623\\u2626\\u262A\\u262E\\u262F\\u2638-\\u263A\\u2640\\u2642]\\uFE0F?|[\\u2648-\\u2653]|[\\u265F\\u2660\\u2663\\u2665\\u2666\\u2668\\u267B\\u267E]\\uFE0F?|\\u267F|\\u2692\\uFE0F?|\\u2693|[\\u2694-\\u2697\\u2699\\u269B\\u269C\\u26A0]\\uFE0F?|\\u26A1|\\u26A7\\uFE0F?|[\\u26AA\\u26AB]|[\\u26B0\\u26B1]\\uFE0F?|[\\u26BD\\u26BE\\u26C4\\u26C5]|\\u26C8\\uFE0F?|\\u26CE|[\\u26CF\\u26D1\\u26D3]\\uFE0F?|\\u26D4|\\u26E9\\uFE0F?|\\u26EA|[\\u26F0\\u26F1]\\uFE0F?|[\\u26F2\\u26F3]|\\u26F4\\uFE0F?|\\u26F5|[\\u26F7\\u26F8]\\uFE0F?|\\u26F9(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\u26FA\\u26FD]|\\u2702\\uFE0F?|\\u2705|[\\u2708\\u2709]\\uFE0F?|[\\u270A\\u270B](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\u270C\\u270D](?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|\\u270F\\uFE0F?|[\\u2712\\u2714\\u2716\\u271D\\u2721]\\uFE0F?|\\u2728|[\\u2733\\u2734\\u2744\\u2747]\\uFE0F?|[\\u274C\\u274E\\u2753-\\u2755\\u2757]|\\u2763\\uFE0F?|\\u2764(?:\\u200D(?:\\uD83D\\uDD25|\\uD83E\\uDE79)|\\uFE0F(?:\\u200D(?:\\uD83D\\uDD25|\\uD83E\\uDE79))?)?|[\\u2795-\\u2797]|\\u27A1\\uFE0F?|[\\u27B0\\u27BF]|[\\u2934\\u2935\\u2B05-\\u2B07]\\uFE0F?|[\\u2B1B\\u2B1C\\u2B50\\u2B55]|[\\u3030\\u303D\\u3297\\u3299]\\uFE0F?|\\uD83C(?:[\\uDC04\\uDCCF]|[\\uDD70\\uDD71\\uDD7E\\uDD7F]\\uFE0F?|[\\uDD8E\\uDD91-\\uDD9A]|\\uDDE6\\uD83C[\\uDDE8-\\uDDEC\\uDDEE\\uDDF1\\uDDF2\\uDDF4\\uDDF6-\\uDDFA\\uDDFC\\uDDFD\\uDDFF]|\\uDDE7\\uD83C[\\uDDE6\\uDDE7\\uDDE9-\\uDDEF\\uDDF1-\\uDDF4\\uDDF6-\\uDDF9\\uDDFB\\uDDFC\\uDDFE\\uDDFF]|\\uDDE8\\uD83C[\\uDDE6\\uDDE8\\uDDE9\\uDDEB-\\uDDEE\\uDDF0-\\uDDF5\\uDDF7\\uDDFA-\\uDDFF]|\\uDDE9\\uD83C[\\uDDEA\\uDDEC\\uDDEF\\uDDF0\\uDDF2\\uDDF4\\uDDFF]|\\uDDEA\\uD83C[\\uDDE6\\uDDE8\\uDDEA\\uDDEC\\uDDED\\uDDF7-\\uDDFA]|\\uDDEB\\uD83C[\\uDDEE-\\uDDF0\\uDDF2\\uDDF4\\uDDF7]|\\uDDEC\\uD83C[\\uDDE6\\uDDE7\\uDDE9-\\uDDEE\\uDDF1-\\uDDF3\\uDDF5-\\uDDFA\\uDDFC\\uDDFE]|\\uDDED\\uD83C[\\uDDF0\\uDDF2\\uDDF3\\uDDF7\\uDDF9\\uDDFA]|\\uDDEE\\uD83C[\\uDDE8-\\uDDEA\\uDDF1-\\uDDF4\\uDDF6-\\uDDF9]|\\uDDEF\\uD83C[\\uDDEA\\uDDF2\\uDDF4\\uDDF5]|\\uDDF0\\uD83C[\\uDDEA\\uDDEC-\\uDDEE\\uDDF2\\uDDF3\\uDDF5\\uDDF7\\uDDFC\\uDDFE\\uDDFF]|\\uDDF1\\uD83C[\\uDDE6-\\uDDE8\\uDDEE\\uDDF0\\uDDF7-\\uDDFB\\uDDFE]|\\uDDF2\\uD83C[\\uDDE6\\uDDE8-\\uDDED\\uDDF0-\\uDDFF]|\\uDDF3\\uD83C[\\uDDE6\\uDDE8\\uDDEA-\\uDDEC\\uDDEE\\uDDF1\\uDDF4\\uDDF5\\uDDF7\\uDDFA\\uDDFF]|\\uDDF4\\uD83C\\uDDF2|\\uDDF5\\uD83C[\\uDDE6\\uDDEA-\\uDDED\\uDDF0-\\uDDF3\\uDDF7-\\uDDF9\\uDDFC\\uDDFE]|\\uDDF6\\uD83C\\uDDE6|\\uDDF7\\uD83C[\\uDDEA\\uDDF4\\uDDF8\\uDDFA\\uDDFC]|\\uDDF8\\uD83C[\\uDDE6-\\uDDEA\\uDDEC-\\uDDF4\\uDDF7-\\uDDF9\\uDDFB\\uDDFD-\\uDDFF]|\\uDDF9\\uD83C[\\uDDE6\\uDDE8\\uDDE9\\uDDEB-\\uDDED\\uDDEF-\\uDDF4\\uDDF7\\uDDF9\\uDDFB\\uDDFC\\uDDFF]|\\uDDFA\\uD83C[\\uDDE6\\uDDEC\\uDDF2\\uDDF3\\uDDF8\\uDDFE\\uDDFF]|\\uDDFB\\uD83C[\\uDDE6\\uDDE8\\uDDEA\\uDDEC\\uDDEE\\uDDF3\\uDDFA]|\\uDDFC\\uD83C[\\uDDEB\\uDDF8]|\\uDDFD\\uD83C\\uDDF0|\\uDDFE\\uD83C[\\uDDEA\\uDDF9]|\\uDDFF\\uD83C[\\uDDE6\\uDDF2\\uDDFC]|\\uDE01|\\uDE02\\uFE0F?|[\\uDE1A\\uDE2F\\uDE32-\\uDE36]|\\uDE37\\uFE0F?|[\\uDE38-\\uDE3A\\uDE50\\uDE51\\uDF00-\\uDF20]|[\\uDF21\\uDF24-\\uDF2C]\\uFE0F?|[\\uDF2D-\\uDF35]|\\uDF36\\uFE0F?|[\\uDF37-\\uDF7C]|\\uDF7D\\uFE0F?|[\\uDF7E-\\uDF84]|\\uDF85(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDF86-\\uDF93]|[\\uDF96\\uDF97\\uDF99-\\uDF9B\\uDF9E\\uDF9F]\\uFE0F?|[\\uDFA0-\\uDFC1]|\\uDFC2(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDFC3\\uDFC4](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFC5\\uDFC6]|\\uDFC7(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDFC8\\uDFC9]|\\uDFCA(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFCB\\uDFCC](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFCD\\uDFCE]\\uFE0F?|[\\uDFCF-\\uDFD3]|[\\uDFD4-\\uDFDF]\\uFE0F?|[\\uDFE0-\\uDFF0]|\\uDFF3(?:\\u200D(?:\\u26A7\\uFE0F?|\\uD83C\\uDF08)|\\uFE0F(?:\\u200D(?:\\u26A7\\uFE0F?|\\uD83C\\uDF08))?)?|\\uDFF4(?:\\u200D\\u2620\\uFE0F?|\\uDB40\\uDC67\\uDB40\\uDC62\\uDB40(?:\\uDC65\\uDB40\\uDC6E\\uDB40\\uDC67|\\uDC73\\uDB40\\uDC63\\uDB40\\uDC74|\\uDC77\\uDB40\\uDC6C\\uDB40\\uDC73)\\uDB40\\uDC7F)?|[\\uDFF5\\uDFF7]\\uFE0F?|[\\uDFF8-\\uDFFF])|\\uD83D(?:[\\uDC00-\\uDC07]|\\uDC08(?:\\u200D\\u2B1B)?|[\\uDC09-\\uDC14]|\\uDC15(?:\\u200D\\uD83E\\uDDBA)?|[\\uDC16-\\uDC3A]|\\uDC3B(?:\\u200D\\u2744\\uFE0F?)?|[\\uDC3C-\\uDC3E]|\\uDC3F\\uFE0F?|\\uDC40|\\uDC41(?:\\u200D\\uD83D\\uDDE8\\uFE0F?|\\uFE0F(?:\\u200D\\uD83D\\uDDE8\\uFE0F?)?)?|[\\uDC42\\uDC43](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC44\\uDC45]|[\\uDC46-\\uDC50](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC51-\\uDC65]|[\\uDC66\\uDC67](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC68(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?|[\\uDC68\\uDC69]\\u200D\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?)|[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92])|\\uD83E[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFC-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB-\\uDFFE]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|\\uDC69(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?[\\uDC68\\uDC69]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?|\\uDC69\\u200D\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?)|[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92])|\\uD83E[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFC-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFE]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|\\uDC6A|[\\uDC6B-\\uDC6D](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC6E(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC6F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDC70\\uDC71](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC72(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC73(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDC74-\\uDC76](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC77(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC78(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC79-\\uDC7B]|\\uDC7C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC7D-\\uDC80]|[\\uDC81\\uDC82](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC83(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC84|\\uDC85(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC86\\uDC87](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDC88-\\uDC8E]|\\uDC8F(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC90|\\uDC91(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC92-\\uDCA9]|\\uDCAA(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDCAB-\\uDCFC]|\\uDCFD\\uFE0F?|[\\uDCFF-\\uDD3D]|[\\uDD49\\uDD4A]\\uFE0F?|[\\uDD4B-\\uDD4E\\uDD50-\\uDD67]|[\\uDD6F\\uDD70\\uDD73]\\uFE0F?|\\uDD74(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|\\uDD75(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD76-\\uDD79]\\uFE0F?|\\uDD7A(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD87\\uDD8A-\\uDD8D]\\uFE0F?|\\uDD90(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|[\\uDD95\\uDD96](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDA4|[\\uDDA5\\uDDA8\\uDDB1\\uDDB2\\uDDBC\\uDDC2-\\uDDC4\\uDDD1-\\uDDD3\\uDDDC-\\uDDDE\\uDDE1\\uDDE3\\uDDE8\\uDDEF\\uDDF3\\uDDFA]\\uFE0F?|[\\uDDFB-\\uDE2D]|\\uDE2E(?:\\u200D\\uD83D\\uDCA8)?|[\\uDE2F-\\uDE34]|\\uDE35(?:\\u200D\\uD83D\\uDCAB)?|\\uDE36(?:\\u200D\\uD83C\\uDF2B\\uFE0F?)?|[\\uDE37-\\uDE44]|[\\uDE45-\\uDE47](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDE48-\\uDE4A]|\\uDE4B(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDE4C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDE4D\\uDE4E](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDE4F(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDE80-\\uDEA2]|\\uDEA3(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDEA4-\\uDEB3]|[\\uDEB4-\\uDEB6](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDEB7-\\uDEBF]|\\uDEC0(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDEC1-\\uDEC5]|\\uDECB\\uFE0F?|\\uDECC(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDECD-\\uDECF]\\uFE0F?|[\\uDED0-\\uDED2\\uDED5-\\uDED7]|[\\uDEE0-\\uDEE5\\uDEE9]\\uFE0F?|[\\uDEEB\\uDEEC]|[\\uDEF0\\uDEF3]\\uFE0F?|[\\uDEF4-\\uDEFC\\uDFE0-\\uDFEB])|\\uD83E(?:\\uDD0C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD0D\\uDD0E]|\\uDD0F(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD10-\\uDD17]|[\\uDD18-\\uDD1C](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDD1D|[\\uDD1E\\uDD1F](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD20-\\uDD25]|\\uDD26(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD27-\\uDD2F]|[\\uDD30-\\uDD34](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDD35(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDD36(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD37-\\uDD39](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDD3A|\\uDD3C(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDD3D\\uDD3E](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD3F-\\uDD45\\uDD47-\\uDD76]|\\uDD77(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD78\\uDD7A-\\uDDB4]|[\\uDDB5\\uDDB6](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDB7|[\\uDDB8\\uDDB9](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDBA|\\uDDBB(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDDBC-\\uDDCB]|[\\uDDCD-\\uDDCF](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDD0|\\uDDD1(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD]))|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFC-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFE]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|[\\uDDD2\\uDDD3](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDD4(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDD5(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDDD6-\\uDDDD](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDDDE\\uDDDF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDDE0-\\uDDFF\\uDE70-\\uDE74\\uDE78-\\uDE7A\\uDE80-\\uDE86\\uDE90-\\uDEA8\\uDEB0-\\uDEB6\\uDEC0-\\uDEC2\\uDED0-\\uDED6])",D,CA,VK,AA,kA,EA,FK,xA,SA,l0,PA,vA,RK,yA,fA,bA,hA,gA,mA,uA,dA,pA,a,cA,m8,D6,lA,nA,iA,aA,oA,sA,rA,tA,eA,s6,Yk,Zk,Qk,Jk,zk,Kk,Xk,Hk,Wk,qk,OK,Gk,Uk,$k,pY,Bk,MK,a0,u8,U,Vk,Fk,Rk,Ok,Mk,t5,Dk,Nk,_k,Lk,wk,jk,Tk,Ik,Ck,Ak,kk,Ek,xk,Sk,Pk,vk,cY,yk,Y6,l4,fk,bk,hk,o,gk,mk,uk,dk,pk,Z6,ck,lk,g;var H0=O(()=>{TR=jR(import.meta.url),uY=typeof window>"u"||typeof process<"u",IR={dgram:null,worker_threads:null,os:null,fs:null,mathjs:null},t1={consoleTimeInstances:null};D={_modules:IR,arrFindLast(Y,Z){for(let Q=Y.length-1;Q>=0;Q--)if(Z(Y[Q],Q,Y))return Y[Q];return},arrToString(Y,Z={}){let{maxDepth:Q=4,indent:J=3,maxRow:z=10,maxCol:K=20,color:X=!1,defColor:H=void 0,noHeader:W=!1}=Z;if(Q<1)Q=1;let q={color:X,defColor:H},G=D.getDimensions(Y,"max"),$=G.length*0.4,B=typeof J=="number"?" ".repeat(J):J,V=null;if(X)V={magenta:D.ncc(11550650),gray:D.ncc(4802889),_default:D.ncc(H)};if(!W&&(!(Y instanceof Array)||G.length>2||Math.max(...G)>5))return L(Y)+F(Y,0);else return F(Y,0);function F(N,_,I=0){let w="";if(_>Q-1)if(X)return V.gray+`... [${M(N)||"Array"}]`+V._default;else return`... [${M(N)||"Array"}]`;if(!D.isArrayLike(N))return w+D.yuString(N,q);let A;if(_>$)A=D.getDimensions(N,"max");else A=G.slice(_);let x=G[_+1]!=null&&(A[2]!=null||A[1]>2)&&_<Q-1,E=I?B.repeat(I):"",h=E+B,u=x?`[
|
|
2
|
+
`+h:"[",f=x?`
|
|
3
|
+
`+E+"]":"]",m=N.length;w+=u;for(let r=0;r<m;r++){if(D.isArrayLike(N[r]))w+=M(N[r])+F(N[r],_+1,x?I+1:I);else w+=D.yuString(N[r],q);if(x){if(r>=z-2){if(w+=`,
|
|
4
|
+
`+h,X)w+=V.gray+"... ("+(m-z+1)+" more)"+V._default;else w+="... ("+(m-z+1)+" more)";break}}else if(r>=K-2){if(X)w+=", "+V.gray+"... ("+(m-K+1)+" more)"+V._default;else w+=", ... ("+(m-K+1)+" more)";break}if(r!=m-1)w+=x?`,
|
|
5
|
+
`+h:", "}return w+=f,w}function M(N){if(N instanceof Array)return"";if(X)return V.magenta+`${N.constructor.name}: `+V._default;else return`${N.constructor.name}: `}function L(N){if(!D.isArrayLike(N))return"";if(X)return V.magenta+`${N.constructor.name}(${G}): `+V._default;else return`${N.constructor.name}(${G}): `}},argvHasFlag(Y,Z=process?.argv){if(!Z||typeof Y!="string")return!1;let Q=Y.startsWith("-")?"":Y.length===1?"-":"--",J=Z.indexOf(Q+Y),z=Z.indexOf("--");return J!==-1&&(z===-1||J<z)},async asyncSleep(Y){return new Promise((Q)=>{if(!Y||Y<4||typeof Y!="number")Q();setTimeout(Q,Y)})},beautifyJson(Y){Y=Y.replace(/\s/,"");let Z=Y+"",Q=D.getMatchAllIndexes(Y.matchAll(/[{[]/g)).sort((X,H)=>X-H),J=D.getMatchAllIndexes(Y.matchAll(/[}\]]/g)).sort((X,H)=>X-H);for(let X=0,H=0,W=0;W<Y.length;){let q=Q[K(Q,W)],G=J[K(J,W)];if(q=q==null?1/0:q,q<G)X++,W=q+1;else X--,W=G+1;let $=Q[K(Q,W)],B=J[K(J,W)],V=$<B?$:B,F="".padEnd(X,"\t");if(z(Z[W+H-1]))Z=D.strSplice(Z,W+H,0,`
|
|
6
|
+
`);else Z=D.strSplice(Z,W+H-1,0,`
|
|
7
|
+
`),Z=D.strSplice(Z,W+H,0,F),H+=F.length;H++;let M=Y.substring(W,V),L=D.getMatchAllIndexes(M.matchAll(/"/g)).filter((_)=>_!=0?M[_-1]!="\\":!0);if(L.length%2!=0)throw Error('cannot match Double-Quote correctly from string: "'+M+'"');let N=D.getMatchAllIndexes(M.matchAll(/[,]/g)).filter((_)=>{for(let I=0;I<L.length;I+=2)if(_>L[I]&&_<L[I+1])return!1;return!0});for(let _=0;_<N.length+1;_++){let I=_==0?W+H:N[_-1]+H+W+1;if(z(Z[I-1])==null)Z=D.strSplice(Z,I,0,F),H+=F.length;if(!Z[N[_]+H+W])break;Z=D.strSplice(Z,N[_]+1+H+W,0,`
|
|
8
|
+
`),H++}}return Z;function z(X){let H=new RegExp(/[{[]/),W=new RegExp(/[}\]]/);if(H.test(X))return 1;if(W.test(X))return 0;return null}function K(X,H){let W=1/0,q;for(let G=0,$=X[G];G<X.length;$=X[++G]){let B=$-H;if(!B)return G;if(B<0)continue;if(B<W)W=B,q=G}return q}},beforeExit(Y,Z=!1){if(Z)process.stdin.resume();let Q=!1,J=!1;["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException","SIGTERM"].forEach((z)=>{process.on(z,(...K)=>{if(["SIGINT","SIGUSR1","SIGUSR2"].includes(z))if(Q)console.log("Forcefully Exiting..."),process.exit(1);else Q=!0;if(J)return;else J=!0;let X=Y(z,...K);if(X instanceof Promise){X.then(()=>{if(z!=="exit"&&Z)process.exit(0)}).catch((H)=>{if(console.error("Error in beforeExit callback:",H),z!=="exit"&&Z)process.exit(1)});return}if(z!=="exit"&&Z)process.exit(0)})})},changeDateTimezone(Y,Z){let Q=new Date(`${Y.toLocaleString("en-US",{timeZone:Z})}`),J=Y.getTime()-Q.getTime();return new Date(Y.getTime()-J)},charTypeAt(Y,Z){let Q=D.CONSTS.UNICODES_RANGE_TABLE;if(Y<0)Y=Z.length+Y;let J=Z.charCodeAt(Y);if(isNaN(J))return null;for(let z=Q.length>>1,K=0;z>=0&&z<Q.length;K++){if(K>(Q.length>>1)+1)break;if(D.isArrayLike(Q[z].to)){for(let X=0;X<Q[z].to.length;X++)if(J>=Q[z].from[X]&&J<=Q[z].to[X])return Q[z].type;if(J>Q[z].from[0])z++;else z--}else{if(J>=Q[z].from&&J<=Q[z].to)return Q[z].type;if(J>Q[z].from)z++;else z--}}return null},CheckCache:class Y{static#Z=null;static#Q=null;static#Y=null;static get supportsColor(){if(this.#Z==null)this.#Z=D.supportsColor();return this.#Z??0}static get supportsHyperlink(){if(this.#Q==null)this.#Q=D.supportsHyperlink();return this.#Q}static set supportsColor(Z){this.#Z=Z}static set supportsHyperlink(Z){this.#Q=Z}static get forceColor(){if(!uY)this.#Y=!1;if(this.#Y===void 0){let Z=process.env;if(D.argvHasFlag("no-color")||D.argvHasFlag("no-colors")||D.argvHasFlag("color=false"))this.#Y=!1;else if(D.argvHasFlag("color")||D.argvHasFlag("colors")||D.argvHasFlag("color=true")||D.argvHasFlag("color=always"))this.#Y=!0;if("FORCE_COLOR"in Z)this.#Y=Z.FORCE_COLOR.length===0||parseInt(Z.FORCE_COLOR,10)!==0}return this.#Y}static set forceColor(Z){this.#Y=Z}},cleanArr(Y,Z=null){if(Z&&Z instanceof Array)return Y.filter((Q)=>{return!Z.includes(Q)});if(Z!==null)return Y.filter((Q)=>{return Q!==Z});return Y.filter((Q)=>Q!==""&&Q!=="\r"&&!D.isEmptyArray(Q)&&!D.isEmptyObject(Q))},cleanComments(Y){return Y.replace(D.REGEXP.JSComments,(Z,Q)=>Q?"":Z)},cleanString(Y){return Y.normalize().replace(D.REGEXP.ANSICode,"")},CONSTS:Object.freeze({UNICODES_RANGE_TABLE:[Object.freeze({type:"generic.en.upper",regex:/[\x41-\x5a]/g,from:65,to:90}),Object.freeze({type:"generic.en.lower",regex:/[\x61-\x7a]/g,from:97,to:122}),Object.freeze({type:"generic.jp.full",regex:/[\u2E80-\u2FD5\u3400-\u4DB5\u4E00-\u9FCB\uF900-\uFA6A\u3000-\u303f\u3041-\u3096\u30a0-\u30ff\uFF00-\uFFEF]/g,from:new Int16Array([11904,13312,19968,63744,12288,12353,12448,65280]),to:new Int16Array([12245,19893,40907,64106,12351,12438,12543,65519])}),Object.freeze({type:"generic.cn.full",regex:/[\u4e00-\u9fff]/g,from:19968,to:40959}),Object.freeze({type:"generic.jp.half",regex:/[\uff5f-\uff9f]/g,from:65375,to:65439})],AsyncFunction:(async()=>{}).constructor,GeneratorFunction:function*(){}.constructor}),Convert:{decimalColorToRGB(Y){return{r:Y>>16&255,g:Y>>8&255,b:Y&255}},basicColorFromRgb(Y){let Z=Y.r>127,Q=Y.g>127,J=Y.b>127;switch(Z+Q+J){case 3:return"white";case 0:return"black";case 2:if(!Z)return"cyan";else if(!Q)return"magenta";else if(!J)return"yellow";case 1:if(Z)return"red";else if(Q)return"green";else if(J)return"blue"}},_8bitColorFromRgb(Y){let{r:Z,g:Q,b:J}=Y;if(Z===Q&&Q===J){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}let z=Math.round(Z/255*5),K=Math.round(Q/255*5),X=Math.round(J/255*5);return 16+36*z+6*K+X}},ConsoleTime:class Y{static lookbackLimit=100;static elapsedStart(Z){if(t1.consoleTimeInstances==null){t1.consoleTimeInstances=new Map([[Z,[D.getProcessTime()]]]);return}if(!t1.consoleTimeInstances.has(Z)){t1.consoleTimeInstances.set(Z,[D.getProcessTime()]);return}let Q=t1.consoleTimeInstances.get(Z);if(Q.unshift(D.getProcessTime()),this.lookbackLimit>0&&Q.length>=this.lookbackLimit)Q.pop()}static elapsedEnd(Z){if(!t1.consoleTimeInstances.has(Z))return;let Q=t1.consoleTimeInstances.get(Z),J=Q[0];Q[0]=D.getProcessTime()-J}static condense(Z){let Q=t1.consoleTimeInstances.get(Z);if(!Q)return null;let J=0;for(let z of Q)J+=z;return J/=Q.length,t1.consoleTimeInstances.delete(Z),{print(){console.log(Z+": "+D.toShortNum(J)+"s")},valueOf:()=>J,toString:()=>Z+": "+D.toShortNum(J)+"s",value:J}}},compareDate(Y,Z,Q,J="day"){if(!Y||!Q)return!1;let z=W(Y),K=W(Q),X=z.next(),H=K.next();do if(X.value!==H.value)switch(Z){case">":return X.value>H.value;case"<":return X.value<H.value;case">=":return X.value>=H.value;case"<=":return X.value<=H.value;default:return!1}while(!(X=z.next()).done&&!(H=K.next()).done);return Z[1]==="=";function*W(q){if(yield q.getFullYear(),J==="year")return;if(yield q.getMonth(),J==="month")return;yield q.getDate()}},DataScienceKit:{frequencyOf(Y){if(!Y||typeof Y!="string"&&!D.isArrayLike(Y))return new Map;let Z=[...new Set(Y)],Q=new Map(Z.map((J)=>[J,0]));for(let J of Y)Z.forEach((z)=>{if(z==J)Q.set(z,Q.get(z)+1)});return Q},LCS_of(Y,Z,Q=(J,z)=>J===z){if(!(Y?.length&&Z?.length))return[];let J=[],z=Z.length,K=Y.length;while(J.length<K)J.push(Array(z));for(let q=0;q<J.length;q++)for(let G=0;G<J[q].length;G++){if(Q(Y[q],Z[G])){let V=W(q-1,G-1);J[q][G]=[V+1,3];continue}let $=W(q,G-1),B=W(q-1,G);if($>B)J[q][G]=[$,2];else J[q][G]=[B,1]}let X=[];return H(K-1,z-1),X;function H(q,G){if(q<0||G<0)return;switch(J[q][G][1]){case 1:H(q-1,G);break;case 2:H(q,G-1);break;case 3:X.unshift(Y[q]),H(q-1,G-1);break}}function W(q,G){if(q<0||G<0)return 0;else return J[q][G][0]}},LCSLength_of(Y,Z,Q=(J,z)=>J===z){if(!(Y?.length&&Z?.length))return 0;let J=[],z=Z.length,K=Y.length;while(J.length<K)J.push(Array(z));for(let H=0;H<J.length;H++)for(let W=0;W<J[H].length;W++){if(Q(Y[H],Z[W])){let $=X(H-1,W-1);J[H][W]=[$+1,3];continue}let q=X(H,W-1),G=X(H-1,W);if(q>G)J[H][W]=[q,2];else J[H][W]=[G,1]}return J[K-1][z-1][0];function X(H,W){if(H<0||W<0)return 0;else return J[H][W][0]}},TFIDF_of(Y){let Z=Y.length,Q=Array(Z),J=new Map;for(let K=0;K<Z;K++){let X=Y[K].length,H=D.DataScienceKit.frequencyOf(Y[K]);Q[K]=new Map;for(let W=0;W<X;W++){if(!Q[K].has(Y[K][W]))Q[K].set(Y[K][W],new r5(H.get(Y[K][W])/X));if(!J.has(Y[K][W]))J.set(Y[K][W],0)}}let z=[...J.keys()];for(let K=0;K<z.length;K++)for(let X of Y)if(X.includes(z[K]))J.set(z[K],J.get(z[K])+1);for(let[K,X]of J)J.set(K,Math.log10(Z/X));for(let K of Q)for(let[X,H]of K)H.IDF=J.get(X),H.TF_IDF=H.IDF*H.TF;return Q},TFIDF_extends(Y,Z){let Q=Y.concat(Array(Z.length)),J=new Map,z=Q.length;for(let X=0;X<z;X++){let H,W,q=!1,G=X-Y.length;if(!Q[X])q=!0,H=Z[G].length,W=D.DataScienceKit.frequencyOf(Z[G]),Q[X]=new Map;else H=Q[X].size;for(let $=0;$<H;$++){if(q&&!Q[X].has(Z[G][$])){if(Q[X].set(Z[G][$],new r5(W.get(Z[G][$])/H)),!J.has(Z[G][$]))J.set(Z[G][$],0);continue}let B=[...Q[X].keys()][$];if(!J.has(B))J.set(B,0)}}let K=[...J.keys()];for(let X=0;X<K.length;X++)for(let H of Q)if(H.has(K[X]))J.set(K[X],J.get(K[X])+1);for(let[X,H]of J)J.set(X,Math.log10(z/H));for(let X of Q)for(let[H,W]of X)W.IDF=J.get(H),W.TF_IDF=W.IDF*W.TF;return Q},wagnerFischer_of(Y,Z,Q=(J,z)=>J===z){let J=[],z,K;for(z=0;z<=Y.length;z++)J[z]=[z];for(K=0;K<=Z.length;K++)J[0][K]=K;for(z=1;z<=Y.length;z++)for(K=1;K<=Z.length;K++){if(Q(Y[z-1],Z[K-1])){J[z][K]=J[z-1][K-1];continue}J[z][K]=Math.min(J[z-1][K-1]+1,Math.min(J[z][K-1]+1,J[z-1][K]+1))}return{distance:J[Y.length][Z.length],getOperations(){let X=J.length-1,H=J[0].length-1,W=[],q=new D.SafeTrue;while((X>0||H>0)&&q.True)switch(G(X,H,J)){case 2:W.push({type:"delete",index:X-1,value:Y[X-1]}),X--;break;case 0:W.push({type:"insert",index:X,value:Z[H-1]}),H--;break;case 1:if(J[X][H]!==J[X-1][H-1])W.push({type:"replace",index:X-1,value:Z[H-1]});X--,H--;break}return W;function G($,B,V){let F=[V[$][B-1],V[$-1][B-1],V[$-1][B]];if(B<=0)return 2;if($<=0)return 0;if(F[0]==F[1])if(F[2]==F[1])return 1;else return 0;let M=F[0],L=0;for(let N=1;N<F.length;N++)if(F[N]<M)M=F[N],L=N;return L}}}}},deferredFunc(Y,Z=200,Q=!1){let J=null;return function(...z){let K=!1;if(Q&&!J)Y(...z),K=!0;clearTimeout(J),J=setTimeout(()=>{if(J=null,!K)Y(...z)},Z)}},digitAt(Y,Z){try{return parseInt((Z+"").at(Y))}catch{return 0}},digitAtRange(Y,Z,Q){if(!Q)return;Y=Y<0?void 0:Y??void 0,Z=Z<0?void 0:Z??void 0;let J=(Q+"").slice(Y,Z);return parseInt(J.length?J:"0")},getDimensions(Y,Z="max"){let Q=[],J=Z==="min"?Math.min:Math.max,z=Z==="min"?1/0:0,K=z,X=[],H=0;if(!D.isArrayLike(Y))return Q;if(Q.push(Y.length),Z==="symmetric")W(Y,0);else q(Y,0,!0);return Q;function W(G,$){if(!D.isArrayLike(G?.[Q[$]-1]))return;Q.push(G[Q[$]-1].length),W(G[Q[$]-1],$+1)}function q(G,$,B=!1,V=[]){for(let F=0;F<Q[$];F++){if(!D.isArrayLike(G[F]))continue;if(G[F].length!=K){if(Z==="fixed"&&K!==z)throw Error(`Array length mismatched at depth ${$+1} position (${[...V,F].join(",")}):
|
|
9
|
+
expected length: ${K}
|
|
10
|
+
actual length: ${G[F].length}`);K=J(K,G[F].length)}X.push([G[F],$+1,!1,[...V,F]])}if(B&&K!==z){Q.push(K),K=z;let F=[...X];X=[];for(let M=0;M<F.length;M++){if(M==F.length-1)F[M][2]=!0;if(++H>5000){queueMicrotask(()=>{H=0,q(...F[M])});continue}q(...F[M])}}}},Err:class Y extends Error{constructor(Z,Q=null,J=null,z=null){if(D.isError(Z)){if(!Q)Q=Z.name;if(!J)J=Z.code??Z.exitCode;if(!z)z=Z.stack;Z=Z.message}super(Z);if(Q)this.name=Q;if(J)this.code=J;if(z)this.stack=z}toString(Z={}){if(!this||!D.isError(this))return"[Error unknown]";return D.Err.toString(this,Z)}static from(Z,Q=null,J=null,z=null){return new D.Err(Z,Q,J,z)}static isError(Z){if(Z instanceof Error)return!0;if(Object.prototype.isPrototypeOf.call(Error.prototype,Z))return!0;return typeof Z?.message=="string"&&typeof Z?.stack=="string"}static toString(Z,Q={}){let{color:J=!1,defColor:z=void 0}=Q,K=(J?D.ncc("Red")+"ERROR"+D.ncc(z):"ERROR")+" Message: ";if(J)K+=D.ncc("Red")+(Z?.message??"[unknown]")+D.ncc(z);else K+=Z?.message??"[unknown]";if(Z?.name)if(K+=`
|
|
11
|
+
Name: `,J)K+=D.ncc("Red")+Z.name+D.ncc(z);else K+=Z.name;if(Z?.code)if(K+=`
|
|
12
|
+
Code: `,J)K+=D.ncc("Yellow")+Z.code+D.ncc(z);else K+=Z.code;if(Z?.stack)if(K+=`
|
|
13
|
+
Stack: `,J)K+=D.ncc(5592405)+Z.stack+D.ncc(z);else K+=Z.stack;return K}},escapeRegExp(Y){return Y.replace(/[[\]{}.*$^|\-?+,:\\]/g,"\\$&")},estimateStrComplexity(Y){if(D.hasEmojiEst(Y))return 2;let Q=!1;for(let z of D.CONSTS.UNICODES_RANGE_TABLE){if(!z.type.endsWith("full"))continue;if(Q=z.regex.test(Y))break}if(Q)return 1;if(D.REGEXP.ANSICode.test(Y))return 0;return-1},ex_length(Y,Z=0){if(typeof Y!=="string")throw TypeError("argument must be a string");if(Z<0)return Y.length;Y=D.cleanString(Y);let Q=Y.length;if(Z<1)return Q;let J=Y;for(let H of D.CONSTS.UNICODES_RANGE_TABLE){if(!H.type.endsWith("full"))continue;J=J.replace(H.regex,"")}let z=Q+(Q-J.length);if(Z<2)return z;let K=Y.match(D.REGEXP.EmojiEach)??[],X=0;for(let H of K)X+=H.length;return K.length*2+(z-X)},fileNameCleaner(Y,Z="_"){if(!Y||typeof Y!="string")throw Error("the given `rawName` isn't a string");return Y.trim().replace(/[|/*\\<>"?:]/g,Z)},fixFilePath(Y,Z="_"){if(!Y||!Y?.length)throw"path is either falsy or empty!";return Y.replace(/[:?"<>|*]/g,Z)},fixYTurl(Y){if(Y=Y||void 0,!Y)throw"url can't be falsy!!";if(Y.includes("youtu.be"))Y=Y.replace("https://youtu.be/","https://www.youtube.com/watch?v=");if(Y.includes("&list="))Y=Y.split("&list=")[0];if(Y.includes("?si="))Y=Y.split("?si=")[0];if(Y.includes("https")==!1)Y="https://www."+Y;return Y},fileTypeOf(Y){let Z=Y.slice(Y.lastIndexOf(".")+1).toLowerCase(),Q=Z=="jpg"||Z=="png"||Z=="svg"||Z=="jfif"||Z=="pbm"||Z=="pgm"||Z=="jpeg",J=Z=="txt"||Z=="bat"||Z=="text"||Z=="md"||Z=="json"||Z=="step"||Z=="js"||Z=="cs"||Z=="cpp"||Z=="gitignore"||Z=="java"||Z=="py"||Z=="config"||Z=="cfg"||Z=="ts"||Z=="env",z=Z=="exe"||Z=="vpk"||Z=="qc"||Z=="smd"||Z=="vmt"||Z=="vtf"||Z=="zip"||Z=="7z"||Z=="bin"||Z=="ipynb"||Z=="pyc"||Z=="jar",K=Z=="aiff"||Z=="aif"||Z=="aifc"||Z=="flac"||Z=="mp3"||Z=="mp4"||Z=="mp4a"||Z=="m4a"||Z=="mkv"||Z=="mov"||Z=="wav"||Z=="gif"||Z=="webm";if(Q)return"image";else if(J)return"text";else if(z)return"binary";else if(K)return"media";return null},getMatchAllIndexes(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(Q.index);return Z},getMatchAllResults(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(new UK(Q[0],Q.index,Q.index+Q[0].length));return Z},getRandomInt(Y,Z){return Math.round(Math.random()*(Z-Y)+Y)},getProcessTime(){let Y=process.hrtime();return Y[0]*1000+Y[1]/1e6},hasEmojiEst(Y){for(let Z of Y){let Q=Z.codePointAt(0);if(Q<9728)continue;if(Q>=128512&&Q<=128591||Q>=127744&&Q<=128511||Q>=128640&&Q<=128767||Q>=129280&&Q<=129535||Q>=129648&&Q<=129791||Q>=9728&&Q<=10175||Q>=8960&&Q<=9215)return!0}return!1},hyperLink(Y,Z){if(Z=encodeURI(Z.replace(/\\/g,"/")),!D.CheckCache.supportsHyperlink)return Z;return`\x1B]8;;${Z}\x07${Y}\x1B]8;;\x07`},IDGenerator(Y=null,Z="CCNNNN"){let Q=!1,J=Z.length,z=new D.SafeTrue;while(z.True){let K=Array(J);for(let X=0;X<J;X++)switch(Z[X]){case"C":{let H=D.getRandomInt(65,116);if(H>90)H+=6;K[X]=String.fromCharCode(H);continue}case"N":K[X]=D.getRandomInt(0,9).toString();continue;case"B":{let H=D.getRandomInt(48,109);if(H>57&&H<84)H+=7;else if(H>83)H+=13;K[X]=String.fromCharCode(H);continue}default:K[X]=Z[X];break}if(Y){if(Y instanceof Set)Q=Y.has(K);else Q=Y.includes(K);if(!Q)return K.join("")}else return K.join("")}return null},includesWord(Y,Z,Q=!1){if(!Q)Z=Z.toLowerCase(),Y=Y.toLowerCase();Z=Z.padStart(Z.length+1," ").padEnd(Z.length+2," ");let J=Z.search(Y);if(J!==-1){let z=Z.substring(J-1),K=Z.substring(J+Y.length);if(z.search(D.REGEXP.Seperators)==0&&K.search(D.REGEXP.Seperators)==0)return!0}return!1},IPC:class Y{static Listener=dY;#Z;#Q=new Map;#Y;#J=!1;#z=new Set;peersAddress="localhost";peersPort;listenPort;get protocol(){return this.#Y}constructor(Z="udp4",Q={}){if(!uY)throw Error("IPC is only available on JSRuntime, due to the use of Node modules");let{peersPort:J=null,peersAddress:z=null,listenPort:K=null}=typeof Q=="number"?{listenPort:Q}:Q;if(Z!="nodeworker"&&Z!="udp4"&&Z!="udp6")throw Error(`protocol must be 'nodeworker', 'udp4' or 'udp6' instead given '${Z}'`);if(this.#Y=Z,!D._modules.dgram&&Z!="nodeworker")throw Error(`module 'dgram' not loaded use 'Tools._modules.dgram = require("dgram")' to load it`);if(Z=="nodeworker"){if(!D._modules.worker_threads)throw Error(`module 'worker_threads' not loaded use 'Tools._modules.worker_threads = require("worker_threads")' to load it`);if(!K){if(D._modules.worker_threads.isMainThread)throw Error("when using `nodeworker` protocol, `port` must be provided if on the main thread");this.#Z=D._modules.worker_threads.parentPort,this.#K();return}if(!(K instanceof D._modules.worker_threads.Worker)&&K!==D._modules.worker_threads.parentPort&&K!=null)throw Error(`port must be a type of 'Worker' or a 'parentPort' instead given '${typeof K}'`);this.#Z=K,this.#K();return}if(!J)throw Error("peersPort must be provided for `udp4` or `udp6` protocol");this.listenPort=K,this.peersAddress=z,this.peersPort=J,this.#Z=D._modules.dgram.createSocket(Z),this.#K()}async#K(){if(this.#Z.on("message",this.#X),this.protocol=="nodeworker")return;if(!this.listenPort)return;try{this.#Z.bind(this.listenPort),this.#J=!0}catch(Z){switch(Z.code){case"ERR_SOCKET_BAD_PORT":throw new D.Err(`Tools.IPC: port ${this.listenPort} is not valid`,"IPC_ERR_SOCKET_BAD_PORT",Z.code,Z.stack);case"EADDRINUSE":throw new D.Err(`Tools.IPC: port ${this.listenPort} is already in use`,"IPC_EADDRINUSE",Z.code,Z.stack);default:throw D.Err.from(Z,"IPC_BIND_ERROR").message=`Tools.IPC: failed to bind port ${this.listenPort} `+Z.message}}}bind(Z,Q){if(this.protocol=="nodeworker")return;if(this.peersAddress=Z,this.listenPort=Q,!this.#J)this.#K();return this}close(){if(this.protocol=="nodeworker")return;this.#Z.close()}async advSend(Z,Q){return new Promise((J,z)=>{if(!Z)throw Error("channel must be provided");if(typeof Z!="string")throw Error(`channel must be a type of 'string' instead given '${typeof Z}'`);let{contents:K,UPID:X}=Q;if(!(K instanceof Array))K=[K];let H;try{H=this.protocol=="nodeworker"?{channel:Z,UPID:X,contents:K.map((W)=>{if(CR(W))return W;return"@JSON:"+JSON.stringify(W,D.JSONReplacer)})}:Buffer.from(JSON.stringify({channel:Z,UPID:X,contents:K},D.JSONReplacer))}catch(W){z(D.Err.from(W,"IPC_SERIALIZE_ERROR").message="Tools.IPC: failed to serialize payload,"+W.message);return}if(this.protocol=="nodeworker"){this.#Z.postMessage(H),J();return}this.#Z.send(H,this.peersPort,this.peersAddress,(W)=>{if(W)z(W);J()})})}async send(Z,...Q){return this.advSend(Z,{contents:Q})}on(Z,Q){let J=this.#Q.get(Z);if(!J){this.#Q.set(Z,[new dY(0,Q)]);return}return J.push(new dY(0,Q)),this}once(Z,Q,J=null){let z=this.#Q.get(Z);if(!z){this.#Q.set(Z,[new dY(1,Q,J)]);return}return z.push(new dY(1,Q,J)),this}remove(Z){if(typeof Z=="string")return this.#Q.delete(Z),!0;if(typeof Z!="function")throw Error(`listener must be a type of 'string' or 'function' instead given '${typeof Z}'`);for(let[Q,J]of this.#Q){let z=J.find((X)=>X.callback==Z);if(!z)continue;if(!J.filter((X)=>X.callback!=Z))return this.#Q.delete(Q),!0;return this.#Q.set(Q,J.filter((X)=>X.callback!=z)),!0}return!1}async ask(Z,Q,...J){return new Promise((z,K)=>{let X;if(Q)X=setTimeout(()=>{K(new D.Err(`Tools.IPC: ask timeout on channel: ${Z}`,"IPCAskTimeout"))},Q);let H=this.#H();this.once(Z,(W)=>{if(Q)clearTimeout(X);z(W)},H),this.advSend(Z,{contents:J,UPID:H})})}onAsk(Z,Q){let J=this,z=async function(...K){J.#z.add(this.UPID);let X=await Q(...K);J.advSend(Z,{contents:[X],UPID:this.UPID}),J.#z.delete(this.UPID)};return this.on(Z,z),this}#X=(Z)=>{let Q;try{Q=this.protocol=="nodeworker"?{channel:Z.channel,UPID:Z.UPID,contents:Z.contents.map((z)=>{if(typeof z=="string"&&z.startsWith("@JSON:"))return JSON.parse(z.slice(6),D.JSONReviver);return z})}:JSON.parse(Z.toString(),D.JSONReviver)}catch(z){throw D.Err.from(z,"IPC_DESERIALIZE_ERROR").message="Tools.IPC: failed to deserialize payload,"+z.message}let J=this.#Q.get(Q.channel);if(!J)return;for(let z of J){if(z.UPID){if(z.UPID!=Q.UPID)continue;this.#z.delete(z.UPID)}if(z.callback.call(Q,...Q.contents),z.type==1||z.UPID)this.remove(z.callback)}};#H(){let Z=D.IDGenerator(this.#z,"BBBBBBBB");return this.#z.add(Z),Z}},isArrayLike(Y){let Z=Y?.length;return Array.isArray(Y)||!!Y&&Z!=null&&typeof Y==="object"&&typeof Z==="number"&&(Z===0||Z>0&&(Z-1 in Y))},isArrowFunction(Y){if(typeof Y!=="function")return!1;if(Object.hasOwnProperty.call(Y,"prototype"))return!1;try{return Y.arguments,!1}catch{}return Y.toString().slice(0,20).includes("=>")},isAsyncFunction(Y){if(typeof Y!=="function")return!1;if(Y.constructor?.name==="AsyncFunction")return!0;return(Y instanceof D.CONSTS.AsyncFunction&&D.CONSTS.AsyncFunction!==Function&&D.CONSTS.AsyncFunction!==D.CONSTS.GeneratorFunction)===!0},isClass:(Y)=>{if(typeof Y!=="function")return!1;return Y.toString().startsWith("class")},isNumber:(Y)=>{return/^[0-9]+$|^[0-9]+\\.[0-9]+$/.test(Y)},isEmptyArray:(Y)=>D.isArrayLike(Y)&&!Y.length,isEmptyObject:(Y)=>!D.isArrayLike(Y)&&Y instanceof Object&&!D.propertiesCount(Y),isError(Y){return D.Err.isError(Y)},isValidFilePath(Y){if(!Y||!Y?.length)return!1;if(/[:?"<>|*]/g.test(Y))return!1;return!0},JSONReplacer(Y,Z){if(Z instanceof Map)return{"@dataType":"Map","@value":Array.from(Z.entries())};if(Z instanceof Set)return{"@dataType":"Set","@value":Array.from(Z.values())};switch(typeof Z){case"function":return{"@dataType":"function","@value":Z.toString().replace(/\n* {2,}|\n/g,"")};case"bigint":return{"@dataType":"BigInt","@value":Z.toString()};case"object":for(let Q in Z)if(Z[Q]instanceof Date)Z[Q]={"@dataType":"Date","@value":Z[Q].valueOf()};return Z}return Z},JSONReviver(Y,Z){if(!Z||!Z["@dataType"])return Z;switch(Z["@dataType"]){case"function":return Function("return "+Z["@value"])();case"BigInt":return BigInt(Z["@value"]);case"Map":return new Map(Z["@value"]);case"Set":return new Set(Z["@value"]);case"Date":return new Date(Z["@value"])}return Z},jsTime:{howLong(Y,Z=new Date){let Q=Z.getTime()-Y.getTime();return D.jsTime.getTimeFromMS(Q).modern()},getTimeFromMS(Y){let Z=0,Q=0,J=0,z=0,K=0,X=0,H=Y>262800200;while(Y>=1000)Y-=1000,X++;while(X>=60)X-=60,K++;while(K>=60)K-=60,z++;if(H){while(z>=24)z-=24,J++;while(J>=30.4167)J-=30.4167,Q++;J=Math.round(J);while(Q>=12)Q-=12,Z++}if(H)return{year:Z,month:Q,days:J,hr:z,min:K,sec:X,ms:Y,toString(){return`${Z}:${Q}:${J}|${z}:${K}:${X}.${Math.round(Y).toString().padStart(3,"0")}`},modern(){if(Z+Q+J+X+K+z==0)return`${D.maxFraction(Y,4)}ms`;else if(Z+Q+J+K+z==0)return`${X}.${Math.round(Y).toString().padStart(3,"0")}s`;else if(Z+Q+J+z==0)return`${K}min ${X}s`;else if(Z+Q+J==0)return`${z}hr ${K}min`;else if(Z+Q==0)return`${J}days ${z}hr`;else if(Z==0)return`${Q}months ${J}days`;else return`${Z}year ${Q}months`}};return{year:Z,month:Q,days:J,hr:z,min:K,sec:X,ms:Y,toString(){return`${z}:${K}:${X}.${Math.round(Y).toString().padStart(3,"0")}`},modern(){if(X+K+z==0)return`${D.maxFraction(Y,4)}ms`;else if(K+z==0)return`${X}.${Math.round(Y).toString().padStart(3,"0")}s`;else if(z==0)return`${K}min ${X}s`;else return`${z}hr ${K}min`}}}},lazySplit:function*(Y,Z){if(Z===""){for(let z of Y)yield z;return}let Q=0,J;while((J=Y.indexOf(Z,Q))!==-1)yield Y.substring(Q,J),Q=J+Z.length;yield Q?Y.substring(Q):Y},remap(Y,Z){if(Y instanceof Map){let J=new Map;for(let[z,K]of Y){let X=Z(z,K,J);if(X===void 0)continue;if(X===null)J.set(z,K);if(X.key===void 0)J.set(z,X);if(J.set(X.key,X.value),X.key!==z&&J.has(z))J.delete(z)}return J}let Q={};for(let J in Y){let z=Z(J,Y[J],Q);if(z===void 0)continue;if(z===null){Q[J]=Y[J];continue}if(z.key===void 0){Q[J]=z;continue}if(Q[z.key]=z.value,z.key!==J&&Q[J]!==void 0)delete Q[J]}return Q},MathKit:{clamp(Y,Z,Q){return Math.min(Math.max(Y,Z),Q)},degrees(Y){return Y*180/Math.PI},distanceFrom(Y,Z){let Q=Z.x-Y.x,J=Z.y-Y.y,z=Z.z-Y.z;return Math.sqrt(Q**2+(isNaN(J)?0:J**2)+(isNaN(z)?0:z**2))},dopri(Y,Z,Q,J,z=0.000001,K=1000,X){let H=[Y],W=[Q],q=[J(Y,Q)],G,$,B,V,F,M,L=[],N=0.2,_=[0.075,0.225],I=[0.9777777777777777,-3.7333333333333334,3.5555555555555554],w=[2.9525986892242035,-11.595793324188385,9.822892851699436,-0.2908093278463649],A=[2.8462752525252526,-10.757575757575758,8.906422717743473,0.2784090909090909,-0.2735313036020583],x=[0.09114583333333333,0,0.44923629829290207,0.6510416666666666,-0.322376179245283,0.13095238095238096],E=[0.10013431883002395,0,0.3918321794184259,-0.02982460176594817,0.05893268337240795,-0.04497888809104361,0.023904308236133973],h=[0.2,0.3,0.8,0.8888888888888888,1,1],u=[-0.0012326388888888888,0,0.0042527702905061394,-0.03697916666666667,0.05086379716981132,-0.0419047619047619,0.025],f=0,m,r,b=(Z-Y)/10,$0=0,t,X0,e,n,U0,M0=new BK(H,W,q,L,-1,"");if(typeof X==="function")e=X(Y,Q);while(Y<Z&&$0<K){if(++$0,Y+b>Z)b=Z-Y;if(G=J(Y+h[0]*b,Q+N*b*q[f]),$=J(Y+h[1]*b,Q+_[0]*b*q[f]+_[1]*b*G),B=J(Y+h[2]*b,Q+I[0]*b*q[f]+I[1]*b*G+I[2]*b*$),V=J(Y+h[3]*b,Q+w[0]*b*q[f]+w[1]*b*G+w[2]*b*$+w[3]*b*B),F=J(Y+h[4]*b,Q+A[0]*b*q[f]+A[1]*b*G+A[2]*b*$+A[3]*b*B+A[4]*b*V),t=Q+q[f]*b*x[0]+$*b*x[2]+B*b*x[3]+V*b*x[4]+F*b*x[5],M=J(Y+b,t),m=q[f]*b*u[0]+$*b*u[2]+B*b*u[3]+V*b*u[4]+F*b*u[5]+M*b*u[6],X0=Math.abs(m),X0>z){if(b=0.2*b*Math.pow(z/X0,0.25),Y+b===Y){M0.msg="Step size became too small";break}continue}if(L[f]=Q+q[f]*b*E[0]+$*b*E[2]+B*b*E[3]+V*b*E[4]+F*b*E[5]+M*b*E[6],++f,H[f]=Y+b,W[f]=t,q[f]=M,typeof X==="function"){let j0,C0=Y,T0=Y+0.5*b,R0;if(n=X(T0,L[f-1]),U0=e<0&&0<n,U0){let N0,R1,C1=0,x0=1,z1=1;while(!0){if(typeof e==="number")R0=(z1*n*C0-x0*e*T0)/(z1*n-x0*e);else{R0=T0;for(r=e.length-1;r!==-1;--r)if(e[r]<0&&n[r]>0)R0=Math.min(R0,(z1*n[r]*C0-x0*e[r]*T0)/(z1*n[r]-x0*e[r]))}if(R0<=C0||R0>=T0)break;if(j0=M0._at(R0,f-1),R1=X(R0,j0),N0=e<0&&0<R1,N0){if(T0=R0,n=R1,U0=N0,z1=1,C1===-1)x0*=0.5;else x0=1;C1=-1}else{if(C0=R0,e=R1,x0=1,C1===1)z1*=0.5;else z1=1;C1=1}}return t=M0._at(0.5*(Y+R0),f-1),M0.f[f]=J(R0,j0),M0.x[f]=R0,M0.y[f]=j0,M0.ymid[f-1]=t,M0.events=U0,M0.iterations=$0,M0}C0=T0,T0=Y+b,e=n,n=X(T0,t),U0=e<0&&0<n}Y+=b,Q=t,e=n,b=Math.min(0.8*b*Math.pow(z/X0,0.25),4*b)}return M0.iterations=$0,M0},integral(Y,Z,Q){if(Q>Z)throw Error("lower bound must be less than upper bound");if(Q==Z)return 0;if(!D._modules.mathjs)throw Error(`module 'mathjs' not loaded use 'Tools._modules.mathjs = require("mathjs")' to load it`);let J;if(typeof Y=="string")J=D._modules.mathjs.compile(Y);else J=Y;if(typeof Q=="string")Q=D._modules.mathjs.evaluate(Q);if(typeof Z=="string")Z=D._modules.mathjs.evaluate(Z);let z=(K)=>J.evaluate({x:K});return D.MathKit.dopri(Q,Z,0,z).at(Z)},lerp(Y,Z,Q){return Y+(Z-Y)*Q},Lsh_us(Y,Z){return Y*2**Z},not_us16(Y){return Y^65535},not_us32(Y){return Y^4294967295},not_us8(Y){return Y^255},map(Y,Z,Q,J,z){return Y=D.MathKit.clamp(Y,Z,Q),(Y-Z)/(Q-Z)*(z-J)+J},Point:$K,radians(Y){return Y*Math.PI/180},Rsh_us(Y,Z){return Math.floor(Y/2**Z)},sum:(...Y)=>{return Y.flat(5).reduce((Z,Q)=>Z+Q,0)},toPolarCoords(Y,Z,Q="r"){if(!Q||Q!="d"&&Q!="r")throw Error("unit must be 'r' or 'd', given: "+Q);let J=Math.atan(Z/Y);if(Z<0&&Y<0)J+=360;else if(Y<0)J+=180;return{r:Math.sqrt(Y**2+Z**2),t:Q=="d"?J:D.MathKit.radians(J)}},toCartesianCoords(Y,Z,Q=null,J="r"){if(!J||J!="d"&&J!="r")throw Error("unit must be 'r' or 'd', given: "+J);if(Q!==null&&typeof Q!="number")throw Error("polar must be a number");if(J=="d"){if(Z=D.MathKit.radians(Z),Q!==null)Q=D.MathKit.radians(Q)}if(Q===null)return{x:Y*Math.cos(Z),y:Y*Math.sin(Z)};else return{x:Y*Math.sin(Q)*Math.cos(Z),y:Y*Math.sin(Q)*Math.sin(Z),z:Y*Math.cos(Q)}}},maxFraction(Y,Z,Q=!1){let J=Y.toString();if(!J.includes("."))return J;let z=10**Z;return Y=(Q?Math.floor(Y*z):Math.round(Y*z))/z,Y.toString()},ncc(Y=null,Z=null,Q=null){if(D.CheckCache.supportsColor===0)return"";if(Y==null)return"\x1B[0m";if(typeof Y=="number"){let z=D.Convert.decimalColorToRGB(Y);switch(Q?1:D.CheckCache.supportsColor){default:return"";case 1:Y=(Z=="bg"?"bg":"")+D.Convert.basicColorFromRgb(z);case 2:{let X=D.Convert._8bitColorFromRgb(z);return`\x1B[${Z=="bg"?"4":"3"}8;5;${X}m`}case 3:return`\x1B[${Z=="bg"?"4":"3"}8;2;${z.r};${z.g};${z.b}m`}}return Y=Y.toLowerCase(),{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",blink:"\x1B[5m",invert:"\x1B[7m",hidden:"\x1B[8m",normal:"\x1B[22m",bgblack:"\x1B[40m",bgred:"\x1B[41m",bggreen:"\x1B[42m",bgyellow:"\x1B[43m",bgblue:"\x1B[44m",bgmagenta:"\x1B[45m",bgcyan:"\x1B[46m",bgwhite:"\x1B[47m"}[Y]||"\x1B[37m"},nearestNumber(Y,Z){let Q=1/0,J=null;for(let z=0,K=Y[z];z<Y.length;){let X=Math.abs(Z-K);if(!X)return z;if(X<Q)Q=X,J=z;K=Y[++z]}return J},objectMap(Y,Z){return D.remap(Y,Z)},objValueAt(Y,Z){return Y[Object.keys(Y).at(Z)]},objToString(Y,Z={}){let{maxDepth:Q=4,indent:J=3,maxKeys:z=20,color:K=!1,defColor:X=void 0,noHeader:H=!1}=Z;if(Q<1)Q=1;let W={color:K,defColor:X},q=typeof J=="number"?" ".repeat(J):J,G=null;if(K)G={cyan:D.ncc(4764610),magenta:D.ncc(11550650),gray:D.ncc(4802889),yellow:D.ncc(12754962),_default:D.ncc(X)};if(Y==null||typeof Y!=="object")return D.yuString(Y,W);if(D.isArrayLike(Y))return D.arrToString(Y,{color:K,defColor:X,maxDepth:Q,indent:J});if(Y instanceof Map||Y instanceof Set||Y instanceof Promise||Y instanceof Date||Y instanceof RegExp)return D.yuString(Y,W);if(D.isError(Y))return D.Err.toString(Y,{color:K,defColor:X});let $=Y.constructor?.name||"Object",B=$!=="Object",F=Object.keys(Y).length,M="";if(!H&&(B||F>5))if(K)M=G.magenta+`${$}(${F}) `+G._default;else M=`${$}(${F}) `;return M+L(Y,0);function L(N,_,I=0){if(_>Q-1)if(K)return G.gray+"... {Object}"+G._default;else return"... {Object}";if(N==null)return D.yuString(N,W);if(typeof N!=="object"||N instanceof Date||N instanceof RegExp)return D.yuString(N,W);if(D.isArrayLike(N))return D.arrToString(N,{color:K,defColor:X,maxDepth:Q-_,indent:J,noHeader:!0});if(N instanceof Map||N instanceof Set)return D.yuString(N,W);let w=Object.keys(N),A=w.length;if(A===0)return"{}";let x=A>3||_>0,E=I?q.repeat(I):"",h=E+q,u=x?`{
|
|
14
|
+
`+h:"{ ",f=Math.min(w.length,z-1);for(let m=0;m<f;m++){let r=w[m],b=N[r];if(K)u+=G.cyan+r+G._default+": ";else u+=r+": ";if(b&&typeof b==="object"&&!D.isArrayLike(b)&&!(b instanceof Date)&&!(b instanceof RegExp)&&!(b instanceof Map)&&!(b instanceof Set)&&!(b instanceof Promise)){let $0=b.constructor?.name||"Object";if($0!=="Object"&&K)u+=G.magenta+$0+" "+G._default;else if($0!=="Object")u+=$0+" ";u+=L(b,_+1,x?I+1:I)}else u+=D.yuString(b,W);if(m<f-1)u+=x?`,
|
|
15
|
+
`+h:", "}if(w.length>z-1){let m=w.length-f;if(K)u+=x?`,
|
|
16
|
+
`+h:", ",u+=G.gray+`... (${m} more)`+G._default;else u+=x?`,
|
|
17
|
+
`+h:", ",u+=`... (${m} more)`}return u+=x?`
|
|
18
|
+
`+E+"}":" }",u}},propertiesCount(Y){return Object.keys(Y).length},padEnd(Y,Z,Q=" ",J=0){let z=D.ex_length(Y,J);if(z>=Z)return Y;return Y+Q.repeat(Z-z)},padStart(Y,Z,Q=" ",J=0){let z=D.ex_length(Y,J);if(z>=Z)return Y;return Q.repeat(Z-z)+Y},parseArgs(Y,Z,Q=!1){let J={_unmatched:[]},z=new Set;for(let X in Z)if(Z[X]?.required)z.add(X);for(let X=0;X<Y.length;X++){let H=!1;for(let W in Z){if(!Z[W]?.pattern)throw Error("invalid template: Object structure missmatched. every entries requires `pattern` property");if(!K(Y[X],Z[W].pattern))continue;if(z.delete(W),Z[W]?.isFlag||Z[W]?.type=="flag"){H=!0,J[W]=new e1(!0,"flag",X);continue}let q=!1;if(X+1<Y.length){for(let G in Z)if(K(Y[X+1],Z[G].pattern))q=!0}if(X+1>=Y.length||q)throw Error(`argument '${Y[X]}' requires a Value`);switch(Z[W]?.type){case"int":if(isNaN((J[W]=new e1(parseInt(Y[++X]),Z[W]?.type,X)).value))throw Error(`argument '${Y[X-1]}' requires a Value of type '${Z[W]?.type}'`);break;case"float":if(isNaN((J[W]=new e1(parseFloat(Y[++X]),Z[W]?.type,X)).value))throw Error(`argument '${Y[X-1]}' requires a Value of type '${Z[W]?.type}'`);break;case"choice":if(!Z[W]?.choices?.length)throw Error("invalid template: Object structure missmatched. entry of type 'choice' requires `choices` property");if(!K(Y[++X],Z[W].choices)&&Z[W]?.default==null)throw Error(`invalid value for '${Y[X-1]}' argument, requires any of these Choices: ${Z[W].choices}`);J[W]=new e1(Y[X],Z[W]?.type,X);break;case"string":case void 0:J[W]=new e1(Y[++X],Z[W]?.type,X);break;default:throw Error(`invalid template: entry of type '${Z[W]?.type}' is not supported`)}H=!0}if(!H)J._unmatched.push(new e1(Y[X],void 0,X))}if(z.size>0)throw Error(`argument(s) '${[...z]}' is required.`);for(let X in Z){if(Z[X]?.isFlag||Z[X]?.type=="flag"){if(!J[X])J[X]=new e1(!1,"flag");continue}if(!J[X])J[X]=new e1(Z[X]?.default?Z[X]?.default:null,Z[X]?.type)}return J;function K(X,H){for(let W of H){if(!Q){if(X.toLowerCase()==W.toLowerCase())return!0;continue}if(X==W)return!0}return!1}},parseBool(Y,Z=!1){if(typeof Y=="boolean")return Y;Y=Y.toLowerCase();let Q=Y=="true"?!0:!1;if(!Z)return Q;if(!(Y=="true"||Y=="false"))return null;return Q},parseConfig(Y,Z=null,Q={}){let{ignoreGroups:J=!1,multiValues:z=!1}=Q,K=D.cleanArr(Y.trim().split(`
|
|
19
|
+
`),["","\r"]),X={},H=null,W="",q,G=0,$=!1;for(let V=0;V<K.length;V++){let F=K[V].trim();if(/^[#;]/.test(F))continue;if(F.startsWith("[")){if(J)continue;{let w=!1;for(let A=1;A<F.length;A++)if(F[A]=="]"&&F[A-1]!="\\"){if(H=F.slice(1,A),!X[H])X[H]={};w=!0;break}if(!w)throw Error(`Tools.parseConfig(): invalid syntax, missing ']' at the end of the group. at \`${F}\``);else continue}}if($){if(W+=K[V],!B(V,K))continue;if($=!1,H)X[H][q]=JSON.parse(W,Z);else X[q]=JSON.parse(W,Z);continue}let M=D.cleanArr(F.split("="));if(M.length>2)throw Error(`Tools.parseConfig(): invalid syntax, '=' cannot occur more than one time. at \`${F}\``);else if(M.length==1&&!$)if(F.includes("="))throw Error(`Tools.parseConfig(): invalid syntax, expected expresion after '='. at \`${F}\``);else throw Error(`Tools.parseConfig(): expected expresion. at \`${F}\``);else if(!M.length)throw Error(`Tools.parseConfig(): unknown operator. \`${F}\``);M=[M[0].trim(),M[1].trim()];let L=D.getMatchAllIndexes(M[1].matchAll(/["']/g)).filter((w,A,x)=>{if(M[1][w-1]=="\\"){M[1]=M[1].slice(0,w-1)+M[1].slice(w);for(let E=A+1;E<x.length;E++)x[E]--;return!1}return!0}),N=M[1].search("#"),_=L[0],I=!1;if(_!=null&&(N==-1||_<N)){let w=L[1]==null?-1:L[1],A=M[1].slice(w+2).trim();if(A&&!/^[#;]/.test(A))throw Error(`Tools.parseConfig(): invalid syntax, unexpected charactor(s).
|
|
20
|
+
at \`${F}\`
|
|
21
|
+
`+"".padStart(w+10+M[0].length," ")+"^");if(w==-1)throw Error(`Tools.parseConfig(): invalid syntax, missing closing quote.
|
|
22
|
+
at \`${F}\`
|
|
23
|
+
`+" ".padStart(_+7+M[0].length," ")+"^");I=!0,M[1]=M[1].slice(_+1,w)}else if(N!=-1){if(M[1]=M[1].slice(0,M[1].indexOf("#")).trim(),!M[1])throw Error(`Tools.parseConfig(): invalid syntax, expected expresion after '='. at \`${F}\``)}if(/^[0-9]/.test(M[0]))throw Error(`Tools.parseConfig(): Key cannot starts with Numbers. at \`${F}\``);{let w=M[0].replace(/[a-z$_0-9.]/gi,"");if(w.length!==0)throw Error(`Tools.parseConfig(): these character(s) "${w}" can not be Parse. at \`${F}\``)}if(/^[[{]/.test(M[1])){if(G=0,[q,W]=M,B(1,M)){if(H)X[H][q]=JSON.parse(W,Z);else X[q]=JSON.parse(W,Z);continue}$=!0;continue}{let w=H?X[H]:X;if(z&&Object.hasOwnProperty.call(w,M[0])){if(w[M[0]].$multiValues===void 0)w[M[0]]=[w[M[0]]],w[M[0]].$multiValues=!0;w[M[0]].push(I?M[1]:D.parseValue(M[1]))}else w[M[0]]=I?M[1]:D.parseValue(M[1])}}return X;function B(V,F){if(G+=[...F[V].matchAll(D.REGEXP.OpenSCBrackets)].filter((M)=>M[1]).length,G-=[...F[V].matchAll(D.REGEXP.CloseSCBrackets)].filter((M)=>M[1]).length,G<=0)return!0;return!1}},parseValue(Y){if(typeof Y!="string")return Y;switch(Y.toLowerCase()){case"true":return!0;case"false":return!1;case"null":return null;case"":case"undefined":return;default:if(!isNaN(Y))return Number(Y);return Y}},pass(Y,Z=null){if(Z)Z(Y);else console?.log(Y);return Y},Progress:class Y{stdout=process.stdout;progress=0;spd=0;lastCheck=null;printInterval;updateInterval;total;#Z=0;#Q=!0;#Y;constructor(Z,Q=null,J=500,z=100){if(!Z)throw Error("printTemplate is required");this.total=Q,this.printInterval=J,this.updateInterval=z,this.setPrintTemplate(Z),this.lastCheck=Date.now()}update(Z=1){if(!this.#Y)return;this.#Z+=Z,this.progress+=Z;let Q=Date.now()-this.lastCheck;if(Q>this.updateInterval&&this.#Z>4)this.spd=this.#Z*this.updateInterval/Q,this.#Z=0,this.lastCheck=Date.now();if(this.lastPrint+this.printInterval>Date.now())return;if(this.lastPrint=Date.now(),!this.#Q)this.stdout.clearLine(),this.stdout.cursorTo(0);else this.#Q=!1;if(!this.total){this.#Y();return}this.#Y()}done(){if(this.progress!=this.total){if(!this.#Q)this.stdout.clearLine(),this.stdout.cursorTo(0);this.progress=this.total,this.#Y()}this.stdout.write(`
|
|
24
|
+
`),this.reset()}reset(){this.progress=0,this.#Z=0,this.spd=0,this.lastCheck=Date.now(),this.#Q=!0}setPrintTemplate(Z){Z=Z.replace(/%total%/g,"${this.total}"),Z=Z.replace(/%spd%/g,"${this.spd.toFixed(1)}"),Z=Z.replace(/%prog%/g,"${this.progress}"),this.#Y=Function("this.stdout.write(`"+Z+"`);").bind(this)}},proximate(Y,Z,Q){if(Y<Z+Q&&Y>Z-Q)return Z;else return Y},randomPick(Y){if(Y.length<=1)return Y[0];return Y[Math.floor(Math.random()*Y.length)]},redexOf(Y,Z,Q=0){let J=typeof this!=="string";if(!Y&&J)return-1;if(!J)Y=this;if(!Y.length)return-1;if(!(Z instanceof RegExp))if(Q>=0)return Y.indexOf(Z,Q);else return Y.lastIndexOf(Z,Y.length+Q);let z,K;if(Q>=0){z=-1;do{K=Y.substring(++z);let X=K.search(Z);if(X==-1)return-1;z=X+z}while(z<Q)}else{z=-1;do{K=Y.substring(++z);let X=K.search(Z);if(X==-1)return z-1;z=X+z}while(z<Y.length+Q)}return z},REGEXP:Object.freeze({Seperators:/[-\s_・⧸/\\;:()[\]、,.'""!^**=+「【】」()]/g,SoftWrapSeperators:/\x1b(?:\[[0-9;]*m|\]8;;[^\x07\x1b]*(?:\x07|\x1b\\))|([\s,.;:()[\]})])/g,HardWrapSeperators:/\x1b(?:\[[0-9;]*m|\]8;;[^\x07\x1b]*(?:\x07|\x1b\\))|([-_・⧸/\\、'""!^**=+「【】」()])/g,ValidEmail:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,ANSICode:/\x1b(?:\[[0-9;]*m|\]8;;[^\x07\x1b]*(?:\x07|\x1b\\))/g,EmojiDetection:new RegExp(s5),EmojiEach:new RegExp(s5,"g"),EmojiEachGroup:new RegExp("(?:"+s5+")+","g"),IniGroups:/^[\t ]*\[(.+)\][\t ]*$/gm,JSComments:/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g,OpenSCBrackets:/\\"|"(?:\\"|[^"])*"|([[{])/g,CloseSCBrackets:/\\"|"(?:\\"|[^"])*"|([\]}])/g}),resolveNodeEnv(Y,Z=/%(\w+)%/g){return Y.replace(Z,(Q,J)=>{let z=J;if(process.env[z]==null)return Q;return process.env[z]})},SafeTrue:class Y{#Z=0;limit=0;noWarning=!1;constructor(Z=10000000000,Q=!1){this.limit=Z,this.noWarning=Q}get True(){if(this.#Z++>=this.limit){if(!this.noWarning)process?.emitWarning("SafeTrue limit reached");return!1}return!0}},search(Y,Z,Q={}){let J=D.REGEXP.Seperators,z=Q.maxResult,K=Q.TF_IDFMaps instanceof Array?[...Q.TF_IDFMaps]:Q.TF_IDFMaps;if(!z)if(typeof Q=="number")z=Q;else z=1/0;if(Z=Z.trim().toLowerCase(),Z=="")return null;let X=[...Y];if(X.forEach((q,G,$)=>$[G]=q.trim().toLowerCase()),K==="builtin")K=D.DataScienceKit.TFIDF_of(X.concat(Z).map((q)=>D.cleanArr(q.split(J))));class H{constructor(q,G,$=-1,B=null){this.score=G,this.string=q,this.matchIndex=$,this.scores=B}}let W=[];for(let q=0;q<X.length;q++){let G=X[q].replace(J,"");if(X[q]==Z||G==Z)W.unshift(new H(Y[q],Z.length<<2,q));let $,B,V,F;$=B=V=F=0;for(let L of D.cleanArr(Z.split(J))){let N=0;if(D.includesWord(L,X[q],!1))if(K&&K[q]?.has(L))N=L.length*K[q].get(L).TF_IDF*2.9,$+=N;else N=L.length,B+=N;else if(X[q].includes(L))N=L.length*0.3,V+=N;let _=D.DataScienceKit.LCSLength_of(L,X[q])*0.4;F+=_}let M=$+B+V+F;W.push(new H(null,M,q,{tfidf_s:$,word_s:B,includes_s:V,lcs_s:F,TF_IDFMap:K?.[q]}))}W.sort((q,G)=>G.score-q.score);for(let q=0;q<z;q++){if(!W[q])break;if(W[q].string!=null)continue;W[q].string=Y[W[q].matchIndex]}return W.slice(0,z)},sleep(Y){if(!Y||Y<0)return;let Z=Date.now();while(Date.now()-Z<Y);},SpawnMirror:class Y{static STDIO_MIRROR=["inherit","pipe","pipe"];static createMirror(Z){Z?.stdout?.pipe(process.stdout),Z?.stderr?.pipe(process.stderr)}},strClamp(Y,Z,Q="mid",J=0){let z=D.ex_length(Y,J);if(z<=Z)return Y.padEnd(Z," ");let K=z-(z-Z)-3;switch(Q){default:if(uY)process?.emitWarning(`'${Q}' is not a valid location type.`);else throw Error(`'${Q}' is not a valid location type.`);case"mid":{let X=K>>1;return D.strSlice(Y,0,X,J)+"..."+D.strSlice(Y,z-X,void 0,J)}case"end":return D.strSlice(Y,0,K,J)+"...";case"start":return"..."+D.strSlice(Y,K,void 0,J)}},stringifyConfig(Y,Z={}){let{ignoreList:Q=[],minify:J=!1,replacer:z,mode:K="merge",useIniGroup:X=!1,alwaysWrapStrInQuotes:H=!1,oldConfigStr:W=""}=Z,q=new D.SafeTrue(1e5),G=K=="merge"?W:"";for(let F in Y){if(Q.includes(F))continue;if(!X){$(F,Y);continue}if(F===""||typeof Y[F]!=="object"){$(F,Y,"");continue}for(let M in Y[F]){if(Q.includes(M))continue;$(M,Y[F],F)}}return G;function $(F,M,L,N=!1){let _="";if(M[F]!=null&&typeof M[F]==="object")if(M[F].$multiValues){for(let m of M[F])$(F,{[F]:m},L,!0);return}else _=`${JSON.stringify(M[F],z,J?null:3)}
|
|
25
|
+
`;else if(typeof M[F]=="string")if(H||/\s|[{[}\]]/.test(M[F]))_=`"${M[F]}"`;else _=`${M[F]}`;else _=`${M[F]}`;let I=N?-1:D.redexOf(G,new RegExp(`^[ \\t]*\\b${F}\\s*=`,"m")),w;if(L==="")w=-3;else w=X?G.indexOf(`[${L}]`):null;let A=w===-1;if(A)w=G.length+2,G+=`
|
|
26
|
+
|
|
27
|
+
[${L}]
|
|
28
|
+
`;if(I==-1){let m=J?`${F}=${_}
|
|
29
|
+
`:`${F} = ${_}
|
|
30
|
+
`;if(X)if(A)G+=m+`
|
|
31
|
+
`;else{let r=D.redexOf(G,new RegExp(`^\\s*
|
|
32
|
+
$`,"m"),w);G=D.strSplice(G,r,0,m)}else G+=m;return}let x=null,E=null;if(X)x=D.redexOf(G.slice(0,I),D.REGEXP.IniGroups,-1),E=x==w?L:G.slice(x+1,G.slice(x,I).indexOf("]")+x);let h=G.indexOf("=",I)+1,u=D.getMatchAllIndexes(G.slice(h).matchAll(/(?<!\\)[#\n;]/g))?.[0]??-1;if(u==-1)u=G.length;else u+=h;let f=G[u]===`
|
|
33
|
+
`?u:G.indexOf(`
|
|
34
|
+
`,u+1);if(V(h,u))u=B(h);if(E&&E!==L){let m=G.slice(I,f+1),r=f-I,b=h-I,$0=u-I;if(G=D.strSplice(G,I,r+1,""),w>I)w-=r;else w++;I=w+L.length+2,h=I+b,u=I+$0,G=D.strSplice(G,I,0,m)}G=D.strSplice(G,h,u-h,(J?"":" ")+_);{let m=0;while(G[h+(m-2)]==" ")m--;if(J&&m<0)G=D.strSplice(G,h+m-1,-m,"");else if(!J&&m!==-1)G=D.strSplice(G,h+m-1,-m," ")}}function B(F){let M=0,L=F,N=!1;do{if(L++,N){if(G[L]=='"'&&G[L-1]!="\\")N=!1;continue}if(G[L]=='"'){N=!0;continue}if(G[L]=="{"||G[L]=="[")M++;if(G[L]=="}"||G[L]=="]")M--}while(M&&q.True);if(q.True==!1)throw Error(`failed to write config
|
|
35
|
+
Reason: loop limit reached`);return L+1}function V(F,M){return/^[\t ]*[[{]/.test(G.slice(F,M))}},strJustify(Y,Z,Q={}){let{filler:J=" ",align:z="center",overflow:K="hidden",collapseLocation:X="end",redundancyLv:H=0}=Q,W=Y instanceof Array,q=W?Y.join(""):Y,G=D.ex_length(q,H);if(G>Z){if(K=="collapse")return D.strLimit(q,Z,X);if(K=="hidden")return q.slice(0,Z);return q}switch(z){case"spacebetween":if(W){let $=J.repeat((Z-G)/(Y.length-1));return Y.reduce((B,V,F)=>{if(F==0)return B;return B+$+V},Y[0])}default:case"center":return D.strSurround(q,J,Z);case"right":return D.padStart(q,Z,J);case"left":return D.padEnd(q,Z,J)}},strLimit(Y,Z,Q="mid",J=0){let z=D.ex_length(Y,J);if(z<=Z)return Y;let K=z-(z-Z)-3;switch(Q){default:if(uY)process?.emitWarning(`'${Q}' is not a valid location type.`);else throw Error(`'${Q}' is not a valid location type.`);case"mid":{let X=K>>1;return D.strSlice(Y,0,X)+"..."+D.strSlice(Y,z-X+1)}case"end":return D.strSlice(Y,0,K)+"...";case"start":return"..."+D.strSlice(Y,z-K)}},strSlice(Y,Z,Q,J=0){let z=[...Y.matchAll(D.REGEXP.ANSICode)].map((H)=>{return{start:H.index,end:H.index+H[0].length,length:H[0].length}});if(!Q)Q=D.ex_length(Y,J);let K=0,X=0;for(let H=0;H<z.length;H++){if(z[H].start-K<Z)K+=z[H].length;if(z[H].start-X<=Q)X+=z[H].length;if(z[H].start-X>Q)break}return Y.slice(Z+K,Q+X)},strSplice(Y,Z,Q,J=null){if(Q<0)Q=0;if(Z<Y.length*-1)Z=0;if(J)return Y.slice(0,Z)+J+(Z<0&&Q+Z>=0?"":Y.slice(Z+Q));else return Y.slice(0,Z)+(Z<0&&Q+Z>=0?"":Y.slice(Z+Q))},strSurround(Y,Z,Q,J=0){let z=D.ex_length(Y,J),K=Math.ceil(Q/2-z/2);return D.padEnd(" ",K,Z,J)+D.padEnd(Y,Q/2+z/2,Z,J)},strWrap(Y,Z,Q={}){if(!Y)return"";let{indent:J="",firstIndent:z="",mode:K="softboundary",redundancyLv:X=0}=Q,H=[],W=K=="softboundary",q=Z*0.67,G=D.REGEXP.ANSICode,$=/[\s,.;:()[\]})]/,B=/[-_・⧸/\\、'""!^**=+「【】」()]/,V=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null,F=new Map;if(typeof z=="number")z="".padEnd(z," ");if(typeof J=="number")J="".padEnd(J," ");let M=Y.split(`
|
|
36
|
+
`);for(let _=0;_<M.length;_++){while(D.ex_length(M[_],X)>Z){let I=L(M[_]),w=I>0?I:Math.min(M[_].length,Z);if(J!=null)if(z!=null)H.push(z);else H.push(J);H.push(M[_].substring(0,w).concat(`
|
|
37
|
+
`)),M[_]=M[_].substring(w).trimStart()}if(J!=null)if(z!=null)H.push(z),z=null;else H.push(J);H.push(M[_].concat(_<M.length-1?`
|
|
38
|
+
`:""))}return H.join("");function L(_){let I=0,w=0,A=0,x=null,E=null,h=null,u=null,f=null,m=null,r=!1,b=0;G.lastIndex=0;let $0=G.exec(_);while($0&&!r){let n=$0.index??0;if(n>b){if(X0(_.slice(b,n)))break}if(e($0[0],!0))break;b=n+$0[0].length,$0=G.exec(_)}if(!r&&b<_.length)X0(_.slice(b));if(!W)return A||w||_.length;let t=h??u??f??m??x??E;if(t)return t.breakIndex;return A||w||_.length;function X0(n){if(!n)return!1;if(V&&X>=2){for(let U0 of V.segment(n))if(e(U0.segment,!1))return!0;return!1}if(X>=2){let U0=D.REGEXP.EmojiEach,M0=0;while(M0<n.length){U0.lastIndex=M0;let j0=U0.exec(n),C0=null;if(j0&&j0.index===M0)C0=j0[0],M0+=C0.length;else{let T0=n.codePointAt(M0);C0=String.fromCodePoint(T0),M0+=C0.length}if(e(C0,!1))return!0}return!1}for(let U0 of n)if(e(U0,!1))return!0;return!1}function e(n,U0){let M0=U0?X<0?n.length:0:N(n),j0=I+M0,C0=w;if(w+=n.length,!U0){if($.test(n)){let T0=n.trim().length===0,R0=T0?C0:w,N0=T0?I:j0,R1={breakIndex:R0,width:N0};if(N0<=Z){if(x=R1,N0>=q)h=R1}else if(!f)f=R1}if(B.test(n)){let T0={breakIndex:w,width:j0};if(T0.width<=Z){if(E=T0,T0.width>=q)u=T0}else if(!m)m=T0}}if(!A&&j0>=Z)if(j0===Z)A=w;else if(C0===0&&U0)A=w;else A=C0>0?C0:w;if(I=j0,!W)return I>=Z;if(I<Z)return!1;if(h||u)return!0;if(f||m)return!0;return!1}}function N(_){if(X<1)return _.length;let I=F.get(_);if(I!=null)return I;let w=D.ex_length(_,X);return F.set(_,w),w}},supportsColor(Y=process?.stdout){if(!uY)return 3;if(D.CheckCache.forceColor===!1)return 0;if(D.argvHasFlag("color=16m")||D.argvHasFlag("color=full")||D.argvHasFlag("color=truecolor"))return 3;if(D.argvHasFlag("color=256"))return 2;if(Y&&!Y.isTTY&&D.CheckCache.forceColor!==!0)return 0;let Z=D.CheckCache.forceColor?1:0;if(process.platform==="win32"){if(!D._modules.os)D._modules.os=TR("os");let J=D._modules.os.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}let{env:Q}=process;if("CI"in Q){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some((J)=>(J in Q))||Q.CI_NAME==="codeship")return 1;return Z}if("TEAMCITY_VERSION"in Q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Q.TEAMCITY_VERSION)?1:0;if(Q.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Q){let J=parseInt((Q.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Q.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Q.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Q.TERM))return 1;if("COLORTERM"in Q)return 1;if(Q.TERM==="dumb")return Z;return Z},supportsHyperlink(Y=process?.stdout,Z=!1){if(!uY)return!0;let{env:Q}=process;if(!Q)return!1;if("FORCE_HYPERLINK"in Q)return!(Q.FORCE_HYPERLINK.length>0&&parseInt(Q.FORCE_HYPERLINK,10)===0);if(D.argvHasFlag("no-hyperlink")||D.argvHasFlag("no-hyperlinks")||D.argvHasFlag("hyperlink=false")||D.argvHasFlag("hyperlink=never"))return!1;if(D.argvHasFlag("hyperlink=true")||D.argvHasFlag("hyperlink=always"))return!0;if("NETLIFY"in Q)return!0;if(D.CheckCache.supportsColor>0)return!0;if(Y&&!Y.isTTY)return!1;if(process.platform==="win32")return!1;if("CI"in Q)return!1;if("TEAMCITY_VERSION"in Q)return!1;if("TERM_PROGRAM"in Q){let z=J(Q.TERM_PROGRAM_VERSION);switch(Q.TERM_PROGRAM){case"iTerm.app":if(z.major===3)return z.minor>=1;return z.major>3;case"WezTerm":return z.major>=20200620;case"vscode":return z.major>1||z.major===1&&z.minor>=72}}if("VTE_VERSION"in Q){if(Q.VTE_VERSION==="0.50.0")return!1;let z=J(Q.VTE_VERSION);return z.major>0||z.minor>=50}return!1;function J(z){if(/^\d{3,4}$/.test(z)){let X=/(\d{1,2})(\d{2})/.exec(z);return{major:0,minor:parseInt(X[1],10),patch:parseInt(X[2],10)}}let K=(z||"").split(".").map((X)=>parseInt(X,10));return{major:K[0],minor:K[1],patch:K[2]}}},surroundedBy(Y,Z,Q){if(Z<0)return!1;let J=-1/0,z=1/0,K=Y=="{"||Y=="["||Y=="("||Y=="<";for(let H=Z;H>0;H-=2){let W=Q.lastIndexOf(Y,H);if(W==-1)break;else J=W;if(Q[J-1]=="\\")J=-1/0}for(let H=0;H<Q.length;H+=2){let W=Q.indexOf(K?X(Y):Y,H);if(W==-1)break;else z=W;if(Q[z-1]=="\\")z=1/0}if(J==-1/0||z==1/0)return!1;return J<Z&&z>Z;function X(H){return String.fromCharCode(H.charCodeAt(0)+(H[0]=="("?1:2))}},Timer:class Y{time;resolution;isRunning=!1;maxTime;#Z;#Q;#Y=0;#J;#z;constructor(Z,Q="ms"){switch(this.maxTime=this.time=Z,this.resolution=Q,Q){case"ms":this.#Z=1;break;case"s":this.#Z=1000;break;case"m":this.#Z=60000;break}}start(){if(this.isRunning||this.time<=0)return;return this.isRunning=!0,this.#Y=Date.now(),this.#Q=setInterval(this.#K,this.#Z==1?4:this.#Z/100),this}stop(){if(!this.isRunning)return;return clearInterval(this.#Q),this.isRunning=!1,this.reset()}pause(){if(!this.isRunning)return;clearInterval(this.#Q),this.isRunning=!1;return}reset(){return this.time=this.maxTime,this}async wait(){if(!this.isRunning)return;return new Promise((Z)=>{this.#z=()=>{this.#z=null,Z()}})}onceEnd(Z){return this.#J=Z,this}#K=()=>{let Z=Date.now(),Q=(Z-this.#Y)/this.#Z;if(this.time-=Q,this.#Y=Z,this.time>0)return;if(this.stop(),this.time=0,this.#J)this.#J(),this.#J=null;if(this.#z)this.#z()}},toPlace(Y){switch(Y){case 1:return"1st";case 2:return"2nd";case 3:return"3rd";default:return Y+"th"}},toShortNum(Y,Z=2,Q=1000,J=!1,z=-Number.MAX_SAFE_INTEGER,K=Number.MAX_SAFE_INTEGER){if(Y===0)return"0";let X=Math.abs(Y),H=Math.sign(Y),W=X>0&&X<1,q=D.MathKit.clamp(Math.floor(Math.log(X)/Math.log(Q)),z,K);Y=Y/Math.pow(Q,q)*H;let G=D.maxFraction(Y,Z,J),B={4:"T",2:"M",3:"G",1:"k",0:"","-1":"m","-2":"μ","-3":"n","-4":"p"}[q]??`e${W?"":"+"}${q*3}`;return G+B},Tracer:class Y{liveLog=!0;log="";startTime;enableLogging=!1;recursive=!1;constructor(){this.startTime=new Date}createTracker=function(Z,Q,J){let z=(K,X)=>{let H=K.length;if(H<=X)return K;let q=H-(H-X)-3>>1;return K.slice(0,q)+"..."+K.slice(H-q+1)};return function(){if(!J.enableLogging)return Z.apply(this,arguments);let K=Z.apply(this,arguments)??"void",X="["+D.jsTime.howLong(J.startTime)+"] "+Q+"(";for(let H=0;H<arguments.length;H++){if(H>0)X+=", ";let W=D.yuString(arguments[H]);X+=W.trim().length?z(W,70):`"${W}"`}if(K==="void")X+=")";else X+="): "+z(D.yuString(K),70);if(J.log+=X+`
|
|
39
|
+
`,J.liveLog)console.log(X);return K==="void"?void 0:K}};attachTracer(Z,Q=""){if(Q.length>100)return this;if(typeof Z!=="object")return this;for(let J of Object.getOwnPropertyNames(Z)){let z=Z[J];if(Object.prototype.toString.call(z)==="[object Function]"){if(!D.isClass(z))Z[J]=this.createTracker(z,Q+J,this);if(this.recursive&&D.propertiesCount(z)>0)for(let K of Object.getOwnPropertyNames(z)){let X=z[K];return this.attachTracer(X,Q+J+".")}}}return this}},writeConfig(Y,Z,Q={}){if(!D._modules.fs)throw Error('fs module is required for Tools.writeConfig()\nimport them with `Tools._modules.fs = require("fs")`');let{ignoreList:J=[],minify:z=!1,replacer:K,mode:X="merge",useIniGroup:H=!1,alwaysWrapStrInQuotes:W=!1}=Q,q="";if(D._modules.fs.existsSync(Z)&&X=="merge")q=D._modules.fs.readFileSync(Z,{encoding:"utf-8"});q=D.stringifyConfig(Y,{ignoreList:J,minify:z,replacer:K,mode:X,useIniGroup:H,alwaysWrapStrInQuotes:W,oldConfigStr:q}),D._modules.fs.writeFileSync(Z,q,{encoding:"utf-8"})},yuString(Y,Z={}){let{color:Q=!1,defColor:J=void 0}=Z;switch(typeof Y){case"string":if(Q)return D.ncc(8373322)+`"${Y}"`+D.ncc(J);return`"${Y}"`;case"bigint":case"number":if(Q)return D.ncc(11609489)+Y+D.ncc(J);case"boolean":case"undefined":if(Q)return D.ncc(15756194)+Y+D.ncc(J);return Y+"";case"function":if(Q)return(D.isAsyncFunction(Y)?D.ncc(4802889)+"async ":"")+(D.isArrowFunction(Y)?D.ncc(13401911)+(Y.name||D.ncc(4802889)+"[anonymous]"+D.ncc(13401911))+" () => {...}":D.ncc(13401911)+(Y.name||D.ncc(4802889)+"[anonymous]"+D.ncc(13401911))+"()")+D.ncc(J);return(D.isAsyncFunction(Y)?"async ":"")+(D.isArrowFunction(Y)?(Y.name||"[anonymous]")+" () => {...}":(Y.name||"[anonymous]")+"()");case"symbol":if(Q)return D.ncc(13401911)+Y.toString()+D.ncc(J);return Y.toString()}if(Y==null){if(Q)return D.ncc(13136006)+Y+D.ncc(J);return Y+""}if(Y instanceof Date){if(Q)return D.ncc(11550650)+"Date"+D.ncc(J)+" "+Y.toISOString();return"Date "+Y.toISOString()}if(Y instanceof RegExp){if(Q)return D.ncc("Yellow")+Y.toString()+D.ncc(J);return Y.toString()}if(Y instanceof Promise)return D.ncc(11550650)+"Promise"+D.ncc(J)+" {...(pending)}";if(Y instanceof Map){let z=[...Y.entries()];return(Q?D.ncc(11550650)+`Map(${Y.size}) {`+D.ncc(J):`Map(${Y.size}) {`)+D.arrToString(z,{color:Q,defColor:J,noHeader:!0})+"}"}if(Y instanceof Set){let z=[...Y.values()];return(Q?D.ncc(11550650)+`Set(${Y.size}) {`+D.ncc(J):`Set(${Y.size}) {`)+D.arrToString(z,{color:Q,defColor:J,noHeader:!0})+"}"}if(D.isError(Y))return D.Err.toString(Y,{color:Q,defColor:J});try{if(typeof Y==="object"){if(D.isArrayLike(Y))return D.arrToString(Y,{color:Q,defColor:J});return D.objToString(Y,{color:Q,defColor:J})}}catch{}return"[unknown]"}};if(typeof window<"u")window._tools=D;({arrFindLast:CA,arrToString:VK,argvHasFlag:AA,asyncSleep:kA,beautifyJson:EA,beforeExit:FK,changeDateTimezone:xA,charTypeAt:SA,CheckCache:l0,cleanArr:PA,cleanComments:vA,cleanString:RK,CONSTS:yA,Convert:fA,ConsoleTime:bA,compareDate:hA,DataScienceKit:gA,deferredFunc:mA,digitAt:uA,digitAtRange:dA,getDimensions:pA,Err:a,escapeRegExp:cA,estimateStrComplexity:m8,ex_length:D6,fileNameCleaner:lA,fixFilePath:nA,fixYTurl:iA,fileTypeOf:aA,getMatchAllIndexes:oA,getMatchAllResults:sA,getRandomInt:rA,getProcessTime:tA,hasEmojiEst:eA,hyperLink:s6,IDGenerator:Yk,includesWord:Zk,IPC:Qk,isArrayLike:Jk,isArrowFunction:zk,isAsyncFunction:Kk,isClass:Xk,isNumber:Hk,isEmptyArray:Wk,isEmptyObject:qk,isError:OK,isValidFilePath:Gk,JSONReplacer:Uk,JSONReviver:$k,jsTime:pY,lazySplit:Bk,remap:MK,MathKit:a0,maxFraction:u8,ncc:U,nearestNumber:Vk,objectMap:Fk,objValueAt:Rk,objToString:Ok,propertiesCount:Mk,padEnd:t5,padStart:Dk,parseArgs:Nk,parseBool:_k,parseConfig:Lk,parseValue:wk,pass:jk,Progress:Tk,proximate:Ik,randomPick:Ck,redexOf:Ak,REGEXP:kk,resolveNodeEnv:Ek,SafeTrue:xk,search:Sk,sleep:Pk,SpawnMirror:vk,strClamp:cY,stringifyConfig:yk,strJustify:Y6,strLimit:l4,strSlice:fk,strSplice:bk,strSurround:hk,strWrap:o,supportsColor:gk,supportsHyperlink:mk,surroundedBy:uk,Timer:dk,toPlace:pk,toShortNum:Z6,Tracer:ck,writeConfig:lk,yuString:g}=D)});var e5;var DK=O(()=>{e5={name:"gdx",version:"0.4.1",description:"Git, but with better DX. The raw power of Git, aligned with human workflows.",homepage:"https://github.com/Type-Delta/gdx#readme",bugs:{url:"https://github.com/Type-Delta/gdx/issues"},repository:{type:"git",url:"git+https://github.com/Type-Delta/gdx.git"},keywords:["git","dx","cli-wrapper"],license:"MIT",author:"Type-Delta",type:"module",main:"dist/index.js",bin:{gdx:"scripts/launcher.cjs"},files:["dist/*.js","scripts/postinstall.cjs","scripts/launcher.cjs","README.md","LICENSE"],packageManager:"bun@1.3.10",scripts:{"prepare-dev":"bun i && bun run transpile-esm",start:"bun run src/index.ts","start:profile":"bun --cpu-prof src/index.ts","start:node":"tsx src/index.ts","transpile-esm":"bunx tsc -p lib/tsconfig.json && bun run scripts/transform-tools.mjs",check:"bun run ts-check && bun run lint && bun run build",lint:"bun run ts-check && eslint src --ext .ts -c eslint.config.ts --fix",build:"bun run transpile-esm && bun build ./src/index.ts --outfile=./bin/gdx --compile --bytecode --production --keep-names","ts-check":"bunx tsc --noEmit","package:node":"bun run transpile-esm && bun build ./src/index.ts --outdir=./dist --target=node --external=keytar --external=cspell-lib --external=@shikijs/cli --format=esm --production --keep-names",prepack:"bun run package:node",postinstall:"node scripts/postinstall.cjs",prettier:'prettier --write "src/**/*.ts" "test/**/*.ts" "./*.md"',"dummy-editor":"bun ./scripts/dummyEditor.mjs"},devDependencies:{"@babel/cli":"^7.28.0","@babel/core":"^7.28.0","@babel/preset-env":"^7.27.2","@babel/preset-typescript":"^7.27.1","@eslint/js":"^9.22.0","@types/chai":"^5.2.3","@typescript-eslint/eslint-plugin":"^8.13.0","@typescript-eslint/parser":"^8.13.0",banditypes:"^0.3.0","bun-types":"latest",chai:"^6.2.1",dedent:"^1.7.0",eslint:"^9.22.0",execa:"^9.6.1",jiti:"^2.6.1",openai:"^6.14.0",prettier:"^3.6.2","smol-toml":"^1.5.2",tinybench:"^6.0.0",tsx:"^4.21.0",typescript:"^5.8.3","typescript-eslint":"^8.50.0","unicode-animations":"^1.0.3"},dependencies:{"@shikijs/cli":"^3.22.0","cspell-lib":"9.4.0",keytar:"^7.9.0"}}});function n0(Y){return Y.replace(/\\/g,"/")}import d8 from"fs";import kR from"path";import ER from"fs/promises";import{existsSync as l,readFileSync as N6,writeFileSync as r6,mkdirSync as H1,mkdtempSync as LK,rmSync as t6,accessSync as wK,readdirSync as b1,appendFileSync as jK,unlinkSync as YQ,constants as ZQ}from"fs";import{access as TK,rm as IK,rmdir as ZE,mkdir as QQ,readdir as p8,readlink as QE,stat as e6,link as JE,unlink as c8,writeFile as Y1,appendFile as zE,readFile as S0}from"fs/promises";async function n4(Y){if(!Y)return;try{if(!d8.existsSync(Y))return;return(await ER.stat(Y)).mtimeMs}catch{return}}function NK(Y){if(!Y)return"";let Z=Y;try{Z=d8.realpathSync.native?d8.realpathSync.native(Y):d8.realpathSync(Y)}catch{Z=kR.resolve(Y)}return process.platform==="win32"?n0(Z).toLowerCase():Z}function _K(Y,Z){let Q=NK(Y).replace(/\/+$/,""),J=NK(Z).replace(/\/+$/,"");if(!Q||!J)return!1;if(J===Q)return!0;return J.startsWith(`${Q}/`)}var o0=()=>{};import{constants as xR}from"fs";function j(Y,Z=`
|
|
40
|
+
`){if(CK){CK(Y+Z);return}process.stdout.write(Y+Z)}async function JQ(Y){try{if(!(await e6(Y)).isFile())return!1;return await TK(Y,xR.X_OK),!0}catch{return!1}}function P0(Y,Z,Q=!1){if(Y==="")return{match:null,candidates:Z,isExact:!1};let J=[];for(let z of Z){if(z===Y)return{match:z,candidates:null,isExact:!0};if(z.startsWith(Y))J.push(z)}if(Q&&J.length>1)J=[J[0]];return{match:J.length===1?J[0]:null,candidates:J,isExact:J.includes(Y)}}function _6(Y){return Y.map((Z)=>{if(/[\s"`$\\]/.test(Z))return`"${Z.replace(/(["\\$`])/g,"\\$1")}"`;return Z})}function zQ(Y){if(!Y)return"";return Y.replace(/[/\\]/g,"_").replace(/[<>:"|?*\x00-\x1f]/g,"_")}function AK(Y){return["1","true","yes","on"].includes(Y.toLowerCase())}function kK(Y,Z){let Q=Y.split(".").map(Number),J=Z.split(".").map(Number),z=Math.max(Q.length,J.length);for(let K=0;K<z;K++){let X=Q[K]||0,H=J[K]||0;if(X>H)return 1;if(X<H)return-1}return 0}var CK=null,k1=()=>{};var L0=O(()=>{o0()});import XQ from"os";import YY from"path";var KQ,C,O1,UE,EK=".gdxrc.toml",xK,i4,HQ,l8=1,ZY=150,Q6,E1,SK,WQ,n8="gdx-cli",L6,SR="cache.json",PR="macro.json",PK="catppuccin-mocha",k,Q0,vK,QY,yK,i8=86400000,M1,JY,a8=360,fK=7,bK="https://openrouter.ai/api/v1",hK=512000,a4,gK,mK,uK,dK,pK,cK;var W0=O(()=>{DK();L0();KQ=YY.basename(process.argv[0]||"gdx",YY.extname(process.argv[0]||"")),C=KQ.startsWith("bun")||KQ.startsWith("node")?"gdx":KQ,O1=process.env.GDX_TEMP_DIR||XQ.tmpdir(),UE=process.env.GDX_CURRENT_DIR||process.cwd(),xK=YY.join(XQ.homedir(),".gdx"),i4=YY.join(xK,EK),HQ=YY.join(XQ.homedir(),EK),Q6=process.env.GDX_RESULT,E1=e5.version||"unknown",SK=e5.homepage||"",WQ=process.env.GDX_WRITE_LOGS!=null?AK(process.env.GDX_WRITE_LOGS):!0,L6=["llm.apiKey"],k={OceanDeepBlue:[46,149,153],OceanGreen:[57,211,83],ForestGreen:[34,139,34],SunsetOrange:[255,99,71],MidnightBlack:[10,16,36],Zinc700:[63,63,70],Zinc400:[161,161,170],Zinc100:[244,244,245],Fuchsia400:[232,121,249],Teal300:[94,234,212]},Q0={base:[30,30,46],mantle:[24,24,37],crust:[17,17,27],surface0:[49,50,68],surface1:[69,71,90],overlay0:[147,153,178],overlay1:[127,132,156],text:[205,214,244],green:[166,227,161],red:[243,139,168],yellow:[249,226,175],blue:[137,180,250],cyan:[148,226,213],lavender:[180,190,254]},vK=["⠁⠀","⠋⠀","⠟⠁","⡿⠋","⣿⠟","⣿⡿","⣿⣿","⣿⣿","⣾⣿","⣴⣿","⣠⣾","⢀⣴","⠀⣠","⠀⢀","⠀⠀","⠀⠀"],QY={AVG_CHARS_PER_LINE:40,AVG_LINES_PER_FUNCTION:45,AVG_LINES_PER_FILE:500},yK=[/api[\w_-]?key[\w_-]?\s*=\s*['"].+['"]/i,/access[\w_-]?token[\w_-]?\s*=\s*['"].+['"]/i,/private[\w_-]?key[\w_-]?\s*=\s*['"].+['"]/i,/sk-ant-[\d\w]{32,}/,/sk-[\d\w]{32,}/,/sk-or-[\d\w]{32,}/,/-----\s*BEGIN PRIVATE KEY\s*-----/i],M1=YY.join(O1,"gdx",SR),JY=YY.join(xK,PR),a4=["add","branch","checkout","clone","commit","diff","log","pull","push","rebase","reset","revert","merge","init","stash","status","switch","submodule","tag","fetch","remote","show","config","parallel","nocap","clear","reword","gdx-config","graph","macro","cache","doctor"],gK=["s","st","co","br","cmi","mg","pl","pu","ps","ad","rv","rb","lg","sta"],mK=["--loglevel","--ghelp","--bypass","--no-enhance"],uK=["--loglevel","--init","--shell","--cmd"],dK=["--ghelp","--bypass","--no-enhance","-gh"],pK=["-C","-c","--git-dir","--work-tree","--namespace","--config-env"],cK=["--no-pager","--no-optional-locks","--literal-pathspecs","--glob-pathspecs","--noglob-pathspecs","--icase-pathspecs"]});function d(Y,Z,Q,J=0,z=1){if(J<0)J=0;else if(z>1)z=1;if(!(J<z)||l0.supportsColor<3)return Y;let K=Y.length,X=Math.floor(K*J),H=Math.floor(K*z),W=H-X,q=(Q[0]-Z[0])/W,G=(Q[1]-Z[1])/W,$=(Q[2]-Z[2])/W,B="";for(let V=0;V<K;V++)if(V<X)B+=`\x1B[38;2;${Z[0]};${Z[1]};${Z[2]}m${Y[V]}`;else if(V>=X&&V<=H){let F=V-X,M=Math.round(a0.clamp(Z[0]+q*F,0,255)),L=Math.round(a0.clamp(Z[1]+G*F,0,255)),N=Math.round(a0.clamp(Z[2]+$*F,0,255));B+=`\x1B[38;2;${M};${L};${N}m${Y[V]}`}else B+=`\x1B[38;2;${Q[0]};${Q[1]};${Q[2]}m${Y[V]}`;return B+="\x1B[0m",B}function lK(Y,Z,Q){let J=a0.clamp(Math.round(Y[0]+(Z[0]-Y[0])*Q),0,255),z=a0.clamp(Math.round(Y[1]+(Z[1]-Y[1])*Q),0,255),K=a0.clamp(Math.round(Y[2]+(Z[2]-Y[2])*Q),0,255);return[J,z,K]}function nK(Y,Z,Q,J=0.5,z=0.3){if(J<0)J=0;else if(J>1)J=1;if(z<=0||l0.supportsColor<3)return Y;let K=Y.length,X=J*K,H=z*K,W="";for(let q=0;q<K;q++){let $=Math.abs(q-X)/H;$=a0.clamp($,0,1);let B=Math.round(a0.clamp(Z[0]+(Q[0]-Z[0])*$,0,255)),V=Math.round(a0.clamp(Z[1]+(Q[1]-Z[1])*$,0,255)),F=Math.round(a0.clamp(Z[2]+(Q[2]-Z[2])*$,0,255));W+=`\x1B[38;2;${B};${V};${F}m${Y[q]}`}return W+="\x1B[0m",W}function zY(Y){let Z=a0.clamp(Math.round(Y[0]),0,255),Q=a0.clamp(Math.round(Y[1]),0,255),J=a0.clamp(Math.round(Y[2]),0,255);return(Z<<16)+(Q<<8)+J}function iK(Y,Z,Q){let J,z,K;if(Z===0)J=z=K=Q;else{let X=(q,G,$)=>{if($<0)$+=1;if($>1)$-=1;if($<0.16666666666666666)return q+(G-q)*6*$;if($<0.5)return G;if($<0.6666666666666666)return q+(G-q)*(0.6666666666666666-$)*6;return q},H=Q<0.5?Q*(1+Z):Q+Z-Q*Z,W=2*Q-H;J=X(W,H,Y+0.3333333333333333),z=X(W,H,Y),K=X(W,H,Y-0.3333333333333333)}return[Math.round(J*255),Math.round(z*255),Math.round(K*255)]}function J6(Y,Z,Q){return[Math.round(Y[0]*(1-Q)+Z[0]*Q),Math.round(Y[1]*(1-Q)+Z[1]*Q),Math.round(Y[2]*(1-Q)+Z[2]*Q)]}function f0(Y){return`\x1B[38;2;${Y[0]};${Y[1]};${Y[2]}m`}function D1(Y){return`\x1B[48;2;${Y[0]};${Y[1]};${Y[2]}m`}function lY(Y){return Y.replace(/\x1b\[[0-9;]*m/g,"")}function o4(Y,Z,Q,J,z){let H=0,W=1,q=Y;for(let G=0;G<10;G++){let B=vR(q,Z,J)-Y;if(Math.abs(B)<0.000001)break;if(B>0)W=q;else H=q;q=(H+W)/2}return yR(q,Q,z)}function vR(Y,Z,Q){let J=1-Y;return 3*J*J*Y*Z+3*J*Y*Y*Q+Y*Y*Y}function yR(Y,Z,Q){let J=1-Y;return 3*J*J*Y*Z+3*J*Y*Y*Q+Y*Y*Y}var aK;var A0=O(()=>{H0();aK={linear:(Y)=>Y,easeIn:(Y)=>o4(Y,0.42,0,1,1),easeOut:(Y)=>o4(Y,0,0,0.58,1),easeInOut:(Y)=>o4(Y,0.42,0,0.58,1),smooth:(Y)=>o4(Y,0.25,0.1,0.25,1),bounce:(Y)=>o4(Y,0.68,-0.55,0.265,1.55)}});var c;var v0=O(()=>{c={exitCodeOverride:-1,finalStringOutput:"",logLevel:"warn",terminalWidth:process.stdout.columns||100}});function k0(Y){if(typeof Y!=="object"||Y===null)return!1;let Z=Object.getPrototypeOf(Y);return(Z===null||Z===Object.prototype||Object.getPrototypeOf(Z)===null)&&!(Symbol.toStringTag in Y)&&!(Symbol.iterator in Y)}import{fileURLToPath as fR}from"node:url";var nY=(Y,Z)=>{let Q=GQ(bR(Y));if(typeof Q!=="string")throw TypeError(`${Z} must be a string or a file URL: ${Q}.`);return Q},bR=(Y)=>qQ(Y)?Y.toString():Y,qQ=(Y)=>typeof Y!=="string"&&Y&&Object.getPrototypeOf(Y)===String.prototype,GQ=(Y)=>Y instanceof URL?fR(Y):Y;var iY=()=>{};var o8=(Y,Z=[],Q={})=>{let J=nY(Y,"First argument"),[z,K]=k0(Z)?[[],Z]:[Z,Q];if(!Array.isArray(z))throw TypeError(`Second argument must be either an array of arguments or an options object: ${z}`);if(z.some((W)=>typeof W==="object"&&W!==null))throw TypeError(`Second argument must be an array of strings: ${z}`);let X=z.map(String),H=X.find((W)=>W.includes("\x00"));if(H!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${H}`);if(!k0(K))throw TypeError(`Last argument must be an options object: ${K}`);return[J,X,K]};var UQ=O(()=>{iY()});import{StringDecoder as hR}from"node:string_decoder";var oK,sK=(Y)=>oK.call(Y)==="[object ArrayBuffer]",b0=(Y)=>oK.call(Y)==="[object Uint8Array]",z6=(Y)=>new Uint8Array(Y.buffer,Y.byteOffset,Y.byteLength),gR,rK=(Y)=>gR.encode(Y),mR,s8=(Y)=>mR.decode(Y),tK=(Y,Z)=>{return uR(Y,Z).join("")},uR=(Y,Z)=>{if(Z==="utf8"&&Y.every((K)=>typeof K==="string"))return Y;let Q=new hR(Z),J=Y.map((K)=>typeof K==="string"?rK(K):K).map((K)=>Q.write(K)),z=Q.end();return z===""?J:[...J,z]},s4=(Y)=>{if(Y.length===1&&b0(Y[0]))return Y[0];return $Q(dR(Y))},dR=(Y)=>Y.map((Z)=>typeof Z==="string"?rK(Z):Z),$Q=(Y)=>{let Z=new Uint8Array(pR(Y)),Q=0;for(let J of Y)Z.set(J,Q),Q+=J.length;return Z},pR=(Y)=>{let Z=0;for(let Q of Y)Z+=Q.length;return Z};var W1=O(()=>{({toString:oK}=Object.prototype),gR=new TextEncoder,mR=new TextDecoder});import{ChildProcess as cR}from"node:child_process";var QX=(Y)=>Array.isArray(Y)&&Array.isArray(Y.raw),JX=(Y,Z)=>{let Q=[];for(let[K,X]of Y.entries())Q=lR({templates:Y,expressions:Z,tokens:Q,index:K,template:X});if(Q.length===0)throw TypeError("Template script must not be empty");let[J,...z]=Q;return[J,z,{}]},lR=({templates:Y,expressions:Z,tokens:Q,index:J,template:z})=>{if(z===void 0)throw TypeError(`Invalid backslash sequence: ${Y.raw[J]}`);let{nextTokens:K,leadingWhitespaces:X,trailingWhitespaces:H}=nR(z,Y.raw[J]),W=YX(Q,K,X);if(J===Z.length)return W;let q=Z[J],G=Array.isArray(q)?q.map(($)=>ZX($)):[ZX(q)];return YX(W,G,H)},nR=(Y,Z)=>{if(Z.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let Q=[],J=0,z=eK.has(Z[0]);for(let X=0,H=0;X<Y.length;X+=1,H+=1){let W=Z[H];if(eK.has(W)){if(J!==X)Q.push(Y.slice(J,X));J=X+1}else if(W==="\\"){let q=Z[H+1];if(q===`
|
|
41
|
+
`)X-=1,H+=1;else if(q==="u"&&Z[H+2]==="{")H=Z.indexOf("}",H+3);else H+=iR[q]??1}}let K=J===Y.length;if(!K)Q.push(Y.slice(J));return{nextTokens:Q,leadingWhitespaces:z,trailingWhitespaces:K}},eK,iR,YX=(Y,Z,Q)=>Q||Y.length===0||Z.length===0?[...Y,...Z]:[...Y.slice(0,-1),`${Y.at(-1)}${Z[0]}`,...Z.slice(1)],ZX=(Y)=>{let Z=typeof Y;if(Z==="string")return Y;if(Z==="number")return String(Y);if(k0(Y)&&(("stdout"in Y)||("isMaxBuffer"in Y)))return aR(Y);if(Y instanceof cR||Object.prototype.toString.call(Y)==="[object Promise]")throw TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw TypeError(`Unexpected "${Z}" in template expression`)},aR=({stdout:Y})=>{if(typeof Y==="string")return Y;if(b0(Y))return s8(Y);if(Y===void 0)throw TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw TypeError(`Unexpected "${typeof Y}" stdout in template expression`)};var zX=O(()=>{W1();eK=new Set([" ","\t","\r",`
|
|
42
|
+
`]),iR={x:3,u:5}});import BQ from"node:process";var x1=(Y)=>r8.includes(Y),r8,N1,t8=(Y)=>N1[Y]??`stdio[${Y}]`;var K6=O(()=>{r8=[BQ.stdin,BQ.stdout,BQ.stderr],N1=["stdin","stdout","stderr"]});import{debuglog as oR}from"node:util";var XX=(Y)=>{let Z={...Y};for(let Q of RQ)Z[Q]=VQ(Y,Q);return Z},VQ=(Y,Z)=>{let Q=Array.from({length:sR(Y)+1}),J=rR(Y[Z],Q,Z);return QO(J,Z)},sR=({stdio:Y})=>Array.isArray(Y)?Math.max(Y.length,N1.length):N1.length,rR=(Y,Z,Q)=>k0(Y)?tR(Y,Z,Q):Z.fill(Y),tR=(Y,Z,Q)=>{for(let J of Object.keys(Y).sort(eR))for(let z of YO(J,Q,Z))Z[z]=Y[J];return Z},eR=(Y,Z)=>KX(Y)<KX(Z)?1:-1,KX=(Y)=>{if(Y==="stdout"||Y==="stderr")return 0;return Y==="all"?2:1},YO=(Y,Z,Q)=>{if(Y==="ipc")return[Q.length-1];let J=FQ(Y);if(J===void 0||J===0)throw TypeError(`"${Z}.${Y}" is invalid.
|
|
43
43
|
It must be "${Z}.stdout", "${Z}.stderr", "${Z}.all", "${Z}.ipc", or "${Z}.fd3", "${Z}.fd4" (and so on).`);if(J>=Q.length)throw TypeError(`"${Z}.${Y}" is invalid: that file descriptor does not exist.
|
|
44
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);return J==="all"?[1,2]:[J]},
|
|
45
|
-
`).map((Z)=>
|
|
46
|
-
`),
|
|
44
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);return J==="all"?[1,2]:[J]},FQ=(Y)=>{if(Y==="all")return Y;if(N1.includes(Y))return N1.indexOf(Y);let Z=ZO.exec(Y);if(Z!==null)return Number(Z[1])},ZO,QO=(Y,Z)=>Y.map((Q)=>Q===void 0?zO[Z]:Q),JO,zO,RQ,X6=(Y,Z)=>Z==="ipc"?Y.at(-1):Y[Z];var H6=O(()=>{K6();ZO=/^fd(\d+)$/,JO=oR("execa").enabled?"full":"none",zO={lines:!1,buffer:!0,maxBuffer:1e8,verbose:JO,stripFinalNewline:!0},RQ=["lines","buffer","maxBuffer","verbose","stripFinalNewline"]});var aY=({verbose:Y},Z)=>OQ(Y,Z)!=="none",oY=({verbose:Y},Z)=>!["none","short"].includes(OQ(Y,Z)),HX=({verbose:Y},Z)=>{let Q=OQ(Y,Z);return e8(Q)?Q:void 0},OQ=(Y,Z)=>Z===void 0?KO(Y):X6(Y,Z),KO=(Y)=>Y.find((Z)=>e8(Z))??Y2.findLast((Z)=>Y.includes(Z)),e8=(Y)=>typeof Y==="function",Y2;var w6=O(()=>{H6();Y2=["none","short","full"]});import{platform as XO}from"node:process";import{stripVTControlCharacters as HO}from"node:util";var WX=(Y,Z)=>{let Q=[Y,...Z],J=Q.join(" "),z=Q.map((K)=>BO(qX(K))).join(" ");return{command:J,escapedCommand:z}},r4=(Y)=>HO(Y).split(`
|
|
45
|
+
`).map((Z)=>qX(Z)).join(`
|
|
46
|
+
`),qX=(Y)=>Y.replaceAll(GO,(Z)=>WO(Z)),WO=(Y)=>{let Z=UO[Y];if(Z!==void 0)return Z;let Q=Y.codePointAt(0),J=Q.toString(16);return Q<=$O?`\\u${J.padStart(4,"0")}`:`\\U${J}`},qO=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},GO,UO,$O=65535,BO=(Y)=>{if(VO.test(Y))return Y;return XO==="win32"?`"${Y.replaceAll('"','""')}"`:`'${Y.replaceAll("'","'\\''")}'`},VO;var Z2=O(()=>{GO=qO(),UO={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},VO=/^[\w./-]+$/});import GX from"node:process";function MQ(){let{env:Y}=GX,{TERM:Z,TERM_PROGRAM:Q}=Y;if(GX.platform!=="win32")return Z!=="linux";return Boolean(Y.WT_SESSION)||Boolean(Y.TERMINUS_SUBLIME)||Y.ConEmuTask==="{cmd::Cmder}"||Q==="Terminus-Sublime"||Q==="vscode"||Z==="xterm-256color"||Z==="alacritty"||Z==="rxvt-unicode"||Z==="rxvt-unicode-256color"||Y.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var UX=()=>{};var $X,BX,FO,RO,OO,MO,DO,Q2,dE;var VX=O(()=>{UX();$X={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},BX={tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},FO={tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},RO={...$X,...BX},OO={...$X,...FO},MO=MQ(),DO=MO?RO:OO,Q2=DO,dE=Object.entries(BX)});import NO from"node:tty";var _O,J0=(Y,Z)=>{if(!_O)return(z)=>z;let Q=`\x1B[${Y}m`,J=`\x1B[${Z}m`;return(z)=>{let K=z+"",X=K.indexOf(J);if(X===-1)return Q+K+J;let H=Q,W=0,G=(Z===22?J:"")+Q;while(X!==-1)H+=K.slice(W,X)+G,W=X+J.length,X=K.indexOf(J,W);return H+=K.slice(W)+J,H}},lE,FX,nE,iE,aE,oE,sE,rE,tE,eE,Yx,Zx,Qx,Jx,zx,Kx,Xx,J2,Hx,Wx,qx,Gx,Ux,$x,Bx,Vx,Fx,RX,Rx,OX,Ox,Mx,Dx,Nx,_x,Lx,wx,jx,Tx,Ix,Cx;var MX=O(()=>{_O=NO?.WriteStream?.prototype?.hasColors?.()??!1,lE=J0(0,0),FX=J0(1,22),nE=J0(2,22),iE=J0(3,23),aE=J0(4,24),oE=J0(53,55),sE=J0(7,27),rE=J0(8,28),tE=J0(9,29),eE=J0(30,39),Yx=J0(31,39),Zx=J0(32,39),Qx=J0(33,39),Jx=J0(34,39),zx=J0(35,39),Kx=J0(36,39),Xx=J0(37,39),J2=J0(90,39),Hx=J0(40,49),Wx=J0(41,49),qx=J0(42,49),Gx=J0(43,49),Ux=J0(44,49),$x=J0(45,49),Bx=J0(46,49),Vx=J0(47,49),Fx=J0(100,49),RX=J0(91,39),Rx=J0(92,39),OX=J0(93,39),Ox=J0(94,39),Mx=J0(95,39),Dx=J0(96,39),Nx=J0(97,39),_x=J0(101,49),Lx=J0(102,49),wx=J0(103,49),jx=J0(104,49),Tx=J0(105,49),Ix=J0(106,49),Cx=J0(107,49)});var DX=O(()=>{MX()});var LX=({type:Y,message:Z,timestamp:Q,piped:J,commandId:z,result:{failed:K=!1}={},options:{reject:X=!0}})=>{let H=LO(Q),W=wO[Y]({failed:K,reject:X,piped:J}),q=jO[Y]({reject:X});return`${J2(`[${H}]`)} ${J2(`[${z}]`)} ${q(W)} ${q(Z)}`},LO=(Y)=>`${z2(Y.getHours(),2)}:${z2(Y.getMinutes(),2)}:${z2(Y.getSeconds(),2)}.${z2(Y.getMilliseconds(),3)}`,z2=(Y,Z)=>String(Y).padStart(Z,"0"),NX=({failed:Y,reject:Z})=>{if(!Y)return Q2.tick;return Z?Q2.cross:Q2.warning},wO,_X=(Y)=>Y,jO;var wX=O(()=>{VX();DX();wO={command:({piped:Y})=>Y?"|":"$",output:()=>" ",ipc:()=>"*",error:NX,duration:NX},jO={command:()=>FX,output:()=>_X,ipc:()=>_X,error:({reject:Y})=>Y?RX:OX,duration:()=>J2}});var jX=(Y,Z,Q)=>{let J=HX(Z,Q);return Y.map(({verboseLine:z,verboseObject:K})=>TO(z,K,J)).filter((z)=>z!==void 0).map((z)=>IO(z)).join("")},TO=(Y,Z,Q)=>{if(Q===void 0)return Y;let J=Q(Y,Z);if(typeof J==="string")return J},IO=(Y)=>Y.endsWith(`
|
|
47
47
|
`)?Y:`${Y}
|
|
48
|
-
`;var
|
|
49
|
-
`).map((Q)=>wR({...Z,message:Q})),wR=(Y)=>{return{verboseLine:fX(Y),verboseObject:Y}},bZ=(Y)=>{let Z=typeof Y==="string"?Y:OR(Y);return v8(Z).replaceAll("\t"," ".repeat(LR))},LR=2;var y1=R(()=>{SZ();bX();gX()});var mX=(Y,Z)=>{if(!S1(Z))return;DY({type:"command",verboseMessage:Y,verboseInfo:Z})};var uX=R(()=>{W6();y1()});var dX=(Y,Z,Q)=>{jR(Y);let J=_R(Y);return{verbose:Y,escapedCommand:Z,commandId:J,rawOptions:Q}},_R=(Y)=>S1({verbose:Y})?IR++:void 0,IR=0n,jR=(Y)=>{for(let Z of Y){if(Z===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(Z===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!PZ.includes(Z)&&!EZ(Z)){let Q=PZ.map((J)=>`'${J}'`).join(", ");throw TypeError(`The "verbose" option must not be ${Z}. Allowed values are: ${Q} or a function.`)}}};var pX=R(()=>{W6()});import{hrtime as cX}from"node:process";var hZ=()=>cX.bigint(),l5=(Y)=>Number(cX.bigint()-Y)/1e6;var gZ=()=>{};var mZ=(Y,Z,Q)=>{let J=hZ(),{command:z,escapedCommand:X}=_X(Y,Z),H=g5(Q,"verbose"),W=dX(H,X,{...Q});return mX(X,W),{command:z,escapedCommand:X,startTime:J,verboseInfo:W}};var i5=R(()=>{uX();pX();gZ();SZ();pY()});var oX=p0((Jx,aX)=>{aX.exports=nX;nX.sync=CR;var lX=$Y("fs");function TR(Y,Z){var Q=Z.pathExt!==void 0?Z.pathExt:process.env.PATHEXT;if(!Q)return!0;if(Q=Q.split(";"),Q.indexOf("")!==-1)return!0;for(var J=0;J<Q.length;J++){var z=Q[J].toLowerCase();if(z&&Y.substr(-z.length).toLowerCase()===z)return!0}return!1}function iX(Y,Z,Q){if(!Y.isSymbolicLink()&&!Y.isFile())return!1;return TR(Z,Q)}function nX(Y,Z,Q){lX.stat(Y,function(J,z){Q(J,J?!1:iX(z,Y,Z))})}function CR(Y,Z){return iX(lX.statSync(Y),Y,Z)}});var YH=p0((zx,eX)=>{eX.exports=rX;rX.sync=kR;var sX=$Y("fs");function rX(Y,Z,Q){sX.stat(Y,function(J,z){Q(J,J?!1:tX(z,Z))})}function kR(Y,Z){return tX(sX.statSync(Y),Z)}function tX(Y,Z){return Y.isFile()&&AR(Y,Z)}function AR(Y,Z){var{mode:Q,uid:J,gid:z}=Y,X=Z.uid!==void 0?Z.uid:process.getuid&&process.getuid(),H=Z.gid!==void 0?Z.gid:process.getgid&&process.getgid(),W=parseInt("100",8),K=parseInt("010",8),$=parseInt("001",8),G=W|K,U=Q&$||Q&K&&z===H||Q&W&&J===X||Q&G&&X===0;return U}});var QH=p0((Hx,ZH)=>{var Xx=$Y("fs"),uZ;if(process.platform==="win32"||global.TESTING_WINDOWS)uZ=oX();else uZ=YH();ZH.exports=n5;n5.sync=xR;function n5(Y,Z,Q){if(typeof Z==="function")Q=Z,Z={};if(!Q){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(J,z){n5(Y,Z||{},function(X,H){if(X)z(X);else J(H)})})}uZ(Y,Z||{},function(J,z){if(J){if(J.code==="EACCES"||Z&&Z.ignoreErrors)J=null,z=!1}Q(J,z)})}function xR(Y,Z){try{return uZ.sync(Y,Z||{})}catch(Q){if(Z&&Z.ignoreErrors||Q.code==="EACCES")return!1;else throw Q}}});var GH=p0((Wx,KH)=>{var f1=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",JH=$Y("path"),ER=f1?";":":",zH=QH(),XH=(Y)=>Object.assign(Error(`not found: ${Y}`),{code:"ENOENT"}),HH=(Y,Z)=>{let Q=Z.colon||ER,J=Y.match(/\//)||f1&&Y.match(/\\/)?[""]:[...f1?[process.cwd()]:[],...(Z.path||process.env.PATH||"").split(Q)],z=f1?Z.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",X=f1?z.split(Q):[""];if(f1){if(Y.indexOf(".")!==-1&&X[0]!=="")X.unshift("")}return{pathEnv:J,pathExt:X,pathExtExe:z}},WH=(Y,Z,Q)=>{if(typeof Z==="function")Q=Z,Z={};if(!Z)Z={};let{pathEnv:J,pathExt:z,pathExtExe:X}=HH(Y,Z),H=[],W=($)=>new Promise((G,U)=>{if($===J.length)return Z.all&&H.length?G(H):U(XH(Y));let B=J[$],F=/^".*"$/.test(B)?B.slice(1,-1):B,V=JH.join(F,Y),O=!F&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+V:V;G(K(O,$,0))}),K=($,G,U)=>new Promise((B,F)=>{if(U===z.length)return B(W(G+1));let V=z[U];zH($+V,{pathExt:X},(O,N)=>{if(!O&&N)if(Z.all)H.push($+V);else return B($+V);return B(K($,G,U+1))})});return Q?W(0).then(($)=>Q(null,$),Q):W(0)},PR=(Y,Z)=>{Z=Z||{};let{pathEnv:Q,pathExt:J,pathExtExe:z}=HH(Y,Z),X=[];for(let H=0;H<Q.length;H++){let W=Q[H],K=/^".*"$/.test(W)?W.slice(1,-1):W,$=JH.join(K,Y),G=!K&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+$:$;for(let U=0;U<J.length;U++){let B=G+J[U];try{if(zH.sync(B,{pathExt:z}))if(Z.all)X.push(B);else return B}catch(F){}}}if(Z.all&&X.length)return X;if(Z.nothrow)return null;throw XH(Y)};KH.exports=WH;WH.sync=PR});var qH=p0((Kx,a5)=>{var $H=(Y={})=>{let Z=Y.env||process.env;if((Y.platform||process.platform)!=="win32")return"PATH";return Object.keys(Z).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"};a5.exports=$H;a5.exports.default=$H});var FH=p0((Gx,VH)=>{var UH=$Y("path"),SR=GH(),vR=qH();function BH(Y,Z){let Q=Y.options.env||process.env,J=process.cwd(),z=Y.options.cwd!=null,X=z&&process.chdir!==void 0&&!process.chdir.disabled;if(X)try{process.chdir(Y.options.cwd)}catch(W){}let H;try{H=SR.sync(Y.command,{path:Q[vR({env:Q})],pathExt:Z?UH.delimiter:void 0})}catch(W){}finally{if(X)process.chdir(J)}if(H)H=UH.resolve(z?Y.options.cwd:"",H);return H}function yR(Y){return BH(Y)||BH(Y,!0)}VH.exports=yR});var RH=p0((hR,s5)=>{var o5=/([()\][%!^"`<>&|;, *?])/g;function fR(Y){return Y=Y.replace(o5,"^$1"),Y}function bR(Y,Z){if(Y=`${Y}`,Y=Y.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),Y=Y.replace(/(?=(\\+?)?)\1$/,"$1$1"),Y=`"${Y}"`,Y=Y.replace(o5,"^$1"),Z)Y=Y.replace(o5,"^$1");return Y}hR.command=fR;hR.argument=bR});var OH=p0(($x,MH)=>{MH.exports=/^#!(.*)/});var NH=p0((qx,DH)=>{var uR=OH();DH.exports=(Y="")=>{let Z=Y.match(uR);if(!Z)return null;let[Q,J]=Z[0].replace(/#! ?/,"").split(" "),z=Q.split("/").pop();if(z==="env")return J;return J?`${z} ${J}`:z}});var LH=p0((Ux,wH)=>{var r5=$Y("fs"),dR=NH();function pR(Y){let Q=Buffer.alloc(150),J;try{J=r5.openSync(Y,"r"),r5.readSync(J,Q,0,150,0),r5.closeSync(J)}catch(z){}return dR(Q.toString())}wH.exports=pR});var TH=p0((Bx,jH)=>{var cR=$Y("path"),_H=FH(),IH=RH(),lR=LH(),iR=process.platform==="win32",nR=/\.(?:com|exe)$/i,aR=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function oR(Y){Y.file=_H(Y);let Z=Y.file&&lR(Y.file);if(Z)return Y.args.unshift(Y.file),Y.command=Z,_H(Y);return Y.file}function sR(Y){if(!iR)return Y;let Z=oR(Y),Q=!nR.test(Z);if(Y.options.forceShell||Q){let J=aR.test(Z);Y.command=cR.normalize(Y.command),Y.command=IH.command(Y.command),Y.args=Y.args.map((X)=>IH.argument(X,J));let z=[Y.command].concat(Y.args).join(" ");Y.args=["/d","/s","/c",`"${z}"`],Y.command=process.env.comspec||"cmd.exe",Y.options.windowsVerbatimArguments=!0}return Y}function rR(Y,Z,Q){if(Z&&!Array.isArray(Z))Q=Z,Z=null;Z=Z?Z.slice(0):[],Q=Object.assign({},Q);let J={command:Y,args:Z,options:Q,file:void 0,original:{command:Y,args:Z}};return Q.shell?J:sR(J)}jH.exports=rR});var AH=p0((Vx,kH)=>{var t5=process.platform==="win32";function e5(Y,Z){return Object.assign(Error(`${Z} ${Y.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${Z} ${Y.command}`,path:Y.command,spawnargs:Y.args})}function tR(Y,Z){if(!t5)return;let Q=Y.emit;Y.emit=function(J,z){if(J==="exit"){let X=CH(z,Z);if(X)return Q.call(Y,"error",X)}return Q.apply(Y,arguments)}}function CH(Y,Z){if(t5&&Y===1&&!Z.file)return e5(Z.original,"spawn");return null}function eR(Y,Z){if(t5&&Y===1&&!Z.file)return e5(Z.original,"spawnSync");return null}kH.exports={hookChildProcess:tR,verifyENOENT:CH,verifyENOENTSync:eR,notFoundError:e5}});var PH=p0((Fx,b1)=>{var xH=$Y("child_process"),Y3=TH(),Z3=AH();function EH(Y,Z,Q){let J=Y3(Y,Z,Q),z=xH.spawn(J.command,J.args,J.options);return Z3.hookChildProcess(z,J),z}function YM(Y,Z,Q){let J=Y3(Y,Z,Q),z=xH.spawnSync(J.command,J.args,J.options);return z.error=z.error||Z3.verifyENOENTSync(z.status,J),z}b1.exports=EH;b1.exports.spawn=EH;b1.exports.sync=YM;b1.exports._parse=Y3;b1.exports._enoent=Z3});function dZ(Y={}){let{env:Z=process.env,platform:Q=process.platform}=Y;if(Q!=="win32")return"PATH";return Object.keys(Z).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"}import{promisify as ZM}from"node:util";import{execFile as QM,execFileSync as Dx}from"node:child_process";import SH from"node:path";import{fileURLToPath as JM}from"node:url";function pZ(Y){return Y instanceof URL?JM(Y):Y}function vH(Y){return{*[Symbol.iterator](){let Z=SH.resolve(pZ(Y)),Q;while(Q!==Z)yield Z,Q=Z,Z=SH.resolve(Z,"..")}}}var Lx;var yH=R(()=>{Lx=ZM(QM)});import cZ from"node:process";import l6 from"node:path";var zM=({cwd:Y=cZ.cwd(),path:Z=cZ.env[dZ()],preferLocal:Q=!0,execPath:J=cZ.execPath,addExecPath:z=!0}={})=>{let X=l6.resolve(pZ(Y)),H=[],W=Z.split(l6.delimiter);if(Q)XM(H,W,X);if(z)HM(H,W,J,X);return Z===""||Z===l6.delimiter?`${H.join(l6.delimiter)}${Z}`:[...H,Z].join(l6.delimiter)},XM=(Y,Z,Q)=>{for(let J of vH(Q)){let z=l6.join(J,"node_modules/.bin");if(!Z.includes(z))Y.push(z)}},HM=(Y,Z,Q,J)=>{let z=l6.resolve(J,pZ(Q),"..");if(!Z.includes(z))Y.push(z)},fH=({env:Y=cZ.env,...Z}={})=>{Y={...Y};let Q=dZ({env:Y});return Z.path=Y[Q],Y[Q]=zM(Z),Y};var bH=R(()=>{yH()});var hH=(Y,Z,Q)=>{let J=Q?y8:n0,z=Y instanceof NY?{}:{cause:Y};return new J(Z,z)},NY,gH=(Y,Z)=>{Object.defineProperty(Y.prototype,"name",{value:Z,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,uH,{value:!0,writable:!1,enumerable:!1,configurable:!1})},mH=(Y)=>lZ(Y)&&(uH in Y),uH,lZ=(Y)=>Object.prototype.toString.call(Y)==="[object Error]",n0,y8;var K6=R(()=>{NY=class NY extends Error{};uH=Symbol("isExecaError");n0=class n0 extends Error{};gH(n0,n0.name);y8=class y8 extends Error{};gH(y8,y8.name)});var dH=()=>{let Y=Q3-pH+1;return Array.from({length:Y},WM)},WM=(Y,Z)=>({name:`SIGRT${Z+1}`,number:pH+Z,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),pH=34,Q3=64;var cH;var lH=R(()=>{cH=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}]});import{constants as KM}from"node:os";var J3=()=>{let Y=dH();return[...cH,...Y].map(GM)},GM=({name:Y,number:Z,description:Q,action:J,forced:z=!1,standard:X})=>{let{signals:{[Y]:H}}=KM,W=H!==void 0;return{name:Y,number:W?H:Z,description:Q,supported:W,action:J,forced:z,standard:X}};var iH=R(()=>{lH()});import{constants as $M}from"node:os";var qM=()=>{let Y=J3();return Object.fromEntries(Y.map(UM))},UM=({name:Y,number:Z,description:Q,supported:J,action:z,forced:X,standard:H})=>[Y,{name:Y,number:Z,description:Q,supported:J,action:z,forced:X,standard:H}],nH,BM=()=>{let Y=J3(),Z=Q3+1,Q=Array.from({length:Z},(J,z)=>VM(z,Y));return Object.assign({},...Q)},VM=(Y,Z)=>{let Q=FM(Y,Z);if(Q===void 0)return{};let{name:J,description:z,supported:X,action:H,forced:W,standard:K}=Q;return{[Y]:{name:J,number:Y,description:z,supported:X,action:H,forced:W,standard:K}}},FM=(Y,Z)=>{let Q=Z.find(({name:J})=>$M.signals[J]===Y);if(Q!==void 0)return Q;return Z.find((J)=>J.number===Y)},mx;var aH=R(()=>{iH();nH=qM(),mx=BM()});import{constants as f8}from"node:os";var sH=(Y)=>{if(Y===0)throw TypeError("Invalid option `killSignal`: 0 cannot be used.");return tH(Y,"option `killSignal`")},rH=(Y)=>Y===0?Y:tH(Y,"`subprocess.kill()`'s argument"),tH=(Y,Z)=>{if(Number.isInteger(Y))return RM(Y,Z);if(typeof Y==="string")return OM(Y,Z);throw TypeError(`Invalid ${Z} ${String(Y)}: it must be a string or an integer.
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
Available signal numbers: ${
|
|
48
|
+
`;var TX=O(()=>{w6()});import{inspect as CO}from"node:util";var h1=({type:Y,verboseMessage:Z,fdNumber:Q,verboseInfo:J,result:z})=>{let K=AO({type:Y,result:z,verboseInfo:J}),X=kO(Z,K),H=jX(X,J,Q);if(H!=="")console.warn(H.slice(0,-1))},AO=({type:Y,result:Z,verboseInfo:{escapedCommand:Q,commandId:J,rawOptions:{piped:z=!1,...K}}})=>({type:Y,escapedCommand:Q,commandId:`${J}`,timestamp:new Date,piped:z,result:Z,options:K}),kO=(Y,Z)=>Y.split(`
|
|
49
|
+
`).map((Q)=>EO({...Z,message:Q})),EO=(Y)=>{return{verboseLine:LX(Y),verboseObject:Y}},K2=(Y)=>{let Z=typeof Y==="string"?Y:CO(Y);return r4(Z).replaceAll("\t"," ".repeat(xO))},xO=2;var sY=O(()=>{Z2();wX();TX()});var IX=(Y,Z)=>{if(!aY(Z))return;h1({type:"command",verboseMessage:Y,verboseInfo:Z})};var CX=O(()=>{w6();sY()});var AX=(Y,Z,Q)=>{vO(Y);let J=SO(Y);return{verbose:Y,escapedCommand:Z,commandId:J,rawOptions:Q}},SO=(Y)=>aY({verbose:Y})?PO++:void 0,PO=0n,vO=(Y)=>{for(let Z of Y){if(Z===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(Z===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!Y2.includes(Z)&&!e8(Z)){let Q=Y2.map((J)=>`'${J}'`).join(", ");throw TypeError(`The "verbose" option must not be ${Z}. Allowed values are: ${Q} or a function.`)}}};var kX=O(()=>{w6()});import{hrtime as EX}from"node:process";var X2=()=>EX.bigint(),DQ=(Y)=>Number(EX.bigint()-Y)/1e6;var H2=()=>{};var W2=(Y,Z,Q)=>{let J=X2(),{command:z,escapedCommand:K}=WX(Y,Z),X=VQ(Q,"verbose"),H=AX(X,K,{...Q});return IX(K,H),{command:z,escapedCommand:K,startTime:J,verboseInfo:H}};var NQ=O(()=>{CX();kX();H2();Z2();H6()});var yX=X1((ZS,vX)=>{vX.exports=PX;PX.sync=fO;var xX=A1("fs");function yO(Y,Z){var Q=Z.pathExt!==void 0?Z.pathExt:process.env.PATHEXT;if(!Q)return!0;if(Q=Q.split(";"),Q.indexOf("")!==-1)return!0;for(var J=0;J<Q.length;J++){var z=Q[J].toLowerCase();if(z&&Y.substr(-z.length).toLowerCase()===z)return!0}return!1}function SX(Y,Z,Q){if(!Y.isSymbolicLink()&&!Y.isFile())return!1;return yO(Z,Q)}function PX(Y,Z,Q){xX.stat(Y,function(J,z){Q(J,J?!1:SX(z,Y,Z))})}function fO(Y,Z){return SX(xX.statSync(Y),Y,Z)}});var mX=X1((QS,gX)=>{gX.exports=bX;bX.sync=bO;var fX=A1("fs");function bX(Y,Z,Q){fX.stat(Y,function(J,z){Q(J,J?!1:hX(z,Z))})}function bO(Y,Z){return hX(fX.statSync(Y),Z)}function hX(Y,Z){return Y.isFile()&&hO(Y,Z)}function hO(Y,Z){var{mode:Q,uid:J,gid:z}=Y,K=Z.uid!==void 0?Z.uid:process.getuid&&process.getuid(),X=Z.gid!==void 0?Z.gid:process.getgid&&process.getgid(),H=parseInt("100",8),W=parseInt("010",8),q=parseInt("001",8),G=H|W,$=Q&q||Q&W&&z===X||Q&H&&J===K||Q&G&&K===0;return $}});var dX=X1((zS,uX)=>{var JS=A1("fs"),q2;if(process.platform==="win32"||global.TESTING_WINDOWS)q2=yX();else q2=mX();uX.exports=_Q;_Q.sync=gO;function _Q(Y,Z,Q){if(typeof Z==="function")Q=Z,Z={};if(!Q){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(J,z){_Q(Y,Z||{},function(K,X){if(K)z(K);else J(X)})})}q2(Y,Z||{},function(J,z){if(J){if(J.code==="EACCES"||Z&&Z.ignoreErrors)J=null,z=!1}Q(J,z)})}function gO(Y,Z){try{return q2.sync(Y,Z||{})}catch(Q){if(Z&&Z.ignoreErrors||Q.code==="EACCES")return!1;else throw Q}}});var oX=X1((KS,aX)=>{var rY=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",pX=A1("path"),mO=rY?";":":",cX=dX(),lX=(Y)=>Object.assign(Error(`not found: ${Y}`),{code:"ENOENT"}),nX=(Y,Z)=>{let Q=Z.colon||mO,J=Y.match(/\//)||rY&&Y.match(/\\/)?[""]:[...rY?[process.cwd()]:[],...(Z.path||process.env.PATH||"").split(Q)],z=rY?Z.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",K=rY?z.split(Q):[""];if(rY){if(Y.indexOf(".")!==-1&&K[0]!=="")K.unshift("")}return{pathEnv:J,pathExt:K,pathExtExe:z}},iX=(Y,Z,Q)=>{if(typeof Z==="function")Q=Z,Z={};if(!Z)Z={};let{pathEnv:J,pathExt:z,pathExtExe:K}=nX(Y,Z),X=[],H=(q)=>new Promise((G,$)=>{if(q===J.length)return Z.all&&X.length?G(X):$(lX(Y));let B=J[q],V=/^".*"$/.test(B)?B.slice(1,-1):B,F=pX.join(V,Y),M=!V&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+F:F;G(W(M,q,0))}),W=(q,G,$)=>new Promise((B,V)=>{if($===z.length)return B(H(G+1));let F=z[$];cX(q+F,{pathExt:K},(M,L)=>{if(!M&&L)if(Z.all)X.push(q+F);else return B(q+F);return B(W(q,G,$+1))})});return Q?H(0).then((q)=>Q(null,q),Q):H(0)},uO=(Y,Z)=>{Z=Z||{};let{pathEnv:Q,pathExt:J,pathExtExe:z}=nX(Y,Z),K=[];for(let X=0;X<Q.length;X++){let H=Q[X],W=/^".*"$/.test(H)?H.slice(1,-1):H,q=pX.join(W,Y),G=!W&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+q:q;for(let $=0;$<J.length;$++){let B=G+J[$];try{if(cX.sync(B,{pathExt:z}))if(Z.all)K.push(B);else return B}catch(V){}}}if(Z.all&&K.length)return K;if(Z.nothrow)return null;throw lX(Y)};aX.exports=iX;iX.sync=uO});var rX=X1((XS,LQ)=>{var sX=(Y={})=>{let Z=Y.env||process.env;if((Y.platform||process.platform)!=="win32")return"PATH";return Object.keys(Z).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"};LQ.exports=sX;LQ.exports.default=sX});var ZH=X1((HS,YH)=>{var tX=A1("path"),dO=oX(),pO=rX();function eX(Y,Z){let Q=Y.options.env||process.env,J=process.cwd(),z=Y.options.cwd!=null,K=z&&process.chdir!==void 0&&!process.chdir.disabled;if(K)try{process.chdir(Y.options.cwd)}catch(H){}let X;try{X=dO.sync(Y.command,{path:Q[pO({env:Q})],pathExt:Z?tX.delimiter:void 0})}catch(H){}finally{if(K)process.chdir(J)}if(X)X=tX.resolve(z?Y.options.cwd:"",X);return X}function cO(Y){return eX(Y)||eX(Y,!0)}YH.exports=cO});var QH=X1((iO,jQ)=>{var wQ=/([()\][%!^"`<>&|;, *?])/g;function lO(Y){return Y=Y.replace(wQ,"^$1"),Y}function nO(Y,Z){if(Y=`${Y}`,Y=Y.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),Y=Y.replace(/(?=(\\+?)?)\1$/,"$1$1"),Y=`"${Y}"`,Y=Y.replace(wQ,"^$1"),Z)Y=Y.replace(wQ,"^$1");return Y}iO.command=lO;iO.argument=nO});var zH=X1((WS,JH)=>{JH.exports=/^#!(.*)/});var XH=X1((qS,KH)=>{var sO=zH();KH.exports=(Y="")=>{let Z=Y.match(sO);if(!Z)return null;let[Q,J]=Z[0].replace(/#! ?/,"").split(" "),z=Q.split("/").pop();if(z==="env")return J;return J?`${z} ${J}`:z}});var WH=X1((GS,HH)=>{var TQ=A1("fs"),rO=XH();function tO(Y){let Q=Buffer.alloc(150),J;try{J=TQ.openSync(Y,"r"),TQ.readSync(J,Q,0,150,0),TQ.closeSync(J)}catch(z){}return rO(Q.toString())}HH.exports=tO});var $H=X1((US,UH)=>{var eO=A1("path"),qH=ZH(),GH=QH(),YM=WH(),ZM=process.platform==="win32",QM=/\.(?:com|exe)$/i,JM=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function zM(Y){Y.file=qH(Y);let Z=Y.file&&YM(Y.file);if(Z)return Y.args.unshift(Y.file),Y.command=Z,qH(Y);return Y.file}function KM(Y){if(!ZM)return Y;let Z=zM(Y),Q=!QM.test(Z);if(Y.options.forceShell||Q){let J=JM.test(Z);Y.command=eO.normalize(Y.command),Y.command=GH.command(Y.command),Y.args=Y.args.map((K)=>GH.argument(K,J));let z=[Y.command].concat(Y.args).join(" ");Y.args=["/d","/s","/c",`"${z}"`],Y.command=process.env.comspec||"cmd.exe",Y.options.windowsVerbatimArguments=!0}return Y}function XM(Y,Z,Q){if(Z&&!Array.isArray(Z))Q=Z,Z=null;Z=Z?Z.slice(0):[],Q=Object.assign({},Q);let J={command:Y,args:Z,options:Q,file:void 0,original:{command:Y,args:Z}};return Q.shell?J:KM(J)}UH.exports=XM});var FH=X1(($S,VH)=>{var IQ=process.platform==="win32";function CQ(Y,Z){return Object.assign(Error(`${Z} ${Y.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${Z} ${Y.command}`,path:Y.command,spawnargs:Y.args})}function HM(Y,Z){if(!IQ)return;let Q=Y.emit;Y.emit=function(J,z){if(J==="exit"){let K=BH(z,Z);if(K)return Q.call(Y,"error",K)}return Q.apply(Y,arguments)}}function BH(Y,Z){if(IQ&&Y===1&&!Z.file)return CQ(Z.original,"spawn");return null}function WM(Y,Z){if(IQ&&Y===1&&!Z.file)return CQ(Z.original,"spawnSync");return null}VH.exports={hookChildProcess:HM,verifyENOENT:BH,verifyENOENTSync:WM,notFoundError:CQ}});var MH=X1((BS,tY)=>{var RH=A1("child_process"),AQ=$H(),kQ=FH();function OH(Y,Z,Q){let J=AQ(Y,Z,Q),z=RH.spawn(J.command,J.args,J.options);return kQ.hookChildProcess(z,J),z}function qM(Y,Z,Q){let J=AQ(Y,Z,Q),z=RH.spawnSync(J.command,J.args,J.options);return z.error=z.error||kQ.verifyENOENTSync(z.status,J),z}tY.exports=OH;tY.exports.spawn=OH;tY.exports.sync=qM;tY.exports._parse=AQ;tY.exports._enoent=kQ});function G2(Y={}){let{env:Z=process.env,platform:Q=process.platform}=Y;if(Q!=="win32")return"PATH";return Object.keys(Z).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"}import{promisify as GM}from"node:util";import{execFile as UM,execFileSync as OS}from"node:child_process";import DH from"node:path";import{fileURLToPath as $M}from"node:url";function U2(Y){return Y instanceof URL?$M(Y):Y}function NH(Y){return{*[Symbol.iterator](){let Z=DH.resolve(U2(Y)),Q;while(Q!==Z)yield Z,Q=Z,Z=DH.resolve(Z,"..")}}}var NS;var _H=O(()=>{NS=GM(UM)});import $2 from"node:process";import KY from"node:path";var BM=({cwd:Y=$2.cwd(),path:Z=$2.env[G2()],preferLocal:Q=!0,execPath:J=$2.execPath,addExecPath:z=!0}={})=>{let K=KY.resolve(U2(Y)),X=[],H=Z.split(KY.delimiter);if(Q)VM(X,H,K);if(z)FM(X,H,J,K);return Z===""||Z===KY.delimiter?`${X.join(KY.delimiter)}${Z}`:[...X,Z].join(KY.delimiter)},VM=(Y,Z,Q)=>{for(let J of NH(Q)){let z=KY.join(J,"node_modules/.bin");if(!Z.includes(z))Y.push(z)}},FM=(Y,Z,Q,J)=>{let z=KY.resolve(J,U2(Q),"..");if(!Z.includes(z))Y.push(z)},LH=({env:Y=$2.env,...Z}={})=>{Y={...Y};let Q=G2({env:Y});return Z.path=Y[Q],Y[Q]=BM(Z),Y};var wH=O(()=>{_H()});var jH=(Y,Z,Q)=>{let J=Q?t4:_1,z=Y instanceof g1?{}:{cause:Y};return new J(Z,z)},g1,TH=(Y,Z)=>{Object.defineProperty(Y.prototype,"name",{value:Z,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,CH,{value:!0,writable:!1,enumerable:!1,configurable:!1})},IH=(Y)=>B2(Y)&&(CH in Y),CH,B2=(Y)=>Object.prototype.toString.call(Y)==="[object Error]",_1,t4;var j6=O(()=>{g1=class g1 extends Error{};CH=Symbol("isExecaError");_1=class _1 extends Error{};TH(_1,_1.name);t4=class t4 extends Error{};TH(t4,t4.name)});var AH=()=>{let Y=EQ-kH+1;return Array.from({length:Y},RM)},RM=(Y,Z)=>({name:`SIGRT${Z+1}`,number:kH+Z,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),kH=34,EQ=64;var EH;var xH=O(()=>{EH=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}]});import{constants as OM}from"node:os";var xQ=()=>{let Y=AH();return[...EH,...Y].map(MM)},MM=({name:Y,number:Z,description:Q,action:J,forced:z=!1,standard:K})=>{let{signals:{[Y]:X}}=OM,H=X!==void 0;return{name:Y,number:H?X:Z,description:Q,supported:H,action:J,forced:z,standard:K}};var SH=O(()=>{xH()});import{constants as DM}from"node:os";var NM=()=>{let Y=xQ();return Object.fromEntries(Y.map(_M))},_M=({name:Y,number:Z,description:Q,supported:J,action:z,forced:K,standard:X})=>[Y,{name:Y,number:Z,description:Q,supported:J,action:z,forced:K,standard:X}],PH,LM=()=>{let Y=xQ(),Z=EQ+1,Q=Array.from({length:Z},(J,z)=>wM(z,Y));return Object.assign({},...Q)},wM=(Y,Z)=>{let Q=jM(Y,Z);if(Q===void 0)return{};let{name:J,description:z,supported:K,action:X,forced:H,standard:W}=Q;return{[Y]:{name:J,number:Y,description:z,supported:K,action:X,forced:H,standard:W}}},jM=(Y,Z)=>{let Q=Z.find(({name:J})=>DM.signals[J]===Y);if(Q!==void 0)return Q;return Z.find((J)=>J.number===Y)},hS;var vH=O(()=>{SH();PH=NM(),hS=LM()});import{constants as e4}from"node:os";var fH=(Y)=>{if(Y===0)throw TypeError("Invalid option `killSignal`: 0 cannot be used.");return hH(Y,"option `killSignal`")},bH=(Y)=>Y===0?Y:hH(Y,"`subprocess.kill()`'s argument"),hH=(Y,Z)=>{if(Number.isInteger(Y))return TM(Y,Z);if(typeof Y==="string")return CM(Y,Z);throw TypeError(`Invalid ${Z} ${String(Y)}: it must be a string or an integer.
|
|
50
|
+
${SQ()}`)},TM=(Y,Z)=>{if(yH.has(Y))return yH.get(Y);throw TypeError(`Invalid ${Z} ${Y}: this signal integer does not exist.
|
|
51
|
+
${SQ()}`)},IM=()=>new Map(Object.entries(e4.signals).reverse().map(([Y,Z])=>[Z,Y])),yH,CM=(Y,Z)=>{if(Y in e4.signals)return Y;if(Y.toUpperCase()in e4.signals)throw TypeError(`Invalid ${Z} '${Y}': please rename it to '${Y.toUpperCase()}'.`);throw TypeError(`Invalid ${Z} '${Y}': this signal name does not exist.
|
|
52
|
+
${SQ()}`)},SQ=()=>`Available signal names: ${AM()}.
|
|
53
|
+
Available signal numbers: ${kM()}.`,AM=()=>Object.keys(e4.signals).sort().map((Y)=>`'${Y}'`).join(", "),kM=()=>[...new Set(Object.values(e4.signals).sort((Y,Z)=>Y-Z))].join(", "),V2=(Y)=>PH[Y].description;var YZ=O(()=>{vH();yH=IM()});import{setTimeout as EM}from"node:timers/promises";var gH=(Y)=>{if(Y===!1)return Y;if(Y===!0)return xM;if(!Number.isFinite(Y)||Y<0)throw TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${Y}\` (${typeof Y})`);return Y},xM=5000,mH=({kill:Y,options:{forceKillAfterDelay:Z,killSignal:Q},onInternalError:J,context:z,controller:K},X,H)=>{let{signal:W,error:q}=SM(X,H,Q);PM(q,J);let G=Y(W);return vM({kill:Y,signal:W,forceKillAfterDelay:Z,killSignal:Q,killResult:G,context:z,controller:K}),G},SM=(Y,Z,Q)=>{let[J=Q,z]=B2(Y)?[void 0,Y]:[Y,Z];if(typeof J!=="string"&&!Number.isInteger(J))throw TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(J)}`);if(z!==void 0&&!B2(z))throw TypeError(`The second argument is optional. If specified, it must be an error instance: ${z}`);return{signal:bH(J),error:z}},PM=(Y,Z)=>{if(Y!==void 0)Z.reject(Y)},vM=async({kill:Y,signal:Z,forceKillAfterDelay:Q,killSignal:J,killResult:z,context:K,controller:X})=>{if(Z===J&&z)PQ({kill:Y,forceKillAfterDelay:Q,context:K,controllerSignal:X.signal})},PQ=async({kill:Y,forceKillAfterDelay:Z,context:Q,controllerSignal:J})=>{if(Z===!1)return;try{if(await EM(Z,void 0,{signal:J}),Y("SIGKILL"))Q.isForcefullyTerminated??=!0}catch{}};var F2=O(()=>{j6();YZ()});import{once as yM}from"node:events";var R2=async(Y,Z)=>{if(!Y.aborted)await yM(Y,"abort",{signal:Z})};var vQ=()=>{};var uH=({cancelSignal:Y})=>{if(Y!==void 0&&Object.prototype.toString.call(Y)!=="[object AbortSignal]")throw Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(Y)}`)},dH=({subprocess:Y,cancelSignal:Z,gracefulCancel:Q,context:J,controller:z})=>Z===void 0||Q?[]:[fM(Y,Z,J,z)],fM=async(Y,Z,Q,{signal:J})=>{throw await R2(Z,J),Q.terminationReason??="cancel",Y.kill(),Z.reason};var yQ=O(()=>{vQ()});var eY=({methodName:Y,isSubprocess:Z,ipc:Q,isConnected:J})=>{bM(Y,Z,Q),fQ(Y,Z,J)},bM=(Y,Z,Q)=>{if(!Q)throw Error(`${S1(Y,Z)} can only be used if the \`ipc\` option is \`true\`.`)},fQ=(Y,Z,Q)=>{if(!Q)throw Error(`${S1(Y,Z)} cannot be used: the ${T6(Z)} has already exited or disconnected.`)},pH=(Y)=>{throw Error(`${S1("getOneMessage",Y)} could not complete: the ${T6(Y)} exited or disconnected.`)},cH=(Y)=>{throw Error(`${S1("sendMessage",Y)} failed: the ${T6(Y)} is sending a message too, instead of listening to incoming messages.
|
|
54
54
|
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
55
55
|
|
|
56
56
|
const [receivedMessage] = await Promise.all([
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
]);`)},
|
|
57
|
+
${S1("getOneMessage",Y)},
|
|
58
|
+
${S1("sendMessage",Y,"message, {strict: true}")},
|
|
59
|
+
]);`)},O2=(Y,Z)=>Error(`${S1("sendMessage",Z)} failed when sending an acknowledgment response to the ${T6(Z)}.`,{cause:Y}),lH=(Y)=>{throw Error(`${S1("sendMessage",Y)} failed: the ${T6(Y)} is not listening to incoming messages.`)},nH=(Y)=>{throw Error(`${S1("sendMessage",Y)} failed: the ${T6(Y)} exited without listening to incoming messages.`)},iH=()=>Error(`\`cancelSignal\` aborted: the ${T6(!0)} disconnected.`),aH=()=>{throw Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},oH=({error:Y,methodName:Z,isSubprocess:Q})=>{if(Y.code==="EPIPE")throw Error(`${S1(Z,Q)} cannot be used: the ${T6(Q)} is disconnecting.`,{cause:Y})},sH=({error:Y,methodName:Z,isSubprocess:Q,message:J})=>{if(hM(Y))throw Error(`${S1(Z,Q)}'s argument type is invalid: the message cannot be serialized: ${String(J)}.`,{cause:Y})},hM=({code:Y,message:Z})=>gM.has(Y)||mM.some((Q)=>Z.includes(Q)),gM,mM,S1=(Y,Z,Q="")=>Y==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${uM(Z)}${Y}(${Q})`,uM=(Y)=>Y?"":"subprocess.",T6=(Y)=>Y?"parent process":"subprocess",Y4=(Y)=>{if(Y.connected)Y.disconnect()};var Z4=O(()=>{gM=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),mM=["could not be cloned","circular structure","call stack size exceeded"]});var m1=()=>{let Y={},Z=new Promise((Q,J)=>{Object.assign(Y,{resolve:Q,reject:J})});return Object.assign(Z,Y)};var D2=(Y,Z="stdin")=>{let{options:J,fileDescriptors:z}=u1.get(Y),K=rH(z,Z,!0),X=Y.stdio[K];if(X===null)throw TypeError(tH(K,Z,J,!0));return X},Q4=(Y,Z="stdout")=>{let{options:J,fileDescriptors:z}=u1.get(Y),K=rH(z,Z,!1),X=K==="all"?Y.all:Y.stdio[K];if(X===null||X===void 0)throw TypeError(tH(K,Z,J,!1));return X},u1,rH=(Y,Z,Q)=>{let J=dM(Z,Q);return pM(J,Z,Q,Y),J},dM=(Y,Z)=>{let Q=FQ(Y);if(Q!==void 0)return Q;let{validOptions:J,defaultValue:z}=Z?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw TypeError(`"${ZZ(Z)}" must not be "${Y}".
|
|
60
60
|
It must be ${J} or "fd3", "fd4" (and so on).
|
|
61
|
-
It is optional and defaults to "${z}".`)},
|
|
62
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);if(z.direction==="input"&&!Q)throw TypeError(`"${
|
|
63
|
-
Please set this option with "pipe" instead.`},
|
|
64
|
-
Please rename it to ${
|
|
65
|
-
Please rename it to one of: ${Q}.`)},
|
|
66
|
-
${Y.message}`,Y}},
|
|
61
|
+
It is optional and defaults to "${z}".`)},pM=(Y,Z,Q,J)=>{let z=J[eH(Y)];if(z===void 0)throw TypeError(`"${ZZ(Q)}" must not be ${Z}. That file descriptor does not exist.
|
|
62
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);if(z.direction==="input"&&!Q)throw TypeError(`"${ZZ(Q)}" must not be ${Z}. It must be a readable stream, not writable.`);if(z.direction!=="input"&&Q)throw TypeError(`"${ZZ(Q)}" must not be ${Z}. It must be a writable stream, not readable.`)},tH=(Y,Z,Q,J)=>{if(Y==="all"&&!Q.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:z,optionValue:K}=cM(Y,Q);return`The "${z}: ${M2(K)}" option is incompatible with using "${ZZ(J)}: ${M2(Z)}".
|
|
63
|
+
Please set this option with "pipe" instead.`},cM=(Y,{stdin:Z,stdout:Q,stderr:J,stdio:z})=>{let K=eH(Y);if(K===0&&Z!==void 0)return{optionName:"stdin",optionValue:Z};if(K===1&&Q!==void 0)return{optionName:"stdout",optionValue:Q};if(K===2&&J!==void 0)return{optionName:"stderr",optionValue:J};return{optionName:`stdio[${K}]`,optionValue:z[K]}},eH=(Y)=>Y==="all"?1:Y,ZZ=(Y)=>Y?"to":"from",M2=(Y)=>{if(typeof Y==="string")return`'${Y}'`;return typeof Y==="number"?`${Y}`:"Stream"};var I6=O(()=>{H6();u1=new WeakMap});import{addAbortListener as lM}from"node:events";var XY=(Y,Z,Q)=>{let J=Y.getMaxListeners();if(J===0||J===Number.POSITIVE_INFINITY)return;Y.setMaxListeners(J+Z),lM(Q,()=>{Y.setMaxListeners(Y.getMaxListeners()-Z)})};var N2=()=>{};var _2=(Y,Z)=>{if(Z)bQ(Y)},bQ=(Y)=>{Y.refCounted()},L2=(Y,Z)=>{if(Z)hQ(Y)},hQ=(Y)=>{Y.unrefCounted()},YW=(Y,Z)=>{if(Z)hQ(Y),hQ(Y)},ZW=(Y,Z)=>{if(Z)bQ(Y),bQ(Y)};import{once as nM}from"node:events";import{scheduler as iM}from"node:timers/promises";var QW=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipcEmitter:J},z)=>{if(XW(z)||WW(z))return;if(!w2.has(Y))w2.set(Y,[]);let K=w2.get(Y);if(K.push(z),K.length>1)return;while(K.length>0){await HW(Y,J,z),await iM.yield();let X=await KW({wrappedMessage:K[0],anyProcess:Y,channel:Z,isSubprocess:Q,ipcEmitter:J});K.shift(),J.emit("message",X),J.emit("message:done")}},JW=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipcEmitter:J,boundOnMessage:z})=>{gQ();let K=w2.get(Y);while(K?.length>0)await nM(J,"message:done");Y.removeListener("message",z),ZW(Z,Q),J.connected=!1,J.emit("disconnect")},w2;var zW=O(()=>{T2();j2();I2();w2=new WeakMap});import{EventEmitter as aM}from"node:events";var C6=(Y,Z,Q)=>{if(C2.has(Y))return C2.get(Y);let J=new aM;return J.connected=!0,C2.set(Y,J),oM({ipcEmitter:J,anyProcess:Y,channel:Z,isSubprocess:Q}),J},C2,oM=({ipcEmitter:Y,anyProcess:Z,channel:Q,isSubprocess:J})=>{let z=QW.bind(void 0,{anyProcess:Z,channel:Q,isSubprocess:J,ipcEmitter:Y});Z.on("message",z),Z.once("disconnect",JW.bind(void 0,{anyProcess:Z,channel:Q,isSubprocess:J,ipcEmitter:Y,boundOnMessage:z})),YW(Q,J)},A2=(Y)=>{let Z=C2.get(Y);return Z===void 0?Y.channel!==null:Z.connected};var QZ=O(()=>{zW();C2=new WeakMap});import{once as sM}from"node:events";var qW=({anyProcess:Y,channel:Z,isSubprocess:Q,message:J,strict:z})=>{if(!z)return J;let K=C6(Y,Z,Q),X=x2(Y,K);return{id:rM++,type:E2,message:J,hasListeners:X}},rM=0n,GW=(Y,Z)=>{if(Z?.type!==E2||Z.hasListeners)return;for(let{id:Q}of Y)if(Q!==void 0)k2[Q].resolve({isDeadlock:!0,hasListeners:!1})},KW=async({wrappedMessage:Y,anyProcess:Z,channel:Q,isSubprocess:J,ipcEmitter:z})=>{if(Y?.type!==E2||!Z.connected)return Y;let{id:K,message:X}=Y,H={id:K,type:$W,message:x2(Z,z)};try{await S2({anyProcess:Z,channel:Q,isSubprocess:J,ipc:!0},H)}catch(W){z.emit("strict:error",W)}return X},XW=(Y)=>{if(Y?.type!==$W)return!1;let{id:Z,message:Q}=Y;return k2[Z]?.resolve({isDeadlock:!1,hasListeners:Q}),!0},UW=async(Y,Z,Q)=>{if(Y?.type!==E2)return;let J=m1();k2[Y.id]=J;let z=new AbortController;try{let{isDeadlock:K,hasListeners:X}=await Promise.race([J,tM(Z,Q,z)]);if(K)cH(Q);if(!X)lH(Q)}finally{z.abort(),delete k2[Y.id]}},k2,tM=async(Y,Z,{signal:Q})=>{XY(Y,1,Q),await sM(Y,"disconnect",{signal:Q}),nH(Z)},E2="execa:ipc:request",$W="execa:ipc:response";var j2=O(()=>{N2();P2();Z4();QZ();T2();k2={}});var BW=(Y,Z,Q)=>{if(!JZ.has(Y))JZ.set(Y,new Set);let J=JZ.get(Y),z=m1(),K=Q?Z.id:void 0,X={onMessageSent:z,id:K};return J.add(X),{outgoingMessages:J,outgoingMessage:X}},VW=({outgoingMessages:Y,outgoingMessage:Z})=>{Y.delete(Z),Z.onMessageSent.resolve()},HW=async(Y,Z,Q)=>{while(!x2(Y,Z)&&JZ.get(Y)?.size>0){let J=[...JZ.get(Y)];GW(J,Q),await Promise.all(J.map(({onMessageSent:z})=>z))}},JZ,x2=(Y,Z)=>Z.listenerCount("message")>eM(Y),eM=(Y)=>u1.has(Y)&&!X6(u1.get(Y).options.buffer,"ipc")?1:0;var T2=O(()=>{H6();I6();j2();JZ=new WeakMap});import{promisify as YD}from"node:util";var S2=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},z,{strict:K=!1}={})=>{return eY({methodName:"sendMessage",isSubprocess:Q,ipc:J,isConnected:Y.connected}),ZD({anyProcess:Y,channel:Z,methodName:"sendMessage",isSubprocess:Q,message:z,strict:K})},ZD=async({anyProcess:Y,channel:Z,methodName:Q,isSubprocess:J,message:z,strict:K})=>{let X=qW({anyProcess:Y,channel:Z,isSubprocess:J,message:z,strict:K}),H=BW(Y,X,K);try{await uQ({anyProcess:Y,methodName:Q,isSubprocess:J,wrappedMessage:X,message:z})}catch(W){throw Y4(Y),W}finally{VW(H)}},uQ=async({anyProcess:Y,methodName:Z,isSubprocess:Q,wrappedMessage:J,message:z})=>{let K=QD(Y);try{await Promise.all([UW(J,Y,Q),K(J)])}catch(X){throw oH({error:X,methodName:Z,isSubprocess:Q}),sH({error:X,methodName:Z,isSubprocess:Q,message:z}),X}},QD=(Y)=>{if(mQ.has(Y))return mQ.get(Y);let Z=YD(Y.send.bind(Y));return mQ.set(Y,Z),Z},mQ;var P2=O(()=>{Z4();T2();j2();mQ=new WeakMap});import{scheduler as JD}from"node:timers/promises";var RW=(Y,Z)=>{return fQ("cancelSignal",!1,Y.connected),uQ({anyProcess:Y,methodName:"cancelSignal",isSubprocess:!1,wrappedMessage:{type:MW,message:Z},message:Z})},OW=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J})=>{return await zD({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J}),dQ.signal},zD=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J})=>{if(FW)return;if(FW=!0,!J){aH();return}if(Z===null){gQ();return}C6(Y,Z,Q),await JD.yield()},FW=!1,WW=(Y)=>{if(Y?.type!==MW)return!1;return dQ.abort(Y.message),!0},MW="execa:ipc:cancel",gQ=()=>{dQ.abort(iH())},dQ;var I2=O(()=>{P2();QZ();Z4();dQ=new AbortController});var DW=({gracefulCancel:Y,cancelSignal:Z,ipc:Q,serialization:J})=>{if(!Y)return;if(Z===void 0)throw Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!Q)throw Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(J==="json")throw Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")},NW=({subprocess:Y,cancelSignal:Z,gracefulCancel:Q,forceKillAfterDelay:J,context:z,controller:K})=>Q?[KD({subprocess:Y,cancelSignal:Z,forceKillAfterDelay:J,context:z,controller:K})]:[],KD=async({subprocess:Y,cancelSignal:Z,forceKillAfterDelay:Q,context:J,controller:{signal:z}})=>{await R2(Z,z);let K=XD(Z);throw await RW(Y,K),PQ({kill:Y.kill,forceKillAfterDelay:Q,context:J,controllerSignal:z}),J.terminationReason??="gracefulCancel",Z.reason},XD=({reason:Y})=>{if(!(Y instanceof DOMException))return Y;let Z=Error(Y.message);return Object.defineProperty(Z,"stack",{value:Y.stack,enumerable:!1,configurable:!0,writable:!0}),Z};var pQ=O(()=>{vQ();I2();F2()});import{setTimeout as HD}from"node:timers/promises";var _W=({timeout:Y})=>{if(Y!==void 0&&(!Number.isFinite(Y)||Y<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${Y}\` (${typeof Y})`)},LW=(Y,Z,Q,J)=>Z===0||Z===void 0?[]:[WD(Y,Z,Q,J)],WD=async(Y,Z,Q,{signal:J})=>{throw await HD(Z,void 0,{signal:J}),Q.terminationReason??="timeout",Y.kill(),new g1};var cQ=O(()=>{j6()});import{execPath as qD,execArgv as GD}from"node:process";import wW from"node:path";var jW=({options:Y})=>{if(Y.node===!1)throw TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...Y,node:!0}}},TW=(Y,Z,{node:Q=!1,nodePath:J=qD,nodeOptions:z=GD.filter((W)=>!W.startsWith("--inspect")),cwd:K,execPath:X,...H})=>{if(X!==void 0)throw TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let W=nY(J,'The "nodePath" option'),q=wW.resolve(K,W),G={...H,nodePath:q,node:Q,cwd:K};if(!Q)return[Y,Z,G];if(wW.basename(Y,".exe")==="node")throw TypeError('When the "node" option is true, the first argument does not need to be "node".');return[q,[...z,Y,...Z],{ipc:!0,...G,shell:!1}]};var lQ=O(()=>{iY()});import{serialize as UD}from"node:v8";var IW=({ipcInput:Y,ipc:Z,serialization:Q})=>{if(Y===void 0)return;if(!Z)throw Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");VD[Q](Y)},$D=(Y)=>{try{UD(Y)}catch(Z){throw Error("The `ipcInput` option is not serializable with a structured clone.",{cause:Z})}},BD=(Y)=>{try{JSON.stringify(Y)}catch(Z){throw Error("The `ipcInput` option is not serializable with JSON.",{cause:Z})}},VD,CW=async(Y,Z)=>{if(Z===void 0)return;await Y.sendMessage(Z)};var nQ=O(()=>{VD={advanced:$D,json:BD}});var kW=({encoding:Y})=>{if(iQ.has(Y))return;let Z=RD(Y);if(Z!==void 0)throw TypeError(`Invalid option \`encoding: ${v2(Y)}\`.
|
|
64
|
+
Please rename it to ${v2(Z)}.`);let Q=[...iQ].map((J)=>v2(J)).join(", ");throw TypeError(`Invalid option \`encoding: ${v2(Y)}\`.
|
|
65
|
+
Please rename it to one of: ${Q}.`)},FD,q1,iQ,RD=(Y)=>{if(Y===null)return"buffer";if(typeof Y!=="string")return;let Z=Y.toLowerCase();if(Z in AW)return AW[Z];if(iQ.has(Z))return Z},AW,v2=(Y)=>typeof Y==="string"?`"${Y}"`:String(Y);var HY=O(()=>{FD=new Set(["utf8","utf16le"]),q1=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),iQ=new Set([...FD,...q1]),AW={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"}});import{statSync as OD}from"node:fs";import MD from"node:path";import DD from"node:process";var EW=(Y=xW())=>{let Z=nY(Y,'The "cwd" option');return MD.resolve(Z)},xW=()=>{try{return DD.cwd()}catch(Y){throw Y.message=`The current directory does not exist.
|
|
66
|
+
${Y.message}`,Y}},SW=(Y,Z)=>{if(Z===xW())return Y;let Q;try{Q=OD(Z)}catch(J){return`The "cwd" option is invalid: ${Z}.
|
|
67
67
|
${J.message}
|
|
68
68
|
${Y}`}if(!Q.isDirectory())return`The "cwd" option is not a directory: ${Z}.
|
|
69
|
-
${Y}`;return Y};var
|
|
70
|
-
`,
|
|
71
|
-
${
|
|
72
|
-
`)].map((
|
|
73
|
-
|
|
74
|
-
`);return{originalMessage:
|
|
75
|
-
`):wK(Y),wK=(Y)=>{if(typeof Y==="string")return Y;if(L0(Y))return kZ(Y);return""};var _K=R(()=>{L3();i0();N3();SZ();o6();b8();K6()});var I7=({command:Y,escapedCommand:Z,stdio:Q,all:J,ipcOutput:z,options:{cwd:X},startTime:H})=>IK({command:Y,escapedCommand:Z,cwd:X,durationMs:l5(H),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:Q[1],stderr:Q[2],all:J,stdio:Q,ipcOutput:z,pipedFrom:[]}),c1=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:X,isSync:H})=>c8({error:Y,command:Z,escapedCommand:Q,startTime:X,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:J.length}),ipcOutput:[],options:z,isSync:H}),c8=({error:Y,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:$,signal:G,stdio:U,all:B,ipcOutput:F,options:{timeoutDuration:V,timeout:O=V,forceKillAfterDelay:N,killSignal:w,cwd:L,maxBuffer:I},isSync:T})=>{let{exitCode:y,signal:E,signalDescription:P}=YD($,G),{originalMessage:m,shortMessage:g,message:b}=LK({stdio:U,all:B,ipcOutput:F,originalError:Y,signal:E,signalDescription:P,exitCode:y,escapedCommand:Q,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,forceKillAfterDelay:N,killSignal:w,maxBuffer:I,timeout:O,cwd:L}),c=hH(Y,b,T);return Object.assign(c,eO({error:c,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:y,signal:E,signalDescription:P,stdio:U,all:B,ipcOutput:F,cwd:L,originalMessage:m,shortMessage:g})),c},eO=({error:Y,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:$,signal:G,signalDescription:U,stdio:B,all:F,ipcOutput:V,cwd:O,originalMessage:N,shortMessage:w})=>IK({shortMessage:w,originalMessage:N,command:Z,escapedCommand:Q,cwd:O,durationMs:l5(J),failed:!0,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isTerminated:G!==void 0,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:$,signal:G,signalDescription:U,code:Y.cause?.code,stdout:B[1],stderr:B[2],all:F,stdio:B,ipcOutput:V,pipedFrom:[]}),IK=(Y)=>Object.fromEntries(Object.entries(Y).filter(([,Z])=>Z!==void 0)),YD=(Y,Z)=>{let Q=Y===null?void 0:Y,J=Z===null?void 0:Z,z=J===void 0?void 0:iZ(Z);return{exitCode:Q,signal:J,signalDescription:z}};var l8=R(()=>{b8();gZ();K6();_K()});function ZD(Y){return{days:Math.trunc(Y/86400000),hours:Math.trunc(Y/3600000%24),minutes:Math.trunc(Y/60000%60),seconds:Math.trunc(Y/1000%60),milliseconds:Math.trunc(Y%1000),microseconds:Math.trunc(jK(Y*1000)%1000),nanoseconds:Math.trunc(jK(Y*1e6)%1000)}}function QD(Y){return{days:Y/86400000n,hours:Y/3600000n%24n,minutes:Y/60000n%60n,seconds:Y/1000n%60n,milliseconds:Y%1000n,microseconds:0n,nanoseconds:0n}}function k3(Y){switch(typeof Y){case"number":{if(Number.isFinite(Y))return ZD(Y);break}case"bigint":return QD(Y)}throw TypeError("Expected a finite number or bigint")}var jK=(Y)=>Number.isFinite(Y)?Y:0;function A3(Y,Z){let Q=typeof Y==="bigint";if(!Q&&!Number.isFinite(Y))throw TypeError("Expected a finite number or bigint");Z={...Z};let J=Y<0?"-":"";if(Y=Y<0?-Y:Y,Z.colonNotation)Z.compact=!1,Z.formatSubMilliseconds=!1,Z.separateMilliseconds=!1,Z.verbose=!1;if(Z.compact)Z.unitCount=1,Z.secondsDecimalDigits=0,Z.millisecondsDecimalDigits=0;let z=[],X=(G,U)=>{let B=Math.floor(G*10**U+XD);return(Math.round(B)/10**U).toFixed(U)},H=(G,U,B,F)=>{if((z.length===0||!Z.colonNotation)&&JD(G)&&!(Z.colonNotation&&B==="m"))return;if(F??=String(G),Z.colonNotation){let V=F.includes(".")?F.split(".")[0].length:F.length,O=z.length>0?2:1;F="0".repeat(Math.max(0,O-V))+F}else F+=Z.verbose?" "+zD(U,G):B;z.push(F)},W=k3(Y),K=BigInt(W.days);if(Z.hideYearAndDays)H(BigInt(K)*24n+BigInt(W.hours),"hour","h");else{if(Z.hideYear)H(K,"day","d");else H(K/365n,"year","y"),H(K%365n,"day","d");H(Number(W.hours),"hour","h")}if(H(Number(W.minutes),"minute","m"),!Z.hideSeconds)if(Z.separateMilliseconds||Z.formatSubMilliseconds||!Z.colonNotation&&Y<1000&&!Z.subSecondsAsDecimals){let G=Number(W.seconds),U=Number(W.milliseconds),B=Number(W.microseconds),F=Number(W.nanoseconds);if(H(G,"second","s"),Z.formatSubMilliseconds)H(U,"millisecond","ms"),H(B,"microsecond","µs"),H(F,"nanosecond","ns");else{let V=U+B/1000+F/1e6,O=typeof Z.millisecondsDecimalDigits==="number"?Z.millisecondsDecimalDigits:0,N=V>=1?Math.round(V):Math.ceil(V),w=O?V.toFixed(O):N;H(Number.parseFloat(w),"millisecond","ms",w)}}else{let G=(Q?Number(Y%HD):Y)/1000%60,U=typeof Z.secondsDecimalDigits==="number"?Z.secondsDecimalDigits:1,B=X(G,U),F=Z.keepDecimalsOnWholeSeconds?B:B.replace(/\.0+$/,"");H(Number.parseFloat(F),"second","s",F)}if(z.length===0)return J+"0"+(Z.verbose?" milliseconds":"ms");let $=Z.colonNotation?":":" ";if(typeof Z.unitCount==="number")z=z.slice(0,Math.max(Z.unitCount,1));return J+z.join($)}var JD=(Y)=>Y===0||Y===0n,zD=(Y,Z)=>Z===1||Z===1n?Y:`${Y}s`,XD=0.0000001,HD;var TK=R(()=>{HD=24n*60n*60n*1000n});var CK=(Y,Z)=>{if(Y.failed)DY({type:"error",verboseMessage:Y.shortMessage,verboseInfo:Z,result:Y})};var kK=R(()=>{y1()});var AK=(Y,Z)=>{if(!S1(Z))return;CK(Y,Z),WD(Y,Z)},WD=(Y,Z)=>{let Q=`(done in ${A3(Y.durationMs)})`;DY({type:"duration",verboseMessage:Q,verboseInfo:Z,result:Y})};var xK=R(()=>{TK();W6();y1();kK()});var l1=(Y,Z,{reject:Q})=>{if(AK(Y,Z),Y.failed&&Q)throw Y;return Y};var j7=R(()=>{xK()});var SK=(Y,Z)=>{if(s6(Y))return"asyncGenerator";if(fK(Y))return"generator";if(T7(Y))return"fileUrl";if(UD(Y))return"filePath";if(FD(Y))return"webStream";if(VY(Y,{checkOpen:!1}))return"native";if(L0(Y))return"uint8Array";if(RD(Y))return"asyncIterable";if(MD(Y))return"iterable";if(P3(Y))return vK({transform:Y},Z);if(qD(Y))return KD(Y,Z);return"native"},KD=(Y,Z)=>{if(I3(Y.transform,{checkOpen:!1}))return GD(Y,Z);if(P3(Y.transform))return vK(Y,Z);return $D(Y,Z)},GD=(Y,Z)=>{return yK(Y,Z,"Duplex stream"),"duplex"},vK=(Y,Z)=>{return yK(Y,Z,"web TransformStream"),"webTransform"},yK=({final:Y,binary:Z,objectMode:Q},J,z)=>{EK(Y,`${J}.final`,z),EK(Z,`${J}.binary`,z),x3(Q,`${J}.objectMode`)},EK=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Z}\` option can only be defined when using a generator, not a ${Q}.`)},$D=({transform:Y,final:Z,binary:Q,objectMode:J},z)=>{if(Y!==void 0&&!PK(Y))throw TypeError(`The \`${z}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(I3(Z,{checkOpen:!1}))throw TypeError(`The \`${z}.final\` option must not be a Duplex stream.`);if(P3(Z))throw TypeError(`The \`${z}.final\` option must not be a web TransformStream.`);if(Z!==void 0&&!PK(Z))throw TypeError(`The \`${z}.final\` option must be a generator.`);return x3(Q,`${z}.binary`),x3(J,`${z}.objectMode`),s6(Y)||s6(Z)?"asyncGenerator":"generator"},x3=(Y,Z)=>{if(Y!==void 0&&typeof Y!=="boolean")throw TypeError(`The \`${Z}\` option must use a boolean.`)},PK=(Y)=>s6(Y)||fK(Y),s6=(Y)=>Object.prototype.toString.call(Y)==="[object AsyncGeneratorFunction]",fK=(Y)=>Object.prototype.toString.call(Y)==="[object GeneratorFunction]",qD=(Y)=>F0(Y)&&(Y.transform!==void 0||Y.final!==void 0),T7=(Y)=>Object.prototype.toString.call(Y)==="[object URL]",bK=(Y)=>T7(Y)&&Y.protocol!=="file:",UD=(Y)=>F0(Y)&&Object.keys(Y).length>0&&Object.keys(Y).every((Z)=>BD.has(Z))&&E3(Y.file),BD,E3=(Y)=>typeof Y==="string",hK=(Y,Z)=>Y==="native"&&typeof Z==="string"&&!VD.has(Z),VD,gK=(Y)=>Object.prototype.toString.call(Y)==="[object ReadableStream]",C7=(Y)=>Object.prototype.toString.call(Y)==="[object WritableStream]",FD=(Y)=>gK(Y)||C7(Y),P3=(Y)=>gK(Y?.readable)&&C7(Y?.writable),RD=(Y)=>mK(Y)&&typeof Y[Symbol.asyncIterator]==="function",MD=(Y)=>mK(Y)&&typeof Y[Symbol.iterator]==="function",mK=(Y)=>typeof Y==="object"&&Y!==null,XY,k7,S3,uK,dK,U6;var h0=R(()=>{i0();BD=new Set(["file","append"]),VD=new Set(["ipc","ignore","inherit","overlapped","pipe"]),XY=new Set(["generator","asyncGenerator","duplex","webTransform"]),k7=new Set(["fileUrl","filePath","fileNumber"]),S3=new Set(["fileUrl","filePath"]),uK=new Set([...S3,"webStream","nodeStream"]),dK=new Set(["webTransform","duplex"]),U6={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"}});var v3=(Y,Z,Q,J)=>J==="output"?OD(Y,Z,Q):DD(Y,Z,Q),OD=(Y,Z,Q)=>{let J=Z!==0&&Q[Z-1].value.readableObjectMode;return{writableObjectMode:J,readableObjectMode:Y??J}},DD=(Y,Z,Q)=>{let J=Z===0?Y===!0:Q[Z-1].value.readableObjectMode,z=Z!==Q.length-1&&(Y??J);return{writableObjectMode:J,readableObjectMode:z}},pK=(Y,Z)=>{let Q=Y.findLast(({type:J})=>XY.has(J));if(Q===void 0)return!1;return Z==="input"?Q.value.writableObjectMode:Q.value.readableObjectMode};var y3=R(()=>{h0()});var cK=(Y,Z,Q,J)=>[...Y.filter(({type:z})=>!XY.has(z)),...ND(Y,Z,Q,J)],ND=(Y,Z,Q,{encoding:J})=>{let z=Y.filter(({type:H})=>XY.has(H)),X=Array.from({length:z.length});for(let[H,W]of Object.entries(z))X[H]=wD({stdioItem:W,index:Number(H),newTransforms:X,optionName:Z,direction:Q,encoding:J});return jD(X,Q)},wD=({stdioItem:Y,stdioItem:{type:Z},index:Q,newTransforms:J,optionName:z,direction:X,encoding:H})=>{if(Z==="duplex")return LD({stdioItem:Y,optionName:z});if(Z==="webTransform")return _D({stdioItem:Y,index:Q,newTransforms:J,direction:X});return ID({stdioItem:Y,index:Q,newTransforms:J,direction:X,encoding:H})},LD=({stdioItem:Y,stdioItem:{value:{transform:Z,transform:{writableObjectMode:Q,readableObjectMode:J},objectMode:z=J}},optionName:X})=>{if(z&&!J)throw TypeError(`The \`${X}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!z&&J)throw TypeError(`The \`${X}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...Y,value:{transform:Z,writableObjectMode:Q,readableObjectMode:J}}},_D=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:J,direction:z})=>{let{transform:X,objectMode:H}=F0(Z)?Z:{transform:Z},{writableObjectMode:W,readableObjectMode:K}=v3(H,Q,J,z);return{...Y,value:{transform:X,writableObjectMode:W,readableObjectMode:K}}},ID=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:J,direction:z,encoding:X})=>{let{transform:H,final:W,binary:K=!1,preserveNewlines:$=!1,objectMode:G}=F0(Z)?Z:{transform:Z},U=K||a0.has(X),{writableObjectMode:B,readableObjectMode:F}=v3(G,Q,J,z);return{...Y,value:{transform:H,final:W,binary:U,preserveNewlines:$,writableObjectMode:B,readableObjectMode:F}}},jD=(Y,Z)=>Z==="input"?Y.reverse():Y;var lK=R(()=>{n6();h0();y3()});import f3 from"node:process";var iK=(Y,Z,Q)=>{let J=Y.map((z)=>TD(z,Z));if(J.includes("input")&&J.includes("output"))throw TypeError(`The \`${Q}\` option must not be an array of both readable and writable values.`);return J.find(Boolean)??AD},TD=({type:Y,value:Z},Q)=>CD[Q]??nK[Y](Z),CD,i1=()=>{return},b3=()=>"input",nK,kD=(Y)=>{if([0,f3.stdin].includes(Y))return"input";if([1,2,f3.stdout,f3.stderr].includes(Y))return"output"},AD="output";var aK=R(()=>{h0();CD=["input","output","output"],nK={generator:i1,asyncGenerator:i1,fileUrl:i1,filePath:i1,iterable:b3,asyncIterable:b3,uint8Array:b3,webStream:(Y)=>C7(Y)?"output":"input",nodeStream(Y){if(!a6(Y,{checkOpen:!1}))return"output";return _3(Y,{checkOpen:!1})?void 0:"input"},webTransform:i1,duplex:i1,native(Y){let Z=kD(Y);if(Z!==void 0)return Z;if(VY(Y,{checkOpen:!1}))return nK.nodeStream(Y)}}});var oK=(Y,Z)=>Z&&!Y.includes("ipc")?[...Y,"ipc"]:Y;var sK=({stdio:Y,ipc:Z,buffer:Q,...J},z,X)=>{let H=xD(Y,J).map((W,K)=>rK(W,K));return X?PD(H,Q,z):oK(H,Z)},xD=(Y,Z)=>{if(Y===void 0)return zY.map((J)=>Z[J]);if(ED(Z))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${zY.map((J)=>`\`${J}\``).join(", ")}`);if(typeof Y==="string")return[Y,Y,Y];if(!Array.isArray(Y))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof Y}\``);let Q=Math.max(Y.length,zY.length);return Array.from({length:Q},(J,z)=>Y[z])},ED=(Y)=>zY.some((Z)=>Y[Z]!==void 0),rK=(Y,Z)=>{if(Array.isArray(Y))return Y.map((Q)=>rK(Q,Z));if(Y===null||Y===void 0)return Z>=zY.length?"ignore":"pipe";return Y},PD=(Y,Z,Q)=>Y.map((J,z)=>!Z[z]&&z!==0&&!v1(Q,z)&&SD(J)?"ignore":J),SD=(Y)=>Y==="pipe"||Array.isArray(Y)&&Y.every((Z)=>Z==="pipe");var tK=R(()=>{uY();W6()});import{readFileSync as vD}from"node:fs";import yD from"node:tty";var YG=({stdioItem:Y,stdioItem:{type:Z},isStdioArray:Q,fdNumber:J,direction:z,isSync:X})=>{if(!Q||Z!=="native")return Y;return X?fD({stdioItem:Y,fdNumber:J,direction:z}):gD({stdioItem:Y,fdNumber:J})},fD=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:J,direction:z})=>{let X=bD({value:Z,optionName:Q,fdNumber:J,direction:z});if(X!==void 0)return X;if(VY(Z,{checkOpen:!1}))throw TypeError(`The \`${Q}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return Y},bD=({value:Y,optionName:Z,fdNumber:Q,direction:J})=>{let z=hD(Y,Q);if(z===void 0)return;if(J==="output")return{type:"fileNumber",value:z,optionName:Z};if(yD.isatty(z))throw TypeError(`The \`${Z}: ${sZ(Y)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:mY(vD(z)),optionName:Z}},hD=(Y,Z)=>{if(Y==="inherit")return Z;if(typeof Y==="number")return Y;let Q=AZ.indexOf(Y);if(Q!==-1)return Q},gD=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:J})=>{if(Z==="inherit")return{type:"nodeStream",value:eK(J,Z,Q),optionName:Q};if(typeof Z==="number")return{type:"nodeStream",value:eK(Z,Z,Q),optionName:Q};if(VY(Z,{checkOpen:!1}))return{type:"nodeStream",value:Z,optionName:Q};return Y},eK=(Y,Z,Q)=>{let J=AZ[Y];if(J===void 0)throw TypeError(`The \`${Q}: ${Z}\` option is invalid: no such standard stream.`);return J};var ZG=R(()=>{uY();i0();$6()});var QG=({input:Y,inputFile:Z},Q)=>Q===0?[...mD(Y),...dD(Z)]:[],mD=(Y)=>Y===void 0?[]:[{type:uD(Y),value:Y,optionName:"input"}],uD=(Y)=>{if(a6(Y,{checkOpen:!1}))return"nodeStream";if(typeof Y==="string")return"string";if(L0(Y))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},dD=(Y)=>Y===void 0?[]:[{...pD(Y),optionName:"inputFile"}],pD=(Y)=>{if(T7(Y))return{type:"fileUrl",value:Y};if(E3(Y))return{type:"filePath",value:{file:Y}};throw Error("The `inputFile` option must be a file path string or a file URL.")};var JG=R(()=>{i0();h0()});var zG=(Y)=>Y.filter((Z,Q)=>Y.every((J,z)=>Z.value!==J.value||Q>=z||Z.type==="generator"||Z.type==="asyncGenerator")),XG=({stdioItem:{type:Y,value:Z,optionName:Q},direction:J,fileDescriptors:z,isSync:X})=>{let H=cD(z,Y);if(H.length===0)return;if(X){lD({otherStdioItems:H,type:Y,value:Z,optionName:Q,direction:J});return}if(uK.has(Y))return HG({otherStdioItems:H,type:Y,value:Z,optionName:Q,direction:J});if(dK.has(Y))nD({otherStdioItems:H,type:Y,value:Z,optionName:Q})},cD=(Y,Z)=>Y.flatMap(({direction:Q,stdioItems:J})=>J.filter((z)=>z.type===Z).map((z)=>({...z,direction:Q}))),lD=({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})=>{if(S3.has(Z))HG({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})},HG=({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})=>{let X=Y.filter((W)=>iD(W,Q));if(X.length===0)return;let H=X.find((W)=>W.direction!==z);return WG(H,J,Z),z==="output"?X[0].stream:void 0},iD=({type:Y,value:Z},Q)=>{if(Y==="filePath")return Z.file===Q.file;if(Y==="fileUrl")return Z.href===Q.href;return Z===Q},nD=({otherStdioItems:Y,type:Z,value:Q,optionName:J})=>{let z=Y.find(({value:{transform:X}})=>X===Q.transform);WG(z,J,Z)},WG=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Y.optionName}\` and \`${Z}\` options must not target ${U6[Q]} that is the same.`)};var KG=R(()=>{h0()});var A7=(Y,Z,Q,J)=>{let X=sK(Z,Q,J).map((W,K)=>aD({stdioOption:W,fdNumber:K,options:Z,isSync:J})),H=QN({initialFileDescriptors:X,addProperties:Y,options:Z,isSync:J});return Z.stdio=H.map(({stdioItems:W})=>XN(W)),H},aD=({stdioOption:Y,fdNumber:Z,options:Q,isSync:J})=>{let z=xZ(Z),{stdioItems:X,isStdioArray:H}=oD({stdioOption:Y,fdNumber:Z,options:Q,optionName:z}),W=iK(X,Z,z),K=X.map((U)=>YG({stdioItem:U,isStdioArray:H,fdNumber:Z,direction:W,isSync:J})),$=cK(K,z,W,Q),G=pK($,W);return ZN($,G),{direction:W,objectMode:G,stdioItems:$}},oD=({stdioOption:Y,fdNumber:Z,options:Q,optionName:J})=>{let X=[...(Array.isArray(Y)?Y:[Y]).map((K)=>sD(K,J)),...QG(Q,Z)],H=zG(X),W=H.length>1;return rD(H,W,J),eD(H),{stdioItems:H,isStdioArray:W}},sD=(Y,Z)=>({type:SK(Y,Z),value:Y,optionName:Z}),rD=(Y,Z,Q)=>{if(Y.length===0)throw TypeError(`The \`${Q}\` option must not be an empty array.`);if(!Z)return;for(let{value:J,optionName:z}of Y)if(tD.has(J))throw Error(`The \`${z}\` option must not include \`${J}\`.`)},tD,eD=(Y)=>{for(let Z of Y)YN(Z)},YN=({type:Y,value:Z,optionName:Q})=>{if(bK(Z))throw TypeError(`The \`${Q}: URL\` option must use the \`file:\` scheme.
|
|
76
|
-
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(
|
|
77
|
-
`){let
|
|
69
|
+
${Y}`;return Y};var aQ=O(()=>{iY()});import ND from"node:path";import PW from"node:process";var vW,y2=(Y,Z,Q)=>{Q.cwd=EW(Q.cwd);let[J,z,K]=TW(Y,Z,Q),{command:X,args:H,options:W}=vW.default._parse(J,z,K),q=XX(W),G=_D(q);if(_W(G),kW(G),IW(G),uH(G),DW(G),G.shell=GQ(G.shell),G.env=LD(G),G.killSignal=fH(G.killSignal),G.forceKillAfterDelay=gH(G.forceKillAfterDelay),G.lines=G.lines.map(($,B)=>$&&!q1.has(G.encoding)&&G.buffer[B]),PW.platform==="win32"&&ND.basename(X,".exe")==="cmd")H.unshift("/q");return{file:X,commandArguments:H,options:G}},_D=({extendEnv:Y=!0,preferLocal:Z=!1,cwd:Q,localDir:J=Q,encoding:z="utf8",reject:K=!0,cleanup:X=!0,all:H=!1,windowsHide:W=!0,killSignal:q="SIGTERM",forceKillAfterDelay:G=!0,gracefulCancel:$=!1,ipcInput:B,ipc:V=B!==void 0||$,serialization:F="advanced",...M})=>({...M,extendEnv:Y,preferLocal:Z,cwd:Q,localDirectory:J,encoding:z,reject:K,cleanup:X,all:H,windowsHide:W,killSignal:q,forceKillAfterDelay:G,gracefulCancel:$,ipcInput:B,ipc:V,serialization:F}),LD=({env:Y,extendEnv:Z,preferLocal:Q,node:J,localDirectory:z,nodePath:K})=>{let X=Z?{...PW.env,...Y}:Y;if(Q||J)return LH({env:X,cwd:z,execPath:K,preferLocal:Q,addExecPath:J});return X};var oQ=O(()=>{wH();F2();YZ();yQ();pQ();cQ();lQ();nQ();HY();aQ();iY();H6();vW=NR(MH(),1)});var f2=(Y,Z,Q)=>Q.shell&&Z.length>0?[[Y,...Z].join(" "),[],Q]:[Y,Z,Q];function J4(Y){if(typeof Y==="string")return wD(Y);if(!(ArrayBuffer.isView(Y)&&Y.BYTES_PER_ELEMENT===1))throw Error("Input must be a string or a Uint8Array");return jD(Y)}var wD=(Y)=>Y.at(-1)===yW?Y.slice(0,Y.at(-2)===fW?-2:-1):Y,jD=(Y)=>Y.at(-1)===TD?Y.subarray(0,Y.at(-2)===ID?-2:-1):Y,yW=`
|
|
70
|
+
`,TD,fW="\r",ID;var sQ=O(()=>{TD=yW.codePointAt(0),ID=fW.codePointAt(0)});function P1(Y,{checkOpen:Z=!0}={}){return Y!==null&&typeof Y==="object"&&(Y.writable||Y.readable||!Z||Y.writable===void 0&&Y.readable===void 0)&&typeof Y.pipe==="function"}function rQ(Y,{checkOpen:Z=!0}={}){return P1(Y,{checkOpen:Z})&&(Y.writable||!Z)&&typeof Y.write==="function"&&typeof Y.end==="function"&&typeof Y.writable==="boolean"&&typeof Y.writableObjectMode==="boolean"&&typeof Y.destroy==="function"&&typeof Y.destroyed==="boolean"}function WY(Y,{checkOpen:Z=!0}={}){return P1(Y,{checkOpen:Z})&&(Y.readable||!Z)&&typeof Y.read==="function"&&typeof Y.readable==="boolean"&&typeof Y.readableObjectMode==="boolean"&&typeof Y.destroy==="function"&&typeof Y.destroyed==="boolean"}function tQ(Y,Z){return rQ(Y,Z)&&WY(Y,Z)}class bW{#Z;#Q;#Y=!1;#J=void 0;constructor(Y,Z){this.#Z=Y,this.#Q=Z}next(){let Y=()=>this.#z();return this.#J=this.#J?this.#J.then(Y,Y):Y(),this.#J}return(Y){let Z=()=>this.#K(Y);return this.#J?this.#J.then(Z,Z):Z()}async#z(){if(this.#Y)return{done:!0,value:void 0};let Y;try{Y=await this.#Z.read()}catch(Z){throw this.#J=void 0,this.#Y=!0,this.#Z.releaseLock(),Z}return Y.done&&(this.#J=void 0,this.#Y=!0,this.#Z.releaseLock()),Y}async#K(Y){if(this.#Y)return{done:!0,value:Y};if(this.#Y=!0,!this.#Q){let Z=this.#Z.cancel(Y);return this.#Z.releaseLock(),await Z,{done:!0,value:Y}}return this.#Z.releaseLock(),{done:!0,value:Y}}}function hW(){return this[eQ].next()}function gW(Y){return this[eQ].return(Y)}function Y3({preventCancel:Y=!1}={}){let Z=this.getReader(),Q=new bW(Z,Y),J=Object.create(AD);return J[eQ]=Q,J}var CD,eQ,AD;var mW=O(()=>{CD=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);eQ=Symbol();Object.defineProperty(hW,"name",{value:"next"});Object.defineProperty(gW,"name",{value:"return"});AD=Object.create(CD,{next:{enumerable:!0,configurable:!0,writable:!0,value:hW},return:{enumerable:!0,configurable:!0,writable:!0,value:gW}})});var uW=()=>{};var dW=O(()=>{mW();uW()});var pW=(Y)=>{if(WY(Y,{checkOpen:!1})&&zZ.on!==void 0)return ED(Y);if(typeof Y?.[Symbol.asyncIterator]==="function")return Y;if(kD.call(Y)==="[object ReadableStream]")return Y3.call(Y);throw TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},kD,ED=async function*(Y){let Z=new AbortController,Q={};xD(Y,Z,Q);try{for await(let[J]of zZ.on(Y,"data",{signal:Z.signal}))yield J}catch(J){if(Q.error!==void 0)throw Q.error;else if(!Z.signal.aborted)throw J}finally{Y.destroy()}},xD=async(Y,Z,Q)=>{try{await zZ.finished(Y,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(J){Q.error=J}finally{Z.abort()}},zZ;var Z3=O(()=>{dW();({toString:kD}=Object.prototype),zZ={}});var z4=async(Y,{init:Z,convertChunk:Q,getSize:J,truncateChunk:z,addChunk:K,getFinalChunk:X,finalize:H},{maxBuffer:W=Number.POSITIVE_INFINITY}={})=>{let q=pW(Y),G=Z();G.length=0;try{for await(let $ of q){let B=PD($),V=Q[B]($,G);nW({convertedChunk:V,state:G,getSize:J,truncateChunk:z,addChunk:K,maxBuffer:W})}return SD({state:G,convertChunk:Q,getSize:J,truncateChunk:z,addChunk:K,getFinalChunk:X,maxBuffer:W}),H(G)}catch($){let B=typeof $==="object"&&$!==null?$:Error($);throw B.bufferedData=H(G),B}},SD=({state:Y,getSize:Z,truncateChunk:Q,addChunk:J,getFinalChunk:z,maxBuffer:K})=>{let X=z(Y);if(X!==void 0)nW({convertedChunk:X,state:Y,getSize:Z,truncateChunk:Q,addChunk:J,maxBuffer:K})},nW=({convertedChunk:Y,state:Z,getSize:Q,truncateChunk:J,addChunk:z,maxBuffer:K})=>{let X=Q(Y),H=Z.length+X;if(H<=K){cW(Y,Z,z,H);return}let W=J(Y,K-Z.length);if(W!==void 0)cW(W,Z,z,K);throw new W6},cW=(Y,Z,Q,J)=>{Z.contents=Q(Y,Z,J),Z.length=J},PD=(Y)=>{let Z=typeof Y;if(Z==="string")return"string";if(Z!=="object"||Y===null)return"others";if(globalThis.Buffer?.isBuffer(Y))return"buffer";let Q=lW.call(Y);if(Q==="[object ArrayBuffer]")return"arrayBuffer";if(Q==="[object DataView]")return"dataView";if(Number.isInteger(Y.byteLength)&&Number.isInteger(Y.byteOffset)&&lW.call(Y.buffer)==="[object ArrayBuffer]")return"typedArray";return"others"},lW,W6;var KZ=O(()=>{Z3();({toString:lW}=Object.prototype);W6=class W6 extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}}});var q6=(Y)=>Y,XZ=()=>{return},b2=({contents:Y})=>Y,h2=(Y)=>{throw Error(`Streams in object mode are not supported: ${String(Y)}`)},g2=(Y)=>Y.length;async function m2(Y,Z){return z4(Y,bD,Z)}var vD=()=>({contents:[]}),yD=()=>1,fD=(Y,{contents:Z})=>{return Z.push(Y),Z},bD;var iW=O(()=>{KZ();bD={init:vD,convertChunk:{string:q6,buffer:q6,arrayBuffer:q6,dataView:q6,typedArray:q6,others:q6},getSize:yD,truncateChunk:XZ,addChunk:fD,getFinalChunk:XZ,finalize:b2}});async function u2(Y,Z){return z4(Y,nD,Z)}var hD=()=>({contents:new ArrayBuffer(0)}),gD=(Y)=>mD.encode(Y),mD,aW=(Y)=>new Uint8Array(Y),oW=(Y)=>new Uint8Array(Y.buffer,Y.byteOffset,Y.byteLength),uD=(Y,Z)=>Y.slice(0,Z),dD=(Y,{contents:Z,length:Q},J)=>{let z=tW()?cD(Z,J):pD(Z,J);return new Uint8Array(z).set(Y,Q),z},pD=(Y,Z)=>{if(Z<=Y.byteLength)return Y;let Q=new ArrayBuffer(rW(Z));return new Uint8Array(Q).set(new Uint8Array(Y),0),Q},cD=(Y,Z)=>{if(Z<=Y.maxByteLength)return Y.resize(Z),Y;let Q=new ArrayBuffer(Z,{maxByteLength:rW(Z)});return new Uint8Array(Q).set(new Uint8Array(Y),0),Q},rW=(Y)=>sW**Math.ceil(Math.log(Y)/Math.log(sW)),sW=2,lD=({contents:Y,length:Z})=>tW()?Y:Y.slice(0,Z),tW=()=>("resize"in ArrayBuffer.prototype),nD;var eW=O(()=>{KZ();mD=new TextEncoder,nD={init:hD,convertChunk:{string:gD,buffer:aW,arrayBuffer:aW,dataView:oW,typedArray:oW,others:h2},getSize:g2,truncateChunk:uD,addChunk:dD,getFinalChunk:XZ,finalize:lD}});async function p2(Y,Z){return z4(Y,rD,Z)}var iD=()=>({contents:"",textDecoder:new TextDecoder}),d2=(Y,{textDecoder:Z})=>Z.decode(Y,{stream:!0}),aD=(Y,{contents:Z})=>Z+Y,oD=(Y,Z)=>Y.slice(0,Z),sD=({textDecoder:Y})=>{let Z=Y.decode();return Z===""?void 0:Z},rD;var Yq=O(()=>{KZ();rD={init:iD,convertChunk:{string:q6,buffer:d2,arrayBuffer:d2,dataView:d2,typedArray:d2,others:h2},getSize:g2,truncateChunk:oD,addChunk:aD,getFinalChunk:sD,finalize:b2}});var Zq=O(()=>{iW();eW();Yq();KZ()});import{on as tD}from"node:events";import{finished as eD}from"node:stream/promises";var c2=O(()=>{Z3();Zq();Object.assign(zZ,{on:tD,finished:eD})});var Qq=({error:Y,stream:Z,readableObjectMode:Q,lines:J,encoding:z,fdNumber:K})=>{if(!(Y instanceof W6))throw Y;if(K==="all")return Y;let X=YN(Q,J,z);throw Y.maxBufferInfo={fdNumber:K,unit:X},Z.destroy(),Y},YN=(Y,Z,Q)=>{if(Y)return"objects";if(Z)return"lines";if(Q==="buffer")return"bytes";return"characters"},Jq=(Y,Z,Q)=>{if(Z.length!==Q)return;let J=new W6;throw J.maxBufferInfo={fdNumber:"ipc"},J},zq=(Y,Z)=>{let{streamName:Q,threshold:J,unit:z}=ZN(Y,Z);return`Command's ${Q} was larger than ${J} ${z}`},ZN=(Y,Z)=>{if(Y?.maxBufferInfo===void 0)return{streamName:"output",threshold:Z[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:Q,unit:J}}=Y;delete Y.maxBufferInfo;let z=X6(Z,Q);if(Q==="ipc")return{streamName:"IPC output",threshold:z,unit:"messages"};return{streamName:t8(Q),threshold:z,unit:J}},Kq=(Y,Z,Q)=>Y?.code==="ENOBUFS"&&Z!==null&&Z.some((J)=>J!==null&&J.length>l2(Q)),Xq=(Y,Z,Q)=>{if(!Z)return Y;let J=l2(Q);return Y.length>J?Y.slice(0,J):Y},l2=([,Y])=>Y;var qY=O(()=>{c2();K6();H6()});import{inspect as QN}from"node:util";var Wq=({stdio:Y,all:Z,ipcOutput:Q,originalError:J,signal:z,signalDescription:K,exitCode:X,escapedCommand:H,timedOut:W,isCanceled:q,isGracefullyCanceled:G,isMaxBuffer:$,isForcefullyTerminated:B,forceKillAfterDelay:V,killSignal:F,maxBuffer:M,timeout:L,cwd:N})=>{let _=J?.code,I=JN({originalError:J,timedOut:W,timeout:L,isMaxBuffer:$,maxBuffer:M,errorCode:_,signal:z,signalDescription:K,exitCode:X,isCanceled:q,isGracefullyCanceled:G,isForcefullyTerminated:B,forceKillAfterDelay:V,killSignal:F}),w=KN(J,N),A=w===void 0?"":`
|
|
71
|
+
${w}`,x=`${I}: ${H}${A}`,E=Z===void 0?[Y[2],Y[1]]:[Z],h=[x,...E,...Y.slice(3),Q.map((u)=>XN(u)).join(`
|
|
72
|
+
`)].map((u)=>r4(J4(HN(u)))).filter(Boolean).join(`
|
|
73
|
+
|
|
74
|
+
`);return{originalMessage:w,shortMessage:x,message:h}},JN=({originalError:Y,timedOut:Z,timeout:Q,isMaxBuffer:J,maxBuffer:z,errorCode:K,signal:X,signalDescription:H,exitCode:W,isCanceled:q,isGracefullyCanceled:G,isForcefullyTerminated:$,forceKillAfterDelay:B,killSignal:V})=>{let F=zN($,B);if(Z)return`Command timed out after ${Q} milliseconds${F}`;if(G){if(X===void 0)return`Command was gracefully canceled with exit code ${W}`;return $?`Command was gracefully canceled${F}`:`Command was gracefully canceled with ${X} (${H})`}if(q)return`Command was canceled${F}`;if(J)return`${zq(Y,z)}${F}`;if(K!==void 0)return`Command failed with ${K}${F}`;if($)return`Command was killed with ${V} (${V2(V)})${F}`;if(X!==void 0)return`Command was killed with ${X} (${H})`;if(W!==void 0)return`Command failed with exit code ${W}`;return"Command failed"},zN=(Y,Z)=>Y?` and was forcefully terminated after ${Z} milliseconds`:"",KN=(Y,Z)=>{if(Y instanceof g1)return;let Q=IH(Y)?Y.originalMessage:String(Y?.message??Y),J=r4(SW(Q,Z));return J===""?void 0:J},XN=(Y)=>typeof Y==="string"?Y:QN(Y),HN=(Y)=>Array.isArray(Y)?Y.map((Z)=>J4(Hq(Z))).filter(Boolean).join(`
|
|
75
|
+
`):Hq(Y),Hq=(Y)=>{if(typeof Y==="string")return Y;if(b0(Y))return s8(Y);return""};var qq=O(()=>{sQ();W1();aQ();Z2();qY();YZ();j6()});var n2=({command:Y,escapedCommand:Z,stdio:Q,all:J,ipcOutput:z,options:{cwd:K},startTime:X})=>Gq({command:Y,escapedCommand:Z,cwd:K,durationMs:DQ(X),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:Q[1],stderr:Q[2],all:J,stdio:Q,ipcOutput:z,pipedFrom:[]}),K4=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:K,isSync:X})=>HZ({error:Y,command:Z,escapedCommand:Q,startTime:K,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:J.length}),ipcOutput:[],options:z,isSync:X}),HZ=({error:Y,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:K,isGracefullyCanceled:X,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:q,signal:G,stdio:$,all:B,ipcOutput:V,options:{timeoutDuration:F,timeout:M=F,forceKillAfterDelay:L,killSignal:N,cwd:_,maxBuffer:I},isSync:w})=>{let{exitCode:A,signal:x,signalDescription:E}=qN(q,G),{originalMessage:h,shortMessage:u,message:f}=Wq({stdio:$,all:B,ipcOutput:V,originalError:Y,signal:x,signalDescription:E,exitCode:A,escapedCommand:Q,timedOut:z,isCanceled:K,isGracefullyCanceled:X,isMaxBuffer:H,isForcefullyTerminated:W,forceKillAfterDelay:L,killSignal:N,maxBuffer:I,timeout:M,cwd:_}),m=jH(Y,f,w);return Object.assign(m,WN({error:m,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:K,isGracefullyCanceled:X,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:A,signal:x,signalDescription:E,stdio:$,all:B,ipcOutput:V,cwd:_,originalMessage:h,shortMessage:u})),m},WN=({error:Y,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:K,isGracefullyCanceled:X,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:q,signal:G,signalDescription:$,stdio:B,all:V,ipcOutput:F,cwd:M,originalMessage:L,shortMessage:N})=>Gq({shortMessage:N,originalMessage:L,command:Z,escapedCommand:Q,cwd:M,durationMs:DQ(J),failed:!0,timedOut:z,isCanceled:K,isGracefullyCanceled:X,isTerminated:G!==void 0,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:q,signal:G,signalDescription:$,code:Y.cause?.code,stdout:B[1],stderr:B[2],all:V,stdio:B,ipcOutput:F,pipedFrom:[]}),Gq=(Y)=>Object.fromEntries(Object.entries(Y).filter(([,Z])=>Z!==void 0)),qN=(Y,Z)=>{let Q=Y===null?void 0:Y,J=Z===null?void 0:Z,z=J===void 0?void 0:V2(Z);return{exitCode:Q,signal:J,signalDescription:z}};var WZ=O(()=>{YZ();H2();j6();qq()});function GN(Y){return{days:Math.trunc(Y/86400000),hours:Math.trunc(Y/3600000%24),minutes:Math.trunc(Y/60000%60),seconds:Math.trunc(Y/1000%60),milliseconds:Math.trunc(Y%1000),microseconds:Math.trunc(Uq(Y*1000)%1000),nanoseconds:Math.trunc(Uq(Y*1e6)%1000)}}function UN(Y){return{days:Y/86400000n,hours:Y/3600000n%24n,minutes:Y/60000n%60n,seconds:Y/1000n%60n,milliseconds:Y%1000n,microseconds:0n,nanoseconds:0n}}function Q3(Y){switch(typeof Y){case"number":{if(Number.isFinite(Y))return GN(Y);break}case"bigint":return UN(Y)}throw TypeError("Expected a finite number or bigint")}var Uq=(Y)=>Number.isFinite(Y)?Y:0;function J3(Y,Z){let Q=typeof Y==="bigint";if(!Q&&!Number.isFinite(Y))throw TypeError("Expected a finite number or bigint");Z={...Z};let J=Y<0?"-":"";if(Y=Y<0?-Y:Y,Z.colonNotation)Z.compact=!1,Z.formatSubMilliseconds=!1,Z.separateMilliseconds=!1,Z.verbose=!1;if(Z.compact)Z.unitCount=1,Z.secondsDecimalDigits=0,Z.millisecondsDecimalDigits=0;let z=[],K=(G,$)=>{let B=Math.floor(G*10**$+VN);return(Math.round(B)/10**$).toFixed($)},X=(G,$,B,V)=>{if((z.length===0||!Z.colonNotation)&&$N(G)&&!(Z.colonNotation&&B==="m"))return;if(V??=String(G),Z.colonNotation){let F=V.includes(".")?V.split(".")[0].length:V.length,M=z.length>0?2:1;V="0".repeat(Math.max(0,M-F))+V}else V+=Z.verbose?" "+BN($,G):B;z.push(V)},H=Q3(Y),W=BigInt(H.days);if(Z.hideYearAndDays)X(BigInt(W)*24n+BigInt(H.hours),"hour","h");else{if(Z.hideYear)X(W,"day","d");else X(W/365n,"year","y"),X(W%365n,"day","d");X(Number(H.hours),"hour","h")}if(X(Number(H.minutes),"minute","m"),!Z.hideSeconds)if(Z.separateMilliseconds||Z.formatSubMilliseconds||!Z.colonNotation&&Y<1000&&!Z.subSecondsAsDecimals){let G=Number(H.seconds),$=Number(H.milliseconds),B=Number(H.microseconds),V=Number(H.nanoseconds);if(X(G,"second","s"),Z.formatSubMilliseconds)X($,"millisecond","ms"),X(B,"microsecond","µs"),X(V,"nanosecond","ns");else{let F=$+B/1000+V/1e6,M=typeof Z.millisecondsDecimalDigits==="number"?Z.millisecondsDecimalDigits:0,L=F>=1?Math.round(F):Math.ceil(F),N=M?F.toFixed(M):L;X(Number.parseFloat(N),"millisecond","ms",N)}}else{let G=(Q?Number(Y%FN):Y)/1000%60,$=typeof Z.secondsDecimalDigits==="number"?Z.secondsDecimalDigits:1,B=K(G,$),V=Z.keepDecimalsOnWholeSeconds?B:B.replace(/\.0+$/,"");X(Number.parseFloat(V),"second","s",V)}if(z.length===0)return J+"0"+(Z.verbose?" milliseconds":"ms");let q=Z.colonNotation?":":" ";if(typeof Z.unitCount==="number")z=z.slice(0,Math.max(Z.unitCount,1));return J+z.join(q)}var $N=(Y)=>Y===0||Y===0n,BN=(Y,Z)=>Z===1||Z===1n?Y:`${Y}s`,VN=0.0000001,FN;var $q=O(()=>{FN=24n*60n*60n*1000n});var Bq=(Y,Z)=>{if(Y.failed)h1({type:"error",verboseMessage:Y.shortMessage,verboseInfo:Z,result:Y})};var Vq=O(()=>{sY()});var Fq=(Y,Z)=>{if(!aY(Z))return;Bq(Y,Z),RN(Y,Z)},RN=(Y,Z)=>{let Q=`(done in ${J3(Y.durationMs)})`;h1({type:"duration",verboseMessage:Q,verboseInfo:Z,result:Y})};var Rq=O(()=>{$q();w6();sY();Vq()});var X4=(Y,Z,{reject:Q})=>{if(Fq(Y,Z),Y.failed&&Q)throw Y;return Y};var i2=O(()=>{Rq()});var Dq=(Y,Z)=>{if(GY(Y))return"asyncGenerator";if(Lq(Y))return"generator";if(a2(Y))return"fileUrl";if(_N(Y))return"filePath";if(jN(Y))return"webStream";if(P1(Y,{checkOpen:!1}))return"native";if(b0(Y))return"uint8Array";if(TN(Y))return"asyncIterable";if(IN(Y))return"iterable";if(X3(Y))return Nq({transform:Y},Z);if(NN(Y))return ON(Y,Z);return"native"},ON=(Y,Z)=>{if(tQ(Y.transform,{checkOpen:!1}))return MN(Y,Z);if(X3(Y.transform))return Nq(Y,Z);return DN(Y,Z)},MN=(Y,Z)=>{return _q(Y,Z,"Duplex stream"),"duplex"},Nq=(Y,Z)=>{return _q(Y,Z,"web TransformStream"),"webTransform"},_q=({final:Y,binary:Z,objectMode:Q},J,z)=>{Oq(Y,`${J}.final`,z),Oq(Z,`${J}.binary`,z),z3(Q,`${J}.objectMode`)},Oq=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Z}\` option can only be defined when using a generator, not a ${Q}.`)},DN=({transform:Y,final:Z,binary:Q,objectMode:J},z)=>{if(Y!==void 0&&!Mq(Y))throw TypeError(`The \`${z}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(tQ(Z,{checkOpen:!1}))throw TypeError(`The \`${z}.final\` option must not be a Duplex stream.`);if(X3(Z))throw TypeError(`The \`${z}.final\` option must not be a web TransformStream.`);if(Z!==void 0&&!Mq(Z))throw TypeError(`The \`${z}.final\` option must be a generator.`);return z3(Q,`${z}.binary`),z3(J,`${z}.objectMode`),GY(Y)||GY(Z)?"asyncGenerator":"generator"},z3=(Y,Z)=>{if(Y!==void 0&&typeof Y!=="boolean")throw TypeError(`The \`${Z}\` option must use a boolean.`)},Mq=(Y)=>GY(Y)||Lq(Y),GY=(Y)=>Object.prototype.toString.call(Y)==="[object AsyncGeneratorFunction]",Lq=(Y)=>Object.prototype.toString.call(Y)==="[object GeneratorFunction]",NN=(Y)=>k0(Y)&&(Y.transform!==void 0||Y.final!==void 0),a2=(Y)=>Object.prototype.toString.call(Y)==="[object URL]",wq=(Y)=>a2(Y)&&Y.protocol!=="file:",_N=(Y)=>k0(Y)&&Object.keys(Y).length>0&&Object.keys(Y).every((Z)=>LN.has(Z))&&K3(Y.file),LN,K3=(Y)=>typeof Y==="string",jq=(Y,Z)=>Y==="native"&&typeof Z==="string"&&!wN.has(Z),wN,Tq=(Y)=>Object.prototype.toString.call(Y)==="[object ReadableStream]",o2=(Y)=>Object.prototype.toString.call(Y)==="[object WritableStream]",jN=(Y)=>Tq(Y)||o2(Y),X3=(Y)=>Tq(Y?.readable)&&o2(Y?.writable),TN=(Y)=>Iq(Y)&&typeof Y[Symbol.asyncIterator]==="function",IN=(Y)=>Iq(Y)&&typeof Y[Symbol.iterator]==="function",Iq=(Y)=>typeof Y==="object"&&Y!==null,L1,s2,H3,Cq,Aq,A6;var Z1=O(()=>{W1();LN=new Set(["file","append"]),wN=new Set(["ipc","ignore","inherit","overlapped","pipe"]),L1=new Set(["generator","asyncGenerator","duplex","webTransform"]),s2=new Set(["fileUrl","filePath","fileNumber"]),H3=new Set(["fileUrl","filePath"]),Cq=new Set([...H3,"webStream","nodeStream"]),Aq=new Set(["webTransform","duplex"]),A6={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"}});var W3=(Y,Z,Q,J)=>J==="output"?CN(Y,Z,Q):AN(Y,Z,Q),CN=(Y,Z,Q)=>{let J=Z!==0&&Q[Z-1].value.readableObjectMode;return{writableObjectMode:J,readableObjectMode:Y??J}},AN=(Y,Z,Q)=>{let J=Z===0?Y===!0:Q[Z-1].value.readableObjectMode,z=Z!==Q.length-1&&(Y??J);return{writableObjectMode:J,readableObjectMode:z}},kq=(Y,Z)=>{let Q=Y.findLast(({type:J})=>L1.has(J));if(Q===void 0)return!1;return Z==="input"?Q.value.writableObjectMode:Q.value.readableObjectMode};var q3=O(()=>{Z1()});var Eq=(Y,Z,Q,J)=>[...Y.filter(({type:z})=>!L1.has(z)),...kN(Y,Z,Q,J)],kN=(Y,Z,Q,{encoding:J})=>{let z=Y.filter(({type:X})=>L1.has(X)),K=Array.from({length:z.length});for(let[X,H]of Object.entries(z))K[X]=EN({stdioItem:H,index:Number(X),newTransforms:K,optionName:Z,direction:Q,encoding:J});return vN(K,Q)},EN=({stdioItem:Y,stdioItem:{type:Z},index:Q,newTransforms:J,optionName:z,direction:K,encoding:X})=>{if(Z==="duplex")return xN({stdioItem:Y,optionName:z});if(Z==="webTransform")return SN({stdioItem:Y,index:Q,newTransforms:J,direction:K});return PN({stdioItem:Y,index:Q,newTransforms:J,direction:K,encoding:X})},xN=({stdioItem:Y,stdioItem:{value:{transform:Z,transform:{writableObjectMode:Q,readableObjectMode:J},objectMode:z=J}},optionName:K})=>{if(z&&!J)throw TypeError(`The \`${K}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!z&&J)throw TypeError(`The \`${K}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...Y,value:{transform:Z,writableObjectMode:Q,readableObjectMode:J}}},SN=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:J,direction:z})=>{let{transform:K,objectMode:X}=k0(Z)?Z:{transform:Z},{writableObjectMode:H,readableObjectMode:W}=W3(X,Q,J,z);return{...Y,value:{transform:K,writableObjectMode:H,readableObjectMode:W}}},PN=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:J,direction:z,encoding:K})=>{let{transform:X,final:H,binary:W=!1,preserveNewlines:q=!1,objectMode:G}=k0(Z)?Z:{transform:Z},$=W||q1.has(K),{writableObjectMode:B,readableObjectMode:V}=W3(G,Q,J,z);return{...Y,value:{transform:X,final:H,binary:$,preserveNewlines:q,writableObjectMode:B,readableObjectMode:V}}},vN=(Y,Z)=>Z==="input"?Y.reverse():Y;var xq=O(()=>{HY();Z1();q3()});import G3 from"node:process";var Sq=(Y,Z,Q)=>{let J=Y.map((z)=>yN(z,Z));if(J.includes("input")&&J.includes("output"))throw TypeError(`The \`${Q}\` option must not be an array of both readable and writable values.`);return J.find(Boolean)??hN},yN=({type:Y,value:Z},Q)=>fN[Q]??Pq[Y](Z),fN,H4=()=>{return},U3=()=>"input",Pq,bN=(Y)=>{if([0,G3.stdin].includes(Y))return"input";if([1,2,G3.stdout,G3.stderr].includes(Y))return"output"},hN="output";var vq=O(()=>{Z1();fN=["input","output","output"],Pq={generator:H4,asyncGenerator:H4,fileUrl:H4,filePath:H4,iterable:U3,asyncIterable:U3,uint8Array:U3,webStream:(Y)=>o2(Y)?"output":"input",nodeStream(Y){if(!WY(Y,{checkOpen:!1}))return"output";return rQ(Y,{checkOpen:!1})?void 0:"input"},webTransform:H4,duplex:H4,native(Y){let Z=bN(Y);if(Z!==void 0)return Z;if(P1(Y,{checkOpen:!1}))return Pq.nodeStream(Y)}}});var yq=(Y,Z)=>Z&&!Y.includes("ipc")?[...Y,"ipc"]:Y;var fq=({stdio:Y,ipc:Z,buffer:Q,...J},z,K)=>{let X=gN(Y,J).map((H,W)=>bq(H,W));return K?uN(X,Q,z):yq(X,Z)},gN=(Y,Z)=>{if(Y===void 0)return N1.map((J)=>Z[J]);if(mN(Z))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${N1.map((J)=>`\`${J}\``).join(", ")}`);if(typeof Y==="string")return[Y,Y,Y];if(!Array.isArray(Y))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof Y}\``);let Q=Math.max(Y.length,N1.length);return Array.from({length:Q},(J,z)=>Y[z])},mN=(Y)=>N1.some((Z)=>Y[Z]!==void 0),bq=(Y,Z)=>{if(Array.isArray(Y))return Y.map((Q)=>bq(Q,Z));if(Y===null||Y===void 0)return Z>=N1.length?"ignore":"pipe";return Y},uN=(Y,Z,Q)=>Y.map((J,z)=>!Z[z]&&z!==0&&!oY(Q,z)&&dN(J)?"ignore":J),dN=(Y)=>Y==="pipe"||Array.isArray(Y)&&Y.every((Z)=>Z==="pipe");var hq=O(()=>{K6();w6()});import{readFileSync as pN}from"node:fs";import cN from"node:tty";var mq=({stdioItem:Y,stdioItem:{type:Z},isStdioArray:Q,fdNumber:J,direction:z,isSync:K})=>{if(!Q||Z!=="native")return Y;return K?lN({stdioItem:Y,fdNumber:J,direction:z}):aN({stdioItem:Y,fdNumber:J})},lN=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:J,direction:z})=>{let K=nN({value:Z,optionName:Q,fdNumber:J,direction:z});if(K!==void 0)return K;if(P1(Z,{checkOpen:!1}))throw TypeError(`The \`${Q}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return Y},nN=({value:Y,optionName:Z,fdNumber:Q,direction:J})=>{let z=iN(Y,Q);if(z===void 0)return;if(J==="output")return{type:"fileNumber",value:z,optionName:Z};if(cN.isatty(z))throw TypeError(`The \`${Z}: ${M2(Y)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:z6(pN(z)),optionName:Z}},iN=(Y,Z)=>{if(Y==="inherit")return Z;if(typeof Y==="number")return Y;let Q=r8.indexOf(Y);if(Q!==-1)return Q},aN=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:J})=>{if(Z==="inherit")return{type:"nodeStream",value:gq(J,Z,Q),optionName:Q};if(typeof Z==="number")return{type:"nodeStream",value:gq(Z,Z,Q),optionName:Q};if(P1(Z,{checkOpen:!1}))return{type:"nodeStream",value:Z,optionName:Q};return Y},gq=(Y,Z,Q)=>{let J=r8[Y];if(J===void 0)throw TypeError(`The \`${Q}: ${Z}\` option is invalid: no such standard stream.`);return J};var uq=O(()=>{K6();W1();I6()});var dq=({input:Y,inputFile:Z},Q)=>Q===0?[...oN(Y),...rN(Z)]:[],oN=(Y)=>Y===void 0?[]:[{type:sN(Y),value:Y,optionName:"input"}],sN=(Y)=>{if(WY(Y,{checkOpen:!1}))return"nodeStream";if(typeof Y==="string")return"string";if(b0(Y))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},rN=(Y)=>Y===void 0?[]:[{...tN(Y),optionName:"inputFile"}],tN=(Y)=>{if(a2(Y))return{type:"fileUrl",value:Y};if(K3(Y))return{type:"filePath",value:{file:Y}};throw Error("The `inputFile` option must be a file path string or a file URL.")};var pq=O(()=>{W1();Z1()});var cq=(Y)=>Y.filter((Z,Q)=>Y.every((J,z)=>Z.value!==J.value||Q>=z||Z.type==="generator"||Z.type==="asyncGenerator")),lq=({stdioItem:{type:Y,value:Z,optionName:Q},direction:J,fileDescriptors:z,isSync:K})=>{let X=eN(z,Y);if(X.length===0)return;if(K){Y_({otherStdioItems:X,type:Y,value:Z,optionName:Q,direction:J});return}if(Cq.has(Y))return nq({otherStdioItems:X,type:Y,value:Z,optionName:Q,direction:J});if(Aq.has(Y))Q_({otherStdioItems:X,type:Y,value:Z,optionName:Q})},eN=(Y,Z)=>Y.flatMap(({direction:Q,stdioItems:J})=>J.filter((z)=>z.type===Z).map((z)=>({...z,direction:Q}))),Y_=({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})=>{if(H3.has(Z))nq({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})},nq=({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})=>{let K=Y.filter((H)=>Z_(H,Q));if(K.length===0)return;let X=K.find((H)=>H.direction!==z);return iq(X,J,Z),z==="output"?K[0].stream:void 0},Z_=({type:Y,value:Z},Q)=>{if(Y==="filePath")return Z.file===Q.file;if(Y==="fileUrl")return Z.href===Q.href;return Z===Q},Q_=({otherStdioItems:Y,type:Z,value:Q,optionName:J})=>{let z=Y.find(({value:{transform:K}})=>K===Q.transform);iq(z,J,Z)},iq=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Y.optionName}\` and \`${Z}\` options must not target ${A6[Q]} that is the same.`)};var aq=O(()=>{Z1()});var r2=(Y,Z,Q,J)=>{let K=fq(Z,Q,J).map((H,W)=>J_({stdioOption:H,fdNumber:W,options:Z,isSync:J})),X=U_({initialFileDescriptors:K,addProperties:Y,options:Z,isSync:J});return Z.stdio=X.map(({stdioItems:H})=>V_(H)),X},J_=({stdioOption:Y,fdNumber:Z,options:Q,isSync:J})=>{let z=t8(Z),{stdioItems:K,isStdioArray:X}=z_({stdioOption:Y,fdNumber:Z,options:Q,optionName:z}),H=Sq(K,Z,z),W=K.map(($)=>mq({stdioItem:$,isStdioArray:X,fdNumber:Z,direction:H,isSync:J})),q=Eq(W,z,H,Q),G=kq(q,H);return G_(q,G),{direction:H,objectMode:G,stdioItems:q}},z_=({stdioOption:Y,fdNumber:Z,options:Q,optionName:J})=>{let K=[...(Array.isArray(Y)?Y:[Y]).map((W)=>K_(W,J)),...dq(Q,Z)],X=cq(K),H=X.length>1;return X_(X,H,J),W_(X),{stdioItems:X,isStdioArray:H}},K_=(Y,Z)=>({type:Dq(Y,Z),value:Y,optionName:Z}),X_=(Y,Z,Q)=>{if(Y.length===0)throw TypeError(`The \`${Q}\` option must not be an empty array.`);if(!Z)return;for(let{value:J,optionName:z}of Y)if(H_.has(J))throw Error(`The \`${z}\` option must not include \`${J}\`.`)},H_,W_=(Y)=>{for(let Z of Y)q_(Z)},q_=({type:Y,value:Z,optionName:Q})=>{if(wq(Z))throw TypeError(`The \`${Q}: URL\` option must use the \`file:\` scheme.
|
|
76
|
+
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(jq(Y,Z))throw TypeError(`The \`${Q}: { file: '...' }\` option must be used instead of \`${Q}: '...'\`.`)},G_=(Y,Z)=>{if(!Z)return;let Q=Y.find(({type:J})=>s2.has(J));if(Q!==void 0)throw TypeError(`The \`${Q.optionName}\` option cannot use both files and transforms in objectMode.`)},U_=({initialFileDescriptors:Y,addProperties:Z,options:Q,isSync:J})=>{let z=[];try{for(let K of Y)z.push($_({fileDescriptor:K,fileDescriptors:z,addProperties:Z,options:Q,isSync:J}));return z}catch(K){throw $3(z),K}},$_=({fileDescriptor:{direction:Y,objectMode:Z,stdioItems:Q},fileDescriptors:J,addProperties:z,options:K,isSync:X})=>{let H=Q.map((W)=>B_({stdioItem:W,addProperties:z,direction:Y,options:K,fileDescriptors:J,isSync:X}));return{direction:Y,objectMode:Z,stdioItems:H}},B_=({stdioItem:Y,addProperties:Z,direction:Q,options:J,fileDescriptors:z,isSync:K})=>{let X=lq({stdioItem:Y,direction:Q,fileDescriptors:z,isSync:K});if(X!==void 0)return{...Y,stream:X};return{...Y,...Z[Q][Y.type](Y,J)}},$3=(Y)=>{for(let{stdioItems:Z}of Y)for(let{stream:Q}of Z)if(Q!==void 0&&!x1(Q))Q.destroy()},V_=(Y)=>{if(Y.length>1)return Y.some(({value:J})=>J==="overlapped")?"overlapped":"pipe";let[{type:Z,value:Q}]=Y;return Z==="native"?Q:"pipe"};var t2=O(()=>{K6();xq();q3();Z1();vq();hq();uq();pq();aq();H_=new Set(["ignore","ipc"])});import{readFileSync as oq}from"node:fs";var rq=(Y,Z)=>r2(R_,Y,Z,!0),d1=({type:Y,optionName:Z})=>{tq(Z,A6[Y])},F_=({optionName:Y,value:Z})=>{if(Z==="ipc"||Z==="overlapped")tq(Y,`"${Z}"`);return{}},tq=(Y,Z)=>{throw TypeError(`The \`${Y}\` option cannot be ${Z} with synchronous methods.`)},sq,R_;var eq=O(()=>{W1();t2();Z1();sq={generator(){},asyncGenerator:d1,webStream:d1,nodeStream:d1,webTransform:d1,duplex:d1,asyncIterable:d1,native:F_},R_={input:{...sq,fileUrl:({value:Y})=>({contents:[z6(oq(Y))]}),filePath:({value:{file:Y}})=>({contents:[z6(oq(Y))]}),fileNumber:d1,iterable:({value:Y})=>({contents:[...Y]}),string:({value:Y})=>({contents:[Y]}),uint8Array:({value:Y})=>({contents:[Y]})},output:{...sq,fileUrl:({value:Y})=>({path:Y}),filePath:({value:{file:Y,append:Z}})=>({path:Y,append:Z}),fileNumber:({value:Y})=>({path:Y}),iterable:d1,string:d1,uint8Array:d1}}});var G6=(Y,{stripFinalNewline:Z},Q)=>B3(Z,Q)&&Y!==void 0&&!Array.isArray(Y)?J4(Y):Y,B3=(Y,Z)=>Z==="all"?Y[1]||Y[2]:Y[Z];var qZ=O(()=>{sQ()});var e2=(Y,Z,Q,J)=>Y||Q?void 0:ZG(Z,J),F3=(Y,Z,Q)=>Q?Y.flatMap((J)=>YG(J,Z)):YG(Y,Z),YG=(Y,Z)=>{let{transform:Q,final:J}=ZG(Z,{});return[...Q(Y),...J()]},ZG=(Y,Z)=>{return Z.previousChunks="",{transform:O_.bind(void 0,Z,Y),final:D_.bind(void 0,Z)}},O_=function*(Y,Z,Q){if(typeof Q!=="string"){yield Q;return}let{previousChunks:J}=Y,z=-1;for(let K=0;K<Q.length;K+=1)if(Q[K]===`
|
|
77
|
+
`){let X=M_(Q,K,Z,Y),H=Q.slice(z+1,K+1-X);if(J.length>0)H=V3(J,H),J="";yield H,z=K}if(z!==Q.length-1)J=V3(J,Q.slice(z+1));Y.previousChunks=J},M_=(Y,Z,Q,J)=>{if(Q)return 0;return J.isWindowsNewline=Z!==0&&Y[Z-1]==="\r",J.isWindowsNewline?2:1},D_=function*({previousChunks:Y}){if(Y.length>0)yield Y},QG=({binary:Y,preserveNewlines:Z,readableObjectMode:Q,state:J})=>Y||Z||Q?void 0:{transform:N_.bind(void 0,J)},N_=function*({isWindowsNewline:Y=!1},Z){let{unixNewline:Q,windowsNewline:J,LF:z,concatBytes:K}=typeof Z==="string"?__:w_;if(Z.at(-1)===z){yield Z;return}yield K(Z,Y?J:Q)},V3=(Y,Z)=>`${Y}${Z}`,__,L_=(Y,Z)=>{let Q=new Uint8Array(Y.length+Z.length);return Q.set(Y,0),Q.set(Z,Y.length),Q},w_;var Y7=O(()=>{__={windowsNewline:`\r
|
|
78
78
|
`,unixNewline:`
|
|
79
79
|
`,LF:`
|
|
80
|
-
`,concatBytes:
|
|
80
|
+
`,concatBytes:V3},w_={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:L_}});import{Buffer as j_}from"node:buffer";var JG=(Y,Z)=>Y?void 0:T_.bind(void 0,Z),T_=function*(Y,Z){if(typeof Z!=="string"&&!b0(Z)&&!j_.isBuffer(Z))throw TypeError(`The \`${Y}\` option's transform must use "objectMode: true" to receive as input: ${typeof Z}.`);yield Z},zG=(Y,Z)=>Y?I_.bind(void 0,Z):C_.bind(void 0,Z),I_=function*(Y,Z){KG(Y,Z),yield Z},C_=function*(Y,Z){if(KG(Y,Z),typeof Z!=="string"&&!b0(Z))throw TypeError(`The \`${Y}\` option's function must yield a string or an Uint8Array, not ${typeof Z}.`);yield Z},KG=(Y,Z)=>{if(Z===null||Z===void 0)throw TypeError(`The \`${Y}\` option's function must not call \`yield ${Z}\`.
|
|
81
81
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
82
|
-
if (condition) { yield value; }`)};var NG=R(()=>{i0()});import{Buffer as DN}from"node:buffer";import{StringDecoder as NN}from"node:string_decoder";var S7=(Y,Z,Q)=>{if(Q)return;if(Y)return{transform:wN.bind(void 0,new TextEncoder)};let J=new NN(Z);return{transform:LN.bind(void 0,J),final:_N.bind(void 0,J)}},wN=function*(Y,Z){if(DN.isBuffer(Z))yield mY(Z);else if(typeof Z==="string")yield Y.encode(Z);else yield Z},LN=function*(Y,Z){yield L0(Z)?Y.write(Z):Z},_N=function*(Y){let Z=Y.end();if(Z!=="")yield Z};var d3=R(()=>{i0()});import{callbackify as wG}from"node:util";var p3,v7=async function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:J=jN}=Z[Q];for await(let z of J(Y))yield*v7(z,Z,Q+1)},LG=async function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*IN(Q,Number(Z),Y)},IN=async function*(Y,Z,Q){if(Y===void 0)return;for await(let J of Y())yield*v7(J,Q,Z+1)},_G,jN=function*(Y){yield Y};var IG=R(()=>{p3=wG(async(Y,Z,Q,J)=>{Z.currentIterable=Y(...Q);try{for await(let z of Z.currentIterable)J.push(z)}finally{delete Z.currentIterable}}),_G=wG(async({currentIterable:Y},Z)=>{if(Y!==void 0){await(Z?Y.throw(Z):Y.return());return}if(Z)throw Z})});var c3=(Y,Z,Q,J)=>{try{for(let z of Y(...Z))Q.push(z);J()}catch(z){J(z)}},jG=(Y,Z)=>[...Z.flatMap((Q)=>[...r6(Q,Y,0)]),...n8(Y)],r6=function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:J=CN}=Z[Q];for(let z of J(Y))yield*r6(z,Z,Q+1)},n8=function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*TN(Q,Number(Z),Y)},TN=function*(Y,Z,Q){if(Y===void 0)return;for(let J of Y())yield*r6(J,Q,Z+1)},CN=function*(Y){yield Y};import{Transform as kN,getDefaultHighWaterMark as TG}from"node:stream";var l3=({value:Y,value:{transform:Z,final:Q,writableObjectMode:J,readableObjectMode:z},optionName:X},{encoding:H})=>{let W={},K=CG(Y,H,X),$=s6(Z),G=s6(Q),U=$?p3.bind(void 0,v7,W):c3.bind(void 0,r6),B=$||G?p3.bind(void 0,LG,W):c3.bind(void 0,n8),F=$||G?_G.bind(void 0,W):void 0;return{stream:new kN({writableObjectMode:J,writableHighWaterMark:TG(J),readableObjectMode:z,readableHighWaterMark:TG(z),transform(O,N,w){U([O,K,0],this,w)},flush(O){B([K],this,O)},destroy:F})}},y7=(Y,Z,Q,J)=>{let z=Z.filter(({type:H})=>H==="generator"),X=J?z.reverse():z;for(let{value:H,optionName:W}of X){let K=CG(H,Q,W);Y=jG(K,Y)}return Y},CG=({transform:Y,final:Z,binary:Q,writableObjectMode:J,readableObjectMode:z,preserveNewlines:X},H,W)=>{let K={};return[{transform:MG(J,W)},S7(Q,H,J),E7(Q,X,J,K),{transform:Y,final:Z},{transform:OG(z,W)},RG({binary:Q,preserveNewlines:X,readableObjectMode:z,state:K})].filter(Boolean)};var f7=R(()=>{h0();P7();NG();d3();IG()});var kG=(Y,Z)=>{for(let Q of AN(Y))xN(Y,Q,Z)},AN=(Y)=>new Set(Object.entries(Y).filter(([,{direction:Z}])=>Z==="input").map(([Z])=>Number(Z))),xN=(Y,Z,Q)=>{let{stdioItems:J}=Y[Z],z=J.filter(({contents:W})=>W!==void 0);if(z.length===0)return;if(Z!==0){let[{type:W,optionName:K}]=z;throw TypeError(`Only the \`stdin\` option, not \`${K}\`, can be ${U6[W]} with synchronous methods.`)}let H=z.map(({contents:W})=>W).map((W)=>EN(W,J));Q.input=S8(H)},EN=(Y,Z)=>{let Q=y7(Y,Z,"utf8",!0);return PN(Q),S8(Q)},PN=(Y)=>{let Z=Y.find((Q)=>typeof Q!=="string"&&!L0(Q));if(Z!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${Z}.`)};var AG=R(()=>{f7();i0();h0()});var b7=({stdioItems:Y,encoding:Z,verboseInfo:Q,fdNumber:J})=>J!=="all"&&v1(Q,J)&&!a0.has(Z)&&SN(J)&&(Y.some(({type:z,value:X})=>z==="native"&&vN.has(X))||Y.every(({type:z})=>XY.has(z))),SN=(Y)=>Y===1||Y===2,vN,xG=async(Y,Z,Q,J)=>{for await(let z of Y)if(!yN(Z))PG(z,Q,J)},EG=(Y,Z,Q)=>{for(let J of Y)PG(J,Z,Q)},yN=(Y)=>Y._readableState.pipes.length>0,PG=(Y,Z,Q)=>{let J=bZ(Y);DY({type:"output",verboseMessage:J,fdNumber:Z,verboseInfo:Q})};var i3=R(()=>{n6();h0();y1();W6();vN=new Set(["pipe","overlapped"])});import{writeFileSync as fN,appendFileSync as bN}from"node:fs";var SG=({fileDescriptors:Y,syncResult:{output:Z},options:Q,isMaxBuffer:J,verboseInfo:z})=>{if(Z===null)return{output:Array.from({length:3})};let X={},H=new Set([]);return{output:Z.map((K,$)=>hN({result:K,fileDescriptors:Y,fdNumber:$,state:X,outputFiles:H,isMaxBuffer:J,verboseInfo:z},Q)),...X}},hN=({result:Y,fileDescriptors:Z,fdNumber:Q,state:J,outputFiles:z,isMaxBuffer:X,verboseInfo:H},{buffer:W,encoding:K,lines:$,stripFinalNewline:G,maxBuffer:U})=>{if(Y===null)return;let B=NK(Y,X,U),F=mY(B),{stdioItems:V,objectMode:O}=Z[Q],N=gN([F],V,K,J),{serializedResult:w,finalResult:L=w}=mN({chunks:N,objectMode:O,encoding:K,lines:$,stripFinalNewline:G,fdNumber:Q});uN({serializedResult:w,fdNumber:Q,state:J,verboseInfo:H,encoding:K,stdioItems:V,objectMode:O});let I=W[Q]?L:void 0;try{if(J.error===void 0)dN(w,V,z);return I}catch(T){return J.error=T,I}},gN=(Y,Z,Q,J)=>{try{return y7(Y,Z,Q,!1)}catch(z){return J.error=z,Y}},mN=({chunks:Y,objectMode:Z,encoding:Q,lines:J,stripFinalNewline:z,fdNumber:X})=>{if(Z)return{serializedResult:Y};if(Q==="buffer")return{serializedResult:S8(Y)};let H=BX(Y,Q);if(J[X])return{serializedResult:H,finalResult:u3(H,!z[X],Z)};return{serializedResult:H}},uN=({serializedResult:Y,fdNumber:Z,state:Q,verboseInfo:J,encoding:z,stdioItems:X,objectMode:H})=>{if(!b7({stdioItems:X,encoding:z,verboseInfo:J,fdNumber:Z}))return;let W=u3(Y,!1,H);try{EG(W,Z,J)}catch(K){Q.error??=K}},dN=(Y,Z,Q)=>{for(let{path:J,append:z}of Z.filter(({type:X})=>k7.has(X))){let X=typeof J==="string"?J:J.toString();if(z||Q.has(X))bN(J,Y);else Q.add(X),fN(J,Y)}};var vG=R(()=>{i3();f7();P7();i0();h0();o6()});var yG=([,Y,Z],Q)=>{if(!Q.all)return;if(Y===void 0)return Z;if(Z===void 0)return Y;if(Array.isArray(Y))return Array.isArray(Z)?[...Y,...Z]:[...Y,iY(Z,Q,"all")];if(Array.isArray(Z))return[iY(Y,Q,"all"),...Z];if(L0(Y)&&L0(Z))return b5([Y,Z]);return`${Y}${Z}`};var fG=R(()=>{i0();i8()});import{once as n3}from"node:events";var bG=async(Y,Z)=>{let[Q,J]=await pN(Y);return Z.isForcefullyTerminated??=!1,[Q,J]},pN=async(Y)=>{let[Z,Q]=await Promise.allSettled([n3(Y,"spawn"),n3(Y,"exit")]);if(Z.status==="rejected")return[];return Q.status==="rejected"?hG(Y):Q.value},hG=async(Y)=>{try{return await n3(Y,"exit")}catch{return hG(Y)}},gG=async(Y)=>{let[Z,Q]=await Y;if(!cN(Z,Q)&&a3(Z,Q))throw new NY;return[Z,Q]},cN=(Y,Z)=>Y===void 0&&Z===void 0,a3=(Y,Z)=>Y!==0||Z!==null;var o3=R(()=>{K6()});var mG=({error:Y,status:Z,signal:Q,output:J},{maxBuffer:z})=>{let X=lN(Y,Z,Q),H=X?.code==="ETIMEDOUT",W=DK(X,J,z);return{resultError:X,exitCode:Z,signal:Q,timedOut:H,isMaxBuffer:W}},lN=(Y,Z,Q)=>{if(Y!==void 0)return Y;return a3(Z,Q)?new NY:void 0};var uG=R(()=>{K6();o6();o3()});import{spawnSync as iN}from"node:child_process";var dG=(Y,Z,Q)=>{let{file:J,commandArguments:z,command:X,escapedCommand:H,startTime:W,verboseInfo:K,options:$,fileDescriptors:G}=nN(Y,Z,Q),U=sN({file:J,commandArguments:z,options:$,command:X,escapedCommand:H,verboseInfo:K,fileDescriptors:G,startTime:W});return l1(U,K,$)},nN=(Y,Z,Q)=>{let{command:J,escapedCommand:z,startTime:X,verboseInfo:H}=mZ(Y,Z,Q),W=aN(Q),{file:K,commandArguments:$,options:G}=B7(Y,Z,W);oN(G);let U=qG(G,H);return{file:K,commandArguments:$,command:J,escapedCommand:z,startTime:X,verboseInfo:H,options:G,fileDescriptors:U}},aN=(Y)=>Y.node&&!Y.ipc?{...Y,ipc:!1}:Y,oN=({ipc:Y,ipcInput:Z,detached:Q,cancelSignal:J})=>{if(Z)h7("ipcInput");if(Y)h7("ipc: true");if(Q)h7("detached: true");if(J)h7("cancelSignal")},h7=(Y)=>{throw TypeError(`The "${Y}" option cannot be used with synchronous methods.`)},sN=({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,verboseInfo:X,fileDescriptors:H,startTime:W})=>{let K=rN({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,fileDescriptors:H,startTime:W});if(K.failed)return K;let{resultError:$,exitCode:G,signal:U,timedOut:B,isMaxBuffer:F}=mG(K,Q),{output:V,error:O=$}=SG({fileDescriptors:H,syncResult:K,options:Q,isMaxBuffer:F,verboseInfo:X}),N=V.map((L,I)=>iY(L,Q,I)),w=iY(yG(V,Q),Q,"all");return eN({error:O,exitCode:G,signal:U,timedOut:B,isMaxBuffer:F,stdio:N,all:w,options:Q,command:J,escapedCommand:z,startTime:W})},rN=({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,fileDescriptors:X,startTime:H})=>{try{kG(X,Q);let W=tN(Q);return iN(...V7(Y,Z,W))}catch(W){return c1({error:W,command:J,escapedCommand:z,fileDescriptors:X,options:Q,startTime:H,isSync:!0})}},tN=({encoding:Y,maxBuffer:Z,...Q})=>({...Q,encoding:"buffer",maxBuffer:_7(Z)}),eN=({error:Y,exitCode:Z,signal:Q,timedOut:J,isMaxBuffer:z,stdio:X,all:H,options:W,command:K,escapedCommand:$,startTime:G})=>Y===void 0?I7({command:K,escapedCommand:$,stdio:X,all:H,ipcOutput:[],options:W,startTime:G}):c8({error:Y,command:K,escapedCommand:$,timedOut:J,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:z,isForcefullyTerminated:!1,exitCode:Z,signal:Q,stdio:X,all:H,ipcOutput:[],options:W,startTime:G,isSync:!0});var pG=R(()=>{i5();w3();l8();j7();BG();i8();AG();vG();o6();fG();uG()});import{once as s3,on as Yw}from"node:events";var cG=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},{reference:z=!0,filter:X}={})=>{return h1({methodName:"getOneMessage",isSubprocess:Q,ipc:J,isConnected:H7(Y)}),Zw({anyProcess:Y,channel:Z,isSubprocess:Q,filter:X,reference:z})},Zw=async({anyProcess:Y,channel:Z,isSubprocess:Q,filter:J,reference:z})=>{eZ(Z,z);let X=q6(Y,Z,Q),H=new AbortController;try{return await Promise.race([Qw(X,J,H),Jw(X,Q,H),zw(X,Q,H)])}catch(W){throw g1(Y),W}finally{H.abort(),Y7(Z,z)}},Qw=async(Y,Z,{signal:Q})=>{if(Z===void 0){let[J]=await s3(Y,"message",{signal:Q});return J}for await(let[J]of Yw(Y,"message",{signal:Q}))if(Z(J))return J},Jw=async(Y,Z,{signal:Q})=>{await s3(Y,"disconnect",{signal:Q}),JW(Z)},zw=async(Y,Z,{signal:Q})=>{let[J]=await s3(Y,"strict:error",{signal:Q});throw oZ(J,Z)};var lG=R(()=>{m1();g8()});import{once as nG,on as Xw}from"node:events";var aG=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},{reference:z=!0}={})=>r3({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J,shouldAwait:!Q,reference:z}),r3=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J,shouldAwait:z,reference:X})=>{h1({methodName:"getEachMessage",isSubprocess:Q,ipc:J,isConnected:H7(Y)}),eZ(Z,X);let H=q6(Y,Z,Q),W=new AbortController,K={};return Hw(Y,H,W),Ww({ipcEmitter:H,isSubprocess:Q,controller:W,state:K}),Kw({anyProcess:Y,channel:Z,ipcEmitter:H,isSubprocess:Q,shouldAwait:z,controller:W,state:K,reference:X})},Hw=async(Y,Z,Q)=>{try{await nG(Z,"disconnect",{signal:Q.signal}),Q.abort()}catch{}},Ww=async({ipcEmitter:Y,isSubprocess:Z,controller:Q,state:J})=>{try{let[z]=await nG(Y,"strict:error",{signal:Q.signal});J.error=oZ(z,Z),Q.abort()}catch{}},Kw=async function*({anyProcess:Y,channel:Z,ipcEmitter:Q,isSubprocess:J,shouldAwait:z,controller:X,state:H,reference:W}){try{for await(let[K]of Xw(Q,"message",{signal:X.signal}))iG(H),yield K}catch{iG(H)}finally{if(X.abort(),Y7(Z,W),!J)g1(Y);if(z)await Y}},iG=({error:Y})=>{if(Y)throw Y};var t3=R(()=>{m1();g8()});import oG from"node:process";var sG=(Y,{ipc:Z})=>{Object.assign(Y,tG(Y,!1,Z))},rG=()=>{let Y=oG,Z=!0,Q=oG.channel!==void 0;return{...tG(Y,!0,Q),getCancelSignal:EW.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:!0,ipc:Q})}},tG=(Y,Z,Q)=>({sendMessage:$7.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getOneMessage:cG.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getEachMessage:aG.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q})});var e3=R(()=>{q7();lG();t3();z7()});import{ChildProcess as Gw}from"node:child_process";import{PassThrough as $w,Readable as qw,Writable as Uw,Duplex as Bw}from"node:stream";var eG=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:X,verboseInfo:H})=>{h3(J);let W=new Gw;Vw(W,J),Object.assign(W,{readable:Fw,writable:Rw,duplex:Mw});let K=c1({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:X,isSync:!1}),$=Ow(K,H,z);return{subprocess:W,promise:$}},Vw=(Y,Z)=>{let Q=a8(),J=a8(),z=a8(),X=Array.from({length:Z.length-3},a8),H=a8(),W=[Q,J,z,...X];Object.assign(Y,{stdin:Q,stdout:J,stderr:z,all:H,stdio:W})},a8=()=>{let Y=new $w;return Y.end(),Y},Fw=()=>new qw({read(){}}),Rw=()=>new Uw({write(){}}),Mw=()=>new Bw({read(){},write(){}}),Ow=async(Y,Z,Q)=>l1(Y,Z,Q);var Y$=R(()=>{x7();l8();j7()});import{createReadStream as Z$,createWriteStream as Q$}from"node:fs";import{Buffer as Dw}from"node:buffer";import{Readable as o8,Writable as Nw,Duplex as ww}from"node:stream";var z$=(Y,Z)=>A7(Lw,Y,Z,!1),s8=({type:Y,optionName:Z})=>{throw TypeError(`The \`${Z}\` option cannot be ${U6[Y]}.`)},J$,Lw;var X$=R(()=>{f7();x7();h0();J$={fileNumber:s8,generator:l3,asyncGenerator:l3,nodeStream:({value:Y})=>({stream:Y}),webTransform({value:{transform:Y,writableObjectMode:Z,readableObjectMode:Q}}){let J=Z||Q;return{stream:ww.fromWeb(Y,{objectMode:J})}},duplex:({value:{transform:Y}})=>({stream:Y}),native(){}},Lw={input:{...J$,fileUrl:({value:Y})=>({stream:Z$(Y)}),filePath:({value:{file:Y}})=>({stream:Z$(Y)}),webStream:({value:Y})=>({stream:o8.fromWeb(Y)}),iterable:({value:Y})=>({stream:o8.from(Y)}),asyncIterable:({value:Y})=>({stream:o8.from(Y)}),string:({value:Y})=>({stream:o8.from(Y)}),uint8Array:({value:Y})=>({stream:o8.from(Dw.from(Y))})},output:{...J$,fileUrl:({value:Y})=>({stream:Q$(Y)}),filePath:({value:{file:Y,append:Z}})=>({stream:Q$(Y,Z?{flags:"a"}:{})}),webStream:({value:Y})=>({stream:Nw.fromWeb(Y)}),iterable:s8,asyncIterable:s8,string:s8,uint8Array:s8}}});import{on as _w,once as H$}from"node:events";import{PassThrough as Iw,getDefaultHighWaterMark as jw}from"node:stream";import{finished as G$}from"node:stream/promises";function t6(Y){if(!Array.isArray(Y))throw TypeError(`Expected an array, got \`${typeof Y}\`.`);for(let z of Y)YQ(z);let Z=Y.some(({readableObjectMode:z})=>z),Q=Tw(Y,Z),J=new $$({objectMode:Z,writableHighWaterMark:Q,readableHighWaterMark:Q});for(let z of Y)J.add(z);return J}var Tw=(Y,Z)=>{if(Y.length===0)return jw(Z);let Q=Y.filter(({readableObjectMode:J})=>J===Z).map(({readableHighWaterMark:J})=>J);return Math.max(...Q)},$$,Cw=async(Y,Z,Q)=>{g7(Y,W$);let J=new AbortController;try{await Promise.race([kw(Y,J),Aw(Y,Z,Q,J)])}finally{J.abort(),g7(Y,-W$)}},kw=async(Y,{signal:Z})=>{try{await G$(Y,{signal:Z,cleanup:!0})}catch(Q){throw q$(Y,Q),Q}},Aw=async(Y,Z,Q,{signal:J})=>{for await(let[z]of _w(Y,"unpipe",{signal:J}))if(Z.has(z))z.emit(Q)},YQ=(Y)=>{if(typeof Y?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Y}\`.`)},xw=async({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,onFinished:X,unpipeEvent:H})=>{g7(Y,K$);let W=new AbortController;try{await Promise.race([Ew(X,Z,W),Pw({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,controller:W}),Sw({stream:Z,streams:Q,ended:J,aborted:z,unpipeEvent:H,controller:W})])}finally{W.abort(),g7(Y,-K$)}if(Q.size>0&&Q.size===J.size+z.size)if(J.size===0&&z.size>0)ZQ(Y);else vw(Y)},Ew=async(Y,Z,{signal:Q})=>{try{if(await Y,!Q.aborted)ZQ(Z)}catch(J){if(!Q.aborted)q$(Z,J)}},Pw=async({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,controller:{signal:X}})=>{try{if(await G$(Z,{signal:X,cleanup:!0,readable:!0,writable:!1}),Q.has(Z))J.add(Z)}catch(H){if(X.aborted||!Q.has(Z))return;if(U$(H))z.add(Z);else B$(Y,H)}},Sw=async({stream:Y,streams:Z,ended:Q,aborted:J,unpipeEvent:z,controller:{signal:X}})=>{if(await H$(Y,z,{signal:X}),!Y.readable)return H$(X,"abort",{signal:X});Z.delete(Y),Q.delete(Y),J.delete(Y)},vw=(Y)=>{if(Y.writable)Y.end()},q$=(Y,Z)=>{if(U$(Z))ZQ(Y);else B$(Y,Z)},U$=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",ZQ=(Y)=>{if(Y.readable||Y.writable)Y.destroy()},B$=(Y,Z)=>{if(!Y.destroyed)Y.once("error",yw),Y.destroy(Z)},yw=()=>{},g7=(Y,Z)=>{let Q=Y.getMaxListeners();if(Q!==0&&Q!==Number.POSITIVE_INFINITY)Y.setMaxListeners(Q+Z)},W$=2,K$=1;var m7=R(()=>{$$=class $$ extends Iw{#Z=new Set([]);#Q=new Set([]);#Y=new Set([]);#J;#z=Symbol("unpipe");#X=new WeakMap;add(Y){if(YQ(Y),this.#Z.has(Y))return;this.#Z.add(Y),this.#J??=Cw(this,this.#Z,this.#z);let Z=xw({passThroughStream:this,stream:Y,streams:this.#Z,ended:this.#Q,aborted:this.#Y,onFinished:this.#J,unpipeEvent:this.#z});this.#X.set(Y,Z),Y.pipe(this,{end:!1})}async remove(Y){if(YQ(Y),!this.#Z.has(Y))return!1;let Z=this.#X.get(Y);if(Z===void 0)return!1;return this.#X.delete(Y),Y.unpipe(this),await Z,!0}}});import{finished as V$}from"node:stream/promises";var n1=(Y,Z)=>{Y.pipe(Z),fw(Y,Z),bw(Y,Z)},fw=async(Y,Z)=>{if(UY(Y)||UY(Z))return;try{await V$(Y,{cleanup:!0,readable:!0,writable:!1})}catch{}QQ(Z)},QQ=(Y)=>{if(Y.writable)Y.end()},bw=async(Y,Z)=>{if(UY(Y)||UY(Z))return;try{await V$(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}JQ(Y)},JQ=(Y)=>{if(Y.readable)Y.destroy()};var u7=R(()=>{uY()});var F$=(Y,Z,Q)=>{let J=new Map;for(let[z,{stdioItems:X,direction:H}]of Object.entries(Z)){for(let{stream:W}of X.filter(({type:K})=>XY.has(K)))hw(Y,W,H,z);for(let{stream:W}of X.filter(({type:K})=>!XY.has(K)))mw({subprocess:Y,stream:W,direction:H,fdNumber:z,pipeGroups:J,controller:Q})}for(let[z,X]of J.entries()){let H=X.length===1?X[0]:t6(X);n1(H,z)}},hw=(Y,Z,Q,J)=>{if(Q==="output")n1(Y.stdio[J],Z);else n1(Z,Y.stdio[J]);let z=gw[J];if(z!==void 0)Y[z]=Z;Y.stdio[J]=Z},gw,mw=({subprocess:Y,stream:Z,direction:Q,fdNumber:J,pipeGroups:z,controller:X})=>{if(Z===void 0)return;uw(Z,X);let[H,W]=Q==="output"?[Z,Y.stdio[J]]:[Y.stdio[J],Z],K=z.get(H)??[];z.set(H,[...K,W])},uw=(Y,{signal:Z})=>{if(UY(Y))i6(Y,dw,Z)},dw=2;var R$=R(()=>{m7();uY();tZ();h0();u7();gw=["stdin","stdout","stderr"]});var e6;var M$=R(()=>{e6=[];e6.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")e6.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")e6.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class O${emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(XQ[zQ])return XQ[zQ];pw(XQ,zQ,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Y,Z){this.listeners[Y].push(Z)}removeListener(Y,Z){let Q=this.listeners[Y],J=Q.indexOf(Z);if(J===-1)return;if(J===0&&Q.length===1)Q.length=0;else Q.splice(J,1)}emit(Y,Z,Q){if(this.emitted[Y])return!1;this.emitted[Y]=!0;let J=!1;for(let z of this.listeners[Y])J=z(Z,Q)===!0||J;if(Y==="exit")J=this.emit("afterExit",Z,Q)||J;return J}}class WQ{}var d7=(Y)=>!!Y&&typeof Y==="object"&&typeof Y.removeListener==="function"&&typeof Y.emit==="function"&&typeof Y.reallyExit==="function"&&typeof Y.listeners==="function"&&typeof Y.kill==="function"&&typeof Y.pid==="number"&&typeof Y.on==="function",zQ,XQ,pw,cw=(Y)=>{return{onExit(Z,Q){return Y.onExit(Z,Q)},load(){return Y.load()},unload(){return Y.unload()}}},D$,N$,HQ,w$,_f,If;var L$=R(()=>{M$();zQ=Symbol.for("signal-exit emitter"),XQ=globalThis,pw=Object.defineProperty.bind(Object);D$=class D$ extends WQ{onExit(){return()=>{}}load(){}unload(){}};N$=class N$ extends WQ{#Z=HQ.platform==="win32"?"SIGINT":"SIGHUP";#Q=new O$;#Y;#J;#z;#X={};#H=!1;constructor(Y){super();this.#Y=Y,this.#X={};for(let Z of e6)this.#X[Z]=()=>{let Q=this.#Y.listeners(Z),{count:J}=this.#Q,z=Y;if(typeof z.__signal_exit_emitter__==="object"&&typeof z.__signal_exit_emitter__.count==="number")J+=z.__signal_exit_emitter__.count;if(Q.length===J){this.unload();let X=this.#Q.emit("exit",null,Z),H=Z==="SIGHUP"?this.#Z:Z;if(!X)Y.kill(Y.pid,H)}};this.#z=Y.reallyExit,this.#J=Y.emit}onExit(Y,Z){if(!d7(this.#Y))return()=>{};if(this.#H===!1)this.load();let Q=Z?.alwaysLast?"afterExit":"exit";return this.#Q.on(Q,Y),()=>{if(this.#Q.removeListener(Q,Y),this.#Q.listeners.exit.length===0&&this.#Q.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#Q.count+=1;for(let Y of e6)try{let Z=this.#X[Y];if(Z)this.#Y.on(Y,Z)}catch(Z){}this.#Y.emit=(Y,...Z)=>{return this.#K(Y,...Z)},this.#Y.reallyExit=(Y)=>{return this.#W(Y)}}unload(){if(!this.#H)return;this.#H=!1,e6.forEach((Y)=>{let Z=this.#X[Y];if(!Z)throw Error("Listener not defined for signal: "+Y);try{this.#Y.removeListener(Y,Z)}catch(Q){}}),this.#Y.emit=this.#J,this.#Y.reallyExit=this.#z,this.#Q.count-=1}#W(Y){if(!d7(this.#Y))return 0;return this.#Y.exitCode=Y||0,this.#Q.emit("exit",this.#Y.exitCode,null),this.#z.call(this.#Y,this.#Y.exitCode)}#K(Y,...Z){let Q=this.#J;if(Y==="exit"&&d7(this.#Y)){if(typeof Z[0]==="number")this.#Y.exitCode=Z[0];let J=Q.call(this.#Y,Y,...Z);return this.#Q.emit("exit",this.#Y.exitCode,null),J}else return Q.call(this.#Y,Y,...Z)}};HQ=globalThis.process,{onExit:w$,load:_f,unload:If}=cw(d7(HQ)?new N$(HQ):new D$)});import{addAbortListener as lw}from"node:events";var _$=(Y,{cleanup:Z,detached:Q},{signal:J})=>{if(!Z||Q)return;let z=w$(()=>{Y.kill()});lw(J,()=>{z()})};var I$=R(()=>{L$()});var T$=({source:Y,sourcePromise:Z,boundOptions:Q,createNested:J},...z)=>{let X=hZ(),{destination:H,destinationStream:W,destinationError:K,from:$,unpipeSignal:G}=iw(Q,J,z),{sourceStream:U,sourceError:B}=aw(Y,$),{options:F,fileDescriptors:V}=LY.get(Y);return{sourcePromise:Z,sourceStream:U,sourceOptions:F,sourceError:B,destination:H,destinationStream:W,destinationError:K,unpipeSignal:G,fileDescriptors:V,startTime:X}},iw=(Y,Z,Q)=>{try{let{destination:J,pipeOptions:{from:z,to:X,unpipeSignal:H}={}}=nw(Y,Z,...Q),W=rZ(J,X);return{destination:J,destinationStream:W,from:z,unpipeSignal:H}}catch(J){return{destinationError:J}}},nw=(Y,Z,Q,...J)=>{if(Array.isArray(Q))return{destination:Z(j$,Y)(Q,...J),pipeOptions:Y};if(typeof Q==="string"||Q instanceof URL||v5(Q)){if(Object.keys(Y).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[z,X,H]=CZ(Q,...J);return{destination:Z(j$)(z,X,H),pipeOptions:H}}if(LY.has(Q)){if(Object.keys(Y).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:Q,pipeOptions:J[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${Q}`)},j$=({options:Y})=>({options:{...Y,stdin:"pipe",piped:!0}}),aw=(Y,Z)=>{try{return{sourceStream:u1(Y,Z)}}catch(Q){return{sourceError:Q}}};var C$=R(()=>{f5();gZ();$6();P1()});var A$=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J,fileDescriptors:z,sourceOptions:X,startTime:H})=>{let W=ow({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J});if(W!==void 0)throw KQ({error:W,fileDescriptors:z,sourceOptions:X,startTime:H})},ow=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J})=>{if(Z!==void 0&&J!==void 0)return J;if(J!==void 0)return JQ(Y),J;if(Z!==void 0)return QQ(Q),Z},KQ=({error:Y,fileDescriptors:Z,sourceOptions:Q,startTime:J})=>c1({error:Y,command:k$,escapedCommand:k$,fileDescriptors:Z,options:Q,startTime:J,isSync:!1}),k$="source.pipe(destination)";var GQ=R(()=>{l8();u7()});var x$=async(Y)=>{let[{status:Z,reason:Q,value:J=Q},{status:z,reason:X,value:H=X}]=await Y;if(!H.pipedFrom.includes(J))H.pipedFrom.push(J);if(z==="rejected")throw H;if(Z==="rejected")throw J;return H};import{finished as sw}from"node:stream/promises";var E$=(Y,Z,Q)=>{let J=p7.has(Z)?tw(Y,Z):rw(Y,Z);return i6(Y,YL,Q.signal),i6(Z,ZL,Q.signal),ew(Z),J},rw=(Y,Z)=>{let Q=t6([Y]);return n1(Q,Z),p7.set(Z,Q),Q},tw=(Y,Z)=>{let Q=p7.get(Z);return Q.add(Y),Q},ew=async(Y)=>{try{await sw(Y,{cleanup:!0,readable:!1,writable:!0})}catch{}p7.delete(Y)},p7,YL=2,ZL=1;var P$=R(()=>{m7();tZ();u7();p7=new WeakMap});import{aborted as QL}from"node:util";var S$=(Y,Z)=>Y===void 0?[]:[JL(Y,Z)],JL=async(Y,{sourceStream:Z,mergedStream:Q,fileDescriptors:J,sourceOptions:z,startTime:X})=>{await QL(Y,Z),await Q.remove(Z);let H=Error("Pipe canceled by `unpipeSignal` option.");throw KQ({error:H,fileDescriptors:J,sourceOptions:z,startTime:X})};var v$=R(()=>{GQ()});var c7=(Y,...Z)=>{if(F0(Z[0]))return c7.bind(void 0,{...Y,boundOptions:{...Y.boundOptions,...Z[0]}});let{destination:Q,...J}=T$(Y,...Z),z=zL({...J,destination:Q});return z.pipe=c7.bind(void 0,{...Y,source:Q,sourcePromise:z,boundOptions:{}}),z},zL=async({sourcePromise:Y,sourceStream:Z,sourceOptions:Q,sourceError:J,destination:z,destinationStream:X,destinationError:H,unpipeSignal:W,fileDescriptors:K,startTime:$})=>{let G=XL(Y,z);A$({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:H,fileDescriptors:K,sourceOptions:Q,startTime:$});let U=new AbortController;try{let B=E$(Z,X,U);return await Promise.race([x$(G),...S$(W,{sourceStream:Z,mergedStream:B,sourceOptions:Q,fileDescriptors:K,startTime:$})])}finally{U.abort()}},XL=(Y,Z)=>Promise.allSettled([Y,Z]);var y$=R(()=>{C$();GQ();P$();v$()});import{on as HL}from"node:events";import{getDefaultHighWaterMark as WL}from"node:stream";var l7=({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:J,encoding:z,preserveNewlines:X})=>{let H=new AbortController;return KL(Z,H),b$({stream:Y,controller:H,binary:Q,shouldEncode:!Y.readableObjectMode&&J,encoding:z,shouldSplit:!Y.readableObjectMode,preserveNewlines:X})},KL=async(Y,Z)=>{try{await Y}catch{}finally{Z.abort()}},$Q=({stream:Y,onStreamEnd:Z,lines:Q,encoding:J,stripFinalNewline:z,allMixed:X})=>{let H=new AbortController;GL(Z,H,Y);let W=Y.readableObjectMode&&!X;return b$({stream:Y,controller:H,binary:J==="buffer",shouldEncode:!W,encoding:J,shouldSplit:!W&&Q,preserveNewlines:!z})},GL=async(Y,Z,Q)=>{try{await Y}catch{Q.destroy()}finally{Z.abort()}},b$=({stream:Y,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H})=>{let W=HL(Y,"data",{signal:Z.signal,highWaterMark:f$,highWatermark:f$});return $L({onStdoutChunk:W,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H})},qQ,f$,$L=async function*({onStdoutChunk:Y,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H}){let W=qL({binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H});try{for await(let[K]of Y)yield*r6(K,W,0)}catch(K){if(!Z.signal.aborted)throw K}finally{yield*n8(W)}},qL=({binary:Y,shouldEncode:Z,encoding:Q,shouldSplit:J,preserveNewlines:z})=>[S7(Y,Q,!Z),E7(Y,z,!J,{})].filter(Boolean);var i7=R(()=>{d3();P7();qQ=WL(!0),f$=qQ});import{setImmediate as UL}from"node:timers/promises";var h$=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,buffer:z,maxBuffer:X,lines:H,allMixed:W,stripFinalNewline:K,verboseInfo:$,streamInfo:G})=>{let U=BL({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,allMixed:W,verboseInfo:$,streamInfo:G});if(!z){await Promise.all([VL(Y),U]);return}let B=g3(K,Q),F=$Q({stream:Y,onStreamEnd:Z,lines:H,encoding:J,stripFinalNewline:B,allMixed:W}),[V]=await Promise.all([FL({stream:Y,iterable:F,fdNumber:Q,encoding:J,maxBuffer:X,lines:H}),U]);return V},BL=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,allMixed:z,verboseInfo:X,streamInfo:{fileDescriptors:H}})=>{if(!b7({stdioItems:H[Q]?.stdioItems,encoding:J,verboseInfo:X,fdNumber:Q}))return;let W=$Q({stream:Y,onStreamEnd:Z,lines:!0,encoding:J,stripFinalNewline:!0,allMixed:z});await xG(W,Y,Q,X)},VL=async(Y)=>{if(await UL(),Y.readableFlowing===null)Y.resume()},FL=async({stream:Y,stream:{readableObjectMode:Z},iterable:Q,fdNumber:J,encoding:z,maxBuffer:X,lines:H})=>{try{if(Z||H)return await O7(Q,{maxBuffer:X});if(z==="buffer")return new Uint8Array(await D7(Q,{maxBuffer:X}));return await w7(Q,{maxBuffer:X})}catch(W){return g$(RK({error:W,stream:Y,readableObjectMode:Z,lines:H,encoding:z,fdNumber:J}))}},UQ=async(Y)=>{try{return await Y}catch(Z){return g$(Z)}},g$=({bufferedData:Y})=>qX(Y)?new Uint8Array(Y):Y;var BQ=R(()=>{L7();i0();i3();i7();o6();i8()});import{finished as RL}from"node:stream/promises";var r8=async(Y,Z,Q,{isSameDirection:J,stopOnExit:z=!1}={})=>{let X=ML(Y,Q),H=new AbortController;try{await Promise.race([...z?[Q.exitPromise]:[],RL(Y,{cleanup:!0,signal:H.signal})])}catch(W){if(!X.stdinCleanedUp)NL(W,Z,Q,J)}finally{H.abort()}},ML=(Y,{originalStreams:[Z],subprocess:Q})=>{let J={stdinCleanedUp:!1};if(Y===Z)OL(Y,Q,J);return J},OL=(Y,Z,Q)=>{let{_destroy:J}=Y;Y._destroy=(...z)=>{DL(Z,Q),J.call(Y,...z)}},DL=({exitCode:Y,signalCode:Z},Q)=>{if(Y!==null||Z!==null)Q.stdinCleanedUp=!0},NL=(Y,Z,Q,J)=>{if(!wL(Y,Z,Q,J))throw Y},wL=(Y,Z,Q,J=!0)=>{if(Q.propagating)return m$(Y)||n7(Y);return Q.propagating=!0,VQ(Q,Z)===J?m$(Y):n7(Y)},VQ=({fileDescriptors:Y},Z)=>Z!=="all"&&Y[Z].direction==="input",n7=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",m$=(Y)=>Y?.code==="EPIPE";var a7=()=>{};var u$=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:X,verboseInfo:H,streamInfo:W})=>Y.stdio.map((K,$)=>FQ({stream:K,fdNumber:$,encoding:Z,buffer:Q[$],maxBuffer:J[$],lines:z[$],allMixed:!1,stripFinalNewline:X,verboseInfo:H,streamInfo:W})),FQ=async({stream:Y,fdNumber:Z,encoding:Q,buffer:J,maxBuffer:z,lines:X,allMixed:H,stripFinalNewline:W,verboseInfo:K,streamInfo:$})=>{if(!Y)return;let G=r8(Y,Z,$);if(VQ($,Z)){await G;return}let[U]=await Promise.all([h$({stream:Y,onStreamEnd:G,fdNumber:Z,encoding:Q,buffer:J,maxBuffer:z,lines:X,allMixed:H,stripFinalNewline:W,verboseInfo:K,streamInfo:$}),G]);return U};var RQ=R(()=>{BQ();a7()});var d$=({stdout:Y,stderr:Z},{all:Q})=>Q&&(Y||Z)?t6([Y,Z].filter(Boolean)):void 0,p$=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:X,verboseInfo:H,streamInfo:W})=>FQ({...LL(Y,Q),fdNumber:"all",encoding:Z,maxBuffer:J[1]+J[2],lines:z[1]||z[2],allMixed:_L(Y),stripFinalNewline:X,verboseInfo:H,streamInfo:W}),LL=({stdout:Y,stderr:Z,all:Q},[,J,z])=>{let X=J||z;if(!X)return{stream:Q,buffer:X};if(!J)return{stream:Z,buffer:X};if(!z)return{stream:Y,buffer:X};return{stream:Q,buffer:X}},_L=({all:Y,stdout:Z,stderr:Q})=>Y&&Z&&Q&&Z.readableObjectMode!==Q.readableObjectMode;var MQ=R(()=>{m7();RQ()});var c$=(Y)=>v1(Y,"ipc"),l$=(Y,Z)=>{let Q=bZ(Y);DY({type:"ipc",verboseMessage:Q,fdNumber:"ipc",verboseInfo:Z})};var i$=R(()=>{y1();W6()});var n$=async({subprocess:Y,buffer:Z,maxBuffer:Q,ipc:J,ipcOutput:z,verboseInfo:X})=>{if(!J)return z;let H=c$(X),W=dY(Z,"ipc"),K=dY(Q,"ipc");for await(let $ of r3({anyProcess:Y,channel:Y.channel,isSubprocess:!1,ipc:J,shouldAwait:!1,reference:!0})){if(W)MK(Y,z,K),z.push($);if(H)l$($,X)}return z},a$=async(Y,Z)=>{return await Promise.allSettled([Y]),Z};var o$=R(()=>{o6();i$();pY();t3()});import{once as IL}from"node:events";var s$=async({subprocess:Y,options:{encoding:Z,buffer:Q,maxBuffer:J,lines:z,timeoutDuration:X,cancelSignal:H,gracefulCancel:W,forceKillAfterDelay:K,stripFinalNewline:$,ipc:G,ipcInput:U},context:B,verboseInfo:F,fileDescriptors:V,originalStreams:O,onInternalError:N,controller:w})=>{let L=bG(Y,B),I={originalStreams:O,fileDescriptors:V,subprocess:Y,exitPromise:L,propagating:!1},T=u$({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:$,verboseInfo:F,streamInfo:I}),y=p$({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:$,verboseInfo:F,streamInfo:I}),E=[],P=n$({subprocess:Y,buffer:Q,maxBuffer:J,ipc:G,ipcOutput:E,verboseInfo:F}),m=jL(O,Y,I),g=TL(V,I);try{return await Promise.race([Promise.all([{},gG(L),Promise.all(T),y,P,uW(Y,U),...m,...g]),N,CL(Y,w),...fW(Y,X,B,w),...QW({subprocess:Y,cancelSignal:H,gracefulCancel:W,context:B,controller:w}),...vW({subprocess:Y,cancelSignal:H,gracefulCancel:W,forceKillAfterDelay:K,context:B,controller:w})])}catch(b){return B.terminationReason??="other",Promise.all([{error:b},L,Promise.all(T.map((c)=>UQ(c))),UQ(y),a$(P,E),Promise.allSettled(m),Promise.allSettled(g)])}},jL=(Y,Z,Q)=>Y.map((J,z)=>J===Z.stdio[z]?void 0:r8(J,z,Q)),TL=(Y,Z)=>Y.flatMap(({stdioItems:Q},J)=>Q.filter(({value:z,stream:X=z})=>VY(X,{checkOpen:!1})&&!UY(X)).map(({type:z,value:X,stream:H=X})=>r8(H,J,Z,{isSameDirection:XY.has(z),stopOnExit:z==="native"}))),CL=async(Y,{signal:Z})=>{let[Q]=await IL(Y,"error",{signal:Z});throw Q};var r$=R(()=>{R3();W3();F3();uY();h0();BQ();o$();O3();MQ();RQ();o3();a7()});var t$=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),t8=(Y,Z,Q)=>{let J=Y[Q];if(!J.has(Z))J.set(Z,[]);let z=J.get(Z),X=wY();return z.push(X),{resolve:X.resolve.bind(X),promises:z}},a1=async({resolve:Y,promises:Z},Q)=>{Y();let[J]=await Promise.race([Promise.allSettled([!0,Q]),Promise.all([!1,...Z])]);return!J};var o7=()=>{};import{finished as e$}from"node:stream/promises";var OQ=async(Y)=>{if(Y===void 0)return;try{await DQ(Y)}catch{}},Yq=async(Y)=>{if(Y===void 0)return;try{await NQ(Y)}catch{}},DQ=async(Y)=>{await e$(Y,{cleanup:!0,readable:!1,writable:!0})},NQ=async(Y)=>{await e$(Y,{cleanup:!0,readable:!0,writable:!1})},s7=async(Y,Z)=>{if(await Y,Z)throw Z},r7=(Y,Z,Q)=>{if(Q&&!n7(Q))Y.destroy(Q);else if(Z)Y.destroy()};var wQ=R(()=>{a7()});import{Readable as kL}from"node:stream";import{callbackify as AL}from"node:util";var Zq=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:J,binary:z=!0,preserveNewlines:X=!0}={})=>{let H=z||a0.has(Q),{subprocessStdout:W,waitReadableDestroy:K}=LQ(Y,J,Z),{readableEncoding:$,readableObjectMode:G,readableHighWaterMark:U}=_Q(W,H),{read:B,onStdoutDataDone:F}=IQ({subprocessStdout:W,subprocess:Y,binary:H,encoding:Q,preserveNewlines:X}),V=new kL({read:B,destroy:AL(TQ.bind(void 0,{subprocessStdout:W,subprocess:Y,waitReadableDestroy:K})),highWaterMark:U,objectMode:G,encoding:$});return jQ({subprocessStdout:W,onStdoutDataDone:F,readable:V,subprocess:Y}),V},LQ=(Y,Z,Q)=>{let J=u1(Y,Z),z=t8(Q,J,"readableDestroy");return{subprocessStdout:J,waitReadableDestroy:z}},_Q=({readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q},J)=>J?{readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q}:{readableEncoding:Y,readableObjectMode:!0,readableHighWaterMark:qQ},IQ=({subprocessStdout:Y,subprocess:Z,binary:Q,encoding:J,preserveNewlines:z})=>{let X=wY(),H=l7({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:!Q,encoding:J,preserveNewlines:z});return{read(){xL(this,H,X)},onStdoutDataDone:X}},xL=async(Y,Z,Q)=>{try{let{value:J,done:z}=await Z.next();if(z)Q.resolve();else Y.push(J)}catch{}},jQ=async({subprocessStdout:Y,onStdoutDataDone:Z,readable:Q,subprocess:J,subprocessStdin:z})=>{try{if(await NQ(Y),await J,await OQ(z),await Z,Q.readable)Q.push(null)}catch(X){await OQ(z),Qq(Q,X)}},TQ=async({subprocessStdout:Y,subprocess:Z,waitReadableDestroy:Q},J)=>{if(await a1(Q,Z))Qq(Y,J),await s7(Z,J)},Qq=(Y,Z)=>{r7(Y,Y.readable,Z)};var CQ=R(()=>{n6();$6();i7();o7();wQ()});import{Writable as EL}from"node:stream";import{callbackify as Jq}from"node:util";var zq=({subprocess:Y,concurrentStreams:Z},{to:Q}={})=>{let{subprocessStdin:J,waitWritableFinal:z,waitWritableDestroy:X}=kQ(Y,Q,Z),H=new EL({...AQ(J,Y,z),destroy:Jq(EQ.bind(void 0,{subprocessStdin:J,subprocess:Y,waitWritableFinal:z,waitWritableDestroy:X})),highWaterMark:J.writableHighWaterMark,objectMode:J.writableObjectMode});return xQ(J,H),H},kQ=(Y,Z,Q)=>{let J=rZ(Y,Z),z=t8(Q,J,"writableFinal"),X=t8(Q,J,"writableDestroy");return{subprocessStdin:J,waitWritableFinal:z,waitWritableDestroy:X}},AQ=(Y,Z,Q)=>({write:PL.bind(void 0,Y),final:Jq(SL.bind(void 0,Y,Z,Q))}),PL=(Y,Z,Q,J)=>{if(Y.write(Z,Q))J();else Y.once("drain",J)},SL=async(Y,Z,Q)=>{if(await a1(Q,Z)){if(Y.writable)Y.end();await Z}},xQ=async(Y,Z,Q)=>{try{if(await DQ(Y),Z.writable)Z.end()}catch(J){await Yq(Q),Xq(Z,J)}},EQ=async({subprocessStdin:Y,subprocess:Z,waitWritableFinal:Q,waitWritableDestroy:J},z)=>{if(await a1(Q,Z),await a1(J,Z))Xq(Y,z),await s7(Z,z)},Xq=(Y,Z)=>{r7(Y,Y.writable,Z)};var PQ=R(()=>{$6();o7();wQ()});import{Duplex as vL}from"node:stream";import{callbackify as yL}from"node:util";var Hq=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:J,to:z,binary:X=!0,preserveNewlines:H=!0}={})=>{let W=X||a0.has(Q),{subprocessStdout:K,waitReadableDestroy:$}=LQ(Y,J,Z),{subprocessStdin:G,waitWritableFinal:U,waitWritableDestroy:B}=kQ(Y,z,Z),{readableEncoding:F,readableObjectMode:V,readableHighWaterMark:O}=_Q(K,W),{read:N,onStdoutDataDone:w}=IQ({subprocessStdout:K,subprocess:Y,binary:W,encoding:Q,preserveNewlines:H}),L=new vL({read:N,...AQ(G,Y,U),destroy:yL(fL.bind(void 0,{subprocessStdout:K,subprocessStdin:G,subprocess:Y,waitReadableDestroy:$,waitWritableFinal:U,waitWritableDestroy:B})),readableHighWaterMark:O,writableHighWaterMark:G.writableHighWaterMark,readableObjectMode:V,writableObjectMode:G.writableObjectMode,encoding:F});return jQ({subprocessStdout:K,onStdoutDataDone:w,readable:L,subprocess:Y,subprocessStdin:G}),xQ(G,L,K),L},fL=async({subprocessStdout:Y,subprocessStdin:Z,subprocess:Q,waitReadableDestroy:J,waitWritableFinal:z,waitWritableDestroy:X},H)=>{await Promise.all([TQ({subprocessStdout:Y,subprocess:Q,waitReadableDestroy:J},H),EQ({subprocessStdin:Z,subprocess:Q,waitWritableFinal:z,waitWritableDestroy:X},H)])};var Wq=R(()=>{n6();CQ();PQ()});var SQ=(Y,Z,{from:Q,binary:J=!1,preserveNewlines:z=!1}={})=>{let X=J||a0.has(Z),H=u1(Y,Q),W=l7({subprocessStdout:H,subprocess:Y,binary:X,shouldEncode:!0,encoding:Z,preserveNewlines:z});return bL(W,H,Y)},bL=async function*(Y,Z,Q){try{yield*Y}finally{if(Z.readable)Z.destroy();await Q}};var Kq=R(()=>{n6();$6();i7()});var Gq=(Y,{encoding:Z})=>{let Q=t$();Y.readable=Zq.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.writable=zq.bind(void 0,{subprocess:Y,concurrentStreams:Q}),Y.duplex=Hq.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.iterable=SQ.bind(void 0,Y,Z),Y[Symbol.asyncIterator]=SQ.bind(void 0,Y,Z,{})};var $q=R(()=>{o7();CQ();PQ();Wq();Kq()});var qq=(Y,Z)=>{for(let[Q,J]of gL){let z=J.value.bind(Z);Reflect.defineProperty(Y,Q,{...J,value:z})}},hL,gL;var Uq=R(()=>{hL=(async()=>{})().constructor.prototype,gL=["then","catch","finally"].map((Y)=>[Y,Reflect.getOwnPropertyDescriptor(hL,Y)])});import{setMaxListeners as mL}from"node:events";import{spawn as uL}from"node:child_process";var Bq=(Y,Z,Q,J)=>{let{file:z,commandArguments:X,command:H,escapedCommand:W,startTime:K,verboseInfo:$,options:G,fileDescriptors:U}=dL(Y,Z,Q),{subprocess:B,promise:F}=cL({file:z,commandArguments:X,options:G,startTime:K,verboseInfo:$,command:H,escapedCommand:W,fileDescriptors:U});return B.pipe=c7.bind(void 0,{source:B,sourcePromise:F,boundOptions:{},createNested:J}),qq(B,F),LY.set(B,{options:G,fileDescriptors:U}),B},dL=(Y,Z,Q)=>{let{command:J,escapedCommand:z,startTime:X,verboseInfo:H}=mZ(Y,Z,Q),{file:W,commandArguments:K,options:$}=B7(Y,Z,Q),G=pL($),U=z$(G,H);return{file:W,commandArguments:K,command:J,escapedCommand:z,startTime:X,verboseInfo:H,options:G,fileDescriptors:U}},pL=({timeout:Y,signal:Z,...Q})=>{if(Z!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...Q,timeoutDuration:Y}},cL=({file:Y,commandArguments:Z,options:Q,startTime:J,verboseInfo:z,command:X,escapedCommand:H,fileDescriptors:W})=>{let K;try{K=uL(...V7(Y,Z,Q))}catch(V){return eG({error:V,command:X,escapedCommand:H,fileDescriptors:W,options:Q,startTime:J,verboseInfo:z})}let $=new AbortController;mL(Number.POSITIVE_INFINITY,$.signal);let G=[...K.stdio];F$(K,W,$),_$(K,Q,$);let U={},B=wY();K.kill=YW.bind(void 0,{kill:K.kill.bind(K),options:Q,onInternalError:B,context:U,controller:$}),K.all=d$(K,Q),Gq(K,Q),sG(K,Q);let F=lL({subprocess:K,options:Q,startTime:J,verboseInfo:z,fileDescriptors:W,originalStreams:G,command:X,escapedCommand:H,context:U,onInternalError:B,controller:$});return{subprocess:K,promise:F}},lL=async({subprocess:Y,options:Z,startTime:Q,verboseInfo:J,fileDescriptors:z,originalStreams:X,command:H,escapedCommand:W,context:K,onInternalError:$,controller:G})=>{let[U,[B,F],V,O,N]=await s$({subprocess:Y,options:Z,context:K,verboseInfo:J,fileDescriptors:z,originalStreams:X,onInternalError:$,controller:G});G.abort(),$.resolve();let w=V.map((T,y)=>iY(T,Z,y)),L=iY(O,Z,"all"),I=iL({errorInfo:U,exitCode:B,signal:F,stdio:w,all:L,ipcOutput:N,context:K,options:Z,command:H,escapedCommand:W,startTime:Q});return l1(I,J,Z)},iL=({errorInfo:Y,exitCode:Z,signal:Q,stdio:J,all:z,ipcOutput:X,context:H,options:W,command:K,escapedCommand:$,startTime:G})=>("error"in Y)?c8({error:Y.error,command:K,escapedCommand:$,timedOut:H.terminationReason==="timeout",isCanceled:H.terminationReason==="cancel"||H.terminationReason==="gracefulCancel",isGracefullyCanceled:H.terminationReason==="gracefulCancel",isMaxBuffer:Y.error instanceof cY,isForcefullyTerminated:H.isForcefullyTerminated,exitCode:Z,signal:Q,stdio:J,all:z,ipcOutput:X,options:W,startTime:G,isSync:!1}):I7({command:K,escapedCommand:$,stdio:J,all:z,ipcOutput:X,options:W,startTime:G});var Vq=R(()=>{L7();i5();w3();$6();e3();l8();j7();Y$();X$();i8();R$();nZ();I$();y$();MQ();r$();$q();Uq()});var t7=(Y,Z)=>{let Q=Object.fromEntries(Object.entries(Z).map(([J,z])=>[J,nL(J,Y[J],z)]));return{...Y,...Q}},nL=(Y,Z,Q)=>{if(aL.has(Y)&&F0(Z)&&F0(Q))return{...Z,...Q};return Q},aL;var Fq=R(()=>{pY();aL=new Set(["env",...u5])});var B6=(Y,Z,Q,J)=>{let z=(H,W,K)=>B6(H,W,Q,K),X=(...H)=>oL({mapArguments:Y,deepOptions:Q,boundOptions:Z,setBoundExeca:J,createNested:z},...H);if(J!==void 0)J(X,z,Z);return X},oL=({mapArguments:Y,deepOptions:Z={},boundOptions:Q={},setBoundExeca:J,createNested:z},X,...H)=>{if(F0(X))return z(Y,t7(Q,X),J);let{file:W,commandArguments:K,options:$,isSync:G}=sL({mapArguments:Y,firstArgument:X,nextArguments:H,deepOptions:Z,boundOptions:Q});return G?dG(W,K,$):Bq(W,K,$,z)},sL=({mapArguments:Y,firstArgument:Z,nextArguments:Q,deepOptions:J,boundOptions:z})=>{let X=MX(Z)?OX(Z,Q):[Z,...Q],[H,W,K]=CZ(...X),$=t7(t7(J,z),K),{file:G=H,commandArguments:U=W,options:B=$,isSync:F=!1}=Y({file:H,commandArguments:W,options:$});return{file:G,commandArguments:U,options:B,isSync:F}};var Rq=R(()=>{f5();DX();pG();Vq();Fq()});var Mq=({file:Y,commandArguments:Z})=>Dq(Y,Z),Oq=({file:Y,commandArguments:Z})=>({...Dq(Y,Z),isSync:!0}),Dq=(Y,Z)=>{if(Z.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Y} ${Z}.`);let[Q,...J]=rL(Y);return{file:Q,commandArguments:J}},rL=(Y)=>{if(typeof Y!=="string")throw TypeError(`The command must be a string: ${String(Y)}.`);let Z=Y.trim();if(Z==="")return[];let Q=[];for(let J of Z.split(tL)){let z=Q.at(-1);if(z&&z.endsWith("\\"))Q[Q.length-1]=`${z.slice(0,-1)} ${J}`;else Q.push(J)}return Q},tL;var Nq=R(()=>{tL=/ +/g});var wq=(Y,Z,Q)=>{Y.sync=Z(eL,Q),Y.s=Y.sync},Lq=({options:Y})=>_q(Y),eL=({options:Y})=>({..._q(Y),isSync:!0}),_q=(Y)=>({options:{...Y_(Y),...Y}}),Y_=({input:Y,inputFile:Z,stdio:Q})=>Y===void 0&&Z===void 0&&Q===void 0?{stdin:"inherit"}:{},Iq;var jq=R(()=>{Iq={preferLocal:!0}});var IY,Vg,Fg,Rg,Mg,Og,Dg,Ng,wg,Lg;var e8=R(()=>{Rq();Nq();M3();jq();e3();K6();IY=B6(()=>({})),Vg=B6(()=>({isSync:!0})),Fg=B6(Mq),Rg=B6(Oq),Mg=B6(hW),Og=B6(Lq,{},Iq,wq),{sendMessage:Dg,getOneMessage:Ng,getEachMessage:wg,getCancelSignal:Lg}=rG()});function Z_(Y,Z){let Q=Y.slice(0,Z).split(/\r\n|\n|\r/g);return[Q.length,Q.pop().length+1]}function Q_(Y,Z,Q){let J=Y.split(/\r\n|\n|\r/g),z="",X=(Math.log10(Z+1)|0)+1;for(let H=Z-1;H<=Z+1;H++){let W=J[H-1];if(!W)continue;if(z+=H.toString().padEnd(X," "),z+=": ",z+=W,z+=`
|
|
83
|
-
`,
|
|
84
|
-
`}return z}var
|
|
82
|
+
if (condition) { yield value; }`)};var XG=O(()=>{W1()});import{Buffer as A_}from"node:buffer";import{StringDecoder as k_}from"node:string_decoder";var Z7=(Y,Z,Q)=>{if(Q)return;if(Y)return{transform:E_.bind(void 0,new TextEncoder)};let J=new k_(Z);return{transform:x_.bind(void 0,J),final:S_.bind(void 0,J)}},E_=function*(Y,Z){if(A_.isBuffer(Z))yield z6(Z);else if(typeof Z==="string")yield Y.encode(Z);else yield Z},x_=function*(Y,Z){yield b0(Z)?Y.write(Z):Z},S_=function*(Y){let Z=Y.end();if(Z!=="")yield Z};var R3=O(()=>{W1()});import{callbackify as HG}from"node:util";var O3,Q7=async function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:J=v_}=Z[Q];for await(let z of J(Y))yield*Q7(z,Z,Q+1)},WG=async function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*P_(Q,Number(Z),Y)},P_=async function*(Y,Z,Q){if(Y===void 0)return;for await(let J of Y())yield*Q7(J,Q,Z+1)},qG,v_=function*(Y){yield Y};var GG=O(()=>{O3=HG(async(Y,Z,Q,J)=>{Z.currentIterable=Y(...Q);try{for await(let z of Z.currentIterable)J.push(z)}finally{delete Z.currentIterable}}),qG=HG(async({currentIterable:Y},Z)=>{if(Y!==void 0){await(Z?Y.throw(Z):Y.return());return}if(Z)throw Z})});var M3=(Y,Z,Q,J)=>{try{for(let z of Y(...Z))Q.push(z);J()}catch(z){J(z)}},UG=(Y,Z)=>[...Z.flatMap((Q)=>[...UY(Q,Y,0)]),...GZ(Y)],UY=function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:J=f_}=Z[Q];for(let z of J(Y))yield*UY(z,Z,Q+1)},GZ=function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*y_(Q,Number(Z),Y)},y_=function*(Y,Z,Q){if(Y===void 0)return;for(let J of Y())yield*UY(J,Q,Z+1)},f_=function*(Y){yield Y};import{Transform as b_,getDefaultHighWaterMark as $G}from"node:stream";var D3=({value:Y,value:{transform:Z,final:Q,writableObjectMode:J,readableObjectMode:z},optionName:K},{encoding:X})=>{let H={},W=BG(Y,X,K),q=GY(Z),G=GY(Q),$=q?O3.bind(void 0,Q7,H):M3.bind(void 0,UY),B=q||G?O3.bind(void 0,WG,H):M3.bind(void 0,GZ),V=q||G?qG.bind(void 0,H):void 0;return{stream:new b_({writableObjectMode:J,writableHighWaterMark:$G(J),readableObjectMode:z,readableHighWaterMark:$G(z),transform(M,L,N){$([M,W,0],this,N)},flush(M){B([W],this,M)},destroy:V})}},J7=(Y,Z,Q,J)=>{let z=Z.filter(({type:X})=>X==="generator"),K=J?z.reverse():z;for(let{value:X,optionName:H}of K){let W=BG(X,Q,H);Y=UG(W,Y)}return Y},BG=({transform:Y,final:Z,binary:Q,writableObjectMode:J,readableObjectMode:z,preserveNewlines:K},X,H)=>{let W={};return[{transform:JG(J,H)},Z7(Q,X,J),e2(Q,K,J,W),{transform:Y,final:Z},{transform:zG(z,H)},QG({binary:Q,preserveNewlines:K,readableObjectMode:z,state:W})].filter(Boolean)};var z7=O(()=>{Z1();Y7();XG();R3();GG()});var VG=(Y,Z)=>{for(let Q of h_(Y))g_(Y,Q,Z)},h_=(Y)=>new Set(Object.entries(Y).filter(([,{direction:Z}])=>Z==="input").map(([Z])=>Number(Z))),g_=(Y,Z,Q)=>{let{stdioItems:J}=Y[Z],z=J.filter(({contents:H})=>H!==void 0);if(z.length===0)return;if(Z!==0){let[{type:H,optionName:W}]=z;throw TypeError(`Only the \`stdin\` option, not \`${W}\`, can be ${A6[H]} with synchronous methods.`)}let X=z.map(({contents:H})=>H).map((H)=>m_(H,J));Q.input=s4(X)},m_=(Y,Z)=>{let Q=J7(Y,Z,"utf8",!0);return u_(Q),s4(Q)},u_=(Y)=>{let Z=Y.find((Q)=>typeof Q!=="string"&&!b0(Q));if(Z!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${Z}.`)};var FG=O(()=>{z7();W1();Z1()});var K7=({stdioItems:Y,encoding:Z,verboseInfo:Q,fdNumber:J})=>J!=="all"&&oY(Q,J)&&!q1.has(Z)&&d_(J)&&(Y.some(({type:z,value:K})=>z==="native"&&p_.has(K))||Y.every(({type:z})=>L1.has(z))),d_=(Y)=>Y===1||Y===2,p_,RG=async(Y,Z,Q,J)=>{for await(let z of Y)if(!c_(Z))MG(z,Q,J)},OG=(Y,Z,Q)=>{for(let J of Y)MG(J,Z,Q)},c_=(Y)=>Y._readableState.pipes.length>0,MG=(Y,Z,Q)=>{let J=K2(Y);h1({type:"output",verboseMessage:J,fdNumber:Z,verboseInfo:Q})};var N3=O(()=>{HY();Z1();sY();w6();p_=new Set(["pipe","overlapped"])});import{writeFileSync as l_,appendFileSync as n_}from"node:fs";var DG=({fileDescriptors:Y,syncResult:{output:Z},options:Q,isMaxBuffer:J,verboseInfo:z})=>{if(Z===null)return{output:Array.from({length:3})};let K={},X=new Set([]);return{output:Z.map((W,q)=>i_({result:W,fileDescriptors:Y,fdNumber:q,state:K,outputFiles:X,isMaxBuffer:J,verboseInfo:z},Q)),...K}},i_=({result:Y,fileDescriptors:Z,fdNumber:Q,state:J,outputFiles:z,isMaxBuffer:K,verboseInfo:X},{buffer:H,encoding:W,lines:q,stripFinalNewline:G,maxBuffer:$})=>{if(Y===null)return;let B=Xq(Y,K,$),V=z6(B),{stdioItems:F,objectMode:M}=Z[Q],L=a_([V],F,W,J),{serializedResult:N,finalResult:_=N}=o_({chunks:L,objectMode:M,encoding:W,lines:q,stripFinalNewline:G,fdNumber:Q});s_({serializedResult:N,fdNumber:Q,state:J,verboseInfo:X,encoding:W,stdioItems:F,objectMode:M});let I=H[Q]?_:void 0;try{if(J.error===void 0)r_(N,F,z);return I}catch(w){return J.error=w,I}},a_=(Y,Z,Q,J)=>{try{return J7(Y,Z,Q,!1)}catch(z){return J.error=z,Y}},o_=({chunks:Y,objectMode:Z,encoding:Q,lines:J,stripFinalNewline:z,fdNumber:K})=>{if(Z)return{serializedResult:Y};if(Q==="buffer")return{serializedResult:s4(Y)};let X=tK(Y,Q);if(J[K])return{serializedResult:X,finalResult:F3(X,!z[K],Z)};return{serializedResult:X}},s_=({serializedResult:Y,fdNumber:Z,state:Q,verboseInfo:J,encoding:z,stdioItems:K,objectMode:X})=>{if(!K7({stdioItems:K,encoding:z,verboseInfo:J,fdNumber:Z}))return;let H=F3(Y,!1,X);try{OG(H,Z,J)}catch(W){Q.error??=W}},r_=(Y,Z,Q)=>{for(let{path:J,append:z}of Z.filter(({type:K})=>s2.has(K))){let K=typeof J==="string"?J:J.toString();if(z||Q.has(K))n_(J,Y);else Q.add(K),l_(J,Y)}};var NG=O(()=>{N3();z7();Y7();W1();Z1();qY()});var _G=([,Y,Z],Q)=>{if(!Q.all)return;if(Y===void 0)return Z;if(Z===void 0)return Y;if(Array.isArray(Y))return Array.isArray(Z)?[...Y,...Z]:[...Y,G6(Z,Q,"all")];if(Array.isArray(Z))return[G6(Y,Q,"all"),...Z];if(b0(Y)&&b0(Z))return $Q([Y,Z]);return`${Y}${Z}`};var LG=O(()=>{W1();qZ()});import{once as _3}from"node:events";var wG=async(Y,Z)=>{let[Q,J]=await t_(Y);return Z.isForcefullyTerminated??=!1,[Q,J]},t_=async(Y)=>{let[Z,Q]=await Promise.allSettled([_3(Y,"spawn"),_3(Y,"exit")]);if(Z.status==="rejected")return[];return Q.status==="rejected"?jG(Y):Q.value},jG=async(Y)=>{try{return await _3(Y,"exit")}catch{return jG(Y)}},TG=async(Y)=>{let[Z,Q]=await Y;if(!e_(Z,Q)&&L3(Z,Q))throw new g1;return[Z,Q]},e_=(Y,Z)=>Y===void 0&&Z===void 0,L3=(Y,Z)=>Y!==0||Z!==null;var w3=O(()=>{j6()});var IG=({error:Y,status:Z,signal:Q,output:J},{maxBuffer:z})=>{let K=YL(Y,Z,Q),X=K?.code==="ETIMEDOUT",H=Kq(K,J,z);return{resultError:K,exitCode:Z,signal:Q,timedOut:X,isMaxBuffer:H}},YL=(Y,Z,Q)=>{if(Y!==void 0)return Y;return L3(Z,Q)?new g1:void 0};var CG=O(()=>{j6();qY();w3()});import{spawnSync as ZL}from"node:child_process";var AG=(Y,Z,Q)=>{let{file:J,commandArguments:z,command:K,escapedCommand:X,startTime:H,verboseInfo:W,options:q,fileDescriptors:G}=QL(Y,Z,Q),$=KL({file:J,commandArguments:z,options:q,command:K,escapedCommand:X,verboseInfo:W,fileDescriptors:G,startTime:H});return X4($,W,q)},QL=(Y,Z,Q)=>{let{command:J,escapedCommand:z,startTime:K,verboseInfo:X}=W2(Y,Z,Q),H=JL(Q),{file:W,commandArguments:q,options:G}=y2(Y,Z,H);zL(G);let $=rq(G,X);return{file:W,commandArguments:q,command:J,escapedCommand:z,startTime:K,verboseInfo:X,options:G,fileDescriptors:$}},JL=(Y)=>Y.node&&!Y.ipc?{...Y,ipc:!1}:Y,zL=({ipc:Y,ipcInput:Z,detached:Q,cancelSignal:J})=>{if(Z)X7("ipcInput");if(Y)X7("ipc: true");if(Q)X7("detached: true");if(J)X7("cancelSignal")},X7=(Y)=>{throw TypeError(`The "${Y}" option cannot be used with synchronous methods.`)},KL=({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,verboseInfo:K,fileDescriptors:X,startTime:H})=>{let W=XL({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,fileDescriptors:X,startTime:H});if(W.failed)return W;let{resultError:q,exitCode:G,signal:$,timedOut:B,isMaxBuffer:V}=IG(W,Q),{output:F,error:M=q}=DG({fileDescriptors:X,syncResult:W,options:Q,isMaxBuffer:V,verboseInfo:K}),L=F.map((_,I)=>G6(_,Q,I)),N=G6(_G(F,Q),Q,"all");return WL({error:M,exitCode:G,signal:$,timedOut:B,isMaxBuffer:V,stdio:L,all:N,options:Q,command:J,escapedCommand:z,startTime:H})},XL=({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,fileDescriptors:K,startTime:X})=>{try{VG(K,Q);let H=HL(Q);return ZL(...f2(Y,Z,H))}catch(H){return K4({error:H,command:J,escapedCommand:z,fileDescriptors:K,options:Q,startTime:X,isSync:!0})}},HL=({encoding:Y,maxBuffer:Z,...Q})=>({...Q,encoding:"buffer",maxBuffer:l2(Z)}),WL=({error:Y,exitCode:Z,signal:Q,timedOut:J,isMaxBuffer:z,stdio:K,all:X,options:H,command:W,escapedCommand:q,startTime:G})=>Y===void 0?n2({command:W,escapedCommand:q,stdio:K,all:X,ipcOutput:[],options:H,startTime:G}):HZ({error:Y,command:W,escapedCommand:q,timedOut:J,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:z,isForcefullyTerminated:!1,exitCode:Z,signal:Q,stdio:K,all:X,ipcOutput:[],options:H,startTime:G,isSync:!0});var kG=O(()=>{NQ();oQ();WZ();i2();eq();qZ();FG();NG();qY();LG();CG()});import{once as j3,on as qL}from"node:events";var EG=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},{reference:z=!0,filter:K}={})=>{return eY({methodName:"getOneMessage",isSubprocess:Q,ipc:J,isConnected:A2(Y)}),GL({anyProcess:Y,channel:Z,isSubprocess:Q,filter:K,reference:z})},GL=async({anyProcess:Y,channel:Z,isSubprocess:Q,filter:J,reference:z})=>{_2(Z,z);let K=C6(Y,Z,Q),X=new AbortController;try{return await Promise.race([UL(K,J,X),$L(K,Q,X),BL(K,Q,X)])}catch(H){throw Y4(Y),H}finally{X.abort(),L2(Z,z)}},UL=async(Y,Z,{signal:Q})=>{if(Z===void 0){let[J]=await j3(Y,"message",{signal:Q});return J}for await(let[J]of qL(Y,"message",{signal:Q}))if(Z(J))return J},$L=async(Y,Z,{signal:Q})=>{await j3(Y,"disconnect",{signal:Q}),pH(Z)},BL=async(Y,Z,{signal:Q})=>{let[J]=await j3(Y,"strict:error",{signal:Q});throw O2(J,Z)};var xG=O(()=>{Z4();QZ()});import{once as PG,on as VL}from"node:events";var vG=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},{reference:z=!0}={})=>T3({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J,shouldAwait:!Q,reference:z}),T3=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J,shouldAwait:z,reference:K})=>{eY({methodName:"getEachMessage",isSubprocess:Q,ipc:J,isConnected:A2(Y)}),_2(Z,K);let X=C6(Y,Z,Q),H=new AbortController,W={};return FL(Y,X,H),RL({ipcEmitter:X,isSubprocess:Q,controller:H,state:W}),OL({anyProcess:Y,channel:Z,ipcEmitter:X,isSubprocess:Q,shouldAwait:z,controller:H,state:W,reference:K})},FL=async(Y,Z,Q)=>{try{await PG(Z,"disconnect",{signal:Q.signal}),Q.abort()}catch{}},RL=async({ipcEmitter:Y,isSubprocess:Z,controller:Q,state:J})=>{try{let[z]=await PG(Y,"strict:error",{signal:Q.signal});J.error=O2(z,Z),Q.abort()}catch{}},OL=async function*({anyProcess:Y,channel:Z,ipcEmitter:Q,isSubprocess:J,shouldAwait:z,controller:K,state:X,reference:H}){try{for await(let[W]of VL(Q,"message",{signal:K.signal}))SG(X),yield W}catch{SG(X)}finally{if(K.abort(),L2(Z,H),!J)Y4(Y);if(z)await Y}},SG=({error:Y})=>{if(Y)throw Y};var I3=O(()=>{Z4();QZ()});import yG from"node:process";var fG=(Y,{ipc:Z})=>{Object.assign(Y,hG(Y,!1,Z))},bG=()=>{let Y=yG,Z=!0,Q=yG.channel!==void 0;return{...hG(Y,!0,Q),getCancelSignal:OW.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:!0,ipc:Q})}},hG=(Y,Z,Q)=>({sendMessage:S2.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getOneMessage:EG.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getEachMessage:vG.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q})});var C3=O(()=>{P2();xG();I3();I2()});import{ChildProcess as ML}from"node:child_process";import{PassThrough as DL,Readable as NL,Writable as _L,Duplex as LL}from"node:stream";var gG=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:K,verboseInfo:X})=>{$3(J);let H=new ML;wL(H,J),Object.assign(H,{readable:jL,writable:TL,duplex:IL});let W=K4({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:K,isSync:!1}),q=CL(W,X,z);return{subprocess:H,promise:q}},wL=(Y,Z)=>{let Q=UZ(),J=UZ(),z=UZ(),K=Array.from({length:Z.length-3},UZ),X=UZ(),H=[Q,J,z,...K];Object.assign(Y,{stdin:Q,stdout:J,stderr:z,all:X,stdio:H})},UZ=()=>{let Y=new DL;return Y.end(),Y},jL=()=>new NL({read(){}}),TL=()=>new _L({write(){}}),IL=()=>new LL({read(){},write(){}}),CL=async(Y,Z,Q)=>X4(Y,Z,Q);var mG=O(()=>{t2();WZ();i2()});import{createReadStream as uG,createWriteStream as dG}from"node:fs";import{Buffer as AL}from"node:buffer";import{Readable as $Z,Writable as kL,Duplex as EL}from"node:stream";var cG=(Y,Z)=>r2(xL,Y,Z,!1),BZ=({type:Y,optionName:Z})=>{throw TypeError(`The \`${Z}\` option cannot be ${A6[Y]}.`)},pG,xL;var lG=O(()=>{z7();t2();Z1();pG={fileNumber:BZ,generator:D3,asyncGenerator:D3,nodeStream:({value:Y})=>({stream:Y}),webTransform({value:{transform:Y,writableObjectMode:Z,readableObjectMode:Q}}){let J=Z||Q;return{stream:EL.fromWeb(Y,{objectMode:J})}},duplex:({value:{transform:Y}})=>({stream:Y}),native(){}},xL={input:{...pG,fileUrl:({value:Y})=>({stream:uG(Y)}),filePath:({value:{file:Y}})=>({stream:uG(Y)}),webStream:({value:Y})=>({stream:$Z.fromWeb(Y)}),iterable:({value:Y})=>({stream:$Z.from(Y)}),asyncIterable:({value:Y})=>({stream:$Z.from(Y)}),string:({value:Y})=>({stream:$Z.from(Y)}),uint8Array:({value:Y})=>({stream:$Z.from(AL.from(Y))})},output:{...pG,fileUrl:({value:Y})=>({stream:dG(Y)}),filePath:({value:{file:Y,append:Z}})=>({stream:dG(Y,Z?{flags:"a"}:{})}),webStream:({value:Y})=>({stream:kL.fromWeb(Y)}),iterable:BZ,asyncIterable:BZ,string:BZ,uint8Array:BZ}}});import{on as SL,once as nG}from"node:events";import{PassThrough as PL,getDefaultHighWaterMark as vL}from"node:stream";import{finished as oG}from"node:stream/promises";function $Y(Y){if(!Array.isArray(Y))throw TypeError(`Expected an array, got \`${typeof Y}\`.`);for(let z of Y)A3(z);let Z=Y.some(({readableObjectMode:z})=>z),Q=yL(Y,Z),J=new sG({objectMode:Z,writableHighWaterMark:Q,readableHighWaterMark:Q});for(let z of Y)J.add(z);return J}var yL=(Y,Z)=>{if(Y.length===0)return vL(Z);let Q=Y.filter(({readableObjectMode:J})=>J===Z).map(({readableHighWaterMark:J})=>J);return Math.max(...Q)},sG,fL=async(Y,Z,Q)=>{H7(Y,iG);let J=new AbortController;try{await Promise.race([bL(Y,J),hL(Y,Z,Q,J)])}finally{J.abort(),H7(Y,-iG)}},bL=async(Y,{signal:Z})=>{try{await oG(Y,{signal:Z,cleanup:!0})}catch(Q){throw rG(Y,Q),Q}},hL=async(Y,Z,Q,{signal:J})=>{for await(let[z]of SL(Y,"unpipe",{signal:J}))if(Z.has(z))z.emit(Q)},A3=(Y)=>{if(typeof Y?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Y}\`.`)},gL=async({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,onFinished:K,unpipeEvent:X})=>{H7(Y,aG);let H=new AbortController;try{await Promise.race([mL(K,Z,H),uL({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,controller:H}),dL({stream:Z,streams:Q,ended:J,aborted:z,unpipeEvent:X,controller:H})])}finally{H.abort(),H7(Y,-aG)}if(Q.size>0&&Q.size===J.size+z.size)if(J.size===0&&z.size>0)k3(Y);else pL(Y)},mL=async(Y,Z,{signal:Q})=>{try{if(await Y,!Q.aborted)k3(Z)}catch(J){if(!Q.aborted)rG(Z,J)}},uL=async({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,controller:{signal:K}})=>{try{if(await oG(Z,{signal:K,cleanup:!0,readable:!0,writable:!1}),Q.has(Z))J.add(Z)}catch(X){if(K.aborted||!Q.has(Z))return;if(tG(X))z.add(Z);else eG(Y,X)}},dL=async({stream:Y,streams:Z,ended:Q,aborted:J,unpipeEvent:z,controller:{signal:K}})=>{if(await nG(Y,z,{signal:K}),!Y.readable)return nG(K,"abort",{signal:K});Z.delete(Y),Q.delete(Y),J.delete(Y)},pL=(Y)=>{if(Y.writable)Y.end()},rG=(Y,Z)=>{if(tG(Z))k3(Y);else eG(Y,Z)},tG=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",k3=(Y)=>{if(Y.readable||Y.writable)Y.destroy()},eG=(Y,Z)=>{if(!Y.destroyed)Y.once("error",cL),Y.destroy(Z)},cL=()=>{},H7=(Y,Z)=>{let Q=Y.getMaxListeners();if(Q!==0&&Q!==Number.POSITIVE_INFINITY)Y.setMaxListeners(Q+Z)},iG=2,aG=1;var W7=O(()=>{sG=class sG extends PL{#Z=new Set([]);#Q=new Set([]);#Y=new Set([]);#J;#z=Symbol("unpipe");#K=new WeakMap;add(Y){if(A3(Y),this.#Z.has(Y))return;this.#Z.add(Y),this.#J??=fL(this,this.#Z,this.#z);let Z=gL({passThroughStream:this,stream:Y,streams:this.#Z,ended:this.#Q,aborted:this.#Y,onFinished:this.#J,unpipeEvent:this.#z});this.#K.set(Y,Z),Y.pipe(this,{end:!1})}async remove(Y){if(A3(Y),!this.#Z.has(Y))return!1;let Z=this.#K.get(Y);if(Z===void 0)return!1;return this.#K.delete(Y),Y.unpipe(this),await Z,!0}}});import{finished as YU}from"node:stream/promises";var W4=(Y,Z)=>{Y.pipe(Z),lL(Y,Z),nL(Y,Z)},lL=async(Y,Z)=>{if(x1(Y)||x1(Z))return;try{await YU(Y,{cleanup:!0,readable:!0,writable:!1})}catch{}E3(Z)},E3=(Y)=>{if(Y.writable)Y.end()},nL=async(Y,Z)=>{if(x1(Y)||x1(Z))return;try{await YU(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}x3(Y)},x3=(Y)=>{if(Y.readable)Y.destroy()};var q7=O(()=>{K6()});var ZU=(Y,Z,Q)=>{let J=new Map;for(let[z,{stdioItems:K,direction:X}]of Object.entries(Z)){for(let{stream:H}of K.filter(({type:W})=>L1.has(W)))iL(Y,H,X,z);for(let{stream:H}of K.filter(({type:W})=>!L1.has(W)))oL({subprocess:Y,stream:H,direction:X,fdNumber:z,pipeGroups:J,controller:Q})}for(let[z,K]of J.entries()){let X=K.length===1?K[0]:$Y(K);W4(X,z)}},iL=(Y,Z,Q,J)=>{if(Q==="output")W4(Y.stdio[J],Z);else W4(Z,Y.stdio[J]);let z=aL[J];if(z!==void 0)Y[z]=Z;Y.stdio[J]=Z},aL,oL=({subprocess:Y,stream:Z,direction:Q,fdNumber:J,pipeGroups:z,controller:K})=>{if(Z===void 0)return;sL(Z,K);let[X,H]=Q==="output"?[Z,Y.stdio[J]]:[Y.stdio[J],Z],W=z.get(X)??[];z.set(X,[...W,H])},sL=(Y,{signal:Z})=>{if(x1(Y))XY(Y,rL,Z)},rL=2;var QU=O(()=>{W7();K6();N2();Z1();q7();aL=["stdin","stdout","stderr"]});var BY;var JU=O(()=>{BY=[];BY.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")BY.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")BY.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class zU{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(P3[S3])return P3[S3];tL(P3,S3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Y,Z){this.listeners[Y].push(Z)}removeListener(Y,Z){let Q=this.listeners[Y],J=Q.indexOf(Z);if(J===-1)return;if(J===0&&Q.length===1)Q.length=0;else Q.splice(J,1)}emit(Y,Z,Q){if(this.emitted[Y])return!1;this.emitted[Y]=!0;let J=!1;for(let z of this.listeners[Y])J=z(Z,Q)===!0||J;if(Y==="exit")J=this.emit("afterExit",Z,Q)||J;return J}}class y3{}var G7=(Y)=>!!Y&&typeof Y==="object"&&typeof Y.removeListener==="function"&&typeof Y.emit==="function"&&typeof Y.reallyExit==="function"&&typeof Y.listeners==="function"&&typeof Y.kill==="function"&&typeof Y.pid==="number"&&typeof Y.on==="function",S3,P3,tL,eL=(Y)=>{return{onExit(Z,Q){return Y.onExit(Z,Q)},load(){return Y.load()},unload(){return Y.unload()}}},KU,XU,v3,HU,Lh,wh;var WU=O(()=>{JU();S3=Symbol.for("signal-exit emitter"),P3=globalThis,tL=Object.defineProperty.bind(Object);KU=class KU extends y3{onExit(){return()=>{}}load(){}unload(){}};XU=class XU extends y3{#Z=v3.platform==="win32"?"SIGINT":"SIGHUP";#Q=new zU;#Y;#J;#z;#K={};#X=!1;constructor(Y){super();this.#Y=Y,this.#K={};for(let Z of BY)this.#K[Z]=()=>{let Q=this.#Y.listeners(Z),{count:J}=this.#Q,z=Y;if(typeof z.__signal_exit_emitter__==="object"&&typeof z.__signal_exit_emitter__.count==="number")J+=z.__signal_exit_emitter__.count;if(Q.length===J){this.unload();let K=this.#Q.emit("exit",null,Z),X=Z==="SIGHUP"?this.#Z:Z;if(!K)Y.kill(Y.pid,X)}};this.#z=Y.reallyExit,this.#J=Y.emit}onExit(Y,Z){if(!G7(this.#Y))return()=>{};if(this.#X===!1)this.load();let Q=Z?.alwaysLast?"afterExit":"exit";return this.#Q.on(Q,Y),()=>{if(this.#Q.removeListener(Q,Y),this.#Q.listeners.exit.length===0&&this.#Q.listeners.afterExit.length===0)this.unload()}}load(){if(this.#X)return;this.#X=!0,this.#Q.count+=1;for(let Y of BY)try{let Z=this.#K[Y];if(Z)this.#Y.on(Y,Z)}catch(Z){}this.#Y.emit=(Y,...Z)=>{return this.#W(Y,...Z)},this.#Y.reallyExit=(Y)=>{return this.#H(Y)}}unload(){if(!this.#X)return;this.#X=!1,BY.forEach((Y)=>{let Z=this.#K[Y];if(!Z)throw Error("Listener not defined for signal: "+Y);try{this.#Y.removeListener(Y,Z)}catch(Q){}}),this.#Y.emit=this.#J,this.#Y.reallyExit=this.#z,this.#Q.count-=1}#H(Y){if(!G7(this.#Y))return 0;return this.#Y.exitCode=Y||0,this.#Q.emit("exit",this.#Y.exitCode,null),this.#z.call(this.#Y,this.#Y.exitCode)}#W(Y,...Z){let Q=this.#J;if(Y==="exit"&&G7(this.#Y)){if(typeof Z[0]==="number")this.#Y.exitCode=Z[0];let J=Q.call(this.#Y,Y,...Z);return this.#Q.emit("exit",this.#Y.exitCode,null),J}else return Q.call(this.#Y,Y,...Z)}};v3=globalThis.process,{onExit:HU,load:Lh,unload:wh}=eL(G7(v3)?new XU(v3):new KU)});import{addAbortListener as Yw}from"node:events";var qU=(Y,{cleanup:Z,detached:Q},{signal:J})=>{if(!Z||Q)return;let z=HU(()=>{Y.kill()});Yw(J,()=>{z()})};var GU=O(()=>{WU()});var $U=({source:Y,sourcePromise:Z,boundOptions:Q,createNested:J},...z)=>{let K=X2(),{destination:X,destinationStream:H,destinationError:W,from:q,unpipeSignal:G}=Zw(Q,J,z),{sourceStream:$,sourceError:B}=Jw(Y,q),{options:V,fileDescriptors:F}=u1.get(Y);return{sourcePromise:Z,sourceStream:$,sourceOptions:V,sourceError:B,destination:X,destinationStream:H,destinationError:W,unpipeSignal:G,fileDescriptors:F,startTime:K}},Zw=(Y,Z,Q)=>{try{let{destination:J,pipeOptions:{from:z,to:K,unpipeSignal:X}={}}=Qw(Y,Z,...Q),H=D2(J,K);return{destination:J,destinationStream:H,from:z,unpipeSignal:X}}catch(J){return{destinationError:J}}},Qw=(Y,Z,Q,...J)=>{if(Array.isArray(Q))return{destination:Z(UU,Y)(Q,...J),pipeOptions:Y};if(typeof Q==="string"||Q instanceof URL||qQ(Q)){if(Object.keys(Y).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[z,K,X]=o8(Q,...J);return{destination:Z(UU)(z,K,X),pipeOptions:X}}if(u1.has(Q)){if(Object.keys(Y).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:Q,pipeOptions:J[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${Q}`)},UU=({options:Y})=>({options:{...Y,stdin:"pipe",piped:!0}}),Jw=(Y,Z)=>{try{return{sourceStream:Q4(Y,Z)}}catch(Q){return{sourceError:Q}}};var BU=O(()=>{UQ();H2();I6();iY()});var FU=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J,fileDescriptors:z,sourceOptions:K,startTime:X})=>{let H=zw({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J});if(H!==void 0)throw f3({error:H,fileDescriptors:z,sourceOptions:K,startTime:X})},zw=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J})=>{if(Z!==void 0&&J!==void 0)return J;if(J!==void 0)return x3(Y),J;if(Z!==void 0)return E3(Q),Z},f3=({error:Y,fileDescriptors:Z,sourceOptions:Q,startTime:J})=>K4({error:Y,command:VU,escapedCommand:VU,fileDescriptors:Z,options:Q,startTime:J,isSync:!1}),VU="source.pipe(destination)";var b3=O(()=>{WZ();q7()});var RU=async(Y)=>{let[{status:Z,reason:Q,value:J=Q},{status:z,reason:K,value:X=K}]=await Y;if(!X.pipedFrom.includes(J))X.pipedFrom.push(J);if(z==="rejected")throw X;if(Z==="rejected")throw J;return X};import{finished as Kw}from"node:stream/promises";var OU=(Y,Z,Q)=>{let J=U7.has(Z)?Hw(Y,Z):Xw(Y,Z);return XY(Y,qw,Q.signal),XY(Z,Gw,Q.signal),Ww(Z),J},Xw=(Y,Z)=>{let Q=$Y([Y]);return W4(Q,Z),U7.set(Z,Q),Q},Hw=(Y,Z)=>{let Q=U7.get(Z);return Q.add(Y),Q},Ww=async(Y)=>{try{await Kw(Y,{cleanup:!0,readable:!1,writable:!0})}catch{}U7.delete(Y)},U7,qw=2,Gw=1;var MU=O(()=>{W7();N2();q7();U7=new WeakMap});import{aborted as Uw}from"node:util";var DU=(Y,Z)=>Y===void 0?[]:[$w(Y,Z)],$w=async(Y,{sourceStream:Z,mergedStream:Q,fileDescriptors:J,sourceOptions:z,startTime:K})=>{await Uw(Y,Z),await Q.remove(Z);let X=Error("Pipe canceled by `unpipeSignal` option.");throw f3({error:X,fileDescriptors:J,sourceOptions:z,startTime:K})};var NU=O(()=>{b3()});var $7=(Y,...Z)=>{if(k0(Z[0]))return $7.bind(void 0,{...Y,boundOptions:{...Y.boundOptions,...Z[0]}});let{destination:Q,...J}=$U(Y,...Z),z=Bw({...J,destination:Q});return z.pipe=$7.bind(void 0,{...Y,source:Q,sourcePromise:z,boundOptions:{}}),z},Bw=async({sourcePromise:Y,sourceStream:Z,sourceOptions:Q,sourceError:J,destination:z,destinationStream:K,destinationError:X,unpipeSignal:H,fileDescriptors:W,startTime:q})=>{let G=Vw(Y,z);FU({sourceStream:Z,sourceError:J,destinationStream:K,destinationError:X,fileDescriptors:W,sourceOptions:Q,startTime:q});let $=new AbortController;try{let B=OU(Z,K,$);return await Promise.race([RU(G),...DU(H,{sourceStream:Z,mergedStream:B,sourceOptions:Q,fileDescriptors:W,startTime:q})])}finally{$.abort()}},Vw=(Y,Z)=>Promise.allSettled([Y,Z]);var _U=O(()=>{BU();b3();MU();NU()});import{on as Fw}from"node:events";import{getDefaultHighWaterMark as Rw}from"node:stream";var B7=({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:J,encoding:z,preserveNewlines:K})=>{let X=new AbortController;return Ow(Z,X),wU({stream:Y,controller:X,binary:Q,shouldEncode:!Y.readableObjectMode&&J,encoding:z,shouldSplit:!Y.readableObjectMode,preserveNewlines:K})},Ow=async(Y,Z)=>{try{await Y}catch{}finally{Z.abort()}},h3=({stream:Y,onStreamEnd:Z,lines:Q,encoding:J,stripFinalNewline:z,allMixed:K})=>{let X=new AbortController;Mw(Z,X,Y);let H=Y.readableObjectMode&&!K;return wU({stream:Y,controller:X,binary:J==="buffer",shouldEncode:!H,encoding:J,shouldSplit:!H&&Q,preserveNewlines:!z})},Mw=async(Y,Z,Q)=>{try{await Y}catch{Q.destroy()}finally{Z.abort()}},wU=({stream:Y,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:K,preserveNewlines:X})=>{let H=Fw(Y,"data",{signal:Z.signal,highWaterMark:LU,highWatermark:LU});return Dw({onStdoutChunk:H,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:K,preserveNewlines:X})},g3,LU,Dw=async function*({onStdoutChunk:Y,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:K,preserveNewlines:X}){let H=Nw({binary:Q,shouldEncode:J,encoding:z,shouldSplit:K,preserveNewlines:X});try{for await(let[W]of Y)yield*UY(W,H,0)}catch(W){if(!Z.signal.aborted)throw W}finally{yield*GZ(H)}},Nw=({binary:Y,shouldEncode:Z,encoding:Q,shouldSplit:J,preserveNewlines:z})=>[Z7(Y,Q,!Z),e2(Y,z,!J,{})].filter(Boolean);var V7=O(()=>{R3();Y7();g3=Rw(!0),LU=g3});import{setImmediate as _w}from"node:timers/promises";var jU=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,buffer:z,maxBuffer:K,lines:X,allMixed:H,stripFinalNewline:W,verboseInfo:q,streamInfo:G})=>{let $=Lw({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,allMixed:H,verboseInfo:q,streamInfo:G});if(!z){await Promise.all([ww(Y),$]);return}let B=B3(W,Q),V=h3({stream:Y,onStreamEnd:Z,lines:X,encoding:J,stripFinalNewline:B,allMixed:H}),[F]=await Promise.all([jw({stream:Y,iterable:V,fdNumber:Q,encoding:J,maxBuffer:K,lines:X}),$]);return F},Lw=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,allMixed:z,verboseInfo:K,streamInfo:{fileDescriptors:X}})=>{if(!K7({stdioItems:X[Q]?.stdioItems,encoding:J,verboseInfo:K,fdNumber:Q}))return;let H=h3({stream:Y,onStreamEnd:Z,lines:!0,encoding:J,stripFinalNewline:!0,allMixed:z});await RG(H,Y,Q,K)},ww=async(Y)=>{if(await _w(),Y.readableFlowing===null)Y.resume()},jw=async({stream:Y,stream:{readableObjectMode:Z},iterable:Q,fdNumber:J,encoding:z,maxBuffer:K,lines:X})=>{try{if(Z||X)return await m2(Q,{maxBuffer:K});if(z==="buffer")return new Uint8Array(await u2(Q,{maxBuffer:K}));return await p2(Q,{maxBuffer:K})}catch(H){return TU(Qq({error:H,stream:Y,readableObjectMode:Z,lines:X,encoding:z,fdNumber:J}))}},m3=async(Y)=>{try{return await Y}catch(Z){return TU(Z)}},TU=({bufferedData:Y})=>sK(Y)?new Uint8Array(Y):Y;var u3=O(()=>{c2();W1();N3();V7();qY();qZ()});import{finished as Tw}from"node:stream/promises";var VZ=async(Y,Z,Q,{isSameDirection:J,stopOnExit:z=!1}={})=>{let K=Iw(Y,Q),X=new AbortController;try{await Promise.race([...z?[Q.exitPromise]:[],Tw(Y,{cleanup:!0,signal:X.signal})])}catch(H){if(!K.stdinCleanedUp)kw(H,Z,Q,J)}finally{X.abort()}},Iw=(Y,{originalStreams:[Z],subprocess:Q})=>{let J={stdinCleanedUp:!1};if(Y===Z)Cw(Y,Q,J);return J},Cw=(Y,Z,Q)=>{let{_destroy:J}=Y;Y._destroy=(...z)=>{Aw(Z,Q),J.call(Y,...z)}},Aw=({exitCode:Y,signalCode:Z},Q)=>{if(Y!==null||Z!==null)Q.stdinCleanedUp=!0},kw=(Y,Z,Q,J)=>{if(!Ew(Y,Z,Q,J))throw Y},Ew=(Y,Z,Q,J=!0)=>{if(Q.propagating)return IU(Y)||F7(Y);return Q.propagating=!0,d3(Q,Z)===J?IU(Y):F7(Y)},d3=({fileDescriptors:Y},Z)=>Z!=="all"&&Y[Z].direction==="input",F7=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",IU=(Y)=>Y?.code==="EPIPE";var R7=()=>{};var CU=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:K,verboseInfo:X,streamInfo:H})=>Y.stdio.map((W,q)=>p3({stream:W,fdNumber:q,encoding:Z,buffer:Q[q],maxBuffer:J[q],lines:z[q],allMixed:!1,stripFinalNewline:K,verboseInfo:X,streamInfo:H})),p3=async({stream:Y,fdNumber:Z,encoding:Q,buffer:J,maxBuffer:z,lines:K,allMixed:X,stripFinalNewline:H,verboseInfo:W,streamInfo:q})=>{if(!Y)return;let G=VZ(Y,Z,q);if(d3(q,Z)){await G;return}let[$]=await Promise.all([jU({stream:Y,onStreamEnd:G,fdNumber:Z,encoding:Q,buffer:J,maxBuffer:z,lines:K,allMixed:X,stripFinalNewline:H,verboseInfo:W,streamInfo:q}),G]);return $};var c3=O(()=>{u3();R7()});var AU=({stdout:Y,stderr:Z},{all:Q})=>Q&&(Y||Z)?$Y([Y,Z].filter(Boolean)):void 0,kU=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:K,verboseInfo:X,streamInfo:H})=>p3({...xw(Y,Q),fdNumber:"all",encoding:Z,maxBuffer:J[1]+J[2],lines:z[1]||z[2],allMixed:Sw(Y),stripFinalNewline:K,verboseInfo:X,streamInfo:H}),xw=({stdout:Y,stderr:Z,all:Q},[,J,z])=>{let K=J||z;if(!K)return{stream:Q,buffer:K};if(!J)return{stream:Z,buffer:K};if(!z)return{stream:Y,buffer:K};return{stream:Q,buffer:K}},Sw=({all:Y,stdout:Z,stderr:Q})=>Y&&Z&&Q&&Z.readableObjectMode!==Q.readableObjectMode;var l3=O(()=>{W7();c3()});var EU=(Y)=>oY(Y,"ipc"),xU=(Y,Z)=>{let Q=K2(Y);h1({type:"ipc",verboseMessage:Q,fdNumber:"ipc",verboseInfo:Z})};var SU=O(()=>{sY();w6()});var PU=async({subprocess:Y,buffer:Z,maxBuffer:Q,ipc:J,ipcOutput:z,verboseInfo:K})=>{if(!J)return z;let X=EU(K),H=X6(Z,"ipc"),W=X6(Q,"ipc");for await(let q of T3({anyProcess:Y,channel:Y.channel,isSubprocess:!1,ipc:J,shouldAwait:!1,reference:!0})){if(H)Jq(Y,z,W),z.push(q);if(X)xU(q,K)}return z},vU=async(Y,Z)=>{return await Promise.allSettled([Y]),Z};var yU=O(()=>{qY();SU();H6();I3()});import{once as Pw}from"node:events";var fU=async({subprocess:Y,options:{encoding:Z,buffer:Q,maxBuffer:J,lines:z,timeoutDuration:K,cancelSignal:X,gracefulCancel:H,forceKillAfterDelay:W,stripFinalNewline:q,ipc:G,ipcInput:$},context:B,verboseInfo:V,fileDescriptors:F,originalStreams:M,onInternalError:L,controller:N})=>{let _=wG(Y,B),I={originalStreams:M,fileDescriptors:F,subprocess:Y,exitPromise:_,propagating:!1},w=CU({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:q,verboseInfo:V,streamInfo:I}),A=kU({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:q,verboseInfo:V,streamInfo:I}),x=[],E=PU({subprocess:Y,buffer:Q,maxBuffer:J,ipc:G,ipcOutput:x,verboseInfo:V}),h=vw(M,Y,I),u=yw(F,I);try{return await Promise.race([Promise.all([{},TG(_),Promise.all(w),A,E,CW(Y,$),...h,...u]),L,fw(Y,N),...LW(Y,K,B,N),...dH({subprocess:Y,cancelSignal:X,gracefulCancel:H,context:B,controller:N}),...NW({subprocess:Y,cancelSignal:X,gracefulCancel:H,forceKillAfterDelay:W,context:B,controller:N})])}catch(f){return B.terminationReason??="other",Promise.all([{error:f},_,Promise.all(w.map((m)=>m3(m))),m3(A),vU(E,x),Promise.allSettled(h),Promise.allSettled(u)])}},vw=(Y,Z,Q)=>Y.map((J,z)=>J===Z.stdio[z]?void 0:VZ(J,z,Q)),yw=(Y,Z)=>Y.flatMap(({stdioItems:Q},J)=>Q.filter(({value:z,stream:K=z})=>P1(K,{checkOpen:!1})&&!x1(K)).map(({type:z,value:K,stream:X=K})=>VZ(X,J,Z,{isSameDirection:L1.has(z),stopOnExit:z==="native"}))),fw=async(Y,{signal:Z})=>{let[Q]=await Pw(Y,"error",{signal:Z});throw Q};var bU=O(()=>{cQ();yQ();pQ();K6();Z1();u3();yU();nQ();l3();c3();w3();R7()});var hU=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),FZ=(Y,Z,Q)=>{let J=Y[Q];if(!J.has(Z))J.set(Z,[]);let z=J.get(Z),K=m1();return z.push(K),{resolve:K.resolve.bind(K),promises:z}},q4=async({resolve:Y,promises:Z},Q)=>{Y();let[J]=await Promise.race([Promise.allSettled([!0,Q]),Promise.all([!1,...Z])]);return!J};var O7=()=>{};import{finished as gU}from"node:stream/promises";var n3=async(Y)=>{if(Y===void 0)return;try{await i3(Y)}catch{}},mU=async(Y)=>{if(Y===void 0)return;try{await a3(Y)}catch{}},i3=async(Y)=>{await gU(Y,{cleanup:!0,readable:!1,writable:!0})},a3=async(Y)=>{await gU(Y,{cleanup:!0,readable:!0,writable:!1})},M7=async(Y,Z)=>{if(await Y,Z)throw Z},D7=(Y,Z,Q)=>{if(Q&&!F7(Q))Y.destroy(Q);else if(Z)Y.destroy()};var o3=O(()=>{R7()});import{Readable as bw}from"node:stream";import{callbackify as hw}from"node:util";var uU=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:J,binary:z=!0,preserveNewlines:K=!0}={})=>{let X=z||q1.has(Q),{subprocessStdout:H,waitReadableDestroy:W}=s3(Y,J,Z),{readableEncoding:q,readableObjectMode:G,readableHighWaterMark:$}=r3(H,X),{read:B,onStdoutDataDone:V}=t3({subprocessStdout:H,subprocess:Y,binary:X,encoding:Q,preserveNewlines:K}),F=new bw({read:B,destroy:hw(Y9.bind(void 0,{subprocessStdout:H,subprocess:Y,waitReadableDestroy:W})),highWaterMark:$,objectMode:G,encoding:q});return e3({subprocessStdout:H,onStdoutDataDone:V,readable:F,subprocess:Y}),F},s3=(Y,Z,Q)=>{let J=Q4(Y,Z),z=FZ(Q,J,"readableDestroy");return{subprocessStdout:J,waitReadableDestroy:z}},r3=({readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q},J)=>J?{readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q}:{readableEncoding:Y,readableObjectMode:!0,readableHighWaterMark:g3},t3=({subprocessStdout:Y,subprocess:Z,binary:Q,encoding:J,preserveNewlines:z})=>{let K=m1(),X=B7({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:!Q,encoding:J,preserveNewlines:z});return{read(){gw(this,X,K)},onStdoutDataDone:K}},gw=async(Y,Z,Q)=>{try{let{value:J,done:z}=await Z.next();if(z)Q.resolve();else Y.push(J)}catch{}},e3=async({subprocessStdout:Y,onStdoutDataDone:Z,readable:Q,subprocess:J,subprocessStdin:z})=>{try{if(await a3(Y),await J,await n3(z),await Z,Q.readable)Q.push(null)}catch(K){await n3(z),dU(Q,K)}},Y9=async({subprocessStdout:Y,subprocess:Z,waitReadableDestroy:Q},J)=>{if(await q4(Q,Z))dU(Y,J),await M7(Z,J)},dU=(Y,Z)=>{D7(Y,Y.readable,Z)};var Z9=O(()=>{HY();I6();V7();O7();o3()});import{Writable as mw}from"node:stream";import{callbackify as pU}from"node:util";var cU=({subprocess:Y,concurrentStreams:Z},{to:Q}={})=>{let{subprocessStdin:J,waitWritableFinal:z,waitWritableDestroy:K}=Q9(Y,Q,Z),X=new mw({...J9(J,Y,z),destroy:pU(K9.bind(void 0,{subprocessStdin:J,subprocess:Y,waitWritableFinal:z,waitWritableDestroy:K})),highWaterMark:J.writableHighWaterMark,objectMode:J.writableObjectMode});return z9(J,X),X},Q9=(Y,Z,Q)=>{let J=D2(Y,Z),z=FZ(Q,J,"writableFinal"),K=FZ(Q,J,"writableDestroy");return{subprocessStdin:J,waitWritableFinal:z,waitWritableDestroy:K}},J9=(Y,Z,Q)=>({write:uw.bind(void 0,Y),final:pU(dw.bind(void 0,Y,Z,Q))}),uw=(Y,Z,Q,J)=>{if(Y.write(Z,Q))J();else Y.once("drain",J)},dw=async(Y,Z,Q)=>{if(await q4(Q,Z)){if(Y.writable)Y.end();await Z}},z9=async(Y,Z,Q)=>{try{if(await i3(Y),Z.writable)Z.end()}catch(J){await mU(Q),lU(Z,J)}},K9=async({subprocessStdin:Y,subprocess:Z,waitWritableFinal:Q,waitWritableDestroy:J},z)=>{if(await q4(Q,Z),await q4(J,Z))lU(Y,z),await M7(Z,z)},lU=(Y,Z)=>{D7(Y,Y.writable,Z)};var X9=O(()=>{I6();O7();o3()});import{Duplex as pw}from"node:stream";import{callbackify as cw}from"node:util";var nU=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:J,to:z,binary:K=!0,preserveNewlines:X=!0}={})=>{let H=K||q1.has(Q),{subprocessStdout:W,waitReadableDestroy:q}=s3(Y,J,Z),{subprocessStdin:G,waitWritableFinal:$,waitWritableDestroy:B}=Q9(Y,z,Z),{readableEncoding:V,readableObjectMode:F,readableHighWaterMark:M}=r3(W,H),{read:L,onStdoutDataDone:N}=t3({subprocessStdout:W,subprocess:Y,binary:H,encoding:Q,preserveNewlines:X}),_=new pw({read:L,...J9(G,Y,$),destroy:cw(lw.bind(void 0,{subprocessStdout:W,subprocessStdin:G,subprocess:Y,waitReadableDestroy:q,waitWritableFinal:$,waitWritableDestroy:B})),readableHighWaterMark:M,writableHighWaterMark:G.writableHighWaterMark,readableObjectMode:F,writableObjectMode:G.writableObjectMode,encoding:V});return e3({subprocessStdout:W,onStdoutDataDone:N,readable:_,subprocess:Y,subprocessStdin:G}),z9(G,_,W),_},lw=async({subprocessStdout:Y,subprocessStdin:Z,subprocess:Q,waitReadableDestroy:J,waitWritableFinal:z,waitWritableDestroy:K},X)=>{await Promise.all([Y9({subprocessStdout:Y,subprocess:Q,waitReadableDestroy:J},X),K9({subprocessStdin:Z,subprocess:Q,waitWritableFinal:z,waitWritableDestroy:K},X)])};var iU=O(()=>{HY();Z9();X9()});var H9=(Y,Z,{from:Q,binary:J=!1,preserveNewlines:z=!1}={})=>{let K=J||q1.has(Z),X=Q4(Y,Q),H=B7({subprocessStdout:X,subprocess:Y,binary:K,shouldEncode:!0,encoding:Z,preserveNewlines:z});return nw(H,X,Y)},nw=async function*(Y,Z,Q){try{yield*Y}finally{if(Z.readable)Z.destroy();await Q}};var aU=O(()=>{HY();I6();V7()});var oU=(Y,{encoding:Z})=>{let Q=hU();Y.readable=uU.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.writable=cU.bind(void 0,{subprocess:Y,concurrentStreams:Q}),Y.duplex=nU.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.iterable=H9.bind(void 0,Y,Z),Y[Symbol.asyncIterator]=H9.bind(void 0,Y,Z,{})};var sU=O(()=>{O7();Z9();X9();iU();aU()});var rU=(Y,Z)=>{for(let[Q,J]of aw){let z=J.value.bind(Z);Reflect.defineProperty(Y,Q,{...J,value:z})}},iw,aw;var tU=O(()=>{iw=(async()=>{})().constructor.prototype,aw=["then","catch","finally"].map((Y)=>[Y,Reflect.getOwnPropertyDescriptor(iw,Y)])});import{setMaxListeners as ow}from"node:events";import{spawn as sw}from"node:child_process";var eU=(Y,Z,Q,J)=>{let{file:z,commandArguments:K,command:X,escapedCommand:H,startTime:W,verboseInfo:q,options:G,fileDescriptors:$}=rw(Y,Z,Q),{subprocess:B,promise:V}=ew({file:z,commandArguments:K,options:G,startTime:W,verboseInfo:q,command:X,escapedCommand:H,fileDescriptors:$});return B.pipe=$7.bind(void 0,{source:B,sourcePromise:V,boundOptions:{},createNested:J}),rU(B,V),u1.set(B,{options:G,fileDescriptors:$}),B},rw=(Y,Z,Q)=>{let{command:J,escapedCommand:z,startTime:K,verboseInfo:X}=W2(Y,Z,Q),{file:H,commandArguments:W,options:q}=y2(Y,Z,Q),G=tw(q),$=cG(G,X);return{file:H,commandArguments:W,command:J,escapedCommand:z,startTime:K,verboseInfo:X,options:G,fileDescriptors:$}},tw=({timeout:Y,signal:Z,...Q})=>{if(Z!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...Q,timeoutDuration:Y}},ew=({file:Y,commandArguments:Z,options:Q,startTime:J,verboseInfo:z,command:K,escapedCommand:X,fileDescriptors:H})=>{let W;try{W=sw(...f2(Y,Z,Q))}catch(F){return gG({error:F,command:K,escapedCommand:X,fileDescriptors:H,options:Q,startTime:J,verboseInfo:z})}let q=new AbortController;ow(Number.POSITIVE_INFINITY,q.signal);let G=[...W.stdio];ZU(W,H,q),qU(W,Q,q);let $={},B=m1();W.kill=mH.bind(void 0,{kill:W.kill.bind(W),options:Q,onInternalError:B,context:$,controller:q}),W.all=AU(W,Q),oU(W,Q),fG(W,Q);let V=Yj({subprocess:W,options:Q,startTime:J,verboseInfo:z,fileDescriptors:H,originalStreams:G,command:K,escapedCommand:X,context:$,onInternalError:B,controller:q});return{subprocess:W,promise:V}},Yj=async({subprocess:Y,options:Z,startTime:Q,verboseInfo:J,fileDescriptors:z,originalStreams:K,command:X,escapedCommand:H,context:W,onInternalError:q,controller:G})=>{let[$,[B,V],F,M,L]=await fU({subprocess:Y,options:Z,context:W,verboseInfo:J,fileDescriptors:z,originalStreams:K,onInternalError:q,controller:G});G.abort(),q.resolve();let N=F.map((w,A)=>G6(w,Z,A)),_=G6(M,Z,"all"),I=Zj({errorInfo:$,exitCode:B,signal:V,stdio:N,all:_,ipcOutput:L,context:W,options:Z,command:X,escapedCommand:H,startTime:Q});return X4(I,J,Z)},Zj=({errorInfo:Y,exitCode:Z,signal:Q,stdio:J,all:z,ipcOutput:K,context:X,options:H,command:W,escapedCommand:q,startTime:G})=>("error"in Y)?HZ({error:Y.error,command:W,escapedCommand:q,timedOut:X.terminationReason==="timeout",isCanceled:X.terminationReason==="cancel"||X.terminationReason==="gracefulCancel",isGracefullyCanceled:X.terminationReason==="gracefulCancel",isMaxBuffer:Y.error instanceof W6,isForcefullyTerminated:X.isForcefullyTerminated,exitCode:Z,signal:Q,stdio:J,all:z,ipcOutput:K,options:H,startTime:G,isSync:!1}):n2({command:W,escapedCommand:q,stdio:J,all:z,ipcOutput:K,options:H,startTime:G});var Y$=O(()=>{c2();NQ();oQ();I6();C3();WZ();i2();mG();lG();qZ();QU();F2();GU();_U();l3();bU();sU();tU()});var N7=(Y,Z)=>{let Q=Object.fromEntries(Object.entries(Z).map(([J,z])=>[J,Qj(J,Y[J],z)]));return{...Y,...Q}},Qj=(Y,Z,Q)=>{if(Jj.has(Y)&&k0(Z)&&k0(Q))return{...Z,...Q};return Q},Jj;var Z$=O(()=>{H6();Jj=new Set(["env",...RQ])});var k6=(Y,Z,Q,J)=>{let z=(X,H,W)=>k6(X,H,Q,W),K=(...X)=>zj({mapArguments:Y,deepOptions:Q,boundOptions:Z,setBoundExeca:J,createNested:z},...X);if(J!==void 0)J(K,z,Z);return K},zj=({mapArguments:Y,deepOptions:Z={},boundOptions:Q={},setBoundExeca:J,createNested:z},K,...X)=>{if(k0(K))return z(Y,N7(Q,K),J);let{file:H,commandArguments:W,options:q,isSync:G}=Kj({mapArguments:Y,firstArgument:K,nextArguments:X,deepOptions:Z,boundOptions:Q});return G?AG(H,W,q):eU(H,W,q,z)},Kj=({mapArguments:Y,firstArgument:Z,nextArguments:Q,deepOptions:J,boundOptions:z})=>{let K=QX(Z)?JX(Z,Q):[Z,...Q],[X,H,W]=o8(...K),q=N7(N7(J,z),W),{file:G=X,commandArguments:$=H,options:B=q,isSync:V=!1}=Y({file:X,commandArguments:H,options:q});return{file:G,commandArguments:$,options:B,isSync:V}};var Q$=O(()=>{UQ();zX();kG();Y$();Z$()});var J$=({file:Y,commandArguments:Z})=>K$(Y,Z),z$=({file:Y,commandArguments:Z})=>({...K$(Y,Z),isSync:!0}),K$=(Y,Z)=>{if(Z.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Y} ${Z}.`);let[Q,...J]=Xj(Y);return{file:Q,commandArguments:J}},Xj=(Y)=>{if(typeof Y!=="string")throw TypeError(`The command must be a string: ${String(Y)}.`);let Z=Y.trim();if(Z==="")return[];let Q=[];for(let J of Z.split(Hj)){let z=Q.at(-1);if(z&&z.endsWith("\\"))Q[Q.length-1]=`${z.slice(0,-1)} ${J}`;else Q.push(J)}return Q},Hj;var X$=O(()=>{Hj=/ +/g});var H$=(Y,Z,Q)=>{Y.sync=Z(Wj,Q),Y.s=Y.sync},W$=({options:Y})=>q$(Y),Wj=({options:Y})=>({...q$(Y),isSync:!0}),q$=(Y)=>({options:{...qj(Y),...Y}}),qj=({input:Y,inputFile:Z,stdio:Q})=>Y===void 0&&Z===void 0&&Q===void 0?{stdin:"inherit"}:{},G$;var U$=O(()=>{G$={preferLocal:!0}});var p1,$u,Bu,Vu,Fu,Ru,Ou,Mu,Du,Nu;var _7=O(()=>{Q$();X$();lQ();U$();C3();j6();p1=k6(()=>({})),$u=k6(()=>({isSync:!0})),Bu=k6(J$),Vu=k6(z$),Fu=k6(jW),Ru=k6(W$,{},G$,H$),{sendMessage:Ou,getOneMessage:Mu,getEachMessage:Du,getCancelSignal:Nu}=bG()});function Gj(Y,Z){let Q=Y.slice(0,Z).split(/\r\n|\n|\r/g);return[Q.length,Q.pop().length+1]}function Uj(Y,Z,Q){let J=Y.split(/\r\n|\n|\r/g),z="",K=(Math.log10(Z+1)|0)+1;for(let X=Z-1;X<=Z+1;X++){let H=J[X-1];if(!H)continue;if(z+=X.toString().padEnd(K," "),z+=": ",z+=H,z+=`
|
|
83
|
+
`,X===Z)z+=" ".repeat(K+Q+2),z+=`^
|
|
84
|
+
`}return z}var Z0;var VY=O(()=>{/*!
|
|
85
85
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
86
86
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
87
87
|
*
|
|
@@ -107,16 +107,16 @@ Instead, \`yield\` should either be called with a value, or not be called at all
|
|
|
107
107
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
108
108
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
109
109
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
110
|
-
*/
|
|
110
|
+
*/Z0=class Z0 extends Error{line;column;codeblock;constructor(Y,Z){let[Q,J]=Gj(Z.toml,Z.ptr),z=Uj(Z.toml,Q,J);super(`Invalid TOML document: ${Y}
|
|
111
111
|
|
|
112
|
-
${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function
|
|
113
|
-
`,Z);if(Y[J-1]==="\r")J--;return J<=Q?J:-1}function
|
|
112
|
+
${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function $j(Y,Z){let Q=0;while(Y[Z-++Q]==="\\");return--Q&&Q%2}function G4(Y,Z=0,Q=Y.length){let J=Y.indexOf(`
|
|
113
|
+
`,Z);if(Y[J-1]==="\r")J--;return J<=Q?J:-1}function RZ(Y,Z){for(let Q=Z;Q<Y.length;Q++){let J=Y[Q];if(J===`
|
|
114
114
|
`)return Q;if(J==="\r"&&Y[Q+1]===`
|
|
115
|
-
`)return Q+1;if(J<" "&&J!=="\t"||J==="")throw new
|
|
115
|
+
`)return Q+1;if(J<" "&&J!=="\t"||J==="")throw new Z0("control characters are not allowed in comments",{toml:Y,ptr:Z})}return Y.length}function G1(Y,Z,Q,J){let z;while((z=Y[Z])===" "||z==="\t"||!Q&&(z===`
|
|
116
116
|
`||z==="\r"&&Y[Z+1]===`
|
|
117
|
-
`))Z++;return J||z!=="#"?Z:
|
|
118
|
-
`||
|
|
119
|
-
`))return
|
|
117
|
+
`))Z++;return J||z!=="#"?Z:G1(Y,RZ(Y,Z),Q)}function W9(Y,Z,Q,J,z=!1){if(!J)return Z=G4(Y,Z),Z<0?Y.length:Z;for(let K=Z;K<Y.length;K++){let X=Y[K];if(X==="#")K=G4(Y,K);else if(X===Q)return K+1;else if(X===J||z&&(X===`
|
|
118
|
+
`||X==="\r"&&Y[K+1]===`
|
|
119
|
+
`))return K}throw new Z0("cannot find end of structure",{toml:Y,ptr:Z})}function L7(Y,Z){let Q=Y[Z],J=Q===Y[Z+1]&&Y[Z+1]===Y[Z+2]?Y.slice(Z,Z+3):Q;Z+=J.length-1;do Z=Y.indexOf(J,++Z);while(Z>-1&&Q!=="'"&&$j(Y,Z));if(Z>-1){if(Z+=J.length,J.length>1){if(Y[Z]===Q)Z++;if(Y[Z]===Q)Z++}}return Z}var OZ=O(()=>{VY();/*!
|
|
120
120
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
121
121
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
122
122
|
*
|
|
@@ -142,7 +142,7 @@ ${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function J_(Y,Z){let Q=0
|
|
|
142
142
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
143
143
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
144
144
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
145
|
-
*/});var
|
|
145
|
+
*/});var Bj,E6;var q9=O(()=>{/*!
|
|
146
146
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
147
147
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
148
148
|
*
|
|
@@ -168,12 +168,12 @@ ${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function J_(Y,Z){let Q=0
|
|
|
168
168
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
169
169
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
170
170
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
171
|
-
*/
|
|
172
|
-
`)Z++}let
|
|
173
|
-
|
|
174
|
-
`){if(!z)throw new
|
|
175
|
-
|
|
176
|
-
`&&Y[Z]!=="\r")throw new
|
|
171
|
+
*/Bj=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;E6=class E6 extends Date{#Z=!1;#Q=!1;#Y=null;constructor(Y){let Z=!0,Q=!0,J="Z";if(typeof Y==="string"){let z=Y.match(Bj);if(z){if(!z[1])Z=!1,Y=`0000-01-01T${Y}`;if(Q=!!z[2],Q&&Y[10]===" "&&(Y=Y.replace(" ","T")),z[2]&&+z[2]>23)Y="";else if(J=z[3]||null,Y=Y.toUpperCase(),!J&&Q)Y+="Z"}else Y=""}super(Y);if(!isNaN(this.getTime()))this.#Z=Z,this.#Q=Q,this.#Y=J}isDateTime(){return this.#Z&&this.#Q}isLocal(){return!this.#Z||!this.#Q||!this.#Y}isDate(){return this.#Z&&!this.#Q}isTime(){return this.#Q&&!this.#Z}isValid(){return this.#Z||this.#Q}toISOString(){let Y=super.toISOString();if(this.isDate())return Y.slice(0,10);if(this.isTime())return Y.slice(11,23);if(this.#Y===null)return Y.slice(0,-1);if(this.#Y==="Z")return Y;let Z=+this.#Y.slice(1,3)*60+ +this.#Y.slice(4,6);return Z=this.#Y[0]==="-"?Z:-Z,new Date(this.getTime()-Z*60000).toISOString().slice(0,-1)+this.#Y}static wrapAsOffsetDateTime(Y,Z="Z"){let Q=new E6(Y);return Q.#Y=Z,Q}static wrapAsLocalDateTime(Y){let Z=new E6(Y);return Z.#Y=null,Z}static wrapAsLocalDate(Y){let Z=new E6(Y);return Z.#Q=!1,Z.#Y=null,Z}static wrapAsLocalTime(Y){let Z=new E6(Y);return Z.#Z=!1,Z.#Y=null,Z}}});function w7(Y,Z=0,Q=Y.length){let J=Y[Z]==="'",z=Y[Z++]===Y[Z]&&Y[Z]===Y[Z+1];if(z){if(Q-=2,Y[Z+=2]==="\r")Z++;if(Y[Z]===`
|
|
172
|
+
`)Z++}let K=0,X,H="",W=Z;while(Z<Q-1){let q=Y[Z++];if(q===`
|
|
173
|
+
`||q==="\r"&&Y[Z]===`
|
|
174
|
+
`){if(!z)throw new Z0("newlines are not allowed in strings",{toml:Y,ptr:Z-1})}else if(q<" "&&q!=="\t"||q==="")throw new Z0("control characters are not allowed in strings",{toml:Y,ptr:Z-1});if(X){if(X=!1,q==="u"||q==="U"){let G=Y.slice(Z,Z+=q==="u"?4:8);if(!Oj.test(G))throw new Z0("invalid unicode escape",{toml:Y,ptr:K});try{H+=String.fromCodePoint(parseInt(G,16))}catch{throw new Z0("invalid unicode escape",{toml:Y,ptr:K})}}else if(z&&(q===`
|
|
175
|
+
`||q===" "||q==="\t"||q==="\r")){if(Z=G1(Y,Z-1,!0),Y[Z]!==`
|
|
176
|
+
`&&Y[Z]!=="\r")throw new Z0("invalid escape: only line-ending whitespace may be escaped",{toml:Y,ptr:K});Z=G1(Y,Z)}else if(q in $$)H+=$$[q];else throw new Z0("unrecognized escape sequence",{toml:Y,ptr:K});W=Z}else if(!J&&q==="\\")K=Z-1,X=!0,H+=Y.slice(W,K)}return H+Y.slice(W,Q-1)}function B$(Y,Z,Q,J){if(Y==="true")return!0;if(Y==="false")return!1;if(Y==="-inf")return-1/0;if(Y==="inf"||Y==="+inf")return 1/0;if(Y==="nan"||Y==="+nan"||Y==="-nan")return NaN;if(Y==="-0")return J?0n:0;let z=Vj.test(Y);if(z||Fj.test(Y)){if(Rj.test(Y))throw new Z0("leading zeroes are not allowed",{toml:Z,ptr:Q});Y=Y.replace(/_/g,"");let X=+Y;if(isNaN(X))throw new Z0("invalid number",{toml:Z,ptr:Q});if(z){if((z=!Number.isSafeInteger(X))&&!J)throw new Z0("integer value cannot be represented losslessly",{toml:Z,ptr:Q});if(z||J===!0)X=BigInt(Y)}return X}let K=new E6(Y);if(!K.isValid())throw new Z0("invalid value",{toml:Z,ptr:Q});return K}var Vj,Fj,Rj,Oj,$$;var G9=O(()=>{OZ();q9();VY();/*!
|
|
177
177
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
178
178
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
179
179
|
*
|
|
@@ -199,10 +199,10 @@ ${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function J_(Y,Z){let Q=0
|
|
|
199
199
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
200
200
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
201
201
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
202
|
-
*/
|
|
203
|
-
`,f:"\f",r:"\r",'"':'"',"\\":"\\"}});function
|
|
204
|
-
`,
|
|
205
|
-
`&&Y[
|
|
202
|
+
*/Vj=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Fj=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Rj=/^[+-]?0[0-9_]/,Oj=/^[0-9a-f]{4,8}$/i,$$={b:"\b",t:"\t",n:`
|
|
203
|
+
`,f:"\f",r:"\r",'"':'"',"\\":"\\"}});function Mj(Y,Z,Q,J){let z=Y.slice(Z,Q),K=z.indexOf("#");if(K>-1)RZ(Y,K),z=z.slice(0,K);let X=z.trimEnd();if(!J){let H=z.indexOf(`
|
|
204
|
+
`,X.length);if(H>-1)throw new Z0("newlines are not allowed in inline tables",{toml:Y,ptr:Z+H})}return[X,K]}function MZ(Y,Z,Q,J,z){if(J===0)throw new Z0("document contains excessively nested structures. aborting.",{toml:Y,ptr:Z});let K=Y[Z];if(K==="["||K==="{"){let[W,q]=K==="["?F$(Y,Z,J,z):V$(Y,Z,J,z),G=Q?W9(Y,q,",",Q):q;if(q-G&&Q==="}"){let $=G4(Y,q,G);if($>-1)throw new Z0("newlines are not allowed in inline tables",{toml:Y,ptr:$})}return[W,G]}let X;if(K==='"'||K==="'"){X=L7(Y,Z);let W=w7(Y,Z,X);if(Q){if(X=G1(Y,X,Q!=="]"),Y[X]&&Y[X]!==","&&Y[X]!==Q&&Y[X]!==`
|
|
205
|
+
`&&Y[X]!=="\r")throw new Z0("unexpected character encountered",{toml:Y,ptr:X});X+=+(Y[X]===",")}return[W,X]}X=W9(Y,Z,",",Q);let H=Mj(Y,Z,X-+(Y[X-1]===","),Q==="]");if(!H[0])throw new Z0("incomplete key-value declaration: no value specified",{toml:Y,ptr:Z});if(Q&&H[1]>-1)X=G1(Y,Z+H[1]),X+=+(Y[X]===",");return[B$(H[0],Y,Z,z),X]}var U9=O(()=>{G9();$9();OZ();VY();/*!
|
|
206
206
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
207
207
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
208
208
|
*
|
|
@@ -228,9 +228,9 @@ ${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function J_(Y,Z){let Q=0
|
|
|
228
228
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
229
229
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
230
230
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
231
|
-
*/});function
|
|
232
|
-
`)throw new
|
|
233
|
-
`&&
|
|
231
|
+
*/});function j7(Y,Z,Q="="){let J=Z-1,z=[],K=Y.indexOf(Q,Z);if(K<0)throw new Z0("incomplete key-value: cannot find end of key",{toml:Y,ptr:Z});do{let X=Y[Z=++J];if(X!==" "&&X!=="\t")if(X==='"'||X==="'"){if(X===Y[Z+1]&&X===Y[Z+2])throw new Z0("multiline strings are not allowed in keys",{toml:Y,ptr:Z});let H=L7(Y,Z);if(H<0)throw new Z0("unfinished string encountered",{toml:Y,ptr:Z});J=Y.indexOf(".",H);let W=Y.slice(H,J<0||J>K?K:J),q=G4(W);if(q>-1)throw new Z0("newlines are not allowed in keys",{toml:Y,ptr:Z+J+q});if(W.trimStart())throw new Z0("found extra tokens after the string part",{toml:Y,ptr:H});if(K<H){if(K=Y.indexOf(Q,H),K<0)throw new Z0("incomplete key-value: cannot find end of key",{toml:Y,ptr:Z})}z.push(w7(Y,Z,H))}else{J=Y.indexOf(".",Z);let H=Y.slice(Z,J<0||J>K?K:J);if(!Dj.test(H))throw new Z0("only letter, numbers, dashes and underscores are allowed in keys",{toml:Y,ptr:Z});z.push(H.trimEnd())}}while(J+1&&J<K);return[z,G1(Y,K+1,!0,!0)]}function V$(Y,Z,Q,J){let z={},K=new Set,X,H=0;Z++;while((X=Y[Z++])!=="}"&&X){let W={toml:Y,ptr:Z-1};if(X===`
|
|
232
|
+
`)throw new Z0("newlines are not allowed in inline tables",W);else if(X==="#")throw new Z0("inline tables cannot contain comments",W);else if(X===",")throw new Z0("expected key-value, found comma",W);else if(X!==" "&&X!=="\t"){let q,G=z,$=!1,[B,V]=j7(Y,Z-1);for(let L=0;L<B.length;L++){if(L)G=$?G[q]:G[q]={};if(q=B[L],($=Object.hasOwn(G,q))&&(typeof G[q]!=="object"||K.has(G[q])))throw new Z0("trying to redefine an already defined value",{toml:Y,ptr:Z});if(!$&&q==="__proto__")Object.defineProperty(G,q,{enumerable:!0,configurable:!0,writable:!0})}if($)throw new Z0("trying to redefine an already defined value",{toml:Y,ptr:Z});let[F,M]=MZ(Y,V,"}",Q-1,J);K.add(F),G[q]=F,Z=M,H=Y[Z-1]===","?Z-1:0}}if(H)throw new Z0("trailing commas are not allowed in inline tables",{toml:Y,ptr:H});if(!X)throw new Z0("unfinished table encountered",{toml:Y,ptr:Z});return[z,Z]}function F$(Y,Z,Q,J){let z=[],K;Z++;while((K=Y[Z++])!=="]"&&K)if(K===",")throw new Z0("expected value, found comma",{toml:Y,ptr:Z-1});else if(K==="#")Z=RZ(Y,Z);else if(K!==" "&&K!=="\t"&&K!==`
|
|
233
|
+
`&&K!=="\r"){let X=MZ(Y,Z-1,"]",Q-1,J);z.push(X[0]),Z=X[1]}if(!K)throw new Z0("unfinished array encountered",{toml:Y,ptr:Z});return[z,Z]}var Dj;var $9=O(()=>{G9();U9();OZ();VY();/*!
|
|
234
234
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
235
235
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
236
236
|
*
|
|
@@ -256,8 +256,8 @@ ${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function J_(Y,Z){let Q=0
|
|
|
256
256
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
257
257
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
258
258
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
259
|
-
|
|
260
|
-
`&&Y[
|
|
259
|
+
*/Dj=/^[a-zA-Z0-9-_]+[ \t]*$/});function R$(Y,Z,Q,J){let z=Z,K=Q,X,H=!1,W;for(let q=0;q<Y.length;q++){if(q){if(z=H?z[X]:z[X]={},K=(W=K[X]).c,J===0&&(W.t===1||W.t===2))return null;if(W.t===2){let G=z.length-1;z=z[G],K=K[G].c}}if(X=Y[q],(H=Object.hasOwn(z,X))&&K[X]?.t===0&&K[X]?.d)return null;if(!H){if(X==="__proto__")Object.defineProperty(z,X,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(K,X,{enumerable:!0,configurable:!0,writable:!0});K[X]={t:q<Y.length-1&&J===2?3:J,d:!1,i:0,c:{}}}}if(W=K[X],W.t!==J&&!(J===1&&W.t===3))return null;if(J===2){if(!W.d)W.d=!0,z[X]=[];z[X].push(z={}),W.c[W.i++]=W={t:1,d:!1,i:0,c:{}}}if(W.d)return null;if(W.d=!0,J===1)z=H?z[X]:z[X]={};else if(J===0&&H)return null;return[X,z,W.c]}function B9(Y,{maxDepth:Z=1000,integersAsBigInt:Q}={}){let J={},z={},K=J,X=z;for(let H=G1(Y,0);H<Y.length;){if(Y[H]==="["){let W=Y[++H]==="[",q=j7(Y,H+=+W,"]");if(W){if(Y[q[1]-1]!=="]")throw new Z0("expected end of table declaration",{toml:Y,ptr:q[1]-1});q[1]++}let G=R$(q[0],J,z,W?2:1);if(!G)throw new Z0("trying to redefine an already defined table or value",{toml:Y,ptr:H});X=G[2],K=G[1],H=q[1]}else{let W=j7(Y,H),q=R$(W[0],K,X,0);if(!q)throw new Z0("trying to redefine an already defined table or value",{toml:Y,ptr:H});let G=MZ(Y,W[1],void 0,Z,Q);q[1][q[0]]=G[0],H=G[1]}if(H=G1(Y,H,!0),Y[H]&&Y[H]!==`
|
|
260
|
+
`&&Y[H]!=="\r")throw new Z0("each key-value declaration must be followed by an end-of-line",{toml:Y,ptr:H});H=G1(Y,H)}return J}var O$=O(()=>{$9();U9();OZ();VY();/*!
|
|
261
261
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
262
262
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
263
263
|
*
|
|
@@ -283,16 +283,16 @@ ${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function J_(Y,Z){let Q=0
|
|
|
283
283
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
284
284
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
285
285
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
286
|
-
*/});function
|
|
286
|
+
*/});function DZ(Y){let Z=typeof Y;if(Z==="object"){if(Array.isArray(Y))return"array";if(Y instanceof Date)return"date"}return Z}function Nj(Y){for(let Z=0;Z<Y.length;Z++)if(DZ(Y[Z])!=="object")return!1;return Y.length!=0}function V9(Y){return JSON.stringify(Y).replace(/\x7f/g,"\\u007f")}function F9(Y,Z,Q,J){if(Q===0)throw Error("Could not stringify the object: maximum object depth exceeded");if(Z==="number"){if(isNaN(Y))return"nan";if(Y===1/0)return"inf";if(Y===-1/0)return"-inf";if(J&&Number.isInteger(Y))return Y.toFixed(1);return Y.toString()}if(Z==="bigint"||Z==="boolean")return Y.toString();if(Z==="string")return V9(Y);if(Z==="date"){if(isNaN(Y.getTime()))throw TypeError("cannot serialize invalid date");return Y.toISOString()}if(Z==="object")return _j(Y,Q,J);if(Z==="array")return Lj(Y,Q,J)}function _j(Y,Z,Q){let J=Object.keys(Y);if(J.length===0)return"{}";let z="{ ";for(let K=0;K<J.length;K++){let X=J[K];if(K)z+=", ";z+=M$.test(X)?X:V9(X),z+=" = ",z+=F9(Y[X],DZ(Y[X]),Z-1,Q)}return z+" }"}function Lj(Y,Z,Q){if(Y.length===0)return"[]";let J="[ ";for(let z=0;z<Y.length;z++){if(z)J+=", ";if(Y[z]===null||Y[z]===void 0)throw TypeError("arrays cannot contain null or undefined values");J+=F9(Y[z],DZ(Y[z]),Z-1,Q)}return J+" ]"}function wj(Y,Z,Q,J){if(Q===0)throw Error("Could not stringify the object: maximum object depth exceeded");let z="";for(let K=0;K<Y.length;K++)z+=`${z&&`
|
|
287
287
|
`}[[${Z}]]
|
|
288
|
-
`,z+=
|
|
289
|
-
`)+
|
|
290
|
-
`)+
|
|
291
|
-
`}}if(Y&&(X
|
|
292
|
-
${
|
|
293
|
-
${
|
|
288
|
+
`,z+=R9(0,Y[K],Z,Q,J);return z}function R9(Y,Z,Q,J,z){if(J===0)throw Error("Could not stringify the object: maximum object depth exceeded");let K="",X="",H=Object.keys(Z);for(let W=0;W<H.length;W++){let q=H[W];if(Z[q]!==null&&Z[q]!==void 0){let G=DZ(Z[q]);if(G==="symbol"||G==="function")throw TypeError(`cannot serialize values of type '${G}'`);let $=M$.test(q)?q:V9(q);if(G==="array"&&Nj(Z[q]))X+=(X&&`
|
|
289
|
+
`)+wj(Z[q],Q?`${Q}.${$}`:$,J-1,z);else if(G==="object"){let B=Q?`${Q}.${$}`:$;X+=(X&&`
|
|
290
|
+
`)+R9(B,Z[q],B,J-1,z)}else K+=$,K+=" = ",K+=F9(Z[q],G,J,z),K+=`
|
|
291
|
+
`}}if(Y&&(K||!X))K=K?`[${Y}]
|
|
292
|
+
${K}`:`[${Y}]`;return K&&X?`${K}
|
|
293
|
+
${X}`:K||X}function O9(Y,{maxDepth:Z=1000,numbersAsFloat:Q=!1}={}){if(DZ(Y)!=="object")throw TypeError("stringify can only be called with an object");let J=R9(0,Y,"",Z,Q);if(J[J.length-1]!==`
|
|
294
294
|
`)return J+`
|
|
295
|
-
`;return J}var
|
|
295
|
+
`;return J}var M$;var D$=O(()=>{/*!
|
|
296
296
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
297
297
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
298
298
|
*
|
|
@@ -318,7 +318,7 @@ ${H}`:X||H}function pQ(Y,{maxDepth:Z=1000,numbersAsFloat:Q=!1}={}){if(J4(Y)!=="o
|
|
|
318
318
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
319
319
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
320
320
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
321
|
-
*/
|
|
321
|
+
*/M$=/^[a-z0-9-_]+$/i});var N$=O(()=>{O$();D$();q9();VY();/*!
|
|
322
322
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
323
323
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
324
324
|
*
|
|
@@ -344,52 +344,51 @@ ${H}`:X||H}function pQ(Y,{maxDepth:Z=1000,numbersAsFloat:Q=!1}={}){if(J4(Y)!=="o
|
|
|
344
344
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
345
345
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
346
346
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
347
|
-
*/});var
|
|
348
|
-
Values that are expensive to get are cached for faster subsequent access.`,"cache.enabled":"Whether caching is enabled","cache.maxAgeMinutes":"Default maximum age of cache entries in minutes (some cache ignore this)",parallel:"Configuration for parallel worktree automation","parallel.init":"Comma-separated list specifying what to init for new forks (submodule, pkg)",defaultEditor:"Default code editor to open files with",enhancedOutput:"Whether to enhanced Git's output (modify the output of some git commands when conditions are met)"}});import
|
|
347
|
+
*/});var FY,_$,M9;var D9=O(()=>{W0();FY={llm:{provider:"openai",model:"gpt-5-nano",temperature:0.14,maxTokens:void 0,apiKey:void 0,baseUrl:void 0,showThinking:!1},lint:{onPushBehavior:"off",maxFileSizeKb:1024},stash:{undoLimit:10},commit:{commitPattern:"inherit",guidelineCacheDays:30},reword:{editor:null},cache:{enabled:!0,maxAgeMinutes:a8},parallel:{init:"submodule,env",envPaths:""},defaultEditor:"code",enhancedOutput:!0},_$={"llm.provider":"GDX_LLM_PROVIDER","llm.apiKey":"GDX_LLM_API_KEY","llm.baseUrl":"GDX_LLM_BASE_URL","llm.model":"GDX_LLM_MODEL","llm.temperature":"GDX_LLM_TEMPERATURE","llm.maxTokens":"GDX_LLM_MAX_TOKENS","llm.showThinking":"GDX_LLM_SHOW_THINKING","lint.onPushBehavior":"GDX_LINT_ON_PUSH_BEHAVIOR","lint.maxFileSizeKb":"GDX_LINT_MAX_FILE_SIZE_KB","stash.undoLimit":"GDX_STASH_UNDO_LIMIT","commit.commitPattern":"GDX_COMMIT_PATTERN","commit.guidelineCacheDays":"GDX_COMMIT_GUIDELINE_CACHE_DAYS","reword.editor":"GDX_REWORD_EDITOR","cache.enabled":"GDX_CACHE_ENABLED","cache.maxAgeMinutes":"GDX_CACHE_MAX_AGE_MINUTES","parallel.init":"GDX_PARALLEL_INIT","parallel.envPaths":"GDX_PARALLEL_ENV_PATHS",defaultEditor:"GDX_DEFAULT_EDITOR",enhancedOutput:"GDX_ENHANCED_OUTPUT"},M9={llm:"Configuration for the Language Model (LLM) integration","llm.provider":"LLM provider to use (e.g., openai)","llm.apiKey":"API key for the LLM provider","llm.baseUrl":"Base URL for the LLM API (optional)","llm.model":"Model to use for LLM requests","llm.temperature":"Temperature for LLM generation (0-2)","llm.maxTokens":"Maximum tokens for LLM responses","llm.showThinking":"Whether to show part of LLM reasoning messages",lint:"Configuration for post-commit linting","lint.onPushBehavior":"Lint behavior before push (off, error, warning)","lint.maxFileSizeKb":"Maximum allowed file size in KiB","stash.undoLimit":"Max number of stash drops to keep in history",commit:"Configuration for commit message generation","commit.commitPattern":"Commit message pattern (inherit: learn from repo, comprehensive: fixed format)","commit.guidelineCacheDays":"Days to cache learned commit guidelines per repository",reword:"Configuration for rewording commit messages","reword.editor":"Editor command used by gdx reword (overrides global editor when set)",cache:`Configuration for caching mechanism.
|
|
348
|
+
Values that are expensive to get are cached for faster subsequent access.`,"cache.enabled":"Whether caching is enabled","cache.maxAgeMinutes":"Default maximum age of cache entries in minutes (some cache ignore this)",parallel:"Configuration for parallel worktree automation","parallel.init":"Comma-separated list specifying what to init for new forks (submodule, env, pkg)","parallel.envPaths":"Colon-separated list of .gitignore patterns for env files to copy into new forks",defaultEditor:"Default code editor to open files with",enhancedOutput:"Whether to enhanced Git's output (modify the output of some git commands when conditions are met)"}});import RY from"fs";import N9 from"path";import jj from"os";var L$=null,T7,Tj,Ij,Cj,z0,R;var D0=O(()=>{H0();W0();v0();T7={off:-1,fatal:0,error:1,warn:2,info:3,debug:4,verbose:5},Tj={off:"BgBlue",fatal:"BgRed",error:"BgRed",warn:"BgYellow",info:"BgBlue",debug:"BgMagenta",verbose:"BgCyan"},Ij={off:"",fatal:"FATAL",error:"ERROR",warn:"WARN",info:"INFO",debug:"DEBUG",verbose:"VERBOSE"},Cj={off:"Cyan",fatal:"Red",error:"Red",warn:"Yellow",info:"Cyan",debug:"Magenta",verbose:"Blue"};z0=class z0{static logFile=N9.join(jj.tmpdir(),"gdx","gdx.log");static logLevel=T7[c.logLevel];static timeLabels=new Map;moduleName;static initialized=!1;static allLogs=[{timestamp:new Date().toISOString(),level:"info",message:`
|
|
349
349
|
|
|
350
350
|
=== New gdx session started ===
|
|
351
351
|
LocalMachineDate: ${new Date().toLocaleString()}
|
|
352
|
-
AppVersion: ${
|
|
352
|
+
AppVersion: ${E1}
|
|
353
353
|
Platform: ${process.platform}
|
|
354
354
|
Arch: ${process.arch}
|
|
355
|
-
`,module:"logger"}];constructor(Y){this.moduleName=Y,
|
|
356
|
-
`);else process.stdout.write(
|
|
357
|
-
`)}fatal(Y){
|
|
355
|
+
`,module:"logger"}];constructor(Y){this.moduleName=Y,z0.ensureInitialized()}static wouldLog(Y){return T7[Y]<=z0.logLevel}static ensureInitialized(){if(!z0.initialized){if(z0.initialized=!0,!WQ)return;z0.initializeLogDirectory(),process.on("exit",()=>z0.flushLogs())}}static initializeLogDirectory(){let Y=N9.dirname(z0.logFile);try{if(!RY.existsSync(Y))RY.mkdirSync(Y,{recursive:!0})}catch{}}static logInternal(Y,Z,Q){let z={timestamp:new Date().toISOString(),level:Y,message:Z,module:Q};if(L$)L$(z);if(T7[Y]<=T7[c.logLevel])z0.printMessage(Y,Z,Q);if(!WQ)return;z0.ensureInitialized(),z0.allLogs.push(z)}static printMessage(Y,Z,Q){let J=Tj[Y],z=Ij[Y],K=Cj[Y],X=o(Z,100,{indent:" "}),H=U(J)+U("Bright")+U("White")+` ${z} `+U()+U("Invert")+` ${Q} ${U()+U(K)} ${X}`+U();if(Y==="fatal"||Y==="error")process.stderr.write(H+`
|
|
356
|
+
`);else process.stdout.write(H+`
|
|
357
|
+
`)}fatal(Y){z0.logInternal("fatal",Y,this.moduleName)}error(Y){z0.logInternal("error",Y,this.moduleName)}warn(Y){z0.logInternal("warn",Y,this.moduleName)}info(Y){z0.logInternal("info",Y,this.moduleName)}debug(Y){z0.logInternal("debug",Y,this.moduleName)}verbose(Y){z0.logInternal("verbose",Y,this.moduleName)}time(Y,Z){if(!Z){z0.timeLabels.set(Y,performance.now());return}return z0.time(Y,Z,this.moduleName)}timeEnd(Y){z0.timeEnd(Y,this.moduleName)}async timeAsync(Y,Z){return await z0.timeAsync(Y,Z,this.moduleName)}static fatal(Y,Z="gdx"){z0.logInternal("fatal",Y,Z)}static error(Y,Z="gdx"){z0.logInternal("error",Y,Z)}static warn(Y,Z="gdx"){z0.logInternal("warn",Y,Z)}static info(Y,Z="gdx"){z0.logInternal("info",Y,Z)}static debug(Y,Z="gdx"){z0.logInternal("debug",Y,Z)}static verbose(Y,Z="gdx"){z0.logInternal("verbose",Y,Z)}static async timeAsync(Y,Z,Q="gdx"){let J=performance.now();try{return await Z()}finally{let z=performance.now(),K=pY.getTimeFromMS(z-J).modern();z0.debug(`${Y} took ${K}`,Q)}}static time(Y,Z,Q="gdx"){let J=performance.now();if(!Z){z0.timeLabels.set(Y,J);return}try{return Z()}finally{let z=performance.now(),K=pY.getTimeFromMS(z-J).modern();z0.debug(`${Y} took ${K}`,Q)}}static timeEnd(Y,Z="gdx"){let Q=performance.now(),J=z0.timeLabels.get(Y);if(J){let z=pY.getTimeFromMS(Q-J).modern();z0.debug(`${Y} took ${z}`,Z),z0.timeLabels.delete(Y)}else z0.warn(`No such label '${Y}' for timeEnd`,Z)}static flushLogs(){if(z0.allLogs.length===0)return;try{let Y=N9.dirname(z0.logFile);if(!RY.existsSync(Y))RY.mkdirSync(Y,{recursive:!0});let Z="";if(RY.existsSync(z0.logFile))Z=RY.readFileSync(z0.logFile,"utf-8");let Q=z0.allLogs.map(({timestamp:K,level:X,message:H,module:W})=>{let q=X.toUpperCase().padEnd(5);return H=o(RK(H),100,{indent:33,redundancyLv:-1,mode:"strict"}),`${K} [${q}] ${W}: ${H}`}).join(`
|
|
358
358
|
`),J=Z?Z+`
|
|
359
|
-
`+Q:Q;if(Buffer.byteLength(J,"utf-8")>
|
|
360
|
-
`),
|
|
361
|
-
`)}
|
|
362
|
-
`+
|
|
363
|
-
`+n.from(H).toString({color:!0}))}J[z]=Z}getAll(){return this.config}getConfigPath(){return this.configPath}isDefault(Y){let Z=Y.split("."),Q=this.config,J=Z1;for(let z of Z){if(Q&&typeof Q==="object"&&z in Q)Q=Q[z];else Q=void 0;if(J&&typeof J==="object"&&z in J)J=J[z];else J=void 0}return Q===J}mergeConfig(Y,Z){let Q=structuredClone(Y),J=(z,X,H="")=>{for(let W in X){let K=H?`${H}.${W}`:W,$=X[W],G=z[W];if(G===void 0)continue;if(typeof $==="object"&&$!==null&&!Array.isArray($))if(typeof G==="object"&&G!==null)J(z[W],$,K);else this.logger.warn(`Type mismatch for '${K}'. Expected ${typeof G}, got object. Ignoring value.`);else if(typeof $!==typeof G)this.logger.warn(`Type mismatch for '${K}'. Expected ${typeof G}, got ${typeof $}. Ignoring value.`);else z[W]=$}};return J(Q,Z),Q}removeSecureKeys(Y){let Z=structuredClone(Y);for(let Q of X6){let J=Q.split("."),z=Z;for(let X=0;X<J.length-1;X++){if(!z[J[X]])return Z;z=z[J[X]]}delete z[J[J.length-1]]}return Z}async deleteSecureKey(Y){if(!X6.includes(Y))return!1;try{return await(await nQ()).deletePassword(_Z,Y)}catch{return!1}}applyEnvOverrides(){for(let[Y,Z]of Object.entries(yq)){let Q=process.env[Z];if(Q!==void 0){let J=this.get(Y),z=Q;if(typeof J==="number"){let X=Number(Q);if(!isNaN(X))z=X;else{this.logger.warn(`Environment variable ${Z} has invalid number value '${Q}'. Ignoring.`);continue}}else if(typeof J==="boolean")z=Q.toLowerCase()==="true";this.set(Y,z)}}}}function N_(){let Y=process.env.GDX_CONFIG_PATH;if(Y)return Y;if(o(A8))return A8;if(o(P5))return P5;return A8}async function q0(){if(!J2)J2=new hq(N_()),await J2.load();return J2}var bq=null,J2=null;var FY=R(()=>{vq();u0();lQ();W0();z0();$0()});import w_ from"path";class mq{cachePath;isDisabled=!1;cache={...gq};memoryData={};memoryEntryMeta={};loaded=!1;dirty=!1;loadingPromise=null;logger=new D("cache");constructor(Y){this.cachePath=Y||JY}async ensureLoaded(){if(this.loaded)return;if(this.loadingPromise){await this.loadingPromise;return}this.loadingPromise=this.load();try{await this.loadingPromise}finally{this.loadingPromise=null}}pruneExpiredKeys(){let Y=Date.now(),Z=0,Q=[];for(let[J,z]of Object.entries(this.cache.entryMeta))if(Y>z.expiresAt)Q.push(J);for(let J of Q){delete this.cache.entryMeta[J];let z=J.split("."),X=[],H=this.cache.data;for(let W of z)if(H&&typeof H==="object"&&W in H)X.push({obj:H,key:W}),H=H[W];else break;if(X.length>0){let W=X[X.length-1];delete W.obj[W.key],Z++}for(let W=X.length-2;W>=0;W--){let{obj:K,key:$}=X[W],G=K[$];if(G&&typeof G==="object"&&Object.keys(G).length===0)delete K[$];else break}}if(this.cache.meta.lastPruneAt=Y,Z>0)this.cache.meta.updatedAt=Y,this.dirty=!0;return Z}async load(){if(this.loaded)return;if(!(await q0()).get("cache.enabled")){this.resetCache(!1),this.loaded=!0,this.isDisabled=!0,this.logger.debug("Cache is disabled via configuration");return}try{let Z=await QY(this.cachePath,"utf-8"),Q=JSON.parse(Z);if(!Q.meta||!Q.data){this.resetCache(!1),this.loaded=!0;return}if(Q.meta.version!==l0){this.logger.debug(`Cache version mismatch: stored=${Q.meta.version}, current=${l0}. Resetting cache.`),this.resetCache(!1),this.loaded=!0;return}if(!Q.entryMeta||!Q.meta.lastPruneAt){this.logger.debug("Existing cache file' schema mismatch; resetting cache to newer version"),this.resetCache(!1),this.loaded=!0;return}this.cache=Q;let z=(Date.now()-this.cache.meta.lastPruneAt)/jZ;if(z>=JX){this.logger.debug(`Last prune was ${z.toFixed(1)} days ago. Running cache pruning...`);let X=this.pruneExpiredKeys();if(X>0)this.logger.debug(`Pruned ${X} expired cache entries`);else this.logger.debug("No expired entries found during pruning")}}catch(Z){let Q=new n(Z);if(Q.code!=="ENOENT")this.logger.debug(`Failed to parse cache file at ${this.cachePath}: ${Q.message}`);this.resetCache(!1)}this.loaded=!0}resetCache(Y=!0){if(this.cache=structuredClone(gq),Y)this.dirty=!0}resetMemoryCache(){this.memoryData={},this.memoryEntryMeta={}}async get(Y,Z){if(this.isDisabled)return Z;await this.ensureLoaded();let Q=this.cache.entryMeta[Y];if(!Q)return this.logger.debug(`Cache ${Y} missed.`),Z;if(Date.now()>Q.expiresAt)return this.logger.debug(`Cache entry expired: ${Y}. expiresAt=${new Date(Q.expiresAt).toISOString()}, now=${new Date().toISOString()}`),await this.delete(Y),Z;let J=Y.split("."),z=this.cache.data;for(let X of J)if(z&&typeof z==="object"&&X in z)z=z[X];else return Z;return this.logger.debug(`Cache ${Y} hit.`),z}async getOneOff(Y,Z){if(await this.ensureLoaded(),this.isDisabled)return Z;if(!this.memoryEntryMeta[Y])return this.logger.debug(`Memory cache ${Y} missed.`),Z;let J=Y.split("."),z=this.memoryData;for(let X of J)if(z&&typeof z==="object"&&X in z)z=z[X];else return Z;return this.logger.debug(`Memory cache ${Y} hit.`),z}async set(Y,Z,Q){if(this.isDisabled)return;let J=await q0();await this.ensureLoaded();let z=Y.split("."),X=this.cache.data,H=Q?.maxAgeMinutes??J.get("cache.maxAgeMinutes")??TZ;this.logger.debug(`Setting cache ${Y} with maxAgeMinutes=${H}`);for(let $=0;$<z.length-1;$++){let G=z[$];if(!(G in X)||typeof X[G]!=="object")X[G]={};X=X[G]}let W=z[z.length-1];X[W]=Z;let K=Date.now();this.cache.entryMeta[Y]={createdAt:this.cache.entryMeta[Y]?.createdAt??K,updatedAt:K,expiresAt:K+H*60*1000},this.cache.meta.updatedAt=K,this.dirty=!0}async setOneOff(Y,Z){if(await this.ensureLoaded(),this.isDisabled)return;let Q=Y.split("."),J=this.memoryData;this.logger.debug(`Setting memory cache ${Y}`);for(let H=0;H<Q.length-1;H++){let W=Q[H];if(!(W in J)||typeof J[W]!=="object")J[W]={};J=J[W]}let z=Q[Q.length-1];J[z]=Z;let X=Date.now();this.memoryEntryMeta[Y]={createdAt:this.memoryEntryMeta[Y]?.createdAt??X,updatedAt:X}}async delete(Y){if(this.isDisabled)return!1;if(await this.ensureLoaded(),!this.cache.entryMeta[Y])return!1;delete this.cache.entryMeta[Y];let Z=Y.split("."),Q=[],J=this.cache.data;for(let z of Z)if(J&&typeof J==="object"&&z in J)Q.push({obj:J,key:z}),J=J[z];else return!1;if(Q.length>0){let z=Q[Q.length-1];delete z.obj[z.key]}for(let z=Q.length-2;z>=0;z--){let{obj:X,key:H}=Q[z],W=X[H];if(W&&typeof W==="object"&&Object.keys(W).length===0)delete X[H];else break}return this.cache.meta.updatedAt=Date.now(),this.dirty=!0,this.logger.debug(`Cache entry deleted: ${Y}`),!0}async deleteOneOff(Y){if(await this.ensureLoaded(),this.isDisabled)return!1;if(!this.memoryEntryMeta[Y])return!1;delete this.memoryEntryMeta[Y];let Z=Y.split("."),Q=[],J=this.memoryData;for(let z of Z)if(J&&typeof J==="object"&&z in J)Q.push({obj:J,key:z}),J=J[z];else return!1;if(Q.length>0){let z=Q[Q.length-1];delete z.obj[z.key]}for(let z=Q.length-2;z>=0;z--){let{obj:X,key:H}=Q[z],W=X[H];if(W&&typeof W==="object"&&Object.keys(W).length===0)delete X[H];else break}return this.logger.debug(`Memory cache entry deleted: ${Y}`),!0}async getAll(){return await this.ensureLoaded(),this.cache}getCachePath(){return this.cachePath}flush(){if(!this.dirty)return;try{let Y=w_.dirname(this.cachePath);ZY(Y,{recursive:!0});let Z=JSON.stringify(this.cache);Q6(this.cachePath,Z,"utf-8"),this.dirty=!1,this.logger.debug(`Cache flushed to ${this.cachePath}`)}catch(Y){let Z=new n(Y);this.logger.warn(`Failed to flush cache: ${Z.message}`)}}async clear(){await this.ensureLoaded(),this.resetCache(),this.resetMemoryCache()}}async function X0(){if(!F6){if(F6=new mq,await F6.ensureLoaded(),!F6.isDisabled)L_()}return F6}function z2(){F6=null}function L_(){D.debug("Registering cache flush hook on exit","cache"),vz(()=>{if(F6)F6.flush()})}var gq,F6=null;var R6=R(()=>{u0();W0();z0();$0();FY();gq={meta:{version:l0,createdAt:Date.now(),updatedAt:Date.now(),lastPruneAt:Date.now()},data:{},entryMeta:{}}});async function uq(Y,Z){let Q=await X0(),J=`which.${Y}`,z=await Q.get(J);if(z!=null&&o(z))return D.debug(`Cache hit for ${J}`,"cache-ctrl"),z;try{let X=Z?await Z():await M6(Y);if(!X)return null;return await Q.set(J,X),D.debug(`Cache store for ${J}: ${X}`,"cache-ctrl"),X}catch(X){throw D.warn(`Failed to get which exec for ${Y}: ${X}`,"cache-ctrl"),X}}var dq=R(()=>{k0();R6();$0();u0()});import s1 from"path";import{createInterface as __}from"readline";import{writeFile as I_}from"fs/promises";import{unlink as j_}from"fs/promises";function r1(Y={}){let Z=new AbortController;return{$:IY({cancelSignal:Z.signal,...Y,verbose:aQ}),abort:()=>Z.abort(),signal:Z.signal}}async function z4(Y){let Z=__({input:process.stdin,output:process.stdout});return new Promise((Q)=>{Z.question(Y,(J)=>{Z.close(),Q(J.trim())})})}async function M6(Y){return await uq(Y,async()=>{if(Y.includes(s1.sep)){let X=s1.resolve(Y);return await k5(X)?X:null}let Z=process.platform==="win32",Q=[""];if(Z)Q=["",...(process.env.PATHEXT||".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH").split(";").filter(Boolean)];let J=[];if(J.push(process.cwd()),process.argv[1])J.push(s1.dirname(process.argv[1]));if(J.push(s1.dirname(process.execPath)),process.env.PATH)J.push(...process.env.PATH.split(s1.delimiter));let z=[...new Set(J)];for(let X of z){if(!X)continue;for(let H of Q){let W=s1.join(X,Y+H);if(await k5(W))return W}}return null})}async function X2(Y){try{switch(process.platform){case"win32":return await S({input:Y})`clip`,!0;case"darwin":return await S({input:Y})`pbcopy`,!0;case"linux":try{return await S({input:Y})`xclip -selection clipboard`,!0}catch{return await S({input:Y})`xsel --clipboard --input`,!0}default:return!1}}catch{return!1}}function d0(Y={}){let Z=!Y.message;if(Y={message:"",interval:80,frames:ZX,animateGradient:!1,gradientColor:A.Zinc100,gradientColorBg:A.Zinc700,gradientSpeed:0.11,...Y},!process.stdout.isTTY)return{stop:()=>{},start:(K=!0)=>{if(K)process.stdout.write(`
|
|
364
|
-
`)},options:Y};let Q=0,J=0,z=!0,
|
|
365
|
-
`:"")),z=!0,
|
|
366
|
-
`+
|
|
367
|
-
`).map((
|
|
368
|
-
`).map((
|
|
369
|
-
`).filter((
|
|
370
|
-
`)){if(!
|
|
371
|
-
`).map((I)=>I.trim()).filter((I)=>I.length>0).map((I)=>{return I.match(/^submodule\.(.+?)\.path\s+(.+)$/)?.[2]?.trim()??""}).filter((I)=>I.length>0)}catch{
|
|
372
|
-
`).map((
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
`).map((
|
|
376
|
-
|
|
377
|
-
${Y+u("STASH DROP",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
359
|
+
`+Q:Q;if(Buffer.byteLength(J,"utf-8")>hK){let K=J.split(`
|
|
360
|
+
`),X=Math.floor(K.length/2);J=K.slice(X).join(`
|
|
361
|
+
`)}RY.writeFileSync(z0.logFile,J,"utf-8")}catch{}}};R=z0});import Aj from"path";async function _9(){w$??=import("keytar");let Y=await w$,Z=Y.default??Y;if(!Z||typeof Z.setPassword!=="function")throw new a("Keytar module does not expose setPassword.","KEYTAR_INVALID");return Z}class j${configPath;config=structuredClone(FY);loaded=!1;logger=new R("ConfigService");constructor(Y){this.configPath=Y||i4}async load(){if(this.loaded)return;try{let Y=await S0(this.configPath,"utf-8"),Z=B9(Y);this.config=this.mergeConfig(FY,Z)}catch(Y){let Z=new a(Y);if(Z.code!=="ENOENT")this.logger.warn(`Failed to parse config file at ${this.configPath}: ${Z.message}`);this.config=structuredClone(FY)}this.applyEnvOverrides(),this.loaded=!0}async save(){let Y=this.removeSecureKeys(this.config),Z=O9(Y),Q=Aj.dirname(this.configPath);if(!l(Q))H1(Q,{recursive:!0});await Y1(this.configPath,Z,"utf-8")}get(Y,Z){let Q=Y.split("."),J=this.config;for(let z of Q)if(J&&typeof J==="object"&&z in J)J=J[z];else return Z;return J}async getSecure(Y,Z){let Q=this.get(Y);if(Q!==void 0)return Q;if(L6.includes(Y))try{let z=await(await _9()).getPassword(n8,Y);if(z){let K=Y.split("."),X=this.config;for(let H=0;H<K.length-1;H++){let W=K[H];if(!(W in X)||typeof X[W]!=="object")X[W]={};X=X[W]}return X[K[K.length-1]]=z,z}}catch(J){this.logger.warn(`Failed to load secure key '${Y}' from keychain:
|
|
362
|
+
`+a.from(J).toString({color:!0}))}return Z}async set(Y,Z){let Q=Y.split("."),J=this.config;for(let X=0;X<Q.length-1;X++){let H=Q[X];if(!(H in J)||typeof J[H]!=="object")J[H]={};J=J[H]}let z=Q[Q.length-1],K=this.get(Y);if(K!==void 0){if(K===null){if(Z!==null&&typeof Z!=="string"){this.logger.warn(`Type mismatch for '${Y}'. Expected string or null, got ${typeof Z}. Ignoring value.`);return}}else if(typeof Z!==typeof K){this.logger.warn(`Type mismatch for '${Y}'. Expected ${typeof K}, got ${typeof Z}. Ignoring value.`);return}}if(L6.includes(Y))try{await(await _9()).setPassword(n8,Y,String(Z))}catch(X){this.logger.warn(`Failed to save secure key '${Y}' to keychain:
|
|
363
|
+
`+a.from(X).toString({color:!0}))}J[z]=Z}getAll(){return this.config}getConfigPath(){return this.configPath}isDefault(Y){let Z=Y.split("."),Q=this.config,J=FY;for(let z of Z){if(Q&&typeof Q==="object"&&z in Q)Q=Q[z];else Q=void 0;if(J&&typeof J==="object"&&z in J)J=J[z];else J=void 0}return Q===J}mergeConfig(Y,Z){let Q=structuredClone(Y),J=(z,K,X="")=>{for(let H in K){let W=X?`${X}.${H}`:H,q=K[H],G=z[H];if(G===void 0)continue;if(typeof q==="object"&&q!==null&&!Array.isArray(q))if(typeof G==="object"&&G!==null)J(z[H],q,W);else this.logger.warn(`Type mismatch for '${W}'. Expected ${typeof G}, got object. Ignoring value.`);else if(G===null)if(q===null||typeof q==="string")z[H]=q;else this.logger.warn(`Type mismatch for '${W}'. Expected string or null, got ${typeof q}. Ignoring value.`);else if(typeof q!==typeof G)this.logger.warn(`Type mismatch for '${W}'. Expected ${typeof G}, got ${typeof q}. Ignoring value.`);else z[H]=q}};return J(Q,Z),Q}removeSecureKeys(Y){let Z=structuredClone(Y);for(let Q of L6){let J=Q.split("."),z=Z;for(let K=0;K<J.length-1;K++){if(!z[J[K]])return Z;z=z[J[K]]}delete z[J[J.length-1]]}return Z}async deleteSecureKey(Y){if(!L6.includes(Y))return!1;try{return await(await _9()).deletePassword(n8,Y)}catch{return!1}}applyEnvOverrides(){for(let[Y,Z]of Object.entries(_$)){let Q=process.env[Z];if(Q!==void 0){let J=this.get(Y),z=Q;if(J===null)z=Q;else if(typeof J==="number"){let K=Number(Q);if(!isNaN(K))z=K;else{this.logger.warn(`Environment variable ${Z} has invalid number value '${Q}'. Ignoring.`);continue}}else if(typeof J==="boolean")z=Q.toLowerCase()==="true";this.set(Y,z)}}}}function kj(){let Y=process.env.GDX_CONFIG_PATH;if(Y)return Y;if(l(i4))return i4;if(l(HQ))return HQ;return i4}async function O0(){if(!I7)I7=new j$(kj()),await I7.load();return I7}var w$=null,I7=null;var w1=O(()=>{N$();o0();D9();W0();H0();D0()});var U4=(Y)=>{return Y.map=(Z)=>U4((Q)=>Z(Y(Q))),Y.or=(Z)=>U4((Q)=>{try{return Y(Q)}catch(J){return Z(Q)}}),Y},L9=()=>"bad banditype"(),T$=()=>U4((Y)=>Y),I$=(Y)=>U4((Z)=>Y.includes(Z)?Z:L9()),C$=(Y)=>U4((Z)=>typeof Z===typeof Y?Z:L9()),A$=()=>C$(""),OY=()=>C$(0),k$=(Y)=>U4((Z)=>Z instanceof Y?Z:L9()),w9=(Y)=>k$(Object).map((Z)=>{let Q={};for(let J in Z){let z=Y(Z[J]);z!==void 0&&(Q[J]=z)}return Q}),C7=(Y)=>k$(Object).map((Z)=>{let Q={};for(let J in Y){let z=Y[J](Z[J]);z!==void 0&&(Q[J]=z)}return Q});var E$=()=>{};var xj,Sj,A7;var j9=O(()=>{E$();W0();xj=C7({version:A$(),cacheSchemaVersion:I$([l8]),createdAt:OY(),updatedAt:OY(),lastPruneAt:OY()}),Sj=C7({createdAt:OY(),updatedAt:OY(),expiresAt:OY()}),A7=C7({meta:xj,data:w9(T$()),entryMeta:w9(Sj)})});import Pj from"path";class S${cachePath;isDisabled=!1;cache={...x$};memoryData={};memoryEntryMeta={};loaded=!1;dirty=!1;loadingPromise=null;logger=new R("cache");constructor(Y){this.cachePath=Y||M1}async ensureLoaded(){if(this.loaded)return;if(this.loadingPromise){await this.loadingPromise;return}this.loadingPromise=this.load();try{await this.loadingPromise}finally{this.loadingPromise=null}}pruneExpiredKeys(){let Y=Date.now(),Z=0,Q=[];for(let[J,z]of Object.entries(this.cache.entryMeta))if(Y>z.expiresAt)Q.push(J);for(let J of Q){delete this.cache.entryMeta[J];let z=J.split("."),K=[],X=this.cache.data;for(let H of z)if(X&&typeof X==="object"&&H in X)K.push({obj:X,key:H}),X=X[H];else break;if(K.length>0){let H=K[K.length-1];delete H.obj[H.key],Z++}for(let H=K.length-2;H>=0;H--){let{obj:W,key:q}=K[H],G=W[q];if(G&&typeof G==="object"&&Object.keys(G).length===0)delete W[q];else break}}if(this.cache.meta.lastPruneAt=Y,Z>0)this.cache.meta.updatedAt=Y,this.dirty=!0;return Z}async load(){if(this.loaded)return;if(!(await O0()).get("cache.enabled")){this.resetCache(!1),this.loaded=!0,this.isDisabled=!0,this.logger.debug("Cache is disabled via configuration");return}try{let Z=await S0(this.cachePath,"utf-8"),Q=JSON.parse(Z);try{A7(Q)}catch{this.logger.warn("Cache file structure is outdated or invalid. Cache will be reset on next write."),this.resetCache(!1),this.loaded=!0;return}if(Q.meta.version!==E1)this.logger.debug(`App version mismatch: stored=${Q.meta.version}, current=${E1}. Updating version number.`),Q.meta.version=E1,this.dirty=!0;this.cache=Q;let z=(Date.now()-this.cache.meta.lastPruneAt)/i8;if(z>=fK){this.logger.debug(`Last prune was ${z.toFixed(1)} days ago. Running cache pruning...`);let K=this.pruneExpiredKeys();if(K>0)this.logger.debug(`Pruned ${K} expired cache entries`);else this.logger.debug("No expired entries found during pruning")}}catch(Z){let Q=new a(Z);if(Q.code!=="ENOENT")this.logger.debug(`Failed to parse cache file at ${this.cachePath}: ${Q.message}`);this.resetCache(!1)}this.loaded=!0}resetCache(Y=!0){if(this.cache=structuredClone(x$),Y)this.dirty=!0}resetMemoryCache(){this.memoryData={},this.memoryEntryMeta={}}async get(Y,Z){if(this.isDisabled)return Z;await this.ensureLoaded();let Q=this.cache.entryMeta[Y];if(!Q)return this.logger.debug(`Cache ${Y} missed.`),Z;if(Date.now()>Q.expiresAt)return this.logger.debug(`Cache entry expired: ${Y}. expiresAt=${new Date(Q.expiresAt).toISOString()}, now=${new Date().toISOString()}`),await this.delete(Y),Z;let J=Y.split("."),z=this.cache.data;for(let K of J)if(z&&typeof z==="object"&&K in z)z=z[K];else return Z;return this.logger.debug(`Cache ${Y} hit.`),z}async getOneOff(Y,Z){if(await this.ensureLoaded(),this.isDisabled)return Z;if(!this.memoryEntryMeta[Y])return this.logger.debug(`Memory cache ${Y} missed.`),Z;let J=Y.split("."),z=this.memoryData;for(let K of J)if(z&&typeof z==="object"&&K in z)z=z[K];else return Z;return this.logger.debug(`Memory cache ${Y} hit.`),z}async set(Y,Z,Q){if(this.isDisabled)return;let J=await O0();await this.ensureLoaded();let z=Y.split("."),K=this.cache.data,X=Q?.maxAgeMinutes??J.get("cache.maxAgeMinutes")??a8;this.logger.debug(`Setting cache ${Y} with maxAgeMinutes=${X}`);for(let q=0;q<z.length-1;q++){let G=z[q];if(!(G in K)||typeof K[G]!=="object")K[G]={};K=K[G]}let H=z[z.length-1];K[H]=Z;let W=Date.now();this.cache.entryMeta[Y]={createdAt:this.cache.entryMeta[Y]?.createdAt??W,updatedAt:W,expiresAt:W+X*60*1000},this.cache.meta.updatedAt=W,this.dirty=!0}async setOneOff(Y,Z){if(await this.ensureLoaded(),this.isDisabled)return;let Q=Y.split("."),J=this.memoryData;this.logger.debug(`Setting memory cache ${Y}`);for(let X=0;X<Q.length-1;X++){let H=Q[X];if(!(H in J)||typeof J[H]!=="object")J[H]={};J=J[H]}let z=Q[Q.length-1];J[z]=Z;let K=Date.now();this.memoryEntryMeta[Y]={createdAt:this.memoryEntryMeta[Y]?.createdAt??K,updatedAt:K}}async delete(Y){if(this.isDisabled)return!1;if(await this.ensureLoaded(),!this.cache.entryMeta[Y])return!1;delete this.cache.entryMeta[Y];let Z=Y.split("."),Q=[],J=this.cache.data;for(let z of Z)if(J&&typeof J==="object"&&z in J)Q.push({obj:J,key:z}),J=J[z];else return!1;if(Q.length>0){let z=Q[Q.length-1];delete z.obj[z.key]}for(let z=Q.length-2;z>=0;z--){let{obj:K,key:X}=Q[z],H=K[X];if(H&&typeof H==="object"&&Object.keys(H).length===0)delete K[X];else break}return this.cache.meta.updatedAt=Date.now(),this.dirty=!0,this.logger.debug(`Cache entry deleted: ${Y}`),!0}async deleteOneOff(Y){if(await this.ensureLoaded(),this.isDisabled)return!1;if(!this.memoryEntryMeta[Y])return!1;delete this.memoryEntryMeta[Y];let Z=Y.split("."),Q=[],J=this.memoryData;for(let z of Z)if(J&&typeof J==="object"&&z in J)Q.push({obj:J,key:z}),J=J[z];else return!1;if(Q.length>0){let z=Q[Q.length-1];delete z.obj[z.key]}for(let z=Q.length-2;z>=0;z--){let{obj:K,key:X}=Q[z],H=K[X];if(H&&typeof H==="object"&&Object.keys(H).length===0)delete K[X];else break}return this.logger.debug(`Memory cache entry deleted: ${Y}`),!0}async getAll(){return await this.ensureLoaded(),this.cache}getCachePath(){return this.cachePath}flush(){if(!this.dirty)return;try{let Y=Pj.dirname(this.cachePath);H1(Y,{recursive:!0});let Z=JSON.stringify(this.cache);r6(this.cachePath,Z,"utf-8"),this.dirty=!1,this.logger.debug(`Cache flushed to ${this.cachePath}`)}catch(Y){let Z=new a(Y);this.logger.warn(`Failed to flush cache: ${Z.message}`)}}async clear(){await this.ensureLoaded(),this.resetCache(),this.resetMemoryCache()}}async function B0(){if(!x6){if(x6=new S$,await x6.ensureLoaded(),!x6.isDisabled)vj()}return x6}function k7(){x6=null}function vj(){R.debug("Registering cache flush hook on exit","cache"),FK(()=>{if(x6)x6.flush()})}var x$,x6=null;var S6=O(()=>{o0();H0();W0();D0();w1();j9();x$={meta:{version:E1,cacheSchemaVersion:l8,createdAt:Date.now(),updatedAt:Date.now(),lastPruneAt:Date.now()},data:{},entryMeta:{}}});async function P$(Y,Z){let Q=await B0(),J=`which.${Y}`,z=await Q.get(J);if(z!=null&&l(z))return R.debug(`Cache hit for ${J}`,"cache-ctrl"),z;try{let K=Z?await Z():await c1(Y);if(!K)return null;return await Q.set(J,K),R.debug(`Cache store for ${J}: ${K}`,"cache-ctrl"),K}catch(K){throw R.warn(`Failed to get which exec for ${Y}: ${K}`,"cache-ctrl"),K}}var v$=O(()=>{h0();S6();D0();o0()});import $4 from"path";import{createInterface as yj}from"readline";import{writeFile as fj}from"fs/promises";import{unlink as bj}from"fs/promises";function B4(Y={}){let Z=new AbortController;return{$:p1({cancelSignal:Z.signal,...Y,verbose:I9}),abort:()=>Z.abort(),signal:Z.signal}}async function NZ(Y){let Z=yj({input:process.stdin,output:process.stdout});return new Promise((Q)=>{Z.question(Y,(J)=>{Z.close(),Q(J.trim())})})}async function c1(Y){return await P$(Y,async()=>{if(Y.includes($4.sep)){let K=$4.resolve(Y);return await JQ(K)?K:null}let Z=process.platform==="win32",Q=[""];if(Z)Q=["",...(process.env.PATHEXT||".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH").split(";").filter(Boolean)];let J=[];if(J.push(process.cwd()),process.argv[1])J.push($4.dirname(process.argv[1]));if(J.push($4.dirname(process.execPath)),process.env.PATH)J.push(...process.env.PATH.split($4.delimiter));let z=[...new Set(J)];for(let K of z){if(!K)continue;for(let X of Q){let H=$4.join(K,Y+X);if(await JQ(H))return H}}return null})}async function E7(Y){try{switch(process.platform){case"win32":return await S({input:Y})`clip`,!0;case"darwin":return await S({input:Y})`pbcopy`,!0;case"linux":try{return await S({input:Y})`xclip -selection clipboard`,!0}catch{return await S({input:Y})`xsel --clipboard --input`,!0}default:return!1}}catch{return!1}}function d0(Y={}){let Z=!Y.message;if(Y={message:"",interval:70,frames:vK,animateGradient:!1,gradientColor:k.Zinc100,gradientColorBg:k.Zinc700,gradientSpeed:0.11,gradientInterval:3,...Y},!process.stdout.isTTY)return{stop:()=>{},start:(W=!0)=>{if(W)process.stdout.write(`
|
|
364
|
+
`)},setMessage:(W)=>{},options:Y};let Q=0,J=0,z=!0,K=null,X=U(),H=()=>{if(!z)return;let W=Y.frames[Q%Y.frames.length];if(Y.message)if(Y.animateGradient&&l0.supportsColor>=3){let q=J%Y.gradientInterval;if(q<=1){let G=aK.easeInOut(q),$=nK(Y.message,Y.gradientColor,Y.gradientColorBg,G,0.3);W+=" "+$}else W+=" "+U(zY(Y.gradientColorBg))+Y.message+X;J+=Y.gradientSpeed??0.1}else W+=" "+Y.message;process.stdout.write("\r\x1B[K"+W),Q++};if(!Z)K=setInterval(H,Y.interval),process.stdout.write("\x1B[?25l"),H();return{stop:()=>{if(z=!1,K)clearInterval(K),K=null;process.stdout.write("\r\x1B[K\x1B[?25h")},start:(W=!0)=>{if(!z)process.stdout.write("\x1B[?25l"+(W?`
|
|
365
|
+
`:"")),z=!0,K=setInterval(H,Y.interval)},setMessage:(W)=>{Y.message=W,H()},options:Y}}async function f$(Y){let Q=(await O0()).getAll().defaultEditor,J=await c1(Q);if(!J)throw new a(`Default editor "${Q}" not found in PATH. Set a valid editor in the configuration.`,"EDITOR_NOT_FOUND");await V0`${J} ${Y}`}async function _Z(Y){if(!Y){if(Q6)await bj(Q6).catch(k1);c.exitCodeOverride=-1;return}if(Q6)await fj(Q6,Y,"utf-8");c.exitCodeOverride=ZY}function LZ(Y){let Z=[],Q="",J=!1,z=!1;for(let K=0;K<Y.length;K++){let X=Y[K];if(X==="'"&&!z)J=!J;else if(X==='"'&&!J)z=!z;else if(X===" "&&!J&&!z){if(Q)Z.push(Q),Q=""}else Q+=X}if(Q)Z.push(Q);return Z}async function x7(Y,Z,Q=null,J=">"){let z=0;try{if(Q){let{exitCode:K}=await p1({stdout:{file:Q,append:J===">>"},stderr:"inherit"})`${Y} ${Z}`;z=K}else{let{exitCode:K}=await V0`${Y} ${Z}`;z=K}}catch(K){let X=a.from(K),H=K.signal;if(H)X.code=H;if(X.code==="SIGINT"||X.code==="SIGTERM"||X.code==="SIGABRT"||X.code==="SIGKILL")return R.debug(`Git command was killed by signal: ${X.code}. Treating as failure with exit code 1.`),R.verbose("Full error details: "+g(X,{color:!0})),1;if(X.code==="ENOENT")return R.error(`Git executable not found: "${Y}". Ensure git is installed and in your PATH.`),1;if(X.code==="EACCES")return R.error(`Permission denied when trying to execute git: "${Y}". Check your permissions for this executable.`),1;if(X.code==="SIGPIPE")return R.debug("Git command failed with SIGPIPE. This may indicate that the pipe was no longer inuse by the consumer process."),1;if(X.name===_1.name&&X.message.startsWith("Command failed"))return z||1;return R.error(`Command failed.
|
|
366
|
+
`+g(X,{color:!0})),1}return z??0}function I9(Y,Z){if(Z.type!=="duration")return;let Q="done";if(Z.result.failed)Q="FAILED";else if(Z.result.timedOut)Q="TIMEOUT";else if(Z.result.isCanceled)Q="CANCELED";else if(Z.result.isTerminated)Q="TERMINATED";hj.debug(`${mj+y$}$ ${gj+Z.escapedCommand+y$} (${Q} in ${Z.result.durationMs}ms)`)}var hj,y$,gj,mj,T9=()=>process.stdout.isTTY&&process.stdin.isTTY,S,V0;var h0=O(()=>{_7();H0();L0();A0();W0();w1();v0();v$();D0();hj=new R("shell"),y$=U("Dim"),gj=U(),mj=U("Bright"),S=p1({stdout:"pipe",stderr:"pipe",verbose:I9});V0=p1({stdout:"inherit",stderr:"inherit",verbose:I9})});import k9 from"crypto";import F0 from"path";function s0(Y,Z){let Q=k9.createHash("sha1").update(Z).digest("hex");return`${Y}.${Q}`}function j1(Y,Z){let Q=Array.isArray(Y)?Y.join(" "):Y,J=Z?F0.resolve(Z):process.cwd();return`${Q}|${J}`}async function V4(Y){try{await S`${Y} rev-parse --is-inside-work-tree`}catch{return R.error("This command must be run inside a git repository.","git"),!1}return!0}async function E9(Y,Z){let Q=await B0(),J=s0("git.stashEntry",`${j1(Y)}|${Z}`),z=await Q.getOneOff(J);if(z!==void 0)return z;try{let K=`stash@{${Z}}`,{stdout:X}=await S`${Y} rev-parse ${K}`,{stdout:H}=await S`${Y} log -1 --format=%s ${K}`,W={sha:X.trim(),message:H.trim()};return await Q.setOneOff(J,W),W}catch{return await Q.setOneOff(J,null),null}}async function h$(Y,Z,Q){await S`${Y} stash store -m ${Q} ${Z}`}function uj(Y){let Z=Y.trim();if(!Z)return"";Z=Z.replace(/\\+/g,"/");let Q=Z.match(/^(?:[^@]+@)?([^:/]+):(.+)$/);if(Q&&!Z.includes("://")){let J=Q[1].toLowerCase(),z=Q[2];return A9(J,z)}try{let J=new URL(Z),z=J.hostname.toLowerCase(),K=J.pathname;return A9(z,K)}catch{return A9("",Z)}}async function dj(Y){let Z=await B0(),Q=s0("git.defaultRemoteName",j1(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z=null;try{let{stdout:K}=await S`${Y} remote`,X=K.trim().split(`
|
|
367
|
+
`).map((H)=>H.trim()).filter(Boolean);if(X.length===0)z=null;else{let H="";try{let{stdout:W}=await S`${Y} rev-parse --abbrev-ref HEAD`,q=W.trim();if(q&&q!=="HEAD"){let{stdout:G}=await S`${Y} config branch.${q}.remote`;H=G.trim()}}catch{H=""}if(H&&X.includes(H))z=H;else if(X.includes("origin"))z="origin";else z=X[0]}}catch{z=null}return await Z.setOneOff(Q,z),z}async function g$(Y){let Z=await B0(),Q=s0("git.normalizedRemoteUrl",j1(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z=await dj(Y);if(!z)return await Z.setOneOff(Q,null),null;try{let{stdout:K}=await S`${Y} remote get-url ${z}`,X=K.trim();if(!X)return await Z.setOneOff(Q,null),null;let W=uj(X)||null;return await Z.setOneOff(Q,W),W}catch{return await Z.setOneOff(Q,null),null}}async function v7(Y){let Z=await B0(),Q=s0("git.mainWorktreeRoot",j1(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z="";try{let{stdout:K}=await S`${Y} rev-parse --show-toplevel`;z=K.trim()}catch{z=process.cwd()}try{let{stdout:K}=await S`${Y} rev-parse --git-common-dir`,X=K.trim();if(!X)return await Z.setOneOff(Q,z),z;let H=F0.isAbsolute(X)?X:F0.resolve(z,X);if(n0(H).includes("/.git/worktrees/")){let $=F0.dirname(F0.dirname(H)),V=F0.dirname($)||z;return await Z.setOneOff(Q,V),V}try{let B=N6(H,"utf-8").split(`
|
|
368
|
+
`).map((V)=>V.trim()).find((V)=>V.toLowerCase().startsWith("gitdir:"));if(B){let V=B.split(":").slice(1).join(":").trim(),F=F0.isAbsolute(V)?V:F0.resolve(z,V);if(n0(F).includes("/.git/worktrees/")){let L=F0.dirname(F0.dirname(F)),_=F0.dirname(L)||z;return await Z.setOneOff(Q,_),_}}}catch{}let G=F0.dirname(H)||z;return await Z.setOneOff(Q,G),G}catch{return await Z.setOneOff(Q,z),z}}async function wZ(Y,Z){let Q=await B0(),J=s0("git.cherryPickInProgress",`${j1(Y,Z)}|${F0.resolve(Z)}`),z=await Q.getOneOff(J);if(z!==void 0)return z;try{return await S`${Y} -C ${Z} rev-parse -q --verify CHERRY_PICK_HEAD`,await Q.setOneOff(J,!0),!0}catch{return await Q.setOneOff(J,!1),!1}}async function P6(Y,Z){let Q=await B0(),J=`git.config.${Z}`,z=await Q.get(J);if(z!==void 0)return R.debug(`Cache hit for ${J}`,"cache-ctrl"),z;try{let{stdout:K}=await S`${Y} config ${Z}`,X=K.trim();if(X)await Q.set(J,X),R.debug(`Cache store for ${J}: ${X}`,"cache-ctrl");return X}catch(K){return R.warn(`Git config ${Z} not found or failed`,"cache-ctrl"),R.debug(`Error details: ${a.from(K)}`,"cache-ctrl"),""}}async function m$(Y,Z=!1){let Q=await B0(),J=`${j1(Y)}|${Z?"remote":"local"}`,z=s0("git.branches",J),K=await Q.get(z);if(K)return R.debug(`Cache hit for ${z}`,"cache-ctrl"),K;try{let X=Z?["for-each-ref","--format=%(refname:short)","refs/remotes/"]:["for-each-ref","--format=%(refname:short)","refs/heads/"],{stdout:H}=await S`${Y} ${X}`,W=H.trim().split(`
|
|
369
|
+
`).filter((q)=>q.length>0);return await Q.set(z,W),R.debug(`Cache store for ${z}: ${W.length} branches`,"cache-ctrl"),W}catch(X){return R.warn(`Failed to get git branches: ${a.from(X)}`,"cache-ctrl"),[]}}async function pj(Y){let Z=await B0(),Q=s0("git.trackedUpstreamRef",j1(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z=B4();try{let{stdout:K}=await z.$`${Y} rev-parse --abbrev-ref --symbolic-full-name @{u}`,X=K.trim();return await Z.setOneOff(Q,X),X||null}catch{return null}}async function u$(Y){let Z=await B0(),Q="git.version",J=await Z.get("git.version");if(J)return R.debug("Cache hit for git.version","cache-ctrl"),J;try{let{stdout:z}=await S`${Y} --version`,K=z.trim().match(/(\d{1,2}\.\d{1,3}\.\d{1,3})/i)?.[1]||"unknown";return await Z.set("git.version",K),R.debug(`Cache store for git.version: ${K}`,"cache-ctrl"),K}catch(z){throw R.warn(`Failed to get git version: ${z}`,"cache-ctrl"),z}}async function T1(Y){let Z=await B0(),Q=process.cwd(),J=Array.isArray(Y)?Y.join(" "):Y,K="git.repoRoot."+k9.createHash("sha1").update(`${J}|${Q}`).digest("hex"),X=await Z.get(K);if(X&&l(X))return R.debug(`Cache hit for ${K}`,"cache-ctrl"),X;try{let{stdout:H}=await S`${Y} rev-parse --show-toplevel`,W=H.trim();return await Z.set(K,W),R.debug(`Cache store for ${K}: ${W}`,"cache-ctrl"),W}catch(H){throw R.warn(`Failed to get repo root: ${H}`,"cache-ctrl"),H}}function b$(Y){let Z=n0(F0.resolve(Y));return process.platform==="win32"?Z.toLowerCase():Z}async function cj(Y){let Z=await B0(),Q=s0("git.worktreeList",j1(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;try{let z=(await S`${Y} worktree list --porcelain`).stdout.trim();if(!z)return await Z.setOneOff(Q,[]),[];let K=[],X=null;for(let H of z.split(`
|
|
370
|
+
`)){if(!H.trim())continue;if(H.startsWith("worktree ")){if(X)K.push(X);X={path:H.slice(9).trim(),locked:!1,lockReason:null,prunable:!1};continue}if(!X)continue;if(H.startsWith("locked")){X.locked=!0;let W=H.slice(6).trim();X.lockReason=W.length>0?W:null}else if(H.startsWith("prunable"))X.prunable=!0}if(X)K.push(X);return await Z.setOneOff(Q,K),K}catch(z){return R.debug(g(z,{color:!0}),"git"),await Z.setOneOff(Q,[]),[]}}async function x9(Y){let Z=await B0(),Q=s0("git.worktreeList",j1(Y));await Z.deleteOneOff(Q)}async function S9(Y,Z){let Q=await cj(Y),J=b$(Z);return Q.find((z)=>b$(z.path)===J)??null}async function y7(Y){try{await S`${Y} worktree prune --expire now`}catch(Z){R.debug(g(Z,{color:!0}),"git")}finally{await x9(Y)}}async function P7(Y,Z,Q){let J=await B0(),z=`${j1(Y,Z)}|${Q}`,K=s0("git.path",z),X=await J.get(K);if(X!==void 0)return X;try{let H=(await S`${Y} -C ${Z} rev-parse --git-path ${Q}`).stdout.trim();if(!H)return await J.set(K,null,{maxAgeMinutes:C9}),null;let W=F0.isAbsolute(H)?H:F0.resolve(Z,H);return await J.set(K,W,{maxAgeMinutes:C9}),W}catch(H){return R.debug(g(H,{color:!0}),"git"),await J.set(K,null,{maxAgeMinutes:C9}),null}}async function lj(Y,Z){let Q=await P7(Y,Z,"HEAD");if(!Q)return null;let J=await n4(Q),z,K="";try{let H=N6(Q,"utf-8").trim().match(/^ref:\s*(.+)$/i);if(H?.[1]){if(K=H[1].trim(),K){let W=await P7(Y,Z,K);z=await n4(W)}}}catch{}return`${J??"null"}|${K}|${z??"null"}`}async function Q1(Y,Z,Q){let J=await B0(),z=Array.isArray(Q)?Q:Q.trim().split(/\s+/).filter(Boolean),K=z.join(" "),X=`${Y}|${F0.resolve(Z)}|${K}`,H=s0("git.revParse",X),W=z.length===1&&z[0]==="HEAD"||z.length===2&&z[0]==="--abbrev-ref"&&z[1]==="HEAD",q=W?await lj(Y,Z):null;if(W&&q!==null){let G=await J.get(H);if(G&&G.signature===q)return G.value}else{let G=await J.get(H);if(G!==void 0)return G}try{let G=["-C",Z,"rev-parse",...z],$=(await S`${Y} ${G}`).stdout.trim();if(W&&q!==null)await J.set(H,{value:$,signature:q},{maxAgeMinutes:S7});else await J.set(H,$,{maxAgeMinutes:S7});return $}catch{if(W&&q!==null)await J.set(H,{value:"",signature:q},{maxAgeMinutes:S7});else await J.set(H,"",{maxAgeMinutes:S7});return""}}async function d$(Y,Z){let Q=[{label:"merge",path:"MERGE_HEAD"},{label:"cherry-pick",path:"CHERRY_PICK_HEAD"},{label:"revert",path:"REVERT_HEAD"},{label:"rebase",path:"rebase-apply"},{label:"rebase",path:"rebase-merge"},{label:"bisect",path:"BISECT_LOG"},{label:"sequencer",path:"sequencer"}],J=new Set;for(let z of Q){let K=await P7(Y,Z,z.path);if(!K)continue;if(l(K))J.add(z.label)}return Array.from(J)}async function v6(Y,Z){let Q=Array.isArray(Y)?Y[0]:Y,J=await B0(),z=j1(Y,Z),K=s0("git.submodules.paths",z),X=s0("git.submodules.gitlinks",z),H=F0.join(Z,".gitmodules"),W=await n4(H)??null,q=null,G=await J.get(X);try{let $=[],B=await J.get(K);if(B&&B.mtime===W)$=B.paths;else if(W!==null){try{$=(await S`${Q} -C ${Z} config --file .gitmodules --get-regexp path`).stdout.trim().split(`
|
|
371
|
+
`).map((I)=>I.trim()).filter((I)=>I.length>0).map((I)=>{return I.match(/^submodule\.(.+?)\.path\s+(.+)$/)?.[2]?.trim()??""}).filter((I)=>I.length>0)}catch{$=[]}await J.set(K,{mtime:W,paths:$})}else if(B&&B.mtime===null)$=B.paths;let V=[],F=new Map;if(q===null)q=await n4(await P7(Y,Z,"index"))??null;if(G&&G.mtime===q&&q!==null)V=G.paths;else{try{let I=(await S`${Q} -C ${Z} ls-files --stage`).stdout.split(`
|
|
372
|
+
`).map((w)=>w.trim()).filter((w)=>w.startsWith("160000 ")).map((w)=>{let A=w.match(/^160000 ([0-9a-f]{40}) (\d)\t(.+)$/);return A?{sha:A[1],stage:A[2],path:A[3].trim()}:null}).filter((w)=>!!w).filter((w)=>w.path.length>0);F=new Map(I.map((w)=>[w.path,{sha:w.sha,stage:w.stage}])),V=Array.from(F.keys())}catch{V=[]}await J.set(X,{mtime:q,paths:V})}let M=new Set([...$,...V]);if(M.size===0)return[];let L=Array.from(M);return(await Promise.all(L.map(async(_)=>{let I=F.get(_);if(I&&I.stage!=="0")return{path:_,status:"U"};let w=F0.resolve(Z,_),A=F0.join(w,".git");if(!l(w)||!l(A))return{path:_,status:"-"};if(!I?.sha)return{path:_,status:" "};let x=(await Q1(Q,w,"HEAD")).trim(),E=x&&x!==I.sha?"+":" ";return{path:_,status:E}}))).map((_)=>{return{path:_.path,status:_.status,initialized:_.status!=="-"}})}catch($){return R.debug(g($,{color:!0}),"git"),[]}}async function p$(Y,Z){let Q=await B0(),J=j1(Y,Z);await Q.delete(s0("git.submodules.paths",J)),await Q.delete(s0("git.submodules.gitlinks",J))}async function c$(Y,Z,Q){let J=Array.isArray(Y)?Y[0]:Y,z=[];for(let K of Q){if(K.status==="U"){z.push(K.path);continue}let X=F0.resolve(Z,K.path);if(!l(X))continue;let H=F0.join(X,".git");if(!l(H)){if(K.status!=="-")try{if(b1(X).length>0)z.push(K.path)}catch{z.push(K.path)}continue}try{if((await S`${J} -C ${X} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0)z.push(K.path)}catch{z.push(K.path)}}return z}async function l$(Y,Z){let Q=Array.isArray(Y)?Y[0]:Y;await S`${Q} -C ${Z} submodule deinit -f --all`,await p$(Y,Z);let J=await v6(Y,Z);if(J.length===0)return;for(let z of J){let K=F0.resolve(Z,z.path);try{if(l(K))t6(K,{recursive:!0,force:!0});H1(K,{recursive:!0})}catch(X){R.debug(`Failed to clean submodule path '${K}'. ${g(X,{color:!0})}`,"git")}}try{let z=(await S`${Q} -C ${Z} rev-parse --git-dir`).stdout.trim();if(z){let K=F0.isAbsolute(z)?z:F0.resolve(Z,z);if(n0(K).includes("/.git/worktrees/")){let H=F0.join(K,"modules");if(l(H))t6(H,{recursive:!0,force:!0})}}}catch(z){R.debug(`Failed to clean worktree submodule metadata. ${g(z,{color:!0})}`,"git")}}async function n$(Y,Z){if((await v6(Y,Z)).length===0)return;await S`${Y} -c protocol.file.allow=always -C ${Z} submodule update --init --recursive`,await p$(Y,Z)}function i$(Y){let Z=nj(Y);if(!Z)return!1;return Z.includes("the previous cherry-pick is now empty")||Z.includes("the previous cherry-pick is empty")||Z.includes("previous cherry-pick is now empty")||Z.includes("previous cherry-pick is empty")||Z.includes("cherry-pick is now empty")||Z.includes("cherry-pick is empty")||Z.includes("the patch is empty")||Z.includes("patch is empty")}function nj(Y){if(!Y)return"";if(typeof Y==="string")return lY(Y).toLowerCase();let Z=Y,Q=[Z?.stderr,Z?.stdout,Z?.message].map((z)=>ij(z)).filter((z)=>z.length>0);if(Q.length===0)return"";let J=Q.join(`
|
|
373
|
+
`);return lY(J).toLowerCase()}function ij(Y){if(!Y)return"";if(typeof Y==="string")return Y;if(Y instanceof Uint8Array)return new TextDecoder().decode(Y);return String(Y)}async function f7(Y,Z){try{return(await S`${Y} -C ${Z} diff --name-only --diff-filter=U`).stdout.split(`
|
|
374
|
+
`).map((J)=>J.trim()).filter((J)=>J.length>0)}catch{return[]}}async function a$(Y,Z){let Q=await f7(Y,Z);if(Q.length===0)return;await V0`${Y} -C ${Z} add -A -- ${Q}`}async function o$(Y,Z){if((await f7(Y,Z)).length>0)return!1;try{if((await S`${Y} -C ${Z} diff --cached --name-only`).stdout.trim().length>0)return!1}catch{return!1}return!0}async function P9(Y){let{gitExec:Z,repoPath:Q,range:J,maxCount:z,formatTemplate:K,excludeRefs:X}=Y,H="";try{let B=["-C",Q,"log",`--pretty=format:${K||"%h %s"}`,J],V=X?.filter((F)=>F&&F.trim().length>0)??[];if(V.length>0)B.push("--not",...V);H=(await S`${Z} ${B}`).stdout.trim()}catch{H=""}let W=H.split(`
|
|
375
|
+
`).map((B)=>B.trim()).filter((B)=>B.length>0),q=W.length;if(q===0)return{commits:[],totalCount:0,moreCount:0};let G=z&&z>0?W.slice(0,z):W,$=Math.max(q-G.length,0);return{commits:G,totalCount:q,moreCount:$}}async function v9(Y,Z,Q,J){let z=await B0(),K=`${Y}|${F0.resolve(Z)}|${Q}|${J}`,X=s0("git.submoduleBaseSha",K),H=await z.get(X);if(H!==void 0)return H;try{let W=(await S`${Y} -C ${Z} ls-tree ${Q} -- ${J}`).stdout.trim();if(!W)return await z.set(X,null),null;let G=W.match(/^160000\s+commit\s+([0-9a-f]{7,40})\s+/i)?.[1]??null;return await z.set(X,G),G}catch{return await z.set(X,null),null}}function y9(){if(l0.supportsColor<=0)return[];return["-c","color.ui=always"]}async function F4(Y,Z,Q=0){for(let J=Q;J<Y.length;J++){let z=/^(head|origin)?~(\d+)?$/i.exec(Y[J]);if(!z)continue;let K=0;if(z[2]){if(K=parseInt(z[2],10),isNaN(K)||K<0)return R.error(`Invalid relative ref format: ${Y[J]}`,"reset"),{error:new a(`Invalid relative ref format: ${Y[J]}`)}}try{if(z[1]?.toLowerCase()==="origin"){let X=await pj(Z);if(!X)return R.error("No upstream configured for current branch.","reset"),{error:new a("No upstream configured for current branch.")};Y[J]=`${X}~${K}`;break}else Y[J]=`HEAD~${K}`}catch(X){return R.error(`Failed to expand relative ref: ${a.from(X)}`,"reset"),{error:a.from(X)}}}return{value:void 0}}function A9(Y,Z){let Q=Z.replace(/^[/:]+/,"");if(Q=Q.replace(/\.git$/i,""),Q=Q.replace(/\/+$/,""),Y)return`${Y}/${Q}`;return Q}var S7=360,C9=360;var K1=O(()=>{H0();S6();o0();A0();D0();h0()});import s$ from"path";import jZ from"fs";import aj from"crypto";async function oj(Y){try{let Z=await T1(Y),Q=rj(Z);if(!Q)return R.error("No stash drop to pardon.","stash"),1;j(U("Cyan")+`Restoring ${Q.entries.length} dropped stash(es)...`+U());for(let J of Q.entries)await h$(Y,J.sha,J.message),j(U("Green")+` + Restored: ${J.message}`+U());return 0}catch(Z){return R.error("Error pardoning stash: "+Z,"stash"),1}}async function r$(Y,Z,Q){let[J,z]=Z[2].split("..").map((X)=>parseInt(X,10));if(isNaN(J)||isNaN(z)||J>z)return R.error(`Invalid stash range: ${Z[2]}`,"stash"),1;let K=[];try{let X=await T1(Y),H=[];for(let W=z;W>=J;W--)H.push(E9(Y,W));if(K=(await Promise.all(H)).filter((W)=>W!=null),K.length>0)ZB(X,{timestamp:Date.now(),entries:K,type:"range"},Q)}catch(X){let H=a.from(X);R.warn(`Could not capture stash entry for undo. (${H.name})`,"stash"),R.debug(H.toString(),"stash")}j(U("Cyan")+`Dropping stashes from ${U("Bright")+J+U()+U("Cyan")} to ${U("Bright")+z+U()+U("Cyan")} (inclusive)`+U());for(let X=z;X>=J;X--)await V0`${Y} stash drop stash@{${X}}`;return 0}async function sj(Y,Z){if(Z[2]==="pardon")return await oj(Y);let J=(await O0()).get("stash.undoLimit")??10;if(Z[2]&&/\d+\.\.\d+$/.test(Z[2]))return await r$(Y,Z,J);let z=0,K=Z.slice(2).filter((X)=>!X.startsWith("-"));if(K.length>0)if(K[0].includes(".."));else{let X=K[0].match(/stash@\{(\d+)\}/)||K[0].match(/^(\d+)$/);if(X)z=parseInt(X[1],10)}try{let X=await E9(Y,z);if(X){let H=await T1(Y);ZB(H,{timestamp:Date.now(),entries:[X],type:"single"},J)}}catch(X){R.warn(`Could not capture stash entry for undo. (${a.from(X).name})`,"stash")}try{return await V0`${Y} ${Z}`,0}catch{return 1}}function t$(Y){let Z=aj.createHash("sha256").update(Y).digest("hex"),Q=s$.join(O1,"gdx","stash-undo");if(!jZ.existsSync(Q))jZ.mkdirSync(Q,{recursive:!0});return s$.join(Q,`${Z}.json`)}function e$(Y){let Z=t$(Y);if(!jZ.existsSync(Z))return[];try{let Q=jZ.readFileSync(Z,"utf-8");return JSON.parse(Q)}catch{return[]}}function YB(Y,Z){let Q=t$(Y);jZ.writeFileSync(Q,JSON.stringify(Z,null,2))}function ZB(Y,Z,Q=10){let J=e$(Y);if(J.push(Z),J.length>Q)J.splice(0,J.length-Q);YB(Y,J)}function rj(Y){let Z=e$(Y);if(Z.length===0)return null;let Q=Z.pop()||null;return YB(Y,Z),Q}var QB,JB,zB;var b7=O(()=>{H0();h0();L0();W0();W0();A0();K1();w1();D0();v0();QB={dropRange:r$,drop:sj},JB={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
376
|
+
${Y+d("STASH DROP",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
378
377
|
Remove a stash entry or a range of stash entries.
|
|
379
378
|
|
|
380
|
-
${Y+
|
|
379
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
381
380
|
Accepts a single stash index, a range like <start>..<end>, or defaults to the latest stash.
|
|
382
381
|
Includes safety features:
|
|
383
382
|
- **Undoable**: You can restore the last dropped stash(es) with \`${Z}${C} stash drop pardon${Q}\`.
|
|
384
383
|
|
|
385
|
-
${Y+
|
|
384
|
+
${Y+d("COMMANDS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
386
385
|
- \`${Z}drop <index>${Q}\`: Drop specific stash.
|
|
387
386
|
- \`${Z}drop <start>..<end>${Q}\`: Drop range of stashes.
|
|
388
387
|
- \`${Z}drop pardon${Q}\`: Undo the last drop operation.
|
|
389
388
|
|
|
390
|
-
${Y+
|
|
389
|
+
${Y+d("SAFETY",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
391
390
|
Dropped stashes are backed up temporarily. Use \`${Z}pardon${Q}\` to bring them back.
|
|
392
|
-
`,Math.min(100,
|
|
391
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Drop stash entries with undo support (e.g. 0..3, pardon).",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
393
392
|
${Y}${C} stash drop ${Z}[<stash> | <range> | pardon]${Q}
|
|
394
393
|
|
|
395
394
|
Examples:
|
|
@@ -399,72 +398,72 @@ Examples:
|
|
|
399
398
|
${Y}${C} stash d 3 ${Q+Z}# Drop stash@{3}.${Q}
|
|
400
399
|
${Y}${C} stash d 2..5 ${Q+Z}# Drop stash@{5}, stash@{4}, stash@{3}, stash@{2} (safe ordering).${Q}
|
|
401
400
|
${Y}${C} stash p 1 ${Q+Z}# Pop stash@{1}.${Q}
|
|
402
|
-
${Y}${C} stash c ${Q+Z}# Clear all stashes (maps to ${C} stash clear — destructive).${Q}`,Math.min(100,
|
|
403
|
-
${Z} --no-pager log --all --author=${J} --since=${
|
|
404
|
-
`).stdout.trim()
|
|
405
|
-
`)){let
|
|
406
|
-
`+
|
|
407
|
-
`);let
|
|
408
|
-
${Y+
|
|
401
|
+
${Y}${C} stash c ${Q+Z}# Clear all stashes (maps to ${C} stash clear — destructive).${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},zB={$root:["pardon"]}});async function TZ(Y){let{git$:Z,args:Q}=Y,J=Q.popValue("--email")||await P6(Z,"user.email");if(J=J?J.trim().replace(/^["']|["']$/g,""):J,!J)return R.error('User email not configured. Please set it using "git config user.email <email>" or provide it with --email option.',"graph"),1;if(!Q.includes("--quiet"))j(U("Cyan")+"Generating commit graph for user: "+U("Yellow")+J+U());let K=c.terminalWidth-KB-XB,X=Math.min(Math.floor(K/h7),52);if(K<HB)return R.error(`Terminal width too small for graph display. Minimum required width is ${HB+KB+XB} columns.`,"graph"),1;let H=new Date,W=new Date(H),q=W.getDay();W.setDate(W.getDate()-q),W.setDate(W.getDate()-X*7);let G=(await S`
|
|
402
|
+
${Z} --no-pager log --all --author=${J} --since=${W.toISOString()} --date=short --format=%ad
|
|
403
|
+
`).stdout.trim(),$={};for(let N of G.split(`
|
|
404
|
+
`)){let _=N.trim();if(_)$[_]=($[_]||0)+1}let B=1;for(let N of Object.values($))if(N>B)B=N;j(`
|
|
405
|
+
`+U("Bright")+d("Contribution Graph",k.OceanDeepBlue,k.OceanGreen,0.12,0.83)+` (Max: ${B} commits/day)
|
|
406
|
+
`);let V=" ",F=0,M=-1;for(let N=0;N<=X;N++){let _=new Date(W);_.setDate(_.getDate()+N*7);let I=N*h7;if(_.getMonth()!==M&&I>=F){V+=" ".repeat(I-F);let w=_.toLocaleString("default",{month:"short"});V+=w.padEnd(h7*3," "),F=I+h7*3,M=_.getMonth()}}j(U("Bright")+V+U());let L=[" ","Mon"," ","Wed"," ","Fri"," "];for(let N=0;N<7;N++){let _=U("Bright")+L[N]+U()+" ";for(let I=0;I<=X;I++){let w=new Date(W);if(w.setDate(w.getDate()+I*7+N),w>H){_+=" ";continue}let A=w.toISOString().slice(0,10),x=$[A]||0,E,h="■";if(x===0)E=U("Dim")+U(zY(k.MidnightBlack)),h="▨";else{let u=a0.clamp(x/B,0.15,1),f=lK(k.MidnightBlack,k.OceanGreen,u);E=U(zY(f))}_+=E+h+U()+" "}j(" "+_)}return j(""),0}var KB=6,h7=2,XB=4,HB=12,WB,qB;var IZ=O(()=>{h0();L0();H0();A0();W0();D0();v0();K1();WB={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
407
|
+
${Y+d("GRAPH",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
409
408
|
Render a calendar-style contribution graph for a repository author.
|
|
410
409
|
|
|
411
|
-
${Y+
|
|
410
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
412
411
|
Visualize commit activity as a calendar-like heatmap showing commit density by day for the last N weeks (limited by terminal width). Each cell is colored to indicate relative commit frequency and can be clamped to a maximum of 52 weeks.
|
|
413
412
|
|
|
414
|
-
${Y+
|
|
413
|
+
${Y+d("OPTIONS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
415
414
|
Supply ${Z}--email <email>${Q} to override the configured git user email. Use ${Z}--quiet${Q} to suppress informational headers when embedding the graph in other scripts.
|
|
416
415
|
|
|
417
|
-
${Y+
|
|
416
|
+
${Y+d("TERMINAL NOTES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
418
417
|
The graph respects \`${Z}global.terminalWidth${Q}\`. If the terminal is too narrow the command will bail with an error message.
|
|
419
|
-
`,Math.min(100,
|
|
418
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Render a calendar-style contribution graph for an author.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
420
419
|
${Y}${C} graph ${Z}[--email <email>] [--quiet]${Q}
|
|
421
420
|
|
|
422
421
|
Examples:
|
|
423
422
|
${Y}${C} graph ${Q+Z}# Graph for configured git user${Q}
|
|
424
|
-
${Y}${C} graph --email bob@example.com ${Q+Z}# Graph for specified author${Q}`,Math.min(100,
|
|
425
|
-
`).length:0,
|
|
426
|
-
`)){let
|
|
427
|
-
`)){let
|
|
428
|
-
|
|
429
|
-
─── ${
|
|
430
|
-
Project: ${
|
|
431
|
-
Total Commits: ${
|
|
432
|
-
Total Lines Added: ${
|
|
433
|
-
Total Lines Removed: ${
|
|
434
|
-
Contributions: ${
|
|
435
|
-
Most Active Branch: ${
|
|
436
|
-
Last Commit: ${
|
|
437
|
-
`),await
|
|
438
|
-
${Y+
|
|
423
|
+
${Y}${C} graph --email bob@example.com ${Q+Z}# Graph for specified author${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},qB={$root:["--email","--quiet"]}});function QT(Y,Z){let Q=Y[Z];if(ZT.includes(Q))return{consumed:1,gitArgs:[Q]};for(let J of YT){if(Q===J){if(Z+1>=Y.length)return null;let z=Y[Z+1];if(z==="--")return null;return{consumed:2,gitArgs:[J,z]}}if(Q.startsWith(J+"="))return{consumed:1,gitArgs:[J,Q.slice(J.length+1)]};if(!J.startsWith("--")&&Q.startsWith(J)&&Q.length>J.length)return{consumed:1,gitArgs:[J,Q.slice(J.length)]}}return null}function g7(Y,Z){if(Y[0]&&!Y[0].startsWith("-"))return{args:Y,gitArgs:[],cursorIndex:Z,cursorInGitGlobal:!1};let Q=new Set,J=[],z=0;while(z<Y.length){let H=Y[z];if(H==="--")break;let W=QT(Y,z);if(W){let q=z,G=z+W.consumed-1;if(Z!=null&&Z>=q&&Z<=G)return{args:Y,gitArgs:[],cursorIndex:Z,cursorInGitGlobal:!0};if(Z==null||G<Z){J.push(...W.gitArgs);for(let $=q;$<=G;$++)Q.add($)}z+=W.consumed;continue}if(tj.includes(H)){if(z+1>=Y.length)break;z+=2;continue}if(ej.includes(H)){z+=1;continue}if(H.startsWith("-")){z+=1;continue}break}if(Q.size===0)return{args:Y,gitArgs:J,cursorIndex:Z,cursorInGitGlobal:!1};let K=Y.filter((H,W)=>!Q.has(W)),X=Z;if(Z!=null){let H=0;for(let W of Q)if(W<Z)H+=1;if(X=Math.max(0,Z-H),K.length>0&&X>=K.length)X=K.length-1}return{args:K,gitArgs:J,cursorIndex:X,cursorInGitGlobal:!1}}function JT(Y){let Z=Y.indexOf("=");if(Z!==-1)return Y.substring(Z+1);return null}function GB(Y){return new MY(Y)}var tj,ej,YT,ZT,MY;var CZ=O(()=>{W0();tj=[...uK],ej=[...dK],YT=[...pK],ZT=[...cK];MY=class MY extends Array{constructor(Y){if(Array.isArray(Y))super(...Y);else super(Y)}optionIndexOf(Y,Z=0){let Q=this.indexOf("--");if(Q!==-1&&Q<Z)return-1;let J=Q===-1?this.length:Q;for(let z=Z;z<J;z++)if(this[z]===Y||this[z].startsWith(Y+"="))return z;return-1}delete(Y){let Z=this.optionIndexOf(Y);if(Z!==-1)return this.splice(Z,1),!0;return!1}popValue(Y,Z=0,Q=!1){let J=this.optionIndexOf(Y,Z);if(J!==-1){let z=null;if(Y.includes("="))z=JT(this[J]),this.splice(J,1);else if(!Q&&J+1<this.length&&!this[J+1].startsWith("-"))z=this[J+1],this.splice(J,2);else this.splice(J,1);return z}return null}popOption(Y,Z=0){let Q=this.optionIndexOf(Y,Z);if(Q!==-1)return this.splice(Q,1),Y;return null}spliceOption(Y,Z,Q=0){let J=this.optionIndexOf(Y,Q);if(J!==-1)return this.splice(J,1,...Z),!0;return!1}hasOption(Y,Z=0){let Q=this.indexOf("--");if(Q!==-1&&Q<Z)return!1;let J=Q===-1?this.length:Q;for(let z=Z;z<J;z++)if(this[z]===Y||this[z].startsWith(Y+"="))return!0;return!1}slice(Y,Z){return new MY(super.slice(Y,Z))}toArray(){return super.slice(0)}}});async function f9(Y){let Z=B4(),Q=Z.$,{args:J,git$:z}=Y;if(!await V4(z))return 1;let K="",X="Your",H=J.indexOf("--author");try{if(H!==-1&&H+1<J.length)K=J[H+1].trim(),X=K.split("@")[0]+"'s";else K=await P6(z,"user.email")}catch(q){return Z.abort(),R.error("Failed to read git config user.email.","stats"),R.error(g(q,{color:!0}),"stats"),1}if(!K)return R.error("No user.email configured in git.","stats"),1;let W=d0({message:`Gathering stats for ${K}...`});try{let[q,G,$,B,V,F,M,L]=await Promise.all([T1(z),Q`${z} rev-list --all --count --author=${K}`,Q`${z} rev-list --all --count`,Q`${z} log --all --author=${K} --since=midnight --pretty=tformat:%h`,Q`${z} log --all --author=${K} --pretty=tformat: --numstat`,Q`${z} log --all --pretty=tformat: --numstat`,m$(z),Q`${z} log --all --author=${K} -1 --format=${`%ar ${U()+U("Dim")}[at %h] (on %ad)`+U()}`]),N=q.split(/[\\/]/).pop(),_=G.stdout.trim(),I=$.stdout.trim(),w=B.stdout.trim()?B.stdout.trim().split(`
|
|
424
|
+
`).length:0,A=V.stdout,x=0,E=0;for(let R0 of A.split(`
|
|
425
|
+
`)){let N0=R0.match(/^(\d+)\s+(\d+)/);if(N0)x+=parseInt(N0[1],10),E+=parseInt(N0[2],10)}let h=Z6(x*QY.AVG_CHARS_PER_LINE,2,1024)+"iB",u=Z6(E*QY.AVG_CHARS_PER_LINE,2,1024)+"iB",f=Z6(x/QY.AVG_LINES_PER_FUNCTION,1,1000,!1,0),m=Z6(E/QY.AVG_LINES_PER_FUNCTION,1,1000,!1,0),r=Z6(x/QY.AVG_LINES_PER_FILE,1,1000,!1,0),b=Z6(E/QY.AVG_LINES_PER_FILE,1,1000,!1,0),$0=F.stdout,t=0,X0=0;for(let R0 of $0.split(`
|
|
426
|
+
`)){let N0=R0.match(/^(\d+)\s+(\d+)/);if(N0)t+=parseInt(N0[1],10),X0+=parseInt(N0[2],10)}let e=x+E,n=t+X0,U0=n>0?u8(e/n*100,2,!0):"0.00",M0=0,j0="N/A",C0=await Promise.all(M.map(async(R0)=>{let{stdout:N0}=await Q`${z} rev-list --count --author=${K} refs/heads/${R0}`;return{branch:R0,count:parseInt(N0.trim(),10)}}));for(let{branch:R0,count:N0}of C0)if(N0>M0)M0=N0,j0=R0;let T0=L.stdout.trim()||"Never";return W.stop(),j(` ${U("Dim")+U("Italic")}Showing stats for ${K} in ${N}${U()}
|
|
427
|
+
|
|
428
|
+
─── ${X} Git Stats ───
|
|
429
|
+
Project: ${U("Cyan")}${N}${U()}
|
|
430
|
+
Total Commits: ${U("Green")}${_}${U()} (today: ${w}) / ${U("Yellow")}${I}${U()} (all)
|
|
431
|
+
Total Lines Added: ${U("Green")}+ ${x} lines ${U()}${U("Dim")}(roughly ${h}, ${f} functions or ${r} source files)${U()}
|
|
432
|
+
Total Lines Removed: ${U("Red")}- ${E} lines ${U()}${U("Dim")}(roughly ${u}, ${m} functions or ${b} source files)${U()}
|
|
433
|
+
Contributions: ${U("Magenta")}${U0}%${U()} of all lines changed in the project
|
|
434
|
+
Most Active Branch: ${U("Cyan")}${j0}${U()} (${M0} commits)
|
|
435
|
+
Last Commit: ${U("Yellow")}${T0}${U()}
|
|
436
|
+
`),await TZ({...Y,args:GB(["--quiet","--author",K])}),0}catch(q){return W.stop(),Z.abort(),R.error(g(q,{color:!0})),1}}var UB,$B;var m7=O(()=>{H0();h0();L0();IZ();CZ();W0();v0();A0();D0();K1();UB={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
437
|
+
${Y+d("STATS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
439
438
|
Gather detailed contribution statistics for a git author in this repository.
|
|
440
439
|
|
|
441
|
-
${Y+
|
|
440
|
+
${Y+d("WHAT IT COMPUTES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
442
441
|
Total commits by the author, today's commits, lines added/removed, rough size estimates (bytes), estimated functions/files added or removed, contribution percentage of the project, most active branch, and time of the last commit.
|
|
443
442
|
|
|
444
|
-
${Y+
|
|
443
|
+
${Y+d("HOW IT WORKS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
445
444
|
The command runs multiple git queries in parallel to collect commit lists, per-commit numstat, branch lists and last-commit metadata. For large repos this may take some time; progress messages are shown while queries run.
|
|
446
445
|
|
|
447
|
-
${Y+
|
|
446
|
+
${Y+d("OPTIONS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
448
447
|
Use ${Z}--author <email>${Q} to target a different author than the configured git user.email. Output includes a small visual graph invocation via the \`${Z}graph${Q}\` command by default.
|
|
449
|
-
`,Math.min(100,
|
|
448
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Show (local) contribution statistics for a repository author.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
450
449
|
${Y}${C} stats ${Z}[--author <email>]${Q}
|
|
451
450
|
|
|
452
451
|
Examples:
|
|
453
452
|
${Y}${C} stats ${Q+Z}# Stats for configured git user${Q}
|
|
454
|
-
${Y}${C} stats --author alice@example.com ${Q+Z}# Stats for specified author${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},IU={$root:["--author"]}});function p(Y,Z,Q,J,z){if(J==="m")throw TypeError("Private method is not writable");if(J==="a"&&!z)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?Y!==Z||!z:!Z.has(Y))throw TypeError("Cannot write private member to an object whose class did not declare it");return J==="a"?z.call(Y,Q):z?z.value=Q:Z.set(Y,Q),Q}function _(Y,Z,Q,J){if(Q==="a"&&!J)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?Y!==Z||!J:!Z.has(Y))throw TypeError("Cannot read private member from an object whose class did not declare it");return Q==="m"?J:Q==="a"?J.call(Y):J?J.value:Z.get(Y)}var KY=()=>{};var X9=function(){let{crypto:Y}=globalThis;if(Y?.randomUUID)return X9=Y.randomUUID.bind(Y),Y.randomUUID();let Z=new Uint8Array(1),Q=Y?()=>Y.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(J)=>(+J^Q()&15>>+J/4).toString(16))};function K4(Y){return typeof Y==="object"&&Y!==null&&(("name"in Y)&&Y.name==="AbortError"||("message"in Y)&&String(Y.message).includes("FetchRequestCanceledException"))}var G4=(Y)=>{if(Y instanceof Error)return Y;if(typeof Y==="object"&&Y!==null){try{if(Object.prototype.toString.call(Y)==="[object Error]"){let Z=Error(Y.message,Y.cause?{cause:Y.cause}:{});if(Y.stack)Z.stack=Y.stack;if(Y.cause&&!Z.cause)Z.cause=Y.cause;if(Y.name)Z.name=Y.name;return Z}}catch{}try{return Error(JSON.stringify(Y))}catch{}}return Error(Y)};var h,O0,_0,z1,X1,$4,q4,U4,B4,V4,F4,R4,M4,O4,D4,aY;var jY=R(()=>{h=class h extends Error{};O0=class O0 extends h{constructor(Y,Z,Q,J){super(`${O0.makeMessage(Y,Z,Q)}`);this.status=Y,this.headers=J,this.requestID=J?.get("x-request-id"),this.error=Z;let z=Z;this.code=z?.code,this.param=z?.param,this.type=z?.type}static makeMessage(Y,Z,Q){let J=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):Q;if(Y&&J)return`${Y} ${J}`;if(Y)return`${Y} status code (no body)`;if(J)return J;return"(no status code or body)"}static generate(Y,Z,Q,J){if(!Y||!J)return new z1({message:Q,cause:G4(Z)});let z=Z?.error;if(Y===400)return new $4(Y,z,Q,J);if(Y===401)return new q4(Y,z,Q,J);if(Y===403)return new U4(Y,z,Q,J);if(Y===404)return new B4(Y,z,Q,J);if(Y===409)return new V4(Y,z,Q,J);if(Y===422)return new F4(Y,z,Q,J);if(Y===429)return new R4(Y,z,Q,J);if(Y>=500)return new M4(Y,z,Q,J);return new O0(Y,z,Q,J)}};_0=class _0 extends O0{constructor({message:Y}={}){super(void 0,void 0,Y||"Request was aborted.",void 0)}};z1=class z1 extends O0{constructor({message:Y,cause:Z}){super(void 0,void 0,Y||"Connection error.",void 0);if(Z)this.cause=Z}};X1=class X1 extends z1{constructor({message:Y}={}){super({message:Y??"Request timed out."})}};$4=class $4 extends O0{};q4=class q4 extends O0{};U4=class U4 extends O0{};B4=class B4 extends O0{};V4=class V4 extends O0{};F4=class F4 extends O0{};R4=class R4 extends O0{};M4=class M4 extends O0{};O4=class O4 extends h{constructor(){super("Could not parse response content as the length limit was reached")}};D4=class D4 extends h{constructor(){super("Could not parse response content as the request was rejected by the content filter")}};aY=class aY extends Error{constructor(Y){super(Y)}}});function W9(Y){if(typeof Y!=="object")return{};return Y??{}}function TU(Y){if(!Y)return!0;for(let Z in Y)return!1;return!0}function CU(Y,Z){return Object.prototype.hasOwnProperty.call(Y,Z)}function N4(Y){return Y!=null&&typeof Y==="object"&&!Array.isArray(Y)}var m_,jU=(Y)=>{return m_.test(Y)},f0=(Y)=>(f0=Array.isArray,f0(Y)),H9,kU=(Y,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new h(`${Y} must be an integer`);if(Z<0)throw new h(`${Y} must be a positive integer`);return Z},AU=(Y)=>{try{return JSON.parse(Y)}catch(Z){return}};var oY=R(()=>{jY();m_=/^[a-z][a-z0-9+.-]*:/i,H9=f0});var TY=(Y)=>new Promise((Z)=>setTimeout(Z,Y));var D6="6.14.0";function u_(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}function p_(){if(typeof navigator>"u"||!navigator)return null;let Y=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:Q}of Y){let J=Q.exec(navigator.userAgent);if(J){let z=J[1]||0,X=J[2]||0,H=J[3]||0;return{browser:Z,version:`${z}.${X}.${H}`}}}return null}var SU=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},d_=()=>{let Y=u_();if(Y==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":EU(Deno.build.os),"X-Stainless-Arch":xU(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(Y==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":EU(globalThis.process.platform??"unknown"),"X-Stainless-Arch":xU(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=p_();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},xU=(Y)=>{if(Y==="x32")return"x32";if(Y==="x86_64"||Y==="x64")return"x64";if(Y==="arm")return"arm";if(Y==="aarch64"||Y==="arm64")return"arm64";if(Y)return`other:${Y}`;return"unknown"},EU=(Y)=>{if(Y=Y.toLowerCase(),Y.includes("ios"))return"iOS";if(Y==="android")return"Android";if(Y==="darwin")return"MacOS";if(Y==="win32")return"Windows";if(Y==="freebsd")return"FreeBSD";if(Y==="openbsd")return"OpenBSD";if(Y==="linux")return"Linux";if(Y)return`Other:${Y}`;return"Unknown"},PU,vU=()=>{return PU??(PU=d_())};var K9=()=>{};function yU(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function G9(...Y){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...Y)}function O2(Y){let Z=Symbol.asyncIterator in Y?Y[Symbol.asyncIterator]():Y[Symbol.iterator]();return G9({start(){},async pull(Q){let{done:J,value:z}=await Z.next();if(J)Q.close();else Q.enqueue(z)},async cancel(){await Z.return?.()}})}function $9(Y){if(Y[Symbol.asyncIterator])return Y;let Z=Y.getReader();return{async next(){try{let Q=await Z.read();if(Q?.done)Z.releaseLock();return Q}catch(Q){throw Z.releaseLock(),Q}},async return(){let Q=Z.cancel();return Z.releaseLock(),await Q,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function fU(Y){if(Y===null||typeof Y!=="object")return;if(Y[Symbol.asyncIterator]){await Y[Symbol.asyncIterator]().return?.();return}let Z=Y.getReader(),Q=Z.cancel();Z.releaseLock(),await Q}var bU=({headers:Y,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};var D2="RFC3986",q9=(Y)=>String(Y),N2,U9="RFC1738";var w2=R(()=>{N2={RFC1738:(Y)=>String(Y).replace(/%20/g,"+"),RFC3986:q9}});function gU(Y){if(!Y||typeof Y!=="object")return!1;return!!(Y.constructor&&Y.constructor.isBuffer&&Y.constructor.isBuffer(Y))}function V9(Y,Z){if(f0(Y)){let Q=[];for(let J=0;J<Y.length;J+=1)Q.push(Z(Y[J]));return Q}return Z(Y)}var L2=(Y,Z)=>(L2=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),L2(Y,Z)),CY,B9=1024,hU=(Y,Z,Q,J,z)=>{if(Y.length===0)return Y;let X=Y;if(typeof Y==="symbol")X=Symbol.prototype.toString.call(Y);else if(typeof Y!=="string")X=String(Y);if(Q==="iso-8859-1")return escape(X).replace(/%u[0-9a-f]{4}/gi,function(W){return"%26%23"+parseInt(W.slice(2),16)+"%3B"});let H="";for(let W=0;W<X.length;W+=B9){let K=X.length>=B9?X.slice(W,W+B9):X,$=[];for(let G=0;G<K.length;++G){let U=K.charCodeAt(G);if(U===45||U===46||U===95||U===126||U>=48&&U<=57||U>=65&&U<=90||U>=97&&U<=122||z===U9&&(U===40||U===41)){$[$.length]=K.charAt(G);continue}if(U<128){$[$.length]=CY[U];continue}if(U<2048){$[$.length]=CY[192|U>>6]+CY[128|U&63];continue}if(U<55296||U>=57344){$[$.length]=CY[224|U>>12]+CY[128|U>>6&63]+CY[128|U&63];continue}G+=1,U=65536+((U&1023)<<10|K.charCodeAt(G)&1023),$[$.length]=CY[240|U>>18]+CY[128|U>>12&63]+CY[128|U>>6&63]+CY[128|U&63]}H+=$.join("")}return H};var mU=R(()=>{w2();oY();CY=(()=>{let Y=[];for(let Z=0;Z<256;++Z)Y.push("%"+((Z<16?"0":"")+Z.toString(16)).toUpperCase());return Y})()});function i_(Y){return typeof Y==="string"||typeof Y==="number"||typeof Y==="boolean"||typeof Y==="symbol"||typeof Y==="bigint"}function cU(Y,Z,Q,J,z,X,H,W,K,$,G,U,B,F,V,O,N,w){let L=Y,I=w,T=0,y=!1;while((I=I.get(F9))!==void 0&&!y){let b=I.get(Y);if(T+=1,typeof b<"u")if(b===T)throw RangeError("Cyclic object value");else y=!0;if(typeof I.get(F9)>"u")T=0}if(typeof $==="function")L=$(Z,L);else if(L instanceof Date)L=B?.(L);else if(Q==="comma"&&f0(L))L=V9(L,function(b){if(b instanceof Date)return B?.(b);return b});if(L===null){if(X)return K&&!O?K(Z,I0.encoder,N,"key",F):Z;L=""}if(i_(L)||gU(L)){if(K){let b=O?Z:K(Z,I0.encoder,N,"key",F);return[V?.(b)+"="+V?.(K(L,I0.encoder,N,"value",F))]}return[V?.(Z)+"="+V?.(String(L))]}let E=[];if(typeof L>"u")return E;let P;if(Q==="comma"&&f0(L)){if(O&&K)L=V9(L,K);P=[{value:L.length>0?L.join(",")||null:void 0}]}else if(f0($))P=$;else{let b=Object.keys(L);P=G?b.sort(G):b}let m=W?String(Z).replace(/\./g,"%2E"):String(Z),g=J&&f0(L)&&L.length===1?m+"[]":m;if(z&&f0(L)&&L.length===0)return g+"[]";for(let b=0;b<P.length;++b){let c=P[b],Y0=typeof c==="object"&&typeof c.value<"u"?c.value:L[c];if(H&&Y0===null)continue;let f=U&&W?c.replace(/\./g,"%2E"):c,N0=f0(L)?typeof Q==="function"?Q(g,f):g:g+(U?"."+f:"["+f+"]");w.set(Y,T);let w0=new WeakMap;w0.set(F9,w),pU(E,cU(Y0,N0,Q,J,z,X,H,W,Q==="comma"&&O&&f0(L)?null:K,$,G,U,B,F,V,O,N,w0))}return E}function n_(Y=I0){if(typeof Y.allowEmptyArrays<"u"&&typeof Y.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof Y.encodeDotInKeys<"u"&&typeof Y.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(Y.encoder!==null&&typeof Y.encoder<"u"&&typeof Y.encoder!=="function")throw TypeError("Encoder has to be a function.");let Z=Y.charset||I0.charset;if(typeof Y.charset<"u"&&Y.charset!=="utf-8"&&Y.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let Q=D2;if(typeof Y.format<"u"){if(!L2(N2,Y.format))throw TypeError("Unknown format option provided.");Q=Y.format}let J=N2[Q],z=I0.filter;if(typeof Y.filter==="function"||f0(Y.filter))z=Y.filter;let X;if(Y.arrayFormat&&Y.arrayFormat in dU)X=Y.arrayFormat;else if("indices"in Y)X=Y.indices?"indices":"repeat";else X=I0.arrayFormat;if("commaRoundTrip"in Y&&typeof Y.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let H=typeof Y.allowDots>"u"?!!Y.encodeDotInKeys===!0?!0:I0.allowDots:!!Y.allowDots;return{addQueryPrefix:typeof Y.addQueryPrefix==="boolean"?Y.addQueryPrefix:I0.addQueryPrefix,allowDots:H,allowEmptyArrays:typeof Y.allowEmptyArrays==="boolean"?!!Y.allowEmptyArrays:I0.allowEmptyArrays,arrayFormat:X,charset:Z,charsetSentinel:typeof Y.charsetSentinel==="boolean"?Y.charsetSentinel:I0.charsetSentinel,commaRoundTrip:!!Y.commaRoundTrip,delimiter:typeof Y.delimiter>"u"?I0.delimiter:Y.delimiter,encode:typeof Y.encode==="boolean"?Y.encode:I0.encode,encodeDotInKeys:typeof Y.encodeDotInKeys==="boolean"?Y.encodeDotInKeys:I0.encodeDotInKeys,encoder:typeof Y.encoder==="function"?Y.encoder:I0.encoder,encodeValuesOnly:typeof Y.encodeValuesOnly==="boolean"?Y.encodeValuesOnly:I0.encodeValuesOnly,filter:z,format:Q,formatter:J,serializeDate:typeof Y.serializeDate==="function"?Y.serializeDate:I0.serializeDate,skipNulls:typeof Y.skipNulls==="boolean"?Y.skipNulls:I0.skipNulls,sort:typeof Y.sort==="function"?Y.sort:null,strictNullHandling:typeof Y.strictNullHandling==="boolean"?Y.strictNullHandling:I0.strictNullHandling}}function R9(Y,Z={}){let Q=Y,J=n_(Z),z,X;if(typeof J.filter==="function")X=J.filter,Q=X("",Q);else if(f0(J.filter))X=J.filter,z=X;let H=[];if(typeof Q!=="object"||Q===null)return"";let W=dU[J.arrayFormat],K=W==="comma"&&J.commaRoundTrip;if(!z)z=Object.keys(Q);if(J.sort)z.sort(J.sort);let $=new WeakMap;for(let B=0;B<z.length;++B){let F=z[B];if(J.skipNulls&&Q[F]===null)continue;pU(H,cU(Q[F],F,W,K,J.allowEmptyArrays,J.strictNullHandling,J.skipNulls,J.encodeDotInKeys,J.encode?J.encoder:null,J.filter,J.sort,J.allowDots,J.serializeDate,J.format,J.formatter,J.encodeValuesOnly,J.charset,$))}let G=H.join(J.delimiter),U=J.addQueryPrefix===!0?"?":"";if(J.charsetSentinel)if(J.charset==="iso-8859-1")U+="utf8=%26%2310003%3B&";else U+="utf8=%E2%9C%93&";return G.length>0?U+G:""}var dU,pU=function(Y,Z){Array.prototype.push.apply(Y,f0(Z)?Z:[Z])},uU,I0,F9;var lU=R(()=>{mU();w2();oY();dU={brackets(Y){return String(Y)+"[]"},comma:"comma",indices(Y,Z){return String(Y)+"["+Z+"]"},repeat(Y){return String(Y)}},I0={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:hU,encodeValuesOnly:!1,format:D2,formatter:q9,indices:!1,serializeDate(Y){return(uU??(uU=Function.prototype.call.bind(Date.prototype.toISOString)))(Y)},skipNulls:!1,strictNullHandling:!1};F9={}});var iU=R(()=>{w2();lU()});function oU(Y){let Z=0;for(let z of Y)Z+=z.length;let Q=new Uint8Array(Z),J=0;for(let z of Y)Q.set(z,J),J+=z.length;return Q}function e1(Y){let Z;return(nU??(Z=new globalThis.TextEncoder,nU=Z.encode.bind(Z)))(Y)}function M9(Y){let Z;return(aU??(Z=new globalThis.TextDecoder,aU=Z.decode.bind(Z)))(Y)}var nU,aU;class Y8{constructor(){s0.set(this,void 0),r0.set(this,void 0),p(this,s0,new Uint8Array,"f"),p(this,r0,null,"f")}decode(Y){if(Y==null)return[];let Z=Y instanceof ArrayBuffer?new Uint8Array(Y):typeof Y==="string"?e1(Y):Y;p(this,s0,oU([_(this,s0,"f"),Z]),"f");let Q=[],J;while((J=o_(_(this,s0,"f"),_(this,r0,"f")))!=null){if(J.carriage&&_(this,r0,"f")==null){p(this,r0,J.index,"f");continue}if(_(this,r0,"f")!=null&&(J.index!==_(this,r0,"f")+1||J.carriage)){Q.push(M9(_(this,s0,"f").subarray(0,_(this,r0,"f")-1))),p(this,s0,_(this,s0,"f").subarray(_(this,r0,"f")),"f"),p(this,r0,null,"f");continue}let z=_(this,r0,"f")!==null?J.preceding-1:J.preceding,X=M9(_(this,s0,"f").subarray(0,z));Q.push(X),p(this,s0,_(this,s0,"f").subarray(J.index),"f"),p(this,r0,null,"f")}return Q}flush(){if(!_(this,s0,"f").length)return[];return this.decode(`
|
|
455
|
-
`)}}function
|
|
456
|
-
`,"\r"]);
|
|
457
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],z}if(this.chunks.push(Y),Y.startsWith(":"))return null;let[Z,Q,J]=
|
|
458
|
-
`);Q.enqueue(
|
|
459
|
-
${
|
|
453
|
+
${Y}${C} stats --author alice@example.com ${Q+Z}# Stats for specified author${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},$B={$root:["--author"]}});function i(Y,Z,Q,J,z){if(J==="m")throw TypeError("Private method is not writable");if(J==="a"&&!z)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?Y!==Z||!z:!Z.has(Y))throw TypeError("Cannot write private member to an object whose class did not declare it");return J==="a"?z.call(Y,Q):z?z.value=Q:Z.set(Y,Q),Q}function T(Y,Z,Q,J){if(Q==="a"&&!J)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?Y!==Z||!J:!Z.has(Y))throw TypeError("Cannot read private member from an object whose class did not declare it");return Q==="m"?J:Q==="a"?J.call(Y):J?J.value:Z.get(Y)}var I1=()=>{};var b9=function(){let{crypto:Y}=globalThis;if(Y?.randomUUID)return b9=Y.randomUUID.bind(Y),Y.randomUUID();let Z=new Uint8Array(1),Q=Y?()=>Y.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(J)=>(+J^Q()&15>>+J/4).toString(16))};function AZ(Y){return typeof Y==="object"&&Y!==null&&(("name"in Y)&&Y.name==="AbortError"||("message"in Y)&&String(Y.message).includes("FetchRequestCanceledException"))}var kZ=(Y)=>{if(Y instanceof Error)return Y;if(typeof Y==="object"&&Y!==null){try{if(Object.prototype.toString.call(Y)==="[object Error]"){let Z=Error(Y.message,Y.cause?{cause:Y.cause}:{});if(Y.stack)Z.stack=Y.stack;if(Y.cause&&!Z.cause)Z.cause=Y.cause;if(Y.name)Z.name=Y.name;return Z}}catch{}try{return Error(JSON.stringify(Y))}catch{}}return Error(Y)};var p,y0,g0,DY,NY,EZ,xZ,SZ,PZ,vZ,yZ,fZ,bZ,hZ,gZ,U6;var l1=O(()=>{p=class p extends Error{};y0=class y0 extends p{constructor(Y,Z,Q,J){super(`${y0.makeMessage(Y,Z,Q)}`);this.status=Y,this.headers=J,this.requestID=J?.get("x-request-id"),this.error=Z;let z=Z;this.code=z?.code,this.param=z?.param,this.type=z?.type}static makeMessage(Y,Z,Q){let J=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):Q;if(Y&&J)return`${Y} ${J}`;if(Y)return`${Y} status code (no body)`;if(J)return J;return"(no status code or body)"}static generate(Y,Z,Q,J){if(!Y||!J)return new DY({message:Q,cause:kZ(Z)});let z=Z?.error;if(Y===400)return new EZ(Y,z,Q,J);if(Y===401)return new xZ(Y,z,Q,J);if(Y===403)return new SZ(Y,z,Q,J);if(Y===404)return new PZ(Y,z,Q,J);if(Y===409)return new vZ(Y,z,Q,J);if(Y===422)return new yZ(Y,z,Q,J);if(Y===429)return new fZ(Y,z,Q,J);if(Y>=500)return new bZ(Y,z,Q,J);return new y0(Y,z,Q,J)}};g0=class g0 extends y0{constructor({message:Y}={}){super(void 0,void 0,Y||"Request was aborted.",void 0)}};DY=class DY extends y0{constructor({message:Y,cause:Z}){super(void 0,void 0,Y||"Connection error.",void 0);if(Z)this.cause=Z}};NY=class NY extends DY{constructor({message:Y}={}){super({message:Y??"Request timed out."})}};EZ=class EZ extends y0{};xZ=class xZ extends y0{};SZ=class SZ extends y0{};PZ=class PZ extends y0{};vZ=class vZ extends y0{};yZ=class yZ extends y0{};fZ=class fZ extends y0{};bZ=class bZ extends y0{};hZ=class hZ extends p{constructor(){super("Could not parse response content as the length limit was reached")}};gZ=class gZ extends p{constructor(){super("Could not parse response content as the request was rejected by the content filter")}};U6=class U6 extends Error{constructor(Y){super(Y)}}});function g9(Y){if(typeof Y!=="object")return{};return Y??{}}function VB(Y){if(!Y)return!0;for(let Z in Y)return!1;return!0}function FB(Y,Z){return Object.prototype.hasOwnProperty.call(Y,Z)}function mZ(Y){return Y!=null&&typeof Y==="object"&&!Array.isArray(Y)}var KT,BB=(Y)=>{return KT.test(Y)},r0=(Y)=>(r0=Array.isArray,r0(Y)),h9,RB=(Y,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new p(`${Y} must be an integer`);if(Z<0)throw new p(`${Y} must be a positive integer`);return Z},OB=(Y)=>{try{return JSON.parse(Y)}catch(Z){return}};var $6=O(()=>{l1();KT=/^[a-z][a-z0-9+.-]*:/i,h9=r0});var n1=(Y)=>new Promise((Z)=>setTimeout(Z,Y));var y6="6.14.0";function XT(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}function WT(){if(typeof navigator>"u"||!navigator)return null;let Y=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:Q}of Y){let J=Q.exec(navigator.userAgent);if(J){let z=J[1]||0,K=J[2]||0,X=J[3]||0;return{browser:Z,version:`${z}.${K}.${X}`}}}return null}var _B=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},HT=()=>{let Y=XT();if(Y==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":y6,"X-Stainless-OS":DB(Deno.build.os),"X-Stainless-Arch":MB(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":y6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(Y==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":y6,"X-Stainless-OS":DB(globalThis.process.platform??"unknown"),"X-Stainless-Arch":MB(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=WT();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":y6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":y6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},MB=(Y)=>{if(Y==="x32")return"x32";if(Y==="x86_64"||Y==="x64")return"x64";if(Y==="arm")return"arm";if(Y==="aarch64"||Y==="arm64")return"arm64";if(Y)return`other:${Y}`;return"unknown"},DB=(Y)=>{if(Y=Y.toLowerCase(),Y.includes("ios"))return"iOS";if(Y==="android")return"Android";if(Y==="darwin")return"MacOS";if(Y==="win32")return"Windows";if(Y==="freebsd")return"FreeBSD";if(Y==="openbsd")return"OpenBSD";if(Y==="linux")return"Linux";if(Y)return`Other:${Y}`;return"Unknown"},NB,LB=()=>{return NB??(NB=HT())};var m9=()=>{};function wB(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function u9(...Y){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...Y)}function u7(Y){let Z=Symbol.asyncIterator in Y?Y[Symbol.asyncIterator]():Y[Symbol.iterator]();return u9({start(){},async pull(Q){let{done:J,value:z}=await Z.next();if(J)Q.close();else Q.enqueue(z)},async cancel(){await Z.return?.()}})}function d9(Y){if(Y[Symbol.asyncIterator])return Y;let Z=Y.getReader();return{async next(){try{let Q=await Z.read();if(Q?.done)Z.releaseLock();return Q}catch(Q){throw Z.releaseLock(),Q}},async return(){let Q=Z.cancel();return Z.releaseLock(),await Q,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function jB(Y){if(Y===null||typeof Y!=="object")return;if(Y[Symbol.asyncIterator]){await Y[Symbol.asyncIterator]().return?.();return}let Z=Y.getReader(),Q=Z.cancel();Z.releaseLock(),await Q}var TB=({headers:Y,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};var d7="RFC3986",p9=(Y)=>String(Y),p7,c9="RFC1738";var c7=O(()=>{p7={RFC1738:(Y)=>String(Y).replace(/%20/g,"+"),RFC3986:p9}});function CB(Y){if(!Y||typeof Y!=="object")return!1;return!!(Y.constructor&&Y.constructor.isBuffer&&Y.constructor.isBuffer(Y))}function n9(Y,Z){if(r0(Y)){let Q=[];for(let J=0;J<Y.length;J+=1)Q.push(Z(Y[J]));return Q}return Z(Y)}var l7=(Y,Z)=>(l7=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),l7(Y,Z)),i1,l9=1024,IB=(Y,Z,Q,J,z)=>{if(Y.length===0)return Y;let K=Y;if(typeof Y==="symbol")K=Symbol.prototype.toString.call(Y);else if(typeof Y!=="string")K=String(Y);if(Q==="iso-8859-1")return escape(K).replace(/%u[0-9a-f]{4}/gi,function(H){return"%26%23"+parseInt(H.slice(2),16)+"%3B"});let X="";for(let H=0;H<K.length;H+=l9){let W=K.length>=l9?K.slice(H,H+l9):K,q=[];for(let G=0;G<W.length;++G){let $=W.charCodeAt(G);if($===45||$===46||$===95||$===126||$>=48&&$<=57||$>=65&&$<=90||$>=97&&$<=122||z===c9&&($===40||$===41)){q[q.length]=W.charAt(G);continue}if($<128){q[q.length]=i1[$];continue}if($<2048){q[q.length]=i1[192|$>>6]+i1[128|$&63];continue}if($<55296||$>=57344){q[q.length]=i1[224|$>>12]+i1[128|$>>6&63]+i1[128|$&63];continue}G+=1,$=65536+(($&1023)<<10|W.charCodeAt(G)&1023),q[q.length]=i1[240|$>>18]+i1[128|$>>12&63]+i1[128|$>>6&63]+i1[128|$&63]}X+=q.join("")}return X};var AB=O(()=>{c7();$6();i1=(()=>{let Y=[];for(let Z=0;Z<256;++Z)Y.push("%"+((Z<16?"0":"")+Z.toString(16)).toUpperCase());return Y})()});function UT(Y){return typeof Y==="string"||typeof Y==="number"||typeof Y==="boolean"||typeof Y==="symbol"||typeof Y==="bigint"}function SB(Y,Z,Q,J,z,K,X,H,W,q,G,$,B,V,F,M,L,N){let _=Y,I=N,w=0,A=!1;while((I=I.get(i9))!==void 0&&!A){let f=I.get(Y);if(w+=1,typeof f<"u")if(f===w)throw RangeError("Cyclic object value");else A=!0;if(typeof I.get(i9)>"u")w=0}if(typeof q==="function")_=q(Z,_);else if(_ instanceof Date)_=B?.(_);else if(Q==="comma"&&r0(_))_=n9(_,function(f){if(f instanceof Date)return B?.(f);return f});if(_===null){if(K)return W&&!M?W(Z,m0.encoder,L,"key",V):Z;_=""}if(UT(_)||CB(_)){if(W){let f=M?Z:W(Z,m0.encoder,L,"key",V);return[F?.(f)+"="+F?.(W(_,m0.encoder,L,"value",V))]}return[F?.(Z)+"="+F?.(String(_))]}let x=[];if(typeof _>"u")return x;let E;if(Q==="comma"&&r0(_)){if(M&&W)_=n9(_,W);E=[{value:_.length>0?_.join(",")||null:void 0}]}else if(r0(q))E=q;else{let f=Object.keys(_);E=G?f.sort(G):f}let h=H?String(Z).replace(/\./g,"%2E"):String(Z),u=J&&r0(_)&&_.length===1?h+"[]":h;if(z&&r0(_)&&_.length===0)return u+"[]";for(let f=0;f<E.length;++f){let m=E[f],r=typeof m==="object"&&typeof m.value<"u"?m.value:_[m];if(X&&r===null)continue;let b=$&&H?m.replace(/\./g,"%2E"):m,$0=r0(_)?typeof Q==="function"?Q(u,b):u:u+($?"."+b:"["+b+"]");N.set(Y,w);let t=new WeakMap;t.set(i9,N),xB(x,SB(r,$0,Q,J,z,K,X,H,Q==="comma"&&M&&r0(_)?null:W,q,G,$,B,V,F,M,L,t))}return x}function $T(Y=m0){if(typeof Y.allowEmptyArrays<"u"&&typeof Y.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof Y.encodeDotInKeys<"u"&&typeof Y.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(Y.encoder!==null&&typeof Y.encoder<"u"&&typeof Y.encoder!=="function")throw TypeError("Encoder has to be a function.");let Z=Y.charset||m0.charset;if(typeof Y.charset<"u"&&Y.charset!=="utf-8"&&Y.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let Q=d7;if(typeof Y.format<"u"){if(!l7(p7,Y.format))throw TypeError("Unknown format option provided.");Q=Y.format}let J=p7[Q],z=m0.filter;if(typeof Y.filter==="function"||r0(Y.filter))z=Y.filter;let K;if(Y.arrayFormat&&Y.arrayFormat in EB)K=Y.arrayFormat;else if("indices"in Y)K=Y.indices?"indices":"repeat";else K=m0.arrayFormat;if("commaRoundTrip"in Y&&typeof Y.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let X=typeof Y.allowDots>"u"?!!Y.encodeDotInKeys===!0?!0:m0.allowDots:!!Y.allowDots;return{addQueryPrefix:typeof Y.addQueryPrefix==="boolean"?Y.addQueryPrefix:m0.addQueryPrefix,allowDots:X,allowEmptyArrays:typeof Y.allowEmptyArrays==="boolean"?!!Y.allowEmptyArrays:m0.allowEmptyArrays,arrayFormat:K,charset:Z,charsetSentinel:typeof Y.charsetSentinel==="boolean"?Y.charsetSentinel:m0.charsetSentinel,commaRoundTrip:!!Y.commaRoundTrip,delimiter:typeof Y.delimiter>"u"?m0.delimiter:Y.delimiter,encode:typeof Y.encode==="boolean"?Y.encode:m0.encode,encodeDotInKeys:typeof Y.encodeDotInKeys==="boolean"?Y.encodeDotInKeys:m0.encodeDotInKeys,encoder:typeof Y.encoder==="function"?Y.encoder:m0.encoder,encodeValuesOnly:typeof Y.encodeValuesOnly==="boolean"?Y.encodeValuesOnly:m0.encodeValuesOnly,filter:z,format:Q,formatter:J,serializeDate:typeof Y.serializeDate==="function"?Y.serializeDate:m0.serializeDate,skipNulls:typeof Y.skipNulls==="boolean"?Y.skipNulls:m0.skipNulls,sort:typeof Y.sort==="function"?Y.sort:null,strictNullHandling:typeof Y.strictNullHandling==="boolean"?Y.strictNullHandling:m0.strictNullHandling}}function a9(Y,Z={}){let Q=Y,J=$T(Z),z,K;if(typeof J.filter==="function")K=J.filter,Q=K("",Q);else if(r0(J.filter))K=J.filter,z=K;let X=[];if(typeof Q!=="object"||Q===null)return"";let H=EB[J.arrayFormat],W=H==="comma"&&J.commaRoundTrip;if(!z)z=Object.keys(Q);if(J.sort)z.sort(J.sort);let q=new WeakMap;for(let B=0;B<z.length;++B){let V=z[B];if(J.skipNulls&&Q[V]===null)continue;xB(X,SB(Q[V],V,H,W,J.allowEmptyArrays,J.strictNullHandling,J.skipNulls,J.encodeDotInKeys,J.encode?J.encoder:null,J.filter,J.sort,J.allowDots,J.serializeDate,J.format,J.formatter,J.encodeValuesOnly,J.charset,q))}let G=X.join(J.delimiter),$=J.addQueryPrefix===!0?"?":"";if(J.charsetSentinel)if(J.charset==="iso-8859-1")$+="utf8=%26%2310003%3B&";else $+="utf8=%E2%9C%93&";return G.length>0?$+G:""}var EB,xB=function(Y,Z){Array.prototype.push.apply(Y,r0(Z)?Z:[Z])},kB,m0,i9;var PB=O(()=>{AB();c7();$6();EB={brackets(Y){return String(Y)+"[]"},comma:"comma",indices(Y,Z){return String(Y)+"["+Z+"]"},repeat(Y){return String(Y)}},m0={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:IB,encodeValuesOnly:!1,format:d7,formatter:p9,indices:!1,serializeDate(Y){return(kB??(kB=Function.prototype.call.bind(Date.prototype.toISOString)))(Y)},skipNulls:!1,strictNullHandling:!1};i9={}});var vB=O(()=>{c7();PB()});function bB(Y){let Z=0;for(let z of Y)Z+=z.length;let Q=new Uint8Array(Z),J=0;for(let z of Y)Q.set(z,J),J+=z.length;return Q}function R4(Y){let Z;return(yB??(Z=new globalThis.TextEncoder,yB=Z.encode.bind(Z)))(Y)}function o9(Y){let Z;return(fB??(Z=new globalThis.TextDecoder,fB=Z.decode.bind(Z)))(Y)}var yB,fB;class O4{constructor(){U1.set(this,void 0),$1.set(this,void 0),i(this,U1,new Uint8Array,"f"),i(this,$1,null,"f")}decode(Y){if(Y==null)return[];let Z=Y instanceof ArrayBuffer?new Uint8Array(Y):typeof Y==="string"?R4(Y):Y;i(this,U1,bB([T(this,U1,"f"),Z]),"f");let Q=[],J;while((J=VT(T(this,U1,"f"),T(this,$1,"f")))!=null){if(J.carriage&&T(this,$1,"f")==null){i(this,$1,J.index,"f");continue}if(T(this,$1,"f")!=null&&(J.index!==T(this,$1,"f")+1||J.carriage)){Q.push(o9(T(this,U1,"f").subarray(0,T(this,$1,"f")-1))),i(this,U1,T(this,U1,"f").subarray(T(this,$1,"f")),"f"),i(this,$1,null,"f");continue}let z=T(this,$1,"f")!==null?J.preceding-1:J.preceding,K=o9(T(this,U1,"f").subarray(0,z));Q.push(K),i(this,U1,T(this,U1,"f").subarray(J.index),"f"),i(this,$1,null,"f")}return Q}flush(){if(!T(this,U1,"f").length)return[];return this.decode(`
|
|
454
|
+
`)}}function VT(Y,Z){for(let z=Z??0;z<Y.length;z++){if(Y[z]===10)return{preceding:z,index:z+1,carriage:!1};if(Y[z]===13)return{preceding:z,index:z+1,carriage:!0}}return null}function hB(Y){for(let J=0;J<Y.length-1;J++){if(Y[J]===10&&Y[J+1]===10)return J+2;if(Y[J]===13&&Y[J+1]===13)return J+2;if(Y[J]===13&&Y[J+1]===10&&J+3<Y.length&&Y[J+2]===13&&Y[J+3]===10)return J+4}return-1}var U1,$1;var gB=O(()=>{I1();U1=new WeakMap,$1=new WeakMap;O4.NEWLINE_CHARS=new Set([`
|
|
455
|
+
`,"\r"]);O4.NEWLINE_REGEXP=/\r\n|[\n\r]/g});function uZ(){}function n7(Y,Z,Q){if(!Z||i7[Y]>i7[Q])return uZ;else return Z[Y].bind(Z)}function E0(Y){let Z=Y.logger,Q=Y.logLevel??"off";if(!Z)return FT;let J=mB.get(Z);if(J&&J[0]===Q)return J[1];let z={error:n7("error",Z,Q),warn:n7("warn",Z,Q),info:n7("info",Z,Q),debug:n7("debug",Z,Q)};return mB.set(Z,[Q,z]),z}var i7,s9=(Y,Z,Q)=>{if(!Y)return;if(FB(i7,Y))return Y;E0(Q).warn(`${Z} was set to ${JSON.stringify(Y)}, expected one of ${JSON.stringify(Object.keys(i7))}`);return},FT,mB,B6=(Y)=>{if(Y.options)Y.options={...Y.options},delete Y.options.headers;if(Y.headers)Y.headers=Object.fromEntries((Y.headers instanceof Headers?[...Y.headers]:Object.entries(Y.headers)).map(([Z,Q])=>[Z,Z.toLowerCase()==="authorization"||Z.toLowerCase()==="cookie"||Z.toLowerCase()==="set-cookie"?"***":Q]));if("retryOfRequestLogID"in Y){if(Y.retryOfRequestLogID)Y.retryOf=Y.retryOfRequestLogID;delete Y.retryOfRequestLogID}return Y};var dZ=O(()=>{$6();i7={off:0,error:200,warn:300,info:400,debug:500};FT={error:uZ,warn:uZ,info:uZ,debug:uZ},mB=new WeakMap});async function*RT(Y,Z){if(!Y.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new p("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new p("Attempted to iterate over a response with no body")}let Q=new uB,J=new O4,z=d9(Y.body);for await(let K of OT(z))for(let X of J.decode(K)){let H=Q.decode(X);if(H)yield H}for(let K of J.flush()){let X=Q.decode(K);if(X)yield X}}async function*OT(Y){let Z=new Uint8Array;for await(let Q of Y){if(Q==null)continue;let J=Q instanceof ArrayBuffer?new Uint8Array(Q):typeof Q==="string"?R4(Q):Q,z=new Uint8Array(Z.length+J.length);z.set(Z),z.set(J,Z.length),Z=z;let K;while((K=hB(Z))!==-1)yield Z.slice(0,K),Z=Z.slice(K)}if(Z.length>0)yield Z}class uB{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(Y){if(Y.endsWith("\r"))Y=Y.substring(0,Y.length-1);if(!Y){if(!this.event&&!this.data.length)return null;let z={event:this.event,data:this.data.join(`
|
|
456
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],z}if(this.chunks.push(Y),Y.startsWith(":"))return null;let[Z,Q,J]=MT(Y,":");if(J.startsWith(" "))J=J.substring(1);if(Z==="event")this.event=J;else if(Z==="data")this.data.push(J);return null}}function MT(Y,Z){let Q=Y.indexOf(Z);if(Q!==-1)return[Y.substring(0,Q),Z,Y.substring(Q+Z.length)];return[Y,"",""]}var pZ,B1;var r9=O(()=>{I1();l1();gB();dZ();l1();B1=class B1{constructor(Y,Z,Q){this.iterator=Y,pZ.set(this,void 0),this.controller=Z,i(this,pZ,Q,"f")}static fromSSEResponse(Y,Z,Q){let J=!1,z=Q?E0(Q):console;async function*K(){if(J)throw new p("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");J=!0;let X=!1;try{for await(let H of RT(Y,Z)){if(X)continue;if(H.data.startsWith("[DONE]")){X=!0;continue}if(H.event===null||!H.event.startsWith("thread.")){let W;try{W=JSON.parse(H.data)}catch(q){throw z.error("Could not parse message into JSON:",H.data),z.error("From chunk:",H.raw),q}if(W&&W.error)throw new y0(void 0,W.error,void 0,Y.headers);yield W}else{let W;try{W=JSON.parse(H.data)}catch(q){throw console.error("Could not parse message into JSON:",H.data),console.error("From chunk:",H.raw),q}if(H.event=="error")throw new y0(void 0,W.error,W.message,void 0);yield{event:H.event,data:W}}}X=!0}catch(H){if(AZ(H))return;throw H}finally{if(!X)Z.abort()}}return new B1(K,Z,Q)}static fromReadableStream(Y,Z,Q){let J=!1;async function*z(){let X=new O4,H=d9(Y);for await(let W of H)for(let q of X.decode(W))yield q;for(let W of X.flush())yield W}async function*K(){if(J)throw new p("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");J=!0;let X=!1;try{for await(let H of z()){if(X)continue;if(H)yield JSON.parse(H)}X=!0}catch(H){if(AZ(H))return;throw H}finally{if(!X)Z.abort()}}return new B1(K,Z,Q)}[(pZ=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let Y=[],Z=[],Q=this.iterator(),J=(z)=>{return{next:()=>{if(z.length===0){let K=Q.next();Y.push(K),Z.push(K)}return z.shift()}}};return[new B1(()=>J(Y),this.controller,T(this,pZ,"f")),new B1(()=>J(Z),this.controller,T(this,pZ,"f"))]}toReadableStream(){let Y=this,Z;return u9({async start(){Z=Y[Symbol.asyncIterator]()},async pull(Q){try{let{value:J,done:z}=await Z.next();if(z)return Q.close();let K=R4(JSON.stringify(J)+`
|
|
457
|
+
`);Q.enqueue(K)}catch(J){Q.error(J)}},async cancel(){await Z.return?.()}})}}});async function a7(Y,Z){let{response:Q,requestLogID:J,retryOfRequestLogID:z,startTime:K}=Z,X=await(async()=>{if(Z.options.stream){if(E0(Y).debug("response",Q.status,Q.url,Q.headers,Q.body),Z.options.__streamClass)return Z.options.__streamClass.fromSSEResponse(Q,Z.controller,Y);return B1.fromSSEResponse(Q,Z.controller,Y)}if(Q.status===204)return null;if(Z.options.__binaryResponse)return Q;let W=Q.headers.get("content-type")?.split(";")[0]?.trim();if(W?.includes("application/json")||W?.endsWith("+json")){let $=await Q.json();return t9($,Q)}return await Q.text()})();return E0(Y).debug(`[${J}] response parsed`,B6({retryOfRequestLogID:z,url:Q.url,status:Q.status,body:X,durationMs:Date.now()-K})),X}function t9(Y,Z){if(!Y||typeof Y!=="object"||Array.isArray(Y))return Y;return Object.defineProperty(Y,"_request_id",{value:Z.headers.get("x-request-id"),enumerable:!1})}var e9=O(()=>{r9();dZ()});var cZ,_Y;var o7=O(()=>{I1();e9();_Y=class _Y extends Promise{constructor(Y,Z,Q=a7){super((J)=>{J(null)});this.responsePromise=Z,this.parseResponse=Q,cZ.set(this,void 0),i(this,cZ,Y,"f")}_thenUnwrap(Y){return new _Y(T(this,cZ,"f"),this.responsePromise,async(Z,Q)=>t9(Y(await this.parseResponse(Z,Q),Q),Q.response))}asResponse(){return this.responsePromise.then((Y)=>Y.response)}async withResponse(){let[Y,Z]=await Promise.all([this.parse(),this.asResponse()]);return{data:Y,response:Z,request_id:Z.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then((Y)=>this.parseResponse(T(this,cZ,"f"),Y));return this.parsedPromise}then(Y,Z){return this.parse().then(Y,Z)}catch(Y){return this.parse().catch(Y)}finally(Y){return this.parse().finally(Y)}};cZ=new WeakMap});var s7,r7,t7,V6,K0,f6;var _0=O(()=>{I1();l1();e9();o7();$6();r7=class r7{constructor(Y,Z,Q,J){s7.set(this,void 0),i(this,s7,Y,"f"),this.options=J,this.response=Z,this.body=Q}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let Y=this.nextPageRequestOptions();if(!Y)throw new p("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await T(this,s7,"f").requestAPIList(this.constructor,Y)}async*iterPages(){let Y=this;yield Y;while(Y.hasNextPage())Y=await Y.getNextPage(),yield Y}async*[(s7=new WeakMap,Symbol.asyncIterator)](){for await(let Y of this.iterPages())for(let Z of Y.getPaginatedItems())yield Z}};t7=class t7 extends _Y{constructor(Y,Z,Q){super(Y,Z,async(J,z)=>new Q(J,z.response,await a7(J,z),z.options))}async*[Symbol.asyncIterator](){let Y=await this;for await(let Z of Y)yield Z}};V6=class V6 extends r7{constructor(Y,Z,Q,J){super(Y,Z,Q,J);this.data=Q.data||[],this.object=Q.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}};K0=class K0 extends r7{constructor(Y,Z,Q,J){super(Y,Z,Q,J);this.data=Q.data||[],this.has_more=Q.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let Y=this.getPaginatedItems(),Z=Y[Y.length-1]?.id;if(!Z)return null;return{...this.options,query:{...g9(this.options.query),after:Z}}}};f6=class f6 extends r7{constructor(Y,Z,Q,J){super(Y,Z,Q,J);this.data=Q.data||[],this.has_more=Q.has_more||!1,this.last_id=Q.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let Y=this.last_id;if(!Y)return null;return{...this.options,query:{...g9(this.options.query),after:Y}}}}});function M4(Y,Z,Q){return QJ(),new File(Y,Z??"unknown_file",Q)}function lZ(Y){return(typeof Y==="object"&&Y!==null&&(("name"in Y)&&Y.name&&String(Y.name)||("url"in Y)&&Y.url&&String(Y.url)||("filename"in Y)&&Y.filename&&String(Y.filename)||("path"in Y)&&Y.path&&String(Y.path))||"").split(/[\\/]/).pop()||void 0}function NT(Y){let Z=typeof Y==="function"?Y:Y.fetch,Q=dB.get(Z);if(Q)return Q;let J=(async()=>{try{let z="Response"in Z?Z.Response:(await Z("data:,")).constructor,K=new FormData;if(K.toString()===await new z(K).text())return!1;return!0}catch{return!0}})();return dB.set(Z,J),J}var QJ=()=>{if(typeof File>"u"){let{process:Y}=globalThis,Z=typeof Y?.versions?.node==="string"&&parseInt(Y.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(Z?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}},e7=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y[Symbol.asyncIterator]==="function",JJ=async(Y,Z)=>{if(!YJ(Y.body))return Y;return{...Y,body:await pB(Y.body,Z)}},V1=async(Y,Z)=>{return{...Y,body:await pB(Y.body,Z)}},dB,pB=async(Y,Z)=>{if(!await NT(Z))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let Q=new FormData;return await Promise.all(Object.entries(Y||{}).map(([J,z])=>ZJ(Q,J,z))),Q},cB=(Y)=>Y instanceof Blob&&("name"in Y),_T=(Y)=>typeof Y==="object"&&Y!==null&&(Y instanceof Response||e7(Y)||cB(Y)),YJ=(Y)=>{if(_T(Y))return!0;if(Array.isArray(Y))return Y.some(YJ);if(Y&&typeof Y==="object"){for(let Z in Y)if(YJ(Y[Z]))return!0}return!1},ZJ=async(Y,Z,Q)=>{if(Q===void 0)return;if(Q==null)throw TypeError(`Received null for "${Z}"; to pass null in FormData, you must use the string 'null'`);if(typeof Q==="string"||typeof Q==="number"||typeof Q==="boolean")Y.append(Z,String(Q));else if(Q instanceof Response)Y.append(Z,M4([await Q.blob()],lZ(Q)));else if(e7(Q))Y.append(Z,M4([await new Response(u7(Q)).blob()],lZ(Q)));else if(cB(Q))Y.append(Z,Q,lZ(Q));else if(Array.isArray(Q))await Promise.all(Q.map((J)=>ZJ(Y,Z+"[]",J)));else if(typeof Q==="object")await Promise.all(Object.entries(Q).map(([J,z])=>ZJ(Y,`${Z}[${J}]`,z)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${Q} instead`)};var a1=O(()=>{dB=new WeakMap});async function Y5(Y,Z,Q){if(QJ(),Y=await Y,LT(Y)){if(Y instanceof File)return Y;return M4([await Y.arrayBuffer()],Y.name)}if(wT(Y)){let z=await Y.blob();return Z||(Z=new URL(Y.url).pathname.split(/[\\/]/).pop()),M4(await zJ(z),Z,Q)}let J=await zJ(Y);if(Z||(Z=lZ(Y)),!Q?.type){let z=J.find((K)=>typeof K==="object"&&("type"in K)&&K.type);if(typeof z==="string")Q={...Q,type:z}}return M4(J,Z,Q)}async function zJ(Y){let Z=[];if(typeof Y==="string"||ArrayBuffer.isView(Y)||Y instanceof ArrayBuffer)Z.push(Y);else if(lB(Y))Z.push(Y instanceof Blob?Y:await Y.arrayBuffer());else if(e7(Y))for await(let Q of Y)Z.push(...await zJ(Q));else{let Q=Y?.constructor?.name;throw Error(`Unexpected data type: ${typeof Y}${Q?`; constructor: ${Q}`:""}${jT(Y)}`)}return Z}function jT(Y){if(typeof Y!=="object"||Y===null)return"";return`; props: [${Object.getOwnPropertyNames(Y).map((Q)=>`"${Q}"`).join(", ")}]`}var lB=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y.size==="number"&&typeof Y.type==="string"&&typeof Y.text==="function"&&typeof Y.slice==="function"&&typeof Y.arrayBuffer==="function",LT=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y.name==="string"&&typeof Y.lastModified==="number"&&lB(Y),wT=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y.url==="string"&&typeof Y.blob==="function";var nB=O(()=>{a1();a1()});var KJ=O(()=>{nB()});class v{constructor(Y){this._client=Y}}function aB(Y){return Y.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var iB,IT=(Y=aB)=>function Z(Q,...J){if(Q.length===1)return Q[0];let z=!1,K=[],X=Q.reduce((G,$,B)=>{if(/[?#]/.test($))z=!0;let V=J[B],F=(z?encodeURIComponent:Y)(""+V);if(B!==J.length&&(V==null||typeof V==="object"&&V.toString===Object.getPrototypeOf(Object.getPrototypeOf(V.hasOwnProperty??iB)??iB)?.toString))F=V+"",K.push({start:G.length+$.length,length:F.length,error:`Value of type ${Object.prototype.toString.call(V).slice(8,-1)} is not a valid path parameter`});return G+$+(B===J.length?"":F)},""),H=X.split(/[?#]/,1)[0],W=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,q;while((q=W.exec(H))!==null)K.push({start:q.index,length:q[0].length,error:`Value "${q[0]}" can't be safely passed as a path parameter`});if(K.sort((G,$)=>G.start-$.start),K.length>0){let G=0,$=K.reduce((B,V)=>{let F=" ".repeat(V.start-G),M="^".repeat(V.length);return G=V.start+V.length,B+F+M},"");throw new p(`Path parameters result in path with invalid segments:
|
|
458
|
+
${K.map((B)=>B.error).join(`
|
|
460
459
|
`)}
|
|
461
|
-
${
|
|
462
|
-
${U}`)}return H},k;var J0=R(()=>{jY();XB=Object.freeze(Object.create(null)),k=WI(HB)});var Q8;var P2=R(()=>{K0();J0();Q8=class Q8 extends x{list(Y,Z={},Q){return this._client.getAPIList(k`/chat/completions/${Y}/messages`,Z0,{query:Z,...Q})}}});var MY=R(()=>{jY()});function T4(Y){return Y!==void 0&&"function"in Y&&Y.function!==void 0}function C4(Y){return Y?.$brand==="auto-parseable-response-format"}function W1(Y){return Y?.$brand==="auto-parseable-tool"}function WB(Y,Z){if(!Z||!k9(Z))return{...Y,choices:Y.choices.map((Q)=>{return GB(Q.message.tool_calls),{...Q,message:{...Q.message,parsed:null,...Q.message.tool_calls?{tool_calls:Q.message.tool_calls}:void 0}}})};return k4(Y,Z)}function k4(Y,Z){let Q=Y.choices.map((J)=>{if(J.finish_reason==="length")throw new O4;if(J.finish_reason==="content_filter")throw new D4;return GB(J.message.tool_calls),{...J,message:{...J.message,...J.message.tool_calls?{tool_calls:J.message.tool_calls?.map((z)=>qI(Z,z))??void 0}:void 0,parsed:J.message.content&&!J.message.refusal?$I(Z,J.message.content):null}}});return{...Y,choices:Q}}function $I(Y,Z){if(Y.response_format?.type!=="json_schema")return null;if(Y.response_format?.type==="json_schema"){if("$parseRaw"in Y.response_format)return Y.response_format.$parseRaw(Z);return JSON.parse(Z)}return null}function qI(Y,Z){let Q=Y.tools?.find((J)=>T4(J)&&J.function?.name===Z.function.name);return{...Z,function:{...Z.function,parsed_arguments:W1(Q)?Q.$parseRaw(Z.function.arguments):Q?.function.strict?JSON.parse(Z.function.arguments):null}}}function KB(Y,Z){if(!Y||!("tools"in Y)||!Y.tools)return!1;let Q=Y.tools?.find((J)=>T4(J)&&J.function?.name===Z.function.name);return T4(Q)&&(W1(Q)||Q?.function.strict||!1)}function k9(Y){if(C4(Y.response_format))return!0;return Y.tools?.some((Z)=>W1(Z)||Z.type==="function"&&Z.function.strict===!0)??!1}function GB(Y){for(let Z of Y||[])if(Z.type!=="function")throw new h(`Currently only \`function\` tool calls are supported; Received \`${Z.type}\``)}function $B(Y){for(let Z of Y??[]){if(Z.type!=="function")throw new h(`Currently only \`function\` tool types support auto-parsing; Received \`${Z.type}\``);if(Z.function.strict!==!0)throw new h(`The \`${Z.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var A4=R(()=>{MY()});var J8=(Y)=>{return Y?.role==="assistant"},A9=(Y)=>{return Y?.role==="tool"};class K1{constructor(){x9.add(this),this.controller=new AbortController,S2.set(this,void 0),v2.set(this,()=>{}),x4.set(this,()=>{}),E4.set(this,void 0),y2.set(this,()=>{}),P4.set(this,()=>{}),tY.set(this,{}),S4.set(this,!1),f2.set(this,!1),b2.set(this,!1),z8.set(this,!1),p(this,S2,new Promise((Y,Z)=>{p(this,v2,Y,"f"),p(this,x4,Z,"f")}),"f"),p(this,E4,new Promise((Y,Z)=>{p(this,y2,Y,"f"),p(this,P4,Z,"f")}),"f"),_(this,S2,"f").catch(()=>{}),_(this,E4,"f").catch(()=>{})}_run(Y){setTimeout(()=>{Y().then(()=>{this._emitFinal(),this._emit("end")},_(this,x9,"m",qB).bind(this))},0)}_connected(){if(this.ended)return;_(this,v2,"f").call(this),this._emit("connect")}get ended(){return _(this,S4,"f")}get errored(){return _(this,f2,"f")}get aborted(){return _(this,b2,"f")}abort(){this.controller.abort()}on(Y,Z){return(_(this,tY,"f")[Y]||(_(this,tY,"f")[Y]=[])).push({listener:Z}),this}off(Y,Z){let Q=_(this,tY,"f")[Y];if(!Q)return this;let J=Q.findIndex((z)=>z.listener===Z);if(J>=0)Q.splice(J,1);return this}once(Y,Z){return(_(this,tY,"f")[Y]||(_(this,tY,"f")[Y]=[])).push({listener:Z,once:!0}),this}emitted(Y){return new Promise((Z,Q)=>{if(p(this,z8,!0,"f"),Y!=="error")this.once("error",Q);this.once(Y,Z)})}async done(){p(this,z8,!0,"f"),await _(this,E4,"f")}_emit(Y,...Z){if(_(this,S4,"f"))return;if(Y==="end")p(this,S4,!0,"f"),_(this,y2,"f").call(this);let Q=_(this,tY,"f")[Y];if(Q)_(this,tY,"f")[Y]=Q.filter((J)=>!J.once),Q.forEach(({listener:J})=>J(...Z));if(Y==="abort"){let J=Z[0];if(!_(this,z8,"f")&&!Q?.length)Promise.reject(J);_(this,x4,"f").call(this,J),_(this,P4,"f").call(this,J),this._emit("end");return}if(Y==="error"){let J=Z[0];if(!_(this,z8,"f")&&!Q?.length)Promise.reject(J);_(this,x4,"f").call(this,J),_(this,P4,"f").call(this,J),this._emit("end")}}_emitFinal(){}}var x9,S2,v2,x4,E4,y2,P4,tY,S4,f2,b2,z8,qB;var h2=R(()=>{KY();MY();S2=new WeakMap,v2=new WeakMap,x4=new WeakMap,E4=new WeakMap,y2=new WeakMap,P4=new WeakMap,tY=new WeakMap,S4=new WeakMap,f2=new WeakMap,b2=new WeakMap,z8=new WeakMap,x9=new WeakSet,qB=function Y(Z){if(p(this,f2,!0,"f"),Z instanceof Error&&Z.name==="AbortError")Z=new _0;if(Z instanceof _0)return p(this,b2,!0,"f"),this._emit("abort",Z);if(Z instanceof h)return this._emit("error",Z);if(Z instanceof Error){let Q=new h(Z.message);return Q.cause=Z,this._emit("error",Q)}return this._emit("error",new h(String(Z)))}});function UB(Y){return typeof Y.parse==="function"}var m0,E9,g2,P9,S9,v9,BB,VB,UI=10,v4;var y9=R(()=>{KY();MY();A4();h2();v4=class v4 extends K1{constructor(){super(...arguments);m0.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(Y){this._chatCompletions.push(Y),this._emit("chatCompletion",Y);let Z=Y.choices[0]?.message;if(Z)this._addMessage(Z);return Y}_addMessage(Y,Z=!0){if(!("content"in Y))Y.content=null;if(this.messages.push(Y),Z){if(this._emit("message",Y),A9(Y)&&Y.content)this._emit("functionToolCallResult",Y.content);else if(J8(Y)&&Y.tool_calls){for(let Q of Y.tool_calls)if(Q.type==="function")this._emit("functionToolCall",Q.function)}}}async finalChatCompletion(){await this.done();let Y=this._chatCompletions[this._chatCompletions.length-1];if(!Y)throw new h("stream ended without producing a ChatCompletion");return Y}async finalContent(){return await this.done(),_(this,m0,"m",E9).call(this)}async finalMessage(){return await this.done(),_(this,m0,"m",g2).call(this)}async finalFunctionToolCall(){return await this.done(),_(this,m0,"m",P9).call(this)}async finalFunctionToolCallResult(){return await this.done(),_(this,m0,"m",S9).call(this)}async totalUsage(){return await this.done(),_(this,m0,"m",v9).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let Y=this._chatCompletions[this._chatCompletions.length-1];if(Y)this._emit("finalChatCompletion",Y);let Z=_(this,m0,"m",g2).call(this);if(Z)this._emit("finalMessage",Z);let Q=_(this,m0,"m",E9).call(this);if(Q)this._emit("finalContent",Q);let J=_(this,m0,"m",P9).call(this);if(J)this._emit("finalFunctionToolCall",J);let z=_(this,m0,"m",S9).call(this);if(z!=null)this._emit("finalFunctionToolCallResult",z);if(this._chatCompletions.some((X)=>X.usage))this._emit("totalUsage",_(this,m0,"m",v9).call(this))}async _createChatCompletion(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}_(this,m0,"m",BB).call(this,Z);let z=await Y.chat.completions.create({...Z,stream:!1},{...Q,signal:this.controller.signal});return this._connected(),this._addChatCompletion(k4(z,Z))}async _runChatCompletion(Y,Z,Q){for(let J of Z.messages)this._addMessage(J,!1);return await this._createChatCompletion(Y,Z,Q)}async _runTools(Y,Z,Q){let{tool_choice:z="auto",stream:X,...H}=Z,W=typeof z!=="string"&&z.type==="function"&&z?.function?.name,{maxChatCompletions:K=UI}=Q||{},$=Z.tools.map((B)=>{if(W1(B)){if(!B.$callback)throw new h("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:B.$callback,name:B.function.name,description:B.function.description||"",parameters:B.function.parameters,parse:B.$parseRaw,strict:!0}}}return B}),G={};for(let B of $)if(B.type==="function")G[B.function.name||B.function.function.name]=B.function;let U="tools"in Z?$.map((B)=>B.type==="function"?{type:"function",function:{name:B.function.name||B.function.function.name,parameters:B.function.parameters,description:B.function.description,strict:B.function.strict}}:B):void 0;for(let B of Z.messages)this._addMessage(B,!1);for(let B=0;B<K;++B){let V=(await this._createChatCompletion(Y,{...H,tool_choice:z,tools:U,messages:[...this.messages]},Q)).choices[0]?.message;if(!V)throw new h("missing message in ChatCompletion response");if(!V.tool_calls?.length)return;for(let O of V.tool_calls){if(O.type!=="function")continue;let N=O.id,{name:w,arguments:L}=O.function,I=G[w];if(!I){let P=`Invalid tool_call: ${JSON.stringify(w)}. Available options are: ${Object.keys(G).map((m)=>JSON.stringify(m)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:N,content:P});continue}else if(W&&W!==w){let P=`Invalid tool_call: ${JSON.stringify(w)}. ${JSON.stringify(W)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:N,content:P});continue}let T;try{T=UB(I)?await I.parse(L):L}catch(P){let m=P instanceof Error?P.message:String(P);this._addMessage({role:"tool",tool_call_id:N,content:m});continue}let y=await I.function(T,this),E=_(this,m0,"m",VB).call(this,y);if(this._addMessage({role:"tool",tool_call_id:N,content:E}),W)return}}return}};m0=new WeakSet,E9=function Y(){return _(this,m0,"m",g2).call(this).content??null},g2=function Y(){let Z=this.messages.length;while(Z-- >0){let Q=this.messages[Z];if(J8(Q))return{...Q,content:Q.content??null,refusal:Q.refusal??null}}throw new h("stream ended without producing a ChatCompletionMessage with role=assistant")},P9=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(J8(Q)&&Q?.tool_calls?.length)return Q.tool_calls.filter((J)=>J.type==="function").at(-1)?.function}return},S9=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(A9(Q)&&Q.content!=null&&typeof Q.content==="string"&&this.messages.some((J)=>J.role==="assistant"&&J.tool_calls?.some((z)=>z.type==="function"&&z.id===Q.tool_call_id)))return Q.content}return},v9=function Y(){let Z={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:Q}of this._chatCompletions)if(Q)Z.completion_tokens+=Q.completion_tokens,Z.prompt_tokens+=Q.prompt_tokens,Z.total_tokens+=Q.total_tokens;return Z},BB=function Y(Z){if(Z.n!=null&&Z.n>1)throw new h("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},VB=function Y(Z){return typeof Z==="string"?Z:Z===void 0?"undefined":JSON.stringify(Z)}});var y4;var f9=R(()=>{y9();y4=class y4 extends v4{static runTools(Y,Z,Q){let J=new y4,z={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Y,Z,z)),J}_addMessage(Y,Z=!0){if(super._addMessage(Y,Z),J8(Y)&&Y.content)this._emit("content",Y.content)}}});function BI(Y,Z=A0.ALL){if(typeof Y!=="string")throw TypeError(`expecting str, got ${typeof Y}`);if(!Y.trim())throw Error(`${Y} is empty`);return VI(Y.trim(),Z)}var A0,FB,RB,VI=(Y,Z)=>{let Q=Y.length,J=0,z=(B)=>{throw new FB(`${B} at position ${J}`)},X=(B)=>{throw new RB(`${B} at position ${J}`)},H=()=>{if(U(),J>=Q)z("Unexpected end of input");if(Y[J]==='"')return W();if(Y[J]==="{")return K();if(Y[J]==="[")return $();if(Y.substring(J,J+4)==="null"||A0.NULL&Z&&Q-J<4&&"null".startsWith(Y.substring(J)))return J+=4,null;if(Y.substring(J,J+4)==="true"||A0.BOOL&Z&&Q-J<4&&"true".startsWith(Y.substring(J)))return J+=4,!0;if(Y.substring(J,J+5)==="false"||A0.BOOL&Z&&Q-J<5&&"false".startsWith(Y.substring(J)))return J+=5,!1;if(Y.substring(J,J+8)==="Infinity"||A0.INFINITY&Z&&Q-J<8&&"Infinity".startsWith(Y.substring(J)))return J+=8,1/0;if(Y.substring(J,J+9)==="-Infinity"||A0.MINUS_INFINITY&Z&&1<Q-J&&Q-J<9&&"-Infinity".startsWith(Y.substring(J)))return J+=9,-1/0;if(Y.substring(J,J+3)==="NaN"||A0.NAN&Z&&Q-J<3&&"NaN".startsWith(Y.substring(J)))return J+=3,NaN;return G()},W=()=>{let B=J,F=!1;J++;while(J<Q&&(Y[J]!=='"'||F&&Y[J-1]==="\\"))F=Y[J]==="\\"?!F:!1,J++;if(Y.charAt(J)=='"')try{return JSON.parse(Y.substring(B,++J-Number(F)))}catch(V){X(String(V))}else if(A0.STR&Z)try{return JSON.parse(Y.substring(B,J-Number(F))+'"')}catch(V){return JSON.parse(Y.substring(B,Y.lastIndexOf("\\"))+'"')}z("Unterminated string literal")},K=()=>{J++,U();let B={};try{while(Y[J]!=="}"){if(U(),J>=Q&&A0.OBJ&Z)return B;let F=W();U(),J++;try{let V=H();Object.defineProperty(B,F,{value:V,writable:!0,enumerable:!0,configurable:!0})}catch(V){if(A0.OBJ&Z)return B;else throw V}if(U(),Y[J]===",")J++}}catch(F){if(A0.OBJ&Z)return B;else z("Expected '}' at end of object")}return J++,B},$=()=>{J++;let B=[];try{while(Y[J]!=="]")if(B.push(H()),U(),Y[J]===",")J++}catch(F){if(A0.ARR&Z)return B;z("Expected ']' at end of array")}return J++,B},G=()=>{if(J===0){if(Y==="-"&&A0.NUM&Z)z("Not sure what '-' is");try{return JSON.parse(Y)}catch(F){if(A0.NUM&Z)try{if(Y[Y.length-1]===".")return JSON.parse(Y.substring(0,Y.lastIndexOf(".")));return JSON.parse(Y.substring(0,Y.lastIndexOf("e")))}catch(V){}X(String(F))}}let B=J;if(Y[J]==="-")J++;while(Y[J]&&!",]}".includes(Y[J]))J++;if(J==Q&&!(A0.NUM&Z))z("Unterminated number literal");try{return JSON.parse(Y.substring(B,J))}catch(F){if(Y.substring(B,J)==="-"&&A0.NUM&Z)z("Not sure what '-' is");try{return JSON.parse(Y.substring(B,Y.lastIndexOf("e")))}catch(V){X(String(V))}}},U=()=>{while(J<Q&&`
|
|
463
|
-
\r `.includes(Y[J]))J++};return
|
|
464
|
-
${
|
|
465
|
-
${
|
|
466
|
-
${
|
|
467
|
-
${d2(Y)}`);return{...m,id:P,type:E,function:{...c,name:b,arguments:g}}})}};return{...F,message:{...w,content:V,role:L,refusal:$.refusal??null},finish_reason:G,index:U,logprobs:B}}),created:z,model:X,object:"chat.completion",...H?{system_fingerprint:H}:{}};return WB(K,Z)}function d2(Y){return JSON.stringify(Y)}function DB(Y){return}function NB(Y){}var j0,eY,X8,w6,g9,m2,m9,u9,d9,u2,p9,OB,L6;var p2=R(()=>{KY();MB();MY();A4();h9();y9();L6=class L6 extends v4{constructor(Y){super();j0.add(this),eY.set(this,void 0),X8.set(this,void 0),w6.set(this,void 0),p(this,eY,Y,"f"),p(this,X8,[],"f")}get currentChatCompletionSnapshot(){return _(this,w6,"f")}static fromReadableStream(Y){let Z=new L6(null);return Z._run(()=>Z._fromReadableStream(Y)),Z}static createChatCompletion(Y,Z,Q){let J=new L6(Z);return J._run(()=>J._runChatCompletion(Y,{...Z,stream:!0},{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createChatCompletion(Y,Z,Q){super._createChatCompletion;let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}_(this,j0,"m",g9).call(this);let z=await Y.chat.completions.create({...Z,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let X of z)_(this,j0,"m",m9).call(this,X);if(z.controller.signal?.aborted)throw new _0;return this._addChatCompletion(_(this,j0,"m",u2).call(this))}async _fromReadableStream(Y,Z){let Q=Z?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}_(this,j0,"m",g9).call(this),this._connected();let J=t0.fromReadableStream(Y,this.controller),z;for await(let X of J){if(z&&z!==X.id)this._addChatCompletion(_(this,j0,"m",u2).call(this));_(this,j0,"m",m9).call(this,X),z=X.id}if(J.controller.signal?.aborted)throw new _0;return this._addChatCompletion(_(this,j0,"m",u2).call(this))}[(eY=new WeakMap,X8=new WeakMap,w6=new WeakMap,j0=new WeakSet,g9=function Y(){if(this.ended)return;p(this,w6,void 0,"f")},m2=function Y(Z){let Q=_(this,X8,"f")[Z.index];if(Q)return Q;return Q={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},_(this,X8,"f")[Z.index]=Q,Q},m9=function Y(Z){if(this.ended)return;let Q=_(this,j0,"m",OB).call(this,Z);this._emit("chunk",Z,Q);for(let J of Z.choices){let z=Q.choices[J.index];if(J.delta.content!=null&&z.message?.role==="assistant"&&z.message?.content)this._emit("content",J.delta.content,z.message.content),this._emit("content.delta",{delta:J.delta.content,snapshot:z.message.content,parsed:z.message.parsed});if(J.delta.refusal!=null&&z.message?.role==="assistant"&&z.message?.refusal)this._emit("refusal.delta",{delta:J.delta.refusal,snapshot:z.message.refusal});if(J.logprobs?.content!=null&&z.message?.role==="assistant")this._emit("logprobs.content.delta",{content:J.logprobs?.content,snapshot:z.logprobs?.content??[]});if(J.logprobs?.refusal!=null&&z.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:J.logprobs?.refusal,snapshot:z.logprobs?.refusal??[]});let X=_(this,j0,"m",m2).call(this,z);if(z.finish_reason){if(_(this,j0,"m",d9).call(this,z),X.current_tool_call_index!=null)_(this,j0,"m",u9).call(this,z,X.current_tool_call_index)}for(let H of J.delta.tool_calls??[]){if(X.current_tool_call_index!==H.index){if(_(this,j0,"m",d9).call(this,z),X.current_tool_call_index!=null)_(this,j0,"m",u9).call(this,z,X.current_tool_call_index)}X.current_tool_call_index=H.index}for(let H of J.delta.tool_calls??[]){let W=z.message.tool_calls?.[H.index];if(!W?.type)continue;if(W?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:W.function?.name,index:H.index,arguments:W.function.arguments,parsed_arguments:W.function.parsed_arguments,arguments_delta:H.function?.arguments??""});else NB(W?.type)}}},u9=function Y(Z,Q){if(_(this,j0,"m",m2).call(this,Z).done_tool_calls.has(Q))return;let z=Z.message.tool_calls?.[Q];if(!z)throw Error("no tool call snapshot");if(!z.type)throw Error("tool call snapshot missing `type`");if(z.type==="function"){let X=_(this,eY,"f")?.tools?.find((H)=>T4(H)&&H.function.name===z.function.name);this._emit("tool_calls.function.arguments.done",{name:z.function.name,index:Q,arguments:z.function.arguments,parsed_arguments:W1(X)?X.$parseRaw(z.function.arguments):X?.function.strict?JSON.parse(z.function.arguments):null})}else NB(z.type)},d9=function Y(Z){let Q=_(this,j0,"m",m2).call(this,Z);if(Z.message.content&&!Q.content_done){Q.content_done=!0;let J=_(this,j0,"m",p9).call(this);this._emit("content.done",{content:Z.message.content,parsed:J?J.$parseRaw(Z.message.content):null})}if(Z.message.refusal&&!Q.refusal_done)Q.refusal_done=!0,this._emit("refusal.done",{refusal:Z.message.refusal});if(Z.logprobs?.content&&!Q.logprobs_content_done)Q.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:Z.logprobs.content});if(Z.logprobs?.refusal&&!Q.logprobs_refusal_done)Q.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:Z.logprobs.refusal})},u2=function Y(){if(this.ended)throw new h("stream has ended, this shouldn't happen");let Z=_(this,w6,"f");if(!Z)throw new h("request ended without sending any chunks");return p(this,w6,void 0,"f"),p(this,X8,[],"f"),FI(Z,_(this,eY,"f"))},p9=function Y(){let Z=_(this,eY,"f")?.response_format;if(C4(Z))return Z;return null},OB=function Y(Z){var Q,J,z,X;let H=_(this,w6,"f"),{choices:W,...K}=Z;if(!H)H=p(this,w6,{...K,choices:[]},"f");else Object.assign(H,K);for(let{delta:$,finish_reason:G,index:U,logprobs:B=null,...F}of Z.choices){let V=H.choices[U];if(!V)V=H.choices[U]={finish_reason:G,index:U,message:{},logprobs:B,...F};if(B)if(!V.logprobs)V.logprobs=Object.assign({},B);else{let{content:y,refusal:E,...P}=B;if(DB(P),Object.assign(V.logprobs,P),y)(Q=V.logprobs).content??(Q.content=[]),V.logprobs.content.push(...y);if(E)(J=V.logprobs).refusal??(J.refusal=[]),V.logprobs.refusal.push(...E)}if(G){if(V.finish_reason=G,_(this,eY,"f")&&k9(_(this,eY,"f"))){if(G==="length")throw new O4;if(G==="content_filter")throw new D4}}if(Object.assign(V,F),!$)continue;let{content:O,refusal:N,function_call:w,role:L,tool_calls:I,...T}=$;if(DB(T),Object.assign(V.message,T),N)V.message.refusal=(V.message.refusal||"")+N;if(L)V.message.role=L;if(w)if(!V.message.function_call)V.message.function_call=w;else{if(w.name)V.message.function_call.name=w.name;if(w.arguments)(z=V.message.function_call).arguments??(z.arguments=""),V.message.function_call.arguments+=w.arguments}if(O){if(V.message.content=(V.message.content||"")+O,!V.message.refusal&&_(this,j0,"m",p9).call(this))V.message.parsed=b9(V.message.content)}if(I){if(!V.message.tool_calls)V.message.tool_calls=[];for(let{index:y,id:E,type:P,function:m,...g}of I){let b=(X=V.message.tool_calls)[y]??(X[y]={});if(Object.assign(b,g),E)b.id=E;if(P)b.type=P;if(m)b.function??(b.function={name:m.name??"",arguments:""});if(m?.name)b.function.name=m.name;if(m?.arguments){if(b.function.arguments+=m.arguments,KB(_(this,eY,"f"),b))b.function.parsed_arguments=b9(b.function.arguments)}}}}return H},Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("chunk",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,X)=>Z.push({resolve:z,reject:X})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new t0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var H8;var c9=R(()=>{p2();H8=class H8 extends L6{static fromReadableStream(Y){let Z=new H8(null);return Z._run(()=>Z._fromReadableStream(Y)),Z}static runTools(Y,Z,Q){let J=new H8(Z),z={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Y,Z,z)),J}}});var _6;var f4=R(()=>{P2();P2();K0();J0();f9();c9();p2();A4();c9();p2();f9();_6=class _6 extends x{constructor(){super(...arguments);this.messages=new Q8(this._client)}create(Y,Z){return this._client.post("/chat/completions",{body:Y,...Z,stream:Y.stream??!1})}retrieve(Y,Z){return this._client.get(k`/chat/completions/${Y}`,Z)}update(Y,Z,Q){return this._client.post(k`/chat/completions/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/chat/completions",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/chat/completions/${Y}`,Z)}parse(Y,Z){return $B(Y.tools),this._client.chat.completions.create(Y,{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap((Q)=>k4(Q,Y))}runTools(Y,Z){if(Y.stream)return H8.runTools(this._client,Y,Z);return y4.runTools(this._client,Y,Z)}stream(Y,Z){return L6.createChatCompletion(this._client,Y,Z)}};_6.Messages=Q8});var G1;var l9=R(()=>{f4();f4();G1=class G1 extends x{constructor(){super(...arguments);this.completions=new _6(this._client)}};G1.Completions=_6});var wB=R(()=>{f4();P2();f4()});var LB=R(()=>{l9();wB()});var _B=()=>{};function*MI(Y){if(!Y)return;if(IB in Y){let{values:J,nulls:z}=Y;yield*J.entries();for(let X of z)yield[X,null];return}let Z=!1,Q;if(Y instanceof Headers)Q=Y.entries();else if(H9(Y))Q=Y;else Z=!0,Q=Object.entries(Y??{});for(let J of Q){let z=J[0];if(typeof z!=="string")throw TypeError("expected header name to be a string");let X=H9(J[1])?J[1]:[J[1]],H=!1;for(let W of X){if(W===void 0)continue;if(Z&&!H)H=!0,yield[z,null];yield[z,W]}}}var IB,v=(Y)=>{let Z=new Headers,Q=new Set;for(let J of Y){let z=new Set;for(let[X,H]of MI(J)){let W=X.toLowerCase();if(!z.has(W))Z.delete(X),z.add(W);if(H===null)Z.delete(X),Q.add(W);else Z.append(X,H),Q.delete(W)}}return{[IB]:!0,values:Z,nulls:Q}};var U0=R(()=>{oY();IB=Symbol("brand.privateNullableHeaders")});var b4;var i9=R(()=>{U0();b4=class b4 extends x{create(Y,Z){return this._client.post("/audio/speech",{body:Y,...Z,headers:v([{Accept:"application/octet-stream"},Z?.headers]),__binaryResponse:!0})}}});var h4;var n9=R(()=>{kY();h4=class h4 extends x{create(Y,Z){return this._client.post("/audio/transcriptions",e0({body:Y,...Z,stream:Y.stream??!1,__metadata:{model:Y.model}},this._client))}}});var g4;var a9=R(()=>{kY();g4=class g4 extends x{create(Y,Z){return this._client.post("/audio/translations",e0({body:Y,...Z,__metadata:{model:Y.model}},this._client))}}});var Y6;var o9=R(()=>{i9();i9();n9();n9();a9();a9();Y6=class Y6 extends x{constructor(){super(...arguments);this.transcriptions=new h4(this._client),this.translations=new g4(this._client),this.speech=new b4(this._client)}};Y6.Transcriptions=h4;Y6.Translations=g4;Y6.Speech=b4});var W8;var s9=R(()=>{K0();J0();W8=class W8 extends x{create(Y,Z){return this._client.post("/batches",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/batches/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/batches",Z0,{query:Y,...Z})}cancel(Y,Z){return this._client.post(k`/batches/${Y}/cancel`,Z)}}});var m4;var r9=R(()=>{K0();U0();J0();m4=class m4 extends x{create(Y,Z){return this._client.post("/assistants",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(k`/assistants/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(k`/assistants/${Y}`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/assistants",Z0,{query:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(k`/assistants/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var u4;var t9=R(()=>{U0();u4=class u4 extends x{create(Y,Z){return this._client.post("/realtime/sessions",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var d4;var e9=R(()=>{U0();d4=class d4 extends x{create(Y,Z){return this._client.post("/realtime/transcription_sessions",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var $1;var YJ=R(()=>{t9();t9();e9();e9();$1=class $1 extends x{constructor(){super(...arguments);this.sessions=new u4(this._client),this.transcriptionSessions=new d4(this._client)}};$1.Sessions=u4;$1.TranscriptionSessions=d4});var p4;var ZJ=R(()=>{U0();J0();p4=class p4 extends x{create(Y,Z){return this._client.post("/chatkit/sessions",{body:Y,...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}cancel(Y,Z){return this._client.post(k`/chatkit/sessions/${Y}/cancel`,{...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}}});var c4;var QJ=R(()=>{K0();U0();J0();c4=class c4 extends x{retrieve(Y,Z){return this._client.get(k`/chatkit/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}list(Y={},Z){return this._client.getAPIList("/chatkit/threads",N6,{query:Y,...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}delete(Y,Z){return this._client.delete(k`/chatkit/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}listItems(Y,Z={},Q){return this._client.getAPIList(k`/chatkit/threads/${Y}/items`,N6,{query:Z,...Q,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Q?.headers])})}}});var q1;var JJ=R(()=>{ZJ();ZJ();QJ();QJ();q1=class q1 extends x{constructor(){super(...arguments);this.sessions=new p4(this._client),this.threads=new c4(this._client)}};q1.Sessions=p4;q1.Threads=c4});var l4;var zJ=R(()=>{K0();U0();J0();l4=class l4 extends x{create(Y,Z,Q){return this._client.post(k`/threads/${Y}/messages`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{thread_id:J}=Z;return this._client.get(k`/threads/${J}/messages/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(k`/threads/${J}/messages/${Y}`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(k`/threads/${Y}/messages`,Z0,{query:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{thread_id:J}=Z;return this._client.delete(k`/threads/${J}/messages/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var i4;var XJ=R(()=>{K0();U0();J0();i4=class i4 extends x{retrieve(Y,Z,Q){let{thread_id:J,run_id:z,...X}=Z;return this._client.get(k`/threads/${J}/runs/${z}/steps/${Y}`,{query:X,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.getAPIList(k`/threads/${J}/runs/${Y}/steps`,Z0,{query:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var jB=(Y)=>{if(typeof Buffer<"u"){let Z=Buffer.from(Y,"base64");return Array.from(new Float32Array(Z.buffer,Z.byteOffset,Z.length/Float32Array.BYTES_PER_ELEMENT))}else{let Z=atob(Y),Q=Z.length,J=new Uint8Array(Q);for(let z=0;z<Q;z++)J[z]=Z.charCodeAt(z);return Array.from(new Float32Array(J.buffer))}};var TB=R(()=>{jY()});var I6=(Y)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[Y]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(Y)?.trim();return};var n4=R(()=>{oY();TB();L4()});function xI(Y){}var x0,B1,HJ,AY,c2,OY,V1,K8,U1,n2,YY,l2,i2,s4,a4,o4,CB,kB,AB,xB,EB,PB,SB,j6;var WJ=R(()=>{KY();h9();MY();h2();n4();j6=class j6 extends K1{constructor(){super(...arguments);x0.add(this),HJ.set(this,[]),AY.set(this,{}),c2.set(this,{}),OY.set(this,void 0),V1.set(this,void 0),K8.set(this,void 0),U1.set(this,void 0),n2.set(this,void 0),YY.set(this,void 0),l2.set(this,void 0),i2.set(this,void 0),s4.set(this,void 0)}[(HJ=new WeakMap,AY=new WeakMap,c2=new WeakMap,OY=new WeakMap,V1=new WeakMap,K8=new WeakMap,U1=new WeakMap,n2=new WeakMap,YY=new WeakMap,l2=new WeakMap,i2=new WeakMap,s4=new WeakMap,x0=new WeakSet,Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,X)=>Z.push({resolve:z,reject:X})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream(Y){let Z=new B1;return Z._run(()=>Z._fromReadableStream(Y)),Z}async _fromReadableStream(Y,Z){let Q=Z?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}this._connected();let J=t0.fromReadableStream(Y,this.controller);for await(let z of J)_(this,x0,"m",a4).call(this,z);if(J.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}toReadableStream(){return new t0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(Y,Z,Q,J){let z=new B1;return z._run(()=>z._runToolAssistantStream(Y,Z,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),z}async _createToolAssistantStream(Y,Z,Q,J){let z=J?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}let X={...Q,stream:!0},H=await Y.submitToolOutputs(Z,X,{...J,signal:this.controller.signal});this._connected();for await(let W of H)_(this,x0,"m",a4).call(this,W);if(H.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}static createThreadAssistantStream(Y,Z,Q){let J=new B1;return J._run(()=>J._threadAssistantStream(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}static createAssistantStream(Y,Z,Q,J){let z=new B1;return z._run(()=>z._runAssistantStream(Y,Z,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),z}currentEvent(){return _(this,l2,"f")}currentRun(){return _(this,i2,"f")}currentMessageSnapshot(){return _(this,OY,"f")}currentRunStepSnapshot(){return _(this,s4,"f")}async finalRunSteps(){return await this.done(),Object.values(_(this,AY,"f"))}async finalMessages(){return await this.done(),Object.values(_(this,c2,"f"))}async finalRun(){if(await this.done(),!_(this,V1,"f"))throw Error("Final run was not received.");return _(this,V1,"f")}async _createThreadAssistantStream(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}let z={...Z,stream:!0},X=await Y.createAndRun(z,{...Q,signal:this.controller.signal});this._connected();for await(let H of X)_(this,x0,"m",a4).call(this,H);if(X.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}async _createAssistantStream(Y,Z,Q,J){let z=J?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}let X={...Q,stream:!0},H=await Y.create(Z,X,{...J,signal:this.controller.signal});this._connected();for await(let W of H)_(this,x0,"m",a4).call(this,W);if(H.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}static accumulateDelta(Y,Z){for(let[Q,J]of Object.entries(Z)){if(!Y.hasOwnProperty(Q)){Y[Q]=J;continue}let z=Y[Q];if(z===null||z===void 0){Y[Q]=J;continue}if(Q==="index"||Q==="type"){Y[Q]=J;continue}if(typeof z==="string"&&typeof J==="string")z+=J;else if(typeof z==="number"&&typeof J==="number")z+=J;else if(N4(z)&&N4(J))z=this.accumulateDelta(z,J);else if(Array.isArray(z)&&Array.isArray(J)){if(z.every((X)=>typeof X==="string"||typeof X==="number")){z.push(...J);continue}for(let X of J){if(!N4(X))throw Error(`Expected array delta entry to be an object but got: ${X}`);let H=X.index;if(H==null)throw console.error(X),Error("Expected array delta entry to have an `index` property");if(typeof H!=="number")throw Error(`Expected array delta entry \`index\` property to be a number but got ${H}`);let W=z[H];if(W==null)z.push(X);else z[H]=this.accumulateDelta(W,X)}continue}else throw Error(`Unhandled record type: ${Q}, deltaValue: ${J}, accValue: ${z}`);Y[Q]=z}return Y}_addRun(Y){return Y}async _threadAssistantStream(Y,Z,Q){return await this._createThreadAssistantStream(Z,Y,Q)}async _runAssistantStream(Y,Z,Q,J){return await this._createAssistantStream(Z,Y,Q,J)}async _runToolAssistantStream(Y,Z,Q,J){return await this._createToolAssistantStream(Z,Y,Q,J)}};B1=j6,a4=function Y(Z){if(this.ended)return;switch(p(this,l2,Z,"f"),_(this,x0,"m",AB).call(this,Z),Z.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":_(this,x0,"m",SB).call(this,Z);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":_(this,x0,"m",kB).call(this,Z);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":_(this,x0,"m",CB).call(this,Z);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier");default:xI(Z)}},o4=function Y(){if(this.ended)throw new h("stream has ended, this shouldn't happen");if(!_(this,V1,"f"))throw Error("Final run has not been received");return _(this,V1,"f")},CB=function Y(Z){let[Q,J]=_(this,x0,"m",EB).call(this,Z,_(this,OY,"f"));p(this,OY,Q,"f"),_(this,c2,"f")[Q.id]=Q;for(let z of J){let X=Q.content[z.index];if(X?.type=="text")this._emit("textCreated",X.text)}switch(Z.event){case"thread.message.created":this._emit("messageCreated",Z.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",Z.data.delta,Q),Z.data.delta.content)for(let z of Z.data.delta.content){if(z.type=="text"&&z.text){let X=z.text,H=Q.content[z.index];if(H&&H.type=="text")this._emit("textDelta",X,H.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(z.index!=_(this,K8,"f")){if(_(this,U1,"f"))switch(_(this,U1,"f").type){case"text":this._emit("textDone",_(this,U1,"f").text,_(this,OY,"f"));break;case"image_file":this._emit("imageFileDone",_(this,U1,"f").image_file,_(this,OY,"f"));break}p(this,K8,z.index,"f")}p(this,U1,Q.content[z.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(_(this,K8,"f")!==void 0){let z=Z.data.content[_(this,K8,"f")];if(z)switch(z.type){case"image_file":this._emit("imageFileDone",z.image_file,_(this,OY,"f"));break;case"text":this._emit("textDone",z.text,_(this,OY,"f"));break}}if(_(this,OY,"f"))this._emit("messageDone",Z.data);p(this,OY,void 0,"f")}},kB=function Y(Z){let Q=_(this,x0,"m",xB).call(this,Z);switch(p(this,s4,Q,"f"),Z.event){case"thread.run.step.created":this._emit("runStepCreated",Z.data);break;case"thread.run.step.delta":let J=Z.data.delta;if(J.step_details&&J.step_details.type=="tool_calls"&&J.step_details.tool_calls&&Q.step_details.type=="tool_calls")for(let X of J.step_details.tool_calls)if(X.index==_(this,n2,"f"))this._emit("toolCallDelta",X,Q.step_details.tool_calls[X.index]);else{if(_(this,YY,"f"))this._emit("toolCallDone",_(this,YY,"f"));if(p(this,n2,X.index,"f"),p(this,YY,Q.step_details.tool_calls[X.index],"f"),_(this,YY,"f"))this._emit("toolCallCreated",_(this,YY,"f"))}this._emit("runStepDelta",Z.data.delta,Q);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(p(this,s4,void 0,"f"),Z.data.step_details.type=="tool_calls"){if(_(this,YY,"f"))this._emit("toolCallDone",_(this,YY,"f")),p(this,YY,void 0,"f")}this._emit("runStepDone",Z.data,Q);break;case"thread.run.step.in_progress":break}},AB=function Y(Z){_(this,HJ,"f").push(Z),this._emit("event",Z)},xB=function Y(Z){switch(Z.event){case"thread.run.step.created":return _(this,AY,"f")[Z.data.id]=Z.data,Z.data;case"thread.run.step.delta":let Q=_(this,AY,"f")[Z.data.id];if(!Q)throw Error("Received a RunStepDelta before creation of a snapshot");let J=Z.data;if(J.delta){let z=B1.accumulateDelta(Q,J.delta);_(this,AY,"f")[Z.data.id]=z}return _(this,AY,"f")[Z.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":_(this,AY,"f")[Z.data.id]=Z.data;break}if(_(this,AY,"f")[Z.data.id])return _(this,AY,"f")[Z.data.id];throw Error("No snapshot available")},EB=function Y(Z,Q){let J=[];switch(Z.event){case"thread.message.created":return[Z.data,J];case"thread.message.delta":if(!Q)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let z=Z.data;if(z.delta.content)for(let X of z.delta.content)if(X.index in Q.content){let H=Q.content[X.index];Q.content[X.index]=_(this,x0,"m",PB).call(this,X,H)}else Q.content[X.index]=X,J.push(X);return[Q,J];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(Q)return[Q,J];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},PB=function Y(Z,Q){return B1.accumulateDelta(Q,Z)},SB=function Y(Z){switch(p(this,i2,Z.data,"f"),Z.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":if(p(this,V1,Z.data,"f"),_(this,YY,"f"))this._emit("toolCallDone",_(this,YY,"f")),p(this,YY,void 0,"f");break;case"thread.run.cancelling":break}}});var G8;var KJ=R(()=>{XJ();XJ();K0();U0();WJ();J0();G8=class G8 extends x{constructor(){super(...arguments);this.steps=new i4(this._client)}create(Y,Z,Q){let{include:J,...z}=Z;return this._client.post(k`/threads/${Y}/runs`,{query:{include:J},body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}retrieve(Y,Z,Q){let{thread_id:J}=Z;return this._client.get(k`/threads/${J}/runs/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(k`/threads/${J}/runs/${Y}`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(k`/threads/${Y}/runs`,Z0,{query:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{thread_id:J}=Z;return this._client.post(k`/threads/${J}/runs/${Y}/cancel`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z,Q);return await this.poll(J.id,{thread_id:Y},Q)}createAndStream(Y,Z,Q){return j6.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}async poll(Y,Z,Q){let J=v([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:z,response:X}=await this.retrieve(Y,Z,{...Q,headers:{...Q?.headers,...J}}).withResponse();switch(z.status){case"queued":case"in_progress":case"cancelling":let H=5000;if(Q?.pollIntervalMs)H=Q.pollIntervalMs;else{let W=X.headers.get("openai-poll-after-ms");if(W){let K=parseInt(W);if(!isNaN(K))H=K}}await TY(H);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return z}}}stream(Y,Z,Q){return j6.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}submitToolOutputs(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(k`/threads/${J}/runs/${Y}/submit_tool_outputs`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}async submitToolOutputsAndPoll(Y,Z,Q){let J=await this.submitToolOutputs(Y,Z,Q);return await this.poll(J.id,Z,Q)}submitToolOutputsStream(Y,Z,Q){return j6.createToolAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}};G8.Steps=i4});var F1;var GJ=R(()=>{zJ();zJ();KJ();KJ();U0();WJ();J0();F1=class F1 extends x{constructor(){super(...arguments);this.runs=new G8(this._client),this.messages=new l4(this._client)}create(Y={},Z){return this._client.post("/threads",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(k`/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(k`/threads/${Y}`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z){return this._client.delete(k`/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}createAndRun(Y,Z){return this._client.post("/threads/runs",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),stream:Y.stream??!1})}async createAndRunPoll(Y,Z){let Q=await this.createAndRun(Y,Z);return await this.runs.poll(Q.id,{thread_id:Q.thread_id},Z)}createAndRunStream(Y,Z){return j6.createThreadAssistantStream(Y,this._client.beta.threads,Z)}};F1.Runs=G8;F1.Messages=l4});var xY;var $J=R(()=>{r9();r9();YJ();YJ();JJ();JJ();GJ();GJ();xY=class xY extends x{constructor(){super(...arguments);this.realtime=new $1(this._client),this.chatkit=new q1(this._client),this.assistants=new m4(this._client),this.threads=new F1(this._client)}};xY.Realtime=$1;xY.ChatKit=q1;xY.Assistants=m4;xY.Threads=F1});var $8;var qJ=R(()=>{$8=class $8 extends x{create(Y,Z){return this._client.post("/completions",{body:Y,...Z,stream:Y.stream??!1})}}});var r4;var UJ=R(()=>{U0();J0();r4=class r4 extends x{retrieve(Y,Z,Q){let{container_id:J}=Z;return this._client.get(k`/containers/${J}/files/${Y}/content`,{...Q,headers:v([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}}});var q8;var BJ=R(()=>{UJ();UJ();K0();U0();kY();J0();q8=class q8 extends x{constructor(){super(...arguments);this.content=new r4(this._client)}create(Y,Z,Q){return this._client.post(k`/containers/${Y}/files`,e0({body:Z,...Q},this._client))}retrieve(Y,Z,Q){let{container_id:J}=Z;return this._client.get(k`/containers/${J}/files/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(k`/containers/${Y}/files`,Z0,{query:Z,...Q})}delete(Y,Z,Q){let{container_id:J}=Z;return this._client.delete(k`/containers/${J}/files/${Y}`,{...Q,headers:v([{Accept:"*/*"},Q?.headers])})}};q8.Content=r4});var R1;var VJ=R(()=>{BJ();BJ();K0();U0();J0();R1=class R1 extends x{constructor(){super(...arguments);this.files=new q8(this._client)}create(Y,Z){return this._client.post("/containers",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/containers/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/containers",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/containers/${Y}`,{...Z,headers:v([{Accept:"*/*"},Z?.headers])})}};R1.Files=q8});var t4;var FJ=R(()=>{K0();J0();t4=class t4 extends x{create(Y,Z,Q){let{include:J,...z}=Z;return this._client.post(k`/conversations/${Y}/items`,{query:{include:J},body:z,...Q})}retrieve(Y,Z,Q){let{conversation_id:J,...z}=Z;return this._client.get(k`/conversations/${J}/items/${Y}`,{query:z,...Q})}list(Y,Z={},Q){return this._client.getAPIList(k`/conversations/${Y}/items`,N6,{query:Z,...Q})}delete(Y,Z,Q){let{conversation_id:J}=Z;return this._client.delete(k`/conversations/${J}/items/${Y}`,Q)}}});var M1;var RJ=R(()=>{FJ();FJ();J0();M1=class M1 extends x{constructor(){super(...arguments);this.items=new t4(this._client)}create(Y={},Z){return this._client.post("/conversations",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/conversations/${Y}`,Z)}update(Y,Z,Q){return this._client.post(k`/conversations/${Y}`,{body:Z,...Q})}delete(Y,Z){return this._client.delete(k`/conversations/${Y}`,Z)}};M1.Items=t4});var U8;var MJ=R(()=>{n4();U8=class U8 extends x{create(Y,Z){let Q=!!Y.encoding_format,J=Q?Y.encoding_format:"base64";if(Q)R0(this._client).debug("embeddings/user defined encoding_format:",Y.encoding_format);let z=this._client.post("/embeddings",{body:{...Y,encoding_format:J},...Z});if(Q)return z;return R0(this._client).debug("embeddings/decoding base64 embeddings from base64"),z._thenUnwrap((X)=>{if(X&&X.data)X.data.forEach((H)=>{let W=H.embedding;H.embedding=jB(W)});return X})}}});var e4;var OJ=R(()=>{K0();J0();e4=class e4 extends x{retrieve(Y,Z,Q){let{eval_id:J,run_id:z}=Z;return this._client.get(k`/evals/${J}/runs/${z}/output_items/${Y}`,Q)}list(Y,Z,Q){let{eval_id:J,...z}=Z;return this._client.getAPIList(k`/evals/${J}/runs/${Y}/output_items`,Z0,{query:z,...Q})}}});var B8;var DJ=R(()=>{OJ();OJ();K0();J0();B8=class B8 extends x{constructor(){super(...arguments);this.outputItems=new e4(this._client)}create(Y,Z,Q){return this._client.post(k`/evals/${Y}/runs`,{body:Z,...Q})}retrieve(Y,Z,Q){let{eval_id:J}=Z;return this._client.get(k`/evals/${J}/runs/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(k`/evals/${Y}/runs`,Z0,{query:Z,...Q})}delete(Y,Z,Q){let{eval_id:J}=Z;return this._client.delete(k`/evals/${J}/runs/${Y}`,Q)}cancel(Y,Z,Q){let{eval_id:J}=Z;return this._client.post(k`/evals/${J}/runs/${Y}`,Q)}};B8.OutputItems=e4});var O1;var NJ=R(()=>{DJ();DJ();K0();J0();O1=class O1 extends x{constructor(){super(...arguments);this.runs=new B8(this._client)}create(Y,Z){return this._client.post("/evals",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/evals/${Y}`,Z)}update(Y,Z,Q){return this._client.post(k`/evals/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/evals",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/evals/${Y}`,Z)}};O1.Runs=B8});var V8;var wJ=R(()=>{K0();U0();MY();kY();J0();V8=class V8 extends x{create(Y,Z){return this._client.post("/files",e0({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(k`/files/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/files",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/files/${Y}`,Z)}content(Y,Z){return this._client.get(k`/files/${Y}/content`,{...Z,headers:v([{Accept:"application/binary"},Z?.headers]),__binaryResponse:!0})}async waitForProcessing(Y,{pollInterval:Z=5000,maxWait:Q=1800000}={}){let J=new Set(["processed","error","deleted"]),z=Date.now(),X=await this.retrieve(Y);while(!X.status||!J.has(X.status))if(await TY(Z),X=await this.retrieve(Y),Date.now()-z>Q)throw new X1({message:`Giving up on waiting for file ${Y} to finish processing after ${Q} milliseconds.`});return X}}});var YZ;var LJ=R(()=>{YZ=class YZ extends x{}});var ZZ;var _J=R(()=>{ZZ=class ZZ extends x{run(Y,Z){return this._client.post("/fine_tuning/alpha/graders/run",{body:Y,...Z})}validate(Y,Z){return this._client.post("/fine_tuning/alpha/graders/validate",{body:Y,...Z})}}});var F8;var IJ=R(()=>{_J();_J();F8=class F8 extends x{constructor(){super(...arguments);this.graders=new ZZ(this._client)}};F8.Graders=ZZ});var QZ;var jJ=R(()=>{K0();J0();QZ=class QZ extends x{create(Y,Z,Q){return this._client.getAPIList(k`/fine_tuning/checkpoints/${Y}/permissions`,rY,{body:Z,method:"post",...Q})}retrieve(Y,Z={},Q){return this._client.get(k`/fine_tuning/checkpoints/${Y}/permissions`,{query:Z,...Q})}delete(Y,Z,Q){let{fine_tuned_model_checkpoint:J}=Z;return this._client.delete(k`/fine_tuning/checkpoints/${J}/permissions/${Y}`,Q)}}});var R8;var TJ=R(()=>{jJ();jJ();R8=class R8 extends x{constructor(){super(...arguments);this.permissions=new QZ(this._client)}};R8.Permissions=QZ});var JZ;var CJ=R(()=>{K0();J0();JZ=class JZ extends x{list(Y,Z={},Q){return this._client.getAPIList(k`/fine_tuning/jobs/${Y}/checkpoints`,Z0,{query:Z,...Q})}}});var M8;var kJ=R(()=>{CJ();CJ();K0();J0();M8=class M8 extends x{constructor(){super(...arguments);this.checkpoints=new JZ(this._client)}create(Y,Z){return this._client.post("/fine_tuning/jobs",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/fine_tuning/jobs/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/fine_tuning/jobs",Z0,{query:Y,...Z})}cancel(Y,Z){return this._client.post(k`/fine_tuning/jobs/${Y}/cancel`,Z)}listEvents(Y,Z={},Q){return this._client.getAPIList(k`/fine_tuning/jobs/${Y}/events`,Z0,{query:Z,...Q})}pause(Y,Z){return this._client.post(k`/fine_tuning/jobs/${Y}/pause`,Z)}resume(Y,Z){return this._client.post(k`/fine_tuning/jobs/${Y}/resume`,Z)}};M8.Checkpoints=JZ});var EY;var AJ=R(()=>{LJ();LJ();IJ();IJ();TJ();TJ();kJ();kJ();EY=class EY extends x{constructor(){super(...arguments);this.methods=new YZ(this._client),this.jobs=new M8(this._client),this.checkpoints=new R8(this._client),this.alpha=new F8(this._client)}};EY.Methods=YZ;EY.Jobs=M8;EY.Checkpoints=R8;EY.Alpha=F8});var zZ;var xJ=R(()=>{zZ=class zZ extends x{}});var D1;var EJ=R(()=>{xJ();xJ();D1=class D1 extends x{constructor(){super(...arguments);this.graderModels=new zZ(this._client)}};D1.GraderModels=zZ});var O8;var PJ=R(()=>{kY();O8=class O8 extends x{createVariation(Y,Z){return this._client.post("/images/variations",e0({body:Y,...Z},this._client))}edit(Y,Z){return this._client.post("/images/edits",e0({body:Y,...Z,stream:Y.stream??!1},this._client))}generate(Y,Z){return this._client.post("/images/generations",{body:Y,...Z,stream:Y.stream??!1})}}});var D8;var SJ=R(()=>{K0();J0();D8=class D8 extends x{retrieve(Y,Z){return this._client.get(k`/models/${Y}`,Z)}list(Y){return this._client.getAPIList("/models",rY,Y)}delete(Y,Z){return this._client.delete(k`/models/${Y}`,Z)}}});var N8;var vJ=R(()=>{N8=class N8 extends x{create(Y,Z){return this._client.post("/moderations",{body:Y,...Z})}}});var XZ;var yJ=R(()=>{U0();J0();XZ=class XZ extends x{accept(Y,Z,Q){return this._client.post(k`/realtime/calls/${Y}/accept`,{body:Z,...Q,headers:v([{Accept:"*/*"},Q?.headers])})}hangup(Y,Z){return this._client.post(k`/realtime/calls/${Y}/hangup`,{...Z,headers:v([{Accept:"*/*"},Z?.headers])})}refer(Y,Z,Q){return this._client.post(k`/realtime/calls/${Y}/refer`,{body:Z,...Q,headers:v([{Accept:"*/*"},Q?.headers])})}reject(Y,Z={},Q){return this._client.post(k`/realtime/calls/${Y}/reject`,{body:Z,...Q,headers:v([{Accept:"*/*"},Q?.headers])})}}});var HZ;var fJ=R(()=>{HZ=class HZ extends x{create(Y,Z){return this._client.post("/realtime/client_secrets",{body:Y,...Z})}}});var T6;var bJ=R(()=>{yJ();yJ();fJ();fJ();T6=class T6 extends x{constructor(){super(...arguments);this.clientSecrets=new HZ(this._client),this.calls=new XZ(this._client)}};T6.ClientSecrets=HZ;T6.Calls=XZ});function vB(Y,Z){if(!Z||!oI(Z))return{...Y,output_parsed:null,output:Y.output.map((Q)=>{if(Q.type==="function_call")return{...Q,parsed_arguments:null};if(Q.type==="message")return{...Q,content:Q.content.map((J)=>({...J,parsed:null}))};else return Q})};return hJ(Y,Z)}function hJ(Y,Z){let Q=Y.output.map((z)=>{if(z.type==="function_call")return{...z,parsed_arguments:tI(Z,z)};if(z.type==="message"){let X=z.content.map((H)=>{if(H.type==="output_text")return{...H,parsed:aI(Z,H.text)};return H});return{...z,content:X}}return z}),J=Object.assign({},Y,{output:Q});if(!Object.getOwnPropertyDescriptor(Y,"output_text"))a2(J);return Object.defineProperty(J,"output_parsed",{enumerable:!0,get(){for(let z of J.output){if(z.type!=="message")continue;for(let X of z.content)if(X.type==="output_text"&&X.parsed!==null)return X.parsed}return null}}),J}function aI(Y,Z){if(Y.text?.format?.type!=="json_schema")return null;if("$parseRaw"in Y.text?.format)return(Y.text?.format).$parseRaw(Z);return JSON.parse(Z)}function oI(Y){if(C4(Y.text?.format))return!0;return!1}function sI(Y){return Y?.$brand==="auto-parseable-tool"}function rI(Y,Z){return Y.find((Q)=>Q.type==="function"&&Q.name===Z)}function tI(Y,Z){let Q=rI(Y.tools??[],Z.name);return{...Z,...Z,parsed_arguments:sI(Q)?Q.$parseRaw(Z.arguments):Q?.strict?JSON.parse(Z.arguments):null}}function a2(Y){let Z=[];for(let Q of Y.output){if(Q.type!=="message")continue;for(let J of Q.content)if(J.type==="output_text")Z.push(J.text)}Y.output_text=Z.join("")}var gJ=R(()=>{MY();A4()});function eI(Y,Z){return vB(Y,Z)}var w8,o2,C6,s2,yB,fB,bB,hB,r2;var gB=R(()=>{KY();MY();h2();gJ();r2=class r2 extends K1{constructor(Y){super();w8.add(this),o2.set(this,void 0),C6.set(this,void 0),s2.set(this,void 0),p(this,o2,Y,"f")}static createResponse(Y,Z,Q){let J=new r2(Z);return J._run(()=>J._createOrRetrieveResponse(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createOrRetrieveResponse(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}_(this,w8,"m",yB).call(this);let z,X=null;if("response_id"in Z)z=await Y.responses.retrieve(Z.response_id,{stream:!0},{...Q,signal:this.controller.signal,stream:!0}),X=Z.starting_after??null;else z=await Y.responses.create({...Z,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let H of z)_(this,w8,"m",fB).call(this,H,X);if(z.controller.signal?.aborted)throw new _0;return _(this,w8,"m",bB).call(this)}[(o2=new WeakMap,C6=new WeakMap,s2=new WeakMap,w8=new WeakSet,yB=function Y(){if(this.ended)return;p(this,C6,void 0,"f")},fB=function Y(Z,Q){if(this.ended)return;let J=(X,H)=>{if(Q==null||H.sequence_number>Q)this._emit(X,H)},z=_(this,w8,"m",hB).call(this,Z);switch(J("event",Z),Z.type){case"response.output_text.delta":{let X=z.output[Z.output_index];if(!X)throw new h(`missing output at index ${Z.output_index}`);if(X.type==="message"){let H=X.content[Z.content_index];if(!H)throw new h(`missing content at index ${Z.content_index}`);if(H.type!=="output_text")throw new h(`expected content to be 'output_text', got ${H.type}`);J("response.output_text.delta",{...Z,snapshot:H.text})}break}case"response.function_call_arguments.delta":{let X=z.output[Z.output_index];if(!X)throw new h(`missing output at index ${Z.output_index}`);if(X.type==="function_call")J("response.function_call_arguments.delta",{...Z,snapshot:X.arguments});break}default:J(Z.type,Z);break}},bB=function Y(){if(this.ended)throw new h("stream has ended, this shouldn't happen");let Z=_(this,C6,"f");if(!Z)throw new h("request ended without sending any events");p(this,C6,void 0,"f");let Q=eI(Z,_(this,o2,"f"));return p(this,s2,Q,"f"),Q},hB=function Y(Z){let Q=_(this,C6,"f");if(!Q){if(Z.type!=="response.created")throw new h(`When snapshot hasn't been set yet, expected 'response.created' event, got ${Z.type}`);return Q=p(this,C6,Z.response,"f"),Q}switch(Z.type){case"response.output_item.added":{Q.output.push(Z.item);break}case"response.content_part.added":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);let z=J.type,X=Z.part;if(z==="message"&&X.type!=="reasoning_text")J.content.push(X);else if(z==="reasoning"&&X.type==="reasoning_text"){if(!J.content)J.content=[];J.content.push(X)}break}case"response.output_text.delta":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);if(J.type==="message"){let z=J.content[Z.content_index];if(!z)throw new h(`missing content at index ${Z.content_index}`);if(z.type!=="output_text")throw new h(`expected content to be 'output_text', got ${z.type}`);z.text+=Z.delta}break}case"response.function_call_arguments.delta":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);if(J.type==="function_call")J.arguments+=Z.delta;break}case"response.reasoning_text.delta":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);if(J.type==="reasoning"){let z=J.content?.[Z.content_index];if(!z)throw new h(`missing content at index ${Z.content_index}`);if(z.type!=="reasoning_text")throw new h(`expected content to be 'reasoning_text', got ${z.type}`);z.text+=Z.delta}break}case"response.completed":{p(this,C6,Z.response,"f");break}}return Q},Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,X)=>Z.push({resolve:z,reject:X})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let Y=_(this,s2,"f");if(!Y)throw new h("stream ended without producing a ChatCompletion");return Y}}});var WZ;var mJ=R(()=>{K0();J0();WZ=class WZ extends x{list(Y,Z={},Q){return this._client.getAPIList(k`/responses/${Y}/input_items`,Z0,{query:Z,...Q})}}});var KZ;var uJ=R(()=>{KZ=class KZ extends x{count(Y={},Z){return this._client.post("/responses/input_tokens",{body:Y,...Z})}}});var k6;var dJ=R(()=>{gJ();gB();mJ();mJ();uJ();uJ();U0();J0();k6=class k6 extends x{constructor(){super(...arguments);this.inputItems=new WZ(this._client),this.inputTokens=new KZ(this._client)}create(Y,Z){return this._client.post("/responses",{body:Y,...Z,stream:Y.stream??!1})._thenUnwrap((Q)=>{if("object"in Q&&Q.object==="response")a2(Q);return Q})}retrieve(Y,Z={},Q){return this._client.get(k`/responses/${Y}`,{query:Z,...Q,stream:Z?.stream??!1})._thenUnwrap((J)=>{if("object"in J&&J.object==="response")a2(J);return J})}delete(Y,Z){return this._client.delete(k`/responses/${Y}`,{...Z,headers:v([{Accept:"*/*"},Z?.headers])})}parse(Y,Z){return this._client.responses.create(Y,Z)._thenUnwrap((Q)=>hJ(Q,Y))}stream(Y,Z){return r2.createResponse(this._client,Y,Z)}cancel(Y,Z){return this._client.post(k`/responses/${Y}/cancel`,Z)}compact(Y,Z){return this._client.post("/responses/compact",{body:Y,...Z})}};k6.InputItems=WZ;k6.InputTokens=KZ});var GZ;var pJ=R(()=>{kY();J0();GZ=class GZ extends x{create(Y,Z,Q){return this._client.post(k`/uploads/${Y}/parts`,e0({body:Z,...Q},this._client))}}});var N1;var cJ=R(()=>{pJ();pJ();J0();N1=class N1 extends x{constructor(){super(...arguments);this.parts=new GZ(this._client)}create(Y,Z){return this._client.post("/uploads",{body:Y,...Z})}cancel(Y,Z){return this._client.post(k`/uploads/${Y}/cancel`,Z)}complete(Y,Z,Q){return this._client.post(k`/uploads/${Y}/complete`,{body:Z,...Q})}};N1.Parts=GZ});var mB=async(Y)=>{let Z=await Promise.allSettled(Y),Q=Z.filter((z)=>z.status==="rejected");if(Q.length){for(let z of Q)console.error(z.reason);throw Error(`${Q.length} promise(s) failed - see the above errors`)}let J=[];for(let z of Z)if(z.status==="fulfilled")J.push(z.value);return J};var $Z;var lJ=R(()=>{K0();U0();J0();$Z=class $Z extends x{create(Y,Z,Q){return this._client.post(k`/vector_stores/${Y}/file_batches`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.get(k`/vector_stores/${J}/file_batches/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.post(k`/vector_stores/${J}/file_batches/${Y}/cancel`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z);return await this.poll(Y,J.id,Q)}listFiles(Y,Z,Q){let{vector_store_id:J,...z}=Z;return this._client.getAPIList(k`/vector_stores/${J}/file_batches/${Y}/files`,Z0,{query:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async poll(Y,Z,Q){let J=v([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:z,response:X}=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:J}).withResponse();switch(z.status){case"in_progress":let H=5000;if(Q?.pollIntervalMs)H=Q.pollIntervalMs;else{let W=X.headers.get("openai-poll-after-ms");if(W){let K=parseInt(W);if(!isNaN(K))H=K}}await TY(H);break;case"failed":case"cancelled":case"completed":return z}}}async uploadAndPoll(Y,{files:Z,fileIds:Q=[]},J){if(Z==null||Z.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let z=J?.maxConcurrency??5,X=Math.min(z,Z.length),H=this._client,W=Z.values(),K=[...Q];async function $(U){for(let B of U){let F=await H.files.create({file:B,purpose:"assistants"},J);K.push(F.id)}}let G=Array(X).fill(W).map($);return await mB(G),await this.createAndPoll(Y,{file_ids:K})}}});var qZ;var iJ=R(()=>{K0();U0();n4();J0();qZ=class qZ extends x{create(Y,Z,Q){return this._client.post(k`/vector_stores/${Y}/files`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.get(k`/vector_stores/${J}/files/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{vector_store_id:J,...z}=Z;return this._client.post(k`/vector_stores/${J}/files/${Y}`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(k`/vector_stores/${Y}/files`,Z0,{query:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.delete(k`/vector_stores/${J}/files/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z,Q);return await this.poll(Y,J.id,Q)}async poll(Y,Z,Q){let J=v([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let z=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:J}).withResponse(),X=z.data;switch(X.status){case"in_progress":let H=5000;if(Q?.pollIntervalMs)H=Q.pollIntervalMs;else{let W=z.response.headers.get("openai-poll-after-ms");if(W){let K=parseInt(W);if(!isNaN(K))H=K}}await TY(H);break;case"failed":case"completed":return X}}}async upload(Y,Z,Q){let J=await this._client.files.create({file:Z,purpose:"assistants"},Q);return this.create(Y,{file_id:J.id},Q)}async uploadAndPoll(Y,Z,Q){let J=await this.upload(Y,Z,Q);return await this.poll(Y,J.id,Q)}content(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.getAPIList(k`/vector_stores/${J}/files/${Y}/content`,rY,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var A6;var nJ=R(()=>{lJ();lJ();iJ();iJ();K0();U0();J0();A6=class A6 extends x{constructor(){super(...arguments);this.files=new qZ(this._client),this.fileBatches=new $Z(this._client)}create(Y,Z){return this._client.post("/vector_stores",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(k`/vector_stores/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(k`/vector_stores/${Y}`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/vector_stores",Z0,{query:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(k`/vector_stores/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}search(Y,Z,Q){return this._client.getAPIList(k`/vector_stores/${Y}/search`,rY,{body:Z,method:"post",...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}};A6.Files=qZ;A6.FileBatches=$Z});var L8;var aJ=R(()=>{K0();U0();kY();J0();L8=class L8 extends x{create(Y,Z){return this._client.post("/videos",j9({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(k`/videos/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/videos",N6,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/videos/${Y}`,Z)}downloadContent(Y,Z={},Q){return this._client.get(k`/videos/${Y}/content`,{query:Z,...Q,headers:v([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}remix(Y,Z,Q){return this._client.post(k`/videos/${Y}/remix`,j9({body:Z,...Q},this._client))}}});var _8,uB,t2,I8;var oJ=R(()=>{KY();MY();U0();I8=class I8 extends x{constructor(){super(...arguments);_8.add(this)}async unwrap(Y,Z,Q=this._client.webhookSecret,J=300){return await this.verifySignature(Y,Z,Q,J),JSON.parse(Y)}async verifySignature(Y,Z,Q=this._client.webhookSecret,J=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!=="function"||typeof crypto.subtle.verify!=="function")throw Error("Webhook signature verification is only supported when the `crypto` global is defined");_(this,_8,"m",uB).call(this,Q);let z=v([Z]).values,X=_(this,_8,"m",t2).call(this,z,"webhook-signature"),H=_(this,_8,"m",t2).call(this,z,"webhook-timestamp"),W=_(this,_8,"m",t2).call(this,z,"webhook-id"),K=parseInt(H,10);if(isNaN(K))throw new aY("Invalid webhook timestamp format");let $=Math.floor(Date.now()/1000);if($-K>J)throw new aY("Webhook timestamp is too old");if(K>$+J)throw new aY("Webhook timestamp is too new");let G=X.split(" ").map((V)=>V.startsWith("v1,")?V.substring(3):V),U=Q.startsWith("whsec_")?Buffer.from(Q.replace("whsec_",""),"base64"):Buffer.from(Q,"utf-8"),B=W?`${W}.${H}.${Y}`:`${H}.${Y}`,F=await crypto.subtle.importKey("raw",U,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let V of G)try{let O=Buffer.from(V,"base64");if(await crypto.subtle.verify("HMAC",F,O,new TextEncoder().encode(B)))return}catch{continue}throw new aY("The given webhook signature does not match the expected signature")}};_8=new WeakSet,uB=function Y(Z){if(typeof Z!=="string"||Z.length===0)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},t2=function Y(Z,Q){if(!Z)throw Error("Headers are required");let J=Z.get(Q);if(J===null||J===void 0)throw Error(`Missing required header: ${Q}`);return J}});var dB=R(()=>{o9();s9();$J();qJ();VJ();RJ();MJ();NJ();wJ();AJ();EJ();PJ();SJ();vJ();bJ();dJ();cJ();nJ();aJ();oJ();LB();_B()});class s{constructor({baseURL:Y=I6("OPENAI_BASE_URL"),apiKey:Z=I6("OPENAI_API_KEY"),organization:Q=I6("OPENAI_ORG_ID")??null,project:J=I6("OPENAI_PROJECT_ID")??null,webhookSecret:z=I6("OPENAI_WEBHOOK_SECRET")??null,...X}={}){if(sJ.add(this),e2.set(this,void 0),this.completions=new $8(this),this.chat=new G1(this),this.embeddings=new U8(this),this.files=new V8(this),this.images=new O8(this),this.audio=new Y6(this),this.moderations=new N8(this),this.models=new D8(this),this.fineTuning=new EY(this),this.graders=new D1(this),this.vectorStores=new A6(this),this.webhooks=new I8(this),this.beta=new xY(this),this.batches=new W8(this),this.uploads=new N1(this),this.responses=new k6(this),this.realtime=new T6(this),this.conversations=new M1(this),this.evals=new O1(this),this.containers=new R1(this),this.videos=new L8(this),Z===void 0)throw new h("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");let H={apiKey:Z,organization:Q,project:J,webhookSecret:z,...X,baseURL:Y||"https://api.openai.com/v1"};if(!H.dangerouslyAllowBrowser&&SU())throw new h(`It looks like you're running in a browser-like environment.
|
|
460
|
+
${X}
|
|
461
|
+
${$}`)}return X},P;var q0=O(()=>{l1();iB=Object.freeze(Object.create(null)),P=IT(aB)});var D4;var Z5=O(()=>{_0();q0();D4=class D4 extends v{list(Y,Z={},Q){return this._client.getAPIList(P`/chat/completions/${Y}/messages`,K0,{query:Z,...Q})}}});var v1=O(()=>{l1()});function nZ(Y){return Y!==void 0&&"function"in Y&&Y.function!==void 0}function iZ(Y){return Y?.$brand==="auto-parseable-response-format"}function LY(Y){return Y?.$brand==="auto-parseable-tool"}function oB(Y,Z){if(!Z||!XJ(Z))return{...Y,choices:Y.choices.map((Q)=>{return rB(Q.message.tool_calls),{...Q,message:{...Q.message,parsed:null,...Q.message.tool_calls?{tool_calls:Q.message.tool_calls}:void 0}}})};return aZ(Y,Z)}function aZ(Y,Z){let Q=Y.choices.map((J)=>{if(J.finish_reason==="length")throw new hZ;if(J.finish_reason==="content_filter")throw new gZ;return rB(J.message.tool_calls),{...J,message:{...J.message,...J.message.tool_calls?{tool_calls:J.message.tool_calls?.map((z)=>ET(Z,z))??void 0}:void 0,parsed:J.message.content&&!J.message.refusal?kT(Z,J.message.content):null}}});return{...Y,choices:Q}}function kT(Y,Z){if(Y.response_format?.type!=="json_schema")return null;if(Y.response_format?.type==="json_schema"){if("$parseRaw"in Y.response_format)return Y.response_format.$parseRaw(Z);return JSON.parse(Z)}return null}function ET(Y,Z){let Q=Y.tools?.find((J)=>nZ(J)&&J.function?.name===Z.function.name);return{...Z,function:{...Z.function,parsed_arguments:LY(Q)?Q.$parseRaw(Z.function.arguments):Q?.function.strict?JSON.parse(Z.function.arguments):null}}}function sB(Y,Z){if(!Y||!("tools"in Y)||!Y.tools)return!1;let Q=Y.tools?.find((J)=>nZ(J)&&J.function?.name===Z.function.name);return nZ(Q)&&(LY(Q)||Q?.function.strict||!1)}function XJ(Y){if(iZ(Y.response_format))return!0;return Y.tools?.some((Z)=>LY(Z)||Z.type==="function"&&Z.function.strict===!0)??!1}function rB(Y){for(let Z of Y||[])if(Z.type!=="function")throw new p(`Currently only \`function\` tool calls are supported; Received \`${Z.type}\``)}function tB(Y){for(let Z of Y??[]){if(Z.type!=="function")throw new p(`Currently only \`function\` tool types support auto-parsing; Received \`${Z.type}\``);if(Z.function.strict!==!0)throw new p(`The \`${Z.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var oZ=O(()=>{v1()});var N4=(Y)=>{return Y?.role==="assistant"},HJ=(Y)=>{return Y?.role==="tool"};class wY{constructor(){WJ.add(this),this.controller=new AbortController,Q5.set(this,void 0),J5.set(this,()=>{}),sZ.set(this,()=>{}),rZ.set(this,void 0),z5.set(this,()=>{}),tZ.set(this,()=>{}),F6.set(this,{}),eZ.set(this,!1),K5.set(this,!1),X5.set(this,!1),_4.set(this,!1),i(this,Q5,new Promise((Y,Z)=>{i(this,J5,Y,"f"),i(this,sZ,Z,"f")}),"f"),i(this,rZ,new Promise((Y,Z)=>{i(this,z5,Y,"f"),i(this,tZ,Z,"f")}),"f"),T(this,Q5,"f").catch(()=>{}),T(this,rZ,"f").catch(()=>{})}_run(Y){setTimeout(()=>{Y().then(()=>{this._emitFinal(),this._emit("end")},T(this,WJ,"m",eB).bind(this))},0)}_connected(){if(this.ended)return;T(this,J5,"f").call(this),this._emit("connect")}get ended(){return T(this,eZ,"f")}get errored(){return T(this,K5,"f")}get aborted(){return T(this,X5,"f")}abort(){this.controller.abort()}on(Y,Z){return(T(this,F6,"f")[Y]||(T(this,F6,"f")[Y]=[])).push({listener:Z}),this}off(Y,Z){let Q=T(this,F6,"f")[Y];if(!Q)return this;let J=Q.findIndex((z)=>z.listener===Z);if(J>=0)Q.splice(J,1);return this}once(Y,Z){return(T(this,F6,"f")[Y]||(T(this,F6,"f")[Y]=[])).push({listener:Z,once:!0}),this}emitted(Y){return new Promise((Z,Q)=>{if(i(this,_4,!0,"f"),Y!=="error")this.once("error",Q);this.once(Y,Z)})}async done(){i(this,_4,!0,"f"),await T(this,rZ,"f")}_emit(Y,...Z){if(T(this,eZ,"f"))return;if(Y==="end")i(this,eZ,!0,"f"),T(this,z5,"f").call(this);let Q=T(this,F6,"f")[Y];if(Q)T(this,F6,"f")[Y]=Q.filter((J)=>!J.once),Q.forEach(({listener:J})=>J(...Z));if(Y==="abort"){let J=Z[0];if(!T(this,_4,"f")&&!Q?.length)Promise.reject(J);T(this,sZ,"f").call(this,J),T(this,tZ,"f").call(this,J),this._emit("end");return}if(Y==="error"){let J=Z[0];if(!T(this,_4,"f")&&!Q?.length)Promise.reject(J);T(this,sZ,"f").call(this,J),T(this,tZ,"f").call(this,J),this._emit("end")}}_emitFinal(){}}var WJ,Q5,J5,sZ,rZ,z5,tZ,F6,eZ,K5,X5,_4,eB;var H5=O(()=>{I1();v1();Q5=new WeakMap,J5=new WeakMap,sZ=new WeakMap,rZ=new WeakMap,z5=new WeakMap,tZ=new WeakMap,F6=new WeakMap,eZ=new WeakMap,K5=new WeakMap,X5=new WeakMap,_4=new WeakMap,WJ=new WeakSet,eB=function Y(Z){if(i(this,K5,!0,"f"),Z instanceof Error&&Z.name==="AbortError")Z=new g0;if(Z instanceof g0)return i(this,X5,!0,"f"),this._emit("abort",Z);if(Z instanceof p)return this._emit("error",Z);if(Z instanceof Error){let Q=new p(Z.message);return Q.cause=Z,this._emit("error",Q)}return this._emit("error",new p(String(Z)))}});function YV(Y){return typeof Y.parse==="function"}var J1,qJ,W5,GJ,UJ,$J,ZV,QV,xT=10,Y8;var BJ=O(()=>{I1();v1();oZ();H5();Y8=class Y8 extends wY{constructor(){super(...arguments);J1.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(Y){this._chatCompletions.push(Y),this._emit("chatCompletion",Y);let Z=Y.choices[0]?.message;if(Z)this._addMessage(Z);return Y}_addMessage(Y,Z=!0){if(!("content"in Y))Y.content=null;if(this.messages.push(Y),Z){if(this._emit("message",Y),HJ(Y)&&Y.content)this._emit("functionToolCallResult",Y.content);else if(N4(Y)&&Y.tool_calls){for(let Q of Y.tool_calls)if(Q.type==="function")this._emit("functionToolCall",Q.function)}}}async finalChatCompletion(){await this.done();let Y=this._chatCompletions[this._chatCompletions.length-1];if(!Y)throw new p("stream ended without producing a ChatCompletion");return Y}async finalContent(){return await this.done(),T(this,J1,"m",qJ).call(this)}async finalMessage(){return await this.done(),T(this,J1,"m",W5).call(this)}async finalFunctionToolCall(){return await this.done(),T(this,J1,"m",GJ).call(this)}async finalFunctionToolCallResult(){return await this.done(),T(this,J1,"m",UJ).call(this)}async totalUsage(){return await this.done(),T(this,J1,"m",$J).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let Y=this._chatCompletions[this._chatCompletions.length-1];if(Y)this._emit("finalChatCompletion",Y);let Z=T(this,J1,"m",W5).call(this);if(Z)this._emit("finalMessage",Z);let Q=T(this,J1,"m",qJ).call(this);if(Q)this._emit("finalContent",Q);let J=T(this,J1,"m",GJ).call(this);if(J)this._emit("finalFunctionToolCall",J);let z=T(this,J1,"m",UJ).call(this);if(z!=null)this._emit("finalFunctionToolCallResult",z);if(this._chatCompletions.some((K)=>K.usage))this._emit("totalUsage",T(this,J1,"m",$J).call(this))}async _createChatCompletion(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}T(this,J1,"m",ZV).call(this,Z);let z=await Y.chat.completions.create({...Z,stream:!1},{...Q,signal:this.controller.signal});return this._connected(),this._addChatCompletion(aZ(z,Z))}async _runChatCompletion(Y,Z,Q){for(let J of Z.messages)this._addMessage(J,!1);return await this._createChatCompletion(Y,Z,Q)}async _runTools(Y,Z,Q){let{tool_choice:z="auto",stream:K,...X}=Z,H=typeof z!=="string"&&z.type==="function"&&z?.function?.name,{maxChatCompletions:W=xT}=Q||{},q=Z.tools.map((B)=>{if(LY(B)){if(!B.$callback)throw new p("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:B.$callback,name:B.function.name,description:B.function.description||"",parameters:B.function.parameters,parse:B.$parseRaw,strict:!0}}}return B}),G={};for(let B of q)if(B.type==="function")G[B.function.name||B.function.function.name]=B.function;let $="tools"in Z?q.map((B)=>B.type==="function"?{type:"function",function:{name:B.function.name||B.function.function.name,parameters:B.function.parameters,description:B.function.description,strict:B.function.strict}}:B):void 0;for(let B of Z.messages)this._addMessage(B,!1);for(let B=0;B<W;++B){let F=(await this._createChatCompletion(Y,{...X,tool_choice:z,tools:$,messages:[...this.messages]},Q)).choices[0]?.message;if(!F)throw new p("missing message in ChatCompletion response");if(!F.tool_calls?.length)return;for(let M of F.tool_calls){if(M.type!=="function")continue;let L=M.id,{name:N,arguments:_}=M.function,I=G[N];if(!I){let E=`Invalid tool_call: ${JSON.stringify(N)}. Available options are: ${Object.keys(G).map((h)=>JSON.stringify(h)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:L,content:E});continue}else if(H&&H!==N){let E=`Invalid tool_call: ${JSON.stringify(N)}. ${JSON.stringify(H)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:L,content:E});continue}let w;try{w=YV(I)?await I.parse(_):_}catch(E){let h=E instanceof Error?E.message:String(E);this._addMessage({role:"tool",tool_call_id:L,content:h});continue}let A=await I.function(w,this),x=T(this,J1,"m",QV).call(this,A);if(this._addMessage({role:"tool",tool_call_id:L,content:x}),H)return}}return}};J1=new WeakSet,qJ=function Y(){return T(this,J1,"m",W5).call(this).content??null},W5=function Y(){let Z=this.messages.length;while(Z-- >0){let Q=this.messages[Z];if(N4(Q))return{...Q,content:Q.content??null,refusal:Q.refusal??null}}throw new p("stream ended without producing a ChatCompletionMessage with role=assistant")},GJ=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(N4(Q)&&Q?.tool_calls?.length)return Q.tool_calls.filter((J)=>J.type==="function").at(-1)?.function}return},UJ=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(HJ(Q)&&Q.content!=null&&typeof Q.content==="string"&&this.messages.some((J)=>J.role==="assistant"&&J.tool_calls?.some((z)=>z.type==="function"&&z.id===Q.tool_call_id)))return Q.content}return},$J=function Y(){let Z={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:Q}of this._chatCompletions)if(Q)Z.completion_tokens+=Q.completion_tokens,Z.prompt_tokens+=Q.prompt_tokens,Z.total_tokens+=Q.total_tokens;return Z},ZV=function Y(Z){if(Z.n!=null&&Z.n>1)throw new p("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},QV=function Y(Z){return typeof Z==="string"?Z:Z===void 0?"undefined":JSON.stringify(Z)}});var Z8;var VJ=O(()=>{BJ();Z8=class Z8 extends Y8{static runTools(Y,Z,Q){let J=new Z8,z={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Y,Z,z)),J}_addMessage(Y,Z=!0){if(super._addMessage(Y,Z),N4(Y)&&Y.content)this._emit("content",Y.content)}}});function ST(Y,Z=p0.ALL){if(typeof Y!=="string")throw TypeError(`expecting str, got ${typeof Y}`);if(!Y.trim())throw Error(`${Y} is empty`);return PT(Y.trim(),Z)}var p0,JV,zV,PT=(Y,Z)=>{let Q=Y.length,J=0,z=(B)=>{throw new JV(`${B} at position ${J}`)},K=(B)=>{throw new zV(`${B} at position ${J}`)},X=()=>{if($(),J>=Q)z("Unexpected end of input");if(Y[J]==='"')return H();if(Y[J]==="{")return W();if(Y[J]==="[")return q();if(Y.substring(J,J+4)==="null"||p0.NULL&Z&&Q-J<4&&"null".startsWith(Y.substring(J)))return J+=4,null;if(Y.substring(J,J+4)==="true"||p0.BOOL&Z&&Q-J<4&&"true".startsWith(Y.substring(J)))return J+=4,!0;if(Y.substring(J,J+5)==="false"||p0.BOOL&Z&&Q-J<5&&"false".startsWith(Y.substring(J)))return J+=5,!1;if(Y.substring(J,J+8)==="Infinity"||p0.INFINITY&Z&&Q-J<8&&"Infinity".startsWith(Y.substring(J)))return J+=8,1/0;if(Y.substring(J,J+9)==="-Infinity"||p0.MINUS_INFINITY&Z&&1<Q-J&&Q-J<9&&"-Infinity".startsWith(Y.substring(J)))return J+=9,-1/0;if(Y.substring(J,J+3)==="NaN"||p0.NAN&Z&&Q-J<3&&"NaN".startsWith(Y.substring(J)))return J+=3,NaN;return G()},H=()=>{let B=J,V=!1;J++;while(J<Q&&(Y[J]!=='"'||V&&Y[J-1]==="\\"))V=Y[J]==="\\"?!V:!1,J++;if(Y.charAt(J)=='"')try{return JSON.parse(Y.substring(B,++J-Number(V)))}catch(F){K(String(F))}else if(p0.STR&Z)try{return JSON.parse(Y.substring(B,J-Number(V))+'"')}catch(F){return JSON.parse(Y.substring(B,Y.lastIndexOf("\\"))+'"')}z("Unterminated string literal")},W=()=>{J++,$();let B={};try{while(Y[J]!=="}"){if($(),J>=Q&&p0.OBJ&Z)return B;let V=H();$(),J++;try{let F=X();Object.defineProperty(B,V,{value:F,writable:!0,enumerable:!0,configurable:!0})}catch(F){if(p0.OBJ&Z)return B;else throw F}if($(),Y[J]===",")J++}}catch(V){if(p0.OBJ&Z)return B;else z("Expected '}' at end of object")}return J++,B},q=()=>{J++;let B=[];try{while(Y[J]!=="]")if(B.push(X()),$(),Y[J]===",")J++}catch(V){if(p0.ARR&Z)return B;z("Expected ']' at end of array")}return J++,B},G=()=>{if(J===0){if(Y==="-"&&p0.NUM&Z)z("Not sure what '-' is");try{return JSON.parse(Y)}catch(V){if(p0.NUM&Z)try{if(Y[Y.length-1]===".")return JSON.parse(Y.substring(0,Y.lastIndexOf(".")));return JSON.parse(Y.substring(0,Y.lastIndexOf("e")))}catch(F){}K(String(V))}}let B=J;if(Y[J]==="-")J++;while(Y[J]&&!",]}".includes(Y[J]))J++;if(J==Q&&!(p0.NUM&Z))z("Unterminated number literal");try{return JSON.parse(Y.substring(B,J))}catch(V){if(Y.substring(B,J)==="-"&&p0.NUM&Z)z("Not sure what '-' is");try{return JSON.parse(Y.substring(B,Y.lastIndexOf("e")))}catch(F){K(String(F))}}},$=()=>{while(J<Q&&`
|
|
462
|
+
\r `.includes(Y[J]))J++};return X()},FJ=(Y)=>ST(Y,p0.ALL^p0.NUM);var KV=O(()=>{p0={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511};JV=class JV extends Error{};zV=class zV extends Error{}});var RJ=O(()=>{r9()});function vT(Y,Z){let{id:Q,choices:J,created:z,model:K,system_fingerprint:X,...H}=Y,W={...H,id:Q,choices:J.map(({message:q,finish_reason:G,index:$,logprobs:B,...V})=>{if(!G)throw new p(`missing finish_reason for choice ${$}`);let{content:F=null,function_call:M,tool_calls:L,...N}=q,_=q.role;if(!_)throw new p(`missing role for choice ${$}`);if(M){let{arguments:I,name:w}=M;if(I==null)throw new p(`missing function_call.arguments for choice ${$}`);if(!w)throw new p(`missing function_call.name for choice ${$}`);return{...V,message:{content:F,function_call:{arguments:I,name:w},role:_,refusal:q.refusal??null},finish_reason:G,index:$,logprobs:B}}if(L)return{...V,index:$,finish_reason:G,logprobs:B,message:{...N,role:_,content:F,refusal:q.refusal??null,tool_calls:L.map((I,w)=>{let{function:A,type:x,id:E,...h}=I,{arguments:u,name:f,...m}=A||{};if(E==null)throw new p(`missing choices[${$}].tool_calls[${w}].id
|
|
463
|
+
${U5(Y)}`);if(x==null)throw new p(`missing choices[${$}].tool_calls[${w}].type
|
|
464
|
+
${U5(Y)}`);if(f==null)throw new p(`missing choices[${$}].tool_calls[${w}].function.name
|
|
465
|
+
${U5(Y)}`);if(u==null)throw new p(`missing choices[${$}].tool_calls[${w}].function.arguments
|
|
466
|
+
${U5(Y)}`);return{...h,id:E,type:x,function:{...m,name:f,arguments:u}}})}};return{...V,message:{...N,content:F,role:_,refusal:q.refusal??null},finish_reason:G,index:$,logprobs:B}}),created:z,model:K,object:"chat.completion",...X?{system_fingerprint:X}:{}};return oB(W,Z)}function U5(Y){return JSON.stringify(Y)}function HV(Y){return}function WV(Y){}var u0,R6,L4,b6,OJ,q5,MJ,DJ,NJ,G5,_J,XV,h6;var $5=O(()=>{I1();KV();v1();oZ();RJ();BJ();h6=class h6 extends Y8{constructor(Y){super();u0.add(this),R6.set(this,void 0),L4.set(this,void 0),b6.set(this,void 0),i(this,R6,Y,"f"),i(this,L4,[],"f")}get currentChatCompletionSnapshot(){return T(this,b6,"f")}static fromReadableStream(Y){let Z=new h6(null);return Z._run(()=>Z._fromReadableStream(Y)),Z}static createChatCompletion(Y,Z,Q){let J=new h6(Z);return J._run(()=>J._runChatCompletion(Y,{...Z,stream:!0},{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createChatCompletion(Y,Z,Q){super._createChatCompletion;let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}T(this,u0,"m",OJ).call(this);let z=await Y.chat.completions.create({...Z,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let K of z)T(this,u0,"m",MJ).call(this,K);if(z.controller.signal?.aborted)throw new g0;return this._addChatCompletion(T(this,u0,"m",G5).call(this))}async _fromReadableStream(Y,Z){let Q=Z?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}T(this,u0,"m",OJ).call(this),this._connected();let J=B1.fromReadableStream(Y,this.controller),z;for await(let K of J){if(z&&z!==K.id)this._addChatCompletion(T(this,u0,"m",G5).call(this));T(this,u0,"m",MJ).call(this,K),z=K.id}if(J.controller.signal?.aborted)throw new g0;return this._addChatCompletion(T(this,u0,"m",G5).call(this))}[(R6=new WeakMap,L4=new WeakMap,b6=new WeakMap,u0=new WeakSet,OJ=function Y(){if(this.ended)return;i(this,b6,void 0,"f")},q5=function Y(Z){let Q=T(this,L4,"f")[Z.index];if(Q)return Q;return Q={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},T(this,L4,"f")[Z.index]=Q,Q},MJ=function Y(Z){if(this.ended)return;let Q=T(this,u0,"m",XV).call(this,Z);this._emit("chunk",Z,Q);for(let J of Z.choices){let z=Q.choices[J.index];if(J.delta.content!=null&&z.message?.role==="assistant"&&z.message?.content)this._emit("content",J.delta.content,z.message.content),this._emit("content.delta",{delta:J.delta.content,snapshot:z.message.content,parsed:z.message.parsed});if(J.delta.refusal!=null&&z.message?.role==="assistant"&&z.message?.refusal)this._emit("refusal.delta",{delta:J.delta.refusal,snapshot:z.message.refusal});if(J.logprobs?.content!=null&&z.message?.role==="assistant")this._emit("logprobs.content.delta",{content:J.logprobs?.content,snapshot:z.logprobs?.content??[]});if(J.logprobs?.refusal!=null&&z.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:J.logprobs?.refusal,snapshot:z.logprobs?.refusal??[]});let K=T(this,u0,"m",q5).call(this,z);if(z.finish_reason){if(T(this,u0,"m",NJ).call(this,z),K.current_tool_call_index!=null)T(this,u0,"m",DJ).call(this,z,K.current_tool_call_index)}for(let X of J.delta.tool_calls??[]){if(K.current_tool_call_index!==X.index){if(T(this,u0,"m",NJ).call(this,z),K.current_tool_call_index!=null)T(this,u0,"m",DJ).call(this,z,K.current_tool_call_index)}K.current_tool_call_index=X.index}for(let X of J.delta.tool_calls??[]){let H=z.message.tool_calls?.[X.index];if(!H?.type)continue;if(H?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:H.function?.name,index:X.index,arguments:H.function.arguments,parsed_arguments:H.function.parsed_arguments,arguments_delta:X.function?.arguments??""});else WV(H?.type)}}},DJ=function Y(Z,Q){if(T(this,u0,"m",q5).call(this,Z).done_tool_calls.has(Q))return;let z=Z.message.tool_calls?.[Q];if(!z)throw Error("no tool call snapshot");if(!z.type)throw Error("tool call snapshot missing `type`");if(z.type==="function"){let K=T(this,R6,"f")?.tools?.find((X)=>nZ(X)&&X.function.name===z.function.name);this._emit("tool_calls.function.arguments.done",{name:z.function.name,index:Q,arguments:z.function.arguments,parsed_arguments:LY(K)?K.$parseRaw(z.function.arguments):K?.function.strict?JSON.parse(z.function.arguments):null})}else WV(z.type)},NJ=function Y(Z){let Q=T(this,u0,"m",q5).call(this,Z);if(Z.message.content&&!Q.content_done){Q.content_done=!0;let J=T(this,u0,"m",_J).call(this);this._emit("content.done",{content:Z.message.content,parsed:J?J.$parseRaw(Z.message.content):null})}if(Z.message.refusal&&!Q.refusal_done)Q.refusal_done=!0,this._emit("refusal.done",{refusal:Z.message.refusal});if(Z.logprobs?.content&&!Q.logprobs_content_done)Q.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:Z.logprobs.content});if(Z.logprobs?.refusal&&!Q.logprobs_refusal_done)Q.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:Z.logprobs.refusal})},G5=function Y(){if(this.ended)throw new p("stream has ended, this shouldn't happen");let Z=T(this,b6,"f");if(!Z)throw new p("request ended without sending any chunks");return i(this,b6,void 0,"f"),i(this,L4,[],"f"),vT(Z,T(this,R6,"f"))},_J=function Y(){let Z=T(this,R6,"f")?.response_format;if(iZ(Z))return Z;return null},XV=function Y(Z){var Q,J,z,K;let X=T(this,b6,"f"),{choices:H,...W}=Z;if(!X)X=i(this,b6,{...W,choices:[]},"f");else Object.assign(X,W);for(let{delta:q,finish_reason:G,index:$,logprobs:B=null,...V}of Z.choices){let F=X.choices[$];if(!F)F=X.choices[$]={finish_reason:G,index:$,message:{},logprobs:B,...V};if(B)if(!F.logprobs)F.logprobs=Object.assign({},B);else{let{content:A,refusal:x,...E}=B;if(HV(E),Object.assign(F.logprobs,E),A)(Q=F.logprobs).content??(Q.content=[]),F.logprobs.content.push(...A);if(x)(J=F.logprobs).refusal??(J.refusal=[]),F.logprobs.refusal.push(...x)}if(G){if(F.finish_reason=G,T(this,R6,"f")&&XJ(T(this,R6,"f"))){if(G==="length")throw new hZ;if(G==="content_filter")throw new gZ}}if(Object.assign(F,V),!q)continue;let{content:M,refusal:L,function_call:N,role:_,tool_calls:I,...w}=q;if(HV(w),Object.assign(F.message,w),L)F.message.refusal=(F.message.refusal||"")+L;if(_)F.message.role=_;if(N)if(!F.message.function_call)F.message.function_call=N;else{if(N.name)F.message.function_call.name=N.name;if(N.arguments)(z=F.message.function_call).arguments??(z.arguments=""),F.message.function_call.arguments+=N.arguments}if(M){if(F.message.content=(F.message.content||"")+M,!F.message.refusal&&T(this,u0,"m",_J).call(this))F.message.parsed=FJ(F.message.content)}if(I){if(!F.message.tool_calls)F.message.tool_calls=[];for(let{index:A,id:x,type:E,function:h,...u}of I){let f=(K=F.message.tool_calls)[A]??(K[A]={});if(Object.assign(f,u),x)f.id=x;if(E)f.type=E;if(h)f.function??(f.function={name:h.name??"",arguments:""});if(h?.name)f.function.name=h.name;if(h?.arguments){if(f.function.arguments+=h.arguments,sB(T(this,R6,"f"),f))f.function.parsed_arguments=FJ(f.function.arguments)}}}}return X},Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("chunk",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,K)=>Z.push({resolve:z,reject:K})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new B1(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var w4;var LJ=O(()=>{$5();w4=class w4 extends h6{static fromReadableStream(Y){let Z=new w4(null);return Z._run(()=>Z._fromReadableStream(Y)),Z}static runTools(Y,Z,Q){let J=new w4(Z),z={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Y,Z,z)),J}}});var g6;var Q8=O(()=>{Z5();Z5();_0();q0();VJ();LJ();$5();oZ();LJ();$5();VJ();g6=class g6 extends v{constructor(){super(...arguments);this.messages=new D4(this._client)}create(Y,Z){return this._client.post("/chat/completions",{body:Y,...Z,stream:Y.stream??!1})}retrieve(Y,Z){return this._client.get(P`/chat/completions/${Y}`,Z)}update(Y,Z,Q){return this._client.post(P`/chat/completions/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/chat/completions",K0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(P`/chat/completions/${Y}`,Z)}parse(Y,Z){return tB(Y.tools),this._client.chat.completions.create(Y,{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap((Q)=>aZ(Q,Y))}runTools(Y,Z){if(Y.stream)return w4.runTools(this._client,Y,Z);return Z8.runTools(this._client,Y,Z)}stream(Y,Z){return h6.createChatCompletion(this._client,Y,Z)}};g6.Messages=D4});var jY;var wJ=O(()=>{Q8();Q8();jY=class jY extends v{constructor(){super(...arguments);this.completions=new g6(this._client)}};jY.Completions=g6});var qV=O(()=>{Q8();Z5();Q8()});var GV=O(()=>{wJ();qV()});var UV=()=>{};function*fT(Y){if(!Y)return;if($V in Y){let{values:J,nulls:z}=Y;yield*J.entries();for(let K of z)yield[K,null];return}let Z=!1,Q;if(Y instanceof Headers)Q=Y.entries();else if(h9(Y))Q=Y;else Z=!0,Q=Object.entries(Y??{});for(let J of Q){let z=J[0];if(typeof z!=="string")throw TypeError("expected header name to be a string");let K=h9(J[1])?J[1]:[J[1]],X=!1;for(let H of K){if(H===void 0)continue;if(Z&&!X)X=!0,yield[z,null];yield[z,H]}}}var $V,y=(Y)=>{let Z=new Headers,Q=new Set;for(let J of Y){let z=new Set;for(let[K,X]of fT(J)){let H=K.toLowerCase();if(!z.has(H))Z.delete(K),z.add(H);if(X===null)Z.delete(K),Q.add(H);else Z.append(K,X),Q.delete(H)}}return{[$V]:!0,values:Z,nulls:Q}};var w0=O(()=>{$6();$V=Symbol("brand.privateNullableHeaders")});var J8;var jJ=O(()=>{w0();J8=class J8 extends v{create(Y,Z){return this._client.post("/audio/speech",{body:Y,...Z,headers:y([{Accept:"application/octet-stream"},Z?.headers]),__binaryResponse:!0})}}});var z8;var TJ=O(()=>{a1();z8=class z8 extends v{create(Y,Z){return this._client.post("/audio/transcriptions",V1({body:Y,...Z,stream:Y.stream??!1,__metadata:{model:Y.model}},this._client))}}});var K8;var IJ=O(()=>{a1();K8=class K8 extends v{create(Y,Z){return this._client.post("/audio/translations",V1({body:Y,...Z,__metadata:{model:Y.model}},this._client))}}});var O6;var CJ=O(()=>{jJ();jJ();TJ();TJ();IJ();IJ();O6=class O6 extends v{constructor(){super(...arguments);this.transcriptions=new z8(this._client),this.translations=new K8(this._client),this.speech=new J8(this._client)}};O6.Transcriptions=z8;O6.Translations=K8;O6.Speech=J8});var j4;var AJ=O(()=>{_0();q0();j4=class j4 extends v{create(Y,Z){return this._client.post("/batches",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(P`/batches/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/batches",K0,{query:Y,...Z})}cancel(Y,Z){return this._client.post(P`/batches/${Y}/cancel`,Z)}}});var X8;var kJ=O(()=>{_0();w0();q0();X8=class X8 extends v{create(Y,Z){return this._client.post("/assistants",{body:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(P`/assistants/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(P`/assistants/${Y}`,{body:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/assistants",K0,{query:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(P`/assistants/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var H8;var EJ=O(()=>{w0();H8=class H8 extends v{create(Y,Z){return this._client.post("/realtime/sessions",{body:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var W8;var xJ=O(()=>{w0();W8=class W8 extends v{create(Y,Z){return this._client.post("/realtime/transcription_sessions",{body:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var TY;var SJ=O(()=>{EJ();EJ();xJ();xJ();TY=class TY extends v{constructor(){super(...arguments);this.sessions=new H8(this._client),this.transcriptionSessions=new W8(this._client)}};TY.Sessions=H8;TY.TranscriptionSessions=W8});var q8;var PJ=O(()=>{w0();q0();q8=class q8 extends v{create(Y,Z){return this._client.post("/chatkit/sessions",{body:Y,...Z,headers:y([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}cancel(Y,Z){return this._client.post(P`/chatkit/sessions/${Y}/cancel`,{...Z,headers:y([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}}});var G8;var vJ=O(()=>{_0();w0();q0();G8=class G8 extends v{retrieve(Y,Z){return this._client.get(P`/chatkit/threads/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}list(Y={},Z){return this._client.getAPIList("/chatkit/threads",f6,{query:Y,...Z,headers:y([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}delete(Y,Z){return this._client.delete(P`/chatkit/threads/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}listItems(Y,Z={},Q){return this._client.getAPIList(P`/chatkit/threads/${Y}/items`,f6,{query:Z,...Q,headers:y([{"OpenAI-Beta":"chatkit_beta=v1"},Q?.headers])})}}});var IY;var yJ=O(()=>{PJ();PJ();vJ();vJ();IY=class IY extends v{constructor(){super(...arguments);this.sessions=new q8(this._client),this.threads=new G8(this._client)}};IY.Sessions=q8;IY.Threads=G8});var U8;var fJ=O(()=>{_0();w0();q0();U8=class U8 extends v{create(Y,Z,Q){return this._client.post(P`/threads/${Y}/messages`,{body:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{thread_id:J}=Z;return this._client.get(P`/threads/${J}/messages/${Y}`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(P`/threads/${J}/messages/${Y}`,{body:z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(P`/threads/${Y}/messages`,K0,{query:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{thread_id:J}=Z;return this._client.delete(P`/threads/${J}/messages/${Y}`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var $8;var bJ=O(()=>{_0();w0();q0();$8=class $8 extends v{retrieve(Y,Z,Q){let{thread_id:J,run_id:z,...K}=Z;return this._client.get(P`/threads/${J}/runs/${z}/steps/${Y}`,{query:K,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.getAPIList(P`/threads/${J}/runs/${Y}/steps`,K0,{query:z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var BV=(Y)=>{if(typeof Buffer<"u"){let Z=Buffer.from(Y,"base64");return Array.from(new Float32Array(Z.buffer,Z.byteOffset,Z.length/Float32Array.BYTES_PER_ELEMENT))}else{let Z=atob(Y),Q=Z.length,J=new Uint8Array(Q);for(let z=0;z<Q;z++)J[z]=Z.charCodeAt(z);return Array.from(new Float32Array(J.buffer))}};var VV=O(()=>{l1()});var m6=(Y)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[Y]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(Y)?.trim();return};var B8=O(()=>{$6();VV();dZ()});function oT(Y){}var i0,AY,hJ,o1,B5,y1,kY,T4,CY,R5,F1,V5,F5,R8,V8,F8,FV,RV,OV,MV,DV,NV,_V,u6;var gJ=O(()=>{I1();RJ();v1();H5();B8();u6=class u6 extends wY{constructor(){super(...arguments);i0.add(this),hJ.set(this,[]),o1.set(this,{}),B5.set(this,{}),y1.set(this,void 0),kY.set(this,void 0),T4.set(this,void 0),CY.set(this,void 0),R5.set(this,void 0),F1.set(this,void 0),V5.set(this,void 0),F5.set(this,void 0),R8.set(this,void 0)}[(hJ=new WeakMap,o1=new WeakMap,B5=new WeakMap,y1=new WeakMap,kY=new WeakMap,T4=new WeakMap,CY=new WeakMap,R5=new WeakMap,F1=new WeakMap,V5=new WeakMap,F5=new WeakMap,R8=new WeakMap,i0=new WeakSet,Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,K)=>Z.push({resolve:z,reject:K})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream(Y){let Z=new AY;return Z._run(()=>Z._fromReadableStream(Y)),Z}async _fromReadableStream(Y,Z){let Q=Z?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}this._connected();let J=B1.fromReadableStream(Y,this.controller);for await(let z of J)T(this,i0,"m",V8).call(this,z);if(J.controller.signal?.aborted)throw new g0;return this._addRun(T(this,i0,"m",F8).call(this))}toReadableStream(){return new B1(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(Y,Z,Q,J){let z=new AY;return z._run(()=>z._runToolAssistantStream(Y,Z,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),z}async _createToolAssistantStream(Y,Z,Q,J){let z=J?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}let K={...Q,stream:!0},X=await Y.submitToolOutputs(Z,K,{...J,signal:this.controller.signal});this._connected();for await(let H of X)T(this,i0,"m",V8).call(this,H);if(X.controller.signal?.aborted)throw new g0;return this._addRun(T(this,i0,"m",F8).call(this))}static createThreadAssistantStream(Y,Z,Q){let J=new AY;return J._run(()=>J._threadAssistantStream(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}static createAssistantStream(Y,Z,Q,J){let z=new AY;return z._run(()=>z._runAssistantStream(Y,Z,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),z}currentEvent(){return T(this,V5,"f")}currentRun(){return T(this,F5,"f")}currentMessageSnapshot(){return T(this,y1,"f")}currentRunStepSnapshot(){return T(this,R8,"f")}async finalRunSteps(){return await this.done(),Object.values(T(this,o1,"f"))}async finalMessages(){return await this.done(),Object.values(T(this,B5,"f"))}async finalRun(){if(await this.done(),!T(this,kY,"f"))throw Error("Final run was not received.");return T(this,kY,"f")}async _createThreadAssistantStream(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}let z={...Z,stream:!0},K=await Y.createAndRun(z,{...Q,signal:this.controller.signal});this._connected();for await(let X of K)T(this,i0,"m",V8).call(this,X);if(K.controller.signal?.aborted)throw new g0;return this._addRun(T(this,i0,"m",F8).call(this))}async _createAssistantStream(Y,Z,Q,J){let z=J?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}let K={...Q,stream:!0},X=await Y.create(Z,K,{...J,signal:this.controller.signal});this._connected();for await(let H of X)T(this,i0,"m",V8).call(this,H);if(X.controller.signal?.aborted)throw new g0;return this._addRun(T(this,i0,"m",F8).call(this))}static accumulateDelta(Y,Z){for(let[Q,J]of Object.entries(Z)){if(!Y.hasOwnProperty(Q)){Y[Q]=J;continue}let z=Y[Q];if(z===null||z===void 0){Y[Q]=J;continue}if(Q==="index"||Q==="type"){Y[Q]=J;continue}if(typeof z==="string"&&typeof J==="string")z+=J;else if(typeof z==="number"&&typeof J==="number")z+=J;else if(mZ(z)&&mZ(J))z=this.accumulateDelta(z,J);else if(Array.isArray(z)&&Array.isArray(J)){if(z.every((K)=>typeof K==="string"||typeof K==="number")){z.push(...J);continue}for(let K of J){if(!mZ(K))throw Error(`Expected array delta entry to be an object but got: ${K}`);let X=K.index;if(X==null)throw console.error(K),Error("Expected array delta entry to have an `index` property");if(typeof X!=="number")throw Error(`Expected array delta entry \`index\` property to be a number but got ${X}`);let H=z[X];if(H==null)z.push(K);else z[X]=this.accumulateDelta(H,K)}continue}else throw Error(`Unhandled record type: ${Q}, deltaValue: ${J}, accValue: ${z}`);Y[Q]=z}return Y}_addRun(Y){return Y}async _threadAssistantStream(Y,Z,Q){return await this._createThreadAssistantStream(Z,Y,Q)}async _runAssistantStream(Y,Z,Q,J){return await this._createAssistantStream(Z,Y,Q,J)}async _runToolAssistantStream(Y,Z,Q,J){return await this._createToolAssistantStream(Z,Y,Q,J)}};AY=u6,V8=function Y(Z){if(this.ended)return;switch(i(this,V5,Z,"f"),T(this,i0,"m",OV).call(this,Z),Z.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":T(this,i0,"m",_V).call(this,Z);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":T(this,i0,"m",RV).call(this,Z);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":T(this,i0,"m",FV).call(this,Z);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier");default:oT(Z)}},F8=function Y(){if(this.ended)throw new p("stream has ended, this shouldn't happen");if(!T(this,kY,"f"))throw Error("Final run has not been received");return T(this,kY,"f")},FV=function Y(Z){let[Q,J]=T(this,i0,"m",DV).call(this,Z,T(this,y1,"f"));i(this,y1,Q,"f"),T(this,B5,"f")[Q.id]=Q;for(let z of J){let K=Q.content[z.index];if(K?.type=="text")this._emit("textCreated",K.text)}switch(Z.event){case"thread.message.created":this._emit("messageCreated",Z.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",Z.data.delta,Q),Z.data.delta.content)for(let z of Z.data.delta.content){if(z.type=="text"&&z.text){let K=z.text,X=Q.content[z.index];if(X&&X.type=="text")this._emit("textDelta",K,X.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(z.index!=T(this,T4,"f")){if(T(this,CY,"f"))switch(T(this,CY,"f").type){case"text":this._emit("textDone",T(this,CY,"f").text,T(this,y1,"f"));break;case"image_file":this._emit("imageFileDone",T(this,CY,"f").image_file,T(this,y1,"f"));break}i(this,T4,z.index,"f")}i(this,CY,Q.content[z.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(T(this,T4,"f")!==void 0){let z=Z.data.content[T(this,T4,"f")];if(z)switch(z.type){case"image_file":this._emit("imageFileDone",z.image_file,T(this,y1,"f"));break;case"text":this._emit("textDone",z.text,T(this,y1,"f"));break}}if(T(this,y1,"f"))this._emit("messageDone",Z.data);i(this,y1,void 0,"f")}},RV=function Y(Z){let Q=T(this,i0,"m",MV).call(this,Z);switch(i(this,R8,Q,"f"),Z.event){case"thread.run.step.created":this._emit("runStepCreated",Z.data);break;case"thread.run.step.delta":let J=Z.data.delta;if(J.step_details&&J.step_details.type=="tool_calls"&&J.step_details.tool_calls&&Q.step_details.type=="tool_calls")for(let K of J.step_details.tool_calls)if(K.index==T(this,R5,"f"))this._emit("toolCallDelta",K,Q.step_details.tool_calls[K.index]);else{if(T(this,F1,"f"))this._emit("toolCallDone",T(this,F1,"f"));if(i(this,R5,K.index,"f"),i(this,F1,Q.step_details.tool_calls[K.index],"f"),T(this,F1,"f"))this._emit("toolCallCreated",T(this,F1,"f"))}this._emit("runStepDelta",Z.data.delta,Q);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(i(this,R8,void 0,"f"),Z.data.step_details.type=="tool_calls"){if(T(this,F1,"f"))this._emit("toolCallDone",T(this,F1,"f")),i(this,F1,void 0,"f")}this._emit("runStepDone",Z.data,Q);break;case"thread.run.step.in_progress":break}},OV=function Y(Z){T(this,hJ,"f").push(Z),this._emit("event",Z)},MV=function Y(Z){switch(Z.event){case"thread.run.step.created":return T(this,o1,"f")[Z.data.id]=Z.data,Z.data;case"thread.run.step.delta":let Q=T(this,o1,"f")[Z.data.id];if(!Q)throw Error("Received a RunStepDelta before creation of a snapshot");let J=Z.data;if(J.delta){let z=AY.accumulateDelta(Q,J.delta);T(this,o1,"f")[Z.data.id]=z}return T(this,o1,"f")[Z.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":T(this,o1,"f")[Z.data.id]=Z.data;break}if(T(this,o1,"f")[Z.data.id])return T(this,o1,"f")[Z.data.id];throw Error("No snapshot available")},DV=function Y(Z,Q){let J=[];switch(Z.event){case"thread.message.created":return[Z.data,J];case"thread.message.delta":if(!Q)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let z=Z.data;if(z.delta.content)for(let K of z.delta.content)if(K.index in Q.content){let X=Q.content[K.index];Q.content[K.index]=T(this,i0,"m",NV).call(this,K,X)}else Q.content[K.index]=K,J.push(K);return[Q,J];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(Q)return[Q,J];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},NV=function Y(Z,Q){return AY.accumulateDelta(Q,Z)},_V=function Y(Z){switch(i(this,F5,Z.data,"f"),Z.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":if(i(this,kY,Z.data,"f"),T(this,F1,"f"))this._emit("toolCallDone",T(this,F1,"f")),i(this,F1,void 0,"f");break;case"thread.run.cancelling":break}}});var I4;var mJ=O(()=>{bJ();bJ();_0();w0();gJ();q0();I4=class I4 extends v{constructor(){super(...arguments);this.steps=new $8(this._client)}create(Y,Z,Q){let{include:J,...z}=Z;return this._client.post(P`/threads/${Y}/runs`,{query:{include:J},body:z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}retrieve(Y,Z,Q){let{thread_id:J}=Z;return this._client.get(P`/threads/${J}/runs/${Y}`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(P`/threads/${J}/runs/${Y}`,{body:z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(P`/threads/${Y}/runs`,K0,{query:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{thread_id:J}=Z;return this._client.post(P`/threads/${J}/runs/${Y}/cancel`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z,Q);return await this.poll(J.id,{thread_id:Y},Q)}createAndStream(Y,Z,Q){return u6.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}async poll(Y,Z,Q){let J=y([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:z,response:K}=await this.retrieve(Y,Z,{...Q,headers:{...Q?.headers,...J}}).withResponse();switch(z.status){case"queued":case"in_progress":case"cancelling":let X=5000;if(Q?.pollIntervalMs)X=Q.pollIntervalMs;else{let H=K.headers.get("openai-poll-after-ms");if(H){let W=parseInt(H);if(!isNaN(W))X=W}}await n1(X);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return z}}}stream(Y,Z,Q){return u6.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}submitToolOutputs(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(P`/threads/${J}/runs/${Y}/submit_tool_outputs`,{body:z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}async submitToolOutputsAndPoll(Y,Z,Q){let J=await this.submitToolOutputs(Y,Z,Q);return await this.poll(J.id,Z,Q)}submitToolOutputsStream(Y,Z,Q){return u6.createToolAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}};I4.Steps=$8});var EY;var uJ=O(()=>{fJ();fJ();mJ();mJ();w0();gJ();q0();EY=class EY extends v{constructor(){super(...arguments);this.runs=new I4(this._client),this.messages=new U8(this._client)}create(Y={},Z){return this._client.post("/threads",{body:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(P`/threads/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(P`/threads/${Y}`,{body:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z){return this._client.delete(P`/threads/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}createAndRun(Y,Z){return this._client.post("/threads/runs",{body:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),stream:Y.stream??!1})}async createAndRunPoll(Y,Z){let Q=await this.createAndRun(Y,Z);return await this.runs.poll(Q.id,{thread_id:Q.thread_id},Z)}createAndRunStream(Y,Z){return u6.createThreadAssistantStream(Y,this._client.beta.threads,Z)}};EY.Runs=I4;EY.Messages=U8});var s1;var dJ=O(()=>{kJ();kJ();SJ();SJ();yJ();yJ();uJ();uJ();s1=class s1 extends v{constructor(){super(...arguments);this.realtime=new TY(this._client),this.chatkit=new IY(this._client),this.assistants=new X8(this._client),this.threads=new EY(this._client)}};s1.Realtime=TY;s1.ChatKit=IY;s1.Assistants=X8;s1.Threads=EY});var C4;var pJ=O(()=>{C4=class C4 extends v{create(Y,Z){return this._client.post("/completions",{body:Y,...Z,stream:Y.stream??!1})}}});var O8;var cJ=O(()=>{w0();q0();O8=class O8 extends v{retrieve(Y,Z,Q){let{container_id:J}=Z;return this._client.get(P`/containers/${J}/files/${Y}/content`,{...Q,headers:y([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}}});var A4;var lJ=O(()=>{cJ();cJ();_0();w0();a1();q0();A4=class A4 extends v{constructor(){super(...arguments);this.content=new O8(this._client)}create(Y,Z,Q){return this._client.post(P`/containers/${Y}/files`,V1({body:Z,...Q},this._client))}retrieve(Y,Z,Q){let{container_id:J}=Z;return this._client.get(P`/containers/${J}/files/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(P`/containers/${Y}/files`,K0,{query:Z,...Q})}delete(Y,Z,Q){let{container_id:J}=Z;return this._client.delete(P`/containers/${J}/files/${Y}`,{...Q,headers:y([{Accept:"*/*"},Q?.headers])})}};A4.Content=O8});var xY;var nJ=O(()=>{lJ();lJ();_0();w0();q0();xY=class xY extends v{constructor(){super(...arguments);this.files=new A4(this._client)}create(Y,Z){return this._client.post("/containers",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(P`/containers/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/containers",K0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(P`/containers/${Y}`,{...Z,headers:y([{Accept:"*/*"},Z?.headers])})}};xY.Files=A4});var M8;var iJ=O(()=>{_0();q0();M8=class M8 extends v{create(Y,Z,Q){let{include:J,...z}=Z;return this._client.post(P`/conversations/${Y}/items`,{query:{include:J},body:z,...Q})}retrieve(Y,Z,Q){let{conversation_id:J,...z}=Z;return this._client.get(P`/conversations/${J}/items/${Y}`,{query:z,...Q})}list(Y,Z={},Q){return this._client.getAPIList(P`/conversations/${Y}/items`,f6,{query:Z,...Q})}delete(Y,Z,Q){let{conversation_id:J}=Z;return this._client.delete(P`/conversations/${J}/items/${Y}`,Q)}}});var SY;var aJ=O(()=>{iJ();iJ();q0();SY=class SY extends v{constructor(){super(...arguments);this.items=new M8(this._client)}create(Y={},Z){return this._client.post("/conversations",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(P`/conversations/${Y}`,Z)}update(Y,Z,Q){return this._client.post(P`/conversations/${Y}`,{body:Z,...Q})}delete(Y,Z){return this._client.delete(P`/conversations/${Y}`,Z)}};SY.Items=M8});var k4;var oJ=O(()=>{B8();k4=class k4 extends v{create(Y,Z){let Q=!!Y.encoding_format,J=Q?Y.encoding_format:"base64";if(Q)E0(this._client).debug("embeddings/user defined encoding_format:",Y.encoding_format);let z=this._client.post("/embeddings",{body:{...Y,encoding_format:J},...Z});if(Q)return z;return E0(this._client).debug("embeddings/decoding base64 embeddings from base64"),z._thenUnwrap((K)=>{if(K&&K.data)K.data.forEach((X)=>{let H=X.embedding;X.embedding=BV(H)});return K})}}});var D8;var sJ=O(()=>{_0();q0();D8=class D8 extends v{retrieve(Y,Z,Q){let{eval_id:J,run_id:z}=Z;return this._client.get(P`/evals/${J}/runs/${z}/output_items/${Y}`,Q)}list(Y,Z,Q){let{eval_id:J,...z}=Z;return this._client.getAPIList(P`/evals/${J}/runs/${Y}/output_items`,K0,{query:z,...Q})}}});var E4;var rJ=O(()=>{sJ();sJ();_0();q0();E4=class E4 extends v{constructor(){super(...arguments);this.outputItems=new D8(this._client)}create(Y,Z,Q){return this._client.post(P`/evals/${Y}/runs`,{body:Z,...Q})}retrieve(Y,Z,Q){let{eval_id:J}=Z;return this._client.get(P`/evals/${J}/runs/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(P`/evals/${Y}/runs`,K0,{query:Z,...Q})}delete(Y,Z,Q){let{eval_id:J}=Z;return this._client.delete(P`/evals/${J}/runs/${Y}`,Q)}cancel(Y,Z,Q){let{eval_id:J}=Z;return this._client.post(P`/evals/${J}/runs/${Y}`,Q)}};E4.OutputItems=D8});var PY;var tJ=O(()=>{rJ();rJ();_0();q0();PY=class PY extends v{constructor(){super(...arguments);this.runs=new E4(this._client)}create(Y,Z){return this._client.post("/evals",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(P`/evals/${Y}`,Z)}update(Y,Z,Q){return this._client.post(P`/evals/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/evals",K0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(P`/evals/${Y}`,Z)}};PY.Runs=E4});var x4;var eJ=O(()=>{_0();w0();v1();a1();q0();x4=class x4 extends v{create(Y,Z){return this._client.post("/files",V1({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(P`/files/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/files",K0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(P`/files/${Y}`,Z)}content(Y,Z){return this._client.get(P`/files/${Y}/content`,{...Z,headers:y([{Accept:"application/binary"},Z?.headers]),__binaryResponse:!0})}async waitForProcessing(Y,{pollInterval:Z=5000,maxWait:Q=1800000}={}){let J=new Set(["processed","error","deleted"]),z=Date.now(),K=await this.retrieve(Y);while(!K.status||!J.has(K.status))if(await n1(Z),K=await this.retrieve(Y),Date.now()-z>Q)throw new NY({message:`Giving up on waiting for file ${Y} to finish processing after ${Q} milliseconds.`});return K}}});var N8;var Yz=O(()=>{N8=class N8 extends v{}});var _8;var Zz=O(()=>{_8=class _8 extends v{run(Y,Z){return this._client.post("/fine_tuning/alpha/graders/run",{body:Y,...Z})}validate(Y,Z){return this._client.post("/fine_tuning/alpha/graders/validate",{body:Y,...Z})}}});var S4;var Qz=O(()=>{Zz();Zz();S4=class S4 extends v{constructor(){super(...arguments);this.graders=new _8(this._client)}};S4.Graders=_8});var L8;var Jz=O(()=>{_0();q0();L8=class L8 extends v{create(Y,Z,Q){return this._client.getAPIList(P`/fine_tuning/checkpoints/${Y}/permissions`,V6,{body:Z,method:"post",...Q})}retrieve(Y,Z={},Q){return this._client.get(P`/fine_tuning/checkpoints/${Y}/permissions`,{query:Z,...Q})}delete(Y,Z,Q){let{fine_tuned_model_checkpoint:J}=Z;return this._client.delete(P`/fine_tuning/checkpoints/${J}/permissions/${Y}`,Q)}}});var P4;var zz=O(()=>{Jz();Jz();P4=class P4 extends v{constructor(){super(...arguments);this.permissions=new L8(this._client)}};P4.Permissions=L8});var w8;var Kz=O(()=>{_0();q0();w8=class w8 extends v{list(Y,Z={},Q){return this._client.getAPIList(P`/fine_tuning/jobs/${Y}/checkpoints`,K0,{query:Z,...Q})}}});var v4;var Xz=O(()=>{Kz();Kz();_0();q0();v4=class v4 extends v{constructor(){super(...arguments);this.checkpoints=new w8(this._client)}create(Y,Z){return this._client.post("/fine_tuning/jobs",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(P`/fine_tuning/jobs/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/fine_tuning/jobs",K0,{query:Y,...Z})}cancel(Y,Z){return this._client.post(P`/fine_tuning/jobs/${Y}/cancel`,Z)}listEvents(Y,Z={},Q){return this._client.getAPIList(P`/fine_tuning/jobs/${Y}/events`,K0,{query:Z,...Q})}pause(Y,Z){return this._client.post(P`/fine_tuning/jobs/${Y}/pause`,Z)}resume(Y,Z){return this._client.post(P`/fine_tuning/jobs/${Y}/resume`,Z)}};v4.Checkpoints=w8});var r1;var Hz=O(()=>{Yz();Yz();Qz();Qz();zz();zz();Xz();Xz();r1=class r1 extends v{constructor(){super(...arguments);this.methods=new N8(this._client),this.jobs=new v4(this._client),this.checkpoints=new P4(this._client),this.alpha=new S4(this._client)}};r1.Methods=N8;r1.Jobs=v4;r1.Checkpoints=P4;r1.Alpha=S4});var j8;var Wz=O(()=>{j8=class j8 extends v{}});var vY;var qz=O(()=>{Wz();Wz();vY=class vY extends v{constructor(){super(...arguments);this.graderModels=new j8(this._client)}};vY.GraderModels=j8});var y4;var Gz=O(()=>{a1();y4=class y4 extends v{createVariation(Y,Z){return this._client.post("/images/variations",V1({body:Y,...Z},this._client))}edit(Y,Z){return this._client.post("/images/edits",V1({body:Y,...Z,stream:Y.stream??!1},this._client))}generate(Y,Z){return this._client.post("/images/generations",{body:Y,...Z,stream:Y.stream??!1})}}});var f4;var Uz=O(()=>{_0();q0();f4=class f4 extends v{retrieve(Y,Z){return this._client.get(P`/models/${Y}`,Z)}list(Y){return this._client.getAPIList("/models",V6,Y)}delete(Y,Z){return this._client.delete(P`/models/${Y}`,Z)}}});var b4;var $z=O(()=>{b4=class b4 extends v{create(Y,Z){return this._client.post("/moderations",{body:Y,...Z})}}});var T8;var Bz=O(()=>{w0();q0();T8=class T8 extends v{accept(Y,Z,Q){return this._client.post(P`/realtime/calls/${Y}/accept`,{body:Z,...Q,headers:y([{Accept:"*/*"},Q?.headers])})}hangup(Y,Z){return this._client.post(P`/realtime/calls/${Y}/hangup`,{...Z,headers:y([{Accept:"*/*"},Z?.headers])})}refer(Y,Z,Q){return this._client.post(P`/realtime/calls/${Y}/refer`,{body:Z,...Q,headers:y([{Accept:"*/*"},Q?.headers])})}reject(Y,Z={},Q){return this._client.post(P`/realtime/calls/${Y}/reject`,{body:Z,...Q,headers:y([{Accept:"*/*"},Q?.headers])})}}});var I8;var Vz=O(()=>{I8=class I8 extends v{create(Y,Z){return this._client.post("/realtime/client_secrets",{body:Y,...Z})}}});var d6;var Fz=O(()=>{Bz();Bz();Vz();Vz();d6=class d6 extends v{constructor(){super(...arguments);this.clientSecrets=new I8(this._client),this.calls=new T8(this._client)}};d6.ClientSecrets=I8;d6.Calls=T8});function LV(Y,Z){if(!Z||!VI(Z))return{...Y,output_parsed:null,output:Y.output.map((Q)=>{if(Q.type==="function_call")return{...Q,parsed_arguments:null};if(Q.type==="message")return{...Q,content:Q.content.map((J)=>({...J,parsed:null}))};else return Q})};return Rz(Y,Z)}function Rz(Y,Z){let Q=Y.output.map((z)=>{if(z.type==="function_call")return{...z,parsed_arguments:OI(Z,z)};if(z.type==="message"){let K=z.content.map((X)=>{if(X.type==="output_text")return{...X,parsed:BI(Z,X.text)};return X});return{...z,content:K}}return z}),J=Object.assign({},Y,{output:Q});if(!Object.getOwnPropertyDescriptor(Y,"output_text"))O5(J);return Object.defineProperty(J,"output_parsed",{enumerable:!0,get(){for(let z of J.output){if(z.type!=="message")continue;for(let K of z.content)if(K.type==="output_text"&&K.parsed!==null)return K.parsed}return null}}),J}function BI(Y,Z){if(Y.text?.format?.type!=="json_schema")return null;if("$parseRaw"in Y.text?.format)return(Y.text?.format).$parseRaw(Z);return JSON.parse(Z)}function VI(Y){if(iZ(Y.text?.format))return!0;return!1}function FI(Y){return Y?.$brand==="auto-parseable-tool"}function RI(Y,Z){return Y.find((Q)=>Q.type==="function"&&Q.name===Z)}function OI(Y,Z){let Q=RI(Y.tools??[],Z.name);return{...Z,...Z,parsed_arguments:FI(Q)?Q.$parseRaw(Z.arguments):Q?.strict?JSON.parse(Z.arguments):null}}function O5(Y){let Z=[];for(let Q of Y.output){if(Q.type!=="message")continue;for(let J of Q.content)if(J.type==="output_text")Z.push(J.text)}Y.output_text=Z.join("")}var Oz=O(()=>{v1();oZ()});function MI(Y,Z){return LV(Y,Z)}var h4,M5,p6,D5,wV,jV,TV,IV,N5;var CV=O(()=>{I1();v1();H5();Oz();N5=class N5 extends wY{constructor(Y){super();h4.add(this),M5.set(this,void 0),p6.set(this,void 0),D5.set(this,void 0),i(this,M5,Y,"f")}static createResponse(Y,Z,Q){let J=new N5(Z);return J._run(()=>J._createOrRetrieveResponse(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createOrRetrieveResponse(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}T(this,h4,"m",wV).call(this);let z,K=null;if("response_id"in Z)z=await Y.responses.retrieve(Z.response_id,{stream:!0},{...Q,signal:this.controller.signal,stream:!0}),K=Z.starting_after??null;else z=await Y.responses.create({...Z,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let X of z)T(this,h4,"m",jV).call(this,X,K);if(z.controller.signal?.aborted)throw new g0;return T(this,h4,"m",TV).call(this)}[(M5=new WeakMap,p6=new WeakMap,D5=new WeakMap,h4=new WeakSet,wV=function Y(){if(this.ended)return;i(this,p6,void 0,"f")},jV=function Y(Z,Q){if(this.ended)return;let J=(K,X)=>{if(Q==null||X.sequence_number>Q)this._emit(K,X)},z=T(this,h4,"m",IV).call(this,Z);switch(J("event",Z),Z.type){case"response.output_text.delta":{let K=z.output[Z.output_index];if(!K)throw new p(`missing output at index ${Z.output_index}`);if(K.type==="message"){let X=K.content[Z.content_index];if(!X)throw new p(`missing content at index ${Z.content_index}`);if(X.type!=="output_text")throw new p(`expected content to be 'output_text', got ${X.type}`);J("response.output_text.delta",{...Z,snapshot:X.text})}break}case"response.function_call_arguments.delta":{let K=z.output[Z.output_index];if(!K)throw new p(`missing output at index ${Z.output_index}`);if(K.type==="function_call")J("response.function_call_arguments.delta",{...Z,snapshot:K.arguments});break}default:J(Z.type,Z);break}},TV=function Y(){if(this.ended)throw new p("stream has ended, this shouldn't happen");let Z=T(this,p6,"f");if(!Z)throw new p("request ended without sending any events");i(this,p6,void 0,"f");let Q=MI(Z,T(this,M5,"f"));return i(this,D5,Q,"f"),Q},IV=function Y(Z){let Q=T(this,p6,"f");if(!Q){if(Z.type!=="response.created")throw new p(`When snapshot hasn't been set yet, expected 'response.created' event, got ${Z.type}`);return Q=i(this,p6,Z.response,"f"),Q}switch(Z.type){case"response.output_item.added":{Q.output.push(Z.item);break}case"response.content_part.added":{let J=Q.output[Z.output_index];if(!J)throw new p(`missing output at index ${Z.output_index}`);let z=J.type,K=Z.part;if(z==="message"&&K.type!=="reasoning_text")J.content.push(K);else if(z==="reasoning"&&K.type==="reasoning_text"){if(!J.content)J.content=[];J.content.push(K)}break}case"response.output_text.delta":{let J=Q.output[Z.output_index];if(!J)throw new p(`missing output at index ${Z.output_index}`);if(J.type==="message"){let z=J.content[Z.content_index];if(!z)throw new p(`missing content at index ${Z.content_index}`);if(z.type!=="output_text")throw new p(`expected content to be 'output_text', got ${z.type}`);z.text+=Z.delta}break}case"response.function_call_arguments.delta":{let J=Q.output[Z.output_index];if(!J)throw new p(`missing output at index ${Z.output_index}`);if(J.type==="function_call")J.arguments+=Z.delta;break}case"response.reasoning_text.delta":{let J=Q.output[Z.output_index];if(!J)throw new p(`missing output at index ${Z.output_index}`);if(J.type==="reasoning"){let z=J.content?.[Z.content_index];if(!z)throw new p(`missing content at index ${Z.content_index}`);if(z.type!=="reasoning_text")throw new p(`expected content to be 'reasoning_text', got ${z.type}`);z.text+=Z.delta}break}case"response.completed":{i(this,p6,Z.response,"f");break}}return Q},Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,K)=>Z.push({resolve:z,reject:K})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let Y=T(this,D5,"f");if(!Y)throw new p("stream ended without producing a ChatCompletion");return Y}}});var C8;var Mz=O(()=>{_0();q0();C8=class C8 extends v{list(Y,Z={},Q){return this._client.getAPIList(P`/responses/${Y}/input_items`,K0,{query:Z,...Q})}}});var A8;var Dz=O(()=>{A8=class A8 extends v{count(Y={},Z){return this._client.post("/responses/input_tokens",{body:Y,...Z})}}});var c6;var Nz=O(()=>{Oz();CV();Mz();Mz();Dz();Dz();w0();q0();c6=class c6 extends v{constructor(){super(...arguments);this.inputItems=new C8(this._client),this.inputTokens=new A8(this._client)}create(Y,Z){return this._client.post("/responses",{body:Y,...Z,stream:Y.stream??!1})._thenUnwrap((Q)=>{if("object"in Q&&Q.object==="response")O5(Q);return Q})}retrieve(Y,Z={},Q){return this._client.get(P`/responses/${Y}`,{query:Z,...Q,stream:Z?.stream??!1})._thenUnwrap((J)=>{if("object"in J&&J.object==="response")O5(J);return J})}delete(Y,Z){return this._client.delete(P`/responses/${Y}`,{...Z,headers:y([{Accept:"*/*"},Z?.headers])})}parse(Y,Z){return this._client.responses.create(Y,Z)._thenUnwrap((Q)=>Rz(Q,Y))}stream(Y,Z){return N5.createResponse(this._client,Y,Z)}cancel(Y,Z){return this._client.post(P`/responses/${Y}/cancel`,Z)}compact(Y,Z){return this._client.post("/responses/compact",{body:Y,...Z})}};c6.InputItems=C8;c6.InputTokens=A8});var k8;var _z=O(()=>{a1();q0();k8=class k8 extends v{create(Y,Z,Q){return this._client.post(P`/uploads/${Y}/parts`,V1({body:Z,...Q},this._client))}}});var yY;var Lz=O(()=>{_z();_z();q0();yY=class yY extends v{constructor(){super(...arguments);this.parts=new k8(this._client)}create(Y,Z){return this._client.post("/uploads",{body:Y,...Z})}cancel(Y,Z){return this._client.post(P`/uploads/${Y}/cancel`,Z)}complete(Y,Z,Q){return this._client.post(P`/uploads/${Y}/complete`,{body:Z,...Q})}};yY.Parts=k8});var AV=async(Y)=>{let Z=await Promise.allSettled(Y),Q=Z.filter((z)=>z.status==="rejected");if(Q.length){for(let z of Q)console.error(z.reason);throw Error(`${Q.length} promise(s) failed - see the above errors`)}let J=[];for(let z of Z)if(z.status==="fulfilled")J.push(z.value);return J};var E8;var wz=O(()=>{_0();w0();q0();E8=class E8 extends v{create(Y,Z,Q){return this._client.post(P`/vector_stores/${Y}/file_batches`,{body:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.get(P`/vector_stores/${J}/file_batches/${Y}`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.post(P`/vector_stores/${J}/file_batches/${Y}/cancel`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z);return await this.poll(Y,J.id,Q)}listFiles(Y,Z,Q){let{vector_store_id:J,...z}=Z;return this._client.getAPIList(P`/vector_stores/${J}/file_batches/${Y}/files`,K0,{query:z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async poll(Y,Z,Q){let J=y([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:z,response:K}=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:J}).withResponse();switch(z.status){case"in_progress":let X=5000;if(Q?.pollIntervalMs)X=Q.pollIntervalMs;else{let H=K.headers.get("openai-poll-after-ms");if(H){let W=parseInt(H);if(!isNaN(W))X=W}}await n1(X);break;case"failed":case"cancelled":case"completed":return z}}}async uploadAndPoll(Y,{files:Z,fileIds:Q=[]},J){if(Z==null||Z.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let z=J?.maxConcurrency??5,K=Math.min(z,Z.length),X=this._client,H=Z.values(),W=[...Q];async function q($){for(let B of $){let V=await X.files.create({file:B,purpose:"assistants"},J);W.push(V.id)}}let G=Array(K).fill(H).map(q);return await AV(G),await this.createAndPoll(Y,{file_ids:W})}}});var x8;var jz=O(()=>{_0();w0();B8();q0();x8=class x8 extends v{create(Y,Z,Q){return this._client.post(P`/vector_stores/${Y}/files`,{body:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.get(P`/vector_stores/${J}/files/${Y}`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{vector_store_id:J,...z}=Z;return this._client.post(P`/vector_stores/${J}/files/${Y}`,{body:z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(P`/vector_stores/${Y}/files`,K0,{query:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.delete(P`/vector_stores/${J}/files/${Y}`,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z,Q);return await this.poll(Y,J.id,Q)}async poll(Y,Z,Q){let J=y([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let z=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:J}).withResponse(),K=z.data;switch(K.status){case"in_progress":let X=5000;if(Q?.pollIntervalMs)X=Q.pollIntervalMs;else{let H=z.response.headers.get("openai-poll-after-ms");if(H){let W=parseInt(H);if(!isNaN(W))X=W}}await n1(X);break;case"failed":case"completed":return K}}}async upload(Y,Z,Q){let J=await this._client.files.create({file:Z,purpose:"assistants"},Q);return this.create(Y,{file_id:J.id},Q)}async uploadAndPoll(Y,Z,Q){let J=await this.upload(Y,Z,Q);return await this.poll(Y,J.id,Q)}content(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.getAPIList(P`/vector_stores/${J}/files/${Y}/content`,V6,{...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var l6;var Tz=O(()=>{wz();wz();jz();jz();_0();w0();q0();l6=class l6 extends v{constructor(){super(...arguments);this.files=new x8(this._client),this.fileBatches=new E8(this._client)}create(Y,Z){return this._client.post("/vector_stores",{body:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(P`/vector_stores/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(P`/vector_stores/${Y}`,{body:Z,...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/vector_stores",K0,{query:Y,...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(P`/vector_stores/${Y}`,{...Z,headers:y([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}search(Y,Z,Q){return this._client.getAPIList(P`/vector_stores/${Y}/search`,V6,{body:Z,method:"post",...Q,headers:y([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}};l6.Files=x8;l6.FileBatches=E8});var g4;var Iz=O(()=>{_0();w0();a1();q0();g4=class g4 extends v{create(Y,Z){return this._client.post("/videos",JJ({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(P`/videos/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/videos",f6,{query:Y,...Z})}delete(Y,Z){return this._client.delete(P`/videos/${Y}`,Z)}downloadContent(Y,Z={},Q){return this._client.get(P`/videos/${Y}/content`,{query:Z,...Q,headers:y([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}remix(Y,Z,Q){return this._client.post(P`/videos/${Y}/remix`,JJ({body:Z,...Q},this._client))}}});var m4,kV,_5,u4;var Cz=O(()=>{I1();v1();w0();u4=class u4 extends v{constructor(){super(...arguments);m4.add(this)}async unwrap(Y,Z,Q=this._client.webhookSecret,J=300){return await this.verifySignature(Y,Z,Q,J),JSON.parse(Y)}async verifySignature(Y,Z,Q=this._client.webhookSecret,J=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!=="function"||typeof crypto.subtle.verify!=="function")throw Error("Webhook signature verification is only supported when the `crypto` global is defined");T(this,m4,"m",kV).call(this,Q);let z=y([Z]).values,K=T(this,m4,"m",_5).call(this,z,"webhook-signature"),X=T(this,m4,"m",_5).call(this,z,"webhook-timestamp"),H=T(this,m4,"m",_5).call(this,z,"webhook-id"),W=parseInt(X,10);if(isNaN(W))throw new U6("Invalid webhook timestamp format");let q=Math.floor(Date.now()/1000);if(q-W>J)throw new U6("Webhook timestamp is too old");if(W>q+J)throw new U6("Webhook timestamp is too new");let G=K.split(" ").map((F)=>F.startsWith("v1,")?F.substring(3):F),$=Q.startsWith("whsec_")?Buffer.from(Q.replace("whsec_",""),"base64"):Buffer.from(Q,"utf-8"),B=H?`${H}.${X}.${Y}`:`${X}.${Y}`,V=await crypto.subtle.importKey("raw",$,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let F of G)try{let M=Buffer.from(F,"base64");if(await crypto.subtle.verify("HMAC",V,M,new TextEncoder().encode(B)))return}catch{continue}throw new U6("The given webhook signature does not match the expected signature")}};m4=new WeakSet,kV=function Y(Z){if(typeof Z!=="string"||Z.length===0)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},_5=function Y(Z,Q){if(!Z)throw Error("Headers are required");let J=Z.get(Q);if(J===null||J===void 0)throw Error(`Missing required header: ${Q}`);return J}});var EV=O(()=>{CJ();AJ();dJ();pJ();nJ();aJ();oJ();tJ();eJ();Hz();qz();Gz();Uz();$z();Fz();Nz();Lz();Tz();Iz();Cz();GV();UV()});class Y0{constructor({baseURL:Y=m6("OPENAI_BASE_URL"),apiKey:Z=m6("OPENAI_API_KEY"),organization:Q=m6("OPENAI_ORG_ID")??null,project:J=m6("OPENAI_PROJECT_ID")??null,webhookSecret:z=m6("OPENAI_WEBHOOK_SECRET")??null,...K}={}){if(Az.add(this),L5.set(this,void 0),this.completions=new C4(this),this.chat=new jY(this),this.embeddings=new k4(this),this.files=new x4(this),this.images=new y4(this),this.audio=new O6(this),this.moderations=new b4(this),this.models=new f4(this),this.fineTuning=new r1(this),this.graders=new vY(this),this.vectorStores=new l6(this),this.webhooks=new u4(this),this.beta=new s1(this),this.batches=new j4(this),this.uploads=new yY(this),this.responses=new c6(this),this.realtime=new d6(this),this.conversations=new SY(this),this.evals=new PY(this),this.containers=new xY(this),this.videos=new g4(this),Z===void 0)throw new p("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");let X={apiKey:Z,organization:Q,project:J,webhookSecret:z,...K,baseURL:Y||"https://api.openai.com/v1"};if(!X.dangerouslyAllowBrowser&&_B())throw new p(`It looks like you're running in a browser-like environment.
|
|
468
467
|
|
|
469
468
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
470
469
|
If you understand the risks and have appropriate mitigations in place,
|
|
@@ -473,13 +472,13 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
473
472
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
474
473
|
|
|
475
474
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
476
|
-
`);this.baseURL=H.baseURL,this.timeout=H.timeout??rJ.DEFAULT_TIMEOUT,this.logger=H.logger??console;let W="warn";this.logLevel=W,this.logLevel=O9(H.logLevel,"ClientOptions.logLevel",this)??O9(I6("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??W,this.fetchOptions=H.fetchOptions,this.maxRetries=H.maxRetries??2,this.fetch=H.fetch??yU(),p(this,e2,bU,"f"),this._options=H,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Q,this.project=J,this.webhookSecret=z}withOptions(Y){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...Y})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:Y,nulls:Z}){return}async authHeaders(Y){return v([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(Y){return R9(Y,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${D6}`}defaultIdempotencyKey(){return`stainless-node-retry-${X9()}`}makeStatusError(Y,Z,Q,J){return O0.generate(Y,Z,Q,J)}async _callApiKey(){let Y=this._options.apiKey;if(typeof Y!=="function")return!1;let Z;try{Z=await Y()}catch(Q){if(Q instanceof h)throw Q;throw new h(`Failed to get token from 'apiKey' function: ${Q.message}`,{cause:Q})}if(typeof Z!=="string"||!Z)throw new h(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(Y,Z,Q){let J=!_(this,sJ,"m",pB).call(this)&&Q||this.baseURL,z=jU(Y)?new URL(Y):new URL(J+(J.endsWith("/")&&Y.startsWith("/")?Y.slice(1):Y)),X=this.defaultQuery();if(!TU(X))Z={...X,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))z.search=this.stringifyQuery(Z);return z.toString()}async prepareOptions(Y){await this._callApiKey()}async prepareRequest(Y,{url:Z,options:Q}){}get(Y,Z){return this.methodRequest("get",Y,Z)}post(Y,Z){return this.methodRequest("post",Y,Z)}patch(Y,Z){return this.methodRequest("patch",Y,Z)}put(Y,Z){return this.methodRequest("put",Y,Z)}delete(Y,Z){return this.methodRequest("delete",Y,Z)}methodRequest(Y,Z,Q){return this.request(Promise.resolve(Q).then((J)=>{return{method:Y,path:Z,...J}}))}request(Y,Z=null){return new H1(this,this.makeRequest(Y,Z,void 0))}async makeRequest(Y,Z,Q){let J=await Y,z=J.maxRetries??this.maxRetries;if(Z==null)Z=z;await this.prepareOptions(J);let{req:X,url:H,timeout:W}=await this.buildRequest(J,{retryCount:z-Z});await this.prepareRequest(X,{url:H,options:J});let K="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),$=Q===void 0?"":`, retryOf: ${Q}`,G=Date.now();if(R0(this).debug(`[${K}] sending request`,sY({retryOfRequestLogID:Q,method:J.method,url:H,options:J,headers:X.headers})),J.signal?.aborted)throw new _0;let U=new AbortController,B=await this.fetchWithTimeout(H,X,W,U).catch(G4),F=Date.now();if(B instanceof globalThis.Error){let N=`retrying, ${Z} attempts remaining`;if(J.signal?.aborted)throw new _0;let w=K4(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return R0(this).info(`[${K}] connection ${w?"timed out":"failed"} - ${N}`),R0(this).debug(`[${K}] connection ${w?"timed out":"failed"} (${N})`,sY({retryOfRequestLogID:Q,url:H,durationMs:F-G,message:B.message})),this.retryRequest(J,Z,Q??K);if(R0(this).info(`[${K}] connection ${w?"timed out":"failed"} - error; no more retries left`),R0(this).debug(`[${K}] connection ${w?"timed out":"failed"} (error; no more retries left)`,sY({retryOfRequestLogID:Q,url:H,durationMs:F-G,message:B.message})),w)throw new X1;throw new z1({cause:B})}let V=[...B.headers.entries()].filter(([N])=>N==="x-request-id").map(([N,w])=>", "+N+": "+JSON.stringify(w)).join(""),O=`[${K}${$}${V}] ${X.method} ${H} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${F-G}ms`;if(!B.ok){let N=await this.shouldRetry(B);if(Z&&N){let E=`retrying, ${Z} attempts remaining`;return await fU(B.body),R0(this).info(`${O} - ${E}`),R0(this).debug(`[${K}] response error (${E})`,sY({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:F-G})),this.retryRequest(J,Z,Q??K,B.headers)}let w=N?"error; no more retries left":"error; not retryable";R0(this).info(`${O} - ${w}`);let L=await B.text().catch((E)=>G4(E).message),I=AU(L),T=I?void 0:L;throw R0(this).debug(`[${K}] response error (${w})`,sY({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,message:T,durationMs:Date.now()-G})),this.makeStatusError(B.status,I,T,B.headers)}return R0(this).info(O),R0(this).debug(`[${K}] response start`,sY({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:F-G})),{response:B,options:J,controller:U,requestLogID:K,retryOfRequestLogID:Q,startTime:G}}getAPIList(Y,Z,Q){return this.requestAPIList(Z,{method:"get",path:Y,...Q})}requestAPIList(Y,Z){let Q=this.makeRequest(Z,null,void 0);return new A2(this,Q,Y)}async fetchWithTimeout(Y,Z,Q,J){let{signal:z,method:X,...H}=Z||{};if(z)z.addEventListener("abort",()=>J.abort());let W=setTimeout(()=>J.abort(),Q),K=globalThis.ReadableStream&&H.body instanceof globalThis.ReadableStream||typeof H.body==="object"&&H.body!==null&&Symbol.asyncIterator in H.body,$={signal:J.signal,...K?{duplex:"half"}:{},method:"GET",...H};if(X)$.method=X.toUpperCase();try{return await this.fetch.call(void 0,Y,$)}finally{clearTimeout(W)}}async shouldRetry(Y){let Z=Y.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(Y.status===408)return!0;if(Y.status===409)return!0;if(Y.status===429)return!0;if(Y.status>=500)return!0;return!1}async retryRequest(Y,Z,Q,J){let z,X=J?.get("retry-after-ms");if(X){let W=parseFloat(X);if(!Number.isNaN(W))z=W}let H=J?.get("retry-after");if(H&&!z){let W=parseFloat(H);if(!Number.isNaN(W))z=W*1000;else z=Date.parse(H)-Date.now()}if(!(z&&0<=z&&z<60000)){let W=Y.maxRetries??this.maxRetries;z=this.calculateDefaultRetryTimeoutMillis(Z,W)}return await TY(z),this.makeRequest(Y,Z-1,Q)}calculateDefaultRetryTimeoutMillis(Y,Z){let z=Z-Y,X=Math.min(0.5*Math.pow(2,z),8),H=1-Math.random()*0.25;return X*H*1000}async buildRequest(Y,{retryCount:Z=0}={}){let Q={...Y},{method:J,path:z,query:X,defaultBaseURL:H}=Q,W=this.buildURL(z,X,H);if("timeout"in Q)kU("timeout",Q.timeout);Q.timeout=Q.timeout??this.timeout;let{bodyHeaders:K,body:$}=this.buildBody({options:Q}),G=await this.buildHeaders({options:Y,method:J,bodyHeaders:K,retryCount:Z});return{req:{method:J,headers:G,...Q.signal&&{signal:Q.signal},...globalThis.ReadableStream&&$ instanceof globalThis.ReadableStream&&{duplex:"half"},...$&&{body:$},...this.fetchOptions??{},...Q.fetchOptions??{}},url:W,timeout:Q.timeout}}async buildHeaders({options:Y,method:Z,bodyHeaders:Q,retryCount:J}){let z={};if(this.idempotencyHeader&&Z!=="get"){if(!Y.idempotencyKey)Y.idempotencyKey=this.defaultIdempotencyKey();z[this.idempotencyHeader]=Y.idempotencyKey}let X=v([z,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(J),...Y.timeout?{"X-Stainless-Timeout":String(Math.trunc(Y.timeout/1000))}:{},...vU(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(Y),this._options.defaultHeaders,Q,Y.headers]);return this.validateHeaders(X),X.values}buildBody({options:{body:Y,headers:Z}}){if(!Y)return{bodyHeaders:void 0,body:void 0};let Q=v([Z]);if(ArrayBuffer.isView(Y)||Y instanceof ArrayBuffer||Y instanceof DataView||typeof Y==="string"&&Q.values.has("content-type")||globalThis.Blob&&Y instanceof globalThis.Blob||Y instanceof FormData||Y instanceof URLSearchParams||globalThis.ReadableStream&&Y instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:Y};else if(typeof Y==="object"&&((Symbol.asyncIterator in Y)||(Symbol.iterator in Y)&&("next"in Y)&&typeof Y.next==="function"))return{bodyHeaders:void 0,body:O2(Y)};else return _(this,e2,"f").call(this,{body:Y,headers:Q})}}var sJ,rJ,e2,pB;var Y5=R(()=>{KY();oY();K9();iU();jY();K0();C9();dB();T2();s9();qJ();MJ();wJ();PJ();SJ();vJ();aJ();oJ();o9();$J();l9();VJ();RJ();NJ();AJ();EJ();bJ();dJ();cJ();nJ();K9();U0();L4();oY();rJ=s,e2=new WeakMap,sJ=new WeakSet,pB=function Y(){return this.baseURL!=="https://api.openai.com/v1"};s.OpenAI=rJ;s.DEFAULT_TIMEOUT=600000;s.OpenAIError=h;s.APIError=O0;s.APIConnectionError=z1;s.APIConnectionTimeoutError=X1;s.APIUserAbortError=_0;s.NotFoundError=B4;s.ConflictError=V4;s.RateLimitError=R4;s.BadRequestError=$4;s.AuthenticationError=q4;s.InternalServerError=M4;s.PermissionDeniedError=U4;s.UnprocessableEntityError=F4;s.InvalidWebhookSignatureError=aY;s.toFile=E2;s.Completions=$8;s.Chat=G1;s.Embeddings=U8;s.Files=V8;s.Images=O8;s.Audio=Y6;s.Moderations=N8;s.Models=D8;s.FineTuning=EY;s.Graders=D1;s.VectorStores=A6;s.Webhooks=I8;s.Beta=xY;s.Batches=W8;s.Uploads=N1;s.Responses=k6;s.Realtime=T6;s.Conversations=M1;s.Evals=O1;s.Containers=R1;s.Videos=L8});var cB=R(()=>{U0();MY();n4();Y5()});var lB=R(()=>{Y5();C9();T2();Y5();K0();jY();cB()});class Z5{client;defaultModel;constructor(Y,Z,Q="gpt-5-nano",J){this.client=new s({apiKey:Y,baseURL:Z,defaultHeaders:J}),this.defaultModel=Q}async generate(Y){return(await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,reasoning_effort:Y.reasoning})).choices[0].message.content||""}async*streamGenerate(Y){try{let Z=await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,stream:!0,reasoning_effort:Y.reasoning});for await(let Q of Z){let J=Q.choices[0]?.delta,z=J?.content,X=J?.reasoning_content||J?.reasoning||J?.reasoning_details?.[0]?.summary;if(z||X)yield{chunk:z??void 0,thinkingChunk:X??void 0,metadata:{model:Q.model,finishReason:Q.choices[0]?.finish_reason??void 0}}}}catch(Z){yield{error:fz(Z)?Z:new n(String(Z),"OPENAI_STREAM_ERROR")}}}}var iB=R(()=>{lB();z0()});var nB=()=>{};async function UZ(){let Y=await q0(),Z=Y.get("llm.provider")||"openai",Q=await Y.getSecure("llm.apiKey"),J=Y.get("llm.model");if(!Q)throw new n("No API key found. Please set llm.apiKey in ~/.gdx/.gdxrc.toml or GDX_LLM_API_KEY env var.","NO_API_KEY");if(Q.startsWith("sk-or-"))Z="openrouter";switch(Z.toLowerCase()){case"openrouter":return new Z5(Q,zX,J,{"HTTP-Referer":"https://github.com/Type-Delta/gdx/tree/main","X-Title":"GDX"});case"openai":return new Z5(Q,void 0,J);default:throw new n(`Unsupported LLM provider: ${Z}`,"UNSUPPORTED_LLM_PROVIDER")}}var tJ=R(()=>{z0();W0();FY();iB();nB()});function aB(Y,Z){var Q=Object.keys(Y);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(Y);Z&&(J=J.filter(function(z){return Object.getOwnPropertyDescriptor(Y,z).enumerable})),Q.push.apply(Q,J)}return Q}function oB(Y){for(var Z=1;Z<arguments.length;Z++){var Q=arguments[Z]!=null?arguments[Z]:{};Z%2?aB(Object(Q),!0).forEach(function(J){Hj(Y,J,Q[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(Q)):aB(Object(Q)).forEach(function(J){Object.defineProperty(Y,J,Object.getOwnPropertyDescriptor(Q,J))})}return Y}function Hj(Y,Z,Q){if(Z=Wj(Z),Z in Y)Object.defineProperty(Y,Z,{value:Q,enumerable:!0,configurable:!0,writable:!0});else Y[Z]=Q;return Y}function Wj(Y){var Z=Kj(Y,"string");return typeof Z==="symbol"?Z:String(Z)}function Kj(Y,Z){if(typeof Y!=="object"||Y===null)return Y;var Q=Y[Symbol.toPrimitive];if(Q!==void 0){var J=Q.call(Y,Z||"default");if(typeof J!=="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return(Z==="string"?String:Number)(Y)}function sB(Y){return Z.withOptions=(Q)=>sB(oB(oB({},Y),Q)),Z;function Z(Q,...J){let z=typeof Q==="string"?[Q]:Q.raw,{alignValues:X=!1,escapeSpecialCharacters:H=Array.isArray(Q),trimWhitespace:W=!0}=Y,K="";for(let U=0;U<z.length;U++){let B=z[U];if(H)B=B.replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(K+=B,U<J.length){let F=X?$j(J[U],K):J[U];K+=F}}let $=K.split(`
|
|
477
|
-
`),G=null;for(let
|
|
478
|
-
`)}if(W
|
|
479
|
-
`);return
|
|
475
|
+
`);this.baseURL=X.baseURL,this.timeout=X.timeout??kz.DEFAULT_TIMEOUT,this.logger=X.logger??console;let H="warn";this.logLevel=H,this.logLevel=s9(X.logLevel,"ClientOptions.logLevel",this)??s9(m6("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??H,this.fetchOptions=X.fetchOptions,this.maxRetries=X.maxRetries??2,this.fetch=X.fetch??wB(),i(this,L5,TB,"f"),this._options=X,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Q,this.project=J,this.webhookSecret=z}withOptions(Y){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...Y})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:Y,nulls:Z}){return}async authHeaders(Y){return y([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(Y){return a9(Y,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${y6}`}defaultIdempotencyKey(){return`stainless-node-retry-${b9()}`}makeStatusError(Y,Z,Q,J){return y0.generate(Y,Z,Q,J)}async _callApiKey(){let Y=this._options.apiKey;if(typeof Y!=="function")return!1;let Z;try{Z=await Y()}catch(Q){if(Q instanceof p)throw Q;throw new p(`Failed to get token from 'apiKey' function: ${Q.message}`,{cause:Q})}if(typeof Z!=="string"||!Z)throw new p(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(Y,Z,Q){let J=!T(this,Az,"m",xV).call(this)&&Q||this.baseURL,z=BB(Y)?new URL(Y):new URL(J+(J.endsWith("/")&&Y.startsWith("/")?Y.slice(1):Y)),K=this.defaultQuery();if(!VB(K))Z={...K,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))z.search=this.stringifyQuery(Z);return z.toString()}async prepareOptions(Y){await this._callApiKey()}async prepareRequest(Y,{url:Z,options:Q}){}get(Y,Z){return this.methodRequest("get",Y,Z)}post(Y,Z){return this.methodRequest("post",Y,Z)}patch(Y,Z){return this.methodRequest("patch",Y,Z)}put(Y,Z){return this.methodRequest("put",Y,Z)}delete(Y,Z){return this.methodRequest("delete",Y,Z)}methodRequest(Y,Z,Q){return this.request(Promise.resolve(Q).then((J)=>{return{method:Y,path:Z,...J}}))}request(Y,Z=null){return new _Y(this,this.makeRequest(Y,Z,void 0))}async makeRequest(Y,Z,Q){let J=await Y,z=J.maxRetries??this.maxRetries;if(Z==null)Z=z;await this.prepareOptions(J);let{req:K,url:X,timeout:H}=await this.buildRequest(J,{retryCount:z-Z});await this.prepareRequest(K,{url:X,options:J});let W="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),q=Q===void 0?"":`, retryOf: ${Q}`,G=Date.now();if(E0(this).debug(`[${W}] sending request`,B6({retryOfRequestLogID:Q,method:J.method,url:X,options:J,headers:K.headers})),J.signal?.aborted)throw new g0;let $=new AbortController,B=await this.fetchWithTimeout(X,K,H,$).catch(kZ),V=Date.now();if(B instanceof globalThis.Error){let L=`retrying, ${Z} attempts remaining`;if(J.signal?.aborted)throw new g0;let N=AZ(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return E0(this).info(`[${W}] connection ${N?"timed out":"failed"} - ${L}`),E0(this).debug(`[${W}] connection ${N?"timed out":"failed"} (${L})`,B6({retryOfRequestLogID:Q,url:X,durationMs:V-G,message:B.message})),this.retryRequest(J,Z,Q??W);if(E0(this).info(`[${W}] connection ${N?"timed out":"failed"} - error; no more retries left`),E0(this).debug(`[${W}] connection ${N?"timed out":"failed"} (error; no more retries left)`,B6({retryOfRequestLogID:Q,url:X,durationMs:V-G,message:B.message})),N)throw new NY;throw new DY({cause:B})}let F=[...B.headers.entries()].filter(([L])=>L==="x-request-id").map(([L,N])=>", "+L+": "+JSON.stringify(N)).join(""),M=`[${W}${q}${F}] ${K.method} ${X} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${V-G}ms`;if(!B.ok){let L=await this.shouldRetry(B);if(Z&&L){let x=`retrying, ${Z} attempts remaining`;return await jB(B.body),E0(this).info(`${M} - ${x}`),E0(this).debug(`[${W}] response error (${x})`,B6({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:V-G})),this.retryRequest(J,Z,Q??W,B.headers)}let N=L?"error; no more retries left":"error; not retryable";E0(this).info(`${M} - ${N}`);let _=await B.text().catch((x)=>kZ(x).message),I=OB(_),w=I?void 0:_;throw E0(this).debug(`[${W}] response error (${N})`,B6({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,message:w,durationMs:Date.now()-G})),this.makeStatusError(B.status,I,w,B.headers)}return E0(this).info(M),E0(this).debug(`[${W}] response start`,B6({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:V-G})),{response:B,options:J,controller:$,requestLogID:W,retryOfRequestLogID:Q,startTime:G}}getAPIList(Y,Z,Q){return this.requestAPIList(Z,{method:"get",path:Y,...Q})}requestAPIList(Y,Z){let Q=this.makeRequest(Z,null,void 0);return new t7(this,Q,Y)}async fetchWithTimeout(Y,Z,Q,J){let{signal:z,method:K,...X}=Z||{};if(z)z.addEventListener("abort",()=>J.abort());let H=setTimeout(()=>J.abort(),Q),W=globalThis.ReadableStream&&X.body instanceof globalThis.ReadableStream||typeof X.body==="object"&&X.body!==null&&Symbol.asyncIterator in X.body,q={signal:J.signal,...W?{duplex:"half"}:{},method:"GET",...X};if(K)q.method=K.toUpperCase();try{return await this.fetch.call(void 0,Y,q)}finally{clearTimeout(H)}}async shouldRetry(Y){let Z=Y.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(Y.status===408)return!0;if(Y.status===409)return!0;if(Y.status===429)return!0;if(Y.status>=500)return!0;return!1}async retryRequest(Y,Z,Q,J){let z,K=J?.get("retry-after-ms");if(K){let H=parseFloat(K);if(!Number.isNaN(H))z=H}let X=J?.get("retry-after");if(X&&!z){let H=parseFloat(X);if(!Number.isNaN(H))z=H*1000;else z=Date.parse(X)-Date.now()}if(!(z&&0<=z&&z<60000)){let H=Y.maxRetries??this.maxRetries;z=this.calculateDefaultRetryTimeoutMillis(Z,H)}return await n1(z),this.makeRequest(Y,Z-1,Q)}calculateDefaultRetryTimeoutMillis(Y,Z){let z=Z-Y,K=Math.min(0.5*Math.pow(2,z),8),X=1-Math.random()*0.25;return K*X*1000}async buildRequest(Y,{retryCount:Z=0}={}){let Q={...Y},{method:J,path:z,query:K,defaultBaseURL:X}=Q,H=this.buildURL(z,K,X);if("timeout"in Q)RB("timeout",Q.timeout);Q.timeout=Q.timeout??this.timeout;let{bodyHeaders:W,body:q}=this.buildBody({options:Q}),G=await this.buildHeaders({options:Y,method:J,bodyHeaders:W,retryCount:Z});return{req:{method:J,headers:G,...Q.signal&&{signal:Q.signal},...globalThis.ReadableStream&&q instanceof globalThis.ReadableStream&&{duplex:"half"},...q&&{body:q},...this.fetchOptions??{},...Q.fetchOptions??{}},url:H,timeout:Q.timeout}}async buildHeaders({options:Y,method:Z,bodyHeaders:Q,retryCount:J}){let z={};if(this.idempotencyHeader&&Z!=="get"){if(!Y.idempotencyKey)Y.idempotencyKey=this.defaultIdempotencyKey();z[this.idempotencyHeader]=Y.idempotencyKey}let K=y([z,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(J),...Y.timeout?{"X-Stainless-Timeout":String(Math.trunc(Y.timeout/1000))}:{},...LB(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(Y),this._options.defaultHeaders,Q,Y.headers]);return this.validateHeaders(K),K.values}buildBody({options:{body:Y,headers:Z}}){if(!Y)return{bodyHeaders:void 0,body:void 0};let Q=y([Z]);if(ArrayBuffer.isView(Y)||Y instanceof ArrayBuffer||Y instanceof DataView||typeof Y==="string"&&Q.values.has("content-type")||globalThis.Blob&&Y instanceof globalThis.Blob||Y instanceof FormData||Y instanceof URLSearchParams||globalThis.ReadableStream&&Y instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:Y};else if(typeof Y==="object"&&((Symbol.asyncIterator in Y)||(Symbol.iterator in Y)&&("next"in Y)&&typeof Y.next==="function"))return{bodyHeaders:void 0,body:u7(Y)};else return T(this,L5,"f").call(this,{body:Y,headers:Q})}}var Az,kz,L5,xV;var w5=O(()=>{I1();$6();m9();vB();l1();_0();KJ();EV();o7();AJ();pJ();oJ();eJ();Gz();Uz();$z();Iz();Cz();CJ();dJ();wJ();nJ();aJ();tJ();Hz();qz();Fz();Nz();Lz();Tz();m9();w0();dZ();$6();kz=Y0,L5=new WeakMap,Az=new WeakSet,xV=function Y(){return this.baseURL!=="https://api.openai.com/v1"};Y0.OpenAI=kz;Y0.DEFAULT_TIMEOUT=600000;Y0.OpenAIError=p;Y0.APIError=y0;Y0.APIConnectionError=DY;Y0.APIConnectionTimeoutError=NY;Y0.APIUserAbortError=g0;Y0.NotFoundError=PZ;Y0.ConflictError=vZ;Y0.RateLimitError=fZ;Y0.BadRequestError=EZ;Y0.AuthenticationError=xZ;Y0.InternalServerError=bZ;Y0.PermissionDeniedError=SZ;Y0.UnprocessableEntityError=yZ;Y0.InvalidWebhookSignatureError=U6;Y0.toFile=Y5;Y0.Completions=C4;Y0.Chat=jY;Y0.Embeddings=k4;Y0.Files=x4;Y0.Images=y4;Y0.Audio=O6;Y0.Moderations=b4;Y0.Models=f4;Y0.FineTuning=r1;Y0.Graders=vY;Y0.VectorStores=l6;Y0.Webhooks=u4;Y0.Beta=s1;Y0.Batches=j4;Y0.Uploads=yY;Y0.Responses=c6;Y0.Realtime=d6;Y0.Conversations=SY;Y0.Evals=PY;Y0.Containers=xY;Y0.Videos=g4});var SV=O(()=>{w0();v1();B8();w5()});var PV=O(()=>{w5();KJ();o7();w5();_0();l1();SV()});class j5{client;defaultModel;constructor(Y,Z,Q="gpt-5-nano",J){this.client=new Y0({apiKey:Y,baseURL:Z,defaultHeaders:J}),this.defaultModel=Q}async generate(Y){return(await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,reasoning_effort:Y.reasoning})).choices[0].message.content||""}async*streamGenerate(Y){try{let Z=await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,stream:!0,reasoning_effort:Y.reasoning});for await(let Q of Z){let J=Q.choices[0]?.delta,z=J?.content,K=J?.reasoning_content||J?.reasoning||J?.reasoning_details?.[0]?.summary;if(z||K)yield{chunk:z??void 0,thinkingChunk:K??void 0,metadata:{model:Q.model,finishReason:Q.choices[0]?.finish_reason??void 0}}}}catch(Z){yield{error:OK(Z)?Z:new a(String(Z),"OPENAI_STREAM_ERROR")}}}}var vV=O(()=>{PV();H0()});var yV=()=>{};async function S8(){let Y=await O0(),Z=Y.get("llm.provider")||"openai",Q=await Y.getSecure("llm.apiKey"),J=Y.get("llm.model");if(!Q)throw new a("No API key found. Please set llm.apiKey in ~/.gdx/.gdxrc.toml or GDX_LLM_API_KEY env var.","NO_API_KEY");if(Q.startsWith("sk-or-"))Z="openrouter";switch(Z.toLowerCase()){case"openrouter":return new j5(Q,bK,J,{"HTTP-Referer":"https://github.com/Type-Delta/gdx/tree/main","X-Title":"GDX"});case"openai":return new j5(Q,void 0,J);default:throw new a(`Unsupported LLM provider: ${Z}`,"UNSUPPORTED_LLM_PROVIDER")}}var Ez=O(()=>{H0();W0();w1();vV();yV()});function fV(Y,Z){var Q=Object.keys(Y);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(Y);Z&&(J=J.filter(function(z){return Object.getOwnPropertyDescriptor(Y,z).enumerable})),Q.push.apply(Q,J)}return Q}function bV(Y){for(var Z=1;Z<arguments.length;Z++){var Q=arguments[Z]!=null?arguments[Z]:{};Z%2?fV(Object(Q),!0).forEach(function(J){TI(Y,J,Q[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(Q)):fV(Object(Q)).forEach(function(J){Object.defineProperty(Y,J,Object.getOwnPropertyDescriptor(Q,J))})}return Y}function TI(Y,Z,Q){if(Z=II(Z),Z in Y)Object.defineProperty(Y,Z,{value:Q,enumerable:!0,configurable:!0,writable:!0});else Y[Z]=Q;return Y}function II(Y){var Z=CI(Y,"string");return typeof Z==="symbol"?Z:String(Z)}function CI(Y,Z){if(typeof Y!=="object"||Y===null)return Y;var Q=Y[Symbol.toPrimitive];if(Q!==void 0){var J=Q.call(Y,Z||"default");if(typeof J!=="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return(Z==="string"?String:Number)(Y)}function hV(Y){return Z.withOptions=(Q)=>hV(bV(bV({},Y),Q)),Z;function Z(Q,...J){let z=typeof Q==="string"?[Q]:Q.raw,{alignValues:K=!1,escapeSpecialCharacters:X=Array.isArray(Q),trimWhitespace:H=!0}=Y,W="";for(let $=0;$<z.length;$++){let B=z[$];if(X)B=B.replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(W+=B,$<J.length){let V=K?kI(J[$],W):J[$];W+=V}}let q=W.split(`
|
|
476
|
+
`),G=null;for(let $ of q){let B=$.match(/^(\s+)\S+/);if(B){let V=B[1].length;if(!G)G=V;else G=Math.min(G,V)}}if(G!==null){let $=G;W=q.map((B)=>B[0]===" "||B[0]==="\t"?B.slice($):B).join(`
|
|
477
|
+
`)}if(H)W=W.trim();if(X)W=W.replace(/\\n/g,`
|
|
478
|
+
`);return W}}function kI(Y,Z){if(typeof Y!=="string"||!Y.includes(`
|
|
480
479
|
`))return Y;let J=Z.slice(Z.lastIndexOf(`
|
|
481
480
|
`)+1).match(/^(\s+)/);if(J){let z=J[1];return Y.replace(/\n/g,`
|
|
482
|
-
${z}`)}return Y}var
|
|
481
|
+
${z}`)}return Y}var AI,fY;var xz=O(()=>{AI=hV({}),fY=AI});function Sz(Y){return fY`<instructions>You are an expert Git commit message generator. Analyze the provided git diff in the following messages and generate a concise and informative commit message following the specified format and rules. Focus on clarity and relevance to help maintain a well-documented project history. Output ONLY the commit message.</instructions>
|
|
483
482
|
|
|
484
483
|
<rules>
|
|
485
484
|
Commit message must be in the following format:
|
|
@@ -510,7 +509,7 @@ ${z}`)}return Y}var Gj,w1;var eJ=R(()=>{Gj=sB({}),w1=Gj});function Yz(Y){return
|
|
|
510
509
|
${Y}
|
|
511
510
|
</git-diff>
|
|
512
511
|
|
|
513
|
-
Your commit message:`}function
|
|
512
|
+
Your commit message:`}function gV(Y,Z){return fY`<instructions>You are an expert Git commit message generator. Analyze the provided git diff and generate a commit message that follows the project-specific conventions documented below. Focus on clarity and consistency with the existing commit history. Output ONLY the commit message.</instructions>
|
|
514
513
|
|
|
515
514
|
<project-commit-guidelines>
|
|
516
515
|
${Z}
|
|
@@ -528,12 +527,12 @@ ${z}`)}return Y}var Gj,w1;var eJ=R(()=>{Gj=sB({}),w1=Gj});function Yz(Y){return
|
|
|
528
527
|
${Y}
|
|
529
528
|
</git-diff>
|
|
530
529
|
|
|
531
|
-
Your commit message:`}function
|
|
530
|
+
Your commit message:`}function mV(Y){let Z=Y.map((Q,J)=>`Example ${J+1}:
|
|
532
531
|
${Q}`).join(`
|
|
533
532
|
|
|
534
533
|
---
|
|
535
534
|
|
|
536
|
-
`);return
|
|
535
|
+
`);return fY`<instructions>You are analyzing a Git repository's commit message history to identify and document the commit message conventions used by this project. Study the provided examples and extract the underlying patterns, structure, and style rules.</instructions>
|
|
537
536
|
|
|
538
537
|
<commit-message-examples>
|
|
539
538
|
${Z}
|
|
@@ -554,7 +553,7 @@ ${Q}`).join(`
|
|
|
554
553
|
- Output ONLY the guideline document, no preamble
|
|
555
554
|
</task>
|
|
556
555
|
|
|
557
|
-
Commit Message Guideline:`}function
|
|
556
|
+
Commit Message Guideline:`}function uV(Y){return fY`<instruction>
|
|
558
557
|
You are an unfiltered Gen-Z dev who speaks like a terminal meme lord.
|
|
559
558
|
You talk in chaotic, funny, exaggerated internet slang. You sprinkle emojis,
|
|
560
559
|
caps, sarcasm, and over-the-top reactions. Never boring.
|
|
@@ -572,168 +571,209 @@ ${Q}`).join(`
|
|
|
572
571
|
${Y}
|
|
573
572
|
</commit>
|
|
574
573
|
|
|
575
|
-
Your unhinged reaction:`}var
|
|
576
|
-
`);for(let G of z)j(`${
|
|
577
|
-
${
|
|
578
|
-
`);let
|
|
574
|
+
Your unhinged reaction:`}var Pz=O(()=>{xz()});async function vz(Y){let{git$:Z}=Y;try{let Q=await P6(Z,"user.email"),J=(await S`${Z} log -1 --pretty=format:%s\n\n%b --author=${Q} --no-merges`.catch(k1))?.stdout.trim();if(!J||J.length===0)return R.error("Bro, you haven't committed anything yet. \uD83E\uDD23","nocap"),1;let z=J.split(`
|
|
575
|
+
`);for(let G of z)j(`${U("Dim")}▐ ${U()}${G}`);j(`
|
|
576
|
+
${U("Cyan")}${U("Dim")}Reviewing your commit message...${U()}
|
|
577
|
+
`);let K=await S8(),X=d0({message:"cooking up a roast...",animateGradient:!0,gradientColor:k.Teal300,gradientColorBg:k.Fuchsia400}),H=K.streamGenerate({prompt:uV(J),temperature:0.8,maxTokens:269,reasoning:"low"}),W="",q=!1;for await(let G of H){if(G.error)return X.stop(),R.error(`\uD83D\uDE2D ill bro, the server rejected u
|
|
579
578
|
|
|
580
|
-
${
|
|
581
|
-
`),!
|
|
582
|
-
${Y+
|
|
579
|
+
${g(G.error,{color:!0})}`,"nocap"),1;if(G.chunk){if(!q)q=!0,X.stop();j(G.chunk,""),W+=G.chunk}}if(j(`
|
|
580
|
+
`),!W)return R.error("Unable to generate response (empty response).","nocap"),1;return 0}catch(Q){return R.error(g(Q,{color:!0}),"nocap"),1}}var dV,pV;var T5=O(()=>{H0();h0();L0();Ez();D0();Pz();W0();v0();A0();K1();dV={long:()=>{let Y=U("Bright"),Z=U();return o(`
|
|
581
|
+
${Y+d("NOCAP",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
583
582
|
Generate a playful roast for your latest commit message.
|
|
584
583
|
|
|
585
|
-
${Y+
|
|
584
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
586
585
|
Reads the latest commit message authored by the configured git user and asks the configured LLM provider to produce a humorous "roast" or light-hearted commentary. Output is streamed to the terminal with progress spinners and incremental printing as the LLM responds.
|
|
587
586
|
|
|
588
|
-
${Y+
|
|
587
|
+
${Y+d("WHEN TO USE",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
589
588
|
Use when you want a quick, entertaining summary/critique of your most recent commit message before pushing, or as a lighthearted CI/gaming aid.
|
|
590
589
|
|
|
591
|
-
${Y+
|
|
590
|
+
${Y+d("NOTES",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
592
591
|
The command requires a valid git user.email in repo config and a configured LLM adapter. Network or LLM errors will print a colored error and return a non-zero exit code.
|
|
593
|
-
`,Math.min(100,
|
|
592
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Create a humorous critique of your latest commit message.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
594
593
|
${Y}${C} nocap${Q}
|
|
595
594
|
|
|
596
595
|
Examples:
|
|
597
|
-
${Y}${C} nocap ${Q+Z}# Roast the latest commit by the configured git user${Q}`,Math.min(100,
|
|
598
|
-
|
|
599
|
-
|
|
596
|
+
${Y}${C} nocap ${Q+Z}# Roast the latest commit by the configured git user${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},pV={$root:[]}});function cV(Y){let Z={},Q=Array.from(new Set(Y));for(let J of Q){if(!J)continue;Z[J]={}}return Z}function I5(Y,Z,Q="$allOf"){let J={},z=Array.from(new Set(Y));for(let K of z){if(!K)continue;J[K]={[Q]:Z}}return J}function M6(){if(P8!==null)return P8;return P8=process.stdout.rows||24,P8}function d4(){if(v8!==null)return v8;return v8=process.stdout.columns||80,v8}function yz(){P8=null,v8=null}class lV{lines=[];wrappedLines=[];options;lastWidth=0;lastHeight=0;redundancyLv=0;constructor(Y,Z={}){this.options={...C5,...Z},this.redundancyLv=Z.redundancyLv??m8(Y),this.lines=Y.split(`
|
|
597
|
+
`),this.lastWidth=d4(),this.lastHeight=M6(),this.updateWrappedLines()}updateWrappedLines(){let Y=this.lastWidth,Z=this.options.showLineNumbers?Y-this.options.lineNumberWidth-1:Y;this.wrappedLines=[];for(let Q=0;Q<this.lines.length;Q++){let J=this.lines[Q];if(this.options.wrapLines&&D6(J,this.redundancyLv)>Z)o(J,Z,{mode:"softboundary",redundancyLv:Math.max(0,this.redundancyLv)}).split(`
|
|
598
|
+
`).forEach((X,H)=>{if(this.options.showLineNumbers&&H===0)this.wrappedLines.push(this.formatLineNumber(Q+1)+X);else if(this.options.showLineNumbers)this.wrappedLines.push(" ".repeat(this.options.lineNumberWidth+1)+X);else this.wrappedLines.push(X)});else if(this.options.showLineNumbers)this.wrappedLines.push(this.formatLineNumber(Q+1)+J);else this.wrappedLines.push(J)}}formatLineNumber(Y){return String(Y).padStart(this.options.lineNumberWidth)+" "}getLineCount(){return this.wrappedLines.length}getLine(Y){return this.wrappedLines[Y]||""}render(Y,Z,Q){let J=[],z=D1(this.options.backgroundColor),K=U();for(let X=0;X<Z-1;X++){let H=Y+X;if(H<this.wrappedLines.length){let W=this.wrappedLines[H],q=lY(W),G=Math.max(0,Q-D6(q,this.redundancyLv));J.push(`${z}${W}${" ".repeat(G)}${K}`)}else J.push(`${z}${" ".repeat(Q)}${K}`)}return J}onResize(Y,Z){if(Y!==this.lastWidth||Z!==this.lastHeight)this.lastWidth=Y,this.lastHeight=Z,this.updateWrappedLines()}}async function nV(Y,Z={}){let Q=new lV(Y,Z);return fz(Q,Z)}async function fz(Y,Z={}){let Q={...C5,...Z},J=Q.redundancyLv??0;if(!process.stdout.isTTY||!process.stdin.isTTY){for(let M=0;M<Y.getLineCount();M++)process.stdout.write(Y.getLine(M)+`
|
|
599
|
+
`);return}process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf-8");let z=0,K=Y.getLineCount(),X=!0,H=null,W=[];process.stdout.write("\x1B[?25l"),process.stdout.write("\x1B[2J\x1B[H");function q(){let M=performance.now(),L=M6(),N=d4(),_=Y.render(z,L,N);process.stdout.write("\x1B[H");for(let I of _)process.stdout.write("\x1B[K"+I+`
|
|
600
|
+
`);if(Q.showStatus){let I=Q.statusFormat(z+1,K,N,{statusText:Q.statusText,actions:Q.actions,redundancyLv:J}),w=Math.max(0,N-D6(lY(I),J)),A=D1(Q.backgroundColor),x=f0(Q0.overlay0);process.stdout.write("\x1B[K"+A+x+I+" ".repeat(w)+U())}if(W.length>30)W.shift();W.push(performance.now()-M)}function G(){process.stdout.write("\x1B[?25h");let L=M6()-1;process.stdout.write(`\x1B[${L}B`),process.stdin.setRawMode(!1),process.stdin.pause(),R.debug(`Pager performance: ${W.length>0?u8(W.reduce((N,_)=>N+_,0)/W.length,4):"N/A"}ms average over ${W.length} renders`,"pager")}function $(){yz();let M=d4(),L=M6();if(Y.onResize)Y.onResize(M,L);q()}let B=()=>$();process.stdout.on("resize",B);function V(M){let N=M6()-1,_=Math.max(0,Y.getLineCount()-N),I=Q.actions||[];if(I.length>0){for(let w of I)if((Array.isArray(w.key)?w.key:[w.key]).includes(M)){H={action:w.action,key:M},X=!1;return}}switch(M){case"q":case"\x03":case"\x1B":if(I.length>0&&!H)H={action:"abort",key:M};X=!1;break;case"\x1B[A":case"\x1B[A":case"k":z=Math.max(0,z-Q.scrollSensitivity);break;case"\x1B[B":case"\x1B[B":case"j":z=Math.min(_,z+Q.scrollSensitivity);break;case"\x1B[5~":case"b":{let w=N-1;z=Math.max(0,z-w);break}case"\x1B[6~":case"n":case" ":{let w=N-1;z=Math.min(_,z+w);break}case"g":case"\x1B[1~":case"\x1B[H":z=0;break;case"G":case"\x1B[4~":case"\x1B[F":z=_;break}if(X)q()}let F=(M)=>{if(V(M.toString()),!X)process.stdin.off("data",F),process.stdout.off("resize",B),G()};return process.stdin.on("data",F),q(),new Promise((M)=>{let L=setInterval(()=>{if(!X)clearInterval(L),M(H||void 0)},50)})}var C5,P8=null,v8=null;var iV=O(()=>{H0();D0();A0();W0();C5={showLineNumbers:!1,lineNumberWidth:4,wrapLines:!0,showStatus:!0,statusFormat:(Y,Z,Q,J)=>{let z=U("Bright"),K=U("Normal"),X=U("Dim"),H=Math.min(Y+M6()-2,Z),W=typeof J?.statusText==="function"?J.statusText():J?.statusText,q=J?.actions?J.actions.map((V)=>{let M=(Array.isArray(V.key)?V.key:[V.key])[0]??"";if(!M)return"";return`${z}${M}${K} ${V.label}`}).filter(Boolean).join(`${X},${K} `):"",G=q?`${z}↑ ↓ b n${K} navigate, ${z}q${K} quit`:`${z}↑ ↓ b n Home End${K} to navigate, ${z}q${K} quit`,$=q?`ln ${z}${Y}${K} of ${z}${Z}${Y===Z?U("Red")+" EOF"+U("White"):""}`:`lines ${z}${Y}-${H}${K} of ${z}${Z}${H===Z?U("Red")+" (EOF)"+U("White"):""}`,B=[W,G,q].filter(Boolean);return" "+Y6([B.join(" "),$],Q-4,{align:"spacebetween",filler:" ",overflow:"collapse",collapseLocation:"mid",redundancyLv:J?.redundancyLv??0})+" "},backgroundColor:Q0.base,scrollSensitivity:3,statusText:"",actions:[]}});async function xI(){return oV??=import("@shikijs/cli"),await oV}function A5(){return process.stdout.isTTY===!0&&process.stdin.isTTY===!0&&l0.supportsColor>=3}function SI(Y){let Z=Y.split(".").pop()?.toLowerCase()||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",json:"json",md:"markdown",css:"css",scss:"scss",html:"html",vue:"vue",svelte:"svelte",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",sh:"bash",bash:"bash",zsh:"bash",yml:"yaml",yaml:"yaml",toml:"toml",xml:"xml",sql:"sql",dockerfile:"dockerfile",docker:"dockerfile",makefile:"makefile",cmake:"cmake",lua:"lua",perl:"perl",php:"php"}[Z]||"text"}function k5(Y){let Z=[],Q=Y.split(`
|
|
601
|
+
`),J=null,z=0,K=0,X=!1,H=2;for(let W of Q){if(sV.test(W)){if(J)Z.push(J);let q=fI(W);if(q)J={fileName:q.fileName,oldFileName:q.oldFileName,newFileName:q.newFileName,lang:SI(q.fileName),lines:[]},X=q.isCombined,H=2;else J=null,X=!1,H=2;continue}if(!J)continue;if(W.startsWith("--- ")||W.startsWith("+++ ")){J.lines.push({type:"header",content:W});continue}if(W.startsWith("@@@ ")){let q=W.match(/@@@ -(\d+)(?:,\d+)?/),G=W.match(/\+(\d+)(?:,\d+)? @@@/);if(q)z=parseInt(q[1],10);if(G)K=parseInt(G[1],10);J.lines.push({type:"hunk",content:W}),X=!0;let $=W.match(/-\d+(?:,\d+)?/g);H=Math.max($?.length??2,2);continue}if(W.startsWith("@@ ")){let q=W.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(q)z=parseInt(q[1],10),K=parseInt(q[2],10);J.lines.push({type:"hunk",content:W});continue}if(X){if(W.length>=H){let q=W.slice(0,H);if(/^[ +-]+$/.test(q)){let G=W.slice(H),$=q.includes("+"),B=q.includes("-"),V=$?"add":B?"delete":"context",F={type:V,content:G};if(V==="add")F.newLineNum=K++;else if(V==="delete")F.oldLineNum=z++;else F.oldLineNum=z++,F.newLineNum=K++;J.lines.push(F);continue}}}if(W[0]==="+"){J.lines.push({type:"add",content:W.substring(1),newLineNum:K++});continue}if(W[0]==="-"){J.lines.push({type:"delete",content:W.substring(1),oldLineNum:z++});continue}if(W[0]===" "||W===""){J.lines.push({type:"context",content:W[0]===" "?W.substring(1):"",oldLineNum:z++,newLineNum:K++});continue}if(W.match(/^(new file|deleted file|index|Binary|similarity|rename|old mode|new mode)/))J.lines.push({type:"header",content:W})}if(J)Z.push(J);return Z}async function PI(Y,Z,Q,J){let z=new Map;if(Z.size===0)return z;try{let K=J?`${J}/${Y}`:Y,H=(await S0(K,"utf-8")).split(`
|
|
602
|
+
`),W=Math.max(0,Math.min(...Z)-Q),q=Math.min(H.length-1,Math.max(...Z)+Q);for(let G=W;G<=q;G++)z.set(G+1,H[G])}catch{}return z}async function vI(Y,Z,Q){let J=new Map,z=Y.lines.filter((H)=>H.type==="add"||H.type==="delete"||H.type==="context");if(z.length===0)return J;let K=z.filter((H)=>H.type!=="delete"),X=z.filter((H)=>H.type==="delete");try{let H=await xI();if(K.length>0){let W=new Set;K.forEach(($)=>{if($.newLineNum!==void 0)W.add($.newLineNum)});let q=await PI(Y.newFileName,W,20,Q),G=yI(K,q);if(R.debug(`Highlighting diff for ${Y.newFileName} with ${z.length} changed lines and ${q.size} lines of context from FS`,"diff-viewer"),q.size>0&&G){let $=Math.min(...q.keys()),B=Math.max(...q.keys()),V=[];for(let L=$;L<=B;L++)V.push(q.get(L)||"");let M=(await H.codeToANSI(V.join(`
|
|
603
|
+
`),Y.lang,Z)).split(`
|
|
604
|
+
`);for(let L of K){let N=L.newLineNum;if(N!==void 0){let _=N-$;if(_>=0&&_<M.length)J.set(L,M[_])}}}else{R.debug(`No additional context from FS for ${Y.newFileName}, using what we have from git`,"diff-viewer");let $=K.map((F)=>F.content).join(`
|
|
605
|
+
`),V=(await H.codeToANSI($,Y.lang,Z)).split(`
|
|
606
|
+
`);for(let F=0;F<K.length;F++)if(V[F])J.set(K[F],V[F])}}if(X.length>0){let W=X.map(($)=>$.content).join(`
|
|
607
|
+
`),G=(await H.codeToANSI(W,Y.lang,Z)).split(`
|
|
608
|
+
`);for(let $=0;$<X.length;$++)if(G[$])J.set(X[$],G[$])}}catch(H){R.error(`Error highlighting diff for ${Y.newFileName}: ${a.from(H)}`,"diff-viewer"),z.forEach((W)=>J.set(W,W.content))}return J}function yI(Y,Z){if(Z.size===0)return!1;let Q=0;for(let J of Y){if(J.newLineNum===void 0)continue;let z=Z.get(J.newLineNum);if(z===void 0||z!==J.content)return!1;Q++}return Q>0}class rV{parsedDiffs=[];renderedLines=[];options;lastWidth=0;lastHeight=0;redundancyLv=0;widthRedundancyLv=0;logger=new R("diff-renderer");ADDED_BG=J6(Q0.base,Q0.green,0.15);DELETED_BG=J6(Q0.base,Q0.red,0.15);ADDED_GUTTER_BG=J6(Q0.base,Q0.green,0.25);DELETED_GUTTER_BG=J6(Q0.base,Q0.red,0.25);constructor(Y,Z={}){this.options={...C5,showLineNumbers:!0,theme:PK,lineNumberWidth:5,wrapLines:!0,showStatus:!0,preambleLines:[],...Z},this.logger.debug("Initializing DiffViewerRenderer with options: "+g(this.options)),this.lastWidth=d4(),this.lastHeight=M6(),this.redundancyLv=Z.redundancyLv??m8(Y),this.widthRedundancyLv=Math.max(0,this.redundancyLv),this.logger.debug(`Terminal size: ${this.lastWidth}x${this.lastHeight}, redundancy level: ${this.redundancyLv}`),this.parsedDiffs=this.logger.time("Parsing diff output",()=>k5(Y)),this.updateRenderedLines()}async prepareHighlighting(){for(let Y of this.parsedDiffs){let Z=Y.lines.filter((J)=>J.type==="add"||J.type==="delete"||J.type==="context");if(Z.length===0)continue;let Q=await vI(Y,this.options.theme,this.options.workingDir);Z.forEach((J)=>{let z=Q.get(J);if(z!==void 0)J.highlightedContent=z})}this.updateRenderedLines()}renderLine(Y,Z,Q){let J=[],z=this.options.lineNumberWidth,K=Z-z-4,X=" ",H=Q,W=Q,q=Q0.overlay0;switch(Y.type){case"add":X="+",H=this.ADDED_BG,W=this.ADDED_GUTTER_BG,q=Q0.green;break;case"delete":X="-",H=this.DELETED_BG,W=this.DELETED_GUTTER_BG,q=Q0.red;break;case"context":H=Q0.base;break;case"hunk":return J.push(this.renderHunkHeader(Y.content,Z)),J;case"header":return J.push(this.renderFileHeader(Y.content,Z)),J;default:return J}let G=Y.highlightedContent||Y.content,$=Y.newLineNum??Y.oldLineNum,B=$!==void 0?String($).padStart(z):" ".repeat(z),V=`${f0(Q0.overlay1)}${B} ${f0(q)}${X} `;if(this.options.wrapLines&&D6(G,this.widthRedundancyLv)>K){let M=o(G,K,{mode:"softboundary",redundancyLv:this.widthRedundancyLv}).split(`
|
|
609
|
+
`);for(let L=0;L<M.length;L++){let N=L===0?V:" ".repeat(z+3);J.push(this.padLineWithBg(N+D1(H)+M[L],Z,W))}}else J.push(this.padLineWithBg(V+D1(H)+G,Z,W));return J}padLineWithBg(Y,Z,Q){let J=Math.max(0,Z-D6(Y,this.widthRedundancyLv));return`${D1(Q)}${Y}${" ".repeat(J)}${U()}`}renderHunkHeader(Y,Z){let Q=J6(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ↕ ${f0(Q0.cyan)}${aV.italic(Y)}`,Z,Q)}renderFileHeader(Y,Z){let Q=J6(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ${f0(Q0.overlay1)}${Y}`,Z,Q)}renderFileName(Y,Z,Q){let J=J6(Q0.crust,Q0.surface0,0.3);if(Y===Z)return this.padLineWithBg(` ${f0(Q0.lavender)}${aV.bold(Z)}`,Q,J);return this.padLineWithBg(` ${f0(Q0.yellow)}${Y} -> ${Z}`,Q,J)}renderPreambleLine(Y,Z,Q,J){if(!Y)return[this.padLineWithBg(" ",Z,Q)];Y=" ".repeat(J)+Y;let z=Z,K=f0(Q0.overlay1);if(this.options.wrapLines&&D6(Y,this.widthRedundancyLv)>z)return o(Y,z,{mode:"softboundary",indent:J,redundancyLv:this.widthRedundancyLv}).split(`
|
|
610
|
+
`).map((H)=>this.padLineWithBg(K+H,Z,Q));return[this.padLineWithBg(K+Y,Z,Q)]}updateRenderedLines(){this.renderedLines=[];let Y=this.lastWidth,Z=J6(Q0.mantle,Q0.surface0,0.2);if(this.options.preambleLines.length>0){for(let Q of this.options.preambleLines)this.renderedLines.push(...this.renderPreambleLine(Q,Y,Z,3));if(this.parsedDiffs.length>0)this.renderedLines.push(this.padLineWithBg(" ",Y,Z))}for(let Q=0;Q<this.parsedDiffs.length;Q++){let J=this.parsedDiffs[Q],z=Z;if(Q!==0)this.renderedLines.push(this.padLineWithBg(" ",Y,z),this.padLineWithBg(" "+f0(Q0.surface0)+"─".repeat(Y-12),Y,z),this.padLineWithBg(" ",Y,z));this.renderedLines.push(this.renderFileName(J.oldFileName,J.newFileName,Y));for(let K of J.lines)this.renderedLines.push(...this.renderLine(K,Y,z))}}getLineCount(){return this.renderedLines.length}getLine(Y){return this.renderedLines[Y]||""}render(Y,Z,Q){let J=[],z=D1(this.options.backgroundColor);for(let K=0;K<Z-1;K++){let X=Y+K;J.push(X<this.renderedLines.length?this.renderedLines[X]:`${z}${" ".repeat(Q)}${U()}`)}return J}onResize(Y,Z){if(Y!==this.lastWidth||Z!==this.lastHeight)this.lastWidth=Y,this.lastHeight=Z,this.updateRenderedLines()}}async function y8(Y,Z={}){if(!A5())return R.warn("Diff viewer is not supported in this environment. Falling back to plain output.","diff-viewer"),nV(Y,{...Z,showLineNumbers:!1});let Q=Y.length>1e4?d0({message:"Preparing diff viewer...",interval:10}):void 0,{body:J,preamble:z}=bI(Y);R.time("Preparing diff highlighting");let K=new rV(J,{...Z,preambleLines:z});return await K.prepareHighlighting(),yz(),K.onResize(d4(),M6()),Q?.stop(),R.timeEnd("Preparing diff highlighting","diff-viewer"),fz(K,Z)}function tV(Y){return EI.test(Y)}function fI(Y){if(Y.startsWith("diff --git ")){let Q=Y.match(/diff --git a\/(.+?) b\/(.+)/);if(!Q)return null;return{fileName:Q[2],oldFileName:Q[1],newFileName:Q[2],isCombined:!1}}let Z=Y.match(/^diff --(?:cc|combined) (.+)$/);if(!Z)return null;return{fileName:Z[1],oldFileName:Z[1],newFileName:Z[1],isCombined:!0}}function bI(Y){let Z=Y.split(`
|
|
611
|
+
`),Q=Z.findIndex((J)=>sV.test(J));if(Q===-1)return{body:Y,preamble:[]};return{body:Z.slice(Q).join(`
|
|
612
|
+
`),preamble:Z.slice(0,Q)}}var aV,sV,EI,oV=null;var bz=O(()=>{H0();H0();o0();iV();A0();D0();h0();W0();aV={bold:(Y)=>`\x1B[1m${Y}\x1B[22m`,italic:(Y)=>`\x1B[3m${Y}\x1B[23m`,underline:(Y)=>`\x1B[4m${Y}\x1B[24m`,dim:(Y)=>`\x1B[2m${Y}\x1B[22m`},sV=/^diff --(git|cc|combined)\b/,EI=/^diff --(git|cc|combined)\b/m});import c0 from"path";async function YF(Y){let Z=[],Q=!1;try{let z=(await O0()).get("parallel.init","submodule,env"),K=eV(z);if(K.invalid.length>0)Z.push(`Unknown parallel.init values: ${K.invalid.join(", ")}. Valid values: submodule, env, pkg.`);let X=eV(Y.noInitList);if(X.invalid.length>0)Z.push(`Unknown --no-init values: ${X.invalid.join(", ")}. Valid values: submodule, env, pkg.`);if(Y.noInitAll||Y.noInitList==="")Q=!0;let H=new Set(X.values),W=K.values.filter((q)=>!H.has(q));if(W.length===0)Q=!0;if(!Q&&W.includes("submodule")){let q=d0({message:"Initializing git submodules..."});try{await n$(Y.git$,Y.worktreePath),q.stop()}catch(G){q.stop(),Z.push(`Submodule init failed. ${g(G,{color:!0})}`)}}if(!Q&&W.includes("env")){let q=await uI(Y.worktreePath,Y.originPath,Z);Z.push(...q.warnings)}if(!Q&&W.includes("pkg")){let q=await mI(Y.worktreePath);Z.push(...q.warnings)}}catch(J){Z.push(`Init failed. ${g(J,{color:!0})}`)}gI(Z)}function gI(Y){for(let Z of Y)R.warn(Z,"worktree-init")}function eV(Y){let Z=[],Q=[],J=new Set,z=[];if(Array.isArray(Y))z=Y.map((K)=>String(K));else if(typeof Y==="string")z=Y.split(",");else if(Y!=null)z=[String(Y)];for(let K of z){let X=K.trim().toLowerCase();if(!X)continue;if(hI.has(X)){let H=X;if(!J.has(H))Z.push(H),J.add(H)}else Q.push(X)}return{values:Z,invalid:Q}}async function mI(Y){let Z=[],Q=!1,J=oI(Y,Z);if(J){let z=await tI(J,Y,Z);Q||=z}if(rI(Y)){let z=await eI(Y,Z);Q||=z}return{ran:Q,warnings:Z}}async function uI(Y,Z,Q){let J=[],z=0;try{let K=await O0(),X=Z||Y,{rootFiles:H,envPaths:W}=await dI(X,K,J);if(H.length===0&&W.length===0)return{copied:0,warnings:J};if(H.length>0){let q=H.map(($)=>aI($)),G=await pI(X,J);for(let $ of G){if(!$)continue;if(q.some((B)=>B($))){if(await ZF({sourceRoot:X,targetRoot:Y,relativePath:$,warnings:J}))z++}}}if(W.length>0)z+=await lI({sourceRoot:X,targetRoot:Y,patterns:W,warnings:J})}catch(K){J.push(`Env init failed. ${g(K,{color:!0})}`)}return Q.push(...J),{copied:z,warnings:J}}async function dI(Y,Z,Q){let J=new Set,z=new Set,K=c0.join(Y,".gitignore");if(l(K))try{let W=(await S0(K,"utf-8")).split(/\r?\n/);for(let q of W){let G=q.trim();if(!G||G.startsWith("#"))continue;if(G.startsWith("!"))continue;if(G.endsWith("/"))continue;let $=G.startsWith("/")?G.slice(1):G;if($.includes("/"))continue;J.add($)}}catch(H){Q.push(`Failed to read .gitignore. ${g(H,{color:!0})}`)}let X=Z.get("parallel.envPaths","");if(typeof X==="string"){let H=X.split(":").map((W)=>W.trim()).filter((W)=>W.length>0);for(let W of H)z.add(W)}return{rootFiles:Array.from(J),envPaths:Array.from(z)}}async function pI(Y,Z){try{return(await p8(Y,{withFileTypes:!0})).filter((J)=>J.isFile()).map((J)=>J.name)}catch(Q){return Z.push(`Failed to list root files. ${g(Q,{color:!0})}`),[]}}async function ZF(Y){let{sourceRoot:Z,targetRoot:Q,relativePath:J,warnings:z}=Y;if(c0.resolve(Z)===c0.resolve(Q))return!1;let K=E5(Z,J),X=E5(Q,J);if(!l(K))return!1;if(l(X))return!1;try{if(!(await e6(K)).isFile())return!1;await QQ(c0.dirname(X),{recursive:!0});let W=await S0(K);return await Y1(X,W),!0}catch(H){return z.push(`Failed to copy env file '${J}'. ${g(H,{color:!0})}`),!1}}async function cI(Y){let{sourceRoot:Z,targetRoot:Q,relativePath:J,warnings:z}=Y;if(c0.resolve(Z)===c0.resolve(Q))return!1;let K=E5(Z,J),X=E5(Q,J);if(!l(K))return!1;if(l(X))return!1;try{if(!(await e6(K)).isDirectory())return!1;return await QF(K,X,z),!0}catch(H){return z.push(`Failed to copy env directory '${J}'. ${g(H,{color:!0})}`),!1}}async function QF(Y,Z,Q){try{await QQ(Z,{recursive:!0});let J=await p8(Y,{withFileTypes:!0});for(let z of J){let K=c0.join(Y,z.name),X=c0.join(Z,z.name);if(z.isDirectory())await QF(K,X,Q);else if(z.isFile()){let H=await S0(K);await Y1(X,H)}}}catch(J){Q.push(`Failed to copy env directory. ${g(J,{color:!0})}`)}}async function lI(Y){let{sourceRoot:Z,targetRoot:Q,patterns:J,warnings:z}=Y;if(J.length===0)return 0;let K=J.map((W)=>iI(W)).filter((W)=>Boolean(W));if(K.length===0)return 0;let X=0,H=async(W,q)=>{let G=[];try{G=await p8(W,{withFileTypes:!0})}catch($){z.push(`Failed to read env paths. ${g($,{color:!0})}`);return}for(let $ of G){let B=q?`${q}/${$.name}`:$.name,V=K.some((F)=>F(B));if(V&&$.isDirectory()){if(await cI({sourceRoot:Z,targetRoot:Q,relativePath:B,warnings:z})){X++;continue}}if(V&&$.isFile()){if(await ZF({sourceRoot:Z,targetRoot:Q,relativePath:B,warnings:z}))X++}if($.isDirectory())await H(c0.join(W,$.name),B)}};return await H(Z,""),X}function nI(Y){let Z=n0(Y.trim());while(Z.startsWith("./"))Z=Z.slice(2);if(Z.startsWith("/"))Z=Z.slice(1);return Z=Z.replace(/\/+$/,""),Z}function iI(Y){let Z=nI(Y);if(!Z)return null;let Q="^",J=0;while(J<Z.length){let K=Z[J];if(K==="*"){if(Z[J+1]==="*"){if(Z[J+2]==="/"){Q+="(?:.*/)?",J+=3;continue}Q+=".*",J+=2;continue}Q+="[^/]*",J+=1;continue}if(K==="?"){Q+="[^/]",J+=1;continue}if(K==="/"){Q+="/",J+=1;continue}Q+=K.replace(/[.+^${}()|[\]\\]/g,"\\$&"),J+=1}Q+="$";let z=new RegExp(Q);return(K)=>z.test(n0(K))}function E5(Y,Z){let Q=Z.split("/").filter(Boolean);return c0.join(Y,...Q)}function aI(Y){let Z=Y.trim();if(!Z)return()=>!1;if(Z==="*")return()=>!0;let Q=Z.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\?/g,".").replace(/\*/g,"[^/]*"),J=new RegExp(`^${Q}$`);return(z)=>J.test(z)}function oI(Y,Z){let Q=c0.join(Y,"package.json"),J=l(Q),z=c0.join(Y,"bun.lockb"),K=c0.join(Y,"bun.lock"),X=c0.join(Y,"pnpm-lock.yaml"),H=c0.join(Y,"package-lock.json"),W=c0.join(Y,"npm-shrinkwrap.json"),q=null;if(J){let G=sI(Q,Z);if(G)q=G}if(!q){if(l(z)||l(K))q="bun";else if(l(X))q="pnpm";else if(J&&(l(H)||l(W)))q="npm";else if(J)q="npm"}return q}function sI(Y,Z){try{let Q=N6(Y,"utf-8"),z=JSON.parse(Q).packageManager?.split("@")[0]?.trim().toLowerCase();if(z==="npm"||z==="pnpm"||z==="bun")return z;if(z)Z.push(`Unsupported packageManager '${z}' in package.json. Supported: npm, pnpm, bun.`)}catch(Q){Z.push(`Failed to parse package.json: ${g(Q,{color:!0})}`)}return null}function rI(Y){let Z=c0.join(Y,"uv.lock"),Q=c0.join(Y,"pyproject.toml");return l(Z)||l(Q)}async function tI(Y,Z,Q){if(!await c1(Y))return Q.push(`Package manager '${Y}' not found in PATH. Skipping install.`),!1;let z=S({cwd:Z,stdout:"inherit",stderr:"inherit"});try{if(Y==="npm")await z`npm install`;else if(Y==="pnpm")await z`pnpm install`;else await z`bun install`;return!0}catch(K){return Q.push(`Package install failed for '${Y}'. ${g(K,{color:!0})}`),!1}}async function eI(Y,Z){if(!await c1("uv"))return Z.push("Package manager 'uv' not found in PATH. Skipping install."),!1;let J=S({cwd:Y,stdout:"inherit",stderr:"inherit"});try{return await J`uv sync`,!0}catch(z){return Z.push(`Package install failed for 'uv'. ${g(z,{color:!0})}`),!1}}var hI;var JF=O(()=>{H0();o0();h0();D0();w1();K1();hI=new Set(["submodule","pkg","env"])});import G0 from"path";async function v5(Y){let Z=await hY(Y);if(!Z)return[];if(!l(Z.parallelRoot))return[];let Q=b1(Z.parallelRoot,{withFileTypes:!0}),J=[];for(let z of Q){if(!z.isDirectory())continue;let K=G0.join(Z.parallelRoot,z.name),X=p4(K);if(!X)continue;let H=X.alias||z.name;J.push(H)}return J.sort((z,K)=>z.localeCompare(K))}function y5(Y){if(!Y||Y.trim()==="")return!1;if(/[/\\ ]/.test(Y))return!1;if(/[<>:"|?*\x00-\x1f]/.test(Y))return!1;return!0}function p4(Y){let Z=G0.join(Y,".git-parallel.json");try{let Q=N6(Z,"utf-8"),J=JSON.parse(Q);return R.debug(`Loaded parallel metadata from '${Z}': ${g(J)}`,"parallel"),J}catch{return null}}function i6(Y,Z){let Q=G0.join(Y,".git-parallel.json");r6(Q,JSON.stringify(Z,null,2),"utf-8")}async function hY(Y){let Q=`${Array.isArray(Y)?Y.join(" "):Y}|${G0.resolve(process.cwd())}`;if(bY&&bY.cacheKey===Q){if(Date.now()<=bY.expiresAt)return bY.context;bY=null}try{let J=await T1(Y),z=G0.basename(J),K=Array.isArray(Y)?Y[0]:Y,X;try{X=(await Q1(K,J,["--abbrev-ref","HEAD"])).trim()}catch{X="HEAD"}let H=G0.join(O1,"worktrees"),W=_K(H,J),q=z,G=X,$=null,B=J;if(W){let M=p4(J);if(M){if(M.project)z=M.project;if(M.branch)X=M.branch;if(M.originPath)B=G0.resolve(M.originPath);if(M.alias)$=M.alias}else $=G0.basename(J);q=M?.safeProject||q,G=M?.safeBranch||G}q=zQ(q),G=zQ(G);let V=G0.join(H,q,G),F={repoRoot:J,projectName:z,branchName:X,safeProjectName:q,safeBranchName:G,parallelRoot:V,originPath:B,alias:$,isParallelWorktree:W};return bY={cacheKey:Q,context:F,expiresAt:Date.now()+zF},F}catch(J){return R.error(g(J,{color:!0}),"parallel"),bY={cacheKey:Q,context:null,expiresAt:Date.now()+zF},null}}async function hz(Y,Z){let Q=await hY(Y);if(!Q)return 1;R.debug(`Removing worktree '${Z}'...`,"parallel");let J=G0.join(Q.parallelRoot,Z),z=Array.isArray(Y)?Y[0]:Y,K=d0({message:"Preparing worktree for removal..."});await x9(Y);let X=await S9(Y,J);if(!X&&!l(J))return K.stop(),R.error(`Worktree '${Z}' not found for branch '${Q.branchName}'.`,"parallel"),1;if(X?.locked){let G=X.lockReason?` (${X.lockReason})`:"";return K.stop(),R.error(`Worktree '${Z}' is locked ${G}. Unlock it before removing.`,"parallel"),1}if(!l(J)){if(R.debug(`Worktree path '${J}' is missing on disk. Attempting prune...`,"parallel"),await y7(Y),!await S9(Y,J))return K.stop(),j(`${U("Cyan")}Removed worktree metadata:${U()} ${Z}`),R.debug(`Worktree '${Z}' pruned successfully.`,"parallel"),0;return R.error(`Worktree '${Z}' is missing on disk and could not be pruned.`,"parallel"),1}try{wK(J,ZQ.F_OK|ZQ.W_OK)}catch{return K.stop(),R.error(`Worktree '${Z}' is not accessible or writable. Cannot remove.`,"parallel"),1}R.debug(`Worktree path '${J}' is accessible.`,"parallel");let H=await d$(Y,J);if(R.debug(`Active operations for worktree '${Z}': ${H.length>0?H.join(", "):"none"}`,"parallel"),H.length>0)return K.stop(),R.error(`Worktree '${Z}' has in-progress operations (${H.join(", ")}). Complete or abort them before removing.`,"parallel"),1;if((await S`${z} -C ${J} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0)return K.stop(),R.error(`Worktree '${Z}' has uncommitted changes. Join or clean it before removing.`,"parallel"),1;let q=await v6(Y,J);if(R.debug(`Submodules in worktree '${Z}': ${q.length>0?q.map((G)=>G.path).join(", "):"none"}`,"parallel"),q.length>0){let G=await c$(Y,J,q);if(G.length>0){let $=G.join(", ");return K.stop(),R.error(`Worktree '${Z}' has dirty submodules (${$}). Commit, stash, or clean them before removing.`,"parallel"),1}R.debug(`Deinitializing submodules for worktree '${Z}'...`,"parallel"),K.options.message="Deinitializing submodules...";try{R.debug(`Executing deinit for submodules with ${z} -C ${J}...`,"parallel"),await l$(Y,J)}catch($){if(K.stop(),(await S`${z} -C ${J} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length===0)await y7(Y);return R.error(`Failed to deinit submodules for '${Z}'.
|
|
613
|
+
${g($,{color:!0})}`,"parallel"),1}}K.options={...K.options,frames:["███","██▇","██▆","▇▅▆","▆▅▆","▃▅▅","▄▅▄","▃▃▁","▂▂▂","▁ ▁"," ","░ ","▓░ ","█▓░","██▓"],interval:120,message:`Removing worktree '${Z}'...`};try{R.debug(`Executing git worktree remove for '${Z}'...`,"parallel");let G=await S`${Y} worktree remove ${J}`;K.stop(),j(G.stdout.trim());try{R.debug(`Removing directory '${J}' (if exists)...`,"parallel"),t6(J,{recursive:!0,force:!0})}catch{R.warn(`Failed to remove directory '${J}', ignoring.`,"parallel")}return j(`${U("Cyan")}Removed worktree:${U()} ${Z}`),0}catch(G){if(K.stop(),R.debug(`Error removing worktree '${Z}': ${g(G,{color:!0})}`,"parallel"),(G instanceof _1?`${G.stderr||""} ${G.message||""}`:"").toLowerCase().includes("working trees containing submodules cannot be moved or removed"))return R.error(`Worktree '${Z}' contains submodules that must be deinitialized before removal.`,"parallel"),1;if(G instanceof _1&&G.exitCode===255)R.error(`Folder '${J}' is currently in use or GDX does not have permission to remove it. Please close any applications using it and force remove. (git already removed the connection to the origin worktree, retry may not work)`,"parallel");else R.error(`Failed to remove worktree '${Z}'.
|
|
614
|
+
${g(G,{color:!0})}`,"parallel");let B=await NZ("Do you want to force remove the worktree directory? (y/n): ");if(B.toLowerCase()==="y"||B.toLowerCase()==="yes")try{return t6(J,{recursive:!0,force:!0}),await y7(Y),j(`${U("Cyan")}Force removed worktree directory:${U()} ${Z}`),0}catch{return R.error(`Failed to force remove worktree directory '${Z}'.`,"parallel"),1}else return R.warn(`Aborted removing worktree '${Z}'.`,"parallel"),1}finally{K.stop()}}async function zC(Y,Z){let Q=await hY(Y);if(!Q)return 1;if(Q.isParallelWorktree)return R.error("Run `git parallel fork` from the original worktree, not from a fork.","parallel"),1;if(Q.branchName==="HEAD")return R.error("Detached HEAD detected. Switch to a branch before forking.","parallel"),1;if(Z.length<1)return R.error("Missing worktree alias.","parallel"),t0(),1;let J=Z[0];if(!y5(J))return R.error(`Alias '${J}' contains invalid characters or spaces.`,"parallel"),1;let z=Z.slice(1),K=!1,X=null,H=z.hasOption("-b"),W=z.hasOption("-B");if(H&&W)return R.error("Use either '-b' or '-B' to create a branch, not both.","parallel"),t0(),1;let q=null,G=null;if(H)q=z.popValue("-b"),G="-b";else if(W)q=z.popValue("-B"),G="-B";if((H||W)&&!q)return R.error("Missing branch name for '-b'/'-B'.","parallel"),t0(),1;if(z.hasOption("--no-init")){if(X=z.popValue("--no-init",0,!0),X===null)K=!0}let $=G0.join(Q.parallelRoot,J),B=z.includes("--move")||z.includes("-mv"),V=z.includes("--mirror")||z.includes("-mr"),F=z.filter((m)=>!["--move","--mirror","-mv","-mr"].includes(m)),M=F.filter((m)=>m.startsWith("-"));if(M.length>0)return R.error(`Unknown option '${M[0]}'.`,"parallel"),t0(),1;let L=F.filter((m)=>!m.startsWith("-"));if(L.length>1)return R.error("Too many refs provided. Specify a single ref after the alias.","parallel"),t0(),1;let N=L[0]||null;if(l($)&&b1($).length>0)return R.error(`Worktree alias '${J}' already exists for this branch.`,"parallel"),1;let _=G0.join(Q.repoRoot,".git","info","exclude");try{if(!N6(_,"utf-8").includes(".git-parallel.json"))jK(_,`
|
|
600
615
|
.git-parallel.json
|
|
601
|
-
`)}catch{
|
|
602
|
-
`)}
|
|
603
|
-
`),!
|
|
604
|
-
`)
|
|
605
|
-
`).
|
|
606
|
-
`)
|
|
616
|
+
`)}catch{r6(_,`.git-parallel.json
|
|
617
|
+
`)}H1(Q.parallelRoot,{recursive:!0});let I=Array.isArray(Y)?Y[0]:Y,w=(await Q1(I,Q.repoRoot,"HEAD")).trim();if(N)try{w=(await S`${Y} rev-parse ${N}`).stdout.trim()||w}catch{}else if(q)try{w=(await S`${Y} rev-parse ${q}`).stdout.trim()||w}catch{}let x=(await S`${Y} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0,E=null,h=null;if(x&&(B||V)){let m=`git-parallel:${J}`;try{if(V){let r=await S`${Y} stash create --include-untracked`;await S`${Y} stash store -m ${m} ${r}`,h="mirrored"}else if(B)await S`${Y} stash push --include-untracked -m ${m}`,h="moved";E="stash@{0}"}catch{return R.error("Failed to stash changes before forking.","parallel"),1}}try{let m=N||"HEAD";if(q&&G)await V0`${Y} worktree add ${G} ${q} ${$} ${m}`;else await V0`${Y} worktree add --detach ${$} ${m}`}catch{if(R.error("Failed to create the parallel worktree.","parallel"),E)await S`${Y} stash pop ${E}`,j(`${U("Yellow")}Stashed changes restored to the origin worktree.${U()}`);return 1}if(E)try{await S`${Y} -C ${$} stash apply --index ${E}`,await S`${Y} stash drop ${E}`}catch{return R.error("Failed to move local changes into the new worktree.","parallel"),R.warn(`Your changes remain stashed as '${E}'. Apply them manually when ready.`,"parallel"),R.info(`Worktree path: ${$}`,"parallel"),1}let u=!1;if(q)u=!0;let f={alias:J,branch:Q.branchName,safeBranch:Q.safeBranchName,project:Q.projectName,safeProject:Q.safeProjectName,originPath:Q.repoRoot,baseCommit:w,forkBranch:q||void 0,forkBranchTracked:u||void 0,createdAt:new Date().toISOString()};if(i6($,f),j(`${U("Cyan")}Parallel worktree created:${U()} ${$}`),h)j(`${U("Cyan")}Pending changes ${h} to fork '${J}'.${U()}`);return await YF({git$:Y,worktreePath:$,originPath:Q.repoRoot,noInitAll:K,noInitList:X}),0}async function KC(Y,Z){let Q=await hY(Y);if(!Q)return 1;let J=["-r","--recursive"],z=new Set,K=null;for(let W of Z){let q=W.toLowerCase();if(J.includes(q))z.add(q);else if(!K&&!W.startsWith("-"))K=W;else return R.error(`Unknown option '${W}'.`,"parallel"),t0(),1}let X=z.has("-r")||z.has("--recursive");if(X&&K)return R.error("Recursive remove does not accept an alias. Omit <alias> with -r.","parallel"),t0(),1;if(X&&Q.isParallelWorktree)return R.error("Run recursive remove from the origin worktree, not from a fork.","parallel"),1;if(X)return await XC(Y,Q);if(!K)return R.error("Missing worktree alias to remove.","parallel"),t0(),1;if(!y5(K))return R.error(`Alias '${K}' contains invalid characters or spaces.`,"parallel"),1;let H=G0.join(Q.parallelRoot,K);if(G0.resolve(Q.repoRoot)===G0.resolve(H))return R.error("Cannot remove the worktree you are currently in. Switch to origin first.","parallel"),1;return await hz(Y,K)}async function XC(Y,Z){if(!l(Z.parallelRoot))return j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`),0;let J=b1(Z.parallelRoot,{withFileTypes:!0}).filter((z)=>z.isDirectory()).sort((z,K)=>z.name.localeCompare(K.name));if(J.length===0)return j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`),0;for(let z of J){let K=G0.join(Z.parallelRoot,z.name),H=p4(K)?.alias||z.name,W=await hz(Y,H);if(W!==0)return W}return 0}async function KF(Y,Z,Q=!1){let J=await hY(Y);if(!J)return 1;if(Z.length<1)return R.error("Missing target worktree alias or 'origin'.","parallel"),t0(),1;let z=Z[0],K;if(z.toLowerCase()==="origin"){if(!l(J.originPath))return R.error(`Origin worktree path not found at '${J.originPath}'.`,"parallel"),1;K=J.originPath}else{if(!y5(z))return R.error(`Alias '${z}' contains invalid characters or spaces.`,"parallel"),1;if(K=G0.join(J.parallelRoot,z),!l(K))return R.error(`Worktree '${z}' not found for branch '${J.branchName}'.`,"parallel"),1;if(Z.includes("-c")||Z.includes("--copy"))return await E7(K),j(`${U("Cyan")}Worktree path copied to clipboard!${U()}`),0}if(Q)await _Z(K);else await f$(K);return 0}async function HC(Y,Z){let Q=await hY(Y);if(!Q)return 1;let J=Array.isArray(Y)?Y[0]:Y,z=Z.includes("--short")||Z.includes("-s");j(`${U("Cyan")}Project:${U()} ${Q.projectName}`),j(`${U("Cyan")}Branch:${U()} ${Q.branchName}`),j(`${U("Cyan")}Origin:${U()} ${Q.originPath}`);let K=Q.isParallelWorktree?Q.alias:"origin";if(j(`${U("Cyan")}Current:${U()} ${K} ${K!=="origin"?U("Dim")+'(use "origin" alias to refer to main worktree)'+U():""}
|
|
618
|
+
`),!l(Q.parallelRoot))return j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`),0;let H=b1(Q.parallelRoot,{withFileTypes:!0}).filter((q)=>q.isDirectory()).sort((q,G)=>q.name.localeCompare(G.name));if(H.length===0)return j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`),0;let W=!1;for(let q of H){let G=G0.join(Q.parallelRoot,q.name),$=p4(G);if(!$){R.debug(`Skipping worktree at '${G}' due to missing or invalid metadata.`,"parallel");continue}let B=$?.alias||q.name,V=$.baseCommit?.trim(),F=$.joinCursor?.trim();W=!0;let M=V&&await S5(J,G,V,F)?F:V,L=d0({message:`Gatering information for ${B}...`}),N=await Q1(J,Q.originPath,"HEAD"),_=N.trim()?[N.trim()]:[],I=z?3:void 0,[w,A,x,E]=await Promise.all([S`${Y} -C ${G} status --porcelain=v1 --untracked-files=normal`.then((U0)=>U0.stdout.trim()),jC(Y,G,Q.originPath,M),M?P9({gitExec:J,repoPath:G,range:`${M}..HEAD`,maxCount:I,formatTemplate:`${U("Yellow")}%h${U()} %s`,excludeRefs:_}):Promise.resolve({commits:[],totalCount:0,moreCount:0}),V?TC({git$:Y,gitExec:J,worktreePath:G,originPath:Q.originPath,baseCommit:V,maxCount:I,submoduleCursors:$.submoduleCursors},L):Promise.resolve({groups:[],totalCount:0})]),h=w.length>0,u=M?M.slice(0,7):"unknown",f=A.ahead,m=E.totalCount,r=f>0||m>0,b=m>0?`${f}+${m}`:`${f}`,$0="";if(r&&A.behind>0)$0=`${U("Yellow")}↑${b} ↓${A.behind}${U()}`;else if(r)$0=`${U("Green")}↑${b}${U()}`;else if(A.behind>0)$0=`${U("Red")}↓${A.behind}${U()}`;else $0=`${U("Dim")}up-to-date${U()}`;let t=Q.isParallelWorktree&&B===Q.alias?"●":"○",X0=h?`${U("Red")}dirty${U()}`:`${U("Green")}clean${U()}`,e=$.forkBranch?`${U("Dim")}(branch:${$.forkBranch})${U()}`:"",n=G;if(z){let U0=cY(G,50,"mid",-1);n=s6(U0,`file://${n0(G)}`)}if(L.stop(),j(`${U("Dim")}${t}${U()} ${cY(B,18,"end")} ${Y6(X0,7,{align:"center"})} ${U("Dim")}${u}${U()} ${t5($0,11)} ${n}${e?` ${e}`:""}`),V){if(E.groups.length>0){let U0=[{label:`. ${U("Dim")}[main]${U()}`,commits:x.commits,totalCount:x.totalCount,moreCount:x.moreCount},...E.groups];IC(U0)}else if(x.totalCount>0)FF(" ",x.commits,x.moreCount)}}if(!W)j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`);return j(""),0}async function n6(Y,Z,Q,J){try{await S`${Y} -C ${Z} stash pop ${J}`,j(`${U("Yellow")}Stashed changes restored to fork '${Q}' due to cherry-pick failure.${U()}`)}catch(z){j(`${U("Yellow")}Please restore stash '${J}' manually from fork '${Q}'. Automatic pop failed.${U()}`),R.debug(g(z,{color:!0}),"parallel")}}async function WC(Y,Z,Q,J,z){if(j(`${U("Yellow")}Cherry-pick stopped at commit ${Q}. To resolve conflicts run:${U()}`),j(`${U("Cyan")}${` git -C "${Y}" cherry-pick ${Q}`}${U()}`),z.length>0){let X=z.map((H)=>H.includes(" ")?`"${H}"`:H).join(" ");j(`${U("Cyan")}${` git -C "${Y}" add -- ${X}`}${U()}`)}else j(`${U("Cyan")}${` git -C "${Y}" add -A`}${U()}`);if(j(`${U("Cyan")}${` git -C "${Y}" cherry-pick --continue`}${U()}`),j(`${U("Cyan")}${` ${C} parallel join ${Z}`}${U()}`),J)j(`${U("Dim")}Stashed changes from fork '${Z}' can be applied after join.${U()}`)}function qC(Y){if(!Y)return{action:"abort",key:"q"};return Y}async function GC(Y,Z,Q){let J=["%H","%an","%ae","%ad","%B"].join("%n"),K=(await S`${Y} -C ${Z} show -s --date=iso --format=${J} ${Q}`).stdout.split(`
|
|
619
|
+
`),[X,H,W,q,...G]=K,$=G.join(`
|
|
620
|
+
`).trimEnd();return{hash:X?.trim()||Q,authorName:H?.trim()||"unknown",authorEmail:W?.trim()||"unknown",authorDate:q?.trim()||"unknown",message:$.length>0?$:"(no message)"}}async function UC(Y){let{gitExec:Z,originRepoPath:Q,forkRepoPath:J,commit:z,spinner:K}=Y;if(K)K.options.message="Emulating cherry-pick...";let X=(await S`${Z} -C ${J} show --format= --no-color ${z}`).stdout;if(X.trim().length===0)return{diff:"",stat:"",isEmpty:!0,hasConflicts:!1,appliedPatch:!0};let H=G0.join(O1,"parallel-join-preview");H1(H,{recursive:!0});let W=LK(G0.join(H,"index-")),q=G0.join(W,"index"),G={...process.env,GIT_INDEX_FILE:q};try{await S({env:G})`${Z} -C ${Q} read-tree HEAD`;let $=!1,B,V,F;try{await S({env:G,input:X})`${Z} -C ${Q} apply --cached --3way --whitespace=nowarn`,$=!0}catch(x){B=b8(x)}if(!$)if(V=await FC({gitExec:Z,originRepoPath:Q,patch:X,env:G}),V.applies)try{await S({env:G,input:X})`${Z} -C ${Q} apply --cached --whitespace=nowarn`,$=!0,B=void 0}catch(x){B=x5(B,b8(x))}else try{await S({env:G})`${Z} -C ${Q} read-tree HEAD`,await S({env:G,input:X})`${Z} -C ${Q} apply --cached --whitespace=nowarn`,$=!0,B=void 0,V={applies:!0}}catch(x){B=x5(B,x5(V.conflictInfo,b8(x)))}let M=await VC(Z,Q,G),L=x5(M,B);if(!L&&!$&&V&&!V.applies){let x={...process.env,GIT_INDEX_FILE:G0.join(W,"index-conflict")};if(F=await RC({gitExec:Z,originRepoPath:Q,patch:X,env:x}),F&&F.files.length>0){let E=BF(X).length;L=F.files.length<E?F:void 0}}let N=!1;if(!L?.files?.length&&!$){if(N=await $C({gitExec:Z,originRepoPath:Q,forkRepoPath:J,commit:z}),N&&!L)if(F?.files?.length)L=F;else{let x=OC(X);if(x?.files?.length)L=x}}else if(L?.files?.length)N=!0;let _=!1;if(!L?.files?.length&&!$&&!N)_=await BC({gitExec:Z,originRepoPath:Q,forkRepoPath:J,commit:z});let I=Boolean(L?.files?.length)||N||_;if(!$){let x=(await S`${Z} -C ${J} show --format= --no-color ${z}`).stdout,E=(await S`${Z} -C ${J} show --stat --format= --no-color ${z}`).stdout,h=I?"Patch does not apply cleanly to origin HEAD. Preview shows the original commit diff.":void 0;return{diff:x,stat:E,isEmpty:x.trim().length===0,hasConflicts:I,warning:h,appliedPatch:!1,conflictInfo:L}}let w=(await S({env:G})`${Z} -C ${Q} diff --cached --no-color`).stdout,A=(await S({env:G})`${Z} -C ${Q} diff --cached --stat --no-color`).stdout;return{diff:w,stat:A,isEmpty:w.trim().length===0,hasConflicts:I,appliedPatch:$,conflictInfo:L}}finally{t6(W,{recursive:!0,force:!0})}}async function $C(Y){let{gitExec:Z,originRepoPath:Q,forkRepoPath:J,commit:z}=Y;try{let K=(await S`${Z} -C ${J} rev-parse ${z}^`).stdout.trim();if(!K)return!1;let X=(await S`${Z} -C ${Q} rev-parse HEAD`).stdout.trim();if(!X)return!1;let H=(await S`${Z} -C ${Q} merge-tree ${K} ${X} ${z}`).stdout;return/^(<{7}| <{7})/m.test(H)}catch{return!1}}async function BC(Y){let{gitExec:Z,originRepoPath:Q,forkRepoPath:J,commit:z}=Y;try{let K=(await S`${Z} -C ${J} rev-parse ${z}^`).stdout.trim();if(!K)return!1;let X=(await S`${Z} -C ${Q} rev-parse HEAD`).stdout.trim();if(!X)return!1;let H=(await S`${Z} -C ${J} show --name-only --format= ${z}`).stdout.trim();if(!H)return!1;let W=new Set(H.split(`
|
|
621
|
+
`).map(($)=>$.trim()).filter(($)=>$.length>0)),q=(await S`${Z} -C ${Q} diff --name-only ${K} ${X}`).stdout.trim();if(!q)return!1;return q.split(`
|
|
622
|
+
`).map(($)=>$.trim()).filter(($)=>$.length>0).some(($)=>W.has($))}catch{return!1}}async function VC(Y,Z,Q){let J="";try{J=(await S({env:Q})`${Y} -C ${Z} diff --cached --name-only --diff-filter=U`).stdout.trim()}catch{return}let z=J.split(`
|
|
623
|
+
`).map((X)=>X.trim()).filter((X)=>X.length>0);if(z.length===0)return;let K;try{let X=(await S({env:Q})`${Y} -C ${Z} diff --cached --cc --no-color`).stdout;K=MC(X)}catch{K=void 0}if(K){if(!z.every((H)=>typeof K?.[H]==="number"))K=void 0}return{files:z,counts:K}}async function FC(Y){let{gitExec:Z,originRepoPath:Q,patch:J,env:z}=Y;try{return await S({env:z,input:J})`${Z} -C ${Q} apply --check --whitespace=nowarn`,{applies:!0}}catch(K){return{applies:!1,conflictInfo:b8(K)}}}async function RC(Y){let{gitExec:Z,originRepoPath:Q,patch:J,env:z}=Y,K=BF(J);if(K.length===0)return;let X=[],H={};for(let q of K)try{await S({env:z})`${Z} -C ${Q} read-tree HEAD`,await S({env:z,input:q.patch})`${Z} -C ${Q} apply --cached --3way --whitespace=nowarn`}catch(G){if(!X.includes(q.file))X.push(q.file);let B=b8(G)?.counts?.[q.file];if(typeof B==="number")H[q.file]=B}if(X.length===0)return;let W=X.every((q)=>typeof H[q]==="number");return{files:X,counts:W?H:void 0}}function BF(Y){let Z=[],Q=null,J=Y.split(`
|
|
624
|
+
`);for(let z of J){if(z.startsWith("diff --git ")){if(Q)Z.push(Q);Q={file:z.match(/diff --git a\/(.+?) b\/(.+)/)?.[2]?.trim()||"unknown",lines:[z]};continue}if(z.startsWith("diff --cc ")||z.startsWith("diff --combined ")){if(Q)Z.push(Q);Q={file:z.replace(/^diff --(?:cc|combined)\s+/,"").trim()||"unknown",lines:[z]};continue}if(Q)Q.lines.push(z)}if(Q)Z.push(Q);return Z.filter((z)=>z.lines.length>0).map((z)=>({file:z.file,patch:z.lines.join(`
|
|
625
|
+
`)}))}function b8(Y){let Z=[];if(typeof Y==="string")Z.push(Y);else if(Y instanceof _1)Z.push(Y.stderr,Y.stdout,Y.message,Y.shortMessage);else if(Y&&typeof Y==="object"){let H=Y;Z.push(H.stderr,H.stdout,H.message)}let Q=Z.map((H)=>RF(H)).filter(Boolean).join(`
|
|
626
|
+
`);if(!Q)return;let J=[],z={},K=Q.split(`
|
|
627
|
+
`);for(let H of K){let W=H.match(/patch failed:\s+(.+?):\d+/i);if(W){let G=W[1].trim();if(!J.includes(G))J.push(G);z[G]=(z[G]||0)+1;continue}let q=H.match(/error:\s+(.+?):\s+patch does not apply/i);if(q){let G=q[1].trim();if(!J.includes(G))J.push(G)}}if(J.length===0)return;let X=J.every((H)=>typeof z[H]==="number"&&z[H]>0);return{files:J,counts:X?z:void 0}}function x5(Y,Z){if(!Y&&!Z)return;if(!Y)return Z;if(!Z)return Y;let Q=Y.files.length>0?Y.files:Z.files;if(Q.length===0)return Z.files.length>0?Z:void 0;let J=XF(Y,Q),z=XF(Z,Q);return{files:Q,counts:J??z}}function OC(Y){let Z=[],Q=Y.split(`
|
|
628
|
+
`);for(let J of Q){if(J.startsWith("diff --git ")){let z=J.match(/diff --git a\/(.+?) b\/(.+)/);if(z){let K=z[2].trim();if(K&&!Z.includes(K))Z.push(K)}continue}if(J.startsWith("diff --cc ")){let z=J.slice(10).trim();if(z&&!Z.includes(z))Z.push(z);continue}if(J.startsWith("diff --combined ")){let z=J.slice(16).trim();if(z&&!Z.includes(z))Z.push(z)}}if(Z.length===0)return;return{files:Z}}function XF(Y,Z){if(!Y?.counts)return;return Z.every((J)=>typeof Y.counts?.[J]==="number")?Y.counts:void 0}function MC(Y){let Z={},Q=null,J=Y.split(`
|
|
629
|
+
`);for(let z of J){if(z.startsWith("diff --cc ")){Q=z.slice(10).trim();continue}if(z.startsWith("diff --combined ")){Q=z.slice(16).trim();continue}if(z.startsWith("@@@")&&Q)Z[Q]=(Z[Q]||0)+1}return Z}function DC(Y){let{commitInfo:Z,stat:Q,warning:J,isEmpty:z,isSubmodule:K,submodulePath:X,conflictInfo:H}=Y,W=[];if(W.push(`Commit: ${Z.hash}`),W.push(`Author: ${Z.authorName} <${Z.authorEmail}>`),W.push(`Date: ${Z.authorDate}`),K&&X)W.push(`Scope: submodule ${X}`);W.push(""),W.push(...Z.message.split(`
|
|
630
|
+
`).map(($)=>` ${$}`));let q=Q.trimEnd().replace(/(\W)(\++)/g,`$1${U("Green")}$2${f0(Q0.overlay0)}`).replace(/(-+)/g,`${U("Red")}$1${f0(Q0.overlay0)}`);if(q.length>0)W.push(""),W.push(...q.split(`
|
|
631
|
+
`).map(($)=>` ${$}`));if(J)W.push(""),W.push(`Warning: ${U("Yellow")+U("Bright")}${J}${U("Normal")+f0(Q0.overlay0)}`);let G=_C(H);if(G.length>0)W.push(""),W.push(...G);if(z)W.push(""),W.push(` Note: ${U("Blue")}No changes against origin. This commit will be skipped unless applied.${U("Normal")+f0(Q0.overlay0)}`);return W}function NC(Y){let{isEmpty:Z,hasConflicts:Q}=Y;if(Z)return U("BgWhite")+U("Black")+U("Bright")+" EMPTY "+U()+f0(Q0.overlay0)+D1(Q0.base);if(Q)return U("BgRed")+U("White")+U("Bright")+" CONFLICT "+U()+f0(Q0.overlay0)+D1(Q0.base);return U("Green")+U("White")+U("Bright")+" CLEAN "+U()+f0(Q0.overlay0)+D1(Q0.base)}function _C(Y){if(!Y||Y.files.length===0)return[];let Z=["Conflicts:"],{files:Q,counts:J}=Y;if(J&&Q.every((K)=>typeof J?.[K]==="number")&&J){let K=Math.max(...Q.map((X)=>X.length));for(let X of Q){let H=J[X]??0,W=H===1?"conflict":"conflicts";Z.push(` ${t5(X,K)} | ${H} ${W}`)}return Z}for(let K of Q)Z.push(` ${K}`);return Z}async function HF(Y){let{gitExec:Z,originRepoPath:Q,forkRepoPath:J,commit:z,isSubmodule:K,submodulePath:X}=Y,H=d0({message:"Preparing cherry-pick preview..."}),W=await GC(Z,J,z),q=await UC({gitExec:Z,originRepoPath:Q,forkRepoPath:J,commit:z,spinner:H});H.stop();let G=DC({commitInfo:W,stat:q.stat,warning:q.warning,isEmpty:q.isEmpty,isSubmodule:K,submodulePath:X,conflictInfo:q.conflictInfo}),$=q.isEmpty?[{key:"s",label:"skip",action:"skip"},{key:"u",label:"undo",action:"undo"}]:[{key:"a",label:"apply",action:"apply"},{key:"s",label:"skip",action:"skip"},{key:"u",label:"undo",action:"undo"}],B=NC({isEmpty:q.isEmpty,hasConflicts:q.hasConflicts}),V=q.diff.trimEnd(),F=V.length>0?[...G,"",V].join(`
|
|
632
|
+
`):G.join(`
|
|
633
|
+
`),M=await y8(F,{statusText:B,actions:$});return qC(M)}async function WF(Y,Z){let Q=Array.isArray(Y)?Y[0]:Y;try{await S`${Q} -C ${Z} rev-parse --verify HEAD~1`}catch{return R.error("No commit available to undo.","parallel"),!1}try{return await S`${Q} -C ${Z} reset --hard HEAD~1`,j(`${U("Cyan")}Undid last cherry-picked commit in ${Z}.${U()}`),!0}catch(J){return R.error("Failed to undo last cherry-picked commit.","parallel"),R.debug(g(J,{color:!0}),"parallel"),!1}}async function S5(Y,Z,Q,J){if(!J)return!1;let z=(await Q1(Y,Z,"HEAD")).trim();if(!z)return!1;try{return await S`${Y} -C ${Z} merge-base --is-ancestor ${Q} ${J}`,await S`${Y} -C ${Z} merge-base --is-ancestor ${J} ${z}`,!0}catch{return!1}}function qF(Y,Z,Q,J,z){if(Y.submoduleCursors??={},z){Y.submoduleCursors[Z]=z;return}Y.submoduleCursors[Z]=J[J.length-1]||Q}async function VF(Y,Z,Q,J){R.debug(`Joining worktree '${Q}'...`,"parallel");let{keep:z,bringAll:K,interactive:X}=J,H=X&&T9();if(X&&!H)R.warn("Interactive join requires a TTY. Proceeding without --interactive.","parallel");let W=p4(Z);if(!W)return R.error(`Missing metadata for worktree '${Q}'. Unable to join automatically.`,"parallel"),1;let q=G0.resolve(W.originPath);if(!l(q))return R.error(`Original worktree path not found. Expected at '${W.originPath}'.`,"parallel"),1;if(W.forkBranch&&W.forkBranchTracked){let t=W.forkBranch.trim();if(t){let X0=(await S`${Y} -C ${Z} remote`).stdout.trim(),e=X0?X0.split(`
|
|
634
|
+
`).map((n)=>n.trim()).filter((n)=>n.length>0):[];if(e.length>0)for(let n of e)try{if((await S`${Y} -C ${Z} ls-remote --heads ${n} ${t}`).stdout.trim().length>0)return R.error(`Fork branch '${t}' exists on remote '${n}'. Use standard git commands to merge it.`,"parallel"),1}catch{}}}let G=d0({message:"Checking worktree status"}),$=Array.isArray(Y)?Y[0]:Y,[B,V,F]=await Promise.all([S`${Y} -C ${Z} status --porcelain=v1 --untracked-files=normal`,S`${Y} -C ${q} status --porcelain=v1 --untracked-files=normal`,Q1($,Z,"HEAD")]),L=B.stdout.trim().length>0;if(R.debug(`Fork worktree '${Q}' dirty status: ${L?"dirty":"clean"}`,"parallel"),L&&!K&&!z)return G.stop(),R.error(`Fork '${Q}' has uncommitted changes. Re-run with --all to include them or clean the worktree first.`,"parallel"),1;if(V.stdout.trim().length>0&&K&&L)return G.stop(),R.error("Origin worktree has pending changes. Commit or stash them before joining.","parallel"),1;let _=W.baseCommit?.trim(),I=W.joinCursor?.trim();if(!_)return G.stop(),R.error("Fork metadata is missing base commit information. Unable to perform an automatic join.","parallel"),1;let w=await S5($,Z,_,I),A=w?I:_,x=(await Q1($,q,"HEAD")).trim(),E=null;if(L&&K){let t=`git-parallel-join:${Q}`;R.debug(`Stashing uncommitted changes from fork '${Q}' before joining...`,"parallel"),G.options.message="Stashing uncommitted changes";try{await S`${Y} -C ${Z} stash push --include-untracked -m ${t}`,E="stash@{0}"}catch{return R.error("Failed to stash uncommitted changes before joining.","parallel"),1}}let h=F.trim(),u;R.debug(`Enumerating commits from fork '${Q}' since ${w?"join cursor":"base commit"} ${A}...`,"parallel"),G.options.message="Enumerating commits to join";try{let t=["-C",Z,"rev-list","--reverse",`${A}..${h}`];if(x)t.push("--not",x);let X0=(await S`${$} ${t}`).stdout.trim();u=X0?X0.split(`
|
|
635
|
+
`).map((e)=>e.trim()).filter((e)=>e):[]}catch(t){if(E)await S`${Y} -C ${Z} stash pop ${E}`;return R.error("Unable to enumerate commits to join.","parallel"),R.debug(g(t,{color:!0}),"parallel"),1}let f=[],m=[],r=[];G.stop(),R.debug(`Found ${u.length} commit(s) to cherry-pick into origin.`,"parallel");let b=0;while(b<u.length){let t=u[b];if(!t){b++;continue}try{let X0=!1,e=!1;if(H){let n=await HF({git$:Y,gitExec:$,originRepoPath:q,forkRepoPath:Z,commit:t,forkAlias:Q,isSubmodule:!1});if(n.action==="abort"){if(E)await n6(Y,Z,Q,E);return 1}if(n.action==="undo"){if(m.length===0){j(`${U("Yellow")}No commit to undo yet.${U()}`);continue}let U0=m.pop();if(U0===void 0)continue;if(!await WF(Y,q)){if(E)await n6(Y,Z,Q,E);return 1}if(f.length>0)f.pop();let j0=U0>0?u[U0-1]:A;W.joinCursor=j0,i6(Z,W),b=Math.max(U0,0);continue}if(n.action==="skip")e=!0;else if(n.action==="apply")X0=!0}else X0=!0;if(X0){if(await GF(Y,{originRepoPath:q,commit:t,contextLabel:"origin worktree",forkAlias:Q,stashRef:E}))f.push(t),m.push(b),W.joinCursor=t,i6(Z,W)}else if(e)W.joinCursor=t,i6(Z,W)}catch{if(E)await n6(Y,Z,Q,E);return 1}b++}let $0=await v6(Y,Z);for(let t=0;t<$0.length;t++){let X0=$0[t];G.start(),G.options.message=`Enumerating submodule commits ${t+1} of ${$0.length}`;let e=G0.resolve(Z,X0.path),n=G0.resolve(q,X0.path),U0=G0.join(e,".git"),M0=G0.join(n,".git");if(!l(e)||!l(n))continue;if(!l(U0)||!l(M0))continue;let j0=await v9($,Z,_,X0.path);if(!j0)continue;let C0=W.submoduleCursors?.[X0.path]?.trim(),R0=await S5($,e,j0,C0)?C0:j0,N0=[];try{let x0=(await Q1($,e,"HEAD")).trim(),z1=(await Q1($,n,"HEAD")).trim(),c4=z1?(await Q1($,e,["-q","--verify",`${z1}^{commit}`])).trim():"",f1=["-C",e,"rev-list","--reverse",`${R0}..${x0}`];if(c4)f1.push("--not",c4);N0=await S`${$} ${f1}`.then((mY)=>mY.stdout.trim().split(`
|
|
636
|
+
`).map((g8)=>g8.trim()).filter((g8)=>!!g8))}catch(x0){if(G.stop(),R.error(`Unable to enumerate submodule commits for '${X0.path}'.`,"parallel"),R.debug(g(x0,{color:!0}),"parallel"),E)await n6(Y,Z,Q,E);return 1}if(G.stop(),N0.length===0)continue;R.debug(`Found ${N0.length} commit(s) to cherry-pick for submodule '${X0.path}'.`,"parallel");let R1=[],C1=0;while(C1<N0.length){let x0=N0[C1];if(!x0){C1++;continue}try{try{await S`${$} -c protocol.file.allow=always -C ${n} fetch ${e} ${x0}`}catch(f1){if(R.error(`Failed to fetch submodule commit ${x0} from '${X0.path}'.`,"parallel"),R.debug(g(f1,{color:!0}),"parallel"),E)await n6(Y,Z,Q,E);return 1}let z1=!1,c4=!1;if(H){let f1=await HF({git$:Y,gitExec:$,originRepoPath:n,forkRepoPath:e,commit:x0,forkAlias:Q,isSubmodule:!0,submodulePath:X0.path});if(f1.action==="abort"){if(E)await n6(Y,Z,Q,E);return 1}if(f1.action==="undo"){if(R1.length===0){j(`${U("Yellow")}No commit to undo yet.${U()}`);continue}let mY=R1.pop();if(mY===void 0)continue;if(!await WF(Y,n)){if(E)await n6(Y,Z,Q,E);return 1}if(r.length>0)r.pop();let $R=mY>0?N0[mY-1]:R0;W.submoduleCursors??={},W.submoduleCursors[X0.path]=$R,i6(Z,W),C1=Math.max(mY,0);continue}if(f1.action==="skip")c4=!0;else if(f1.action==="apply")z1=!0}else z1=!0;if(z1){if(await GF(Y,{originRepoPath:n,commit:x0,contextLabel:`submodule ${X0.path}`,forkAlias:Q,stashRef:E}))r.push(x0),R1.push(C1);qF(W,X0.path,R0,r,x0),i6(Z,W)}else if(c4)qF(W,X0.path,R0,r,x0),i6(Z,W)}catch{if(E)await n6(Y,Z,Q,E);return 1}C1++}}if(E){R.debug(`Applying stashed uncommitted changes from fork '${Q}' to origin...`,"parallel");try{let e=(await S`${Y} -C ${Z} stash list`).stdout.trim().split(`
|
|
637
|
+
`)[0]?.split(":")[0]||E;await S`${Y} -C ${q} stash apply --index ${e}`,await S`${Y} -C ${Z} stash drop ${e}`}catch(t){R.error("Failed to apply uncommitted changes to the origin worktree.","parallel"),R.debug(g(t,{color:!0}),"parallel");try{await S`${Y} -C ${Z} stash pop ${E}`,j(`${U("Yellow")}Stashed changes restored to fork '${Q}' for safety.${U()}`)}catch(X0){j(`${U("Yellow")}Please restore stash '${E}' manually from fork '${Q}'. Automatic pop failed.${U()}`),R.debug(g(X0,{color:!0}),"parallel")}return 1}}if(f.length>0||r.length>0){if(j(`${U("Cyan")}Cherry-picked ${f.length} commit(s) into origin.${U()}`),r.length>0)j(`${U("Cyan")}Cherry-picked ${r.length} submodule commit(s) into origin.${U()}`)}else j(`${U("Cyan")}No new commits to cherry-pick. Origin was already up to date.${U()}`);if(!z){if(R.debug(`Removing fork worktree '${Q}' after join...`,"parallel"),await hz(Y,Q)!==0)return R.warn(`Failed to remove fork '${Q}' after joining. Please remove it manually later.`),1;j(`${U("Cyan")}Fork '${Q}' merged and removed successfully.${U()}`)}else{try{let t=(await Q1($,q,"HEAD")).trim();if(t)W.baseCommit=t,W.updatedAt=new Date().toISOString()}catch{}W.joinCursor=void 0,W.submoduleCursors=void 0,i6(Z,W),j(`${U("Cyan")}Fork '${Q}' merged into origin. Worktree kept at:${U()} ${Z}`)}return 0}async function LC(Y,Z,Q){if(!l(Z.parallelRoot))return j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`),0;let z=b1(Z.parallelRoot,{withFileTypes:!0}).filter((X)=>X.isDirectory()).sort((X,H)=>X.name.localeCompare(H.name));if(z.length===0)return j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`),0;let K=!1;for(let X of z){let H=G0.join(Z.parallelRoot,X.name),W=p4(H);if(!W)continue;let q=W.alias||X.name;K=!0;let G=await VF(Y,H,q,{keep:Q,bringAll:!1,interactive:!1});if(G!==0)return G}if(!K)j(`${U("Yellow")}No forked worktrees found for this branch.${U()}`);return 0}async function wC(Y,Z){let Q=await hY(Y);if(!Q)return 1;let J=["--keep","--all","--interactive","-i","-r","--recursive"],z=new Set,K=null;for(let B of Z){let V=B.toLowerCase();if(J.includes(V))z.add(V);else if(!K&&!B.startsWith("-"))K=B;else return R.error(`Unknown option '${B}'.`,"parallel"),t0(),1}let X=z.has("--keep"),H=z.has("--all"),W=z.has("--interactive")||z.has("-i"),q=z.has("-r")||z.has("--recursive");if(q&&H)return R.error("Recursive join does not support --all. Join forks individually.","parallel"),t0(),1;if(q&&W)return R.error("Recursive join does not support --interactive. Join forks individually.","parallel"),t0(),1;if(q&&K)return R.error("Recursive join does not accept an alias. Omit <alias> with -r.","parallel"),t0(),1;if(q&&Q.isParallelWorktree)return R.error("Run recursive join from the origin worktree, not from a fork.","parallel"),1;if(q)return await LC(Y,Q,X);let G,$;if(K){if(Q.isParallelWorktree&&Q.alias===K)return R.error("Cannot join the fork you are currently in. Switch to origin or another fork first.","parallel"),1;if(!y5(K))return R.error(`Alias '${K}' contains invalid characters or spaces.`,"parallel"),1;if(G=G0.join(Q.parallelRoot,K),$=K,!l(G))return R.error(`Worktree '${K}' not found for branch '${Q.branchName}'.`,"parallel"),1}else{if(!Q.isParallelWorktree)return R.error("Either run join from inside a forked worktree, or specify which fork to join.","parallel"),R.info("Usage: git parallel join [<alias>] [--keep|--all|--interactive] | git parallel join -r [--keep]","parallel"),1;G=Q.repoRoot,$=Q.alias}return await VF(Y,G,$,{keep:X,bringAll:H,interactive:W})}async function GF(Y,Z){let{originRepoPath:Q,commit:J,contextLabel:z,forkAlias:K,stashRef:X}=Z;R.debug(`Cherry-picking commit ${J} into ${z}...`,"parallel");let H=y9();try{let W=await S`${Y} ${H} -C ${Q} cherry-pick ${J}`;return a6(W),!0}catch(W){if(await UF(Y,Q,W,z))return!1;if(a6(f8(W)),!await wZ(Y,Q))throw R.error(`Cherry-pick failed while applying commit ${J}.`,"parallel"),R.debug(g(W,{color:!0}),"parallel"),W;if(!T9()){let $=await f7(Y,Q);throw await WC(Q,K,J,X,$),R.debug(g(W,{color:!0}),"parallel"),W}j(`${U("Yellow")}Cherry-pick paused due to conflicts while applying commit ${J}.${U()}`),j(`${U("Dim")}Resolve conflicts in ${z}, then choose to continue or abort.${U()}`);while(!0)switch((await NZ("Type c to continue, a to abort, s to skip (c|a|s): ")).toLowerCase()){case"s":case"skip":try{return await S`${Y} ${H} -C ${Q} cherry-pick --skip`,R.debug(`Skipped commit ${J} for ${z}.`,"parallel"),!1}catch(B){if(!await wZ(Y,Q))return!1;a6(f8(B)),R.error(`Failed to skip commit ${J} for ${z}.`,"parallel"),R.debug(g(B,{color:!0}),"parallel");continue}case"c":case"continue":case"y":case"yes":try{await a$(Y,Q);let B=await S`${Y} ${H} -C ${Q} cherry-pick --continue`;return a6(B),!0}catch(B){if(await UF(Y,Q,B,z))return!1;if(a6(f8(B)),await wZ(Y,Q)){j(`${U("Yellow")}Cherry-pick still has conflicts. Resolve them and try again.${U()}`),R.debug(g(B,{color:!0}),"parallel");continue}throw R.error("Cherry-pick no longer in progress. You may need to resolve the state manually before retrying.","parallel"),R.debug(g(B,{color:!0}),"parallel"),B}case"a":case"abort":case"n":case"no":try{let B=await S`${Y} ${H} -C ${Q} cherry-pick --abort`;a6(B)}catch(B){throw a6(f8(B)),R.error("Failed to abort cherry-pick.","parallel"),R.debug(g(B,{color:!0}),"parallel"),B}throw R.error(`Cherry-pick aborted while applying commit ${J}.`,"parallel"),W}}}async function UF(Y,Z,Q,J){let z=await wZ(Y,Z);if(!(i$(Q)||z&&await o$(Y,Z)))return!1;if(!z)return R.debug(`Empty cherry-pick ignored for ${J}.`,"parallel"),!0;try{return await S`${Y} ${y9()} -C ${Z} cherry-pick --skip`,R.debug(`Skipped empty cherry-pick for ${J}.`,"parallel"),!0}catch(X){return a6(f8(X)),R.error(`Failed to skip empty cherry-pick for ${J}.`,"parallel"),R.debug(g(X,{color:!0}),"parallel"),!1}}async function jC(Y,Z,Q,J){let z=Array.isArray(Y)?Y[0]:Y;try{let[K,X]=await Promise.all([Q1(z,Z,"HEAD").then((q)=>q.trim()),Q1(z,Q,"HEAD").then((q)=>q.trim())]);if(K===X)return{ahead:0,behind:0};let H=0,W=0;return await Promise.all([(async()=>{try{let G=(await S`${z} -C ${Z} rev-list --count ${J||X}..${K}`).stdout.trim();H=parseInt(G,10)||0}catch{H=0}})(),(async()=>{try{let q=(await S`${z} -C ${Z} rev-list --count ${K}..${X}`).stdout.trim();W=parseInt(q,10)||0}catch{W=0}})()]),{ahead:H,behind:W}}catch{return{ahead:0,behind:0}}}async function TC(Y,Z){let{git$:Q,gitExec:J,worktreePath:z,originPath:K,baseCommit:X,maxCount:H,submoduleCursors:W}=Y,q=await v6(Q,z);if(q.length===0)return{groups:[],totalCount:0};let G=[],$=0;for(let B of q){let V=G0.resolve(z,B.path),F=G0.resolve(K,B.path),M=G0.join(V,".git"),L=G0.join(F,".git");if(!l(V)||!l(M))continue;if(Z)Z.options.message=`Collecting submodule '${B.path}'...`;let N=await v9(J,z,X,B.path);if(!N)continue;let _=N,I=W?.[B.path];if(I){if(await S5(J,V,N,I))_=I}let w=`${_}..HEAD`,A=l(F)&&l(L)?(await Q1(J,F,"HEAD")).trim():"",x=await P9({gitExec:J,repoPath:V,range:w,maxCount:H,formatTemplate:`${U("Yellow")}%h${U()} %s`,excludeRefs:A?[A]:void 0});if(x.totalCount===0)continue;let E=`${B.path} ${U("Dim")}[submodule]${U()}`;G.push({label:E,commits:x.commits,totalCount:x.totalCount,moreCount:x.moreCount}),$+=x.totalCount}return{groups:G,totalCount:$}}function FF(Y,Z,Q){let J=[...Z];if(Q>0)J.push(`${U("Dim")}+${Q} more${U()}`);if(J.length===0)return;for(let z=0;z<J.length;z++){let X=z===J.length-1?"└─ ":"├─ ";j(`${U("Dim")}${Y}${X}${U()}${J[z]}`)}}function IC(Y){if(Y.length===0)return;for(let Z=0;Z<Y.length;Z++){let Q=Y[Z],J=Z===Y.length-1,z=J?" └─ ":" ├─ ";j(`${U("Dim")}${z}${U()}${Q.label}`),FF(J?" ":" │ ",Q.commits,Q.moreCount)}}function RF(Y){if(!Y)return"";if(typeof Y==="string")return Y;if(Y instanceof Uint8Array)return new TextDecoder().decode(Y);return String(Y)}function $F(Y){let Z=RF(Y);if(!Z)return;j(Z,Z.endsWith(`
|
|
607
638
|
`)?"":`
|
|
608
|
-
`)}function
|
|
609
|
-
`+
|
|
610
|
-
${Y+
|
|
639
|
+
`)}function a6(Y){$F(Y.stdout),$F(Y.stderr)}function f8(Y){if(Y instanceof _1)return{stdout:Y.stdout,stderr:Y.stderr};let Z=Y;return{stdout:Z?.stdout,stderr:Z?.stderr}}async function gz(Y){let{git$:Z,args:Q}=Y;if(Q.length<2)return t0(),1;let J=Q[1].toLowerCase(),{match:z,candidates:K}=P0(J,["fork","list","open","switch","join","remove","help"]),X=Q.slice(2);switch(z){case"fork":return await zC(Z,X);case"remove":return await KC(Z,X);case"switch":if(!Q6)return R.error("'git parallel switch' requires the shell integration. See readme for details."),1;return await KF(Z,X,!0);case"open":return await KF(Z,X);case"list":return await HC(Z,X);case"join":return await wC(Z,X);case"help":return t0(),0;default:if(K&&K.length>0)R.warn(`Ambiguous command '${J}'. Did you mean one of: ${K.join(", ")}?`);else R.warn(`Unknown subcommand '${J}'`);return t0(),1}}function t0(){j(P5.short+`
|
|
640
|
+
`+P5.usage())}var zF=1000,bY=null,YC=async({git$:Y})=>{let Z=await v5(Y);return I5(["origin",...Z],["-c","--copy"])},ZC=async({git$:Y})=>{let Z=await v5(Y);return I5(["origin",...Z],["-c","--copy"])},QC=async({git$:Y})=>{let Z=await v5(Y);return{$allOf:["--keep","--all","-i","--interactive"],"-r":{$allOf:["--keep"]},"--recursive":{$allOf:["--keep"]},...I5(Z,["--keep","--all","-i","--interactive"])}},JC=async({git$:Y})=>{let Z=await v5(Y);return{"-r":{},"--recursive":{},...cV(Z)}},P5,OF;var f5=O(()=>{o0();_7();H0();h0();L0();D0();W0();A0();v0();bz();K1();JF();P5={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
641
|
+
${Y+d("PARALLEL",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
611
642
|
Manage parallel (forked) worktrees for iterative development.
|
|
612
643
|
|
|
613
|
-
${Y+
|
|
644
|
+
${Y+d("OVERVIEW",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
614
645
|
\`${Z}${C} parallel${Q}\` helps you create and manage temporary forked worktrees for the current branch. Forked worktrees live under a temp worktree root and contain a small metadata file (.git-parallel.json) so the tool can later join, list or remove them cleanly.
|
|
615
646
|
|
|
616
|
-
Additionally, \`${Z}${C} parallel fork${Q}\` can auto-initialize submodules
|
|
617
|
-
install dependencies using detected package managers (currently supports
|
|
618
|
-
if configured (see \`${Z}parallel.init${Q}\`
|
|
619
|
-
getting the fork ready for work in no time.
|
|
647
|
+
Additionally, \`${Z}${C} parallel fork${Q}\` can auto-initialize submodules,
|
|
648
|
+
copy ignored env files, and install dependencies using detected package managers (currently supports
|
|
649
|
+
npm, pnpm, bun, and uv) if configured (see \`${Z}parallel.init${Q}\` and
|
|
650
|
+
\`${Z}parallel.envPaths${Q}\` config for options), getting the fork ready for work in no time.
|
|
620
651
|
|
|
621
|
-
${Y+
|
|
622
|
-
- ${Z}fork <alias>${Q}: Creates a detached worktree in a safe temporary namespace. If pending changes exist and you run with \`${Z}--move${Q}\` or \`${Z}--mirror${Q}\`, changes will be moved/applied to the fork. Init behaviors are controlled by config and \`${Z}--no-init${Q}\`.
|
|
623
|
-
- ${Z}join [<alias>] [--keep|--all]${Q}: Cherry-picks commits from the fork back into the origin worktree. \`${Z}--keep${Q}\` retains the fork and updates its base; \`${Z}--all${Q}\` also includes uncommitted changes.
|
|
652
|
+
${Y+d("SUBCOMMANDS AND BEHAVIOR",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
653
|
+
- ${Z}fork <alias>${Q}: Creates a detached worktree in a safe temporary namespace. Use \`${Z}-b${Q}\` or \`${Z}-B${Q}\` to create a non-detached worktree that tracks a local branch. If pending changes exist and you run with \`${Z}--move${Q}\` or \`${Z}--mirror${Q}\`, changes will be moved/applied to the fork. Init behaviors (submodules, env file copy, packages) are controlled by config and \`${Z}--no-init${Q}\`.
|
|
654
|
+
- ${Z}join [<alias>] [--keep|--all|-i|--interactive]${Q}: Cherry-picks commits from the fork back into the origin worktree. \`${Z}--keep${Q}\` retains the fork and updates its base; \`${Z}--all${Q}\` also includes uncommitted changes. \`${Z}--interactive${Q}\` previews and lets you choose each commit before applying.
|
|
624
655
|
- ${Z}join -r|--recursive [--keep]${Q}: Joins every fork for the current branch back into origin. Recursive join does not allow \`${Z}--all${Q}\`.
|
|
625
656
|
- ${Z}list${Q}: Lists forks for the current branch with status, base commit, divergence and recent commits. Use ${Z}--short${Q} for compact output.
|
|
626
657
|
- ${Z}remove <alias>${Q}: Removes the forked worktree and cleans up the directory.
|
|
658
|
+
- ${Z}remove -r|--recursive${Q}: Removes every fork for the current branch.
|
|
627
659
|
|
|
628
|
-
${Y+
|
|
660
|
+
${Y+d("SAFETY AND NOTES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
629
661
|
Joining cherry-picks commits into origin; conflicts will prompt for resolve/continue in a TTY or print manual steps in non-interactive shells. Removing a fork will also delete the worktree directory when forced.
|
|
630
|
-
`,Math.min(100,
|
|
631
|
-
${Y}${C} parallel fork ${Z}<alias> [--move|--mirror] [--no-init[=submodule,pkg]]${Q}
|
|
662
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Manage temporary forked worktrees: create, list, join, open and remove.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
663
|
+
${Y}${C} parallel fork ${Z}<alias> [ref] [-b|-B <branch>] [--move|--mirror] [--no-init[=submodule,env,pkg]]${Q}
|
|
632
664
|
${Y}${C} parallel list${Q}
|
|
633
665
|
${Y}${C} parallel open ${Z}<alias|origin> [-c|--copy]${Q}
|
|
634
666
|
${Y}${C} parallel switch ${Z}<alias|origin> [-c|--copy]${Q}
|
|
635
|
-
${Y}${C} parallel join ${Z}<alias> [--keep|--all]${Q}
|
|
667
|
+
${Y}${C} parallel join ${Z}<alias> [--keep|--all|-i|--interactive]${Q}
|
|
636
668
|
${Y}${C} parallel join ${Z}-r|--recursive [--keep]${Q}
|
|
637
669
|
${Y}${C} parallel remove ${Z}<alias>${Q}
|
|
670
|
+
${Y}${C} parallel remove ${Z}-r|--recursive${Q}
|
|
638
671
|
|
|
639
672
|
Examples:
|
|
640
673
|
${Y}${C} parallel fork feature-x --move ${Q+Z}# Create fork and optionally move changes${Q}
|
|
674
|
+
${Y}${C} parallel fork feature-x deadbeef ${Q+Z}# Create fork from a ref${Q}
|
|
675
|
+
${Y}${C} parallel fork feature-x -b feature-x ${Q+Z}# Create fork on a local branch${Q}
|
|
676
|
+
${Y}${C} parallel fork feature-x -B feature-x ${Q+Z}# Recreate the fork branch${Q}
|
|
641
677
|
${Y}${C} parallel fork feature-x --no-init ${Q+Z}# Skip all init behaviors${Q}
|
|
642
678
|
${Y}${C} parallel fork feature-x --no-init=pkg ${Q+Z}# Skip package installs only${Q}
|
|
679
|
+
${Y}${C} parallel fork feature-x --no-init=env ${Q+Z}# Skip env file copy${Q}
|
|
643
680
|
${Y}${C} parallel list --short ${Q+Z}# Compact output with recent commits${Q}
|
|
644
681
|
${Y}${C} parallel join feature-x --all ${Q+Z}# Merge fork back into origin${Q}
|
|
645
|
-
${Y}${C} parallel join -
|
|
682
|
+
${Y}${C} parallel join feature-x -i ${Q+Z}# Preview and pick commits${Q}
|
|
683
|
+
${Y}${C} parallel join -r ${Q+Z}# Merge all forks back into origin${Q}
|
|
684
|
+
${Y}${C} parallel remove -r ${Q+Z}# Remove all forks for this branch${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},OF={$root:{fork:["--move","--mirror","--no-init","-b","-B"],list:{},open:YC,switch:ZC,join:QC,remove:JC,help:{}}}});async function CC(){let Y=await O0(),Z=NF(FY),Q=[],J="";j(U("Dim")+`# GDX Configuration
|
|
646
685
|
# read from ${Y.getConfigPath()}
|
|
647
686
|
# (api keys stored separately)
|
|
648
|
-
`+
|
|
649
|
-
`;if(
|
|
650
|
-
`,
|
|
687
|
+
`+U());for(let{key:z}of Z){let K=z.split("."),X=K.slice(0,-1).join("."),H=K[K.length-1];if(!Q.includes(X)){if(Q.length>0)J+=`
|
|
688
|
+
`;if(X){let L=M9[X];if(J+=`${U("Magenta")+U("Bright")}[${X}]${U()}
|
|
689
|
+
`,L)J+=`${U("Dim")}# ${L.split(`
|
|
651
690
|
`).join(`
|
|
652
|
-
# `)}${
|
|
653
|
-
`}Q.push(
|
|
654
|
-
`:`${
|
|
655
|
-
`;if(Q[Q.length-1]==="")J=
|
|
656
|
-
`+J;else J+=
|
|
691
|
+
# `)}${U()}
|
|
692
|
+
`}Q.push(X)}let W=Y.get(z);if(W===void 0&&L6.includes(z))W=await Y.getSecure(z);let q=Y.isDefault(z),G=M9[z]||"",$="",B=!1;switch(typeof W){case"boolean":$=g(W,{color:!0});break;case"number":$=g(W,{color:!0});break;case"string":if(H.toLowerCase().includes("key"))$=g(cY(W,20,"mid",-1),{color:!0});else $=g(W,{color:!0});break;case"undefined":case"object":if(W==null)B=!0,$=g(null,{color:!0});break;default:$=String(W)}let V=q?"":` ${U()+U("Yellow")+U("Italic")}[Modified]${U()+U("Dim")}`,F=G?` ${U("Dim")}#${V} ${G}${U()}`:"",M=B?`${U("Dim")}# ${U("Cyan")+H+U("White")} = ${$}${F}${U()}
|
|
693
|
+
`:`${U("Cyan")+H+U()} = ${$}${F}
|
|
694
|
+
`;if(Q[Q.length-1]==="")J=M+`
|
|
695
|
+
`+J;else J+=M}return j(J,""),0}async function AC(Y){let Z=await O0(),Q=Y.args[1];if(!Q)return R.error("Missing configuration key","gdx-config"),1;let J=Z.get(Q);if(J===void 0&&L6.includes(Q))J=await Z.getSecure(Q);if(J===void 0)return R.warn(`Key '${Q}' is not set`,"gdx-config"),1;return j(String(J)),0}async function kC(Y){let Z=await O0(),Q=Y.args[1],J=Y.args[2];if(!Q||J===void 0)return R.error("Usage: gdx gdx-config <key> <value>","gdx-config"),1;let z=Z.get(Q),K=J;if(typeof z==="number"){let H=Number(J);if(isNaN(H))return R.error(`Expected a number for '${Q}', got '${J}'`,"gdx-config"),1;K=H}else if(typeof z==="boolean")K=J.toLowerCase()==="true";await Z.set(Q,K),await Z.save();let X=Q.toLowerCase().includes("key")?cY(String(K),20,"mid",-1):K;return j(`${U("Green")}Configuration updated: ${Q} = ${X}${U()}`),0}async function mz(Y){let Z=Y.args[1]?.toLowerCase(),{match:Q}=P0(Z,["list","path"]);if(Q==="list")return await CC();else if(Q==="path"){let J=await O0();return j(J.getConfigPath()),0}else if(Y.args.length===2)return await AC(Y);else if(Y.args.length===3)return await kC(Y);else return j(fY(`${U("Cyan")}Usage:${U()}
|
|
657
696
|
gdx gdx-config list - List all configuration
|
|
658
697
|
gdx gdx-config path - Show config file path
|
|
659
698
|
gdx gdx-config <key> - Get configuration value
|
|
660
|
-
gdx gdx-config <key> <value> - Set configuration value`)),0}function
|
|
661
|
-
${Y+
|
|
699
|
+
gdx gdx-config <key> <value> - Set configuration value`)),0}function NF(Y,Z=""){let Q=[];for(let J in Y){let z=Z?`${Z}.${J}`:J,K=Y[J];if(K!==null&&typeof K==="object"&&!Array.isArray(K))Q.push(...NF(K,z));else Q.push({key:z,value:K})}return Q}var MF,DF;var b5=O(()=>{xz();H0();w1();D9();L0();D0();W0();v0();A0();MF={long:()=>{let Y=U("Bright"),Z=U();return o(`
|
|
700
|
+
${Y+d("GDX-CONFIG",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
662
701
|
View and modify gdx configuration.
|
|
663
702
|
|
|
664
|
-
${Y+
|
|
703
|
+
${Y+d("OVERVIEW",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
665
704
|
Manage gdx settings stored in the configuration file. The command supports listing all config values, getting the path to the currently loaded config file, and getting/setting individual keys. API keys and sensitive values are masked when displayed.
|
|
666
705
|
|
|
667
|
-
${Y+
|
|
706
|
+
${Y+d("COMMANDS",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
668
707
|
- list: Prints flattened configuration with defaults and modified markers.
|
|
669
708
|
- path: Prints the path to the active config file used by gdx.
|
|
670
709
|
- <key> [value]: Get or set a config key. When setting, types are coerced based on the existing default value where possible.
|
|
671
|
-
`,Math.min(100,
|
|
710
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"View or modify gdx configuration settings.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
672
711
|
${Y}${C} gdx-config list${Q}
|
|
673
712
|
${Y}${C} gdx-config path${Q}
|
|
674
713
|
${Y}${C} gdx-config ${Z}<key> [value]${Q}
|
|
675
714
|
|
|
676
715
|
Examples:
|
|
677
716
|
${Y}${C} gdx-config list ${Q+Z}# List all config keys and values${Q}
|
|
678
|
-
${Y}${C} gdx-config editor.code true ${Q+Z}# Set value for a key${Q}`,Math.min(100,
|
|
679
|
-
`);try{let G=await
|
|
680
|
-
`),!
|
|
681
|
-
`);if(
|
|
717
|
+
${Y}${C} gdx-config editor.code true ${Q+Z}# Set value for a key${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},DF={$root:["list","path"]}});import EC from"path";import xC from"crypto";function _F(Y){return xC.createHash("sha256").update(Y).digest("hex").slice(0,16)}async function SC(Y){j("");let Z=d0({message:"learning this repo's commit style...",animateGradient:!0});try{let J=(await S`${Y} log --no-merges -n 10 --format=%B%x00`).stdout.split("\x00").map((H)=>H.trim()).filter((H)=>H.length>0);if(J.length===0)return Z.stop(),{guideline:null,historyCount:0};let z=J.slice(0,Math.min(10,J.length)),X=await(await S8()).generate({prompt:mV(z),temperature:0.2,reasoning:"medium"});return Z.stop(),{guideline:X.trim(),historyCount:z.length}}catch(Q){return Z.stop(),R.warn(`Failed to learn commit guidelines: ${g(Q)}`,"commit"),{guideline:null,historyCount:0}}}async function PC(Y,Z){let Q=await B0(),J=await v7(Y),z=await g$(Y),K=n0(J),X=Z.get("commit.guidelineCacheDays",30),H=X*24*60,W=z?_F(`remote:${z}`):"",q=_F(`path:${K}`),G=W?`commit.repoGuidelines.${W}`:"",$=`commit.repoGuidelines.${q}`;if(G){let N=await Q.get(G);if(N)return R.debug(`Using cached commit guidelines for remote ${z}`,"commit"),N}let B=await Q.get($);if(B){if(G)await Q.set(G,B,{maxAgeMinutes:H}),R.debug(`Promoted commit guidelines cache to remote ${z}`,"commit");else R.debug(`Using cached commit guidelines for ${K}`,"commit");return B}let{guideline:V,historyCount:F}=await SC(Y);if(!V||F===0)return R.warn("No commit history found in this repository. Falling back to comprehensive format.","commit"),null;if(F<5)R.warn(`Only ${F} commit(s) found in history. The learned guidelines may be less accurate.`,"commit");let M=G||$;await Q.set(M,V,{maxAgeMinutes:H});let L=G?`remote ${z}`:K;return R.debug(`Cached commit guidelines for ${L} (${X} days)`,"commit"),V}async function vC(Y){let{git$:Z,args:Q}=Y,J=["auto","--no-commit","-nc","--copy","-cp","--yes","-y"],z=Q.slice(1).filter((G)=>!J.includes(G)),K=await O0(),X=K.get("llm.showThinking",!0),H=K.get("commit.commitPattern","inherit"),W=(await S`${Z} diff --cached HEAD`).stdout;if(!W||W.trim().length===0)return j(`${U("Red")}No staged changes found. Please stage your changes before generating a commit message.${U()}`),1;let q;if(H==="inherit"){let G=await PC(Z,K);if(G)q=gV(W,G);else q=Sz(W)}else q=Sz(W);j(`${U("Cyan")}Generating commit message based on staged changes...${U()}
|
|
718
|
+
`);try{let G=await S8(),$=d0({message:"connecting...",animateGradient:!1}),B=G.streamGenerate({prompt:q,temperature:0.14,reasoning:"low"}),V="",F=!1,M=!1,L="";for await(let A of B){if(A.error)return $.stop(),R.error(A.error.message,"commit"),1;if(A.thinkingChunk){if(!M){if(M=!0,$.options.animateGradient=!0,!X)$.options.message="reasoning..."}if(X)L=(L+A.thinkingChunk.replace(/[\n\r]/g,"")).slice(-32),$.options.message=`reasoning... ${L.trim()}`;continue}if(A.chunk){if(!F)F=!0,$.stop(),j(`${U("Cyan")}Generated Commit Message:${U()}`);j(A.chunk,""),V+=A.chunk}}if(j(`
|
|
719
|
+
`),!V)return R.error("Unable to generate commit message (empty response).","commit"),1;V=V.replace(/(^\s*["'`]*|["'`]*\s*$)/g,"");let N=V.indexOf(`
|
|
720
|
+
`);if(N!==-1){let A=V.slice(0,N),x=V.slice(N+1).trim();V=A+`
|
|
682
721
|
|
|
683
|
-
`+
|
|
684
|
-
${Y+
|
|
722
|
+
`+o(x,72,{mode:"softboundary",redundancyLv:-1})}let _=Q.includes("--no-commit")||Q.includes("-nc"),I=Q.includes("--yes")||Q.includes("-y");if(_){if(I)R.warn("Ignoring --yes because --no-commit was requested.","commit");if(Q.includes("--copy")||Q.includes("-cp"))if(await E7(V))j(`${U("Cyan")}(message has been copied to clipboard)${U()}`);else R.warn("(failed to copy to clipboard)","commit");return 0}if(I){let A=V.split(/\n{2,}/).filter((E)=>E.trim().length>0),x=[];for(let E of A)x.push("-m",E);return await V0`${Z} commit ${x} ${z}`.catch(k1),0}let w=EC.join(O1,`gdx_commit_msg_${Date.now()}.txt`);return await Y1(w,V,"utf8"),await V0`${Z} commit -F ${w} --edit ${z}`.catch(k1),await c8(w).catch(k1),0}catch(G){return R.error(g(G,{color:!0}),"commit"),1}}var LF,wF;var uz=O(()=>{o0();H0();h0();L0();Ez();D0();Pz();W0();A0();v0();w1();S6();K1();LF={auto:vC},wF={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
723
|
+
${Y+d("COMMIT AUTO",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
685
724
|
Generate a commit message from staged changes using an LLM.
|
|
686
725
|
|
|
687
|
-
${Y+
|
|
726
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
688
727
|
Analyze the staged diff and ask the configured LLM provider to produce a well-formed commit message (title and body). The generated text is streamed for interactive feedback; you may choose to commit it automatically or inspect/copy it first.
|
|
689
728
|
|
|
690
|
-
${Y+
|
|
691
|
-
Use ${Z}--no-commit (-nc)${Q} to prevent creating the commit (message will be printed). Use ${Z}--copy (-cp)${Q} in combination with --no-commit to copy the message to the clipboard. The tool writes a temporary message file when performing an
|
|
729
|
+
${Y+d("FLAGS AND BEHAVIOR",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
730
|
+
Use ${Z}--no-commit (-nc)${Q} to prevent creating the commit (message will be printed). Use ${Z}--copy (-cp)${Q} in combination with --no-commit to copy the message to the clipboard. Use ${Z}--yes (-y)${Q} to commit immediately without writing a temporary message file or opening an editor (ignored when --no-commit is set). The tool writes a temporary message file when performing an interactive commit.
|
|
692
731
|
|
|
693
|
-
${Y+
|
|
732
|
+
${Y+d("REQUIREMENTS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
694
733
|
A non-empty staged diff is required; the command will error if there are no staged changes.
|
|
695
|
-
`,Math.min(100,
|
|
696
|
-
${Y}${C} commit auto ${Z}[--no-commit] [--copy]${Q}
|
|
734
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Auto-generate a commit message from staged changes using an LLM.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
735
|
+
${Y}${C} commit auto ${Z}[--no-commit|-nc] [--copy|-cp] [--yes|-y]${Q}
|
|
697
736
|
|
|
698
737
|
Examples:
|
|
699
738
|
${Y}${C} commit auto ${Q+Z}# Generate and commit using LLM-generated message${Q}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
`),j(`${
|
|
703
|
-
`)
|
|
704
|
-
|
|
705
|
-
${
|
|
706
|
-
${
|
|
707
|
-
${
|
|
739
|
+
${Y}${C} commit auto --no-commit ${Q+Z}# Print generated message without committing${Q}
|
|
740
|
+
${Y}${C} commit auto --no-commit --copy ${Q+Z}# Copy generated message to clipboard${Q}
|
|
741
|
+
${Y}${C} commit auto --yes ${Q+Z}# Commit immediately without editing${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}}});import dz from"path";async function pz(Y){let{git$:Z,args:Q}=Y,J=Q[1]?.toLowerCase(),{match:z}=P0(J,["list","pardon"]),[K,X]=await Promise.all([S`${Z} rev-parse --abbrev-ref HEAD`.then((A)=>A.stdout.trim().replace(/\//g,"-")),T1(Z)]),H=dz.basename(X),W=O1,q=`${H}_${K}_backup_*.patch`,G=`${H}_${K}_backup_`,$=".patch";if(z==="list"){j(`${U("Cyan")}Project:${U()} ${H}`),j(`${U("Cyan")}Branch:${U()} ${K}`),j(`${U("Cyan")}Backup location:${U()} ${W}`),j(`${U("Cyan")}Use \`git clear pardon\` to restore the latest backup.${U()}
|
|
742
|
+
`),j(`${U("Cyan")}Looking for backup patch files matching:${U()} ${q}
|
|
743
|
+
`);let A=await jF(W,G,".patch");if(A.length===0)return j(`${U("Yellow")}No backup patch files found for project '${H}' on branch '${K}'.${U()}`),0;let x=new Date;for(let E=0;E<A.length;E++){let h=A[E],u=(x.getTime()-h.stats.mtime.getTime())/i8,f=h.stats.mtime.toISOString().replace("T"," ").split(".")[0],m=U("Dim");if(h.stats.mtime.toDateString()===x.toDateString())m=U("White");else if(u>=6)m=U("Red");j(`${m}backup@${E}: ${f} - ${h.name}${U()}`)}return 0}let B=await jF(W,G,".patch"),V=new Date;V.setDate(V.getDate()-7);for(let A of B)if(A.stats.mtime<V)try{YQ(A.path),B.splice(B.indexOf(A),1)}catch(x){R.error(`Failed to delete old backup file: ${A.path}
|
|
744
|
+
${g(x,{color:!0})}`,"clear")}if(z==="pardon"){if((await S`${Z} diff --cached --name-only`).stdout.length>0||(await S`${Z} diff --name-only`).stdout.length>0)return R.error("Working Directory is dirty, aborting pardon to prevent unintended data loss. Please clear your workspace first.","clear"),await V0`${Z} status`,1;if(B.length===0)return R.error(`No backup patch file found for branch '${K}'. Pardon failed.`,"clear"),1;let E=B[0],h=new Date;if(h.setDate(h.getDate()-1),E.stats.mtime<h){if(R.warn("Latest backup patch file is older than 1 day. Do you want to proceed with the pardon? (y/n)","clear"),(await NZ("Type 'y' to confirm: ")).toLowerCase()!=="y")return R.error("Pardon aborted.","clear"),1}try{await V0`${Z} apply ${E.path}`,YQ(E.path),j(`${U("Cyan")}Pardon applied successfully from backup: ${U("Bright")}${E.path}${U()}`),await V0`${Z} status`}catch(u){return R.error(`Failed to apply patch. Pardon aborted.
|
|
745
|
+
${g(u,{color:!0})}`,"clear"),1}return 0}let[F,M,L]=await Promise.all([S`${Z} diff --cached --name-only`.then((A)=>A.stdout.length>0),S`${Z} diff --name-only`.then((A)=>A.stdout.length>0),S`${Z} ls-files --others --exclude-standard`.then((A)=>A.stdout.length>0)]);if(!F&&!M&&!L)return j(`${U("Cyan")}No changes to clear. Working directory is clean.${U()}`),await V0`${Z} status`,0;let N=new Date().toISOString().replace(/[-:T.]/g,"").slice(0,14),_=`${H}_${K}_backup_${N}.patch`,I=dz.join(W,_);await V0`${Z} add -A`;let w=await S`${Z} diff --cached --binary`;return r6(I,w.stdout),j(`${U("Cyan")}Backup of all changes saved to: ${U("Bright")}${I}${U()}
|
|
746
|
+
${U("Cyan")}(\`git clear pardon\` to undo)${U()}`),await V0`${Z} reset --hard HEAD`,await V0`${Z} clean -fd`,await V0`${Z} status`,0}async function jF(Y,Z,Q){let z=b1(Y).filter((X)=>X.startsWith(Z)&&X.endsWith(Q));return(await Promise.all(z.map(async(X)=>{let H=dz.join(Y,X),W=await e6(H);return{name:X,path:H,stats:W}}))).sort((X,H)=>H.stats.mtime.getTime()-X.stats.mtime.getTime())}var TF,IF;var h5=O(()=>{o0();H0();h0();L0();W0();D0();W0();A0();v0();K1();TF={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
747
|
+
${Y+d("CLEAR",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
708
748
|
Safely backup and clear local working changes.
|
|
709
749
|
|
|
710
|
-
${Y+
|
|
750
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
711
751
|
Creates a patch file containing the current unstaged, staged, and untracked changes, stores it in the OS temporary directory and then resets the working tree to a clean HEAD via \`${Z}git reset --hard${Q}\` and \`${Z}git clean -fd${Q}\`. The latest patch is kept so you can restore it with \`${Z}${C} clear pardon${Q}\`.
|
|
712
752
|
|
|
713
|
-
${Y+
|
|
753
|
+
${Y+d("SUBCOMMANDS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
714
754
|
- list: Show available backup patch files for this project/branch.
|
|
715
755
|
- pardon: Restore the most recent backup patch.
|
|
716
756
|
|
|
717
|
-
${Y+
|
|
757
|
+
${Y+d("SAFETY",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
718
758
|
All files (tracked and untracked) are backed up before clearing. Pardon requires a clean working directory.
|
|
719
|
-
`,Math.min(100,
|
|
759
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Backup and clear local changes, with a restore (pardon) option.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
720
760
|
${Y}${C} clear ${Z}[list|pardon]${Q}
|
|
721
761
|
|
|
722
762
|
Examples:
|
|
723
763
|
${Y}${C} clear ${Q+Z}# Create backup patch and clear working tree${Q}
|
|
724
764
|
${Y}${C} clear list ${Q+Z}# Show recent backup patches${Q}
|
|
725
|
-
${Y}${C} clear pardon ${Q+Z}# Restore the latest backup patch${Q}`,Math.min(100,
|
|
726
|
-
`);for(let Q of Z){let J=Y.entryMeta[Q];if(!J)continue;let z=J.expiresAt-Date.now(),
|
|
727
|
-
${Y+
|
|
765
|
+
${Y}${C} clear pardon ${Q+Z}# Restore the latest backup patch${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},IF={$root:["list","pardon"]}});import yC from"path";async function cz(Y){let Z=Y.args[1]?.toLowerCase(),{match:Q,candidates:J}=P0(Z,["list","prune","reset","delete","disable","enable"]);switch(Q){case"list":return await bC();case"prune":return await fC();case"reset":return await hC();case"delete":return await gC(Y.args.slice(2));case"disable":return await CF(!1);case"enable":return await CF(!0);default:if(J&&J.length>0)R.warn(`Ambiguous command '${Z}'. Did you mean one of: ${J.join(", ")}?`);return j(nz.usage()),0}}async function fC(){let Y=null;try{Y=await lz()}catch(z){return R.error(g(z,{color:!0}),"cache"),1}if(!Y)return j(`${U("Yellow")}No valid cache found. Nothing to prune.${U()}`),0;let Z=Date.now(),Q=Object.entries(Y.entryMeta).filter(([,z])=>Z>z.expiresAt).map(([z])=>z),J=0;for(let z of Q)if(mC(Y,z))J++;if(Y.meta.lastPruneAt=Z,J>0)Y.meta.updatedAt=Z;if(await AF(Y),k7(),J>0)j(`${U("Green")}Pruned ${J} expired cache entries.${U()}`);else j(`${U("Cyan")}No expired cache entries found.${U()}`);return 0}async function bC(){let Y=null;try{Y=await lz()}catch(Q){return R.error(g(Q,{color:!0}),"cache"),1}if(!Y)return j(`${U("Yellow")}No valid cache found. Nothing to list.${U()}`),0;let Z=Object.keys(Y.entryMeta).sort((Q,J)=>{let z=Y.entryMeta[Q],K=Y.entryMeta[J];return(z?.expiresAt??0)-(K?.expiresAt??0)||Q.localeCompare(J)});if(Z.length===0)return j(`${U("Yellow")}No cache keys found.${U()}`),0;j(`${U("Cyan")}Cache:${U()} ${M1} ${U("Dim")}(${Z.length} keys)${U()}
|
|
766
|
+
`);for(let Q of Z){let J=Y.entryMeta[Q];if(!J)continue;let z=J.expiresAt-Date.now(),K=z<=0?"expired":pY.getTimeFromMS(z).modern(),X=U("Green");if(z<=0)X=U("Dim");else if(z<3600000)X=U("Red");else if(z<43200000)X=U("Yellow");let H=uC(Y.data,Q),W=dC(H);j(`${U("Cyan")}${Y6(Q,24,{align:"left",redundancyLv:-1,overflow:"collapse"})}${U()} ttl=${X}${Y6(K,12,{align:"left",redundancyLv:-1,overflow:"visible"})}${U()} ${U("Dim")}preview=${W}${U()}`)}return 0}async function hC(){try{let Y=l(M1);if(await IK(M1,{force:!0,recursive:!0}),k7(),!Y)return j(`${U("Yellow")}No valid cache found. Nothing to delete.${U()}`),0;let Z=l(M1)?`${U("Yellow")}Cache file not removed: ${M1}${U()}`:`${U("Green")}Cache file deleted: ${M1}${U()}`;return j(Z),0}catch(Y){return R.error(g(Y,{color:!0}),"cache"),1}}async function gC(Y){if(Y.length===0)return R.error("Usage: gdx cache delete <key|prefix> [more...]","cache"),1;let Z=null;try{Z=await lz()}catch(X){return R.error(g(X,{color:!0}),"cache"),1}if(!Z)return j(`${U("Yellow")}No valid cache found. Nothing to delete.${U()}`),0;let Q=Object.keys(Z.entryMeta),J=new Set;for(let X of Y){let H=X.trim();if(!H)continue;let W=H.endsWith(".")?H.slice(0,-1):H,q=W.length>0?`${W}.`:"";for(let G of Q)if(G===W||q&&G.startsWith(q))J.add(G)}if(J.size===0)return j(`${U("Yellow")}No matching cache keys found.${U()}`),0;let z=Date.now(),K=0;for(let X of J){let H=Z.entryMeta[X];if(!H)continue;H.expiresAt=z-1,H.updatedAt=z,K++}if(K>0)return Z.meta.updatedAt=z,await AF(Z),k7(),j(`${U("Green")}Marked ${K} cache entries as expired.${U()}`),0;return j(`${U("Yellow")}No matching cache keys found.${U()}`),0}async function CF(Y){let Z=await O0();await Z.set("cache.enabled",Y),await Z.save();let Q=Y?"enabled":"disabled";return j(`${U("Green")}Cache ${Q}.${U()}`),0}async function lz(){try{let Y=await S0(M1,"utf-8"),Z=JSON.parse(Y);try{A7(Z)}catch{return null}if(!Z.meta.lastPruneAt)Z.meta.lastPruneAt=Z.meta.updatedAt||Date.now();return Z}catch(Y){if(a.from(Y).code==="ENOENT")return null;throw Y}}async function AF(Y){let Z=yC.dirname(M1);H1(Z,{recursive:!0}),await Y1(M1,JSON.stringify(Y),"utf-8")}function mC(Y,Z){if(!Y.entryMeta[Z])return!1;delete Y.entryMeta[Z];let Q=Z.split("."),J=[],z=Y.data;for(let K of Q)if(z&&typeof z==="object"&&K in z)J.push({obj:z,key:K}),z=z[K];else return!1;if(J.length>0){let K=J[J.length-1];delete K.obj[K.key]}for(let K=J.length-2;K>=0;K--){let{obj:X,key:H}=J[K],W=X[H];if(W&&typeof W==="object"&&Object.keys(W).length===0)delete X[H];else break}return!0}function uC(Y,Z){let Q=Z.split("."),J=Y;for(let z of Q)if(J&&typeof J==="object"&&z in J)J=J[z];else return;return J}function dC(Y){if(typeof Y==="string")return`'${l4(Y.replace(/\s+/g," "),60,"mid",-1)}'`;if(typeof Y==="number"||typeof Y==="boolean"||Y==null)return String(Y);if(Array.isArray(Y)){let Z=l4(g(Y,{color:!1}),60,"mid",-1);return`[${Y.length}] ${Z}`}if(typeof Y==="object")return`{...} ${l4(g(Y,{color:!1}),60,"mid",-1)}`;return l4(String(Y),60,"mid",-1)}var nz,kF;var g5=O(()=>{H0();S6();w1();W0();v0();A0();o0();D0();L0();j9();nz={long:()=>{let Y=U("Bright"),Z=U();return o(`
|
|
767
|
+
${Y+d("CACHE",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
728
768
|
Manually manage gdx cache entries and settings.
|
|
729
769
|
|
|
730
|
-
${Y+
|
|
770
|
+
${Y+d("COMMANDS",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
731
771
|
- list: Show cache keys, TTL, and a short value preview.
|
|
732
772
|
- prune: Remove expired entries from the cache file.
|
|
733
773
|
- reset: Delete the entire cache file.
|
|
734
774
|
- delete: Mark cache entries as expired by key or prefix.
|
|
735
775
|
- enable/disable: Toggle cache.enabled in gdx config.
|
|
736
|
-
`,Math.min(100,
|
|
776
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Manually manage gdx cache entries and settings.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
737
777
|
${Y}${C} cache prune${Q}
|
|
738
778
|
${Y}${C} cache reset${Q}
|
|
739
779
|
${Y}${C} cache list${Q}
|
|
@@ -747,67 +787,67 @@ Examples:
|
|
|
747
787
|
${Y}${C} cache reset ${Q+Z}# Delete cache file entirely${Q}
|
|
748
788
|
${Y}${C} cache delete git git.config ${Q+Z}# Expire by key/prefix${Q}
|
|
749
789
|
${Y}${C} cache disable ${Q+Z}# Turn caching off${Q}
|
|
750
|
-
`,Math.min(100,
|
|
751
|
-
`+
|
|
752
|
-
|
|
753
|
-
`+
|
|
754
|
-
`;let
|
|
755
|
-
`}if(
|
|
756
|
-
`}if(
|
|
757
|
-
`}),Q+=
|
|
758
|
-
`,Q}var
|
|
759
|
-
|
|
760
|
-
`+X(
|
|
761
|
-
`).filter((
|
|
762
|
-
Please resolve merge conflict markers.`),
|
|
763
|
-
Matched Pattern: ${
|
|
764
|
-
Content: ${E}`),
|
|
765
|
-
`).filter((
|
|
766
|
-
File size ${
|
|
767
|
-
Lint passed with ${
|
|
768
|
-
No problems found.`+
|
|
769
|
-
${Y+
|
|
790
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},kF={$root:["list","prune","reset","delete","enable","disable"]}});var PF={};o5(PF,{spellCheckDocument:()=>pC,prettyFormatIssues:()=>lC,getBundledDictionaryNames:()=>cC});async function SF(){return EF??=import("cspell-lib"),await EF}async function pC(...Y){return await(await SF()).spellCheckDocument(...Y)}async function cC(){return xF??=(async()=>{let Z=await(await SF()).getDefaultBundledSettingsAsync(),Q=new Set,J=[],z=(K)=>{if(!K||Q.has(K))return;Q.add(K),J.push(K)};return Z.dictionaryDefinitions?.forEach((K)=>z(K.name)),Z.dictionaries?.forEach((K)=>z(K)),J})(),xF}function lC(Y,Z){if(Y.issues.length===0)return U("Green")+"✓ No spelling issues found!"+U();let Q=U("Yellow")+`✗ Found ${Y.issues.length} spelling issue${Y.issues.length===1?"":"s"}:
|
|
791
|
+
`+U();Q+=U("Dim")+"─".repeat(60)+`
|
|
792
|
+
|
|
793
|
+
`+U();let J=U("Cyan"),z=U("Magenta"),K=U("Red")+U("Bright"),X=U("Dim"),H=U("Underline");return Y.issues.forEach((W,q)=>{let G=Z.substring(0,W.line.offset),$=G.length-G.replace(/\n/g,"").length,B=W.offset-W.line.offset;Q+=`${X}${q+1}.${U()} ${J}Line ${$+1}${U()}, ${z}Col ${B+1}${U()}: ${K}"${W.text}"${U()}
|
|
794
|
+
`;let V=W.line.text;if(V){let F=W.offset-W.line.offset,M=V.substring(0,F),L=V.substring(F+W.text.length);Q+=` ${M}${K+H}${W.text}${U()}${L}
|
|
795
|
+
`}if(W.suggestions?.length){let F=W.suggestions.slice(0,5).join(", ");Q+=` ${J}Suggestions:${U()} ${F}
|
|
796
|
+
`}if(q<Y.issues.length-1)Q+=`
|
|
797
|
+
`}),Q+=X+"─".repeat(60)+U()+`
|
|
798
|
+
`,Q}var EF=null,xF=null;var vF=O(()=>{H0()});async function iz(Y){let Q=B4().$,{git$:J}=Y;if(!await V4(J))return 1;let z=d0({message:"Initializing library..."}),{spellCheckDocument:K,prettyFormatIssues:X,getBundledDictionaryNames:H}=await Promise.resolve().then(() => (vF(),PF)),q=(await O0()).get("lint.maxFileSizeKb")||1024;z.options.message="Scanning commits...";let G="";try{let{stdout:N}=await Q`${J} rev-parse --abbrev-ref --symbolic-full-name @{u}`;G=N.trim()}catch{}let $="";if(G)$=`${G}..HEAD`;else z.stop(),R.warn("No upstream configured. Checking last commit only.","lint"),$="HEAD^..HEAD",z.start();let B=0,V=0,[F,M,L]=await Promise.all([Q`${J} log --pretty=format:"%s\n%b$$\$___SEP___\$$$" ${$}`.then((N)=>N.stdout).catch(()=>""),Q`${J} diff ${$}`.then((N)=>N.stdout).catch(()=>""),Q`${J} diff --name-only ${$}`.then((N)=>N.stdout).catch(()=>"")]);if(F){z.options.message="Checking commit message spelling...";let N=await H(),_=F.split("$$$___SEP___$$$").filter((I)=>I.trim());for(let[I,w]of _.entries()){z.start(!1);let A=await K({uri:"commit-message",text:w,languageId:"plaintext",locale:"en"},{generateSuggestions:!0,noConfigSearch:!0,unknownWords:"report-common-typos"},{dictionaries:N});if(A.issues.length===0)continue;z.stop(),V+=A.issues.length,yF("Spelling",`At HEAD~${I} found ${A.issues.length} potential spelling issue(s) in commit messages.
|
|
799
|
+
|
|
800
|
+
`+X(A,w))}}if(z.stop(),M){let N="",_=M.split(/^diff --git a\/.+$/m);for(let I of _){let w=I.split(`
|
|
801
|
+
`).filter((A)=>A.trim());if(N=w.slice(2,4).find((A)=>A.startsWith("+++ b/"))?.split(" b/")[1]||"unknown",/\n?\+?<{7}(?:[^\n]*\n)*\+?={7}(?:[^\n]*\n)*\+?>{7}/.test(M))fF("Conflict Markers",`File: ${N}
|
|
802
|
+
Please resolve merge conflict markers.`),B++;for(let A=3;A<w.length;A++){let x=w[A];if(x.startsWith("+")){let E=x.substring(1);for(let h of yK)if(h.test(E))fF("Sensitive Content",`File: ${N}
|
|
803
|
+
Matched Pattern: ${h}
|
|
804
|
+
Content: ${E}`),B++}}}}if(L){let _=L.split(`
|
|
805
|
+
`).filter((w)=>w.trim()).map(async(w)=>{try{let{stdout:A}=await Q`${J} cat-file -s HEAD:${w}`,x=parseInt(A.trim(),10);return{file:w,sizeBytes:x}}catch{return null}}),I=await Promise.all(_);for(let w of I){if(!w)continue;let{file:A,sizeBytes:x}=w;if(x/1024>q)yF("Size",`File: ${A}
|
|
806
|
+
File size ${Z6(x,2,1024)}B exceeds limit of ${q}KiB`),V++}}if(B>0)return R.error(`Lint failed with ${B} errors and ${V} warnings.`,"lint"),1;else if(V>0)return j(U("Yellow")+`
|
|
807
|
+
Lint passed with ${V} warnings.`+U()),0;else return j(U("Green")+`
|
|
808
|
+
No problems found.`+U()),0}function yF(Y,Z){Z=o(Z,100,{indent:" "}),j(U("BgYellow")+U("Bright")+U("White")+" LWARN "+U()+U("Invert")+` ${Y} ${U()+U("Yellow")} ${Z}`+U())}function fF(Y,Z){Z=o(Z,100,{indent:" "}),j(U("BgRed")+U("Bright")+U("White")+" LERROR "+U()+U("Invert")+` ${Y} ${U()+U("Red")} ${Z}`+U())}var bF,hF;var m5=O(()=>{H0();h0();L0();w1();K1();W0();D0();v0();A0();bF={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
809
|
+
${Y+d("LINT",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
770
810
|
Runs a set of linting checks on your outgoing commits (or the last commit if no upstream is configured).
|
|
771
811
|
|
|
772
|
-
${Y+
|
|
812
|
+
${Y+d("CHECKS PERFORMED",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
773
813
|
- Spelling: Checks for typos in commit messages using cspell.
|
|
774
814
|
- Sensitive Content: Scans for API keys, tokens, and private keys.
|
|
775
815
|
- Conflict Markers: Checks for leftover merge conflict markers.
|
|
776
816
|
- File Size: Warns if files exceed the configured size limit (default 1MB).
|
|
777
817
|
|
|
778
|
-
${Y+
|
|
818
|
+
${Y+d("CONFIGURATION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
779
819
|
You can configure the behavior in your ~/.gdx/.gdxrc.toml file or \`${Z}${C} gdx-config${Q}\`:
|
|
780
820
|
[lint]
|
|
781
821
|
onPushBehavior = "off" | "error" | "warning" # Default: "off"
|
|
782
822
|
maxFileSizeKb = 1024 # Default: 1024 KB
|
|
783
|
-
`,Math.min(100,
|
|
823
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Lint outgoing commits for format, spelling, sensitive data, and more.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
784
824
|
${Y}${C} lint${Q}
|
|
785
825
|
|
|
786
826
|
Examples:
|
|
787
|
-
${Y}${C} lint ${Q+Z}# Run lint checks on outgoing commits${Q}`,Math.min(100,
|
|
788
|
-
`),z=[];for(let
|
|
789
|
-
Error: ${z.message}`,"status"),
|
|
790
|
-
${z.toString({color:!0})}`,"status"),""}}function
|
|
791
|
-
`),await
|
|
792
|
-
${
|
|
793
|
-
${
|
|
794
|
-
`);let
|
|
795
|
-
`)}return 0}catch(
|
|
796
|
-
${
|
|
797
|
-
${Y+
|
|
827
|
+
${Y}${C} lint ${Q+Z}# Run lint checks on outgoing commits${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},hF={$root:[]}});import az from"path";async function nC(Y){try{let Q=(await S`${Y} config --file .gitmodules --get-regexp path`).stdout.trim();if(!Q)return[];let J=Q.split(`
|
|
828
|
+
`),z=[];for(let K of J){if(!K.trim())continue;let X=K.match(/^submodule\.(.+?)\.path\s+(.+)$/);if(X){let H=X[2];z.push({path:H,status:" "})}}return z}catch{return[]}}async function iC(Y,Z,Q){try{return(await S`${Y} -C ${Z} ${aC(Q)}`).stdout}catch(J){let z=a.from(J);return R.warn(`Failed to get status for submodule ${Z}.
|
|
829
|
+
Error: ${z.message}`,"status"),R.debug(`Failed to get status for submodule ${Z}.
|
|
830
|
+
${z.toString({color:!0})}`,"status"),""}}function aC(Y){let Z=["status",...Y];if(l0.supportsColor<=0)return Z;if(oC(Y)||sC(Y)||rC(Y))return Z;return["-c","color.ui=always",...Z]}function oC(Y){return Y.some((Z)=>Z==="--no-color"||Z==="--color=never")}function sC(Y){return Y.some((Z)=>Z==="--porcelain"||Z.startsWith("--porcelain="))}function rC(Y){return Y.some((Z)=>Z==="--color"||Z.startsWith("--color="))}async function oz(Y){let{git$:Z,args:Q}=Y;if(!(Q.includes("-r")||Q.includes("--recursive")))return await V0`${Z} status ${Q.slice(1)}`.then((K)=>K.exitCode??0);let z=Q.slice(1).filter((K)=>K!=="-r"&&K!=="--recursive");try{let K=await T1(Z),X=process.cwd();j(`${U("Cyan")}${U("Bright")}━━━ Repository Root${U()}${U("Dim")} (${az.relative(X,K)||"."})${U()}
|
|
831
|
+
`),await V0`${Z} status ${z}`;let H=await nC(Z);if(H.length===0)return j(`
|
|
832
|
+
${U("Dim")}No submodules found.${U()}`),0;for(let W of H){let q=az.resolve(K,W.path),G=az.relative(X,q);j(`
|
|
833
|
+
${U("Cyan")}${U("Bright")}━━━ Submodule: ${W.path}${U()}${U("Dim")} (${G})${U()}
|
|
834
|
+
`);let $=await iC(Z,q,z);if($)j($);else j(`${U("Dim")}Unable to get status for this submodule.${U()}
|
|
835
|
+
`)}return 0}catch(K){return R.error(`Failed to get recursive status.
|
|
836
|
+
${K}`,"status"),1}}var gF,mF;var u5=O(()=>{H0();h0();L0();W0();A0();D0();v0();K1();gF={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
837
|
+
${Y+d("STATUS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
798
838
|
Show the working tree status for the repository and optionally all submodules.
|
|
799
839
|
|
|
800
|
-
${Y+
|
|
840
|
+
${Y+d("OVERVIEW",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
801
841
|
\`${Z}${C} status${Q}\` is a wrapper around \`${Z}git status${Q}\` with added support for recursive submodule status checking. When the \`${Z}--recursive${Q}\` or \`${Z}-r${Q}\` flag is used, it will show the status of the main repository followed by the status of each submodule.
|
|
802
842
|
|
|
803
|
-
${Y+
|
|
843
|
+
${Y+d("RECURSIVE MODE",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
804
844
|
When \`${Z}--recursive${Q}\` or \`${Z}-r${Q}\` is specified:
|
|
805
845
|
- Shows status of the main repository first
|
|
806
846
|
- Then shows status for each submodule with clear headers
|
|
807
847
|
- Displays both absolute submodule paths and paths relative to your current directory
|
|
808
848
|
- All other \`${Z}git status${Q}\` flags are passed through to each status check
|
|
809
849
|
|
|
810
|
-
${Y+
|
|
850
|
+
${Y+d("EXAMPLES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
811
851
|
${Z}${C} status --recursive${Q}
|
|
812
852
|
Show status for repository and all submodules
|
|
813
853
|
|
|
@@ -819,166 +859,187 @@ ${Z}${C} status -r --short${Q}
|
|
|
819
859
|
|
|
820
860
|
${Z}${C} status --recursive --porcelain${Q}
|
|
821
861
|
Show porcelain format status recursively
|
|
822
|
-
`,Math.min(100,
|
|
862
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Show working tree status with optional recursive submodule support",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
823
863
|
${Y}${C} status ${Z}[--recursive|-r] [<git-status-options>]${Q}
|
|
824
864
|
${Y}${C} s ${Z}[--recursive|-r] [<git-status-options>]${Q}
|
|
825
865
|
|
|
826
866
|
Examples:
|
|
827
867
|
${Y}${C} status --recursive ${Q+Z}# Show status for repo and all submodules${Q}
|
|
828
|
-
${Y}${C} s -r --short ${Q+Z}# Short format with submodules${Q}`,Math.min(100,
|
|
868
|
+
${Y}${C} s -r --short ${Q+Z}# Short format with submodules${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},mF={$root:{$allOf:["-r","--recursive","--short","--porcelain","--branch","--long"]}}});import sz from"fs";import gY from"path";async function rz(){let Y,Z=!1,Q=process.argv[0].endsWith("node")||process.argv[0].endsWith("node.exe"),J=process.argv[0].endsWith("bun")||process.argv[0].endsWith("bun.exe"),z=process.execPath.toLowerCase()!==process.argv[0].toLowerCase();if(!z){let W=process.argv[1],q=gY.dirname(W),G=[gY.join(q,"native/install.json"),gY.join(q,"../dist/native/install.json"),gY.join(q,"../native/install.json")];for(let $ of G)if(sz.existsSync($)){Y=$;break}if(!Y)Y=gY.join(q,"native/install.json")}else Y=gY.join(gY.dirname(process.execPath),"install.json");let K=null;if(sz.existsSync(Y))try{let W=JSON.parse(sz.readFileSync(Y,"utf8"));K=g(W,{color:!0})}catch(W){let q=a.from(W);R.error(`Error reading install.json: ${q.message}`,"doctor"),R.debug(q.toString(),"doctor"),Z=!0}else if(z)R.warn(`No native install info found at ${Y}`,"doctor"),Z=!0;j(`Version: ${U("Cyan")+E1+U()}`),j(`Platform: ${U("Magenta")+process.platform} (${process.arch})`+U()),j(`Runtime: ${U("Magenta")+(J?"Bun":Q?"Node":"Unknown")+(z?" (Native)":"")+U()}`),j(`Terminal color support index: ${U("Cyan")+l0.supportsColor+U()+U("Dim")} ${l0.supportsColor===0?"(No color)":l0.supportsColor===1?"(16 colors)":l0.supportsColor===2?"(8bit color)":l0.supportsColor===3?"(24bit True color)":""}`+U()),j(`TTY mode: ${U("Cyan")+(process.stdout.isTTY?"Yes":"No")+U()}`);try{let W=await p1("bun",["--version"]);j(`Bun: ${U("Cyan")+W.stdout.trim()+U()}`+(!J?U("Dim")+" (inactive)"+U():""))}catch{j("Bun: Not found")}try{let W=await p1("node",["--version"]);j(`Node: ${U("Cyan")+W.stdout.trim()+U()}`+(!Q?U("Dim")+" (inactive)"+U():""))}catch{j("Node: Not found")}j(`Installation mode: ${z?U("Green")+"Native"+U():U("Yellow")+"Interpreted"+U()}`),j(`Executable path: ${U("Cyan")+process.execPath+U()}`),j(`Log file path: ${U("Cyan")+s6(R.logFile,R.logFile)+U()}`);let X=await B0();j(`Cache file path: ${U("Cyan")+s6(X.cachePath,X.cachePath)+U()}`);try{let W=await p1("git",["--version"]);j(`Git: ${U("Cyan")+W.stdout.trim()+U()}`);let q=process.platform==="win32"?"where":"which",$=(await p1(q,["git"])).stdout.trim().replaceAll(`
|
|
829
869
|
`,`
|
|
830
|
-
- `);j(`Git path: ${U
|
|
831
|
-
-
|
|
832
|
-
Native Install Info: ${
|
|
833
|
-
Actionable next steps:`+
|
|
834
|
-
${Y+
|
|
870
|
+
- `);j(`Git path: ${$?U("Green")+`
|
|
871
|
+
- `+$+U():"Not found in PATH"}`)}catch{j(U("Red")+"Git: Not found or error checking"+U()),Z=!0}let H=MK(process.env,(W)=>W.startsWith("GDX_")?null:void 0);if(j("Process argv: "+VK(process.argv,{color:!0,indent:2,maxCol:80})),j("GDX Environment Variables: "+g(H,{color:!0})),K)j(`
|
|
872
|
+
Native Install Info: ${U("Green")+K+U()}`);else{if(j(U("Bright")+`
|
|
873
|
+
Actionable next steps:`+U()),process.platform==="win32"&&process.arch==="x64")j("To use prebuilt binary:"),j(" GDX_USE_PREBUILT=1 npm i -g gdx");else j(`Prebuilt binary not supported for ${process.platform}/${process.arch}.`);j("To build locally (requires Bun):"),j(" GDX_BUILD_NATIVE=1 npm i -g gdx")}return Z?1:0}var uF,dF;var d5=O(()=>{_7();H0();L0();D0();W0();v0();W0();A0();S6();uF={long:()=>{let Y=U("Bright"),Z=U();return o(`
|
|
874
|
+
${Y+d("DOCTOR",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
835
875
|
Diagnose installation and environment.
|
|
836
876
|
|
|
837
|
-
${Y+
|
|
877
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Z}
|
|
838
878
|
Checks for native binary, runtimes, and provides installation guidance.
|
|
839
|
-
`,Math.min(100,
|
|
879
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Run a diagnostic check on gdx installation and environment.",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
840
880
|
${Y}${C} doctor${Q}
|
|
841
881
|
|
|
842
882
|
Examples:
|
|
843
|
-
${Y}${C} doctor ${Q+Z}# Diagnose installation and environment${Q}`,Math.min(100,
|
|
883
|
+
${Y}${C} doctor ${Q+Z}# Diagnose installation and environment${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},dF={$root:[]}});import tC from"path";async function eC(Y){let Q=Y.args[2];if(!Q6)return R.error("'git submodule switch' requires the shell integration. See readme for details."),1;if(!Q)return R.error("Missing submodule path to switch into.","submodule"),1;let J=await v7(Y.git$),z=n0(Q).replace(/^\.\/+/,"").replace(/\/+$/,"");if(z==="main")return await _Z(J),0;let K=await v6(Y.git$,J);if(K.length===0)return R.error("No submodules found in this repository.","submodule"),1;let X=K.map((q)=>n0(q.path).replace(/\/+$/,"")),H=null;if(z&&!z.includes("/")){let q=X.filter((G)=>{let $=G.split("/");return $[$.length-1]===z});if(q.length===1)H=q[0];else if(q.length>1)return R.error(`Ambiguous submodule '${Q}'. Matches: ${q.join(", ")}.`,"submodule"),1}if(!H){let{match:q,candidates:G}=P0(z,X);if(q)H=q;else if(G&&G.length>1)return R.error(`Ambiguous submodule '${Q}'. Matches: ${G.join(", ")}.`,"submodule"),1}if(!H)return R.error(`Submodule '${Q}' not found. Available: ${X.join(", ")}.`,"submodule"),1;let W=tC.resolve(J,H);if(!l(W))return R.error(`Submodule '${H}' is not initialized. Run 'git submodule update --init ${H}'.`,"submodule"),1;return await _Z(W),0}var pF,cF,lF;var p5=O(()=>{H0();W0();o0();K1();A0();h0();D0();L0();v0();pF={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
884
|
+
${Y+d("SUBMODULE SWITCH",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
885
|
+
Jump into a submodule directory from the parent repository.
|
|
886
|
+
|
|
887
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
888
|
+
Resolve the target submodule by full path, unique prefix, or unique leaf name and then
|
|
889
|
+
schedule an auto-cd into it. Use "main" to jump back to the parent repository root.
|
|
890
|
+
Requires shell integration to change directories.
|
|
891
|
+
|
|
892
|
+
${Y+d("REQUIREMENTS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
893
|
+
Shell integration must be enabled using ${Z}${C} --init${Q}.
|
|
894
|
+
Submodules must be initialized (use ${Z}git submodule update --init${Q}).
|
|
895
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Jump into a submodule directory (requires shell integration).",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
896
|
+
${Y}${C} submodule switch ${Z}<path|name|main>${Q}
|
|
897
|
+
|
|
898
|
+
Examples:
|
|
899
|
+
${Y}${C} submodule switch vendor/sdk ${Q+Z}# Switch by full path${Q}
|
|
900
|
+
${Y}${C} submodule switch sdk ${Q+Z}# Switch by unique name${Q}
|
|
901
|
+
${Y}${C} submodule switch main ${Q+Z}# Back to parent repo${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},cF={$root:{switch:{}}},lF={switch:eC}});import nF from"path";function YA(){let Y=process.env.GDX_SELF_COMMAND;if(Y){let z=LZ(Y).filter(Boolean);if(z.length>0)return z}let Z=process.argv[0],Q=process.argv[1],J=Q?nF.extname(Q).toLowerCase():"";if(Q&&l(Q)&&[".js",".mjs",".cjs",".ts"].includes(J))return[Z,Q];return[Z]}async function ZA(Y,Z){try{let{stdout:Q}=await S`${Y} rev-parse --verify ${Z}^{commit}`;return Q.trim()}catch{return null}}async function QA(Y,Z){try{let{stdout:Q}=await S`${Y} rev-parse ${Z}^`;return Q.trim()}catch{return null}}async function JA(Y){let[Z,Q]=await Promise.all([S`${Y} diff --cached --name-only`.then((J)=>J.stdout.trim()),S`${Y} diff --name-only`.then((J)=>J.stdout.trim())]);if(Z||Q)return R.error("Working tree has uncommitted changes. Please stash or commit them before rewording.","reword"),!1;return!0}async function zA(Y,Z){let Q=LZ(Z),J=Q.shift();if(!J)throw new a("Editor is not configured.","EDITOR_NOT_CONFIGURED");let z=await c1(J);if(!z)throw new a(`Editor "${J}" not found in PATH.`,"EDITOR_NOT_FOUND");await V0`${z} ${Q} ${Y}`}async function KA(){let Y=await O0(),Z=Y.get("reword.editor",null),Q=Y.getAll().defaultEditor;if(Z&&Z.trim().length>0)return Z.trim();if(Q&&Q.trim().length>0)return Q.trim();throw new a("No editor configured.","EDITOR_NOT_CONFIGURED")}async function iF(Y){let Z=process.env.GDX_REWORD_TARGET_SHA?.trim(),Q=process.env.GDX_REWORD_TARGET_SHORT?.trim(),J=Y.args[1];if(!Z||!J)return R.error("Missing target commit or rebase todo file.","reword"),1;try{let K=(await S0(J,"utf8")).split(/\r?\n/),X=!1,H=K.map((W)=>{if(X)return W;if(!W.trim()||W.trim().startsWith("#"))return W;let q=/^(\s*)(\w+)(\s+)([0-9a-f]+)(.*)$/i.exec(W);if(!q)return W;let G=q[4];if(!(Z.startsWith(G)||(Q?Q.startsWith(G):!1)||G.startsWith(Z)))return W;return X=!0,`${q[1]}reword${q[3]}${q[4]}${q[5]}`});if(!X)return R.error("Target commit not found in rebase todo list.","reword"),1;return await Y1(J,H.join(`
|
|
902
|
+
`),"utf8"),0}catch(z){return R.error(g(z,{color:!0}),"reword"),1}}async function aF(Y){let Z=process.env.GDX_REWORD_MESSAGE_FILE?.trim(),Q=Y.args[1];if(!Z||!Q)return R.error("Missing commit message file for rewording.","reword"),1;try{let J=await S0(Z,"utf8");return await Y1(Q,J,"utf8"),0}catch(J){return R.error(g(J,{color:!0}),"reword"),1}}async function tz(Y){let{git$:Z,args:Q}=Y;if(!await V4(Z))return 1;let{error:J}=await F4(Q,Z,1);if(J)return 1;if(Q.length>2)return R.error(`Usage: ${C} reword [<commit>]`,"reword"),1;if(!await JA(Z))return 1;let z=Q[1]||"HEAD",K=await ZA(Z,z);if(!K)return R.error(`Invalid commit reference: ${z}`,"reword"),1;let H=(await S`${Z} rev-parse HEAD`).stdout.trim()===K;if(!H){if(!await S`${Z} merge-base --is-ancestor ${K} HEAD`.then(()=>!0).catch(()=>!1))return R.error("Target commit is not an ancestor of HEAD.","reword"),1}let W=nF.join(O1,`gdx_reword_${Date.now()}.txt`);try{let q=(await S`${Z} log -1 --format=%B ${K}`).stdout;await Y1(W,q,"utf8");let G=await KA();if(await zA(W,G),!(await S0(W,"utf8")).trim())return R.error("Commit message is empty. Aborting reword.","reword"),1;if(H)return await V0`${Z} commit --amend -F ${W}`.catch(k1),0;let B=await QA(Z,K),V=(await S`${Z} rev-parse --short ${K}`).stdout.trim(),F=YA(),M=[...F,"__reword-sequence-editor"],L=[...F,"__reword-editor"],N=_6(M).join(" "),_=_6(L).join(" "),I=process.env.GIT_SEQUENCE_EDITOR,w=process.env.GIT_EDITOR,A=process.env.GDX_REWORD_MESSAGE_FILE,x=process.env.GDX_REWORD_TARGET_SHA,E=process.env.GDX_REWORD_TARGET_SHORT;process.env.GIT_SEQUENCE_EDITOR=N,process.env.GIT_EDITOR=_,process.env.GDX_REWORD_MESSAGE_FILE=W,process.env.GDX_REWORD_TARGET_SHA=K,process.env.GDX_REWORD_TARGET_SHORT=V;try{if(R.debug(`Rewording commit ${V} using ${_6(M).join(" ")}`,"reword"),B)await V0`${Z} rebase -i ${B}`;else await V0`${Z} rebase -i --root`}catch(h){return R.error("Reword failed. Resolve the rebase and continue or abort.","reword"),R.error(g(h,{color:!0}),"reword"),1}finally{if(I!==void 0)process.env.GIT_SEQUENCE_EDITOR=I;else delete process.env.GIT_SEQUENCE_EDITOR;if(w!==void 0)process.env.GIT_EDITOR=w;else delete process.env.GIT_EDITOR;if(A!==void 0)process.env.GDX_REWORD_MESSAGE_FILE=A;else delete process.env.GDX_REWORD_MESSAGE_FILE;if(x!==void 0)process.env.GDX_REWORD_TARGET_SHA=x;else delete process.env.GDX_REWORD_TARGET_SHA;if(E!==void 0)process.env.GDX_REWORD_TARGET_SHORT=E;else delete process.env.GDX_REWORD_TARGET_SHORT}return 0}catch(q){return R.error(g(q,{color:!0}),"reword"),1}finally{await c8(W).catch(k1)}}var oF,sF;var h8=O(()=>{H0();o0();h0();w1();K1();L0();D0();W0();A0();v0();oF={long:()=>{let Y=U("Bright"),Z=U("Cyan"),Q=U();return o(`
|
|
903
|
+
${Y+d("REWORD",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
904
|
+
Update a commit message without editing an interactive rebase todo list.
|
|
905
|
+
|
|
906
|
+
${Y+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
907
|
+
Opens the selected commit message in your editor, then rewrites history as needed. By default, it rewords HEAD. Provide a commit SHA or a relative ref (e.g. ${Z}~2${Q}) to target older commits.
|
|
908
|
+
|
|
909
|
+
${Y+d("CONFIG",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
910
|
+
Set ${Z}reword.editor${Q} to override the global editor. When unset, ${Z}defaultEditor${Q} is used.
|
|
911
|
+
|
|
912
|
+
${Y+d("SAFETY",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
913
|
+
Rewording rewrites commit history. Ensure you coordinate with collaborators before rewriting shared commits.
|
|
914
|
+
`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Reword a commit message (defaults to HEAD).",usage:()=>{let Y=U("Cyan"),Z=U("Dim"),Q=U();return o(`
|
|
915
|
+
${Y}${C} reword ${Z}[<commit>]${Q}
|
|
916
|
+
|
|
917
|
+
Examples:
|
|
918
|
+
${Y}${C} reword${Q+Z} # Reword the latest commit${Q}
|
|
919
|
+
${Y}${C} reword ~2${Q+Z} # Reword HEAD~2${Q}
|
|
920
|
+
${Y}${C} reword deadbeef${Q+Z} # Reword a specific commit${Q}`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},sF={$root:[]}});function c5(Y){let Z=U("Cyan"),Q=U("Yellow"),J=U("Bright"),z=U("Dim"),K=U("Reset"),X={cache:nz,stash:JB,stats:UB,graph:WB,nocap:dV,parallel:P5,"gdx-config":MF,commit:wF,clear:TF,lint:bF,status:gF,doctor:uF,submodule:pF,reword:oF};if(!Y)return j(o(`
|
|
844
921
|
──────────────────────────────
|
|
845
|
-
${J+
|
|
846
|
-
Version: ${Z+
|
|
922
|
+
${J+d("GDX (Git Developer eXperience)",k.OceanDeepBlue,k.OceanGreen,0.32,1)+K}
|
|
923
|
+
Version: ${Z+E1+K}
|
|
847
924
|
──────────────────────────────
|
|
848
925
|
|
|
849
926
|
Git, but with better DX. The raw power of Git,
|
|
850
927
|
aligned with human workflows.
|
|
851
928
|
|
|
852
|
-
${J+
|
|
929
|
+
${J+d("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+K}
|
|
853
930
|
${C} (wrapper) — shorthand-friendly wrapper for git (executable) with common shortcuts,
|
|
854
931
|
stash-range support, and convenience expansions.
|
|
855
932
|
It forwards unrecognized commands/args to git (executable) unchanged.
|
|
856
933
|
|
|
857
|
-
${J+
|
|
934
|
+
${J+d("SYNOPSIS",k.Zinc400,k.Zinc100,0.2)+K}
|
|
858
935
|
${C} <command> [<args>]
|
|
859
936
|
Examples:
|
|
860
|
-
${Z}${C} st ${
|
|
861
|
-
${Z}${C} lg ${
|
|
862
|
-
${Z}${C} stash d 2..6 ${
|
|
863
|
-
${Z}${C} clear ${
|
|
864
|
-
${Z}${C} cmi auto ${
|
|
937
|
+
${Z}${C} st ${K+z}# shorthand for ${C} stash${K}
|
|
938
|
+
${Z}${C} lg ${K+z}# shorthand for ${C} log --oneline --graph --all --decorate${K}
|
|
939
|
+
${Z}${C} stash d 2..6 ${K+z}# drop stashes 2 through 6 (safe: drops high->low)${K}
|
|
940
|
+
${Z}${C} clear ${K+z}# backup changes to a temp patch file and reset working directory (use \`${Z}${C} clear pardon${U("White")}\` to restore)${K}
|
|
941
|
+
${Z}${C} cmi auto ${K+z}# generate commit message based on staged changes using LLM${K}
|
|
865
942
|
|
|
866
|
-
${J+
|
|
943
|
+
${J+d("KEY FEATURES",k.Zinc400,k.Zinc100,0.2)+K}
|
|
867
944
|
- Many short aliases for common commands (commit, branch, checkout, etc.).
|
|
868
945
|
- Smart expansions:
|
|
869
|
-
- log: ${Z}${C} lg ${
|
|
870
|
-
- log export: ${Z}${C} lg export [extra args] ${
|
|
871
|
-
export (adds --author if missing).${
|
|
872
|
-
- pull: ${Z}${C} pl -au ${
|
|
873
|
-
- push: ${Z}${C} ps -fl ${
|
|
874
|
-
- reset: ${Z}${C} res -h ${
|
|
875
|
-
${z}(also supports ${Z}origin~N${
|
|
946
|
+
- log: ${Z}${C} lg ${K+z}-> ${K+Z}${C} log --oneline --graph --all --decorate${K}
|
|
947
|
+
- log export: ${Z}${C} lg export [extra args] ${K+z}creates a nicely formatted
|
|
948
|
+
export (adds --author if missing).${K}
|
|
949
|
+
- pull: ${Z}${C} pl -au ${K+z}-> expands -au to --allow-unrelated-histories.${K}
|
|
950
|
+
- push: ${Z}${C} ps -fl ${K+z}-> expands -fl to --force-with-lease.${K}
|
|
951
|
+
- reset: ${Z}${C} res -h ${K+z}-> ${K+Z}${C} reset --hard${K+z}; ${K+Z}${C} res ~3 ${K+z}-> ${K+Z}${C} reset HEAD~3${K}
|
|
952
|
+
${z}(also supports ${Z}origin~N${K+z} for upstream-relative resets)${K}
|
|
876
953
|
- Clear convenience:
|
|
877
|
-
- ${Z}${C} clear ${
|
|
954
|
+
- ${Z}${C} clear ${K+z}->${K} creates a timestamped patch backup
|
|
878
955
|
in the system temp folder, then resets the working directory
|
|
879
|
-
(${Z}${C} reset --hard ${
|
|
880
|
-
- Use \`${Z}${C} clear pardon${
|
|
881
|
-
and restore changes. Add \`${Z}-f${
|
|
956
|
+
(${Z}${C} reset --hard ${K+z}+ ${K+Z}${C} clean -fd${K}).
|
|
957
|
+
- Use \`${Z}${C} clear pardon${K}\` to apply the latest backup patch
|
|
958
|
+
and restore changes. Add \`${Z}-f${K}\`/\`${Z}--force${K}\` to bypass dirty-working-directory prompts.
|
|
882
959
|
- Stash convenience:
|
|
883
|
-
- Short forms: ${Z}${C} sta / ${C} st${
|
|
884
|
-
- ${Z}${C} stash d 2..6${
|
|
960
|
+
- Short forms: ${Z}${C} sta / ${C} st${K} for stash; ${Z}${C} sta l${K} -> stash list.
|
|
961
|
+
- ${Z}${C} stash d 2..6${K} — drops stash@{6}..stash@{2} (drops high→low to
|
|
885
962
|
avoid index shift).
|
|
886
963
|
- Supports apply, pop, drop, list, show, clear via short forms.
|
|
887
964
|
- Quick worktrees:
|
|
888
|
-
- ${Z}${C} parallel fork/remove/join/switch/open/list${
|
|
889
|
-
|
|
890
|
-
${J+
|
|
891
|
-
${Z}ad ${
|
|
892
|
-
${Z}bra, br ${
|
|
893
|
-
${Z}clear ${
|
|
894
|
-
${Z}cl, clo ${
|
|
895
|
-
${Z}com, comm, cmi ${
|
|
896
|
-
${Z}che, checko, co ${
|
|
897
|
-
${Z}dif ${
|
|
898
|
-
${Z}lg, lo ${
|
|
899
|
-
${Z}pl, pul ${
|
|
900
|
-
${Z}ps, pus ${
|
|
901
|
-
${Z}rb, rebas ${
|
|
902
|
-
${Z}res, rese ${
|
|
903
|
-
${Z}rv, rever ${
|
|
904
|
-
${Z}mg, merg ${
|
|
905
|
-
${Z}in, ini ${
|
|
906
|
-
${Z}sta, st ${
|
|
907
|
-
${Z}s, stat ${
|
|
908
|
-
${Z}swit, sw ${
|
|
909
|
-
|
|
910
|
-
${J+
|
|
911
|
-
${
|
|
912
|
-
|
|
913
|
-
${J+
|
|
914
|
-
${Z}--init <shell> ${
|
|
915
|
-
${Z}--bypass ${
|
|
916
|
-
${Z}--no-enhance ${
|
|
917
|
-
${Z}--loglevel <level> ${
|
|
918
|
-
${Z}--ghelp, ${
|
|
919
|
-
${Z} --gdx-help, -gh ${
|
|
920
|
-
${Z}-r, --recursive ${Q}[For '${C} status']${
|
|
921
|
-
${Z}-au ${Q}[For '${C} pull']${
|
|
922
|
-
${Z}--on-lint ${Q}[For '${C} push']${
|
|
923
|
-
${Z}-fl ${Q}[For '${C} push']${
|
|
924
|
-
${Z}-h ${Q}[For '${C} reset']${
|
|
925
|
-
${Z}-s ${Q}[For '${C} reset']${
|
|
926
|
-
|
|
927
|
-
${J+
|
|
965
|
+
- ${Z}${C} parallel fork/remove/join/switch/open/list${K} for temp-backed worktree workflows.
|
|
966
|
+
|
|
967
|
+
${J+d("SHORTHAND LIST (common)",k.Zinc400,k.Zinc100,0.2)+K}
|
|
968
|
+
${Z}ad ${K+z}-> ${K}add
|
|
969
|
+
${Z}bra, br ${K+z}-> ${K}branch
|
|
970
|
+
${Z}clear ${K+z}-> ${K}clear (backup changes and reset working directory; use \`${Z}pardon${K}\` to restore)
|
|
971
|
+
${Z}cl, clo ${K+z}-> ${K}clone
|
|
972
|
+
${Z}com, comm, cmi ${K+z}-> ${K}commit
|
|
973
|
+
${Z}che, checko, co ${K+z}-> ${K}checkout
|
|
974
|
+
${Z}dif ${K+z}-> ${K}diff
|
|
975
|
+
${Z}lg, lo ${K+z}-> ${K}log (auto-expanded)
|
|
976
|
+
${Z}pl, pul ${K+z}-> ${K}pull
|
|
977
|
+
${Z}ps, pus ${K+z}-> ${K}push
|
|
978
|
+
${Z}rb, rebas ${K+z}-> ${K}rebase
|
|
979
|
+
${Z}res, rese ${K+z}-> ${K}reset
|
|
980
|
+
${Z}rv, rever ${K+z}-> ${K}revert
|
|
981
|
+
${Z}mg, merg ${K+z}-> ${K}merge
|
|
982
|
+
${Z}in, ini ${K+z}-> ${K}init
|
|
983
|
+
${Z}sta, st ${K+z}-> ${K}stash
|
|
984
|
+
${Z}s, stat ${K+z}-> ${K}status
|
|
985
|
+
${Z}swit, sw ${K+z}-> ${K}switch
|
|
986
|
+
|
|
987
|
+
${J+d("CUSTOM COMMAND LIST",k.Zinc400,k.Zinc100,0.2)+K}
|
|
988
|
+
${XA(X,{cyan:Z,reset:K})}
|
|
989
|
+
|
|
990
|
+
${J+d("OPTIONS",k.Zinc400,k.Zinc100,0.2)+K}
|
|
991
|
+
${Z}--init <shell> ${K}Output shell initialization script for given shell.
|
|
992
|
+
${Z}--bypass ${K}Bypass gdx and execute git directly with the provided arguments.
|
|
993
|
+
${Z}--no-enhance ${K}Bypass gdx enhanced Git's output.
|
|
994
|
+
${Z}--loglevel <level> ${K}Set log level (error, warning, info, debug).
|
|
995
|
+
${Z}--ghelp, ${K}Show GDX help message. ${z}(use \`${Z}ghelp <command>${K}\`
|
|
996
|
+
${Z} --gdx-help, -gh ${K+z}for command-specific help)${K}
|
|
997
|
+
${Z}-r, --recursive ${Q}[For '${C} status']${K} Recursively show git status of submodules.
|
|
998
|
+
${Z}-au ${Q}[For '${C} pull']${K} Shorthand for ${Z}--allow-unrelated-histories${K}.
|
|
999
|
+
${Z}--on-lint ${Q}[For '${C} push']${K} Skip linting for this push${K}.
|
|
1000
|
+
${Z}-fl ${Q}[For '${C} push']${K} Shorthand for ${Z}--force-with-lease${K}.
|
|
1001
|
+
${Z}-h ${Q}[For '${C} reset']${K} Shorthand for ${Z}--hard${K}.
|
|
1002
|
+
${Z}-s ${Q}[For '${C} reset']${K} Shorthand for ${Z}--soft${K}.
|
|
1003
|
+
|
|
1004
|
+
${J+d("RELATIVE REF EXPANSION",k.Zinc400,k.Zinc100,0.2)+K}
|
|
928
1005
|
Expansions are triggered by specific shorthand patterns in the arguments. When detected, they are expanded to their full form before being passed to git.
|
|
929
1006
|
|
|
930
1007
|
Syntax:
|
|
931
|
-
[origin|head]~[<number>] (e.g. ${Z}~3${
|
|
1008
|
+
[origin|head]~[<number>] (e.g. ${Z}~3${K}, ${Z}origin~2${K})
|
|
932
1009
|
- origin~N expansions resolve relative to the current branch's upstream (e.g. origin~2 -> upstream~2).
|
|
933
1010
|
- ~N or head~N expansions resolve relative to HEAD (e.g. ~3 -> HEAD~3).
|
|
934
|
-
- [head] and <number> can be omitted, they will default to HEAD and 0 respectively (e.g. ${Z}origin~${
|
|
1011
|
+
- [head] and <number> can be omitted, they will default to HEAD and 0 respectively (e.g. ${Z}origin~${K} -> upstream, ${Z}~${K} -> HEAD).
|
|
935
1012
|
|
|
936
1013
|
Examples:
|
|
937
|
-
- ${Z}${C} reset ~3${
|
|
938
|
-
- ${Z}${C} reset -h${
|
|
939
|
-
- ${Z}${C} show origin ~2${
|
|
940
|
-
- ${Z}${C} diff origin ~2${
|
|
1014
|
+
- ${Z}${C} reset ~3${K} expands to ${Z}${C} reset HEAD~3${K}.
|
|
1015
|
+
- ${Z}${C} reset -h${K} expands to ${Z}${C} reset --hard${K}.
|
|
1016
|
+
- ${Z}${C} show origin ~2${K} expands to ${Z}${C} show <upstream>~2${K}.
|
|
1017
|
+
- ${Z}${C} diff origin ~2${K} expands to ${Z}${C} diff <upstream>~2${K}.
|
|
941
1018
|
|
|
942
|
-
${J+
|
|
1019
|
+
${J+d("NOTES & SAFETY",k.Zinc400,k.Zinc100,0.2)+K}
|
|
943
1020
|
- Help message for individual custom commands is available via
|
|
944
|
-
${Z}${C} ghelp <command>${
|
|
1021
|
+
${Z}${C} ghelp <command>${K} (e.g. ${Z}${C} ghelp stash${K}).
|
|
945
1022
|
- Range notation must be numeric and in the form start..end (e.g. 2..6).
|
|
946
1023
|
- The wrapper prints an auto-expansion message when it expands a shorthand.
|
|
947
1024
|
- If you rely on advanced argument parsing or unusual ${C} flags, you can
|
|
948
1025
|
bypass expansions by using the full command name
|
|
949
1026
|
so they are not recognized as shorthand triggers.
|
|
950
|
-
- For more infomation, see ${
|
|
951
|
-
`+J+
|
|
952
|
-
`)}var
|
|
953
|
-
`),this.lastWidth=j8(),this.lastHeight=SY(),this.updateWrappedLines()}updateWrappedLines(){let Y=this.lastWidth,Z=this.options.showLineNumbers?Y-this.options.lineNumberWidth-1:Y;this.wrappedLines=[];for(let Q=0;Q<this.lines.length;Q++){let J=this.lines[Q];if(this.options.wrapLines&&J.length>Z)a(J,Z,{mode:"softboundary"}).split(`
|
|
954
|
-
`).forEach((H,W)=>{if(this.options.showLineNumbers&&W===0)this.wrappedLines.push(this.formatLineNumber(Q+1)+H);else if(this.options.showLineNumbers)this.wrappedLines.push(" ".repeat(this.options.lineNumberWidth+1)+H);else this.wrappedLines.push(H)});else if(this.options.showLineNumbers)this.wrappedLines.push(this.formatLineNumber(Q+1)+J);else this.wrappedLines.push(J)}}formatLineNumber(Y){return String(Y).padStart(this.options.lineNumberWidth)+" "}getLineCount(){return this.wrappedLines.length}getLine(Y){return this.wrappedLines[Y]||""}render(Y,Z,Q){let J=[],z=H6(this.options.backgroundColor),X=q();for(let H=0;H<Z-1;H++){let W=Y+H;if(W<this.wrappedLines.length){let K=this.wrappedLines[W],$=E8(K),G=Math.max(0,Q-$.length);J.push(`${z}${K}${" ".repeat(G)}${X}`)}else J.push(`${z}${" ".repeat(Q)}${X}`)}return J}onResize(Y,Z){if(Y!==this.lastWidth||Z!==this.lastHeight)this.lastWidth=Y,this.lastHeight=Z,this.updateWrappedLines()}getExitLines(){return this.wrappedLines}}async function dV(Y,Z={}){let Q=new uV(Y,Z);return Oz(Q,Z)}async function Oz(Y,Z={}){let Q={...mV,...Z};if(!process.stdout.isTTY||!process.stdin.isTTY){for(let F=0;F<Y.getLineCount();F++)process.stdout.write(Y.getLine(F)+`
|
|
955
|
-
`);return}process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf-8");let J=0,z=Y.getLineCount(),X=!0,H=[];process.stdout.write("\x1B[?25l"),process.stdout.write("\x1B[2J\x1B[H");function W(){let F=performance.now(),V=SY(),O=j8(),N=Y.render(J,V,O);process.stdout.write("\x1B[H");for(let w of N)process.stdout.write("\x1B[K"+w+`
|
|
956
|
-
`);if(Q.showStatus){let w=Q.statusFormat(J+1,z,O),L=Math.max(0,O-P8(w)),I=H6(Q.backgroundColor),T=y0(Q0.overlay0);process.stdout.write("\x1B[K"+I+T+w+" ".repeat(L)+q())}if(H.length>30)H.shift();H.push(performance.now()-F)}function K(){process.stdout.write("\x1B[?25h");let V=SY()-1;process.stdout.write(`\x1B[${V}B`),process.stdin.setRawMode(!1),process.stdin.pause(),D.debug(`Pager performance: ${H.length>0?DZ(H.reduce((O,N)=>O+N,0)/H.length,4):"N/A"}ms average over ${H.length} renders`,"pager")}function $(){Mz();let F=j8(),V=SY();if(Y.onResize)Y.onResize(F,V);W()}let G=()=>$();process.stdout.on("resize",G);function U(F){let O=SY()-1,N=Math.max(0,Y.getLineCount()-O);switch(F){case"q":case"\x03":case"\x1B":X=!1;break;case"\x1B[A":case"\x1B[A":case"k":J=Math.max(0,J-Q.scrollSensitivity);break;case"\x1B[B":case"\x1B[B":case"j":J=Math.min(N,J+Q.scrollSensitivity);break;case"\x1B[5~":case"b":{let w=O-1;J=Math.max(0,J-w);break}case"\x1B[6~":case"n":case" ":{let w=O-1;J=Math.min(N,J+w);break}case"g":case"\x1B[1~":case"\x1B[H":J=0;break;case"G":case"\x1B[4~":case"\x1B[F":J=N;break}if(X)W()}let B=(F)=>{if(U(F.toString()),!X)process.stdin.off("data",B),process.stdout.off("resize",G),K()};return process.stdin.on("data",B),W(),new Promise((F)=>{let V=setInterval(()=>{if(!X)clearInterval(V),F()},50)})}var mV,VZ=null,FZ=null;var pV=R(()=>{z0();$0();T0();W0();mV={showLineNumbers:!1,lineNumberWidth:4,wrapLines:!0,showStatus:!0,statusFormat:(Y,Z,Q)=>{let J=q("Bright"),z=q("Normal"),X=Math.min(Y+SY()-2,Z);return fY([` ${J}↑ ↓ b n Home End${z} to navigate, ${J}q${z} to quit`,`lines ${J}${Y}-${X}${z} of ${J}${Z}${X===Z?q("Red")+" (EOF)"+q("White"):""} `],Q,{align:"spacebetween",filler:" ",redundancyLv:0})},backgroundColor:Q0.base,scrollSensitivity:3}});async function HT(){return lV??=import("@shikijs/cli"),await lV}function M5(){return process.stdout.isTTY===!0&&process.stdin.isTTY===!0&&qY.supportsColor>=3}function WT(Y){let Z=Y.split(".").pop()?.toLowerCase()||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",json:"json",md:"markdown",css:"css",scss:"scss",html:"html",vue:"vue",svelte:"svelte",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",sh:"bash",bash:"bash",zsh:"bash",yml:"yaml",yaml:"yaml",toml:"toml",xml:"xml",sql:"sql",dockerfile:"dockerfile",docker:"dockerfile",makefile:"makefile",cmake:"cmake",lua:"lua",perl:"perl",php:"php"}[Z]||"text"}function KT(Y){let Z=[],Q=Y.split(`
|
|
957
|
-
`),J=null,z=0,X=0;for(let H of Q){if(H.startsWith("diff --git ")){if(J)Z.push(J);let W=H.match(/diff --git a\/(.+?) b\/(.+)/);if(W)J={fileName:W[2],oldFileName:W[1],newFileName:W[2],lang:WT(W[2]),lines:[]};continue}if(!J)continue;if(H.startsWith("--- ")||H.startsWith("+++ ")){J.lines.push({type:"header",content:H});continue}if(H.startsWith("@@ ")){let W=H.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(W)z=parseInt(W[1],10),X=parseInt(W[2],10);J.lines.push({type:"hunk",content:H});continue}if(H[0]==="+"){J.lines.push({type:"add",content:H.substring(1),newLineNum:X++});continue}if(H[0]==="-"){J.lines.push({type:"delete",content:H.substring(1),oldLineNum:z++});continue}if(H[0]===" "||H===""){J.lines.push({type:"context",content:H[0]===" "?H.substring(1):"",oldLineNum:z++,newLineNum:X++});continue}if(H.match(/^(new file|deleted file|index|Binary|similarity|rename|old mode|new mode)/))J.lines.push({type:"header",content:H})}if(J)Z.push(J);return Z}async function GT(Y,Z,Q,J){let z=new Map;if(Z.size===0)return z;try{let X=J?`${J}/${Y}`:Y,W=(await QY(X,"utf-8")).split(`
|
|
958
|
-
`),K=Math.max(0,Math.min(...Z)-Q),$=Math.min(W.length-1,Math.max(...Z)+Q);for(let G=K;G<=$;G++)z.set(G+1,W[G])}catch{}return z}async function $T(Y,Z,Q){let J=new Map,z=Y.lines.filter((W)=>W.type==="add"||W.type==="delete"||W.type==="context");if(z.length===0)return J;let X=z.filter((W)=>W.type!=="delete"),H=z.filter((W)=>W.type==="delete");try{let W=await HT();if(X.length>0){let K=new Set;X.forEach((G)=>{if(G.newLineNum!==void 0)K.add(G.newLineNum)});let $=await GT(Y.newFileName,K,20,Q);if(D.debug(`Highlighting diff for ${Y.newFileName} with ${z.length} changed lines and ${$.size} lines of context from FS`,"diff-viewer"),$.size>0){let G=Math.min(...$.keys()),U=Math.max(...$.keys()),B=[];for(let O=G;O<=U;O++)B.push($.get(O)||"");let V=(await W.codeToANSI(B.join(`
|
|
959
|
-
`),Y.lang,Z)).split(`
|
|
960
|
-
`);for(let O of X){let N=O.newLineNum;if(N!==void 0){let w=N-G;if(w>=0&&w<V.length)J.set(O,V[w])}}}else{D.debug(`No additional context from FS for ${Y.newFileName}, using what we have from git`,"diff-viewer");let G=X.map((F)=>F.content).join(`
|
|
961
|
-
`),B=(await W.codeToANSI(G,Y.lang,Z)).split(`
|
|
962
|
-
`);for(let F=0;F<X.length;F++)if(B[F])J.set(X[F],B[F])}}if(H.length>0){let K=H.map((U)=>U.content).join(`
|
|
963
|
-
`),G=(await W.codeToANSI(K,Y.lang,Z)).split(`
|
|
964
|
-
`);for(let U=0;U<H.length;U++)if(G[U])J.set(H[U],G[U])}}catch(W){D.error(`Error highlighting diff for ${Y.newFileName}: ${n.from(W)}`,"diff-viewer"),z.forEach((K)=>J.set(K,K.content))}return J}class iV{parsedDiffs=[];renderedLines=[];exitLines=[];options;lastWidth=0;lastHeight=0;logger=new D("diff-renderer");ADDED_BG=gY(Q0.base,Q0.green,0.1);DELETED_BG=gY(Q0.base,Q0.red,0.1);ADDED_GUTTER_BG=gY(Q0.base,Q0.green,0.25);DELETED_GUTTER_BG=gY(Q0.base,Q0.red,0.25);constructor(Y,Z={}){this.logger.debug("Initializing DiffViewerRenderer with options: "+JSON.stringify(Z)),this.options={showLineNumbers:!0,lineNumberWidth:5,wrapLines:!0,showStatus:!0,theme:YX,statusFormat:(Q,J)=>{let z=Math.min(Q+SY()-2,J);return`lines ${Q}-${z} of ${J}`},backgroundColor:Q0.mantle,workingDir:void 0,preambleLines:[],...Z},this.lastWidth=j8(),this.lastHeight=SY(),this.parsedDiffs=this.logger.time("Parsing diff output",()=>KT(Y)),this.updateRenderedLines()}async prepareHighlighting(){for(let Y of this.parsedDiffs){let Z=Y.lines.filter((J)=>J.type==="add"||J.type==="delete"||J.type==="context");if(Z.length===0)continue;let Q=await $T(Y,this.options.theme,this.options.workingDir);Z.forEach((J)=>{let z=Q.get(J);if(z!==void 0)J.highlightedContent=z})}this.updateRenderedLines()}renderLine(Y,Z,Q){let J=[],z=this.options.lineNumberWidth,X=Z-z-4,H=" ",W=Q,K=Q,$=Q0.overlay0;switch(Y.type){case"add":H="+",W=this.ADDED_BG,K=this.ADDED_GUTTER_BG,$=Q0.green;break;case"delete":H="-",W=this.DELETED_BG,K=this.DELETED_GUTTER_BG,$=Q0.red;break;case"context":W=Q0.base;break;case"hunk":return J.push(this.renderHunkHeader(Y.content,Z)),J;case"header":return J.push(this.renderFileHeader(Y.content,Z)),J;default:return J}let G=Y.highlightedContent||Y.content,U=Y.newLineNum??Y.oldLineNum,B=U!==void 0?String(U).padStart(z):" ".repeat(z),F=`${y0(Q0.overlay1)}${B} ${y0($)}${H} `;if(this.options.wrapLines&&P8(G)>X){let O=a(G,X,{mode:"softboundary"}).split(`
|
|
965
|
-
`);for(let N=0;N<O.length;N++){let w=N===0?F:" ".repeat(z+3);J.push(this.padLineWithBg(w+H6(W)+O[N],Z,K))}}else J.push(this.padLineWithBg(F+H6(W)+G,Z,K));return J}padLineWithBg(Y,Z,Q){let J=E8(Y),z=Math.max(0,Z-J.length);return`${H6(Q)}${Y}${" ".repeat(z)}${q()}`}renderHunkHeader(Y,Z){let Q=gY(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ↕ ${y0(Q0.cyan)}${cV.italic(Y)}`,Z,Q)}renderFileHeader(Y,Z){let Q=gY(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ${y0(Q0.overlay1)}${Y}`,Z,Q)}renderFileName(Y,Z,Q){let J=gY(Q0.crust,Q0.surface0,0.3);if(Y===Z)return this.padLineWithBg(` ${y0(Q0.lavender)}${cV.bold(Z)}`,Q,J);return this.padLineWithBg(` ${y0(Q0.yellow)}${Y} -> ${Z}`,Q,J)}renderPreambleLine(Y,Z,Q,J){if(!Y)return[this.padLineWithBg(" ",Z,Q)];Y=" ".repeat(J)+Y;let z=Z,X=y0(Q0.overlay1);if(this.options.wrapLines&&P8(Y)>z)return a(Y,z,{mode:"softboundary",indent:J}).split(`
|
|
966
|
-
`).map((W)=>this.padLineWithBg(X+W,Z,Q));return[this.padLineWithBg(X+Y,Z,Q)]}updateRenderedLines(){this.renderedLines=[],this.exitLines=[];let Y=this.lastWidth,Z=q(),Q=gY(Q0.mantle,Q0.surface0,0.2);if(this.options.preambleLines.length>0){for(let J of this.options.preambleLines)if(this.renderedLines.push(...this.renderPreambleLine(J,Y,Q,3)),J.length===0)this.exitLines.push("");else this.exitLines.push(`${y0(Q0.overlay1)}${J}${Z}`);if(this.parsedDiffs.length>0)this.renderedLines.push(this.padLineWithBg(" ",Y,Q)),this.exitLines.push("")}for(let J=0;J<this.parsedDiffs.length;J++){let z=this.parsedDiffs[J],X=Q;if(J!==0)this.renderedLines.push(this.padLineWithBg(" ",Y,X),this.padLineWithBg(" "+y0(Q0.surface0)+"─".repeat(Y-12),Y,X),this.padLineWithBg(" ",Y,X));this.renderedLines.push(this.renderFileName(z.oldFileName,z.newFileName,Y)),this.exitLines.push(`${y0(Q0.lavender)}${z.newFileName}${Z}`);for(let H of z.lines)if(this.renderedLines.push(...this.renderLine(H,Y,X)),H.type==="add")this.exitLines.push(`${y0(Q0.green)}+ ${H.content}${Z}`);else if(H.type==="delete")this.exitLines.push(`${y0(Q0.red)}- ${H.content}${Z}`);else if(H.type==="context")this.exitLines.push(` ${H.content}`);else if(H.type==="hunk")this.exitLines.push(`${y0(Q0.cyan)}${H.content}${Z}`)}}getLineCount(){return this.renderedLines.length}getLine(Y){return this.renderedLines[Y]||""}render(Y,Z,Q){let J=[],z=H6(this.options.backgroundColor);for(let X=0;X<Z-1;X++){let H=Y+X;J.push(H<this.renderedLines.length?this.renderedLines[H]:`${z}${" ".repeat(Q)}${q()}`)}return J}onResize(Y,Z){if(Y!==this.lastWidth||Z!==this.lastHeight)this.lastWidth=Y,this.lastHeight=Z,this.updateRenderedLines()}getExitLines(){return this.exitLines}}async function Dz(Y,Z={}){if(!M5())return D.warn("Diff viewer is not supported in this environment. Falling back to plain output.","diff-viewer"),dV(Y,{...Z,showLineNumbers:!1});let Q=Y.split(`
|
|
967
|
-
`),J=Q.findIndex((K)=>K.startsWith("diff --git ")),z=J>0?Q.slice(0,J):J===-1?Q:[],X=J===-1?"":Q.slice(Math.max(J,0)).join(`
|
|
968
|
-
`),H=Y.length>1e4?d0({message:"Preparing diff viewer...",interval:10}):void 0;D.time("Preparing diff highlighting");let W=new iV(X,{...Z,preambleLines:z});return await W.prepareHighlighting(),Mz(),W.onResize(j8(),SY()),H?.stop(),D.timeEnd("Preparing diff highlighting","diff-viewer"),Oz(W,Z)}function nV(Y){return/^diff --git a\/.+ b\/.+/m.test(Y)}var cV,lV=null;var aV=R(()=>{z0();z0();u0();pV();T0();$0();k0();W0();cV={bold:(Y)=>`\x1B[1m${Y}\x1B[22m`,italic:(Y)=>`\x1B[3m${Y}\x1B[23m`,underline:(Y)=>`\x1B[4m${Y}\x1B[24m`,dim:(Y)=>`\x1B[2m${Y}\x1B[22m`}});var oV={};L5(oV,{dispatch:()=>Nz});async function Nz(Y,Z={inMacro:!1}){let Q=Y.args,J=Q.slice(0);if(!Z.inMacro){let W=await O5();if(Q[0]&&Q[0]in W){let K=Q[0],$=W[K],G=Q.slice(1);j(q("Dim")+q("Magenta")+`※ ${q("White")+q("Bright")} Executing macro '${K}'...`+q());let{executeMacro:U}=await Promise.resolve().then(() => (D5(),sV));return await U(Y.git$,$,G)}}else{let W=await O5();if(Q[0]&&Q[0]in W)return D.error(`Macro '${Q[0]}' cannot be invoked from inside a macro. Macro composition is not allowed.`,"macro"),1}let z=null,X=">",H=!Q.popOption("--no-enhance");Y:if(Q[0]){let{match:W,candidates:K}=A5(Q[0],IZ);if(W)Q[0]=W;switch(Q[0]){case"s":Q[0]="status";case"status":if(Q.includes("-r")||Q.includes("--recursive"))return await D0.status(Y);break;case"co":Q[0]="checkout";break;case"br":Q[0]="branch";break;case"cmi":Q[0]="commit";case"commit":if(Q[1]==="auto")return await D0.commit.auto(Y);break;case"mg":Q[0]="merge";break;case"pl":case"pu":Q[0]="pull";case"pull":for(let $=1;$<Q.length;$++)if(Q[$]==="-au"){Q[$]="--allow-unrelated-histories";break}break;case"lint":return await D0.lint(Y);case"diff":{let{error:$}=await B2(Q,Y.git$);if($)return 1;let G=await q0();if(H&&G.get("enhancedOutput")&&M5()&&!Q.includes("--stat")&&!Q.includes("-h")&&!Q.includes("--help")&&!Q.includes("--numstat")&&!Q.includes("--name-only")&&!Q.includes("--name-status")){let U=Q.slice(1);try{let B=await S`${Y.git$} -c color.ui=never diff ${U}`;if(B.stdout)return await Dz(B.stdout),0}catch(B){D.info("Failed to get or parse diff output for enhanced diff-view, ignoring: "+n.from(B))}}break}case"show":{let{error:$}=await B2(Q,Y.git$);if($)return 1;let G=await q0();if(H&&G.get("enhancedOutput")&&M5()&&!Q.includes("--stat")&&!Q.includes("-h")&&!Q.includes("--help")&&!Q.includes("--numstat")&&!Q.includes("--name-only")&&!Q.includes("--name-status")&&!Q.hasOption("--format")){let U=Q.slice(1);try{let B=await S`${Y.git$} -c color.ui=never show ${U}`;if(B.stdout&&nV(B.stdout))return await Dz(B.stdout),0}catch(B){D.info("Failed to get show output for enhanced diff-view, ignoring: "+n.from(B))}}break}case"ps":Q[0]="push";case"push":{if(!Q.popOption("--no-lint")){let G=(await q0()).get("lint.onPushBehavior")||"off";if(G==="error"||G==="warning"){if(await D0.lint(Y)!==0)if(G==="error")return D.error("Lint failed. Push aborted.","lint"),1;else j(q("Yellow")+"Lint failed, but proceeding with push (warning mode)."+q())}}Q.spliceOption("-fl",["--force-with-lease"],1);break}case"ad":Q[0]="add";break;case"rv":Q[0]="revert";break;case"rb":Q[0]="rebase";break;case"reset":{Q[0]="reset";for(let G=1;G<Q.length;G++){if(Q[G]==="-h"){Q[G]="--hard";break}if(Q[G]==="-s"){Q[G]="--soft";break}}let{error:$}=await B2(Q,Y.git$);if($)return 1;break}case"log":case"lg":if(Q[0]==="lg"&&Q.length===1)Q.push("--oneline","--graph","--decorate","--all");else if(Q.popOption("export")){let $='--date=format:"%Y-%m-%d %H:%M"';if(!Q.hasOption("--author",1)){let F=Array.isArray(Y.git$)?Y.git$[0]:Y.git$;Q.push("--author="+await O6(F,"user.email"))}let U=Q.indexOf("--relative");if(U>=0)Q.splice(U,1),$='--date=format:"%Y-%m-%d %H:%M" (%ar)';let B=["--all",`--pretty=format:## Commit %h on [%p] - %ad%d
|
|
1027
|
+
- For more infomation, see ${s6("README.md",SK)}.`,Math.min(100,c.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})),0;let H=Y.replace(/^\/+/,"");if(H==="help")return c5();let W=X[H],q="";if(W&&W.long)q=W.long();if(q&&W.usage)q+=`
|
|
1028
|
+
`+J+d("USAGE",k.Zinc400,k.Zinc100,0.2)+K+W.usage();if(q)return j(q),0;return j(`No help found for '${H}'.`),1}function XA(Y,Z){let Q=[];for(let[J,z]of Object.entries(Y))Q.push(`${Z.cyan}${Y6(J,19,{overflow:"visible",align:"left",redundancyLv:0})}${Z.reset}${o(z.short,60,{indent:19,firstIndent:0,redundancyLv:0,mode:"strict"})}`);return Q.join(`
|
|
1029
|
+
`)}var rF;var ez=O(()=>{H0();W0();L0();A0();v0();b7();m7();IZ();T5();f5();b5();uz();h5();g5();m5();u5();d5();p5();h8();rF={$root:["cache","clear","commit","doctor","graph","gdx-config","lint","nocap","parallel","stash","stats","status"]}});var tF={};o5(tF,{dispatch:()=>YK});async function YK(Y,Z={inMacro:!1}){let Q=Y.args,J=Q.slice(0);if(!Z.inMacro){let H=await l5();if(Q[0]&&Q[0]in H){let W=Q[0],q=H[W],G=Q.slice(1);j(U("Dim")+U("Magenta")+`※ ${U("White")+U("Bright")} Executing macro '${W}'...`+U());let{executeMacro:$}=await Promise.resolve().then(() => (n5(),eF));return await $(Y.git$,q,G)}}else{let H=await l5();if(Q[0]&&Q[0]in H)return R.error(`Macro '${Q[0]}' cannot be invoked from inside a macro. Macro composition is not allowed.`,"macro"),1}let z=null,K=">",X=!Q.popOption("--no-enhance");Y:if(Q[0]){let{match:H,candidates:W}=P0(Q[0],a4);if(H)Q[0]=H;switch(Q[0]){case"__reword-sequence-editor":return await iF(Y);case"__reword-editor":return await aF(Y);case"s":Q[0]="status";case"status":if(Q.includes("-r")||Q.includes("--recursive"))return await I0.status(Y);break;case"submodule":{let q=["switch"];if(P0(Q[1]||"",q,!0).match!=="switch")break;return await I0.submodule.switch(Y)}case"co":Q[0]="checkout";break;case"br":Q[0]="branch";break;case"cmi":Q[0]="commit";case"commit":if(Q[1]==="auto")return await I0.commit.auto(Y);break;case"mg":Q[0]="merge";break;case"pl":case"pu":Q[0]="pull";case"pull":for(let q=1;q<Q.length;q++)if(Q[q]==="-au"){Q[q]="--allow-unrelated-histories";break}break;case"lint":return await I0.lint(Y);case"diff":{let{error:q}=await F4(Q,Y.git$);if(q)return 1;let G=await O0();if(X&&G.get("enhancedOutput")&&A5()&&!Q.includes("--stat")&&!Q.includes("-h")&&!Q.includes("--help")&&!Q.includes("--numstat")&&!Q.includes("--name-only")&&!Q.includes("--name-status")){let $=Q.slice(1),B=$.popOption("--json");try{let V=await S`${Y.git$} -c color.ui=never diff ${$}`;if(V.stdout){if(B){let F=k5(V.stdout);return j(JSON.stringify(F,null,2)),0}return await y8(V.stdout),0}}catch(V){R.info("Failed to get or parse diff output for enhanced diff-view, ignoring: "+a.from(V))}}break}case"show":{let{error:q}=await F4(Q,Y.git$);if(q)return 1;let G=await O0();if(X&&G.get("enhancedOutput")&&A5()&&!Q.includes("--stat")&&!Q.includes("-h")&&!Q.includes("--help")&&!Q.includes("--numstat")&&!Q.includes("--name-only")&&!Q.includes("--name-status")&&!Q.hasOption("--format")){let $=Q.slice(1),B=$.popOption("--json");try{let V=await S`${Y.git$} -c color.ui=never show ${$}`;if(V.stdout&&tV(V.stdout)){if(B){let F=k5(V.stdout);return j(JSON.stringify(F,null,2)),0}return await y8(V.stdout),0}}catch(V){R.info("Failed to get show output for enhanced diff-view, ignoring: "+a.from(V))}}break}case"ps":Q[0]="push";case"push":{if(!Q.popOption("--no-lint")){let G=(await O0()).get("lint.onPushBehavior")||"off";if(G==="error"||G==="warning"){if(await I0.lint(Y)!==0)if(G==="error")return R.error("Lint failed. Push aborted.","lint"),1;else j(U("Yellow")+"Lint failed, but proceeding with push (warning mode)."+U())}}Q.spliceOption("-fl",["--force-with-lease"],1);break}case"ad":Q[0]="add";break;case"rv":Q[0]="revert";break;case"rb":Q[0]="rebase";break;case"reset":{Q[0]="reset";for(let G=1;G<Q.length;G++){if(Q[G]==="-h"){Q[G]="--hard";break}if(Q[G]==="-s"){Q[G]="--soft";break}}let{error:q}=await F4(Q,Y.git$);if(q)return 1;break}case"log":case"lg":if(Q[0]==="lg"&&Q.length===1)Q.push("--oneline","--graph","--decorate","--all");else if(Q.popOption("export")){let q='--date=format:"%Y-%m-%d %H:%M"';if(!Q.hasOption("--author",1)){let V=Array.isArray(Y.git$)?Y.git$[0]:Y.git$;Q.push("--author="+await P6(V,"user.email"))}let $=Q.indexOf("--relative");if($>=0)Q.splice($,1),q='--date=format:"%Y-%m-%d %H:%M" (%ar)';let B=["--all",`--pretty=format:## Commit %h on [%p] - %ad%d
|
|
969
1030
|
%s
|
|
970
1031
|
|
|
971
1032
|
%b
|
|
972
1033
|
---
|
|
973
|
-
`,$].filter((F)=>!Q.hasOption(F,1));Q.push(...B),z="gitlog_export.md",X=">"}Q[0]="log";break;case"sta":Q[0]="stash";case"stash":{let $=["apply","pop","list","drop","clear","show","push","save","create","store"],G=A5(Q[1]||"",$,!0);if(G.match)Q[1]=G.match;else{let U=Q.indexOf("--");U=U>=0?U:Q.length;let B=!1;for(let F=1;F<U;F++)if($.includes(Q[F])){B=!0;break}if(!B){let F=Array.isArray(Y.git$)?Y.git$[0]:Y.git$,O=oz(await eq(F),"2.15.0")>=0?"push":"save";Q.splice(1,0,O)}}if(Q[1]==="drop"){let U=Array.isArray(Y.git$)?Y.git$[0]:Y.git$;return await D0.stash.drop(U,Q)}break}case"graph":return D0.graph(Y);case"stats":return D0.stats(Y);case"clear":return D0.clear(Y);case"cache":return D0.cache(Y);case"gdx-config":return D0.gdxConfig(Y);case"gdx-help":case"ghelp":return D0.help(Q[1]);case"nocap":return D0.nocap(Y);case"parallel":return D0.parallel(Y);case"doctor":return D0.doctor();case"macro":return D0.macro(Y);default:if(K&&K.length>1){D.warn(`Ambiguous command '${J[0]}'. Did you mean: ${K.join(", ")}?`);break Y}}}if(Z.inMacro||J.some((W,K)=>Q[K]!==W)){let W=KX((Q.length%6+1)/8.6,0.64,0.5);j(q("Dim")+q(c6(W),"fg")+`$ ${q("White")+q("Bright")}git ${LZ(Q).join(" ")}`+q())}return H2(Y.git$,Q,z,X)}var wz=R(()=>{z0();Lz();W0();k0();M0();FY();$0();D5();T0();WY();aV();k0()});var sV={};L5(sV,{writeMacrosToFile:()=>N5,syncMacrosToCache:()=>Iz,substitutePlaceholders:()=>tV,readMacrosFromFile:()=>E6,isFilePath:()=>jz,getMacrosCachedOrLoad:()=>O5,executeMacro:()=>UT});import qT from"path";async function E6(){try{if(!o(p6))return{};let Y=await QY(p6,"utf-8"),Z=JSON.parse(Y);if(typeof Z!=="object"||Z===null||Array.isArray(Z))return D.warn(`Invalid macro.json format at ${p6}`,"macro"),{};return Z}catch(Y){return D.warn(`Failed to read macro.json: ${n.from(Y).message}`,"macro"),{}}}async function N5(Y){try{let Z=qT.dirname(p6);if(!o(Z))ZY(Z,{recursive:!0});let Q=JSON.stringify(Y,null,2);await z6(p6,Q,"utf-8"),D.debug(`Macros written to ${p6}`,"macro")}catch(Z){throw new n(`Failed to write macro.json: ${n.from(Z).message}`,"MACRO_WRITE_FAILED")}}async function Iz(){let Y=await E6(),Z=await X0();if(Z.isDisabled)throw new n("Cache is disabled. Cannot sync macros to cache.","CACHE_DISABLED");await Z.set(_z,Y,{maxAgeMinutes:rV}),D.debug(`Synced ${Object.keys(Y).length} macros to cache`,"macro")}async function O5(){let Y=await X0();if(Y.isDisabled)return await E6();let Z=await Y.get(_z);if(Z)return D.debug("Using cached macros","macro"),Z;let Q=await E6();return await Y.set(_z,Q,{maxAgeMinutes:rV}),D.debug("Loaded macros from file and cached","macro"),Q}async function UT(Y,Z,Q){let J=Z.split(";").map((X)=>X.trim()).filter((X)=>X.length>0);if(J.length===0)return D.error("Macro script is empty.","macro"),1;let{dispatch:z}=await Promise.resolve().then(() => (wz(),oV));for(let X=0;X<J.length;X++){let H=X===J.length-1,W=nq(J[X]),{substituted:K,notUsedArgs:$}=tV(W,Q);if(H)K.push(...$);if(K.length===0)continue;j(q("Dim")+q("Cyan")+`▶ Executing: ${q("White")+q("Bright")}gdx ${LZ(K).join(" ")}`+q());let G={git$:Y,args:new J1(K)},U=await z(G,{inMacro:!0});if(U!==0)return D.error(`Macro command failed with exit code ${U}`,"macro"),U}return 0}function jz(Y){if(Y.startsWith("./")||Y.startsWith("/"))return!0;if(Y.startsWith(".\\"))return!0;if(/^[a-zA-Z]:[/\\]/.test(Y))return!0;return!1}function tV(Y,Z){let Q=-1,J=new Set(Z),z=Y.map((X,H)=>{return X.replace(/\$(\*|\d+)/g,(W,K)=>{if(K==="*")return Q=H,J.clear(),"";let $=parseInt(K,10)-1;if($>=0&&$<Z.length)return J.delete(Z[$]),Z[$];return W})});if(Q!==-1)z.splice(Q,1,...Z);return{substituted:z,notUsedArgs:Array.from(J)}}var _z="macro.all",rV=1440;var D5=R(()=>{u0();W0();R6();z0();$0();k0();M0();R2()});async function BT(Y){let{args:Z}=Y,Q=Z[1];switch(Q){case"set":return await FT(Y);case"list":return await RT();case"drop":return await MT(Y);case"sync":return await OT();default:return D.error(`Unknown macro subcommand: '${Q}'. Available: set, list, drop, sync`,"macro"),1}}async function VT(){return new Promise((Y,Z)=>{let Q="";if(process.stdin.setEncoding("utf-8"),process.stdin.on("data",(J)=>{Q+=J}),process.stdin.on("end",()=>{Y(Q.trim())}),process.stdin.on("error",(J)=>{Z(J)}),process.stdin.isTTY)Y("")})}async function FT(Y){let{args:Z}=Y,Q=Z[2],J=Z.slice(3);if(!Q)return D.error("Macro name is required. Usage: gdx macro set <name> <script>","macro"),1;let z;if(J.length===0)try{if(z=await VT(),!z)return D.error("Macro script or file path is required. Use: gdx macro set <name> <script> or gdx macro set <name> < file.txt","macro"),1;D.debug("Loaded macro script from stdin","macro")}catch(X){return D.error(`Failed to read from stdin: ${n.from(X).message}`,"macro"),1}else if(J.length===1&&jz(J[0])){let X=J[0];try{if(!o(X))return D.error(`File not found: ${X}`,"macro"),1;z=(await QY(X,"utf-8")).trim(),D.debug(`Loaded macro script from file: ${X}`,"macro")}catch(H){return D.error(`Failed to read file: ${n.from(H).message}`,"macro"),1}}else z=J.join(" ");if(!z)return D.error("Macro script cannot be empty.","macro"),1;try{let X=await E6(),H=Q in X;if(X[Q]=z,await N5(X),await(await X0()).set("macro.all",X,{maxAgeMinutes:1440}),H)j(q("Yellow")+`Macro '${Q}' updated.`+q());else j(q("Green")+`Macro '${Q}' created.`+q());return 0}catch(X){return D.error(`Failed to set macro: ${n.from(X).message}`,"macro"),1}}async function RT(){try{let Y=await E6();await(await X0()).set("macro.all",Y,{maxAgeMinutes:1440});let Q=Object.keys(Y);if(Q.length===0)return j(q("Dim")+"No macros defined."+q()),0;j(q("Cyan")+q("Bright")+"Macros:"+q());for(let J of Q.sort()){let z=Y[J],H=(z.length>80?z.substring(0,77)+"...":z).replace(/\s+/g," ");j(` ${q("Green")}${J}${q()}: ${q("Dim")}${H}${q()}`)}return 0}catch(Y){return D.error(`Failed to list macros: ${n.from(Y).message}`,"macro"),1}}async function MT(Y){let{args:Z}=Y,Q=Z[2];if(!Q)return D.error("Macro name is required. Usage: gdx macro drop <name>","macro"),1;try{let J=await E6();if(!(Q in J))return D.error(`Macro '${Q}' not found.`,"macro"),1;return delete J[Q],await N5(J),await(await X0()).set("macro.all",J,{maxAgeMinutes:1440}),j(q("Yellow")+`Macro '${Q}' deleted.`+q()),0}catch(J){return D.error(`Failed to drop macro: ${n.from(J).message}`,"macro"),1}}async function OT(){try{return await Iz(),j(q("Green")+"Macros synced to cache."+q()),0}catch(Y){let Z=n.from(Y);if(Z.code==="CACHE_DISABLED")D.error("Cache is disabled. Cannot sync macros.","macro");else D.error(`Failed to sync macros: ${Z.message}`,"macro");return 1}}var YF,eV;var Tz=R(()=>{D5();z0();$0();M0();R6();u0();YF=BT,eV={$root:{set:{},list:{},drop:{},sync:{}}}});function DT(Y){if(!Y||typeof Y!=="object"||Array.isArray(Y))return!1;return!0}async function Cz(Y,Z){let Q=Y,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Z)}catch{return{}}J+=1}if(Array.isArray(Q)||DT(Q))return Q;return{}}async function ZF(Y,Z){if(!Y)return[];let Q=Y,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Z)}catch{return[]}J+=1}return Array.isArray(Q)?Q:[]}async function QF(Y,Z){if(Array.isArray(Y))return{children:{},anyOf:new Set(Y),allOf:new Set};let Q={},J=new Set(await ZF(Y.$anyOf,Z)),z=new Set(await ZF(Y.$allOf,Z));for(let[X,H]of Object.entries(Y)){if(X==="$allOf"||X==="$anyOf"||!H)continue;Q[X]=H}return{children:Q,anyOf:J,allOf:z}}async function JF(Y,Z,Q,J){let z=Q.$root,X=new Set,H=new Set,W=!1,K=Z,$=(O,N)=>({git$:J.git$,args:Y,index:O,cursorIndex:K,mode:N});for(let O=0;O<Z;O++){let N=Y[O];if(!N)continue;z=await Cz(z,$(O,"history"));let w=await QF(z,$(O,"history"));if(N in w.children){for(let I of w.allOf)X.add(I);z=await Cz(w.children[N],$(O,"history")),W=!1;continue}if(w.anyOf.has(N)){if(W)return{completions:[]};W=!0;continue}if(w.allOf.has(N)){if(H.has(N))return{completions:[]};H.add(N);continue}if(X.has(N)){if(H.has(N))return{completions:[]};H.add(N);continue}if(N.startsWith("-"))return{completions:[]}}z=await Cz(z,$(Z,"suggest"));let G=await QF(z,$(Z,"suggest")),U=new Set;for(let O of Object.keys(G.children))U.add(O);if(!W)for(let O of G.anyOf)U.add(O);let B=new Set([...G.allOf,...X]);for(let O of B)if(!H.has(O))U.add(O);let F=Y[Z]||"";return{completions:Array.from(U).filter((O)=>O.startsWith(F)&&O!==F.trim()).sort((O,N)=>O.length-N.length||O.localeCompare(N))}}var kz,zF,XF;var HF=R(()=>{U5();q5();F5();$5();W4();Rz();B5();Q5();G5();V2();M2();V5();Tz();kz={cache:jV,clear:LV,doctor:hV,"gdx-config":FV,graph:wU,help:gV,lint:vV,nocap:ZV,parallel:BV,stash:RU,stats:IU,status:fV,macro:eV},zF=["s","st","co","br","cmi","mg","pl","pu","ps","ad","rv","rb","lg","sta"],XF=["--loglevel","--ghelp","--bypass"]});function NT(Y){let Z=process.env.GDX_CMP_IDX,Q=Number.parseInt(Z||"",10);if(!Number.isInteger(Q)||Q<0)Q=Math.max(0,Y-1);if(Y>0&&Q>=Y)Q=Y-1;return Q}async function Az(Y){let Z=l.logLevel;l.logLevel="off";try{let Q=[...Y.args];if(Q[0]==="__completion")Q.shift();let J=NT(Q.length);if(D.debug(`Completion invoked with args: ${Q.join(" ")} (idx=${J})`,"completion"),Q.length===0||J===0){let W=Q[0]||"",K=new Set;for(let G of Object.keys(kz))K.add(G);for(let G of zF)K.add(G);for(let G of XF)K.add(G);for(let G of IZ)K.add(G);let $=Array.from(K).filter((G)=>G.startsWith(W)).sort((G,U)=>G.length-U.length||G.localeCompare(U));D.debug(`Completion root-level matches: ${$.join(", ")}`,"completion");for(let G of $)process.stdout.write(`${G}
|
|
974
|
-
`);return 0}let
|
|
975
|
-
`);return 0}}return
|
|
1034
|
+
`,q].filter((V)=>!Q.hasOption(V,1));Q.push(...B),z="gitlog_export.md",K=">"}Q[0]="log";break;case"sta":Q[0]="stash";case"stash":{let q=["apply","pop","list","drop","clear","show","push","save","create","store"],G=P0(Q[1]||"",q,!0);if(G.match)Q[1]=G.match;else{let $=Q.indexOf("--");$=$>=0?$:Q.length;let B=!1;for(let V=1;V<$;V++)if(q.includes(Q[V])||Q[V]==="-h"||Q[V]==="--help"){B=!0;break}if(!B){let V=Array.isArray(Y.git$)?Y.git$[0]:Y.git$,M=kK(await u$(V),"2.15.0")>=0?"push":"save";Q.splice(1,0,M)}}if(Q[1]==="drop"){let $=Array.isArray(Y.git$)?Y.git$[0]:Y.git$;return await I0.stash.drop($,Q)}break}case"graph":return I0.graph(Y);case"stats":return I0.stats(Y);case"clear":return I0.clear(Y);case"cache":return I0.cache(Y);case"gdx-config":return I0.gdxConfig(Y);case"gdx-help":case"ghelp":return I0.help(Q[1]);case"nocap":return I0.nocap(Y);case"parallel":return I0.parallel(Y);case"doctor":return I0.doctor();case"macro":return I0.macro(Y);case"reword":return I0.reword(Y);default:if(W&&W.length>1){R.warn(`Ambiguous command '${J[0]}'. Did you mean one of: ${W.join(", ")}?`);break Y}}}if(Z.inMacro||J.some((H,W)=>Q[W]!==H)){let H=iK((Q.length%6+1)/8.6,0.64,0.5);j(U("Dim")+U(zY(H),"fg")+`$ ${U("White")+U("Bright")}git ${_6(Q).join(" ")}`+U())}return x7(Y.git$,Q,z,K)}var ZK=O(()=>{H0();QK();h8();W0();h0();L0();w1();D0();n5();A0();K1();bz()});var eF={};o5(eF,{writeMacrosToFile:()=>i5,syncMacrosToCache:()=>zK,substitutePlaceholders:()=>ZR,readMacrosFromFile:()=>o6,isFilePath:()=>KK,getMacrosCachedOrLoad:()=>l5,executeMacro:()=>WA});import HA from"path";async function o6(){try{if(!l(JY))return{};let Y=await S0(JY,"utf-8"),Z=JSON.parse(Y);if(typeof Z!=="object"||Z===null||Array.isArray(Z))return R.warn(`Invalid macro.json format at ${JY}`,"macro"),{};return Z}catch(Y){return R.warn(`Failed to read macro.json: ${a.from(Y).message}`,"macro"),{}}}async function i5(Y){try{let Z=HA.dirname(JY);if(!l(Z))H1(Z,{recursive:!0});let Q=JSON.stringify(Y,null,2);await Y1(JY,Q,"utf-8"),R.debug(`Macros written to ${JY}`,"macro")}catch(Z){throw new a(`Failed to write macro.json: ${a.from(Z).message}`,"MACRO_WRITE_FAILED")}}async function zK(){let Y=await o6(),Z=await B0();if(Z.isDisabled)throw new a("Cache is disabled. Cannot sync macros to cache.","CACHE_DISABLED");await Z.set(JK,Y,{maxAgeMinutes:YR}),R.debug(`Synced ${Object.keys(Y).length} macros to cache`,"macro")}async function l5(){let Y=await B0();if(Y.isDisabled)return await o6();let Z=await Y.get(JK);if(Z)return R.debug("Using cached macros","macro"),Z;let Q=await o6();return await Y.set(JK,Q,{maxAgeMinutes:YR}),R.debug("Loaded macros from file and cached","macro"),Q}async function WA(Y,Z,Q){let J=Z.split(";").map((K)=>K.trim()).filter((K)=>K.length>0);if(J.length===0)return R.error("Macro script is empty.","macro"),1;let{dispatch:z}=await Promise.resolve().then(() => (ZK(),tF));for(let K=0;K<J.length;K++){let X=K===J.length-1,H=LZ(J[K]),{substituted:W,notUsedArgs:q}=ZR(H,Q);if(X)W.push(...q);if(W.length===0)continue;j(U("Dim")+U("Cyan")+`▶ Executing: ${U("White")+U("Bright")}gdx ${_6(W).join(" ")}`+U());let G={git$:Y,args:new MY(W)},$=await z(G,{inMacro:!0});if($!==0)return R.error(`Macro command failed with exit code ${$}`,"macro"),$}return 0}function KK(Y){if(Y.startsWith("./")||Y.startsWith("/"))return!0;if(Y.startsWith(".\\"))return!0;if(/^[a-zA-Z]:[/\\]/.test(Y))return!0;return!1}function ZR(Y,Z){let Q=-1,J=new Set(Z),z=Y.map((K,X)=>{return K.replace(/\$(\*|\d+)/g,(H,W)=>{if(W==="*")return Q=X,J.clear(),"";let q=parseInt(W,10)-1;if(q>=0&&q<Z.length)return J.delete(Z[q]),Z[q];return H})});if(Q!==-1)z.splice(Q,1,...Z);return{substituted:z,notUsedArgs:Array.from(J)}}var JK="macro.all",YR=1440;var n5=O(()=>{o0();W0();S6();H0();D0();h0();L0();CZ()});async function qA(Y){let{args:Z}=Y,Q=Z[1]?.toLowerCase(),{match:J,candidates:z}=P0(Q,["set","list","drop","sync"]);switch(J){case"set":return await UA(Y);case"list":return await $A();case"drop":return await BA(Y);case"sync":return await VA();default:if(z&&z.length>0)R.warn(`Ambiguous command '${Q}'. Did you mean one of: ${z.join(", ")}?`);else R.warn(`Unknown macro subcommand '${Q}'`);return R.info("Available subcommands: set, list, drop, sync","macro"),1}}async function GA(){return new Promise((Y,Z)=>{let Q="";if(process.stdin.setEncoding("utf-8"),process.stdin.on("data",(J)=>{Q+=J}),process.stdin.on("end",()=>{Y(Q.trim())}),process.stdin.on("error",(J)=>{Z(J)}),process.stdin.isTTY)Y("")})}async function UA(Y){let{args:Z}=Y,Q=Z[2],J=Z.slice(3);if(!Q)return R.error("Macro name is required. Usage: gdx macro set <name> <script>","macro"),1;let z;if(J.length===0)try{if(z=await GA(),!z)return R.error("Macro script or file path is required. Use: gdx macro set <name> <script> or gdx macro set <name> < file.txt","macro"),1;R.debug("Loaded macro script from stdin","macro")}catch(K){return R.error(`Failed to read from stdin: ${a.from(K).message}`,"macro"),1}else if(J.length===1&&KK(J[0])){let K=J[0];try{if(!l(K))return R.error(`File not found: ${K}`,"macro"),1;z=(await S0(K,"utf-8")).trim(),R.debug(`Loaded macro script from file: ${K}`,"macro")}catch(X){return R.error(`Failed to read file: ${a.from(X).message}`,"macro"),1}}else z=J.join(" ");if(!z)return R.error("Macro script cannot be empty.","macro"),1;try{let K=await o6(),X=Q in K;if(K[Q]=z,await i5(K),await(await B0()).set("macro.all",K,{maxAgeMinutes:1440}),X)j(U("Yellow")+`Macro '${Q}' updated.`+U());else j(U("Green")+`Macro '${Q}' created.`+U());return 0}catch(K){return R.error(`Failed to set macro: ${a.from(K).message}`,"macro"),1}}async function $A(){try{let Y=await o6();await(await B0()).set("macro.all",Y,{maxAgeMinutes:1440});let Q=Object.keys(Y);if(Q.length===0)return j(U("Dim")+"No macros defined."+U()),0;j(U("Cyan")+U("Bright")+"Macros:"+U());for(let J of Q.sort()){let z=Y[J],X=(z.length>80?z.substring(0,77)+"...":z).replace(/\s+/g," ");j(` ${U("Green")}${J}${U()}: ${U("Dim")}${X}${U()}`)}return 0}catch(Y){return R.error(`Failed to list macros: ${a.from(Y).message}`,"macro"),1}}async function BA(Y){let{args:Z}=Y,Q=Z[2];if(!Q)return R.error("Macro name is required. Usage: gdx macro drop <name>","macro"),1;try{let J=await o6();if(!(Q in J))return R.error(`Macro '${Q}' not found.`,"macro"),1;return delete J[Q],await i5(J),await(await B0()).set("macro.all",J,{maxAgeMinutes:1440}),j(U("Yellow")+`Macro '${Q}' deleted.`+U()),0}catch(J){return R.error(`Failed to drop macro: ${a.from(J).message}`,"macro"),1}}async function VA(){try{return await zK(),j(U("Green")+"Macros synced to cache."+U()),0}catch(Y){let Z=a.from(Y);if(Z.code==="CACHE_DISABLED")R.error("Cache is disabled. Cannot sync macros.","macro");else R.error(`Failed to sync macros: ${Z.message}`,"macro");return 1}}var JR,QR;var XK=O(()=>{n5();H0();D0();L0();S6();o0();JR=qA,QR={$root:{set:{},list:{},drop:{},sync:{}}}});function FA(Y){if(!Y||typeof Y!=="object"||Array.isArray(Y))return!1;return!0}async function HK(Y,Z){let Q=Y,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Z)}catch{return{}}J+=1}if(Array.isArray(Q)||FA(Q))return Q;return{}}async function zR(Y,Z){if(!Y)return[];let Q=Y,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Z)}catch{return[]}J+=1}return Array.isArray(Q)?Q:[]}async function KR(Y,Z){if(Array.isArray(Y))return{children:{},anyOf:new Set(Y),allOf:new Set};let Q={},J=new Set(await zR(Y.$anyOf,Z)),z=new Set(await zR(Y.$allOf,Z));for(let[K,X]of Object.entries(Y)){if(K==="$allOf"||K==="$anyOf"||!X)continue;Q[K]=X}return{children:Q,anyOf:J,allOf:z}}function WK(Y,Z,Q=!1){let J=Array.from(new Set(Z)),{match:z,candidates:K}=P0(Y,J,Q);if(z)return{match:z,isAmbiguous:!1};if(Y&&K&&K.length>1)return{match:null,isAmbiguous:!0};return{match:null,isAmbiguous:!1}}async function XR(Y,Z,Q,J){let z=Q.$root,K=new Set,X=new Set,H=[...Y],W=!1,q=Z,G=(L,N)=>({git$:J.git$,args:H,index:L,cursorIndex:q,mode:N});for(let L=0;L<Z;L++){let N=H[L];if(!N)continue;z=await HK(z,G(L,"history"));let _=await KR(z,G(L,"history")),I=Object.keys(_.children),w=WK(N,I);if(w.isAmbiguous)return{completions:[]};if(w.match){for(let u of _.allOf)K.add(u);z=await HK(_.children[w.match],G(L,"history")),H[L]=w.match,W=!1;continue}let A=WK(N,_.anyOf);if(A.isAmbiguous)return{completions:[]};if(A.match){if(W)return{completions:[]};W=!0,H[L]=A.match;continue}let x=new Set([..._.allOf,...K]),E=WK(N,x);if(E.isAmbiguous)return{completions:[]};if(E.match){if(X.has(E.match))return{completions:[]};X.add(E.match),H[L]=E.match;continue}if(N.startsWith("-"))return{completions:[]}}z=await HK(z,G(Z,"suggest"));let $=await KR(z,G(Z,"suggest")),B=new Set;for(let L of Object.keys($.children))B.add(L);if(!W)for(let L of $.anyOf)B.add(L);let V=new Set([...$.allOf,...K]);for(let L of V)if(!X.has(L))B.add(L);let F=H[Z]||"";return{completions:Array.from(B).filter((L)=>L.startsWith(F)&&L!==F.trim()).sort((L,N)=>L.length-N.length||L.localeCompare(N))}}var HR=O(()=>{L0()});var RA,qK;var WR=O(()=>{g5();h5();d5();b5();IZ();ez();m5();T5();f5();b7();m7();u5();XK();p5();h8();RA={commit:{$root:{auto:{$anyOf:["--no-commit","--copy","--yes"]}}},push:{$root:{$anyOf:["-fl","--no-lint"]}},pull:{$root:{$anyOf:["-au"]}},status:{$root:{$anyOf:["--recursive","-r"]}},log:{$root:{$anyOf:["--author","--relative"]}},diff:{$root:{$anyOf:["--json"]}},show:{$root:{$anyOf:["--json"]}}},qK={...RA,cache:kF,clear:IF,doctor:dF,"gdx-config":DF,graph:qB,help:rF,lint:hF,nocap:pV,parallel:OF,stash:zB,stats:$B,status:mF,macro:QR,submodule:cF,reword:sF}});function qR(Y){let Z=process.env.GDX_CMP_IDX,Q=Number.parseInt(Z||"",10);if(!Number.isInteger(Q)||Q<0)Q=Math.max(0,Y-1);if(Y>0&&Q>=Y)Q=Y-1;return Q}async function GK(Y){let Z=c.logLevel;c.logLevel="off";try{let Q=[...Y.args],{args:J,cursorIndex:z,cursorInGitGlobal:K}=g7(Q,qR(Q.length));if(J[0]==="__completion")J.shift();let X=z??qR(J.length);if(R.debug(`Completion invoked with args: ${J.join(" ")} (idx=${X})`,"completion"),K)return 0;if(J.length===0||X===0){let B=J[0]||"",V=new Set;for(let M of Object.keys(qK))V.add(M);for(let M of gK)V.add(M);for(let M of mK)V.add(M);for(let M of a4)V.add(M);let F=Array.from(V).filter((M)=>M.startsWith(B)).sort((M,L)=>M.length-L.length||M.localeCompare(L));R.debug(`Completion root-level matches: ${F.join(", ")}`,"completion");for(let M of F)process.stdout.write(`${M}
|
|
1035
|
+
`);return 0}let H=J[0],{match:W}=P0(H,a4),q=W||OA[H]||H,G=J.slice(1),$=qK[q];if($){let B=X-1;if(B>=0&&B<G.length){let{completions:V}=await XR(G,B,$,{git$:Y.git$});R.debug(`Completion matches for command '${q}': ${V.join(", ")}`,"completion");for(let F of V)process.stdout.write(`${F}
|
|
1036
|
+
`);return 0}}return R.debug(`No completion structure for command '${q}', or index out of range`,"completion"),0}finally{c.logLevel=Z}}var OA;var GR=O(()=>{HR();CZ();v0();W0();D0();L0();WR();OA={s:"status",co:"checkout",br:"branch",cmi:"commit",mg:"merge",pl:"pull",pu:"pull",ps:"push",ad:"add",rv:"revert",rb:"rebase",lg:"log",sta:"stash"}});var I0;var QK=O(()=>{ez();b7();IZ();m7();h5();g5();uz();b5();T5();f5();m5();d5();u5();XK();p5();h8();GR();I0={__completion:GK,help:c5,stash:QB,graph:TZ,stats:f9,clear:pz,cache:cz,commit:LF,gdxConfig:mz,nocap:vz,parallel:gz,lint:iz,doctor:rz,status:oz,macro:JR,submodule:lF,reword:tz}});H0();QK();h0();L0();CZ();W0();var MA=(Y="gdx")=>{return`# gdx shell integration
|
|
976
1037
|
${Y}() {
|
|
977
1038
|
local tmp
|
|
978
1039
|
tmp="$(mktemp)"
|
|
979
1040
|
GDX_RESULT="$tmp" command gdx "$@"
|
|
980
1041
|
local ret=$?
|
|
981
|
-
if [ $ret -eq ${
|
|
1042
|
+
if [ $ret -eq ${ZY} ]; then
|
|
982
1043
|
if [ -f "$tmp" ]; then
|
|
983
1044
|
cd "$(cat "$tmp")"
|
|
984
1045
|
fi
|
|
@@ -1027,13 +1088,13 @@ __gdx_complete_bash() {
|
|
|
1027
1088
|
}
|
|
1028
1089
|
|
|
1029
1090
|
complete -o bashdefault -o default -F __gdx_complete_bash ${Y}
|
|
1030
|
-
`},
|
|
1091
|
+
`},DA=(Y="gdx")=>{return`# gdx shell integration
|
|
1031
1092
|
${Y}() {
|
|
1032
1093
|
local tmp
|
|
1033
1094
|
tmp="$(mktemp)"
|
|
1034
1095
|
GDX_RESULT="$tmp" command gdx "$@"
|
|
1035
1096
|
local ret=$?
|
|
1036
|
-
if [ $ret -eq ${
|
|
1097
|
+
if [ $ret -eq ${ZY} ]; then
|
|
1037
1098
|
if [ -f "$tmp" ]; then
|
|
1038
1099
|
cd "$(cat "$tmp")"
|
|
1039
1100
|
fi
|
|
@@ -1082,13 +1143,13 @@ if ! (( $+functions[compdef] )); then
|
|
|
1082
1143
|
fi
|
|
1083
1144
|
|
|
1084
1145
|
compdef __gdx_complete_zsh ${Y}
|
|
1085
|
-
`},
|
|
1146
|
+
`},NA=(Y="gdx")=>{return`# gdx shell integration
|
|
1086
1147
|
function ${Y}
|
|
1087
1148
|
set -l tmp (mktemp)
|
|
1088
1149
|
set -x GDX_RESULT "$tmp"
|
|
1089
1150
|
command gdx $argv
|
|
1090
1151
|
set -l ret $status
|
|
1091
|
-
if test $ret -eq ${
|
|
1152
|
+
if test $ret -eq ${ZY}
|
|
1092
1153
|
if test -f "$tmp"
|
|
1093
1154
|
cd (cat "$tmp")
|
|
1094
1155
|
end
|
|
@@ -1129,7 +1190,7 @@ complete -c ${Y} -w git
|
|
|
1129
1190
|
|
|
1130
1191
|
# Then add gdx-specific completions (they take precedence)
|
|
1131
1192
|
complete -c ${Y} -f -a "(__gdx_complete_fish)"
|
|
1132
|
-
`},
|
|
1193
|
+
`},_A=(Y="gdx")=>{return`# gdx shell integration
|
|
1133
1194
|
function ${Y} {
|
|
1134
1195
|
$tmp = [System.IO.Path]::GetTempFileName()
|
|
1135
1196
|
$env:GDX_RESULT = $tmp
|
|
@@ -1140,7 +1201,7 @@ function ${Y} {
|
|
|
1140
1201
|
}
|
|
1141
1202
|
if ($command) {
|
|
1142
1203
|
& $command @args
|
|
1143
|
-
if ($LASTEXITCODE -eq ${
|
|
1204
|
+
if ($LASTEXITCODE -eq ${ZY}) {
|
|
1144
1205
|
if (Test-Path $tmp) {
|
|
1145
1206
|
$target = Get-Content $tmp -Raw
|
|
1146
1207
|
if ($target) {
|
|
@@ -1210,4 +1271,4 @@ $__gdxCompleter = {
|
|
|
1210
1271
|
}
|
|
1211
1272
|
|
|
1212
1273
|
Register-ArgumentCompleter -Native -CommandName ${Y} -ScriptBlock $__gdxCompleter
|
|
1213
|
-
`},
|
|
1274
|
+
`},UR=(Y,Z)=>{switch(Y.toLowerCase()){case"bash":return MA(Z);case"zsh":return DA(Z);case"fish":return NA(Z);case"powershell":case"pwsh":return _A(Z);default:throw Error("Unsupported shell: ${shell}`")}};v0();D0();ZK();var LA=process.argv.slice(2);R.debug(`Raw arguments: ${g(process.argv)}`,"gdx");async function wA(){let Y=g7(LA),Z={args:new MY(Y.args),git$:""},Q=Z.args;if(R.debug(`Parsed arguments: ${g(Q.toArray())}`,"gdx"),Q[0]==="--init"){let K=Q.popValue("--shell")||Q.popValue("--init"),X=Q.popValue("--cmd");if(K)try{let H=UR(K,X||void 0);return j(H),0}catch(H){return R.error(g(H,{color:!0})),1}else return R.error("<shell-name> is not specified. --init <shell-name> is required for initialization."),1}if(Q[0]==="__completion")return await I0.__completion({...Z,git$:"git"});let J=await c1("git");if(!J)throw new a("Git is not installed or not found in PATH.","GIT_NOT_FOUND");if(Z.git$=Y.gitArgs.length?[J,...Y.gitArgs]:J,Q[0]==="--bypass")return x7(J,Q.slice(1));let z=Q.popValue("--loglevel");if(z){let K=["fatal","error","warn","info","debug"];if(K.includes(z))c.logLevel=z;else return R.error(`Invalid log level '${z}'. Expected: ${K.join(", ")}`),1}if(Q.includes("--ghelp")||Q.includes("-gh")||Q.includes("--gdx-help")||Q.length===0)return I0.help(),0;return YK(Z)}(async()=>{try{let Y=await wA();if(c.finalStringOutput)j(c.finalStringOutput);process.exit(c.exitCodeOverride>=0?c.exitCodeOverride:Y)}catch(Y){R.error(g(Y,{color:!0})),process.exit(1)}})();
|