gdx 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -26
- package/dist/index.js +589 -400
- package/package.json +13 -10
package/dist/index.js
CHANGED
|
@@ -1,93 +1,87 @@
|
|
|
1
|
-
import{createRequire as tK}from"node:module";var iK=Object.create;var{getPrototypeOf:nK,defineProperty:eZ,getOwnPropertyNames:aK}=Object;var oK=Object.prototype.hasOwnProperty;var Y7=(Y,Z,Q)=>{Q=Y!=null?iK(nK(Y)):{};let X=Z||!Y||!Y.__esModule?eZ(Q,"default",{value:Y,enumerable:!0}):Q;for(let J of aK(Y))if(!oK.call(X,J))eZ(X,J,{get:()=>Y[J],enumerable:!0});return X};var N0=(Y,Z)=>()=>(Z||Y((Z={exports:{}}).exports,Z),Z.exports);var sK=(Y,Z)=>{for(var Q in Z)eZ(Y,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:(X)=>Z[Q]=()=>X})};var i5=(Y,Z)=>()=>(Y&&(Z=Y(Y=0)),Z);var b0=tK(import.meta.url);var O3=N0((mL,N3)=>{N3.exports=w3;w3.sync=rH;var T3=b0("fs");function tH(Y,Z){var Q=Z.pathExt!==void 0?Z.pathExt:process.env.PATHEXT;if(!Q)return!0;if(Q=Q.split(";"),Q.indexOf("")!==-1)return!0;for(var X=0;X<Q.length;X++){var J=Q[X].toLowerCase();if(J&&Y.substr(-J.length).toLowerCase()===J)return!0}return!1}function _3(Y,Z,Q){if(!Y.isSymbolicLink()&&!Y.isFile())return!1;return tH(Z,Q)}function w3(Y,Z,Q){T3.stat(Y,function(X,J){Q(X,X?!1:_3(J,Y,Z))})}function rH(Y,Z){return _3(T3.statSync(Y),Y,Z)}});var A3=N0((uL,k3)=>{k3.exports=E3;E3.sync=eH;var P3=b0("fs");function E3(Y,Z,Q){P3.stat(Y,function(X,J){Q(X,X?!1:C3(J,Z))})}function eH(Y,Z){return C3(P3.statSync(Y),Z)}function C3(Y,Z){return Y.isFile()&&Yz(Y,Z)}function Yz(Y,Z){var{mode:Q,uid:X,gid:J}=Y,$=Z.uid!==void 0?Z.uid:process.getuid&&process.getuid(),G=Z.gid!==void 0?Z.gid:process.getgid&&process.getgid(),K=parseInt("100",8),H=parseInt("010",8),W=parseInt("001",8),z=K|H,q=Q&W||Q&H&&J===G||Q&K&&X===$||Q&z&&$===0;return q}});var j3=N0((pL,I3)=>{var dL=b0("fs"),Z4;if(process.platform==="win32"||global.TESTING_WINDOWS)Z4=O3();else Z4=A3();I3.exports=U7;U7.sync=Zz;function U7(Y,Z,Q){if(typeof Z==="function")Q=Z,Z={};if(!Q){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(X,J){U7(Y,Z||{},function($,G){if($)J($);else X(G)})})}Z4(Y,Z||{},function(X,J){if(X){if(X.code==="EACCES"||Z&&Z.ignoreErrors)X=null,J=!1}Q(X,J)})}function Zz(Y,Z){try{return Z4.sync(Y,Z||{})}catch(Q){if(Z&&Z.ignoreErrors||Q.code==="EACCES")return!1;else throw Q}}});var b3=N0((cL,h3)=>{var _6=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",x3=b0("path"),Qz=_6?";":":",S3=j3(),y3=(Y)=>Object.assign(Error(`not found: ${Y}`),{code:"ENOENT"}),v3=(Y,Z)=>{let Q=Z.colon||Qz,X=Y.match(/\//)||_6&&Y.match(/\\/)?[""]:[..._6?[process.cwd()]:[],...(Z.path||process.env.PATH||"").split(Q)],J=_6?Z.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",$=_6?J.split(Q):[""];if(_6){if(Y.indexOf(".")!==-1&&$[0]!=="")$.unshift("")}return{pathEnv:X,pathExt:$,pathExtExe:J}},f3=(Y,Z,Q)=>{if(typeof Z==="function")Q=Z,Z={};if(!Z)Z={};let{pathEnv:X,pathExt:J,pathExtExe:$}=v3(Y,Z),G=[],K=(W)=>new Promise((z,q)=>{if(W===X.length)return Z.all&&G.length?z(G):q(y3(Y));let V=X[W],R=/^".*"$/.test(V)?V.slice(1,-1):V,B=x3.join(R,Y),M=!R&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+B:B;z(H(M,W,0))}),H=(W,z,q)=>new Promise((V,R)=>{if(q===J.length)return V(K(z+1));let B=J[q];S3(W+B,{pathExt:$},(M,T)=>{if(!M&&T)if(Z.all)G.push(W+B);else return V(W+B);return V(H(W,z,q+1))})});return Q?K(0).then((W)=>Q(null,W),Q):K(0)},Xz=(Y,Z)=>{Z=Z||{};let{pathEnv:Q,pathExt:X,pathExtExe:J}=v3(Y,Z),$=[];for(let G=0;G<Q.length;G++){let K=Q[G],H=/^".*"$/.test(K)?K.slice(1,-1):K,W=x3.join(H,Y),z=!H&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+W:W;for(let q=0;q<X.length;q++){let V=z+X[q];try{if(S3.sync(V,{pathExt:J}))if(Z.all)$.push(V);else return V}catch(R){}}}if(Z.all&&$.length)return $;if(Z.nothrow)return null;throw y3(Y)};h3.exports=f3;f3.sync=Xz});var m3=N0((lL,q7)=>{var g3=(Y={})=>{let Z=Y.env||process.env;if((Y.platform||process.platform)!=="win32")return"PATH";return Object.keys(Z).reverse().find((X)=>X.toUpperCase()==="PATH")||"Path"};q7.exports=g3;q7.exports.default=g3});var c3=N0((iL,p3)=>{var u3=b0("path"),Jz=b3(),$z=m3();function d3(Y,Z){let Q=Y.options.env||process.env,X=process.cwd(),J=Y.options.cwd!=null,$=J&&process.chdir!==void 0&&!process.chdir.disabled;if($)try{process.chdir(Y.options.cwd)}catch(K){}let G;try{G=Jz.sync(Y.command,{path:Q[$z({env:Q})],pathExt:Z?u3.delimiter:void 0})}catch(K){}finally{if($)process.chdir(X)}if(G)G=u3.resolve(J?Y.options.cwd:"",G);return G}function Gz(Y){return d3(Y)||d3(Y,!0)}p3.exports=Gz});var l3=N0((zz,B7)=>{var V7=/([()\][%!^"`<>&|;, *?])/g;function Kz(Y){return Y=Y.replace(V7,"^$1"),Y}function Hz(Y,Z){if(Y=`${Y}`,Y=Y.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),Y=Y.replace(/(?=(\\+?)?)\1$/,"$1$1"),Y=`"${Y}"`,Y=Y.replace(V7,"^$1"),Z)Y=Y.replace(V7,"^$1");return Y}zz.command=Kz;zz.argument=Hz});var n3=N0((nL,i3)=>{i3.exports=/^#!(.*)/});var o3=N0((aL,a3)=>{var qz=n3();a3.exports=(Y="")=>{let Z=Y.match(qz);if(!Z)return null;let[Q,X]=Z[0].replace(/#! ?/,"").split(" "),J=Q.split("/").pop();if(J==="env")return X;return X?`${J} ${X}`:J}});var t3=N0((oL,s3)=>{var F7=b0("fs"),Vz=o3();function Bz(Y){let Q=Buffer.alloc(150),X;try{X=F7.openSync(Y,"r"),F7.readSync(X,Q,0,150,0),F7.closeSync(X)}catch(J){}return Vz(Q.toString())}s3.exports=Bz});var ZQ=N0((sL,YQ)=>{var Fz=b0("path"),r3=c3(),e3=l3(),Rz=t3(),Mz=process.platform==="win32",Dz=/\.(?:com|exe)$/i,Lz=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Tz(Y){Y.file=r3(Y);let Z=Y.file&&Rz(Y.file);if(Z)return Y.args.unshift(Y.file),Y.command=Z,r3(Y);return Y.file}function _z(Y){if(!Mz)return Y;let Z=Tz(Y),Q=!Dz.test(Z);if(Y.options.forceShell||Q){let X=Lz.test(Z);Y.command=Fz.normalize(Y.command),Y.command=e3.command(Y.command),Y.args=Y.args.map(($)=>e3.argument($,X));let J=[Y.command].concat(Y.args).join(" ");Y.args=["/d","/s","/c",`"${J}"`],Y.command=process.env.comspec||"cmd.exe",Y.options.windowsVerbatimArguments=!0}return Y}function wz(Y,Z,Q){if(Z&&!Array.isArray(Z))Q=Z,Z=null;Z=Z?Z.slice(0):[],Q=Object.assign({},Q);let X={command:Y,args:Z,options:Q,file:void 0,original:{command:Y,args:Z}};return Q.shell?X:_z(X)}YQ.exports=wz});var JQ=N0((tL,XQ)=>{var R7=process.platform==="win32";function M7(Y,Z){return Object.assign(Error(`${Z} ${Y.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${Z} ${Y.command}`,path:Y.command,spawnargs:Y.args})}function Nz(Y,Z){if(!R7)return;let Q=Y.emit;Y.emit=function(X,J){if(X==="exit"){let $=QQ(J,Z);if($)return Q.call(Y,"error",$)}return Q.apply(Y,arguments)}}function QQ(Y,Z){if(R7&&Y===1&&!Z.file)return M7(Z.original,"spawn");return null}function Oz(Y,Z){if(R7&&Y===1&&!Z.file)return M7(Z.original,"spawnSync");return null}XQ.exports={hookChildProcess:Nz,verifyENOENT:QQ,verifyENOENTSync:Oz,notFoundError:M7}});var KQ=N0((rL,w6)=>{var $Q=b0("child_process"),D7=ZQ(),L7=JQ();function GQ(Y,Z,Q){let X=D7(Y,Z,Q),J=$Q.spawn(X.command,X.args,X.options);return L7.hookChildProcess(J,X),J}function Pz(Y,Z,Q){let X=D7(Y,Z,Q),J=$Q.spawnSync(X.command,X.args,X.options);return J.error=J.error||L7.verifyENOENTSync(J.status,X),J}w6.exports=GQ;w6.exports.spawn=GQ;w6.exports.sync=Pz;w6.exports._parse=D7;w6.exports._enoent=L7});import{createRequire as EF}from"module";class Z${value;start;end;constructor(Y,Z,Q){this.value=Y,this.start=Z,this.end=Q}}class I2{TF;IDF;TF_IDF;constructor(Y){this.TF=Y}}class Q${x;y;z;r;t;get unit(){return this.#Z}get dimension(){return this.#Q}#Z;#Q=0;constructor(Y,Z,Q=null){if(this.x=Y,this.y=Z,this.z=Q,Q)this.#Q=3;else if(Z)this.#Q=2;else if(Y)this.#Q=1}toPolarCoords(Y="r"){this.#Z=Y;let{r:Z,t:Q}=F.MathKit.toPolarCoords(this.x,this.y,Y);return this.r=Z,this.t=Q,this}toCartesianCoords(){if(!this.#Z&&this.x)return this;let{x:Y,y:Z}=F.MathKit.toCartesianCoords(this.r,this.t,this.#Z);return this.x=Y,this.y=Z,this}setUnit(Y){if(!Y||Y!="d"&&Y!="r")throw Error("unit must be 'r' or 'd', given: "+Y);if(this.#Z==Y)return;if(Y=="r")this.#Z=Y,this.t=F.MathKit.radians(this.t);else this.#Z=Y,this.t=F.MathKit.degrees(this.t)}}class X${constructor(Y,Z,Q,X,J,$,G){this.x=Y,this.y=Z,this.f=Q,this.ymid=X,this.iterations=J,this.events=G,this.msg=$}_at(Y,Z){function Q(R){return R*R}let X,J,$,G,K,H,W,z,q,V;return X=this.x[Z],J=this.x[Z+1],G=this.y[Z],K=this.y[Z+1],W=J-X,$=X+0.5*W,H=this.ymid[Z],z=this.f[Z]-G*(1/(X-$)+2/(X-J)),q=this.f[Z+1]-K*(1/(J-$)+2/(J-X)),V=[Q(Y-J)*(Y-$)/Q(X-J)/(X-$),Q(Y-X)*Q(Y-J)/Q(X-$)/Q(J-$),Q(Y-X)*(Y-$)/Q(J-X)/(J-$),(Y-X)*Q(Y-J)*(Y-$)/Q(X-J)/(X-$),(Y-J)*Q(Y-X)*(Y-$)/Q(X-J)/(J-$)],G*V[0]+H*V[1]+K*V[2]+z*V[3]+q*V[4]}at(Y){let Z,Q,X;if(typeof Y!=="number"){let $=Y.length,G=Array($);for(Z=$-1;Z!==-1;--Z)G[Z]=this.at(Y[Z]);return G}let J=this.x;Z=0,Q=J.length-1;while(Q-Z>1)if(X=Math.floor(0.5*(Z+Q)),J[X]<=Y)Z=X;else Q=X;return this._at(Y,Z)}}class JY{value;index;type;constructor(Y,Z,Q=-1){this.value=Y,this.type=Z,this.index=Q}valueOf(){return this.value}toString(){return this.value.toString()}}class y6{type;UPID=null;callback;constructor(Y,Z,Q=null){if(Q)this.type=1,this.UPID=Q;else this.type=Y;this.callback=Z}}function AF(Y){return Y==null||typeof Y=="number"||typeof Y=="string"||typeof Y=="boolean"||Y instanceof ArrayBuffer||Y instanceof MessagePort||Y instanceof ReadableStream||Y instanceof WritableStream||Y instanceof TransformStream}var CF,S6,kF,XY,A2="[#*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])",F,KA,J$,HA,zA,WA,$$,UA,qA,I1,VA,BA,FA,RA,MA,DA,LA,TA,_A,wA,NA,OA,X0,PA,EA,CA,kA,AA,IA,jA,xA,SA,yA,v6,vA,fA,hA,bA,gA,mA,uA,dA,pA,cA,G$,lA,iA,nA,aA,oA,K$,M0,H$,U,sA,tA,rA,eA,YI,z$,ZI,QI,XI,JI,$I,GI,KI,HI,zI,WI,UI,qI,VI,BI,FI,RI,f6,MI,W$,DI,LI,TI,_I,a,wI,NI,OI,PI,EI,$Y,CI,kI,s;var Y0=i5(()=>{CF=EF(import.meta.url),S6=typeof window>"u"||typeof process<"u",kF={dgram:null,worker_threads:null,os:null,fs:null,mathjs:null},XY={consoleTimeInstances:null};F={_modules:kF,arrFindLast(Y,Z){for(let Q=Y.length-1;Q>=0;Q--)if(Z(Y[Q],Q,Y))return Y[Q];return},arrToString(Y,Z={}){let{maxDepth:Q=4,indent:X=3,maxRow:J=10,maxCol:$=20,color:G=!1,defColor:K=void 0,noHeader:H=!1}=Z;if(Q<1)Q=1;let W={color:G,defColor:K},z=F.getDimensions(Y,"max"),q=z.length*0.4,V=typeof X=="number"?" ".repeat(X):X,R=null;if(G)R={magenta:F.ncc(11550650),gray:F.ncc(4802889),_default:F.ncc(K)};if(!H&&(!(Y instanceof Array)||z.length>2||Math.max(...z)>5))return T(Y)+B(Y,0);else return B(Y,0);function B(D,_,w=0){let N="";if(_>Q-1)if(G)return R.gray+`... [${M(D)||"Array"}]`+R._default;else return`... [${M(D)||"Array"}]`;if(!F.isArrayLike(D))return N+F.yuString(D,W);let j;if(_>q)j=F.getDimensions(D,"max");else j=z.slice(_);let x=z[_+1]!=null&&(j[2]!=null||j[1]>2)&&_<Q-1,f=w?V.repeat(w):"",m=f+V,b=x?`[
|
|
2
|
-
`+m:"[",
|
|
3
|
-
`+
|
|
4
|
-
`+m,
|
|
5
|
-
`+m:", "}return
|
|
6
|
-
`);else Z=
|
|
7
|
-
`),Z=
|
|
8
|
-
`),
|
|
9
|
-
expected length: ${
|
|
10
|
-
actual length: ${
|
|
11
|
-
Name: `,X
|
|
12
|
-
Code: `,X
|
|
13
|
-
Stack: `,X)$+=F.ncc(5592405)+Z.stack+F.ncc(J);else $+=Z.stack;return $}},escapeRegExp(Y){return Y.replace(/[[\]{}.*$^|\-?+,:\\]/g,"\\$&")},ex_length(Y,Z=0){if(typeof Y!=="string")throw TypeError("argument must be a string");if(Z<0)return Y.length;Y=F.cleanString(Y);let Q=Y.length;if(Z<1)return Q;let X=Y;for(let K of F.CONSTS.UNICODES_RANGE_TABLE){if(!K.type.endsWith("full"))continue;X=X.replace(K.regex,"")}let J=Q+(Q-X.length);if(Z<2)return J;let $=Y.match(F.REGEXP.EmojiEach)??[],G=$.reduce((K,H)=>K+H.length,0);return $.length*2+(J-G)},fileNameCleaner(Y,Z="_"){if(!Y||typeof Y!="string")throw Error("the given `rawName` isn't a string");return Y.trim().replace(/[|/*\\<>"?:]/g,Z)},fixFilePath(Y,Z="_"){if(!Y||!Y?.length)throw"path is either falsy or empty!";return Y.replace(/[:?"<>|*]/g,Z)},fixYTurl(Y){if(Y=Y||void 0,!Y)throw"url can't be falsy!!";if(Y.includes("youtu.be"))Y=Y.replace("https://youtu.be/","https://www.youtube.com/watch?v=");if(Y.includes("&list="))Y=Y.split("&list=")[0];if(Y.includes("?si="))Y=Y.split("?si=")[0];if(Y.includes("https")==!1)Y="https://www."+Y;return Y},fileTypeOf(Y){let Z=Y.slice(Y.lastIndexOf(".")+1).toLowerCase(),Q=Z=="jpg"||Z=="png"||Z=="svg"||Z=="jfif"||Z=="pbm"||Z=="pgm"||Z=="jpeg",X=Z=="txt"||Z=="bat"||Z=="text"||Z=="md"||Z=="json"||Z=="step"||Z=="js"||Z=="cs"||Z=="cpp"||Z=="gitignore"||Z=="java"||Z=="py"||Z=="config"||Z=="cfg"||Z=="ts"||Z=="env",J=Z=="exe"||Z=="vpk"||Z=="qc"||Z=="smd"||Z=="vmt"||Z=="vtf"||Z=="zip"||Z=="7z"||Z=="bin"||Z=="ipynb"||Z=="pyc"||Z=="jar",$=Z=="aiff"||Z=="aif"||Z=="aifc"||Z=="flac"||Z=="mp3"||Z=="mp4"||Z=="mp4a"||Z=="m4a"||Z=="mkv"||Z=="mov"||Z=="wav"||Z=="gif"||Z=="webm";if(Q)return"image";else if(X)return"text";else if(J)return"binary";else if($)return"media";return null},getMatchAllIndexes(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(Q.index);return Z},getMatchAllResults(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(new Z$(Q[0],Q.index,Q.index+Q[0].length));return Z},getRandomInt(Y,Z){return Math.round(Math.random()*(Z-Y)+Y)},getProcessTime(){let Y=process.hrtime();return Y[0]*1000+Y[1]/1e6},hyperLink(Y,Z){if(Z=encodeURI(Z),!F.CheckCache.supportsHyperlink)return Z;return`\x1B]8;;${Z}\x07${Y}\x1B]8;;\x07`},IDGenerator(Y=null,Z="CCNNNN"){let Q=!1,X=Z.length,J=new F.SafeTrue;while(J.True){let $=Array(X);for(let G=0;G<X;G++)switch(Z[G]){case"C":{let K=F.getRandomInt(65,116);if(K>90)K+=6;$[G]=String.fromCharCode(K);continue}case"N":$[G]=F.getRandomInt(0,9).toString();continue;case"B":{let K=F.getRandomInt(48,109);if(K>57&&K<84)K+=7;else if(K>83)K+=13;$[G]=String.fromCharCode(K);continue}default:$[G]=Z[G];break}if(Y){if(Y instanceof Set)Q=Y.has($);else Q=Y.includes($);if(!Q)return $.join("")}else return $.join("")}return null},includesWord(Y,Z,Q=!1){if(!Q)Z=Z.toLowerCase(),Y=Y.toLowerCase();Z=Z.padStart(Z.length+1," ").padEnd(Z.length+2," ");let X=Z.search(Y);if(X!==-1){let J=Z.substring(X-1),$=Z.substring(X+Y.length);if(J.search(F.REGEXP.Seperators)==0&&$.search(F.REGEXP.Seperators)==0)return!0}return!1},IPC:class Y{static Listener=y6;#Z;#Q=new Map;#Y;#X=!1;#J=new Set;peersAddress="localhost";peersPort;listenPort;get protocol(){return this.#Y}constructor(Z="udp4",Q={}){if(!S6)throw Error("IPC is only available on JSRuntime, due to the use of Node modules");let{peersPort:X=null,peersAddress:J=null,listenPort:$=null}=typeof Q=="number"?{listenPort:Q}:Q;if(Z!="nodeworker"&&Z!="udp4"&&Z!="udp6")throw Error(`protocol must be 'nodeworker', 'udp4' or 'udp6' instead given '${Z}'`);if(this.#Y=Z,!F._modules.dgram&&Z!="nodeworker")throw Error(`module 'dgram' not loaded use 'Tools._modules.dgram = require("dgram")' to load it`);if(Z=="nodeworker"){if(!F._modules.worker_threads)throw Error(`module 'worker_threads' not loaded use 'Tools._modules.worker_threads = require("worker_threads")' to load it`);if(!$){if(F._modules.worker_threads.isMainThread)throw Error("when using `nodeworker` protocol, `port` must be provided if on the main thread");this.#Z=F._modules.worker_threads.parentPort,this.#$();return}if(!($ instanceof F._modules.worker_threads.Worker)&&$!==F._modules.worker_threads.parentPort&&$!=null)throw Error(`port must be a type of 'Worker' or a 'parentPort' instead given '${typeof $}'`);this.#Z=$,this.#$();return}if(!X)throw Error("peersPort must be provided for `udp4` or `udp6` protocol");this.listenPort=$,this.peersAddress=J,this.peersPort=X,this.#Z=F._modules.dgram.createSocket(Z),this.#$()}async#$(){if(this.#Z.on("message",this.#G),this.protocol=="nodeworker")return;if(!this.listenPort)return;try{this.#Z.bind(this.listenPort),this.#X=!0}catch(Z){switch(Z.code){case"ERR_SOCKET_BAD_PORT":throw new F.Err(`Tools.IPC: port ${this.listenPort} is not valid`,"IPC_ERR_SOCKET_BAD_PORT",Z.code,Z.stack);case"EADDRINUSE":throw new F.Err(`Tools.IPC: port ${this.listenPort} is already in use`,"IPC_EADDRINUSE",Z.code,Z.stack);default:throw F.Err.from(Z,"IPC_BIND_ERROR").message=`Tools.IPC: failed to bind port ${this.listenPort} `+Z.message}}}bind(Z,Q){if(this.protocol=="nodeworker")return;if(this.peersAddress=Z,this.listenPort=Q,!this.#X)this.#$();return this}close(){if(this.protocol=="nodeworker")return;this.#Z.close()}async advSend(Z,Q){return new Promise((X,J)=>{if(!Z)throw Error("channel must be provided");if(typeof Z!="string")throw Error(`channel must be a type of 'string' instead given '${typeof Z}'`);let{contents:$,UPID:G}=Q;if(!($ instanceof Array))$=[$];let K;try{K=this.protocol=="nodeworker"?{channel:Z,UPID:G,contents:$.map((H)=>{if(AF(H))return H;return"@JSON:"+JSON.stringify(H,F.JSONReplacer)})}:Buffer.from(JSON.stringify({channel:Z,UPID:G,contents:$},F.JSONReplacer))}catch(H){J(F.Err.from(H,"IPC_SERIALIZE_ERROR").message="Tools.IPC: failed to serialize payload,"+H.message);return}if(this.protocol=="nodeworker"){this.#Z.postMessage(K),X();return}this.#Z.send(K,this.peersPort,this.peersAddress,(H)=>{if(H)J(H);X()})})}async send(Z,...Q){return this.advSend(Z,{contents:Q})}on(Z,Q){let X=this.#Q.get(Z);if(!X){this.#Q.set(Z,[new y6(0,Q)]);return}return X.push(new y6(0,Q)),this}once(Z,Q,X=null){let J=this.#Q.get(Z);if(!J){this.#Q.set(Z,[new y6(1,Q,X)]);return}return J.push(new y6(1,Q,X)),this}remove(Z){if(typeof Z=="string")return this.#Q.delete(Z),!0;if(typeof Z!="function")throw Error(`listener must be a type of 'string' or 'function' instead given '${typeof Z}'`);for(let[Q,X]of this.#Q){let J=X.find((G)=>G.callback==Z);if(!J)continue;if(!X.filter((G)=>G.callback!=Z))return this.#Q.delete(Q),!0;return this.#Q.set(Q,X.filter((G)=>G.callback!=J)),!0}return!1}async ask(Z,Q,...X){return new Promise((J,$)=>{let G;if(Q)G=setTimeout(()=>{$(new F.Err(`Tools.IPC: ask timeout on channel: ${Z}`,"IPCAskTimeout"))},Q);let K=this.#K();this.once(Z,(H)=>{if(Q)clearTimeout(G);J(H)},K),this.advSend(Z,{contents:X,UPID:K})})}onAsk(Z,Q){let X=this,J=async function(...$){X.#J.add(this.UPID);let G=await Q(...$);X.advSend(Z,{contents:[G],UPID:this.UPID}),X.#J.delete(this.UPID)};return this.on(Z,J),this}#G=(Z)=>{let Q;try{Q=this.protocol=="nodeworker"?{channel:Z.channel,UPID:Z.UPID,contents:Z.contents.map((J)=>{if(typeof J=="string"&&J.startsWith("@JSON:"))return JSON.parse(J.slice(6),F.JSONReviver);return J})}:JSON.parse(Z.toString(),F.JSONReviver)}catch(J){throw F.Err.from(J,"IPC_DESERIALIZE_ERROR").message="Tools.IPC: failed to deserialize payload,"+J.message}let X=this.#Q.get(Q.channel);if(!X)return;for(let J of X){if(J.UPID){if(J.UPID!=Q.UPID)continue;this.#J.delete(J.UPID)}if(J.callback.call(Q,...Q.contents),J.type==1||J.UPID)this.remove(J.callback)}};#K(){let Z=F.IDGenerator(this.#J,"BBBBBBBB");return this.#J.add(Z),Z}},isArrayLike(Y){let Z=Y?.length;return Array.isArray(Y)||!!Y&&Z!=null&&typeof Y==="object"&&typeof Z==="number"&&(Z===0||Z>0&&(Z-1 in Y))},isArrowFunction(Y){if(typeof Y!=="function")return!1;if(Object.hasOwnProperty.call(Y,"prototype"))return!1;try{return Y.arguments,!1}catch{}return Y.toString().slice(0,20).includes("=>")},isAsyncFunction(Y){if(typeof Y!=="function")return!1;if(Y.constructor?.name==="AsyncFunction")return!0;return(Y instanceof F.CONSTS.AsyncFunction&&F.CONSTS.AsyncFunction!==Function&&F.CONSTS.AsyncFunction!==F.CONSTS.GeneratorFunction)===!0},isClass:(Y)=>{if(typeof Y!=="function")return!1;return Y.toString().startsWith("class")},isNumber:(Y)=>{return/^[0-9]+$|^[0-9]+\\.[0-9]+$/.test(Y)},isEmptyArray:(Y)=>F.isArrayLike(Y)&&!Y.length,isEmptyObject:(Y)=>!F.isArrayLike(Y)&&Y instanceof Object&&!F.propertiesCount(Y),isError(Y){return F.Err.isError(Y)},isValidFilePath(Y){if(!Y||!Y?.length)return!1;if(/[:?"<>|*]/g.test(Y))return!1;return!0},JSONReplacer(Y,Z){if(Z instanceof Map)return{"@dataType":"Map","@value":Array.from(Z.entries())};if(Z instanceof Set)return{"@dataType":"Set","@value":Array.from(Z.values())};switch(typeof Z){case"function":return{"@dataType":"function","@value":Z.toString().replace(/\n* {2,}|\n/g,"")};case"bigint":return{"@dataType":"BigInt","@value":Z.toString()};case"object":for(let Q in Z)if(Z[Q]instanceof Date)Z[Q]={"@dataType":"Date","@value":Z[Q].valueOf()};return Z}return Z},JSONReviver(Y,Z){if(!Z||!Z["@dataType"])return Z;switch(Z["@dataType"]){case"function":return Function("return "+Z["@value"])();case"BigInt":return BigInt(Z["@value"]);case"Map":return new Map(Z["@value"]);case"Set":return new Set(Z["@value"]);case"Date":return new Date(Z["@value"])}return Z},jsTime:{howLong(Y,Z=new Date){let Q=Z.getTime()-Y.getTime();return F.jsTime.getTimeFromMS(Q).modern()},getTimeFromMS(Y){let Z=0,Q=0,X=0,J=0,$=0,G=0,K=Y>262800200;while(Y>=1000)Y-=1000,G++;while(G>=60)G-=60,$++;while($>=60)$-=60,J++;if(K){while(J>=24)J-=24,X++;while(X>=30.4167)X-=30.4167,Q++;X=Math.round(X);while(Q>=12)Q-=12,Z++}if(K)return{year:Z,month:Q,days:X,hr:J,min:$,sec:G,ms:Y,toString(){return`${Z}:${Q}:${X}|${J}:${$}:${G}.${Y.toString().padStart(3,"0")}`},modern(){if(Z+Q+X+G+$+J==0)return`${Y}ms`;else if(Z+Q+X+$+J==0)return`${G}.${Y}s`;else if(Z+Q+X+J==0)return`${$}min ${G}s`;else if(Z+Q+X==0)return`${J}hr ${$}min`;else if(Z+Q==0)return`${X}days ${J}hr`;else if(Z==0)return`${Q}months ${X}days`;else return`${Z}year ${Q}months`}};return{year:Z,month:Q,days:X,hr:J,min:$,sec:G,ms:Y,toString(){return`${J}:${$}:${G}.${Y.toString().padStart(3,"0")}`},modern(){if(G+$+J==0)return`${Y}ms`;else if($+J==0)return`${G}.${Y}s`;else if(J==0)return`${$}min ${G}s`;else return`${J}hr ${$}min`}}}},lazySplit:function*(Y,Z){if(Z===""){for(let J of Y)yield J;return}let Q=0,X;while((X=Y.indexOf(Z,Q))!==-1)yield Y.substring(Q,X),Q=X+Z.length;yield Q?Y.substring(Q):Y},remap(Y,Z){if(Y instanceof Map){let X=new Map;for(let[J,$]of Y){let G=Z(J,$,X);if(G===void 0)continue;if(G===null)X.set(J,$);if(G.key===void 0)X.set(J,G);if(X.set(G.key,G.value),G.key!==J&&X.has(J))X.delete(J)}return X}let Q={};for(let X in Y){let J=Z(X,Y[X],Q);if(J===void 0)continue;if(J===null){Q[X]=Y[X];continue}if(J.key===void 0){Q[X]=J;continue}if(Q[J.key]=J.value,J.key!==X&&Q[X]!==void 0)delete Q[X]}return Q},MathKit:{clamp(Y,Z,Q){return Math.min(Math.max(Y,Z),Q)},degrees(Y){return Y*180/Math.PI},distanceFrom(Y,Z){let Q=Z.x-Y.x,X=Z.y-Y.y,J=Z.z-Y.z;return Math.sqrt(Q**2+(isNaN(X)?0:X**2)+(isNaN(J)?0:J**2))},dopri(Y,Z,Q,X,J=0.000001,$=1000,G){let K=[Y],H=[Q],W=[X(Y,Q)],z,q,V,R,B,M,T=[],D=0.2,_=[0.075,0.225],w=[0.9777777777777777,-3.7333333333333334,3.5555555555555554],N=[2.9525986892242035,-11.595793324188385,9.822892851699436,-0.2908093278463649],j=[2.8462752525252526,-10.757575757575758,8.906422717743473,0.2784090909090909,-0.2735313036020583],x=[0.09114583333333333,0,0.44923629829290207,0.6510416666666666,-0.322376179245283,0.13095238095238096],f=[0.10013431883002395,0,0.3918321794184259,-0.02982460176594817,0.05893268337240795,-0.04497888809104361,0.023904308236133973],m=[0.2,0.3,0.8,0.8888888888888888,1,1],b=[-0.0012326388888888888,0,0.0042527702905061394,-0.03697916666666667,0.05086379716981132,-0.0419047619047619,0.025],v=0,d,o,y=(Z-Y)/10,B0=0,w0,M6,q0,_0,xY,F0=new X$(K,H,W,T,-1,"");if(typeof G==="function")q0=G(Y,Q);while(Y<Z&&B0<$){if(++B0,Y+y>Z)y=Z-Y;if(z=X(Y+m[0]*y,Q+D*y*W[v]),q=X(Y+m[1]*y,Q+_[0]*y*W[v]+_[1]*y*z),V=X(Y+m[2]*y,Q+w[0]*y*W[v]+w[1]*y*z+w[2]*y*q),R=X(Y+m[3]*y,Q+N[0]*y*W[v]+N[1]*y*z+N[2]*y*q+N[3]*y*V),B=X(Y+m[4]*y,Q+j[0]*y*W[v]+j[1]*y*z+j[2]*y*q+j[3]*y*V+j[4]*y*R),w0=Q+W[v]*y*x[0]+q*y*x[2]+V*y*x[3]+R*y*x[4]+B*y*x[5],M=X(Y+y,w0),d=W[v]*y*b[0]+q*y*b[2]+V*y*b[3]+R*y*b[4]+B*y*b[5]+M*y*b[6],M6=Math.abs(d),M6>J){if(y=0.2*y*Math.pow(J/M6,0.25),Y+y===Y){F0.msg="Step size became too small";break}continue}if(T[v]=Q+W[v]*y*f[0]+q*y*f[2]+V*y*f[3]+R*y*f[4]+B*y*f[5]+M*y*f[6],++v,K[v]=Y+y,H[v]=w0,W[v]=M,typeof G==="function"){let SY,yY=Y,S0=Y+0.5*y,r;if(_0=G(S0,T[v-1]),xY=q0<0&&0<_0,xY){let R0,u8,d8=0,vY=1,fY=1;while(!0){if(typeof q0==="number")r=(fY*_0*yY-vY*q0*S0)/(fY*_0-vY*q0);else{r=S0;for(o=q0.length-1;o!==-1;--o)if(q0[o]<0&&_0[o]>0)r=Math.min(r,(fY*_0[o]*yY-vY*q0[o]*S0)/(fY*_0[o]-vY*q0[o]))}if(r<=yY||r>=S0)break;if(SY=F0._at(r,v-1),u8=G(r,SY),R0=q0<0&&0<u8,R0){if(S0=r,_0=u8,xY=R0,fY=1,d8===-1)vY*=0.5;else vY=1;d8=-1}else{if(yY=r,q0=u8,vY=1,d8===1)fY*=0.5;else fY=1;d8=1}}return w0=F0._at(0.5*(Y+r),v-1),F0.f[v]=X(r,SY),F0.x[v]=r,F0.y[v]=SY,F0.ymid[v-1]=w0,F0.events=xY,F0.iterations=B0,F0}yY=S0,S0=Y+y,q0=_0,_0=G(S0,w0),xY=q0<0&&0<_0}Y+=y,Q=w0,q0=_0,y=Math.min(0.8*y*Math.pow(J/M6,0.25),4*y)}return F0.iterations=B0,F0},integral(Y,Z,Q){if(Q>Z)throw Error("lower bound must be less than upper bound");if(Q==Z)return 0;if(!F._modules.mathjs)throw Error(`module 'mathjs' not loaded use 'Tools._modules.mathjs = require("mathjs")' to load it`);let X;if(typeof Y=="string")X=F._modules.mathjs.compile(Y);else X=Y;if(typeof Q=="string")Q=F._modules.mathjs.evaluate(Q);if(typeof Z=="string")Z=F._modules.mathjs.evaluate(Z);let J=($)=>X.evaluate({x:$});return F.MathKit.dopri(Q,Z,0,J).at(Z)},lerp(Y,Z,Q){return Y+(Z-Y)*Q},Lsh_us(Y,Z){return Y*2**Z},not_us16(Y){return Y^65535},not_us32(Y){return Y^4294967295},not_us8(Y){return Y^255},map(Y,Z,Q,X,J){return Y=F.MathKit.clamp(Y,Z,Q),(Y-Z)/(Q-Z)*(J-X)+X},Point:Q$,radians(Y){return Y*Math.PI/180},Rsh_us(Y,Z){return Math.floor(Y/2**Z)},sum:(...Y)=>{return Y.flat(5).reduce((Z,Q)=>Z+Q,0)},toPolarCoords(Y,Z,Q="r"){if(!Q||Q!="d"&&Q!="r")throw Error("unit must be 'r' or 'd', given: "+Q);let X=Math.atan(Z/Y);if(Z<0&&Y<0)X+=360;else if(Y<0)X+=180;return{r:Math.sqrt(Y**2+Z**2),t:Q=="d"?X:F.MathKit.radians(X)}},toCartesianCoords(Y,Z,Q=null,X="r"){if(!X||X!="d"&&X!="r")throw Error("unit must be 'r' or 'd', given: "+X);if(Q!==null&&typeof Q!="number")throw Error("polar must be a number");if(X=="d"){if(Z=F.MathKit.radians(Z),Q!==null)Q=F.MathKit.radians(Q)}if(Q===null)return{x:Y*Math.cos(Z),y:Y*Math.sin(Z)};else return{x:Y*Math.sin(Q)*Math.cos(Z),y:Y*Math.sin(Q)*Math.sin(Z),z:Y*Math.cos(Q)}}},maxFraction(Y,Z,Q=!1){let X=Y.toString();if(!X.includes("."))return X;let J=10**Z;return Y=(Q?Math.floor(Y*J):Math.round(Y*J))/J,Y.toString()},ncc(Y=null,Z=null,Q=null){if(F.CheckCache.supportsColor===0)return"";if(Y==null)return"\x1B[0m";if(typeof Y=="number"){let J=F.Convert.decimalColorToRGB(Y);switch(Q?1:F.CheckCache.supportsColor){default:return"";case 1:Y=(Z=="bg"?"bg":"")+F.Convert.basicColorFromRgb(J);case 2:{let G=F.Convert._8bitColorFromRgb(J);return`\x1B[${Z=="bg"?"4":"3"}8;5;${G}m`}case 3:return`\x1B[${Z=="bg"?"4":"3"}8;2;${J.r};${J.g};${J.b}m`}}return Y=Y.toLowerCase(),{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",blink:"\x1B[5m",invert:"\x1B[7m",hidden:"\x1B[8m",normal:"\x1B[22m",bgblack:"\x1B[40m",bgred:"\x1B[41m",bggreen:"\x1B[42m",bgyellow:"\x1B[43m",bgblue:"\x1B[44m",bgmagenta:"\x1B[45m",bgcyan:"\x1B[46m",bgwhite:"\x1B[47m"}[Y]||"\x1B[37m"},nearestNumber(Y,Z){let Q=1/0,X=null;for(let J=0,$=Y[J];J<Y.length;){let G=Math.abs(Z-$);if(!G)return J;if(G<Q)Q=G,X=J;$=Y[++J]}return X},objectMap(Y,Z){return F.remap(Y,Z)},objValueAt(Y,Z){return Y[Object.keys(Y).at(Z)]},objToString(Y,Z={}){let{maxDepth:Q=4,indent:X=3,maxKeys:J=20,color:$=!1,defColor:G=void 0,noHeader:K=!1}=Z;if(Q<1)Q=1;let H={color:$,defColor:G},W=typeof X=="number"?" ".repeat(X):X,z=null;if($)z={cyan:F.ncc(4764610),magenta:F.ncc(11550650),gray:F.ncc(4802889),yellow:F.ncc(12754962),_default:F.ncc(G)};if(Y==null||typeof Y!=="object")return F.yuString(Y,H);if(F.isArrayLike(Y))return F.arrToString(Y,{color:$,defColor:G,maxDepth:Q,indent:X});if(Y instanceof Map||Y instanceof Set||Y instanceof Promise||Y instanceof Date||Y instanceof RegExp)return F.yuString(Y,H);if(F.isError(Y))return F.Err.toString(Y,{color:$,defColor:G});let q=Y.constructor?.name||"Object",V=q!=="Object",B=Object.keys(Y).length,M="";if(!K&&(V||B>5))if($)M=z.magenta+`${q}(${B}) `+z._default;else M=`${q}(${B}) `;return M+T(Y,0);function T(D,_,w=0){if(_>Q-1)if($)return z.gray+"... {Object}"+z._default;else return"... {Object}";if(D==null)return F.yuString(D,H);if(typeof D!=="object"||D instanceof Date||D instanceof RegExp)return F.yuString(D,H);if(F.isArrayLike(D))return F.arrToString(D,{color:$,defColor:G,maxDepth:Q-_,indent:X,noHeader:!0});if(D instanceof Map||D instanceof Set)return F.yuString(D,H);let N=Object.keys(D),j=N.length;if(j===0)return"{}";let x=j>3||_>0,f=w?W.repeat(w):"",m=f+W,b=x?`{
|
|
14
|
-
`+m:"{ ",
|
|
15
|
-
`+m:", "}if(
|
|
16
|
-
`+m:", ",
|
|
17
|
-
`+m:", ",
|
|
18
|
-
`+
|
|
19
|
-
`),["","\r"]),
|
|
20
|
-
at \`${
|
|
21
|
-
`+"".padStart(
|
|
22
|
-
at \`${
|
|
23
|
-
`+" ".padStart(
|
|
24
|
-
`),this.reset()}reset(){this.progress=0,this.#Z=0,this.spd=0,this.lastCheck=Date.now(),this.#Q=!0}setPrintTemplate(Z){Z=Z.replace(/%total%/g,"${this.total}"),Z=Z.replace(/%spd%/g,"${this.spd.toFixed(1)}"),Z=Z.replace(/%prog%/g,"${this.progress}"),this.#Y=Function("this.stdout.write(`"+Z+"`);").bind(this)}},proximate(Y,Z,Q){if(Y<Z+Q&&Y>Z-Q)return Z;else return Y},randomPick(Y){if(Y.length<=1)return Y[0];return Y[Math.floor(Math.random()*Y.length)]},redexOf(Y,Z,Q=0){let
|
|
25
|
-
`;else if(typeof
|
|
26
|
-
|
|
27
|
-
[${
|
|
28
|
-
`;if(
|
|
29
|
-
`:`${
|
|
30
|
-
`;if(
|
|
31
|
-
`;else{let
|
|
32
|
-
$`,"m"),
|
|
33
|
-
`?
|
|
34
|
-
`,
|
|
35
|
-
Reason: loop limit reached`);return
|
|
36
|
-
`)){let
|
|
37
|
-
`),
|
|
38
|
-
|
|
39
|
-
`,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`
|
|
46
|
-
`}),Q+=G+"
|
|
47
|
-
`,Q}var SK=null;var vK=i5(()=>{Y0()});function e(Y){if(typeof Y!=="object"||Y===null)return!1;let Z=Object.getPrototypeOf(Y);return(Z===null||Z===Object.prototype||Object.getPrototypeOf(Z)===null)&&!(Symbol.toStringTag in Y)&&!(Symbol.iterator in Y)}import{fileURLToPath as rK}from"node:url";var D6=(Y,Z)=>{let Q=Q7(eK(Y));if(typeof Q!=="string")throw TypeError(`${Z} must be a string or a file URL: ${Q}.`);return Q},eK=(Y)=>Z7(Y)?Y.toString():Y,Z7=(Y)=>typeof Y!=="string"&&Y&&Object.getPrototypeOf(Y)===String.prototype,Q7=(Y)=>Y instanceof URL?rK(Y):Y;var p8=(Y,Z=[],Q={})=>{let X=D6(Y,"First argument"),[J,$]=e(Z)?[[],Z]:[Z,Q];if(!Array.isArray(J))throw TypeError(`Second argument must be either an array of arguments or an options object: ${J}`);if(J.some((H)=>typeof H==="object"&&H!==null))throw TypeError(`Second argument must be an array of strings: ${J}`);let G=J.map(String),K=G.find((H)=>H.includes("\x00"));if(K!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${K}`);if(!e($))throw TypeError(`Last argument must be an options object: ${$}`);return[X,G,$]};import{ChildProcess as GH}from"node:child_process";import{StringDecoder as YH}from"node:string_decoder";var{toString:n5}=Object.prototype,a5=(Y)=>n5.call(Y)==="[object ArrayBuffer]",G0=(Y)=>n5.call(Y)==="[object Uint8Array]",r0=(Y)=>new Uint8Array(Y.buffer,Y.byteOffset,Y.byteLength),ZH=new TextEncoder,o5=(Y)=>ZH.encode(Y),QH=new TextDecoder,c8=(Y)=>QH.decode(Y),s5=(Y,Z)=>{return XH(Y,Z).join("")},XH=(Y,Z)=>{if(Z==="utf8"&&Y.every(($)=>typeof $==="string"))return Y;let Q=new YH(Z),X=Y.map(($)=>typeof $==="string"?o5($):$).map(($)=>Q.write($)),J=Q.end();return J===""?X:[...X,J]},F1=(Y)=>{if(Y.length===1&&G0(Y[0]))return Y[0];return X7(JH(Y))},JH=(Y)=>Y.map((Z)=>typeof Z==="string"?o5(Z):Z),X7=(Y)=>{let Z=new Uint8Array($H(Y)),Q=0;for(let X of Y)Z.set(X,Q),Q+=X.length;return Z},$H=(Y)=>{let Z=0;for(let Q of Y)Z+=Q.length;return Z};var Y3=(Y)=>Array.isArray(Y)&&Array.isArray(Y.raw),Z3=(Y,Z)=>{let Q=[];for(let[$,G]of Y.entries())Q=KH({templates:Y,expressions:Z,tokens:Q,index:$,template:G});if(Q.length===0)throw TypeError("Template script must not be empty");let[X,...J]=Q;return[X,J,{}]},KH=({templates:Y,expressions:Z,tokens:Q,index:X,template:J})=>{if(J===void 0)throw TypeError(`Invalid backslash sequence: ${Y.raw[X]}`);let{nextTokens:$,leadingWhitespaces:G,trailingWhitespaces:K}=HH(J,Y.raw[X]),H=r5(Q,$,G);if(X===Z.length)return H;let W=Z[X],z=Array.isArray(W)?W.map((q)=>e5(q)):[e5(W)];return r5(H,z,K)},HH=(Y,Z)=>{if(Z.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let Q=[],X=0,J=t5.has(Z[0]);for(let G=0,K=0;G<Y.length;G+=1,K+=1){let H=Z[K];if(t5.has(H)){if(X!==G)Q.push(Y.slice(X,G));X=G+1}else if(H==="\\"){let W=Z[K+1];if(W===`
|
|
48
|
-
`)G-=1,K+=1;else if(W==="u"&&Z[K+2]==="{")K=Z.indexOf("}",K+3);else K+=zH[W]??1}}let $=X===Y.length;if(!$)Q.push(Y.slice(X));return{nextTokens:Q,leadingWhitespaces:J,trailingWhitespaces:$}},t5=new Set([" ","\t","\r",`
|
|
49
|
-
`]),zH={x:3,u:5},r5=(Y,Z,Q)=>Q||Y.length===0||Z.length===0?[...Y,...Z]:[...Y.slice(0,-1),`${Y.at(-1)}${Z[0]}`,...Z.slice(1)],e5=(Y)=>{let Z=typeof Y;if(Z==="string")return Y;if(Z==="number")return String(Y);if(e(Y)&&(("stdout"in Y)||("isMaxBuffer"in Y)))return WH(Y);if(Y instanceof GH||Object.prototype.toString.call(Y)==="[object Promise]")throw TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw TypeError(`Unexpected "${Z}" in template expression`)},WH=({stdout:Y})=>{if(typeof Y==="string")return Y;if(G0(Y))return c8(Y);if(Y===void 0)throw TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw TypeError(`Unexpected "${typeof Y}" stdout in template expression`)};import{spawnSync as MV}from"node:child_process";import{debuglog as UH}from"node:util";import J7 from"node:process";var y0=(Y)=>l8.includes(Y),l8=[J7.stdin,J7.stdout,J7.stderr],j0=["stdin","stdout","stderr"],i8=(Y)=>j0[Y]??`stdio[${Y}]`;var X3=(Y)=>{let Z={...Y};for(let Q of K7)Z[Q]=$7(Y,Q);return Z},$7=(Y,Z)=>{let Q=Array.from({length:qH(Y)+1}),X=VH(Y[Z],Q,Z);return DH(X,Z)},qH=({stdio:Y})=>Array.isArray(Y)?Math.max(Y.length,j0.length):j0.length,VH=(Y,Z,Q)=>e(Y)?BH(Y,Z,Q):Z.fill(Y),BH=(Y,Z,Q)=>{for(let X of Object.keys(Y).sort(FH))for(let J of RH(X,Q,Z))Z[J]=Y[X];return Z},FH=(Y,Z)=>Q3(Y)<Q3(Z)?1:-1,Q3=(Y)=>{if(Y==="stdout"||Y==="stderr")return 0;return Y==="all"?2:1},RH=(Y,Z,Q)=>{if(Y==="ipc")return[Q.length-1];let X=G7(Y);if(X===void 0||X===0)throw TypeError(`"${Z}.${Y}" is invalid.
|
|
50
|
-
It must be "${Z}.stdout", "${Z}.stderr", "${Z}.all", "${Z}.ipc", or "${Z}.fd3", "${Z}.fd4" (and so on).`);if(X>=Q.length)throw TypeError(`"${Z}.${Y}" is invalid: that file descriptor does not exist.
|
|
51
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);return X==="all"?[1,2]:[X]},G7=(Y)=>{if(Y==="all")return Y;if(j0.includes(Y))return j0.indexOf(Y);let Z=MH.exec(Y);if(Z!==null)return Number(Z[1])},MH=/^fd(\d+)$/,DH=(Y,Z)=>Y.map((Q)=>Q===void 0?TH[Z]:Q),LH=UH("execa").enabled?"full":"none",TH={lines:!1,buffer:!0,maxBuffer:1e8,verbose:LH,stripFinalNewline:!0},K7=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],e0=(Y,Z)=>Z==="ipc"?Y.at(-1):Y[Z];var L6=({verbose:Y},Z)=>H7(Y,Z)!=="none",T6=({verbose:Y},Z)=>!["none","short"].includes(H7(Y,Z)),J3=({verbose:Y},Z)=>{let Q=H7(Y,Z);return n8(Q)?Q:void 0},H7=(Y,Z)=>Z===void 0?_H(Y):e0(Y,Z),_H=(Y)=>Y.find((Z)=>n8(Z))??a8.findLast((Z)=>Y.includes(Z)),n8=(Y)=>typeof Y==="function",a8=["none","short","full"];import{inspect as pH}from"node:util";import{platform as wH}from"node:process";import{stripVTControlCharacters as NH}from"node:util";var $3=(Y,Z)=>{let Q=[Y,...Z],X=Q.join(" "),J=Q.map(($)=>AH(G3($))).join(" ");return{command:X,escapedCommand:J}},R1=(Y)=>NH(Y).split(`
|
|
52
|
-
`).map((Z)=>G3(Z)).join(`
|
|
53
|
-
`),G3=(Y)=>Y.replaceAll(EH,(Z)=>OH(Z)),OH=(Y)=>{let Z=CH[Y];if(Z!==void 0)return Z;let Q=Y.codePointAt(0),X=Q.toString(16);return Q<=kH?`\\u${X.padStart(4,"0")}`:`\\U${X}`},PH=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},EH=PH(),CH={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},kH=65535,AH=(Y)=>{if(IH.test(Y))return Y;return wH==="win32"?`"${Y.replaceAll('"','""')}"`:`'${Y.replaceAll("'","'\\''")}'`},IH=/^[\w./-]+$/;import K3 from"node:process";function z7(){let{env:Y}=K3,{TERM:Z,TERM_PROGRAM:Q}=Y;if(K3.platform!=="win32")return Z!=="linux";return Boolean(Y.WT_SESSION)||Boolean(Y.TERMINUS_SUBLIME)||Y.ConEmuTask==="{cmd::Cmder}"||Q==="Terminus-Sublime"||Q==="vscode"||Z==="xterm-256color"||Z==="alacritty"||Z==="rxvt-unicode"||Z==="rxvt-unicode-256color"||Y.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var H3={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:"╱"},z3={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:"⅒"},jH={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"},xH={...H3,...z3},SH={...H3,...jH},yH=z7(),vH=yH?xH:SH,o8=vH,ID=Object.entries(z3);import fH from"node:tty";var hH=fH?.WriteStream?.prototype?.hasColors?.()??!1,i=(Y,Z)=>{if(!hH)return(J)=>J;let Q=`\x1B[${Y}m`,X=`\x1B[${Z}m`;return(J)=>{let $=J+"",G=$.indexOf(X);if(G===-1)return Q+$+X;let K=Q,H=0,z=(Z===22?X:"")+Q;while(G!==-1)K+=$.slice(H,G)+z,H=G+X.length,G=$.indexOf(X,H);return K+=$.slice(H)+X,K}},SD=i(0,0),W3=i(1,22),yD=i(2,22),vD=i(3,23),fD=i(4,24),hD=i(53,55),bD=i(7,27),gD=i(8,28),mD=i(9,29),uD=i(30,39),dD=i(31,39),pD=i(32,39),cD=i(33,39),lD=i(34,39),iD=i(35,39),nD=i(36,39),aD=i(37,39),s8=i(90,39),oD=i(40,49),sD=i(41,49),tD=i(42,49),rD=i(43,49),eD=i(44,49),YL=i(45,49),ZL=i(46,49),QL=i(47,49),XL=i(100,49),U3=i(91,39),JL=i(92,39),q3=i(93,39),$L=i(94,39),GL=i(95,39),KL=i(96,39),HL=i(97,39),zL=i(101,49),WL=i(102,49),UL=i(103,49),qL=i(104,49),VL=i(105,49),BL=i(106,49),FL=i(107,49);var F3=({type:Y,message:Z,timestamp:Q,piped:X,commandId:J,result:{failed:$=!1}={},options:{reject:G=!0}})=>{let K=bH(Q),H=gH[Y]({failed:$,reject:G,piped:X}),W=mH[Y]({reject:G});return`${s8(`[${K}]`)} ${s8(`[${J}]`)} ${W(H)} ${W(Z)}`},bH=(Y)=>`${t8(Y.getHours(),2)}:${t8(Y.getMinutes(),2)}:${t8(Y.getSeconds(),2)}.${t8(Y.getMilliseconds(),3)}`,t8=(Y,Z)=>String(Y).padStart(Z,"0"),V3=({failed:Y,reject:Z})=>{if(!Y)return o8.tick;return Z?o8.cross:o8.warning},gH={command:({piped:Y})=>Y?"|":"$",output:()=>" ",ipc:()=>"*",error:V3,duration:V3},B3=(Y)=>Y,mH={command:()=>W3,output:()=>B3,ipc:()=>B3,error:({reject:Y})=>Y?U3:q3,duration:()=>s8};var R3=(Y,Z,Q)=>{let X=J3(Z,Q);return Y.map(({verboseLine:J,verboseObject:$})=>uH(J,$,X)).filter((J)=>J!==void 0).map((J)=>dH(J)).join("")},uH=(Y,Z,Q)=>{if(Q===void 0)return Y;let X=Q(Y,Z);if(typeof X==="string")return X},dH=(Y)=>Y.endsWith(`
|
|
1
|
+
import{createRequire as BF}from"node:module";var GF=Object.create;var{getPrototypeOf:$F,defineProperty:w5,getOwnPropertyNames:qF}=Object;var UF=Object.prototype.hasOwnProperty;var OZ=(Y,Z,Q)=>{Q=Y!=null?GF($F(Y)):{};let J=Z||!Y||!Y.__esModule?w5(Q,"default",{value:Y,enumerable:!0}):Q;for(let z of qF(Y))if(!UF.call(J,z))w5(J,z,{get:()=>Y[z],enumerable:!0});return J};var p0=(Y,Z)=>()=>(Z||Y((Z={exports:{}}).exports,Z),Z.exports);var L5=(Y,Z)=>{for(var Q in Z)w5(Y,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:(J)=>Z[Q]=()=>J})};var R=(Y,Z)=>()=>(Y&&(Z=Y(Y=0)),Z);var $Y=BF(import.meta.url);import{createRequire as VF}from"module";class xz{value;start;end;constructor(Y,Z,Q){this.value=Y,this.start=Z,this.end=Q}}class I5{TF;IDF;TF_IDF;constructor(Y){this.TF=Y}}class Ez{x;y;z;r;t;get unit(){return this.#Z}get dimension(){return this.#Q}#Z;#Q=0;constructor(Y,Z,Q=null){if(this.x=Y,this.y=Z,this.z=Q,Q)this.#Q=3;else if(Z)this.#Q=2;else if(Y)this.#Q=1}toPolarCoords(Y="r"){this.#Z=Y;let{r:Z,t:Q}=M.MathKit.toPolarCoords(this.x,this.y,Y);return this.r=Z,this.t=Q,this}toCartesianCoords(){if(!this.#Z&&this.x)return this;let{x:Y,y:Z}=M.MathKit.toCartesianCoords(this.r,this.t,this.#Z);return this.x=Y,this.y=Z,this}setUnit(Y){if(!Y||Y!="d"&&Y!="r")throw Error("unit must be 'r' or 'd', given: "+Y);if(this.#Z==Y)return;if(Y=="r")this.#Z=Y,this.t=M.MathKit.radians(this.t);else this.#Z=Y,this.t=M.MathKit.degrees(this.t)}}class Pz{constructor(Y,Z,Q,J,z,X,H){this.x=Y,this.y=Z,this.f=Q,this.ymid=J,this.iterations=z,this.events=H,this.msg=X}_at(Y,Z){function Q(F){return F*F}let J,z,X,H,W,K,$,G,U,B;return J=this.x[Z],z=this.x[Z+1],H=this.y[Z],W=this.y[Z+1],$=z-J,X=J+0.5*$,K=this.ymid[Z],G=this.f[Z]-H*(1/(J-X)+2/(J-z)),U=this.f[Z+1]-W*(1/(z-X)+2/(z-J)),B=[Q(Y-z)*(Y-X)/Q(J-z)/(J-X),Q(Y-J)*Q(Y-z)/Q(J-X)/Q(z-X),Q(Y-J)*(Y-X)/Q(z-J)/(z-X),(Y-J)*Q(Y-z)*(Y-X)/Q(J-z)/(J-X),(Y-z)*Q(Y-J)*(Y-X)/Q(J-z)/(z-X)],H*B[0]+K*B[1]+W*B[2]+G*B[3]+U*B[4]}at(Y){let Z,Q,J;if(typeof Y!=="number"){let X=Y.length,H=Array(X);for(Z=X-1;Z!==-1;--Z)H[Z]=this.at(Y[Z]);return H}let z=this.x;Z=0,Q=z.length-1;while(Q-Z>1)if(J=Math.floor(0.5*(Z+Q)),z[J]<=Y)Z=J;else Q=J;return this._at(Y,Z)}}class yY{value;index;type;constructor(Y,Z,Q=-1){this.value=Y,this.type=Z,this.index=Q}valueOf(){return this.value}toString(){return this.value.toString()}}class C1{type;UPID=null;callback;constructor(Y,Z,Q=null){if(Q)this.type=1,this.UPID=Q;else this.type=Y;this.callback=Z}}function MF(Y){return Y==null||typeof Y=="number"||typeof Y=="string"||typeof Y=="boolean"||Y instanceof ArrayBuffer||Y instanceof MessagePort||Y instanceof ReadableStream||Y instanceof WritableStream||Y instanceof TransformStream}var FF,T1,RF,vY,_5="[#*0-9]\\uFE0F?\\u20E3|©\\uFE0F?|[®\\u203C\\u2049\\u2122\\u2139\\u2194-\\u2199\\u21A9\\u21AA]\\uFE0F?|[\\u231A\\u231B]|[\\u2328\\u23CF]\\uFE0F?|[\\u23E9-\\u23EC]|[\\u23ED-\\u23EF]\\uFE0F?|\\u23F0|[\\u23F1\\u23F2]\\uFE0F?|\\u23F3|[\\u23F8-\\u23FA\\u24C2\\u25AA\\u25AB\\u25B6\\u25C0\\u25FB\\u25FC]\\uFE0F?|[\\u25FD\\u25FE]|[\\u2600-\\u2604\\u260E\\u2611]\\uFE0F?|[\\u2614\\u2615]|\\u2618\\uFE0F?|\\u261D(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|[\\u2620\\u2622\\u2623\\u2626\\u262A\\u262E\\u262F\\u2638-\\u263A\\u2640\\u2642]\\uFE0F?|[\\u2648-\\u2653]|[\\u265F\\u2660\\u2663\\u2665\\u2666\\u2668\\u267B\\u267E]\\uFE0F?|\\u267F|\\u2692\\uFE0F?|\\u2693|[\\u2694-\\u2697\\u2699\\u269B\\u269C\\u26A0]\\uFE0F?|\\u26A1|\\u26A7\\uFE0F?|[\\u26AA\\u26AB]|[\\u26B0\\u26B1]\\uFE0F?|[\\u26BD\\u26BE\\u26C4\\u26C5]|\\u26C8\\uFE0F?|\\u26CE|[\\u26CF\\u26D1\\u26D3]\\uFE0F?|\\u26D4|\\u26E9\\uFE0F?|\\u26EA|[\\u26F0\\u26F1]\\uFE0F?|[\\u26F2\\u26F3]|\\u26F4\\uFE0F?|\\u26F5|[\\u26F7\\u26F8]\\uFE0F?|\\u26F9(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\u26FA\\u26FD]|\\u2702\\uFE0F?|\\u2705|[\\u2708\\u2709]\\uFE0F?|[\\u270A\\u270B](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\u270C\\u270D](?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|\\u270F\\uFE0F?|[\\u2712\\u2714\\u2716\\u271D\\u2721]\\uFE0F?|\\u2728|[\\u2733\\u2734\\u2744\\u2747]\\uFE0F?|[\\u274C\\u274E\\u2753-\\u2755\\u2757]|\\u2763\\uFE0F?|\\u2764(?:\\u200D(?:\\uD83D\\uDD25|\\uD83E\\uDE79)|\\uFE0F(?:\\u200D(?:\\uD83D\\uDD25|\\uD83E\\uDE79))?)?|[\\u2795-\\u2797]|\\u27A1\\uFE0F?|[\\u27B0\\u27BF]|[\\u2934\\u2935\\u2B05-\\u2B07]\\uFE0F?|[\\u2B1B\\u2B1C\\u2B50\\u2B55]|[\\u3030\\u303D\\u3297\\u3299]\\uFE0F?|\\uD83C(?:[\\uDC04\\uDCCF]|[\\uDD70\\uDD71\\uDD7E\\uDD7F]\\uFE0F?|[\\uDD8E\\uDD91-\\uDD9A]|\\uDDE6\\uD83C[\\uDDE8-\\uDDEC\\uDDEE\\uDDF1\\uDDF2\\uDDF4\\uDDF6-\\uDDFA\\uDDFC\\uDDFD\\uDDFF]|\\uDDE7\\uD83C[\\uDDE6\\uDDE7\\uDDE9-\\uDDEF\\uDDF1-\\uDDF4\\uDDF6-\\uDDF9\\uDDFB\\uDDFC\\uDDFE\\uDDFF]|\\uDDE8\\uD83C[\\uDDE6\\uDDE8\\uDDE9\\uDDEB-\\uDDEE\\uDDF0-\\uDDF5\\uDDF7\\uDDFA-\\uDDFF]|\\uDDE9\\uD83C[\\uDDEA\\uDDEC\\uDDEF\\uDDF0\\uDDF2\\uDDF4\\uDDFF]|\\uDDEA\\uD83C[\\uDDE6\\uDDE8\\uDDEA\\uDDEC\\uDDED\\uDDF7-\\uDDFA]|\\uDDEB\\uD83C[\\uDDEE-\\uDDF0\\uDDF2\\uDDF4\\uDDF7]|\\uDDEC\\uD83C[\\uDDE6\\uDDE7\\uDDE9-\\uDDEE\\uDDF1-\\uDDF3\\uDDF5-\\uDDFA\\uDDFC\\uDDFE]|\\uDDED\\uD83C[\\uDDF0\\uDDF2\\uDDF3\\uDDF7\\uDDF9\\uDDFA]|\\uDDEE\\uD83C[\\uDDE8-\\uDDEA\\uDDF1-\\uDDF4\\uDDF6-\\uDDF9]|\\uDDEF\\uD83C[\\uDDEA\\uDDF2\\uDDF4\\uDDF5]|\\uDDF0\\uD83C[\\uDDEA\\uDDEC-\\uDDEE\\uDDF2\\uDDF3\\uDDF5\\uDDF7\\uDDFC\\uDDFE\\uDDFF]|\\uDDF1\\uD83C[\\uDDE6-\\uDDE8\\uDDEE\\uDDF0\\uDDF7-\\uDDFB\\uDDFE]|\\uDDF2\\uD83C[\\uDDE6\\uDDE8-\\uDDED\\uDDF0-\\uDDFF]|\\uDDF3\\uD83C[\\uDDE6\\uDDE8\\uDDEA-\\uDDEC\\uDDEE\\uDDF1\\uDDF4\\uDDF5\\uDDF7\\uDDFA\\uDDFF]|\\uDDF4\\uD83C\\uDDF2|\\uDDF5\\uD83C[\\uDDE6\\uDDEA-\\uDDED\\uDDF0-\\uDDF3\\uDDF7-\\uDDF9\\uDDFC\\uDDFE]|\\uDDF6\\uD83C\\uDDE6|\\uDDF7\\uD83C[\\uDDEA\\uDDF4\\uDDF8\\uDDFA\\uDDFC]|\\uDDF8\\uD83C[\\uDDE6-\\uDDEA\\uDDEC-\\uDDF4\\uDDF7-\\uDDF9\\uDDFB\\uDDFD-\\uDDFF]|\\uDDF9\\uD83C[\\uDDE6\\uDDE8\\uDDE9\\uDDEB-\\uDDED\\uDDEF-\\uDDF4\\uDDF7\\uDDF9\\uDDFB\\uDDFC\\uDDFF]|\\uDDFA\\uD83C[\\uDDE6\\uDDEC\\uDDF2\\uDDF3\\uDDF8\\uDDFE\\uDDFF]|\\uDDFB\\uD83C[\\uDDE6\\uDDE8\\uDDEA\\uDDEC\\uDDEE\\uDDF3\\uDDFA]|\\uDDFC\\uD83C[\\uDDEB\\uDDF8]|\\uDDFD\\uD83C\\uDDF0|\\uDDFE\\uD83C[\\uDDEA\\uDDF9]|\\uDDFF\\uD83C[\\uDDE6\\uDDF2\\uDDFC]|\\uDE01|\\uDE02\\uFE0F?|[\\uDE1A\\uDE2F\\uDE32-\\uDE36]|\\uDE37\\uFE0F?|[\\uDE38-\\uDE3A\\uDE50\\uDE51\\uDF00-\\uDF20]|[\\uDF21\\uDF24-\\uDF2C]\\uFE0F?|[\\uDF2D-\\uDF35]|\\uDF36\\uFE0F?|[\\uDF37-\\uDF7C]|\\uDF7D\\uFE0F?|[\\uDF7E-\\uDF84]|\\uDF85(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDF86-\\uDF93]|[\\uDF96\\uDF97\\uDF99-\\uDF9B\\uDF9E\\uDF9F]\\uFE0F?|[\\uDFA0-\\uDFC1]|\\uDFC2(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDFC3\\uDFC4](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFC5\\uDFC6]|\\uDFC7(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDFC8\\uDFC9]|\\uDFCA(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFCB\\uDFCC](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDFCD\\uDFCE]\\uFE0F?|[\\uDFCF-\\uDFD3]|[\\uDFD4-\\uDFDF]\\uFE0F?|[\\uDFE0-\\uDFF0]|\\uDFF3(?:\\u200D(?:\\u26A7\\uFE0F?|\\uD83C\\uDF08)|\\uFE0F(?:\\u200D(?:\\u26A7\\uFE0F?|\\uD83C\\uDF08))?)?|\\uDFF4(?:\\u200D\\u2620\\uFE0F?|\\uDB40\\uDC67\\uDB40\\uDC62\\uDB40(?:\\uDC65\\uDB40\\uDC6E\\uDB40\\uDC67|\\uDC73\\uDB40\\uDC63\\uDB40\\uDC74|\\uDC77\\uDB40\\uDC6C\\uDB40\\uDC73)\\uDB40\\uDC7F)?|[\\uDFF5\\uDFF7]\\uFE0F?|[\\uDFF8-\\uDFFF])|\\uD83D(?:[\\uDC00-\\uDC07]|\\uDC08(?:\\u200D\\u2B1B)?|[\\uDC09-\\uDC14]|\\uDC15(?:\\u200D\\uD83E\\uDDBA)?|[\\uDC16-\\uDC3A]|\\uDC3B(?:\\u200D\\u2744\\uFE0F?)?|[\\uDC3C-\\uDC3E]|\\uDC3F\\uFE0F?|\\uDC40|\\uDC41(?:\\u200D\\uD83D\\uDDE8\\uFE0F?|\\uFE0F(?:\\u200D\\uD83D\\uDDE8\\uFE0F?)?)?|[\\uDC42\\uDC43](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC44\\uDC45]|[\\uDC46-\\uDC50](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC51-\\uDC65]|[\\uDC66\\uDC67](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC68(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?|[\\uDC68\\uDC69]\\u200D\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?)|[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92])|\\uD83E[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFC-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?\\uDC68\\uD83C[\\uDFFB-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D\\uDC68\\uD83C[\\uDFFB-\\uDFFE]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|\\uDC69(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:\\uDC8B\\u200D\\uD83D)?[\\uDC68\\uDC69]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?|\\uDC69\\u200D\\uD83D(?:\\uDC66(?:\\u200D\\uD83D\\uDC66)?|\\uDC67(?:\\u200D\\uD83D[\\uDC66\\uDC67])?)|[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92])|\\uD83E[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFC-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D\\uD83D(?:[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF]|\\uDC8B\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFF])|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83D[\\uDC68\\uDC69]\\uD83C[\\uDFFB-\\uDFFE]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|\\uDC6A|[\\uDC6B-\\uDC6D](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC6E(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC6F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDC70\\uDC71](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC72(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC73(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDC74-\\uDC76](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC77(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC78(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC79-\\uDC7B]|\\uDC7C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC7D-\\uDC80]|[\\uDC81\\uDC82](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDC83(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC84|\\uDC85(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC86\\uDC87](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDC88-\\uDC8E]|\\uDC8F(?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDC90|\\uDC91(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDC92-\\uDCA9]|\\uDCAA(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDCAB-\\uDCFC]|\\uDCFD\\uFE0F?|[\\uDCFF-\\uDD3D]|[\\uDD49\\uDD4A]\\uFE0F?|[\\uDD4B-\\uDD4E\\uDD50-\\uDD67]|[\\uDD6F\\uDD70\\uDD73]\\uFE0F?|\\uDD74(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|\\uDD75(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|\\uFE0F(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD76-\\uDD79]\\uFE0F?|\\uDD7A(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD87\\uDD8A-\\uDD8D]\\uFE0F?|\\uDD90(?:\\uD83C[\\uDFFB-\\uDFFF]|\\uFE0F)?|[\\uDD95\\uDD96](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDA4|[\\uDDA5\\uDDA8\\uDDB1\\uDDB2\\uDDBC\\uDDC2-\\uDDC4\\uDDD1-\\uDDD3\\uDDDC-\\uDDDE\\uDDE1\\uDDE3\\uDDE8\\uDDEF\\uDDF3\\uDDFA]\\uFE0F?|[\\uDDFB-\\uDE2D]|\\uDE2E(?:\\u200D\\uD83D\\uDCA8)?|[\\uDE2F-\\uDE34]|\\uDE35(?:\\u200D\\uD83D\\uDCAB)?|\\uDE36(?:\\u200D\\uD83C\\uDF2B\\uFE0F?)?|[\\uDE37-\\uDE44]|[\\uDE45-\\uDE47](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDE48-\\uDE4A]|\\uDE4B(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDE4C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDE4D\\uDE4E](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDE4F(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDE80-\\uDEA2]|\\uDEA3(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDEA4-\\uDEB3]|[\\uDEB4-\\uDEB6](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDEB7-\\uDEBF]|\\uDEC0(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDEC1-\\uDEC5]|\\uDECB\\uFE0F?|\\uDECC(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDECD-\\uDECF]\\uFE0F?|[\\uDED0-\\uDED2\\uDED5-\\uDED7]|[\\uDEE0-\\uDEE5\\uDEE9]\\uFE0F?|[\\uDEEB\\uDEEC]|[\\uDEF0\\uDEF3]\\uFE0F?|[\\uDEF4-\\uDEFC\\uDFE0-\\uDFEB])|\\uD83E(?:\\uDD0C(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD0D\\uDD0E]|\\uDD0F(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD10-\\uDD17]|[\\uDD18-\\uDD1C](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDD1D|[\\uDD1E\\uDD1F](?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD20-\\uDD25]|\\uDD26(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD27-\\uDD2F]|[\\uDD30-\\uDD34](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDD35(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDD36(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD37-\\uDD39](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDD3A|\\uDD3C(?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDD3D\\uDD3E](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDD3F-\\uDD45\\uDD47-\\uDD76]|\\uDD77(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDD78\\uDD7A-\\uDDB4]|[\\uDDB5\\uDDB6](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDB7|[\\uDDB8\\uDDB9](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDBA|\\uDDBB(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDDBC-\\uDDCB]|[\\uDDCD-\\uDDCF](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDD0|\\uDDD1(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD]))|\\uD83C(?:\\uDFFB(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFC-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFC(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB\\uDFFD-\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFD(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB\\uDFFC\\uDFFE\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFE(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFD\\uDFFF]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?|\\uDFFF(?:\\u200D(?:[\\u2695\\u2696\\u2708]\\uFE0F?|\\u2764\\uFE0F?\\u200D(?:\\uD83D\\uDC8B\\u200D)?\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFE]|\\uD83C[\\uDF3E\\uDF73\\uDF7C\\uDF84\\uDF93\\uDFA4\\uDFA8\\uDFEB\\uDFED]|\\uD83D[\\uDCBB\\uDCBC\\uDD27\\uDD2C\\uDE80\\uDE92]|\\uD83E(?:\\uDD1D\\u200D\\uD83E\\uDDD1\\uD83C[\\uDFFB-\\uDFFF]|[\\uDDAF-\\uDDB3\\uDDBC\\uDDBD])))?))?|[\\uDDD2\\uDDD3](?:\\uD83C[\\uDFFB-\\uDFFF])?|\\uDDD4(?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|\\uDDD5(?:\\uD83C[\\uDFFB-\\uDFFF])?|[\\uDDD6-\\uDDDD](?:\\u200D[\\u2640\\u2642]\\uFE0F?|\\uD83C[\\uDFFB-\\uDFFF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?)?|[\\uDDDE\\uDDDF](?:\\u200D[\\u2640\\u2642]\\uFE0F?)?|[\\uDDE0-\\uDDFF\\uDE70-\\uDE74\\uDE78-\\uDE7A\\uDE80-\\uDE86\\uDE90-\\uDEA8\\uDEB0-\\uDEB6\\uDEC0-\\uDEC2\\uDED0-\\uDED6])",M,xT,Sz,ET,PT,ST,vz,vT,yT,qY,fT,bT,yz,hT,gT,mT,uT,dT,pT,cT,lT,iT,n,nT,aT,oT,sT,rT,tT,eT,YC,ZC,QC,h6,JC,zC,XC,HC,WC,KC,GC,$C,qC,UC,fz,BC,VC,FC,k1,RC,bz,v0,DZ,q,MC,OC,DC,NC,wC,hz,LC,_C,IC,jC,TC,CC,kC,AC,xC,EC,PC,SC,vC,yC,fC,bC,A1,hC,fY,T8,gC,mC,uC,a,dC,pC,cC,lC,iC,bY,nC,aC,d;var z0=R(()=>{FF=VF(import.meta.url),T1=typeof window>"u"||typeof process<"u",RF={dgram:null,worker_threads:null,os:null,fs:null,mathjs:null},vY={consoleTimeInstances:null};M={_modules:RF,arrFindLast(Y,Z){for(let Q=Y.length-1;Q>=0;Q--)if(Z(Y[Q],Q,Y))return Y[Q];return},arrToString(Y,Z={}){let{maxDepth:Q=4,indent:J=3,maxRow:z=10,maxCol:X=20,color:H=!1,defColor:W=void 0,noHeader:K=!1}=Z;if(Q<1)Q=1;let $={color:H,defColor:W},G=M.getDimensions(Y,"max"),U=G.length*0.4,B=typeof J=="number"?" ".repeat(J):J,F=null;if(H)F={magenta:M.ncc(11550650),gray:M.ncc(4802889),_default:M.ncc(W)};if(!K&&(!(Y instanceof Array)||G.length>2||Math.max(...G)>5))return N(Y)+V(Y,0);else return V(Y,0);function V(w,L,I=0){let T="";if(L>Q-1)if(H)return F.gray+`... [${O(w)||"Array"}]`+F._default;else return`... [${O(w)||"Array"}]`;if(!M.isArrayLike(w))return T+M.yuString(w,$);let y;if(L>U)y=M.getDimensions(w,"max");else y=G.slice(L);let E=G[L+1]!=null&&(y[2]!=null||y[1]>2)&&L<Q-1,P=I?B.repeat(I):"",m=P+B,g=E?`[
|
|
2
|
+
`+m:"[",b=E?`
|
|
3
|
+
`+P+"]":"]",c=w.length;T+=g;for(let Y0=0;Y0<c;Y0++){if(M.isArrayLike(w[Y0]))T+=O(w[Y0])+V(w[Y0],L+1,E?I+1:I);else T+=M.yuString(w[Y0],$);if(E){if(Y0>=z-2){if(T+=`,
|
|
4
|
+
`+m,H)T+=F.gray+"... ("+(c-z+1)+" more)"+F._default;else T+="... ("+(c-z+1)+" more)";break}}else if(Y0>=X-2){if(H)T+=", "+F.gray+"... ("+(c-X+1)+" more)"+F._default;else T+=", ... ("+(c-X+1)+" more)";break}if(Y0!=c-1)T+=E?`,
|
|
5
|
+
`+m:", "}return T+=b,T}function O(w){if(w instanceof Array)return"";if(H)return F.magenta+`${w.constructor.name}: `+F._default;else return`${w.constructor.name}: `}function N(w){if(!M.isArrayLike(w))return"";if(H)return F.magenta+`${w.constructor.name}(${G}): `+F._default;else return`${w.constructor.name}(${G}): `}},argvHasFlag(Y,Z=process?.argv){if(!Z||typeof Y!="string")return!1;let Q=Y.startsWith("-")?"":Y.length===1?"-":"--",J=Z.indexOf(Q+Y),z=Z.indexOf("--");return J!==-1&&(z===-1||J<z)},async asyncSleep(Y){return new Promise((Q)=>{if(!Y||Y<4||typeof Y!="number")Q();setTimeout(Q,Y)})},beautifyJson(Y){Y=Y.replace(/\s/,"");let Z=Y+"",Q=M.getMatchAllIndexes(Y.matchAll(/[{[]/g)).sort((H,W)=>H-W),J=M.getMatchAllIndexes(Y.matchAll(/[}\]]/g)).sort((H,W)=>H-W);for(let H=0,W=0,K=0;K<Y.length;){let $=Q[X(Q,K)],G=J[X(J,K)];if($=$==null?1/0:$,$<G)H++,K=$+1;else H--,K=G+1;let U=Q[X(Q,K)],B=J[X(J,K)],F=U<B?U:B,V="".padEnd(H,"\t");if(z(Z[K+W-1]))Z=M.strSplice(Z,K+W,0,`
|
|
6
|
+
`);else Z=M.strSplice(Z,K+W-1,0,`
|
|
7
|
+
`),Z=M.strSplice(Z,K+W,0,V),W+=V.length;W++;let O=Y.substring(K,F),N=M.getMatchAllIndexes(O.matchAll(/"/g)).filter((L)=>L!=0?O[L-1]!="\\":!0);if(N.length%2!=0)throw Error('cannot match Double-Quote correctly from string: "'+O+'"');let w=M.getMatchAllIndexes(O.matchAll(/[,]/g)).filter((L)=>{for(let I=0;I<N.length;I+=2)if(L>N[I]&&L<N[I+1])return!1;return!0});for(let L=0;L<w.length+1;L++){let I=L==0?K+W:w[L-1]+W+K+1;if(z(Z[I-1])==null)Z=M.strSplice(Z,I,0,V),W+=V.length;if(!Z[w[L]+W+K])break;Z=M.strSplice(Z,w[L]+1+W+K,0,`
|
|
8
|
+
`),W++}}return Z;function z(H){let W=new RegExp(/[{[]/),K=new RegExp(/[}\]]/);if(W.test(H))return 1;if(K.test(H))return 0;return null}function X(H,W){let K=1/0,$;for(let G=0,U=H[G];G<H.length;U=H[++G]){let B=U-W;if(!B)return G;if(B<0)continue;if(B<K)K=B,$=G}return $}},beforeExit(Y,Z=!1){if(Z)process.stdin.resume();let Q=!1,J=!1;["exit","SIGINT","SIGUSR1","SIGUSR2","uncaughtException","SIGTERM"].forEach((z)=>{process.on(z,(...X)=>{if(["SIGINT","SIGUSR1","SIGUSR2"].includes(z))if(Q)console.log("Forcefully Exiting..."),process.exit(1);else Q=!0;if(J)return;else J=!0;let H=Y(z,...X);if(H instanceof Promise){H.then(()=>{if(z!=="exit"&&Z)process.exit(0)}).catch((W)=>{if(console.error("Error in beforeExit callback:",W),z!=="exit"&&Z)process.exit(1)});return}if(z!=="exit"&&Z)process.exit(0)})})},changeDateTimezone(Y,Z){let Q=new Date(`${Y.toLocaleString("en-US",{timeZone:Z})}`),J=Y.getTime()-Q.getTime();return new Date(Y.getTime()-J)},charTypeAt(Y,Z){let Q=M.CONSTS.UNICODES_RANGE_TABLE;if(Y<0)Y=Z.length+Y;let J=Z.charCodeAt(Y);if(isNaN(J))return null;for(let z=Q.length>>1,X=0;z>=0&&z<Q.length;X++){if(X>(Q.length>>1)+1)break;if(M.isArrayLike(Q[z].to)){for(let H=0;H<Q[z].to.length;H++)if(J>=Q[z].from[H]&&J<=Q[z].to[H])return Q[z].type;if(J>Q[z].from[0])z++;else z--}else{if(J>=Q[z].from&&J<=Q[z].to)return Q[z].type;if(J>Q[z].from)z++;else z--}}return null},CheckCache:class Y{static#Z=null;static#Q=null;static#Y=null;static get supportsColor(){if(this.#Z==null)this.#Z=M.supportsColor();return this.#Z??0}static get supportsHyperlink(){if(this.#Q==null)this.#Q=M.supportsHyperlink();return this.#Q}static set supportsColor(Z){this.#Z=Z}static set supportsHyperlink(Z){this.#Q=Z}static get forceColor(){if(!T1)this.#Y=!1;if(this.#Y===void 0){let Z=process.env;if(M.argvHasFlag("no-color")||M.argvHasFlag("no-colors")||M.argvHasFlag("color=false"))this.#Y=!1;else if(M.argvHasFlag("color")||M.argvHasFlag("colors")||M.argvHasFlag("color=true")||M.argvHasFlag("color=always"))this.#Y=!0;if("FORCE_COLOR"in Z)this.#Y=Z.FORCE_COLOR.length===0||parseInt(Z.FORCE_COLOR,10)!==0}return this.#Y}static set forceColor(Z){this.#Y=Z}},cleanArr(Y,Z=null){if(Z&&Z instanceof Array)return Y.filter((Q)=>{return!Z.includes(Q)});if(Z!==null)return Y.filter((Q)=>{return Q!==Z});return Y.filter((Q)=>Q!==""&&Q!=="\r"&&!M.isEmptyArray(Q)&&!M.isEmptyObject(Q))},cleanComments(Y){return Y.replace(M.REGEXP.JSComments,(Z,Q)=>Q?"":Z)},cleanString(Y){return Y.normalize().replace(M.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]/g,from:new Int16Array([11904,13312,19968,63744,12288,12353,12448]),to:new Int16Array([12245,19893,40907,64106,12351,12438,12543])}),Object.freeze({type:"generic.cn.full",regex:/[\u4e00-\u9fff]/g,from:19968,to:40959}),Object.freeze({type:"generic.jp.half",regex:/[\uff5f-\uff9f]/g,from:65375,to:65439})],AsyncFunction:(async()=>{}).constructor,GeneratorFunction:function*(){}.constructor}),Convert:{decimalColorToRGB(Y){return{r:Y>>16&255,g:Y>>8&255,b:Y&255}},basicColorFromRgb(Y){let Z=Y.r>127,Q=Y.g>127,J=Y.b>127;switch(Z+Q+J){case 3:return"white";case 0:return"black";case 2:if(!Z)return"cyan";else if(!Q)return"magenta";else if(!J)return"yellow";case 1:if(Z)return"red";else if(Q)return"green";else if(J)return"blue"}},_8bitColorFromRgb(Y){let{r:Z,g:Q,b:J}=Y;if(Z===Q&&Q===J){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}let z=Math.round(Z/255*5),X=Math.round(Q/255*5),H=Math.round(J/255*5);return 16+36*z+6*X+H}},ConsoleTime:class Y{static lookbackLimit=100;static elipsedStart(Z){if(vY.consoleTimeInstances==null){vY.consoleTimeInstances=new Map([[Z,[M.getProcessTime()]]]);return}if(!vY.consoleTimeInstances.has(Z)){vY.consoleTimeInstances.set(Z,[M.getProcessTime()]);return}let Q=vY.consoleTimeInstances.get(Z);if(Q.unshift(M.getProcessTime()),this.lookbackLimit>0&&Q.length>=this.lookbackLimit)Q.pop()}static elipsedEnd(Z){if(!vY.consoleTimeInstances.has(Z))return;let Q=vY.consoleTimeInstances.get(Z),J=Q[0];Q[0]=M.getProcessTime()-J}static condense(Z){let Q=vY.consoleTimeInstances.get(Z);if(!Q)return null;let J=0;for(let z of Q)J+=z;return J/=Q.length,vY.consoleTimeInstances.delete(Z),{print(){console.log(Z+": "+M.toShortNum(J)+"s")},valueOf:()=>J,toString:()=>Z+": "+M.toShortNum(J)+"s",value:J}}},compareDate(Y,Z,Q,J="day"){if(!Y||!Q)return!1;let z=K(Y),X=K(Q),H=z.next(),W=X.next();do if(H.value!==W.value)switch(Z){case">":return H.value>W.value;case"<":return H.value<W.value;case">=":return H.value>=W.value;case"<=":return H.value<=W.value;default:return!1}while(!(H=z.next()).done&&!(W=X.next()).done);return Z[1]==="=";function*K($){if(yield $.getFullYear(),J==="year")return;if(yield $.getMonth(),J==="month")return;yield $.getDate()}},DataScienceKit:{frequencyOf(Y){if(!Y||typeof Y!="string"&&!M.isArrayLike(Y))return new Map;let Z=[...new Set(Y)],Q=new Map(Z.map((J)=>[J,0]));for(let J of Y)Z.forEach((z)=>{if(z==J)Q.set(z,Q.get(z)+1)});return Q},LCS_of(Y,Z,Q=(J,z)=>J===z){if(!(Y?.length&&Z?.length))return[];let J=[],z=Z.length,X=Y.length;while(J.length<X)J.push(Array(z));for(let $=0;$<J.length;$++)for(let G=0;G<J[$].length;G++){if(Q(Y[$],Z[G])){let F=K($-1,G-1);J[$][G]=[F+1,3];continue}let U=K($,G-1),B=K($-1,G);if(U>B)J[$][G]=[U,2];else J[$][G]=[B,1]}let H=[];return W(X-1,z-1),H;function W($,G){if($<0||G<0)return;switch(J[$][G][1]){case 1:W($-1,G);break;case 2:W($,G-1);break;case 3:H.unshift(Y[$]),W($-1,G-1);break}}function K($,G){if($<0||G<0)return 0;else return J[$][G][0]}},LCSLength_of(Y,Z,Q=(J,z)=>J===z){if(!(Y?.length&&Z?.length))return 0;let J=[],z=Z.length,X=Y.length;while(J.length<X)J.push(Array(z));for(let W=0;W<J.length;W++)for(let K=0;K<J[W].length;K++){if(Q(Y[W],Z[K])){let U=H(W-1,K-1);J[W][K]=[U+1,3];continue}let $=H(W,K-1),G=H(W-1,K);if($>G)J[W][K]=[$,2];else J[W][K]=[G,1]}return J[X-1][z-1][0];function H(W,K){if(W<0||K<0)return 0;else return J[W][K][0]}},TFIDF_of(Y){let Z=Y.length,Q=Array(Z),J=new Map;for(let X=0;X<Z;X++){let H=Y[X].length,W=M.DataScienceKit.frequencyOf(Y[X]);Q[X]=new Map;for(let K=0;K<H;K++){if(!Q[X].has(Y[X][K]))Q[X].set(Y[X][K],new I5(W.get(Y[X][K])/H));if(!J.has(Y[X][K]))J.set(Y[X][K],0)}}let z=[...J.keys()];for(let X=0;X<z.length;X++)for(let H of Y)if(H.includes(z[X]))J.set(z[X],J.get(z[X])+1);for(let[X,H]of J)J.set(X,Math.log10(Z/H));for(let X of Q)for(let[H,W]of X)W.IDF=J.get(H),W.TF_IDF=W.IDF*W.TF;return Q},TFIDF_extends(Y,Z){let Q=Y.concat(Array(Z.length)),J=new Map,z=Q.length;for(let H=0;H<z;H++){let W,K,$=!1,G=H-Y.length;if(!Q[H])$=!0,W=Z[G].length,K=M.DataScienceKit.frequencyOf(Z[G]),Q[H]=new Map;else W=Q[H].size;for(let U=0;U<W;U++){if($&&!Q[H].has(Z[G][U])){if(Q[H].set(Z[G][U],new I5(K.get(Z[G][U])/W)),!J.has(Z[G][U]))J.set(Z[G][U],0);continue}let B=[...Q[H].keys()][U];if(!J.has(B))J.set(B,0)}}let X=[...J.keys()];for(let H=0;H<X.length;H++)for(let W of Q)if(W.has(X[H]))J.set(X[H],J.get(X[H])+1);for(let[H,W]of J)J.set(H,Math.log10(z/W));for(let H of Q)for(let[W,K]of H)K.IDF=J.get(W),K.TF_IDF=K.IDF*K.TF;return Q},wagnerFischer_of(Y,Z,Q=(J,z)=>J===z){let J=[],z,X;for(z=0;z<=Y.length;z++)J[z]=[z];for(X=0;X<=Z.length;X++)J[0][X]=X;for(z=1;z<=Y.length;z++)for(X=1;X<=Z.length;X++){if(Q(Y[z-1],Z[X-1])){J[z][X]=J[z-1][X-1];continue}J[z][X]=Math.min(J[z-1][X-1]+1,Math.min(J[z][X-1]+1,J[z-1][X]+1))}return{distance:J[Y.length][Z.length],getOperations(){let H=J.length-1,W=J[0].length-1,K=[],$=new M.SafeTrue;while((H>0||W>0)&&$.True)switch(G(H,W,J)){case 2:K.push({type:"delete",index:H-1,value:Y[H-1]}),H--;break;case 0:K.push({type:"insert",index:H,value:Z[W-1]}),W--;break;case 1:if(J[H][W]!==J[H-1][W-1])K.push({type:"replace",index:H-1,value:Z[W-1]});H--,W--;break}return K;function G(U,B,F){let V=[F[U][B-1],F[U-1][B-1],F[U-1][B]];if(B<=0)return 2;if(U<=0)return 0;if(V[0]==V[1])if(V[2]==V[1])return 1;else return 0;let O=V[0],N=0;for(let w=1;w<V.length;w++)if(V[w]<O)O=V[w],N=w;return N}}}}},deferredFunc(Y,Z=200,Q=!1){let J=null;return function(...z){let X=!1;if(Q&&!J)Y(...z),X=!0;clearTimeout(J),J=setTimeout(()=>{if(J=null,!X)Y(...z)},Z)}},digitAt(Y,Z){try{return parseInt((Z+"").at(Y))}catch{return 0}},digitAtRange(Y,Z,Q){if(!Q)return;Y=Y<0?void 0:Y??void 0,Z=Z<0?void 0:Z??void 0;let J=(Q+"").slice(Y,Z);return parseInt(J.length?J:"0")},getDimensions(Y,Z="max"){let Q=[],J=Z==="min"?Math.min:Math.max,z=Z==="min"?1/0:0,X=z,H=[],W=0;if(!M.isArrayLike(Y))return Q;if(Q.push(Y.length),Z==="symmetric")K(Y,0);else $(Y,0,!0);return Q;function K(G,U){if(!M.isArrayLike(G?.[Q[U]-1]))return;Q.push(G[Q[U]-1].length),K(G[Q[U]-1],U+1)}function $(G,U,B=!1,F=[]){for(let V=0;V<Q[U];V++){if(!M.isArrayLike(G[V]))continue;if(G[V].length!=X){if(Z==="fixed"&&X!==z)throw Error(`Array length mismatched at depth ${U+1} position (${[...F,V].join(",")}):
|
|
9
|
+
expected length: ${X}
|
|
10
|
+
actual length: ${G[V].length}`);X=J(X,G[V].length)}H.push([G[V],U+1,!1,[...F,V]])}if(B&&X!==z){Q.push(X),X=z;let V=[...H];H=[];for(let O=0;O<V.length;O++){if(O==V.length-1)V[O][2]=!0;if(++W>5000){queueMicrotask(()=>{W=0,$(...V[O])});continue}$(...V[O])}}}},Err:class Y extends Error{constructor(Z,Q=null,J=null,z=null){if(M.isError(Z)){if(!Q)Q=Z.name;if(!J)J=Z.code;if(!z)z=Z.stack;Z=Z.message}super(Z);if(Q)this.name=Q;if(J)this.code=J;if(z)this.stack=z}toString(Z={}){if(!this||!M.isError(this))return"[Error unknown]";return M.Err.toString(this,Z)}static from(Z,Q=null,J=null,z=null){return new M.Err(Z,Q,J,z)}static isError(Z){if(Z instanceof Error)return!0;if(Object.prototype.isPrototypeOf.call(Error.prototype,Z))return!0;return typeof Z?.message=="string"&&typeof Z?.stack=="string"}static toString(Z,Q={}){let{color:J=!1,defColor:z=void 0}=Q,X=(J?M.ncc("Red")+"ERROR"+M.ncc(z):"ERROR")+" Message: ";if(J)X+=M.ncc("Red")+(Z?.message??"[unknown]")+M.ncc(z);else X+=Z?.message??"[unknown]";if(Z?.name)if(X+=`
|
|
11
|
+
Name: `,J)X+=M.ncc("Red")+Z.name+M.ncc(z);else X+=Z.name;if(Z?.code)if(X+=`
|
|
12
|
+
Code: `,J)X+=M.ncc("Yellow")+Z.code+M.ncc(z);else X+=Z.code;if(Z?.stack)if(X+=`
|
|
13
|
+
Stack: `,J)X+=M.ncc(5592405)+Z.stack+M.ncc(z);else X+=Z.stack;return X}},escapeRegExp(Y){return Y.replace(/[[\]{}.*$^|\-?+,:\\]/g,"\\$&")},ex_length(Y,Z=0){if(typeof Y!=="string")throw TypeError("argument must be a string");if(Z<0)return Y.length;Y=M.cleanString(Y);let Q=Y.length;if(Z<1)return Q;let J=Y;for(let W of M.CONSTS.UNICODES_RANGE_TABLE){if(!W.type.endsWith("full"))continue;J=J.replace(W.regex,"")}let z=Q+(Q-J.length);if(Z<2)return z;let X=Y.match(M.REGEXP.EmojiEach)??[],H=X.reduce((W,K)=>W+K.length,0);return X.length*2+(z-H)},fileNameCleaner(Y,Z="_"){if(!Y||typeof Y!="string")throw Error("the given `rawName` isn't a string");return Y.trim().replace(/[|/*\\<>"?:]/g,Z)},fixFilePath(Y,Z="_"){if(!Y||!Y?.length)throw"path is either falsy or empty!";return Y.replace(/[:?"<>|*]/g,Z)},fixYTurl(Y){if(Y=Y||void 0,!Y)throw"url can't be falsy!!";if(Y.includes("youtu.be"))Y=Y.replace("https://youtu.be/","https://www.youtube.com/watch?v=");if(Y.includes("&list="))Y=Y.split("&list=")[0];if(Y.includes("?si="))Y=Y.split("?si=")[0];if(Y.includes("https")==!1)Y="https://www."+Y;return Y},fileTypeOf(Y){let Z=Y.slice(Y.lastIndexOf(".")+1).toLowerCase(),Q=Z=="jpg"||Z=="png"||Z=="svg"||Z=="jfif"||Z=="pbm"||Z=="pgm"||Z=="jpeg",J=Z=="txt"||Z=="bat"||Z=="text"||Z=="md"||Z=="json"||Z=="step"||Z=="js"||Z=="cs"||Z=="cpp"||Z=="gitignore"||Z=="java"||Z=="py"||Z=="config"||Z=="cfg"||Z=="ts"||Z=="env",z=Z=="exe"||Z=="vpk"||Z=="qc"||Z=="smd"||Z=="vmt"||Z=="vtf"||Z=="zip"||Z=="7z"||Z=="bin"||Z=="ipynb"||Z=="pyc"||Z=="jar",X=Z=="aiff"||Z=="aif"||Z=="aifc"||Z=="flac"||Z=="mp3"||Z=="mp4"||Z=="mp4a"||Z=="m4a"||Z=="mkv"||Z=="mov"||Z=="wav"||Z=="gif"||Z=="webm";if(Q)return"image";else if(J)return"text";else if(z)return"binary";else if(X)return"media";return null},getMatchAllIndexes(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(Q.index);return Z},getMatchAllResults(Y){if(!Y)return[];let Z=[];for(let Q of Y)Z.push(new xz(Q[0],Q.index,Q.index+Q[0].length));return Z},getRandomInt(Y,Z){return Math.round(Math.random()*(Z-Y)+Y)},getProcessTime(){let Y=process.hrtime();return Y[0]*1000+Y[1]/1e6},hyperLink(Y,Z){if(Z=encodeURI(Z.replace(/\\/g,"/")),!M.CheckCache.supportsHyperlink)return Z;return`\x1B]8;;${Z}\x07${Y}\x1B]8;;\x07`},IDGenerator(Y=null,Z="CCNNNN"){let Q=!1,J=Z.length,z=new M.SafeTrue;while(z.True){let X=Array(J);for(let H=0;H<J;H++)switch(Z[H]){case"C":{let W=M.getRandomInt(65,116);if(W>90)W+=6;X[H]=String.fromCharCode(W);continue}case"N":X[H]=M.getRandomInt(0,9).toString();continue;case"B":{let W=M.getRandomInt(48,109);if(W>57&&W<84)W+=7;else if(W>83)W+=13;X[H]=String.fromCharCode(W);continue}default:X[H]=Z[H];break}if(Y){if(Y instanceof Set)Q=Y.has(X);else Q=Y.includes(X);if(!Q)return X.join("")}else return X.join("")}return null},includesWord(Y,Z,Q=!1){if(!Q)Z=Z.toLowerCase(),Y=Y.toLowerCase();Z=Z.padStart(Z.length+1," ").padEnd(Z.length+2," ");let J=Z.search(Y);if(J!==-1){let z=Z.substring(J-1),X=Z.substring(J+Y.length);if(z.search(M.REGEXP.Seperators)==0&&X.search(M.REGEXP.Seperators)==0)return!0}return!1},IPC:class Y{static Listener=C1;#Z;#Q=new Map;#Y;#J=!1;#z=new Set;peersAddress="localhost";peersPort;listenPort;get protocol(){return this.#Y}constructor(Z="udp4",Q={}){if(!T1)throw Error("IPC is only available on JSRuntime, due to the use of Node modules");let{peersPort:J=null,peersAddress:z=null,listenPort:X=null}=typeof Q=="number"?{listenPort:Q}:Q;if(Z!="nodeworker"&&Z!="udp4"&&Z!="udp6")throw Error(`protocol must be 'nodeworker', 'udp4' or 'udp6' instead given '${Z}'`);if(this.#Y=Z,!M._modules.dgram&&Z!="nodeworker")throw Error(`module 'dgram' not loaded use 'Tools._modules.dgram = require("dgram")' to load it`);if(Z=="nodeworker"){if(!M._modules.worker_threads)throw Error(`module 'worker_threads' not loaded use 'Tools._modules.worker_threads = require("worker_threads")' to load it`);if(!X){if(M._modules.worker_threads.isMainThread)throw Error("when using `nodeworker` protocol, `port` must be provided if on the main thread");this.#Z=M._modules.worker_threads.parentPort,this.#X();return}if(!(X instanceof M._modules.worker_threads.Worker)&&X!==M._modules.worker_threads.parentPort&&X!=null)throw Error(`port must be a type of 'Worker' or a 'parentPort' instead given '${typeof X}'`);this.#Z=X,this.#X();return}if(!J)throw Error("peersPort must be provided for `udp4` or `udp6` protocol");this.listenPort=X,this.peersAddress=z,this.peersPort=J,this.#Z=M._modules.dgram.createSocket(Z),this.#X()}async#X(){if(this.#Z.on("message",this.#H),this.protocol=="nodeworker")return;if(!this.listenPort)return;try{this.#Z.bind(this.listenPort),this.#J=!0}catch(Z){switch(Z.code){case"ERR_SOCKET_BAD_PORT":throw new M.Err(`Tools.IPC: port ${this.listenPort} is not valid`,"IPC_ERR_SOCKET_BAD_PORT",Z.code,Z.stack);case"EADDRINUSE":throw new M.Err(`Tools.IPC: port ${this.listenPort} is already in use`,"IPC_EADDRINUSE",Z.code,Z.stack);default:throw M.Err.from(Z,"IPC_BIND_ERROR").message=`Tools.IPC: failed to bind port ${this.listenPort} `+Z.message}}}bind(Z,Q){if(this.protocol=="nodeworker")return;if(this.peersAddress=Z,this.listenPort=Q,!this.#J)this.#X();return this}close(){if(this.protocol=="nodeworker")return;this.#Z.close()}async advSend(Z,Q){return new Promise((J,z)=>{if(!Z)throw Error("channel must be provided");if(typeof Z!="string")throw Error(`channel must be a type of 'string' instead given '${typeof Z}'`);let{contents:X,UPID:H}=Q;if(!(X instanceof Array))X=[X];let W;try{W=this.protocol=="nodeworker"?{channel:Z,UPID:H,contents:X.map((K)=>{if(MF(K))return K;return"@JSON:"+JSON.stringify(K,M.JSONReplacer)})}:Buffer.from(JSON.stringify({channel:Z,UPID:H,contents:X},M.JSONReplacer))}catch(K){z(M.Err.from(K,"IPC_SERIALIZE_ERROR").message="Tools.IPC: failed to serialize payload,"+K.message);return}if(this.protocol=="nodeworker"){this.#Z.postMessage(W),J();return}this.#Z.send(W,this.peersPort,this.peersAddress,(K)=>{if(K)z(K);J()})})}async send(Z,...Q){return this.advSend(Z,{contents:Q})}on(Z,Q){let J=this.#Q.get(Z);if(!J){this.#Q.set(Z,[new C1(0,Q)]);return}return J.push(new C1(0,Q)),this}once(Z,Q,J=null){let z=this.#Q.get(Z);if(!z){this.#Q.set(Z,[new C1(1,Q,J)]);return}return z.push(new C1(1,Q,J)),this}remove(Z){if(typeof Z=="string")return this.#Q.delete(Z),!0;if(typeof Z!="function")throw Error(`listener must be a type of 'string' or 'function' instead given '${typeof Z}'`);for(let[Q,J]of this.#Q){let z=J.find((H)=>H.callback==Z);if(!z)continue;if(!J.filter((H)=>H.callback!=Z))return this.#Q.delete(Q),!0;return this.#Q.set(Q,J.filter((H)=>H.callback!=z)),!0}return!1}async ask(Z,Q,...J){return new Promise((z,X)=>{let H;if(Q)H=setTimeout(()=>{X(new M.Err(`Tools.IPC: ask timeout on channel: ${Z}`,"IPCAskTimeout"))},Q);let W=this.#W();this.once(Z,(K)=>{if(Q)clearTimeout(H);z(K)},W),this.advSend(Z,{contents:J,UPID:W})})}onAsk(Z,Q){let J=this,z=async function(...X){J.#z.add(this.UPID);let H=await Q(...X);J.advSend(Z,{contents:[H],UPID:this.UPID}),J.#z.delete(this.UPID)};return this.on(Z,z),this}#H=(Z)=>{let Q;try{Q=this.protocol=="nodeworker"?{channel:Z.channel,UPID:Z.UPID,contents:Z.contents.map((z)=>{if(typeof z=="string"&&z.startsWith("@JSON:"))return JSON.parse(z.slice(6),M.JSONReviver);return z})}:JSON.parse(Z.toString(),M.JSONReviver)}catch(z){throw M.Err.from(z,"IPC_DESERIALIZE_ERROR").message="Tools.IPC: failed to deserialize payload,"+z.message}let J=this.#Q.get(Q.channel);if(!J)return;for(let z of J){if(z.UPID){if(z.UPID!=Q.UPID)continue;this.#z.delete(z.UPID)}if(z.callback.call(Q,...Q.contents),z.type==1||z.UPID)this.remove(z.callback)}};#W(){let Z=M.IDGenerator(this.#z,"BBBBBBBB");return this.#z.add(Z),Z}},isArrayLike(Y){let Z=Y?.length;return Array.isArray(Y)||!!Y&&Z!=null&&typeof Y==="object"&&typeof Z==="number"&&(Z===0||Z>0&&(Z-1 in Y))},isArrowFunction(Y){if(typeof Y!=="function")return!1;if(Object.hasOwnProperty.call(Y,"prototype"))return!1;try{return Y.arguments,!1}catch{}return Y.toString().slice(0,20).includes("=>")},isAsyncFunction(Y){if(typeof Y!=="function")return!1;if(Y.constructor?.name==="AsyncFunction")return!0;return(Y instanceof M.CONSTS.AsyncFunction&&M.CONSTS.AsyncFunction!==Function&&M.CONSTS.AsyncFunction!==M.CONSTS.GeneratorFunction)===!0},isClass:(Y)=>{if(typeof Y!=="function")return!1;return Y.toString().startsWith("class")},isNumber:(Y)=>{return/^[0-9]+$|^[0-9]+\\.[0-9]+$/.test(Y)},isEmptyArray:(Y)=>M.isArrayLike(Y)&&!Y.length,isEmptyObject:(Y)=>!M.isArrayLike(Y)&&Y instanceof Object&&!M.propertiesCount(Y),isError(Y){return M.Err.isError(Y)},isValidFilePath(Y){if(!Y||!Y?.length)return!1;if(/[:?"<>|*]/g.test(Y))return!1;return!0},JSONReplacer(Y,Z){if(Z instanceof Map)return{"@dataType":"Map","@value":Array.from(Z.entries())};if(Z instanceof Set)return{"@dataType":"Set","@value":Array.from(Z.values())};switch(typeof Z){case"function":return{"@dataType":"function","@value":Z.toString().replace(/\n* {2,}|\n/g,"")};case"bigint":return{"@dataType":"BigInt","@value":Z.toString()};case"object":for(let Q in Z)if(Z[Q]instanceof Date)Z[Q]={"@dataType":"Date","@value":Z[Q].valueOf()};return Z}return Z},JSONReviver(Y,Z){if(!Z||!Z["@dataType"])return Z;switch(Z["@dataType"]){case"function":return Function("return "+Z["@value"])();case"BigInt":return BigInt(Z["@value"]);case"Map":return new Map(Z["@value"]);case"Set":return new Set(Z["@value"]);case"Date":return new Date(Z["@value"])}return Z},jsTime:{howLong(Y,Z=new Date){let Q=Z.getTime()-Y.getTime();return M.jsTime.getTimeFromMS(Q).modern()},getTimeFromMS(Y){let Z=0,Q=0,J=0,z=0,X=0,H=0,W=Y>262800200;while(Y>=1000)Y-=1000,H++;while(H>=60)H-=60,X++;while(X>=60)X-=60,z++;if(W){while(z>=24)z-=24,J++;while(J>=30.4167)J-=30.4167,Q++;J=Math.round(J);while(Q>=12)Q-=12,Z++}if(W)return{year:Z,month:Q,days:J,hr:z,min:X,sec:H,ms:Y,toString(){return`${Z}:${Q}:${J}|${z}:${X}:${H}.${Math.round(Y).toString().padStart(3,"0")}`},modern(){if(Z+Q+J+H+X+z==0)return`${M.maxFraction(Y,4)}ms`;else if(Z+Q+J+X+z==0)return`${H}.${Math.round(Y).toString().padStart(3,"0")}s`;else if(Z+Q+J+z==0)return`${X}min ${H}s`;else if(Z+Q+J==0)return`${z}hr ${X}min`;else if(Z+Q==0)return`${J}days ${z}hr`;else if(Z==0)return`${Q}months ${J}days`;else return`${Z}year ${Q}months`}};return{year:Z,month:Q,days:J,hr:z,min:X,sec:H,ms:Y,toString(){return`${z}:${X}:${H}.${Math.round(Y).toString().padStart(3,"0")}`},modern(){if(H+X+z==0)return`${M.maxFraction(Y,4)}ms`;else if(X+z==0)return`${H}.${Math.round(Y).toString().padStart(3,"0")}s`;else if(z==0)return`${X}min ${H}s`;else return`${z}hr ${X}min`}}}},lazySplit:function*(Y,Z){if(Z===""){for(let z of Y)yield z;return}let Q=0,J;while((J=Y.indexOf(Z,Q))!==-1)yield Y.substring(Q,J),Q=J+Z.length;yield Q?Y.substring(Q):Y},remap(Y,Z){if(Y instanceof Map){let J=new Map;for(let[z,X]of Y){let H=Z(z,X,J);if(H===void 0)continue;if(H===null)J.set(z,X);if(H.key===void 0)J.set(z,H);if(J.set(H.key,H.value),H.key!==z&&J.has(z))J.delete(z)}return J}let Q={};for(let J in Y){let z=Z(J,Y[J],Q);if(z===void 0)continue;if(z===null){Q[J]=Y[J];continue}if(z.key===void 0){Q[J]=z;continue}if(Q[z.key]=z.value,z.key!==J&&Q[J]!==void 0)delete Q[J]}return Q},MathKit:{clamp(Y,Z,Q){return Math.min(Math.max(Y,Z),Q)},degrees(Y){return Y*180/Math.PI},distanceFrom(Y,Z){let Q=Z.x-Y.x,J=Z.y-Y.y,z=Z.z-Y.z;return Math.sqrt(Q**2+(isNaN(J)?0:J**2)+(isNaN(z)?0:z**2))},dopri(Y,Z,Q,J,z=0.000001,X=1000,H){let W=[Y],K=[Q],$=[J(Y,Q)],G,U,B,F,V,O,N=[],w=0.2,L=[0.075,0.225],I=[0.9777777777777777,-3.7333333333333334,3.5555555555555554],T=[2.9525986892242035,-11.595793324188385,9.822892851699436,-0.2908093278463649],y=[2.8462752525252526,-10.757575757575758,8.906422717743473,0.2784090909090909,-0.2735313036020583],E=[0.09114583333333333,0,0.44923629829290207,0.6510416666666666,-0.322376179245283,0.13095238095238096],P=[0.10013431883002395,0,0.3918321794184259,-0.02982460176594817,0.05893268337240795,-0.04497888809104361,0.023904308236133973],m=[0.2,0.3,0.8,0.8888888888888888,1,1],g=[-0.0012326388888888888,0,0.0042527702905061394,-0.03697916666666667,0.05086379716981132,-0.0419047619047619,0.025],b=0,c,Y0,f=(Z-Y)/10,N0=0,w0,P6,E0,b0,S6,P0=new Pz(W,K,$,N,-1,"");if(typeof H==="function")E0=H(Y,Q);while(Y<Z&&N0<X){if(++N0,Y+f>Z)f=Z-Y;if(G=J(Y+m[0]*f,Q+w*f*$[b]),U=J(Y+m[1]*f,Q+L[0]*f*$[b]+L[1]*f*G),B=J(Y+m[2]*f,Q+I[0]*f*$[b]+I[1]*f*G+I[2]*f*U),F=J(Y+m[3]*f,Q+T[0]*f*$[b]+T[1]*f*G+T[2]*f*U+T[3]*f*B),V=J(Y+m[4]*f,Q+y[0]*f*$[b]+y[1]*f*G+y[2]*f*U+y[3]*f*B+y[4]*f*F),w0=Q+$[b]*f*E[0]+U*f*E[2]+B*f*E[3]+F*f*E[4]+V*f*E[5],O=J(Y+f,w0),c=$[b]*f*g[0]+U*f*g[2]+B*f*g[3]+F*f*g[4]+V*f*g[5]+O*f*g[6],P6=Math.abs(c),P6>z){if(f=0.2*f*Math.pow(z/P6,0.25),Y+f===Y){P0.msg="Step size became too small";break}continue}if(N[b]=Q+$[b]*f*P[0]+U*f*P[2]+B*f*P[3]+F*f*P[4]+V*f*P[5]+O*f*P[6],++b,W[b]=Y+f,K[b]=w0,$[b]=O,typeof H==="function"){let v6,y6=Y,GY=Y+0.5*f,V0;if(b0=H(GY,N[b-1]),S6=E0<0&&0<b0,S6){let S0,RZ,MZ=0,f6=1,b6=1;while(!0){if(typeof E0==="number")V0=(b6*b0*y6-f6*E0*GY)/(b6*b0-f6*E0);else{V0=GY;for(Y0=E0.length-1;Y0!==-1;--Y0)if(E0[Y0]<0&&b0[Y0]>0)V0=Math.min(V0,(b6*b0[Y0]*y6-f6*E0[Y0]*GY)/(b6*b0[Y0]-f6*E0[Y0]))}if(V0<=y6||V0>=GY)break;if(v6=P0._at(V0,b-1),RZ=H(V0,v6),S0=E0<0&&0<RZ,S0){if(GY=V0,b0=RZ,S6=S0,b6=1,MZ===-1)f6*=0.5;else f6=1;MZ=-1}else{if(y6=V0,E0=RZ,f6=1,MZ===1)b6*=0.5;else b6=1;MZ=1}}return w0=P0._at(0.5*(Y+V0),b-1),P0.f[b]=J(V0,v6),P0.x[b]=V0,P0.y[b]=v6,P0.ymid[b-1]=w0,P0.events=S6,P0.iterations=N0,P0}y6=GY,GY=Y+f,E0=b0,b0=H(GY,w0),S6=E0<0&&0<b0}Y+=f,Q=w0,E0=b0,f=Math.min(0.8*f*Math.pow(z/P6,0.25),4*f)}return P0.iterations=N0,P0},integral(Y,Z,Q){if(Q>Z)throw Error("lower bound must be less than upper bound");if(Q==Z)return 0;if(!M._modules.mathjs)throw Error(`module 'mathjs' not loaded use 'Tools._modules.mathjs = require("mathjs")' to load it`);let J;if(typeof Y=="string")J=M._modules.mathjs.compile(Y);else J=Y;if(typeof Q=="string")Q=M._modules.mathjs.evaluate(Q);if(typeof Z=="string")Z=M._modules.mathjs.evaluate(Z);let z=(X)=>J.evaluate({x:X});return M.MathKit.dopri(Q,Z,0,z).at(Z)},lerp(Y,Z,Q){return Y+(Z-Y)*Q},Lsh_us(Y,Z){return Y*2**Z},not_us16(Y){return Y^65535},not_us32(Y){return Y^4294967295},not_us8(Y){return Y^255},map(Y,Z,Q,J,z){return Y=M.MathKit.clamp(Y,Z,Q),(Y-Z)/(Q-Z)*(z-J)+J},Point:Ez,radians(Y){return Y*Math.PI/180},Rsh_us(Y,Z){return Math.floor(Y/2**Z)},sum:(...Y)=>{return Y.flat(5).reduce((Z,Q)=>Z+Q,0)},toPolarCoords(Y,Z,Q="r"){if(!Q||Q!="d"&&Q!="r")throw Error("unit must be 'r' or 'd', given: "+Q);let J=Math.atan(Z/Y);if(Z<0&&Y<0)J+=360;else if(Y<0)J+=180;return{r:Math.sqrt(Y**2+Z**2),t:Q=="d"?J:M.MathKit.radians(J)}},toCartesianCoords(Y,Z,Q=null,J="r"){if(!J||J!="d"&&J!="r")throw Error("unit must be 'r' or 'd', given: "+J);if(Q!==null&&typeof Q!="number")throw Error("polar must be a number");if(J=="d"){if(Z=M.MathKit.radians(Z),Q!==null)Q=M.MathKit.radians(Q)}if(Q===null)return{x:Y*Math.cos(Z),y:Y*Math.sin(Z)};else return{x:Y*Math.sin(Q)*Math.cos(Z),y:Y*Math.sin(Q)*Math.sin(Z),z:Y*Math.cos(Q)}}},maxFraction(Y,Z,Q=!1){let J=Y.toString();if(!J.includes("."))return J;let z=10**Z;return Y=(Q?Math.floor(Y*z):Math.round(Y*z))/z,Y.toString()},ncc(Y=null,Z=null,Q=null){if(M.CheckCache.supportsColor===0)return"";if(Y==null)return"\x1B[0m";if(typeof Y=="number"){let z=M.Convert.decimalColorToRGB(Y);switch(Q?1:M.CheckCache.supportsColor){default:return"";case 1:Y=(Z=="bg"?"bg":"")+M.Convert.basicColorFromRgb(z);case 2:{let H=M.Convert._8bitColorFromRgb(z);return`\x1B[${Z=="bg"?"4":"3"}8;5;${H}m`}case 3:return`\x1B[${Z=="bg"?"4":"3"}8;2;${z.r};${z.g};${z.b}m`}}return Y=Y.toLowerCase(),{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",blink:"\x1B[5m",invert:"\x1B[7m",hidden:"\x1B[8m",normal:"\x1B[22m",bgblack:"\x1B[40m",bgred:"\x1B[41m",bggreen:"\x1B[42m",bgyellow:"\x1B[43m",bgblue:"\x1B[44m",bgmagenta:"\x1B[45m",bgcyan:"\x1B[46m",bgwhite:"\x1B[47m"}[Y]||"\x1B[37m"},nearestNumber(Y,Z){let Q=1/0,J=null;for(let z=0,X=Y[z];z<Y.length;){let H=Math.abs(Z-X);if(!H)return z;if(H<Q)Q=H,J=z;X=Y[++z]}return J},objectMap(Y,Z){return M.remap(Y,Z)},objValueAt(Y,Z){return Y[Object.keys(Y).at(Z)]},objToString(Y,Z={}){let{maxDepth:Q=4,indent:J=3,maxKeys:z=20,color:X=!1,defColor:H=void 0,noHeader:W=!1}=Z;if(Q<1)Q=1;let K={color:X,defColor:H},$=typeof J=="number"?" ".repeat(J):J,G=null;if(X)G={cyan:M.ncc(4764610),magenta:M.ncc(11550650),gray:M.ncc(4802889),yellow:M.ncc(12754962),_default:M.ncc(H)};if(Y==null||typeof Y!=="object")return M.yuString(Y,K);if(M.isArrayLike(Y))return M.arrToString(Y,{color:X,defColor:H,maxDepth:Q,indent:J});if(Y instanceof Map||Y instanceof Set||Y instanceof Promise||Y instanceof Date||Y instanceof RegExp)return M.yuString(Y,K);if(M.isError(Y))return M.Err.toString(Y,{color:X,defColor:H});let U=Y.constructor?.name||"Object",B=U!=="Object",V=Object.keys(Y).length,O="";if(!W&&(B||V>5))if(X)O=G.magenta+`${U}(${V}) `+G._default;else O=`${U}(${V}) `;return O+N(Y,0);function N(w,L,I=0){if(L>Q-1)if(X)return G.gray+"... {Object}"+G._default;else return"... {Object}";if(w==null)return M.yuString(w,K);if(typeof w!=="object"||w instanceof Date||w instanceof RegExp)return M.yuString(w,K);if(M.isArrayLike(w))return M.arrToString(w,{color:X,defColor:H,maxDepth:Q-L,indent:J,noHeader:!0});if(w instanceof Map||w instanceof Set)return M.yuString(w,K);let T=Object.keys(w),y=T.length;if(y===0)return"{}";let E=y>3||L>0,P=I?$.repeat(I):"",m=P+$,g=E?`{
|
|
14
|
+
`+m:"{ ",b=Math.min(T.length,z-1);for(let c=0;c<b;c++){let Y0=T[c],f=w[Y0];if(X)g+=G.cyan+Y0+G._default+": ";else g+=Y0+": ";if(f&&typeof f==="object"&&!M.isArrayLike(f)&&!(f instanceof Date)&&!(f instanceof RegExp)&&!(f instanceof Map)&&!(f instanceof Set)&&!(f instanceof Promise)){let N0=f.constructor?.name||"Object";if(N0!=="Object"&&X)g+=G.magenta+N0+" "+G._default;else if(N0!=="Object")g+=N0+" ";g+=N(f,L+1,E?I+1:I)}else g+=M.yuString(f,K);if(c<b-1)g+=E?`,
|
|
15
|
+
`+m:", "}if(T.length>z-1){let c=T.length-b;if(X)g+=E?`,
|
|
16
|
+
`+m:", ",g+=G.gray+`... (${c} more)`+G._default;else g+=E?`,
|
|
17
|
+
`+m:", ",g+=`... (${c} more)`}return g+=E?`
|
|
18
|
+
`+P+"}":" }",g}},propertiesCount(Y){return Object.keys(Y).length},padEnd(Y,Z,Q=" ",J=0){let z=M.ex_length(Y,J);if(z>=Z)return Y;return Y+Q.repeat(Z-z)},padStart(Y,Z,Q=" ",J=0){let z=M.ex_length(Y,J);if(z>=Z)return Y;return Q.repeat(Z-z)+Y},parseArgs(Y,Z,Q=!1){let J={_unmatched:[]},z=new Set;for(let H in Z)if(Z[H]?.required)z.add(H);for(let H=0;H<Y.length;H++){let W=!1;for(let K in Z){if(!Z[K]?.pattern)throw Error("invalid template: Object structure missmatched. every entries requires `pattern` property");if(!X(Y[H],Z[K].pattern))continue;if(z.delete(K),Z[K]?.isFlag||Z[K]?.type=="flag"){W=!0,J[K]=new yY(!0,"flag",H);continue}let $=!1;if(H+1<Y.length){for(let G in Z)if(X(Y[H+1],Z[G].pattern))$=!0}if(H+1>=Y.length||$)throw Error(`argument '${Y[H]}' requires a Value`);switch(Z[K]?.type){case"int":if(isNaN((J[K]=new yY(parseInt(Y[++H]),Z[K]?.type,H)).value))throw Error(`argument '${Y[H-1]}' requires a Value of type '${Z[K]?.type}'`);break;case"float":if(isNaN((J[K]=new yY(parseFloat(Y[++H]),Z[K]?.type,H)).value))throw Error(`argument '${Y[H-1]}' requires a Value of type '${Z[K]?.type}'`);break;case"choice":if(!Z[K]?.choices?.length)throw Error("invalid template: Object structure missmatched. entry of type 'choice' requires `choices` property");if(!X(Y[++H],Z[K].choices)&&Z[K]?.default==null)throw Error(`invalid value for '${Y[H-1]}' argument, requires any of these Choices: ${Z[K].choices}`);J[K]=new yY(Y[H],Z[K]?.type,H);break;case"string":case void 0:J[K]=new yY(Y[++H],Z[K]?.type,H);break;default:throw Error(`invalid template: entry of type '${Z[K]?.type}' is not supported`)}W=!0}if(!W)J._unmatched.push(new yY(Y[H],void 0,H))}if(z.size>0)throw Error(`argument(s) '${[...z]}' is required.`);for(let H in Z){if(Z[H]?.isFlag||Z[H]?.type=="flag"){if(!J[H])J[H]=new yY(!1,"flag");continue}if(!J[H])J[H]=new yY(Z[H]?.default?Z[H]?.default:null,Z[H]?.type)}return J;function X(H,W){for(let K of W){if(!Q){if(H.toLowerCase()==K.toLowerCase())return!0;continue}if(H==K)return!0}return!1}},parseBool(Y,Z=!1){if(typeof Y=="boolean")return Y;Y=Y.toLowerCase();let Q=Y=="true"?!0:!1;if(!Z)return Q;if(!(Y=="true"||Y=="false"))return null;return Q},parseConfig(Y,Z=null,Q={}){let{ignoreGroups:J=!1,multiValues:z=!1}=Q,X=M.cleanArr(Y.trim().split(`
|
|
19
|
+
`),["","\r"]),H={},W=null,K="",$,G=0,U=!1;for(let F=0;F<X.length;F++){let V=X[F].trim();if(/^[#;]/.test(V))continue;if(V.startsWith("[")){if(J)continue;{let T=!1;for(let y=1;y<V.length;y++)if(V[y]=="]"&&V[y-1]!="\\"){if(W=V.slice(1,y),!H[W])H[W]={};T=!0;break}if(!T)throw Error(`Tools.parseConfig(): invalid syntax, missing ']' at the end of the group. at \`${V}\``);else continue}}if(U){if(K+=X[F],!B(F,X))continue;if(U=!1,W)H[W][$]=JSON.parse(K,Z);else H[$]=JSON.parse(K,Z);continue}let O=M.cleanArr(V.split("="));if(O.length>2)throw Error(`Tools.parseConfig(): invalid syntax, '=' cannot occur more than one time. at \`${V}\``);else if(O.length==1&&!U)if(V.includes("="))throw Error(`Tools.parseConfig(): invalid syntax, expected expresion after '='. at \`${V}\``);else throw Error(`Tools.parseConfig(): expected expresion. at \`${V}\``);else if(!O.length)throw Error(`Tools.parseConfig(): unknown operator. \`${V}\``);O=[O[0].trim(),O[1].trim()];let N=M.getMatchAllIndexes(O[1].matchAll(/["']/g)).filter((T,y,E)=>{if(O[1][T-1]=="\\"){O[1]=O[1].slice(0,T-1)+O[1].slice(T);for(let P=y+1;P<E.length;P++)E[P]--;return!1}return!0}),w=O[1].search("#"),L=N[0],I=!1;if(L!=null&&(w==-1||L<w)){let T=N[1]==null?-1:N[1],y=O[1].slice(T+2).trim();if(y&&!/^[#;]/.test(y))throw Error(`Tools.parseConfig(): invalid syntax, unexpected charactor(s).
|
|
20
|
+
at \`${V}\`
|
|
21
|
+
`+"".padStart(T+10+O[0].length," ")+"^");if(T==-1)throw Error(`Tools.parseConfig(): invalid syntax, missing closing quote.
|
|
22
|
+
at \`${V}\`
|
|
23
|
+
`+" ".padStart(L+7+O[0].length," ")+"^");I=!0,O[1]=O[1].slice(L+1,T)}else if(w!=-1){if(O[1]=O[1].slice(0,O[1].indexOf("#")).trim(),!O[1])throw Error(`Tools.parseConfig(): invalid syntax, expected expresion after '='. at \`${V}\``)}if(/^[0-9]/.test(O[0]))throw Error(`Tools.parseConfig(): Key cannot starts with Numbers. at \`${V}\``);{let T=O[0].replace(/[a-z$_0-9.]/ig,"");if(T.length!==0)throw Error(`Tools.parseConfig(): these character(s) "${T}" can not be Parse. at \`${V}\``)}if(/^[[{]/.test(O[1])){if(G=0,[$,K]=O,B(1,O)){if(W)H[W][$]=JSON.parse(K,Z);else H[$]=JSON.parse(K,Z);continue}U=!0;continue}{let T=W?H[W]:H;if(z&&Object.hasOwnProperty.call(T,O[0])){if(T[O[0]].$multiValues===void 0)T[O[0]]=[T[O[0]]],T[O[0]].$multiValues=!0;T[O[0]].push(I?O[1]:M.parseValue(O[1]))}else T[O[0]]=I?O[1]:M.parseValue(O[1])}}return H;function B(F,V){if(G+=[...V[F].matchAll(M.REGEXP.OpenSCBrackets)].filter((O)=>O[1]).length,G-=[...V[F].matchAll(M.REGEXP.CloseSCBrackets)].filter((O)=>O[1]).length,G<=0)return!0;return!1}},parseValue(Y){if(typeof Y!="string")return Y;switch(Y.toLowerCase()){case"true":return!0;case"false":return!1;case"null":return null;case"":case"undefined":return;default:if(!isNaN(Y))return Number(Y);return Y}},pass(Y,Z=null){if(Z)Z(Y);else console?.log(Y);return Y},Progress:class Y{stdout=process.stdout;progress=0;spd=0;lastCheck=null;printInterval;updateInterval;total;#Z=0;#Q=!0;#Y;constructor(Z,Q=null,J=500,z=100){if(!Z)throw Error("printTemplate is required");this.total=Q,this.printInterval=J,this.updateInterval=z,this.setPrintTemplate(Z),this.lastCheck=Date.now()}update(Z=1){if(!this.#Y)return;this.#Z+=Z,this.progress+=Z;let Q=Date.now()-this.lastCheck;if(Q>this.updateInterval&&this.#Z>4)this.spd=this.#Z*this.updateInterval/Q,this.#Z=0,this.lastCheck=Date.now();if(this.lastPrint+this.printInterval>Date.now())return;if(this.lastPrint=Date.now(),!this.#Q)this.stdout.clearLine(),this.stdout.cursorTo(0);else this.#Q=!1;if(!this.total){this.#Y();return}this.#Y()}done(){if(this.progress!=this.total){if(!this.#Q)this.stdout.clearLine(),this.stdout.cursorTo(0);this.progress=this.total,this.#Y()}this.stdout.write(`
|
|
24
|
+
`),this.reset()}reset(){this.progress=0,this.#Z=0,this.spd=0,this.lastCheck=Date.now(),this.#Q=!0}setPrintTemplate(Z){Z=Z.replace(/%total%/g,"${this.total}"),Z=Z.replace(/%spd%/g,"${this.spd.toFixed(1)}"),Z=Z.replace(/%prog%/g,"${this.progress}"),this.#Y=Function("this.stdout.write(`"+Z+"`);").bind(this)}},proximate(Y,Z,Q){if(Y<Z+Q&&Y>Z-Q)return Z;else return Y},randomPick(Y){if(Y.length<=1)return Y[0];return Y[Math.floor(Math.random()*Y.length)]},redexOf(Y,Z,Q=0){let J=typeof this!=="string";if(!Y&&J)return-1;if(!J)Y=this;if(!Y.length)return-1;if(!(Z instanceof RegExp))if(Q>=0)return Y.indexOf(Z,Q);else return Y.lastIndexOf(Z,Y.length+Q);let z,X;if(Q>=0){z=-1;do{X=Y.substring(++z);let H=X.search(Z);if(H==-1)return-1;z=H+z}while(z<Q)}else{z=-1;do{X=Y.substring(++z);let H=X.search(Z);if(H==-1)return z-1;z=H+z}while(z<Y.length+Q)}return z},REGEXP:Object.freeze({Seperators:/[-\s_・⧸/\\;:()[\]、,.'""!^**=+「【】」()]/g,SoftWrapSeperators:/(?<!\x1b(?:\[[0-9;]*m|\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)))[\s,.\]})]/g,HardWrapSeperators:/(?<!\x1b(?:\[[0-9;]*m|\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)))[-\s_・⧸/\\;:()\[\]、,.'""!^**=+「【】」()]/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(_5),EmojiEach:new RegExp(_5,"g"),EmojiEachGroup:new RegExp("(?:"+_5+")+","g"),IniGroups:/^[\t ]*\[(.+)\][\t ]*$/gm,JSComments:/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g,OpenSCBrackets:/\\"|"(?:\\"|[^"])*"|([[{])/g,CloseSCBrackets:/\\"|"(?:\\"|[^"])*"|([\]}])/g}),resolveNodeEnv(Y,Z=/%(\w+)%/g){return Y.replace(Z,(Q,J)=>{let z=J;if(process.env[z]==null)return Q;return process.env[z]})},SafeTrue:class Y{#Z=0;limit=0;noWarning=!1;constructor(Z=10000000000,Q=!1){this.limit=Z,this.noWarning=Q}get True(){if(this.#Z++>=this.limit){if(!this.noWarning)process?.emitWarning("SafeTrue limit reached");return!1}return!0}},search(Y,Z,Q={}){let J=M.REGEXP.Seperators,z=Q.maxResult,X=Q.TF_IDFMaps instanceof Array?[...Q.TF_IDFMaps]:Q.TF_IDFMaps;if(!z)if(typeof Q=="number")z=Q;else z=1/0;if(Z=Z.trim().toLowerCase(),Z=="")return null;let H=[...Y];if(H.forEach(($,G,U)=>U[G]=$.trim().toLowerCase()),X==="builtin")X=M.DataScienceKit.TFIDF_of(H.concat(Z).map(($)=>M.cleanArr($.split(J))));class W{constructor($,G,U=-1,B=null){this.score=G,this.string=$,this.matchIndex=U,this.scores=B}}let K=[];for(let $=0;$<H.length;$++){let G=H[$].replace(J,"");if(H[$]==Z||G==Z)K.unshift(new W(Y[$],Z.length<<2,$));let U,B,F,V;U=B=F=V=0;for(let N of M.cleanArr(Z.split(J))){let w=0;if(M.includesWord(N,H[$],!1))if(X&&X[$]?.has(N))w=N.length*X[$].get(N).TF_IDF*2.9,U+=w;else w=N.length,B+=w;else if(H[$].includes(N))w=N.length*0.3,F+=w;let L=M.DataScienceKit.LCSLength_of(N,H[$])*0.4;V+=L}let O=U+B+F+V;K.push(new W(null,O,$,{tfidf_s:U,word_s:B,includes_s:F,lcs_s:V,TF_IDFMap:X?.[$]}))}K.sort(($,G)=>G.score-$.score);for(let $=0;$<z;$++){if(!K[$])break;if(K[$].string!=null)continue;K[$].string=Y[K[$].matchIndex]}return K.slice(0,z)},sleep(Y){if(!Y||Y<0)return;let Z=Date.now();while(Date.now()-Z<Y);},SpawnMirror:class Y{static STDIO_MIRROR=["inherit","pipe","pipe"];static createMirror(Z){Z?.stdout?.pipe(process.stdout),Z?.stderr?.pipe(process.stderr)}},strClamp(Y,Z,Q="mid",J=0){let z=M.ex_length(Y,J);if(z<=Z)return Y.padEnd(Z," ");let X=z-(z-Z)-3;switch(Q){default:if(T1)process?.emitWarning(`'${Q}' is not a valid location type.`);else throw Error(`'${Q}' is not a valid location type.`);case"mid":{let H=X>>1;return M.strSlice(Y,0,H,J)+"..."+M.strSlice(Y,z-H,void 0,J)}case"end":return M.strSlice(Y,0,X,J)+"...";case"start":return"..."+M.strSlice(Y,X,void 0,J)}},stringifyConfig(Y,Z={}){let{ignoreList:Q=[],minify:J=!1,replacer:z,mode:X="merge",useIniGroup:H=!1,alwaysWrapStrInQuotes:W=!1,oldConfigStr:K=""}=Z,$=new M.SafeTrue(1e5),G=X=="merge"?K:"";for(let V in Y){if(Q.includes(V))continue;if(!H){U(V,Y);continue}if(V===""||typeof Y[V]!=="object"){U(V,Y,"");continue}for(let O in Y[V]){if(Q.includes(O))continue;U(O,Y[V],V)}}return G;function U(V,O,N,w=!1){let L="";if(O[V]!=null&&typeof O[V]==="object")if(O[V].$multiValues){for(let c of O[V])U(V,{[V]:c},N,!0);return}else L=`${JSON.stringify(O[V],z,J?null:3)}
|
|
25
|
+
`;else if(typeof O[V]=="string")if(W||/\s|[{[}\]]/.test(O[V]))L=`"${O[V]}"`;else L=`${O[V]}`;else L=`${O[V]}`;let I=w?-1:M.redexOf(G,new RegExp(`^[ \\t]*\\b${V}\\s*=`,"m")),T;if(N==="")T=-3;else T=H?G.indexOf(`[${N}]`):null;let y=T===-1;if(y)T=G.length+2,G+=`
|
|
26
|
+
|
|
27
|
+
[${N}]
|
|
28
|
+
`;if(I==-1){let c=J?`${V}=${L}
|
|
29
|
+
`:`${V} = ${L}
|
|
30
|
+
`;if(H)if(y)G+=c+`
|
|
31
|
+
`;else{let Y0=M.redexOf(G,new RegExp(`^\\s*
|
|
32
|
+
$`,"m"),T);G=M.strSplice(G,Y0,0,c)}else G+=c;return}let E=null,P=null;if(H)E=M.redexOf(G.slice(0,I),M.REGEXP.IniGroups,-1),P=E==T?N:G.slice(E+1,G.slice(E,I).indexOf("]")+E);let m=G.indexOf("=",I)+1,g=M.getMatchAllIndexes(G.slice(m).matchAll(/(?<!\\)[#\n;]/g))?.[0]??-1;if(g==-1)g=G.length;else g+=m;let b=G[g]===`
|
|
33
|
+
`?g:G.indexOf(`
|
|
34
|
+
`,g+1);if(F(m,g))g=B(m);if(P&&P!==N){let c=G.slice(I,b+1),Y0=b-I,f=m-I,N0=g-I;if(G=M.strSplice(G,I,Y0+1,""),T>I)T-=Y0;else T++;I=T+N.length+2,m=I+f,g=I+N0,G=M.strSplice(G,I,0,c)}G=M.strSplice(G,m,g-m,(J?"":" ")+L);{let c=0;while(G[m+(c-2)]==" ")c--;if(J&&c<0)G=M.strSplice(G,m+c-1,-c,"");else if(!J&&c!==-1)G=M.strSplice(G,m+c-1,-c," ")}}function B(V){let O=0,N=V,w=!1;do{if(N++,w){if(G[N]=='"'&&G[N-1]!="\\")w=!1;continue}if(G[N]=='"'){w=!0;continue}if(G[N]=="{"||G[N]=="[")O++;if(G[N]=="}"||G[N]=="]")O--}while(O&&$.True);if($.True==!1)throw Error(`failed to write config
|
|
35
|
+
Reason: loop limit reached`);return N+1}function F(V,O){return/^[\t ]*[[{]/.test(G.slice(V,O))}},strJustify(Y,Z,Q={}){let{filler:J=" ",align:z="center",overflow:X="hidden",collapseLocation:H="end",redundancyLv:W=0}=Q,K=Y instanceof Array,$=K?Y.join(""):Y,G=M.ex_length($,W);if(G>Z){if(X=="collapse")return M.strLimit($,Z,H);if(X=="hidden")return $.slice(0,Z);return $}switch(z){case"spacebetween":if(K){let U=J.repeat((Z-G)/(Y.length-1));return Y.reduce((B,F,V)=>{if(V==0)return B;return B+U+F},Y[0])}default:case"center":return M.strSurround($,J,Z);case"right":return M.padStart($,Z,J);case"left":return M.padEnd($,Z,J)}},strLimit(Y,Z,Q="mid",J=0){let z=M.ex_length(Y,J);if(z<=Z)return Y;let X=z-(z-Z)-3;switch(Q){default:if(T1)process?.emitWarning(`'${Q}' is not a valid location type.`);else throw Error(`'${Q}' is not a valid location type.`);case"mid":{let H=X>>1;return M.strSlice(Y,0,H)+"..."+M.strSlice(Y,z-H+1)}case"end":return M.strSlice(Y,0,X)+"...";case"start":return"..."+M.strSlice(Y,z-X)}},strSlice(Y,Z,Q,J=0){let z=[...Y.matchAll(M.REGEXP.ANSICode)].map((W)=>{return{start:W.index,end:W.index+W[0].length,length:W[0].length}});if(!Q)Q=M.ex_length(Y,J);let X=0,H=0;for(let W=0;W<z.length;W++){if(z[W].start-X<Z)X+=z[W].length;if(z[W].start-H<=Q)H+=z[W].length;if(z[W].start-H>Q)break}return Y.slice(Z+X,Q+H)},strSplice(Y,Z,Q,J=null){if(Q<0)Q=0;if(Z<Y.length*-1)Z=0;if(J)return Y.slice(0,Z)+J+(Z<0&&Q+Z>=0?"":Y.slice(Z+Q));else return Y.slice(0,Z)+(Z<0&&Q+Z>=0?"":Y.slice(Z+Q))},strSurround(Y,Z,Q,J=0){let z=M.ex_length(Y,J),X=Math.ceil(Q/2-z/2);return M.padEnd(" ",X,Z,J)+M.padEnd(Y,Q/2+z/2,Z,J)},strWrap(Y,Z,Q={}){if(!Y)return"";let{indent:J="",firstIndent:z="",mode:X="softboundary",redundancyLv:H=0}=Q,W="",K=M.REGEXP.SoftWrapSeperators,$=M.REGEXP.HardWrapSeperators,G=Z*0.67;if(typeof z=="number")z="".padEnd(z," ");if(typeof J=="number")J="".padEnd(J," ");let U=0,B=Y.split(`
|
|
36
|
+
`);for(let V=0;V<B.length;V++){let O=M.getMatchAllIndexes(B[V].matchAll(K));while(M.ex_length(B[V],H)>Z){let N=O.map((L)=>L-U).filter((L)=>L>=G),w=N[0]??-1;if(J!=null)if(z!=null)W+=z,z=null;else W+=J;if(X=="softboundary")if(w==-1){let L=M.getMatchAllIndexes(B[V].matchAll($)).filter((I)=>I>=G);w=F(L,0)??Z}else w=F(N,0);else w=w>Z||w==-1?Z:w;w++,W+=B[V].substring(0,w).concat(`
|
|
37
|
+
`),B[V]=B[V].substring(w).trimStart(),U+=w}if(J!=null)if(z!=null)W+=z,z=null;else W+=J;W+=B[V].concat(V<B.length-1?`
|
|
38
|
+
`:"")}return W;function F(V,O){if(!V[O+1])return V[O];if(V[O+1]-V[O]>1)return V[O];return F(V,O+1)}},supportsColor(Y=process?.stdout){if(!T1)return 3;if(M.CheckCache.forceColor===!1)return 0;if(M.argvHasFlag("color=16m")||M.argvHasFlag("color=full")||M.argvHasFlag("color=truecolor"))return 3;if(M.argvHasFlag("color=256"))return 2;if(Y&&!Y.isTTY&&M.CheckCache.forceColor!==!0)return 0;let Z=M.CheckCache.forceColor?1:0;if(process.platform==="win32"){if(!M._modules.os)M._modules.os=FF("os");let J=M._modules.os.release().split(".");if(Number(process.versions.node.split(".")[0])>=8&&Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}let{env:Q}=process;if("CI"in Q){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some((J)=>(J in Q))||Q.CI_NAME==="codeship")return 1;return Z}if("TEAMCITY_VERSION"in Q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Q.TEAMCITY_VERSION)?1:0;if(Q.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Q){let J=parseInt((Q.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Q.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Q.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Q.TERM))return 1;if("COLORTERM"in Q)return 1;if(Q.TERM==="dumb")return Z;return Z},supportsHyperlink(Y=process?.stdout,Z=!1){if(!T1)return!0;if(Z)console.log("Terminal Support Hyperlink Test: (result of last check is the test result)");if(Z)console.log(`1. has process.env: ${!!process.env}`);let{env:Q}=process;if(!Q)return!1;if(Z)console.log(`2. force hyperlink: ${!!Q.FORCE_HYPERLINK&&!(Q.FORCE_HYPERLINK.length>0&&parseInt(Q.FORCE_HYPERLINK,10)===0)}`);if("FORCE_HYPERLINK"in Q)return!(Q.FORCE_HYPERLINK.length>0&&parseInt(Q.FORCE_HYPERLINK,10)===0);if(Z)console.log(`3. hyperlink disable: ${M.argvHasFlag("no-hyperlink")||M.argvHasFlag("no-hyperlinks")||M.argvHasFlag("hyperlink=false")||M.argvHasFlag("hyperlink=never")}`);if(M.argvHasFlag("no-hyperlink")||M.argvHasFlag("no-hyperlinks")||M.argvHasFlag("hyperlink=false")||M.argvHasFlag("hyperlink=never"))return!1;if(Z)console.log(`4. has hyperlink enable: ${M.argvHasFlag("hyperlink=true")||M.argvHasFlag("hyperlink=always")}`);if(M.argvHasFlag("hyperlink=true")||M.argvHasFlag("hyperlink=always"))return!0;if(Z)console.log(`5. ran on Netlify: ${"NETLIFY"in Q}`);if("NETLIFY"in Q)return!0;if(Z)console.log(`6. supports color: ${M.CheckCache.supportsColor>0}`);if(M.CheckCache.supportsColor>0)return!0;if(Z)console.log(`7. in TTY stream: ${!(Y&&!Y.isTTY)}`);if(Y&&!Y.isTTY)return!1;if(Z)console.log(`8. platform is win32: ${process.platform==="win32"}`);if(process.platform==="win32")return!1;if(Z)console.log(`9. is CI: ${"CI"in Q}`);if("CI"in Q)return!1;if(Z)console.log(`10. no TEAMCITY_VERSION: ${!("TEAMCITY_VERSION"in Q)}`);if("TEAMCITY_VERSION"in Q)return!1;if(Z)console.log("11. valid TERM_PROGRAM: (multiple check)");if("TERM_PROGRAM"in Q){let z=J(Q.TERM_PROGRAM_VERSION);switch(Q.TERM_PROGRAM){case"iTerm.app":if(z.major===3)return z.minor>=1;return z.major>3;case"WezTerm":return z.major>=20200620;case"vscode":return z.major>1||z.major===1&&z.minor>=72}}if(Z)console.log("11. valid VTE_VERSION: (multiple check)");if("VTE_VERSION"in Q){if(Q.VTE_VERSION==="0.50.0")return!1;let z=J(Q.VTE_VERSION);return z.major>0||z.minor>=50}if(Z)console.log("12. Final: failed");return!1;function J(z){if(/^\d{3,4}$/.test(z)){let H=/(\d{1,2})(\d{2})/.exec(z);return{major:0,minor:parseInt(H[1],10),patch:parseInt(H[2],10)}}let X=(z||"").split(".").map((H)=>parseInt(H,10));return{major:X[0],minor:X[1],patch:X[2]}}},surroundedBy(Y,Z,Q){if(Z<0)return!1;let J=-1/0,z=1/0,X=Y=="{"||Y=="["||Y=="("||Y=="<";for(let W=Z;W>0;W-=2){let K=Q.lastIndexOf(Y,W);if(K==-1)break;else J=K;if(Q[J-1]=="\\")J=-1/0}for(let W=0;W<Q.length;W+=2){let K=Q.indexOf(X?H(Y):Y,W);if(K==-1)break;else z=K;if(Q[z-1]=="\\")z=1/0}if(J==-1/0||z==1/0)return!1;return J<Z&&z>Z;function H(W){return String.fromCharCode(W.charCodeAt(0)+(W[0]=="("?1:2))}},Timer:class Y{time;resolution;isRunning=!1;maxTime;#Z;#Q;#Y=0;#J;#z;constructor(Z,Q="ms"){switch(this.maxTime=this.time=Z,this.resolution=Q,Q){case"ms":this.#Z=1;break;case"s":this.#Z=1000;break;case"m":this.#Z=60000;break}}start(){if(this.isRunning||this.time<=0)return;return this.isRunning=!0,this.#Y=Date.now(),this.#Q=setInterval(this.#X,this.#Z==1?4:this.#Z/100),this}stop(){if(!this.isRunning)return;return clearInterval(this.#Q),this.isRunning=!1,this.reset()}pause(){if(!this.isRunning)return;clearInterval(this.#Q),this.isRunning=!1;return}reset(){return this.time=this.maxTime,this}async wait(){if(!this.isRunning)return;return new Promise((Z)=>{this.#z=()=>{this.#z=null,Z()}})}onceEnd(Z){return this.#J=Z,this}#X=()=>{let Z=Date.now(),Q=(Z-this.#Y)/this.#Z;if(this.time-=Q,this.#Y=Z,this.time>0)return;if(this.stop(),this.time=0,this.#J)this.#J(),this.#J=null;if(this.#z)this.#z()}},toPlace(Y){switch(Y){case 1:return"1st";case 2:return"2nd";case 3:return"3rd";default:return Y+"th"}},toShortNum(Y,Z=2,Q=1000,J=!1,z=-Number.MAX_SAFE_INTEGER,X=Number.MAX_SAFE_INTEGER){if(Y===0)return"0";let H=Math.abs(Y),W=Math.sign(Y),K=H>0&&H<1,$=M.MathKit.clamp(Math.floor(Math.log(H)/Math.log(Q)),z,X);Y=Y/Math.pow(Q,$)*W;let G=M.maxFraction(Y,Z,J),B={"4":"T","2":"M","3":"G","1":"k","0":"","-1":"m","-2":"μ","-3":"n","-4":"p"}[$]??`e${K?"":"+"}${$*3}`;return G+B},Tracer:class Y{liveLog=!0;log="";startTime;enableLogging=!1;recursive=!1;constructor(){this.startTime=new Date}createTracker=function(Z,Q,J){let z=(X,H)=>{let W=X.length;if(W<=H)return X;let $=W-(W-H)-3>>1;return X.slice(0,$)+"..."+X.slice(W-$+1)};return function(){if(!J.enableLogging)return Z.apply(this,arguments);let X=Z.apply(this,arguments)??"void",H="["+M.jsTime.howLong(J.startTime)+"] "+Q+"(";for(let W=0;W<arguments.length;W++){if(W>0)H+=", ";let K=M.yuString(arguments[W]);H+=K.trim().length?z(K,70):`"${K}"`}if(X==="void")H+=")";else H+="): "+z(M.yuString(X),70);if(J.log+=H+`
|
|
39
|
+
`,J.liveLog)console.log(H);return X==="void"?void 0:X}};attachTracer(Z,Q=""){if(Q.length>100)return this;if(typeof Z!=="object")return this;for(let J of Object.getOwnPropertyNames(Z)){let z=Z[J];if(Object.prototype.toString.call(z)==="[object Function]"){if(!M.isClass(z))Z[J]=this.createTracker(z,Q+J,this);if(this.recursive&&M.propertiesCount(z)>0)for(let X of Object.getOwnPropertyNames(z)){let H=z[X];return this.attachTracer(H,Q+J+".")}}}return this}},writeConfig(Y,Z,Q={}){if(!M._modules.fs)throw Error('fs module is required for Tools.writeConfig()\nimport them with `Tools._modules.fs = require("fs")`');let{ignoreList:J=[],minify:z=!1,replacer:X,mode:H="merge",useIniGroup:W=!1,alwaysWrapStrInQuotes:K=!1}=Q,$="";if(M._modules.fs.existsSync(Z)&&H=="merge")$=M._modules.fs.readFileSync(Z,{encoding:"utf-8"});$=M.stringifyConfig(Y,{ignoreList:J,minify:z,replacer:X,mode:H,useIniGroup:W,alwaysWrapStrInQuotes:K,oldConfigStr:$}),M._modules.fs.writeFileSync(Z,$,{encoding:"utf-8"})},yuString(Y,Z={}){let{color:Q=!1,defColor:J=void 0}=Z;switch(typeof Y){case"string":if(Q)return M.ncc(8373322)+`"${Y}"`+M.ncc(J);return`"${Y}"`;case"bigint":case"number":if(Q)return M.ncc(11609489)+Y+M.ncc(J);case"boolean":case"undefined":if(Q)return M.ncc(15756194)+Y+M.ncc(J);return Y+"";case"function":if(Q)return(M.isAsyncFunction(Y)?M.ncc(4802889)+"async ":"")+(M.isArrowFunction(Y)?M.ncc(13401911)+(Y.name||M.ncc(4802889)+"[anonymous]"+M.ncc(13401911))+" () => {...}":M.ncc(13401911)+(Y.name||M.ncc(4802889)+"[anonymous]"+M.ncc(13401911))+"()")+M.ncc(J);return(M.isAsyncFunction(Y)?"async ":"")+(M.isArrowFunction(Y)?(Y.name||"[anonymous]")+" () => {...}":(Y.name||"[anonymous]")+"()");case"symbol":if(Q)return M.ncc(13401911)+Y.toString()+M.ncc(J);return Y.toString()}if(Y==null){if(Q)return M.ncc(13136006)+Y+M.ncc(J);return Y+""}if(Y instanceof Date){if(Q)return M.ncc(11550650)+"Date"+M.ncc(J)+" "+Y.toISOString();return"Date "+Y.toISOString()}if(Y instanceof RegExp){if(Q)return M.ncc("Yellow")+Y.toString()+M.ncc(J);return Y.toString()}if(Y instanceof Promise)return M.ncc(11550650)+"Promise"+M.ncc(J)+" {...(pending)}";if(Y instanceof Map){let z=[...Y.entries()];return(Q?M.ncc(11550650)+`Map(${Y.size}) {`+M.ncc(J):`Map(${Y.size}) {`)+M.arrToString(z,{color:Q,defColor:J,noHeader:!0})+"}"}if(Y instanceof Set){let z=[...Y.values()];return(Q?M.ncc(11550650)+`Set(${Y.size}) {`+M.ncc(J):`Set(${Y.size}) {`)+M.arrToString(z,{color:Q,defColor:J,noHeader:!0})+"}"}if(M.isError(Y))return M.Err.toString(Y,{color:Q,defColor:J});try{if(typeof Y==="object"){if(M.isArrayLike(Y))return M.arrToString(Y,{color:Q,defColor:J});return M.objToString(Y,{color:Q,defColor:J})}}catch{}return"[unknown]"}};if(typeof window<"u")window._tools=M;({arrFindLast:xT,arrToString:Sz,argvHasFlag:ET,asyncSleep:PT,beautifyJson:ST,beforeExit:vz,changeDateTimezone:vT,charTypeAt:yT,CheckCache:qY,cleanArr:fT,cleanComments:bT,cleanString:yz,CONSTS:hT,Convert:gT,ConsoleTime:mT,compareDate:uT,DataScienceKit:dT,deferredFunc:pT,digitAt:cT,digitAtRange:lT,getDimensions:iT,Err:n,escapeRegExp:nT,ex_length:aT,fileNameCleaner:oT,fixFilePath:sT,fixYTurl:rT,fileTypeOf:tT,getMatchAllIndexes:eT,getMatchAllResults:YC,getRandomInt:ZC,getProcessTime:QC,hyperLink:h6,IDGenerator:JC,includesWord:zC,IPC:XC,isArrayLike:HC,isArrowFunction:WC,isAsyncFunction:KC,isClass:GC,isNumber:$C,isEmptyArray:qC,isEmptyObject:UC,isError:fz,isValidFilePath:BC,JSONReplacer:VC,JSONReviver:FC,jsTime:k1,lazySplit:RC,remap:bz,MathKit:v0,maxFraction:DZ,ncc:q,nearestNumber:MC,objectMap:OC,objValueAt:DC,objToString:NC,propertiesCount:wC,padEnd:hz,padStart:LC,parseArgs:_C,parseBool:IC,parseConfig:jC,parseValue:TC,pass:CC,Progress:kC,proximate:AC,randomPick:xC,redexOf:EC,REGEXP:PC,resolveNodeEnv:SC,SafeTrue:vC,search:yC,sleep:fC,SpawnMirror:bC,strClamp:A1,stringifyConfig:hC,strJustify:fY,strLimit:T8,strSlice:gC,strSplice:mC,strSurround:uC,strWrap:a,supportsColor:dC,supportsHyperlink:pC,surroundedBy:cC,Timer:lC,toPlace:iC,toShortNum:bY,Tracer:nC,writeConfig:aC,yuString:d}=M)});var j5;var gz=R(()=>{j5={name:"gdx",version:"0.4.0",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/","scripts/postinstall.cjs","scripts/launcher.cjs","README.md","LICENSE"],packageManager:"bun@1.3.5",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 --external=@shikijs/cli","ts-check":"bunx tsc --noEmit","package:node":"bun run transpile-esm && bun build ./src/index.ts --outdir=./dist --target=node --external=keytar --external=cspell-lib --external=@shikijs/cli --format=esm --production --keep-names",prepack:"bun run package:node",postinstall:"node scripts/postinstall.cjs",prettier:'prettier --write "src/**/*.ts" "test/**/*.ts" "./*.md"',"dummy-editor":"bun ./scripts/dummyEditor.mjs"},devDependencies:{"@babel/cli":"^7.28.0","@babel/core":"^7.28.0","@babel/preset-env":"^7.27.2","@babel/preset-typescript":"^7.27.1","@eslint/js":"^9.22.0","@types/chai":"^5.2.3","@typescript-eslint/eslint-plugin":"^8.13.0","@typescript-eslint/parser":"^8.13.0","bun-types":"latest",chai:"^6.2.1",dedent:"^1.7.0",eslint:"^9.22.0",execa:"^9.6.1",jiti:"^2.6.1",openai:"^6.14.0",prettier:"^3.6.2","smol-toml":"^1.5.2",tsx:"^4.21.0",typescript:"^5.8.3","typescript-eslint":"^8.50.0"},dependencies:{"@shikijs/cli":"^3.22.0","cspell-lib":"9.4.0",keytar:"^7.9.0"}}});import NZ from"fs";import DF from"path";import NF from"fs/promises";import{existsSync as o,readFileSync as Z6,writeFileSync as Q6,mkdirSync as ZY,mkdtempSync as Zk,rmSync as x1,accessSync as dz,readdirSync as J6,appendFileSync as pz,unlinkSync as T5,constants as C5}from"fs";import{access as cz,rm as lz,rmdir as Jk,mkdir as zk,readdir as Xk,readlink as Hk,stat as wZ,link as Wk,unlink as iz,writeFile as z6,appendFile as Kk,readFile as QY}from"fs/promises";async function C8(Y){if(!Y)return;try{if(!NZ.existsSync(Y))return;return(await NF.stat(Y)).mtimeMs}catch{return}}function mz(Y){if(!Y)return"";let Z=Y;try{Z=NZ.realpathSync.native?NZ.realpathSync.native(Y):NZ.realpathSync(Y)}catch{Z=DF.resolve(Y)}return process.platform==="win32"?Z.replace(/\\/g,"/").toLowerCase():Z}function uz(Y,Z){let Q=mz(Y).replace(/\/+$/,""),J=mz(Z).replace(/\/+$/,"");if(!Q||!J)return!1;if(J===Q)return!0;return J.startsWith(`${Q}/`)}var u0=()=>{};import{constants as wF}from"fs";function j(Y,Z=`
|
|
40
|
+
`){if(nz){nz(Y+Z);return}process.stdout.write(Y+Z)}async function k5(Y){try{if(!(await wZ(Y)).isFile())return!1;return await cz(Y,wF.X_OK),!0}catch{return!1}}function A5(Y,Z,Q=!1){if(Y==="")return{match:null,candidates:Z,isExact:!1};let J=[];for(let z of Z){if(z===Y)return{match:z,candidates:null,isExact:!0};if(z.startsWith(Y))J.push(z)}if(Q&&J.length>1)J=[J[0]];return{match:J.length===1?J[0]:null,candidates:J,isExact:J.includes(Y)}}function LZ(Y){return Y.map((Z)=>{if(/[\s"`$\\]/.test(Z))return`"${Z.replace(/(["\\$`])/g,"\\$1")}"`;return Z})}function x5(Y){if(!Y)return"";return Y.replace(/[/\\]/g,"_").replace(/[<>:"|?*\x00-\x1f]/g,"_")}function az(Y){return["1","true","yes","on"].includes(Y.toLowerCase())}function oz(Y,Z){let Q=Y.split(".").map(Number),J=Z.split(".").map(Number),z=Math.max(Q.length,J.length);for(let X=0;X<z;X++){let H=Q[X]||0,W=J[X]||0;if(H>W)return 1;if(H<W)return-1}return 0}var nz=null,k8=()=>{};var M0=R(()=>{u0()});import E5 from"os";import g6 from"path";var sz,C,hY,Fk,rz=".gdxrc.toml",tz,A8,P5,m6=150,u6,l0,ez,S5,_Z="gdx-cli",X6,LF="cache.json",_F="macro.json",YX="catppuccin-mocha",IZ,A,Q0,ZX,d6,QX,jZ=86400000,JY,p6,TZ=360,JX=7,zX="https://openrouter.ai/api/v1",XX=512000;var W0=R(()=>{gz();M0();sz=g6.basename(process.argv[0]||"gdx",g6.extname(process.argv[0]||"")),C=sz.startsWith("bun")?"gdx":sz,hY=process.env.GDX_TEMP_DIR||E5.tmpdir(),Fk=process.env.GDX_CURRENT_DIR||process.cwd(),tz=g6.join(E5.homedir(),".gdx"),A8=g6.join(tz,rz),P5=g6.join(E5.homedir(),rz),u6=process.env.GDX_RESULT,l0=j5.version||"unknown",ez=j5.homepage||"",S5=process.env.GDX_WRITE_LOGS!=null?az(process.env.GDX_WRITE_LOGS):!0,X6=["llm.apiKey"],IZ=["add","branch","checkout","clone","commit","diff","log","pull","push","rebase","reset","revert","merge","init","stash","status","switch"],A={OceanDeepBlue:[46,149,153],OceanGreen:[57,211,83],ForestGreen:[34,139,34],SunsetOrange:[255,99,71],MidnightBlack:[10,16,36],Zinc700:[63,63,70],Zinc400:[161,161,170],Zinc100:[244,244,245],Fuchsia400:[232,121,249],Teal300:[94,234,212]},Q0={base:[30,30,46],mantle:[24,24,37],crust:[17,17,27],surface0:[49,50,68],surface1:[69,71,90],overlay0:[147,153,178],overlay1:[127,132,156],text:[205,214,244],green:[166,227,161],red:[243,139,168],yellow:[249,226,175],blue:[137,180,250],cyan:[148,226,213],lavender:[180,190,254]},ZX=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],d6={AVG_CHARS_PER_LINE:40,AVG_LINES_PER_FUNCTION:45,AVG_LINES_PER_FILE:500},QX=[/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],JY=g6.join(hY,"gdx",LF),p6=g6.join(tz,_F)});function u(Y,Z,Q,J=0,z=1){if(J<0)J=0;else if(z>1)z=1;if(!(J<z)||qY.supportsColor<3)return Y;let X=Y.length,H=Math.floor(X*J),W=Math.floor(X*z),K=W-H,$=(Q[0]-Z[0])/K,G=(Q[1]-Z[1])/K,U=(Q[2]-Z[2])/K,B="";for(let F=0;F<X;F++)if(F<H)B+=`\x1B[38;2;${Z[0]};${Z[1]};${Z[2]}m${Y[F]}`;else if(F>=H&&F<=W){let V=F-H,O=Math.round(v0.clamp(Z[0]+$*V,0,255)),N=Math.round(v0.clamp(Z[1]+G*V,0,255)),w=Math.round(v0.clamp(Z[2]+U*V,0,255));B+=`\x1B[38;2;${O};${N};${w}m${Y[F]}`}else B+=`\x1B[38;2;${Q[0]};${Q[1]};${Q[2]}m${Y[F]}`;return B+="\x1B[0m",B}function HX(Y,Z,Q){let J=v0.clamp(Math.round(Y[0]+(Z[0]-Y[0])*Q),0,255),z=v0.clamp(Math.round(Y[1]+(Z[1]-Y[1])*Q),0,255),X=v0.clamp(Math.round(Y[2]+(Z[2]-Y[2])*Q),0,255);return[J,z,X]}function WX(Y,Z,Q,J=0.5,z=0.3){if(J<0)J=0;else if(J>1)J=1;if(z<=0||qY.supportsColor<3)return Y;let X=Y.length,H=J*X,W=z*X,K="";for(let $=0;$<X;$++){let U=Math.abs($-H)/W;U=v0.clamp(U,0,1);let B=Math.round(v0.clamp(Z[0]+(Q[0]-Z[0])*U,0,255)),F=Math.round(v0.clamp(Z[1]+(Q[1]-Z[1])*U,0,255)),V=Math.round(v0.clamp(Z[2]+(Q[2]-Z[2])*U,0,255));K+=`\x1B[38;2;${B};${F};${V}m${Y[$]}`}return K+="\x1B[0m",K}function c6(Y){let Z=v0.clamp(Math.round(Y[0]),0,255),Q=v0.clamp(Math.round(Y[1]),0,255),J=v0.clamp(Math.round(Y[2]),0,255);return(Z<<16)+(Q<<8)+J}function KX(Y,Z,Q){let J,z,X;if(Z===0)J=z=X=Q;else{let H=($,G,U)=>{if(U<0)U+=1;if(U>1)U-=1;if(U<0.16666666666666666)return $+(G-$)*6*U;if(U<0.5)return G;if(U<0.6666666666666666)return $+(G-$)*(0.6666666666666666-U)*6;return $},W=Q<0.5?Q*(1+Z):Q+Z-Q*Z,K=2*Q-W;J=H(K,W,Y+0.3333333333333333),z=H(K,W,Y),X=H(K,W,Y-0.3333333333333333)}return[Math.round(J*255),Math.round(z*255),Math.round(X*255)]}function gY(Y,Z,Q){return[Math.round(Y[0]*(1-Q)+Z[0]*Q),Math.round(Y[1]*(1-Q)+Z[1]*Q),Math.round(Y[2]*(1-Q)+Z[2]*Q)]}function y0(Y){return`\x1B[38;2;${Y[0]};${Y[1]};${Y[2]}m`}function H6(Y){return`\x1B[48;2;${Y[0]};${Y[1]};${Y[2]}m`}function E8(Y){return Y.replace(/\x1b\[[0-9;]*m/g,"")}function P8(Y){return E8(Y).length}function x8(Y,Z,Q,J,z){let W=0,K=1,$=Y;for(let G=0;G<10;G++){let B=IF($,Z,J)-Y;if(Math.abs(B)<0.000001)break;if(B>0)K=$;else W=$;$=(W+K)/2}return jF($,Q,z)}function IF(Y,Z,Q){let J=1-Y;return 3*J*J*Y*Z+3*J*Y*Y*Q+Y*Y*Y}function jF(Y,Z,Q){let J=1-Y;return 3*J*J*Y*Z+3*J*Y*Y*Q+Y*Y*Y}var GX;var T0=R(()=>{z0();GX={linear:(Y)=>Y,easeIn:(Y)=>x8(Y,0.42,0,1,1),easeOut:(Y)=>x8(Y,0,0,0.58,1),easeInOut:(Y)=>x8(Y,0.42,0,0.58,1),smooth:(Y)=>x8(Y,0.25,0.1,0.25,1),bounce:(Y)=>x8(Y,0.68,-0.55,0.265,1.55)}});var l;var C0=R(()=>{l={exitCodeOverride:-1,finalStringOutput:"",logLevel:"warn",terminalWidth:process.stdout.columns||100}});function F0(Y){if(typeof Y!=="object"||Y===null)return!1;let Z=Object.getPrototypeOf(Y);return(Z===null||Z===Object.prototype||Object.getPrototypeOf(Z)===null)&&!(Symbol.toStringTag in Y)&&!(Symbol.iterator in Y)}import{fileURLToPath as TF}from"node:url";var E1=(Y,Z)=>{let Q=y5(CF(Y));if(typeof Q!=="string")throw TypeError(`${Z} must be a string or a file URL: ${Q}.`);return Q},CF=(Y)=>v5(Y)?Y.toString():Y,v5=(Y)=>typeof Y!=="string"&&Y&&Object.getPrototypeOf(Y)===String.prototype,y5=(Y)=>Y instanceof URL?TF(Y):Y;var P1=()=>{};var CZ=(Y,Z=[],Q={})=>{let J=E1(Y,"First argument"),[z,X]=F0(Z)?[[],Z]:[Z,Q];if(!Array.isArray(z))throw TypeError(`Second argument must be either an array of arguments or an options object: ${z}`);if(z.some((K)=>typeof K==="object"&&K!==null))throw TypeError(`Second argument must be an array of strings: ${z}`);let H=z.map(String),W=H.find((K)=>K.includes("\x00"));if(W!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${W}`);if(!F0(X))throw TypeError(`Last argument must be an options object: ${X}`);return[J,H,X]};var f5=R(()=>{P1()});import{StringDecoder as kF}from"node:string_decoder";var $X,qX=(Y)=>$X.call(Y)==="[object ArrayBuffer]",L0=(Y)=>$X.call(Y)==="[object Uint8Array]",mY=(Y)=>new Uint8Array(Y.buffer,Y.byteOffset,Y.byteLength),AF,UX=(Y)=>AF.encode(Y),xF,kZ=(Y)=>xF.decode(Y),BX=(Y,Z)=>{return EF(Y,Z).join("")},EF=(Y,Z)=>{if(Z==="utf8"&&Y.every((X)=>typeof X==="string"))return Y;let Q=new kF(Z),J=Y.map((X)=>typeof X==="string"?UX(X):X).map((X)=>Q.write(X)),z=Q.end();return z===""?J:[...J,z]},S8=(Y)=>{if(Y.length===1&&L0(Y[0]))return Y[0];return b5(PF(Y))},PF=(Y)=>Y.map((Z)=>typeof Z==="string"?UX(Z):Z),b5=(Y)=>{let Z=new Uint8Array(SF(Y)),Q=0;for(let J of Y)Z.set(J,Q),Q+=J.length;return Z},SF=(Y)=>{let Z=0;for(let Q of Y)Z+=Q.length;return Z};var i0=R(()=>{({toString:$X}=Object.prototype),AF=new TextEncoder,xF=new TextDecoder});import{ChildProcess as vF}from"node:child_process";var MX=(Y)=>Array.isArray(Y)&&Array.isArray(Y.raw),OX=(Y,Z)=>{let Q=[];for(let[X,H]of Y.entries())Q=yF({templates:Y,expressions:Z,tokens:Q,index:X,template:H});if(Q.length===0)throw TypeError("Template script must not be empty");let[J,...z]=Q;return[J,z,{}]},yF=({templates:Y,expressions:Z,tokens:Q,index:J,template:z})=>{if(z===void 0)throw TypeError(`Invalid backslash sequence: ${Y.raw[J]}`);let{nextTokens:X,leadingWhitespaces:H,trailingWhitespaces:W}=fF(z,Y.raw[J]),K=FX(Q,X,H);if(J===Z.length)return K;let $=Z[J],G=Array.isArray($)?$.map((U)=>RX(U)):[RX($)];return FX(K,G,W)},fF=(Y,Z)=>{if(Z.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let Q=[],J=0,z=VX.has(Z[0]);for(let H=0,W=0;H<Y.length;H+=1,W+=1){let K=Z[W];if(VX.has(K)){if(J!==H)Q.push(Y.slice(J,H));J=H+1}else if(K==="\\"){let $=Z[W+1];if($===`
|
|
41
|
+
`)H-=1,W+=1;else if($==="u"&&Z[W+2]==="{")W=Z.indexOf("}",W+3);else W+=bF[$]??1}}let X=J===Y.length;if(!X)Q.push(Y.slice(J));return{nextTokens:Q,leadingWhitespaces:z,trailingWhitespaces:X}},VX,bF,FX=(Y,Z,Q)=>Q||Y.length===0||Z.length===0?[...Y,...Z]:[...Y.slice(0,-1),`${Y.at(-1)}${Z[0]}`,...Z.slice(1)],RX=(Y)=>{let Z=typeof Y;if(Z==="string")return Y;if(Z==="number")return String(Y);if(F0(Y)&&(("stdout"in Y)||("isMaxBuffer"in Y)))return hF(Y);if(Y instanceof vF||Object.prototype.toString.call(Y)==="[object Promise]")throw TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.");throw TypeError(`Unexpected "${Z}" in template expression`)},hF=({stdout:Y})=>{if(typeof Y==="string")return Y;if(L0(Y))return kZ(Y);if(Y===void 0)throw TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`);throw TypeError(`Unexpected "${typeof Y}" stdout in template expression`)};var DX=R(()=>{i0();VX=new Set([" ","\t","\r",`
|
|
42
|
+
`]),bF={x:3,u:5}});import h5 from"node:process";var UY=(Y)=>AZ.includes(Y),AZ,zY,xZ=(Y)=>zY[Y]??`stdio[${Y}]`;var uY=R(()=>{AZ=[h5.stdin,h5.stdout,h5.stderr],zY=["stdin","stdout","stderr"]});import{debuglog as gF}from"node:util";var wX=(Y)=>{let Z={...Y};for(let Q of u5)Z[Q]=g5(Y,Q);return Z},g5=(Y,Z)=>{let Q=Array.from({length:mF(Y)+1}),J=uF(Y[Z],Q,Z);return iF(J,Z)},mF=({stdio:Y})=>Array.isArray(Y)?Math.max(Y.length,zY.length):zY.length,uF=(Y,Z,Q)=>F0(Y)?dF(Y,Z,Q):Z.fill(Y),dF=(Y,Z,Q)=>{for(let J of Object.keys(Y).sort(pF))for(let z of cF(J,Q,Z))Z[z]=Y[J];return Z},pF=(Y,Z)=>NX(Y)<NX(Z)?1:-1,NX=(Y)=>{if(Y==="stdout"||Y==="stderr")return 0;return Y==="all"?2:1},cF=(Y,Z,Q)=>{if(Y==="ipc")return[Q.length-1];let J=m5(Y);if(J===void 0||J===0)throw TypeError(`"${Z}.${Y}" is invalid.
|
|
43
|
+
It must be "${Z}.stdout", "${Z}.stderr", "${Z}.all", "${Z}.ipc", or "${Z}.fd3", "${Z}.fd4" (and so on).`);if(J>=Q.length)throw TypeError(`"${Z}.${Y}" is invalid: that file descriptor does not exist.
|
|
44
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);return J==="all"?[1,2]:[J]},m5=(Y)=>{if(Y==="all")return Y;if(zY.includes(Y))return zY.indexOf(Y);let Z=lF.exec(Y);if(Z!==null)return Number(Z[1])},lF,iF=(Y,Z)=>Y.map((Q)=>Q===void 0?aF[Z]:Q),nF,aF,u5,dY=(Y,Z)=>Z==="ipc"?Y.at(-1):Y[Z];var pY=R(()=>{uY();lF=/^fd(\d+)$/,nF=gF("execa").enabled?"full":"none",aF={lines:!1,buffer:!0,maxBuffer:1e8,verbose:nF,stripFinalNewline:!0},u5=["lines","buffer","maxBuffer","verbose","stripFinalNewline"]});var S1=({verbose:Y},Z)=>d5(Y,Z)!=="none",v1=({verbose:Y},Z)=>!["none","short"].includes(d5(Y,Z)),LX=({verbose:Y},Z)=>{let Q=d5(Y,Z);return EZ(Q)?Q:void 0},d5=(Y,Z)=>Z===void 0?oF(Y):dY(Y,Z),oF=(Y)=>Y.find((Z)=>EZ(Z))??PZ.findLast((Z)=>Y.includes(Z)),EZ=(Y)=>typeof Y==="function",PZ;var W6=R(()=>{pY();PZ=["none","short","full"]});import{platform as sF}from"node:process";import{stripVTControlCharacters as rF}from"node:util";var _X=(Y,Z)=>{let Q=[Y,...Z],J=Q.join(" "),z=Q.map((X)=>JR(IX(X))).join(" ");return{command:J,escapedCommand:z}},v8=(Y)=>rF(Y).split(`
|
|
45
|
+
`).map((Z)=>IX(Z)).join(`
|
|
46
|
+
`),IX=(Y)=>Y.replaceAll(YR,(Z)=>tF(Z)),tF=(Y)=>{let Z=ZR[Y];if(Z!==void 0)return Z;let Q=Y.codePointAt(0),J=Q.toString(16);return Q<=QR?`\\u${J.padStart(4,"0")}`:`\\U${J}`},eF=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},YR,ZR,QR=65535,JR=(Y)=>{if(zR.test(Y))return Y;return sF==="win32"?`"${Y.replaceAll('"','""')}"`:`'${Y.replaceAll("'","'\\''")}'`},zR;var SZ=R(()=>{YR=eF(),ZR={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},zR=/^[\w./-]+$/});import jX from"node:process";function p5(){let{env:Y}=jX,{TERM:Z,TERM_PROGRAM:Q}=Y;if(jX.platform!=="win32")return Z!=="linux";return Boolean(Y.WT_SESSION)||Boolean(Y.TERMINUS_SUBLIME)||Y.ConEmuTask==="{cmd::Cmder}"||Q==="Terminus-Sublime"||Q==="vscode"||Z==="xterm-256color"||Z==="alacritty"||Z==="rxvt-unicode"||Z==="rxvt-unicode-256color"||Y.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var TX=()=>{};var CX,kX,XR,HR,WR,KR,GR,vZ,ik;var AX=R(()=>{TX();CX={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:"╱"},kX={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:"⅒"},XR={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"},HR={...CX,...kX},WR={...CX,...XR},KR=p5(),GR=KR?HR:WR,vZ=GR,ik=Object.entries(kX)});import $R from"node:tty";var qR,t=(Y,Z)=>{if(!qR)return(z)=>z;let Q=`\x1B[${Y}m`,J=`\x1B[${Z}m`;return(z)=>{let X=z+"",H=X.indexOf(J);if(H===-1)return Q+X+J;let W=Q,K=0,G=(Z===22?J:"")+Q;while(H!==-1)W+=X.slice(K,H)+G,K=H+J.length,H=X.indexOf(J,K);return W+=X.slice(K)+J,W}},ok,xX,sk,rk,tk,ek,YA,ZA,QA,JA,zA,XA,HA,WA,KA,GA,$A,yZ,qA,UA,BA,VA,FA,RA,MA,OA,DA,EX,NA,PX,wA,LA,_A,IA,jA,TA,CA,kA,AA,xA,EA;var c5=R(()=>{qR=$R?.WriteStream?.prototype?.hasColors?.()??!1,ok=t(0,0),xX=t(1,22),sk=t(2,22),rk=t(3,23),tk=t(4,24),ek=t(53,55),YA=t(7,27),ZA=t(8,28),QA=t(9,29),JA=t(30,39),zA=t(31,39),XA=t(32,39),HA=t(33,39),WA=t(34,39),KA=t(35,39),GA=t(36,39),$A=t(37,39),yZ=t(90,39),qA=t(40,49),UA=t(41,49),BA=t(42,49),VA=t(43,49),FA=t(44,49),RA=t(45,49),MA=t(46,49),OA=t(47,49),DA=t(100,49),EX=t(91,39),NA=t(92,39),PX=t(93,39),wA=t(94,39),LA=t(95,39),_A=t(96,39),IA=t(97,39),jA=t(101,49),TA=t(102,49),CA=t(103,49),kA=t(104,49),AA=t(105,49),xA=t(106,49),EA=t(107,49)});var SX=R(()=>{c5();c5()});var fX=({type:Y,message:Z,timestamp:Q,piped:J,commandId:z,result:{failed:X=!1}={},options:{reject:H=!0}})=>{let W=BR(Q),K=VR[Y]({failed:X,reject:H,piped:J}),$=FR[Y]({reject:H});return`${yZ(`[${W}]`)} ${yZ(`[${z}]`)} ${$(K)} ${$(Z)}`},BR=(Y)=>`${fZ(Y.getHours(),2)}:${fZ(Y.getMinutes(),2)}:${fZ(Y.getSeconds(),2)}.${fZ(Y.getMilliseconds(),3)}`,fZ=(Y,Z)=>String(Y).padStart(Z,"0"),vX=({failed:Y,reject:Z})=>{if(!Y)return vZ.tick;return Z?vZ.cross:vZ.warning},VR,yX=(Y)=>Y,FR;var bX=R(()=>{AX();SX();VR={command:({piped:Y})=>Y?"|":"$",output:()=>" ",ipc:()=>"*",error:vX,duration:vX},FR={command:()=>xX,output:()=>yX,ipc:()=>yX,error:({reject:Y})=>Y?EX:PX,duration:()=>yZ}});var hX=(Y,Z,Q)=>{let J=LX(Z,Q);return Y.map(({verboseLine:z,verboseObject:X})=>RR(z,X,J)).filter((z)=>z!==void 0).map((z)=>MR(z)).join("")},RR=(Y,Z,Q)=>{if(Q===void 0)return Y;let J=Q(Y,Z);if(typeof J==="string")return J},MR=(Y)=>Y.endsWith(`
|
|
54
47
|
`)?Y:`${Y}
|
|
55
|
-
`;var
|
|
56
|
-
`).map((Q)=>iH({...Z,message:Q})),iH=(Y)=>{return{verboseLine:F3(Y),verboseObject:Y}},r8=(Y)=>{let Z=typeof Y==="string"?Y:pH(Y);return R1(Z).replaceAll("\t"," ".repeat(nH))},nH=2;var M3=(Y,Z)=>{if(!L6(Z))return;g0({type:"command",verboseMessage:Y,verboseInfo:Z})};var D3=(Y,Z,Q)=>{sH(Y);let X=aH(Y);return{verbose:Y,escapedCommand:Z,commandId:X,rawOptions:Q}},aH=(Y)=>L6({verbose:Y})?oH++:void 0,oH=0n,sH=(Y)=>{for(let Z of Y){if(Z===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(Z===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!a8.includes(Z)&&!n8(Z)){let Q=a8.map((X)=>`'${X}'`).join(", ");throw TypeError(`The "verbose" option must not be ${Z}. Allowed values are: ${Q} or a function.`)}}};import{hrtime as L3}from"node:process";var e8=()=>L3.bigint(),W7=(Y)=>Number(L3.bigint()-Y)/1e6;var Y4=(Y,Z,Q)=>{let X=e8(),{command:J,escapedCommand:$}=$3(Y,Z),G=$7(Q,"verbose"),K=D3(G,$,{...Q});return M3($,K),{command:J,escapedCommand:$,startTime:X,verboseInfo:K}};var MX=Y7(KQ(),1);import fW from"node:path";import RX from"node:process";import J4 from"node:process";import hY from"node:path";function Q4(Y={}){let{env:Z=process.env,platform:Q=process.platform}=Y;if(Q!=="win32")return"PATH";return Object.keys(Z).reverse().find((X)=>X.toUpperCase()==="PATH")||"Path"}import{promisify as Ez}from"node:util";import{execFile as Cz,execFileSync as QT}from"node:child_process";import HQ from"node:path";import{fileURLToPath as kz}from"node:url";var $T=Ez(Cz);function X4(Y){return Y instanceof URL?kz(Y):Y}function zQ(Y){return{*[Symbol.iterator](){let Z=HQ.resolve(X4(Y)),Q;while(Q!==Z)yield Z,Q=Z,Z=HQ.resolve(Z,"..")}}}var Az=({cwd:Y=J4.cwd(),path:Z=J4.env[Q4()],preferLocal:Q=!0,execPath:X=J4.execPath,addExecPath:J=!0}={})=>{let $=hY.resolve(X4(Y)),G=[],K=Z.split(hY.delimiter);if(Q)Iz(G,K,$);if(J)jz(G,K,X,$);return Z===""||Z===hY.delimiter?`${G.join(hY.delimiter)}${Z}`:[...G,Z].join(hY.delimiter)},Iz=(Y,Z,Q)=>{for(let X of zQ(Q)){let J=hY.join(X,"node_modules/.bin");if(!Z.includes(J))Y.push(J)}},jz=(Y,Z,Q,X)=>{let J=hY.resolve(X,X4(Q),"..");if(!Z.includes(J))Y.push(J)},WQ=({env:Y=J4.env,...Z}={})=>{Y={...Y};let Q=Q4({env:Y});return Z.path=Y[Q],Y[Q]=Az(Z),Y};import{setTimeout as iz}from"node:timers/promises";var UQ=(Y,Z,Q)=>{let X=Q?M1:bY,J=Y instanceof m0?{}:{cause:Y};return new X(Z,J)};class m0 extends Error{}var qQ=(Y,Z)=>{Object.defineProperty(Y.prototype,"name",{value:Z,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,BQ,{value:!0,writable:!1,enumerable:!1,configurable:!1})},VQ=(Y)=>$4(Y)&&(BQ in Y),BQ=Symbol("isExecaError"),$4=(Y)=>Object.prototype.toString.call(Y)==="[object Error]";class bY extends Error{}qQ(bY,bY.name);class M1 extends Error{}qQ(M1,M1.name);import{constants as D1}from"node:os";import{constants as vz}from"node:os";var FQ=()=>{let Y=T7-RQ+1;return Array.from({length:Y},xz)},xz=(Y,Z)=>({name:`SIGRT${Z+1}`,number:RQ+Z,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),RQ=34,T7=64;import{constants as Sz}from"node:os";var MQ=[{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"}];var _7=()=>{let Y=FQ();return[...MQ,...Y].map(yz)},yz=({name:Y,number:Z,description:Q,action:X,forced:J=!1,standard:$})=>{let{signals:{[Y]:G}}=Sz,K=G!==void 0;return{name:Y,number:K?G:Z,description:Q,supported:K,action:X,forced:J,standard:$}};var fz=()=>{let Y=_7();return Object.fromEntries(Y.map(hz))},hz=({name:Y,number:Z,description:Q,supported:X,action:J,forced:$,standard:G})=>[Y,{name:Y,number:Z,description:Q,supported:X,action:J,forced:$,standard:G}],DQ=fz(),bz=()=>{let Y=_7(),Z=T7+1,Q=Array.from({length:Z},(X,J)=>gz(J,Y));return Object.assign({},...Q)},gz=(Y,Z)=>{let Q=mz(Y,Z);if(Q===void 0)return{};let{name:X,description:J,supported:$,action:G,forced:K,standard:H}=Q;return{[Y]:{name:X,number:Y,description:J,supported:$,action:G,forced:K,standard:H}}},mz=(Y,Z)=>{let Q=Z.find(({name:X})=>vz.signals[X]===Y);if(Q!==void 0)return Q;return Z.find((X)=>X.number===Y)},NT=bz();var TQ=(Y)=>{if(Y===0)throw TypeError("Invalid option `killSignal`: 0 cannot be used.");return wQ(Y,"option `killSignal`")},_Q=(Y)=>Y===0?Y:wQ(Y,"`subprocess.kill()`'s argument"),wQ=(Y,Z)=>{if(Number.isInteger(Y))return uz(Y,Z);if(typeof Y==="string")return pz(Y,Z);throw TypeError(`Invalid ${Z} ${String(Y)}: it must be a string or an integer.
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
${
|
|
60
|
-
Available signal numbers: ${
|
|
48
|
+
`;var gX=R(()=>{W6()});import{inspect as OR}from"node:util";var DY=({type:Y,verboseMessage:Z,fdNumber:Q,verboseInfo:J,result:z})=>{let X=DR({type:Y,result:z,verboseInfo:J}),H=NR(Z,X),W=hX(H,J,Q);if(W!=="")console.warn(W.slice(0,-1))},DR=({type:Y,result:Z,verboseInfo:{escapedCommand:Q,commandId:J,rawOptions:{piped:z=!1,...X}}})=>({type:Y,escapedCommand:Q,commandId:`${J}`,timestamp:new Date,piped:z,result:Z,options:X}),NR=(Y,Z)=>Y.split(`
|
|
49
|
+
`).map((Q)=>wR({...Z,message:Q})),wR=(Y)=>{return{verboseLine:fX(Y),verboseObject:Y}},bZ=(Y)=>{let Z=typeof Y==="string"?Y:OR(Y);return v8(Z).replaceAll("\t"," ".repeat(LR))},LR=2;var y1=R(()=>{SZ();bX();gX()});var mX=(Y,Z)=>{if(!S1(Z))return;DY({type:"command",verboseMessage:Y,verboseInfo:Z})};var uX=R(()=>{W6();y1()});var dX=(Y,Z,Q)=>{jR(Y);let J=_R(Y);return{verbose:Y,escapedCommand:Z,commandId:J,rawOptions:Q}},_R=(Y)=>S1({verbose:Y})?IR++:void 0,IR=0n,jR=(Y)=>{for(let Z of Y){if(Z===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(Z===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!PZ.includes(Z)&&!EZ(Z)){let Q=PZ.map((J)=>`'${J}'`).join(", ");throw TypeError(`The "verbose" option must not be ${Z}. Allowed values are: ${Q} or a function.`)}}};var pX=R(()=>{W6()});import{hrtime as cX}from"node:process";var hZ=()=>cX.bigint(),l5=(Y)=>Number(cX.bigint()-Y)/1e6;var gZ=()=>{};var mZ=(Y,Z,Q)=>{let J=hZ(),{command:z,escapedCommand:X}=_X(Y,Z),H=g5(Q,"verbose"),W=dX(H,X,{...Q});return mX(X,W),{command:z,escapedCommand:X,startTime:J,verboseInfo:W}};var i5=R(()=>{uX();pX();gZ();SZ();pY()});var oX=p0((Jx,aX)=>{aX.exports=nX;nX.sync=CR;var lX=$Y("fs");function TR(Y,Z){var Q=Z.pathExt!==void 0?Z.pathExt:process.env.PATHEXT;if(!Q)return!0;if(Q=Q.split(";"),Q.indexOf("")!==-1)return!0;for(var J=0;J<Q.length;J++){var z=Q[J].toLowerCase();if(z&&Y.substr(-z.length).toLowerCase()===z)return!0}return!1}function iX(Y,Z,Q){if(!Y.isSymbolicLink()&&!Y.isFile())return!1;return TR(Z,Q)}function nX(Y,Z,Q){lX.stat(Y,function(J,z){Q(J,J?!1:iX(z,Y,Z))})}function CR(Y,Z){return iX(lX.statSync(Y),Y,Z)}});var YH=p0((zx,eX)=>{eX.exports=rX;rX.sync=kR;var sX=$Y("fs");function rX(Y,Z,Q){sX.stat(Y,function(J,z){Q(J,J?!1:tX(z,Z))})}function kR(Y,Z){return tX(sX.statSync(Y),Z)}function tX(Y,Z){return Y.isFile()&&AR(Y,Z)}function AR(Y,Z){var{mode:Q,uid:J,gid:z}=Y,X=Z.uid!==void 0?Z.uid:process.getuid&&process.getuid(),H=Z.gid!==void 0?Z.gid:process.getgid&&process.getgid(),W=parseInt("100",8),K=parseInt("010",8),$=parseInt("001",8),G=W|K,U=Q&$||Q&K&&z===H||Q&W&&J===X||Q&G&&X===0;return U}});var QH=p0((Hx,ZH)=>{var Xx=$Y("fs"),uZ;if(process.platform==="win32"||global.TESTING_WINDOWS)uZ=oX();else uZ=YH();ZH.exports=n5;n5.sync=xR;function n5(Y,Z,Q){if(typeof Z==="function")Q=Z,Z={};if(!Q){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(J,z){n5(Y,Z||{},function(X,H){if(X)z(X);else J(H)})})}uZ(Y,Z||{},function(J,z){if(J){if(J.code==="EACCES"||Z&&Z.ignoreErrors)J=null,z=!1}Q(J,z)})}function xR(Y,Z){try{return uZ.sync(Y,Z||{})}catch(Q){if(Z&&Z.ignoreErrors||Q.code==="EACCES")return!1;else throw Q}}});var GH=p0((Wx,KH)=>{var f1=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",JH=$Y("path"),ER=f1?";":":",zH=QH(),XH=(Y)=>Object.assign(Error(`not found: ${Y}`),{code:"ENOENT"}),HH=(Y,Z)=>{let Q=Z.colon||ER,J=Y.match(/\//)||f1&&Y.match(/\\/)?[""]:[...f1?[process.cwd()]:[],...(Z.path||process.env.PATH||"").split(Q)],z=f1?Z.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",X=f1?z.split(Q):[""];if(f1){if(Y.indexOf(".")!==-1&&X[0]!=="")X.unshift("")}return{pathEnv:J,pathExt:X,pathExtExe:z}},WH=(Y,Z,Q)=>{if(typeof Z==="function")Q=Z,Z={};if(!Z)Z={};let{pathEnv:J,pathExt:z,pathExtExe:X}=HH(Y,Z),H=[],W=($)=>new Promise((G,U)=>{if($===J.length)return Z.all&&H.length?G(H):U(XH(Y));let B=J[$],F=/^".*"$/.test(B)?B.slice(1,-1):B,V=JH.join(F,Y),O=!F&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+V:V;G(K(O,$,0))}),K=($,G,U)=>new Promise((B,F)=>{if(U===z.length)return B(W(G+1));let V=z[U];zH($+V,{pathExt:X},(O,N)=>{if(!O&&N)if(Z.all)H.push($+V);else return B($+V);return B(K($,G,U+1))})});return Q?W(0).then(($)=>Q(null,$),Q):W(0)},PR=(Y,Z)=>{Z=Z||{};let{pathEnv:Q,pathExt:J,pathExtExe:z}=HH(Y,Z),X=[];for(let H=0;H<Q.length;H++){let W=Q[H],K=/^".*"$/.test(W)?W.slice(1,-1):W,$=JH.join(K,Y),G=!K&&/^\.[\\\/]/.test(Y)?Y.slice(0,2)+$:$;for(let U=0;U<J.length;U++){let B=G+J[U];try{if(zH.sync(B,{pathExt:z}))if(Z.all)X.push(B);else return B}catch(F){}}}if(Z.all&&X.length)return X;if(Z.nothrow)return null;throw XH(Y)};KH.exports=WH;WH.sync=PR});var qH=p0((Kx,a5)=>{var $H=(Y={})=>{let Z=Y.env||process.env;if((Y.platform||process.platform)!=="win32")return"PATH";return Object.keys(Z).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"};a5.exports=$H;a5.exports.default=$H});var FH=p0((Gx,VH)=>{var UH=$Y("path"),SR=GH(),vR=qH();function BH(Y,Z){let Q=Y.options.env||process.env,J=process.cwd(),z=Y.options.cwd!=null,X=z&&process.chdir!==void 0&&!process.chdir.disabled;if(X)try{process.chdir(Y.options.cwd)}catch(W){}let H;try{H=SR.sync(Y.command,{path:Q[vR({env:Q})],pathExt:Z?UH.delimiter:void 0})}catch(W){}finally{if(X)process.chdir(J)}if(H)H=UH.resolve(z?Y.options.cwd:"",H);return H}function yR(Y){return BH(Y)||BH(Y,!0)}VH.exports=yR});var RH=p0((hR,s5)=>{var o5=/([()\][%!^"`<>&|;, *?])/g;function fR(Y){return Y=Y.replace(o5,"^$1"),Y}function bR(Y,Z){if(Y=`${Y}`,Y=Y.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),Y=Y.replace(/(?=(\\+?)?)\1$/,"$1$1"),Y=`"${Y}"`,Y=Y.replace(o5,"^$1"),Z)Y=Y.replace(o5,"^$1");return Y}hR.command=fR;hR.argument=bR});var OH=p0(($x,MH)=>{MH.exports=/^#!(.*)/});var NH=p0((qx,DH)=>{var uR=OH();DH.exports=(Y="")=>{let Z=Y.match(uR);if(!Z)return null;let[Q,J]=Z[0].replace(/#! ?/,"").split(" "),z=Q.split("/").pop();if(z==="env")return J;return J?`${z} ${J}`:z}});var LH=p0((Ux,wH)=>{var r5=$Y("fs"),dR=NH();function pR(Y){let Q=Buffer.alloc(150),J;try{J=r5.openSync(Y,"r"),r5.readSync(J,Q,0,150,0),r5.closeSync(J)}catch(z){}return dR(Q.toString())}wH.exports=pR});var TH=p0((Bx,jH)=>{var cR=$Y("path"),_H=FH(),IH=RH(),lR=LH(),iR=process.platform==="win32",nR=/\.(?:com|exe)$/i,aR=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function oR(Y){Y.file=_H(Y);let Z=Y.file&&lR(Y.file);if(Z)return Y.args.unshift(Y.file),Y.command=Z,_H(Y);return Y.file}function sR(Y){if(!iR)return Y;let Z=oR(Y),Q=!nR.test(Z);if(Y.options.forceShell||Q){let J=aR.test(Z);Y.command=cR.normalize(Y.command),Y.command=IH.command(Y.command),Y.args=Y.args.map((X)=>IH.argument(X,J));let z=[Y.command].concat(Y.args).join(" ");Y.args=["/d","/s","/c",`"${z}"`],Y.command=process.env.comspec||"cmd.exe",Y.options.windowsVerbatimArguments=!0}return Y}function rR(Y,Z,Q){if(Z&&!Array.isArray(Z))Q=Z,Z=null;Z=Z?Z.slice(0):[],Q=Object.assign({},Q);let J={command:Y,args:Z,options:Q,file:void 0,original:{command:Y,args:Z}};return Q.shell?J:sR(J)}jH.exports=rR});var AH=p0((Vx,kH)=>{var t5=process.platform==="win32";function e5(Y,Z){return Object.assign(Error(`${Z} ${Y.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${Z} ${Y.command}`,path:Y.command,spawnargs:Y.args})}function tR(Y,Z){if(!t5)return;let Q=Y.emit;Y.emit=function(J,z){if(J==="exit"){let X=CH(z,Z);if(X)return Q.call(Y,"error",X)}return Q.apply(Y,arguments)}}function CH(Y,Z){if(t5&&Y===1&&!Z.file)return e5(Z.original,"spawn");return null}function eR(Y,Z){if(t5&&Y===1&&!Z.file)return e5(Z.original,"spawnSync");return null}kH.exports={hookChildProcess:tR,verifyENOENT:CH,verifyENOENTSync:eR,notFoundError:e5}});var PH=p0((Fx,b1)=>{var xH=$Y("child_process"),Y3=TH(),Z3=AH();function EH(Y,Z,Q){let J=Y3(Y,Z,Q),z=xH.spawn(J.command,J.args,J.options);return Z3.hookChildProcess(z,J),z}function YM(Y,Z,Q){let J=Y3(Y,Z,Q),z=xH.spawnSync(J.command,J.args,J.options);return z.error=z.error||Z3.verifyENOENTSync(z.status,J),z}b1.exports=EH;b1.exports.spawn=EH;b1.exports.sync=YM;b1.exports._parse=Y3;b1.exports._enoent=Z3});function dZ(Y={}){let{env:Z=process.env,platform:Q=process.platform}=Y;if(Q!=="win32")return"PATH";return Object.keys(Z).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"}import{promisify as ZM}from"node:util";import{execFile as QM,execFileSync as Dx}from"node:child_process";import SH from"node:path";import{fileURLToPath as JM}from"node:url";function pZ(Y){return Y instanceof URL?JM(Y):Y}function vH(Y){return{*[Symbol.iterator](){let Z=SH.resolve(pZ(Y)),Q;while(Q!==Z)yield Z,Q=Z,Z=SH.resolve(Z,"..")}}}var Lx;var yH=R(()=>{Lx=ZM(QM)});import cZ from"node:process";import l6 from"node:path";var zM=({cwd:Y=cZ.cwd(),path:Z=cZ.env[dZ()],preferLocal:Q=!0,execPath:J=cZ.execPath,addExecPath:z=!0}={})=>{let X=l6.resolve(pZ(Y)),H=[],W=Z.split(l6.delimiter);if(Q)XM(H,W,X);if(z)HM(H,W,J,X);return Z===""||Z===l6.delimiter?`${H.join(l6.delimiter)}${Z}`:[...H,Z].join(l6.delimiter)},XM=(Y,Z,Q)=>{for(let J of vH(Q)){let z=l6.join(J,"node_modules/.bin");if(!Z.includes(z))Y.push(z)}},HM=(Y,Z,Q,J)=>{let z=l6.resolve(J,pZ(Q),"..");if(!Z.includes(z))Y.push(z)},fH=({env:Y=cZ.env,...Z}={})=>{Y={...Y};let Q=dZ({env:Y});return Z.path=Y[Q],Y[Q]=zM(Z),Y};var bH=R(()=>{yH()});var hH=(Y,Z,Q)=>{let J=Q?y8:n0,z=Y instanceof NY?{}:{cause:Y};return new J(Z,z)},NY,gH=(Y,Z)=>{Object.defineProperty(Y.prototype,"name",{value:Z,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(Y.prototype,uH,{value:!0,writable:!1,enumerable:!1,configurable:!1})},mH=(Y)=>lZ(Y)&&(uH in Y),uH,lZ=(Y)=>Object.prototype.toString.call(Y)==="[object Error]",n0,y8;var K6=R(()=>{NY=class NY extends Error{};uH=Symbol("isExecaError");n0=class n0 extends Error{};gH(n0,n0.name);y8=class y8 extends Error{};gH(y8,y8.name)});var dH=()=>{let Y=Q3-pH+1;return Array.from({length:Y},WM)},WM=(Y,Z)=>({name:`SIGRT${Z+1}`,number:pH+Z,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),pH=34,Q3=64;var cH;var lH=R(()=>{cH=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}]});import{constants as KM}from"node:os";var J3=()=>{let Y=dH();return[...cH,...Y].map(GM)},GM=({name:Y,number:Z,description:Q,action:J,forced:z=!1,standard:X})=>{let{signals:{[Y]:H}}=KM,W=H!==void 0;return{name:Y,number:W?H:Z,description:Q,supported:W,action:J,forced:z,standard:X}};var iH=R(()=>{lH()});import{constants as $M}from"node:os";var qM=()=>{let Y=J3();return Object.fromEntries(Y.map(UM))},UM=({name:Y,number:Z,description:Q,supported:J,action:z,forced:X,standard:H})=>[Y,{name:Y,number:Z,description:Q,supported:J,action:z,forced:X,standard:H}],nH,BM=()=>{let Y=J3(),Z=Q3+1,Q=Array.from({length:Z},(J,z)=>VM(z,Y));return Object.assign({},...Q)},VM=(Y,Z)=>{let Q=FM(Y,Z);if(Q===void 0)return{};let{name:J,description:z,supported:X,action:H,forced:W,standard:K}=Q;return{[Y]:{name:J,number:Y,description:z,supported:X,action:H,forced:W,standard:K}}},FM=(Y,Z)=>{let Q=Z.find(({name:J})=>$M.signals[J]===Y);if(Q!==void 0)return Q;return Z.find((J)=>J.number===Y)},mx;var aH=R(()=>{iH();nH=qM(),mx=BM()});import{constants as f8}from"node:os";var sH=(Y)=>{if(Y===0)throw TypeError("Invalid option `killSignal`: 0 cannot be used.");return tH(Y,"option `killSignal`")},rH=(Y)=>Y===0?Y:tH(Y,"`subprocess.kill()`'s argument"),tH=(Y,Z)=>{if(Number.isInteger(Y))return RM(Y,Z);if(typeof Y==="string")return OM(Y,Z);throw TypeError(`Invalid ${Z} ${String(Y)}: it must be a string or an integer.
|
|
50
|
+
${z3()}`)},RM=(Y,Z)=>{if(oH.has(Y))return oH.get(Y);throw TypeError(`Invalid ${Z} ${Y}: this signal integer does not exist.
|
|
51
|
+
${z3()}`)},MM=()=>new Map(Object.entries(f8.signals).reverse().map(([Y,Z])=>[Z,Y])),oH,OM=(Y,Z)=>{if(Y in f8.signals)return Y;if(Y.toUpperCase()in f8.signals)throw TypeError(`Invalid ${Z} '${Y}': please rename it to '${Y.toUpperCase()}'.`);throw TypeError(`Invalid ${Z} '${Y}': this signal name does not exist.
|
|
52
|
+
${z3()}`)},z3=()=>`Available signal names: ${DM()}.
|
|
53
|
+
Available signal numbers: ${NM()}.`,DM=()=>Object.keys(f8.signals).sort().map((Y)=>`'${Y}'`).join(", "),NM=()=>[...new Set(Object.values(f8.signals).sort((Y,Z)=>Y-Z))].join(", "),iZ=(Y)=>nH[Y].description;var b8=R(()=>{aH();oH=MM()});import{setTimeout as wM}from"node:timers/promises";var eH=(Y)=>{if(Y===!1)return Y;if(Y===!0)return LM;if(!Number.isFinite(Y)||Y<0)throw TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${Y}\` (${typeof Y})`);return Y},LM=5000,YW=({kill:Y,options:{forceKillAfterDelay:Z,killSignal:Q},onInternalError:J,context:z,controller:X},H,W)=>{let{signal:K,error:$}=_M(H,W,Q);IM($,J);let G=Y(K);return jM({kill:Y,signal:K,forceKillAfterDelay:Z,killSignal:Q,killResult:G,context:z,controller:X}),G},_M=(Y,Z,Q)=>{let[J=Q,z]=lZ(Y)?[void 0,Y]:[Y,Z];if(typeof J!=="string"&&!Number.isInteger(J))throw TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(J)}`);if(z!==void 0&&!lZ(z))throw TypeError(`The second argument is optional. If specified, it must be an error instance: ${z}`);return{signal:rH(J),error:z}},IM=(Y,Z)=>{if(Y!==void 0)Z.reject(Y)},jM=async({kill:Y,signal:Z,forceKillAfterDelay:Q,killSignal:J,killResult:z,context:X,controller:H})=>{if(Z===J&&z)X3({kill:Y,forceKillAfterDelay:Q,context:X,controllerSignal:H.signal})},X3=async({kill:Y,forceKillAfterDelay:Z,context:Q,controllerSignal:J})=>{if(Z===!1)return;try{if(await wM(Z,void 0,{signal:J}),Y("SIGKILL"))Q.isForcefullyTerminated??=!0}catch{}};var nZ=R(()=>{K6();b8()});import{once as TM}from"node:events";var aZ=async(Y,Z)=>{if(!Y.aborted)await TM(Y,"abort",{signal:Z})};var H3=()=>{};var ZW=({cancelSignal:Y})=>{if(Y!==void 0&&Object.prototype.toString.call(Y)!=="[object AbortSignal]")throw Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(Y)}`)},QW=({subprocess:Y,cancelSignal:Z,gracefulCancel:Q,context:J,controller:z})=>Z===void 0||Q?[]:[CM(Y,Z,J,z)],CM=async(Y,Z,Q,{signal:J})=>{throw await aZ(Z,J),Q.terminationReason??="cancel",Y.kill(),Z.reason};var W3=R(()=>{H3()});var h1=({methodName:Y,isSubprocess:Z,ipc:Q,isConnected:J})=>{kM(Y,Z,Q),K3(Y,Z,J)},kM=(Y,Z,Q)=>{if(!Q)throw Error(`${BY(Y,Z)} can only be used if the \`ipc\` option is \`true\`.`)},K3=(Y,Z,Q)=>{if(!Q)throw Error(`${BY(Y,Z)} cannot be used: the ${G6(Z)} has already exited or disconnected.`)},JW=(Y)=>{throw Error(`${BY("getOneMessage",Y)} could not complete: the ${G6(Y)} exited or disconnected.`)},zW=(Y)=>{throw Error(`${BY("sendMessage",Y)} failed: the ${G6(Y)} is sending a message too, instead of listening to incoming messages.
|
|
61
54
|
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
62
55
|
|
|
63
56
|
const [receivedMessage] = await Promise.all([
|
|
64
|
-
${
|
|
65
|
-
${
|
|
66
|
-
]);`)},
|
|
67
|
-
It must be ${
|
|
68
|
-
It is optional and defaults to "${
|
|
69
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);if(
|
|
70
|
-
Please set this option with "pipe" instead.`},
|
|
71
|
-
Please rename it to ${
|
|
72
|
-
Please rename it to one of: ${Q}.`)},
|
|
73
|
-
${Y.message}`,Y}},
|
|
74
|
-
${
|
|
57
|
+
${BY("getOneMessage",Y)},
|
|
58
|
+
${BY("sendMessage",Y,"message, {strict: true}")},
|
|
59
|
+
]);`)},oZ=(Y,Z)=>Error(`${BY("sendMessage",Z)} failed when sending an acknowledgment response to the ${G6(Z)}.`,{cause:Y}),XW=(Y)=>{throw Error(`${BY("sendMessage",Y)} failed: the ${G6(Y)} is not listening to incoming messages.`)},HW=(Y)=>{throw Error(`${BY("sendMessage",Y)} failed: the ${G6(Y)} exited without listening to incoming messages.`)},WW=()=>Error(`\`cancelSignal\` aborted: the ${G6(!0)} disconnected.`),KW=()=>{throw Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},GW=({error:Y,methodName:Z,isSubprocess:Q})=>{if(Y.code==="EPIPE")throw Error(`${BY(Z,Q)} cannot be used: the ${G6(Q)} is disconnecting.`,{cause:Y})},$W=({error:Y,methodName:Z,isSubprocess:Q,message:J})=>{if(AM(Y))throw Error(`${BY(Z,Q)}'s argument type is invalid: the message cannot be serialized: ${String(J)}.`,{cause:Y})},AM=({code:Y,message:Z})=>xM.has(Y)||EM.some((Q)=>Z.includes(Q)),xM,EM,BY=(Y,Z,Q="")=>Y==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${PM(Z)}${Y}(${Q})`,PM=(Y)=>Y?"":"subprocess.",G6=(Y)=>Y?"parent process":"subprocess",g1=(Y)=>{if(Y.connected)Y.disconnect()};var m1=R(()=>{xM=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),EM=["could not be cloned","circular structure","call stack size exceeded"]});var wY=()=>{let Y={},Z=new Promise((Q,J)=>{Object.assign(Y,{resolve:Q,reject:J})});return Object.assign(Z,Y)};var rZ=(Y,Z="stdin")=>{let{options:J,fileDescriptors:z}=LY.get(Y),X=qW(z,Z,!0),H=Y.stdio[X];if(H===null)throw TypeError(UW(X,Z,J,!0));return H},u1=(Y,Z="stdout")=>{let{options:J,fileDescriptors:z}=LY.get(Y),X=qW(z,Z,!1),H=X==="all"?Y.all:Y.stdio[X];if(H===null||H===void 0)throw TypeError(UW(X,Z,J,!1));return H},LY,qW=(Y,Z,Q)=>{let J=SM(Z,Q);return vM(J,Z,Q,Y),J},SM=(Y,Z)=>{let Q=m5(Y);if(Q!==void 0)return Q;let{validOptions:J,defaultValue:z}=Z?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw TypeError(`"${h8(Z)}" must not be "${Y}".
|
|
60
|
+
It must be ${J} or "fd3", "fd4" (and so on).
|
|
61
|
+
It is optional and defaults to "${z}".`)},vM=(Y,Z,Q,J)=>{let z=J[BW(Y)];if(z===void 0)throw TypeError(`"${h8(Q)}" must not be ${Z}. That file descriptor does not exist.
|
|
62
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);if(z.direction==="input"&&!Q)throw TypeError(`"${h8(Q)}" must not be ${Z}. It must be a readable stream, not writable.`);if(z.direction!=="input"&&Q)throw TypeError(`"${h8(Q)}" must not be ${Z}. It must be a writable stream, not readable.`)},UW=(Y,Z,Q,J)=>{if(Y==="all"&&!Q.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:z,optionValue:X}=yM(Y,Q);return`The "${z}: ${sZ(X)}" option is incompatible with using "${h8(J)}: ${sZ(Z)}".
|
|
63
|
+
Please set this option with "pipe" instead.`},yM=(Y,{stdin:Z,stdout:Q,stderr:J,stdio:z})=>{let X=BW(Y);if(X===0&&Z!==void 0)return{optionName:"stdin",optionValue:Z};if(X===1&&Q!==void 0)return{optionName:"stdout",optionValue:Q};if(X===2&&J!==void 0)return{optionName:"stderr",optionValue:J};return{optionName:`stdio[${X}]`,optionValue:z[X]}},BW=(Y)=>Y==="all"?1:Y,h8=(Y)=>Y?"to":"from",sZ=(Y)=>{if(typeof Y==="string")return`'${Y}'`;return typeof Y==="number"?`${Y}`:"Stream"};var $6=R(()=>{pY();LY=new WeakMap});import{addAbortListener as fM}from"node:events";var i6=(Y,Z,Q)=>{let J=Y.getMaxListeners();if(J===0||J===Number.POSITIVE_INFINITY)return;Y.setMaxListeners(J+Z),fM(Q,()=>{Y.setMaxListeners(Y.getMaxListeners()-Z)})};var tZ=()=>{};var eZ=(Y,Z)=>{if(Z)G3(Y)},G3=(Y)=>{Y.refCounted()},Y7=(Y,Z)=>{if(Z)$3(Y)},$3=(Y)=>{Y.unrefCounted()},VW=(Y,Z)=>{if(Z)$3(Y),$3(Y)},FW=(Y,Z)=>{if(Z)G3(Y),G3(Y)};import{once as bM}from"node:events";import{scheduler as hM}from"node:timers/promises";var RW=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipcEmitter:J},z)=>{if(NW(z)||LW(z))return;if(!Z7.has(Y))Z7.set(Y,[]);let X=Z7.get(Y);if(X.push(z),X.length>1)return;while(X.length>0){await wW(Y,J,z),await hM.yield();let H=await DW({wrappedMessage:X[0],anyProcess:Y,channel:Z,isSubprocess:Q,ipcEmitter:J});X.shift(),J.emit("message",H),J.emit("message:done")}},MW=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipcEmitter:J,boundOnMessage:z})=>{q3();let X=Z7.get(Y);while(X?.length>0)await bM(J,"message:done");Y.removeListener("message",z),FW(Z,Q),J.connected=!1,J.emit("disconnect")},Z7;var OW=R(()=>{J7();Q7();z7();Z7=new WeakMap});import{EventEmitter as gM}from"node:events";var q6=(Y,Z,Q)=>{if(X7.has(Y))return X7.get(Y);let J=new gM;return J.connected=!0,X7.set(Y,J),mM({ipcEmitter:J,anyProcess:Y,channel:Z,isSubprocess:Q}),J},X7,mM=({ipcEmitter:Y,anyProcess:Z,channel:Q,isSubprocess:J})=>{let z=RW.bind(void 0,{anyProcess:Z,channel:Q,isSubprocess:J,ipcEmitter:Y});Z.on("message",z),Z.once("disconnect",MW.bind(void 0,{anyProcess:Z,channel:Q,isSubprocess:J,ipcEmitter:Y,boundOnMessage:z})),VW(Q,J)},H7=(Y)=>{let Z=X7.get(Y);return Z===void 0?Y.channel!==null:Z.connected};var g8=R(()=>{OW();X7=new WeakMap});import{once as uM}from"node:events";var _W=({anyProcess:Y,channel:Z,isSubprocess:Q,message:J,strict:z})=>{if(!z)return J;let X=q6(Y,Z,Q),H=G7(Y,X);return{id:dM++,type:K7,message:J,hasListeners:H}},dM=0n,IW=(Y,Z)=>{if(Z?.type!==K7||Z.hasListeners)return;for(let{id:Q}of Y)if(Q!==void 0)W7[Q].resolve({isDeadlock:!0,hasListeners:!1})},DW=async({wrappedMessage:Y,anyProcess:Z,channel:Q,isSubprocess:J,ipcEmitter:z})=>{if(Y?.type!==K7||!Z.connected)return Y;let{id:X,message:H}=Y,W={id:X,type:TW,message:G7(Z,z)};try{await $7({anyProcess:Z,channel:Q,isSubprocess:J,ipc:!0},W)}catch(K){z.emit("strict:error",K)}return H},NW=(Y)=>{if(Y?.type!==TW)return!1;let{id:Z,message:Q}=Y;return W7[Z]?.resolve({isDeadlock:!1,hasListeners:Q}),!0},jW=async(Y,Z,Q)=>{if(Y?.type!==K7)return;let J=wY();W7[Y.id]=J;let z=new AbortController;try{let{isDeadlock:X,hasListeners:H}=await Promise.race([J,pM(Z,Q,z)]);if(X)zW(Q);if(!H)XW(Q)}finally{z.abort(),delete W7[Y.id]}},W7,pM=async(Y,Z,{signal:Q})=>{i6(Y,1,Q),await uM(Y,"disconnect",{signal:Q}),HW(Z)},K7="execa:ipc:request",TW="execa:ipc:response";var Q7=R(()=>{tZ();q7();m1();g8();J7();W7={}});var CW=(Y,Z,Q)=>{if(!m8.has(Y))m8.set(Y,new Set);let J=m8.get(Y),z=wY(),X=Q?Z.id:void 0,H={onMessageSent:z,id:X};return J.add(H),{outgoingMessages:J,outgoingMessage:H}},kW=({outgoingMessages:Y,outgoingMessage:Z})=>{Y.delete(Z),Z.onMessageSent.resolve()},wW=async(Y,Z,Q)=>{while(!G7(Y,Z)&&m8.get(Y)?.size>0){let J=[...m8.get(Y)];IW(J,Q),await Promise.all(J.map(({onMessageSent:z})=>z))}},m8,G7=(Y,Z)=>Z.listenerCount("message")>cM(Y),cM=(Y)=>LY.has(Y)&&!dY(LY.get(Y).options.buffer,"ipc")?1:0;var J7=R(()=>{pY();$6();Q7();m8=new WeakMap});import{promisify as lM}from"node:util";var $7=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},z,{strict:X=!1}={})=>{return h1({methodName:"sendMessage",isSubprocess:Q,ipc:J,isConnected:Y.connected}),iM({anyProcess:Y,channel:Z,methodName:"sendMessage",isSubprocess:Q,message:z,strict:X})},iM=async({anyProcess:Y,channel:Z,methodName:Q,isSubprocess:J,message:z,strict:X})=>{let H=_W({anyProcess:Y,channel:Z,isSubprocess:J,message:z,strict:X}),W=CW(Y,H,X);try{await B3({anyProcess:Y,methodName:Q,isSubprocess:J,wrappedMessage:H,message:z})}catch(K){throw g1(Y),K}finally{kW(W)}},B3=async({anyProcess:Y,methodName:Z,isSubprocess:Q,wrappedMessage:J,message:z})=>{let X=nM(Y);try{await Promise.all([jW(J,Y,Q),X(J)])}catch(H){throw GW({error:H,methodName:Z,isSubprocess:Q}),$W({error:H,methodName:Z,isSubprocess:Q,message:z}),H}},nM=(Y)=>{if(U3.has(Y))return U3.get(Y);let Z=lM(Y.send.bind(Y));return U3.set(Y,Z),Z},U3;var q7=R(()=>{m1();J7();Q7();U3=new WeakMap});import{scheduler as aM}from"node:timers/promises";var xW=(Y,Z)=>{return K3("cancelSignal",!1,Y.connected),B3({anyProcess:Y,methodName:"cancelSignal",isSubprocess:!1,wrappedMessage:{type:PW,message:Z},message:Z})},EW=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J})=>{return await oM({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J}),V3.signal},oM=async({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J})=>{if(AW)return;if(AW=!0,!J){KW();return}if(Z===null){q3();return}q6(Y,Z,Q),await aM.yield()},AW=!1,LW=(Y)=>{if(Y?.type!==PW)return!1;return V3.abort(Y.message),!0},PW="execa:ipc:cancel",q3=()=>{V3.abort(WW())},V3;var z7=R(()=>{q7();g8();m1();V3=new AbortController});var SW=({gracefulCancel:Y,cancelSignal:Z,ipc:Q,serialization:J})=>{if(!Y)return;if(Z===void 0)throw Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!Q)throw Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(J==="json")throw Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")},vW=({subprocess:Y,cancelSignal:Z,gracefulCancel:Q,forceKillAfterDelay:J,context:z,controller:X})=>Q?[sM({subprocess:Y,cancelSignal:Z,forceKillAfterDelay:J,context:z,controller:X})]:[],sM=async({subprocess:Y,cancelSignal:Z,forceKillAfterDelay:Q,context:J,controller:{signal:z}})=>{await aZ(Z,z);let X=rM(Z);throw await xW(Y,X),X3({kill:Y.kill,forceKillAfterDelay:Q,context:J,controllerSignal:z}),J.terminationReason??="gracefulCancel",Z.reason},rM=({reason:Y})=>{if(!(Y instanceof DOMException))return Y;let Z=Error(Y.message);return Object.defineProperty(Z,"stack",{value:Y.stack,enumerable:!1,configurable:!0,writable:!0}),Z};var F3=R(()=>{H3();z7();nZ()});import{setTimeout as tM}from"node:timers/promises";var yW=({timeout:Y})=>{if(Y!==void 0&&(!Number.isFinite(Y)||Y<0))throw TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${Y}\` (${typeof Y})`)},fW=(Y,Z,Q,J)=>Z===0||Z===void 0?[]:[eM(Y,Z,Q,J)],eM=async(Y,Z,Q,{signal:J})=>{throw await tM(Z,void 0,{signal:J}),Q.terminationReason??="timeout",Y.kill(),new NY};var R3=R(()=>{K6()});import{execPath as YO,execArgv as ZO}from"node:process";import bW from"node:path";var hW=({options:Y})=>{if(Y.node===!1)throw TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...Y,node:!0}}},gW=(Y,Z,{node:Q=!1,nodePath:J=YO,nodeOptions:z=ZO.filter((K)=>!K.startsWith("--inspect")),cwd:X,execPath:H,...W})=>{if(H!==void 0)throw TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let K=E1(J,'The "nodePath" option'),$=bW.resolve(X,K),G={...W,nodePath:$,node:Q,cwd:X};if(!Q)return[Y,Z,G];if(bW.basename(Y,".exe")==="node")throw TypeError('When the "node" option is true, the first argument does not need to be "node".');return[$,[...z,Y,...Z],{ipc:!0,...G,shell:!1}]};var M3=R(()=>{P1()});import{serialize as QO}from"node:v8";var mW=({ipcInput:Y,ipc:Z,serialization:Q})=>{if(Y===void 0)return;if(!Z)throw Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");XO[Q](Y)},JO=(Y)=>{try{QO(Y)}catch(Z){throw Error("The `ipcInput` option is not serializable with a structured clone.",{cause:Z})}},zO=(Y)=>{try{JSON.stringify(Y)}catch(Z){throw Error("The `ipcInput` option is not serializable with JSON.",{cause:Z})}},XO,uW=async(Y,Z)=>{if(Z===void 0)return;await Y.sendMessage(Z)};var O3=R(()=>{XO={advanced:JO,json:zO}});var pW=({encoding:Y})=>{if(D3.has(Y))return;let Z=WO(Y);if(Z!==void 0)throw TypeError(`Invalid option \`encoding: ${U7(Y)}\`.
|
|
64
|
+
Please rename it to ${U7(Z)}.`);let Q=[...D3].map((J)=>U7(J)).join(", ");throw TypeError(`Invalid option \`encoding: ${U7(Y)}\`.
|
|
65
|
+
Please rename it to one of: ${Q}.`)},HO,a0,D3,WO=(Y)=>{if(Y===null)return"buffer";if(typeof Y!=="string")return;let Z=Y.toLowerCase();if(Z in dW)return dW[Z];if(D3.has(Z))return Z},dW,U7=(Y)=>typeof Y==="string"?`"${Y}"`:String(Y);var n6=R(()=>{HO=new Set(["utf8","utf16le"]),a0=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),D3=new Set([...HO,...a0]),dW={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"}});import{statSync as KO}from"node:fs";import GO from"node:path";import $O from"node:process";var cW=(Y=lW())=>{let Z=E1(Y,'The "cwd" option');return GO.resolve(Z)},lW=()=>{try{return $O.cwd()}catch(Y){throw Y.message=`The current directory does not exist.
|
|
66
|
+
${Y.message}`,Y}},iW=(Y,Z)=>{if(Z===lW())return Y;let Q;try{Q=KO(Z)}catch(J){return`The "cwd" option is invalid: ${Z}.
|
|
67
|
+
${J.message}
|
|
75
68
|
${Y}`}if(!Q.isDirectory())return`The "cwd" option is not a directory: ${Z}.
|
|
76
|
-
${Y}`;return Y};var
|
|
77
|
-
`,
|
|
78
|
-
${
|
|
79
|
-
`)].map((
|
|
80
|
-
|
|
81
|
-
`);return{originalMessage:
|
|
82
|
-
`):hX(Y),hX=(Y)=>{if(typeof Y==="string")return Y;if(G0(Y))return c8(Y);return""};var j4=({command:Y,escapedCommand:Z,stdio:Q,all:X,ipcOutput:J,options:{cwd:$},startTime:G})=>gX({command:Y,escapedCommand:Z,cwd:$,durationMs:W7(G),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:Q[1],stderr:Q[2],all:X,stdio:Q,ipcOutput:J,pipedFrom:[]}),k6=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:X,options:J,startTime:$,isSync:G})=>N1({error:Y,command:Z,escapedCommand:Q,startTime:$,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:X.length}),ipcOutput:[],options:J,isSync:G}),N1=({error:Y,command:Z,escapedCommand:Q,startTime:X,timedOut:J,isCanceled:$,isGracefullyCanceled:G,isMaxBuffer:K,isForcefullyTerminated:H,exitCode:W,signal:z,stdio:q,all:V,ipcOutput:R,options:{timeoutDuration:B,timeout:M=B,forceKillAfterDelay:T,killSignal:D,cwd:_,maxBuffer:w},isSync:N})=>{let{exitCode:j,signal:x,signalDescription:f}=PU(W,z),{originalMessage:m,shortMessage:b,message:v}=bX({stdio:q,all:V,ipcOutput:R,originalError:Y,signal:x,signalDescription:f,exitCode:j,escapedCommand:Q,timedOut:J,isCanceled:$,isGracefullyCanceled:G,isMaxBuffer:K,isForcefullyTerminated:H,forceKillAfterDelay:T,killSignal:D,maxBuffer:w,timeout:M,cwd:_}),d=UQ(Y,v,N);return Object.assign(d,OU({error:d,command:Z,escapedCommand:Q,startTime:X,timedOut:J,isCanceled:$,isGracefullyCanceled:G,isMaxBuffer:K,isForcefullyTerminated:H,exitCode:j,signal:x,signalDescription:f,stdio:q,all:V,ipcOutput:R,cwd:_,originalMessage:m,shortMessage:b})),d},OU=({error:Y,command:Z,escapedCommand:Q,startTime:X,timedOut:J,isCanceled:$,isGracefullyCanceled:G,isMaxBuffer:K,isForcefullyTerminated:H,exitCode:W,signal:z,signalDescription:q,stdio:V,all:R,ipcOutput:B,cwd:M,originalMessage:T,shortMessage:D})=>gX({shortMessage:D,originalMessage:T,command:Z,escapedCommand:Q,cwd:M,durationMs:W7(X),failed:!0,timedOut:J,isCanceled:$,isGracefullyCanceled:G,isTerminated:z!==void 0,isMaxBuffer:K,isForcefullyTerminated:H,exitCode:W,signal:z,signalDescription:q,code:Y.cause?.code,stdout:V[1],stderr:V[2],all:R,stdio:V,ipcOutput:B,pipedFrom:[]}),gX=(Y)=>Object.fromEntries(Object.entries(Y).filter(([,Z])=>Z!==void 0)),PU=(Y,Z)=>{let Q=Y===null?void 0:Y,X=Z===null?void 0:Z,J=X===void 0?void 0:G4(Z);return{exitCode:Q,signal:X,signalDescription:J}};var mX=(Y)=>Number.isFinite(Y)?Y:0;function EU(Y){return{days:Math.trunc(Y/86400000),hours:Math.trunc(Y/3600000%24),minutes:Math.trunc(Y/60000%60),seconds:Math.trunc(Y/1000%60),milliseconds:Math.trunc(Y%1000),microseconds:Math.trunc(mX(Y*1000)%1000),nanoseconds:Math.trunc(mX(Y*1e6)%1000)}}function CU(Y){return{days:Y/86400000n,hours:Y/3600000n%24n,minutes:Y/60000n%60n,seconds:Y/1000n%60n,milliseconds:Y%1000n,microseconds:0n,nanoseconds:0n}}function f7(Y){switch(typeof Y){case"number":{if(Number.isFinite(Y))return EU(Y);break}case"bigint":return CU(Y)}throw TypeError("Expected a finite number or bigint")}var kU=(Y)=>Y===0||Y===0n,AU=(Y,Z)=>Z===1||Z===1n?Y:`${Y}s`,IU=0.0000001,jU=24n*60n*60n*1000n;function h7(Y,Z){let Q=typeof Y==="bigint";if(!Q&&!Number.isFinite(Y))throw TypeError("Expected a finite number or bigint");Z={...Z};let X=Y<0?"-":"";if(Y=Y<0?-Y:Y,Z.colonNotation)Z.compact=!1,Z.formatSubMilliseconds=!1,Z.separateMilliseconds=!1,Z.verbose=!1;if(Z.compact)Z.unitCount=1,Z.secondsDecimalDigits=0,Z.millisecondsDecimalDigits=0;let J=[],$=(z,q)=>{let V=Math.floor(z*10**q+IU);return(Math.round(V)/10**q).toFixed(q)},G=(z,q,V,R)=>{if((J.length===0||!Z.colonNotation)&&kU(z)&&!(Z.colonNotation&&V==="m"))return;if(R??=String(z),Z.colonNotation){let B=R.includes(".")?R.split(".")[0].length:R.length,M=J.length>0?2:1;R="0".repeat(Math.max(0,M-B))+R}else R+=Z.verbose?" "+AU(q,z):V;J.push(R)},K=f7(Y),H=BigInt(K.days);if(Z.hideYearAndDays)G(BigInt(H)*24n+BigInt(K.hours),"hour","h");else{if(Z.hideYear)G(H,"day","d");else G(H/365n,"year","y"),G(H%365n,"day","d");G(Number(K.hours),"hour","h")}if(G(Number(K.minutes),"minute","m"),!Z.hideSeconds)if(Z.separateMilliseconds||Z.formatSubMilliseconds||!Z.colonNotation&&Y<1000&&!Z.subSecondsAsDecimals){let z=Number(K.seconds),q=Number(K.milliseconds),V=Number(K.microseconds),R=Number(K.nanoseconds);if(G(z,"second","s"),Z.formatSubMilliseconds)G(q,"millisecond","ms"),G(V,"microsecond","µs"),G(R,"nanosecond","ns");else{let B=q+V/1000+R/1e6,M=typeof Z.millisecondsDecimalDigits==="number"?Z.millisecondsDecimalDigits:0,T=B>=1?Math.round(B):Math.ceil(B),D=M?B.toFixed(M):T;G(Number.parseFloat(D),"millisecond","ms",D)}}else{let z=(Q?Number(Y%jU):Y)/1000%60,q=typeof Z.secondsDecimalDigits==="number"?Z.secondsDecimalDigits:1,V=$(z,q),R=Z.keepDecimalsOnWholeSeconds?V:V.replace(/\.0+$/,"");G(Number.parseFloat(R),"second","s",R)}if(J.length===0)return X+"0"+(Z.verbose?" milliseconds":"ms");let W=Z.colonNotation?":":" ";if(typeof Z.unitCount==="number")J=J.slice(0,Math.max(Z.unitCount,1));return X+J.join(W)}var uX=(Y,Z)=>{if(Y.failed)g0({type:"error",verboseMessage:Y.shortMessage,verboseInfo:Z,result:Y})};var dX=(Y,Z)=>{if(!L6(Z))return;uX(Y,Z),xU(Y,Z)},xU=(Y,Z)=>{let Q=`(done in ${h7(Y.durationMs)})`;g0({type:"duration",verboseMessage:Q,verboseInfo:Z,result:Y})};var A6=(Y,Z,{reject:Q})=>{if(dX(Y,Z),Y.failed&&Q)throw Y;return Y};import{readFileSync as FJ}from"node:fs";var lX=(Y,Z)=>{if(uY(Y))return"asyncGenerator";if(aX(Y))return"generator";if(x4(Y))return"fileUrl";if(hU(Y))return"filePath";if(mU(Y))return"webStream";if(f0(Y,{checkOpen:!1}))return"native";if(G0(Y))return"uint8Array";if(uU(Y))return"asyncIterable";if(dU(Y))return"iterable";if(m7(Y))return iX({transform:Y},Z);if(fU(Y))return SU(Y,Z);return"native"},SU=(Y,Z)=>{if(S7(Y.transform,{checkOpen:!1}))return yU(Y,Z);if(m7(Y.transform))return iX(Y,Z);return vU(Y,Z)},yU=(Y,Z)=>{return nX(Y,Z,"Duplex stream"),"duplex"},iX=(Y,Z)=>{return nX(Y,Z,"web TransformStream"),"webTransform"},nX=({final:Y,binary:Z,objectMode:Q},X,J)=>{pX(Y,`${X}.final`,J),pX(Z,`${X}.binary`,J),b7(Q,`${X}.objectMode`)},pX=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Z}\` option can only be defined when using a generator, not a ${Q}.`)},vU=({transform:Y,final:Z,binary:Q,objectMode:X},J)=>{if(Y!==void 0&&!cX(Y))throw TypeError(`The \`${J}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(S7(Z,{checkOpen:!1}))throw TypeError(`The \`${J}.final\` option must not be a Duplex stream.`);if(m7(Z))throw TypeError(`The \`${J}.final\` option must not be a web TransformStream.`);if(Z!==void 0&&!cX(Z))throw TypeError(`The \`${J}.final\` option must be a generator.`);return b7(Q,`${J}.binary`),b7(X,`${J}.objectMode`),uY(Y)||uY(Z)?"asyncGenerator":"generator"},b7=(Y,Z)=>{if(Y!==void 0&&typeof Y!=="boolean")throw TypeError(`The \`${Z}\` option must use a boolean.`)},cX=(Y)=>uY(Y)||aX(Y),uY=(Y)=>Object.prototype.toString.call(Y)==="[object AsyncGeneratorFunction]",aX=(Y)=>Object.prototype.toString.call(Y)==="[object GeneratorFunction]",fU=(Y)=>e(Y)&&(Y.transform!==void 0||Y.final!==void 0),x4=(Y)=>Object.prototype.toString.call(Y)==="[object URL]",oX=(Y)=>x4(Y)&&Y.protocol!=="file:",hU=(Y)=>e(Y)&&Object.keys(Y).length>0&&Object.keys(Y).every((Z)=>bU.has(Z))&&g7(Y.file),bU=new Set(["file","append"]),g7=(Y)=>typeof Y==="string",sX=(Y,Z)=>Y==="native"&&typeof Z==="string"&&!gU.has(Z),gU=new Set(["ipc","ignore","inherit","overlapped","pipe"]),tX=(Y)=>Object.prototype.toString.call(Y)==="[object ReadableStream]",S4=(Y)=>Object.prototype.toString.call(Y)==="[object WritableStream]",mU=(Y)=>tX(Y)||S4(Y),m7=(Y)=>tX(Y?.readable)&&S4(Y?.writable),uU=(Y)=>rX(Y)&&typeof Y[Symbol.asyncIterator]==="function",dU=(Y)=>rX(Y)&&typeof Y[Symbol.iterator]==="function",rX=(Y)=>typeof Y==="object"&&Y!==null,x0=new Set(["generator","asyncGenerator","duplex","webTransform"]),y4=new Set(["fileUrl","filePath","fileNumber"]),u7=new Set(["fileUrl","filePath"]),eX=new Set([...u7,"webStream","nodeStream"]),YJ=new Set(["webTransform","duplex"]),FY={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 d7=(Y,Z,Q,X)=>X==="output"?pU(Y,Z,Q):cU(Y,Z,Q),pU=(Y,Z,Q)=>{let X=Z!==0&&Q[Z-1].value.readableObjectMode;return{writableObjectMode:X,readableObjectMode:Y??X}},cU=(Y,Z,Q)=>{let X=Z===0?Y===!0:Q[Z-1].value.readableObjectMode,J=Z!==Q.length-1&&(Y??X);return{writableObjectMode:X,readableObjectMode:J}},ZJ=(Y,Z)=>{let Q=Y.findLast(({type:X})=>x0.has(X));if(Q===void 0)return!1;return Z==="input"?Q.value.writableObjectMode:Q.value.readableObjectMode};var QJ=(Y,Z,Q,X)=>[...Y.filter(({type:J})=>!x0.has(J)),...lU(Y,Z,Q,X)],lU=(Y,Z,Q,{encoding:X})=>{let J=Y.filter(({type:G})=>x0.has(G)),$=Array.from({length:J.length});for(let[G,K]of Object.entries(J))$[G]=iU({stdioItem:K,index:Number(G),newTransforms:$,optionName:Z,direction:Q,encoding:X});return sU($,Q)},iU=({stdioItem:Y,stdioItem:{type:Z},index:Q,newTransforms:X,optionName:J,direction:$,encoding:G})=>{if(Z==="duplex")return nU({stdioItem:Y,optionName:J});if(Z==="webTransform")return aU({stdioItem:Y,index:Q,newTransforms:X,direction:$});return oU({stdioItem:Y,index:Q,newTransforms:X,direction:$,encoding:G})},nU=({stdioItem:Y,stdioItem:{value:{transform:Z,transform:{writableObjectMode:Q,readableObjectMode:X},objectMode:J=X}},optionName:$})=>{if(J&&!X)throw TypeError(`The \`${$}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!J&&X)throw TypeError(`The \`${$}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...Y,value:{transform:Z,writableObjectMode:Q,readableObjectMode:X}}},aU=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:X,direction:J})=>{let{transform:$,objectMode:G}=e(Z)?Z:{transform:Z},{writableObjectMode:K,readableObjectMode:H}=d7(G,Q,X,J);return{...Y,value:{transform:$,writableObjectMode:K,readableObjectMode:H}}},oU=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:X,direction:J,encoding:$})=>{let{transform:G,final:K,binary:H=!1,preserveNewlines:W=!1,objectMode:z}=e(Z)?Z:{transform:Z},q=H||O0.has($),{writableObjectMode:V,readableObjectMode:R}=d7(z,Q,X,J);return{...Y,value:{transform:G,final:K,binary:q,preserveNewlines:W,writableObjectMode:V,readableObjectMode:R}}},sU=(Y,Z)=>Z==="input"?Y.reverse():Y;import p7 from"node:process";var XJ=(Y,Z,Q)=>{let X=Y.map((J)=>tU(J,Z));if(X.includes("input")&&X.includes("output"))throw TypeError(`The \`${Q}\` option must not be an array of both readable and writable values.`);return X.find(Boolean)??Yq},tU=({type:Y,value:Z},Q)=>rU[Q]??JJ[Y](Z),rU=["input","output","output"],I6=()=>{return},c7=()=>"input",JJ={generator:I6,asyncGenerator:I6,fileUrl:I6,filePath:I6,iterable:c7,asyncIterable:c7,uint8Array:c7,webStream:(Y)=>S4(Y)?"output":"input",nodeStream(Y){if(!mY(Y,{checkOpen:!1}))return"output";return x7(Y,{checkOpen:!1})?void 0:"input"},webTransform:I6,duplex:I6,native(Y){let Z=eU(Y);if(Z!==void 0)return Z;if(f0(Y,{checkOpen:!1}))return JJ.nodeStream(Y)}},eU=(Y)=>{if([0,p7.stdin].includes(Y))return"input";if([1,2,p7.stdout,p7.stderr].includes(Y))return"output"},Yq="output";var $J=(Y,Z)=>Z&&!Y.includes("ipc")?[...Y,"ipc"]:Y;var GJ=({stdio:Y,ipc:Z,buffer:Q,...X},J,$)=>{let G=Zq(Y,X).map((K,H)=>KJ(K,H));return $?Xq(G,Q,J):$J(G,Z)},Zq=(Y,Z)=>{if(Y===void 0)return j0.map((X)=>Z[X]);if(Qq(Z))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${j0.map((X)=>`\`${X}\``).join(", ")}`);if(typeof Y==="string")return[Y,Y,Y];if(!Array.isArray(Y))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof Y}\``);let Q=Math.max(Y.length,j0.length);return Array.from({length:Q},(X,J)=>Y[J])},Qq=(Y)=>j0.some((Z)=>Y[Z]!==void 0),KJ=(Y,Z)=>{if(Array.isArray(Y))return Y.map((Q)=>KJ(Q,Z));if(Y===null||Y===void 0)return Z>=j0.length?"ignore":"pipe";return Y},Xq=(Y,Z,Q)=>Y.map((X,J)=>!Z[J]&&J!==0&&!T6(Q,J)&&Jq(X)?"ignore":X),Jq=(Y)=>Y==="pipe"||Array.isArray(Y)&&Y.every((Z)=>Z==="pipe");import{readFileSync as $q}from"node:fs";import Gq from"node:tty";var zJ=({stdioItem:Y,stdioItem:{type:Z},isStdioArray:Q,fdNumber:X,direction:J,isSync:$})=>{if(!Q||Z!=="native")return Y;return $?Kq({stdioItem:Y,fdNumber:X,direction:J}):Wq({stdioItem:Y,fdNumber:X})},Kq=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:X,direction:J})=>{let $=Hq({value:Z,optionName:Q,fdNumber:X,direction:J});if($!==void 0)return $;if(f0(Z,{checkOpen:!1}))throw TypeError(`The \`${Q}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return Y},Hq=({value:Y,optionName:Z,fdNumber:Q,direction:X})=>{let J=zq(Y,Q);if(J===void 0)return;if(X==="output")return{type:"fileNumber",value:J,optionName:Z};if(Gq.isatty(J))throw TypeError(`The \`${Z}: ${z4(Y)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:r0($q(J)),optionName:Z}},zq=(Y,Z)=>{if(Y==="inherit")return Z;if(typeof Y==="number")return Y;let Q=l8.indexOf(Y);if(Q!==-1)return Q},Wq=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:X})=>{if(Z==="inherit")return{type:"nodeStream",value:HJ(X,Z,Q),optionName:Q};if(typeof Z==="number")return{type:"nodeStream",value:HJ(Z,Z,Q),optionName:Q};if(f0(Z,{checkOpen:!1}))return{type:"nodeStream",value:Z,optionName:Q};return Y},HJ=(Y,Z,Q)=>{let X=l8[Y];if(X===void 0)throw TypeError(`The \`${Q}: ${Z}\` option is invalid: no such standard stream.`);return X};var WJ=({input:Y,inputFile:Z},Q)=>Q===0?[...Uq(Y),...Vq(Z)]:[],Uq=(Y)=>Y===void 0?[]:[{type:qq(Y),value:Y,optionName:"input"}],qq=(Y)=>{if(mY(Y,{checkOpen:!1}))return"nodeStream";if(typeof Y==="string")return"string";if(G0(Y))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},Vq=(Y)=>Y===void 0?[]:[{...Bq(Y),optionName:"inputFile"}],Bq=(Y)=>{if(x4(Y))return{type:"fileUrl",value:Y};if(g7(Y))return{type:"filePath",value:{file:Y}};throw Error("The `inputFile` option must be a file path string or a file URL.")};var UJ=(Y)=>Y.filter((Z,Q)=>Y.every((X,J)=>Z.value!==X.value||Q>=J||Z.type==="generator"||Z.type==="asyncGenerator")),qJ=({stdioItem:{type:Y,value:Z,optionName:Q},direction:X,fileDescriptors:J,isSync:$})=>{let G=Fq(J,Y);if(G.length===0)return;if($){Rq({otherStdioItems:G,type:Y,value:Z,optionName:Q,direction:X});return}if(eX.has(Y))return VJ({otherStdioItems:G,type:Y,value:Z,optionName:Q,direction:X});if(YJ.has(Y))Dq({otherStdioItems:G,type:Y,value:Z,optionName:Q})},Fq=(Y,Z)=>Y.flatMap(({direction:Q,stdioItems:X})=>X.filter((J)=>J.type===Z).map((J)=>({...J,direction:Q}))),Rq=({otherStdioItems:Y,type:Z,value:Q,optionName:X,direction:J})=>{if(u7.has(Z))VJ({otherStdioItems:Y,type:Z,value:Q,optionName:X,direction:J})},VJ=({otherStdioItems:Y,type:Z,value:Q,optionName:X,direction:J})=>{let $=Y.filter((K)=>Mq(K,Q));if($.length===0)return;let G=$.find((K)=>K.direction!==J);return BJ(G,X,Z),J==="output"?$[0].stream:void 0},Mq=({type:Y,value:Z},Q)=>{if(Y==="filePath")return Z.file===Q.file;if(Y==="fileUrl")return Z.href===Q.href;return Z===Q},Dq=({otherStdioItems:Y,type:Z,value:Q,optionName:X})=>{let J=Y.find(({value:{transform:$}})=>$===Q.transform);BJ(J,X,Z)},BJ=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Y.optionName}\` and \`${Z}\` options must not target ${FY[Q]} that is the same.`)};var v4=(Y,Z,Q,X)=>{let $=GJ(Z,Q,X).map((K,H)=>Lq({stdioOption:K,fdNumber:H,options:Z,isSync:X})),G=Cq({initialFileDescriptors:$,addProperties:Y,options:Z,isSync:X});return Z.stdio=G.map(({stdioItems:K})=>Iq(K)),G},Lq=({stdioOption:Y,fdNumber:Z,options:Q,isSync:X})=>{let J=i8(Z),{stdioItems:$,isStdioArray:G}=Tq({stdioOption:Y,fdNumber:Z,options:Q,optionName:J}),K=XJ($,Z,J),H=$.map((q)=>zJ({stdioItem:q,isStdioArray:G,fdNumber:Z,direction:K,isSync:X})),W=QJ(H,J,K,Q),z=ZJ(W,K);return Eq(W,z),{direction:K,objectMode:z,stdioItems:W}},Tq=({stdioOption:Y,fdNumber:Z,options:Q,optionName:X})=>{let $=[...(Array.isArray(Y)?Y:[Y]).map((H)=>_q(H,X)),...WJ(Q,Z)],G=UJ($),K=G.length>1;return wq(G,K,X),Oq(G),{stdioItems:G,isStdioArray:K}},_q=(Y,Z)=>({type:lX(Y,Z),value:Y,optionName:Z}),wq=(Y,Z,Q)=>{if(Y.length===0)throw TypeError(`The \`${Q}\` option must not be an empty array.`);if(!Z)return;for(let{value:X,optionName:J}of Y)if(Nq.has(X))throw Error(`The \`${J}\` option must not include \`${X}\`.`)},Nq=new Set(["ignore","ipc"]),Oq=(Y)=>{for(let Z of Y)Pq(Z)},Pq=({type:Y,value:Z,optionName:Q})=>{if(oX(Z))throw TypeError(`The \`${Q}: URL\` option must use the \`file:\` scheme.
|
|
83
|
-
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(
|
|
84
|
-
`){let
|
|
69
|
+
${Y}`;return Y};var N3=R(()=>{P1()});import qO from"node:path";import nW from"node:process";var aW,B7=(Y,Z,Q)=>{Q.cwd=cW(Q.cwd);let[J,z,X]=gW(Y,Z,Q),{command:H,args:W,options:K}=aW.default._parse(J,z,X),$=wX(K),G=UO($);if(yW(G),pW(G),mW(G),ZW(G),SW(G),G.shell=y5(G.shell),G.env=BO(G),G.killSignal=sH(G.killSignal),G.forceKillAfterDelay=eH(G.forceKillAfterDelay),G.lines=G.lines.map((U,B)=>U&&!a0.has(G.encoding)&&G.buffer[B]),nW.platform==="win32"&&qO.basename(H,".exe")==="cmd")W.unshift("/q");return{file:H,commandArguments:W,options:G}},UO=({extendEnv:Y=!0,preferLocal:Z=!1,cwd:Q,localDir:J=Q,encoding:z="utf8",reject:X=!0,cleanup:H=!0,all:W=!1,windowsHide:K=!0,killSignal:$="SIGTERM",forceKillAfterDelay:G=!0,gracefulCancel:U=!1,ipcInput:B,ipc:F=B!==void 0||U,serialization:V="advanced",...O})=>({...O,extendEnv:Y,preferLocal:Z,cwd:Q,localDirectory:J,encoding:z,reject:X,cleanup:H,all:W,windowsHide:K,killSignal:$,forceKillAfterDelay:G,gracefulCancel:U,ipcInput:B,ipc:F,serialization:V}),BO=({env:Y,extendEnv:Z,preferLocal:Q,node:J,localDirectory:z,nodePath:X})=>{let H=Z?{...nW.env,...Y}:Y;if(Q||J)return fH({env:H,cwd:z,execPath:X,preferLocal:Q,addExecPath:J});return H};var w3=R(()=>{bH();nZ();b8();W3();F3();R3();M3();O3();n6();N3();P1();pY();aW=OZ(PH(),1)});var V7=(Y,Z,Q)=>Q.shell&&Z.length>0?[[Y,...Z].join(" "),[],Q]:[Y,Z,Q];function d1(Y){if(typeof Y==="string")return VO(Y);if(!(ArrayBuffer.isView(Y)&&Y.BYTES_PER_ELEMENT===1))throw Error("Input must be a string or a Uint8Array");return FO(Y)}var VO=(Y)=>Y.at(-1)===oW?Y.slice(0,Y.at(-2)===sW?-2:-1):Y,FO=(Y)=>Y.at(-1)===RO?Y.subarray(0,Y.at(-2)===MO?-2:-1):Y,oW=`
|
|
70
|
+
`,RO,sW="\r",MO;var L3=R(()=>{RO=oW.codePointAt(0),MO=sW.codePointAt(0)});function VY(Y,{checkOpen:Z=!0}={}){return Y!==null&&typeof Y==="object"&&(Y.writable||Y.readable||!Z||Y.writable===void 0&&Y.readable===void 0)&&typeof Y.pipe==="function"}function _3(Y,{checkOpen:Z=!0}={}){return VY(Y,{checkOpen:Z})&&(Y.writable||!Z)&&typeof Y.write==="function"&&typeof Y.end==="function"&&typeof Y.writable==="boolean"&&typeof Y.writableObjectMode==="boolean"&&typeof Y.destroy==="function"&&typeof Y.destroyed==="boolean"}function a6(Y,{checkOpen:Z=!0}={}){return VY(Y,{checkOpen:Z})&&(Y.readable||!Z)&&typeof Y.read==="function"&&typeof Y.readable==="boolean"&&typeof Y.readableObjectMode==="boolean"&&typeof Y.destroy==="function"&&typeof Y.destroyed==="boolean"}function I3(Y,Z){return _3(Y,Z)&&a6(Y,Z)}class rW{#Z;#Q;#Y=!1;#J=void 0;constructor(Y,Z){this.#Z=Y,this.#Q=Z}next(){let Y=()=>this.#z();return this.#J=this.#J?this.#J.then(Y,Y):Y(),this.#J}return(Y){let Z=()=>this.#X(Y);return this.#J?this.#J.then(Z,Z):Z()}async#z(){if(this.#Y)return{done:!0,value:void 0};let Y;try{Y=await this.#Z.read()}catch(Z){throw this.#J=void 0,this.#Y=!0,this.#Z.releaseLock(),Z}return Y.done&&(this.#J=void 0,this.#Y=!0,this.#Z.releaseLock()),Y}async#X(Y){if(this.#Y)return{done:!0,value:Y};if(this.#Y=!0,!this.#Q){let Z=this.#Z.cancel(Y);return this.#Z.releaseLock(),await Z,{done:!0,value:Y}}return this.#Z.releaseLock(),{done:!0,value:Y}}}function tW(){return this[j3].next()}function eW(Y){return this[j3].return(Y)}function T3({preventCancel:Y=!1}={}){let Z=this.getReader(),Q=new rW(Z,Y),J=Object.create(DO);return J[j3]=Q,J}var OO,j3,DO;var YK=R(()=>{OO=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype);j3=Symbol();Object.defineProperty(tW,"name",{value:"next"});Object.defineProperty(eW,"name",{value:"return"});DO=Object.create(OO,{next:{enumerable:!0,configurable:!0,writable:!0,value:tW},return:{enumerable:!0,configurable:!0,writable:!0,value:eW}})});var ZK=()=>{};var QK=R(()=>{YK();ZK()});var JK=(Y)=>{if(a6(Y,{checkOpen:!1})&&u8.on!==void 0)return wO(Y);if(typeof Y?.[Symbol.asyncIterator]==="function")return Y;if(NO.call(Y)==="[object ReadableStream]")return T3.call(Y);throw TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},NO,wO=async function*(Y){let Z=new AbortController,Q={};LO(Y,Z,Q);try{for await(let[J]of u8.on(Y,"data",{signal:Z.signal}))yield J}catch(J){if(Q.error!==void 0)throw Q.error;else if(!Z.signal.aborted)throw J}finally{Y.destroy()}},LO=async(Y,Z,Q)=>{try{await u8.finished(Y,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(J){Q.error=J}finally{Z.abort()}},u8;var C3=R(()=>{QK();({toString:NO}=Object.prototype),u8={}});var p1=async(Y,{init:Z,convertChunk:Q,getSize:J,truncateChunk:z,addChunk:X,getFinalChunk:H,finalize:W},{maxBuffer:K=Number.POSITIVE_INFINITY}={})=>{let $=JK(Y),G=Z();G.length=0;try{for await(let U of $){let B=IO(U),F=Q[B](U,G);HK({convertedChunk:F,state:G,getSize:J,truncateChunk:z,addChunk:X,maxBuffer:K})}return _O({state:G,convertChunk:Q,getSize:J,truncateChunk:z,addChunk:X,getFinalChunk:H,maxBuffer:K}),W(G)}catch(U){let B=typeof U==="object"&&U!==null?U:Error(U);throw B.bufferedData=W(G),B}},_O=({state:Y,getSize:Z,truncateChunk:Q,addChunk:J,getFinalChunk:z,maxBuffer:X})=>{let H=z(Y);if(H!==void 0)HK({convertedChunk:H,state:Y,getSize:Z,truncateChunk:Q,addChunk:J,maxBuffer:X})},HK=({convertedChunk:Y,state:Z,getSize:Q,truncateChunk:J,addChunk:z,maxBuffer:X})=>{let H=Q(Y),W=Z.length+H;if(W<=X){zK(Y,Z,z,W);return}let K=J(Y,X-Z.length);if(K!==void 0)zK(K,Z,z,X);throw new cY},zK=(Y,Z,Q,J)=>{Z.contents=Q(Y,Z,J),Z.length=J},IO=(Y)=>{let Z=typeof Y;if(Z==="string")return"string";if(Z!=="object"||Y===null)return"others";if(globalThis.Buffer?.isBuffer(Y))return"buffer";let Q=XK.call(Y);if(Q==="[object ArrayBuffer]")return"arrayBuffer";if(Q==="[object DataView]")return"dataView";if(Number.isInteger(Y.byteLength)&&Number.isInteger(Y.byteOffset)&&XK.call(Y.buffer)==="[object ArrayBuffer]")return"typedArray";return"others"},XK,cY;var d8=R(()=>{C3();({toString:XK}=Object.prototype);cY=class cY extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}}});var lY=(Y)=>Y,p8=()=>{return},F7=({contents:Y})=>Y,R7=(Y)=>{throw Error(`Streams in object mode are not supported: ${String(Y)}`)},M7=(Y)=>Y.length;async function O7(Y,Z){return p1(Y,kO,Z)}var jO=()=>({contents:[]}),TO=()=>1,CO=(Y,{contents:Z})=>{return Z.push(Y),Z},kO;var WK=R(()=>{d8();kO={init:jO,convertChunk:{string:lY,buffer:lY,arrayBuffer:lY,dataView:lY,typedArray:lY,others:lY},getSize:TO,truncateChunk:p8,addChunk:CO,getFinalChunk:p8,finalize:F7}});async function D7(Y,Z){return p1(Y,bO,Z)}var AO=()=>({contents:new ArrayBuffer(0)}),xO=(Y)=>EO.encode(Y),EO,KK=(Y)=>new Uint8Array(Y),GK=(Y)=>new Uint8Array(Y.buffer,Y.byteOffset,Y.byteLength),PO=(Y,Z)=>Y.slice(0,Z),SO=(Y,{contents:Z,length:Q},J)=>{let z=UK()?yO(Z,J):vO(Z,J);return new Uint8Array(z).set(Y,Q),z},vO=(Y,Z)=>{if(Z<=Y.byteLength)return Y;let Q=new ArrayBuffer(qK(Z));return new Uint8Array(Q).set(new Uint8Array(Y),0),Q},yO=(Y,Z)=>{if(Z<=Y.maxByteLength)return Y.resize(Z),Y;let Q=new ArrayBuffer(Z,{maxByteLength:qK(Z)});return new Uint8Array(Q).set(new Uint8Array(Y),0),Q},qK=(Y)=>$K**Math.ceil(Math.log(Y)/Math.log($K)),$K=2,fO=({contents:Y,length:Z})=>UK()?Y:Y.slice(0,Z),UK=()=>("resize"in ArrayBuffer.prototype),bO;var BK=R(()=>{d8();EO=new TextEncoder,bO={init:AO,convertChunk:{string:xO,buffer:KK,arrayBuffer:KK,dataView:GK,typedArray:GK,others:R7},getSize:M7,truncateChunk:PO,addChunk:SO,getFinalChunk:p8,finalize:fO}});async function w7(Y,Z){return p1(Y,dO,Z)}var hO=()=>({contents:"",textDecoder:new TextDecoder}),N7=(Y,{textDecoder:Z})=>Z.decode(Y,{stream:!0}),gO=(Y,{contents:Z})=>Z+Y,mO=(Y,Z)=>Y.slice(0,Z),uO=({textDecoder:Y})=>{let Z=Y.decode();return Z===""?void 0:Z},dO;var VK=R(()=>{d8();dO={init:hO,convertChunk:{string:lY,buffer:N7,arrayBuffer:N7,dataView:N7,typedArray:N7,others:R7},getSize:M7,truncateChunk:mO,addChunk:gO,getFinalChunk:uO,finalize:F7}});var FK=R(()=>{WK();BK();VK();d8()});import{on as pO}from"node:events";import{finished as cO}from"node:stream/promises";var L7=R(()=>{C3();FK();Object.assign(u8,{on:pO,finished:cO})});var RK=({error:Y,stream:Z,readableObjectMode:Q,lines:J,encoding:z,fdNumber:X})=>{if(!(Y instanceof cY))throw Y;if(X==="all")return Y;let H=lO(Q,J,z);throw Y.maxBufferInfo={fdNumber:X,unit:H},Z.destroy(),Y},lO=(Y,Z,Q)=>{if(Y)return"objects";if(Z)return"lines";if(Q==="buffer")return"bytes";return"characters"},MK=(Y,Z,Q)=>{if(Z.length!==Q)return;let J=new cY;throw J.maxBufferInfo={fdNumber:"ipc"},J},OK=(Y,Z)=>{let{streamName:Q,threshold:J,unit:z}=iO(Y,Z);return`Command's ${Q} was larger than ${J} ${z}`},iO=(Y,Z)=>{if(Y?.maxBufferInfo===void 0)return{streamName:"output",threshold:Z[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:Q,unit:J}}=Y;delete Y.maxBufferInfo;let z=dY(Z,Q);if(Q==="ipc")return{streamName:"IPC output",threshold:z,unit:"messages"};return{streamName:xZ(Q),threshold:z,unit:J}},DK=(Y,Z,Q)=>Y?.code==="ENOBUFS"&&Z!==null&&Z.some((J)=>J!==null&&J.length>_7(Q)),NK=(Y,Z,Q)=>{if(!Z)return Y;let J=_7(Q);return Y.length>J?Y.slice(0,J):Y},_7=([,Y])=>Y;var o6=R(()=>{L7();uY();pY()});import{inspect as nO}from"node:util";var LK=({stdio:Y,all:Z,ipcOutput:Q,originalError:J,signal:z,signalDescription:X,exitCode:H,escapedCommand:W,timedOut:K,isCanceled:$,isGracefullyCanceled:G,isMaxBuffer:U,isForcefullyTerminated:B,forceKillAfterDelay:F,killSignal:V,maxBuffer:O,timeout:N,cwd:w})=>{let L=J?.code,I=aO({originalError:J,timedOut:K,timeout:N,isMaxBuffer:U,maxBuffer:O,errorCode:L,signal:z,signalDescription:X,exitCode:H,isCanceled:$,isGracefullyCanceled:G,isForcefullyTerminated:B,forceKillAfterDelay:F,killSignal:V}),T=sO(J,w),y=T===void 0?"":`
|
|
71
|
+
${T}`,E=`${I}: ${W}${y}`,P=Z===void 0?[Y[2],Y[1]]:[Z],m=[E,...P,...Y.slice(3),Q.map((g)=>rO(g)).join(`
|
|
72
|
+
`)].map((g)=>v8(d1(tO(g)))).filter(Boolean).join(`
|
|
73
|
+
|
|
74
|
+
`);return{originalMessage:T,shortMessage:E,message:m}},aO=({originalError:Y,timedOut:Z,timeout:Q,isMaxBuffer:J,maxBuffer:z,errorCode:X,signal:H,signalDescription:W,exitCode:K,isCanceled:$,isGracefullyCanceled:G,isForcefullyTerminated:U,forceKillAfterDelay:B,killSignal:F})=>{let V=oO(U,B);if(Z)return`Command timed out after ${Q} milliseconds${V}`;if(G){if(H===void 0)return`Command was gracefully canceled with exit code ${K}`;return U?`Command was gracefully canceled${V}`:`Command was gracefully canceled with ${H} (${W})`}if($)return`Command was canceled${V}`;if(J)return`${OK(Y,z)}${V}`;if(X!==void 0)return`Command failed with ${X}${V}`;if(U)return`Command was killed with ${F} (${iZ(F)})${V}`;if(H!==void 0)return`Command was killed with ${H} (${W})`;if(K!==void 0)return`Command failed with exit code ${K}`;return"Command failed"},oO=(Y,Z)=>Y?` and was forcefully terminated after ${Z} milliseconds`:"",sO=(Y,Z)=>{if(Y instanceof NY)return;let Q=mH(Y)?Y.originalMessage:String(Y?.message??Y),J=v8(iW(Q,Z));return J===""?void 0:J},rO=(Y)=>typeof Y==="string"?Y:nO(Y),tO=(Y)=>Array.isArray(Y)?Y.map((Z)=>d1(wK(Z))).filter(Boolean).join(`
|
|
75
|
+
`):wK(Y),wK=(Y)=>{if(typeof Y==="string")return Y;if(L0(Y))return kZ(Y);return""};var _K=R(()=>{L3();i0();N3();SZ();o6();b8();K6()});var I7=({command:Y,escapedCommand:Z,stdio:Q,all:J,ipcOutput:z,options:{cwd:X},startTime:H})=>IK({command:Y,escapedCommand:Z,cwd:X,durationMs:l5(H),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:Q[1],stderr:Q[2],all:J,stdio:Q,ipcOutput:z,pipedFrom:[]}),c1=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:X,isSync:H})=>c8({error:Y,command:Z,escapedCommand:Q,startTime:X,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:J.length}),ipcOutput:[],options:z,isSync:H}),c8=({error:Y,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:$,signal:G,stdio:U,all:B,ipcOutput:F,options:{timeoutDuration:V,timeout:O=V,forceKillAfterDelay:N,killSignal:w,cwd:L,maxBuffer:I},isSync:T})=>{let{exitCode:y,signal:E,signalDescription:P}=YD($,G),{originalMessage:m,shortMessage:g,message:b}=LK({stdio:U,all:B,ipcOutput:F,originalError:Y,signal:E,signalDescription:P,exitCode:y,escapedCommand:Q,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,forceKillAfterDelay:N,killSignal:w,maxBuffer:I,timeout:O,cwd:L}),c=hH(Y,b,T);return Object.assign(c,eO({error:c,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:y,signal:E,signalDescription:P,stdio:U,all:B,ipcOutput:F,cwd:L,originalMessage:m,shortMessage:g})),c},eO=({error:Y,command:Z,escapedCommand:Q,startTime:J,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:$,signal:G,signalDescription:U,stdio:B,all:F,ipcOutput:V,cwd:O,originalMessage:N,shortMessage:w})=>IK({shortMessage:w,originalMessage:N,command:Z,escapedCommand:Q,cwd:O,durationMs:l5(J),failed:!0,timedOut:z,isCanceled:X,isGracefullyCanceled:H,isTerminated:G!==void 0,isMaxBuffer:W,isForcefullyTerminated:K,exitCode:$,signal:G,signalDescription:U,code:Y.cause?.code,stdout:B[1],stderr:B[2],all:F,stdio:B,ipcOutput:V,pipedFrom:[]}),IK=(Y)=>Object.fromEntries(Object.entries(Y).filter(([,Z])=>Z!==void 0)),YD=(Y,Z)=>{let Q=Y===null?void 0:Y,J=Z===null?void 0:Z,z=J===void 0?void 0:iZ(Z);return{exitCode:Q,signal:J,signalDescription:z}};var l8=R(()=>{b8();gZ();K6();_K()});function ZD(Y){return{days:Math.trunc(Y/86400000),hours:Math.trunc(Y/3600000%24),minutes:Math.trunc(Y/60000%60),seconds:Math.trunc(Y/1000%60),milliseconds:Math.trunc(Y%1000),microseconds:Math.trunc(jK(Y*1000)%1000),nanoseconds:Math.trunc(jK(Y*1e6)%1000)}}function QD(Y){return{days:Y/86400000n,hours:Y/3600000n%24n,minutes:Y/60000n%60n,seconds:Y/1000n%60n,milliseconds:Y%1000n,microseconds:0n,nanoseconds:0n}}function k3(Y){switch(typeof Y){case"number":{if(Number.isFinite(Y))return ZD(Y);break}case"bigint":return QD(Y)}throw TypeError("Expected a finite number or bigint")}var jK=(Y)=>Number.isFinite(Y)?Y:0;function A3(Y,Z){let Q=typeof Y==="bigint";if(!Q&&!Number.isFinite(Y))throw TypeError("Expected a finite number or bigint");Z={...Z};let J=Y<0?"-":"";if(Y=Y<0?-Y:Y,Z.colonNotation)Z.compact=!1,Z.formatSubMilliseconds=!1,Z.separateMilliseconds=!1,Z.verbose=!1;if(Z.compact)Z.unitCount=1,Z.secondsDecimalDigits=0,Z.millisecondsDecimalDigits=0;let z=[],X=(G,U)=>{let B=Math.floor(G*10**U+XD);return(Math.round(B)/10**U).toFixed(U)},H=(G,U,B,F)=>{if((z.length===0||!Z.colonNotation)&&JD(G)&&!(Z.colonNotation&&B==="m"))return;if(F??=String(G),Z.colonNotation){let V=F.includes(".")?F.split(".")[0].length:F.length,O=z.length>0?2:1;F="0".repeat(Math.max(0,O-V))+F}else F+=Z.verbose?" "+zD(U,G):B;z.push(F)},W=k3(Y),K=BigInt(W.days);if(Z.hideYearAndDays)H(BigInt(K)*24n+BigInt(W.hours),"hour","h");else{if(Z.hideYear)H(K,"day","d");else H(K/365n,"year","y"),H(K%365n,"day","d");H(Number(W.hours),"hour","h")}if(H(Number(W.minutes),"minute","m"),!Z.hideSeconds)if(Z.separateMilliseconds||Z.formatSubMilliseconds||!Z.colonNotation&&Y<1000&&!Z.subSecondsAsDecimals){let G=Number(W.seconds),U=Number(W.milliseconds),B=Number(W.microseconds),F=Number(W.nanoseconds);if(H(G,"second","s"),Z.formatSubMilliseconds)H(U,"millisecond","ms"),H(B,"microsecond","µs"),H(F,"nanosecond","ns");else{let V=U+B/1000+F/1e6,O=typeof Z.millisecondsDecimalDigits==="number"?Z.millisecondsDecimalDigits:0,N=V>=1?Math.round(V):Math.ceil(V),w=O?V.toFixed(O):N;H(Number.parseFloat(w),"millisecond","ms",w)}}else{let G=(Q?Number(Y%HD):Y)/1000%60,U=typeof Z.secondsDecimalDigits==="number"?Z.secondsDecimalDigits:1,B=X(G,U),F=Z.keepDecimalsOnWholeSeconds?B:B.replace(/\.0+$/,"");H(Number.parseFloat(F),"second","s",F)}if(z.length===0)return J+"0"+(Z.verbose?" milliseconds":"ms");let $=Z.colonNotation?":":" ";if(typeof Z.unitCount==="number")z=z.slice(0,Math.max(Z.unitCount,1));return J+z.join($)}var JD=(Y)=>Y===0||Y===0n,zD=(Y,Z)=>Z===1||Z===1n?Y:`${Y}s`,XD=0.0000001,HD;var TK=R(()=>{HD=24n*60n*60n*1000n});var CK=(Y,Z)=>{if(Y.failed)DY({type:"error",verboseMessage:Y.shortMessage,verboseInfo:Z,result:Y})};var kK=R(()=>{y1()});var AK=(Y,Z)=>{if(!S1(Z))return;CK(Y,Z),WD(Y,Z)},WD=(Y,Z)=>{let Q=`(done in ${A3(Y.durationMs)})`;DY({type:"duration",verboseMessage:Q,verboseInfo:Z,result:Y})};var xK=R(()=>{TK();W6();y1();kK()});var l1=(Y,Z,{reject:Q})=>{if(AK(Y,Z),Y.failed&&Q)throw Y;return Y};var j7=R(()=>{xK()});var SK=(Y,Z)=>{if(s6(Y))return"asyncGenerator";if(fK(Y))return"generator";if(T7(Y))return"fileUrl";if(UD(Y))return"filePath";if(FD(Y))return"webStream";if(VY(Y,{checkOpen:!1}))return"native";if(L0(Y))return"uint8Array";if(RD(Y))return"asyncIterable";if(MD(Y))return"iterable";if(P3(Y))return vK({transform:Y},Z);if(qD(Y))return KD(Y,Z);return"native"},KD=(Y,Z)=>{if(I3(Y.transform,{checkOpen:!1}))return GD(Y,Z);if(P3(Y.transform))return vK(Y,Z);return $D(Y,Z)},GD=(Y,Z)=>{return yK(Y,Z,"Duplex stream"),"duplex"},vK=(Y,Z)=>{return yK(Y,Z,"web TransformStream"),"webTransform"},yK=({final:Y,binary:Z,objectMode:Q},J,z)=>{EK(Y,`${J}.final`,z),EK(Z,`${J}.binary`,z),x3(Q,`${J}.objectMode`)},EK=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Z}\` option can only be defined when using a generator, not a ${Q}.`)},$D=({transform:Y,final:Z,binary:Q,objectMode:J},z)=>{if(Y!==void 0&&!PK(Y))throw TypeError(`The \`${z}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(I3(Z,{checkOpen:!1}))throw TypeError(`The \`${z}.final\` option must not be a Duplex stream.`);if(P3(Z))throw TypeError(`The \`${z}.final\` option must not be a web TransformStream.`);if(Z!==void 0&&!PK(Z))throw TypeError(`The \`${z}.final\` option must be a generator.`);return x3(Q,`${z}.binary`),x3(J,`${z}.objectMode`),s6(Y)||s6(Z)?"asyncGenerator":"generator"},x3=(Y,Z)=>{if(Y!==void 0&&typeof Y!=="boolean")throw TypeError(`The \`${Z}\` option must use a boolean.`)},PK=(Y)=>s6(Y)||fK(Y),s6=(Y)=>Object.prototype.toString.call(Y)==="[object AsyncGeneratorFunction]",fK=(Y)=>Object.prototype.toString.call(Y)==="[object GeneratorFunction]",qD=(Y)=>F0(Y)&&(Y.transform!==void 0||Y.final!==void 0),T7=(Y)=>Object.prototype.toString.call(Y)==="[object URL]",bK=(Y)=>T7(Y)&&Y.protocol!=="file:",UD=(Y)=>F0(Y)&&Object.keys(Y).length>0&&Object.keys(Y).every((Z)=>BD.has(Z))&&E3(Y.file),BD,E3=(Y)=>typeof Y==="string",hK=(Y,Z)=>Y==="native"&&typeof Z==="string"&&!VD.has(Z),VD,gK=(Y)=>Object.prototype.toString.call(Y)==="[object ReadableStream]",C7=(Y)=>Object.prototype.toString.call(Y)==="[object WritableStream]",FD=(Y)=>gK(Y)||C7(Y),P3=(Y)=>gK(Y?.readable)&&C7(Y?.writable),RD=(Y)=>mK(Y)&&typeof Y[Symbol.asyncIterator]==="function",MD=(Y)=>mK(Y)&&typeof Y[Symbol.iterator]==="function",mK=(Y)=>typeof Y==="object"&&Y!==null,XY,k7,S3,uK,dK,U6;var h0=R(()=>{i0();BD=new Set(["file","append"]),VD=new Set(["ipc","ignore","inherit","overlapped","pipe"]),XY=new Set(["generator","asyncGenerator","duplex","webTransform"]),k7=new Set(["fileUrl","filePath","fileNumber"]),S3=new Set(["fileUrl","filePath"]),uK=new Set([...S3,"webStream","nodeStream"]),dK=new Set(["webTransform","duplex"]),U6={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"}});var v3=(Y,Z,Q,J)=>J==="output"?OD(Y,Z,Q):DD(Y,Z,Q),OD=(Y,Z,Q)=>{let J=Z!==0&&Q[Z-1].value.readableObjectMode;return{writableObjectMode:J,readableObjectMode:Y??J}},DD=(Y,Z,Q)=>{let J=Z===0?Y===!0:Q[Z-1].value.readableObjectMode,z=Z!==Q.length-1&&(Y??J);return{writableObjectMode:J,readableObjectMode:z}},pK=(Y,Z)=>{let Q=Y.findLast(({type:J})=>XY.has(J));if(Q===void 0)return!1;return Z==="input"?Q.value.writableObjectMode:Q.value.readableObjectMode};var y3=R(()=>{h0()});var cK=(Y,Z,Q,J)=>[...Y.filter(({type:z})=>!XY.has(z)),...ND(Y,Z,Q,J)],ND=(Y,Z,Q,{encoding:J})=>{let z=Y.filter(({type:H})=>XY.has(H)),X=Array.from({length:z.length});for(let[H,W]of Object.entries(z))X[H]=wD({stdioItem:W,index:Number(H),newTransforms:X,optionName:Z,direction:Q,encoding:J});return jD(X,Q)},wD=({stdioItem:Y,stdioItem:{type:Z},index:Q,newTransforms:J,optionName:z,direction:X,encoding:H})=>{if(Z==="duplex")return LD({stdioItem:Y,optionName:z});if(Z==="webTransform")return _D({stdioItem:Y,index:Q,newTransforms:J,direction:X});return ID({stdioItem:Y,index:Q,newTransforms:J,direction:X,encoding:H})},LD=({stdioItem:Y,stdioItem:{value:{transform:Z,transform:{writableObjectMode:Q,readableObjectMode:J},objectMode:z=J}},optionName:X})=>{if(z&&!J)throw TypeError(`The \`${X}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!z&&J)throw TypeError(`The \`${X}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...Y,value:{transform:Z,writableObjectMode:Q,readableObjectMode:J}}},_D=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:J,direction:z})=>{let{transform:X,objectMode:H}=F0(Z)?Z:{transform:Z},{writableObjectMode:W,readableObjectMode:K}=v3(H,Q,J,z);return{...Y,value:{transform:X,writableObjectMode:W,readableObjectMode:K}}},ID=({stdioItem:Y,stdioItem:{value:Z},index:Q,newTransforms:J,direction:z,encoding:X})=>{let{transform:H,final:W,binary:K=!1,preserveNewlines:$=!1,objectMode:G}=F0(Z)?Z:{transform:Z},U=K||a0.has(X),{writableObjectMode:B,readableObjectMode:F}=v3(G,Q,J,z);return{...Y,value:{transform:H,final:W,binary:U,preserveNewlines:$,writableObjectMode:B,readableObjectMode:F}}},jD=(Y,Z)=>Z==="input"?Y.reverse():Y;var lK=R(()=>{n6();h0();y3()});import f3 from"node:process";var iK=(Y,Z,Q)=>{let J=Y.map((z)=>TD(z,Z));if(J.includes("input")&&J.includes("output"))throw TypeError(`The \`${Q}\` option must not be an array of both readable and writable values.`);return J.find(Boolean)??AD},TD=({type:Y,value:Z},Q)=>CD[Q]??nK[Y](Z),CD,i1=()=>{return},b3=()=>"input",nK,kD=(Y)=>{if([0,f3.stdin].includes(Y))return"input";if([1,2,f3.stdout,f3.stderr].includes(Y))return"output"},AD="output";var aK=R(()=>{h0();CD=["input","output","output"],nK={generator:i1,asyncGenerator:i1,fileUrl:i1,filePath:i1,iterable:b3,asyncIterable:b3,uint8Array:b3,webStream:(Y)=>C7(Y)?"output":"input",nodeStream(Y){if(!a6(Y,{checkOpen:!1}))return"output";return _3(Y,{checkOpen:!1})?void 0:"input"},webTransform:i1,duplex:i1,native(Y){let Z=kD(Y);if(Z!==void 0)return Z;if(VY(Y,{checkOpen:!1}))return nK.nodeStream(Y)}}});var oK=(Y,Z)=>Z&&!Y.includes("ipc")?[...Y,"ipc"]:Y;var sK=({stdio:Y,ipc:Z,buffer:Q,...J},z,X)=>{let H=xD(Y,J).map((W,K)=>rK(W,K));return X?PD(H,Q,z):oK(H,Z)},xD=(Y,Z)=>{if(Y===void 0)return zY.map((J)=>Z[J]);if(ED(Z))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${zY.map((J)=>`\`${J}\``).join(", ")}`);if(typeof Y==="string")return[Y,Y,Y];if(!Array.isArray(Y))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof Y}\``);let Q=Math.max(Y.length,zY.length);return Array.from({length:Q},(J,z)=>Y[z])},ED=(Y)=>zY.some((Z)=>Y[Z]!==void 0),rK=(Y,Z)=>{if(Array.isArray(Y))return Y.map((Q)=>rK(Q,Z));if(Y===null||Y===void 0)return Z>=zY.length?"ignore":"pipe";return Y},PD=(Y,Z,Q)=>Y.map((J,z)=>!Z[z]&&z!==0&&!v1(Q,z)&&SD(J)?"ignore":J),SD=(Y)=>Y==="pipe"||Array.isArray(Y)&&Y.every((Z)=>Z==="pipe");var tK=R(()=>{uY();W6()});import{readFileSync as vD}from"node:fs";import yD from"node:tty";var YG=({stdioItem:Y,stdioItem:{type:Z},isStdioArray:Q,fdNumber:J,direction:z,isSync:X})=>{if(!Q||Z!=="native")return Y;return X?fD({stdioItem:Y,fdNumber:J,direction:z}):gD({stdioItem:Y,fdNumber:J})},fD=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:J,direction:z})=>{let X=bD({value:Z,optionName:Q,fdNumber:J,direction:z});if(X!==void 0)return X;if(VY(Z,{checkOpen:!1}))throw TypeError(`The \`${Q}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return Y},bD=({value:Y,optionName:Z,fdNumber:Q,direction:J})=>{let z=hD(Y,Q);if(z===void 0)return;if(J==="output")return{type:"fileNumber",value:z,optionName:Z};if(yD.isatty(z))throw TypeError(`The \`${Z}: ${sZ(Y)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:mY(vD(z)),optionName:Z}},hD=(Y,Z)=>{if(Y==="inherit")return Z;if(typeof Y==="number")return Y;let Q=AZ.indexOf(Y);if(Q!==-1)return Q},gD=({stdioItem:Y,stdioItem:{value:Z,optionName:Q},fdNumber:J})=>{if(Z==="inherit")return{type:"nodeStream",value:eK(J,Z,Q),optionName:Q};if(typeof Z==="number")return{type:"nodeStream",value:eK(Z,Z,Q),optionName:Q};if(VY(Z,{checkOpen:!1}))return{type:"nodeStream",value:Z,optionName:Q};return Y},eK=(Y,Z,Q)=>{let J=AZ[Y];if(J===void 0)throw TypeError(`The \`${Q}: ${Z}\` option is invalid: no such standard stream.`);return J};var ZG=R(()=>{uY();i0();$6()});var QG=({input:Y,inputFile:Z},Q)=>Q===0?[...mD(Y),...dD(Z)]:[],mD=(Y)=>Y===void 0?[]:[{type:uD(Y),value:Y,optionName:"input"}],uD=(Y)=>{if(a6(Y,{checkOpen:!1}))return"nodeStream";if(typeof Y==="string")return"string";if(L0(Y))return"uint8Array";throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},dD=(Y)=>Y===void 0?[]:[{...pD(Y),optionName:"inputFile"}],pD=(Y)=>{if(T7(Y))return{type:"fileUrl",value:Y};if(E3(Y))return{type:"filePath",value:{file:Y}};throw Error("The `inputFile` option must be a file path string or a file URL.")};var JG=R(()=>{i0();h0()});var zG=(Y)=>Y.filter((Z,Q)=>Y.every((J,z)=>Z.value!==J.value||Q>=z||Z.type==="generator"||Z.type==="asyncGenerator")),XG=({stdioItem:{type:Y,value:Z,optionName:Q},direction:J,fileDescriptors:z,isSync:X})=>{let H=cD(z,Y);if(H.length===0)return;if(X){lD({otherStdioItems:H,type:Y,value:Z,optionName:Q,direction:J});return}if(uK.has(Y))return HG({otherStdioItems:H,type:Y,value:Z,optionName:Q,direction:J});if(dK.has(Y))nD({otherStdioItems:H,type:Y,value:Z,optionName:Q})},cD=(Y,Z)=>Y.flatMap(({direction:Q,stdioItems:J})=>J.filter((z)=>z.type===Z).map((z)=>({...z,direction:Q}))),lD=({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})=>{if(S3.has(Z))HG({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})},HG=({otherStdioItems:Y,type:Z,value:Q,optionName:J,direction:z})=>{let X=Y.filter((W)=>iD(W,Q));if(X.length===0)return;let H=X.find((W)=>W.direction!==z);return WG(H,J,Z),z==="output"?X[0].stream:void 0},iD=({type:Y,value:Z},Q)=>{if(Y==="filePath")return Z.file===Q.file;if(Y==="fileUrl")return Z.href===Q.href;return Z===Q},nD=({otherStdioItems:Y,type:Z,value:Q,optionName:J})=>{let z=Y.find(({value:{transform:X}})=>X===Q.transform);WG(z,J,Z)},WG=(Y,Z,Q)=>{if(Y!==void 0)throw TypeError(`The \`${Y.optionName}\` and \`${Z}\` options must not target ${U6[Q]} that is the same.`)};var KG=R(()=>{h0()});var A7=(Y,Z,Q,J)=>{let X=sK(Z,Q,J).map((W,K)=>aD({stdioOption:W,fdNumber:K,options:Z,isSync:J})),H=QN({initialFileDescriptors:X,addProperties:Y,options:Z,isSync:J});return Z.stdio=H.map(({stdioItems:W})=>XN(W)),H},aD=({stdioOption:Y,fdNumber:Z,options:Q,isSync:J})=>{let z=xZ(Z),{stdioItems:X,isStdioArray:H}=oD({stdioOption:Y,fdNumber:Z,options:Q,optionName:z}),W=iK(X,Z,z),K=X.map((U)=>YG({stdioItem:U,isStdioArray:H,fdNumber:Z,direction:W,isSync:J})),$=cK(K,z,W,Q),G=pK($,W);return ZN($,G),{direction:W,objectMode:G,stdioItems:$}},oD=({stdioOption:Y,fdNumber:Z,options:Q,optionName:J})=>{let X=[...(Array.isArray(Y)?Y:[Y]).map((K)=>sD(K,J)),...QG(Q,Z)],H=zG(X),W=H.length>1;return rD(H,W,J),eD(H),{stdioItems:H,isStdioArray:W}},sD=(Y,Z)=>({type:SK(Y,Z),value:Y,optionName:Z}),rD=(Y,Z,Q)=>{if(Y.length===0)throw TypeError(`The \`${Q}\` option must not be an empty array.`);if(!Z)return;for(let{value:J,optionName:z}of Y)if(tD.has(J))throw Error(`The \`${z}\` option must not include \`${J}\`.`)},tD,eD=(Y)=>{for(let Z of Y)YN(Z)},YN=({type:Y,value:Z,optionName:Q})=>{if(bK(Z))throw TypeError(`The \`${Q}: URL\` option must use the \`file:\` scheme.
|
|
76
|
+
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(hK(Y,Z))throw TypeError(`The \`${Q}: { file: '...' }\` option must be used instead of \`${Q}: '...'\`.`)},ZN=(Y,Z)=>{if(!Z)return;let Q=Y.find(({type:J})=>k7.has(J));if(Q!==void 0)throw TypeError(`The \`${Q.optionName}\` option cannot use both files and transforms in objectMode.`)},QN=({initialFileDescriptors:Y,addProperties:Z,options:Q,isSync:J})=>{let z=[];try{for(let X of Y)z.push(JN({fileDescriptor:X,fileDescriptors:z,addProperties:Z,options:Q,isSync:J}));return z}catch(X){throw h3(z),X}},JN=({fileDescriptor:{direction:Y,objectMode:Z,stdioItems:Q},fileDescriptors:J,addProperties:z,options:X,isSync:H})=>{let W=Q.map((K)=>zN({stdioItem:K,addProperties:z,direction:Y,options:X,fileDescriptors:J,isSync:H}));return{direction:Y,objectMode:Z,stdioItems:W}},zN=({stdioItem:Y,addProperties:Z,direction:Q,options:J,fileDescriptors:z,isSync:X})=>{let H=XG({stdioItem:Y,direction:Q,fileDescriptors:z,isSync:X});if(H!==void 0)return{...Y,stream:H};return{...Y,...Z[Q][Y.type](Y,J)}},h3=(Y)=>{for(let{stdioItems:Z}of Y)for(let{stream:Q}of Z)if(Q!==void 0&&!UY(Q))Q.destroy()},XN=(Y)=>{if(Y.length>1)return Y.some(({value:J})=>J==="overlapped")?"overlapped":"pipe";let[{type:Z,value:Q}]=Y;return Z==="native"?Q:"pipe"};var x7=R(()=>{uY();lK();y3();h0();aK();tK();ZG();JG();KG();tD=new Set(["ignore","ipc"])});import{readFileSync as GG}from"node:fs";var qG=(Y,Z)=>A7(WN,Y,Z,!0),_Y=({type:Y,optionName:Z})=>{UG(Z,U6[Y])},HN=({optionName:Y,value:Z})=>{if(Z==="ipc"||Z==="overlapped")UG(Y,`"${Z}"`);return{}},UG=(Y,Z)=>{throw TypeError(`The \`${Y}\` option cannot be ${Z} with synchronous methods.`)},$G,WN;var BG=R(()=>{i0();x7();h0();$G={generator(){},asyncGenerator:_Y,webStream:_Y,nodeStream:_Y,webTransform:_Y,duplex:_Y,asyncIterable:_Y,native:HN},WN={input:{...$G,fileUrl:({value:Y})=>({contents:[mY(GG(Y))]}),filePath:({value:{file:Y}})=>({contents:[mY(GG(Y))]}),fileNumber:_Y,iterable:({value:Y})=>({contents:[...Y]}),string:({value:Y})=>({contents:[Y]}),uint8Array:({value:Y})=>({contents:[Y]})},output:{...$G,fileUrl:({value:Y})=>({path:Y}),filePath:({value:{file:Y,append:Z}})=>({path:Y,append:Z}),fileNumber:({value:Y})=>({path:Y}),iterable:_Y,string:_Y,uint8Array:_Y}}});var iY=(Y,{stripFinalNewline:Z},Q)=>g3(Z,Q)&&Y!==void 0&&!Array.isArray(Y)?d1(Y):Y,g3=(Y,Z)=>Z==="all"?Y[1]||Y[2]:Y[Z];var i8=R(()=>{L3()});var E7=(Y,Z,Q,J)=>Y||Q?void 0:FG(Z,J),u3=(Y,Z,Q)=>Q?Y.flatMap((J)=>VG(J,Z)):VG(Y,Z),VG=(Y,Z)=>{let{transform:Q,final:J}=FG(Z,{});return[...Q(Y),...J()]},FG=(Y,Z)=>{return Z.previousChunks="",{transform:KN.bind(void 0,Z,Y),final:$N.bind(void 0,Z)}},KN=function*(Y,Z,Q){if(typeof Q!=="string"){yield Q;return}let{previousChunks:J}=Y,z=-1;for(let X=0;X<Q.length;X+=1)if(Q[X]===`
|
|
77
|
+
`){let H=GN(Q,X,Z,Y),W=Q.slice(z+1,X+1-H);if(J.length>0)W=m3(J,W),J="";yield W,z=X}if(z!==Q.length-1)J=m3(J,Q.slice(z+1));Y.previousChunks=J},GN=(Y,Z,Q,J)=>{if(Q)return 0;return J.isWindowsNewline=Z!==0&&Y[Z-1]==="\r",J.isWindowsNewline?2:1},$N=function*({previousChunks:Y}){if(Y.length>0)yield Y},RG=({binary:Y,preserveNewlines:Z,readableObjectMode:Q,state:J})=>Y||Z||Q?void 0:{transform:qN.bind(void 0,J)},qN=function*({isWindowsNewline:Y=!1},Z){let{unixNewline:Q,windowsNewline:J,LF:z,concatBytes:X}=typeof Z==="string"?UN:VN;if(Z.at(-1)===z){yield Z;return}yield X(Z,Y?J:Q)},m3=(Y,Z)=>`${Y}${Z}`,UN,BN=(Y,Z)=>{let Q=new Uint8Array(Y.length+Z.length);return Q.set(Y,0),Q.set(Z,Y.length),Q},VN;var P7=R(()=>{UN={windowsNewline:`\r
|
|
85
78
|
`,unixNewline:`
|
|
86
79
|
`,LF:`
|
|
87
|
-
`,concatBytes:
|
|
80
|
+
`,concatBytes:m3},VN={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:BN}});import{Buffer as FN}from"node:buffer";var MG=(Y,Z)=>Y?void 0:RN.bind(void 0,Z),RN=function*(Y,Z){if(typeof Z!=="string"&&!L0(Z)&&!FN.isBuffer(Z))throw TypeError(`The \`${Y}\` option's transform must use "objectMode: true" to receive as input: ${typeof Z}.`);yield Z},OG=(Y,Z)=>Y?MN.bind(void 0,Z):ON.bind(void 0,Z),MN=function*(Y,Z){DG(Y,Z),yield Z},ON=function*(Y,Z){if(DG(Y,Z),typeof Z!=="string"&&!L0(Z))throw TypeError(`The \`${Y}\` option's function must yield a string or an Uint8Array, not ${typeof Z}.`);yield Z},DG=(Y,Z)=>{if(Z===null||Z===void 0)throw TypeError(`The \`${Y}\` option's function must not call \`yield ${Z}\`.
|
|
88
81
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
89
|
-
if (condition) { yield value; }`)};import{Buffer as cq}from"node:buffer";import{StringDecoder as lq}from"node:string_decoder";var h4=(Y,Z,Q)=>{if(Q)return;if(Y)return{transform:iq.bind(void 0,new TextEncoder)};let X=new lq(Z);return{transform:nq.bind(void 0,X),final:aq.bind(void 0,X)}},iq=function*(Y,Z){if(cq.isBuffer(Z))yield r0(Z);else if(typeof Z==="string")yield Y.encode(Z);else yield Z},nq=function*(Y,Z){yield G0(Z)?Y.write(Z):Z},aq=function*(Y){let Z=Y.end();if(Z!=="")yield Z};import{callbackify as PJ}from"node:util";var o7=PJ(async(Y,Z,Q,X)=>{Z.currentIterable=Y(...Q);try{for await(let J of Z.currentIterable)X.push(J)}finally{delete Z.currentIterable}}),b4=async function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:X=sq}=Z[Q];for await(let J of X(Y))yield*b4(J,Z,Q+1)},EJ=async function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*oq(Q,Number(Z),Y)},oq=async function*(Y,Z,Q){if(Y===void 0)return;for await(let X of Y())yield*b4(X,Q,Z+1)},CJ=PJ(async({currentIterable:Y},Z)=>{if(Y!==void 0){await(Z?Y.throw(Z):Y.return());return}if(Z)throw Z}),sq=function*(Y){yield Y};var s7=(Y,Z,Q,X)=>{try{for(let J of Y(...Z))Q.push(J);X()}catch(J){X(J)}},kJ=(Y,Z)=>[...Z.flatMap((Q)=>[...dY(Q,Y,0)]),...O1(Y)],dY=function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:X=rq}=Z[Q];for(let J of X(Y))yield*dY(J,Z,Q+1)},O1=function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*tq(Q,Number(Z),Y)},tq=function*(Y,Z,Q){if(Y===void 0)return;for(let X of Y())yield*dY(X,Q,Z+1)},rq=function*(Y){yield Y};var t7=({value:Y,value:{transform:Z,final:Q,writableObjectMode:X,readableObjectMode:J},optionName:$},{encoding:G})=>{let K={},H=IJ(Y,G,$),W=uY(Z),z=uY(Q),q=W?o7.bind(void 0,b4,K):s7.bind(void 0,dY),V=W||z?o7.bind(void 0,EJ,K):s7.bind(void 0,O1),R=W||z?CJ.bind(void 0,K):void 0;return{stream:new eq({writableObjectMode:X,writableHighWaterMark:AJ(X),readableObjectMode:J,readableHighWaterMark:AJ(J),transform(M,T,D){q([M,H,0],this,D)},flush(M){V([H],this,M)},destroy:R})}},g4=(Y,Z,Q,X)=>{let J=Z.filter(({type:G})=>G==="generator"),$=X?J.reverse():J;for(let{value:G,optionName:K}of $){let H=IJ(G,Q,K);Y=kJ(H,Y)}return Y},IJ=({transform:Y,final:Z,binary:Q,writableObjectMode:X,readableObjectMode:J,preserveNewlines:$},G,K)=>{let H={};return[{transform:wJ(X,K)},h4(Q,G,X),f4(Q,$,X,H),{transform:Y,final:Z},{transform:NJ(J,K)},_J({binary:Q,preserveNewlines:$,readableObjectMode:J,state:H})].filter(Boolean)};var jJ=(Y,Z)=>{for(let Q of YV(Y))ZV(Y,Q,Z)},YV=(Y)=>new Set(Object.entries(Y).filter(([,{direction:Z}])=>Z==="input").map(([Z])=>Number(Z))),ZV=(Y,Z,Q)=>{let{stdioItems:X}=Y[Z],J=X.filter(({contents:K})=>K!==void 0);if(J.length===0)return;if(Z!==0){let[{type:K,optionName:H}]=J;throw TypeError(`Only the \`stdin\` option, not \`${H}\`, can be ${FY[K]} with synchronous methods.`)}let G=J.map(({contents:K})=>K).map((K)=>QV(K,X));Q.input=F1(G)},QV=(Y,Z)=>{let Q=g4(Y,Z,"utf8",!0);return XV(Q),F1(Q)},XV=(Y)=>{let Z=Y.find((Q)=>typeof Q!=="string"&&!G0(Q));if(Z!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${Z}.`)};import{writeFileSync as KV,appendFileSync as HV}from"node:fs";var m4=({stdioItems:Y,encoding:Z,verboseInfo:Q,fdNumber:X})=>X!=="all"&&T6(Q,X)&&!O0.has(Z)&&JV(X)&&(Y.some(({type:J,value:$})=>J==="native"&&$V.has($))||Y.every(({type:J})=>x0.has(J))),JV=(Y)=>Y===1||Y===2,$V=new Set(["pipe","overlapped"]),xJ=async(Y,Z,Q,X)=>{for await(let J of Y)if(!GV(Z))yJ(J,Q,X)},SJ=(Y,Z,Q)=>{for(let X of Y)yJ(X,Z,Q)},GV=(Y)=>Y._readableState.pipes.length>0,yJ=(Y,Z,Q)=>{let X=r8(Y);g0({type:"output",verboseMessage:X,fdNumber:Z,verboseInfo:Q})};var vJ=({fileDescriptors:Y,syncResult:{output:Z},options:Q,isMaxBuffer:X,verboseInfo:J})=>{if(Z===null)return{output:Array.from({length:3})};let $={},G=new Set([]);return{output:Z.map((H,W)=>zV({result:H,fileDescriptors:Y,fdNumber:W,state:$,outputFiles:G,isMaxBuffer:X,verboseInfo:J},Q)),...$}},zV=({result:Y,fileDescriptors:Z,fdNumber:Q,state:X,outputFiles:J,isMaxBuffer:$,verboseInfo:G},{buffer:K,encoding:H,lines:W,stripFinalNewline:z,maxBuffer:q})=>{if(Y===null)return;let V=fX(Y,$,q),R=r0(V),{stdioItems:B,objectMode:M}=Z[Q],T=WV([R],B,H,X),{serializedResult:D,finalResult:_=D}=UV({chunks:T,objectMode:M,encoding:H,lines:W,stripFinalNewline:z,fdNumber:Q});qV({serializedResult:D,fdNumber:Q,state:X,verboseInfo:G,encoding:H,stdioItems:B,objectMode:M});let w=K[Q]?_:void 0;try{if(X.error===void 0)VV(D,B,J);return w}catch(N){return X.error=N,w}},WV=(Y,Z,Q,X)=>{try{return g4(Y,Z,Q,!1)}catch(J){return X.error=J,Y}},UV=({chunks:Y,objectMode:Z,encoding:Q,lines:X,stripFinalNewline:J,fdNumber:$})=>{if(Z)return{serializedResult:Y};if(Q==="buffer")return{serializedResult:F1(Y)};let G=s5(Y,Q);if(X[$])return{serializedResult:G,finalResult:a7(G,!J[$],Z)};return{serializedResult:G}},qV=({serializedResult:Y,fdNumber:Z,state:Q,verboseInfo:X,encoding:J,stdioItems:$,objectMode:G})=>{if(!m4({stdioItems:$,encoding:J,verboseInfo:X,fdNumber:Z}))return;let K=a7(Y,!1,G);try{SJ(K,Z,X)}catch(H){Q.error??=H}},VV=(Y,Z,Q)=>{for(let{path:X,append:J}of Z.filter(({type:$})=>y4.has($))){let $=typeof X==="string"?X:X.toString();if(J||Q.has($))HV(X,Y);else Q.add($),KV(X,Y)}};var fJ=([,Y,Z],Q)=>{if(!Q.all)return;if(Y===void 0)return Z;if(Z===void 0)return Y;if(Array.isArray(Y))return Array.isArray(Z)?[...Y,...Z]:[...Y,QY(Z,Q,"all")];if(Array.isArray(Z))return[QY(Y,Q,"all"),...Z];if(G0(Y)&&G0(Z))return X7([Y,Z]);return`${Y}${Z}`};import{once as r7}from"node:events";var hJ=async(Y,Z)=>{let[Q,X]=await BV(Y);return Z.isForcefullyTerminated??=!1,[Q,X]},BV=async(Y)=>{let[Z,Q]=await Promise.allSettled([r7(Y,"spawn"),r7(Y,"exit")]);if(Z.status==="rejected")return[];return Q.status==="rejected"?bJ(Y):Q.value},bJ=async(Y)=>{try{return await r7(Y,"exit")}catch{return bJ(Y)}},gJ=async(Y)=>{let[Z,Q]=await Y;if(!FV(Z,Q)&&e7(Z,Q))throw new m0;return[Z,Q]},FV=(Y,Z)=>Y===void 0&&Z===void 0,e7=(Y,Z)=>Y!==0||Z!==null;var mJ=({error:Y,status:Z,signal:Q,output:X},{maxBuffer:J})=>{let $=RV(Y,Z,Q),G=$?.code==="ETIMEDOUT",K=vX($,X,J);return{resultError:$,exitCode:Z,signal:Q,timedOut:G,isMaxBuffer:K}},RV=(Y,Z,Q)=>{if(Y!==void 0)return Y;return e7(Z,Q)?new m0:void 0};var uJ=(Y,Z,Q)=>{let{file:X,commandArguments:J,command:$,escapedCommand:G,startTime:K,verboseInfo:H,options:W,fileDescriptors:z}=DV(Y,Z,Q),q=_V({file:X,commandArguments:J,options:W,command:$,escapedCommand:G,verboseInfo:H,fileDescriptors:z,startTime:K});return A6(q,H,W)},DV=(Y,Z,Q)=>{let{command:X,escapedCommand:J,startTime:$,verboseInfo:G}=Y4(Y,Z,Q),K=LV(Q),{file:H,commandArguments:W,options:z}=_4(Y,Z,K);TV(z);let q=MJ(z,G);return{file:H,commandArguments:W,command:X,escapedCommand:J,startTime:$,verboseInfo:G,options:z,fileDescriptors:q}},LV=(Y)=>Y.node&&!Y.ipc?{...Y,ipc:!1}:Y,TV=({ipc:Y,ipcInput:Z,detached:Q,cancelSignal:X})=>{if(Z)u4("ipcInput");if(Y)u4("ipc: true");if(Q)u4("detached: true");if(X)u4("cancelSignal")},u4=(Y)=>{throw TypeError(`The "${Y}" option cannot be used with synchronous methods.`)},_V=({file:Y,commandArguments:Z,options:Q,command:X,escapedCommand:J,verboseInfo:$,fileDescriptors:G,startTime:K})=>{let H=wV({file:Y,commandArguments:Z,options:Q,command:X,escapedCommand:J,fileDescriptors:G,startTime:K});if(H.failed)return H;let{resultError:W,exitCode:z,signal:q,timedOut:V,isMaxBuffer:R}=mJ(H,Q),{output:B,error:M=W}=vJ({fileDescriptors:G,syncResult:H,options:Q,isMaxBuffer:R,verboseInfo:$}),T=B.map((_,w)=>QY(_,Q,w)),D=QY(fJ(B,Q),Q,"all");return OV({error:M,exitCode:z,signal:q,timedOut:V,isMaxBuffer:R,stdio:T,all:D,options:Q,command:X,escapedCommand:J,startTime:K})},wV=({file:Y,commandArguments:Z,options:Q,command:X,escapedCommand:J,fileDescriptors:$,startTime:G})=>{try{jJ($,Q);let K=NV(Q);return MV(...w4(Y,Z,K))}catch(K){return k6({error:K,command:X,escapedCommand:J,fileDescriptors:$,options:Q,startTime:G,isSync:!0})}},NV=({encoding:Y,maxBuffer:Z,...Q})=>({...Q,encoding:"buffer",maxBuffer:I4(Z)}),OV=({error:Y,exitCode:Z,signal:Q,timedOut:X,isMaxBuffer:J,stdio:$,all:G,options:K,command:H,escapedCommand:W,startTime:z})=>Y===void 0?j4({command:H,escapedCommand:W,stdio:$,all:G,ipcOutput:[],options:K,startTime:z}):N1({error:Y,command:H,escapedCommand:W,timedOut:X,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:J,isForcefullyTerminated:!1,exitCode:Z,signal:Q,stdio:$,all:G,ipcOutput:[],options:K,startTime:z,isSync:!0});import{setMaxListeners as UF}from"node:events";import{spawn as qF}from"node:child_process";import iJ from"node:process";import{once as Y2,on as PV}from"node:events";var dJ=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:X},{reference:J=!0,filter:$}={})=>{return N6({methodName:"getOneMessage",isSubprocess:Q,ipc:X,isConnected:F4(Y)}),EV({anyProcess:Y,channel:Z,isSubprocess:Q,filter:$,reference:J})},EV=async({anyProcess:Y,channel:Z,isSubprocess:Q,filter:X,reference:J})=>{U4(Z,J);let $=BY(Y,Z,Q),G=new AbortController;try{return await Promise.race([CV($,X,G),kV($,Q,G),AV($,Q,G)])}catch(K){throw O6(Y),K}finally{G.abort(),q4(Z,J)}},CV=async(Y,Z,{signal:Q})=>{if(Z===void 0){let[X]=await Y2(Y,"message",{signal:Q});return X}for await(let[X]of PV(Y,"message",{signal:Q}))if(Z(X))return X},kV=async(Y,Z,{signal:Q})=>{await Y2(Y,"disconnect",{signal:Q}),CQ(Z)},AV=async(Y,Z,{signal:Q})=>{let[X]=await Y2(Y,"strict:error",{signal:Q});throw H4(X,Z)};import{once as cJ,on as IV}from"node:events";var lJ=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:X},{reference:J=!0}={})=>Z2({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:X,shouldAwait:!Q,reference:J}),Z2=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:X,shouldAwait:J,reference:$})=>{N6({methodName:"getEachMessage",isSubprocess:Q,ipc:X,isConnected:F4(Y)}),U4(Z,$);let G=BY(Y,Z,Q),K=new AbortController,H={};return jV(Y,G,K),xV({ipcEmitter:G,isSubprocess:Q,controller:K,state:H}),SV({anyProcess:Y,channel:Z,ipcEmitter:G,isSubprocess:Q,shouldAwait:J,controller:K,state:H,reference:$})},jV=async(Y,Z,Q)=>{try{await cJ(Z,"disconnect",{signal:Q.signal}),Q.abort()}catch{}},xV=async({ipcEmitter:Y,isSubprocess:Z,controller:Q,state:X})=>{try{let[J]=await cJ(Y,"strict:error",{signal:Q.signal});X.error=H4(J,Z),Q.abort()}catch{}},SV=async function*({anyProcess:Y,channel:Z,ipcEmitter:Q,isSubprocess:X,shouldAwait:J,controller:$,state:G,reference:K}){try{for await(let[H]of IV(Q,"message",{signal:$.signal}))pJ(G),yield H}catch{pJ(G)}finally{if($.abort(),q4(Z,K),!X)O6(Y);if(J)await Y}},pJ=({error:Y})=>{if(Y)throw Y};var nJ=(Y,{ipc:Z})=>{Object.assign(Y,oJ(Y,!1,Z))},aJ=()=>{let Y=iJ,Z=!0,Q=iJ.channel!==void 0;return{...oJ(Y,!0,Q),getCancelSignal:YX.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:!0,ipc:Q})}},oJ=(Y,Z,Q)=>({sendMessage:L4.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getOneMessage:dJ.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getEachMessage:lJ.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q})});import{ChildProcess as yV}from"node:child_process";import{PassThrough as vV,Readable as fV,Writable as hV,Duplex as bV}from"node:stream";var sJ=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:X,options:J,startTime:$,verboseInfo:G})=>{l7(X);let K=new yV;gV(K,X),Object.assign(K,{readable:mV,writable:uV,duplex:dV});let H=k6({error:Y,command:Z,escapedCommand:Q,fileDescriptors:X,options:J,startTime:$,isSync:!1}),W=pV(H,G,J);return{subprocess:K,promise:W}},gV=(Y,Z)=>{let Q=P1(),X=P1(),J=P1(),$=Array.from({length:Z.length-3},P1),G=P1(),K=[Q,X,J,...$];Object.assign(Y,{stdin:Q,stdout:X,stderr:J,all:G,stdio:K})},P1=()=>{let Y=new vV;return Y.end(),Y},mV=()=>new fV({read(){}}),uV=()=>new hV({write(){}}),dV=()=>new bV({read(){},write(){}}),pV=async(Y,Z,Q)=>A6(Y,Z,Q);import{createReadStream as tJ,createWriteStream as rJ}from"node:fs";import{Buffer as cV}from"node:buffer";import{Readable as E1,Writable as lV,Duplex as iV}from"node:stream";var Y9=(Y,Z)=>v4(nV,Y,Z,!1),C1=({type:Y,optionName:Z})=>{throw TypeError(`The \`${Z}\` option cannot be ${FY[Y]}.`)},eJ={fileNumber:C1,generator:t7,asyncGenerator:t7,nodeStream:({value:Y})=>({stream:Y}),webTransform({value:{transform:Y,writableObjectMode:Z,readableObjectMode:Q}}){let X=Z||Q;return{stream:iV.fromWeb(Y,{objectMode:X})}},duplex:({value:{transform:Y}})=>({stream:Y}),native(){}},nV={input:{...eJ,fileUrl:({value:Y})=>({stream:tJ(Y)}),filePath:({value:{file:Y}})=>({stream:tJ(Y)}),webStream:({value:Y})=>({stream:E1.fromWeb(Y)}),iterable:({value:Y})=>({stream:E1.from(Y)}),asyncIterable:({value:Y})=>({stream:E1.from(Y)}),string:({value:Y})=>({stream:E1.from(Y)}),uint8Array:({value:Y})=>({stream:E1.from(cV.from(Y))})},output:{...eJ,fileUrl:({value:Y})=>({stream:rJ(Y)}),filePath:({value:{file:Y,append:Z}})=>({stream:rJ(Y,Z?{flags:"a"}:{})}),webStream:({value:Y})=>({stream:lV.fromWeb(Y)}),iterable:C1,asyncIterable:C1,string:C1,uint8Array:C1}};import{on as aV,once as Z9}from"node:events";import{PassThrough as oV,getDefaultHighWaterMark as sV}from"node:stream";import{finished as J9}from"node:stream/promises";function pY(Y){if(!Array.isArray(Y))throw TypeError(`Expected an array, got \`${typeof Y}\`.`);for(let J of Y)Q2(J);let Z=Y.some(({readableObjectMode:J})=>J),Q=tV(Y,Z),X=new $9({objectMode:Z,writableHighWaterMark:Q,readableHighWaterMark:Q});for(let J of Y)X.add(J);return X}var tV=(Y,Z)=>{if(Y.length===0)return sV(Z);let Q=Y.filter(({readableObjectMode:X})=>X===Z).map(({readableHighWaterMark:X})=>X);return Math.max(...Q)};class $9 extends oV{#Z=new Set([]);#Q=new Set([]);#Y=new Set([]);#X;#J=Symbol("unpipe");#$=new WeakMap;add(Y){if(Q2(Y),this.#Z.has(Y))return;this.#Z.add(Y),this.#X??=rV(this,this.#Z,this.#J);let Z=ZB({passThroughStream:this,stream:Y,streams:this.#Z,ended:this.#Q,aborted:this.#Y,onFinished:this.#X,unpipeEvent:this.#J});this.#$.set(Y,Z),Y.pipe(this,{end:!1})}async remove(Y){if(Q2(Y),!this.#Z.has(Y))return!1;let Z=this.#$.get(Y);if(Z===void 0)return!1;return this.#$.delete(Y),Y.unpipe(this),await Z,!0}}var rV=async(Y,Z,Q)=>{d4(Y,Q9);let X=new AbortController;try{await Promise.race([eV(Y,X),YB(Y,Z,Q,X)])}finally{X.abort(),d4(Y,-Q9)}},eV=async(Y,{signal:Z})=>{try{await J9(Y,{signal:Z,cleanup:!0})}catch(Q){throw G9(Y,Q),Q}},YB=async(Y,Z,Q,{signal:X})=>{for await(let[J]of aV(Y,"unpipe",{signal:X}))if(Z.has(J))J.emit(Q)},Q2=(Y)=>{if(typeof Y?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Y}\`.`)},ZB=async({passThroughStream:Y,stream:Z,streams:Q,ended:X,aborted:J,onFinished:$,unpipeEvent:G})=>{d4(Y,X9);let K=new AbortController;try{await Promise.race([QB($,Z,K),XB({passThroughStream:Y,stream:Z,streams:Q,ended:X,aborted:J,controller:K}),JB({stream:Z,streams:Q,ended:X,aborted:J,unpipeEvent:G,controller:K})])}finally{K.abort(),d4(Y,-X9)}if(Q.size>0&&Q.size===X.size+J.size)if(X.size===0&&J.size>0)X2(Y);else $B(Y)},QB=async(Y,Z,{signal:Q})=>{try{if(await Y,!Q.aborted)X2(Z)}catch(X){if(!Q.aborted)G9(Z,X)}},XB=async({passThroughStream:Y,stream:Z,streams:Q,ended:X,aborted:J,controller:{signal:$}})=>{try{if(await J9(Z,{signal:$,cleanup:!0,readable:!0,writable:!1}),Q.has(Z))X.add(Z)}catch(G){if($.aborted||!Q.has(Z))return;if(K9(G))J.add(Z);else H9(Y,G)}},JB=async({stream:Y,streams:Z,ended:Q,aborted:X,unpipeEvent:J,controller:{signal:$}})=>{if(await Z9(Y,J,{signal:$}),!Y.readable)return Z9($,"abort",{signal:$});Z.delete(Y),Q.delete(Y),X.delete(Y)},$B=(Y)=>{if(Y.writable)Y.end()},G9=(Y,Z)=>{if(K9(Z))X2(Y);else H9(Y,Z)},K9=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",X2=(Y)=>{if(Y.readable||Y.writable)Y.destroy()},H9=(Y,Z)=>{if(!Y.destroyed)Y.once("error",GB),Y.destroy(Z)},GB=()=>{},d4=(Y,Z)=>{let Q=Y.getMaxListeners();if(Q!==0&&Q!==Number.POSITIVE_INFINITY)Y.setMaxListeners(Q+Z)},Q9=2,X9=1;import{finished as z9}from"node:stream/promises";var j6=(Y,Z)=>{Y.pipe(Z),KB(Y,Z),HB(Y,Z)},KB=async(Y,Z)=>{if(y0(Y)||y0(Z))return;try{await z9(Y,{cleanup:!0,readable:!0,writable:!1})}catch{}J2(Z)},J2=(Y)=>{if(Y.writable)Y.end()},HB=async(Y,Z)=>{if(y0(Y)||y0(Z))return;try{await z9(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}$2(Y)},$2=(Y)=>{if(Y.readable)Y.destroy()};var W9=(Y,Z,Q)=>{let X=new Map;for(let[J,{stdioItems:$,direction:G}]of Object.entries(Z)){for(let{stream:K}of $.filter(({type:H})=>x0.has(H)))zB(Y,K,G,J);for(let{stream:K}of $.filter(({type:H})=>!x0.has(H)))UB({subprocess:Y,stream:K,direction:G,fdNumber:J,pipeGroups:X,controller:Q})}for(let[J,$]of X.entries()){let G=$.length===1?$[0]:pY($);j6(G,J)}},zB=(Y,Z,Q,X)=>{if(Q==="output")j6(Y.stdio[X],Z);else j6(Z,Y.stdio[X]);let J=WB[X];if(J!==void 0)Y[J]=Z;Y.stdio[X]=Z},WB=["stdin","stdout","stderr"],UB=({subprocess:Y,stream:Z,direction:Q,fdNumber:X,pipeGroups:J,controller:$})=>{if(Z===void 0)return;qB(Z,$);let[G,K]=Q==="output"?[Z,Y.stdio[X]]:[Y.stdio[X],Z],H=J.get(G)??[];J.set(G,[...H,K])},qB=(Y,{signal:Z})=>{if(y0(Y))gY(Y,VB,Z)},VB=2;import{addAbortListener as RB}from"node:events";var cY=[];cY.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")cY.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")cY.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var p4=(Y)=>!!Y&&typeof Y==="object"&&typeof Y.removeListener==="function"&&typeof Y.emit==="function"&&typeof Y.reallyExit==="function"&&typeof Y.listeners==="function"&&typeof Y.kill==="function"&&typeof Y.pid==="number"&&typeof Y.on==="function",G2=Symbol.for("signal-exit emitter"),K2=globalThis,BB=Object.defineProperty.bind(Object);class U9{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(K2[G2])return K2[G2];BB(K2,G2,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Y,Z){this.listeners[Y].push(Z)}removeListener(Y,Z){let Q=this.listeners[Y],X=Q.indexOf(Z);if(X===-1)return;if(X===0&&Q.length===1)Q.length=0;else Q.splice(X,1)}emit(Y,Z,Q){if(this.emitted[Y])return!1;this.emitted[Y]=!0;let X=!1;for(let J of this.listeners[Y])X=J(Z,Q)===!0||X;if(Y==="exit")X=this.emit("afterExit",Z,Q)||X;return X}}class z2{}var FB=(Y)=>{return{onExit(Z,Q){return Y.onExit(Z,Q)},load(){return Y.load()},unload(){return Y.unload()}}};class q9 extends z2{onExit(){return()=>{}}load(){}unload(){}}class V9 extends z2{#Z=H2.platform==="win32"?"SIGINT":"SIGHUP";#Q=new U9;#Y;#X;#J;#$={};#G=!1;constructor(Y){super();this.#Y=Y,this.#$={};for(let Z of cY)this.#$[Z]=()=>{let Q=this.#Y.listeners(Z),{count:X}=this.#Q,J=Y;if(typeof J.__signal_exit_emitter__==="object"&&typeof J.__signal_exit_emitter__.count==="number")X+=J.__signal_exit_emitter__.count;if(Q.length===X){this.unload();let $=this.#Q.emit("exit",null,Z),G=Z==="SIGHUP"?this.#Z:Z;if(!$)Y.kill(Y.pid,G)}};this.#J=Y.reallyExit,this.#X=Y.emit}onExit(Y,Z){if(!p4(this.#Y))return()=>{};if(this.#G===!1)this.load();let Q=Z?.alwaysLast?"afterExit":"exit";return this.#Q.on(Q,Y),()=>{if(this.#Q.removeListener(Q,Y),this.#Q.listeners.exit.length===0&&this.#Q.listeners.afterExit.length===0)this.unload()}}load(){if(this.#G)return;this.#G=!0,this.#Q.count+=1;for(let Y of cY)try{let Z=this.#$[Y];if(Z)this.#Y.on(Y,Z)}catch(Z){}this.#Y.emit=(Y,...Z)=>{return this.#H(Y,...Z)},this.#Y.reallyExit=(Y)=>{return this.#K(Y)}}unload(){if(!this.#G)return;this.#G=!1,cY.forEach((Y)=>{let Z=this.#$[Y];if(!Z)throw Error("Listener not defined for signal: "+Y);try{this.#Y.removeListener(Y,Z)}catch(Q){}}),this.#Y.emit=this.#X,this.#Y.reallyExit=this.#J,this.#Q.count-=1}#K(Y){if(!p4(this.#Y))return 0;return this.#Y.exitCode=Y||0,this.#Q.emit("exit",this.#Y.exitCode,null),this.#J.call(this.#Y,this.#Y.exitCode)}#H(Y,...Z){let Q=this.#X;if(Y==="exit"&&p4(this.#Y)){if(typeof Z[0]==="number")this.#Y.exitCode=Z[0];let X=Q.call(this.#Y,Y,...Z);return this.#Q.emit("exit",this.#Y.exitCode,null),X}else return Q.call(this.#Y,Y,...Z)}}var H2=globalThis.process,{onExit:B9,load:GE,unload:KE}=FB(p4(H2)?new V9(H2):new q9);var F9=(Y,{cleanup:Z,detached:Q},{signal:X})=>{if(!Z||Q)return;let J=B9(()=>{Y.kill()});RB(X,()=>{J()})};var M9=({source:Y,sourcePromise:Z,boundOptions:Q,createNested:X},...J)=>{let $=e8(),{destination:G,destinationStream:K,destinationError:H,from:W,unpipeSignal:z}=MB(Q,X,J),{sourceStream:q,sourceError:V}=LB(Y,W),{options:R,fileDescriptors:B}=d0.get(Y);return{sourcePromise:Z,sourceStream:q,sourceOptions:R,sourceError:V,destination:G,destinationStream:K,destinationError:H,unpipeSignal:z,fileDescriptors:B,startTime:$}},MB=(Y,Z,Q)=>{try{let{destination:X,pipeOptions:{from:J,to:$,unpipeSignal:G}={}}=DB(Y,Z,...Q),K=W4(X,$);return{destination:X,destinationStream:K,from:J,unpipeSignal:G}}catch(X){return{destinationError:X}}},DB=(Y,Z,Q,...X)=>{if(Array.isArray(Q))return{destination:Z(R9,Y)(Q,...X),pipeOptions:Y};if(typeof Q==="string"||Q instanceof URL||Z7(Q)){if(Object.keys(Y).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[J,$,G]=p8(Q,...X);return{destination:Z(R9)(J,$,G),pipeOptions:G}}if(d0.has(Q)){if(Object.keys(Y).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:Q,pipeOptions:X[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${Q}`)},R9=({options:Y})=>({options:{...Y,stdin:"pipe",piped:!0}}),LB=(Y,Z)=>{try{return{sourceStream:P6(Y,Z)}}catch(Q){return{sourceError:Q}}};var L9=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:X,fileDescriptors:J,sourceOptions:$,startTime:G})=>{let K=TB({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:X});if(K!==void 0)throw W2({error:K,fileDescriptors:J,sourceOptions:$,startTime:G})},TB=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:X})=>{if(Z!==void 0&&X!==void 0)return X;if(X!==void 0)return $2(Y),X;if(Z!==void 0)return J2(Q),Z},W2=({error:Y,fileDescriptors:Z,sourceOptions:Q,startTime:X})=>k6({error:Y,command:D9,escapedCommand:D9,fileDescriptors:Z,options:Q,startTime:X,isSync:!1}),D9="source.pipe(destination)";var T9=async(Y)=>{let[{status:Z,reason:Q,value:X=Q},{status:J,reason:$,value:G=$}]=await Y;if(!G.pipedFrom.includes(X))G.pipedFrom.push(X);if(J==="rejected")throw G;if(Z==="rejected")throw X;return G};import{finished as _B}from"node:stream/promises";var _9=(Y,Z,Q)=>{let X=c4.has(Z)?NB(Y,Z):wB(Y,Z);return gY(Y,PB,Q.signal),gY(Z,EB,Q.signal),OB(Z),X},wB=(Y,Z)=>{let Q=pY([Y]);return j6(Q,Z),c4.set(Z,Q),Q},NB=(Y,Z)=>{let Q=c4.get(Z);return Q.add(Y),Q},OB=async(Y)=>{try{await _B(Y,{cleanup:!0,readable:!1,writable:!0})}catch{}c4.delete(Y)},c4=new WeakMap,PB=2,EB=1;import{aborted as CB}from"node:util";var w9=(Y,Z)=>Y===void 0?[]:[kB(Y,Z)],kB=async(Y,{sourceStream:Z,mergedStream:Q,fileDescriptors:X,sourceOptions:J,startTime:$})=>{await CB(Y,Z),await Q.remove(Z);let G=Error("Pipe canceled by `unpipeSignal` option.");throw W2({error:G,fileDescriptors:X,sourceOptions:J,startTime:$})};var l4=(Y,...Z)=>{if(e(Z[0]))return l4.bind(void 0,{...Y,boundOptions:{...Y.boundOptions,...Z[0]}});let{destination:Q,...X}=M9(Y,...Z),J=AB({...X,destination:Q});return J.pipe=l4.bind(void 0,{...Y,source:Q,sourcePromise:J,boundOptions:{}}),J},AB=async({sourcePromise:Y,sourceStream:Z,sourceOptions:Q,sourceError:X,destination:J,destinationStream:$,destinationError:G,unpipeSignal:K,fileDescriptors:H,startTime:W})=>{let z=IB(Y,J);L9({sourceStream:Z,sourceError:X,destinationStream:$,destinationError:G,fileDescriptors:H,sourceOptions:Q,startTime:W});let q=new AbortController;try{let V=_9(Z,$,q);return await Promise.race([T9(z),...w9(K,{sourceStream:Z,mergedStream:V,sourceOptions:Q,fileDescriptors:H,startTime:W})])}finally{q.abort()}},IB=(Y,Z)=>Promise.allSettled([Y,Z]);import{setImmediate as hB}from"node:timers/promises";import{on as jB}from"node:events";import{getDefaultHighWaterMark as xB}from"node:stream";var i4=({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:X,encoding:J,preserveNewlines:$})=>{let G=new AbortController;return SB(Z,G),O9({stream:Y,controller:G,binary:Q,shouldEncode:!Y.readableObjectMode&&X,encoding:J,shouldSplit:!Y.readableObjectMode,preserveNewlines:$})},SB=async(Y,Z)=>{try{await Y}catch{}finally{Z.abort()}},U2=({stream:Y,onStreamEnd:Z,lines:Q,encoding:X,stripFinalNewline:J,allMixed:$})=>{let G=new AbortController;yB(Z,G,Y);let K=Y.readableObjectMode&&!$;return O9({stream:Y,controller:G,binary:X==="buffer",shouldEncode:!K,encoding:X,shouldSplit:!K&&Q,preserveNewlines:!J})},yB=async(Y,Z,Q)=>{try{await Y}catch{Q.destroy()}finally{Z.abort()}},O9=({stream:Y,controller:Z,binary:Q,shouldEncode:X,encoding:J,shouldSplit:$,preserveNewlines:G})=>{let K=jB(Y,"data",{signal:Z.signal,highWaterMark:N9,highWatermark:N9});return vB({onStdoutChunk:K,controller:Z,binary:Q,shouldEncode:X,encoding:J,shouldSplit:$,preserveNewlines:G})},q2=xB(!0),N9=q2,vB=async function*({onStdoutChunk:Y,controller:Z,binary:Q,shouldEncode:X,encoding:J,shouldSplit:$,preserveNewlines:G}){let K=fB({binary:Q,shouldEncode:X,encoding:J,shouldSplit:$,preserveNewlines:G});try{for await(let[H]of Y)yield*dY(H,K,0)}catch(H){if(!Z.signal.aborted)throw H}finally{yield*O1(K)}},fB=({binary:Y,shouldEncode:Z,encoding:Q,shouldSplit:X,preserveNewlines:J})=>[h4(Y,Q,!Z),f4(Y,J,!X,{})].filter(Boolean);var P9=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:X,buffer:J,maxBuffer:$,lines:G,allMixed:K,stripFinalNewline:H,verboseInfo:W,streamInfo:z})=>{let q=bB({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:X,allMixed:K,verboseInfo:W,streamInfo:z});if(!J){await Promise.all([gB(Y),q]);return}let V=i7(H,Q),R=U2({stream:Y,onStreamEnd:Z,lines:G,encoding:X,stripFinalNewline:V,allMixed:K}),[B]=await Promise.all([mB({stream:Y,iterable:R,fdNumber:Q,encoding:X,maxBuffer:$,lines:G}),q]);return B},bB=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:X,allMixed:J,verboseInfo:$,streamInfo:{fileDescriptors:G}})=>{if(!m4({stdioItems:G[Q]?.stdioItems,encoding:X,verboseInfo:$,fdNumber:Q}))return;let K=U2({stream:Y,onStreamEnd:Z,lines:!0,encoding:X,stripFinalNewline:!0,allMixed:J});await xJ(K,Y,Q,$)},gB=async(Y)=>{if(await hB(),Y.readableFlowing===null)Y.resume()},mB=async({stream:Y,stream:{readableObjectMode:Z},iterable:Q,fdNumber:X,encoding:J,maxBuffer:$,lines:G})=>{try{if(Z||G)return await E4(Q,{maxBuffer:$});if(J==="buffer")return new Uint8Array(await C4(Q,{maxBuffer:$}));return await A4(Q,{maxBuffer:$})}catch(K){return E9(xX({error:K,stream:Y,readableObjectMode:Z,lines:G,encoding:J,fdNumber:X}))}},V2=async(Y)=>{try{return await Y}catch(Z){return E9(Z)}},E9=({bufferedData:Y})=>a5(Y)?new Uint8Array(Y):Y;import{finished as uB}from"node:stream/promises";var k1=async(Y,Z,Q,{isSameDirection:X,stopOnExit:J=!1}={})=>{let $=dB(Y,Q),G=new AbortController;try{await Promise.race([...J?[Q.exitPromise]:[],uB(Y,{cleanup:!0,signal:G.signal})])}catch(K){if(!$.stdinCleanedUp)lB(K,Z,Q,X)}finally{G.abort()}},dB=(Y,{originalStreams:[Z],subprocess:Q})=>{let X={stdinCleanedUp:!1};if(Y===Z)pB(Y,Q,X);return X},pB=(Y,Z,Q)=>{let{_destroy:X}=Y;Y._destroy=(...J)=>{cB(Z,Q),X.call(Y,...J)}},cB=({exitCode:Y,signalCode:Z},Q)=>{if(Y!==null||Z!==null)Q.stdinCleanedUp=!0},lB=(Y,Z,Q,X)=>{if(!iB(Y,Z,Q,X))throw Y},iB=(Y,Z,Q,X=!0)=>{if(Q.propagating)return C9(Y)||n4(Y);return Q.propagating=!0,B2(Q,Z)===X?C9(Y):n4(Y)},B2=({fileDescriptors:Y},Z)=>Z!=="all"&&Y[Z].direction==="input",n4=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",C9=(Y)=>Y?.code==="EPIPE";var k9=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:X,lines:J,stripFinalNewline:$,verboseInfo:G,streamInfo:K})=>Y.stdio.map((H,W)=>F2({stream:H,fdNumber:W,encoding:Z,buffer:Q[W],maxBuffer:X[W],lines:J[W],allMixed:!1,stripFinalNewline:$,verboseInfo:G,streamInfo:K})),F2=async({stream:Y,fdNumber:Z,encoding:Q,buffer:X,maxBuffer:J,lines:$,allMixed:G,stripFinalNewline:K,verboseInfo:H,streamInfo:W})=>{if(!Y)return;let z=k1(Y,Z,W);if(B2(W,Z)){await z;return}let[q]=await Promise.all([P9({stream:Y,onStreamEnd:z,fdNumber:Z,encoding:Q,buffer:X,maxBuffer:J,lines:$,allMixed:G,stripFinalNewline:K,verboseInfo:H,streamInfo:W}),z]);return q};var A9=({stdout:Y,stderr:Z},{all:Q})=>Q&&(Y||Z)?pY([Y,Z].filter(Boolean)):void 0,I9=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:X,lines:J,stripFinalNewline:$,verboseInfo:G,streamInfo:K})=>F2({...nB(Y,Q),fdNumber:"all",encoding:Z,maxBuffer:X[1]+X[2],lines:J[1]||J[2],allMixed:aB(Y),stripFinalNewline:$,verboseInfo:G,streamInfo:K}),nB=({stdout:Y,stderr:Z,all:Q},[,X,J])=>{let $=X||J;if(!$)return{stream:Q,buffer:$};if(!X)return{stream:Z,buffer:$};if(!J)return{stream:Y,buffer:$};return{stream:Q,buffer:$}},aB=({all:Y,stdout:Z,stderr:Q})=>Y&&Z&&Q&&Z.readableObjectMode!==Q.readableObjectMode;import{once as oB}from"node:events";var j9=(Y)=>T6(Y,"ipc"),x9=(Y,Z)=>{let Q=r8(Y);g0({type:"ipc",verboseMessage:Q,fdNumber:"ipc",verboseInfo:Z})};var S9=async({subprocess:Y,buffer:Z,maxBuffer:Q,ipc:X,ipcOutput:J,verboseInfo:$})=>{if(!X)return J;let G=j9($),K=e0(Z,"ipc"),H=e0(Q,"ipc");for await(let W of Z2({anyProcess:Y,channel:Y.channel,isSubprocess:!1,ipc:X,shouldAwait:!1,reference:!0})){if(K)SX(Y,J,H),J.push(W);if(G)x9(W,$)}return J},y9=async(Y,Z)=>{return await Promise.allSettled([Y]),Z};var v9=async({subprocess:Y,options:{encoding:Z,buffer:Q,maxBuffer:X,lines:J,timeoutDuration:$,cancelSignal:G,gracefulCancel:K,forceKillAfterDelay:H,stripFinalNewline:W,ipc:z,ipcInput:q},context:V,verboseInfo:R,fileDescriptors:B,originalStreams:M,onInternalError:T,controller:D})=>{let _=hJ(Y,V),w={originalStreams:M,fileDescriptors:B,subprocess:Y,exitPromise:_,propagating:!1},N=k9({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:X,lines:J,stripFinalNewline:W,verboseInfo:R,streamInfo:w}),j=I9({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:X,lines:J,stripFinalNewline:W,verboseInfo:R,streamInfo:w}),x=[],f=S9({subprocess:Y,buffer:Q,maxBuffer:X,ipc:z,ipcOutput:x,verboseInfo:R}),m=sB(M,Y,w),b=tB(B,w);try{return await Promise.race([Promise.all([{},gJ(_),Promise.all(N),j,f,WX(Y,q),...m,...b]),T,rB(Y,D),...$X(Y,$,V,D),...EQ({subprocess:Y,cancelSignal:G,gracefulCancel:K,context:V,controller:D}),...XX({subprocess:Y,cancelSignal:G,gracefulCancel:K,forceKillAfterDelay:H,context:V,controller:D})])}catch(v){return V.terminationReason??="other",Promise.all([{error:v},_,Promise.all(N.map((d)=>V2(d))),V2(j),y9(f,x),Promise.allSettled(m),Promise.allSettled(b)])}},sB=(Y,Z,Q)=>Y.map((X,J)=>X===Z.stdio[J]?void 0:k1(X,J,Q)),tB=(Y,Z)=>Y.flatMap(({stdioItems:Q},X)=>Q.filter(({value:J,stream:$=J})=>f0($,{checkOpen:!1})&&!y0($)).map(({type:J,value:$,stream:G=$})=>k1(G,X,Z,{isSameDirection:x0.has(J),stopOnExit:J==="native"}))),rB=async(Y,{signal:Z})=>{let[Q]=await oB(Y,"error",{signal:Z});throw Q};var f9=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),A1=(Y,Z,Q)=>{let X=Y[Q];if(!X.has(Z))X.set(Z,[]);let J=X.get(Z),$=u0();return J.push($),{resolve:$.resolve.bind($),promises:J}},x6=async({resolve:Y,promises:Z},Q)=>{Y();let[X]=await Promise.race([Promise.allSettled([!0,Q]),Promise.all([!1,...Z])]);return!X};import{Readable as eB}from"node:stream";import{callbackify as YF}from"node:util";import{finished as h9}from"node:stream/promises";var R2=async(Y)=>{if(Y===void 0)return;try{await M2(Y)}catch{}},b9=async(Y)=>{if(Y===void 0)return;try{await D2(Y)}catch{}},M2=async(Y)=>{await h9(Y,{cleanup:!0,readable:!1,writable:!0})},D2=async(Y)=>{await h9(Y,{cleanup:!0,readable:!0,writable:!1})},a4=async(Y,Z)=>{if(await Y,Z)throw Z},o4=(Y,Z,Q)=>{if(Q&&!n4(Q))Y.destroy(Q);else if(Z)Y.destroy()};var g9=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:X,binary:J=!0,preserveNewlines:$=!0}={})=>{let G=J||O0.has(Q),{subprocessStdout:K,waitReadableDestroy:H}=L2(Y,X,Z),{readableEncoding:W,readableObjectMode:z,readableHighWaterMark:q}=T2(K,G),{read:V,onStdoutDataDone:R}=_2({subprocessStdout:K,subprocess:Y,binary:G,encoding:Q,preserveNewlines:$}),B=new eB({read:V,destroy:YF(N2.bind(void 0,{subprocessStdout:K,subprocess:Y,waitReadableDestroy:H})),highWaterMark:q,objectMode:z,encoding:W});return w2({subprocessStdout:K,onStdoutDataDone:R,readable:B,subprocess:Y}),B},L2=(Y,Z,Q)=>{let X=P6(Y,Z),J=A1(Q,X,"readableDestroy");return{subprocessStdout:X,waitReadableDestroy:J}},T2=({readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q},X)=>X?{readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q}:{readableEncoding:Y,readableObjectMode:!0,readableHighWaterMark:q2},_2=({subprocessStdout:Y,subprocess:Z,binary:Q,encoding:X,preserveNewlines:J})=>{let $=u0(),G=i4({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:!Q,encoding:X,preserveNewlines:J});return{read(){ZF(this,G,$)},onStdoutDataDone:$}},ZF=async(Y,Z,Q)=>{try{let{value:X,done:J}=await Z.next();if(J)Q.resolve();else Y.push(X)}catch{}},w2=async({subprocessStdout:Y,onStdoutDataDone:Z,readable:Q,subprocess:X,subprocessStdin:J})=>{try{if(await D2(Y),await X,await R2(J),await Z,Q.readable)Q.push(null)}catch($){await R2(J),m9(Q,$)}},N2=async({subprocessStdout:Y,subprocess:Z,waitReadableDestroy:Q},X)=>{if(await x6(Q,Z))m9(Y,X),await a4(Z,X)},m9=(Y,Z)=>{o4(Y,Y.readable,Z)};import{Writable as QF}from"node:stream";import{callbackify as u9}from"node:util";var d9=({subprocess:Y,concurrentStreams:Z},{to:Q}={})=>{let{subprocessStdin:X,waitWritableFinal:J,waitWritableDestroy:$}=O2(Y,Q,Z),G=new QF({...P2(X,Y,J),destroy:u9(C2.bind(void 0,{subprocessStdin:X,subprocess:Y,waitWritableFinal:J,waitWritableDestroy:$})),highWaterMark:X.writableHighWaterMark,objectMode:X.writableObjectMode});return E2(X,G),G},O2=(Y,Z,Q)=>{let X=W4(Y,Z),J=A1(Q,X,"writableFinal"),$=A1(Q,X,"writableDestroy");return{subprocessStdin:X,waitWritableFinal:J,waitWritableDestroy:$}},P2=(Y,Z,Q)=>({write:XF.bind(void 0,Y),final:u9(JF.bind(void 0,Y,Z,Q))}),XF=(Y,Z,Q,X)=>{if(Y.write(Z,Q))X();else Y.once("drain",X)},JF=async(Y,Z,Q)=>{if(await x6(Q,Z)){if(Y.writable)Y.end();await Z}},E2=async(Y,Z,Q)=>{try{if(await M2(Y),Z.writable)Z.end()}catch(X){await b9(Q),p9(Z,X)}},C2=async({subprocessStdin:Y,subprocess:Z,waitWritableFinal:Q,waitWritableDestroy:X},J)=>{if(await x6(Q,Z),await x6(X,Z))p9(Y,J),await a4(Z,J)},p9=(Y,Z)=>{o4(Y,Y.writable,Z)};import{Duplex as $F}from"node:stream";import{callbackify as GF}from"node:util";var c9=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:X,to:J,binary:$=!0,preserveNewlines:G=!0}={})=>{let K=$||O0.has(Q),{subprocessStdout:H,waitReadableDestroy:W}=L2(Y,X,Z),{subprocessStdin:z,waitWritableFinal:q,waitWritableDestroy:V}=O2(Y,J,Z),{readableEncoding:R,readableObjectMode:B,readableHighWaterMark:M}=T2(H,K),{read:T,onStdoutDataDone:D}=_2({subprocessStdout:H,subprocess:Y,binary:K,encoding:Q,preserveNewlines:G}),_=new $F({read:T,...P2(z,Y,q),destroy:GF(KF.bind(void 0,{subprocessStdout:H,subprocessStdin:z,subprocess:Y,waitReadableDestroy:W,waitWritableFinal:q,waitWritableDestroy:V})),readableHighWaterMark:M,writableHighWaterMark:z.writableHighWaterMark,readableObjectMode:B,writableObjectMode:z.writableObjectMode,encoding:R});return w2({subprocessStdout:H,onStdoutDataDone:D,readable:_,subprocess:Y,subprocessStdin:z}),E2(z,_,H),_},KF=async({subprocessStdout:Y,subprocessStdin:Z,subprocess:Q,waitReadableDestroy:X,waitWritableFinal:J,waitWritableDestroy:$},G)=>{await Promise.all([N2({subprocessStdout:Y,subprocess:Q,waitReadableDestroy:X},G),C2({subprocessStdin:Z,subprocess:Q,waitWritableFinal:J,waitWritableDestroy:$},G)])};var k2=(Y,Z,{from:Q,binary:X=!1,preserveNewlines:J=!1}={})=>{let $=X||O0.has(Z),G=P6(Y,Q),K=i4({subprocessStdout:G,subprocess:Y,binary:$,shouldEncode:!0,encoding:Z,preserveNewlines:J});return HF(K,G,Y)},HF=async function*(Y,Z,Q){try{yield*Y}finally{if(Z.readable)Z.destroy();await Q}};var l9=(Y,{encoding:Z})=>{let Q=f9();Y.readable=g9.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.writable=d9.bind(void 0,{subprocess:Y,concurrentStreams:Q}),Y.duplex=c9.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.iterable=k2.bind(void 0,Y,Z),Y[Symbol.asyncIterator]=k2.bind(void 0,Y,Z,{})};var i9=(Y,Z)=>{for(let[Q,X]of WF){let J=X.value.bind(Z);Reflect.defineProperty(Y,Q,{...X,value:J})}},zF=(async()=>{})().constructor.prototype,WF=["then","catch","finally"].map((Y)=>[Y,Reflect.getOwnPropertyDescriptor(zF,Y)]);var n9=(Y,Z,Q,X)=>{let{file:J,commandArguments:$,command:G,escapedCommand:K,startTime:H,verboseInfo:W,options:z,fileDescriptors:q}=VF(Y,Z,Q),{subprocess:V,promise:R}=FF({file:J,commandArguments:$,options:z,startTime:H,verboseInfo:W,command:G,escapedCommand:K,fileDescriptors:q});return V.pipe=l4.bind(void 0,{source:V,sourcePromise:R,boundOptions:{},createNested:X}),i9(V,R),d0.set(V,{options:z,fileDescriptors:q}),V},VF=(Y,Z,Q)=>{let{command:X,escapedCommand:J,startTime:$,verboseInfo:G}=Y4(Y,Z,Q),{file:K,commandArguments:H,options:W}=_4(Y,Z,Q),z=BF(W),q=Y9(z,G);return{file:K,commandArguments:H,command:X,escapedCommand:J,startTime:$,verboseInfo:G,options:z,fileDescriptors:q}},BF=({timeout:Y,signal:Z,...Q})=>{if(Z!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...Q,timeoutDuration:Y}},FF=({file:Y,commandArguments:Z,options:Q,startTime:X,verboseInfo:J,command:$,escapedCommand:G,fileDescriptors:K})=>{let H;try{H=qF(...w4(Y,Z,Q))}catch(B){return sJ({error:B,command:$,escapedCommand:G,fileDescriptors:K,options:Q,startTime:X,verboseInfo:J})}let W=new AbortController;UF(Number.POSITIVE_INFINITY,W.signal);let z=[...H.stdio];W9(H,K,W),F9(H,Q,W);let q={},V=u0();H.kill=OQ.bind(void 0,{kill:H.kill.bind(H),options:Q,onInternalError:V,context:q,controller:W}),H.all=A9(H,Q),l9(H,Q),nJ(H,Q);let R=RF({subprocess:H,options:Q,startTime:X,verboseInfo:J,fileDescriptors:K,originalStreams:z,command:$,escapedCommand:G,context:q,onInternalError:V,controller:W});return{subprocess:H,promise:R}},RF=async({subprocess:Y,options:Z,startTime:Q,verboseInfo:X,fileDescriptors:J,originalStreams:$,command:G,escapedCommand:K,context:H,onInternalError:W,controller:z})=>{let[q,[V,R],B,M,T]=await v9({subprocess:Y,options:Z,context:H,verboseInfo:X,fileDescriptors:J,originalStreams:$,onInternalError:W,controller:z});z.abort(),W.resolve();let D=B.map((N,j)=>QY(N,Z,j)),_=QY(M,Z,"all"),w=MF({errorInfo:q,exitCode:V,signal:R,stdio:D,all:_,ipcOutput:T,context:H,options:Z,command:G,escapedCommand:K,startTime:Q});return A6(w,X,Z)},MF=({errorInfo:Y,exitCode:Z,signal:Q,stdio:X,all:J,ipcOutput:$,context:G,options:K,command:H,escapedCommand:W,startTime:z})=>("error"in Y)?N1({error:Y.error,command:H,escapedCommand:W,timedOut:G.terminationReason==="timeout",isCanceled:G.terminationReason==="cancel"||G.terminationReason==="gracefulCancel",isGracefullyCanceled:G.terminationReason==="gracefulCancel",isMaxBuffer:Y.error instanceof YY,isForcefullyTerminated:G.isForcefullyTerminated,exitCode:Z,signal:Q,stdio:X,all:J,ipcOutput:$,options:K,startTime:z,isSync:!1}):j4({command:H,escapedCommand:W,stdio:X,all:J,ipcOutput:$,options:K,startTime:z});var s4=(Y,Z)=>{let Q=Object.fromEntries(Object.entries(Z).map(([X,J])=>[X,DF(X,Y[X],J)]));return{...Y,...Q}},DF=(Y,Z,Q)=>{if(LF.has(Y)&&e(Z)&&e(Q))return{...Z,...Q};return Q},LF=new Set(["env",...K7]);var RY=(Y,Z,Q,X)=>{let J=(G,K,H)=>RY(G,K,Q,H),$=(...G)=>TF({mapArguments:Y,deepOptions:Q,boundOptions:Z,setBoundExeca:X,createNested:J},...G);if(X!==void 0)X($,J,Z);return $},TF=({mapArguments:Y,deepOptions:Z={},boundOptions:Q={},setBoundExeca:X,createNested:J},$,...G)=>{if(e($))return J(Y,s4(Q,$),X);let{file:K,commandArguments:H,options:W,isSync:z}=_F({mapArguments:Y,firstArgument:$,nextArguments:G,deepOptions:Z,boundOptions:Q});return z?uJ(K,H,W):n9(K,H,W,J)},_F=({mapArguments:Y,firstArgument:Z,nextArguments:Q,deepOptions:X,boundOptions:J})=>{let $=Y3(Z)?Z3(Z,Q):[Z,...Q],[G,K,H]=p8(...$),W=s4(s4(X,J),H),{file:z=G,commandArguments:q=K,options:V=W,isSync:R=!1}=Y({file:G,commandArguments:K,options:W});return{file:z,commandArguments:q,options:V,isSync:R}};var a9=({file:Y,commandArguments:Z})=>s9(Y,Z),o9=({file:Y,commandArguments:Z})=>({...s9(Y,Z),isSync:!0}),s9=(Y,Z)=>{if(Z.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Y} ${Z}.`);let[Q,...X]=wF(Y);return{file:Q,commandArguments:X}},wF=(Y)=>{if(typeof Y!=="string")throw TypeError(`The command must be a string: ${String(Y)}.`);let Z=Y.trim();if(Z==="")return[];let Q=[];for(let X of Z.split(NF)){let J=Q.at(-1);if(J&&J.endsWith("\\"))Q[Q.length-1]=`${J.slice(0,-1)} ${X}`;else Q.push(X)}return Q},NF=/ +/g;var t9=(Y,Z,Q)=>{Y.sync=Z(OF,Q),Y.s=Y.sync},r9=({options:Y})=>e9(Y),OF=({options:Y})=>({...e9(Y),isSync:!0}),e9=(Y)=>({options:{...PF(Y),...Y}}),PF=({input:Y,inputFile:Z,stdio:Q})=>Y===void 0&&Z===void 0&&Q===void 0?{stdin:"inherit"}:{},Y$={preferLocal:!0};var c0=RY(()=>({})),sk=RY(()=>({isSync:!0})),tk=RY(a9),rk=RY(o9),ek=RY(KX),h=RY(r9,{},Y$,t9),{sendMessage:YA,getOneMessage:ZA,getEachMessage:QA,getCancelSignal:XA}=aJ();Y0();Y0();import QZ from"path";import L$ from"os";var j2={name:"gdx",version:"0.2.0",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/","scripts/postinstall.cjs","scripts/launcher.cjs","README.md","LICENSE"],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",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 --format=esm --production --keep-names",prepack:"bun run package:node",postinstall:"node scripts/postinstall.cjs",prettier:'prettier --write "src/**/*.ts" "test/**/*.ts" "./*.md"',"dummy-editor":"bun ./scripts/dummyEditor.mjs"},devDependencies:{"@babel/cli":"^7.28.0","@babel/core":"^7.28.0","@babel/preset-env":"^7.27.2","@babel/preset-typescript":"^7.27.1","@eslint/js":"^9.22.0","@types/chai":"^5.2.3","@typescript-eslint/eslint-plugin":"^8.13.0","@typescript-eslint/parser":"^8.13.0","bun-types":"latest",chai:"^6.2.1",eslint:"^9.22.0",jiti:"^2.6.1",tsx:"^4.21.0",prettier:"^3.6.2",typescript:"^5.8.3","typescript-eslint":"^8.50.0",dedent:"^1.7.0",execa:"^9.6.1",openai:"^6.14.0","smol-toml":"^1.5.2"},dependencies:{"cspell-lib":"^9.4.0",keytar:"^7.9.0"}};import{existsSync as l0,readFileSync as x2,writeFileSync as MY,mkdirSync as t4,mkdtempSync as xI,rmSync as S2,accessSync as U$,readdirSync as r4,appendFileSync as q$,unlinkSync as y2,constants as v2}from"fs";import{access as V$,rm as yI,rmdir as vI,mkdir as fI,readdir as hI,readlink as bI,stat as e4,link as gI,unlink as B$,writeFile as YZ,appendFile as mI,readFile as ZZ}from"fs/promises";import{constants as jF}from"fs";function k(Y,Z=`
|
|
90
|
-
|
|
82
|
+
if (condition) { yield value; }`)};var NG=R(()=>{i0()});import{Buffer as DN}from"node:buffer";import{StringDecoder as NN}from"node:string_decoder";var S7=(Y,Z,Q)=>{if(Q)return;if(Y)return{transform:wN.bind(void 0,new TextEncoder)};let J=new NN(Z);return{transform:LN.bind(void 0,J),final:_N.bind(void 0,J)}},wN=function*(Y,Z){if(DN.isBuffer(Z))yield mY(Z);else if(typeof Z==="string")yield Y.encode(Z);else yield Z},LN=function*(Y,Z){yield L0(Z)?Y.write(Z):Z},_N=function*(Y){let Z=Y.end();if(Z!=="")yield Z};var d3=R(()=>{i0()});import{callbackify as wG}from"node:util";var p3,v7=async function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:J=jN}=Z[Q];for await(let z of J(Y))yield*v7(z,Z,Q+1)},LG=async function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*IN(Q,Number(Z),Y)},IN=async function*(Y,Z,Q){if(Y===void 0)return;for await(let J of Y())yield*v7(J,Q,Z+1)},_G,jN=function*(Y){yield Y};var IG=R(()=>{p3=wG(async(Y,Z,Q,J)=>{Z.currentIterable=Y(...Q);try{for await(let z of Z.currentIterable)J.push(z)}finally{delete Z.currentIterable}}),_G=wG(async({currentIterable:Y},Z)=>{if(Y!==void 0){await(Z?Y.throw(Z):Y.return());return}if(Z)throw Z})});var c3=(Y,Z,Q,J)=>{try{for(let z of Y(...Z))Q.push(z);J()}catch(z){J(z)}},jG=(Y,Z)=>[...Z.flatMap((Q)=>[...r6(Q,Y,0)]),...n8(Y)],r6=function*(Y,Z,Q){if(Q===Z.length){yield Y;return}let{transform:J=CN}=Z[Q];for(let z of J(Y))yield*r6(z,Z,Q+1)},n8=function*(Y){for(let[Z,{final:Q}]of Object.entries(Y))yield*TN(Q,Number(Z),Y)},TN=function*(Y,Z,Q){if(Y===void 0)return;for(let J of Y())yield*r6(J,Q,Z+1)},CN=function*(Y){yield Y};import{Transform as kN,getDefaultHighWaterMark as TG}from"node:stream";var l3=({value:Y,value:{transform:Z,final:Q,writableObjectMode:J,readableObjectMode:z},optionName:X},{encoding:H})=>{let W={},K=CG(Y,H,X),$=s6(Z),G=s6(Q),U=$?p3.bind(void 0,v7,W):c3.bind(void 0,r6),B=$||G?p3.bind(void 0,LG,W):c3.bind(void 0,n8),F=$||G?_G.bind(void 0,W):void 0;return{stream:new kN({writableObjectMode:J,writableHighWaterMark:TG(J),readableObjectMode:z,readableHighWaterMark:TG(z),transform(O,N,w){U([O,K,0],this,w)},flush(O){B([K],this,O)},destroy:F})}},y7=(Y,Z,Q,J)=>{let z=Z.filter(({type:H})=>H==="generator"),X=J?z.reverse():z;for(let{value:H,optionName:W}of X){let K=CG(H,Q,W);Y=jG(K,Y)}return Y},CG=({transform:Y,final:Z,binary:Q,writableObjectMode:J,readableObjectMode:z,preserveNewlines:X},H,W)=>{let K={};return[{transform:MG(J,W)},S7(Q,H,J),E7(Q,X,J,K),{transform:Y,final:Z},{transform:OG(z,W)},RG({binary:Q,preserveNewlines:X,readableObjectMode:z,state:K})].filter(Boolean)};var f7=R(()=>{h0();P7();NG();d3();IG()});var kG=(Y,Z)=>{for(let Q of AN(Y))xN(Y,Q,Z)},AN=(Y)=>new Set(Object.entries(Y).filter(([,{direction:Z}])=>Z==="input").map(([Z])=>Number(Z))),xN=(Y,Z,Q)=>{let{stdioItems:J}=Y[Z],z=J.filter(({contents:W})=>W!==void 0);if(z.length===0)return;if(Z!==0){let[{type:W,optionName:K}]=z;throw TypeError(`Only the \`stdin\` option, not \`${K}\`, can be ${U6[W]} with synchronous methods.`)}let H=z.map(({contents:W})=>W).map((W)=>EN(W,J));Q.input=S8(H)},EN=(Y,Z)=>{let Q=y7(Y,Z,"utf8",!0);return PN(Q),S8(Q)},PN=(Y)=>{let Z=Y.find((Q)=>typeof Q!=="string"&&!L0(Q));if(Z!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${Z}.`)};var AG=R(()=>{f7();i0();h0()});var b7=({stdioItems:Y,encoding:Z,verboseInfo:Q,fdNumber:J})=>J!=="all"&&v1(Q,J)&&!a0.has(Z)&&SN(J)&&(Y.some(({type:z,value:X})=>z==="native"&&vN.has(X))||Y.every(({type:z})=>XY.has(z))),SN=(Y)=>Y===1||Y===2,vN,xG=async(Y,Z,Q,J)=>{for await(let z of Y)if(!yN(Z))PG(z,Q,J)},EG=(Y,Z,Q)=>{for(let J of Y)PG(J,Z,Q)},yN=(Y)=>Y._readableState.pipes.length>0,PG=(Y,Z,Q)=>{let J=bZ(Y);DY({type:"output",verboseMessage:J,fdNumber:Z,verboseInfo:Q})};var i3=R(()=>{n6();h0();y1();W6();vN=new Set(["pipe","overlapped"])});import{writeFileSync as fN,appendFileSync as bN}from"node:fs";var SG=({fileDescriptors:Y,syncResult:{output:Z},options:Q,isMaxBuffer:J,verboseInfo:z})=>{if(Z===null)return{output:Array.from({length:3})};let X={},H=new Set([]);return{output:Z.map((K,$)=>hN({result:K,fileDescriptors:Y,fdNumber:$,state:X,outputFiles:H,isMaxBuffer:J,verboseInfo:z},Q)),...X}},hN=({result:Y,fileDescriptors:Z,fdNumber:Q,state:J,outputFiles:z,isMaxBuffer:X,verboseInfo:H},{buffer:W,encoding:K,lines:$,stripFinalNewline:G,maxBuffer:U})=>{if(Y===null)return;let B=NK(Y,X,U),F=mY(B),{stdioItems:V,objectMode:O}=Z[Q],N=gN([F],V,K,J),{serializedResult:w,finalResult:L=w}=mN({chunks:N,objectMode:O,encoding:K,lines:$,stripFinalNewline:G,fdNumber:Q});uN({serializedResult:w,fdNumber:Q,state:J,verboseInfo:H,encoding:K,stdioItems:V,objectMode:O});let I=W[Q]?L:void 0;try{if(J.error===void 0)dN(w,V,z);return I}catch(T){return J.error=T,I}},gN=(Y,Z,Q,J)=>{try{return y7(Y,Z,Q,!1)}catch(z){return J.error=z,Y}},mN=({chunks:Y,objectMode:Z,encoding:Q,lines:J,stripFinalNewline:z,fdNumber:X})=>{if(Z)return{serializedResult:Y};if(Q==="buffer")return{serializedResult:S8(Y)};let H=BX(Y,Q);if(J[X])return{serializedResult:H,finalResult:u3(H,!z[X],Z)};return{serializedResult:H}},uN=({serializedResult:Y,fdNumber:Z,state:Q,verboseInfo:J,encoding:z,stdioItems:X,objectMode:H})=>{if(!b7({stdioItems:X,encoding:z,verboseInfo:J,fdNumber:Z}))return;let W=u3(Y,!1,H);try{EG(W,Z,J)}catch(K){Q.error??=K}},dN=(Y,Z,Q)=>{for(let{path:J,append:z}of Z.filter(({type:X})=>k7.has(X))){let X=typeof J==="string"?J:J.toString();if(z||Q.has(X))bN(J,Y);else Q.add(X),fN(J,Y)}};var vG=R(()=>{i3();f7();P7();i0();h0();o6()});var yG=([,Y,Z],Q)=>{if(!Q.all)return;if(Y===void 0)return Z;if(Z===void 0)return Y;if(Array.isArray(Y))return Array.isArray(Z)?[...Y,...Z]:[...Y,iY(Z,Q,"all")];if(Array.isArray(Z))return[iY(Y,Q,"all"),...Z];if(L0(Y)&&L0(Z))return b5([Y,Z]);return`${Y}${Z}`};var fG=R(()=>{i0();i8()});import{once as n3}from"node:events";var bG=async(Y,Z)=>{let[Q,J]=await pN(Y);return Z.isForcefullyTerminated??=!1,[Q,J]},pN=async(Y)=>{let[Z,Q]=await Promise.allSettled([n3(Y,"spawn"),n3(Y,"exit")]);if(Z.status==="rejected")return[];return Q.status==="rejected"?hG(Y):Q.value},hG=async(Y)=>{try{return await n3(Y,"exit")}catch{return hG(Y)}},gG=async(Y)=>{let[Z,Q]=await Y;if(!cN(Z,Q)&&a3(Z,Q))throw new NY;return[Z,Q]},cN=(Y,Z)=>Y===void 0&&Z===void 0,a3=(Y,Z)=>Y!==0||Z!==null;var o3=R(()=>{K6()});var mG=({error:Y,status:Z,signal:Q,output:J},{maxBuffer:z})=>{let X=lN(Y,Z,Q),H=X?.code==="ETIMEDOUT",W=DK(X,J,z);return{resultError:X,exitCode:Z,signal:Q,timedOut:H,isMaxBuffer:W}},lN=(Y,Z,Q)=>{if(Y!==void 0)return Y;return a3(Z,Q)?new NY:void 0};var uG=R(()=>{K6();o6();o3()});import{spawnSync as iN}from"node:child_process";var dG=(Y,Z,Q)=>{let{file:J,commandArguments:z,command:X,escapedCommand:H,startTime:W,verboseInfo:K,options:$,fileDescriptors:G}=nN(Y,Z,Q),U=sN({file:J,commandArguments:z,options:$,command:X,escapedCommand:H,verboseInfo:K,fileDescriptors:G,startTime:W});return l1(U,K,$)},nN=(Y,Z,Q)=>{let{command:J,escapedCommand:z,startTime:X,verboseInfo:H}=mZ(Y,Z,Q),W=aN(Q),{file:K,commandArguments:$,options:G}=B7(Y,Z,W);oN(G);let U=qG(G,H);return{file:K,commandArguments:$,command:J,escapedCommand:z,startTime:X,verboseInfo:H,options:G,fileDescriptors:U}},aN=(Y)=>Y.node&&!Y.ipc?{...Y,ipc:!1}:Y,oN=({ipc:Y,ipcInput:Z,detached:Q,cancelSignal:J})=>{if(Z)h7("ipcInput");if(Y)h7("ipc: true");if(Q)h7("detached: true");if(J)h7("cancelSignal")},h7=(Y)=>{throw TypeError(`The "${Y}" option cannot be used with synchronous methods.`)},sN=({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,verboseInfo:X,fileDescriptors:H,startTime:W})=>{let K=rN({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,fileDescriptors:H,startTime:W});if(K.failed)return K;let{resultError:$,exitCode:G,signal:U,timedOut:B,isMaxBuffer:F}=mG(K,Q),{output:V,error:O=$}=SG({fileDescriptors:H,syncResult:K,options:Q,isMaxBuffer:F,verboseInfo:X}),N=V.map((L,I)=>iY(L,Q,I)),w=iY(yG(V,Q),Q,"all");return eN({error:O,exitCode:G,signal:U,timedOut:B,isMaxBuffer:F,stdio:N,all:w,options:Q,command:J,escapedCommand:z,startTime:W})},rN=({file:Y,commandArguments:Z,options:Q,command:J,escapedCommand:z,fileDescriptors:X,startTime:H})=>{try{kG(X,Q);let W=tN(Q);return iN(...V7(Y,Z,W))}catch(W){return c1({error:W,command:J,escapedCommand:z,fileDescriptors:X,options:Q,startTime:H,isSync:!0})}},tN=({encoding:Y,maxBuffer:Z,...Q})=>({...Q,encoding:"buffer",maxBuffer:_7(Z)}),eN=({error:Y,exitCode:Z,signal:Q,timedOut:J,isMaxBuffer:z,stdio:X,all:H,options:W,command:K,escapedCommand:$,startTime:G})=>Y===void 0?I7({command:K,escapedCommand:$,stdio:X,all:H,ipcOutput:[],options:W,startTime:G}):c8({error:Y,command:K,escapedCommand:$,timedOut:J,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:z,isForcefullyTerminated:!1,exitCode:Z,signal:Q,stdio:X,all:H,ipcOutput:[],options:W,startTime:G,isSync:!0});var pG=R(()=>{i5();w3();l8();j7();BG();i8();AG();vG();o6();fG();uG()});import{once as s3,on as Yw}from"node:events";var cG=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},{reference:z=!0,filter:X}={})=>{return h1({methodName:"getOneMessage",isSubprocess:Q,ipc:J,isConnected:H7(Y)}),Zw({anyProcess:Y,channel:Z,isSubprocess:Q,filter:X,reference:z})},Zw=async({anyProcess:Y,channel:Z,isSubprocess:Q,filter:J,reference:z})=>{eZ(Z,z);let X=q6(Y,Z,Q),H=new AbortController;try{return await Promise.race([Qw(X,J,H),Jw(X,Q,H),zw(X,Q,H)])}catch(W){throw g1(Y),W}finally{H.abort(),Y7(Z,z)}},Qw=async(Y,Z,{signal:Q})=>{if(Z===void 0){let[J]=await s3(Y,"message",{signal:Q});return J}for await(let[J]of Yw(Y,"message",{signal:Q}))if(Z(J))return J},Jw=async(Y,Z,{signal:Q})=>{await s3(Y,"disconnect",{signal:Q}),JW(Z)},zw=async(Y,Z,{signal:Q})=>{let[J]=await s3(Y,"strict:error",{signal:Q});throw oZ(J,Z)};var lG=R(()=>{m1();g8()});import{once as nG,on as Xw}from"node:events";var aG=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J},{reference:z=!0}={})=>r3({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J,shouldAwait:!Q,reference:z}),r3=({anyProcess:Y,channel:Z,isSubprocess:Q,ipc:J,shouldAwait:z,reference:X})=>{h1({methodName:"getEachMessage",isSubprocess:Q,ipc:J,isConnected:H7(Y)}),eZ(Z,X);let H=q6(Y,Z,Q),W=new AbortController,K={};return Hw(Y,H,W),Ww({ipcEmitter:H,isSubprocess:Q,controller:W,state:K}),Kw({anyProcess:Y,channel:Z,ipcEmitter:H,isSubprocess:Q,shouldAwait:z,controller:W,state:K,reference:X})},Hw=async(Y,Z,Q)=>{try{await nG(Z,"disconnect",{signal:Q.signal}),Q.abort()}catch{}},Ww=async({ipcEmitter:Y,isSubprocess:Z,controller:Q,state:J})=>{try{let[z]=await nG(Y,"strict:error",{signal:Q.signal});J.error=oZ(z,Z),Q.abort()}catch{}},Kw=async function*({anyProcess:Y,channel:Z,ipcEmitter:Q,isSubprocess:J,shouldAwait:z,controller:X,state:H,reference:W}){try{for await(let[K]of Xw(Q,"message",{signal:X.signal}))iG(H),yield K}catch{iG(H)}finally{if(X.abort(),Y7(Z,W),!J)g1(Y);if(z)await Y}},iG=({error:Y})=>{if(Y)throw Y};var t3=R(()=>{m1();g8()});import oG from"node:process";var sG=(Y,{ipc:Z})=>{Object.assign(Y,tG(Y,!1,Z))},rG=()=>{let Y=oG,Z=!0,Q=oG.channel!==void 0;return{...tG(Y,!0,Q),getCancelSignal:EW.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:!0,ipc:Q})}},tG=(Y,Z,Q)=>({sendMessage:$7.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getOneMessage:cG.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q}),getEachMessage:aG.bind(void 0,{anyProcess:Y,channel:Y.channel,isSubprocess:Z,ipc:Q})});var e3=R(()=>{q7();lG();t3();z7()});import{ChildProcess as Gw}from"node:child_process";import{PassThrough as $w,Readable as qw,Writable as Uw,Duplex as Bw}from"node:stream";var eG=({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:X,verboseInfo:H})=>{h3(J);let W=new Gw;Vw(W,J),Object.assign(W,{readable:Fw,writable:Rw,duplex:Mw});let K=c1({error:Y,command:Z,escapedCommand:Q,fileDescriptors:J,options:z,startTime:X,isSync:!1}),$=Ow(K,H,z);return{subprocess:W,promise:$}},Vw=(Y,Z)=>{let Q=a8(),J=a8(),z=a8(),X=Array.from({length:Z.length-3},a8),H=a8(),W=[Q,J,z,...X];Object.assign(Y,{stdin:Q,stdout:J,stderr:z,all:H,stdio:W})},a8=()=>{let Y=new $w;return Y.end(),Y},Fw=()=>new qw({read(){}}),Rw=()=>new Uw({write(){}}),Mw=()=>new Bw({read(){},write(){}}),Ow=async(Y,Z,Q)=>l1(Y,Z,Q);var Y$=R(()=>{x7();l8();j7()});import{createReadStream as Z$,createWriteStream as Q$}from"node:fs";import{Buffer as Dw}from"node:buffer";import{Readable as o8,Writable as Nw,Duplex as ww}from"node:stream";var z$=(Y,Z)=>A7(Lw,Y,Z,!1),s8=({type:Y,optionName:Z})=>{throw TypeError(`The \`${Z}\` option cannot be ${U6[Y]}.`)},J$,Lw;var X$=R(()=>{f7();x7();h0();J$={fileNumber:s8,generator:l3,asyncGenerator:l3,nodeStream:({value:Y})=>({stream:Y}),webTransform({value:{transform:Y,writableObjectMode:Z,readableObjectMode:Q}}){let J=Z||Q;return{stream:ww.fromWeb(Y,{objectMode:J})}},duplex:({value:{transform:Y}})=>({stream:Y}),native(){}},Lw={input:{...J$,fileUrl:({value:Y})=>({stream:Z$(Y)}),filePath:({value:{file:Y}})=>({stream:Z$(Y)}),webStream:({value:Y})=>({stream:o8.fromWeb(Y)}),iterable:({value:Y})=>({stream:o8.from(Y)}),asyncIterable:({value:Y})=>({stream:o8.from(Y)}),string:({value:Y})=>({stream:o8.from(Y)}),uint8Array:({value:Y})=>({stream:o8.from(Dw.from(Y))})},output:{...J$,fileUrl:({value:Y})=>({stream:Q$(Y)}),filePath:({value:{file:Y,append:Z}})=>({stream:Q$(Y,Z?{flags:"a"}:{})}),webStream:({value:Y})=>({stream:Nw.fromWeb(Y)}),iterable:s8,asyncIterable:s8,string:s8,uint8Array:s8}}});import{on as _w,once as H$}from"node:events";import{PassThrough as Iw,getDefaultHighWaterMark as jw}from"node:stream";import{finished as G$}from"node:stream/promises";function t6(Y){if(!Array.isArray(Y))throw TypeError(`Expected an array, got \`${typeof Y}\`.`);for(let z of Y)YQ(z);let Z=Y.some(({readableObjectMode:z})=>z),Q=Tw(Y,Z),J=new $$({objectMode:Z,writableHighWaterMark:Q,readableHighWaterMark:Q});for(let z of Y)J.add(z);return J}var Tw=(Y,Z)=>{if(Y.length===0)return jw(Z);let Q=Y.filter(({readableObjectMode:J})=>J===Z).map(({readableHighWaterMark:J})=>J);return Math.max(...Q)},$$,Cw=async(Y,Z,Q)=>{g7(Y,W$);let J=new AbortController;try{await Promise.race([kw(Y,J),Aw(Y,Z,Q,J)])}finally{J.abort(),g7(Y,-W$)}},kw=async(Y,{signal:Z})=>{try{await G$(Y,{signal:Z,cleanup:!0})}catch(Q){throw q$(Y,Q),Q}},Aw=async(Y,Z,Q,{signal:J})=>{for await(let[z]of _w(Y,"unpipe",{signal:J}))if(Z.has(z))z.emit(Q)},YQ=(Y)=>{if(typeof Y?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Y}\`.`)},xw=async({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,onFinished:X,unpipeEvent:H})=>{g7(Y,K$);let W=new AbortController;try{await Promise.race([Ew(X,Z,W),Pw({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,controller:W}),Sw({stream:Z,streams:Q,ended:J,aborted:z,unpipeEvent:H,controller:W})])}finally{W.abort(),g7(Y,-K$)}if(Q.size>0&&Q.size===J.size+z.size)if(J.size===0&&z.size>0)ZQ(Y);else vw(Y)},Ew=async(Y,Z,{signal:Q})=>{try{if(await Y,!Q.aborted)ZQ(Z)}catch(J){if(!Q.aborted)q$(Z,J)}},Pw=async({passThroughStream:Y,stream:Z,streams:Q,ended:J,aborted:z,controller:{signal:X}})=>{try{if(await G$(Z,{signal:X,cleanup:!0,readable:!0,writable:!1}),Q.has(Z))J.add(Z)}catch(H){if(X.aborted||!Q.has(Z))return;if(U$(H))z.add(Z);else B$(Y,H)}},Sw=async({stream:Y,streams:Z,ended:Q,aborted:J,unpipeEvent:z,controller:{signal:X}})=>{if(await H$(Y,z,{signal:X}),!Y.readable)return H$(X,"abort",{signal:X});Z.delete(Y),Q.delete(Y),J.delete(Y)},vw=(Y)=>{if(Y.writable)Y.end()},q$=(Y,Z)=>{if(U$(Z))ZQ(Y);else B$(Y,Z)},U$=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",ZQ=(Y)=>{if(Y.readable||Y.writable)Y.destroy()},B$=(Y,Z)=>{if(!Y.destroyed)Y.once("error",yw),Y.destroy(Z)},yw=()=>{},g7=(Y,Z)=>{let Q=Y.getMaxListeners();if(Q!==0&&Q!==Number.POSITIVE_INFINITY)Y.setMaxListeners(Q+Z)},W$=2,K$=1;var m7=R(()=>{$$=class $$ extends Iw{#Z=new Set([]);#Q=new Set([]);#Y=new Set([]);#J;#z=Symbol("unpipe");#X=new WeakMap;add(Y){if(YQ(Y),this.#Z.has(Y))return;this.#Z.add(Y),this.#J??=Cw(this,this.#Z,this.#z);let Z=xw({passThroughStream:this,stream:Y,streams:this.#Z,ended:this.#Q,aborted:this.#Y,onFinished:this.#J,unpipeEvent:this.#z});this.#X.set(Y,Z),Y.pipe(this,{end:!1})}async remove(Y){if(YQ(Y),!this.#Z.has(Y))return!1;let Z=this.#X.get(Y);if(Z===void 0)return!1;return this.#X.delete(Y),Y.unpipe(this),await Z,!0}}});import{finished as V$}from"node:stream/promises";var n1=(Y,Z)=>{Y.pipe(Z),fw(Y,Z),bw(Y,Z)},fw=async(Y,Z)=>{if(UY(Y)||UY(Z))return;try{await V$(Y,{cleanup:!0,readable:!0,writable:!1})}catch{}QQ(Z)},QQ=(Y)=>{if(Y.writable)Y.end()},bw=async(Y,Z)=>{if(UY(Y)||UY(Z))return;try{await V$(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}JQ(Y)},JQ=(Y)=>{if(Y.readable)Y.destroy()};var u7=R(()=>{uY()});var F$=(Y,Z,Q)=>{let J=new Map;for(let[z,{stdioItems:X,direction:H}]of Object.entries(Z)){for(let{stream:W}of X.filter(({type:K})=>XY.has(K)))hw(Y,W,H,z);for(let{stream:W}of X.filter(({type:K})=>!XY.has(K)))mw({subprocess:Y,stream:W,direction:H,fdNumber:z,pipeGroups:J,controller:Q})}for(let[z,X]of J.entries()){let H=X.length===1?X[0]:t6(X);n1(H,z)}},hw=(Y,Z,Q,J)=>{if(Q==="output")n1(Y.stdio[J],Z);else n1(Z,Y.stdio[J]);let z=gw[J];if(z!==void 0)Y[z]=Z;Y.stdio[J]=Z},gw,mw=({subprocess:Y,stream:Z,direction:Q,fdNumber:J,pipeGroups:z,controller:X})=>{if(Z===void 0)return;uw(Z,X);let[H,W]=Q==="output"?[Z,Y.stdio[J]]:[Y.stdio[J],Z],K=z.get(H)??[];z.set(H,[...K,W])},uw=(Y,{signal:Z})=>{if(UY(Y))i6(Y,dw,Z)},dw=2;var R$=R(()=>{m7();uY();tZ();h0();u7();gw=["stdin","stdout","stderr"]});var e6;var M$=R(()=>{e6=[];e6.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")e6.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")e6.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT")});class O${emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(XQ[zQ])return XQ[zQ];pw(XQ,zQ,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Y,Z){this.listeners[Y].push(Z)}removeListener(Y,Z){let Q=this.listeners[Y],J=Q.indexOf(Z);if(J===-1)return;if(J===0&&Q.length===1)Q.length=0;else Q.splice(J,1)}emit(Y,Z,Q){if(this.emitted[Y])return!1;this.emitted[Y]=!0;let J=!1;for(let z of this.listeners[Y])J=z(Z,Q)===!0||J;if(Y==="exit")J=this.emit("afterExit",Z,Q)||J;return J}}class WQ{}var d7=(Y)=>!!Y&&typeof Y==="object"&&typeof Y.removeListener==="function"&&typeof Y.emit==="function"&&typeof Y.reallyExit==="function"&&typeof Y.listeners==="function"&&typeof Y.kill==="function"&&typeof Y.pid==="number"&&typeof Y.on==="function",zQ,XQ,pw,cw=(Y)=>{return{onExit(Z,Q){return Y.onExit(Z,Q)},load(){return Y.load()},unload(){return Y.unload()}}},D$,N$,HQ,w$,_f,If;var L$=R(()=>{M$();zQ=Symbol.for("signal-exit emitter"),XQ=globalThis,pw=Object.defineProperty.bind(Object);D$=class D$ extends WQ{onExit(){return()=>{}}load(){}unload(){}};N$=class N$ extends WQ{#Z=HQ.platform==="win32"?"SIGINT":"SIGHUP";#Q=new O$;#Y;#J;#z;#X={};#H=!1;constructor(Y){super();this.#Y=Y,this.#X={};for(let Z of e6)this.#X[Z]=()=>{let Q=this.#Y.listeners(Z),{count:J}=this.#Q,z=Y;if(typeof z.__signal_exit_emitter__==="object"&&typeof z.__signal_exit_emitter__.count==="number")J+=z.__signal_exit_emitter__.count;if(Q.length===J){this.unload();let X=this.#Q.emit("exit",null,Z),H=Z==="SIGHUP"?this.#Z:Z;if(!X)Y.kill(Y.pid,H)}};this.#z=Y.reallyExit,this.#J=Y.emit}onExit(Y,Z){if(!d7(this.#Y))return()=>{};if(this.#H===!1)this.load();let Q=Z?.alwaysLast?"afterExit":"exit";return this.#Q.on(Q,Y),()=>{if(this.#Q.removeListener(Q,Y),this.#Q.listeners.exit.length===0&&this.#Q.listeners.afterExit.length===0)this.unload()}}load(){if(this.#H)return;this.#H=!0,this.#Q.count+=1;for(let Y of e6)try{let Z=this.#X[Y];if(Z)this.#Y.on(Y,Z)}catch(Z){}this.#Y.emit=(Y,...Z)=>{return this.#K(Y,...Z)},this.#Y.reallyExit=(Y)=>{return this.#W(Y)}}unload(){if(!this.#H)return;this.#H=!1,e6.forEach((Y)=>{let Z=this.#X[Y];if(!Z)throw Error("Listener not defined for signal: "+Y);try{this.#Y.removeListener(Y,Z)}catch(Q){}}),this.#Y.emit=this.#J,this.#Y.reallyExit=this.#z,this.#Q.count-=1}#W(Y){if(!d7(this.#Y))return 0;return this.#Y.exitCode=Y||0,this.#Q.emit("exit",this.#Y.exitCode,null),this.#z.call(this.#Y,this.#Y.exitCode)}#K(Y,...Z){let Q=this.#J;if(Y==="exit"&&d7(this.#Y)){if(typeof Z[0]==="number")this.#Y.exitCode=Z[0];let J=Q.call(this.#Y,Y,...Z);return this.#Q.emit("exit",this.#Y.exitCode,null),J}else return Q.call(this.#Y,Y,...Z)}};HQ=globalThis.process,{onExit:w$,load:_f,unload:If}=cw(d7(HQ)?new N$(HQ):new D$)});import{addAbortListener as lw}from"node:events";var _$=(Y,{cleanup:Z,detached:Q},{signal:J})=>{if(!Z||Q)return;let z=w$(()=>{Y.kill()});lw(J,()=>{z()})};var I$=R(()=>{L$()});var T$=({source:Y,sourcePromise:Z,boundOptions:Q,createNested:J},...z)=>{let X=hZ(),{destination:H,destinationStream:W,destinationError:K,from:$,unpipeSignal:G}=iw(Q,J,z),{sourceStream:U,sourceError:B}=aw(Y,$),{options:F,fileDescriptors:V}=LY.get(Y);return{sourcePromise:Z,sourceStream:U,sourceOptions:F,sourceError:B,destination:H,destinationStream:W,destinationError:K,unpipeSignal:G,fileDescriptors:V,startTime:X}},iw=(Y,Z,Q)=>{try{let{destination:J,pipeOptions:{from:z,to:X,unpipeSignal:H}={}}=nw(Y,Z,...Q),W=rZ(J,X);return{destination:J,destinationStream:W,from:z,unpipeSignal:H}}catch(J){return{destinationError:J}}},nw=(Y,Z,Q,...J)=>{if(Array.isArray(Q))return{destination:Z(j$,Y)(Q,...J),pipeOptions:Y};if(typeof Q==="string"||Q instanceof URL||v5(Q)){if(Object.keys(Y).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[z,X,H]=CZ(Q,...J);return{destination:Z(j$)(z,X,H),pipeOptions:H}}if(LY.has(Q)){if(Object.keys(Y).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:Q,pipeOptions:J[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${Q}`)},j$=({options:Y})=>({options:{...Y,stdin:"pipe",piped:!0}}),aw=(Y,Z)=>{try{return{sourceStream:u1(Y,Z)}}catch(Q){return{sourceError:Q}}};var C$=R(()=>{f5();gZ();$6();P1()});var A$=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J,fileDescriptors:z,sourceOptions:X,startTime:H})=>{let W=ow({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J});if(W!==void 0)throw KQ({error:W,fileDescriptors:z,sourceOptions:X,startTime:H})},ow=({sourceStream:Y,sourceError:Z,destinationStream:Q,destinationError:J})=>{if(Z!==void 0&&J!==void 0)return J;if(J!==void 0)return JQ(Y),J;if(Z!==void 0)return QQ(Q),Z},KQ=({error:Y,fileDescriptors:Z,sourceOptions:Q,startTime:J})=>c1({error:Y,command:k$,escapedCommand:k$,fileDescriptors:Z,options:Q,startTime:J,isSync:!1}),k$="source.pipe(destination)";var GQ=R(()=>{l8();u7()});var x$=async(Y)=>{let[{status:Z,reason:Q,value:J=Q},{status:z,reason:X,value:H=X}]=await Y;if(!H.pipedFrom.includes(J))H.pipedFrom.push(J);if(z==="rejected")throw H;if(Z==="rejected")throw J;return H};import{finished as sw}from"node:stream/promises";var E$=(Y,Z,Q)=>{let J=p7.has(Z)?tw(Y,Z):rw(Y,Z);return i6(Y,YL,Q.signal),i6(Z,ZL,Q.signal),ew(Z),J},rw=(Y,Z)=>{let Q=t6([Y]);return n1(Q,Z),p7.set(Z,Q),Q},tw=(Y,Z)=>{let Q=p7.get(Z);return Q.add(Y),Q},ew=async(Y)=>{try{await sw(Y,{cleanup:!0,readable:!1,writable:!0})}catch{}p7.delete(Y)},p7,YL=2,ZL=1;var P$=R(()=>{m7();tZ();u7();p7=new WeakMap});import{aborted as QL}from"node:util";var S$=(Y,Z)=>Y===void 0?[]:[JL(Y,Z)],JL=async(Y,{sourceStream:Z,mergedStream:Q,fileDescriptors:J,sourceOptions:z,startTime:X})=>{await QL(Y,Z),await Q.remove(Z);let H=Error("Pipe canceled by `unpipeSignal` option.");throw KQ({error:H,fileDescriptors:J,sourceOptions:z,startTime:X})};var v$=R(()=>{GQ()});var c7=(Y,...Z)=>{if(F0(Z[0]))return c7.bind(void 0,{...Y,boundOptions:{...Y.boundOptions,...Z[0]}});let{destination:Q,...J}=T$(Y,...Z),z=zL({...J,destination:Q});return z.pipe=c7.bind(void 0,{...Y,source:Q,sourcePromise:z,boundOptions:{}}),z},zL=async({sourcePromise:Y,sourceStream:Z,sourceOptions:Q,sourceError:J,destination:z,destinationStream:X,destinationError:H,unpipeSignal:W,fileDescriptors:K,startTime:$})=>{let G=XL(Y,z);A$({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:H,fileDescriptors:K,sourceOptions:Q,startTime:$});let U=new AbortController;try{let B=E$(Z,X,U);return await Promise.race([x$(G),...S$(W,{sourceStream:Z,mergedStream:B,sourceOptions:Q,fileDescriptors:K,startTime:$})])}finally{U.abort()}},XL=(Y,Z)=>Promise.allSettled([Y,Z]);var y$=R(()=>{C$();GQ();P$();v$()});import{on as HL}from"node:events";import{getDefaultHighWaterMark as WL}from"node:stream";var l7=({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:J,encoding:z,preserveNewlines:X})=>{let H=new AbortController;return KL(Z,H),b$({stream:Y,controller:H,binary:Q,shouldEncode:!Y.readableObjectMode&&J,encoding:z,shouldSplit:!Y.readableObjectMode,preserveNewlines:X})},KL=async(Y,Z)=>{try{await Y}catch{}finally{Z.abort()}},$Q=({stream:Y,onStreamEnd:Z,lines:Q,encoding:J,stripFinalNewline:z,allMixed:X})=>{let H=new AbortController;GL(Z,H,Y);let W=Y.readableObjectMode&&!X;return b$({stream:Y,controller:H,binary:J==="buffer",shouldEncode:!W,encoding:J,shouldSplit:!W&&Q,preserveNewlines:!z})},GL=async(Y,Z,Q)=>{try{await Y}catch{Q.destroy()}finally{Z.abort()}},b$=({stream:Y,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H})=>{let W=HL(Y,"data",{signal:Z.signal,highWaterMark:f$,highWatermark:f$});return $L({onStdoutChunk:W,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H})},qQ,f$,$L=async function*({onStdoutChunk:Y,controller:Z,binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H}){let W=qL({binary:Q,shouldEncode:J,encoding:z,shouldSplit:X,preserveNewlines:H});try{for await(let[K]of Y)yield*r6(K,W,0)}catch(K){if(!Z.signal.aborted)throw K}finally{yield*n8(W)}},qL=({binary:Y,shouldEncode:Z,encoding:Q,shouldSplit:J,preserveNewlines:z})=>[S7(Y,Q,!Z),E7(Y,z,!J,{})].filter(Boolean);var i7=R(()=>{d3();P7();qQ=WL(!0),f$=qQ});import{setImmediate as UL}from"node:timers/promises";var h$=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,buffer:z,maxBuffer:X,lines:H,allMixed:W,stripFinalNewline:K,verboseInfo:$,streamInfo:G})=>{let U=BL({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,allMixed:W,verboseInfo:$,streamInfo:G});if(!z){await Promise.all([VL(Y),U]);return}let B=g3(K,Q),F=$Q({stream:Y,onStreamEnd:Z,lines:H,encoding:J,stripFinalNewline:B,allMixed:W}),[V]=await Promise.all([FL({stream:Y,iterable:F,fdNumber:Q,encoding:J,maxBuffer:X,lines:H}),U]);return V},BL=async({stream:Y,onStreamEnd:Z,fdNumber:Q,encoding:J,allMixed:z,verboseInfo:X,streamInfo:{fileDescriptors:H}})=>{if(!b7({stdioItems:H[Q]?.stdioItems,encoding:J,verboseInfo:X,fdNumber:Q}))return;let W=$Q({stream:Y,onStreamEnd:Z,lines:!0,encoding:J,stripFinalNewline:!0,allMixed:z});await xG(W,Y,Q,X)},VL=async(Y)=>{if(await UL(),Y.readableFlowing===null)Y.resume()},FL=async({stream:Y,stream:{readableObjectMode:Z},iterable:Q,fdNumber:J,encoding:z,maxBuffer:X,lines:H})=>{try{if(Z||H)return await O7(Q,{maxBuffer:X});if(z==="buffer")return new Uint8Array(await D7(Q,{maxBuffer:X}));return await w7(Q,{maxBuffer:X})}catch(W){return g$(RK({error:W,stream:Y,readableObjectMode:Z,lines:H,encoding:z,fdNumber:J}))}},UQ=async(Y)=>{try{return await Y}catch(Z){return g$(Z)}},g$=({bufferedData:Y})=>qX(Y)?new Uint8Array(Y):Y;var BQ=R(()=>{L7();i0();i3();i7();o6();i8()});import{finished as RL}from"node:stream/promises";var r8=async(Y,Z,Q,{isSameDirection:J,stopOnExit:z=!1}={})=>{let X=ML(Y,Q),H=new AbortController;try{await Promise.race([...z?[Q.exitPromise]:[],RL(Y,{cleanup:!0,signal:H.signal})])}catch(W){if(!X.stdinCleanedUp)NL(W,Z,Q,J)}finally{H.abort()}},ML=(Y,{originalStreams:[Z],subprocess:Q})=>{let J={stdinCleanedUp:!1};if(Y===Z)OL(Y,Q,J);return J},OL=(Y,Z,Q)=>{let{_destroy:J}=Y;Y._destroy=(...z)=>{DL(Z,Q),J.call(Y,...z)}},DL=({exitCode:Y,signalCode:Z},Q)=>{if(Y!==null||Z!==null)Q.stdinCleanedUp=!0},NL=(Y,Z,Q,J)=>{if(!wL(Y,Z,Q,J))throw Y},wL=(Y,Z,Q,J=!0)=>{if(Q.propagating)return m$(Y)||n7(Y);return Q.propagating=!0,VQ(Q,Z)===J?m$(Y):n7(Y)},VQ=({fileDescriptors:Y},Z)=>Z!=="all"&&Y[Z].direction==="input",n7=(Y)=>Y?.code==="ERR_STREAM_PREMATURE_CLOSE",m$=(Y)=>Y?.code==="EPIPE";var a7=()=>{};var u$=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:X,verboseInfo:H,streamInfo:W})=>Y.stdio.map((K,$)=>FQ({stream:K,fdNumber:$,encoding:Z,buffer:Q[$],maxBuffer:J[$],lines:z[$],allMixed:!1,stripFinalNewline:X,verboseInfo:H,streamInfo:W})),FQ=async({stream:Y,fdNumber:Z,encoding:Q,buffer:J,maxBuffer:z,lines:X,allMixed:H,stripFinalNewline:W,verboseInfo:K,streamInfo:$})=>{if(!Y)return;let G=r8(Y,Z,$);if(VQ($,Z)){await G;return}let[U]=await Promise.all([h$({stream:Y,onStreamEnd:G,fdNumber:Z,encoding:Q,buffer:J,maxBuffer:z,lines:X,allMixed:H,stripFinalNewline:W,verboseInfo:K,streamInfo:$}),G]);return U};var RQ=R(()=>{BQ();a7()});var d$=({stdout:Y,stderr:Z},{all:Q})=>Q&&(Y||Z)?t6([Y,Z].filter(Boolean)):void 0,p$=({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:X,verboseInfo:H,streamInfo:W})=>FQ({...LL(Y,Q),fdNumber:"all",encoding:Z,maxBuffer:J[1]+J[2],lines:z[1]||z[2],allMixed:_L(Y),stripFinalNewline:X,verboseInfo:H,streamInfo:W}),LL=({stdout:Y,stderr:Z,all:Q},[,J,z])=>{let X=J||z;if(!X)return{stream:Q,buffer:X};if(!J)return{stream:Z,buffer:X};if(!z)return{stream:Y,buffer:X};return{stream:Q,buffer:X}},_L=({all:Y,stdout:Z,stderr:Q})=>Y&&Z&&Q&&Z.readableObjectMode!==Q.readableObjectMode;var MQ=R(()=>{m7();RQ()});var c$=(Y)=>v1(Y,"ipc"),l$=(Y,Z)=>{let Q=bZ(Y);DY({type:"ipc",verboseMessage:Q,fdNumber:"ipc",verboseInfo:Z})};var i$=R(()=>{y1();W6()});var n$=async({subprocess:Y,buffer:Z,maxBuffer:Q,ipc:J,ipcOutput:z,verboseInfo:X})=>{if(!J)return z;let H=c$(X),W=dY(Z,"ipc"),K=dY(Q,"ipc");for await(let $ of r3({anyProcess:Y,channel:Y.channel,isSubprocess:!1,ipc:J,shouldAwait:!1,reference:!0})){if(W)MK(Y,z,K),z.push($);if(H)l$($,X)}return z},a$=async(Y,Z)=>{return await Promise.allSettled([Y]),Z};var o$=R(()=>{o6();i$();pY();t3()});import{once as IL}from"node:events";var s$=async({subprocess:Y,options:{encoding:Z,buffer:Q,maxBuffer:J,lines:z,timeoutDuration:X,cancelSignal:H,gracefulCancel:W,forceKillAfterDelay:K,stripFinalNewline:$,ipc:G,ipcInput:U},context:B,verboseInfo:F,fileDescriptors:V,originalStreams:O,onInternalError:N,controller:w})=>{let L=bG(Y,B),I={originalStreams:O,fileDescriptors:V,subprocess:Y,exitPromise:L,propagating:!1},T=u$({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:$,verboseInfo:F,streamInfo:I}),y=p$({subprocess:Y,encoding:Z,buffer:Q,maxBuffer:J,lines:z,stripFinalNewline:$,verboseInfo:F,streamInfo:I}),E=[],P=n$({subprocess:Y,buffer:Q,maxBuffer:J,ipc:G,ipcOutput:E,verboseInfo:F}),m=jL(O,Y,I),g=TL(V,I);try{return await Promise.race([Promise.all([{},gG(L),Promise.all(T),y,P,uW(Y,U),...m,...g]),N,CL(Y,w),...fW(Y,X,B,w),...QW({subprocess:Y,cancelSignal:H,gracefulCancel:W,context:B,controller:w}),...vW({subprocess:Y,cancelSignal:H,gracefulCancel:W,forceKillAfterDelay:K,context:B,controller:w})])}catch(b){return B.terminationReason??="other",Promise.all([{error:b},L,Promise.all(T.map((c)=>UQ(c))),UQ(y),a$(P,E),Promise.allSettled(m),Promise.allSettled(g)])}},jL=(Y,Z,Q)=>Y.map((J,z)=>J===Z.stdio[z]?void 0:r8(J,z,Q)),TL=(Y,Z)=>Y.flatMap(({stdioItems:Q},J)=>Q.filter(({value:z,stream:X=z})=>VY(X,{checkOpen:!1})&&!UY(X)).map(({type:z,value:X,stream:H=X})=>r8(H,J,Z,{isSameDirection:XY.has(z),stopOnExit:z==="native"}))),CL=async(Y,{signal:Z})=>{let[Q]=await IL(Y,"error",{signal:Z});throw Q};var r$=R(()=>{R3();W3();F3();uY();h0();BQ();o$();O3();MQ();RQ();o3();a7()});var t$=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),t8=(Y,Z,Q)=>{let J=Y[Q];if(!J.has(Z))J.set(Z,[]);let z=J.get(Z),X=wY();return z.push(X),{resolve:X.resolve.bind(X),promises:z}},a1=async({resolve:Y,promises:Z},Q)=>{Y();let[J]=await Promise.race([Promise.allSettled([!0,Q]),Promise.all([!1,...Z])]);return!J};var o7=()=>{};import{finished as e$}from"node:stream/promises";var OQ=async(Y)=>{if(Y===void 0)return;try{await DQ(Y)}catch{}},Yq=async(Y)=>{if(Y===void 0)return;try{await NQ(Y)}catch{}},DQ=async(Y)=>{await e$(Y,{cleanup:!0,readable:!1,writable:!0})},NQ=async(Y)=>{await e$(Y,{cleanup:!0,readable:!0,writable:!1})},s7=async(Y,Z)=>{if(await Y,Z)throw Z},r7=(Y,Z,Q)=>{if(Q&&!n7(Q))Y.destroy(Q);else if(Z)Y.destroy()};var wQ=R(()=>{a7()});import{Readable as kL}from"node:stream";import{callbackify as AL}from"node:util";var Zq=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:J,binary:z=!0,preserveNewlines:X=!0}={})=>{let H=z||a0.has(Q),{subprocessStdout:W,waitReadableDestroy:K}=LQ(Y,J,Z),{readableEncoding:$,readableObjectMode:G,readableHighWaterMark:U}=_Q(W,H),{read:B,onStdoutDataDone:F}=IQ({subprocessStdout:W,subprocess:Y,binary:H,encoding:Q,preserveNewlines:X}),V=new kL({read:B,destroy:AL(TQ.bind(void 0,{subprocessStdout:W,subprocess:Y,waitReadableDestroy:K})),highWaterMark:U,objectMode:G,encoding:$});return jQ({subprocessStdout:W,onStdoutDataDone:F,readable:V,subprocess:Y}),V},LQ=(Y,Z,Q)=>{let J=u1(Y,Z),z=t8(Q,J,"readableDestroy");return{subprocessStdout:J,waitReadableDestroy:z}},_Q=({readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q},J)=>J?{readableEncoding:Y,readableObjectMode:Z,readableHighWaterMark:Q}:{readableEncoding:Y,readableObjectMode:!0,readableHighWaterMark:qQ},IQ=({subprocessStdout:Y,subprocess:Z,binary:Q,encoding:J,preserveNewlines:z})=>{let X=wY(),H=l7({subprocessStdout:Y,subprocess:Z,binary:Q,shouldEncode:!Q,encoding:J,preserveNewlines:z});return{read(){xL(this,H,X)},onStdoutDataDone:X}},xL=async(Y,Z,Q)=>{try{let{value:J,done:z}=await Z.next();if(z)Q.resolve();else Y.push(J)}catch{}},jQ=async({subprocessStdout:Y,onStdoutDataDone:Z,readable:Q,subprocess:J,subprocessStdin:z})=>{try{if(await NQ(Y),await J,await OQ(z),await Z,Q.readable)Q.push(null)}catch(X){await OQ(z),Qq(Q,X)}},TQ=async({subprocessStdout:Y,subprocess:Z,waitReadableDestroy:Q},J)=>{if(await a1(Q,Z))Qq(Y,J),await s7(Z,J)},Qq=(Y,Z)=>{r7(Y,Y.readable,Z)};var CQ=R(()=>{n6();$6();i7();o7();wQ()});import{Writable as EL}from"node:stream";import{callbackify as Jq}from"node:util";var zq=({subprocess:Y,concurrentStreams:Z},{to:Q}={})=>{let{subprocessStdin:J,waitWritableFinal:z,waitWritableDestroy:X}=kQ(Y,Q,Z),H=new EL({...AQ(J,Y,z),destroy:Jq(EQ.bind(void 0,{subprocessStdin:J,subprocess:Y,waitWritableFinal:z,waitWritableDestroy:X})),highWaterMark:J.writableHighWaterMark,objectMode:J.writableObjectMode});return xQ(J,H),H},kQ=(Y,Z,Q)=>{let J=rZ(Y,Z),z=t8(Q,J,"writableFinal"),X=t8(Q,J,"writableDestroy");return{subprocessStdin:J,waitWritableFinal:z,waitWritableDestroy:X}},AQ=(Y,Z,Q)=>({write:PL.bind(void 0,Y),final:Jq(SL.bind(void 0,Y,Z,Q))}),PL=(Y,Z,Q,J)=>{if(Y.write(Z,Q))J();else Y.once("drain",J)},SL=async(Y,Z,Q)=>{if(await a1(Q,Z)){if(Y.writable)Y.end();await Z}},xQ=async(Y,Z,Q)=>{try{if(await DQ(Y),Z.writable)Z.end()}catch(J){await Yq(Q),Xq(Z,J)}},EQ=async({subprocessStdin:Y,subprocess:Z,waitWritableFinal:Q,waitWritableDestroy:J},z)=>{if(await a1(Q,Z),await a1(J,Z))Xq(Y,z),await s7(Z,z)},Xq=(Y,Z)=>{r7(Y,Y.writable,Z)};var PQ=R(()=>{$6();o7();wQ()});import{Duplex as vL}from"node:stream";import{callbackify as yL}from"node:util";var Hq=({subprocess:Y,concurrentStreams:Z,encoding:Q},{from:J,to:z,binary:X=!0,preserveNewlines:H=!0}={})=>{let W=X||a0.has(Q),{subprocessStdout:K,waitReadableDestroy:$}=LQ(Y,J,Z),{subprocessStdin:G,waitWritableFinal:U,waitWritableDestroy:B}=kQ(Y,z,Z),{readableEncoding:F,readableObjectMode:V,readableHighWaterMark:O}=_Q(K,W),{read:N,onStdoutDataDone:w}=IQ({subprocessStdout:K,subprocess:Y,binary:W,encoding:Q,preserveNewlines:H}),L=new vL({read:N,...AQ(G,Y,U),destroy:yL(fL.bind(void 0,{subprocessStdout:K,subprocessStdin:G,subprocess:Y,waitReadableDestroy:$,waitWritableFinal:U,waitWritableDestroy:B})),readableHighWaterMark:O,writableHighWaterMark:G.writableHighWaterMark,readableObjectMode:V,writableObjectMode:G.writableObjectMode,encoding:F});return jQ({subprocessStdout:K,onStdoutDataDone:w,readable:L,subprocess:Y,subprocessStdin:G}),xQ(G,L,K),L},fL=async({subprocessStdout:Y,subprocessStdin:Z,subprocess:Q,waitReadableDestroy:J,waitWritableFinal:z,waitWritableDestroy:X},H)=>{await Promise.all([TQ({subprocessStdout:Y,subprocess:Q,waitReadableDestroy:J},H),EQ({subprocessStdin:Z,subprocess:Q,waitWritableFinal:z,waitWritableDestroy:X},H)])};var Wq=R(()=>{n6();CQ();PQ()});var SQ=(Y,Z,{from:Q,binary:J=!1,preserveNewlines:z=!1}={})=>{let X=J||a0.has(Z),H=u1(Y,Q),W=l7({subprocessStdout:H,subprocess:Y,binary:X,shouldEncode:!0,encoding:Z,preserveNewlines:z});return bL(W,H,Y)},bL=async function*(Y,Z,Q){try{yield*Y}finally{if(Z.readable)Z.destroy();await Q}};var Kq=R(()=>{n6();$6();i7()});var Gq=(Y,{encoding:Z})=>{let Q=t$();Y.readable=Zq.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.writable=zq.bind(void 0,{subprocess:Y,concurrentStreams:Q}),Y.duplex=Hq.bind(void 0,{subprocess:Y,concurrentStreams:Q,encoding:Z}),Y.iterable=SQ.bind(void 0,Y,Z),Y[Symbol.asyncIterator]=SQ.bind(void 0,Y,Z,{})};var $q=R(()=>{o7();CQ();PQ();Wq();Kq()});var qq=(Y,Z)=>{for(let[Q,J]of gL){let z=J.value.bind(Z);Reflect.defineProperty(Y,Q,{...J,value:z})}},hL,gL;var Uq=R(()=>{hL=(async()=>{})().constructor.prototype,gL=["then","catch","finally"].map((Y)=>[Y,Reflect.getOwnPropertyDescriptor(hL,Y)])});import{setMaxListeners as mL}from"node:events";import{spawn as uL}from"node:child_process";var Bq=(Y,Z,Q,J)=>{let{file:z,commandArguments:X,command:H,escapedCommand:W,startTime:K,verboseInfo:$,options:G,fileDescriptors:U}=dL(Y,Z,Q),{subprocess:B,promise:F}=cL({file:z,commandArguments:X,options:G,startTime:K,verboseInfo:$,command:H,escapedCommand:W,fileDescriptors:U});return B.pipe=c7.bind(void 0,{source:B,sourcePromise:F,boundOptions:{},createNested:J}),qq(B,F),LY.set(B,{options:G,fileDescriptors:U}),B},dL=(Y,Z,Q)=>{let{command:J,escapedCommand:z,startTime:X,verboseInfo:H}=mZ(Y,Z,Q),{file:W,commandArguments:K,options:$}=B7(Y,Z,Q),G=pL($),U=z$(G,H);return{file:W,commandArguments:K,command:J,escapedCommand:z,startTime:X,verboseInfo:H,options:G,fileDescriptors:U}},pL=({timeout:Y,signal:Z,...Q})=>{if(Z!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...Q,timeoutDuration:Y}},cL=({file:Y,commandArguments:Z,options:Q,startTime:J,verboseInfo:z,command:X,escapedCommand:H,fileDescriptors:W})=>{let K;try{K=uL(...V7(Y,Z,Q))}catch(V){return eG({error:V,command:X,escapedCommand:H,fileDescriptors:W,options:Q,startTime:J,verboseInfo:z})}let $=new AbortController;mL(Number.POSITIVE_INFINITY,$.signal);let G=[...K.stdio];F$(K,W,$),_$(K,Q,$);let U={},B=wY();K.kill=YW.bind(void 0,{kill:K.kill.bind(K),options:Q,onInternalError:B,context:U,controller:$}),K.all=d$(K,Q),Gq(K,Q),sG(K,Q);let F=lL({subprocess:K,options:Q,startTime:J,verboseInfo:z,fileDescriptors:W,originalStreams:G,command:X,escapedCommand:H,context:U,onInternalError:B,controller:$});return{subprocess:K,promise:F}},lL=async({subprocess:Y,options:Z,startTime:Q,verboseInfo:J,fileDescriptors:z,originalStreams:X,command:H,escapedCommand:W,context:K,onInternalError:$,controller:G})=>{let[U,[B,F],V,O,N]=await s$({subprocess:Y,options:Z,context:K,verboseInfo:J,fileDescriptors:z,originalStreams:X,onInternalError:$,controller:G});G.abort(),$.resolve();let w=V.map((T,y)=>iY(T,Z,y)),L=iY(O,Z,"all"),I=iL({errorInfo:U,exitCode:B,signal:F,stdio:w,all:L,ipcOutput:N,context:K,options:Z,command:H,escapedCommand:W,startTime:Q});return l1(I,J,Z)},iL=({errorInfo:Y,exitCode:Z,signal:Q,stdio:J,all:z,ipcOutput:X,context:H,options:W,command:K,escapedCommand:$,startTime:G})=>("error"in Y)?c8({error:Y.error,command:K,escapedCommand:$,timedOut:H.terminationReason==="timeout",isCanceled:H.terminationReason==="cancel"||H.terminationReason==="gracefulCancel",isGracefullyCanceled:H.terminationReason==="gracefulCancel",isMaxBuffer:Y.error instanceof cY,isForcefullyTerminated:H.isForcefullyTerminated,exitCode:Z,signal:Q,stdio:J,all:z,ipcOutput:X,options:W,startTime:G,isSync:!1}):I7({command:K,escapedCommand:$,stdio:J,all:z,ipcOutput:X,options:W,startTime:G});var Vq=R(()=>{L7();i5();w3();$6();e3();l8();j7();Y$();X$();i8();R$();nZ();I$();y$();MQ();r$();$q();Uq()});var t7=(Y,Z)=>{let Q=Object.fromEntries(Object.entries(Z).map(([J,z])=>[J,nL(J,Y[J],z)]));return{...Y,...Q}},nL=(Y,Z,Q)=>{if(aL.has(Y)&&F0(Z)&&F0(Q))return{...Z,...Q};return Q},aL;var Fq=R(()=>{pY();aL=new Set(["env",...u5])});var B6=(Y,Z,Q,J)=>{let z=(H,W,K)=>B6(H,W,Q,K),X=(...H)=>oL({mapArguments:Y,deepOptions:Q,boundOptions:Z,setBoundExeca:J,createNested:z},...H);if(J!==void 0)J(X,z,Z);return X},oL=({mapArguments:Y,deepOptions:Z={},boundOptions:Q={},setBoundExeca:J,createNested:z},X,...H)=>{if(F0(X))return z(Y,t7(Q,X),J);let{file:W,commandArguments:K,options:$,isSync:G}=sL({mapArguments:Y,firstArgument:X,nextArguments:H,deepOptions:Z,boundOptions:Q});return G?dG(W,K,$):Bq(W,K,$,z)},sL=({mapArguments:Y,firstArgument:Z,nextArguments:Q,deepOptions:J,boundOptions:z})=>{let X=MX(Z)?OX(Z,Q):[Z,...Q],[H,W,K]=CZ(...X),$=t7(t7(J,z),K),{file:G=H,commandArguments:U=W,options:B=$,isSync:F=!1}=Y({file:H,commandArguments:W,options:$});return{file:G,commandArguments:U,options:B,isSync:F}};var Rq=R(()=>{f5();DX();pG();Vq();Fq()});var Mq=({file:Y,commandArguments:Z})=>Dq(Y,Z),Oq=({file:Y,commandArguments:Z})=>({...Dq(Y,Z),isSync:!0}),Dq=(Y,Z)=>{if(Z.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Y} ${Z}.`);let[Q,...J]=rL(Y);return{file:Q,commandArguments:J}},rL=(Y)=>{if(typeof Y!=="string")throw TypeError(`The command must be a string: ${String(Y)}.`);let Z=Y.trim();if(Z==="")return[];let Q=[];for(let J of Z.split(tL)){let z=Q.at(-1);if(z&&z.endsWith("\\"))Q[Q.length-1]=`${z.slice(0,-1)} ${J}`;else Q.push(J)}return Q},tL;var Nq=R(()=>{tL=/ +/g});var wq=(Y,Z,Q)=>{Y.sync=Z(eL,Q),Y.s=Y.sync},Lq=({options:Y})=>_q(Y),eL=({options:Y})=>({..._q(Y),isSync:!0}),_q=(Y)=>({options:{...Y_(Y),...Y}}),Y_=({input:Y,inputFile:Z,stdio:Q})=>Y===void 0&&Z===void 0&&Q===void 0?{stdin:"inherit"}:{},Iq;var jq=R(()=>{Iq={preferLocal:!0}});var IY,Vg,Fg,Rg,Mg,Og,Dg,Ng,wg,Lg;var e8=R(()=>{Rq();Nq();M3();jq();e3();K6();IY=B6(()=>({})),Vg=B6(()=>({isSync:!0})),Fg=B6(Mq),Rg=B6(Oq),Mg=B6(hW),Og=B6(Lq,{},Iq,wq),{sendMessage:Dg,getOneMessage:Ng,getEachMessage:wg,getCancelSignal:Lg}=rG()});function Z_(Y,Z){let Q=Y.slice(0,Z).split(/\r\n|\n|\r/g);return[Q.length,Q.pop().length+1]}function Q_(Y,Z,Q){let J=Y.split(/\r\n|\n|\r/g),z="",X=(Math.log10(Z+1)|0)+1;for(let H=Z-1;H<=Z+1;H++){let W=J[H-1];if(!W)continue;if(z+=H.toString().padEnd(X," "),z+=": ",z+=W,z+=`
|
|
83
|
+
`,H===Z)z+=" ".repeat(X+Q+2),z+=`^
|
|
84
|
+
`}return z}var r;var Y1=R(()=>{/*!
|
|
91
85
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
92
86
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
93
87
|
*
|
|
@@ -113,11 +107,16 @@ Instead, \`yield\` should either be called with a value, or not be called at all
|
|
|
113
107
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
114
108
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
115
109
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
110
|
+
*/r=class r extends Error{line;column;codeblock;constructor(Y,Z){let[Q,J]=Z_(Z.toml,Z.ptr),z=Q_(Z.toml,Q,J);super(`Invalid TOML document: ${Y}
|
|
111
|
+
|
|
112
|
+
${z}`,Z);this.line=Q,this.column=J,this.codeblock=z}}});function J_(Y,Z){let Q=0;while(Y[Z-++Q]==="\\");return--Q&&Q%2}function o1(Y,Z=0,Q=Y.length){let J=Y.indexOf(`
|
|
113
|
+
`,Z);if(Y[J-1]==="\r")J--;return J<=Q?J:-1}function Y4(Y,Z){for(let Q=Z;Q<Y.length;Q++){let J=Y[Q];if(J===`
|
|
114
|
+
`)return Q;if(J==="\r"&&Y[Q+1]===`
|
|
115
|
+
`)return Q+1;if(J<" "&&J!=="\t"||J==="")throw new r("control characters are not allowed in comments",{toml:Y,ptr:Z})}return Y.length}function o0(Y,Z,Q,J){let z;while((z=Y[Z])===" "||z==="\t"||!Q&&(z===`
|
|
116
|
+
`||z==="\r"&&Y[Z+1]===`
|
|
117
|
+
`))Z++;return J||z!=="#"?Z:o0(Y,Y4(Y,Z),Q)}function vQ(Y,Z,Q,J,z=!1){if(!J)return Z=o1(Y,Z),Z<0?Y.length:Z;for(let X=Z;X<Y.length;X++){let H=Y[X];if(H==="#")X=o1(Y,X);else if(H===Q)return X+1;else if(H===J||z&&(H===`
|
|
118
|
+
`||H==="\r"&&Y[X+1]===`
|
|
119
|
+
`))return X}throw new r("cannot find end of structure",{toml:Y,ptr:Z})}function e7(Y,Z){let Q=Y[Z],J=Q===Y[Z+1]&&Y[Z+1]===Y[Z+2]?Y.slice(Z,Z+3):Q;Z+=J.length-1;do Z=Y.indexOf(J,++Z);while(Z>-1&&Q!=="'"&&J_(Y,Z));if(Z>-1){if(Z+=J.length,J.length>1){if(Y[Z]===Q)Z++;if(Y[Z]===Q)Z++}}return Z}var Z4=R(()=>{Y1();/*!
|
|
121
120
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
122
121
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
123
122
|
*
|
|
@@ -143,14 +142,7 @@ ${J}`,Z);this.line=Q,this.column=X,this.codeblock=J}}/*!
|
|
|
143
142
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
144
143
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
145
144
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
146
|
-
*/
|
|
147
|
-
`,Z);if(Y[X-1]==="\r")X--;return X<=Q?X:-1}function v1(Y,Z){for(let Q=Z;Q<Y.length;Q++){let X=Y[Q];if(X===`
|
|
148
|
-
`)return Q;if(X==="\r"&&Y[Q+1]===`
|
|
149
|
-
`)return Q+1;if(X<" "&&X!=="\t"||X==="")throw new l("control characters are not allowed in comments",{toml:Y,ptr:Z})}return Y.length}function P0(Y,Z,Q,X){let J;while((J=Y[Z])===" "||J==="\t"||!Q&&(J===`
|
|
150
|
-
`||J==="\r"&&Y[Z+1]===`
|
|
151
|
-
`))Z++;return X||J!=="#"?Z:P0(Y,v1(Y,Z),Q)}function m2(Y,Z,Q,X,J=!1){if(!X)return Z=h6(Y,Z),Z<0?Y.length:Z;for(let $=Z;$<Y.length;$++){let G=Y[$];if(G==="#")$=h6(Y,$);else if(G===Q)return $+1;else if(G===X||J&&(G===`
|
|
152
|
-
`||G==="\r"&&Y[$+1]===`
|
|
153
|
-
`))return $}throw new l("cannot find end of structure",{toml:Y,ptr:Z})}function $Z(Y,Z){let Q=Y[Z],X=Q===Y[Z+1]&&Y[Z+1]===Y[Z+2]?Y.slice(Z,Z+3):Q;Z+=X.length-1;do Z=Y.indexOf(X,++Z);while(Z>-1&&Q!=="'"&&bF(Y,Z));if(Z>-1){if(Z+=X.length,X.length>1){if(Y[Z]===Q)Z++;if(Y[Z]===Q)Z++}}return Z}/*!
|
|
145
|
+
*/});var z_,V6;var yQ=R(()=>{/*!
|
|
154
146
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
155
147
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
156
148
|
*
|
|
@@ -176,7 +168,12 @@ ${J}`,Z);this.line=Q,this.column=X,this.codeblock=J}}/*!
|
|
|
176
168
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
177
169
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
178
170
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
179
|
-
*/
|
|
171
|
+
*/z_=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;V6=class V6 extends Date{#Z=!1;#Q=!1;#Y=null;constructor(Y){let Z=!0,Q=!0,J="Z";if(typeof Y==="string"){let z=Y.match(z_);if(z){if(!z[1])Z=!1,Y=`0000-01-01T${Y}`;if(Q=!!z[2],Q&&Y[10]===" "&&(Y=Y.replace(" ","T")),z[2]&&+z[2]>23)Y="";else if(J=z[3]||null,Y=Y.toUpperCase(),!J&&Q)Y+="Z"}else Y=""}super(Y);if(!isNaN(this.getTime()))this.#Z=Z,this.#Q=Q,this.#Y=J}isDateTime(){return this.#Z&&this.#Q}isLocal(){return!this.#Z||!this.#Q||!this.#Y}isDate(){return this.#Z&&!this.#Q}isTime(){return this.#Q&&!this.#Z}isValid(){return this.#Z||this.#Q}toISOString(){let Y=super.toISOString();if(this.isDate())return Y.slice(0,10);if(this.isTime())return Y.slice(11,23);if(this.#Y===null)return Y.slice(0,-1);if(this.#Y==="Z")return Y;let Z=+this.#Y.slice(1,3)*60+ +this.#Y.slice(4,6);return Z=this.#Y[0]==="-"?Z:-Z,new Date(this.getTime()-Z*60000).toISOString().slice(0,-1)+this.#Y}static wrapAsOffsetDateTime(Y,Z="Z"){let Q=new V6(Y);return Q.#Y=Z,Q}static wrapAsLocalDateTime(Y){let Z=new V6(Y);return Z.#Y=null,Z}static wrapAsLocalDate(Y){let Z=new V6(Y);return Z.#Q=!1,Z.#Y=null,Z}static wrapAsLocalTime(Y){let Z=new V6(Y);return Z.#Z=!1,Z.#Y=null,Z}}});function Y2(Y,Z=0,Q=Y.length){let J=Y[Z]==="'",z=Y[Z++]===Y[Z]&&Y[Z]===Y[Z+1];if(z){if(Q-=2,Y[Z+=2]==="\r")Z++;if(Y[Z]===`
|
|
172
|
+
`)Z++}let X=0,H,W="",K=Z;while(Z<Q-1){let $=Y[Z++];if($===`
|
|
173
|
+
`||$==="\r"&&Y[Z]===`
|
|
174
|
+
`){if(!z)throw new r("newlines are not allowed in strings",{toml:Y,ptr:Z-1})}else if($<" "&&$!=="\t"||$==="")throw new r("control characters are not allowed in strings",{toml:Y,ptr:Z-1});if(H){if(H=!1,$==="u"||$==="U"){let G=Y.slice(Z,Z+=$==="u"?4:8);if(!K_.test(G))throw new r("invalid unicode escape",{toml:Y,ptr:X});try{W+=String.fromCodePoint(parseInt(G,16))}catch{throw new r("invalid unicode escape",{toml:Y,ptr:X})}}else if(z&&($===`
|
|
175
|
+
`||$===" "||$==="\t"||$==="\r")){if(Z=o0(Y,Z-1,!0),Y[Z]!==`
|
|
176
|
+
`&&Y[Z]!=="\r")throw new r("invalid escape: only line-ending whitespace may be escaped",{toml:Y,ptr:X});Z=o0(Y,Z)}else if($ in Tq)W+=Tq[$];else throw new r("unrecognized escape sequence",{toml:Y,ptr:X});K=Z}else if(!J&&$==="\\")X=Z-1,H=!0,W+=Y.slice(K,X)}return W+Y.slice(K,Q-1)}function Cq(Y,Z,Q,J){if(Y==="true")return!0;if(Y==="false")return!1;if(Y==="-inf")return-1/0;if(Y==="inf"||Y==="+inf")return 1/0;if(Y==="nan"||Y==="+nan"||Y==="-nan")return NaN;if(Y==="-0")return J?0n:0;let z=X_.test(Y);if(z||H_.test(Y)){if(W_.test(Y))throw new r("leading zeroes are not allowed",{toml:Z,ptr:Q});Y=Y.replace(/_/g,"");let H=+Y;if(isNaN(H))throw new r("invalid number",{toml:Z,ptr:Q});if(z){if((z=!Number.isSafeInteger(H))&&!J)throw new r("integer value cannot be represented losslessly",{toml:Z,ptr:Q});if(z||J===!0)H=BigInt(Y)}return H}let X=new V6(Y);if(!X.isValid())throw new r("invalid value",{toml:Z,ptr:Q});return X}var X_,H_,W_,K_,Tq;var fQ=R(()=>{Z4();yQ();Y1();/*!
|
|
180
177
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
181
178
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
182
179
|
*
|
|
@@ -202,13 +199,10 @@ ${J}`,Z);this.line=Q,this.column=X,this.codeblock=J}}/*!
|
|
|
202
199
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
203
200
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
204
201
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
205
|
-
*/
|
|
206
|
-
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};function
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
`){if(!J)throw new l("newlines are not allowed in strings",{toml:Y,ptr:Z-1})}else if(W<" "&&W!=="\t"||W==="")throw new l("control characters are not allowed in strings",{toml:Y,ptr:Z-1});if(G){if(G=!1,W==="u"||W==="U"){let z=Y.slice(Z,Z+=W==="u"?4:8);if(!pF.test(z))throw new l("invalid unicode escape",{toml:Y,ptr:$});try{K+=String.fromCodePoint(parseInt(z,16))}catch{throw new l("invalid unicode escape",{toml:Y,ptr:$})}}else if(J&&(W===`
|
|
210
|
-
`||W===" "||W==="\t"||W==="\r")){if(Z=P0(Y,Z-1,!0),Y[Z]!==`
|
|
211
|
-
`&&Y[Z]!=="\r")throw new l("invalid escape: only line-ending whitespace may be escaped",{toml:Y,ptr:$});Z=P0(Y,Z)}else if(W in j$)K+=j$[W];else throw new l("unrecognized escape sequence",{toml:Y,ptr:$});H=Z}else if(!X&&W==="\\")$=Z-1,G=!0,K+=Y.slice(H,$)}return K+Y.slice(H,Q-1)}function x$(Y,Z,Q,X){if(Y==="true")return!0;if(Y==="false")return!1;if(Y==="-inf")return-1/0;if(Y==="inf"||Y==="+inf")return 1/0;if(Y==="nan"||Y==="+nan"||Y==="-nan")return NaN;if(Y==="-0")return X?0n:0;let J=mF.test(Y);if(J||uF.test(Y)){if(dF.test(Y))throw new l("leading zeroes are not allowed",{toml:Z,ptr:Q});Y=Y.replace(/_/g,"");let G=+Y;if(isNaN(G))throw new l("invalid number",{toml:Z,ptr:Q});if(J){if((J=!Number.isSafeInteger(G))&&!X)throw new l("integer value cannot be represented losslessly",{toml:Z,ptr:Q});if(J||X===!0)G=BigInt(Y)}return G}let $=new TY(Y);if(!$.isValid())throw new l("invalid value",{toml:Z,ptr:Q});return $}/*!
|
|
202
|
+
*/X_=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,H_=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,W_=/^[+-]?0[0-9_]/,K_=/^[0-9a-f]{4,8}$/i,Tq={b:"\b",t:"\t",n:`
|
|
203
|
+
`,f:"\f",r:"\r",'"':'"',"\\":"\\"}});function G_(Y,Z,Q,J){let z=Y.slice(Z,Q),X=z.indexOf("#");if(X>-1)Y4(Y,X),z=z.slice(0,X);let H=z.trimEnd();if(!J){let W=z.indexOf(`
|
|
204
|
+
`,H.length);if(W>-1)throw new r("newlines are not allowed in inline tables",{toml:Y,ptr:Z+W})}return[H,X]}function Q4(Y,Z,Q,J,z){if(J===0)throw new r("document contains excessively nested structures. aborting.",{toml:Y,ptr:Z});let X=Y[Z];if(X==="["||X==="{"){let[K,$]=X==="["?Aq(Y,Z,J,z):kq(Y,Z,J,z),G=Q?vQ(Y,$,",",Q):$;if($-G&&Q==="}"){let U=o1(Y,$,G);if(U>-1)throw new r("newlines are not allowed in inline tables",{toml:Y,ptr:U})}return[K,G]}let H;if(X==='"'||X==="'"){H=e7(Y,Z);let K=Y2(Y,Z,H);if(Q){if(H=o0(Y,H,Q!=="]"),Y[H]&&Y[H]!==","&&Y[H]!==Q&&Y[H]!==`
|
|
205
|
+
`&&Y[H]!=="\r")throw new r("unexpected character encountered",{toml:Y,ptr:H});H+=+(Y[H]===",")}return[K,H]}H=vQ(Y,Z,",",Q);let W=G_(Y,Z,H-+(Y[H-1]===","),Q==="]");if(!W[0])throw new r("incomplete key-value declaration: no value specified",{toml:Y,ptr:Z});if(Q&&W[1]>-1)H=o0(Y,Z+W[1]),H+=+(Y[H]===",");return[Cq(W[0],Y,Z,z),H]}var bQ=R(()=>{fQ();hQ();Z4();Y1();/*!
|
|
212
206
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
213
207
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
214
208
|
*
|
|
@@ -234,9 +228,9 @@ ${J}`,Z);this.line=Q,this.column=X,this.codeblock=J}}/*!
|
|
|
234
228
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
235
229
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
236
230
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
237
|
-
*/function
|
|
238
|
-
|
|
239
|
-
`&&
|
|
231
|
+
*/});function Z2(Y,Z,Q="="){let J=Z-1,z=[],X=Y.indexOf(Q,Z);if(X<0)throw new r("incomplete key-value: cannot find end of key",{toml:Y,ptr:Z});do{let H=Y[Z=++J];if(H!==" "&&H!=="\t")if(H==='"'||H==="'"){if(H===Y[Z+1]&&H===Y[Z+2])throw new r("multiline strings are not allowed in keys",{toml:Y,ptr:Z});let W=e7(Y,Z);if(W<0)throw new r("unfinished string encountered",{toml:Y,ptr:Z});J=Y.indexOf(".",W);let K=Y.slice(W,J<0||J>X?X:J),$=o1(K);if($>-1)throw new r("newlines are not allowed in keys",{toml:Y,ptr:Z+J+$});if(K.trimStart())throw new r("found extra tokens after the string part",{toml:Y,ptr:W});if(X<W){if(X=Y.indexOf(Q,W),X<0)throw new r("incomplete key-value: cannot find end of key",{toml:Y,ptr:Z})}z.push(Y2(Y,Z,W))}else{J=Y.indexOf(".",Z);let W=Y.slice(Z,J<0||J>X?X:J);if(!$_.test(W))throw new r("only letter, numbers, dashes and underscores are allowed in keys",{toml:Y,ptr:Z});z.push(W.trimEnd())}}while(J+1&&J<X);return[z,o0(Y,X+1,!0,!0)]}function kq(Y,Z,Q,J){let z={},X=new Set,H,W=0;Z++;while((H=Y[Z++])!=="}"&&H){let K={toml:Y,ptr:Z-1};if(H===`
|
|
232
|
+
`)throw new r("newlines are not allowed in inline tables",K);else if(H==="#")throw new r("inline tables cannot contain comments",K);else if(H===",")throw new r("expected key-value, found comma",K);else if(H!==" "&&H!=="\t"){let $,G=z,U=!1,[B,F]=Z2(Y,Z-1);for(let N=0;N<B.length;N++){if(N)G=U?G[$]:G[$]={};if($=B[N],(U=Object.hasOwn(G,$))&&(typeof G[$]!=="object"||X.has(G[$])))throw new r("trying to redefine an already defined value",{toml:Y,ptr:Z});if(!U&&$==="__proto__")Object.defineProperty(G,$,{enumerable:!0,configurable:!0,writable:!0})}if(U)throw new r("trying to redefine an already defined value",{toml:Y,ptr:Z});let[V,O]=Q4(Y,F,"}",Q-1,J);X.add(V),G[$]=V,Z=O,W=Y[Z-1]===","?Z-1:0}}if(W)throw new r("trailing commas are not allowed in inline tables",{toml:Y,ptr:W});if(!H)throw new r("unfinished table encountered",{toml:Y,ptr:Z});return[z,Z]}function Aq(Y,Z,Q,J){let z=[],X;Z++;while((X=Y[Z++])!=="]"&&X)if(X===",")throw new r("expected value, found comma",{toml:Y,ptr:Z-1});else if(X==="#")Z=Y4(Y,Z);else if(X!==" "&&X!=="\t"&&X!==`
|
|
233
|
+
`&&X!=="\r"){let H=Q4(Y,Z-1,"]",Q-1,J);z.push(H[0]),Z=H[1]}if(!X)throw new r("unfinished array encountered",{toml:Y,ptr:Z});return[z,Z]}var $_;var hQ=R(()=>{fQ();bQ();Z4();Y1();/*!
|
|
240
234
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
241
235
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
242
236
|
*
|
|
@@ -262,9 +256,8 @@ ${J}`,Z);this.line=Q,this.column=X,this.codeblock=J}}/*!
|
|
|
262
256
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
263
257
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
264
258
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
`&&$!=="\r"){let G=f1(Y,Z-1,"]",Q-1,X);J.push(G[0]),Z=G[1]}if(!$)throw new l("unfinished array encountered",{toml:Y,ptr:Z});return[J,Z]}/*!
|
|
259
|
+
*/$_=/^[a-zA-Z0-9-_]+[ \t]*$/});function xq(Y,Z,Q,J){let z=Z,X=Q,H,W=!1,K;for(let $=0;$<Y.length;$++){if($){if(z=W?z[H]:z[H]={},X=(K=X[H]).c,J===0&&(K.t===1||K.t===2))return null;if(K.t===2){let G=z.length-1;z=z[G],X=X[G].c}}if(H=Y[$],(W=Object.hasOwn(z,H))&&X[H]?.t===0&&X[H]?.d)return null;if(!W){if(H==="__proto__")Object.defineProperty(z,H,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(X,H,{enumerable:!0,configurable:!0,writable:!0});X[H]={t:$<Y.length-1&&J===2?3:J,d:!1,i:0,c:{}}}}if(K=X[H],K.t!==J&&!(J===1&&K.t===3))return null;if(J===2){if(!K.d)K.d=!0,z[H]=[];z[H].push(z={}),K.c[K.i++]=K={t:1,d:!1,i:0,c:{}}}if(K.d)return null;if(K.d=!0,J===1)z=W?z[H]:z[H]={};else if(J===0&&W)return null;return[H,z,K.c]}function gQ(Y,{maxDepth:Z=1000,integersAsBigInt:Q}={}){let J={},z={},X=J,H=z;for(let W=o0(Y,0);W<Y.length;){if(Y[W]==="["){let K=Y[++W]==="[",$=Z2(Y,W+=+K,"]");if(K){if(Y[$[1]-1]!=="]")throw new r("expected end of table declaration",{toml:Y,ptr:$[1]-1});$[1]++}let G=xq($[0],J,z,K?2:1);if(!G)throw new r("trying to redefine an already defined table or value",{toml:Y,ptr:W});H=G[2],X=G[1],W=$[1]}else{let K=Z2(Y,W),$=xq(K[0],X,H,0);if(!$)throw new r("trying to redefine an already defined table or value",{toml:Y,ptr:W});let G=Q4(Y,K[1],void 0,Z,Q);$[1][$[0]]=G[0],W=G[1]}if(W=o0(Y,W,!0),Y[W]&&Y[W]!==`
|
|
260
|
+
`&&Y[W]!=="\r")throw new r("each key-value declaration must be followed by an end-of-line",{toml:Y,ptr:W});W=o0(Y,W)}return J}var Eq=R(()=>{hQ();bQ();Z4();Y1();/*!
|
|
268
261
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
269
262
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
270
263
|
*
|
|
@@ -290,8 +283,16 @@ ${J}`,Z);this.line=Q,this.column=X,this.codeblock=J}}/*!
|
|
|
290
283
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
291
284
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
292
285
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
293
|
-
*/function
|
|
294
|
-
|
|
286
|
+
*/});function J4(Y){let Z=typeof Y;if(Z==="object"){if(Array.isArray(Y))return"array";if(Y instanceof Date)return"date"}return Z}function q_(Y){for(let Z=0;Z<Y.length;Z++)if(J4(Y[Z])!=="object")return!1;return Y.length!=0}function mQ(Y){return JSON.stringify(Y).replace(/\x7f/g,"\\u007f")}function uQ(Y,Z,Q,J){if(Q===0)throw Error("Could not stringify the object: maximum object depth exceeded");if(Z==="number"){if(isNaN(Y))return"nan";if(Y===1/0)return"inf";if(Y===-1/0)return"-inf";if(J&&Number.isInteger(Y))return Y.toFixed(1);return Y.toString()}if(Z==="bigint"||Z==="boolean")return Y.toString();if(Z==="string")return mQ(Y);if(Z==="date"){if(isNaN(Y.getTime()))throw TypeError("cannot serialize invalid date");return Y.toISOString()}if(Z==="object")return U_(Y,Q,J);if(Z==="array")return B_(Y,Q,J)}function U_(Y,Z,Q){let J=Object.keys(Y);if(J.length===0)return"{}";let z="{ ";for(let X=0;X<J.length;X++){let H=J[X];if(X)z+=", ";z+=Pq.test(H)?H:mQ(H),z+=" = ",z+=uQ(Y[H],J4(Y[H]),Z-1,Q)}return z+" }"}function B_(Y,Z,Q){if(Y.length===0)return"[]";let J="[ ";for(let z=0;z<Y.length;z++){if(z)J+=", ";if(Y[z]===null||Y[z]===void 0)throw TypeError("arrays cannot contain null or undefined values");J+=uQ(Y[z],J4(Y[z]),Z-1,Q)}return J+" ]"}function V_(Y,Z,Q,J){if(Q===0)throw Error("Could not stringify the object: maximum object depth exceeded");let z="";for(let X=0;X<Y.length;X++)z+=`${z&&`
|
|
287
|
+
`}[[${Z}]]
|
|
288
|
+
`,z+=dQ(0,Y[X],Z,Q,J);return z}function dQ(Y,Z,Q,J,z){if(J===0)throw Error("Could not stringify the object: maximum object depth exceeded");let X="",H="",W=Object.keys(Z);for(let K=0;K<W.length;K++){let $=W[K];if(Z[$]!==null&&Z[$]!==void 0){let G=J4(Z[$]);if(G==="symbol"||G==="function")throw TypeError(`cannot serialize values of type '${G}'`);let U=Pq.test($)?$:mQ($);if(G==="array"&&q_(Z[$]))H+=(H&&`
|
|
289
|
+
`)+V_(Z[$],Q?`${Q}.${U}`:U,J-1,z);else if(G==="object"){let B=Q?`${Q}.${U}`:U;H+=(H&&`
|
|
290
|
+
`)+dQ(B,Z[$],B,J-1,z)}else X+=U,X+=" = ",X+=uQ(Z[$],G,J,z),X+=`
|
|
291
|
+
`}}if(Y&&(X||!H))X=X?`[${Y}]
|
|
292
|
+
${X}`:`[${Y}]`;return X&&H?`${X}
|
|
293
|
+
${H}`:X||H}function pQ(Y,{maxDepth:Z=1000,numbersAsFloat:Q=!1}={}){if(J4(Y)!=="object")throw TypeError("stringify can only be called with an object");let J=dQ(0,Y,"",Z,Q);if(J[J.length-1]!==`
|
|
294
|
+
`)return J+`
|
|
295
|
+
`;return J}var Pq;var Sq=R(()=>{/*!
|
|
295
296
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
296
297
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
297
298
|
*
|
|
@@ -317,16 +318,7 @@ ${J}`,Z);this.line=Q,this.column=X,this.codeblock=J}}/*!
|
|
|
317
318
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
318
319
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
319
320
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
320
|
-
*/
|
|
321
|
-
`}[[${Z}]]
|
|
322
|
-
`,J+=c2(0,Y[$],Z,Q,X);return J}function c2(Y,Z,Q,X,J){if(X===0)throw Error("Could not stringify the object: maximum object depth exceeded");let $="",G="",K=Object.keys(Z);for(let H=0;H<K.length;H++){let W=K[H];if(Z[W]!==null&&Z[W]!==void 0){let z=h1(Z[W]);if(z==="symbol"||z==="function")throw TypeError(`cannot serialize values of type '${z}'`);let q=f$.test(W)?W:d2(W);if(z==="array"&&iF(Z[W]))G+=(G&&`
|
|
323
|
-
`)+oF(Z[W],Q?`${Q}.${q}`:q,X-1,J);else if(z==="object"){let V=Q?`${Q}.${q}`:q;G+=(G&&`
|
|
324
|
-
`)+c2(V,Z[W],V,X-1,J)}else $+=q,$+=" = ",$+=p2(Z[W],z,X,J),$+=`
|
|
325
|
-
`}}if(Y&&($||!G))$=$?`[${Y}]
|
|
326
|
-
${$}`:`[${Y}]`;return $&&G?`${$}
|
|
327
|
-
${G}`:$||G}function l2(Y,{maxDepth:Z=1000,numbersAsFloat:Q=!1}={}){if(h1(Y)!=="object")throw TypeError("stringify can only be called with an object");let X=c2(0,Y,"",Z,Q);if(X[X.length-1]!==`
|
|
328
|
-
`)return X+`
|
|
329
|
-
`;return X}/*!
|
|
321
|
+
*/Pq=/^[a-z0-9-_]+$/i});var vq=R(()=>{Eq();Sq();yQ();Y1();/*!
|
|
330
322
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
331
323
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
332
324
|
*
|
|
@@ -352,106 +344,127 @@ ${G}`:$||G}function l2(Y,{maxDepth:Z=1000,numbersAsFloat:Q=!1}={}){if(h1(Y)!=="o
|
|
|
352
344
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
353
345
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
354
346
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
355
|
-
*/var
|
|
356
|
-
Values that are expensive to get are cached for faster subsequent access.`,"cache.enabled":"Whether caching is enabled","cache.maxAgeMinutes":"
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
347
|
+
*/});var Z1,yq,cQ;var lQ=R(()=>{W0();Z1={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},cache:{enabled:!0,maxAgeMinutes:TZ},parallel:{init:"submodule"},defaultEditor:"code",enhancedOutput:!0},yq={"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","cache.enabled":"GDX_CACHE_ENABLED","cache.maxAgeMinutes":"GDX_CACHE_MAX_AGE_MINUTES","parallel.init":"GDX_PARALLEL_INIT",defaultEditor:"GDX_DEFAULT_EDITOR",enhancedOutput:"GDX_ENHANCED_OUTPUT"},cQ={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",cache:`Configuration for caching mechanism.
|
|
348
|
+
Values that are expensive to get are cached for faster subsequent access.`,"cache.enabled":"Whether caching is enabled","cache.maxAgeMinutes":"Default maximum age of cache entries in minutes (some cache ignore this)",parallel:"Configuration for parallel worktree automation","parallel.init":"Comma-separated list specifying what to init for new forks (submodule, pkg)",defaultEditor:"Default code editor to open files with",enhancedOutput:"Whether to enhanced Git's output (modify the output of some git commands when conditions are met)"}});import Q1 from"fs";import iQ from"path";import F_ from"os";var fq=null,Q2,R_,M_,O_,e,D;var $0=R(()=>{z0();W0();C0();Q2={off:-1,fatal:0,error:1,warn:2,info:3,debug:4,verbose:5},R_={off:"BgBlue",fatal:"BgRed",error:"BgRed",warn:"BgYellow",info:"BgBlue",debug:"BgMagenta",verbose:"BgCyan"},M_={off:"",fatal:"FATAL",error:"ERROR",warn:"WARN",info:"INFO",debug:"DEBUG",verbose:"VERBOSE"},O_={off:"Cyan",fatal:"Red",error:"Red",warn:"Yellow",info:"Cyan",debug:"Magenta",verbose:"Blue"};e=class e{static logFile=iQ.join(F_.tmpdir(),"gdx","gdx.log");static logLevel=Q2[l.logLevel];static timeLabels=new Map;moduleName;static initialized=!1;static allLogs=[{timestamp:new Date().toISOString(),level:"info",message:`
|
|
349
|
+
|
|
350
|
+
=== New gdx session started ===
|
|
351
|
+
LocalMachineDate: ${new Date().toLocaleString()}
|
|
352
|
+
AppVersion: ${l0}
|
|
353
|
+
Platform: ${process.platform}
|
|
354
|
+
Arch: ${process.arch}
|
|
355
|
+
`,module:"logger"}];constructor(Y){this.moduleName=Y,e.ensureInitialized()}static wouldLog(Y){return Q2[Y]<=e.logLevel}static ensureInitialized(){if(!e.initialized){if(e.initialized=!0,!S5)return;e.initializeLogDirectory(),process.on("exit",()=>e.flushLogs())}}static initializeLogDirectory(){let Y=iQ.dirname(e.logFile);try{if(!Q1.existsSync(Y))Q1.mkdirSync(Y,{recursive:!0})}catch{}}static logInternal(Y,Z,Q){let z={timestamp:new Date().toISOString(),level:Y,message:Z,module:Q};if(fq)fq(z);if(Q2[Y]<=Q2[l.logLevel])e.printMessage(Y,Z,Q);if(!S5)return;e.ensureInitialized(),e.allLogs.push(z)}static printMessage(Y,Z,Q){let J=R_[Y],z=M_[Y],X=O_[Y],H=a(Z,100,{indent:" "}),W=q(J)+q("Bright")+q("White")+` ${z} `+q()+q("Invert")+` ${Q} ${q()+q(X)} ${H}`+q();if(Y==="fatal"||Y==="error")process.stderr.write(W+`
|
|
356
|
+
`);else process.stdout.write(W+`
|
|
357
|
+
`)}fatal(Y){e.logInternal("fatal",Y,this.moduleName)}error(Y){e.logInternal("error",Y,this.moduleName)}warn(Y){e.logInternal("warn",Y,this.moduleName)}info(Y){e.logInternal("info",Y,this.moduleName)}debug(Y){e.logInternal("debug",Y,this.moduleName)}verbose(Y){e.logInternal("verbose",Y,this.moduleName)}time(Y,Z){if(!Z){e.timeLabels.set(Y,performance.now());return}return e.time(Y,Z,this.moduleName)}timeEnd(Y){e.timeEnd(Y,this.moduleName)}async timeAsync(Y,Z){return await e.timeAsync(Y,Z,this.moduleName)}static fatal(Y,Z="gdx"){e.logInternal("fatal",Y,Z)}static error(Y,Z="gdx"){e.logInternal("error",Y,Z)}static warn(Y,Z="gdx"){e.logInternal("warn",Y,Z)}static info(Y,Z="gdx"){e.logInternal("info",Y,Z)}static debug(Y,Z="gdx"){e.logInternal("debug",Y,Z)}static verbose(Y,Z="gdx"){e.logInternal("verbose",Y,Z)}static async timeAsync(Y,Z,Q="gdx"){let J=performance.now();try{return await Z()}finally{let z=performance.now(),X=k1.getTimeFromMS(z-J).modern();e.debug(`${Y} took ${X}`,Q)}}static time(Y,Z,Q="gdx"){let J=performance.now();if(!Z){e.timeLabels.set(Y,J);return}try{return Z()}finally{let z=performance.now(),X=k1.getTimeFromMS(z-J).modern();e.debug(`${Y} took ${X}`,Q)}}static timeEnd(Y,Z="gdx"){let Q=performance.now(),J=e.timeLabels.get(Y);if(J){let z=k1.getTimeFromMS(Q-J).modern();e.debug(`${Y} took ${z}`,Z),e.timeLabels.delete(Y)}else e.warn(`No such label '${Y}' for timeEnd`,Z)}static flushLogs(){if(e.allLogs.length===0)return;try{let Y=iQ.dirname(e.logFile);if(!Q1.existsSync(Y))Q1.mkdirSync(Y,{recursive:!0});let Z="";if(Q1.existsSync(e.logFile))Z=Q1.readFileSync(e.logFile,"utf-8");let Q=e.allLogs.map(({timestamp:X,level:H,message:W,module:K})=>{let $=H.toUpperCase().padEnd(5);return W=a(yz(W),100,{indent:33,redundancyLv:-1,mode:"strict"}),`${X} [${$}] ${K}: ${W}`}).join(`
|
|
358
|
+
`),J=Z?Z+`
|
|
359
|
+
`+Q:Q;if(Buffer.byteLength(J,"utf-8")>XX){let X=J.split(`
|
|
360
|
+
`),H=Math.floor(X.length/2);J=X.slice(H).join(`
|
|
361
|
+
`)}Q1.writeFileSync(e.logFile,J,"utf-8")}catch{}}};D=e});import D_ from"path";async function nQ(){return bq??=import("keytar"),await bq}class hq{configPath;config=structuredClone(Z1);loaded=!1;logger=new D("ConfigService");constructor(Y){this.configPath=Y||A8}async load(){if(this.loaded)return;try{let Y=await QY(this.configPath,"utf-8"),Z=gQ(Y);this.config=this.mergeConfig(Z1,Z)}catch(Y){let Z=new n(Y);if(Z.code!=="ENOENT")this.logger.warn(`Failed to parse config file at ${this.configPath}: ${Z.message}`);this.config=structuredClone(Z1)}this.applyEnvOverrides(),this.loaded=!0}async save(){let Y=this.removeSecureKeys(this.config),Z=pQ(Y),Q=D_.dirname(this.configPath);if(!o(Q))ZY(Q,{recursive:!0});await z6(this.configPath,Z,"utf-8")}get(Y,Z){let Q=Y.split("."),J=this.config;for(let z of Q)if(J&&typeof J==="object"&&z in J)J=J[z];else return Z;return J}async getSecure(Y,Z){let Q=this.get(Y);if(Q!==void 0)return Q;if(X6.includes(Y))try{let z=await(await nQ()).getPassword(_Z,Y);if(z){let X=Y.split("."),H=this.config;for(let W=0;W<X.length-1;W++){let K=X[W];if(!(K in H)||typeof H[K]!=="object")H[K]={};H=H[K]}return H[X[X.length-1]]=z,z}}catch(J){this.logger.warn(`Failed to load secure key '${Y}' from keychain:
|
|
362
|
+
`+n.from(J).toString({color:!0}))}return Z}async set(Y,Z){let Q=Y.split("."),J=this.config;for(let H=0;H<Q.length-1;H++){let W=Q[H];if(!(W in J)||typeof J[W]!=="object")J[W]={};J=J[W]}let z=Q[Q.length-1],X=this.get(Y);if(X!==void 0&&typeof Z!==typeof X){this.logger.warn(`Type mismatch for '${Y}'. Expected ${typeof X}, got ${typeof Z}. Ignoring value.`);return}if(X6.includes(Y))try{await(await nQ()).setPassword(_Z,Y,String(Z))}catch(H){this.logger.warn(`Failed to save secure key '${Y}' to keychain:
|
|
363
|
+
`+n.from(H).toString({color:!0}))}J[z]=Z}getAll(){return this.config}getConfigPath(){return this.configPath}isDefault(Y){let Z=Y.split("."),Q=this.config,J=Z1;for(let z of Z){if(Q&&typeof Q==="object"&&z in Q)Q=Q[z];else Q=void 0;if(J&&typeof J==="object"&&z in J)J=J[z];else J=void 0}return Q===J}mergeConfig(Y,Z){let Q=structuredClone(Y),J=(z,X,H="")=>{for(let W in X){let K=H?`${H}.${W}`:W,$=X[W],G=z[W];if(G===void 0)continue;if(typeof $==="object"&&$!==null&&!Array.isArray($))if(typeof G==="object"&&G!==null)J(z[W],$,K);else this.logger.warn(`Type mismatch for '${K}'. Expected ${typeof G}, got object. Ignoring value.`);else if(typeof $!==typeof G)this.logger.warn(`Type mismatch for '${K}'. Expected ${typeof G}, got ${typeof $}. Ignoring value.`);else z[W]=$}};return J(Q,Z),Q}removeSecureKeys(Y){let Z=structuredClone(Y);for(let Q of X6){let J=Q.split("."),z=Z;for(let X=0;X<J.length-1;X++){if(!z[J[X]])return Z;z=z[J[X]]}delete z[J[J.length-1]]}return Z}async deleteSecureKey(Y){if(!X6.includes(Y))return!1;try{return await(await nQ()).deletePassword(_Z,Y)}catch{return!1}}applyEnvOverrides(){for(let[Y,Z]of Object.entries(yq)){let Q=process.env[Z];if(Q!==void 0){let J=this.get(Y),z=Q;if(typeof J==="number"){let X=Number(Q);if(!isNaN(X))z=X;else{this.logger.warn(`Environment variable ${Z} has invalid number value '${Q}'. Ignoring.`);continue}}else if(typeof J==="boolean")z=Q.toLowerCase()==="true";this.set(Y,z)}}}}function N_(){let Y=process.env.GDX_CONFIG_PATH;if(Y)return Y;if(o(A8))return A8;if(o(P5))return P5;return A8}async function q0(){if(!J2)J2=new hq(N_()),await J2.load();return J2}var bq=null,J2=null;var FY=R(()=>{vq();u0();lQ();W0();z0();$0()});import w_ from"path";class mq{cachePath;isDisabled=!1;cache={...gq};memoryData={};memoryEntryMeta={};loaded=!1;dirty=!1;loadingPromise=null;logger=new D("cache");constructor(Y){this.cachePath=Y||JY}async ensureLoaded(){if(this.loaded)return;if(this.loadingPromise){await this.loadingPromise;return}this.loadingPromise=this.load();try{await this.loadingPromise}finally{this.loadingPromise=null}}pruneExpiredKeys(){let Y=Date.now(),Z=0,Q=[];for(let[J,z]of Object.entries(this.cache.entryMeta))if(Y>z.expiresAt)Q.push(J);for(let J of Q){delete this.cache.entryMeta[J];let z=J.split("."),X=[],H=this.cache.data;for(let W of z)if(H&&typeof H==="object"&&W in H)X.push({obj:H,key:W}),H=H[W];else break;if(X.length>0){let W=X[X.length-1];delete W.obj[W.key],Z++}for(let W=X.length-2;W>=0;W--){let{obj:K,key:$}=X[W],G=K[$];if(G&&typeof G==="object"&&Object.keys(G).length===0)delete K[$];else break}}if(this.cache.meta.lastPruneAt=Y,Z>0)this.cache.meta.updatedAt=Y,this.dirty=!0;return Z}async load(){if(this.loaded)return;if(!(await q0()).get("cache.enabled")){this.resetCache(!1),this.loaded=!0,this.isDisabled=!0,this.logger.debug("Cache is disabled via configuration");return}try{let Z=await QY(this.cachePath,"utf-8"),Q=JSON.parse(Z);if(!Q.meta||!Q.data){this.resetCache(!1),this.loaded=!0;return}if(Q.meta.version!==l0){this.logger.debug(`Cache version mismatch: stored=${Q.meta.version}, current=${l0}. Resetting cache.`),this.resetCache(!1),this.loaded=!0;return}if(!Q.entryMeta||!Q.meta.lastPruneAt){this.logger.debug("Existing cache file' schema mismatch; resetting cache to newer version"),this.resetCache(!1),this.loaded=!0;return}this.cache=Q;let z=(Date.now()-this.cache.meta.lastPruneAt)/jZ;if(z>=JX){this.logger.debug(`Last prune was ${z.toFixed(1)} days ago. Running cache pruning...`);let X=this.pruneExpiredKeys();if(X>0)this.logger.debug(`Pruned ${X} expired cache entries`);else this.logger.debug("No expired entries found during pruning")}}catch(Z){let Q=new n(Z);if(Q.code!=="ENOENT")this.logger.debug(`Failed to parse cache file at ${this.cachePath}: ${Q.message}`);this.resetCache(!1)}this.loaded=!0}resetCache(Y=!0){if(this.cache=structuredClone(gq),Y)this.dirty=!0}resetMemoryCache(){this.memoryData={},this.memoryEntryMeta={}}async get(Y,Z){if(this.isDisabled)return Z;await this.ensureLoaded();let Q=this.cache.entryMeta[Y];if(!Q)return this.logger.debug(`Cache ${Y} missed.`),Z;if(Date.now()>Q.expiresAt)return this.logger.debug(`Cache entry expired: ${Y}. expiresAt=${new Date(Q.expiresAt).toISOString()}, now=${new Date().toISOString()}`),await this.delete(Y),Z;let J=Y.split("."),z=this.cache.data;for(let X of J)if(z&&typeof z==="object"&&X in z)z=z[X];else return Z;return this.logger.debug(`Cache ${Y} hit.`),z}async getOneOff(Y,Z){if(await this.ensureLoaded(),this.isDisabled)return Z;if(!this.memoryEntryMeta[Y])return this.logger.debug(`Memory cache ${Y} missed.`),Z;let J=Y.split("."),z=this.memoryData;for(let X of J)if(z&&typeof z==="object"&&X in z)z=z[X];else return Z;return this.logger.debug(`Memory cache ${Y} hit.`),z}async set(Y,Z,Q){if(this.isDisabled)return;let J=await q0();await this.ensureLoaded();let z=Y.split("."),X=this.cache.data,H=Q?.maxAgeMinutes??J.get("cache.maxAgeMinutes")??TZ;this.logger.debug(`Setting cache ${Y} with maxAgeMinutes=${H}`);for(let $=0;$<z.length-1;$++){let G=z[$];if(!(G in X)||typeof X[G]!=="object")X[G]={};X=X[G]}let W=z[z.length-1];X[W]=Z;let K=Date.now();this.cache.entryMeta[Y]={createdAt:this.cache.entryMeta[Y]?.createdAt??K,updatedAt:K,expiresAt:K+H*60*1000},this.cache.meta.updatedAt=K,this.dirty=!0}async setOneOff(Y,Z){if(await this.ensureLoaded(),this.isDisabled)return;let Q=Y.split("."),J=this.memoryData;this.logger.debug(`Setting memory cache ${Y}`);for(let H=0;H<Q.length-1;H++){let W=Q[H];if(!(W in J)||typeof J[W]!=="object")J[W]={};J=J[W]}let z=Q[Q.length-1];J[z]=Z;let X=Date.now();this.memoryEntryMeta[Y]={createdAt:this.memoryEntryMeta[Y]?.createdAt??X,updatedAt:X}}async delete(Y){if(this.isDisabled)return!1;if(await this.ensureLoaded(),!this.cache.entryMeta[Y])return!1;delete this.cache.entryMeta[Y];let Z=Y.split("."),Q=[],J=this.cache.data;for(let z of Z)if(J&&typeof J==="object"&&z in J)Q.push({obj:J,key:z}),J=J[z];else return!1;if(Q.length>0){let z=Q[Q.length-1];delete z.obj[z.key]}for(let z=Q.length-2;z>=0;z--){let{obj:X,key:H}=Q[z],W=X[H];if(W&&typeof W==="object"&&Object.keys(W).length===0)delete X[H];else break}return this.cache.meta.updatedAt=Date.now(),this.dirty=!0,this.logger.debug(`Cache entry deleted: ${Y}`),!0}async deleteOneOff(Y){if(await this.ensureLoaded(),this.isDisabled)return!1;if(!this.memoryEntryMeta[Y])return!1;delete this.memoryEntryMeta[Y];let Z=Y.split("."),Q=[],J=this.memoryData;for(let z of Z)if(J&&typeof J==="object"&&z in J)Q.push({obj:J,key:z}),J=J[z];else return!1;if(Q.length>0){let z=Q[Q.length-1];delete z.obj[z.key]}for(let z=Q.length-2;z>=0;z--){let{obj:X,key:H}=Q[z],W=X[H];if(W&&typeof W==="object"&&Object.keys(W).length===0)delete X[H];else break}return this.logger.debug(`Memory cache entry deleted: ${Y}`),!0}async getAll(){return await this.ensureLoaded(),this.cache}getCachePath(){return this.cachePath}flush(){if(!this.dirty)return;try{let Y=w_.dirname(this.cachePath);ZY(Y,{recursive:!0});let Z=JSON.stringify(this.cache);Q6(this.cachePath,Z,"utf-8"),this.dirty=!1,this.logger.debug(`Cache flushed to ${this.cachePath}`)}catch(Y){let Z=new n(Y);this.logger.warn(`Failed to flush cache: ${Z.message}`)}}async clear(){await this.ensureLoaded(),this.resetCache(),this.resetMemoryCache()}}async function X0(){if(!F6){if(F6=new mq,await F6.ensureLoaded(),!F6.isDisabled)L_()}return F6}function z2(){F6=null}function L_(){D.debug("Registering cache flush hook on exit","cache"),vz(()=>{if(F6)F6.flush()})}var gq,F6=null;var R6=R(()=>{u0();W0();z0();$0();FY();gq={meta:{version:l0,createdAt:Date.now(),updatedAt:Date.now(),lastPruneAt:Date.now()},data:{},entryMeta:{}}});async function uq(Y,Z){let Q=await X0(),J=`which.${Y}`,z=await Q.get(J);if(z!=null&&o(z))return D.debug(`Cache hit for ${J}`,"cache-ctrl"),z;try{let X=Z?await Z():await M6(Y);if(!X)return null;return await Q.set(J,X),D.debug(`Cache store for ${J}: ${X}`,"cache-ctrl"),X}catch(X){throw D.warn(`Failed to get which exec for ${Y}: ${X}`,"cache-ctrl"),X}}var dq=R(()=>{k0();R6();$0();u0()});import s1 from"path";import{createInterface as __}from"readline";import{writeFile as I_}from"fs/promises";import{unlink as j_}from"fs/promises";function r1(Y={}){let Z=new AbortController;return{$:IY({cancelSignal:Z.signal,...Y,verbose:aQ}),abort:()=>Z.abort(),signal:Z.signal}}async function z4(Y){let Z=__({input:process.stdin,output:process.stdout});return new Promise((Q)=>{Z.question(Y,(J)=>{Z.close(),Q(J.trim())})})}async function M6(Y){return await uq(Y,async()=>{if(Y.includes(s1.sep)){let X=s1.resolve(Y);return await k5(X)?X:null}let Z=process.platform==="win32",Q=[""];if(Z)Q=["",...(process.env.PATHEXT||".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH").split(";").filter(Boolean)];let J=[];if(J.push(process.cwd()),process.argv[1])J.push(s1.dirname(process.argv[1]));if(J.push(s1.dirname(process.execPath)),process.env.PATH)J.push(...process.env.PATH.split(s1.delimiter));let z=[...new Set(J)];for(let X of z){if(!X)continue;for(let H of Q){let W=s1.join(X,Y+H);if(await k5(W))return W}}return null})}async function X2(Y){try{switch(process.platform){case"win32":return await S({input:Y})`clip`,!0;case"darwin":return await S({input:Y})`pbcopy`,!0;case"linux":try{return await S({input:Y})`xclip -selection clipboard`,!0}catch{return await S({input:Y})`xsel --clipboard --input`,!0}default:return!1}}catch{return!1}}function d0(Y={}){let Z=!Y.message;if(Y={message:"",interval:80,frames:ZX,animateGradient:!1,gradientColor:A.Zinc100,gradientColorBg:A.Zinc700,gradientSpeed:0.11,...Y},!process.stdout.isTTY)return{stop:()=>{},start:(K=!0)=>{if(K)process.stdout.write(`
|
|
364
|
+
`)},options:Y};let Q=0,J=0,z=!0,X=null,H=q(),W=()=>{if(!z)return;let K=Y.frames[Q%Y.frames.length];if(Y.message)if(Y.animateGradient&&qY.supportsColor>=3){let $=J%2;if($<=1){let G=GX.easeInOut($),U=WX(Y.message,Y.gradientColor,Y.gradientColorBg,G,0.3);K+=" "+U}else K+=" "+q(c6(Y.gradientColorBg))+Y.message+H;J+=Y.gradientSpeed??0.1}else K+=" "+Y.message;process.stdout.write("\r\x1B[K"+K),Q++};if(!Z)X=setInterval(W,Y.interval),process.stdout.write("\x1B[?25l"),W();return{stop:()=>{if(z=!1,X)clearInterval(X),X=null;process.stdout.write("\r\x1B[K\x1B[?25h")},start:(K=!0)=>{if(!z)process.stdout.write("\x1B[?25l"+(K?`
|
|
365
|
+
`:"")),z=!0,X=setInterval(W,Y.interval)},options:Y}}async function lq(Y){let Q=(await q0()).getAll().defaultEditor,J=await M6(Q);if(!J)throw new n(`Default editor "${Q}" not found in PATH. Set a valid editor in the configuration.`,"EDITOR_NOT_FOUND");await B0`${J} ${Y}`}async function iq(Y){if(!Y){if(u6)await j_(u6).catch(()=>{});l.exitCodeOverride=-1;return}if(u6)await I_(u6,Y,"utf-8");l.exitCodeOverride=m6}function nq(Y){let Z=[],Q="",J=!1,z=!1;for(let X=0;X<Y.length;X++){let H=Y[X];if(H==="'"&&!z)J=!J;else if(H==='"'&&!J)z=!z;else if(H===" "&&!J&&!z){if(Q)Z.push(Q),Q=""}else Q+=H}if(Q)Z.push(Q);return Z}async function H2(Y,Z,Q=null,J=">"){let z=0;try{if(Q){let{exitCode:X}=await IY({stdout:{file:Q,append:J===">>"},stderr:"inherit"})`${Y} ${Z}`;z=X}else{let{exitCode:X}=await B0`${Y} ${Z}`;z=X}}catch(X){let H=n.from(X);if(H.name===n0.name&&H.message.startsWith("Command failed"))return z||1;return D.error(`Command failed.
|
|
366
|
+
`+d(H,{color:!0})),1}return z??0}function aQ(Y,Z){if(Z.type!=="duration")return;let Q="done";if(Z.result.failed)Q="FAILED";else if(Z.result.timedOut)Q="TIMEOUT";else if(Z.result.isCanceled)Q="CANCELED";else if(Z.result.isTerminated)Q="TERMINATED";T_.debug(`${k_+pq}$ ${C_+Z.escapedCommand+pq} (${Q} in ${Z.result.durationMs}ms)`)}var T_,pq,C_,k_,cq=()=>process.stdout.isTTY&&process.stdin.isTTY,S,B0;var k0=R(()=>{e8();z0();M0();T0();W0();FY();C0();dq();$0();T_=new D("shell"),pq=q("Dim"),C_=q(),k_=q("Bright"),S=IY({stdout:"pipe",stderr:"pipe",verbose:aQ});B0=IY({stdout:"inherit",stderr:"inherit",verbose:aQ})});import rQ from"crypto";import H0 from"path";function g0(Y,Z){let Q=rQ.createHash("sha1").update(Z).digest("hex");return`${Y}.${Q}`}function RY(Y,Z){let Q=Array.isArray(Y)?Y.join(" "):Y,J=Z?H0.resolve(Z):process.cwd();return`${Q}|${J}`}async function G2(Y){try{await S`${Y} rev-parse --is-inside-work-tree`}catch{return D.error("This command must be run inside a git repository.","git"),!1}return!0}async function tQ(Y,Z){let Q=await X0(),J=g0("git.stashEntry",`${RY(Y)}|${Z}`),z=await Q.getOneOff(J);if(z!==void 0)return z;try{let X=`stash@{${Z}}`,{stdout:H}=await S`${Y} rev-parse ${X}`,{stdout:W}=await S`${Y} log -1 --format=%s ${X}`,K={sha:H.trim(),message:W.trim()};return await Q.setOneOff(J,K),K}catch{return await Q.setOneOff(J,null),null}}async function oq(Y,Z,Q){await S`${Y} stash store -m ${Q} ${Z}`}function A_(Y){let Z=Y.trim();if(!Z)return"";Z=Z.replace(/\\+/g,"/");let Q=Z.match(/^(?:[^@]+@)?([^:/]+):(.+)$/);if(Q&&!Z.includes("://")){let J=Q[1].toLowerCase(),z=Q[2];return sQ(J,z)}try{let J=new URL(Z),z=J.hostname.toLowerCase(),X=J.pathname;return sQ(z,X)}catch{return sQ("",Z)}}async function x_(Y){let Z=await X0(),Q=g0("git.defaultRemoteName",RY(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z=null;try{let{stdout:X}=await S`${Y} remote`,H=X.trim().split(`
|
|
367
|
+
`).map((W)=>W.trim()).filter(Boolean);if(H.length===0)z=null;else{let W="";try{let{stdout:K}=await S`${Y} rev-parse --abbrev-ref HEAD`,$=K.trim();if($&&$!=="HEAD"){let{stdout:G}=await S`${Y} config branch.${$}.remote`;W=G.trim()}}catch{W=""}if(W&&H.includes(W))z=W;else if(H.includes("origin"))z="origin";else z=H[0]}}catch{z=null}return await Z.setOneOff(Q,z),z}async function sq(Y){let Z=await X0(),Q=g0("git.normalizedRemoteUrl",RY(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z=await x_(Y);if(!z)return await Z.setOneOff(Q,null),null;try{let{stdout:X}=await S`${Y} remote get-url ${z}`,H=X.trim();if(!H)return await Z.setOneOff(Q,null),null;let K=A_(H)||null;return await Z.setOneOff(Q,K),K}catch{return await Z.setOneOff(Q,null),null}}async function rq(Y){let Z=await X0(),Q=g0("git.mainWorktreeRoot",RY(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z="";try{let{stdout:X}=await S`${Y} rev-parse --show-toplevel`;z=X.trim()}catch{z=process.cwd()}try{let{stdout:X}=await S`${Y} rev-parse --git-common-dir`,H=X.trim();if(!H)return await Z.setOneOff(Q,z),z;let W=H0.isAbsolute(H)?H:H0.resolve(z,H);if(W.replace(/\\/g,"/").includes("/.git/worktrees/")){let U=H0.dirname(H0.dirname(W)),F=H0.dirname(U)||z;return await Z.setOneOff(Q,F),F}try{let B=Z6(W,"utf-8").split(`
|
|
368
|
+
`).map((F)=>F.trim()).find((F)=>F.toLowerCase().startsWith("gitdir:"));if(B){let F=B.split(":").slice(1).join(":").trim(),V=H0.isAbsolute(F)?F:H0.resolve(z,F);if(V.replace(/\\/g,"/").includes("/.git/worktrees/")){let N=H0.dirname(H0.dirname(V)),L=H0.dirname(N)||z;return await Z.setOneOff(Q,L),L}}}catch{}let G=H0.dirname(W)||z;return await Z.setOneOff(Q,G),G}catch{return await Z.setOneOff(Q,z),z}}async function $2(Y,Z){let Q=await X0(),J=g0("git.cherryPickInProgress",`${RY(Y,Z)}|${H0.resolve(Z)}`),z=await Q.getOneOff(J);if(z!==void 0)return z;try{return await S`${Y} -C ${Z} rev-parse -q --verify CHERRY_PICK_HEAD`,await Q.setOneOff(J,!0),!0}catch{return await Q.setOneOff(J,!1),!1}}async function O6(Y,Z){let Q=await X0(),J=`git.config.${Z}`,z=await Q.get(J);if(z!==void 0)return D.debug(`Cache hit for ${J}`,"cache-ctrl"),z;try{let{stdout:X}=await S`${Y} config ${Z}`,H=X.trim();if(H)await Q.set(J,H),D.debug(`Cache store for ${J}: ${H}`,"cache-ctrl");return H}catch(X){return D.warn(`Git config ${Z} not found or failed`,"cache-ctrl"),D.debug(`Error details: ${n.from(X)}`,"cache-ctrl"),""}}async function tq(Y,Z=!1){let Q=await X0(),J=`git.branches${Z?".remote":""}`,z=await Q.get(J);if(z)return D.debug(`Cache hit for ${J}`,"cache-ctrl"),z;try{let X=Z?["for-each-ref","--format=%(refname:short)","refs/remotes/"]:["for-each-ref","--format=%(refname:short)","refs/heads/"],{stdout:H}=await S`${Y} ${X}`,W=H.trim().split(`
|
|
369
|
+
`).filter((K)=>K.length>0);return await Q.set(J,W),D.debug(`Cache store for ${J}: ${W.length} branches`,"cache-ctrl"),W}catch(X){return D.warn(`Failed to get git branches: ${n.from(X)}`,"cache-ctrl"),[]}}async function E_(Y){let Z=await X0(),Q=g0("git.trackedUpstreamRef",RY(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;let z=r1();try{let{stdout:X}=await z.$`${Y} rev-parse --abbrev-ref --symbolic-full-name @{u}`,H=X.trim();return await Z.setOneOff(Q,H),H||null}catch{return null}}async function eq(Y){let Z=await X0(),Q="git.version",J=await Z.get("git.version");if(J)return D.debug("Cache hit for git.version","cache-ctrl"),J;try{let{stdout:z}=await S`${Y} --version`,X=z.trim().match(/(\d{1,2}\.\d{1,3}\.\d{1,3})/i)?.[1]||"unknown";return await Z.set("git.version",X),D.debug(`Cache store for git.version: ${X}`,"cache-ctrl"),X}catch(z){throw D.warn(`Failed to get git version: ${z}`,"cache-ctrl"),z}}async function HY(Y){let Z=await X0(),Q=process.cwd(),J=Array.isArray(Y)?Y.join(" "):Y,X="git.repoRoot."+rQ.createHash("sha1").update(`${J}|${Q}`).digest("hex"),H=await Z.get(X);if(H&&o(H))return D.debug(`Cache hit for ${X}`,"cache-ctrl"),H;try{let{stdout:W}=await S`${Y} rev-parse --show-toplevel`,K=W.trim();return await Z.set(X,K),D.debug(`Cache store for ${X}: ${K}`,"cache-ctrl"),K}catch(W){throw D.warn(`Failed to get repo root: ${W}`,"cache-ctrl"),W}}function aq(Y){let Z=H0.resolve(Y).replace(/\\/g,"/");return process.platform==="win32"?Z.toLowerCase():Z}async function P_(Y){let Z=await X0(),Q=g0("git.worktreeList",RY(Y)),J=await Z.getOneOff(Q);if(J!==void 0)return J;try{let z=(await S`${Y} worktree list --porcelain`).stdout.trim();if(!z)return await Z.setOneOff(Q,[]),[];let X=[],H=null;for(let W of z.split(`
|
|
370
|
+
`)){if(!W.trim())continue;if(W.startsWith("worktree ")){if(H)X.push(H);H={path:W.slice(9).trim(),locked:!1,lockReason:null,prunable:!1};continue}if(!H)continue;if(W.startsWith("locked")){H.locked=!0;let K=W.slice(6).trim();H.lockReason=K.length>0?K:null}else if(W.startsWith("prunable"))H.prunable=!0}if(H)X.push(H);return await Z.setOneOff(Q,X),X}catch(z){return D.debug(d(z,{color:!0}),"git"),await Z.setOneOff(Q,[]),[]}}async function eQ(Y){let Z=await X0(),Q=g0("git.worktreeList",RY(Y));await Z.deleteOneOff(Q)}async function Y9(Y,Z){let Q=await P_(Y),J=aq(Z);return Q.find((z)=>aq(z.path)===J)??null}async function q2(Y){try{await S`${Y} worktree prune --expire now`}catch(Z){D.debug(d(Z,{color:!0}),"git")}finally{await eQ(Y)}}async function K2(Y,Z,Q){let J=await X0(),z=`${RY(Y,Z)}|${Q}`,X=g0("git.path",z),H=await J.get(X);if(H!==void 0)return H;try{let W=(await S`${Y} -C ${Z} rev-parse --git-path ${Q}`).stdout.trim();if(!W)return await J.set(X,null,{maxAgeMinutes:oQ}),null;let K=H0.isAbsolute(W)?W:H0.resolve(Z,W);return await J.set(X,K,{maxAgeMinutes:oQ}),K}catch{return await J.set(X,null,{maxAgeMinutes:oQ}),null}}async function S_(Y,Z){let Q=await K2(Y,Z,"HEAD");if(!Q)return null;let J=await C8(Q),z,X="";try{let W=Z6(Q,"utf-8").trim().match(/^ref:\s*(.+)$/i);if(W?.[1]){if(X=W[1].trim(),X){let K=await K2(Y,Z,X);z=await C8(K)}}}catch{}return`${J??"null"}|${X}|${z??"null"}`}async function nY(Y,Z,Q){let J=await X0(),z=Array.isArray(Q)?Q:Q.trim().split(/\s+/).filter(Boolean),X=z.join(" "),H=`${Y}|${H0.resolve(Z)}|${X}`,W=g0("git.revParse",H),K=z.length===1&&z[0]==="HEAD"||z.length===2&&z[0]==="--abbrev-ref"&&z[1]==="HEAD",$=K?await S_(Y,Z):null;if(K&&$!==null){let G=await J.get(W);if(G&&G.signature===$)return G.value}else{let G=await J.get(W);if(G!==void 0)return G}try{let G=["-C",Z,"rev-parse",...z],U=(await S`${Y} ${G}`).stdout.trim();if(K&&$!==null)await J.set(W,{value:U,signature:$},{maxAgeMinutes:W2});else await J.set(W,U,{maxAgeMinutes:W2});return U}catch{if(K&&$!==null)await J.set(W,{value:"",signature:$},{maxAgeMinutes:W2});else await J.set(W,"",{maxAgeMinutes:W2});return""}}async function YU(Y,Z){let Q=[{label:"merge",path:"MERGE_HEAD"},{label:"cherry-pick",path:"CHERRY_PICK_HEAD"},{label:"revert",path:"REVERT_HEAD"},{label:"rebase",path:"rebase-apply"},{label:"rebase",path:"rebase-merge"},{label:"bisect",path:"BISECT_LOG"},{label:"sequencer",path:"sequencer"}],J=new Set;for(let z of Q){let X=await K2(Y,Z,z.path);if(!X)continue;if(o(X))J.add(z.label)}return Array.from(J)}async function t1(Y,Z){let Q=Array.isArray(Y)?Y[0]:Y,J=await X0(),z=RY(Y,Z),X=g0("git.submodules.paths",z),H=g0("git.submodules.gitlinks",z),W=H0.join(Z,".gitmodules"),K=await C8(W)??null,$=null,G=await J.get(H);try{let U=[],B=await J.get(X);if(B&&B.mtime===K)U=B.paths;else if(K!==null){try{U=(await S`${Q} -C ${Z} config --file .gitmodules --get-regexp path`).stdout.trim().split(`
|
|
371
|
+
`).map((I)=>I.trim()).filter((I)=>I.length>0).map((I)=>{return I.match(/^submodule\.(.+?)\.path\s+(.+)$/)?.[2]?.trim()??""}).filter((I)=>I.length>0)}catch{U=[]}await J.set(X,{mtime:K,paths:U})}else if(B&&B.mtime===null)U=B.paths;let F=[],V=new Map;if($===null)$=await C8(await K2(Y,Z,"index"))??null;if(G&&G.mtime===$&&$!==null)F=G.paths;else{try{let I=(await S`${Q} -C ${Z} ls-files --stage`).stdout.split(`
|
|
372
|
+
`).map((T)=>T.trim()).filter((T)=>T.startsWith("160000 ")).map((T)=>{let y=T.match(/^160000 ([0-9a-f]{40}) (\d)\t(.+)$/);return y?{sha:y[1],stage:y[2],path:y[3].trim()}:null}).filter((T)=>!!T).filter((T)=>T.path.length>0);V=new Map(I.map((T)=>[T.path,{sha:T.sha,stage:T.stage}])),F=Array.from(V.keys())}catch{F=[]}await J.set(H,{mtime:$,paths:F})}let O=new Set([...U,...F]);if(O.size===0)return[];let N=Array.from(O);return(await Promise.all(N.map(async(L)=>{let I=V.get(L);if(I&&I.stage!=="0")return{path:L,status:"U"};let T=H0.resolve(Z,L),y=H0.join(T,".git");if(!o(T)||!o(y))return{path:L,status:"-"};if(!I?.sha)return{path:L,status:" "};let E=(await nY(Q,T,"HEAD")).trim(),P=E&&E!==I.sha?"+":" ";return{path:L,status:P}}))).map((L)=>{return{path:L.path,status:L.status,initialized:L.status!=="-"}})}catch(U){return D.debug(d(U,{color:!0}),"git"),[]}}async function ZU(Y,Z){let Q=await X0(),J=RY(Y,Z);await Q.delete(g0("git.submodules.paths",J)),await Q.delete(g0("git.submodules.gitlinks",J))}async function QU(Y,Z,Q){let J=Array.isArray(Y)?Y[0]:Y,z=[];for(let X of Q){if(X.status==="U"){z.push(X.path);continue}let H=H0.resolve(Z,X.path);if(!o(H))continue;let W=H0.join(H,".git");if(!o(W)){if(X.status!=="-")try{if(J6(H).length>0)z.push(X.path)}catch{z.push(X.path)}continue}try{if((await S`${J} -C ${H} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0)z.push(X.path)}catch{z.push(X.path)}}return z}async function JU(Y,Z){let Q=Array.isArray(Y)?Y[0]:Y;await S`${Q} -C ${Z} submodule deinit -f --all`,await ZU(Y,Z);let J=await t1(Y,Z);if(J.length===0)return;for(let z of J){let X=H0.resolve(Z,z.path);try{if(o(X))x1(X,{recursive:!0,force:!0});ZY(X,{recursive:!0})}catch(H){D.debug(`Failed to clean submodule path '${X}'. ${d(H,{color:!0})}`,"git")}}try{let z=(await S`${Q} -C ${Z} rev-parse --git-dir`).stdout.trim();if(z){let X=H0.isAbsolute(z)?z:H0.resolve(Z,z);if(X.replace(/\\/g,"/").includes("/.git/worktrees/")){let W=H0.join(X,"modules");if(o(W))x1(W,{recursive:!0,force:!0})}}}catch(z){D.debug(`Failed to clean worktree submodule metadata. ${d(z,{color:!0})}`,"git")}}async function zU(Y,Z){if((await t1(Y,Z)).length===0)return;await S`${Y} -c protocol.file.allow=always -C ${Z} submodule update --init --recursive`,await ZU(Y,Z)}function XU(Y){if(!(Y instanceof n0))return!1;let Z=`${Y.stderr||""}
|
|
373
|
+
${Y.stdout||""}
|
|
374
|
+
${Y.message||""}`.toLowerCase();return Z.includes("the previous cherry-pick is now empty")||Z.includes("the patch is empty")||Z.includes("previous cherry-pick is now empty")||Z.includes("cherry-pick is now empty")}async function U2(Y,Z){try{return(await S`${Y} -C ${Z} diff --name-only --diff-filter=U`).stdout.split(`
|
|
375
|
+
`).map((J)=>J.trim()).filter((J)=>J.length>0)}catch{return[]}}async function HU(Y,Z){let Q=await U2(Y,Z);if(Q.length===0)return;await B0`${Y} -C ${Z} add -A -- ${Q}`}async function WU(Y,Z){if((await U2(Y,Z)).length>0)return!1;try{if((await S`${Y} -C ${Z} diff --cached --name-only`).stdout.trim().length>0)return!1}catch{return!1}return!0}async function Z9(Y){let{gitExec:Z,repoPath:Q,range:J,maxCount:z,formatTemplate:X}=Y,H="";try{let U=["-C",Q,"log",`--pretty=format:${X||"%h %s"}`,J];H=(await S`${Z} ${U}`).stdout.trim()}catch{H=""}let W=H.split(`
|
|
376
|
+
`).map((U)=>U.trim()).filter((U)=>U.length>0),K=W.length;if(K===0)return{commits:[],totalCount:0,moreCount:0};let $=z&&z>0?W.slice(0,z):W,G=Math.max(K-$.length,0);return{commits:$,totalCount:K,moreCount:G}}async function Q9(Y,Z,Q,J){let z=await X0(),X=`${Y}|${H0.resolve(Z)}|${Q}|${J}`,H=g0("git.submoduleBaseSha",X),W=await z.get(H);if(W!==void 0)return W;try{let K=(await S`${Y} -C ${Z} ls-tree ${Q} -- ${J}`).stdout.trim();if(!K)return await z.set(H,null),null;let G=K.match(/^160000\s+commit\s+([0-9a-f]{7,40})\s+/i)?.[1]??null;return await z.set(H,G),G}catch{return await z.set(H,null),null}}function J9(){if(qY.supportsColor<=0)return[];return["-c","color.ui=always"]}async function B2(Y,Z,Q=0){for(let J=Q;J<Y.length;J++){let z=/^(head|origin)?~(\d+)?$/i.exec(Y[J]);if(!z)continue;let X=0;if(z[2]){if(X=parseInt(z[2],10),isNaN(X)||X<0)return D.error(`Invalid relative ref format: ${Y[J]}`,"reset"),{error:new n(`Invalid relative ref format: ${Y[J]}`)}}try{if(z[1]?.toLowerCase()==="origin"){let H=await E_(Z);if(!H)return D.error("No upstream configured for current branch.","reset"),{error:new n("No upstream configured for current branch.")};Y[J]=`${H}~${X}`;break}else Y[J]=`HEAD~${X}`}catch(H){return D.error(`Failed to expand relative ref: ${n.from(H)}`,"reset"),{error:n.from(H)}}}return{value:void 0}}function sQ(Y,Z){let Q=Z.replace(/^[/:]+/,"");if(Q=Q.replace(/\.git$/i,""),Q=Q.replace(/\/+$/,""),Y)return`${Y}/${Q}`;return Q}var W2=360,oQ=360;var WY=R(()=>{z0();R6();u0();$0();k0();e8()});import KU from"path";import X4 from"fs";import v_ from"crypto";async function y_(Y){try{let Z=await HY(Y),Q=b_(Z);if(!Q)return D.error("No stash drop to pardon.","stash"),1;j(q("Cyan")+`Restoring ${Q.entries.length} dropped stash(es)...`+q());for(let J of Q.entries)await oq(Y,J.sha,J.message),j(q("Green")+` + Restored: ${J.message}`+q());return 0}catch(Z){return D.error("Error pardoning stash: "+Z,"stash"),1}}async function GU(Y,Z,Q){let[J,z]=Z[2].split("..").map((H)=>parseInt(H,10));if(isNaN(J)||isNaN(z)||J>z)return D.error(`Invalid stash range: ${Z[2]}`,"stash"),1;let X=[];try{let H=await HY(Y),W=[];for(let K=z;K>=J;K--)W.push(tQ(Y,K));if(X=(await Promise.all(W)).filter((K)=>K!=null),X.length>0)BU(H,{timestamp:Date.now(),entries:X,type:"range"},Q)}catch(H){let W=n.from(H);D.warn(`Could not capture stash entry for undo. (${W.name})`,"stash"),D.debug(W.toString(),"stash")}j(q("Cyan")+`Dropping stashes from ${q("Bright")+J+q()+q("Cyan")} to ${q("Bright")+z+q()+q("Cyan")} (inclusive)`+q());for(let H=z;H>=J;H--)await B0`${Y} stash drop stash@{${H}}`;return 0}async function f_(Y,Z){if(Z[2]==="pardon")return await y_(Y);let J=(await q0()).get("stash.undoLimit")??10;if(Z[2]&&/\d+\.\.\d+$/.test(Z[2]))return await GU(Y,Z,J);let z=0,X=Z.slice(2).filter((H)=>!H.startsWith("-"));if(X.length>0)if(X[0].includes(".."));else{let H=X[0].match(/stash@\{(\d+)\}/)||X[0].match(/^(\d+)$/);if(H)z=parseInt(H[1],10)}try{let H=await tQ(Y,z);if(H){let W=await HY(Y);BU(W,{timestamp:Date.now(),entries:[H],type:"single"},J)}}catch(H){D.warn(`Could not capture stash entry for undo. (${n.from(H).name})`,"stash")}try{return await B0`${Y} ${Z}`,0}catch{return 1}}function $U(Y){let Z=v_.createHash("sha256").update(Y).digest("hex"),Q=KU.join(hY,"gdx","stash-undo");if(!X4.existsSync(Q))X4.mkdirSync(Q,{recursive:!0});return KU.join(Q,`${Z}.json`)}function qU(Y){let Z=$U(Y);if(!X4.existsSync(Z))return[];try{let Q=X4.readFileSync(Z,"utf-8");return JSON.parse(Q)}catch{return[]}}function UU(Y,Z){let Q=$U(Y);X4.writeFileSync(Q,JSON.stringify(Z,null,2))}function BU(Y,Z,Q=10){let J=qU(Y);if(J.push(Z),J.length>Q)J.splice(0,J.length-Q);UU(Y,J)}function b_(Y){let Z=qU(Y);if(Z.length===0)return null;let Q=Z.pop()||null;return UU(Y,Z),Q}var VU,FU,RU;var V2=R(()=>{z0();k0();M0();W0();W0();T0();WY();FY();$0();C0();VU={dropRange:GU,drop:f_},FU={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
377
|
+
${Y+u("STASH DROP",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
364
378
|
Remove a stash entry or a range of stash entries.
|
|
365
379
|
|
|
366
|
-
${
|
|
380
|
+
${Y+u("DESCRIPTION",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
367
381
|
Accepts a single stash index, a range like <start>..<end>, or defaults to the latest stash.
|
|
368
382
|
Includes safety features:
|
|
369
|
-
- **Undoable**: You can restore the last dropped stash(es) with
|
|
383
|
+
- **Undoable**: You can restore the last dropped stash(es) with \`${Z}${C} stash drop pardon${Q}\`.
|
|
370
384
|
|
|
371
|
-
${
|
|
372
|
-
-
|
|
373
|
-
-
|
|
374
|
-
-
|
|
385
|
+
${Y+u("COMMANDS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
386
|
+
- \`${Z}drop <index>${Q}\`: Drop specific stash.
|
|
387
|
+
- \`${Z}drop <start>..<end>${Q}\`: Drop range of stashes.
|
|
388
|
+
- \`${Z}drop pardon${Q}\`: Undo the last drop operation.
|
|
375
389
|
|
|
376
|
-
${
|
|
377
|
-
Dropped stashes are backed up temporarily. Use
|
|
378
|
-
`,Math.min(100,
|
|
379
|
-
${
|
|
390
|
+
${Y+u("SAFETY",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
391
|
+
Dropped stashes are backed up temporarily. Use \`${Z}pardon${Q}\` to bring them back.
|
|
392
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Drop stash entries with undo support (e.g. 0..3, pardon).",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
393
|
+
${Y}${C} stash drop ${Z}[<stash> | <range> | pardon]${Q}
|
|
380
394
|
|
|
381
395
|
Examples:
|
|
382
|
-
${
|
|
383
|
-
${
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
${
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
${U("Bright")+u("GRAPH",C.Zinc400,C.Zinc100,0.2)}
|
|
396
|
+
${Y}${C} stash drop 0..0 ${Q+Z}# Drop the most recent stash${Q}
|
|
397
|
+
${Y}${C} stash drop pardon ${Q+Z}# Restore last dropped stash${Q}
|
|
398
|
+
${Y}${C} stash l ${Q+Z}# Show stash list (alias for ${C} stash list).${Q}
|
|
399
|
+
${Y}${C} stash d 3 ${Q+Z}# Drop stash@{3}.${Q}
|
|
400
|
+
${Y}${C} stash d 2..5 ${Q+Z}# Drop stash@{5}, stash@{4}, stash@{3}, stash@{2} (safe ordering).${Q}
|
|
401
|
+
${Y}${C} stash p 1 ${Q+Z}# Pop stash@{1}.${Q}
|
|
402
|
+
${Y}${C} stash c ${Q+Z}# Clear all stashes (maps to ${C} stash clear — destructive).${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},RU={$root:["pardon"]}});async function H4(Y){let{git$:Z,args:Q}=Y,J=Q.popValue("--email")||await O6(Z,"user.email");if(J=J?J.trim().replace(/^["']|["']$/g,""):J,!J)return D.error('User email not configured. Please set it using "git config user.email <email>" or provide it with --email option.',"graph"),1;if(!Q.includes("--quiet"))j(q("Cyan")+"Generating commit graph for user: "+q("Yellow")+J+q());let X=l.terminalWidth-MU-OU,H=Math.min(Math.floor(X/F2),52);if(X<DU)return D.error(`Terminal width too small for graph display. Minimum required width is ${DU+MU+OU} columns.`,"graph"),1;let W=new Date,K=new Date(W),$=K.getDay();K.setDate(K.getDate()-$),K.setDate(K.getDate()-H*7);let G=(await S`
|
|
403
|
+
${Z} --no-pager log --all --author=${J} --since=${K.toISOString()} --date=short --format=%ad
|
|
404
|
+
`).stdout.trim(),U={};for(let w of G.split(`
|
|
405
|
+
`)){let L=w.trim();if(L)U[L]=(U[L]||0)+1}let B=1;for(let w of Object.values(U))if(w>B)B=w;j(`
|
|
406
|
+
`+q("Bright")+u("Contribution Graph",A.OceanDeepBlue,A.OceanGreen,0.12,0.83)+` (Max: ${B} commits/day)
|
|
407
|
+
`);let F=" ",V=0,O=-1;for(let w=0;w<=H;w++){let L=new Date(K);L.setDate(L.getDate()+w*7);let I=w*F2;if(L.getMonth()!==O&&I>=V){F+=" ".repeat(I-V);let T=L.toLocaleString("default",{month:"short"});F+=T.padEnd(F2*3," "),V=I+F2*3,O=L.getMonth()}}j(q("Bright")+F+q());let N=[" ","Mon"," ","Wed"," ","Fri"," "];for(let w=0;w<7;w++){let L=q("Bright")+N[w]+q()+" ";for(let I=0;I<=H;I++){let T=new Date(K);if(T.setDate(T.getDate()+I*7+w),T>W){L+=" ";continue}let y=T.toISOString().slice(0,10),E=U[y]||0,P,m="■";if(E===0)P=q("Dim")+q(c6(A.MidnightBlack)),m="▨";else{let g=v0.clamp(E/B,0.15,1),b=HX(A.MidnightBlack,A.OceanGreen,g);P=q(c6(b))}L+=P+m+q()+" "}j(" "+L)}return j(""),0}var MU=6,F2=2,OU=4,DU=12,NU,wU;var W4=R(()=>{k0();M0();z0();T0();W0();$0();C0();WY();NU={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
408
|
+
${Y+u("GRAPH",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
396
409
|
Render a calendar-style contribution graph for a repository author.
|
|
397
410
|
|
|
398
|
-
${
|
|
411
|
+
${Y+u("DESCRIPTION",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
399
412
|
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.
|
|
400
413
|
|
|
401
|
-
${
|
|
402
|
-
Supply ${
|
|
414
|
+
${Y+u("OPTIONS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
415
|
+
Supply ${Z}--email <email>${Q} to override the configured git user email. Use ${Z}--quiet${Q} to suppress informational headers when embedding the graph in other scripts.
|
|
403
416
|
|
|
404
|
-
${
|
|
405
|
-
The graph respects
|
|
406
|
-
`,Math.min(100,
|
|
407
|
-
${
|
|
417
|
+
${Y+u("TERMINAL NOTES",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
418
|
+
The graph respects \`${Z}global.terminalWidth${Q}\`. If the terminal is too narrow the command will bail with an error message.
|
|
419
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Render a calendar-style contribution graph for an author.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
420
|
+
${Y}${C} graph ${Z}[--email <email>] [--quiet]${Q}
|
|
408
421
|
|
|
409
422
|
Examples:
|
|
410
|
-
${
|
|
411
|
-
${
|
|
412
|
-
`).length:0,
|
|
413
|
-
`)){let
|
|
414
|
-
`)){let
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
`),await
|
|
425
|
-
${
|
|
423
|
+
${Y}${C} graph ${Q+Z}# Graph for configured git user${Q}
|
|
424
|
+
${Y}${C} graph --email bob@example.com ${Q+Z}# Graph for specified author${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},wU={$root:["--email","--quiet"]}});function h_(Y){let Z=Y.indexOf("=");if(Z!==-1)return Y.substring(Z+1);return null}function LU(Y){return new J1(Y)}var J1;var R2=R(()=>{J1=class J1 extends Array{constructor(Y){if(Array.isArray(Y))super(...Y);else super(Y)}optionIndexOf(Y,Z=0){for(let Q=Z;Q<this.length;Q++)if(this[Q]===Y||this[Q].startsWith(Y+"="))return Q;return-1}delete(Y){let Z=this.optionIndexOf(Y);if(Z!==-1)return this.splice(Z,1),!0;return!1}popValue(Y,Z=0,Q=!1){let J=this.optionIndexOf(Y,Z);if(J!==-1){let z=null;if(Y.includes("="))z=h_(this[J]),this.splice(J,1);else if(!Q&&J+1<this.length&&!this[J+1].startsWith("-"))z=this[J+1],this.splice(J,2);else this.splice(J,1);return z}return null}popOption(Y,Z=0){let Q=this.optionIndexOf(Y,Z);if(Q!==-1)return this.splice(Q,1),Y;return null}spliceOption(Y,Z,Q=0){let J=this.optionIndexOf(Y,Q);if(J!==-1)return this.splice(J,1,...Z),!0;return!1}hasOption(Y,Z=0){for(let Q=Z;Q<this.length;Q++)if(this[Q]===Y||this[Q].startsWith(Y+"="))return!0;return!1}slice(Y,Z){return new J1(super.slice(Y,Z))}}});async function z9(Y){let Z=r1(),Q=Z.$,{args:J,git$:z}=Y;if(!await G2(z))return 1;let X="",H="Your",W=J.indexOf("--author");try{if(W!==-1&&W+1<J.length)X=J[W+1].trim(),H=X.split("@")[0]+"'s";else X=await O6(z,"user.email")}catch($){return Z.abort(),D.error("Failed to read git config user.email.","stats"),D.error(d($,{color:!0}),"stats"),1}if(!X)return D.error("No user.email configured in git.","stats"),1;let K=d0({message:`Gathering stats for ${X}...`});try{let[$,G,U,B,F,V,O,N]=await Promise.all([HY(z),Q`${z} rev-list --all --count --author=${X}`,Q`${z} rev-list --all --count`,Q`${z} log --all --author=${X} --since=midnight --pretty=tformat:%h`,Q`${z} log --all --author=${X} --pretty=tformat: --numstat`,Q`${z} log --all --pretty=tformat: --numstat`,tq(z),Q`${z} log --all --author=${X} -1 --format=${`%ar ${q()+q("Dim")}[at %h] (on %ad)`+q()}`]),w=$.split(/[\\/]/).pop(),L=G.stdout.trim(),I=U.stdout.trim(),T=B.stdout.trim()?B.stdout.trim().split(`
|
|
425
|
+
`).length:0,y=F.stdout,E=0,P=0;for(let V0 of y.split(`
|
|
426
|
+
`)){let S0=V0.match(/^(\d+)\s+(\d+)/);if(S0)E+=parseInt(S0[1],10),P+=parseInt(S0[2],10)}let m=bY(E*d6.AVG_CHARS_PER_LINE,2,1024)+"iB",g=bY(P*d6.AVG_CHARS_PER_LINE,2,1024)+"iB",b=bY(E/d6.AVG_LINES_PER_FUNCTION,1,1000,!1,0),c=bY(P/d6.AVG_LINES_PER_FUNCTION,1,1000,!1,0),Y0=bY(E/d6.AVG_LINES_PER_FILE,1,1000,!1,0),f=bY(P/d6.AVG_LINES_PER_FILE,1,1000,!1,0),N0=V.stdout,w0=0,P6=0;for(let V0 of N0.split(`
|
|
427
|
+
`)){let S0=V0.match(/^(\d+)\s+(\d+)/);if(S0)w0+=parseInt(S0[1],10),P6+=parseInt(S0[2],10)}let E0=E+P,b0=w0+P6,S6=b0>0?DZ(E0/b0*100,2,!0):"0.00",P0=0,v6="N/A",y6=await Promise.all(O.map(async(V0)=>{let{stdout:S0}=await Q`${z} rev-list --count --author=${X} ${V0}`;return{branch:V0,count:parseInt(S0.trim(),10)}}));for(let{branch:V0,count:S0}of y6)if(S0>P0)P0=S0,v6=V0;let GY=N.stdout.trim()||"Never";return K.stop(),j(` ${q("Dim")+q("Italic")}Showing stats for ${X} in ${w}${q()}
|
|
428
|
+
|
|
429
|
+
─── ${H} Git Stats ───
|
|
430
|
+
Project: ${q("Cyan")}${w}${q()}
|
|
431
|
+
Total Commits: ${q("Green")}${L}${q()} (today: ${T}) / ${q("Yellow")}${I}${q()} (all)
|
|
432
|
+
Total Lines Added: ${q("Green")}+ ${E} lines ${q()}${q("Dim")}(roughly ${m}, ${b} functions or ${Y0} source files)${q()}
|
|
433
|
+
Total Lines Removed: ${q("Red")}- ${P} lines ${q()}${q("Dim")}(roughly ${g}, ${c} functions or ${f} source files)${q()}
|
|
434
|
+
Contributions: ${q("Magenta")}${S6}%${q()} of all lines changed in the project
|
|
435
|
+
Most Active Branch: ${q("Cyan")}${v6}${q()} (${P0} commits)
|
|
436
|
+
Last Commit: ${q("Yellow")}${GY}${q()}
|
|
437
|
+
`),await H4({...Y,args:LU(["--quiet","--author",X])}),0}catch($){return K.stop(),Z.abort(),D.error(d($,{color:!0})),1}}var _U,IU;var M2=R(()=>{z0();k0();M0();W4();R2();W0();C0();T0();$0();WY();_U={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
438
|
+
${Y+u("STATS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
426
439
|
Gather detailed contribution statistics for a git author in this repository.
|
|
427
440
|
|
|
428
|
-
${
|
|
441
|
+
${Y+u("WHAT IT COMPUTES",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
429
442
|
Total commits by the author, today's commits, lines added/removed, rough size estimates (bytes), estimated functions/files added or removed, contribution percentage of the project, most active branch, and time of the last commit.
|
|
430
443
|
|
|
431
|
-
${
|
|
444
|
+
${Y+u("HOW IT WORKS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
432
445
|
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.
|
|
433
446
|
|
|
434
|
-
${
|
|
435
|
-
Use ${
|
|
436
|
-
`,Math.min(100,
|
|
437
|
-
${
|
|
447
|
+
${Y+u("OPTIONS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
448
|
+
Use ${Z}--author <email>${Q} to target a different author than the configured git user.email. Output includes a small visual graph invocation via the \`${Z}graph${Q}\` command by default.
|
|
449
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Show (local) contribution statistics for a repository author.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
450
|
+
${Y}${C} stats ${Z}[--author <email>]${Q}
|
|
438
451
|
|
|
439
452
|
Examples:
|
|
440
|
-
${
|
|
441
|
-
${U("Cyan")}${I} stats --author alice@example.com ${U()+U("Dim")}# Stats for specified author${U()}`,Math.min(100,p.terminalWidth-4),{firstIndent:" ",mode:"softboundery",indent:" "})},UG={$root:["--author"]};Y0();Y0();function g(Y,Z,Q,X,J){if(X==="m")throw TypeError("Private method is not writable");if(X==="a"&&!J)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?Y!==Z||!J:!Z.has(Y))throw TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?J.call(Y,Q):J?J.value=Q:Z.set(Y,Q),Q}function L(Y,Z,Q,X){if(Q==="a"&&!X)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?Y!==Z||!X:!Z.has(Y))throw TypeError("Cannot read private member from an object whose class did not declare it");return Q==="m"?X:Q==="a"?X.call(Y):X?X.value:Z.get(Y)}var r2=function(){let{crypto:Y}=globalThis;if(Y?.randomUUID)return r2=Y.randomUUID.bind(Y),Y.randomUUID();let Z=new Uint8Array(1),Q=Y?()=>Y.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(X)=>(+X^Q()&15>>+X/4).toString(16))};function u1(Y){return typeof Y==="object"&&Y!==null&&(("name"in Y)&&Y.name==="AbortError"||("message"in Y)&&String(Y.message).includes("FetchRequestCanceledException"))}var d1=(Y)=>{if(Y instanceof Error)return Y;if(typeof Y==="object"&&Y!==null){try{if(Object.prototype.toString.call(Y)==="[object Error]"){let Z=Error(Y.message,Y.cause?{cause:Y.cause}:{});if(Y.stack)Z.stack=Y.stack;if(Y.cause&&!Z.cause)Z.cause=Y.cause;if(Y.name)Z.name=Y.name;return Z}}catch{}try{return Error(JSON.stringify(Y))}catch{}}return Error(Y)};class S extends Error{}class $0 extends S{constructor(Y,Z,Q,X){super(`${$0.makeMessage(Y,Z,Q)}`);this.status=Y,this.headers=X,this.requestID=X?.get("x-request-id"),this.error=Z;let J=Z;this.code=J?.code,this.param=J?.param,this.type=J?.type}static makeMessage(Y,Z,Q){let X=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):Q;if(Y&&X)return`${Y} ${X}`;if(Y)return`${Y} status code (no body)`;if(X)return X;return"(no status code or body)"}static generate(Y,Z,Q,X){if(!Y||!X)return new rY({message:Q,cause:d1(Z)});let J=Z?.error;if(Y===400)return new p1(Y,J,Q,X);if(Y===401)return new c1(Y,J,Q,X);if(Y===403)return new l1(Y,J,Q,X);if(Y===404)return new i1(Y,J,Q,X);if(Y===409)return new n1(Y,J,Q,X);if(Y===422)return new a1(Y,J,Q,X);if(Y===429)return new o1(Y,J,Q,X);if(Y>=500)return new s1(Y,J,Q,X);return new $0(Y,J,Q,X)}}class K0 extends $0{constructor({message:Y}={}){super(void 0,void 0,Y||"Request was aborted.",void 0)}}class rY extends $0{constructor({message:Y,cause:Z}){super(void 0,void 0,Y||"Connection error.",void 0);if(Z)this.cause=Z}}class eY extends rY{constructor({message:Y}={}){super({message:Y??"Request timed out."})}}class p1 extends $0{}class c1 extends $0{}class l1 extends $0{}class i1 extends $0{}class n1 extends $0{}class a1 extends $0{}class o1 extends $0{}class s1 extends $0{}class t1 extends S{constructor(){super("Could not parse response content as the length limit was reached")}}class r1 extends S{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class KY extends Error{constructor(Y){super(Y)}}var RR=/^[a-z][a-z0-9+.-]*:/i,qG=(Y)=>{return RR.test(Y)},D0=(Y)=>(D0=Array.isArray,D0(Y)),e2=D0;function Y5(Y){if(typeof Y!=="object")return{};return Y??{}}function VG(Y){if(!Y)return!0;for(let Z in Y)return!1;return!0}function BG(Y,Z){return Object.prototype.hasOwnProperty.call(Y,Z)}function e1(Y){return Y!=null&&typeof Y==="object"&&!Array.isArray(Y)}var FG=(Y,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new S(`${Y} must be an integer`);if(Z<0)throw new S(`${Y} must be a positive integer`);return Z};var RG=(Y)=>{try{return JSON.parse(Y)}catch(Z){return}};var n0=(Y)=>new Promise((Z)=>setTimeout(Z,Y));var _Y="6.14.0";var TG=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"};function MR(){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"}var DR=()=>{let Y=MR();if(Y==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_Y,"X-Stainless-OS":DG(Deno.build.os),"X-Stainless-Arch":MG(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":_Y,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(Y==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_Y,"X-Stainless-OS":DG(globalThis.process.platform??"unknown"),"X-Stainless-Arch":MG(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=LR();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_Y,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_Y,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function LR(){if(typeof navigator>"u"||!navigator)return null;let Y=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:Q}of Y){let X=Q.exec(navigator.userAgent);if(X){let J=X[1]||0,$=X[2]||0,G=X[3]||0;return{browser:Z,version:`${J}.${$}.${G}`}}}return null}var MG=(Y)=>{if(Y==="x32")return"x32";if(Y==="x86_64"||Y==="x64")return"x64";if(Y==="arm")return"arm";if(Y==="aarch64"||Y==="arm64")return"arm64";if(Y)return`other:${Y}`;return"unknown"},DG=(Y)=>{if(Y=Y.toLowerCase(),Y.includes("ios"))return"iOS";if(Y==="android")return"Android";if(Y==="darwin")return"MacOS";if(Y==="win32")return"Windows";if(Y==="freebsd")return"FreeBSD";if(Y==="openbsd")return"OpenBSD";if(Y==="linux")return"Linux";if(Y)return`Other:${Y}`;return"Unknown"},LG,_G=()=>{return LG??(LG=DR())};function wG(){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 Z5(...Y){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...Y)}function MZ(Y){let Z=Symbol.asyncIterator in Y?Y[Symbol.asyncIterator]():Y[Symbol.iterator]();return Z5({start(){},async pull(Q){let{done:X,value:J}=await Z.next();if(X)Q.close();else Q.enqueue(J)},async cancel(){await Z.return?.()}})}function Q5(Y){if(Y[Symbol.asyncIterator])return Y;let Z=Y.getReader();return{async next(){try{let Q=await Z.read();if(Q?.done)Z.releaseLock();return Q}catch(Q){throw Z.releaseLock(),Q}},async return(){let Q=Z.cancel();return Z.releaseLock(),await Q,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function NG(Y){if(Y===null||typeof Y!=="object")return;if(Y[Symbol.asyncIterator]){await Y[Symbol.asyncIterator]().return?.();return}let Z=Y.getReader(),Q=Z.cancel();Z.releaseLock(),await Q}var OG=({headers:Y,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};var DZ="RFC3986",X5=(Y)=>String(Y),LZ={RFC1738:(Y)=>String(Y).replace(/%20/g,"+"),RFC3986:X5},J5="RFC1738";var TZ=(Y,Z)=>(TZ=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),TZ(Y,Z)),a0=(()=>{let Y=[];for(let Z=0;Z<256;++Z)Y.push("%"+((Z<16?"0":"")+Z.toString(16)).toUpperCase());return Y})();var $5=1024,PG=(Y,Z,Q,X,J)=>{if(Y.length===0)return Y;let $=Y;if(typeof Y==="symbol")$=Symbol.prototype.toString.call(Y);else if(typeof Y!=="string")$=String(Y);if(Q==="iso-8859-1")return escape($).replace(/%u[0-9a-f]{4}/gi,function(K){return"%26%23"+parseInt(K.slice(2),16)+"%3B"});let G="";for(let K=0;K<$.length;K+=$5){let H=$.length>=$5?$.slice(K,K+$5):$,W=[];for(let z=0;z<H.length;++z){let q=H.charCodeAt(z);if(q===45||q===46||q===95||q===126||q>=48&&q<=57||q>=65&&q<=90||q>=97&&q<=122||J===J5&&(q===40||q===41)){W[W.length]=H.charAt(z);continue}if(q<128){W[W.length]=a0[q];continue}if(q<2048){W[W.length]=a0[192|q>>6]+a0[128|q&63];continue}if(q<55296||q>=57344){W[W.length]=a0[224|q>>12]+a0[128|q>>6&63]+a0[128|q&63];continue}z+=1,q=65536+((q&1023)<<10|H.charCodeAt(z)&1023),W[W.length]=a0[240|q>>18]+a0[128|q>>12&63]+a0[128|q>>6&63]+a0[128|q&63]}G+=W.join("")}return G};function EG(Y){if(!Y||typeof Y!=="object")return!1;return!!(Y.constructor&&Y.constructor.isBuffer&&Y.constructor.isBuffer(Y))}function G5(Y,Z){if(D0(Y)){let Q=[];for(let X=0;X<Y.length;X+=1)Q.push(Z(Y[X]));return Q}return Z(Y)}var kG={brackets(Y){return String(Y)+"[]"},comma:"comma",indices(Y,Z){return String(Y)+"["+Z+"]"},repeat(Y){return String(Y)}},AG=function(Y,Z){Array.prototype.push.apply(Y,D0(Z)?Z:[Z])},CG,H0={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:PG,encodeValuesOnly:!1,format:DZ,formatter:X5,indices:!1,serializeDate(Y){return(CG??(CG=Function.prototype.call.bind(Date.prototype.toISOString)))(Y)},skipNulls:!1,strictNullHandling:!1};function wR(Y){return typeof Y==="string"||typeof Y==="number"||typeof Y==="boolean"||typeof Y==="symbol"||typeof Y==="bigint"}var K5={};function IG(Y,Z,Q,X,J,$,G,K,H,W,z,q,V,R,B,M,T,D){let _=Y,w=D,N=0,j=!1;while((w=w.get(K5))!==void 0&&!j){let v=w.get(Y);if(N+=1,typeof v<"u")if(v===N)throw RangeError("Cyclic object value");else j=!0;if(typeof w.get(K5)>"u")N=0}if(typeof W==="function")_=W(Z,_);else if(_ instanceof Date)_=V?.(_);else if(Q==="comma"&&D0(_))_=G5(_,function(v){if(v instanceof Date)return V?.(v);return v});if(_===null){if($)return H&&!M?H(Z,H0.encoder,T,"key",R):Z;_=""}if(wR(_)||EG(_)){if(H){let v=M?Z:H(Z,H0.encoder,T,"key",R);return[B?.(v)+"="+B?.(H(_,H0.encoder,T,"value",R))]}return[B?.(Z)+"="+B?.(String(_))]}let x=[];if(typeof _>"u")return x;let f;if(Q==="comma"&&D0(_)){if(M&&H)_=G5(_,H);f=[{value:_.length>0?_.join(",")||null:void 0}]}else if(D0(W))f=W;else{let v=Object.keys(_);f=z?v.sort(z):v}let m=K?String(Z).replace(/\./g,"%2E"):String(Z),b=X&&D0(_)&&_.length===1?m+"[]":m;if(J&&D0(_)&&_.length===0)return b+"[]";for(let v=0;v<f.length;++v){let d=f[v],o=typeof d==="object"&&typeof d.value<"u"?d.value:_[d];if(G&&o===null)continue;let y=q&&K?d.replace(/\./g,"%2E"):d,B0=D0(_)?typeof Q==="function"?Q(b,y):b:b+(q?"."+y:"["+y+"]");D.set(Y,N);let w0=new WeakMap;w0.set(K5,D),AG(x,IG(o,B0,Q,X,J,$,G,K,Q==="comma"&&M&&D0(_)?null:H,W,z,q,V,R,B,M,T,w0))}return x}function NR(Y=H0){if(typeof Y.allowEmptyArrays<"u"&&typeof Y.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof Y.encodeDotInKeys<"u"&&typeof Y.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(Y.encoder!==null&&typeof Y.encoder<"u"&&typeof Y.encoder!=="function")throw TypeError("Encoder has to be a function.");let Z=Y.charset||H0.charset;if(typeof Y.charset<"u"&&Y.charset!=="utf-8"&&Y.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let Q=DZ;if(typeof Y.format<"u"){if(!TZ(LZ,Y.format))throw TypeError("Unknown format option provided.");Q=Y.format}let X=LZ[Q],J=H0.filter;if(typeof Y.filter==="function"||D0(Y.filter))J=Y.filter;let $;if(Y.arrayFormat&&Y.arrayFormat in kG)$=Y.arrayFormat;else if("indices"in Y)$=Y.indices?"indices":"repeat";else $=H0.arrayFormat;if("commaRoundTrip"in Y&&typeof Y.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let G=typeof Y.allowDots>"u"?!!Y.encodeDotInKeys===!0?!0:H0.allowDots:!!Y.allowDots;return{addQueryPrefix:typeof Y.addQueryPrefix==="boolean"?Y.addQueryPrefix:H0.addQueryPrefix,allowDots:G,allowEmptyArrays:typeof Y.allowEmptyArrays==="boolean"?!!Y.allowEmptyArrays:H0.allowEmptyArrays,arrayFormat:$,charset:Z,charsetSentinel:typeof Y.charsetSentinel==="boolean"?Y.charsetSentinel:H0.charsetSentinel,commaRoundTrip:!!Y.commaRoundTrip,delimiter:typeof Y.delimiter>"u"?H0.delimiter:Y.delimiter,encode:typeof Y.encode==="boolean"?Y.encode:H0.encode,encodeDotInKeys:typeof Y.encodeDotInKeys==="boolean"?Y.encodeDotInKeys:H0.encodeDotInKeys,encoder:typeof Y.encoder==="function"?Y.encoder:H0.encoder,encodeValuesOnly:typeof Y.encodeValuesOnly==="boolean"?Y.encodeValuesOnly:H0.encodeValuesOnly,filter:J,format:Q,formatter:X,serializeDate:typeof Y.serializeDate==="function"?Y.serializeDate:H0.serializeDate,skipNulls:typeof Y.skipNulls==="boolean"?Y.skipNulls:H0.skipNulls,sort:typeof Y.sort==="function"?Y.sort:null,strictNullHandling:typeof Y.strictNullHandling==="boolean"?Y.strictNullHandling:H0.strictNullHandling}}function H5(Y,Z={}){let Q=Y,X=NR(Z),J,$;if(typeof X.filter==="function")$=X.filter,Q=$("",Q);else if(D0(X.filter))$=X.filter,J=$;let G=[];if(typeof Q!=="object"||Q===null)return"";let K=kG[X.arrayFormat],H=K==="comma"&&X.commaRoundTrip;if(!J)J=Object.keys(Q);if(X.sort)J.sort(X.sort);let W=new WeakMap;for(let V=0;V<J.length;++V){let R=J[V];if(X.skipNulls&&Q[R]===null)continue;AG(G,IG(Q[R],R,K,H,X.allowEmptyArrays,X.strictNullHandling,X.skipNulls,X.encodeDotInKeys,X.encode?X.encoder:null,X.filter,X.sort,X.allowDots,X.serializeDate,X.format,X.formatter,X.encodeValuesOnly,X.charset,W))}let z=G.join(X.delimiter),q=X.addQueryPrefix===!0?"?":"";if(X.charsetSentinel)if(X.charset==="iso-8859-1")q+="utf8=%26%2310003%3B&";else q+="utf8=%E2%9C%93&";return z.length>0?q+z:""}function SG(Y){let Z=0;for(let J of Y)Z+=J.length;let Q=new Uint8Array(Z),X=0;for(let J of Y)Q.set(J,X),X+=J.length;return Q}var jG;function d6(Y){let Z;return(jG??(Z=new globalThis.TextEncoder,jG=Z.encode.bind(Z)))(Y)}var xG;function z5(Y){let Z;return(xG??(Z=new globalThis.TextDecoder,xG=Z.decode.bind(Z)))(Y)}var E0,C0;class p6{constructor(){E0.set(this,void 0),C0.set(this,void 0),g(this,E0,new Uint8Array,"f"),g(this,C0,null,"f")}decode(Y){if(Y==null)return[];let Z=Y instanceof ArrayBuffer?new Uint8Array(Y):typeof Y==="string"?d6(Y):Y;g(this,E0,SG([L(this,E0,"f"),Z]),"f");let Q=[],X;while((X=PR(L(this,E0,"f"),L(this,C0,"f")))!=null){if(X.carriage&&L(this,C0,"f")==null){g(this,C0,X.index,"f");continue}if(L(this,C0,"f")!=null&&(X.index!==L(this,C0,"f")+1||X.carriage)){Q.push(z5(L(this,E0,"f").subarray(0,L(this,C0,"f")-1))),g(this,E0,L(this,E0,"f").subarray(L(this,C0,"f")),"f"),g(this,C0,null,"f");continue}let J=L(this,C0,"f")!==null?X.preceding-1:X.preceding,$=z5(L(this,E0,"f").subarray(0,J));Q.push($),g(this,E0,L(this,E0,"f").subarray(X.index),"f"),g(this,C0,null,"f")}return Q}flush(){if(!L(this,E0,"f").length)return[];return this.decode(`
|
|
442
|
-
`)}}
|
|
443
|
-
`,"\r"]);
|
|
444
|
-
`);Q.
|
|
445
|
-
`)
|
|
446
|
-
${
|
|
453
|
+
${Y}${C} stats ${Q+Z}# Stats for configured git user${Q}
|
|
454
|
+
${Y}${C} stats --author alice@example.com ${Q+Z}# Stats for specified author${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},IU={$root:["--author"]}});function p(Y,Z,Q,J,z){if(J==="m")throw TypeError("Private method is not writable");if(J==="a"&&!z)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?Y!==Z||!z:!Z.has(Y))throw TypeError("Cannot write private member to an object whose class did not declare it");return J==="a"?z.call(Y,Q):z?z.value=Q:Z.set(Y,Q),Q}function _(Y,Z,Q,J){if(Q==="a"&&!J)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?Y!==Z||!J:!Z.has(Y))throw TypeError("Cannot read private member from an object whose class did not declare it");return Q==="m"?J:Q==="a"?J.call(Y):J?J.value:Z.get(Y)}var KY=()=>{};var X9=function(){let{crypto:Y}=globalThis;if(Y?.randomUUID)return X9=Y.randomUUID.bind(Y),Y.randomUUID();let Z=new Uint8Array(1),Q=Y?()=>Y.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(J)=>(+J^Q()&15>>+J/4).toString(16))};function K4(Y){return typeof Y==="object"&&Y!==null&&(("name"in Y)&&Y.name==="AbortError"||("message"in Y)&&String(Y.message).includes("FetchRequestCanceledException"))}var G4=(Y)=>{if(Y instanceof Error)return Y;if(typeof Y==="object"&&Y!==null){try{if(Object.prototype.toString.call(Y)==="[object Error]"){let Z=Error(Y.message,Y.cause?{cause:Y.cause}:{});if(Y.stack)Z.stack=Y.stack;if(Y.cause&&!Z.cause)Z.cause=Y.cause;if(Y.name)Z.name=Y.name;return Z}}catch{}try{return Error(JSON.stringify(Y))}catch{}}return Error(Y)};var h,O0,_0,z1,X1,$4,q4,U4,B4,V4,F4,R4,M4,O4,D4,aY;var jY=R(()=>{h=class h extends Error{};O0=class O0 extends h{constructor(Y,Z,Q,J){super(`${O0.makeMessage(Y,Z,Q)}`);this.status=Y,this.headers=J,this.requestID=J?.get("x-request-id"),this.error=Z;let z=Z;this.code=z?.code,this.param=z?.param,this.type=z?.type}static makeMessage(Y,Z,Q){let J=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):Q;if(Y&&J)return`${Y} ${J}`;if(Y)return`${Y} status code (no body)`;if(J)return J;return"(no status code or body)"}static generate(Y,Z,Q,J){if(!Y||!J)return new z1({message:Q,cause:G4(Z)});let z=Z?.error;if(Y===400)return new $4(Y,z,Q,J);if(Y===401)return new q4(Y,z,Q,J);if(Y===403)return new U4(Y,z,Q,J);if(Y===404)return new B4(Y,z,Q,J);if(Y===409)return new V4(Y,z,Q,J);if(Y===422)return new F4(Y,z,Q,J);if(Y===429)return new R4(Y,z,Q,J);if(Y>=500)return new M4(Y,z,Q,J);return new O0(Y,z,Q,J)}};_0=class _0 extends O0{constructor({message:Y}={}){super(void 0,void 0,Y||"Request was aborted.",void 0)}};z1=class z1 extends O0{constructor({message:Y,cause:Z}){super(void 0,void 0,Y||"Connection error.",void 0);if(Z)this.cause=Z}};X1=class X1 extends z1{constructor({message:Y}={}){super({message:Y??"Request timed out."})}};$4=class $4 extends O0{};q4=class q4 extends O0{};U4=class U4 extends O0{};B4=class B4 extends O0{};V4=class V4 extends O0{};F4=class F4 extends O0{};R4=class R4 extends O0{};M4=class M4 extends O0{};O4=class O4 extends h{constructor(){super("Could not parse response content as the length limit was reached")}};D4=class D4 extends h{constructor(){super("Could not parse response content as the request was rejected by the content filter")}};aY=class aY extends Error{constructor(Y){super(Y)}}});function W9(Y){if(typeof Y!=="object")return{};return Y??{}}function TU(Y){if(!Y)return!0;for(let Z in Y)return!1;return!0}function CU(Y,Z){return Object.prototype.hasOwnProperty.call(Y,Z)}function N4(Y){return Y!=null&&typeof Y==="object"&&!Array.isArray(Y)}var m_,jU=(Y)=>{return m_.test(Y)},f0=(Y)=>(f0=Array.isArray,f0(Y)),H9,kU=(Y,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new h(`${Y} must be an integer`);if(Z<0)throw new h(`${Y} must be a positive integer`);return Z},AU=(Y)=>{try{return JSON.parse(Y)}catch(Z){return}};var oY=R(()=>{jY();m_=/^[a-z][a-z0-9+.-]*:/i,H9=f0});var TY=(Y)=>new Promise((Z)=>setTimeout(Z,Y));var D6="6.14.0";function u_(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}function p_(){if(typeof navigator>"u"||!navigator)return null;let Y=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:Q}of Y){let J=Q.exec(navigator.userAgent);if(J){let z=J[1]||0,X=J[2]||0,H=J[3]||0;return{browser:Z,version:`${z}.${X}.${H}`}}}return null}var SU=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},d_=()=>{let Y=u_();if(Y==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":EU(Deno.build.os),"X-Stainless-Arch":xU(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(Y==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":EU(globalThis.process.platform??"unknown"),"X-Stainless-Arch":xU(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=p_();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":D6,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},xU=(Y)=>{if(Y==="x32")return"x32";if(Y==="x86_64"||Y==="x64")return"x64";if(Y==="arm")return"arm";if(Y==="aarch64"||Y==="arm64")return"arm64";if(Y)return`other:${Y}`;return"unknown"},EU=(Y)=>{if(Y=Y.toLowerCase(),Y.includes("ios"))return"iOS";if(Y==="android")return"Android";if(Y==="darwin")return"MacOS";if(Y==="win32")return"Windows";if(Y==="freebsd")return"FreeBSD";if(Y==="openbsd")return"OpenBSD";if(Y==="linux")return"Linux";if(Y)return`Other:${Y}`;return"Unknown"},PU,vU=()=>{return PU??(PU=d_())};var K9=()=>{};function yU(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function G9(...Y){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...Y)}function O2(Y){let Z=Symbol.asyncIterator in Y?Y[Symbol.asyncIterator]():Y[Symbol.iterator]();return G9({start(){},async pull(Q){let{done:J,value:z}=await Z.next();if(J)Q.close();else Q.enqueue(z)},async cancel(){await Z.return?.()}})}function $9(Y){if(Y[Symbol.asyncIterator])return Y;let Z=Y.getReader();return{async next(){try{let Q=await Z.read();if(Q?.done)Z.releaseLock();return Q}catch(Q){throw Z.releaseLock(),Q}},async return(){let Q=Z.cancel();return Z.releaseLock(),await Q,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function fU(Y){if(Y===null||typeof Y!=="object")return;if(Y[Symbol.asyncIterator]){await Y[Symbol.asyncIterator]().return?.();return}let Z=Y.getReader(),Q=Z.cancel();Z.releaseLock(),await Q}var bU=({headers:Y,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};var D2="RFC3986",q9=(Y)=>String(Y),N2,U9="RFC1738";var w2=R(()=>{N2={RFC1738:(Y)=>String(Y).replace(/%20/g,"+"),RFC3986:q9}});function gU(Y){if(!Y||typeof Y!=="object")return!1;return!!(Y.constructor&&Y.constructor.isBuffer&&Y.constructor.isBuffer(Y))}function V9(Y,Z){if(f0(Y)){let Q=[];for(let J=0;J<Y.length;J+=1)Q.push(Z(Y[J]));return Q}return Z(Y)}var L2=(Y,Z)=>(L2=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),L2(Y,Z)),CY,B9=1024,hU=(Y,Z,Q,J,z)=>{if(Y.length===0)return Y;let X=Y;if(typeof Y==="symbol")X=Symbol.prototype.toString.call(Y);else if(typeof Y!=="string")X=String(Y);if(Q==="iso-8859-1")return escape(X).replace(/%u[0-9a-f]{4}/gi,function(W){return"%26%23"+parseInt(W.slice(2),16)+"%3B"});let H="";for(let W=0;W<X.length;W+=B9){let K=X.length>=B9?X.slice(W,W+B9):X,$=[];for(let G=0;G<K.length;++G){let U=K.charCodeAt(G);if(U===45||U===46||U===95||U===126||U>=48&&U<=57||U>=65&&U<=90||U>=97&&U<=122||z===U9&&(U===40||U===41)){$[$.length]=K.charAt(G);continue}if(U<128){$[$.length]=CY[U];continue}if(U<2048){$[$.length]=CY[192|U>>6]+CY[128|U&63];continue}if(U<55296||U>=57344){$[$.length]=CY[224|U>>12]+CY[128|U>>6&63]+CY[128|U&63];continue}G+=1,U=65536+((U&1023)<<10|K.charCodeAt(G)&1023),$[$.length]=CY[240|U>>18]+CY[128|U>>12&63]+CY[128|U>>6&63]+CY[128|U&63]}H+=$.join("")}return H};var mU=R(()=>{w2();oY();CY=(()=>{let Y=[];for(let Z=0;Z<256;++Z)Y.push("%"+((Z<16?"0":"")+Z.toString(16)).toUpperCase());return Y})()});function i_(Y){return typeof Y==="string"||typeof Y==="number"||typeof Y==="boolean"||typeof Y==="symbol"||typeof Y==="bigint"}function cU(Y,Z,Q,J,z,X,H,W,K,$,G,U,B,F,V,O,N,w){let L=Y,I=w,T=0,y=!1;while((I=I.get(F9))!==void 0&&!y){let b=I.get(Y);if(T+=1,typeof b<"u")if(b===T)throw RangeError("Cyclic object value");else y=!0;if(typeof I.get(F9)>"u")T=0}if(typeof $==="function")L=$(Z,L);else if(L instanceof Date)L=B?.(L);else if(Q==="comma"&&f0(L))L=V9(L,function(b){if(b instanceof Date)return B?.(b);return b});if(L===null){if(X)return K&&!O?K(Z,I0.encoder,N,"key",F):Z;L=""}if(i_(L)||gU(L)){if(K){let b=O?Z:K(Z,I0.encoder,N,"key",F);return[V?.(b)+"="+V?.(K(L,I0.encoder,N,"value",F))]}return[V?.(Z)+"="+V?.(String(L))]}let E=[];if(typeof L>"u")return E;let P;if(Q==="comma"&&f0(L)){if(O&&K)L=V9(L,K);P=[{value:L.length>0?L.join(",")||null:void 0}]}else if(f0($))P=$;else{let b=Object.keys(L);P=G?b.sort(G):b}let m=W?String(Z).replace(/\./g,"%2E"):String(Z),g=J&&f0(L)&&L.length===1?m+"[]":m;if(z&&f0(L)&&L.length===0)return g+"[]";for(let b=0;b<P.length;++b){let c=P[b],Y0=typeof c==="object"&&typeof c.value<"u"?c.value:L[c];if(H&&Y0===null)continue;let f=U&&W?c.replace(/\./g,"%2E"):c,N0=f0(L)?typeof Q==="function"?Q(g,f):g:g+(U?"."+f:"["+f+"]");w.set(Y,T);let w0=new WeakMap;w0.set(F9,w),pU(E,cU(Y0,N0,Q,J,z,X,H,W,Q==="comma"&&O&&f0(L)?null:K,$,G,U,B,F,V,O,N,w0))}return E}function n_(Y=I0){if(typeof Y.allowEmptyArrays<"u"&&typeof Y.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof Y.encodeDotInKeys<"u"&&typeof Y.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(Y.encoder!==null&&typeof Y.encoder<"u"&&typeof Y.encoder!=="function")throw TypeError("Encoder has to be a function.");let Z=Y.charset||I0.charset;if(typeof Y.charset<"u"&&Y.charset!=="utf-8"&&Y.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let Q=D2;if(typeof Y.format<"u"){if(!L2(N2,Y.format))throw TypeError("Unknown format option provided.");Q=Y.format}let J=N2[Q],z=I0.filter;if(typeof Y.filter==="function"||f0(Y.filter))z=Y.filter;let X;if(Y.arrayFormat&&Y.arrayFormat in dU)X=Y.arrayFormat;else if("indices"in Y)X=Y.indices?"indices":"repeat";else X=I0.arrayFormat;if("commaRoundTrip"in Y&&typeof Y.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let H=typeof Y.allowDots>"u"?!!Y.encodeDotInKeys===!0?!0:I0.allowDots:!!Y.allowDots;return{addQueryPrefix:typeof Y.addQueryPrefix==="boolean"?Y.addQueryPrefix:I0.addQueryPrefix,allowDots:H,allowEmptyArrays:typeof Y.allowEmptyArrays==="boolean"?!!Y.allowEmptyArrays:I0.allowEmptyArrays,arrayFormat:X,charset:Z,charsetSentinel:typeof Y.charsetSentinel==="boolean"?Y.charsetSentinel:I0.charsetSentinel,commaRoundTrip:!!Y.commaRoundTrip,delimiter:typeof Y.delimiter>"u"?I0.delimiter:Y.delimiter,encode:typeof Y.encode==="boolean"?Y.encode:I0.encode,encodeDotInKeys:typeof Y.encodeDotInKeys==="boolean"?Y.encodeDotInKeys:I0.encodeDotInKeys,encoder:typeof Y.encoder==="function"?Y.encoder:I0.encoder,encodeValuesOnly:typeof Y.encodeValuesOnly==="boolean"?Y.encodeValuesOnly:I0.encodeValuesOnly,filter:z,format:Q,formatter:J,serializeDate:typeof Y.serializeDate==="function"?Y.serializeDate:I0.serializeDate,skipNulls:typeof Y.skipNulls==="boolean"?Y.skipNulls:I0.skipNulls,sort:typeof Y.sort==="function"?Y.sort:null,strictNullHandling:typeof Y.strictNullHandling==="boolean"?Y.strictNullHandling:I0.strictNullHandling}}function R9(Y,Z={}){let Q=Y,J=n_(Z),z,X;if(typeof J.filter==="function")X=J.filter,Q=X("",Q);else if(f0(J.filter))X=J.filter,z=X;let H=[];if(typeof Q!=="object"||Q===null)return"";let W=dU[J.arrayFormat],K=W==="comma"&&J.commaRoundTrip;if(!z)z=Object.keys(Q);if(J.sort)z.sort(J.sort);let $=new WeakMap;for(let B=0;B<z.length;++B){let F=z[B];if(J.skipNulls&&Q[F]===null)continue;pU(H,cU(Q[F],F,W,K,J.allowEmptyArrays,J.strictNullHandling,J.skipNulls,J.encodeDotInKeys,J.encode?J.encoder:null,J.filter,J.sort,J.allowDots,J.serializeDate,J.format,J.formatter,J.encodeValuesOnly,J.charset,$))}let G=H.join(J.delimiter),U=J.addQueryPrefix===!0?"?":"";if(J.charsetSentinel)if(J.charset==="iso-8859-1")U+="utf8=%26%2310003%3B&";else U+="utf8=%E2%9C%93&";return G.length>0?U+G:""}var dU,pU=function(Y,Z){Array.prototype.push.apply(Y,f0(Z)?Z:[Z])},uU,I0,F9;var lU=R(()=>{mU();w2();oY();dU={brackets(Y){return String(Y)+"[]"},comma:"comma",indices(Y,Z){return String(Y)+"["+Z+"]"},repeat(Y){return String(Y)}},I0={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:hU,encodeValuesOnly:!1,format:D2,formatter:q9,indices:!1,serializeDate(Y){return(uU??(uU=Function.prototype.call.bind(Date.prototype.toISOString)))(Y)},skipNulls:!1,strictNullHandling:!1};F9={}});var iU=R(()=>{w2();lU()});function oU(Y){let Z=0;for(let z of Y)Z+=z.length;let Q=new Uint8Array(Z),J=0;for(let z of Y)Q.set(z,J),J+=z.length;return Q}function e1(Y){let Z;return(nU??(Z=new globalThis.TextEncoder,nU=Z.encode.bind(Z)))(Y)}function M9(Y){let Z;return(aU??(Z=new globalThis.TextDecoder,aU=Z.decode.bind(Z)))(Y)}var nU,aU;class Y8{constructor(){s0.set(this,void 0),r0.set(this,void 0),p(this,s0,new Uint8Array,"f"),p(this,r0,null,"f")}decode(Y){if(Y==null)return[];let Z=Y instanceof ArrayBuffer?new Uint8Array(Y):typeof Y==="string"?e1(Y):Y;p(this,s0,oU([_(this,s0,"f"),Z]),"f");let Q=[],J;while((J=o_(_(this,s0,"f"),_(this,r0,"f")))!=null){if(J.carriage&&_(this,r0,"f")==null){p(this,r0,J.index,"f");continue}if(_(this,r0,"f")!=null&&(J.index!==_(this,r0,"f")+1||J.carriage)){Q.push(M9(_(this,s0,"f").subarray(0,_(this,r0,"f")-1))),p(this,s0,_(this,s0,"f").subarray(_(this,r0,"f")),"f"),p(this,r0,null,"f");continue}let z=_(this,r0,"f")!==null?J.preceding-1:J.preceding,X=M9(_(this,s0,"f").subarray(0,z));Q.push(X),p(this,s0,_(this,s0,"f").subarray(J.index),"f"),p(this,r0,null,"f")}return Q}flush(){if(!_(this,s0,"f").length)return[];return this.decode(`
|
|
455
|
+
`)}}function o_(Y,Z){for(let z=Z??0;z<Y.length;z++){if(Y[z]===10)return{preceding:z,index:z+1,carriage:!1};if(Y[z]===13)return{preceding:z,index:z+1,carriage:!0}}return null}function sU(Y){for(let J=0;J<Y.length-1;J++){if(Y[J]===10&&Y[J+1]===10)return J+2;if(Y[J]===13&&Y[J+1]===13)return J+2;if(Y[J]===13&&Y[J+1]===10&&J+3<Y.length&&Y[J+2]===13&&Y[J+3]===10)return J+4}return-1}var s0,r0;var rU=R(()=>{KY();s0=new WeakMap,r0=new WeakMap;Y8.NEWLINE_CHARS=new Set([`
|
|
456
|
+
`,"\r"]);Y8.NEWLINE_REGEXP=/\r\n|[\n\r]/g});function w4(){}function _2(Y,Z,Q){if(!Z||I2[Y]>I2[Q])return w4;else return Z[Y].bind(Z)}function R0(Y){let Z=Y.logger,Q=Y.logLevel??"off";if(!Z)return s_;let J=tU.get(Z);if(J&&J[0]===Q)return J[1];let z={error:_2("error",Z,Q),warn:_2("warn",Z,Q),info:_2("info",Z,Q),debug:_2("debug",Z,Q)};return tU.set(Z,[Q,z]),z}var I2,O9=(Y,Z,Q)=>{if(!Y)return;if(CU(I2,Y))return Y;R0(Q).warn(`${Z} was set to ${JSON.stringify(Y)}, expected one of ${JSON.stringify(Object.keys(I2))}`);return},s_,tU,sY=(Y)=>{if(Y.options)Y.options={...Y.options},delete Y.options.headers;if(Y.headers)Y.headers=Object.fromEntries((Y.headers instanceof Headers?[...Y.headers]:Object.entries(Y.headers)).map(([Z,Q])=>[Z,Z.toLowerCase()==="authorization"||Z.toLowerCase()==="cookie"||Z.toLowerCase()==="set-cookie"?"***":Q]));if("retryOfRequestLogID"in Y){if(Y.retryOfRequestLogID)Y.retryOf=Y.retryOfRequestLogID;delete Y.retryOfRequestLogID}return Y};var L4=R(()=>{oY();I2={off:0,error:200,warn:300,info:400,debug:500};s_={error:w4,warn:w4,info:w4,debug:w4},tU=new WeakMap});async function*r_(Y,Z){if(!Y.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new h("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 h("Attempted to iterate over a response with no body")}let Q=new eU,J=new Y8,z=$9(Y.body);for await(let X of t_(z))for(let H of J.decode(X)){let W=Q.decode(H);if(W)yield W}for(let X of J.flush()){let H=Q.decode(X);if(H)yield H}}async function*t_(Y){let Z=new Uint8Array;for await(let Q of Y){if(Q==null)continue;let J=Q instanceof ArrayBuffer?new Uint8Array(Q):typeof Q==="string"?e1(Q):Q,z=new Uint8Array(Z.length+J.length);z.set(Z),z.set(J,Z.length),Z=z;let X;while((X=sU(Z))!==-1)yield Z.slice(0,X),Z=Z.slice(X)}if(Z.length>0)yield Z}class eU{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(Y){if(Y.endsWith("\r"))Y=Y.substring(0,Y.length-1);if(!Y){if(!this.event&&!this.data.length)return null;let z={event:this.event,data:this.data.join(`
|
|
457
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],z}if(this.chunks.push(Y),Y.startsWith(":"))return null;let[Z,Q,J]=e_(Y,":");if(J.startsWith(" "))J=J.substring(1);if(Z==="event")this.event=J;else if(Z==="data")this.data.push(J);return null}}function e_(Y,Z){let Q=Y.indexOf(Z);if(Q!==-1)return[Y.substring(0,Q),Z,Y.substring(Q+Z.length)];return[Y,"",""]}var _4,t0;var D9=R(()=>{KY();jY();rU();L4();jY();t0=class t0{constructor(Y,Z,Q){this.iterator=Y,_4.set(this,void 0),this.controller=Z,p(this,_4,Q,"f")}static fromSSEResponse(Y,Z,Q){let J=!1,z=Q?R0(Q):console;async function*X(){if(J)throw new h("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");J=!0;let H=!1;try{for await(let W of r_(Y,Z)){if(H)continue;if(W.data.startsWith("[DONE]")){H=!0;continue}if(W.event===null||!W.event.startsWith("thread.")){let K;try{K=JSON.parse(W.data)}catch($){throw z.error("Could not parse message into JSON:",W.data),z.error("From chunk:",W.raw),$}if(K&&K.error)throw new O0(void 0,K.error,void 0,Y.headers);yield K}else{let K;try{K=JSON.parse(W.data)}catch($){throw console.error("Could not parse message into JSON:",W.data),console.error("From chunk:",W.raw),$}if(W.event=="error")throw new O0(void 0,K.error,K.message,void 0);yield{event:W.event,data:K}}}H=!0}catch(W){if(K4(W))return;throw W}finally{if(!H)Z.abort()}}return new t0(X,Z,Q)}static fromReadableStream(Y,Z,Q){let J=!1;async function*z(){let H=new Y8,W=$9(Y);for await(let K of W)for(let $ of H.decode(K))yield $;for(let K of H.flush())yield K}async function*X(){if(J)throw new h("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");J=!0;let H=!1;try{for await(let W of z()){if(H)continue;if(W)yield JSON.parse(W)}H=!0}catch(W){if(K4(W))return;throw W}finally{if(!H)Z.abort()}}return new t0(X,Z,Q)}[(_4=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let Y=[],Z=[],Q=this.iterator(),J=(z)=>{return{next:()=>{if(z.length===0){let X=Q.next();Y.push(X),Z.push(X)}return z.shift()}}};return[new t0(()=>J(Y),this.controller,_(this,_4,"f")),new t0(()=>J(Z),this.controller,_(this,_4,"f"))]}toReadableStream(){let Y=this,Z;return G9({async start(){Z=Y[Symbol.asyncIterator]()},async pull(Q){try{let{value:J,done:z}=await Z.next();if(z)return Q.close();let X=e1(JSON.stringify(J)+`
|
|
458
|
+
`);Q.enqueue(X)}catch(J){Q.error(J)}},async cancel(){await Z.return?.()}})}}});async function j2(Y,Z){let{response:Q,requestLogID:J,retryOfRequestLogID:z,startTime:X}=Z,H=await(async()=>{if(Z.options.stream){if(R0(Y).debug("response",Q.status,Q.url,Q.headers,Q.body),Z.options.__streamClass)return Z.options.__streamClass.fromSSEResponse(Q,Z.controller,Y);return t0.fromSSEResponse(Q,Z.controller,Y)}if(Q.status===204)return null;if(Z.options.__binaryResponse)return Q;let K=Q.headers.get("content-type")?.split(";")[0]?.trim();if(K?.includes("application/json")||K?.endsWith("+json")){let U=await Q.json();return N9(U,Q)}return await Q.text()})();return R0(Y).debug(`[${J}] response parsed`,sY({retryOfRequestLogID:z,url:Q.url,status:Q.status,body:H,durationMs:Date.now()-X})),H}function N9(Y,Z){if(!Y||typeof Y!=="object"||Array.isArray(Y))return Y;return Object.defineProperty(Y,"_request_id",{value:Z.headers.get("x-request-id"),enumerable:!1})}var w9=R(()=>{D9();L4()});var I4,H1;var T2=R(()=>{KY();w9();H1=class H1 extends Promise{constructor(Y,Z,Q=j2){super((J)=>{J(null)});this.responsePromise=Z,this.parseResponse=Q,I4.set(this,void 0),p(this,I4,Y,"f")}_thenUnwrap(Y){return new H1(_(this,I4,"f"),this.responsePromise,async(Z,Q)=>N9(Y(await this.parseResponse(Z,Q),Q),Q.response))}asResponse(){return this.responsePromise.then((Y)=>Y.response)}async withResponse(){let[Y,Z]=await Promise.all([this.parse(),this.asResponse()]);return{data:Y,response:Z,request_id:Z.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then((Y)=>this.parseResponse(_(this,I4,"f"),Y));return this.parsedPromise}then(Y,Z){return this.parse().then(Y,Z)}catch(Y){return this.parse().catch(Y)}finally(Y){return this.parse().finally(Y)}};I4=new WeakMap});var C2,k2,A2,rY,Z0,N6;var K0=R(()=>{KY();jY();w9();T2();oY();k2=class k2{constructor(Y,Z,Q,J){C2.set(this,void 0),p(this,C2,Y,"f"),this.options=J,this.response=Z,this.body=Q}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let Y=this.nextPageRequestOptions();if(!Y)throw new h("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await _(this,C2,"f").requestAPIList(this.constructor,Y)}async*iterPages(){let Y=this;yield Y;while(Y.hasNextPage())Y=await Y.getNextPage(),yield Y}async*[(C2=new WeakMap,Symbol.asyncIterator)](){for await(let Y of this.iterPages())for(let Z of Y.getPaginatedItems())yield Z}};A2=class A2 extends H1{constructor(Y,Z,Q){super(Y,Z,async(J,z)=>new Q(J,z.response,await j2(J,z),z.options))}async*[Symbol.asyncIterator](){let Y=await this;for await(let Z of Y)yield Z}};rY=class rY extends k2{constructor(Y,Z,Q,J){super(Y,Z,Q,J);this.data=Q.data||[],this.object=Q.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}};Z0=class Z0 extends k2{constructor(Y,Z,Q,J){super(Y,Z,Q,J);this.data=Q.data||[],this.has_more=Q.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let Y=this.getPaginatedItems(),Z=Y[Y.length-1]?.id;if(!Z)return null;return{...this.options,query:{...W9(this.options.query),after:Z}}}};N6=class N6 extends k2{constructor(Y,Z,Q,J){super(Y,Z,Q,J);this.data=Q.data||[],this.has_more=Q.has_more||!1,this.last_id=Q.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let Y=this.last_id;if(!Y)return null;return{...this.options,query:{...W9(this.options.query),after:Y}}}}});function Z8(Y,Z,Q){return I9(),new File(Y,Z??"unknown_file",Q)}function j4(Y){return(typeof Y==="object"&&Y!==null&&(("name"in Y)&&Y.name&&String(Y.name)||("url"in Y)&&Y.url&&String(Y.url)||("filename"in Y)&&Y.filename&&String(Y.filename)||("path"in Y)&&Y.path&&String(Y.path))||"").split(/[\\/]/).pop()||void 0}function ZI(Y){let Z=typeof Y==="function"?Y:Y.fetch,Q=YB.get(Z);if(Q)return Q;let J=(async()=>{try{let z="Response"in Z?Z.Response:(await Z("data:,")).constructor,X=new FormData;if(X.toString()===await new z(X).text())return!1;return!0}catch{return!0}})();return YB.set(Z,J),J}var I9=()=>{if(typeof File>"u"){let{process:Y}=globalThis,Z=typeof Y?.versions?.node==="string"&&parseInt(Y.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(Z?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}},x2=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y[Symbol.asyncIterator]==="function",j9=async(Y,Z)=>{if(!L9(Y.body))return Y;return{...Y,body:await ZB(Y.body,Z)}},e0=async(Y,Z)=>{return{...Y,body:await ZB(Y.body,Z)}},YB,ZB=async(Y,Z)=>{if(!await ZI(Z))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let Q=new FormData;return await Promise.all(Object.entries(Y||{}).map(([J,z])=>_9(Q,J,z))),Q},QB=(Y)=>Y instanceof Blob&&("name"in Y),QI=(Y)=>typeof Y==="object"&&Y!==null&&(Y instanceof Response||x2(Y)||QB(Y)),L9=(Y)=>{if(QI(Y))return!0;if(Array.isArray(Y))return Y.some(L9);if(Y&&typeof Y==="object"){for(let Z in Y)if(L9(Y[Z]))return!0}return!1},_9=async(Y,Z,Q)=>{if(Q===void 0)return;if(Q==null)throw TypeError(`Received null for "${Z}"; to pass null in FormData, you must use the string 'null'`);if(typeof Q==="string"||typeof Q==="number"||typeof Q==="boolean")Y.append(Z,String(Q));else if(Q instanceof Response)Y.append(Z,Z8([await Q.blob()],j4(Q)));else if(x2(Q))Y.append(Z,Z8([await new Response(O2(Q)).blob()],j4(Q)));else if(QB(Q))Y.append(Z,Q,j4(Q));else if(Array.isArray(Q))await Promise.all(Q.map((J)=>_9(Y,Z+"[]",J)));else if(typeof Q==="object")await Promise.all(Object.entries(Q).map(([J,z])=>_9(Y,`${Z}[${J}]`,z)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${Q} instead`)};var kY=R(()=>{YB=new WeakMap});async function E2(Y,Z,Q){if(I9(),Y=await Y,JI(Y)){if(Y instanceof File)return Y;return Z8([await Y.arrayBuffer()],Y.name)}if(zI(Y)){let z=await Y.blob();return Z||(Z=new URL(Y.url).pathname.split(/[\\/]/).pop()),Z8(await T9(z),Z,Q)}let J=await T9(Y);if(Z||(Z=j4(Y)),!Q?.type){let z=J.find((X)=>typeof X==="object"&&("type"in X)&&X.type);if(typeof z==="string")Q={...Q,type:z}}return Z8(J,Z,Q)}async function T9(Y){let Z=[];if(typeof Y==="string"||ArrayBuffer.isView(Y)||Y instanceof ArrayBuffer)Z.push(Y);else if(JB(Y))Z.push(Y instanceof Blob?Y:await Y.arrayBuffer());else if(x2(Y))for await(let Q of Y)Z.push(...await T9(Q));else{let Q=Y?.constructor?.name;throw Error(`Unexpected data type: ${typeof Y}${Q?`; constructor: ${Q}`:""}${XI(Y)}`)}return Z}function XI(Y){if(typeof Y!=="object"||Y===null)return"";return`; props: [${Object.getOwnPropertyNames(Y).map((Q)=>`"${Q}"`).join(", ")}]`}var JB=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y.size==="number"&&typeof Y.type==="string"&&typeof Y.text==="function"&&typeof Y.slice==="function"&&typeof Y.arrayBuffer==="function",JI=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y.name==="string"&&typeof Y.lastModified==="number"&&JB(Y),zI=(Y)=>Y!=null&&typeof Y==="object"&&typeof Y.url==="string"&&typeof Y.blob==="function";var zB=R(()=>{kY();kY()});var C9=R(()=>{zB()});class x{constructor(Y){this._client=Y}}function HB(Y){return Y.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var XB,WI=(Y=HB)=>function Z(Q,...J){if(Q.length===1)return Q[0];let z=!1,X=[],H=Q.reduce((G,U,B)=>{if(/[?#]/.test(U))z=!0;let F=J[B],V=(z?encodeURIComponent:Y)(""+F);if(B!==J.length&&(F==null||typeof F==="object"&&F.toString===Object.getPrototypeOf(Object.getPrototypeOf(F.hasOwnProperty??XB)??XB)?.toString))V=F+"",X.push({start:G.length+U.length,length:V.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?"":V)},""),W=H.split(/[?#]/,1)[0],K=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,$;while(($=K.exec(W))!==null)X.push({start:$.index,length:$[0].length,error:`Value "${$[0]}" can't be safely passed as a path parameter`});if(X.sort((G,U)=>G.start-U.start),X.length>0){let G=0,U=X.reduce((B,F)=>{let V=" ".repeat(F.start-G),O="^".repeat(F.length);return G=F.start+F.length,B+V+O},"");throw new h(`Path parameters result in path with invalid segments:
|
|
459
|
+
${X.map((B)=>B.error).join(`
|
|
447
460
|
`)}
|
|
448
|
-
${
|
|
449
|
-
${q}`)}return G},O=hR(dG);class l6 extends E{list(Y,Z={},Q){return this._client.getAPIList(O`/chat/completions/${Y}/messages`,n,{query:Z,...Q})}}function J8(Y){return Y!==void 0&&"function"in Y&&Y.function!==void 0}function $8(Y){return Y?.$brand==="auto-parseable-response-format"}function Z6(Y){return Y?.$brand==="auto-parseable-tool"}function pG(Y,Z){if(!Z||!M5(Z))return{...Y,choices:Y.choices.map((Q)=>{return lG(Q.message.tool_calls),{...Q,message:{...Q.message,parsed:null,...Q.message.tool_calls?{tool_calls:Q.message.tool_calls}:void 0}}})};return G8(Y,Z)}function G8(Y,Z){let Q=Y.choices.map((X)=>{if(X.finish_reason==="length")throw new t1;if(X.finish_reason==="content_filter")throw new r1;return lG(X.message.tool_calls),{...X,message:{...X.message,...X.message.tool_calls?{tool_calls:X.message.tool_calls?.map((J)=>uR(Z,J))??void 0}:void 0,parsed:X.message.content&&!X.message.refusal?mR(Z,X.message.content):null}}});return{...Y,choices:Q}}function mR(Y,Z){if(Y.response_format?.type!=="json_schema")return null;if(Y.response_format?.type==="json_schema"){if("$parseRaw"in Y.response_format)return Y.response_format.$parseRaw(Z);return JSON.parse(Z)}return null}function uR(Y,Z){let Q=Y.tools?.find((X)=>J8(X)&&X.function?.name===Z.function.name);return{...Z,function:{...Z.function,parsed_arguments:Z6(Q)?Q.$parseRaw(Z.function.arguments):Q?.function.strict?JSON.parse(Z.function.arguments):null}}}function cG(Y,Z){if(!Y||!("tools"in Y)||!Y.tools)return!1;let Q=Y.tools?.find((X)=>J8(X)&&X.function?.name===Z.function.name);return J8(Q)&&(Z6(Q)||Q?.function.strict||!1)}function M5(Y){if($8(Y.response_format))return!0;return Y.tools?.some((Z)=>Z6(Z)||Z.type==="function"&&Z.function.strict===!0)??!1}function lG(Y){for(let Z of Y||[])if(Z.type!=="function")throw new S(`Currently only \`function\` tool calls are supported; Received \`${Z.type}\``)}function iG(Y){for(let Z of Y??[]){if(Z.type!=="function")throw new S(`Currently only \`function\` tool types support auto-parsing; Received \`${Z.type}\``);if(Z.function.strict!==!0)throw new S(`The \`${Z.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var i6=(Y)=>{return Y?.role==="assistant"},D5=(Y)=>{return Y?.role==="tool"};var L5,AZ,IZ,K8,H8,jZ,z8,WY,W8,xZ,SZ,n6,nG;class Q6{constructor(){L5.add(this),this.controller=new AbortController,AZ.set(this,void 0),IZ.set(this,()=>{}),K8.set(this,()=>{}),H8.set(this,void 0),jZ.set(this,()=>{}),z8.set(this,()=>{}),WY.set(this,{}),W8.set(this,!1),xZ.set(this,!1),SZ.set(this,!1),n6.set(this,!1),g(this,AZ,new Promise((Y,Z)=>{g(this,IZ,Y,"f"),g(this,K8,Z,"f")}),"f"),g(this,H8,new Promise((Y,Z)=>{g(this,jZ,Y,"f"),g(this,z8,Z,"f")}),"f"),L(this,AZ,"f").catch(()=>{}),L(this,H8,"f").catch(()=>{})}_run(Y){setTimeout(()=>{Y().then(()=>{this._emitFinal(),this._emit("end")},L(this,L5,"m",nG).bind(this))},0)}_connected(){if(this.ended)return;L(this,IZ,"f").call(this),this._emit("connect")}get ended(){return L(this,W8,"f")}get errored(){return L(this,xZ,"f")}get aborted(){return L(this,SZ,"f")}abort(){this.controller.abort()}on(Y,Z){return(L(this,WY,"f")[Y]||(L(this,WY,"f")[Y]=[])).push({listener:Z}),this}off(Y,Z){let Q=L(this,WY,"f")[Y];if(!Q)return this;let X=Q.findIndex((J)=>J.listener===Z);if(X>=0)Q.splice(X,1);return this}once(Y,Z){return(L(this,WY,"f")[Y]||(L(this,WY,"f")[Y]=[])).push({listener:Z,once:!0}),this}emitted(Y){return new Promise((Z,Q)=>{if(g(this,n6,!0,"f"),Y!=="error")this.once("error",Q);this.once(Y,Z)})}async done(){g(this,n6,!0,"f"),await L(this,H8,"f")}_emit(Y,...Z){if(L(this,W8,"f"))return;if(Y==="end")g(this,W8,!0,"f"),L(this,jZ,"f").call(this);let Q=L(this,WY,"f")[Y];if(Q)L(this,WY,"f")[Y]=Q.filter((X)=>!X.once),Q.forEach(({listener:X})=>X(...Z));if(Y==="abort"){let X=Z[0];if(!L(this,n6,"f")&&!Q?.length)Promise.reject(X);L(this,K8,"f").call(this,X),L(this,z8,"f").call(this,X),this._emit("end");return}if(Y==="error"){let X=Z[0];if(!L(this,n6,"f")&&!Q?.length)Promise.reject(X);L(this,K8,"f").call(this,X),L(this,z8,"f").call(this,X),this._emit("end")}}_emitFinal(){}}AZ=new WeakMap,IZ=new WeakMap,K8=new WeakMap,H8=new WeakMap,jZ=new WeakMap,z8=new WeakMap,WY=new WeakMap,W8=new WeakMap,xZ=new WeakMap,SZ=new WeakMap,n6=new WeakMap,L5=new WeakSet,nG=function Y(Z){if(g(this,xZ,!0,"f"),Z instanceof Error&&Z.name==="AbortError")Z=new K0;if(Z instanceof K0)return g(this,SZ,!0,"f"),this._emit("abort",Z);if(Z instanceof S)return this._emit("error",Z);if(Z instanceof Error){let Q=new S(Z.message);return Q.cause=Z,this._emit("error",Q)}return this._emit("error",new S(String(Z)))};function aG(Y){return typeof Y.parse==="function"}var T0,T5,yZ,_5,w5,N5,oG,sG,dR=10;class U8 extends Q6{constructor(){super(...arguments);T0.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(Y){this._chatCompletions.push(Y),this._emit("chatCompletion",Y);let Z=Y.choices[0]?.message;if(Z)this._addMessage(Z);return Y}_addMessage(Y,Z=!0){if(!("content"in Y))Y.content=null;if(this.messages.push(Y),Z){if(this._emit("message",Y),D5(Y)&&Y.content)this._emit("functionToolCallResult",Y.content);else if(i6(Y)&&Y.tool_calls){for(let Q of Y.tool_calls)if(Q.type==="function")this._emit("functionToolCall",Q.function)}}}async finalChatCompletion(){await this.done();let Y=this._chatCompletions[this._chatCompletions.length-1];if(!Y)throw new S("stream ended without producing a ChatCompletion");return Y}async finalContent(){return await this.done(),L(this,T0,"m",T5).call(this)}async finalMessage(){return await this.done(),L(this,T0,"m",yZ).call(this)}async finalFunctionToolCall(){return await this.done(),L(this,T0,"m",_5).call(this)}async finalFunctionToolCallResult(){return await this.done(),L(this,T0,"m",w5).call(this)}async totalUsage(){return await this.done(),L(this,T0,"m",N5).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let Y=this._chatCompletions[this._chatCompletions.length-1];if(Y)this._emit("finalChatCompletion",Y);let Z=L(this,T0,"m",yZ).call(this);if(Z)this._emit("finalMessage",Z);let Q=L(this,T0,"m",T5).call(this);if(Q)this._emit("finalContent",Q);let X=L(this,T0,"m",_5).call(this);if(X)this._emit("finalFunctionToolCall",X);let J=L(this,T0,"m",w5).call(this);if(J!=null)this._emit("finalFunctionToolCallResult",J);if(this._chatCompletions.some(($)=>$.usage))this._emit("totalUsage",L(this,T0,"m",N5).call(this))}async _createChatCompletion(Y,Z,Q){let X=Q?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}L(this,T0,"m",oG).call(this,Z);let J=await Y.chat.completions.create({...Z,stream:!1},{...Q,signal:this.controller.signal});return this._connected(),this._addChatCompletion(G8(J,Z))}async _runChatCompletion(Y,Z,Q){for(let X of Z.messages)this._addMessage(X,!1);return await this._createChatCompletion(Y,Z,Q)}async _runTools(Y,Z,Q){let{tool_choice:J="auto",stream:$,...G}=Z,K=typeof J!=="string"&&J.type==="function"&&J?.function?.name,{maxChatCompletions:H=dR}=Q||{},W=Z.tools.map((V)=>{if(Z6(V)){if(!V.$callback)throw new S("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:V.$callback,name:V.function.name,description:V.function.description||"",parameters:V.function.parameters,parse:V.$parseRaw,strict:!0}}}return V}),z={};for(let V of W)if(V.type==="function")z[V.function.name||V.function.function.name]=V.function;let q="tools"in Z?W.map((V)=>V.type==="function"?{type:"function",function:{name:V.function.name||V.function.function.name,parameters:V.function.parameters,description:V.function.description,strict:V.function.strict}}:V):void 0;for(let V of Z.messages)this._addMessage(V,!1);for(let V=0;V<H;++V){let B=(await this._createChatCompletion(Y,{...G,tool_choice:J,tools:q,messages:[...this.messages]},Q)).choices[0]?.message;if(!B)throw new S("missing message in ChatCompletion response");if(!B.tool_calls?.length)return;for(let M of B.tool_calls){if(M.type!=="function")continue;let T=M.id,{name:D,arguments:_}=M.function,w=z[D];if(!w){let f=`Invalid tool_call: ${JSON.stringify(D)}. Available options are: ${Object.keys(z).map((m)=>JSON.stringify(m)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:T,content:f});continue}else if(K&&K!==D){let f=`Invalid tool_call: ${JSON.stringify(D)}. ${JSON.stringify(K)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:T,content:f});continue}let N;try{N=aG(w)?await w.parse(_):_}catch(f){let m=f instanceof Error?f.message:String(f);this._addMessage({role:"tool",tool_call_id:T,content:m});continue}let j=await w.function(N,this),x=L(this,T0,"m",sG).call(this,j);if(this._addMessage({role:"tool",tool_call_id:T,content:x}),K)return}}return}}T0=new WeakSet,T5=function Y(){return L(this,T0,"m",yZ).call(this).content??null},yZ=function Y(){let Z=this.messages.length;while(Z-- >0){let Q=this.messages[Z];if(i6(Q))return{...Q,content:Q.content??null,refusal:Q.refusal??null}}throw new S("stream ended without producing a ChatCompletionMessage with role=assistant")},_5=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(i6(Q)&&Q?.tool_calls?.length)return Q.tool_calls.filter((X)=>X.type==="function").at(-1)?.function}return},w5=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(D5(Q)&&Q.content!=null&&typeof Q.content==="string"&&this.messages.some((X)=>X.role==="assistant"&&X.tool_calls?.some((J)=>J.type==="function"&&J.id===Q.tool_call_id)))return Q.content}return},N5=function Y(){let Z={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:Q}of this._chatCompletions)if(Q)Z.completion_tokens+=Q.completion_tokens,Z.prompt_tokens+=Q.prompt_tokens,Z.total_tokens+=Q.total_tokens;return Z},oG=function Y(Z){if(Z.n!=null&&Z.n>1)throw new S("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},sG=function Y(Z){return typeof Z==="string"?Z:Z===void 0?"undefined":JSON.stringify(Z)};class q8 extends U8{static runTools(Y,Z,Q){let X=new q8,J={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return X._run(()=>X._runTools(Y,Z,J)),X}_addMessage(Y,Z=!0){if(super._addMessage(Y,Z),i6(Y)&&Y.content)this._emit("content",Y.content)}}var W0={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};class tG extends Error{}class rG extends Error{}function pR(Y,Z=W0.ALL){if(typeof Y!=="string")throw TypeError(`expecting str, got ${typeof Y}`);if(!Y.trim())throw Error(`${Y} is empty`);return cR(Y.trim(),Z)}var cR=(Y,Z)=>{let Q=Y.length,X=0,J=(V)=>{throw new tG(`${V} at position ${X}`)},$=(V)=>{throw new rG(`${V} at position ${X}`)},G=()=>{if(q(),X>=Q)J("Unexpected end of input");if(Y[X]==='"')return K();if(Y[X]==="{")return H();if(Y[X]==="[")return W();if(Y.substring(X,X+4)==="null"||W0.NULL&Z&&Q-X<4&&"null".startsWith(Y.substring(X)))return X+=4,null;if(Y.substring(X,X+4)==="true"||W0.BOOL&Z&&Q-X<4&&"true".startsWith(Y.substring(X)))return X+=4,!0;if(Y.substring(X,X+5)==="false"||W0.BOOL&Z&&Q-X<5&&"false".startsWith(Y.substring(X)))return X+=5,!1;if(Y.substring(X,X+8)==="Infinity"||W0.INFINITY&Z&&Q-X<8&&"Infinity".startsWith(Y.substring(X)))return X+=8,1/0;if(Y.substring(X,X+9)==="-Infinity"||W0.MINUS_INFINITY&Z&&1<Q-X&&Q-X<9&&"-Infinity".startsWith(Y.substring(X)))return X+=9,-1/0;if(Y.substring(X,X+3)==="NaN"||W0.NAN&Z&&Q-X<3&&"NaN".startsWith(Y.substring(X)))return X+=3,NaN;return z()},K=()=>{let V=X,R=!1;X++;while(X<Q&&(Y[X]!=='"'||R&&Y[X-1]==="\\"))R=Y[X]==="\\"?!R:!1,X++;if(Y.charAt(X)=='"')try{return JSON.parse(Y.substring(V,++X-Number(R)))}catch(B){$(String(B))}else if(W0.STR&Z)try{return JSON.parse(Y.substring(V,X-Number(R))+'"')}catch(B){return JSON.parse(Y.substring(V,Y.lastIndexOf("\\"))+'"')}J("Unterminated string literal")},H=()=>{X++,q();let V={};try{while(Y[X]!=="}"){if(q(),X>=Q&&W0.OBJ&Z)return V;let R=K();q(),X++;try{let B=G();Object.defineProperty(V,R,{value:B,writable:!0,enumerable:!0,configurable:!0})}catch(B){if(W0.OBJ&Z)return V;else throw B}if(q(),Y[X]===",")X++}}catch(R){if(W0.OBJ&Z)return V;else J("Expected '}' at end of object")}return X++,V},W=()=>{X++;let V=[];try{while(Y[X]!=="]")if(V.push(G()),q(),Y[X]===",")X++}catch(R){if(W0.ARR&Z)return V;J("Expected ']' at end of array")}return X++,V},z=()=>{if(X===0){if(Y==="-"&&W0.NUM&Z)J("Not sure what '-' is");try{return JSON.parse(Y)}catch(R){if(W0.NUM&Z)try{if(Y[Y.length-1]===".")return JSON.parse(Y.substring(0,Y.lastIndexOf(".")));return JSON.parse(Y.substring(0,Y.lastIndexOf("e")))}catch(B){}$(String(R))}}let V=X;if(Y[X]==="-")X++;while(Y[X]&&!",]}".includes(Y[X]))X++;if(X==Q&&!(W0.NUM&Z))J("Unterminated number literal");try{return JSON.parse(Y.substring(V,X))}catch(R){if(Y.substring(V,X)==="-"&&W0.NUM&Z)J("Not sure what '-' is");try{return JSON.parse(Y.substring(V,Y.lastIndexOf("e")))}catch(B){$(String(B))}}},q=()=>{while(X<Q&&`
|
|
450
|
-
\r `.includes(Y[
|
|
451
|
-
${
|
|
452
|
-
${
|
|
453
|
-
${
|
|
454
|
-
${hZ(Y)}`);return{...m,id:f,type:x,function:{...d,name:v,arguments:b}}})}};return{...R,message:{...D,content:B,role:_,refusal:W.refusal??null},finish_reason:z,index:q,logprobs:V}}),created:J,model:$,object:"chat.completion",...G?{system_fingerprint:G}:{}};return pG(H,Z)}function hZ(Y){return JSON.stringify(Y)}function YK(Y){return}function ZK(Y){}class o6 extends OY{static fromReadableStream(Y){let Z=new o6(null);return Z._run(()=>Z._fromReadableStream(Y)),Z}static runTools(Y,Z,Q){let X=new o6(Z),J={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return X._run(()=>X._runTools(Y,Z,J)),X}}class PY extends E{constructor(){super(...arguments);this.messages=new l6(this._client)}create(Y,Z){return this._client.post("/chat/completions",{body:Y,...Z,stream:Y.stream??!1})}retrieve(Y,Z){return this._client.get(O`/chat/completions/${Y}`,Z)}update(Y,Z,Q){return this._client.post(O`/chat/completions/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/chat/completions",n,{query:Y,...Z})}delete(Y,Z){return this._client.delete(O`/chat/completions/${Y}`,Z)}parse(Y,Z){return iG(Y.tools),this._client.chat.completions.create(Y,{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap((Q)=>G8(Q,Y))}runTools(Y,Z){if(Y.stream)return o6.runTools(this._client,Y,Z);return q8.runTools(this._client,Y,Z)}stream(Y,Z){return OY.createChatCompletion(this._client,Y,Z)}}PY.Messages=l6;class X6 extends E{constructor(){super(...arguments);this.completions=new PY(this._client)}}X6.Completions=PY;var QK=Symbol("brand.privateNullableHeaders");function*nR(Y){if(!Y)return;if(QK in Y){let{values:X,nulls:J}=Y;yield*X.entries();for(let $ of J)yield[$,null];return}let Z=!1,Q;if(Y instanceof Headers)Q=Y.entries();else if(e2(Y))Q=Y;else Z=!0,Q=Object.entries(Y??{});for(let X of Q){let J=X[0];if(typeof J!=="string")throw TypeError("expected header name to be a string");let $=e2(X[1])?X[1]:[X[1]],G=!1;for(let K of $){if(K===void 0)continue;if(Z&&!G)G=!0,yield[J,null];yield[J,K]}}}var A=(Y)=>{let Z=new Headers,Q=new Set;for(let X of Y){let J=new Set;for(let[$,G]of nR(X)){let K=$.toLowerCase();if(!J.has(K))Z.delete($),J.add(K);if(G===null)Z.delete($),Q.add(K);else Z.append($,G),Q.delete(K)}}return{[QK]:!0,values:Z,nulls:Q}};class V8 extends E{create(Y,Z){return this._client.post("/audio/speech",{body:Y,...Z,headers:A([{Accept:"application/octet-stream"},Z?.headers]),__binaryResponse:!0})}}class B8 extends E{create(Y,Z){return this._client.post("/audio/transcriptions",A0({body:Y,...Z,stream:Y.stream??!1,__metadata:{model:Y.model}},this._client))}}class F8 extends E{create(Y,Z){return this._client.post("/audio/translations",A0({body:Y,...Z,__metadata:{model:Y.model}},this._client))}}class qY extends E{constructor(){super(...arguments);this.transcriptions=new B8(this._client),this.translations=new F8(this._client),this.speech=new V8(this._client)}}qY.Transcriptions=B8;qY.Translations=F8;qY.Speech=V8;class s6 extends E{create(Y,Z){return this._client.post("/batches",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(O`/batches/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/batches",n,{query:Y,...Z})}cancel(Y,Z){return this._client.post(O`/batches/${Y}/cancel`,Z)}}class R8 extends E{create(Y,Z){return this._client.post("/assistants",{body:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(O`/assistants/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(O`/assistants/${Y}`,{body:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/assistants",n,{query:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(O`/assistants/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}class M8 extends E{create(Y,Z){return this._client.post("/realtime/sessions",{body:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}class D8 extends E{create(Y,Z){return this._client.post("/realtime/transcription_sessions",{body:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}class J6 extends E{constructor(){super(...arguments);this.sessions=new M8(this._client),this.transcriptionSessions=new D8(this._client)}}J6.Sessions=M8;J6.TranscriptionSessions=D8;class L8 extends E{create(Y,Z){return this._client.post("/chatkit/sessions",{body:Y,...Z,headers:A([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}cancel(Y,Z){return this._client.post(O`/chatkit/sessions/${Y}/cancel`,{...Z,headers:A([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}}class T8 extends E{retrieve(Y,Z){return this._client.get(O`/chatkit/threads/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}list(Y={},Z){return this._client.getAPIList("/chatkit/threads",wY,{query:Y,...Z,headers:A([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}delete(Y,Z){return this._client.delete(O`/chatkit/threads/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}listItems(Y,Z={},Q){return this._client.getAPIList(O`/chatkit/threads/${Y}/items`,wY,{query:Z,...Q,headers:A([{"OpenAI-Beta":"chatkit_beta=v1"},Q?.headers])})}}class $6 extends E{constructor(){super(...arguments);this.sessions=new L8(this._client),this.threads=new T8(this._client)}}$6.Sessions=L8;$6.Threads=T8;class _8 extends E{create(Y,Z,Q){return this._client.post(O`/threads/${Y}/messages`,{body:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{thread_id:X}=Z;return this._client.get(O`/threads/${X}/messages/${Y}`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:X,...J}=Z;return this._client.post(O`/threads/${X}/messages/${Y}`,{body:J,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(O`/threads/${Y}/messages`,n,{query:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{thread_id:X}=Z;return this._client.delete(O`/threads/${X}/messages/${Y}`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}class w8 extends E{retrieve(Y,Z,Q){let{thread_id:X,run_id:J,...$}=Z;return this._client.get(O`/threads/${X}/runs/${J}/steps/${Y}`,{query:$,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z,Q){let{thread_id:X,...J}=Z;return this._client.getAPIList(O`/threads/${X}/runs/${Y}/steps`,n,{query:J,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}var XK=(Y)=>{if(typeof Buffer<"u"){let Z=Buffer.from(Y,"base64");return Array.from(new Float32Array(Z.buffer,Z.byteOffset,Z.length/Float32Array.BYTES_PER_ELEMENT))}else{let Z=atob(Y),Q=Z.length,X=new Uint8Array(Q);for(let J=0;J<Q;J++)X[J]=Z.charCodeAt(J);return Array.from(new Float32Array(X.buffer))}};var EY=(Y)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[Y]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(Y)?.trim();return};var V0,K6,I5,o0,bZ,h0,H6,t6,G6,uZ,I0,gZ,mZ,P8,N8,O8,JK,$K,GK,KK,HK,zK,WK;class CY extends Q6{constructor(){super(...arguments);V0.add(this),I5.set(this,[]),o0.set(this,{}),bZ.set(this,{}),h0.set(this,void 0),H6.set(this,void 0),t6.set(this,void 0),G6.set(this,void 0),uZ.set(this,void 0),I0.set(this,void 0),gZ.set(this,void 0),mZ.set(this,void 0),P8.set(this,void 0)}[(I5=new WeakMap,o0=new WeakMap,bZ=new WeakMap,h0=new WeakMap,H6=new WeakMap,t6=new WeakMap,G6=new WeakMap,uZ=new WeakMap,I0=new WeakMap,gZ=new WeakMap,mZ=new WeakMap,P8=new WeakMap,V0=new WeakSet,Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(X)=>{let J=Z.shift();if(J)J.resolve(X);else Y.push(X)}),this.on("end",()=>{Q=!0;for(let X of Z)X.resolve(void 0);Z.length=0}),this.on("abort",(X)=>{Q=!0;for(let J of Z)J.reject(X);Z.length=0}),this.on("error",(X)=>{Q=!0;for(let J of Z)J.reject(X);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((J,$)=>Z.push({resolve:J,reject:$})).then((J)=>J?{value:J,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream(Y){let Z=new K6;return Z._run(()=>Z._fromReadableStream(Y)),Z}async _fromReadableStream(Y,Z){let Q=Z?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}this._connected();let X=k0.fromReadableStream(Y,this.controller);for await(let J of X)L(this,V0,"m",N8).call(this,J);if(X.controller.signal?.aborted)throw new K0;return this._addRun(L(this,V0,"m",O8).call(this))}toReadableStream(){return new k0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(Y,Z,Q,X){let J=new K6;return J._run(()=>J._runToolAssistantStream(Y,Z,Q,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createToolAssistantStream(Y,Z,Q,X){let J=X?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}let $={...Q,stream:!0},G=await Y.submitToolOutputs(Z,$,{...X,signal:this.controller.signal});this._connected();for await(let K of G)L(this,V0,"m",N8).call(this,K);if(G.controller.signal?.aborted)throw new K0;return this._addRun(L(this,V0,"m",O8).call(this))}static createThreadAssistantStream(Y,Z,Q){let X=new K6;return X._run(()=>X._threadAssistantStream(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),X}static createAssistantStream(Y,Z,Q,X){let J=new K6;return J._run(()=>J._runAssistantStream(Y,Z,Q,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),J}currentEvent(){return L(this,gZ,"f")}currentRun(){return L(this,mZ,"f")}currentMessageSnapshot(){return L(this,h0,"f")}currentRunStepSnapshot(){return L(this,P8,"f")}async finalRunSteps(){return await this.done(),Object.values(L(this,o0,"f"))}async finalMessages(){return await this.done(),Object.values(L(this,bZ,"f"))}async finalRun(){if(await this.done(),!L(this,H6,"f"))throw Error("Final run was not received.");return L(this,H6,"f")}async _createThreadAssistantStream(Y,Z,Q){let X=Q?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}let J={...Z,stream:!0},$=await Y.createAndRun(J,{...Q,signal:this.controller.signal});this._connected();for await(let G of $)L(this,V0,"m",N8).call(this,G);if($.controller.signal?.aborted)throw new K0;return this._addRun(L(this,V0,"m",O8).call(this))}async _createAssistantStream(Y,Z,Q,X){let J=X?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}let $={...Q,stream:!0},G=await Y.create(Z,$,{...X,signal:this.controller.signal});this._connected();for await(let K of G)L(this,V0,"m",N8).call(this,K);if(G.controller.signal?.aborted)throw new K0;return this._addRun(L(this,V0,"m",O8).call(this))}static accumulateDelta(Y,Z){for(let[Q,X]of Object.entries(Z)){if(!Y.hasOwnProperty(Q)){Y[Q]=X;continue}let J=Y[Q];if(J===null||J===void 0){Y[Q]=X;continue}if(Q==="index"||Q==="type"){Y[Q]=X;continue}if(typeof J==="string"&&typeof X==="string")J+=X;else if(typeof J==="number"&&typeof X==="number")J+=X;else if(e1(J)&&e1(X))J=this.accumulateDelta(J,X);else if(Array.isArray(J)&&Array.isArray(X)){if(J.every(($)=>typeof $==="string"||typeof $==="number")){J.push(...X);continue}for(let $ of X){if(!e1($))throw Error(`Expected array delta entry to be an object but got: ${$}`);let G=$.index;if(G==null)throw console.error($),Error("Expected array delta entry to have an `index` property");if(typeof G!=="number")throw Error(`Expected array delta entry \`index\` property to be a number but got ${G}`);let K=J[G];if(K==null)J.push($);else J[G]=this.accumulateDelta(K,$)}continue}else throw Error(`Unhandled record type: ${Q}, deltaValue: ${X}, accValue: ${J}`);Y[Q]=J}return Y}_addRun(Y){return Y}async _threadAssistantStream(Y,Z,Q){return await this._createThreadAssistantStream(Z,Y,Q)}async _runAssistantStream(Y,Z,Q,X){return await this._createAssistantStream(Z,Y,Q,X)}async _runToolAssistantStream(Y,Z,Q,X){return await this._createToolAssistantStream(Z,Y,Q,X)}}K6=CY,N8=function Y(Z){if(this.ended)return;switch(g(this,gZ,Z,"f"),L(this,V0,"m",GK).call(this,Z),Z.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":L(this,V0,"m",WK).call(this,Z);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":L(this,V0,"m",$K).call(this,Z);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":L(this,V0,"m",JK).call(this,Z);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier");default:GM(Z)}},O8=function Y(){if(this.ended)throw new S("stream has ended, this shouldn't happen");if(!L(this,H6,"f"))throw Error("Final run has not been received");return L(this,H6,"f")},JK=function Y(Z){let[Q,X]=L(this,V0,"m",HK).call(this,Z,L(this,h0,"f"));g(this,h0,Q,"f"),L(this,bZ,"f")[Q.id]=Q;for(let J of X){let $=Q.content[J.index];if($?.type=="text")this._emit("textCreated",$.text)}switch(Z.event){case"thread.message.created":this._emit("messageCreated",Z.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",Z.data.delta,Q),Z.data.delta.content)for(let J of Z.data.delta.content){if(J.type=="text"&&J.text){let $=J.text,G=Q.content[J.index];if(G&&G.type=="text")this._emit("textDelta",$,G.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(J.index!=L(this,t6,"f")){if(L(this,G6,"f"))switch(L(this,G6,"f").type){case"text":this._emit("textDone",L(this,G6,"f").text,L(this,h0,"f"));break;case"image_file":this._emit("imageFileDone",L(this,G6,"f").image_file,L(this,h0,"f"));break}g(this,t6,J.index,"f")}g(this,G6,Q.content[J.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(L(this,t6,"f")!==void 0){let J=Z.data.content[L(this,t6,"f")];if(J)switch(J.type){case"image_file":this._emit("imageFileDone",J.image_file,L(this,h0,"f"));break;case"text":this._emit("textDone",J.text,L(this,h0,"f"));break}}if(L(this,h0,"f"))this._emit("messageDone",Z.data);g(this,h0,void 0,"f")}},$K=function Y(Z){let Q=L(this,V0,"m",KK).call(this,Z);switch(g(this,P8,Q,"f"),Z.event){case"thread.run.step.created":this._emit("runStepCreated",Z.data);break;case"thread.run.step.delta":let X=Z.data.delta;if(X.step_details&&X.step_details.type=="tool_calls"&&X.step_details.tool_calls&&Q.step_details.type=="tool_calls")for(let $ of X.step_details.tool_calls)if($.index==L(this,uZ,"f"))this._emit("toolCallDelta",$,Q.step_details.tool_calls[$.index]);else{if(L(this,I0,"f"))this._emit("toolCallDone",L(this,I0,"f"));if(g(this,uZ,$.index,"f"),g(this,I0,Q.step_details.tool_calls[$.index],"f"),L(this,I0,"f"))this._emit("toolCallCreated",L(this,I0,"f"))}this._emit("runStepDelta",Z.data.delta,Q);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(g(this,P8,void 0,"f"),Z.data.step_details.type=="tool_calls"){if(L(this,I0,"f"))this._emit("toolCallDone",L(this,I0,"f")),g(this,I0,void 0,"f")}this._emit("runStepDone",Z.data,Q);break;case"thread.run.step.in_progress":break}},GK=function Y(Z){L(this,I5,"f").push(Z),this._emit("event",Z)},KK=function Y(Z){switch(Z.event){case"thread.run.step.created":return L(this,o0,"f")[Z.data.id]=Z.data,Z.data;case"thread.run.step.delta":let Q=L(this,o0,"f")[Z.data.id];if(!Q)throw Error("Received a RunStepDelta before creation of a snapshot");let X=Z.data;if(X.delta){let J=K6.accumulateDelta(Q,X.delta);L(this,o0,"f")[Z.data.id]=J}return L(this,o0,"f")[Z.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":L(this,o0,"f")[Z.data.id]=Z.data;break}if(L(this,o0,"f")[Z.data.id])return L(this,o0,"f")[Z.data.id];throw Error("No snapshot available")},HK=function Y(Z,Q){let X=[];switch(Z.event){case"thread.message.created":return[Z.data,X];case"thread.message.delta":if(!Q)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let J=Z.data;if(J.delta.content)for(let $ of J.delta.content)if($.index in Q.content){let G=Q.content[$.index];Q.content[$.index]=L(this,V0,"m",zK).call(this,$,G)}else Q.content[$.index]=$,X.push($);return[Q,X];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(Q)return[Q,X];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},zK=function Y(Z,Q){return K6.accumulateDelta(Q,Z)},WK=function Y(Z){switch(g(this,mZ,Z.data,"f"),Z.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":if(g(this,H6,Z.data,"f"),L(this,I0,"f"))this._emit("toolCallDone",L(this,I0,"f")),g(this,I0,void 0,"f");break;case"thread.run.cancelling":break}};function GM(Y){}class r6 extends E{constructor(){super(...arguments);this.steps=new w8(this._client)}create(Y,Z,Q){let{include:X,...J}=Z;return this._client.post(O`/threads/${Y}/runs`,{query:{include:X},body:J,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}retrieve(Y,Z,Q){let{thread_id:X}=Z;return this._client.get(O`/threads/${X}/runs/${Y}`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:X,...J}=Z;return this._client.post(O`/threads/${X}/runs/${Y}`,{body:J,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(O`/threads/${Y}/runs`,n,{query:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{thread_id:X}=Z;return this._client.post(O`/threads/${X}/runs/${Y}/cancel`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let X=await this.create(Y,Z,Q);return await this.poll(X.id,{thread_id:Y},Q)}createAndStream(Y,Z,Q){return CY.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}async poll(Y,Z,Q){let X=A([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:J,response:$}=await this.retrieve(Y,Z,{...Q,headers:{...Q?.headers,...X}}).withResponse();switch(J.status){case"queued":case"in_progress":case"cancelling":let G=5000;if(Q?.pollIntervalMs)G=Q.pollIntervalMs;else{let K=$.headers.get("openai-poll-after-ms");if(K){let H=parseInt(K);if(!isNaN(H))G=H}}await n0(G);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return J}}}stream(Y,Z,Q){return CY.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}submitToolOutputs(Y,Z,Q){let{thread_id:X,...J}=Z;return this._client.post(O`/threads/${X}/runs/${Y}/submit_tool_outputs`,{body:J,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}async submitToolOutputsAndPoll(Y,Z,Q){let X=await this.submitToolOutputs(Y,Z,Q);return await this.poll(X.id,Z,Q)}submitToolOutputsStream(Y,Z,Q){return CY.createToolAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}}r6.Steps=w8;class z6 extends E{constructor(){super(...arguments);this.runs=new r6(this._client),this.messages=new _8(this._client)}create(Y={},Z){return this._client.post("/threads",{body:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(O`/threads/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(O`/threads/${Y}`,{body:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z){return this._client.delete(O`/threads/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}createAndRun(Y,Z){return this._client.post("/threads/runs",{body:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),stream:Y.stream??!1})}async createAndRunPoll(Y,Z){let Q=await this.createAndRun(Y,Z);return await this.runs.poll(Q.id,{thread_id:Q.thread_id},Z)}createAndRunStream(Y,Z){return CY.createThreadAssistantStream(Y,this._client.beta.threads,Z)}}z6.Runs=r6;z6.Messages=_8;class s0 extends E{constructor(){super(...arguments);this.realtime=new J6(this._client),this.chatkit=new $6(this._client),this.assistants=new R8(this._client),this.threads=new z6(this._client)}}s0.Realtime=J6;s0.ChatKit=$6;s0.Assistants=R8;s0.Threads=z6;class e6 extends E{create(Y,Z){return this._client.post("/completions",{body:Y,...Z,stream:Y.stream??!1})}}class E8 extends E{retrieve(Y,Z,Q){let{container_id:X}=Z;return this._client.get(O`/containers/${X}/files/${Y}/content`,{...Q,headers:A([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}}class Y1 extends E{constructor(){super(...arguments);this.content=new E8(this._client)}create(Y,Z,Q){return this._client.post(O`/containers/${Y}/files`,A0({body:Z,...Q},this._client))}retrieve(Y,Z,Q){let{container_id:X}=Z;return this._client.get(O`/containers/${X}/files/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(O`/containers/${Y}/files`,n,{query:Z,...Q})}delete(Y,Z,Q){let{container_id:X}=Z;return this._client.delete(O`/containers/${X}/files/${Y}`,{...Q,headers:A([{Accept:"*/*"},Q?.headers])})}}Y1.Content=E8;class W6 extends E{constructor(){super(...arguments);this.files=new Y1(this._client)}create(Y,Z){return this._client.post("/containers",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(O`/containers/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/containers",n,{query:Y,...Z})}delete(Y,Z){return this._client.delete(O`/containers/${Y}`,{...Z,headers:A([{Accept:"*/*"},Z?.headers])})}}W6.Files=Y1;class C8 extends E{create(Y,Z,Q){let{include:X,...J}=Z;return this._client.post(O`/conversations/${Y}/items`,{query:{include:X},body:J,...Q})}retrieve(Y,Z,Q){let{conversation_id:X,...J}=Z;return this._client.get(O`/conversations/${X}/items/${Y}`,{query:J,...Q})}list(Y,Z={},Q){return this._client.getAPIList(O`/conversations/${Y}/items`,wY,{query:Z,...Q})}delete(Y,Z,Q){let{conversation_id:X}=Z;return this._client.delete(O`/conversations/${X}/items/${Y}`,Q)}}class U6 extends E{constructor(){super(...arguments);this.items=new C8(this._client)}create(Y={},Z){return this._client.post("/conversations",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(O`/conversations/${Y}`,Z)}update(Y,Z,Q){return this._client.post(O`/conversations/${Y}`,{body:Z,...Q})}delete(Y,Z){return this._client.delete(O`/conversations/${Y}`,Z)}}U6.Items=C8;class Z1 extends E{create(Y,Z){let Q=!!Y.encoding_format,X=Q?Y.encoding_format:"base64";if(Q)Q0(this._client).debug("embeddings/user defined encoding_format:",Y.encoding_format);let J=this._client.post("/embeddings",{body:{...Y,encoding_format:X},...Z});if(Q)return J;return Q0(this._client).debug("embeddings/decoding base64 embeddings from base64"),J._thenUnwrap(($)=>{if($&&$.data)$.data.forEach((G)=>{let K=G.embedding;G.embedding=XK(K)});return $})}}class k8 extends E{retrieve(Y,Z,Q){let{eval_id:X,run_id:J}=Z;return this._client.get(O`/evals/${X}/runs/${J}/output_items/${Y}`,Q)}list(Y,Z,Q){let{eval_id:X,...J}=Z;return this._client.getAPIList(O`/evals/${X}/runs/${Y}/output_items`,n,{query:J,...Q})}}class Q1 extends E{constructor(){super(...arguments);this.outputItems=new k8(this._client)}create(Y,Z,Q){return this._client.post(O`/evals/${Y}/runs`,{body:Z,...Q})}retrieve(Y,Z,Q){let{eval_id:X}=Z;return this._client.get(O`/evals/${X}/runs/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(O`/evals/${Y}/runs`,n,{query:Z,...Q})}delete(Y,Z,Q){let{eval_id:X}=Z;return this._client.delete(O`/evals/${X}/runs/${Y}`,Q)}cancel(Y,Z,Q){let{eval_id:X}=Z;return this._client.post(O`/evals/${X}/runs/${Y}`,Q)}}Q1.OutputItems=k8;class q6 extends E{constructor(){super(...arguments);this.runs=new Q1(this._client)}create(Y,Z){return this._client.post("/evals",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(O`/evals/${Y}`,Z)}update(Y,Z,Q){return this._client.post(O`/evals/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/evals",n,{query:Y,...Z})}delete(Y,Z){return this._client.delete(O`/evals/${Y}`,Z)}}q6.Runs=Q1;class X1 extends E{create(Y,Z){return this._client.post("/files",A0({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(O`/files/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/files",n,{query:Y,...Z})}delete(Y,Z){return this._client.delete(O`/files/${Y}`,Z)}content(Y,Z){return this._client.get(O`/files/${Y}/content`,{...Z,headers:A([{Accept:"application/binary"},Z?.headers]),__binaryResponse:!0})}async waitForProcessing(Y,{pollInterval:Z=5000,maxWait:Q=1800000}={}){let X=new Set(["processed","error","deleted"]),J=Date.now(),$=await this.retrieve(Y);while(!$.status||!X.has($.status))if(await n0(Z),$=await this.retrieve(Y),Date.now()-J>Q)throw new eY({message:`Giving up on waiting for file ${Y} to finish processing after ${Q} milliseconds.`});return $}}class A8 extends E{}class I8 extends E{run(Y,Z){return this._client.post("/fine_tuning/alpha/graders/run",{body:Y,...Z})}validate(Y,Z){return this._client.post("/fine_tuning/alpha/graders/validate",{body:Y,...Z})}}class J1 extends E{constructor(){super(...arguments);this.graders=new I8(this._client)}}J1.Graders=I8;class j8 extends E{create(Y,Z,Q){return this._client.getAPIList(O`/fine_tuning/checkpoints/${Y}/permissions`,zY,{body:Z,method:"post",...Q})}retrieve(Y,Z={},Q){return this._client.get(O`/fine_tuning/checkpoints/${Y}/permissions`,{query:Z,...Q})}delete(Y,Z,Q){let{fine_tuned_model_checkpoint:X}=Z;return this._client.delete(O`/fine_tuning/checkpoints/${X}/permissions/${Y}`,Q)}}class $1 extends E{constructor(){super(...arguments);this.permissions=new j8(this._client)}}$1.Permissions=j8;class x8 extends E{list(Y,Z={},Q){return this._client.getAPIList(O`/fine_tuning/jobs/${Y}/checkpoints`,n,{query:Z,...Q})}}class G1 extends E{constructor(){super(...arguments);this.checkpoints=new x8(this._client)}create(Y,Z){return this._client.post("/fine_tuning/jobs",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(O`/fine_tuning/jobs/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/fine_tuning/jobs",n,{query:Y,...Z})}cancel(Y,Z){return this._client.post(O`/fine_tuning/jobs/${Y}/cancel`,Z)}listEvents(Y,Z={},Q){return this._client.getAPIList(O`/fine_tuning/jobs/${Y}/events`,n,{query:Z,...Q})}pause(Y,Z){return this._client.post(O`/fine_tuning/jobs/${Y}/pause`,Z)}resume(Y,Z){return this._client.post(O`/fine_tuning/jobs/${Y}/resume`,Z)}}G1.Checkpoints=x8;class t0 extends E{constructor(){super(...arguments);this.methods=new A8(this._client),this.jobs=new G1(this._client),this.checkpoints=new $1(this._client),this.alpha=new J1(this._client)}}t0.Methods=A8;t0.Jobs=G1;t0.Checkpoints=$1;t0.Alpha=J1;class S8 extends E{}class V6 extends E{constructor(){super(...arguments);this.graderModels=new S8(this._client)}}V6.GraderModels=S8;class K1 extends E{createVariation(Y,Z){return this._client.post("/images/variations",A0({body:Y,...Z},this._client))}edit(Y,Z){return this._client.post("/images/edits",A0({body:Y,...Z,stream:Y.stream??!1},this._client))}generate(Y,Z){return this._client.post("/images/generations",{body:Y,...Z,stream:Y.stream??!1})}}class H1 extends E{retrieve(Y,Z){return this._client.get(O`/models/${Y}`,Z)}list(Y){return this._client.getAPIList("/models",zY,Y)}delete(Y,Z){return this._client.delete(O`/models/${Y}`,Z)}}class z1 extends E{create(Y,Z){return this._client.post("/moderations",{body:Y,...Z})}}class y8 extends E{accept(Y,Z,Q){return this._client.post(O`/realtime/calls/${Y}/accept`,{body:Z,...Q,headers:A([{Accept:"*/*"},Q?.headers])})}hangup(Y,Z){return this._client.post(O`/realtime/calls/${Y}/hangup`,{...Z,headers:A([{Accept:"*/*"},Z?.headers])})}refer(Y,Z,Q){return this._client.post(O`/realtime/calls/${Y}/refer`,{body:Z,...Q,headers:A([{Accept:"*/*"},Q?.headers])})}reject(Y,Z={},Q){return this._client.post(O`/realtime/calls/${Y}/reject`,{body:Z,...Q,headers:A([{Accept:"*/*"},Q?.headers])})}}class v8 extends E{create(Y,Z){return this._client.post("/realtime/client_secrets",{body:Y,...Z})}}class kY extends E{constructor(){super(...arguments);this.clientSecrets=new v8(this._client),this.calls=new y8(this._client)}}kY.ClientSecrets=v8;kY.Calls=y8;function UK(Y,Z){if(!Z||!PM(Z))return{...Y,output_parsed:null,output:Y.output.map((Q)=>{if(Q.type==="function_call")return{...Q,parsed_arguments:null};if(Q.type==="message")return{...Q,content:Q.content.map((X)=>({...X,parsed:null}))};else return Q})};return j5(Y,Z)}function j5(Y,Z){let Q=Y.output.map((J)=>{if(J.type==="function_call")return{...J,parsed_arguments:kM(Z,J)};if(J.type==="message"){let $=J.content.map((G)=>{if(G.type==="output_text")return{...G,parsed:OM(Z,G.text)};return G});return{...J,content:$}}return J}),X=Object.assign({},Y,{output:Q});if(!Object.getOwnPropertyDescriptor(Y,"output_text"))dZ(X);return Object.defineProperty(X,"output_parsed",{enumerable:!0,get(){for(let J of X.output){if(J.type!=="message")continue;for(let $ of J.content)if($.type==="output_text"&&$.parsed!==null)return $.parsed}return null}}),X}function OM(Y,Z){if(Y.text?.format?.type!=="json_schema")return null;if("$parseRaw"in Y.text?.format)return(Y.text?.format).$parseRaw(Z);return JSON.parse(Z)}function PM(Y){if($8(Y.text?.format))return!0;return!1}function EM(Y){return Y?.$brand==="auto-parseable-tool"}function CM(Y,Z){return Y.find((Q)=>Q.type==="function"&&Q.name===Z)}function kM(Y,Z){let Q=CM(Y.tools??[],Z.name);return{...Z,...Z,parsed_arguments:EM(Q)?Q.$parseRaw(Z.arguments):Q?.strict?JSON.parse(Z.arguments):null}}function dZ(Y){let Z=[];for(let Q of Y.output){if(Q.type!=="message")continue;for(let X of Q.content)if(X.type==="output_text")Z.push(X.text)}Y.output_text=Z.join("")}var W1,pZ,AY,cZ,qK,VK,BK,FK;class lZ extends Q6{constructor(Y){super();W1.add(this),pZ.set(this,void 0),AY.set(this,void 0),cZ.set(this,void 0),g(this,pZ,Y,"f")}static createResponse(Y,Z,Q){let X=new lZ(Z);return X._run(()=>X._createOrRetrieveResponse(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),X}async _createOrRetrieveResponse(Y,Z,Q){let X=Q?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}L(this,W1,"m",qK).call(this);let J,$=null;if("response_id"in Z)J=await Y.responses.retrieve(Z.response_id,{stream:!0},{...Q,signal:this.controller.signal,stream:!0}),$=Z.starting_after??null;else J=await Y.responses.create({...Z,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let G of J)L(this,W1,"m",VK).call(this,G,$);if(J.controller.signal?.aborted)throw new K0;return L(this,W1,"m",BK).call(this)}[(pZ=new WeakMap,AY=new WeakMap,cZ=new WeakMap,W1=new WeakSet,qK=function Y(){if(this.ended)return;g(this,AY,void 0,"f")},VK=function Y(Z,Q){if(this.ended)return;let X=($,G)=>{if(Q==null||G.sequence_number>Q)this._emit($,G)},J=L(this,W1,"m",FK).call(this,Z);switch(X("event",Z),Z.type){case"response.output_text.delta":{let $=J.output[Z.output_index];if(!$)throw new S(`missing output at index ${Z.output_index}`);if($.type==="message"){let G=$.content[Z.content_index];if(!G)throw new S(`missing content at index ${Z.content_index}`);if(G.type!=="output_text")throw new S(`expected content to be 'output_text', got ${G.type}`);X("response.output_text.delta",{...Z,snapshot:G.text})}break}case"response.function_call_arguments.delta":{let $=J.output[Z.output_index];if(!$)throw new S(`missing output at index ${Z.output_index}`);if($.type==="function_call")X("response.function_call_arguments.delta",{...Z,snapshot:$.arguments});break}default:X(Z.type,Z);break}},BK=function Y(){if(this.ended)throw new S("stream has ended, this shouldn't happen");let Z=L(this,AY,"f");if(!Z)throw new S("request ended without sending any events");g(this,AY,void 0,"f");let Q=AM(Z,L(this,pZ,"f"));return g(this,cZ,Q,"f"),Q},FK=function Y(Z){let Q=L(this,AY,"f");if(!Q){if(Z.type!=="response.created")throw new S(`When snapshot hasn't been set yet, expected 'response.created' event, got ${Z.type}`);return Q=g(this,AY,Z.response,"f"),Q}switch(Z.type){case"response.output_item.added":{Q.output.push(Z.item);break}case"response.content_part.added":{let X=Q.output[Z.output_index];if(!X)throw new S(`missing output at index ${Z.output_index}`);let J=X.type,$=Z.part;if(J==="message"&&$.type!=="reasoning_text")X.content.push($);else if(J==="reasoning"&&$.type==="reasoning_text"){if(!X.content)X.content=[];X.content.push($)}break}case"response.output_text.delta":{let X=Q.output[Z.output_index];if(!X)throw new S(`missing output at index ${Z.output_index}`);if(X.type==="message"){let J=X.content[Z.content_index];if(!J)throw new S(`missing content at index ${Z.content_index}`);if(J.type!=="output_text")throw new S(`expected content to be 'output_text', got ${J.type}`);J.text+=Z.delta}break}case"response.function_call_arguments.delta":{let X=Q.output[Z.output_index];if(!X)throw new S(`missing output at index ${Z.output_index}`);if(X.type==="function_call")X.arguments+=Z.delta;break}case"response.reasoning_text.delta":{let X=Q.output[Z.output_index];if(!X)throw new S(`missing output at index ${Z.output_index}`);if(X.type==="reasoning"){let J=X.content?.[Z.content_index];if(!J)throw new S(`missing content at index ${Z.content_index}`);if(J.type!=="reasoning_text")throw new S(`expected content to be 'reasoning_text', got ${J.type}`);J.text+=Z.delta}break}case"response.completed":{g(this,AY,Z.response,"f");break}}return Q},Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(X)=>{let J=Z.shift();if(J)J.resolve(X);else Y.push(X)}),this.on("end",()=>{Q=!0;for(let X of Z)X.resolve(void 0);Z.length=0}),this.on("abort",(X)=>{Q=!0;for(let J of Z)J.reject(X);Z.length=0}),this.on("error",(X)=>{Q=!0;for(let J of Z)J.reject(X);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((J,$)=>Z.push({resolve:J,reject:$})).then((J)=>J?{value:J,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let Y=L(this,cZ,"f");if(!Y)throw new S("stream ended without producing a ChatCompletion");return Y}}function AM(Y,Z){return UK(Y,Z)}class f8 extends E{list(Y,Z={},Q){return this._client.getAPIList(O`/responses/${Y}/input_items`,n,{query:Z,...Q})}}class h8 extends E{count(Y={},Z){return this._client.post("/responses/input_tokens",{body:Y,...Z})}}class IY extends E{constructor(){super(...arguments);this.inputItems=new f8(this._client),this.inputTokens=new h8(this._client)}create(Y,Z){return this._client.post("/responses",{body:Y,...Z,stream:Y.stream??!1})._thenUnwrap((Q)=>{if("object"in Q&&Q.object==="response")dZ(Q);return Q})}retrieve(Y,Z={},Q){return this._client.get(O`/responses/${Y}`,{query:Z,...Q,stream:Z?.stream??!1})._thenUnwrap((X)=>{if("object"in X&&X.object==="response")dZ(X);return X})}delete(Y,Z){return this._client.delete(O`/responses/${Y}`,{...Z,headers:A([{Accept:"*/*"},Z?.headers])})}parse(Y,Z){return this._client.responses.create(Y,Z)._thenUnwrap((Q)=>j5(Q,Y))}stream(Y,Z){return lZ.createResponse(this._client,Y,Z)}cancel(Y,Z){return this._client.post(O`/responses/${Y}/cancel`,Z)}compact(Y,Z){return this._client.post("/responses/compact",{body:Y,...Z})}}IY.InputItems=f8;IY.InputTokens=h8;class b8 extends E{create(Y,Z,Q){return this._client.post(O`/uploads/${Y}/parts`,A0({body:Z,...Q},this._client))}}class B6 extends E{constructor(){super(...arguments);this.parts=new b8(this._client)}create(Y,Z){return this._client.post("/uploads",{body:Y,...Z})}cancel(Y,Z){return this._client.post(O`/uploads/${Y}/cancel`,Z)}complete(Y,Z,Q){return this._client.post(O`/uploads/${Y}/complete`,{body:Z,...Q})}}B6.Parts=b8;var RK=async(Y)=>{let Z=await Promise.allSettled(Y),Q=Z.filter((J)=>J.status==="rejected");if(Q.length){for(let J of Q)console.error(J.reason);throw Error(`${Q.length} promise(s) failed - see the above errors`)}let X=[];for(let J of Z)if(J.status==="fulfilled")X.push(J.value);return X};class g8 extends E{create(Y,Z,Q){return this._client.post(O`/vector_stores/${Y}/file_batches`,{body:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:X}=Z;return this._client.get(O`/vector_stores/${X}/file_batches/${Y}`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{vector_store_id:X}=Z;return this._client.post(O`/vector_stores/${X}/file_batches/${Y}/cancel`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let X=await this.create(Y,Z);return await this.poll(Y,X.id,Q)}listFiles(Y,Z,Q){let{vector_store_id:X,...J}=Z;return this._client.getAPIList(O`/vector_stores/${X}/file_batches/${Y}/files`,n,{query:J,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async poll(Y,Z,Q){let X=A([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:J,response:$}=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:X}).withResponse();switch(J.status){case"in_progress":let G=5000;if(Q?.pollIntervalMs)G=Q.pollIntervalMs;else{let K=$.headers.get("openai-poll-after-ms");if(K){let H=parseInt(K);if(!isNaN(H))G=H}}await n0(G);break;case"failed":case"cancelled":case"completed":return J}}}async uploadAndPoll(Y,{files:Z,fileIds:Q=[]},X){if(Z==null||Z.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let J=X?.maxConcurrency??5,$=Math.min(J,Z.length),G=this._client,K=Z.values(),H=[...Q];async function W(q){for(let V of q){let R=await G.files.create({file:V,purpose:"assistants"},X);H.push(R.id)}}let z=Array($).fill(K).map(W);return await RK(z),await this.createAndPoll(Y,{file_ids:H})}}class m8 extends E{create(Y,Z,Q){return this._client.post(O`/vector_stores/${Y}/files`,{body:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:X}=Z;return this._client.get(O`/vector_stores/${X}/files/${Y}`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{vector_store_id:X,...J}=Z;return this._client.post(O`/vector_stores/${X}/files/${Y}`,{body:J,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(O`/vector_stores/${Y}/files`,n,{query:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{vector_store_id:X}=Z;return this._client.delete(O`/vector_stores/${X}/files/${Y}`,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let X=await this.create(Y,Z,Q);return await this.poll(Y,X.id,Q)}async poll(Y,Z,Q){let X=A([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let J=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:X}).withResponse(),$=J.data;switch($.status){case"in_progress":let G=5000;if(Q?.pollIntervalMs)G=Q.pollIntervalMs;else{let K=J.response.headers.get("openai-poll-after-ms");if(K){let H=parseInt(K);if(!isNaN(H))G=H}}await n0(G);break;case"failed":case"completed":return $}}}async upload(Y,Z,Q){let X=await this._client.files.create({file:Z,purpose:"assistants"},Q);return this.create(Y,{file_id:X.id},Q)}async uploadAndPoll(Y,Z,Q){let X=await this.upload(Y,Z,Q);return await this.poll(Y,X.id,Q)}content(Y,Z,Q){let{vector_store_id:X}=Z;return this._client.getAPIList(O`/vector_stores/${X}/files/${Y}/content`,zY,{...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}class jY extends E{constructor(){super(...arguments);this.files=new m8(this._client),this.fileBatches=new g8(this._client)}create(Y,Z){return this._client.post("/vector_stores",{body:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(O`/vector_stores/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(O`/vector_stores/${Y}`,{body:Z,...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/vector_stores",n,{query:Y,...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(O`/vector_stores/${Y}`,{...Z,headers:A([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}search(Y,Z,Q){return this._client.getAPIList(O`/vector_stores/${Y}/search`,zY,{body:Z,method:"post",...Q,headers:A([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}jY.Files=m8;jY.FileBatches=g8;class U1 extends E{create(Y,Z){return this._client.post("/videos",F5({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(O`/videos/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/videos",wY,{query:Y,...Z})}delete(Y,Z){return this._client.delete(O`/videos/${Y}`,Z)}downloadContent(Y,Z={},Q){return this._client.get(O`/videos/${Y}/content`,{query:Z,...Q,headers:A([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}remix(Y,Z,Q){return this._client.post(O`/videos/${Y}/remix`,F5({body:Z,...Q},this._client))}}var q1,MK,iZ;class V1 extends E{constructor(){super(...arguments);q1.add(this)}async unwrap(Y,Z,Q=this._client.webhookSecret,X=300){return await this.verifySignature(Y,Z,Q,X),JSON.parse(Y)}async verifySignature(Y,Z,Q=this._client.webhookSecret,X=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");L(this,q1,"m",MK).call(this,Q);let J=A([Z]).values,$=L(this,q1,"m",iZ).call(this,J,"webhook-signature"),G=L(this,q1,"m",iZ).call(this,J,"webhook-timestamp"),K=L(this,q1,"m",iZ).call(this,J,"webhook-id"),H=parseInt(G,10);if(isNaN(H))throw new KY("Invalid webhook timestamp format");let W=Math.floor(Date.now()/1000);if(W-H>X)throw new KY("Webhook timestamp is too old");if(H>W+X)throw new KY("Webhook timestamp is too new");let z=$.split(" ").map((B)=>B.startsWith("v1,")?B.substring(3):B),q=Q.startsWith("whsec_")?Buffer.from(Q.replace("whsec_",""),"base64"):Buffer.from(Q,"utf-8"),V=K?`${K}.${G}.${Y}`:`${G}.${Y}`,R=await crypto.subtle.importKey("raw",q,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let B of z)try{let M=Buffer.from(B,"base64");if(await crypto.subtle.verify("HMAC",R,M,new TextEncoder().encode(V)))return}catch{continue}throw new KY("The given webhook signature does not match the expected signature")}}q1=new WeakSet,MK=function Y(Z){if(typeof Z!=="string"||Z.length===0)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},iZ=function Y(Z,Q){if(!Z)throw Error("Headers are required");let X=Z.get(Q);if(X===null||X===void 0)throw Error(`Missing required header: ${Q}`);return X};var x5,S5,nZ,DK;class c{constructor({baseURL:Y=EY("OPENAI_BASE_URL"),apiKey:Z=EY("OPENAI_API_KEY"),organization:Q=EY("OPENAI_ORG_ID")??null,project:X=EY("OPENAI_PROJECT_ID")??null,webhookSecret:J=EY("OPENAI_WEBHOOK_SECRET")??null,...$}={}){if(x5.add(this),nZ.set(this,void 0),this.completions=new e6(this),this.chat=new X6(this),this.embeddings=new Z1(this),this.files=new X1(this),this.images=new K1(this),this.audio=new qY(this),this.moderations=new z1(this),this.models=new H1(this),this.fineTuning=new t0(this),this.graders=new V6(this),this.vectorStores=new jY(this),this.webhooks=new V1(this),this.beta=new s0(this),this.batches=new s6(this),this.uploads=new B6(this),this.responses=new IY(this),this.realtime=new kY(this),this.conversations=new U6(this),this.evals=new q6(this),this.containers=new W6(this),this.videos=new U1(this),Z===void 0)throw new S("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");let G={apiKey:Z,organization:Q,project:X,webhookSecret:J,...$,baseURL:Y||"https://api.openai.com/v1"};if(!G.dangerouslyAllowBrowser&&TG())throw new S(`It looks like you're running in a browser-like environment.
|
|
461
|
+
${H}
|
|
462
|
+
${U}`)}return H},k;var J0=R(()=>{jY();XB=Object.freeze(Object.create(null)),k=WI(HB)});var Q8;var P2=R(()=>{K0();J0();Q8=class Q8 extends x{list(Y,Z={},Q){return this._client.getAPIList(k`/chat/completions/${Y}/messages`,Z0,{query:Z,...Q})}}});var MY=R(()=>{jY()});function T4(Y){return Y!==void 0&&"function"in Y&&Y.function!==void 0}function C4(Y){return Y?.$brand==="auto-parseable-response-format"}function W1(Y){return Y?.$brand==="auto-parseable-tool"}function WB(Y,Z){if(!Z||!k9(Z))return{...Y,choices:Y.choices.map((Q)=>{return GB(Q.message.tool_calls),{...Q,message:{...Q.message,parsed:null,...Q.message.tool_calls?{tool_calls:Q.message.tool_calls}:void 0}}})};return k4(Y,Z)}function k4(Y,Z){let Q=Y.choices.map((J)=>{if(J.finish_reason==="length")throw new O4;if(J.finish_reason==="content_filter")throw new D4;return GB(J.message.tool_calls),{...J,message:{...J.message,...J.message.tool_calls?{tool_calls:J.message.tool_calls?.map((z)=>qI(Z,z))??void 0}:void 0,parsed:J.message.content&&!J.message.refusal?$I(Z,J.message.content):null}}});return{...Y,choices:Q}}function $I(Y,Z){if(Y.response_format?.type!=="json_schema")return null;if(Y.response_format?.type==="json_schema"){if("$parseRaw"in Y.response_format)return Y.response_format.$parseRaw(Z);return JSON.parse(Z)}return null}function qI(Y,Z){let Q=Y.tools?.find((J)=>T4(J)&&J.function?.name===Z.function.name);return{...Z,function:{...Z.function,parsed_arguments:W1(Q)?Q.$parseRaw(Z.function.arguments):Q?.function.strict?JSON.parse(Z.function.arguments):null}}}function KB(Y,Z){if(!Y||!("tools"in Y)||!Y.tools)return!1;let Q=Y.tools?.find((J)=>T4(J)&&J.function?.name===Z.function.name);return T4(Q)&&(W1(Q)||Q?.function.strict||!1)}function k9(Y){if(C4(Y.response_format))return!0;return Y.tools?.some((Z)=>W1(Z)||Z.type==="function"&&Z.function.strict===!0)??!1}function GB(Y){for(let Z of Y||[])if(Z.type!=="function")throw new h(`Currently only \`function\` tool calls are supported; Received \`${Z.type}\``)}function $B(Y){for(let Z of Y??[]){if(Z.type!=="function")throw new h(`Currently only \`function\` tool types support auto-parsing; Received \`${Z.type}\``);if(Z.function.strict!==!0)throw new h(`The \`${Z.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var A4=R(()=>{MY()});var J8=(Y)=>{return Y?.role==="assistant"},A9=(Y)=>{return Y?.role==="tool"};class K1{constructor(){x9.add(this),this.controller=new AbortController,S2.set(this,void 0),v2.set(this,()=>{}),x4.set(this,()=>{}),E4.set(this,void 0),y2.set(this,()=>{}),P4.set(this,()=>{}),tY.set(this,{}),S4.set(this,!1),f2.set(this,!1),b2.set(this,!1),z8.set(this,!1),p(this,S2,new Promise((Y,Z)=>{p(this,v2,Y,"f"),p(this,x4,Z,"f")}),"f"),p(this,E4,new Promise((Y,Z)=>{p(this,y2,Y,"f"),p(this,P4,Z,"f")}),"f"),_(this,S2,"f").catch(()=>{}),_(this,E4,"f").catch(()=>{})}_run(Y){setTimeout(()=>{Y().then(()=>{this._emitFinal(),this._emit("end")},_(this,x9,"m",qB).bind(this))},0)}_connected(){if(this.ended)return;_(this,v2,"f").call(this),this._emit("connect")}get ended(){return _(this,S4,"f")}get errored(){return _(this,f2,"f")}get aborted(){return _(this,b2,"f")}abort(){this.controller.abort()}on(Y,Z){return(_(this,tY,"f")[Y]||(_(this,tY,"f")[Y]=[])).push({listener:Z}),this}off(Y,Z){let Q=_(this,tY,"f")[Y];if(!Q)return this;let J=Q.findIndex((z)=>z.listener===Z);if(J>=0)Q.splice(J,1);return this}once(Y,Z){return(_(this,tY,"f")[Y]||(_(this,tY,"f")[Y]=[])).push({listener:Z,once:!0}),this}emitted(Y){return new Promise((Z,Q)=>{if(p(this,z8,!0,"f"),Y!=="error")this.once("error",Q);this.once(Y,Z)})}async done(){p(this,z8,!0,"f"),await _(this,E4,"f")}_emit(Y,...Z){if(_(this,S4,"f"))return;if(Y==="end")p(this,S4,!0,"f"),_(this,y2,"f").call(this);let Q=_(this,tY,"f")[Y];if(Q)_(this,tY,"f")[Y]=Q.filter((J)=>!J.once),Q.forEach(({listener:J})=>J(...Z));if(Y==="abort"){let J=Z[0];if(!_(this,z8,"f")&&!Q?.length)Promise.reject(J);_(this,x4,"f").call(this,J),_(this,P4,"f").call(this,J),this._emit("end");return}if(Y==="error"){let J=Z[0];if(!_(this,z8,"f")&&!Q?.length)Promise.reject(J);_(this,x4,"f").call(this,J),_(this,P4,"f").call(this,J),this._emit("end")}}_emitFinal(){}}var x9,S2,v2,x4,E4,y2,P4,tY,S4,f2,b2,z8,qB;var h2=R(()=>{KY();MY();S2=new WeakMap,v2=new WeakMap,x4=new WeakMap,E4=new WeakMap,y2=new WeakMap,P4=new WeakMap,tY=new WeakMap,S4=new WeakMap,f2=new WeakMap,b2=new WeakMap,z8=new WeakMap,x9=new WeakSet,qB=function Y(Z){if(p(this,f2,!0,"f"),Z instanceof Error&&Z.name==="AbortError")Z=new _0;if(Z instanceof _0)return p(this,b2,!0,"f"),this._emit("abort",Z);if(Z instanceof h)return this._emit("error",Z);if(Z instanceof Error){let Q=new h(Z.message);return Q.cause=Z,this._emit("error",Q)}return this._emit("error",new h(String(Z)))}});function UB(Y){return typeof Y.parse==="function"}var m0,E9,g2,P9,S9,v9,BB,VB,UI=10,v4;var y9=R(()=>{KY();MY();A4();h2();v4=class v4 extends K1{constructor(){super(...arguments);m0.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(Y){this._chatCompletions.push(Y),this._emit("chatCompletion",Y);let Z=Y.choices[0]?.message;if(Z)this._addMessage(Z);return Y}_addMessage(Y,Z=!0){if(!("content"in Y))Y.content=null;if(this.messages.push(Y),Z){if(this._emit("message",Y),A9(Y)&&Y.content)this._emit("functionToolCallResult",Y.content);else if(J8(Y)&&Y.tool_calls){for(let Q of Y.tool_calls)if(Q.type==="function")this._emit("functionToolCall",Q.function)}}}async finalChatCompletion(){await this.done();let Y=this._chatCompletions[this._chatCompletions.length-1];if(!Y)throw new h("stream ended without producing a ChatCompletion");return Y}async finalContent(){return await this.done(),_(this,m0,"m",E9).call(this)}async finalMessage(){return await this.done(),_(this,m0,"m",g2).call(this)}async finalFunctionToolCall(){return await this.done(),_(this,m0,"m",P9).call(this)}async finalFunctionToolCallResult(){return await this.done(),_(this,m0,"m",S9).call(this)}async totalUsage(){return await this.done(),_(this,m0,"m",v9).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let Y=this._chatCompletions[this._chatCompletions.length-1];if(Y)this._emit("finalChatCompletion",Y);let Z=_(this,m0,"m",g2).call(this);if(Z)this._emit("finalMessage",Z);let Q=_(this,m0,"m",E9).call(this);if(Q)this._emit("finalContent",Q);let J=_(this,m0,"m",P9).call(this);if(J)this._emit("finalFunctionToolCall",J);let z=_(this,m0,"m",S9).call(this);if(z!=null)this._emit("finalFunctionToolCallResult",z);if(this._chatCompletions.some((X)=>X.usage))this._emit("totalUsage",_(this,m0,"m",v9).call(this))}async _createChatCompletion(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}_(this,m0,"m",BB).call(this,Z);let z=await Y.chat.completions.create({...Z,stream:!1},{...Q,signal:this.controller.signal});return this._connected(),this._addChatCompletion(k4(z,Z))}async _runChatCompletion(Y,Z,Q){for(let J of Z.messages)this._addMessage(J,!1);return await this._createChatCompletion(Y,Z,Q)}async _runTools(Y,Z,Q){let{tool_choice:z="auto",stream:X,...H}=Z,W=typeof z!=="string"&&z.type==="function"&&z?.function?.name,{maxChatCompletions:K=UI}=Q||{},$=Z.tools.map((B)=>{if(W1(B)){if(!B.$callback)throw new h("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:B.$callback,name:B.function.name,description:B.function.description||"",parameters:B.function.parameters,parse:B.$parseRaw,strict:!0}}}return B}),G={};for(let B of $)if(B.type==="function")G[B.function.name||B.function.function.name]=B.function;let U="tools"in Z?$.map((B)=>B.type==="function"?{type:"function",function:{name:B.function.name||B.function.function.name,parameters:B.function.parameters,description:B.function.description,strict:B.function.strict}}:B):void 0;for(let B of Z.messages)this._addMessage(B,!1);for(let B=0;B<K;++B){let V=(await this._createChatCompletion(Y,{...H,tool_choice:z,tools:U,messages:[...this.messages]},Q)).choices[0]?.message;if(!V)throw new h("missing message in ChatCompletion response");if(!V.tool_calls?.length)return;for(let O of V.tool_calls){if(O.type!=="function")continue;let N=O.id,{name:w,arguments:L}=O.function,I=G[w];if(!I){let P=`Invalid tool_call: ${JSON.stringify(w)}. Available options are: ${Object.keys(G).map((m)=>JSON.stringify(m)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:N,content:P});continue}else if(W&&W!==w){let P=`Invalid tool_call: ${JSON.stringify(w)}. ${JSON.stringify(W)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:N,content:P});continue}let T;try{T=UB(I)?await I.parse(L):L}catch(P){let m=P instanceof Error?P.message:String(P);this._addMessage({role:"tool",tool_call_id:N,content:m});continue}let y=await I.function(T,this),E=_(this,m0,"m",VB).call(this,y);if(this._addMessage({role:"tool",tool_call_id:N,content:E}),W)return}}return}};m0=new WeakSet,E9=function Y(){return _(this,m0,"m",g2).call(this).content??null},g2=function Y(){let Z=this.messages.length;while(Z-- >0){let Q=this.messages[Z];if(J8(Q))return{...Q,content:Q.content??null,refusal:Q.refusal??null}}throw new h("stream ended without producing a ChatCompletionMessage with role=assistant")},P9=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(J8(Q)&&Q?.tool_calls?.length)return Q.tool_calls.filter((J)=>J.type==="function").at(-1)?.function}return},S9=function Y(){for(let Z=this.messages.length-1;Z>=0;Z--){let Q=this.messages[Z];if(A9(Q)&&Q.content!=null&&typeof Q.content==="string"&&this.messages.some((J)=>J.role==="assistant"&&J.tool_calls?.some((z)=>z.type==="function"&&z.id===Q.tool_call_id)))return Q.content}return},v9=function Y(){let Z={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:Q}of this._chatCompletions)if(Q)Z.completion_tokens+=Q.completion_tokens,Z.prompt_tokens+=Q.prompt_tokens,Z.total_tokens+=Q.total_tokens;return Z},BB=function Y(Z){if(Z.n!=null&&Z.n>1)throw new h("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},VB=function Y(Z){return typeof Z==="string"?Z:Z===void 0?"undefined":JSON.stringify(Z)}});var y4;var f9=R(()=>{y9();y4=class y4 extends v4{static runTools(Y,Z,Q){let J=new y4,z={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Y,Z,z)),J}_addMessage(Y,Z=!0){if(super._addMessage(Y,Z),J8(Y)&&Y.content)this._emit("content",Y.content)}}});function BI(Y,Z=A0.ALL){if(typeof Y!=="string")throw TypeError(`expecting str, got ${typeof Y}`);if(!Y.trim())throw Error(`${Y} is empty`);return VI(Y.trim(),Z)}var A0,FB,RB,VI=(Y,Z)=>{let Q=Y.length,J=0,z=(B)=>{throw new FB(`${B} at position ${J}`)},X=(B)=>{throw new RB(`${B} at position ${J}`)},H=()=>{if(U(),J>=Q)z("Unexpected end of input");if(Y[J]==='"')return W();if(Y[J]==="{")return K();if(Y[J]==="[")return $();if(Y.substring(J,J+4)==="null"||A0.NULL&Z&&Q-J<4&&"null".startsWith(Y.substring(J)))return J+=4,null;if(Y.substring(J,J+4)==="true"||A0.BOOL&Z&&Q-J<4&&"true".startsWith(Y.substring(J)))return J+=4,!0;if(Y.substring(J,J+5)==="false"||A0.BOOL&Z&&Q-J<5&&"false".startsWith(Y.substring(J)))return J+=5,!1;if(Y.substring(J,J+8)==="Infinity"||A0.INFINITY&Z&&Q-J<8&&"Infinity".startsWith(Y.substring(J)))return J+=8,1/0;if(Y.substring(J,J+9)==="-Infinity"||A0.MINUS_INFINITY&Z&&1<Q-J&&Q-J<9&&"-Infinity".startsWith(Y.substring(J)))return J+=9,-1/0;if(Y.substring(J,J+3)==="NaN"||A0.NAN&Z&&Q-J<3&&"NaN".startsWith(Y.substring(J)))return J+=3,NaN;return G()},W=()=>{let B=J,F=!1;J++;while(J<Q&&(Y[J]!=='"'||F&&Y[J-1]==="\\"))F=Y[J]==="\\"?!F:!1,J++;if(Y.charAt(J)=='"')try{return JSON.parse(Y.substring(B,++J-Number(F)))}catch(V){X(String(V))}else if(A0.STR&Z)try{return JSON.parse(Y.substring(B,J-Number(F))+'"')}catch(V){return JSON.parse(Y.substring(B,Y.lastIndexOf("\\"))+'"')}z("Unterminated string literal")},K=()=>{J++,U();let B={};try{while(Y[J]!=="}"){if(U(),J>=Q&&A0.OBJ&Z)return B;let F=W();U(),J++;try{let V=H();Object.defineProperty(B,F,{value:V,writable:!0,enumerable:!0,configurable:!0})}catch(V){if(A0.OBJ&Z)return B;else throw V}if(U(),Y[J]===",")J++}}catch(F){if(A0.OBJ&Z)return B;else z("Expected '}' at end of object")}return J++,B},$=()=>{J++;let B=[];try{while(Y[J]!=="]")if(B.push(H()),U(),Y[J]===",")J++}catch(F){if(A0.ARR&Z)return B;z("Expected ']' at end of array")}return J++,B},G=()=>{if(J===0){if(Y==="-"&&A0.NUM&Z)z("Not sure what '-' is");try{return JSON.parse(Y)}catch(F){if(A0.NUM&Z)try{if(Y[Y.length-1]===".")return JSON.parse(Y.substring(0,Y.lastIndexOf(".")));return JSON.parse(Y.substring(0,Y.lastIndexOf("e")))}catch(V){}X(String(F))}}let B=J;if(Y[J]==="-")J++;while(Y[J]&&!",]}".includes(Y[J]))J++;if(J==Q&&!(A0.NUM&Z))z("Unterminated number literal");try{return JSON.parse(Y.substring(B,J))}catch(F){if(Y.substring(B,J)==="-"&&A0.NUM&Z)z("Not sure what '-' is");try{return JSON.parse(Y.substring(B,Y.lastIndexOf("e")))}catch(V){X(String(V))}}},U=()=>{while(J<Q&&`
|
|
463
|
+
\r `.includes(Y[J]))J++};return H()},b9=(Y)=>BI(Y,A0.ALL^A0.NUM);var MB=R(()=>{A0={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};FB=class FB extends Error{};RB=class RB extends Error{}});var h9=R(()=>{D9()});function FI(Y,Z){let{id:Q,choices:J,created:z,model:X,system_fingerprint:H,...W}=Y,K={...W,id:Q,choices:J.map(({message:$,finish_reason:G,index:U,logprobs:B,...F})=>{if(!G)throw new h(`missing finish_reason for choice ${U}`);let{content:V=null,function_call:O,tool_calls:N,...w}=$,L=$.role;if(!L)throw new h(`missing role for choice ${U}`);if(O){let{arguments:I,name:T}=O;if(I==null)throw new h(`missing function_call.arguments for choice ${U}`);if(!T)throw new h(`missing function_call.name for choice ${U}`);return{...F,message:{content:V,function_call:{arguments:I,name:T},role:L,refusal:$.refusal??null},finish_reason:G,index:U,logprobs:B}}if(N)return{...F,index:U,finish_reason:G,logprobs:B,message:{...w,role:L,content:V,refusal:$.refusal??null,tool_calls:N.map((I,T)=>{let{function:y,type:E,id:P,...m}=I,{arguments:g,name:b,...c}=y||{};if(P==null)throw new h(`missing choices[${U}].tool_calls[${T}].id
|
|
464
|
+
${d2(Y)}`);if(E==null)throw new h(`missing choices[${U}].tool_calls[${T}].type
|
|
465
|
+
${d2(Y)}`);if(b==null)throw new h(`missing choices[${U}].tool_calls[${T}].function.name
|
|
466
|
+
${d2(Y)}`);if(g==null)throw new h(`missing choices[${U}].tool_calls[${T}].function.arguments
|
|
467
|
+
${d2(Y)}`);return{...m,id:P,type:E,function:{...c,name:b,arguments:g}}})}};return{...F,message:{...w,content:V,role:L,refusal:$.refusal??null},finish_reason:G,index:U,logprobs:B}}),created:z,model:X,object:"chat.completion",...H?{system_fingerprint:H}:{}};return WB(K,Z)}function d2(Y){return JSON.stringify(Y)}function DB(Y){return}function NB(Y){}var j0,eY,X8,w6,g9,m2,m9,u9,d9,u2,p9,OB,L6;var p2=R(()=>{KY();MB();MY();A4();h9();y9();L6=class L6 extends v4{constructor(Y){super();j0.add(this),eY.set(this,void 0),X8.set(this,void 0),w6.set(this,void 0),p(this,eY,Y,"f"),p(this,X8,[],"f")}get currentChatCompletionSnapshot(){return _(this,w6,"f")}static fromReadableStream(Y){let Z=new L6(null);return Z._run(()=>Z._fromReadableStream(Y)),Z}static createChatCompletion(Y,Z,Q){let J=new L6(Z);return J._run(()=>J._runChatCompletion(Y,{...Z,stream:!0},{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createChatCompletion(Y,Z,Q){super._createChatCompletion;let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}_(this,j0,"m",g9).call(this);let z=await Y.chat.completions.create({...Z,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let X of z)_(this,j0,"m",m9).call(this,X);if(z.controller.signal?.aborted)throw new _0;return this._addChatCompletion(_(this,j0,"m",u2).call(this))}async _fromReadableStream(Y,Z){let Q=Z?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}_(this,j0,"m",g9).call(this),this._connected();let J=t0.fromReadableStream(Y,this.controller),z;for await(let X of J){if(z&&z!==X.id)this._addChatCompletion(_(this,j0,"m",u2).call(this));_(this,j0,"m",m9).call(this,X),z=X.id}if(J.controller.signal?.aborted)throw new _0;return this._addChatCompletion(_(this,j0,"m",u2).call(this))}[(eY=new WeakMap,X8=new WeakMap,w6=new WeakMap,j0=new WeakSet,g9=function Y(){if(this.ended)return;p(this,w6,void 0,"f")},m2=function Y(Z){let Q=_(this,X8,"f")[Z.index];if(Q)return Q;return Q={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},_(this,X8,"f")[Z.index]=Q,Q},m9=function Y(Z){if(this.ended)return;let Q=_(this,j0,"m",OB).call(this,Z);this._emit("chunk",Z,Q);for(let J of Z.choices){let z=Q.choices[J.index];if(J.delta.content!=null&&z.message?.role==="assistant"&&z.message?.content)this._emit("content",J.delta.content,z.message.content),this._emit("content.delta",{delta:J.delta.content,snapshot:z.message.content,parsed:z.message.parsed});if(J.delta.refusal!=null&&z.message?.role==="assistant"&&z.message?.refusal)this._emit("refusal.delta",{delta:J.delta.refusal,snapshot:z.message.refusal});if(J.logprobs?.content!=null&&z.message?.role==="assistant")this._emit("logprobs.content.delta",{content:J.logprobs?.content,snapshot:z.logprobs?.content??[]});if(J.logprobs?.refusal!=null&&z.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:J.logprobs?.refusal,snapshot:z.logprobs?.refusal??[]});let X=_(this,j0,"m",m2).call(this,z);if(z.finish_reason){if(_(this,j0,"m",d9).call(this,z),X.current_tool_call_index!=null)_(this,j0,"m",u9).call(this,z,X.current_tool_call_index)}for(let H of J.delta.tool_calls??[]){if(X.current_tool_call_index!==H.index){if(_(this,j0,"m",d9).call(this,z),X.current_tool_call_index!=null)_(this,j0,"m",u9).call(this,z,X.current_tool_call_index)}X.current_tool_call_index=H.index}for(let H of J.delta.tool_calls??[]){let W=z.message.tool_calls?.[H.index];if(!W?.type)continue;if(W?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:W.function?.name,index:H.index,arguments:W.function.arguments,parsed_arguments:W.function.parsed_arguments,arguments_delta:H.function?.arguments??""});else NB(W?.type)}}},u9=function Y(Z,Q){if(_(this,j0,"m",m2).call(this,Z).done_tool_calls.has(Q))return;let z=Z.message.tool_calls?.[Q];if(!z)throw Error("no tool call snapshot");if(!z.type)throw Error("tool call snapshot missing `type`");if(z.type==="function"){let X=_(this,eY,"f")?.tools?.find((H)=>T4(H)&&H.function.name===z.function.name);this._emit("tool_calls.function.arguments.done",{name:z.function.name,index:Q,arguments:z.function.arguments,parsed_arguments:W1(X)?X.$parseRaw(z.function.arguments):X?.function.strict?JSON.parse(z.function.arguments):null})}else NB(z.type)},d9=function Y(Z){let Q=_(this,j0,"m",m2).call(this,Z);if(Z.message.content&&!Q.content_done){Q.content_done=!0;let J=_(this,j0,"m",p9).call(this);this._emit("content.done",{content:Z.message.content,parsed:J?J.$parseRaw(Z.message.content):null})}if(Z.message.refusal&&!Q.refusal_done)Q.refusal_done=!0,this._emit("refusal.done",{refusal:Z.message.refusal});if(Z.logprobs?.content&&!Q.logprobs_content_done)Q.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:Z.logprobs.content});if(Z.logprobs?.refusal&&!Q.logprobs_refusal_done)Q.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:Z.logprobs.refusal})},u2=function Y(){if(this.ended)throw new h("stream has ended, this shouldn't happen");let Z=_(this,w6,"f");if(!Z)throw new h("request ended without sending any chunks");return p(this,w6,void 0,"f"),p(this,X8,[],"f"),FI(Z,_(this,eY,"f"))},p9=function Y(){let Z=_(this,eY,"f")?.response_format;if(C4(Z))return Z;return null},OB=function Y(Z){var Q,J,z,X;let H=_(this,w6,"f"),{choices:W,...K}=Z;if(!H)H=p(this,w6,{...K,choices:[]},"f");else Object.assign(H,K);for(let{delta:$,finish_reason:G,index:U,logprobs:B=null,...F}of Z.choices){let V=H.choices[U];if(!V)V=H.choices[U]={finish_reason:G,index:U,message:{},logprobs:B,...F};if(B)if(!V.logprobs)V.logprobs=Object.assign({},B);else{let{content:y,refusal:E,...P}=B;if(DB(P),Object.assign(V.logprobs,P),y)(Q=V.logprobs).content??(Q.content=[]),V.logprobs.content.push(...y);if(E)(J=V.logprobs).refusal??(J.refusal=[]),V.logprobs.refusal.push(...E)}if(G){if(V.finish_reason=G,_(this,eY,"f")&&k9(_(this,eY,"f"))){if(G==="length")throw new O4;if(G==="content_filter")throw new D4}}if(Object.assign(V,F),!$)continue;let{content:O,refusal:N,function_call:w,role:L,tool_calls:I,...T}=$;if(DB(T),Object.assign(V.message,T),N)V.message.refusal=(V.message.refusal||"")+N;if(L)V.message.role=L;if(w)if(!V.message.function_call)V.message.function_call=w;else{if(w.name)V.message.function_call.name=w.name;if(w.arguments)(z=V.message.function_call).arguments??(z.arguments=""),V.message.function_call.arguments+=w.arguments}if(O){if(V.message.content=(V.message.content||"")+O,!V.message.refusal&&_(this,j0,"m",p9).call(this))V.message.parsed=b9(V.message.content)}if(I){if(!V.message.tool_calls)V.message.tool_calls=[];for(let{index:y,id:E,type:P,function:m,...g}of I){let b=(X=V.message.tool_calls)[y]??(X[y]={});if(Object.assign(b,g),E)b.id=E;if(P)b.type=P;if(m)b.function??(b.function={name:m.name??"",arguments:""});if(m?.name)b.function.name=m.name;if(m?.arguments){if(b.function.arguments+=m.arguments,KB(_(this,eY,"f"),b))b.function.parsed_arguments=b9(b.function.arguments)}}}}return H},Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("chunk",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,X)=>Z.push({resolve:z,reject:X})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new t0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var H8;var c9=R(()=>{p2();H8=class H8 extends L6{static fromReadableStream(Y){let Z=new H8(null);return Z._run(()=>Z._fromReadableStream(Y)),Z}static runTools(Y,Z,Q){let J=new H8(Z),z={...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"runTools"}};return J._run(()=>J._runTools(Y,Z,z)),J}}});var _6;var f4=R(()=>{P2();P2();K0();J0();f9();c9();p2();A4();c9();p2();f9();_6=class _6 extends x{constructor(){super(...arguments);this.messages=new Q8(this._client)}create(Y,Z){return this._client.post("/chat/completions",{body:Y,...Z,stream:Y.stream??!1})}retrieve(Y,Z){return this._client.get(k`/chat/completions/${Y}`,Z)}update(Y,Z,Q){return this._client.post(k`/chat/completions/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/chat/completions",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/chat/completions/${Y}`,Z)}parse(Y,Z){return $B(Y.tools),this._client.chat.completions.create(Y,{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap((Q)=>k4(Q,Y))}runTools(Y,Z){if(Y.stream)return H8.runTools(this._client,Y,Z);return y4.runTools(this._client,Y,Z)}stream(Y,Z){return L6.createChatCompletion(this._client,Y,Z)}};_6.Messages=Q8});var G1;var l9=R(()=>{f4();f4();G1=class G1 extends x{constructor(){super(...arguments);this.completions=new _6(this._client)}};G1.Completions=_6});var wB=R(()=>{f4();P2();f4()});var LB=R(()=>{l9();wB()});var _B=()=>{};function*MI(Y){if(!Y)return;if(IB in Y){let{values:J,nulls:z}=Y;yield*J.entries();for(let X of z)yield[X,null];return}let Z=!1,Q;if(Y instanceof Headers)Q=Y.entries();else if(H9(Y))Q=Y;else Z=!0,Q=Object.entries(Y??{});for(let J of Q){let z=J[0];if(typeof z!=="string")throw TypeError("expected header name to be a string");let X=H9(J[1])?J[1]:[J[1]],H=!1;for(let W of X){if(W===void 0)continue;if(Z&&!H)H=!0,yield[z,null];yield[z,W]}}}var IB,v=(Y)=>{let Z=new Headers,Q=new Set;for(let J of Y){let z=new Set;for(let[X,H]of MI(J)){let W=X.toLowerCase();if(!z.has(W))Z.delete(X),z.add(W);if(H===null)Z.delete(X),Q.add(W);else Z.append(X,H),Q.delete(W)}}return{[IB]:!0,values:Z,nulls:Q}};var U0=R(()=>{oY();IB=Symbol("brand.privateNullableHeaders")});var b4;var i9=R(()=>{U0();b4=class b4 extends x{create(Y,Z){return this._client.post("/audio/speech",{body:Y,...Z,headers:v([{Accept:"application/octet-stream"},Z?.headers]),__binaryResponse:!0})}}});var h4;var n9=R(()=>{kY();h4=class h4 extends x{create(Y,Z){return this._client.post("/audio/transcriptions",e0({body:Y,...Z,stream:Y.stream??!1,__metadata:{model:Y.model}},this._client))}}});var g4;var a9=R(()=>{kY();g4=class g4 extends x{create(Y,Z){return this._client.post("/audio/translations",e0({body:Y,...Z,__metadata:{model:Y.model}},this._client))}}});var Y6;var o9=R(()=>{i9();i9();n9();n9();a9();a9();Y6=class Y6 extends x{constructor(){super(...arguments);this.transcriptions=new h4(this._client),this.translations=new g4(this._client),this.speech=new b4(this._client)}};Y6.Transcriptions=h4;Y6.Translations=g4;Y6.Speech=b4});var W8;var s9=R(()=>{K0();J0();W8=class W8 extends x{create(Y,Z){return this._client.post("/batches",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/batches/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/batches",Z0,{query:Y,...Z})}cancel(Y,Z){return this._client.post(k`/batches/${Y}/cancel`,Z)}}});var m4;var r9=R(()=>{K0();U0();J0();m4=class m4 extends x{create(Y,Z){return this._client.post("/assistants",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(k`/assistants/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(k`/assistants/${Y}`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/assistants",Z0,{query:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(k`/assistants/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var u4;var t9=R(()=>{U0();u4=class u4 extends x{create(Y,Z){return this._client.post("/realtime/sessions",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var d4;var e9=R(()=>{U0();d4=class d4 extends x{create(Y,Z){return this._client.post("/realtime/transcription_sessions",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}}});var $1;var YJ=R(()=>{t9();t9();e9();e9();$1=class $1 extends x{constructor(){super(...arguments);this.sessions=new u4(this._client),this.transcriptionSessions=new d4(this._client)}};$1.Sessions=u4;$1.TranscriptionSessions=d4});var p4;var ZJ=R(()=>{U0();J0();p4=class p4 extends x{create(Y,Z){return this._client.post("/chatkit/sessions",{body:Y,...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}cancel(Y,Z){return this._client.post(k`/chatkit/sessions/${Y}/cancel`,{...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}}});var c4;var QJ=R(()=>{K0();U0();J0();c4=class c4 extends x{retrieve(Y,Z){return this._client.get(k`/chatkit/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}list(Y={},Z){return this._client.getAPIList("/chatkit/threads",N6,{query:Y,...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}delete(Y,Z){return this._client.delete(k`/chatkit/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers])})}listItems(Y,Z={},Q){return this._client.getAPIList(k`/chatkit/threads/${Y}/items`,N6,{query:Z,...Q,headers:v([{"OpenAI-Beta":"chatkit_beta=v1"},Q?.headers])})}}});var q1;var JJ=R(()=>{ZJ();ZJ();QJ();QJ();q1=class q1 extends x{constructor(){super(...arguments);this.sessions=new p4(this._client),this.threads=new c4(this._client)}};q1.Sessions=p4;q1.Threads=c4});var l4;var zJ=R(()=>{K0();U0();J0();l4=class l4 extends x{create(Y,Z,Q){return this._client.post(k`/threads/${Y}/messages`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{thread_id:J}=Z;return this._client.get(k`/threads/${J}/messages/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(k`/threads/${J}/messages/${Y}`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(k`/threads/${Y}/messages`,Z0,{query:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{thread_id:J}=Z;return this._client.delete(k`/threads/${J}/messages/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var i4;var XJ=R(()=>{K0();U0();J0();i4=class i4 extends x{retrieve(Y,Z,Q){let{thread_id:J,run_id:z,...X}=Z;return this._client.get(k`/threads/${J}/runs/${z}/steps/${Y}`,{query:X,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.getAPIList(k`/threads/${J}/runs/${Y}/steps`,Z0,{query:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var jB=(Y)=>{if(typeof Buffer<"u"){let Z=Buffer.from(Y,"base64");return Array.from(new Float32Array(Z.buffer,Z.byteOffset,Z.length/Float32Array.BYTES_PER_ELEMENT))}else{let Z=atob(Y),Q=Z.length,J=new Uint8Array(Q);for(let z=0;z<Q;z++)J[z]=Z.charCodeAt(z);return Array.from(new Float32Array(J.buffer))}};var TB=R(()=>{jY()});var I6=(Y)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[Y]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(Y)?.trim();return};var n4=R(()=>{oY();TB();L4()});function xI(Y){}var x0,B1,HJ,AY,c2,OY,V1,K8,U1,n2,YY,l2,i2,s4,a4,o4,CB,kB,AB,xB,EB,PB,SB,j6;var WJ=R(()=>{KY();h9();MY();h2();n4();j6=class j6 extends K1{constructor(){super(...arguments);x0.add(this),HJ.set(this,[]),AY.set(this,{}),c2.set(this,{}),OY.set(this,void 0),V1.set(this,void 0),K8.set(this,void 0),U1.set(this,void 0),n2.set(this,void 0),YY.set(this,void 0),l2.set(this,void 0),i2.set(this,void 0),s4.set(this,void 0)}[(HJ=new WeakMap,AY=new WeakMap,c2=new WeakMap,OY=new WeakMap,V1=new WeakMap,K8=new WeakMap,U1=new WeakMap,n2=new WeakMap,YY=new WeakMap,l2=new WeakMap,i2=new WeakMap,s4=new WeakMap,x0=new WeakSet,Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,X)=>Z.push({resolve:z,reject:X})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream(Y){let Z=new B1;return Z._run(()=>Z._fromReadableStream(Y)),Z}async _fromReadableStream(Y,Z){let Q=Z?.signal;if(Q){if(Q.aborted)this.controller.abort();Q.addEventListener("abort",()=>this.controller.abort())}this._connected();let J=t0.fromReadableStream(Y,this.controller);for await(let z of J)_(this,x0,"m",a4).call(this,z);if(J.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}toReadableStream(){return new t0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(Y,Z,Q,J){let z=new B1;return z._run(()=>z._runToolAssistantStream(Y,Z,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),z}async _createToolAssistantStream(Y,Z,Q,J){let z=J?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}let X={...Q,stream:!0},H=await Y.submitToolOutputs(Z,X,{...J,signal:this.controller.signal});this._connected();for await(let W of H)_(this,x0,"m",a4).call(this,W);if(H.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}static createThreadAssistantStream(Y,Z,Q){let J=new B1;return J._run(()=>J._threadAssistantStream(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}static createAssistantStream(Y,Z,Q,J){let z=new B1;return z._run(()=>z._runAssistantStream(Y,Z,Q,{...J,headers:{...J?.headers,"X-Stainless-Helper-Method":"stream"}})),z}currentEvent(){return _(this,l2,"f")}currentRun(){return _(this,i2,"f")}currentMessageSnapshot(){return _(this,OY,"f")}currentRunStepSnapshot(){return _(this,s4,"f")}async finalRunSteps(){return await this.done(),Object.values(_(this,AY,"f"))}async finalMessages(){return await this.done(),Object.values(_(this,c2,"f"))}async finalRun(){if(await this.done(),!_(this,V1,"f"))throw Error("Final run was not received.");return _(this,V1,"f")}async _createThreadAssistantStream(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}let z={...Z,stream:!0},X=await Y.createAndRun(z,{...Q,signal:this.controller.signal});this._connected();for await(let H of X)_(this,x0,"m",a4).call(this,H);if(X.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}async _createAssistantStream(Y,Z,Q,J){let z=J?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}let X={...Q,stream:!0},H=await Y.create(Z,X,{...J,signal:this.controller.signal});this._connected();for await(let W of H)_(this,x0,"m",a4).call(this,W);if(H.controller.signal?.aborted)throw new _0;return this._addRun(_(this,x0,"m",o4).call(this))}static accumulateDelta(Y,Z){for(let[Q,J]of Object.entries(Z)){if(!Y.hasOwnProperty(Q)){Y[Q]=J;continue}let z=Y[Q];if(z===null||z===void 0){Y[Q]=J;continue}if(Q==="index"||Q==="type"){Y[Q]=J;continue}if(typeof z==="string"&&typeof J==="string")z+=J;else if(typeof z==="number"&&typeof J==="number")z+=J;else if(N4(z)&&N4(J))z=this.accumulateDelta(z,J);else if(Array.isArray(z)&&Array.isArray(J)){if(z.every((X)=>typeof X==="string"||typeof X==="number")){z.push(...J);continue}for(let X of J){if(!N4(X))throw Error(`Expected array delta entry to be an object but got: ${X}`);let H=X.index;if(H==null)throw console.error(X),Error("Expected array delta entry to have an `index` property");if(typeof H!=="number")throw Error(`Expected array delta entry \`index\` property to be a number but got ${H}`);let W=z[H];if(W==null)z.push(X);else z[H]=this.accumulateDelta(W,X)}continue}else throw Error(`Unhandled record type: ${Q}, deltaValue: ${J}, accValue: ${z}`);Y[Q]=z}return Y}_addRun(Y){return Y}async _threadAssistantStream(Y,Z,Q){return await this._createThreadAssistantStream(Z,Y,Q)}async _runAssistantStream(Y,Z,Q,J){return await this._createAssistantStream(Z,Y,Q,J)}async _runToolAssistantStream(Y,Z,Q,J){return await this._createToolAssistantStream(Z,Y,Q,J)}};B1=j6,a4=function Y(Z){if(this.ended)return;switch(p(this,l2,Z,"f"),_(this,x0,"m",AB).call(this,Z),Z.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":_(this,x0,"m",SB).call(this,Z);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":_(this,x0,"m",kB).call(this,Z);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":_(this,x0,"m",CB).call(this,Z);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier");default:xI(Z)}},o4=function Y(){if(this.ended)throw new h("stream has ended, this shouldn't happen");if(!_(this,V1,"f"))throw Error("Final run has not been received");return _(this,V1,"f")},CB=function Y(Z){let[Q,J]=_(this,x0,"m",EB).call(this,Z,_(this,OY,"f"));p(this,OY,Q,"f"),_(this,c2,"f")[Q.id]=Q;for(let z of J){let X=Q.content[z.index];if(X?.type=="text")this._emit("textCreated",X.text)}switch(Z.event){case"thread.message.created":this._emit("messageCreated",Z.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",Z.data.delta,Q),Z.data.delta.content)for(let z of Z.data.delta.content){if(z.type=="text"&&z.text){let X=z.text,H=Q.content[z.index];if(H&&H.type=="text")this._emit("textDelta",X,H.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(z.index!=_(this,K8,"f")){if(_(this,U1,"f"))switch(_(this,U1,"f").type){case"text":this._emit("textDone",_(this,U1,"f").text,_(this,OY,"f"));break;case"image_file":this._emit("imageFileDone",_(this,U1,"f").image_file,_(this,OY,"f"));break}p(this,K8,z.index,"f")}p(this,U1,Q.content[z.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(_(this,K8,"f")!==void 0){let z=Z.data.content[_(this,K8,"f")];if(z)switch(z.type){case"image_file":this._emit("imageFileDone",z.image_file,_(this,OY,"f"));break;case"text":this._emit("textDone",z.text,_(this,OY,"f"));break}}if(_(this,OY,"f"))this._emit("messageDone",Z.data);p(this,OY,void 0,"f")}},kB=function Y(Z){let Q=_(this,x0,"m",xB).call(this,Z);switch(p(this,s4,Q,"f"),Z.event){case"thread.run.step.created":this._emit("runStepCreated",Z.data);break;case"thread.run.step.delta":let J=Z.data.delta;if(J.step_details&&J.step_details.type=="tool_calls"&&J.step_details.tool_calls&&Q.step_details.type=="tool_calls")for(let X of J.step_details.tool_calls)if(X.index==_(this,n2,"f"))this._emit("toolCallDelta",X,Q.step_details.tool_calls[X.index]);else{if(_(this,YY,"f"))this._emit("toolCallDone",_(this,YY,"f"));if(p(this,n2,X.index,"f"),p(this,YY,Q.step_details.tool_calls[X.index],"f"),_(this,YY,"f"))this._emit("toolCallCreated",_(this,YY,"f"))}this._emit("runStepDelta",Z.data.delta,Q);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(p(this,s4,void 0,"f"),Z.data.step_details.type=="tool_calls"){if(_(this,YY,"f"))this._emit("toolCallDone",_(this,YY,"f")),p(this,YY,void 0,"f")}this._emit("runStepDone",Z.data,Q);break;case"thread.run.step.in_progress":break}},AB=function Y(Z){_(this,HJ,"f").push(Z),this._emit("event",Z)},xB=function Y(Z){switch(Z.event){case"thread.run.step.created":return _(this,AY,"f")[Z.data.id]=Z.data,Z.data;case"thread.run.step.delta":let Q=_(this,AY,"f")[Z.data.id];if(!Q)throw Error("Received a RunStepDelta before creation of a snapshot");let J=Z.data;if(J.delta){let z=B1.accumulateDelta(Q,J.delta);_(this,AY,"f")[Z.data.id]=z}return _(this,AY,"f")[Z.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":_(this,AY,"f")[Z.data.id]=Z.data;break}if(_(this,AY,"f")[Z.data.id])return _(this,AY,"f")[Z.data.id];throw Error("No snapshot available")},EB=function Y(Z,Q){let J=[];switch(Z.event){case"thread.message.created":return[Z.data,J];case"thread.message.delta":if(!Q)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let z=Z.data;if(z.delta.content)for(let X of z.delta.content)if(X.index in Q.content){let H=Q.content[X.index];Q.content[X.index]=_(this,x0,"m",PB).call(this,X,H)}else Q.content[X.index]=X,J.push(X);return[Q,J];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(Q)return[Q,J];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},PB=function Y(Z,Q){return B1.accumulateDelta(Q,Z)},SB=function Y(Z){switch(p(this,i2,Z.data,"f"),Z.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":if(p(this,V1,Z.data,"f"),_(this,YY,"f"))this._emit("toolCallDone",_(this,YY,"f")),p(this,YY,void 0,"f");break;case"thread.run.cancelling":break}}});var G8;var KJ=R(()=>{XJ();XJ();K0();U0();WJ();J0();G8=class G8 extends x{constructor(){super(...arguments);this.steps=new i4(this._client)}create(Y,Z,Q){let{include:J,...z}=Z;return this._client.post(k`/threads/${Y}/runs`,{query:{include:J},body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}retrieve(Y,Z,Q){let{thread_id:J}=Z;return this._client.get(k`/threads/${J}/runs/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(k`/threads/${J}/runs/${Y}`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(k`/threads/${Y}/runs`,Z0,{query:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{thread_id:J}=Z;return this._client.post(k`/threads/${J}/runs/${Y}/cancel`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z,Q);return await this.poll(J.id,{thread_id:Y},Q)}createAndStream(Y,Z,Q){return j6.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}async poll(Y,Z,Q){let J=v([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:z,response:X}=await this.retrieve(Y,Z,{...Q,headers:{...Q?.headers,...J}}).withResponse();switch(z.status){case"queued":case"in_progress":case"cancelling":let H=5000;if(Q?.pollIntervalMs)H=Q.pollIntervalMs;else{let W=X.headers.get("openai-poll-after-ms");if(W){let K=parseInt(W);if(!isNaN(K))H=K}}await TY(H);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return z}}}stream(Y,Z,Q){return j6.createAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}submitToolOutputs(Y,Z,Q){let{thread_id:J,...z}=Z;return this._client.post(k`/threads/${J}/runs/${Y}/submit_tool_outputs`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers]),stream:Z.stream??!1})}async submitToolOutputsAndPoll(Y,Z,Q){let J=await this.submitToolOutputs(Y,Z,Q);return await this.poll(J.id,Z,Q)}submitToolOutputsStream(Y,Z,Q){return j6.createToolAssistantStream(Y,this._client.beta.threads.runs,Z,Q)}};G8.Steps=i4});var F1;var GJ=R(()=>{zJ();zJ();KJ();KJ();U0();WJ();J0();F1=class F1 extends x{constructor(){super(...arguments);this.runs=new G8(this._client),this.messages=new l4(this._client)}create(Y={},Z){return this._client.post("/threads",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(k`/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(k`/threads/${Y}`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z){return this._client.delete(k`/threads/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}createAndRun(Y,Z){return this._client.post("/threads/runs",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),stream:Y.stream??!1})}async createAndRunPoll(Y,Z){let Q=await this.createAndRun(Y,Z);return await this.runs.poll(Q.id,{thread_id:Q.thread_id},Z)}createAndRunStream(Y,Z){return j6.createThreadAssistantStream(Y,this._client.beta.threads,Z)}};F1.Runs=G8;F1.Messages=l4});var xY;var $J=R(()=>{r9();r9();YJ();YJ();JJ();JJ();GJ();GJ();xY=class xY extends x{constructor(){super(...arguments);this.realtime=new $1(this._client),this.chatkit=new q1(this._client),this.assistants=new m4(this._client),this.threads=new F1(this._client)}};xY.Realtime=$1;xY.ChatKit=q1;xY.Assistants=m4;xY.Threads=F1});var $8;var qJ=R(()=>{$8=class $8 extends x{create(Y,Z){return this._client.post("/completions",{body:Y,...Z,stream:Y.stream??!1})}}});var r4;var UJ=R(()=>{U0();J0();r4=class r4 extends x{retrieve(Y,Z,Q){let{container_id:J}=Z;return this._client.get(k`/containers/${J}/files/${Y}/content`,{...Q,headers:v([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}}});var q8;var BJ=R(()=>{UJ();UJ();K0();U0();kY();J0();q8=class q8 extends x{constructor(){super(...arguments);this.content=new r4(this._client)}create(Y,Z,Q){return this._client.post(k`/containers/${Y}/files`,e0({body:Z,...Q},this._client))}retrieve(Y,Z,Q){let{container_id:J}=Z;return this._client.get(k`/containers/${J}/files/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(k`/containers/${Y}/files`,Z0,{query:Z,...Q})}delete(Y,Z,Q){let{container_id:J}=Z;return this._client.delete(k`/containers/${J}/files/${Y}`,{...Q,headers:v([{Accept:"*/*"},Q?.headers])})}};q8.Content=r4});var R1;var VJ=R(()=>{BJ();BJ();K0();U0();J0();R1=class R1 extends x{constructor(){super(...arguments);this.files=new q8(this._client)}create(Y,Z){return this._client.post("/containers",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/containers/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/containers",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/containers/${Y}`,{...Z,headers:v([{Accept:"*/*"},Z?.headers])})}};R1.Files=q8});var t4;var FJ=R(()=>{K0();J0();t4=class t4 extends x{create(Y,Z,Q){let{include:J,...z}=Z;return this._client.post(k`/conversations/${Y}/items`,{query:{include:J},body:z,...Q})}retrieve(Y,Z,Q){let{conversation_id:J,...z}=Z;return this._client.get(k`/conversations/${J}/items/${Y}`,{query:z,...Q})}list(Y,Z={},Q){return this._client.getAPIList(k`/conversations/${Y}/items`,N6,{query:Z,...Q})}delete(Y,Z,Q){let{conversation_id:J}=Z;return this._client.delete(k`/conversations/${J}/items/${Y}`,Q)}}});var M1;var RJ=R(()=>{FJ();FJ();J0();M1=class M1 extends x{constructor(){super(...arguments);this.items=new t4(this._client)}create(Y={},Z){return this._client.post("/conversations",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/conversations/${Y}`,Z)}update(Y,Z,Q){return this._client.post(k`/conversations/${Y}`,{body:Z,...Q})}delete(Y,Z){return this._client.delete(k`/conversations/${Y}`,Z)}};M1.Items=t4});var U8;var MJ=R(()=>{n4();U8=class U8 extends x{create(Y,Z){let Q=!!Y.encoding_format,J=Q?Y.encoding_format:"base64";if(Q)R0(this._client).debug("embeddings/user defined encoding_format:",Y.encoding_format);let z=this._client.post("/embeddings",{body:{...Y,encoding_format:J},...Z});if(Q)return z;return R0(this._client).debug("embeddings/decoding base64 embeddings from base64"),z._thenUnwrap((X)=>{if(X&&X.data)X.data.forEach((H)=>{let W=H.embedding;H.embedding=jB(W)});return X})}}});var e4;var OJ=R(()=>{K0();J0();e4=class e4 extends x{retrieve(Y,Z,Q){let{eval_id:J,run_id:z}=Z;return this._client.get(k`/evals/${J}/runs/${z}/output_items/${Y}`,Q)}list(Y,Z,Q){let{eval_id:J,...z}=Z;return this._client.getAPIList(k`/evals/${J}/runs/${Y}/output_items`,Z0,{query:z,...Q})}}});var B8;var DJ=R(()=>{OJ();OJ();K0();J0();B8=class B8 extends x{constructor(){super(...arguments);this.outputItems=new e4(this._client)}create(Y,Z,Q){return this._client.post(k`/evals/${Y}/runs`,{body:Z,...Q})}retrieve(Y,Z,Q){let{eval_id:J}=Z;return this._client.get(k`/evals/${J}/runs/${Y}`,Q)}list(Y,Z={},Q){return this._client.getAPIList(k`/evals/${Y}/runs`,Z0,{query:Z,...Q})}delete(Y,Z,Q){let{eval_id:J}=Z;return this._client.delete(k`/evals/${J}/runs/${Y}`,Q)}cancel(Y,Z,Q){let{eval_id:J}=Z;return this._client.post(k`/evals/${J}/runs/${Y}`,Q)}};B8.OutputItems=e4});var O1;var NJ=R(()=>{DJ();DJ();K0();J0();O1=class O1 extends x{constructor(){super(...arguments);this.runs=new B8(this._client)}create(Y,Z){return this._client.post("/evals",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/evals/${Y}`,Z)}update(Y,Z,Q){return this._client.post(k`/evals/${Y}`,{body:Z,...Q})}list(Y={},Z){return this._client.getAPIList("/evals",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/evals/${Y}`,Z)}};O1.Runs=B8});var V8;var wJ=R(()=>{K0();U0();MY();kY();J0();V8=class V8 extends x{create(Y,Z){return this._client.post("/files",e0({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(k`/files/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/files",Z0,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/files/${Y}`,Z)}content(Y,Z){return this._client.get(k`/files/${Y}/content`,{...Z,headers:v([{Accept:"application/binary"},Z?.headers]),__binaryResponse:!0})}async waitForProcessing(Y,{pollInterval:Z=5000,maxWait:Q=1800000}={}){let J=new Set(["processed","error","deleted"]),z=Date.now(),X=await this.retrieve(Y);while(!X.status||!J.has(X.status))if(await TY(Z),X=await this.retrieve(Y),Date.now()-z>Q)throw new X1({message:`Giving up on waiting for file ${Y} to finish processing after ${Q} milliseconds.`});return X}}});var YZ;var LJ=R(()=>{YZ=class YZ extends x{}});var ZZ;var _J=R(()=>{ZZ=class ZZ extends x{run(Y,Z){return this._client.post("/fine_tuning/alpha/graders/run",{body:Y,...Z})}validate(Y,Z){return this._client.post("/fine_tuning/alpha/graders/validate",{body:Y,...Z})}}});var F8;var IJ=R(()=>{_J();_J();F8=class F8 extends x{constructor(){super(...arguments);this.graders=new ZZ(this._client)}};F8.Graders=ZZ});var QZ;var jJ=R(()=>{K0();J0();QZ=class QZ extends x{create(Y,Z,Q){return this._client.getAPIList(k`/fine_tuning/checkpoints/${Y}/permissions`,rY,{body:Z,method:"post",...Q})}retrieve(Y,Z={},Q){return this._client.get(k`/fine_tuning/checkpoints/${Y}/permissions`,{query:Z,...Q})}delete(Y,Z,Q){let{fine_tuned_model_checkpoint:J}=Z;return this._client.delete(k`/fine_tuning/checkpoints/${J}/permissions/${Y}`,Q)}}});var R8;var TJ=R(()=>{jJ();jJ();R8=class R8 extends x{constructor(){super(...arguments);this.permissions=new QZ(this._client)}};R8.Permissions=QZ});var JZ;var CJ=R(()=>{K0();J0();JZ=class JZ extends x{list(Y,Z={},Q){return this._client.getAPIList(k`/fine_tuning/jobs/${Y}/checkpoints`,Z0,{query:Z,...Q})}}});var M8;var kJ=R(()=>{CJ();CJ();K0();J0();M8=class M8 extends x{constructor(){super(...arguments);this.checkpoints=new JZ(this._client)}create(Y,Z){return this._client.post("/fine_tuning/jobs",{body:Y,...Z})}retrieve(Y,Z){return this._client.get(k`/fine_tuning/jobs/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/fine_tuning/jobs",Z0,{query:Y,...Z})}cancel(Y,Z){return this._client.post(k`/fine_tuning/jobs/${Y}/cancel`,Z)}listEvents(Y,Z={},Q){return this._client.getAPIList(k`/fine_tuning/jobs/${Y}/events`,Z0,{query:Z,...Q})}pause(Y,Z){return this._client.post(k`/fine_tuning/jobs/${Y}/pause`,Z)}resume(Y,Z){return this._client.post(k`/fine_tuning/jobs/${Y}/resume`,Z)}};M8.Checkpoints=JZ});var EY;var AJ=R(()=>{LJ();LJ();IJ();IJ();TJ();TJ();kJ();kJ();EY=class EY extends x{constructor(){super(...arguments);this.methods=new YZ(this._client),this.jobs=new M8(this._client),this.checkpoints=new R8(this._client),this.alpha=new F8(this._client)}};EY.Methods=YZ;EY.Jobs=M8;EY.Checkpoints=R8;EY.Alpha=F8});var zZ;var xJ=R(()=>{zZ=class zZ extends x{}});var D1;var EJ=R(()=>{xJ();xJ();D1=class D1 extends x{constructor(){super(...arguments);this.graderModels=new zZ(this._client)}};D1.GraderModels=zZ});var O8;var PJ=R(()=>{kY();O8=class O8 extends x{createVariation(Y,Z){return this._client.post("/images/variations",e0({body:Y,...Z},this._client))}edit(Y,Z){return this._client.post("/images/edits",e0({body:Y,...Z,stream:Y.stream??!1},this._client))}generate(Y,Z){return this._client.post("/images/generations",{body:Y,...Z,stream:Y.stream??!1})}}});var D8;var SJ=R(()=>{K0();J0();D8=class D8 extends x{retrieve(Y,Z){return this._client.get(k`/models/${Y}`,Z)}list(Y){return this._client.getAPIList("/models",rY,Y)}delete(Y,Z){return this._client.delete(k`/models/${Y}`,Z)}}});var N8;var vJ=R(()=>{N8=class N8 extends x{create(Y,Z){return this._client.post("/moderations",{body:Y,...Z})}}});var XZ;var yJ=R(()=>{U0();J0();XZ=class XZ extends x{accept(Y,Z,Q){return this._client.post(k`/realtime/calls/${Y}/accept`,{body:Z,...Q,headers:v([{Accept:"*/*"},Q?.headers])})}hangup(Y,Z){return this._client.post(k`/realtime/calls/${Y}/hangup`,{...Z,headers:v([{Accept:"*/*"},Z?.headers])})}refer(Y,Z,Q){return this._client.post(k`/realtime/calls/${Y}/refer`,{body:Z,...Q,headers:v([{Accept:"*/*"},Q?.headers])})}reject(Y,Z={},Q){return this._client.post(k`/realtime/calls/${Y}/reject`,{body:Z,...Q,headers:v([{Accept:"*/*"},Q?.headers])})}}});var HZ;var fJ=R(()=>{HZ=class HZ extends x{create(Y,Z){return this._client.post("/realtime/client_secrets",{body:Y,...Z})}}});var T6;var bJ=R(()=>{yJ();yJ();fJ();fJ();T6=class T6 extends x{constructor(){super(...arguments);this.clientSecrets=new HZ(this._client),this.calls=new XZ(this._client)}};T6.ClientSecrets=HZ;T6.Calls=XZ});function vB(Y,Z){if(!Z||!oI(Z))return{...Y,output_parsed:null,output:Y.output.map((Q)=>{if(Q.type==="function_call")return{...Q,parsed_arguments:null};if(Q.type==="message")return{...Q,content:Q.content.map((J)=>({...J,parsed:null}))};else return Q})};return hJ(Y,Z)}function hJ(Y,Z){let Q=Y.output.map((z)=>{if(z.type==="function_call")return{...z,parsed_arguments:tI(Z,z)};if(z.type==="message"){let X=z.content.map((H)=>{if(H.type==="output_text")return{...H,parsed:aI(Z,H.text)};return H});return{...z,content:X}}return z}),J=Object.assign({},Y,{output:Q});if(!Object.getOwnPropertyDescriptor(Y,"output_text"))a2(J);return Object.defineProperty(J,"output_parsed",{enumerable:!0,get(){for(let z of J.output){if(z.type!=="message")continue;for(let X of z.content)if(X.type==="output_text"&&X.parsed!==null)return X.parsed}return null}}),J}function aI(Y,Z){if(Y.text?.format?.type!=="json_schema")return null;if("$parseRaw"in Y.text?.format)return(Y.text?.format).$parseRaw(Z);return JSON.parse(Z)}function oI(Y){if(C4(Y.text?.format))return!0;return!1}function sI(Y){return Y?.$brand==="auto-parseable-tool"}function rI(Y,Z){return Y.find((Q)=>Q.type==="function"&&Q.name===Z)}function tI(Y,Z){let Q=rI(Y.tools??[],Z.name);return{...Z,...Z,parsed_arguments:sI(Q)?Q.$parseRaw(Z.arguments):Q?.strict?JSON.parse(Z.arguments):null}}function a2(Y){let Z=[];for(let Q of Y.output){if(Q.type!=="message")continue;for(let J of Q.content)if(J.type==="output_text")Z.push(J.text)}Y.output_text=Z.join("")}var gJ=R(()=>{MY();A4()});function eI(Y,Z){return vB(Y,Z)}var w8,o2,C6,s2,yB,fB,bB,hB,r2;var gB=R(()=>{KY();MY();h2();gJ();r2=class r2 extends K1{constructor(Y){super();w8.add(this),o2.set(this,void 0),C6.set(this,void 0),s2.set(this,void 0),p(this,o2,Y,"f")}static createResponse(Y,Z,Q){let J=new r2(Z);return J._run(()=>J._createOrRetrieveResponse(Y,Z,{...Q,headers:{...Q?.headers,"X-Stainless-Helper-Method":"stream"}})),J}async _createOrRetrieveResponse(Y,Z,Q){let J=Q?.signal;if(J){if(J.aborted)this.controller.abort();J.addEventListener("abort",()=>this.controller.abort())}_(this,w8,"m",yB).call(this);let z,X=null;if("response_id"in Z)z=await Y.responses.retrieve(Z.response_id,{stream:!0},{...Q,signal:this.controller.signal,stream:!0}),X=Z.starting_after??null;else z=await Y.responses.create({...Z,stream:!0},{...Q,signal:this.controller.signal});this._connected();for await(let H of z)_(this,w8,"m",fB).call(this,H,X);if(z.controller.signal?.aborted)throw new _0;return _(this,w8,"m",bB).call(this)}[(o2=new WeakMap,C6=new WeakMap,s2=new WeakMap,w8=new WeakSet,yB=function Y(){if(this.ended)return;p(this,C6,void 0,"f")},fB=function Y(Z,Q){if(this.ended)return;let J=(X,H)=>{if(Q==null||H.sequence_number>Q)this._emit(X,H)},z=_(this,w8,"m",hB).call(this,Z);switch(J("event",Z),Z.type){case"response.output_text.delta":{let X=z.output[Z.output_index];if(!X)throw new h(`missing output at index ${Z.output_index}`);if(X.type==="message"){let H=X.content[Z.content_index];if(!H)throw new h(`missing content at index ${Z.content_index}`);if(H.type!=="output_text")throw new h(`expected content to be 'output_text', got ${H.type}`);J("response.output_text.delta",{...Z,snapshot:H.text})}break}case"response.function_call_arguments.delta":{let X=z.output[Z.output_index];if(!X)throw new h(`missing output at index ${Z.output_index}`);if(X.type==="function_call")J("response.function_call_arguments.delta",{...Z,snapshot:X.arguments});break}default:J(Z.type,Z);break}},bB=function Y(){if(this.ended)throw new h("stream has ended, this shouldn't happen");let Z=_(this,C6,"f");if(!Z)throw new h("request ended without sending any events");p(this,C6,void 0,"f");let Q=eI(Z,_(this,o2,"f"));return p(this,s2,Q,"f"),Q},hB=function Y(Z){let Q=_(this,C6,"f");if(!Q){if(Z.type!=="response.created")throw new h(`When snapshot hasn't been set yet, expected 'response.created' event, got ${Z.type}`);return Q=p(this,C6,Z.response,"f"),Q}switch(Z.type){case"response.output_item.added":{Q.output.push(Z.item);break}case"response.content_part.added":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);let z=J.type,X=Z.part;if(z==="message"&&X.type!=="reasoning_text")J.content.push(X);else if(z==="reasoning"&&X.type==="reasoning_text"){if(!J.content)J.content=[];J.content.push(X)}break}case"response.output_text.delta":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);if(J.type==="message"){let z=J.content[Z.content_index];if(!z)throw new h(`missing content at index ${Z.content_index}`);if(z.type!=="output_text")throw new h(`expected content to be 'output_text', got ${z.type}`);z.text+=Z.delta}break}case"response.function_call_arguments.delta":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);if(J.type==="function_call")J.arguments+=Z.delta;break}case"response.reasoning_text.delta":{let J=Q.output[Z.output_index];if(!J)throw new h(`missing output at index ${Z.output_index}`);if(J.type==="reasoning"){let z=J.content?.[Z.content_index];if(!z)throw new h(`missing content at index ${Z.content_index}`);if(z.type!=="reasoning_text")throw new h(`expected content to be 'reasoning_text', got ${z.type}`);z.text+=Z.delta}break}case"response.completed":{p(this,C6,Z.response,"f");break}}return Q},Symbol.asyncIterator)](){let Y=[],Z=[],Q=!1;return this.on("event",(J)=>{let z=Z.shift();if(z)z.resolve(J);else Y.push(J)}),this.on("end",()=>{Q=!0;for(let J of Z)J.resolve(void 0);Z.length=0}),this.on("abort",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),this.on("error",(J)=>{Q=!0;for(let z of Z)z.reject(J);Z.length=0}),{next:async()=>{if(!Y.length){if(Q)return{value:void 0,done:!0};return new Promise((z,X)=>Z.push({resolve:z,reject:X})).then((z)=>z?{value:z,done:!1}:{value:void 0,done:!0})}return{value:Y.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let Y=_(this,s2,"f");if(!Y)throw new h("stream ended without producing a ChatCompletion");return Y}}});var WZ;var mJ=R(()=>{K0();J0();WZ=class WZ extends x{list(Y,Z={},Q){return this._client.getAPIList(k`/responses/${Y}/input_items`,Z0,{query:Z,...Q})}}});var KZ;var uJ=R(()=>{KZ=class KZ extends x{count(Y={},Z){return this._client.post("/responses/input_tokens",{body:Y,...Z})}}});var k6;var dJ=R(()=>{gJ();gB();mJ();mJ();uJ();uJ();U0();J0();k6=class k6 extends x{constructor(){super(...arguments);this.inputItems=new WZ(this._client),this.inputTokens=new KZ(this._client)}create(Y,Z){return this._client.post("/responses",{body:Y,...Z,stream:Y.stream??!1})._thenUnwrap((Q)=>{if("object"in Q&&Q.object==="response")a2(Q);return Q})}retrieve(Y,Z={},Q){return this._client.get(k`/responses/${Y}`,{query:Z,...Q,stream:Z?.stream??!1})._thenUnwrap((J)=>{if("object"in J&&J.object==="response")a2(J);return J})}delete(Y,Z){return this._client.delete(k`/responses/${Y}`,{...Z,headers:v([{Accept:"*/*"},Z?.headers])})}parse(Y,Z){return this._client.responses.create(Y,Z)._thenUnwrap((Q)=>hJ(Q,Y))}stream(Y,Z){return r2.createResponse(this._client,Y,Z)}cancel(Y,Z){return this._client.post(k`/responses/${Y}/cancel`,Z)}compact(Y,Z){return this._client.post("/responses/compact",{body:Y,...Z})}};k6.InputItems=WZ;k6.InputTokens=KZ});var GZ;var pJ=R(()=>{kY();J0();GZ=class GZ extends x{create(Y,Z,Q){return this._client.post(k`/uploads/${Y}/parts`,e0({body:Z,...Q},this._client))}}});var N1;var cJ=R(()=>{pJ();pJ();J0();N1=class N1 extends x{constructor(){super(...arguments);this.parts=new GZ(this._client)}create(Y,Z){return this._client.post("/uploads",{body:Y,...Z})}cancel(Y,Z){return this._client.post(k`/uploads/${Y}/cancel`,Z)}complete(Y,Z,Q){return this._client.post(k`/uploads/${Y}/complete`,{body:Z,...Q})}};N1.Parts=GZ});var mB=async(Y)=>{let Z=await Promise.allSettled(Y),Q=Z.filter((z)=>z.status==="rejected");if(Q.length){for(let z of Q)console.error(z.reason);throw Error(`${Q.length} promise(s) failed - see the above errors`)}let J=[];for(let z of Z)if(z.status==="fulfilled")J.push(z.value);return J};var $Z;var lJ=R(()=>{K0();U0();J0();$Z=class $Z extends x{create(Y,Z,Q){return this._client.post(k`/vector_stores/${Y}/file_batches`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.get(k`/vector_stores/${J}/file_batches/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}cancel(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.post(k`/vector_stores/${J}/file_batches/${Y}/cancel`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z);return await this.poll(Y,J.id,Q)}listFiles(Y,Z,Q){let{vector_store_id:J,...z}=Z;return this._client.getAPIList(k`/vector_stores/${J}/file_batches/${Y}/files`,Z0,{query:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async poll(Y,Z,Q){let J=v([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:z,response:X}=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:J}).withResponse();switch(z.status){case"in_progress":let H=5000;if(Q?.pollIntervalMs)H=Q.pollIntervalMs;else{let W=X.headers.get("openai-poll-after-ms");if(W){let K=parseInt(W);if(!isNaN(K))H=K}}await TY(H);break;case"failed":case"cancelled":case"completed":return z}}}async uploadAndPoll(Y,{files:Z,fileIds:Q=[]},J){if(Z==null||Z.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let z=J?.maxConcurrency??5,X=Math.min(z,Z.length),H=this._client,W=Z.values(),K=[...Q];async function $(U){for(let B of U){let F=await H.files.create({file:B,purpose:"assistants"},J);K.push(F.id)}}let G=Array(X).fill(W).map($);return await mB(G),await this.createAndPoll(Y,{file_ids:K})}}});var qZ;var iJ=R(()=>{K0();U0();n4();J0();qZ=class qZ extends x{create(Y,Z,Q){return this._client.post(k`/vector_stores/${Y}/files`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}retrieve(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.get(k`/vector_stores/${J}/files/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}update(Y,Z,Q){let{vector_store_id:J,...z}=Z;return this._client.post(k`/vector_stores/${J}/files/${Y}`,{body:z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y,Z={},Q){return this._client.getAPIList(k`/vector_stores/${Y}/files`,Z0,{query:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}delete(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.delete(k`/vector_stores/${J}/files/${Y}`,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}async createAndPoll(Y,Z,Q){let J=await this.create(Y,Z,Q);return await this.poll(Y,J.id,Q)}async poll(Y,Z,Q){let J=v([Q?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":Q?.pollIntervalMs?.toString()??void 0}]);while(!0){let z=await this.retrieve(Z,{vector_store_id:Y},{...Q,headers:J}).withResponse(),X=z.data;switch(X.status){case"in_progress":let H=5000;if(Q?.pollIntervalMs)H=Q.pollIntervalMs;else{let W=z.response.headers.get("openai-poll-after-ms");if(W){let K=parseInt(W);if(!isNaN(K))H=K}}await TY(H);break;case"failed":case"completed":return X}}}async upload(Y,Z,Q){let J=await this._client.files.create({file:Z,purpose:"assistants"},Q);return this.create(Y,{file_id:J.id},Q)}async uploadAndPoll(Y,Z,Q){let J=await this.upload(Y,Z,Q);return await this.poll(Y,J.id,Q)}content(Y,Z,Q){let{vector_store_id:J}=Z;return this._client.getAPIList(k`/vector_stores/${J}/files/${Y}/content`,rY,{...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}}});var A6;var nJ=R(()=>{lJ();lJ();iJ();iJ();K0();U0();J0();A6=class A6 extends x{constructor(){super(...arguments);this.files=new qZ(this._client),this.fileBatches=new $Z(this._client)}create(Y,Z){return this._client.post("/vector_stores",{body:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}retrieve(Y,Z){return this._client.get(k`/vector_stores/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}update(Y,Z,Q){return this._client.post(k`/vector_stores/${Y}`,{body:Z,...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}list(Y={},Z){return this._client.getAPIList("/vector_stores",Z0,{query:Y,...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}delete(Y,Z){return this._client.delete(k`/vector_stores/${Y}`,{...Z,headers:v([{"OpenAI-Beta":"assistants=v2"},Z?.headers])})}search(Y,Z,Q){return this._client.getAPIList(k`/vector_stores/${Y}/search`,rY,{body:Z,method:"post",...Q,headers:v([{"OpenAI-Beta":"assistants=v2"},Q?.headers])})}};A6.Files=qZ;A6.FileBatches=$Z});var L8;var aJ=R(()=>{K0();U0();kY();J0();L8=class L8 extends x{create(Y,Z){return this._client.post("/videos",j9({body:Y,...Z},this._client))}retrieve(Y,Z){return this._client.get(k`/videos/${Y}`,Z)}list(Y={},Z){return this._client.getAPIList("/videos",N6,{query:Y,...Z})}delete(Y,Z){return this._client.delete(k`/videos/${Y}`,Z)}downloadContent(Y,Z={},Q){return this._client.get(k`/videos/${Y}/content`,{query:Z,...Q,headers:v([{Accept:"application/binary"},Q?.headers]),__binaryResponse:!0})}remix(Y,Z,Q){return this._client.post(k`/videos/${Y}/remix`,j9({body:Z,...Q},this._client))}}});var _8,uB,t2,I8;var oJ=R(()=>{KY();MY();U0();I8=class I8 extends x{constructor(){super(...arguments);_8.add(this)}async unwrap(Y,Z,Q=this._client.webhookSecret,J=300){return await this.verifySignature(Y,Z,Q,J),JSON.parse(Y)}async verifySignature(Y,Z,Q=this._client.webhookSecret,J=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!=="function"||typeof crypto.subtle.verify!=="function")throw Error("Webhook signature verification is only supported when the `crypto` global is defined");_(this,_8,"m",uB).call(this,Q);let z=v([Z]).values,X=_(this,_8,"m",t2).call(this,z,"webhook-signature"),H=_(this,_8,"m",t2).call(this,z,"webhook-timestamp"),W=_(this,_8,"m",t2).call(this,z,"webhook-id"),K=parseInt(H,10);if(isNaN(K))throw new aY("Invalid webhook timestamp format");let $=Math.floor(Date.now()/1000);if($-K>J)throw new aY("Webhook timestamp is too old");if(K>$+J)throw new aY("Webhook timestamp is too new");let G=X.split(" ").map((V)=>V.startsWith("v1,")?V.substring(3):V),U=Q.startsWith("whsec_")?Buffer.from(Q.replace("whsec_",""),"base64"):Buffer.from(Q,"utf-8"),B=W?`${W}.${H}.${Y}`:`${H}.${Y}`,F=await crypto.subtle.importKey("raw",U,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let V of G)try{let O=Buffer.from(V,"base64");if(await crypto.subtle.verify("HMAC",F,O,new TextEncoder().encode(B)))return}catch{continue}throw new aY("The given webhook signature does not match the expected signature")}};_8=new WeakSet,uB=function Y(Z){if(typeof Z!=="string"||Z.length===0)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},t2=function Y(Z,Q){if(!Z)throw Error("Headers are required");let J=Z.get(Q);if(J===null||J===void 0)throw Error(`Missing required header: ${Q}`);return J}});var dB=R(()=>{o9();s9();$J();qJ();VJ();RJ();MJ();NJ();wJ();AJ();EJ();PJ();SJ();vJ();bJ();dJ();cJ();nJ();aJ();oJ();LB();_B()});class s{constructor({baseURL:Y=I6("OPENAI_BASE_URL"),apiKey:Z=I6("OPENAI_API_KEY"),organization:Q=I6("OPENAI_ORG_ID")??null,project:J=I6("OPENAI_PROJECT_ID")??null,webhookSecret:z=I6("OPENAI_WEBHOOK_SECRET")??null,...X}={}){if(sJ.add(this),e2.set(this,void 0),this.completions=new $8(this),this.chat=new G1(this),this.embeddings=new U8(this),this.files=new V8(this),this.images=new O8(this),this.audio=new Y6(this),this.moderations=new N8(this),this.models=new D8(this),this.fineTuning=new EY(this),this.graders=new D1(this),this.vectorStores=new A6(this),this.webhooks=new I8(this),this.beta=new xY(this),this.batches=new W8(this),this.uploads=new N1(this),this.responses=new k6(this),this.realtime=new T6(this),this.conversations=new M1(this),this.evals=new O1(this),this.containers=new R1(this),this.videos=new L8(this),Z===void 0)throw new h("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");let H={apiKey:Z,organization:Q,project:J,webhookSecret:z,...X,baseURL:Y||"https://api.openai.com/v1"};if(!H.dangerouslyAllowBrowser&&SU())throw new h(`It looks like you're running in a browser-like environment.
|
|
455
468
|
|
|
456
469
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
457
470
|
If you understand the risks and have appropriate mitigations in place,
|
|
@@ -460,7 +473,13 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
460
473
|
new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
|
|
461
474
|
|
|
462
475
|
https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
463
|
-
`);this.baseURL=G.baseURL,this.timeout=G.timeout??S5.DEFAULT_TIMEOUT,this.logger=G.logger??console;let K="warn";this.logLevel=K,this.logLevel=W5(G.logLevel,"ClientOptions.logLevel",this)??W5(EY("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??K,this.fetchOptions=G.fetchOptions,this.maxRetries=G.maxRetries??2,this.fetch=G.fetch??wG(),g(this,nZ,OG,"f"),this._options=G,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Q,this.project=X,this.webhookSecret=J}withOptions(Y){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...Y})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:Y,nulls:Z}){return}async authHeaders(Y){return A([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(Y){return H5(Y,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${_Y}`}defaultIdempotencyKey(){return`stainless-node-retry-${r2()}`}makeStatusError(Y,Z,Q,X){return $0.generate(Y,Z,Q,X)}async _callApiKey(){let Y=this._options.apiKey;if(typeof Y!=="function")return!1;let Z;try{Z=await Y()}catch(Q){if(Q instanceof S)throw Q;throw new S(`Failed to get token from 'apiKey' function: ${Q.message}`,{cause:Q})}if(typeof Z!=="string"||!Z)throw new S(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(Y,Z,Q){let X=!L(this,x5,"m",DK).call(this)&&Q||this.baseURL,J=qG(Y)?new URL(Y):new URL(X+(X.endsWith("/")&&Y.startsWith("/")?Y.slice(1):Y)),$=this.defaultQuery();if(!VG($))Z={...$,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))J.search=this.stringifyQuery(Z);return J.toString()}async prepareOptions(Y){await this._callApiKey()}async prepareRequest(Y,{url:Z,options:Q}){}get(Y,Z){return this.methodRequest("get",Y,Z)}post(Y,Z){return this.methodRequest("post",Y,Z)}patch(Y,Z){return this.methodRequest("patch",Y,Z)}put(Y,Z){return this.methodRequest("put",Y,Z)}delete(Y,Z){return this.methodRequest("delete",Y,Z)}methodRequest(Y,Z,Q){return this.request(Promise.resolve(Q).then((X)=>{return{method:Y,path:Z,...X}}))}request(Y,Z=null){return new Y6(this,this.makeRequest(Y,Z,void 0))}async makeRequest(Y,Z,Q){let X=await Y,J=X.maxRetries??this.maxRetries;if(Z==null)Z=J;await this.prepareOptions(X);let{req:$,url:G,timeout:K}=await this.buildRequest(X,{retryCount:J-Z});await this.prepareRequest($,{url:G,options:X});let H="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),W=Q===void 0?"":`, retryOf: ${Q}`,z=Date.now();if(Q0(this).debug(`[${H}] sending request`,HY({retryOfRequestLogID:Q,method:X.method,url:G,options:X,headers:$.headers})),X.signal?.aborted)throw new K0;let q=new AbortController,V=await this.fetchWithTimeout(G,$,K,q).catch(d1),R=Date.now();if(V instanceof globalThis.Error){let T=`retrying, ${Z} attempts remaining`;if(X.signal?.aborted)throw new K0;let D=u1(V)||/timed? ?out/i.test(String(V)+("cause"in V?String(V.cause):""));if(Z)return Q0(this).info(`[${H}] connection ${D?"timed out":"failed"} - ${T}`),Q0(this).debug(`[${H}] connection ${D?"timed out":"failed"} (${T})`,HY({retryOfRequestLogID:Q,url:G,durationMs:R-z,message:V.message})),this.retryRequest(X,Z,Q??H);if(Q0(this).info(`[${H}] connection ${D?"timed out":"failed"} - error; no more retries left`),Q0(this).debug(`[${H}] connection ${D?"timed out":"failed"} (error; no more retries left)`,HY({retryOfRequestLogID:Q,url:G,durationMs:R-z,message:V.message})),D)throw new eY;throw new rY({cause:V})}let B=[...V.headers.entries()].filter(([T])=>T==="x-request-id").map(([T,D])=>", "+T+": "+JSON.stringify(D)).join(""),M=`[${H}${W}${B}] ${$.method} ${G} ${V.ok?"succeeded":"failed"} with status ${V.status} in ${R-z}ms`;if(!V.ok){let T=await this.shouldRetry(V);if(Z&&T){let x=`retrying, ${Z} attempts remaining`;return await NG(V.body),Q0(this).info(`${M} - ${x}`),Q0(this).debug(`[${H}] response error (${x})`,HY({retryOfRequestLogID:Q,url:V.url,status:V.status,headers:V.headers,durationMs:R-z})),this.retryRequest(X,Z,Q??H,V.headers)}let D=T?"error; no more retries left":"error; not retryable";Q0(this).info(`${M} - ${D}`);let _=await V.text().catch((x)=>d1(x).message),w=RG(_),N=w?void 0:_;throw Q0(this).debug(`[${H}] response error (${D})`,HY({retryOfRequestLogID:Q,url:V.url,status:V.status,headers:V.headers,message:N,durationMs:Date.now()-z})),this.makeStatusError(V.status,w,N,V.headers)}return Q0(this).info(M),Q0(this).debug(`[${H}] response start`,HY({retryOfRequestLogID:Q,url:V.url,status:V.status,headers:V.headers,durationMs:R-z})),{response:V,options:X,controller:q,requestLogID:H,retryOfRequestLogID:Q,startTime:z}}getAPIList(Y,Z,Q){return this.requestAPIList(Z,{method:"get",path:Y,...Q})}requestAPIList(Y,Z){let Q=this.makeRequest(Z,null,void 0);return new EZ(this,Q,Y)}async fetchWithTimeout(Y,Z,Q,X){let{signal:J,method:$,...G}=Z||{};if(J)J.addEventListener("abort",()=>X.abort());let K=setTimeout(()=>X.abort(),Q),H=globalThis.ReadableStream&&G.body instanceof globalThis.ReadableStream||typeof G.body==="object"&&G.body!==null&&Symbol.asyncIterator in G.body,W={signal:X.signal,...H?{duplex:"half"}:{},method:"GET",...G};if($)W.method=$.toUpperCase();try{return await this.fetch.call(void 0,Y,W)}finally{clearTimeout(K)}}async shouldRetry(Y){let Z=Y.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(Y.status===408)return!0;if(Y.status===409)return!0;if(Y.status===429)return!0;if(Y.status>=500)return!0;return!1}async retryRequest(Y,Z,Q,X){let J,$=X?.get("retry-after-ms");if($){let K=parseFloat($);if(!Number.isNaN(K))J=K}let G=X?.get("retry-after");if(G&&!J){let K=parseFloat(G);if(!Number.isNaN(K))J=K*1000;else J=Date.parse(G)-Date.now()}if(!(J&&0<=J&&J<60000)){let K=Y.maxRetries??this.maxRetries;J=this.calculateDefaultRetryTimeoutMillis(Z,K)}return await n0(J),this.makeRequest(Y,Z-1,Q)}calculateDefaultRetryTimeoutMillis(Y,Z){let J=Z-Y,$=Math.min(0.5*Math.pow(2,J),8),G=1-Math.random()*0.25;return $*G*1000}async buildRequest(Y,{retryCount:Z=0}={}){let Q={...Y},{method:X,path:J,query:$,defaultBaseURL:G}=Q,K=this.buildURL(J,$,G);if("timeout"in Q)FG("timeout",Q.timeout);Q.timeout=Q.timeout??this.timeout;let{bodyHeaders:H,body:W}=this.buildBody({options:Q}),z=await this.buildHeaders({options:Y,method:X,bodyHeaders:H,retryCount:Z});return{req:{method:X,headers:z,...Q.signal&&{signal:Q.signal},...globalThis.ReadableStream&&W instanceof globalThis.ReadableStream&&{duplex:"half"},...W&&{body:W},...this.fetchOptions??{},...Q.fetchOptions??{}},url:K,timeout:Q.timeout}}async buildHeaders({options:Y,method:Z,bodyHeaders:Q,retryCount:X}){let J={};if(this.idempotencyHeader&&Z!=="get"){if(!Y.idempotencyKey)Y.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=Y.idempotencyKey}let $=A([J,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(X),...Y.timeout?{"X-Stainless-Timeout":String(Math.trunc(Y.timeout/1000))}:{},..._G(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(Y),this._options.defaultHeaders,Q,Y.headers]);return this.validateHeaders($),$.values}buildBody({options:{body:Y,headers:Z}}){if(!Y)return{bodyHeaders:void 0,body:void 0};let Q=A([Z]);if(ArrayBuffer.isView(Y)||Y instanceof ArrayBuffer||Y instanceof DataView||typeof Y==="string"&&Q.values.has("content-type")||globalThis.Blob&&Y instanceof globalThis.Blob||Y instanceof FormData||Y instanceof URLSearchParams||globalThis.ReadableStream&&Y instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:Y};else if(typeof Y==="object"&&((Symbol.asyncIterator in Y)||(Symbol.iterator in Y)&&("next"in Y)&&typeof Y.next==="function"))return{bodyHeaders:void 0,body:MZ(Y)};else return L(this,nZ,"f").call(this,{body:Y,headers:Q})}}S5=c,nZ=new WeakMap,x5=new WeakSet,DK=function Y(){return this.baseURL!=="https://api.openai.com/v1"};c.OpenAI=S5;c.DEFAULT_TIMEOUT=600000;c.OpenAIError=S;c.APIError=$0;c.APIConnectionError=rY;c.APIConnectionTimeoutError=eY;c.APIUserAbortError=K0;c.NotFoundError=i1;c.ConflictError=n1;c.RateLimitError=o1;c.BadRequestError=p1;c.AuthenticationError=c1;c.InternalServerError=s1;c.PermissionDeniedError=l1;c.UnprocessableEntityError=a1;c.InvalidWebhookSignatureError=KY;c.toFile=kZ;c.Completions=e6;c.Chat=X6;c.Embeddings=Z1;c.Files=X1;c.Images=K1;c.Audio=qY;c.Moderations=z1;c.Models=H1;c.FineTuning=t0;c.Graders=V6;c.VectorStores=jY;c.Webhooks=V1;c.Beta=s0;c.Batches=s6;c.Uploads=B6;c.Responses=IY;c.Realtime=kY;c.Conversations=U6;c.Evals=q6;c.Containers=W6;c.Videos=U1;Y0();class aZ{client;defaultModel;constructor(Y,Z,Q="gpt-5-nano",X){this.client=new c({apiKey:Y,baseURL:Z,defaultHeaders:X}),this.defaultModel=Q}async generate(Y){return(await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,reasoning_effort:Y.reasoning})).choices[0].message.content||""}async*streamGenerate(Y){try{let Z=await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,stream:!0,reasoning_effort:Y.reasoning});for await(let Q of Z){let X=Q.choices[0]?.delta,J=X?.content,$=X?.reasoning_content||X?.reasoning||X?.reasoning_details?.[0]?.summary;if(J||$)yield{chunk:J??void 0,thinkingChunk:$??void 0,metadata:{model:Q.model,finishReason:Q.choices[0]?.finish_reason??void 0}}}}catch(Z){yield{error:G$(Z)?Z:new X0(String(Z),"OPENAI_STREAM_ERROR")}}}}async function oZ(){let Y=await J0(),Z=Y.get("llm.provider")||"openai",Q=await Y.getSecure("llm.apiKey"),X=Y.get("llm.model");if(!Q)throw new X0("No API key found. Please set llm.apiKey in ~/.gdxrc.toml or GDX_LLM_API_KEY env var.","NO_API_KEY");if(Q.startsWith("sk-or-"))Z="openrouter";switch(Z.toLowerCase()){case"openrouter":return new aZ(Q,E$,X,{"HTTP-Referer":"https://github.com/Type-Delta/gdx/tree/main","X-Title":"GDX"});case"openai":return new aZ(Q,void 0,X);default:throw new X0(`Unsupported LLM provider: ${Z}`,"UNSUPPORTED_LLM_PROVIDER")}}function LK(Y){return tY`<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>
|
|
476
|
+
`);this.baseURL=H.baseURL,this.timeout=H.timeout??rJ.DEFAULT_TIMEOUT,this.logger=H.logger??console;let W="warn";this.logLevel=W,this.logLevel=O9(H.logLevel,"ClientOptions.logLevel",this)??O9(I6("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??W,this.fetchOptions=H.fetchOptions,this.maxRetries=H.maxRetries??2,this.fetch=H.fetch??yU(),p(this,e2,bU,"f"),this._options=H,this.apiKey=typeof Z==="string"?Z:"Missing Key",this.organization=Q,this.project=J,this.webhookSecret=z}withOptions(Y){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...Y})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:Y,nulls:Z}){return}async authHeaders(Y){return v([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(Y){return R9(Y,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${D6}`}defaultIdempotencyKey(){return`stainless-node-retry-${X9()}`}makeStatusError(Y,Z,Q,J){return O0.generate(Y,Z,Q,J)}async _callApiKey(){let Y=this._options.apiKey;if(typeof Y!=="function")return!1;let Z;try{Z=await Y()}catch(Q){if(Q instanceof h)throw Q;throw new h(`Failed to get token from 'apiKey' function: ${Q.message}`,{cause:Q})}if(typeof Z!=="string"||!Z)throw new h(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL(Y,Z,Q){let J=!_(this,sJ,"m",pB).call(this)&&Q||this.baseURL,z=jU(Y)?new URL(Y):new URL(J+(J.endsWith("/")&&Y.startsWith("/")?Y.slice(1):Y)),X=this.defaultQuery();if(!TU(X))Z={...X,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))z.search=this.stringifyQuery(Z);return z.toString()}async prepareOptions(Y){await this._callApiKey()}async prepareRequest(Y,{url:Z,options:Q}){}get(Y,Z){return this.methodRequest("get",Y,Z)}post(Y,Z){return this.methodRequest("post",Y,Z)}patch(Y,Z){return this.methodRequest("patch",Y,Z)}put(Y,Z){return this.methodRequest("put",Y,Z)}delete(Y,Z){return this.methodRequest("delete",Y,Z)}methodRequest(Y,Z,Q){return this.request(Promise.resolve(Q).then((J)=>{return{method:Y,path:Z,...J}}))}request(Y,Z=null){return new H1(this,this.makeRequest(Y,Z,void 0))}async makeRequest(Y,Z,Q){let J=await Y,z=J.maxRetries??this.maxRetries;if(Z==null)Z=z;await this.prepareOptions(J);let{req:X,url:H,timeout:W}=await this.buildRequest(J,{retryCount:z-Z});await this.prepareRequest(X,{url:H,options:J});let K="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),$=Q===void 0?"":`, retryOf: ${Q}`,G=Date.now();if(R0(this).debug(`[${K}] sending request`,sY({retryOfRequestLogID:Q,method:J.method,url:H,options:J,headers:X.headers})),J.signal?.aborted)throw new _0;let U=new AbortController,B=await this.fetchWithTimeout(H,X,W,U).catch(G4),F=Date.now();if(B instanceof globalThis.Error){let N=`retrying, ${Z} attempts remaining`;if(J.signal?.aborted)throw new _0;let w=K4(B)||/timed? ?out/i.test(String(B)+("cause"in B?String(B.cause):""));if(Z)return R0(this).info(`[${K}] connection ${w?"timed out":"failed"} - ${N}`),R0(this).debug(`[${K}] connection ${w?"timed out":"failed"} (${N})`,sY({retryOfRequestLogID:Q,url:H,durationMs:F-G,message:B.message})),this.retryRequest(J,Z,Q??K);if(R0(this).info(`[${K}] connection ${w?"timed out":"failed"} - error; no more retries left`),R0(this).debug(`[${K}] connection ${w?"timed out":"failed"} (error; no more retries left)`,sY({retryOfRequestLogID:Q,url:H,durationMs:F-G,message:B.message})),w)throw new X1;throw new z1({cause:B})}let V=[...B.headers.entries()].filter(([N])=>N==="x-request-id").map(([N,w])=>", "+N+": "+JSON.stringify(w)).join(""),O=`[${K}${$}${V}] ${X.method} ${H} ${B.ok?"succeeded":"failed"} with status ${B.status} in ${F-G}ms`;if(!B.ok){let N=await this.shouldRetry(B);if(Z&&N){let E=`retrying, ${Z} attempts remaining`;return await fU(B.body),R0(this).info(`${O} - ${E}`),R0(this).debug(`[${K}] response error (${E})`,sY({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:F-G})),this.retryRequest(J,Z,Q??K,B.headers)}let w=N?"error; no more retries left":"error; not retryable";R0(this).info(`${O} - ${w}`);let L=await B.text().catch((E)=>G4(E).message),I=AU(L),T=I?void 0:L;throw R0(this).debug(`[${K}] response error (${w})`,sY({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,message:T,durationMs:Date.now()-G})),this.makeStatusError(B.status,I,T,B.headers)}return R0(this).info(O),R0(this).debug(`[${K}] response start`,sY({retryOfRequestLogID:Q,url:B.url,status:B.status,headers:B.headers,durationMs:F-G})),{response:B,options:J,controller:U,requestLogID:K,retryOfRequestLogID:Q,startTime:G}}getAPIList(Y,Z,Q){return this.requestAPIList(Z,{method:"get",path:Y,...Q})}requestAPIList(Y,Z){let Q=this.makeRequest(Z,null,void 0);return new A2(this,Q,Y)}async fetchWithTimeout(Y,Z,Q,J){let{signal:z,method:X,...H}=Z||{};if(z)z.addEventListener("abort",()=>J.abort());let W=setTimeout(()=>J.abort(),Q),K=globalThis.ReadableStream&&H.body instanceof globalThis.ReadableStream||typeof H.body==="object"&&H.body!==null&&Symbol.asyncIterator in H.body,$={signal:J.signal,...K?{duplex:"half"}:{},method:"GET",...H};if(X)$.method=X.toUpperCase();try{return await this.fetch.call(void 0,Y,$)}finally{clearTimeout(W)}}async shouldRetry(Y){let Z=Y.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if(Y.status===408)return!0;if(Y.status===409)return!0;if(Y.status===429)return!0;if(Y.status>=500)return!0;return!1}async retryRequest(Y,Z,Q,J){let z,X=J?.get("retry-after-ms");if(X){let W=parseFloat(X);if(!Number.isNaN(W))z=W}let H=J?.get("retry-after");if(H&&!z){let W=parseFloat(H);if(!Number.isNaN(W))z=W*1000;else z=Date.parse(H)-Date.now()}if(!(z&&0<=z&&z<60000)){let W=Y.maxRetries??this.maxRetries;z=this.calculateDefaultRetryTimeoutMillis(Z,W)}return await TY(z),this.makeRequest(Y,Z-1,Q)}calculateDefaultRetryTimeoutMillis(Y,Z){let z=Z-Y,X=Math.min(0.5*Math.pow(2,z),8),H=1-Math.random()*0.25;return X*H*1000}async buildRequest(Y,{retryCount:Z=0}={}){let Q={...Y},{method:J,path:z,query:X,defaultBaseURL:H}=Q,W=this.buildURL(z,X,H);if("timeout"in Q)kU("timeout",Q.timeout);Q.timeout=Q.timeout??this.timeout;let{bodyHeaders:K,body:$}=this.buildBody({options:Q}),G=await this.buildHeaders({options:Y,method:J,bodyHeaders:K,retryCount:Z});return{req:{method:J,headers:G,...Q.signal&&{signal:Q.signal},...globalThis.ReadableStream&&$ instanceof globalThis.ReadableStream&&{duplex:"half"},...$&&{body:$},...this.fetchOptions??{},...Q.fetchOptions??{}},url:W,timeout:Q.timeout}}async buildHeaders({options:Y,method:Z,bodyHeaders:Q,retryCount:J}){let z={};if(this.idempotencyHeader&&Z!=="get"){if(!Y.idempotencyKey)Y.idempotencyKey=this.defaultIdempotencyKey();z[this.idempotencyHeader]=Y.idempotencyKey}let X=v([z,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(J),...Y.timeout?{"X-Stainless-Timeout":String(Math.trunc(Y.timeout/1000))}:{},...vU(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(Y),this._options.defaultHeaders,Q,Y.headers]);return this.validateHeaders(X),X.values}buildBody({options:{body:Y,headers:Z}}){if(!Y)return{bodyHeaders:void 0,body:void 0};let Q=v([Z]);if(ArrayBuffer.isView(Y)||Y instanceof ArrayBuffer||Y instanceof DataView||typeof Y==="string"&&Q.values.has("content-type")||globalThis.Blob&&Y instanceof globalThis.Blob||Y instanceof FormData||Y instanceof URLSearchParams||globalThis.ReadableStream&&Y instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:Y};else if(typeof Y==="object"&&((Symbol.asyncIterator in Y)||(Symbol.iterator in Y)&&("next"in Y)&&typeof Y.next==="function"))return{bodyHeaders:void 0,body:O2(Y)};else return _(this,e2,"f").call(this,{body:Y,headers:Q})}}var sJ,rJ,e2,pB;var Y5=R(()=>{KY();oY();K9();iU();jY();K0();C9();dB();T2();s9();qJ();MJ();wJ();PJ();SJ();vJ();aJ();oJ();o9();$J();l9();VJ();RJ();NJ();AJ();EJ();bJ();dJ();cJ();nJ();K9();U0();L4();oY();rJ=s,e2=new WeakMap,sJ=new WeakSet,pB=function Y(){return this.baseURL!=="https://api.openai.com/v1"};s.OpenAI=rJ;s.DEFAULT_TIMEOUT=600000;s.OpenAIError=h;s.APIError=O0;s.APIConnectionError=z1;s.APIConnectionTimeoutError=X1;s.APIUserAbortError=_0;s.NotFoundError=B4;s.ConflictError=V4;s.RateLimitError=R4;s.BadRequestError=$4;s.AuthenticationError=q4;s.InternalServerError=M4;s.PermissionDeniedError=U4;s.UnprocessableEntityError=F4;s.InvalidWebhookSignatureError=aY;s.toFile=E2;s.Completions=$8;s.Chat=G1;s.Embeddings=U8;s.Files=V8;s.Images=O8;s.Audio=Y6;s.Moderations=N8;s.Models=D8;s.FineTuning=EY;s.Graders=D1;s.VectorStores=A6;s.Webhooks=I8;s.Beta=xY;s.Batches=W8;s.Uploads=N1;s.Responses=k6;s.Realtime=T6;s.Conversations=M1;s.Evals=O1;s.Containers=R1;s.Videos=L8});var cB=R(()=>{U0();MY();n4();Y5()});var lB=R(()=>{Y5();C9();T2();Y5();K0();jY();cB()});class Z5{client;defaultModel;constructor(Y,Z,Q="gpt-5-nano",J){this.client=new s({apiKey:Y,baseURL:Z,defaultHeaders:J}),this.defaultModel=Q}async generate(Y){return(await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,reasoning_effort:Y.reasoning})).choices[0].message.content||""}async*streamGenerate(Y){try{let Z=await this.client.chat.completions.create({messages:[{role:"user",content:Y.prompt}],model:Y.model||this.defaultModel,temperature:Y.temperature,max_tokens:Y.maxTokens,stream:!0,reasoning_effort:Y.reasoning});for await(let Q of Z){let J=Q.choices[0]?.delta,z=J?.content,X=J?.reasoning_content||J?.reasoning||J?.reasoning_details?.[0]?.summary;if(z||X)yield{chunk:z??void 0,thinkingChunk:X??void 0,metadata:{model:Q.model,finishReason:Q.choices[0]?.finish_reason??void 0}}}}catch(Z){yield{error:fz(Z)?Z:new n(String(Z),"OPENAI_STREAM_ERROR")}}}}var iB=R(()=>{lB();z0()});var nB=()=>{};async function UZ(){let Y=await q0(),Z=Y.get("llm.provider")||"openai",Q=await Y.getSecure("llm.apiKey"),J=Y.get("llm.model");if(!Q)throw new n("No API key found. Please set llm.apiKey in ~/.gdx/.gdxrc.toml or GDX_LLM_API_KEY env var.","NO_API_KEY");if(Q.startsWith("sk-or-"))Z="openrouter";switch(Z.toLowerCase()){case"openrouter":return new Z5(Q,zX,J,{"HTTP-Referer":"https://github.com/Type-Delta/gdx/tree/main","X-Title":"GDX"});case"openai":return new Z5(Q,void 0,J);default:throw new n(`Unsupported LLM provider: ${Z}`,"UNSUPPORTED_LLM_PROVIDER")}}var tJ=R(()=>{z0();W0();FY();iB();nB()});function aB(Y,Z){var Q=Object.keys(Y);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(Y);Z&&(J=J.filter(function(z){return Object.getOwnPropertyDescriptor(Y,z).enumerable})),Q.push.apply(Q,J)}return Q}function oB(Y){for(var Z=1;Z<arguments.length;Z++){var Q=arguments[Z]!=null?arguments[Z]:{};Z%2?aB(Object(Q),!0).forEach(function(J){Hj(Y,J,Q[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(Y,Object.getOwnPropertyDescriptors(Q)):aB(Object(Q)).forEach(function(J){Object.defineProperty(Y,J,Object.getOwnPropertyDescriptor(Q,J))})}return Y}function Hj(Y,Z,Q){if(Z=Wj(Z),Z in Y)Object.defineProperty(Y,Z,{value:Q,enumerable:!0,configurable:!0,writable:!0});else Y[Z]=Q;return Y}function Wj(Y){var Z=Kj(Y,"string");return typeof Z==="symbol"?Z:String(Z)}function Kj(Y,Z){if(typeof Y!=="object"||Y===null)return Y;var Q=Y[Symbol.toPrimitive];if(Q!==void 0){var J=Q.call(Y,Z||"default");if(typeof J!=="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return(Z==="string"?String:Number)(Y)}function sB(Y){return Z.withOptions=(Q)=>sB(oB(oB({},Y),Q)),Z;function Z(Q,...J){let z=typeof Q==="string"?[Q]:Q.raw,{alignValues:X=!1,escapeSpecialCharacters:H=Array.isArray(Q),trimWhitespace:W=!0}=Y,K="";for(let U=0;U<z.length;U++){let B=z[U];if(H)B=B.replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`").replace(/\\\$/g,"$").replace(/\\\{/g,"{");if(K+=B,U<J.length){let F=X?$j(J[U],K):J[U];K+=F}}let $=K.split(`
|
|
477
|
+
`),G=null;for(let U of $){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;K=$.map((B)=>B[0]===" "||B[0]==="\t"?B.slice(U):B).join(`
|
|
478
|
+
`)}if(W)K=K.trim();if(H)K=K.replace(/\\n/g,`
|
|
479
|
+
`);return K}}function $j(Y,Z){if(typeof Y!=="string"||!Y.includes(`
|
|
480
|
+
`))return Y;let J=Z.slice(Z.lastIndexOf(`
|
|
481
|
+
`)+1).match(/^(\s+)/);if(J){let z=J[1];return Y.replace(/\n/g,`
|
|
482
|
+
${z}`)}return Y}var Gj,w1;var eJ=R(()=>{Gj=sB({}),w1=Gj});function Yz(Y){return w1`<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>
|
|
464
483
|
|
|
465
484
|
<rules>
|
|
466
485
|
Commit message must be in the following format:
|
|
@@ -481,7 +500,7 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
|
481
500
|
|
|
482
501
|
Additional rules:
|
|
483
502
|
- Use the imperative mood in the title (e.g., "Fix bug" not "Fixed bug" or "Fixes bug")
|
|
484
|
-
- Total commit message length
|
|
503
|
+
- IMPORTANT! Total commit message length MUST NOT EXCEED 170 WORDS, keep it concise
|
|
485
504
|
- Do not use Markdown or any other formatting in the output
|
|
486
505
|
- Do not use bullet points outside of the recap section
|
|
487
506
|
- DO NOT PREFIX SECTIONS with labels like "Description:" or "Recap:"
|
|
@@ -491,7 +510,51 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
|
491
510
|
${Y}
|
|
492
511
|
</git-diff>
|
|
493
512
|
|
|
494
|
-
Your commit message:`}function
|
|
513
|
+
Your commit message:`}function rB(Y,Z){return w1`<instructions>You are an expert Git commit message generator. Analyze the provided git diff and generate a commit message that follows the project-specific conventions documented below. Focus on clarity and consistency with the existing commit history. Output ONLY the commit message.</instructions>
|
|
514
|
+
|
|
515
|
+
<project-commit-guidelines>
|
|
516
|
+
${Z}
|
|
517
|
+
</project-commit-guidelines>
|
|
518
|
+
|
|
519
|
+
<rules>
|
|
520
|
+
- Follow the project-specific conventions above strictly
|
|
521
|
+
- Use the imperative mood in commit titles
|
|
522
|
+
- IMPORTANT! Total commit message length MUST NOT EXCEED 170 WORDS, keep it concise
|
|
523
|
+
- Do not use Markdown or any other formatting in the output
|
|
524
|
+
- Output ONLY the commit message without any labels or prefixes
|
|
525
|
+
</rules>
|
|
526
|
+
|
|
527
|
+
<git-diff>
|
|
528
|
+
${Y}
|
|
529
|
+
</git-diff>
|
|
530
|
+
|
|
531
|
+
Your commit message:`}function tB(Y){let Z=Y.map((Q,J)=>`Example ${J+1}:
|
|
532
|
+
${Q}`).join(`
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
`);return w1`<instructions>You are analyzing a Git repository's commit message history to identify and document the commit message conventions used by this project. Study the provided examples and extract the underlying patterns, structure, and style rules.</instructions>
|
|
537
|
+
|
|
538
|
+
<commit-message-examples>
|
|
539
|
+
${Z}
|
|
540
|
+
</commit-message-examples>
|
|
541
|
+
|
|
542
|
+
<task>
|
|
543
|
+
Analyze the commit messages above and produce a concise "Commit Message Guideline" document (max 500 words) that captures:
|
|
544
|
+
1. Overall structure (header/body/footer format, line length limits)
|
|
545
|
+
2. Header conventions (prefixes, types, scopes, title style)
|
|
546
|
+
3. Body conventions (description style, wrapping, bullets if used)
|
|
547
|
+
4. Any recurring patterns or special formatting
|
|
548
|
+
|
|
549
|
+
CRITICAL RULES:
|
|
550
|
+
- Only document patterns that are CLEARLY EVIDENT in the examples
|
|
551
|
+
- Do NOT invent rules that aren't demonstrated in the actual commits
|
|
552
|
+
- If examples are inconsistent, note the variations
|
|
553
|
+
- Be specific and actionable
|
|
554
|
+
- Output ONLY the guideline document, no preamble
|
|
555
|
+
</task>
|
|
556
|
+
|
|
557
|
+
Commit Message Guideline:`}function eB(Y){return w1`<instruction>
|
|
495
558
|
You are an unfiltered Gen-Z dev who speaks like a terminal meme lord.
|
|
496
559
|
You talk in chaotic, funny, exaggerated internet slang. You sprinkle emojis,
|
|
497
560
|
caps, sarcasm, and over-the-top reactions. Never boring.
|
|
@@ -509,281 +572,413 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
|
509
572
|
${Y}
|
|
510
573
|
</commit>
|
|
511
574
|
|
|
512
|
-
Your unhinged reaction:`}async function
|
|
513
|
-
`);for(let
|
|
514
|
-
${
|
|
515
|
-
`);let
|
|
575
|
+
Your unhinged reaction:`}var Zz=R(()=>{eJ()});async function Qz(Y){let{git$:Z}=Y;try{let Q=await O6(Z,"user.email"),J=(await S`${Z} log -1 --pretty=format:%s\n\n%b --author=${Q} --no-merges`.catch(k8))?.stdout.trim();if(!J||J.length===0)return D.error("Bro, you haven't committed anything yet. \uD83E\uDD23","nocap"),1;let z=J.split(`
|
|
576
|
+
`);for(let G of z)j(`${q("Dim")}▐ ${q()}${G}`);j(`
|
|
577
|
+
${q("Cyan")}${q("Dim")}Reviewing your commit message...${q()}
|
|
578
|
+
`);let X=await UZ(),H=d0({message:"cooking up a roast...",animateGradient:!0,gradientColor:A.Teal300,gradientColorBg:A.Fuchsia400}),W=X.streamGenerate({prompt:eB(J),temperature:0.8,maxTokens:269,reasoning:"low"}),K="",$=!1;for await(let G of W){if(G.error)return H.stop(),D.error(`\uD83D\uDE2D ill bro, the server rejected u
|
|
516
579
|
|
|
517
|
-
${
|
|
518
|
-
`),!
|
|
519
|
-
${
|
|
580
|
+
${d(G.error,{color:!0})}`,"nocap"),1;if(G.chunk){if(!$)$=!0,H.stop();j(G.chunk,""),K+=G.chunk}}if(j(`
|
|
581
|
+
`),!K)return D.error("Unable to generate response (empty response).","nocap"),1;return 0}catch(Q){return D.error(d(Q,{color:!0}),"nocap"),1}}var YV,ZV;var Q5=R(()=>{z0();k0();M0();tJ();$0();Zz();W0();C0();T0();WY();YV={long:()=>{let Y=q("Bright"),Z=q();return a(`
|
|
582
|
+
${Y+u("NOCAP",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
520
583
|
Generate a playful roast for your latest commit message.
|
|
521
584
|
|
|
522
|
-
${
|
|
585
|
+
${Y+u("DESCRIPTION",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
523
586
|
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.
|
|
524
587
|
|
|
525
|
-
${
|
|
588
|
+
${Y+u("WHEN TO USE",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
526
589
|
Use when you want a quick, entertaining summary/critique of your most recent commit message before pushing, or as a lighthearted CI/gaming aid.
|
|
527
590
|
|
|
528
|
-
${
|
|
591
|
+
${Y+u("NOTES",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
529
592
|
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.
|
|
530
|
-
`,Math.min(100,
|
|
531
|
-
${
|
|
593
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Create a humorous critique of your latest commit message.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
594
|
+
${Y}${C} nocap${Q}
|
|
532
595
|
|
|
533
596
|
Examples:
|
|
534
|
-
${
|
|
535
|
-
${
|
|
597
|
+
${Y}${C} nocap ${Q+Z}# Roast the latest commit by the configured git user${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},ZV={$root:[]}});function QV(Y){let Z={},Q=Array.from(new Set(Y));for(let J of Q){if(!J)continue;Z[J]={}}return Z}function J5(Y,Z,Q="$allOf"){let J={},z=Array.from(new Set(Y));for(let X of z){if(!X)continue;J[X]={[Q]:Z}}return J}import x6 from"path";async function zV(Y){let Z=[],Q=!1;try{let z=(await q0()).get("parallel.init","submodule"),X=JV(z);if(X.invalid.length>0)Z.push(`Unknown parallel.init values: ${X.invalid.join(", ")}. Valid values: submodule, pkg.`);let H=JV(Y.noInitList);if(H.invalid.length>0)Z.push(`Unknown --no-init values: ${H.invalid.join(", ")}. Valid values: submodule, pkg.`);if(Y.noInitAll||Y.noInitList==="")Q=!0;let W=new Set(H.values),K=X.values.filter(($)=>!W.has($));if(K.length===0)Q=!0;if(!Q&&K.includes("submodule")){let $=d0({message:"Initializing git submodules..."});try{await zU(Y.git$,Y.worktreePath),$.stop()}catch(G){$.stop(),Z.push(`Submodule init failed. ${d(G,{color:!0})}`)}}if(!Q&&K.includes("pkg")){let $=await Bj(Y.worktreePath);Z.push(...$.warnings)}}catch(J){Z.push(`Init failed. ${d(J,{color:!0})}`)}Uj(Z)}function Uj(Y){for(let Z of Y)D.warn(Z,"worktree-init")}function JV(Y){let Z=[],Q=[],J=new Set,z=[];if(Array.isArray(Y))z=Y.map((X)=>String(X));else if(typeof Y==="string")z=Y.split(",");else if(Y!=null)z=[String(Y)];for(let X of z){let H=X.trim().toLowerCase();if(!H)continue;if(qj.has(H)){let W=H;if(!J.has(W))Z.push(W),J.add(W)}else Q.push(H)}return{values:Z,invalid:Q}}async function Bj(Y){let Z=[],Q=!1,J=Vj(Y,Z);if(J){let z=await Mj(J,Y,Z);Q||=z}if(Rj(Y)){let z=await Oj(Y,Z);Q||=z}return{ran:Q,warnings:Z}}function Vj(Y,Z){let Q=x6.join(Y,"package.json"),J=o(Q),z=x6.join(Y,"bun.lockb"),X=x6.join(Y,"bun.lock"),H=x6.join(Y,"pnpm-lock.yaml"),W=x6.join(Y,"package-lock.json"),K=x6.join(Y,"npm-shrinkwrap.json"),$=null;if(J){let G=Fj(Q,Z);if(G)$=G}if(!$){if(o(z)||o(X))$="bun";else if(o(H))$="pnpm";else if(J&&(o(W)||o(K)))$="npm";else if(J)$="npm"}return $}function Fj(Y,Z){try{let Q=Z6(Y,"utf-8"),z=JSON.parse(Q).packageManager?.split("@")[0]?.trim().toLowerCase();if(z==="npm"||z==="pnpm"||z==="bun")return z;if(z)Z.push(`Unsupported packageManager '${z}' in package.json. Supported: npm, pnpm, bun.`)}catch(Q){Z.push(`Failed to parse package.json: ${d(Q,{color:!0})}`)}return null}function Rj(Y){let Z=x6.join(Y,"uv.lock"),Q=x6.join(Y,"pyproject.toml");return o(Z)||o(Q)}async function Mj(Y,Z,Q){if(!await M6(Y))return Q.push(`Package manager '${Y}' not found in PATH. Skipping install.`),!1;let z=S({cwd:Z,stdout:"inherit",stderr:"inherit"});try{if(Y==="npm")await z`npm install`;else if(Y==="pnpm")await z`pnpm install`;else await z`bun install`;return!0}catch(X){return Q.push(`Package install failed for '${Y}'. ${d(X,{color:!0})}`),!1}}async function Oj(Y,Z){if(!await M6("uv"))return Z.push("Package manager 'uv' not found in PATH. Skipping install."),!1;let J=S({cwd:Y,stdout:"inherit",stderr:"inherit"});try{return await J`uv sync`,!0}catch(z){return Z.push(`Package install failed for 'uv'. ${d(z,{color:!0})}`),!1}}var qj;var XV=R(()=>{z0();u0();k0();$0();FY();WY();qj=new Set(["submodule","pkg"])});import G0 from"path";async function W5(Y){let Z=await I1(Y);if(!Z)return[];if(!o(Z.parallelRoot))return[];let Q=J6(Z.parallelRoot,{withFileTypes:!0}),J=[];for(let z of Q){if(!z.isDirectory())continue;let X=G0.join(Z.parallelRoot,z.name),H=BZ(X);if(!H)continue;let W=H.alias||z.name;J.push(W)}return J.sort((z,X)=>z.localeCompare(X))}function K5(Y){if(!Y||Y.trim()==="")return!1;if(/[/\\ ]/.test(Y))return!1;if(/[<>:"|?*\x00-\x1f]/.test(Y))return!1;return!0}function BZ(Y){let Z=G0.join(Y,".git-parallel.json");try{let Q=Z6(Z,"utf-8"),J=JSON.parse(Q);return D.debug(`Loaded parallel metadata from '${Z}': ${d(J)}`,"parallel"),J}catch{return null}}async function I1(Y){let Q=`${Array.isArray(Y)?Y.join(" "):Y}|${G0.resolve(process.cwd())}`;if(L1&&L1.cacheKey===Q){if(Date.now()<=L1.expiresAt)return L1.context;L1=null}try{let J=await HY(Y),z=G0.basename(J),X=Array.isArray(Y)?Y[0]:Y,H;try{H=(await nY(X,J,["--abbrev-ref","HEAD"])).trim()}catch{H="HEAD"}let W=G0.join(hY,"worktrees"),K=uz(W,J),$=z,G=H,U=null,B=J;if(K){let O=BZ(J);if(O){if(O.project)z=O.project;if(O.branch)H=O.branch;if(O.originPath)B=G0.resolve(O.originPath);if(O.alias)U=O.alias}else U=G0.basename(J);$=O?.safeProject||$,G=O?.safeBranch||G}$=x5($),G=x5(G);let F=G0.join(W,$,G),V={repoRoot:J,projectName:z,branchName:H,safeProjectName:$,safeBranchName:G,parallelRoot:F,originPath:B,alias:U,isParallelWorktree:K};return L1={cacheKey:Q,context:V,expiresAt:Date.now()+HV},V}catch(J){return D.error(d(J,{color:!0}),"parallel"),L1={cacheKey:Q,context:null,expiresAt:Date.now()+HV},null}}async function $V(Y,Z){let Q=await I1(Y);if(!Q)return 1;D.debug(`Removing worktree '${Z}'...`,"parallel");let J=G0.join(Q.parallelRoot,Z),z=Array.isArray(Y)?Y[0]:Y;await eQ(Y);let X=await Y9(Y,J);if(!X&&!o(J))return D.error(`Worktree '${Z}' not found for branch '${Q.branchName}'.`,"parallel"),1;if(X?.locked){let G=X.lockReason?` (${X.lockReason})`:"";return D.error(`Worktree '${Z}' is locked ${G}. Unlock it before removing.`,"parallel"),1}if(!o(J)){if(D.debug(`Worktree path '${J}' is missing on disk. Attempting prune...`,"parallel"),await q2(Y),!await Y9(Y,J))return j(`${q("Cyan")}Removed worktree metadata:${q()} ${Z}`),D.debug(`Worktree '${Z}' pruned successfully.`,"parallel"),0;return D.error(`Worktree '${Z}' is missing on disk and could not be pruned.`,"parallel"),1}try{dz(J,C5.F_OK|C5.W_OK)}catch{return D.error(`Worktree '${Z}' is not accessible or writable. Cannot remove.`,"parallel"),1}D.debug(`Worktree path '${J}' is accessible.`,"parallel");let H=await YU(Y,J);if(D.debug(`Active operations for worktree '${Z}': ${H.length>0?H.join(", "):"none"}`,"parallel"),H.length>0)return D.error(`Worktree '${Z}' has in-progress operations (${H.join(", ")}). Complete or abort them before removing.`,"parallel"),1;if((await S`${z} -C ${J} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0)return D.error(`Worktree '${Z}' has uncommitted changes. Join or clean it before removing.`,"parallel"),1;j("");let K=d0({message:"Preparing worktree for removal..."}),$=await t1(Y,J);if(D.wouldLog("debug"))K.stop(),D.debug(`Submodules in worktree '${Z}': ${$.length>0?$.map((G)=>G.path).join(", "):"none"}`,"parallel"),K.start();if($.length>0){let G=await QU(Y,J,$);if(G.length>0){let U=G.join(", ");return K.stop(),D.error(`Worktree '${Z}' has dirty submodules (${U}). Commit, stash, or clean them before removing.`,"parallel"),1}D.debug(`Deinitializing submodules for worktree '${Z}'...`,"parallel"),j(`${q("Cyan")}Found submodules, deinitializing...${q()}`),K.options.message="Deinitializing submodules...";try{D.debug(`Executing deinit for submodules with ${z} -C ${J}...`,"parallel"),await JU(Y,J)}catch(U){if(K.stop(),(await S`${z} -C ${J} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length===0)await q2(Y);return D.error(`Failed to deinit submodules for '${Z}'.
|
|
598
|
+
${d(U,{color:!0})}`,"parallel"),1}}K.options={...K.options,frames:["███","██▇","██▆","▇▅▆","▆▅▆","▃▅▅","▄▅▄","▃▃▁","▂▂▂","▁ ▁"," ","░ ","▓░ ","█▓░","██▓"],interval:120,message:`Removing worktree '${Z}'...`};try{D.debug(`Executing git worktree remove for '${Z}'...`,"parallel");let G=await S`${Y} worktree remove ${J}`;K.stop(),j(G.stdout.trim());try{D.debug(`Removing directory '${J}' (if exists)...`,"parallel"),x1(J,{recursive:!0,force:!0})}catch{D.warn(`Failed to remove directory '${J}', ignoring.`,"parallel")}return j(`${q("Cyan")}Removed worktree:${q()} ${Z}`),0}catch(G){if(K.stop(),D.debug(`Error removing worktree '${Z}': ${d(G,{color:!0})}`,"parallel"),(G instanceof n0?`${G.stderr||""} ${G.message||""}`:"").toLowerCase().includes("working trees containing submodules cannot be moved or removed"))return D.error(`Worktree '${Z}' contains submodules that must be deinitialized before removal.`,"parallel"),1;if(G instanceof n0&&G.exitCode===255)D.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 D.error(`Failed to remove worktree '${Z}'.
|
|
599
|
+
${d(G,{color:!0})}`,"parallel");let B=await z4("Do you want to force remove the worktree directory? (y/n): ");if(B.toLowerCase()==="y"||B.toLowerCase()==="yes")try{return x1(J,{recursive:!0,force:!0}),await q2(Y),j(`${q("Cyan")}Force removed worktree directory:${q()} ${Z}`),0}catch{return D.error(`Failed to force remove worktree directory '${Z}'.`,"parallel"),1}else return D.warn(`Aborted removing worktree '${Z}'.`,"parallel"),1}finally{K.stop()}}async function _j(Y,Z){let Q=await I1(Y);if(!Q)return 1;if(Q.isParallelWorktree)return D.error("Run `git parallel fork` from the original worktree, not from a fork.","parallel"),1;if(Q.branchName==="HEAD")return D.error("Detached HEAD detected. Switch to a branch before forking.","parallel"),1;if(Z.length<1)return D.error("Missing worktree alias.","parallel"),PY(),1;let J=Z[0];if(!K5(J))return D.error(`Alias '${J}' contains invalid characters or spaces.`,"parallel"),1;let z=Z.slice(1),X=!1,H=null;if(z.hasOption("--no-init")){if(H=z.popValue("--no-init",0,!0),H===null)X=!0}let W=G0.join(Q.parallelRoot,J),K=z.includes("--move")||z.includes("-mv"),$=z.includes("--mirror")||z.includes("-mr"),G=z.filter((T)=>!["--move","--mirror","-mv","-mr"].includes(T));if(G.length>0)return D.error(`Unknown option '${G[0]}'.`,"parallel"),PY(),1;if(o(W))return D.error(`Worktree alias '${J}' already exists for this branch.`,"parallel"),1;let U=G0.join(Q.repoRoot,".git","info","exclude");try{if(!Z6(U,"utf-8").includes(".git-parallel.json"))pz(U,`
|
|
536
600
|
.git-parallel.json
|
|
537
|
-
`)}catch{
|
|
538
|
-
`)}
|
|
539
|
-
`),!
|
|
540
|
-
`).map((
|
|
541
|
-
`)
|
|
542
|
-
${U("
|
|
601
|
+
`)}catch{Q6(U,`.git-parallel.json
|
|
602
|
+
`)}ZY(Q.parallelRoot,{recursive:!0});let B=Array.isArray(Y)?Y[0]:Y,F=(await nY(B,Q.repoRoot,"HEAD")).trim(),O=(await S`${Y} status --porcelain=v1 --untracked-files=normal`).stdout.trim().length>0,N=null,w=null;if(O&&(K||$)){let T=`git-parallel:${J}`;try{if($){let y=await S`${Y} stash create --include-untracked`;await S`${Y} stash store -m ${T} ${y}`,w="mirrored"}else if(K)await S`${Y} stash push --include-untracked -m ${T}`,w="moved";N="stash@{0}"}catch{return D.error("Failed to stash changes before forking.","parallel"),1}}try{await B0`${Y} worktree add --detach ${W} HEAD`}catch{if(D.error("Failed to create the parallel worktree.","parallel"),N)await S`${Y} stash pop ${N}`,j(`${q("Yellow")}Stashed changes restored to the origin worktree.${q()}`);return 1}if(N)try{await S`${Y} -C ${W} stash apply --index ${N}`,await S`${Y} stash drop ${N}`}catch{return D.error("Failed to move local changes into the new worktree.","parallel"),D.warn(`Your changes remain stashed as '${N}'. Apply them manually when ready.`,"parallel"),D.info(`Worktree path: ${W}`,"parallel"),1}let L={alias:J,branch:Q.branchName,safeBranch:Q.safeBranchName,project:Q.projectName,safeProject:Q.safeProjectName,originPath:Q.repoRoot,baseCommit:F,createdAt:new Date().toISOString()},I=G0.join(W,".git-parallel.json");if(Q6(I,JSON.stringify(L,null,2),"utf-8"),j(`${q("Cyan")}Parallel worktree created:${q()} ${W}`),w)j(`${q("Cyan")}Pending changes ${w} to fork '${J}'.${q()}`);return await zV({git$:Y,worktreePath:W,noInitAll:X,noInitList:H}),0}async function Ij(Y,Z){if(Z.length<1)return D.error("Missing worktree alias to remove.","parallel"),PY(),1;let Q=Z[0];if(!K5(Q))return D.error(`Alias '${Q}' contains invalid characters or spaces.`,"parallel"),1;let J=await I1(Y);if(!J)return 1;let z=G0.join(J.parallelRoot,Q);if(G0.resolve(J.repoRoot)===G0.resolve(z))return D.error("Cannot remove the worktree you are currently in. Switch to origin first.","parallel"),1;return await $V(Y,Q)}async function WV(Y,Z,Q=!1){let J=await I1(Y);if(!J)return 1;if(Z.length<1)return D.error("Missing target worktree alias or 'origin'.","parallel"),PY(),1;let z=Z[0],X;if(z.toLowerCase()==="origin"){if(!o(J.originPath))return D.error(`Origin worktree path not found at '${J.originPath}'.`,"parallel"),1;X=J.originPath}else{if(!K5(z))return D.error(`Alias '${z}' contains invalid characters or spaces.`,"parallel"),1;if(X=G0.join(J.parallelRoot,z),!o(X))return D.error(`Worktree '${z}' not found for branch '${J.branchName}'.`,"parallel"),1;if(Z.includes("-c")||Z.includes("--copy"))return await X2(X),j(`${q("Cyan")}Worktree path copied to clipboard!${q()}`),0}if(Q)await iq(X);else await lq(X);return 0}async function jj(Y,Z){let Q=await I1(Y);if(!Q)return 1;let J=Array.isArray(Y)?Y[0]:Y,z=Z.includes("--short")||Z.includes("-s");j(`${q("Cyan")}Project:${q()} ${Q.projectName}`),j(`${q("Cyan")}Branch:${q()} ${Q.branchName}`),j(`${q("Cyan")}Origin:${q()} ${Q.originPath}`);let X=Q.isParallelWorktree?Q.alias:"origin";if(j(`${q("Cyan")}Current:${q()} ${X} ${X!=="origin"?q("Dim")+'(use "origin" alias to refer to main worktree)'+q():""}
|
|
603
|
+
`),!o(Q.parallelRoot))return j(`${q("Yellow")}No forked worktrees found for this branch.${q()}`),0;let W=J6(Q.parallelRoot,{withFileTypes:!0}).filter(($)=>$.isDirectory()).sort(($,G)=>$.name.localeCompare(G.name));if(W.length===0)return j(`${q("Yellow")}No forked worktrees found for this branch.${q()}`),0;let K=!1;for(let $ of W){let G=G0.join(Q.parallelRoot,$.name),U=BZ(G);if(!U)continue;let B=U?.alias||$.name,F=U.baseCommit?.trim();K=!0;let V=d0({message:`Gatering information for ${B}...`}),O=z?3:void 0,[N,w,L,I]=await Promise.all([S`${Y} -C ${G} status --porcelain=v1 --untracked-files=normal`.then((f)=>f.stdout.trim()),xj(Y,G,Q.originPath),F?Z9({gitExec:J,repoPath:G,range:`${F}..HEAD`,maxCount:O,formatTemplate:`${q("Yellow")}%h${q()} %s`}):Promise.resolve({commits:[],totalCount:0,moreCount:0}),F?Ej({git$:Y,gitExec:J,worktreePath:G,baseCommit:F,maxCount:O},V):Promise.resolve({groups:[],totalCount:0})]),T=N.length>0,y=F?F.slice(0,7):"unknown",E=I.totalCount,P=w.ahead>0||E>0,m=E>0?`${w.ahead}+${E}`:`${w.ahead}`,g="";if(P&&w.behind>0)g=`${q("Yellow")}↑${m} ↓${w.behind}${q()}`;else if(P)g=`${q("Green")}↑${m}${q()}`;else if(w.behind>0)g=`${q("Red")}↓${w.behind}${q()}`;else g=`${q("Dim")}up-to-date${q()}`;let b=Q.isParallelWorktree&&B===Q.alias?"●":"○",c=T?`${q("Red")}dirty${q()}`:`${q("Green")}clean${q()}`,Y0=G;if(z){let f=A1(G,50,"mid",-1);Y0=h6(f,`file://${G.replace(/\\/g,"/")}`)}if(V.stop(),j(`${q("Dim")}${b}${q()} ${A1(B,18,"end")} ${fY(c,7,{align:"center"})} ${q("Dim")}${y}${q()} ${hz(g,11)} ${Y0}`),F){if(I.groups.length>0){let f=[{label:"main",commits:L.commits,totalCount:L.totalCount,moreCount:L.moreCount},...I.groups];Pj(f)}else if(L.totalCount>0)UV(" ",L.commits,L.moreCount)}}if(!K)j(`${q("Yellow")}No forked worktrees found for this branch.${q()}`);return j(""),0}async function z5(Y,Z,Q,J){try{await S`${Y} -C ${Z} stash pop ${J}`,j(`${q("Yellow")}Stashed changes restored to fork '${Q}' due to cherry-pick failure.${q()}`)}catch(z){j(`${q("Yellow")}Please restore stash '${J}' manually from fork '${Q}'. Automatic pop failed.${q()}`),D.debug(d(z,{color:!0}),"parallel")}}async function Tj(Y,Z,Q,J,z){if(j(`${q("Yellow")}Cherry-pick stopped at commit ${Q}. To resolve conflicts run:${q()}`),j(`${q("Cyan")}${` git -C "${Y}" cherry-pick ${Q}`}${q()}`),z.length>0){let H=z.map((W)=>W.includes(" ")?`"${W}"`:W).join(" ");j(`${q("Cyan")}${` git -C "${Y}" add -- ${H}`}${q()}`)}else j(`${q("Cyan")}${` git -C "${Y}" add -A`}${q()}`);if(j(`${q("Cyan")}${` git -C "${Y}" cherry-pick --continue`}${q()}`),j(`${q("Cyan")}${` ${C} parallel join ${Z}`}${q()}`),J)j(`${q("Dim")}Stashed changes from fork '${Z}' can be applied after join.${q()}`)}async function qV(Y,Z,Q,J){D.debug(`Joining worktree '${Q}'...`,"parallel");let{keep:z,bringAll:X}=J,H=BZ(Z);if(!H)return D.error(`Missing metadata for worktree '${Q}'. Unable to join automatically.`,"parallel"),1;let W=G0.resolve(H.originPath);if(!o(W))return D.error(`Original worktree path not found. Expected at '${H.originPath}'.`,"parallel"),1;let K=Array.isArray(Y)?Y[0]:Y,[$,G,U]=await Promise.all([S`${Y} -C ${Z} status --porcelain=v1 --untracked-files=normal`,S`${Y} -C ${W} status --porcelain=v1 --untracked-files=normal`,nY(K,Z,"HEAD")]),F=$.stdout.trim().length>0;if(D.debug(`Fork worktree '${Q}' dirty status: ${F?"dirty":"clean"}`,"parallel"),F&&!X&&!z)return D.error(`Fork '${Q}' has uncommitted changes. Re-run with --all to include them or clean the worktree first.`,"parallel"),1;if(G.stdout.trim().length>0&&X&&F)return D.error("Origin worktree has pending changes. Commit or stash them before joining.","parallel"),1;let O=H.baseCommit?.trim();if(!O)return D.error("Fork metadata is missing base commit information. Unable to perform an automatic join.","parallel"),1;let N=null;if(F&&X){let E=`git-parallel-join:${Q}`;D.debug(`Stashing uncommitted changes from fork '${Q}' before joining...`,"parallel");try{await S`${Y} -C ${Z} stash push --include-untracked -m ${E}`,N="stash@{0}"}catch{return D.error("Failed to stash uncommitted changes before joining.","parallel"),1}}let w=U.trim(),L;D.debug(`Enumerating commits from fork '${Q}' since base commit ${O}...`,"parallel");try{let E=(await S`${Y} -C ${Z} rev-list --reverse ${O}..${w}`).stdout.trim();L=E?E.split(`
|
|
604
|
+
`).map((P)=>P.trim()).filter((P)=>P):[]}catch(E){if(N)await S`${Y} -C ${Z} stash pop ${N}`;return D.error("Unable to enumerate commits to join.","parallel"),D.debug(d(E,{color:!0}),"parallel"),1}let I=[],T=[];D.debug(`Found ${L.length} commit(s) to cherry-pick into origin.`,"parallel");for(let E of L){if(!E)continue;try{if(await KV(Y,{originRepoPath:W,commit:E,contextLabel:"origin worktree",forkAlias:Q,stashRef:N}))I.push(E)}catch{if(N)await z5(Y,Z,Q,N);return 1}}let y=await t1(Y,Z);for(let E of y){let P=G0.resolve(Z,E.path),m=G0.resolve(W,E.path),g=G0.join(P,".git"),b=G0.join(m,".git");if(!o(P)||!o(m))continue;if(!o(g)||!o(b))continue;let c=await Q9(K,Z,O,E.path);if(!c)continue;let Y0=[];try{let f=(await nY(K,P,"HEAD")).trim(),N0=(await S`${Y} -C ${P} rev-list --reverse ${c}..${f}`).stdout.trim();Y0=N0?N0.split(`
|
|
605
|
+
`).map((w0)=>w0.trim()).filter((w0)=>w0):[]}catch(f){if(D.error(`Unable to enumerate submodule commits for '${E.path}'.`,"parallel"),D.debug(d(f,{color:!0}),"parallel"),N)await z5(Y,Z,Q,N);return 1}if(Y0.length===0)continue;for(let f of Y0){if(!f)continue;try{try{await S`${K} -c protocol.file.allow=always -C ${m} fetch ${P} ${f}`}catch(w0){if(D.error(`Failed to fetch submodule commit ${f} from '${E.path}'.`,"parallel"),D.debug(d(w0,{color:!0}),"parallel"),N)await z5(Y,Z,Q,N);return 1}if(await KV(Y,{originRepoPath:m,commit:f,contextLabel:`submodule ${E.path}`,forkAlias:Q,stashRef:N}))T.push(f)}catch{if(N)await z5(Y,Z,Q,N);return 1}}}if(N){D.debug(`Applying stashed uncommitted changes from fork '${Q}' to origin...`,"parallel");try{let m=(await S`${Y} -C ${Z} stash list`).stdout.trim().split(`
|
|
606
|
+
`)[0]?.split(":")[0]||N;await S`${Y} -C ${W} stash apply --index ${m}`,await S`${Y} -C ${Z} stash drop ${m}`}catch(E){D.error("Failed to apply uncommitted changes to the origin worktree.","parallel"),D.debug(d(E,{color:!0}),"parallel");try{await S`${Y} -C ${Z} stash pop ${N}`,j(`${q("Yellow")}Stashed changes restored to fork '${Q}' for safety.${q()}`)}catch(P){j(`${q("Yellow")}Please restore stash '${N}' manually from fork '${Q}'. Automatic pop failed.${q()}`),D.debug(d(P,{color:!0}),"parallel")}return 1}}if(I.length>0||T.length>0){if(j(`${q("Cyan")}Cherry-picked ${I.length} commit(s) into origin.${q()}`),T.length>0)j(`${q("Cyan")}Cherry-picked ${T.length} submodule commit(s) into origin.${q()}`)}else j(`${q("Cyan")}No new commits to cherry-pick. Origin was already up to date.${q()}`);if(!z){if(D.debug(`Removing fork worktree '${Q}' after join...`,"parallel"),await $V(Y,Q)!==0)return D.warn(`Failed to remove fork '${Q}' after joining. Please remove it manually later.`),1;j(`${q("Cyan")}Fork '${Q}' merged and removed successfully.${q()}`)}else{try{let E=(await nY(K,W,"HEAD")).trim();if(E){H.baseCommit=E,H.updatedAt=new Date().toISOString();let P=G0.join(Z,".git-parallel.json");Q6(P,JSON.stringify(H,null,2),"utf-8")}}catch{}j(`${q("Cyan")}Fork '${Q}' merged into origin. Worktree kept at:${q()} ${Z}`)}return 0}async function Cj(Y,Z,Q){if(!o(Z.parallelRoot))return j(`${q("Yellow")}No forked worktrees found for this branch.${q()}`),0;let z=J6(Z.parallelRoot,{withFileTypes:!0}).filter((H)=>H.isDirectory()).sort((H,W)=>H.name.localeCompare(W.name));if(z.length===0)return j(`${q("Yellow")}No forked worktrees found for this branch.${q()}`),0;let X=!1;for(let H of z){let W=G0.join(Z.parallelRoot,H.name),K=BZ(W);if(!K)continue;let $=K.alias||H.name;X=!0;let G=await qV(Y,W,$,{keep:Q,bringAll:!1});if(G!==0)return G}if(!X)j(`${q("Yellow")}No forked worktrees found for this branch.${q()}`);return 0}async function kj(Y,Z){let Q=await I1(Y);if(!Q)return 1;let J=["--keep","--all","-r","--recursive"],z=new Set,X=null;for(let U of Z){let B=U.toLowerCase();if(J.includes(B))z.add(B);else if(!X&&!U.startsWith("-"))X=U;else return D.error(`Unknown option '${U}'.`,"parallel"),PY(),1}let H=z.has("--keep"),W=z.has("--all"),K=z.has("-r")||z.has("--recursive");if(K&&W)return D.error("Recursive join does not support --all. Join forks individually.","parallel"),PY(),1;if(K&&X)return D.error("Recursive join does not accept an alias. Omit <alias> with -r.","parallel"),PY(),1;if(K&&Q.isParallelWorktree)return D.error("Run recursive join from the origin worktree, not from a fork.","parallel"),1;if(K)return await Cj(Y,Q,H);let $,G;if(X){if(Q.isParallelWorktree&&Q.alias===X)return D.error("Cannot join the fork you are currently in. Switch to origin or another fork first.","parallel"),1;if(!K5(X))return D.error(`Alias '${X}' contains invalid characters or spaces.`,"parallel"),1;if($=G0.join(Q.parallelRoot,X),G=X,!o($))return D.error(`Worktree '${X}' not found for branch '${Q.branchName}'.`,"parallel"),1}else{if(!Q.isParallelWorktree)return D.error("Either run join from inside a forked worktree, or specify which fork to join.","parallel"),D.info("Usage: git parallel join [<alias>] [--keep|--all] | git parallel join -r [--keep]","parallel"),1;$=Q.repoRoot,G=Q.alias}return await qV(Y,$,G,{keep:H,bringAll:W})}async function Jz(Y){let{git$:Z,args:Q}=Y;if(Q.length<2)return PY(),1;let J=Q[1].toLowerCase(),z=Q.slice(2);switch(J){case"fork":return await _j(Z,z);case"remove":return await Ij(Z,z);case"switch":if(!u6)return D.error("'git parallel switch' requires the shell integration. See readme for details."),1;return await WV(Z,z,!0);case"open":return await WV(Z,z);case"list":return await jj(Z,z);case"join":return await kj(Z,z);case"help":return PY(),0;default:return PY(),1}}async function KV(Y,Z){let{originRepoPath:Q,commit:J,contextLabel:z,forkAlias:X,stashRef:H}=Z;D.debug(`Cherry-picking commit ${J} into ${z}...`,"parallel");let W=J9();try{let K=await S`${Y} ${W} -C ${Q} cherry-pick ${J}`;return _1(K),!0}catch(K){if(await Aj(Y,Q,K,z))return!1;if(_1(X5(K)),!await $2(Y,Q))throw D.error(`Cherry-pick failed while applying commit ${J}.`,"parallel"),D.debug(d(K,{color:!0}),"parallel"),K;if(!cq()){let U=await U2(Y,Q);throw await Tj(Q,X,J,H,U),D.debug(d(K,{color:!0}),"parallel"),K}j(`${q("Yellow")}Cherry-pick paused due to conflicts while applying commit ${J}.${q()}`),j(`${q("Dim")}Resolve conflicts in ${z}, then choose to continue or abort.${q()}`);while(!0){let U=(await z4("Type c to continue, a to abort (c|a): ")).toLowerCase();if(U==="c"||U==="continue"||U==="y"||U==="yes")try{await HU(Y,Q);let B=await S`${Y} ${W} -C ${Q} cherry-pick --continue`;return _1(B),!0}catch(B){if(_1(X5(B)),await $2(Y,Q)){j(`${q("Yellow")}Cherry-pick still has conflicts. Resolve them and try again.${q()}`),D.debug(d(B,{color:!0}),"parallel");continue}throw D.error("Cherry-pick no longer in progress. You may need to resolve the state manually before retrying.","parallel"),D.debug(d(B,{color:!0}),"parallel"),B}if(U==="a"||U==="abort"||U==="n"||U==="no"){try{let B=await S`${Y} ${W} -C ${Q} cherry-pick --abort`;_1(B)}catch(B){throw _1(X5(B)),D.error("Failed to abort cherry-pick.","parallel"),D.debug(d(B,{color:!0}),"parallel"),B}throw D.error(`Cherry-pick aborted while applying commit ${J}.`,"parallel"),K}}}}async function Aj(Y,Z,Q,J){let z=await $2(Y,Z);if(!(XU(Q)||z&&await WU(Y,Z)))return!1;if(!z)return D.debug(`Empty cherry-pick ignored for ${J}.`,"parallel"),!0;try{return await S`${Y} ${J9()} -C ${Z} cherry-pick --skip`,D.debug(`Skipped empty cherry-pick for ${J}.`,"parallel"),!0}catch(H){return _1(X5(H)),D.error(`Failed to skip empty cherry-pick for ${J}.`,"parallel"),D.debug(d(H,{color:!0}),"parallel"),!1}}async function xj(Y,Z,Q){let J=Array.isArray(Y)?Y[0]:Y;try{let[z,X]=await Promise.all([nY(J,Z,"HEAD").then((K)=>K.trim()),nY(J,Q,"HEAD").then((K)=>K.trim())]);if(z===X)return{ahead:0,behind:0};let H=0,W=0;return await Promise.all([(async()=>{try{let K=(await S`${J} -C ${Z} rev-list --count ${X}..${z}`).stdout.trim();H=parseInt(K,10)||0}catch{H=0}})(),(async()=>{try{let K=(await S`${J} -C ${Z} rev-list --count ${z}..${X}`).stdout.trim();W=parseInt(K,10)||0}catch{W=0}})()]),{ahead:H,behind:W}}catch{return{ahead:0,behind:0}}}async function Ej(Y,Z){let{git$:Q,gitExec:J,worktreePath:z,baseCommit:X,maxCount:H}=Y,W=await t1(Q,z);if(W.length===0)return{groups:[],totalCount:0};let K=[],$=0;for(let G of W){let U=G0.resolve(z,G.path),B=G0.join(U,".git");if(!o(U)||!o(B))continue;if(Z)Z.options.message=`Collecting submodule '${G.path}'...`;let F=await Q9(J,z,X,G.path);if(!F)continue;let V=`${F}..HEAD`,O=await Z9({gitExec:J,repoPath:U,range:V,maxCount:H,formatTemplate:`${q("Yellow")}%h${q()} %s`});if(O.totalCount===0)continue;let N=`${G.path} ${q("Dim")}[submodule]${q()}`;K.push({label:N,commits:O.commits,totalCount:O.totalCount,moreCount:O.moreCount}),$+=O.totalCount}return{groups:K,totalCount:$}}function UV(Y,Z,Q){let J=[...Z];if(Q>0)J.push(`${q("Dim")}+${Q} more${q()}`);if(J.length===0)return;for(let z=0;z<J.length;z++){let H=z===J.length-1?"└─ ":"├─ ";j(`${q("Dim")}${Y}${H}${q()}${J[z]}`)}}function Pj(Y){if(Y.length===0)return;for(let Z=0;Z<Y.length;Z++){let Q=Y[Z],J=Z===Y.length-1,z=J?" └─ ":" ├─ ";j(`${q("Dim")}${z}${q()}${Q.label}`),UV(J?" ":" │ ",Q.commits,Q.moreCount)}}function Sj(Y){if(!Y)return"";if(typeof Y==="string")return Y;if(Y instanceof Uint8Array)return new TextDecoder().decode(Y);return String(Y)}function GV(Y){let Z=Sj(Y);if(!Z)return;j(Z,Z.endsWith(`
|
|
607
|
+
`)?"":`
|
|
608
|
+
`)}function _1(Y){GV(Y.stdout),GV(Y.stderr)}function X5(Y){if(Y instanceof n0)return{stdout:Y.stdout,stderr:Y.stderr};let Z=Y;return{stdout:Z?.stdout,stderr:Z?.stderr}}function PY(){j(H5.short+`
|
|
609
|
+
`+H5.usage())}var HV=1000,L1=null,Dj=async({git$:Y})=>{let Z=await W5(Y);return J5(["origin",...Z],["-c","--copy"])},Nj=async({git$:Y})=>{let Z=await W5(Y);return J5(["origin",...Z],["-c","--copy"])},wj=async({git$:Y})=>{let Z=await W5(Y);return{$allOf:["--keep","--all"],"-r":{$allOf:["--keep"]},"--recursive":{$allOf:["--keep"]},...J5(Z,["--keep","--all"])}},Lj=async({git$:Y})=>{let Z=await W5(Y);return QV(Z)},H5,BV;var G5=R(()=>{u0();e8();z0();k0();M0();$0();W0();T0();C0();WY();XV();H5={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
610
|
+
${Y+u("PARALLEL",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
543
611
|
Manage parallel (forked) worktrees for iterative development.
|
|
544
612
|
|
|
545
|
-
${
|
|
546
|
-
\`${
|
|
547
|
-
|
|
548
|
-
${
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
${
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
${
|
|
558
|
-
${
|
|
559
|
-
|
|
560
|
-
${
|
|
561
|
-
|
|
562
|
-
|
|
613
|
+
${Y+u("OVERVIEW",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
614
|
+
\`${Z}${C} parallel${Q}\` helps you create and manage temporary forked worktrees for the current branch. Forked worktrees live under a temp worktree root and contain a small metadata file (.git-parallel.json) so the tool can later join, list or remove them cleanly.
|
|
615
|
+
|
|
616
|
+
Additionally, \`${Z}${C} parallel fork${Q}\` can auto-initialize submodules and
|
|
617
|
+
install dependencies using detected package managers (currently supports npm, pnpm, bun, and uv)
|
|
618
|
+
if configured (see \`${Z}parallel.init${Q}\` config for options),
|
|
619
|
+
getting the fork ready for work in no time.
|
|
620
|
+
|
|
621
|
+
${Y+u("SUBCOMMANDS AND BEHAVIOR",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
622
|
+
- ${Z}fork <alias>${Q}: Creates a detached worktree in a safe temporary namespace. If pending changes exist and you run with \`${Z}--move${Q}\` or \`${Z}--mirror${Q}\`, changes will be moved/applied to the fork. Init behaviors are controlled by config and \`${Z}--no-init${Q}\`.
|
|
623
|
+
- ${Z}join [<alias>] [--keep|--all]${Q}: Cherry-picks commits from the fork back into the origin worktree. \`${Z}--keep${Q}\` retains the fork and updates its base; \`${Z}--all${Q}\` also includes uncommitted changes.
|
|
624
|
+
- ${Z}join -r|--recursive [--keep]${Q}: Joins every fork for the current branch back into origin. Recursive join does not allow \`${Z}--all${Q}\`.
|
|
625
|
+
- ${Z}list${Q}: Lists forks for the current branch with status, base commit, divergence and recent commits. Use ${Z}--short${Q} for compact output.
|
|
626
|
+
- ${Z}remove <alias>${Q}: Removes the forked worktree and cleans up the directory.
|
|
627
|
+
|
|
628
|
+
${Y+u("SAFETY AND NOTES",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
629
|
+
Joining cherry-picks commits into origin; conflicts will prompt for resolve/continue in a TTY or print manual steps in non-interactive shells. Removing a fork will also delete the worktree directory when forced.
|
|
630
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Manage temporary forked worktrees: create, list, join, open and remove.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
631
|
+
${Y}${C} parallel fork ${Z}<alias> [--move|--mirror] [--no-init[=submodule,pkg]]${Q}
|
|
632
|
+
${Y}${C} parallel list${Q}
|
|
633
|
+
${Y}${C} parallel open ${Z}<alias|origin> [-c|--copy]${Q}
|
|
634
|
+
${Y}${C} parallel switch ${Z}<alias|origin> [-c|--copy]${Q}
|
|
635
|
+
${Y}${C} parallel join ${Z}<alias> [--keep|--all]${Q}
|
|
636
|
+
${Y}${C} parallel join ${Z}-r|--recursive [--keep]${Q}
|
|
637
|
+
${Y}${C} parallel remove ${Z}<alias>${Q}
|
|
563
638
|
|
|
564
639
|
Examples:
|
|
565
|
-
${
|
|
566
|
-
${
|
|
567
|
-
${
|
|
568
|
-
|
|
640
|
+
${Y}${C} parallel fork feature-x --move ${Q+Z}# Create fork and optionally move changes${Q}
|
|
641
|
+
${Y}${C} parallel fork feature-x --no-init ${Q+Z}# Skip all init behaviors${Q}
|
|
642
|
+
${Y}${C} parallel fork feature-x --no-init=pkg ${Q+Z}# Skip package installs only${Q}
|
|
643
|
+
${Y}${C} parallel list --short ${Q+Z}# Compact output with recent commits${Q}
|
|
644
|
+
${Y}${C} parallel join feature-x --all ${Q+Z}# Merge fork back into origin${Q}
|
|
645
|
+
${Y}${C} parallel join -r ${Q+Z}# Merge all forks back into origin${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},BV={$root:{fork:["--move","--mirror","--no-init"],list:{},open:Dj,switch:Nj,join:wj,remove:Lj,help:{}}}});async function vj(){let Y=await q0(),Z=RV(Z1),Q=[],J="";j(q("Dim")+`# GDX Configuration
|
|
569
646
|
# read from ${Y.getConfigPath()}
|
|
570
647
|
# (api keys stored separately)
|
|
571
|
-
`+
|
|
572
|
-
`;if(
|
|
573
|
-
`,
|
|
648
|
+
`+q());for(let{key:z}of Z){let X=z.split("."),H=X.slice(0,-1).join("."),W=X[X.length-1];if(!Q.includes(H)){if(Q.length>0)J+=`
|
|
649
|
+
`;if(H){let N=cQ[H];if(J+=`${q("Magenta")+q("Bright")}[${H}]${q()}
|
|
650
|
+
`,N)J+=`${q("Dim")}# ${N.split(`
|
|
574
651
|
`).join(`
|
|
575
|
-
# `)}${
|
|
576
|
-
`}Q.push(
|
|
577
|
-
`:`${
|
|
578
|
-
`;if(Q[Q.length-1]==="")
|
|
579
|
-
`+
|
|
652
|
+
# `)}${q()}
|
|
653
|
+
`}Q.push(H)}let K=Y.get(z);if(K===void 0&&X6.includes(z))K=await Y.getSecure(z);let $=Y.isDefault(z),G=cQ[z]||"",U="",B=!1;switch(typeof K){case"boolean":U=d(K,{color:!0});break;case"number":U=d(K,{color:!0});break;case"string":if(W.toLowerCase().includes("key"))U=d(A1(K,20,"mid",-1),{color:!0});else U=d(K,{color:!0});break;case"undefined":case"object":if(K==null)B=!0,U=d(null,{color:!0});break;default:U=String(K)}let F=$?"":` ${q()+q("Yellow")+q("Italic")}[Modified]${q()+q("Dim")}`,V=G?` ${q("Dim")}#${F} ${G}${q()}`:"",O=B?`${q("Dim")}# ${q("Cyan")+W+q("White")} = ${U}${V}${q()}
|
|
654
|
+
`:`${q("Cyan")+W+q()} = ${U}${V}
|
|
655
|
+
`;if(Q[Q.length-1]==="")J=O+`
|
|
656
|
+
`+J;else J+=O}return j(J,""),0}async function yj(Y){let Z=await q0(),Q=Y.args[1];if(!Q)return D.error("Missing configuration key","gdx-config"),1;let J=Z.get(Q);if(J===void 0&&X6.includes(Q))J=await Z.getSecure(Q);if(J===void 0)return D.warn(`Key '${Q}' is not set`,"gdx-config"),1;return j(String(J)),0}async function fj(Y){let Z=await q0(),Q=Y.args[1],J=Y.args[2];if(!Q||J===void 0)return D.error("Usage: gdx gdx-config <key> <value>","gdx-config"),1;let z=Z.get(Q),X=J;if(typeof z==="number"){let W=Number(J);if(isNaN(W))return D.error(`Expected a number for '${Q}', got '${J}'`,"gdx-config"),1;X=W}else if(typeof z==="boolean")X=J.toLowerCase()==="true";await Z.set(Q,X),await Z.save();let H=Q.toLowerCase().includes("key")?A1(String(X),20,"mid",-1):X;return j(`${q("Green")}Configuration updated: ${Q} = ${H}${q()}`),0}async function zz(Y){let Z=Y.args[1];if(Z==="list")return await vj();else if(Z==="path"){let Q=await q0();return j(Q.getConfigPath()),0}else if(Y.args.length===2)return await yj(Y);else if(Y.args.length===3)return await fj(Y);else return j(w1(`${q("Cyan")}Usage:${q()}
|
|
580
657
|
gdx gdx-config list - List all configuration
|
|
581
658
|
gdx gdx-config path - Show config file path
|
|
582
659
|
gdx gdx-config <key> - Get configuration value
|
|
583
|
-
gdx gdx-config <key> <value> - Set configuration value`)),0}var
|
|
584
|
-
${
|
|
660
|
+
gdx gdx-config <key> <value> - Set configuration value`)),0}function RV(Y,Z=""){let Q=[];for(let J in Y){let z=Z?`${Z}.${J}`:J,X=Y[J];if(X!==null&&typeof X==="object"&&!Array.isArray(X))Q.push(...RV(X,z));else Q.push({key:z,value:X})}return Q}var VV,FV;var $5=R(()=>{eJ();z0();FY();lQ();M0();$0();W0();C0();T0();VV={long:()=>{let Y=q("Bright"),Z=q();return a(`
|
|
661
|
+
${Y+u("GDX-CONFIG",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
585
662
|
View and modify gdx configuration.
|
|
586
663
|
|
|
587
|
-
${
|
|
664
|
+
${Y+u("OVERVIEW",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
588
665
|
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.
|
|
589
666
|
|
|
590
|
-
${
|
|
667
|
+
${Y+u("COMMANDS",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
591
668
|
- list: Prints flattened configuration with defaults and modified markers.
|
|
592
669
|
- path: Prints the path to the active config file used by gdx.
|
|
593
670
|
- <key> [value]: Get or set a config key. When setting, types are coerced based on the existing default value where possible.
|
|
594
|
-
`,Math.min(100,
|
|
595
|
-
${
|
|
596
|
-
${
|
|
597
|
-
${
|
|
671
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"View or modify gdx configuration settings.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
672
|
+
${Y}${C} gdx-config list${Q}
|
|
673
|
+
${Y}${C} gdx-config path${Q}
|
|
674
|
+
${Y}${C} gdx-config ${Z}<key> [value]${Q}
|
|
598
675
|
|
|
599
676
|
Examples:
|
|
600
|
-
${
|
|
601
|
-
${
|
|
602
|
-
`);try{let
|
|
603
|
-
`),!
|
|
604
|
-
`);if(
|
|
605
|
-
|
|
606
|
-
`+a(
|
|
607
|
-
${
|
|
677
|
+
${Y}${C} gdx-config list ${Q+Z}# List all config keys and values${Q}
|
|
678
|
+
${Y}${C} gdx-config editor.code true ${Q+Z}# Set value for a key${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},FV={$root:["list","path"]}});import bj from"path";import hj from"crypto";function MV(Y){return hj.createHash("sha256").update(Y).digest("hex").slice(0,16)}async function gj(Y){j("");let Z=d0({message:"learning this repo's commit style...",animateGradient:!0});try{let J=(await S`${Y} log --no-merges -n 10 --format=%B%x00`).stdout.split("\x00").map((W)=>W.trim()).filter((W)=>W.length>0);if(J.length===0)return Z.stop(),{guideline:null,historyCount:0};let z=J.slice(0,Math.min(10,J.length)),H=await(await UZ()).generate({prompt:tB(z),temperature:0.2,reasoning:"medium"});return Z.stop(),{guideline:H.trim(),historyCount:z.length}}catch(Q){return Z.stop(),D.warn(`Failed to learn commit guidelines: ${d(Q)}`,"commit"),{guideline:null,historyCount:0}}}async function mj(Y,Z){let Q=await X0(),J=await rq(Y),z=await sq(Y),X=J.replace(/\\/g,"/"),H=Z.get("commit.guidelineCacheDays",30),W=H*24*60,K=z?MV(`remote:${z}`):"",$=MV(`path:${X}`),G=K?`commit.repoGuidelines.${K}`:"",U=`commit.repoGuidelines.${$}`;if(G){let w=await Q.get(G);if(w)return D.debug(`Using cached commit guidelines for remote ${z}`,"commit"),w}let B=await Q.get(U);if(B){if(G)await Q.set(G,B,{maxAgeMinutes:W}),D.debug(`Promoted commit guidelines cache to remote ${z}`,"commit");else D.debug(`Using cached commit guidelines for ${X}`,"commit");return B}let{guideline:F,historyCount:V}=await gj(Y);if(!F||V===0)return D.warn("No commit history found in this repository. Falling back to comprehensive format.","commit"),null;if(V<5)D.warn(`Only ${V} commit(s) found in history. The learned guidelines may be less accurate.`,"commit");let O=G||U;await Q.set(O,F,{maxAgeMinutes:W});let N=G?`remote ${z}`:X;return D.debug(`Cached commit guidelines for ${N} (${H} days)`,"commit"),F}async function uj(Y){let{git$:Z,args:Q}=Y,J=["auto","--no-commit","-nc","--copy","-cp"],z=Q.slice(1).filter((G)=>!J.includes(G)),X=await q0(),H=X.get("llm.showThinking",!0),W=X.get("commit.commitPattern","inherit"),K=(await S`${Z} diff --cached HEAD`).stdout;if(!K||K.trim().length===0)return j(`${q("Red")}No staged changes found. Please stage your changes before generating a commit message.${q()}`),1;let $;if(W==="inherit"){let G=await mj(Z,X);if(G)$=rB(K,G);else $=Yz(K)}else $=Yz(K);j(`${q("Cyan")}Generating commit message based on staged changes...${q()}
|
|
679
|
+
`);try{let G=await UZ(),U=d0({message:"connecting...",animateGradient:!1}),B=G.streamGenerate({prompt:$,temperature:0.14,reasoning:"low"}),F="",V=!1,O=!1,N="";for await(let I of B){if(I.error)return U.stop(),D.error(I.error.message,"commit"),1;if(I.thinkingChunk){if(!O){if(O=!0,U.options.animateGradient=!0,!H)U.options.message="reasoning..."}if(H)N=(N+I.thinkingChunk.replace(/[\n\r]/g,"")).slice(-32),U.options.message=`reasoning... ${N.trim()}`;continue}if(I.chunk){if(!V)V=!0,U.stop(),j(`${q("Cyan")}Generated Commit Message:${q()}`);j(I.chunk,""),F+=I.chunk}}if(j(`
|
|
680
|
+
`),!F)return D.error("Unable to generate commit message (empty response).","commit"),1;F=F.replace(/(^\s*["'`]*|["'`]*\s*$)/g,"");let w=F.indexOf(`
|
|
681
|
+
`);if(w!==-1){let I=F.slice(0,w),T=F.slice(w+1).trim();F=I+`
|
|
682
|
+
|
|
683
|
+
`+a(T,72,{mode:"softboundary",redundancyLv:-1})}if(Q.includes("--no-commit")||Q.includes("-nc")){if(Q.includes("--copy")||Q.includes("-cp"))if(await X2(F))j(`${q("Cyan")}(message has been copied to clipboard)${q()}`);else D.warn("(failed to copy to clipboard)","commit");return 0}let L=bj.join(hY,`gdx_commit_msg_${Date.now()}.txt`);return await z6(L,F,"utf8"),await B0`${Z} commit -F ${L} --edit ${z}`.catch(k8),await iz(L).catch(k8),0}catch(G){return D.error(d(G,{color:!0}),"commit"),1}}var OV,DV;var Xz=R(()=>{u0();z0();k0();M0();tJ();$0();Zz();W0();T0();C0();FY();R6();WY();OV={auto:uj},DV={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
684
|
+
${Y+u("COMMIT AUTO",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
608
685
|
Generate a commit message from staged changes using an LLM.
|
|
609
686
|
|
|
610
|
-
${
|
|
687
|
+
${Y+u("DESCRIPTION",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
611
688
|
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.
|
|
612
689
|
|
|
613
|
-
${
|
|
614
|
-
Use ${
|
|
690
|
+
${Y+u("FLAGS AND BEHAVIOR",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
691
|
+
Use ${Z}--no-commit (-nc)${Q} to prevent creating the commit (message will be printed). Use ${Z}--copy (-cp)${Q} in combination with --no-commit to copy the message to the clipboard. The tool writes a temporary message file when performing an actual commit.
|
|
615
692
|
|
|
616
|
-
${
|
|
693
|
+
${Y+u("REQUIREMENTS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
617
694
|
A non-empty staged diff is required; the command will error if there are no staged changes.
|
|
618
|
-
`,Math.min(100,
|
|
619
|
-
${
|
|
695
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Auto-generate a commit message from staged changes using an LLM.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
696
|
+
${Y}${C} commit auto ${Z}[--no-commit] [--copy]${Q}
|
|
620
697
|
|
|
621
698
|
Examples:
|
|
622
|
-
${
|
|
623
|
-
${
|
|
624
|
-
${
|
|
625
|
-
`),
|
|
626
|
-
`);let
|
|
627
|
-
${
|
|
628
|
-
${
|
|
629
|
-
${
|
|
630
|
-
${
|
|
699
|
+
${Y}${C} commit auto ${Q+Z}# Generate and commit using LLM-generated message${Q}
|
|
700
|
+
${Y}${C} commit auto --no-commit ${Q+Z}# Print generated message without committing${Q}
|
|
701
|
+
${Y}${C} commit auto --no-commit --copy ${Q+Z}# Copy generated message to clipboard${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}}});import Hz from"path";async function Wz(Y){let{git$:Z,args:Q}=Y,[J,z]=await Promise.all([S`${Z} rev-parse --abbrev-ref HEAD`.then((I)=>I.stdout.trim().replace(/\//g,"-")),HY(Z)]),X=Hz.basename(z),H=hY,W=`${X}_${J}_backup_*.patch`,K=`${X}_${J}_backup_`,$=".patch";if(Q.includes("list")){j(`${q("Cyan")}Project:${q()} ${X}`),j(`${q("Cyan")}Branch:${q()} ${J}`),j(`${q("Cyan")}Backup location:${q()} ${H}`),j(`${q("Cyan")}Use \`git clear pardon\` to restore the latest backup.${q()}
|
|
702
|
+
`),j(`${q("Cyan")}Looking for backup patch files matching:${q()} ${W}
|
|
703
|
+
`);let I=await NV(H,K,".patch");if(I.length===0)return j(`${q("Yellow")}No backup patch files found for project '${X}' on branch '${J}'.${q()}`),0;let T=new Date;for(let y=0;y<I.length;y++){let E=I[y],P=(T.getTime()-E.stats.mtime.getTime())/jZ,m=E.stats.mtime.toISOString().replace("T"," ").split(".")[0],g=q("Dim");if(E.stats.mtime.toDateString()===T.toDateString())g=q("White");else if(P>=6)g=q("Red");j(`${g}backup@${y}: ${m} - ${E.name}${q()}`)}return 0}let G=await NV(H,K,".patch"),U=new Date;U.setDate(U.getDate()-7);for(let I of G)if(I.stats.mtime<U)try{T5(I.path),G.splice(G.indexOf(I),1)}catch(T){D.error(`Failed to delete old backup file: ${I.path}
|
|
704
|
+
${d(T,{color:!0})}`,"clear")}if(Q.includes("pardon")){if((await S`${Z} diff --cached --name-only`).stdout.length>0||(await S`${Z} diff --name-only`).stdout.length>0)return D.error("Working Directory is dirty, aborting pardon to prevent unintended data loss. Please clear your workspace first.","clear"),await B0`${Z} status`,1;if(G.length===0)return D.error(`No backup patch file found for branch '${J}'. Pardon failed.`,"clear"),1;let y=G[0],E=new Date;if(E.setDate(E.getDate()-1),y.stats.mtime<E){if(D.warn("Latest backup patch file is older than 1 day. Do you want to proceed with the pardon? (y/n)","clear"),(await z4("Type 'y' to confirm: ")).toLowerCase()!=="y")return D.error("Pardon aborted.","clear"),1}try{await B0`${Z} apply ${y.path}`,T5(y.path),j(`${q("Cyan")}Pardon applied successfully from backup: ${q("Bright")}${y.path}${q()}`),await B0`${Z} status`}catch(P){return D.error(`Failed to apply patch. Pardon aborted.
|
|
705
|
+
${d(P,{color:!0})}`,"clear"),1}return 0}let[B,F,V]=await Promise.all([S`${Z} diff --cached --name-only`.then((I)=>I.stdout.length>0),S`${Z} diff --name-only`.then((I)=>I.stdout.length>0),S`${Z} ls-files --others --exclude-standard`.then((I)=>I.stdout.length>0)]);if(!B&&!F&&!V)return j(`${q("Cyan")}No changes to clear. Working directory is clean.${q()}`),await B0`${Z} status`,0;let O=new Date().toISOString().replace(/[-:T.]/g,"").slice(0,14),N=`${X}_${J}_backup_${O}.patch`,w=Hz.join(H,N);await B0`${Z} add -A`;let L=await S`${Z} diff --cached --binary`;return Q6(w,L.stdout),j(`${q("Cyan")}Backup of all changes saved to: ${q("Bright")}${w}${q()}
|
|
706
|
+
${q("Cyan")}(\`git clear pardon\` to undo)${q()}`),await B0`${Z} reset --hard HEAD`,await B0`${Z} clean -fd`,await B0`${Z} status`,0}async function NV(Y,Z,Q){let z=J6(Y).filter((H)=>H.startsWith(Z)&&H.endsWith(Q));return(await Promise.all(z.map(async(H)=>{let W=Hz.join(Y,H),K=await wZ(W);return{name:H,path:W,stats:K}}))).sort((H,W)=>W.stats.mtime.getTime()-H.stats.mtime.getTime())}var wV,LV;var q5=R(()=>{u0();z0();k0();M0();W0();$0();W0();T0();C0();WY();wV={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
707
|
+
${Y+u("CLEAR",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
631
708
|
Safely backup and clear local working changes.
|
|
632
709
|
|
|
633
|
-
${
|
|
634
|
-
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
|
|
710
|
+
${Y+u("DESCRIPTION",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
711
|
+
Creates a patch file containing the current unstaged, staged, and untracked changes, stores it in the OS temporary directory and then resets the working tree to a clean HEAD via \`${Z}git reset --hard${Q}\` and \`${Z}git clean -fd${Q}\`. The latest patch is kept so you can restore it with \`${Z}${C} clear pardon${Q}\`.
|
|
635
712
|
|
|
636
|
-
${
|
|
713
|
+
${Y+u("SUBCOMMANDS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
637
714
|
- list: Show available backup patch files for this project/branch.
|
|
638
715
|
- pardon: Restore the most recent backup patch.
|
|
639
716
|
|
|
640
|
-
${
|
|
717
|
+
${Y+u("SAFETY",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
641
718
|
All files (tracked and untracked) are backed up before clearing. Pardon requires a clean working directory.
|
|
642
|
-
`,Math.min(100,
|
|
643
|
-
${
|
|
719
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Backup and clear local changes, with a restore (pardon) option.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
720
|
+
${Y}${C} clear ${Z}[list|pardon]${Q}
|
|
644
721
|
|
|
645
722
|
Examples:
|
|
646
|
-
${
|
|
647
|
-
${
|
|
648
|
-
${
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
723
|
+
${Y}${C} clear ${Q+Z}# Create backup patch and clear working tree${Q}
|
|
724
|
+
${Y}${C} clear list ${Q+Z}# Show recent backup patches${Q}
|
|
725
|
+
${Y}${C} clear pardon ${Q+Z}# Restore the latest backup patch${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},LV={$root:["list","pardon"]}});import dj from"path";async function Kz(Y){switch(Y.args[1]){case"list":return await cj();case"prune":return await pj();case"reset":return await lj();case"delete":return await ij(Y.args.slice(2));case"disable":return await _V(!1);case"enable":return await _V(!0);default:return j($z.usage()),0}}async function pj(){let Y=null;try{Y=await Gz()}catch(z){return D.error(d(z,{color:!0}),"cache"),1}if(!Y)return j(`${q("Yellow")}No cache file found. Nothing to prune.${q()}`),0;let Z=Date.now(),Q=Object.entries(Y.entryMeta).filter(([,z])=>Z>z.expiresAt).map(([z])=>z),J=0;for(let z of Q)if(nj(Y,z))J++;if(Y.meta.lastPruneAt=Z,J>0)Y.meta.updatedAt=Z;if(await IV(Y),z2(),J>0)j(`${q("Green")}Pruned ${J} expired cache entries.${q()}`);else j(`${q("Cyan")}No expired cache entries found.${q()}`);return 0}async function cj(){let Y=null;try{Y=await Gz()}catch(Q){return D.error(d(Q,{color:!0}),"cache"),1}if(!Y)return j(`${q("Yellow")}No cache file found. Nothing to list.${q()}`),0;let Z=Object.keys(Y.entryMeta).sort((Q,J)=>{let z=Y.entryMeta[Q],X=Y.entryMeta[J];return(z?.expiresAt??0)-(X?.expiresAt??0)||Q.localeCompare(J)});if(Z.length===0)return j(`${q("Yellow")}No cache keys found.${q()}`),0;j(`${q("Cyan")}Cache:${q()} ${JY} ${q("Dim")}(${Z.length} keys)${q()}
|
|
726
|
+
`);for(let Q of Z){let J=Y.entryMeta[Q];if(!J)continue;let z=J.expiresAt-Date.now(),X=z<=0?"expired":k1.getTimeFromMS(z).modern(),H=q("Green");if(z<=0)H=q("Dim");else if(z<3600000)H=q("Red");else if(z<43200000)H=q("Yellow");let W=aj(Y.data,Q),K=oj(W);j(`${q("Cyan")}${fY(Q,24,{align:"left",redundancyLv:-1,overflow:"collapse"})}${q()} ttl=${H}${fY(X,12,{align:"left",redundancyLv:-1,overflow:"visible"})}${q()} ${q("Dim")}preview=${K}${q()}`)}return 0}async function lj(){try{let Y=o(JY);if(await lz(JY,{force:!0,recursive:!0}),z2(),!Y)return j(`${q("Yellow")}No cache file found. Nothing to delete.${q()}`),0;let Z=o(JY)?`${q("Yellow")}Cache file not removed: ${JY}${q()}`:`${q("Green")}Cache file deleted: ${JY}${q()}`;return j(Z),0}catch(Y){return D.error(d(Y,{color:!0}),"cache"),1}}async function ij(Y){if(Y.length===0)return D.error("Usage: gdx cache delete <key|prefix> [more...]","cache"),1;let Z=null;try{Z=await Gz()}catch(H){return D.error(d(H,{color:!0}),"cache"),1}if(!Z)return j(`${q("Yellow")}No cache file found. Nothing to delete.${q()}`),0;let Q=Object.keys(Z.entryMeta),J=new Set;for(let H of Y){let W=H.trim();if(!W)continue;let K=W.endsWith(".")?W.slice(0,-1):W,$=K.length>0?`${K}.`:"";for(let G of Q)if(G===K||$&&G.startsWith($))J.add(G)}if(J.size===0)return j(`${q("Yellow")}No matching cache keys found.${q()}`),0;let z=Date.now(),X=0;for(let H of J){let W=Z.entryMeta[H];if(!W)continue;W.expiresAt=z-1,W.updatedAt=z,X++}if(X>0)return Z.meta.updatedAt=z,await IV(Z),z2(),j(`${q("Green")}Marked ${X} cache entries as expired.${q()}`),0;return j(`${q("Yellow")}No matching cache keys found.${q()}`),0}async function _V(Y){let Z=await q0();await Z.set("cache.enabled",Y),await Z.save();let Q=Y?"enabled":"disabled";return j(`${q("Green")}Cache ${Q}.${q()}`),0}async function Gz(){try{let Y=await QY(JY,"utf-8"),Z=JSON.parse(Y);if(!Z||!Z.meta||!Z.data||!Z.entryMeta)throw new n("Cache file is invalid or corrupted. Run `gdx cache reset`.","CACHE_INVALID");if(Z.meta.version!==l0)throw new n(`Cache version mismatch (found ${Z.meta.version}, expected ${l0}). Run gdx cache reset.`,"CACHE_VERSION_MISMATCH");if(!Z.meta.lastPruneAt)Z.meta.lastPruneAt=Z.meta.updatedAt||Date.now();return Z}catch(Y){if(n.from(Y).code==="ENOENT")return null;throw Y}}async function IV(Y){let Z=dj.dirname(JY);ZY(Z,{recursive:!0}),await z6(JY,JSON.stringify(Y),"utf-8")}function nj(Y,Z){if(!Y.entryMeta[Z])return!1;delete Y.entryMeta[Z];let Q=Z.split("."),J=[],z=Y.data;for(let X of Q)if(z&&typeof z==="object"&&X in z)J.push({obj:z,key:X}),z=z[X];else return!1;if(J.length>0){let X=J[J.length-1];delete X.obj[X.key]}for(let X=J.length-2;X>=0;X--){let{obj:H,key:W}=J[X],K=H[W];if(K&&typeof K==="object"&&Object.keys(K).length===0)delete H[W];else break}return!0}function aj(Y,Z){let Q=Z.split("."),J=Y;for(let z of Q)if(J&&typeof J==="object"&&z in J)J=J[z];else return;return J}function oj(Y){if(typeof Y==="string")return`'${T8(Y.replace(/\s+/g," "),60,"mid",-1)}'`;if(typeof Y==="number"||typeof Y==="boolean"||Y==null)return String(Y);if(Array.isArray(Y)){let Z=T8(d(Y,{color:!1}),60,"mid",-1);return`[${Y.length}] ${Z}`}if(typeof Y==="object")return`{...} ${T8(d(Y,{color:!1}),60,"mid",-1)}`;return T8(String(Y),60,"mid",-1)}var $z,jV;var U5=R(()=>{z0();R6();FY();W0();C0();T0();u0();$0();M0();$z={long:()=>{let Y=q("Bright"),Z=q();return a(`
|
|
727
|
+
${Y+u("CACHE",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
728
|
+
Manually manage gdx cache entries and settings.
|
|
729
|
+
|
|
730
|
+
${Y+u("COMMANDS",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
731
|
+
- list: Show cache keys, TTL, and a short value preview.
|
|
732
|
+
- prune: Remove expired entries from the cache file.
|
|
733
|
+
- reset: Delete the entire cache file.
|
|
734
|
+
- delete: Mark cache entries as expired by key or prefix.
|
|
735
|
+
- enable/disable: Toggle cache.enabled in gdx config.
|
|
736
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Manually manage gdx cache entries and settings.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
737
|
+
${Y}${C} cache prune${Q}
|
|
738
|
+
${Y}${C} cache reset${Q}
|
|
739
|
+
${Y}${C} cache list${Q}
|
|
740
|
+
${Y}${C} cache delete ${Z}<key|prefix> [more...]${Q}
|
|
741
|
+
${Y}${C} cache enable${Q}
|
|
742
|
+
${Y}${C} cache disable${Q}
|
|
743
|
+
|
|
744
|
+
Examples:
|
|
745
|
+
${Y}${C} cache list ${Q+Z}# List cached keys with TTL${Q}
|
|
746
|
+
${Y}${C} cache prune ${Q+Z}# Remove expired cache entries${Q}
|
|
747
|
+
${Y}${C} cache reset ${Q+Z}# Delete cache file entirely${Q}
|
|
748
|
+
${Y}${C} cache delete git git.config ${Q+Z}# Expire by key/prefix${Q}
|
|
749
|
+
${Y}${C} cache disable ${Q+Z}# Turn caching off${Q}
|
|
750
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},jV={$root:["list","prune","reset","delete","enable","disable"]}});var AV={};L5(AV,{spellCheckDocument:()=>sj,prettyFormatIssues:()=>tj,getBundledDictionaryNames:()=>rj});async function kV(){return TV??=import("cspell-lib"),await TV}async function sj(...Y){return await(await kV()).spellCheckDocument(...Y)}async function rj(){return CV??=(async()=>{let Z=await(await kV()).getDefaultBundledSettingsAsync(),Q=new Set,J=[],z=(X)=>{if(!X||Q.has(X))return;Q.add(X),J.push(X)};return Z.dictionaryDefinitions?.forEach((X)=>z(X.name)),Z.dictionaries?.forEach((X)=>z(X)),J})(),CV}function tj(Y,Z){if(Y.issues.length===0)return q("Green")+"✓ No spelling issues found!"+q();let Q=q("Yellow")+`✗ Found ${Y.issues.length} spelling issue${Y.issues.length===1?"":"s"}:
|
|
751
|
+
`+q();Q+=q("Dim")+"─".repeat(60)+`
|
|
752
|
+
|
|
753
|
+
`+q();let J=q("Cyan"),z=q("Magenta"),X=q("Red")+q("Bright"),H=q("Dim"),W=q("Underline");return Y.issues.forEach((K,$)=>{let G=Z.substring(0,K.line.offset),U=G.length-G.replace(/\n/g,"").length,B=K.offset-K.line.offset;Q+=`${H}${$+1}.${q()} ${J}Line ${U+1}${q()}, ${z}Col ${B+1}${q()}: ${X}"${K.text}"${q()}
|
|
754
|
+
`;let F=K.line.text;if(F){let V=K.offset-K.line.offset,O=F.substring(0,V),N=F.substring(V+K.text.length);Q+=` ${O}${X+W}${K.text}${q()}${N}
|
|
755
|
+
`}if(K.suggestions?.length){let V=K.suggestions.slice(0,5).join(", ");Q+=` ${J}Suggestions:${q()} ${V}
|
|
756
|
+
`}if($<Y.issues.length-1)Q+=`
|
|
757
|
+
`}),Q+=H+"─".repeat(60)+q()+`
|
|
758
|
+
`,Q}var TV=null,CV=null;var xV=R(()=>{z0()});async function qz(Y){let Q=r1().$,{git$:J}=Y;if(!await G2(J))return 1;let{spellCheckDocument:z,prettyFormatIssues:X,getBundledDictionaryNames:H}=await Promise.resolve().then(() => (xV(),AV)),K=(await q0()).get("lint.maxFileSizeKb")||1024,$="";try{let{stdout:N}=await Q`${J} rev-parse --abbrev-ref --symbolic-full-name @{u}`;$=N.trim()}catch{}let G="";if($)G=`${$}..HEAD`;else D.warn("No upstream configured. Checking last commit only.","lint"),G="HEAD^..HEAD";let U=0,B=0,[F,V,O]=await Promise.all([Q`${J} log --pretty=format:"%s\n%b$$\$___SEP___\$$$" ${G}`.then((N)=>N.stdout).catch(()=>""),Q`${J} diff ${G}`.then((N)=>N.stdout).catch(()=>""),Q`${J} diff --name-only ${G}`.then((N)=>N.stdout).catch(()=>"")]);if(F){let N=await H(),w=F.split("$$$___SEP___$$$").filter((L)=>L.trim());for(let[L,I]of w.entries()){let T=await z({uri:"commit-message",text:I,languageId:"plaintext",locale:"en"},{generateSuggestions:!0,noConfigSearch:!0,unknownWords:"report-common-typos"},{dictionaries:N});if(T.issues.length===0)continue;B+=T.issues.length,EV("Spelling",`At HEAD~${L} found ${T.issues.length} potential spelling issue(s) in commit messages.
|
|
759
|
+
|
|
760
|
+
`+X(T,I))}}if(V){let N="",w=V.split(/^diff --git a\/.+$/m);for(let L of w){let I=L.split(`
|
|
761
|
+
`).filter((T)=>T.trim());if(N=I.slice(2,4).find((T)=>T.startsWith("+++ b/"))?.split(" b/")[1]||"unknown",/\n?\+?<{7}(?:[^\n]*\n)*\+?={7}(?:[^\n]*\n)*\+?>{7}/.test(V))PV("Conflict Markers",`File: ${N}
|
|
762
|
+
Please resolve merge conflict markers.`),U++;for(let T=3;T<I.length;T++){let y=I[T];if(y.startsWith("+")){let E=y.substring(1);for(let P of QX)if(P.test(E))PV("Sensitive Content",`File: ${N}
|
|
763
|
+
Matched Pattern: ${P}
|
|
764
|
+
Content: ${E}`),U++}}}}if(O){let w=O.split(`
|
|
765
|
+
`).filter((I)=>I.trim()).map(async(I)=>{try{let{stdout:T}=await Q`${J} cat-file -s HEAD:${I}`,y=parseInt(T.trim(),10);return{file:I,sizeBytes:y}}catch{return null}}),L=await Promise.all(w);for(let I of L){if(!I)continue;let{file:T,sizeBytes:y}=I;if(y/1024>K)EV("Size",`File: ${T}
|
|
766
|
+
File size ${bY(y,2,1024)}B exceeds limit of ${K}KiB`),B++}}if(U>0)return D.error(`Lint failed with ${U} errors and ${B} warnings.`,"lint"),1;else if(B>0)return j(q("Yellow")+`
|
|
767
|
+
Lint passed with ${B} warnings.`+q()),0;else return j(q("Green")+`
|
|
768
|
+
No problems found.`+q()),0}function EV(Y,Z){Z=a(Z,100,{indent:" "}),j(q("BgYellow")+q("Bright")+q("White")+" LWARN "+q()+q("Invert")+` ${Y} ${q()+q("Yellow")} ${Z}`+q())}function PV(Y,Z){Z=a(Z,100,{indent:" "}),j(q("BgRed")+q("Bright")+q("White")+" LERROR "+q()+q("Invert")+` ${Y} ${q()+q("Red")} ${Z}`+q())}var SV,vV;var B5=R(()=>{z0();k0();M0();FY();WY();W0();$0();C0();T0();SV={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
769
|
+
${Y+u("LINT",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
660
770
|
Runs a set of linting checks on your outgoing commits (or the last commit if no upstream is configured).
|
|
661
771
|
|
|
662
|
-
${
|
|
772
|
+
${Y+u("CHECKS PERFORMED",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
663
773
|
- Spelling: Checks for typos in commit messages using cspell.
|
|
664
774
|
- Sensitive Content: Scans for API keys, tokens, and private keys.
|
|
665
775
|
- Conflict Markers: Checks for leftover merge conflict markers.
|
|
666
776
|
- File Size: Warns if files exceed the configured size limit (default 1MB).
|
|
667
777
|
|
|
668
|
-
${
|
|
669
|
-
You can configure the behavior in your
|
|
778
|
+
${Y+u("CONFIGURATION",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
779
|
+
You can configure the behavior in your ~/.gdx/.gdxrc.toml file or \`${Z}${C} gdx-config${Q}\`:
|
|
670
780
|
[lint]
|
|
671
781
|
onPushBehavior = "off" | "error" | "warning" # Default: "off"
|
|
672
782
|
maxFileSizeKb = 1024 # Default: 1024 KB
|
|
673
|
-
`,Math.min(100,
|
|
674
|
-
${
|
|
783
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Lint outgoing commits for format, spelling, sensitive data, and more.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
784
|
+
${Y}${C} lint${Q}
|
|
785
|
+
|
|
786
|
+
Examples:
|
|
787
|
+
${Y}${C} lint ${Q+Z}# Run lint checks on outgoing commits${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},vV={$root:[]}});import Uz from"path";async function ej(Y){try{let Q=(await S`${Y} config --file .gitmodules --get-regexp path`).stdout.trim();if(!Q)return[];let J=Q.split(`
|
|
788
|
+
`),z=[];for(let X of J){if(!X.trim())continue;let H=X.match(/^submodule\.(.+?)\.path\s+(.+)$/);if(H){let W=H[2];z.push({path:W,status:" "})}}return z}catch{return[]}}async function YT(Y,Z,Q){try{return(await S`${Y} -C ${Z} ${ZT(Q)}`).stdout}catch(J){let z=n.from(J);return D.warn(`Failed to get status for submodule ${Z}.
|
|
789
|
+
Error: ${z.message}`,"status"),D.debug(`Failed to get status for submodule ${Z}.
|
|
790
|
+
${z.toString({color:!0})}`,"status"),""}}function ZT(Y){let Z=["status",...Y];if(qY.supportsColor<=0)return Z;if(QT(Y)||JT(Y)||zT(Y))return Z;return["-c","color.ui=always",...Z]}function QT(Y){return Y.some((Z)=>Z==="--no-color"||Z==="--color=never")}function JT(Y){return Y.some((Z)=>Z==="--porcelain"||Z.startsWith("--porcelain="))}function zT(Y){return Y.some((Z)=>Z==="--color"||Z.startsWith("--color="))}async function Bz(Y){let{git$:Z,args:Q}=Y;if(!(Q.includes("-r")||Q.includes("--recursive")))return await B0`${Z} status ${Q.slice(1)}`.then((X)=>X.exitCode??0);let z=Q.slice(1).filter((X)=>X!=="-r"&&X!=="--recursive");try{let X=await HY(Z),H=process.cwd();j(`${q("Cyan")}${q("Bright")}━━━ Repository Root${q()}${q("Dim")} (${Uz.relative(H,X)||"."})${q()}
|
|
791
|
+
`),await B0`${Z} status ${z}`;let W=await ej(Z);if(W.length===0)return j(`
|
|
792
|
+
${q("Dim")}No submodules found.${q()}`),0;for(let K of W){let $=Uz.resolve(X,K.path),G=Uz.relative(H,$);j(`
|
|
793
|
+
${q("Cyan")}${q("Bright")}━━━ Submodule: ${K.path}${q()}${q("Dim")} (${G})${q()}
|
|
794
|
+
`);let U=await YT(Z,$,z);if(U)j(U);else j(`${q("Dim")}Unable to get status for this submodule.${q()}
|
|
795
|
+
`)}return 0}catch(X){return D.error(`Failed to get recursive status.
|
|
796
|
+
${X}`,"status"),1}}var yV,fV;var V5=R(()=>{z0();k0();M0();W0();T0();$0();C0();WY();yV={long:()=>{let Y=q("Bright"),Z=q("Cyan"),Q=q();return a(`
|
|
797
|
+
${Y+u("STATUS",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
798
|
+
Show the working tree status for the repository and optionally all submodules.
|
|
799
|
+
|
|
800
|
+
${Y+u("OVERVIEW",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
801
|
+
\`${Z}${C} status${Q}\` is a wrapper around \`${Z}git status${Q}\` with added support for recursive submodule status checking. When the \`${Z}--recursive${Q}\` or \`${Z}-r${Q}\` flag is used, it will show the status of the main repository followed by the status of each submodule.
|
|
802
|
+
|
|
803
|
+
${Y+u("RECURSIVE MODE",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
804
|
+
When \`${Z}--recursive${Q}\` or \`${Z}-r${Q}\` is specified:
|
|
805
|
+
- Shows status of the main repository first
|
|
806
|
+
- Then shows status for each submodule with clear headers
|
|
807
|
+
- Displays both absolute submodule paths and paths relative to your current directory
|
|
808
|
+
- All other \`${Z}git status${Q}\` flags are passed through to each status check
|
|
809
|
+
|
|
810
|
+
${Y+u("EXAMPLES",A.Zinc400,A.Zinc100,0.2)+Q}
|
|
811
|
+
${Z}${C} status --recursive${Q}
|
|
812
|
+
Show status for repository and all submodules
|
|
813
|
+
|
|
814
|
+
${Z}${C} s -r${Q}
|
|
815
|
+
Same as above using shorthand
|
|
816
|
+
|
|
817
|
+
${Z}${C} status -r --short${Q}
|
|
818
|
+
Show short format status recursively
|
|
819
|
+
|
|
820
|
+
${Z}${C} status --recursive --porcelain${Q}
|
|
821
|
+
Show porcelain format status recursively
|
|
822
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Show working tree status with optional recursive submodule support",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
823
|
+
${Y}${C} status ${Z}[--recursive|-r] [<git-status-options>]${Q}
|
|
824
|
+
${Y}${C} s ${Z}[--recursive|-r] [<git-status-options>]${Q}
|
|
825
|
+
|
|
826
|
+
Examples:
|
|
827
|
+
${Y}${C} status --recursive ${Q+Z}# Show status for repo and all submodules${Q}
|
|
828
|
+
${Y}${C} s -r --short ${Q+Z}# Short format with submodules${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},fV={$root:{$allOf:["-r","--recursive","--short","--porcelain","--branch","--long"]}}});import Vz from"fs";import j1 from"path";async function Fz(){let Y,Z=!1,Q=process.argv[0].endsWith("node")||process.argv[0].endsWith("node.exe"),J=process.argv[0].endsWith("bun")||process.argv[0].endsWith("bun.exe"),z=process.execPath.toLowerCase()!==process.argv[0].toLowerCase();if(!z){let K=process.argv[1],$=j1.dirname(K),G=[j1.join($,"native/install.json"),j1.join($,"../dist/native/install.json"),j1.join($,"../native/install.json")];for(let U of G)if(Vz.existsSync(U)){Y=U;break}if(!Y)Y=j1.join($,"native/install.json")}else Y=j1.join(j1.dirname(process.execPath),"install.json");let X=null;if(Vz.existsSync(Y))try{let K=JSON.parse(Vz.readFileSync(Y,"utf8"));X=d(K,{color:!0})}catch(K){let $=n.from(K);D.error(`Error reading install.json: ${$.message}`,"doctor"),D.debug($.toString(),"doctor"),Z=!0}else if(z)D.warn(`No native install info found at ${Y}`,"doctor"),Z=!0;j(`Version: ${q("Cyan")+l0+q()}`),j(`Platform: ${q("Magenta")+process.platform+q()}`),j(`Arch: ${q("Magenta")+process.arch+q()}`),j(`Runtime: ${q("Magenta")+(J?"Bun":Q?"Node":"Unknown")+(z?" (Native)":"")+q()}`);try{let K=await IY("bun",["--version"]);j(`Bun: ${q("Cyan")+K.stdout.trim()+q()}`)}catch{j("Bun: Not found")}try{let K=await IY("node",["--version"]);j(`Node: ${q("Cyan")+K.stdout.trim()+q()}`)}catch{j("Node: Not found")}j(`Installation mode: ${z?q("Green")+"Native"+q():q("Yellow")+"Interpreted"+q()}`),j(`Executable path: ${q("Cyan")+process.execPath+q()}`),j(`Log file path: ${q("Cyan")+h6(D.logFile,D.logFile)+q()}`);let H=await X0();j(`Cache file path: ${q("Cyan")+h6(H.cachePath,H.cachePath)+q()}`);try{let K=await IY("git",["--version"]);j(`Git: ${q("Cyan")+K.stdout.trim()+q()}`);let $=process.platform==="win32"?"where":"which",U=(await IY($,["git"])).stdout.trim().replaceAll(`
|
|
829
|
+
`,`
|
|
830
|
+
- `);j(`Git path: ${U?q("Green")+`
|
|
831
|
+
- `+U+q():"Not found in PATH"}`)}catch{j(q("Red")+"Git: Not found or error checking"+q()),Z=!0}let W=bz(process.env,(K)=>K.startsWith("GDX_")?null:void 0);if(j("Process argv: "+Sz(process.argv,{color:!0,indent:2,maxCol:80})),j("GDX Environment Variables: "+d(W,{color:!0})),X)j(`
|
|
832
|
+
Native Install Info: ${q("Green")+X+q()}`);else{if(j(q("Bright")+`
|
|
833
|
+
Actionable next steps:`+q()),process.platform==="win32"&&process.arch==="x64")j("To use prebuilt binary:"),j(" GDX_USE_PREBUILT=1 npm i -g gdx");else j(`Prebuilt binary not supported for ${process.platform}/${process.arch}.`);j("To build locally (requires Bun):"),j(" GDX_BUILD_NATIVE=1 npm i -g gdx")}return Z?1:0}var bV,hV;var F5=R(()=>{e8();z0();M0();$0();W0();C0();W0();T0();R6();bV={long:()=>{let Y=q("Bright"),Z=q();return a(`
|
|
834
|
+
${Y+u("DOCTOR",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
835
|
+
Diagnose installation and environment.
|
|
836
|
+
|
|
837
|
+
${Y+u("DESCRIPTION",A.Zinc400,A.Zinc100,0.2)+Z}
|
|
838
|
+
Checks for native binary, runtimes, and provides installation guidance.
|
|
839
|
+
`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})},short:"Run a diagnostic check on gdx installation and environment.",usage:()=>{let Y=q("Cyan"),Z=q("Dim"),Q=q();return a(`
|
|
840
|
+
${Y}${C} doctor${Q}
|
|
675
841
|
|
|
676
842
|
Examples:
|
|
677
|
-
${
|
|
843
|
+
${Y}${C} doctor ${Q+Z}# Diagnose installation and environment${Q}`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})}},hV={$root:[]}});function R5(Y){let Z=q("Cyan"),Q=q("Yellow"),J=q("Bright"),z=q("Dim"),X=q("Reset"),H={cache:$z,stash:FU,stats:_U,graph:NU,nocap:YV,parallel:H5,"gdx-config":VV,commit:DV,clear:wV,lint:SV,status:yV,doctor:bV};if(!Y)return j(a(`
|
|
678
844
|
──────────────────────────────
|
|
679
|
-
${
|
|
680
|
-
Version: ${Z+
|
|
845
|
+
${J+u("GDX (Git Developer eXperience)",A.OceanDeepBlue,A.OceanGreen,0.32,1)+X}
|
|
846
|
+
Version: ${Z+l0+X}
|
|
681
847
|
──────────────────────────────
|
|
682
848
|
|
|
683
849
|
Git, but with better DX. The raw power of Git,
|
|
684
850
|
aligned with human workflows.
|
|
685
851
|
|
|
686
|
-
${
|
|
687
|
-
${
|
|
852
|
+
${J+u("DESCRIPTION",A.Zinc400,A.Zinc100,0.2)+X}
|
|
853
|
+
${C} (wrapper) — shorthand-friendly wrapper for git (executable) with common shortcuts,
|
|
688
854
|
stash-range support, and convenience expansions.
|
|
689
855
|
It forwards unrecognized commands/args to git (executable) unchanged.
|
|
690
856
|
|
|
691
|
-
${
|
|
692
|
-
${
|
|
857
|
+
${J+u("SYNOPSIS",A.Zinc400,A.Zinc100,0.2)+X}
|
|
858
|
+
${C} <command> [<args>]
|
|
693
859
|
Examples:
|
|
694
|
-
${Z}${
|
|
695
|
-
${Z}${
|
|
696
|
-
${Z}${
|
|
697
|
-
${Z}${
|
|
698
|
-
${Z}${
|
|
860
|
+
${Z}${C} st ${X+z}# shorthand for ${C} stash${X}
|
|
861
|
+
${Z}${C} lg ${X+z}# shorthand for ${C} log --oneline --graph --all --decorate${X}
|
|
862
|
+
${Z}${C} stash d 2..6 ${X+z}# drop stashes 2 through 6 (safe: drops high->low)${X}
|
|
863
|
+
${Z}${C} clear ${X+z}# backup changes to a temp patch file and reset working directory (use \`${Z}${C} clear pardon${q("White")}\` to restore)${X}
|
|
864
|
+
${Z}${C} cmi auto ${X+z}# generate commit message based on staged changes using LLM${X}
|
|
699
865
|
|
|
700
|
-
${
|
|
866
|
+
${J+u("KEY FEATURES",A.Zinc400,A.Zinc100,0.2)+X}
|
|
701
867
|
- Many short aliases for common commands (commit, branch, checkout, etc.).
|
|
702
868
|
- Smart expansions:
|
|
703
|
-
- log: ${Z}${
|
|
704
|
-
- log export: ${Z}${
|
|
705
|
-
export (adds --author if missing).${
|
|
706
|
-
- pull: ${Z}${
|
|
707
|
-
- push: ${Z}${
|
|
708
|
-
- reset: ${Z}${
|
|
869
|
+
- log: ${Z}${C} lg ${X+z}-> ${X+Z}${C} log --oneline --graph --all --decorate${X}
|
|
870
|
+
- log export: ${Z}${C} lg export [extra args] ${X+z}creates a nicely formatted
|
|
871
|
+
export (adds --author if missing).${X}
|
|
872
|
+
- pull: ${Z}${C} pl -au ${X+z}-> expands -au to --allow-unrelated-histories.${X}
|
|
873
|
+
- push: ${Z}${C} ps -fl ${X+z}-> expands -fl to --force-with-lease.${X}
|
|
874
|
+
- reset: ${Z}${C} res -h ${X+z}-> ${X+Z}${C} reset --hard${X+z}; ${X+Z}${C} res ~3 ${X+z}-> ${X+Z}${C} reset HEAD~3${X}
|
|
875
|
+
${z}(also supports ${Z}origin~N${X+z} for upstream-relative resets)${X}
|
|
709
876
|
- Clear convenience:
|
|
710
|
-
- ${Z}${
|
|
877
|
+
- ${Z}${C} clear ${X+z}->${X} creates a timestamped patch backup
|
|
711
878
|
in the system temp folder, then resets the working directory
|
|
712
|
-
(${Z}${
|
|
713
|
-
- Use \`${
|
|
714
|
-
and restore changes. Add
|
|
879
|
+
(${Z}${C} reset --hard ${X+z}+ ${X+Z}${C} clean -fd${X}).
|
|
880
|
+
- Use \`${Z}${C} clear pardon${X}\` to apply the latest backup patch
|
|
881
|
+
and restore changes. Add \`${Z}-f${X}\`/\`${Z}--force${X}\` to bypass dirty-working-directory prompts.
|
|
715
882
|
- Stash convenience:
|
|
716
|
-
- Short forms: ${Z}${
|
|
717
|
-
- ${Z}${
|
|
883
|
+
- Short forms: ${Z}${C} sta / ${C} st${X} for stash; ${Z}${C} sta l${X} -> stash list.
|
|
884
|
+
- ${Z}${C} stash d 2..6${X} — drops stash@{6}..stash@{2} (drops high→low to
|
|
718
885
|
avoid index shift).
|
|
719
886
|
- Supports apply, pop, drop, list, show, clear via short forms.
|
|
720
887
|
- Quick worktrees:
|
|
721
|
-
- ${Z}${
|
|
722
|
-
|
|
723
|
-
${
|
|
724
|
-
${Z}ad ${
|
|
725
|
-
${Z}bra, br ${
|
|
726
|
-
${Z}clear ${
|
|
727
|
-
${Z}cl, clo ${
|
|
728
|
-
${Z}com, comm, cmi ${
|
|
729
|
-
${Z}che, checko, co ${
|
|
730
|
-
${Z}dif ${
|
|
731
|
-
${Z}lg, lo ${
|
|
732
|
-
${Z}pl, pul ${
|
|
733
|
-
${Z}ps, pus ${
|
|
734
|
-
${Z}rb, rebas ${
|
|
735
|
-
${Z}res, rese ${
|
|
736
|
-
${Z}rv, rever ${
|
|
737
|
-
${Z}mg, merg ${
|
|
738
|
-
${Z}in, ini ${
|
|
739
|
-
${Z}sta, st ${
|
|
740
|
-
${Z}s, stat ${
|
|
741
|
-
${Z}swit, sw ${
|
|
742
|
-
|
|
743
|
-
${
|
|
744
|
-
${Z}
|
|
745
|
-
|
|
746
|
-
${
|
|
747
|
-
${Z}
|
|
748
|
-
${Z}
|
|
749
|
-
${Z}
|
|
750
|
-
${Z}
|
|
751
|
-
${Z}
|
|
752
|
-
|
|
753
|
-
${Q
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
${
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
888
|
+
- ${Z}${C} parallel fork/remove/join/switch/open/list${X} for temp-backed worktree workflows.
|
|
889
|
+
|
|
890
|
+
${J+u("SHORTHAND LIST (common)",A.Zinc400,A.Zinc100,0.2)+X}
|
|
891
|
+
${Z}ad ${X+z}-> ${X}add
|
|
892
|
+
${Z}bra, br ${X+z}-> ${X}branch
|
|
893
|
+
${Z}clear ${X+z}-> ${X}clear (backup changes and reset working directory; use \`${Z}pardon${X}\` to restore)
|
|
894
|
+
${Z}cl, clo ${X+z}-> ${X}clone
|
|
895
|
+
${Z}com, comm, cmi ${X+z}-> ${X}commit
|
|
896
|
+
${Z}che, checko, co ${X+z}-> ${X}checkout
|
|
897
|
+
${Z}dif ${X+z}-> ${X}diff
|
|
898
|
+
${Z}lg, lo ${X+z}-> ${X}log (auto-expanded)
|
|
899
|
+
${Z}pl, pul ${X+z}-> ${X}pull
|
|
900
|
+
${Z}ps, pus ${X+z}-> ${X}push
|
|
901
|
+
${Z}rb, rebas ${X+z}-> ${X}rebase
|
|
902
|
+
${Z}res, rese ${X+z}-> ${X}reset
|
|
903
|
+
${Z}rv, rever ${X+z}-> ${X}revert
|
|
904
|
+
${Z}mg, merg ${X+z}-> ${X}merge
|
|
905
|
+
${Z}in, ini ${X+z}-> ${X}init
|
|
906
|
+
${Z}sta, st ${X+z}-> ${X}stash
|
|
907
|
+
${Z}s, stat ${X+z}-> ${X}status
|
|
908
|
+
${Z}swit, sw ${X+z}-> ${X}switch
|
|
909
|
+
|
|
910
|
+
${J+u("CUSTOM COMMAND LIST",A.Zinc400,A.Zinc100,0.2)+X}
|
|
911
|
+
${XT(H,{cyan:Z,reset:X})}
|
|
912
|
+
|
|
913
|
+
${J+u("OPTIONS",A.Zinc400,A.Zinc100,0.2)+X}
|
|
914
|
+
${Z}--init <shell> ${X}Output shell initialization script for given shell.
|
|
915
|
+
${Z}--bypass ${X}Bypass gdx and execute git directly with the provided arguments.
|
|
916
|
+
${Z}--no-enhance ${X}Bypass gdx enhanced Git's output.
|
|
917
|
+
${Z}--loglevel <level> ${X}Set log level (error, warning, info, debug).
|
|
918
|
+
${Z}--ghelp, ${X}Show GDX help message. ${z}(use \`${Z}ghelp <command>${X}\`
|
|
919
|
+
${Z} --gdx-help, -gh ${X+z}for command-specific help)${X}
|
|
920
|
+
${Z}-r, --recursive ${Q}[For '${C} status']${X} Recursively show git status of submodules.
|
|
921
|
+
${Z}-au ${Q}[For '${C} pull']${X} Shorthand for ${Z}--allow-unrelated-histories${X}.
|
|
922
|
+
${Z}--on-lint ${Q}[For '${C} push']${X} Skip linting for this push${X}.
|
|
923
|
+
${Z}-fl ${Q}[For '${C} push']${X} Shorthand for ${Z}--force-with-lease${X}.
|
|
924
|
+
${Z}-h ${Q}[For '${C} reset']${X} Shorthand for ${Z}--hard${X}.
|
|
925
|
+
${Z}-s ${Q}[For '${C} reset']${X} Shorthand for ${Z}--soft${X}.
|
|
926
|
+
|
|
927
|
+
${J+u("RELATIVE REF EXPANSION",A.Zinc400,A.Zinc100,0.2)+X}
|
|
928
|
+
Expansions are triggered by specific shorthand patterns in the arguments. When detected, they are expanded to their full form before being passed to git.
|
|
929
|
+
|
|
930
|
+
Syntax:
|
|
931
|
+
[origin|head]~[<number>] (e.g. ${Z}~3${X}, ${Z}origin~2${X})
|
|
932
|
+
- origin~N expansions resolve relative to the current branch's upstream (e.g. origin~2 -> upstream~2).
|
|
933
|
+
- ~N or head~N expansions resolve relative to HEAD (e.g. ~3 -> HEAD~3).
|
|
934
|
+
- [head] and <number> can be omitted, they will default to HEAD and 0 respectively (e.g. ${Z}origin~${X} -> upstream, ${Z}~${X} -> HEAD).
|
|
935
|
+
|
|
936
|
+
Examples:
|
|
937
|
+
- ${Z}${C} reset ~3${X} expands to ${Z}${C} reset HEAD~3${X}.
|
|
938
|
+
- ${Z}${C} reset -h${X} expands to ${Z}${C} reset --hard${X}.
|
|
939
|
+
- ${Z}${C} show origin ~2${X} expands to ${Z}${C} show <upstream>~2${X}.
|
|
940
|
+
- ${Z}${C} diff origin ~2${X} expands to ${Z}${C} diff <upstream>~2${X}.
|
|
941
|
+
|
|
942
|
+
${J+u("NOTES & SAFETY",A.Zinc400,A.Zinc100,0.2)+X}
|
|
766
943
|
- Help message for individual custom commands is available via
|
|
767
|
-
${Z}${
|
|
944
|
+
${Z}${C} ghelp <command>${X} (e.g. ${Z}${C} ghelp stash${X}).
|
|
768
945
|
- Range notation must be numeric and in the form start..end (e.g. 2..6).
|
|
769
946
|
- The wrapper prints an auto-expansion message when it expands a shorthand.
|
|
770
|
-
- If you rely on advanced argument parsing or unusual ${
|
|
947
|
+
- If you rely on advanced argument parsing or unusual ${C} flags, you can
|
|
771
948
|
bypass expansions by using the full command name
|
|
772
949
|
so they are not recognized as shorthand triggers.
|
|
773
|
-
- For more infomation, see ${
|
|
774
|
-
|
|
775
|
-
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
`);
|
|
780
|
-
`);
|
|
950
|
+
- For more infomation, see ${h6("README.md",ez)}.`,Math.min(100,l.terminalWidth-4),{firstIndent:" ",mode:"softboundary",indent:" "})),0;let W=Y.replace(/^\/+/,"");if(W==="help")return R5();let K=H[W],$="";if(K&&K.long)$=K.long();if($&&K.usage)$+=`
|
|
951
|
+
`+J+u("USAGE",A.Zinc400,A.Zinc100,0.2)+X+K.usage();if($)return j($),0;return j(`No help found for '${W}'.`),1}function XT(Y,Z){let Q=[];for(let[J,z]of Object.entries(Y))Q.push(`${Z.cyan}${fY(J,19,{overflow:"visible",align:"left",redundancyLv:0})}${Z.reset}${a(z.short,60,{indent:19,firstIndent:0,redundancyLv:0,mode:"strict"})}`);return Q.join(`
|
|
952
|
+
`)}var gV;var Rz=R(()=>{z0();W0();M0();T0();C0();V2();M2();W4();Q5();G5();$5();Xz();q5();U5();B5();V5();F5();gV={$root:["cache","clear","commit","doctor","graph","gdx-config","lint","nocap","parallel","stash","stats","status"]}});function SY(){if(VZ!==null)return VZ;return VZ=process.stdout.rows||24,VZ}function j8(){if(FZ!==null)return FZ;return FZ=process.stdout.columns||80,FZ}function Mz(){VZ=null,FZ=null}class uV{lines=[];wrappedLines=[];options;lastWidth=0;lastHeight=0;constructor(Y,Z={}){this.options={...mV,...Z},this.lines=Y.split(`
|
|
953
|
+
`),this.lastWidth=j8(),this.lastHeight=SY(),this.updateWrappedLines()}updateWrappedLines(){let Y=this.lastWidth,Z=this.options.showLineNumbers?Y-this.options.lineNumberWidth-1:Y;this.wrappedLines=[];for(let Q=0;Q<this.lines.length;Q++){let J=this.lines[Q];if(this.options.wrapLines&&J.length>Z)a(J,Z,{mode:"softboundary"}).split(`
|
|
954
|
+
`).forEach((H,W)=>{if(this.options.showLineNumbers&&W===0)this.wrappedLines.push(this.formatLineNumber(Q+1)+H);else if(this.options.showLineNumbers)this.wrappedLines.push(" ".repeat(this.options.lineNumberWidth+1)+H);else this.wrappedLines.push(H)});else if(this.options.showLineNumbers)this.wrappedLines.push(this.formatLineNumber(Q+1)+J);else this.wrappedLines.push(J)}}formatLineNumber(Y){return String(Y).padStart(this.options.lineNumberWidth)+" "}getLineCount(){return this.wrappedLines.length}getLine(Y){return this.wrappedLines[Y]||""}render(Y,Z,Q){let J=[],z=H6(this.options.backgroundColor),X=q();for(let H=0;H<Z-1;H++){let W=Y+H;if(W<this.wrappedLines.length){let K=this.wrappedLines[W],$=E8(K),G=Math.max(0,Q-$.length);J.push(`${z}${K}${" ".repeat(G)}${X}`)}else J.push(`${z}${" ".repeat(Q)}${X}`)}return J}onResize(Y,Z){if(Y!==this.lastWidth||Z!==this.lastHeight)this.lastWidth=Y,this.lastHeight=Z,this.updateWrappedLines()}getExitLines(){return this.wrappedLines}}async function dV(Y,Z={}){let Q=new uV(Y,Z);return Oz(Q,Z)}async function Oz(Y,Z={}){let Q={...mV,...Z};if(!process.stdout.isTTY||!process.stdin.isTTY){for(let F=0;F<Y.getLineCount();F++)process.stdout.write(Y.getLine(F)+`
|
|
955
|
+
`);return}process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf-8");let J=0,z=Y.getLineCount(),X=!0,H=[];process.stdout.write("\x1B[?25l"),process.stdout.write("\x1B[2J\x1B[H");function W(){let F=performance.now(),V=SY(),O=j8(),N=Y.render(J,V,O);process.stdout.write("\x1B[H");for(let w of N)process.stdout.write("\x1B[K"+w+`
|
|
956
|
+
`);if(Q.showStatus){let w=Q.statusFormat(J+1,z,O),L=Math.max(0,O-P8(w)),I=H6(Q.backgroundColor),T=y0(Q0.overlay0);process.stdout.write("\x1B[K"+I+T+w+" ".repeat(L)+q())}if(H.length>30)H.shift();H.push(performance.now()-F)}function K(){process.stdout.write("\x1B[?25h");let V=SY()-1;process.stdout.write(`\x1B[${V}B`),process.stdin.setRawMode(!1),process.stdin.pause(),D.debug(`Pager performance: ${H.length>0?DZ(H.reduce((O,N)=>O+N,0)/H.length,4):"N/A"}ms average over ${H.length} renders`,"pager")}function $(){Mz();let F=j8(),V=SY();if(Y.onResize)Y.onResize(F,V);W()}let G=()=>$();process.stdout.on("resize",G);function U(F){let O=SY()-1,N=Math.max(0,Y.getLineCount()-O);switch(F){case"q":case"\x03":case"\x1B":X=!1;break;case"\x1B[A":case"\x1B[A":case"k":J=Math.max(0,J-Q.scrollSensitivity);break;case"\x1B[B":case"\x1B[B":case"j":J=Math.min(N,J+Q.scrollSensitivity);break;case"\x1B[5~":case"b":{let w=O-1;J=Math.max(0,J-w);break}case"\x1B[6~":case"n":case" ":{let w=O-1;J=Math.min(N,J+w);break}case"g":case"\x1B[1~":case"\x1B[H":J=0;break;case"G":case"\x1B[4~":case"\x1B[F":J=N;break}if(X)W()}let B=(F)=>{if(U(F.toString()),!X)process.stdin.off("data",B),process.stdout.off("resize",G),K()};return process.stdin.on("data",B),W(),new Promise((F)=>{let V=setInterval(()=>{if(!X)clearInterval(V),F()},50)})}var mV,VZ=null,FZ=null;var pV=R(()=>{z0();$0();T0();W0();mV={showLineNumbers:!1,lineNumberWidth:4,wrapLines:!0,showStatus:!0,statusFormat:(Y,Z,Q)=>{let J=q("Bright"),z=q("Normal"),X=Math.min(Y+SY()-2,Z);return fY([` ${J}↑ ↓ b n Home End${z} to navigate, ${J}q${z} to quit`,`lines ${J}${Y}-${X}${z} of ${J}${Z}${X===Z?q("Red")+" (EOF)"+q("White"):""} `],Q,{align:"spacebetween",filler:" ",redundancyLv:0})},backgroundColor:Q0.base,scrollSensitivity:3}});async function HT(){return lV??=import("@shikijs/cli"),await lV}function M5(){return process.stdout.isTTY===!0&&process.stdin.isTTY===!0&&qY.supportsColor>=3}function WT(Y){let Z=Y.split(".").pop()?.toLowerCase()||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",json:"json",md:"markdown",css:"css",scss:"scss",html:"html",vue:"vue",svelte:"svelte",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",sh:"bash",bash:"bash",zsh:"bash",yml:"yaml",yaml:"yaml",toml:"toml",xml:"xml",sql:"sql",dockerfile:"dockerfile",docker:"dockerfile",makefile:"makefile",cmake:"cmake",lua:"lua",perl:"perl",php:"php"}[Z]||"text"}function KT(Y){let Z=[],Q=Y.split(`
|
|
957
|
+
`),J=null,z=0,X=0;for(let H of Q){if(H.startsWith("diff --git ")){if(J)Z.push(J);let W=H.match(/diff --git a\/(.+?) b\/(.+)/);if(W)J={fileName:W[2],oldFileName:W[1],newFileName:W[2],lang:WT(W[2]),lines:[]};continue}if(!J)continue;if(H.startsWith("--- ")||H.startsWith("+++ ")){J.lines.push({type:"header",content:H});continue}if(H.startsWith("@@ ")){let W=H.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(W)z=parseInt(W[1],10),X=parseInt(W[2],10);J.lines.push({type:"hunk",content:H});continue}if(H[0]==="+"){J.lines.push({type:"add",content:H.substring(1),newLineNum:X++});continue}if(H[0]==="-"){J.lines.push({type:"delete",content:H.substring(1),oldLineNum:z++});continue}if(H[0]===" "||H===""){J.lines.push({type:"context",content:H[0]===" "?H.substring(1):"",oldLineNum:z++,newLineNum:X++});continue}if(H.match(/^(new file|deleted file|index|Binary|similarity|rename|old mode|new mode)/))J.lines.push({type:"header",content:H})}if(J)Z.push(J);return Z}async function GT(Y,Z,Q,J){let z=new Map;if(Z.size===0)return z;try{let X=J?`${J}/${Y}`:Y,W=(await QY(X,"utf-8")).split(`
|
|
958
|
+
`),K=Math.max(0,Math.min(...Z)-Q),$=Math.min(W.length-1,Math.max(...Z)+Q);for(let G=K;G<=$;G++)z.set(G+1,W[G])}catch{}return z}async function $T(Y,Z,Q){let J=new Map,z=Y.lines.filter((W)=>W.type==="add"||W.type==="delete"||W.type==="context");if(z.length===0)return J;let X=z.filter((W)=>W.type!=="delete"),H=z.filter((W)=>W.type==="delete");try{let W=await HT();if(X.length>0){let K=new Set;X.forEach((G)=>{if(G.newLineNum!==void 0)K.add(G.newLineNum)});let $=await GT(Y.newFileName,K,20,Q);if(D.debug(`Highlighting diff for ${Y.newFileName} with ${z.length} changed lines and ${$.size} lines of context from FS`,"diff-viewer"),$.size>0){let G=Math.min(...$.keys()),U=Math.max(...$.keys()),B=[];for(let O=G;O<=U;O++)B.push($.get(O)||"");let V=(await W.codeToANSI(B.join(`
|
|
959
|
+
`),Y.lang,Z)).split(`
|
|
960
|
+
`);for(let O of X){let N=O.newLineNum;if(N!==void 0){let w=N-G;if(w>=0&&w<V.length)J.set(O,V[w])}}}else{D.debug(`No additional context from FS for ${Y.newFileName}, using what we have from git`,"diff-viewer");let G=X.map((F)=>F.content).join(`
|
|
961
|
+
`),B=(await W.codeToANSI(G,Y.lang,Z)).split(`
|
|
962
|
+
`);for(let F=0;F<X.length;F++)if(B[F])J.set(X[F],B[F])}}if(H.length>0){let K=H.map((U)=>U.content).join(`
|
|
963
|
+
`),G=(await W.codeToANSI(K,Y.lang,Z)).split(`
|
|
964
|
+
`);for(let U=0;U<H.length;U++)if(G[U])J.set(H[U],G[U])}}catch(W){D.error(`Error highlighting diff for ${Y.newFileName}: ${n.from(W)}`,"diff-viewer"),z.forEach((K)=>J.set(K,K.content))}return J}class iV{parsedDiffs=[];renderedLines=[];exitLines=[];options;lastWidth=0;lastHeight=0;logger=new D("diff-renderer");ADDED_BG=gY(Q0.base,Q0.green,0.1);DELETED_BG=gY(Q0.base,Q0.red,0.1);ADDED_GUTTER_BG=gY(Q0.base,Q0.green,0.25);DELETED_GUTTER_BG=gY(Q0.base,Q0.red,0.25);constructor(Y,Z={}){this.logger.debug("Initializing DiffViewerRenderer with options: "+JSON.stringify(Z)),this.options={showLineNumbers:!0,lineNumberWidth:5,wrapLines:!0,showStatus:!0,theme:YX,statusFormat:(Q,J)=>{let z=Math.min(Q+SY()-2,J);return`lines ${Q}-${z} of ${J}`},backgroundColor:Q0.mantle,workingDir:void 0,preambleLines:[],...Z},this.lastWidth=j8(),this.lastHeight=SY(),this.parsedDiffs=this.logger.time("Parsing diff output",()=>KT(Y)),this.updateRenderedLines()}async prepareHighlighting(){for(let Y of this.parsedDiffs){let Z=Y.lines.filter((J)=>J.type==="add"||J.type==="delete"||J.type==="context");if(Z.length===0)continue;let Q=await $T(Y,this.options.theme,this.options.workingDir);Z.forEach((J)=>{let z=Q.get(J);if(z!==void 0)J.highlightedContent=z})}this.updateRenderedLines()}renderLine(Y,Z,Q){let J=[],z=this.options.lineNumberWidth,X=Z-z-4,H=" ",W=Q,K=Q,$=Q0.overlay0;switch(Y.type){case"add":H="+",W=this.ADDED_BG,K=this.ADDED_GUTTER_BG,$=Q0.green;break;case"delete":H="-",W=this.DELETED_BG,K=this.DELETED_GUTTER_BG,$=Q0.red;break;case"context":W=Q0.base;break;case"hunk":return J.push(this.renderHunkHeader(Y.content,Z)),J;case"header":return J.push(this.renderFileHeader(Y.content,Z)),J;default:return J}let G=Y.highlightedContent||Y.content,U=Y.newLineNum??Y.oldLineNum,B=U!==void 0?String(U).padStart(z):" ".repeat(z),F=`${y0(Q0.overlay1)}${B} ${y0($)}${H} `;if(this.options.wrapLines&&P8(G)>X){let O=a(G,X,{mode:"softboundary"}).split(`
|
|
965
|
+
`);for(let N=0;N<O.length;N++){let w=N===0?F:" ".repeat(z+3);J.push(this.padLineWithBg(w+H6(W)+O[N],Z,K))}}else J.push(this.padLineWithBg(F+H6(W)+G,Z,K));return J}padLineWithBg(Y,Z,Q){let J=E8(Y),z=Math.max(0,Z-J.length);return`${H6(Q)}${Y}${" ".repeat(z)}${q()}`}renderHunkHeader(Y,Z){let Q=gY(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ↕ ${y0(Q0.cyan)}${cV.italic(Y)}`,Z,Q)}renderFileHeader(Y,Z){let Q=gY(Q0.crust,Q0.surface0,0.3);return this.padLineWithBg(` ${y0(Q0.overlay1)}${Y}`,Z,Q)}renderFileName(Y,Z,Q){let J=gY(Q0.crust,Q0.surface0,0.3);if(Y===Z)return this.padLineWithBg(` ${y0(Q0.lavender)}${cV.bold(Z)}`,Q,J);return this.padLineWithBg(` ${y0(Q0.yellow)}${Y} -> ${Z}`,Q,J)}renderPreambleLine(Y,Z,Q,J){if(!Y)return[this.padLineWithBg(" ",Z,Q)];Y=" ".repeat(J)+Y;let z=Z,X=y0(Q0.overlay1);if(this.options.wrapLines&&P8(Y)>z)return a(Y,z,{mode:"softboundary",indent:J}).split(`
|
|
966
|
+
`).map((W)=>this.padLineWithBg(X+W,Z,Q));return[this.padLineWithBg(X+Y,Z,Q)]}updateRenderedLines(){this.renderedLines=[],this.exitLines=[];let Y=this.lastWidth,Z=q(),Q=gY(Q0.mantle,Q0.surface0,0.2);if(this.options.preambleLines.length>0){for(let J of this.options.preambleLines)if(this.renderedLines.push(...this.renderPreambleLine(J,Y,Q,3)),J.length===0)this.exitLines.push("");else this.exitLines.push(`${y0(Q0.overlay1)}${J}${Z}`);if(this.parsedDiffs.length>0)this.renderedLines.push(this.padLineWithBg(" ",Y,Q)),this.exitLines.push("")}for(let J=0;J<this.parsedDiffs.length;J++){let z=this.parsedDiffs[J],X=Q;if(J!==0)this.renderedLines.push(this.padLineWithBg(" ",Y,X),this.padLineWithBg(" "+y0(Q0.surface0)+"─".repeat(Y-12),Y,X),this.padLineWithBg(" ",Y,X));this.renderedLines.push(this.renderFileName(z.oldFileName,z.newFileName,Y)),this.exitLines.push(`${y0(Q0.lavender)}${z.newFileName}${Z}`);for(let H of z.lines)if(this.renderedLines.push(...this.renderLine(H,Y,X)),H.type==="add")this.exitLines.push(`${y0(Q0.green)}+ ${H.content}${Z}`);else if(H.type==="delete")this.exitLines.push(`${y0(Q0.red)}- ${H.content}${Z}`);else if(H.type==="context")this.exitLines.push(` ${H.content}`);else if(H.type==="hunk")this.exitLines.push(`${y0(Q0.cyan)}${H.content}${Z}`)}}getLineCount(){return this.renderedLines.length}getLine(Y){return this.renderedLines[Y]||""}render(Y,Z,Q){let J=[],z=H6(this.options.backgroundColor);for(let X=0;X<Z-1;X++){let H=Y+X;J.push(H<this.renderedLines.length?this.renderedLines[H]:`${z}${" ".repeat(Q)}${q()}`)}return J}onResize(Y,Z){if(Y!==this.lastWidth||Z!==this.lastHeight)this.lastWidth=Y,this.lastHeight=Z,this.updateRenderedLines()}getExitLines(){return this.exitLines}}async function Dz(Y,Z={}){if(!M5())return D.warn("Diff viewer is not supported in this environment. Falling back to plain output.","diff-viewer"),dV(Y,{...Z,showLineNumbers:!1});let Q=Y.split(`
|
|
967
|
+
`),J=Q.findIndex((K)=>K.startsWith("diff --git ")),z=J>0?Q.slice(0,J):J===-1?Q:[],X=J===-1?"":Q.slice(Math.max(J,0)).join(`
|
|
968
|
+
`),H=Y.length>1e4?d0({message:"Preparing diff viewer...",interval:10}):void 0;D.time("Preparing diff highlighting");let W=new iV(X,{...Z,preambleLines:z});return await W.prepareHighlighting(),Mz(),W.onResize(j8(),SY()),H?.stop(),D.timeEnd("Preparing diff highlighting","diff-viewer"),Oz(W,Z)}function nV(Y){return/^diff --git a\/.+ b\/.+/m.test(Y)}var cV,lV=null;var aV=R(()=>{z0();z0();u0();pV();T0();$0();k0();W0();cV={bold:(Y)=>`\x1B[1m${Y}\x1B[22m`,italic:(Y)=>`\x1B[3m${Y}\x1B[23m`,underline:(Y)=>`\x1B[4m${Y}\x1B[24m`,dim:(Y)=>`\x1B[2m${Y}\x1B[22m`}});var oV={};L5(oV,{dispatch:()=>Nz});async function Nz(Y,Z={inMacro:!1}){let Q=Y.args,J=Q.slice(0);if(!Z.inMacro){let W=await O5();if(Q[0]&&Q[0]in W){let K=Q[0],$=W[K],G=Q.slice(1);j(q("Dim")+q("Magenta")+`※ ${q("White")+q("Bright")} Executing macro '${K}'...`+q());let{executeMacro:U}=await Promise.resolve().then(() => (D5(),sV));return await U(Y.git$,$,G)}}else{let W=await O5();if(Q[0]&&Q[0]in W)return D.error(`Macro '${Q[0]}' cannot be invoked from inside a macro. Macro composition is not allowed.`,"macro"),1}let z=null,X=">",H=!Q.popOption("--no-enhance");Y:if(Q[0]){let{match:W,candidates:K}=A5(Q[0],IZ);if(W)Q[0]=W;switch(Q[0]){case"s":Q[0]="status";case"status":if(Q.includes("-r")||Q.includes("--recursive"))return await D0.status(Y);break;case"co":Q[0]="checkout";break;case"br":Q[0]="branch";break;case"cmi":Q[0]="commit";case"commit":if(Q[1]==="auto")return await D0.commit.auto(Y);break;case"mg":Q[0]="merge";break;case"pl":case"pu":Q[0]="pull";case"pull":for(let $=1;$<Q.length;$++)if(Q[$]==="-au"){Q[$]="--allow-unrelated-histories";break}break;case"lint":return await D0.lint(Y);case"diff":{let{error:$}=await B2(Q,Y.git$);if($)return 1;let G=await q0();if(H&&G.get("enhancedOutput")&&M5()&&!Q.includes("--stat")&&!Q.includes("-h")&&!Q.includes("--help")&&!Q.includes("--numstat")&&!Q.includes("--name-only")&&!Q.includes("--name-status")){let U=Q.slice(1);try{let B=await S`${Y.git$} -c color.ui=never diff ${U}`;if(B.stdout)return await Dz(B.stdout),0}catch(B){D.info("Failed to get or parse diff output for enhanced diff-view, ignoring: "+n.from(B))}}break}case"show":{let{error:$}=await B2(Q,Y.git$);if($)return 1;let G=await q0();if(H&&G.get("enhancedOutput")&&M5()&&!Q.includes("--stat")&&!Q.includes("-h")&&!Q.includes("--help")&&!Q.includes("--numstat")&&!Q.includes("--name-only")&&!Q.includes("--name-status")&&!Q.hasOption("--format")){let U=Q.slice(1);try{let B=await S`${Y.git$} -c color.ui=never show ${U}`;if(B.stdout&&nV(B.stdout))return await Dz(B.stdout),0}catch(B){D.info("Failed to get show output for enhanced diff-view, ignoring: "+n.from(B))}}break}case"ps":Q[0]="push";case"push":{if(!Q.popOption("--no-lint")){let G=(await q0()).get("lint.onPushBehavior")||"off";if(G==="error"||G==="warning"){if(await D0.lint(Y)!==0)if(G==="error")return D.error("Lint failed. Push aborted.","lint"),1;else j(q("Yellow")+"Lint failed, but proceeding with push (warning mode)."+q())}}Q.spliceOption("-fl",["--force-with-lease"],1);break}case"ad":Q[0]="add";break;case"rv":Q[0]="revert";break;case"rb":Q[0]="rebase";break;case"reset":{Q[0]="reset";for(let G=1;G<Q.length;G++){if(Q[G]==="-h"){Q[G]="--hard";break}if(Q[G]==="-s"){Q[G]="--soft";break}}let{error:$}=await B2(Q,Y.git$);if($)return 1;break}case"log":case"lg":if(Q[0]==="lg"&&Q.length===1)Q.push("--oneline","--graph","--decorate","--all");else if(Q.popOption("export")){let $='--date=format:"%Y-%m-%d %H:%M"';if(!Q.hasOption("--author",1)){let F=Array.isArray(Y.git$)?Y.git$[0]:Y.git$;Q.push("--author="+await O6(F,"user.email"))}let U=Q.indexOf("--relative");if(U>=0)Q.splice(U,1),$='--date=format:"%Y-%m-%d %H:%M" (%ar)';let B=["--all",`--pretty=format:## Commit %h on [%p] - %ad%d
|
|
969
|
+
%s
|
|
970
|
+
|
|
971
|
+
%b
|
|
972
|
+
---
|
|
973
|
+
`,$].filter((F)=>!Q.hasOption(F,1));Q.push(...B),z="gitlog_export.md",X=">"}Q[0]="log";break;case"sta":Q[0]="stash";case"stash":{let $=["apply","pop","list","drop","clear","show","push","save","create","store"],G=A5(Q[1]||"",$,!0);if(G.match)Q[1]=G.match;else{let U=Q.indexOf("--");U=U>=0?U:Q.length;let B=!1;for(let F=1;F<U;F++)if($.includes(Q[F])){B=!0;break}if(!B){let F=Array.isArray(Y.git$)?Y.git$[0]:Y.git$,O=oz(await eq(F),"2.15.0")>=0?"push":"save";Q.splice(1,0,O)}}if(Q[1]==="drop"){let U=Array.isArray(Y.git$)?Y.git$[0]:Y.git$;return await D0.stash.drop(U,Q)}break}case"graph":return D0.graph(Y);case"stats":return D0.stats(Y);case"clear":return D0.clear(Y);case"cache":return D0.cache(Y);case"gdx-config":return D0.gdxConfig(Y);case"gdx-help":case"ghelp":return D0.help(Q[1]);case"nocap":return D0.nocap(Y);case"parallel":return D0.parallel(Y);case"doctor":return D0.doctor();case"macro":return D0.macro(Y);default:if(K&&K.length>1){D.warn(`Ambiguous command '${J[0]}'. Did you mean: ${K.join(", ")}?`);break Y}}}if(Z.inMacro||J.some((W,K)=>Q[K]!==W)){let W=KX((Q.length%6+1)/8.6,0.64,0.5);j(q("Dim")+q(c6(W),"fg")+`$ ${q("White")+q("Bright")}git ${LZ(Q).join(" ")}`+q())}return H2(Y.git$,Q,z,X)}var wz=R(()=>{z0();Lz();W0();k0();M0();FY();$0();D5();T0();WY();aV();k0()});var sV={};L5(sV,{writeMacrosToFile:()=>N5,syncMacrosToCache:()=>Iz,substitutePlaceholders:()=>tV,readMacrosFromFile:()=>E6,isFilePath:()=>jz,getMacrosCachedOrLoad:()=>O5,executeMacro:()=>UT});import qT from"path";async function E6(){try{if(!o(p6))return{};let Y=await QY(p6,"utf-8"),Z=JSON.parse(Y);if(typeof Z!=="object"||Z===null||Array.isArray(Z))return D.warn(`Invalid macro.json format at ${p6}`,"macro"),{};return Z}catch(Y){return D.warn(`Failed to read macro.json: ${n.from(Y).message}`,"macro"),{}}}async function N5(Y){try{let Z=qT.dirname(p6);if(!o(Z))ZY(Z,{recursive:!0});let Q=JSON.stringify(Y,null,2);await z6(p6,Q,"utf-8"),D.debug(`Macros written to ${p6}`,"macro")}catch(Z){throw new n(`Failed to write macro.json: ${n.from(Z).message}`,"MACRO_WRITE_FAILED")}}async function Iz(){let Y=await E6(),Z=await X0();if(Z.isDisabled)throw new n("Cache is disabled. Cannot sync macros to cache.","CACHE_DISABLED");await Z.set(_z,Y,{maxAgeMinutes:rV}),D.debug(`Synced ${Object.keys(Y).length} macros to cache`,"macro")}async function O5(){let Y=await X0();if(Y.isDisabled)return await E6();let Z=await Y.get(_z);if(Z)return D.debug("Using cached macros","macro"),Z;let Q=await E6();return await Y.set(_z,Q,{maxAgeMinutes:rV}),D.debug("Loaded macros from file and cached","macro"),Q}async function UT(Y,Z,Q){let J=Z.split(";").map((X)=>X.trim()).filter((X)=>X.length>0);if(J.length===0)return D.error("Macro script is empty.","macro"),1;let{dispatch:z}=await Promise.resolve().then(() => (wz(),oV));for(let X=0;X<J.length;X++){let H=X===J.length-1,W=nq(J[X]),{substituted:K,notUsedArgs:$}=tV(W,Q);if(H)K.push(...$);if(K.length===0)continue;j(q("Dim")+q("Cyan")+`▶ Executing: ${q("White")+q("Bright")}gdx ${LZ(K).join(" ")}`+q());let G={git$:Y,args:new J1(K)},U=await z(G,{inMacro:!0});if(U!==0)return D.error(`Macro command failed with exit code ${U}`,"macro"),U}return 0}function jz(Y){if(Y.startsWith("./")||Y.startsWith("/"))return!0;if(Y.startsWith(".\\"))return!0;if(/^[a-zA-Z]:[/\\]/.test(Y))return!0;return!1}function tV(Y,Z){let Q=-1,J=new Set(Z),z=Y.map((X,H)=>{return X.replace(/\$(\*|\d+)/g,(W,K)=>{if(K==="*")return Q=H,J.clear(),"";let $=parseInt(K,10)-1;if($>=0&&$<Z.length)return J.delete(Z[$]),Z[$];return W})});if(Q!==-1)z.splice(Q,1,...Z);return{substituted:z,notUsedArgs:Array.from(J)}}var _z="macro.all",rV=1440;var D5=R(()=>{u0();W0();R6();z0();$0();k0();M0();R2()});async function BT(Y){let{args:Z}=Y,Q=Z[1];switch(Q){case"set":return await FT(Y);case"list":return await RT();case"drop":return await MT(Y);case"sync":return await OT();default:return D.error(`Unknown macro subcommand: '${Q}'. Available: set, list, drop, sync`,"macro"),1}}async function VT(){return new Promise((Y,Z)=>{let Q="";if(process.stdin.setEncoding("utf-8"),process.stdin.on("data",(J)=>{Q+=J}),process.stdin.on("end",()=>{Y(Q.trim())}),process.stdin.on("error",(J)=>{Z(J)}),process.stdin.isTTY)Y("")})}async function FT(Y){let{args:Z}=Y,Q=Z[2],J=Z.slice(3);if(!Q)return D.error("Macro name is required. Usage: gdx macro set <name> <script>","macro"),1;let z;if(J.length===0)try{if(z=await VT(),!z)return D.error("Macro script or file path is required. Use: gdx macro set <name> <script> or gdx macro set <name> < file.txt","macro"),1;D.debug("Loaded macro script from stdin","macro")}catch(X){return D.error(`Failed to read from stdin: ${n.from(X).message}`,"macro"),1}else if(J.length===1&&jz(J[0])){let X=J[0];try{if(!o(X))return D.error(`File not found: ${X}`,"macro"),1;z=(await QY(X,"utf-8")).trim(),D.debug(`Loaded macro script from file: ${X}`,"macro")}catch(H){return D.error(`Failed to read file: ${n.from(H).message}`,"macro"),1}}else z=J.join(" ");if(!z)return D.error("Macro script cannot be empty.","macro"),1;try{let X=await E6(),H=Q in X;if(X[Q]=z,await N5(X),await(await X0()).set("macro.all",X,{maxAgeMinutes:1440}),H)j(q("Yellow")+`Macro '${Q}' updated.`+q());else j(q("Green")+`Macro '${Q}' created.`+q());return 0}catch(X){return D.error(`Failed to set macro: ${n.from(X).message}`,"macro"),1}}async function RT(){try{let Y=await E6();await(await X0()).set("macro.all",Y,{maxAgeMinutes:1440});let Q=Object.keys(Y);if(Q.length===0)return j(q("Dim")+"No macros defined."+q()),0;j(q("Cyan")+q("Bright")+"Macros:"+q());for(let J of Q.sort()){let z=Y[J],H=(z.length>80?z.substring(0,77)+"...":z).replace(/\s+/g," ");j(` ${q("Green")}${J}${q()}: ${q("Dim")}${H}${q()}`)}return 0}catch(Y){return D.error(`Failed to list macros: ${n.from(Y).message}`,"macro"),1}}async function MT(Y){let{args:Z}=Y,Q=Z[2];if(!Q)return D.error("Macro name is required. Usage: gdx macro drop <name>","macro"),1;try{let J=await E6();if(!(Q in J))return D.error(`Macro '${Q}' not found.`,"macro"),1;return delete J[Q],await N5(J),await(await X0()).set("macro.all",J,{maxAgeMinutes:1440}),j(q("Yellow")+`Macro '${Q}' deleted.`+q()),0}catch(J){return D.error(`Failed to drop macro: ${n.from(J).message}`,"macro"),1}}async function OT(){try{return await Iz(),j(q("Green")+"Macros synced to cache."+q()),0}catch(Y){let Z=n.from(Y);if(Z.code==="CACHE_DISABLED")D.error("Cache is disabled. Cannot sync macros.","macro");else D.error(`Failed to sync macros: ${Z.message}`,"macro");return 1}}var YF,eV;var Tz=R(()=>{D5();z0();$0();M0();R6();u0();YF=BT,eV={$root:{set:{},list:{},drop:{},sync:{}}}});function DT(Y){if(!Y||typeof Y!=="object"||Array.isArray(Y))return!1;return!0}async function Cz(Y,Z){let Q=Y,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Z)}catch{return{}}J+=1}if(Array.isArray(Q)||DT(Q))return Q;return{}}async function ZF(Y,Z){if(!Y)return[];let Q=Y,J=0;while(typeof Q==="function"&&J<3){try{Q=await Q(Z)}catch{return[]}J+=1}return Array.isArray(Q)?Q:[]}async function QF(Y,Z){if(Array.isArray(Y))return{children:{},anyOf:new Set(Y),allOf:new Set};let Q={},J=new Set(await ZF(Y.$anyOf,Z)),z=new Set(await ZF(Y.$allOf,Z));for(let[X,H]of Object.entries(Y)){if(X==="$allOf"||X==="$anyOf"||!H)continue;Q[X]=H}return{children:Q,anyOf:J,allOf:z}}async function JF(Y,Z,Q,J){let z=Q.$root,X=new Set,H=new Set,W=!1,K=Z,$=(O,N)=>({git$:J.git$,args:Y,index:O,cursorIndex:K,mode:N});for(let O=0;O<Z;O++){let N=Y[O];if(!N)continue;z=await Cz(z,$(O,"history"));let w=await QF(z,$(O,"history"));if(N in w.children){for(let I of w.allOf)X.add(I);z=await Cz(w.children[N],$(O,"history")),W=!1;continue}if(w.anyOf.has(N)){if(W)return{completions:[]};W=!0;continue}if(w.allOf.has(N)){if(H.has(N))return{completions:[]};H.add(N);continue}if(X.has(N)){if(H.has(N))return{completions:[]};H.add(N);continue}if(N.startsWith("-"))return{completions:[]}}z=await Cz(z,$(Z,"suggest"));let G=await QF(z,$(Z,"suggest")),U=new Set;for(let O of Object.keys(G.children))U.add(O);if(!W)for(let O of G.anyOf)U.add(O);let B=new Set([...G.allOf,...X]);for(let O of B)if(!H.has(O))U.add(O);let F=Y[Z]||"";return{completions:Array.from(U).filter((O)=>O.startsWith(F)&&O!==F.trim()).sort((O,N)=>O.length-N.length||O.localeCompare(N))}}var kz,zF,XF;var HF=R(()=>{U5();q5();F5();$5();W4();Rz();B5();Q5();G5();V2();M2();V5();Tz();kz={cache:jV,clear:LV,doctor:hV,"gdx-config":FV,graph:wU,help:gV,lint:vV,nocap:ZV,parallel:BV,stash:RU,stats:IU,status:fV,macro:eV},zF=["s","st","co","br","cmi","mg","pl","pu","ps","ad","rv","rb","lg","sta"],XF=["--loglevel","--ghelp","--bypass"]});function NT(Y){let Z=process.env.GDX_CMP_IDX,Q=Number.parseInt(Z||"",10);if(!Number.isInteger(Q)||Q<0)Q=Math.max(0,Y-1);if(Y>0&&Q>=Y)Q=Y-1;return Q}async function Az(Y){let Z=l.logLevel;l.logLevel="off";try{let Q=[...Y.args];if(Q[0]==="__completion")Q.shift();let J=NT(Q.length);if(D.debug(`Completion invoked with args: ${Q.join(" ")} (idx=${J})`,"completion"),Q.length===0||J===0){let W=Q[0]||"",K=new Set;for(let G of Object.keys(kz))K.add(G);for(let G of zF)K.add(G);for(let G of XF)K.add(G);for(let G of IZ)K.add(G);let $=Array.from(K).filter((G)=>G.startsWith(W)).sort((G,U)=>G.length-U.length||G.localeCompare(U));D.debug(`Completion root-level matches: ${$.join(", ")}`,"completion");for(let G of $)process.stdout.write(`${G}
|
|
974
|
+
`);return 0}let z=Q[0],X=Q.slice(1),H=kz[z];if(H){let W=J-1;if(W>=0&&W<X.length){let{completions:K}=await JF(X,W,H,{git$:Y.git$});D.debug(`Completion matches for command '${z}': ${K.join(", ")}`,"completion");for(let $ of K)process.stdout.write(`${$}
|
|
975
|
+
`);return 0}}return D.debug(`No completion structure for command '${z}', or index out of range`,"completion"),0}finally{l.logLevel=Z}}var WF=R(()=>{C0();W0();$0();HF()});var D0;var Lz=R(()=>{Rz();V2();W4();M2();q5();U5();Xz();$5();Q5();G5();B5();F5();V5();Tz();WF();D0={__completion:Az,help:R5,stash:VU,graph:H4,stats:z9,clear:Wz,cache:Kz,commit:OV,gdxConfig:zz,nocap:Qz,parallel:Jz,lint:qz,doctor:Fz,status:Bz,macro:YF}});z0();Lz();k0();M0();R2();W0();var wT=(Y="gdx")=>{return`# gdx shell integration
|
|
781
976
|
${Y}() {
|
|
782
977
|
local tmp
|
|
783
978
|
tmp="$(mktemp)"
|
|
784
979
|
GDX_RESULT="$tmp" command gdx "$@"
|
|
785
980
|
local ret=$?
|
|
786
|
-
if [ $ret -eq ${
|
|
981
|
+
if [ $ret -eq ${m6} ]; then
|
|
787
982
|
if [ -f "$tmp" ]; then
|
|
788
983
|
cd "$(cat "$tmp")"
|
|
789
984
|
fi
|
|
@@ -832,13 +1027,13 @@ __gdx_complete_bash() {
|
|
|
832
1027
|
}
|
|
833
1028
|
|
|
834
1029
|
complete -o bashdefault -o default -F __gdx_complete_bash ${Y}
|
|
835
|
-
`},
|
|
1030
|
+
`},LT=(Y="gdx")=>{return`# gdx shell integration
|
|
836
1031
|
${Y}() {
|
|
837
1032
|
local tmp
|
|
838
1033
|
tmp="$(mktemp)"
|
|
839
1034
|
GDX_RESULT="$tmp" command gdx "$@"
|
|
840
1035
|
local ret=$?
|
|
841
|
-
if [ $ret -eq ${
|
|
1036
|
+
if [ $ret -eq ${m6} ]; then
|
|
842
1037
|
if [ -f "$tmp" ]; then
|
|
843
1038
|
cd "$(cat "$tmp")"
|
|
844
1039
|
fi
|
|
@@ -887,13 +1082,13 @@ if ! (( $+functions[compdef] )); then
|
|
|
887
1082
|
fi
|
|
888
1083
|
|
|
889
1084
|
compdef __gdx_complete_zsh ${Y}
|
|
890
|
-
`},
|
|
1085
|
+
`},_T=(Y="gdx")=>{return`# gdx shell integration
|
|
891
1086
|
function ${Y}
|
|
892
1087
|
set -l tmp (mktemp)
|
|
893
1088
|
set -x GDX_RESULT "$tmp"
|
|
894
1089
|
command gdx $argv
|
|
895
1090
|
set -l ret $status
|
|
896
|
-
if test $ret -eq ${
|
|
1091
|
+
if test $ret -eq ${m6}
|
|
897
1092
|
if test -f "$tmp"
|
|
898
1093
|
cd (cat "$tmp")
|
|
899
1094
|
end
|
|
@@ -934,7 +1129,7 @@ complete -c ${Y} -w git
|
|
|
934
1129
|
|
|
935
1130
|
# Then add gdx-specific completions (they take precedence)
|
|
936
1131
|
complete -c ${Y} -f -a "(__gdx_complete_fish)"
|
|
937
|
-
`},
|
|
1132
|
+
`},IT=(Y="gdx")=>{return`# gdx shell integration
|
|
938
1133
|
function ${Y} {
|
|
939
1134
|
$tmp = [System.IO.Path]::GetTempFileName()
|
|
940
1135
|
$env:GDX_RESULT = $tmp
|
|
@@ -945,7 +1140,7 @@ function ${Y} {
|
|
|
945
1140
|
}
|
|
946
1141
|
if ($command) {
|
|
947
1142
|
& $command @args
|
|
948
|
-
if ($LASTEXITCODE -eq ${
|
|
1143
|
+
if ($LASTEXITCODE -eq ${m6}) {
|
|
949
1144
|
if (Test-Path $tmp) {
|
|
950
1145
|
$target = Get-Content $tmp -Raw
|
|
951
1146
|
if ($target) {
|
|
@@ -1015,10 +1210,4 @@ $__gdxCompleter = {
|
|
|
1015
1210
|
}
|
|
1016
1211
|
|
|
1017
1212
|
Register-ArgumentCompleter -Native -CommandName ${Y} -ScriptBlock $__gdxCompleter
|
|
1018
|
-
`},
|
|
1019
|
-
%s
|
|
1020
|
-
|
|
1021
|
-
%b
|
|
1022
|
-
---
|
|
1023
|
-
`,z].filter((R)=>!Z.hasOption(R,1));Z.push(...V),$="gitlog_export.md",G=">"}Z[0]="log";break;case"sta":Z[0]="stash";case"stash":{let z=["apply","pop","list","drop","clear","show","push","save"],q=h2(Z[1]||"",z,!0);if(q.match)Z[1]=q.match;else{let V=Z.indexOf("--");V=V>=0?V:Z.length;let R=!1;for(let B=1;B<V;B++)if(z.includes(Z[B])){R=!0;break}if(!R){let M=M$(await d$(Q),"2.15.0")>=0?"push":"save";Z.splice(1,0,M)}}if(Z[1]==="drop")return await L0.stash.drop(Q,Z);break}case"graph":return L0.graph(Y);case"stats":return L0.stats(Y);case"clear":return L0.clear(Y);case"gdx-config":return L0.gdxConfig(Y);case"gdx-help":case"ghelp":return L0.help(Z[1]);case"nocap":return L0.nocap(Y);case"parallel":return L0.parallel(Y);case"doctor":return L0.doctor();default:if(W&&W.length>1){P.warn(`Ambiguous command '${J}'. Did you mean: ${W.join(", ")}?`);break Y}}}if(Z[0]!==J)k(U("Cyan")+`Command auto expanded to: git ${F$(Z).join(" ")}`+U());let K=0;try{if($){let{exitCode:H}=await c0({stdout:{file:$,append:G===">>"},stderr:"inherit"})`${Q} ${Z}`;K=H}else{let{exitCode:H}=await Z0`${Q} ${Z}`;K=H}}catch(H){let W=X0.from(H);if(W.name===bY.name&&W.message.startsWith("Command failed"))return K||1;return P.error(`Command failed.
|
|
1024
|
-
`+s(W,{color:!0})),1}return K??0}(async()=>{try{let Y=await ZD();if(p.finalStringOutput)k(p.finalStringOutput);process.exit(p.exitCodeOverride>=0?p.exitCodeOverride:Y)}catch(Y){P.error(s(Y,{color:!0})),process.exit(1)}})();
|
|
1213
|
+
`},KF=(Y,Z)=>{switch(Y.toLowerCase()){case"bash":return wT(Z);case"zsh":return LT(Z);case"fish":return _T(Z);case"powershell":case"pwsh":return IT(Z);default:throw Error("Unsupported shell: ${shell}`")}};C0();$0();wz();var jT=process.argv.slice(2);async function TT(){let Y={args:new J1(jT),git$:""},Z=Y.args;if(Z[0]==="--init"){let z=Z.popValue("--shell")||Z.popValue("--init"),X=Z.popValue("--cmd");if(z)try{let H=KF(z,X||void 0);return j(H),0}catch(H){return D.error(d(H,{color:!0})),1}else return D.error("<shell-name> is not specified. --init <shell-name> is required for initialization."),1}if(Z[0]==="__completion")return await D0.__completion({...Y,git$:"git"});let Q=await M6("git");if(!Q)throw new n("Git is not installed or not found in PATH.","GIT_NOT_FOUND");if(Y.git$=Q,Z[0]==="--bypass")return H2(Q,Z.slice(1));let J=Z.popValue("--loglevel");if(J){let z=["fatal","error","warn","info","debug"];if(z.includes(J))l.logLevel=J;else return D.error(`Invalid log level '${J}'. Expected: ${z.join(", ")}`),1}if(Z.includes("--ghelp")||Z.includes("-gh")||Z.includes("--gdx-help")||Z.length===0)return D0.help(),0;return Nz(Y)}(async()=>{try{let Y=await TT();if(l.finalStringOutput)j(l.finalStringOutput);process.exit(l.exitCodeOverride>=0?l.exitCodeOverride:Y)}catch(Y){D.error(d(Y,{color:!0})),process.exit(1)}})();
|