gdx 0.4.1 → 0.4.2
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 +25 -15
- package/dist/index.js +983 -853
- package/dist/index_old.js +1337 -0
- package/package.json +23 -20
|
@@ -0,0 +1,1337 @@
|
|
|
1
|
+
import{createRequire as D_}from"node:module";var q_=Object.create;var{getPrototypeOf:G_,defineProperty:Q9,getOwnPropertyNames:U_}=Object;var V_=Object.prototype.hasOwnProperty;function B_(Z){return this[Z]}var $_,F_,O_=(Z,Y,Q)=>{var J=Z!=null&&typeof Z==="object";if(J){var X=Y?$_??=new WeakMap:F_??=new WeakMap,K=X.get(Z);if(K)return K}Q=Z!=null?q_(G_(Z)):{};let z=Y||!Z||!Z.__esModule?Q9(Q,"default",{value:Z,enumerable:!0}):Q;for(let H of U_(Z))if(!V_.call(z,H))Q9(z,H,{get:B_.bind(Z,H),enumerable:!0});if(J)X.set(Z,z);return z};var M6=(Z,Y)=>()=>(Y||Z((Y={exports:{}}).exports,Y),Y.exports);var R_=(Z)=>Z;function M_(Z,Y){this[Z]=R_.bind(null,Y)}var TY=(Z,Y)=>{for(var Q in Y)Q9(Z,Q,{get:Y[Q],enumerable:!0,configurable:!0,set:M_.bind(Y,Q)})};var _=(Z,Y)=>()=>(Z&&(Y=Z(Z=0)),Y);var E6=D_(import.meta.url);import{createRequire as __}from"module";class jH{value;start;end;constructor(Z,Y,Q){this.value=Z,this.start=Y,this.end=Q}}class X9{TF;IDF;TF_IDF;constructor(Z){this.TF=Z}}class wH{x;y;z;r;t;get unit(){return this.#Y}get dimension(){return this.#Q}#Y;#Q=0;constructor(Z,Y,Q=null){if(this.x=Z,this.y=Y,this.z=Q,Q)this.#Q=3;else if(Y)this.#Q=2;else if(Z)this.#Q=1}toPolarCoords(Z="r"){this.#Y=Z;let{r:Y,t:Q}=w.MathKit.toPolarCoords(this.x,this.y,Z);return this.r=Y,this.t=Q,this}toCartesianCoords(){if(!this.#Y&&this.x)return this;let{x:Z,y:Y}=w.MathKit.toCartesianCoords(this.r,this.t,this.#Y);return this.x=Z,this.y=Y,this}setUnit(Z){if(!Z||Z!="d"&&Z!="r")throw Error("unit must be 'r' or 'd', given: "+Z);if(this.#Y==Z)return;if(Z=="r")this.#Y=Z,this.t=w.MathKit.radians(this.t);else this.#Y=Z,this.t=w.MathKit.degrees(this.t)}}class TH{constructor(Z,Y,Q,J,X,K,z){this.x=Z,this.y=Y,this.f=Q,this.ymid=J,this.iterations=X,this.events=z,this.msg=K}_at(Z,Y){function Q(F){return F*F}let J,X,K,z,H,W,q,G,U,B;return J=this.x[Y],X=this.x[Y+1],z=this.y[Y],H=this.y[Y+1],q=X-J,K=J+0.5*q,W=this.ymid[Y],G=this.f[Y]-z*(1/(J-K)+2/(J-X)),U=this.f[Y+1]-H*(1/(X-K)+2/(X-J)),B=[Q(Z-X)*(Z-K)/Q(J-X)/(J-K),Q(Z-J)*Q(Z-X)/Q(J-K)/Q(X-K),Q(Z-J)*(Z-K)/Q(X-J)/(X-K),(Z-J)*Q(Z-X)*(Z-K)/Q(J-X)/(J-K),(Z-X)*Q(Z-J)*(Z-K)/Q(J-X)/(X-K)],z*B[0]+W*B[1]+H*B[2]+G*B[3]+U*B[4]}at(Z){let Y,Q,J;if(typeof Z!=="number"){let K=Z.length,z=Array(K);for(Y=K-1;Y!==-1;--Y)z[Y]=this.at(Z[Y]);return z}let X=this.x;Y=0,Q=X.length-1;while(Q-Y>1)if(J=Math.floor(0.5*(Y+Q)),X[J]<=Z)Y=J;else Q=J;return this._at(Z,Y)}}class B1{value;index;type;constructor(Z,Y,Q=-1){this.value=Z,this.type=Y,this.index=Q}valueOf(){return this.value}toString(){return this.value.toString()}}class K8{type;UPID=null;callback;constructor(Z,Y,Q=null){if(Q)this.type=1,this.UPID=Q;else this.type=Z;this.callback=Y}}function w_(Z){return Z==null||typeof Z=="number"||typeof Z=="string"||typeof Z=="boolean"||Z instanceof ArrayBuffer||Z instanceof MessagePort||Z instanceof ReadableStream||Z instanceof WritableStream||Z instanceof TransformStream}var N_,X8,j_,V1,J9="[#*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])",w,gP,LH,mP,LY,uP,IH,pP,dP,e0,cP,lP,AH,MZ,iP,nP,oP,aP,sP,rP,tP,eP,o,Zv,IY,o6,Yv,Qv,Jv,Xv,Kv,zv,Hv,Wv,qv,a6,Gv,Uv,Vv,Bv,$v,Fv,Ov,Rv,Mv,Dv,CH,_v,Nv,jv,z8,wv,EH,d0,H8,V,Tv,Lv,Iv,Av,Cv,K9,Ev,xv,Sv,kv,Pv,vv,yv,bv,fv,hv,xH,gv,mv,uv,pv,dv,W8,cv,D6,DZ,lv,iv,nv,s,ov,av,sv,rv,tv,B6,ev,Zy,u;var G0=_(()=>{N_=__(import.meta.url),X8=typeof window>"u"||typeof process<"u",j_={dgram:null,worker_threads:null,os:null,fs:null,mathjs:null},V1={consoleTimeInstances:null};w={_modules:j_,arrFindLast(Z,Y){for(let Q=Z.length-1;Q>=0;Q--)if(Y(Z[Q],Q,Z))return Z[Q];return},arrToString(Z,Y={}){let{maxDepth:Q=4,indent:J=3,maxRow:X=10,maxCol:K=20,color:z=!1,defColor:H=void 0,noHeader:W=!1}=Y;if(Q<1)Q=1;let q={color:z,defColor:H},G=w.getDimensions(Z,"max"),U=G.length*0.4,B=typeof J=="number"?" ".repeat(J):J,F=null;if(z)F={magenta:w.ncc(11550650),gray:w.ncc(4802889),_default:w.ncc(H)};if(!W&&(!(Z instanceof Array)||G.length>2||Math.max(...G)>5))return D(Z)+$(Z,0);else return $(Z,0);function $(j,M,T=0){let N="";if(M>Q-1)if(z)return F.gray+`... [${O(j)||"Array"}]`+F._default;else return`... [${O(j)||"Array"}]`;if(!w.isArrayLike(j))return N+w.yuString(j,q);let L;if(M>U)L=w.getDimensions(j,"max");else L=G.slice(M);let x=G[M+1]!=null&&(L[2]!=null||L[1]>2)&&M<Q-1,S=T?B.repeat(T):"",g=S+B,h=x?`[
|
|
2
|
+
`+g:"[",f=x?`
|
|
3
|
+
`+S+"]":"]",v=j.length;N+=h;for(let d=0;d<v;d++){if(w.isArrayLike(j[d]))N+=O(j[d])+$(j[d],M+1,x?T+1:T);else N+=w.yuString(j[d],q);if(x){if(d>=X-2){if(N+=`,
|
|
4
|
+
`+g,z)N+=F.gray+"... ("+(v-X+1)+" more)"+F._default;else N+="... ("+(v-X+1)+" more)";break}}else if(d>=K-2){if(z)N+=", "+F.gray+"... ("+(v-K+1)+" more)"+F._default;else N+=", ... ("+(v-K+1)+" more)";break}if(d!=v-1)N+=x?`,
|
|
5
|
+
`+g:", "}return N+=f,N}function O(j){if(j instanceof Array)return"";if(z)return F.magenta+`${j.constructor.name}: `+F._default;else return`${j.constructor.name}: `}function D(j){if(!w.isArrayLike(j))return"";if(z)return F.magenta+`${j.constructor.name}(${G}): `+F._default;else return`${j.constructor.name}(${G}): `}},argvHasFlag(Z,Y=process?.argv){if(!Y||typeof Z!="string")return!1;let Q=Z.startsWith("-")?"":Z.length===1?"-":"--",J=Y.indexOf(Q+Z),X=Y.indexOf("--");return J!==-1&&(X===-1||J<X)},async asyncSleep(Z){return new Promise((Q)=>{if(!Z||Z<4||typeof Z!="number")Q();setTimeout(Q,Z)})},beautifyJson(Z){Z=Z.replace(/\s/,"");let Y=Z+"",Q=w.getMatchAllIndexes(Z.matchAll(/[{[]/g)).sort((z,H)=>z-H),J=w.getMatchAllIndexes(Z.matchAll(/[}\]]/g)).sort((z,H)=>z-H);for(let z=0,H=0,W=0;W<Z.length;){let q=Q[K(Q,W)],G=J[K(J,W)];if(q=q==null?1/0:q,q<G)z++,W=q+1;else z--,W=G+1;let U=Q[K(Q,W)],B=J[K(J,W)],F=U<B?U:B,$="".padEnd(z,"\t");if(X(Y[W+H-1]))Y=w.strSplice(Y,W+H,0,`
|
|
6
|
+
`);else Y=w.strSplice(Y,W+H-1,0,`
|
|
7
|
+
`),Y=w.strSplice(Y,W+H,0,$),H+=$.length;H++;let O=Z.substring(W,F),D=w.getMatchAllIndexes(O.matchAll(/"/g)).filter((M)=>M!=0?O[M-1]!="\\":!0);if(D.length%2!=0)throw Error('cannot match Double-Quote correctly from string: "'+O+'"');let j=w.getMatchAllIndexes(O.matchAll(/[,]/g)).filter((M)=>{for(let T=0;T<D.length;T+=2)if(M>D[T]&&M<D[T+1])return!1;return!0});for(let M=0;M<j.length+1;M++){let T=M==0?W+H:j[M-1]+H+W+1;if(X(Y[T-1])==null)Y=w.strSplice(Y,T,0,$),H+=$.length;if(!Y[j[M]+H+W])break;Y=w.strSplice(Y,j[M]+1+H+W,0,`
|
|
8
|
+
`),H++}}return Y;function X(z){let H=new RegExp(/[{[]/),W=new RegExp(/[}\]]/);if(H.test(z))return 1;if(W.test(z))return 0;return null}function K(z,H){let W=1/0,q;for(let G=0,U=z[G];G<z.length;U=z[++G]){let B=U-H;if(!B)return G;if(B<0)continue;if(B<W)W=B,q=G}return q}},beforeExit(Z,Y=!1){if(Y)process.stdin.resume();let Q=!1,J=!1;["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException","SIGTERM"].forEach((X)=>{process.on(X,(...K)=>{if(["SIGINT","SIGUSR1","SIGUSR2"].includes(X))if(Q)console.log("Forcefully Exiting..."),process.exit(1);else Q=!0;if(J)return;else J=!0;let z=Z(X,...K);if(z instanceof Promise){z.then(()=>{if(X!=="exit"&&Y)process.exit(0)}).catch((H)=>{if(console.error("Error in beforeExit callback:",H),X!=="exit"&&Y)process.exit(1)});return}if(X!=="exit"&&Y)process.exit(0)})})},changeDateTimezone(Z,Y){let Q=new Date(`${Z.toLocaleString("en-US",{timeZone:Y})}`),J=Z.getTime()-Q.getTime();return new Date(Z.getTime()-J)},charTypeAt(Z,Y){let Q=w.CONSTS.UNICODES_RANGE_TABLE;if(Z<0)Z=Y.length+Z;let J=Y.charCodeAt(Z);if(isNaN(J))return null;for(let X=Q.length>>1,K=0;X>=0&&X<Q.length;K++){if(K>(Q.length>>1)+1)break;if(w.isArrayLike(Q[X].to)){for(let z=0;z<Q[X].to.length;z++)if(J>=Q[X].from[z]&&J<=Q[X].to[z])return Q[X].type;if(J>Q[X].from[0])X++;else X--}else{if(J>=Q[X].from&&J<=Q[X].to)return Q[X].type;if(J>Q[X].from)X++;else X--}}return null},CheckCache:class Z{static#Y=null;static#Q=null;static#Z=null;static get supportsColor(){if(this.#Y==null)this.#Y=w.supportsColor();return this.#Y??0}static get supportsHyperlink(){if(this.#Q==null)this.#Q=w.supportsHyperlink();return this.#Q}static set supportsColor(Y){this.#Y=Y}static set supportsHyperlink(Y){this.#Q=Y}static get forceColor(){if(!X8)this.#Z=!1;if(this.#Z===void 0){let Y=process.env;if(w.argvHasFlag("no-color")||w.argvHasFlag("no-colors")||w.argvHasFlag("color=false"))this.#Z=!1;else if(w.argvHasFlag("color")||w.argvHasFlag("colors")||w.argvHasFlag("color=true")||w.argvHasFlag("color=always"))this.#Z=!0;if("FORCE_COLOR"in Y)this.#Z=Y.FORCE_COLOR.length===0||parseInt(Y.FORCE_COLOR,10)!==0}return this.#Z}static set forceColor(Y){this.#Z=Y}},cleanArr(Z,Y=null){if(Y&&Y instanceof Array)return Z.filter((Q)=>{return!Y.includes(Q)});if(Y!==null)return Z.filter((Q)=>{return Q!==Y});return Z.filter((Q)=>Q!==""&&Q!=="\r"&&!w.isEmptyArray(Q)&&!w.isEmptyObject(Q))},cleanComments(Z){return Z.replace(w.REGEXP.JSComments,(Y,Q)=>Q?"":Y)},cleanString(Z){return Z.normalize().replace(w.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,AnsiColorCodes:Object.freeze({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","~italic":"\x1B[23m",underline:"\x1B[4m","~underline":"\x1B[24m",blink:"\x1B[5m","~blink":"\x1B[25m",invert:"\x1B[7m","~invert":"\x1B[27m",hidden:"\x1B[8m","~hidden":"\x1B[28m",strikethrough:"\x1B[9m","~strikethrough":"\x1B[29m",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"})}),Convert:{decimalColorToRGB(Z){return{r:Z>>16&255,g:Z>>8&255,b:Z&255}},basicColorFromRgb(Z){let Y=Z.r>127,Q=Z.g>127,J=Z.b>127;switch(Y+Q+J){case 3:return"white";case 0:return"black";case 2:if(!Y)return"cyan";else if(!Q)return"magenta";else if(!J)return"yellow";case 1:if(Y)return"red";else if(Q)return"green";else if(J)return"blue"}},_8bitColorFromRgb(Z){let{r:Y,g:Q,b:J}=Z;if(Y===Q&&Q===J){if(Y<8)return 16;if(Y>248)return 231;return Math.round((Y-8)/247*24)+232}let X=Math.round(Y/255*5),K=Math.round(Q/255*5),z=Math.round(J/255*5);return 16+36*X+6*K+z}},ConsoleTime:class Z{static lookbackLimit=100;static elapsedStart(Y){if(V1.consoleTimeInstances==null){V1.consoleTimeInstances=new Map([[Y,[w.getProcessTime()]]]);return}if(!V1.consoleTimeInstances.has(Y)){V1.consoleTimeInstances.set(Y,[w.getProcessTime()]);return}let Q=V1.consoleTimeInstances.get(Y);if(Q.unshift(w.getProcessTime()),this.lookbackLimit>0&&Q.length>=this.lookbackLimit)Q.pop()}static elapsedEnd(Y){if(!V1.consoleTimeInstances.has(Y))return;let Q=V1.consoleTimeInstances.get(Y),J=Q[0];Q[0]=w.getProcessTime()-J}static condense(Y){let Q=V1.consoleTimeInstances.get(Y);if(!Q)return null;let J=0;for(let X of Q)J+=X;return J/=Q.length,V1.consoleTimeInstances.delete(Y),{print(){console.log(Y+": "+w.toShortNum(J)+"s")},valueOf:()=>J,toString:()=>Y+": "+w.toShortNum(J)+"s",value:J}}},compareDate(Z,Y,Q,J="day"){if(!Z||!Q)return!1;let X=W(Z),K=W(Q),z=X.next(),H=K.next();do if(z.value!==H.value)switch(Y){case">":return z.value>H.value;case"<":return z.value<H.value;case">=":return z.value>=H.value;case"<=":return z.value<=H.value;default:return!1}while(!(z=X.next()).done&&!(H=K.next()).done);return Y[1]==="=";function*W(q){if(yield q.getFullYear(),J==="year")return;if(yield q.getMonth(),J==="month")return;yield q.getDate()}},DataScienceKit:{frequencyOf(Z){if(!Z||typeof Z!="string"&&!w.isArrayLike(Z))return new Map;let Y=[...new Set(Z)],Q=new Map(Y.map((J)=>[J,0]));for(let J of Z)Y.forEach((X)=>{if(X==J)Q.set(X,Q.get(X)+1)});return Q},LCS_of(Z,Y,Q=(J,X)=>J===X){if(!(Z?.length&&Y?.length))return[];let J=[],X=Y.length,K=Z.length;while(J.length<K)J.push(Array(X));for(let q=0;q<J.length;q++)for(let G=0;G<J[q].length;G++){if(Q(Z[q],Y[G])){let F=W(q-1,G-1);J[q][G]=[F+1,3];continue}let U=W(q,G-1),B=W(q-1,G);if(U>B)J[q][G]=[U,2];else J[q][G]=[B,1]}let z=[];return H(K-1,X-1),z;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:z.unshift(Z[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(Z,Y,Q=(J,X)=>J===X){if(!(Z?.length&&Y?.length))return 0;let J=[],X=Y.length,K=Z.length;while(J.length<K)J.push(Array(X));for(let H=0;H<J.length;H++)for(let W=0;W<J[H].length;W++){if(Q(Z[H],Y[W])){let U=z(H-1,W-1);J[H][W]=[U+1,3];continue}let q=z(H,W-1),G=z(H-1,W);if(q>G)J[H][W]=[q,2];else J[H][W]=[G,1]}return J[K-1][X-1][0];function z(H,W){if(H<0||W<0)return 0;else return J[H][W][0]}},TFIDF_of(Z){let Y=Z.length,Q=Array(Y),J=new Map;for(let K=0;K<Y;K++){let z=Z[K].length,H=w.DataScienceKit.frequencyOf(Z[K]);Q[K]=new Map;for(let W=0;W<z;W++){if(!Q[K].has(Z[K][W]))Q[K].set(Z[K][W],new X9(H.get(Z[K][W])/z));if(!J.has(Z[K][W]))J.set(Z[K][W],0)}}let X=[...J.keys()];for(let K=0;K<X.length;K++)for(let z of Z)if(z.includes(X[K]))J.set(X[K],J.get(X[K])+1);for(let[K,z]of J)J.set(K,Math.log10(Y/z));for(let K of Q)for(let[z,H]of K)H.IDF=J.get(z),H.TF_IDF=H.IDF*H.TF;return Q},TFIDF_extends(Z,Y){let Q=Z.concat(Array(Y.length)),J=new Map,X=Q.length;for(let z=0;z<X;z++){let H,W,q=!1,G=z-Z.length;if(!Q[z])q=!0,H=Y[G].length,W=w.DataScienceKit.frequencyOf(Y[G]),Q[z]=new Map;else H=Q[z].size;for(let U=0;U<H;U++){if(q&&!Q[z].has(Y[G][U])){if(Q[z].set(Y[G][U],new X9(W.get(Y[G][U])/H)),!J.has(Y[G][U]))J.set(Y[G][U],0);continue}let B=[...Q[z].keys()][U];if(!J.has(B))J.set(B,0)}}let K=[...J.keys()];for(let z=0;z<K.length;z++)for(let H of Q)if(H.has(K[z]))J.set(K[z],J.get(K[z])+1);for(let[z,H]of J)J.set(z,Math.log10(X/H));for(let z of Q)for(let[H,W]of z)W.IDF=J.get(H),W.TF_IDF=W.IDF*W.TF;return Q},wagnerFischer_of(Z,Y,Q=(J,X)=>J===X){let J=[],X,K;for(X=0;X<=Z.length;X++)J[X]=[X];for(K=0;K<=Y.length;K++)J[0][K]=K;for(X=1;X<=Z.length;X++)for(K=1;K<=Y.length;K++){if(Q(Z[X-1],Y[K-1])){J[X][K]=J[X-1][K-1];continue}J[X][K]=Math.min(J[X-1][K-1]+1,Math.min(J[X][K-1]+1,J[X-1][K]+1))}return{distance:J[Z.length][Y.length],getOperations(){let z=J.length-1,H=J[0].length-1,W=[],q=new w.SafeTrue;while((z>0||H>0)&&q.True)switch(G(z,H,J)){case 2:W.push({type:"delete",index:z-1,value:Z[z-1]}),z--;break;case 0:W.push({type:"insert",index:z,value:Y[H-1]}),H--;break;case 1:if(J[z][H]!==J[z-1][H-1])W.push({type:"replace",index:z-1,value:Y[H-1]});z--,H--;break}return W;function G(U,B,F){let $=[F[U][B-1],F[U-1][B-1],F[U-1][B]];if(B<=0)return 2;if(U<=0)return 0;if($[0]==$[1])if($[2]==$[1])return 1;else return 0;let O=$[0],D=0;for(let j=1;j<$.length;j++)if($[j]<O)O=$[j],D=j;return D}}}}},deferredFunc(Z,Y=200,Q=!1){let J=null;return function(...X){let K=!1;if(Q&&!J)Z(...X),K=!0;clearTimeout(J),J=setTimeout(()=>{if(J=null,!K)Z(...X)},Y)}},digitAt(Z,Y){try{return parseInt((Y+"").at(Z))}catch{return 0}},digitAtRange(Z,Y,Q){if(!Q)return;Z=Z<0?void 0:Z??void 0,Y=Y<0?void 0:Y??void 0;let J=(Q+"").slice(Z,Y);return parseInt(J.length?J:"0")},getDimensions(Z,Y="max"){let Q=[],J=Y==="min"?Math.min:Math.max,X=Y==="min"?1/0:0,K=X,z=[],H=0;if(!w.isArrayLike(Z))return Q;if(Q.push(Z.length),Y==="symmetric")W(Z,0);else q(Z,0,!0);return Q;function W(G,U){if(!w.isArrayLike(G?.[Q[U]-1]))return;Q.push(G[Q[U]-1].length),W(G[Q[U]-1],U+1)}function q(G,U,B=!1,F=[]){for(let $=0;$<Q[U];$++){if(!w.isArrayLike(G[$]))continue;if(G[$].length!=K){if(Y==="fixed"&&K!==X)throw Error(`Array length mismatched at depth ${U+1} position (${[...F,$].join(",")}):
|
|
9
|
+
expected length: ${K}
|
|
10
|
+
actual length: ${G[$].length}`);K=J(K,G[$].length)}z.push([G[$],U+1,!1,[...F,$]])}if(B&&K!==X){Q.push(K),K=X;let $=[...z];z=[];for(let O=0;O<$.length;O++){if(O==$.length-1)$[O][2]=!0;if(++H>5000){queueMicrotask(()=>{H=0,q(...$[O])});continue}q(...$[O])}}}},Err:class Z extends Error{constructor(Y,Q=null,J=null,X=null){if(w.isError(Y)){if(!Q)Q=Y.name;if(!J)J=Y.code??Y.exitCode;if(!X)X=Y.stack;Y=Y.message}super(Y);if(Q)this.name=Q;if(J)this.code=J;if(X)this.stack=X}toString(Y={}){if(!this||!w.isError(this))return"[Error unknown]";return w.Err.toString(this,Y)}static from(Y,Q=null,J=null,X=null){return new w.Err(Y,Q,J,X)}static isError(Y){if(Y instanceof Error)return!0;if(Object.prototype.isPrototypeOf.call(Error.prototype,Y))return!0;return typeof Y?.message=="string"&&typeof Y?.stack=="string"}static toString(Y,Q={}){let{color:J=!1,defColor:X=void 0}=Q,K=(J?w.ncc("Red")+"ERROR"+w.ncc(X):"ERROR")+" Message: ";if(J)K+=w.ncc("Red")+(Y?.message??"[unknown]")+w.ncc(X);else K+=Y?.message??"[unknown]";if(Y?.name)if(K+=`
|
|
11
|
+
Name: `,J)K+=w.ncc("Red")+Y.name+w.ncc(X);else K+=Y.name;if(Y?.code)if(K+=`
|
|
12
|
+
Code: `,J)K+=w.ncc("Yellow")+Y.code+w.ncc(X);else K+=Y.code;if(Y?.stack)if(K+=`
|
|
13
|
+
Stack: `,J)K+=w.ncc(5592405)+Y.stack+w.ncc(X);else K+=Y.stack;return K}},escapeRegExp(Z){return Z.replace(/[[\]{}.*$^|\-?+,:\\]/g,"\\$&")},estimateStrComplexity(Z){if(w.hasEmojiEst(Z))return 2;let Q=!1;for(let X of w.CONSTS.UNICODES_RANGE_TABLE){if(!X.type.endsWith("full"))continue;if(Q=X.regex.test(Z))break}if(Q)return 1;if(w.REGEXP.ANSICode.test(Z))return 0;return-1},ex_length(Z,Y=0){if(typeof Z!=="string")throw TypeError("argument must be a string");if(Y<0)return Z.length;Z=w.cleanString(Z);let Q=Z.length;if(Y<1)return Q;let J=Z;for(let H of w.CONSTS.UNICODES_RANGE_TABLE){if(!H.type.endsWith("full"))continue;J=J.replace(H.regex,"")}let X=Q+(Q-J.length);if(Y<2)return X;let K=Z.match(w.REGEXP.EmojiEach)??[],z=0;for(let H of K)z+=H.length;return K.length*2+(X-z)},fileNameCleaner(Z,Y="_"){if(!Z||typeof Z!="string")throw Error("the given `rawName` isn't a string");return Z.trim().replace(/[|/*\\<>"?:]/g,Y)},fixFilePath(Z,Y="_"){if(!Z||!Z?.length)throw"path is either falsy or empty!";return Z.replace(/[:?"<>|*]/g,Y)},fixYTurl(Z){if(Z=Z||void 0,!Z)throw"url can't be falsy!!";if(Z.includes("youtu.be"))Z=Z.replace("https://youtu.be/","https://www.youtube.com/watch?v=");if(Z.includes("&list="))Z=Z.split("&list=")[0];if(Z.includes("?si="))Z=Z.split("?si=")[0];if(Z.includes("https")==!1)Z="https://www."+Z;return Z},fileTypeOf(Z){let Y=Z.slice(Z.lastIndexOf(".")+1).toLowerCase(),Q=Y=="jpg"||Y=="png"||Y=="svg"||Y=="jfif"||Y=="pbm"||Y=="pgm"||Y=="jpeg",J=Y=="txt"||Y=="bat"||Y=="text"||Y=="md"||Y=="json"||Y=="step"||Y=="js"||Y=="cs"||Y=="cpp"||Y=="gitignore"||Y=="java"||Y=="py"||Y=="config"||Y=="cfg"||Y=="ts"||Y=="env",X=Y=="exe"||Y=="vpk"||Y=="qc"||Y=="smd"||Y=="vmt"||Y=="vtf"||Y=="zip"||Y=="7z"||Y=="bin"||Y=="ipynb"||Y=="pyc"||Y=="jar",K=Y=="aiff"||Y=="aif"||Y=="aifc"||Y=="flac"||Y=="mp3"||Y=="mp4"||Y=="mp4a"||Y=="m4a"||Y=="mkv"||Y=="mov"||Y=="wav"||Y=="gif"||Y=="webm";if(Q)return"image";else if(J)return"text";else if(X)return"binary";else if(K)return"media";return null},getMatchAllIndexes(Z){if(!Z)return[];let Y=[];for(let Q of Z)Y.push(Q.index);return Y},getMatchAllResults(Z){if(!Z)return[];let Y=[];for(let Q of Z)Y.push(new jH(Q[0],Q.index,Q.index+Q[0].length));return Y},getRandomInt(Z,Y){return Math.round(Math.random()*(Y-Z)+Z)},getProcessTime(){let Z=process.hrtime();return Z[0]*1000+Z[1]/1e6},hasEmojiEst(Z){for(let Y of Z){let Q=Y.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(Z,Y,Q=!0){if(Y=encodeURI(Y.replace(/\\/g,"/")),!w.CheckCache.supportsHyperlink){if(Q)return Y;return Z}return`\x1B]8;;${Y}\x07${Z}\x1B]8;;\x07`},IDGenerator(Z=null,Y="CCNNNN"){let Q=!1,J=Y.length,X=new w.SafeTrue;while(X.True){let K=Array(J);for(let z=0;z<J;z++)switch(Y[z]){case"C":{let H=w.getRandomInt(65,116);if(H>90)H+=6;K[z]=String.fromCharCode(H);continue}case"N":K[z]=w.getRandomInt(0,9).toString();continue;case"B":{let H=w.getRandomInt(48,109);if(H>57&&H<84)H+=7;else if(H>83)H+=13;K[z]=String.fromCharCode(H);continue}default:K[z]=Y[z];break}if(Z){if(Z instanceof Set)Q=Z.has(K);else Q=Z.includes(K);if(!Q)return K.join("")}else return K.join("")}return null},includesWord(Z,Y,Q=!1){if(!Q)Y=Y.toLowerCase(),Z=Z.toLowerCase();Y=Y.padStart(Y.length+1," ").padEnd(Y.length+2," ");let J=Y.search(Z);if(J!==-1){let X=Y.substring(J-1),K=Y.substring(J+Z.length);if(X.search(w.REGEXP.Seperators)==0&&K.search(w.REGEXP.Seperators)==0)return!0}return!1},IPC:class Z{static Listener=K8;#Y;#Q=new Map;#Z;#J=!1;#X=new Set;peersAddress="localhost";peersPort;listenPort;get protocol(){return this.#Z}constructor(Y="udp4",Q={}){if(!X8)throw Error("IPC is only available on JSRuntime, due to the use of Node modules");let{peersPort:J=null,peersAddress:X=null,listenPort:K=null}=typeof Q=="number"?{listenPort:Q}:Q;if(Y!="nodeworker"&&Y!="udp4"&&Y!="udp6")throw Error(`protocol must be 'nodeworker', 'udp4' or 'udp6' instead given '${Y}'`);if(this.#Z=Y,!w._modules.dgram&&Y!="nodeworker")throw Error(`module 'dgram' not loaded use 'Tools._modules.dgram = require("dgram")' to load it`);if(Y=="nodeworker"){if(!w._modules.worker_threads)throw Error(`module 'worker_threads' not loaded use 'Tools._modules.worker_threads = require("worker_threads")' to load it`);if(!K){if(w._modules.worker_threads.isMainThread)throw Error("when using `nodeworker` protocol, `port` must be provided if on the main thread");this.#Y=w._modules.worker_threads.parentPort,this.#K();return}if(!(K instanceof w._modules.worker_threads.Worker)&&K!==w._modules.worker_threads.parentPort&&K!=null)throw Error(`port must be a type of 'Worker' or a 'parentPort' instead given '${typeof K}'`);this.#Y=K,this.#K();return}if(!J)throw Error("peersPort must be provided for `udp4` or `udp6` protocol");this.listenPort=K,this.peersAddress=X,this.peersPort=J,this.#Y=w._modules.dgram.createSocket(Y),this.#K()}async#K(){if(this.#Y.on("message",this.#z),this.protocol=="nodeworker")return;if(!this.listenPort)return;try{this.#Y.bind(this.listenPort),this.#J=!0}catch(Y){switch(Y.code){case"ERR_SOCKET_BAD_PORT":throw new w.Err(`Tools.IPC: port ${this.listenPort} is not valid`,"IPC_ERR_SOCKET_BAD_PORT",Y.code,Y.stack);case"EADDRINUSE":throw new w.Err(`Tools.IPC: port ${this.listenPort} is already in use`,"IPC_EADDRINUSE",Y.code,Y.stack);default:throw w.Err.from(Y,"IPC_BIND_ERROR").message=`Tools.IPC: failed to bind port ${this.listenPort} `+Y.message}}}bind(Y,Q){if(this.protocol=="nodeworker")return;if(this.peersAddress=Y,this.listenPort=Q,!this.#J)this.#K();return this}close(){if(this.protocol=="nodeworker")return;this.#Y.close()}async advSend(Y,Q){return new Promise((J,X)=>{if(!Y)throw Error("channel must be provided");if(typeof Y!="string")throw Error(`channel must be a type of 'string' instead given '${typeof Y}'`);let{contents:K,UPID:z}=Q;if(!(K instanceof Array))K=[K];let H;try{H=this.protocol=="nodeworker"?{channel:Y,UPID:z,contents:K.map((W)=>{if(w_(W))return W;return"@JSON:"+JSON.stringify(W,w.JSONReplacer)})}:Buffer.from(JSON.stringify({channel:Y,UPID:z,contents:K},w.JSONReplacer))}catch(W){X(w.Err.from(W,"IPC_SERIALIZE_ERROR").message="Tools.IPC: failed to serialize payload,"+W.message);return}if(this.protocol=="nodeworker"){this.#Y.postMessage(H),J();return}this.#Y.send(H,this.peersPort,this.peersAddress,(W)=>{if(W)X(W);J()})})}async send(Y,...Q){return this.advSend(Y,{contents:Q})}on(Y,Q){let J=this.#Q.get(Y);if(!J){this.#Q.set(Y,[new K8(0,Q)]);return}return J.push(new K8(0,Q)),this}once(Y,Q,J=null){let X=this.#Q.get(Y);if(!X){this.#Q.set(Y,[new K8(1,Q,J)]);return}return X.push(new K8(1,Q,J)),this}remove(Y){if(typeof Y=="string")return this.#Q.delete(Y),!0;if(typeof Y!="function")throw Error(`listener must be a type of 'string' or 'function' instead given '${typeof Y}'`);for(let[Q,J]of this.#Q){let X=J.find((z)=>z.callback==Y);if(!X)continue;if(!J.filter((z)=>z.callback!=Y))return this.#Q.delete(Q),!0;return this.#Q.set(Q,J.filter((z)=>z.callback!=X)),!0}return!1}async ask(Y,Q,...J){return new Promise((X,K)=>{let z;if(Q)z=setTimeout(()=>{K(new w.Err(`Tools.IPC: ask timeout on channel: ${Y}`,"IPCAskTimeout"))},Q);let H=this.#H();this.once(Y,(W)=>{if(Q)clearTimeout(z);X(W)},H),this.advSend(Y,{contents:J,UPID:H})})}onAsk(Y,Q){let J=this,X=async function(...K){J.#X.add(this.UPID);let z=await Q(...K);J.advSend(Y,{contents:[z],UPID:this.UPID}),J.#X.delete(this.UPID)};return this.on(Y,X),this}#z=(Y)=>{let Q;try{Q=this.protocol=="nodeworker"?{channel:Y.channel,UPID:Y.UPID,contents:Y.contents.map((X)=>{if(typeof X=="string"&&X.startsWith("@JSON:"))return JSON.parse(X.slice(6),w.JSONReviver);return X})}:JSON.parse(Y.toString(),w.JSONReviver)}catch(X){throw w.Err.from(X,"IPC_DESERIALIZE_ERROR").message="Tools.IPC: failed to deserialize payload,"+X.message}let J=this.#Q.get(Q.channel);if(!J)return;for(let X of J){if(X.UPID){if(X.UPID!=Q.UPID)continue;this.#X.delete(X.UPID)}if(X.callback.call(Q,...Q.contents),X.type==1||X.UPID)this.remove(X.callback)}};#H(){let Y=w.IDGenerator(this.#X,"BBBBBBBB");return this.#X.add(Y),Y}},isArrayLike(Z){let Y=Z?.length;return Array.isArray(Z)||!!Z&&Y!=null&&typeof Z==="object"&&typeof Y==="number"&&(Y===0||Y>0&&(Y-1 in Z))},isArrowFunction(Z){if(typeof Z!=="function")return!1;if(Object.hasOwnProperty.call(Z,"prototype"))return!1;try{return Z.arguments,!1}catch{}return Z.toString().slice(0,20).includes("=>")},isAsyncFunction(Z){if(typeof Z!=="function")return!1;if(Z.constructor?.name==="AsyncFunction")return!0;return(Z instanceof w.CONSTS.AsyncFunction&&w.CONSTS.AsyncFunction!==Function&&w.CONSTS.AsyncFunction!==w.CONSTS.GeneratorFunction)===!0},isClass:(Z)=>{if(typeof Z!=="function")return!1;return Z.toString().startsWith("class")},isNumber:(Z)=>{return/^[0-9]+$|^[0-9]+\\.[0-9]+$/.test(Z)},isEmptyArray:(Z)=>w.isArrayLike(Z)&&!Z.length,isEmptyObject:(Z)=>!w.isArrayLike(Z)&&Z instanceof Object&&!w.propertiesCount(Z),isError(Z){return w.Err.isError(Z)},isValidFilePath(Z){if(!Z||!Z?.length)return!1;if(/[:?"<>|*]/g.test(Z))return!1;return!0},JSONReplacer(Z,Y){if(Y instanceof Map)return{"@dataType":"Map","@value":Array.from(Y.entries())};if(Y instanceof Set)return{"@dataType":"Set","@value":Array.from(Y.values())};switch(typeof Y){case"function":return{"@dataType":"function","@value":Y.toString().replace(/\n* {2,}|\n/g,"")};case"bigint":return{"@dataType":"BigInt","@value":Y.toString()};case"object":for(let Q in Y)if(Y[Q]instanceof Date)Y[Q]={"@dataType":"Date","@value":Y[Q].valueOf()};return Y}return Y},JSONReviver(Z,Y){if(!Y||!Y["@dataType"])return Y;switch(Y["@dataType"]){case"function":return Function("return "+Y["@value"])();case"BigInt":return BigInt(Y["@value"]);case"Map":return new Map(Y["@value"]);case"Set":return new Set(Y["@value"]);case"Date":return new Date(Y["@value"])}return Y},jsTime:{howLong(Z,Y=new Date){let Q=Y.getTime()-Z.getTime();return w.jsTime.getTimeFromMS(Q).modern()},getTimeFromMS(Z){Z=Math.abs(Z);let Y=Z>262800200,Q={year:0,month:0,days:0,hr:0,min:0,sec:0,ms:0},J=[["year",31556926000],["month",2629743830],["days",86400000],["hr",3600000],["min",60000],["sec",1000],["ms",1]];for(let X=0;X<J.length;X++){if(Z<J[X][1])continue;let K=J[X-1]?Z%J[X-1][1]:Z;Q[J[X][0]]=Math.floor(K/J[X][1])}if(Y)return{...Q,toString(){return`${Q.year}:${Q.month}:${Q.days}|${Q.hr}:${Q.min}:${Q.sec}.${Math.round(Q.ms).toString().padStart(3,"0")}`},modern(){if(Q.year+Q.month+Q.days+Q.sec+Q.min+Q.hr==0)return`${w.maxFraction(Q.ms,4)}ms`;else if(Q.year+Q.month+Q.days+Q.min+Q.hr==0)return`${Q.sec}.${Math.round(Q.ms).toString().padStart(3,"0")}s`;else if(Q.year+Q.month+Q.days+Q.hr==0)return`${Q.min}min ${Q.sec}s`;else if(Q.year+Q.month+Q.days==0)return`${Q.hr}hr ${Q.min}min`;else if(Q.year+Q.month==0)return`${Q.days}days ${Q.hr}hr`;else if(Q.year==0)return`${Q.month}months ${Q.days}days`;else return`${Q.year}years ${Q.month}months`}};return{...Q,toString(){return`${Q.hr}:${Q.min}:${Q.sec}.${Math.round(Q.ms).toString().padStart(3,"0")}`},modern(){if(Q.sec+Q.min+Q.hr==0)return`${w.maxFraction(Q.ms,4)}ms`;else if(Q.min+Q.hr==0)return`${Q.sec}.${Math.round(Q.ms).toString().padStart(3,"0")}s`;else if(Q.hr==0)return`${Q.min}min ${Q.sec}s`;else return`${Q.hr}hr ${Q.min}min`}}}},lazySplit:function*(Z,Y){if(Y===""){for(let X of Z)yield X;return}let Q=0,J;while((J=Z.indexOf(Y,Q))!==-1)yield Z.substring(Q,J),Q=J+Y.length;yield Q?Z.substring(Q):Z},remap(Z,Y){if(Z instanceof Map){let J=new Map;for(let[X,K]of Z){let z=Y(X,K,J);if(z===void 0)continue;if(z===null)J.set(X,K);if(z.key===void 0)J.set(X,z);if(J.set(z.key,z.value),z.key!==X&&J.has(X))J.delete(X)}return J}let Q={};for(let J in Z){let X=Y(J,Z[J],Q);if(X===void 0)continue;if(X===null){Q[J]=Z[J];continue}if(X.key===void 0){Q[J]=X;continue}if(Q[X.key]=X.value,X.key!==J&&Q[J]!==void 0)delete Q[J]}return Q},MathKit:{clamp(Z,Y,Q){return Math.min(Math.max(Z,Y),Q)},degrees(Z){return Z*180/Math.PI},distanceFrom(Z,Y){let Q=Y.x-Z.x,J=Y.y-Z.y,X=Y.z-Z.z;return Math.sqrt(Q**2+(isNaN(J)?0:J**2)+(isNaN(X)?0:X**2))},dopri(Z,Y,Q,J,X=0.000001,K=1000,z){let H=[Z],W=[Q],q=[J(Z,Q)],G,U,B,F,$,O,D=[],j=0.2,M=[0.075,0.225],T=[0.9777777777777777,-3.7333333333333334,3.5555555555555554],N=[2.9525986892242035,-11.595793324188385,9.822892851699436,-0.2908093278463649],L=[2.8462752525252526,-10.757575757575758,8.906422717743473,0.2784090909090909,-0.2735313036020583],x=[0.09114583333333333,0,0.44923629829290207,0.6510416666666666,-0.322376179245283,0.13095238095238096],S=[0.10013431883002395,0,0.3918321794184259,-0.02982460176594817,0.05893268337240795,-0.04497888809104361,0.023904308236133973],g=[0.2,0.3,0.8,0.8888888888888888,1,1],h=[-0.0012326388888888888,0,0.0042527702905061394,-0.03697916666666667,0.05086379716981132,-0.0419047619047619,0.025],f=0,v,d,y=(Y-Z)/10,e=0,V0,a0,t,a,Z0,Y0=new TH(H,W,q,D,-1,"");if(typeof z==="function")t=z(Z,Q);while(Z<Y&&e<K){if(++e,Z+y>Y)y=Y-Z;if(G=J(Z+g[0]*y,Q+j*y*q[f]),U=J(Z+g[1]*y,Q+M[0]*y*q[f]+M[1]*y*G),B=J(Z+g[2]*y,Q+T[0]*y*q[f]+T[1]*y*G+T[2]*y*U),F=J(Z+g[3]*y,Q+N[0]*y*q[f]+N[1]*y*G+N[2]*y*U+N[3]*y*B),$=J(Z+g[4]*y,Q+L[0]*y*q[f]+L[1]*y*G+L[2]*y*U+L[3]*y*B+L[4]*y*F),V0=Q+q[f]*y*x[0]+U*y*x[2]+B*y*x[3]+F*y*x[4]+$*y*x[5],O=J(Z+y,V0),v=q[f]*y*h[0]+U*y*h[2]+B*y*h[3]+F*y*h[4]+$*y*h[5]+O*y*h[6],a0=Math.abs(v),a0>X){if(y=0.2*y*Math.pow(X/a0,0.25),Z+y===Z){Y0.msg="Step size became too small";break}continue}if(D[f]=Q+q[f]*y*S[0]+U*y*S[2]+B*y*S[3]+F*y*S[4]+$*y*S[5]+O*y*S[6],++f,H[f]=Z+y,W[f]=V0,q[f]=O,typeof z==="function"){let _0,T0=Z,O0=Z+0.5*y,x0;if(a=z(O0,D[f-1]),Z0=t<0&&0<a,Z0){let i6,s0,r0=0,R6=1,t0=1;while(!0){if(typeof t==="number")x0=(t0*a*T0-R6*t*O0)/(t0*a-R6*t);else{x0=O0;for(d=t.length-1;d!==-1;--d)if(t[d]<0&&a[d]>0)x0=Math.min(x0,(t0*a[d]*T0-R6*t[d]*O0)/(t0*a[d]-R6*t[d]))}if(x0<=T0||x0>=O0)break;if(_0=Y0._at(x0,f-1),s0=z(x0,_0),i6=t<0&&0<s0,i6){if(O0=x0,a=s0,Z0=i6,t0=1,r0===-1)R6*=0.5;else R6=1;r0=-1}else{if(T0=x0,t=s0,R6=1,r0===1)t0*=0.5;else t0=1;r0=1}}return V0=Y0._at(0.5*(Z+x0),f-1),Y0.f[f]=J(x0,_0),Y0.x[f]=x0,Y0.y[f]=_0,Y0.ymid[f-1]=V0,Y0.events=Z0,Y0.iterations=e,Y0}T0=O0,O0=Z+y,t=a,a=z(O0,V0),Z0=t<0&&0<a}Z+=y,Q=V0,t=a,y=Math.min(0.8*y*Math.pow(X/a0,0.25),4*y)}return Y0.iterations=e,Y0},integral(Z,Y,Q){if(Q>Y)throw Error("lower bound must be less than upper bound");if(Q==Y)return 0;if(!w._modules.mathjs)throw Error(`module 'mathjs' not loaded use 'Tools._modules.mathjs = require("mathjs")' to load it`);let J;if(typeof Z=="string")J=w._modules.mathjs.compile(Z);else J=Z;if(typeof Q=="string")Q=w._modules.mathjs.evaluate(Q);if(typeof Y=="string")Y=w._modules.mathjs.evaluate(Y);let X=(K)=>J.evaluate({x:K});return w.MathKit.dopri(Q,Y,0,X).at(Y)},lerp(Z,Y,Q){return Z+(Y-Z)*Q},Lsh_us(Z,Y){return Z*2**Y},not_us16(Z){return Z^65535},not_us32(Z){return Z^4294967295},not_us8(Z){return Z^255},map(Z,Y,Q,J,X){return Z=w.MathKit.clamp(Z,Y,Q),(Z-Y)/(Q-Y)*(X-J)+J},Point:wH,radians(Z){return Z*Math.PI/180},Rsh_us(Z,Y){return Math.floor(Z/2**Y)},sum:(...Z)=>{return Z.flat(5).reduce((Y,Q)=>Y+Q,0)},toPolarCoords(Z,Y,Q="r"){if(!Q||Q!="d"&&Q!="r")throw Error("unit must be 'r' or 'd', given: "+Q);let J=Math.atan(Y/Z);if(Y<0&&Z<0)J+=360;else if(Z<0)J+=180;return{r:Math.sqrt(Z**2+Y**2),t:Q=="d"?J:w.MathKit.radians(J)}},toCartesianCoords(Z,Y,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(Y=w.MathKit.radians(Y),Q!==null)Q=w.MathKit.radians(Q)}if(Q===null)return{x:Z*Math.cos(Y),y:Z*Math.sin(Y)};else return{x:Z*Math.sin(Q)*Math.cos(Y),y:Z*Math.sin(Q)*Math.sin(Y),z:Z*Math.cos(Q)}}},maxFraction(Z,Y,Q=!1){let J=Z.toString();if(!J.includes("."))return J;let X=10**Y;return Z=(Q?Math.floor(Z*X):Math.round(Z*X))/X,Z.toString()},ncc(Z=null,Y=null,Q=null){if(w.CheckCache.supportsColor===0)return"";if(Z==null)return"\x1B[0m";if(typeof Z=="number"){let J=w.Convert.decimalColorToRGB(Z);switch(Q?1:w.CheckCache.supportsColor){default:return"";case 1:Z=(Y=="bg"?"bg":"")+w.Convert.basicColorFromRgb(J);case 2:{let K=w.Convert._8bitColorFromRgb(J);return`\x1B[${Y=="bg"?"4":"3"}8;5;${K}m`}case 3:return`\x1B[${Y=="bg"?"4":"3"}8;2;${J.r};${J.g};${J.b}m`}}else Z=Z.toLowerCase();return w.CONSTS.AnsiColorCodes[Z]||"\x1B[37m"},nearestNumber(Z,Y){let Q=1/0,J=null;for(let X=0,K=Z[X];X<Z.length;){let z=Math.abs(Y-K);if(!z)return X;if(z<Q)Q=z,J=X;K=Z[++X]}return J},objectMap(Z,Y){return w.remap(Z,Y)},objValueAt(Z,Y){return Z[Object.keys(Z).at(Y)]},objToString(Z,Y={}){let{maxDepth:Q=4,indent:J=3,maxKeys:X=20,color:K=!1,defColor:z=void 0,noHeader:H=!1}=Y;if(Q<1)Q=1;let W={color:K,defColor:z},q=typeof J=="number"?" ".repeat(J):J,G=null;if(K)G={cyan:w.ncc(4764610),magenta:w.ncc(11550650),gray:w.ncc(4802889),yellow:w.ncc(12754962),_default:w.ncc(z)};if(Z==null||typeof Z!=="object")return w.yuString(Z,W);if(w.isArrayLike(Z))return w.arrToString(Z,{color:K,defColor:z,maxDepth:Q,indent:J});if(Z instanceof Map||Z instanceof Set||Z instanceof Promise||Z instanceof Date||Z instanceof RegExp)return w.yuString(Z,W);if(w.isError(Z))return w.Err.toString(Z,{color:K,defColor:z});let U=Z.constructor?.name||"Object",B=U!=="Object",$=Object.keys(Z).length,O="";if(!H&&(B||$>5))if(K)O=G.magenta+`${U}(${$}) `+G._default;else O=`${U}(${$}) `;return O+D(Z,0);function D(j,M,T=0){if(M>Q-1)if(K)return G.gray+"... {Object}"+G._default;else return"... {Object}";if(j==null)return w.yuString(j,W);if(typeof j!=="object"||j instanceof Date||j instanceof RegExp)return w.yuString(j,W);if(w.isArrayLike(j))return w.arrToString(j,{color:K,defColor:z,maxDepth:Q-M,indent:J,noHeader:!0});if(j instanceof Map||j instanceof Set)return w.yuString(j,W);let N=Object.keys(j),L=N.length;if(L===0)return"{}";let x=L>3||M>0,S=T?q.repeat(T):"",g=S+q,h=x?`{
|
|
14
|
+
`+g:"{ ",f=Math.min(N.length,X-1);for(let v=0;v<f;v++){let d=N[v],y=j[d];if(K)h+=G.cyan+d+G._default+": ";else h+=d+": ";if(y&&typeof y==="object"&&!w.isArrayLike(y)&&!(y instanceof Date)&&!(y instanceof RegExp)&&!(y instanceof Map)&&!(y instanceof Set)&&!(y instanceof Promise)){let e=y.constructor?.name||"Object";if(e!=="Object"&&K)h+=G.magenta+e+" "+G._default;else if(e!=="Object")h+=e+" ";h+=D(y,M+1,x?T+1:T)}else h+=w.yuString(y,W);if(v<f-1)h+=x?`,
|
|
15
|
+
`+g:", "}if(N.length>X-1){let v=N.length-f;if(K)h+=x?`,
|
|
16
|
+
`+g:", ",h+=G.gray+`... (${v} more)`+G._default;else h+=x?`,
|
|
17
|
+
`+g:", ",h+=`... (${v} more)`}return h+=x?`
|
|
18
|
+
`+S+"}":" }",h}},propertiesCount(Z){return Object.keys(Z).length},padEnd(Z,Y,Q=" ",J=0){let X=w.ex_length(Z,J);if(X>=Y)return Z;return Z+Q.repeat(Y-X)},padStart(Z,Y,Q=" ",J=0){let X=w.ex_length(Z,J);if(X>=Y)return Z;return Q.repeat(Y-X)+Z},parseArgs(Z,Y,Q=!1){let J={_unmatched:[]},X=new Set;for(let z in Y)if(Y[z]?.required)X.add(z);for(let z=0;z<Z.length;z++){let H=!1;for(let W in Y){if(!Y[W]?.pattern)throw Error("invalid template: Object structure missmatched. every entries requires `pattern` property");if(!K(Z[z],Y[W].pattern))continue;if(X.delete(W),Y[W]?.isFlag||Y[W]?.type=="flag"){H=!0,J[W]=new B1(!0,"flag",z);continue}let q=!1;if(z+1<Z.length){for(let G in Y)if(K(Z[z+1],Y[G].pattern))q=!0}if(z+1>=Z.length||q)throw Error(`argument '${Z[z]}' requires a Value`);switch(Y[W]?.type){case"int":if(isNaN((J[W]=new B1(parseInt(Z[++z]),Y[W]?.type,z)).value))throw Error(`argument '${Z[z-1]}' requires a Value of type '${Y[W]?.type}'`);break;case"float":if(isNaN((J[W]=new B1(parseFloat(Z[++z]),Y[W]?.type,z)).value))throw Error(`argument '${Z[z-1]}' requires a Value of type '${Y[W]?.type}'`);break;case"choice":if(!Y[W]?.choices?.length)throw Error("invalid template: Object structure missmatched. entry of type 'choice' requires `choices` property");if(!K(Z[++z],Y[W].choices)&&Y[W]?.default==null)throw Error(`invalid value for '${Z[z-1]}' argument, requires any of these Choices: ${Y[W].choices}`);J[W]=new B1(Z[z],Y[W]?.type,z);break;case"string":case void 0:J[W]=new B1(Z[++z],Y[W]?.type,z);break;default:throw Error(`invalid template: entry of type '${Y[W]?.type}' is not supported`)}H=!0}if(!H)J._unmatched.push(new B1(Z[z],void 0,z))}if(X.size>0)throw Error(`argument(s) '${[...X]}' is required.`);for(let z in Y){if(Y[z]?.isFlag||Y[z]?.type=="flag"){if(!J[z])J[z]=new B1(!1,"flag");continue}if(!J[z])J[z]=new B1(Y[z]?.default?Y[z]?.default:null,Y[z]?.type)}return J;function K(z,H){for(let W of H){if(!Q){if(z.toLowerCase()==W.toLowerCase())return!0;continue}if(z==W)return!0}return!1}},parseBool(Z,Y=!1){if(typeof Z=="boolean")return Z;Z=Z.toLowerCase();let Q=Z=="true"?!0:!1;if(!Y)return Q;if(!(Z=="true"||Z=="false"))return null;return Q},parseConfig(Z,Y=null,Q={}){let{ignoreGroups:J=!1,multiValues:X=!1}=Q,K=w.cleanArr(Z.trim().split(`
|
|
19
|
+
`),["","\r"]),z={},H=null,W="",q,G=0,U=!1;for(let F=0;F<K.length;F++){let $=K[F].trim();if(/^[#;]/.test($))continue;if($.startsWith("[")){if(J)continue;{let N=!1;for(let L=1;L<$.length;L++)if($[L]=="]"&&$[L-1]!="\\"){if(H=$.slice(1,L),!z[H])z[H]={};N=!0;break}if(!N)throw Error(`Tools.parseConfig(): invalid syntax, missing ']' at the end of the group. at \`${$}\``);else continue}}if(U){if(W+=K[F],!B(F,K))continue;if(U=!1,H)z[H][q]=JSON.parse(W,Y);else z[q]=JSON.parse(W,Y);continue}let O=w.cleanArr($.split("="));if(O.length>2)throw Error(`Tools.parseConfig(): invalid syntax, '=' cannot occur more than one time. at \`${$}\``);else if(O.length==1&&!U)if($.includes("="))throw Error(`Tools.parseConfig(): invalid syntax, expected expresion after '='. at \`${$}\``);else throw Error(`Tools.parseConfig(): expected expresion. at \`${$}\``);else if(!O.length)throw Error(`Tools.parseConfig(): unknown operator. \`${$}\``);O=[O[0].trim(),O[1].trim()];let D=w.getMatchAllIndexes(O[1].matchAll(/["']/g)).filter((N,L,x)=>{if(O[1][N-1]=="\\"){O[1]=O[1].slice(0,N-1)+O[1].slice(N);for(let S=L+1;S<x.length;S++)x[S]--;return!1}return!0}),j=O[1].search("#"),M=D[0],T=!1;if(M!=null&&(j==-1||M<j)){let N=D[1]==null?-1:D[1],L=O[1].slice(N+2).trim();if(L&&!/^[#;]/.test(L))throw Error(`Tools.parseConfig(): invalid syntax, unexpected charactor(s).
|
|
20
|
+
at \`${$}\`
|
|
21
|
+
`+"".padStart(N+10+O[0].length," ")+"^");if(N==-1)throw Error(`Tools.parseConfig(): invalid syntax, missing closing quote.
|
|
22
|
+
at \`${$}\`
|
|
23
|
+
`+" ".padStart(M+7+O[0].length," ")+"^");T=!0,O[1]=O[1].slice(M+1,N)}else if(j!=-1){if(O[1]=O[1].slice(0,O[1].indexOf("#")).trim(),!O[1])throw Error(`Tools.parseConfig(): invalid syntax, expected expresion after '='. at \`${$}\``)}if(/^[0-9]/.test(O[0]))throw Error(`Tools.parseConfig(): Key cannot starts with Numbers. at \`${$}\``);{let N=O[0].replace(/[a-z$_0-9.]/gi,"");if(N.length!==0)throw Error(`Tools.parseConfig(): these character(s) "${N}" can not be Parse. at \`${$}\``)}if(/^[[{]/.test(O[1])){if(G=0,[q,W]=O,B(1,O)){if(H)z[H][q]=JSON.parse(W,Y);else z[q]=JSON.parse(W,Y);continue}U=!0;continue}{let N=H?z[H]:z;if(X&&Object.hasOwnProperty.call(N,O[0])){if(N[O[0]].$multiValues===void 0)N[O[0]]=[N[O[0]]],N[O[0]].$multiValues=!0;N[O[0]].push(T?O[1]:w.parseValue(O[1]))}else N[O[0]]=T?O[1]:w.parseValue(O[1])}}return z;function B(F,$){if(G+=[...$[F].matchAll(w.REGEXP.OpenSCBrackets)].filter((O)=>O[1]).length,G-=[...$[F].matchAll(w.REGEXP.CloseSCBrackets)].filter((O)=>O[1]).length,G<=0)return!0;return!1}},parseValue(Z){if(typeof Z!="string")return Z;switch(Z.toLowerCase()){case"true":return!0;case"false":return!1;case"null":return null;case"":case"undefined":return;default:if(!isNaN(Z))return Number(Z);return Z}},pass(Z,Y=null){if(Y)Y(Z);else console?.log(Z);return Z},Progress:class Z{stdout=process.stdout;progress=0;spd=0;lastCheck=null;printInterval;updateInterval;total;#Y=0;#Q=!0;#Z;constructor(Y,Q=null,J=500,X=100){if(!Y)throw Error("printTemplate is required");this.total=Q,this.printInterval=J,this.updateInterval=X,this.setPrintTemplate(Y),this.lastCheck=Date.now()}update(Y=1){if(!this.#Z)return;this.#Y+=Y,this.progress+=Y;let Q=Date.now()-this.lastCheck;if(Q>this.updateInterval&&this.#Y>4)this.spd=this.#Y*this.updateInterval/Q,this.#Y=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.#Z();return}this.#Z()}done(){if(this.progress!=this.total){if(!this.#Q)this.stdout.clearLine(),this.stdout.cursorTo(0);this.progress=this.total,this.#Z()}this.stdout.write(`
|
|
24
|
+
`),this.reset()}reset(){this.progress=0,this.#Y=0,this.spd=0,this.lastCheck=Date.now(),this.#Q=!0}setPrintTemplate(Y){Y=Y.replace(/%total%/g,"${this.total}"),Y=Y.replace(/%spd%/g,"${this.spd.toFixed(1)}"),Y=Y.replace(/%prog%/g,"${this.progress}"),this.#Z=Function("this.stdout.write(`"+Y+"`);").bind(this)}},proximate(Z,Y,Q){if(Z<Y+Q&&Z>Y-Q)return Y;else return Z},randomPick(Z){if(Z.length<=1)return Z[0];return Z[Math.floor(Math.random()*Z.length)]},redexOf(Z,Y,Q=0){let J=typeof this!=="string";if(!Z&&J)return-1;if(!J)Z=this;if(!Z.length)return-1;if(!(Y instanceof RegExp))if(Q>=0)return Z.indexOf(Y,Q);else return Z.lastIndexOf(Y,Z.length+Q);let X,K;if(Q>=0){X=-1;do{K=Z.substring(++X);let z=K.search(Y);if(z==-1)return-1;X=z+X}while(X<Q)}else{X=-1;do{K=Z.substring(++X);let z=K.search(Y);if(z==-1)return X-1;X=z+X}while(X<Z.length+Q)}return X},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(J9),EmojiEach:new RegExp(J9,"g"),EmojiEachGroup:new RegExp("(?:"+J9+")+","g"),IniGroups:/^[\t ]*\[(.+)\][\t ]*$/gm,JSComments:/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g,OpenSCBrackets:/\\"|"(?:\\"|[^"])*"|([[{])/g,CloseSCBrackets:/\\"|"(?:\\"|[^"])*"|([\]}])/g}),resolveNodeEnv(Z,Y=/%(\w+)%/g){return Z.replace(Y,(Q,J)=>{let X=J;if(process.env[X]==null)return Q;return process.env[X]})},SafeTrue:class Z{#Y=0;limit=0;noWarning=!1;constructor(Y=10000000000,Q=!1){this.limit=Y,this.noWarning=Q}get True(){if(this.#Y++>=this.limit){if(!this.noWarning)process?.emitWarning("SafeTrue limit reached");return!1}return!0}},search(Z,Y,Q={}){let J=w.REGEXP.Seperators,X=Q.maxResult,K=Q.TF_IDFMaps instanceof Array?[...Q.TF_IDFMaps]:Q.TF_IDFMaps;if(!X)if(typeof Q=="number")X=Q;else X=1/0;if(Y=Y.trim().toLowerCase(),Y=="")return null;let z=[...Z];if(z.forEach((q,G,U)=>U[G]=q.trim().toLowerCase()),K==="builtin")K=w.DataScienceKit.TFIDF_of(z.concat(Y).map((q)=>w.cleanArr(q.split(J))));class H{constructor(q,G,U=-1,B=null){this.score=G,this.string=q,this.matchIndex=U,this.scores=B}}let W=[];for(let q=0;q<z.length;q++){let G=z[q].replace(J,"");if(z[q]==Y||G==Y)W.unshift(new H(Z[q],Y.length<<2,q));let U,B,F,$;U=B=F=$=0;for(let D of w.cleanArr(Y.split(J))){let j=0;if(w.includesWord(D,z[q],!1))if(K&&K[q]?.has(D))j=D.length*K[q].get(D).TF_IDF*2.9,U+=j;else j=D.length,B+=j;else if(z[q].includes(D))j=D.length*0.3,F+=j;let M=w.DataScienceKit.LCSLength_of(D,z[q])*0.4;$+=M}let O=U+B+F+$;W.push(new H(null,O,q,{tfidf_s:U,word_s:B,includes_s:F,lcs_s:$,TF_IDFMap:K?.[q]}))}W.sort((q,G)=>G.score-q.score);for(let q=0;q<X;q++){if(!W[q])break;if(W[q].string!=null)continue;W[q].string=Z[W[q].matchIndex]}return W.slice(0,X)},sleep(Z){if(!Z||Z<0)return;let Y=Date.now();while(Date.now()-Y<Z);},SpawnMirror:class Z{static STDIO_MIRROR=["inherit","pipe","pipe"];static createMirror(Y){Y?.stdout?.pipe(process.stdout),Y?.stderr?.pipe(process.stderr)}},strClamp(Z,Y,Q="mid",J=0){let X=w.ex_length(Z,J);if(X<=Y)return Z.padEnd(Y," ");let K=X-(X-Y)-3;switch(Q){default:if(X8)process?.emitWarning(`'${Q}' is not a valid location type.`);else throw Error(`'${Q}' is not a valid location type.`);case"mid":{let z=K>>1;return w.strSlice(Z,0,z,J)+"..."+w.strSlice(Z,X-z,void 0,J)}case"end":return w.strSlice(Z,0,K,J)+"...";case"start":return"..."+w.strSlice(Z,K,void 0,J)}},stringifyConfig(Z,Y={}){let{ignoreList:Q=[],minify:J=!1,replacer:X,mode:K="merge",useIniGroup:z=!1,alwaysWrapStrInQuotes:H=!1,oldConfigStr:W=""}=Y,q=new w.SafeTrue(1e5),G=K=="merge"?W:"";for(let $ in Z){if(Q.includes($))continue;if(!z){U($,Z);continue}if($===""||typeof Z[$]!=="object"){U($,Z,"");continue}for(let O in Z[$]){if(Q.includes(O))continue;U(O,Z[$],$)}}return G;function U($,O,D,j=!1){let M="";if(O[$]!=null&&typeof O[$]==="object")if(O[$].$multiValues){for(let v of O[$])U($,{[$]:v},D,!0);return}else M=`${JSON.stringify(O[$],X,J?null:3)}
|
|
25
|
+
`;else if(typeof O[$]=="string")if(H||/\s|[{[}\]]/.test(O[$]))M=`"${O[$]}"`;else M=`${O[$]}`;else M=`${O[$]}`;let T=j?-1:w.redexOf(G,new RegExp(`^[ \\t]*\\b${$}\\s*=`,"m")),N;if(D==="")N=-3;else N=z?G.indexOf(`[${D}]`):null;let L=N===-1;if(L)N=G.length+2,G+=`
|
|
26
|
+
|
|
27
|
+
[${D}]
|
|
28
|
+
`;if(T==-1){let v=J?`${$}=${M}
|
|
29
|
+
`:`${$} = ${M}
|
|
30
|
+
`;if(z)if(L)G+=v+`
|
|
31
|
+
`;else{let d=w.redexOf(G,new RegExp(`^\\s*
|
|
32
|
+
$`,"m"),N);G=w.strSplice(G,d,0,v)}else G+=v;return}let x=null,S=null;if(z)x=w.redexOf(G.slice(0,T),w.REGEXP.IniGroups,-1),S=x==N?D:G.slice(x+1,G.slice(x,T).indexOf("]")+x);let g=G.indexOf("=",T)+1,h=w.getMatchAllIndexes(G.slice(g).matchAll(/(?<!\\)[#\n;]/g))?.[0]??-1;if(h==-1)h=G.length;else h+=g;let f=G[h]===`
|
|
33
|
+
`?h:G.indexOf(`
|
|
34
|
+
`,h+1);if(F(g,h))h=B(g);if(S&&S!==D){let v=G.slice(T,f+1),d=f-T,y=g-T,e=h-T;if(G=w.strSplice(G,T,d+1,""),N>T)N-=d;else N++;T=N+D.length+2,g=T+y,h=T+e,G=w.strSplice(G,T,0,v)}G=w.strSplice(G,g,h-g,(J?"":" ")+M);{let v=0;while(G[g+(v-2)]==" ")v--;if(J&&v<0)G=w.strSplice(G,g+v-1,-v,"");else if(!J&&v!==-1)G=w.strSplice(G,g+v-1,-v," ")}}function B($){let O=0,D=$,j=!1;do{if(D++,j){if(G[D]=='"'&&G[D-1]!="\\")j=!1;continue}if(G[D]=='"'){j=!0;continue}if(G[D]=="{"||G[D]=="[")O++;if(G[D]=="}"||G[D]=="]")O--}while(O&&q.True);if(q.True==!1)throw Error(`failed to write config
|
|
35
|
+
Reason: loop limit reached`);return D+1}function F($,O){return/^[\t ]*[[{]/.test(G.slice($,O))}},strJustify(Z,Y,Q={}){let{filler:J=" ",align:X="center",overflow:K="hidden",collapseLocation:z="end",redundancyLv:H=0}=Q,W=Z instanceof Array,q=W?Z.join(""):Z,G=w.ex_length(q,H);if(G>Y){if(K=="collapse")return w.strLimit(q,Y,z);if(K=="hidden")return q.slice(0,Y);return q}switch(X){case"spacebetween":if(W){let U=J.repeat((Y-G)/(Z.length-1));return Z.reduce((B,F,$)=>{if($==0)return B;return B+U+F},Z[0])}default:case"center":return w.strSurround(q,J,Y);case"right":return w.padStart(q,Y,J);case"left":return w.padEnd(q,Y,J)}},strLimit(Z,Y,Q="mid",J=0){let X=w.ex_length(Z,J);if(X<=Y)return Z;let K=X-(X-Y)-3;switch(Q){default:if(X8)process?.emitWarning(`'${Q}' is not a valid location type.`);else throw Error(`'${Q}' is not a valid location type.`);case"mid":{let z=K>>1;return w.strSlice(Z,0,z)+"..."+w.strSlice(Z,X-z+1)}case"end":return w.strSlice(Z,0,K)+"...";case"start":return"..."+w.strSlice(Z,X-K)}},strSlice(Z,Y,Q,J=0){let X=[...Z.matchAll(w.REGEXP.ANSICode)].map((H)=>{return{start:H.index,end:H.index+H[0].length,length:H[0].length}});if(!Q)Q=w.ex_length(Z,J);let K=0,z=0;for(let H=0;H<X.length;H++){if(X[H].start-K<Y)K+=X[H].length;if(X[H].start-z<=Q)z+=X[H].length;if(X[H].start-z>Q)break}return Z.slice(Y+K,Q+z)},strSplice(Z,Y,Q,J=null){if(Q<0)Q=0;if(Y<Z.length*-1)Y=0;if(J)return Z.slice(0,Y)+J+(Y<0&&Q+Y>=0?"":Z.slice(Y+Q));else return Z.slice(0,Y)+(Y<0&&Q+Y>=0?"":Z.slice(Y+Q))},strSurround(Z,Y,Q,J=0){let X=w.ex_length(Z,J),K=Math.ceil(Q/2-X/2);return w.padEnd(" ",K,Y,J)+w.padEnd(Z,Q/2+X/2,Y,J)},strWrap(Z,Y,Q={}){if(!Z)return"";let{indent:J="",firstIndent:X="",mode:K="softboundary",redundancyLv:z=0}=Q,H=[],W=K=="softboundary",q=Y*0.67,G=w.REGEXP.ANSICode,U=/[\s,.;:()[\]})]/,B=/[-_・⧸/\\、'""!^**=+「【】」()]/,F=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null,$=new Map;if(typeof X=="number")X="".padEnd(X," ");if(typeof J=="number")J="".padEnd(J," ");let O=Z.split(`
|
|
36
|
+
`);for(let M=0;M<O.length;M++){while(w.ex_length(O[M],z)>Y){let T=D(O[M]),N=T>0?T:Math.min(O[M].length,Y);if(J!=null)if(X!=null)H.push(X);else H.push(J);H.push(O[M].substring(0,N).concat(`
|
|
37
|
+
`)),O[M]=O[M].substring(N).trimStart()}if(J!=null)if(X!=null)H.push(X),X=null;else H.push(J);H.push(O[M].concat(M<O.length-1?`
|
|
38
|
+
`:""))}return H.join("");function D(M){let T=0,N=0,L=0,x=null,S=null,g=null,h=null,f=null,v=null,d=!1,y=0;G.lastIndex=0;let e=G.exec(M);while(e&&!d){let a=e.index??0;if(a>y){if(a0(M.slice(y,a)))break}if(t(e[0],!0))break;y=a+e[0].length,e=G.exec(M)}if(!d&&y<M.length)a0(M.slice(y));if(!W)return L||N||M.length;let V0=g??h??f??v??x??S;if(V0)return V0.breakIndex;return L||N||M.length;function a0(a){if(!a)return!1;if(F&&z>=2){for(let Z0 of F.segment(a))if(t(Z0.segment,!1))return!0;return!1}if(z>=2){let Z0=w.REGEXP.EmojiEach,Y0=0;while(Y0<a.length){Z0.lastIndex=Y0;let _0=Z0.exec(a),T0=null;if(_0&&_0.index===Y0)T0=_0[0],Y0+=T0.length;else{let O0=a.codePointAt(Y0);T0=String.fromCodePoint(O0),Y0+=T0.length}if(t(T0,!1))return!0}return!1}for(let Z0 of a)if(t(Z0,!1))return!0;return!1}function t(a,Z0){let Y0=Z0?z<0?a.length:0:j(a),_0=T+Y0,T0=N;if(N+=a.length,!Z0){if(U.test(a)){let O0=a.trim().length===0,x0=O0?T0:N,i6=O0?T:_0,s0={breakIndex:x0,width:i6};if(i6<=Y){if(x=s0,i6>=q)g=s0}else if(!f)f=s0}if(B.test(a)){let O0={breakIndex:N,width:_0};if(O0.width<=Y){if(S=O0,O0.width>=q)h=O0}else if(!v)v=O0}}if(!L&&_0>=Y)if(_0===Y)L=N;else if(T0===0&&Z0)L=N;else L=T0>0?T0:N;if(T=_0,!W)return T>=Y;if(T<Y)return!1;if(g||h)return!0;if(f||v)return!0;return!1}}function j(M){if(z<1)return M.length;let T=$.get(M);if(T!=null)return T;let N=w.ex_length(M,z);return $.set(M,N),N}},supportsColor(Z=process?.stdout){if(!X8)return 3;if(w.CheckCache.forceColor===!1)return 0;if(w.argvHasFlag("color=16m")||w.argvHasFlag("color=full")||w.argvHasFlag("color=truecolor"))return 3;if(w.argvHasFlag("color=256"))return 2;if(Z&&!Z.isTTY&&w.CheckCache.forceColor!==!0)return 0;let Y=w.CheckCache.forceColor?1:0;if(process.platform==="win32"){if(!w._modules.os)w._modules.os=N_("os");let J=w._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 Y}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 Y;return Y},supportsHyperlink(Z=process?.stdout,Y=!1){if(!X8)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(w.argvHasFlag("no-hyperlink")||w.argvHasFlag("no-hyperlinks")||w.argvHasFlag("hyperlink=false")||w.argvHasFlag("hyperlink=never"))return!1;if(w.argvHasFlag("hyperlink=true")||w.argvHasFlag("hyperlink=always"))return!0;if("NETLIFY"in Q)return!0;if(w.CheckCache.supportsColor>0)return!0;if(Z&&!Z.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 X=J(Q.TERM_PROGRAM_VERSION);switch(Q.TERM_PROGRAM){case"iTerm.app":if(X.major===3)return X.minor>=1;return X.major>3;case"WezTerm":return X.major>=20200620;case"vscode":return X.major>1||X.major===1&&X.minor>=72}}if("VTE_VERSION"in Q){if(Q.VTE_VERSION==="0.50.0")return!1;let X=J(Q.VTE_VERSION);return X.major>0||X.minor>=50}return!1;function J(X){if(/^\d{3,4}$/.test(X)){let z=/(\d{1,2})(\d{2})/.exec(X);return{major:0,minor:parseInt(z[1],10),patch:parseInt(z[2],10)}}let K=(X||"").split(".").map((z)=>parseInt(z,10));return{major:K[0],minor:K[1],patch:K[2]}}},surroundedBy(Z,Y,Q){if(Y<0)return!1;let J=-1/0,X=1/0,K=Z=="{"||Z=="["||Z=="("||Z=="<";for(let H=Y;H>0;H-=2){let W=Q.lastIndexOf(Z,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?z(Z):Z,H);if(W==-1)break;else X=W;if(Q[X-1]=="\\")X=1/0}if(J==-1/0||X==1/0)return!1;return J<Y&&X>Y;function z(H){return String.fromCharCode(H.charCodeAt(0)+(H[0]=="("?1:2))}},Timer:class Z{time;resolution;isRunning=!1;maxTime;#Y;#Q;#Z=0;#J;#X;constructor(Y,Q="ms"){switch(this.maxTime=this.time=Y,this.resolution=Q,Q){case"ms":this.#Y=1;break;case"s":this.#Y=1000;break;case"m":this.#Y=60000;break}}start(){if(this.isRunning||this.time<=0)return;return this.isRunning=!0,this.#Z=Date.now(),this.#Q=setInterval(this.#K,this.#Y==1?4:this.#Y/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((Y)=>{this.#X=()=>{this.#X=null,Y()}})}onceEnd(Y){return this.#J=Y,this}#K=()=>{let Y=Date.now(),Q=(Y-this.#Z)/this.#Y;if(this.time-=Q,this.#Z=Y,this.time>0)return;if(this.stop(),this.time=0,this.#J)this.#J(),this.#J=null;if(this.#X)this.#X()}},toPlace(Z){switch(Z){case 1:return"1st";case 2:return"2nd";case 3:return"3rd";default:return Z+"th"}},toShortNum(Z,Y=2,Q=1000,J=!1,X=-Number.MAX_SAFE_INTEGER,K=Number.MAX_SAFE_INTEGER){if(Z===0)return"0";let z=Math.abs(Z),H=Math.sign(Z),W=z>0&&z<1,q=w.MathKit.clamp(Math.floor(Math.log(z)/Math.log(Q)),X,K);Z=Z/Math.pow(Q,q)*H;let G=w.maxFraction(Z,Y,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 Z{liveLog=!0;log="";startTime;enableLogging=!1;recursive=!1;constructor(){this.startTime=new Date}createTracker=function(Y,Q,J){let X=(K,z)=>{let H=K.length;if(H<=z)return K;let q=H-(H-z)-3>>1;return K.slice(0,q)+"..."+K.slice(H-q+1)};return function(){if(!J.enableLogging)return Y.apply(this,arguments);let K=Y.apply(this,arguments)??"void",z="["+w.jsTime.howLong(J.startTime)+"] "+Q+"(";for(let H=0;H<arguments.length;H++){if(H>0)z+=", ";let W=w.yuString(arguments[H]);z+=W.trim().length?X(W,70):`"${W}"`}if(K==="void")z+=")";else z+="): "+X(w.yuString(K),70);if(J.log+=z+`
|
|
39
|
+
`,J.liveLog)console.log(z);return K==="void"?void 0:K}};attachTracer(Y,Q=""){if(Q.length>100)return this;if(typeof Y!=="object")return this;for(let J of Object.getOwnPropertyNames(Y)){let X=Y[J];if(Object.prototype.toString.call(X)==="[object Function]"){if(!w.isClass(X))Y[J]=this.createTracker(X,Q+J,this);if(this.recursive&&w.propertiesCount(X)>0)for(let K of Object.getOwnPropertyNames(X)){let z=X[K];return this.attachTracer(z,Q+J+".")}}}return this}},writeConfig(Z,Y,Q={}){if(!w._modules.fs)throw Error('fs module is required for Tools.writeConfig()\nimport them with `Tools._modules.fs = require("fs")`');let{ignoreList:J=[],minify:X=!1,replacer:K,mode:z="merge",useIniGroup:H=!1,alwaysWrapStrInQuotes:W=!1}=Q,q="";if(w._modules.fs.existsSync(Y)&&z=="merge")q=w._modules.fs.readFileSync(Y,{encoding:"utf-8"});q=w.stringifyConfig(Z,{ignoreList:J,minify:X,replacer:K,mode:z,useIniGroup:H,alwaysWrapStrInQuotes:W,oldConfigStr:q}),w._modules.fs.writeFileSync(Y,q,{encoding:"utf-8"})},yuString(Z,Y={}){let{color:Q=!1,defColor:J=void 0}=Y;switch(typeof Z){case"string":if(Q)return w.ncc(8373322)+`"${Z}"`+w.ncc(J);return`"${Z}"`;case"bigint":case"number":if(Q)return w.ncc(11609489)+Z+w.ncc(J);case"boolean":case"undefined":if(Q)return w.ncc(15756194)+Z+w.ncc(J);return Z+"";case"function":if(Q)return(w.isAsyncFunction(Z)?w.ncc(4802889)+"async ":"")+(w.isArrowFunction(Z)?w.ncc(13401911)+(Z.name||w.ncc(4802889)+"[anonymous]"+w.ncc(13401911))+" () => {...}":w.ncc(13401911)+(Z.name||w.ncc(4802889)+"[anonymous]"+w.ncc(13401911))+"()")+w.ncc(J);return(w.isAsyncFunction(Z)?"async ":"")+(w.isArrowFunction(Z)?(Z.name||"[anonymous]")+" () => {...}":(Z.name||"[anonymous]")+"()");case"symbol":if(Q)return w.ncc(13401911)+Z.toString()+w.ncc(J);return Z.toString()}if(Z==null){if(Q)return w.ncc(13136006)+Z+w.ncc(J);return Z+""}if(Z instanceof Date){if(Q)return w.ncc(11550650)+"Date"+w.ncc(J)+" "+Z.toISOString();return"Date "+Z.toISOString()}if(Z instanceof RegExp){if(Q)return w.ncc("Yellow")+Z.toString()+w.ncc(J);return Z.toString()}if(Z instanceof Promise)return w.ncc(11550650)+"Promise"+w.ncc(J)+" {...(pending)}";if(Z instanceof Map){let X=[...Z.entries()];return(Q?w.ncc(11550650)+`Map(${Z.size}) {`+w.ncc(J):`Map(${Z.size}) {`)+w.arrToString(X,{color:Q,defColor:J,noHeader:!0})+"}"}if(Z instanceof Set){let X=[...Z.values()];return(Q?w.ncc(11550650)+`Set(${Z.size}) {`+w.ncc(J):`Set(${Z.size}) {`)+w.arrToString(X,{color:Q,defColor:J,noHeader:!0})+"}"}if(w.isError(Z))return w.Err.toString(Z,{color:Q,defColor:J});try{if(typeof Z==="object"){if(w.isArrayLike(Z))return w.arrToString(Z,{color:Q,defColor:J});return w.objToString(Z,{color:Q,defColor:J})}}catch{}return"[unknown]"}};if(typeof window<"u")window._tools=w;({arrFindLast:gP,arrToString:LH,argvHasFlag:mP,asyncSleep:LY,beautifyJson:uP,beforeExit:IH,changeDateTimezone:pP,charTypeAt:dP,CheckCache:e0,cleanArr:cP,cleanComments:lP,cleanString:AH,CONSTS:MZ,Convert:iP,ConsoleTime:nP,compareDate:oP,DataScienceKit:aP,deferredFunc:sP,digitAt:rP,digitAtRange:tP,getDimensions:eP,Err:o,escapeRegExp:Zv,estimateStrComplexity:IY,ex_length:o6,fileNameCleaner:Yv,fixFilePath:Qv,fixYTurl:Jv,fileTypeOf:Xv,getMatchAllIndexes:Kv,getMatchAllResults:zv,getRandomInt:Hv,getProcessTime:Wv,hasEmojiEst:qv,hyperlink:a6,IDGenerator:Gv,includesWord:Uv,IPC:Vv,isArrayLike:Bv,isArrowFunction:$v,isAsyncFunction:Fv,isClass:Ov,isNumber:Rv,isEmptyArray:Mv,isEmptyObject:Dv,isError:CH,isValidFilePath:_v,JSONReplacer:Nv,JSONReviver:jv,jsTime:z8,lazySplit:wv,remap:EH,MathKit:d0,maxFraction:H8,ncc:V,nearestNumber:Tv,objectMap:Lv,objValueAt:Iv,objToString:Av,propertiesCount:Cv,padEnd:K9,padStart:Ev,parseArgs:xv,parseBool:Sv,parseConfig:kv,parseValue:Pv,pass:vv,Progress:yv,proximate:bv,randomPick:fv,redexOf:hv,REGEXP:xH,resolveNodeEnv:gv,SafeTrue:mv,search:uv,sleep:pv,SpawnMirror:dv,strClamp:W8,stringifyConfig:cv,strJustify:D6,strLimit:DZ,strSlice:lv,strSplice:iv,strSurround:nv,strWrap:s,supportsColor:ov,supportsHyperlink:av,surroundedBy:sv,Timer:rv,toPlace:tv,toShortNum:B6,Tracer:ev,writeConfig:Zy,yuString:u}=w)});var z9;var SH=_(()=>{z9={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 --external=yaml --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.6","@babel/core":"^7.29.0","@babel/preset-env":"^7.29.2","@babel/preset-typescript":"^7.28.5","@eslint/js":"^9.39.4","@types/chai":"^5.2.3","@typescript-eslint/eslint-plugin":"^8.57.1","@typescript-eslint/parser":"^8.57.1",banditypes:"^0.3.0","bun-types":"latest",chai:"^6.2.2",dedent:"^1.7.2",eslint:"^10.0.3",execa:"^9.6.1",jiti:"^2.6.1",openai:"^6.32.0",prettier:"^3.8.1","smol-toml":"^1.6.0",tinybench:"^6.0.0",tsx:"^4.21.0",typescript:"^5.9.3","typescript-eslint":"^8.57.1","unicode-animations":"^1.0.3"},dependencies:{"@shikijs/cli":"^4.0.2","cspell-lib":"9.4.0",diff:"^8.0.4",keytar:"^7.9.0",yaml:"^2.8.2"}}});function c0(Z){return Z.replace(/\\/g,"/")}import AY from"fs";import L_ from"path";import I_ from"fs/promises";import{existsSync as l,readFileSync as $1,writeFileSync as F1,mkdirSync as z6,mkdtempSync as vH,rmSync as O1,accessSync as yH,readdirSync as f6,appendFileSync as bH,unlinkSync as H9,constants as W9}from"fs";import{access as fH,rm as CY,rmdir as Gy,mkdir as NZ,readdir as EY,readlink as Uy,stat as s6,link as Vy,unlink as xY,writeFile as _6,appendFile as By,readFile as l0}from"fs/promises";async function _Z(Z){if(!Z)return;try{if(!AY.existsSync(Z))return;return(await I_.stat(Z)).mtimeMs}catch{return}}function kH(Z){if(!Z)return"";let Y=Z;try{Y=AY.realpathSync.native?AY.realpathSync.native(Z):AY.realpathSync(Z)}catch{Y=L_.resolve(Z)}return process.platform==="win32"?c0(Y).toLowerCase():Y}function PH(Z,Y){let Q=kH(Z).replace(/\/+$/,""),J=kH(Y).replace(/\/+$/,"");if(!Q||!J)return!1;if(J===Q)return!0;return J.startsWith(`${Q}/`)}var Y6=()=>{};import{constants as A_}from"fs";function I(Z="",Y=`
|
|
40
|
+
`){if(hH){hH(Z+Y);return}process.stdout.write(Z+Y)}async function q9(Z){try{if(!(await s6(Z)).isFile())return!1;return await fH(Z,A_.X_OK),!0}catch{return!1}}function S0(Z,Y,Q=!1){if(Z==="")return{match:null,candidates:Y,isExact:!1};let J=[];for(let X of Y){if(X===Z)return{match:X,candidates:null,isExact:!0};if(X.startsWith(Z))J.push(X)}if(Q&&J.length>1)J=[J[0]];return{match:J.length===1?J[0]:null,candidates:J,isExact:J.includes(Z)}}function SY(Z){return Z.map((Y)=>{if(/[\s"`$\\]/.test(Y))return`"${Y.replace(/(["\\$`])/g,"\\$1")}"`;return Y})}function G9(Z){if(!Z)return"";return Z.replace(/[/\\]/g,"_").replace(/[<>:"|?*\x00-\x1f]/g,"_")}function gH(Z){return["1","true","yes","on"].includes(Z.toLowerCase())}function mH(Z,Y){let Q=Z.split(".").map(Number),J=Y.split(".").map(Number),X=Math.max(Q.length,J.length);for(let K=0;K<X;K++){let z=Q[K]||0,H=J[K]||0;if(z>H)return 1;if(z<H)return-1}return 0}function uH(Z,Y){let Q=[],J=-1;for(let X=0;X<Z.length;X++){let K=Z[X],z=Y(K,X,Z);if(!Q[z]){if(Q[z]=[],J+1<z)for(let H=J+1;H<z;H++)Q[H]=[];J=z}Q[z].push(K)}return Q}var hH=null,x6=()=>{};var w0=_(()=>{Y6()});import V9 from"os";import m1 from"path";var U9,C,H6,_y,pH=".gdxrc.toml",dH,jZ,cH,B9,kY=1,R4=150,R1,h6,lH,$9,PY="gdx-cli",u1,C_="cache.json",E_="macro.json",iH="catppuccin-mocha",k,Q0,nH,M4,oH,wZ=86400000,S6,D4,vY=360,aH=7,sH="https://openrouter.ai/api/v1",rH=512000,TZ,tH,eH,ZW,YW,QW,JW,F9,XW="https://github.com/github-linguist/linguist/raw/refs/heads/main/lib/linguist/languages.yml",O9="languages.catalog",KW,zW=4000,R9,M9=7;var B0=_(()=>{SH();w0();U9=m1.basename(process.argv[0]||"gdx",m1.extname(process.argv[0]||"")),C=U9.startsWith("bun")||U9.startsWith("node")?"gdx":U9,H6=process.env.GDX_TEMP_DIR||V9.tmpdir(),_y=process.env.GDX_CURRENT_DIR||process.cwd(),dH=m1.join(V9.homedir(),".gdx"),jZ=m1.join(dH,pH),cH=m1.join(H6,"gdx","gdx.log"),B9=m1.join(V9.homedir(),pH),R1=process.env.GDX_RESULT,h6=z9.version||"unknown",lH=z9.homepage||"",$9=process.env.GDX_WRITE_LOGS!=null?gH(process.env.GDX_WRITE_LOGS):!0,u1=["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],Zinc500:[113,113,122],Zinc400:[161,161,170],Zinc100:[244,244,245],Zinc050:[250,250,250],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]},nH=["⠁⠀","⠋⠀","⠟⠁","⡿⠋","⣿⠟","⣿⡿","⣿⣿","⣿⣿","⣾⣿","⣴⣿","⣠⣾","⢀⣴","⠀⣠","⠀⢀","⠀⠀","⠀⠀","⠀⠀","⠀⠀","⠀⠀","⠀⠀"],M4={AVG_CHARS_PER_LINE:40,AVG_LINES_PER_FUNCTION:45,AVG_LINES_PER_FILE:500},oH=[/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],S6=m1.join(H6,"gdx",C_),D4=m1.join(dH,E_),TZ=["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"],tH=["s","st","co","br","cmi","mg","pl","pu","ps","ad","rv","rb","lg","sta"],eH=["--loglevel","--ghelp","--bypass","--no-enhance"],ZW=["--loglevel","--init","--shell","--cmd"],YW=["--ghelp","--bypass","--no-enhance","-gh"],QW=["-C","-c","--git-dir","--work-tree","--namespace","--config-env"],JW=["--no-pager","--no-optional-locks","--literal-pathspecs","--glob-pathspecs","--noglob-pathspecs","--icase-pathspecs"],F9=[".pdf",".doc",".docx",".zip",".tar",".png",".jpg",".jpeg",".gif"],KW=wZ*7,R9=[163,222,407,337,51,174,365,88,80]});function c(Z,Y,Q,J=0,X=1){if(J<0)J=0;else if(X>1)X=1;if(!(J<X)||e0.supportsColor<3)return Z;let K=Z.length,z=Math.floor(K*J),H=Math.floor(K*X),W=H-z,q=(Q[0]-Y[0])/W,G=(Q[1]-Y[1])/W,U=(Q[2]-Y[2])/W,B="";for(let F=0;F<K;F++)if(F<z)B+=`\x1B[38;2;${Y[0]};${Y[1]};${Y[2]}m${Z[F]}`;else if(F>=z&&F<=H){let $=F-z,O=Math.round(d0.clamp(Y[0]+q*$,0,255)),D=Math.round(d0.clamp(Y[1]+G*$,0,255)),j=Math.round(d0.clamp(Y[2]+U*$,0,255));B+=`\x1B[38;2;${O};${D};${j}m${Z[F]}`}else B+=`\x1B[38;2;${Q[0]};${Q[1]};${Q[2]}m${Z[F]}`;return B+="\x1B[0m",B}function HW(Z,Y,Q){let J=d0.clamp(Math.round(Z[0]+(Y[0]-Z[0])*Q),0,255),X=d0.clamp(Math.round(Z[1]+(Y[1]-Z[1])*Q),0,255),K=d0.clamp(Math.round(Z[2]+(Y[2]-Z[2])*Q),0,255);return[J,X,K]}function WW(Z,Y,Q,J=0.5,X=0.3){if(J<0)J=0;else if(J>1)J=1;if(X<=0||e0.supportsColor<3)return Z;let K=Z.length,z=J*K,H=X*K,W="";for(let q=0;q<K;q++){let U=Math.abs(q-z)/H;U=d0.clamp(U,0,1);let B=Math.round(d0.clamp(Y[0]+(Q[0]-Y[0])*U,0,255)),F=Math.round(d0.clamp(Y[1]+(Q[1]-Y[1])*U,0,255)),$=Math.round(d0.clamp(Y[2]+(Q[2]-Y[2])*U,0,255));W+=`\x1B[38;2;${B};${F};${$}m${Z[q]}`}return W+="\x1B[0m",W}function _4(Z){let Y=d0.clamp(Math.round(Z[0]),0,255),Q=d0.clamp(Math.round(Z[1]),0,255),J=d0.clamp(Math.round(Z[2]),0,255);return(Y<<16)+(Q<<8)+J}function qW(Z,Y,Q){let J,X,K;if(Y===0)J=X=K=Q;else{let z=(q,G,U)=>{if(U<0)U+=1;if(U>1)U-=1;if(U<0.16666666666666666)return q+(G-q)*6*U;if(U<0.5)return G;if(U<0.6666666666666666)return q+(G-q)*(0.6666666666666666-U)*6;return q},H=Q<0.5?Q*(1+Y):Q+Y-Q*Y,W=2*Q-H;J=z(W,H,Z+0.3333333333333333),X=z(W,H,Z),K=z(W,H,Z-0.3333333333333333)}return[Math.round(J*255),Math.round(X*255),Math.round(K*255)]}function g6(Z,Y,Q){return[Math.round(Z[0]*(1-Q)+Y[0]*Q),Math.round(Z[1]*(1-Q)+Y[1]*Q),Math.round(Z[2]*(1-Q)+Y[2]*Q)]}function k0(Z){return`\x1B[38;2;${Z[0]};${Z[1]};${Z[2]}m`}function Q6(Z){return`\x1B[48;2;${Z[0]};${Z[1]};${Z[2]}m`}function q8(Z){return Z.replace(/\x1b\[[0-9;]*m/g,"")}function LZ(Z,Y,Q,J,X){let H=0,W=1,q=Z;for(let G=0;G<10;G++){let B=k_(q,Y,J)-Z;if(Math.abs(B)<0.000001)break;if(B>0)W=q;else H=q;q=(H+W)/2}return P_(q,Q,X)}function k_(Z,Y,Q){let J=1-Z;return 3*J*J*Z*Y+3*J*Z*Z*Q+Z*Z*Z}function P_(Z,Y,Q){let J=1-Z;return 3*J*J*Z*Y+3*J*Z*Z*Q+Z*Z*Z}function v_(Z){for(let[Y,Q]of x_)if(Q===Z)return Y;return null}function yY(Z){let Y={},Q=[...Z.matchAll(xH.ANSICode)].reverse();for(let J of Q){let X=J[1],K=v_("\x1B"+X);if(K)if(K==="reset")break;else if(!Y.bg&&K.startsWith("bg"))Y.bg=K;else if(S_.includes(K)){if(!Y.sp)Y.sp=[];Y.sp.unshift(K)}else{if(Y.fg)continue;Y.fg=K}else if(!Y.fg&&X.startsWith("[38;2;")){let[z,H,W]=X.slice(6).split(";").map((q)=>parseInt(q,10));Y.fg=[z,H,W]}else if(!Y.bg&&X.startsWith("[48;2;")){let[z,H,W]=X.slice(6).split(";").map((q)=>parseInt(q,10));Y.bg=[z,H,W]}}return Y}function bY(Z){let Y="";if(Z.sp)for(let Q of Z.sp){let J=MZ.AnsiColorCodes[Q];if(J)Y+=J}if(Z.fg)if(typeof Z.fg==="string"){let Q=MZ.AnsiColorCodes[Z.fg];if(Q)Y+=Q}else Y+=k0(Z.fg);if(Z.bg)if(typeof Z.bg==="string"){let Q=MZ.AnsiColorCodes[Z.bg];if(Q)Y+=Q}else Y+=Q6(Z.bg);return Y}function fY(Z,Y){let Q=Z.length-Z.replace(/\n/g,"").length+1;process.stdout.write(`\x1B[${Q}F`),process.stdout.write("\x1B[0J");for(let J of Y.split(`
|
|
41
|
+
`))process.stdout.write(`\x1B[2K${J}
|
|
42
|
+
`)}var x_,S_,GW;var I0=_(()=>{G0();x_=Object.entries(MZ.AnsiColorCodes),S_=["bright","dim","italic","underline","inverse","hidden"];GW={linear:(Z)=>Z,easeIn:(Z)=>LZ(Z,0.42,0,1,1),easeOut:(Z)=>LZ(Z,0,0,0.58,1),easeInOut:(Z)=>LZ(Z,0.42,0,0.58,1),smooth:(Z)=>LZ(Z,0.25,0.1,0.25,1),bounce:(Z)=>LZ(Z,0.68,-0.55,0.265,1.55)}});var p;var A0=_(()=>{p={exitCodeOverride:-1,finalStringOutput:"",logLevel:"warn",terminalWidth:process.stdout.columns||100,indexArgs:!0}});function C0(Z){if(typeof Z!=="object"||Z===null)return!1;let Y=Object.getPrototypeOf(Z);return(Y===null||Y===Object.prototype||Object.getPrototypeOf(Y)===null)&&!(Symbol.toStringTag in Z)&&!(Symbol.iterator in Z)}import{fileURLToPath as y_}from"node:url";var G8=(Z,Y)=>{let Q=_9(b_(Z));if(typeof Q!=="string")throw TypeError(`${Y} must be a string or a file URL: ${Q}.`);return Q},b_=(Z)=>D9(Z)?Z.toString():Z,D9=(Z)=>typeof Z!=="string"&&Z&&Object.getPrototypeOf(Z)===String.prototype,_9=(Z)=>Z instanceof URL?y_(Z):Z;var U8=()=>{};var hY=(Z,Y=[],Q={})=>{let J=G8(Z,"First argument"),[X,K]=C0(Y)?[[],Y]:[Y,Q];if(!Array.isArray(X))throw TypeError(`Second argument must be either an array of arguments or an options object: ${X}`);if(X.some((W)=>typeof W==="object"&&W!==null))throw TypeError(`Second argument must be an array of strings: ${X}`);let z=X.map(String),H=z.find((W)=>W.includes("\x00"));if(H!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${H}`);if(!C0(K))throw TypeError(`Last argument must be an options object: ${K}`);return[J,z,K]};var N9=_(()=>{U8()});import{StringDecoder as f_}from"node:string_decoder";var UW,VW=(Z)=>UW.call(Z)==="[object ArrayBuffer]",y0=(Z)=>UW.call(Z)==="[object Uint8Array]",M1=(Z)=>new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),h_,BW=(Z)=>h_.encode(Z),g_,gY=(Z)=>g_.decode(Z),$W=(Z,Y)=>{return m_(Z,Y).join("")},m_=(Z,Y)=>{if(Y==="utf8"&&Z.every((K)=>typeof K==="string"))return Z;let Q=new f_(Y),J=Z.map((K)=>typeof K==="string"?BW(K):K).map((K)=>Q.write(K)),X=Q.end();return X===""?J:[...J,X]},IZ=(Z)=>{if(Z.length===1&&y0(Z[0]))return Z[0];return j9(u_(Z))},u_=(Z)=>Z.map((Y)=>typeof Y==="string"?BW(Y):Y),j9=(Z)=>{let Y=new Uint8Array(p_(Z)),Q=0;for(let J of Z)Y.set(J,Q),Q+=J.length;return Y},p_=(Z)=>{let Y=0;for(let Q of Z)Y+=Q.length;return Y};var N6=_(()=>{({toString:UW}=Object.prototype),h_=new TextEncoder,g_=new TextDecoder});import{ChildProcess as d_}from"node:child_process";var MW=(Z)=>Array.isArray(Z)&&Array.isArray(Z.raw),DW=(Z,Y)=>{let Q=[];for(let[K,z]of Z.entries())Q=c_({templates:Z,expressions:Y,tokens:Q,index:K,template:z});if(Q.length===0)throw TypeError("Template script must not be empty");let[J,...X]=Q;return[J,X,{}]},c_=({templates:Z,expressions:Y,tokens:Q,index:J,template:X})=>{if(X===void 0)throw TypeError(`Invalid backslash sequence: ${Z.raw[J]}`);let{nextTokens:K,leadingWhitespaces:z,trailingWhitespaces:H}=l_(X,Z.raw[J]),W=OW(Q,K,z);if(J===Y.length)return W;let q=Y[J],G=Array.isArray(q)?q.map((U)=>RW(U)):[RW(q)];return OW(W,G,H)},l_=(Z,Y)=>{if(Y.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let Q=[],J=0,X=FW.has(Y[0]);for(let z=0,H=0;z<Z.length;z+=1,H+=1){let W=Y[H];if(FW.has(W)){if(J!==z)Q.push(Z.slice(J,z));J=z+1}else if(W==="\\"){let q=Y[H+1];if(q===`
|
|
43
|
+
`)z-=1,H+=1;else if(q==="u"&&Y[H+2]==="{")H=Y.indexOf("}",H+3);else H+=i_[q]??1}}let K=J===Z.length;if(!K)Q.push(Z.slice(J));return{nextTokens:Q,leadingWhitespaces:X,trailingWhitespaces:K}},FW,i_,OW=(Z,Y,Q)=>Q||Z.length===0||Y.length===0?[...Z,...Y]:[...Z.slice(0,-1),`${Z.at(-1)}${Y[0]}`,...Y.slice(1)],RW=(Z)=>{let Y=typeof Z;if(Y==="string")return Z;if(Y==="number")return String(Z);if(C0(Z)&&(("stdout"in Z)||("isMaxBuffer"in Z)))return n_(Z);if(Z instanceof d_||Object.prototype.toString.call(Z)==="[object Promise]")throw TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw TypeError(`Unexpected "${Y}" in template expression`)},n_=({stdout:Z})=>{if(typeof Z==="string")return Z;if(y0(Z))return gY(Z);if(Z===void 0)throw TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw TypeError(`Unexpected "${typeof Z}" stdout in template expression`)};var _W=_(()=>{N6();FW=new Set([" ","\t","\r",`
|
|
44
|
+
`]),i_={x:3,u:5}});import w9 from"node:process";var m6=(Z)=>mY.includes(Z),mY,k6,uY=(Z)=>k6[Z]??`stdio[${Z}]`;var D1=_(()=>{mY=[w9.stdin,w9.stdout,w9.stderr],k6=["stdin","stdout","stderr"]});import{debuglog as o_}from"node:util";var jW=(Z)=>{let Y={...Z};for(let Q of I9)Y[Q]=T9(Z,Q);return Y},T9=(Z,Y)=>{let Q=Array.from({length:a_(Z)+1}),J=s_(Z[Y],Q,Y);return YN(J,Y)},a_=({stdio:Z})=>Array.isArray(Z)?Math.max(Z.length,k6.length):k6.length,s_=(Z,Y,Q)=>C0(Z)?r_(Z,Y,Q):Y.fill(Z),r_=(Z,Y,Q)=>{for(let J of Object.keys(Z).sort(t_))for(let X of e_(J,Q,Y))Y[X]=Z[J];return Y},t_=(Z,Y)=>NW(Z)<NW(Y)?1:-1,NW=(Z)=>{if(Z==="stdout"||Z==="stderr")return 0;return Z==="all"?2:1},e_=(Z,Y,Q)=>{if(Z==="ipc")return[Q.length-1];let J=L9(Z);if(J===void 0||J===0)throw TypeError(`"${Y}.${Z}" is invalid.
|
|
45
|
+
It must be "${Y}.stdout", "${Y}.stderr", "${Y}.all", "${Y}.ipc", or "${Y}.fd3", "${Y}.fd4" (and so on).`);if(J>=Q.length)throw TypeError(`"${Y}.${Z}" is invalid: that file descriptor does not exist.
|
|
46
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);return J==="all"?[1,2]:[J]},L9=(Z)=>{if(Z==="all")return Z;if(k6.includes(Z))return k6.indexOf(Z);let Y=ZN.exec(Z);if(Y!==null)return Number(Y[1])},ZN,YN=(Z,Y)=>Z.map((Q)=>Q===void 0?JN[Y]:Q),QN,JN,I9,_1=(Z,Y)=>Y==="ipc"?Z.at(-1):Z[Y];var N1=_(()=>{D1();ZN=/^fd(\d+)$/,QN=o_("execa").enabled?"full":"none",JN={lines:!1,buffer:!0,maxBuffer:1e8,verbose:QN,stripFinalNewline:!0},I9=["lines","buffer","maxBuffer","verbose","stripFinalNewline"]});var V8=({verbose:Z},Y)=>A9(Z,Y)!=="none",B8=({verbose:Z},Y)=>!["none","short"].includes(A9(Z,Y)),wW=({verbose:Z},Y)=>{let Q=A9(Z,Y);return pY(Q)?Q:void 0},A9=(Z,Y)=>Y===void 0?XN(Z):_1(Z,Y),XN=(Z)=>Z.find((Y)=>pY(Y))??dY.findLast((Y)=>Z.includes(Y)),pY=(Z)=>typeof Z==="function",dY;var p1=_(()=>{N1();dY=["none","short","full"]});import{platform as KN}from"node:process";import{stripVTControlCharacters as zN}from"node:util";var TW=(Z,Y)=>{let Q=[Z,...Y],J=Q.join(" "),X=Q.map((K)=>VN(LW(K))).join(" ");return{command:J,escapedCommand:X}},AZ=(Z)=>zN(Z).split(`
|
|
47
|
+
`).map((Y)=>LW(Y)).join(`
|
|
48
|
+
`),LW=(Z)=>Z.replaceAll(qN,(Y)=>HN(Y)),HN=(Z)=>{let Y=GN[Z];if(Y!==void 0)return Y;let Q=Z.codePointAt(0),J=Q.toString(16);return Q<=UN?`\\u${J.padStart(4,"0")}`:`\\U${J}`},WN=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},qN,GN,UN=65535,VN=(Z)=>{if(BN.test(Z))return Z;return KN==="win32"?`"${Z.replaceAll('"','""')}"`:`'${Z.replaceAll("'","'\\''")}'`},BN;var cY=_(()=>{qN=WN(),GN={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},BN=/^[\w./-]+$/});import IW from"node:process";function C9(){let{env:Z}=IW,{TERM:Y,TERM_PROGRAM:Q}=Z;if(IW.platform!=="win32")return Y!=="linux";return Boolean(Z.WT_SESSION)||Boolean(Z.TERMINUS_SUBLIME)||Z.ConEmuTask==="{cmd::Cmder}"||Q==="Terminus-Sublime"||Q==="vscode"||Y==="xterm-256color"||Y==="alacritty"||Y==="rxvt-unicode"||Y==="rxvt-unicode-256color"||Z.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var AW=()=>{};var CW,EW,$N,FN,ON,RN,MN,lY,ry;var xW=_(()=>{AW();CW={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:"╱"},EW={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:"⅒"},$N={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"},FN={...CW,...EW},ON={...CW,...$N},RN=C9(),MN=RN?FN:ON,lY=MN,ry=Object.entries(EW)});import DN from"node:tty";var _N,z0=(Z,Y)=>{if(!_N)return(X)=>X;let Q=`\x1B[${Z}m`,J=`\x1B[${Y}m`;return(X)=>{let K=X+"",z=K.indexOf(J);if(z===-1)return Q+K+J;let H=Q,W=0,G=(Y===22?J:"")+Q;while(z!==-1)H+=K.slice(W,z)+G,W=z+J.length,z=K.indexOf(J,W);return H+=K.slice(W)+J,H}},Zb,SW,Yb,Qb,Jb,Xb,Kb,zb,Hb,Wb,qb,Gb,Ub,Vb,Bb,$b,Fb,iY,Ob,Rb,Mb,Db,_b,Nb,jb,wb,Tb,kW,Lb,PW,Ib,Ab,Cb,Eb,xb,Sb,kb,Pb,vb,yb,bb;var vW=_(()=>{_N=DN?.WriteStream?.prototype?.hasColors?.()??!1,Zb=z0(0,0),SW=z0(1,22),Yb=z0(2,22),Qb=z0(3,23),Jb=z0(4,24),Xb=z0(53,55),Kb=z0(7,27),zb=z0(8,28),Hb=z0(9,29),Wb=z0(30,39),qb=z0(31,39),Gb=z0(32,39),Ub=z0(33,39),Vb=z0(34,39),Bb=z0(35,39),$b=z0(36,39),Fb=z0(37,39),iY=z0(90,39),Ob=z0(40,49),Rb=z0(41,49),Mb=z0(42,49),Db=z0(43,49),_b=z0(44,49),Nb=z0(45,49),jb=z0(46,49),wb=z0(47,49),Tb=z0(100,49),kW=z0(91,39),Lb=z0(92,39),PW=z0(93,39),Ib=z0(94,39),Ab=z0(95,39),Cb=z0(96,39),Eb=z0(97,39),xb=z0(101,49),Sb=z0(102,49),kb=z0(103,49),Pb=z0(104,49),vb=z0(105,49),yb=z0(106,49),bb=z0(107,49)});var yW=_(()=>{vW()});var hW=({type:Z,message:Y,timestamp:Q,piped:J,commandId:X,result:{failed:K=!1}={},options:{reject:z=!0}})=>{let H=NN(Q),W=jN[Z]({failed:K,reject:z,piped:J}),q=wN[Z]({reject:z});return`${iY(`[${H}]`)} ${iY(`[${X}]`)} ${q(W)} ${q(Y)}`},NN=(Z)=>`${nY(Z.getHours(),2)}:${nY(Z.getMinutes(),2)}:${nY(Z.getSeconds(),2)}.${nY(Z.getMilliseconds(),3)}`,nY=(Z,Y)=>String(Z).padStart(Y,"0"),bW=({failed:Z,reject:Y})=>{if(!Z)return lY.tick;return Y?lY.cross:lY.warning},jN,fW=(Z)=>Z,wN;var gW=_(()=>{xW();yW();jN={command:({piped:Z})=>Z?"|":"$",output:()=>" ",ipc:()=>"*",error:bW,duration:bW},wN={command:()=>SW,output:()=>fW,ipc:()=>fW,error:({reject:Z})=>Z?kW:PW,duration:()=>iY}});var mW=(Z,Y,Q)=>{let J=wW(Y,Q);return Z.map(({verboseLine:X,verboseObject:K})=>TN(X,K,J)).filter((X)=>X!==void 0).map((X)=>LN(X)).join("")},TN=(Z,Y,Q)=>{if(Q===void 0)return Z;let J=Q(Z,Y);if(typeof J==="string")return J},LN=(Z)=>Z.endsWith(`
|
|
49
|
+
`)?Z:`${Z}
|
|
50
|
+
`;var uW=_(()=>{p1()});import{inspect as IN}from"node:util";var r6=({type:Z,verboseMessage:Y,fdNumber:Q,verboseInfo:J,result:X})=>{let K=AN({type:Z,result:X,verboseInfo:J}),z=CN(Y,K),H=mW(z,J,Q);if(H!=="")console.warn(H.slice(0,-1))},AN=({type:Z,result:Y,verboseInfo:{escapedCommand:Q,commandId:J,rawOptions:{piped:X=!1,...K}}})=>({type:Z,escapedCommand:Q,commandId:`${J}`,timestamp:new Date,piped:X,result:Y,options:K}),CN=(Z,Y)=>Z.split(`
|
|
51
|
+
`).map((Q)=>EN({...Y,message:Q})),EN=(Z)=>{return{verboseLine:hW(Z),verboseObject:Z}},oY=(Z)=>{let Y=typeof Z==="string"?Z:IN(Z);return AZ(Y).replaceAll("\t"," ".repeat(xN))},xN=2;var $8=_(()=>{cY();gW();uW()});var pW=(Z,Y)=>{if(!V8(Y))return;r6({type:"command",verboseMessage:Z,verboseInfo:Y})};var dW=_(()=>{p1();$8()});var cW=(Z,Y,Q)=>{PN(Z);let J=SN(Z);return{verbose:Z,escapedCommand:Y,commandId:J,rawOptions:Q}},SN=(Z)=>V8({verbose:Z})?kN++:void 0,kN=0n,PN=(Z)=>{for(let Y of Z){if(Y===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(Y===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!dY.includes(Y)&&!pY(Y)){let Q=dY.map((J)=>`'${J}'`).join(", ");throw TypeError(`The "verbose" option must not be ${Y}. Allowed values are: ${Q} or a function.`)}}};var lW=_(()=>{p1()});import{hrtime as iW}from"node:process";var aY=()=>iW.bigint(),E9=(Z)=>Number(iW.bigint()-Z)/1e6;var sY=()=>{};var rY=(Z,Y,Q)=>{let J=aY(),{command:X,escapedCommand:K}=TW(Z,Y),z=T9(Q,"verbose"),H=cW(z,K,{...Q});return pW(K,H),{command:X,escapedCommand:K,startTime:J,verboseInfo:H}};var x9=_(()=>{dW();lW();sY();cY();N1()});var rW=M6((Gf,sW)=>{sW.exports=aW;aW.sync=yN;var nW=E6("fs");function vN(Z,Y){var Q=Y.pathExt!==void 0?Y.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 X=Q[J].toLowerCase();if(X&&Z.substr(-X.length).toLowerCase()===X)return!0}return!1}function oW(Z,Y,Q){if(!Z.isSymbolicLink()&&!Z.isFile())return!1;return vN(Y,Q)}function aW(Z,Y,Q){nW.stat(Z,function(J,X){Q(J,J?!1:oW(X,Z,Y))})}function yN(Z,Y){return oW(nW.statSync(Z),Z,Y)}});var Qq=M6((Uf,Yq)=>{Yq.exports=eW;eW.sync=bN;var tW=E6("fs");function eW(Z,Y,Q){tW.stat(Z,function(J,X){Q(J,J?!1:Zq(X,Y))})}function bN(Z,Y){return Zq(tW.statSync(Z),Y)}function Zq(Z,Y){return Z.isFile()&&fN(Z,Y)}function fN(Z,Y){var{mode:Q,uid:J,gid:X}=Z,K=Y.uid!==void 0?Y.uid:process.getuid&&process.getuid(),z=Y.gid!==void 0?Y.gid:process.getgid&&process.getgid(),H=parseInt("100",8),W=parseInt("010",8),q=parseInt("001",8),G=H|W,U=Q&q||Q&W&&X===z||Q&H&&J===K||Q&G&&K===0;return U}});var Xq=M6((Bf,Jq)=>{var Vf=E6("fs"),tY;if(process.platform==="win32"||global.TESTING_WINDOWS)tY=rW();else tY=Qq();Jq.exports=S9;S9.sync=hN;function S9(Z,Y,Q){if(typeof Y==="function")Q=Y,Y={};if(!Q){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(J,X){S9(Z,Y||{},function(K,z){if(K)X(K);else J(z)})})}tY(Z,Y||{},function(J,X){if(J){if(J.code==="EACCES"||Y&&Y.ignoreErrors)J=null,X=!1}Q(J,X)})}function hN(Z,Y){try{return tY.sync(Z,Y||{})}catch(Q){if(Y&&Y.ignoreErrors||Q.code==="EACCES")return!1;else throw Q}}});var Uq=M6(($f,Gq)=>{var F8=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Kq=E6("path"),gN=F8?";":":",zq=Xq(),Hq=(Z)=>Object.assign(Error(`not found: ${Z}`),{code:"ENOENT"}),Wq=(Z,Y)=>{let Q=Y.colon||gN,J=Z.match(/\//)||F8&&Z.match(/\\/)?[""]:[...F8?[process.cwd()]:[],...(Y.path||process.env.PATH||"").split(Q)],X=F8?Y.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",K=F8?X.split(Q):[""];if(F8){if(Z.indexOf(".")!==-1&&K[0]!=="")K.unshift("")}return{pathEnv:J,pathExt:K,pathExtExe:X}},qq=(Z,Y,Q)=>{if(typeof Y==="function")Q=Y,Y={};if(!Y)Y={};let{pathEnv:J,pathExt:X,pathExtExe:K}=Wq(Z,Y),z=[],H=(q)=>new Promise((G,U)=>{if(q===J.length)return Y.all&&z.length?G(z):U(Hq(Z));let B=J[q],F=/^".*"$/.test(B)?B.slice(1,-1):B,$=Kq.join(F,Z),O=!F&&/^\.[\\\/]/.test(Z)?Z.slice(0,2)+$:$;G(W(O,q,0))}),W=(q,G,U)=>new Promise((B,F)=>{if(U===X.length)return B(H(G+1));let $=X[U];zq(q+$,{pathExt:K},(O,D)=>{if(!O&&D)if(Y.all)z.push(q+$);else return B(q+$);return B(W(q,G,U+1))})});return Q?H(0).then((q)=>Q(null,q),Q):H(0)},mN=(Z,Y)=>{Y=Y||{};let{pathEnv:Q,pathExt:J,pathExtExe:X}=Wq(Z,Y),K=[];for(let z=0;z<Q.length;z++){let H=Q[z],W=/^".*"$/.test(H)?H.slice(1,-1):H,q=Kq.join(W,Z),G=!W&&/^\.[\\\/]/.test(Z)?Z.slice(0,2)+q:q;for(let U=0;U<J.length;U++){let B=G+J[U];try{if(zq.sync(B,{pathExt:X}))if(Y.all)K.push(B);else return B}catch(F){}}}if(Y.all&&K.length)return K;if(Y.nothrow)return null;throw Hq(Z)};Gq.exports=qq;qq.sync=mN});var Bq=M6((Ff,k9)=>{var Vq=(Z={})=>{let Y=Z.env||process.env;if((Z.platform||process.platform)!=="win32")return"PATH";return Object.keys(Y).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"};k9.exports=Vq;k9.exports.default=Vq});var Rq=M6((Of,Oq)=>{var $q=E6("path"),uN=Uq(),pN=Bq();function Fq(Z,Y){let Q=Z.options.env||process.env,J=process.cwd(),X=Z.options.cwd!=null,K=X&&process.chdir!==void 0&&!process.chdir.disabled;if(K)try{process.chdir(Z.options.cwd)}catch(H){}let z;try{z=uN.sync(Z.command,{path:Q[pN({env:Q})],pathExt:Y?$q.delimiter:void 0})}catch(H){}finally{if(K)process.chdir(J)}if(z)z=$q.resolve(X?Z.options.cwd:"",z);return z}function dN(Z){return Fq(Z)||Fq(Z,!0)}Oq.exports=dN});var Mq=M6((iN,v9)=>{var P9=/([()\][%!^"`<>&|;, *?])/g;function cN(Z){return Z=Z.replace(P9,"^$1"),Z}function lN(Z,Y){if(Z=`${Z}`,Z=Z.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),Z=Z.replace(/(?=(\\+?)?)\1$/,"$1$1"),Z=`"${Z}"`,Z=Z.replace(P9,"^$1"),Y)Z=Z.replace(P9,"^$1");return Z}iN.command=cN;iN.argument=lN});var _q=M6((Rf,Dq)=>{Dq.exports=/^#!(.*)/});var jq=M6((Mf,Nq)=>{var aN=_q();Nq.exports=(Z="")=>{let Y=Z.match(aN);if(!Y)return null;let[Q,J]=Y[0].replace(/#! ?/,"").split(" "),X=Q.split("/").pop();if(X==="env")return J;return J?`${X} ${J}`:X}});var Tq=M6((Df,wq)=>{var y9=E6("fs"),sN=jq();function rN(Z){let Q=Buffer.alloc(150),J;try{J=y9.openSync(Z,"r"),y9.readSync(J,Q,0,150,0),y9.closeSync(J)}catch(X){}return sN(Q.toString())}wq.exports=rN});var Cq=M6((_f,Aq)=>{var tN=E6("path"),Lq=Rq(),Iq=Mq(),eN=Tq(),Zj=process.platform==="win32",Yj=/\.(?:com|exe)$/i,Qj=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Jj(Z){Z.file=Lq(Z);let Y=Z.file&&eN(Z.file);if(Y)return Z.args.unshift(Z.file),Z.command=Y,Lq(Z);return Z.file}function Xj(Z){if(!Zj)return Z;let Y=Jj(Z),Q=!Yj.test(Y);if(Z.options.forceShell||Q){let J=Qj.test(Y);Z.command=tN.normalize(Z.command),Z.command=Iq.command(Z.command),Z.args=Z.args.map((K)=>Iq.argument(K,J));let X=[Z.command].concat(Z.args).join(" ");Z.args=["/d","/s","/c",`"${X}"`],Z.command=process.env.comspec||"cmd.exe",Z.options.windowsVerbatimArguments=!0}return Z}function Kj(Z,Y,Q){if(Y&&!Array.isArray(Y))Q=Y,Y=null;Y=Y?Y.slice(0):[],Q=Object.assign({},Q);let J={command:Z,args:Y,options:Q,file:void 0,original:{command:Z,args:Y}};return Q.shell?J:Xj(J)}Aq.exports=Kj});var Sq=M6((Nf,xq)=>{var b9=process.platform==="win32";function f9(Z,Y){return Object.assign(Error(`${Y} ${Z.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${Y} ${Z.command}`,path:Z.command,spawnargs:Z.args})}function zj(Z,Y){if(!b9)return;let Q=Z.emit;Z.emit=function(J,X){if(J==="exit"){let K=Eq(X,Y);if(K)return Q.call(Z,"error",K)}return Q.apply(Z,arguments)}}function Eq(Z,Y){if(b9&&Z===1&&!Y.file)return f9(Y.original,"spawn");return null}function Hj(Z,Y){if(b9&&Z===1&&!Y.file)return f9(Y.original,"spawnSync");return null}xq.exports={hookChildProcess:zj,verifyENOENT:Eq,verifyENOENTSync:Hj,notFoundError:f9}});var vq=M6((jf,O8)=>{var kq=E6("child_process"),h9=Cq(),g9=Sq();function Pq(Z,Y,Q){let J=h9(Z,Y,Q),X=kq.spawn(J.command,J.args,J.options);return g9.hookChildProcess(X,J),X}function Wj(Z,Y,Q){let J=h9(Z,Y,Q),X=kq.spawnSync(J.command,J.args,J.options);return X.error=X.error||g9.verifyENOENTSync(X.status,J),X}O8.exports=Pq;O8.exports.spawn=Pq;O8.exports.sync=Wj;O8.exports._parse=h9;O8.exports._enoent=g9});function eY(Z={}){let{env:Y=process.env,platform:Q=process.platform}=Z;if(Q!=="win32")return"PATH";return Object.keys(Y).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"}import{promisify as qj}from"node:util";import{execFile as Gj,execFileSync as If}from"node:child_process";import yq from"node:path";import{fileURLToPath as Uj}from"node:url";function Z5(Z){return Z instanceof URL?Uj(Z):Z}function bq(Z){return{*[Symbol.iterator](){let Y=yq.resolve(Z5(Z)),Q;while(Q!==Y)yield Y,Q=Y,Y=yq.resolve(Y,"..")}}}var Ef;var fq=_(()=>{Ef=qj(Gj)});import Y5 from"node:process";import N4 from"node:path";var Vj=({cwd:Z=Y5.cwd(),path:Y=Y5.env[eY()],preferLocal:Q=!0,execPath:J=Y5.execPath,addExecPath:X=!0}={})=>{let K=N4.resolve(Z5(Z)),z=[],H=Y.split(N4.delimiter);if(Q)Bj(z,H,K);if(X)$j(z,H,J,K);return Y===""||Y===N4.delimiter?`${z.join(N4.delimiter)}${Y}`:[...z,Y].join(N4.delimiter)},Bj=(Z,Y,Q)=>{for(let J of bq(Q)){let X=N4.join(J,"node_modules/.bin");if(!Y.includes(X))Z.push(X)}},$j=(Z,Y,Q,J)=>{let X=N4.resolve(J,Z5(Q),"..");if(!Y.includes(X))Z.push(X)},hq=({env:Z=Y5.env,...Y}={})=>{Z={...Z};let Q=eY({env:Z});return Y.path=Z[Q],Z[Q]=Vj(Y),Z};var gq=_(()=>{fq()});var mq=(Z,Y,Q)=>{let J=Q?CZ:P6,X=Z instanceof t6?{}:{cause:Z};return new J(Y,X)},t6,uq=(Z,Y)=>{Object.defineProperty(Z.prototype,"name",{value:Y,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(Z.prototype,dq,{value:!0,writable:!1,enumerable:!1,configurable:!1})},pq=(Z)=>Q5(Z)&&(dq in Z),dq,Q5=(Z)=>Object.prototype.toString.call(Z)==="[object Error]",P6,CZ;var d1=_(()=>{t6=class t6 extends Error{};dq=Symbol("isExecaError");P6=class P6 extends Error{};uq(P6,P6.name);CZ=class CZ extends Error{};uq(CZ,CZ.name)});var cq=()=>{let Z=m9-lq+1;return Array.from({length:Z},Fj)},Fj=(Z,Y)=>({name:`SIGRT${Y+1}`,number:lq+Y,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),lq=34,m9=64;var iq;var nq=_(()=>{iq=[{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 Oj}from"node:os";var u9=()=>{let Z=cq();return[...iq,...Z].map(Rj)},Rj=({name:Z,number:Y,description:Q,action:J,forced:X=!1,standard:K})=>{let{signals:{[Z]:z}}=Oj,H=z!==void 0;return{name:Z,number:H?z:Y,description:Q,supported:H,action:J,forced:X,standard:K}};var oq=_(()=>{nq()});import{constants as Mj}from"node:os";var Dj=()=>{let Z=u9();return Object.fromEntries(Z.map(_j))},_j=({name:Z,number:Y,description:Q,supported:J,action:X,forced:K,standard:z})=>[Z,{name:Z,number:Y,description:Q,supported:J,action:X,forced:K,standard:z}],aq,Nj=()=>{let Z=u9(),Y=m9+1,Q=Array.from({length:Y},(J,X)=>jj(X,Z));return Object.assign({},...Q)},jj=(Z,Y)=>{let Q=wj(Z,Y);if(Q===void 0)return{};let{name:J,description:X,supported:K,action:z,forced:H,standard:W}=Q;return{[Z]:{name:J,number:Z,description:X,supported:K,action:z,forced:H,standard:W}}},wj=(Z,Y)=>{let Q=Y.find(({name:J})=>Mj.signals[J]===Z);if(Q!==void 0)return Q;return Y.find((J)=>J.number===Z)},of;var sq=_(()=>{oq();aq=Dj(),of=Nj()});import{constants as EZ}from"node:os";var tq=(Z)=>{if(Z===0)throw TypeError("Invalid option `killSignal`: 0 cannot be used.");return ZG(Z,"option `killSignal`")},eq=(Z)=>Z===0?Z:ZG(Z,"`subprocess.kill()`'s argument"),ZG=(Z,Y)=>{if(Number.isInteger(Z))return Tj(Z,Y);if(typeof Z==="string")return Ij(Z,Y);throw TypeError(`Invalid ${Y} ${String(Z)}: it must be a string or an integer.
|
|
52
|
+
${p9()}`)},Tj=(Z,Y)=>{if(rq.has(Z))return rq.get(Z);throw TypeError(`Invalid ${Y} ${Z}: this signal integer does not exist.
|
|
53
|
+
${p9()}`)},Lj=()=>new Map(Object.entries(EZ.signals).reverse().map(([Z,Y])=>[Y,Z])),rq,Ij=(Z,Y)=>{if(Z in EZ.signals)return Z;if(Z.toUpperCase()in EZ.signals)throw TypeError(`Invalid ${Y} '${Z}': please rename it to '${Z.toUpperCase()}'.`);throw TypeError(`Invalid ${Y} '${Z}': this signal name does not exist.
|
|
54
|
+
${p9()}`)},p9=()=>`Available signal names: ${Aj()}.
|
|
55
|
+
Available signal numbers: ${Cj()}.`,Aj=()=>Object.keys(EZ.signals).sort().map((Z)=>`'${Z}'`).join(", "),Cj=()=>[...new Set(Object.values(EZ.signals).sort((Z,Y)=>Z-Y))].join(", "),J5=(Z)=>aq[Z].description;var xZ=_(()=>{sq();rq=Lj()});import{setTimeout as Ej}from"node:timers/promises";var YG=(Z)=>{if(Z===!1)return Z;if(Z===!0)return xj;if(!Number.isFinite(Z)||Z<0)throw TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${Z}\` (${typeof Z})`);return Z},xj=5000,QG=({kill:Z,options:{forceKillAfterDelay:Y,killSignal:Q},onInternalError:J,context:X,controller:K},z,H)=>{let{signal:W,error:q}=Sj(z,H,Q);kj(q,J);let G=Z(W);return Pj({kill:Z,signal:W,forceKillAfterDelay:Y,killSignal:Q,killResult:G,context:X,controller:K}),G},Sj=(Z,Y,Q)=>{let[J=Q,X]=Q5(Z)?[void 0,Z]:[Z,Y];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(X!==void 0&&!Q5(X))throw TypeError(`The second argument is optional. If specified, it must be an error instance: ${X}`);return{signal:eq(J),error:X}},kj=(Z,Y)=>{if(Z!==void 0)Y.reject(Z)},Pj=async({kill:Z,signal:Y,forceKillAfterDelay:Q,killSignal:J,killResult:X,context:K,controller:z})=>{if(Y===J&&X)d9({kill:Z,forceKillAfterDelay:Q,context:K,controllerSignal:z.signal})},d9=async({kill:Z,forceKillAfterDelay:Y,context:Q,controllerSignal:J})=>{if(Y===!1)return;try{if(await Ej(Y,void 0,{signal:J}),Z("SIGKILL"))Q.isForcefullyTerminated??=!0}catch{}};var X5=_(()=>{d1();xZ()});import{once as vj}from"node:events";var K5=async(Z,Y)=>{if(!Z.aborted)await vj(Z,"abort",{signal:Y})};var c9=()=>{};var JG=({cancelSignal:Z})=>{if(Z!==void 0&&Object.prototype.toString.call(Z)!=="[object AbortSignal]")throw Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(Z)}`)},XG=({subprocess:Z,cancelSignal:Y,gracefulCancel:Q,context:J,controller:X})=>Y===void 0||Q?[]:[yj(Z,Y,J,X)],yj=async(Z,Y,Q,{signal:J})=>{throw await K5(Y,J),Q.terminationReason??="cancel",Z.kill(),Y.reason};var l9=_(()=>{c9()});var R8=({methodName:Z,isSubprocess:Y,ipc:Q,isConnected:J})=>{bj(Z,Y,Q),i9(Z,Y,J)},bj=(Z,Y,Q)=>{if(!Q)throw Error(`${u6(Z,Y)} can only be used if the \`ipc\` option is \`true\`.`)},i9=(Z,Y,Q)=>{if(!Q)throw Error(`${u6(Z,Y)} cannot be used: the ${c1(Y)} has already exited or disconnected.`)},KG=(Z)=>{throw Error(`${u6("getOneMessage",Z)} could not complete: the ${c1(Z)} exited or disconnected.`)},zG=(Z)=>{throw Error(`${u6("sendMessage",Z)} failed: the ${c1(Z)} is sending a message too, instead of listening to incoming messages.
|
|
56
|
+
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
57
|
+
|
|
58
|
+
const [receivedMessage] = await Promise.all([
|
|
59
|
+
${u6("getOneMessage",Z)},
|
|
60
|
+
${u6("sendMessage",Z,"message, {strict: true}")},
|
|
61
|
+
]);`)},z5=(Z,Y)=>Error(`${u6("sendMessage",Y)} failed when sending an acknowledgment response to the ${c1(Y)}.`,{cause:Z}),HG=(Z)=>{throw Error(`${u6("sendMessage",Z)} failed: the ${c1(Z)} is not listening to incoming messages.`)},WG=(Z)=>{throw Error(`${u6("sendMessage",Z)} failed: the ${c1(Z)} exited without listening to incoming messages.`)},qG=()=>Error(`\`cancelSignal\` aborted: the ${c1(!0)} disconnected.`),GG=()=>{throw Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},UG=({error:Z,methodName:Y,isSubprocess:Q})=>{if(Z.code==="EPIPE")throw Error(`${u6(Y,Q)} cannot be used: the ${c1(Q)} is disconnecting.`,{cause:Z})},VG=({error:Z,methodName:Y,isSubprocess:Q,message:J})=>{if(fj(Z))throw Error(`${u6(Y,Q)}'s argument type is invalid: the message cannot be serialized: ${String(J)}.`,{cause:Z})},fj=({code:Z,message:Y})=>hj.has(Z)||gj.some((Q)=>Y.includes(Q)),hj,gj,u6=(Z,Y,Q="")=>Z==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${mj(Y)}${Z}(${Q})`,mj=(Z)=>Z?"":"subprocess.",c1=(Z)=>Z?"parent process":"subprocess",M8=(Z)=>{if(Z.connected)Z.disconnect()};var D8=_(()=>{hj=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),gj=["could not be cloned","circular structure","call stack size exceeded"]});var e6=()=>{let Z={},Y=new Promise((Q,J)=>{Object.assign(Z,{resolve:Q,reject:J})});return Object.assign(Y,Z)};var W5=(Z,Y="stdin")=>{let{options:J,fileDescriptors:X}=Z1.get(Z),K=BG(X,Y,!0),z=Z.stdio[K];if(z===null)throw TypeError($G(K,Y,J,!0));return z},_8=(Z,Y="stdout")=>{let{options:J,fileDescriptors:X}=Z1.get(Z),K=BG(X,Y,!1),z=K==="all"?Z.all:Z.stdio[K];if(z===null||z===void 0)throw TypeError($G(K,Y,J,!1));return z},Z1,BG=(Z,Y,Q)=>{let J=uj(Y,Q);return pj(J,Y,Q,Z),J},uj=(Z,Y)=>{let Q=L9(Z);if(Q!==void 0)return Q;let{validOptions:J,defaultValue:X}=Y?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw TypeError(`"${SZ(Y)}" must not be "${Z}".
|
|
62
|
+
It must be ${J} or "fd3", "fd4" (and so on).
|
|
63
|
+
It is optional and defaults to "${X}".`)},pj=(Z,Y,Q,J)=>{let X=J[FG(Z)];if(X===void 0)throw TypeError(`"${SZ(Q)}" must not be ${Y}. That file descriptor does not exist.
|
|
64
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);if(X.direction==="input"&&!Q)throw TypeError(`"${SZ(Q)}" must not be ${Y}. It must be a readable stream, not writable.`);if(X.direction!=="input"&&Q)throw TypeError(`"${SZ(Q)}" must not be ${Y}. It must be a writable stream, not readable.`)},$G=(Z,Y,Q,J)=>{if(Z==="all"&&!Q.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:X,optionValue:K}=dj(Z,Q);return`The "${X}: ${H5(K)}" option is incompatible with using "${SZ(J)}: ${H5(Y)}".
|
|
65
|
+
Please set this option with "pipe" instead.`},dj=(Z,{stdin:Y,stdout:Q,stderr:J,stdio:X})=>{let K=FG(Z);if(K===0&&Y!==void 0)return{optionName:"stdin",optionValue:Y};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:X[K]}},FG=(Z)=>Z==="all"?1:Z,SZ=(Z)=>Z?"to":"from",H5=(Z)=>{if(typeof Z==="string")return`'${Z}'`;return typeof Z==="number"?`${Z}`:"Stream"};var l1=_(()=>{N1();Z1=new WeakMap});import{addAbortListener as cj}from"node:events";var j4=(Z,Y,Q)=>{let J=Z.getMaxListeners();if(J===0||J===Number.POSITIVE_INFINITY)return;Z.setMaxListeners(J+Y),cj(Q,()=>{Z.setMaxListeners(Z.getMaxListeners()-Y)})};var q5=()=>{};var G5=(Z,Y)=>{if(Y)n9(Z)},n9=(Z)=>{Z.refCounted()},U5=(Z,Y)=>{if(Y)o9(Z)},o9=(Z)=>{Z.unrefCounted()},OG=(Z,Y)=>{if(Y)o9(Z),o9(Z)},RG=(Z,Y)=>{if(Y)n9(Z),n9(Z)};import{once as lj}from"node:events";import{scheduler as ij}from"node:timers/promises";var MG=async({anyProcess:Z,channel:Y,isSubprocess:Q,ipcEmitter:J},X)=>{if(jG(X)||TG(X))return;if(!V5.has(Z))V5.set(Z,[]);let K=V5.get(Z);if(K.push(X),K.length>1)return;while(K.length>0){await wG(Z,J,X),await ij.yield();let z=await NG({wrappedMessage:K[0],anyProcess:Z,channel:Y,isSubprocess:Q,ipcEmitter:J});K.shift(),J.emit("message",z),J.emit("message:done")}},DG=async({anyProcess:Z,channel:Y,isSubprocess:Q,ipcEmitter:J,boundOnMessage:X})=>{a9();let K=V5.get(Z);while(K?.length>0)await lj(J,"message:done");Z.removeListener("message",X),RG(Y,Q),J.connected=!1,J.emit("disconnect")},V5;var _G=_(()=>{$5();B5();F5();V5=new WeakMap});import{EventEmitter as nj}from"node:events";var i1=(Z,Y,Q)=>{if(O5.has(Z))return O5.get(Z);let J=new nj;return J.connected=!0,O5.set(Z,J),oj({ipcEmitter:J,anyProcess:Z,channel:Y,isSubprocess:Q}),J},O5,oj=({ipcEmitter:Z,anyProcess:Y,channel:Q,isSubprocess:J})=>{let X=MG.bind(void 0,{anyProcess:Y,channel:Q,isSubprocess:J,ipcEmitter:Z});Y.on("message",X),Y.once("disconnect",DG.bind(void 0,{anyProcess:Y,channel:Q,isSubprocess:J,ipcEmitter:Z,boundOnMessage:X})),OG(Q,J)},R5=(Z)=>{let Y=O5.get(Z);return Y===void 0?Z.channel!==null:Y.connected};var kZ=_(()=>{_G();O5=new WeakMap});import{once as aj}from"node:events";var LG=({anyProcess:Z,channel:Y,isSubprocess:Q,message:J,strict:X})=>{if(!X)return J;let K=i1(Z,Y,Q),z=_5(Z,K);return{id:sj++,type:D5,message:J,hasListeners:z}},sj=0n,IG=(Z,Y)=>{if(Y?.type!==D5||Y.hasListeners)return;for(let{id:Q}of Z)if(Q!==void 0)M5[Q].resolve({isDeadlock:!0,hasListeners:!1})},NG=async({wrappedMessage:Z,anyProcess:Y,channel:Q,isSubprocess:J,ipcEmitter:X})=>{if(Z?.type!==D5||!Y.connected)return Z;let{id:K,message:z}=Z,H={id:K,type:CG,message:_5(Y,X)};try{await N5({anyProcess:Y,channel:Q,isSubprocess:J,ipc:!0},H)}catch(W){X.emit("strict:error",W)}return z},jG=(Z)=>{if(Z?.type!==CG)return!1;let{id:Y,message:Q}=Z;return M5[Y]?.resolve({isDeadlock:!1,hasListeners:Q}),!0},AG=async(Z,Y,Q)=>{if(Z?.type!==D5)return;let J=e6();M5[Z.id]=J;let X=new AbortController;try{let{isDeadlock:K,hasListeners:z}=await Promise.race([J,rj(Y,Q,X)]);if(K)zG(Q);if(!z)HG(Q)}finally{X.abort(),delete M5[Z.id]}},M5,rj=async(Z,Y,{signal:Q})=>{j4(Z,1,Q),await aj(Z,"disconnect",{signal:Q}),WG(Y)},D5="execa:ipc:request",CG="execa:ipc:response";var B5=_(()=>{q5();j5();D8();kZ();$5();M5={}});var EG=(Z,Y,Q)=>{if(!PZ.has(Z))PZ.set(Z,new Set);let J=PZ.get(Z),X=e6(),K=Q?Y.id:void 0,z={onMessageSent:X,id:K};return J.add(z),{outgoingMessages:J,outgoingMessage:z}},xG=({outgoingMessages:Z,outgoingMessage:Y})=>{Z.delete(Y),Y.onMessageSent.resolve()},wG=async(Z,Y,Q)=>{while(!_5(Z,Y)&&PZ.get(Z)?.size>0){let J=[...PZ.get(Z)];IG(J,Q),await Promise.all(J.map(({onMessageSent:X})=>X))}},PZ,_5=(Z,Y)=>Y.listenerCount("message")>tj(Z),tj=(Z)=>Z1.has(Z)&&!_1(Z1.get(Z).options.buffer,"ipc")?1:0;var $5=_(()=>{N1();l1();B5();PZ=new WeakMap});import{promisify as ej}from"node:util";var N5=({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J},X,{strict:K=!1}={})=>{return R8({methodName:"sendMessage",isSubprocess:Q,ipc:J,isConnected:Z.connected}),Zw({anyProcess:Z,channel:Y,methodName:"sendMessage",isSubprocess:Q,message:X,strict:K})},Zw=async({anyProcess:Z,channel:Y,methodName:Q,isSubprocess:J,message:X,strict:K})=>{let z=LG({anyProcess:Z,channel:Y,isSubprocess:J,message:X,strict:K}),H=EG(Z,z,K);try{await r9({anyProcess:Z,methodName:Q,isSubprocess:J,wrappedMessage:z,message:X})}catch(W){throw M8(Z),W}finally{xG(H)}},r9=async({anyProcess:Z,methodName:Y,isSubprocess:Q,wrappedMessage:J,message:X})=>{let K=Yw(Z);try{await Promise.all([AG(J,Z,Q),K(J)])}catch(z){throw UG({error:z,methodName:Y,isSubprocess:Q}),VG({error:z,methodName:Y,isSubprocess:Q,message:X}),z}},Yw=(Z)=>{if(s9.has(Z))return s9.get(Z);let Y=ej(Z.send.bind(Z));return s9.set(Z,Y),Y},s9;var j5=_(()=>{D8();$5();B5();s9=new WeakMap});import{scheduler as Qw}from"node:timers/promises";var kG=(Z,Y)=>{return i9("cancelSignal",!1,Z.connected),r9({anyProcess:Z,methodName:"cancelSignal",isSubprocess:!1,wrappedMessage:{type:vG,message:Y},message:Y})},PG=async({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J})=>{return await Jw({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J}),t9.signal},Jw=async({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J})=>{if(SG)return;if(SG=!0,!J){GG();return}if(Y===null){a9();return}i1(Z,Y,Q),await Qw.yield()},SG=!1,TG=(Z)=>{if(Z?.type!==vG)return!1;return t9.abort(Z.message),!0},vG="execa:ipc:cancel",a9=()=>{t9.abort(qG())},t9;var F5=_(()=>{j5();kZ();D8();t9=new AbortController});var yG=({gracefulCancel:Z,cancelSignal:Y,ipc:Q,serialization:J})=>{if(!Z)return;if(Y===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.")},bG=({subprocess:Z,cancelSignal:Y,gracefulCancel:Q,forceKillAfterDelay:J,context:X,controller:K})=>Q?[Xw({subprocess:Z,cancelSignal:Y,forceKillAfterDelay:J,context:X,controller:K})]:[],Xw=async({subprocess:Z,cancelSignal:Y,forceKillAfterDelay:Q,context:J,controller:{signal:X}})=>{await K5(Y,X);let K=Kw(Y);throw await kG(Z,K),d9({kill:Z.kill,forceKillAfterDelay:Q,context:J,controllerSignal:X}),J.terminationReason??="gracefulCancel",Y.reason},Kw=({reason:Z})=>{if(!(Z instanceof DOMException))return Z;let Y=Error(Z.message);return Object.defineProperty(Y,"stack",{value:Z.stack,enumerable:!1,configurable:!0,writable:!0}),Y};var e9=_(()=>{c9();F5();X5()});import{setTimeout as zw}from"node:timers/promises";var fG=({timeout:Z})=>{if(Z!==void 0&&(!Number.isFinite(Z)||Z<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${Z}\` (${typeof Z})`)},hG=(Z,Y,Q,J)=>Y===0||Y===void 0?[]:[Hw(Z,Y,Q,J)],Hw=async(Z,Y,Q,{signal:J})=>{throw await zw(Y,void 0,{signal:J}),Q.terminationReason??="timeout",Z.kill(),new t6};var Z3=_(()=>{d1()});import{execPath as Ww,execArgv as qw}from"node:process";import gG from"node:path";var mG=({options:Z})=>{if(Z.node===!1)throw TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...Z,node:!0}}},uG=(Z,Y,{node:Q=!1,nodePath:J=Ww,nodeOptions:X=qw.filter((W)=>!W.startsWith("--inspect")),cwd:K,execPath:z,...H})=>{if(z!==void 0)throw TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let W=G8(J,'The "nodePath" option'),q=gG.resolve(K,W),G={...H,nodePath:q,node:Q,cwd:K};if(!Q)return[Z,Y,G];if(gG.basename(Z,".exe")==="node")throw TypeError('When the "node" option is true, the first argument does not need to be "node".');return[q,[...X,Z,...Y],{ipc:!0,...G,shell:!1}]};var Y3=_(()=>{U8()});import{serialize as Gw}from"node:v8";var pG=({ipcInput:Z,ipc:Y,serialization:Q})=>{if(Z===void 0)return;if(!Y)throw Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");Bw[Q](Z)},Uw=(Z)=>{try{Gw(Z)}catch(Y){throw Error("The `ipcInput` option is not serializable with a structured clone.",{cause:Y})}},Vw=(Z)=>{try{JSON.stringify(Z)}catch(Y){throw Error("The `ipcInput` option is not serializable with JSON.",{cause:Y})}},Bw,dG=async(Z,Y)=>{if(Y===void 0)return;await Z.sendMessage(Y)};var Q3=_(()=>{Bw={advanced:Uw,json:Vw}});var lG=({encoding:Z})=>{if(J3.has(Z))return;let Y=Fw(Z);if(Y!==void 0)throw TypeError(`Invalid option \`encoding: ${w5(Z)}\`.
|
|
66
|
+
Please rename it to ${w5(Y)}.`);let Q=[...J3].map((J)=>w5(J)).join(", ");throw TypeError(`Invalid option \`encoding: ${w5(Z)}\`.
|
|
67
|
+
Please rename it to one of: ${Q}.`)},$w,j6,J3,Fw=(Z)=>{if(Z===null)return"buffer";if(typeof Z!=="string")return;let Y=Z.toLowerCase();if(Y in cG)return cG[Y];if(J3.has(Y))return Y},cG,w5=(Z)=>typeof Z==="string"?`"${Z}"`:String(Z);var w4=_(()=>{$w=new Set(["utf8","utf16le"]),j6=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),J3=new Set([...$w,...j6]),cG={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"}});import{statSync as Ow}from"node:fs";import Rw from"node:path";import Mw from"node:process";var iG=(Z=nG())=>{let Y=G8(Z,'The "cwd" option');return Rw.resolve(Y)},nG=()=>{try{return Mw.cwd()}catch(Z){throw Z.message=`The current directory does not exist.
|
|
68
|
+
${Z.message}`,Z}},oG=(Z,Y)=>{if(Y===nG())return Z;let Q;try{Q=Ow(Y)}catch(J){return`The "cwd" option is invalid: ${Y}.
|
|
69
|
+
${J.message}
|
|
70
|
+
${Z}`}if(!Q.isDirectory())return`The "cwd" option is not a directory: ${Y}.
|
|
71
|
+
${Z}`;return Z};var X3=_(()=>{U8()});import Dw from"node:path";import aG from"node:process";var sG,T5=(Z,Y,Q)=>{Q.cwd=iG(Q.cwd);let[J,X,K]=uG(Z,Y,Q),{command:z,args:H,options:W}=sG.default._parse(J,X,K),q=jW(W),G=_w(q);if(fG(G),lG(G),pG(G),JG(G),yG(G),G.shell=_9(G.shell),G.env=Nw(G),G.killSignal=tq(G.killSignal),G.forceKillAfterDelay=YG(G.forceKillAfterDelay),G.lines=G.lines.map((U,B)=>U&&!j6.has(G.encoding)&&G.buffer[B]),aG.platform==="win32"&&Dw.basename(z,".exe")==="cmd")H.unshift("/q");return{file:z,commandArguments:H,options:G}},_w=({extendEnv:Z=!0,preferLocal:Y=!1,cwd:Q,localDir:J=Q,encoding:X="utf8",reject:K=!0,cleanup:z=!0,all:H=!1,windowsHide:W=!0,killSignal:q="SIGTERM",forceKillAfterDelay:G=!0,gracefulCancel:U=!1,ipcInput:B,ipc:F=B!==void 0||U,serialization:$="advanced",...O})=>({...O,extendEnv:Z,preferLocal:Y,cwd:Q,localDirectory:J,encoding:X,reject:K,cleanup:z,all:H,windowsHide:W,killSignal:q,forceKillAfterDelay:G,gracefulCancel:U,ipcInput:B,ipc:F,serialization:$}),Nw=({env:Z,extendEnv:Y,preferLocal:Q,node:J,localDirectory:X,nodePath:K})=>{let z=Y?{...aG.env,...Z}:Z;if(Q||J)return hq({env:z,cwd:X,execPath:K,preferLocal:Q,addExecPath:J});return z};var K3=_(()=>{gq();X5();xZ();l9();e9();Z3();Y3();Q3();w4();X3();U8();N1();sG=O_(vq(),1)});var L5=(Z,Y,Q)=>Q.shell&&Y.length>0?[[Z,...Y].join(" "),[],Q]:[Z,Y,Q];function N8(Z){if(typeof Z==="string")return jw(Z);if(!(ArrayBuffer.isView(Z)&&Z.BYTES_PER_ELEMENT===1))throw Error("Input must be a string or a Uint8Array");return ww(Z)}var jw=(Z)=>Z.at(-1)===rG?Z.slice(0,Z.at(-2)===tG?-2:-1):Z,ww=(Z)=>Z.at(-1)===Tw?Z.subarray(0,Z.at(-2)===Lw?-2:-1):Z,rG=`
|
|
72
|
+
`,Tw,tG="\r",Lw;var z3=_(()=>{Tw=rG.codePointAt(0),Lw=tG.codePointAt(0)});function p6(Z,{checkOpen:Y=!0}={}){return Z!==null&&typeof Z==="object"&&(Z.writable||Z.readable||!Y||Z.writable===void 0&&Z.readable===void 0)&&typeof Z.pipe==="function"}function H3(Z,{checkOpen:Y=!0}={}){return p6(Z,{checkOpen:Y})&&(Z.writable||!Y)&&typeof Z.write==="function"&&typeof Z.end==="function"&&typeof Z.writable==="boolean"&&typeof Z.writableObjectMode==="boolean"&&typeof Z.destroy==="function"&&typeof Z.destroyed==="boolean"}function T4(Z,{checkOpen:Y=!0}={}){return p6(Z,{checkOpen:Y})&&(Z.readable||!Y)&&typeof Z.read==="function"&&typeof Z.readable==="boolean"&&typeof Z.readableObjectMode==="boolean"&&typeof Z.destroy==="function"&&typeof Z.destroyed==="boolean"}function W3(Z,Y){return H3(Z,Y)&&T4(Z,Y)}class eG{#Y;#Q;#Z=!1;#J=void 0;constructor(Z,Y){this.#Y=Z,this.#Q=Y}next(){let Z=()=>this.#X();return this.#J=this.#J?this.#J.then(Z,Z):Z(),this.#J}return(Z){let Y=()=>this.#K(Z);return this.#J?this.#J.then(Y,Y):Y()}async#X(){if(this.#Z)return{done:!0,value:void 0};let Z;try{Z=await this.#Y.read()}catch(Y){throw this.#J=void 0,this.#Z=!0,this.#Y.releaseLock(),Y}return Z.done&&(this.#J=void 0,this.#Z=!0,this.#Y.releaseLock()),Z}async#K(Z){if(this.#Z)return{done:!0,value:Z};if(this.#Z=!0,!this.#Q){let Y=this.#Y.cancel(Z);return this.#Y.releaseLock(),await Y,{done:!0,value:Z}}return this.#Y.releaseLock(),{done:!0,value:Z}}}function ZU(){return this[q3].next()}function YU(Z){return this[q3].return(Z)}function G3({preventCancel:Z=!1}={}){let Y=this.getReader(),Q=new eG(Y,Z),J=Object.create(Aw);return J[q3]=Q,J}var Iw,q3,Aw;var QU=_(()=>{Iw=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);q3=Symbol();Object.defineProperty(ZU,"name",{value:"next"});Object.defineProperty(YU,"name",{value:"return"});Aw=Object.create(Iw,{next:{enumerable:!0,configurable:!0,writable:!0,value:ZU},return:{enumerable:!0,configurable:!0,writable:!0,value:YU}})});var JU=()=>{};var XU=_(()=>{QU();JU()});var KU=(Z)=>{if(T4(Z,{checkOpen:!1})&&vZ.on!==void 0)return Ew(Z);if(typeof Z?.[Symbol.asyncIterator]==="function")return Z;if(Cw.call(Z)==="[object ReadableStream]")return G3.call(Z);throw TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},Cw,Ew=async function*(Z){let Y=new AbortController,Q={};xw(Z,Y,Q);try{for await(let[J]of vZ.on(Z,"data",{signal:Y.signal}))yield J}catch(J){if(Q.error!==void 0)throw Q.error;else if(!Y.signal.aborted)throw J}finally{Z.destroy()}},xw=async(Z,Y,Q)=>{try{await vZ.finished(Z,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(J){Q.error=J}finally{Y.abort()}},vZ;var U3=_(()=>{XU();({toString:Cw}=Object.prototype),vZ={}});var j8=async(Z,{init:Y,convertChunk:Q,getSize:J,truncateChunk:X,addChunk:K,getFinalChunk:z,finalize:H},{maxBuffer:W=Number.POSITIVE_INFINITY}={})=>{let q=KU(Z),G=Y();G.length=0;try{for await(let U of q){let B=kw(U),F=Q[B](U,G);WU({convertedChunk:F,state:G,getSize:J,truncateChunk:X,addChunk:K,maxBuffer:W})}return Sw({state:G,convertChunk:Q,getSize:J,truncateChunk:X,addChunk:K,getFinalChunk:z,maxBuffer:W}),H(G)}catch(U){let B=typeof U==="object"&&U!==null?U:Error(U);throw B.bufferedData=H(G),B}},Sw=({state:Z,getSize:Y,truncateChunk:Q,addChunk:J,getFinalChunk:X,maxBuffer:K})=>{let z=X(Z);if(z!==void 0)WU({convertedChunk:z,state:Z,getSize:Y,truncateChunk:Q,addChunk:J,maxBuffer:K})},WU=({convertedChunk:Z,state:Y,getSize:Q,truncateChunk:J,addChunk:X,maxBuffer:K})=>{let z=Q(Z),H=Y.length+z;if(H<=K){zU(Z,Y,X,H);return}let W=J(Z,K-Y.length);if(W!==void 0)zU(W,Y,X,K);throw new j1},zU=(Z,Y,Q,J)=>{Y.contents=Q(Z,Y,J),Y.length=J},kw=(Z)=>{let Y=typeof Z;if(Y==="string")return"string";if(Y!=="object"||Z===null)return"others";if(globalThis.Buffer?.isBuffer(Z))return"buffer";let Q=HU.call(Z);if(Q==="[object ArrayBuffer]")return"arrayBuffer";if(Q==="[object DataView]")return"dataView";if(Number.isInteger(Z.byteLength)&&Number.isInteger(Z.byteOffset)&&HU.call(Z.buffer)==="[object ArrayBuffer]")return"typedArray";return"others"},HU,j1;var yZ=_(()=>{U3();({toString:HU}=Object.prototype);j1=class j1 extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}}});var w1=(Z)=>Z,bZ=()=>{return},I5=({contents:Z})=>Z,A5=(Z)=>{throw Error(`Streams in object mode are not supported: ${String(Z)}`)},C5=(Z)=>Z.length;async function E5(Z,Y){return j8(Z,bw,Y)}var Pw=()=>({contents:[]}),vw=()=>1,yw=(Z,{contents:Y})=>{return Y.push(Z),Y},bw;var qU=_(()=>{yZ();bw={init:Pw,convertChunk:{string:w1,buffer:w1,arrayBuffer:w1,dataView:w1,typedArray:w1,others:w1},getSize:vw,truncateChunk:bZ,addChunk:yw,getFinalChunk:bZ,finalize:I5}});async function x5(Z,Y){return j8(Z,lw,Y)}var fw=()=>({contents:new ArrayBuffer(0)}),hw=(Z)=>gw.encode(Z),gw,GU=(Z)=>new Uint8Array(Z),UU=(Z)=>new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),mw=(Z,Y)=>Z.slice(0,Y),uw=(Z,{contents:Y,length:Q},J)=>{let X=$U()?dw(Y,J):pw(Y,J);return new Uint8Array(X).set(Z,Q),X},pw=(Z,Y)=>{if(Y<=Z.byteLength)return Z;let Q=new ArrayBuffer(BU(Y));return new Uint8Array(Q).set(new Uint8Array(Z),0),Q},dw=(Z,Y)=>{if(Y<=Z.maxByteLength)return Z.resize(Y),Z;let Q=new ArrayBuffer(Y,{maxByteLength:BU(Y)});return new Uint8Array(Q).set(new Uint8Array(Z),0),Q},BU=(Z)=>VU**Math.ceil(Math.log(Z)/Math.log(VU)),VU=2,cw=({contents:Z,length:Y})=>$U()?Z:Z.slice(0,Y),$U=()=>("resize"in ArrayBuffer.prototype),lw;var FU=_(()=>{yZ();gw=new TextEncoder,lw={init:fw,convertChunk:{string:hw,buffer:GU,arrayBuffer:GU,dataView:UU,typedArray:UU,others:A5},getSize:C5,truncateChunk:mw,addChunk:uw,getFinalChunk:bZ,finalize:cw}});async function k5(Z,Y){return j8(Z,sw,Y)}var iw=()=>({contents:"",textDecoder:new TextDecoder}),S5=(Z,{textDecoder:Y})=>Y.decode(Z,{stream:!0}),nw=(Z,{contents:Y})=>Y+Z,ow=(Z,Y)=>Z.slice(0,Y),aw=({textDecoder:Z})=>{let Y=Z.decode();return Y===""?void 0:Y},sw;var OU=_(()=>{yZ();sw={init:iw,convertChunk:{string:w1,buffer:S5,arrayBuffer:S5,dataView:S5,typedArray:S5,others:A5},getSize:C5,truncateChunk:ow,addChunk:nw,getFinalChunk:aw,finalize:I5}});var RU=_(()=>{qU();FU();OU();yZ()});import{on as rw}from"node:events";import{finished as tw}from"node:stream/promises";var P5=_(()=>{U3();RU();Object.assign(vZ,{on:rw,finished:tw})});var MU=({error:Z,stream:Y,readableObjectMode:Q,lines:J,encoding:X,fdNumber:K})=>{if(!(Z instanceof j1))throw Z;if(K==="all")return Z;let z=ew(Q,J,X);throw Z.maxBufferInfo={fdNumber:K,unit:z},Y.destroy(),Z},ew=(Z,Y,Q)=>{if(Z)return"objects";if(Y)return"lines";if(Q==="buffer")return"bytes";return"characters"},DU=(Z,Y,Q)=>{if(Y.length!==Q)return;let J=new j1;throw J.maxBufferInfo={fdNumber:"ipc"},J},_U=(Z,Y)=>{let{streamName:Q,threshold:J,unit:X}=ZT(Z,Y);return`Command's ${Q} was larger than ${J} ${X}`},ZT=(Z,Y)=>{if(Z?.maxBufferInfo===void 0)return{streamName:"output",threshold:Y[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:Q,unit:J}}=Z;delete Z.maxBufferInfo;let X=_1(Y,Q);if(Q==="ipc")return{streamName:"IPC output",threshold:X,unit:"messages"};return{streamName:uY(Q),threshold:X,unit:J}},NU=(Z,Y,Q)=>Z?.code==="ENOBUFS"&&Y!==null&&Y.some((J)=>J!==null&&J.length>v5(Q)),jU=(Z,Y,Q)=>{if(!Y)return Z;let J=v5(Q);return Z.length>J?Z.slice(0,J):Z},v5=([,Z])=>Z;var L4=_(()=>{P5();D1();N1()});import{inspect as YT}from"node:util";var TU=({stdio:Z,all:Y,ipcOutput:Q,originalError:J,signal:X,signalDescription:K,exitCode:z,escapedCommand:H,timedOut:W,isCanceled:q,isGracefullyCanceled:G,isMaxBuffer:U,isForcefullyTerminated:B,forceKillAfterDelay:F,killSignal:$,maxBuffer:O,timeout:D,cwd:j})=>{let M=J?.code,T=QT({originalError:J,timedOut:W,timeout:D,isMaxBuffer:U,maxBuffer:O,errorCode:M,signal:X,signalDescription:K,exitCode:z,isCanceled:q,isGracefullyCanceled:G,isForcefullyTerminated:B,forceKillAfterDelay:F,killSignal:$}),N=XT(J,j),L=N===void 0?"":`
|
|
73
|
+
${N}`,x=`${T}: ${H}${L}`,S=Y===void 0?[Z[2],Z[1]]:[Y],g=[x,...S,...Z.slice(3),Q.map((h)=>KT(h)).join(`
|
|
74
|
+
`)].map((h)=>AZ(N8(zT(h)))).filter(Boolean).join(`
|
|
75
|
+
|
|
76
|
+
`);return{originalMessage:N,shortMessage:x,message:g}},QT=({originalError:Z,timedOut:Y,timeout:Q,isMaxBuffer:J,maxBuffer:X,errorCode:K,signal:z,signalDescription:H,exitCode:W,isCanceled:q,isGracefullyCanceled:G,isForcefullyTerminated:U,forceKillAfterDelay:B,killSignal:F})=>{let $=JT(U,B);if(Y)return`Command timed out after ${Q} milliseconds${$}`;if(G){if(z===void 0)return`Command was gracefully canceled with exit code ${W}`;return U?`Command was gracefully canceled${$}`:`Command was gracefully canceled with ${z} (${H})`}if(q)return`Command was canceled${$}`;if(J)return`${_U(Z,X)}${$}`;if(K!==void 0)return`Command failed with ${K}${$}`;if(U)return`Command was killed with ${F} (${J5(F)})${$}`;if(z!==void 0)return`Command was killed with ${z} (${H})`;if(W!==void 0)return`Command failed with exit code ${W}`;return"Command failed"},JT=(Z,Y)=>Z?` and was forcefully terminated after ${Y} milliseconds`:"",XT=(Z,Y)=>{if(Z instanceof t6)return;let Q=pq(Z)?Z.originalMessage:String(Z?.message??Z),J=AZ(oG(Q,Y));return J===""?void 0:J},KT=(Z)=>typeof Z==="string"?Z:YT(Z),zT=(Z)=>Array.isArray(Z)?Z.map((Y)=>N8(wU(Y))).filter(Boolean).join(`
|
|
77
|
+
`):wU(Z),wU=(Z)=>{if(typeof Z==="string")return Z;if(y0(Z))return gY(Z);return""};var LU=_(()=>{z3();N6();X3();cY();L4();xZ();d1()});var y5=({command:Z,escapedCommand:Y,stdio:Q,all:J,ipcOutput:X,options:{cwd:K},startTime:z})=>IU({command:Z,escapedCommand:Y,cwd:K,durationMs:E9(z),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:X,pipedFrom:[]}),w8=({error:Z,command:Y,escapedCommand:Q,fileDescriptors:J,options:X,startTime:K,isSync:z})=>fZ({error:Z,command:Y,escapedCommand:Q,startTime:K,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:J.length}),ipcOutput:[],options:X,isSync:z}),fZ=({error:Z,command:Y,escapedCommand:Q,startTime:J,timedOut:X,isCanceled:K,isGracefullyCanceled:z,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:q,signal:G,stdio:U,all:B,ipcOutput:F,options:{timeoutDuration:$,timeout:O=$,forceKillAfterDelay:D,killSignal:j,cwd:M,maxBuffer:T},isSync:N})=>{let{exitCode:L,signal:x,signalDescription:S}=WT(q,G),{originalMessage:g,shortMessage:h,message:f}=TU({stdio:U,all:B,ipcOutput:F,originalError:Z,signal:x,signalDescription:S,exitCode:L,escapedCommand:Q,timedOut:X,isCanceled:K,isGracefullyCanceled:z,isMaxBuffer:H,isForcefullyTerminated:W,forceKillAfterDelay:D,killSignal:j,maxBuffer:T,timeout:O,cwd:M}),v=mq(Z,f,N);return Object.assign(v,HT({error:v,command:Y,escapedCommand:Q,startTime:J,timedOut:X,isCanceled:K,isGracefullyCanceled:z,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:L,signal:x,signalDescription:S,stdio:U,all:B,ipcOutput:F,cwd:M,originalMessage:g,shortMessage:h})),v},HT=({error:Z,command:Y,escapedCommand:Q,startTime:J,timedOut:X,isCanceled:K,isGracefullyCanceled:z,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:q,signal:G,signalDescription:U,stdio:B,all:F,ipcOutput:$,cwd:O,originalMessage:D,shortMessage:j})=>IU({shortMessage:j,originalMessage:D,command:Y,escapedCommand:Q,cwd:O,durationMs:E9(J),failed:!0,timedOut:X,isCanceled:K,isGracefullyCanceled:z,isTerminated:G!==void 0,isMaxBuffer:H,isForcefullyTerminated:W,exitCode:q,signal:G,signalDescription:U,code:Z.cause?.code,stdout:B[1],stderr:B[2],all:F,stdio:B,ipcOutput:$,pipedFrom:[]}),IU=(Z)=>Object.fromEntries(Object.entries(Z).filter(([,Y])=>Y!==void 0)),WT=(Z,Y)=>{let Q=Z===null?void 0:Z,J=Y===null?void 0:Y,X=J===void 0?void 0:J5(Y);return{exitCode:Q,signal:J,signalDescription:X}};var hZ=_(()=>{xZ();sY();d1();LU()});function qT(Z){return{days:Math.trunc(Z/86400000),hours:Math.trunc(Z/3600000%24),minutes:Math.trunc(Z/60000%60),seconds:Math.trunc(Z/1000%60),milliseconds:Math.trunc(Z%1000),microseconds:Math.trunc(AU(Z*1000)%1000),nanoseconds:Math.trunc(AU(Z*1e6)%1000)}}function GT(Z){return{days:Z/86400000n,hours:Z/3600000n%24n,minutes:Z/60000n%60n,seconds:Z/1000n%60n,milliseconds:Z%1000n,microseconds:0n,nanoseconds:0n}}function V3(Z){switch(typeof Z){case"number":{if(Number.isFinite(Z))return qT(Z);break}case"bigint":return GT(Z)}throw TypeError("Expected a finite number or bigint")}var AU=(Z)=>Number.isFinite(Z)?Z:0;function B3(Z,Y){let Q=typeof Z==="bigint";if(!Q&&!Number.isFinite(Z))throw TypeError("Expected a finite number or bigint");Y={...Y};let J=Z<0?"-":"";if(Z=Z<0?-Z:Z,Y.colonNotation)Y.compact=!1,Y.formatSubMilliseconds=!1,Y.separateMilliseconds=!1,Y.verbose=!1;if(Y.compact)Y.unitCount=1,Y.secondsDecimalDigits=0,Y.millisecondsDecimalDigits=0;let X=[],K=(G,U)=>{let B=Math.floor(G*10**U+BT);return(Math.round(B)/10**U).toFixed(U)},z=(G,U,B,F)=>{if((X.length===0||!Y.colonNotation)&&UT(G)&&!(Y.colonNotation&&B==="m"))return;if(F??=String(G),Y.colonNotation){let $=F.includes(".")?F.split(".")[0].length:F.length,O=X.length>0?2:1;F="0".repeat(Math.max(0,O-$))+F}else F+=Y.verbose?" "+VT(U,G):B;X.push(F)},H=V3(Z),W=BigInt(H.days);if(Y.hideYearAndDays)z(BigInt(W)*24n+BigInt(H.hours),"hour","h");else{if(Y.hideYear)z(W,"day","d");else z(W/365n,"year","y"),z(W%365n,"day","d");z(Number(H.hours),"hour","h")}if(z(Number(H.minutes),"minute","m"),!Y.hideSeconds)if(Y.separateMilliseconds||Y.formatSubMilliseconds||!Y.colonNotation&&Z<1000&&!Y.subSecondsAsDecimals){let G=Number(H.seconds),U=Number(H.milliseconds),B=Number(H.microseconds),F=Number(H.nanoseconds);if(z(G,"second","s"),Y.formatSubMilliseconds)z(U,"millisecond","ms"),z(B,"microsecond","µs"),z(F,"nanosecond","ns");else{let $=U+B/1000+F/1e6,O=typeof Y.millisecondsDecimalDigits==="number"?Y.millisecondsDecimalDigits:0,D=$>=1?Math.round($):Math.ceil($),j=O?$.toFixed(O):D;z(Number.parseFloat(j),"millisecond","ms",j)}}else{let G=(Q?Number(Z%$T):Z)/1000%60,U=typeof Y.secondsDecimalDigits==="number"?Y.secondsDecimalDigits:1,B=K(G,U),F=Y.keepDecimalsOnWholeSeconds?B:B.replace(/\.0+$/,"");z(Number.parseFloat(F),"second","s",F)}if(X.length===0)return J+"0"+(Y.verbose?" milliseconds":"ms");let q=Y.colonNotation?":":" ";if(typeof Y.unitCount==="number")X=X.slice(0,Math.max(Y.unitCount,1));return J+X.join(q)}var UT=(Z)=>Z===0||Z===0n,VT=(Z,Y)=>Y===1||Y===1n?Z:`${Z}s`,BT=0.0000001,$T;var CU=_(()=>{$T=24n*60n*60n*1000n});var EU=(Z,Y)=>{if(Z.failed)r6({type:"error",verboseMessage:Z.shortMessage,verboseInfo:Y,result:Z})};var xU=_(()=>{$8()});var SU=(Z,Y)=>{if(!V8(Y))return;EU(Z,Y),FT(Z,Y)},FT=(Z,Y)=>{let Q=`(done in ${B3(Z.durationMs)})`;r6({type:"duration",verboseMessage:Q,verboseInfo:Y,result:Z})};var kU=_(()=>{CU();p1();$8();xU()});var T8=(Z,Y,{reject:Q})=>{if(SU(Z,Y),Z.failed&&Q)throw Z;return Z};var b5=_(()=>{kU()});var yU=(Z,Y)=>{if(I4(Z))return"asyncGenerator";if(hU(Z))return"generator";if(f5(Z))return"fileUrl";if(_T(Z))return"filePath";if(wT(Z))return"webStream";if(p6(Z,{checkOpen:!1}))return"native";if(y0(Z))return"uint8Array";if(TT(Z))return"asyncIterable";if(LT(Z))return"iterable";if(O3(Z))return bU({transform:Z},Y);if(DT(Z))return OT(Z,Y);return"native"},OT=(Z,Y)=>{if(W3(Z.transform,{checkOpen:!1}))return RT(Z,Y);if(O3(Z.transform))return bU(Z,Y);return MT(Z,Y)},RT=(Z,Y)=>{return fU(Z,Y,"Duplex stream"),"duplex"},bU=(Z,Y)=>{return fU(Z,Y,"web TransformStream"),"webTransform"},fU=({final:Z,binary:Y,objectMode:Q},J,X)=>{PU(Z,`${J}.final`,X),PU(Y,`${J}.binary`,X),$3(Q,`${J}.objectMode`)},PU=(Z,Y,Q)=>{if(Z!==void 0)throw TypeError(`The \`${Y}\` option can only be defined when using a generator, not a ${Q}.`)},MT=({transform:Z,final:Y,binary:Q,objectMode:J},X)=>{if(Z!==void 0&&!vU(Z))throw TypeError(`The \`${X}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(W3(Y,{checkOpen:!1}))throw TypeError(`The \`${X}.final\` option must not be a Duplex stream.`);if(O3(Y))throw TypeError(`The \`${X}.final\` option must not be a web TransformStream.`);if(Y!==void 0&&!vU(Y))throw TypeError(`The \`${X}.final\` option must be a generator.`);return $3(Q,`${X}.binary`),$3(J,`${X}.objectMode`),I4(Z)||I4(Y)?"asyncGenerator":"generator"},$3=(Z,Y)=>{if(Z!==void 0&&typeof Z!=="boolean")throw TypeError(`The \`${Y}\` option must use a boolean.`)},vU=(Z)=>I4(Z)||hU(Z),I4=(Z)=>Object.prototype.toString.call(Z)==="[object AsyncGeneratorFunction]",hU=(Z)=>Object.prototype.toString.call(Z)==="[object GeneratorFunction]",DT=(Z)=>C0(Z)&&(Z.transform!==void 0||Z.final!==void 0),f5=(Z)=>Object.prototype.toString.call(Z)==="[object URL]",gU=(Z)=>f5(Z)&&Z.protocol!=="file:",_T=(Z)=>C0(Z)&&Object.keys(Z).length>0&&Object.keys(Z).every((Y)=>NT.has(Y))&&F3(Z.file),NT,F3=(Z)=>typeof Z==="string",mU=(Z,Y)=>Z==="native"&&typeof Y==="string"&&!jT.has(Y),jT,uU=(Z)=>Object.prototype.toString.call(Z)==="[object ReadableStream]",h5=(Z)=>Object.prototype.toString.call(Z)==="[object WritableStream]",wT=(Z)=>uU(Z)||h5(Z),O3=(Z)=>uU(Z?.readable)&&h5(Z?.writable),TT=(Z)=>pU(Z)&&typeof Z[Symbol.asyncIterator]==="function",LT=(Z)=>pU(Z)&&typeof Z[Symbol.iterator]==="function",pU=(Z)=>typeof Z==="object"&&Z!==null,v6,g5,R3,dU,cU,n1;var W6=_(()=>{N6();NT=new Set(["file","append"]),jT=new Set(["ipc","ignore","inherit","overlapped","pipe"]),v6=new Set(["generator","asyncGenerator","duplex","webTransform"]),g5=new Set(["fileUrl","filePath","fileNumber"]),R3=new Set(["fileUrl","filePath"]),dU=new Set([...R3,"webStream","nodeStream"]),cU=new Set(["webTransform","duplex"]),n1={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 M3=(Z,Y,Q,J)=>J==="output"?IT(Z,Y,Q):AT(Z,Y,Q),IT=(Z,Y,Q)=>{let J=Y!==0&&Q[Y-1].value.readableObjectMode;return{writableObjectMode:J,readableObjectMode:Z??J}},AT=(Z,Y,Q)=>{let J=Y===0?Z===!0:Q[Y-1].value.readableObjectMode,X=Y!==Q.length-1&&(Z??J);return{writableObjectMode:J,readableObjectMode:X}},lU=(Z,Y)=>{let Q=Z.findLast(({type:J})=>v6.has(J));if(Q===void 0)return!1;return Y==="input"?Q.value.writableObjectMode:Q.value.readableObjectMode};var D3=_(()=>{W6()});var iU=(Z,Y,Q,J)=>[...Z.filter(({type:X})=>!v6.has(X)),...CT(Z,Y,Q,J)],CT=(Z,Y,Q,{encoding:J})=>{let X=Z.filter(({type:z})=>v6.has(z)),K=Array.from({length:X.length});for(let[z,H]of Object.entries(X))K[z]=ET({stdioItem:H,index:Number(z),newTransforms:K,optionName:Y,direction:Q,encoding:J});return PT(K,Q)},ET=({stdioItem:Z,stdioItem:{type:Y},index:Q,newTransforms:J,optionName:X,direction:K,encoding:z})=>{if(Y==="duplex")return xT({stdioItem:Z,optionName:X});if(Y==="webTransform")return ST({stdioItem:Z,index:Q,newTransforms:J,direction:K});return kT({stdioItem:Z,index:Q,newTransforms:J,direction:K,encoding:z})},xT=({stdioItem:Z,stdioItem:{value:{transform:Y,transform:{writableObjectMode:Q,readableObjectMode:J},objectMode:X=J}},optionName:K})=>{if(X&&!J)throw TypeError(`The \`${K}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!X&&J)throw TypeError(`The \`${K}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...Z,value:{transform:Y,writableObjectMode:Q,readableObjectMode:J}}},ST=({stdioItem:Z,stdioItem:{value:Y},index:Q,newTransforms:J,direction:X})=>{let{transform:K,objectMode:z}=C0(Y)?Y:{transform:Y},{writableObjectMode:H,readableObjectMode:W}=M3(z,Q,J,X);return{...Z,value:{transform:K,writableObjectMode:H,readableObjectMode:W}}},kT=({stdioItem:Z,stdioItem:{value:Y},index:Q,newTransforms:J,direction:X,encoding:K})=>{let{transform:z,final:H,binary:W=!1,preserveNewlines:q=!1,objectMode:G}=C0(Y)?Y:{transform:Y},U=W||j6.has(K),{writableObjectMode:B,readableObjectMode:F}=M3(G,Q,J,X);return{...Z,value:{transform:z,final:H,binary:U,preserveNewlines:q,writableObjectMode:B,readableObjectMode:F}}},PT=(Z,Y)=>Y==="input"?Z.reverse():Z;var nU=_(()=>{w4();W6();D3()});import _3 from"node:process";var oU=(Z,Y,Q)=>{let J=Z.map((X)=>vT(X,Y));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)??fT},vT=({type:Z,value:Y},Q)=>yT[Q]??aU[Z](Y),yT,L8=()=>{return},N3=()=>"input",aU,bT=(Z)=>{if([0,_3.stdin].includes(Z))return"input";if([1,2,_3.stdout,_3.stderr].includes(Z))return"output"},fT="output";var sU=_(()=>{W6();yT=["input","output","output"],aU={generator:L8,asyncGenerator:L8,fileUrl:L8,filePath:L8,iterable:N3,asyncIterable:N3,uint8Array:N3,webStream:(Z)=>h5(Z)?"output":"input",nodeStream(Z){if(!T4(Z,{checkOpen:!1}))return"output";return H3(Z,{checkOpen:!1})?void 0:"input"},webTransform:L8,duplex:L8,native(Z){let Y=bT(Z);if(Y!==void 0)return Y;if(p6(Z,{checkOpen:!1}))return aU.nodeStream(Z)}}});var rU=(Z,Y)=>Y&&!Z.includes("ipc")?[...Z,"ipc"]:Z;var tU=({stdio:Z,ipc:Y,buffer:Q,...J},X,K)=>{let z=hT(Z,J).map((H,W)=>eU(H,W));return K?mT(z,Q,X):rU(z,Y)},hT=(Z,Y)=>{if(Z===void 0)return k6.map((J)=>Y[J]);if(gT(Y))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${k6.map((J)=>`\`${J}\``).join(", ")}`);if(typeof Z==="string")return[Z,Z,Z];if(!Array.isArray(Z))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof Z}\``);let Q=Math.max(Z.length,k6.length);return Array.from({length:Q},(J,X)=>Z[X])},gT=(Z)=>k6.some((Y)=>Z[Y]!==void 0),eU=(Z,Y)=>{if(Array.isArray(Z))return Z.map((Q)=>eU(Q,Y));if(Z===null||Z===void 0)return Y>=k6.length?"ignore":"pipe";return Z},mT=(Z,Y,Q)=>Z.map((J,X)=>!Y[X]&&X!==0&&!B8(Q,X)&&uT(J)?"ignore":J),uT=(Z)=>Z==="pipe"||Array.isArray(Z)&&Z.every((Y)=>Y==="pipe");var ZV=_(()=>{D1();p1()});import{readFileSync as pT}from"node:fs";import dT from"node:tty";var QV=({stdioItem:Z,stdioItem:{type:Y},isStdioArray:Q,fdNumber:J,direction:X,isSync:K})=>{if(!Q||Y!=="native")return Z;return K?cT({stdioItem:Z,fdNumber:J,direction:X}):nT({stdioItem:Z,fdNumber:J})},cT=({stdioItem:Z,stdioItem:{value:Y,optionName:Q},fdNumber:J,direction:X})=>{let K=lT({value:Y,optionName:Q,fdNumber:J,direction:X});if(K!==void 0)return K;if(p6(Y,{checkOpen:!1}))throw TypeError(`The \`${Q}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return Z},lT=({value:Z,optionName:Y,fdNumber:Q,direction:J})=>{let X=iT(Z,Q);if(X===void 0)return;if(J==="output")return{type:"fileNumber",value:X,optionName:Y};if(dT.isatty(X))throw TypeError(`The \`${Y}: ${H5(Z)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:M1(pT(X)),optionName:Y}},iT=(Z,Y)=>{if(Z==="inherit")return Y;if(typeof Z==="number")return Z;let Q=mY.indexOf(Z);if(Q!==-1)return Q},nT=({stdioItem:Z,stdioItem:{value:Y,optionName:Q},fdNumber:J})=>{if(Y==="inherit")return{type:"nodeStream",value:YV(J,Y,Q),optionName:Q};if(typeof Y==="number")return{type:"nodeStream",value:YV(Y,Y,Q),optionName:Q};if(p6(Y,{checkOpen:!1}))return{type:"nodeStream",value:Y,optionName:Q};return Z},YV=(Z,Y,Q)=>{let J=mY[Z];if(J===void 0)throw TypeError(`The \`${Q}: ${Y}\` option is invalid: no such standard stream.`);return J};var JV=_(()=>{D1();N6();l1()});var XV=({input:Z,inputFile:Y},Q)=>Q===0?[...oT(Z),...sT(Y)]:[],oT=(Z)=>Z===void 0?[]:[{type:aT(Z),value:Z,optionName:"input"}],aT=(Z)=>{if(T4(Z,{checkOpen:!1}))return"nodeStream";if(typeof Z==="string")return"string";if(y0(Z))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},sT=(Z)=>Z===void 0?[]:[{...rT(Z),optionName:"inputFile"}],rT=(Z)=>{if(f5(Z))return{type:"fileUrl",value:Z};if(F3(Z))return{type:"filePath",value:{file:Z}};throw Error("The `inputFile` option must be a file path string or a file URL.")};var KV=_(()=>{N6();W6()});var zV=(Z)=>Z.filter((Y,Q)=>Z.every((J,X)=>Y.value!==J.value||Q>=X||Y.type==="generator"||Y.type==="asyncGenerator")),HV=({stdioItem:{type:Z,value:Y,optionName:Q},direction:J,fileDescriptors:X,isSync:K})=>{let z=tT(X,Z);if(z.length===0)return;if(K){eT({otherStdioItems:z,type:Z,value:Y,optionName:Q,direction:J});return}if(dU.has(Z))return WV({otherStdioItems:z,type:Z,value:Y,optionName:Q,direction:J});if(cU.has(Z))YL({otherStdioItems:z,type:Z,value:Y,optionName:Q})},tT=(Z,Y)=>Z.flatMap(({direction:Q,stdioItems:J})=>J.filter((X)=>X.type===Y).map((X)=>({...X,direction:Q}))),eT=({otherStdioItems:Z,type:Y,value:Q,optionName:J,direction:X})=>{if(R3.has(Y))WV({otherStdioItems:Z,type:Y,value:Q,optionName:J,direction:X})},WV=({otherStdioItems:Z,type:Y,value:Q,optionName:J,direction:X})=>{let K=Z.filter((H)=>ZL(H,Q));if(K.length===0)return;let z=K.find((H)=>H.direction!==X);return qV(z,J,Y),X==="output"?K[0].stream:void 0},ZL=({type:Z,value:Y},Q)=>{if(Z==="filePath")return Y.file===Q.file;if(Z==="fileUrl")return Y.href===Q.href;return Y===Q},YL=({otherStdioItems:Z,type:Y,value:Q,optionName:J})=>{let X=Z.find(({value:{transform:K}})=>K===Q.transform);qV(X,J,Y)},qV=(Z,Y,Q)=>{if(Z!==void 0)throw TypeError(`The \`${Z.optionName}\` and \`${Y}\` options must not target ${n1[Q]} that is the same.`)};var GV=_(()=>{W6()});var m5=(Z,Y,Q,J)=>{let K=tU(Y,Q,J).map((H,W)=>QL({stdioOption:H,fdNumber:W,options:Y,isSync:J})),z=GL({initialFileDescriptors:K,addProperties:Z,options:Y,isSync:J});return Y.stdio=z.map(({stdioItems:H})=>BL(H)),z},QL=({stdioOption:Z,fdNumber:Y,options:Q,isSync:J})=>{let X=uY(Y),{stdioItems:K,isStdioArray:z}=JL({stdioOption:Z,fdNumber:Y,options:Q,optionName:X}),H=oU(K,Y,X),W=K.map((U)=>QV({stdioItem:U,isStdioArray:z,fdNumber:Y,direction:H,isSync:J})),q=iU(W,X,H,Q),G=lU(q,H);return qL(q,G),{direction:H,objectMode:G,stdioItems:q}},JL=({stdioOption:Z,fdNumber:Y,options:Q,optionName:J})=>{let K=[...(Array.isArray(Z)?Z:[Z]).map((W)=>XL(W,J)),...XV(Q,Y)],z=zV(K),H=z.length>1;return KL(z,H,J),HL(z),{stdioItems:z,isStdioArray:H}},XL=(Z,Y)=>({type:yU(Z,Y),value:Z,optionName:Y}),KL=(Z,Y,Q)=>{if(Z.length===0)throw TypeError(`The \`${Q}\` option must not be an empty array.`);if(!Y)return;for(let{value:J,optionName:X}of Z)if(zL.has(J))throw Error(`The \`${X}\` option must not include \`${J}\`.`)},zL,HL=(Z)=>{for(let Y of Z)WL(Y)},WL=({type:Z,value:Y,optionName:Q})=>{if(gU(Y))throw TypeError(`The \`${Q}: URL\` option must use the \`file:\` scheme.
|
|
78
|
+
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(mU(Z,Y))throw TypeError(`The \`${Q}: { file: '...' }\` option must be used instead of \`${Q}: '...'\`.`)},qL=(Z,Y)=>{if(!Y)return;let Q=Z.find(({type:J})=>g5.has(J));if(Q!==void 0)throw TypeError(`The \`${Q.optionName}\` option cannot use both files and transforms in objectMode.`)},GL=({initialFileDescriptors:Z,addProperties:Y,options:Q,isSync:J})=>{let X=[];try{for(let K of Z)X.push(UL({fileDescriptor:K,fileDescriptors:X,addProperties:Y,options:Q,isSync:J}));return X}catch(K){throw j3(X),K}},UL=({fileDescriptor:{direction:Z,objectMode:Y,stdioItems:Q},fileDescriptors:J,addProperties:X,options:K,isSync:z})=>{let H=Q.map((W)=>VL({stdioItem:W,addProperties:X,direction:Z,options:K,fileDescriptors:J,isSync:z}));return{direction:Z,objectMode:Y,stdioItems:H}},VL=({stdioItem:Z,addProperties:Y,direction:Q,options:J,fileDescriptors:X,isSync:K})=>{let z=HV({stdioItem:Z,direction:Q,fileDescriptors:X,isSync:K});if(z!==void 0)return{...Z,stream:z};return{...Z,...Y[Q][Z.type](Z,J)}},j3=(Z)=>{for(let{stdioItems:Y}of Z)for(let{stream:Q}of Y)if(Q!==void 0&&!m6(Q))Q.destroy()},BL=(Z)=>{if(Z.length>1)return Z.some(({value:J})=>J==="overlapped")?"overlapped":"pipe";let[{type:Y,value:Q}]=Z;return Y==="native"?Q:"pipe"};var u5=_(()=>{D1();nU();D3();W6();sU();ZV();JV();KV();GV();zL=new Set(["ignore","ipc"])});import{readFileSync as UV}from"node:fs";var BV=(Z,Y)=>m5(FL,Z,Y,!0),Y1=({type:Z,optionName:Y})=>{$V(Y,n1[Z])},$L=({optionName:Z,value:Y})=>{if(Y==="ipc"||Y==="overlapped")$V(Z,`"${Y}"`);return{}},$V=(Z,Y)=>{throw TypeError(`The \`${Z}\` option cannot be ${Y} with synchronous methods.`)},VV,FL;var FV=_(()=>{N6();u5();W6();VV={generator(){},asyncGenerator:Y1,webStream:Y1,nodeStream:Y1,webTransform:Y1,duplex:Y1,asyncIterable:Y1,native:$L},FL={input:{...VV,fileUrl:({value:Z})=>({contents:[M1(UV(Z))]}),filePath:({value:{file:Z}})=>({contents:[M1(UV(Z))]}),fileNumber:Y1,iterable:({value:Z})=>({contents:[...Z]}),string:({value:Z})=>({contents:[Z]}),uint8Array:({value:Z})=>({contents:[Z]})},output:{...VV,fileUrl:({value:Z})=>({path:Z}),filePath:({value:{file:Z,append:Y}})=>({path:Z,append:Y}),fileNumber:({value:Z})=>({path:Z}),iterable:Y1,string:Y1,uint8Array:Y1}}});var T1=(Z,{stripFinalNewline:Y},Q)=>w3(Y,Q)&&Z!==void 0&&!Array.isArray(Z)?N8(Z):Z,w3=(Z,Y)=>Y==="all"?Z[1]||Z[2]:Z[Y];var gZ=_(()=>{z3()});var p5=(Z,Y,Q,J)=>Z||Q?void 0:RV(Y,J),L3=(Z,Y,Q)=>Q?Z.flatMap((J)=>OV(J,Y)):OV(Z,Y),OV=(Z,Y)=>{let{transform:Q,final:J}=RV(Y,{});return[...Q(Z),...J()]},RV=(Z,Y)=>{return Y.previousChunks="",{transform:OL.bind(void 0,Y,Z),final:ML.bind(void 0,Y)}},OL=function*(Z,Y,Q){if(typeof Q!=="string"){yield Q;return}let{previousChunks:J}=Z,X=-1;for(let K=0;K<Q.length;K+=1)if(Q[K]===`
|
|
79
|
+
`){let z=RL(Q,K,Y,Z),H=Q.slice(X+1,K+1-z);if(J.length>0)H=T3(J,H),J="";yield H,X=K}if(X!==Q.length-1)J=T3(J,Q.slice(X+1));Z.previousChunks=J},RL=(Z,Y,Q,J)=>{if(Q)return 0;return J.isWindowsNewline=Y!==0&&Z[Y-1]==="\r",J.isWindowsNewline?2:1},ML=function*({previousChunks:Z}){if(Z.length>0)yield Z},MV=({binary:Z,preserveNewlines:Y,readableObjectMode:Q,state:J})=>Z||Y||Q?void 0:{transform:DL.bind(void 0,J)},DL=function*({isWindowsNewline:Z=!1},Y){let{unixNewline:Q,windowsNewline:J,LF:X,concatBytes:K}=typeof Y==="string"?_L:jL;if(Y.at(-1)===X){yield Y;return}yield K(Y,Z?J:Q)},T3=(Z,Y)=>`${Z}${Y}`,_L,NL=(Z,Y)=>{let Q=new Uint8Array(Z.length+Y.length);return Q.set(Z,0),Q.set(Y,Z.length),Q},jL;var d5=_(()=>{_L={windowsNewline:`\r
|
|
80
|
+
`,unixNewline:`
|
|
81
|
+
`,LF:`
|
|
82
|
+
`,concatBytes:T3},jL={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:NL}});import{Buffer as wL}from"node:buffer";var DV=(Z,Y)=>Z?void 0:TL.bind(void 0,Y),TL=function*(Z,Y){if(typeof Y!=="string"&&!y0(Y)&&!wL.isBuffer(Y))throw TypeError(`The \`${Z}\` option's transform must use "objectMode: true" to receive as input: ${typeof Y}.`);yield Y},_V=(Z,Y)=>Z?LL.bind(void 0,Y):IL.bind(void 0,Y),LL=function*(Z,Y){NV(Z,Y),yield Y},IL=function*(Z,Y){if(NV(Z,Y),typeof Y!=="string"&&!y0(Y))throw TypeError(`The \`${Z}\` option's function must yield a string or an Uint8Array, not ${typeof Y}.`);yield Y},NV=(Z,Y)=>{if(Y===null||Y===void 0)throw TypeError(`The \`${Z}\` option's function must not call \`yield ${Y}\`.
|
|
83
|
+
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
84
|
+
if (condition) { yield value; }`)};var jV=_(()=>{N6()});import{Buffer as AL}from"node:buffer";import{StringDecoder as CL}from"node:string_decoder";var c5=(Z,Y,Q)=>{if(Q)return;if(Z)return{transform:EL.bind(void 0,new TextEncoder)};let J=new CL(Y);return{transform:xL.bind(void 0,J),final:SL.bind(void 0,J)}},EL=function*(Z,Y){if(AL.isBuffer(Y))yield M1(Y);else if(typeof Y==="string")yield Z.encode(Y);else yield Y},xL=function*(Z,Y){yield y0(Y)?Z.write(Y):Y},SL=function*(Z){let Y=Z.end();if(Y!=="")yield Y};var I3=_(()=>{N6()});import{callbackify as wV}from"node:util";var A3,l5=async function*(Z,Y,Q){if(Q===Y.length){yield Z;return}let{transform:J=PL}=Y[Q];for await(let X of J(Z))yield*l5(X,Y,Q+1)},TV=async function*(Z){for(let[Y,{final:Q}]of Object.entries(Z))yield*kL(Q,Number(Y),Z)},kL=async function*(Z,Y,Q){if(Z===void 0)return;for await(let J of Z())yield*l5(J,Q,Y+1)},LV,PL=function*(Z){yield Z};var IV=_(()=>{A3=wV(async(Z,Y,Q,J)=>{Y.currentIterable=Z(...Q);try{for await(let X of Y.currentIterable)J.push(X)}finally{delete Y.currentIterable}}),LV=wV(async({currentIterable:Z},Y)=>{if(Z!==void 0){await(Y?Z.throw(Y):Z.return());return}if(Y)throw Y})});var C3=(Z,Y,Q,J)=>{try{for(let X of Z(...Y))Q.push(X);J()}catch(X){J(X)}},AV=(Z,Y)=>[...Y.flatMap((Q)=>[...A4(Q,Z,0)]),...mZ(Z)],A4=function*(Z,Y,Q){if(Q===Y.length){yield Z;return}let{transform:J=yL}=Y[Q];for(let X of J(Z))yield*A4(X,Y,Q+1)},mZ=function*(Z){for(let[Y,{final:Q}]of Object.entries(Z))yield*vL(Q,Number(Y),Z)},vL=function*(Z,Y,Q){if(Z===void 0)return;for(let J of Z())yield*A4(J,Q,Y+1)},yL=function*(Z){yield Z};import{Transform as bL,getDefaultHighWaterMark as CV}from"node:stream";var E3=({value:Z,value:{transform:Y,final:Q,writableObjectMode:J,readableObjectMode:X},optionName:K},{encoding:z})=>{let H={},W=EV(Z,z,K),q=I4(Y),G=I4(Q),U=q?A3.bind(void 0,l5,H):C3.bind(void 0,A4),B=q||G?A3.bind(void 0,TV,H):C3.bind(void 0,mZ),F=q||G?LV.bind(void 0,H):void 0;return{stream:new bL({writableObjectMode:J,writableHighWaterMark:CV(J),readableObjectMode:X,readableHighWaterMark:CV(X),transform(O,D,j){U([O,W,0],this,j)},flush(O){B([W],this,O)},destroy:F})}},i5=(Z,Y,Q,J)=>{let X=Y.filter(({type:z})=>z==="generator"),K=J?X.reverse():X;for(let{value:z,optionName:H}of K){let W=EV(z,Q,H);Z=AV(W,Z)}return Z},EV=({transform:Z,final:Y,binary:Q,writableObjectMode:J,readableObjectMode:X,preserveNewlines:K},z,H)=>{let W={};return[{transform:DV(J,H)},c5(Q,z,J),p5(Q,K,J,W),{transform:Z,final:Y},{transform:_V(X,H)},MV({binary:Q,preserveNewlines:K,readableObjectMode:X,state:W})].filter(Boolean)};var n5=_(()=>{W6();d5();jV();I3();IV()});var xV=(Z,Y)=>{for(let Q of fL(Z))hL(Z,Q,Y)},fL=(Z)=>new Set(Object.entries(Z).filter(([,{direction:Y}])=>Y==="input").map(([Y])=>Number(Y))),hL=(Z,Y,Q)=>{let{stdioItems:J}=Z[Y],X=J.filter(({contents:H})=>H!==void 0);if(X.length===0)return;if(Y!==0){let[{type:H,optionName:W}]=X;throw TypeError(`Only the \`stdin\` option, not \`${W}\`, can be ${n1[H]} with synchronous methods.`)}let z=X.map(({contents:H})=>H).map((H)=>gL(H,J));Q.input=IZ(z)},gL=(Z,Y)=>{let Q=i5(Z,Y,"utf8",!0);return mL(Q),IZ(Q)},mL=(Z)=>{let Y=Z.find((Q)=>typeof Q!=="string"&&!y0(Q));if(Y!==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: ${Y}.`)};var SV=_(()=>{n5();N6();W6()});var o5=({stdioItems:Z,encoding:Y,verboseInfo:Q,fdNumber:J})=>J!=="all"&&B8(Q,J)&&!j6.has(Y)&&uL(J)&&(Z.some(({type:X,value:K})=>X==="native"&&pL.has(K))||Z.every(({type:X})=>v6.has(X))),uL=(Z)=>Z===1||Z===2,pL,kV=async(Z,Y,Q,J)=>{for await(let X of Z)if(!dL(Y))vV(X,Q,J)},PV=(Z,Y,Q)=>{for(let J of Z)vV(J,Y,Q)},dL=(Z)=>Z._readableState.pipes.length>0,vV=(Z,Y,Q)=>{let J=oY(Z);r6({type:"output",verboseMessage:J,fdNumber:Y,verboseInfo:Q})};var x3=_(()=>{w4();W6();$8();p1();pL=new Set(["pipe","overlapped"])});import{writeFileSync as cL,appendFileSync as lL}from"node:fs";var yV=({fileDescriptors:Z,syncResult:{output:Y},options:Q,isMaxBuffer:J,verboseInfo:X})=>{if(Y===null)return{output:Array.from({length:3})};let K={},z=new Set([]);return{output:Y.map((W,q)=>iL({result:W,fileDescriptors:Z,fdNumber:q,state:K,outputFiles:z,isMaxBuffer:J,verboseInfo:X},Q)),...K}},iL=({result:Z,fileDescriptors:Y,fdNumber:Q,state:J,outputFiles:X,isMaxBuffer:K,verboseInfo:z},{buffer:H,encoding:W,lines:q,stripFinalNewline:G,maxBuffer:U})=>{if(Z===null)return;let B=jU(Z,K,U),F=M1(B),{stdioItems:$,objectMode:O}=Y[Q],D=nL([F],$,W,J),{serializedResult:j,finalResult:M=j}=oL({chunks:D,objectMode:O,encoding:W,lines:q,stripFinalNewline:G,fdNumber:Q});aL({serializedResult:j,fdNumber:Q,state:J,verboseInfo:z,encoding:W,stdioItems:$,objectMode:O});let T=H[Q]?M:void 0;try{if(J.error===void 0)sL(j,$,X);return T}catch(N){return J.error=N,T}},nL=(Z,Y,Q,J)=>{try{return i5(Z,Y,Q,!1)}catch(X){return J.error=X,Z}},oL=({chunks:Z,objectMode:Y,encoding:Q,lines:J,stripFinalNewline:X,fdNumber:K})=>{if(Y)return{serializedResult:Z};if(Q==="buffer")return{serializedResult:IZ(Z)};let z=$W(Z,Q);if(J[K])return{serializedResult:z,finalResult:L3(z,!X[K],Y)};return{serializedResult:z}},aL=({serializedResult:Z,fdNumber:Y,state:Q,verboseInfo:J,encoding:X,stdioItems:K,objectMode:z})=>{if(!o5({stdioItems:K,encoding:X,verboseInfo:J,fdNumber:Y}))return;let H=L3(Z,!1,z);try{PV(H,Y,J)}catch(W){Q.error??=W}},sL=(Z,Y,Q)=>{for(let{path:J,append:X}of Y.filter(({type:K})=>g5.has(K))){let K=typeof J==="string"?J:J.toString();if(X||Q.has(K))lL(J,Z);else Q.add(K),cL(J,Z)}};var bV=_(()=>{x3();n5();d5();N6();W6();L4()});var fV=([,Z,Y],Q)=>{if(!Q.all)return;if(Z===void 0)return Y;if(Y===void 0)return Z;if(Array.isArray(Z))return Array.isArray(Y)?[...Z,...Y]:[...Z,T1(Y,Q,"all")];if(Array.isArray(Y))return[T1(Z,Q,"all"),...Y];if(y0(Z)&&y0(Y))return j9([Z,Y]);return`${Z}${Y}`};var hV=_(()=>{N6();gZ()});import{once as S3}from"node:events";var gV=async(Z,Y)=>{let[Q,J]=await rL(Z);return Y.isForcefullyTerminated??=!1,[Q,J]},rL=async(Z)=>{let[Y,Q]=await Promise.allSettled([S3(Z,"spawn"),S3(Z,"exit")]);if(Y.status==="rejected")return[];return Q.status==="rejected"?mV(Z):Q.value},mV=async(Z)=>{try{return await S3(Z,"exit")}catch{return mV(Z)}},uV=async(Z)=>{let[Y,Q]=await Z;if(!tL(Y,Q)&&k3(Y,Q))throw new t6;return[Y,Q]},tL=(Z,Y)=>Z===void 0&&Y===void 0,k3=(Z,Y)=>Z!==0||Y!==null;var P3=_(()=>{d1()});var pV=({error:Z,status:Y,signal:Q,output:J},{maxBuffer:X})=>{let K=eL(Z,Y,Q),z=K?.code==="ETIMEDOUT",H=NU(K,J,X);return{resultError:K,exitCode:Y,signal:Q,timedOut:z,isMaxBuffer:H}},eL=(Z,Y,Q)=>{if(Z!==void 0)return Z;return k3(Y,Q)?new t6:void 0};var dV=_(()=>{d1();L4();P3()});import{spawnSync as ZI}from"node:child_process";var cV=(Z,Y,Q)=>{let{file:J,commandArguments:X,command:K,escapedCommand:z,startTime:H,verboseInfo:W,options:q,fileDescriptors:G}=YI(Z,Y,Q),U=XI({file:J,commandArguments:X,options:q,command:K,escapedCommand:z,verboseInfo:W,fileDescriptors:G,startTime:H});return T8(U,W,q)},YI=(Z,Y,Q)=>{let{command:J,escapedCommand:X,startTime:K,verboseInfo:z}=rY(Z,Y,Q),H=QI(Q),{file:W,commandArguments:q,options:G}=T5(Z,Y,H);JI(G);let U=BV(G,z);return{file:W,commandArguments:q,command:J,escapedCommand:X,startTime:K,verboseInfo:z,options:G,fileDescriptors:U}},QI=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,JI=({ipc:Z,ipcInput:Y,detached:Q,cancelSignal:J})=>{if(Y)a5("ipcInput");if(Z)a5("ipc: true");if(Q)a5("detached: true");if(J)a5("cancelSignal")},a5=(Z)=>{throw TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},XI=({file:Z,commandArguments:Y,options:Q,command:J,escapedCommand:X,verboseInfo:K,fileDescriptors:z,startTime:H})=>{let W=KI({file:Z,commandArguments:Y,options:Q,command:J,escapedCommand:X,fileDescriptors:z,startTime:H});if(W.failed)return W;let{resultError:q,exitCode:G,signal:U,timedOut:B,isMaxBuffer:F}=pV(W,Q),{output:$,error:O=q}=yV({fileDescriptors:z,syncResult:W,options:Q,isMaxBuffer:F,verboseInfo:K}),D=$.map((M,T)=>T1(M,Q,T)),j=T1(fV($,Q),Q,"all");return HI({error:O,exitCode:G,signal:U,timedOut:B,isMaxBuffer:F,stdio:D,all:j,options:Q,command:J,escapedCommand:X,startTime:H})},KI=({file:Z,commandArguments:Y,options:Q,command:J,escapedCommand:X,fileDescriptors:K,startTime:z})=>{try{xV(K,Q);let H=zI(Q);return ZI(...L5(Z,Y,H))}catch(H){return w8({error:H,command:J,escapedCommand:X,fileDescriptors:K,options:Q,startTime:z,isSync:!0})}},zI=({encoding:Z,maxBuffer:Y,...Q})=>({...Q,encoding:"buffer",maxBuffer:v5(Y)}),HI=({error:Z,exitCode:Y,signal:Q,timedOut:J,isMaxBuffer:X,stdio:K,all:z,options:H,command:W,escapedCommand:q,startTime:G})=>Z===void 0?y5({command:W,escapedCommand:q,stdio:K,all:z,ipcOutput:[],options:H,startTime:G}):fZ({error:Z,command:W,escapedCommand:q,timedOut:J,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:X,isForcefullyTerminated:!1,exitCode:Y,signal:Q,stdio:K,all:z,ipcOutput:[],options:H,startTime:G,isSync:!0});var lV=_(()=>{x9();K3();hZ();b5();FV();gZ();SV();bV();L4();hV();dV()});import{once as v3,on as WI}from"node:events";var iV=({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J},{reference:X=!0,filter:K}={})=>{return R8({methodName:"getOneMessage",isSubprocess:Q,ipc:J,isConnected:R5(Z)}),qI({anyProcess:Z,channel:Y,isSubprocess:Q,filter:K,reference:X})},qI=async({anyProcess:Z,channel:Y,isSubprocess:Q,filter:J,reference:X})=>{G5(Y,X);let K=i1(Z,Y,Q),z=new AbortController;try{return await Promise.race([GI(K,J,z),UI(K,Q,z),VI(K,Q,z)])}catch(H){throw M8(Z),H}finally{z.abort(),U5(Y,X)}},GI=async(Z,Y,{signal:Q})=>{if(Y===void 0){let[J]=await v3(Z,"message",{signal:Q});return J}for await(let[J]of WI(Z,"message",{signal:Q}))if(Y(J))return J},UI=async(Z,Y,{signal:Q})=>{await v3(Z,"disconnect",{signal:Q}),KG(Y)},VI=async(Z,Y,{signal:Q})=>{let[J]=await v3(Z,"strict:error",{signal:Q});throw z5(J,Y)};var nV=_(()=>{D8();kZ()});import{once as aV,on as BI}from"node:events";var sV=({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J},{reference:X=!0}={})=>y3({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J,shouldAwait:!Q,reference:X}),y3=({anyProcess:Z,channel:Y,isSubprocess:Q,ipc:J,shouldAwait:X,reference:K})=>{R8({methodName:"getEachMessage",isSubprocess:Q,ipc:J,isConnected:R5(Z)}),G5(Y,K);let z=i1(Z,Y,Q),H=new AbortController,W={};return $I(Z,z,H),FI({ipcEmitter:z,isSubprocess:Q,controller:H,state:W}),OI({anyProcess:Z,channel:Y,ipcEmitter:z,isSubprocess:Q,shouldAwait:X,controller:H,state:W,reference:K})},$I=async(Z,Y,Q)=>{try{await aV(Y,"disconnect",{signal:Q.signal}),Q.abort()}catch{}},FI=async({ipcEmitter:Z,isSubprocess:Y,controller:Q,state:J})=>{try{let[X]=await aV(Z,"strict:error",{signal:Q.signal});J.error=z5(X,Y),Q.abort()}catch{}},OI=async function*({anyProcess:Z,channel:Y,ipcEmitter:Q,isSubprocess:J,shouldAwait:X,controller:K,state:z,reference:H}){try{for await(let[W]of BI(Q,"message",{signal:K.signal}))oV(z),yield W}catch{oV(z)}finally{if(K.abort(),U5(Y,H),!J)M8(Z);if(X)await Z}},oV=({error:Z})=>{if(Z)throw Z};var b3=_(()=>{D8();kZ()});import rV from"node:process";var tV=(Z,{ipc:Y})=>{Object.assign(Z,ZB(Z,!1,Y))},eV=()=>{let Z=rV,Y=!0,Q=rV.channel!==void 0;return{...ZB(Z,!0,Q),getCancelSignal:PG.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:Q})}},ZB=(Z,Y,Q)=>({sendMessage:N5.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:Y,ipc:Q}),getOneMessage:iV.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:Y,ipc:Q}),getEachMessage:sV.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:Y,ipc:Q})});var f3=_(()=>{j5();nV();b3();F5()});import{ChildProcess as RI}from"node:child_process";import{PassThrough as MI,Readable as DI,Writable as _I,Duplex as NI}from"node:stream";var YB=({error:Z,command:Y,escapedCommand:Q,fileDescriptors:J,options:X,startTime:K,verboseInfo:z})=>{j3(J);let H=new RI;jI(H,J),Object.assign(H,{readable:wI,writable:TI,duplex:LI});let W=w8({error:Z,command:Y,escapedCommand:Q,fileDescriptors:J,options:X,startTime:K,isSync:!1}),q=II(W,z,X);return{subprocess:H,promise:q}},jI=(Z,Y)=>{let Q=uZ(),J=uZ(),X=uZ(),K=Array.from({length:Y.length-3},uZ),z=uZ(),H=[Q,J,X,...K];Object.assign(Z,{stdin:Q,stdout:J,stderr:X,all:z,stdio:H})},uZ=()=>{let Z=new MI;return Z.end(),Z},wI=()=>new DI({read(){}}),TI=()=>new _I({write(){}}),LI=()=>new NI({read(){},write(){}}),II=async(Z,Y,Q)=>T8(Z,Y,Q);var QB=_(()=>{u5();hZ();b5()});import{createReadStream as JB,createWriteStream as XB}from"node:fs";import{Buffer as AI}from"node:buffer";import{Readable as pZ,Writable as CI,Duplex as EI}from"node:stream";var zB=(Z,Y)=>m5(xI,Z,Y,!1),dZ=({type:Z,optionName:Y})=>{throw TypeError(`The \`${Y}\` option cannot be ${n1[Z]}.`)},KB,xI;var HB=_(()=>{n5();u5();W6();KB={fileNumber:dZ,generator:E3,asyncGenerator:E3,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:Y,readableObjectMode:Q}}){let J=Y||Q;return{stream:EI.fromWeb(Z,{objectMode:J})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},xI={input:{...KB,fileUrl:({value:Z})=>({stream:JB(Z)}),filePath:({value:{file:Z}})=>({stream:JB(Z)}),webStream:({value:Z})=>({stream:pZ.fromWeb(Z)}),iterable:({value:Z})=>({stream:pZ.from(Z)}),asyncIterable:({value:Z})=>({stream:pZ.from(Z)}),string:({value:Z})=>({stream:pZ.from(Z)}),uint8Array:({value:Z})=>({stream:pZ.from(AI.from(Z))})},output:{...KB,fileUrl:({value:Z})=>({stream:XB(Z)}),filePath:({value:{file:Z,append:Y}})=>({stream:XB(Z,Y?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:CI.fromWeb(Z)}),iterable:dZ,asyncIterable:dZ,string:dZ,uint8Array:dZ}}});import{on as SI,once as WB}from"node:events";import{PassThrough as kI,getDefaultHighWaterMark as PI}from"node:stream";import{finished as UB}from"node:stream/promises";function C4(Z){if(!Array.isArray(Z))throw TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let X of Z)h3(X);let Y=Z.some(({readableObjectMode:X})=>X),Q=vI(Z,Y),J=new VB({objectMode:Y,writableHighWaterMark:Q,readableHighWaterMark:Q});for(let X of Z)J.add(X);return J}var vI=(Z,Y)=>{if(Z.length===0)return PI(Y);let Q=Z.filter(({readableObjectMode:J})=>J===Y).map(({readableHighWaterMark:J})=>J);return Math.max(...Q)},VB,yI=async(Z,Y,Q)=>{s5(Z,qB);let J=new AbortController;try{await Promise.race([bI(Z,J),fI(Z,Y,Q,J)])}finally{J.abort(),s5(Z,-qB)}},bI=async(Z,{signal:Y})=>{try{await UB(Z,{signal:Y,cleanup:!0})}catch(Q){throw BB(Z,Q),Q}},fI=async(Z,Y,Q,{signal:J})=>{for await(let[X]of SI(Z,"unpipe",{signal:J}))if(Y.has(X))X.emit(Q)},h3=(Z)=>{if(typeof Z?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},hI=async({passThroughStream:Z,stream:Y,streams:Q,ended:J,aborted:X,onFinished:K,unpipeEvent:z})=>{s5(Z,GB);let H=new AbortController;try{await Promise.race([gI(K,Y,H),mI({passThroughStream:Z,stream:Y,streams:Q,ended:J,aborted:X,controller:H}),uI({stream:Y,streams:Q,ended:J,aborted:X,unpipeEvent:z,controller:H})])}finally{H.abort(),s5(Z,-GB)}if(Q.size>0&&Q.size===J.size+X.size)if(J.size===0&&X.size>0)g3(Z);else pI(Z)},gI=async(Z,Y,{signal:Q})=>{try{if(await Z,!Q.aborted)g3(Y)}catch(J){if(!Q.aborted)BB(Y,J)}},mI=async({passThroughStream:Z,stream:Y,streams:Q,ended:J,aborted:X,controller:{signal:K}})=>{try{if(await UB(Y,{signal:K,cleanup:!0,readable:!0,writable:!1}),Q.has(Y))J.add(Y)}catch(z){if(K.aborted||!Q.has(Y))return;if($B(z))X.add(Y);else FB(Z,z)}},uI=async({stream:Z,streams:Y,ended:Q,aborted:J,unpipeEvent:X,controller:{signal:K}})=>{if(await WB(Z,X,{signal:K}),!Z.readable)return WB(K,"abort",{signal:K});Y.delete(Z),Q.delete(Z),J.delete(Z)},pI=(Z)=>{if(Z.writable)Z.end()},BB=(Z,Y)=>{if($B(Y))g3(Z);else FB(Z,Y)},$B=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",g3=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},FB=(Z,Y)=>{if(!Z.destroyed)Z.once("error",dI),Z.destroy(Y)},dI=()=>{},s5=(Z,Y)=>{let Q=Z.getMaxListeners();if(Q!==0&&Q!==Number.POSITIVE_INFINITY)Z.setMaxListeners(Q+Y)},qB=2,GB=1;var r5=_(()=>{VB=class VB extends kI{#Y=new Set([]);#Q=new Set([]);#Z=new Set([]);#J;#X=Symbol("unpipe");#K=new WeakMap;add(Z){if(h3(Z),this.#Y.has(Z))return;this.#Y.add(Z),this.#J??=yI(this,this.#Y,this.#X);let Y=hI({passThroughStream:this,stream:Z,streams:this.#Y,ended:this.#Q,aborted:this.#Z,onFinished:this.#J,unpipeEvent:this.#X});this.#K.set(Z,Y),Z.pipe(this,{end:!1})}async remove(Z){if(h3(Z),!this.#Y.has(Z))return!1;let Y=this.#K.get(Z);if(Y===void 0)return!1;return this.#K.delete(Z),Z.unpipe(this),await Y,!0}}});import{finished as OB}from"node:stream/promises";var I8=(Z,Y)=>{Z.pipe(Y),cI(Z,Y),lI(Z,Y)},cI=async(Z,Y)=>{if(m6(Z)||m6(Y))return;try{await OB(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}m3(Y)},m3=(Z)=>{if(Z.writable)Z.end()},lI=async(Z,Y)=>{if(m6(Z)||m6(Y))return;try{await OB(Y,{cleanup:!0,readable:!1,writable:!0})}catch{}u3(Z)},u3=(Z)=>{if(Z.readable)Z.destroy()};var t5=_(()=>{D1()});var RB=(Z,Y,Q)=>{let J=new Map;for(let[X,{stdioItems:K,direction:z}]of Object.entries(Y)){for(let{stream:H}of K.filter(({type:W})=>v6.has(W)))iI(Z,H,z,X);for(let{stream:H}of K.filter(({type:W})=>!v6.has(W)))oI({subprocess:Z,stream:H,direction:z,fdNumber:X,pipeGroups:J,controller:Q})}for(let[X,K]of J.entries()){let z=K.length===1?K[0]:C4(K);I8(z,X)}},iI=(Z,Y,Q,J)=>{if(Q==="output")I8(Z.stdio[J],Y);else I8(Y,Z.stdio[J]);let X=nI[J];if(X!==void 0)Z[X]=Y;Z.stdio[J]=Y},nI,oI=({subprocess:Z,stream:Y,direction:Q,fdNumber:J,pipeGroups:X,controller:K})=>{if(Y===void 0)return;aI(Y,K);let[z,H]=Q==="output"?[Y,Z.stdio[J]]:[Z.stdio[J],Y],W=X.get(z)??[];X.set(z,[...W,H])},aI=(Z,{signal:Y})=>{if(m6(Z))j4(Z,sI,Y)},sI=2;var MB=_(()=>{r5();D1();q5();W6();t5();nI=["stdin","stdout","stderr"]});var E4;var DB=_(()=>{E4=[];E4.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")E4.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")E4.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class _B{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(d3[p3])return d3[p3];rI(d3,p3,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Z,Y){this.listeners[Z].push(Y)}removeListener(Z,Y){let Q=this.listeners[Z],J=Q.indexOf(Y);if(J===-1)return;if(J===0&&Q.length===1)Q.length=0;else Q.splice(J,1)}emit(Z,Y,Q){if(this.emitted[Z])return!1;this.emitted[Z]=!0;let J=!1;for(let X of this.listeners[Z])J=X(Y,Q)===!0||J;if(Z==="exit")J=this.emit("afterExit",Y,Q)||J;return J}}class l3{}var e5=(Z)=>!!Z&&typeof Z==="object"&&typeof Z.removeListener==="function"&&typeof Z.emit==="function"&&typeof Z.reallyExit==="function"&&typeof Z.listeners==="function"&&typeof Z.kill==="function"&&typeof Z.pid==="number"&&typeof Z.on==="function",p3,d3,rI,tI=(Z)=>{return{onExit(Y,Q){return Z.onExit(Y,Q)},load(){return Z.load()},unload(){return Z.unload()}}},NB,jB,c3,wB,Sd,kd;var TB=_(()=>{DB();p3=Symbol.for("signal-exit emitter"),d3=globalThis,rI=Object.defineProperty.bind(Object);NB=class NB extends l3{onExit(){return()=>{}}load(){}unload(){}};jB=class jB extends l3{#Y=c3.platform==="win32"?"SIGINT":"SIGHUP";#Q=new _B;#Z;#J;#X;#K={};#z=!1;constructor(Z){super();this.#Z=Z,this.#K={};for(let Y of E4)this.#K[Y]=()=>{let Q=this.#Z.listeners(Y),{count:J}=this.#Q,X=Z;if(typeof X.__signal_exit_emitter__==="object"&&typeof X.__signal_exit_emitter__.count==="number")J+=X.__signal_exit_emitter__.count;if(Q.length===J){this.unload();let K=this.#Q.emit("exit",null,Y),z=Y==="SIGHUP"?this.#Y:Y;if(!K)Z.kill(Z.pid,z)}};this.#X=Z.reallyExit,this.#J=Z.emit}onExit(Z,Y){if(!e5(this.#Z))return()=>{};if(this.#z===!1)this.load();let Q=Y?.alwaysLast?"afterExit":"exit";return this.#Q.on(Q,Z),()=>{if(this.#Q.removeListener(Q,Z),this.#Q.listeners.exit.length===0&&this.#Q.listeners.afterExit.length===0)this.unload()}}load(){if(this.#z)return;this.#z=!0,this.#Q.count+=1;for(let Z of E4)try{let Y=this.#K[Z];if(Y)this.#Z.on(Z,Y)}catch(Y){}this.#Z.emit=(Z,...Y)=>{return this.#W(Z,...Y)},this.#Z.reallyExit=(Z)=>{return this.#H(Z)}}unload(){if(!this.#z)return;this.#z=!1,E4.forEach((Z)=>{let Y=this.#K[Z];if(!Y)throw Error("Listener not defined for signal: "+Z);try{this.#Z.removeListener(Z,Y)}catch(Q){}}),this.#Z.emit=this.#J,this.#Z.reallyExit=this.#X,this.#Q.count-=1}#H(Z){if(!e5(this.#Z))return 0;return this.#Z.exitCode=Z||0,this.#Q.emit("exit",this.#Z.exitCode,null),this.#X.call(this.#Z,this.#Z.exitCode)}#W(Z,...Y){let Q=this.#J;if(Z==="exit"&&e5(this.#Z)){if(typeof Y[0]==="number")this.#Z.exitCode=Y[0];let J=Q.call(this.#Z,Z,...Y);return this.#Q.emit("exit",this.#Z.exitCode,null),J}else return Q.call(this.#Z,Z,...Y)}};c3=globalThis.process,{onExit:wB,load:Sd,unload:kd}=tI(e5(c3)?new jB(c3):new NB)});import{addAbortListener as eI}from"node:events";var LB=(Z,{cleanup:Y,detached:Q},{signal:J})=>{if(!Y||Q)return;let X=wB(()=>{Z.kill()});eI(J,()=>{X()})};var IB=_(()=>{TB()});var CB=({source:Z,sourcePromise:Y,boundOptions:Q,createNested:J},...X)=>{let K=aY(),{destination:z,destinationStream:H,destinationError:W,from:q,unpipeSignal:G}=ZA(Q,J,X),{sourceStream:U,sourceError:B}=QA(Z,q),{options:F,fileDescriptors:$}=Z1.get(Z);return{sourcePromise:Y,sourceStream:U,sourceOptions:F,sourceError:B,destination:z,destinationStream:H,destinationError:W,unpipeSignal:G,fileDescriptors:$,startTime:K}},ZA=(Z,Y,Q)=>{try{let{destination:J,pipeOptions:{from:X,to:K,unpipeSignal:z}={}}=YA(Z,Y,...Q),H=W5(J,K);return{destination:J,destinationStream:H,from:X,unpipeSignal:z}}catch(J){return{destinationError:J}}},YA=(Z,Y,Q,...J)=>{if(Array.isArray(Q))return{destination:Y(AB,Z)(Q,...J),pipeOptions:Z};if(typeof Q==="string"||Q instanceof URL||D9(Q)){if(Object.keys(Z).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[X,K,z]=hY(Q,...J);return{destination:Y(AB)(X,K,z),pipeOptions:z}}if(Z1.has(Q)){if(Object.keys(Z).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}`)},AB=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),QA=(Z,Y)=>{try{return{sourceStream:_8(Z,Y)}}catch(Q){return{sourceError:Q}}};var EB=_(()=>{N9();sY();l1();U8()});var SB=({sourceStream:Z,sourceError:Y,destinationStream:Q,destinationError:J,fileDescriptors:X,sourceOptions:K,startTime:z})=>{let H=JA({sourceStream:Z,sourceError:Y,destinationStream:Q,destinationError:J});if(H!==void 0)throw i3({error:H,fileDescriptors:X,sourceOptions:K,startTime:z})},JA=({sourceStream:Z,sourceError:Y,destinationStream:Q,destinationError:J})=>{if(Y!==void 0&&J!==void 0)return J;if(J!==void 0)return u3(Z),J;if(Y!==void 0)return m3(Q),Y},i3=({error:Z,fileDescriptors:Y,sourceOptions:Q,startTime:J})=>w8({error:Z,command:xB,escapedCommand:xB,fileDescriptors:Y,options:Q,startTime:J,isSync:!1}),xB="source.pipe(destination)";var n3=_(()=>{hZ();t5()});var kB=async(Z)=>{let[{status:Y,reason:Q,value:J=Q},{status:X,reason:K,value:z=K}]=await Z;if(!z.pipedFrom.includes(J))z.pipedFrom.push(J);if(X==="rejected")throw z;if(Y==="rejected")throw J;return z};import{finished as XA}from"node:stream/promises";var PB=(Z,Y,Q)=>{let J=Z2.has(Y)?zA(Z,Y):KA(Z,Y);return j4(Z,WA,Q.signal),j4(Y,qA,Q.signal),HA(Y),J},KA=(Z,Y)=>{let Q=C4([Z]);return I8(Q,Y),Z2.set(Y,Q),Q},zA=(Z,Y)=>{let Q=Z2.get(Y);return Q.add(Z),Q},HA=async(Z)=>{try{await XA(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}Z2.delete(Z)},Z2,WA=2,qA=1;var vB=_(()=>{r5();q5();t5();Z2=new WeakMap});import{aborted as GA}from"node:util";var yB=(Z,Y)=>Z===void 0?[]:[UA(Z,Y)],UA=async(Z,{sourceStream:Y,mergedStream:Q,fileDescriptors:J,sourceOptions:X,startTime:K})=>{await GA(Z,Y),await Q.remove(Y);let z=Error("Pipe canceled by `unpipeSignal` option.");throw i3({error:z,fileDescriptors:J,sourceOptions:X,startTime:K})};var bB=_(()=>{n3()});var Y2=(Z,...Y)=>{if(C0(Y[0]))return Y2.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...Y[0]}});let{destination:Q,...J}=CB(Z,...Y),X=VA({...J,destination:Q});return X.pipe=Y2.bind(void 0,{...Z,source:Q,sourcePromise:X,boundOptions:{}}),X},VA=async({sourcePromise:Z,sourceStream:Y,sourceOptions:Q,sourceError:J,destination:X,destinationStream:K,destinationError:z,unpipeSignal:H,fileDescriptors:W,startTime:q})=>{let G=BA(Z,X);SB({sourceStream:Y,sourceError:J,destinationStream:K,destinationError:z,fileDescriptors:W,sourceOptions:Q,startTime:q});let U=new AbortController;try{let B=PB(Y,K,U);return await Promise.race([kB(G),...yB(H,{sourceStream:Y,mergedStream:B,sourceOptions:Q,fileDescriptors:W,startTime:q})])}finally{U.abort()}},BA=(Z,Y)=>Promise.allSettled([Z,Y]);var fB=_(()=>{EB();n3();vB();bB()});import{on as $A}from"node:events";import{getDefaultHighWaterMark as FA}from"node:stream";var Q2=({subprocessStdout:Z,subprocess:Y,binary:Q,shouldEncode:J,encoding:X,preserveNewlines:K})=>{let z=new AbortController;return OA(Y,z),gB({stream:Z,controller:z,binary:Q,shouldEncode:!Z.readableObjectMode&&J,encoding:X,shouldSplit:!Z.readableObjectMode,preserveNewlines:K})},OA=async(Z,Y)=>{try{await Z}catch{}finally{Y.abort()}},o3=({stream:Z,onStreamEnd:Y,lines:Q,encoding:J,stripFinalNewline:X,allMixed:K})=>{let z=new AbortController;RA(Y,z,Z);let H=Z.readableObjectMode&&!K;return gB({stream:Z,controller:z,binary:J==="buffer",shouldEncode:!H,encoding:J,shouldSplit:!H&&Q,preserveNewlines:!X})},RA=async(Z,Y,Q)=>{try{await Z}catch{Q.destroy()}finally{Y.abort()}},gB=({stream:Z,controller:Y,binary:Q,shouldEncode:J,encoding:X,shouldSplit:K,preserveNewlines:z})=>{let H=$A(Z,"data",{signal:Y.signal,highWaterMark:hB,highWatermark:hB});return MA({onStdoutChunk:H,controller:Y,binary:Q,shouldEncode:J,encoding:X,shouldSplit:K,preserveNewlines:z})},a3,hB,MA=async function*({onStdoutChunk:Z,controller:Y,binary:Q,shouldEncode:J,encoding:X,shouldSplit:K,preserveNewlines:z}){let H=DA({binary:Q,shouldEncode:J,encoding:X,shouldSplit:K,preserveNewlines:z});try{for await(let[W]of Z)yield*A4(W,H,0)}catch(W){if(!Y.signal.aborted)throw W}finally{yield*mZ(H)}},DA=({binary:Z,shouldEncode:Y,encoding:Q,shouldSplit:J,preserveNewlines:X})=>[c5(Z,Q,!Y),p5(Z,X,!J,{})].filter(Boolean);var J2=_(()=>{I3();d5();a3=FA(!0),hB=a3});import{setImmediate as _A}from"node:timers/promises";var mB=async({stream:Z,onStreamEnd:Y,fdNumber:Q,encoding:J,buffer:X,maxBuffer:K,lines:z,allMixed:H,stripFinalNewline:W,verboseInfo:q,streamInfo:G})=>{let U=NA({stream:Z,onStreamEnd:Y,fdNumber:Q,encoding:J,allMixed:H,verboseInfo:q,streamInfo:G});if(!X){await Promise.all([jA(Z),U]);return}let B=w3(W,Q),F=o3({stream:Z,onStreamEnd:Y,lines:z,encoding:J,stripFinalNewline:B,allMixed:H}),[$]=await Promise.all([wA({stream:Z,iterable:F,fdNumber:Q,encoding:J,maxBuffer:K,lines:z}),U]);return $},NA=async({stream:Z,onStreamEnd:Y,fdNumber:Q,encoding:J,allMixed:X,verboseInfo:K,streamInfo:{fileDescriptors:z}})=>{if(!o5({stdioItems:z[Q]?.stdioItems,encoding:J,verboseInfo:K,fdNumber:Q}))return;let H=o3({stream:Z,onStreamEnd:Y,lines:!0,encoding:J,stripFinalNewline:!0,allMixed:X});await kV(H,Z,Q,K)},jA=async(Z)=>{if(await _A(),Z.readableFlowing===null)Z.resume()},wA=async({stream:Z,stream:{readableObjectMode:Y},iterable:Q,fdNumber:J,encoding:X,maxBuffer:K,lines:z})=>{try{if(Y||z)return await E5(Q,{maxBuffer:K});if(X==="buffer")return new Uint8Array(await x5(Q,{maxBuffer:K}));return await k5(Q,{maxBuffer:K})}catch(H){return uB(MU({error:H,stream:Z,readableObjectMode:Y,lines:z,encoding:X,fdNumber:J}))}},s3=async(Z)=>{try{return await Z}catch(Y){return uB(Y)}},uB=({bufferedData:Z})=>VW(Z)?new Uint8Array(Z):Z;var r3=_(()=>{P5();N6();x3();J2();L4();gZ()});import{finished as TA}from"node:stream/promises";var cZ=async(Z,Y,Q,{isSameDirection:J,stopOnExit:X=!1}={})=>{let K=LA(Z,Q),z=new AbortController;try{await Promise.race([...X?[Q.exitPromise]:[],TA(Z,{cleanup:!0,signal:z.signal})])}catch(H){if(!K.stdinCleanedUp)CA(H,Y,Q,J)}finally{z.abort()}},LA=(Z,{originalStreams:[Y],subprocess:Q})=>{let J={stdinCleanedUp:!1};if(Z===Y)IA(Z,Q,J);return J},IA=(Z,Y,Q)=>{let{_destroy:J}=Z;Z._destroy=(...X)=>{AA(Y,Q),J.call(Z,...X)}},AA=({exitCode:Z,signalCode:Y},Q)=>{if(Z!==null||Y!==null)Q.stdinCleanedUp=!0},CA=(Z,Y,Q,J)=>{if(!EA(Z,Y,Q,J))throw Z},EA=(Z,Y,Q,J=!0)=>{if(Q.propagating)return pB(Z)||X2(Z);return Q.propagating=!0,t3(Q,Y)===J?pB(Z):X2(Z)},t3=({fileDescriptors:Z},Y)=>Y!=="all"&&Z[Y].direction==="input",X2=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",pB=(Z)=>Z?.code==="EPIPE";var K2=()=>{};var dB=({subprocess:Z,encoding:Y,buffer:Q,maxBuffer:J,lines:X,stripFinalNewline:K,verboseInfo:z,streamInfo:H})=>Z.stdio.map((W,q)=>e3({stream:W,fdNumber:q,encoding:Y,buffer:Q[q],maxBuffer:J[q],lines:X[q],allMixed:!1,stripFinalNewline:K,verboseInfo:z,streamInfo:H})),e3=async({stream:Z,fdNumber:Y,encoding:Q,buffer:J,maxBuffer:X,lines:K,allMixed:z,stripFinalNewline:H,verboseInfo:W,streamInfo:q})=>{if(!Z)return;let G=cZ(Z,Y,q);if(t3(q,Y)){await G;return}let[U]=await Promise.all([mB({stream:Z,onStreamEnd:G,fdNumber:Y,encoding:Q,buffer:J,maxBuffer:X,lines:K,allMixed:z,stripFinalNewline:H,verboseInfo:W,streamInfo:q}),G]);return U};var ZJ=_(()=>{r3();K2()});var cB=({stdout:Z,stderr:Y},{all:Q})=>Q&&(Z||Y)?C4([Z,Y].filter(Boolean)):void 0,lB=({subprocess:Z,encoding:Y,buffer:Q,maxBuffer:J,lines:X,stripFinalNewline:K,verboseInfo:z,streamInfo:H})=>e3({...xA(Z,Q),fdNumber:"all",encoding:Y,maxBuffer:J[1]+J[2],lines:X[1]||X[2],allMixed:SA(Z),stripFinalNewline:K,verboseInfo:z,streamInfo:H}),xA=({stdout:Z,stderr:Y,all:Q},[,J,X])=>{let K=J||X;if(!K)return{stream:Q,buffer:K};if(!J)return{stream:Y,buffer:K};if(!X)return{stream:Z,buffer:K};return{stream:Q,buffer:K}},SA=({all:Z,stdout:Y,stderr:Q})=>Z&&Y&&Q&&Y.readableObjectMode!==Q.readableObjectMode;var YJ=_(()=>{r5();ZJ()});var iB=(Z)=>B8(Z,"ipc"),nB=(Z,Y)=>{let Q=oY(Z);r6({type:"ipc",verboseMessage:Q,fdNumber:"ipc",verboseInfo:Y})};var oB=_(()=>{$8();p1()});var aB=async({subprocess:Z,buffer:Y,maxBuffer:Q,ipc:J,ipcOutput:X,verboseInfo:K})=>{if(!J)return X;let z=iB(K),H=_1(Y,"ipc"),W=_1(Q,"ipc");for await(let q of y3({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:J,shouldAwait:!1,reference:!0})){if(H)DU(Z,X,W),X.push(q);if(z)nB(q,K)}return X},sB=async(Z,Y)=>{return await Promise.allSettled([Z]),Y};var rB=_(()=>{L4();oB();N1();b3()});import{once as kA}from"node:events";var tB=async({subprocess:Z,options:{encoding:Y,buffer:Q,maxBuffer:J,lines:X,timeoutDuration:K,cancelSignal:z,gracefulCancel:H,forceKillAfterDelay:W,stripFinalNewline:q,ipc:G,ipcInput:U},context:B,verboseInfo:F,fileDescriptors:$,originalStreams:O,onInternalError:D,controller:j})=>{let M=gV(Z,B),T={originalStreams:O,fileDescriptors:$,subprocess:Z,exitPromise:M,propagating:!1},N=dB({subprocess:Z,encoding:Y,buffer:Q,maxBuffer:J,lines:X,stripFinalNewline:q,verboseInfo:F,streamInfo:T}),L=lB({subprocess:Z,encoding:Y,buffer:Q,maxBuffer:J,lines:X,stripFinalNewline:q,verboseInfo:F,streamInfo:T}),x=[],S=aB({subprocess:Z,buffer:Q,maxBuffer:J,ipc:G,ipcOutput:x,verboseInfo:F}),g=PA(O,Z,T),h=vA($,T);try{return await Promise.race([Promise.all([{},uV(M),Promise.all(N),L,S,dG(Z,U),...g,...h]),D,yA(Z,j),...hG(Z,K,B,j),...XG({subprocess:Z,cancelSignal:z,gracefulCancel:H,context:B,controller:j}),...bG({subprocess:Z,cancelSignal:z,gracefulCancel:H,forceKillAfterDelay:W,context:B,controller:j})])}catch(f){return B.terminationReason??="other",Promise.all([{error:f},M,Promise.all(N.map((v)=>s3(v))),s3(L),sB(S,x),Promise.allSettled(g),Promise.allSettled(h)])}},PA=(Z,Y,Q)=>Z.map((J,X)=>J===Y.stdio[X]?void 0:cZ(J,X,Q)),vA=(Z,Y)=>Z.flatMap(({stdioItems:Q},J)=>Q.filter(({value:X,stream:K=X})=>p6(K,{checkOpen:!1})&&!m6(K)).map(({type:X,value:K,stream:z=K})=>cZ(z,J,Y,{isSameDirection:v6.has(X),stopOnExit:X==="native"}))),yA=async(Z,{signal:Y})=>{let[Q]=await kA(Z,"error",{signal:Y});throw Q};var eB=_(()=>{Z3();l9();e9();D1();W6();r3();rB();Q3();YJ();ZJ();P3();K2()});var Z$=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),lZ=(Z,Y,Q)=>{let J=Z[Q];if(!J.has(Y))J.set(Y,[]);let X=J.get(Y),K=e6();return X.push(K),{resolve:K.resolve.bind(K),promises:X}},A8=async({resolve:Z,promises:Y},Q)=>{Z();let[J]=await Promise.race([Promise.allSettled([!0,Q]),Promise.all([!1,...Y])]);return!J};var z2=()=>{};import{finished as Y$}from"node:stream/promises";var QJ=async(Z)=>{if(Z===void 0)return;try{await JJ(Z)}catch{}},Q$=async(Z)=>{if(Z===void 0)return;try{await XJ(Z)}catch{}},JJ=async(Z)=>{await Y$(Z,{cleanup:!0,readable:!1,writable:!0})},XJ=async(Z)=>{await Y$(Z,{cleanup:!0,readable:!0,writable:!1})},H2=async(Z,Y)=>{if(await Z,Y)throw Y},W2=(Z,Y,Q)=>{if(Q&&!X2(Q))Z.destroy(Q);else if(Y)Z.destroy()};var KJ=_(()=>{K2()});import{Readable as bA}from"node:stream";import{callbackify as fA}from"node:util";var J$=({subprocess:Z,concurrentStreams:Y,encoding:Q},{from:J,binary:X=!0,preserveNewlines:K=!0}={})=>{let z=X||j6.has(Q),{subprocessStdout:H,waitReadableDestroy:W}=zJ(Z,J,Y),{readableEncoding:q,readableObjectMode:G,readableHighWaterMark:U}=HJ(H,z),{read:B,onStdoutDataDone:F}=WJ({subprocessStdout:H,subprocess:Z,binary:z,encoding:Q,preserveNewlines:K}),$=new bA({read:B,destroy:fA(GJ.bind(void 0,{subprocessStdout:H,subprocess:Z,waitReadableDestroy:W})),highWaterMark:U,objectMode:G,encoding:q});return qJ({subprocessStdout:H,onStdoutDataDone:F,readable:$,subprocess:Z}),$},zJ=(Z,Y,Q)=>{let J=_8(Z,Y),X=lZ(Q,J,"readableDestroy");return{subprocessStdout:J,waitReadableDestroy:X}},HJ=({readableEncoding:Z,readableObjectMode:Y,readableHighWaterMark:Q},J)=>J?{readableEncoding:Z,readableObjectMode:Y,readableHighWaterMark:Q}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:a3},WJ=({subprocessStdout:Z,subprocess:Y,binary:Q,encoding:J,preserveNewlines:X})=>{let K=e6(),z=Q2({subprocessStdout:Z,subprocess:Y,binary:Q,shouldEncode:!Q,encoding:J,preserveNewlines:X});return{read(){hA(this,z,K)},onStdoutDataDone:K}},hA=async(Z,Y,Q)=>{try{let{value:J,done:X}=await Y.next();if(X)Q.resolve();else Z.push(J)}catch{}},qJ=async({subprocessStdout:Z,onStdoutDataDone:Y,readable:Q,subprocess:J,subprocessStdin:X})=>{try{if(await XJ(Z),await J,await QJ(X),await Y,Q.readable)Q.push(null)}catch(K){await QJ(X),X$(Q,K)}},GJ=async({subprocessStdout:Z,subprocess:Y,waitReadableDestroy:Q},J)=>{if(await A8(Q,Y))X$(Z,J),await H2(Y,J)},X$=(Z,Y)=>{W2(Z,Z.readable,Y)};var UJ=_(()=>{w4();l1();J2();z2();KJ()});import{Writable as gA}from"node:stream";import{callbackify as K$}from"node:util";var z$=({subprocess:Z,concurrentStreams:Y},{to:Q}={})=>{let{subprocessStdin:J,waitWritableFinal:X,waitWritableDestroy:K}=VJ(Z,Q,Y),z=new gA({...BJ(J,Z,X),destroy:K$(FJ.bind(void 0,{subprocessStdin:J,subprocess:Z,waitWritableFinal:X,waitWritableDestroy:K})),highWaterMark:J.writableHighWaterMark,objectMode:J.writableObjectMode});return $J(J,z),z},VJ=(Z,Y,Q)=>{let J=W5(Z,Y),X=lZ(Q,J,"writableFinal"),K=lZ(Q,J,"writableDestroy");return{subprocessStdin:J,waitWritableFinal:X,waitWritableDestroy:K}},BJ=(Z,Y,Q)=>({write:mA.bind(void 0,Z),final:K$(uA.bind(void 0,Z,Y,Q))}),mA=(Z,Y,Q,J)=>{if(Z.write(Y,Q))J();else Z.once("drain",J)},uA=async(Z,Y,Q)=>{if(await A8(Q,Y)){if(Z.writable)Z.end();await Y}},$J=async(Z,Y,Q)=>{try{if(await JJ(Z),Y.writable)Y.end()}catch(J){await Q$(Q),H$(Y,J)}},FJ=async({subprocessStdin:Z,subprocess:Y,waitWritableFinal:Q,waitWritableDestroy:J},X)=>{if(await A8(Q,Y),await A8(J,Y))H$(Z,X),await H2(Y,X)},H$=(Z,Y)=>{W2(Z,Z.writable,Y)};var OJ=_(()=>{l1();z2();KJ()});import{Duplex as pA}from"node:stream";import{callbackify as dA}from"node:util";var W$=({subprocess:Z,concurrentStreams:Y,encoding:Q},{from:J,to:X,binary:K=!0,preserveNewlines:z=!0}={})=>{let H=K||j6.has(Q),{subprocessStdout:W,waitReadableDestroy:q}=zJ(Z,J,Y),{subprocessStdin:G,waitWritableFinal:U,waitWritableDestroy:B}=VJ(Z,X,Y),{readableEncoding:F,readableObjectMode:$,readableHighWaterMark:O}=HJ(W,H),{read:D,onStdoutDataDone:j}=WJ({subprocessStdout:W,subprocess:Z,binary:H,encoding:Q,preserveNewlines:z}),M=new pA({read:D,...BJ(G,Z,U),destroy:dA(cA.bind(void 0,{subprocessStdout:W,subprocessStdin:G,subprocess:Z,waitReadableDestroy:q,waitWritableFinal:U,waitWritableDestroy:B})),readableHighWaterMark:O,writableHighWaterMark:G.writableHighWaterMark,readableObjectMode:$,writableObjectMode:G.writableObjectMode,encoding:F});return qJ({subprocessStdout:W,onStdoutDataDone:j,readable:M,subprocess:Z,subprocessStdin:G}),$J(G,M,W),M},cA=async({subprocessStdout:Z,subprocessStdin:Y,subprocess:Q,waitReadableDestroy:J,waitWritableFinal:X,waitWritableDestroy:K},z)=>{await Promise.all([GJ({subprocessStdout:Z,subprocess:Q,waitReadableDestroy:J},z),FJ({subprocessStdin:Y,subprocess:Q,waitWritableFinal:X,waitWritableDestroy:K},z)])};var q$=_(()=>{w4();UJ();OJ()});var RJ=(Z,Y,{from:Q,binary:J=!1,preserveNewlines:X=!1}={})=>{let K=J||j6.has(Y),z=_8(Z,Q),H=Q2({subprocessStdout:z,subprocess:Z,binary:K,shouldEncode:!0,encoding:Y,preserveNewlines:X});return lA(H,z,Z)},lA=async function*(Z,Y,Q){try{yield*Z}finally{if(Y.readable)Y.destroy();await Q}};var G$=_(()=>{w4();l1();J2()});var U$=(Z,{encoding:Y})=>{let Q=Z$();Z.readable=J$.bind(void 0,{subprocess:Z,concurrentStreams:Q,encoding:Y}),Z.writable=z$.bind(void 0,{subprocess:Z,concurrentStreams:Q}),Z.duplex=W$.bind(void 0,{subprocess:Z,concurrentStreams:Q,encoding:Y}),Z.iterable=RJ.bind(void 0,Z,Y),Z[Symbol.asyncIterator]=RJ.bind(void 0,Z,Y,{})};var V$=_(()=>{z2();UJ();OJ();q$();G$()});var B$=(Z,Y)=>{for(let[Q,J]of nA){let X=J.value.bind(Y);Reflect.defineProperty(Z,Q,{...J,value:X})}},iA,nA;var $$=_(()=>{iA=(async()=>{})().constructor.prototype,nA=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(iA,Z)])});import{setMaxListeners as oA}from"node:events";import{spawn as aA}from"node:child_process";var F$=(Z,Y,Q,J)=>{let{file:X,commandArguments:K,command:z,escapedCommand:H,startTime:W,verboseInfo:q,options:G,fileDescriptors:U}=sA(Z,Y,Q),{subprocess:B,promise:F}=tA({file:X,commandArguments:K,options:G,startTime:W,verboseInfo:q,command:z,escapedCommand:H,fileDescriptors:U});return B.pipe=Y2.bind(void 0,{source:B,sourcePromise:F,boundOptions:{},createNested:J}),B$(B,F),Z1.set(B,{options:G,fileDescriptors:U}),B},sA=(Z,Y,Q)=>{let{command:J,escapedCommand:X,startTime:K,verboseInfo:z}=rY(Z,Y,Q),{file:H,commandArguments:W,options:q}=T5(Z,Y,Q),G=rA(q),U=zB(G,z);return{file:H,commandArguments:W,command:J,escapedCommand:X,startTime:K,verboseInfo:z,options:G,fileDescriptors:U}},rA=({timeout:Z,signal:Y,...Q})=>{if(Y!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...Q,timeoutDuration:Z}},tA=({file:Z,commandArguments:Y,options:Q,startTime:J,verboseInfo:X,command:K,escapedCommand:z,fileDescriptors:H})=>{let W;try{W=aA(...L5(Z,Y,Q))}catch($){return YB({error:$,command:K,escapedCommand:z,fileDescriptors:H,options:Q,startTime:J,verboseInfo:X})}let q=new AbortController;oA(Number.POSITIVE_INFINITY,q.signal);let G=[...W.stdio];RB(W,H,q),LB(W,Q,q);let U={},B=e6();W.kill=QG.bind(void 0,{kill:W.kill.bind(W),options:Q,onInternalError:B,context:U,controller:q}),W.all=cB(W,Q),U$(W,Q),tV(W,Q);let F=eA({subprocess:W,options:Q,startTime:J,verboseInfo:X,fileDescriptors:H,originalStreams:G,command:K,escapedCommand:z,context:U,onInternalError:B,controller:q});return{subprocess:W,promise:F}},eA=async({subprocess:Z,options:Y,startTime:Q,verboseInfo:J,fileDescriptors:X,originalStreams:K,command:z,escapedCommand:H,context:W,onInternalError:q,controller:G})=>{let[U,[B,F],$,O,D]=await tB({subprocess:Z,options:Y,context:W,verboseInfo:J,fileDescriptors:X,originalStreams:K,onInternalError:q,controller:G});G.abort(),q.resolve();let j=$.map((N,L)=>T1(N,Y,L)),M=T1(O,Y,"all"),T=ZC({errorInfo:U,exitCode:B,signal:F,stdio:j,all:M,ipcOutput:D,context:W,options:Y,command:z,escapedCommand:H,startTime:Q});return T8(T,J,Y)},ZC=({errorInfo:Z,exitCode:Y,signal:Q,stdio:J,all:X,ipcOutput:K,context:z,options:H,command:W,escapedCommand:q,startTime:G})=>("error"in Z)?fZ({error:Z.error,command:W,escapedCommand:q,timedOut:z.terminationReason==="timeout",isCanceled:z.terminationReason==="cancel"||z.terminationReason==="gracefulCancel",isGracefullyCanceled:z.terminationReason==="gracefulCancel",isMaxBuffer:Z.error instanceof j1,isForcefullyTerminated:z.isForcefullyTerminated,exitCode:Y,signal:Q,stdio:J,all:X,ipcOutput:K,options:H,startTime:G,isSync:!1}):y5({command:W,escapedCommand:q,stdio:J,all:X,ipcOutput:K,options:H,startTime:G});var O$=_(()=>{P5();x9();K3();l1();f3();hZ();b5();QB();HB();gZ();MB();X5();IB();fB();YJ();eB();V$();$$()});var q2=(Z,Y)=>{let Q=Object.fromEntries(Object.entries(Y).map(([J,X])=>[J,YC(J,Z[J],X)]));return{...Z,...Q}},YC=(Z,Y,Q)=>{if(QC.has(Z)&&C0(Y)&&C0(Q))return{...Y,...Q};return Q},QC;var R$=_(()=>{N1();QC=new Set(["env",...I9])});var o1=(Z,Y,Q,J)=>{let X=(z,H,W)=>o1(z,H,Q,W),K=(...z)=>JC({mapArguments:Z,deepOptions:Q,boundOptions:Y,setBoundExeca:J,createNested:X},...z);if(J!==void 0)J(K,X,Y);return K},JC=({mapArguments:Z,deepOptions:Y={},boundOptions:Q={},setBoundExeca:J,createNested:X},K,...z)=>{if(C0(K))return X(Z,q2(Q,K),J);let{file:H,commandArguments:W,options:q,isSync:G}=XC({mapArguments:Z,firstArgument:K,nextArguments:z,deepOptions:Y,boundOptions:Q});return G?cV(H,W,q):F$(H,W,q,X)},XC=({mapArguments:Z,firstArgument:Y,nextArguments:Q,deepOptions:J,boundOptions:X})=>{let K=MW(Y)?DW(Y,Q):[Y,...Q],[z,H,W]=hY(...K),q=q2(q2(J,X),W),{file:G=z,commandArguments:U=H,options:B=q,isSync:F=!1}=Z({file:z,commandArguments:H,options:q});return{file:G,commandArguments:U,options:B,isSync:F}};var M$=_(()=>{N9();_W();lV();O$();R$()});var D$=({file:Z,commandArguments:Y})=>N$(Z,Y),_$=({file:Z,commandArguments:Y})=>({...N$(Z,Y),isSync:!0}),N$=(Z,Y)=>{if(Y.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Z} ${Y}.`);let[Q,...J]=KC(Z);return{file:Q,commandArguments:J}},KC=(Z)=>{if(typeof Z!=="string")throw TypeError(`The command must be a string: ${String(Z)}.`);let Y=Z.trim();if(Y==="")return[];let Q=[];for(let J of Y.split(zC)){let X=Q.at(-1);if(X&&X.endsWith("\\"))Q[Q.length-1]=`${X.slice(0,-1)} ${J}`;else Q.push(J)}return Q},zC;var j$=_(()=>{zC=/ +/g});var w$=(Z,Y,Q)=>{Z.sync=Y(HC,Q),Z.s=Z.sync},T$=({options:Z})=>L$(Z),HC=({options:Z})=>({...L$(Z),isSync:!0}),L$=(Z)=>({options:{...WC(Z),...Z}}),WC=({input:Z,inputFile:Y,stdio:Q})=>Z===void 0&&Y===void 0&&Q===void 0?{stdin:"inherit"}:{},I$;var A$=_(()=>{I$={preferLocal:!0}});var Q1,Ni,ji,wi,Ti,Li,Ii,Ai,Ci,Ei;var G2=_(()=>{M$();j$();Y3();A$();f3();d1();Q1=o1(()=>({})),Ni=o1(()=>({isSync:!0})),ji=o1(D$),wi=o1(_$),Ti=o1(mG),Li=o1(T$,{},I$,w$),{sendMessage:Ii,getOneMessage:Ai,getEachMessage:Ci,getCancelSignal:Ei}=eV()});function qC(Z,Y){let Q=Z.slice(0,Y).split(/\r\n|\n|\r/g);return[Q.length,Q.pop().length+1]}function GC(Z,Y,Q){let J=Z.split(/\r\n|\n|\r/g),X="",K=(Math.log10(Y+1)|0)+1;for(let z=Y-1;z<=Y+1;z++){let H=J[z-1];if(!H)continue;if(X+=z.toString().padEnd(K," "),X+=": ",X+=H,X+=`
|
|
85
|
+
`,z===Y)X+=" ".repeat(K+Q+2),X+=`^
|
|
86
|
+
`}return X}var W0;var x4=_(()=>{/*!
|
|
87
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
88
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
89
|
+
*
|
|
90
|
+
* Redistribution and use in source and binary forms, with or without
|
|
91
|
+
* modification, are permitted provided that the following conditions are met:
|
|
92
|
+
*
|
|
93
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
94
|
+
* list of conditions and the following disclaimer.
|
|
95
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
96
|
+
* this list of conditions and the following disclaimer in the
|
|
97
|
+
* documentation and/or other materials provided with the distribution.
|
|
98
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
99
|
+
* may be used to endorse or promote products derived from this software without
|
|
100
|
+
* specific prior written permission.
|
|
101
|
+
*
|
|
102
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
103
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
104
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
105
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
106
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
107
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
108
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
109
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
110
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
111
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
112
|
+
*/W0=class W0 extends Error{line;column;codeblock;constructor(Z,Y){let[Q,J]=qC(Y.toml,Y.ptr),X=GC(Y.toml,Q,J);super(`Invalid TOML document: ${Z}
|
|
113
|
+
|
|
114
|
+
${X}`,Y);this.line=Q,this.column=J,this.codeblock=X}}});function UC(Z,Y){let Q=0;while(Z[Y-++Q]==="\\");return--Q&&Q%2}function U2(Z,Y=0,Q=Z.length){let J=Z.indexOf(`
|
|
115
|
+
`,Y);if(Z[J-1]==="\r")J--;return J<=Q?J:-1}function C8(Z,Y){for(let Q=Y;Q<Z.length;Q++){let J=Z[Q];if(J===`
|
|
116
|
+
`)return Q;if(J==="\r"&&Z[Q+1]===`
|
|
117
|
+
`)return Q+1;if(J<" "&&J!=="\t"||J==="")throw new W0("control characters are not allowed in comments",{toml:Z,ptr:Y})}return Z.length}function $6(Z,Y,Q,J){let X;while((X=Z[Y])===" "||X==="\t"||!Q&&(X===`
|
|
118
|
+
`||X==="\r"&&Z[Y+1]===`
|
|
119
|
+
`))Y++;return J||X!=="#"?Y:$6(Z,C8(Z,Y),Q)}function C$(Z,Y,Q,J,X=!1){if(!J)return Y=U2(Z,Y),Y<0?Z.length:Y;for(let K=Y;K<Z.length;K++){let z=Z[K];if(z==="#")K=U2(Z,K);else if(z===Q)return K+1;else if(z===J||X&&(z===`
|
|
120
|
+
`||z==="\r"&&Z[K+1]===`
|
|
121
|
+
`))return K}throw new W0("cannot find end of structure",{toml:Z,ptr:Y})}function V2(Z,Y){let Q=Z[Y],J=Q===Z[Y+1]&&Z[Y+1]===Z[Y+2]?Z.slice(Y,Y+3):Q;Y+=J.length-1;do Y=Z.indexOf(J,++Y);while(Y>-1&&Q!=="'"&&UC(Z,Y));if(Y>-1){if(Y+=J.length,J.length>1){if(Z[Y]===Q)Y++;if(Z[Y]===Q)Y++}}return Y}var iZ=_(()=>{x4();/*!
|
|
122
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
123
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
124
|
+
*
|
|
125
|
+
* Redistribution and use in source and binary forms, with or without
|
|
126
|
+
* modification, are permitted provided that the following conditions are met:
|
|
127
|
+
*
|
|
128
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
129
|
+
* list of conditions and the following disclaimer.
|
|
130
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
131
|
+
* this list of conditions and the following disclaimer in the
|
|
132
|
+
* documentation and/or other materials provided with the distribution.
|
|
133
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
134
|
+
* may be used to endorse or promote products derived from this software without
|
|
135
|
+
* specific prior written permission.
|
|
136
|
+
*
|
|
137
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
138
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
139
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
140
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
141
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
142
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
143
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
144
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
145
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
146
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
147
|
+
*/});var VC,a1;var MJ=_(()=>{/*!
|
|
148
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
149
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
150
|
+
*
|
|
151
|
+
* Redistribution and use in source and binary forms, with or without
|
|
152
|
+
* modification, are permitted provided that the following conditions are met:
|
|
153
|
+
*
|
|
154
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
155
|
+
* list of conditions and the following disclaimer.
|
|
156
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
157
|
+
* this list of conditions and the following disclaimer in the
|
|
158
|
+
* documentation and/or other materials provided with the distribution.
|
|
159
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
160
|
+
* may be used to endorse or promote products derived from this software without
|
|
161
|
+
* specific prior written permission.
|
|
162
|
+
*
|
|
163
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
164
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
165
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
166
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
167
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
168
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
169
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
170
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
171
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
172
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
173
|
+
*/VC=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;a1=class a1 extends Date{#Y=!1;#Q=!1;#Z=null;constructor(Z){let Y=!0,Q=!0,J="Z";if(typeof Z==="string"){let X=Z.match(VC);if(X){if(!X[1])Y=!1,Z=`0000-01-01T${Z}`;if(Q=!!X[2],Q&&Z[10]===" "&&(Z=Z.replace(" ","T")),X[2]&&+X[2]>23)Z="";else if(J=X[3]||null,Z=Z.toUpperCase(),!J&&Q)Z+="Z"}else Z=""}super(Z);if(!isNaN(this.getTime()))this.#Y=Y,this.#Q=Q,this.#Z=J}isDateTime(){return this.#Y&&this.#Q}isLocal(){return!this.#Y||!this.#Q||!this.#Z}isDate(){return this.#Y&&!this.#Q}isTime(){return this.#Q&&!this.#Y}isValid(){return this.#Y||this.#Q}toISOString(){let Z=super.toISOString();if(this.isDate())return Z.slice(0,10);if(this.isTime())return Z.slice(11,23);if(this.#Z===null)return Z.slice(0,-1);if(this.#Z==="Z")return Z;let Y=+this.#Z.slice(1,3)*60+ +this.#Z.slice(4,6);return Y=this.#Z[0]==="-"?Y:-Y,new Date(this.getTime()-Y*60000).toISOString().slice(0,-1)+this.#Z}static wrapAsOffsetDateTime(Z,Y="Z"){let Q=new a1(Z);return Q.#Z=Y,Q}static wrapAsLocalDateTime(Z){let Y=new a1(Z);return Y.#Z=null,Y}static wrapAsLocalDate(Z){let Y=new a1(Z);return Y.#Q=!1,Y.#Z=null,Y}static wrapAsLocalTime(Z){let Y=new a1(Z);return Y.#Y=!1,Y.#Z=null,Y}}});function B2(Z,Y=0,Q=Z.length){let J=Z[Y]==="'",X=Z[Y++]===Z[Y]&&Z[Y]===Z[Y+1];if(X){if(Q-=2,Z[Y+=2]==="\r")Y++;if(Z[Y]===`
|
|
174
|
+
`)Y++}let K=0,z,H="",W=Y;while(Y<Q-1){let q=Z[Y++];if(q===`
|
|
175
|
+
`||q==="\r"&&Z[Y]===`
|
|
176
|
+
`){if(!X)throw new W0("newlines are not allowed in strings",{toml:Z,ptr:Y-1})}else if(q<" "&&q!=="\t"||q==="")throw new W0("control characters are not allowed in strings",{toml:Z,ptr:Y-1});if(z){if(z=!1,q==="x"||q==="u"||q==="U"){let G=Z.slice(Y,Y+=q==="x"?2:q==="u"?4:8);if(!OC.test(G))throw new W0("invalid unicode escape",{toml:Z,ptr:K});try{H+=String.fromCodePoint(parseInt(G,16))}catch{throw new W0("invalid unicode escape",{toml:Z,ptr:K})}}else if(X&&(q===`
|
|
177
|
+
`||q===" "||q==="\t"||q==="\r")){if(Y=$6(Z,Y-1,!0),Z[Y]!==`
|
|
178
|
+
`&&Z[Y]!=="\r")throw new W0("invalid escape: only line-ending whitespace may be escaped",{toml:Z,ptr:K});Y=$6(Z,Y)}else if(q in E$)H+=E$[q];else throw new W0("unrecognized escape sequence",{toml:Z,ptr:K});W=Y}else if(!J&&q==="\\")K=Y-1,z=!0,H+=Z.slice(W,K)}return H+Z.slice(W,Q-1)}function x$(Z,Y,Q,J){if(Z==="true")return!0;if(Z==="false")return!1;if(Z==="-inf")return-1/0;if(Z==="inf"||Z==="+inf")return 1/0;if(Z==="nan"||Z==="+nan"||Z==="-nan")return NaN;if(Z==="-0")return J?0n:0;let X=BC.test(Z);if(X||$C.test(Z)){if(FC.test(Z))throw new W0("leading zeroes are not allowed",{toml:Y,ptr:Q});Z=Z.replace(/_/g,"");let z=+Z;if(isNaN(z))throw new W0("invalid number",{toml:Y,ptr:Q});if(X){if((X=!Number.isSafeInteger(z))&&!J)throw new W0("integer value cannot be represented losslessly",{toml:Y,ptr:Q});if(X||J===!0)z=BigInt(Z)}return z}let K=new a1(Z);if(!K.isValid())throw new W0("invalid value",{toml:Y,ptr:Q});return K}var BC,$C,FC,OC,E$;var DJ=_(()=>{iZ();MJ();x4();/*!
|
|
179
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
180
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
181
|
+
*
|
|
182
|
+
* Redistribution and use in source and binary forms, with or without
|
|
183
|
+
* modification, are permitted provided that the following conditions are met:
|
|
184
|
+
*
|
|
185
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
186
|
+
* list of conditions and the following disclaimer.
|
|
187
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
188
|
+
* this list of conditions and the following disclaimer in the
|
|
189
|
+
* documentation and/or other materials provided with the distribution.
|
|
190
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
191
|
+
* may be used to endorse or promote products derived from this software without
|
|
192
|
+
* specific prior written permission.
|
|
193
|
+
*
|
|
194
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
195
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
196
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
197
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
198
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
199
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
200
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
201
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
202
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
203
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
204
|
+
*/BC=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,$C=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,FC=/^[+-]?0[0-9_]/,OC=/^[0-9a-f]{2,8}$/i,E$={b:"\b",t:"\t",n:`
|
|
205
|
+
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"}});function RC(Z,Y,Q){let J=Z.slice(Y,Q),X=J.indexOf("#");if(X>-1)C8(Z,X),J=J.slice(0,X);return[J.trimEnd(),X]}function nZ(Z,Y,Q,J,X){if(J===0)throw new W0("document contains excessively nested structures. aborting.",{toml:Z,ptr:Y});let K=Z[Y];if(K==="["||K==="{"){let[W,q]=K==="["?k$(Z,Y,J,X):S$(Z,Y,J,X);if(Q){if(q=$6(Z,q),Z[q]===",")q++;else if(Z[q]!==Q)throw new W0("expected comma or end of structure",{toml:Z,ptr:q})}return[W,q]}let z;if(K==='"'||K==="'"){z=V2(Z,Y);let W=B2(Z,Y,z);if(Q){if(z=$6(Z,z),Z[z]&&Z[z]!==","&&Z[z]!==Q&&Z[z]!==`
|
|
206
|
+
`&&Z[z]!=="\r")throw new W0("unexpected character encountered",{toml:Z,ptr:z});z+=+(Z[z]===",")}return[W,z]}z=C$(Z,Y,",",Q);let H=RC(Z,Y,z-+(Z[z-1]===","));if(!H[0])throw new W0("incomplete key-value declaration: no value specified",{toml:Z,ptr:Y});if(Q&&H[1]>-1)z=$6(Z,Y+H[1]),z+=+(Z[z]===",");return[x$(H[0],Z,Y,X),z]}var _J=_(()=>{DJ();NJ();iZ();x4();/*!
|
|
207
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
208
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
209
|
+
*
|
|
210
|
+
* Redistribution and use in source and binary forms, with or without
|
|
211
|
+
* modification, are permitted provided that the following conditions are met:
|
|
212
|
+
*
|
|
213
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
214
|
+
* list of conditions and the following disclaimer.
|
|
215
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
216
|
+
* this list of conditions and the following disclaimer in the
|
|
217
|
+
* documentation and/or other materials provided with the distribution.
|
|
218
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
219
|
+
* may be used to endorse or promote products derived from this software without
|
|
220
|
+
* specific prior written permission.
|
|
221
|
+
*
|
|
222
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
223
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
224
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
225
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
226
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
227
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
228
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
229
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
230
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
231
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
232
|
+
*/});function $2(Z,Y,Q="="){let J=Y-1,X=[],K=Z.indexOf(Q,Y);if(K<0)throw new W0("incomplete key-value: cannot find end of key",{toml:Z,ptr:Y});do{let z=Z[Y=++J];if(z!==" "&&z!=="\t")if(z==='"'||z==="'"){if(z===Z[Y+1]&&z===Z[Y+2])throw new W0("multiline strings are not allowed in keys",{toml:Z,ptr:Y});let H=V2(Z,Y);if(H<0)throw new W0("unfinished string encountered",{toml:Z,ptr:Y});J=Z.indexOf(".",H);let W=Z.slice(H,J<0||J>K?K:J),q=U2(W);if(q>-1)throw new W0("newlines are not allowed in keys",{toml:Z,ptr:Y+J+q});if(W.trimStart())throw new W0("found extra tokens after the string part",{toml:Z,ptr:H});if(K<H){if(K=Z.indexOf(Q,H),K<0)throw new W0("incomplete key-value: cannot find end of key",{toml:Z,ptr:Y})}X.push(B2(Z,Y,H))}else{J=Z.indexOf(".",Y);let H=Z.slice(Y,J<0||J>K?K:J);if(!MC.test(H))throw new W0("only letter, numbers, dashes and underscores are allowed in keys",{toml:Z,ptr:Y});X.push(H.trimEnd())}}while(J+1&&J<K);return[X,$6(Z,K+1,!0,!0)]}function S$(Z,Y,Q,J){let X={},K=new Set,z;Y++;while((z=Z[Y++])!=="}"&&z)if(z===",")throw new W0("expected value, found comma",{toml:Z,ptr:Y-1});else if(z==="#")Y=C8(Z,Y);else if(z!==" "&&z!=="\t"&&z!==`
|
|
233
|
+
`&&z!=="\r"){let H,W=X,q=!1,[G,U]=$2(Z,Y-1);for(let $=0;$<G.length;$++){if($)W=q?W[H]:W[H]={};if(H=G[$],(q=Object.hasOwn(W,H))&&(typeof W[H]!=="object"||K.has(W[H])))throw new W0("trying to redefine an already defined value",{toml:Z,ptr:Y});if(!q&&H==="__proto__")Object.defineProperty(W,H,{enumerable:!0,configurable:!0,writable:!0})}if(q)throw new W0("trying to redefine an already defined value",{toml:Z,ptr:Y});let[B,F]=nZ(Z,U,"}",Q-1,J);K.add(B),W[H]=B,Y=F}if(!z)throw new W0("unfinished table encountered",{toml:Z,ptr:Y});return[X,Y]}function k$(Z,Y,Q,J){let X=[],K;Y++;while((K=Z[Y++])!=="]"&&K)if(K===",")throw new W0("expected value, found comma",{toml:Z,ptr:Y-1});else if(K==="#")Y=C8(Z,Y);else if(K!==" "&&K!=="\t"&&K!==`
|
|
234
|
+
`&&K!=="\r"){let z=nZ(Z,Y-1,"]",Q-1,J);X.push(z[0]),Y=z[1]}if(!K)throw new W0("unfinished array encountered",{toml:Z,ptr:Y});return[X,Y]}var MC;var NJ=_(()=>{DJ();_J();iZ();x4();/*!
|
|
235
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
236
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
237
|
+
*
|
|
238
|
+
* Redistribution and use in source and binary forms, with or without
|
|
239
|
+
* modification, are permitted provided that the following conditions are met:
|
|
240
|
+
*
|
|
241
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
242
|
+
* list of conditions and the following disclaimer.
|
|
243
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
244
|
+
* this list of conditions and the following disclaimer in the
|
|
245
|
+
* documentation and/or other materials provided with the distribution.
|
|
246
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
247
|
+
* may be used to endorse or promote products derived from this software without
|
|
248
|
+
* specific prior written permission.
|
|
249
|
+
*
|
|
250
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
251
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
252
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
253
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
254
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
255
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
256
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
257
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
258
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
259
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
260
|
+
*/MC=/^[a-zA-Z0-9-_]+[ \t]*$/});function P$(Z,Y,Q,J){let X=Y,K=Q,z,H=!1,W;for(let q=0;q<Z.length;q++){if(q){if(X=H?X[z]:X[z]={},K=(W=K[z]).c,J===0&&(W.t===1||W.t===2))return null;if(W.t===2){let G=X.length-1;X=X[G],K=K[G].c}}if(z=Z[q],(H=Object.hasOwn(X,z))&&K[z]?.t===0&&K[z]?.d)return null;if(!H){if(z==="__proto__")Object.defineProperty(X,z,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(K,z,{enumerable:!0,configurable:!0,writable:!0});K[z]={t:q<Z.length-1&&J===2?3:J,d:!1,i:0,c:{}}}}if(W=K[z],W.t!==J&&!(J===1&&W.t===3))return null;if(J===2){if(!W.d)W.d=!0,X[z]=[];X[z].push(X={}),W.c[W.i++]=W={t:1,d:!1,i:0,c:{}}}if(W.d)return null;if(W.d=!0,J===1)X=H?X[z]:X[z]={};else if(J===0&&H)return null;return[z,X,W.c]}function jJ(Z,{maxDepth:Y=1000,integersAsBigInt:Q}={}){let J={},X={},K=J,z=X;for(let H=$6(Z,0);H<Z.length;){if(Z[H]==="["){let W=Z[++H]==="[",q=$2(Z,H+=+W,"]");if(W){if(Z[q[1]-1]!=="]")throw new W0("expected end of table declaration",{toml:Z,ptr:q[1]-1});q[1]++}let G=P$(q[0],J,X,W?2:1);if(!G)throw new W0("trying to redefine an already defined table or value",{toml:Z,ptr:H});z=G[2],K=G[1],H=q[1]}else{let W=$2(Z,H),q=P$(W[0],K,z,0);if(!q)throw new W0("trying to redefine an already defined table or value",{toml:Z,ptr:H});let G=nZ(Z,W[1],void 0,Y,Q);q[1][q[0]]=G[0],H=G[1]}if(H=$6(Z,H,!0),Z[H]&&Z[H]!==`
|
|
261
|
+
`&&Z[H]!=="\r")throw new W0("each key-value declaration must be followed by an end-of-line",{toml:Z,ptr:H});H=$6(Z,H)}return J}var v$=_(()=>{NJ();_J();iZ();x4();/*!
|
|
262
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
263
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
264
|
+
*
|
|
265
|
+
* Redistribution and use in source and binary forms, with or without
|
|
266
|
+
* modification, are permitted provided that the following conditions are met:
|
|
267
|
+
*
|
|
268
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
269
|
+
* list of conditions and the following disclaimer.
|
|
270
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
271
|
+
* this list of conditions and the following disclaimer in the
|
|
272
|
+
* documentation and/or other materials provided with the distribution.
|
|
273
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
274
|
+
* may be used to endorse or promote products derived from this software without
|
|
275
|
+
* specific prior written permission.
|
|
276
|
+
*
|
|
277
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
278
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
279
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
280
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
281
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
282
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
283
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
284
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
285
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
286
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
287
|
+
*/});function oZ(Z){let Y=typeof Z;if(Y==="object"){if(Array.isArray(Z))return"array";if(Z instanceof Date)return"date"}return Y}function DC(Z){for(let Y=0;Y<Z.length;Y++)if(oZ(Z[Y])!=="object")return!1;return Z.length!=0}function wJ(Z){return JSON.stringify(Z).replace(/\x7f/g,"\\u007f")}function TJ(Z,Y,Q,J){if(Q===0)throw Error("Could not stringify the object: maximum object depth exceeded");if(Y==="number"){if(isNaN(Z))return"nan";if(Z===1/0)return"inf";if(Z===-1/0)return"-inf";if(J&&Number.isInteger(Z))return Z.toFixed(1);return Z.toString()}if(Y==="bigint"||Y==="boolean")return Z.toString();if(Y==="string")return wJ(Z);if(Y==="date"){if(isNaN(Z.getTime()))throw TypeError("cannot serialize invalid date");return Z.toISOString()}if(Y==="object")return _C(Z,Q,J);if(Y==="array")return NC(Z,Q,J)}function _C(Z,Y,Q){let J=Object.keys(Z);if(J.length===0)return"{}";let X="{ ";for(let K=0;K<J.length;K++){let z=J[K];if(K)X+=", ";X+=y$.test(z)?z:wJ(z),X+=" = ",X+=TJ(Z[z],oZ(Z[z]),Y-1,Q)}return X+" }"}function NC(Z,Y,Q){if(Z.length===0)return"[]";let J="[ ";for(let X=0;X<Z.length;X++){if(X)J+=", ";if(Z[X]===null||Z[X]===void 0)throw TypeError("arrays cannot contain null or undefined values");J+=TJ(Z[X],oZ(Z[X]),Y-1,Q)}return J+" ]"}function jC(Z,Y,Q,J){if(Q===0)throw Error("Could not stringify the object: maximum object depth exceeded");let X="";for(let K=0;K<Z.length;K++)X+=`${X&&`
|
|
288
|
+
`}[[${Y}]]
|
|
289
|
+
`,X+=LJ(0,Z[K],Y,Q,J);return X}function LJ(Z,Y,Q,J,X){if(J===0)throw Error("Could not stringify the object: maximum object depth exceeded");let K="",z="",H=Object.keys(Y);for(let W=0;W<H.length;W++){let q=H[W];if(Y[q]!==null&&Y[q]!==void 0){let G=oZ(Y[q]);if(G==="symbol"||G==="function")throw TypeError(`cannot serialize values of type '${G}'`);let U=y$.test(q)?q:wJ(q);if(G==="array"&&DC(Y[q]))z+=(z&&`
|
|
290
|
+
`)+jC(Y[q],Q?`${Q}.${U}`:U,J-1,X);else if(G==="object"){let B=Q?`${Q}.${U}`:U;z+=(z&&`
|
|
291
|
+
`)+LJ(B,Y[q],B,J-1,X)}else K+=U,K+=" = ",K+=TJ(Y[q],G,J,X),K+=`
|
|
292
|
+
`}}if(Z&&(K||!z))K=K?`[${Z}]
|
|
293
|
+
${K}`:`[${Z}]`;return K&&z?`${K}
|
|
294
|
+
${z}`:K||z}function IJ(Z,{maxDepth:Y=1000,numbersAsFloat:Q=!1}={}){if(oZ(Z)!=="object")throw TypeError("stringify can only be called with an object");let J=LJ(0,Z,"",Y,Q);if(J[J.length-1]!==`
|
|
295
|
+
`)return J+`
|
|
296
|
+
`;return J}var y$;var b$=_(()=>{/*!
|
|
297
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
298
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
299
|
+
*
|
|
300
|
+
* Redistribution and use in source and binary forms, with or without
|
|
301
|
+
* modification, are permitted provided that the following conditions are met:
|
|
302
|
+
*
|
|
303
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
304
|
+
* list of conditions and the following disclaimer.
|
|
305
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
306
|
+
* this list of conditions and the following disclaimer in the
|
|
307
|
+
* documentation and/or other materials provided with the distribution.
|
|
308
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
309
|
+
* may be used to endorse or promote products derived from this software without
|
|
310
|
+
* specific prior written permission.
|
|
311
|
+
*
|
|
312
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
313
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
314
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
315
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
316
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
317
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
318
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
319
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
320
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
321
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
322
|
+
*/y$=/^[a-z0-9-_]+$/i});var f$=_(()=>{v$();b$();MJ();x4();/*!
|
|
323
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
324
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
325
|
+
*
|
|
326
|
+
* Redistribution and use in source and binary forms, with or without
|
|
327
|
+
* modification, are permitted provided that the following conditions are met:
|
|
328
|
+
*
|
|
329
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
330
|
+
* list of conditions and the following disclaimer.
|
|
331
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
332
|
+
* this list of conditions and the following disclaimer in the
|
|
333
|
+
* documentation and/or other materials provided with the distribution.
|
|
334
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
335
|
+
* may be used to endorse or promote products derived from this software without
|
|
336
|
+
* specific prior written permission.
|
|
337
|
+
*
|
|
338
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
339
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
340
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
341
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
342
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
343
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
344
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
345
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
346
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
347
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
348
|
+
*/});var AJ,S4,h$,CJ;var F2=_(()=>{B0();AJ=["**/package-lock.json","**/bun.lock","**/yarn.lock","**/pnpm-lock.yaml","**/npm-shrinkwrap.json","**/__snapshots__/*.snap","**/*.snap","**/dist/**","**/build/**","**/coverage/**","**/out/**","**/*.min.js","**/*.min.css"],S4={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,noisyFiles:[...AJ]},reword:{editor:null},cache:{enabled:!0,maxAgeMinutes:vY},parallel:{init:"submodule,env",envPaths:""},defaultEditor:"code",enhancedOutput:!0,useInlineSubmodule:"internal"},h$={"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",useInlineSubmodule:"GDX_USE_INLINE_SUBMODULE"},CJ={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","commit.noisyFiles":"Files treated as noisy in commit auto diff summary (array of glob patterns matching relative paths)",reword:"Configuration for rewording commit messages","reword.editor":"Editor command used by gdx reword (overrides global editor when set)",cache:`Configuration for caching mechanism.
|
|
349
|
+
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)",useInlineSubmodule:"[Experimental] Select submodule implementation mode (off: git-only, internal: gdx internal flow, all: reserved for broader internal usage)"}});import k4 from"fs";import g$ from"path";var m$=null,O2,wC,TC,LC,H0,R;var R0=_(()=>{G0();B0();A0();O2={off:-1,fatal:0,error:1,warn:2,info:3,debug:4,verbose:5},wC={off:"BgBlue",fatal:"BgRed",error:"BgRed",warn:"BgYellow",info:"BgBlue",debug:"BgMagenta",verbose:"BgCyan"},TC={off:"",fatal:"FATAL",error:"ERROR",warn:"WARN",info:"INFO",debug:"DEBUG",verbose:"VERBOSE"},LC={off:"Cyan",fatal:"Red",error:"Red",warn:"Yellow",info:"Cyan",debug:"Magenta",verbose:"Blue"};H0=class H0{static logFile=cH;static logLevel=O2[p.logLevel];static timeLabels=new Map;moduleName;static initialized=!1;static allLogs=[{timestamp:new Date().toISOString(),level:"info",message:`
|
|
350
|
+
|
|
351
|
+
=== New gdx session started ===
|
|
352
|
+
LocalMachineDate: ${new Date().toLocaleString()}
|
|
353
|
+
AppVersion: ${h6}
|
|
354
|
+
Platform: ${process.platform}
|
|
355
|
+
Arch: ${process.arch}
|
|
356
|
+
`,module:"logger"}];constructor(Z){this.moduleName=Z,H0.ensureInitialized()}static wouldLog(Z){return O2[Z]<=H0.logLevel}static ensureInitialized(){if(!H0.initialized){if(H0.initialized=!0,!$9)return;H0.initializeLogDirectory(),process.on("exit",()=>H0.flushLogs())}}static initializeLogDirectory(){let Z=g$.dirname(H0.logFile);try{if(!k4.existsSync(Z))k4.mkdirSync(Z,{recursive:!0})}catch{}}static logInternal(Z,Y,Q){let X={timestamp:new Date().toISOString(),level:Z,message:Y,module:Q};if(m$)m$(X);if(O2[Z]<=O2[p.logLevel])H0.printMessage(Z,Y,Q);if(!$9)return;H0.ensureInitialized(),H0.allLogs.push(X)}static printMessage(Z,Y,Q){let J=wC[Z],X=TC[Z],K=LC[Z],z=s(Y,100,{indent:" "}),H=V(J)+V("Bright")+V("White")+` ${X} `+V()+V("Invert")+` ${Q} ${V()+V(K)} ${z}`+V();if(Z==="fatal"||Z==="error")process.stderr.write(H+`
|
|
357
|
+
`);else process.stdout.write(H+`
|
|
358
|
+
`)}fatal(Z){H0.logInternal("fatal",Z,this.moduleName)}error(Z){H0.logInternal("error",Z,this.moduleName)}warn(Z){H0.logInternal("warn",Z,this.moduleName)}info(Z){H0.logInternal("info",Z,this.moduleName)}debug(Z){H0.logInternal("debug",Z,this.moduleName)}verbose(Z){H0.logInternal("verbose",Z,this.moduleName)}time(Z,Y){if(!Y){H0.timeLabels.set(Z,performance.now());return}return H0.time(Z,Y,this.moduleName)}timeEnd(Z){H0.timeEnd(Z,this.moduleName)}async timeAsync(Z,Y){return await H0.timeAsync(Z,Y,this.moduleName)}static fatal(Z,Y="gdx"){H0.logInternal("fatal",Z,Y)}static error(Z,Y="gdx"){H0.logInternal("error",Z,Y)}static warn(Z,Y="gdx"){H0.logInternal("warn",Z,Y)}static info(Z,Y="gdx"){H0.logInternal("info",Z,Y)}static debug(Z,Y="gdx"){H0.logInternal("debug",Z,Y)}static verbose(Z,Y="gdx"){H0.logInternal("verbose",Z,Y)}static async timeAsync(Z,Y,Q="gdx"){let J=performance.now();try{return await Y()}finally{let X=performance.now(),K=z8.getTimeFromMS(X-J).modern();H0.debug(`${Z} took ${K}`,Q)}}static time(Z,Y,Q="gdx"){let J=performance.now();if(!Y){H0.timeLabels.set(Z,J);return}try{return Y()}finally{let X=performance.now(),K=z8.getTimeFromMS(X-J).modern();H0.debug(`${Z} took ${K}`,Q)}}static timeEnd(Z,Y="gdx"){let Q=performance.now(),J=H0.timeLabels.get(Z);if(J){let X=z8.getTimeFromMS(Q-J).modern();H0.debug(`${Z} took ${X}`,Y),H0.timeLabels.delete(Z)}else H0.warn(`No such label '${Z}' for timeEnd`,Y)}static flushLogs(){if(H0.allLogs.length===0)return;try{let Z=g$.dirname(H0.logFile);if(!k4.existsSync(Z))k4.mkdirSync(Z,{recursive:!0});let Y="";if(k4.existsSync(H0.logFile))Y=k4.readFileSync(H0.logFile,"utf-8");let Q=H0.allLogs.map(({timestamp:K,level:z,message:H,module:W})=>{let q=z.toUpperCase().padEnd(5);return H=s(AH(H),100,{indent:33,redundancyLv:-1,mode:"strict"}),`${K} [${q}] ${W}: ${H}`}).join(`
|
|
359
|
+
`),J=Y?Y+`
|
|
360
|
+
`+Q:Q;if(Buffer.byteLength(J,"utf-8")>rH){let K=J.split(`
|
|
361
|
+
`),z=Math.floor(K.length/2);J=K.slice(z).join(`
|
|
362
|
+
`)}k4.writeFileSync(H0.logFile,J,"utf-8")}catch{}}};R=H0});import IC from"path";async function EJ(){u$??=import("keytar");let Z=await u$,Y=Z.default??Z;if(!Y||typeof Y.setPassword!=="function")throw new o("Keytar module does not expose setPassword.","KEYTAR_INVALID");return Y}class p${configPath;config=structuredClone(S4);loaded=!1;logger=new R("ConfigService");constructor(Z){this.configPath=Z||jZ}async load(){if(this.loaded)return;try{let Z=await l0(this.configPath,"utf-8"),Y=jJ(Z);this.config=this.mergeConfig(S4,Y)}catch(Z){let Y=new o(Z);if(Y.code!=="ENOENT")this.logger.warn(`Failed to parse config file at ${this.configPath}: ${Y.message}`);this.config=structuredClone(S4)}this.applyEnvOverrides(),this.loaded=!0}async save(){let Z=this.removeSecureKeys(this.config),Y=IJ(Z),Q=IC.dirname(this.configPath);if(!l(Q))z6(Q,{recursive:!0});await _6(this.configPath,Y,"utf-8")}get(Z,Y){let Q=Z.split("."),J=this.config;for(let X of Q)if(J&&typeof J==="object"&&X in J)J=J[X];else return Y;return J}async getSecure(Z,Y){let Q=this.get(Z);if(Q!==void 0)return Q;if(u1.includes(Z))try{let X=await(await EJ()).getPassword(PY,Z);if(X){let K=Z.split("."),z=this.config;for(let H=0;H<K.length-1;H++){let W=K[H];if(!(W in z)||typeof z[W]!=="object")z[W]={};z=z[W]}return z[K[K.length-1]]=X,X}}catch(J){this.logger.warn(`Failed to load secure key '${Z}' from keychain:
|
|
363
|
+
`+o.from(J).toString({color:!0}))}return Y}async set(Z,Y){let Q=Z.split("."),J=this.config;for(let z=0;z<Q.length-1;z++){let H=Q[z];if(!(H in J)||typeof J[H]!=="object")J[H]={};J=J[H]}let X=Q[Q.length-1],K=this.get(Z);if(K!==void 0){if(K===null){if(Y!==null&&typeof Y!=="string"){this.logger.warn(`Type mismatch for '${Z}'. Expected string or null, got ${typeof Y}. Ignoring value.`);return}}else if(typeof Y!==typeof K){this.logger.warn(`Type mismatch for '${Z}'. Expected ${typeof K}, got ${typeof Y}. Ignoring value.`);return}}if(u1.includes(Z))try{await(await EJ()).setPassword(PY,Z,String(Y))}catch(z){this.logger.warn(`Failed to save secure key '${Z}' to keychain:
|
|
364
|
+
`+o.from(z).toString({color:!0}))}J[X]=Y}getAll(){return this.config}getConfigPath(){return this.configPath}isDefault(Z){let Y=Z.split("."),Q=this.config,J=S4;for(let X of Y){if(Q&&typeof Q==="object"&&X in Q)Q=Q[X];else Q=void 0;if(J&&typeof J==="object"&&X in J)J=J[X];else J=void 0}return Q===J}mergeConfig(Z,Y){let Q=structuredClone(Z),J=(X,K,z="")=>{for(let H in K){let W=z?`${z}.${H}`:H,q=K[H],G=X[H];if(G===void 0)continue;if(typeof q==="object"&&q!==null&&!Array.isArray(q))if(typeof G==="object"&&G!==null)J(X[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")X[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 X[H]=q}};return J(Q,Y),Q}removeSecureKeys(Z){let Y=structuredClone(Z);for(let Q of u1){let J=Q.split("."),X=Y;for(let K=0;K<J.length-1;K++){if(!X[J[K]])return Y;X=X[J[K]]}delete X[J[J.length-1]]}return Y}async deleteSecureKey(Z){if(!u1.includes(Z))return!1;try{return await(await EJ()).deletePassword(PY,Z)}catch{return!1}}applyEnvOverrides(){for(let[Z,Y]of Object.entries(h$)){let Q=process.env[Y];if(Q!==void 0){let J=this.get(Z),X=Q;if(J===null)X=Q;else if(Array.isArray(J))try{let K=JSON.parse(Q);if(!Array.isArray(K)){this.logger.warn(`Environment variable ${Y} must be a JSON array. Ignoring.`);continue}X=K}catch{this.logger.warn(`Environment variable ${Y} has invalid JSON array value '${Q}'. Ignoring.`);continue}else if(typeof J==="number"){let K=Number(Q);if(!isNaN(K))X=K;else{this.logger.warn(`Environment variable ${Y} has invalid number value '${Q}'. Ignoring.`);continue}}else if(typeof J==="boolean")X=Q.toLowerCase()==="true";this.set(Z,X)}}}}function AC(){let Z=process.env.GDX_CONFIG_PATH;if(Z)return Z;if(l(jZ))return jZ;if(l(B9))return B9;return jZ}async function $0(){if(!R2)R2=new p$(AC()),await R2.load();return R2}var u$=null,R2=null;var F6=_(()=>{f$();Y6();F2();B0();G0();R0()});var E8=(Z)=>{return Z.map=(Y)=>E8((Q)=>Y(Z(Q))),Z.or=(Y)=>E8((Q)=>{try{return Z(Q)}catch(J){return Y(Q)}}),Z},xJ=()=>"bad banditype"(),d$=()=>E8((Z)=>Z),c$=(Z)=>E8((Y)=>Z.includes(Y)?Y:xJ()),l$=(Z)=>E8((Y)=>typeof Y===typeof Z?Y:xJ()),x8=()=>l$(""),L1=()=>l$(0),SJ=(Z)=>E8((Y)=>Y instanceof Z?Y:xJ()),kJ=(Z)=>SJ(Object).map((Y)=>{let Q={};for(let J in Y){let X=Z(Y[J]);X!==void 0&&(Q[J]=X)}return Q}),S8=(Z)=>SJ(Object).map((Y)=>{let Q={};for(let J in Z){let X=Z[J](Y[J]);X!==void 0&&(Q[J]=X)}return Q}),M2=(Z)=>SJ(Array).map((Y)=>Y.map(Z));var i$=()=>{};var EC,xC,SC,n$,D2;var _2=_(()=>{i$();B0();EC=S8({version:x8(),cacheSchemaVersion:c$([kY]),createdAt:L1(),updatedAt:L1(),lastPruneAt:L1()}),xC=S8({createdAt:L1(),updatedAt:L1(),expiresAt:L1()}),SC=S8({name:x8(),extensions:M2(x8()),filenames:M2(x8()),color:L1(),id:L1()}),n$=S8({lastUpdatedAt:x8(),languages:M2(SC)}),D2=S8({meta:EC,data:kJ(d$()),entryMeta:kJ(xC)})});import kC from"path";class a${cachePath;isDisabled=!1;cache={...o$};memoryData={};memoryEntryMeta={};loaded=!1;dirty=!1;loadingPromise=null;logger=new R("cache");constructor(Z){this.cachePath=Z||S6}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 Z=Date.now(),Y=0,Q=[];for(let[J,X]of Object.entries(this.cache.entryMeta))if(X.expiresAt!==PJ&&Z>X.expiresAt)Q.push(J);for(let J of Q){delete this.cache.entryMeta[J];let X=J.split("."),K=[],z=this.cache.data;for(let H of X)if(z&&typeof z==="object"&&H in z)K.push({obj:z,key:H}),z=z[H];else break;if(K.length>0){let H=K[K.length-1];delete H.obj[H.key],Y++}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=Z,Y>0)this.cache.meta.updatedAt=Z,this.dirty=!0;return Y}async load(){if(this.loaded)return;if(!(await $0()).get("cache.enabled")){this.resetCache(!1),this.loaded=!0,this.isDisabled=!0,this.logger.debug("Cache is disabled via configuration");return}try{let Y=await l0(this.cachePath,"utf-8"),Q=JSON.parse(Y);try{D2(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!==h6)this.logger.debug(`App version mismatch: stored=${Q.meta.version}, current=${h6}. Updating version number.`),Q.meta.version=h6,this.dirty=!0;this.cache=Q;let X=(Date.now()-this.cache.meta.lastPruneAt)/wZ;if(X>=aH){this.logger.debug(`Last prune was ${X.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(Y){let Q=new o(Y);if(Q.code!=="ENOENT")this.logger.debug(`Failed to parse cache file at ${this.cachePath}: ${Q.message}`);this.resetCache(!1)}this.loaded=!0}resetCache(Z=!0){if(this.cache=structuredClone(o$),Z)this.dirty=!0}resetMemoryCache(){this.memoryData={},this.memoryEntryMeta={}}async get(Z,Y){if(this.isDisabled)return Y;await this.ensureLoaded();let Q=this.cache.entryMeta[Z];if(!Q)return this.logger.debug(`Cache ${Z} missed.`),Y;if(Date.now()>Q.expiresAt)return this.logger.debug(`Cache entry expired: ${Z}. expiresAt=${new Date(Q.expiresAt).toISOString()}, now=${new Date().toISOString()}`),await this.delete(Z),Y;let J=Z.split("."),X=this.cache.data;for(let K of J)if(X&&typeof X==="object"&&K in X)X=X[K];else return Y;return this.logger.debug(`Cache ${Z} hit.`),X}async getOneOff(Z,Y){if(await this.ensureLoaded(),this.isDisabled)return Y;if(!this.memoryEntryMeta[Z])return this.logger.debug(`Memory cache ${Z} missed.`),Y;let J=Z.split("."),X=this.memoryData;for(let K of J)if(X&&typeof X==="object"&&K in X)X=X[K];else return Y;return this.logger.debug(`Memory cache ${Z} hit.`),X}async set(Z,Y,Q){if(this.isDisabled)return;let J=await $0();await this.ensureLoaded();let X=Z.split("."),K=this.cache.data,z=Q?.maxAgeMinutes??J.get("cache.maxAgeMinutes")??vY;this.logger.debug(`Setting cache ${Z} with maxAgeMinutes=${z}`);for(let G=0;G<X.length-1;G++){let U=X[G];if(!(U in K)||typeof K[U]!=="object")K[U]={};K=K[U]}let H=X[X.length-1];K[H]=Y;let W=Date.now(),q=Number.isFinite(z)?W+Math.max(z,0)*60*1000:PJ;this.cache.entryMeta[Z]={createdAt:this.cache.entryMeta[Z]?.createdAt??W,updatedAt:W,expiresAt:q},this.cache.meta.updatedAt=W,this.dirty=!0}async setOneOff(Z,Y){if(await this.ensureLoaded(),this.isDisabled)return;let Q=Z.split("."),J=this.memoryData;this.logger.debug(`Setting memory cache ${Z}`);for(let z=0;z<Q.length-1;z++){let H=Q[z];if(!(H in J)||typeof J[H]!=="object")J[H]={};J=J[H]}let X=Q[Q.length-1];J[X]=Y;let K=Date.now();this.memoryEntryMeta[Z]={createdAt:this.memoryEntryMeta[Z]?.createdAt??K,updatedAt:K}}async delete(Z){if(this.isDisabled)return!1;if(await this.ensureLoaded(),!this.cache.entryMeta[Z])return!1;delete this.cache.entryMeta[Z];let Y=Z.split("."),Q=[],J=this.cache.data;for(let X of Y)if(J&&typeof J==="object"&&X in J)Q.push({obj:J,key:X}),J=J[X];else return!1;if(Q.length>0){let X=Q[Q.length-1];delete X.obj[X.key]}for(let X=Q.length-2;X>=0;X--){let{obj:K,key:z}=Q[X],H=K[z];if(H&&typeof H==="object"&&Object.keys(H).length===0)delete K[z];else break}return this.cache.meta.updatedAt=Date.now(),this.dirty=!0,this.logger.debug(`Cache entry deleted: ${Z}`),!0}async deleteOneOff(Z){if(await this.ensureLoaded(),this.isDisabled)return!1;if(!this.memoryEntryMeta[Z])return!1;delete this.memoryEntryMeta[Z];let Y=Z.split("."),Q=[],J=this.memoryData;for(let X of Y)if(J&&typeof J==="object"&&X in J)Q.push({obj:J,key:X}),J=J[X];else return!1;if(Q.length>0){let X=Q[Q.length-1];delete X.obj[X.key]}for(let X=Q.length-2;X>=0;X--){let{obj:K,key:z}=Q[X],H=K[z];if(H&&typeof H==="object"&&Object.keys(H).length===0)delete K[z];else break}return this.logger.debug(`Memory cache entry deleted: ${Z}`),!0}async getAll(){return await this.ensureLoaded(),this.cache}getCachePath(){return this.cachePath}flush(){if(!this.dirty)return;try{let Z=kC.dirname(this.cachePath);z6(Z,{recursive:!0});let Y=JSON.stringify(this.cache);F1(this.cachePath,Y,"utf-8"),this.dirty=!1,this.logger.debug(`Cache flushed to ${this.cachePath}`)}catch(Z){let Y=new o(Z);this.logger.warn(`Failed to flush cache: ${Y.message}`)}}async clear(){await this.ensureLoaded(),this.resetCache(),this.resetMemoryCache()}}async function F0(){if(!s1){if(s1=new a$,await s1.ensureLoaded(),!s1.isDisabled)PC()}return s1}function N2(){s1=null}function PC(){R.debug("Registering cache flush hook on exit","cache"),IH(()=>{if(s1)s1.flush()})}var o$,PJ,s1=null;var I1=_(()=>{Y6();G0();B0();R0();F6();_2();o$={meta:{version:h6,cacheSchemaVersion:kY,createdAt:Date.now(),updatedAt:Date.now(),lastPruneAt:Date.now()},data:{},entryMeta:{}},PJ=Number.MAX_SAFE_INTEGER});async function s$(Z,Y){let Q=await F0(),J=`which.${Z}`,X=await Q.get(J);if(X!=null&&l(X))return X;try{let K=Y?await Y():await J1(Z);if(!K)return null;return await Q.set(J,K),K}catch(K){throw R.warn(`Failed to get which exec for ${Z}: ${K}`,"cache-ctrl"),K}}var r$=_(()=>{P0();I1();R0();Y6()});import k8 from"path";import{createInterface as vC}from"readline";import{writeFile as yC}from"fs/promises";import{unlink as bC}from"fs/promises";function P8(Z={}){let Y=new AbortController;return{$:Q1({cancelSignal:Y.signal,...Z,verbose:yJ}),abort:()=>Y.abort(),signal:Y.signal}}async function aZ(Z){let Y=vC({input:process.stdin,output:process.stdout});return new Promise((Q)=>{Y.question(Z,(J)=>{Y.close(),Q(J.trim())})})}async function J1(Z){return await s$(Z,async()=>{if(Z.includes(k8.sep)){let K=k8.resolve(Z);return await q9(K)?K:null}let Y=process.platform==="win32",Q=[""];if(Y)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(k8.dirname(process.argv[1]));if(J.push(k8.dirname(process.execPath)),process.env.PATH)J.push(...process.env.PATH.split(k8.delimiter));let X=[...new Set(J)];for(let K of X){if(!K)continue;for(let z of Q){let H=k8.join(K,Z+z);if(await q9(H))return H}}return null})}async function j2(Z){try{switch(process.platform){case"win32":return await E({input:Z})`clip`,!0;case"darwin":return await E({input:Z})`pbcopy`,!0;case"linux":try{return await E({input:Z})`xclip -selection clipboard`,!0}catch{return await E({input:Z})`xsel --clipboard --input`,!0}default:return!1}}catch{return!1}}function b0(Z={}){let Y=!Z.message;if(Z={message:"",interval:70,frames:nH,animateGradient:!1,gradientColor:k.Zinc050,gradientColorBg:k.Zinc400,gradientSpeed:0.13,gradientInterval:3,...Z},!process.stdout.isTTY)return{stop:()=>{},start:(W=!0)=>{if(W)process.stdout.write(`
|
|
365
|
+
`)},setMessage:(W)=>{},options:Z};let Q=0,J=0,X=!0,K=null,z=V(),H=()=>{if(!X)return;let W=Z.frames[Q%Z.frames.length];if(Z.message)if(Z.animateGradient&&e0.supportsColor>=3){let q=J%Z.gradientInterval;if(q<=1){let G=GW.easeInOut(q),U=WW(Z.message,Z.gradientColor,Z.gradientColorBg,G,0.3);W+=" "+U}else W+=" "+V(_4(Z.gradientColorBg))+Z.message+z;J+=Z.gradientSpeed??0.1}else W+=" "+Z.message;process.stdout.write("\r\x1B[K"+W),Q++};if(!Y)K=setInterval(H,Z.interval),process.stdout.write("\x1B[?25l"),H();return{stop:()=>{if(X=!1,K)clearInterval(K),K=null;process.stdout.write("\r\x1B[K\x1B[?25h")},start:(W=!0)=>{if(!X)process.stdout.write("\x1B[?25l"+(W?`
|
|
366
|
+
`:"")),X=!0,K=setInterval(H,Z.interval)},setMessage:(W)=>{Z.message=W,H()},options:Z}}async function e$(Z){let Q=(await $0()).getAll().defaultEditor,J=await J1(Q);if(!J)throw new o(`Default editor "${Q}" not found in PATH. Set a valid editor in the configuration.`,"EDITOR_NOT_FOUND");await D0`${J} ${Z}`}async function sZ(Z){if(!Z){if(R1)await bC(R1).catch(x6);p.exitCodeOverride=-1;return}if(R1)await yC(R1,Z,"utf-8");p.exitCodeOverride=R4}function w2(Z){let Y=[],Q="",J=!1,X=!1;for(let K=0;K<Z.length;K++){let z=Z[K];if(z==="'"&&!X)J=!J;else if(z==='"'&&!J)X=!X;else if(z===" "&&!J&&!X){if(Q)Y.push(Q),Q=""}else Q+=z}if(Q)Y.push(Q);return Y}async function T2(Z,Y,Q=null,J=">"){let X=0;try{if(Q){let{exitCode:K}=await Q1({stdout:{file:Q,append:J===">>"},stderr:"inherit"})`${Z} ${Y}`;X=K}else{let{exitCode:K}=await D0`${Z} ${Y}`;X=K}}catch(K){let z=o.from(K),H=K.signal;if(H)z.code=H;if(z.code==="SIGINT"||z.code==="SIGTERM"||z.code==="SIGABRT"||z.code==="SIGKILL")return R.debug(`Git command was killed by signal: ${z.code}. Treating as failure with exit code 1.`),R.verbose("Full error details: "+u(z,{color:!0})),1;if(z.code==="ENOENT")return R.error(`Git executable not found: "${Z}". Ensure git is installed and in your PATH.`),1;if(z.code==="EACCES")return R.error(`Permission denied when trying to execute git: "${Z}". Check your permissions for this executable.`),1;if(z.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(z.name===P6.name&&z.message.startsWith("Command failed"))return X||1;return R.error(`Command failed.
|
|
367
|
+
`+u(z,{color:!0})),1}return X??0}function yJ(Z,Y){if(Y.type!=="duration")return;let Q="done";if(Y.result.failed)Q="FAILED";else if(Y.result.timedOut)Q="TIMEOUT";else if(Y.result.isCanceled)Q="CANCELED";else if(Y.result.isTerminated)Q="TERMINATED";fC.debug(`${gC+t$}$ ${hC+Y.escapedCommand+t$} (${Q} in ${Y.result.durationMs}ms)`)}var fC,t$,hC,gC,vJ=()=>process.stdout.isTTY&&process.stdin.isTTY,E,D0;var P0=_(()=>{G2();G0();w0();I0();B0();F6();A0();r$();R0();fC=new R("shell"),t$=V("Dim"),hC=V(),gC=V("Bright"),E=Q1({stdout:"pipe",stderr:"pipe",verbose:yJ});D0=Q1({stdout:"inherit",stderr:"inherit",verbose:yJ})});import gJ from"crypto";import J0 from"path";function q6(Z,Y){let Q=gJ.createHash("sha1").update(Y).digest("hex");return`${Z}.${Q}`}function d6(Z,Y){let Q=Array.isArray(Z)?Z.join(" "):Z,J=Y?J0.resolve(Y):process.cwd();return`${Q}|${J}`}function mC(Z,Y){let Q=Array.isArray(Z)?Z[0]:Z;if(Y)return{gitExec:Q,repoPath:J0.resolve(Y)};if(Array.isArray(Z))for(let J=Z.length-2;J>=0;J--){if(Z[J]!=="-C")continue;let X=Z[J+1];if(typeof X==="string"&&X.trim().length>0)return{gitExec:Q,repoPath:J0.resolve(X)}}return{gitExec:Q,repoPath:process.cwd()}}function uC(Z){return Z.some((Y)=>/^head(?:[~^].*)?$/i.test(Y))}async function I2(Z,Y,Q){let J=mC(Z,Q);return await N0(J.gitExec,J.repoPath,Y)}async function v8(Z){try{await E`${Z} 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 mJ(Z,Y){let Q=await F0(),J=q6("git.stashEntry",`${d6(Z)}|${Y}`),X=await Q.getOneOff(J);if(X!==void 0)return X;try{let K=`stash@{${Y}}`,{stdout:z}=await E`${Z} rev-parse ${K}`,{stdout:H}=await E`${Z} log -1 --format=%s ${K}`,W={sha:z.trim(),message:H.trim()};return await Q.setOneOff(J,W),W}catch{return await Q.setOneOff(J,null),null}}async function YF(Z,Y,Q){await E`${Z} stash store -m ${Q} ${Y}`}function pC(Z){let Y=Z.trim();if(!Y)return"";Y=Y.replace(/\\+/g,"/");let Q=Y.match(/^(?:[^@]+@)?([^:/]+):(.+)$/);if(Q&&!Y.includes("://")){let J=Q[1].toLowerCase(),X=Q[2];return hJ(J,X)}try{let J=new URL(Y),X=J.hostname.toLowerCase(),K=J.pathname;return hJ(X,K)}catch{return hJ("",Y)}}async function dC(Z){let Y=await F0(),Q=q6("git.defaultRemoteName",d6(Z)),J=await Y.getOneOff(Q);if(J!==void 0)return J;let X=null;try{let{stdout:K}=await E`${Z} remote`,z=K.trim().split(`
|
|
368
|
+
`).map((H)=>H.trim()).filter(Boolean);if(z.length===0)X=null;else{let H="";try{let{stdout:W}=await E`${Z} rev-parse --abbrev-ref HEAD`,q=W.trim();if(q&&q!=="HEAD"){let{stdout:G}=await E`${Z} config branch.${q}.remote`;H=G.trim()}}catch{H=""}if(H&&z.includes(H))X=H;else if(z.includes("origin"))X="origin";else X=z[0]}}catch{X=null}return await Y.setOneOff(Q,X),X}async function A2(Z){let Y=await F0(),Q=q6("git.normalizedRemoteUrl",d6(Z)),J=await Y.getOneOff(Q);if(J!==void 0)return J;let X=await dC(Z);if(!X)return await Y.setOneOff(Q,null),null;try{let{stdout:K}=await E`${Z} remote get-url ${X}`,z=K.trim();if(!z)return await Y.setOneOff(Q,null),null;let W=pC(z)||null;return await Y.setOneOff(Q,W),W}catch{return await Y.setOneOff(Q,null),null}}async function C2(Z){let Y=await F0(),Q=q6("git.mainWorktreeRoot",d6(Z)),J=await Y.getOneOff(Q);if(J!==void 0)return J;let X="";try{let{stdout:K}=await E`${Z} rev-parse --show-toplevel`;X=K.trim()}catch{X=process.cwd()}try{let{stdout:K}=await E`${Z} rev-parse --git-common-dir`,z=K.trim();if(!z)return await Y.setOneOff(Q,X),X;let H=J0.isAbsolute(z)?z:J0.resolve(X,z);if(c0(H).includes("/.git/worktrees/")){let U=J0.dirname(J0.dirname(H)),F=J0.dirname(U)||X;return await Y.setOneOff(Q,F),F}try{let B=$1(H,"utf-8").split(`
|
|
369
|
+
`).map((F)=>F.trim()).find((F)=>F.toLowerCase().startsWith("gitdir:"));if(B){let F=B.split(":").slice(1).join(":").trim(),$=J0.isAbsolute(F)?F:J0.resolve(X,F);if(c0($).includes("/.git/worktrees/")){let D=J0.dirname(J0.dirname($)),M=J0.dirname(D)||X;return await Y.setOneOff(Q,M),M}}}catch{}let G=J0.dirname(H)||X;return await Y.setOneOff(Q,G),G}catch{return await Y.setOneOff(Q,X),X}}async function tZ(Z,Y){let Q=await rZ(Z,Y,"CHERRY_PICK_HEAD");return!!Q&&l(Q)}async function t1(Z,Y){let Q=await F0(),J=`git.config.${Y}`,X=await Q.get(J);if(X!==void 0)return R.debug(`Cache hit for ${J}`,"cache-ctrl"),X;try{let{stdout:K}=await E`${Z} config ${Y}`,z=K.trim();if(z)await Q.set(J,z),R.debug(`Cache store for ${J}: ${z}`,"cache-ctrl");return z}catch(K){return R.warn(`Git config ${Y} not found or failed`,"cache-ctrl"),R.debug(`Error details: ${o.from(K)}`,"cache-ctrl"),""}}async function QF(Z,Y=!1){let Q=await F0(),J=`${d6(Z)}|${Y?"remote":"local"}`,X=q6("git.branches",J),K=await Q.get(X);if(K)return R.debug(`Cache hit for ${X}`,"cache-ctrl"),K;try{let z=Y?["for-each-ref","--format=%(refname:short)","refs/remotes/"]:["for-each-ref","--format=%(refname:short)","refs/heads/"],{stdout:H}=await E`${Z} ${z}`,W=H.trim().split(`
|
|
370
|
+
`).filter((q)=>q.length>0);return await Q.set(X,W),R.debug(`Cache store for ${X}: ${W.length} branches`,"cache-ctrl"),W}catch(z){return R.warn(`Failed to get git branches: ${o.from(z)}`,"cache-ctrl"),[]}}async function cC(Z){let Y=await F0(),Q=q6("git.trackedUpstreamRef",d6(Z)),J=await Y.getOneOff(Q);if(J!==void 0)return J;let X=P8();try{let{stdout:K}=await X.$`${Z} rev-parse --abbrev-ref --symbolic-full-name @{u}`,z=K.trim();return await Y.setOneOff(Q,z),z||null}catch{return null}}async function JF(Z){let Y=await F0(),Q="git.version",J=await Y.get("git.version");if(J)return R.debug("Cache hit for git.version","cache-ctrl"),J;try{let{stdout:X}=await E`${Z} --version`,K=X.trim().match(/(\d{1,2}\.\d{1,3}\.\d{1,3})/i)?.[1]||"unknown";return await Y.set("git.version",K),R.debug(`Cache store for git.version: ${K}`,"cache-ctrl"),K}catch(X){throw R.warn(`Failed to get git version: ${X}`,"cache-ctrl"),X}}async function G6(Z){let Y=await F0(),Q=process.cwd(),J=Array.isArray(Z)?Z.join(" "):Z,K="git.repoRoot."+gJ.createHash("sha1").update(`${J}|${Q}`).digest("hex"),z=await Y.get(K);if(z&&l(z))return R.debug(`Cache hit for ${K}`,"cache-ctrl"),z;try{let{stdout:H}=await E`${Z} rev-parse --show-toplevel`,W=H.trim();return await Y.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 ZF(Z){let Y=c0(J0.resolve(Z));return process.platform==="win32"?Y.toLowerCase():Y}async function lC(Z){let Y=await F0(),Q=q6("git.worktreeList",d6(Z)),J=await Y.getOneOff(Q);if(J!==void 0)return J;try{let X=(await E`${Z} worktree list --porcelain`).stdout.trim();if(!X)return await Y.setOneOff(Q,[]),[];let K=[],z=null;for(let H of X.split(`
|
|
371
|
+
`)){if(!H.trim())continue;if(H.startsWith("worktree ")){if(z)K.push(z);z={path:H.slice(9).trim(),locked:!1,lockReason:null,prunable:!1};continue}if(!z)continue;if(H.startsWith("locked")){z.locked=!0;let W=H.slice(6).trim();z.lockReason=W.length>0?W:null}else if(H.startsWith("prunable"))z.prunable=!0}if(z)K.push(z);return await Y.setOneOff(Q,K),K}catch(X){return R.debug(u(X,{color:!0}),"git"),await Y.setOneOff(Q,[]),[]}}async function uJ(Z){let Y=await F0(),Q=q6("git.worktreeList",d6(Z));await Y.deleteOneOff(Q)}async function pJ(Z,Y){let Q=await lC(Z),J=ZF(Y);return Q.find((X)=>ZF(X.path)===J)??null}async function E2(Z){try{await E`${Z} worktree prune --expire now`}catch(Y){R.debug(u(Y,{color:!0}),"git")}finally{await uJ(Z)}}async function rZ(Z,Y,Q){let J=await F0(),X=`${d6(Z,Y)}|${Q}`,K=q6("git.path",X),z=await J.get(K);if(z!==void 0)return z;try{let H=(await E`${Z} -C ${Y} rev-parse --git-path ${Q}`).stdout.trim();if(!H)return await J.set(K,null,{maxAgeMinutes:bJ}),null;let W=J0.isAbsolute(H)?H:J0.resolve(Y,H);return await J.set(K,W,{maxAgeMinutes:bJ}),W}catch(H){return R.debug(u(H,{color:!0}),"git"),await J.set(K,null,{maxAgeMinutes:bJ}),null}}async function iC(Z,Y){let Q=await rZ(Z,Y,"HEAD");if(!Q)return null;let J=await _Z(Q),X,K="";try{let H=$1(Q,"utf-8").trim().match(/^ref:\s*(.+)$/i);if(H?.[1]){if(K=H[1].trim(),K){let W=await rZ(Z,Y,K);X=await _Z(W)}}}catch{}return`${J??"null"}|${K}|${X??"null"}`}async function N0(Z,Y,Q){let J=await F0(),X=Array.isArray(Q)?Q:Q.trim().split(/\s+/).filter(Boolean),K=X.join(" "),z=J0.resolve(Y),H=`${Z}|${z}|${K}`,W=q6("git.revParse",H),q=uC(X),G=q?await iC(Z,z):null;if(q&&G!==null){let $=await J.get(W);if($&&$.signature===G)return $.value}else{let $=await J.get(W);if($!==void 0)return $}let U=q?`${W}|${G??"none"}`:W,B=fJ.get(U);if(B)return await B;let F=(async()=>{try{let $=["-C",z,"rev-parse",...X],O=(await E`${Z} ${$}`).stdout.trim();if(q&&G!==null)await J.set(W,{value:O,signature:G},{maxAgeMinutes:L2});else await J.set(W,O,{maxAgeMinutes:L2});return O}catch{if(q&&G!==null)await J.set(W,{value:"",signature:G},{maxAgeMinutes:L2});else await J.set(W,"",{maxAgeMinutes:L2});return""}})();fJ.set(U,F);try{return await F}finally{fJ.delete(U)}}async function XF(Z,Y){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 X of Q){let K=await rZ(Z,Y,X.path);if(!K)continue;if(l(K))J.add(X.label)}return Array.from(J)}function A1(Z){return c0(Z.trim()).replace(/^\/+/,"").replace(/\/+$/,"")}function x2(Z){return Z.trim().replace(/\\/g,"/")}async function dJ(){let Y=(await $0()).get("useInlineSubmodule","internal");if(Y==="off"||Y==="internal"||Y==="all")return Y;return"internal"}function P4(Z,Y){if(!Y)return Z;return["-c","protocol.file.allow=always",...Z]}function KF(Z){if(!Z||Z.length===0)return[];let Y=new Set;for(let Q of Z){let J=A1(Q);if(!J)continue;Y.add(J)}return Array.from(Y)}function zF(Z,Y){if(!Y||Y.size===0)return!0;if(Y.has(Z))return!0;for(let Q of Y)if(Z.startsWith(Q+"/"))return!0;return!1}function cJ(Z){let Y=new Map,Q=J0.join(Z,".gitmodules");if(!l(Q))return Y;let J="";try{J=$1(Q,"utf-8")}catch{return Y}let X=J.split(/\r?\n/),K="",z="",H="",W="",q=()=>{if(!z)return;Y.set(z,{name:K||z,path:z,url:H,branch:W||void 0})};for(let G of X){let U=G.trim();if(!U||U.startsWith("#")||U.startsWith(";"))continue;let B=U.match(/^\[submodule\s+"(.+)"\]$/i);if(B){q(),K=B[1]?.trim()||"",z="",H="",W="";continue}let F=U.match(/^([a-zA-Z0-9._-]+)\s*=\s*(.*)$/);if(!F)continue;let $=F[1]?.trim().toLowerCase(),O=F[2]?.trim()||"";if($==="path")z=A1(O);else if($==="url")H=O;else if($==="branch")W=O}return q(),Y}function nC(Z,Y,Q,J){let X=A1(Y),K=x2(Q),z=J?.name?.trim()||X,H=J?.branch?.trim()||void 0,W=cJ(Z),q=W.get(X);if(q&&q.url.trim()===K&&(q.name||X)===z&&(q.branch?.trim()||void 0)===H)return;W.set(X,{name:z||q?.name||X,path:X,url:K,branch:H});let G=J0.join(Z,".gitmodules"),U=Array.from(W.values()).map((B)=>{return`[submodule "${B.name}"]
|
|
372
|
+
path = ${B.path}
|
|
373
|
+
url = ${B.url}`+(B.branch?`
|
|
374
|
+
branch = ${B.branch}`:"")}).join(`
|
|
375
|
+
|
|
376
|
+
`);F1(G,U?`${U}
|
|
377
|
+
`:"","utf-8")}async function oC(Z,Y){let Q=new Map,J="";try{J=(await E`${Z} -C ${Y} ls-files --stage`).stdout}catch{return Q}for(let X of J.split(`
|
|
378
|
+
`)){let K=X.trim();if(!K.startsWith("160000 "))continue;let z=K.match(/^160000\s+([0-9a-f]{40})\s+(\d)\t(.+)$/i);if(!z)continue;if(z[2]!=="0")continue;let H=A1(z[3]);if(!H)continue;Q.set(H,z[1])}return Q}async function aC(Z,Y,Q){let J=x2(Y),X=Q?.branch?.trim(),K=X?`refs/heads/${X}`:"HEAD",z=J.startsWith("file://")?J0.resolve(J.replace(/^file:\/\//i,"")):J;if(l(z)){let q=(await E`${Z} -C ${z} rev-parse ${X||"HEAD"}`).stdout.trim();if(q)return q}let W=(await E`${Z} ls-remote ${J} ${K}`).stdout.trim().split(`
|
|
379
|
+
`).map((q)=>q.trim()).find((q)=>q.length>0)?.split(/\s+/)[0]?.trim()||"";if(!W)throw Error(`Unable to resolve ${K} for submodule source '${J}'.`);return W}async function sC(Z,Y){let Q=(await E`${Z} -C ${Y} rev-parse --git-dir`).stdout.trim(),J=J0.isAbsolute(Q)?Q:J0.resolve(Y,Q);return J0.join(J,"modules")}async function HF(Z,Y,Q,J,X){let K=x2(Q),z=J0.resolve(Y,J);if(l(z))O1(z,{recursive:!0,force:!0});z6(J0.dirname(z),{recursive:!0});let H=await sC(Z,Y),W=J0.join(H,...J.split("/").filter(Boolean));z6(J0.dirname(W),{recursive:!0});let q=["-C",Y,"clone","--no-checkout","--separate-git-dir",W];if(X.quiet)q.push("--quiet");if(X.reference)q.push("--reference",X.reference);if(X.singleBranch===!0)q.push("--single-branch");else if(X.singleBranch===!1)q.push("--no-single-branch");if(X.filter)q.push(`--filter=${X.filter}`);if(X.branch)q.push("--branch",X.branch);q.push(K,J);let G=P4(q,X.allowFileProtocol);await E`${Z} ${G}`}async function WF(Z,Y,Q,J,X){let K=Array.isArray(Z)?Z[0]:Z,z=A1(J),H=await dJ(),W=X?.allowFileProtocol!==!1,q=X?.quiet!==!1,G=!!X?.force,U=x2(Q),B=X?.branch?.trim()||void 0,F=X?.name?.trim()||void 0,$=X?.reference?.trim()||void 0;if(!z)throw Error("Submodule path cannot be empty.");if(H==="off"){let T=["-C",Y,"submodule"];if(q)T.push("--quiet");if(T.push("add"),B)T.push("--branch",B);if(G)T.push("--force");if(F)T.push("--name",F);if($)T.push("--reference",$);T.push("--",U,z),await E`${K} ${P4(T,W)}`,await r1(Z,Y);return}let O=await aC(K,Q,{branch:B});nC(Y,z,U,{name:F,branch:B});let D=J0.resolve(Y,z);if(l(D)){if(f6(D).length>0&&!G)throw Error(`Submodule path '${z}' already exists. Re-run with --force to replace it.`)}let j=J0.join(D,".git"),M=l(j)?await s6(j).then((T)=>T.isDirectory()).catch(()=>!1):!1;if(!l(j)||M)await HF(K,Y,U,z,{allowFileProtocol:X?.allowFileProtocol!==!1,quiet:!!X?.quiet,reference:$,branch:B});try{let T=["-C",D,"checkout"];if(q)T.push("--quiet");T.push("--detach",O),await E`${K} ${T}`}catch{let T=["-C",D,"fetch"];if(q)T.push("--quiet");T.push("origin",O),await E`${K} ${P4(T,W)}`;let N=["-C",D,"checkout"];if(q)N.push("--quiet");N.push("--detach",O),await E`${K} ${N}`}if(await E`${K} -C ${Y} add .gitmodules`,await E`${K} -C ${Y} update-index --add --cacheinfo 160000 ${O} ${z}`,await r1(Z,Y),!q)I(`Submodule add: path=${z} url=${U} commit=${O}`)}async function C1(Z,Y){let Q=Array.isArray(Z)?Z[0]:Z,J=await F0(),X=d6(Z,Y),K=q6("git.submodules.paths",X),z=q6("git.submodules.gitlinks",X),H=J0.join(Y,".gitmodules"),W=await _Z(H)??null,q=null,G=await J.get(z);try{let U=[],B=await J.get(K);if(B&&B.mtime===W)U=B.paths;else if(W!==null){try{U=(await E`${Q} -C ${Y} config --file .gitmodules --get-regexp path`).stdout.trim().split(`
|
|
380
|
+
`).map((T)=>T.trim()).filter((T)=>T.length>0).map((T)=>{return T.match(/^submodule\.(.+?)\.path\s+(.+)$/)?.[2]?.trim()??""}).filter((T)=>T.length>0)}catch{U=[]}await J.set(K,{mtime:W,paths:U})}else if(B&&B.mtime===null)U=B.paths;let F=[],$=new Map;if(q===null)q=await _Z(await rZ(Z,Y,"index"))??null;if(G&&G.mtime===q&&q!==null)F=G.paths;else{try{let T=(await E`${Q} -C ${Y} ls-files --stage`).stdout.split(`
|
|
381
|
+
`).map((N)=>N.trim()).filter((N)=>N.startsWith("160000 ")).map((N)=>{let L=N.match(/^160000 ([0-9a-f]{40}) (\d)\t(.+)$/);return L?{sha:L[1],stage:L[2],path:L[3].trim()}:null}).filter((N)=>!!N).filter((N)=>N.path.length>0);$=new Map(T.map((N)=>[N.path,{sha:N.sha,stage:N.stage}])),F=Array.from($.keys())}catch{F=[]}await J.set(z,{mtime:q,paths:F})}let O=new Set([...U,...F]);if(O.size===0)return[];let D=Array.from(O);return(await Promise.all(D.map(async(M)=>{let T=$.get(M);if(T&&T.stage!=="0")return{path:M,status:"U"};let N=J0.resolve(Y,M),L=J0.join(N,".git");if(!l(N)||!l(L))return{path:M,status:"-"};if(!T?.sha)return{path:M,status:" "};let x=(await N0(Q,N,"HEAD")).trim(),S=x&&x!==T.sha?"+":" ";return{path:M,status:S}}))).map((M)=>{return{path:M.path,status:M.status,initialized:M.status!=="-"}})}catch(U){return R.debug(u(U,{color:!0}),"git"),[]}}async function r1(Z,Y){let Q=await F0(),J=d6(Z,Y);await Q.delete(q6("git.submodules.paths",J)),await Q.delete(q6("git.submodules.gitlinks",J))}async function qF(Z,Y,Q){let J=Array.isArray(Z)?Z[0]:Z,X=[];for(let K of Q){if(K.status==="U"){X.push(K.path);continue}let z=J0.resolve(Y,K.path);if(!l(z))continue;let H=J0.join(z,".git");if(!l(H)){if(K.status!=="-")try{if(f6(z).length>0)X.push(K.path)}catch{X.push(K.path)}continue}try{if((await E`${J} -C ${z} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0)X.push(K.path)}catch{X.push(K.path)}}return X}async function S2(Z,Y,Q){let J=Array.isArray(Z)?Z[0]:Z,X=Q?.force!==!1,K=Q?.quiet!==!1,z=KF(Q?.paths),H=Q?.all===!0||z.length===0;if(await dJ()==="off"){let $=["-C",Y,"submodule"];if(K)$.push("--quiet");if($.push("deinit"),X)$.push("--force");if(H)$.push("--all");else $.push("--",...z);await E`${J} ${$}`,await r1(Z,Y);return}let q=await C1(Z,Y),G=cJ(Y),U=new Set([...q.map(($)=>A1($.path)),...Array.from(G.keys())]),B=H?null:new Set(z),F=Array.from(U).filter(($)=>$&&zF($,B));if(F.length===0)return;for(let $ of F){if(!$)continue;let O=G.get($),D=new Set([A1($),A1(O?.name||"")]);for(let j of D){if(!j)continue;try{await E`${J} -C ${Y} config --local --remove-section submodule.${j}`}catch{}}}for(let $ of F){if(!$)continue;let O=J0.resolve(Y,$);try{if(l(O))O1(O,{recursive:!0,force:!0});z6(O,{recursive:!0})}catch(D){R.debug(`Failed to clean submodule path '${O}'. ${u(D,{color:!0})}`,"git")}}try{let $=(await E`${J} -C ${Y} rev-parse --git-dir`).stdout.trim(),O=$?J0.isAbsolute($)?$:J0.resolve(Y,$):"",D=O?J0.join(O,"modules"):"";if(D&&l(D))if(H)O1(D,{recursive:!0,force:!0});else for(let j of F){let M=J0.join(D,...j.split("/").filter(Boolean));if(l(M))O1(M,{recursive:!0,force:!0})}}catch($){R.debug(`Failed to clean worktree submodule metadata. ${u($,{color:!0})}`,"git")}if(!K)I(`Submodule deinit: ${F.length} path(s) (${F.join(", ")})`);await r1(Z,Y)}async function k2(Z,Y,Q){let J=Array.isArray(Z)?Z[0]:Z,X=Q?.recursive!==!1,K=Q?.force===!0,z=Q?.init!==!1,H=Q?.remote===!0,W=Q?.noFetch===!0,q=Q?.strategy||"checkout",G=Q?.quiet!==!1,U=Q?.allowFileProtocol!==!1,B=KF(Q?.paths),F=B.length>0?new Set(B):null;if(await dJ()==="off"){let M=["-C",Y,"submodule"];if(G)M.push("--quiet");if(M.push("update"),K)M.push("--force");if(z)M.push("--init");if(Q?.filter)M.push(`--filter=${Q.filter}`);if(H)M.push("--remote");if(W)M.push("--no-fetch");if(q==="merge")M.push("--merge");else if(q==="rebase")M.push("--rebase");else M.push("--checkout");if(Q?.recommendShallow===!0)M.push("--recommend-shallow");else if(Q?.recommendShallow===!1)M.push("--no-recommend-shallow");if(Q?.reference)M.push("--reference",Q.reference);if(X)M.push("--recursive");if(Q?.singleBranch===!0)M.push("--single-branch");else if(Q?.singleBranch===!1)M.push("--no-single-branch");if(B.length>0)M.push("--",...B);await E`${J} ${P4(M,U)}`,await r1(Z,Y);return}if(q!=="checkout"){let M=["-C",Y,"submodule"];if(G)M.push("--quiet");if(M.push("update"),K)M.push("--force");if(z)M.push("--init");if(Q?.filter)M.push(`--filter=${Q.filter}`);if(H)M.push("--remote");if(W)M.push("--no-fetch");if(q==="merge")M.push("--merge");else M.push("--rebase");if(Q?.recommendShallow===!0)M.push("--recommend-shallow");else if(Q?.recommendShallow===!1)M.push("--no-recommend-shallow");if(Q?.reference)M.push("--reference",Q.reference);if(X)M.push("--recursive");if(Q?.singleBranch===!0)M.push("--single-branch");else if(Q?.singleBranch===!1)M.push("--no-single-branch");if(B.length>0)M.push("--",...B);await E`${J} ${P4(M,U)}`,await r1(Z,Y);return}let O=await oC(J,Y);if(O.size===0){await r1(Z,Y);return}let D=cJ(Y),j=[];for(let[M,T]of O.entries()){let N=A1(M);if(!N||!T)continue;if(!zF(N,F))continue;let L=D.get(N);if(!L?.url)continue;let x=J0.resolve(Y,N),S=J0.join(x,".git"),g=l(S)?await s6(S).then((d)=>d.isDirectory()).catch(()=>!1):!1;if(!l(S)||g){if(!z)continue;await HF(J,Y,L.url,N,{allowFileProtocol:U,quiet:G,reference:Q?.reference,singleBranch:Q?.singleBranch,filter:Q?.filter,branch:H?L.branch:void 0})}let h=T;if(H){let d=L.branch?.trim()||"HEAD";if(!W){let V0=["-C",x,"fetch"];if(G)V0.push("--quiet");if(V0.push("origin"),d!=="HEAD")V0.push(d);await E`${J} ${P4(V0,U)}`}let y=d==="HEAD"?"origin/HEAD":`origin/${d}`,e=(await N0(J,x,y)).trim();if(!e)throw Error(`Unable to resolve remote ref '${y}' for submodule '${N}'.`);h=e}if(!(await N0(J,x,["-q","--verify",`${h}^{commit}`])).trim()){if(W)throw Error(`Missing commit '${h}' for submodule '${N}' and --no-fetch is set.`);let d=P4(["-C",x,"fetch",...G?["--quiet"]:[],"origin",h],U);await E`${J} ${d}`}let v=["-C",x,"checkout"];if(K)v.push("--force");else if(G)v.push("--quiet");if(v.push("--detach",h),await E`${J} ${v}`,j.push(`${N}@${h}`),X)await k2(Z,x,{...Q,paths:void 0})}if(j.length>0&&!G)I(`Submodule update: ${j.length} path(s) (${j.join(", ")})`);await r1(Z,Y)}async function GF(Z,Y){await k2(Z,Y,{recursive:!0})}function UF(Z){let Y=rC(Z);if(!Y)return!1;return Y.includes("the previous cherry-pick is now empty")||Y.includes("the previous cherry-pick is empty")||Y.includes("previous cherry-pick is now empty")||Y.includes("previous cherry-pick is empty")||Y.includes("cherry-pick is now empty")||Y.includes("cherry-pick is empty")||Y.includes("the patch is empty")||Y.includes("patch is empty")}function rC(Z){if(!Z)return"";if(typeof Z==="string")return q8(Z).toLowerCase();let Y=Z,Q=[Y?.stderr,Y?.stdout,Y?.message].map((X)=>tC(X)).filter((X)=>X.length>0);if(Q.length===0)return"";let J=Q.join(`
|
|
382
|
+
`);return q8(J).toLowerCase()}function tC(Z){if(!Z)return"";if(typeof Z==="string")return Z;if(Z instanceof Uint8Array)return new TextDecoder().decode(Z);return String(Z)}async function P2(Z,Y){try{return(await E`${Z} -C ${Y} diff --name-only --diff-filter=U`).stdout.split(`
|
|
383
|
+
`).map((J)=>J.trim()).filter((J)=>J.length>0)}catch{return[]}}async function VF(Z,Y){let Q=await P2(Z,Y);if(Q.length===0)return;await D0`${Z} -C ${Y} add -A -- ${Q}`}async function BF(Z,Y){if((await P2(Z,Y)).length>0)return!1;try{if((await E`${Z} -C ${Y} diff --cached --name-only`).stdout.trim().length>0)return!1}catch{return!1}return!0}async function lJ(Z){let{gitExec:Y,repoPath:Q,range:J,maxCount:X,formatTemplate:K,excludeRefs:z}=Z,H="";try{let B=["-C",Q,"log",`--pretty=format:${K||"%h %s"}`,J],F=z?.filter(($)=>$&&$.trim().length>0)??[];if(F.length>0)B.push("--not",...F);H=(await E`${Y} ${B}`).stdout.trim()}catch{H=""}let W=H.split(`
|
|
384
|
+
`).map((B)=>B.trim()).filter((B)=>B.length>0),q=W.length;if(q===0)return{commits:[],totalCount:0,moreCount:0};let G=X&&X>0?W.slice(0,X):W,U=Math.max(q-G.length,0);return{commits:G,totalCount:q,moreCount:U}}async function iJ(Z,Y,Q,J){let X=await F0(),K=`${Z}|${J0.resolve(Y)}|${Q}|${J}`,z=q6("git.submoduleBaseSha",K),H=await X.get(z);if(H!==void 0)return H;try{let W=(await E`${Z} -C ${Y} ls-tree ${Q} -- ${J}`).stdout.trim();if(!W)return await X.set(z,null),null;let G=W.match(/^160000\s+commit\s+([0-9a-f]{7,40})\s+/i)?.[1]??null;return await X.set(z,G),G}catch{return await X.set(z,null),null}}function v2(){if(e0.supportsColor<=0)return[];return["-c","color.ui=always"]}async function y8(Z,Y,Q=0){for(let J=Q;J<Z.length;J++){let X=/^(head|origin)?~(\d+)?$/i.exec(Z[J]);if(!X)continue;let K=0;if(X[2]){if(K=parseInt(X[2],10),isNaN(K)||K<0)return R.error(`Invalid relative ref format: ${Z[J]}`,"reset"),{error:new o(`Invalid relative ref format: ${Z[J]}`)}}try{if(X[1]?.toLowerCase()==="origin"){let z=await cC(Y);if(!z)return R.error("No upstream configured for current branch.","reset"),{error:new o("No upstream configured for current branch.")};Z[J]=`${z}~${K}`;break}else Z[J]=`HEAD~${K}`}catch(z){return R.error(`Failed to expand relative ref: ${o.from(z)}`,"reset"),{error:o.from(z)}}}return{value:void 0}}function hJ(Z,Y){let Q=Y.replace(/^[/:]+/,"");if(Q=Q.replace(/\.git$/i,""),Q=Q.replace(/\/+$/,""),Z)return`${Z}/${Q}`;return Q}var L2=360,bJ=360,fJ;var O6=_(()=>{G0();I1();F6();Y6();I0();R0();w0();P0();fJ=new Map});import $F from"path";import eZ from"fs";import eC from"crypto";async function ZE(Z){try{let Y=await G6(Z),Q=QE(Y);if(!Q)return R.error("No stash drop to pardon.","stash"),1;I(V("Cyan")+`Restoring ${Q.entries.length} dropped stash(es)...`+V());for(let J of Q.entries)await YF(Z,J.sha,J.message),I(V("Green")+` + Restored: ${J.message}`+V());return 0}catch(Y){return R.error("Error pardoning stash: "+Y,"stash"),1}}async function FF(Z,Y,Q){let[J,X]=Y[2].split("..").map((z)=>parseInt(z,10));if(isNaN(J)||isNaN(X)||J>X)return R.error(`Invalid stash range: ${Y[2]}`,"stash"),1;let K=[];try{let z=await G6(Z),H=[];for(let W=X;W>=J;W--)H.push(mJ(Z,W));if(K=(await Promise.all(H)).filter((W)=>W!=null),K.length>0)DF(z,{timestamp:Date.now(),entries:K,type:"range"},Q)}catch(z){let H=o.from(z);R.warn(`Could not capture stash entry for undo. (${H.name})`,"stash"),R.debug(H.toString(),"stash")}I(V("Cyan")+`Dropping stashes from ${V("Bright")+J+V()+V("Cyan")} to ${V("Bright")+X+V()+V("Cyan")} (inclusive)`+V());for(let z=X;z>=J;z--)await D0`${Z} stash drop stash@{${z}}`;return 0}async function YE(Z,Y){if(Y[2]==="pardon")return await ZE(Z);let J=(await $0()).get("stash.undoLimit")??10;if(Y[2]&&/\d+\.\.\d+$/.test(Y[2]))return await FF(Z,Y,J);let X=0,K=Y.slice(2).filter((z)=>!z.startsWith("-"));if(K.length>0)if(K[0].includes(".."));else{let z=K[0].match(/stash@\{(\d+)\}/)||K[0].match(/^(\d+)$/);if(z)X=parseInt(z[1],10)}try{let z=await mJ(Z,X);if(z){let H=await G6(Z);DF(H,{timestamp:Date.now(),entries:[z],type:"single"},J)}}catch(z){R.warn(`Could not capture stash entry for undo. (${o.from(z).name})`,"stash")}try{return await D0`${Z} ${Y}`,0}catch{return 1}}function OF(Z){let Y=eC.createHash("sha256").update(Z).digest("hex"),Q=$F.join(H6,"gdx","stash-undo");if(!eZ.existsSync(Q))eZ.mkdirSync(Q,{recursive:!0});return $F.join(Q,`${Y}.json`)}function RF(Z){let Y=OF(Z);if(!eZ.existsSync(Y))return[];try{let Q=eZ.readFileSync(Y,"utf-8");return JSON.parse(Q)}catch{return[]}}function MF(Z,Y){let Q=OF(Z);eZ.writeFileSync(Q,JSON.stringify(Y,null,2))}function DF(Z,Y,Q=10){let J=RF(Z);if(J.push(Y),J.length>Q)J.splice(0,J.length-Q);MF(Z,J)}function QE(Z){let Y=RF(Z);if(Y.length===0)return null;let Q=Y.pop()||null;return MF(Z,Y),Q}var _F,NF,jF;var y2=_(()=>{G0();P0();w0();B0();B0();I0();O6();F6();R0();A0();_F={dropRange:FF,drop:YE},NF={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
385
|
+
${Z+c("STASH DROP",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
386
|
+
Remove a stash entry or a range of stash entries.
|
|
387
|
+
|
|
388
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
389
|
+
Accepts a single stash index, a range like <start>..<end>, or defaults to the latest stash.
|
|
390
|
+
Includes safety features:
|
|
391
|
+
- **Undoable**: You can restore the last dropped stash(es) with \`${Y}${C} stash drop pardon${Q}\`.
|
|
392
|
+
|
|
393
|
+
${Z+c("COMMANDS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
394
|
+
- \`${Y}drop <index>${Q}\`: Drop specific stash.
|
|
395
|
+
- \`${Y}drop <start>..<end>${Q}\`: Drop range of stashes.
|
|
396
|
+
- \`${Y}drop pardon${Q}\`: Undo the last drop operation.
|
|
397
|
+
|
|
398
|
+
${Z+c("SAFETY",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
399
|
+
Dropped stashes are backed up temporarily. Use \`${Y}pardon${Q}\` to bring them back.
|
|
400
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Drop stash entries with undo support (e.g. 0..3, pardon).",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
401
|
+
${Z}${C} stash drop ${Y}[<stash> | <range> | pardon]${Q}
|
|
402
|
+
|
|
403
|
+
Examples:
|
|
404
|
+
${Z}${C} stash drop 0..0 ${Q+Y}# Drop the most recent stash${Q}
|
|
405
|
+
${Z}${C} stash drop pardon ${Q+Y}# Restore last dropped stash${Q}
|
|
406
|
+
${Z}${C} stash l ${Q+Y}# Show stash list (alias for ${C} stash list).${Q}
|
|
407
|
+
${Z}${C} stash d 3 ${Q+Y}# Drop stash@{3}.${Q}
|
|
408
|
+
${Z}${C} stash d 2..5 ${Q+Y}# Drop stash@{5}, stash@{4}, stash@{3}, stash@{2} (safe ordering).${Q}
|
|
409
|
+
${Z}${C} stash p 1 ${Q+Y}# Pop stash@{1}.${Q}
|
|
410
|
+
${Z}${C} stash c ${Q+Y}# Clear all stashes (maps to ${C} stash clear — destructive).${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},jF={$root:["pardon"]}});async function Z7(Z){let{git$:Y,args:Q}=Z,J=!!Q.popOption("--all")||!!Q.popOption("-a"),X="";if(!J){if(X=Q.popValue("--email")||await t1(Y,"user.email"),X=X?X.trim().replace(/^["']|["']$/g,""):X,!X)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"))I(J?V("Cyan")+"Generating commit graph for all authors"+V():V("Cyan")+"Generating commit graph for user: "+V("Yellow")+X+V());let z=p.terminalWidth-wF-TF,H=Math.min(Math.floor(z/b2),52);if(z<LF)return R.error(`Terminal width too small for graph display. Minimum required width is ${LF+wF+TF} columns.`,"graph"),1;let W=new Date,q=new Date(W),G=q.getDay();q.setDate(q.getDate()-G),q.setDate(q.getDate()-H*7);let U=(J?await E`
|
|
411
|
+
${Y} --no-pager log --all --since=${q.toISOString()} --date=short --format=%ad
|
|
412
|
+
`:await E`
|
|
413
|
+
${Y} --no-pager log --all --author=${X} --since=${q.toISOString()} --date=short --format=%ad
|
|
414
|
+
`).stdout.trim(),B={};for(let M of U.split(`
|
|
415
|
+
`)){let T=M.trim();if(T)B[T]=(B[T]||0)+1}let F=1;for(let M of Object.values(B))if(M>F)F=M;I(`
|
|
416
|
+
`+V("Bright")+c("Contribution Graph",k.OceanDeepBlue,k.OceanGreen,0.12,0.83)+` (Max: ${F} commits/day)
|
|
417
|
+
`);let $=" ",O=0,D=-1;for(let M=0;M<=H;M++){let T=new Date(q);T.setDate(T.getDate()+M*7);let N=M*b2;if(T.getMonth()!==D&&N>=O){$+=" ".repeat(N-O);let L=T.toLocaleString("default",{month:"short"});$+=L.padEnd(b2*3," "),O=N+b2*3,D=T.getMonth()}}I(V("Bright")+$+V());let j=[" ","Mon"," ","Wed"," ","Fri"," "];for(let M=0;M<7;M++){let T=V("Bright")+j[M]+V()+" ";for(let N=0;N<=H;N++){let L=new Date(q);if(L.setDate(L.getDate()+N*7+M),L>W){T+=" ";continue}let x=L.toISOString().slice(0,10),S=B[x]||0,g,h="■";if(S===0)g=V("Dim")+V(_4(k.MidnightBlack)),h="▨";else{let f=d0.clamp(S/F,0.15,1),v=HW(k.MidnightBlack,k.OceanGreen,f);g=V(_4(v))}T+=g+h+V()+" "}I(" "+T)}return I(""),0}var wF=6,b2=2,TF=4,LF=12,IF,AF;var Y7=_(()=>{P0();w0();G0();I0();B0();R0();A0();O6();IF={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
418
|
+
${Z+c("GRAPH",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
419
|
+
Render a calendar-style contribution graph for a repository author or the whole repository.
|
|
420
|
+
|
|
421
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
422
|
+
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.
|
|
423
|
+
|
|
424
|
+
${Z+c("OPTIONS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
425
|
+
Supply ${Y}--email <email>${Q} to override the configured git user email. Use ${Y}--all${Q} or ${Y}-a${Q} for project-wide commit graph across all authors. Use ${Y}--quiet${Q} to suppress informational headers when embedding the graph in other scripts.
|
|
426
|
+
|
|
427
|
+
${Z+c("TERMINAL NOTES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
428
|
+
The graph respects \`${Y}global.terminalWidth${Q}\`. If the terminal is too narrow the command will bail with an error message.
|
|
429
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Render a calendar-style contribution graph for an author or all authors.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
430
|
+
${Z}${C} graph ${Y}[--email <email>] [--all|-a] [--quiet]${Q}
|
|
431
|
+
|
|
432
|
+
Examples:
|
|
433
|
+
${Z}${C} graph ${Q+Y}# Graph for configured git user${Q}
|
|
434
|
+
${Z}${C} graph --email bob@example.com ${Q+Y}# Graph for specified author${Q}
|
|
435
|
+
${Z}${C} graph --all ${Q+Y}# Graph for all authors${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},AF={$root:["--email","--all","-a","--quiet"]}});function CF(Z,Y){if(!Number.isFinite(Z))return 0;let Q=Math.trunc(Z);if(Q<0){let J=Y+Q;return J<0?0:J}return Q}function EF(Z,Y){if(Z==null)return!1;if(Y.includes(Q7))return Z===Y;return Z===Y||Z.startsWith(Y+Q7)}function f2(Z){let Y=Z.indexOf(Q7);return Y===-1?Z:Z.slice(0,Y)}function nJ(Z,Y){let Q=0,J=Z.length;while(Q<J){let X=Q+J>>>1;if(Z[X]<Y)Q=X+1;else J=X}return Q}function HE(Z,Y){if(!Number.isFinite(Z))return 0;if(Z<0){let Q=Y+Z;return Q<0?0:Q}return Z>Y?Y:Z}function xF(Z){if(Z==="--")return!1;if(Z==="-"||!Z.startsWith("-"))return!0;return/^-\d+(\.\d+)?$/.test(Z)}function WE(Z,Y){let Q=Z[Y];if(zE.includes(Q))return{consumed:1,gitArgs:[Q]};for(let J of KE){if(Q===J){if(Y+1>=Z.length)return null;let X=Z[Y+1];if(X==="--")return null;return{consumed:2,gitArgs:[J,X]}}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 h2(Z,Y){if(Z[0]&&!Z[0].startsWith("-"))return{args:Z,gitArgs:[],cursorIndex:Y,cursorInGitGlobal:!1};let Q=new Set,J=[],X=0;while(X<Z.length){let H=Z[X];if(H==="--")break;let W=WE(Z,X);if(W){let q=X,G=X+W.consumed-1;if(Y!=null&&Y>=q&&Y<=G)return{args:Z,gitArgs:[],cursorIndex:Y,cursorInGitGlobal:!0};if(Y==null||G<Y){J.push(...W.gitArgs);for(let U=q;U<=G;U++)Q.add(U)}X+=W.consumed;continue}if(JE.includes(H)){if(X+1>=Z.length)break;X+=2;continue}if(XE.includes(H)){X+=1;continue}if(H.startsWith("-")){X+=1;continue}break}if(Q.size===0)return{args:Z,gitArgs:J,cursorIndex:Y,cursorInGitGlobal:!1};let K=Z.filter((H,W)=>!Q.has(W)),z=Y;if(Y!=null){let H=0;for(let W of Q)if(W<Y)H+=1;if(z=Math.max(0,Y-H),K.length>0&&z>=K.length)z=K.length-1}return{args:K,gitArgs:J,cursorIndex:z,cursorInGitGlobal:!1}}function SF(Z){let Y=Z.indexOf("=");if(Y!==-1)return Z.substring(Y+1);return null}function oJ(Z){return new E1(Z)}var JE,XE,KE,zE,Q7="=",E1;var b8=_(()=>{B0();G0();A0();JE=[...ZW],XE=[...YW],KE=[...QW],zE=[...JW];E1=class E1 extends Array{argIndexes=new Map;indexedLength=-1;indexesDirty=!0;constructor(Z){if(Array.isArray(Z))super(...Z);else super(Z);this.reindex()}optionIndexOf(Z,Y=0){let Q=CF(Y,this.length),J=-1;if(p.indexArgs)this.ensureIndexes(),J=this.argIndexes.get("--")?.[0]??-1;else J=super.indexOf("--");if(J!==-1&&J<Q)return-1;let X=J===-1?this.length:J,K=f2(Z);if(p.indexArgs&&K.startsWith("-")){let z=this.argIndexes.get(K);if(z&&z.length>0){let H=0;if(z.length===1){let W=z[0];if(W<Q||W>=X)H=1}else H=nJ(z,Q);while(H<z.length){let W=z[H];if(W>=X)break;if(EF(this[W],Z))return W;H+=1}}}for(let z=Q;z<X;z++)if(EF(this[z],Z)){if(p.indexArgs&&K.startsWith("-"))this.reindex();return z}return-1}delete(Z){let Y=this.optionIndexOf(Z);if(Y!==-1)return this.splice(Y,1),!0;return!1}popValue(Z,Y=0,Q=!1){let J=this.optionIndexOf(Z,Y);if(J!==-1){let X=null,K=this[J];if(K.includes(Q7))X=SF(K),this.splice(J,1);else if(!Q&&J+1<this.length&&xF(this[J+1]))X=this[J+1],this.splice(J,2);else this.splice(J,1);return X}return null}popAssertValue(Z,Y=0,Q=!1){let J=this.optionIndexOf(Z,Y);if(J!==-1){let X=null,K=this[J];if(K.includes(Q7))X=SF(K),this.splice(J,1);else if(!Q&&J+1<this.length&&xF(this[J+1]))X=this[J+1],this.splice(J,2);else throw new o(`Options "${this[J]}" requires a value, but none was provided.`,"MISSING_OPTION_VALUE");return X}return null}popOption(Z,Y=0){let Q=this.optionIndexOf(Z,Y);if(Q!==-1)return this.splice(Q,1)[0];return null}spliceOption(Z,Y,Q=0){let J=this.optionIndexOf(Z,Q);if(J!==-1)return this.splice(J,1,...Y),!0;return!1}hasOption(Z,Y=0){return this.optionIndexOf(Z,Y)!==-1}slice(Z,Y){return new E1(super.slice(Z,Y))}toArray(){return super.slice(0)}splice(Z,Y,...Q){let J=this.length,X=arguments.length===1?super.splice(Z):super.splice(Z,Y,...Q);if(!p.indexArgs)return X;if(this.indexesDirty||this.indexedLength!==J)return this.reindex(),X;let K=HE(Z,J);return this.updateIndexesAfterSplice(K,X.length,Q),X}indexOf(Z,Y=0){if(!p.indexArgs||!Z.startsWith("-"))return super.indexOf(Z,Y);this.ensureIndexes();let Q=CF(Y,this.length);if(Q>=this.length)return-1;let J=this.argIndexes.get(f2(Z));if(J&&J.length>0){let K=0;if(J.length===1){if(J[0]<Q)K=1}else K=nJ(J,Q);while(K<J.length){let z=J[K];if(this[z]===Z)return z;K+=1}}let X=super.indexOf(Z,Q);if(X!==-1)this.reindex();return X}push(...Z){let Y=this.length,Q=super.push(...Z);if(!p.indexArgs)return Q;if(this.indexesDirty||this.indexedLength!==Y)return this.reindex(),Q;return this.updateIndexesAfterSplice(Y,0,Z),Q}pop(){if(this.length===0)return;let Z=this.length,Y=super.pop();if(!p.indexArgs)return Y;if(this.indexesDirty||this.indexedLength!==Z)return this.reindex(),Y;return this.updateIndexesAfterSplice(Z-1,1,[]),Y}shift(){if(this.length===0)return;let Z=this.length,Y=super.shift();if(!p.indexArgs)return Y;if(this.indexesDirty||this.indexedLength!==Z)return this.reindex(),Y;return this.updateIndexesAfterSplice(0,1,[]),Y}unshift(...Z){let Y=this.length,Q=super.unshift(...Z);if(!p.indexArgs)return Q;if(this.indexesDirty||this.indexedLength!==Y)return this.reindex(),Q;return this.updateIndexesAfterSplice(0,0,Z),Q}reverse(){return super.reverse(),this.reindex(),this}sort(Z){return super.sort(Z),this.reindex(),this}fill(Z,Y,Q){return super.fill(Z,Y,Q),this.reindex(),this}copyWithin(Z,Y,Q){return super.copyWithin(Z,Y,Q),this.reindex(),this}invalidateIndexes(){this.argIndexes.clear(),this.indexedLength=-1,this.indexesDirty=!0}ensureIndexes(){if(!p.indexArgs)return;if(this.indexesDirty||this.indexedLength!==this.length)this.reindex()}updateIndexesAfterSplice(Z,Y,Q){let J=Z+Y,X=Q.length-Y;for(let[K,z]of this.argIndexes){if(z.length===1){let W=z[0];if(W>=Z&&W<J){this.argIndexes.delete(K);continue}if(W>=J)z[0]=W+X;continue}let H=0;for(let W of z){if(W<Z){z[H]=W,H+=1;continue}if(W>=J)z[H]=W+X,H+=1}if(H===0)this.argIndexes.delete(K);else z.length=H}for(let K=0;K<Q.length;K++){let z=Q[K];if(!z.startsWith("-"))continue;let H=f2(z),W=Z+K,q=this.argIndexes.get(H);if(!q){this.argIndexes.set(H,[W]);continue}if(q.length===1){if(W<=q[0])q.unshift(W);else q.push(W);continue}let G=q[q.length-1];if(W>=G){q.push(W);continue}let U=nJ(q,W);q.splice(U,0,W)}this.indexedLength=this.length,this.indexesDirty=!1}reindex(){if(!p.indexArgs)return;this.argIndexes.clear();for(let Z=0;Z<this.length;Z++){let Y=this[Z];if(Y===void 0)continue;if(!Y.startsWith("-"))continue;let Q=f2(Y),J=this.argIndexes.get(Q);if(J)J.push(Z);else this.argIndexes.set(Q,[Z])}this.indexedLength=this.length,this.indexesDirty=!1}}});import kF from"path";async function vF(Z){let Y=!!Z?.forceRefresh,Q=Z?.spinner,J=await F0(),X=await J.get(O9),K=FE(X);if(K&&!Y&&!VE(K.lastUpdatedAt))return aJ(K);if(!K&&!Y&&Date.now()-PF<qE)return null;try{if(Q)Q.setMessage("Updating language catalog...");let z=await UE(),H=await OE(),W=GE(z,H);return await J.set(O9,W,{maxAgeMinutes:1/0}),aJ(W)}catch(z){return PF=Date.now(),R.warn(`Failed to refresh language catalog: ${o.from(z).message}`,"languages"),K?aJ(K):null}}function yF(Z,Y){let Q=kF.extname(Y).toLowerCase(),J=kF.basename(Y),X=Z.languages.find((K)=>K.filenames.includes(J));if(X)return X;if(!Q)return null;return Z.byExtension.get(Q)||null}function GE(Z,Y){let Q=Y.parse(Z),J=[];for(let[X,K]of Object.entries(Q||{})){if(!K||typeof K!=="object")continue;let z=K,H=BE(z.extensions);if(!z.color)continue;if(z.type==="data"&&!R9.includes(z.language_id))continue;if(H.length===0)continue;let W=$E(z.color)??sJ;J.push({name:X,extensions:H,color:W,filenames:Array.isArray(z.filenames)?z.filenames.filter((q)=>typeof q==="string"):[],id:z.language_id})}return J=bF(J),J.sort((X,K)=>X.name.localeCompare(K.name)),{lastUpdatedAt:new Date().toISOString(),languages:J}}async function UE(){let Z=new AbortController,Y=setTimeout(()=>Z.abort(),zW);try{let Q=await fetch(XW,{signal:Z.signal});if(!Q.ok)throw Error(`HTTP ${Q.status} ${Q.statusText}`);return await Q.text()}finally{clearTimeout(Y)}}function aJ(Z){let Y=bF(Z.languages),Q=new Map;for(let J of Y)for(let X of J.extensions)if(!Q.has(X))Q.set(X,J);return{lastUpdatedAt:Z.lastUpdatedAt,languages:Y,byExtension:Q}}function bF(Z){let Y=new Map;for(let J of Z)for(let X of J.extensions)Y.set(X,(Y.get(X)||0)+1);let Q=[];for(let J of Z){if(R9.includes(J.id)){Q.push(J);continue}let X=J.extensions.filter((K)=>(Y.get(K)||0)===1);if(X.length===0)continue;Q.push({...J,extensions:X})}return Q}function VE(Z){let Y=Date.parse(Z);if(!Number.isFinite(Y))return!0;return Date.now()-Y>=KW}function BE(Z){if(!Array.isArray(Z))return[];let Y=new Set;for(let Q of Z){if(typeof Q!=="string")continue;let J=Q.trim().toLowerCase();if(!J.startsWith("."))continue;if(J.length<=1)continue;Y.add(J)}return Array.from(Y)}function $E(Z){if(typeof Z!=="string")return null;let Y=Z.trim(),Q=Y.match(/^#?([\da-fA-F]{6})$/);if(Q)return parseInt(Q[1],16);let J=Y.match(/^#?([\da-fA-F]{3})$/);if(J){let X=J[1].split("").map((K)=>K+K).join("");return parseInt(X,16)}return null}function FE(Z){try{return n$(Z)}catch{return null}}async function OE(){if(g2)return g2;try{return g2=await import("yaml"),g2}catch(Z){throw R.error(`Failed to load YAML parser for language catalog: ${o.from(Z).message}`,"languages"),Error("YAML parser unavailable")}}var qE=600000,sJ=16777215,PF=0,g2=null;var fF=_(()=>{G0();I1();_2();B0();R0()});import*as rJ from"path";async function tJ(Z){let Y=P8(),Q=Y.$,{args:J,git$:X}=Z;if(!await v8(X))return 1;let K=J.hasOption("--all")||J.hasOption("-a");J.popOption("--all"),J.popOption("-a");let z=J.hasOption("--lang-metric"),H=J.popValue("--lang-metric"),W=LE(H,z);if(!W)return R.error("Invalid --lang-metric value. Use one of: auto, net, activity (for example: --lang-metric auto).","stats"),1;let q=IE(W,K),G="",U="Your",B="";if(!K){try{let $=J.popValue("--author");if($)G=$.trim().replace(/^["']|["']$/g,"");else G=await t1(X,"user.email"),G=G?G.trim().replace(/^["']|["']$/g,""):G}catch($){return Y.abort(),R.error("Failed to read git config user.email.","stats"),R.error(u($,{color:!0}),"stats"),1}if(!G)return R.error("No user.email configured in git.","stats"),1;B=G}else U="Project-wide",B="all authors";let F=b0({message:K?"Gathering project-wide stats...":`Gathering stats for ${G}...`});try{let $=Q`${X} rev-list --all --count`,O=Q`${X} fsck --unreachable --no-reflogs --no-progress --full`,D=K?Q`${X} cat-file --batch-all-objects --batch-check=%(objectname):%(objectsize)`:Promise.resolve({stdout:""}),j=Q`${X} log --all --pretty=tformat: --numstat`,M=`%ar ${V()+V("Dim")}[at %h] (on %ad)`+V(),T=`%ar ${V()+V("Dim")}[at %h] (on %ad)`+V(),N=K?Q`${X} log --all --format=%aN%x09%ae --numstat`:Promise.resolve({stdout:""}),L=K?Promise.resolve({stdout:""}):Q`${X} log --all --author=${G} -1 --format=%aN`,x=(await G6(X)).trim(),[S,g,h,f,v,d,y,e,V0,a0,t,a,Z0,Y0]=await Promise.all([K?$:Q`${X} rev-list --all --count --author=${G}`,$,O,K?Q`${X} log --all --since=midnight --pretty=tformat:%h`:Q`${X} log --all --author=${G} --since=midnight --pretty=tformat:%h`,K?Promise.resolve({stdout:""}):Q`${X} log --all --author=${G} --pretty=tformat: --numstat`,j,N,L,QF(X),K?Q`${X} rev-list --all --reverse`:Q`${X} rev-list --all --author=${G} --reverse`,K?Q`${X} log --all -1 --format=${T}`:Q`${X} log --all --author=${G} -1 --format=${T}`,A2(X),C1(X,x),D]),_0=null;try{_0=await vF({spinner:F})}catch{_0=null}let T0=x.split(/[\\/]/).pop()||x,O0=e.stdout.trim();if(!K&&O0)U=`${O0}'s`;let x0=parseInt(S.stdout.trim()),i6=parseInt(g.stdout.trim()),s0=jE(h.stdout,h.stderr),r0=K?wE(Y0.stdout,s0.objectIds):null,R6=f.stdout.trim()?f.stdout.trim().split(`
|
|
436
|
+
`).length:0;F.setMessage("Detecting repository details...");let t0=Z0.length,U1=t0>0?V("Dim")+V("White")+` (${t0} submodules)`:"",u0=RE(a),g1=u0.repoUrl?`${a6(T0,u0.repoUrl,!1)}${U1}`:`${T0}${U1}`,$4=performance.now(),p0=gF(d.stdout),C6=K?p0:gF(v.stdout),n6=C6.totalAdded,F4=C6.totalRemoved,qH=B6(n6*M4.AVG_CHARS_PER_LINE,2,1024)+"iB",GH=B6(F4*M4.AVG_CHARS_PER_LINE,2,1024)+"iB",UH=B6(n6/M4.AVG_LINES_PER_FUNCTION,1,1000,!1,0),VH=B6(F4/M4.AVG_LINES_PER_FUNCTION,1,1000,!1,0),BH=B6(n6/M4.AVG_LINES_PER_FILE,1,1000,!1,0),$H=B6(F4/M4.AVG_LINES_PER_FILE,1,1000,!1,0),dD=p0.totalAdded,cD=p0.totalRemoved,lD=n6+F4,eQ=dD+cD,iD=eQ>0?H8(lD/eQ*100,2,!0):"0.00",jY=K?ME(y.stdout,eQ):null,FH=K?jY?jY.contributionPct:"0.00":iD,nD=jY?hF(jY.username,u0):"N/A",oD=!K?hF(U,u0):U,aD=B6((performance.now()-$4)/1000,2)+"s",Z9=0,OH="N/A";F.setMessage("Analyzing branch activity...");let sD=await Promise.all(V0.map(async(V6)=>{let{stdout:J8}=K?await Q`${X} rev-list --count refs/heads/${V6}`:await Q`${X} rev-list --count --author=${G} refs/heads/${V6}`;return{branch:V6,count:parseInt(J8.trim(),10)}}));for(let{branch:V6,count:J8}of sD)if(J8>Z9)Z9=J8,OH=V6;F.setMessage("Resolving commit timestamps...");let RH=a0.stdout.split(`
|
|
437
|
+
`).map((V6)=>V6.trim()).find((V6)=>V6.length>0),MH="Never";if(RH)MH=(await Q`${X} show -s --format=${M} ${RH}`).stdout.trim()||"Never";let rD=t.stdout.trim()||"Never",tD=Buffer.byteLength(d.stdout)+(K?0:Buffer.byteLength(v.stdout)),eD=p0.totalRecords+(K?0:C6.totalRecords),DH=s0.commit>0?V("Red"):V("White")+V("Dim"),_H=`${s0.commit} ${V("White")+V("Dim")}orphan${s0.commit===1?"":"s"}`,Z_=K?` / ${DH}${_H}${V()}`:` / ${V("Yellow")}${f8(i6)}${V()+V("Dim")} all${V()} / ${DH}${_H}${V()}`,Y_=K?` Most Active User: ${V("Cyan")}${nD}${V()} (${V("Magenta")}${FH}%${V()} of all lines changed in the project)`:` Contributions: ${V("Magenta")}${FH}%${V()} of all lines changed in the project`,wY=[`${V("Dim")+V("Italic")}Showing stats for ${B} in ${T0}${V()}`,`${V("Dim")}Parsed ${B6(tD,1,1024)}iB of ${B6(eD,1,1000,!0)} numstat records in ${aD}${V()}`],Q_=o6(wY[0]+wY[1])+7<p.terminalWidth?" "+D6(wY,p.terminalWidth-4,{align:"spacebetween"}):wY.map((V6)=>" "+V6).join(`
|
|
438
|
+
`),J_=p.terminalWidth>100?`(roughly ${qH}, ${UH} functions or ${BH} source files)`:`(${qH}, ${UH} fns or ${BH} files)`,X_=p.terminalWidth>100?`(roughly ${GH}, ${VH} functions or ${$H} source files)`:`(${GH}, ${VH} fns or ${$H} files)`,NH=K&&r0?` Object Inventory: ${V("Cyan")}${f8(r0.totalObjects)}${V()} total ${V("Dim")}(${B6(r0.totalBytes,1,1024)}iB)${V()} / ${V("Yellow")}${f8(r0.garbageObjects)}${V()} garbage ${V("Dim")}(${B6(r0.garbageBytes,1,1024)}iB)${V()}`:"",K_=NH?`
|
|
439
|
+
${NH}`:"";if(F.stop(),I(`${Q_}
|
|
440
|
+
|
|
441
|
+
─── ${oD} Git Stats ───
|
|
442
|
+
Project: ${V("Cyan")}${g1}${V()}
|
|
443
|
+
Total Commits: ${V("Green")}${f8(x0)}${V()} (today: ${R6})${Z_}${K_}
|
|
444
|
+
Total Lines Added: ${V("Green")}+ ${f8(n6)} lines ${V()}${V("Dim")}${J_+V()}
|
|
445
|
+
Total Lines Removed: ${V("Red")}- ${f8(F4)} lines ${V()}${V("Dim")}${X_+V()}
|
|
446
|
+
${Y_}
|
|
447
|
+
Most Active Branch: ${V("Cyan")}${OH}${V()} (${Z9} commits)
|
|
448
|
+
First Commit: ${V("Yellow")}${MH}${V()}
|
|
449
|
+
Last Commit: ${V("Yellow")}${rD}${V()}`),_0){let V6=q==="net"?"Language Usage:":"Language Activity:",J8=q==="net"?"(Net changes)":"(Aggregated changes)",z_=d0.clamp(p.terminalWidth-21-2-2,24,56),H_=q==="net"?C6.netFiles.map((O4)=>({filePath:O4.filePath,lines:O4.netLines})):C6.activityFiles.map((O4)=>({filePath:O4.filePath,lines:O4.activityLines})),Y9=TE(_0,H_,z_);if(Y9){let O4=" "+D6(V6,21,{align:"left",redundancyLv:-1}),W_=" "+D6(J8,21,{align:"left",redundancyLv:-1});I(`${O4}${Y9.bar}
|
|
450
|
+
${V("Dim")+W_+V()}${Y9.legend}
|
|
451
|
+
`)}}return await Z7({...Z,args:K?oJ(["--quiet","--all"]):oJ(["--quiet","--email",G])}),0}catch($){return F.stop(),Y.abort(),R.error(u($,{color:!0})),1}}function RE(Z){if(!Z)return{repoUrl:null,host:null,provider:null};let Y=Z.trim();if(!Y)return{repoUrl:null,host:null,provider:null};let Q=Y.indexOf("/"),J=Q===-1?Y:Y.slice(0,Q),X=Q===-1?"":Y.slice(Q+1),z=J.includes(".")||J.includes(":")||J==="localhost"?J:null,H=z&&X?`https://${z}/${X}`:null,W=z?z.toLowerCase():"",q=null;if(W.includes("github"))q="github";else if(W.includes("gitlab"))q="gitlab";else if(W.includes("gitea"))q="gitea";return{repoUrl:H,host:z,provider:q}}function ME(Z,Y){if(!Z.trim())return null;let Q=new Map,J="",X="";for(let W of Z.split(`
|
|
452
|
+
`)){let q=W.trim();if(!q)continue;let G=W.split("\t");if(G.length>=3){if(!/^\d+$/.test(G[0])||!/^\d+$/.test(G[1]))continue;if(!J)continue;let B=parseInt(G[0],10)+parseInt(G[1],10);if(B<=0)continue;let F=pF(G.slice(2).join("\t").trim());if(F9.includes(rJ.extname(F).toLowerCase()))continue;let $=DE(X,J),O=Q.get($);if(O){if(O.lines+=B,!O.name&&X)O.name=X;if(!O.email&&J)O.email=J}else Q.set($,{name:X,email:J,lines:B});continue}let U=W.lastIndexOf("\t");if(U>0)X=W.slice(0,U).trim().replace(/^"|"$/g,"").replace(/^'|'$/g,""),J=W.slice(U+1).trim().replace(/^"|"$/g,"").replace(/^'|'$/g,"");else X="",J=q.replace(/^"|"$/g,"").replace(/^'|'$/g,"")}let K="",z="",H=0;for(let[,W]of Q.entries())if(W.lines>H)K=W.email,z=W.name,H=W.lines;if(!K)return null;return{email:K,username:z||K,contributionPct:Y>0?H8(H/Y*100,2,!0):"0.00"}}function DE(Z,Y){let Q=Y.trim().toLowerCase();if(Q)return`email:${Q}`;let J=Z.trim().toLowerCase();if(J)return`name:${J}`;return"unknown"}function hF(Z,Y){let Q=_E(Z),J=NE(Q,Y);if(!J)return Z;return a6(Z,J,!1)}function _E(Z){return Z.trim().replace(/"/g,"").replace(/'s$/i,"")}function NE(Z,Y){if(!Z||!Y.host||!Y.provider)return null;return`https://${Y.host}/${Z}`}function gF(Z){let Y=0,Q=0,J=new Map,X=new Map,K=Z.split(`
|
|
453
|
+
`);for(let W of K){let q=W.split("\t");if(q.length<3)continue;let[G,U]=q;if(!/^\d+$/.test(G)||!/^\d+$/.test(U))continue;let B=parseInt(G,10),F=parseInt(U,10),$=B+F;if($<=0)continue;let O=pF(q.slice(2).join("\t").trim());if(F9.includes(rJ.extname(O).toLowerCase()))continue;Y+=B,Q+=F,X.set(O,(X.get(O)??0)+$);let D=B-F;if(D===0)continue;J.set(O,(J.get(O)??0)+D)}let z=Array.from(J.entries()).map(([W,q])=>({filePath:W,netLines:q})),H=Array.from(X.entries()).map(([W,q])=>({filePath:W,activityLines:q}));return{totalAdded:Y,totalRemoved:Q,totalRecords:K.length,netFiles:z,activityFiles:H}}function pF(Z){let Y=Z.lastIndexOf("=>");if(Y===-1)return Z;let Q=Z.slice(Y+2).trim();if(Q.startsWith("{"))Q=Q.slice(1);if(Q.endsWith("}"))Q=Q.slice(0,-1);return Q.trim()}function jE(Z,Y){let Q=new Set,J=`${Z}
|
|
454
|
+
${Y}`,X={};for(let K of J.split(`
|
|
455
|
+
`)){let z=K.trim().match(/^(?:unreachable|dangling) (\w+) ([0-9a-f]{40})$/i);if(!z)continue;let H=z[2].toLowerCase();if(!Q.has(H)){Q.add(H);let W=z[1].toLowerCase();X[W]=(X[W]||0)+1}}return{total:Q.size,commit:X.commit||0,objectIds:Q}}function wE(Z,Y){let Q=0,J=0,X=0;for(let K of Z.split(`
|
|
456
|
+
`)){let z=K.trim().match(/^([0-9a-f]{40}):(\d+)$/i);if(!z)continue;let H=z[1].toLowerCase(),W=parseInt(z[2],10);if(Q+=1,J+=W,Y.has(H))X+=W}return{totalObjects:Q,totalBytes:J,garbageObjects:Y.size,garbageBytes:X}}function f8(Z){return Math.max(0,Math.trunc(Z)).toLocaleString("en-US")}function TE(Z,Y,Q){if(Q<=0)return null;let J=0,X=new Map;for(let N of Y){let L=yF(Z,N.filePath);if(!L){J+=N.lines;continue}let x=X.get(L.name);if(x)x.lines+=N.lines;else X.set(L.name,{name:L.name,color:L.color,lines:N.lines})}let K=[...X.values()].filter((N)=>N.lines>0),z=Math.max(0,J),H=K.reduce((N,L)=>N+L.lines,0)+z;if(H<=0)return null;let W=[],q=z;for(let N of K){let L=N.lines/H*Q;if(L<1){q+=N.lines;continue}let x=Math.floor(L);W.push({name:N.name,color:N.color,lines:N.lines,cols:x,remainder:L-x,isOthers:!1})}if(q>0){let N=q/H*Q,L=Math.floor(N);W.push({name:"Others",color:sJ,lines:q,cols:L,remainder:N-L,isOthers:!0})}if(W.length===0)return null;let G=W.find((N)=>N.isOthers);if(G&&G.cols===0)G.cols=1,G.remainder=0;let U=W.reduce((N,L)=>N+L.cols,0);if(U>Q){let N=W.filter((L)=>!L.isOthers).sort((L,x)=>x.cols-L.cols);for(let L of N){while(U>Q&&L.cols>1)L.cols-=1,U-=1;if(U<=Q)break}}if(U>Q&&G&&G.cols>1)while(U>Q&&G.cols>1)G.cols-=1,U-=1;let B=Q-U;if(B>0){let N=[...W].sort((x,S)=>S.remainder-x.remainder),L=0;while(B>0&&N.length>0)N[L%N.length].cols+=1,B-=1,L+=1}let F=W.filter((N)=>N.cols>0).sort((N,L)=>L.lines-N.lines),$=H*0.18,[O,D]=uH(F.slice(0,6),(N,L)=>{if(N.lines>=$)return 0;if(L===0)return 0;return 1}),j=O.map((N)=>H8(N.lines/H*100,1,!0)),M=F.map((N)=>`${V(N.color,"fg")}${"━".repeat(N.cols)}`).join("")+V(),T=O.map((N,L)=>`${V(N.color,"fg")}●${V()} ${j[L]}% ${N.name}`).join(" ")+V("Dim")+" "+(D?D.map((N)=>`${V(N.color,"fg")}●${V("White")} ${N.name}`).join(" "):"");return{bar:M,legend:T}}function LE(Z,Y){if(!Y)return"auto";if(!Z)return null;let Q=Z.trim().toLowerCase();if(Q==="auto"||Q==="net"||Q==="activity")return Q;return null}function IE(Z,Y){if(Z==="auto")return Y?"net":"activity";return Z}var mF,uF;var m2=_(()=>{G0();P0();w0();Y7();b8();B0();A0();I0();R0();O6();fF();mF={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
457
|
+
${Z+c("STATS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
458
|
+
Gather detailed contribution statistics for a git author in this repository.
|
|
459
|
+
|
|
460
|
+
${Z+c("WHAT IT COMPUTES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
461
|
+
Total commits by the selected scope, today's commits, lines added/removed, rough size estimates (bytes), estimated functions/files added or removed, contribution percentage of the project, most active branch, language bar (activity or net), and time of the last commit. In project-wide mode, it also shows total object count/size and garbage object count/size (objects that would be pruned by ${Y}git gc${Q}).
|
|
462
|
+
|
|
463
|
+
${Z+c("HOW IT WORKS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
464
|
+
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.
|
|
465
|
+
|
|
466
|
+
${Z+c("OPTIONS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
467
|
+
Use ${Y}--author <email>${Q} to target a different author than the configured git user.email. Use ${Y}--all${Q} or ${Y}-a${Q} for project-wide stats across all authors. Use ${Y}--lang-metric <auto|net|activity>${Q} to choose whether the language bar reflects net lines (added - removed), activity (added + removed), or automatic mode (project-wide net, author activity). Output includes a small visual graph invocation via the \`${Y}graph${Q}\` command by default.
|
|
468
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Show contribution statistics for an author or the whole project.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
469
|
+
${Z}${C} stats ${Y}[--author <email>] [--all|-a] [--lang-metric <auto|net|activity>]${Q}
|
|
470
|
+
|
|
471
|
+
Examples:
|
|
472
|
+
${Z}${C} stats ${Q+Y}# Stats for configured git user${Q}
|
|
473
|
+
${Z}${C} stats --author alice@example.com ${Q+Y}# Stats for specified author${Q}
|
|
474
|
+
${Z}${C} stats --all ${Q+Y}# Project-wide stats for all authors${Q}
|
|
475
|
+
${Z}${C} stats --lang-metric net ${Q+Y}# Force net language usage in author scope${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},uF={$root:["--author","--all","-a","--lang-metric"]}});function r(Z,Y,Q,J,X){if(J==="m")throw TypeError("Private method is not writable");if(J==="a"&&!X)throw TypeError("Private accessor was defined without a setter");if(typeof Y==="function"?Z!==Y||!X:!Y.has(Z))throw TypeError("Cannot write private member to an object whose class did not declare it");return J==="a"?X.call(Z,Q):X?X.value=Q:Y.set(Z,Q),Q}function A(Z,Y,Q,J){if(Q==="a"&&!J)throw TypeError("Private accessor was defined without a getter");if(typeof Y==="function"?Z!==Y||!J:!Y.has(Z))throw TypeError("Cannot read private member from an object whose class did not declare it");return Q==="m"?J:Q==="a"?J.call(Z):J?J.value:Y.get(Z)}var y6=()=>{};var eJ=function(){let{crypto:Z}=globalThis;if(Z?.randomUUID)return eJ=Z.randomUUID.bind(Z),Z.randomUUID();let Y=new Uint8Array(1),Q=Z?()=>Z.getRandomValues(Y)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(J)=>(+J^Q()&15>>+J/4).toString(16))};function J7(Z){return typeof Z==="object"&&Z!==null&&(("name"in Z)&&Z.name==="AbortError"||("message"in Z)&&String(Z.message).includes("FetchRequestCanceledException"))}var X7=(Z)=>{if(Z instanceof Error)return Z;if(typeof Z==="object"&&Z!==null){try{if(Object.prototype.toString.call(Z)==="[object Error]"){let Y=Error(Z.message,Z.cause?{cause:Z.cause}:{});if(Z.stack)Y.stack=Z.stack;if(Z.cause&&!Y.cause)Y.cause=Z.cause;if(Z.name)Y.name=Z.name;return Y}}catch{}try{return Error(JSON.stringify(Z))}catch{}}return Error(Z)};var n,v0,f0,v4,y4,K7,z7,H7,W7,q7,G7,U7,V7,B7,$7,x1;var X1=_(()=>{n=class n extends Error{};v0=class v0 extends n{constructor(Z,Y,Q,J){super(`${v0.makeMessage(Z,Y,Q)}`);this.status=Z,this.headers=J,this.requestID=J?.get("x-request-id"),this.error=Y;let X=Y;this.code=X?.code,this.param=X?.param,this.type=X?.type}static makeMessage(Z,Y,Q){let J=Y?.message?typeof Y.message==="string"?Y.message:JSON.stringify(Y.message):Y?JSON.stringify(Y):Q;if(Z&&J)return`${Z} ${J}`;if(Z)return`${Z} status code (no body)`;if(J)return J;return"(no status code or body)"}static generate(Z,Y,Q,J){if(!Z||!J)return new v4({message:Q,cause:X7(Y)});let X=Y?.error;if(Z===400)return new K7(Z,X,Q,J);if(Z===401)return new z7(Z,X,Q,J);if(Z===403)return new H7(Z,X,Q,J);if(Z===404)return new W7(Z,X,Q,J);if(Z===409)return new q7(Z,X,Q,J);if(Z===422)return new G7(Z,X,Q,J);if(Z===429)return new U7(Z,X,Q,J);if(Z>=500)return new V7(Z,X,Q,J);return new v0(Z,X,Q,J)}};f0=class f0 extends v0{constructor({message:Z}={}){super(void 0,void 0,Z||"Request was aborted.",void 0)}};v4=class v4 extends v0{constructor({message:Z,cause:Y}){super(void 0,void 0,Z||"Connection error.",void 0);if(Y)this.cause=Y}};y4=class y4 extends v4{constructor({message:Z}={}){super({message:Z??"Request timed out."})}};K7=class K7 extends v0{};z7=class z7 extends v0{};H7=class H7 extends v0{};W7=class W7 extends v0{};q7=class q7 extends v0{};G7=class G7 extends v0{};U7=class U7 extends v0{};V7=class V7 extends v0{};B7=class B7 extends n{constructor(){super("Could not parse response content as the length limit was reached")}};$7=class $7 extends n{constructor(){super("Could not parse response content as the request was rejected by the content filter")}};x1=class x1 extends Error{constructor(Z){super(Z)}}});function YX(Z){if(typeof Z!=="object")return{};return Z??{}}function QX(Z){if(!Z)return!0;for(let Y in Z)return!1;return!0}function cF(Z,Y){return Object.prototype.hasOwnProperty.call(Z,Y)}function F7(Z){return Z!=null&&typeof Z==="object"&&!Array.isArray(Z)}var CE,dF=(Z)=>{return CE.test(Z)},J6=(Z)=>(J6=Array.isArray,J6(Z)),ZX,lF=(Z,Y)=>{if(typeof Y!=="number"||!Number.isInteger(Y))throw new n(`${Z} must be an integer`);if(Y<0)throw new n(`${Z} must be a positive integer`);return Y},iF=(Z)=>{try{return JSON.parse(Z)}catch(Y){return}};var S1=_(()=>{X1();CE=/^[a-z][a-z0-9+.-]*:/i,ZX=J6});var K1=(Z)=>new Promise((Y)=>setTimeout(Y,Z));var e1="6.32.0";function EE(){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 SE(){if(typeof navigator>"u"||!navigator)return null;let Z=[{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:Y,pattern:Q}of Z){let J=Q.exec(navigator.userAgent);if(J){let X=J[1]||0,K=J[2]||0,z=J[3]||0;return{browser:Y,version:`${X}.${K}.${z}`}}}return null}var sF=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},xE=()=>{let Z=EE();if(Z==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e1,"X-Stainless-OS":oF(Deno.build.os),"X-Stainless-Arch":nF(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":e1,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(Z==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e1,"X-Stainless-OS":oF(globalThis.process.platform??"unknown"),"X-Stainless-Arch":nF(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Y=SE();if(Y)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e1,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Y.browser}`,"X-Stainless-Runtime-Version":Y.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":e1,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},nF=(Z)=>{if(Z==="x32")return"x32";if(Z==="x86_64"||Z==="x64")return"x64";if(Z==="arm")return"arm";if(Z==="aarch64"||Z==="arm64")return"arm64";if(Z)return`other:${Z}`;return"unknown"},oF=(Z)=>{if(Z=Z.toLowerCase(),Z.includes("ios"))return"iOS";if(Z==="android")return"Android";if(Z==="darwin")return"MacOS";if(Z==="win32")return"Windows";if(Z==="freebsd")return"FreeBSD";if(Z==="openbsd")return"OpenBSD";if(Z==="linux")return"Linux";if(Z)return`Other:${Z}`;return"Unknown"},aF,rF=()=>{return aF??(aF=xE())};var JX=()=>{};function tF(){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 XX(...Z){let Y=globalThis.ReadableStream;if(typeof Y>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Y(...Z)}function u2(Z){let Y=Symbol.asyncIterator in Z?Z[Symbol.asyncIterator]():Z[Symbol.iterator]();return XX({start(){},async pull(Q){let{done:J,value:X}=await Y.next();if(J)Q.close();else Q.enqueue(X)},async cancel(){await Y.return?.()}})}function KX(Z){if(Z[Symbol.asyncIterator])return Z;let Y=Z.getReader();return{async next(){try{let Q=await Y.read();if(Q?.done)Y.releaseLock();return Q}catch(Q){throw Y.releaseLock(),Q}},async return(){let Q=Y.cancel();return Y.releaseLock(),await Q,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function eF(Z){if(Z===null||typeof Z!=="object")return;if(Z[Symbol.asyncIterator]){await Z[Symbol.asyncIterator]().return?.();return}let Y=Z.getReader(),Q=Y.cancel();Y.releaseLock(),await Q}var ZO=({headers:Z,body:Y})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Y)}};var zX="RFC3986",HX=(Z)=>String(Z),WX,YO="RFC1738";var qX=_(()=>{WX={RFC1738:(Z)=>String(Z).replace(/%20/g,"+"),RFC3986:HX}});function JO(Z){if(!Z||typeof Z!=="object")return!1;return!!(Z.constructor&&Z.constructor.isBuffer&&Z.constructor.isBuffer(Z))}function UX(Z,Y){if(J6(Z)){let Q=[];for(let J=0;J<Z.length;J+=1)Q.push(Y(Z[J]));return Q}return Y(Z)}var p2=(Z,Y)=>(p2=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),p2(Z,Y)),z1,GX=1024,QO=(Z,Y,Q,J,X)=>{if(Z.length===0)return Z;let K=Z;if(typeof Z==="symbol")K=Symbol.prototype.toString.call(Z);else if(typeof Z!=="string")K=String(Z);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 z="";for(let H=0;H<K.length;H+=GX){let W=K.length>=GX?K.slice(H,H+GX):K,q=[];for(let G=0;G<W.length;++G){let U=W.charCodeAt(G);if(U===45||U===46||U===95||U===126||U>=48&&U<=57||U>=65&&U<=90||U>=97&&U<=122||X===YO&&(U===40||U===41)){q[q.length]=W.charAt(G);continue}if(U<128){q[q.length]=z1[U];continue}if(U<2048){q[q.length]=z1[192|U>>6]+z1[128|U&63];continue}if(U<55296||U>=57344){q[q.length]=z1[224|U>>12]+z1[128|U>>6&63]+z1[128|U&63];continue}G+=1,U=65536+((U&1023)<<10|W.charCodeAt(G)&1023),q[q.length]=z1[240|U>>18]+z1[128|U>>12&63]+z1[128|U>>6&63]+z1[128|U&63]}z+=q.join("")}return z};var XO=_(()=>{qX();S1();z1=(()=>{let Z=[];for(let Y=0;Y<256;++Y)Z.push("%"+((Y<16?"0":"")+Y.toString(16)).toUpperCase());return Z})()});function vE(Z){return typeof Z==="string"||typeof Z==="number"||typeof Z==="boolean"||typeof Z==="symbol"||typeof Z==="bigint"}function WO(Z,Y,Q,J,X,K,z,H,W,q,G,U,B,F,$,O,D,j){let M=Z,T=j,N=0,L=!1;while((T=T.get(VX))!==void 0&&!L){let f=T.get(Z);if(N+=1,typeof f<"u")if(f===N)throw RangeError("Cyclic object value");else L=!0;if(typeof T.get(VX)>"u")N=0}if(typeof q==="function")M=q(Y,M);else if(M instanceof Date)M=B?.(M);else if(Q==="comma"&&J6(M))M=UX(M,function(f){if(f instanceof Date)return B?.(f);return f});if(M===null){if(K)return W&&!O?W(Y,h0.encoder,D,"key",F):Y;M=""}if(vE(M)||JO(M)){if(W){let f=O?Y:W(Y,h0.encoder,D,"key",F);return[$?.(f)+"="+$?.(W(M,h0.encoder,D,"value",F))]}return[$?.(Y)+"="+$?.(String(M))]}let x=[];if(typeof M>"u")return x;let S;if(Q==="comma"&&J6(M)){if(O&&W)M=UX(M,W);S=[{value:M.length>0?M.join(",")||null:void 0}]}else if(J6(q))S=q;else{let f=Object.keys(M);S=G?f.sort(G):f}let g=H?String(Y).replace(/\./g,"%2E"):String(Y),h=J&&J6(M)&&M.length===1?g+"[]":g;if(X&&J6(M)&&M.length===0)return h+"[]";for(let f=0;f<S.length;++f){let v=S[f],d=typeof v==="object"&&typeof v.value<"u"?v.value:M[v];if(z&&d===null)continue;let y=U&&H?v.replace(/\./g,"%2E"):v,e=J6(M)?typeof Q==="function"?Q(h,y):h:h+(U?"."+y:"["+y+"]");j.set(Z,N);let V0=new WeakMap;V0.set(VX,j),HO(x,WO(d,e,Q,J,X,K,z,H,Q==="comma"&&O&&J6(M)?null:W,q,G,U,B,F,$,O,D,V0))}return x}function yE(Z=h0){if(typeof Z.allowEmptyArrays<"u"&&typeof Z.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof Z.encodeDotInKeys<"u"&&typeof Z.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(Z.encoder!==null&&typeof Z.encoder<"u"&&typeof Z.encoder!=="function")throw TypeError("Encoder has to be a function.");let Y=Z.charset||h0.charset;if(typeof Z.charset<"u"&&Z.charset!=="utf-8"&&Z.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let Q=zX;if(typeof Z.format<"u"){if(!p2(WX,Z.format))throw TypeError("Unknown format option provided.");Q=Z.format}let J=WX[Q],X=h0.filter;if(typeof Z.filter==="function"||J6(Z.filter))X=Z.filter;let K;if(Z.arrayFormat&&Z.arrayFormat in zO)K=Z.arrayFormat;else if("indices"in Z)K=Z.indices?"indices":"repeat";else K=h0.arrayFormat;if("commaRoundTrip"in Z&&typeof Z.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let z=typeof Z.allowDots>"u"?!!Z.encodeDotInKeys===!0?!0:h0.allowDots:!!Z.allowDots;return{addQueryPrefix:typeof Z.addQueryPrefix==="boolean"?Z.addQueryPrefix:h0.addQueryPrefix,allowDots:z,allowEmptyArrays:typeof Z.allowEmptyArrays==="boolean"?!!Z.allowEmptyArrays:h0.allowEmptyArrays,arrayFormat:K,charset:Y,charsetSentinel:typeof Z.charsetSentinel==="boolean"?Z.charsetSentinel:h0.charsetSentinel,commaRoundTrip:!!Z.commaRoundTrip,delimiter:typeof Z.delimiter>"u"?h0.delimiter:Z.delimiter,encode:typeof Z.encode==="boolean"?Z.encode:h0.encode,encodeDotInKeys:typeof Z.encodeDotInKeys==="boolean"?Z.encodeDotInKeys:h0.encodeDotInKeys,encoder:typeof Z.encoder==="function"?Z.encoder:h0.encoder,encodeValuesOnly:typeof Z.encodeValuesOnly==="boolean"?Z.encodeValuesOnly:h0.encodeValuesOnly,filter:X,format:Q,formatter:J,serializeDate:typeof Z.serializeDate==="function"?Z.serializeDate:h0.serializeDate,skipNulls:typeof Z.skipNulls==="boolean"?Z.skipNulls:h0.skipNulls,sort:typeof Z.sort==="function"?Z.sort:null,strictNullHandling:typeof Z.strictNullHandling==="boolean"?Z.strictNullHandling:h0.strictNullHandling}}function qO(Z,Y={}){let Q=Z,J=yE(Y),X,K;if(typeof J.filter==="function")K=J.filter,Q=K("",Q);else if(J6(J.filter))K=J.filter,X=K;let z=[];if(typeof Q!=="object"||Q===null)return"";let H=zO[J.arrayFormat],W=H==="comma"&&J.commaRoundTrip;if(!X)X=Object.keys(Q);if(J.sort)X.sort(J.sort);let q=new WeakMap;for(let B=0;B<X.length;++B){let F=X[B];if(J.skipNulls&&Q[F]===null)continue;HO(z,WO(Q[F],F,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=z.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 zO,HO=function(Z,Y){Array.prototype.push.apply(Z,J6(Y)?Y:[Y])},KO,h0,VX;var GO=_(()=>{XO();qX();S1();zO={brackets(Z){return String(Z)+"[]"},comma:"comma",indices(Z,Y){return String(Z)+"["+Y+"]"},repeat(Z){return String(Z)}},h0={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:QO,encodeValuesOnly:!1,format:zX,formatter:HX,indices:!1,serializeDate(Z){return(KO??(KO=Function.prototype.call.bind(Date.prototype.toISOString)))(Z)},skipNulls:!1,strictNullHandling:!1};VX={}});function UO(Z){return qO(Z,{arrayFormat:"brackets"})}var BX=_(()=>{GO()});function $O(Z){let Y=0;for(let X of Z)Y+=X.length;let Q=new Uint8Array(Y),J=0;for(let X of Z)Q.set(X,J),J+=X.length;return Q}function h8(Z){let Y;return(VO??(Y=new globalThis.TextEncoder,VO=Y.encode.bind(Y)))(Z)}function $X(Z){let Y;return(BO??(Y=new globalThis.TextDecoder,BO=Y.decode.bind(Y)))(Z)}var VO,BO;class g8{constructor(){w6.set(this,void 0),T6.set(this,void 0),r(this,w6,new Uint8Array,"f"),r(this,T6,null,"f")}decode(Z){if(Z==null)return[];let Y=Z instanceof ArrayBuffer?new Uint8Array(Z):typeof Z==="string"?h8(Z):Z;r(this,w6,$O([A(this,w6,"f"),Y]),"f");let Q=[],J;while((J=fE(A(this,w6,"f"),A(this,T6,"f")))!=null){if(J.carriage&&A(this,T6,"f")==null){r(this,T6,J.index,"f");continue}if(A(this,T6,"f")!=null&&(J.index!==A(this,T6,"f")+1||J.carriage)){Q.push($X(A(this,w6,"f").subarray(0,A(this,T6,"f")-1))),r(this,w6,A(this,w6,"f").subarray(A(this,T6,"f")),"f"),r(this,T6,null,"f");continue}let X=A(this,T6,"f")!==null?J.preceding-1:J.preceding,K=$X(A(this,w6,"f").subarray(0,X));Q.push(K),r(this,w6,A(this,w6,"f").subarray(J.index),"f"),r(this,T6,null,"f")}return Q}flush(){if(!A(this,w6,"f").length)return[];return this.decode(`
|
|
476
|
+
`)}}function fE(Z,Y){for(let X=Y??0;X<Z.length;X++){if(Z[X]===10)return{preceding:X,index:X+1,carriage:!1};if(Z[X]===13)return{preceding:X,index:X+1,carriage:!0}}return null}function FO(Z){for(let J=0;J<Z.length-1;J++){if(Z[J]===10&&Z[J+1]===10)return J+2;if(Z[J]===13&&Z[J+1]===13)return J+2;if(Z[J]===13&&Z[J+1]===10&&J+3<Z.length&&Z[J+2]===13&&Z[J+3]===10)return J+4}return-1}var w6,T6;var OO=_(()=>{y6();w6=new WeakMap,T6=new WeakMap;g8.NEWLINE_CHARS=new Set([`
|
|
477
|
+
`,"\r"]);g8.NEWLINE_REGEXP=/\r\n|[\n\r]/g});function O7(){}function d2(Z,Y,Q){if(!Y||c2[Z]>c2[Q])return O7;else return Y[Z].bind(Y)}function E0(Z){let Y=Z.logger,Q=Z.logLevel??"off";if(!Y)return hE;let J=RO.get(Y);if(J&&J[0]===Q)return J[1];let X={error:d2("error",Y,Q),warn:d2("warn",Y,Q),info:d2("info",Y,Q),debug:d2("debug",Y,Q)};return RO.set(Y,[Q,X]),X}var c2,FX=(Z,Y,Q)=>{if(!Z)return;if(cF(c2,Z))return Z;E0(Q).warn(`${Y} was set to ${JSON.stringify(Z)}, expected one of ${JSON.stringify(Object.keys(c2))}`);return},hE,RO,k1=(Z)=>{if(Z.options)Z.options={...Z.options},delete Z.options.headers;if(Z.headers)Z.headers=Object.fromEntries((Z.headers instanceof Headers?[...Z.headers]:Object.entries(Z.headers)).map(([Y,Q])=>[Y,Y.toLowerCase()==="authorization"||Y.toLowerCase()==="cookie"||Y.toLowerCase()==="set-cookie"?"***":Q]));if("retryOfRequestLogID"in Z){if(Z.retryOfRequestLogID)Z.retryOf=Z.retryOfRequestLogID;delete Z.retryOfRequestLogID}return Z};var R7=_(()=>{S1();c2={off:0,error:200,warn:300,info:400,debug:500};hE={error:O7,warn:O7,info:O7,debug:O7},RO=new WeakMap});async function*gE(Z,Y){if(!Z.body){if(Y.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new n("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 n("Attempted to iterate over a response with no body")}let Q=new MO,J=new g8,X=KX(Z.body);for await(let K of mE(X))for(let z of J.decode(K)){let H=Q.decode(z);if(H)yield H}for(let K of J.flush()){let z=Q.decode(K);if(z)yield z}}async function*mE(Z){let Y=new Uint8Array;for await(let Q of Z){if(Q==null)continue;let J=Q instanceof ArrayBuffer?new Uint8Array(Q):typeof Q==="string"?h8(Q):Q,X=new Uint8Array(Y.length+J.length);X.set(Y),X.set(J,Y.length),Y=X;let K;while((K=FO(Y))!==-1)yield Y.slice(0,K),Y=Y.slice(K)}if(Y.length>0)yield Y}class MO{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(Z){if(Z.endsWith("\r"))Z=Z.substring(0,Z.length-1);if(!Z){if(!this.event&&!this.data.length)return null;let X={event:this.event,data:this.data.join(`
|
|
478
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],X}if(this.chunks.push(Z),Z.startsWith(":"))return null;let[Y,Q,J]=uE(Z,":");if(J.startsWith(" "))J=J.substring(1);if(Y==="event")this.event=J;else if(Y==="data")this.data.push(J);return null}}function uE(Z,Y){let Q=Z.indexOf(Y);if(Q!==-1)return[Z.substring(0,Q),Y,Z.substring(Q+Y.length)];return[Z,"",""]}var M7,L6;var OX=_(()=>{y6();X1();OO();R7();X1();L6=class L6{constructor(Z,Y,Q){this.iterator=Z,M7.set(this,void 0),this.controller=Y,r(this,M7,Q,"f")}static fromSSEResponse(Z,Y,Q,J){let X=!1,K=Q?E0(Q):console;async function*z(){if(X)throw new n("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let H=!1;try{for await(let W of gE(Z,Y)){if(H)continue;if(W.data.startsWith("[DONE]")){H=!0;continue}if(W.event===null||!W.event.startsWith("thread.")){let q;try{q=JSON.parse(W.data)}catch(G){throw K.error("Could not parse message into JSON:",W.data),K.error("From chunk:",W.raw),G}if(q&&q.error)throw new v0(void 0,q.error,void 0,Z.headers);yield J?{event:W.event,data:q}:q}else{let q;try{q=JSON.parse(W.data)}catch(G){throw console.error("Could not parse message into JSON:",W.data),console.error("From chunk:",W.raw),G}if(W.event=="error")throw new v0(void 0,q.error,q.message,void 0);yield{event:W.event,data:q}}}H=!0}catch(W){if(J7(W))return;throw W}finally{if(!H)Y.abort()}}return new L6(z,Y,Q)}static fromReadableStream(Z,Y,Q){let J=!1;async function*X(){let z=new g8,H=KX(Z);for await(let W of H)for(let q of z.decode(W))yield q;for(let W of z.flush())yield W}async function*K(){if(J)throw new n("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");J=!0;let z=!1;try{for await(let H of X()){if(z)continue;if(H)yield JSON.parse(H)}z=!0}catch(H){if(J7(H))return;throw H}finally{if(!z)Y.abort()}}return new L6(K,Y,Q)}[(M7=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let Z=[],Y=[],Q=this.iterator(),J=(X)=>{return{next:()=>{if(X.length===0){let K=Q.next();Z.push(K),Y.push(K)}return X.shift()}}};return[new L6(()=>J(Z),this.controller,A(this,M7,"f")),new L6(()=>J(Y),this.controller,A(this,M7,"f"))]}toReadableStream(){let Z=this,Y;return XX({async start(){Y=Z[Symbol.asyncIterator]()},async pull(Q){try{let{value:J,done:X}=await Y.next();if(X)return Q.close();let K=h8(JSON.stringify(J)+`
|
|
479
|
+
`);Q.enqueue(K)}catch(J){Q.error(J)}},async cancel(){await Y.return?.()}})}}});async function l2(Z,Y){let{response:Q,requestLogID:J,retryOfRequestLogID:X,startTime:K}=Y,z=await(async()=>{if(Y.options.stream){if(E0(Z).debug("response",Q.status,Q.url,Q.headers,Q.body),Y.options.__streamClass)return Y.options.__streamClass.fromSSEResponse(Q,Y.controller,Z,Y.options.__synthesizeEventData);return L6.fromSSEResponse(Q,Y.controller,Z,Y.options.__synthesizeEventData)}if(Q.status===204)return null;if(Y.options.__binaryResponse)return Q;let W=Q.headers.get("content-type")?.split(";")[0]?.trim();if(W?.includes("application/json")||W?.endsWith("+json")){if(Q.headers.get("content-length")==="0")return;let B=await Q.json();return RX(B,Q)}return await Q.text()})();return E0(Z).debug(`[${J}] response parsed`,k1({retryOfRequestLogID:X,url:Q.url,status:Q.status,body:z,durationMs:Date.now()-K})),z}function RX(Z,Y){if(!Z||typeof Z!=="object"||Array.isArray(Z))return Z;return Object.defineProperty(Z,"_request_id",{value:Y.headers.get("x-request-id"),enumerable:!1})}var MX=_(()=>{OX();R7()});var D7,b4;var i2=_(()=>{y6();MX();b4=class b4 extends Promise{constructor(Z,Y,Q=l2){super((J)=>{J(null)});this.responsePromise=Y,this.parseResponse=Q,D7.set(this,void 0),r(this,D7,Z,"f")}_thenUnwrap(Z){return new b4(A(this,D7,"f"),this.responsePromise,async(Y,Q)=>RX(Z(await this.parseResponse(Y,Q),Q),Q.response))}asResponse(){return this.responsePromise.then((Z)=>Z.response)}async withResponse(){let[Z,Y]=await Promise.all([this.parse(),this.asResponse()]);return{data:Z,response:Y,request_id:Y.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then((Z)=>this.parseResponse(A(this,D7,"f"),Z));return this.parsedPromise}then(Z,Y){return this.parse().then(Z,Y)}catch(Z){return this.parse().catch(Z)}finally(Z){return this.parse().finally(Z)}};D7=new WeakMap});var n2,o2,a2,P1,K0,H1;var M0=_(()=>{y6();X1();MX();i2();S1();o2=class o2{constructor(Z,Y,Q,J){n2.set(this,void 0),r(this,n2,Z,"f"),this.options=J,this.response=Y,this.body=Q}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let Z=this.nextPageRequestOptions();if(!Z)throw new n("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await A(this,n2,"f").requestAPIList(this.constructor,Z)}async*iterPages(){let Z=this;yield Z;while(Z.hasNextPage())Z=await Z.getNextPage(),yield Z}async*[(n2=new WeakMap,Symbol.asyncIterator)](){for await(let Z of this.iterPages())for(let Y of Z.getPaginatedItems())yield Y}};a2=class a2 extends b4{constructor(Z,Y,Q){super(Z,Y,async(J,X)=>new Q(J,X.response,await l2(J,X),X.options))}async*[Symbol.asyncIterator](){let Z=await this;for await(let Y of Z)yield Y}};P1=class P1 extends o2{constructor(Z,Y,Q,J){super(Z,Y,Q,J);this.data=Q.data||[],this.object=Q.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}};K0=class K0 extends o2{constructor(Z,Y,Q,J){super(Z,Y,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 Z=this.getPaginatedItems(),Y=Z[Z.length-1]?.id;if(!Y)return null;return{...this.options,query:{...YX(this.options.query),after:Y}}}};H1=class H1 extends o2{constructor(Z,Y,Q,J){super(Z,Y,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 Z=this.last_id;if(!Z)return null;return{...this.options,query:{...YX(this.options.query),after:Z}}}}});function m8(Z,Y,Q){return NX(),new File(Z,Y??"unknown_file",Q)}function _7(Z){return(typeof Z==="object"&&Z!==null&&(("name"in Z)&&Z.name&&String(Z.name)||("url"in Z)&&Z.url&&String(Z.url)||("filename"in Z)&&Z.filename&&String(Z.filename)||("path"in Z)&&Z.path&&String(Z.path))||"").split(/[\\/]/).pop()||void 0}function dE(Z){let Y=typeof Z==="function"?Z:Z.fetch,Q=DO.get(Y);if(Q)return Q;let J=(async()=>{try{let X="Response"in Y?Y.Response:(await Y("data:,")).constructor,K=new FormData;if(K.toString()===await new X(K).text())return!1;return!0}catch{return!0}})();return DO.set(Y,J),J}var NX=()=>{if(typeof File>"u"){let{process:Z}=globalThis,Y=typeof Z?.versions?.node==="string"&&parseInt(Z.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(Y?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}},s2=(Z)=>Z!=null&&typeof Z==="object"&&typeof Z[Symbol.asyncIterator]==="function",Z4=async(Z,Y)=>{if(!DX(Z.body))return Z;return{...Z,body:await _O(Z.body,Y)}},X6=async(Z,Y)=>{return{...Z,body:await _O(Z.body,Y)}},DO,_O=async(Z,Y)=>{if(!await dE(Y))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(Z||{}).map(([J,X])=>_X(Q,J,X))),Q},NO=(Z)=>Z instanceof Blob&&("name"in Z),cE=(Z)=>typeof Z==="object"&&Z!==null&&(Z instanceof Response||s2(Z)||NO(Z)),DX=(Z)=>{if(cE(Z))return!0;if(Array.isArray(Z))return Z.some(DX);if(Z&&typeof Z==="object"){for(let Y in Z)if(DX(Z[Y]))return!0}return!1},_X=async(Z,Y,Q)=>{if(Q===void 0)return;if(Q==null)throw TypeError(`Received null for "${Y}"; to pass null in FormData, you must use the string 'null'`);if(typeof Q==="string"||typeof Q==="number"||typeof Q==="boolean")Z.append(Y,String(Q));else if(Q instanceof Response)Z.append(Y,m8([await Q.blob()],_7(Q)));else if(s2(Q))Z.append(Y,m8([await new Response(u2(Q)).blob()],_7(Q)));else if(NO(Q))Z.append(Y,Q,_7(Q));else if(Array.isArray(Q))await Promise.all(Q.map((J)=>_X(Z,Y+"[]",J)));else if(typeof Q==="object")await Promise.all(Object.entries(Q).map(([J,X])=>_X(Z,`${Y}[${J}]`,X)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${Q} instead`)};var b6=_(()=>{DO=new WeakMap});async function r2(Z,Y,Q){if(NX(),Z=await Z,lE(Z)){if(Z instanceof File)return Z;return m8([await Z.arrayBuffer()],Z.name)}if(iE(Z)){let X=await Z.blob();return Y||(Y=new URL(Z.url).pathname.split(/[\\/]/).pop()),m8(await jX(X),Y,Q)}let J=await jX(Z);if(Y||(Y=_7(Z)),!Q?.type){let X=J.find((K)=>typeof K==="object"&&("type"in K)&&K.type);if(typeof X==="string")Q={...Q,type:X}}return m8(J,Y,Q)}async function jX(Z){let Y=[];if(typeof Z==="string"||ArrayBuffer.isView(Z)||Z instanceof ArrayBuffer)Y.push(Z);else if(jO(Z))Y.push(Z instanceof Blob?Z:await Z.arrayBuffer());else if(s2(Z))for await(let Q of Z)Y.push(...await jX(Q));else{let Q=Z?.constructor?.name;throw Error(`Unexpected data type: ${typeof Z}${Q?`; constructor: ${Q}`:""}${nE(Z)}`)}return Y}function nE(Z){if(typeof Z!=="object"||Z===null)return"";return`; props: [${Object.getOwnPropertyNames(Z).map((Q)=>`"${Q}"`).join(", ")}]`}var jO=(Z)=>Z!=null&&typeof Z==="object"&&typeof Z.size==="number"&&typeof Z.type==="string"&&typeof Z.text==="function"&&typeof Z.slice==="function"&&typeof Z.arrayBuffer==="function",lE=(Z)=>Z!=null&&typeof Z==="object"&&typeof Z.name==="string"&&typeof Z.lastModified==="number"&&jO(Z),iE=(Z)=>Z!=null&&typeof Z==="object"&&typeof Z.url==="string"&&typeof Z.blob==="function";var wO=_(()=>{b6();b6()});var wX=_(()=>{wO()});class b{constructor(Z){this._client=Z}}function LO(Z){return Z.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var TO,aE=(Z=LO)=>function Y(Q,...J){if(Q.length===1)return Q[0];let X=!1,K=[],z=Q.reduce((G,U,B)=>{if(/[?#]/.test(U))X=!0;let F=J[B],$=(X?encodeURIComponent:Z)(""+F);if(B!==J.length&&(F==null||typeof F==="object"&&F.toString===Object.getPrototypeOf(Object.getPrototypeOf(F.hasOwnProperty??TO)??TO)?.toString))$=F+"",K.push({start:G.length+U.length,length:$.length,error:`Value of type ${Object.prototype.toString.call(F).slice(8,-1)} is not a valid path parameter`});return G+U+(B===J.length?"":$)},""),H=z.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,U)=>G.start-U.start),K.length>0){let G=0,U=K.reduce((B,F)=>{let $=" ".repeat(F.start-G),O="^".repeat(F.length);return G=F.start+F.length,B+$+O},"");throw new n(`Path parameters result in path with invalid segments:
|
|
480
|
+
${K.map((B)=>B.error).join(`
|
|
481
|
+
`)}
|
|
482
|
+
${z}
|
|
483
|
+
${U}`)}return z},P;var U0=_(()=>{X1();TO=Object.freeze(Object.create(null)),P=aE(LO)});var u8;var t2=_(()=>{M0();U0();u8=class u8 extends b{list(Z,Y={},Q){return this._client.getAPIList(P`/chat/completions/${Z}/messages`,K0,{query:Y,...Q})}}});var c6=_(()=>{X1()});function N7(Z){return Z!==void 0&&"function"in Z&&Z.function!==void 0}function j7(Z){return Z?.$brand==="auto-parseable-response-format"}function f4(Z){return Z?.$brand==="auto-parseable-tool"}function IO(Z,Y){if(!Y||!TX(Y))return{...Z,choices:Z.choices.map((Q)=>{return CO(Q.message.tool_calls),{...Q,message:{...Q.message,parsed:null,...Q.message.tool_calls?{tool_calls:Q.message.tool_calls}:void 0}}})};return w7(Z,Y)}function w7(Z,Y){let Q=Z.choices.map((J)=>{if(J.finish_reason==="length")throw new B7;if(J.finish_reason==="content_filter")throw new $7;return CO(J.message.tool_calls),{...J,message:{...J.message,...J.message.tool_calls?{tool_calls:J.message.tool_calls?.map((X)=>eE(Y,X))??void 0}:void 0,parsed:J.message.content&&!J.message.refusal?tE(Y,J.message.content):null}}});return{...Z,choices:Q}}function tE(Z,Y){if(Z.response_format?.type!=="json_schema")return null;if(Z.response_format?.type==="json_schema"){if("$parseRaw"in Z.response_format)return Z.response_format.$parseRaw(Y);return JSON.parse(Y)}return null}function eE(Z,Y){let Q=Z.tools?.find((J)=>N7(J)&&J.function?.name===Y.function.name);return{...Y,function:{...Y.function,parsed_arguments:f4(Q)?Q.$parseRaw(Y.function.arguments):Q?.function.strict?JSON.parse(Y.function.arguments):null}}}function AO(Z,Y){if(!Z||!("tools"in Z)||!Z.tools)return!1;let Q=Z.tools?.find((J)=>N7(J)&&J.function?.name===Y.function.name);return N7(Q)&&(f4(Q)||Q?.function.strict||!1)}function TX(Z){if(j7(Z.response_format))return!0;return Z.tools?.some((Y)=>f4(Y)||Y.type==="function"&&Y.function.strict===!0)??!1}function CO(Z){for(let Y of Z||[])if(Y.type!=="function")throw new n(`Currently only \`function\` tool calls are supported; Received \`${Y.type}\``)}function EO(Z){for(let Y of Z??[]){if(Y.type!=="function")throw new n(`Currently only \`function\` tool types support auto-parsing; Received \`${Y.type}\``);if(Y.function.strict!==!0)throw new n(`The \`${Y.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var T7=_(()=>{c6()});var p8=(Z)=>{return Z?.role==="assistant"},LX=(Z)=>{return Z?.role==="tool"};class h4{constructor(){IX.add(this),this.controller=new AbortController,e2.set(this,void 0),ZQ.set(this,()=>{}),L7.set(this,()=>{}),I7.set(this,void 0),YQ.set(this,()=>{}),A7.set(this,()=>{}),v1.set(this,{}),C7.set(this,!1),QQ.set(this,!1),JQ.set(this,!1),d8.set(this,!1),r(this,e2,new Promise((Z,Y)=>{r(this,ZQ,Z,"f"),r(this,L7,Y,"f")}),"f"),r(this,I7,new Promise((Z,Y)=>{r(this,YQ,Z,"f"),r(this,A7,Y,"f")}),"f"),A(this,e2,"f").catch(()=>{}),A(this,I7,"f").catch(()=>{})}_run(Z){setTimeout(()=>{Z().then(()=>{this._emitFinal(),this._emit("end")},A(this,IX,"m",xO).bind(this))},0)}_connected(){if(this.ended)return;A(this,ZQ,"f").call(this),this._emit("connect")}get ended(){return A(this,C7,"f")}get errored(){return A(this,QQ,"f")}get aborted(){return A(this,JQ,"f")}abort(){this.controller.abort()}on(Z,Y){return(A(this,v1,"f")[Z]||(A(this,v1,"f")[Z]=[])).push({listener:Y}),this}off(Z,Y){let Q=A(this,v1,"f")[Z];if(!Q)return this;let J=Q.findIndex((X)=>X.listener===Y);if(J>=0)Q.splice(J,1);return this}once(Z,Y){return(A(this,v1,"f")[Z]||(A(this,v1,"f")[Z]=[])).push({listener:Y,once:!0}),this}emitted(Z){return new Promise((Y,Q)=>{if(r(this,d8,!0,"f"),Z!=="error")this.once("error",Q);this.once(Z,Y)})}async done(){r(this,d8,!0,"f"),await A(this,I7,"f")}_emit(Z,...Y){if(A(this,C7,"f"))return;if(Z==="end")r(this,C7,!0,"f"),A(this,YQ,"f").call(this);let Q=A(this,v1,"f")[Z];if(Q)A(this,v1,"f")[Z]=Q.filter((J)=>!J.once),Q.forEach(({listener:J})=>J(...Y));if(Z==="abort"){let J=Y[0];if(!A(this,d8,"f")&&!Q?.length)Promise.reject(J);A(this,L7,"f").call(this,J),A(this,A7,"f").call(this,J),this._emit("end");return}if(Z==="error"){let J=Y[0];if(!A(this,d8,"f")&&!Q?.length)Promise.reject(J);A(this,L7,"f").call(this,J),A(this,A7,"f").call(this,J),this._emit("end")}}_emitFinal(){}}var IX,e2,ZQ,L7,I7,YQ,A7,v1,C7,QQ,JQ,d8,xO;var XQ=_(()=>{y6();c6();e2=new WeakMap,ZQ=new WeakMap,L7=new WeakMap,I7=new WeakMap,YQ=new WeakMap,A7=new WeakMap,v1=new WeakMap,C7=new WeakMap,QQ=new WeakMap,JQ=new WeakMap,d8=new WeakMap,IX=new WeakSet,xO=function Z(Y){if(r(this,QQ,!0,"f"),Y instanceof Error&&Y.name==="AbortError")Y=new f0;if(Y instanceof f0)return r(this,JQ,!0,"f"),this._emit("abort",Y);if(Y instanceof n)return this._emit("error",Y);if(Y instanceof Error){let Q=new n(Y.message);return Q.cause=Y,this._emit("error",Q)}return this._emit("error",new n(String(Y)))}});function SO(Z){return typeof Z.parse==="function"}var U6,AX,KQ,CX,EX,xX,kO,PO,Zx=10,E7;var SX=_(()=>{y6();c6();T7();XQ();E7=class E7 extends h4{constructor(){super(...arguments);U6.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(Z){this._chatCompletions.push(Z),this._emit("chatCompletion",Z);let Y=Z.choices[0]?.message;if(Y)this._addMessage(Y);return Z}_addMessage(Z,Y=!0){if(!("content"in Z))Z.content=null;if(this.messages.push(Z),Y){if(this._emit("message",Z),LX(Z)&&Z.content)this._emit("functionToolCallResult",Z.content);else if(p8(Z)&&Z.tool_calls){for(let Q of Z.tool_calls)if(Q.type==="function")this._emit("functionToolCall",Q.function)}}}async finalChatCompletion(){await this.done();let Z=this._chatCompletions[this._chatCompletions.length-1];if(!Z)throw new n("stream ended without producing a ChatCompletion");return Z}async finalContent(){return await this.done(),A(this,U6,"m",AX).call(this)}async finalMessage(){return await this.done(),A(this,U6,"m",KQ).call(this)}async finalFunctionToolCall(){return await this.done(),A(this,U6,"m",CX).call(this)}async finalFunctionToolCallResult(){return await this.done(),A(this,U6,"m",EX).call(this)}async totalUsage(){return await this.done(),A(this,U6,"m",xX).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let Z=this._chatCompletions[this._chatCompletions.length-1];if(Z)this._emit("finalChatCompletion",Z);let Y=A(this,U6,"m",KQ).call(this);if(Y)this._emit("finalMessage",Y);let Q=A(this,U6,"m",AX).call(this);if(Q)this._emit("finalContent",Q);let J=A(this,U6,"m",CX).call(this);if(J)this._emit("finalFunctionToolCall",J);let X=A(this,U6,"m",EX).call(this);if(X!=null)this._emit("finalFunctionToolCallResult",X);if(this._chatCompletions.some((K)=>K.usage))this._emit("totalUsage",A(this,U6,"m",xX).call(this))}async _createChatCompletion(Z,Y,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}A(this,U6,"m",kO).call(this,Y);let X=await Z.chat.completions.create({...Y,stream:!1},{...Q,signal:this.controller.signal});return this._connected(),this._addChatCompletion(w7(X,Y))}async _runChatCompletion(Z,Y,Q){for(let J of Y.messages)this._addMessage(J,!1);return await this._createChatCompletion(Z,Y,Q)}async _runTools(Z,Y,Q){let{tool_choice:X="auto",stream:K,...z}=Y,H=typeof X!=="string"&&X.type==="function"&&X?.function?.name,{maxChatCompletions:W=Zx}=Q||{},q=Y.tools.map((B)=>{if(f4(B)){if(!B.$callback)throw new n("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 U="tools"in Y?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 Y.messages)this._addMessage(B,!1);for(let B=0;B<W;++B){let $=(await this._createChatCompletion(Z,{...z,tool_choice:X,tools:U,messages:[...this.messages]},Q)).choices[0]?.message;if(!$)throw new n("missing message in ChatCompletion response");if(!$.tool_calls?.length)return;for(let O of $.tool_calls){if(O.type!=="function")continue;let D=O.id,{name:j,arguments:M}=O.function,T=G[j];if(!T){let S=`Invalid tool_call: ${JSON.stringify(j)}. Available options are: ${Object.keys(G).map((g)=>JSON.stringify(g)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:D,content:S});continue}else if(H&&H!==j){let S=`Invalid tool_call: ${JSON.stringify(j)}. ${JSON.stringify(H)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:D,content:S});continue}let N;try{N=SO(T)?await T.parse(M):M}catch(S){let g=S instanceof Error?S.message:String(S);this._addMessage({role:"tool",tool_call_id:D,content:g});continue}let L=await T.function(N,this),x=A(this,U6,"m",PO).call(this,L);if(this._addMessage({role:"tool",tool_call_id:D,content:x}),H)return}}return}};U6=new WeakSet,AX=function Z(){return A(this,U6,"m",KQ).call(this).content??null},KQ=function Z(){let Y=this.messages.length;while(Y-- >0){let Q=this.messages[Y];if(p8(Q))return{...Q,content:Q.content??null,refusal:Q.refusal??null}}throw new n("stream ended without producing a ChatCompletionMessage with role=assistant")},CX=function Z(){for(let Y=this.messages.length-1;Y>=0;Y--){let Q=this.messages[Y];if(p8(Q)&&Q?.tool_calls?.length)return Q.tool_calls.filter((J)=>J.type==="function").at(-1)?.function}return},EX=function Z(){for(let Y=this.messages.length-1;Y>=0;Y--){let Q=this.messages[Y];if(LX(Q)&&Q.content!=null&&typeof Q.content==="string"&&this.messages.some((J)=>J.role==="assistant"&&J.tool_calls?.some((X)=>X.type==="function"&&X.id===Q.tool_call_id)))return Q.content}return},xX=function Z(){let Y={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:Q}of this._chatCompletions)if(Q)Y.completion_tokens+=Q.completion_tokens,Y.prompt_tokens+=Q.prompt_tokens,Y.total_tokens+=Q.total_tokens;return Y},kO=function Z(Y){if(Y.n!=null&&Y.n>1)throw new n("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},PO=function Z(Y){return typeof Y==="string"?Y:Y===void 0?"undefined":JSON.stringify(Y)}});var x7;var kX=_(()=>{SX();x7=class x7 extends E7{static runTools(Z,Y,Q){let J=new x7,X={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Z,Y,X)),J}_addMessage(Z,Y=!0){if(super._addMessage(Z,Y),p8(Z)&&Z.content)this._emit("content",Z.content)}}});function Yx(Z,Y=i0.ALL){if(typeof Z!=="string")throw TypeError(`expecting str, got ${typeof Z}`);if(!Z.trim())throw Error(`${Z} is empty`);return Qx(Z.trim(),Y)}var i0,vO,yO,Qx=(Z,Y)=>{let Q=Z.length,J=0,X=(B)=>{throw new vO(`${B} at position ${J}`)},K=(B)=>{throw new yO(`${B} at position ${J}`)},z=()=>{if(U(),J>=Q)X("Unexpected end of input");if(Z[J]==='"')return H();if(Z[J]==="{")return W();if(Z[J]==="[")return q();if(Z.substring(J,J+4)==="null"||i0.NULL&Y&&Q-J<4&&"null".startsWith(Z.substring(J)))return J+=4,null;if(Z.substring(J,J+4)==="true"||i0.BOOL&Y&&Q-J<4&&"true".startsWith(Z.substring(J)))return J+=4,!0;if(Z.substring(J,J+5)==="false"||i0.BOOL&Y&&Q-J<5&&"false".startsWith(Z.substring(J)))return J+=5,!1;if(Z.substring(J,J+8)==="Infinity"||i0.INFINITY&Y&&Q-J<8&&"Infinity".startsWith(Z.substring(J)))return J+=8,1/0;if(Z.substring(J,J+9)==="-Infinity"||i0.MINUS_INFINITY&Y&&1<Q-J&&Q-J<9&&"-Infinity".startsWith(Z.substring(J)))return J+=9,-1/0;if(Z.substring(J,J+3)==="NaN"||i0.NAN&Y&&Q-J<3&&"NaN".startsWith(Z.substring(J)))return J+=3,NaN;return G()},H=()=>{let B=J,F=!1;J++;while(J<Q&&(Z[J]!=='"'||F&&Z[J-1]==="\\"))F=Z[J]==="\\"?!F:!1,J++;if(Z.charAt(J)=='"')try{return JSON.parse(Z.substring(B,++J-Number(F)))}catch($){K(String($))}else if(i0.STR&Y)try{return JSON.parse(Z.substring(B,J-Number(F))+'"')}catch($){return JSON.parse(Z.substring(B,Z.lastIndexOf("\\"))+'"')}X("Unterminated string literal")},W=()=>{J++,U();let B={};try{while(Z[J]!=="}"){if(U(),J>=Q&&i0.OBJ&Y)return B;let F=H();U(),J++;try{let $=z();Object.defineProperty(B,F,{value:$,writable:!0,enumerable:!0,configurable:!0})}catch($){if(i0.OBJ&Y)return B;else throw $}if(U(),Z[J]===",")J++}}catch(F){if(i0.OBJ&Y)return B;else X("Expected '}' at end of object")}return J++,B},q=()=>{J++;let B=[];try{while(Z[J]!=="]")if(B.push(z()),U(),Z[J]===",")J++}catch(F){if(i0.ARR&Y)return B;X("Expected ']' at end of array")}return J++,B},G=()=>{if(J===0){if(Z==="-"&&i0.NUM&Y)X("Not sure what '-' is");try{return JSON.parse(Z)}catch(F){if(i0.NUM&Y)try{if(Z[Z.length-1]===".")return JSON.parse(Z.substring(0,Z.lastIndexOf(".")));return JSON.parse(Z.substring(0,Z.lastIndexOf("e")))}catch($){}K(String(F))}}let B=J;if(Z[J]==="-")J++;while(Z[J]&&!",]}".includes(Z[J]))J++;if(J==Q&&!(i0.NUM&Y))X("Unterminated number literal");try{return JSON.parse(Z.substring(B,J))}catch(F){if(Z.substring(B,J)==="-"&&i0.NUM&Y)X("Not sure what '-' is");try{return JSON.parse(Z.substring(B,Z.lastIndexOf("e")))}catch($){K(String($))}}},U=()=>{while(J<Q&&`
|
|
484
|
+
\r `.includes(Z[J]))J++};return z()},PX=(Z)=>Yx(Z,i0.ALL^i0.NUM);var bO=_(()=>{i0={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};vO=class vO extends Error{};yO=class yO extends Error{}});var vX=_(()=>{OX()});function Jx(Z,Y){let{id:Q,choices:J,created:X,model:K,system_fingerprint:z,...H}=Z,W={...H,id:Q,choices:J.map(({message:q,finish_reason:G,index:U,logprobs:B,...F})=>{if(!G)throw new n(`missing finish_reason for choice ${U}`);let{content:$=null,function_call:O,tool_calls:D,...j}=q,M=q.role;if(!M)throw new n(`missing role for choice ${U}`);if(O){let{arguments:T,name:N}=O;if(T==null)throw new n(`missing function_call.arguments for choice ${U}`);if(!N)throw new n(`missing function_call.name for choice ${U}`);return{...F,message:{content:$,function_call:{arguments:T,name:N},role:M,refusal:q.refusal??null},finish_reason:G,index:U,logprobs:B}}if(D)return{...F,index:U,finish_reason:G,logprobs:B,message:{...j,role:M,content:$,refusal:q.refusal??null,tool_calls:D.map((T,N)=>{let{function:L,type:x,id:S,...g}=T,{arguments:h,name:f,...v}=L||{};if(S==null)throw new n(`missing choices[${U}].tool_calls[${N}].id
|
|
485
|
+
${WQ(Z)}`);if(x==null)throw new n(`missing choices[${U}].tool_calls[${N}].type
|
|
486
|
+
${WQ(Z)}`);if(f==null)throw new n(`missing choices[${U}].tool_calls[${N}].function.name
|
|
487
|
+
${WQ(Z)}`);if(h==null)throw new n(`missing choices[${U}].tool_calls[${N}].function.arguments
|
|
488
|
+
${WQ(Z)}`);return{...g,id:S,type:x,function:{...v,name:f,arguments:h}}})}};return{...F,message:{...j,content:$,role:M,refusal:q.refusal??null},finish_reason:G,index:U,logprobs:B}}),created:X,model:K,object:"chat.completion",...z?{system_fingerprint:z}:{}};return IO(W,Y)}function WQ(Z){return JSON.stringify(Z)}function hO(Z){return}function gO(Z){}var g0,y1,c8,Y4,yX,zQ,bX,fX,hX,HQ,gX,fO,Q4;var qQ=_(()=>{y6();bO();c6();T7();vX();SX();Q4=class Q4 extends E7{constructor(Z){super();g0.add(this),y1.set(this,void 0),c8.set(this,void 0),Y4.set(this,void 0),r(this,y1,Z,"f"),r(this,c8,[],"f")}get currentChatCompletionSnapshot(){return A(this,Y4,"f")}static fromReadableStream(Z){let Y=new Q4(null);return Y._run(()=>Y._fromReadableStream(Z)),Y}static createChatCompletion(Z,Y,Q){let J=new Q4(Y);return J._run(()=>J._runChatCompletion(Z,{...Y,stream:!0},{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createChatCompletion(Z,Y,Q){super._createChatCompletion;let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}A(this,g0,"m",yX).call(this);let X=await Z.chat.completions.create({...Y,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let K of X)A(this,g0,"m",bX).call(this,K);if(X.controller.signal?.aborted)throw new f0;return this._addChatCompletion(A(this,g0,"m",HQ).call(this))}async _fromReadableStream(Z,Y){let Q=Y?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}A(this,g0,"m",yX).call(this),this._connected();let J=L6.fromReadableStream(Z,this.controller),X;for await(let K of J){if(X&&X!==K.id)this._addChatCompletion(A(this,g0,"m",HQ).call(this));A(this,g0,"m",bX).call(this,K),X=K.id}if(J.controller.signal?.aborted)throw new f0;return this._addChatCompletion(A(this,g0,"m",HQ).call(this))}[(y1=new WeakMap,c8=new WeakMap,Y4=new WeakMap,g0=new WeakSet,yX=function Z(){if(this.ended)return;r(this,Y4,void 0,"f")},zQ=function Z(Y){let Q=A(this,c8,"f")[Y.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},A(this,c8,"f")[Y.index]=Q,Q},bX=function Z(Y){if(this.ended)return;let Q=A(this,g0,"m",fO).call(this,Y);this._emit("chunk",Y,Q);for(let J of Y.choices){let X=Q.choices[J.index];if(J.delta.content!=null&&X.message?.role==="assistant"&&X.message?.content)this._emit("content",J.delta.content,X.message.content),this._emit("content.delta",{delta:J.delta.content,snapshot:X.message.content,parsed:X.message.parsed});if(J.delta.refusal!=null&&X.message?.role==="assistant"&&X.message?.refusal)this._emit("refusal.delta",{delta:J.delta.refusal,snapshot:X.message.refusal});if(J.logprobs?.content!=null&&X.message?.role==="assistant")this._emit("logprobs.content.delta",{content:J.logprobs?.content,snapshot:X.logprobs?.content??[]});if(J.logprobs?.refusal!=null&&X.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:J.logprobs?.refusal,snapshot:X.logprobs?.refusal??[]});let K=A(this,g0,"m",zQ).call(this,X);if(X.finish_reason){if(A(this,g0,"m",hX).call(this,X),K.current_tool_call_index!=null)A(this,g0,"m",fX).call(this,X,K.current_tool_call_index)}for(let z of J.delta.tool_calls??[]){if(K.current_tool_call_index!==z.index){if(A(this,g0,"m",hX).call(this,X),K.current_tool_call_index!=null)A(this,g0,"m",fX).call(this,X,K.current_tool_call_index)}K.current_tool_call_index=z.index}for(let z of J.delta.tool_calls??[]){let H=X.message.tool_calls?.[z.index];if(!H?.type)continue;if(H?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:H.function?.name,index:z.index,arguments:H.function.arguments,parsed_arguments:H.function.parsed_arguments,arguments_delta:z.function?.arguments??""});else gO(H?.type)}}},fX=function Z(Y,Q){if(A(this,g0,"m",zQ).call(this,Y).done_tool_calls.has(Q))return;let X=Y.message.tool_calls?.[Q];if(!X)throw Error("no tool call snapshot");if(!X.type)throw Error("tool call snapshot missing `type`");if(X.type==="function"){let K=A(this,y1,"f")?.tools?.find((z)=>N7(z)&&z.function.name===X.function.name);this._emit("tool_calls.function.arguments.done",{name:X.function.name,index:Q,arguments:X.function.arguments,parsed_arguments:f4(K)?K.$parseRaw(X.function.arguments):K?.function.strict?JSON.parse(X.function.arguments):null})}else gO(X.type)},hX=function Z(Y){let Q=A(this,g0,"m",zQ).call(this,Y);if(Y.message.content&&!Q.content_done){Q.content_done=!0;let J=A(this,g0,"m",gX).call(this);this._emit("content.done",{content:Y.message.content,parsed:J?J.$parseRaw(Y.message.content):null})}if(Y.message.refusal&&!Q.refusal_done)Q.refusal_done=!0,this._emit("refusal.done",{refusal:Y.message.refusal});if(Y.logprobs?.content&&!Q.logprobs_content_done)Q.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:Y.logprobs.content});if(Y.logprobs?.refusal&&!Q.logprobs_refusal_done)Q.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:Y.logprobs.refusal})},HQ=function Z(){if(this.ended)throw new n("stream has ended, this shouldn't happen");let Y=A(this,Y4,"f");if(!Y)throw new n("request ended without sending any chunks");return r(this,Y4,void 0,"f"),r(this,c8,[],"f"),Jx(Y,A(this,y1,"f"))},gX=function Z(){let Y=A(this,y1,"f")?.response_format;if(j7(Y))return Y;return null},fO=function Z(Y){var Q,J,X,K;let z=A(this,Y4,"f"),{choices:H,...W}=Y;if(!z)z=r(this,Y4,{...W,choices:[]},"f");else Object.assign(z,W);for(let{delta:q,finish_reason:G,index:U,logprobs:B=null,...F}of Y.choices){let $=z.choices[U];if(!$)$=z.choices[U]={finish_reason:G,index:U,message:{},logprobs:B,...F};if(B)if(!$.logprobs)$.logprobs=Object.assign({},B);else{let{content:L,refusal:x,...S}=B;if(hO(S),Object.assign($.logprobs,S),L)(Q=$.logprobs).content??(Q.content=[]),$.logprobs.content.push(...L);if(x)(J=$.logprobs).refusal??(J.refusal=[]),$.logprobs.refusal.push(...x)}if(G){if($.finish_reason=G,A(this,y1,"f")&&TX(A(this,y1,"f"))){if(G==="length")throw new B7;if(G==="content_filter")throw new $7}}if(Object.assign($,F),!q)continue;let{content:O,refusal:D,function_call:j,role:M,tool_calls:T,...N}=q;if(hO(N),Object.assign($.message,N),D)$.message.refusal=($.message.refusal||"")+D;if(M)$.message.role=M;if(j)if(!$.message.function_call)$.message.function_call=j;else{if(j.name)$.message.function_call.name=j.name;if(j.arguments)(X=$.message.function_call).arguments??(X.arguments=""),$.message.function_call.arguments+=j.arguments}if(O){if($.message.content=($.message.content||"")+O,!$.message.refusal&&A(this,g0,"m",gX).call(this))$.message.parsed=PX($.message.content)}if(T){if(!$.message.tool_calls)$.message.tool_calls=[];for(let{index:L,id:x,type:S,function:g,...h}of T){let f=(K=$.message.tool_calls)[L]??(K[L]={});if(Object.assign(f,h),x)f.id=x;if(S)f.type=S;if(g)f.function??(f.function={name:g.name??"",arguments:""});if(g?.name)f.function.name=g.name;if(g?.arguments){if(f.function.arguments+=g.arguments,AO(A(this,y1,"f"),f))f.function.parsed_arguments=PX(f.function.arguments)}}}}return z},Symbol.asyncIterator)](){let Z=[],Y=[],Q=!1;return this.on("chunk",(J)=>{let X=Y.shift();if(X)X.resolve(J);else Z.push(J)}),this.on("end",()=>{Q=!0;for(let J of Y)J.resolve(void 0);Y.length=0}),this.on("abort",(J)=>{Q=!0;for(let X of Y)X.reject(J);Y.length=0}),this.on("error",(J)=>{Q=!0;for(let X of Y)X.reject(J);Y.length=0}),{next:async()=>{if(!Z.length){if(Q)return{value:void 0,done:!0};return new Promise((X,K)=>Y.push({resolve:X,reject:K})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:Z.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new L6(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var l8;var mX=_(()=>{qQ();l8=class l8 extends Q4{static fromReadableStream(Z){let Y=new l8(null);return Y._run(()=>Y._fromReadableStream(Z)),Y}static runTools(Z,Y,Q){let J=new l8(Y),X={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Z,Y,X)),J}}});var J4;var S7=_(()=>{t2();t2();M0();U0();kX();mX();qQ();T7();mX();qQ();kX();J4=class J4 extends b{constructor(){super(...arguments);this.messages=new u8(this._client)}create(Z,Y){return this._client.post("/chat/completions",{body:Z,...Y,stream:Z.stream??!1})}retrieve(Z,Y){return this._client.get(P`/chat/completions/${Z}`,Y)}update(Z,Y,Q){return this._client.post(P`/chat/completions/${Z}`,{body:Y,...Q})}list(Z={},Y){return this._client.getAPIList("/chat/completions",K0,{query:Z,...Y})}delete(Z,Y){return this._client.delete(P`/chat/completions/${Z}`,Y)}parse(Z,Y){return EO(Z.tools),this._client.chat.completions.create(Z,{...Y,headers:{...Y?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap((Q)=>w7(Q,Z))}runTools(Z,Y){if(Z.stream)return l8.runTools(this._client,Z,Y);return x7.runTools(this._client,Z,Y)}stream(Z,Y){return Q4.createChatCompletion(this._client,Z,Y)}};J4.Messages=u8});var g4;var uX=_(()=>{S7();S7();g4=class g4 extends b{constructor(){super(...arguments);this.completions=new J4(this._client)}};g4.Completions=J4});var mO=_(()=>{S7();t2();S7()});var uO=_(()=>{uX();mO()});var pO=()=>{};function*Kx(Z){if(!Z)return;if(dO in Z){let{values:J,nulls:X}=Z;yield*J.entries();for(let K of X)yield[K,null];return}let Y=!1,Q;if(Z instanceof Headers)Q=Z.entries();else if(ZX(Z))Q=Z;else Y=!0,Q=Object.entries(Z??{});for(let J of Q){let X=J[0];if(typeof X!=="string")throw TypeError("expected header name to be a string");let K=ZX(J[1])?J[1]:[J[1]],z=!1;for(let H of K){if(H===void 0)continue;if(Y&&!z)z=!0,yield[X,null];yield[X,H]}}}var dO,m=(Z)=>{let Y=new Headers,Q=new Set;for(let J of Z){let X=new Set;for(let[K,z]of Kx(J)){let H=K.toLowerCase();if(!X.has(H))Y.delete(K),X.add(H);if(z===null)Y.delete(K),Q.add(H);else Y.append(K,z),Q.delete(H)}}return{[dO]:!0,values:Y,nulls:Q}};var j0=_(()=>{S1();dO=Symbol("brand.privateNullableHeaders")});var k7;var pX=_(()=>{j0();k7=class k7 extends b{create(Z,Y){return this._client.post("/audio/speech",{body:Z,...Y,headers:m([{Accept:"application/octet-stream"},Y?.headers]),__binaryResponse:!0})}}});var P7;var dX=_(()=>{b6();P7=class P7 extends b{create(Z,Y){return this._client.post("/audio/transcriptions",X6({body:Z,...Y,stream:Z.stream??!1,__metadata:{model:Z.model}},this._client))}}});var v7;var cX=_(()=>{b6();v7=class v7 extends b{create(Z,Y){return this._client.post("/audio/translations",X6({body:Z,...Y,__metadata:{model:Z.model}},this._client))}}});var b1;var lX=_(()=>{pX();pX();dX();dX();cX();cX();b1=class b1 extends b{constructor(){super(...arguments);this.transcriptions=new P7(this._client),this.translations=new v7(this._client),this.speech=new k7(this._client)}};b1.Transcriptions=P7;b1.Translations=v7;b1.Speech=k7});var i8;var iX=_(()=>{M0();U0();i8=class i8 extends b{create(Z,Y){return this._client.post("/batches",{body:Z,...Y})}retrieve(Z,Y){return this._client.get(P`/batches/${Z}`,Y)}list(Z={},Y){return this._client.getAPIList("/batches",K0,{query:Z,...Y})}cancel(Z,Y){return this._client.post(P`/batches/${Z}/cancel`,Y)}}});var y7;var nX=_(()=>{M0();j0();U0();y7=class y7 extends b{create(Z,Y){return this._client.post("/assistants",{body:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}retrieve(Z,Y){return this._client.get(P`/assistants/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}update(Z,Y,Q){return this._client.post(P`/assistants/${Z}`,{body:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Z={},Y){return this._client.getAPIList("/assistants",K0,{query:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}delete(Z,Y){return this._client.delete(P`/assistants/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}}});var b7;var oX=_(()=>{j0();b7=class b7 extends b{create(Z,Y){return this._client.post("/realtime/sessions",{body:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}}});var f7;var aX=_(()=>{j0();f7=class f7 extends b{create(Z,Y){return this._client.post("/realtime/transcription_sessions",{body:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}}});var m4;var sX=_(()=>{oX();oX();aX();aX();m4=class m4 extends b{constructor(){super(...arguments);this.sessions=new b7(this._client),this.transcriptionSessions=new f7(this._client)}};m4.Sessions=b7;m4.TranscriptionSessions=f7});var h7;var rX=_(()=>{j0();U0();h7=class h7 extends b{create(Z,Y){return this._client.post("/chatkit/sessions",{body:Z,...Y,headers:m([{"OpenAI-Beta":"chatkit_beta=v1"},Y?.headers])})}cancel(Z,Y){return this._client.post(P`/chatkit/sessions/${Z}/cancel`,{...Y,headers:m([{"OpenAI-Beta":"chatkit_beta=v1"},Y?.headers])})}}});var g7;var tX=_(()=>{M0();j0();U0();g7=class g7 extends b{retrieve(Z,Y){return this._client.get(P`/chatkit/threads/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"chatkit_beta=v1"},Y?.headers])})}list(Z={},Y){return this._client.getAPIList("/chatkit/threads",H1,{query:Z,...Y,headers:m([{"OpenAI-Beta":"chatkit_beta=v1"},Y?.headers])})}delete(Z,Y){return this._client.delete(P`/chatkit/threads/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"chatkit_beta=v1"},Y?.headers])})}listItems(Z,Y={},Q){return this._client.getAPIList(P`/chatkit/threads/${Z}/items`,H1,{query:Y,...Q,headers:m([{"OpenAI-Beta":"chatkit_beta=v1"},Q?.headers])})}}});var u4;var eX=_(()=>{rX();rX();tX();tX();u4=class u4 extends b{constructor(){super(...arguments);this.sessions=new h7(this._client),this.threads=new g7(this._client)}};u4.Sessions=h7;u4.Threads=g7});var m7;var ZK=_(()=>{M0();j0();U0();m7=class m7 extends b{create(Z,Y,Q){return this._client.post(P`/threads/${Z}/messages`,{body:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Z,Y,Q){let{thread_id:J}=Y;return this._client.get(P`/threads/${J}/messages/${Z}`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Z,Y,Q){let{thread_id:J,...X}=Y;return this._client.post(P`/threads/${J}/messages/${Z}`,{body:X,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Z,Y={},Q){return this._client.getAPIList(P`/threads/${Z}/messages`,K0,{query:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Z,Y,Q){let{thread_id:J}=Y;return this._client.delete(P`/threads/${J}/messages/${Z}`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var u7;var YK=_(()=>{M0();j0();U0();u7=class u7 extends b{retrieve(Z,Y,Q){let{thread_id:J,run_id:X,...K}=Y;return this._client.get(P`/threads/${J}/runs/${X}/steps/${Z}`,{query:K,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Z,Y,Q){let{thread_id:J,...X}=Y;return this._client.getAPIList(P`/threads/${J}/runs/${Z}/steps`,K0,{query:X,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var cO=(Z)=>{if(typeof Buffer<"u"){let Y=Buffer.from(Z,"base64");return Array.from(new Float32Array(Y.buffer,Y.byteOffset,Y.length/Float32Array.BYTES_PER_ELEMENT))}else{let Y=atob(Z),Q=Y.length,J=new Uint8Array(Q);for(let X=0;X<Q;X++)J[X]=Y.charCodeAt(X);return Array.from(new Float32Array(J.buffer))}};var lO=_(()=>{X1()});var X4=(Z)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[Z]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(Z)?.trim();return};var p7=_(()=>{S1();lO();R7();BX()});function Mx(Z){}var Z6,d4,QK,W1,GQ,l6,c4,n8,p4,BQ,I6,UQ,VQ,l7,d7,c7,iO,nO,oO,aO,sO,rO,tO,K4;var JK=_(()=>{y6();vX();c6();XQ();p7();K4=class K4 extends h4{constructor(){super(...arguments);Z6.add(this),QK.set(this,[]),W1.set(this,{}),GQ.set(this,{}),l6.set(this,void 0),c4.set(this,void 0),n8.set(this,void 0),p4.set(this,void 0),BQ.set(this,void 0),I6.set(this,void 0),UQ.set(this,void 0),VQ.set(this,void 0),l7.set(this,void 0)}[(QK=new WeakMap,W1=new WeakMap,GQ=new WeakMap,l6=new WeakMap,c4=new WeakMap,n8=new WeakMap,p4=new WeakMap,BQ=new WeakMap,I6=new WeakMap,UQ=new WeakMap,VQ=new WeakMap,l7=new WeakMap,Z6=new WeakSet,Symbol.asyncIterator)](){let Z=[],Y=[],Q=!1;return this.on("event",(J)=>{let X=Y.shift();if(X)X.resolve(J);else Z.push(J)}),this.on("end",()=>{Q=!0;for(let J of Y)J.resolve(void 0);Y.length=0}),this.on("abort",(J)=>{Q=!0;for(let X of Y)X.reject(J);Y.length=0}),this.on("error",(J)=>{Q=!0;for(let X of Y)X.reject(J);Y.length=0}),{next:async()=>{if(!Z.length){if(Q)return{value:void 0,done:!0};return new Promise((X,K)=>Y.push({resolve:X,reject:K})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:Z.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream(Z){let Y=new d4;return Y._run(()=>Y._fromReadableStream(Z)),Y}async _fromReadableStream(Z,Y){let Q=Y?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}this._connected();let J=L6.fromReadableStream(Z,this.controller);for await(let X of J)A(this,Z6,"m",d7).call(this,X);if(J.controller.signal?.aborted)throw new f0;return this._addRun(A(this,Z6,"m",c7).call(this))}toReadableStream(){return new L6(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(Z,Y,Q,J){let X=new d4;return X._run(()=>X._runToolAssistantStream(Z,Y,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),X}async _createToolAssistantStream(Z,Y,Q,J){let X=J?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let K={...Q,stream:!0},z=await Z.submitToolOutputs(Y,K,{...J,signal:this.controller.signal});this._connected();for await(let H of z)A(this,Z6,"m",d7).call(this,H);if(z.controller.signal?.aborted)throw new f0;return this._addRun(A(this,Z6,"m",c7).call(this))}static createThreadAssistantStream(Z,Y,Q){let J=new d4;return J._run(()=>J._threadAssistantStream(Z,Y,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}static createAssistantStream(Z,Y,Q,J){let X=new d4;return X._run(()=>X._runAssistantStream(Z,Y,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),X}currentEvent(){return A(this,UQ,"f")}currentRun(){return A(this,VQ,"f")}currentMessageSnapshot(){return A(this,l6,"f")}currentRunStepSnapshot(){return A(this,l7,"f")}async finalRunSteps(){return await this.done(),Object.values(A(this,W1,"f"))}async finalMessages(){return await this.done(),Object.values(A(this,GQ,"f"))}async finalRun(){if(await this.done(),!A(this,c4,"f"))throw Error("Final run was not received.");return A(this,c4,"f")}async _createThreadAssistantStream(Z,Y,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}let X={...Y,stream:!0},K=await Z.createAndRun(X,{...Q,signal:this.controller.signal});this._connected();for await(let z of K)A(this,Z6,"m",d7).call(this,z);if(K.controller.signal?.aborted)throw new f0;return this._addRun(A(this,Z6,"m",c7).call(this))}async _createAssistantStream(Z,Y,Q,J){let X=J?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let K={...Q,stream:!0},z=await Z.create(Y,K,{...J,signal:this.controller.signal});this._connected();for await(let H of z)A(this,Z6,"m",d7).call(this,H);if(z.controller.signal?.aborted)throw new f0;return this._addRun(A(this,Z6,"m",c7).call(this))}static accumulateDelta(Z,Y){for(let[Q,J]of Object.entries(Y)){if(!Z.hasOwnProperty(Q)){Z[Q]=J;continue}let X=Z[Q];if(X===null||X===void 0){Z[Q]=J;continue}if(Q==="index"||Q==="type"){Z[Q]=J;continue}if(typeof X==="string"&&typeof J==="string")X+=J;else if(typeof X==="number"&&typeof J==="number")X+=J;else if(F7(X)&&F7(J))X=this.accumulateDelta(X,J);else if(Array.isArray(X)&&Array.isArray(J)){if(X.every((K)=>typeof K==="string"||typeof K==="number")){X.push(...J);continue}for(let K of J){if(!F7(K))throw Error(`Expected array delta entry to be an object but got: ${K}`);let z=K.index;if(z==null)throw console.error(K),Error("Expected array delta entry to have an `index` property");if(typeof z!=="number")throw Error(`Expected array delta entry \`index\` property to be a number but got ${z}`);let H=X[z];if(H==null)X.push(K);else X[z]=this.accumulateDelta(H,K)}continue}else throw Error(`Unhandled record type: ${Q}, deltaValue: ${J}, accValue: ${X}`);Z[Q]=X}return Z}_addRun(Z){return Z}async _threadAssistantStream(Z,Y,Q){return await this._createThreadAssistantStream(Y,Z,Q)}async _runAssistantStream(Z,Y,Q,J){return await this._createAssistantStream(Y,Z,Q,J)}async _runToolAssistantStream(Z,Y,Q,J){return await this._createToolAssistantStream(Y,Z,Q,J)}};d4=K4,d7=function Z(Y){if(this.ended)return;switch(r(this,UQ,Y,"f"),A(this,Z6,"m",oO).call(this,Y),Y.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":A(this,Z6,"m",tO).call(this,Y);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":A(this,Z6,"m",nO).call(this,Y);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":A(this,Z6,"m",iO).call(this,Y);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier");default:Mx(Y)}},c7=function Z(){if(this.ended)throw new n("stream has ended, this shouldn't happen");if(!A(this,c4,"f"))throw Error("Final run has not been received");return A(this,c4,"f")},iO=function Z(Y){let[Q,J]=A(this,Z6,"m",sO).call(this,Y,A(this,l6,"f"));r(this,l6,Q,"f"),A(this,GQ,"f")[Q.id]=Q;for(let X of J){let K=Q.content[X.index];if(K?.type=="text")this._emit("textCreated",K.text)}switch(Y.event){case"thread.message.created":this._emit("messageCreated",Y.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",Y.data.delta,Q),Y.data.delta.content)for(let X of Y.data.delta.content){if(X.type=="text"&&X.text){let K=X.text,z=Q.content[X.index];if(z&&z.type=="text")this._emit("textDelta",K,z.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(X.index!=A(this,n8,"f")){if(A(this,p4,"f"))switch(A(this,p4,"f").type){case"text":this._emit("textDone",A(this,p4,"f").text,A(this,l6,"f"));break;case"image_file":this._emit("imageFileDone",A(this,p4,"f").image_file,A(this,l6,"f"));break}r(this,n8,X.index,"f")}r(this,p4,Q.content[X.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(A(this,n8,"f")!==void 0){let X=Y.data.content[A(this,n8,"f")];if(X)switch(X.type){case"image_file":this._emit("imageFileDone",X.image_file,A(this,l6,"f"));break;case"text":this._emit("textDone",X.text,A(this,l6,"f"));break}}if(A(this,l6,"f"))this._emit("messageDone",Y.data);r(this,l6,void 0,"f")}},nO=function Z(Y){let Q=A(this,Z6,"m",aO).call(this,Y);switch(r(this,l7,Q,"f"),Y.event){case"thread.run.step.created":this._emit("runStepCreated",Y.data);break;case"thread.run.step.delta":let J=Y.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==A(this,BQ,"f"))this._emit("toolCallDelta",K,Q.step_details.tool_calls[K.index]);else{if(A(this,I6,"f"))this._emit("toolCallDone",A(this,I6,"f"));if(r(this,BQ,K.index,"f"),r(this,I6,Q.step_details.tool_calls[K.index],"f"),A(this,I6,"f"))this._emit("toolCallCreated",A(this,I6,"f"))}this._emit("runStepDelta",Y.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(r(this,l7,void 0,"f"),Y.data.step_details.type=="tool_calls"){if(A(this,I6,"f"))this._emit("toolCallDone",A(this,I6,"f")),r(this,I6,void 0,"f")}this._emit("runStepDone",Y.data,Q);break;case"thread.run.step.in_progress":break}},oO=function Z(Y){A(this,QK,"f").push(Y),this._emit("event",Y)},aO=function Z(Y){switch(Y.event){case"thread.run.step.created":return A(this,W1,"f")[Y.data.id]=Y.data,Y.data;case"thread.run.step.delta":let Q=A(this,W1,"f")[Y.data.id];if(!Q)throw Error("Received a RunStepDelta before creation of a snapshot");let J=Y.data;if(J.delta){let X=d4.accumulateDelta(Q,J.delta);A(this,W1,"f")[Y.data.id]=X}return A(this,W1,"f")[Y.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":A(this,W1,"f")[Y.data.id]=Y.data;break}if(A(this,W1,"f")[Y.data.id])return A(this,W1,"f")[Y.data.id];throw Error("No snapshot available")},sO=function Z(Y,Q){let J=[];switch(Y.event){case"thread.message.created":return[Y.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 X=Y.data;if(X.delta.content)for(let K of X.delta.content)if(K.index in Q.content){let z=Q.content[K.index];Q.content[K.index]=A(this,Z6,"m",rO).call(this,K,z)}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")},rO=function Z(Y,Q){return d4.accumulateDelta(Q,Y)},tO=function Z(Y){switch(r(this,VQ,Y.data,"f"),Y.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(r(this,c4,Y.data,"f"),A(this,I6,"f"))this._emit("toolCallDone",A(this,I6,"f")),r(this,I6,void 0,"f");break;case"thread.run.cancelling":break}}});var o8;var XK=_(()=>{YK();YK();M0();j0();JK();U0();o8=class o8 extends b{constructor(){super(...arguments);this.steps=new u7(this._client)}create(Z,Y,Q){let{include:J,...X}=Y;return this._client.post(P`/threads/${Z}/runs`,{query:{include:J},body:X,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Y.stream??!1,__synthesizeEventData:!0})}retrieve(Z,Y,Q){let{thread_id:J}=Y;return this._client.get(P`/threads/${J}/runs/${Z}`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Z,Y,Q){let{thread_id:J,...X}=Y;return this._client.post(P`/threads/${J}/runs/${Z}`,{body:X,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Z,Y={},Q){return this._client.getAPIList(P`/threads/${Z}/runs`,K0,{query:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Z,Y,Q){let{thread_id:J}=Y;return this._client.post(P`/threads/${J}/runs/${Z}/cancel`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Z,Y,Q){let J=await this.create(Z,Y,Q);return await this.poll(J.id,{thread_id:Z},Q)}createAndStream(Z,Y,Q){return K4.createAssistantStream(Z,this._client.beta.threads.runs,Y,Q)}async poll(Z,Y,Q){let J=m([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:X,response:K}=await this.retrieve(Z,Y,{...Q,headers:{...Q?.headers,...J}}).withResponse();switch(X.status){case"queued":case"in_progress":case"cancelling":let z=5000;if(Q?.pollIntervalMs)z=Q.pollIntervalMs;else{let H=K.headers.get("openai-poll-after-ms");if(H){let W=parseInt(H);if(!isNaN(W))z=W}}await K1(z);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return X}}}stream(Z,Y,Q){return K4.createAssistantStream(Z,this._client.beta.threads.runs,Y,Q)}submitToolOutputs(Z,Y,Q){let{thread_id:J,...X}=Y;return this._client.post(P`/threads/${J}/runs/${Z}/submit_tool_outputs`,{body:X,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Y.stream??!1,__synthesizeEventData:!0})}async submitToolOutputsAndPoll(Z,Y,Q){let J=await this.submitToolOutputs(Z,Y,Q);return await this.poll(J.id,Y,Q)}submitToolOutputsStream(Z,Y,Q){return K4.createToolAssistantStream(Z,this._client.beta.threads.runs,Y,Q)}};o8.Steps=u7});var l4;var KK=_(()=>{ZK();ZK();XK();XK();j0();JK();U0();l4=class l4 extends b{constructor(){super(...arguments);this.runs=new o8(this._client),this.messages=new m7(this._client)}create(Z={},Y){return this._client.post("/threads",{body:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}retrieve(Z,Y){return this._client.get(P`/threads/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}update(Z,Y,Q){return this._client.post(P`/threads/${Z}`,{body:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Z,Y){return this._client.delete(P`/threads/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}createAndRun(Z,Y){return this._client.post("/threads/runs",{body:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers]),stream:Z.stream??!1,__synthesizeEventData:!0})}async createAndRunPoll(Z,Y){let Q=await this.createAndRun(Z,Y);return await this.runs.poll(Q.id,{thread_id:Q.thread_id},Y)}createAndRunStream(Z,Y){return K4.createThreadAssistantStream(Z,this._client.beta.threads,Y)}};l4.Runs=o8;l4.Messages=m7});var q1;var zK=_(()=>{nX();nX();sX();sX();eX();eX();KK();KK();q1=class q1 extends b{constructor(){super(...arguments);this.realtime=new m4(this._client),this.chatkit=new u4(this._client),this.assistants=new y7(this._client),this.threads=new l4(this._client)}};q1.Realtime=m4;q1.ChatKit=u4;q1.Assistants=y7;q1.Threads=l4});var a8;var HK=_(()=>{a8=class a8 extends b{create(Z,Y){return this._client.post("/completions",{body:Z,...Y,stream:Z.stream??!1})}}});var i7;var WK=_(()=>{j0();U0();i7=class i7 extends b{retrieve(Z,Y,Q){let{container_id:J}=Y;return this._client.get(P`/containers/${J}/files/${Z}/content`,{...Q,headers:m([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}}});var s8;var qK=_(()=>{WK();WK();M0();j0();b6();U0();s8=class s8 extends b{constructor(){super(...arguments);this.content=new i7(this._client)}create(Z,Y,Q){return this._client.post(P`/containers/${Z}/files`,Z4({body:Y,...Q},this._client))}retrieve(Z,Y,Q){let{container_id:J}=Y;return this._client.get(P`/containers/${J}/files/${Z}`,Q)}list(Z,Y={},Q){return this._client.getAPIList(P`/containers/${Z}/files`,K0,{query:Y,...Q})}delete(Z,Y,Q){let{container_id:J}=Y;return this._client.delete(P`/containers/${J}/files/${Z}`,{...Q,headers:m([{Accept:"*/*"},Q?.headers])})}};s8.Content=i7});var i4;var GK=_(()=>{qK();qK();M0();j0();U0();i4=class i4 extends b{constructor(){super(...arguments);this.files=new s8(this._client)}create(Z,Y){return this._client.post("/containers",{body:Z,...Y})}retrieve(Z,Y){return this._client.get(P`/containers/${Z}`,Y)}list(Z={},Y){return this._client.getAPIList("/containers",K0,{query:Z,...Y})}delete(Z,Y){return this._client.delete(P`/containers/${Z}`,{...Y,headers:m([{Accept:"*/*"},Y?.headers])})}};i4.Files=s8});var n7;var UK=_(()=>{M0();U0();n7=class n7 extends b{create(Z,Y,Q){let{include:J,...X}=Y;return this._client.post(P`/conversations/${Z}/items`,{query:{include:J},body:X,...Q})}retrieve(Z,Y,Q){let{conversation_id:J,...X}=Y;return this._client.get(P`/conversations/${J}/items/${Z}`,{query:X,...Q})}list(Z,Y={},Q){return this._client.getAPIList(P`/conversations/${Z}/items`,H1,{query:Y,...Q})}delete(Z,Y,Q){let{conversation_id:J}=Y;return this._client.delete(P`/conversations/${J}/items/${Z}`,Q)}}});var n4;var VK=_(()=>{UK();UK();U0();n4=class n4 extends b{constructor(){super(...arguments);this.items=new n7(this._client)}create(Z={},Y){return this._client.post("/conversations",{body:Z,...Y})}retrieve(Z,Y){return this._client.get(P`/conversations/${Z}`,Y)}update(Z,Y,Q){return this._client.post(P`/conversations/${Z}`,{body:Y,...Q})}delete(Z,Y){return this._client.delete(P`/conversations/${Z}`,Y)}};n4.Items=n7});var r8;var BK=_(()=>{p7();r8=class r8 extends b{create(Z,Y){let Q=!!Z.encoding_format,J=Q?Z.encoding_format:"base64";if(Q)E0(this._client).debug("embeddings/user defined encoding_format:",Z.encoding_format);let X=this._client.post("/embeddings",{body:{...Z,encoding_format:J},...Y});if(Q)return X;return E0(this._client).debug("embeddings/decoding base64 embeddings from base64"),X._thenUnwrap((K)=>{if(K&&K.data)K.data.forEach((z)=>{let H=z.embedding;z.embedding=cO(H)});return K})}}});var o7;var $K=_(()=>{M0();U0();o7=class o7 extends b{retrieve(Z,Y,Q){let{eval_id:J,run_id:X}=Y;return this._client.get(P`/evals/${J}/runs/${X}/output_items/${Z}`,Q)}list(Z,Y,Q){let{eval_id:J,...X}=Y;return this._client.getAPIList(P`/evals/${J}/runs/${Z}/output_items`,K0,{query:X,...Q})}}});var t8;var FK=_(()=>{$K();$K();M0();U0();t8=class t8 extends b{constructor(){super(...arguments);this.outputItems=new o7(this._client)}create(Z,Y,Q){return this._client.post(P`/evals/${Z}/runs`,{body:Y,...Q})}retrieve(Z,Y,Q){let{eval_id:J}=Y;return this._client.get(P`/evals/${J}/runs/${Z}`,Q)}list(Z,Y={},Q){return this._client.getAPIList(P`/evals/${Z}/runs`,K0,{query:Y,...Q})}delete(Z,Y,Q){let{eval_id:J}=Y;return this._client.delete(P`/evals/${J}/runs/${Z}`,Q)}cancel(Z,Y,Q){let{eval_id:J}=Y;return this._client.post(P`/evals/${J}/runs/${Z}`,Q)}};t8.OutputItems=o7});var o4;var OK=_(()=>{FK();FK();M0();U0();o4=class o4 extends b{constructor(){super(...arguments);this.runs=new t8(this._client)}create(Z,Y){return this._client.post("/evals",{body:Z,...Y})}retrieve(Z,Y){return this._client.get(P`/evals/${Z}`,Y)}update(Z,Y,Q){return this._client.post(P`/evals/${Z}`,{body:Y,...Q})}list(Z={},Y){return this._client.getAPIList("/evals",K0,{query:Z,...Y})}delete(Z,Y){return this._client.delete(P`/evals/${Z}`,Y)}};o4.Runs=t8});var e8;var RK=_(()=>{M0();j0();c6();b6();U0();e8=class e8 extends b{create(Z,Y){return this._client.post("/files",X6({body:Z,...Y},this._client))}retrieve(Z,Y){return this._client.get(P`/files/${Z}`,Y)}list(Z={},Y){return this._client.getAPIList("/files",K0,{query:Z,...Y})}delete(Z,Y){return this._client.delete(P`/files/${Z}`,Y)}content(Z,Y){return this._client.get(P`/files/${Z}/content`,{...Y,headers:m([{Accept:"application/binary"},Y?.headers]),__binaryResponse:!0})}async waitForProcessing(Z,{pollInterval:Y=5000,maxWait:Q=1800000}={}){let J=new Set(["processed","error","deleted"]),X=Date.now(),K=await this.retrieve(Z);while(!K.status||!J.has(K.status))if(await K1(Y),K=await this.retrieve(Z),Date.now()-X>Q)throw new y4({message:`Giving up on waiting for file ${Z} to finish processing after ${Q} milliseconds.`});return K}}});var a7;var MK=_(()=>{a7=class a7 extends b{}});var s7;var DK=_(()=>{s7=class s7 extends b{run(Z,Y){return this._client.post("/fine_tuning/alpha/graders/run",{body:Z,...Y})}validate(Z,Y){return this._client.post("/fine_tuning/alpha/graders/validate",{body:Z,...Y})}}});var ZZ;var _K=_(()=>{DK();DK();ZZ=class ZZ extends b{constructor(){super(...arguments);this.graders=new s7(this._client)}};ZZ.Graders=s7});var r7;var NK=_(()=>{M0();U0();r7=class r7 extends b{create(Z,Y,Q){return this._client.getAPIList(P`/fine_tuning/checkpoints/${Z}/permissions`,P1,{body:Y,method:"post",...Q})}retrieve(Z,Y={},Q){return this._client.get(P`/fine_tuning/checkpoints/${Z}/permissions`,{query:Y,...Q})}list(Z,Y={},Q){return this._client.getAPIList(P`/fine_tuning/checkpoints/${Z}/permissions`,H1,{query:Y,...Q})}delete(Z,Y,Q){let{fine_tuned_model_checkpoint:J}=Y;return this._client.delete(P`/fine_tuning/checkpoints/${J}/permissions/${Z}`,Q)}}});var YZ;var jK=_(()=>{NK();NK();YZ=class YZ extends b{constructor(){super(...arguments);this.permissions=new r7(this._client)}};YZ.Permissions=r7});var t7;var wK=_(()=>{M0();U0();t7=class t7 extends b{list(Z,Y={},Q){return this._client.getAPIList(P`/fine_tuning/jobs/${Z}/checkpoints`,K0,{query:Y,...Q})}}});var QZ;var TK=_(()=>{wK();wK();M0();U0();QZ=class QZ extends b{constructor(){super(...arguments);this.checkpoints=new t7(this._client)}create(Z,Y){return this._client.post("/fine_tuning/jobs",{body:Z,...Y})}retrieve(Z,Y){return this._client.get(P`/fine_tuning/jobs/${Z}`,Y)}list(Z={},Y){return this._client.getAPIList("/fine_tuning/jobs",K0,{query:Z,...Y})}cancel(Z,Y){return this._client.post(P`/fine_tuning/jobs/${Z}/cancel`,Y)}listEvents(Z,Y={},Q){return this._client.getAPIList(P`/fine_tuning/jobs/${Z}/events`,K0,{query:Y,...Q})}pause(Z,Y){return this._client.post(P`/fine_tuning/jobs/${Z}/pause`,Y)}resume(Z,Y){return this._client.post(P`/fine_tuning/jobs/${Z}/resume`,Y)}};QZ.Checkpoints=t7});var G1;var LK=_(()=>{MK();MK();_K();_K();jK();jK();TK();TK();G1=class G1 extends b{constructor(){super(...arguments);this.methods=new a7(this._client),this.jobs=new QZ(this._client),this.checkpoints=new YZ(this._client),this.alpha=new ZZ(this._client)}};G1.Methods=a7;G1.Jobs=QZ;G1.Checkpoints=YZ;G1.Alpha=ZZ});var e7;var IK=_(()=>{e7=class e7 extends b{}});var a4;var AK=_(()=>{IK();IK();a4=class a4 extends b{constructor(){super(...arguments);this.graderModels=new e7(this._client)}};a4.GraderModels=e7});var JZ;var CK=_(()=>{b6();JZ=class JZ extends b{createVariation(Z,Y){return this._client.post("/images/variations",X6({body:Z,...Y},this._client))}edit(Z,Y){return this._client.post("/images/edits",X6({body:Z,...Y,stream:Z.stream??!1},this._client))}generate(Z,Y){return this._client.post("/images/generations",{body:Z,...Y,stream:Z.stream??!1})}}});var XZ;var EK=_(()=>{M0();U0();XZ=class XZ extends b{retrieve(Z,Y){return this._client.get(P`/models/${Z}`,Y)}list(Z){return this._client.getAPIList("/models",P1,Z)}delete(Z,Y){return this._client.delete(P`/models/${Z}`,Y)}}});var KZ;var xK=_(()=>{KZ=class KZ extends b{create(Z,Y){return this._client.post("/moderations",{body:Z,...Y})}}});var ZY;var SK=_(()=>{j0();U0();ZY=class ZY extends b{accept(Z,Y,Q){return this._client.post(P`/realtime/calls/${Z}/accept`,{body:Y,...Q,headers:m([{Accept:"*/*"},Q?.headers])})}hangup(Z,Y){return this._client.post(P`/realtime/calls/${Z}/hangup`,{...Y,headers:m([{Accept:"*/*"},Y?.headers])})}refer(Z,Y,Q){return this._client.post(P`/realtime/calls/${Z}/refer`,{body:Y,...Q,headers:m([{Accept:"*/*"},Q?.headers])})}reject(Z,Y={},Q){return this._client.post(P`/realtime/calls/${Z}/reject`,{body:Y,...Q,headers:m([{Accept:"*/*"},Q?.headers])})}}});var YY;var kK=_(()=>{YY=class YY extends b{create(Z,Y){return this._client.post("/realtime/client_secrets",{body:Z,...Y})}}});var z4;var PK=_(()=>{SK();SK();kK();kK();z4=class z4 extends b{constructor(){super(...arguments);this.clientSecrets=new YY(this._client),this.calls=new ZY(this._client)}};z4.ClientSecrets=YY;z4.Calls=ZY});function eO(Z,Y){if(!Y||!fx(Y))return{...Z,output_parsed:null,output:Z.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 vK(Z,Y)}function vK(Z,Y){let Q=Z.output.map((X)=>{if(X.type==="function_call")return{...X,parsed_arguments:mx(Y,X)};if(X.type==="message"){let K=X.content.map((z)=>{if(z.type==="output_text")return{...z,parsed:bx(Y,z.text)};return z});return{...X,content:K}}return X}),J=Object.assign({},Z,{output:Q});if(!Object.getOwnPropertyDescriptor(Z,"output_text"))$Q(J);return Object.defineProperty(J,"output_parsed",{enumerable:!0,get(){for(let X of J.output){if(X.type!=="message")continue;for(let K of X.content)if(K.type==="output_text"&&K.parsed!==null)return K.parsed}return null}}),J}function bx(Z,Y){if(Z.text?.format?.type!=="json_schema")return null;if("$parseRaw"in Z.text?.format)return(Z.text?.format).$parseRaw(Y);return JSON.parse(Y)}function fx(Z){if(j7(Z.text?.format))return!0;return!1}function hx(Z){return Z?.$brand==="auto-parseable-tool"}function gx(Z,Y){return Z.find((Q)=>Q.type==="function"&&Q.name===Y)}function mx(Z,Y){let Q=gx(Z.tools??[],Y.name);return{...Y,...Y,parsed_arguments:hx(Q)?Q.$parseRaw(Y.arguments):Q?.strict?JSON.parse(Y.arguments):null}}function $Q(Z){let Y=[];for(let Q of Z.output){if(Q.type!=="message")continue;for(let J of Q.content)if(J.type==="output_text")Y.push(J.text)}Z.output_text=Y.join("")}var yK=_(()=>{c6();T7()});function ux(Z,Y){return eO(Z,Y)}var zZ,FQ,H4,OQ,ZR,YR,QR,JR,RQ;var XR=_(()=>{y6();c6();XQ();yK();RQ=class RQ extends h4{constructor(Z){super();zZ.add(this),FQ.set(this,void 0),H4.set(this,void 0),OQ.set(this,void 0),r(this,FQ,Z,"f")}static createResponse(Z,Y,Q){let J=new RQ(Y);return J._run(()=>J._createOrRetrieveResponse(Z,Y,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createOrRetrieveResponse(Z,Y,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}A(this,zZ,"m",ZR).call(this);let X,K=null;if("response_id"in Y)X=await Z.responses.retrieve(Y.response_id,{stream:!0},{...Q,signal:this.controller.signal,stream:!0}),K=Y.starting_after??null;else X=await Z.responses.create({...Y,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let z of X)A(this,zZ,"m",YR).call(this,z,K);if(X.controller.signal?.aborted)throw new f0;return A(this,zZ,"m",QR).call(this)}[(FQ=new WeakMap,H4=new WeakMap,OQ=new WeakMap,zZ=new WeakSet,ZR=function Z(){if(this.ended)return;r(this,H4,void 0,"f")},YR=function Z(Y,Q){if(this.ended)return;let J=(K,z)=>{if(Q==null||z.sequence_number>Q)this._emit(K,z)},X=A(this,zZ,"m",JR).call(this,Y);switch(J("event",Y),Y.type){case"response.output_text.delta":{let K=X.output[Y.output_index];if(!K)throw new n(`missing output at index ${Y.output_index}`);if(K.type==="message"){let z=K.content[Y.content_index];if(!z)throw new n(`missing content at index ${Y.content_index}`);if(z.type!=="output_text")throw new n(`expected content to be 'output_text', got ${z.type}`);J("response.output_text.delta",{...Y,snapshot:z.text})}break}case"response.function_call_arguments.delta":{let K=X.output[Y.output_index];if(!K)throw new n(`missing output at index ${Y.output_index}`);if(K.type==="function_call")J("response.function_call_arguments.delta",{...Y,snapshot:K.arguments});break}default:J(Y.type,Y);break}},QR=function Z(){if(this.ended)throw new n("stream has ended, this shouldn't happen");let Y=A(this,H4,"f");if(!Y)throw new n("request ended without sending any events");r(this,H4,void 0,"f");let Q=ux(Y,A(this,FQ,"f"));return r(this,OQ,Q,"f"),Q},JR=function Z(Y){let Q=A(this,H4,"f");if(!Q){if(Y.type!=="response.created")throw new n(`When snapshot hasn't been set yet, expected 'response.created' event, got ${Y.type}`);return Q=r(this,H4,Y.response,"f"),Q}switch(Y.type){case"response.output_item.added":{Q.output.push(Y.item);break}case"response.content_part.added":{let J=Q.output[Y.output_index];if(!J)throw new n(`missing output at index ${Y.output_index}`);let X=J.type,K=Y.part;if(X==="message"&&K.type!=="reasoning_text")J.content.push(K);else if(X==="reasoning"&&K.type==="reasoning_text"){if(!J.content)J.content=[];J.content.push(K)}break}case"response.output_text.delta":{let J=Q.output[Y.output_index];if(!J)throw new n(`missing output at index ${Y.output_index}`);if(J.type==="message"){let X=J.content[Y.content_index];if(!X)throw new n(`missing content at index ${Y.content_index}`);if(X.type!=="output_text")throw new n(`expected content to be 'output_text', got ${X.type}`);X.text+=Y.delta}break}case"response.function_call_arguments.delta":{let J=Q.output[Y.output_index];if(!J)throw new n(`missing output at index ${Y.output_index}`);if(J.type==="function_call")J.arguments+=Y.delta;break}case"response.reasoning_text.delta":{let J=Q.output[Y.output_index];if(!J)throw new n(`missing output at index ${Y.output_index}`);if(J.type==="reasoning"){let X=J.content?.[Y.content_index];if(!X)throw new n(`missing content at index ${Y.content_index}`);if(X.type!=="reasoning_text")throw new n(`expected content to be 'reasoning_text', got ${X.type}`);X.text+=Y.delta}break}case"response.completed":{r(this,H4,Y.response,"f");break}}return Q},Symbol.asyncIterator)](){let Z=[],Y=[],Q=!1;return this.on("event",(J)=>{let X=Y.shift();if(X)X.resolve(J);else Z.push(J)}),this.on("end",()=>{Q=!0;for(let J of Y)J.resolve(void 0);Y.length=0}),this.on("abort",(J)=>{Q=!0;for(let X of Y)X.reject(J);Y.length=0}),this.on("error",(J)=>{Q=!0;for(let X of Y)X.reject(J);Y.length=0}),{next:async()=>{if(!Z.length){if(Q)return{value:void 0,done:!0};return new Promise((X,K)=>Y.push({resolve:X,reject:K})).then((X)=>X?{value:X,done:!1}:{value:void 0,done:!0})}return{value:Z.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let Z=A(this,OQ,"f");if(!Z)throw new n("stream ended without producing a ChatCompletion");return Z}}});var QY;var bK=_(()=>{M0();U0();QY=class QY extends b{list(Z,Y={},Q){return this._client.getAPIList(P`/responses/${Z}/input_items`,K0,{query:Y,...Q})}}});var JY;var fK=_(()=>{JY=class JY extends b{count(Z={},Y){return this._client.post("/responses/input_tokens",{body:Z,...Y})}}});var W4;var hK=_(()=>{yK();XR();bK();bK();fK();fK();j0();U0();W4=class W4 extends b{constructor(){super(...arguments);this.inputItems=new QY(this._client),this.inputTokens=new JY(this._client)}create(Z,Y){return this._client.post("/responses",{body:Z,...Y,stream:Z.stream??!1})._thenUnwrap((Q)=>{if("object"in Q&&Q.object==="response")$Q(Q);return Q})}retrieve(Z,Y={},Q){return this._client.get(P`/responses/${Z}`,{query:Y,...Q,stream:Y?.stream??!1})._thenUnwrap((J)=>{if("object"in J&&J.object==="response")$Q(J);return J})}delete(Z,Y){return this._client.delete(P`/responses/${Z}`,{...Y,headers:m([{Accept:"*/*"},Y?.headers])})}parse(Z,Y){return this._client.responses.create(Z,Y)._thenUnwrap((Q)=>vK(Q,Z))}stream(Z,Y){return RQ.createResponse(this._client,Z,Y)}cancel(Z,Y){return this._client.post(P`/responses/${Z}/cancel`,Y)}compact(Z,Y){return this._client.post("/responses/compact",{body:Z,...Y})}};W4.InputItems=QY;W4.InputTokens=JY});var XY;var gK=_(()=>{j0();U0();XY=class XY extends b{retrieve(Z,Y){return this._client.get(P`/skills/${Z}/content`,{...Y,headers:m([{Accept:"application/binary"},Y?.headers]),__binaryResponse:!0})}}});var KY;var mK=_(()=>{j0();U0();KY=class KY extends b{retrieve(Z,Y,Q){let{skill_id:J}=Y;return this._client.get(P`/skills/${J}/versions/${Z}/content`,{...Q,headers:m([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}}});var HZ;var uK=_(()=>{mK();mK();M0();b6();U0();HZ=class HZ extends b{constructor(){super(...arguments);this.content=new KY(this._client)}create(Z,Y={},Q){return this._client.post(P`/skills/${Z}/versions`,Z4({body:Y,...Q},this._client))}retrieve(Z,Y,Q){let{skill_id:J}=Y;return this._client.get(P`/skills/${J}/versions/${Z}`,Q)}list(Z,Y={},Q){return this._client.getAPIList(P`/skills/${Z}/versions`,K0,{query:Y,...Q})}delete(Z,Y,Q){let{skill_id:J}=Y;return this._client.delete(P`/skills/${J}/versions/${Z}`,Q)}};HZ.Content=KY});var q4;var pK=_(()=>{gK();gK();uK();uK();M0();b6();U0();q4=class q4 extends b{constructor(){super(...arguments);this.content=new XY(this._client),this.versions=new HZ(this._client)}create(Z={},Y){return this._client.post("/skills",Z4({body:Z,...Y},this._client))}retrieve(Z,Y){return this._client.get(P`/skills/${Z}`,Y)}update(Z,Y,Q){return this._client.post(P`/skills/${Z}`,{body:Y,...Q})}list(Z={},Y){return this._client.getAPIList("/skills",K0,{query:Z,...Y})}delete(Z,Y){return this._client.delete(P`/skills/${Z}`,Y)}};q4.Content=XY;q4.Versions=HZ});var zY;var dK=_(()=>{b6();U0();zY=class zY extends b{create(Z,Y,Q){return this._client.post(P`/uploads/${Z}/parts`,X6({body:Y,...Q},this._client))}}});var s4;var cK=_(()=>{dK();dK();U0();s4=class s4 extends b{constructor(){super(...arguments);this.parts=new zY(this._client)}create(Z,Y){return this._client.post("/uploads",{body:Z,...Y})}cancel(Z,Y){return this._client.post(P`/uploads/${Z}/cancel`,Y)}complete(Z,Y,Q){return this._client.post(P`/uploads/${Z}/complete`,{body:Y,...Q})}};s4.Parts=zY});var KR=async(Z)=>{let Y=await Promise.allSettled(Z),Q=Y.filter((X)=>X.status==="rejected");if(Q.length){for(let X of Q)console.error(X.reason);throw Error(`${Q.length} promise(s) failed - see the above errors`)}let J=[];for(let X of Y)if(X.status==="fulfilled")J.push(X.value);return J};var HY;var lK=_(()=>{M0();j0();U0();HY=class HY extends b{create(Z,Y,Q){return this._client.post(P`/vector_stores/${Z}/file_batches`,{body:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Z,Y,Q){let{vector_store_id:J}=Y;return this._client.get(P`/vector_stores/${J}/file_batches/${Z}`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Z,Y,Q){let{vector_store_id:J}=Y;return this._client.post(P`/vector_stores/${J}/file_batches/${Z}/cancel`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Z,Y,Q){let J=await this.create(Z,Y);return await this.poll(Z,J.id,Q)}listFiles(Z,Y,Q){let{vector_store_id:J,...X}=Y;return this._client.getAPIList(P`/vector_stores/${J}/file_batches/${Z}/files`,K0,{query:X,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async poll(Z,Y,Q){let J=m([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:X,response:K}=await this.retrieve(Y,{vector_store_id:Z},{...Q,headers:J}).withResponse();switch(X.status){case"in_progress":let z=5000;if(Q?.pollIntervalMs)z=Q.pollIntervalMs;else{let H=K.headers.get("openai-poll-after-ms");if(H){let W=parseInt(H);if(!isNaN(W))z=W}}await K1(z);break;case"failed":case"cancelled":case"completed":return X}}}async uploadAndPoll(Z,{files:Y,fileIds:Q=[]},J){if(Y==null||Y.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let X=J?.maxConcurrency??5,K=Math.min(X,Y.length),z=this._client,H=Y.values(),W=[...Q];async function q(U){for(let B of U){let F=await z.files.create({file:B,purpose:"assistants"},J);W.push(F.id)}}let G=Array(K).fill(H).map(q);return await KR(G),await this.createAndPoll(Z,{file_ids:W})}}});var WY;var iK=_(()=>{M0();j0();p7();U0();WY=class WY extends b{create(Z,Y,Q){return this._client.post(P`/vector_stores/${Z}/files`,{body:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Z,Y,Q){let{vector_store_id:J}=Y;return this._client.get(P`/vector_stores/${J}/files/${Z}`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Z,Y,Q){let{vector_store_id:J,...X}=Y;return this._client.post(P`/vector_stores/${J}/files/${Z}`,{body:X,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Z,Y={},Q){return this._client.getAPIList(P`/vector_stores/${Z}/files`,K0,{query:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Z,Y,Q){let{vector_store_id:J}=Y;return this._client.delete(P`/vector_stores/${J}/files/${Z}`,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Z,Y,Q){let J=await this.create(Z,Y,Q);return await this.poll(Z,J.id,Q)}async poll(Z,Y,Q){let J=m([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let X=await this.retrieve(Y,{vector_store_id:Z},{...Q,headers:J}).withResponse(),K=X.data;switch(K.status){case"in_progress":let z=5000;if(Q?.pollIntervalMs)z=Q.pollIntervalMs;else{let H=X.response.headers.get("openai-poll-after-ms");if(H){let W=parseInt(H);if(!isNaN(W))z=W}}await K1(z);break;case"failed":case"completed":return K}}}async upload(Z,Y,Q){let J=await this._client.files.create({file:Y,purpose:"assistants"},Q);return this.create(Z,{file_id:J.id},Q)}async uploadAndPoll(Z,Y,Q){let J=await this.upload(Z,Y,Q);return await this.poll(Z,J.id,Q)}content(Z,Y,Q){let{vector_store_id:J}=Y;return this._client.getAPIList(P`/vector_stores/${J}/files/${Z}/content`,P1,{...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var G4;var nK=_(()=>{lK();lK();iK();iK();M0();j0();U0();G4=class G4 extends b{constructor(){super(...arguments);this.files=new WY(this._client),this.fileBatches=new HY(this._client)}create(Z,Y){return this._client.post("/vector_stores",{body:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}retrieve(Z,Y){return this._client.get(P`/vector_stores/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}update(Z,Y,Q){return this._client.post(P`/vector_stores/${Z}`,{body:Y,...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Z={},Y){return this._client.getAPIList("/vector_stores",K0,{query:Z,...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}delete(Z,Y){return this._client.delete(P`/vector_stores/${Z}`,{...Y,headers:m([{"OpenAI-Beta":"assistants=v2"},Y?.headers])})}search(Z,Y,Q){return this._client.getAPIList(P`/vector_stores/${Z}/search`,P1,{body:Y,method:"post",...Q,headers:m([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}};G4.Files=WY;G4.FileBatches=HY});var WZ;var oK=_(()=>{M0();j0();b6();U0();WZ=class WZ extends b{create(Z,Y){return this._client.post("/videos",X6({body:Z,...Y},this._client))}retrieve(Z,Y){return this._client.get(P`/videos/${Z}`,Y)}list(Z={},Y){return this._client.getAPIList("/videos",H1,{query:Z,...Y})}delete(Z,Y){return this._client.delete(P`/videos/${Z}`,Y)}createCharacter(Z,Y){return this._client.post("/videos/characters",X6({body:Z,...Y},this._client))}downloadContent(Z,Y={},Q){return this._client.get(P`/videos/${Z}/content`,{query:Y,...Q,headers:m([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}edit(Z,Y){return this._client.post("/videos/edits",X6({body:Z,...Y},this._client))}extend(Z,Y){return this._client.post("/videos/extensions",X6({body:Z,...Y},this._client))}getCharacter(Z,Y){return this._client.get(P`/videos/characters/${Z}`,Y)}remix(Z,Y,Q){return this._client.post(P`/videos/${Z}/remix`,Z4({body:Y,...Q},this._client))}}});var qZ,zR,MQ,GZ;var aK=_(()=>{y6();c6();j0();GZ=class GZ extends b{constructor(){super(...arguments);qZ.add(this)}async unwrap(Z,Y,Q=this._client.webhookSecret,J=300){return await this.verifySignature(Z,Y,Q,J),JSON.parse(Z)}async verifySignature(Z,Y,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");A(this,qZ,"m",zR).call(this,Q);let X=m([Y]).values,K=A(this,qZ,"m",MQ).call(this,X,"webhook-signature"),z=A(this,qZ,"m",MQ).call(this,X,"webhook-timestamp"),H=A(this,qZ,"m",MQ).call(this,X,"webhook-id"),W=parseInt(z,10);if(isNaN(W))throw new x1("Invalid webhook timestamp format");let q=Math.floor(Date.now()/1000);if(q-W>J)throw new x1("Webhook timestamp is too old");if(W>q+J)throw new x1("Webhook timestamp is too new");let G=K.split(" ").map(($)=>$.startsWith("v1,")?$.substring(3):$),U=Q.startsWith("whsec_")?Buffer.from(Q.replace("whsec_",""),"base64"):Buffer.from(Q,"utf-8"),B=H?`${H}.${z}.${Z}`:`${z}.${Z}`,F=await crypto.subtle.importKey("raw",U,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let $ of G)try{let O=Buffer.from($,"base64");if(await crypto.subtle.verify("HMAC",F,O,new TextEncoder().encode(B)))return}catch{continue}throw new x1("The given webhook signature does not match the expected signature")}};qZ=new WeakSet,zR=function Z(Y){if(typeof Y!=="string"||Y.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")},MQ=function Z(Y,Q){if(!Y)throw Error("Headers are required");let J=Y.get(Q);if(J===null||J===void 0)throw Error(`Missing required header: ${Q}`);return J}});var HR=_(()=>{aK()});var WR=_(()=>{HR()});var qR=_(()=>{lX();iX();zK();HK();GK();VK();BK();OK();RK();LK();AK();CK();EK();xK();PK();hK();pK();cK();nK();oK();WR();uO();pO()});class X0{constructor({baseURL:Z=X4("OPENAI_BASE_URL"),apiKey:Y=X4("OPENAI_API_KEY"),organization:Q=X4("OPENAI_ORG_ID")??null,project:J=X4("OPENAI_PROJECT_ID")??null,webhookSecret:X=X4("OPENAI_WEBHOOK_SECRET")??null,...K}={}){if(sK.add(this),DQ.set(this,void 0),this.completions=new a8(this),this.chat=new g4(this),this.embeddings=new r8(this),this.files=new e8(this),this.images=new JZ(this),this.audio=new b1(this),this.moderations=new KZ(this),this.models=new XZ(this),this.fineTuning=new G1(this),this.graders=new a4(this),this.vectorStores=new G4(this),this.webhooks=new GZ(this),this.beta=new q1(this),this.batches=new i8(this),this.uploads=new s4(this),this.responses=new W4(this),this.realtime=new z4(this),this.conversations=new n4(this),this.evals=new o4(this),this.containers=new i4(this),this.skills=new q4(this),this.videos=new WZ(this),Y===void 0)throw new n("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");let z={apiKey:Y,organization:Q,project:J,webhookSecret:X,...K,baseURL:Z||"https://api.openai.com/v1"};if(!z.dangerouslyAllowBrowser&&sF())throw new n(`It looks like you're running in a browser-like environment.
|
|
489
|
+
|
|
490
|
+
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
491
|
+
If you understand the risks and have appropriate mitigations in place,
|
|
492
|
+
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
493
|
+
|
|
494
|
+
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
495
|
+
|
|
496
|
+
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
497
|
+
`);this.baseURL=z.baseURL,this.timeout=z.timeout??rK.DEFAULT_TIMEOUT,this.logger=z.logger??console;let H="warn";this.logLevel=H,this.logLevel=FX(z.logLevel,"ClientOptions.logLevel",this)??FX(X4("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??H,this.fetchOptions=z.fetchOptions,this.maxRetries=z.maxRetries??2,this.fetch=z.fetch??tF(),r(this,DQ,ZO,"f"),this._options=z,this.apiKey=typeof Y==="string"?Y:"Missing Key",this.organization=Q,this.project=J,this.webhookSecret=X}withOptions(Z){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,...Z})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:Z,nulls:Y}){return}async authHeaders(Z){return m([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(Z){return UO(Z)}getUserAgent(){return`${this.constructor.name}/JS ${e1}`}defaultIdempotencyKey(){return`stainless-node-retry-${eJ()}`}makeStatusError(Z,Y,Q,J){return v0.generate(Z,Y,Q,J)}async _callApiKey(){let Z=this._options.apiKey;if(typeof Z!=="function")return!1;let Y;try{Y=await Z()}catch(Q){if(Q instanceof n)throw Q;throw new n(`Failed to get token from 'apiKey' function: ${Q.message}`,{cause:Q})}if(typeof Y!=="string"||!Y)throw new n(`Expected 'apiKey' function argument to return a string but it returned ${Y}`);return this.apiKey=Y,!0}buildURL(Z,Y,Q){let J=!A(this,sK,"m",GR).call(this)&&Q||this.baseURL,X=dF(Z)?new URL(Z):new URL(J+(J.endsWith("/")&&Z.startsWith("/")?Z.slice(1):Z)),K=this.defaultQuery(),z=Object.fromEntries(X.searchParams);if(!QX(K)||!QX(z))Y={...z,...K,...Y};if(typeof Y==="object"&&Y&&!Array.isArray(Y))X.search=this.stringifyQuery(Y);return X.toString()}async prepareOptions(Z){await this._callApiKey()}async prepareRequest(Z,{url:Y,options:Q}){}get(Z,Y){return this.methodRequest("get",Z,Y)}post(Z,Y){return this.methodRequest("post",Z,Y)}patch(Z,Y){return this.methodRequest("patch",Z,Y)}put(Z,Y){return this.methodRequest("put",Z,Y)}delete(Z,Y){return this.methodRequest("delete",Z,Y)}methodRequest(Z,Y,Q){return this.request(Promise.resolve(Q).then((J)=>{return{method:Z,path:Y,...J}}))}request(Z,Y=null){return new b4(this,this.makeRequest(Z,Y,void 0))}async makeRequest(Z,Y,Q){let J=await Z,X=J.maxRetries??this.maxRetries;if(Y==null)Y=X;await this.prepareOptions(J);let{req:K,url:z,timeout:H}=await this.buildRequest(J,{retryCount:X-Y});await this.prepareRequest(K,{url:z,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`,k1({retryOfRequestLogID:Q,method:J.method,url:z,options:J,headers:K.headers})),J.signal?.aborted)throw new f0;let U=new AbortController,B=await this.fetchWithTimeout(z,K,H,U).catch(X7),F=Date.now();if(B instanceof globalThis.Error){let D=`retrying, ${Y} attempts remaining`;if(J.signal?.aborted)throw new f0;let j=J7(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Y)return E0(this).info(`[${W}] connection ${j?"timed out":"failed"} - ${D}`),E0(this).debug(`[${W}] connection ${j?"timed out":"failed"} (${D})`,k1({retryOfRequestLogID:Q,url:z,durationMs:F-G,message:B.message})),this.retryRequest(J,Y,Q??W);if(E0(this).info(`[${W}] connection ${j?"timed out":"failed"} - error; no more retries left`),E0(this).debug(`[${W}] connection ${j?"timed out":"failed"} (error; no more retries left)`,k1({retryOfRequestLogID:Q,url:z,durationMs:F-G,message:B.message})),j)throw new y4;throw new v4({cause:B})}let $=[...B.headers.entries()].filter(([D])=>D==="x-request-id").map(([D,j])=>", "+D+": "+JSON.stringify(j)).join(""),O=`[${W}${q}${$}] ${K.method} ${z} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${F-G}ms`;if(!B.ok){let D=await this.shouldRetry(B);if(Y&&D){let x=`retrying, ${Y} attempts remaining`;return await eF(B.body),E0(this).info(`${O} - ${x}`),E0(this).debug(`[${W}] response error (${x})`,k1({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:F-G})),this.retryRequest(J,Y,Q??W,B.headers)}let j=D?"error; no more retries left":"error; not retryable";E0(this).info(`${O} - ${j}`);let M=await B.text().catch((x)=>X7(x).message),T=iF(M),N=T?void 0:M;throw E0(this).debug(`[${W}] response error (${j})`,k1({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,message:N,durationMs:Date.now()-G})),this.makeStatusError(B.status,T,N,B.headers)}return E0(this).info(O),E0(this).debug(`[${W}] response start`,k1({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:F-G})),{response:B,options:J,controller:U,requestLogID:W,retryOfRequestLogID:Q,startTime:G}}getAPIList(Z,Y,Q){return this.requestAPIList(Y,Q&&"then"in Q?Q.then((J)=>({method:"get",path:Z,...J})):{method:"get",path:Z,...Q})}requestAPIList(Z,Y){let Q=this.makeRequest(Y,null,void 0);return new a2(this,Q,Z)}async fetchWithTimeout(Z,Y,Q,J){let{signal:X,method:K,...z}=Y||{},H=this._makeAbort(J);if(X)X.addEventListener("abort",H,{once:!0});let W=setTimeout(H,Q),q=globalThis.ReadableStream&&z.body instanceof globalThis.ReadableStream||typeof z.body==="object"&&z.body!==null&&Symbol.asyncIterator in z.body,G={signal:J.signal,...q?{duplex:"half"}:{},method:"GET",...z};if(K)G.method=K.toUpperCase();try{return await this.fetch.call(void 0,Z,G)}finally{clearTimeout(W)}}async shouldRetry(Z){let Y=Z.headers.get("x-should-retry");if(Y==="true")return!0;if(Y==="false")return!1;if(Z.status===408)return!0;if(Z.status===409)return!0;if(Z.status===429)return!0;if(Z.status>=500)return!0;return!1}async retryRequest(Z,Y,Q,J){let X,K=J?.get("retry-after-ms");if(K){let H=parseFloat(K);if(!Number.isNaN(H))X=H}let z=J?.get("retry-after");if(z&&!X){let H=parseFloat(z);if(!Number.isNaN(H))X=H*1000;else X=Date.parse(z)-Date.now()}if(X===void 0){let H=Z.maxRetries??this.maxRetries;X=this.calculateDefaultRetryTimeoutMillis(Y,H)}return await K1(X),this.makeRequest(Z,Y-1,Q)}calculateDefaultRetryTimeoutMillis(Z,Y){let X=Y-Z,K=Math.min(0.5*Math.pow(2,X),8),z=1-Math.random()*0.25;return K*z*1000}async buildRequest(Z,{retryCount:Y=0}={}){let Q={...Z},{method:J,path:X,query:K,defaultBaseURL:z}=Q,H=this.buildURL(X,K,z);if("timeout"in Q)lF("timeout",Q.timeout);Q.timeout=Q.timeout??this.timeout;let{bodyHeaders:W,body:q}=this.buildBody({options:Q}),G=await this.buildHeaders({options:Z,method:J,bodyHeaders:W,retryCount:Y});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:Z,method:Y,bodyHeaders:Q,retryCount:J}){let X={};if(this.idempotencyHeader&&Y!=="get"){if(!Z.idempotencyKey)Z.idempotencyKey=this.defaultIdempotencyKey();X[this.idempotencyHeader]=Z.idempotencyKey}let K=m([X,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(J),...Z.timeout?{"X-Stainless-Timeout":String(Math.trunc(Z.timeout/1000))}:{},...rF(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(Z),this._options.defaultHeaders,Q,Z.headers]);return this.validateHeaders(K),K.values}_makeAbort(Z){return()=>Z.abort()}buildBody({options:{body:Z,headers:Y}}){if(!Z)return{bodyHeaders:void 0,body:void 0};let Q=m([Y]);if(ArrayBuffer.isView(Z)||Z instanceof ArrayBuffer||Z instanceof DataView||typeof Z==="string"&&Q.values.has("content-type")||globalThis.Blob&&Z instanceof globalThis.Blob||Z instanceof FormData||Z instanceof URLSearchParams||globalThis.ReadableStream&&Z instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:Z};else if(typeof Z==="object"&&((Symbol.asyncIterator in Z)||(Symbol.iterator in Z)&&("next"in Z)&&typeof Z.next==="function"))return{bodyHeaders:void 0,body:u2(Z)};else if(typeof Z==="object"&&Q.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(Z)};else return A(this,DQ,"f").call(this,{body:Z,headers:Q})}}var sK,rK,DQ,GR;var _Q=_(()=>{y6();S1();JX();BX();X1();M0();wX();qR();i2();iX();HK();BK();RK();CK();EK();xK();oK();lX();zK();uX();GK();VK();OK();LK();AK();PK();hK();pK();cK();nK();aK();JX();j0();R7();S1();rK=X0,DQ=new WeakMap,sK=new WeakSet,GR=function Z(){return this.baseURL!=="https://api.openai.com/v1"};X0.OpenAI=rK;X0.DEFAULT_TIMEOUT=600000;X0.OpenAIError=n;X0.APIError=v0;X0.APIConnectionError=v4;X0.APIConnectionTimeoutError=y4;X0.APIUserAbortError=f0;X0.NotFoundError=W7;X0.ConflictError=q7;X0.RateLimitError=U7;X0.BadRequestError=K7;X0.AuthenticationError=z7;X0.InternalServerError=V7;X0.PermissionDeniedError=H7;X0.UnprocessableEntityError=G7;X0.InvalidWebhookSignatureError=x1;X0.toFile=r2;X0.Completions=a8;X0.Chat=g4;X0.Embeddings=r8;X0.Files=e8;X0.Images=JZ;X0.Audio=b1;X0.Moderations=KZ;X0.Models=XZ;X0.FineTuning=G1;X0.Graders=a4;X0.VectorStores=G4;X0.Webhooks=GZ;X0.Beta=q1;X0.Batches=i8;X0.Uploads=s4;X0.Responses=W4;X0.Realtime=z4;X0.Conversations=n4;X0.Evals=o4;X0.Containers=i4;X0.Skills=q4;X0.Videos=WZ});var UR=_(()=>{j0();c6();p7();_Q()});var VR=_(()=>{_Q();wX();i2();_Q();M0();X1();UR()});class NQ{client;defaultModel;constructor(Z,Y,Q="gpt-5-nano",J){this.client=new X0({apiKey:Z,baseURL:Y,defaultHeaders:J}),this.defaultModel=Q}async generate(Z){return(await this.client.chat.completions.create({messages:[{role:"user",content:Z.prompt}],model:Z.model||this.defaultModel,temperature:Z.temperature,max_tokens:Z.maxTokens,reasoning_effort:Z.reasoning})).choices[0].message.content||""}async*streamGenerate(Z){try{let Y=await this.client.chat.completions.create({messages:[{role:"user",content:Z.prompt}],model:Z.model||this.defaultModel,temperature:Z.temperature,max_tokens:Z.maxTokens,stream:!0,reasoning_effort:Z.reasoning});for await(let Q of Y){let J=Q.choices[0]?.delta,X=J?.content,K=J?.reasoning_content||J?.reasoning||J?.reasoning_details?.[0]?.summary;if(X||K)yield{chunk:X??void 0,thinkingChunk:K??void 0,metadata:{model:Q.model,finishReason:Q.choices[0]?.finish_reason??void 0}}}}catch(Y){yield{error:CH(Y)?Y:new o(String(Y),"OPENAI_STREAM_ERROR")}}}}var BR=_(()=>{VR();G0()});class tK{config;constructor(Z={}){this.config=Z;this.config={responseDelayMs:0,streamDelayMs:0,...Z}}async generate(Z){return"Mock response from LLM"}async*streamGenerate(Z){let Q="Mock response from LLM".split(" ");if(this.config.responseDelayMs>0)await LY(this.config.responseDelayMs);let J=`I should generate a mock response for prompt with ${Q.length} words.`.split(" ");for(let X of J){if(this.config.streamDelayMs>0)await LY(this.config.streamDelayMs);yield{chunk:void 0,thinkingChunk:X+" ",metadata:{}}}for(let X of Q){if(this.config.streamDelayMs>0)await LY(this.config.streamDelayMs);yield{chunk:X+" ",thinkingChunk:void 0,metadata:{}}}}}var $R=_(()=>{G0()});async function qY(){let Z=await $0(),Y=Z.get("llm.provider")||"openai";if(Y==="mock")return new tK(Y==="mock"?{responseDelayMs:2300,streamDelayMs:10}:{});let Q=await Z.getSecure("llm.apiKey"),J=Z.get("llm.model");if(!Q)throw new o("No API key found. Please set llm.apiKey with gdx-config command or GDX_LLM_API_KEY env var.","NO_API_KEY");if(Q.startsWith("sk-or-"))Y="openrouter";switch(Y.toLowerCase()){case"openrouter":return new NQ(Q,sH,J,{"HTTP-Referer":"https://github.com/Type-Delta/gdx/tree/main","X-Title":"GDX"});case"openai":return new NQ(Q,void 0,J);default:throw new o(`Unsupported LLM provider: ${Y}`,"UNSUPPORTED_LLM_PROVIDER")}}var eK=_(()=>{G0();B0();F6();BR();$R()});function FR(Z,Y){var Q=Object.keys(Z);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(Z);Y&&(J=J.filter(function(X){return Object.getOwnPropertyDescriptor(Z,X).enumerable})),Q.push.apply(Q,J)}return Q}function OR(Z){for(var Y=1;Y<arguments.length;Y++){var Q=arguments[Y]!=null?arguments[Y]:{};Y%2?FR(Object(Q),!0).forEach(function(J){rx(Z,J,Q[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Z,Object.getOwnPropertyDescriptors(Q)):FR(Object(Q)).forEach(function(J){Object.defineProperty(Z,J,Object.getOwnPropertyDescriptor(Q,J))})}return Z}function rx(Z,Y,Q){if(Y=tx(Y),Y in Z)Object.defineProperty(Z,Y,{value:Q,enumerable:!0,configurable:!0,writable:!0});else Z[Y]=Q;return Z}function tx(Z){var Y=ex(Z,"string");return typeof Y==="symbol"?Y:String(Y)}function ex(Z,Y){if(typeof Z!=="object"||Z===null)return Z;var Q=Z[Symbol.toPrimitive];if(Q!==void 0){var J=Q.call(Z,Y||"default");if(typeof J!=="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return(Y==="string"?String:Number)(Z)}function RR(Z){return Y.withOptions=(Q)=>RR(OR(OR({},Z),Q)),Y;function Y(Q,...J){let X=typeof Q==="string"?[Q]:Q.raw,{alignValues:K=!1,escapeSpecialCharacters:z=Array.isArray(Q),trimWhitespace:H=!0}=Z,W="";for(let U=0;U<X.length;U++){let B=X[U];if(z)B=B.replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(W+=B,U<J.length){let F=K?YS(J[U],W):J[U];W+=F}}let q=W.split(`
|
|
498
|
+
`),G=null;for(let U of q){let B=U.match(/^(\s+)\S+/);if(B){let F=B[1].length;if(!G)G=F;else G=Math.min(G,F)}}if(G!==null){let U=G;W=q.map((B)=>B[0]===" "||B[0]==="\t"?B.slice(U):B).join(`
|
|
499
|
+
`)}if(H)W=W.trim();if(z)W=W.replace(/\\n/g,`
|
|
500
|
+
`).replace(/\\t/g,"\t").replace(/\\r/g,"\r").replace(/\\v/g,"\v").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\0/g,"\x00").replace(/\\x([\da-fA-F]{2})/g,(U,B)=>String.fromCharCode(parseInt(B,16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g,(U,B)=>String.fromCodePoint(parseInt(B,16))).replace(/\\u([\da-fA-F]{4})/g,(U,B)=>String.fromCharCode(parseInt(B,16)));if(typeof Bun<"u")W=W.replace(/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,(U,B,F)=>{var $;let O=($=B!==null&&B!==void 0?B:F)!==null&&$!==void 0?$:"";return String.fromCodePoint(parseInt(O,16))});return W}}function YS(Z,Y){if(typeof Z!=="string"||!Z.includes(`
|
|
501
|
+
`))return Z;let J=Y.slice(Y.lastIndexOf(`
|
|
502
|
+
`)+1).match(/^(\s+)/);if(J){let X=J[1];return Z.replace(/\n/g,`
|
|
503
|
+
${X}`)}return Z}var ZS,U4;var Zz=_(()=>{ZS=RR({}),U4=ZS});function Yz(Z,Y){let Q=Y?`<user-change-description>
|
|
504
|
+
User describes the changes as: ${Y}
|
|
505
|
+
</user-change-description>`:"",J=U4`
|
|
506
|
+
<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>
|
|
507
|
+
|
|
508
|
+
<rules>
|
|
509
|
+
Commit message must be in the following format:
|
|
510
|
+
\`\`\`
|
|
511
|
+
<type>(<scope>): <title>
|
|
512
|
+
|
|
513
|
+
<description>
|
|
514
|
+
|
|
515
|
+
<recap>
|
|
516
|
+
\`\`\`
|
|
517
|
+
|
|
518
|
+
Where:
|
|
519
|
+
- \`<type>\` is one of the following: feat, fix, docs, style, refactor, test, chore, ci, build, revert
|
|
520
|
+
- \`<scope>\` is a noun describing the section of the codebase affected (e.g., component or file name)
|
|
521
|
+
- \`<title>\` is a short description of the change (max 90 characters)
|
|
522
|
+
- \`<description>\` is a detailed an comprehensive description of the changes (wrap at 72 characters)
|
|
523
|
+
- \`<recap>\` Only if there are more than two MAJOR changes; bullet points listing important changes
|
|
524
|
+
|
|
525
|
+
Additional rules:
|
|
526
|
+
- Use the imperative mood in the title (e.g., "Fix bug" not "Fixed bug" or "Fixes bug")
|
|
527
|
+
- IMPORTANT! Total commit message length MUST NOT EXCEED 170 WORDS, keep it concise
|
|
528
|
+
- Do not use Markdown or any other formatting in the output
|
|
529
|
+
- Do not use bullet points outside of the recap section
|
|
530
|
+
- DO NOT PREFIX SECTIONS with labels like "Description:" or "Recap:"
|
|
531
|
+
</rules>`,X=`<git-diff>
|
|
532
|
+
${Z}
|
|
533
|
+
</git-diff>`;return[J,X,Q,"Your commit message:"].filter((K)=>K.length>0).join(`
|
|
534
|
+
|
|
535
|
+
`)}function MR(Z,Y,Q){let J=Q?`<user-change-description>
|
|
536
|
+
User describes the changes as: ${Q}
|
|
537
|
+
</user-change-description>`:"",X=U4`
|
|
538
|
+
<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>
|
|
539
|
+
|
|
540
|
+
<project-commit-guidelines>
|
|
541
|
+
${Y}
|
|
542
|
+
</project-commit-guidelines>
|
|
543
|
+
|
|
544
|
+
<rules>
|
|
545
|
+
- Follow the project-specific conventions above strictly
|
|
546
|
+
- Use the imperative mood in commit titles
|
|
547
|
+
- IMPORTANT! Total commit message length MUST NOT EXCEED 170 WORDS, keep it concise
|
|
548
|
+
- Do not use Markdown or any other formatting in the output
|
|
549
|
+
- Output ONLY the commit message without any labels or prefixes
|
|
550
|
+
</rules>`,K=U4.withOptions({alignValues:!1,escapeSpecialCharacters:!1})`<git-diff>
|
|
551
|
+
${Z}
|
|
552
|
+
</git-diff>`;return[X,K,J,"Your commit message:"].filter((z)=>z.length>0).join(`
|
|
553
|
+
|
|
554
|
+
`)}function DR(Z){let Y=Z.map((Q,J)=>`Example ${J+1}:
|
|
555
|
+
${Q}`).join(`
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
`);return U4`
|
|
560
|
+
<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>
|
|
561
|
+
|
|
562
|
+
<commit-message-examples>
|
|
563
|
+
${Y}
|
|
564
|
+
</commit-message-examples>
|
|
565
|
+
|
|
566
|
+
<task>
|
|
567
|
+
Analyze the commit messages above and produce a concise "Commit Message Guideline" document (max 500 words) that captures:
|
|
568
|
+
1. Overall structure (header/body/footer format, line length limits)
|
|
569
|
+
2. Header conventions (prefixes, types, scopes, title style)
|
|
570
|
+
3. Body conventions (description style, wrapping, bullets if used)
|
|
571
|
+
4. Any recurring patterns or special formatting
|
|
572
|
+
|
|
573
|
+
CRITICAL RULES:
|
|
574
|
+
- Only document patterns that are CLEARLY EVIDENT in the examples
|
|
575
|
+
- Do NOT invent rules that aren't demonstrated in the actual commits
|
|
576
|
+
- If examples are inconsistent, note the variations
|
|
577
|
+
- Be specific and actionable
|
|
578
|
+
- Output ONLY the guideline document, no preamble
|
|
579
|
+
</task>
|
|
580
|
+
|
|
581
|
+
Commit Message Guideline:`}function _R(Z){return U4`
|
|
582
|
+
<instruction>
|
|
583
|
+
You are an unfiltered Gen-Z dev who speaks like a terminal meme lord.
|
|
584
|
+
You talk in chaotic, funny, exaggerated internet slang. You sprinkle emojis,
|
|
585
|
+
caps, sarcasm, and over-the-top reactions. Never boring.
|
|
586
|
+
You're reacting to a git commit message and giving a short, witty comment (max 250 chars).
|
|
587
|
+
You may roast, praise, or question the commit — whatever fits the vibe.
|
|
588
|
+
Keep it casual, absurd, Gen-Z, and funny. Pretend it's your homie's commit.
|
|
589
|
+
</instruction>
|
|
590
|
+
|
|
591
|
+
<rules>
|
|
592
|
+
- NEVER put hashtags in your comments.
|
|
593
|
+
- Output ONLY the comment.
|
|
594
|
+
</rules>
|
|
595
|
+
|
|
596
|
+
<commit>
|
|
597
|
+
${Z}
|
|
598
|
+
</commit>
|
|
599
|
+
|
|
600
|
+
Your unhinged reaction:`}var Qz=_(()=>{Zz()});async function Jz(Z){let{git$:Y}=Z;try{let Q=await t1(Y,"user.email"),J=(await E`${Y} log -1 --pretty=format:%s\n\n%b --author=${Q} --no-merges`.catch(x6))?.stdout.trim();if(!J||J.length===0)return R.error("Bro, you haven't committed anything yet. \uD83E\uDD23","nocap"),1;let X=J.split(`
|
|
601
|
+
`);for(let U of X)I(`${V("Dim")}▐ ${V()}${U}`);I(`
|
|
602
|
+
${V("Cyan")}${V("Dim")}Reviewing your commit message...${V()}
|
|
603
|
+
`);let K=await qY(),z=b0({message:"cooking up a roast...",animateGradient:!0,gradientColor:k.Teal300,gradientColorBg:k.Fuchsia400}),H=K.streamGenerate({prompt:_R(J),temperature:0.8,maxTokens:269,reasoning:"low"}),W="",q=!1;for await(let U of H){if(U.error)return z.stop(),R.error(`\uD83D\uDE2D ill bro, the server rejected u
|
|
604
|
+
|
|
605
|
+
${u(U.error,{color:!0})}`,"nocap"),1;if(U.chunk){if(!q)q=!0,z.stop();I(U.chunk,""),W+=U.chunk}}if(!W)return I(`
|
|
606
|
+
`),R.error("Unable to generate response (empty response).","nocap"),1;let G=W;return W=W.replace(/(^\s*["'`]*|["'`]*\s*$)/g,""),W=s(W,72,{mode:"softboundary",redundancyLv:2}),fY(G,W),I(),0}catch(Q){return R.error(u(Q,{color:!0}),"nocap"),1}}var NR,jR;var jQ=_(()=>{G0();P0();w0();eK();R0();Qz();B0();A0();I0();O6();NR={long:()=>{let Z=V("Bright"),Y=V();return s(`
|
|
607
|
+
${Z+c("NOCAP",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
608
|
+
Generate a playful roast for your latest commit message.
|
|
609
|
+
|
|
610
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
611
|
+
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.
|
|
612
|
+
|
|
613
|
+
${Z+c("WHEN TO USE",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
614
|
+
Use when you want a quick, entertaining summary/critique of your most recent commit message before pushing, or as a lighthearted CI/gaming aid.
|
|
615
|
+
|
|
616
|
+
${Z+c("NOTES",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
617
|
+
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.
|
|
618
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Create a humorous critique of your latest commit message.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
619
|
+
${Z}${C} nocap${Q}
|
|
620
|
+
|
|
621
|
+
Examples:
|
|
622
|
+
${Z}${C} nocap ${Q+Y}# Roast the latest commit by the configured git user${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},jR={$root:[]}});function Xz(Z){let Y={},Q=Array.from(new Set(Z));for(let J of Q){if(!J)continue;Y[J]={}}return Y}function GY(Z,Y,Q="$allOf"){let J={},X=Array.from(new Set(Z));for(let K of X){if(!K)continue;J[K]={[Q]:Y}}return J}function f1(){if(UY!==null)return UY;return UY=process.stdout.rows||24,UY}function UZ(){if(VY!==null)return VY;return VY=process.stdout.columns||80,VY}function Kz(){UY=null,VY=null}class wR{lines=[];wrappedLines=[];options;lastWidth=0;lastHeight=0;redundancyLv=0;constructor(Z,Y={}){this.options={...wQ,...Y},this.redundancyLv=Y.redundancyLv??IY(Z),this.lines=Z.split(`
|
|
623
|
+
`),this.lastWidth=UZ(),this.lastHeight=f1(),this.updateWrappedLines()}updateWrappedLines(){let Z=this.lastWidth,Y=this.options.showLineNumbers?Z-this.options.lineNumberWidth-1:Z;this.wrappedLines=[];for(let Q=0;Q<this.lines.length;Q++){let J=this.lines[Q];if(this.options.wrapLines&&o6(J,this.redundancyLv)>Y){let K=s(J,Y,{mode:"softboundary",redundancyLv:Math.max(0,this.redundancyLv)}).split(`
|
|
624
|
+
`),z=this.options.showLineNumbers?this.formatLineNumber(Q+1):"",H;for(let W=0;W<K.length;W++){let q=W===0?z:" ".repeat(this.options.lineNumberWidth+1);if(H)K[W]=bY(H)+K[W];if(this.wrappedLines.push(q+K[W]),W!=K.length-1)H=yY(K[W])}}else if(this.options.showLineNumbers)this.wrappedLines.push(this.formatLineNumber(Q+1)+J);else this.wrappedLines.push(J)}}formatLineNumber(Z){return String(Z).padStart(this.options.lineNumberWidth)+" "}getLineCount(){return this.wrappedLines.length}getLine(Z){return this.wrappedLines[Z]||""}render(Z,Y,Q){let J=[],X=Q6(this.options.backgroundColor),K=V();for(let z=0;z<Y-1;z++){let H=Z+z;if(H<this.wrappedLines.length){let W=this.wrappedLines[H],q=q8(W),G=Math.max(0,Q-o6(q,this.redundancyLv));J.push(`${X}${W}${" ".repeat(G)}${K}`)}else J.push(`${X}${" ".repeat(Q)}${K}`)}return J}onResize(Z,Y){if(Z!==this.lastWidth||Y!==this.lastHeight)this.lastWidth=Z,this.lastHeight=Y,this.updateWrappedLines()}}async function TR(Z,Y={}){let Q=new wR(Z,Y);return zz(Q,Y)}async function zz(Z,Y={}){let Q={...wQ,...Y},J=Q.redundancyLv??0;if(!process.stdout.isTTY||!process.stdin.isTTY){for(let D=0;D<Z.getLineCount();D++)process.stdout.write(Z.getLine(D)+`
|
|
625
|
+
`);return}process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf-8");let X=0,K=Z.getLineCount(),z=!0,H=null,W=[];process.stdout.write("\x1B[?25l"),process.stdout.write("\x1B[2J\x1B[H");let q=R.logLevel;R.logLevel=-1;function G(){let D=performance.now(),j=f1(),M=UZ(),T=Z.render(X,j,M);process.stdout.write("\x1B[H");for(let N of T)process.stdout.write("\x1B[K"+N+`
|
|
626
|
+
`);if(Q.showStatus){let N=Q.statusFormat(X+1,K,M,{statusText:Q.statusText,actions:Q.actions,redundancyLv:J}),L=Math.max(0,M-o6(q8(N),J)),x=Q6(Q.backgroundColor),S=k0(Q0.overlay0);process.stdout.write("\x1B[K"+x+S+N+" ".repeat(L)+V())}if(W.length>30)W.shift();W.push(performance.now()-D)}function U(){process.stdin.off("data",O),process.stdout.off("resize",$),process.stdout.write("\x1B[?25h");let j=f1()-1;process.stdout.write(`\x1B[${j}B`),process.stdin.setRawMode(!1),process.stdin.pause(),R.logLevel=q,R.debug(`Pager performance: ${W.length>0?H8(W.reduce((M,T)=>M+T,0)/W.length,4):"N/A"}ms average over ${W.length} renders`,"pager")}function B(){Kz();let D=UZ(),j=f1();if(Z.onResize)Z.onResize(D,j);G()}function F(D){let M=f1()-1,T=Math.max(0,Z.getLineCount()-M),N=Q.actions||[];if(N.length>0){for(let L of N)if((Array.isArray(L.key)?L.key:[L.key]).includes(D)){H={action:L.action,key:D},z=!1;return}}switch(D){case"q":case"\x03":case"\x1B":if(N.length>0&&!H)H={action:"abort",key:D};z=!1;break;case"\x1B[A":case"\x1B[A":case"k":X=Math.max(0,X-Q.scrollSensitivity);break;case"\x1B[B":case"\x1B[B":case"j":X=Math.min(T,X+Q.scrollSensitivity);break;case"\x1B[5~":case"b":{let L=M-1;X=Math.max(0,X-L);break}case"\x1B[6~":case"n":case" ":{let L=M-1;X=Math.min(T,X+L);break}case"g":case"\x1B[1~":case"\x1B[H":X=0;break;case"G":case"\x1B[4~":case"\x1B[F":X=T;break}if(z)G()}let $=()=>B(),O=(D)=>{if(F(D.toString()),!z)U()};return process.stdout.on("resize",$),process.stdin.on("data",O),G(),new Promise((D)=>{let j=setInterval(()=>{if(!z)clearInterval(j),D(H||void 0)},50)})}var wQ,UY=null,VY=null;var LR=_(()=>{G0();R0();I0();B0();wQ={showLineNumbers:!1,lineNumberWidth:4,wrapLines:!0,showStatus:!0,statusFormat:(Z,Y,Q,J)=>{let X=V("Bright"),K=V("Normal"),z=V("Dim"),H=Math.min(Z+f1()-2,Y),W=typeof J?.statusText==="function"?J.statusText():J?.statusText,q=J?.actions?J.actions.map((F)=>{let O=(Array.isArray(F.key)?F.key:[F.key])[0]??"";if(!O)return"";return`${X}${O}${K} ${F.label}`}).filter(Boolean).join(`${z},${K} `):"",G=q?`${X}↑ ↓ b n${K} navigate, ${X}q${K} quit`:`${X}↑ ↓ b n Home End${K} to navigate, ${X}q${K} quit`,U=q?`ln ${X}${Z}${K} of ${X}${Y}${Z===Y?V("Red")+" EOF"+V("White"):""}`:`lines ${X}${Z}-${H}${K} of ${X}${Y}${H===Y?V("Red")+" (EOF)"+V("White"):""}`,B=[W,G,q].filter(Boolean);return" "+D6([B.join(" "),U],Q-4,{align:"spacebetween",filler:" ",overflow:"collapse",collapseLocation:"mid",redundancyLv:J?.redundancyLv??0})+" "},backgroundColor:Q0.base,scrollSensitivity:3,statusText:"",actions:[]}});class m0{diff(Z,Y,Q={}){let J;if(typeof Q==="function")J=Q,Q={};else if("callback"in Q)J=Q.callback;let X=this.castInput(Z,Q),K=this.castInput(Y,Q),z=this.removeEmpty(this.tokenize(X,Q)),H=this.removeEmpty(this.tokenize(K,Q));return this.diffWithOptionsObj(z,H,Q,J)}diffWithOptionsObj(Z,Y,Q,J){var X;let K=(j)=>{if(j=this.postProcess(j,Q),J){setTimeout(function(){J(j)},0);return}else return j},z=Y.length,H=Z.length,W=1,q=z+H;if(Q.maxEditLength!=null)q=Math.min(q,Q.maxEditLength);let G=(X=Q.timeout)!==null&&X!==void 0?X:1/0,U=Date.now()+G,B=[{oldPos:-1,lastComponent:void 0}],F=this.extractCommon(B[0],Y,Z,0,Q);if(B[0].oldPos+1>=H&&F+1>=z)return K(this.buildValues(B[0].lastComponent,Y,Z));let $=-1/0,O=1/0,D=()=>{for(let j=Math.max($,-W);j<=Math.min(O,W);j+=2){let M,T=B[j-1],N=B[j+1];if(T)B[j-1]=void 0;let L=!1;if(N){let S=N.oldPos-j;L=N&&0<=S&&S<z}let x=T&&T.oldPos+1<H;if(!L&&!x){B[j]=void 0;continue}if(!x||L&&T.oldPos<N.oldPos)M=this.addToPath(N,!0,!1,0,Q);else M=this.addToPath(T,!1,!0,1,Q);if(F=this.extractCommon(M,Y,Z,j,Q),M.oldPos+1>=H&&F+1>=z)return K(this.buildValues(M.lastComponent,Y,Z))||!0;else{if(B[j]=M,M.oldPos+1>=H)O=Math.min(O,j-1);if(F+1>=z)$=Math.max($,j+1)}}W++};if(J)(function j(){setTimeout(function(){if(W>q||Date.now()>U)return J(void 0);if(!D())j()},0)})();else while(W<=q&&Date.now()<=U){let j=D();if(j)return j}}addToPath(Z,Y,Q,J,X){let K=Z.lastComponent;if(K&&!X.oneChangePerToken&&K.added===Y&&K.removed===Q)return{oldPos:Z.oldPos+J,lastComponent:{count:K.count+1,added:Y,removed:Q,previousComponent:K.previousComponent}};else return{oldPos:Z.oldPos+J,lastComponent:{count:1,added:Y,removed:Q,previousComponent:K}}}extractCommon(Z,Y,Q,J,X){let K=Y.length,z=Q.length,H=Z.oldPos,W=H-J,q=0;while(W+1<K&&H+1<z&&this.equals(Q[H+1],Y[W+1],X))if(W++,H++,q++,X.oneChangePerToken)Z.lastComponent={count:1,previousComponent:Z.lastComponent,added:!1,removed:!1};if(q&&!X.oneChangePerToken)Z.lastComponent={count:q,previousComponent:Z.lastComponent,added:!1,removed:!1};return Z.oldPos=H,W}equals(Z,Y,Q){if(Q.comparator)return Q.comparator(Z,Y);else return Z===Y||!!Q.ignoreCase&&Z.toLowerCase()===Y.toLowerCase()}removeEmpty(Z){let Y=[];for(let Q=0;Q<Z.length;Q++)if(Z[Q])Y.push(Z[Q]);return Y}castInput(Z,Y){return Z}tokenize(Z,Y){return Array.from(Z)}join(Z){return Z.join("")}postProcess(Z,Y){return Z}get useLongestToken(){return!1}buildValues(Z,Y,Q){let J=[],X;while(Z)J.push(Z),X=Z.previousComponent,delete Z.previousComponent,Z=X;J.reverse();let K=J.length,z=0,H=0,W=0;for(;z<K;z++){let q=J[z];if(!q.removed){if(!q.added&&this.useLongestToken){let G=Y.slice(H,H+q.count);G=G.map(function(U,B){let F=Q[W+B];return F.length>U.length?F:U}),q.value=this.join(G)}else q.value=this.join(Y.slice(H,H+q.count));if(H+=q.count,!q.added)W+=q.count}else q.value=this.join(Q.slice(W,W+q.count)),W+=q.count}return J}}function AR(Z,Y,Q){return Hz.diff(Z,Y,Q)}var IR,Hz;var CR=_(()=>{IR=class IR extends m0{};Hz=new IR});function Wz(Z,Y){let Q;for(Q=0;Q<Z.length&&Q<Y.length;Q++)if(Z[Q]!=Y[Q])return Z.slice(0,Q);return Z.slice(0,Q)}function qz(Z,Y){let Q;if(!Z||!Y||Z[Z.length-1]!=Y[Y.length-1])return"";for(Q=0;Q<Z.length&&Q<Y.length;Q++)if(Z[Z.length-(Q+1)]!=Y[Y.length-(Q+1)])return Z.slice(-Q);return Z.slice(-Q)}function TQ(Z,Y,Q){if(Z.slice(0,Y.length)!=Y)throw Error(`string ${JSON.stringify(Z)} doesn't start with prefix ${JSON.stringify(Y)}; this is a bug`);return Q+Z.slice(Y.length)}function LQ(Z,Y,Q){if(!Y)return Z+Q;if(Z.slice(-Y.length)!=Y)throw Error(`string ${JSON.stringify(Z)} doesn't end with suffix ${JSON.stringify(Y)}; this is a bug`);return Z.slice(0,-Y.length)+Q}function VZ(Z,Y){return TQ(Z,Y,"")}function BY(Z,Y){return LQ(Z,Y,"")}function Gz(Z,Y){return Y.slice(0,QS(Z,Y))}function QS(Z,Y){let Q=0;if(Z.length>Y.length)Q=Z.length-Y.length;let J=Y.length;if(Z.length<Y.length)J=Z.length;let X=Array(J),K=0;X[0]=0;for(let z=1;z<J;z++){if(Y[z]==Y[K])X[z]=X[K];else X[z]=K;while(K>0&&Y[z]!=Y[K])K=X[K];if(Y[z]==Y[K])K++}K=0;for(let z=Q;z<Z.length;z++){while(K>0&&Z[z]!=Y[K])K=X[K];if(Z[z]==Y[K])K++}return K}function ER(Z){return Z.includes(`\r
|
|
627
|
+
`)&&!Z.startsWith(`
|
|
628
|
+
`)&&!Z.match(/[^\r]\n/)}function xR(Z){return!Z.includes(`\r
|
|
629
|
+
`)&&Z.includes(`
|
|
630
|
+
`)}function Uz(Z,Y){let Q=[];for(let J of Array.from(Y.segment(Z))){let X=J.segment;if(Q.length&&/\s/.test(Q[Q.length-1])&&/\s/.test(X))Q[Q.length-1]+=X;else Q.push(X)}return Q}function IQ(Z,Y){if(Y)return BZ(Z,Y)[1];let Q;for(Q=Z.length-1;Q>=0;Q--)if(!Z[Q].match(/\s/))break;return Z.substring(Q+1)}function r4(Z,Y){if(Y)return BZ(Z,Y)[0];let Q=Z.match(/^\s*/);return Q?Q[0]:""}function BZ(Z,Y){if(!Y)return[r4(Z),IQ(Z)];if(Y.resolvedOptions().granularity!="word")throw Error('The segmenter passed must have a granularity of "word"');let Q=Uz(Z,Y),J=Q[0],X=Q[Q.length-1],K=/\s/.test(J)?J:"",z=/\s/.test(X)?X:"";return[K,z]}function PR(Z,Y,Q){if((Q===null||Q===void 0?void 0:Q.ignoreWhitespace)!=null&&!Q.ignoreWhitespace)return $z(Z,Y,Q);return Vz.diff(Z,Y,Q)}function SR(Z,Y,Q,J,X){if(Y&&Q){let[K,z]=BZ(Y.value,X),[H,W]=BZ(Q.value,X);if(Z){let q=Wz(K,H);Z.value=LQ(Z.value,H,q),Y.value=VZ(Y.value,q),Q.value=VZ(Q.value,q)}if(J){let q=qz(z,W);J.value=TQ(J.value,W,q),Y.value=BY(Y.value,q),Q.value=BY(Q.value,q)}}else if(Q){if(Z){let K=r4(Q.value,X);Q.value=Q.value.substring(K.length)}if(J){let K=r4(J.value,X);J.value=J.value.substring(K.length)}}else if(Z&&J){let K=r4(J.value,X),[z,H]=BZ(Y.value,X),W=Wz(K,z);Y.value=VZ(Y.value,W);let q=qz(VZ(K,W),H);Y.value=BY(Y.value,q),J.value=TQ(J.value,K,q),Z.value=LQ(Z.value,K,K.slice(0,K.length-q.length))}else if(J){let K=r4(J.value,X),z=IQ(Y.value,X),H=Gz(z,K);Y.value=BY(Y.value,H)}else if(Z){let K=IQ(Z.value,X),z=r4(Y.value,X),H=Gz(K,z);Y.value=VZ(Y.value,H)}}function $z(Z,Y,Q){return Bz.diff(Z,Y,Q)}var AQ="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",JS,kR,Vz,vR,Bz;var yR=_(()=>{JS=new RegExp(`[${AQ}]+|\\s+|[^${AQ}]`,"ug");kR=class kR extends m0{equals(Z,Y,Q){if(Q.ignoreCase)Z=Z.toLowerCase(),Y=Y.toLowerCase();return Z.trim()===Y.trim()}tokenize(Z,Y={}){let Q;if(Y.intlSegmenter){let K=Y.intlSegmenter;if(K.resolvedOptions().granularity!="word")throw Error('The segmenter passed must have a granularity of "word"');Q=Uz(Z,K)}else Q=Z.match(JS)||[];let J=[],X=null;return Q.forEach((K)=>{if(/\s/.test(K))if(X==null)J.push(K);else J.push(J.pop()+K);else if(X!=null&&/\s/.test(X))if(J[J.length-1]==X)J.push(J.pop()+K);else J.push(X+K);else J.push(K);X=K}),J}join(Z){return Z.map((Y,Q)=>{if(Q==0)return Y;else return Y.replace(/^\s+/,"")}).join("")}postProcess(Z,Y){if(!Z||Y.oneChangePerToken)return Z;let Q=null,J=null,X=null;if(Z.forEach((K)=>{if(K.added)J=K;else if(K.removed)X=K;else{if(J||X)SR(Q,X,J,K,Y.intlSegmenter);Q=K,J=null,X=null}}),J||X)SR(Q,X,J,null,Y.intlSegmenter);return Z}};Vz=new kR;vR=class vR extends m0{tokenize(Z){let Y=new RegExp(`(\\r?\\n)|[${AQ}]+|[^\\S\\n\\r]+|[^${AQ}]`,"ug");return Z.match(Y)||[]}};Bz=new vR});function bR(Z,Y){if(typeof Z==="function")Y.callback=Z;else if(Z){for(let Q in Z)if(Object.prototype.hasOwnProperty.call(Z,Q))Y[Q]=Z[Q]}return Y}function $Y(Z,Y,Q){return CQ.diff(Z,Y,Q)}function hR(Z,Y,Q){return Q=bR(Q,{ignoreWhitespace:!0}),CQ.diff(Z,Y,Q)}function Fz(Z,Y){if(Y.stripTrailingCr)Z=Z.replace(/\r\n/g,`
|
|
631
|
+
`);let Q=[],J=Z.split(/(\n|\r\n)/);if(!J[J.length-1])J.pop();for(let X=0;X<J.length;X++){let K=J[X];if(X%2&&!Y.newlineIsToken)Q[Q.length-1]+=K;else Q.push(K)}return Q}var fR,CQ;var EQ=_(()=>{fR=class fR extends m0{constructor(){super(...arguments);this.tokenize=Fz}equals(Z,Y,Q){if(Q.ignoreWhitespace){if(!Q.newlineIsToken||!Z.includes(`
|
|
632
|
+
`))Z=Z.trim();if(!Q.newlineIsToken||!Y.includes(`
|
|
633
|
+
`))Y=Y.trim()}else if(Q.ignoreNewlineAtEof&&!Q.newlineIsToken){if(Z.endsWith(`
|
|
634
|
+
`))Z=Z.slice(0,-1);if(Y.endsWith(`
|
|
635
|
+
`))Y=Y.slice(0,-1)}return super.equals(Z,Y,Q)}};CQ=new fR});function XS(Z){return Z=="."||Z=="!"||Z=="?"}function mR(Z,Y,Q){return Oz.diff(Z,Y,Q)}var gR,Oz;var uR=_(()=>{gR=class gR extends m0{tokenize(Z){var Y;let Q=[],J=0;for(let X=0;X<Z.length;X++){if(X==Z.length-1){Q.push(Z.slice(J));break}if(XS(Z[X])&&Z[X+1].match(/\s/)){Q.push(Z.slice(J,X+1)),X=J=X+1;while((Y=Z[X+1])===null||Y===void 0?void 0:Y.match(/\s/))X++;Q.push(Z.slice(J,X+1)),J=X+1}}return Q}};Oz=new gR});function dR(Z,Y,Q){return Rz.diff(Z,Y,Q)}var pR,Rz;var cR=_(()=>{pR=class pR extends m0{tokenize(Z){return Z.split(/([{}:;,]|\s+)/)}};Rz=new pR});function iR(Z,Y,Q){return Mz.diff(Z,Y,Q)}function FY(Z,Y,Q,J,X){if(Y=Y||[],Q=Q||[],J)Z=J(X===void 0?"":X,Z);let K;for(K=0;K<Y.length;K+=1)if(Y[K]===Z)return Q[K];let z;if(Object.prototype.toString.call(Z)==="[object Array]"){Y.push(Z),z=Array(Z.length),Q.push(z);for(K=0;K<Z.length;K+=1)z[K]=FY(Z[K],Y,Q,J,String(K));return Y.pop(),Q.pop(),z}if(Z&&Z.toJSON)Z=Z.toJSON();if(typeof Z==="object"&&Z!==null){Y.push(Z),z={},Q.push(z);let H=[],W;for(W in Z)if(Object.prototype.hasOwnProperty.call(Z,W))H.push(W);H.sort();for(K=0;K<H.length;K+=1)W=H[K],z[W]=FY(Z[W],Y,Q,J,W);Y.pop(),Q.pop()}else z=Z;return z}var lR,Mz;var nR=_(()=>{EQ();lR=class lR extends m0{constructor(){super(...arguments);this.tokenize=Fz}get useLongestToken(){return!0}castInput(Z,Y){let{undefinedReplacement:Q,stringifyReplacer:J=(X,K)=>typeof K>"u"?Q:K}=Y;return typeof Z==="string"?Z:JSON.stringify(FY(Z,null,null,J),null," ")}equals(Z,Y,Q){return super.equals(Z.replace(/,([\r\n])/g,"$1"),Y.replace(/,([\r\n])/g,"$1"),Q)}};Mz=new lR});function aR(Z,Y,Q){return Dz.diff(Z,Y,Q)}var oR,Dz;var sR=_(()=>{oR=class oR extends m0{tokenize(Z){return Z.slice()}join(Z){return Z}removeEmpty(Z){return Z}};Dz=new oR});function _z(Z){if(Array.isArray(Z))return Z.map((Y)=>_z(Y));return Object.assign(Object.assign({},Z),{hunks:Z.hunks.map((Y)=>Object.assign(Object.assign({},Y),{lines:Y.lines.map((Q,J)=>{var X;return Q.startsWith("\\")||Q.endsWith("\r")||((X=Y.lines[J+1])===null||X===void 0?void 0:X.startsWith("\\"))?Q:Q+"\r"})}))})}function Nz(Z){if(Array.isArray(Z))return Z.map((Y)=>Nz(Y));return Object.assign(Object.assign({},Z),{hunks:Z.hunks.map((Y)=>Object.assign(Object.assign({},Y),{lines:Y.lines.map((Q)=>Q.endsWith("\r")?Q.substring(0,Q.length-1):Q)}))})}function rR(Z){if(!Array.isArray(Z))Z=[Z];return!Z.some((Y)=>Y.hunks.some((Q)=>Q.lines.some((J)=>!J.startsWith("\\")&&J.endsWith("\r"))))}function tR(Z){if(!Array.isArray(Z))Z=[Z];return Z.some((Y)=>Y.hunks.some((Q)=>Q.lines.some((J)=>J.endsWith("\r"))))&&Z.every((Y)=>Y.hunks.every((Q)=>Q.lines.every((J,X)=>{var K;return J.startsWith("\\")||J.endsWith("\r")||((K=Q.lines[X+1])===null||K===void 0?void 0:K.startsWith("\\"))})))}function OY(Z){let Y=Z.split(/\n/),Q=[],J=0;function X(){let H={};Q.push(H);while(J<Y.length){let W=Y[J];if(/^(---|\+\+\+|@@)\s/.test(W))break;let q=/^(?:Index:|diff(?: -r \w+)+)\s+/.exec(W);if(q)H.index=W.substring(q[0].length).trim();J++}K(H),K(H),H.hunks=[];while(J<Y.length){let W=Y[J];if(/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(W))break;else if(/^@@/.test(W))H.hunks.push(z());else if(W)throw Error("Unknown line "+(J+1)+" "+JSON.stringify(W));else J++}}function K(H){let W=/^(---|\+\+\+)\s+/.exec(Y[J]);if(W){let q=W[1],G=Y[J].substring(3).trim().split("\t",2),U=(G[1]||"").trim(),B=G[0].replace(/\\\\/g,"\\");if(B.startsWith('"')&&B.endsWith('"'))B=B.substr(1,B.length-2);if(q==="---")H.oldFileName=B,H.oldHeader=U;else H.newFileName=B,H.newHeader=U;J++}}function z(){var H;let W=J,q=Y[J++],G=q.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),U={oldStart:+G[1],oldLines:typeof G[2]>"u"?1:+G[2],newStart:+G[3],newLines:typeof G[4]>"u"?1:+G[4],lines:[]};if(U.oldLines===0)U.oldStart+=1;if(U.newLines===0)U.newStart+=1;let B=0,F=0;for(;J<Y.length&&(F<U.oldLines||B<U.newLines||((H=Y[J])===null||H===void 0?void 0:H.startsWith("\\")));J++){let $=Y[J].length==0&&J!=Y.length-1?" ":Y[J][0];if($==="+"||$==="-"||$===" "||$==="\\"){if(U.lines.push(Y[J]),$==="+")B++;else if($==="-")F++;else if($===" ")B++,F++}else throw Error(`Hunk at line ${W+1} contained invalid line ${Y[J]}`)}if(!B&&U.newLines===1)U.newLines=0;if(!F&&U.oldLines===1)U.oldLines=0;if(B!==U.newLines)throw Error("Added line count did not match for hunk at line "+(W+1));if(F!==U.oldLines)throw Error("Removed line count did not match for hunk at line "+(W+1));return U}while(J<Y.length)X();return Q}function jz(Z,Y,Q){let J=!0,X=!1,K=!1,z=1;return function H(){if(J&&!K){if(X)z++;else J=!1;if(Z+z<=Q)return Z+z;K=!0}if(!X){if(!K)J=!0;if(Y<=Z-z)return Z-z++;return X=!0,H()}return}}function wz(Z,Y,Q={}){let J;if(typeof Y==="string")J=OY(Y);else if(Array.isArray(Y))J=Y;else J=[Y];if(J.length>1)throw Error("applyPatch only works with a single input.");return KS(Z,J[0],Q)}function KS(Z,Y,Q={}){if(Q.autoConvertLineEndings||Q.autoConvertLineEndings==null){if(ER(Z)&&rR(Y))Y=_z(Y);else if(xR(Z)&&tR(Y))Y=Nz(Y)}let J=Z.split(`
|
|
636
|
+
`),X=Y.hunks,K=Q.compareLine||(($,O,D,j)=>O===j),z=Q.fuzzFactor||0,H=0;if(z<0||!Number.isInteger(z))throw Error("fuzzFactor must be a non-negative integer");if(!X.length)return Z;let W="",q=!1,G=!1;for(let $=0;$<X[X.length-1].lines.length;$++){let O=X[X.length-1].lines[$];if(O[0]=="\\"){if(W[0]=="+")q=!0;else if(W[0]=="-")G=!0}W=O}if(q){if(G){if(!z&&J[J.length-1]=="")return!1}else if(J[J.length-1]=="")J.pop();else if(!z)return!1}else if(G){if(J[J.length-1]!="")J.push("");else if(!z)return!1}function U($,O,D,j=0,M=!0,T=[],N=0){let L=0,x=!1;for(;j<$.length;j++){let S=$[j],g=S.length>0?S[0]:" ",h=S.length>0?S.substr(1):S;if(g==="-")if(K(O+1,J[O],g,h))O++,L=0;else{if(!D||J[O]==null)return null;return T[N]=J[O],U($,O+1,D-1,j,!1,T,N+1)}if(g==="+"){if(!M)return null;T[N]=h,N++,L=0,x=!0}if(g===" ")if(L++,T[N]=J[O],K(O+1,J[O],g,h))N++,M=!0,x=!1,O++;else{if(x||!D)return null;return J[O]&&(U($,O+1,D-1,j+1,!1,T,N+1)||U($,O+1,D-1,j,!1,T,N+1))||U($,O,D-1,j+1,!1,T,N)}}return N-=L,O-=L,T.length=N,{patchedLines:T,oldLineLastI:O-1}}let B=[],F=0;for(let $=0;$<X.length;$++){let O=X[$],D,j=J.length-O.oldLines+z,M;for(let T=0;T<=z;T++){M=O.oldStart+F-1;let N=jz(M,H,j);for(;M!==void 0;M=N())if(D=U(O.lines,M,T),D)break;if(D)break}if(!D)return!1;for(let T=H;T<M;T++)B.push(J[T]);for(let T=0;T<D.patchedLines.length;T++){let N=D.patchedLines[T];B.push(N)}H=D.oldLineLastI+1,F=M+1-O.oldStart}for(let $=H;$<J.length;$++)B.push(J[$]);return B.join(`
|
|
637
|
+
`)}function eR(Z,Y){let Q=typeof Z==="string"?OY(Z):Z,J=0;function X(){let K=Q[J++];if(!K)return Y.complete();Y.loadFile(K,function(z,H){if(z)return Y.complete(z);let W=wz(H,K,Y);Y.patched(K,W,function(q){if(q)return Y.complete(q);X()})})}X()}var ZM=()=>{};function Tz(Z){if(Array.isArray(Z))return Z.map((Y)=>Tz(Y)).reverse();return Object.assign(Object.assign({},Z),{oldFileName:Z.newFileName,oldHeader:Z.newHeader,newFileName:Z.oldFileName,newHeader:Z.oldHeader,hunks:Z.hunks.map((Y)=>{return{oldLines:Y.newLines,oldStart:Y.newStart,newLines:Y.oldLines,newStart:Y.oldStart,lines:Y.lines.map((Q)=>{if(Q.startsWith("-"))return`+${Q.slice(1)}`;if(Q.startsWith("+"))return`-${Q.slice(1)}`;return Q})}})})}function xQ(Z,Y,Q,J,X,K,z){let H;if(!z)H={};else if(typeof z==="function")H={callback:z};else H=z;if(typeof H.context>"u")H.context=4;let W=H.context;if(H.newlineIsToken)throw Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(!H.callback)return q($Y(Q,J,H));else{let{callback:G}=H;$Y(Q,J,Object.assign(Object.assign({},H),{callback:(U)=>{let B=q(U);G(B)}}))}function q(G){if(!G)return;G.push({value:"",lines:[]});function U(M){return M.map(function(T){return" "+T})}let B=[],F=0,$=0,O=[],D=1,j=1;for(let M=0;M<G.length;M++){let T=G[M],N=T.lines||zS(T.value);if(T.lines=N,T.added||T.removed){if(!F){let L=G[M-1];if(F=D,$=j,L)O=W>0?U(L.lines.slice(-W)):[],F-=O.length,$-=O.length}for(let L of N)O.push((T.added?"+":"-")+L);if(T.added)j+=N.length;else D+=N.length}else{if(F)if(N.length<=W*2&&M<G.length-2)for(let L of U(N))O.push(L);else{let L=Math.min(N.length,W);for(let S of U(N.slice(0,L)))O.push(S);let x={oldStart:F,oldLines:D-F+L,newStart:$,newLines:j-$+L,lines:O};B.push(x),F=0,$=0,O=[]}D+=N.length,j+=N.length}}for(let M of B)for(let T=0;T<M.lines.length;T++)if(M.lines[T].endsWith(`
|
|
638
|
+
`))M.lines[T]=M.lines[T].slice(0,-1);else M.lines.splice(T+1,0,"\"),T++;return{oldFileName:Z,newFileName:Y,oldHeader:X,newHeader:K,hunks:B}}}function RY(Z,Y){if(!Y)Y=Lz;if(Array.isArray(Z)){if(Z.length>1&&!Y.includeFileHeaders)throw Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return Z.map((J)=>RY(J,Y)).join(`
|
|
639
|
+
`)}let Q=[];if(Y.includeIndex&&Z.oldFileName==Z.newFileName)Q.push("Index: "+Z.oldFileName);if(Y.includeUnderline)Q.push("===================================================================");if(Y.includeFileHeaders)Q.push("--- "+Z.oldFileName+(typeof Z.oldHeader>"u"?"":"\t"+Z.oldHeader)),Q.push("+++ "+Z.newFileName+(typeof Z.newHeader>"u"?"":"\t"+Z.newHeader));for(let J=0;J<Z.hunks.length;J++){let X=Z.hunks[J];if(X.oldLines===0)X.oldStart-=1;if(X.newLines===0)X.newStart-=1;Q.push("@@ -"+X.oldStart+","+X.oldLines+" +"+X.newStart+","+X.newLines+" @@");for(let K of X.lines)Q.push(K)}return Q.join(`
|
|
640
|
+
`)+`
|
|
641
|
+
`}function Iz(Z,Y,Q,J,X,K,z){if(typeof z==="function")z={callback:z};if(!(z===null||z===void 0?void 0:z.callback)){let H=xQ(Z,Y,Q,J,X,K,z);if(!H)return;return RY(H,z===null||z===void 0?void 0:z.headerOptions)}else{let{callback:H}=z;xQ(Z,Y,Q,J,X,K,Object.assign(Object.assign({},z),{callback:(W)=>{if(!W)H(void 0);else H(RY(W,z.headerOptions))}}))}}function JM(Z,Y,Q,J,X,K){return Iz(Z,Z,Y,Q,J,X,K)}function zS(Z){let Y=Z.endsWith(`
|
|
642
|
+
`),Q=Z.split(`
|
|
643
|
+
`).map((J)=>J+`
|
|
644
|
+
`);if(Y)Q.pop();else Q.push(Q.pop().slice(0,-1));return Q}var Lz,YM,QM;var XM=_(()=>{EQ();Lz={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0},YM={includeIndex:!1,includeUnderline:!1,includeFileHeaders:!0},QM={includeIndex:!1,includeUnderline:!1,includeFileHeaders:!1}});function KM(Z){let Y=[],Q,J;for(let X=0;X<Z.length;X++){if(Q=Z[X],Q.added)J=1;else if(Q.removed)J=-1;else J=0;Y.push([J,Q.value])}return Y}function zM(Z){let Y=[];for(let Q=0;Q<Z.length;Q++){let J=Z[Q];if(J.added)Y.push("<ins>");else if(J.removed)Y.push("<del>");if(Y.push(HS(J.value)),J.added)Y.push("</ins>");else if(J.removed)Y.push("</del>")}return Y.join("")}function HS(Z){let Y=Z;return Y=Y.replace(/&/g,"&"),Y=Y.replace(/</g,"<"),Y=Y.replace(/>/g,">"),Y=Y.replace(/"/g,"""),Y}var Az={};TY(Az,{wordsWithSpaceDiff:()=>Bz,wordDiff:()=>Vz,structuredPatch:()=>xQ,sentenceDiff:()=>Oz,reversePatch:()=>Tz,parsePatch:()=>OY,lineDiff:()=>CQ,jsonDiff:()=>Mz,formatPatch:()=>RY,diffWordsWithSpace:()=>$z,diffWords:()=>PR,diffTrimmedLines:()=>hR,diffSentences:()=>mR,diffLines:()=>$Y,diffJson:()=>iR,diffCss:()=>dR,diffChars:()=>AR,diffArrays:()=>aR,cssDiff:()=>Rz,createTwoFilesPatch:()=>Iz,createPatch:()=>JM,convertChangesToXML:()=>zM,convertChangesToDMP:()=>KM,characterDiff:()=>Hz,canonicalize:()=>FY,arrayDiff:()=>Dz,applyPatches:()=>eR,applyPatch:()=>wz,OMIT_HEADERS:()=>QM,INCLUDE_HEADERS:()=>Lz,FILE_HEADERS_ONLY:()=>YM,Diff:()=>m0});var Cz=_(()=>{CR();yR();EQ();uR();cR();nR();sR();ZM();XM()});async function GS(){return WM??=import("@shikijs/cli"),await WM}async function US(){return qM??=Promise.resolve().then(() => (Cz(),Az)),await qM}function xz(Z){let Y=[];for(let Q of Z){if(!Q.value)continue;let J=Y[Y.length-1];if(J&&J.type===Q.type)J.value+=Q.value;else Y.push({...Q})}return Y}function Ez(Z){return Boolean(Z.added||Z.removed)}function $M(Z,Y,Q){let J=Z[Y];if(!J||Ez(J))return!1;let X=Array.from(J.value);if(X.filter((q)=>q===`
|
|
645
|
+
`).length>1)return!1;if(X.filter((q)=>q!==`
|
|
646
|
+
`&&q!=="\r").length>=Q)return!1;let H=!1;for(let q=Y-1;q>=0;q--){if(!Z[q]?.value)continue;if(Ez(Z[q]))H=!0;break}if(!H)return!1;let W=!1;for(let q=Y+1;q<Z.length;q++){if(!Z[q]?.value)continue;if(Ez(Z[q]))W=!0;break}return W}function VS(Z){let Y=Z.map((Q,J)=>{return{type:Q.removed?"delete":Q.added||$M(Z,J,M9)?"add":"same",value:Q.value}});return xz(Y)}function GM(Z,Y){let Q=[];for(let J=0;J<Z.length;J++){let X=Z[J];if(Y==="add"&&X.removed)continue;if(Y==="delete"&&X.added)continue;if(X.added)Q.push({type:"add",value:X.value});else if(X.removed)Q.push({type:"delete",value:X.value});else if($M(Z,J,M9))Q.push({type:Y,value:X.value});else Q.push({type:"same",value:X.value})}return xz(Q)}function UM(Z){return Z.map((Y)=>Y.value).join("")}function VM(Z,Y){let Q=Array.from({length:Y},()=>[]);if(Y<=0)return Q;let J=0;for(let X of Z){let K=X.value;while(K.length>0&&J<Y){let z=K.indexOf(`
|
|
647
|
+
`);if(z===-1){if(K)Q[J].push({type:X.type,value:K});break}let H=K.slice(0,z);if(H)Q[J].push({type:X.type,value:H});J++,K=K.slice(z+1)}}for(let X=0;X<Q.length;X++)Q[X]=xz(Q[X]);return Q}function BS(Z){let Y=[],Q="",J=0,X="";while(J<Z.length){if(Z[J]==="\x1B"){let H=Z.slice(J).match(qS);if(H){X+=H[0],J+=H[0].length;continue}}let K=Z.codePointAt(J);if(K===void 0)break;let z=String.fromCodePoint(K);Y.push({prefix:X,char:z}),X="",J+=z.length}return Q=X,{tokens:Y,trailingAnsi:Q}}function SQ(){return process.stdout.isTTY===!0&&process.stdin.isTTY===!0&&e0.supportsColor>=3}function $S(Z){let Y=Z.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"}[Y]||"text"}function $Z(Z){let Y=[],Q=Z.split(`
|
|
648
|
+
`),J=null,X=0,K=0,z=!1,H=2;for(let W of Q){if(BM.test(W)){if(J)Y.push(J);let q=MS(W);if(q)J={fileName:q.fileName,oldFileName:q.oldFileName,newFileName:q.newFileName,lang:$S(q.fileName),lines:[]},z=q.isCombined,H=2;else J=null,z=!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)X=parseInt(q[1],10);if(G)K=parseInt(G[1],10);J.lines.push({type:"hunk",content:W}),z=!0;let U=W.match(/-\d+(?:,\d+)?/g);H=Math.max(U?.length??2,2);continue}if(W.startsWith("@@ ")){let q=W.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(q)X=parseInt(q[1],10),K=parseInt(q[2],10);J.lines.push({type:"hunk",content:W});continue}if(z){if(W.length>=H){let q=W.slice(0,H);if(/^[ +-]+$/.test(q)){let G=W.slice(H),U=q.includes("+"),B=q.includes("-"),F=U?"add":B?"delete":"context",$={type:F,content:G};if(F==="add")$.newLineNum=K++;else if(F==="delete")$.oldLineNum=X++;else $.oldLineNum=X++,$.newLineNum=K++;J.lines.push($);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:X++});continue}if(W[0]===" "||W===""){J.lines.push({type:"context",content:W[0]===" "?W.substring(1):"",oldLineNum:X++,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)Y.push(J);return Y}async function FS(Z,Y,Q,J){let X=new Map;if(Y.size===0)return X;try{let K=J?`${J}/${Z}`:Z,H=(await l0(K,"utf-8")).split(`
|
|
649
|
+
`),W=Math.max(0,Math.min(...Y)-Q),q=Math.min(H.length-1,Math.max(...Y)+Q);for(let G=W;G<=q;G++)X.set(G+1,H[G])}catch{}return X}async function OS(Z,Y,Q){let J=new Map,X=Z.lines.filter((H)=>H.type==="add"||H.type==="delete"||H.type==="context"||H.type==="modify");if(X.length===0)return J;let K=X.filter((H)=>H.type!=="delete"),z=X.filter((H)=>H.type==="delete");try{let H=await GS();if(K.length>0){let W=new Set;K.forEach((U)=>{if(U.newLineNum!==void 0)W.add(U.newLineNum)});let q=await FS(Z.newFileName,W,20,Q),G=RS(K,q);if(R.debug(`Highlighting diff for ${Z.newFileName} with ${X.length} changed lines and ${q.size} lines of context from FS`,"diff-viewer"),q.size>0&&G){let U=Math.min(...q.keys()),B=Math.max(...q.keys()),F=[];for(let D=U;D<=B;D++)F.push(q.get(D)||"");let O=(await H.codeToANSI(F.join(`
|
|
650
|
+
`),Z.lang,Y)).split(`
|
|
651
|
+
`);for(let D of K){let j=D.newLineNum;if(j!==void 0){let M=j-U;if(M>=0&&M<O.length)J.set(D,O[M])}}}else{R.debug(`No additional context from FS for ${Z.newFileName}, using what we have from git`,"diff-viewer");let U=K.map(($)=>$.content).join(`
|
|
652
|
+
`),F=(await H.codeToANSI(U,Z.lang,Y)).split(`
|
|
653
|
+
`);for(let $=0;$<K.length;$++)if(F[$])J.set(K[$],F[$])}}if(z.length>0){let W=z.map((U)=>U.content).join(`
|
|
654
|
+
`),G=(await H.codeToANSI(W,Z.lang,Y)).split(`
|
|
655
|
+
`);for(let U=0;U<z.length;U++)if(G[U])J.set(z[U],G[U])}}catch(H){R.error(`Error highlighting diff for ${Z.newFileName}: ${o.from(H)}`,"diff-viewer"),X.forEach((W)=>J.set(W,W.content))}return J}function RS(Z,Y){if(Y.size===0)return!1;let Q=0;for(let J of Z){if(J.newLineNum===void 0)continue;let X=Y.get(J.newLineNum);if(X===void 0||X!==J.content)return!1;Q++}return Q>0}class FM{parsedDiffs=[];renderedLines=[];options;lastWidth=0;lastHeight=0;redundancyLv=0;widthRedundancyLv=0;logger=new R("diff-renderer");ADDED_BG=g6(Q0.base,Q0.green,0.15);DELETED_BG=g6(Q0.base,Q0.red,0.15);ADDED_INLINE_BG=g6(Q0.base,Q0.green,0.28);DELETED_INLINE_BG=g6(Q0.base,Q0.red,0.28);ADDED_GUTTER_BG=g6(Q0.base,Q0.green,0.25);DELETED_GUTTER_BG=g6(Q0.base,Q0.red,0.25);constructor(Z,Y={}){this.options={...wQ,showLineNumbers:!0,theme:iH,lineNumberWidth:5,wrapLines:!0,showStatus:!0,preambleLines:[],...Y},this.logger.debug("Initializing DiffViewerRenderer with options: "+u(this.options)),this.lastWidth=UZ(),this.lastHeight=f1(),this.redundancyLv=Y.redundancyLv??IY(Z),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",()=>$Z(Z)),this.updateRenderedLines()}async prepareHighlighting(){await this.prepareInlineDiffs();for(let Z of this.parsedDiffs){let Y=Z.lines.filter((J)=>J.type==="add"||J.type==="delete"||J.type==="context"||J.type==="modify");if(Y.length===0)continue;let Q=await OS(Z,this.options.theme,this.options.workingDir);Y.forEach((J)=>{let X=Q.get(J);if(X!==void 0)J.highlightedContent=X})}this.updateRenderedLines()}async prepareInlineDiffs(){if(!this.parsedDiffs.some((Q)=>{for(let J=0;J<Q.lines.length;J++){if(Q.lines[J].type!=="add"&&Q.lines[J].type!=="delete")continue;let X=J;while(J<Q.lines.length&&(Q.lines[J].type==="add"||Q.lines[J].type==="delete"))J++;let K=Q.lines.slice(X,J),z=K.some((W)=>W.type==="add"),H=K.some((W)=>W.type==="delete");if(z&&H)return!0;J--}return!1}))return;let Y;try{let Q=await US();Y=Q.diffChars||Q.default?.diffChars}catch(Q){this.logger.warn(`Inline diff module failed to load: ${o.from(Q)}`);return}if(!Y){this.logger.warn("Inline diff module loaded without diffChars export");return}for(let Q of this.parsedDiffs){let J=0;while(J<Q.lines.length){if(Q.lines[J].type!=="add"&&Q.lines[J].type!=="delete"){J++;continue}let X=J;while(J<Q.lines.length&&(Q.lines[J].type==="add"||Q.lines[J].type==="delete"))J++;let K=J,z=Q.lines.slice(X,K),H=z.filter((O)=>O.type==="delete"),W=z.filter((O)=>O.type==="add");if(H.length===0||W.length===0)continue;if(H.length===1&&W.length===1&&H[0].oldLineNum!==void 0&&W[0].newLineNum!==void 0){let O=H[0],D=W[0],j=Y(O.content,D.content),M=VS(j),T={type:"modify",content:D.content,oldLineNum:O.oldLineNum,newLineNum:D.newLineNum,inlineSegments:M};Q.lines.splice(X,K-X,T),J=X+1;continue}let G=H.map((O)=>O.content).join(`
|
|
656
|
+
`),U=W.map((O)=>O.content).join(`
|
|
657
|
+
`),B=Y(G,U),F=GM(B,"add");if(F.length>0&&UM(F)===U){let O=VM(F,W.length);for(let D=0;D<W.length;D++)if(O[D].length>0)W[D].inlineSegments=O[D]}let $=GM(B,"delete");if($.length>0&&UM($)===G){let O=VM($,H.length);for(let D=0;D<H.length;D++)if(O[D].length>0)H[D].inlineSegments=O[D]}}}}renderLine(Z,Y,Q){let J=[],X=this.options.lineNumberWidth,K=Y-X-4,z=" ",H=Q,W=Q,q=Q0.overlay0;switch(Z.type){case"add":z="+",H=this.ADDED_BG,W=this.ADDED_GUTTER_BG,q=Q0.green;break;case"modify":z="~",H=this.ADDED_BG,W=this.ADDED_GUTTER_BG,q=Q0.green;break;case"delete":z="-",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(Z.content,Y)),J;case"header":return J.push(this.renderFileHeader(Z.content,Y)),J;default:return J}let G=Z.inlineSegments?this.renderInlineSegments(Z.inlineSegments,Z.type,H,Z.highlightedContent||Z.content,Z.content):Z.highlightedContent||Z.content,U=Z.newLineNum??Z.oldLineNum,B=U!==void 0?String(U).padStart(X):" ".repeat(X),F=`${k0(Q0.overlay1)}${B} ${k0(q)}${z} `;if(this.options.wrapLines&&o6(G,this.widthRedundancyLv)>K){let $=s(G,K,{mode:"softboundary",redundancyLv:this.widthRedundancyLv});if($.length<2)R.warn(`Expected wrapped content to have multiple lines but got: "${$}". Original content length: ${G.length}, wrapped length: ${$.length}, content width: ${K}`,"diff-renderer");let O=$.split(`
|
|
658
|
+
`),D;for(let j=0;j<O.length;j++){let M=j===0?F:" ".repeat(X+3);if(D)O[j]=bY(D)+O[j];if(J.push(this.padLineWithBg(M+Q6(H)+O[j],Y,W)),j!==O.length-1)D=yY(O[j])}}else J.push(this.padLineWithBg(F+Q6(H)+G,Y,W));return J}renderInlineSegments(Z,Y,Q,J,X){let K=[],z=Q6(Q),{tokens:H,trailingAnsi:W}=BS(J),q=Array.from(X),G=0,U=(B)=>{let F=Array.from(B),$="";for(let O of F){let D=H[G];if(D){$+=`${D.prefix}${D.char}`,G++;continue}let j=q[G]??O;$+=j,G++}return $};for(let B of Z){if(B.type==="same"){K.push(U(B.value));continue}if(B.type==="add"){K.push(`${Q6(this.ADDED_INLINE_BG)}${U(B.value)}${z}`);continue}let F=Y==="modify"?B.value:U(B.value),$=Y==="modify",O=$?"\x1B[9m":"",D=$?"\x1B[29m":"";K.push(`${Q6(this.DELETED_INLINE_BG)}${O}${F}${D}${z}`)}if(W)K.push(W);return K.join("")}padLineWithBg(Z,Y,Q){let J=Math.max(0,Y-o6(Z,this.widthRedundancyLv));return`${Q6(Q)}${Z}${" ".repeat(J)}${V()}`}renderHunkHeader(Z,Y){let Q=g6(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ↕ ${k0(Q0.cyan)}${HM.italic(Z)}`,Y,Q)}renderFileHeader(Z,Y){let Q=g6(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ${k0(Q0.overlay1)}${Z}`,Y,Q)}renderFileName(Z,Y,Q){let J=g6(Q0.crust,Q0.surface0,0.3);if(Z===Y)return this.padLineWithBg(` ${k0(Q0.lavender)}${HM.bold(Y)}`,Q,J);return this.padLineWithBg(` ${k0(Q0.yellow)}${Z} -> ${Y}`,Q,J)}renderPreambleLine(Z,Y,Q,J){if(!Z)return[this.padLineWithBg(" ",Y,Q)];Z=" ".repeat(J)+Z;let X=Y,K=k0(Q0.overlay1);if(this.options.wrapLines&&o6(Z,this.widthRedundancyLv)>X)return s(Z,X,{mode:"softboundary",indent:J,redundancyLv:this.widthRedundancyLv}).split(`
|
|
659
|
+
`).map((H)=>this.padLineWithBg(K+H,Y,Q));return[this.padLineWithBg(K+Z,Y,Q)]}updateRenderedLines(){this.renderedLines=[];let Z=this.lastWidth,Y=g6(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,Z,Y,3));if(this.parsedDiffs.length>0)this.renderedLines.push(this.padLineWithBg(" ",Z,Y))}for(let Q=0;Q<this.parsedDiffs.length;Q++){let J=this.parsedDiffs[Q],X=Y;if(Q!==0)this.renderedLines.push(this.padLineWithBg(" ",Z,X),this.padLineWithBg(" "+k0(Q0.surface0)+"─".repeat(Z-12),Z,X),this.padLineWithBg(" ",Z,X));this.renderedLines.push(this.renderFileName(J.oldFileName,J.newFileName,Z));for(let K of J.lines)this.renderedLines.push(...this.renderLine(K,Z,X))}}getLineCount(){return this.renderedLines.length}getLine(Z){return this.renderedLines[Z]||""}render(Z,Y,Q){let J=[],X=Q6(this.options.backgroundColor);for(let K=0;K<Y-1;K++){let z=Z+K;J.push(z<this.renderedLines.length?this.renderedLines[z]:`${X}${" ".repeat(Q)}${V()}`)}return J}onResize(Z,Y){if(Z!==this.lastWidth||Y!==this.lastHeight)this.lastWidth=Z,this.lastHeight=Y,this.updateRenderedLines()}}async function MY(Z,Y={}){if(!SQ())return R.warn("Diff viewer is not supported in this environment. Falling back to plain output.","diff-viewer"),TR(Z,{...Y,showLineNumbers:!1});let Q=Z.length>1e4?b0({message:"Preparing diff viewer...",interval:10}):void 0,{body:J,preamble:X}=DS(Z);R.time("Preparing diff highlighting");let K=new FM(J,{...Y,preambleLines:X});return await K.prepareHighlighting(),Kz(),K.onResize(UZ(),f1()),Q?.stop(),R.timeEnd("Preparing diff highlighting","diff-viewer"),zz(K,Y)}function OM(Z){return WS.test(Z)}function MS(Z){if(Z.startsWith("diff --git ")){let Q=Z.match(/diff --git a\/(.+?) b\/(.+)/);if(!Q)return null;return{fileName:Q[2],oldFileName:Q[1],newFileName:Q[2],isCombined:!1}}let Y=Z.match(/^diff --(?:cc|combined) (.+)$/);if(!Y)return null;return{fileName:Y[1],oldFileName:Y[1],newFileName:Y[1],isCombined:!0}}function DS(Z){let Y=Z.split(`
|
|
660
|
+
`),Q=Y.findIndex((J)=>BM.test(J));if(Q===-1)return{body:Z,preamble:[]};return{body:Y.slice(Q).join(`
|
|
661
|
+
`),preamble:Y.slice(0,Q)}}var HM,BM,WS,qS,WM=null,qM=null;var kQ=_(()=>{G0();G0();Y6();LR();I0();R0();P0();B0();HM={bold:(Z)=>`\x1B[1m${Z}\x1B[22m`,italic:(Z)=>`\x1B[3m${Z}\x1B[23m`,underline:(Z)=>`\x1B[4m${Z}\x1B[24m`,dim:(Z)=>`\x1B[2m${Z}\x1B[22m`},BM=/^diff --(git|cc|combined)\b/,WS=/^diff --(git|cc|combined)\b/m,qS=/^\x1b\[[0-9;]*m/});function RM(Z){let Y=Z.trim();if(!Y)return()=>!1;if(Y==="*")return()=>!0;let Q=new RegExp(`^${MM(Y,{pathMode:!1})}$`);return(J)=>Q.test(J)}function PQ(Z){let Y=_S(Z);if(!Y)return null;let Q=new RegExp(`^${MM(Y,{pathMode:!0})}$`);return(J)=>Q.test(NS(J))}function _S(Z){let Y=c0(Z.trim());while(Y.startsWith("./"))Y=Y.slice(2);if(Y.startsWith("/"))Y=Y.slice(1);return Y=Y.replace(/\/+$/,""),Y}function NS(Z){let Y=c0(Z.trim());while(Y.startsWith("./"))Y=Y.slice(2);if(Y.startsWith("/"))Y=Y.slice(1);return Y=Y.replace(/\/+$/,""),Y}function MM(Z,Y){let{pathMode:Q}=Y,J="",X=0;while(X<Z.length){let K=Z[X];if(K==="*"){let z=Z[X+1];if(Q&&z==="*"){if(Z[X+2]==="/"){J+="(?:.*/)?",X+=3;continue}J+=".*",X+=2;continue}J+="[^/]*",X+=1;continue}if(K==="?"){J+=Q?"[^/]":".",X+=1;continue}if(K==="/"){J+="/",X+=1;continue}J+=K.replace(/[.+^${}()|[\]\\]/g,"\\$&"),X+=1}return J}var Sz=()=>{};import n0 from"path";async function _M(Z){let Y=[],Q=!1;try{let X=(await $0()).get("parallel.init","submodule,env"),K=DM(X);if(K.invalid.length>0)Y.push(`Unknown parallel.init values: ${K.invalid.join(", ")}. Valid values: submodule, env, pkg.`);let z=DM(Z.noInitList);if(z.invalid.length>0)Y.push(`Unknown --no-init values: ${z.invalid.join(", ")}. Valid values: submodule, env, pkg.`);if(Z.noInitAll||Z.noInitList==="")Q=!0;let H=new Set(z.values),W=K.values.filter((q)=>!H.has(q));if(W.length===0)Q=!0;if(!Q&&W.includes("submodule")){let q=b0({message:"Initializing git submodules..."});try{await GF(Z.git$,Z.worktreePath),q.stop()}catch(G){q.stop(),Y.push(`Submodule init failed. ${u(G,{color:!0})}`)}}if(!Q&&W.includes("env")){let q=await LS(Z.worktreePath,Z.originPath,Y);Y.push(...q.warnings)}if(!Q&&W.includes("pkg")){let q=await TS(Z.worktreePath);Y.push(...q.warnings)}}catch(J){Y.push(`Init failed. ${u(J,{color:!0})}`)}wS(Y)}function wS(Z){for(let Y of Z)R.warn(Y,"worktree-init")}function DM(Z){let Y=[],Q=[],J=new Set,X=[];if(Array.isArray(Z))X=Z.map((K)=>String(K));else if(typeof Z==="string")X=Z.split(",");else if(Z!=null)X=[String(Z)];for(let K of X){let z=K.trim().toLowerCase();if(!z)continue;if(jS.has(z)){let H=z;if(!J.has(H))Y.push(H),J.add(H)}else Q.push(z)}return{values:Y,invalid:Q}}async function TS(Z){let Y=[],Q=!1,J=xS(Z,Y);if(J){let X=await PS(J,Z,Y);Q||=X}if(kS(Z)){let X=await vS(Z,Y);Q||=X}return{ran:Q,warnings:Y}}async function LS(Z,Y,Q){let J=[],X=0;try{let K=await $0(),z=Y||Z,{rootFiles:H,envPaths:W}=await IS(z,K,J);if(H.length===0&&W.length===0)return{copied:0,warnings:J};if(H.length>0){let q=H.map((U)=>RM(U)),G=await AS(z,J);for(let U of G){if(!U)continue;if(q.some((B)=>B(U))){if(await NM({sourceRoot:z,targetRoot:Z,relativePath:U,warnings:J}))X++}}}if(W.length>0)X+=await ES({sourceRoot:z,targetRoot:Z,patterns:W,warnings:J})}catch(K){J.push(`Env init failed. ${u(K,{color:!0})}`)}return Q.push(...J),{copied:X,warnings:J}}async function IS(Z,Y,Q){let J=new Set,X=new Set,K=n0.join(Z,".gitignore");if(l(K))try{let W=(await l0(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 U=G.startsWith("/")?G.slice(1):G;if(U.includes("/"))continue;J.add(U)}}catch(H){Q.push(`Failed to read .gitignore. ${u(H,{color:!0})}`)}let z=Y.get("parallel.envPaths","");if(typeof z==="string"){let H=z.split(":").map((W)=>W.trim()).filter((W)=>W.length>0);for(let W of H)X.add(W)}return{rootFiles:Array.from(J),envPaths:Array.from(X)}}async function AS(Z,Y){try{return(await EY(Z,{withFileTypes:!0})).filter((J)=>J.isFile()).map((J)=>J.name)}catch(Q){return Y.push(`Failed to list root files. ${u(Q,{color:!0})}`),[]}}async function NM(Z){let{sourceRoot:Y,targetRoot:Q,relativePath:J,warnings:X}=Z;if(n0.resolve(Y)===n0.resolve(Q))return!1;let K=vQ(Y,J),z=vQ(Q,J);if(!l(K))return!1;if(l(z))return!1;try{if(!(await s6(K)).isFile())return!1;await NZ(n0.dirname(z),{recursive:!0});let W=await l0(K);return await _6(z,W),!0}catch(H){return X.push(`Failed to copy env file '${J}'. ${u(H,{color:!0})}`),!1}}async function CS(Z){let{sourceRoot:Y,targetRoot:Q,relativePath:J,warnings:X}=Z;if(n0.resolve(Y)===n0.resolve(Q))return!1;let K=vQ(Y,J),z=vQ(Q,J);if(!l(K))return!1;if(l(z))return!1;try{if(!(await s6(K)).isDirectory())return!1;return await jM(K,z,X),!0}catch(H){return X.push(`Failed to copy env directory '${J}'. ${u(H,{color:!0})}`),!1}}async function jM(Z,Y,Q){try{await NZ(Y,{recursive:!0});let J=await EY(Z,{withFileTypes:!0});for(let X of J){let K=n0.join(Z,X.name),z=n0.join(Y,X.name);if(X.isDirectory())await jM(K,z,Q);else if(X.isFile()){let H=await l0(K);await _6(z,H)}}}catch(J){Q.push(`Failed to copy env directory. ${u(J,{color:!0})}`)}}async function ES(Z){let{sourceRoot:Y,targetRoot:Q,patterns:J,warnings:X}=Z;if(J.length===0)return 0;let K=J.map((W)=>PQ(W)).filter((W)=>Boolean(W));if(K.length===0)return 0;let z=0,H=async(W,q)=>{let G=[];try{G=await EY(W,{withFileTypes:!0})}catch(U){X.push(`Failed to read env paths. ${u(U,{color:!0})}`);return}for(let U of G){let B=q?`${q}/${U.name}`:U.name,F=K.some(($)=>$(B));if(F&&U.isDirectory()){if(await CS({sourceRoot:Y,targetRoot:Q,relativePath:B,warnings:X})){z++;continue}}if(F&&U.isFile()){if(await NM({sourceRoot:Y,targetRoot:Q,relativePath:B,warnings:X}))z++}if(U.isDirectory())await H(n0.join(W,U.name),B)}};return await H(Y,""),z}function vQ(Z,Y){let Q=Y.split("/").filter(Boolean);return n0.join(Z,...Q)}function xS(Z,Y){let Q=n0.join(Z,"package.json"),J=l(Q),X=n0.join(Z,"bun.lockb"),K=n0.join(Z,"bun.lock"),z=n0.join(Z,"pnpm-lock.yaml"),H=n0.join(Z,"package-lock.json"),W=n0.join(Z,"npm-shrinkwrap.json"),q=null;if(J){let G=SS(Q,Y);if(G)q=G}if(!q){if(l(X)||l(K))q="bun";else if(l(z))q="pnpm";else if(J&&(l(H)||l(W)))q="npm";else if(J)q="npm"}return q}function SS(Z,Y){try{let Q=$1(Z,"utf-8"),X=JSON.parse(Q).packageManager?.split("@")[0]?.trim().toLowerCase();if(X==="npm"||X==="pnpm"||X==="bun")return X;if(X)Y.push(`Unsupported packageManager '${X}' in package.json. Supported: npm, pnpm, bun.`)}catch(Q){Y.push(`Failed to parse package.json: ${u(Q,{color:!0})}`)}return null}function kS(Z){let Y=n0.join(Z,"uv.lock"),Q=n0.join(Z,"pyproject.toml");return l(Y)||l(Q)}async function PS(Z,Y,Q){if(!await J1(Z))return Q.push(`Package manager '${Z}' not found in PATH. Skipping install.`),!1;let X=E({cwd:Y,stdout:"inherit",stderr:"inherit"});try{if(Z==="npm")await X`npm install`;else if(Z==="pnpm")await X`pnpm install`;else await X`bun install`;return!0}catch(K){return Q.push(`Package install failed for '${Z}'. ${u(K,{color:!0})}`),!1}}async function vS(Z,Y){if(!await J1("uv"))return Y.push("Package manager 'uv' not found in PATH. Skipping install."),!1;let J=E({cwd:Z,stdout:"inherit",stderr:"inherit"});try{return await J`uv sync`,!0}catch(X){return Y.push(`Package install failed for 'uv'. ${u(X,{color:!0})}`),!1}}var jS;var wM=_(()=>{G0();Y6();P0();R0();F6();O6();Sz();jS=new Set(["submodule","pkg","env"])});import kz from"path";async function DY(Z){let{git$:Y,args:Q}=Z,J=Q[1]?.toLowerCase(),{match:X}=S0(J,["list","pardon"]),[K,z]=await Promise.all([E`${Y} rev-parse --abbrev-ref HEAD`.then((L)=>L.stdout.trim().replace(/\//g,"-")),G6(Y)]),H=kz.basename(z),W=H6,q=`${H}_${K}_backup_*.patch`,G=`${H}_${K}_backup_`,U=".patch";if(X==="list"){I(`${V("Cyan")}Project:${V()} ${H}`),I(`${V("Cyan")}Branch:${V()} ${K}`),I(`${V("Cyan")}Backup location:${V()} ${W}`),I(`${V("Cyan")}Use \`git clear pardon\` to restore the latest backup.${V()}
|
|
662
|
+
`),I(`${V("Cyan")}Looking for backup patch files matching:${V()} ${q}
|
|
663
|
+
`);let L=await TM(W,G,".patch");if(L.length===0)return I(`${V("Yellow")}No backup patch files found for project '${H}' on branch '${K}'.${V()}`),0;let x=new Date;for(let S=0;S<L.length;S++){let g=L[S],h=(x.getTime()-g.stats.mtime.getTime())/wZ,f=g.stats.mtime.toISOString().replace("T"," ").split(".")[0],v=V("Dim");if(g.stats.mtime.toDateString()===x.toDateString())v=V("White");else if(h>=6)v=V("Red");I(`${v}backup@${S}: ${f} - ${g.name}${V()}`)}return 0}let B=await TM(W,G,".patch"),F=new Date;F.setDate(F.getDate()-7);for(let L of B)if(L.stats.mtime<F)try{H9(L.path),B.splice(B.indexOf(L),1)}catch(x){R.error(`Failed to delete old backup file: ${L.path}
|
|
664
|
+
${u(x,{color:!0})}`,"clear")}if(X==="pardon"){if((await E`${Y} diff --cached --name-only`).stdout.length>0||(await E`${Y} 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 D0`${Y} status`,1;if(B.length===0)return R.error(`No backup patch file found for branch '${K}'. Pardon failed.`,"clear"),1;let S=B[0],g=new Date;if(g.setDate(g.getDate()-1),S.stats.mtime<g){if(R.warn("Latest backup patch file is older than 1 day. Do you want to proceed with the pardon? (y/n)","clear"),(await aZ("Type 'y' to confirm: ")).toLowerCase()!=="y")return R.error("Pardon aborted.","clear"),1}try{await D0`${Y} apply ${S.path}`,H9(S.path),I(`${V("Cyan")}Pardon applied successfully from backup: ${V("Bright")}${S.path}${V()}`),await D0`${Y} status`}catch(h){return R.error(`Failed to apply patch. Pardon aborted.
|
|
665
|
+
${u(h,{color:!0})}`,"clear"),1}return 0}let[$,O,D]=await Promise.all([E`${Y} diff --cached --name-only`.then((L)=>L.stdout.length>0),E`${Y} diff --name-only`.then((L)=>L.stdout.length>0),E`${Y} ls-files --others --exclude-standard`.then((L)=>L.stdout.length>0)]);if(!$&&!O&&!D)return I(`${V("Cyan")}No changes to clear. Working directory is clean.${V()}`),await D0`${Y} status`,0;let j=new Date().toISOString().replace(/[-:T.]/g,"").slice(0,14),M=`${H}_${K}_backup_${j}.patch`,T=kz.join(W,M);await D0`${Y} add -A`;let N=await E`${Y} diff --cached --binary`;return F1(T,N.stdout),I(`${V("Cyan")}Backup of all changes saved to: ${V("Bright")}${T}${V()}
|
|
666
|
+
${V("Cyan")}(\`git clear pardon\` to undo)${V()}`),await D0`${Y} reset --hard HEAD`,await D0`${Y} clean -fd`,await D0`${Y} status`,0}async function TM(Z,Y,Q){let X=f6(Z).filter((z)=>z.startsWith(Y)&&z.endsWith(Q));return(await Promise.all(X.map(async(z)=>{let H=kz.join(Z,z),W=await s6(H);return{name:z,path:H,stats:W}}))).sort((z,H)=>H.stats.mtime.getTime()-z.stats.mtime.getTime())}var LM,IM;var _Y=_(()=>{Y6();G0();P0();w0();B0();R0();B0();I0();A0();O6();LM={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
667
|
+
${Z+c("CLEAR",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
668
|
+
Safely backup and clear local working changes.
|
|
669
|
+
|
|
670
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
671
|
+
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 \`${Y}git reset --hard${Q}\` and \`${Y}git clean -fd${Q}\`. The latest patch is kept so you can restore it with \`${Y}${C} clear pardon${Q}\`.
|
|
672
|
+
|
|
673
|
+
${Z+c("SUBCOMMANDS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
674
|
+
- list: Show available backup patch files for this project/branch.
|
|
675
|
+
- pardon: Restore the most recent backup patch.
|
|
676
|
+
|
|
677
|
+
${Z+c("SAFETY",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
678
|
+
All files (tracked and untracked) are backed up before clearing. Pardon requires a clean working directory.
|
|
679
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Backup and clear local changes, with a restore (pardon) option.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
680
|
+
${Z}${C} clear ${Y}[list|pardon]${Q}
|
|
681
|
+
|
|
682
|
+
Examples:
|
|
683
|
+
${Z}${C} clear ${Q+Y}# Create backup patch and clear working tree${Q}
|
|
684
|
+
${Z}${C} clear list ${Q+Y}# Show recent backup patches${Q}
|
|
685
|
+
${Z}${C} clear pardon ${Q+Y}# Restore the latest backup patch${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},IM={$root:["list","pardon"]}});import q0 from"path";async function FZ(Z){let Y=await RZ(Z);if(!Y)return[];return yS(Y).map((Q)=>Q.alias).sort((Q,J)=>Q.localeCompare(J))}function yS(Z){if(!l(Z.parallelRoot))return[];let Y=f6(Z.parallelRoot,{withFileTypes:!0}),Q=[];for(let J of Y){if(!J.isDirectory())continue;let X=q0.join(Z.parallelRoot,J.name),K=Y8(X);if(!K)continue;Q.push({alias:K.alias||J.name,path:X})}return Q.sort((J,X)=>J.alias.localeCompare(X.alias))}function OZ(Z){if(!Z||Z.trim()==="")return!1;if(/[/\\ ]/.test(Z))return!1;if(/[<>:"|?*\x00-\x1f]/.test(Z))return!1;return!0}function Y8(Z){let Y=q0.join(Z,".git-parallel.json");try{let Q=$1(Y,"utf-8"),J=JSON.parse(Q);return R.debug(`Loaded parallel metadata from '${Y}': ${u(J)}`,"parallel"),J}catch{return null}}function h1(Z,Y){let Q=q0.join(Z,".git-parallel.json");F1(Q,JSON.stringify(Y,null,2),"utf-8")}function bM(Z,Y){Z.baseCommit=Y,Z.updatedAt=new Date().toISOString(),Z.joinCursor=void 0,Z.submoduleCursors=void 0}async function pS(Z){let Q=`${Array.isArray(Z)?Z.join(" "):Z}|${q0.resolve(process.cwd())}`;if(e4&&e4.cacheKey===Q){if(Date.now()<=e4.expiresAt)return e4.value;e4=null}let J=await G6(Z),K=(await I2(Z,"--show-superproject-working-tree")).trim()||null;if(!K){let H={repoRoot:J,superprojectPath:null,submodulePath:null};return e4={cacheKey:Q,value:H,expiresAt:Date.now()+bQ},H}let z={repoRoot:J,superprojectPath:K,submodulePath:c0(q0.relative(K,J))};return e4={cacheKey:Q,value:z,expiresAt:Date.now()+bQ},z}async function gQ(Z){let Y=Array.isArray(Z)?Z[0]:Z,Q=await pS(Z),J=Q.superprojectPath?[Y,"-C",Q.superprojectPath]:Z,X=await RZ(J);if(!X)throw Error("Not inside a git worktree.");return{gitExec:Y,repoRoot:Q.repoRoot,scopeGit$:J,parallelCtx:X,currentLabel:X.isParallelWorktree?X.alias||"origin":"origin",submodulePath:Q.submodulePath}}function vz(Z,Y){return Y==="origin"?Z.originPath:q0.join(Z.parallelRoot,Y)}async function dS(Z,Y,Q){if((await E`${Z} -C ${Y} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length===0)return!0;if(!Q)return!1;return await DY({git$:[Z,"-C",Y],args:new E1(["clear"])})===0}async function cS(Z,Y,Q){let J=["-c","protocol.file.allow=always","-C",Y,"submodule","update"];if(Q)J.push("--force");J.push("--init","--recursive"),await E`${Z} ${J}`}function lS(Z,Y,Q,J,X){if(X)return X;return Z.joinCursor=Q||J,h1(Y,Z),!1}function AM(Z,Y,Q,J){if(!J)Z.joinCursor=Q,h1(Y,Z);return!0}function CM(Z,Y,Q,J,X){if(!X)Z.submoduleCursors??={},Z.submoduleCursors[Q]=J,h1(Y,Z);return!0}async function EM(Z,Y,Q){try{return(await E`${Z} -C ${Y} config ${Q}`).stdout.trim()}catch{return""}}async function fM(Z,Y,Q,J){let[X,K]=await Promise.all([EM(Z,Y,"user.name"),EM(Z,Y,"user.email")]);if(X&&K)return[];let z=await hM(Z,Q,J),H=X||z.authorName,W=K||z.authorEmail;if(!H||!W)return[];return["-c",`user.name=${H}`,"-c",`user.email=${W}`]}async function RZ(Z){let Q=`${Array.isArray(Z)?Z.join(" "):Z}|${q0.resolve(process.cwd())}`;if(t4&&t4.cacheKey===Q){if(Date.now()<=t4.expiresAt)return t4.context;t4=null}try{let J=await G6(Z),X=q0.basename(J),K=Array.isArray(Z)?Z[0]:Z,z;try{z=(await N0(K,J,["--abbrev-ref","HEAD"])).trim()}catch{z="HEAD"}let H=q0.join(H6,"worktrees"),W=PH(H,J),q=X,G=z,U=null,B=J;if(W){let O=Y8(J);if(O){if(O.project)X=O.project;if(O.branch)z=O.branch;if(O.originPath)B=q0.resolve(O.originPath);if(O.alias)U=O.alias}else U=q0.basename(J);q=O?.safeProject||q,G=O?.safeBranch||G}q=G9(q),G=G9(G);let F=q0.join(H,q,G),$={repoRoot:J,projectName:X,branchName:z,safeProjectName:q,safeBranchName:G,parallelRoot:F,originPath:B,alias:U,isParallelWorktree:W};return t4={cacheKey:Q,context:$,expiresAt:Date.now()+bQ},$}catch(J){return R.error(u(J,{color:!0}),"parallel"),t4={cacheKey:Q,context:null,expiresAt:Date.now()+bQ},null}}async function yz(Z,Y){let Q=await RZ(Z);if(!Q)return 1;R.debug(`Removing worktree '${Y}'...`,"parallel");let J=q0.join(Q.parallelRoot,Y),X=Array.isArray(Z)?Z[0]:Z,K=b0({message:"Preparing worktree for removal..."});await uJ(Z);let z=await pJ(Z,J);if(!z&&!l(J))return K.stop(),R.error(`Worktree '${Y}' not found for branch '${Q.branchName}'.`,"parallel"),1;if(z?.locked){let G=z.lockReason?` (${z.lockReason})`:"";return K.stop(),R.error(`Worktree '${Y}' 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 E2(Z),!await pJ(Z,J))return K.stop(),I(`${V("Cyan")}Removed worktree metadata:${V()} ${Y}`),R.debug(`Worktree '${Y}' pruned successfully.`,"parallel"),0;return R.error(`Worktree '${Y}' is missing on disk and could not be pruned.`,"parallel"),1}try{yH(J,W9.F_OK|W9.W_OK)}catch{return K.stop(),R.error(`Worktree '${Y}' is not accessible or writable. Cannot remove.`,"parallel"),1}R.debug(`Worktree path '${J}' is accessible.`,"parallel");let H=await XF(Z,J);if(R.debug(`Active operations for worktree '${Y}': ${H.length>0?H.join(", "):"none"}`,"parallel"),H.length>0)return K.stop(),R.error(`Worktree '${Y}' has in-progress operations (${H.join(", ")}). Complete or abort them before removing.`,"parallel"),1;if((await E`${X} -C ${J} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0)return K.stop(),R.error(`Worktree '${Y}' has uncommitted changes. Join or clean it before removing.`,"parallel"),1;let q=await C1(Z,J);if(R.debug(`Submodules in worktree '${Y}': ${q.length>0?q.map((G)=>G.path).join(", "):"none"}`,"parallel"),q.length>0){let G=await qF(Z,J,q);if(G.length>0){let U=G.join(", ");return K.stop(),R.error(`Worktree '${Y}' has dirty submodules (${U}). Commit, stash, or clean them before removing.`,"parallel"),1}R.debug(`Deinitializing submodules for worktree '${Y}'...`,"parallel"),K.options.message="Deinitializing submodules...";try{R.debug(`Executing deinit for submodules with ${X} -C ${J}...`,"parallel"),await S2(Z,J)}catch(U){if(K.stop(),(await E`${X} -C ${J} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length===0)await E2(Z);return R.error(`Failed to deinit submodules for '${Y}'.
|
|
686
|
+
${u(U,{color:!0})}`,"parallel"),1}}K.options={...K.options,frames:["███","██▇","██▆","▇▅▆","▆▅▆","▃▅▅","▄▅▄","▃▃▁","▂▂▂","▁ ▁"," ","░ ","▓░ ","█▓░","██▓"],interval:120,message:`Removing worktree '${Y}'...`};try{R.debug(`Executing git worktree remove for '${Y}'...`,"parallel");let G=await E`${Z} worktree remove ${J}`;K.stop(),I(G.stdout.trim());try{R.debug(`Removing directory '${J}' (if exists)...`,"parallel"),O1(J,{recursive:!0,force:!0})}catch{R.warn(`Failed to remove directory '${J}', ignoring.`,"parallel")}return I(`${V("Cyan")}Removed worktree:${V()} ${Y}`),0}catch(G){if(K.stop(),R.debug(`Error removing worktree '${Y}': ${u(G,{color:!0})}`,"parallel"),(G instanceof P6?`${G.stderr||""} ${G.message||""}`:"").toLowerCase().includes("working trees containing submodules cannot be moved or removed"))return R.error(`Worktree '${Y}' contains submodules that must be deinitialized before removal.`,"parallel"),1;if(G instanceof P6&&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 '${Y}'.
|
|
687
|
+
${u(G,{color:!0})}`,"parallel");let B=await aZ("Do you want to force remove the worktree directory? (y/n): ");if(B.toLowerCase()==="y"||B.toLowerCase()==="yes")try{return O1(J,{recursive:!0,force:!0}),await E2(Z),I(`${V("Cyan")}Force removed worktree directory:${V()} ${Y}`),0}catch{return R.error(`Failed to force remove worktree directory '${Y}'.`,"parallel"),1}else return R.warn(`Aborted removing worktree '${Y}'.`,"parallel"),1}finally{K.stop()}}async function iS(Z,Y){let Q;try{Q=await gQ(Z)}catch(y){return R.error(u(y,{color:!0}),"parallel"),1}let{parallelCtx:J,scopeGit$:X}=Q;if(J.isParallelWorktree)return R.error("Run `git parallel fork` from the original worktree, not from a fork.","parallel"),1;if(J.branchName==="HEAD")return R.error("Detached HEAD detected. Switch to a branch before forking.","parallel"),1;if(Y.length<1)return R.error("Missing worktree alias.","parallel"),o0(),1;let K=Y[0];if(!OZ(K))return R.error(`Alias '${K}' contains invalid characters or spaces.`,"parallel"),1;let z=Y.slice(1),H=!1,W=null,q=z.hasOption("-b"),G=z.hasOption("-B");if(q&&G)return R.error("Use either '-b' or '-B' to create a branch, not both.","parallel"),o0(),1;let U=null,B=null;if(q)U=z.popValue("-b"),B="-b";else if(G)U=z.popValue("-B"),B="-B";if((q||G)&&!U)return R.error("Missing branch name for '-b'/'-B'.","parallel"),o0(),1;if(z.hasOption("--no-init")){if(W=z.popValue("--no-init",0,!0),W===null)H=!0}let F=q0.join(J.parallelRoot,K),$=z.includes("--move")||z.includes("-mv"),O=z.includes("--mirror")||z.includes("-mr"),D=z.filter((y)=>!["--move","--mirror","-mv","-mr"].includes(y)),j=D.filter((y)=>y.startsWith("-"));if(j.length>0)return R.error(`Unknown option '${j[0]}'.`,"parallel"),o0(),1;let M=D.filter((y)=>!y.startsWith("-"));if(M.length>1)return R.error("Too many refs provided. Specify a single ref after the alias.","parallel"),o0(),1;let T=M[0]||null;if(l(F)&&f6(F).length>0)return R.error(`Worktree alias '${K}' already exists for this branch.`,"parallel"),1;let N=q0.join(J.repoRoot,".git","info","exclude");try{if(!$1(N,"utf-8").includes(".git-parallel.json"))bH(N,`
|
|
688
|
+
.git-parallel.json
|
|
689
|
+
`)}catch{F1(N,`.git-parallel.json
|
|
690
|
+
`)}z6(J.parallelRoot,{recursive:!0});let L=Q.gitExec,x=(await N0(L,J.repoRoot,"HEAD")).trim();if(T){let y=(await I2(X,T)).trim();if(y)x=y}else if(U){let y=(await I2(X,U)).trim();if(y)x=y}let g=(await E`${X} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0,h=null,f=null;if(g&&($||O)){let y=`git-parallel:${K}`;try{if(O){let e=await E`${X} stash create --include-untracked`;await E`${X} stash store -m ${y} ${e}`,f="mirrored"}else if($)await E`${X} stash push --include-untracked -m ${y}`,f="moved";h="stash@{0}"}catch{return R.error("Failed to stash changes before forking.","parallel"),1}}try{let y=T||"HEAD";if(U&&B)await D0`${X} worktree add ${B} ${U} ${F} ${y}`;else await D0`${X} worktree add --detach ${F} ${y}`}catch{if(R.error("Failed to create the parallel worktree.","parallel"),h)await E`${X} stash pop ${h}`,I(`${V("Yellow")}Stashed changes restored to the origin worktree.${V()}`);return 1}if(h)try{await E`${X} -C ${F} stash apply --index ${h}`,await E`${X} stash drop ${h}`}catch{return R.error("Failed to move local changes into the new worktree.","parallel"),R.warn(`Your changes remain stashed as '${h}'. Apply them manually when ready.`,"parallel"),R.info(`Worktree path: ${F}`,"parallel"),1}let v=!1;if(U)v=!0;let d={alias:K,branch:J.branchName,safeBranch:J.safeBranchName,project:J.projectName,safeProject:J.safeProjectName,originPath:J.repoRoot,baseCommit:x,forkBranch:U||void 0,forkBranchTracked:v||void 0,createdAt:new Date().toISOString()};if(h1(F,d),I(`${V("Cyan")}Parallel worktree created:${V()} ${F}`),f)I(`${V("Cyan")}Pending changes ${f} to fork '${K}'.${V()}`);return await _M({git$:X,worktreePath:F,originPath:J.repoRoot,noInitAll:H,noInitList:W}),0}async function nS(Z,Y){let Q=await RZ(Z);if(!Q)return 1;let J=["-r","--recursive"],X=new Set,K=null;for(let W of Y){let q=W.toLowerCase();if(J.includes(q))X.add(q);else if(!K&&!W.startsWith("-"))K=W;else return R.error(`Unknown option '${W}'.`,"parallel"),o0(),1}let z=X.has("-r")||X.has("--recursive");if(z&&K)return R.error("Recursive remove does not accept an alias. Omit <alias> with -r.","parallel"),o0(),1;if(z&&Q.isParallelWorktree)return R.error("Run recursive remove from the origin worktree, not from a fork.","parallel"),1;if(z)return await oS(Z,Q);if(!K)return R.error("Missing worktree alias to remove.","parallel"),o0(),1;if(!OZ(K))return R.error(`Alias '${K}' contains invalid characters or spaces.`,"parallel"),1;let H=q0.join(Q.parallelRoot,K);if(q0.resolve(Q.repoRoot)===q0.resolve(H))return R.error("Cannot remove the worktree you are currently in. Switch to origin first.","parallel"),1;return await yz(Z,K)}async function oS(Z,Y){if(!l(Y.parallelRoot))return I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`),0;let J=f6(Y.parallelRoot,{withFileTypes:!0}).filter((X)=>X.isDirectory()).sort((X,K)=>X.name.localeCompare(K.name));if(J.length===0)return I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`),0;for(let X of J){let K=q0.join(Y.parallelRoot,X.name),H=Y8(K)?.alias||X.name,W=await yz(Z,H);if(W!==0)return W}return 0}async function xM(Z,Y,Q=!1){let J=await RZ(Z);if(!J)return 1;if(Y.length<1)return R.error("Missing target worktree alias or 'origin'.","parallel"),o0(),1;let X=Y[0],K;if(X.toLowerCase()==="origin"){if(!l(J.originPath))return R.error(`Origin worktree path not found at '${J.originPath}'.`,"parallel"),1;K=J.originPath}else{if(!OZ(X))return R.error(`Alias '${X}' contains invalid characters or spaces.`,"parallel"),1;if(K=q0.join(J.parallelRoot,X),!l(K))return R.error(`Worktree '${X}' not found for branch '${J.branchName}'.`,"parallel"),1;if(Y.includes("-c")||Y.includes("--copy"))return await j2(K),I(`${V("Cyan")}Worktree path copied to clipboard!${V()}`),0}if(Q)await sZ(K);else await e$(K);return 0}async function aS(Z,Y){let Q=await RZ(Z);if(!Q)return 1;let J=Array.isArray(Z)?Z[0]:Z,X=Y.includes("--short")||Y.includes("-s");I(`${V("Cyan")}Project:${V()} ${Q.projectName}`),I(`${V("Cyan")}Branch:${V()} ${Q.branchName}`),I(`${V("Cyan")}Origin:${V()} ${Q.originPath}`);let K=Q.isParallelWorktree?Q.alias:"origin";if(I(`${V("Cyan")}Current:${V()} ${K} ${K!=="origin"?V("Dim")+'(use "origin" alias to refer to main worktree)'+V():""}
|
|
691
|
+
`),!l(Q.parallelRoot))return I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`),0;let H=f6(Q.parallelRoot,{withFileTypes:!0}).filter((q)=>q.isDirectory()).sort((q,G)=>q.name.localeCompare(G.name));if(H.length===0)return I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`),0;let W=!1;for(let q of H){let G=q0.join(Q.parallelRoot,q.name),U=Y8(G);if(!U){R.debug(`Skipping worktree at '${G}' due to missing or invalid metadata.`,"parallel");continue}let B=U?.alias||q.name,F=U.baseCommit?.trim(),$=U.joinCursor?.trim();W=!0;let O=F&&await fQ(J,G,F,$)?$:F,D=b0({message:`Gatering information for ${B}...`}),j=(await N0(J,Q.originPath,"HEAD")).trim(),M=j?[j]:[],T=X?3:void 0,[N,L,x,S]=await Promise.all([E`${Z} -C ${G} status --porcelain=v1 --untracked-files=normal`.then((Z0)=>Z0.stdout.trim()),Bk(Z,G,Q.originPath,O,j),O?lJ({gitExec:J,repoPath:G,range:`${O}..HEAD`,maxCount:T,formatTemplate:`${V("Yellow")}%h${V()} %s`,excludeRefs:M}):Promise.resolve({commits:[],totalCount:0,moreCount:0}),F?$k({git$:Z,gitExec:J,worktreePath:G,originPath:Q.originPath,baseCommit:F,maxCount:T,submoduleCursors:U.submoduleCursors},D):Promise.resolve({groups:[],totalCount:0})]),g=N.length>0,h=O?O.slice(0,7):"unknown",f=L.ahead,v=S.totalCount,d=f>0||v>0,y=v>0?`${f}+${v}`:`${f}`,e="";if(d&&L.behind>0)e=`${V("Yellow")}↑${y} ↓${L.behind}${V()}`;else if(d)e=`${V("Green")}↑${y}${V()}`;else if(L.behind>0)e=`${V("Red")}↓${L.behind}${V()}`;else e=`${V("Dim")}up-to-date${V()}`;let V0=Q.isParallelWorktree&&B===Q.alias?"●":"○",a0=g?`${V("Red")}dirty${V()}`:`${V("Green")}clean${V()}`,t=U.forkBranch?`${V("Dim")}(branch:${U.forkBranch})${V()}`:"",a=G;if(X){let Z0=W8(G,50,"mid",-1);a=a6(Z0,`file://${c0(G)}`)}if(D.stop(),I(`${V("Dim")}${V0}${V()} ${W8(B,18,"end")} ${D6(a0,7,{align:"center"})} ${V("Dim")}${h}${V()} ${K9(e,11)} ${a}${t?` ${t}`:""}`),F){if(S.groups.length>0){let Z0=[{label:`. ${V("Dim")}[main]${V()}`,commits:x.commits,totalCount:x.totalCount,moreCount:x.moreCount},...S.groups];Fk(Z0)}else if(x.totalCount>0)uM(" ",x.commits,x.moreCount)}}if(!W)I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`);return I(""),0}async function V4(Z,Y,Q,J){try{await E`${Z} -C ${Y} stash pop ${J}`,I(`${V("Yellow")}Stashed changes restored to fork '${Q}' due to cherry-pick failure.${V()}`)}catch(X){I(`${V("Yellow")}Please restore stash '${J}' manually from fork '${Q}'. Automatic pop failed.${V()}`),R.debug(u(X,{color:!0}),"parallel")}}async function sS(Z,Y,Q,J,X){if(I(`${V("Yellow")}Cherry-pick stopped at commit ${Q}. To resolve conflicts run:${V()}`),I(`${V("Cyan")}${` git -C "${Z}" cherry-pick ${Q}`}${V()}`),X.length>0){let z=X.map((H)=>H.includes(" ")?`"${H}"`:H).join(" ");I(`${V("Cyan")}${` git -C "${Z}" add -- ${z}`}${V()}`)}else I(`${V("Cyan")}${` git -C "${Z}" add -A`}${V()}`);if(I(`${V("Cyan")}${` git -C "${Z}" cherry-pick --continue`}${V()}`),I(`${V("Cyan")}${` ${C} parallel join ${Y}`}${V()}`),J)I(`${V("Dim")}Stashed changes from fork '${Y}' can be applied after join.${V()}`)}function rS(Z){if(!Z)return{action:"abort",key:"q"};return Z}async function hM(Z,Y,Q){let J=["%H","%an","%ae","%ad","%B"].join("%n"),K=(await E`${Z} -C ${Y} show -s --date=iso --format=${J} ${Q}`).stdout.split(`
|
|
692
|
+
`),[z,H,W,q,...G]=K,U=G.join(`
|
|
693
|
+
`).trimEnd();return{hash:z?.trim()||Q,authorName:H?.trim()||"unknown",authorEmail:W?.trim()||"unknown",authorDate:q?.trim()||"unknown",message:U.length>0?U:"(no message)"}}async function tS(Z){let{gitExec:Y,originRepoPath:Q,forkRepoPath:J,commit:X,spinner:K}=Z;if(K)K.options.message="Emulating cherry-pick...";let z=(await E`${Y} -C ${J} show --format= --no-color ${X}`).stdout;if(z.trim().length===0)return{diff:"",stat:"",isEmpty:!0,hasConflicts:!1,appliedPatch:!0};let H=q0.join(H6,"parallel-join-preview");z6(H,{recursive:!0});let W=vH(q0.join(H,"index-")),q=q0.join(W,"index"),G={...process.env,GIT_INDEX_FILE:q};try{await E({env:G})`${Y} -C ${Q} read-tree HEAD`;let U=!1,B,F,$;try{await E({env:G,input:z})`${Y} -C ${Q} apply --cached --3way --whitespace=nowarn`,U=!0}catch(x){B=NY(x)}if(!U)if(F=await Qk({gitExec:Y,originRepoPath:Q,patch:z,env:G}),F.applies)try{await E({env:G,input:z})`${Y} -C ${Q} apply --cached --whitespace=nowarn`,U=!0,B=void 0}catch(x){B=yQ(B,NY(x))}else try{await E({env:G})`${Y} -C ${Q} read-tree HEAD`,await E({env:G,input:z})`${Y} -C ${Q} apply --cached --whitespace=nowarn`,U=!0,B=void 0,F={applies:!0}}catch(x){B=yQ(B,yQ(F.conflictInfo,NY(x)))}let O=await Yk(Y,Q,G),D=yQ(O,B);if(!D&&!U&&F&&!F.applies){let x={...process.env,GIT_INDEX_FILE:q0.join(W,"index-conflict")};if($=await Jk({gitExec:Y,originRepoPath:Q,patch:z,env:x}),$&&$.files.length>0){let S=gM(z).length;D=$.files.length<S?$:void 0}}let j=!1;if(!D?.files?.length&&!U){if(j=await eS({gitExec:Y,originRepoPath:Q,forkRepoPath:J,commit:X}),j&&!D)if($?.files?.length)D=$;else{let x=Xk(z);if(x?.files?.length)D=x}}else if(D?.files?.length)j=!0;let M=!1;if(!D?.files?.length&&!U&&!j)M=await Zk({gitExec:Y,originRepoPath:Q,forkRepoPath:J,commit:X});let T=Boolean(D?.files?.length)||j||M;if(!U){let x=(await E`${Y} -C ${J} show --format= --no-color ${X}`).stdout,S=(await E`${Y} -C ${J} show --stat --format= --no-color ${X}`).stdout,g=T?"Patch does not apply cleanly to origin HEAD. Preview shows the original commit diff.":void 0;return{diff:x,stat:S,isEmpty:x.trim().length===0,hasConflicts:T,warning:g,appliedPatch:!1,conflictInfo:D}}let N=(await E({env:G})`${Y} -C ${Q} diff --cached --no-color`).stdout,L=(await E({env:G})`${Y} -C ${Q} diff --cached --stat --no-color`).stdout;return{diff:N,stat:L,isEmpty:N.trim().length===0,hasConflicts:T,appliedPatch:U,conflictInfo:D}}finally{O1(W,{recursive:!0,force:!0})}}async function eS(Z){let{gitExec:Y,originRepoPath:Q,forkRepoPath:J,commit:X}=Z;try{let K=(await N0(Y,J,`${X}^`)).trim();if(!K)return!1;let z=(await N0(Y,Q,"HEAD")).trim();if(!z)return!1;let H=(await E`${Y} -C ${Q} merge-tree ${K} ${z} ${X}`).stdout;return/^(<{7}| <{7})/m.test(H)}catch{return!1}}async function Zk(Z){let{gitExec:Y,originRepoPath:Q,forkRepoPath:J,commit:X}=Z;try{let K=(await N0(Y,J,`${X}^`)).trim();if(!K)return!1;let z=(await N0(Y,Q,"HEAD")).trim();if(!z)return!1;let H=(await E`${Y} -C ${J} show --name-only --format= ${X}`).stdout.trim();if(!H)return!1;let W=new Set(H.split(`
|
|
694
|
+
`).map((U)=>U.trim()).filter((U)=>U.length>0)),q=(await E`${Y} -C ${Q} diff --name-only ${K} ${z}`).stdout.trim();if(!q)return!1;return q.split(`
|
|
695
|
+
`).map((U)=>U.trim()).filter((U)=>U.length>0).some((U)=>W.has(U))}catch{return!1}}async function Yk(Z,Y,Q){let J="";try{J=(await E({env:Q})`${Z} -C ${Y} diff --cached --name-only --diff-filter=U`).stdout.trim()}catch{return}let X=J.split(`
|
|
696
|
+
`).map((z)=>z.trim()).filter((z)=>z.length>0);if(X.length===0)return;let K;try{let z=(await E({env:Q})`${Z} -C ${Y} diff --cached --cc --no-color`).stdout;K=Kk(z)}catch{K=void 0}if(K){if(!X.every((H)=>typeof K?.[H]==="number"))K=void 0}return{files:X,counts:K}}async function Qk(Z){let{gitExec:Y,originRepoPath:Q,patch:J,env:X}=Z;try{return await E({env:X,input:J})`${Y} -C ${Q} apply --check --whitespace=nowarn`,{applies:!0}}catch(K){return{applies:!1,conflictInfo:NY(K)}}}async function Jk(Z){let{gitExec:Y,originRepoPath:Q,patch:J,env:X}=Z,K=gM(J);if(K.length===0)return;let z=[],H={};for(let q of K)try{await E({env:X})`${Y} -C ${Q} read-tree HEAD`,await E({env:X,input:q.patch})`${Y} -C ${Q} apply --cached --3way --whitespace=nowarn`}catch(G){if(!z.includes(q.file))z.push(q.file);let B=NY(G)?.counts?.[q.file];if(typeof B==="number")H[q.file]=B}if(z.length===0)return;let W=z.every((q)=>typeof H[q]==="number");return{files:z,counts:W?H:void 0}}function gM(Z){let Y=[],Q=null,J=Z.split(`
|
|
697
|
+
`);for(let X of J){if(X.startsWith("diff --git ")){if(Q)Y.push(Q);Q={file:X.match(/diff --git a\/(.+?) b\/(.+)/)?.[2]?.trim()||"unknown",lines:[X]};continue}if(X.startsWith("diff --cc ")||X.startsWith("diff --combined ")){if(Q)Y.push(Q);Q={file:X.replace(/^diff --(?:cc|combined)\s+/,"").trim()||"unknown",lines:[X]};continue}if(Q)Q.lines.push(X)}if(Q)Y.push(Q);return Y.filter((X)=>X.lines.length>0).map((X)=>({file:X.file,patch:X.lines.join(`
|
|
698
|
+
`)}))}function NY(Z){let Y=[];if(typeof Z==="string")Y.push(Z);else if(Z instanceof P6)Y.push(Z.stderr,Z.stdout,Z.message,Z.shortMessage);else if(Z&&typeof Z==="object"){let H=Z;Y.push(H.stderr,H.stdout,H.message)}let Q=Y.map((H)=>pM(H)).filter(Boolean).join(`
|
|
699
|
+
`);if(!Q)return;let J=[],X={},K=Q.split(`
|
|
700
|
+
`);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);X[G]=(X[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 z=J.every((H)=>typeof X[H]==="number"&&X[H]>0);return{files:J,counts:z?X:void 0}}function yQ(Z,Y){if(!Z&&!Y)return;if(!Z)return Y;if(!Y)return Z;let Q=Z.files.length>0?Z.files:Y.files;if(Q.length===0)return Y.files.length>0?Y:void 0;let J=SM(Z,Q),X=SM(Y,Q);return{files:Q,counts:J??X}}function Xk(Z){let Y=[],Q=Z.split(`
|
|
701
|
+
`);for(let J of Q){if(J.startsWith("diff --git ")){let X=J.match(/diff --git a\/(.+?) b\/(.+)/);if(X){let K=X[2].trim();if(K&&!Y.includes(K))Y.push(K)}continue}if(J.startsWith("diff --cc ")){let X=J.slice(10).trim();if(X&&!Y.includes(X))Y.push(X);continue}if(J.startsWith("diff --combined ")){let X=J.slice(16).trim();if(X&&!Y.includes(X))Y.push(X)}}if(Y.length===0)return;return{files:Y}}function SM(Z,Y){if(!Z?.counts)return;return Y.every((J)=>typeof Z.counts?.[J]==="number")?Z.counts:void 0}function Kk(Z){let Y={},Q=null,J=Z.split(`
|
|
702
|
+
`);for(let X of J){if(X.startsWith("diff --cc ")){Q=X.slice(10).trim();continue}if(X.startsWith("diff --combined ")){Q=X.slice(16).trim();continue}if(X.startsWith("@@@")&&Q)Y[Q]=(Y[Q]||0)+1}return Y}function zk(Z){let{commitInfo:Y,stat:Q,warning:J,isEmpty:X,isSubmodule:K,submodulePath:z,conflictInfo:H}=Z,W=[];if(W.push(`Commit: ${Y.hash}`),W.push(`Author: ${Y.authorName} <${Y.authorEmail}>`),W.push(`Date: ${Y.authorDate}`),K&&z)W.push(`Scope: submodule ${z}`);W.push(""),W.push(...Y.message.split(`
|
|
703
|
+
`).map((U)=>` ${U}`));let q=Q.trimEnd().replace(/(\W)(\++)/g,`$1${V("Green")}$2${k0(Q0.overlay0)}`).replace(/(-+)/g,`${V("Red")}$1${k0(Q0.overlay0)}`);if(q.length>0)W.push(""),W.push(...q.split(`
|
|
704
|
+
`).map((U)=>` ${U}`));if(J)W.push(""),W.push(`Warning: ${V("Yellow")+V("Bright")}${J}${V("Normal")+k0(Q0.overlay0)}`);let G=Wk(H);if(G.length>0)W.push(""),W.push(...G);if(X)W.push(""),W.push(` Note: ${V("Blue")}No changes against origin. This commit will be skipped unless applied.${V("Normal")+k0(Q0.overlay0)}`);return W}function Hk(Z){let{isEmpty:Y,hasConflicts:Q}=Z;if(Y)return V("BgWhite")+V("Black")+V("Bright")+" EMPTY "+V()+k0(Q0.overlay0)+Q6(Q0.base);if(Q)return V("BgRed")+V("White")+V("Bright")+" CONFLICT "+V()+k0(Q0.overlay0)+Q6(Q0.base);return V("Green")+V("White")+V("Bright")+" CLEAN "+V()+k0(Q0.overlay0)+Q6(Q0.base)}function Wk(Z){if(!Z||Z.files.length===0)return[];let Y=["Conflicts:"],{files:Q,counts:J}=Z;if(J&&Q.every((K)=>typeof J?.[K]==="number")&&J){let K=Math.max(...Q.map((z)=>z.length));for(let z of Q){let H=J[z]??0,W=H===1?"conflict":"conflicts";Y.push(` ${K9(z,K)} | ${H} ${W}`)}return Y}for(let K of Q)Y.push(` ${K}`);return Y}async function kM(Z){let{gitExec:Y,originRepoPath:Q,forkRepoPath:J,commit:X,isSubmodule:K,submodulePath:z}=Z,H=b0({message:"Preparing cherry-pick preview..."}),W=await hM(Y,J,X),q=await tS({gitExec:Y,originRepoPath:Q,forkRepoPath:J,commit:X,spinner:H});H.stop();let G=zk({commitInfo:W,stat:q.stat,warning:q.warning,isEmpty:q.isEmpty,isSubmodule:K,submodulePath:z,conflictInfo:q.conflictInfo}),U=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=Hk({isEmpty:q.isEmpty,hasConflicts:q.hasConflicts}),F=q.diff.trimEnd(),$=F.length>0?[...G,"",F].join(`
|
|
705
|
+
`):G.join(`
|
|
706
|
+
`),O=await MY($,{statusText:B,actions:U});return rS(O)}async function PM(Z,Y){let Q=Array.isArray(Z)?Z[0]:Z;if(!(await N0(Q,Y,["-q","--verify","HEAD~1"])).trim())return R.error("No commit available to undo.","parallel"),!1;try{return await E`${Q} -C ${Y} reset --hard HEAD~1`,I(`${V("Cyan")}Undid last cherry-picked commit in ${Y}.${V()}`),!0}catch(X){return R.error("Failed to undo last cherry-picked commit.","parallel"),R.debug(u(X,{color:!0}),"parallel"),!1}}async function fQ(Z,Y,Q,J){if(!J)return!1;let X=(await N0(Z,Y,"HEAD")).trim();if(!X)return!1;try{return await E`${Z} -C ${Y} merge-base --is-ancestor ${Q} ${J}`,await E`${Z} -C ${Y} merge-base --is-ancestor ${J} ${X}`,!0}catch{return!1}}async function mM(Z,Y,Q,J){R.debug(`Joining worktree '${Q}'...`,"parallel");let{keep:X,bringAll:K,interactive:z}=J,H=z&&vJ();if(z&&!H)R.warn("Interactive join requires a TTY. Proceeding without --interactive.","parallel");let W=Y8(Y);if(!W)return R.error(`Missing metadata for worktree '${Q}'. Unable to join automatically.`,"parallel"),1;let q=q0.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 a=(await E`${Z} -C ${Y} remote`).stdout.trim(),Z0=a?a.split(`
|
|
707
|
+
`).map((Y0)=>Y0.trim()).filter((Y0)=>Y0.length>0):[];if(Z0.length>0)for(let Y0 of Z0)try{if((await E`${Z} -C ${Y} ls-remote --heads ${Y0} ${t}`).stdout.trim().length>0)return R.error(`Fork branch '${t}' exists on remote '${Y0}'. Use standard git commands to merge it.`,"parallel"),1}catch{}}}let G=b0({message:"Checking worktree status"}),U=Array.isArray(Z)?Z[0]:Z,[B,F,$]=await Promise.all([E`${Z} -C ${Y} status --porcelain=v1 --untracked-files=normal`,E`${Z} -C ${q} status --porcelain=v1 --untracked-files=normal`,N0(U,Y,"HEAD")]),D=B.stdout.trim().length>0;if(R.debug(`Fork worktree '${Q}' dirty status: ${D?"dirty":"clean"}`,"parallel"),D&&!K&&!X)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(F.stdout.trim().length>0&&K&&D)return G.stop(),R.error("Origin worktree has pending changes. Commit or stash them before joining.","parallel"),1;let M=W.baseCommit?.trim(),T=W.joinCursor?.trim();if(!M)return G.stop(),R.error("Fork metadata is missing base commit information. Unable to perform an automatic join.","parallel"),1;let N=await fQ(U,Y,M,T),L=N?T:M,x=(await N0(U,q,"HEAD")).trim(),S=null;if(D&&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 E`${Z} -C ${Y} stash push --include-untracked -m ${t}`,S="stash@{0}"}catch{return R.error("Failed to stash uncommitted changes before joining.","parallel"),1}}let g=$.trim(),h;R.debug(`Enumerating commits from fork '${Q}' since ${N?"join cursor":"base commit"} ${L}...`,"parallel"),G.options.message="Enumerating commits to join";try{let t=["-C",Y,"rev-list","--reverse",`${L}..${g}`];if(x)t.push("--not",x);let a=(await E`${U} ${t}`).stdout.trim();h=a?a.split(`
|
|
708
|
+
`).map((Z0)=>Z0.trim()).filter((Z0)=>Z0):[]}catch(t){if(S)await E`${Z} -C ${Y} stash pop ${S}`;return R.error("Unable to enumerate commits to join.","parallel"),R.debug(u(t,{color:!0}),"parallel"),1}let f=[],v=[],d=[],y=!1,e=!1;G.stop(),R.debug(`Found ${h.length} commit(s) to cherry-pick into origin.`,"parallel");let V0=0;while(V0<h.length){let t=h[V0];if(!t){V0++;continue}try{let a=!1,Z0=!1;if(H){let Y0=await kM({git$:Z,gitExec:U,originRepoPath:q,forkRepoPath:Y,commit:t,forkAlias:Q,isSubmodule:!1});if(Y0.action==="abort"){if(S)await V4(Z,Y,Q,S);return 1}if(Y0.action==="undo"){if(v.length===0){I(`${V("Yellow")}No commit to undo yet.${V()}`);continue}let _0=v.pop();if(_0===void 0)continue;if(!await PM(Z,q)){if(S)await V4(Z,Y,Q,S);return 1}if(f.length>0)f.pop();let O0=_0>0?h[_0-1]:L;W.joinCursor=O0,h1(Y,W),y=!1,V0=Math.max(_0,0);continue}if(Y0.action==="skip")Z0=!0;else if(Y0.action==="apply")a=!0}else a=!0;if(a){let Y0=await vM(Z,{originRepoPath:q,commit:t,contextLabel:"origin worktree",forkAlias:Q,stashRef:S,sourceRepoPath:Y});if(Y0==="applied")f.push(t),v.push(V0);if(Y0==="skipped"||Y0==="empty")y=AM(W,Y,t,y),e=!0;else y=lS(W,Y,t,L,y)}else if(Z0)y=AM(W,Y,t,y),e=!0}catch{if(S)await V4(Z,Y,Q,S);return 1}V0++}let a0=await C1(Z,Y);for(let t=0;t<a0.length;t++){let a=a0[t];G.start(),G.options.message=`Enumerating submodule commits ${t+1} of ${a0.length}`;let Z0=q0.resolve(Y,a.path),Y0=q0.resolve(q,a.path),_0=q0.join(Z0,".git"),T0=q0.join(Y0,".git");if(!l(Z0)||!l(Y0))continue;if(!l(_0)||!l(T0))continue;let O0=await iJ(U,Y,M,a.path);if(!O0)continue;let x0=W.submoduleCursors?.[a.path]?.trim(),s0=await fQ(U,Z0,O0,x0)?x0:O0,r0=[];try{let u0=(await N0(U,Z0,"HEAD")).trim(),g1=(await N0(U,Y0,"HEAD")).trim(),$4=g1?(await N0(U,Z0,["-q","--verify",`${g1}^{commit}`])).trim():"",p0=["-C",Z0,"rev-list","--reverse",`${s0}..${u0}`];if($4)p0.push("--not",$4);r0=await E`${U} ${p0}`.then((C6)=>C6.stdout.trim().split(`
|
|
709
|
+
`).map((n6)=>n6.trim()).filter((n6)=>!!n6))}catch(u0){if(G.stop(),R.error(`Unable to enumerate submodule commits for '${a.path}'.`,"parallel"),R.debug(u(u0,{color:!0}),"parallel"),S)await V4(Z,Y,Q,S);return 1}if(G.stop(),r0.length===0)continue;R.debug(`Found ${r0.length} commit(s) to cherry-pick for submodule '${a.path}'.`,"parallel");let R6=[],t0=!1,U1=0;while(U1<r0.length){let u0=r0[U1];if(!u0){U1++;continue}try{try{await E`${U} -c protocol.file.allow=always -C ${Y0} fetch ${Z0} ${u0}`}catch(p0){if(R.error(`Failed to fetch submodule commit ${u0} from '${a.path}'.`,"parallel"),R.debug(u(p0,{color:!0}),"parallel"),S)await V4(Z,Y,Q,S);return 1}let g1=!1,$4=!1;if(H){let p0=await kM({git$:Z,gitExec:U,originRepoPath:Y0,forkRepoPath:Z0,commit:u0,forkAlias:Q,isSubmodule:!0,submodulePath:a.path});if(p0.action==="abort"){if(S)await V4(Z,Y,Q,S);return 1}if(p0.action==="undo"){if(R6.length===0){I(`${V("Yellow")}No commit to undo yet.${V()}`);continue}let C6=R6.pop();if(C6===void 0)continue;if(!await PM(Z,Y0)){if(S)await V4(Z,Y,Q,S);return 1}if(d.length>0)d.pop();let F4=C6>0?r0[C6-1]:s0;W.submoduleCursors??={},W.submoduleCursors[a.path]=F4,h1(Y,W),t0=!1,U1=Math.max(C6,0);continue}if(p0.action==="skip")$4=!0;else if(p0.action==="apply")g1=!0}else g1=!0;if(g1){let p0=await vM(Z,{originRepoPath:Y0,commit:u0,contextLabel:`submodule ${a.path}`,forkAlias:Q,stashRef:S,sourceRepoPath:Z0});if(p0==="applied")d.push(u0),R6.push(U1);if(p0==="skipped"||p0==="empty")t0=CM(W,Y,a.path,u0,t0),e=!0;else if(!t0)W.submoduleCursors??={},W.submoduleCursors[a.path]=u0||s0,h1(Y,W)}else if($4)t0=CM(W,Y,a.path,u0,t0),e=!0}catch{if(S)await V4(Z,Y,Q,S);return 1}U1++}}if(S){R.debug(`Applying stashed uncommitted changes from fork '${Q}' to origin...`,"parallel");try{let Z0=(await E`${Z} -C ${Y} stash list`).stdout.trim().split(`
|
|
710
|
+
`)[0]?.split(":")[0]||S;await E`${Z} -C ${q} stash apply --index ${Z0}`,await E`${Z} -C ${Y} stash drop ${Z0}`}catch(t){R.error("Failed to apply uncommitted changes to the origin worktree.","parallel"),R.debug(u(t,{color:!0}),"parallel");try{await E`${Z} -C ${Y} stash pop ${S}`,I(`${V("Yellow")}Stashed changes restored to fork '${Q}' for safety.${V()}`)}catch(a){I(`${V("Yellow")}Please restore stash '${S}' manually from fork '${Q}'. Automatic pop failed.${V()}`),R.debug(u(a,{color:!0}),"parallel")}return 1}}if(f.length>0||d.length>0){if(I(`${V("Cyan")}Cherry-picked ${f.length} commit(s) into origin.${V()}`),d.length>0)I(`${V("Cyan")}Cherry-picked ${d.length} submodule commit(s) into origin.${V()}`)}else I(`${V("Cyan")}No new commits to cherry-pick. Origin was already up to date.${V()}`);if(!X&&!e&&(f.length>0||d.length>0)){if(R.debug(`Removing fork worktree '${Q}' after join...`,"parallel"),await yz(Z,Q)!==0)return R.warn(`Failed to remove fork '${Q}' after joining. Please remove it manually later.`),1;I(`${V("Cyan")}Fork '${Q}' merged and removed successfully.${V()}`)}else{if(!e)try{let t=(await N0(U,q,"HEAD")).trim();if(t)bM(W,t)}catch{}else W.updatedAt=new Date().toISOString();h1(Y,W),I(`${V("Cyan")}Fork '${Q}' merged into origin. Worktree kept at:${V()} ${Y}`)}return 0}async function qk(Z,Y,Q){if(!l(Y.parallelRoot))return I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`),0;let X=f6(Y.parallelRoot,{withFileTypes:!0}).filter((z)=>z.isDirectory()).sort((z,H)=>z.name.localeCompare(H.name));if(X.length===0)return I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`),0;let K=!1;for(let z of X){let H=q0.join(Y.parallelRoot,z.name),W=Y8(H);if(!W)continue;let q=W.alias||z.name;K=!0;let G=await mM(Z,H,q,{keep:Q,bringAll:!1,interactive:!1});if(G!==0)return G}if(!K)I(`${V("Yellow")}No forked worktrees found for this branch.${V()}`);return 0}async function Gk(Z,Y){let Q;try{Q=await gQ(Z)}catch($){return R.error(u($,{color:!0}),"parallel"),1}let{parallelCtx:J,scopeGit$:X}=Q,K=["--keep","--all","--interactive","-i","-r","--recursive"],z=new Set,H=null;for(let $ of Y){let O=$.toLowerCase();if(K.includes(O))z.add(O);else if(!H&&!$.startsWith("-"))H=$;else return R.error(`Unknown option '${$}'.`,"parallel"),o0(),1}let W=z.has("--keep"),q=z.has("--all"),G=z.has("--interactive")||z.has("-i"),U=z.has("-r")||z.has("--recursive");if(U&&q)return R.error("Recursive join does not support --all. Join forks individually.","parallel"),o0(),1;if(U&&G)return R.error("Recursive join does not support --interactive. Join forks individually.","parallel"),o0(),1;if(U&&H)return R.error("Recursive join does not accept an alias. Omit <alias> with -r.","parallel"),o0(),1;if(U&&J.isParallelWorktree)return R.error("Run recursive join from the origin worktree, not from a fork.","parallel"),1;if(U)return await qk(X,J,W);let B,F;if(H){if(J.isParallelWorktree&&J.alias===H)return R.error("Cannot join the fork you are currently in. Switch to origin or another fork first.","parallel"),1;if(!OZ(H))return R.error(`Alias '${H}' contains invalid characters or spaces.`,"parallel"),1;if(B=q0.join(J.parallelRoot,H),F=H,!l(B))return R.error(`Worktree '${H}' not found for branch '${J.branchName}'.`,"parallel"),1}else{if(Q.currentLabel==="origin")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;F=Q.currentLabel,B=vz(J,F)}return await mM(X,B,F,{keep:W,bringAll:q,interactive:G})}async function Uk(Z,Y){let Q;try{Q=await gQ(Z)}catch(O){return R.error(u(O,{color:!0}),"parallel"),1}let J=["--hard","-h"],X=new Set,K=null;for(let O of Y){let D=O.toLowerCase();if(J.includes(D))X.add(D);else if(!K&&!O.startsWith("-"))K=O;else return R.error(`Unknown option '${O}'.`,"parallel"),o0(),1}let z=X.has("--hard")||X.has("-h"),H=Q.parallelCtx,W,q;if(K){if(K==="origin")return R.error("Origin is already the synchronization source.","parallel"),1;if(!OZ(K))return R.error(`Alias '${K}' contains invalid characters or spaces.`,"parallel"),1;if(W=K,q=vz(H,W),!l(q))return R.error(`Worktree '${W}' not found for branch '${H.branchName}'.`,"parallel"),1}else{if(Q.currentLabel==="origin")return R.error("Run sync from inside a forked worktree, or specify which fork to sync.","parallel"),1;W=Q.currentLabel,q=H.repoRoot}let G=Y8(q);if(!G)return R.error(`Missing metadata for worktree '${W}'.`,"parallel"),1;let U=q0.resolve(G.originPath);if(!l(U))return R.error(`Origin worktree path not found at '${U}'.`,"parallel"),1;if(!await dS(Q.gitExec,q,z))return R.error(`Fork '${W}' has uncommitted changes. Re-run with --hard to clear them first.`,"parallel"),1;let F=(await N0(Q.gitExec,U,"HEAD")).trim();if(!F)return R.error("Unable to resolve origin HEAD for sync.","parallel"),1;try{if(G.forkBranch&&G.forkBranchTracked){let O=["-C",q,"merge","--no-edit","-X","theirs",F],D=await E`${Q.gitExec} ${O}`;A6(D)}else{let O=await E`${Q.gitExec} -C ${q} reset --hard ${F}`;A6(O)}}catch(O){A6(Z8(O));try{await E`${Q.gitExec} -C ${q} merge --abort`}catch{}return R.error(`Failed to sync fork '${W}' with origin.`,"parallel"),R.debug(u(O,{color:!0}),"parallel"),1}try{await cS(Q.gitExec,q,z)}catch(O){return R.error(`Failed to refresh submodules for '${W}' after sync.`,"parallel"),R.debug(u(O,{color:!0}),"parallel"),1}let $=(await N0(Q.gitExec,q,"HEAD")).trim()||F;return bM(G,$),h1(q,G),I(`${V("Cyan")}Fork '${W}' synchronized with origin.${V()}`),0}async function Vk(Z,Y){let Q;try{Q=await gQ(Z)}catch(G){return R.error(u(G,{color:!0}),"parallel"),1}if(Y.length<2)return R.error("Usage: gdx parallel pick <alias|origin> <commit> [commit...]","parallel"),o0(),1;let J=Y[0],X=Y.slice(1).filter((G)=>G.length>0);if(J!=="origin"&&!OZ(J))return R.error(`Alias '${J}' contains invalid characters or spaces.`,"parallel"),1;let K=vz(Q.parallelCtx,J),z=Q.parallelCtx.repoRoot;if(!l(K))return R.error(`Worktree '${J}' not found for branch '${Q.parallelCtx.branchName}'.`,"parallel"),1;if(q0.resolve(K)===q0.resolve(z))return R.error("Source and destination worktrees are the same.","parallel"),1;let H=Q.submodulePath?q0.resolve(K,Q.submodulePath):K,W=Q.repoRoot;if(!l(H))return R.error(`Submodule '${Q.submodulePath}' is not available in worktree '${J}'.`,"parallel"),1;let q=[];for(let G of X)try{let U=(await N0(Q.gitExec,H,["-q","--verify",`${G}^{commit}`])).trim();if(!U)return R.error(`Commit '${G}' was not found in '${J}'.`,"parallel"),1;q.push(U)}catch{return R.error(`Commit '${G}' was not found in '${J}'.`,"parallel"),1}if(Q.submodulePath)try{await E`${Q.gitExec} -c protocol.file.allow=always -C ${W} fetch ${H} ${q}`}catch(G){return R.error(`Failed to fetch commits from submodule '${Q.submodulePath}' in '${J}'.`,"parallel"),R.debug(u(G,{color:!0}),"parallel"),1}for(let G of q)try{let U=await fM(Q.gitExec,W,H,G),B=await E`${Q.gitExec} ${U} ${v2()} -C ${W} cherry-pick ${G}`;A6(B)}catch(U){if(await Pz(Q.gitExec,W,U,"parallel pick"))continue;return A6(Z8(U)),R.error(`Failed to cherry-pick commit ${G} from '${J}'.`,"parallel"),R.debug(u(U,{color:!0}),"parallel"),1}return I(`${V("Cyan")}Cherry-picked ${q.length} commit(s) from '${J}' into ${Q.currentLabel}.${V()}`),0}async function vM(Z,Y){let{originRepoPath:Q,commit:J,contextLabel:X,forkAlias:K,stashRef:z,sourceRepoPath:H}=Y;R.debug(`Cherry-picking commit ${J} into ${X}...`,"parallel");let W=v2(),q=Array.isArray(Z)?Z[0]:Z,G=H?await fM(q,Q,H,J):[];try{let U=await E`${q} ${G} ${W} -C ${Q} cherry-pick ${J}`;return A6(U),"applied"}catch(U){if(await Pz(Z,Q,U,X))return"empty";if(A6(Z8(U)),!await tZ(Z,Q))throw R.error(`Cherry-pick failed while applying commit ${J}.`,"parallel"),R.debug(u(U,{color:!0}),"parallel"),U;if(!vJ()){let $=await P2(Z,Q);throw await sS(Q,K,J,z,$),R.debug(u(U,{color:!0}),"parallel"),U}I(`${V("Yellow")}Cherry-pick paused due to conflicts while applying commit ${J}.${V()}`),I(`${V("Dim")}Resolve conflicts in ${X}, then choose to continue or abort.${V()}`);while(!0)switch((await aZ("Type c to continue, a to abort, s to skip (c|a|s): ")).toLowerCase()){case"s":case"skip":try{return await E`${q} ${G} ${W} -C ${Q} cherry-pick --skip`,R.debug(`Skipped commit ${J} for ${X}.`,"parallel"),"skipped"}catch(O){if(!await tZ(Z,Q))return"skipped";A6(Z8(O)),R.error(`Failed to skip commit ${J} for ${X}.`,"parallel"),R.debug(u(O,{color:!0}),"parallel");continue}case"c":case"continue":case"y":case"yes":try{await VF(Z,Q);let O=await E`${q} ${G} ${W} -C ${Q} cherry-pick --continue`;return A6(O),"applied"}catch(O){if(await Pz(Z,Q,O,X))return"empty";if(A6(Z8(O)),await tZ(Z,Q)){I(`${V("Yellow")}Cherry-pick still has conflicts. Resolve them and try again.${V()}`),R.debug(u(O,{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(u(O,{color:!0}),"parallel"),O}case"a":case"abort":case"n":case"no":try{let O=await E`${q} ${G} ${W} -C ${Q} cherry-pick --abort`;A6(O)}catch(O){throw A6(Z8(O)),R.error("Failed to abort cherry-pick.","parallel"),R.debug(u(O,{color:!0}),"parallel"),O}throw R.error(`Cherry-pick aborted while applying commit ${J}.`,"parallel"),U}}}async function Pz(Z,Y,Q,J){let X=await tZ(Z,Y);if(!(UF(Q)||X&&await BF(Z,Y)))return!1;if(!X)return R.debug(`Empty cherry-pick ignored for ${J}.`,"parallel"),!0;try{return await E`${Z} ${v2()} -C ${Y} cherry-pick --skip`,R.debug(`Skipped empty cherry-pick for ${J}.`,"parallel"),!0}catch(z){return A6(Z8(z)),R.error(`Failed to skip empty cherry-pick for ${J}.`,"parallel"),R.debug(u(z,{color:!0}),"parallel"),!1}}async function Bk(Z,Y,Q,J,X){let K=Array.isArray(Z)?Z[0]:Z;try{let[z,H]=await Promise.all([N0(K,Y,"HEAD").then((U)=>U.trim()),X!==void 0?Promise.resolve(X.trim()):N0(K,Q,"HEAD").then((U)=>U.trim())]),W=H;if(z===W)return{ahead:0,behind:0};let q=0,G=0;return await Promise.all([(async()=>{try{let B=(await E`${K} -C ${Y} rev-list --count ${J||W}..${z}`).stdout.trim();q=parseInt(B,10)||0}catch{q=0}})(),(async()=>{try{let U=(await E`${K} -C ${Y} rev-list --count ${z}..${W}`).stdout.trim();G=parseInt(U,10)||0}catch{G=0}})()]),{ahead:q,behind:G}}catch{return{ahead:0,behind:0}}}async function $k(Z,Y){let{git$:Q,gitExec:J,worktreePath:X,originPath:K,baseCommit:z,maxCount:H,submoduleCursors:W}=Z,q=await C1(Q,X);if(q.length===0)return{groups:[],totalCount:0};let G=[],U=0;for(let B of q){let F=q0.resolve(X,B.path),$=q0.resolve(K,B.path),O=q0.join(F,".git"),D=q0.join($,".git");if(!l(F)||!l(O))continue;if(Y)Y.options.message=`Collecting submodule '${B.path}'...`;let j=await iJ(J,X,z,B.path);if(!j)continue;let M=j,T=W?.[B.path];if(T){if(await fQ(J,F,j,T))M=T}let N=`${M}..HEAD`,L=l($)&&l(D)?(await N0(J,$,"HEAD")).trim():"",x=await lJ({gitExec:J,repoPath:F,range:N,maxCount:H,formatTemplate:`${V("Yellow")}%h${V()} %s`,excludeRefs:L?[L]:void 0});if(x.totalCount===0)continue;let S=`${B.path} ${V("Dim")}[submodule]${V()}`;G.push({label:S,commits:x.commits,totalCount:x.totalCount,moreCount:x.moreCount}),U+=x.totalCount}return{groups:G,totalCount:U}}function uM(Z,Y,Q){let J=[...Y];if(Q>0)J.push(`${V("Dim")}+${Q} more${V()}`);if(J.length===0)return;for(let X=0;X<J.length;X++){let z=X===J.length-1?"└─ ":"├─ ";I(`${V("Dim")}${Z}${z}${V()}${J[X]}`)}}function Fk(Z){if(Z.length===0)return;for(let Y=0;Y<Z.length;Y++){let Q=Z[Y],J=Y===Z.length-1,X=J?" └─ ":" ├─ ";I(`${V("Dim")}${X}${V()}${Q.label}`),uM(J?" ":" │ ",Q.commits,Q.moreCount)}}function pM(Z){if(!Z)return"";if(typeof Z==="string")return Z;if(Z instanceof Uint8Array)return new TextDecoder().decode(Z);return String(Z)}function yM(Z){let Y=pM(Z);if(!Y)return;I(Y,Y.endsWith(`
|
|
711
|
+
`)?"":`
|
|
712
|
+
`)}function A6(Z){yM(Z.stdout),yM(Z.stderr)}function Z8(Z){if(Z instanceof P6)return{stdout:Z.stdout,stderr:Z.stderr};let Y=Z;return{stdout:Y?.stdout,stderr:Y?.stderr}}async function bz(Z){let{git$:Y,args:Q}=Z;if(Q.length<2)return o0(),1;let J=Q[1].toLowerCase(),{match:X,candidates:K}=S0(J,["fork","list","open","switch","sync","pick","join","remove","help"]),z=Q.slice(2);switch(X){case"fork":return await iS(Y,z);case"remove":return await nS(Y,z);case"switch":if(!R1)return R.error("'git parallel switch' requires the shell integration. See readme for details."),1;return await xM(Y,z,!0);case"open":return await xM(Y,z);case"list":return await aS(Y,z);case"sync":return await Uk(Y,z);case"pick":return await Vk(Y,z);case"join":return await Gk(Y,z);case"help":return o0(),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 o0(),1}}function o0(){I(hQ.short+`
|
|
713
|
+
`+hQ.usage())}var bQ=1000,t4=null,e4=null,bS=async({git$:Z})=>{let Y=await FZ(Z);return GY(["origin",...Y],["-c","--copy"])},fS=async({git$:Z})=>{let Y=await FZ(Z);return GY(["origin",...Y],["-c","--copy"])},hS=async({git$:Z})=>{let Y=await FZ(Z);return{$allOf:["--keep","--all","-i","--interactive"],"-r":{$allOf:["--keep"]},"--recursive":{$allOf:["--keep"]},...GY(Y,["--keep","--all","-i","--interactive"])}},gS=async({git$:Z})=>{let Y=await FZ(Z);return GY(Y,["--hard","-h"])},mS=async({git$:Z})=>{let Y=await FZ(Z);return Xz(["origin",...Y])},uS=async({git$:Z})=>{let Y=await FZ(Z);return{"-r":{},"--recursive":{},...Xz(Y)}},hQ,dM;var mQ=_(()=>{Y6();G2();G0();P0();w0();R0();B0();I0();A0();kQ();O6();wM();b8();_Y();hQ={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
714
|
+
${Z+c("PARALLEL",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
715
|
+
Manage parallel (forked) worktrees for iterative development.
|
|
716
|
+
|
|
717
|
+
${Z+c("OVERVIEW",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
718
|
+
\`${Y}${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.
|
|
719
|
+
|
|
720
|
+
Additionally, \`${Y}${C} parallel fork${Q}\` can auto-initialize submodules,
|
|
721
|
+
copy ignored env files, and install dependencies using detected package managers (currently supports
|
|
722
|
+
npm, pnpm, bun, and uv) if configured (see \`${Y}parallel.init${Q}\` and
|
|
723
|
+
\`${Y}parallel.envPaths${Q}\` config for options), getting the fork ready for work in no time.
|
|
724
|
+
|
|
725
|
+
${Z+c("SUBCOMMANDS AND BEHAVIOR",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
726
|
+
- ${Y}fork <alias>${Q}: Creates a detached worktree in a safe temporary namespace. Use \`${Y}-b${Q}\` or \`${Y}-B${Q}\` to create a non-detached worktree that tracks a local branch. If pending changes exist and you run with \`${Y}--move${Q}\` or \`${Y}--mirror${Q}\`, changes will be moved/applied to the fork. Init behaviors (submodules, env file copy, packages) are controlled by config and \`${Y}--no-init${Q}\`.
|
|
727
|
+
- ${Y}join [<alias>] [--keep|--all|-i|--interactive]${Q}: Cherry-picks commits from the fork back into the origin worktree. \`${Y}--keep${Q}\` retains the fork and updates its base; \`${Y}--all${Q}\` also includes uncommitted changes. \`${Y}--interactive${Q}\` previews and lets you choose each commit before applying.
|
|
728
|
+
- ${Y}join -r|--recursive [--keep]${Q}: Joins every fork for the current branch back into origin. Recursive join does not allow \`${Y}--all${Q}\`.
|
|
729
|
+
- ${Y}sync [<alias>] [--hard|-h]${Q}: Synchronizes a fork with origin. Detached forks move to origin HEAD; branch-tracked forks merge origin into the fork and prefer origin changes on conflicts. \`${Y}--hard${Q}\` clears fork-local changes before syncing.
|
|
730
|
+
- ${Y}pick <alias|origin> <commit> [commit...]${Q}: Cherry-picks commits from another worktree into the current worktree. When run inside a submodule, it targets the same submodule path in the source worktree.
|
|
731
|
+
- ${Y}list${Q}: Lists forks for the current branch with status, base commit, divergence and recent commits. Use ${Y}--short${Q} for compact output.
|
|
732
|
+
- ${Y}remove <alias>${Q}: Removes the forked worktree and cleans up the directory.
|
|
733
|
+
- ${Y}remove -r|--recursive${Q}: Removes every fork for the current branch.
|
|
734
|
+
|
|
735
|
+
${Z+c("SAFETY AND NOTES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
736
|
+
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.
|
|
737
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Manage temporary forked worktrees: create, list, join, open and remove.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
738
|
+
${Z}${C} parallel fork ${Y}<alias> [ref] [-b|-B <branch>] [--move|--mirror] [--no-init[=submodule,env,pkg]]${Q}
|
|
739
|
+
${Z}${C} parallel list${Q}
|
|
740
|
+
${Z}${C} parallel open ${Y}<alias|origin> [-c|--copy]${Q}
|
|
741
|
+
${Z}${C} parallel switch ${Y}<alias|origin> [-c|--copy]${Q}
|
|
742
|
+
${Z}${C} parallel sync ${Y}[<alias>] [--hard|-h]${Q}
|
|
743
|
+
${Z}${C} parallel pick ${Y}<alias|origin> <commit> [commit...]${Q}
|
|
744
|
+
${Z}${C} parallel join ${Y}<alias> [--keep|--all|-i|--interactive]${Q}
|
|
745
|
+
${Z}${C} parallel join ${Y}-r|--recursive [--keep]${Q}
|
|
746
|
+
${Z}${C} parallel remove ${Y}<alias>${Q}
|
|
747
|
+
${Z}${C} parallel remove ${Y}-r|--recursive${Q}
|
|
748
|
+
|
|
749
|
+
Examples:
|
|
750
|
+
${Z}${C} parallel fork feature-x --move ${Q+Y}# Create fork and optionally move changes${Q}
|
|
751
|
+
${Z}${C} parallel fork feature-x deadbeef ${Q+Y}# Create fork from a ref${Q}
|
|
752
|
+
${Z}${C} parallel fork feature-x -b feature-x ${Q+Y}# Create fork on a local branch${Q}
|
|
753
|
+
${Z}${C} parallel fork feature-x -B feature-x ${Q+Y}# Recreate the fork branch${Q}
|
|
754
|
+
${Z}${C} parallel fork feature-x --no-init ${Q+Y}# Skip all init behaviors${Q}
|
|
755
|
+
${Z}${C} parallel fork feature-x --no-init=pkg ${Q+Y}# Skip package installs only${Q}
|
|
756
|
+
${Z}${C} parallel fork feature-x --no-init=env ${Q+Y}# Skip env file copy${Q}
|
|
757
|
+
${Z}${C} parallel list --short ${Q+Y}# Compact output with recent commits${Q}
|
|
758
|
+
${Z}${C} parallel sync feature-x --hard ${Q+Y}# Reset a fork to the latest origin state${Q}
|
|
759
|
+
${Z}${C} parallel pick origin deadbeef ${Q+Y}# Cherry-pick from origin into current worktree${Q}
|
|
760
|
+
${Z}${C} parallel join feature-x --all ${Q+Y}# Merge fork back into origin${Q}
|
|
761
|
+
${Z}${C} parallel join feature-x -i ${Q+Y}# Preview and pick commits${Q}
|
|
762
|
+
${Z}${C} parallel join -r ${Q+Y}# Merge all forks back into origin${Q}
|
|
763
|
+
${Z}${C} parallel remove -r ${Q+Y}# Remove all forks for this branch${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},dM={$root:{fork:["--move","--mirror","--no-init","-b","-B"],list:{},open:bS,switch:fS,sync:gS,pick:mS,join:hS,remove:uS,help:{}}}});async function Ok(){let Z=await $0(),Y=iM(S4),Q=[],J="";I(V("Dim")+`# GDX Configuration
|
|
764
|
+
# read from ${Z.getConfigPath()}
|
|
765
|
+
# (api keys stored separately)
|
|
766
|
+
`+V());for(let{key:X}of Y){let K=X.split("."),z=K.slice(0,-1).join("."),H=K[K.length-1];if(!Q.includes(z)){if(Q.length>0)J+=`
|
|
767
|
+
`;if(z){let D=CJ[z];if(J+=`${V("Magenta")+V("Bright")}[${z}]${V()}
|
|
768
|
+
`,D)J+=`${V("Dim")}# ${D.split(`
|
|
769
|
+
`).join(`
|
|
770
|
+
# `)}${V()}
|
|
771
|
+
`}Q.push(z)}let W=Z.get(X);if(W===void 0&&u1.includes(X))W=await Z.getSecure(X);let q=Z.isDefault(X),G=CJ[X]||"",U="",B=!1;switch(typeof W){case"boolean":U=u(W,{color:!0});break;case"number":U=u(W,{color:!0});break;case"string":if(H.toLowerCase().includes("key"))U=u(W8(W,20,"mid",-1),{color:!0});else U=u(W,{color:!0});break;case"undefined":case"object":if(W==null)B=!0,U=u(null,{color:!0});break;default:U=String(W)}let F=q?"":` ${V()+V("Yellow")+V("Italic")}[Modified]${V()+V("Dim")}`,$=G?` ${V("Dim")}#${F} ${G}${V()}`:"",O=B?`${V("Dim")}# ${V("Cyan")+H+V("White")} = ${U}${$}${V()}
|
|
772
|
+
`:`${V("Cyan")+H+V()} = ${U}${$}
|
|
773
|
+
`;if(Q[Q.length-1]==="")J=O+`
|
|
774
|
+
`+J;else J+=O}return I(J,""),0}async function Rk(Z){let Y=await $0(),Q=Z.args[1];if(!Q)return R.error("Missing configuration key","gdx-config"),1;let J=Y.get(Q);if(J===void 0&&u1.includes(Q))J=await Y.getSecure(Q);if(J===void 0)return R.warn(`Key '${Q}' is not set`,"gdx-config"),1;return I(String(J)),0}async function Mk(Z){let Y=await $0(),Q=Z.args[1],J=Z.args[2];if(!Q||J===void 0)return R.error("Usage: gdx gdx-config <key> <value>","gdx-config"),1;let X=Y.get(Q),K=J;if(Q==="useInlineSubmodule"){let H=["off","internal","all"];if(!H.includes(J))return R.error(`Expected one of ${H.join(", ")} for '${Q}', got '${J}'`,"gdx-config"),1}if(typeof X==="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(Array.isArray(X)){let H;try{H=JSON.parse(J)}catch{return R.error(`Expected a JSON array for '${Q}', got '${J}'. Example: ["**/*.foo"]`,"gdx-config"),1}if(!Array.isArray(H))return R.error(`Expected a JSON array for '${Q}', got '${J}'. Example: ["**/*.foo"]`,"gdx-config"),1;if(typeof X.find((q)=>q!=null)==="string"){if(H.some((G)=>typeof G!=="string"))return R.error(`Expected all array values for '${Q}' to be strings.`,"gdx-config"),1}K=H}else if(typeof X==="boolean")K=J.toLowerCase()==="true";await Y.set(Q,K),await Y.save();let z=Q.toLowerCase().includes("key")?W8(String(K),20,"mid",-1):K;return I(`${V("Green")}Configuration updated: ${Q} = ${z}${V()}`),0}async function fz(Z){let Y=Z.args[1]?.toLowerCase(),{match:Q}=S0(Y,["list","path"]);if(Q==="list"||!Y)return await Ok();else if(Q==="path"){let J=await $0();return I(J.getConfigPath()),0}else if(Z.args.length===2)return await Rk(Z);else if(Z.args.length===3)return await Mk(Z);else return I(U4(`${V("Cyan")}Usage:${V()}
|
|
775
|
+
gdx gdx-config list - List all configuration
|
|
776
|
+
gdx gdx-config path - Show config file path
|
|
777
|
+
gdx gdx-config <key> - Get configuration value
|
|
778
|
+
gdx gdx-config <key> <value> - Set configuration value`)),0}function iM(Z,Y=""){let Q=[];for(let J in Z){let X=Y?`${Y}.${J}`:J,K=Z[J];if(K!==null&&typeof K==="object"&&!Array.isArray(K))Q.push(...iM(K,X));else Q.push({key:X,value:K})}return Q}var cM,lM;var uQ=_(()=>{Zz();G0();F6();F2();w0();R0();B0();A0();I0();cM={long:()=>{let Z=V("Bright"),Y=V();return s(`
|
|
779
|
+
${Z+c("GDX-CONFIG",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
780
|
+
View and modify gdx configuration.
|
|
781
|
+
|
|
782
|
+
${Z+c("OVERVIEW",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
783
|
+
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.
|
|
784
|
+
|
|
785
|
+
${Z+c("COMMANDS",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
786
|
+
- list: Prints flattened configuration with defaults and modified markers.
|
|
787
|
+
- path: Prints the path to the active config file used by gdx.
|
|
788
|
+
- <key> [value]: Get or set a config key. When setting, types are coerced based on the existing default value where possible.
|
|
789
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"View or modify gdx configuration settings.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
790
|
+
${Z}${C} gdx-config list${Q}
|
|
791
|
+
${Z}${C} gdx-config path${Q}
|
|
792
|
+
${Z}${C} gdx-config ${Y}<key> [value]${Q}
|
|
793
|
+
|
|
794
|
+
Examples:
|
|
795
|
+
${Z}${C} gdx-config list ${Q+Y}# List all config keys and values${Q}
|
|
796
|
+
${Z}${C} gdx-config editor.code true ${Q+Y}# Set value for a key${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},lM={$root:["list","path"]}});async function sM(Z,Y={}){let Q=Y.normalFileCharCap??Dk,J=Y.noisyFileCharCap??_k,X=(Y.noisyPatterns||[...AJ]).map((v)=>PQ(v)).filter((v)=>Boolean(v));if(X.length===0)X.push(()=>!1);let[K,z,H,W,q]=await Promise.all([E`${Z} diff --cached --name-status -z -M`,E`${Z} diff --cached --numstat -z`,E`${Z} -c color.ui=never diff --cached --stat`,E`${Z} diff --cached --shortstat`,E`${Z} -c color.ui=never diff --cached --patch --no-ext-diff`]),G=Nk(K.stdout);if(G.length===0)return{hasChanges:!1,summary:""};let U=new Map;for(let v of G)if(v.oldPath)U.set(v.oldPath,v.path);let B=jk(z.stdout,U),F=wk(H.stdout),$=Tk(q.stdout),O=await Pk(),D=Ik(G,B,F,X),j=[],M=[],T=[],N=[],L=[],x=[];for(let v of D){if(v.category==="rename"){let V0=100-parseInt(v.status.slice(1),10),a0=isNaN(V0)?"":V0===0?"(identical content)":`(~${V0}% content drifted)`;T.push(`- ${v.oldPath||v.path} -> ${v.path} ${a0}`);continue}if(v.category==="binary"){let V0=v.binaryStat?`${v.binaryStat.beforeBytes} -> ${v.binaryStat.afterBytes} bytes`:"binary size unavailable";N.push(`- [${v.status}] ${v.path} (${V0})`);continue}let d=$.get(v.path)||(v.oldPath?$.get(v.oldPath):void 0);if(!d)continue;let y=v.category==="noisy",e=Ak(d,O,y?J:Q,y);if(e.whitespaceOnlyFile){L.push(`- ${v.path}: only whitespace-only changes were detected.`);continue}if(e.whitespaceOnlyHunksOmitted>0)x.push(`${v.path}: omitted ${e.whitespaceOnlyHunksOmitted} whitespace-only hunk(s).`);if(e.droppedLowImportanceHunks>0)x.push(`${v.path}: dropped ${e.droppedLowImportanceHunks} low-importance hunk(s) to fit budget.`);if(e.hardTrimmed)x.push(`${v.path}: noisy diff still exceeded budget and was hard-trimmed to ${J} chars.`);if(y)M.push(e.text);else j.push(e.text)}let S=W.stdout.trim(),g={normal:D.filter((v)=>v.category==="normal").length,noisy:D.filter((v)=>v.category==="noisy").length,binary:D.filter((v)=>v.category==="binary").length,rename:D.filter((v)=>v.category==="rename").length},h=D.map((v)=>{let d=v.category,y=v.status[0]!=="R"?v.status:"R",e=v.isBinary||v.added==null||v.deleted==null?"":`(+${v.added} -${v.deleted})`;return`- ${y} [${d}] ${v.path} ${y!=="R"?e:`(${v.status})`}`}),f=["<summary-help-text>","This summary includes trimmed diffs, file-level stats, and other metadata, constructed by analyzing raw git diff. Changes are classified into the following categories:","- normal: text files with typical changes","- noisy: text files that usually don't contain meaningful changes (e.g. lockfiles, minified files)","- binary: non-text files where content changes cannot be meaningfully summarized in text","- rename: files detected as renames/moves without content changes","</summary-help-text>","","<changes-overview>",S?`- shortstat: ${S}`:"- shortstat: (empty)",`- files: total=${D.length}, normal=${g.normal}, noisy=${g.noisy}, binary=${g.binary}, renames=${g.rename}`,"</changes-overview>","","<file-stats>",...h,"</file-stats>"];if(T.length>0)f.push("","<renames>",...T,"</renames>");if(N.length>0)f.push("","<binary-changes>",...N,"</binary-changes>");if(L.length>0)f.push("","<whitespace-only-changes>",...L,"</whitespace-only-changes>");if(j.length>0)f.push("","<normal-text-diffs>",...j,"</normal-text-diffs>");if(M.length>0)f.push("","<noisy-text-diffs>",...M,"</noisy-text-diffs>");if(x.length>0)f.push("","<system-notes>",...x.map((v)=>`- ${v}`),"</system-notes>");return{hasChanges:!0,summary:f.join(`
|
|
797
|
+
`)}}function Nk(Z){let Y=Z.split("\x00").filter((J)=>J.length>0),Q=[];for(let J=0;J<Y.length;){let X=Y[J++];if(!X)break;if(X.startsWith("R")||X.startsWith("C")){let z=Y[J++],H=Y[J++];if(!z||!H)break;Q.push({status:X,path:H,oldPath:z});continue}let K=Y[J++];if(!K)break;Q.push({status:X,path:K})}return Q}function jk(Z,Y){let Q=Z.split("\x00"),J=new Map;for(let X=0;X<Q.length;X++){let K=Q[X];if(!K)continue;let z=K.match(/^(-|\d+)\t(-|\d+)\t(.+)$/);if(!z)continue;let H=z[1],W=z[2],q=z[3],G=Y.get(q);if(G&&Q[X+1]===G)q=G,X+=1;J.set(q,{added:H==="-"?null:parseInt(H,10),deleted:W==="-"?null:parseInt(W,10),isBinary:H==="-"||W==="-"})}return J}function wk(Z){let Y=new Map,Q=Z.split(/\r?\n/);for(let J of Q){let X=J.match(/^\s*(.+?)\s+\|\s+Bin\s+(\d+)\s+->\s+(\d+)\s+bytes\s*$/);if(!X)continue;let K=X[1].trim(),z=parseInt(X[2],10),H=parseInt(X[3],10),W=rM(K);Y.set(W,{beforeBytes:z,afterBytes:H})}return Y}function rM(Z){if(Z.includes("{")&&Z.includes("=>")&&Z.includes("}")){let Y=Z.indexOf("{"),Q=Z.indexOf("}",Y);if(Q>Y){let J=Z.slice(0,Y),X=Z.slice(Q+1),z=Z.slice(Y+1,Q).split("=>");if(z.length===2){let H=z[1].trim();return`${J}${H}${X}`.trim()}}}if(Z.includes("=>")){let Y=Z.split("=>");return Y[Y.length-1].trim()}return Z}function Tk(Z){let Y=$Z(Z),Q=new Map;for(let J of Y){let X={path:J.newFileName,oldPath:J.oldFileName,headerLines:[],hunks:[]},K=null,z=0,H=0;for(let W of J.lines){if(W.type==="header"){if(X.hunks.length===0)X.headerLines.push(W.content);continue}if(W.type==="hunk"){let q=Lk(W.content);if(!q)continue;K={oldStart:q.oldStart,newStart:q.newStart,lines:[]},X.hunks.push(K),z=q.oldStart,H=q.newStart;continue}if(!K)continue;if(W.type==="context"){K.lines.push({type:"context",content:W.content,oldCursorStart:z,newCursorStart:H}),z+=1,H+=1;continue}if(W.type==="delete"){K.lines.push({type:"delete",content:W.content,oldCursorStart:z,newCursorStart:H}),z+=1;continue}if(W.type==="add")K.lines.push({type:"add",content:W.content,oldCursorStart:z,newCursorStart:H}),H+=1}Q.set(X.path,X)}return Q}function Lk(Z){let Y=Z.match(/^@@\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/);if(!Y)return null;return{oldStart:parseInt(Y[1],10),oldCount:Y[2]?parseInt(Y[2],10):1,newStart:parseInt(Y[3],10),newCount:Y[4]?parseInt(Y[4],10):1}}function Ik(Z,Y,Q,J){return Z.map((X)=>{let K=Y.get(X.path)||(X.oldPath?Y.get(X.oldPath):void 0),z=Q.get(X.path)||(X.oldPath?Q.get(X.oldPath):void 0)||Q.get(rM(X.path)),H=X.status.startsWith("R"),W=Boolean(K?.isBinary),q;if(H)q="rename";else if(W)q="binary";else if(kk(X.path,J))q="noisy";else q="normal";return{status:X.status,path:X.path,oldPath:X.oldPath,added:K?.added??0,deleted:K?.deleted??0,isBinary:W,binaryStat:z,category:q}})}function Ak(Z,Y,Q,J){if(Z.hunks.length===0){let U=hz(Z,[]);if(!J||U.length<=Q)return{text:U,whitespaceOnlyFile:!1,whitespaceOnlyHunksOmitted:0,droppedLowImportanceHunks:0,hardTrimmed:!1};return{text:U.slice(0,Q),whitespaceOnlyFile:!1,whitespaceOnlyHunksOmitted:0,droppedLowImportanceHunks:0,hardTrimmed:!0}}let X=[],K=0,z=!1;for(let U of Z.hunks){let B=Ck(U.lines,Y),F=B.some((j)=>j.nonWhitespaceChange),$=B.some((j)=>j.whitespaceOnlyChange);if(!F&&$){K+=1;continue}z||=F;let O=Ek(B),D=xk(O);for(let j of D){if(!j.some((N)=>N.type==="add"||N.type==="delete"))continue;let M=Sk(j),T=j.reduce((N,L)=>{if((L.type==="add"||L.type==="delete")&&L.nonWhitespaceChange)return N+1;return N},0);X.push({text:M,importance:T,size:M.length})}}if(!z)return{text:"",whitespaceOnlyFile:!0,whitespaceOnlyHunksOmitted:K,droppedLowImportanceHunks:0,hardTrimmed:!1};let H=0,W=[...X],q=hz(Z,W.map((U)=>U.text));if(q.length>Q&&W.length>0){let U=[...W].sort((B,F)=>{if(B.importance!==F.importance)return B.importance-F.importance;return F.size-B.size});while(q.length>Q&&W.length>0){let B=U.shift();if(!B)break;let F=W.indexOf(B);if(F===-1)continue;W.splice(F,1),H+=1,q=hz(Z,W.map(($)=>$.text))}}let G=!1;if(J&&q.length>Q)G=!0,q=q.slice(0,Q);return{text:q,whitespaceOnlyFile:!1,whitespaceOnlyHunksOmitted:K,droppedLowImportanceHunks:H,hardTrimmed:G}}function Ck(Z,Y){let Q=Z.map((J)=>({...J}));for(let J=0;J<Q.length;J++){if(Q[J].type!=="add"&&Q[J].type!=="delete")continue;let X=J;while(J<Q.length&&(Q[J].type==="add"||Q[J].type==="delete"))J+=1;let K=Q.slice(X,J),z=K.filter((G)=>G.type==="delete"),H=K.filter((G)=>G.type==="add"),W=Math.min(z.length,H.length);for(let G=0;G<W;G++){let U=z[G],B=H[G];if(oM(U.content,B.content,Y))U.whitespaceOnlyChange=!0,B.whitespaceOnlyChange=!0;else U.nonWhitespaceChange=!0,B.nonWhitespaceChange=!0}for(let G=W;G<z.length;G++)z[G].nonWhitespaceChange=!0;for(let G=W;G<H.length;G++)H[G].nonWhitespaceChange=!0;if(!K.some((G)=>G.nonWhitespaceChange)){let G=z.map((B)=>B.content).join(`
|
|
798
|
+
`),U=H.map((B)=>B.content).join(`
|
|
799
|
+
`);if(!oM(G,U,Y)){for(let B of z)B.nonWhitespaceChange=!0,B.whitespaceOnlyChange=!1;for(let B of H)B.nonWhitespaceChange=!0,B.whitespaceOnlyChange=!1}}J-=1}return Q}function oM(Z,Y,Q){if(Z===Y)return!1;if(!Q){let K=Z.replace(/\s+/g,""),z=Y.replace(/\s+/g,"");return K===z}let X=Q(Z,Y).filter((K)=>K.added||K.removed);if(X.length===0)return!1;return X.every((K)=>/^\s*$/.test(K.value))}function Ek(Z){let Y=new Set;for(let J=0;J<Z.length;J++){let X=Z[J];if(X.type==="context"){Y.add(J);continue}if(X.nonWhitespaceChange)Y.add(J)}for(let J=0;J<Z.length;J++){let X=Z[J];if(!(X.type==="add"||X.type==="delete")||!X.whitespaceOnlyChange)continue;let K=J;while(J<Z.length&&(Z[J].type==="add"||Z[J].type==="delete")&&Z[J].whitespaceOnlyChange)J+=1;let z=J-1,H=Z[K-1],W=Z[z+1],q=Boolean(H)&&(H.type==="add"||H.type==="delete")&&Boolean(H.nonWhitespaceChange),G=Boolean(W)&&(W.type==="add"||W.type==="delete")&&Boolean(W.nonWhitespaceChange);if(q)Y.add(K);if(G)Y.add(z);J-=1}let Q=[];for(let J of[...Y].sort((X,K)=>X-K))Q.push(Z[J]);return Q}function xk(Z){if(Z.length===0)return[];let Y=[],Q=[Z[0]];for(let J=1;J<Z.length;J++){let X=Z[J-1],K=Z[J],z=X.oldCursorStart+(X.type==="add"?0:1),H=X.newCursorStart+(X.type==="delete"?0:1);if(K.oldCursorStart!==z||K.newCursorStart!==H){Y.push(Q),Q=[K];continue}Q.push(K)}if(Q.length>0)Y.push(Q);return Y}function Sk(Z){if(Z.length===0)return"";let Y=Z[0].oldCursorStart,Q=Z[0].newCursorStart,J=Z.reduce((H,W)=>H+(W.type==="add"?0:1),0),X=Z.reduce((H,W)=>H+(W.type==="delete"?0:1),0),K=`@@ -${aM(Y,J)} +${aM(Q,X)} @@`,z=Z.map((H)=>{if(H.type==="context")return` ${H.content}`;if(H.type==="add")return`+${H.content}`;return`-${H.content}`});return[K,...z].join(`
|
|
800
|
+
`)}function aM(Z,Y){if(Y===1)return String(Z);return`${Z},${Y}`}function hz(Z,Y){return[...[`diff --git a/${Z.oldPath} b/${Z.path}`,...Z.headerLines],...Y].filter((X)=>X.length>0).join(`
|
|
801
|
+
`)}function kk(Z,Y){return Y.some((Q)=>Q(Z))}async function Pk(){return nM??=(async()=>{try{let Z=await Promise.resolve().then(() => (Cz(),Az));return Z.diffChars||Z.default?.diffChars||null}catch(Z){throw new o(`Failed to load diff module for whitespace-aware commit summary: ${o.from(Z).message}`,"DIFF_MODULE_LOAD_FAILED")}})(),await nM}var Dk=50000,_k=1000,nM=null;var tM=_(()=>{G0();P0();kQ();Sz();F2()});import vk from"path";import yk from"crypto";function eM(Z){return yk.createHash("sha256").update(Z).digest("hex").slice(0,16)}async function bk(Z){I("");let Y=b0({message:"learning this repo's commit style...",animateGradient:!0});try{let J=(await E`${Z} 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 Y.stop(),{guideline:null,historyCount:0};let X=J.slice(0,Math.min(10,J.length)),z=await(await qY()).generate({prompt:DR(X),temperature:0.2,reasoning:"medium"});return Y.stop(),{guideline:z.trim(),historyCount:X.length}}catch(Q){Y.stop();let J=o.from(Q);return R.warn(`Failed to learn commit guidelines: ${J.message}`,"commit"),R.debug(`LLM error details: ${J}`,"commit"),{guideline:null,historyCount:0}}}async function fk(Z,Y){let Q=await F0(),J=await C2(Z),X=await A2(Z),K=c0(J),z=Y.get("commit.guidelineCacheDays",30),H=z*24*60,W=X?eM(`remote:${X}`):"",q=eM(`path:${K}`),G=W?`commit.repoGuidelines.${W}`:"",U=`commit.repoGuidelines.${q}`;if(G){let j=await Q.get(G);if(j)return R.debug(`Using cached commit guidelines for remote ${X}`,"commit"),j}let B=await Q.get(U);if(B){if(G)await Q.set(G,B,{maxAgeMinutes:H}),R.debug(`Promoted commit guidelines cache to remote ${X}`,"commit");else R.debug(`Using cached commit guidelines for ${K}`,"commit");return B}let{guideline:F,historyCount:$}=await bk(Z);if(!F||$===0)return R.warn("No commit history found in this repository. Falling back to comprehensive format.","commit"),null;if($<5)R.warn(`Only ${$} commit(s) found in history. The learned guidelines may be less accurate.`,"commit");let O=G||U;await Q.set(O,F,{maxAgeMinutes:H});let D=G?`remote ${X}`:K;return R.debug(`Cached commit guidelines for ${D} (${z} days)`,"commit"),F}async function hk(Z){let{git$:Y,args:Q}=Z,J=Q.slice(2),X=J.popOption("--no-commit")!==null||J.popOption("-nc")!==null,K=J.popOption("--copy")!==null||J.popOption("-cp")!==null,z=J.popOption("--yes")!==null||J.popOption("-y")!==null,H=J.popOption("--preview")!==null,q=(J.popValue("--describe")||J.popValue("-d")||"").trim();if((Q.hasOption("--describe")||Q.hasOption("-d"))&&!q)R.warn("Ignoring --describe/-d because no description text was provided.","commit");let G=await $0(),U=G.get("llm.showThinking",!0),B=G.get("commit.commitPattern","inherit"),F=G.get("commit.noisyFiles",[]),$=Array.isArray(F)?F.filter((M)=>typeof M==="string"):[],O=b0({message:"compiling changes summary..."}),D=await sM(Y,{noisyPatterns:$});if(O.stop(),!D.hasChanges||D.summary.trim().length===0)return I(`${V("Red")}No staged changes found. Please stage your changes before generating a commit message.${V()}`),1;let j;if(B==="inherit"){let M=await fk(Y,G);if(M)j=MR(D.summary,M,q);else j=Yz(D.summary,q)}else j=Yz(D.summary,q);if(H)return I(j),0;I(`${V("Cyan")}Generating commit message based on staged changes...${V()}
|
|
802
|
+
`);try{let M=await qY(),T=b0({message:"connecting...",animateGradient:!1}),N=M.streamGenerate({prompt:j,temperature:0.14,reasoning:"low"}),L="",x=!1,S=!1,g="";for await(let d of N){if(d.error)return T.stop(),R.error(d.error.message+(d.error.cause?": "+d.error.cause:""),"commit"),R.debug(`LLM error details: ${o.from(d.error)}`,"commit"),1;if(d.thinkingChunk){if(!S){if(S=!0,T.options.animateGradient=!0,!U)T.options.message="reasoning..."}if(U)g=(g+d.thinkingChunk.replace(/[\n\r]/g,"")).slice(-32),T.options.message=`reasoning... ${g.trim()}`;continue}if(d.chunk){if(!x)x=!0,T.stop(),I(`${V("Cyan")}Generated Commit Message:${V()}`);I(d.chunk,""),L+=d.chunk}}if(!L)return I(`
|
|
803
|
+
`),R.error("Unable to generate commit message (empty response).","commit"),1;let h=L;L=L.replace(/(^\s*["'`]*|["'`]*\s*$)/g,"");let f=L.indexOf(`
|
|
804
|
+
`);if(f!==-1){let d=L.slice(0,f),y=L.slice(f+1).trim();L=d+`
|
|
805
|
+
|
|
806
|
+
`+s(y,72,{mode:"softboundary",redundancyLv:-1})}if(fY(h,L),I(""),X){if(z)R.warn("Ignoring --yes because --no-commit was requested.","commit");if(K)if(await j2(L))I(`${V("Cyan")}(message has been copied to clipboard)${V()}`);else R.warn("(failed to copy to clipboard)","commit");return 0}if(z){let d=L.split(/\n{2,}/).filter((e)=>e.trim().length>0),y=[];for(let e of d)y.push("-m",e);return await D0`${Y} commit ${y} ${J}`.catch(x6),0}let v=vk.join(H6,`gdx_commit_msg_${Date.now()}.txt`);return await _6(v,L,"utf8"),await D0`${Y} commit -F ${v} --edit ${J}`.catch(x6),await xY(v).catch(x6),0}catch(M){return R.error(u(M,{color:!0}),"commit"),1}}var ZD,YD;var gz=_(()=>{Y6();G0();P0();w0();eK();R0();Qz();B0();I0();A0();F6();I1();O6();tM();ZD={auto:hk},YD={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
807
|
+
${Z+c("COMMIT AUTO",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
808
|
+
Generate a commit message from staged changes using an LLM.
|
|
809
|
+
|
|
810
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
811
|
+
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.
|
|
812
|
+
|
|
813
|
+
${Z+c("FLAGS AND BEHAVIOR",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
814
|
+
Use ${Y}--no-commit (-nc)${Q} to prevent creating the commit (message will be printed). Use ${Y}--copy (-cp)${Q} in combination with --no-commit to copy the message to the clipboard. Use ${Y}--yes (-y)${Q} to commit immediately without writing a temporary message file or opening an editor (ignored when --no-commit is set). Use ${Y}--describe (-d) <text>${Q} to provide a short human summary of the change intent so the model can prioritize relevant diff sections. Use ${Y}--preview${Q} to print the complete generated prompt and exit (no LLM request, no commit). The tool writes a temporary message file when performing an interactive commit.
|
|
815
|
+
|
|
816
|
+
${Z+c("REQUIREMENTS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
817
|
+
A non-empty staged diff is required; the command will error if there are no staged changes.
|
|
818
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Auto-generate a commit message from staged changes using an LLM.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
819
|
+
${Z}${C} commit auto ${Y}[--no-commit|-nc] [--copy|-cp] [--yes|-y] [--describe|-d <text>] [--preview]${Q}
|
|
820
|
+
|
|
821
|
+
Examples:
|
|
822
|
+
${Z}${C} commit auto ${Q+Y}# Generate and commit using LLM-generated message${Q}
|
|
823
|
+
${Z}${C} commit auto --no-commit ${Q+Y}# Print generated message without committing${Q}
|
|
824
|
+
${Z}${C} commit auto --no-commit --copy ${Q+Y}# Copy generated message to clipboard${Q}
|
|
825
|
+
${Z}${C} commit auto --yes ${Q+Y}# Commit immediately without editing${Q}
|
|
826
|
+
${Z}${C} commit auto -d "refactor parser + trim noisy lockfile diffs" ${Q+Y}# Add extra context for the LLM${Q}
|
|
827
|
+
${Z}${C} commit auto --preview ${Q+Y}# Print full LLM prompt and exit${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}}});import gk from"path";async function mz(Z){let Y=Z.args[1]?.toLowerCase(),{match:Q,candidates:J}=S0(Y,["list","prune","reset","delete","disable","enable"]);switch(Q){case"list":return await uk();case"prune":return await mk();case"reset":return await pk();case"delete":return await dk(Z.args.slice(2));case"disable":return await QD(!1);case"enable":return await QD(!0);default:if(J&&J.length>0)R.warn(`Ambiguous command '${Y}'. Did you mean one of: ${J.join(", ")}?`);return I(pz.usage()),0}}async function mk(){let Z=null;try{Z=await uz()}catch(X){return R.error(u(X,{color:!0}),"cache"),1}if(!Z)return I(`${V("Yellow")}No valid cache found. Nothing to prune.${V()}`),0;let Y=Date.now(),Q=Object.entries(Z.entryMeta).filter(([,X])=>Y>X.expiresAt).map(([X])=>X),J=0;for(let X of Q)if(ck(Z,X))J++;if(Z.meta.lastPruneAt=Y,J>0)Z.meta.updatedAt=Y;if(await JD(Z),N2(),J>0)I(`${V("Green")}Pruned ${J} expired cache entries.${V()}`);else I(`${V("Cyan")}No expired cache entries found.${V()}`);return 0}async function uk(){let Z=null;try{Z=await uz()}catch(Q){return R.error(u(Q,{color:!0}),"cache"),1}if(!Z)return I(`${V("Yellow")}No valid cache found. Nothing to list.${V()}`),0;let Y=Object.keys(Z.entryMeta).sort((Q,J)=>{let X=Z.entryMeta[Q],K=Z.entryMeta[J];return(X?.expiresAt??0)-(K?.expiresAt??0)||Q.localeCompare(J)});if(Y.length===0)return I(`${V("Yellow")}No cache keys found.${V()}`),0;I(`${V("Cyan")}Cache:${V()} ${S6} ${V("Dim")}(${Y.length} keys)${V()}
|
|
828
|
+
`);for(let Q of Y){let J=Z.entryMeta[Q];if(!J)continue;let X=J.expiresAt-Date.now(),K=X<=0?"expired":J.expiresAt>=Number.MAX_SAFE_INTEGER?"N/A":z8.getTimeFromMS(X).modern(),z=V("Green");if(X<=0)z=V("Dim");else if(X<3600000)z=V("Red");else if(X<43200000)z=V("Yellow");let H=lk(Z.data,Q),W=ik(H);I(`${V("Cyan")}${D6(Q,24,{align:"left",redundancyLv:-1,overflow:"collapse"})}${V()} ttl=${z}${D6(K,12,{align:"left",redundancyLv:-1,overflow:"visible"})}${V()} ${V("Dim")}preview=${W}${V()}`)}return 0}async function pk(){try{let Z=l(S6);if(await CY(S6,{force:!0,recursive:!0}),N2(),!Z)return I(`${V("Yellow")}No valid cache found. Nothing to delete.${V()}`),0;let Y=l(S6)?`${V("Yellow")}Cache file not removed: ${S6}${V()}`:`${V("Green")}Cache file deleted: ${S6}${V()}`;return I(Y),0}catch(Z){return R.error(u(Z,{color:!0}),"cache"),1}}async function dk(Z){if(Z.length===0)return R.error("Usage: gdx cache delete <key|prefix> [more...]","cache"),1;let Y=null;try{Y=await uz()}catch(z){return R.error(u(z,{color:!0}),"cache"),1}if(!Y)return I(`${V("Yellow")}No valid cache found. Nothing to delete.${V()}`),0;let Q=Object.keys(Y.entryMeta),J=new Set;for(let z of Z){let H=z.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 I(`${V("Yellow")}No matching cache keys found.${V()}`),0;let X=Date.now(),K=0;for(let z of J){let H=Y.entryMeta[z];if(!H)continue;H.expiresAt=X-1,H.updatedAt=X,K++}if(K>0)return Y.meta.updatedAt=X,await JD(Y),N2(),I(`${V("Green")}Marked ${K} cache entries as expired.${V()}`),0;return I(`${V("Yellow")}No matching cache keys found.${V()}`),0}async function QD(Z){let Y=await $0();await Y.set("cache.enabled",Z),await Y.save();let Q=Z?"enabled":"disabled";return I(`${V("Green")}Cache ${Q}.${V()}`),0}async function uz(){try{let Z=await l0(S6,"utf-8"),Y=JSON.parse(Z);try{D2(Y)}catch{return null}if(!Y.meta.lastPruneAt)Y.meta.lastPruneAt=Y.meta.updatedAt||Date.now();return Y}catch(Z){if(o.from(Z).code==="ENOENT")return null;throw Z}}async function JD(Z){let Y=gk.dirname(S6);z6(Y,{recursive:!0}),await _6(S6,JSON.stringify(Z),"utf-8")}function ck(Z,Y){if(!Z.entryMeta[Y])return!1;delete Z.entryMeta[Y];let Q=Y.split("."),J=[],X=Z.data;for(let K of Q)if(X&&typeof X==="object"&&K in X)J.push({obj:X,key:K}),X=X[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:z,key:H}=J[K],W=z[H];if(W&&typeof W==="object"&&Object.keys(W).length===0)delete z[H];else break}return!0}function lk(Z,Y){let Q=Y.split("."),J=Z;for(let X of Q)if(J&&typeof J==="object"&&X in J)J=J[X];else return;return J}function ik(Z){if(typeof Z==="string")return`'${DZ(Z.replace(/\s+/g," "),60,"mid",-1)}'`;if(typeof Z==="number"||typeof Z==="boolean"||Z==null)return String(Z);if(Array.isArray(Z)){let Y=DZ(u(Z,{color:!1}),60,"mid",-1);return`[${Z.length}] ${Y}`}if(typeof Z==="object")return`{...} ${DZ(u(Z,{color:!1}),60,"mid",-1)}`;return DZ(String(Z),60,"mid",-1)}var pz,XD;var pQ=_(()=>{G0();I1();F6();B0();A0();I0();Y6();R0();w0();_2();pz={long:()=>{let Z=V("Bright"),Y=V();return s(`
|
|
829
|
+
${Z+c("CACHE",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
830
|
+
Manually manage gdx cache entries and settings.
|
|
831
|
+
|
|
832
|
+
${Z+c("COMMANDS",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
833
|
+
- list: Show cache keys, TTL, and a short value preview.
|
|
834
|
+
- prune: Remove expired entries from the cache file.
|
|
835
|
+
- reset: Delete the entire cache file.
|
|
836
|
+
- delete: Mark cache entries as expired by key or prefix.
|
|
837
|
+
- enable/disable: Toggle cache.enabled in gdx config.
|
|
838
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Manually manage gdx cache entries and settings.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
839
|
+
${Z}${C} cache prune${Q}
|
|
840
|
+
${Z}${C} cache reset${Q}
|
|
841
|
+
${Z}${C} cache list${Q}
|
|
842
|
+
${Z}${C} cache delete ${Y}<key|prefix> [more...]${Q}
|
|
843
|
+
${Z}${C} cache enable${Q}
|
|
844
|
+
${Z}${C} cache disable${Q}
|
|
845
|
+
|
|
846
|
+
Examples:
|
|
847
|
+
${Z}${C} cache list ${Q+Y}# List cached keys with TTL${Q}
|
|
848
|
+
${Z}${C} cache prune ${Q+Y}# Remove expired cache entries${Q}
|
|
849
|
+
${Z}${C} cache reset ${Q+Y}# Delete cache file entirely${Q}
|
|
850
|
+
${Z}${C} cache delete git git.config ${Q+Y}# Expire by key/prefix${Q}
|
|
851
|
+
${Z}${C} cache disable ${Q+Y}# Turn caching off${Q}
|
|
852
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},XD={$root:["list","prune","reset","delete","enable","disable"]}});var WD={};TY(WD,{spellCheckDocument:()=>nk,prettyFormatIssues:()=>ak,getBundledDictionaryNames:()=>ok});async function HD(){return KD??=import("cspell-lib"),await KD}async function nk(...Z){return await(await HD()).spellCheckDocument(...Z)}async function ok(){return zD??=(async()=>{let Y=await(await HD()).getDefaultBundledSettingsAsync(),Q=new Set,J=[],X=(K)=>{if(!K||Q.has(K))return;Q.add(K),J.push(K)};return Y.dictionaryDefinitions?.forEach((K)=>X(K.name)),Y.dictionaries?.forEach((K)=>X(K)),J})(),zD}function ak(Z,Y){if(Z.issues.length===0)return V("Green")+"✓ No spelling issues found!"+V();let Q=V("Yellow")+`✗ Found ${Z.issues.length} spelling issue${Z.issues.length===1?"":"s"}:
|
|
853
|
+
`+V();Q+=V("Dim")+"─".repeat(60)+`
|
|
854
|
+
|
|
855
|
+
`+V();let J=V("Cyan"),X=V("Magenta"),K=V("Red")+V("Bright"),z=V("Dim"),H=V("Underline");return Z.issues.forEach((W,q)=>{let G=Y.substring(0,W.line.offset),U=G.length-G.replace(/\n/g,"").length,B=W.offset-W.line.offset;Q+=`${z}${q+1}.${V()} ${J}Line ${U+1}${V()}, ${X}Col ${B+1}${V()}: ${K}"${W.text}"${V()}
|
|
856
|
+
`;let F=W.line.text;if(F){let $=W.offset-W.line.offset,O=F.substring(0,$),D=F.substring($+W.text.length);Q+=` ${O}${K+H}${W.text}${V()}${D}
|
|
857
|
+
`}if(W.suggestions?.length){let $=W.suggestions.slice(0,5).join(", ");Q+=` ${J}Suggestions:${V()} ${$}
|
|
858
|
+
`}if(q<Z.issues.length-1)Q+=`
|
|
859
|
+
`}),Q+=z+"─".repeat(60)+V()+`
|
|
860
|
+
`,Q}var KD=null,zD=null;var qD=_(()=>{G0()});async function dz(Z){let Q=P8().$,{git$:J}=Z;if(!await v8(J))return 1;let X=b0({message:"Initializing library..."}),{spellCheckDocument:K,prettyFormatIssues:z,getBundledDictionaryNames:H}=await Promise.resolve().then(() => (qD(),WD)),q=(await $0()).get("lint.maxFileSizeKb")||1024;X.options.message="Scanning commits...";let G="";try{let{stdout:j}=await Q`${J} rev-parse --abbrev-ref --symbolic-full-name @{u}`;G=j.trim()}catch{}let U="";if(G)U=`${G}..HEAD`;else X.stop(),R.warn("No upstream configured. Checking last commit only.","lint"),U="HEAD^..HEAD",X.start();let B=0,F=0,[$,O,D]=await Promise.all([Q`${J} log --pretty=format:"%s\n%b$$\$___SEP___\$$$" ${U}`.then((j)=>j.stdout).catch(()=>""),Q`${J} diff ${U}`.then((j)=>j.stdout).catch(()=>""),Q`${J} diff --name-only ${U}`.then((j)=>j.stdout).catch(()=>"")]);if($){X.options.message="Checking commit message spelling...";let j=await H(),M=$.split("$$$___SEP___$$$").filter((T)=>T.trim());for(let[T,N]of M.entries()){X.start(!1);let L=await K({uri:"commit-message",text:N,languageId:"plaintext",locale:"en"},{generateSuggestions:!0,noConfigSearch:!0,unknownWords:"report-common-typos"},{dictionaries:j});if(L.issues.length===0)continue;X.stop(),F+=L.issues.length,GD("Spelling",`At HEAD~${T} found ${L.issues.length} potential spelling issue(s) in commit messages.
|
|
861
|
+
|
|
862
|
+
`+z(L,N))}}if(X.stop(),O){let j="",M=O.split(/^diff --git a\/.+$/m);for(let T of M){let N=T.split(`
|
|
863
|
+
`).filter((L)=>L.trim());if(j=N.slice(2,4).find((L)=>L.startsWith("+++ b/"))?.split(" b/")[1]||"unknown",/\n?\+?<{7}(?:[^\n]*\n)*\+?={7}(?:[^\n]*\n)*\+?>{7}/.test(O))UD("Conflict Markers",`File: ${j}
|
|
864
|
+
Please resolve merge conflict markers.`),B++;for(let L=3;L<N.length;L++){let x=N[L];if(x.startsWith("+")){let S=x.substring(1);for(let g of oH)if(g.test(S))UD("Sensitive Content",`File: ${j}
|
|
865
|
+
Matched Pattern: ${g}
|
|
866
|
+
Content: ${S}`),B++}}}}if(D){let M=D.split(`
|
|
867
|
+
`).filter((N)=>N.trim()).map(async(N)=>{try{let{stdout:L}=await Q`${J} cat-file -s HEAD:${N}`,x=parseInt(L.trim(),10);return{file:N,sizeBytes:x}}catch{return null}}),T=await Promise.all(M);for(let N of T){if(!N)continue;let{file:L,sizeBytes:x}=N;if(x/1024>q)GD("Size",`File: ${L}
|
|
868
|
+
File size ${B6(x,2,1024)}B exceeds limit of ${q}KiB`),F++}}if(B>0)return R.error(`Lint failed with ${B} errors and ${F} warnings.`,"lint"),1;else if(F>0)return I(V("Yellow")+`
|
|
869
|
+
Lint passed with ${F} warnings.`+V()),0;else return I(V("Green")+`
|
|
870
|
+
No problems found.`+V()),0}function GD(Z,Y){Y=s(Y,100,{indent:" "}),I(V("BgYellow")+V("Bright")+V("White")+" LWARN "+V()+V("Invert")+` ${Z} ${V()+V("Yellow")} ${Y}`+V())}function UD(Z,Y){Y=s(Y,100,{indent:" "}),I(V("BgRed")+V("Bright")+V("White")+" LERROR "+V()+V("Invert")+` ${Z} ${V()+V("Red")} ${Y}`+V())}var VD,BD;var dQ=_(()=>{G0();P0();w0();F6();O6();B0();R0();A0();I0();VD={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
871
|
+
${Z+c("LINT",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
872
|
+
Runs a set of linting checks on your outgoing commits (or the last commit if no upstream is configured).
|
|
873
|
+
|
|
874
|
+
${Z+c("CHECKS PERFORMED",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
875
|
+
- Spelling: Checks for typos in commit messages using cspell.
|
|
876
|
+
- Sensitive Content: Scans for API keys, tokens, and private keys.
|
|
877
|
+
- Conflict Markers: Checks for leftover merge conflict markers.
|
|
878
|
+
- File Size: Warns if files exceed the configured size limit (default 1MB).
|
|
879
|
+
|
|
880
|
+
${Z+c("CONFIGURATION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
881
|
+
You can configure the behavior in your ~/.gdx/.gdxrc.toml file or \`${Y}${C} gdx-config${Q}\`:
|
|
882
|
+
[lint]
|
|
883
|
+
onPushBehavior = "off" | "error" | "warning" # Default: "off"
|
|
884
|
+
maxFileSizeKb = 1024 # Default: 1024 KB
|
|
885
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Lint outgoing commits for format, spelling, sensitive data, and more.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
886
|
+
${Z}${C} lint${Q}
|
|
887
|
+
|
|
888
|
+
Examples:
|
|
889
|
+
${Z}${C} lint ${Q+Y}# Run lint checks on outgoing commits${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},BD={$root:[]}});import cz from"path";async function sk(Z){try{let Q=(await E`${Z} config --file .gitmodules --get-regexp path`).stdout.trim();if(!Q)return[];let J=Q.split(`
|
|
890
|
+
`),X=[];for(let K of J){if(!K.trim())continue;let z=K.match(/^submodule\.(.+?)\.path\s+(.+)$/);if(z){let H=z[2];X.push({path:H,status:" "})}}return X}catch{return[]}}async function rk(Z,Y,Q){try{return(await E`${Z} -C ${Y} ${tk(Q)}`).stdout}catch(J){let X=o.from(J);return R.warn(`Failed to get status for submodule ${Y}.
|
|
891
|
+
Error: ${X.message}`,"status"),R.debug(`Failed to get status for submodule ${Y}.
|
|
892
|
+
${X.toString({color:!0})}`,"status"),""}}function tk(Z){let Y=["status",...Z];if(e0.supportsColor<=0)return Y;if(ek(Z)||ZP(Z)||YP(Z))return Y;return["-c","color.ui=always",...Y]}function ek(Z){return Z.some((Y)=>Y==="--no-color"||Y==="--color=never")}function ZP(Z){return Z.some((Y)=>Y==="--porcelain"||Y.startsWith("--porcelain="))}function YP(Z){return Z.some((Y)=>Y==="--color"||Y.startsWith("--color="))}async function lz(Z){let{git$:Y,args:Q}=Z;if(!(Q.includes("-r")||Q.includes("--recursive")))return await D0`${Y} status ${Q.slice(1)}`.then((K)=>K.exitCode??0);let X=Q.slice(1).filter((K)=>K!=="-r"&&K!=="--recursive");try{let K=await G6(Y),z=process.cwd();I(`${V("Cyan")}${V("Bright")}━━━ Repository Root${V()}${V("Dim")} (${cz.relative(z,K)||"."})${V()}
|
|
893
|
+
`),await D0`${Y} status ${X}`;let H=await sk(Y);if(H.length===0)return I(`
|
|
894
|
+
${V("Dim")}No submodules found.${V()}`),0;for(let W of H){let q=cz.resolve(K,W.path),G=cz.relative(z,q);I(`
|
|
895
|
+
${V("Cyan")}${V("Bright")}━━━ Submodule: ${W.path}${V()}${V("Dim")} (${G})${V()}
|
|
896
|
+
`);let U=await rk(Y,q,X);if(U)I(U);else I(`${V("Dim")}Unable to get status for this submodule.${V()}
|
|
897
|
+
`)}return 0}catch(K){return R.error(`Failed to get recursive status.
|
|
898
|
+
${K}`,"status"),1}}var $D,FD;var cQ=_(()=>{G0();P0();w0();B0();I0();R0();A0();O6();$D={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
899
|
+
${Z+c("STATUS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
900
|
+
Show the working tree status for the repository and optionally all submodules.
|
|
901
|
+
|
|
902
|
+
${Z+c("OVERVIEW",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
903
|
+
\`${Y}${C} status${Q}\` is a wrapper around \`${Y}git status${Q}\` with added support for recursive submodule status checking. When the \`${Y}--recursive${Q}\` or \`${Y}-r${Q}\` flag is used, it will show the status of the main repository followed by the status of each submodule.
|
|
904
|
+
|
|
905
|
+
${Z+c("RECURSIVE MODE",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
906
|
+
When \`${Y}--recursive${Q}\` or \`${Y}-r${Q}\` is specified:
|
|
907
|
+
- Shows status of the main repository first
|
|
908
|
+
- Then shows status for each submodule with clear headers
|
|
909
|
+
- Displays both absolute submodule paths and paths relative to your current directory
|
|
910
|
+
- All other \`${Y}git status${Q}\` flags are passed through to each status check
|
|
911
|
+
|
|
912
|
+
${Z+c("EXAMPLES",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
913
|
+
${Y}${C} status --recursive${Q}
|
|
914
|
+
Show status for repository and all submodules
|
|
915
|
+
|
|
916
|
+
${Y}${C} s -r${Q}
|
|
917
|
+
Same as above using shorthand
|
|
918
|
+
|
|
919
|
+
${Y}${C} status -r --short${Q}
|
|
920
|
+
Show short format status recursively
|
|
921
|
+
|
|
922
|
+
${Y}${C} status --recursive --porcelain${Q}
|
|
923
|
+
Show porcelain format status recursively
|
|
924
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Show working tree status with optional recursive submodule support",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
925
|
+
${Z}${C} status ${Y}[--recursive|-r] [<git-status-options>]${Q}
|
|
926
|
+
${Z}${C} s ${Y}[--recursive|-r] [<git-status-options>]${Q}
|
|
927
|
+
|
|
928
|
+
Examples:
|
|
929
|
+
${Z}${C} status --recursive ${Q+Y}# Show status for repo and all submodules${Q}
|
|
930
|
+
${Z}${C} s -r --short ${Q+Y}# Short format with submodules${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},FD={$root:{$allOf:["-r","--recursive","--short","--porcelain","--branch","--long"]}}});import iz from"fs";import Q8 from"path";async function nz(){let Z,Y=!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"),X=process.execPath.toLowerCase()!==process.argv[0].toLowerCase();if(!X){let W=process.argv[1],q=Q8.dirname(W),G=[Q8.join(q,"native/install.json"),Q8.join(q,"../dist/native/install.json"),Q8.join(q,"../native/install.json")];for(let U of G)if(iz.existsSync(U)){Z=U;break}if(!Z)Z=Q8.join(q,"native/install.json")}else Z=Q8.join(Q8.dirname(process.execPath),"install.json");let K=null;if(iz.existsSync(Z))try{let W=JSON.parse(iz.readFileSync(Z,"utf8"));K=u(W,{color:!0})}catch(W){let q=o.from(W);R.error(`Error reading install.json: ${q.message}`,"doctor"),R.debug(q.toString(),"doctor"),Y=!0}else if(X)R.warn(`No native install info found at ${Z}`,"doctor"),Y=!0;I(`Version: ${V("Cyan")+h6+V()}`),I(`Platform: ${V("Magenta")+process.platform} (${process.arch})`+V()),I(`Runtime: ${V("Magenta")+(J?"Bun":Q?"Node":"Unknown")+(X?" (Native)":"")+V()}`),I(`Terminal color support index: ${V("Cyan")+e0.supportsColor+V()+V("Dim")} ${e0.supportsColor===0?"(No color)":e0.supportsColor===1?"(16 colors)":e0.supportsColor===2?"(8bit color)":e0.supportsColor===3?"(24bit True color)":""}`+V()),I(`TTY mode: ${V("Cyan")+(process.stdout.isTTY?"Yes":"No")+V()}`);try{let W=await Q1("bun",["--version"]);I(`Bun: ${V("Cyan")+W.stdout.trim()+V()}`+(!J?V("Dim")+" (inactive)"+V():""))}catch{I("Bun: Not found")}try{let W=await Q1("node",["--version"]);I(`Node: ${V("Cyan")+W.stdout.trim()+V()}`+(!Q?V("Dim")+" (inactive)"+V():""))}catch{I("Node: Not found")}I(`Installation mode: ${X?V("Green")+"Native"+V():V("Yellow")+"Interpreted"+V()}`),I(`Executable path: ${V("Cyan")+process.execPath+V()}`),I(`Log file path: ${V("Cyan")+a6(R.logFile,R.logFile)+V()}`);let z=await F0();I(`Cache file path: ${V("Cyan")+a6(z.cachePath,z.cachePath)+V()}`);try{let W=await Q1("git",["--version"]);I(`Git: ${V("Cyan")+W.stdout.trim()+V()}`);let q=process.platform==="win32"?"where":"which",U=(await Q1(q,["git"])).stdout.trim().replaceAll(`
|
|
931
|
+
`,`
|
|
932
|
+
- `);I(`Git path: ${U?V("Green")+`
|
|
933
|
+
- `+U+V():"Not found in PATH"}`)}catch{I(V("Red")+"Git: Not found or error checking"+V()),Y=!0}let H=EH(process.env,(W)=>W.startsWith("GDX_")?null:void 0);if(I("Process argv: "+LH(process.argv,{color:!0,indent:2,maxCol:80})),I("GDX Environment Variables: "+u(H,{color:!0})),K)I(`
|
|
934
|
+
Native Install Info: ${V("Green")+K+V()}`);else{if(I(V("Bright")+`
|
|
935
|
+
Actionable next steps:`+V()),process.platform==="win32"&&process.arch==="x64")I("To use prebuilt binary:"),I(" GDX_USE_PREBUILT=1 npm i -g gdx");else I(`Prebuilt binary not supported for ${process.platform}/${process.arch}.`);I("To build locally (requires Bun):"),I(" GDX_BUILD_NATIVE=1 npm i -g gdx")}return Y?1:0}var OD,RD;var lQ=_(()=>{G2();G0();w0();R0();B0();A0();B0();I0();I1();OD={long:()=>{let Z=V("Bright"),Y=V();return s(`
|
|
936
|
+
${Z+c("DOCTOR",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
937
|
+
Diagnose installation and environment.
|
|
938
|
+
|
|
939
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Y}
|
|
940
|
+
Checks for native binary, runtimes, and provides installation guidance.
|
|
941
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Run a diagnostic check on gdx installation and environment.",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
942
|
+
${Z}${C} doctor${Q}
|
|
943
|
+
|
|
944
|
+
Examples:
|
|
945
|
+
${Z}${C} doctor ${Q+Y}# Diagnose installation and environment${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},RD={$root:[]}});import QP from"path";async function JP(Z){let Q=Z.args[2];if(!R1)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 C2(Z.git$),X=c0(Q).replace(/^\.\/+/,"").replace(/\/+$/,"");if(X==="main")return await sZ(J),0;let K=await C1(Z.git$,J);if(K.length===0)return R.error("No submodules found in this repository.","submodule"),1;let z=K.map((q)=>c0(q.path).replace(/\/+$/,"")),H=null;if(X&&!X.includes("/")){let q=z.filter((G)=>{let U=G.split("/");return U[U.length-1]===X});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}=S0(X,z);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: ${z.join(", ")}.`,"submodule"),1;let W=QP.resolve(J,H);if(!l(W))return R.error(`Submodule '${H}' is not initialized. Run 'git submodule update --init ${H}'.`,"submodule"),1;return await sZ(W),0}function XP(Z){let J=Z.replace(/\\/g,"/").replace(/\/+$/,"").replace(/\.git$/i,"").match(/([^/:]+)$/)?.[1]?.trim()||"";if(!J)throw Error(`Unable to derive submodule path from repository '${Z}'.`);return J}function oz(Z){let Y=Z.indexOf("--");if(Y===-1)return{head:Z.slice(),tail:[]};return{head:Z.slice(0,Y),tail:Z.slice(Y+1).toArray()}}function az(Z,Y){let Q=Z.find((J)=>J.startsWith("-"));if(Q)throw Error(`Unsupported option for 'submodule ${Y}': ${Q}`)}function KP(Z,Y){let{head:Q,tail:J}=oz(Z),X={quiet:Y};if(Q.popOption("-q")||Q.popOption("--quiet"))X.quiet=!0;if(Q.popOption("-f")||Q.popOption("--force"))X.force=!0;let K=Q.popAssertValue("--branch")||Q.popAssertValue("-b");if(K)X.branch=K;let z=Q.popAssertValue("--name");if(z)X.name=z;let H=Q.popAssertValue("--reference");if(H)X.reference=H;az(Q,"add");let W=[...Q.toArray(),...J];if(W.length===0)throw Error("'submodule add' requires <repository> [path].");if(W.length>2)throw Error("'submodule add' accepts at most two positional arguments.");let q=W[0],G=W[1]||XP(q);return{submoduleUrl:q,submodulePath:G,options:X}}function zP(Z,Y){let{head:Q,tail:J}=oz(Z),X={quiet:Y,init:!1,recursive:!1,strategy:"checkout"};if(Q.popOption("-q")||Q.popOption("--quiet"))X.quiet=!0;if(Q.popOption("--init"))X.init=!0;if(Q.popOption("--remote"))X.remote=!0;if(Q.popOption("-N")||Q.popOption("--no-fetch"))X.noFetch=!0;if(Q.popOption("-f")||Q.popOption("--force"))X.force=!0;if(Q.popOption("--checkout"))X.strategy="checkout";if(Q.popOption("--merge"))X.strategy="merge";if(Q.popOption("--rebase"))X.strategy="rebase";if(Q.popOption("--recommend-shallow"))X.recommendShallow=!0;if(Q.popOption("--no-recommend-shallow"))X.recommendShallow=!1;let K=Q.popAssertValue("--reference");if(K)X.reference=K;if(Q.popOption("--recursive"))X.recursive=!0;if(Q.popOption("--single-branch"))X.singleBranch=!0;if(Q.popOption("--no-single-branch"))X.singleBranch=!1;let z=Q.popAssertValue("--filter");if(z)X.filter=z;az(Q,"update");let H=[...Q.toArray(),...J];if(H.length>0)X.paths=H;return X}function HP(Z,Y){let{head:Q,tail:J}=oz(Z),X={quiet:Y,force:!1,all:!1};if(Q.popOption("-q")||Q.popOption("--quiet"))X.quiet=!0;if(Q.popOption("-f")||Q.popOption("--force"))X.force=!0;if(Q.popOption("--all"))X.all=!0;az(Q,"deinit");let K=[...Q.toArray(),...J];if(X.all&&K.length>0)throw Error("'submodule deinit' does not allow paths together with '--all'.");if(!X.all&&K.length===0)throw Error("'submodule deinit' requires '--all' or at least one path.");if(K.length>0)X.paths=K;return X}async function WP(){let Y=(await $0()).get("useInlineSubmodule","internal");if(Y==="off"||Y==="internal"||Y==="all")return Y;return"internal"}async function qP(Z,Y,Q){if(await WP()!=="all")return null;let X=await G6(Z.git$),K=Y[0];Y=Y.slice(1);try{if(K==="add"){let z=KP(Y,Q);return await WF(Z.git$,X,z.submoduleUrl,z.submodulePath,z.options),0}if(K==="update"){let z=zP(Y,Q);return await k2(Z.git$,X,z),0}if(K==="deinit"){let z=HP(Y,Q);return await S2(Z.git$,X,z),0}}catch(z){return R.error(z.message,"submodule"),1}return null}var MD,DD,_D;var iQ=_(()=>{G0();F6();B0();Y6();O6();I0();P0();R0();w0();A0();MD={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
946
|
+
${Z+c("SUBMODULE SWITCH",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
947
|
+
Jump into a submodule directory from the parent repository.
|
|
948
|
+
|
|
949
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
950
|
+
Resolve the target submodule by full path, unique prefix, or unique leaf name and then
|
|
951
|
+
schedule an auto-cd into it. Use "main" to jump back to the parent repository root.
|
|
952
|
+
Requires shell integration to change directories.
|
|
953
|
+
|
|
954
|
+
${Z+c("REQUIREMENTS",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
955
|
+
Shell integration must be enabled using ${Y}${C} --init${Q}.
|
|
956
|
+
Submodules must be initialized (use ${Y}git submodule update --init${Q}).
|
|
957
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Jump into a submodule directory (requires shell integration).",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
958
|
+
${Z}${C} submodule switch ${Y}<path|name|main>${Q}
|
|
959
|
+
|
|
960
|
+
Examples:
|
|
961
|
+
${Z}${C} submodule switch vendor/sdk ${Q+Y}# Switch by full path${Q}
|
|
962
|
+
${Z}${C} submodule switch sdk ${Q+Y}# Switch by unique name${Q}
|
|
963
|
+
${Z}${C} submodule switch main ${Q+Y}# Back to parent repo${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},DD={$root:{switch:{}}},_D={switch:JP,handleUserCommand:qP}});import ND from"path";async function GP(Z,Y){try{let{stdout:Q}=await E`${Z} rev-parse --verify ${Y}^{commit}`;return Q.trim()}catch{return null}}async function jD(Z,Y){let{stdout:Q}=await E`${Z} rev-list --parents -n 1 ${Y}`;return Q.trim().split(/\s+/).filter(Boolean).slice(1)}async function nQ(Z,Y){let{stdout:Q}=await E`${Z} show -s --format=%T ${Y}`;return Q.trim()}async function wD(Z,Y){let{stdout:J}=await E`${Z} show -s --format=${"%an%x00%ae%x00%aI"} ${Y}`,[X="",K="",z=""]=J.trimEnd().split("\x00");return{name:X,email:K,date:z}}async function UP(Z,Y){let Q=w2(Y),J=Q.shift();if(!J)throw new o("Editor is not configured.","EDITOR_NOT_CONFIGURED");let X=await J1(J);if(!X)throw new o(`Editor "${J}" not found in PATH.`,"EDITOR_NOT_FOUND");await D0`${X} ${Q} ${Z}`}async function VP(){let Z=await $0(),Y=Z.get("reword.editor",null),Q=Z.getAll().defaultEditor;if(Y&&Y.trim().length>0)return Y.trim();if(Q&&Q.trim().length>0)return Q.trim();throw new o("No editor configured.","EDITOR_NOT_CONFIGURED")}async function TD(Z){let{git$:Y,treeSha:Q,parents:J,messageFile:X,author:K}=Z,z=["commit-tree",Q,...J.flatMap((G)=>["-p",G]),"-F",X],H=E({env:{GIT_AUTHOR_NAME:K.name,GIT_AUTHOR_EMAIL:K.email,GIT_AUTHOR_DATE:K.date}}),{stdout:W}=await H`${Y} ${z}`,q=W.trim();if(!q)throw new o("Failed to create rewritten commit.","REWORD_COMMIT_TREE_FAILED");return q}async function LD(Z){return await E`${Z} symbolic-ref -q HEAD`.then((Q)=>Q.stdout.trim()).catch(()=>"")||"HEAD"}async function BP(Z,Y,Q){let J=`${Y}..${Q}`,{stdout:X}=await E`${Z} rev-list --reverse ${J}`;return X.trim().split(`
|
|
964
|
+
`).map((K)=>K.trim()).filter(Boolean)}function $P(Z){if(Array.isArray(Z))return Z[0];return Z}async function FP(Z,Y,Q){let[J,X,K]=await Promise.all([nQ(Z,Y),jD(Z,Y),wD(Z,Y)]),z=await TD({git$:Z,treeSha:J,parents:X,messageFile:Q,author:K}),H=await LD(Z);await E`${Z} update-ref ${H} ${z} ${Y}`}async function OP(Z,Y,Q,J){await NZ(H6,{recursive:!0});let X=ND.join(H6,`gdx_reword_worktree_${Date.now()}_${Math.random().toString(16).slice(2,10)}`),K=!1;try{await E`${Z} worktree add --detach ${X} ${Q}`,K=!0;let z=[$P(Z),"-C",X],[H,W,q]=await Promise.all([nQ(Z,Y),jD(Z,Y),wD(Z,Y)]),G=await TD({git$:z,treeSha:H,parents:W,messageFile:J,author:q});await E`${z} checkout --detach ${G}`;let U=await BP(Z,Y,Q);for(let D of U)await D0`${z} cherry-pick ${D}`;let B=(await E`${z} rev-parse HEAD`).stdout.trim(),[F,$]=await Promise.all([nQ(Z,Q),nQ(z,B)]);if(F!==$)throw new o("Reword aborted because rewritten history changed the HEAD tree.","REWORD_TREE_MISMATCH");let O=await LD(Z);await E`${Z} update-ref ${O} ${B} ${Q}`}finally{if(K)await E`${Z} worktree remove --force ${X}`.catch(x6);await CY(X,{recursive:!0,force:!0}).catch(x6)}}async function sz(Z){let{git$:Y,args:Q}=Z;if(!await v8(Y))return 1;let{error:J}=await y8(Q,Y,1);if(J)return 1;if(Q.length>2)return R.error(`Usage: ${C} reword [<commit>]`,"reword"),1;let X=Q[1]||"HEAD",K=await GP(Y,X);if(!K)return R.error(`Invalid commit reference: ${X}`,"reword"),1;let z=(await E`${Y} rev-parse HEAD`).stdout.trim(),H=z===K;if(!H){if(!await E`${Y} 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=ND.join(H6,`gdx_reword_${Date.now()}.txt`);try{let q=(await E`${Y} log -1 --format=%B ${K}`).stdout;await _6(W,q,"utf8");let G=await VP();if(await UP(W,G),!(await l0(W,"utf8")).trim())return R.error("Commit message is empty. Aborting reword.","reword"),1;if(H)await FP(Y,z,W);else await OP(Y,K,z,W);return 0}catch(q){return R.error(u(q,{color:!0}),"reword"),1}finally{await xY(W).catch(x6)}}var ID,AD;var oQ=_(()=>{G0();Y6();P0();F6();O6();w0();R0();B0();I0();A0();ID={long:()=>{let Z=V("Bright"),Y=V("Cyan"),Q=V();return s(`
|
|
965
|
+
${Z+c("REWORD",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
966
|
+
Update a commit message without rebase, no clean working directory required, and with safety checks to prevent history corruption. Ideal for quick fixes to recent commits.
|
|
967
|
+
|
|
968
|
+
${Z+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
969
|
+
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. ${Y}~2${Q}) to target older commits.
|
|
970
|
+
|
|
971
|
+
${Z+c("CONFIG",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
972
|
+
Set ${Y}reword.editor${Q} to override the global editor. When unset, ${Y}defaultEditor${Q} is used.
|
|
973
|
+
|
|
974
|
+
${Z+c("SAFETY",k.Zinc400,k.Zinc100,0.2)+Q}
|
|
975
|
+
Rewording rewrites commit history. Ensure you coordinate with collaborators before rewriting shared commits.
|
|
976
|
+
If the commit you are rewording or later commits exist on a remote, you will need to force push after rewording. Always double-check the rewritten history before pushing.
|
|
977
|
+
`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Reword a commit message (defaults to HEAD).",usage:()=>{let Z=V("Cyan"),Y=V("Dim"),Q=V();return s(`
|
|
978
|
+
${Z}${C} reword ${Y}[<commit>]${Q}
|
|
979
|
+
|
|
980
|
+
Examples:
|
|
981
|
+
${Z}${C} reword${Q+Y} # Reword the latest commit${Q}
|
|
982
|
+
${Z}${C} reword ~2${Q+Y} # Reword HEAD~2${Q}
|
|
983
|
+
${Z}${C} reword deadbeef${Q+Y} # Reword a specific commit${Q}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},AD={$root:[]}});function aQ(Z){let Y=V("Cyan"),Q=V("Yellow"),J=V("Bright"),X=V("Dim"),K=V("Reset"),z={cache:pz,stash:NF,stats:mF,graph:IF,nocap:NR,parallel:hQ,"gdx-config":cM,commit:YD,clear:LM,lint:VD,status:$D,doctor:OD,submodule:MD,reword:ID};if(!Z)return I(s(`
|
|
984
|
+
──────────────────────────────
|
|
985
|
+
${J+c("GDX (Git Developer eXperience)",k.OceanDeepBlue,k.OceanGreen,0.32,1)+K}
|
|
986
|
+
Version: ${Y+h6+K}
|
|
987
|
+
──────────────────────────────
|
|
988
|
+
|
|
989
|
+
Git, but with better DX. The raw power of Git,
|
|
990
|
+
aligned with human workflows.
|
|
991
|
+
|
|
992
|
+
${J+c("DESCRIPTION",k.Zinc400,k.Zinc100,0.2)+K}
|
|
993
|
+
${C} (wrapper) — shorthand-friendly wrapper for git (executable) with common shortcuts,
|
|
994
|
+
stash-range support, and convenience expansions.
|
|
995
|
+
It forwards unrecognized commands/args to git (executable) unchanged.
|
|
996
|
+
|
|
997
|
+
${J+c("SYNOPSIS",k.Zinc400,k.Zinc100,0.2)+K}
|
|
998
|
+
${C} <command> [<args>]
|
|
999
|
+
Examples:
|
|
1000
|
+
${Y}${C} st ${K+X}# shorthand for ${C} stash${K}
|
|
1001
|
+
${Y}${C} lg ${K+X}# shorthand for ${C} log --oneline --graph --all --decorate${K}
|
|
1002
|
+
${Y}${C} stash d 2..6 ${K+X}# drop stashes 2 through 6 (safe: drops high->low)${K}
|
|
1003
|
+
${Y}${C} clear ${K+X}# backup changes to a temp patch file and reset working directory (use \`${Y}${C} clear pardon${V("White")}\` to restore)${K}
|
|
1004
|
+
${Y}${C} cmi auto ${K+X}# generate commit message based on staged changes using LLM${K}
|
|
1005
|
+
|
|
1006
|
+
${J+c("KEY FEATURES",k.Zinc400,k.Zinc100,0.2)+K}
|
|
1007
|
+
- Many short aliases for common commands (commit, branch, checkout, etc.).
|
|
1008
|
+
- Smart expansions:
|
|
1009
|
+
- log: ${Y}${C} lg ${K+X}-> ${K+Y}${C} log --oneline --graph --all --decorate${K}
|
|
1010
|
+
- log export: ${Y}${C} lg export [extra args] ${K+X}creates a nicely formatted
|
|
1011
|
+
export (adds --author if missing).${K}
|
|
1012
|
+
- pull: ${Y}${C} pl -au ${K+X}-> expands -au to --allow-unrelated-histories.${K}
|
|
1013
|
+
- push: ${Y}${C} ps -fl ${K+X}-> expands -fl to --force-with-lease.${K}
|
|
1014
|
+
- reset: ${Y}${C} res -h ${K+X}-> ${K+Y}${C} reset --hard${K+X}; ${K+Y}${C} res ~3 ${K+X}-> ${K+Y}${C} reset HEAD~3${K}
|
|
1015
|
+
${X}(also supports ${Y}origin~N${K+X} for upstream-relative resets)${K}
|
|
1016
|
+
- Clear convenience:
|
|
1017
|
+
- ${Y}${C} clear ${K+X}->${K} creates a timestamped patch backup
|
|
1018
|
+
in the system temp folder, then resets the working directory
|
|
1019
|
+
(${Y}${C} reset --hard ${K+X}+ ${K+Y}${C} clean -fd${K}).
|
|
1020
|
+
- Use \`${Y}${C} clear pardon${K}\` to apply the latest backup patch
|
|
1021
|
+
and restore changes. Add \`${Y}-f${K}\`/\`${Y}--force${K}\` to bypass dirty-working-directory prompts.
|
|
1022
|
+
- Stash convenience:
|
|
1023
|
+
- Short forms: ${Y}${C} sta / ${C} st${K} for stash; ${Y}${C} sta l${K} -> stash list.
|
|
1024
|
+
- ${Y}${C} stash d 2..6${K} — drops stash@{6}..stash@{2} (drops high→low to
|
|
1025
|
+
avoid index shift).
|
|
1026
|
+
- Supports apply, pop, drop, list, show, clear via short forms.
|
|
1027
|
+
- Quick worktrees:
|
|
1028
|
+
- ${Y}${C} parallel fork/remove/join/switch/open/list${K} for temp-backed worktree workflows.
|
|
1029
|
+
|
|
1030
|
+
${J+c("SHORTHAND LIST (common)",k.Zinc400,k.Zinc100,0.2)+K}
|
|
1031
|
+
${Y}ad ${K+X}-> ${K}add
|
|
1032
|
+
${Y}bra, br ${K+X}-> ${K}branch
|
|
1033
|
+
${Y}clear ${K+X}-> ${K}clear (backup changes and reset working directory; use \`${Y}pardon${K}\` to restore)
|
|
1034
|
+
${Y}cl, clo ${K+X}-> ${K}clone
|
|
1035
|
+
${Y}com, comm, cmi ${K+X}-> ${K}commit
|
|
1036
|
+
${Y}che, checko, co ${K+X}-> ${K}checkout
|
|
1037
|
+
${Y}dif ${K+X}-> ${K}diff
|
|
1038
|
+
${Y}lg, lo ${K+X}-> ${K}log (auto-expanded)
|
|
1039
|
+
${Y}pl, pul ${K+X}-> ${K}pull
|
|
1040
|
+
${Y}ps, pus ${K+X}-> ${K}push
|
|
1041
|
+
${Y}rb, rebas ${K+X}-> ${K}rebase
|
|
1042
|
+
${Y}res, rese ${K+X}-> ${K}reset
|
|
1043
|
+
${Y}rv, rever ${K+X}-> ${K}revert
|
|
1044
|
+
${Y}mg, merg ${K+X}-> ${K}merge
|
|
1045
|
+
${Y}in, ini ${K+X}-> ${K}init
|
|
1046
|
+
${Y}sta, st ${K+X}-> ${K}stash
|
|
1047
|
+
${Y}s, stat ${K+X}-> ${K}status
|
|
1048
|
+
${Y}swit, sw ${K+X}-> ${K}switch
|
|
1049
|
+
|
|
1050
|
+
${J+c("CUSTOM COMMAND LIST",k.Zinc400,k.Zinc100,0.2)+K}
|
|
1051
|
+
${RP(z,{cyan:Y,reset:K})}
|
|
1052
|
+
|
|
1053
|
+
${J+c("OPTIONS",k.Zinc400,k.Zinc100,0.2)+K}
|
|
1054
|
+
${Y}--init <shell> ${K}Output shell initialization script for given shell.
|
|
1055
|
+
${Y}--bypass ${K}Bypass gdx and execute git directly with the provided arguments.
|
|
1056
|
+
${Y}--no-enhance ${K}Bypass gdx enhanced Git's output.
|
|
1057
|
+
${Y}--loglevel <level> ${K}Set log level (error, warning, info, debug).
|
|
1058
|
+
${Y}--ghelp, ${K}Show GDX help message. ${X}(use \`${Y}ghelp <command>${K}\`
|
|
1059
|
+
${Y} --gdx-help, -gh ${K+X}for command-specific help)${K}
|
|
1060
|
+
${Y}-r, --recursive ${Q}[For '${C} status']${K} Recursively show git status of submodules.
|
|
1061
|
+
${Y}-au ${Q}[For '${C} pull']${K} Shorthand for ${Y}--allow-unrelated-histories${K}.
|
|
1062
|
+
${Y}--on-lint ${Q}[For '${C} push']${K} Skip linting for this push${K}.
|
|
1063
|
+
${Y}-fl ${Q}[For '${C} push']${K} Shorthand for ${Y}--force-with-lease${K}.
|
|
1064
|
+
${Y}-h ${Q}[For '${C} reset']${K} Shorthand for ${Y}--hard${K}.
|
|
1065
|
+
${Y}-s ${Q}[For '${C} reset']${K} Shorthand for ${Y}--soft${K}.
|
|
1066
|
+
|
|
1067
|
+
${J+c("RELATIVE REF EXPANSION",k.Zinc400,k.Zinc100,0.2)+K}
|
|
1068
|
+
Expansions are triggered by specific shorthand patterns in the arguments. When detected, they are expanded to their full form before being passed to git.
|
|
1069
|
+
|
|
1070
|
+
Syntax:
|
|
1071
|
+
[origin|head]~[<number>] (e.g. ${Y}~3${K}, ${Y}origin~2${K})
|
|
1072
|
+
- origin~N expansions resolve relative to the current branch's upstream (e.g. origin~2 -> upstream~2).
|
|
1073
|
+
- ~N or head~N expansions resolve relative to HEAD (e.g. ~3 -> HEAD~3).
|
|
1074
|
+
- [head] and <number> can be omitted, they will default to HEAD and 0 respectively (e.g. ${Y}origin~${K} -> upstream, ${Y}~${K} -> HEAD).
|
|
1075
|
+
|
|
1076
|
+
Examples:
|
|
1077
|
+
- ${Y}${C} reset ~3${K} expands to ${Y}${C} reset HEAD~3${K}.
|
|
1078
|
+
- ${Y}${C} reset -h${K} expands to ${Y}${C} reset --hard${K}.
|
|
1079
|
+
- ${Y}${C} show origin ~2${K} expands to ${Y}${C} show <upstream>~2${K}.
|
|
1080
|
+
- ${Y}${C} diff origin ~2${K} expands to ${Y}${C} diff <upstream>~2${K}.
|
|
1081
|
+
|
|
1082
|
+
${J+c("NOTES & SAFETY",k.Zinc400,k.Zinc100,0.2)+K}
|
|
1083
|
+
- Help message for individual custom commands is available via
|
|
1084
|
+
${Y}${C} ghelp <command>${K} (e.g. ${Y}${C} ghelp stash${K}).
|
|
1085
|
+
- Range notation must be numeric and in the form start..end (e.g. 2..6).
|
|
1086
|
+
- The wrapper prints an auto-expansion message when it expands a shorthand.
|
|
1087
|
+
- If you rely on advanced argument parsing or unusual ${C} flags, you can
|
|
1088
|
+
bypass expansions by using the full command name
|
|
1089
|
+
so they are not recognized as shorthand triggers.
|
|
1090
|
+
- For more infomation, see ${a6("README.md",lH)}.`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})),0;let H=Z.replace(/^\/+/,"");if(H==="help")return aQ();let W=z[H],q="";if(W&&W.long)q=W.long();if(q&&W.usage)q+=`
|
|
1091
|
+
`+J+c("USAGE",k.Zinc400,k.Zinc100,0.2)+K+W.usage();if(q)return I(q),0;return I(`No help found for '${H}'.`),1}function RP(Z,Y){let Q=[];for(let[J,X]of Object.entries(Z))Q.push(`${Y.cyan}${D6(J,19,{overflow:"visible",align:"left",redundancyLv:0})}${Y.reset}${s(X.short,60,{indent:19,firstIndent:0,redundancyLv:0,mode:"strict"})}`);return Q.join(`
|
|
1092
|
+
`)}var CD;var rz=_(()=>{G0();B0();w0();I0();A0();y2();m2();Y7();jQ();mQ();uQ();gz();_Y();pQ();dQ();cQ();lQ();iQ();oQ();CD={$root:["cache","clear","commit","doctor","graph","gdx-config","lint","nocap","parallel","stash","stats","status"]}});var ED={};TY(ED,{dispatch:()=>tz});async function tz(Z,Y={inMacro:!1}){let Q=Z.args,J=Q.slice(0);if(!Y.inMacro){let H=await sQ();if(Q[0]&&Q[0]in H){let W=Q[0],q=H[W],G=Q.slice(1);I(V("Dim")+V("Magenta")+`※ ${V("White")+V("Bright")} Executing macro '${W}'...`+V());let{executeMacro:U}=await Promise.resolve().then(() => (rQ(),xD));return await U(Z.git$,q,G)}}else{let H=await sQ();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 X=null,K=">",z=!Q.popOption("--no-enhance");Z:if(Q[0]){let{match:H,candidates:W}=S0(Q[0],TZ);if(H)Q[0]=H;switch(Q[0]){case"s":Q[0]="status";case"status":if(Q.includes("-r")||Q.includes("--recursive"))return await L0.status(Z);break;case"submodule":{let q=["switch","update","status","add","sync","summary","deinit","foreach"],G=S0(Q[1]||"",q,!0);switch(G.match){case"switch":return await L0.submodule.switch(Z);case"update":case"add":case"deinit":{let U=!!Q.popOption("--quiet");Q[1]=G.match;let B=await L0.submodule.handleUserCommand(Z,Q.slice(1),U);if(typeof B==="number")return B}default:if(G.match)Q[1]=G.match}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 L0.commit.auto(Z);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 L0.lint(Z);case"diff":{let{error:q}=await y8(Q,Z.git$);if(q)return 1;let G=await $0();if(z&&G.get("enhancedOutput")&&SQ()&&!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),B=U.popOption("--json");try{let F=await E`${Z.git$} -c color.ui=never diff ${U}`;if(F.stdout){if(B){let $=$Z(F.stdout);return I(JSON.stringify($,null,2)),0}return await MY(F.stdout),0}}catch(F){R.info("Failed to get or parse diff output for enhanced diff-view, ignoring: "+o.from(F))}}break}case"show":{let{error:q}=await y8(Q,Z.git$);if(q)return 1;let G=await $0();if(z&&G.get("enhancedOutput")&&SQ()&&!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),B=U.popOption("--json");try{let F=await E`${Z.git$} -c color.ui=never show ${U}`;if(F.stdout&&OM(F.stdout)){if(B){let $=$Z(F.stdout);return I(JSON.stringify($,null,2)),0}return await MY(F.stdout),0}}catch(F){R.info("Failed to get show output for enhanced diff-view, ignoring: "+o.from(F))}}break}case"ps":Q[0]="push";case"push":{if(!Q.popOption("--no-lint")){let G=(await $0()).get("lint.onPushBehavior")||"off";if(G==="error"||G==="warning"){if(await L0.lint(Z)!==0)if(G==="error")return R.error("Lint failed. Push aborted.","lint"),1;else I(V("Yellow")+"Lint failed, but proceeding with push (warning mode)."+V())}}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 y8(Q,Z.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 F=Array.isArray(Z.git$)?Z.git$[0]:Z.git$;Q.push("--author="+await t1(F,"user.email"))}let U=Q.indexOf("--relative");if(U>=0)Q.splice(U,1),q='--date=format:"%Y-%m-%d %H:%M" (%ar)';let B=["--all",`--pretty=format:## Commit %h on [%p] - %ad%d
|
|
1093
|
+
%s
|
|
1094
|
+
|
|
1095
|
+
%b
|
|
1096
|
+
---
|
|
1097
|
+
`,q].filter((F)=>!Q.hasOption(F,1));Q.push(...B),X="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=S0(Q[1]||"",q,!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(q.includes(Q[F])||Q[F]==="-h"||Q[F]==="--help"){B=!0;break}if(!B){let F=Array.isArray(Z.git$)?Z.git$[0]:Z.git$,O=mH(await JF(F),"2.15.0")>=0?"push":"save";Q.splice(1,0,O)}}if(Q[1]==="drop"){let U=Array.isArray(Z.git$)?Z.git$[0]:Z.git$;return await L0.stash.drop(U,Q)}break}case"graph":return L0.graph(Z);case"stats":return L0.stats(Z);case"clear":return L0.clear(Z);case"cache":return L0.cache(Z);case"gdx-config":return L0.gdxConfig(Z);case"gdx-help":case"ghelp":return L0.help(Q[1]);case"nocap":return L0.nocap(Z);case"parallel":return L0.parallel(Z);case"doctor":return L0.doctor();case"macro":return L0.macro(Z);case"reword":return L0.reword(Z);default:if(W&&W.length>1){R.warn(`Ambiguous command '${J[0]}'. Did you mean one of: ${W.join(", ")}?`);break Z}}}if(Y.inMacro||J.some((H,W)=>Q[W]!==H)){let H=qW((Q.length%6+1)/8.6,0.64,0.5);I(V("Dim")+V(_4(H),"fg")+`$ ${V("White")+V("Bright")}git ${SY(Q).join(" ")}`+V())}return T2(Z.git$,Q,X,K)}var ez=_(()=>{G0();ZH();B0();P0();w0();F6();R0();rQ();I0();O6();kQ()});var xD={};TY(xD,{writeMacrosToFile:()=>tQ,syncMacrosToCache:()=>QH,substitutePlaceholders:()=>kD,readMacrosFromFile:()=>B4,isFilePath:()=>JH,getMacrosCachedOrLoad:()=>sQ,executeMacro:()=>DP});import MP from"path";async function B4(){try{if(!l(D4))return{};let Z=await l0(D4,"utf-8"),Y=JSON.parse(Z);if(typeof Y!=="object"||Y===null||Array.isArray(Y))return R.warn(`Invalid macro.json format at ${D4}`,"macro"),{};return Y}catch(Z){return R.warn(`Failed to read macro.json: ${o.from(Z).message}`,"macro"),{}}}async function tQ(Z){try{let Y=MP.dirname(D4);if(!l(Y))z6(Y,{recursive:!0});let Q=JSON.stringify(Z,null,2);await _6(D4,Q,"utf-8"),R.debug(`Macros written to ${D4}`,"macro")}catch(Y){throw new o(`Failed to write macro.json: ${o.from(Y).message}`,"MACRO_WRITE_FAILED")}}async function QH(){let Z=await B4(),Y=await F0();if(Y.isDisabled)throw new o("Cache is disabled. Cannot sync macros to cache.","CACHE_DISABLED");await Y.set(YH,Z,{maxAgeMinutes:SD}),R.debug(`Synced ${Object.keys(Z).length} macros to cache`,"macro")}async function sQ(){let Z=await F0();if(Z.isDisabled)return await B4();let Y=await Z.get(YH);if(Y)return R.debug("Using cached macros","macro"),Y;let Q=await B4();return await Z.set(YH,Q,{maxAgeMinutes:SD}),R.debug("Loaded macros from file and cached","macro"),Q}async function DP(Z,Y,Q){let J=Y.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:X}=await Promise.resolve().then(() => (ez(),ED));for(let K=0;K<J.length;K++){let z=K===J.length-1,H=w2(J[K]),{substituted:W,notUsedArgs:q}=kD(H,Q);if(z)W.push(...q);if(W.length===0)continue;I(V("Dim")+V("Cyan")+`▶ Executing: ${V("White")+V("Bright")}gdx ${SY(W).join(" ")}`+V());let G={git$:Z,args:new E1(W)},U=await X(G,{inMacro:!0});if(U!==0)return R.error(`Macro command failed with exit code ${U}`,"macro"),U}return 0}function JH(Z){if(Z.startsWith("./")||Z.startsWith("/"))return!0;if(Z.startsWith(".\\"))return!0;if(/^[a-zA-Z]:[/\\]/.test(Z))return!0;return!1}function kD(Z,Y){let Q=-1,J=new Set(Y),X=Z.map((K,z)=>{return K.replace(/\$(\*|\d+)/g,(H,W)=>{if(W==="*")return Q=z,J.clear(),"";let q=parseInt(W,10)-1;if(q>=0&&q<Y.length)return J.delete(Y[q]),Y[q];return H})});if(Q!==-1)X.splice(Q,1,...Y);return{substituted:X,notUsedArgs:Array.from(J)}}var YH="macro.all",SD=1440;var rQ=_(()=>{Y6();B0();I1();G0();R0();P0();w0();b8()});async function _P(Z){let{args:Y}=Z,Q=Y[1]?.toLowerCase(),{match:J,candidates:X}=S0(Q,["set","list","drop","sync"]);switch(J){case"set":return await jP(Z);case"list":return await wP();case"drop":return await TP(Z);case"sync":return await LP();default:if(X&&X.length>0)R.warn(`Ambiguous command '${Q}'. Did you mean one of: ${X.join(", ")}?`);else R.warn(`Unknown macro subcommand '${Q}'`);return R.info("Available subcommands: set, list, drop, sync","macro"),1}}async function NP(){return new Promise((Z,Y)=>{let Q="";if(process.stdin.setEncoding("utf-8"),process.stdin.on("data",(J)=>{Q+=J}),process.stdin.on("end",()=>{Z(Q.trim())}),process.stdin.on("error",(J)=>{Y(J)}),process.stdin.isTTY)Z("")})}async function jP(Z){let{args:Y}=Z,Q=Y[2],J=Y.slice(3);if(!Q)return R.error("Macro name is required. Usage: gdx macro set <name> <script>","macro"),1;let X;if(J.length===0)try{if(X=await NP(),!X)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: ${o.from(K).message}`,"macro"),1}else if(J.length===1&&JH(J[0])){let K=J[0];try{if(!l(K))return R.error(`File not found: ${K}`,"macro"),1;X=(await l0(K,"utf-8")).trim(),R.debug(`Loaded macro script from file: ${K}`,"macro")}catch(z){return R.error(`Failed to read file: ${o.from(z).message}`,"macro"),1}}else X=J.join(" ");if(!X)return R.error("Macro script cannot be empty.","macro"),1;try{let K=await B4(),z=Q in K;if(K[Q]=X,await tQ(K),await(await F0()).set("macro.all",K,{maxAgeMinutes:1440}),z)I(V("Yellow")+`Macro '${Q}' updated.`+V());else I(V("Green")+`Macro '${Q}' created.`+V());return 0}catch(K){return R.error(`Failed to set macro: ${o.from(K).message}`,"macro"),1}}async function wP(){try{let Z=await B4();await(await F0()).set("macro.all",Z,{maxAgeMinutes:1440});let Q=Object.keys(Z);if(Q.length===0)return I(V("Dim")+"No macros defined."+V()),0;I(V("Cyan")+V("Bright")+"Macros:"+V());for(let J of Q.sort()){let X=Z[J],z=(X.length>80?X.substring(0,77)+"...":X).replace(/\s+/g," ");I(` ${V("Green")}${J}${V()}: ${V("Dim")}${z}${V()}`)}return 0}catch(Z){return R.error(`Failed to list macros: ${o.from(Z).message}`,"macro"),1}}async function TP(Z){let{args:Y}=Z,Q=Y[2];if(!Q)return R.error("Macro name is required. Usage: gdx macro drop <name>","macro"),1;try{let J=await B4();if(!(Q in J))return R.error(`Macro '${Q}' not found.`,"macro"),1;return delete J[Q],await tQ(J),await(await F0()).set("macro.all",J,{maxAgeMinutes:1440}),I(V("Yellow")+`Macro '${Q}' deleted.`+V()),0}catch(J){return R.error(`Failed to drop macro: ${o.from(J).message}`,"macro"),1}}async function LP(){try{return await QH(),I(V("Green")+"Macros synced to cache."+V()),0}catch(Z){let Y=o.from(Z);if(Y.code==="CACHE_DISABLED")R.error("Cache is disabled. Cannot sync macros.","macro");else R.error(`Failed to sync macros: ${Y.message}`,"macro");return 1}}var vD,PD;var XH=_(()=>{rQ();G0();R0();w0();I1();Y6();vD=_P,PD={$root:{set:{},list:{},drop:{},sync:{}}}});function IP(Z){if(!Z||typeof Z!=="object"||Array.isArray(Z))return!1;return!0}async function KH(Z,Y){let Q=Z,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Y)}catch{return{}}J+=1}if(Array.isArray(Q)||IP(Q))return Q;return{}}async function yD(Z,Y){if(!Z)return[];let Q=Z,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Y)}catch{return[]}J+=1}return Array.isArray(Q)?Q:[]}async function bD(Z,Y){if(Array.isArray(Z))return{children:{},anyOf:new Set(Z),allOf:new Set};let Q={},J=new Set(await yD(Z.$anyOf,Y)),X=new Set(await yD(Z.$allOf,Y));for(let[K,z]of Object.entries(Z)){if(K==="$allOf"||K==="$anyOf"||!z)continue;Q[K]=z}return{children:Q,anyOf:J,allOf:X}}function zH(Z,Y,Q=!1){let J=Array.from(new Set(Y)),{match:X,candidates:K}=S0(Z,J,Q);if(X)return{match:X,isAmbiguous:!1};if(Z&&K&&K.length>1)return{match:null,isAmbiguous:!0};return{match:null,isAmbiguous:!1}}async function fD(Z,Y,Q,J){let X=Q.$root,K=new Set,z=new Set,H=[...Z],W=!1,q=Y,G=(D,j)=>({git$:J.git$,args:H,index:D,cursorIndex:q,mode:j});for(let D=0;D<Y;D++){let j=H[D];if(!j)continue;X=await KH(X,G(D,"history"));let M=await bD(X,G(D,"history")),T=Object.keys(M.children),N=zH(j,T);if(N.isAmbiguous)return{completions:[]};if(N.match){for(let h of M.allOf)K.add(h);X=await KH(M.children[N.match],G(D,"history")),H[D]=N.match,W=!1;continue}let L=zH(j,M.anyOf);if(L.isAmbiguous)return{completions:[]};if(L.match){if(W)return{completions:[]};W=!0,H[D]=L.match;continue}let x=new Set([...M.allOf,...K]),S=zH(j,x);if(S.isAmbiguous)return{completions:[]};if(S.match){if(z.has(S.match))return{completions:[]};z.add(S.match),H[D]=S.match;continue}if(j.startsWith("-"))return{completions:[]}}X=await KH(X,G(Y,"suggest"));let U=await bD(X,G(Y,"suggest")),B=new Set;for(let D of Object.keys(U.children))B.add(D);if(!W)for(let D of U.anyOf)B.add(D);let F=new Set([...U.allOf,...K]);for(let D of F)if(!z.has(D))B.add(D);let $=H[Y]||"";return{completions:Array.from(B).filter((D)=>D.startsWith($)&&D!==$.trim()).sort((D,j)=>D.length-j.length||D.localeCompare(j))}}var hD=_(()=>{w0()});var AP,HH;var gD=_(()=>{pQ();_Y();lQ();uQ();Y7();rz();dQ();jQ();mQ();y2();m2();cQ();XH();iQ();oQ();AP={commit:{$root:{auto:{$anyOf:["--no-commit","--copy","--yes","--describe","-d","--preview"]}}},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"]}}},HH={...AP,cache:XD,clear:IM,doctor:RD,"gdx-config":lM,graph:AF,help:CD,lint:BD,nocap:jR,parallel:dM,stash:jF,stats:uF,status:FD,macro:PD,submodule:DD,reword:AD}});function mD(Z){let Y=process.env.GDX_CMP_IDX,Q=Number.parseInt(Y||"",10);if(!Number.isInteger(Q)||Q<0)Q=Math.max(0,Z-1);if(Z>0&&Q>=Z)Q=Z-1;return Q}async function WH(Z){let Y=p.logLevel;p.logLevel="off";try{let Q=[...Z.args],{args:J,cursorIndex:X,cursorInGitGlobal:K}=h2(Q,mD(Q.length));if(J[0]==="__completion")J.shift();let z=X??mD(J.length);if(R.debug(`Completion invoked with args: ${J.join(" ")} (idx=${z})`,"completion"),K)return 0;if(J.length===0||z===0){let B=J[0]||"",F=new Set;for(let O of Object.keys(HH))F.add(O);for(let O of tH)F.add(O);for(let O of eH)F.add(O);for(let O of TZ)F.add(O);let $=Array.from(F).filter((O)=>O.startsWith(B)).sort((O,D)=>O.length-D.length||O.localeCompare(D));R.debug(`Completion root-level matches: ${$.join(", ")}`,"completion");for(let O of $)process.stdout.write(`${O}
|
|
1098
|
+
`);return 0}let H=J[0],{match:W}=S0(H,TZ),q=W||CP[H]||H,G=J.slice(1),U=HH[q];if(U){let B=z-1;if(B>=0&&B<G.length){let{completions:F}=await fD(G,B,U,{git$:Z.git$});R.debug(`Completion matches for command '${q}': ${F.join(", ")}`,"completion");for(let $ of F)process.stdout.write(`${$}
|
|
1099
|
+
`);return 0}}return R.debug(`No completion structure for command '${q}', or index out of range`,"completion"),0}finally{p.logLevel=Y}}var CP;var uD=_(()=>{hD();b8();A0();B0();R0();w0();gD();CP={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 L0;var ZH=_(()=>{rz();y2();Y7();m2();_Y();pQ();gz();uQ();jQ();mQ();dQ();lQ();cQ();XH();iQ();oQ();uD();L0={__completion:WH,help:aQ,stash:_F,graph:Z7,stats:tJ,clear:DY,cache:mz,commit:ZD,gdxConfig:fz,nocap:Jz,parallel:bz,lint:dz,doctor:nz,status:lz,macro:vD,submodule:_D,reword:sz}});G0();ZH();P0();w0();b8();B0();var EP=(Z="gdx")=>{return`# gdx shell integration
|
|
1100
|
+
${Z}() {
|
|
1101
|
+
local tmp
|
|
1102
|
+
tmp="$(mktemp)"
|
|
1103
|
+
GDX_RESULT="$tmp" command gdx "$@"
|
|
1104
|
+
local ret=$?
|
|
1105
|
+
if [ $ret -eq ${R4} ]; then
|
|
1106
|
+
if [ -f "$tmp" ]; then
|
|
1107
|
+
cd "$(cat "$tmp")"
|
|
1108
|
+
fi
|
|
1109
|
+
rm -f "$tmp"
|
|
1110
|
+
return 0
|
|
1111
|
+
fi
|
|
1112
|
+
rm -f "$tmp"
|
|
1113
|
+
return $ret
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
# Completion function for ${Z}
|
|
1117
|
+
__gdx_complete_bash() {
|
|
1118
|
+
local cur prev words cword
|
|
1119
|
+
_init_completion || return
|
|
1120
|
+
|
|
1121
|
+
# Build args array excluding command name
|
|
1122
|
+
local args=("\${words[@]:1}")
|
|
1123
|
+
local idx=$((cword - 1))
|
|
1124
|
+
|
|
1125
|
+
# Call gdx completion
|
|
1126
|
+
local out
|
|
1127
|
+
out="$(GDX_CMP_IDX="$idx" command gdx __completion "\${args[@]}" 2>/dev/null)"
|
|
1128
|
+
|
|
1129
|
+
if [ -n "$out" ]; then
|
|
1130
|
+
# Use gdx suggestions
|
|
1131
|
+
COMPREPLY=( $(compgen -W "$out" -- "$cur") )
|
|
1132
|
+
return 0
|
|
1133
|
+
fi
|
|
1134
|
+
|
|
1135
|
+
# Fallback to git completion
|
|
1136
|
+
if declare -F _git >/dev/null 2>&1; then
|
|
1137
|
+
# Temporarily set words[0] to git for git completion
|
|
1138
|
+
local orig_word0="\${words[0]}"
|
|
1139
|
+
words[0]="git"
|
|
1140
|
+
_git
|
|
1141
|
+
words[0]="$orig_word0"
|
|
1142
|
+
elif [ -f /usr/share/bash-completion/completions/git ]; then
|
|
1143
|
+
source /usr/share/bash-completion/completions/git 2>/dev/null
|
|
1144
|
+
if declare -F _git >/dev/null 2>&1; then
|
|
1145
|
+
local orig_word0="\${words[0]}"
|
|
1146
|
+
words[0]="git"
|
|
1147
|
+
_git
|
|
1148
|
+
words[0]="$orig_word0"
|
|
1149
|
+
fi
|
|
1150
|
+
fi
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
complete -o bashdefault -o default -F __gdx_complete_bash ${Z}
|
|
1154
|
+
`},xP=(Z="gdx")=>{return`# gdx shell integration
|
|
1155
|
+
${Z}() {
|
|
1156
|
+
local tmp
|
|
1157
|
+
tmp="$(mktemp)"
|
|
1158
|
+
GDX_RESULT="$tmp" command gdx "$@"
|
|
1159
|
+
local ret=$?
|
|
1160
|
+
if [ $ret -eq ${R4} ]; then
|
|
1161
|
+
if [ -f "$tmp" ]; then
|
|
1162
|
+
cd "$(cat "$tmp")"
|
|
1163
|
+
fi
|
|
1164
|
+
rm -f "$tmp"
|
|
1165
|
+
return 0
|
|
1166
|
+
fi
|
|
1167
|
+
rm -f "$tmp"
|
|
1168
|
+
return $ret
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
# Completion function for ${Z}
|
|
1172
|
+
__gdx_complete_zsh() {
|
|
1173
|
+
local -a args
|
|
1174
|
+
local idx
|
|
1175
|
+
|
|
1176
|
+
# Build args from words, excluding command name
|
|
1177
|
+
args=("\${words[@]:2}")
|
|
1178
|
+
idx=$((CURRENT - 2))
|
|
1179
|
+
|
|
1180
|
+
# Call gdx completion
|
|
1181
|
+
local out
|
|
1182
|
+
out="$(GDX_CMP_IDX="$idx" command gdx __completion "\${args[@]}" 2>/dev/null)"
|
|
1183
|
+
|
|
1184
|
+
if [ -n "$out" ]; then
|
|
1185
|
+
# Use gdx suggestions
|
|
1186
|
+
local -a completions
|
|
1187
|
+
completions=("\${(f)out}")
|
|
1188
|
+
compadd -Q -a completions
|
|
1189
|
+
return 0
|
|
1190
|
+
fi
|
|
1191
|
+
|
|
1192
|
+
# Fallback to git completion
|
|
1193
|
+
if (( $+functions[_git] )); then
|
|
1194
|
+
# Temporarily adjust words[1] to git
|
|
1195
|
+
local orig_word1="\${words[1]}"
|
|
1196
|
+
words[1]="git"
|
|
1197
|
+
_git
|
|
1198
|
+
words[1]="$orig_word1"
|
|
1199
|
+
fi
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
# Ensure completion system is loaded
|
|
1203
|
+
if ! (( $+functions[compdef] )); then
|
|
1204
|
+
autoload -Uz compinit
|
|
1205
|
+
compinit -u
|
|
1206
|
+
fi
|
|
1207
|
+
|
|
1208
|
+
compdef __gdx_complete_zsh ${Z}
|
|
1209
|
+
`},SP=(Z="gdx")=>{return`# gdx shell integration
|
|
1210
|
+
function ${Z}
|
|
1211
|
+
set -l tmp (mktemp)
|
|
1212
|
+
set -x GDX_RESULT "$tmp"
|
|
1213
|
+
command gdx $argv
|
|
1214
|
+
set -l ret $status
|
|
1215
|
+
if test $ret -eq ${R4}
|
|
1216
|
+
if test -f "$tmp"
|
|
1217
|
+
cd (cat "$tmp")
|
|
1218
|
+
end
|
|
1219
|
+
rm -f "$tmp"
|
|
1220
|
+
return 0
|
|
1221
|
+
end
|
|
1222
|
+
rm -f "$tmp"
|
|
1223
|
+
return $ret
|
|
1224
|
+
end
|
|
1225
|
+
|
|
1226
|
+
# Completion function for ${Z}
|
|
1227
|
+
function __gdx_complete_fish
|
|
1228
|
+
# Get commandline tokens
|
|
1229
|
+
set -l tokens (commandline -opc)
|
|
1230
|
+
set -l current (commandline -ct)
|
|
1231
|
+
|
|
1232
|
+
# Remove the command name itself
|
|
1233
|
+
set -e tokens[1]
|
|
1234
|
+
|
|
1235
|
+
# Calculate cursor index
|
|
1236
|
+
set -l idx (math (count $tokens) - 1)
|
|
1237
|
+
if test $idx -lt 0
|
|
1238
|
+
set idx 0
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
# Call gdx completion
|
|
1242
|
+
set -l out (GDX_CMP_IDX=$idx command gdx __completion $tokens $current 2>/dev/null)
|
|
1243
|
+
|
|
1244
|
+
# Output suggestions
|
|
1245
|
+
for suggestion in $out
|
|
1246
|
+
echo $suggestion
|
|
1247
|
+
end
|
|
1248
|
+
end
|
|
1249
|
+
|
|
1250
|
+
# Register completions for ${Z}
|
|
1251
|
+
# First, provide git-like fallback by default
|
|
1252
|
+
complete -c ${Z} -w git
|
|
1253
|
+
|
|
1254
|
+
# Then add gdx-specific completions (they take precedence)
|
|
1255
|
+
complete -c ${Z} -f -a "(__gdx_complete_fish)"
|
|
1256
|
+
`},kP=(Z="gdx")=>{return`# gdx shell integration
|
|
1257
|
+
function ${Z} {
|
|
1258
|
+
$tmp = [System.IO.Path]::GetTempFileName()
|
|
1259
|
+
$env:GDX_RESULT = $tmp
|
|
1260
|
+
try {
|
|
1261
|
+
$command = Get-Command -Name "gdx" -CommandType Application -ErrorAction SilentlyContinue
|
|
1262
|
+
if ($command.length -gt 1) {
|
|
1263
|
+
$command = $command | Select-Object -First 1
|
|
1264
|
+
}
|
|
1265
|
+
if ($command) {
|
|
1266
|
+
& $command @args
|
|
1267
|
+
if ($LASTEXITCODE -eq ${R4}) {
|
|
1268
|
+
if (Test-Path $tmp) {
|
|
1269
|
+
$target = Get-Content $tmp -Raw
|
|
1270
|
+
if ($target) {
|
|
1271
|
+
Set-Location $target.Trim()
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
} else {
|
|
1276
|
+
Write-Error "gdx executable not found"
|
|
1277
|
+
}
|
|
1278
|
+
} finally {
|
|
1279
|
+
if (Test-Path $tmp) {
|
|
1280
|
+
Remove-Item $tmp
|
|
1281
|
+
}
|
|
1282
|
+
$env:GDX_RESULT = $null
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
# Completion scriptblock for ${Z}
|
|
1287
|
+
$__gdxCompleter = {
|
|
1288
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
1289
|
+
|
|
1290
|
+
# Use AST to get properly parsed tokens (handles quotes correctly)
|
|
1291
|
+
$tokens = @($commandAst.CommandElements | ForEach-Object { $_.Extent.Text })
|
|
1292
|
+
|
|
1293
|
+
# Remove the command name itself
|
|
1294
|
+
if ($tokens.Count -gt 0) {
|
|
1295
|
+
$tokens = @($tokens | Select-Object -Skip 1)
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
# Find cursor token index
|
|
1299
|
+
$idx = [Math]::Max(0, $tokens.Count - 1)
|
|
1300
|
+
|
|
1301
|
+
# Call gdx completion
|
|
1302
|
+
$env:GDX_CMP_IDX = $idx
|
|
1303
|
+
try {
|
|
1304
|
+
$completions = & gdx __completion @tokens 2>$null
|
|
1305
|
+
|
|
1306
|
+
if ($completions) {
|
|
1307
|
+
# Return gdx suggestions
|
|
1308
|
+
$completions | ForEach-Object {
|
|
1309
|
+
[System.Management.Automation.CompletionResult]::new(
|
|
1310
|
+
$_, $_, 'ParameterValue', $_
|
|
1311
|
+
)
|
|
1312
|
+
}
|
|
1313
|
+
return
|
|
1314
|
+
}
|
|
1315
|
+
} finally {
|
|
1316
|
+
$env:GDX_CMP_IDX = $null
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
# Fallback to git completion if posh-git is available
|
|
1320
|
+
if (Get-Command -Name "GitTabExpansion" -ErrorAction SilentlyContinue) {
|
|
1321
|
+
$gitCompletions = GitTabExpansion $wordToComplete $commandAst
|
|
1322
|
+
if ($gitCompletions) {
|
|
1323
|
+
$gitCompletions | ForEach-Object {
|
|
1324
|
+
if ($_ -is [System.Management.Automation.CompletionResult]) {
|
|
1325
|
+
$_
|
|
1326
|
+
} else {
|
|
1327
|
+
[System.Management.Automation.CompletionResult]::new(
|
|
1328
|
+
$_, $_, 'ParameterValue', $_
|
|
1329
|
+
)
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
Register-ArgumentCompleter -Native -CommandName ${Z} -ScriptBlock $__gdxCompleter
|
|
1337
|
+
`},pD=(Z,Y)=>{switch(Z.toLowerCase()){case"bash":return EP(Y);case"zsh":return xP(Y);case"fish":return SP(Y);case"powershell":case"pwsh":return kP(Y);default:throw Error("Unsupported shell: ${shell}`")}};A0();R0();ez();var PP=process.argv.slice(2);R.debug(`Raw arguments: ${u(process.argv)}`,"gdx");async function vP(){let Z=h2(PP),Y={args:new E1(Z.args),git$:""},Q=Y.args;if(R.debug(`Parsed arguments: ${u(Q.toArray())}`,"gdx"),Q[0]==="--init"){let K=Q.popValue("--shell")||Q.popValue("--init"),z=Q.popValue("--cmd");if(K)try{let H=pD(K,z||void 0);return I(H),0}catch(H){return R.error(u(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 L0.__completion({...Y,git$:"git"});let J=await J1("git");if(!J)throw new o("Git is not installed or not found in PATH.","GIT_NOT_FOUND");if(Y.git$=Z.gitArgs.length?[J,...Z.gitArgs]:J,Q[0]==="--bypass")return T2(J,Q.slice(1));let X=Q.popValue("--loglevel");if(X){let K=["fatal","error","warn","info","debug"];if(K.includes(X))p.logLevel=X;else return R.error(`Invalid log level '${X}'. Expected: ${K.join(", ")}`),1}if(Q.includes("--ghelp")||Q.includes("-gh")||Q.includes("--gdx-help")||Q.length===0)return L0.help(),0;return tz(Y)}(async()=>{try{let Z=await vP();if(p.finalStringOutput)I(p.finalStringOutput);process.exit(p.exitCodeOverride>=0?p.exitCodeOverride:Z)}catch(Z){R.error(u(Z,{color:!0})),process.exit(1)}})();
|